@sveltejs/kit 3.0.0-next.23 → 3.0.0-next.25
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 +51 -8
- package/src/cli.js +3 -3
- package/src/constants.js +19 -1
- package/src/core/adapt/builder.js +3 -5
- package/src/core/env.js +137 -182
- package/src/core/postbuild/analyse.js +9 -4
- package/src/core/postbuild/prerender.js +5 -6
- package/src/core/sync/create_manifest_data/index.js +29 -33
- package/src/core/sync/sync.js +23 -40
- package/src/core/sync/write_app_manifest.js +83 -0
- package/src/core/sync/write_client_manifest.js +6 -4
- package/src/core/sync/write_server.js +12 -22
- package/src/core/sync/write_types/index.js +2 -2
- package/src/core/utils.js +10 -28
- package/src/exports/adapter.js +22 -0
- package/src/exports/hooks/public.d.ts +9 -1
- package/src/exports/node/index.js +77 -5
- package/src/exports/public.d.ts +1 -1
- package/src/exports/vite/build/build_server.js +3 -3
- package/src/exports/vite/build/service-worker.js +98 -0
- package/src/exports/vite/build/utils.js +48 -4
- package/src/exports/vite/dev/index.js +28 -25
- package/src/exports/vite/index.js +94 -747
- package/src/exports/vite/module_ids.js +1 -11
- package/src/exports/vite/plugins/env-vars.js +159 -0
- package/src/exports/vite/plugins/guard.js +205 -0
- package/src/exports/vite/preview/index.js +6 -4
- package/src/exports/vite/utils.js +99 -4
- package/src/runtime/app/env/{types.d.ts → client.js} +9 -4
- package/src/runtime/app/env/index.js +1 -2
- package/src/runtime/app/env/private/index.js +1 -0
- package/src/runtime/app/env/public/client.js +1 -1
- package/src/runtime/app/env/public/server.js +1 -1
- package/src/runtime/app/env/{internal.js → server.js} +4 -4
- package/src/runtime/app/forms/client.js +263 -0
- package/src/runtime/app/forms/index.js +1 -263
- package/src/runtime/app/forms/public.d.ts +1 -1
- package/src/runtime/app/forms/server.js +6 -0
- package/src/runtime/app/forms/shared.js +34 -0
- package/src/runtime/app/manifest/index.js +1 -1
- package/src/runtime/app/navigation/client.js +15 -0
- package/src/runtime/app/navigation/index.js +1 -15
- package/src/runtime/app/navigation/public.d.ts +1 -1
- package/src/runtime/app/navigation/server.js +15 -0
- package/src/runtime/app/paths/server.js +1 -1
- package/src/runtime/app/server/remote/form.js +11 -1
- package/src/runtime/app/server/remote/prerender.js +1 -2
- package/src/runtime/app/server/remote/query.js +3 -3
- package/src/runtime/app/state/client.svelte.js +207 -0
- package/src/runtime/app/state/index.js +1 -66
- package/src/runtime/app/state/public.d.ts +1 -1
- package/src/runtime/client/bundle.js +1 -1
- package/src/runtime/client/client.js +210 -278
- package/src/runtime/client/fetcher.js +18 -8
- package/src/runtime/client/remote-functions/form.svelte.js +9 -6
- package/src/runtime/client/remote-functions/prerender.svelte.js +1 -1
- package/src/runtime/client/remote-functions/query-live/iterator.js +1 -1
- package/src/runtime/client/remote-functions/shared.svelte.js +2 -2
- package/src/runtime/client/snapshots.js +1 -3
- package/src/runtime/client/stream.js +27 -20
- package/src/runtime/client/utils.js +7 -3
- package/src/runtime/components/root.svelte +5 -5
- package/src/runtime/env/dynamic/private.js +1 -1
- package/src/runtime/env/static/private.js +1 -1
- package/src/runtime/error-chain.js +54 -0
- package/src/runtime/form-utils.js +55 -87
- package/src/runtime/invalid-import.js +1 -0
- package/src/runtime/props.svelte.js +1 -1
- package/src/runtime/server/data/index.js +12 -27
- package/src/runtime/server/endpoint.js +8 -3
- package/src/runtime/server/env_module.js +1 -1
- package/src/runtime/server/errors.js +9 -12
- package/src/runtime/server/fetch.js +14 -16
- package/src/runtime/server/index.js +30 -27
- package/src/runtime/server/internal.js +34 -4
- package/src/runtime/server/page/actions.js +77 -124
- package/src/runtime/server/page/data_serializer.js +6 -10
- package/src/runtime/server/page/index.js +45 -82
- package/src/runtime/server/page/render.js +34 -52
- package/src/runtime/server/page/respond_with_error.js +7 -9
- package/src/runtime/server/remote-functions.js +138 -166
- package/src/runtime/server/respond.js +75 -30
- package/src/runtime/server/state.js +1 -0
- package/src/runtime/server/utils.js +0 -7
- package/src/runtime/utils.js +41 -0
- package/src/telemetry.js +1 -33
- package/src/types/ambient-private.d.ts +9 -17
- package/src/types/global-private.d.ts +8 -0
- package/src/types/internal.d.ts +27 -15
- package/src/types/private.d.ts +1 -1
- package/src/utils/exports.js +1 -0
- package/src/utils/filesystem.js +10 -22
- package/src/utils/functions.js +10 -0
- package/src/utils/routing.js +0 -11
- package/src/utils/streaming.js +5 -15
- package/src/utils/url.js +0 -11
- package/src/version.js +1 -1
- package/types/index.d.ts +54 -29
- package/types/index.d.ts.map +10 -5
- package/src/runtime/app/env/private.js +0 -1
- package/src/runtime/app/env/standard-schema.d.ts +0 -0
- package/src/runtime/app/state/client.js +0 -63
- package/src/runtime/client/state.svelte.js +0 -98
- package/src/runtime/server/ambient.d.ts +0 -4
- package/src/utils/path.js +0 -23
|
@@ -29,13 +29,6 @@ export function allowed_methods(mod) {
|
|
|
29
29
|
return allowed;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
/**
|
|
33
|
-
* @param {import('types').SSROptions} options
|
|
34
|
-
*/
|
|
35
|
-
export function get_global_name(options) {
|
|
36
|
-
return __SVELTEKIT_DEV__ ? '__sveltekit_dev' : `__sveltekit_${options.version_hash}`;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
32
|
/**
|
|
40
33
|
* @param {number} status
|
|
41
34
|
* @param {string} location
|
package/src/runtime/utils.js
CHANGED
|
@@ -1,6 +1,47 @@
|
|
|
1
1
|
import { BROWSER } from 'esm-env';
|
|
2
2
|
|
|
3
3
|
export const text_encoder = new TextEncoder();
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* `ReadableStream.from`, for runtimes that don't support it (as of writing, every Bun release)
|
|
7
|
+
* @template T
|
|
8
|
+
* @param {AsyncIterable<T>} iterable
|
|
9
|
+
* @returns {ReadableStream<T>}
|
|
10
|
+
*/
|
|
11
|
+
export function stream_from_iterable(iterable) {
|
|
12
|
+
// TODO remove the casts once TypeScript's lib includes `ReadableStream.from`
|
|
13
|
+
if (/** @type {any} */ (ReadableStream).from) {
|
|
14
|
+
return /** @type {any} */ (ReadableStream).from(iterable);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const iterator = iterable[Symbol.asyncIterator]();
|
|
18
|
+
return new ReadableStream({
|
|
19
|
+
async pull(controller) {
|
|
20
|
+
const { value, done } = await iterator.next();
|
|
21
|
+
if (done) controller.close();
|
|
22
|
+
else controller.enqueue(value);
|
|
23
|
+
},
|
|
24
|
+
async cancel(reason) {
|
|
25
|
+
await iterator.return?.(reason);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @param {string} head
|
|
32
|
+
* @param {AsyncIterable<string>} chunks
|
|
33
|
+
* @returns {ReadableStream<Uint8Array>} `head` followed by each non-empty chunk, encoded
|
|
34
|
+
*/
|
|
35
|
+
export function stream_text(head, chunks) {
|
|
36
|
+
return stream_from_iterable(
|
|
37
|
+
(async function* () {
|
|
38
|
+
yield text_encoder.encode(head);
|
|
39
|
+
for await (const chunk of chunks) {
|
|
40
|
+
if (chunk) yield text_encoder.encode(chunk);
|
|
41
|
+
}
|
|
42
|
+
})()
|
|
43
|
+
);
|
|
44
|
+
}
|
|
4
45
|
export const text_decoder = new TextDecoder();
|
|
5
46
|
|
|
6
47
|
/**
|
package/src/telemetry.js
CHANGED
|
@@ -1,36 +1,4 @@
|
|
|
1
|
-
/** @import {
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Tracer implementation that does nothing (null object).
|
|
5
|
-
* @type {Tracer}
|
|
6
|
-
*/
|
|
7
|
-
export const noop_tracer = {
|
|
8
|
-
/**
|
|
9
|
-
* @returns {Span}
|
|
10
|
-
*/
|
|
11
|
-
startSpan() {
|
|
12
|
-
return noop_span;
|
|
13
|
-
},
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @param {unknown} _name
|
|
17
|
-
* @param {unknown} arg_1
|
|
18
|
-
* @param {unknown} [arg_2]
|
|
19
|
-
* @param {Function} [arg_3]
|
|
20
|
-
* @returns {unknown}
|
|
21
|
-
*/
|
|
22
|
-
startActiveSpan(_name, arg_1, arg_2, arg_3) {
|
|
23
|
-
if (typeof arg_1 === 'function') {
|
|
24
|
-
return arg_1(noop_span);
|
|
25
|
-
}
|
|
26
|
-
if (typeof arg_2 === 'function') {
|
|
27
|
-
return arg_2(noop_span);
|
|
28
|
-
}
|
|
29
|
-
if (typeof arg_3 === 'function') {
|
|
30
|
-
return arg_3(noop_span);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
};
|
|
1
|
+
/** @import { Span, SpanContext } from '@opentelemetry/api' */
|
|
34
2
|
|
|
35
3
|
/**
|
|
36
4
|
* @type {Span}
|
|
@@ -1,18 +1,10 @@
|
|
|
1
|
-
/** Internal version of $app/paths */
|
|
2
|
-
declare module '__sveltekit/paths' {
|
|
3
|
-
export let base: '' | `/${string}`;
|
|
4
|
-
export let assets: '' | `https://${string}` | `http://${string}` | '/_svelte_kit_assets';
|
|
5
|
-
export let app_dir: string;
|
|
6
|
-
export let relative: boolean;
|
|
7
|
-
export function reset(): void;
|
|
8
|
-
export function override(paths: { base: string; assets: string }): void;
|
|
9
|
-
export function set_assets(path: string): void;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
1
|
/** Internal version of $app/server */
|
|
13
|
-
declare module '
|
|
2
|
+
declare module '<sveltekit:generated>/server.js' {
|
|
14
3
|
import { SSRManifest } from '@sveltejs/kit';
|
|
4
|
+
import { SSROptions, ServerHooks } from 'types';
|
|
15
5
|
|
|
6
|
+
export const options: SSROptions;
|
|
7
|
+
export const get_hooks: () => Promise<Partial<ServerHooks>>;
|
|
16
8
|
export let fix_stack_trace: (error: Error) => string;
|
|
17
9
|
export let manifest: SSRManifest;
|
|
18
10
|
export function read_implementation(path: string): ReadableStream;
|
|
@@ -21,7 +13,7 @@ declare module '__sveltekit/server' {
|
|
|
21
13
|
export function set_read_implementation(fn: (path: string) => ReadableStream): void;
|
|
22
14
|
}
|
|
23
15
|
|
|
24
|
-
declare module '
|
|
16
|
+
declare module '<sveltekit:generated>/env/config.js' {
|
|
25
17
|
// exported environment variables are defined in env.d.ts
|
|
26
18
|
|
|
27
19
|
/** Populate exported environment variables */
|
|
@@ -34,20 +26,20 @@ declare module '__sveltekit/env' {
|
|
|
34
26
|
export const rendered_env: Record<string, any>;
|
|
35
27
|
}
|
|
36
28
|
|
|
37
|
-
declare module '
|
|
29
|
+
declare module '<sveltekit:generated>/env/private/server.js' {
|
|
38
30
|
// exported environment variables are defined in env.d.ts
|
|
39
31
|
}
|
|
40
32
|
|
|
41
|
-
declare module '
|
|
33
|
+
declare module '<sveltekit:generated>/env/public/client.js' {
|
|
42
34
|
// exported environment variables are defined in env.d.ts
|
|
43
35
|
}
|
|
44
36
|
|
|
45
|
-
declare module '
|
|
37
|
+
declare module '<sveltekit:generated>/env/public/server.js' {
|
|
46
38
|
// exported environment variables are defined in env.d.ts
|
|
47
39
|
}
|
|
48
40
|
|
|
49
41
|
/** Internal version of $app/manifest */
|
|
50
|
-
declare module '
|
|
42
|
+
declare module '<sveltekit:generated>/app-manifest.js' {
|
|
51
43
|
export const immutable: Array<{ path: string }>;
|
|
52
44
|
export const assets: Array<{ path: string }>;
|
|
53
45
|
export const prerendered: Array<{ path: string }>;
|
|
@@ -13,7 +13,15 @@ declare global {
|
|
|
13
13
|
* it is influenced by `NODE_ENV` which can still be true during `vite preview`
|
|
14
14
|
*/
|
|
15
15
|
const __SVELTEKIT_DEV__: boolean;
|
|
16
|
+
const __SVELTEKIT_CSRF_CHECK_ORIGIN__: boolean;
|
|
16
17
|
const __SVELTEKIT_EMBEDDED__: boolean;
|
|
18
|
+
/** True if `config.output.linkHeaderPreload` is `true` */
|
|
19
|
+
const __SVELTEKIT_LINK_HEADER_PRELOAD__: boolean;
|
|
20
|
+
const __SVELTEKIT_PATHS_ORIGIN__: string | undefined;
|
|
21
|
+
/** True if the app has a service worker and `config.serviceWorker.register` is `true` */
|
|
22
|
+
const __SVELTEKIT_SERVICE_WORKER__: boolean;
|
|
23
|
+
/** The `__sveltekit_xxx` name the payload object is attached to, without `globalThis.` */
|
|
24
|
+
const __SVELTEKIT_GLOBAL_NAME__: string;
|
|
17
25
|
const __SVELTEKIT_PATHS_ASSETS__: string;
|
|
18
26
|
const __SVELTEKIT_PATHS_BASE__: string;
|
|
19
27
|
const __SVELTEKIT_PATHS_RELATIVE__: boolean;
|
package/src/types/internal.d.ts
CHANGED
|
@@ -8,7 +8,8 @@ import {
|
|
|
8
8
|
Actions,
|
|
9
9
|
RequestEvent,
|
|
10
10
|
SSRManifest,
|
|
11
|
-
Emulator
|
|
11
|
+
Emulator,
|
|
12
|
+
HttpError
|
|
12
13
|
} from '@sveltejs/kit';
|
|
13
14
|
import { RemoteFormIssue, RemoteQuery, RemoteLiveQuery } from '$app/server';
|
|
14
15
|
import { Config } from '@sveltejs/kit/vite';
|
|
@@ -47,7 +48,7 @@ export interface ServerInternalModule {
|
|
|
47
48
|
set_version(version: string): void;
|
|
48
49
|
set_fix_stack_trace(fix_stack_trace: (error: Error) => void): void;
|
|
49
50
|
get_hooks: () => Promise<Record<string, any>>;
|
|
50
|
-
|
|
51
|
+
format_response: (status: number, request: Request) => string;
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
export interface Asset {
|
|
@@ -61,10 +62,17 @@ export interface AssetDependencies {
|
|
|
61
62
|
file: string;
|
|
62
63
|
imports: string[];
|
|
63
64
|
stylesheets: string[];
|
|
64
|
-
fonts:
|
|
65
|
+
fonts: FontDependency[];
|
|
65
66
|
stylesheet_map: Map<string, { css: Set<string>; assets: Set<string> }>;
|
|
66
67
|
}
|
|
67
68
|
|
|
69
|
+
export interface FontDependency {
|
|
70
|
+
/** emitted file path, relative to the client output directory */
|
|
71
|
+
file: string;
|
|
72
|
+
/** the source file path relative to the project root, before hashing and character sanitization */
|
|
73
|
+
filename: string;
|
|
74
|
+
}
|
|
75
|
+
|
|
68
76
|
export interface BuildData {
|
|
69
77
|
app_dir: string;
|
|
70
78
|
app_path: string;
|
|
@@ -97,7 +105,7 @@ export interface BuildData {
|
|
|
97
105
|
*/
|
|
98
106
|
routes?: SSRClientRoute[];
|
|
99
107
|
stylesheets: string[];
|
|
100
|
-
fonts:
|
|
108
|
+
fonts: FontDependency[];
|
|
101
109
|
/**
|
|
102
110
|
* Whether the client uses public dynamic env vars — `$env/dynamic/public` or `$app/env/public`.
|
|
103
111
|
*/
|
|
@@ -292,6 +300,14 @@ export interface RouteData {
|
|
|
292
300
|
} | null;
|
|
293
301
|
}
|
|
294
302
|
|
|
303
|
+
/**
|
|
304
|
+
* The server-side form of `ActionResult`, before the error is passed
|
|
305
|
+
* through `handleError` and the data is serialized
|
|
306
|
+
*/
|
|
307
|
+
export type ServerActionResult =
|
|
308
|
+
| Exclude<import('$app/forms').ActionResult, { type: 'error' }>
|
|
309
|
+
| { type: 'error'; location: string; error: Error | HttpError };
|
|
310
|
+
|
|
295
311
|
export type ServerRedirectNode = {
|
|
296
312
|
type: 'redirect';
|
|
297
313
|
status: number;
|
|
@@ -449,7 +465,7 @@ export interface SSRNode {
|
|
|
449
465
|
/** external CSS files that are loaded on the client */
|
|
450
466
|
stylesheets: string[];
|
|
451
467
|
/** external font files that are loaded on the client */
|
|
452
|
-
fonts:
|
|
468
|
+
fonts: FontDependency[];
|
|
453
469
|
|
|
454
470
|
universal_id?: string;
|
|
455
471
|
server_id?: string;
|
|
@@ -477,14 +493,7 @@ export type SSRNodeLoader = () => Promise<SSRNode>;
|
|
|
477
493
|
export interface SSROptions {
|
|
478
494
|
app_template_contains_nonce: boolean;
|
|
479
495
|
csp: ValidatedConfig['csp'];
|
|
480
|
-
csrf_check_origin: boolean;
|
|
481
496
|
csrf_trusted_origins: string[];
|
|
482
|
-
embedded: boolean;
|
|
483
|
-
hash_routing: boolean;
|
|
484
|
-
hooks: ServerHooks;
|
|
485
|
-
link_header_preload: ValidatedConfig['output']['linkHeaderPreload'];
|
|
486
|
-
paths_origin: string | undefined;
|
|
487
|
-
service_worker: boolean;
|
|
488
497
|
service_worker_options: RegistrationOptions;
|
|
489
498
|
templates: {
|
|
490
499
|
app(values: {
|
|
@@ -496,8 +505,6 @@ export interface SSROptions {
|
|
|
496
505
|
}): string;
|
|
497
506
|
error(values: { message: string; status: number }): string;
|
|
498
507
|
};
|
|
499
|
-
version: string;
|
|
500
|
-
version_hash: string;
|
|
501
508
|
}
|
|
502
509
|
|
|
503
510
|
export interface PageNodeIndexes {
|
|
@@ -590,7 +597,7 @@ export interface RemoteQueryLiveInternals extends BaseRemoteInternals {
|
|
|
590
597
|
export interface RemoteQueryBatchInternals extends BaseRemoteInternals {
|
|
591
598
|
type: 'query_batch';
|
|
592
599
|
validate: (arg?: any) => MaybePromise<any>;
|
|
593
|
-
run: (args: any[]
|
|
600
|
+
run: (args: any[]) => Promise<any[]>;
|
|
594
601
|
/**
|
|
595
602
|
* Creates a `RemoteQuery` bound directly to a specific client payload (the
|
|
596
603
|
* stringified raw argument) and a pre-validated argument, skipping the query
|
|
@@ -675,6 +682,11 @@ export interface RequestState {
|
|
|
675
682
|
* True if we're currently attempting to render an error page.
|
|
676
683
|
*/
|
|
677
684
|
error: boolean;
|
|
685
|
+
/**
|
|
686
|
+
* The rerouted URL (only if the new pathname differs from the original).
|
|
687
|
+
* Used by platforms that serve a catch-all serverless function.
|
|
688
|
+
*/
|
|
689
|
+
rerouted_url: string | null;
|
|
678
690
|
/**
|
|
679
691
|
* Allows us to prevent `event.fetch` from making infinitely looping internal requests.
|
|
680
692
|
*/
|
package/src/types/private.d.ts
CHANGED
|
@@ -154,7 +154,7 @@ export interface CspDirectives {
|
|
|
154
154
|
>;
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
-
export type HttpMethod = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'OPTIONS';
|
|
157
|
+
export type HttpMethod = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'OPTIONS' | 'QUERY';
|
|
158
158
|
|
|
159
159
|
export interface Logger {
|
|
160
160
|
(msg: string): void;
|
package/src/utils/exports.js
CHANGED
package/src/utils/filesystem.js
CHANGED
|
@@ -63,30 +63,18 @@ export function copy(source, target, opts = {}) {
|
|
|
63
63
|
/**
|
|
64
64
|
* Get a list of all files in a directory
|
|
65
65
|
* @param {string} cwd - the directory to walk
|
|
66
|
-
* @param {
|
|
67
|
-
* @returns {string
|
|
66
|
+
* @param {string} [dir] - the subdirectory to walk, relative to `cwd`
|
|
67
|
+
* @returns {Generator<string>} the posix paths of all found files, relative to `cwd`
|
|
68
68
|
*/
|
|
69
|
-
export function walk(cwd,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
for (const file of files) {
|
|
78
|
-
const joined = path.join(dir, file);
|
|
79
|
-
const stats = fs.statSync(path.join(cwd, joined));
|
|
80
|
-
if (stats.isDirectory()) {
|
|
81
|
-
if (dirs) all_files.push(joined);
|
|
82
|
-
walk_dir(joined);
|
|
83
|
-
} else {
|
|
84
|
-
all_files.push(joined);
|
|
85
|
-
}
|
|
69
|
+
export function* walk(cwd, dir = '') {
|
|
70
|
+
for (const file of fs.readdirSync(path.join(cwd, dir))) {
|
|
71
|
+
const joined = dir ? `${dir}/${file}` : file;
|
|
72
|
+
if (fs.statSync(path.join(cwd, joined)).isDirectory()) {
|
|
73
|
+
yield* walk(cwd, joined);
|
|
74
|
+
} else {
|
|
75
|
+
yield joined;
|
|
86
76
|
}
|
|
87
77
|
}
|
|
88
|
-
|
|
89
|
-
return (walk_dir(''), all_files);
|
|
90
78
|
}
|
|
91
79
|
|
|
92
80
|
/**
|
|
@@ -115,7 +103,7 @@ export function relative_path(from, to) {
|
|
|
115
103
|
/**
|
|
116
104
|
* Given an entry point like [cwd]/src/hooks, returns a filename like [cwd]/src/hooks.js or [cwd]/src/hooks/index.js
|
|
117
105
|
* @param {string} entry
|
|
118
|
-
* @returns {string|null}
|
|
106
|
+
* @returns {string | null}
|
|
119
107
|
*/
|
|
120
108
|
export function resolve_entry(entry) {
|
|
121
109
|
if (fs.existsSync(entry)) {
|
package/src/utils/functions.js
CHANGED
|
@@ -16,3 +16,13 @@ export function once(fn) {
|
|
|
16
16
|
return (result = fn());
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @param {string} name
|
|
22
|
+
* @param {string} [parens]
|
|
23
|
+
*/
|
|
24
|
+
export function disallow_on_server(name, parens = '(...)') {
|
|
25
|
+
return () => {
|
|
26
|
+
throw new Error(`Cannot call \`${name}${parens}\` on the server`);
|
|
27
|
+
};
|
|
28
|
+
}
|
package/src/utils/routing.js
CHANGED
|
@@ -116,17 +116,6 @@ export function parse_route_id(id) {
|
|
|
116
116
|
return { pattern, params };
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
const optional_param_regex = /\/\[\[[\w-]+?(?:=[\w-]+)?\]\]/;
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Removes optional params from a route ID.
|
|
123
|
-
* @param {string} id
|
|
124
|
-
* @returns The route id with optional params removed
|
|
125
|
-
*/
|
|
126
|
-
export function remove_optional_params(id) {
|
|
127
|
-
return id.replace(optional_param_regex, '');
|
|
128
|
-
}
|
|
129
|
-
|
|
130
119
|
/**
|
|
131
120
|
* Returns `false` for `(group)` segments
|
|
132
121
|
* @param {string} segment
|
package/src/utils/streaming.js
CHANGED
|
@@ -10,26 +10,16 @@ import { noop } from './functions.js';
|
|
|
10
10
|
*/
|
|
11
11
|
export function create_async_iterator() {
|
|
12
12
|
let resolved = -1;
|
|
13
|
-
let returned = -1;
|
|
14
13
|
|
|
15
14
|
/** @type {PromiseWithResolvers<T>[]} */
|
|
16
15
|
const deferred = [];
|
|
17
16
|
|
|
18
17
|
return {
|
|
19
|
-
iterate
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const next = deferred[++returned];
|
|
25
|
-
if (!next) return { value: null, done: true };
|
|
26
|
-
|
|
27
|
-
const value = await next.promise;
|
|
28
|
-
return { value: transform(value), done: false };
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
};
|
|
18
|
+
async *iterate(transform = (x) => x) {
|
|
19
|
+
// `deferred` can grow while we iterate, as resolved values may add further promises
|
|
20
|
+
for (let i = 0; i < deferred.length; i += 1) {
|
|
21
|
+
yield transform(await deferred[i].promise);
|
|
22
|
+
}
|
|
33
23
|
},
|
|
34
24
|
add: (promise) => {
|
|
35
25
|
const next = Promise.withResolvers();
|
package/src/utils/url.js
CHANGED
|
@@ -82,17 +82,6 @@ export function decode_pathname(pathname) {
|
|
|
82
82
|
return pathname.split('%25').map(decodeURI).join('%25');
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
/** @param {Record<string, string>} params */
|
|
86
|
-
export function decode_params(params) {
|
|
87
|
-
for (const key in params) {
|
|
88
|
-
// input has already been decoded by decodeURI
|
|
89
|
-
// now handle the rest
|
|
90
|
-
params[key] = decodeURIComponent(params[key]);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return params;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
85
|
/**
|
|
97
86
|
* The error when a URL is malformed is not very helpful, so we augment it with the URI
|
|
98
87
|
* @param {string} uri
|
package/src/version.js
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -150,7 +150,7 @@ declare module '@sveltejs/kit' {
|
|
|
150
150
|
|
|
151
151
|
/**
|
|
152
152
|
* Generate a server-side manifest to initialise the SvelteKit [server](https://svelte.dev/docs/kit/@sveltejs-kit#Server) with.
|
|
153
|
-
* @param opts.relativePath
|
|
153
|
+
* @param opts.relativePath A relative path to the base directory of the server build output
|
|
154
154
|
*/
|
|
155
155
|
generateManifest: (opts: { relativePath: string; routes?: RouteDefinition[] }) => string;
|
|
156
156
|
|
|
@@ -828,7 +828,7 @@ declare module '@sveltejs/kit' {
|
|
|
828
828
|
complete(entry: { generateManifest(opts: { relativePath: string }): string }): MaybePromise<void>;
|
|
829
829
|
}
|
|
830
830
|
|
|
831
|
-
type HttpMethod = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'OPTIONS';
|
|
831
|
+
type HttpMethod = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'OPTIONS' | 'QUERY';
|
|
832
832
|
|
|
833
833
|
interface Logger {
|
|
834
834
|
(msg: string): void;
|
|
@@ -1065,6 +1065,25 @@ declare module '@sveltejs/kit' {
|
|
|
1065
1065
|
export {};
|
|
1066
1066
|
}
|
|
1067
1067
|
|
|
1068
|
+
declare module '@sveltejs/kit/adapter' {
|
|
1069
|
+
/**
|
|
1070
|
+
* Helps a catch-all request handler pass the request to a different handler if
|
|
1071
|
+
* the `reroute` hook has returned a URL pathname that's different from the
|
|
1072
|
+
* incoming request.
|
|
1073
|
+
*
|
|
1074
|
+
* If your adapter is capable of deploying multiple serverless functions, it's a
|
|
1075
|
+
* good idea to also deploy a "catch-all" one to handle uncaught requests.
|
|
1076
|
+
* Running this in that function allows the app's `reroute` hook to rewrite
|
|
1077
|
+
* the request URL and invoke the next appropriate serverless function, if any.
|
|
1078
|
+
* @param response The response returned from the SvelteKit `server.respond` function
|
|
1079
|
+
* @param next Your platform-specific implementation for invoking the next handler with a different request URL
|
|
1080
|
+
* @since 3.0.0
|
|
1081
|
+
*/
|
|
1082
|
+
export function applyReroute(response: Response, next: (url: URL) => Response | Promise<Response>): Response | Promise<Response>;
|
|
1083
|
+
|
|
1084
|
+
export {};
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1068
1087
|
declare module '@sveltejs/kit/env' {
|
|
1069
1088
|
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
1070
1089
|
/**
|
|
@@ -1317,9 +1336,17 @@ declare module '@sveltejs/kit/hooks' {
|
|
|
1317
1336
|
* `<head>` tag; if `output.linkHeaderPreload` is enabled, dynamically rendered pages use the
|
|
1318
1337
|
* [`Link` response header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Link) instead.
|
|
1319
1338
|
* By default, `js` and `css` files will be preloaded.
|
|
1339
|
+
*
|
|
1340
|
+
* For `font` files, `input` also has a `filename` property, the source file's pathname relative
|
|
1341
|
+
* to the project root, so that a filter can match on it instead of the hashed path. `js` and
|
|
1342
|
+
* `css` files are bundled and have no single source file name.
|
|
1320
1343
|
* @param input the type of the file and its path
|
|
1321
1344
|
*/
|
|
1322
|
-
preload?: (
|
|
1345
|
+
preload?: (
|
|
1346
|
+
input:
|
|
1347
|
+
| { type: 'css' | 'js' | 'asset'; path: string }
|
|
1348
|
+
| { type: 'font'; path: string; filename: string }
|
|
1349
|
+
) => boolean;
|
|
1323
1350
|
}
|
|
1324
1351
|
|
|
1325
1352
|
type AppErrorWithOptionalDefaults = Omit<App.Error, 'status' | 'message'> & {
|
|
@@ -1418,8 +1445,9 @@ declare module '@sveltejs/kit/hooks' {
|
|
|
1418
1445
|
}
|
|
1419
1446
|
|
|
1420
1447
|
declare module '@sveltejs/kit/node' {
|
|
1421
|
-
export function getRequest({ request, base, bodySizeLimit }: {
|
|
1448
|
+
export function getRequest({ request, response, base, bodySizeLimit }: {
|
|
1422
1449
|
request: import("http").IncomingMessage;
|
|
1450
|
+
response?: import("http").ServerResponse;
|
|
1423
1451
|
base: string;
|
|
1424
1452
|
bodySizeLimit?: number;
|
|
1425
1453
|
}): Request;
|
|
@@ -2288,19 +2316,16 @@ declare module '@sveltejs/kit/vite' {
|
|
|
2288
2316
|
declare module '$app/env' {
|
|
2289
2317
|
/**
|
|
2290
2318
|
* `true` if the app is running in the browser.
|
|
2291
|
-
*/
|
|
2319
|
+
* */
|
|
2292
2320
|
export const browser: boolean;
|
|
2293
|
-
|
|
2294
2321
|
/**
|
|
2295
2322
|
* Whether the dev server is running. This is not guaranteed to correspond to `NODE_ENV` or `MODE`.
|
|
2296
|
-
*/
|
|
2323
|
+
* */
|
|
2297
2324
|
export const dev: boolean;
|
|
2298
|
-
|
|
2299
2325
|
/**
|
|
2300
2326
|
* SvelteKit analyses your app during the `build` step by running it. During this process, `building` is `true`. This also applies during prerendering.
|
|
2301
|
-
*/
|
|
2327
|
+
* */
|
|
2302
2328
|
export const building: boolean;
|
|
2303
|
-
|
|
2304
2329
|
/**
|
|
2305
2330
|
* The value of `config.version.name`.
|
|
2306
2331
|
*/
|
|
@@ -2310,25 +2335,6 @@ declare module '$app/env' {
|
|
|
2310
2335
|
}
|
|
2311
2336
|
|
|
2312
2337
|
declare module '$app/forms' {
|
|
2313
|
-
/**
|
|
2314
|
-
* Use this function to deserialize the response from a form submission.
|
|
2315
|
-
* Usage:
|
|
2316
|
-
*
|
|
2317
|
-
* ```js
|
|
2318
|
-
* import { deserialize } from '$app/forms';
|
|
2319
|
-
*
|
|
2320
|
-
* async function handleSubmit(event) {
|
|
2321
|
-
* const response = await fetch('/form?/action', {
|
|
2322
|
-
* method: 'POST',
|
|
2323
|
-
* body: new FormData(event.target)
|
|
2324
|
-
* });
|
|
2325
|
-
*
|
|
2326
|
-
* const result = deserialize(await response.text());
|
|
2327
|
-
* // ...
|
|
2328
|
-
* }
|
|
2329
|
-
* ```
|
|
2330
|
-
* */
|
|
2331
|
-
export function deserialize<Success extends Record<string, unknown> | undefined, Failure extends Record<string, unknown> | undefined>(result: string): ActionResult<Success, Failure>;
|
|
2332
2338
|
/**
|
|
2333
2339
|
* This action enhances a `<form>` element that otherwise would work without JavaScript.
|
|
2334
2340
|
*
|
|
@@ -2416,6 +2422,25 @@ declare module '$app/forms' {
|
|
|
2416
2422
|
* the redirect location.
|
|
2417
2423
|
* */
|
|
2418
2424
|
export function applyAction<Success extends Record<string, unknown> | undefined, Failure extends Record<string, unknown> | undefined>(result: ActionResult<Success, Failure>): Promise<void>;
|
|
2425
|
+
/**
|
|
2426
|
+
* Use this function to deserialize the response from a form submission.
|
|
2427
|
+
* Usage:
|
|
2428
|
+
*
|
|
2429
|
+
* ```js
|
|
2430
|
+
* import { deserialize } from '$app/forms';
|
|
2431
|
+
*
|
|
2432
|
+
* async function handleSubmit(event) {
|
|
2433
|
+
* const response = await fetch('/form?/action', {
|
|
2434
|
+
* method: 'POST',
|
|
2435
|
+
* body: new FormData(event.target)
|
|
2436
|
+
* });
|
|
2437
|
+
*
|
|
2438
|
+
* const result = deserialize(await response.text());
|
|
2439
|
+
* // ...
|
|
2440
|
+
* }
|
|
2441
|
+
* ```
|
|
2442
|
+
* */
|
|
2443
|
+
export function deserialize<Success extends Record<string, unknown> | undefined, Failure extends Record<string, unknown> | undefined>(result: string): ActionResult<Success, Failure>;
|
|
2419
2444
|
type MaybePromise<T> = T | Promise<T>;
|
|
2420
2445
|
|
|
2421
2446
|
export {};
|