@sveltejs/kit 2.63.0 → 3.0.0-next.0
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 +17 -22
- package/src/cli.js +19 -16
- package/src/core/adapt/builder.js +25 -77
- package/src/core/adapt/index.js +6 -4
- package/src/core/config/index.js +12 -84
- package/src/core/config/options.js +36 -46
- package/src/core/env.js +5 -130
- package/src/core/generate_manifest/find_server_assets.js +3 -2
- package/src/core/generate_manifest/index.js +11 -3
- package/src/core/postbuild/analyse.js +19 -16
- package/src/core/postbuild/fallback.js +0 -3
- package/src/core/postbuild/prerender.js +18 -17
- package/src/core/postbuild/queue.js +3 -4
- package/src/core/sync/create_manifest_data/index.js +16 -18
- package/src/core/sync/sync.js +30 -25
- package/src/core/sync/utils.js +0 -15
- package/src/core/sync/write_ambient.js +3 -54
- package/src/core/sync/write_client_manifest.js +8 -9
- package/src/core/sync/write_env.js +5 -1
- package/src/core/sync/write_non_ambient.js +7 -7
- package/src/core/sync/write_root.js +40 -88
- package/src/core/sync/write_server.js +16 -23
- package/src/core/sync/write_tsconfig.js +28 -24
- package/src/core/sync/write_types/index.js +31 -25
- package/src/core/utils.js +14 -11
- package/src/exports/index.js +8 -21
- package/src/exports/node/index.js +8 -13
- package/src/exports/public.d.ts +35 -76
- package/src/exports/vite/build/build_server.js +14 -11
- package/src/exports/vite/build/remote.js +6 -7
- package/src/exports/vite/build/utils.js +7 -5
- package/src/exports/vite/dev/index.js +30 -31
- package/src/exports/vite/index.js +938 -732
- package/src/exports/vite/module_ids.js +1 -6
- package/src/exports/vite/options.js +17 -0
- package/src/exports/vite/preview/index.js +3 -5
- package/src/exports/vite/static_analysis/index.js +11 -5
- package/src/exports/vite/utils.js +9 -45
- package/src/runtime/app/env/internal.js +3 -0
- package/src/runtime/app/env/public/client.js +0 -6
- package/src/runtime/app/env/public/server.js +0 -6
- package/src/runtime/app/server/index.js +4 -2
- package/src/runtime/app/server/remote/form.js +0 -51
- package/src/runtime/app/server/remote/query.js +0 -7
- package/src/runtime/app/server/remote/shared.js +4 -3
- package/src/runtime/app/state/client.js +1 -12
- package/src/runtime/client/client.js +1 -1
- package/src/runtime/client/constants.js +0 -1
- package/src/runtime/client/remote-functions/form.svelte.js +0 -31
- package/src/runtime/client/remote-functions/query/index.js +2 -2
- package/src/runtime/client/remote-functions/query/instance.svelte.js +1 -2
- package/src/runtime/client/remote-functions/query-batch.svelte.js +2 -2
- package/src/runtime/client/remote-functions/query-live/instance.svelte.js +5 -8
- package/src/runtime/client/utils.js +8 -10
- package/src/runtime/components/{svelte-5/layout.svelte → layout.svelte} +1 -1
- package/src/runtime/form-utils.js +4 -41
- package/src/runtime/server/cookie.js +21 -37
- package/src/runtime/server/env_module.js +1 -3
- package/src/runtime/server/fetch.js +6 -10
- package/src/runtime/server/index.js +3 -9
- package/src/runtime/server/page/render.js +32 -44
- package/src/runtime/server/page/types.d.ts +4 -2
- package/src/runtime/server/respond.js +2 -2
- package/src/runtime/server/utils.js +2 -4
- package/src/runtime/shared-server.js +0 -22
- package/src/runtime/shared.js +0 -15
- package/src/types/global-private.d.ts +5 -1
- package/src/types/internal.d.ts +3 -8
- package/src/utils/css.js +3 -19
- package/src/utils/filesystem.js +1 -30
- package/src/utils/http.js +0 -21
- package/src/utils/import.js +7 -6
- package/src/utils/os.js +7 -0
- package/src/utils/path.js +23 -0
- package/src/utils/shared-iterator.js +3 -0
- package/src/utils/streaming.js +2 -4
- package/src/utils/url.js +1 -1
- package/src/utils/vite.js +28 -0
- package/src/version.js +1 -1
- package/types/index.d.ts +45 -138
- package/types/index.d.ts.map +1 -8
- package/src/exports/vite/build/build_service_worker.js +0 -165
- package/src/runtime/app/environment/index.js +0 -10
- package/src/runtime/app/environment/types.d.ts +0 -19
- package/src/runtime/components/svelte-4/error.svelte +0 -6
- package/src/runtime/components/svelte-4/layout.svelte +0 -1
- package/src/runtime/env/dynamic/private.js +0 -1
- package/src/runtime/env/dynamic/public.js +0 -1
- package/src/types/synthetic/$env+dynamic+private.md +0 -43
- package/src/types/synthetic/$env+dynamic+public.md +0 -46
- package/src/types/synthetic/$env+static+private.md +0 -31
- package/src/types/synthetic/$env+static+public.md +0 -31
- package/src/utils/env.js +0 -13
- package/src/utils/promise.js +0 -29
- /package/src/runtime/components/{svelte-5/error.svelte → error.svelte} +0 -0
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import { fileURLToPath } from 'node:url';
|
|
2
|
-
import { posixify } from '../../utils/
|
|
3
|
-
|
|
4
|
-
export const env_static_private = '\0virtual:env/static/private';
|
|
5
|
-
export const env_static_public = '\0virtual:env/static/public';
|
|
6
|
-
export const env_dynamic_private = '\0virtual:env/dynamic/private';
|
|
7
|
-
export const env_dynamic_public = '\0virtual:env/dynamic/public';
|
|
2
|
+
import { posixify } from '../../utils/os.js';
|
|
8
3
|
|
|
9
4
|
export const sveltekit_env = '\0virtual:__sveltekit/env';
|
|
10
5
|
export const sveltekit_env_public_client = '\0virtual:__sveltekit/env/public/client';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** @import { Validator } from '../../core/config/types.js' */
|
|
2
|
+
|
|
3
|
+
import { object, validate } from '../../core/config/options.js';
|
|
4
|
+
|
|
5
|
+
/** @type {Validator} */
|
|
6
|
+
const options = object({
|
|
7
|
+
adapter: validate(undefined, (input, keypath) => {
|
|
8
|
+
if (typeof input !== 'object' || !input.adapt) {
|
|
9
|
+
const message = `The SvelteKit Vite plugin ${keypath} should be an object with an \`adapt\` method`;
|
|
10
|
+
throw new Error(`${message}. See https://svelte.dev/docs/kit/adapters`);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return input;
|
|
14
|
+
})
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export default options;
|
|
@@ -5,7 +5,6 @@ import { lookup } from 'mrmime';
|
|
|
5
5
|
import sirv from 'sirv';
|
|
6
6
|
import { loadEnv, normalizePath } from 'vite';
|
|
7
7
|
import { createReadableStream, getRequest, setResponse } from '../../../exports/node/index.js';
|
|
8
|
-
import { installPolyfills } from '../../../exports/node/polyfills.js';
|
|
9
8
|
import { SVELTE_KIT_ASSETS } from '../../../constants.js';
|
|
10
9
|
import { is_chrome_devtools_request, not_found } from '../utils.js';
|
|
11
10
|
|
|
@@ -17,10 +16,9 @@ import { is_chrome_devtools_request, not_found } from '../utils.js';
|
|
|
17
16
|
* @param {import('vite').PreviewServer} vite
|
|
18
17
|
* @param {import('vite').ResolvedConfig} vite_config
|
|
19
18
|
* @param {import('types').ValidatedConfig} svelte_config
|
|
19
|
+
* @param {import('@sveltejs/kit').Adapter | undefined} adapter
|
|
20
20
|
*/
|
|
21
|
-
export async function preview(vite, vite_config, svelte_config) {
|
|
22
|
-
installPolyfills();
|
|
23
|
-
|
|
21
|
+
export async function preview(vite, vite_config, svelte_config, adapter) {
|
|
24
22
|
const { paths } = svelte_config.kit;
|
|
25
23
|
const base = paths.base;
|
|
26
24
|
const assets = paths.assets ? SVELTE_KIT_ASSETS : paths.base;
|
|
@@ -56,7 +54,7 @@ export async function preview(vite, vite_config, svelte_config) {
|
|
|
56
54
|
read: (file) => createReadableStream(`${dir}/${file}`)
|
|
57
55
|
});
|
|
58
56
|
|
|
59
|
-
const emulator = await
|
|
57
|
+
const emulator = await adapter?.emulate?.();
|
|
60
58
|
|
|
61
59
|
return () => {
|
|
62
60
|
// Remove the base middleware. It screws with the URL.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
1
2
|
import { tsPlugin } from '@sveltejs/acorn-typescript';
|
|
2
3
|
import { Parser } from 'acorn';
|
|
3
4
|
import { read } from '../../../utils/filesystem.js';
|
|
@@ -213,11 +214,13 @@ function get_name(node) {
|
|
|
213
214
|
/**
|
|
214
215
|
* Reads and statically analyses a file for page options
|
|
215
216
|
* @param {string} filepath
|
|
217
|
+
* @param {string} root The project root directory
|
|
216
218
|
* @returns {PageOptions | null} Returns the page options for the file or `null` if unanalysable
|
|
217
219
|
*/
|
|
218
|
-
export function get_page_options(filepath) {
|
|
220
|
+
export function get_page_options(filepath, root) {
|
|
221
|
+
const input = read(path.resolve(root, filepath));
|
|
222
|
+
|
|
219
223
|
try {
|
|
220
|
-
const input = read(filepath);
|
|
221
224
|
const page_options = statically_analyse_page_options(filepath, input);
|
|
222
225
|
if (page_options === null) {
|
|
223
226
|
return null;
|
|
@@ -229,7 +232,10 @@ export function get_page_options(filepath) {
|
|
|
229
232
|
}
|
|
230
233
|
}
|
|
231
234
|
|
|
232
|
-
|
|
235
|
+
/**
|
|
236
|
+
* @param {string} root
|
|
237
|
+
*/
|
|
238
|
+
export function create_node_analyser(root) {
|
|
233
239
|
const static_exports = new Map();
|
|
234
240
|
|
|
235
241
|
/**
|
|
@@ -273,7 +279,7 @@ export function create_node_analyser() {
|
|
|
273
279
|
}
|
|
274
280
|
|
|
275
281
|
if (node.server) {
|
|
276
|
-
const server_page_options = get_page_options(node.server);
|
|
282
|
+
const server_page_options = get_page_options(node.server, root);
|
|
277
283
|
if (server_page_options === null) {
|
|
278
284
|
cache(key, null);
|
|
279
285
|
return null;
|
|
@@ -282,7 +288,7 @@ export function create_node_analyser() {
|
|
|
282
288
|
}
|
|
283
289
|
|
|
284
290
|
if (node.universal) {
|
|
285
|
-
const universal_page_options = get_page_options(node.universal);
|
|
291
|
+
const universal_page_options = get_page_options(node.universal, root);
|
|
286
292
|
if (universal_page_options === null) {
|
|
287
293
|
cache(key, null);
|
|
288
294
|
return null;
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
|
-
import {
|
|
3
|
-
import { posixify } from '../../utils/filesystem.js';
|
|
2
|
+
import { posixify } from '../../utils/os.js';
|
|
4
3
|
import { negotiate } from '../../utils/http.js';
|
|
5
|
-
import { filter_env } from '../../utils/env.js';
|
|
6
4
|
import { escape_html } from '../../utils/escape.js';
|
|
7
5
|
import { dedent } from '../../core/sync/utils.js';
|
|
8
6
|
import {
|
|
9
7
|
app_server,
|
|
10
8
|
app_env_private,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
env_static_private,
|
|
14
|
-
env_static_public,
|
|
15
|
-
service_worker
|
|
9
|
+
service_worker,
|
|
10
|
+
sveltekit_env_private
|
|
16
11
|
} from './module_ids.js';
|
|
17
12
|
|
|
18
13
|
/**
|
|
@@ -21,8 +16,9 @@ import {
|
|
|
21
16
|
* Related to tsconfig path alias creation.
|
|
22
17
|
*
|
|
23
18
|
* @param {import('types').ValidatedKitConfig} config
|
|
19
|
+
* @param {string} root
|
|
24
20
|
* */
|
|
25
|
-
export function get_config_aliases(config) {
|
|
21
|
+
export function get_config_aliases(config, root) {
|
|
26
22
|
/** @type {import('vite').Alias[]} */
|
|
27
23
|
const alias = [
|
|
28
24
|
// For now, we handle `$lib` specially here rather than make it a default value for
|
|
@@ -39,16 +35,16 @@ export function get_config_aliases(config) {
|
|
|
39
35
|
// Doing just `{ find: key.slice(0, -2) ,..}` would mean `import .. from "key"` would also be matched, which we don't want
|
|
40
36
|
alias.push({
|
|
41
37
|
find: new RegExp(`^${escape_for_regexp(key.slice(0, -2))}\\/(.+)$`),
|
|
42
|
-
replacement: `${path.resolve(value)}/$1`
|
|
38
|
+
replacement: `${path.resolve(root, value)}/$1`
|
|
43
39
|
});
|
|
44
40
|
} else if (key + '/*' in config.alias) {
|
|
45
41
|
// key and key/* both exist -> the replacement for key needs to happen _only_ on import .. from "key"
|
|
46
42
|
alias.push({
|
|
47
43
|
find: new RegExp(`^${escape_for_regexp(key)}$`),
|
|
48
|
-
replacement: path.resolve(value)
|
|
44
|
+
replacement: path.resolve(root, value)
|
|
49
45
|
});
|
|
50
46
|
} else {
|
|
51
|
-
alias.push({ find: key, replacement: path.resolve(value) });
|
|
47
|
+
alias.push({ find: key, replacement: path.resolve(root, value) });
|
|
52
48
|
}
|
|
53
49
|
}
|
|
54
50
|
|
|
@@ -62,22 +58,6 @@ function escape_for_regexp(str) {
|
|
|
62
58
|
return str.replace(/[.*+?^${}()|[\]\\]/g, (match) => '\\' + match);
|
|
63
59
|
}
|
|
64
60
|
|
|
65
|
-
/**
|
|
66
|
-
* Load environment variables from process.env and .env files
|
|
67
|
-
* @param {import('types').ValidatedKitConfig['env']} env_config
|
|
68
|
-
* @param {string} mode
|
|
69
|
-
*/
|
|
70
|
-
export function get_env(env_config, mode) {
|
|
71
|
-
const { publicPrefix: public_prefix, privatePrefix: private_prefix } = env_config;
|
|
72
|
-
const env = loadEnv(mode, env_config.dir, '');
|
|
73
|
-
|
|
74
|
-
return {
|
|
75
|
-
all: env,
|
|
76
|
-
public: filter_env(env, public_prefix, private_prefix),
|
|
77
|
-
private: filter_env(env, private_prefix, public_prefix)
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
|
|
81
61
|
/**
|
|
82
62
|
* Silently respond with 404 for Chrome DevTools workspaces request.
|
|
83
63
|
* Chrome always requests this at the root, regardless of base path.
|
|
@@ -157,26 +137,10 @@ export function normalize_id(id, lib, cwd) {
|
|
|
157
137
|
return '$app/server';
|
|
158
138
|
}
|
|
159
139
|
|
|
160
|
-
if (id === app_env_private) {
|
|
140
|
+
if (id === app_env_private || id === sveltekit_env_private) {
|
|
161
141
|
return '$app/env/private';
|
|
162
142
|
}
|
|
163
143
|
|
|
164
|
-
if (id === env_static_private) {
|
|
165
|
-
return '$env/static/private';
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
if (id === env_static_public) {
|
|
169
|
-
return '$env/static/public';
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
if (id === env_dynamic_private) {
|
|
173
|
-
return '$env/dynamic/private';
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
if (id === env_dynamic_public) {
|
|
177
|
-
return '$env/dynamic/public';
|
|
178
|
-
}
|
|
179
|
-
|
|
180
144
|
if (id === service_worker) {
|
|
181
145
|
return '$service-worker';
|
|
182
146
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { read_implementation, manifest } from '__sveltekit/server';
|
|
2
|
-
import {
|
|
2
|
+
import { assets } from '$app/paths/internal/server';
|
|
3
3
|
import { base64_decode } from '../../utils.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -54,7 +54,9 @@ export function read(asset) {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
const file = decodeURIComponent(
|
|
57
|
-
__SVELTEKIT_DEV__ && asset.startsWith('/@fs')
|
|
57
|
+
__SVELTEKIT_DEV__ && asset.startsWith(assets + '/@fs')
|
|
58
|
+
? asset.slice(assets.length)
|
|
59
|
+
: asset.slice(assets.length + 1)
|
|
58
60
|
);
|
|
59
61
|
|
|
60
62
|
if (file in manifest._.server_assets) {
|
|
@@ -2,11 +2,9 @@
|
|
|
2
2
|
/** @import { InternalRemoteFormIssue, MaybePromise, RemoteFormInternals } from 'types' */
|
|
3
3
|
/** @import { StandardSchemaV1 } from '@standard-schema/spec' */
|
|
4
4
|
import { get_request_store } from '@sveltejs/kit/internal/server';
|
|
5
|
-
import { DEV } from 'esm-env';
|
|
6
5
|
import {
|
|
7
6
|
create_field_proxy,
|
|
8
7
|
set_nested_value,
|
|
9
|
-
throw_on_old_property_access,
|
|
10
8
|
deep_set,
|
|
11
9
|
normalize_issue,
|
|
12
10
|
flatten_issues
|
|
@@ -90,32 +88,6 @@ export function form(validate_or_fn, maybe_fn) {
|
|
|
90
88
|
name: '',
|
|
91
89
|
id: '',
|
|
92
90
|
fn: async (data, meta, form_data) => {
|
|
93
|
-
// TODO 3.0 remove this warning
|
|
94
|
-
if (DEV && !data) {
|
|
95
|
-
const error = () => {
|
|
96
|
-
throw new Error(
|
|
97
|
-
'Remote form functions no longer get passed a FormData object. ' +
|
|
98
|
-
"`form` now has the same signature as `query` or `command`, i.e. it expects to be invoked like `form(schema, callback)` or `form('unchecked', callback)`. " +
|
|
99
|
-
'The payload of the callback function is now a POJO instead of a FormData object. See https://kit.svelte.dev/docs/remote-functions#form for details.'
|
|
100
|
-
);
|
|
101
|
-
};
|
|
102
|
-
data = {};
|
|
103
|
-
for (const key of [
|
|
104
|
-
'append',
|
|
105
|
-
'delete',
|
|
106
|
-
'entries',
|
|
107
|
-
'forEach',
|
|
108
|
-
'get',
|
|
109
|
-
'getAll',
|
|
110
|
-
'has',
|
|
111
|
-
'keys',
|
|
112
|
-
'set',
|
|
113
|
-
'values'
|
|
114
|
-
]) {
|
|
115
|
-
Object.defineProperty(data, key, { get: error });
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
91
|
/** @type {{ submission: true, input?: Record<string, any>, issues?: InternalRemoteFormIssue[], result: Output }} */
|
|
120
92
|
const output = {};
|
|
121
93
|
|
|
@@ -203,20 +175,6 @@ export function form(validate_or_fn, maybe_fn) {
|
|
|
203
175
|
}
|
|
204
176
|
});
|
|
205
177
|
|
|
206
|
-
// TODO 3.0 remove
|
|
207
|
-
if (DEV) {
|
|
208
|
-
throw_on_old_property_access(instance);
|
|
209
|
-
|
|
210
|
-
Object.defineProperty(instance, 'buttonProps', {
|
|
211
|
-
get() {
|
|
212
|
-
throw new Error(
|
|
213
|
-
'`form.buttonProps` has been removed: Instead of `<button {...form.buttonProps}>, use `<button {...form.fields.action.as("submit", "value")}>`.' +
|
|
214
|
-
' See the PR for more info: https://github.com/sveltejs/kit/pull/14622'
|
|
215
|
-
);
|
|
216
|
-
}
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
|
|
220
178
|
Object.defineProperty(instance, 'result', {
|
|
221
179
|
get() {
|
|
222
180
|
try {
|
|
@@ -320,15 +278,6 @@ function create_issues() {
|
|
|
320
278
|
new Proxy(
|
|
321
279
|
/** @param {string} message */
|
|
322
280
|
(message) => {
|
|
323
|
-
// TODO 3.0 remove
|
|
324
|
-
if (typeof message !== 'string') {
|
|
325
|
-
throw new Error(
|
|
326
|
-
'`invalid` should now be imported from `@sveltejs/kit` to throw validation issues. ' +
|
|
327
|
-
"The second parameter provided to the form function (renamed to `issue`) is still used to construct issues, e.g. `invalid(issue.field('message'))`. " +
|
|
328
|
-
'For more info see https://github.com/sveltejs/kit/pulls/14768'
|
|
329
|
-
);
|
|
330
|
-
}
|
|
331
|
-
|
|
332
281
|
return create_issue(message);
|
|
333
282
|
},
|
|
334
283
|
{
|
|
@@ -435,13 +435,6 @@ function create_query_resource(__, payload, state, fn) {
|
|
|
435
435
|
set(value) {
|
|
436
436
|
return update_refresh_value(get_refresh_context(__, 'set', payload), value);
|
|
437
437
|
},
|
|
438
|
-
// TODO 3.0 remove this
|
|
439
|
-
// @ts-expect-error This method no longer exists
|
|
440
|
-
run() {
|
|
441
|
-
throw new Error(
|
|
442
|
-
`\`myQuery().run()\` has been removed — please replace it with \`myQuery()\`. See https://github.com/sveltejs/kit/pull/15779 for more details`
|
|
443
|
-
);
|
|
444
|
-
},
|
|
445
438
|
/** @type {Promise<any>['then']} */
|
|
446
439
|
then(onfulfilled, onrejected) {
|
|
447
440
|
return get_promise().then(onfulfilled, onrejected);
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
/** @import { ServerHooks, MaybePromise, RequestState, RemoteInternals, RequestStore, RemoteLiveQueryUserFunctionReturnType } from 'types' */
|
|
3
3
|
import { parse } from 'devalue';
|
|
4
4
|
import { error } from '@sveltejs/kit';
|
|
5
|
+
import { hydratable } from 'svelte';
|
|
5
6
|
import { with_request_store, get_request_store } from '@sveltejs/kit/internal/server';
|
|
7
|
+
import { create_remote_key, stringify } from '../../../shared.js';
|
|
6
8
|
import { noop } from '../../../../utils/functions.js';
|
|
7
|
-
import { create_remote_key, stringify, unfriendly_hydratable } from '../../../shared.js';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* @param {any} validate_or_fn
|
|
@@ -85,9 +86,9 @@ export async function get_response(internals, payload, state, get_result) {
|
|
|
85
86
|
if (state.is_in_render && internals.id) {
|
|
86
87
|
const remote_key = create_remote_key(internals.id, payload);
|
|
87
88
|
|
|
88
|
-
Promise.resolve(entry.data)
|
|
89
|
+
void Promise.resolve(entry.data)
|
|
89
90
|
.then((value) => {
|
|
90
|
-
void
|
|
91
|
+
void hydratable(remote_key, () => stringify(value, state.transport));
|
|
91
92
|
})
|
|
92
93
|
.catch(noop);
|
|
93
94
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { DEV } from 'esm-env';
|
|
2
1
|
import {
|
|
3
2
|
page as _page,
|
|
4
3
|
navigating as _navigating,
|
|
@@ -47,23 +46,13 @@ export const navigating = {
|
|
|
47
46
|
return _navigating.current ? _navigating.current.willUnload : null;
|
|
48
47
|
},
|
|
49
48
|
get delta() {
|
|
50
|
-
return _navigating.current ? _navigating.current.delta : null;
|
|
49
|
+
return _navigating.current?.type === 'popstate' ? _navigating.current.delta : null;
|
|
51
50
|
},
|
|
52
51
|
get complete() {
|
|
53
52
|
return _navigating.current ? _navigating.current.complete : null;
|
|
54
53
|
}
|
|
55
54
|
};
|
|
56
55
|
|
|
57
|
-
// TODO: remove in 3.0
|
|
58
|
-
if (DEV) {
|
|
59
|
-
Object.defineProperty(navigating, 'current', {
|
|
60
|
-
get() {
|
|
61
|
-
// between 2.12.0 and 2.12.1 `navigating.current` existed
|
|
62
|
-
throw new Error('Replace navigating.current.<prop> with navigating.<prop>');
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
|
|
67
56
|
export const updated = {
|
|
68
57
|
get current() {
|
|
69
58
|
return _updated.current;
|
|
@@ -1619,7 +1619,7 @@ function _before_navigate({ url, type, intent, delta, event, scroll }) {
|
|
|
1619
1619
|
|
|
1620
1620
|
const nav = create_navigation(current, intent, url, type, scroll ?? null);
|
|
1621
1621
|
|
|
1622
|
-
if (delta !== undefined) {
|
|
1622
|
+
if (nav.navigation.type === 'popstate' && delta !== undefined) {
|
|
1623
1623
|
nav.navigation.delta = delta;
|
|
1624
1624
|
}
|
|
1625
1625
|
|
|
@@ -15,7 +15,6 @@ import {
|
|
|
15
15
|
create_field_proxy,
|
|
16
16
|
deep_set,
|
|
17
17
|
set_nested_value,
|
|
18
|
-
throw_on_old_property_access,
|
|
19
18
|
build_path_string,
|
|
20
19
|
normalize_issue,
|
|
21
20
|
serialize_binary_form,
|
|
@@ -304,22 +303,6 @@ export function form(id) {
|
|
|
304
303
|
{},
|
|
305
304
|
{
|
|
306
305
|
...descriptors,
|
|
307
|
-
data: {
|
|
308
|
-
get() {
|
|
309
|
-
// TODO 3.0 remove
|
|
310
|
-
throw new Error(
|
|
311
|
-
`The \`data\` property has been removed from the \`enhance\` callback argument. Use \`instance.fields.value()\` instead.`
|
|
312
|
-
);
|
|
313
|
-
}
|
|
314
|
-
},
|
|
315
|
-
form: {
|
|
316
|
-
get() {
|
|
317
|
-
// TODO 3.0 remove
|
|
318
|
-
throw new Error(
|
|
319
|
-
`The \`form\` property has been removed from the \`enhance\` callback argument. To get the current \`<form>\` element, use \`instance.element\` instead.`
|
|
320
|
-
);
|
|
321
|
-
}
|
|
322
|
-
},
|
|
323
306
|
element: {
|
|
324
307
|
value: form
|
|
325
308
|
},
|
|
@@ -543,20 +526,6 @@ export function form(id) {
|
|
|
543
526
|
|
|
544
527
|
let validate_id = 0;
|
|
545
528
|
|
|
546
|
-
// TODO 3.0 remove
|
|
547
|
-
if (DEV) {
|
|
548
|
-
throw_on_old_property_access(instance);
|
|
549
|
-
|
|
550
|
-
Object.defineProperty(instance, 'buttonProps', {
|
|
551
|
-
get() {
|
|
552
|
-
throw new Error(
|
|
553
|
-
'`form.buttonProps` has been removed: Instead of `<button {...form.buttonProps}>, use `<button {...form.fields.action.as("submit", "value")}>`.' +
|
|
554
|
-
' See the PR for more info: https://github.com/sveltejs/kit/pull/14622'
|
|
555
|
-
);
|
|
556
|
-
}
|
|
557
|
-
});
|
|
558
|
-
}
|
|
559
|
-
|
|
560
529
|
Object.defineProperties(instance, {
|
|
561
530
|
element: {
|
|
562
531
|
get: () => element
|
|
@@ -4,7 +4,7 @@ import { app, query_map, query_responses } from '../../client.js';
|
|
|
4
4
|
import { get_remote_request_headers, QUERY_FUNCTION_ID, remote_request } from '../shared.svelte.js';
|
|
5
5
|
import * as devalue from 'devalue';
|
|
6
6
|
import { DEV } from 'esm-env';
|
|
7
|
-
import {
|
|
7
|
+
import { hydratable } from 'svelte';
|
|
8
8
|
import { QueryProxy } from './proxy.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -34,7 +34,7 @@ export function query(id) {
|
|
|
34
34
|
|
|
35
35
|
const url = `${base}/${app_dir}/remote/${id}${payload ? `?payload=${payload}` : ''}`;
|
|
36
36
|
|
|
37
|
-
const serialized = await
|
|
37
|
+
const serialized = await hydratable(key, () =>
|
|
38
38
|
remote_request(url, get_remote_request_headers())
|
|
39
39
|
);
|
|
40
40
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { query_responses } from '../../client.js';
|
|
2
2
|
import { QUERY_OVERRIDE_KEY } from '../shared.svelte.js';
|
|
3
3
|
import { noop } from '../../../../utils/functions.js';
|
|
4
|
-
import { with_resolvers } from '../../../../utils/promise.js';
|
|
5
4
|
import { tick, untrack } from 'svelte';
|
|
6
5
|
|
|
7
6
|
/**
|
|
@@ -87,7 +86,7 @@ export class Query {
|
|
|
87
86
|
#run() {
|
|
88
87
|
this.#loading = true;
|
|
89
88
|
|
|
90
|
-
const { promise, resolve, reject } =
|
|
89
|
+
const { promise, resolve, reject } = Promise.withResolvers();
|
|
91
90
|
|
|
92
91
|
this.#latest.push(resolve);
|
|
93
92
|
|
|
@@ -6,7 +6,7 @@ import { get_remote_request_headers, QUERY_FUNCTION_ID } from './shared.svelte.j
|
|
|
6
6
|
import { QueryProxy } from './query/proxy.js';
|
|
7
7
|
import * as devalue from 'devalue';
|
|
8
8
|
import { HttpError, Redirect } from '@sveltejs/kit/internal';
|
|
9
|
-
import {
|
|
9
|
+
import { hydratable } from 'svelte';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* @param {string} id
|
|
@@ -19,7 +19,7 @@ export function query_batch(id) {
|
|
|
19
19
|
/** @type {RemoteQueryFunction<any, any>} */
|
|
20
20
|
const wrapper = (arg) => {
|
|
21
21
|
return new QueryProxy(id, arg, async (key, payload) => {
|
|
22
|
-
const serialized = await
|
|
22
|
+
const serialized = await hydratable(key, () => {
|
|
23
23
|
return new Promise((resolve, reject) => {
|
|
24
24
|
// create_remote_function caches identical calls, but in case a refresh to the same query is called multiple times this function
|
|
25
25
|
// is invoked multiple times with the same payload, so we need to deduplicate here
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
/** @import { PromiseWithResolvers } from '../../../../utils/promise.js' */
|
|
2
1
|
import { app } from '../../client.js';
|
|
3
2
|
import * as devalue from 'devalue';
|
|
4
3
|
import { HttpError, Redirect } from '@sveltejs/kit/internal';
|
|
5
4
|
import { noop, once } from '../../../../utils/functions.js';
|
|
6
|
-
import { with_resolvers } from '../../../../utils/promise.js';
|
|
7
5
|
import { SharedIterator } from '../../../../utils/shared-iterator.js';
|
|
8
|
-
import { tick } from 'svelte';
|
|
9
|
-
import { unfriendly_hydratable } from '../../../shared.js';
|
|
6
|
+
import { hydratable, tick } from 'svelte';
|
|
10
7
|
import { create_live_iterator } from './iterator.js';
|
|
11
8
|
|
|
12
9
|
/**
|
|
@@ -82,12 +79,12 @@ export class LiveQuery {
|
|
|
82
79
|
// the semantics of awaiting a live query are a bit weird, but it's basically:
|
|
83
80
|
// - It's a promise that resolves to the first value from the server
|
|
84
81
|
// - Thereafter, it's a promise that immediately resolves to the current value
|
|
85
|
-
const { promise, resolve, reject } =
|
|
82
|
+
const { promise, resolve, reject } = Promise.withResolvers();
|
|
86
83
|
this.#promise = $state.raw(promise);
|
|
87
84
|
this.#resolve_first = resolve;
|
|
88
85
|
this.#reject_first = reject;
|
|
89
86
|
|
|
90
|
-
const serialized =
|
|
87
|
+
const serialized = hydratable(key, () => undefined);
|
|
91
88
|
if (serialized !== undefined) {
|
|
92
89
|
this.set(devalue.parse(serialized, app.decoders));
|
|
93
90
|
}
|
|
@@ -109,7 +106,7 @@ export class LiveQuery {
|
|
|
109
106
|
if (this.#interrupt) return;
|
|
110
107
|
|
|
111
108
|
/** @type {PromiseWithResolvers<void>} */
|
|
112
|
-
const { promise: stopped, resolve: on_stop } =
|
|
109
|
+
const { promise: stopped, resolve: on_stop } = Promise.withResolvers();
|
|
113
110
|
|
|
114
111
|
while (!this.#done) {
|
|
115
112
|
const controller = new AbortController();
|
|
@@ -327,7 +324,7 @@ export class LiveQuery {
|
|
|
327
324
|
async reconnect() {
|
|
328
325
|
await this.#interrupt?.();
|
|
329
326
|
/** @type {PromiseWithResolvers<void>} */
|
|
330
|
-
const { promise, resolve: on_connect, reject: on_connect_failed } =
|
|
327
|
+
const { promise, resolve: on_connect, reject: on_connect_failed } = Promise.withResolvers();
|
|
331
328
|
promise.catch(noop);
|
|
332
329
|
this.#done = false;
|
|
333
330
|
this.#attempt = 0;
|
|
@@ -35,12 +35,12 @@ const warned = new WeakSet();
|
|
|
35
35
|
/** @typedef {keyof typeof valid_link_options} LinkOptionName */
|
|
36
36
|
|
|
37
37
|
const valid_link_options = /** @type {const} */ ({
|
|
38
|
-
'preload-code': ['', '
|
|
39
|
-
'preload-data': ['', '
|
|
40
|
-
keepfocus: ['', 'true', '
|
|
41
|
-
noscroll: ['', 'true', '
|
|
42
|
-
reload: ['', 'true', '
|
|
43
|
-
replacestate: ['', 'true', '
|
|
38
|
+
'preload-code': ['', 'false', 'tap', 'hover', 'viewport', 'eager'],
|
|
39
|
+
'preload-data': ['', 'false', 'tap', 'hover'],
|
|
40
|
+
keepfocus: ['', 'true', 'false'],
|
|
41
|
+
noscroll: ['', 'true', 'false'],
|
|
42
|
+
reload: ['', 'true', 'false'],
|
|
43
|
+
replacestate: ['', 'true', 'false']
|
|
44
44
|
});
|
|
45
45
|
|
|
46
46
|
/**
|
|
@@ -194,7 +194,6 @@ export function get_router_options(element) {
|
|
|
194
194
|
case '':
|
|
195
195
|
case 'true':
|
|
196
196
|
return true;
|
|
197
|
-
case 'off':
|
|
198
197
|
case 'false':
|
|
199
198
|
return false;
|
|
200
199
|
default:
|
|
@@ -203,8 +202,8 @@ export function get_router_options(element) {
|
|
|
203
202
|
}
|
|
204
203
|
|
|
205
204
|
return {
|
|
206
|
-
preload_code: levels[preload_code ?? '
|
|
207
|
-
preload_data: levels[preload_data ?? '
|
|
205
|
+
preload_code: levels[preload_code ?? 'false'],
|
|
206
|
+
preload_data: levels[preload_data ?? 'false'],
|
|
208
207
|
keepfocus: get_option_state(keepfocus),
|
|
209
208
|
noscroll: get_option_state(noscroll),
|
|
210
209
|
reload: get_option_state(reload),
|
|
@@ -271,7 +270,6 @@ export function create_updated_store() {
|
|
|
271
270
|
try {
|
|
272
271
|
const res = await fetch(`${assets}/${__SVELTEKIT_APP_VERSION_FILE__}`, {
|
|
273
272
|
headers: {
|
|
274
|
-
pragma: 'no-cache',
|
|
275
273
|
'cache-control': 'no-cache'
|
|
276
274
|
}
|
|
277
275
|
});
|