@sveltejs/kit 1.0.0-next.48 → 1.0.0-next.480
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/README.md +12 -9
- package/package.json +93 -64
- package/scripts/special-types/$env+dynamic+private.md +10 -0
- package/scripts/special-types/$env+dynamic+public.md +8 -0
- package/scripts/special-types/$env+static+private.md +19 -0
- package/scripts/special-types/$env+static+public.md +7 -0
- package/scripts/special-types/$lib.md +1 -0
- package/src/cli.js +112 -0
- package/src/constants.js +7 -0
- package/src/core/adapt/builder.js +207 -0
- package/src/core/adapt/index.js +31 -0
- package/src/core/config/default-error.html +56 -0
- package/src/core/config/index.js +110 -0
- package/src/core/config/options.js +504 -0
- package/src/core/config/types.d.ts +1 -0
- package/src/core/env.js +121 -0
- package/src/core/generate_manifest/index.js +92 -0
- package/src/core/prerender/crawl.js +194 -0
- package/src/core/prerender/prerender.js +431 -0
- package/src/core/prerender/queue.js +80 -0
- package/src/core/sync/create_manifest_data/index.js +472 -0
- package/src/core/sync/create_manifest_data/types.d.ts +37 -0
- package/src/core/sync/sync.js +59 -0
- package/src/core/sync/utils.js +33 -0
- package/src/core/sync/write_ambient.js +53 -0
- package/src/core/sync/write_client_manifest.js +106 -0
- package/src/core/sync/write_matchers.js +25 -0
- package/src/core/sync/write_root.js +91 -0
- package/src/core/sync/write_tsconfig.js +195 -0
- package/src/core/sync/write_types/index.js +673 -0
- package/src/core/utils.js +70 -0
- package/src/exports/hooks/index.js +1 -0
- package/src/exports/hooks/sequence.js +44 -0
- package/src/exports/index.js +45 -0
- package/src/exports/node/index.js +163 -0
- package/src/exports/node/polyfills.js +41 -0
- package/src/exports/vite/build/build_server.js +372 -0
- package/src/exports/vite/build/build_service_worker.js +90 -0
- package/src/exports/vite/build/utils.js +162 -0
- package/src/exports/vite/dev/index.js +576 -0
- package/src/exports/vite/index.js +597 -0
- package/src/exports/vite/preview/index.js +189 -0
- package/src/exports/vite/types.d.ts +3 -0
- package/src/exports/vite/utils.js +438 -0
- package/src/runtime/app/env.js +1 -0
- package/src/runtime/app/environment.js +11 -0
- package/src/runtime/app/forms.js +108 -0
- package/src/runtime/app/navigation.js +23 -0
- package/src/runtime/app/paths.js +1 -0
- package/src/runtime/app/stores.js +102 -0
- package/src/runtime/client/ambient.d.ts +26 -0
- package/src/runtime/client/client.js +1569 -0
- package/src/runtime/client/fetcher.js +107 -0
- package/src/runtime/client/parse.js +60 -0
- package/src/runtime/client/singletons.js +21 -0
- package/src/runtime/client/start.js +37 -0
- package/src/runtime/client/types.d.ts +85 -0
- package/src/runtime/client/utils.js +159 -0
- package/src/runtime/components/error.svelte +16 -0
- package/{assets → src/runtime}/components/layout.svelte +0 -0
- package/src/runtime/control.js +98 -0
- package/src/runtime/env/dynamic/private.js +1 -0
- package/src/runtime/env/dynamic/public.js +1 -0
- package/src/runtime/env-private.js +6 -0
- package/src/runtime/env-public.js +6 -0
- package/src/runtime/env.js +6 -0
- package/src/runtime/hash.js +16 -0
- package/src/runtime/paths.js +11 -0
- package/src/runtime/server/cookie.js +77 -0
- package/src/runtime/server/data/index.js +136 -0
- package/src/runtime/server/endpoint.js +66 -0
- package/src/runtime/server/index.js +343 -0
- package/src/runtime/server/page/actions.js +243 -0
- package/src/runtime/server/page/crypto.js +239 -0
- package/src/runtime/server/page/csp.js +249 -0
- package/src/runtime/server/page/fetch.js +286 -0
- package/src/runtime/server/page/index.js +304 -0
- package/src/runtime/server/page/load_data.js +124 -0
- package/src/runtime/server/page/render.js +346 -0
- package/src/runtime/server/page/respond_with_error.js +92 -0
- package/src/runtime/server/page/serialize_data.js +87 -0
- package/src/runtime/server/page/types.d.ts +35 -0
- package/src/runtime/server/utils.js +178 -0
- package/src/utils/array.js +9 -0
- package/src/utils/error.js +22 -0
- package/src/utils/escape.js +46 -0
- package/src/utils/filesystem.js +137 -0
- package/src/utils/functions.js +16 -0
- package/src/utils/http.js +55 -0
- package/src/utils/misc.js +1 -0
- package/src/utils/routing.js +117 -0
- package/src/utils/url.js +142 -0
- package/svelte-kit.js +1 -1
- package/types/ambient.d.ts +426 -0
- package/types/index.d.ts +410 -0
- package/types/internal.d.ts +384 -0
- package/types/private.d.ts +210 -0
- package/CHANGELOG.md +0 -469
- package/assets/components/error.svelte +0 -13
- package/assets/runtime/app/env.js +0 -5
- package/assets/runtime/app/navigation.js +0 -44
- package/assets/runtime/app/paths.js +0 -1
- package/assets/runtime/app/stores.js +0 -93
- package/assets/runtime/chunks/utils.js +0 -22
- package/assets/runtime/internal/singletons.js +0 -23
- package/assets/runtime/internal/start.js +0 -773
- package/assets/runtime/paths.js +0 -12
- package/dist/chunks/index.js +0 -3517
- package/dist/chunks/index2.js +0 -587
- package/dist/chunks/index3.js +0 -246
- package/dist/chunks/index4.js +0 -530
- package/dist/chunks/index5.js +0 -763
- package/dist/chunks/index6.js +0 -322
- package/dist/chunks/standard.js +0 -99
- package/dist/chunks/utils.js +0 -83
- package/dist/cli.js +0 -553
- package/dist/ssr.js +0 -2581
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { invalidateAll } from './navigation.js';
|
|
2
|
+
import { client } from '../client/singletons.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @param {string} name
|
|
6
|
+
*/
|
|
7
|
+
function guard(name) {
|
|
8
|
+
return () => {
|
|
9
|
+
throw new Error(`Cannot call ${name}(...) on the server`);
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const ssr = import.meta.env.SSR;
|
|
14
|
+
|
|
15
|
+
/** @type {import('$app/forms').applyAction} */
|
|
16
|
+
export const applyAction = ssr ? guard('applyAction') : client.apply_action;
|
|
17
|
+
|
|
18
|
+
/** @type {import('$app/forms').enhance} */
|
|
19
|
+
export function enhance(form, submit = () => {}) {
|
|
20
|
+
/**
|
|
21
|
+
* @param {{
|
|
22
|
+
* action: URL;
|
|
23
|
+
* result: import('types').ActionResult;
|
|
24
|
+
* }} opts
|
|
25
|
+
*/
|
|
26
|
+
const fallback_callback = async ({ action, result }) => {
|
|
27
|
+
if (result.type === 'success') {
|
|
28
|
+
await invalidateAll();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (location.origin + location.pathname === action.origin + action.pathname) {
|
|
32
|
+
applyAction(result);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/** @param {SubmitEvent} event */
|
|
37
|
+
async function handle_submit(event) {
|
|
38
|
+
event.preventDefault();
|
|
39
|
+
|
|
40
|
+
const action = new URL(
|
|
41
|
+
// We can't do submitter.formAction directly because that property is always set
|
|
42
|
+
event.submitter?.hasAttribute('formaction')
|
|
43
|
+
? /** @type {HTMLButtonElement | HTMLInputElement} */ (event.submitter).formAction
|
|
44
|
+
: form.action
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
const data = new FormData(form);
|
|
48
|
+
const controller = new AbortController();
|
|
49
|
+
|
|
50
|
+
let cancelled = false;
|
|
51
|
+
const cancel = () => (cancelled = true);
|
|
52
|
+
|
|
53
|
+
const callback =
|
|
54
|
+
submit({
|
|
55
|
+
action,
|
|
56
|
+
cancel,
|
|
57
|
+
controller,
|
|
58
|
+
data,
|
|
59
|
+
form
|
|
60
|
+
}) ?? fallback_callback;
|
|
61
|
+
if (cancelled) return;
|
|
62
|
+
|
|
63
|
+
/** @type {import('types').ActionResult} */
|
|
64
|
+
let result;
|
|
65
|
+
|
|
66
|
+
try {
|
|
67
|
+
const response = await fetch(action, {
|
|
68
|
+
method: 'POST',
|
|
69
|
+
headers: {
|
|
70
|
+
accept: 'application/json'
|
|
71
|
+
},
|
|
72
|
+
body: data,
|
|
73
|
+
signal: controller.signal
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
result = await response.json();
|
|
77
|
+
} catch (error) {
|
|
78
|
+
if (/** @type {any} */ (error)?.name === 'AbortError') return;
|
|
79
|
+
result = { type: 'error', error };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
callback({
|
|
83
|
+
action,
|
|
84
|
+
data,
|
|
85
|
+
form,
|
|
86
|
+
// @ts-expect-error generic constraints stuff we don't care about
|
|
87
|
+
result,
|
|
88
|
+
// TODO remove for 1.0
|
|
89
|
+
get type() {
|
|
90
|
+
throw new Error('(result) => {...} has changed to ({ result }) => {...}');
|
|
91
|
+
},
|
|
92
|
+
get location() {
|
|
93
|
+
throw new Error('(result) => {...} has changed to ({ result }) => {...}');
|
|
94
|
+
},
|
|
95
|
+
get error() {
|
|
96
|
+
throw new Error('(result) => {...} has changed to ({ result }) => {...}');
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
form.addEventListener('submit', handle_submit);
|
|
102
|
+
|
|
103
|
+
return {
|
|
104
|
+
destroy() {
|
|
105
|
+
form.removeEventListener('submit', handle_submit);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { client } from '../client/singletons.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param {string} name
|
|
5
|
+
*/
|
|
6
|
+
function guard(name) {
|
|
7
|
+
return () => {
|
|
8
|
+
throw new Error(`Cannot call ${name}(...) on the server`);
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const ssr = import.meta.env.SSR;
|
|
13
|
+
|
|
14
|
+
export const disableScrollHandling = ssr
|
|
15
|
+
? guard('disableScrollHandling')
|
|
16
|
+
: client.disable_scroll_handling;
|
|
17
|
+
export const goto = ssr ? guard('goto') : client.goto;
|
|
18
|
+
export const invalidate = ssr ? guard('invalidate') : client.invalidate;
|
|
19
|
+
export const invalidateAll = ssr ? guard('invalidateAll') : client.invalidateAll;
|
|
20
|
+
export const prefetch = ssr ? guard('prefetch') : client.prefetch;
|
|
21
|
+
export const prefetchRoutes = ssr ? guard('prefetchRoutes') : client.prefetch_routes;
|
|
22
|
+
export const beforeNavigate = ssr ? () => {} : client.before_navigate;
|
|
23
|
+
export const afterNavigate = ssr ? () => {} : client.after_navigate;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { base, assets } from '../paths.js';
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { getContext } from 'svelte';
|
|
2
|
+
import { browser } from './environment.js';
|
|
3
|
+
import { stores as browser_stores } from '../client/singletons.js';
|
|
4
|
+
|
|
5
|
+
// TODO remove this (for 1.0? after 1.0?)
|
|
6
|
+
let warned = false;
|
|
7
|
+
export function stores() {
|
|
8
|
+
if (!warned) {
|
|
9
|
+
console.error('stores() is deprecated; use getStores() instead');
|
|
10
|
+
warned = true;
|
|
11
|
+
}
|
|
12
|
+
return getStores();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @type {import('$app/stores').getStores}
|
|
17
|
+
*/
|
|
18
|
+
export const getStores = () => {
|
|
19
|
+
const stores = browser ? browser_stores : getContext('__svelte__');
|
|
20
|
+
|
|
21
|
+
const readonly_stores = {
|
|
22
|
+
page: {
|
|
23
|
+
subscribe: stores.page.subscribe
|
|
24
|
+
},
|
|
25
|
+
navigating: {
|
|
26
|
+
subscribe: stores.navigating.subscribe
|
|
27
|
+
},
|
|
28
|
+
updated: stores.updated
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// TODO remove this for 1.0
|
|
32
|
+
Object.defineProperties(readonly_stores, {
|
|
33
|
+
preloading: {
|
|
34
|
+
get() {
|
|
35
|
+
console.error('stores.preloading is deprecated; use stores.navigating instead');
|
|
36
|
+
return {
|
|
37
|
+
subscribe: stores.navigating.subscribe
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
enumerable: false
|
|
41
|
+
},
|
|
42
|
+
session: {
|
|
43
|
+
get() {
|
|
44
|
+
removed_session();
|
|
45
|
+
return {};
|
|
46
|
+
},
|
|
47
|
+
enumerable: false
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
return readonly_stores;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/** @type {typeof import('$app/stores').page} */
|
|
55
|
+
export const page = {
|
|
56
|
+
/** @param {(value: any) => void} fn */
|
|
57
|
+
subscribe(fn) {
|
|
58
|
+
const store = getStores().page;
|
|
59
|
+
return store.subscribe(fn);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/** @type {typeof import('$app/stores').navigating} */
|
|
64
|
+
export const navigating = {
|
|
65
|
+
subscribe(fn) {
|
|
66
|
+
const store = getStores().navigating;
|
|
67
|
+
return store.subscribe(fn);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
function removed_session() {
|
|
72
|
+
// TODO remove for 1.0
|
|
73
|
+
throw new Error(
|
|
74
|
+
'stores.session is no longer available. See https://github.com/sveltejs/kit/discussions/5883'
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export const session = {
|
|
79
|
+
subscribe: removed_session,
|
|
80
|
+
set: removed_session,
|
|
81
|
+
update: removed_session
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
/** @type {typeof import('$app/stores').updated} */
|
|
85
|
+
export const updated = {
|
|
86
|
+
subscribe(fn) {
|
|
87
|
+
const store = getStores().updated;
|
|
88
|
+
|
|
89
|
+
if (browser) {
|
|
90
|
+
updated.check = store.check;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return store.subscribe(fn);
|
|
94
|
+
},
|
|
95
|
+
check: () => {
|
|
96
|
+
throw new Error(
|
|
97
|
+
browser
|
|
98
|
+
? `Cannot check updated store before subscribing`
|
|
99
|
+
: `Can only check updated store in browser`
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
declare module '__GENERATED__/client-manifest.js' {
|
|
2
|
+
import { CSRPageNodeLoader, ClientHooks, ParamMatcher } from 'types';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A list of all the error/layout/page nodes used in the app
|
|
6
|
+
*/
|
|
7
|
+
export const nodes: CSRPageNodeLoader[];
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A list of all layout node ids that have a server load function.
|
|
11
|
+
* Pages are not present because it's shorter to encode it on the leaf itself.
|
|
12
|
+
*/
|
|
13
|
+
export const server_loads: number[];
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A map of `[routeId: string]: [leaf, layouts, errors]` tuples, which
|
|
17
|
+
* is parsed into an array of routes on startup. The numbers refer to the indices in `nodes`.
|
|
18
|
+
* If the leaf number is negative, it means it does use a server load function and the complement is the node index.
|
|
19
|
+
* The route layout and error nodes are not referenced, they are always number 0 and 1 and always apply.
|
|
20
|
+
*/
|
|
21
|
+
export const dictionary: Record<string, [leaf: number, layouts: number[], errors?: number[]]>;
|
|
22
|
+
|
|
23
|
+
export const matchers: Record<string, ParamMatcher>;
|
|
24
|
+
|
|
25
|
+
export const hooks: ClientHooks;
|
|
26
|
+
}
|