@quilted/quilt 0.5.106 → 0.5.107

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/cjs/AppContext.cjs +21 -0
  3. package/build/cjs/email.cjs +32 -0
  4. package/build/cjs/env.cjs +7 -0
  5. package/build/cjs/global.cjs +5 -0
  6. package/build/cjs/html.cjs +112 -0
  7. package/build/cjs/http-handlers/index.cjs +14 -0
  8. package/build/cjs/http-handlers/node.cjs +14 -0
  9. package/build/cjs/http.cjs +108 -0
  10. package/build/cjs/index.cjs +216 -0
  11. package/build/cjs/matchers.cjs +5 -0
  12. package/build/cjs/polyfills/abort-controller.cjs +4 -0
  13. package/build/cjs/polyfills/base.cjs +4 -0
  14. package/build/cjs/polyfills/crypto.cjs +4 -0
  15. package/build/cjs/polyfills/fetch.cjs +4 -0
  16. package/build/cjs/polyfills/noop.cjs +4 -0
  17. package/build/cjs/server/ServerContext.cjs +21 -0
  18. package/build/cjs/server/http-handler.cjs +206 -0
  19. package/build/cjs/server/index.cjs +119 -0
  20. package/build/cjs/server/render.cjs +89 -0
  21. package/build/cjs/static/StaticContext.cjs +21 -0
  22. package/build/cjs/static/index.cjs +648 -0
  23. package/build/cjs/static/render.cjs +89 -0
  24. package/build/cjs/testing.cjs +61 -0
  25. package/build/cjs/threads.cjs +74 -0
  26. package/build/cjs/utilities/react.cjs +14 -0
  27. package/build/esm/AppContext.mjs +17 -0
  28. package/build/esm/email.mjs +1 -0
  29. package/build/esm/env.mjs +3 -0
  30. package/build/esm/global.mjs +3 -0
  31. package/build/esm/html.mjs +1 -0
  32. package/build/esm/http-handlers/index.mjs +1 -0
  33. package/build/esm/http-handlers/node.mjs +1 -0
  34. package/build/esm/http.mjs +1 -0
  35. package/build/esm/index.mjs +12 -0
  36. package/build/esm/matchers.mjs +2 -0
  37. package/build/esm/polyfills/abort-controller.mjs +1 -0
  38. package/build/esm/polyfills/base.mjs +1 -0
  39. package/build/esm/polyfills/crypto.mjs +1 -0
  40. package/build/esm/polyfills/fetch.mjs +1 -0
  41. package/build/esm/polyfills/noop.mjs +1 -0
  42. package/build/esm/server/ServerContext.mjs +17 -0
  43. package/build/esm/server/http-handler.mjs +192 -0
  44. package/build/esm/server/index.mjs +11 -0
  45. package/build/esm/server/render.mjs +78 -0
  46. package/build/esm/static/StaticContext.mjs +17 -0
  47. package/build/esm/static/index.mjs +618 -0
  48. package/build/esm/static/render.mjs +78 -0
  49. package/build/esm/testing.mjs +4 -0
  50. package/build/esm/threads.mjs +3 -0
  51. package/build/esm/utilities/react.mjs +10 -0
  52. package/build/esnext/AppContext.esnext +18 -0
  53. package/build/esnext/email.esnext +1 -0
  54. package/build/esnext/env.esnext +3 -0
  55. package/build/esnext/global.esnext +3 -0
  56. package/build/esnext/html.esnext +1 -0
  57. package/build/esnext/http-handlers/index.esnext +1 -0
  58. package/build/esnext/http-handlers/node.esnext +1 -0
  59. package/build/esnext/http.esnext +1 -0
  60. package/build/esnext/index.esnext +12 -0
  61. package/build/esnext/matchers.esnext +2 -0
  62. package/build/esnext/polyfills/abort-controller.esnext +1 -0
  63. package/build/esnext/polyfills/base.esnext +1 -0
  64. package/build/esnext/polyfills/crypto.esnext +1 -0
  65. package/build/esnext/polyfills/fetch.esnext +1 -0
  66. package/build/esnext/polyfills/noop.esnext +1 -0
  67. package/build/esnext/server/ServerContext.esnext +18 -0
  68. package/build/esnext/server/http-handler.esnext +82 -0
  69. package/build/esnext/server/index.esnext +11 -0
  70. package/build/esnext/server/render.esnext +40 -0
  71. package/build/esnext/static/StaticContext.esnext +18 -0
  72. package/build/esnext/static/index.esnext +281 -0
  73. package/build/esnext/static/render.esnext +40 -0
  74. package/build/esnext/testing.esnext +4 -0
  75. package/build/esnext/threads.esnext +3 -0
  76. package/build/esnext/utilities/react.esnext +10 -0
  77. package/package.json +1 -1
@@ -0,0 +1,618 @@
1
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
+ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
3
+ import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
4
+ import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
5
+ import _regeneratorRuntime from '@babel/runtime/regenerator';
6
+ import { render, Html } from '@quilted/react-html/server';
7
+ import { StaticRenderer, StaticRendererContext } from '@quilted/react-router/static';
8
+ import { renderApp } from './render.mjs';
9
+ import { jsx } from 'react/jsx-runtime';
10
+
11
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
12
+
13
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
14
+
15
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
16
+
17
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
18
+
19
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
20
+ var BASE_URL = 'http://localhost:3000';
21
+ function renderStatic(_x, _x2) {
22
+ return _renderStatic.apply(this, arguments);
23
+ }
24
+
25
+ function _renderStatic() {
26
+ _renderStatic = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(App, _ref) {
27
+ var assets, startingRoutes, onRender, _ref$crawl, crawl, _ref$baseUrl, baseUrl, _ref$prettify, prettify, routesToHandle, seenRoutes, seenRouteIds, renderableRoute, _loop, recordRouteDefinition, _recordRouteDefinition, renderUrl, _renderUrl;
28
+
29
+ return _regeneratorRuntime.wrap(function _callee3$(_context4) {
30
+ while (1) {
31
+ switch (_context4.prev = _context4.next) {
32
+ case 0:
33
+ _renderUrl = function _renderUrl3() {
34
+ _renderUrl = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(url) {
35
+ var _ref6,
36
+ _ref6$fallback,
37
+ fallback,
38
+ routeRecorder,
39
+ _yield$renderApp,
40
+ http,
41
+ htmlManager,
42
+ markup,
43
+ asyncAssets,
44
+ usedAssets,
45
+ _yield$Promise$all,
46
+ _yield$Promise$all2,
47
+ moduleStyles,
48
+ moduleScripts,
49
+ modulePreload,
50
+ nomoduleStyles,
51
+ nomoduleScripts,
52
+ styles,
53
+ preload,
54
+ scripts,
55
+ minifiedHtml,
56
+ html,
57
+ _args3 = arguments;
58
+
59
+ return _regeneratorRuntime.wrap(function _callee2$(_context3) {
60
+ while (1) {
61
+ switch (_context3.prev = _context3.next) {
62
+ case 0:
63
+ _ref6 = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {}, _ref6$fallback = _ref6.fallback, fallback = _ref6$fallback === void 0 ? false : _ref6$fallback;
64
+ routeRecorder = new StaticRenderer({
65
+ forceFallback: fallback ? url.pathname : undefined
66
+ });
67
+ _context3.next = 4;
68
+ return renderApp( /*#__PURE__*/jsx(App, {}), {
69
+ url: url,
70
+ decorate: function decorate(app) {
71
+ return /*#__PURE__*/jsx(StaticRendererContext.Provider, {
72
+ value: routeRecorder,
73
+ children: app
74
+ });
75
+ }
76
+ });
77
+
78
+ case 4:
79
+ _yield$renderApp = _context3.sent;
80
+ http = _yield$renderApp.http;
81
+ htmlManager = _yield$renderApp.html;
82
+ markup = _yield$renderApp.markup;
83
+ asyncAssets = _yield$renderApp.asyncAssets;
84
+ usedAssets = asyncAssets.used({
85
+ timing: 'load'
86
+ });
87
+ _context3.next = 12;
88
+ return Promise.all([assets.styles({
89
+ async: usedAssets,
90
+ options: {
91
+ modules: true
92
+ }
93
+ }), assets.scripts({
94
+ async: usedAssets,
95
+ options: {
96
+ modules: true
97
+ }
98
+ }), assets.asyncAssets(asyncAssets.used({
99
+ timing: 'preload'
100
+ }), {
101
+ options: {
102
+ modules: true
103
+ }
104
+ }), assets.styles({
105
+ async: usedAssets,
106
+ options: {
107
+ modules: false
108
+ }
109
+ }), assets.scripts({
110
+ async: usedAssets,
111
+ options: {
112
+ modules: false
113
+ }
114
+ })]);
115
+
116
+ case 12:
117
+ _yield$Promise$all = _context3.sent;
118
+ _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 5);
119
+ moduleStyles = _yield$Promise$all2[0];
120
+ moduleScripts = _yield$Promise$all2[1];
121
+ modulePreload = _yield$Promise$all2[2];
122
+ nomoduleStyles = _yield$Promise$all2[3];
123
+ nomoduleScripts = _yield$Promise$all2[4];
124
+ // We don’t want to load styles from both bundles, so we only use module styles,
125
+ // since modules are intended to be the default and CSS (usually) doesn’t
126
+ // have features that meaningfully break older user agents.
127
+ styles = moduleStyles.length > 0 ? moduleStyles : nomoduleStyles; // If there are nomodule scripts, we can’t really do preloading, because we can’t
128
+ // prevent the nomodule scripts from being preloaded in module browsers. If there
129
+ // are only module scripts, we can preload those.
130
+
131
+ preload = nomoduleScripts.length > 0 ? [] : modulePreload;
132
+ scripts = [].concat(_toConsumableArray(moduleScripts), _toConsumableArray(nomoduleScripts.map(function (script) {
133
+ return _objectSpread(_objectSpread({}, script), {}, {
134
+ nomodule: true
135
+ });
136
+ })));
137
+ minifiedHtml = render( /*#__PURE__*/jsx(Html, {
138
+ url: url,
139
+ manager: htmlManager,
140
+ styles: styles,
141
+ scripts: scripts,
142
+ preloadAssets: preload,
143
+ children: markup
144
+ }));
145
+
146
+ if (!prettify) {
147
+ _context3.next = 29;
148
+ break;
149
+ }
150
+
151
+ _context3.next = 26;
152
+ return prettifyHtml(minifiedHtml);
153
+
154
+ case 26:
155
+ _context3.t0 = _context3.sent;
156
+ _context3.next = 30;
157
+ break;
158
+
159
+ case 29:
160
+ _context3.t0 = minifiedHtml;
161
+
162
+ case 30:
163
+ html = _context3.t0;
164
+ return _context3.abrupt("return", {
165
+ html: html,
166
+ http: http.state,
167
+ routes: routeRecorder.state
168
+ });
169
+
170
+ case 32:
171
+ case "end":
172
+ return _context3.stop();
173
+ }
174
+ }
175
+ }, _callee2);
176
+ }));
177
+ return _renderUrl.apply(this, arguments);
178
+ };
179
+
180
+ renderUrl = function _renderUrl2(_x6) {
181
+ return _renderUrl.apply(this, arguments);
182
+ };
183
+
184
+ _recordRouteDefinition = function _recordRouteDefinitio2() {
185
+ _recordRouteDefinition = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref3, _ref4) {
186
+ var match, children, renderStatic, basePathname, baseId, addFallbacks, routeId, hasChildren, hasManualMatches, matchedRoutes, matchedRouteParts, _iterator3, _step3, routePart, id, _iterator4, _step4, _ref5, _step4$value, _id, route, _iterator5, _step5, child, _i2, _matchedRoutes, _matchedRoutes$_i, _route, fallback, _renderableRoute2;
187
+
188
+ return _regeneratorRuntime.wrap(function _callee$(_context2) {
189
+ while (1) {
190
+ switch (_context2.prev = _context2.next) {
191
+ case 0:
192
+ match = _ref3.match, children = _ref3.children, renderStatic = _ref3.renderStatic;
193
+ basePathname = _ref4.basePathname, baseId = _ref4.baseId, addFallbacks = _ref4.addFallbacks;
194
+
195
+ if (!(renderStatic === false)) {
196
+ _context2.next = 4;
197
+ break;
198
+ }
199
+
200
+ return _context2.abrupt("return");
201
+
202
+ case 4:
203
+ hasChildren = children && children.length > 0;
204
+ hasManualMatches = typeof renderStatic === 'function' && typeof match !== 'string';
205
+ matchedRoutes = [];
206
+
207
+ if (typeof match === 'string') {
208
+ routeId = joinPath(baseId, match);
209
+ matchedRoutes.push({
210
+ id: routeId,
211
+ route: joinPath(basePathname, match),
212
+ fallback: false
213
+ });
214
+ } else if (typeof match === 'function') {
215
+ routeId = joinPath(baseId, "__QUILT_FUNCTION_ROUTE_".concat(match.toString(), "__"));
216
+ } else if (match instanceof RegExp) {
217
+ routeId = joinPath("__QUILT_REGEX_ROUTE_".concat(match.source, "__"));
218
+ } else {
219
+ routeId = joinPath(baseId, '__QUILT_FALLBACK_ROUTE__');
220
+
221
+ if (!hasManualMatches) {
222
+ matchedRoutes.push({
223
+ id: routeId,
224
+ route: basePathname,
225
+ fallback: true
226
+ });
227
+ }
228
+ }
229
+
230
+ if (!seenRouteIds.has(routeId)) {
231
+ _context2.next = 10;
232
+ break;
233
+ }
234
+
235
+ return _context2.abrupt("return");
236
+
237
+ case 10:
238
+ seenRouteIds.add(routeId);
239
+
240
+ if (!(typeof renderStatic === 'function' && typeof match !== 'string')) {
241
+ _context2.next = 17;
242
+ break;
243
+ }
244
+
245
+ _context2.next = 14;
246
+ return renderStatic();
247
+
248
+ case 14:
249
+ matchedRouteParts = _context2.sent;
250
+ _iterator3 = _createForOfIteratorHelper(matchedRouteParts);
251
+
252
+ try {
253
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
254
+ routePart = _step3.value;
255
+ id = joinPath(baseId, "__QUILT_MATCH_".concat(routePart, "__"));
256
+ seenRouteIds.add(id);
257
+ matchedRoutes.push({
258
+ id: id,
259
+ route: joinPath(basePathname, routePart),
260
+ fallback: false
261
+ });
262
+ }
263
+ } catch (err) {
264
+ _iterator3.e(err);
265
+ } finally {
266
+ _iterator3.f();
267
+ }
268
+
269
+ case 17:
270
+ if (!hasChildren) {
271
+ _context2.next = 54;
272
+ break;
273
+ }
274
+
275
+ _iterator4 = _createForOfIteratorHelper(matchedRoutes);
276
+ _context2.prev = 19;
277
+
278
+ _iterator4.s();
279
+
280
+ case 21:
281
+ if ((_step4 = _iterator4.n()).done) {
282
+ _context2.next = 45;
283
+ break;
284
+ }
285
+
286
+ _step4$value = _step4.value, _id = _step4$value.id, route = _step4$value.route;
287
+ _iterator5 = _createForOfIteratorHelper(children);
288
+ _context2.prev = 24;
289
+
290
+ _iterator5.s();
291
+
292
+ case 26:
293
+ if ((_step5 = _iterator5.n()).done) {
294
+ _context2.next = 32;
295
+ break;
296
+ }
297
+
298
+ child = _step5.value;
299
+ _context2.next = 30;
300
+ return recordRouteDefinition(child, {
301
+ addFallbacks: addFallbacks,
302
+ basePathname: route,
303
+ baseId: _id
304
+ });
305
+
306
+ case 30:
307
+ _context2.next = 26;
308
+ break;
309
+
310
+ case 32:
311
+ _context2.next = 37;
312
+ break;
313
+
314
+ case 34:
315
+ _context2.prev = 34;
316
+ _context2.t0 = _context2["catch"](24);
317
+
318
+ _iterator5.e(_context2.t0);
319
+
320
+ case 37:
321
+ _context2.prev = 37;
322
+
323
+ _iterator5.f();
324
+
325
+ return _context2.finish(37);
326
+
327
+ case 40:
328
+ if (!(addFallbacks && ((_ref5 = children[children.length - 1]) === null || _ref5 === void 0 ? void 0 : _ref5.match) != null)) {
329
+ _context2.next = 43;
330
+ break;
331
+ }
332
+
333
+ _context2.next = 43;
334
+ return recordRouteDefinition({}, {
335
+ addFallbacks: addFallbacks,
336
+ basePathname: route,
337
+ baseId: _id
338
+ });
339
+
340
+ case 43:
341
+ _context2.next = 21;
342
+ break;
343
+
344
+ case 45:
345
+ _context2.next = 50;
346
+ break;
347
+
348
+ case 47:
349
+ _context2.prev = 47;
350
+ _context2.t1 = _context2["catch"](19);
351
+
352
+ _iterator4.e(_context2.t1);
353
+
354
+ case 50:
355
+ _context2.prev = 50;
356
+
357
+ _iterator4.f();
358
+
359
+ return _context2.finish(50);
360
+
361
+ case 53:
362
+ return _context2.abrupt("return");
363
+
364
+ case 54:
365
+ for (_i2 = 0, _matchedRoutes = matchedRoutes; _i2 < _matchedRoutes.length; _i2++) {
366
+ _matchedRoutes$_i = _matchedRoutes[_i2], _route = _matchedRoutes$_i.route, fallback = _matchedRoutes$_i.fallback;
367
+ _renderableRoute2 = {
368
+ route: _route,
369
+ fallback: fallback
370
+ };
371
+ seenRoutes.push(_renderableRoute2);
372
+ routesToHandle.push(_renderableRoute2);
373
+ }
374
+
375
+ case 55:
376
+ case "end":
377
+ return _context2.stop();
378
+ }
379
+ }
380
+ }, _callee, null, [[19, 47, 50, 53], [24, 34, 37, 40]]);
381
+ }));
382
+ return _recordRouteDefinition.apply(this, arguments);
383
+ };
384
+
385
+ recordRouteDefinition = function _recordRouteDefinitio(_x4, _x5) {
386
+ return _recordRouteDefinition.apply(this, arguments);
387
+ };
388
+
389
+ assets = _ref.assets, startingRoutes = _ref.routes, onRender = _ref.onRender, _ref$crawl = _ref.crawl, crawl = _ref$crawl === void 0 ? true : _ref$crawl, _ref$baseUrl = _ref.baseUrl, baseUrl = _ref$baseUrl === void 0 ? BASE_URL : _ref$baseUrl, _ref$prettify = _ref.prettify, prettify = _ref$prettify === void 0 ? true : _ref$prettify;
390
+ routesToHandle = startingRoutes.map(function (route) {
391
+ return {
392
+ route: removePostfixSlash(new URL(route, baseUrl).pathname),
393
+ fallback: false
394
+ };
395
+ });
396
+ seenRoutes = _toConsumableArray(routesToHandle);
397
+ seenRouteIds = new Set(seenRoutes.map(function (_ref2) {
398
+ var route = _ref2.route;
399
+ return route;
400
+ }));
401
+ _loop = /*#__PURE__*/_regeneratorRuntime.mark(function _loop() {
402
+ var _renderableRoute, route, fallback, url, _yield$renderUrl, html, http, routes, _iterator, _step, _routeDefinitions, _step$value, routeDefinitions, _step$value$fallback, _fallback, consumedPath, prefix, basePathname, baseId, _iterator2, _step2, routeDefinition;
403
+
404
+ return _regeneratorRuntime.wrap(function _loop$(_context) {
405
+ while (1) {
406
+ switch (_context.prev = _context.next) {
407
+ case 0:
408
+ _renderableRoute = renderableRoute, route = _renderableRoute.route, fallback = _renderableRoute.fallback;
409
+ url = new URL(route, baseUrl);
410
+ _context.next = 4;
411
+ return renderUrl(url, {
412
+ fallback: fallback
413
+ });
414
+
415
+ case 4:
416
+ _yield$renderUrl = _context.sent;
417
+ html = _yield$renderUrl.html;
418
+ http = _yield$renderUrl.http;
419
+ routes = _yield$renderUrl.routes;
420
+
421
+ if (!crawl) {
422
+ _context.next = 46;
423
+ break;
424
+ }
425
+
426
+ _iterator = _createForOfIteratorHelper(routes);
427
+ _context.prev = 10;
428
+
429
+ _iterator.s();
430
+
431
+ case 12:
432
+ if ((_step = _iterator.n()).done) {
433
+ _context.next = 38;
434
+ break;
435
+ }
436
+
437
+ _step$value = _step.value, routeDefinitions = _step$value.routes, _step$value$fallback = _step$value.fallback, _fallback = _step$value$fallback === void 0 ? false : _step$value$fallback, consumedPath = _step$value.consumedPath, prefix = _step$value.prefix;
438
+ basePathname = joinPath(prefix, consumedPath);
439
+ baseId = basePathname === '/' ? basePathname : "__QUILT_BASE_".concat(basePathname, "__");
440
+ _iterator2 = _createForOfIteratorHelper(routeDefinitions);
441
+ _context.prev = 17;
442
+
443
+ _iterator2.s();
444
+
445
+ case 19:
446
+ if ((_step2 = _iterator2.n()).done) {
447
+ _context.next = 25;
448
+ break;
449
+ }
450
+
451
+ routeDefinition = _step2.value;
452
+ _context.next = 23;
453
+ return recordRouteDefinition(routeDefinition, {
454
+ baseId: baseId,
455
+ basePathname: basePathname,
456
+ addFallbacks: _fallback
457
+ });
458
+
459
+ case 23:
460
+ _context.next = 19;
461
+ break;
462
+
463
+ case 25:
464
+ _context.next = 30;
465
+ break;
466
+
467
+ case 27:
468
+ _context.prev = 27;
469
+ _context.t0 = _context["catch"](17);
470
+
471
+ _iterator2.e(_context.t0);
472
+
473
+ case 30:
474
+ _context.prev = 30;
475
+
476
+ _iterator2.f();
477
+
478
+ return _context.finish(30);
479
+
480
+ case 33:
481
+ if (!(_fallback && ((_routeDefinitions = routeDefinitions[routeDefinitions.length - 1]) === null || _routeDefinitions === void 0 ? void 0 : _routeDefinitions.match) != null)) {
482
+ _context.next = 36;
483
+ break;
484
+ }
485
+
486
+ _context.next = 36;
487
+ return recordRouteDefinition({}, {
488
+ baseId: baseId,
489
+ basePathname: basePathname,
490
+ addFallbacks: _fallback
491
+ });
492
+
493
+ case 36:
494
+ _context.next = 12;
495
+ break;
496
+
497
+ case 38:
498
+ _context.next = 43;
499
+ break;
500
+
501
+ case 40:
502
+ _context.prev = 40;
503
+ _context.t1 = _context["catch"](10);
504
+
505
+ _iterator.e(_context.t1);
506
+
507
+ case 43:
508
+ _context.prev = 43;
509
+
510
+ _iterator.f();
511
+
512
+ return _context.finish(43);
513
+
514
+ case 46:
515
+ _context.next = 48;
516
+ return onRender({
517
+ route: route,
518
+ content: html,
519
+ http: http,
520
+ fallback: fallback,
521
+ hasChildren: !fallback && seenRoutes.some(function (otherRoute) {
522
+ return otherRoute.route.startsWith("".concat(route, "/"));
523
+ })
524
+ });
525
+
526
+ case 48:
527
+ case "end":
528
+ return _context.stop();
529
+ }
530
+ }
531
+ }, _loop, null, [[10, 40, 43, 46], [17, 27, 30, 33]]);
532
+ });
533
+
534
+ case 9:
535
+ if (!(renderableRoute = routesToHandle.shift())) {
536
+ _context4.next = 13;
537
+ break;
538
+ }
539
+
540
+ return _context4.delegateYield(_loop(), "t0", 11);
541
+
542
+ case 11:
543
+ _context4.next = 9;
544
+ break;
545
+
546
+ case 13:
547
+ case "end":
548
+ return _context4.stop();
549
+ }
550
+ }
551
+ }, _callee3);
552
+ }));
553
+ return _renderStatic.apply(this, arguments);
554
+ }
555
+
556
+ function prettifyHtml(_x3) {
557
+ return _prettifyHtml.apply(this, arguments);
558
+ }
559
+
560
+ function _prettifyHtml() {
561
+ _prettifyHtml = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(html) {
562
+ var _yield$import, prettier;
563
+
564
+ return _regeneratorRuntime.wrap(function _callee4$(_context5) {
565
+ while (1) {
566
+ switch (_context5.prev = _context5.next) {
567
+ case 0:
568
+ _context5.prev = 0;
569
+ _context5.next = 3;
570
+ return import('prettier');
571
+
572
+ case 3:
573
+ _yield$import = _context5.sent;
574
+ prettier = _yield$import["default"];
575
+ return _context5.abrupt("return", prettier.format(html, {
576
+ parser: 'html'
577
+ }));
578
+
579
+ case 8:
580
+ _context5.prev = 8;
581
+ _context5.t0 = _context5["catch"](0);
582
+ return _context5.abrupt("return", html);
583
+
584
+ case 11:
585
+ case "end":
586
+ return _context5.stop();
587
+ }
588
+ }
589
+ }, _callee4, null, [[0, 8]]);
590
+ }));
591
+ return _prettifyHtml.apply(this, arguments);
592
+ }
593
+
594
+ function joinPath() {
595
+ var path = '/';
596
+
597
+ for (var _len = arguments.length, parts = new Array(_len), _key = 0; _key < _len; _key++) {
598
+ parts[_key] = arguments[_key];
599
+ }
600
+
601
+ for (var _i = 0, _parts = parts; _i < _parts.length; _i++) {
602
+ var part = _parts[_i];
603
+ if (typeof part !== 'string') continue;
604
+ var normalizedPart = part.startsWith('/') ? part.slice(1) : part;
605
+ if (normalizedPart.length === 0) continue;
606
+ if (path !== '/') path += '/';
607
+ path += normalizedPart;
608
+ path = removePostfixSlash(path);
609
+ }
610
+
611
+ return path;
612
+ }
613
+
614
+ function removePostfixSlash(value) {
615
+ return value.endsWith('/') && value !== '/' ? value.slice(0, value.length - 1) : value;
616
+ }
617
+
618
+ export { renderStatic };
@@ -0,0 +1,78 @@
1
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
+ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
3
+ import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
4
+ import _regeneratorRuntime from '@babel/runtime/regenerator';
5
+ import { extract } from '@quilted/react-server-render/server';
6
+ import { HtmlManager } from '@quilted/react-html/server';
7
+ import { HttpManager } from '@quilted/react-http/server';
8
+ import { AsyncAssetManager } from '@quilted/react-async/server';
9
+ import { StaticContext } from './StaticContext.mjs';
10
+ import { jsx } from 'react/jsx-runtime';
11
+
12
+ var _excluded = ["decorate", "url", "headers"];
13
+
14
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
15
+
16
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
17
+ function renderApp(_x) {
18
+ return _renderApp.apply(this, arguments);
19
+ }
20
+
21
+ function _renderApp() {
22
+ _renderApp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(app) {
23
+ var _ref,
24
+ _decorate,
25
+ url,
26
+ headers,
27
+ rest,
28
+ html,
29
+ asyncAssets,
30
+ http,
31
+ markup,
32
+ _args = arguments;
33
+
34
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
35
+ while (1) {
36
+ switch (_context.prev = _context.next) {
37
+ case 0:
38
+ _ref = _args.length > 1 && _args[1] !== undefined ? _args[1] : {}, _decorate = _ref.decorate, url = _ref.url, headers = _ref.headers, rest = _objectWithoutProperties(_ref, _excluded);
39
+ html = new HtmlManager();
40
+ asyncAssets = new AsyncAssetManager();
41
+ http = new HttpManager({
42
+ headers: headers
43
+ });
44
+ _context.next = 6;
45
+ return extract(app, _objectSpread({
46
+ decorate: function decorate(app) {
47
+ var _decorate2;
48
+
49
+ return /*#__PURE__*/jsx(StaticContext, {
50
+ asyncAssets: asyncAssets,
51
+ html: html,
52
+ http: http,
53
+ url: url,
54
+ children: (_decorate2 = _decorate === null || _decorate === void 0 ? void 0 : _decorate(app)) !== null && _decorate2 !== void 0 ? _decorate2 : app
55
+ });
56
+ }
57
+ }, rest));
58
+
59
+ case 6:
60
+ markup = _context.sent;
61
+ return _context.abrupt("return", {
62
+ markup: markup,
63
+ http: http,
64
+ html: html,
65
+ asyncAssets: asyncAssets
66
+ });
67
+
68
+ case 8:
69
+ case "end":
70
+ return _context.stop();
71
+ }
72
+ }
73
+ }, _callee);
74
+ }));
75
+ return _renderApp.apply(this, arguments);
76
+ }
77
+
78
+ export { renderApp };