@sveltejs/kit 1.0.0-next.29 → 1.0.0-next.290

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