@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.
@@ -1,4 +1,4 @@
1
- /** @import { RemoteFormInput, RemoteForm, InvalidField } from '@sveltejs/kit/remote' */
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: InvalidField<Input>) => MaybePromise<Output>} fn
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: InvalidField<StandardSchemaV1.InferInput<Schema>>) => MaybePromise<Output>} fn
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 {InvalidField<any>}
296
+ * @returns {RemoteFormInvalidField<any>}
297
297
  */
298
298
  function create_issues() {
299
- return /** @type {InvalidField<any>} */ (
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 '@sveltejs/kit/remote' */
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 '@sveltejs/kit/remote' */
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, QueryRequestedResult, LiveQueryRequestedResult } from '@sveltejs/kit/remote' */
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 {QueryRequestedResult<Validated, Output>}
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 {LiveQueryRequestedResult<Validated, Output>}
94
+ * @returns {RemoteLiveQueryRequestedResult<Validated, Output>}
95
95
  */
96
96
  /**
97
97
  * @template Input
@@ -1,4 +1,4 @@
1
- /** @import { RemoteCommand, RemoteQueryUpdate } from '@sveltejs/kit/remote' */
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 '@sveltejs/kit/remote' */
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 { RemotePrerenderFunction } from '@sveltejs/kit/remote' */
1
+ /** @import { RemotePrerenderFunction } from '$app/server' */
2
2
  import { app_dir, base } from '#app/paths';
3
3
  import { version } from '$app/env';
4
4
  import * as devalue from 'devalue';
@@ -1,4 +1,4 @@
1
- /** @import { RemoteQueryFunction } from '@sveltejs/kit/remote' */
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 } = Promise.withResolvers();
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 '@sveltejs/kit/remote' */
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 '@sveltejs/kit/remote' */
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 } = Promise.withResolvers();
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 } = Promise.withResolvers();
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 } = Promise.withResolvers();
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 '@sveltejs/kit/remote' */
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 '@sveltejs/kit/remote' */
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
 
@@ -10,7 +10,7 @@ import {
10
10
  SSRManifest,
11
11
  Emulator
12
12
  } from '@sveltejs/kit';
13
- import { RemoteFormIssue, RemoteQuery, RemoteLiveQuery } from '@sveltejs/kit/remote';
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
@@ -1,4 +1,4 @@
1
1
  // generated during release, do not modify
2
2
 
3
3
  /** @type {string} */
4
- export const VERSION = '3.0.0-next.22';
4
+ export const VERSION = '3.0.0-next.23';