@sveltejs/kit 1.0.0-next.382 → 1.0.0-next.385
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 +2 -17
- package/assets/client/start.js +23 -1
- package/assets/server/index.js +22 -22
- package/dist/chunks/error.js +18 -0
- package/dist/chunks/index2.js +3 -4
- package/dist/chunks/multipart-parser.js +16 -3
- package/dist/cli.js +1 -1
- package/dist/node/polyfills.js +5572 -34
- package/dist/node.js +2 -5541
- package/dist/vite.js +85 -21
- package/package.json +2 -2
- package/types/ambient.d.ts +2 -19
- package/types/index.d.ts +1 -0
- package/types/internal.d.ts +1 -0
- package/dist/chunks/_commonjsHelpers.js +0 -3
package/dist/vite.js
CHANGED
|
@@ -7,7 +7,7 @@ import * as vite from 'vite';
|
|
|
7
7
|
import { loadConfigFromFile } from 'vite';
|
|
8
8
|
import { p as posixify, m as mkdirp, r as rimraf } from './chunks/write_tsconfig.js';
|
|
9
9
|
import { g as get_runtime_directory, s, i as init, a as get_runtime_prefix, u as update, b as get_mime_lookup, p as parse_route_id, c as all, l as logger } from './chunks/sync.js';
|
|
10
|
-
import {
|
|
10
|
+
import { URL as URL$1, pathToFileURL } from 'url';
|
|
11
11
|
import { installPolyfills } from './node/polyfills.js';
|
|
12
12
|
import * as qs from 'querystring';
|
|
13
13
|
import { getRequest, setResponse } from './node.js';
|
|
@@ -22,11 +22,9 @@ import 'perf_hooks';
|
|
|
22
22
|
import 'util/types';
|
|
23
23
|
import 'events';
|
|
24
24
|
import 'tls';
|
|
25
|
-
import './chunks/_commonjsHelpers.js';
|
|
26
25
|
import 'async_hooks';
|
|
27
26
|
import 'console';
|
|
28
27
|
import 'zlib';
|
|
29
|
-
import 'crypto';
|
|
30
28
|
import 'node:http';
|
|
31
29
|
import 'node:https';
|
|
32
30
|
import 'node:zlib';
|
|
@@ -37,6 +35,7 @@ import 'node:url';
|
|
|
37
35
|
import 'node:net';
|
|
38
36
|
import 'node:fs';
|
|
39
37
|
import 'node:path';
|
|
38
|
+
import 'crypto';
|
|
40
39
|
|
|
41
40
|
/**
|
|
42
41
|
* @param {import('vite').ConfigEnv} config_env
|
|
@@ -47,7 +46,7 @@ async function get_vite_config(config_env) {
|
|
|
47
46
|
if (!config) {
|
|
48
47
|
throw new Error('Could not load Vite config');
|
|
49
48
|
}
|
|
50
|
-
return config;
|
|
49
|
+
return { ...config, mode: config_env.mode };
|
|
51
50
|
}
|
|
52
51
|
|
|
53
52
|
/**
|
|
@@ -282,7 +281,8 @@ const get_default_config = function ({ config, input, ssr, outDir }) {
|
|
|
282
281
|
__SVELTEKIT_ADAPTER_NAME__: JSON.stringify(config.kit.adapter?.name),
|
|
283
282
|
__SVELTEKIT_APP_VERSION__: JSON.stringify(config.kit.version.name),
|
|
284
283
|
__SVELTEKIT_APP_VERSION_FILE__: JSON.stringify(`${config.kit.appDir}/version.json`),
|
|
285
|
-
__SVELTEKIT_APP_VERSION_POLL_INTERVAL__: JSON.stringify(config.kit.version.pollInterval)
|
|
284
|
+
__SVELTEKIT_APP_VERSION_POLL_INTERVAL__: JSON.stringify(config.kit.version.pollInterval),
|
|
285
|
+
__SVELTEKIT_DEV__: 'false'
|
|
286
286
|
},
|
|
287
287
|
// prevent Vite copying the contents of `config.kit.files.assets`,
|
|
288
288
|
// if it happens to be 'public' instead of 'static'
|
|
@@ -435,9 +435,9 @@ export class Server {
|
|
|
435
435
|
/**
|
|
436
436
|
* @param {{
|
|
437
437
|
* cwd: string;
|
|
438
|
-
* config: import('types').ValidatedConfig
|
|
439
|
-
* vite_config_env: import('vite').ConfigEnv
|
|
440
|
-
* manifest_data: import('types').ManifestData
|
|
438
|
+
* config: import('types').ValidatedConfig;
|
|
439
|
+
* vite_config_env: import('vite').ConfigEnv;
|
|
440
|
+
* manifest_data: import('types').ManifestData;
|
|
441
441
|
* build_dir: string;
|
|
442
442
|
* output_dir: string;
|
|
443
443
|
* service_worker_entry_file: string | null;
|
|
@@ -1112,28 +1112,39 @@ function escape_html_attr(str) {
|
|
|
1112
1112
|
|
|
1113
1113
|
/**
|
|
1114
1114
|
* @typedef {import('types').PrerenderErrorHandler} PrerenderErrorHandler
|
|
1115
|
-
* @typedef {import('types').PrerenderOnErrorValue} OnError
|
|
1116
1115
|
* @typedef {import('types').Logger} Logger
|
|
1117
1116
|
*/
|
|
1118
1117
|
|
|
1119
|
-
/**
|
|
1120
|
-
|
|
1121
|
-
|
|
1118
|
+
/**
|
|
1119
|
+
* @param {Parameters<PrerenderErrorHandler>[0]} details
|
|
1120
|
+
* @param {import('types').ValidatedKitConfig} config
|
|
1121
|
+
*/
|
|
1122
|
+
function format_error({ status, path, referrer, referenceType }, config) {
|
|
1123
|
+
const message =
|
|
1124
|
+
status === 404 && !path.startsWith(config.paths.base)
|
|
1125
|
+
? `${path} does not begin with \`base\`, which is configured in \`paths.base\` and can be imported from \`$app/paths\``
|
|
1126
|
+
: path;
|
|
1127
|
+
|
|
1128
|
+
return `${status} ${message}${referrer ? ` (${referenceType} from ${referrer})` : ''}`;
|
|
1122
1129
|
}
|
|
1123
1130
|
|
|
1124
|
-
/**
|
|
1125
|
-
|
|
1126
|
-
|
|
1131
|
+
/**
|
|
1132
|
+
* @param {Logger} log
|
|
1133
|
+
* @param {import('types').ValidatedKitConfig} config
|
|
1134
|
+
* @returns {PrerenderErrorHandler}
|
|
1135
|
+
*/
|
|
1136
|
+
function normalise_error_handler(log, config) {
|
|
1137
|
+
switch (config.prerender.onError) {
|
|
1127
1138
|
case 'continue':
|
|
1128
1139
|
return (details) => {
|
|
1129
|
-
log.error(format_error(details));
|
|
1140
|
+
log.error(format_error(details, config));
|
|
1130
1141
|
};
|
|
1131
1142
|
case 'fail':
|
|
1132
1143
|
return (details) => {
|
|
1133
|
-
throw new Error(format_error(details));
|
|
1144
|
+
throw new Error(format_error(details, config));
|
|
1134
1145
|
};
|
|
1135
1146
|
default:
|
|
1136
|
-
return onError;
|
|
1147
|
+
return config.prerender.onError;
|
|
1137
1148
|
}
|
|
1138
1149
|
}
|
|
1139
1150
|
|
|
@@ -1162,6 +1173,58 @@ async function prerender({ config, entries, files, log }) {
|
|
|
1162
1173
|
}
|
|
1163
1174
|
|
|
1164
1175
|
installPolyfills();
|
|
1176
|
+
const { fetch } = globalThis;
|
|
1177
|
+
globalThis.fetch = async (info, init) => {
|
|
1178
|
+
/** @type {string} */
|
|
1179
|
+
let url;
|
|
1180
|
+
|
|
1181
|
+
/** @type {RequestInit} */
|
|
1182
|
+
let opts = {};
|
|
1183
|
+
|
|
1184
|
+
if (info instanceof Request) {
|
|
1185
|
+
url = info.url;
|
|
1186
|
+
|
|
1187
|
+
opts = {
|
|
1188
|
+
method: info.method,
|
|
1189
|
+
headers: info.headers,
|
|
1190
|
+
body: info.body,
|
|
1191
|
+
mode: info.mode,
|
|
1192
|
+
credentials: info.credentials,
|
|
1193
|
+
cache: info.cache,
|
|
1194
|
+
redirect: info.redirect,
|
|
1195
|
+
referrer: info.referrer,
|
|
1196
|
+
integrity: info.integrity
|
|
1197
|
+
};
|
|
1198
|
+
} else {
|
|
1199
|
+
url = info.toString();
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
if (url.startsWith(config.prerender.origin + '/')) {
|
|
1203
|
+
const request = new Request(url, opts);
|
|
1204
|
+
const response = await server.respond(request, {
|
|
1205
|
+
getClientAddress,
|
|
1206
|
+
prerendering: {
|
|
1207
|
+
dependencies: new Map()
|
|
1208
|
+
}
|
|
1209
|
+
});
|
|
1210
|
+
|
|
1211
|
+
const decoded = new URL$1(url).pathname;
|
|
1212
|
+
|
|
1213
|
+
save(
|
|
1214
|
+
'dependencies',
|
|
1215
|
+
response,
|
|
1216
|
+
Buffer.from(await response.clone().arrayBuffer()),
|
|
1217
|
+
decoded,
|
|
1218
|
+
encodeURI(decoded),
|
|
1219
|
+
null,
|
|
1220
|
+
'fetched'
|
|
1221
|
+
);
|
|
1222
|
+
|
|
1223
|
+
return response;
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1226
|
+
return fetch(info, init);
|
|
1227
|
+
};
|
|
1165
1228
|
|
|
1166
1229
|
const server_root = join(config.outDir, 'output');
|
|
1167
1230
|
|
|
@@ -1177,7 +1240,7 @@ async function prerender({ config, entries, files, log }) {
|
|
|
1177
1240
|
|
|
1178
1241
|
const server = new Server(manifest);
|
|
1179
1242
|
|
|
1180
|
-
const error = normalise_error_handler(log, config
|
|
1243
|
+
const error = normalise_error_handler(log, config);
|
|
1181
1244
|
|
|
1182
1245
|
const q = queue(config.prerender.concurrency);
|
|
1183
1246
|
|
|
@@ -1231,7 +1294,7 @@ async function prerender({ config, entries, files, log }) {
|
|
|
1231
1294
|
/** @type {Map<string, import('types').PrerenderDependency>} */
|
|
1232
1295
|
const dependencies = new Map();
|
|
1233
1296
|
|
|
1234
|
-
const response = await server.respond(new Request(
|
|
1297
|
+
const response = await server.respond(new Request(config.prerender.origin + encoded), {
|
|
1235
1298
|
getClientAddress,
|
|
1236
1299
|
prerendering: {
|
|
1237
1300
|
dependencies
|
|
@@ -1367,7 +1430,7 @@ async function prerender({ config, entries, files, log }) {
|
|
|
1367
1430
|
await q.done();
|
|
1368
1431
|
}
|
|
1369
1432
|
|
|
1370
|
-
const rendered = await server.respond(new Request('
|
|
1433
|
+
const rendered = await server.respond(new Request(config.prerender.origin + '/[fallback]'), {
|
|
1371
1434
|
getClientAddress,
|
|
1372
1435
|
prerendering: {
|
|
1373
1436
|
fallback: true,
|
|
@@ -2977,6 +3040,7 @@ function kit() {
|
|
|
2977
3040
|
}
|
|
2978
3041
|
},
|
|
2979
3042
|
define: {
|
|
3043
|
+
__SVELTEKIT_DEV__: 'true',
|
|
2980
3044
|
__SVELTEKIT_APP_VERSION_POLL_INTERVAL__: '0'
|
|
2981
3045
|
},
|
|
2982
3046
|
resolve: {
|
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.385",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/sveltejs/kit",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"lint": "prettier --check . --config ../../.prettierrc --ignore-path .gitignore",
|
|
88
88
|
"check": "tsc",
|
|
89
89
|
"check:all": "tsc && pnpm -r --filter=\"./**\" check",
|
|
90
|
-
"format": "npm run
|
|
90
|
+
"format": "npm run lint -- --write",
|
|
91
91
|
"test": "npm run test:unit && npm run test:typings && npm run test:packaging && npm run test:integration",
|
|
92
92
|
"test:integration": "pnpm run -r --workspace-concurrency 1 --filter=\"./test/**\" test",
|
|
93
93
|
"test:unit": "uvu src \"(spec\\.js|test[\\\\/]index\\.js)\" -i packaging",
|
package/types/ambient.d.ts
CHANGED
|
@@ -65,7 +65,7 @@ declare namespace App {
|
|
|
65
65
|
|
|
66
66
|
/**
|
|
67
67
|
* ```ts
|
|
68
|
-
* import { browser, dev,
|
|
68
|
+
* import { browser, dev, prerendering } from '$app/env';
|
|
69
69
|
* ```
|
|
70
70
|
*/
|
|
71
71
|
declare module '$app/env' {
|
|
@@ -75,31 +75,14 @@ declare module '$app/env' {
|
|
|
75
75
|
export const browser: boolean;
|
|
76
76
|
|
|
77
77
|
/**
|
|
78
|
-
*
|
|
78
|
+
* Whether the dev server is running. This is not guaranteed to correspond to `NODE_ENV` or `MODE`.
|
|
79
79
|
*/
|
|
80
80
|
export const dev: boolean;
|
|
81
81
|
|
|
82
|
-
/**
|
|
83
|
-
* The Vite.js mode the app is running in. Configure in [`vite.config.js`](https://vitejs.dev/config/shared-options.html#mode).
|
|
84
|
-
* Vite.js loads the dotenv file associated with the provided mode, `.env.[mode]` or `.env.[mode].local`.
|
|
85
|
-
* By default, `vite dev` runs with `mode=development` and `vite build` runs with `mode=production`.
|
|
86
|
-
*/
|
|
87
|
-
export const mode: string;
|
|
88
|
-
|
|
89
82
|
/**
|
|
90
83
|
* `true` when prerendering, `false` otherwise.
|
|
91
84
|
*/
|
|
92
85
|
export const prerendering: boolean;
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* `true` in production mode, `false` in development.
|
|
96
|
-
*/
|
|
97
|
-
export const prod: boolean;
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* `true` if the app is running on the server.
|
|
101
|
-
*/
|
|
102
|
-
export const server: boolean;
|
|
103
86
|
}
|
|
104
87
|
|
|
105
88
|
/**
|
package/types/index.d.ts
CHANGED
package/types/internal.d.ts
CHANGED