@sveltejs/kit 1.0.0-next.30 → 1.0.0-next.300

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 (75) hide show
  1. package/README.md +12 -9
  2. package/assets/app/env.js +20 -0
  3. package/assets/app/navigation.js +24 -0
  4. package/assets/app/paths.js +1 -0
  5. package/assets/app/stores.js +97 -0
  6. package/assets/client/singletons.js +13 -0
  7. package/assets/client/start.js +1614 -0
  8. package/assets/components/error.svelte +18 -2
  9. package/assets/env.js +8 -0
  10. package/assets/paths.js +13 -0
  11. package/assets/server/index.js +2847 -0
  12. package/dist/chunks/amp_hook.js +56 -0
  13. package/dist/chunks/cert.js +28154 -0
  14. package/dist/chunks/constants.js +663 -0
  15. package/dist/chunks/filesystem.js +110 -0
  16. package/dist/chunks/index.js +521 -0
  17. package/dist/chunks/index2.js +1326 -0
  18. package/dist/chunks/index3.js +119 -0
  19. package/dist/chunks/index4.js +197 -0
  20. package/dist/chunks/index5.js +251 -0
  21. package/dist/chunks/index6.js +15585 -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/object.js +83 -0
  26. package/dist/chunks/routing.js +39 -0
  27. package/dist/chunks/sync.js +1055 -0
  28. package/dist/chunks/url.js +56 -0
  29. package/dist/cli.js +1016 -91
  30. package/dist/hooks.js +28 -0
  31. package/dist/install-fetch.js +6518 -0
  32. package/dist/node.js +94 -0
  33. package/package.json +92 -54
  34. package/svelte-kit.js +2 -0
  35. package/types/ambient.d.ts +298 -0
  36. package/types/index.d.ts +262 -0
  37. package/types/internal.d.ts +321 -0
  38. package/types/private.d.ts +273 -0
  39. package/CHANGELOG.md +0 -338
  40. package/assets/runtime/app/navigation.js +0 -23
  41. package/assets/runtime/app/navigation.js.map +0 -1
  42. package/assets/runtime/app/paths.js +0 -2
  43. package/assets/runtime/app/paths.js.map +0 -1
  44. package/assets/runtime/app/stores.js +0 -78
  45. package/assets/runtime/app/stores.js.map +0 -1
  46. package/assets/runtime/internal/singletons.js +0 -15
  47. package/assets/runtime/internal/singletons.js.map +0 -1
  48. package/assets/runtime/internal/start.js +0 -591
  49. package/assets/runtime/internal/start.js.map +0 -1
  50. package/assets/runtime/utils-85ebcc60.js +0 -18
  51. package/assets/runtime/utils-85ebcc60.js.map +0 -1
  52. package/dist/api.js +0 -44
  53. package/dist/api.js.map +0 -1
  54. package/dist/cli.js.map +0 -1
  55. package/dist/create_app.js +0 -580
  56. package/dist/create_app.js.map +0 -1
  57. package/dist/index.js +0 -368
  58. package/dist/index.js.map +0 -1
  59. package/dist/index2.js +0 -12035
  60. package/dist/index2.js.map +0 -1
  61. package/dist/index3.js +0 -549
  62. package/dist/index3.js.map +0 -1
  63. package/dist/index4.js +0 -74
  64. package/dist/index4.js.map +0 -1
  65. package/dist/index5.js +0 -464
  66. package/dist/index5.js.map +0 -1
  67. package/dist/index6.js +0 -735
  68. package/dist/index6.js.map +0 -1
  69. package/dist/renderer.js +0 -2425
  70. package/dist/renderer.js.map +0 -1
  71. package/dist/standard.js +0 -101
  72. package/dist/standard.js.map +0 -1
  73. package/dist/utils.js +0 -58
  74. package/dist/utils.js.map +0 -1
  75. package/svelte-kit +0 -3
@@ -0,0 +1,3 @@
1
+ const s = JSON.stringify;
2
+
3
+ export { s };
@@ -0,0 +1,449 @@
1
+ import 'node:fs';
2
+ import 'node:path';
3
+ import { MessageChannel } from 'node:worker_threads';
4
+ import { F as FormData, a as File } from '../install-fetch.js';
5
+ import 'node:http';
6
+ import 'node:https';
7
+ import 'node:zlib';
8
+ import 'node:stream';
9
+ import 'node:util';
10
+ import 'node:url';
11
+ import 'net';
12
+
13
+ globalThis.DOMException || (() => {
14
+ const port = new MessageChannel().port1;
15
+ const ab = new ArrayBuffer(0);
16
+ try { port.postMessage(ab, [ab, ab]); } catch (err) { return err.constructor }
17
+ })();
18
+
19
+ let s = 0;
20
+ const S = {
21
+ START_BOUNDARY: s++,
22
+ HEADER_FIELD_START: s++,
23
+ HEADER_FIELD: s++,
24
+ HEADER_VALUE_START: s++,
25
+ HEADER_VALUE: s++,
26
+ HEADER_VALUE_ALMOST_DONE: s++,
27
+ HEADERS_ALMOST_DONE: s++,
28
+ PART_DATA_START: s++,
29
+ PART_DATA: s++,
30
+ END: s++
31
+ };
32
+
33
+ let f = 1;
34
+ const F = {
35
+ PART_BOUNDARY: f,
36
+ LAST_BOUNDARY: f *= 2
37
+ };
38
+
39
+ const LF = 10;
40
+ const CR = 13;
41
+ const SPACE = 32;
42
+ const HYPHEN = 45;
43
+ const COLON = 58;
44
+ const A = 97;
45
+ const Z = 122;
46
+
47
+ const lower = c => c | 0x20;
48
+
49
+ const noop = () => {};
50
+
51
+ class MultipartParser {
52
+ /**
53
+ * @param {string} boundary
54
+ */
55
+ constructor(boundary) {
56
+ this.index = 0;
57
+ this.flags = 0;
58
+
59
+ this.onHeaderEnd = noop;
60
+ this.onHeaderField = noop;
61
+ this.onHeadersEnd = noop;
62
+ this.onHeaderValue = noop;
63
+ this.onPartBegin = noop;
64
+ this.onPartData = noop;
65
+ this.onPartEnd = noop;
66
+
67
+ this.boundaryChars = {};
68
+
69
+ boundary = '\r\n--' + boundary;
70
+ const ui8a = new Uint8Array(boundary.length);
71
+ for (let i = 0; i < boundary.length; i++) {
72
+ ui8a[i] = boundary.charCodeAt(i);
73
+ this.boundaryChars[ui8a[i]] = true;
74
+ }
75
+
76
+ this.boundary = ui8a;
77
+ this.lookbehind = new Uint8Array(this.boundary.length + 8);
78
+ this.state = S.START_BOUNDARY;
79
+ }
80
+
81
+ /**
82
+ * @param {Uint8Array} data
83
+ */
84
+ write(data) {
85
+ let i = 0;
86
+ const length_ = data.length;
87
+ let previousIndex = this.index;
88
+ let {lookbehind, boundary, boundaryChars, index, state, flags} = this;
89
+ const boundaryLength = this.boundary.length;
90
+ const boundaryEnd = boundaryLength - 1;
91
+ const bufferLength = data.length;
92
+ let c;
93
+ let cl;
94
+
95
+ const mark = name => {
96
+ this[name + 'Mark'] = i;
97
+ };
98
+
99
+ const clear = name => {
100
+ delete this[name + 'Mark'];
101
+ };
102
+
103
+ const callback = (callbackSymbol, start, end, ui8a) => {
104
+ if (start === undefined || start !== end) {
105
+ this[callbackSymbol](ui8a && ui8a.subarray(start, end));
106
+ }
107
+ };
108
+
109
+ const dataCallback = (name, clear) => {
110
+ const markSymbol = name + 'Mark';
111
+ if (!(markSymbol in this)) {
112
+ return;
113
+ }
114
+
115
+ if (clear) {
116
+ callback(name, this[markSymbol], i, data);
117
+ delete this[markSymbol];
118
+ } else {
119
+ callback(name, this[markSymbol], data.length, data);
120
+ this[markSymbol] = 0;
121
+ }
122
+ };
123
+
124
+ for (i = 0; i < length_; i++) {
125
+ c = data[i];
126
+
127
+ switch (state) {
128
+ case S.START_BOUNDARY:
129
+ if (index === boundary.length - 2) {
130
+ if (c === HYPHEN) {
131
+ flags |= F.LAST_BOUNDARY;
132
+ } else if (c !== CR) {
133
+ return;
134
+ }
135
+
136
+ index++;
137
+ break;
138
+ } else if (index - 1 === boundary.length - 2) {
139
+ if (flags & F.LAST_BOUNDARY && c === HYPHEN) {
140
+ state = S.END;
141
+ flags = 0;
142
+ } else if (!(flags & F.LAST_BOUNDARY) && c === LF) {
143
+ index = 0;
144
+ callback('onPartBegin');
145
+ state = S.HEADER_FIELD_START;
146
+ } else {
147
+ return;
148
+ }
149
+
150
+ break;
151
+ }
152
+
153
+ if (c !== boundary[index + 2]) {
154
+ index = -2;
155
+ }
156
+
157
+ if (c === boundary[index + 2]) {
158
+ index++;
159
+ }
160
+
161
+ break;
162
+ case S.HEADER_FIELD_START:
163
+ state = S.HEADER_FIELD;
164
+ mark('onHeaderField');
165
+ index = 0;
166
+ // falls through
167
+ case S.HEADER_FIELD:
168
+ if (c === CR) {
169
+ clear('onHeaderField');
170
+ state = S.HEADERS_ALMOST_DONE;
171
+ break;
172
+ }
173
+
174
+ index++;
175
+ if (c === HYPHEN) {
176
+ break;
177
+ }
178
+
179
+ if (c === COLON) {
180
+ if (index === 1) {
181
+ // empty header field
182
+ return;
183
+ }
184
+
185
+ dataCallback('onHeaderField', true);
186
+ state = S.HEADER_VALUE_START;
187
+ break;
188
+ }
189
+
190
+ cl = lower(c);
191
+ if (cl < A || cl > Z) {
192
+ return;
193
+ }
194
+
195
+ break;
196
+ case S.HEADER_VALUE_START:
197
+ if (c === SPACE) {
198
+ break;
199
+ }
200
+
201
+ mark('onHeaderValue');
202
+ state = S.HEADER_VALUE;
203
+ // falls through
204
+ case S.HEADER_VALUE:
205
+ if (c === CR) {
206
+ dataCallback('onHeaderValue', true);
207
+ callback('onHeaderEnd');
208
+ state = S.HEADER_VALUE_ALMOST_DONE;
209
+ }
210
+
211
+ break;
212
+ case S.HEADER_VALUE_ALMOST_DONE:
213
+ if (c !== LF) {
214
+ return;
215
+ }
216
+
217
+ state = S.HEADER_FIELD_START;
218
+ break;
219
+ case S.HEADERS_ALMOST_DONE:
220
+ if (c !== LF) {
221
+ return;
222
+ }
223
+
224
+ callback('onHeadersEnd');
225
+ state = S.PART_DATA_START;
226
+ break;
227
+ case S.PART_DATA_START:
228
+ state = S.PART_DATA;
229
+ mark('onPartData');
230
+ // falls through
231
+ case S.PART_DATA:
232
+ previousIndex = index;
233
+
234
+ if (index === 0) {
235
+ // boyer-moore derrived algorithm to safely skip non-boundary data
236
+ i += boundaryEnd;
237
+ while (i < bufferLength && !(data[i] in boundaryChars)) {
238
+ i += boundaryLength;
239
+ }
240
+
241
+ i -= boundaryEnd;
242
+ c = data[i];
243
+ }
244
+
245
+ if (index < boundary.length) {
246
+ if (boundary[index] === c) {
247
+ if (index === 0) {
248
+ dataCallback('onPartData', true);
249
+ }
250
+
251
+ index++;
252
+ } else {
253
+ index = 0;
254
+ }
255
+ } else if (index === boundary.length) {
256
+ index++;
257
+ if (c === CR) {
258
+ // CR = part boundary
259
+ flags |= F.PART_BOUNDARY;
260
+ } else if (c === HYPHEN) {
261
+ // HYPHEN = end boundary
262
+ flags |= F.LAST_BOUNDARY;
263
+ } else {
264
+ index = 0;
265
+ }
266
+ } else if (index - 1 === boundary.length) {
267
+ if (flags & F.PART_BOUNDARY) {
268
+ index = 0;
269
+ if (c === LF) {
270
+ // unset the PART_BOUNDARY flag
271
+ flags &= ~F.PART_BOUNDARY;
272
+ callback('onPartEnd');
273
+ callback('onPartBegin');
274
+ state = S.HEADER_FIELD_START;
275
+ break;
276
+ }
277
+ } else if (flags & F.LAST_BOUNDARY) {
278
+ if (c === HYPHEN) {
279
+ callback('onPartEnd');
280
+ state = S.END;
281
+ flags = 0;
282
+ } else {
283
+ index = 0;
284
+ }
285
+ } else {
286
+ index = 0;
287
+ }
288
+ }
289
+
290
+ if (index > 0) {
291
+ // when matching a possible boundary, keep a lookbehind reference
292
+ // in case it turns out to be a false lead
293
+ lookbehind[index - 1] = c;
294
+ } else if (previousIndex > 0) {
295
+ // if our boundary turned out to be rubbish, the captured lookbehind
296
+ // belongs to partData
297
+ const _lookbehind = new Uint8Array(lookbehind.buffer, lookbehind.byteOffset, lookbehind.byteLength);
298
+ callback('onPartData', 0, previousIndex, _lookbehind);
299
+ previousIndex = 0;
300
+ mark('onPartData');
301
+
302
+ // reconsider the current character even so it interrupted the sequence
303
+ // it could be the beginning of a new sequence
304
+ i--;
305
+ }
306
+
307
+ break;
308
+ case S.END:
309
+ break;
310
+ default:
311
+ throw new Error(`Unexpected state entered: ${state}`);
312
+ }
313
+ }
314
+
315
+ dataCallback('onHeaderField');
316
+ dataCallback('onHeaderValue');
317
+ dataCallback('onPartData');
318
+
319
+ // Update properties for the next call
320
+ this.index = index;
321
+ this.state = state;
322
+ this.flags = flags;
323
+ }
324
+
325
+ end() {
326
+ if ((this.state === S.HEADER_FIELD_START && this.index === 0) ||
327
+ (this.state === S.PART_DATA && this.index === this.boundary.length)) {
328
+ this.onPartEnd();
329
+ } else if (this.state !== S.END) {
330
+ throw new Error('MultipartParser.end(): stream ended unexpectedly');
331
+ }
332
+ }
333
+ }
334
+
335
+ function _fileName(headerValue) {
336
+ // matches either a quoted-string or a token (RFC 2616 section 19.5.1)
337
+ const m = headerValue.match(/\bfilename=("(.*?)"|([^()<>@,;:\\"/[\]?={}\s\t]+))($|;\s)/i);
338
+ if (!m) {
339
+ return;
340
+ }
341
+
342
+ const match = m[2] || m[3] || '';
343
+ let filename = match.slice(match.lastIndexOf('\\') + 1);
344
+ filename = filename.replace(/%22/g, '"');
345
+ filename = filename.replace(/&#(\d{4});/g, (m, code) => {
346
+ return String.fromCharCode(code);
347
+ });
348
+ return filename;
349
+ }
350
+
351
+ async function toFormData(Body, ct) {
352
+ if (!/multipart/i.test(ct)) {
353
+ throw new TypeError('Failed to fetch');
354
+ }
355
+
356
+ const m = ct.match(/boundary=(?:"([^"]+)"|([^;]+))/i);
357
+
358
+ if (!m) {
359
+ throw new TypeError('no or bad content-type header, no multipart boundary');
360
+ }
361
+
362
+ const parser = new MultipartParser(m[1] || m[2]);
363
+
364
+ let headerField;
365
+ let headerValue;
366
+ let entryValue;
367
+ let entryName;
368
+ let contentType;
369
+ let filename;
370
+ const entryChunks = [];
371
+ const formData = new FormData();
372
+
373
+ const onPartData = ui8a => {
374
+ entryValue += decoder.decode(ui8a, {stream: true});
375
+ };
376
+
377
+ const appendToFile = ui8a => {
378
+ entryChunks.push(ui8a);
379
+ };
380
+
381
+ const appendFileToFormData = () => {
382
+ const file = new File(entryChunks, filename, {type: contentType});
383
+ formData.append(entryName, file);
384
+ };
385
+
386
+ const appendEntryToFormData = () => {
387
+ formData.append(entryName, entryValue);
388
+ };
389
+
390
+ const decoder = new TextDecoder('utf-8');
391
+ decoder.decode();
392
+
393
+ parser.onPartBegin = function () {
394
+ parser.onPartData = onPartData;
395
+ parser.onPartEnd = appendEntryToFormData;
396
+
397
+ headerField = '';
398
+ headerValue = '';
399
+ entryValue = '';
400
+ entryName = '';
401
+ contentType = '';
402
+ filename = null;
403
+ entryChunks.length = 0;
404
+ };
405
+
406
+ parser.onHeaderField = function (ui8a) {
407
+ headerField += decoder.decode(ui8a, {stream: true});
408
+ };
409
+
410
+ parser.onHeaderValue = function (ui8a) {
411
+ headerValue += decoder.decode(ui8a, {stream: true});
412
+ };
413
+
414
+ parser.onHeaderEnd = function () {
415
+ headerValue += decoder.decode();
416
+ headerField = headerField.toLowerCase();
417
+
418
+ if (headerField === 'content-disposition') {
419
+ // matches either a quoted-string or a token (RFC 2616 section 19.5.1)
420
+ const m = headerValue.match(/\bname=("([^"]*)"|([^()<>@,;:\\"/[\]?={}\s\t]+))/i);
421
+
422
+ if (m) {
423
+ entryName = m[2] || m[3] || '';
424
+ }
425
+
426
+ filename = _fileName(headerValue);
427
+
428
+ if (filename) {
429
+ parser.onPartData = appendToFile;
430
+ parser.onPartEnd = appendFileToFormData;
431
+ }
432
+ } else if (headerField === 'content-type') {
433
+ contentType = headerValue;
434
+ }
435
+
436
+ headerValue = '';
437
+ headerField = '';
438
+ };
439
+
440
+ for await (const chunk of Body) {
441
+ parser.write(chunk);
442
+ }
443
+
444
+ parser.end();
445
+
446
+ return formData;
447
+ }
448
+
449
+ export { toFormData };
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Takes zero or more objects and returns a new object that has all the values
3
+ * deeply merged together. None of the original objects will be mutated at any
4
+ * level, and the returned object will have no references to the original
5
+ * objects at any depth. If there's a conflict the last one wins, except for
6
+ * arrays which will be combined.
7
+ * @param {...Object} objects
8
+ * @returns {[Record<string, any>, string[]]} a 2-tuple with the merged object,
9
+ * and a list of merge conflicts if there were any, in dotted notation
10
+ */
11
+ function deep_merge(...objects) {
12
+ const result = {};
13
+ /** @type {string[]} */
14
+ const conflicts = [];
15
+ objects.forEach((o) => merge_into(result, o, conflicts));
16
+ return [result, conflicts];
17
+ }
18
+
19
+ /**
20
+ * normalize kit.vite.resolve.alias as an array
21
+ * @param {import('vite').AliasOptions} o
22
+ * @returns {import('vite').Alias[]}
23
+ */
24
+ function normalize_alias(o) {
25
+ if (Array.isArray(o)) return o;
26
+ return Object.entries(o).map(([find, replacement]) => ({ find, replacement }));
27
+ }
28
+
29
+ /**
30
+ * Merges b into a, recursively, mutating a.
31
+ * @param {Record<string, any>} a
32
+ * @param {Record<string, any>} b
33
+ * @param {string[]} conflicts array to accumulate conflicts in
34
+ * @param {string[]} path array of property names representing the current
35
+ * location in the tree
36
+ */
37
+ function merge_into(a, b, conflicts = [], path = []) {
38
+ /**
39
+ * Checks for "plain old Javascript object", typically made as an object
40
+ * literal. Excludes Arrays and built-in types like Buffer.
41
+ * @param {any} x
42
+ */
43
+ const is_plain_object = (x) => typeof x === 'object' && x.constructor === Object;
44
+
45
+ for (const prop in b) {
46
+ // normalize alias objects to array
47
+ if (prop === 'alias' && path[path.length - 1] === 'resolve') {
48
+ if (a[prop]) a[prop] = normalize_alias(a[prop]);
49
+ if (b[prop]) b[prop] = normalize_alias(b[prop]);
50
+ }
51
+
52
+ if (is_plain_object(b[prop])) {
53
+ if (!is_plain_object(a[prop])) {
54
+ if (a[prop] !== undefined) {
55
+ conflicts.push([...path, prop].join('.'));
56
+ }
57
+ a[prop] = {};
58
+ }
59
+ merge_into(a[prop], b[prop], conflicts, [...path, prop]);
60
+ } else if (Array.isArray(b[prop])) {
61
+ if (!Array.isArray(a[prop])) {
62
+ if (a[prop] !== undefined) {
63
+ conflicts.push([...path, prop].join('.'));
64
+ }
65
+ a[prop] = [];
66
+ }
67
+ a[prop].push(...b[prop]);
68
+ } else {
69
+ // Since we're inside a for/in loop which loops over enumerable
70
+ // properties only, we want parity here and to check if 'a' has
71
+ // enumerable-only property 'prop'. Using 'hasOwnProperty' to
72
+ // exclude inherited properties is close enough. It is possible
73
+ // that someone uses Object.defineProperty to create a direct,
74
+ // non-enumerable property but let's not worry about that.
75
+ if (Object.prototype.hasOwnProperty.call(a, prop)) {
76
+ conflicts.push([...path, prop].join('.'));
77
+ }
78
+ a[prop] = b[prop];
79
+ }
80
+ }
81
+ }
82
+
83
+ export { deep_merge as d };
@@ -0,0 +1,39 @@
1
+ /** @param {string} key */
2
+ function parse_route_id(key) {
3
+ /** @type {string[]} */
4
+ const names = [];
5
+
6
+ /** @type {string[]} */
7
+ const types = [];
8
+
9
+ const pattern =
10
+ key === ''
11
+ ? /^\/$/
12
+ : new RegExp(
13
+ `^${decodeURIComponent(key)
14
+ .split('/')
15
+ .map((segment) => {
16
+ // special case — /[...rest]/ could contain zero segments
17
+ const match = /^\[\.\.\.(\w+)(?:=\w+)?\]$/.exec(segment);
18
+ if (match) {
19
+ names.push(match[1]);
20
+ types.push(match[2]);
21
+ return '(?:/(.*))?';
22
+ }
23
+
24
+ return (
25
+ '/' +
26
+ segment.replace(/\[(\.\.\.)?(\w+)(?:=(\w+))?\]/g, (m, rest, name, type) => {
27
+ names.push(name);
28
+ types.push(type);
29
+ return rest ? '(.*?)' : '([^/]+?)';
30
+ })
31
+ );
32
+ })
33
+ .join('')}/?$`
34
+ );
35
+
36
+ return { pattern, names, types };
37
+ }
38
+
39
+ export { parse_route_id as p };