@sveltejs/kit 3.0.0-next.22 → 3.0.0-next.23
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 +1 -5
- package/src/core/postbuild/prerender.js +19 -19
- package/src/exports/index.js +10 -0
- package/src/exports/public.d.ts +9 -0
- package/src/runtime/app/server/public.d.ts +512 -0
- package/src/runtime/app/server/remote/command.js +1 -1
- package/src/runtime/app/server/remote/form.js +5 -5
- package/src/runtime/app/server/remote/prerender.js +1 -1
- package/src/runtime/app/server/remote/query.js +1 -1
- package/src/runtime/app/server/remote/requested.js +3 -3
- package/src/runtime/client/remote-functions/command.svelte.js +1 -1
- package/src/runtime/client/remote-functions/form.svelte.js +1 -1
- package/src/runtime/client/remote-functions/prerender.svelte.js +1 -1
- package/src/runtime/client/remote-functions/query/index.js +1 -1
- package/src/runtime/client/remote-functions/query/instance.svelte.js +2 -1
- package/src/runtime/client/remote-functions/query-batch.svelte.js +1 -1
- package/src/runtime/client/remote-functions/query-live/index.js +1 -1
- package/src/runtime/client/remote-functions/query-live/instance.svelte.js +4 -3
- package/src/runtime/client/remote-functions/shared.svelte.js +1 -1
- package/src/runtime/server/remote-functions.js +1 -1
- package/src/types/internal.d.ts +1 -1
- package/src/utils/promise.js +25 -0
- package/src/version.js +1 -1
- package/types/index.d.ts +1100 -1108
- package/types/index.d.ts.map +45 -47
- package/src/exports/remote/index.js +0 -11
- package/src/exports/remote/public.d.ts +0 -519
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @import { RemoteFormInput, RemoteForm,
|
|
1
|
+
/** @import { RemoteFormInput, RemoteForm, RemoteFormInvalidField } from '$app/server' */
|
|
2
2
|
/** @import { InternalRemoteFormIssue, MaybePromise, HasNonOptionalBoolean, RemoteFormInternals } from 'types' */
|
|
3
3
|
/** @import { StandardSchemaV1 } from '@standard-schema/spec' */
|
|
4
4
|
import { get_request_store } from '@sveltejs/kit/internal/server';
|
|
@@ -33,7 +33,7 @@ import { ValidationError } from '@sveltejs/kit/internal';
|
|
|
33
33
|
* @template Output
|
|
34
34
|
* @overload
|
|
35
35
|
* @param {'unchecked'} validate
|
|
36
|
-
* @param {(data: Input, issue:
|
|
36
|
+
* @param {(data: Input, issue: RemoteFormInvalidField<Input>) => MaybePromise<Output>} fn
|
|
37
37
|
* @returns {RemoteForm<Input, Output>}
|
|
38
38
|
* @since 2.27
|
|
39
39
|
*/
|
|
@@ -46,7 +46,7 @@ import { ValidationError } from '@sveltejs/kit/internal';
|
|
|
46
46
|
* @template Output
|
|
47
47
|
* @overload
|
|
48
48
|
* @param {true extends HasNonOptionalBoolean<StandardSchemaV1.InferInput<Schema>> ? 'Error: All booleans in form schemas must be optional (e.g. `v.optional(v.boolean(), false)`) because checkbox inputs do not send a false value when unchecked.' : Schema} validate
|
|
49
|
-
* @param {(data: StandardSchemaV1.InferOutput<Schema>, issue:
|
|
49
|
+
* @param {(data: StandardSchemaV1.InferOutput<Schema>, issue: RemoteFormInvalidField<StandardSchemaV1.InferInput<Schema>>) => MaybePromise<Output>} fn
|
|
50
50
|
* @returns {RemoteForm<StandardSchemaV1.InferInput<Schema>, Output>}
|
|
51
51
|
* @since 2.27
|
|
52
52
|
*/
|
|
@@ -293,10 +293,10 @@ function handle_issues(output, issues, form_data, form_id) {
|
|
|
293
293
|
|
|
294
294
|
/**
|
|
295
295
|
* Creates an invalid function that can be used to imperatively mark form fields as invalid
|
|
296
|
-
* @returns {
|
|
296
|
+
* @returns {RemoteFormInvalidField<any>}
|
|
297
297
|
*/
|
|
298
298
|
function create_issues() {
|
|
299
|
-
return /** @type {
|
|
299
|
+
return /** @type {RemoteFormInvalidField<any>} */ (
|
|
300
300
|
new Proxy(
|
|
301
301
|
/** @param {string} message */
|
|
302
302
|
(message) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @import { RemoteResource, RemotePrerenderFunction } from '
|
|
1
|
+
/** @import { RemoteResource, RemotePrerenderFunction } from '$app/server' */
|
|
2
2
|
/** @import { RemoteFunctionResponse, RemotePrerenderInputsGenerator, RemotePrerenderInternals, MaybePromise } from 'types' */
|
|
3
3
|
/** @import { StandardSchemaV1 } from '@standard-schema/spec' */
|
|
4
4
|
import { json } from '@sveltejs/kit';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @import { RemoteLiveQuery, RemoteLiveQueryFunction, RemoteQuery, RemoteQueryFunction } from '
|
|
1
|
+
/** @import { RemoteLiveQuery, RemoteLiveQueryFunction, RemoteQuery, RemoteQueryFunction } from '$app/server' */
|
|
2
2
|
/** @import { RequestEvent } from '@sveltejs/kit' */
|
|
3
3
|
/** @import { RemoteInternals, MaybePromise, RequestState, RemoteQueryLiveInternals, RemoteQueryBatchInternals, RemoteQueryInternals, RemoteLiveQueryUserFunctionReturnType } from 'types' */
|
|
4
4
|
/** @import { StandardSchemaV1 } from '@standard-schema/spec' */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @import { RemoteLiveQuery, RemoteLiveQueryFunction, RemoteQuery, RemoteQueryFunction, RequestedResult,
|
|
1
|
+
/** @import { RemoteLiveQuery, RemoteLiveQueryFunction, RemoteQuery, RemoteQueryFunction, RequestedResult, RemoteQueryRequestedResult, RemoteLiveQueryRequestedResult } from '$app/server' */
|
|
2
2
|
/** @import { MaybePromise, RemoteAnyQueryInternals } from 'types' */
|
|
3
3
|
import { HttpError } from '@sveltejs/kit/internal';
|
|
4
4
|
import { get_request_store } from '@sveltejs/kit/internal/server';
|
|
@@ -53,7 +53,7 @@ import { refresh } from './query.js';
|
|
|
53
53
|
* @overload
|
|
54
54
|
* @param {RemoteQueryFunction<Input, Output, Validated>} query
|
|
55
55
|
* @param {number} limit
|
|
56
|
-
* @returns {
|
|
56
|
+
* @returns {RemoteQueryRequestedResult<Validated, Output>}
|
|
57
57
|
*/
|
|
58
58
|
/**
|
|
59
59
|
* Inside a remote `command` or `form` callback, returns an iterable
|
|
@@ -91,7 +91,7 @@ import { refresh } from './query.js';
|
|
|
91
91
|
* @overload
|
|
92
92
|
* @param {RemoteLiveQueryFunction<Input, Output, Validated>} query
|
|
93
93
|
* @param {number} limit
|
|
94
|
-
* @returns {
|
|
94
|
+
* @returns {RemoteLiveQueryRequestedResult<Validated, Output>}
|
|
95
95
|
*/
|
|
96
96
|
/**
|
|
97
97
|
* @template Input
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @import { RemoteCommand, RemoteQueryUpdate } from '
|
|
1
|
+
/** @import { RemoteCommand, RemoteQueryUpdate } from '$app/server' */
|
|
2
2
|
import { app_dir, base } from '#app/paths';
|
|
3
3
|
import { stringify_command_arg } from '../../shared.js';
|
|
4
4
|
import { get_remote_request_headers, categorize_updates, remote_request } from './shared.svelte.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** @import { StandardSchemaV1 } from '@standard-schema/spec' */
|
|
2
|
-
/** @import { RemoteFormInput, RemoteForm, RemoteQueryUpdate } from '
|
|
2
|
+
/** @import { RemoteFormInput, RemoteForm, RemoteQueryUpdate } from '$app/server' */
|
|
3
3
|
/** @import { InternalRemoteFormIssue } from 'types' */
|
|
4
4
|
import { app_dir, base } from '#app/paths';
|
|
5
5
|
import { DEV } from 'esm-env';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @import { RemoteQueryFunction } from '
|
|
1
|
+
/** @import { RemoteQueryFunction } from '$app/server' */
|
|
2
2
|
import { app_dir, base } from '#app/paths';
|
|
3
3
|
import { _goto, query_map } from '../../client.js';
|
|
4
4
|
import { QUERY_FUNCTION_ID, remote_request } from '../shared.svelte.js';
|
|
@@ -3,6 +3,7 @@ import { query_responses, handle_error } from '../../client.js';
|
|
|
3
3
|
import { HandledHttpError } from '@sveltejs/kit/internal';
|
|
4
4
|
import { QUERY_OVERRIDE_KEY } from '../shared.svelte.js';
|
|
5
5
|
import { noop } from '../../../../utils/functions.js';
|
|
6
|
+
import { with_resolvers } from '../../../../utils/promise.js';
|
|
6
7
|
import { tick, untrack } from 'svelte';
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -101,7 +102,7 @@ export class Query {
|
|
|
101
102
|
#run() {
|
|
102
103
|
this.#loading = true;
|
|
103
104
|
|
|
104
|
-
const { promise, resolve, reject } =
|
|
105
|
+
const { promise, resolve, reject } = with_resolvers();
|
|
105
106
|
|
|
106
107
|
// the rejection is surfaced via `.error` / the `then` getter for awaiting
|
|
107
108
|
// consumers — a purely reactive consumer (`.current`) attaches no handler,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @import { RemoteQueryFunction } from '
|
|
1
|
+
/** @import { RemoteQueryFunction } from '$app/server' */
|
|
2
2
|
import { app_dir, base } from '#app/paths';
|
|
3
3
|
import { _goto } from '../client.js';
|
|
4
4
|
import { QUERY_FUNCTION_ID, remote_request } from './shared.svelte.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @import { RemoteLiveQuery, RemoteLiveQueryFunction } from '
|
|
1
|
+
/** @import { RemoteLiveQuery, RemoteLiveQueryFunction } from '$app/server' */
|
|
2
2
|
import { live_query_map } from '../../client.js';
|
|
3
3
|
import { QUERY_FUNCTION_ID } from '../shared.svelte.js';
|
|
4
4
|
import { DEV } from 'esm-env';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { query_responses, handle_error } from '../../client.js';
|
|
2
2
|
import { HttpError, Redirect, HandledHttpError } from '@sveltejs/kit/internal';
|
|
3
3
|
import { noop, once } from '../../../../utils/functions.js';
|
|
4
|
+
import { with_resolvers } from '../../../../utils/promise.js';
|
|
4
5
|
import { SharedIterator } from '../../../../utils/shared-iterator.js';
|
|
5
6
|
import { tick } from 'svelte';
|
|
6
7
|
import { create_live_iterator } from './iterator.js';
|
|
@@ -78,7 +79,7 @@ export class LiveQuery {
|
|
|
78
79
|
// the semantics of awaiting a live query are a bit weird, but it's basically:
|
|
79
80
|
// - It's a promise that resolves to the first value from the server
|
|
80
81
|
// - Thereafter, it's a promise that immediately resolves to the current value
|
|
81
|
-
const { promise, resolve, reject } =
|
|
82
|
+
const { promise, resolve, reject } = with_resolvers();
|
|
82
83
|
this.#promise = $state.raw(promise);
|
|
83
84
|
this.#resolve_first = resolve;
|
|
84
85
|
this.#reject_first = reject;
|
|
@@ -121,7 +122,7 @@ export class LiveQuery {
|
|
|
121
122
|
if (this.#interrupt) return;
|
|
122
123
|
|
|
123
124
|
/** @type {PromiseWithResolvers<void>} */
|
|
124
|
-
const { promise: stopped, resolve: on_stop } =
|
|
125
|
+
const { promise: stopped, resolve: on_stop } = with_resolvers();
|
|
125
126
|
let connected = false;
|
|
126
127
|
|
|
127
128
|
while (!this.#done) {
|
|
@@ -352,7 +353,7 @@ export class LiveQuery {
|
|
|
352
353
|
async reconnect() {
|
|
353
354
|
await this.#interrupt?.();
|
|
354
355
|
/** @type {PromiseWithResolvers<void>} */
|
|
355
|
-
const { promise, resolve: on_connect, reject: on_connect_failed } =
|
|
356
|
+
const { promise, resolve: on_connect, reject: on_connect_failed } = with_resolvers();
|
|
356
357
|
promise.catch(noop);
|
|
357
358
|
this.#done = false;
|
|
358
359
|
this.#attempt = 0;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** @import { RemoteFunctionResponse, RemoteFunctionData, RemoteFunctionDataNode } from 'types' */
|
|
2
|
-
/** @import { RemoteQueryUpdate } from '
|
|
2
|
+
/** @import { RemoteQueryUpdate } from '$app/server' */
|
|
3
3
|
/** @import { CacheEntry } from './cache.svelte.js' */
|
|
4
4
|
import * as devalue from 'devalue';
|
|
5
5
|
import { app, _goto, live_query_map, query_map, query_responses } from '../client.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** @import { RequestEvent, SSRManifest } from '@sveltejs/kit' */
|
|
2
|
-
/** @import { RemoteForm } from '
|
|
2
|
+
/** @import { RemoteForm } from '$app/server' */
|
|
3
3
|
/** @import { ActionResult } from '$app/forms' */
|
|
4
4
|
/** @import { RemoteFormInternals, RemoteFunctionData, RemoteFunctionResponse, RemoteInternals, RequestState, SSROptions } from 'types' */
|
|
5
5
|
|
package/src/types/internal.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
SSRManifest,
|
|
11
11
|
Emulator
|
|
12
12
|
} from '@sveltejs/kit';
|
|
13
|
-
import { RemoteFormIssue, RemoteQuery, RemoteLiveQuery } from '
|
|
13
|
+
import { RemoteFormIssue, RemoteQuery, RemoteLiveQuery } from '$app/server';
|
|
14
14
|
import { Config } from '@sveltejs/kit/vite';
|
|
15
15
|
import {
|
|
16
16
|
ClientInit,
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Replacement for `Promise.withResolvers()` that does not require the native
|
|
3
|
+
* static method, which only shipped in Safari 17.4 / Chrome 119 / Firefox 121.
|
|
4
|
+
*
|
|
5
|
+
* The client remote-function runtime is bundled and shipped to browsers verbatim
|
|
6
|
+
* (Vite 8's default build target is Safari 16.4 / Chrome 111) and is not
|
|
7
|
+
* polyfilled, so it must not assume `Promise.withResolvers` exists. The
|
|
8
|
+
* server-side and build-time call sites run on Node 22+ and keep using the
|
|
9
|
+
* native method.
|
|
10
|
+
*
|
|
11
|
+
* @template T
|
|
12
|
+
* @returns {PromiseWithResolvers<T>}
|
|
13
|
+
*/
|
|
14
|
+
export function with_resolvers() {
|
|
15
|
+
let resolve;
|
|
16
|
+
let reject;
|
|
17
|
+
|
|
18
|
+
const promise = new Promise((res, rej) => {
|
|
19
|
+
resolve = res;
|
|
20
|
+
reject = rej;
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// @ts-expect-error `resolve` and `reject` are assigned!
|
|
24
|
+
return { promise, resolve, reject };
|
|
25
|
+
}
|
package/src/version.js
CHANGED