@sveltejs/kit 1.0.0-next.44 → 1.0.0-next.442

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 (153) hide show
  1. package/README.md +12 -9
  2. package/package.json +94 -63
  3. package/src/cli.js +112 -0
  4. package/src/core/adapt/builder.js +223 -0
  5. package/src/core/adapt/index.js +19 -0
  6. package/src/core/config/index.js +86 -0
  7. package/src/core/config/options.js +488 -0
  8. package/src/core/config/types.d.ts +1 -0
  9. package/src/core/constants.js +5 -0
  10. package/src/core/env.js +97 -0
  11. package/src/core/generate_manifest/index.js +78 -0
  12. package/src/core/prerender/crawl.js +194 -0
  13. package/src/core/prerender/prerender.js +380 -0
  14. package/src/core/prerender/queue.js +80 -0
  15. package/src/core/sync/create_manifest_data/index.js +452 -0
  16. package/src/core/sync/create_manifest_data/types.d.ts +37 -0
  17. package/src/core/sync/sync.js +59 -0
  18. package/src/core/sync/utils.js +33 -0
  19. package/src/core/sync/write_ambient.js +27 -0
  20. package/src/core/sync/write_client_manifest.js +92 -0
  21. package/src/core/sync/write_matchers.js +25 -0
  22. package/src/core/sync/write_root.js +91 -0
  23. package/src/core/sync/write_tsconfig.js +195 -0
  24. package/src/core/sync/write_types/index.js +580 -0
  25. package/src/core/sync/write_types/test/layout/+layout.js +5 -0
  26. package/src/core/sync/write_types/test/layout/+layout.server.js +5 -0
  27. package/src/core/sync/write_types/test/layout/+layout.svelte +0 -0
  28. package/src/core/sync/write_types/test/layout/+page.js +5 -0
  29. package/src/core/sync/write_types/test/layout/+page.server.js +5 -0
  30. package/src/core/sync/write_types/test/layout/+page.svelte +0 -0
  31. package/src/core/sync/write_types/test/layout/_expected/$types.d.ts +67 -0
  32. package/src/core/sync/write_types/test/layout-advanced/(main)/+layout.server.js +5 -0
  33. package/src/core/sync/write_types/test/layout-advanced/(main)/+layout.svelte +0 -0
  34. package/src/core/sync/write_types/test/layout-advanced/(main)/+page.js +5 -0
  35. package/src/core/sync/write_types/test/layout-advanced/(main)/+page@.svelte +0 -0
  36. package/src/core/sync/write_types/test/layout-advanced/(main)/sub/+page.js +5 -0
  37. package/src/core/sync/write_types/test/layout-advanced/(main)/sub/+page.svelte +0 -0
  38. package/src/core/sync/write_types/test/layout-advanced/+layout.js +5 -0
  39. package/src/core/sync/write_types/test/layout-advanced/+layout.svelte +0 -0
  40. package/src/core/sync/write_types/test/layout-advanced/_expected/$types.d.ts +32 -0
  41. package/src/core/sync/write_types/test/layout-advanced/_expected/(main)/$types.d.ts +42 -0
  42. package/src/core/sync/write_types/test/layout-advanced/_expected/(main)/sub/$types.d.ts +33 -0
  43. package/src/core/sync/write_types/test/simple-page-server-and-shared/+page.js +5 -0
  44. package/src/core/sync/write_types/test/simple-page-server-and-shared/+page.server.js +5 -0
  45. package/src/core/sync/write_types/test/simple-page-server-and-shared/+page.svelte +0 -0
  46. package/src/core/sync/write_types/test/simple-page-server-and-shared/_expected/$types.d.ts +44 -0
  47. package/src/core/sync/write_types/test/simple-page-server-only/+page.server.js +5 -0
  48. package/src/core/sync/write_types/test/simple-page-server-only/+page.svelte +0 -0
  49. package/src/core/sync/write_types/test/simple-page-server-only/_expected/$types.d.ts +30 -0
  50. package/src/core/sync/write_types/test/simple-page-shared-only/+page.js +5 -0
  51. package/src/core/sync/write_types/test/simple-page-shared-only/+page.svelte +0 -0
  52. package/src/core/sync/write_types/test/simple-page-shared-only/_expected/$types.d.ts +33 -0
  53. package/src/core/sync/write_types/test/slugs/+layout.js +1 -0
  54. package/src/core/sync/write_types/test/slugs/+layout.svelte +1 -0
  55. package/src/core/sync/write_types/test/slugs/[...rest]/+page.js +3 -0
  56. package/src/core/sync/write_types/test/slugs/[...rest]/+page.svelte +0 -0
  57. package/src/core/sync/write_types/test/slugs/[slug]/+page.js +3 -0
  58. package/src/core/sync/write_types/test/slugs/[slug]/+page.svelte +0 -0
  59. package/src/core/sync/write_types/test/slugs/_expected/$types.d.ts +32 -0
  60. package/src/core/sync/write_types/test/slugs/_expected/[...rest]/$types.d.ts +29 -0
  61. package/src/core/sync/write_types/test/slugs/_expected/[slug]/$types.d.ts +29 -0
  62. package/src/core/sync/write_types/test/slugs-layout-not-all-pages-have-load/+layout.js +1 -0
  63. package/src/core/sync/write_types/test/slugs-layout-not-all-pages-have-load/+layout.svelte +1 -0
  64. package/src/core/sync/write_types/test/slugs-layout-not-all-pages-have-load/_expected/$types.d.ts +30 -0
  65. package/src/core/sync/write_types/test/slugs-layout-not-all-pages-have-load/_expected/nested/$types.d.ts +32 -0
  66. package/src/core/sync/write_types/test/slugs-layout-not-all-pages-have-load/_expected/nested/[...rest]/$types.d.ts +37 -0
  67. package/src/core/sync/write_types/test/slugs-layout-not-all-pages-have-load/_expected/nested/[slug]/$types.d.ts +17 -0
  68. package/src/core/sync/write_types/test/slugs-layout-not-all-pages-have-load/nested/+layout.js +1 -0
  69. package/src/core/sync/write_types/test/slugs-layout-not-all-pages-have-load/nested/+layout.svelte +1 -0
  70. package/src/core/sync/write_types/test/slugs-layout-not-all-pages-have-load/nested/[...rest]/+page.js +3 -0
  71. package/src/core/sync/write_types/test/slugs-layout-not-all-pages-have-load/nested/[...rest]/+page.svelte +0 -0
  72. package/src/core/sync/write_types/test/slugs-layout-not-all-pages-have-load/nested/[slug]/+page@.svelte +0 -0
  73. package/src/core/utils.js +70 -0
  74. package/src/hooks.js +26 -0
  75. package/src/index/index.js +45 -0
  76. package/src/index/private.js +33 -0
  77. package/src/node/index.js +145 -0
  78. package/src/node/polyfills.js +40 -0
  79. package/src/runtime/app/env.js +11 -0
  80. package/src/runtime/app/navigation.js +22 -0
  81. package/src/runtime/app/paths.js +1 -0
  82. package/src/runtime/app/stores.js +102 -0
  83. package/src/runtime/client/ambient.d.ts +18 -0
  84. package/src/runtime/client/client.js +1362 -0
  85. package/src/runtime/client/fetcher.js +60 -0
  86. package/src/runtime/client/parse.js +41 -0
  87. package/src/runtime/client/singletons.js +21 -0
  88. package/src/runtime/client/start.js +46 -0
  89. package/src/runtime/client/types.d.ts +86 -0
  90. package/src/runtime/client/utils.js +113 -0
  91. package/src/runtime/components/error.svelte +16 -0
  92. package/{assets → src/runtime}/components/layout.svelte +0 -0
  93. package/src/runtime/env/dynamic/private.js +1 -0
  94. package/src/runtime/env/dynamic/public.js +1 -0
  95. package/src/runtime/env-private.js +7 -0
  96. package/src/runtime/env-public.js +7 -0
  97. package/src/runtime/env.js +6 -0
  98. package/src/runtime/hash.js +16 -0
  99. package/src/runtime/paths.js +11 -0
  100. package/src/runtime/server/endpoint.js +50 -0
  101. package/src/runtime/server/index.js +492 -0
  102. package/src/runtime/server/page/cookie.js +25 -0
  103. package/src/runtime/server/page/crypto.js +239 -0
  104. package/src/runtime/server/page/csp.js +249 -0
  105. package/src/runtime/server/page/fetch.js +266 -0
  106. package/src/runtime/server/page/index.js +408 -0
  107. package/src/runtime/server/page/load_data.js +168 -0
  108. package/src/runtime/server/page/render.js +361 -0
  109. package/src/runtime/server/page/respond_with_error.js +95 -0
  110. package/src/runtime/server/page/types.d.ts +44 -0
  111. package/src/runtime/server/utils.js +116 -0
  112. package/src/utils/array.js +9 -0
  113. package/src/utils/error.js +22 -0
  114. package/src/utils/escape.js +104 -0
  115. package/src/utils/filesystem.js +108 -0
  116. package/src/utils/functions.js +16 -0
  117. package/src/utils/http.js +55 -0
  118. package/src/utils/misc.js +1 -0
  119. package/src/utils/routing.js +146 -0
  120. package/src/utils/url.js +142 -0
  121. package/src/vite/build/build_server.js +348 -0
  122. package/src/vite/build/build_service_worker.js +90 -0
  123. package/src/vite/build/utils.js +160 -0
  124. package/src/vite/dev/index.js +543 -0
  125. package/src/vite/index.js +578 -0
  126. package/src/vite/preview/index.js +186 -0
  127. package/src/vite/types.d.ts +3 -0
  128. package/src/vite/utils.js +345 -0
  129. package/svelte-kit.js +1 -1
  130. package/types/ambient.d.ts +366 -0
  131. package/types/index.d.ts +345 -0
  132. package/types/internal.d.ts +374 -0
  133. package/types/private.d.ts +209 -0
  134. package/CHANGELOG.md +0 -437
  135. package/assets/components/error.svelte +0 -13
  136. package/assets/runtime/app/env.js +0 -5
  137. package/assets/runtime/app/navigation.js +0 -41
  138. package/assets/runtime/app/paths.js +0 -1
  139. package/assets/runtime/app/stores.js +0 -93
  140. package/assets/runtime/chunks/utils.js +0 -19
  141. package/assets/runtime/internal/singletons.js +0 -23
  142. package/assets/runtime/internal/start.js +0 -770
  143. package/assets/runtime/paths.js +0 -12
  144. package/dist/chunks/index.js +0 -3521
  145. package/dist/chunks/index2.js +0 -587
  146. package/dist/chunks/index3.js +0 -246
  147. package/dist/chunks/index4.js +0 -545
  148. package/dist/chunks/index5.js +0 -761
  149. package/dist/chunks/index6.js +0 -322
  150. package/dist/chunks/standard.js +0 -99
  151. package/dist/chunks/utils.js +0 -83
  152. package/dist/cli.js +0 -546
  153. package/dist/ssr.js +0 -2580
@@ -1,246 +0,0 @@
1
- function read_only_form_data() {
2
- /** @type {Map<string, string[]>} */
3
- const map = new Map();
4
-
5
- return {
6
- /**
7
- * @param {string} key
8
- * @param {string} value
9
- */
10
- append(key, value) {
11
- if (map.has(key)) {
12
- map.get(key).push(value);
13
- } else {
14
- map.set(key, [value]);
15
- }
16
- },
17
-
18
- data: new ReadOnlyFormData(map)
19
- };
20
- }
21
-
22
- class ReadOnlyFormData {
23
- /** @type {Map<string, string[]>} */
24
- #map;
25
-
26
- /** @param {Map<string, string[]>} map */
27
- constructor(map) {
28
- this.#map = map;
29
- }
30
-
31
- /** @param {string} key */
32
- get(key) {
33
- const value = this.#map.get(key);
34
- return value && value[0];
35
- }
36
-
37
- /** @param {string} key */
38
- getAll(key) {
39
- return this.#map.get(key);
40
- }
41
-
42
- /** @param {string} key */
43
- has(key) {
44
- return this.#map.has(key);
45
- }
46
-
47
- *[Symbol.iterator]() {
48
- for (const [key, value] of this.#map) {
49
- for (let i = 0; i < value.length; i += 1) {
50
- yield [key, value[i]];
51
- }
52
- }
53
- }
54
-
55
- *entries() {
56
- for (const [key, value] of this.#map) {
57
- for (let i = 0; i < value.length; i += 1) {
58
- yield [key, value[i]];
59
- }
60
- }
61
- }
62
-
63
- *keys() {
64
- for (const [key, value] of this.#map) {
65
- for (let i = 0; i < value.length; i += 1) {
66
- yield key;
67
- }
68
- }
69
- }
70
-
71
- *values() {
72
- for (const [, value] of this.#map) {
73
- for (let i = 0; i < value.length; i += 1) {
74
- yield value;
75
- }
76
- }
77
- }
78
- }
79
-
80
- /** @param {import('http').IncomingMessage} req */
81
- function get_body(req) {
82
- const headers = req.headers;
83
- const has_body =
84
- headers['content-type'] !== undefined &&
85
- // https://github.com/jshttp/type-is/blob/c1f4388c71c8a01f79934e68f630ca4a15fffcd6/index.js#L81-L95
86
- (headers['transfer-encoding'] !== undefined || !isNaN(Number(headers['content-length'])));
87
-
88
- if (!has_body) return Promise.resolve(undefined);
89
-
90
- const [type, ...directives] = headers['content-type'].split(/;\s*/);
91
-
92
- switch (type) {
93
- case 'application/octet-stream':
94
- return get_buffer(req);
95
-
96
- case 'text/plain':
97
- return get_text(req);
98
-
99
- case 'application/json':
100
- return get_json(req);
101
-
102
- case 'application/x-www-form-urlencoded':
103
- return get_urlencoded(req);
104
-
105
- case 'multipart/form-data': {
106
- const boundary = directives.find((directive) => directive.startsWith('boundary='));
107
- if (!boundary) throw new Error('Missing boundary');
108
- return get_multipart(req, boundary.slice('boundary='.length));
109
- }
110
- default:
111
- throw new Error(`Invalid Content-Type ${type}`);
112
- }
113
- }
114
-
115
- /** @param {import('http').IncomingMessage} req */
116
- async function get_json(req) {
117
- return JSON.parse(await get_text(req));
118
- }
119
-
120
- /** @param {import('http').IncomingMessage} req */
121
- async function get_urlencoded(req) {
122
- const text = await get_text(req);
123
-
124
- const { data, append } = read_only_form_data();
125
-
126
- text
127
- .replace(/\+/g, ' ')
128
- .split('&')
129
- .forEach((str) => {
130
- const [key, value] = str.split('=');
131
- append(decodeURIComponent(key), decodeURIComponent(value));
132
- });
133
-
134
- return data;
135
- }
136
-
137
- /**
138
- * @param {import('http').IncomingMessage} req
139
- * @param {string} boundary
140
- */
141
- async function get_multipart(req, boundary) {
142
- const text = await get_text(req);
143
- const parts = text.split(`--${boundary}`);
144
-
145
- const nope = () => {
146
- throw new Error('Malformed form data');
147
- };
148
-
149
- if (parts[0] !== '' || parts[parts.length - 1].trim() !== '--') {
150
- nope();
151
- }
152
-
153
- const { data, append } = read_only_form_data();
154
-
155
- parts.slice(1, -1).forEach((part) => {
156
- const match = /\s*([\s\S]+?)\r\n\r\n([\s\S]*)\s*/.exec(part);
157
- const raw_headers = match[1];
158
- const body = match[2].trim();
159
-
160
- let key;
161
- raw_headers.split('\r\n').forEach((str) => {
162
- const [raw_header, ...raw_directives] = str.split('; ');
163
- let [name, value] = raw_header.split(': ');
164
-
165
- name = name.toLowerCase();
166
-
167
- /** @type {Record<string, string>} */
168
- const directives = {};
169
- raw_directives.forEach((raw_directive) => {
170
- const [name, value] = raw_directive.split('=');
171
- directives[name] = JSON.parse(value); // TODO is this right?
172
- });
173
-
174
- if (name === 'content-disposition') {
175
- if (value !== 'form-data') nope();
176
-
177
- if (directives.filename) {
178
- // TODO we probably don't want to do this automatically
179
- throw new Error('File upload is not yet implemented');
180
- }
181
-
182
- if (directives.name) {
183
- key = directives.name;
184
- }
185
- }
186
- });
187
-
188
- if (!key) nope();
189
-
190
- append(key, body);
191
- });
192
-
193
- return data;
194
- }
195
-
196
- /**
197
- * @param {import('http').IncomingMessage} req
198
- * @returns {Promise<string>}
199
- */
200
- function get_text(req) {
201
- return new Promise((fulfil, reject) => {
202
- let data = '';
203
-
204
- req.on('error', reject);
205
-
206
- req.on('data', (chunk) => {
207
- data += chunk;
208
- });
209
-
210
- req.on('end', () => {
211
- fulfil(data);
212
- });
213
- });
214
- }
215
-
216
- /**
217
- * @param {import('http').IncomingMessage} req
218
- * @returns {Promise<ArrayBuffer>}
219
- */
220
- function get_buffer(req) {
221
- return new Promise((fulfil, reject) => {
222
- let data = new Uint8Array(0);
223
-
224
- req.on('error', reject);
225
-
226
- req.on('data', (chunk) => {
227
- const new_data = new Uint8Array(data.length + chunk.length);
228
-
229
- for (let i = 0; i < data.length; i += 1) {
230
- new_data[i] = data[i];
231
- }
232
-
233
- for (let i = 0; i < chunk.length; i += 1) {
234
- new_data[i + data.length] = chunk[i];
235
- }
236
-
237
- data = new_data;
238
- });
239
-
240
- req.on('end', () => {
241
- fulfil(data.buffer);
242
- });
243
- });
244
- }
245
-
246
- export { get_body as g };