@sveltejs/kit 1.0.0-next.27 → 1.0.0-next.273

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 (86) hide show
  1. package/README.md +12 -9
  2. package/assets/app/env.js +20 -0
  3. package/assets/app/navigation.js +79 -0
  4. package/assets/app/paths.js +1 -0
  5. package/assets/app/stores.js +97 -0
  6. package/assets/chunks/utils.js +13 -0
  7. package/assets/client/singletons.js +21 -0
  8. package/assets/client/start.js +1520 -0
  9. package/assets/components/error.svelte +18 -2
  10. package/assets/env.js +8 -0
  11. package/assets/paths.js +13 -0
  12. package/assets/server/index.js +2760 -0
  13. package/dist/chunks/amp_hook.js +56 -0
  14. package/dist/chunks/build.js +658 -0
  15. package/dist/chunks/cert.js +28154 -0
  16. package/dist/chunks/index.js +467 -0
  17. package/dist/chunks/index2.js +836 -0
  18. package/dist/chunks/index3.js +638 -0
  19. package/dist/chunks/index4.js +115 -0
  20. package/dist/chunks/index5.js +891 -0
  21. package/dist/chunks/index6.js +170 -0
  22. package/dist/chunks/index7.js +15584 -0
  23. package/dist/chunks/index8.js +4207 -0
  24. package/dist/chunks/misc.js +3 -0
  25. package/dist/chunks/multipart-parser.js +449 -0
  26. package/dist/cli.js +1132 -86
  27. package/dist/hooks.js +28 -0
  28. package/dist/install-fetch.js +6518 -0
  29. package/dist/node.js +95 -0
  30. package/package.json +96 -54
  31. package/svelte-kit.js +2 -0
  32. package/types/ambient-modules.d.ts +208 -0
  33. package/types/app.d.ts +35 -0
  34. package/types/config.d.ts +200 -0
  35. package/types/csp.d.ts +115 -0
  36. package/types/endpoint.d.ts +39 -0
  37. package/types/helper.d.ts +23 -0
  38. package/types/hooks.d.ts +37 -0
  39. package/types/index.d.ts +24 -0
  40. package/types/internal.d.ts +260 -0
  41. package/types/page.d.ts +33 -0
  42. package/CHANGELOG.md +0 -319
  43. package/assets/runtime/app/navigation.js +0 -23
  44. package/assets/runtime/app/navigation.js.map +0 -1
  45. package/assets/runtime/app/paths.js +0 -2
  46. package/assets/runtime/app/paths.js.map +0 -1
  47. package/assets/runtime/app/stores.js +0 -78
  48. package/assets/runtime/app/stores.js.map +0 -1
  49. package/assets/runtime/internal/singletons.js +0 -15
  50. package/assets/runtime/internal/singletons.js.map +0 -1
  51. package/assets/runtime/internal/start.js +0 -591
  52. package/assets/runtime/internal/start.js.map +0 -1
  53. package/assets/runtime/utils-85ebcc60.js +0 -18
  54. package/assets/runtime/utils-85ebcc60.js.map +0 -1
  55. package/dist/api.js +0 -44
  56. package/dist/api.js.map +0 -1
  57. package/dist/build.js +0 -246
  58. package/dist/build.js.map +0 -1
  59. package/dist/cli.js.map +0 -1
  60. package/dist/colors.js +0 -37
  61. package/dist/colors.js.map +0 -1
  62. package/dist/create_app.js +0 -580
  63. package/dist/create_app.js.map +0 -1
  64. package/dist/index.js +0 -368
  65. package/dist/index.js.map +0 -1
  66. package/dist/index2.js +0 -12035
  67. package/dist/index2.js.map +0 -1
  68. package/dist/index3.js +0 -547
  69. package/dist/index3.js.map +0 -1
  70. package/dist/index4.js +0 -74
  71. package/dist/index4.js.map +0 -1
  72. package/dist/index5.js +0 -464
  73. package/dist/index5.js.map +0 -1
  74. package/dist/index6.js +0 -734
  75. package/dist/index6.js.map +0 -1
  76. package/dist/logging.js +0 -43
  77. package/dist/logging.js.map +0 -1
  78. package/dist/package.js +0 -432
  79. package/dist/package.js.map +0 -1
  80. package/dist/renderer.js +0 -2403
  81. package/dist/renderer.js.map +0 -1
  82. package/dist/standard.js +0 -101
  83. package/dist/standard.js.map +0 -1
  84. package/dist/utils.js +0 -58
  85. package/dist/utils.js.map +0 -1
  86. package/svelte-kit +0 -3
@@ -0,0 +1,115 @@
1
+ import { s } from './misc.js';
2
+ import { g as get_mime_lookup } from '../cli.js';
3
+
4
+ /**
5
+ * @param {import('../../../types/internal').BuildData} build_data;
6
+ * @param {string} relative_path;
7
+ * @param {import('../../../types/internal').RouteData[]} routes;
8
+ * @param {'esm' | 'cjs'} format
9
+ */
10
+ function generate_manifest(
11
+ build_data,
12
+ relative_path,
13
+ routes = build_data.manifest_data.routes,
14
+ format = 'esm'
15
+ ) {
16
+ const bundled_nodes = new Map();
17
+
18
+ // 0 and 1 are special, they correspond to the root layout and root error nodes
19
+ bundled_nodes.set(build_data.manifest_data.components[0], {
20
+ path: `${relative_path}/nodes/0.js`,
21
+ index: 0
22
+ });
23
+
24
+ bundled_nodes.set(build_data.manifest_data.components[1], {
25
+ path: `${relative_path}/nodes/1.js`,
26
+ index: 1
27
+ });
28
+
29
+ routes.forEach((route) => {
30
+ if (route.type === 'page') {
31
+ [...route.a, ...route.b].forEach((component) => {
32
+ if (component && !bundled_nodes.has(component)) {
33
+ const i = build_data.manifest_data.components.indexOf(component);
34
+
35
+ bundled_nodes.set(component, {
36
+ path: `${relative_path}/nodes/${i}.js`,
37
+ index: bundled_nodes.size
38
+ });
39
+ }
40
+ });
41
+ }
42
+ });
43
+
44
+ /** @type {(path: string) => string} */
45
+ const importer =
46
+ format === 'esm'
47
+ ? (path) => `() => import('${path}')`
48
+ : (path) => `() => Promise.resolve().then(() => require('${path}'))`;
49
+
50
+ const assets = build_data.manifest_data.assets.map((asset) => asset.file);
51
+ if (build_data.service_worker) {
52
+ assets.push(build_data.service_worker);
53
+ }
54
+
55
+ // prettier-ignore
56
+ return `{
57
+ appDir: ${s(build_data.app_dir)},
58
+ assets: new Set(${s(assets)}),
59
+ _: {
60
+ mime: ${s(get_mime_lookup(build_data.manifest_data))},
61
+ entry: ${s(build_data.client.entry)},
62
+ nodes: [
63
+ ${Array.from(bundled_nodes.values()).map(node => importer(node.path)).join(',\n\t\t\t\t')}
64
+ ],
65
+ routes: [
66
+ ${routes.map(route => {
67
+ if (route.type === 'page') {
68
+ return `{
69
+ type: 'page',
70
+ pattern: ${route.pattern},
71
+ params: ${get_params(route.params)},
72
+ path: ${route.path ? s(route.path) : null},
73
+ shadow: ${route.shadow ? importer(`${relative_path}/${build_data.server.vite_manifest[route.shadow].file}`) : null},
74
+ a: ${s(route.a.map(component => component && bundled_nodes.get(component).index))},
75
+ b: ${s(route.b.map(component => component && bundled_nodes.get(component).index))}
76
+ }`.replace(/^\t\t/gm, '');
77
+ } else {
78
+ if (!build_data.server.vite_manifest[route.file]) {
79
+ // this is necessary in cases where a .css file snuck in —
80
+ // perhaps it would be better to disallow these (and others?)
81
+ return null;
82
+ }
83
+
84
+ return `{
85
+ type: 'endpoint',
86
+ pattern: ${route.pattern},
87
+ params: ${get_params(route.params)},
88
+ load: ${importer(`${relative_path}/${build_data.server.vite_manifest[route.file].file}`)}
89
+ }`.replace(/^\t\t/gm, '');
90
+ }
91
+ }).filter(Boolean).join(',\n\t\t\t\t')}
92
+ ]
93
+ }
94
+ }`.replace(/^\t/gm, '');
95
+ }
96
+
97
+ /** @param {string[]} array */
98
+ function get_params(array) {
99
+ // given an array of params like `['x', 'y', 'z']` for
100
+ // src/routes/[x]/[y]/[z]/svelte, create a function
101
+ // that turns a RexExpMatchArray into ({ x, y, z })
102
+ return array.length
103
+ ? '(m) => ({ ' +
104
+ array
105
+ .map((param, i) => {
106
+ return param.startsWith('...')
107
+ ? `${param.slice(3)}: m[${i + 1}] || ''`
108
+ : `${param}: m[${i + 1}]`;
109
+ })
110
+ .join(', ') +
111
+ '})'
112
+ : 'null';
113
+ }
114
+
115
+ export { generate_manifest as g };