@jetshop/core 1.1.13-no-proxy.4 → 1.1.13-no-proxy.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -79,6 +79,11 @@ export default function createApolloServer({ apolloConfig, extensions = [] }) {
79
79
  schemas,
80
80
  resolvers
81
81
  });
82
+ const engine = apolloConfig.engineApiKey
83
+ ? {
84
+ apiKey: apolloConfig.engineApiKey
85
+ }
86
+ : false;
82
87
  const apolloServer = new ApolloServer({
83
88
  schema,
84
89
  // Disable introspection in production
@@ -93,13 +98,9 @@ export default function createApolloServer({ apolloConfig, extensions = [] }) {
93
98
  persistedQueries: {
94
99
  cache: new InMemoryLRUCache()
95
100
  },
96
- // Enable tracing if Apollo Engine is configured
97
- tracing: !!apolloConfig.engineApiKey,
101
+ tracing: false,
98
102
  cacheControl: true,
99
- // By setting this to "false", we avoid using Apollo Server 2's
100
- // integrated metric reporting and fall-back to using the Apollo
101
- // Engine Proxy (running separately) for metric collection.
102
- engine: false
103
+ engine
103
104
  });
104
105
  return { apolloServer, schema };
105
106
  });
@@ -1 +1 @@
1
- {"version":3,"file":"createApolloServer.js","sourceRoot":"","sources":["createApolloServer.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,0BAA0B,EAC1B,YAAY,EAEb,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,KAAK,MAAM,YAAY,CAAC;AAG/B,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,4BAA4B,EAAE,MAAM,uDAAuD,CAAC;AACrG,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,MAAM,GAAG,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;AAClC,MAAM,IAAI,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AACpC,MAAM,KAA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D,IAAI,MAAM,CAAC,SAAS,EAAE;gBACpB,KAAK,CAAC,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;aACpC;SACF;QAED,MAAM,MAAM,GAAG,YAAY,CAAC;YAC1B,OAAO;YACP,SAAS;SACV,CAAC,CAAC;QAEH,MAAM,MAAM,GAAG,YAAY,CAAC,YAAY;YACtC,CAAC,CAAC;gBACE,MAAM,EAAE,YAAY,CAAC,YAAY;aAClC;YACH,CAAC,CAAC,KAAK,CAAC;QAEV,MAAM,YAAY,GAAG,IAAI,YAAY,CAAC;YACpC,MAAM;YACN,sCAAsC;YACtC,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY;YACpD,OAAO,EAAE,CAAC,EAAE,GAAG,EAAqB,EAAW,EAAE;gBAC/C,MAAM,eAAe,GAAwB,GAAG,CAAC,GAAG,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;gBACrE,MAAM,OAAO,GAAyB,IAAI,CACxC,eAAe,EACf,gBAAgB,CACjB,CAAC;gBAEF,OAAO;oBACL,OAAO;iBACR,CAAC;YACJ,CAAC;YACD,gBAAgB,EAAE;gBAChB,KAAK,EAAE,IAAI,gBAAgB,EAAE;aAC9B;YACD,OAAO,EAAE,KAAK;YACd,YAAY,EAAE,IAAI;YAClB,MAAM;SACP,CAAC,CAAC;QAEH,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC;IAClC,CAAC;CAAA"}
@@ -19,7 +19,6 @@ export const createDevServer = ({ apolloConfig, port, schemaExtensions }) => __a
19
19
  });
20
20
  apolloServer.applyMiddleware({ app: app });
21
21
  const { port: listenPort } = yield listen({
22
- apolloConfig,
23
22
  app,
24
23
  port
25
24
  });
@@ -1 +1 @@
1
- {"version":3,"file":"createDevServer.js","sourceRoot":"","sources":["createDevServer.ts"],"names":[],"mappings":";;;;;;;;AACA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,kBAAwC,MAAM,sBAAsB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AAgB;KAC7B,CAAC,CAAC;IAEH,YAAY,CAAC,eAAe,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;IAE3C,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,MAAM,MAAM,CAAC;QACxC,GAAG;QACH,IAAI;KACL,CAAC,CAAC;IAEH,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC;AAC5C,CAAC,CAAA,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -21,5 +21,5 @@ export interface RendererOptions {
21
21
  declare const createRenderer: (template: string, tree: React.ReactElement<any>, options: RendererOptions) => (req: Request & {
22
22
  universalCookies: any;
23
23
  breakpoint: string;
24
- }, res: Response) => Promise<void>;
24
+ }, res: Response) => Promise<void | Response>;
25
25
  export default createRenderer;
@@ -13,22 +13,23 @@ import { getSelectedChannel, getGeoRedirect } from '@jetshop/core/components/Cha
13
13
  import { channelsQuery } from '@jetshop/core/data/queries';
14
14
  import { setupIntl } from '@jetshop/intl/config';
15
15
  import IntlContext from '@jetshop/intl/context';
16
- import { renderStylesToString } from 'emotion-server';
16
+ import { renderStylesToNodeStream } from 'emotion-server';
17
17
  import get from 'lodash.get';
18
18
  import React from 'react';
19
- import { ApolloProvider, getMarkupFromTree } from 'react-apollo';
19
+ import { ApolloProvider, getDataFromTree } from 'react-apollo';
20
20
  import { CookiesProvider } from 'react-cookie';
21
+ import { renderToNodeStream } from 'react-dom/server';
21
22
  import { HelmetProvider } from 'react-helmet-async';
22
23
  import Loadable from 'react-loadable';
23
24
  import { MediaProvider } from 'react-media-universal';
24
25
  import { StaticRouter } from 'react-router-dom';
26
+ import report from '../../errorReporting';
25
27
  import { createPolyfill } from '../../polyfills';
26
28
  import { createClient } from '../apollo';
27
29
  import AuthProvider from '../../components/AuthContext/AuthProvider';
28
30
  import { getPrefetchFiles, getPrefetchHeader, getPreloadLinksAndScripts } from './getPrefetchFiles';
29
- import { renderToString } from 'react-dom/server';
30
31
  const injectDataIntoSlots = (template, data) => Object.keys(data).reduce((output, key) => output.replace(`<slot name="${key}"/>`, data[key]), template);
31
- const wrapTree = (tree, req, renderOptions, client, selectedChannel, channels, translator, locale) => {
32
+ const wrapTree = (tree, req, renderOptions, client, selectedChannel, channels, translator, locale) => __awaiter(this, void 0, void 0, function* () {
32
33
  const modules = [];
33
34
  const routerContext = { url: null, statusCode: 200 };
34
35
  const helmetContext = { helmet: null };
@@ -53,30 +54,53 @@ const wrapTree = (tree, req, renderOptions, client, selectedChannel, channels, t
53
54
  React.createElement(ChannelProvider, { channels: channels, selectedChannel: selectedChannel },
54
55
  React.createElement(StaticRouter, { location: req.originalUrl, context: routerContext },
55
56
  React.createElement(AuthProvider, null, tree))))))))))));
57
+ try {
58
+ yield getDataFromTree(wrappedTree);
59
+ }
60
+ catch (e) {
61
+ // Don't log to Sentry here as we're already logging query errors in a
62
+ // middleware and JS errors further down in `handleError` and then
63
+ // again on the client if it fails to recover
64
+ console.error('Apollo data fetch failed:', e);
65
+ routerContext.statusCode = 500;
66
+ }
67
+ // Serialize the apollo state for client side rehydration. The html comment
68
+ // (inside js comments) is intentional and prevents inline script tags
69
+ // inside the extracted state from closing this script tag prematurely
70
+ const apolloState = `<script>/*<!--*/
71
+ window.__APOLLO_STATE__=${JSON.stringify(client.extract())};
72
+ /*-->*/</script>`;
56
73
  return {
57
74
  wrappedTree,
58
75
  modules,
59
- routerContext: routerContext,
60
- helmetContext: helmetContext,
76
+ routerUrl: routerContext.url,
77
+ statusCode: routerContext.statusCode,
78
+ helmet: helmetContext.helmet,
79
+ apolloState,
61
80
  polyfill: createPolyfill(locale)
62
81
  };
63
- };
82
+ });
64
83
  const startResponse = ({ res, head, statusCode }) => {
65
84
  res.status(statusCode);
66
85
  // write head and don't end response
67
86
  res.write(head);
68
87
  };
69
- const endResponse = ({ res, client, foot }) => {
70
- // Serialize the apollo state for client side rehydration. The html comment
71
- // (inside js comments) is intentional and prevents inline script tags
72
- // inside the extracted state from closing this script tag prematurely
73
- const apolloState = `<script>/*<!--*/
74
- window.__APOLLO_STATE__=${JSON.stringify(client.extract())};
75
- /*-->*/</script>`;
76
- res.write(apolloState);
88
+ const endResponse = ({ res, foot }) => {
77
89
  res.write(foot);
78
90
  res.end();
79
91
  };
92
+ const handleError = ({ streamName, res, foot }) => (error) => {
93
+ report(error, { reason: streamName });
94
+ console.error(`Error in stream "${streamName}":`, error);
95
+ // we need to make sure that res.write gets a string
96
+ // cause if it does not get a string/buffer it will cause
97
+ // the server to crash
98
+ // error can be literally anything, not limited to Error,
99
+ // which means the key message could be missing
100
+ const chunk = (error && error.message) || '' + error;
101
+ res.write(chunk);
102
+ endResponse({ res, foot });
103
+ };
80
104
  const createRenderer = (template, tree, options) => (req, res) => __awaiter(this, void 0, void 0, function* () {
81
105
  const { apolloConfig, preloadStats, intl } = options;
82
106
  // Set response headers immediately
@@ -98,25 +122,9 @@ const createRenderer = (template, tree, options) => (req, res) => __awaiter(this
98
122
  defaultLocale: intl.defaultLocale,
99
123
  options: intl.options
100
124
  });
101
- const { wrappedTree, modules, routerContext, helmetContext, polyfill } = wrapTree(tree, req, options, client, selectedChannel, channels, translator, locale);
102
- let statusCode;
103
- let response;
104
- try {
105
- response = yield getMarkupFromTree({
106
- tree: wrappedTree,
107
- renderFunction: tree => renderStylesToString(renderToString(tree))
108
- });
109
- }
110
- catch (e) {
111
- // Don't log to Sentry here as we're already logging query errors in a
112
- // middleware and JS errors further down in `handleError` and then
113
- // again on the client if it fails to recover
114
- console.error('Apollo data fetch failed:', e);
115
- response = e;
116
- statusCode = 500;
117
- }
118
- if (routerContext.url) {
119
- return res.redirect(301, routerContext.url);
125
+ const { wrappedTree, modules, routerUrl, statusCode, helmet: { title, meta }, apolloState, polyfill } = yield wrapTree(tree, req, options, client, selectedChannel, channels, translator, locale);
126
+ if (routerUrl) {
127
+ return res.redirect(301, routerUrl);
120
128
  }
121
129
  const prefetchFiles = getPrefetchFiles({
122
130
  locale,
@@ -129,21 +137,28 @@ const createRenderer = (template, tree, options) => (req, res) => __awaiter(this
129
137
  }
130
138
  const { preloadLinks, preloadScripts } = getPreloadLinksAndScripts(prefetchFiles);
131
139
  const data = {
140
+ apolloState,
132
141
  polyfill,
133
142
  preloadLinks,
134
143
  preloadScripts,
135
- title: helmetContext.helmet.title.toString(),
136
- meta: helmetContext.helmet.meta.toString()
144
+ title: title.toString(),
145
+ meta: meta.toString()
137
146
  };
138
147
  const html = injectDataIntoSlots(template, data);
139
148
  const [head, foot] = html.split('<slot name="html"/>');
140
- startResponse({
141
- res,
142
- head,
143
- statusCode: statusCode || routerContext.statusCode
149
+ startResponse({ res, head, statusCode });
150
+ // create node stream
151
+ const stream = renderToNodeStream(wrappedTree)
152
+ .on('error', handleError({ streamName: 'React NodeStream', res, foot }))
153
+ // pipe it to emotion-server node stream
154
+ .pipe(renderStylesToNodeStream())
155
+ .on('error', handleError({ streamName: 'Styles', res, foot }))
156
+ // on node stream end, write the foot part of the html and end the response
157
+ .on('end', () => {
158
+ endResponse({ res, foot });
144
159
  });
145
- res.write(response);
146
- endResponse({ res, client, foot });
160
+ // then pipe it to response, and tell it to not end the response
161
+ return stream.pipe(res, { end: false });
147
162
  });
148
163
  export default createRenderer;
149
164
  //# sourceMappingURL=createRenderer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"createRenderer.js","sourceRoot":"","sources":["createRenderer.tsx"],"names":[],"mappings":";;;;;;;;AAAA,OAAO,iBAAiB,MAAM,2CAA2C,CAAC;AAE1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAC1E,OAAO,EACL,kBAAkB,EAClB,cAAc,EACf,MAAM,+CAA+C,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,WAAW,MAAM,uBAAuB,CAAC;AACh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kBAAkB,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;QAExE,wCAAwC;SACvC,IAAI,CAAC,wBAAwB,EAAE,CAAC;SAChC,EAAE,CAAC,OAAO,EAAE,WAAW,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;QAE9D,2EAA2E;SAC1E,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE;QACd,WAAW,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;IAEL,gEAAgE;IAChE,OAAO,MAAM,CAAC,IAAI,CAChB,GAAG,EACH,EAAE,GAAG,EAAE,KAAK,EAAE,CACf,CAAC;AACJ,CAAC,CAAA,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -44,7 +44,7 @@ const boot = (Component, { apolloConfig, trackingID, tagManagerID, sentryServerD
44
44
  });
45
45
  app.use(asyncErrorHandler(renderer));
46
46
  const port = parseInt(process.env.PORT, 10) || 3000;
47
- yield listen({ app, port, apolloConfig });
47
+ yield listen({ app, port });
48
48
  console.log(`🚀 App ready at http://localhost:${port}`);
49
49
  });
50
50
  export default boot;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,OAAO,kBAAkB,MAAM,oCAAoC,CAAC;AAEpE,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,MAAM,MAAM,UAAU,CAAC;AAG9B,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AAEpD,OAAO,KAAK,MAAM,qCAAqC,CAAC;AAExD,8EAA8E;AAC9E,iGAAiG;AACjG,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,IAAI,CAAC,WAAW,CAA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ptions {
4
3
  app: ExpressApp;
5
4
  port: number;
6
- apolloConfig: ApolloConfig;
7
5
  }
8
6
  /**
9
7
  * - Starts listening to `port`
10
- * - Wraps Express server in Apollo Engine if `apolloConfig.engineApiKey` is set
11
8
  */
12
9
  declare const listen: ({ app, port }: ListenOptions) => Promise<{
13
10
  port: number;
@@ -1,6 +1,5 @@
1
1
  /**
2
2
  * - Starts listening to `port`
3
- * - Wraps Express server in Apollo Engine if `apolloConfig.engineApiKey` is set
4
3
  */
5
4
  const listen = ({ app, port }) => new Promise((resolve, reject) => {
6
5
  const http = app.listen({ port }, (err) => {
@@ -1 +1 @@
1
- {"version":3,"file":"listen.js","sourceRoot":"","sources":["listen.ts"],"names":[],"mappings":"AASA;;;GAGG;AACH,MAAM,MAAM,GAAG,CAAC,EAAE,GAAG,EAAE,IAAI,EAAiB,EAA6B,EAAE,CACzE,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;IAC9B,MAAM,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC,GAAW,EAAE,EAAE;QAChD,GAAG;YACD,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;YACb,CAAC,CAAC,OAAO,CAAC;gBACN,IAAI,EAAG,IAAI,CAAC,OAAO,EAAoB,CAAC,IAAI;aAC7C,CAAC,CAAC;IACT,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEL,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"listen.js","sourceRoot":"","sources":["listen.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,MAAM,MAAM,GAAG,CAAC,EAAE,GAAG,EAAE,IAAI,EAAiB,EAA6B,EAAE,CACzE,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;IAC9B,MAAM,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC,GAAW,EAAE,EAAE;QAChD,GAAG;YACD,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;YACb,CAAC,CAAC,OAAO,CAAC;gBACN,IAAI,EAAG,IAAI,CAAC,OAAO,EAAoB,CAAC,IAAI;aAC7C,CAAC,CAAC;IACT,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEL,eAAe,MAAM,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetshop/core",
3
- "version": "1.1.13-no-proxy.4",
3
+ "version": "1.1.13-no-proxy.5",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "dependencies": {
@@ -10,7 +10,7 @@
10
10
  "@types/lodash.get": "^4.4.4",
11
11
  "@types/lodash.merge": "^4.6.4",
12
12
  "@types/lodash.pick": "^4.4.4",
13
- "@types/node": "^8.0.53",
13
+ "@types/node": "^10.12.12",
14
14
  "@types/node-fetch": "^2.1.2",
15
15
  "@types/qs": "^6.5.1",
16
16
  "@types/react": "^16.4.18",
@@ -19,7 +19,6 @@
19
19
  "@types/react-loadable": "^5.4.1",
20
20
  "apollo-cache-inmemory": "^1.3.9",
21
21
  "apollo-client": "^2.4.5",
22
- "apollo-engine": "^1.1.2",
23
22
  "apollo-link": "^1.2.3",
24
23
  "apollo-link-context": "^1.0.9",
25
24
  "apollo-link-error": "^1.1.1",
package/polyfills.js CHANGED
@@ -11,7 +11,11 @@ const polyfills = (locale) => [
11
11
  'String.prototype.endsWith',
12
12
  'String.prototype.startsWith',
13
13
  'Object.keys',
14
+ 'IntersectionObserver',
14
15
  `Intl.~locale.${locale}`
15
16
  ];
16
- export const createPolyfill = (locale) => `<script src="//cdn.polyfill.io/v2/polyfill${process.env.NODE_ENV === 'production' ? '.min' : ''}.js?features=${polyfills(locale).join(',')}&flags=gated"></script>`;
17
+ export const createPolyfill = (locale) => {
18
+ const features = polyfills(locale).join(',');
19
+ return `<script async defer src="//cdn.polyfill.io/v2/polyfill${process.env.NODE_ENV === 'production' ? '.min' : ''}.js?features=${features}&flags=gated&callback=bootShop"></script>`;
20
+ };
17
21
  //# sourceMappingURL=polyfills.js.map
package/polyfills.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"polyfills.js","sourceRoot":"","sources":["polyfills.ts"],"names":[],"mappings":"AAAA,MAAM,SAAS,GAAG,CAAC,MAAc,EAAE,EAAE,CAAC;IACpC,KAAK;IACL,YAAY;IACZ,sBAAsB;IACtB,eAAe;IACf,gBAAgB;IAChB,sBAAsB;IACtB,2BAA2B;IAC3B,0BAA0B;IAC1B,sBAAsB;IACtB,2BAA2B;IAC3B,6BAA6B;IAC7B,aAAa;IACb,gBAAgB,MAAM,EAAE;CACzB,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAAc,EAAE,EAAE,CAC/C,6CACE,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EACnD,gBAAgB,SAAS,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,yBAAyB,CAAC"}
1
+ {"version":3,"file":"polyfills.js","sourceRoot":"","sources":["polyfills.ts"],"names":[],"mappings":"AAAA,MAAM,SAAS,GAAG,CAAC,MAAc,EAAE,EAAE,CAAC;IACpC,KAAK;IACL,YAAY;IACZ,sBAAsB;IACtB,eAAe;IACf,gBAAgB;IAChB,sBAAsB;IACtB,2BAA2B;IAC3B,0BAA0B;IAC1B,sBAAsB;IACtB,2BAA2B;IAC3B,6BAA6B;IAC7B,aAAa;IACb,sBAAsB;IACtB,gBAAgB,MAAM,EAAE;CACzB,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAAc,EAAE,EAAE;IAC/C,MAAM,QAAQ,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC7C,OAAO,yDACL,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EACnD,gBAAgB,QAAQ,2CAA2C,CAAC;AACtE,CAAC,CAAC"}
@@ -1,17 +0,0 @@
1
- import * as React from 'react';
2
- import { Query } from 'react-apollo';
3
- export declare class RenderPromises {
4
- private queryPromises;
5
- private queryGraveyard;
6
- addQueryPromise<TData, TVariables>(queryInstance: Query<TData, TVariables>, finish: () => React.ReactNode): React.ReactNode;
7
- hasPromises(): boolean;
8
- consumeAndAwaitPromises(): Promise<any[]>;
9
- }
10
- export declare type GetMarkupFromTreeOptions = {
11
- tree: React.ReactNode;
12
- context?: {
13
- [key: string]: any;
14
- };
15
- renderFunction?: (tree: React.ReactElement<any>) => NodeJS.ReadableStream;
16
- };
17
- export default function renderToStream({ tree, context, renderFunction }: GetMarkupFromTreeOptions): Promise<NodeJS.ReadableStream>;
@@ -1,105 +0,0 @@
1
- import * as React from 'react';
2
- import { renderToNodeStream } from 'react-dom/server';
3
- import * as PropTypes from 'prop-types';
4
- // Like a Set, but for tuples. In practice, this class is used to store
5
- // (query, JSON.stringify(variables)) tuples.
6
- class Trie {
7
- constructor() {
8
- this.children = null;
9
- this.added = false;
10
- }
11
- has(...keys) {
12
- let node = this;
13
- return (keys.every(key => {
14
- const child = node.children && node.children.get(key);
15
- return !!(child && (node = child));
16
- }) && node.added);
17
- }
18
- add(...keys) {
19
- let node = this;
20
- keys.forEach(key => {
21
- const map = node.children || (node.children = new Map());
22
- const child = map.get(key);
23
- if (child) {
24
- node = child;
25
- }
26
- else {
27
- map.set(key, (node = new Trie()));
28
- }
29
- });
30
- node.added = true;
31
- }
32
- }
33
- export class RenderPromises {
34
- constructor() {
35
- // Map from Query component instances to pending fetchData promises.
36
- this.queryPromises = new Map();
37
- // A way of remembering queries we've seen during previous renderings,
38
- // so that we never attempt to fetch them again in future renderings.
39
- this.queryGraveyard = new Trie();
40
- }
41
- addQueryPromise(queryInstance, finish) {
42
- const { query, variables } = queryInstance.props;
43
- if (!this.queryGraveyard.has(query, JSON.stringify(variables))) {
44
- this.queryPromises.set(queryInstance, new Promise(resolve => {
45
- resolve(queryInstance.fetchData());
46
- }));
47
- // Render null to abandon this subtree for this rendering, so that we
48
- // can wait for the data to arrive.
49
- return null;
50
- }
51
- return finish();
52
- }
53
- hasPromises() {
54
- return this.queryPromises.size > 0;
55
- }
56
- consumeAndAwaitPromises() {
57
- const promises = [];
58
- this.queryPromises.forEach((promise, queryInstance) => {
59
- const { query, variables } = queryInstance.props;
60
- // Make sure we never try to call fetchData for this query document and
61
- // these variables again. Since the queryInstance objects change with
62
- // every rendering, deduplicating them by query and variables is the
63
- // best we can do. If a different Query component happens to have the
64
- // same query document and variables, it will be immediately rendered
65
- // by calling finish() in addQueryPromise, which could result in the
66
- // rendering of an unwanted loading state, but that's not nearly as bad
67
- // as getting stuck in an infinite rendering loop because we kept calling
68
- // queryInstance.fetchData for the same Query component indefinitely.
69
- this.queryGraveyard.add(query, JSON.stringify(variables));
70
- promises.push(promise);
71
- });
72
- this.queryPromises.clear();
73
- return Promise.all(promises);
74
- }
75
- }
76
- export default function renderToStream({ tree, context = {}, renderFunction = renderToNodeStream }) {
77
- const renderPromises = new RenderPromises();
78
- class RenderPromisesProvider extends React.Component {
79
- getChildContext() {
80
- return Object.assign({}, context, { renderPromises });
81
- }
82
- render() {
83
- // Always re-render from the rootElement, even though it might seem
84
- // better to render the children of the component responsible for the
85
- // promise, because it is not possible to reconstruct the full context
86
- // of the original rendering (including all unknown context provider
87
- // elements) for a subtree of the orginal component tree.
88
- return tree;
89
- }
90
- }
91
- RenderPromisesProvider.childContextTypes = {
92
- renderPromises: PropTypes.object
93
- };
94
- Object.keys(context).forEach(key => {
95
- RenderPromisesProvider.childContextTypes[key] = PropTypes.any;
96
- });
97
- function process() {
98
- const stream = renderFunction(React.createElement(RenderPromisesProvider));
99
- return renderPromises.hasPromises()
100
- ? renderPromises.consumeAndAwaitPromises().then(process)
101
- : stream;
102
- }
103
- return Promise.resolve().then(process);
104
- }
105
- //# source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