@sveltejs/kit 1.0.0-next.378 → 1.0.0-next.380
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/client/start.js +15 -8
- package/assets/server/index.js +3 -5
- package/dist/chunks/index2.js +12 -4
- package/dist/chunks/sync.js +1 -2
- package/dist/cli.js +1 -1
- package/dist/vite.js +21 -15
- package/package.json +2 -4
- package/types/index.d.ts +0 -5
- package/types/internal.d.ts +7 -0
package/assets/client/start.js
CHANGED
|
@@ -126,6 +126,8 @@ class LoadURL extends URL {
|
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
+
/* global __SVELTEKIT_APP_VERSION__, __SVELTEKIT_APP_VERSION_FILE__, __SVELTEKIT_APP_VERSION_POLL_INTERVAL__ */
|
|
130
|
+
|
|
129
131
|
/** @param {HTMLDocument} doc */
|
|
130
132
|
function get_base_uri(doc) {
|
|
131
133
|
let baseURI = doc.baseURI;
|
|
@@ -193,10 +195,7 @@ function notifiable_store(value) {
|
|
|
193
195
|
function create_updated_store() {
|
|
194
196
|
const { set, subscribe } = writable(false);
|
|
195
197
|
|
|
196
|
-
const interval =
|
|
197
|
-
/** @type {string} */ (import.meta.env.VITE_SVELTEKIT_APP_VERSION_POLL_INTERVAL)
|
|
198
|
-
);
|
|
199
|
-
const initial = import.meta.env.VITE_SVELTEKIT_APP_VERSION;
|
|
198
|
+
const interval = __SVELTEKIT_APP_VERSION_POLL_INTERVAL__;
|
|
200
199
|
|
|
201
200
|
/** @type {NodeJS.Timeout} */
|
|
202
201
|
let timeout;
|
|
@@ -208,9 +207,7 @@ function create_updated_store() {
|
|
|
208
207
|
|
|
209
208
|
if (interval) timeout = setTimeout(check, interval);
|
|
210
209
|
|
|
211
|
-
const
|
|
212
|
-
|
|
213
|
-
const res = await fetch(`${assets}/${file}`, {
|
|
210
|
+
const res = await fetch(`${assets}/${__SVELTEKIT_APP_VERSION_FILE__}`, {
|
|
214
211
|
headers: {
|
|
215
212
|
pragma: 'no-cache',
|
|
216
213
|
'cache-control': 'no-cache'
|
|
@@ -219,7 +216,7 @@ function create_updated_store() {
|
|
|
219
216
|
|
|
220
217
|
if (res.ok) {
|
|
221
218
|
const { version } = await res.json();
|
|
222
|
-
const updated = version !==
|
|
219
|
+
const updated = version !== __SVELTEKIT_APP_VERSION__;
|
|
223
220
|
|
|
224
221
|
if (updated) {
|
|
225
222
|
set(true);
|
|
@@ -1652,6 +1649,16 @@ function create_client({ target, session, base, trailing_slash }) {
|
|
|
1652
1649
|
);
|
|
1653
1650
|
}
|
|
1654
1651
|
});
|
|
1652
|
+
|
|
1653
|
+
addEventListener('pageshow', (event) => {
|
|
1654
|
+
// If the user navigates to another site and then uses the back button and
|
|
1655
|
+
// bfcache hits, we need to set navigating to null, the site doesn't know
|
|
1656
|
+
// the navigation away from it was successful.
|
|
1657
|
+
// Info about bfcache here: https://web.dev/bfcache
|
|
1658
|
+
if (event.persisted) {
|
|
1659
|
+
stores.navigating.set(null);
|
|
1660
|
+
}
|
|
1661
|
+
});
|
|
1655
1662
|
},
|
|
1656
1663
|
|
|
1657
1664
|
_hydrate: async ({ status, error, nodes, params, routeId }) => {
|
package/assets/server/index.js
CHANGED
|
@@ -165,8 +165,6 @@ function clone_error(error, get_stack) {
|
|
|
165
165
|
const {
|
|
166
166
|
name,
|
|
167
167
|
message,
|
|
168
|
-
// this should constitute 'using' a var, since it affects `custom`
|
|
169
|
-
// eslint-disable-next-line
|
|
170
168
|
stack,
|
|
171
169
|
// @ts-expect-error i guess typescript doesn't know about error.cause yet
|
|
172
170
|
cause,
|
|
@@ -3214,6 +3212,8 @@ function exec(match, names, types, matchers) {
|
|
|
3214
3212
|
return params;
|
|
3215
3213
|
}
|
|
3216
3214
|
|
|
3215
|
+
/* global __SVELTEKIT_ADAPTER_NAME__ */
|
|
3216
|
+
|
|
3217
3217
|
const DATA_SUFFIX = '/__data.json';
|
|
3218
3218
|
|
|
3219
3219
|
/** @param {{ html: string }} opts */
|
|
@@ -3321,9 +3321,7 @@ async function respond(request, options, state) {
|
|
|
3321
3321
|
get clientAddress() {
|
|
3322
3322
|
if (!state.getClientAddress) {
|
|
3323
3323
|
throw new Error(
|
|
3324
|
-
`${
|
|
3325
|
-
import.meta.env.VITE_SVELTEKIT_ADAPTER_NAME
|
|
3326
|
-
} does not specify getClientAddress. Please raise an issue`
|
|
3324
|
+
`${__SVELTEKIT_ADAPTER_NAME__} does not specify getClientAddress. Please raise an issue`
|
|
3327
3325
|
);
|
|
3328
3326
|
}
|
|
3329
3327
|
|
package/dist/chunks/index2.js
CHANGED
|
@@ -158,7 +158,10 @@ function create_builder({ config, build_data, prerendered, log }) {
|
|
|
158
158
|
},
|
|
159
159
|
|
|
160
160
|
writeClient(dest) {
|
|
161
|
-
return
|
|
161
|
+
return [
|
|
162
|
+
...copy(`${config.kit.outDir}/output/client`, dest),
|
|
163
|
+
...copy(config.kit.files.assets, dest)
|
|
164
|
+
];
|
|
162
165
|
},
|
|
163
166
|
|
|
164
167
|
writePrerendered(dest, { fallback } = {}) {
|
|
@@ -177,11 +180,16 @@ function create_builder({ config, build_data, prerendered, log }) {
|
|
|
177
180
|
return copy(`${config.kit.outDir}/output/server`, dest);
|
|
178
181
|
},
|
|
179
182
|
|
|
180
|
-
|
|
181
|
-
|
|
183
|
+
// TODO remove these methods for 1.0
|
|
184
|
+
// @ts-expect-error
|
|
185
|
+
writeStatic() {
|
|
186
|
+
throw new Error(
|
|
187
|
+
`writeStatic has been removed. Please ensure you are using the latest version of ${
|
|
188
|
+
config.kit.adapter.name || 'your adapter'
|
|
189
|
+
}`
|
|
190
|
+
);
|
|
182
191
|
},
|
|
183
192
|
|
|
184
|
-
// @ts-expect-error
|
|
185
193
|
async prerender() {
|
|
186
194
|
throw new Error(
|
|
187
195
|
'builder.prerender() has been removed. Prerendering now takes place in the build phase — see builder.prerender and builder.writePrerendered'
|
package/dist/chunks/sync.js
CHANGED
|
@@ -564,7 +564,6 @@ function trace(file, path, tree, extensions) {
|
|
|
564
564
|
|
|
565
565
|
// walk up the tree, find which __layout and __error components
|
|
566
566
|
// apply to this page
|
|
567
|
-
// eslint-disable-next-line
|
|
568
567
|
while (true) {
|
|
569
568
|
const node = tree.get(parts.join('/'));
|
|
570
569
|
const layout = node?.layouts[layout_id];
|
|
@@ -726,7 +725,7 @@ function copy_assets(dest) {
|
|
|
726
725
|
}
|
|
727
726
|
|
|
728
727
|
prefix = `../${prefix}`;
|
|
729
|
-
} while (true);
|
|
728
|
+
} while (true);
|
|
730
729
|
}
|
|
731
730
|
|
|
732
731
|
const s = JSON.stringify;
|
package/dist/cli.js
CHANGED
package/dist/vite.js
CHANGED
|
@@ -203,6 +203,9 @@ async function create_build(config) {
|
|
|
203
203
|
* @param {boolean} add_dynamic_css
|
|
204
204
|
*/
|
|
205
205
|
function find_deps$1(manifest, entry, add_dynamic_css) {
|
|
206
|
+
/** @type {Set<string>} */
|
|
207
|
+
const seen = new Set();
|
|
208
|
+
|
|
206
209
|
/** @type {Set<string>} */
|
|
207
210
|
const imports = new Set();
|
|
208
211
|
|
|
@@ -214,9 +217,11 @@ function find_deps$1(manifest, entry, add_dynamic_css) {
|
|
|
214
217
|
* @param {boolean} add_js
|
|
215
218
|
*/
|
|
216
219
|
function traverse(file, add_js) {
|
|
220
|
+
if (seen.has(file)) return;
|
|
221
|
+
seen.add(file);
|
|
222
|
+
|
|
217
223
|
const chunk = manifest[file];
|
|
218
224
|
|
|
219
|
-
if (imports.has(chunk.file)) return;
|
|
220
225
|
if (add_js) imports.add(chunk.file);
|
|
221
226
|
|
|
222
227
|
if (chunk.css) {
|
|
@@ -273,6 +278,12 @@ const get_default_config = function ({ config, input, ssr, outDir }) {
|
|
|
273
278
|
ssr,
|
|
274
279
|
target: ssr ? 'node14.8' : undefined
|
|
275
280
|
},
|
|
281
|
+
define: {
|
|
282
|
+
__SVELTEKIT_ADAPTER_NAME__: JSON.stringify(config.kit.adapter?.name),
|
|
283
|
+
__SVELTEKIT_APP_VERSION__: JSON.stringify(config.kit.version.name),
|
|
284
|
+
__SVELTEKIT_APP_VERSION_FILE__: JSON.stringify(`${config.kit.appDir}/version.json`),
|
|
285
|
+
__SVELTEKIT_APP_VERSION_POLL_INTERVAL__: JSON.stringify(config.kit.version.pollInterval)
|
|
286
|
+
},
|
|
276
287
|
// prevent Vite copying the contents of `config.kit.files.assets`,
|
|
277
288
|
// if it happens to be 'public' instead of 'static'
|
|
278
289
|
publicDir: false,
|
|
@@ -510,8 +521,6 @@ async function build_server(options, client) {
|
|
|
510
521
|
|
|
511
522
|
remove_svelte_kit(merged_config);
|
|
512
523
|
|
|
513
|
-
process.env.VITE_SVELTEKIT_ADAPTER_NAME = config.kit.adapter?.name;
|
|
514
|
-
|
|
515
524
|
const { chunks } = await create_build(merged_config);
|
|
516
525
|
|
|
517
526
|
/** @type {import('vite').Manifest} */
|
|
@@ -1229,9 +1238,9 @@ async function prerender({ config, entries, files, log }) {
|
|
|
1229
1238
|
}
|
|
1230
1239
|
});
|
|
1231
1240
|
|
|
1232
|
-
const
|
|
1241
|
+
const body = Buffer.from(await response.arrayBuffer());
|
|
1233
1242
|
|
|
1234
|
-
save('pages', response,
|
|
1243
|
+
save('pages', response, body, decoded, encoded, referrer, 'linked');
|
|
1235
1244
|
|
|
1236
1245
|
for (const [dependency_path, result] of dependencies) {
|
|
1237
1246
|
// this seems circuitous, but using new URL allows us to not care
|
|
@@ -1252,7 +1261,7 @@ async function prerender({ config, entries, files, log }) {
|
|
|
1252
1261
|
}
|
|
1253
1262
|
|
|
1254
1263
|
if (config.prerender.crawl && response.headers.get('content-type') === 'text/html') {
|
|
1255
|
-
for (const href of crawl(
|
|
1264
|
+
for (const href of crawl(body.toString())) {
|
|
1256
1265
|
if (href.startsWith('data:') || href.startsWith('#')) continue;
|
|
1257
1266
|
|
|
1258
1267
|
const resolved = resolve(encoded, href);
|
|
@@ -2053,8 +2062,6 @@ async function dev(vite, vite_config, svelte_config) {
|
|
|
2053
2062
|
|
|
2054
2063
|
const runtime = get_runtime_prefix(svelte_config.kit);
|
|
2055
2064
|
|
|
2056
|
-
process.env.VITE_SVELTEKIT_APP_VERSION_POLL_INTERVAL = '0';
|
|
2057
|
-
|
|
2058
2065
|
/** @type {import('types').Respond} */
|
|
2059
2066
|
const respond = (await import(`${runtime}/server/index.js`)).respond;
|
|
2060
2067
|
|
|
@@ -2875,7 +2882,7 @@ function kit() {
|
|
|
2875
2882
|
|
|
2876
2883
|
let completed_build = false;
|
|
2877
2884
|
|
|
2878
|
-
function
|
|
2885
|
+
function vite_client_build_config() {
|
|
2879
2886
|
/** @type {Record<string, string>} */
|
|
2880
2887
|
const input = {
|
|
2881
2888
|
// Put unchanging assets in immutable directory. We don't set that in the
|
|
@@ -2948,13 +2955,9 @@ function kit() {
|
|
|
2948
2955
|
};
|
|
2949
2956
|
|
|
2950
2957
|
if (is_build) {
|
|
2951
|
-
process.env.VITE_SVELTEKIT_APP_VERSION = svelte_config.kit.version.name;
|
|
2952
|
-
process.env.VITE_SVELTEKIT_APP_VERSION_FILE = `${svelte_config.kit.appDir}/version.json`;
|
|
2953
|
-
process.env.VITE_SVELTEKIT_APP_VERSION_POLL_INTERVAL = `${svelte_config.kit.version.pollInterval}`;
|
|
2954
|
-
|
|
2955
2958
|
manifest_data = all(svelte_config).manifest_data;
|
|
2956
2959
|
|
|
2957
|
-
const new_config =
|
|
2960
|
+
const new_config = vite_client_build_config();
|
|
2958
2961
|
|
|
2959
2962
|
warn_overridden_config(config, new_config);
|
|
2960
2963
|
|
|
@@ -2973,6 +2976,9 @@ function kit() {
|
|
|
2973
2976
|
input: `${get_runtime_directory(svelte_config.kit)}/client/start.js`
|
|
2974
2977
|
}
|
|
2975
2978
|
},
|
|
2979
|
+
define: {
|
|
2980
|
+
__SVELTEKIT_APP_VERSION_POLL_INTERVAL__: '0'
|
|
2981
|
+
},
|
|
2976
2982
|
resolve: {
|
|
2977
2983
|
alias: get_aliases(svelte_config.kit)
|
|
2978
2984
|
},
|
|
@@ -3037,7 +3043,7 @@ function kit() {
|
|
|
3037
3043
|
|
|
3038
3044
|
fs__default.writeFileSync(
|
|
3039
3045
|
`${paths.client_out_dir}/version.json`,
|
|
3040
|
-
JSON.stringify({ version:
|
|
3046
|
+
JSON.stringify({ version: svelte_config.kit.version.name })
|
|
3041
3047
|
);
|
|
3042
3048
|
|
|
3043
3049
|
const { assets, chunks } = collect_output(bundle);
|
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.380",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/sveltejs/kit",
|
|
@@ -27,7 +27,6 @@
|
|
|
27
27
|
"cookie": "^0.5.0",
|
|
28
28
|
"cross-env": "^7.0.3",
|
|
29
29
|
"devalue": "^2.0.1",
|
|
30
|
-
"eslint": "^8.16.0",
|
|
31
30
|
"kleur": "^4.1.4",
|
|
32
31
|
"locate-character": "^2.0.5",
|
|
33
32
|
"marked": "^4.0.16",
|
|
@@ -85,11 +84,10 @@
|
|
|
85
84
|
"scripts": {
|
|
86
85
|
"build": "rollup -c && node scripts/cp.js src/runtime/components assets/components && npm run types",
|
|
87
86
|
"dev": "rollup -cw",
|
|
88
|
-
"lint": "
|
|
87
|
+
"lint": "prettier --check . --config ../../.prettierrc --ignore-path .gitignore",
|
|
89
88
|
"check": "tsc",
|
|
90
89
|
"check:all": "tsc && pnpm -r --filter=\"./**\" check",
|
|
91
90
|
"format": "npm run check-format -- --write",
|
|
92
|
-
"check-format": "prettier --check . --config ../../.prettierrc --ignore-path .gitignore",
|
|
93
91
|
"test": "npm run test:unit && npm run test:typings && npm run test:packaging && npm run test:integration",
|
|
94
92
|
"test:integration": "pnpm run -r --workspace-concurrency 1 --filter=\"./test/**\" test",
|
|
95
93
|
"test:unit": "uvu src \"(spec\\.js|test[\\\\/]index\\.js)\" -i packaging",
|
package/types/index.d.ts
CHANGED
|
@@ -65,11 +65,6 @@ export interface Builder {
|
|
|
65
65
|
* @returns an array of paths corresponding to the files that have been created by the copy
|
|
66
66
|
*/
|
|
67
67
|
writeServer(dest: string): string[];
|
|
68
|
-
/**
|
|
69
|
-
* @param dest the destination folder to which files should be copied
|
|
70
|
-
* @returns an array of paths corresponding to the files that have been created by the copy
|
|
71
|
-
*/
|
|
72
|
-
writeStatic(dest: string): string[];
|
|
73
68
|
/**
|
|
74
69
|
* @param from the source file or folder
|
|
75
70
|
* @param to the destination file or folder
|
package/types/internal.d.ts
CHANGED
|
@@ -317,3 +317,10 @@ export type ValidatedKitConfig = RecursiveRequired<KitConfig>;
|
|
|
317
317
|
|
|
318
318
|
export * from './index';
|
|
319
319
|
export * from './private';
|
|
320
|
+
|
|
321
|
+
declare global {
|
|
322
|
+
const __SVELTEKIT_ADAPTER_NAME__: string;
|
|
323
|
+
const __SVELTEKIT_APP_VERSION__: string;
|
|
324
|
+
const __SVELTEKIT_APP_VERSION_FILE__: string;
|
|
325
|
+
const __SVELTEKIT_APP_VERSION_POLL_INTERVAL__: number;
|
|
326
|
+
}
|