@sveltejs/adapter-netlify 1.0.0-next.65 → 1.0.0-next.68

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.
package/index.js CHANGED
@@ -137,8 +137,9 @@ async function generate_edge_functions({ builder }) {
137
137
  outfile: '.netlify/edge-functions/render.js',
138
138
  bundle: true,
139
139
  format: 'esm',
140
- target: 'es2020',
141
- platform: 'browser'
140
+ platform: 'browser',
141
+ sourcemap: 'linked',
142
+ target: 'es2020'
142
143
  });
143
144
 
144
145
  writeFileSync('.netlify/edge-functions/manifest.json', JSON.stringify(edge_manifest));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/adapter-netlify",
3
- "version": "1.0.0-next.65",
3
+ "version": "1.0.0-next.68",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sveltejs/kit",
@@ -30,15 +30,15 @@
30
30
  },
31
31
  "devDependencies": {
32
32
  "@netlify/functions": "^1.0.0",
33
- "@rollup/plugin-commonjs": "^21.1.0",
33
+ "@rollup/plugin-commonjs": "^22.0.1",
34
34
  "@rollup/plugin-json": "^4.1.0",
35
35
  "@rollup/plugin-node-resolve": "^13.3.0",
36
- "@sveltejs/kit": "1.0.0-next.352",
36
+ "@sveltejs/kit": "1.0.0-next.370",
37
37
  "@types/node": "^16.11.36",
38
38
  "@types/set-cookie-parser": "^2.4.2",
39
39
  "rimraf": "^3.0.2",
40
40
  "rollup": "^2.75.3",
41
- "typescript": "^4.7.2",
41
+ "typescript": "^4.7.4",
42
42
  "uvu": "^0.5.3"
43
43
  },
44
44
  "scripts": {
@@ -1,446 +0,0 @@
1
- 'use strict';
2
-
3
- require('node:fs');
4
- require('node:path');
5
- var shims = require('./shims.js');
6
- require('node:http');
7
- require('node:https');
8
- require('node:zlib');
9
- require('node:stream');
10
- require('node:buffer');
11
- require('node:util');
12
- require('node:url');
13
- require('node:net');
14
- require('crypto');
15
-
16
- let s = 0;
17
- const S = {
18
- START_BOUNDARY: s++,
19
- HEADER_FIELD_START: s++,
20
- HEADER_FIELD: s++,
21
- HEADER_VALUE_START: s++,
22
- HEADER_VALUE: s++,
23
- HEADER_VALUE_ALMOST_DONE: s++,
24
- HEADERS_ALMOST_DONE: s++,
25
- PART_DATA_START: s++,
26
- PART_DATA: s++,
27
- END: s++
28
- };
29
-
30
- let f = 1;
31
- const F = {
32
- PART_BOUNDARY: f,
33
- LAST_BOUNDARY: f *= 2
34
- };
35
-
36
- const LF = 10;
37
- const CR = 13;
38
- const SPACE = 32;
39
- const HYPHEN = 45;
40
- const COLON = 58;
41
- const A = 97;
42
- const Z = 122;
43
-
44
- const lower = c => c | 0x20;
45
-
46
- const noop = () => {};
47
-
48
- class MultipartParser {
49
- /**
50
- * @param {string} boundary
51
- */
52
- constructor(boundary) {
53
- this.index = 0;
54
- this.flags = 0;
55
-
56
- this.onHeaderEnd = noop;
57
- this.onHeaderField = noop;
58
- this.onHeadersEnd = noop;
59
- this.onHeaderValue = noop;
60
- this.onPartBegin = noop;
61
- this.onPartData = noop;
62
- this.onPartEnd = noop;
63
-
64
- this.boundaryChars = {};
65
-
66
- boundary = '\r\n--' + boundary;
67
- const ui8a = new Uint8Array(boundary.length);
68
- for (let i = 0; i < boundary.length; i++) {
69
- ui8a[i] = boundary.charCodeAt(i);
70
- this.boundaryChars[ui8a[i]] = true;
71
- }
72
-
73
- this.boundary = ui8a;
74
- this.lookbehind = new Uint8Array(this.boundary.length + 8);
75
- this.state = S.START_BOUNDARY;
76
- }
77
-
78
- /**
79
- * @param {Uint8Array} data
80
- */
81
- write(data) {
82
- let i = 0;
83
- const length_ = data.length;
84
- let previousIndex = this.index;
85
- let {lookbehind, boundary, boundaryChars, index, state, flags} = this;
86
- const boundaryLength = this.boundary.length;
87
- const boundaryEnd = boundaryLength - 1;
88
- const bufferLength = data.length;
89
- let c;
90
- let cl;
91
-
92
- const mark = name => {
93
- this[name + 'Mark'] = i;
94
- };
95
-
96
- const clear = name => {
97
- delete this[name + 'Mark'];
98
- };
99
-
100
- const callback = (callbackSymbol, start, end, ui8a) => {
101
- if (start === undefined || start !== end) {
102
- this[callbackSymbol](ui8a && ui8a.subarray(start, end));
103
- }
104
- };
105
-
106
- const dataCallback = (name, clear) => {
107
- const markSymbol = name + 'Mark';
108
- if (!(markSymbol in this)) {
109
- return;
110
- }
111
-
112
- if (clear) {
113
- callback(name, this[markSymbol], i, data);
114
- delete this[markSymbol];
115
- } else {
116
- callback(name, this[markSymbol], data.length, data);
117
- this[markSymbol] = 0;
118
- }
119
- };
120
-
121
- for (i = 0; i < length_; i++) {
122
- c = data[i];
123
-
124
- switch (state) {
125
- case S.START_BOUNDARY:
126
- if (index === boundary.length - 2) {
127
- if (c === HYPHEN) {
128
- flags |= F.LAST_BOUNDARY;
129
- } else if (c !== CR) {
130
- return;
131
- }
132
-
133
- index++;
134
- break;
135
- } else if (index - 1 === boundary.length - 2) {
136
- if (flags & F.LAST_BOUNDARY && c === HYPHEN) {
137
- state = S.END;
138
- flags = 0;
139
- } else if (!(flags & F.LAST_BOUNDARY) && c === LF) {
140
- index = 0;
141
- callback('onPartBegin');
142
- state = S.HEADER_FIELD_START;
143
- } else {
144
- return;
145
- }
146
-
147
- break;
148
- }
149
-
150
- if (c !== boundary[index + 2]) {
151
- index = -2;
152
- }
153
-
154
- if (c === boundary[index + 2]) {
155
- index++;
156
- }
157
-
158
- break;
159
- case S.HEADER_FIELD_START:
160
- state = S.HEADER_FIELD;
161
- mark('onHeaderField');
162
- index = 0;
163
- // falls through
164
- case S.HEADER_FIELD:
165
- if (c === CR) {
166
- clear('onHeaderField');
167
- state = S.HEADERS_ALMOST_DONE;
168
- break;
169
- }
170
-
171
- index++;
172
- if (c === HYPHEN) {
173
- break;
174
- }
175
-
176
- if (c === COLON) {
177
- if (index === 1) {
178
- // empty header field
179
- return;
180
- }
181
-
182
- dataCallback('onHeaderField', true);
183
- state = S.HEADER_VALUE_START;
184
- break;
185
- }
186
-
187
- cl = lower(c);
188
- if (cl < A || cl > Z) {
189
- return;
190
- }
191
-
192
- break;
193
- case S.HEADER_VALUE_START:
194
- if (c === SPACE) {
195
- break;
196
- }
197
-
198
- mark('onHeaderValue');
199
- state = S.HEADER_VALUE;
200
- // falls through
201
- case S.HEADER_VALUE:
202
- if (c === CR) {
203
- dataCallback('onHeaderValue', true);
204
- callback('onHeaderEnd');
205
- state = S.HEADER_VALUE_ALMOST_DONE;
206
- }
207
-
208
- break;
209
- case S.HEADER_VALUE_ALMOST_DONE:
210
- if (c !== LF) {
211
- return;
212
- }
213
-
214
- state = S.HEADER_FIELD_START;
215
- break;
216
- case S.HEADERS_ALMOST_DONE:
217
- if (c !== LF) {
218
- return;
219
- }
220
-
221
- callback('onHeadersEnd');
222
- state = S.PART_DATA_START;
223
- break;
224
- case S.PART_DATA_START:
225
- state = S.PART_DATA;
226
- mark('onPartData');
227
- // falls through
228
- case S.PART_DATA:
229
- previousIndex = index;
230
-
231
- if (index === 0) {
232
- // boyer-moore derrived algorithm to safely skip non-boundary data
233
- i += boundaryEnd;
234
- while (i < bufferLength && !(data[i] in boundaryChars)) {
235
- i += boundaryLength;
236
- }
237
-
238
- i -= boundaryEnd;
239
- c = data[i];
240
- }
241
-
242
- if (index < boundary.length) {
243
- if (boundary[index] === c) {
244
- if (index === 0) {
245
- dataCallback('onPartData', true);
246
- }
247
-
248
- index++;
249
- } else {
250
- index = 0;
251
- }
252
- } else if (index === boundary.length) {
253
- index++;
254
- if (c === CR) {
255
- // CR = part boundary
256
- flags |= F.PART_BOUNDARY;
257
- } else if (c === HYPHEN) {
258
- // HYPHEN = end boundary
259
- flags |= F.LAST_BOUNDARY;
260
- } else {
261
- index = 0;
262
- }
263
- } else if (index - 1 === boundary.length) {
264
- if (flags & F.PART_BOUNDARY) {
265
- index = 0;
266
- if (c === LF) {
267
- // unset the PART_BOUNDARY flag
268
- flags &= ~F.PART_BOUNDARY;
269
- callback('onPartEnd');
270
- callback('onPartBegin');
271
- state = S.HEADER_FIELD_START;
272
- break;
273
- }
274
- } else if (flags & F.LAST_BOUNDARY) {
275
- if (c === HYPHEN) {
276
- callback('onPartEnd');
277
- state = S.END;
278
- flags = 0;
279
- } else {
280
- index = 0;
281
- }
282
- } else {
283
- index = 0;
284
- }
285
- }
286
-
287
- if (index > 0) {
288
- // when matching a possible boundary, keep a lookbehind reference
289
- // in case it turns out to be a false lead
290
- lookbehind[index - 1] = c;
291
- } else if (previousIndex > 0) {
292
- // if our boundary turned out to be rubbish, the captured lookbehind
293
- // belongs to partData
294
- const _lookbehind = new Uint8Array(lookbehind.buffer, lookbehind.byteOffset, lookbehind.byteLength);
295
- callback('onPartData', 0, previousIndex, _lookbehind);
296
- previousIndex = 0;
297
- mark('onPartData');
298
-
299
- // reconsider the current character even so it interrupted the sequence
300
- // it could be the beginning of a new sequence
301
- i--;
302
- }
303
-
304
- break;
305
- case S.END:
306
- break;
307
- default:
308
- throw new Error(`Unexpected state entered: ${state}`);
309
- }
310
- }
311
-
312
- dataCallback('onHeaderField');
313
- dataCallback('onHeaderValue');
314
- dataCallback('onPartData');
315
-
316
- // Update properties for the next call
317
- this.index = index;
318
- this.state = state;
319
- this.flags = flags;
320
- }
321
-
322
- end() {
323
- if ((this.state === S.HEADER_FIELD_START && this.index === 0) ||
324
- (this.state === S.PART_DATA && this.index === this.boundary.length)) {
325
- this.onPartEnd();
326
- } else if (this.state !== S.END) {
327
- throw new Error('MultipartParser.end(): stream ended unexpectedly');
328
- }
329
- }
330
- }
331
-
332
- function _fileName(headerValue) {
333
- // matches either a quoted-string or a token (RFC 2616 section 19.5.1)
334
- const m = headerValue.match(/\bfilename=("(.*?)"|([^()<>@,;:\\"/[\]?={}\s\t]+))($|;\s)/i);
335
- if (!m) {
336
- return;
337
- }
338
-
339
- const match = m[2] || m[3] || '';
340
- let filename = match.slice(match.lastIndexOf('\\') + 1);
341
- filename = filename.replace(/%22/g, '"');
342
- filename = filename.replace(/&#(\d{4});/g, (m, code) => {
343
- return String.fromCharCode(code);
344
- });
345
- return filename;
346
- }
347
-
348
- async function toFormData(Body, ct) {
349
- if (!/multipart/i.test(ct)) {
350
- throw new TypeError('Failed to fetch');
351
- }
352
-
353
- const m = ct.match(/boundary=(?:"([^"]+)"|([^;]+))/i);
354
-
355
- if (!m) {
356
- throw new TypeError('no or bad content-type header, no multipart boundary');
357
- }
358
-
359
- const parser = new MultipartParser(m[1] || m[2]);
360
-
361
- let headerField;
362
- let headerValue;
363
- let entryValue;
364
- let entryName;
365
- let contentType;
366
- let filename;
367
- const entryChunks = [];
368
- const formData = new shims.FormData();
369
-
370
- const onPartData = ui8a => {
371
- entryValue += decoder.decode(ui8a, {stream: true});
372
- };
373
-
374
- const appendToFile = ui8a => {
375
- entryChunks.push(ui8a);
376
- };
377
-
378
- const appendFileToFormData = () => {
379
- const file = new shims.File(entryChunks, filename, {type: contentType});
380
- formData.append(entryName, file);
381
- };
382
-
383
- const appendEntryToFormData = () => {
384
- formData.append(entryName, entryValue);
385
- };
386
-
387
- const decoder = new TextDecoder('utf-8');
388
- decoder.decode();
389
-
390
- parser.onPartBegin = function () {
391
- parser.onPartData = onPartData;
392
- parser.onPartEnd = appendEntryToFormData;
393
-
394
- headerField = '';
395
- headerValue = '';
396
- entryValue = '';
397
- entryName = '';
398
- contentType = '';
399
- filename = null;
400
- entryChunks.length = 0;
401
- };
402
-
403
- parser.onHeaderField = function (ui8a) {
404
- headerField += decoder.decode(ui8a, {stream: true});
405
- };
406
-
407
- parser.onHeaderValue = function (ui8a) {
408
- headerValue += decoder.decode(ui8a, {stream: true});
409
- };
410
-
411
- parser.onHeaderEnd = function () {
412
- headerValue += decoder.decode();
413
- headerField = headerField.toLowerCase();
414
-
415
- if (headerField === 'content-disposition') {
416
- // matches either a quoted-string or a token (RFC 2616 section 19.5.1)
417
- const m = headerValue.match(/\bname=("([^"]*)"|([^()<>@,;:\\"/[\]?={}\s\t]+))/i);
418
-
419
- if (m) {
420
- entryName = m[2] || m[3] || '';
421
- }
422
-
423
- filename = _fileName(headerValue);
424
-
425
- if (filename) {
426
- parser.onPartData = appendToFile;
427
- parser.onPartEnd = appendFileToFormData;
428
- }
429
- } else if (headerField === 'content-type') {
430
- contentType = headerValue;
431
- }
432
-
433
- headerValue = '';
434
- headerField = '';
435
- };
436
-
437
- for await (const chunk of Body) {
438
- parser.write(chunk);
439
- }
440
-
441
- parser.end();
442
-
443
- return formData;
444
- }
445
-
446
- exports.toFormData = toFormData;