@sveltejs/kit 3.0.0-next.7 → 3.0.0-next.8
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/package.json +2 -2
- package/src/core/config/options.js +1 -1
- package/src/core/env.js +1 -0
- package/src/core/sync/create_manifest_data/index.js +1 -1
- package/src/core/sync/sync.js +0 -2
- package/src/core/sync/write_client_manifest.js +0 -7
- package/src/core/sync/write_non_ambient.js +2 -2
- package/src/core/sync/write_server.js +0 -3
- package/src/core/sync/write_types/index.js +17 -14
- package/src/core/utils.js +2 -2
- package/src/exports/node/index.js +4 -8
- package/src/exports/public.d.ts +21 -14
- package/src/exports/vite/dev/index.js +3 -3
- package/src/exports/vite/index.js +64 -44
- package/src/exports/vite/preview/index.js +13 -14
- package/src/exports/vite/utils.js +5 -5
- package/src/runtime/app/env/internal.js +4 -4
- package/src/runtime/app/forms.js +2 -2
- package/src/runtime/app/paths/internal/client.js +4 -2
- package/src/runtime/app/paths/internal/server.js +2 -23
- package/src/runtime/app/paths/server.js +2 -2
- package/src/runtime/client/bundle.js +1 -1
- package/src/runtime/client/client-entry.js +3 -0
- package/src/runtime/client/client.js +216 -171
- package/src/runtime/client/entry.js +24 -3
- package/src/runtime/client/payload.js +17 -0
- package/src/runtime/client/remote-functions/form.svelte.js +6 -6
- package/src/runtime/client/types.d.ts +2 -6
- package/src/runtime/components/root.svelte +66 -0
- package/src/runtime/form-utils.js +1 -4
- package/src/runtime/server/cookie.js +17 -7
- package/src/runtime/server/page/index.js +7 -14
- package/src/runtime/server/page/render.js +71 -78
- package/src/runtime/server/remote.js +2 -1
- package/src/runtime/server/utils.js +28 -5
- package/src/runtime/types.d.ts +8 -0
- package/src/types/global-private.d.ts +10 -17
- package/src/types/internal.d.ts +21 -25
- package/src/utils/import.js +6 -1
- package/src/utils/routing.js +6 -6
- package/src/version.js +1 -1
- package/types/index.d.ts +34 -43
- package/types/index.d.ts.map +3 -2
- package/src/core/sync/write_root.js +0 -127
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/** @import { NextHandleFunction } from 'connect' */
|
|
2
|
+
/** @import { PreviewServer, ResolvedConfig } from 'vite' */
|
|
3
|
+
/** @import { ValidatedConfig, ServerInternalModule, ServerModule } from 'types' */
|
|
1
4
|
import fs from 'node:fs';
|
|
2
5
|
import { join } from 'node:path';
|
|
3
6
|
import { pathToFileURL } from 'node:url';
|
|
@@ -8,14 +11,10 @@ import { createReadableStream, getRequest, setResponse } from '../../../exports/
|
|
|
8
11
|
import { SVELTE_KIT_ASSETS } from '../../../constants.js';
|
|
9
12
|
import { is_chrome_devtools_request, not_found } from '../utils.js';
|
|
10
13
|
|
|
11
|
-
/** @typedef {import('http').IncomingMessage} Req */
|
|
12
|
-
/** @typedef {import('http').ServerResponse} Res */
|
|
13
|
-
/** @typedef {(req: Req, res: Res, next: () => void) => void} Handler */
|
|
14
|
-
|
|
15
14
|
/**
|
|
16
|
-
* @param {
|
|
17
|
-
* @param {
|
|
18
|
-
* @param {
|
|
15
|
+
* @param {PreviewServer} vite
|
|
16
|
+
* @param {ResolvedConfig} vite_config
|
|
17
|
+
* @param {ValidatedConfig} svelte_config
|
|
19
18
|
*/
|
|
20
19
|
export async function preview(vite, vite_config, svelte_config) {
|
|
21
20
|
const { paths } = svelte_config.kit;
|
|
@@ -37,10 +36,10 @@ export async function preview(vite, vite_config, svelte_config) {
|
|
|
37
36
|
await import(pathToFileURL(instrumentation).href);
|
|
38
37
|
}
|
|
39
38
|
|
|
40
|
-
/** @type {
|
|
39
|
+
/** @type {ServerInternalModule} */
|
|
41
40
|
const { set_assets } = await import(pathToFileURL(join(dir, 'internal.js')).href);
|
|
42
41
|
|
|
43
|
-
/** @type {
|
|
42
|
+
/** @type {ServerModule} */
|
|
44
43
|
const { Server } = await import(pathToFileURL(join(dir, 'index.js')).href);
|
|
45
44
|
|
|
46
45
|
const { manifest } = await import(pathToFileURL(join(dir, 'manifest.js')).href);
|
|
@@ -204,12 +203,12 @@ export async function preview(vite, vite_config, svelte_config) {
|
|
|
204
203
|
vite.middlewares.use(async (req, res) => {
|
|
205
204
|
const host = req.headers[':authority'] || req.headers.host;
|
|
206
205
|
|
|
207
|
-
const request =
|
|
206
|
+
const request = getRequest({
|
|
208
207
|
base: `${protocol}://${host}`,
|
|
209
208
|
request: req
|
|
210
209
|
});
|
|
211
210
|
|
|
212
|
-
|
|
211
|
+
setResponse(
|
|
213
212
|
res,
|
|
214
213
|
await server.respond(request, {
|
|
215
214
|
getClientAddress: () => {
|
|
@@ -233,7 +232,7 @@ export async function preview(vite, vite_config, svelte_config) {
|
|
|
233
232
|
|
|
234
233
|
/**
|
|
235
234
|
* @param {string} dir
|
|
236
|
-
* @returns {
|
|
235
|
+
* @returns {NextHandleFunction}
|
|
237
236
|
*/
|
|
238
237
|
const mutable = (dir) =>
|
|
239
238
|
fs.existsSync(dir)
|
|
@@ -245,8 +244,8 @@ const mutable = (dir) =>
|
|
|
245
244
|
|
|
246
245
|
/**
|
|
247
246
|
* @param {string} scope
|
|
248
|
-
* @param {
|
|
249
|
-
* @returns {
|
|
247
|
+
* @param {NextHandleFunction} handler
|
|
248
|
+
* @returns {NextHandleFunction}
|
|
250
249
|
*/
|
|
251
250
|
function scoped(scope, handler) {
|
|
252
251
|
if (scope === '') return handler;
|
|
@@ -18,13 +18,13 @@ import {
|
|
|
18
18
|
*
|
|
19
19
|
* @param {import('types').ValidatedKitConfig} config
|
|
20
20
|
* @param {string} root
|
|
21
|
-
|
|
21
|
+
*/
|
|
22
22
|
export function get_config_aliases(config, root) {
|
|
23
23
|
/** @type {import('vite').Alias[]} */
|
|
24
24
|
const alias = [
|
|
25
25
|
// For now, we handle `$lib` specially here rather than make it a default value for
|
|
26
26
|
// `config.alias` since it has special meaning for packaging, etc.
|
|
27
|
-
{ find: '$lib', replacement: config.files.lib }
|
|
27
|
+
{ find: '$lib', replacement: posixify(config.files.lib) }
|
|
28
28
|
];
|
|
29
29
|
|
|
30
30
|
for (let [key, value] of Object.entries(config.alias)) {
|
|
@@ -36,16 +36,16 @@ export function get_config_aliases(config, root) {
|
|
|
36
36
|
// Doing just `{ find: key.slice(0, -2) ,..}` would mean `import .. from "key"` would also be matched, which we don't want
|
|
37
37
|
alias.push({
|
|
38
38
|
find: new RegExp(`^${escape_for_regexp(key.slice(0, -2))}\\/(.+)$`),
|
|
39
|
-
replacement: `${path.resolve(root, value)}/$1`
|
|
39
|
+
replacement: `${posixify(path.resolve(root, value))}/$1`
|
|
40
40
|
});
|
|
41
41
|
} else if (key + '/*' in config.alias) {
|
|
42
42
|
// key and key/* both exist -> the replacement for key needs to happen _only_ on import .. from "key"
|
|
43
43
|
alias.push({
|
|
44
44
|
find: new RegExp(`^${escape_for_regexp(key)}$`),
|
|
45
|
-
replacement: path.resolve(root, value)
|
|
45
|
+
replacement: posixify(path.resolve(root, value))
|
|
46
46
|
});
|
|
47
47
|
} else {
|
|
48
|
-
alias.push({ find: key, replacement: path.resolve(root, value) });
|
|
48
|
+
alias.push({ find: key, replacement: posixify(path.resolve(root, value)) });
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { BROWSER } from 'esm-env';
|
|
2
|
+
import { payload } from '../../client/payload.js';
|
|
3
|
+
|
|
4
|
+
export const version = BROWSER ? payload.version : __SVELTEKIT_APP_VERSION__;
|
|
2
5
|
export let building = false;
|
|
3
6
|
export let prerendering = false;
|
|
4
7
|
|
|
@@ -9,6 +12,3 @@ export function set_building() {
|
|
|
9
12
|
export function set_prerendering() {
|
|
10
13
|
prerendering = true;
|
|
11
14
|
}
|
|
12
|
-
|
|
13
|
-
// force /@vite/client to be injected
|
|
14
|
-
import.meta.hot;
|
package/src/runtime/app/forms.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as devalue from 'devalue';
|
|
2
2
|
import { BROWSER, DEV } from 'esm-env';
|
|
3
3
|
import { noop } from '../../utils/functions.js';
|
|
4
|
-
import {
|
|
4
|
+
import { refreshAll } from './navigation.js';
|
|
5
5
|
import { app as client_app, applyAction, handle_error } from '../client/client.js';
|
|
6
6
|
import { app as server_app } from '../server/app.js';
|
|
7
7
|
|
|
@@ -106,7 +106,7 @@ export function enhance(form_element, submit = noop) {
|
|
|
106
106
|
HTMLFormElement.prototype.reset.call(form_element);
|
|
107
107
|
}
|
|
108
108
|
if (shouldInvalidateAll) {
|
|
109
|
-
await
|
|
109
|
+
await refreshAll();
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { payload } from '../../../client/payload.js';
|
|
2
|
+
|
|
3
|
+
export const base = payload.base ?? __SVELTEKIT_PATHS_BASE__;
|
|
4
|
+
export const assets = payload.assets ?? base ?? __SVELTEKIT_PATHS_ASSETS__;
|
|
3
5
|
export const app_dir = __SVELTEKIT_APP_DIR__;
|
|
4
6
|
export const hash_routing = __SVELTEKIT_HASH_ROUTING__;
|
|
@@ -1,30 +1,9 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const base = __SVELTEKIT_PATHS_BASE__;
|
|
2
2
|
export let assets = __SVELTEKIT_PATHS_ASSETS__ || base;
|
|
3
3
|
export const app_dir = __SVELTEKIT_APP_DIR__;
|
|
4
4
|
export const relative = __SVELTEKIT_PATHS_RELATIVE__;
|
|
5
5
|
|
|
6
|
-
const initial = { base, assets };
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* `base` could be overridden during rendering to be relative;
|
|
10
|
-
* this one's the original non-relative base path
|
|
11
|
-
*/
|
|
12
|
-
export const initial_base = initial.base;
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @param {{ base: string, assets: string }} paths
|
|
16
|
-
*/
|
|
17
|
-
export function override(paths) {
|
|
18
|
-
base = paths.base;
|
|
19
|
-
assets = paths.assets;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function reset() {
|
|
23
|
-
base = initial.base;
|
|
24
|
-
assets = initial.assets;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
6
|
/** @param {string} path */
|
|
28
7
|
export function set_assets(path) {
|
|
29
|
-
assets =
|
|
8
|
+
assets = path;
|
|
30
9
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { base, assets, relative
|
|
1
|
+
import { base, assets, relative } from './internal/server.js';
|
|
2
2
|
import { resolve_route, find_route } from '../../../utils/routing.js';
|
|
3
3
|
import { decode_pathname } from '../../../utils/url.js';
|
|
4
4
|
import { add_data_suffix } from '../../pathname.js';
|
|
@@ -32,7 +32,7 @@ export function resolve(id, params) {
|
|
|
32
32
|
const pathname = store.event.isDataRequest
|
|
33
33
|
? add_data_suffix(store.event.url.pathname)
|
|
34
34
|
: store.event.url.pathname;
|
|
35
|
-
const after_base = pathname.slice(
|
|
35
|
+
const after_base = pathname.slice(base.length);
|
|
36
36
|
const segments = after_base.split('/').slice(2);
|
|
37
37
|
const prefix = segments.map(() => '..').join('/') || '.';
|
|
38
38
|
|