@sveltejs/kit 1.0.0-next.192 → 1.0.0-next.196
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/assets/runtime/internal/start.js +38 -14
- package/dist/chunks/http.js +1 -0
- package/dist/chunks/index3.js +1 -6
- package/dist/chunks/index5.js +13 -7
- package/dist/cli.js +12 -6
- package/dist/install-fetch.js +246 -215
- package/dist/ssr.js +2 -4
- package/package.json +1 -3
|
@@ -93,7 +93,8 @@ class Router {
|
|
|
93
93
|
'sveltekit:scroll': scroll_state()
|
|
94
94
|
};
|
|
95
95
|
history.replaceState(new_state, document.title, window.location.href);
|
|
96
|
-
|
|
96
|
+
// iOS scroll event intervals happen between 30-150ms, sometimes around 200ms
|
|
97
|
+
}, 200);
|
|
97
98
|
});
|
|
98
99
|
|
|
99
100
|
/** @param {MouseEvent|TouchEvent} event */
|
|
@@ -655,28 +656,51 @@ class Renderer {
|
|
|
655
656
|
this._init(navigation_result);
|
|
656
657
|
}
|
|
657
658
|
|
|
658
|
-
|
|
659
|
+
getSelection()?.removeAllRanges();
|
|
660
|
+
|
|
661
|
+
if (!opts) {
|
|
662
|
+
await 0;
|
|
663
|
+
} else {
|
|
659
664
|
const { hash, scroll, keepfocus } = opts;
|
|
660
665
|
|
|
661
666
|
if (!keepfocus) {
|
|
662
667
|
document.body.focus();
|
|
663
668
|
}
|
|
664
669
|
|
|
665
|
-
const
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
670
|
+
const old_page_y_offset = Math.round(pageYOffset);
|
|
671
|
+
const old_max_page_y_offset = document.documentElement.scrollHeight - innerHeight;
|
|
672
|
+
|
|
673
|
+
await 0;
|
|
674
|
+
|
|
675
|
+
const new_page_y_offset = Math.round(pageYOffset);
|
|
676
|
+
const new_max_page_y_offset = document.documentElement.scrollHeight - innerHeight;
|
|
677
|
+
|
|
678
|
+
// After `await 0`, the `onMount()` function in the component executed.
|
|
679
|
+
// Check if no scrolling happened on mount.
|
|
680
|
+
const no_scroll_happened =
|
|
681
|
+
// In most cases, we can compare whether `pageYOffset` changed between navigation
|
|
682
|
+
new_page_y_offset === Math.min(old_page_y_offset, new_max_page_y_offset) ||
|
|
683
|
+
// But if the page is scrolled to/near the bottom, the browser would also scroll
|
|
684
|
+
// to/near the bottom of the new page on navigation. Since we can't detect when this
|
|
685
|
+
// behaviour happens, we naively compare by the y offset from the bottom of the page.
|
|
686
|
+
old_max_page_y_offset - old_page_y_offset === new_max_page_y_offset - new_page_y_offset;
|
|
687
|
+
|
|
688
|
+
// If there was no scrolling, we run on our custom scroll handling
|
|
689
|
+
if (no_scroll_happened) {
|
|
690
|
+
const deep_linked = hash && document.getElementById(hash.slice(1));
|
|
691
|
+
if (scroll) {
|
|
692
|
+
scrollTo(scroll.x, scroll.y);
|
|
693
|
+
} else if (deep_linked) {
|
|
694
|
+
// Here we use `scrollIntoView` on the element instead of `scrollTo`
|
|
695
|
+
// because it natively supports the `scroll-margin` and `scroll-behavior`
|
|
696
|
+
// CSS properties.
|
|
697
|
+
deep_linked.scrollIntoView();
|
|
698
|
+
} else {
|
|
699
|
+
scrollTo(0, 0);
|
|
700
|
+
}
|
|
675
701
|
}
|
|
676
702
|
}
|
|
677
703
|
|
|
678
|
-
await 0;
|
|
679
|
-
|
|
680
704
|
this.loading.promise = null;
|
|
681
705
|
this.loading.id = null;
|
|
682
706
|
|
package/dist/chunks/http.js
CHANGED
package/dist/chunks/index3.js
CHANGED
package/dist/chunks/index5.js
CHANGED
|
@@ -153,20 +153,26 @@ function send(req, res, file, stats, headers) {
|
|
|
153
153
|
fs.createReadStream(file, opts).pipe(res);
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
156
|
+
const ENCODING = {
|
|
157
|
+
'.br': 'br',
|
|
158
|
+
'.gz': 'gzip',
|
|
159
|
+
};
|
|
160
160
|
|
|
161
161
|
function toHeaders(name, stats, isEtag) {
|
|
162
|
+
let enc = ENCODING[name.slice(-3)];
|
|
163
|
+
|
|
164
|
+
let ctype = lite.getType(name.slice(0, enc && -3)) || '';
|
|
165
|
+
if (ctype === 'text/html') ctype += ';charset=utf-8';
|
|
166
|
+
|
|
162
167
|
let headers = {
|
|
163
168
|
'Content-Length': stats.size,
|
|
164
|
-
'Content-Type':
|
|
169
|
+
'Content-Type': ctype,
|
|
165
170
|
'Last-Modified': stats.mtime.toUTCString(),
|
|
166
171
|
};
|
|
172
|
+
|
|
173
|
+
if (enc) headers['Content-Encoding'] = enc;
|
|
167
174
|
if (isEtag) headers['ETag'] = `W/"${stats.size}-${stats.mtime.getTime()}"`;
|
|
168
|
-
|
|
169
|
-
if (/\.gz$/.test(name)) isEncoding(name, 'gzip', headers);
|
|
175
|
+
|
|
170
176
|
return headers;
|
|
171
177
|
}
|
|
172
178
|
|
package/dist/cli.js
CHANGED
|
@@ -817,7 +817,7 @@ async function launch(port, https) {
|
|
|
817
817
|
exec(`${cmd} ${https ? 'https' : 'http'}://localhost:${port}`);
|
|
818
818
|
}
|
|
819
819
|
|
|
820
|
-
const prog = sade('svelte-kit').version('1.0.0-next.
|
|
820
|
+
const prog = sade('svelte-kit').version('1.0.0-next.196');
|
|
821
821
|
|
|
822
822
|
prog
|
|
823
823
|
.command('dev')
|
|
@@ -851,14 +851,17 @@ prog
|
|
|
851
851
|
watcher.vite.httpServer.address()
|
|
852
852
|
);
|
|
853
853
|
|
|
854
|
-
|
|
855
|
-
|
|
854
|
+
const vite_config = config.kit.vite();
|
|
855
|
+
|
|
856
|
+
https = https || !!vite_config.server?.https;
|
|
857
|
+
open = open || !!vite_config.server?.open;
|
|
856
858
|
|
|
857
859
|
welcome({
|
|
858
860
|
port: address_info.port,
|
|
859
861
|
host: address_info.address,
|
|
860
862
|
https,
|
|
861
863
|
open,
|
|
864
|
+
loose: vite_config.server?.fs?.strict === false,
|
|
862
865
|
allow: watcher.allowed_directories(),
|
|
863
866
|
cwd: watcher.cwd
|
|
864
867
|
});
|
|
@@ -971,14 +974,15 @@ async function check_port(port) {
|
|
|
971
974
|
* host: string;
|
|
972
975
|
* https: boolean;
|
|
973
976
|
* port: number;
|
|
977
|
+
* loose?: boolean;
|
|
974
978
|
* allow?: string[];
|
|
975
979
|
* cwd?: string;
|
|
976
980
|
* }} param0
|
|
977
981
|
*/
|
|
978
|
-
function welcome({ port, host, https, open, allow, cwd }) {
|
|
982
|
+
function welcome({ port, host, https, open, loose, allow, cwd }) {
|
|
979
983
|
if (open) launch(port, https);
|
|
980
984
|
|
|
981
|
-
console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.
|
|
985
|
+
console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.196'}\n`));
|
|
982
986
|
|
|
983
987
|
const protocol = https ? 'https:' : 'http:';
|
|
984
988
|
const exposed = typeof host !== 'undefined' && host !== 'localhost' && host !== '127.0.0.1';
|
|
@@ -996,7 +1000,9 @@ function welcome({ port, host, https, open, allow, cwd }) {
|
|
|
996
1000
|
|
|
997
1001
|
if (exposed) {
|
|
998
1002
|
console.log(` ${$.gray('network:')} ${protocol}//${$.bold(`${details.address}:${port}`)}`);
|
|
999
|
-
if (
|
|
1003
|
+
if (loose) {
|
|
1004
|
+
console.log(`\n ${$.yellow('Serving with vite.server.fs.strict: false. Note that all files on your machine will be accessible to anyone on your network.')}`);
|
|
1005
|
+
} else if (allow?.length && cwd) {
|
|
1000
1006
|
console.log(`\n ${$.yellow('Note that all files in the following directories will be accessible to anyone on your network: ' + allow.map(a => relative(cwd, a)).join(', '))}`);
|
|
1001
1007
|
}
|
|
1002
1008
|
} else {
|
package/dist/install-fetch.js
CHANGED
|
@@ -4238,38 +4238,54 @@ var ponyfill_es2018 = {exports: {}};
|
|
|
4238
4238
|
const POOL_SIZE$1 = 65536;
|
|
4239
4239
|
|
|
4240
4240
|
if (!globalThis.ReadableStream) {
|
|
4241
|
+
// `node:stream/web` got introduced in v16.5.0 as experimental
|
|
4242
|
+
// and it's preferred over the polyfilled version. So we also
|
|
4243
|
+
// suppress the warning that gets emitted by NodeJS for using it.
|
|
4241
4244
|
try {
|
|
4242
|
-
|
|
4245
|
+
const process = require('node:process');
|
|
4246
|
+
const { emitWarning } = process;
|
|
4247
|
+
try {
|
|
4248
|
+
process.emitWarning = () => {};
|
|
4249
|
+
Object.assign(globalThis, require('node:stream/web'));
|
|
4250
|
+
process.emitWarning = emitWarning;
|
|
4251
|
+
} catch (error) {
|
|
4252
|
+
process.emitWarning = emitWarning;
|
|
4253
|
+
throw error
|
|
4254
|
+
}
|
|
4243
4255
|
} catch (error) {
|
|
4244
|
-
|
|
4256
|
+
// fallback to polyfill implementation
|
|
4245
4257
|
Object.assign(globalThis, ponyfill_es2018.exports);
|
|
4246
4258
|
}
|
|
4247
4259
|
}
|
|
4248
4260
|
|
|
4249
4261
|
try {
|
|
4250
|
-
|
|
4262
|
+
// Don't use node: prefix for this, require+node: is not supported until node v14.14
|
|
4263
|
+
// Only `import()` can use prefix in 12.20 and later
|
|
4264
|
+
const { Blob } = require('buffer');
|
|
4251
4265
|
if (Blob && !Blob.prototype.stream) {
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4266
|
+
Blob.prototype.stream = function name (params) {
|
|
4267
|
+
let position = 0;
|
|
4268
|
+
const blob = this;
|
|
4269
|
+
|
|
4270
|
+
return new ReadableStream({
|
|
4271
|
+
type: 'bytes',
|
|
4272
|
+
async pull (ctrl) {
|
|
4273
|
+
const chunk = blob.slice(position, Math.min(blob.size, position + POOL_SIZE$1));
|
|
4274
|
+
const buffer = await chunk.arrayBuffer();
|
|
4275
|
+
position += buffer.byteLength;
|
|
4276
|
+
ctrl.enqueue(new Uint8Array(buffer));
|
|
4277
|
+
|
|
4278
|
+
if (position === blob.size) {
|
|
4279
|
+
ctrl.close();
|
|
4280
|
+
}
|
|
4281
|
+
}
|
|
4282
|
+
})
|
|
4283
|
+
};
|
|
4284
|
+
}
|
|
4271
4285
|
} catch (error) {}
|
|
4272
4286
|
|
|
4287
|
+
/*! fetch-blob. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
|
|
4288
|
+
|
|
4273
4289
|
/** @typedef {import('buffer').Blob} NodeBlob} */
|
|
4274
4290
|
|
|
4275
4291
|
// 64 KiB (same size chrome slice theirs blob into Uint8array's)
|
|
@@ -4277,223 +4293,238 @@ const POOL_SIZE = 65536;
|
|
|
4277
4293
|
|
|
4278
4294
|
/** @param {(Blob | NodeBlob | Uint8Array)[]} parts */
|
|
4279
4295
|
async function * toIterator (parts, clone = true) {
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
|
|
4296
|
+
for (const part of parts) {
|
|
4297
|
+
if ('stream' in part) {
|
|
4298
|
+
yield * part.stream();
|
|
4299
|
+
} else if (ArrayBuffer.isView(part)) {
|
|
4300
|
+
if (clone) {
|
|
4301
|
+
let position = part.byteOffset;
|
|
4302
|
+
const end = part.byteOffset + part.byteLength;
|
|
4303
|
+
while (position !== end) {
|
|
4304
|
+
const size = Math.min(end - position, POOL_SIZE);
|
|
4305
|
+
const chunk = part.buffer.slice(position, position + size);
|
|
4306
|
+
position += chunk.byteLength;
|
|
4307
|
+
yield new Uint8Array(chunk);
|
|
4308
|
+
}
|
|
4309
|
+
} else {
|
|
4310
|
+
yield part;
|
|
4311
|
+
}
|
|
4312
|
+
} else {
|
|
4313
|
+
/* c8 ignore start */
|
|
4314
|
+
// For blobs that have arrayBuffer but no stream method (nodes buffer.Blob)
|
|
4315
|
+
let position = 0;
|
|
4316
|
+
while (position !== part.size) {
|
|
4317
|
+
const chunk = part.slice(position, Math.min(part.size, position + POOL_SIZE));
|
|
4318
|
+
const buffer = await chunk.arrayBuffer();
|
|
4319
|
+
position += buffer.byteLength;
|
|
4320
|
+
yield new Uint8Array(buffer);
|
|
4321
|
+
}
|
|
4322
|
+
/* c8 ignore end */
|
|
4323
|
+
}
|
|
4324
|
+
}
|
|
4309
4325
|
}
|
|
4310
4326
|
|
|
4311
4327
|
const _Blob = class Blob {
|
|
4328
|
+
/** @type {Array.<(Blob|Uint8Array)>} */
|
|
4329
|
+
#parts = []
|
|
4330
|
+
#type = ''
|
|
4331
|
+
#size = 0
|
|
4312
4332
|
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
|
|
4324
|
-
|
|
4325
|
-
*/
|
|
4326
|
-
constructor(blobParts = [], options = {}) {
|
|
4327
|
-
let size = 0;
|
|
4328
|
-
|
|
4329
|
-
const parts = blobParts.map(element => {
|
|
4330
|
-
let part;
|
|
4331
|
-
if (ArrayBuffer.isView(element)) {
|
|
4332
|
-
part = new Uint8Array(element.buffer.slice(element.byteOffset, element.byteOffset + element.byteLength));
|
|
4333
|
-
} else if (element instanceof ArrayBuffer) {
|
|
4334
|
-
part = new Uint8Array(element.slice(0));
|
|
4335
|
-
} else if (element instanceof Blob) {
|
|
4336
|
-
part = element;
|
|
4337
|
-
} else {
|
|
4338
|
-
part = new TextEncoder().encode(element);
|
|
4339
|
-
}
|
|
4340
|
-
|
|
4341
|
-
size += ArrayBuffer.isView(part) ? part.byteLength : part.size;
|
|
4342
|
-
return part;
|
|
4343
|
-
});
|
|
4333
|
+
/**
|
|
4334
|
+
* The Blob() constructor returns a new Blob object. The content
|
|
4335
|
+
* of the blob consists of the concatenation of the values given
|
|
4336
|
+
* in the parameter array.
|
|
4337
|
+
*
|
|
4338
|
+
* @param {*} blobParts
|
|
4339
|
+
* @param {{ type?: string }} [options]
|
|
4340
|
+
*/
|
|
4341
|
+
constructor (blobParts = [], options = {}) {
|
|
4342
|
+
if (typeof blobParts !== 'object' || blobParts === null) {
|
|
4343
|
+
throw new TypeError('Failed to construct \'Blob\': The provided value cannot be converted to a sequence.')
|
|
4344
|
+
}
|
|
4344
4345
|
|
|
4345
|
-
|
|
4346
|
+
if (typeof blobParts[Symbol.iterator] !== 'function') {
|
|
4347
|
+
throw new TypeError('Failed to construct \'Blob\': The object must have a callable @@iterator property.')
|
|
4348
|
+
}
|
|
4346
4349
|
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
}
|
|
4350
|
+
if (typeof options !== 'object' && typeof options !== 'function') {
|
|
4351
|
+
throw new TypeError('Failed to construct \'Blob\': parameter 2 cannot convert to dictionary.')
|
|
4352
|
+
}
|
|
4351
4353
|
|
|
4352
|
-
|
|
4353
|
-
* The Blob interface's size property returns the
|
|
4354
|
-
* size of the Blob in bytes.
|
|
4355
|
-
*/
|
|
4356
|
-
get size() {
|
|
4357
|
-
return this.#size;
|
|
4358
|
-
}
|
|
4354
|
+
if (options === null) options = {};
|
|
4359
4355
|
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4356
|
+
const encoder = new TextEncoder();
|
|
4357
|
+
for (const element of blobParts) {
|
|
4358
|
+
let part;
|
|
4359
|
+
if (ArrayBuffer.isView(element)) {
|
|
4360
|
+
part = new Uint8Array(element.buffer.slice(element.byteOffset, element.byteOffset + element.byteLength));
|
|
4361
|
+
} else if (element instanceof ArrayBuffer) {
|
|
4362
|
+
part = new Uint8Array(element.slice(0));
|
|
4363
|
+
} else if (element instanceof Blob) {
|
|
4364
|
+
part = element;
|
|
4365
|
+
} else {
|
|
4366
|
+
part = encoder.encode(element);
|
|
4367
|
+
}
|
|
4366
4368
|
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
* the blob, interpreted as UTF-8.
|
|
4371
|
-
*
|
|
4372
|
-
* @return {Promise<string>}
|
|
4373
|
-
*/
|
|
4374
|
-
async text() {
|
|
4375
|
-
// More optimized than using this.arrayBuffer()
|
|
4376
|
-
// that requires twice as much ram
|
|
4377
|
-
const decoder = new TextDecoder();
|
|
4378
|
-
let str = '';
|
|
4379
|
-
for await (let part of toIterator(this.#parts, false)) {
|
|
4380
|
-
str += decoder.decode(part, { stream: true });
|
|
4381
|
-
}
|
|
4382
|
-
// Remaining
|
|
4383
|
-
str += decoder.decode();
|
|
4384
|
-
return str;
|
|
4385
|
-
}
|
|
4386
|
-
|
|
4387
|
-
/**
|
|
4388
|
-
* The arrayBuffer() method in the Blob interface returns a
|
|
4389
|
-
* Promise that resolves with the contents of the blob as
|
|
4390
|
-
* binary data contained in an ArrayBuffer.
|
|
4391
|
-
*
|
|
4392
|
-
* @return {Promise<ArrayBuffer>}
|
|
4393
|
-
*/
|
|
4394
|
-
async arrayBuffer() {
|
|
4395
|
-
// Easier way... Just a unnecessary overhead
|
|
4396
|
-
// const view = new Uint8Array(this.size);
|
|
4397
|
-
// await this.stream().getReader({mode: 'byob'}).read(view);
|
|
4398
|
-
// return view.buffer;
|
|
4399
|
-
|
|
4400
|
-
const data = new Uint8Array(this.size);
|
|
4401
|
-
let offset = 0;
|
|
4402
|
-
for await (const chunk of toIterator(this.#parts, false)) {
|
|
4403
|
-
data.set(chunk, offset);
|
|
4404
|
-
offset += chunk.length;
|
|
4405
|
-
}
|
|
4369
|
+
this.#size += ArrayBuffer.isView(part) ? part.byteLength : part.size;
|
|
4370
|
+
this.#parts.push(part);
|
|
4371
|
+
}
|
|
4406
4372
|
|
|
4407
|
-
|
|
4408
|
-
}
|
|
4373
|
+
const type = options.type === undefined ? '' : String(options.type);
|
|
4409
4374
|
|
|
4410
|
-
|
|
4411
|
-
|
|
4375
|
+
this.#type = /^[\x20-\x7E]*$/.test(type) ? type : '';
|
|
4376
|
+
}
|
|
4412
4377
|
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
}
|
|
4378
|
+
/**
|
|
4379
|
+
* The Blob interface's size property returns the
|
|
4380
|
+
* size of the Blob in bytes.
|
|
4381
|
+
*/
|
|
4382
|
+
get size () {
|
|
4383
|
+
return this.#size
|
|
4384
|
+
}
|
|
4421
4385
|
|
|
4422
|
-
|
|
4423
|
-
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
* @param {number} [end]
|
|
4429
|
-
* @param {string} [type]
|
|
4430
|
-
*/
|
|
4431
|
-
slice(start = 0, end = this.size, type = '') {
|
|
4432
|
-
const {size} = this;
|
|
4386
|
+
/**
|
|
4387
|
+
* The type property of a Blob object returns the MIME type of the file.
|
|
4388
|
+
*/
|
|
4389
|
+
get type () {
|
|
4390
|
+
return this.#type
|
|
4391
|
+
}
|
|
4433
4392
|
|
|
4434
|
-
|
|
4435
|
-
|
|
4393
|
+
/**
|
|
4394
|
+
* The text() method in the Blob interface returns a Promise
|
|
4395
|
+
* that resolves with a string containing the contents of
|
|
4396
|
+
* the blob, interpreted as UTF-8.
|
|
4397
|
+
*
|
|
4398
|
+
* @return {Promise<string>}
|
|
4399
|
+
*/
|
|
4400
|
+
async text () {
|
|
4401
|
+
// More optimized than using this.arrayBuffer()
|
|
4402
|
+
// that requires twice as much ram
|
|
4403
|
+
const decoder = new TextDecoder();
|
|
4404
|
+
let str = '';
|
|
4405
|
+
for await (const part of toIterator(this.#parts, false)) {
|
|
4406
|
+
str += decoder.decode(part, { stream: true });
|
|
4407
|
+
}
|
|
4408
|
+
// Remaining
|
|
4409
|
+
str += decoder.decode();
|
|
4410
|
+
return str
|
|
4411
|
+
}
|
|
4436
4412
|
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4413
|
+
/**
|
|
4414
|
+
* The arrayBuffer() method in the Blob interface returns a
|
|
4415
|
+
* Promise that resolves with the contents of the blob as
|
|
4416
|
+
* binary data contained in an ArrayBuffer.
|
|
4417
|
+
*
|
|
4418
|
+
* @return {Promise<ArrayBuffer>}
|
|
4419
|
+
*/
|
|
4420
|
+
async arrayBuffer () {
|
|
4421
|
+
// Easier way... Just a unnecessary overhead
|
|
4422
|
+
// const view = new Uint8Array(this.size);
|
|
4423
|
+
// await this.stream().getReader({mode: 'byob'}).read(view);
|
|
4424
|
+
// return view.buffer;
|
|
4425
|
+
|
|
4426
|
+
const data = new Uint8Array(this.size);
|
|
4427
|
+
let offset = 0;
|
|
4428
|
+
for await (const chunk of toIterator(this.#parts, false)) {
|
|
4429
|
+
data.set(chunk, offset);
|
|
4430
|
+
offset += chunk.length;
|
|
4431
|
+
}
|
|
4432
|
+
|
|
4433
|
+
return data.buffer
|
|
4434
|
+
}
|
|
4441
4435
|
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
if (added >= span) {
|
|
4445
|
-
break;
|
|
4446
|
-
}
|
|
4436
|
+
stream () {
|
|
4437
|
+
const it = toIterator(this.#parts, true);
|
|
4447
4438
|
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
} else {
|
|
4455
|
-
let chunk;
|
|
4456
|
-
if (ArrayBuffer.isView(part)) {
|
|
4457
|
-
chunk = part.subarray(relativeStart, Math.min(size, relativeEnd));
|
|
4458
|
-
added += chunk.byteLength;
|
|
4459
|
-
} else {
|
|
4460
|
-
chunk = part.slice(relativeStart, Math.min(size, relativeEnd));
|
|
4461
|
-
added += chunk.size;
|
|
4462
|
-
}
|
|
4463
|
-
blobParts.push(chunk);
|
|
4464
|
-
relativeStart = 0; // All next sequential parts should start at 0
|
|
4465
|
-
}
|
|
4466
|
-
}
|
|
4439
|
+
return new globalThis.ReadableStream({
|
|
4440
|
+
type: 'bytes',
|
|
4441
|
+
async pull (ctrl) {
|
|
4442
|
+
const chunk = await it.next();
|
|
4443
|
+
chunk.done ? ctrl.close() : ctrl.enqueue(chunk.value);
|
|
4444
|
+
},
|
|
4467
4445
|
|
|
4468
|
-
|
|
4469
|
-
|
|
4470
|
-
|
|
4446
|
+
async cancel () {
|
|
4447
|
+
await it.return();
|
|
4448
|
+
}
|
|
4449
|
+
})
|
|
4450
|
+
}
|
|
4471
4451
|
|
|
4472
|
-
|
|
4473
|
-
|
|
4452
|
+
/**
|
|
4453
|
+
* The Blob interface's slice() method creates and returns a
|
|
4454
|
+
* new Blob object which contains data from a subset of the
|
|
4455
|
+
* blob on which it's called.
|
|
4456
|
+
*
|
|
4457
|
+
* @param {number} [start]
|
|
4458
|
+
* @param {number} [end]
|
|
4459
|
+
* @param {string} [type]
|
|
4460
|
+
*/
|
|
4461
|
+
slice (start = 0, end = this.size, type = '') {
|
|
4462
|
+
const { size } = this;
|
|
4463
|
+
|
|
4464
|
+
let relativeStart = start < 0 ? Math.max(size + start, 0) : Math.min(start, size);
|
|
4465
|
+
let relativeEnd = end < 0 ? Math.max(size + end, 0) : Math.min(end, size);
|
|
4466
|
+
|
|
4467
|
+
const span = Math.max(relativeEnd - relativeStart, 0);
|
|
4468
|
+
const parts = this.#parts;
|
|
4469
|
+
const blobParts = [];
|
|
4470
|
+
let added = 0;
|
|
4471
|
+
|
|
4472
|
+
for (const part of parts) {
|
|
4473
|
+
// don't add the overflow to new blobParts
|
|
4474
|
+
if (added >= span) {
|
|
4475
|
+
break
|
|
4476
|
+
}
|
|
4477
|
+
|
|
4478
|
+
const size = ArrayBuffer.isView(part) ? part.byteLength : part.size;
|
|
4479
|
+
if (relativeStart && size <= relativeStart) {
|
|
4480
|
+
// Skip the beginning and change the relative
|
|
4481
|
+
// start & end position as we skip the unwanted parts
|
|
4482
|
+
relativeStart -= size;
|
|
4483
|
+
relativeEnd -= size;
|
|
4484
|
+
} else {
|
|
4485
|
+
let chunk;
|
|
4486
|
+
if (ArrayBuffer.isView(part)) {
|
|
4487
|
+
chunk = part.subarray(relativeStart, Math.min(size, relativeEnd));
|
|
4488
|
+
added += chunk.byteLength;
|
|
4489
|
+
} else {
|
|
4490
|
+
chunk = part.slice(relativeStart, Math.min(size, relativeEnd));
|
|
4491
|
+
added += chunk.size;
|
|
4492
|
+
}
|
|
4493
|
+
relativeEnd -= size;
|
|
4494
|
+
blobParts.push(chunk);
|
|
4495
|
+
relativeStart = 0; // All next sequential parts should start at 0
|
|
4496
|
+
}
|
|
4497
|
+
}
|
|
4498
|
+
|
|
4499
|
+
const blob = new Blob([], { type: String(type).toLowerCase() });
|
|
4500
|
+
blob.#size = span;
|
|
4501
|
+
blob.#parts = blobParts;
|
|
4502
|
+
|
|
4503
|
+
return blob
|
|
4504
|
+
}
|
|
4474
4505
|
|
|
4475
|
-
|
|
4476
|
-
|
|
4477
|
-
|
|
4506
|
+
get [Symbol.toStringTag] () {
|
|
4507
|
+
return 'Blob'
|
|
4508
|
+
}
|
|
4478
4509
|
|
|
4479
|
-
|
|
4480
|
-
|
|
4481
|
-
|
|
4482
|
-
|
|
4483
|
-
|
|
4484
|
-
|
|
4485
|
-
|
|
4486
|
-
|
|
4487
|
-
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
|
|
4510
|
+
static [Symbol.hasInstance] (object) {
|
|
4511
|
+
return (
|
|
4512
|
+
object &&
|
|
4513
|
+
typeof object === 'object' &&
|
|
4514
|
+
typeof object.constructor === 'function' &&
|
|
4515
|
+
(
|
|
4516
|
+
typeof object.stream === 'function' ||
|
|
4517
|
+
typeof object.arrayBuffer === 'function'
|
|
4518
|
+
) &&
|
|
4519
|
+
/^(Blob|File)$/.test(object[Symbol.toStringTag])
|
|
4520
|
+
)
|
|
4521
|
+
}
|
|
4491
4522
|
};
|
|
4492
4523
|
|
|
4493
4524
|
Object.defineProperties(_Blob.prototype, {
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4525
|
+
size: { enumerable: true },
|
|
4526
|
+
type: { enumerable: true },
|
|
4527
|
+
slice: { enumerable: true }
|
|
4497
4528
|
});
|
|
4498
4529
|
|
|
4499
4530
|
/** @type {typeof globalThis.Blob} */
|
package/dist/ssr.js
CHANGED
|
@@ -1260,8 +1260,7 @@ async function respond$1(opts) {
|
|
|
1260
1260
|
// otherwise bail out at this point
|
|
1261
1261
|
return {
|
|
1262
1262
|
status: 204,
|
|
1263
|
-
headers: {}
|
|
1264
|
-
body: ''
|
|
1263
|
+
headers: {}
|
|
1265
1264
|
};
|
|
1266
1265
|
}
|
|
1267
1266
|
|
|
@@ -1753,8 +1752,7 @@ async function respond(incoming, options, state = {}) {
|
|
|
1753
1752
|
if (request.headers['if-none-match'] === etag) {
|
|
1754
1753
|
return {
|
|
1755
1754
|
status: 304,
|
|
1756
|
-
headers: {}
|
|
1757
|
-
body: ''
|
|
1755
|
+
headers: {}
|
|
1758
1756
|
};
|
|
1759
1757
|
}
|
|
1760
1758
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sveltejs/kit",
|
|
3
|
-
"version": "1.0.0-next.
|
|
3
|
+
"version": "1.0.0-next.196",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/sveltejs/kit",
|
|
@@ -21,7 +21,6 @@
|
|
|
21
21
|
"@types/marked": "^3.0.1",
|
|
22
22
|
"@types/mime": "^2.0.3",
|
|
23
23
|
"@types/node": "^16.10.3",
|
|
24
|
-
"@types/rimraf": "^3.0.2",
|
|
25
24
|
"@types/sade": "^1.7.3",
|
|
26
25
|
"amphtml-validator": "^1.0.35",
|
|
27
26
|
"cookie": "^0.4.1",
|
|
@@ -33,7 +32,6 @@
|
|
|
33
32
|
"mime": "^2.5.2",
|
|
34
33
|
"node-fetch": "^3.0.0",
|
|
35
34
|
"port-authority": "^1.1.2",
|
|
36
|
-
"rimraf": "^3.0.2",
|
|
37
35
|
"rollup": "^2.58.0",
|
|
38
36
|
"selfsigned": "^1.10.11",
|
|
39
37
|
"sirv": "^1.0.17",
|