@sveltejs/kit 1.0.0-next.336 → 1.0.0-next.339
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/app/env.js +1 -5
- package/assets/client/start.js +89 -7
- package/assets/server/index.js +51 -70
- package/dist/chunks/filesystem.js +1 -1
- package/dist/chunks/index.js +25 -28
- package/dist/chunks/index2.js +7 -15
- package/dist/chunks/index6.js +23 -17
- package/dist/chunks/sync.js +94 -92
- package/dist/chunks/write_tsconfig.js +13 -11
- package/dist/cli.js +17 -4
- package/package.json +3 -20
- package/types/ambient.d.ts +1 -5
- package/types/index.d.ts +0 -1
- package/types/internal.d.ts +0 -1
- package/dist/chunks/amp_hook.js +0 -56
- package/dist/chunks/index7.js +0 -4207
package/assets/app/env.js
CHANGED
|
@@ -12,9 +12,5 @@ const dev = !!import.meta.env.DEV;
|
|
|
12
12
|
* @type {import('$app/env').mode}
|
|
13
13
|
*/
|
|
14
14
|
const mode = import.meta.env.MODE;
|
|
15
|
-
/**
|
|
16
|
-
* @type {import('$app/env').amp}
|
|
17
|
-
*/
|
|
18
|
-
const amp = !!import.meta.env.VITE_SVELTEKIT_AMP;
|
|
19
15
|
|
|
20
|
-
export {
|
|
16
|
+
export { browser, dev, mode };
|
package/assets/client/start.js
CHANGED
|
@@ -432,6 +432,33 @@ function update_scroll_positions(index) {
|
|
|
432
432
|
scroll_positions[index] = scroll_state();
|
|
433
433
|
}
|
|
434
434
|
|
|
435
|
+
const fetch$1 = window.fetch;
|
|
436
|
+
let loading = 0;
|
|
437
|
+
|
|
438
|
+
if (import.meta.env.DEV) {
|
|
439
|
+
let can_inspect_stack_trace = false;
|
|
440
|
+
|
|
441
|
+
const check_stack_trace = async () => {
|
|
442
|
+
const stack = /** @type {string} */ (new Error().stack);
|
|
443
|
+
can_inspect_stack_trace = stack.includes('check_stack_trace');
|
|
444
|
+
};
|
|
445
|
+
|
|
446
|
+
check_stack_trace();
|
|
447
|
+
|
|
448
|
+
window.fetch = (input, init) => {
|
|
449
|
+
const url = input instanceof Request ? input.url : input.toString();
|
|
450
|
+
const stack = /** @type {string} */ (new Error().stack);
|
|
451
|
+
|
|
452
|
+
const heuristic = can_inspect_stack_trace ? stack.includes('load_node') : loading;
|
|
453
|
+
if (heuristic) {
|
|
454
|
+
console.warn(
|
|
455
|
+
`Loading ${url} using \`window.fetch\`. For best results, use the \`fetch\` that is passed to your \`load\` function: https://kit.svelte.dev/docs/loading#input-fetch`
|
|
456
|
+
);
|
|
457
|
+
}
|
|
458
|
+
return fetch$1(input, init);
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
|
|
435
462
|
/**
|
|
436
463
|
* @param {{
|
|
437
464
|
* target: Element;
|
|
@@ -914,7 +941,18 @@ function create_client({ target, session, base, trailing_slash }) {
|
|
|
914
941
|
props: props || {},
|
|
915
942
|
get url() {
|
|
916
943
|
node.uses.url = true;
|
|
917
|
-
|
|
944
|
+
|
|
945
|
+
return new Proxy(url, {
|
|
946
|
+
get: (target, property) => {
|
|
947
|
+
if (property === 'hash') {
|
|
948
|
+
throw new Error(
|
|
949
|
+
'url.hash is inaccessible from load. Consider accessing hash from the page store within the script tag of your component.'
|
|
950
|
+
);
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
return Reflect.get(target, property, target);
|
|
954
|
+
}
|
|
955
|
+
});
|
|
918
956
|
},
|
|
919
957
|
get session() {
|
|
920
958
|
node.uses.session = true;
|
|
@@ -924,11 +962,44 @@ function create_client({ target, session, base, trailing_slash }) {
|
|
|
924
962
|
node.uses.stuff = true;
|
|
925
963
|
return { ...stuff };
|
|
926
964
|
},
|
|
927
|
-
fetch(resource,
|
|
928
|
-
|
|
929
|
-
|
|
965
|
+
async fetch(resource, init) {
|
|
966
|
+
let requested;
|
|
967
|
+
|
|
968
|
+
if (typeof resource === 'string') {
|
|
969
|
+
requested = resource;
|
|
970
|
+
} else {
|
|
971
|
+
requested = resource.url;
|
|
972
|
+
|
|
973
|
+
// we're not allowed to modify the received `Request` object, so in order
|
|
974
|
+
// to fixup relative urls we create a new equivalent `init` object instead
|
|
975
|
+
init = {
|
|
976
|
+
// the request body must be consumed in memory until browsers
|
|
977
|
+
// implement streaming request bodies and/or the body getter
|
|
978
|
+
body:
|
|
979
|
+
resource.method === 'GET' || resource.method === 'HEAD'
|
|
980
|
+
? undefined
|
|
981
|
+
: await resource.blob(),
|
|
982
|
+
cache: resource.cache,
|
|
983
|
+
credentials: resource.credentials,
|
|
984
|
+
headers: resource.headers,
|
|
985
|
+
integrity: resource.integrity,
|
|
986
|
+
keepalive: resource.keepalive,
|
|
987
|
+
method: resource.method,
|
|
988
|
+
mode: resource.mode,
|
|
989
|
+
redirect: resource.redirect,
|
|
990
|
+
referrer: resource.referrer,
|
|
991
|
+
referrerPolicy: resource.referrerPolicy,
|
|
992
|
+
signal: resource.signal,
|
|
993
|
+
...init
|
|
994
|
+
};
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
// we must fixup relative urls so they are resolved from the target page
|
|
998
|
+
const normalized = new URL(requested, url).href;
|
|
999
|
+
add_dependency(normalized);
|
|
930
1000
|
|
|
931
|
-
|
|
1001
|
+
// prerendered pages may be served from any origin, so `initial_fetch` urls shouldn't be normalized
|
|
1002
|
+
return started ? fetch$1(normalized, init) : initial_fetch(requested, init);
|
|
932
1003
|
},
|
|
933
1004
|
status: status ?? null,
|
|
934
1005
|
error: error ?? null
|
|
@@ -943,7 +1014,18 @@ function create_client({ target, session, base, trailing_slash }) {
|
|
|
943
1014
|
});
|
|
944
1015
|
}
|
|
945
1016
|
|
|
946
|
-
|
|
1017
|
+
let loaded;
|
|
1018
|
+
|
|
1019
|
+
if (import.meta.env.DEV) {
|
|
1020
|
+
try {
|
|
1021
|
+
loading += 1;
|
|
1022
|
+
loaded = await module.load.call(null, load_input);
|
|
1023
|
+
} finally {
|
|
1024
|
+
loading -= 1;
|
|
1025
|
+
}
|
|
1026
|
+
} else {
|
|
1027
|
+
loaded = await module.load.call(null, load_input);
|
|
1028
|
+
}
|
|
947
1029
|
|
|
948
1030
|
if (!loaded) {
|
|
949
1031
|
throw new Error('load function must return a value');
|
|
@@ -1027,7 +1109,7 @@ function create_client({ target, session, base, trailing_slash }) {
|
|
|
1027
1109
|
const is_shadow_page = has_shadow && i === a.length - 1;
|
|
1028
1110
|
|
|
1029
1111
|
if (is_shadow_page) {
|
|
1030
|
-
const res = await fetch(
|
|
1112
|
+
const res = await fetch$1(
|
|
1031
1113
|
`${url.pathname}${url.pathname.endsWith('/') ? '' : '/'}__data.json${url.search}`,
|
|
1032
1114
|
{
|
|
1033
1115
|
headers: {
|
package/assets/server/index.js
CHANGED
|
@@ -1130,7 +1130,7 @@ async function render_response({
|
|
|
1130
1130
|
}
|
|
1131
1131
|
|
|
1132
1132
|
if (options.template_contains_nonce) {
|
|
1133
|
-
throw new Error('Cannot use prerendering if page template contains %
|
|
1133
|
+
throw new Error('Cannot use prerendering if page template contains %sveltekit.nonce%');
|
|
1134
1134
|
}
|
|
1135
1135
|
}
|
|
1136
1136
|
|
|
@@ -1272,95 +1272,76 @@ async function render_response({
|
|
|
1272
1272
|
}
|
|
1273
1273
|
`;
|
|
1274
1274
|
|
|
1275
|
-
if (
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
head += `
|
|
1280
|
-
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style>
|
|
1281
|
-
<noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
|
|
1282
|
-
<script async src="https://cdn.ampproject.org/v0.js"></script>
|
|
1283
|
-
|
|
1284
|
-
<style amp-custom>${styles}</style>`;
|
|
1285
|
-
|
|
1286
|
-
if (options.service_worker) {
|
|
1287
|
-
head +=
|
|
1288
|
-
'<script async custom-element="amp-install-serviceworker" src="https://cdn.ampproject.org/v0/amp-install-serviceworker-0.1.js"></script>';
|
|
1275
|
+
if (inlined_style) {
|
|
1276
|
+
const attributes = [];
|
|
1277
|
+
if (options.dev) attributes.push(' data-sveltekit');
|
|
1278
|
+
if (csp.style_needs_nonce) attributes.push(` nonce="${csp.nonce}"`);
|
|
1289
1279
|
|
|
1290
|
-
|
|
1291
|
-
}
|
|
1292
|
-
} else {
|
|
1293
|
-
if (inlined_style) {
|
|
1294
|
-
const attributes = [];
|
|
1295
|
-
if (options.dev) attributes.push(' data-sveltekit');
|
|
1296
|
-
if (csp.style_needs_nonce) attributes.push(` nonce="${csp.nonce}"`);
|
|
1280
|
+
csp.add_style(inlined_style);
|
|
1297
1281
|
|
|
1298
|
-
|
|
1282
|
+
head += `\n\t<style${attributes.join('')}>${inlined_style}</style>`;
|
|
1283
|
+
}
|
|
1299
1284
|
|
|
1300
|
-
|
|
1301
|
-
|
|
1285
|
+
// prettier-ignore
|
|
1286
|
+
head += Array.from(stylesheets)
|
|
1287
|
+
.map((dep) => {
|
|
1288
|
+
const attributes = [
|
|
1289
|
+
'rel="stylesheet"',
|
|
1290
|
+
`href="${options.prefix + dep}"`
|
|
1291
|
+
];
|
|
1302
1292
|
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
const attributes = [
|
|
1307
|
-
'rel="stylesheet"',
|
|
1308
|
-
`href="${options.prefix + dep}"`
|
|
1309
|
-
];
|
|
1293
|
+
if (csp.style_needs_nonce) {
|
|
1294
|
+
attributes.push(`nonce="${csp.nonce}"`);
|
|
1295
|
+
}
|
|
1310
1296
|
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1297
|
+
if (styles.has(dep)) {
|
|
1298
|
+
// don't load stylesheets that are already inlined
|
|
1299
|
+
// include them in disabled state so that Vite can detect them and doesn't try to add them
|
|
1300
|
+
attributes.push('disabled', 'media="(max-width: 0)"');
|
|
1301
|
+
}
|
|
1314
1302
|
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
attributes.push('disabled', 'media="(max-width: 0)"');
|
|
1319
|
-
}
|
|
1303
|
+
return `\n\t<link ${attributes.join(' ')}>`;
|
|
1304
|
+
})
|
|
1305
|
+
.join('');
|
|
1320
1306
|
|
|
1321
|
-
|
|
1322
|
-
|
|
1307
|
+
if (page_config.router || page_config.hydrate) {
|
|
1308
|
+
head += Array.from(modulepreloads)
|
|
1309
|
+
.map((dep) => `\n\t<link rel="modulepreload" href="${options.prefix + dep}">`)
|
|
1323
1310
|
.join('');
|
|
1324
1311
|
|
|
1325
|
-
|
|
1326
|
-
head += Array.from(modulepreloads)
|
|
1327
|
-
.map((dep) => `\n\t<link rel="modulepreload" href="${options.prefix + dep}">`)
|
|
1328
|
-
.join('');
|
|
1312
|
+
const attributes = ['type="module"', `data-sveltekit-hydrate="${target}"`];
|
|
1329
1313
|
|
|
1330
|
-
|
|
1314
|
+
csp.add_script(init_app);
|
|
1331
1315
|
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
attributes.push(`nonce="${csp.nonce}"`);
|
|
1336
|
-
}
|
|
1316
|
+
if (csp.script_needs_nonce) {
|
|
1317
|
+
attributes.push(`nonce="${csp.nonce}"`);
|
|
1318
|
+
}
|
|
1337
1319
|
|
|
1338
|
-
|
|
1320
|
+
body += `\n\t\t<script ${attributes.join(' ')}>${init_app}</script>`;
|
|
1339
1321
|
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
)
|
|
1322
|
+
body += serialized_data
|
|
1323
|
+
.map(({ url, body, response }) =>
|
|
1324
|
+
render_json_payload_script(
|
|
1325
|
+
{ type: 'data', url, body: typeof body === 'string' ? hash(body) : undefined },
|
|
1326
|
+
response
|
|
1346
1327
|
)
|
|
1347
|
-
|
|
1328
|
+
)
|
|
1329
|
+
.join('\n\t');
|
|
1348
1330
|
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
}
|
|
1331
|
+
if (shadow_props) {
|
|
1332
|
+
body += render_json_payload_script({ type: 'props' }, shadow_props);
|
|
1352
1333
|
}
|
|
1334
|
+
}
|
|
1353
1335
|
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1336
|
+
if (options.service_worker) {
|
|
1337
|
+
// always include service worker unless it's turned off explicitly
|
|
1338
|
+
csp.add_script(init_service_worker);
|
|
1357
1339
|
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
}
|
|
1340
|
+
head += `
|
|
1341
|
+
<script${csp.script_needs_nonce ? ` nonce="${csp.nonce}"` : ''}>${init_service_worker}</script>`;
|
|
1361
1342
|
}
|
|
1362
1343
|
|
|
1363
|
-
if (state.prerender
|
|
1344
|
+
if (state.prerender) {
|
|
1364
1345
|
const http_equiv = [];
|
|
1365
1346
|
|
|
1366
1347
|
const csp_headers = csp.get_meta();
|
package/dist/chunks/index.js
CHANGED
|
@@ -9,7 +9,6 @@ import { S as SVELTE_KIT_ASSETS, s as sirv } from './constants.js';
|
|
|
9
9
|
import { installFetch } from '../install-fetch.js';
|
|
10
10
|
import { update, init } from './sync.js';
|
|
11
11
|
import { getRequest, setResponse } from '../node.js';
|
|
12
|
-
import { sequence } from '../hooks.js';
|
|
13
12
|
import { p as posixify } from './filesystem.js';
|
|
14
13
|
import { p as parse_route_id } from './misc.js';
|
|
15
14
|
import 'sade';
|
|
@@ -39,14 +38,6 @@ const style_pattern = /\.(css|less|sass|scss|styl|stylus|pcss|postcss)$/;
|
|
|
39
38
|
async function create_plugin(config, cwd) {
|
|
40
39
|
const runtime = get_runtime_path(config);
|
|
41
40
|
|
|
42
|
-
/** @type {import('types').Handle} */
|
|
43
|
-
let amp;
|
|
44
|
-
|
|
45
|
-
if (config.kit.amp) {
|
|
46
|
-
process.env.VITE_SVELTEKIT_AMP = 'true';
|
|
47
|
-
amp = (await import('./amp_hook.js')).handle;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
41
|
process.env.VITE_SVELTEKIT_APP_VERSION_POLL_INTERVAL = '0';
|
|
51
42
|
|
|
52
43
|
/** @type {import('types').Respond} */
|
|
@@ -194,6 +185,11 @@ async function create_plugin(config, cwd) {
|
|
|
194
185
|
});
|
|
195
186
|
|
|
196
187
|
return () => {
|
|
188
|
+
const serve_static_middleware = vite.middlewares.stack.find(
|
|
189
|
+
(middleware) =>
|
|
190
|
+
/** @type {function} */ (middleware.handle).name === 'viteServeStaticMiddleware'
|
|
191
|
+
);
|
|
192
|
+
|
|
197
193
|
remove_html_middlewares(vite.middlewares);
|
|
198
194
|
|
|
199
195
|
vite.middlewares.use(async (req, res) => {
|
|
@@ -233,7 +229,7 @@ async function create_plugin(config, cwd) {
|
|
|
233
229
|
/** @type {import('types').Hooks} */
|
|
234
230
|
const hooks = {
|
|
235
231
|
getSession: user_hooks.getSession || (() => ({})),
|
|
236
|
-
handle
|
|
232
|
+
handle,
|
|
237
233
|
handleError:
|
|
238
234
|
user_hooks.handleError ||
|
|
239
235
|
(({ /** @type {Error & { frame?: string }} */ error }) => {
|
|
@@ -295,7 +291,6 @@ async function create_plugin(config, cwd) {
|
|
|
295
291
|
const rendered = await respond(
|
|
296
292
|
request,
|
|
297
293
|
{
|
|
298
|
-
amp: config.kit.amp,
|
|
299
294
|
csp: config.kit.csp,
|
|
300
295
|
dev: true,
|
|
301
296
|
floc: config.kit.floc,
|
|
@@ -340,14 +335,14 @@ async function create_plugin(config, cwd) {
|
|
|
340
335
|
template: ({ head, body, assets, nonce }) => {
|
|
341
336
|
return (
|
|
342
337
|
template
|
|
343
|
-
.replace(/%
|
|
344
|
-
.replace(/%
|
|
345
|
-
// head and body must be replaced last, in case someone tries to sneak in %
|
|
346
|
-
.replace('%
|
|
347
|
-
.replace('%
|
|
338
|
+
.replace(/%sveltekit\.assets%/g, assets)
|
|
339
|
+
.replace(/%sveltekit\.nonce%/g, nonce)
|
|
340
|
+
// head and body must be replaced last, in case someone tries to sneak in %sveltekit.assets% etc
|
|
341
|
+
.replace('%sveltekit.head%', () => head)
|
|
342
|
+
.replace('%sveltekit.body%', () => body)
|
|
348
343
|
);
|
|
349
344
|
},
|
|
350
|
-
template_contains_nonce: template.includes('%
|
|
345
|
+
template_contains_nonce: template.includes('%sveltekit.nonce%'),
|
|
351
346
|
trailing_slash: config.kit.trailingSlash
|
|
352
347
|
},
|
|
353
348
|
{
|
|
@@ -359,10 +354,13 @@ async function create_plugin(config, cwd) {
|
|
|
359
354
|
}
|
|
360
355
|
);
|
|
361
356
|
|
|
362
|
-
if (rendered) {
|
|
363
|
-
|
|
357
|
+
if (rendered.status === 404) {
|
|
358
|
+
// @ts-expect-error
|
|
359
|
+
serve_static_middleware.handle(req, res, () => {
|
|
360
|
+
setResponse(res, rendered);
|
|
361
|
+
});
|
|
364
362
|
} else {
|
|
365
|
-
|
|
363
|
+
setResponse(res, rendered);
|
|
366
364
|
}
|
|
367
365
|
} catch (e) {
|
|
368
366
|
const error = coalesce_to_error(e);
|
|
@@ -389,7 +387,8 @@ function remove_html_middlewares(server) {
|
|
|
389
387
|
const html_middlewares = [
|
|
390
388
|
'viteIndexHtmlMiddleware',
|
|
391
389
|
'vite404Middleware',
|
|
392
|
-
'viteSpaFallbackMiddleware'
|
|
390
|
+
'viteSpaFallbackMiddleware',
|
|
391
|
+
'viteServeStaticMiddleware'
|
|
393
392
|
];
|
|
394
393
|
for (let i = server.stack.length - 1; i > 0; i--) {
|
|
395
394
|
// @ts-expect-error using internals until https://github.com/vitejs/vite/pull/4640 is merged
|
|
@@ -469,7 +468,10 @@ async function dev({ cwd, port, host, https, config }) {
|
|
|
469
468
|
]
|
|
470
469
|
},
|
|
471
470
|
port: 3000,
|
|
472
|
-
strictPort: true
|
|
471
|
+
strictPort: true,
|
|
472
|
+
watch: {
|
|
473
|
+
ignored: [`${config.kit.outDir}/**`, `!${config.kit.outDir}/generated/**`]
|
|
474
|
+
}
|
|
473
475
|
}
|
|
474
476
|
},
|
|
475
477
|
await config.kit.vite()
|
|
@@ -492,12 +494,7 @@ async function dev({ cwd, port, host, https, config }) {
|
|
|
492
494
|
plugins: [
|
|
493
495
|
svelte({
|
|
494
496
|
...config,
|
|
495
|
-
|
|
496
|
-
// don't need to include CSS for components that are imported but unused, so we can just
|
|
497
|
-
// include rendered CSS.
|
|
498
|
-
// This would also apply if hydrate and router are both false, but we don't know if one
|
|
499
|
-
// has been enabled at the page level, so we don't do anything there.
|
|
500
|
-
emitCss: !config.kit.amp,
|
|
497
|
+
emitCss: true,
|
|
501
498
|
compilerOptions: {
|
|
502
499
|
...config.compilerOptions,
|
|
503
500
|
hydratable: !!config.kit.browser.hydrate
|
package/dist/chunks/index2.js
CHANGED
|
@@ -238,8 +238,6 @@ async function build_client({
|
|
|
238
238
|
process.env.VITE_SVELTEKIT_APP_VERSION_FILE = `${config.kit.appDir}/version.json`;
|
|
239
239
|
process.env.VITE_SVELTEKIT_APP_VERSION_POLL_INTERVAL = `${config.kit.version.pollInterval}`;
|
|
240
240
|
|
|
241
|
-
process.env.VITE_SVELTEKIT_AMP = config.kit.amp ? 'true' : '';
|
|
242
|
-
|
|
243
241
|
const client_out_dir = `${output_dir}/client/${config.kit.appDir}`;
|
|
244
242
|
|
|
245
243
|
/** @type {Record<string, string>} */
|
|
@@ -286,12 +284,7 @@ async function build_client({
|
|
|
286
284
|
plugins: [
|
|
287
285
|
svelte({
|
|
288
286
|
...config,
|
|
289
|
-
|
|
290
|
-
// don't need to include CSS for components that are imported but unused, so we can just
|
|
291
|
-
// include rendered CSS.
|
|
292
|
-
// This would also apply if hydrate and router are both false, but we don't know if one
|
|
293
|
-
// has been enabled at the page level, so we don't do anything there.
|
|
294
|
-
emitCss: !config.kit.amp,
|
|
287
|
+
emitCss: true,
|
|
295
288
|
compilerOptions: {
|
|
296
289
|
...config.compilerOptions,
|
|
297
290
|
hydratable: !!config.kit.browser.hydrate
|
|
@@ -349,10 +342,10 @@ import { set_paths, assets, base } from '${runtime}/paths.js';
|
|
|
349
342
|
import { set_prerendering } from '${runtime}/env.js';
|
|
350
343
|
|
|
351
344
|
const template = ({ head, body, assets, nonce }) => ${s(template)
|
|
352
|
-
.replace('%
|
|
353
|
-
.replace('%
|
|
354
|
-
.replace(/%
|
|
355
|
-
.replace(/%
|
|
345
|
+
.replace('%sveltekit.head%', '" + head + "')
|
|
346
|
+
.replace('%sveltekit.body%', '" + body + "')
|
|
347
|
+
.replace(/%sveltekit\.assets%/g, '" + assets + "')
|
|
348
|
+
.replace(/%sveltekit\.nonce%/g, '" + nonce + "')};
|
|
356
349
|
|
|
357
350
|
let read = null;
|
|
358
351
|
|
|
@@ -372,7 +365,6 @@ export function override(settings) {
|
|
|
372
365
|
export class Server {
|
|
373
366
|
constructor(manifest) {
|
|
374
367
|
this.options = {
|
|
375
|
-
amp: ${config.kit.amp},
|
|
376
368
|
csp: ${s(config.kit.csp)},
|
|
377
369
|
dev: false,
|
|
378
370
|
floc: ${config.kit.floc},
|
|
@@ -402,7 +394,7 @@ export class Server {
|
|
|
402
394
|
service_worker: ${has_service_worker ? "base + '/service-worker.js'" : 'null'},
|
|
403
395
|
router: ${s(config.kit.browser.router)},
|
|
404
396
|
template,
|
|
405
|
-
template_contains_nonce: ${template.includes('%
|
|
397
|
+
template_contains_nonce: ${template.includes('%sveltekit.nonce%')},
|
|
406
398
|
trailing_slash: ${s(config.kit.trailingSlash)}
|
|
407
399
|
};
|
|
408
400
|
}
|
|
@@ -581,7 +573,7 @@ async function build_server(
|
|
|
581
573
|
|
|
582
574
|
client.assets.forEach((asset) => {
|
|
583
575
|
if (asset.fileName.endsWith('.css')) {
|
|
584
|
-
if (
|
|
576
|
+
if (asset.source.length < config.kit.inlineStyleThreshold) {
|
|
585
577
|
const index = stylesheet_lookup.size;
|
|
586
578
|
const file = `${output_dir}/server/stylesheets/${index}.js`;
|
|
587
579
|
|
package/dist/chunks/index6.js
CHANGED
|
@@ -5950,14 +5950,14 @@ const flatten_properties = (array, target) => {
|
|
|
5950
5950
|
* @param {any[]} nodes
|
|
5951
5951
|
* @param {any[]} target
|
|
5952
5952
|
*/
|
|
5953
|
-
const flatten = (nodes, target) => {
|
|
5953
|
+
const flatten$1 = (nodes, target) => {
|
|
5954
5954
|
for (let i = 0; i < nodes.length; i += 1) {
|
|
5955
5955
|
const node = nodes[i];
|
|
5956
5956
|
|
|
5957
5957
|
if (node === EMPTY) continue;
|
|
5958
5958
|
|
|
5959
5959
|
if (Array.isArray(node)) {
|
|
5960
|
-
flatten(node, target);
|
|
5960
|
+
flatten$1(node, target);
|
|
5961
5961
|
continue;
|
|
5962
5962
|
}
|
|
5963
5963
|
|
|
@@ -6076,7 +6076,7 @@ const inject = (raw, node, values, comments) => {
|
|
|
6076
6076
|
}
|
|
6077
6077
|
|
|
6078
6078
|
if (node.type === 'ArrayExpression' || node.type === 'ArrayPattern') {
|
|
6079
|
-
node.elements = flatten(node.elements, []);
|
|
6079
|
+
node.elements = flatten$1(node.elements, []);
|
|
6080
6080
|
}
|
|
6081
6081
|
|
|
6082
6082
|
if (
|
|
@@ -6084,18 +6084,18 @@ const inject = (raw, node, values, comments) => {
|
|
|
6084
6084
|
node.type === 'FunctionDeclaration' ||
|
|
6085
6085
|
node.type === 'ArrowFunctionExpression'
|
|
6086
6086
|
) {
|
|
6087
|
-
node.params = flatten(node.params, []);
|
|
6087
|
+
node.params = flatten$1(node.params, []);
|
|
6088
6088
|
}
|
|
6089
6089
|
|
|
6090
6090
|
if (node.type === 'CallExpression' || node.type === 'NewExpression') {
|
|
6091
|
-
node.arguments = flatten(node.arguments, []);
|
|
6091
|
+
node.arguments = flatten$1(node.arguments, []);
|
|
6092
6092
|
}
|
|
6093
6093
|
|
|
6094
6094
|
if (
|
|
6095
6095
|
node.type === 'ImportDeclaration' ||
|
|
6096
6096
|
node.type === 'ExportNamedDeclaration'
|
|
6097
6097
|
) {
|
|
6098
|
-
node.specifiers = flatten(node.specifiers, []);
|
|
6098
|
+
node.specifiers = flatten$1(node.specifiers, []);
|
|
6099
6099
|
}
|
|
6100
6100
|
|
|
6101
6101
|
if (node.type === 'ForStatement') {
|
|
@@ -13813,7 +13813,7 @@ const meta_tags = new Map([
|
|
|
13813
13813
|
['svelte:window', 'Window'],
|
|
13814
13814
|
['svelte:body', 'Body']
|
|
13815
13815
|
]);
|
|
13816
|
-
Array.from(meta_tags.keys()).concat('svelte:self', 'svelte:component', 'svelte:fragment');
|
|
13816
|
+
Array.from(meta_tags.keys()).concat('svelte:self', 'svelte:component', 'svelte:fragment', 'svelte:element');
|
|
13817
13817
|
|
|
13818
13818
|
function getLocator(source, options) {
|
|
13819
13819
|
if (options === void 0) { options = {}; }
|
|
@@ -13850,6 +13850,19 @@ function getLocator(source, options) {
|
|
|
13850
13850
|
return locate;
|
|
13851
13851
|
}
|
|
13852
13852
|
|
|
13853
|
+
/**
|
|
13854
|
+
* Pushes all `items` into `array` using `push`, therefore mutating the array.
|
|
13855
|
+
* We do this for memory and perf reasons, and because `array.push(...items)` would
|
|
13856
|
+
* run into a "max call stack size exceeded" error with too many items (~65k).
|
|
13857
|
+
* @param array
|
|
13858
|
+
* @param items
|
|
13859
|
+
*/
|
|
13860
|
+
function push_array$1(array, items) {
|
|
13861
|
+
for (let i = 0; i < items.length; i++) {
|
|
13862
|
+
array.push(items[i]);
|
|
13863
|
+
}
|
|
13864
|
+
}
|
|
13865
|
+
|
|
13853
13866
|
x `true`;
|
|
13854
13867
|
x `false`;
|
|
13855
13868
|
|
|
@@ -14744,13 +14757,6 @@ function merge_tables(this_table, other_table) {
|
|
|
14744
14757
|
}
|
|
14745
14758
|
return [new_table, idx_map, val_changed, idx_changed];
|
|
14746
14759
|
}
|
|
14747
|
-
function pushArray(_this, other) {
|
|
14748
|
-
// We use push to mutate in place for memory and perf reasons
|
|
14749
|
-
// We use the for loop instead of _this.push(...other) to avoid the JS engine's function argument limit (65,535 in JavascriptCore)
|
|
14750
|
-
for (let i = 0; i < other.length; i++) {
|
|
14751
|
-
_this.push(other[i]);
|
|
14752
|
-
}
|
|
14753
|
-
}
|
|
14754
14760
|
class MappedCode {
|
|
14755
14761
|
constructor(string = '', map = null) {
|
|
14756
14762
|
this.string = string;
|
|
@@ -14838,9 +14844,9 @@ class MappedCode {
|
|
|
14838
14844
|
}
|
|
14839
14845
|
}
|
|
14840
14846
|
// combine last line + first line
|
|
14841
|
-
|
|
14847
|
+
push_array$1(m1.mappings[m1.mappings.length - 1], m2.mappings.shift());
|
|
14842
14848
|
// append other lines
|
|
14843
|
-
|
|
14849
|
+
push_array$1(m1.mappings, m2.mappings);
|
|
14844
14850
|
return this;
|
|
14845
14851
|
}
|
|
14846
14852
|
static from_processed(string, map) {
|
|
@@ -15549,7 +15555,7 @@ async function build(config, cwd = process.cwd()) {
|
|
|
15549
15555
|
mkdirp(dir);
|
|
15550
15556
|
|
|
15551
15557
|
// Make sure generated tsconfig is up-to-date
|
|
15552
|
-
write_tsconfig(config);
|
|
15558
|
+
write_tsconfig(config, cwd);
|
|
15553
15559
|
|
|
15554
15560
|
const files = scan(config);
|
|
15555
15561
|
|