1 | {"version":3,"file":"ssr.cjs","sources":["RenderPromises.js","getDataFromTree.js","renderToStringWithData.js"],"sourcesContent":["function makeDefaultQueryInfo() {\n return {\n seen: false,\n observable: null\n };\n}\nvar RenderPromises = (function () {\n function RenderPromises() {\n this.queryPromises = new Map();\n this.queryInfoTrie = new Map();\n this.stopped = false;\n }\n RenderPromises.prototype.stop = function () {\n if (!this.stopped) {\n this.queryPromises.clear();\n this.queryInfoTrie.clear();\n this.stopped = true;\n }\n };\n RenderPromises.prototype.registerSSRObservable = function (observable) {\n if (this.stopped)\n return;\n this.lookupQueryInfo(observable.options).observable = observable;\n };\n RenderPromises.prototype.getSSRObservable = function (props) {\n return this.lookupQueryInfo(props).observable;\n };\n RenderPromises.prototype.addQueryPromise = function (queryInstance, finish) {\n if (!this.stopped) {\n var info = this.lookupQueryInfo(queryInstance.getOptions());\n if (!info.seen) {\n this.queryPromises.set(queryInstance.getOptions(), new Promise(function (resolve) {\n resolve(queryInstance.fetchData());\n }));\n return null;\n }\n }\n return finish ? finish() : null;\n };\n RenderPromises.prototype.addObservableQueryPromise = function (obsQuery) {\n return this.addQueryPromise({\n getOptions: function () { return obsQuery.options; },\n fetchData: function () { return new Promise(function (resolve) {\n var sub = obsQuery.subscribe({\n next: function (result) {\n if (!result.loading) {\n resolve();\n sub.unsubscribe();\n }\n },\n error: function () {\n resolve();\n sub.unsubscribe();\n },\n complete: function () {\n resolve();\n },\n });\n }); },\n });\n };\n RenderPromises.prototype.hasPromises = function () {\n return this.queryPromises.size > 0;\n };\n RenderPromises.prototype.consumeAndAwaitPromises = function () {\n var _this = this;\n var promises = [];\n this.queryPromises.forEach(function (promise, queryInstance) {\n _this.lookupQueryInfo(queryInstance).seen = true;\n promises.push(promise);\n });\n this.queryPromises.clear();\n return Promise.all(promises);\n };\n RenderPromises.prototype.lookupQueryInfo = function (props) {\n var queryInfoTrie = this.queryInfoTrie;\n var query = props.query, variables = props.variables;\n var varMap = queryInfoTrie.get(query) || new Map();\n if (!queryInfoTrie.has(query))\n queryInfoTrie.set(query, varMap);\n var variablesString = JSON.stringify(variables);\n var info = varMap.get(variablesString) || makeDefaultQueryInfo();\n if (!varMap.has(variablesString))\n varMap.set(variablesString, info);\n return info;\n };\n return RenderPromises;\n}());\nexport { RenderPromises };\n//# sourceMappingURL=RenderPromises.js.map","import { __assign } from \"tslib\";\nimport * as React from 'react';\nimport { getApolloContext } from '../context';\nimport { RenderPromises } from './RenderPromises';\nimport { renderToStaticMarkup } from 'react-dom/server';\nexport function getDataFromTree(tree, context) {\n if (context === void 0) { context = {}; }\n return getMarkupFromTree({\n tree: tree,\n context: context,\n renderFunction: renderToStaticMarkup\n });\n}\nexport function getMarkupFromTree(_a) {\n var tree = _a.tree, _b = _a.context, context = _b === void 0 ? {} : _b, _c = _a.renderFunction, renderFunction = _c === void 0 ? renderToStaticMarkup : _c;\n var renderPromises = new RenderPromises();\n function process() {\n var ApolloContext = getApolloContext();\n return new Promise(function (resolve) {\n var element = React.createElement(ApolloContext.Provider, { value: __assign(__assign({}, context), { renderPromises: renderPromises }) }, tree);\n resolve(renderFunction(element));\n }).then(function (html) {\n return renderPromises.hasPromises()\n ? renderPromises.consumeAndAwaitPromises().then(process)\n : html;\n }).finally(function () {\n renderPromises.stop();\n });\n }\n return Promise.resolve().then(process);\n}\n//# sourceMappingURL=getDataFromTree.js.map","import { getMarkupFromTree } from './getDataFromTree';\nimport { renderToString } from 'react-dom/server';\nexport function renderToStringWithData(component) {\n return getMarkupFromTree({\n tree: component,\n renderFunction: renderToString\n });\n}\n//# sourceMappingURL=renderToStringWithData.js.map"],"names":["renderToStaticMarkup","context","getApolloContext","React","__assign","renderToString"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,oBAAoB,GAAG;AAChC,IAAI,OAAO;AACX,QAAQ,IAAI,EAAE,KAAK;AACnB,QAAQ,UAAU,EAAE,IAAI;AACxB,KAAK,CAAC;AACN,CAAC;AACE,IAAC,cAAc,IAAI,YAAY;AAClC,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