Odoo GraphQL Subscription using Node, Express JS for Sample
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
13 KiB

5 months ago
{"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 = /** @class */ (function () {\n function RenderPromises() {\n // Map from Query component instances to pending fetchData promises.\n this.queryPromises = new Map();\n // Two-layered map from (query document, stringified variables) to QueryInfo\n // objects. These QueryInfo objects are intended to survive through the whole\n // getMarkupFromTree process, whereas specific Query instances do not survive\n // beyond a single call to renderToStaticMarkup.\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 // Registers the server side rendered observable.\n RenderPromises.prototype.registerSSRObservable = function (observable) {\n if (this.stopped)\n return;\n this.lookupQueryInfo(observable.options).observable = observable;\n };\n // Get's the cached observable that matches the SSR Query instances query and variables.\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 // Render null to abandon this subtree for this rendering, so that we\n // can wait for the data to arrive.\n return null;\n }\n }\n return finish ? finish() : null;\n };\n RenderPromises.prototype.addObservableQueryPromise = function (obsQuery) {\n return this.addQueryPromise({\n // The only options which seem to actually be used by the\n // RenderPromises class are query and variables.\n getOptions: function () { return obsQuery.options; },\n fetchData: function () {\n 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 };\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 // Make sure we never try to call fetchData for this query document and\n // these variables again. Since the queryInstance objects change with\n // every rendering, deduplicating them by query and variables is the\n // best we can do. If a different Query component happens to have the\n // same query document and variables, it will be immediately rendered\n // by calling finish() in addQueryPromise, which could result in the\n //