svelte-effect-runtime 4.2.3 → 4.2.6
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/.dist/chunks/{client-D-u6MNHj.js → client-Bi7SwVVy.js} +24 -14
- package/.dist/chunks/client-Bi7SwVVy.js.map +1 -0
- package/.dist/chunks/{compiler-Dpyu4Owd.js → compiler-B2htZszc.js} +8 -5
- package/.dist/chunks/{compiler-Dpyu4Owd.js.map → compiler-B2htZszc.js.map} +1 -1
- package/.dist/chunks/{dispatcher-B75hLhx3.js → dispatcher-BFTvQ7sm.js} +3 -3
- package/.dist/chunks/{dispatcher-B75hLhx3.js.map → dispatcher-BFTvQ7sm.js.map} +1 -1
- package/.dist/chunks/{dispatcher-DGSStOLQ.js → dispatcher-D3Tpa5HC.js} +24 -16
- package/.dist/chunks/dispatcher-D3Tpa5HC.js.map +1 -0
- package/.dist/chunks/{remote-client-mkQAfP1G.js → remote-client-C_3kdug0.js} +15 -4
- package/.dist/chunks/remote-client-C_3kdug0.js.map +1 -0
- package/.dist/chunks/{runtime-D4a2CqmT.js → runtime-CmiEHnSw.js} +2 -2
- package/.dist/chunks/{runtime-D4a2CqmT.js.map → runtime-CmiEHnSw.js.map} +1 -1
- package/.dist/chunks/{server-BNxq-pUH.js → server-Dxb9zr99.js} +16 -3
- package/.dist/chunks/server-Dxb9zr99.js.map +1 -0
- package/.dist/compiler/remote-client.d.ts +1 -0
- package/.dist/compiler.js +1 -1
- package/.dist/dispatcher/index.d.ts +4 -4
- package/.dist/dispatcher/scope.d.ts +10 -1
- package/.dist/dispatcher.js +1 -1
- package/.dist/environment.d.ts +9 -3
- package/.dist/environment.js.map +1 -1
- package/.dist/internal/generators.js +2 -2
- package/.dist/internal/remote-client.js +1 -1
- package/.dist/internal/remote-server.js +1 -1
- package/.dist/markup/promise.js +1 -1
- package/.dist/markup/run.js +1 -1
- package/.dist/markup/value.js +1 -1
- package/.dist/mod.js +2 -2
- package/.dist/remote/client/form-data.d.ts +8 -1
- package/.dist/remote/client/form.d.ts +2 -2
- package/.dist/remote/client/types.d.ts +10 -11
- package/.dist/remote/client.js +1 -1
- package/.dist/remote/native-types.d.ts +292 -0
- package/.dist/remote/server.js +1 -1
- package/.dist/server/factories.d.ts +4 -4
- package/.dist/server/live-snapshot.d.ts +2 -2
- package/.dist/server/types.d.ts +7 -7
- package/.dist/server.js +4 -4
- package/.dist/server.js.map +1 -1
- package/package.json +2 -2
- package/.dist/chunks/client-D-u6MNHj.js.map +0 -1
- package/.dist/chunks/dispatcher-DGSStOLQ.js.map +0 -1
- package/.dist/chunks/remote-client-mkQAfP1G.js.map +0 -1
- package/.dist/chunks/server-BNxq-pUH.js.map +0 -1
package/.dist/remote/client.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as create_remote_command_adapter, i as create_remote_form_adapter, n as create_remote_query_adapter, r as create_remote_prerender_adapter, t as create_remote_live_query_adapter } from "../chunks/client-
|
|
1
|
+
import { a as create_remote_command_adapter, i as create_remote_form_adapter, n as create_remote_query_adapter, r as create_remote_prerender_adapter, t as create_remote_live_query_adapter } from "../chunks/client-Bi7SwVVy.js";
|
|
2
2
|
export { create_remote_command_adapter, create_remote_form_adapter, create_remote_live_query_adapter, create_remote_prerender_adapter, create_remote_query_adapter };
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
import type { StandardSchemaV1 } from "@sveltejs/kit/internal/types";
|
|
2
|
+
/**
|
|
3
|
+
* SvelteKit moved its remote-function types between majors: SvelteKit 2
|
|
4
|
+
* declares them in `@sveltejs/kit`, while SvelteKit 3 (since `3.0.0-next.20`)
|
|
5
|
+
* declares them only in the `$app/server` ambient module, which SvelteKit 2
|
|
6
|
+
* does not re-export types from. Importing from either location therefore
|
|
7
|
+
* breaks the other major, and the shapes cannot be derived from the
|
|
8
|
+
* `$app/server` value exports because their overload sets share a type-arity
|
|
9
|
+
* with incompatible constraints. This module vendors the surface SER needs.
|
|
10
|
+
* The shapes are identical in SvelteKit 2.69+ and 3.0.0-next.25 except
|
|
11
|
+
* `validate`, whose options here form the superset of both majors.
|
|
12
|
+
*/
|
|
13
|
+
type MaybeArray<T> = T | T[];
|
|
14
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
15
|
+
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
16
|
+
type DeepPartial<T> = T extends Record<PropertyKey, unknown> | unknown[] ? {
|
|
17
|
+
[K in keyof T]?: T[K] extends Record<PropertyKey, unknown> | unknown[] ? DeepPartial<T[K]> : T[K];
|
|
18
|
+
} : T | undefined;
|
|
19
|
+
type WillRecurseIndefinitely<T> = unknown extends T ? true : string extends keyof T ? true : false;
|
|
20
|
+
type KeysOfUnion<T> = T extends unknown ? keyof T : never;
|
|
21
|
+
type ValueOfUnionKey<T, K extends PropertyKey> = T extends unknown ? K extends keyof T ? T[K] : never : never;
|
|
22
|
+
/**
|
|
23
|
+
* Data shape SvelteKit accepts for a remote form submission. Mirrors
|
|
24
|
+
* SvelteKit's `RemoteFormInput`.
|
|
25
|
+
*
|
|
26
|
+
* @since 4.2.6
|
|
27
|
+
*/
|
|
28
|
+
export interface NativeRemoteFormInput {
|
|
29
|
+
[key: string]: MaybeArray<string | number | boolean | File | NativeRemoteFormInput> | undefined;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A single validation issue reported for a remote form field. Mirrors
|
|
33
|
+
* SvelteKit's `RemoteFormIssue`.
|
|
34
|
+
*
|
|
35
|
+
* @since 4.2.6
|
|
36
|
+
*/
|
|
37
|
+
export interface NativeRemoteFormIssue {
|
|
38
|
+
message: string;
|
|
39
|
+
path: Array<string | number>;
|
|
40
|
+
}
|
|
41
|
+
type InputTypeMap = {
|
|
42
|
+
text: string;
|
|
43
|
+
email: string;
|
|
44
|
+
password: string;
|
|
45
|
+
url: string;
|
|
46
|
+
tel: string;
|
|
47
|
+
search: string;
|
|
48
|
+
number: number;
|
|
49
|
+
range: number;
|
|
50
|
+
date: string;
|
|
51
|
+
"datetime-local": string;
|
|
52
|
+
time: string;
|
|
53
|
+
month: string;
|
|
54
|
+
week: string;
|
|
55
|
+
color: string;
|
|
56
|
+
checkbox: boolean | string[];
|
|
57
|
+
radio: string;
|
|
58
|
+
file: File;
|
|
59
|
+
hidden: string | number | boolean;
|
|
60
|
+
submit: string | number | boolean;
|
|
61
|
+
button: string;
|
|
62
|
+
reset: string;
|
|
63
|
+
image: string;
|
|
64
|
+
select: string;
|
|
65
|
+
"select multiple": string[];
|
|
66
|
+
"file multiple": File[];
|
|
67
|
+
};
|
|
68
|
+
type NativeRemoteFormFieldType<T> = {
|
|
69
|
+
[K in keyof InputTypeMap]: T extends InputTypeMap[K] ? K : never;
|
|
70
|
+
}[keyof InputTypeMap];
|
|
71
|
+
type InputElementProps<T extends keyof InputTypeMap> = T extends "checkbox" | "radio" ? {
|
|
72
|
+
name: string;
|
|
73
|
+
type: T;
|
|
74
|
+
value?: string;
|
|
75
|
+
"aria-invalid": boolean | "false" | "true" | undefined;
|
|
76
|
+
get checked(): boolean;
|
|
77
|
+
set checked(value: boolean);
|
|
78
|
+
readonly defaultChecked?: boolean;
|
|
79
|
+
} : T extends "file" ? {
|
|
80
|
+
name: string;
|
|
81
|
+
type: "file";
|
|
82
|
+
"aria-invalid": boolean | "false" | "true" | undefined;
|
|
83
|
+
get files(): FileList | null;
|
|
84
|
+
set files(v: FileList | null);
|
|
85
|
+
} : T extends "select" ? {
|
|
86
|
+
name: string;
|
|
87
|
+
"aria-invalid": boolean | "false" | "true" | undefined;
|
|
88
|
+
get value(): string;
|
|
89
|
+
set value(v: string);
|
|
90
|
+
} : T extends "select multiple" ? {
|
|
91
|
+
name: string;
|
|
92
|
+
multiple: true;
|
|
93
|
+
"aria-invalid": boolean | "false" | "true" | undefined;
|
|
94
|
+
get value(): string[];
|
|
95
|
+
set value(v: string[]);
|
|
96
|
+
} : T extends "text" ? {
|
|
97
|
+
name: string;
|
|
98
|
+
"aria-invalid": boolean | "false" | "true" | undefined;
|
|
99
|
+
get value(): string | number;
|
|
100
|
+
set value(v: string | number);
|
|
101
|
+
readonly defaultValue?: string | number;
|
|
102
|
+
} : {
|
|
103
|
+
name: string;
|
|
104
|
+
type: T;
|
|
105
|
+
"aria-invalid": boolean | "false" | "true" | undefined;
|
|
106
|
+
get value(): string | number;
|
|
107
|
+
set value(v: string | number);
|
|
108
|
+
readonly defaultValue?: string | number;
|
|
109
|
+
};
|
|
110
|
+
type NativeRemoteFormFieldMethods<T> = {
|
|
111
|
+
/** The values that will be submitted. */
|
|
112
|
+
value(): DeepPartial<T>;
|
|
113
|
+
/** Set the values that will be submitted. */
|
|
114
|
+
set(input: DeepPartial<T>): DeepPartial<T>;
|
|
115
|
+
/** Whether the field or any nested field has been interacted with since the form was mounted. */
|
|
116
|
+
touched(): boolean;
|
|
117
|
+
/** Whether the field or any nested field has been edited since the form was mounted. */
|
|
118
|
+
dirty(): boolean;
|
|
119
|
+
/** Validation issues, if any. */
|
|
120
|
+
issues(): NativeRemoteFormIssue[] | undefined;
|
|
121
|
+
};
|
|
122
|
+
type AsArgs<Type extends keyof InputTypeMap, Value> = Type extends "checkbox" ? Value extends string[] ? [type: Type, value: Value[number] | (string & {})] : Value extends boolean ? [type: Type] | [type: Type, value: boolean] : [type: Type] | [type: Type, value: Value | (string & {})] : Type extends "submit" | "hidden" ? Value extends string ? [type: Type, value: Value | (string & {})] : [type: Type, value: Value] : Type extends "radio" ? [type: Type, value: Value | (string & {})] : Type extends "file" | "file multiple" ? [type: Type] : [type: Type] | [type: Type, value: Value | undefined];
|
|
123
|
+
type NativeRemoteFormFieldValue = string | string[] | number | boolean | File | File[];
|
|
124
|
+
type NativeRemoteFormField<Value extends NativeRemoteFormFieldValue> = NativeRemoteFormFieldMethods<Value> & {
|
|
125
|
+
/** Returns spreadable input-element props for the given input type. */
|
|
126
|
+
as<T extends NativeRemoteFormFieldType<Value>>(...args: AsArgs<T, Value>): InputElementProps<T>;
|
|
127
|
+
};
|
|
128
|
+
type NativeRemoteFormFieldContainer<Value> = NativeRemoteFormFieldMethods<Value> & {
|
|
129
|
+
/** Validation issues belonging to this or any of the fields that belong to it, if any. */
|
|
130
|
+
allIssues(): NativeRemoteFormIssue[] | undefined;
|
|
131
|
+
};
|
|
132
|
+
type UnknownField<Value> = NativeRemoteFormFieldMethods<Value> & {
|
|
133
|
+
/** Validation issues belonging to this or any of the fields that belong to it, if any. */
|
|
134
|
+
allIssues(): NativeRemoteFormIssue[] | undefined;
|
|
135
|
+
/** Returns spreadable input-element props for the given input type. */
|
|
136
|
+
as<T extends NativeRemoteFormFieldType<Value>>(...args: AsArgs<T, Value>): InputElementProps<T>;
|
|
137
|
+
} & {
|
|
138
|
+
[key: string | number]: UnknownField<any>;
|
|
139
|
+
};
|
|
140
|
+
type RecursiveFormFields = NativeRemoteFormFieldContainer<any> & {
|
|
141
|
+
[key: string | number]: UnknownField<any>;
|
|
142
|
+
};
|
|
143
|
+
type NativeRemoteFormFields<T> = WillRecurseIndefinitely<T> extends true ? RecursiveFormFields : NonNullable<T> extends string | number | boolean | File ? NativeRemoteFormField<Extract<NonNullable<T>, NativeRemoteFormFieldValue>> : [NonNullable<T>] extends [string[] | File[]] ? NativeRemoteFormField<Extract<NonNullable<T>, NativeRemoteFormFieldValue>> & {
|
|
144
|
+
[K in number]: NativeRemoteFormField<Extract<NonNullable<T>[number], NativeRemoteFormFieldValue>>;
|
|
145
|
+
} : [NonNullable<T>] extends [Array<infer U>] ? NativeRemoteFormFieldContainer<NonNullable<T>> & {
|
|
146
|
+
[K in number]: NativeRemoteFormFields<U>;
|
|
147
|
+
} : NativeRemoteFormFieldContainer<T> & {
|
|
148
|
+
[K in KeysOfUnion<T>]-?: NativeRemoteFormFields<ValueOfUnionKey<T, K>>;
|
|
149
|
+
};
|
|
150
|
+
type NativeRemoteFormFieldsRoot<Input extends NativeRemoteFormInput | void> = IsAny<Input> extends true ? RecursiveFormFields : Input extends void ? {
|
|
151
|
+
/** Validation issues, if any. */
|
|
152
|
+
issues(): NativeRemoteFormIssue[] | undefined;
|
|
153
|
+
/** Validation issues belonging to this or any of the fields that belong to it, if any. */
|
|
154
|
+
allIssues(): NativeRemoteFormIssue[] | undefined;
|
|
155
|
+
} : NativeRemoteFormFields<Input>;
|
|
156
|
+
type ExtractId<Input> = Input extends {
|
|
157
|
+
id: infer Id;
|
|
158
|
+
} ? Id extends string | number ? Id : string | number : string | number;
|
|
159
|
+
/**
|
|
160
|
+
* The form instance received inside an `enhance` callback. Mirrors SvelteKit's
|
|
161
|
+
* `RemoteFormEnhanceInstance`.
|
|
162
|
+
*
|
|
163
|
+
* @since 4.2.6
|
|
164
|
+
*/
|
|
165
|
+
export type NativeRemoteFormEnhanceInstance<Input extends NativeRemoteFormInput | void = NativeRemoteFormInput | void, Output = unknown> = Omit<NativeRemoteForm<Input, Output>, "enhance" | "element"> & {
|
|
166
|
+
readonly element: HTMLFormElement;
|
|
167
|
+
};
|
|
168
|
+
/**
|
|
169
|
+
* The callback passed to a remote form's `enhance` method. Mirrors SvelteKit's
|
|
170
|
+
* `RemoteFormEnhanceCallback`.
|
|
171
|
+
*
|
|
172
|
+
* @since 4.2.6
|
|
173
|
+
*/
|
|
174
|
+
export type NativeRemoteFormEnhanceCallback<Input extends NativeRemoteFormInput | void = NativeRemoteFormInput | void, Output = unknown> = (form: NativeRemoteFormEnhanceInstance<Input, Output>) => MaybePromise<void>;
|
|
175
|
+
/**
|
|
176
|
+
* SvelteKit's `RemoteForm` surface. `validate` accepts the superset of the
|
|
177
|
+
* SvelteKit 2 (`includeUntouched`) and SvelteKit 3 (`all`) options.
|
|
178
|
+
*
|
|
179
|
+
* @since 4.2.6
|
|
180
|
+
*/
|
|
181
|
+
export type NativeRemoteForm<Input extends NativeRemoteFormInput | void, Output> = {
|
|
182
|
+
/** Attachment that intercepts the form submission on the client to prevent a full page reload. */
|
|
183
|
+
[attachment: symbol]: (node: HTMLFormElement) => void;
|
|
184
|
+
method: "POST";
|
|
185
|
+
/** The URL to send the form to. */
|
|
186
|
+
action: string;
|
|
187
|
+
/** The `<form>` element this instance is currently attached to, if any. */
|
|
188
|
+
get element(): HTMLFormElement | null;
|
|
189
|
+
/** Submit the currently attached form programmatically. */
|
|
190
|
+
submit(): Promise<boolean> & {
|
|
191
|
+
updates: (...updates: NativeRemoteQueryUpdate[]) => Promise<boolean>;
|
|
192
|
+
};
|
|
193
|
+
/** Influences what happens when the form is submitted. */
|
|
194
|
+
enhance(callback: NativeRemoteFormEnhanceCallback<Input, Output>): {
|
|
195
|
+
method: "POST";
|
|
196
|
+
action: string;
|
|
197
|
+
[attachment: symbol]: (node: HTMLFormElement) => void;
|
|
198
|
+
};
|
|
199
|
+
/** Create an instance of the form for the given `id`. */
|
|
200
|
+
for(id: ExtractId<Input>): Omit<NativeRemoteForm<Input, Output>, "for">;
|
|
201
|
+
/** Preflight checks. */
|
|
202
|
+
preflight(schema: StandardSchemaV1<Input, unknown>): NativeRemoteForm<Input, Output>;
|
|
203
|
+
/** Validate the form contents programmatically. */
|
|
204
|
+
validate(options?: {
|
|
205
|
+
/** SvelteKit 3: also show validation issues of fields that have not been edited and blurred yet. */
|
|
206
|
+
all?: boolean;
|
|
207
|
+
/** SvelteKit 2: also show validation issues of fields that have not been touched yet. */
|
|
208
|
+
includeUntouched?: boolean;
|
|
209
|
+
/** Only run the `preflight` validation. */
|
|
210
|
+
preflightOnly?: boolean;
|
|
211
|
+
}): Promise<void>;
|
|
212
|
+
/** The result of the form submission. */
|
|
213
|
+
get result(): Output | undefined;
|
|
214
|
+
/** The number of pending submissions. */
|
|
215
|
+
get pending(): number;
|
|
216
|
+
/** True if the form has been submitted at least once. */
|
|
217
|
+
get submitted(): boolean;
|
|
218
|
+
/** Access form fields using object notation. */
|
|
219
|
+
fields: NativeRemoteFormFieldsRoot<Input>;
|
|
220
|
+
};
|
|
221
|
+
/**
|
|
222
|
+
* SvelteKit's `RemoteResource` shape shared by query, live query, and
|
|
223
|
+
* prerender resources.
|
|
224
|
+
*
|
|
225
|
+
* @since 4.2.6
|
|
226
|
+
*/
|
|
227
|
+
export type NativeRemoteResource<T> = Promise<T> & {
|
|
228
|
+
/** The error in case the query fails. */
|
|
229
|
+
get error(): unknown;
|
|
230
|
+
/** `true` before the first result is available and during refreshes. */
|
|
231
|
+
get loading(): boolean;
|
|
232
|
+
} & ({
|
|
233
|
+
/** The current value of the query. Undefined until `ready` is `true`. */
|
|
234
|
+
get current(): undefined;
|
|
235
|
+
ready: false;
|
|
236
|
+
} | {
|
|
237
|
+
/** The current value of the query. Undefined until `ready` is `true`. */
|
|
238
|
+
get current(): T;
|
|
239
|
+
ready: true;
|
|
240
|
+
});
|
|
241
|
+
/**
|
|
242
|
+
* SvelteKit's `RemoteQuery` resource surface.
|
|
243
|
+
*
|
|
244
|
+
* @since 4.2.6
|
|
245
|
+
*/
|
|
246
|
+
export type NativeRemoteQuery<T> = NativeRemoteResource<T> & {
|
|
247
|
+
/** Update the value of the query without re-fetching it. */
|
|
248
|
+
set(value: T): void;
|
|
249
|
+
/** Re-fetch the query from the server. */
|
|
250
|
+
refresh(): Promise<void>;
|
|
251
|
+
/** Temporarily override a query's value during a single-flight mutation. */
|
|
252
|
+
withOverride(update: (current: T) => T): NativeRemoteQueryOverride;
|
|
253
|
+
};
|
|
254
|
+
/**
|
|
255
|
+
* SvelteKit's `RemoteLiveQuery` resource surface.
|
|
256
|
+
*
|
|
257
|
+
* @since 4.2.6
|
|
258
|
+
*/
|
|
259
|
+
export type NativeRemoteLiveQuery<T> = NativeRemoteResource<T> & AsyncIterable<T> & {
|
|
260
|
+
/** `true` if the live stream is currently connected. */
|
|
261
|
+
readonly connected: boolean;
|
|
262
|
+
/** `true` once the current live stream iterator is done. */
|
|
263
|
+
readonly done: boolean;
|
|
264
|
+
/** Reconnects the live stream immediately. */
|
|
265
|
+
reconnect(): Promise<void>;
|
|
266
|
+
};
|
|
267
|
+
/**
|
|
268
|
+
* SvelteKit's `RemoteQueryFunction`.
|
|
269
|
+
*
|
|
270
|
+
* @since 4.2.6
|
|
271
|
+
*/
|
|
272
|
+
export type NativeRemoteQueryFunction<Input, Output, _Validated = Input> = (arg: undefined extends Input ? Input | void : Input) => NativeRemoteQuery<Output>;
|
|
273
|
+
/**
|
|
274
|
+
* SvelteKit's `RemoteLiveQueryFunction`.
|
|
275
|
+
*
|
|
276
|
+
* @since 4.2.6
|
|
277
|
+
*/
|
|
278
|
+
export type NativeRemoteLiveQueryFunction<Input, Output, _Validated = Input> = (arg: undefined extends Input ? Input | void : Input) => NativeRemoteLiveQuery<Output>;
|
|
279
|
+
/**
|
|
280
|
+
* SvelteKit's `RemoteQueryOverride`.
|
|
281
|
+
*
|
|
282
|
+
* @since 4.2.6
|
|
283
|
+
*/
|
|
284
|
+
export type NativeRemoteQueryOverride = () => void;
|
|
285
|
+
/**
|
|
286
|
+
* Update selection accepted by SvelteKit's command and form `updates(...)`
|
|
287
|
+
* methods. Mirrors SvelteKit's `RemoteQueryUpdate`.
|
|
288
|
+
*
|
|
289
|
+
* @since 4.2.6
|
|
290
|
+
*/
|
|
291
|
+
export type NativeRemoteQueryUpdate = NativeRemoteQuery<any> | NativeRemoteLiveQuery<any> | NativeRemoteQueryFunction<any, any> | NativeRemoteLiveQueryFunction<any, any> | NativeRemoteQueryOverride;
|
|
292
|
+
export {};
|
package/.dist/remote/server.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as to_remote_failure_context, i as throw_remote_cause, n as run_remote_effect, o as encode_remote_failure, r as throw_form_error, t as normalize_remote_helper_error } from "../chunks/server-
|
|
1
|
+
import { a as to_remote_failure_context, i as throw_remote_cause, n as run_remote_effect, o as encode_remote_failure, r as throw_form_error, t as normalize_remote_helper_error } from "../chunks/server-Dxb9zr99.js";
|
|
2
2
|
export { encode_remote_failure, normalize_remote_helper_error, run_remote_effect, throw_form_error, throw_remote_cause, to_remote_failure_context };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { EffectLike, EffectRemoteCommand, EffectRemoteForm, EffectRemotePrerenderFunction, PrerenderOptions, QueryFactory, RemoteFormHandler, RemoteHandler, SchemaEncodedInput, SchemaInput, StandardSchema, StandardSchemaInput, StandardSchemaOutput } from "./types.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { NativeRemoteFormInput } from "../remote/native-types.js";
|
|
3
3
|
import { type Schema } from "effect";
|
|
4
4
|
type FormSchemaEncodedInput<S> = S extends Schema.Top ? FormRemoteInput<S["Encoded"]> : never;
|
|
5
|
-
type FormRemoteInput<Input> = NormalizeFormEncoded<Input> extends
|
|
6
|
-
type FormStandardSchemaInput<S> = StandardSchemaInput<S> extends
|
|
5
|
+
type FormRemoteInput<Input> = NormalizeFormEncoded<Input> extends NativeRemoteFormInput ? NormalizeFormEncoded<Input> : never;
|
|
6
|
+
type FormStandardSchemaInput<S> = StandardSchemaInput<S> extends NativeRemoteFormInput ? StandardSchemaInput<S> : NativeRemoteFormInput;
|
|
7
7
|
type FormScalar = string | number | boolean | File;
|
|
8
8
|
type NormalizeFormEncoded<Value> = Value extends FormScalar ? Value : Value extends ReadonlyArray<infer Item> ? Array<NormalizeFormEncoded<Item>> : Value extends object ? NormalizeFormObject<Value> : Value;
|
|
9
9
|
type NormalizeFormObject<Value> = {
|
|
@@ -116,7 +116,7 @@ export declare function Command<S extends StandardSchema, A, E = never, R = neve
|
|
|
116
116
|
* @returns A SvelteKit form function.
|
|
117
117
|
*/
|
|
118
118
|
export declare function Form<A, E = never, R = never>(validate_or_handler: EffectLike<A, E, R> | RemoteFormHandler<void, A, E, R>): EffectRemoteForm<void, A, E>;
|
|
119
|
-
export declare function Form<Input extends
|
|
119
|
+
export declare function Form<Input extends NativeRemoteFormInput, A, E = never, R = never>(validate_or_handler: "unchecked", maybe_handler: RemoteFormHandler<Input, A, E, R>): EffectRemoteForm<Input, A, E>;
|
|
120
120
|
export declare function Form<S extends Schema.Top, A, E = never, R = never>(validate_or_handler: S, maybe_handler: RemoteFormHandler<SchemaInput<S>, A, E, R>): EffectRemoteForm<FormSchemaEncodedInput<S>, A, E>;
|
|
121
121
|
export declare function Form<S extends StandardSchema, A, E = never, R = never>(validate_or_handler: S, maybe_handler: RemoteFormHandler<StandardSchemaOutput<S>, A, E, R>): EffectRemoteForm<FormStandardSchemaInput<S>, A, E>;
|
|
122
122
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type NativeTransport = Readonly<Record<string, {
|
|
2
2
|
readonly encode: (value: unknown) => false | unknown;
|
|
3
3
|
}>>;
|
|
4
|
-
/** Converts SvelteKit transport hooks into a devalue live snapshot encoder. */
|
|
5
|
-
export declare function make_remote_live_snapshot_encoder(transport: NativeTransport): (value: unknown) => string;
|
|
4
|
+
/** Converts available SvelteKit transport hooks into a devalue live snapshot encoder. */
|
|
5
|
+
export declare function make_remote_live_snapshot_encoder(transport: NativeTransport | undefined): (value: unknown) => string;
|
package/.dist/server/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { NativeRemoteFormInput, NativeRemoteQuery, NativeRemoteQueryOverride } from "../remote/native-types.js";
|
|
2
2
|
import type { EffectRemoteCommandCall as ClientEffectRemoteCommandCall, EffectRemoteForm as ClientEffectRemoteForm, EffectRemoteQueryUpdateBrand as ClientEffectRemoteQueryUpdateBrand } from "../remote/client.js";
|
|
3
3
|
import type { Effect, Layer, ManagedRuntime, Schema, Stream } from "effect";
|
|
4
4
|
import type { create_form_error, RemoteFailure } from "../remote/shared.js";
|
|
@@ -339,7 +339,7 @@ export interface CommandFactory {
|
|
|
339
339
|
*/
|
|
340
340
|
export interface FormFactory {
|
|
341
341
|
<A, E = never, R = never>(validate_or_handler: EffectLike<A, E, R> | RemoteFormHandler<void, A, E, R>): EffectRemoteForm<void, A, E>;
|
|
342
|
-
<Input extends
|
|
342
|
+
<Input extends NativeRemoteFormInput, A, E = never, R = never>(validate_or_handler: "unchecked", maybe_handler: RemoteFormHandler<Input, A, E, R>): EffectRemoteForm<Input, A, E>;
|
|
343
343
|
<S extends Schema.Top, A, E = never, R = never>(validate_or_handler: S, maybe_handler: RemoteFormHandler<SchemaInput<S>, A, E, R>): EffectRemoteForm<FormSchemaEncodedInput<S>, A, E>;
|
|
344
344
|
<S extends StandardSchema, A, E = never, R = never>(validate_or_handler: S, maybe_handler: RemoteFormHandler<StandardSchemaOutput<S>, A, E, R>): EffectRemoteForm<FormStandardSchemaInput<S>, A, E>;
|
|
345
345
|
}
|
|
@@ -401,13 +401,13 @@ export type EffectRemotePrerenderFunction<Input, A, E = never> = [Input] extends
|
|
|
401
401
|
*
|
|
402
402
|
* @since 2.0.0
|
|
403
403
|
*/
|
|
404
|
-
export type EffectRemoteQuery<A, E = never> = ClientEffectRemoteQueryUpdateBrand & Effect.Effect<A, RemoteFailure<E>, never> & Pick<
|
|
404
|
+
export type EffectRemoteQuery<A, E = never> = ClientEffectRemoteQueryUpdateBrand & Effect.Effect<A, RemoteFailure<E>, never> & Pick<NativeRemoteQuery<A>, "set"> & {
|
|
405
405
|
readonly current: A | undefined;
|
|
406
406
|
readonly error: unknown;
|
|
407
407
|
readonly loading: boolean;
|
|
408
408
|
readonly ready: boolean;
|
|
409
409
|
readonly refresh: () => Effect.Effect<void, unknown, never>;
|
|
410
|
-
readonly withOverride: (update: (current: A) => A) =>
|
|
410
|
+
readonly withOverride: (update: (current: A) => A) => NativeRemoteQueryOverride;
|
|
411
411
|
};
|
|
412
412
|
/**
|
|
413
413
|
* Effect-returning remote query function with SvelteKit query resource methods
|
|
@@ -477,10 +477,10 @@ export type EffectRemoteCommand<Input, A, E = never> = ([Input] extends [void] ?
|
|
|
477
477
|
* @template Input - Data shape submitted by the remote form.
|
|
478
478
|
* @template A - Successful value produced by the form handler.
|
|
479
479
|
*/
|
|
480
|
-
export type EffectRemoteForm<Input extends
|
|
480
|
+
export type EffectRemoteForm<Input extends NativeRemoteFormInput | void, A, E = never> = ClientEffectRemoteForm<Input, A, E>;
|
|
481
481
|
type FormSchemaEncodedInput<S> = S extends Schema.Top ? FormRemoteInput<S["Encoded"]> : never;
|
|
482
|
-
type FormRemoteInput<Input> = NormalizeFormEncoded<Input> extends
|
|
483
|
-
type FormStandardSchemaInput<S> = StandardSchemaInput<S> extends
|
|
482
|
+
type FormRemoteInput<Input> = NormalizeFormEncoded<Input> extends NativeRemoteFormInput ? NormalizeFormEncoded<Input> : never;
|
|
483
|
+
type FormStandardSchemaInput<S> = StandardSchemaInput<S> extends NativeRemoteFormInput ? StandardSchemaInput<S> : NativeRemoteFormInput;
|
|
484
484
|
type FormScalar = string | number | boolean | File;
|
|
485
485
|
type NormalizeFormEncoded<Value> = Value extends FormScalar ? Value : Value extends ReadonlyArray<infer Item> ? Array<NormalizeFormEncoded<Item>> : Value extends object ? NormalizeFormObject<Value> : Value;
|
|
486
486
|
type NormalizeFormObject<Value> = {
|
package/.dist/server.js
CHANGED
|
@@ -2,8 +2,8 @@ import { D as UncheckedLiveQueryHandlerMissingError, E as UncheckedFormHandlerMi
|
|
|
2
2
|
import { create_form_error, create_remote_transport_error } from "./remote/shared.js";
|
|
3
3
|
import { i as make_remote_live_stream, r as make_failed_remote_live_stream, t as Live } from "./chunks/live-BW7xZKjb.js";
|
|
4
4
|
import { a as normalize_validator, c as attach_remote_resource_getters, d as MakeEffectFromPromise, f as MakeEffectFromSync, l as is_remote_resource, n as attach_native_remote_query_update, o as attach_failed_remote_query_resource, r as resolve_native_remote_query_updates, s as attach_failed_remote_resource_getters, t as copy_property_descriptors, u as FailWithRemoteError } from "./chunks/descriptors-q909VWyR.js";
|
|
5
|
-
import { a as to_remote_failure_context, i as throw_remote_cause, n as run_remote_effect, t as normalize_remote_helper_error } from "./chunks/server-
|
|
6
|
-
import { i as get_server_runtime_or_throw, n as ServerRuntime, t as RequestEvent } from "./chunks/runtime-
|
|
5
|
+
import { a as to_remote_failure_context, i as throw_remote_cause, n as run_remote_effect, t as normalize_remote_helper_error } from "./chunks/server-Dxb9zr99.js";
|
|
6
|
+
import { i as get_server_runtime_or_throw, n as ServerRuntime, t as RequestEvent } from "./chunks/runtime-CmiEHnSw.js";
|
|
7
7
|
import { Effect, Result, Stream } from "effect";
|
|
8
8
|
import { error, invalid, redirect } from "@sveltejs/kit";
|
|
9
9
|
import { stringify } from "devalue";
|
|
@@ -180,9 +180,9 @@ function make_remote_form_wrapper(handler, helper_name) {
|
|
|
180
180
|
}
|
|
181
181
|
//#endregion
|
|
182
182
|
//#region src/server/live-snapshot.ts
|
|
183
|
-
/** Converts SvelteKit transport hooks into a devalue live snapshot encoder. */
|
|
183
|
+
/** Converts available SvelteKit transport hooks into a devalue live snapshot encoder. */
|
|
184
184
|
function make_remote_live_snapshot_encoder(transport) {
|
|
185
|
-
const encoders = Object.fromEntries(Object.entries(transport).map(([key, transformer]) => [key, transformer.encode]));
|
|
185
|
+
const encoders = Object.fromEntries(Object.entries(transport ?? {}).map(([key, transformer]) => [key, transformer.encode]));
|
|
186
186
|
return (value) => stringify(value, encoders);
|
|
187
187
|
}
|
|
188
188
|
//#endregion
|