svelte-effect-runtime 4.2.4 → 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-CpWfP_1f.js → client-Bi7SwVVy.js} +23 -13
- 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/{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/{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/environment.d.ts +9 -3
- package/.dist/environment.js.map +1 -1
- package/.dist/internal/remote-client.js +1 -1
- package/.dist/internal/remote-server.js +1 -1
- package/.dist/mod.js +1 -1
- 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 +3 -3
- package/.dist/server.js.map +1 -1
- package/package.json +2 -2
- package/.dist/chunks/client-CpWfP_1f.js.map +0 -1
- package/.dist/chunks/remote-client-mkQAfP1G.js.map +0 -1
- package/.dist/chunks/server-BNxq-pUH.js.map +0 -1
|
@@ -77,34 +77,41 @@ const InvokeCommand = (native_factory, invoke, input, decode_payload, read_updat
|
|
|
77
77
|
});
|
|
78
78
|
//#endregion
|
|
79
79
|
//#region src/remote/client/form-data.ts
|
|
80
|
-
|
|
80
|
+
/**
|
|
81
|
+
* Encodes a remote form input the way SvelteKit's `convert_formdata` expects.
|
|
82
|
+
* SvelteKit 3.0.0-next.14+ requires every field name to end with `/<form_id>`
|
|
83
|
+
* (the un-keyed remote action id), so callers pass the id whenever they target
|
|
84
|
+
* that wire format. SvelteKit 2 servers never see this encoding because they
|
|
85
|
+
* ship the binary form bridge, which bypasses `FormData` entirely.
|
|
86
|
+
*/
|
|
87
|
+
function to_form_data(input, form_id) {
|
|
81
88
|
const form_data = new FormData();
|
|
82
|
-
append_form_value(form_data, "", input);
|
|
89
|
+
append_form_value(form_data, "", form_id === void 0 ? "" : `/${form_id}`, input);
|
|
83
90
|
return form_data;
|
|
84
91
|
}
|
|
85
|
-
function append_form_value(form_data, path, value) {
|
|
92
|
+
function append_form_value(form_data, path, suffix, value) {
|
|
86
93
|
if (value === void 0) return;
|
|
87
94
|
if (Array.isArray(value)) {
|
|
88
|
-
for (const [index, item] of value.entries()) append_form_value(form_data, `${path}[${index}]`, item);
|
|
95
|
+
for (const [index, item] of value.entries()) append_form_value(form_data, `${path}[${index}]`, suffix, item);
|
|
89
96
|
return;
|
|
90
97
|
}
|
|
91
98
|
if (value instanceof Blob) {
|
|
92
|
-
form_data.append(path
|
|
99
|
+
form_data.append(`${path}${suffix}`, value);
|
|
93
100
|
return;
|
|
94
101
|
}
|
|
95
102
|
if (typeof value === "object" && value !== null) {
|
|
96
|
-
for (const [key, child] of Object.entries(value)) append_form_value(form_data, path.length === 0 ? key : `${path}.${key}`, child);
|
|
103
|
+
for (const [key, child] of Object.entries(value)) append_form_value(form_data, path.length === 0 ? key : `${path}.${key}`, suffix, child);
|
|
97
104
|
return;
|
|
98
105
|
}
|
|
99
106
|
if (typeof value === "number") {
|
|
100
|
-
form_data.append(`n:${path}`, String(value));
|
|
107
|
+
form_data.append(`n:${path}${suffix}`, String(value));
|
|
101
108
|
return;
|
|
102
109
|
}
|
|
103
110
|
if (typeof value === "boolean") {
|
|
104
|
-
form_data.append(`b:${path}`, value ? "on" : "off");
|
|
111
|
+
form_data.append(`b:${path}${suffix}`, value ? "on" : "off");
|
|
105
112
|
return;
|
|
106
113
|
}
|
|
107
|
-
form_data.append(path
|
|
114
|
+
form_data.append(`${path}${suffix}`, value === null ? "" : String(value));
|
|
108
115
|
}
|
|
109
116
|
//#endregion
|
|
110
117
|
//#region src/remote/client/form-transport.ts
|
|
@@ -155,7 +162,7 @@ const SubmitRemoteForm = (form_obj, input, decode_payload, remote_base, remote_t
|
|
|
155
162
|
const response = yield* MakeEffectFromPromise((signal) => fetch(to_remote_form_url(remote_base, action_id), {
|
|
156
163
|
method: "POST",
|
|
157
164
|
headers: get_remote_request_headers(),
|
|
158
|
-
body: to_form_data(to_remote_form_input(input, action_id)),
|
|
165
|
+
body: to_form_data(to_remote_form_input(input, action_id), to_remote_form_id(action_id)),
|
|
159
166
|
signal
|
|
160
167
|
}));
|
|
161
168
|
if (!response.ok) {
|
|
@@ -187,8 +194,11 @@ function get_remote_action_id(form_obj) {
|
|
|
187
194
|
return url.searchParams.get("/remote") ?? url.searchParams.get("remote") ?? void 0;
|
|
188
195
|
}
|
|
189
196
|
function to_remote_form_url(remote_base, action_id) {
|
|
190
|
-
|
|
191
|
-
|
|
197
|
+
return `${remote_base.replace(/\/$/, "")}/${to_remote_form_id(action_id)}`;
|
|
198
|
+
}
|
|
199
|
+
/** The un-keyed remote action id SvelteKit suffixes onto every form field name. */
|
|
200
|
+
function to_remote_form_id(action_id) {
|
|
201
|
+
return action_id.split("/").slice(0, 2).join("/");
|
|
192
202
|
}
|
|
193
203
|
function to_remote_form_input(input, action_id) {
|
|
194
204
|
const data = is_record(input) ? input : {};
|
|
@@ -527,4 +537,4 @@ const RefreshRemoteResource = (resource, refresh) => Effect.gen(function* () {
|
|
|
527
537
|
//#endregion
|
|
528
538
|
export { create_remote_command_adapter as a, create_remote_form_adapter as i, create_remote_query_adapter as n, create_remote_prerender_adapter as r, create_remote_live_query_adapter as t };
|
|
529
539
|
|
|
530
|
-
//# sourceMappingURL=client-
|
|
540
|
+
//# sourceMappingURL=client-Bi7SwVVy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-Bi7SwVVy.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/remote/client/utils.ts","../../../modules/svelte-effect-runtime/src/remote/client/responses.ts","../../../modules/svelte-effect-runtime/src/remote/client/command.ts","../../../modules/svelte-effect-runtime/src/remote/client/form-data.ts","../../../modules/svelte-effect-runtime/src/remote/client/form-transport.ts","../../../modules/svelte-effect-runtime/src/remote/client/form-enhance.ts","../../../modules/svelte-effect-runtime/src/remote/client/form.ts","../../../modules/svelte-effect-runtime/src/remote/client/query-result.ts","../../../modules/svelte-effect-runtime/src/remote/client/prerender.ts","../../../modules/svelte-effect-runtime/src/remote/client/query.ts"],"sourcesContent":["export { copy_property_descriptors } from \"$/internal/descriptors.ts\";\nimport type { NativeMethod } from \"./types.ts\";\n\nexport function has_method<K extends PropertyKey>(\n\tvalue: unknown,\n\tkey: K,\n): value is Record<K, NativeMethod> {\n\tconst value_type = typeof value;\n\n\treturn (\n\t\t((value_type === \"object\" && value !== null) || value_type === \"function\") &&\n\t\ttypeof (value as Record<PropertyKey, unknown>)[key] === \"function\"\n\t);\n}\n","import { decode_remote_error, is_decoded_remote_failure } from \"$/remote/failures.ts\";\nimport { MakeEffectFromPromise, MakeEffectFromSync } from \"$/remote/effect.ts\";\nimport { create_remote_http_error } from \"$/remote/shared.ts\";\nimport type { RemoteFailure } from \"$/remote/shared.ts\";\nimport { Effect } from \"effect\";\n\nexport const DecodeResponseFailure = <ErrorType = never>(response: Response) =>\n\tEffect.gen(function* () {\n\t\tconst body = yield* MakeEffectFromPromise<unknown, ErrorType>(() => response.json()).pipe(\n\t\t\tEffect.orElseSucceed(() => undefined),\n\t\t);\n\t\tconst decoded = decode_remote_error<ErrorType>(body);\n\n\t\tif (is_decoded_remote_failure(decoded)) {\n\t\t\treturn decoded as RemoteFailure<ErrorType>;\n\t\t}\n\n\t\treturn create_remote_http_error(response.status, body);\n\t});\n\nexport const DecodeResponseOrValue = <Output, ErrorType = never>(\n\tvalue: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n) =>\n\tEffect.gen(function* () {\n\t\tif (value instanceof Response) {\n\t\t\tif (!value.ok) {\n\t\t\t\tconst failure = yield* DecodeResponseFailure<ErrorType>(value);\n\n\t\t\t\treturn yield* Effect.fail(failure);\n\t\t\t}\n\n\t\t\tconst data = yield* DecodeSuccessResponseBody<ErrorType>(value);\n\n\t\t\treturn yield* MakeEffectFromSync<Output, ErrorType>(\n\t\t\t\t() => decode_payload(data) as Output,\n\t\t\t);\n\t\t}\n\n\t\treturn yield* MakeEffectFromSync<Output, ErrorType>(() => decode_payload(value) as Output);\n\t});\n\nconst DecodeSuccessResponseBody = <ErrorType>(response: Response) =>\n\tEffect.gen(function* () {\n\t\tif (response.status === 204 || response.status === 205) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst text = yield* MakeEffectFromPromise<string, ErrorType>(() => response.text());\n\n\t\tif (text.length === 0) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn yield* MakeEffectFromSync<unknown, ErrorType>(() => JSON.parse(text));\n\t});\n","import { copy_property_descriptors, has_method } from \"./utils.ts\";\nimport { resolve_native_remote_query_updates } from \"$/remote/query-update.ts\";\nimport { InvalidCommandFactoryError } from \"$/errors.ts\";\nimport type { EffectRemoteCommandCall, NativeMethod, Pending } from \"./types.ts\";\nimport { DecodeResponseOrValue } from \"./responses.ts\";\nimport { MakeEffectFromPromise, MakeEffectFromSync } from \"$/remote/effect.ts\";\nimport { Effect } from \"effect\";\n\ntype EffectRemoteCommandAdapter<Input, Output, ErrorType = never> = ((\n\tinput: undefined extends Input ? Input | void : Input,\n) => EffectRemoteCommandCall<Output, ErrorType>) & {\n\treadonly pending: number;\n};\n\n/** Adapts a generated SvelteKit command to SER's Effect-based client ABI. */\nexport function create_remote_command_adapter<Input, Output, ErrorType = never>(\n\tnative_factory: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n\t_base = \"\",\n\tpending?: Pending,\n): EffectRemoteCommandAdapter<Input, Output, ErrorType> {\n\tconst invoke = has_method(native_factory, \"invoke\") ? native_factory.invoke : undefined;\n\n\tif (typeof native_factory !== \"function\" && !invoke) {\n\t\tthrow new InvalidCommandFactoryError();\n\t}\n\n\tconst count = pending ?? { value: 0 };\n\n\tconst adapter = (input: undefined extends Input ? Input | void : Input) =>\n\t\tMakeCommandEffect<Input, Output, ErrorType>(\n\t\t\tnative_factory,\n\t\t\tinvoke,\n\t\t\tinput,\n\t\t\tdecode_payload,\n\t\t\tcount,\n\t\t);\n\n\tcopy_property_descriptors(native_factory, adapter);\n\n\tif (!Object.prototype.hasOwnProperty.call(adapter, \"pending\")) {\n\t\tObject.defineProperty(adapter, \"pending\", {\n\t\t\tget: () => count.value,\n\t\t});\n\t}\n\n\treturn adapter as EffectRemoteCommandAdapter<Input, Output, ErrorType>;\n}\n\nconst MakeCommandEffect = <Input, Output, ErrorType>(\n\tnative_factory: unknown,\n\tinvoke: NativeMethod | undefined,\n\tinput: undefined extends Input ? Input | void : Input,\n\tdecode_payload: (value: unknown) => unknown,\n\tpending: Pending,\n) => {\n\tlet updates_args: unknown[] | undefined;\n\n\tconst CommandEffect = Effect.acquireUseRelease(\n\t\tAcquirePending(pending),\n\t\t() =>\n\t\t\tInvokeCommand<Input, Output, ErrorType>(\n\t\t\t\tnative_factory,\n\t\t\t\tinvoke,\n\t\t\t\tinput,\n\t\t\t\tdecode_payload,\n\t\t\t\t() => updates_args,\n\t\t\t),\n\t\t() => ReleasePending(pending),\n\t) as EffectRemoteCommandCall<Output, ErrorType>;\n\n\tObject.defineProperty(CommandEffect, \"updates\", {\n\t\tconfigurable: true,\n\t\tenumerable: false,\n\t\tvalue: (...args: unknown[]) => {\n\t\t\tupdates_args ??= args;\n\n\t\t\treturn CommandEffect;\n\t\t},\n\t});\n\n\treturn CommandEffect;\n};\n\nconst AcquirePending = (pending: Pending) =>\n\tEffect.sync(() => {\n\t\tpending.value += 1;\n\t});\n\nconst ReleasePending = (pending: Pending) =>\n\tEffect.sync(() => {\n\t\tpending.value -= 1;\n\t});\n\nconst InvokeCommand = <Input, Output, ErrorType>(\n\tnative_factory: unknown,\n\tinvoke: NativeMethod | undefined,\n\tinput: undefined extends Input ? Input | void : Input,\n\tdecode_payload: (value: unknown) => unknown,\n\tread_updates_args: () => unknown[] | undefined,\n) =>\n\tEffect.gen(function* () {\n\t\tconst invocation = yield* MakeEffectFromSync<unknown, ErrorType>(() => {\n\t\t\tconst result = invoke\n\t\t\t\t? invoke.call(native_factory, input)\n\t\t\t\t: (native_factory as NativeMethod)(input);\n\t\t\tconst updates_args = read_updates_args();\n\n\t\t\tif (updates_args && has_method(result, \"updates\")) {\n\t\t\t\treturn result.updates(...resolve_native_remote_query_updates(updates_args));\n\t\t\t}\n\n\t\t\treturn result;\n\t\t});\n\t\tconst result = yield* MakeEffectFromPromise<unknown, ErrorType>(() =>\n\t\t\tPromise.resolve(invocation),\n\t\t);\n\n\t\treturn yield* DecodeResponseOrValue<Output, ErrorType>(result, decode_payload);\n\t});\n","/**\n * Encodes a remote form input the way SvelteKit's `convert_formdata` expects.\n * SvelteKit 3.0.0-next.14+ requires every field name to end with `/<form_id>`\n * (the un-keyed remote action id), so callers pass the id whenever they target\n * that wire format. SvelteKit 2 servers never see this encoding because they\n * ship the binary form bridge, which bypasses `FormData` entirely.\n */\nexport function to_form_data(input: unknown, form_id?: string): FormData {\n\tconst form_data = new FormData();\n\tconst suffix = form_id === undefined ? \"\" : `/${form_id}`;\n\n\tappend_form_value(form_data, \"\", suffix, input);\n\n\treturn form_data;\n}\n\nfunction append_form_value(\n\tform_data: FormData,\n\tpath: string,\n\tsuffix: string,\n\tvalue: unknown,\n): void {\n\tif (value === undefined) {\n\t\treturn;\n\t}\n\n\tif (Array.isArray(value)) {\n\t\tfor (const [index, item] of value.entries()) {\n\t\t\tappend_form_value(form_data, `${path}[${index}]`, suffix, item);\n\t\t}\n\n\t\treturn;\n\t}\n\n\tif (value instanceof Blob) {\n\t\tform_data.append(`${path}${suffix}`, value);\n\n\t\treturn;\n\t}\n\n\tif (typeof value === \"object\" && value !== null) {\n\t\tfor (const [key, child] of Object.entries(value)) {\n\t\t\tconst child_path = path.length === 0 ? key : `${path}.${key}`;\n\n\t\t\tappend_form_value(form_data, child_path, suffix, child);\n\t\t}\n\n\t\treturn;\n\t}\n\n\tif (typeof value === \"number\") {\n\t\tform_data.append(`n:${path}${suffix}`, String(value));\n\n\t\treturn;\n\t}\n\n\tif (typeof value === \"boolean\") {\n\t\tform_data.append(`b:${path}${suffix}`, value ? \"on\" : \"off\");\n\n\t\treturn;\n\t}\n\n\tform_data.append(`${path}${suffix}`, value === null ? \"\" : String(value));\n}\n","import {\n\tInvalidRemoteFormResponseError,\n\tRemoteFormEndpointMissingError,\n\tUnsupportedRemoteFormResponseError,\n} from \"$/errors.ts\";\nimport {\n\tcreate_remote_http_error,\n\tcreate_remote_transport_error,\n\tcreate_remote_validation_error,\n} from \"$/remote/shared.ts\";\nimport { decode_remote_error, is_decoded_remote_failure } from \"$/remote/failures.ts\";\nimport { MakeEffectFromPromise, MakeEffectFromSync } from \"$/remote/effect.ts\";\nimport type { FormIssue } from \"$/remote/shared.ts\";\nimport type { StandardSchema } from \"$/internal/schema.ts\";\nimport { DecodeResponseFailure } from \"./responses.ts\";\nimport type { NativeFormRecord } from \"./types.ts\";\nimport { Effect, Option, Schema } from \"effect\";\nimport { to_form_data } from \"./form-data.ts\";\nimport { parse } from \"devalue\";\n\ntype RemoteFormResponseEnvelope =\n\t| {\n\t\t\treadonly _tag: \"RemoteFormErrorEnvelope\";\n\t\t\treadonly error?: unknown;\n\t\t\treadonly status?: number | undefined;\n\t }\n\t| {\n\t\t\treadonly _tag: \"RemoteFormResultEnvelope\";\n\t\t\treadonly data: string;\n\t }\n\t| {\n\t\t\treadonly _tag: \"RemoteFormRedirectEnvelope\";\n\t\t\treadonly location: string;\n\t };\n\nexport interface RemoteFormTransport {\n\treadonly binary_form_content_type?: string;\n\treadonly decoders?: Record<string, (value: unknown) => unknown>;\n\treadonly navigate?: (location: string, invalidate_all: boolean) => PromiseLike<void> | void;\n\treadonly remote_request?: (url: string, init?: RequestInit) => PromiseLike<unknown>;\n\treadonly refresh?: () => PromiseLike<void> | void;\n\treadonly serialize_binary_form?: (\n\t\tdata: unknown,\n\t\tmeta: { readonly remote_refreshes: readonly string[] },\n\t) => { readonly blob: Blob };\n}\n\ninterface KitRemoteFormTransport extends RemoteFormTransport {\n\treadonly binary_form_content_type: string;\n\treadonly remote_request: (url: string, init?: RequestInit) => PromiseLike<unknown>;\n\treadonly serialize_binary_form: (\n\t\tdata: unknown,\n\t\tmeta: { readonly remote_refreshes: readonly string[] },\n\t) => { readonly blob: Blob };\n}\n\ntype RemoteFormDecodedPayload<Output> = {\n\treadonly issues?: readonly FormIssue[];\n\treadonly result?: Output;\n};\n\nconst FormIssuePathSegmentSchema = Schema.Union([Schema.String, Schema.Number]);\n\nconst FormIssueSchema = Schema.Struct({\n\tmessage: Schema.String,\n\tpath: Schema.Array(FormIssuePathSegmentSchema),\n});\n\nconst RemoteFormErrorEnvelopeSchema = Schema.Struct({\n\ttype: Schema.Literal(\"error\"),\n\terror: Schema.optional(Schema.Unknown),\n\tstatus: Schema.optional(Schema.Number),\n});\n\nconst RemoteFormResultEnvelopeSchema = Schema.Struct({\n\ttype: Schema.Literal(\"result\"),\n\tdata: Schema.String,\n});\n\nconst RemoteFormRedirectEnvelopeSchema = Schema.Struct({\n\ttype: Schema.Literal(\"redirect\"),\n\tlocation: Schema.String,\n});\n\nconst RemoteFormResponseEnvelopeSchema = Schema.Union([\n\tRemoteFormErrorEnvelopeSchema,\n\tRemoteFormResultEnvelopeSchema,\n\tRemoteFormRedirectEnvelopeSchema,\n]);\n\nconst RemoteFormDecodedPayloadSchema = Schema.Struct({\n\tissues: Schema.optional(Schema.Array(FormIssueSchema)),\n\tresult: Schema.optional(Schema.Unknown),\n});\n\nconst RemoteFormRedirectDataSchema = Schema.Struct({\n\tredirect: Schema.String,\n});\n\nconst RemoteFormResultDataSchema = Schema.Struct({\n\t_: Schema.Unknown,\n});\n\nconst KitRemoteFormDataSchema = Schema.Struct({\n\t_: Schema.optional(Schema.Unknown),\n\tredirect: Schema.optional(Schema.String),\n\tr: Schema.optional(Schema.Literal(true)),\n});\n\nconst DecodeRemoteFormResponseEnvelope = Schema.decodeUnknownOption(\n\tRemoteFormResponseEnvelopeSchema,\n);\nconst DecodeRemoteFormPayload = Schema.decodeUnknownOption(RemoteFormDecodedPayloadSchema);\nconst DecodeRemoteFormRedirectData = Schema.decodeUnknownOption(RemoteFormRedirectDataSchema);\nconst DecodeRemoteFormResultData = Schema.decodeUnknownOption(RemoteFormResultDataSchema);\nconst DecodeKitRemoteFormData = Schema.decodeUnknownOption(KitRemoteFormDataSchema);\n\nexport const SubmitRemoteForm = <Output, ErrorType = never>(\n\tform_obj: NativeFormRecord,\n\tinput: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n\tremote_base: string,\n\tremote_transport: RemoteFormTransport,\n\tpreflight_schema?: StandardSchema,\n) =>\n\tEffect.gen(function* () {\n\t\tconst action_id = yield* MakeEffectFromSync<string | undefined, ErrorType>(() =>\n\t\t\tget_remote_action_id(form_obj),\n\t\t);\n\n\t\tif (!action_id || remote_base.length === 0) {\n\t\t\treturn yield* Effect.fail(\n\t\t\t\tcreate_remote_transport_error(new RemoteFormEndpointMissingError()),\n\t\t\t);\n\t\t}\n\n\t\tyield* ValidatePreflightInput<ErrorType>(preflight_schema, input);\n\n\t\tif (is_kit_remote_form_transport(remote_transport)) {\n\t\t\treturn yield* SubmitRemoteFormWithKit<Output, ErrorType>(\n\t\t\t\taction_id,\n\t\t\t\tinput,\n\t\t\t\tdecode_payload,\n\t\t\t\tremote_base,\n\t\t\t\tremote_transport,\n\t\t\t);\n\t\t}\n\n\t\tconst response = yield* MakeEffectFromPromise<Response, ErrorType>((signal) =>\n\t\t\tfetch(to_remote_form_url(remote_base, action_id), {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\theaders: get_remote_request_headers(),\n\t\t\t\tbody: to_form_data(\n\t\t\t\t\tto_remote_form_input(input, action_id),\n\t\t\t\t\tto_remote_form_id(action_id),\n\t\t\t\t),\n\t\t\t\tsignal,\n\t\t\t}),\n\t\t);\n\n\t\tif (!response.ok) {\n\t\t\tconst failure = yield* DecodeResponseFailure<ErrorType>(response);\n\n\t\t\treturn yield* Effect.fail(failure);\n\t\t}\n\n\t\tconst envelope = yield* MakeEffectFromPromise<unknown, ErrorType>(() => response.json());\n\n\t\treturn yield* DecodeFormResponse<Output, ErrorType>(\n\t\t\tenvelope,\n\t\t\tdecode_payload,\n\t\t\tremote_transport,\n\t\t);\n\t});\n\nconst SubmitRemoteFormWithKit = <Output, ErrorType>(\n\taction_id: string,\n\tinput: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n\tremote_base: string,\n\tremote_transport: KitRemoteFormTransport,\n) =>\n\tEffect.gen(function* () {\n\t\tconst url = to_remote_form_url(remote_base, action_id);\n\t\tconst body = yield* MakeEffectFromSync<Blob, ErrorType>(\n\t\t\t() =>\n\t\t\t\tremote_transport.serialize_binary_form(to_remote_form_input(input, action_id), {\n\t\t\t\t\tremote_refreshes: [],\n\t\t\t\t}).blob,\n\t\t);\n\t\tconst data = yield* MakeEffectFromPromise<unknown, ErrorType>((signal) =>\n\t\t\tremote_transport.remote_request(url, {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\theaders: {\n\t\t\t\t\t...get_remote_request_headers(),\n\t\t\t\t\t\"Content-Type\": remote_transport.binary_form_content_type,\n\t\t\t\t},\n\t\t\t\tbody,\n\t\t\t\tsignal,\n\t\t\t}),\n\t\t);\n\n\t\treturn yield* DecodeKitFormData<Output, ErrorType>(data, decode_payload, remote_transport);\n\t});\n\nexport function get_remote_action_id(form_obj: NativeFormRecord): string | undefined {\n\tconst action = form_obj.action;\n\n\tif (typeof action !== \"string\") {\n\t\treturn undefined;\n\t}\n\n\tconst fallback = \"http://localhost/\";\n\tconst href = typeof location === \"undefined\" ? fallback : location.href;\n\tconst url = new URL(action, href);\n\n\treturn url.searchParams.get(\"/remote\") ?? url.searchParams.get(\"remote\") ?? undefined;\n}\n\nfunction to_remote_form_url(remote_base: string, action_id: string): string {\n\tconst normalized_base = remote_base.replace(/\\/$/, \"\");\n\n\treturn `${normalized_base}/${to_remote_form_id(action_id)}`;\n}\n\n/** The un-keyed remote action id SvelteKit suffixes onto every form field name. */\nfunction to_remote_form_id(action_id: string): string {\n\treturn action_id.split(\"/\").slice(0, 2).join(\"/\");\n}\n\nfunction to_remote_form_input(input: unknown, action_id: string): Record<string, unknown> {\n\tconst data = is_record(input) ? input : {};\n\tconst serialized_key = action_id.split(\"/\").slice(2).join(\"/\");\n\tconst key: unknown = serialized_key.length === 0 ? undefined : JSON.parse(serialized_key);\n\n\tif (key === undefined || data.id !== undefined) {\n\t\treturn data;\n\t}\n\n\treturn {\n\t\t...data,\n\t\tid: key,\n\t};\n}\n\nfunction get_remote_request_headers(): Record<string, string> {\n\tif (typeof location === \"undefined\") {\n\t\treturn {};\n\t}\n\n\treturn {\n\t\t\"x-sveltekit-pathname\": location.pathname,\n\t\t\"x-sveltekit-search\": location.search,\n\t};\n}\n\nconst ValidatePreflightInput = <ErrorType>(schema: StandardSchema | undefined, input: unknown) =>\n\tEffect.gen(function* () {\n\t\tif (!schema) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst validated = yield* MakeEffectFromPromise<unknown, ErrorType>(() =>\n\t\t\tPromise.resolve(schema[\"~standard\"].validate(input)),\n\t\t);\n\n\t\tif (!is_record(validated) || !Array.isArray(validated.issues)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst issues = validated.issues.map(normalize_standard_issue);\n\n\t\treturn yield* Effect.fail(create_remote_validation_error(issues, { issues }, 400));\n\t});\n\nfunction normalize_standard_issue(issue: unknown): FormIssue {\n\tif (!is_record(issue)) {\n\t\treturn { message: String(issue), path: [] };\n\t}\n\n\tconst message = typeof issue.message === \"string\" ? issue.message : \"Invalid input\";\n\tconst path = Array.isArray(issue.path) ? issue.path.flatMap(normalize_path_segment) : [];\n\n\treturn { message, path };\n}\n\nfunction normalize_path_segment(segment: unknown): Array<string | number> {\n\tif (typeof segment === \"string\" || typeof segment === \"number\") {\n\t\treturn [segment];\n\t}\n\n\tif (!is_record(segment)) {\n\t\treturn [];\n\t}\n\n\tconst key = segment.key;\n\n\tif (typeof key === \"string\" || typeof key === \"number\") {\n\t\treturn [key];\n\t}\n\n\treturn [];\n}\n\nfunction is_record(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null;\n}\n\nconst DecodeFormResponse = <Output, ErrorType>(\n\tenvelope: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n\tremote_transport: RemoteFormTransport,\n) =>\n\tEffect.gen(function* () {\n\t\tconst response = decode_remote_form_response_envelope(envelope);\n\n\t\tif (!response) {\n\t\t\treturn yield* Effect.fail(\n\t\t\t\tcreate_remote_transport_error(\n\t\t\t\t\tnew InvalidRemoteFormResponseError(envelope),\n\t\t\t\t\tenvelope,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tif (response._tag === \"RemoteFormErrorEnvelope\") {\n\t\t\tconst decoded = decode_remote_error<ErrorType>(response.error);\n\n\t\t\tif (is_decoded_remote_failure(decoded)) {\n\t\t\t\treturn yield* Effect.fail(decoded);\n\t\t\t}\n\n\t\t\treturn yield* Effect.fail(\n\t\t\t\tcreate_remote_http_error(get_remote_form_error_status(response), response.error),\n\t\t\t);\n\t\t}\n\n\t\tif (response._tag === \"RemoteFormRedirectEnvelope\") {\n\t\t\treturn yield* NavigateRemoteForm<ErrorType>(\n\t\t\t\tresponse.location,\n\t\t\t\ttrue,\n\t\t\t\tremote_transport,\n\t\t\t\tenvelope,\n\t\t\t);\n\t\t}\n\n\t\tconst parsed = yield* MakeEffectFromSync<unknown, ErrorType>(() =>\n\t\t\tparse(response.data, remote_transport.decoders),\n\t\t);\n\t\tconst redirect_data = DecodeRemoteFormRedirectData(parsed);\n\n\t\tif (Option.isSome(redirect_data)) {\n\t\t\treturn yield* NavigateRemoteForm<ErrorType>(\n\t\t\t\tredirect_data.value.redirect,\n\t\t\t\ttrue,\n\t\t\t\tremote_transport,\n\t\t\t\tenvelope,\n\t\t\t);\n\t\t}\n\n\t\tconst result_data = DecodeRemoteFormResultData(parsed);\n\n\t\tif (!Option.isSome(result_data)) {\n\t\t\treturn yield* Effect.fail(\n\t\t\t\tcreate_remote_transport_error(\n\t\t\t\t\tnew UnsupportedRemoteFormResponseError(envelope),\n\t\t\t\t\tenvelope,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tconst payload = yield* MakeEffectFromSync<unknown, ErrorType>(() =>\n\t\t\tdecode_payload(result_data.value._),\n\t\t);\n\t\tconst decoded = decode_remote_form_payload<Output>(payload);\n\n\t\tif (!decoded) {\n\t\t\treturn yield* Effect.fail(\n\t\t\t\tcreate_remote_transport_error(\n\t\t\t\t\tnew UnsupportedRemoteFormResponseError(envelope),\n\t\t\t\t\tenvelope,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tif (decoded.issues && decoded.issues.length > 0) {\n\t\t\treturn yield* Effect.fail(create_remote_validation_error(decoded.issues, decoded, 400));\n\t\t}\n\n\t\tyield* RefreshRemoteFormState<ErrorType>(remote_transport);\n\n\t\treturn decoded.result as Output;\n\t});\n\nconst DecodeKitFormData = <Output, ErrorType>(\n\tdata: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n\tremote_transport: RemoteFormTransport,\n) =>\n\tEffect.gen(function* () {\n\t\tconst decoded_data = DecodeKitRemoteFormData(data);\n\n\t\tif (!Option.isSome(decoded_data)) {\n\t\t\treturn yield* Effect.fail(\n\t\t\t\tcreate_remote_transport_error(new UnsupportedRemoteFormResponseError(data), data),\n\t\t\t);\n\t\t}\n\n\t\tconst should_invalidate = decoded_data.value.r !== true;\n\n\t\tif (decoded_data.value.redirect) {\n\t\t\treturn yield* NavigateRemoteForm<ErrorType>(\n\t\t\t\tdecoded_data.value.redirect,\n\t\t\t\tshould_invalidate,\n\t\t\t\tremote_transport,\n\t\t\t\tdata,\n\t\t\t);\n\t\t}\n\n\t\tif (!(\"_\" in decoded_data.value)) {\n\t\t\treturn yield* Effect.fail(\n\t\t\t\tcreate_remote_transport_error(new UnsupportedRemoteFormResponseError(data), data),\n\t\t\t);\n\t\t}\n\n\t\tconst payload = yield* MakeEffectFromSync<unknown, ErrorType>(() =>\n\t\t\tdecode_payload(decoded_data.value._),\n\t\t);\n\t\tconst decoded = decode_remote_form_payload<Output>(payload);\n\n\t\tif (!decoded) {\n\t\t\treturn yield* Effect.fail(\n\t\t\t\tcreate_remote_transport_error(new UnsupportedRemoteFormResponseError(data), data),\n\t\t\t);\n\t\t}\n\n\t\tif (decoded.issues && decoded.issues.length > 0) {\n\t\t\treturn yield* Effect.fail(create_remote_validation_error(decoded.issues, decoded, 400));\n\t\t}\n\n\t\tif (should_invalidate) {\n\t\t\tyield* RefreshRemoteFormState<ErrorType>(remote_transport);\n\t\t}\n\n\t\treturn decoded.result as Output;\n\t});\n\nconst NavigateRemoteForm = <ErrorType>(\n\tlocation: string,\n\tinvalidate_all: boolean,\n\tremote_transport: RemoteFormTransport,\n\tenvelope: unknown,\n) =>\n\tEffect.gen(function* () {\n\t\tconst navigate = remote_transport.navigate;\n\n\t\tif (!navigate) {\n\t\t\treturn yield* Effect.fail(\n\t\t\t\tcreate_remote_transport_error(\n\t\t\t\t\tnew UnsupportedRemoteFormResponseError(envelope),\n\t\t\t\t\tenvelope,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tyield* MakeEffectFromPromise<void, ErrorType>(() =>\n\t\t\tPromise.resolve(navigate(location, invalidate_all)),\n\t\t);\n\n\t\treturn yield* Effect.interrupt;\n\t});\n\nconst RefreshRemoteFormState = <ErrorType>(remote_transport: RemoteFormTransport) =>\n\tEffect.gen(function* () {\n\t\tconst refresh = remote_transport.refresh;\n\n\t\tif (!refresh) {\n\t\t\treturn;\n\t\t}\n\n\t\tyield* MakeEffectFromPromise<void, ErrorType>(() => Promise.resolve(refresh()));\n\t});\n\nfunction decode_remote_form_response_envelope(\n\tenvelope: unknown,\n): RemoteFormResponseEnvelope | undefined {\n\tconst decoded = DecodeRemoteFormResponseEnvelope(envelope);\n\n\tif (!Option.isSome(decoded)) {\n\t\treturn undefined;\n\t}\n\n\tif (decoded.value.type === \"error\") {\n\t\treturn {\n\t\t\t_tag: \"RemoteFormErrorEnvelope\",\n\t\t\terror: decoded.value.error,\n\t\t\tstatus: decoded.value.status,\n\t\t};\n\t}\n\n\tif (decoded.value.type === \"redirect\") {\n\t\treturn {\n\t\t\t_tag: \"RemoteFormRedirectEnvelope\",\n\t\t\tlocation: decoded.value.location,\n\t\t};\n\t}\n\n\treturn {\n\t\t_tag: \"RemoteFormResultEnvelope\",\n\t\tdata: decoded.value.data,\n\t};\n}\n\nfunction get_remote_form_error_status(\n\tresponse: Extract<RemoteFormResponseEnvelope, { _tag: \"RemoteFormErrorEnvelope\" }>,\n): number {\n\tconst nested_status = is_record(response.error) ? response.error.status : undefined;\n\n\tif (response.status !== undefined) {\n\t\treturn response.status;\n\t}\n\n\treturn typeof nested_status === \"number\" ? nested_status : 500;\n}\n\nfunction is_kit_remote_form_transport(\n\tremote_transport: RemoteFormTransport,\n): remote_transport is KitRemoteFormTransport {\n\treturn (\n\t\ttypeof remote_transport.binary_form_content_type === \"string\" &&\n\t\ttypeof remote_transport.remote_request === \"function\" &&\n\t\ttypeof remote_transport.serialize_binary_form === \"function\"\n\t);\n}\n\nfunction decode_remote_form_payload<Output>(\n\tpayload: unknown,\n): RemoteFormDecodedPayload<Output> | undefined {\n\tconst decoded = DecodeRemoteFormPayload(payload);\n\n\tif (!Option.isSome(decoded)) {\n\t\treturn undefined;\n\t}\n\n\treturn decoded.value as RemoteFormDecodedPayload<Output>;\n}\n","import { MakeEffectFromPromise, MakeEffectFromSync } from \"$/remote/effect.ts\";\nimport { resolve_native_remote_query_updates } from \"$/remote/query-update.ts\";\nimport type { EffectRemoteFormSubmit, NativeMethod } from \"./types.ts\";\nimport { get_dispatcher } from \"$/dispatcher.ts\";\nimport { has_method } from \"./utils.ts\";\nimport { Effect } from \"effect\";\n\nexport function wrap_enhance_callback<Output, ErrorType = never>(\n\tcallback: NativeMethod | undefined,\n): NativeMethod | undefined {\n\tif (!callback) {\n\t\treturn undefined;\n\t}\n\n\treturn (event: unknown) => {\n\t\tconst wrapped_event = wrap_submit_callback<Output, ErrorType>(event);\n\t\tconst result = callback(wrapped_event);\n\n\t\tif (Effect.isEffect(result)) {\n\t\t\treturn get_dispatcher().run(result);\n\t\t}\n\n\t\treturn result;\n\t};\n}\n\nfunction wrap_submit_callback<Output, ErrorType>(event: unknown): unknown {\n\tif (typeof event !== \"object\" || event === null || !has_method(event, \"submit\")) {\n\t\treturn event;\n\t}\n\n\tconst original_submit = event.submit;\n\tconst { submit: _submit, ...descriptors } = Object.getOwnPropertyDescriptors(event);\n\n\tvoid _submit;\n\n\treturn Object.defineProperties(\n\t\t{},\n\t\t{\n\t\t\t...descriptors,\n\t\t\tsubmit: {\n\t\t\t\tconfigurable: true,\n\t\t\t\tenumerable: false,\n\t\t\t\tvalue: () => MakeSubmitEffect<Output, ErrorType>(original_submit, event),\n\t\t\t},\n\t\t},\n\t);\n}\n\nfunction MakeSubmitEffect<Output, ErrorType>(\n\toriginal_submit: NativeMethod,\n\tevent: unknown,\n): EffectRemoteFormSubmit<Output, ErrorType> {\n\tlet updates_args: unknown[] | undefined;\n\n\tconst SubmitEffect = Effect.gen(function* () {\n\t\tconst result = yield* MakeEffectFromSync<unknown, ErrorType>(() =>\n\t\t\toriginal_submit.call(event),\n\t\t);\n\t\tconst value = yield* ResolveSubmitResult<ErrorType>(result, updates_args);\n\n\t\tif (typeof value === \"boolean\") {\n\t\t\treturn read_submit_result<Output>(event);\n\t\t}\n\n\t\treturn value as Output;\n\t}) as EffectRemoteFormSubmit<Output, ErrorType>;\n\n\tObject.defineProperty(SubmitEffect, \"updates\", {\n\t\tconfigurable: true,\n\t\tenumerable: false,\n\t\tvalue: (...args: unknown[]) => {\n\t\t\tupdates_args ??= args;\n\n\t\t\treturn SubmitEffect;\n\t\t},\n\t});\n\n\treturn SubmitEffect;\n}\n\nconst ResolveSubmitResult = <ErrorType>(result: unknown, updates_args: unknown[] | undefined) =>\n\tEffect.gen(function* () {\n\t\tif (updates_args && has_method(result, \"updates\")) {\n\t\t\treturn yield* MakeEffectFromPromise<unknown, ErrorType>(() =>\n\t\t\t\tPromise.resolve(\n\t\t\t\t\tresult.updates(...resolve_native_remote_query_updates(updates_args)),\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\treturn yield* MakeEffectFromPromise<unknown, ErrorType>(() => Promise.resolve(result));\n\t});\n\nfunction read_submit_result<Output>(event: unknown): Output | undefined {\n\tif (typeof event !== \"object\" || event === null || !(\"result\" in event)) {\n\t\treturn undefined;\n\t}\n\n\treturn Reflect.get(event, \"result\") as Output | undefined;\n}\n","import { is_standard_schema, normalize_validator, type StandardSchema } from \"$/internal/schema.ts\";\nimport type { EffectRemoteForm, NativeFormRecord, NativeMethod } from \"./types.ts\";\nimport {\n\tget_remote_action_id,\n\tSubmitRemoteForm,\n\ttype RemoteFormTransport,\n} from \"./form-transport.ts\";\nimport { MakeEffectFromPromise, MakeEffectFromSync } from \"$/remote/effect.ts\";\nimport { copy_property_descriptors, has_method } from \"./utils.ts\";\nimport { wrap_enhance_callback } from \"./form-enhance.ts\";\nimport { DecodeResponseOrValue } from \"./responses.ts\";\nimport type { NativeRemoteFormInput } from \"$/remote/native-types.ts\";\nimport { Effect } from \"effect\";\n\ntype RemoteInput<Input> = undefined extends Input ? Input | void : Input;\n\ninterface RemoteFormAdapterState {\n\tshared_preflight_schema?: StandardSchema;\n}\n\n/** Adapts a generated SvelteKit form to SER's Effect-based client ABI. */\nexport function create_remote_form_adapter<\n\tInput extends NativeRemoteFormInput | void,\n\tOutput,\n\tErrorType = never,\n>(\n\tnative_factory: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n\tremote_base = \"\",\n\tremote_transport: RemoteFormTransport = {},\n\tadapter_state: RemoteFormAdapterState = {},\n\tkeyed = false,\n): EffectRemoteForm<Input, Output, ErrorType> {\n\tconst form_obj = native_factory as NativeFormRecord;\n\tlet local_preflight_schema: StandardSchema | undefined;\n\n\tconst SubmitForm = (input?: RemoteInput<Input>) =>\n\t\tEffect.gen(function* () {\n\t\t\tconst action_id = yield* MakeEffectFromSync<string | undefined, ErrorType>(() =>\n\t\t\t\tget_remote_action_id(form_obj),\n\t\t\t);\n\t\t\tconst can_use_remote_endpoint = remote_base.length > 0 && action_id !== undefined;\n\n\t\t\tif (has_method(form_obj, \"submit\") && !can_use_remote_endpoint) {\n\t\t\t\tconst result = yield* MakeEffectFromPromise<unknown, ErrorType>(() =>\n\t\t\t\t\tPromise.resolve(form_obj.submit(input)),\n\t\t\t\t);\n\n\t\t\t\treturn yield* DecodeResponseOrValue<Output, ErrorType>(result, decode_payload);\n\t\t\t}\n\n\t\t\treturn yield* SubmitRemoteForm<Output, ErrorType>(\n\t\t\t\tform_obj,\n\t\t\t\tinput,\n\t\t\t\tdecode_payload,\n\t\t\t\tremote_base,\n\t\t\t\tremote_transport,\n\t\t\t\tlocal_preflight_schema ?? adapter_state.shared_preflight_schema,\n\t\t\t);\n\t\t});\n\n\tconst callable = ((input?: RemoteInput<Input>) => SubmitForm(input)) as EffectRemoteForm<\n\t\tInput,\n\t\tOutput,\n\t\tErrorType\n\t>;\n\n\tcopy_property_descriptors(\n\t\tform_obj,\n\t\tcallable,\n\t\tnew Set([\"submit\", \"validate\", \"enhance\", \"for\", \"preflight\"]),\n\t);\n\n\tObject.defineProperty(callable, \"submit\", {\n\t\tconfigurable: true,\n\t\tenumerable: false,\n\t\tvalue: SubmitForm,\n\t});\n\n\tif (has_method(form_obj, \"validate\")) {\n\t\tconst validate = form_obj.validate;\n\n\t\tObject.defineProperty(callable, \"validate\", {\n\t\t\tconfigurable: true,\n\t\t\tenumerable: false,\n\t\t\tvalue: (options?: Record<string, unknown>) =>\n\t\t\t\tValidateRemoteForm<ErrorType>(form_obj, validate, options),\n\t\t});\n\t}\n\n\tif (has_method(form_obj, \"enhance\")) {\n\t\tObject.defineProperty(callable, \"enhance\", {\n\t\t\tconfigurable: true,\n\t\t\tenumerable: false,\n\t\t\tvalue: (callback?: NativeMethod) =>\n\t\t\t\tform_obj.enhance(wrap_enhance_callback<Output, ErrorType>(callback)),\n\t\t});\n\t}\n\n\tif (has_method(form_obj, \"for\")) {\n\t\tObject.defineProperty(callable, \"for\", {\n\t\t\tconfigurable: true,\n\t\t\tenumerable: false,\n\t\t\tvalue: (key: string | number | boolean) =>\n\t\t\t\tcreate_remote_form_adapter<Input, Output, ErrorType>(\n\t\t\t\t\tform_obj.for(key),\n\t\t\t\t\tdecode_payload,\n\t\t\t\t\tremote_base,\n\t\t\t\t\tremote_transport,\n\t\t\t\t\tadapter_state,\n\t\t\t\t\ttrue,\n\t\t\t\t),\n\t\t});\n\t}\n\n\tif (has_method(form_obj, \"preflight\")) {\n\t\tObject.defineProperty(callable, \"preflight\", {\n\t\t\tconfigurable: true,\n\t\t\tenumerable: false,\n\t\t\tvalue: (schema: unknown) => {\n\t\t\t\tconst normalized_schema = normalize_validator(schema);\n\n\t\t\t\tif (is_standard_schema(normalized_schema)) {\n\t\t\t\t\tlocal_preflight_schema = normalized_schema;\n\n\t\t\t\t\tif (!keyed) {\n\t\t\t\t\t\tadapter_state.shared_preflight_schema = normalized_schema;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tform_obj.preflight(normalized_schema);\n\n\t\t\t\treturn callable;\n\t\t\t},\n\t\t});\n\t}\n\n\treturn callable;\n}\n\nconst ValidateRemoteForm = <ErrorType>(\n\tform_obj: NativeFormRecord,\n\tvalidate: NativeMethod,\n\toptions: Record<string, unknown> | undefined,\n) =>\n\tEffect.gen(function* () {\n\t\tyield* MakeEffectFromPromise<unknown, ErrorType>(() =>\n\t\t\tPromise.resolve(validate.call(form_obj, normalize_validate_options(validate, options))),\n\t\t);\n\t});\n\nfunction normalize_validate_options(\n\tvalidate: NativeMethod,\n\toptions: Record<string, unknown> | undefined,\n): Record<string, unknown> | undefined {\n\tif (!options || !(\"all\" in options) || \"includeUntouched\" in options) {\n\t\treturn options;\n\t}\n\n\tconst source = Function.prototype.toString.call(validate);\n\tconst uses_stable_option = source.includes(\"includeUntouched\") && !/\\ball\\s*=/.test(source);\n\n\tif (!uses_stable_option) {\n\t\treturn options;\n\t}\n\n\treturn {\n\t\t...options,\n\t\tincludeUntouched: options.all,\n\t};\n}\n","import { DecodeResponseOrValue } from \"./responses.ts\";\nimport { MakeEffectFromPromise } from \"$/remote/effect.ts\";\nimport { has_method } from \"./utils.ts\";\nimport { Effect } from \"effect\";\n\nexport const ResolveQueryResult = <Output, ErrorType = never>(\n\tvalue: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n) =>\n\tEffect.gen(function* () {\n\t\tif (has_method(value, \"then\")) {\n\t\t\tconst result = yield* MakeEffectFromPromise<unknown, ErrorType>(() =>\n\t\t\t\tPromise.resolve(value),\n\t\t\t);\n\n\t\t\treturn yield* DecodeResponseOrValue<Output, ErrorType>(result, decode_payload);\n\t\t}\n\n\t\tif (has_method(value, \"run\")) {\n\t\t\tconst result = yield* MakeEffectFromPromise<unknown, ErrorType>(() =>\n\t\t\t\tPromise.resolve(value.run()),\n\t\t\t);\n\n\t\t\treturn yield* DecodeResponseOrValue<Output, ErrorType>(result, decode_payload);\n\t\t}\n\n\t\treturn yield* DecodeResponseOrValue<Output, ErrorType>(value, decode_payload);\n\t});\n","import {\n\tattach_failed_remote_resource_getters,\n\tattach_remote_resource_getters,\n\ttype RemoteResourceEffect,\n} from \"$/remote/resource.ts\";\nimport { InvalidPrerenderFactoryError } from \"$/errors.ts\";\nimport { FailWithRemoteError } from \"$/remote/effect.ts\";\nimport { copy_property_descriptors } from \"./utils.ts\";\nimport { ResolveQueryResult } from \"./query-result.ts\";\nimport type { NativeMethod } from \"./types.ts\";\nimport { Result } from \"effect\";\n\ntype RemoteInput<Input> = undefined extends Input ? Input | void : Input;\n\ntype EffectRemotePrerenderAdapter<Input, Output, ErrorType = never> = (\n\tinput: RemoteInput<Input>,\n) => RemoteResourceEffect<Output, ErrorType>;\n\nexport function create_remote_prerender_adapter<Input, Output, ErrorType = never>(\n\tnative_factory: unknown,\n\tdecode_payload: (value: unknown) => Output,\n): EffectRemotePrerenderAdapter<Input, Output, ErrorType>;\nexport function create_remote_prerender_adapter<Input, Output, ErrorType = never>(\n\tnative_factory: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n): EffectRemotePrerenderAdapter<Input, Output, ErrorType>;\nexport function create_remote_prerender_adapter<Input, Output, ErrorType = never>(\n\tnative_factory: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n): EffectRemotePrerenderAdapter<Input, Output, ErrorType> {\n\tif (typeof native_factory !== \"function\") {\n\t\tthrow new InvalidPrerenderFactoryError();\n\t}\n\n\tconst prerender = native_factory as NativeMethod;\n\tconst wrapped = ((input: RemoteInput<Input>) => {\n\t\tconst resource_attempt = Result.try(() => prerender(input));\n\n\t\tif (Result.isFailure(resource_attempt)) {\n\t\t\tconst PrerenderEffect = FailWithRemoteError<ErrorType>(\n\t\t\t\tresource_attempt.failure,\n\t\t\t) as unknown as RemoteResourceEffect<Output, ErrorType>;\n\n\t\t\tattach_failed_remote_resource_getters(resource_attempt.failure, PrerenderEffect);\n\n\t\t\treturn PrerenderEffect;\n\t\t}\n\n\t\tconst resource = resource_attempt.success;\n\t\tconst PrerenderEffect = ResolveQueryResult<Output, ErrorType>(\n\t\t\tresource,\n\t\t\tdecode_payload,\n\t\t) as RemoteResourceEffect<Output, ErrorType>;\n\n\t\tattach_remote_resource_getters(resource, PrerenderEffect);\n\n\t\treturn PrerenderEffect;\n\t}) as EffectRemotePrerenderAdapter<Input, Output, ErrorType>;\n\n\tcopy_property_descriptors(native_factory, wrapped);\n\n\treturn wrapped;\n}\n","import {\n\tattach_failed_remote_query_resource,\n\tattach_remote_resource_getters,\n\tis_remote_resource,\n\ttype NativeRemoteResource,\n\ttype RemoteResourceEffect,\n} from \"$/remote/resource.ts\";\nimport {\n\tmake_failed_remote_live_stream,\n\tmake_remote_live_stream,\n\ttype RemoteLiveStream,\n} from \"$/live.ts\";\nimport { InvalidLiveQueryFactoryError, InvalidQueryFactoryError } from \"$/errors.ts\";\nimport { FailWithRemoteError, MakeEffectFromPromise } from \"$/remote/effect.ts\";\nimport { attach_native_remote_query_update } from \"$/remote/query-update.ts\";\nimport type { EffectRemoteQueryUpdateBrand, NativeMethod } from \"./types.ts\";\nimport { copy_property_descriptors, has_method } from \"./utils.ts\";\nimport { normalize_native_error } from \"$/remote/failures.ts\";\nimport { ResolveQueryResult } from \"./query-result.ts\";\nimport { Effect, Result } from \"effect\";\n\ntype RemoteInput<Input> = undefined extends Input ? Input | void : Input;\n\ntype DecodePayload<Output> = (value: unknown) => Output;\n\ntype QueryAdapterMode = \"standard\" | \"batch\";\n\ntype NativeQueryFactory<Input> =\n\t| ((input: RemoteInput<Input>) => unknown)\n\t| {\n\t\t\treadonly load: (input: RemoteInput<Input>) => unknown;\n\t };\n\ntype RemoteQueryEffect<Output, ErrorType = never> = EffectRemoteQueryUpdateBrand &\n\tRemoteResourceEffect<Output, ErrorType> & {\n\t\treadonly refresh: () => Effect.Effect<void, unknown, never>;\n\t\treadonly set: (value: Output) => void;\n\t\treadonly withOverride: (update: (current: Output) => Output) => unknown;\n\t};\n\ntype NativeQueryResource<Output> = NativeRemoteResource<Output> & {\n\treadonly refresh?: () => Promise<void>;\n\treadonly set?: (value: Output) => void;\n\treadonly withOverride?: (update: (current: Output) => Output) => unknown;\n};\n\n/** Adapts a generated SvelteKit query to SER's Effect-based client ABI. */\nexport function create_remote_query_adapter<Input, Output, ErrorType = never>(\n\tnative_factory: NativeQueryFactory<Input>,\n\tdecode_payload: DecodePayload<Output>,\n\t_base?: string,\n\tmode?: QueryAdapterMode,\n): EffectRemoteQueryUpdateBrand &\n\t((input: RemoteInput<Input>) => RemoteQueryEffect<Output, ErrorType>);\nexport function create_remote_query_adapter<Input, Output, ErrorType = never>(\n\tnative_factory: NativeQueryFactory<Input>,\n\tdecode_payload: (value: unknown) => unknown,\n\t_base?: string,\n\tmode?: QueryAdapterMode,\n): EffectRemoteQueryUpdateBrand &\n\t((input: RemoteInput<Input>) => RemoteQueryEffect<Output, ErrorType>);\nexport function create_remote_query_adapter<Input, Output, ErrorType = never>(\n\tnative_factory: unknown,\n\tdecode_payload: DecodePayload<Output>,\n\t_base = \"\",\n\tmode: QueryAdapterMode = \"standard\",\n): EffectRemoteQueryUpdateBrand &\n\t((input: RemoteInput<Input>) => RemoteQueryEffect<Output, ErrorType>) {\n\tconst load = has_method(native_factory, \"load\") ? native_factory.load : undefined;\n\tconst query =\n\t\ttypeof native_factory === \"function\" ? (native_factory as NativeMethod) : undefined;\n\n\tif (!query && !load) {\n\t\tthrow new InvalidQueryFactoryError();\n\t}\n\n\tconst wrapped = ((input: RemoteInput<Input>) => {\n\t\tif (!query) {\n\t\t\treturn Effect.gen(function* () {\n\t\t\t\tconst result = yield* MakeEffectFromPromise<unknown, ErrorType>(() =>\n\t\t\t\t\tPromise.resolve(load?.call(native_factory, input)),\n\t\t\t\t);\n\n\t\t\t\treturn yield* ResolveQueryResult<Output, ErrorType>(result, decode_payload);\n\t\t\t}) as RemoteQueryEffect<Output, ErrorType>;\n\t\t}\n\n\t\tconst resource_attempt = Result.try(() => query(input));\n\n\t\tif (Result.isFailure(resource_attempt)) {\n\t\t\tconst QueryEffect = FailWithRemoteError<ErrorType>(\n\t\t\t\tresource_attempt.failure,\n\t\t\t) as unknown as RemoteQueryEffect<Output, ErrorType>;\n\n\t\t\tattach_failed_remote_query_resource(resource_attempt.failure, QueryEffect);\n\n\t\t\treturn QueryEffect;\n\t\t}\n\n\t\tconst resource = resource_attempt.success;\n\t\tconst query_result = mode === \"batch\" ? begin_batch_query_result(resource) : resource;\n\t\tconst QueryEffect = ResolveQueryResult<Output, ErrorType>(\n\t\t\tquery_result,\n\t\t\tdecode_payload,\n\t\t) as RemoteQueryEffect<Output, ErrorType>;\n\n\t\tattach_native_remote_query_update(QueryEffect, resource);\n\t\tattach_query_resource(resource, QueryEffect);\n\n\t\treturn QueryEffect;\n\t}) as EffectRemoteQueryUpdateBrand &\n\t\t((input: RemoteInput<Input>) => RemoteQueryEffect<Output, ErrorType>);\n\n\tcopy_property_descriptors(native_factory, wrapped);\n\tattach_native_remote_query_update(wrapped, native_factory);\n\n\treturn wrapped;\n}\n\nfunction begin_batch_query_result(resource: unknown): unknown {\n\tif (!has_method(resource, \"then\")) {\n\t\treturn resource;\n\t}\n\n\tconst result = Promise.resolve(resource);\n\n\tvoid result.catch(() => {});\n\n\treturn result;\n}\n\n/** Adapts a generated SvelteKit live query to SER's Effect-based client ABI. */\nexport function create_remote_live_query_adapter<Input, Output, ErrorType = never>(\n\tnative_factory: unknown,\n\t_decode_payload: (value: unknown) => unknown,\n\t_base = \"\",\n): EffectRemoteQueryUpdateBrand &\n\t((input: RemoteInput<Input>) => RemoteLiveStream<Output, ErrorType>) {\n\tconst query =\n\t\ttypeof native_factory === \"function\" ? (native_factory as NativeMethod) : undefined;\n\n\tif (!query) {\n\t\tthrow new InvalidLiveQueryFactoryError();\n\t}\n\n\tconst wrapped = ((input: Input) => {\n\t\tconst resource_attempt = Result.try(() => query(input));\n\n\t\tif (Result.isFailure(resource_attempt)) {\n\t\t\treturn make_failed_remote_live_stream<Output, ErrorType>(\n\t\t\t\tresource_attempt.failure,\n\t\t\t\tnormalize_native_error,\n\t\t\t);\n\t\t}\n\n\t\tconst resource = resource_attempt.success;\n\n\t\tconst stream = make_remote_live_stream<Output, ErrorType>(resource, normalize_native_error);\n\n\t\tattach_native_remote_query_update(stream, resource);\n\n\t\treturn stream;\n\t}) as EffectRemoteQueryUpdateBrand &\n\t\t((input: RemoteInput<Input>) => RemoteLiveStream<Output, ErrorType>);\n\n\tcopy_property_descriptors(native_factory, wrapped);\n\tattach_native_remote_query_update(wrapped, native_factory);\n\n\treturn wrapped;\n}\n\nfunction attach_query_resource<Output, ErrorType = never>(\n\tresource: unknown,\n\teffect: RemoteQueryEffect<Output, ErrorType>,\n): void {\n\tconst methods = is_remote_resource<Output>(resource)\n\t\t? (resource as NativeQueryResource<Output>)\n\t\t: undefined;\n\tconst refresh = methods?.refresh;\n\tconst set = methods?.set;\n\tconst with_override = methods?.withOverride;\n\n\tattach_remote_resource_getters(resource, effect);\n\n\tif (!methods) {\n\t\treturn;\n\t}\n\n\tif (typeof refresh === \"function\") {\n\t\tObject.defineProperty(effect, \"refresh\", {\n\t\t\tconfigurable: true,\n\t\t\tvalue: () => RefreshRemoteResource(resource, refresh),\n\t\t});\n\t}\n\n\tif (typeof set === \"function\") {\n\t\tObject.defineProperty(effect, \"set\", {\n\t\t\tconfigurable: true,\n\t\t\tvalue: (value: Output) => set.call(resource, value),\n\t\t});\n\t}\n\n\tif (typeof with_override === \"function\") {\n\t\tObject.defineProperty(effect, \"withOverride\", {\n\t\t\tconfigurable: true,\n\t\t\tvalue: (update: (current: Output) => Output) => with_override.call(resource, update),\n\t\t});\n\t}\n}\n\nconst RefreshRemoteResource = (resource: unknown, refresh: () => Promise<void>) =>\n\tEffect.gen(function* () {\n\t\tyield* MakeEffectFromPromise(() => Promise.resolve(refresh.call(resource)));\n\t});\n"],"mappings":";;;;;;;;AAGA,SAAgB,WACf,OACA,KACmC;CACnC,MAAM,aAAa,OAAO;CAE1B,QACG,eAAe,YAAY,UAAU,QAAS,eAAe,eAC/D,OAAQ,MAAuC,SAAS;AAE1D;;;ACPA,MAAa,yBAA4C,aACxD,OAAO,IAAI,aAAa;CACvB,MAAM,OAAO,OAAO,4BAAgD,SAAS,KAAK,CAAC,CAAC,CAAC,KACpF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QAAQ,QAAQ;EAElD,OAAO;CACR;CAGA,0BAA0B,gBAAgB,OAAO;CACjD,kCAAkC,SAAS,cAAc;CAEzD,OAAO;AACR;AAEA,SAAS,sBACR,UACA,QACO;CACP,MAAM,UAAU,mBAA2B,QAAQ,IAC/C,WACD,KAAA;CACH,MAAM,UAAU,SAAS;CACzB,MAAM,MAAM,SAAS;CACrB,MAAM,gBAAgB,SAAS;CAE/B,+BAA+B,UAAU,MAAM;CAE/C,IAAI,CAAC,SACJ;CAGD,IAAI,OAAO,YAAY,YACtB,OAAO,eAAe,QAAQ,WAAW;EACxC,cAAc;EACd,aAAa,sBAAsB,UAAU,OAAO;CACrD,CAAC;CAGF,IAAI,OAAO,QAAQ,YAClB,OAAO,eAAe,QAAQ,OAAO;EACpC,cAAc;EACd,QAAQ,UAAkB,IAAI,KAAK,UAAU,KAAK;CACnD,CAAC;CAGF,IAAI,OAAO,kBAAkB,YAC5B,OAAO,eAAe,QAAQ,gBAAgB;EAC7C,cAAc;EACd,QAAQ,WAAwC,cAAc,KAAK,UAAU,MAAM;CACpF,CAAC;AAEH;AAEA,MAAM,yBAAyB,UAAmB,YACjD,OAAO,IAAI,aAAa;CACvB,OAAO,4BAA4B,QAAQ,QAAQ,QAAQ,KAAK,QAAQ,CAAC,CAAC;AAC3E,CAAC"}
|
|
@@ -348,14 +348,17 @@ function make_remote_client_wrapper_plugin(options) {
|
|
|
348
348
|
map: null
|
|
349
349
|
};
|
|
350
350
|
}
|
|
351
|
-
if (!is_remote_module(id)
|
|
351
|
+
if (!is_remote_module(id)) return;
|
|
352
|
+
const remote_client = await import("./remote-client-C_3kdug0.js");
|
|
353
|
+
const runtime_specifier = remote_client.find_remote_client_runtime_specifier(code);
|
|
354
|
+
if (!runtime_specifier) return;
|
|
352
355
|
const has_remote_form = /\.[\s\n]*form[\s\n]*\(/.test(code);
|
|
353
356
|
has_remote_form_module ||= has_remote_form;
|
|
354
357
|
if (has_remote_form) {
|
|
355
|
-
const resolved_runtime = await this.resolve(
|
|
358
|
+
const resolved_runtime = await this.resolve(runtime_specifier, id);
|
|
356
359
|
if (!resolved_runtime || !is_sveltekit_remote_runtime_index(resolved_runtime.id)) this.error(make_missing_sveltekit_remote_runtime_message());
|
|
357
360
|
}
|
|
358
|
-
const rewritten =
|
|
361
|
+
const rewritten = remote_client.rewrite_remote_client_exports(code, options);
|
|
359
362
|
if (rewritten === code) return;
|
|
360
363
|
return {
|
|
361
364
|
code: rewritten,
|
|
@@ -404,9 +407,9 @@ function may_have_ser_syntax(code) {
|
|
|
404
407
|
* @internal
|
|
405
408
|
*/
|
|
406
409
|
async function rewrite_remote_client_exports(code, options) {
|
|
407
|
-
return (await import("./remote-client-
|
|
410
|
+
return (await import("./remote-client-C_3kdug0.js")).rewrite_remote_client_exports(code, options);
|
|
408
411
|
}
|
|
409
412
|
//#endregion
|
|
410
413
|
export { rewrite_remote_client_exports as n, effect as t };
|
|
411
414
|
|
|
412
|
-
//# sourceMappingURL=compiler-
|
|
415
|
+
//# sourceMappingURL=compiler-B2htZszc.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compiler-Dpyu4Owd.js","names":["candidate"],"sources":["../../../modules/svelte-effect-runtime/src/compiler/sveltekit-remote-bridge.ts","../../../modules/svelte-effect-runtime/src/compiler.ts"],"sourcesContent":["const sveltekit_remote_runtime_suffix =\n\t\"/node_modules/@sveltejs/kit/src/runtime/client/remote-functions/index.js\";\n\nconst expected_sveltekit_remote_exports = [\n\t[\"command\", \"./command.svelte.js\"],\n\t[\"form\", \"./form.svelte.js\"],\n\t[\"prerender\", \"./prerender.svelte.js\"],\n\t[\"query\", \"./query/index.js\"],\n\t[\"query_batch\", \"./query-batch.svelte.js\"],\n\t[\"query_live\", \"./query-live/index.js\"],\n] as const;\n\nconst sveltekit_remote_bridge_exports = [\n\t`export { remote_request as __SER___remote_request } from './shared.svelte.js';`,\n\t`export { serialize_binary_form as __SER___serialize_binary_form, BINARY_FORM_CONTENT_TYPE as __SER___binary_form_content_type } from '../../form-utils.js';`,\n] as const;\n\nconst sveltekit_remote_bridge_names = [\n\t\"__SER___remote_request\",\n\t\"__SER___serialize_binary_form\",\n\t\"__SER___binary_form_content_type\",\n] as const;\n\nexport function is_sveltekit_remote_runtime_index(id: string): boolean {\n\tconst [filename] = id.split(\"?\", 2);\n\tconst normalized_filename = filename.replaceAll(\"\\\\\", \"/\");\n\n\treturn normalized_filename.endsWith(sveltekit_remote_runtime_suffix);\n}\n\nexport function append_sveltekit_remote_transport_bridge(code: string): string {\n\tconst has_complete_bridge = sveltekit_remote_bridge_exports.every((statement) =>\n\t\tcode.includes(statement),\n\t);\n\tconst present_bridge_names = sveltekit_remote_bridge_names.filter((name) =>\n\t\tcode.includes(name),\n\t);\n\n\tif (has_complete_bridge) {\n\t\treturn code;\n\t}\n\n\tif (present_bridge_names.length > 0) {\n\t\tthrow new Error(\n\t\t\tmake_unsupported_sveltekit_remote_runtime_message(\n\t\t\t\t`found an incomplete SER transport bridge (${present_bridge_names.join(\", \")})`,\n\t\t\t),\n\t\t);\n\t}\n\n\tconst missing_exports = expected_sveltekit_remote_exports\n\t\t.filter(([name, source]) => !has_named_reexport(code, name, source))\n\t\t.map(([name, source]) => `${name} from ${source}`);\n\n\tif (missing_exports.length > 0) {\n\t\tthrow new Error(\n\t\t\tmake_unsupported_sveltekit_remote_runtime_message(\n\t\t\t\t`missing ${missing_exports.join(\", \")}`,\n\t\t\t),\n\t\t);\n\t}\n\n\treturn `${code.trimEnd()}\\n${sveltekit_remote_bridge_exports.join(\"\\n\")}\\n`;\n}\n\nexport function make_missing_sveltekit_remote_runtime_message(): string {\n\treturn make_unsupported_sveltekit_remote_runtime_message(\n\t\t\"the generated client used a remote form, but the Kit client runtime index was not found\",\n\t);\n}\n\nfunction has_named_reexport(code: string, name: string, source: string): boolean {\n\tconst escaped_name = escape_regular_expression(name);\n\tconst escaped_source = escape_regular_expression(source);\n\tconst pattern = new RegExp(\n\t\t`export\\\\s*\\\\{\\\\s*${escaped_name}\\\\s*\\\\}\\\\s*from\\\\s*[\"']${escaped_source}[\"']\\\\s*;?`,\n\t);\n\n\treturn pattern.test(code);\n}\n\nfunction escape_regular_expression(value: string): string {\n\treturn value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\nfunction make_unsupported_sveltekit_remote_runtime_message(reason: string): string {\n\treturn [\n\t\t\"Unsupported @sveltejs/kit remote client runtime.\",\n\t\treason,\n\t\t\"SER expects the remote runtime layout used by SvelteKit 2.69.x and 3.0.0-next.x.\",\n\t].join(\" \");\n}\n","import {\n\tappend_sveltekit_remote_transport_bridge,\n\tis_sveltekit_remote_runtime_index,\n\tmake_missing_sveltekit_remote_runtime_message,\n} from \"./compiler/sveltekit-remote-bridge.ts\";\nimport type { Plugin } from \"vite\";\n\n/**\n * Options for the {@link effect} Vite plugin.\n *\n * @example\n * ```ts\n * const options: EffectOptions = { debug: true };\n * const plugins = effect(options);\n * ```\n *\n * @since 2.0.0\n */\nexport interface EffectOptions {\n\t/** Whether to emit debug logging in the generated remote client module. */\n\tdebug?: boolean;\n}\n\ninterface SvelteComponentModuleFilter {\n\tset_extensions(extensions: readonly string[]): void;\n\tis_module(id: string): boolean;\n}\n\ninterface VitePluginSvelteApi {\n\toptions?: {\n\t\textensions?: readonly unknown[];\n\t};\n}\n\ntype VitePluginSvelte = Plugin & {\n\tapi?: VitePluginSvelteApi;\n};\n\ntype VitePluginSvelteWithExtensions = Plugin & {\n\tapi: {\n\t\toptions: {\n\t\t\textensions: readonly string[];\n\t\t};\n\t};\n};\n\nconst default_svelte_component_extensions = [\".svelte\"] as const;\n\n/**\n * Vite plugin for SvelteKit. The server import plugin rewrites server-side\n * imports to the server entrypoint; the remote client plugin wraps SvelteKit's\n * generated client remote exports in Effect-returning adapters.\n *\n * @example\n * ```ts\n * import { effect } from \"svelte-effect-runtime/compiler\";\n * import { sveltekit } from \"@sveltejs/kit/vite\";\n *\n * export default defineConfig({ plugins: [effect(), sveltekit()] });\n * ```\n *\n * @since 2.0.0\n * @param options - Optional configuration.\n * @returns Vite plugins that integrate the runtime with SvelteKit.\n */\nexport function effect(options?: EffectOptions): Plugin[] {\n\tconst component_filter = make_svelte_component_module_filter();\n\n\treturn [\n\t\tmake_diagnostics_plugin(component_filter),\n\t\tmake_svelte_transform_plugin(component_filter),\n\t\tmake_server_rewrite_plugin(),\n\t\tmake_remote_client_wrapper_plugin(options),\n\t];\n}\n\nfunction make_diagnostics_plugin(component_filter: SvelteComponentModuleFilter): Plugin {\n\tconst warned_diagnostics = new Set<string>();\n\n\treturn {\n\t\tname: \"svelte-effect-runtime:diagnostics\",\n\n\t\tasync transform(code: string, id: string) {\n\t\t\tif (!component_filter.is_module(id) || !may_have_effect_diagnostics(code)) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst clean_id = id.split(\"?\")[0] ?? id;\n\t\t\tconst { find_svelte_effect_diagnostics } = await import(\"./diagnostics.ts\");\n\t\t\tconst diagnostics = find_svelte_effect_diagnostics(code, clean_id);\n\n\t\t\tfor (const diagnostic of diagnostics) {\n\t\t\t\tconst diagnostic_key = [\n\t\t\t\t\tclean_id,\n\t\t\t\t\tdiagnostic.line,\n\t\t\t\t\tdiagnostic.column,\n\t\t\t\t\tdiagnostic.message,\n\t\t\t\t].join(\":\");\n\n\t\t\t\tif (warned_diagnostics.has(diagnostic_key)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\twarned_diagnostics.add(diagnostic_key);\n\n\t\t\t\tthis.warn({\n\t\t\t\t\tid: clean_id,\n\t\t\t\t\tmessage: diagnostic.message,\n\t\t\t\t\tloc: {\n\t\t\t\t\t\tline: diagnostic.line,\n\t\t\t\t\t\tcolumn: diagnostic.column,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn undefined;\n\t\t},\n\t};\n}\n\nfunction make_svelte_transform_plugin(component_filter: SvelteComponentModuleFilter): Plugin {\n\treturn {\n\t\tname: \"svelte-effect-runtime:svelte-transform\",\n\n\t\tconfigResolved(config) {\n\t\t\tconst extensions = find_svelte_component_extensions(config.plugins);\n\t\t\tconst conflicting_plugin_names = find_pre_transform_plugin_names(config.plugins);\n\n\t\t\tif (extensions) {\n\t\t\t\tcomponent_filter.set_extensions(extensions);\n\t\t\t}\n\n\t\t\tif (conflicting_plugin_names.length === 0) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconfig.logger.info(make_pre_transform_plugin_notice(conflicting_plugin_names));\n\t\t},\n\n\t\tasync transform(code: string, id: string, options?: { ssr?: boolean | undefined }) {\n\t\t\tif (!component_filter.is_module(id) || !may_have_ser_syntax(code)) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst { transform_svelte_effect } = await import(\"./runtime/transform.ts\");\n\t\t\tconst result = transform_svelte_effect(code, id, {\n\t\t\t\ttarget: options?.ssr ? \"server\" : \"client\",\n\t\t\t});\n\n\t\t\tif (result.code === code) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\treturn { code: result.code, map: null };\n\t\t},\n\t};\n}\n\nfunction make_svelte_component_module_filter(): SvelteComponentModuleFilter {\n\tlet extensions: readonly string[] = default_svelte_component_extensions;\n\n\treturn {\n\t\tset_extensions(next_extensions) {\n\t\t\tconst normalized_extensions = normalize_svelte_component_extensions(next_extensions);\n\n\t\t\tif (normalized_extensions.length === 0) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\textensions = normalized_extensions;\n\t\t},\n\n\t\tis_module(id) {\n\t\t\treturn is_svelte_component_module(id, extensions);\n\t\t},\n\t};\n}\n\nfunction normalize_svelte_component_extensions(extensions: readonly string[]): string[] {\n\tconst normalized_extensions = extensions\n\t\t.filter((extension) => extension.length > 0)\n\t\t.map((extension) => (extension.startsWith(\".\") ? extension : `.${extension}`));\n\n\treturn [...new Set(normalized_extensions)];\n}\n\nfunction find_svelte_component_extensions(\n\tplugins: readonly Plugin[],\n): readonly string[] | undefined {\n\tconst svelte_plugin = plugins.find(has_svelte_component_extensions);\n\n\treturn svelte_plugin?.api?.options?.extensions;\n}\n\nfunction has_svelte_component_extensions(plugin: Plugin): plugin is VitePluginSvelteWithExtensions {\n\tconst candidate = plugin as VitePluginSvelte;\n\tconst extensions = candidate.api?.options?.extensions;\n\n\tif (!plugin.name.startsWith(\"vite-plugin-svelte\")) {\n\t\treturn false;\n\t}\n\n\treturn (\n\t\tArray.isArray(extensions) && extensions.every((extension) => typeof extension === \"string\")\n\t);\n}\n\nfunction find_pre_transform_plugin_names(plugins: readonly Plugin[]): string[] {\n\treturn plugins\n\t\t.filter(\n\t\t\t(plugin) =>\n\t\t\t\t!plugin.name.startsWith(\"svelte-effect-runtime:\") &&\n\t\t\t\t!is_known_framework_pre_transform_plugin(plugin.name) &&\n\t\t\t\thas_pre_transform_priority(plugin),\n\t\t)\n\t\t.map((plugin) => plugin.name);\n}\n\nconst ansi_reset = \"\\x1b[0m\";\nconst ansi_light_green = \"\\x1b[92m\";\n\nfunction make_pre_transform_plugin_notice(plugin_names: readonly string[]): string {\n\tconst formatted_plugins = plugin_names.map((plugin_name) => ` - ${plugin_name}`).join(\"\\n\");\n\n\treturn [\n\t\t`${ansi_light_green}[svelte-effect-runtime]${ansi_reset} Svelte Effect Runtime noticed possible Vite plugin ordering conflicts.`,\n\t\t\"\",\n\t\t\"These plugins run before normal Svelte component transforms:\",\n\t\tformatted_plugins,\n\t\t\"\",\n\t\t\"This is usually fine, but if you see Svelte parser errors around <script effect>\",\n\t\t\"or yield* in components, one of those plugins may be reading component files before\",\n\t\t\"SER has lowered its syntax.\",\n\t].join(\"\\n\");\n}\n\nfunction is_known_framework_pre_transform_plugin(name: string): boolean {\n\treturn name.startsWith(\"vite:\") || name === \"vite-plugin-svelte:preprocess\";\n}\n\nfunction has_pre_transform_priority(plugin: Plugin): boolean {\n\tif (plugin.enforce === \"pre\" && plugin.transform) {\n\t\treturn true;\n\t}\n\n\tif (\n\t\ttypeof plugin.transform === \"object\" &&\n\t\tplugin.transform !== null &&\n\t\t\"order\" in plugin.transform &&\n\t\tplugin.transform.order === \"pre\"\n\t) {\n\t\treturn true;\n\t}\n\n\treturn false;\n}\n\nfunction make_server_rewrite_plugin(): Plugin {\n\treturn {\n\t\tname: \"svelte-effect-runtime:server-imports\",\n\n\t\tconfig() {\n\t\t\treturn { optimizeDeps: { exclude: [\"svelte-effect-runtime\"] } };\n\t\t},\n\n\t\tasync transform(code: string, id: string) {\n\t\t\tif (!is_server_runtime_module(id)) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tif (!code.includes(\"svelte-effect-runtime\")) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst rewritten = await rewrite_server_imports(code, id);\n\n\t\t\tif (rewritten === code) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\treturn { code: rewritten, map: null };\n\t\t},\n\t};\n}\n\nasync function rewrite_server_imports(code: string, id: string): Promise<string> {\n\tconst [{ default: MagicString }, ts] = await Promise.all([\n\t\timport(\"magic-string\"),\n\t\timport(\"typescript\"),\n\t]);\n\tconst filename = id.split(\"?\", 2)[0] ?? id;\n\tconst source_file = ts.createSourceFile(\n\t\tfilename,\n\t\tcode,\n\t\tts.ScriptTarget.Latest,\n\t\ttrue,\n\t\tget_script_kind(filename, ts),\n\t);\n\tconst magic = new MagicString(code);\n\tconst ser_prerender_imports = is_remote_module(id)\n\t\t? source_file.statements.flatMap((statement) => {\n\t\t\t\tif (\n\t\t\t\t\t!ts.isImportDeclaration(statement) ||\n\t\t\t\t\t!ts.isStringLiteralLike(statement.moduleSpecifier) ||\n\t\t\t\t\t!is_ser_server_import(statement.moduleSpecifier.text)\n\t\t\t\t) {\n\t\t\t\t\treturn [];\n\t\t\t\t}\n\n\t\t\t\tconst bindings = statement.importClause?.namedBindings;\n\n\t\t\t\tif (\n\t\t\t\t\tstatement.importClause?.isTypeOnly === true ||\n\t\t\t\t\t!bindings ||\n\t\t\t\t\t!ts.isNamedImports(bindings)\n\t\t\t\t) {\n\t\t\t\t\treturn [];\n\t\t\t\t}\n\n\t\t\t\treturn bindings.elements.filter(\n\t\t\t\t\t(element) =>\n\t\t\t\t\t\t!element.isTypeOnly &&\n\t\t\t\t\t\t(element.propertyName?.text ?? element.name.text) === \"Prerender\",\n\t\t\t\t);\n\t\t\t})\n\t\t: [];\n\tconst prerender_binding_names = new Set(\n\t\tser_prerender_imports.map((element) => element.name.text),\n\t);\n\tconst prerender_namespace_names = new Set(\n\t\tis_remote_module(id)\n\t\t\t? source_file.statements.flatMap((statement) => {\n\t\t\t\t\tif (\n\t\t\t\t\t\t!ts.isImportDeclaration(statement) ||\n\t\t\t\t\t\t!ts.isStringLiteralLike(statement.moduleSpecifier) ||\n\t\t\t\t\t\t!is_ser_server_import(statement.moduleSpecifier.text) ||\n\t\t\t\t\t\tstatement.importClause?.isTypeOnly === true ||\n\t\t\t\t\t\tstatement.importClause?.namedBindings === undefined ||\n\t\t\t\t\t\t!ts.isNamespaceImport(statement.importClause.namedBindings)\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn [];\n\t\t\t\t\t}\n\n\t\t\t\t\treturn [statement.importClause.namedBindings.name.text];\n\t\t\t\t})\n\t\t\t: [],\n\t);\n\tconst ser_prerender_calls = collect_exported_ser_prerender_calls(\n\t\tsource_file,\n\t\tprerender_binding_names,\n\t\tprerender_namespace_names,\n\t\tts,\n\t);\n\tconst has_sveltekit_prerender_import = source_file.statements.some(\n\t\t(statement) =>\n\t\t\tts.isImportDeclaration(statement) &&\n\t\t\tts.isStringLiteralLike(statement.moduleSpecifier) &&\n\t\t\tstatement.moduleSpecifier.text === \"$app/server\" &&\n\t\t\tstatement.importClause?.isTypeOnly !== true &&\n\t\t\tstatement.importClause?.namedBindings !== undefined &&\n\t\t\tts.isNamedImports(statement.importClause.namedBindings) &&\n\t\t\tstatement.importClause.namedBindings.elements.some(\n\t\t\t\t(element) =>\n\t\t\t\t\t!element.isTypeOnly &&\n\t\t\t\t\t(element.propertyName?.text ?? element.name.text) === \"prerender\" &&\n\t\t\t\t\telement.name.text === \"prerender\",\n\t\t\t),\n\t);\n\tconst has_top_level_prerender_binding = source_file.statements.some((statement) =>\n\t\tdeclares_top_level_value_binding(statement, \"prerender\", ts),\n\t);\n\tlet changed = false;\n\n\tif (ser_prerender_calls.size > 0 && !has_sveltekit_prerender_import) {\n\t\tif (has_top_level_prerender_binding) {\n\t\t\tthrow new Error(\n\t\t\t\t`[svelte-effect-runtime] ${filename}: Prerender remote modules reserve the top-level \"prerender\" binding for SvelteKit. Rename the existing binding.`,\n\t\t\t);\n\t\t}\n\n\t\tconst last_import = [...source_file.statements].reverse().find(ts.isImportDeclaration);\n\t\tconst native_import = `import { prerender } from \"$app/server\";`;\n\n\t\tif (last_import) {\n\t\t\tmagic.appendRight(last_import.end, `\\n${native_import}`);\n\t\t} else {\n\t\t\tmagic.prepend(`${native_import}\\n`);\n\t\t}\n\n\t\tchanged = true;\n\t}\n\n\tconst rewrite_specifier = (specifier: import(\"typescript\").StringLiteralLike) => {\n\t\tconst replacement = get_server_import_replacement(specifier.text);\n\n\t\tif (!replacement) {\n\t\t\treturn;\n\t\t}\n\n\t\tmagic.overwrite(\n\t\t\tspecifier.getStart(source_file),\n\t\t\tspecifier.end,\n\t\t\tJSON.stringify(replacement),\n\t\t);\n\t\tchanged = true;\n\t};\n\n\tconst visit = (node: import(\"typescript\").Node) => {\n\t\tif (ts.isImportDeclaration(node) && ts.isStringLiteralLike(node.moduleSpecifier)) {\n\t\t\trewrite_specifier(node.moduleSpecifier);\n\t\t}\n\n\t\tif (\n\t\t\tts.isExportDeclaration(node) &&\n\t\t\tnode.moduleSpecifier &&\n\t\t\tts.isStringLiteralLike(node.moduleSpecifier)\n\t\t) {\n\t\t\trewrite_specifier(node.moduleSpecifier);\n\t\t}\n\n\t\tif (ts.isCallExpression(node) && node.expression.kind === ts.SyntaxKind.ImportKeyword) {\n\t\t\tconst [specifier] = node.arguments;\n\n\t\t\tif (specifier && ts.isStringLiteralLike(specifier)) {\n\t\t\t\trewrite_specifier(specifier);\n\t\t\t}\n\t\t}\n\n\t\tif (ts.isCallExpression(node) && ser_prerender_calls.has(node)) {\n\t\t\tconst missing_arguments = Math.max(0, 3 - node.arguments.length);\n\t\t\tconst injected_arguments = [\n\t\t\t\t...Array.from({ length: missing_arguments }, () => \"undefined\"),\n\t\t\t\t\"prerender\",\n\t\t\t];\n\t\t\tconst separator =\n\t\t\t\tnode.arguments.length === 0 || node.arguments.hasTrailingComma ? \"\" : \",\";\n\n\t\t\tmagic.appendLeft(node.end - 1, `${separator} ${injected_arguments.join(\", \")}`);\n\t\t\tchanged = true;\n\t\t}\n\n\t\tts.forEachChild(node, visit);\n\t};\n\n\tvisit(source_file);\n\n\treturn changed ? magic.toString() : code;\n}\n\nfunction is_ser_server_import(specifier: string): boolean {\n\treturn specifier === \"svelte-effect-runtime\" || specifier === \"svelte-effect-runtime/server\";\n}\n\nfunction is_ser_prerender_callee(\n\texpression: import(\"typescript\").Expression,\n\tbinding_names: ReadonlySet<string>,\n\tnamespace_names: ReadonlySet<string>,\n\tts: typeof import(\"typescript\"),\n): boolean {\n\tif (ts.isIdentifier(expression)) {\n\t\treturn binding_names.has(expression.text);\n\t}\n\n\treturn (\n\t\tts.isPropertyAccessExpression(expression) &&\n\t\tts.isIdentifier(expression.expression) &&\n\t\tnamespace_names.has(expression.expression.text) &&\n\t\texpression.name.text === \"Prerender\"\n\t);\n}\n\nfunction collect_exported_ser_prerender_calls(\n\tsource_file: import(\"typescript\").SourceFile,\n\tbinding_names: ReadonlySet<string>,\n\tnamespace_names: ReadonlySet<string>,\n\tts: typeof import(\"typescript\"),\n): ReadonlySet<import(\"typescript\").CallExpression> {\n\tconst calls = new Set<import(\"typescript\").CallExpression>();\n\n\tconst visit = (node: import(\"typescript\").Node) => {\n\t\tif (\n\t\t\tts.isCallExpression(node) &&\n\t\t\tis_ser_prerender_callee(node.expression, binding_names, namespace_names, ts) &&\n\t\t\tis_exported_variable_initializer(node, ts)\n\t\t) {\n\t\t\tcalls.add(node);\n\t\t}\n\n\t\tts.forEachChild(node, visit);\n\t};\n\n\tvisit(source_file);\n\n\treturn calls;\n}\n\nfunction is_exported_variable_initializer(\n\tnode: import(\"typescript\").CallExpression,\n\tts: typeof import(\"typescript\"),\n): boolean {\n\tlet initializer: import(\"typescript\").Expression = node;\n\tlet parent = initializer.parent;\n\n\twhile (is_transparent_expression_wrapper(parent, initializer, ts)) {\n\t\tinitializer = parent;\n\t\tparent = initializer.parent;\n\t}\n\n\tif (!ts.isVariableDeclaration(parent) || parent.initializer !== initializer) {\n\t\treturn false;\n\t}\n\n\tconst statement = parent.parent.parent;\n\n\treturn (\n\t\tts.isVariableStatement(statement) &&\n\t\tstatement.modifiers?.some((modifier) => modifier.kind === ts.SyntaxKind.ExportKeyword) ===\n\t\t\ttrue\n\t);\n}\n\nfunction is_transparent_expression_wrapper(\n\tparent: import(\"typescript\").Node,\n\texpression: import(\"typescript\").Expression,\n\tts: typeof import(\"typescript\"),\n): parent is import(\"typescript\").Expression {\n\treturn (\n\t\t(ts.isParenthesizedExpression(parent) ||\n\t\t\tts.isAsExpression(parent) ||\n\t\t\tts.isSatisfiesExpression(parent) ||\n\t\t\tts.isTypeAssertionExpression(parent) ||\n\t\t\tts.isNonNullExpression(parent)) &&\n\t\tparent.expression === expression\n\t);\n}\n\nfunction declares_top_level_value_binding(\n\tstatement: import(\"typescript\").Statement,\n\tname: string,\n\tts: typeof import(\"typescript\"),\n): boolean {\n\tif (ts.isImportDeclaration(statement)) {\n\t\tconst import_clause = statement.importClause;\n\n\t\tif (!import_clause || import_clause.isTypeOnly) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (import_clause.name?.text === name) {\n\t\t\treturn true;\n\t\t}\n\n\t\tconst bindings = import_clause.namedBindings;\n\n\t\tif (bindings && ts.isNamespaceImport(bindings)) {\n\t\t\treturn bindings.name.text === name;\n\t\t}\n\n\t\treturn (\n\t\t\tbindings?.elements.some(\n\t\t\t\t(element) => !element.isTypeOnly && element.name.text === name,\n\t\t\t) === true\n\t\t);\n\t}\n\n\tif (ts.isVariableStatement(statement)) {\n\t\treturn statement.declarationList.declarations.some((declaration) =>\n\t\t\tbinding_name_contains(declaration.name, name, ts),\n\t\t);\n\t}\n\n\tif (\n\t\tts.isFunctionDeclaration(statement) ||\n\t\tts.isClassDeclaration(statement) ||\n\t\tts.isEnumDeclaration(statement) ||\n\t\tts.isModuleDeclaration(statement)\n\t) {\n\t\treturn statement.name?.getText() === name;\n\t}\n\n\treturn ts.isImportEqualsDeclaration(statement) && statement.name.text === name;\n}\n\nfunction binding_name_contains(\n\tbinding: import(\"typescript\").BindingName,\n\tname: string,\n\tts: typeof import(\"typescript\"),\n): boolean {\n\tif (ts.isIdentifier(binding)) {\n\t\treturn binding.text === name;\n\t}\n\n\treturn binding.elements.some(\n\t\t(element) =>\n\t\t\t!ts.isOmittedExpression(element) && binding_name_contains(element.name, name, ts),\n\t);\n}\n\nfunction get_server_import_replacement(specifier: string): string | undefined {\n\tif (specifier === \"svelte-effect-runtime\") {\n\t\treturn \"svelte-effect-runtime/server\";\n\t}\n\n\tif (specifier === \"svelte-effect-runtime/internal/generators\") {\n\t\treturn \"svelte-effect-runtime/server\";\n\t}\n\n\treturn undefined;\n}\n\nfunction get_script_kind(filename: string, ts: typeof import(\"typescript\")) {\n\tconst normalized_filename = filename.toLowerCase();\n\n\tif (has_file_extension(normalized_filename, [\".tsx\"])) {\n\t\treturn ts.ScriptKind.TSX;\n\t}\n\n\tif (has_file_extension(normalized_filename, [\".jsx\"])) {\n\t\treturn ts.ScriptKind.JSX;\n\t}\n\n\tif (has_file_extension(normalized_filename, [\".js\", \".mjs\", \".cjs\"])) {\n\t\treturn ts.ScriptKind.JS;\n\t}\n\n\treturn ts.ScriptKind.TS;\n}\n\nfunction has_file_extension(filename: string, extensions: readonly string[]): boolean {\n\treturn extensions.some((extension) => filename.endsWith(extension));\n}\n\nfunction make_remote_client_wrapper_plugin(options?: EffectOptions): Plugin {\n\tlet has_remote_form_module = false;\n\tlet has_sveltekit_remote_bridge = false;\n\n\treturn {\n\t\tname: \"svelte-effect-runtime:remote-client\",\n\t\tenforce: \"post\",\n\n\t\tbuildStart() {\n\t\t\thas_remote_form_module = false;\n\t\t\thas_sveltekit_remote_bridge = false;\n\t\t},\n\n\t\tbuildEnd(error) {\n\t\t\tif (error || !has_remote_form_module || has_sveltekit_remote_bridge) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.error(make_missing_sveltekit_remote_runtime_message());\n\t\t},\n\n\t\tconfig() {\n\t\t\treturn { ssr: { noExternal: [\"svelte-effect-runtime\"] } };\n\t\t},\n\n\t\tconfigResolved(config) {\n\t\t\tconst no_external = config.ssr.noExternal;\n\t\t\tconst runtime_package = \"svelte-effect-runtime\";\n\n\t\t\tif (no_external === true) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (Array.isArray(no_external)) {\n\t\t\t\tconst has_runtime_package = no_external.some((entry) => entry === runtime_package);\n\n\t\t\t\tif (!has_runtime_package) {\n\t\t\t\t\tno_external.push(runtime_package);\n\t\t\t\t}\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconfig.ssr.noExternal = [no_external, runtime_package].filter(\n\t\t\t\t(value): value is string | RegExp => value !== undefined,\n\t\t\t);\n\t\t},\n\n\t\tasync transform(code: string, id: string) {\n\t\t\tif (is_sveltekit_remote_runtime_index(id)) {\n\t\t\t\tconst rewritten = append_sveltekit_remote_transport_bridge(code);\n\n\t\t\t\thas_sveltekit_remote_bridge = true;\n\n\t\t\t\tif (rewritten === code) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\treturn { code: rewritten, map: null };\n\t\t\t}\n\n\t\t\tif (!is_remote_module(id) || !code.includes(\"__sveltekit/remote\")) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst has_remote_form = /\\.[\\s\\n]*form[\\s\\n]*\\(/.test(code);\n\n\t\t\thas_remote_form_module ||= has_remote_form;\n\n\t\t\tif (has_remote_form) {\n\t\t\t\tconst resolved_runtime = await this.resolve(\"__sveltekit/remote\", id);\n\n\t\t\t\tif (!resolved_runtime || !is_sveltekit_remote_runtime_index(resolved_runtime.id)) {\n\t\t\t\t\tthis.error(make_missing_sveltekit_remote_runtime_message());\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst rewritten = await rewrite_remote_client_exports(code, options);\n\n\t\t\tif (rewritten === code) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\treturn { code: rewritten, map: null };\n\t\t},\n\t};\n}\n\nfunction is_server_runtime_module(id: string): boolean {\n\tconst [filename] = id.split(\"?\", 2);\n\n\treturn (\n\t\t/\\.(server|remote)(?:\\.[cm])?\\.[jt]s$/.test(filename) ||\n\t\t/(?:^|[\\\\/])hooks\\.server(?:\\.[cm])?\\.[jt]s$/.test(filename)\n\t);\n}\n\nfunction is_remote_module(id: string): boolean {\n\treturn /\\.(remote|remote\\.[cm]?)\\.[jt]s(?:\\?.*)?$/.test(id) || id.includes(\".remote.\");\n}\n\nfunction is_svelte_component_module(id: string, extensions: readonly string[]): boolean {\n\tconst [filename, query = \"\"] = id.split(\"?\", 2);\n\n\tif (!extensions.some((extension) => filename.endsWith(extension))) {\n\t\treturn false;\n\t}\n\n\tif (query.length === 0) {\n\t\treturn true;\n\t}\n\n\tconst params = new URLSearchParams(query);\n\tconst allowed_params = [\"t\", \"v\"];\n\n\treturn [...params.keys()].every((key) => allowed_params.includes(key));\n}\n\nfunction may_have_effect_diagnostics(code: string): boolean {\n\treturn (\n\t\t/\\byield\\s*\\*/.test(code) ||\n\t\tcode.includes(\"Effect\") ||\n\t\t/[\"']effect(?:\\/Effect)?[\"']/.test(code)\n\t);\n}\n\nfunction may_have_ser_syntax(code: string): boolean {\n\treturn /\\byield\\s*\\*/.test(code) || /<script\\b[^>]*\\beffect(?:[\\s=>]|$)/i.test(code);\n}\n\n/**\n * Rewrites SvelteKit's generated client remote module from:\n *\n * `export const get_post = __remote.query(\"hash/get_post\")`\n *\n * into an Effect-aware wrapper around the same native function.\n *\n * @example\n * ```ts\n * const rewritten = await rewrite_remote_client_exports(remote_module_code);\n * ```\n *\n * @since 2.0.0\n * @param code - The generated client remote module code.\n * @param options - Optional plugin options.\n * @returns A promise that resolves to the rewritten module code.\n * @internal\n */\nexport async function rewrite_remote_client_exports(\n\tcode: string,\n\toptions?: EffectOptions,\n): Promise<string> {\n\tconst remote_client = await import(\"./compiler/remote-client.ts\");\n\n\treturn remote_client.rewrite_remote_client_exports(code, options);\n}\n"],"mappings":";AAAA,MAAM,kCACL;AAED,MAAM,oCAAoC;CACzC,CAAC,WAAW,qBAAqB;CACjC,CAAC,QAAQ,kBAAkB;CAC3B,CAAC,aAAa,uBAAuB;CACrC,CAAC,SAAS,kBAAkB;CAC5B,CAAC,eAAe,yBAAyB;CACzC,CAAC,cAAc,uBAAuB;AACvC;AAEA,MAAM,kCAAkC,CACvC,kFACA,6JACD;AAEA,MAAM,gCAAgC;CACrC;CACA;CACA;AACD;AAEA,SAAgB,kCAAkC,IAAqB;CACtE,MAAM,CAAC,YAAY,GAAG,MAAM,KAAK,CAAC;CAGlC,OAF4B,SAAS,WAAW,MAAM,GAE7B,CAAC,CAAC,SAAS,+BAA+B;AACpE;AAEA,SAAgB,yCAAyC,MAAsB;CAC9E,MAAM,sBAAsB,gCAAgC,OAAO,cAClE,KAAK,SAAS,SAAS,CACxB;CACA,MAAM,uBAAuB,8BAA8B,QAAQ,SAClE,KAAK,SAAS,IAAI,CACnB;CAEA,IAAI,qBACH,OAAO;CAGR,IAAI,qBAAqB,SAAS,GACjC,MAAM,IAAI,MACT,kDACC,6CAA6C,qBAAqB,KAAK,IAAI,EAAE,EAC9E,CACD;CAGD,MAAM,kBAAkB,kCACtB,QAAQ,CAAC,MAAM,YAAY,CAAC,mBAAmB,MAAM,MAAM,MAAM,CAAC,CAAC,CACnE,KAAK,CAAC,MAAM,YAAY,GAAG,K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AY,YAAwC;CACvF,MAAM,CAAC,UAAU,QAAQ,MAAM,GAAG,MAAM,KAAK,CAAC;CAE9C,IAAI,CAAC,WAAW,MAAM,cAAc,SAAS,SAAS,SAAS,CAAC,GAC/D,OAAO;CAGR,IAAI,MAAM,WAAW,GACpB,OAAO;CAGR,MAAM,SAAS,IAAI,gBAAgB,KAAK;CACxC,MAAM,iBAAiB,CAAC,KAAK,GAAG;CAEhC,OAAO,CAAC,GAAG,OAAO,KAAK,CAAC,CAAC,CAAC,OAAO,QAAQ,eAAe,SAAS,GAAG,CAAC;AACtE;AAEA,SAAS,4BAA4B,MAAuB;CAC3D,OACC,eAAe,KAAK,IAAI,KACxB,KAAK,SAAS,QAAQ,KACtB,8BAA8B,KAAK,IAAI;AAEzC;AAEA,SAAS,oBAAoB,MAAuB;CACnD,OAAO,eAAe,KAAK,IAAI,KAAK,sCAAsC,KAAK,IAAI;AACpF;;;;;;;;;;;;;;;;;;;AAoBA,eAAsB,8BACrB,MACA,SACkB;CAGlB,QAAO,MAFqB,OAAO,+BAAA,CAEd,8BAA8B,MAAM,OAAO;AACjE"}
|
|
1
|
+
{"version":3,"file":"compiler-B2htZszc.js","names":["candidate"],"sources":["../../../modules/svelte-effect-runtime/src/compiler/sveltekit-remote-bridge.ts","../../../modules/svelte-effect-runtime/src/compiler.ts"],"sourcesContent":["const sveltekit_remote_runtime_suffix =\n\t\"/node_modules/@sveltejs/kit/src/runtime/client/remote-functions/index.js\";\n\nconst expected_sveltekit_remote_exports = [\n\t[\"command\", \"./command.svelte.js\"],\n\t[\"form\", \"./form.svelte.js\"],\n\t[\"prerender\", \"./prerender.svelte.js\"],\n\t[\"query\", \"./query/index.js\"],\n\t[\"query_batch\", \"./query-batch.svelte.js\"],\n\t[\"query_live\", \"./query-live/index.js\"],\n] as const;\n\nconst sveltekit_remote_bridge_exports = [\n\t`export { remote_request as __SER___remote_request } from './shared.svelte.js';`,\n\t`export { serialize_binary_form as __SER___serialize_binary_form, BINARY_FORM_CONTENT_TYPE as __SER___binary_form_content_type } from '../../form-utils.js';`,\n] as const;\n\nconst sveltekit_remote_bridge_names = [\n\t\"__SER___remote_request\",\n\t\"__SER___serialize_binary_form\",\n\t\"__SER___binary_form_content_type\",\n] as const;\n\nexport function is_sveltekit_remote_runtime_index(id: string): boolean {\n\tconst [filename] = id.split(\"?\", 2);\n\tconst normalized_filename = filename.replaceAll(\"\\\\\", \"/\");\n\n\treturn normalized_filename.endsWith(sveltekit_remote_runtime_suffix);\n}\n\nexport function append_sveltekit_remote_transport_bridge(code: string): string {\n\tconst has_complete_bridge = sveltekit_remote_bridge_exports.every((statement) =>\n\t\tcode.includes(statement),\n\t);\n\tconst present_bridge_names = sveltekit_remote_bridge_names.filter((name) =>\n\t\tcode.includes(name),\n\t);\n\n\tif (has_complete_bridge) {\n\t\treturn code;\n\t}\n\n\tif (present_bridge_names.length > 0) {\n\t\tthrow new Error(\n\t\t\tmake_unsupported_sveltekit_remote_runtime_message(\n\t\t\t\t`found an incomplete SER transport bridge (${present_bridge_names.join(\", \")})`,\n\t\t\t),\n\t\t);\n\t}\n\n\tconst missing_exports = expected_sveltekit_remote_exports\n\t\t.filter(([name, source]) => !has_named_reexport(code, name, source))\n\t\t.map(([name, source]) => `${name} from ${source}`);\n\n\tif (missing_exports.length > 0) {\n\t\tthrow new Error(\n\t\t\tmake_unsupported_sveltekit_remote_runtime_message(\n\t\t\t\t`missing ${missing_exports.join(\", \")}`,\n\t\t\t),\n\t\t);\n\t}\n\n\treturn `${code.trimEnd()}\\n${sveltekit_remote_bridge_exports.join(\"\\n\")}\\n`;\n}\n\nexport function make_missing_sveltekit_remote_runtime_message(): string {\n\treturn make_unsupported_sveltekit_remote_runtime_message(\n\t\t\"the generated client used a remote form, but the Kit client runtime index was not found\",\n\t);\n}\n\nfunction has_named_reexport(code: string, name: string, source: string): boolean {\n\tconst escaped_name = escape_regular_expression(name);\n\tconst escaped_source = escape_regular_expression(source);\n\tconst pattern = new RegExp(\n\t\t`export\\\\s*\\\\{\\\\s*${escaped_name}\\\\s*\\\\}\\\\s*from\\\\s*[\"']${escaped_source}[\"']\\\\s*;?`,\n\t);\n\n\treturn pattern.test(code);\n}\n\nfunction escape_regular_expression(value: string): string {\n\treturn value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\nfunction make_unsupported_sveltekit_remote_runtime_message(reason: string): string {\n\treturn [\n\t\t\"Unsupported @sveltejs/kit remote client runtime.\",\n\t\treason,\n\t\t\"SER expects the remote runtime layout used by SvelteKit 2.69.x and 3.0.0-next.x.\",\n\t].join(\" \");\n}\n","import {\n\tappend_sveltekit_remote_transport_bridge,\n\tis_sveltekit_remote_runtime_index,\n\tmake_missing_sveltekit_remote_runtime_message,\n} from \"./compiler/sveltekit-remote-bridge.ts\";\nimport type { Plugin } from \"vite\";\n\n/**\n * Options for the {@link effect} Vite plugin.\n *\n * @example\n * ```ts\n * const options: EffectOptions = { debug: true };\n * const plugins = effect(options);\n * ```\n *\n * @since 2.0.0\n */\nexport interface EffectOptions {\n\t/** Whether to emit debug logging in the generated remote client module. */\n\tdebug?: boolean;\n}\n\ninterface SvelteComponentModuleFilter {\n\tset_extensions(extensions: readonly string[]): void;\n\tis_module(id: string): boolean;\n}\n\ninterface VitePluginSvelteApi {\n\toptions?: {\n\t\textensions?: readonly unknown[];\n\t};\n}\n\ntype VitePluginSvelte = Plugin & {\n\tapi?: VitePluginSvelteApi;\n};\n\ntype VitePluginSvelteWithExtensions = Plugin & {\n\tapi: {\n\t\toptions: {\n\t\t\textensions: readonly string[];\n\t\t};\n\t};\n};\n\nconst default_svelte_component_extensions = [\".svelte\"] as const;\n\n/**\n * Vite plugin for SvelteKit. The server import plugin rewrites server-side\n * imports to the server entrypoint; the remote client plugin wraps SvelteKit's\n * generated client remote exports in Effect-returning adapters.\n *\n * @example\n * ```ts\n * import { effect } from \"svelte-effect-runtime/compiler\";\n * import { sveltekit } from \"@sveltejs/kit/vite\";\n *\n * export default defineConfig({ plugins: [effect(), sveltekit()] });\n * ```\n *\n * @since 2.0.0\n * @param options - Optional configuration.\n * @returns Vite plugins that integrate the runtime with SvelteKit.\n */\nexport function effect(options?: EffectOptions): Plugin[] {\n\tconst component_filter = make_svelte_component_module_filter();\n\n\treturn [\n\t\tmake_diagnostics_plugin(component_filter),\n\t\tmake_svelte_transform_plugin(component_filter),\n\t\tmake_server_rewrite_plugin(),\n\t\tmake_remote_client_wrapper_plugin(options),\n\t];\n}\n\nfunction make_diagnostics_plugin(component_filter: SvelteComponentModuleFilter): Plugin {\n\tconst warned_diagnostics = new Set<string>();\n\n\treturn {\n\t\tname: \"svelte-effect-runtime:diagnostics\",\n\n\t\tasync transform(code: string, id: string) {\n\t\t\tif (!component_filter.is_module(id) || !may_have_effect_diagnostics(code)) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst clean_id = id.split(\"?\")[0] ?? id;\n\t\t\tconst { find_svelte_effect_diagnostics } = await import(\"./diagnostics.ts\");\n\t\t\tconst diagnostics = find_svelte_effect_diagnostics(code, clean_id);\n\n\t\t\tfor (const diagnostic of diagnostics) {\n\t\t\t\tconst diagnostic_key = [\n\t\t\t\t\tclean_id,\n\t\t\t\t\tdiagnostic.line,\n\t\t\t\t\tdiagnostic.column,\n\t\t\t\t\tdiagnostic.message,\n\t\t\t\t].join(\":\");\n\n\t\t\t\tif (warned_diagnostics.has(diagnostic_key)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\twarned_diagnostics.add(diagnostic_key);\n\n\t\t\t\tthis.warn({\n\t\t\t\t\tid: clean_id,\n\t\t\t\t\tmessage: diagnostic.message,\n\t\t\t\t\tloc: {\n\t\t\t\t\t\tline: diagnostic.line,\n\t\t\t\t\t\tcolumn: diagnostic.column,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn undefined;\n\t\t},\n\t};\n}\n\nfunction make_svelte_transform_plugin(component_filter: SvelteComponentModuleFilter): Plugin {\n\treturn {\n\t\tname: \"svelte-effect-runtime:svelte-transform\",\n\n\t\tconfigResolved(config) {\n\t\t\tconst extensions = find_svelte_component_extensions(config.plugins);\n\t\t\tconst conflicting_plugin_names = find_pre_transform_plugin_names(config.plugins);\n\n\t\t\tif (extensions) {\n\t\t\t\tcomponent_filter.set_extensions(extensions);\n\t\t\t}\n\n\t\t\tif (conflicting_plugin_names.length === 0) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconfig.logger.info(make_pre_transform_plugin_notice(conflicting_plugin_names));\n\t\t},\n\n\t\tasync transform(code: string, id: string, options?: { ssr?: boolean | undefined }) {\n\t\t\tif (!component_filter.is_module(id) || !may_have_ser_syntax(code)) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst { transform_svelte_effect } = await import(\"./runtime/transform.ts\");\n\t\t\tconst result = transform_svelte_effect(code, id, {\n\t\t\t\ttarget: options?.ssr ? \"server\" : \"client\",\n\t\t\t});\n\n\t\t\tif (result.code === code) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\treturn { code: result.code, map: null };\n\t\t},\n\t};\n}\n\nfunction make_svelte_component_module_filter(): SvelteComponentModuleFilter {\n\tlet extensions: readonly string[] = default_svelte_component_extensions;\n\n\treturn {\n\t\tset_extensions(next_extensions) {\n\t\t\tconst normalized_extensions = normalize_svelte_component_extensions(next_extensions);\n\n\t\t\tif (normalized_extensions.length === 0) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\textensions = normalized_extensions;\n\t\t},\n\n\t\tis_module(id) {\n\t\t\treturn is_svelte_component_module(id, extensions);\n\t\t},\n\t};\n}\n\nfunction normalize_svelte_component_extensions(extensions: readonly string[]): string[] {\n\tconst normalized_extensions = extensions\n\t\t.filter((extension) => extension.length > 0)\n\t\t.map((extension) => (extension.startsWith(\".\") ? extension : `.${extension}`));\n\n\treturn [...new Set(normalized_extensions)];\n}\n\nfunction find_svelte_component_extensions(\n\tplugins: readonly Plugin[],\n): readonly string[] | undefined {\n\tconst svelte_plugin = plugins.find(has_svelte_component_extensions);\n\n\treturn svelte_plugin?.api?.options?.extensions;\n}\n\nfunction has_svelte_component_extensions(plugin: Plugin): plugin is VitePluginSvelteWithExtensions {\n\tconst candidate = plugin as VitePluginSvelte;\n\tconst extensions = candidate.api?.options?.extensions;\n\n\tif (!plugin.name.startsWith(\"vite-plugin-svelte\")) {\n\t\treturn false;\n\t}\n\n\treturn (\n\t\tArray.isArray(extensions) && extensions.every((extension) => typeof extension === \"string\")\n\t);\n}\n\nfunction find_pre_transform_plugin_names(plugins: readonly Plugin[]): string[] {\n\treturn plugins\n\t\t.filter(\n\t\t\t(plugin) =>\n\t\t\t\t!plugin.name.startsWith(\"svelte-effect-runtime:\") &&\n\t\t\t\t!is_known_framework_pre_transform_plugin(plugin.name) &&\n\t\t\t\thas_pre_transform_priority(plugin),\n\t\t)\n\t\t.map((plugin) => plugin.name);\n}\n\nconst ansi_reset = \"\\x1b[0m\";\nconst ansi_light_green = \"\\x1b[92m\";\n\nfunction make_pre_transform_plugin_notice(plugin_names: readonly string[]): string {\n\tconst formatted_plugins = plugin_names.map((plugin_name) => ` - ${plugin_name}`).join(\"\\n\");\n\n\treturn [\n\t\t`${ansi_light_green}[svelte-effect-runtime]${ansi_reset} Svelte Effect Runtime noticed possible Vite plugin ordering conflicts.`,\n\t\t\"\",\n\t\t\"These plugins run before normal Svelte component transforms:\",\n\t\tformatted_plugins,\n\t\t\"\",\n\t\t\"This is usually fine, but if you see Svelte parser errors around <script effect>\",\n\t\t\"or yield* in components, one of those plugins may be reading component files before\",\n\t\t\"SER has lowered its syntax.\",\n\t].join(\"\\n\");\n}\n\nfunction is_known_framework_pre_transform_plugin(name: string): boolean {\n\treturn name.startsWith(\"vite:\") || name === \"vite-plugin-svelte:preprocess\";\n}\n\nfunction has_pre_transform_priority(plugin: Plugin): boolean {\n\tif (plugin.enforce === \"pre\" && plugin.transform) {\n\t\treturn true;\n\t}\n\n\tif (\n\t\ttypeof plugin.transform === \"object\" &&\n\t\tplugin.transform !== null &&\n\t\t\"order\" in plugin.transform &&\n\t\tplugin.transform.order === \"pre\"\n\t) {\n\t\treturn true;\n\t}\n\n\treturn false;\n}\n\nfunction make_server_rewrite_plugin(): Plugin {\n\treturn {\n\t\tname: \"svelte-effect-runtime:server-imports\",\n\n\t\tconfig() {\n\t\t\treturn { optimizeDeps: { exclude: [\"svelte-effect-runtime\"] } };\n\t\t},\n\n\t\tasync transform(code: string, id: string) {\n\t\t\tif (!is_server_runtime_module(id)) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tif (!code.includes(\"svelte-effect-runtime\")) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst rewritten = await rewrite_server_imports(code, id);\n\n\t\t\tif (rewritten === code) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\treturn { code: rewritten, map: null };\n\t\t},\n\t};\n}\n\nasync function rewrite_server_imports(code: string, id: string): Promise<string> {\n\tconst [{ default: MagicString }, ts] = await Promise.all([\n\t\timport(\"magic-string\"),\n\t\timport(\"typescript\"),\n\t]);\n\tconst filename = id.split(\"?\", 2)[0] ?? id;\n\tconst source_file = ts.createSourceFile(\n\t\tfilename,\n\t\tcode,\n\t\tts.ScriptTarget.Latest,\n\t\ttrue,\n\t\tget_script_kind(filename, ts),\n\t);\n\tconst magic = new MagicString(code);\n\tconst ser_prerender_imports = is_remote_module(id)\n\t\t? source_file.statements.flatMap((statement) => {\n\t\t\t\tif (\n\t\t\t\t\t!ts.isImportDeclaration(statement) ||\n\t\t\t\t\t!ts.isStringLiteralLike(statement.moduleSpecifier) ||\n\t\t\t\t\t!is_ser_server_import(statement.moduleSpecifier.text)\n\t\t\t\t) {\n\t\t\t\t\treturn [];\n\t\t\t\t}\n\n\t\t\t\tconst bindings = statement.importClause?.namedBindings;\n\n\t\t\t\tif (\n\t\t\t\t\tstatement.importClause?.isTypeOnly === true ||\n\t\t\t\t\t!bindings ||\n\t\t\t\t\t!ts.isNamedImports(bindings)\n\t\t\t\t) {\n\t\t\t\t\treturn [];\n\t\t\t\t}\n\n\t\t\t\treturn bindings.elements.filter(\n\t\t\t\t\t(element) =>\n\t\t\t\t\t\t!element.isTypeOnly &&\n\t\t\t\t\t\t(element.propertyName?.text ?? element.name.text) === \"Prerender\",\n\t\t\t\t);\n\t\t\t})\n\t\t: [];\n\tconst prerender_binding_names = new Set(\n\t\tser_prerender_imports.map((element) => element.name.text),\n\t);\n\tconst prerender_namespace_names = new Set(\n\t\tis_remote_module(id)\n\t\t\t? source_file.statements.flatMap((statement) => {\n\t\t\t\t\tif (\n\t\t\t\t\t\t!ts.isImportDeclaration(statement) ||\n\t\t\t\t\t\t!ts.isStringLiteralLike(statement.moduleSpecifier) ||\n\t\t\t\t\t\t!is_ser_server_import(statement.moduleSpecifier.text) ||\n\t\t\t\t\t\tstatement.importClause?.isTypeOnly === true ||\n\t\t\t\t\t\tstatement.importClause?.namedBindings === undefined ||\n\t\t\t\t\t\t!ts.isNamespaceImport(statement.importClause.namedBindings)\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn [];\n\t\t\t\t\t}\n\n\t\t\t\t\treturn [statement.importClause.namedBindings.name.text];\n\t\t\t\t})\n\t\t\t: [],\n\t);\n\tconst ser_prerender_calls = collect_exported_ser_prerender_calls(\n\t\tsource_file,\n\t\tprerender_binding_names,\n\t\tprerender_namespace_names,\n\t\tts,\n\t);\n\tconst has_sveltekit_prerender_import = source_file.statements.some(\n\t\t(statement) =>\n\t\t\tts.isImportDeclaration(statement) &&\n\t\t\tts.isStringLiteralLike(statement.moduleSpecifier) &&\n\t\t\tstatement.moduleSpecifier.text === \"$app/server\" &&\n\t\t\tstatement.importClause?.isTypeOnly !== true &&\n\t\t\tstatement.importClause?.namedBindings !== undefined &&\n\t\t\tts.isNamedImports(statement.importClause.namedBindings) &&\n\t\t\tstatement.importClause.namedBindings.elements.some(\n\t\t\t\t(element) =>\n\t\t\t\t\t!element.isTypeOnly &&\n\t\t\t\t\t(element.propertyName?.text ?? element.name.text) === \"prerender\" &&\n\t\t\t\t\telement.name.text === \"prerender\",\n\t\t\t),\n\t);\n\tconst has_top_level_prerender_binding = source_file.statements.some((statement) =>\n\t\tdeclares_top_level_value_binding(statement, \"prerender\", ts),\n\t);\n\tlet changed = false;\n\n\tif (ser_prerender_calls.size > 0 && !has_sveltekit_prerender_import) {\n\t\tif (has_top_level_prerender_binding) {\n\t\t\tthrow new Error(\n\t\t\t\t`[svelte-effect-runtime] ${filename}: Prerender remote modules reserve the top-level \"prerender\" binding for SvelteKit. Rename the existing binding.`,\n\t\t\t);\n\t\t}\n\n\t\tconst last_import = [...source_file.statements].reverse().find(ts.isImportDeclaration);\n\t\tconst native_import = `import { prerender } from \"$app/server\";`;\n\n\t\tif (last_import) {\n\t\t\tmagic.appendRight(last_import.end, `\\n${native_import}`);\n\t\t} else {\n\t\t\tmagic.prepend(`${native_import}\\n`);\n\t\t}\n\n\t\tchanged = true;\n\t}\n\n\tconst rewrite_specifier = (specifier: import(\"typescript\").StringLiteralLike) => {\n\t\tconst replacement = get_server_import_replacement(specifier.text);\n\n\t\tif (!replacement) {\n\t\t\treturn;\n\t\t}\n\n\t\tmagic.overwrite(\n\t\t\tspecifier.getStart(source_file),\n\t\t\tspecifier.end,\n\t\t\tJSON.stringify(replacement),\n\t\t);\n\t\tchanged = true;\n\t};\n\n\tconst visit = (node: import(\"typescript\").Node) => {\n\t\tif (ts.isImportDeclaration(node) && ts.isStringLiteralLike(node.moduleSpecifier)) {\n\t\t\trewrite_specifier(node.moduleSpecifier);\n\t\t}\n\n\t\tif (\n\t\t\tts.isExportDeclaration(node) &&\n\t\t\tnode.moduleSpecifier &&\n\t\t\tts.isStringLiteralLike(node.moduleSpecifier)\n\t\t) {\n\t\t\trewrite_specifier(node.moduleSpecifier);\n\t\t}\n\n\t\tif (ts.isCallExpression(node) && node.expression.kind === ts.SyntaxKind.ImportKeyword) {\n\t\t\tconst [specifier] = node.arguments;\n\n\t\t\tif (specifier && ts.isStringLiteralLike(specifier)) {\n\t\t\t\trewrite_specifier(specifier);\n\t\t\t}\n\t\t}\n\n\t\tif (ts.isCallExpression(node) && ser_prerender_calls.has(node)) {\n\t\t\tconst missing_arguments = Math.max(0, 3 - node.arguments.length);\n\t\t\tconst injected_arguments = [\n\t\t\t\t...Array.from({ length: missing_arguments }, () => \"undefined\"),\n\t\t\t\t\"prerender\",\n\t\t\t];\n\t\t\tconst separator =\n\t\t\t\tnode.arguments.length === 0 || node.arguments.hasTrailingComma ? \"\" : \",\";\n\n\t\t\tmagic.appendLeft(node.end - 1, `${separator} ${injected_arguments.join(\", \")}`);\n\t\t\tchanged = true;\n\t\t}\n\n\t\tts.forEachChild(node, visit);\n\t};\n\n\tvisit(source_file);\n\n\treturn changed ? magic.toString() : code;\n}\n\nfunction is_ser_server_import(specifier: string): boolean {\n\treturn specifier === \"svelte-effect-runtime\" || specifier === \"svelte-effect-runtime/server\";\n}\n\nfunction is_ser_prerender_callee(\n\texpression: import(\"typescript\").Expression,\n\tbinding_names: ReadonlySet<string>,\n\tnamespace_names: ReadonlySet<string>,\n\tts: typeof import(\"typescript\"),\n): boolean {\n\tif (ts.isIdentifier(expression)) {\n\t\treturn binding_names.has(expression.text);\n\t}\n\n\treturn (\n\t\tts.isPropertyAccessExpression(expression) &&\n\t\tts.isIdentifier(expression.expression) &&\n\t\tnamespace_names.has(expression.expression.text) &&\n\t\texpression.name.text === \"Prerender\"\n\t);\n}\n\nfunction collect_exported_ser_prerender_calls(\n\tsource_file: import(\"typescript\").SourceFile,\n\tbinding_names: ReadonlySet<string>,\n\tnamespace_names: ReadonlySet<string>,\n\tts: typeof import(\"typescript\"),\n): ReadonlySet<import(\"typescript\").CallExpression> {\n\tconst calls = new Set<import(\"typescript\").CallExpression>();\n\n\tconst visit = (node: import(\"typescript\").Node) => {\n\t\tif (\n\t\t\tts.isCallExpression(node) &&\n\t\t\tis_ser_prerender_callee(node.expression, binding_names, namespace_names, ts) &&\n\t\t\tis_exported_variable_initializer(node, ts)\n\t\t) {\n\t\t\tcalls.add(node);\n\t\t}\n\n\t\tts.forEachChild(node, visit);\n\t};\n\n\tvisit(source_file);\n\n\treturn calls;\n}\n\nfunction is_exported_variable_initializer(\n\tnode: import(\"typescript\").CallExpression,\n\tts: typeof import(\"typescript\"),\n): boolean {\n\tlet initializer: import(\"typescript\").Expression = node;\n\tlet parent = initializer.parent;\n\n\twhile (is_transparent_expression_wrapper(parent, initializer, ts)) {\n\t\tinitializer = parent;\n\t\tparent = initializer.parent;\n\t}\n\n\tif (!ts.isVariableDeclaration(parent) || parent.initializer !== initializer) {\n\t\treturn false;\n\t}\n\n\tconst statement = parent.parent.parent;\n\n\treturn (\n\t\tts.isVariableStatement(statement) &&\n\t\tstatement.modifiers?.some((modifier) => modifier.kind === ts.SyntaxKind.ExportKeyword) ===\n\t\t\ttrue\n\t);\n}\n\nfunction is_transparent_expression_wrapper(\n\tparent: import(\"typescript\").Node,\n\texpression: import(\"typescript\").Expression,\n\tts: typeof import(\"typescript\"),\n): parent is import(\"typescript\").Expression {\n\treturn (\n\t\t(ts.isParenthesizedExpression(parent) ||\n\t\t\tts.isAsExpression(parent) ||\n\t\t\tts.isSatisfiesExpression(parent) ||\n\t\t\tts.isTypeAssertionExpression(parent) ||\n\t\t\tts.isNonNullExpression(parent)) &&\n\t\tparent.expression === expression\n\t);\n}\n\nfunction declares_top_level_value_binding(\n\tstatement: import(\"typescript\").Statement,\n\tname: string,\n\tts: typeof import(\"typescript\"),\n): boolean {\n\tif (ts.isImportDeclaration(statement)) {\n\t\tconst import_clause = statement.importClause;\n\n\t\tif (!import_clause || import_clause.isTypeOnly) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (import_clause.name?.text === name) {\n\t\t\treturn true;\n\t\t}\n\n\t\tconst bindings = import_clause.namedBindings;\n\n\t\tif (bindings && ts.isNamespaceImport(bindings)) {\n\t\t\treturn bindings.name.text === name;\n\t\t}\n\n\t\treturn (\n\t\t\tbindings?.elements.some(\n\t\t\t\t(element) => !element.isTypeOnly && element.name.text === name,\n\t\t\t) === true\n\t\t);\n\t}\n\n\tif (ts.isVariableStatement(statement)) {\n\t\treturn statement.declarationList.declarations.some((declaration) =>\n\t\t\tbinding_name_contains(declaration.name, name, ts),\n\t\t);\n\t}\n\n\tif (\n\t\tts.isFunctionDeclaration(statement) ||\n\t\tts.isClassDeclaration(statement) ||\n\t\tts.isEnumDeclaration(statement) ||\n\t\tts.isModuleDeclaration(statement)\n\t) {\n\t\treturn statement.name?.getText() === name;\n\t}\n\n\treturn ts.isImportEqualsDeclaration(statement) && statement.name.text === name;\n}\n\nfunction binding_name_contains(\n\tbinding: import(\"typescript\").BindingName,\n\tname: string,\n\tts: typeof import(\"typescript\"),\n): boolean {\n\tif (ts.isIdentifier(binding)) {\n\t\treturn binding.text === name;\n\t}\n\n\treturn binding.elements.some(\n\t\t(element) =>\n\t\t\t!ts.isOmittedExpression(element) && binding_name_contains(element.name, name, ts),\n\t);\n}\n\nfunction get_server_import_replacement(specifier: string): string | undefined {\n\tif (specifier === \"svelte-effect-runtime\") {\n\t\treturn \"svelte-effect-runtime/server\";\n\t}\n\n\tif (specifier === \"svelte-effect-runtime/internal/generators\") {\n\t\treturn \"svelte-effect-runtime/server\";\n\t}\n\n\treturn undefined;\n}\n\nfunction get_script_kind(filename: string, ts: typeof import(\"typescript\")) {\n\tconst normalized_filename = filename.toLowerCase();\n\n\tif (has_file_extension(normalized_filename, [\".tsx\"])) {\n\t\treturn ts.ScriptKind.TSX;\n\t}\n\n\tif (has_file_extension(normalized_filename, [\".jsx\"])) {\n\t\treturn ts.ScriptKind.JSX;\n\t}\n\n\tif (has_file_extension(normalized_filename, [\".js\", \".mjs\", \".cjs\"])) {\n\t\treturn ts.ScriptKind.JS;\n\t}\n\n\treturn ts.ScriptKind.TS;\n}\n\nfunction has_file_extension(filename: string, extensions: readonly string[]): boolean {\n\treturn extensions.some((extension) => filename.endsWith(extension));\n}\n\nfunction make_remote_client_wrapper_plugin(options?: EffectOptions): Plugin {\n\tlet has_remote_form_module = false;\n\tlet has_sveltekit_remote_bridge = false;\n\n\treturn {\n\t\tname: \"svelte-effect-runtime:remote-client\",\n\t\tenforce: \"post\",\n\n\t\tbuildStart() {\n\t\t\thas_remote_form_module = false;\n\t\t\thas_sveltekit_remote_bridge = false;\n\t\t},\n\n\t\tbuildEnd(error) {\n\t\t\tif (error || !has_remote_form_module || has_sveltekit_remote_bridge) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.error(make_missing_sveltekit_remote_runtime_message());\n\t\t},\n\n\t\tconfig() {\n\t\t\treturn { ssr: { noExternal: [\"svelte-effect-runtime\"] } };\n\t\t},\n\n\t\tconfigResolved(config) {\n\t\t\tconst no_external = config.ssr.noExternal;\n\t\t\tconst runtime_package = \"svelte-effect-runtime\";\n\n\t\t\tif (no_external === true) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (Array.isArray(no_external)) {\n\t\t\t\tconst has_runtime_package = no_external.some((entry) => entry === runtime_package);\n\n\t\t\t\tif (!has_runtime_package) {\n\t\t\t\t\tno_external.push(runtime_package);\n\t\t\t\t}\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconfig.ssr.noExternal = [no_external, runtime_package].filter(\n\t\t\t\t(value): value is string | RegExp => value !== undefined,\n\t\t\t);\n\t\t},\n\n\t\tasync transform(code: string, id: string) {\n\t\t\tif (is_sveltekit_remote_runtime_index(id)) {\n\t\t\t\tconst rewritten = append_sveltekit_remote_transport_bridge(code);\n\n\t\t\t\thas_sveltekit_remote_bridge = true;\n\n\t\t\t\tif (rewritten === code) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\treturn { code: rewritten, map: null };\n\t\t\t}\n\n\t\t\tif (!is_remote_module(id)) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst remote_client = await import(\"./compiler/remote-client.ts\");\n\t\t\tconst runtime_specifier = remote_client.find_remote_client_runtime_specifier(code);\n\n\t\t\tif (!runtime_specifier) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst has_remote_form = /\\.[\\s\\n]*form[\\s\\n]*\\(/.test(code);\n\n\t\t\thas_remote_form_module ||= has_remote_form;\n\n\t\t\tif (has_remote_form) {\n\t\t\t\tconst resolved_runtime = await this.resolve(runtime_specifier, id);\n\n\t\t\t\tif (!resolved_runtime || !is_sveltekit_remote_runtime_index(resolved_runtime.id)) {\n\t\t\t\t\tthis.error(make_missing_sveltekit_remote_runtime_message());\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst rewritten = remote_client.rewrite_remote_client_exports(code, options);\n\n\t\t\tif (rewritten === code) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\treturn { code: rewritten, map: null };\n\t\t},\n\t};\n}\n\nfunction is_server_runtime_module(id: string): boolean {\n\tconst [filename] = id.split(\"?\", 2);\n\n\treturn (\n\t\t/\\.(server|remote)(?:\\.[cm])?\\.[jt]s$/.test(filename) ||\n\t\t/(?:^|[\\\\/])hooks\\.server(?:\\.[cm])?\\.[jt]s$/.test(filename)\n\t);\n}\n\nfunction is_remote_module(id: string): boolean {\n\treturn /\\.(remote|remote\\.[cm]?)\\.[jt]s(?:\\?.*)?$/.test(id) || id.includes(\".remote.\");\n}\n\nfunction is_svelte_component_module(id: string, extensions: readonly string[]): boolean {\n\tconst [filename, query = \"\"] = id.split(\"?\", 2);\n\n\tif (!extensions.some((extension) => filename.endsWith(extension))) {\n\t\treturn false;\n\t}\n\n\tif (query.length === 0) {\n\t\treturn true;\n\t}\n\n\tconst params = new URLSearchParams(query);\n\tconst allowed_params = [\"t\", \"v\"];\n\n\treturn [...params.keys()].every((key) => allowed_params.includes(key));\n}\n\nfunction may_have_effect_diagnostics(code: string): boolean {\n\treturn (\n\t\t/\\byield\\s*\\*/.test(code) ||\n\t\tcode.includes(\"Effect\") ||\n\t\t/[\"']effect(?:\\/Effect)?[\"']/.test(code)\n\t);\n}\n\nfunction may_have_ser_syntax(code: string): boolean {\n\treturn /\\byield\\s*\\*/.test(code) || /<script\\b[^>]*\\beffect(?:[\\s=>]|$)/i.test(code);\n}\n\n/**\n * Rewrites SvelteKit's generated client remote module from:\n *\n * `export const get_post = __remote.query(\"hash/get_post\")`\n *\n * into an Effect-aware wrapper around the same native function.\n *\n * @example\n * ```ts\n * const rewritten = await rewrite_remote_client_exports(remote_module_code);\n * ```\n *\n * @since 2.0.0\n * @param code - The generated client remote module code.\n * @param options - Optional plugin options.\n * @returns A promise that resolves to the rewritten module code.\n * @internal\n */\nexport async function rewrite_remote_client_exports(\n\tcode: string,\n\toptions?: EffectOptions,\n): Promise<string> {\n\tconst remote_client = await import(\"./compiler/remote-client.ts\");\n\n\treturn remote_client.rewrite_remote_client_exports(code, options);\n}\n"],"mappings":";AAAA,MAAM,kCACL;AAED,MAAM,oCAAoC;CACzC,CAAC,WAAW,qBAAqB;CACjC,CAAC,QAAQ,kBAAkB;CAC3B,CAAC,aAAa,uBAAuB;CACrC,CAAC,SAAS,kBAAkB;CAC5B,CAAC,eAAe,yBAAyB;CACzC,CAAC,cAAc,uBAAuB;AACvC;AAEA,MAAM,kCAAkC,CACvC,kFACA,6JACD;AAEA,MAAM,gCAAgC;CACrC;CACA;CACA;AACD;AAEA,SAAgB,kCAAkC,IAAqB;CACtE,MAAM,CAAC,YAAY,GAAG,MAAM,KAAK,CAAC;CAGlC,OAF4B,SAAS,WAAW,MAAM,GAE7B,CAAC,CAAC,SAAS,+BAA+B;AACpE;AAEA,SAAgB,yCAAyC,MAAsB;CAC9E,MAAM,sBAAsB,gCAAgC,OAAO,cAClE,KAAK,SAAS,SAAS,CACxB;CACA,MAAM,uBAAuB,8BAA8B,QAAQ,SAClE,KAAK,SAAS,IAAI,CACnB;CAEA,IAAI,qBACH,OAAO;CAGR,IAAI,qBAAqB,SAAS,GACjC,MAAM,IAAI,MACT,kDACC,6CAA6C,qBAAqB,KAAK,IAAI,EAAE,EAC9E,CACD;C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MAAM,KAAK,CAAC;CAElC,OACC,uCAAuC,KAAK,QAAQ,KACpD,8CAA8C,KAAK,QAAQ;AAE7D;AAEA,SAAS,iBAAiB,IAAqB;CAC9C,OAAO,4CAA4C,KAAK,EAAE,KAAK,GAAG,SAAS,UAAU;AACtF;AAEA,SAAS,2BAA2B,IAAY,YAAwC;CACvF,MAAM,CAAC,UAAU,QAAQ,MAAM,GAAG,MAAM,KAAK,CAAC;CAE9C,IAAI,CAAC,WAAW,MAAM,cAAc,SAAS,SAAS,SAAS,CAAC,GAC/D,OAAO;CAGR,IAAI,MAAM,WAAW,GACpB,OAAO;CAGR,MAAM,SAAS,IAAI,gBAAgB,KAAK;CACxC,MAAM,iBAAiB,CAAC,KAAK,GAAG;CAEhC,OAAO,CAAC,GAAG,OAAO,KAAK,CAAC,CAAC,CAAC,OAAO,QAAQ,eAAe,SAAS,GAAG,CAAC;AACtE;AAEA,SAAS,4BAA4B,MAAuB;CAC3D,OACC,eAAe,KAAK,IAAI,KACxB,KAAK,SAAS,QAAQ,KACtB,8BAA8B,KAAK,IAAI;AAEzC;AAEA,SAAS,oBAAoB,MAAuB;CACnD,OAAO,eAAe,KAAK,IAAI,KAAK,sCAAsC,KAAK,IAAI;AACpF;;;;;;;;;;;;;;;;;;;AAoBA,eAAsB,8BACrB,MACA,SACkB;CAGlB,QAAO,MAFqB,OAAO,+BAAA,CAEd,8BAA8B,MAAM,OAAO;AACjE"}
|
|
@@ -11,7 +11,7 @@ const remote_client_export_types = /* @__PURE__ */ new Set([
|
|
|
11
11
|
]);
|
|
12
12
|
/** Rewrites SvelteKit's generated remote client exports to SER adapters. */
|
|
13
13
|
function rewrite_remote_client_exports(code, options) {
|
|
14
|
-
const source_file =
|
|
14
|
+
const source_file = create_remote_client_source_file(code);
|
|
15
15
|
const namespace_import = find_remote_namespace_import(source_file);
|
|
16
16
|
if (!namespace_import) return code;
|
|
17
17
|
const remote_exports = collect_remote_client_exports(source_file, code, namespace_import.name);
|
|
@@ -48,6 +48,12 @@ function rewrite_remote_client_exports(code, options) {
|
|
|
48
48
|
for (const remote_export of remote_exports) magic.overwrite(remote_export.statement.getStart(source_file), remote_export.statement.end, make_remote_export(remote_export.name, remote_export.type, remote_export.native_call));
|
|
49
49
|
return magic.toString();
|
|
50
50
|
}
|
|
51
|
+
function find_remote_client_runtime_specifier(code) {
|
|
52
|
+
return find_remote_namespace_import(create_remote_client_source_file(code))?.specifier;
|
|
53
|
+
}
|
|
54
|
+
function create_remote_client_source_file(code) {
|
|
55
|
+
return ts.createSourceFile("sveltekit-remote-client.ts", code, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
|
|
56
|
+
}
|
|
51
57
|
function make_remote_export(name, remote_type, native_call) {
|
|
52
58
|
if (remote_type === "command") return `export const ${name} = create_remote_command_adapter(${native_call}, __SER___decode_payload);`;
|
|
53
59
|
if (remote_type === "form") return `export const ${name} = create_remote_form_adapter(${native_call}, __SER___decode_payload, __SER___remote_base, __SER___remote_form_transport);`;
|
|
@@ -64,15 +70,20 @@ function find_remote_namespace_import(source_file) {
|
|
|
64
70
|
}
|
|
65
71
|
}
|
|
66
72
|
function get_remote_namespace_import(statement) {
|
|
67
|
-
if (!ts.isStringLiteral(statement.moduleSpecifier) || statement.moduleSpecifier.text
|
|
73
|
+
if (!ts.isStringLiteral(statement.moduleSpecifier) || !is_sveltekit_remote_client_specifier(statement.moduleSpecifier.text)) return;
|
|
68
74
|
const import_clause = statement.importClause;
|
|
69
75
|
const bindings = import_clause?.namedBindings;
|
|
70
76
|
if (import_clause?.isTypeOnly || !bindings || !ts.isNamespaceImport(bindings)) return;
|
|
71
77
|
return {
|
|
72
78
|
name: bindings.name.text,
|
|
79
|
+
specifier: statement.moduleSpecifier.text,
|
|
73
80
|
statement
|
|
74
81
|
};
|
|
75
82
|
}
|
|
83
|
+
function is_sveltekit_remote_client_specifier(specifier) {
|
|
84
|
+
const normalized_specifier = specifier.replaceAll("\\", "/");
|
|
85
|
+
return normalized_specifier === "__sveltekit/remote" || normalized_specifier.endsWith("/@sveltejs/kit/src/runtime/client/remote-functions/index.js");
|
|
86
|
+
}
|
|
76
87
|
function collect_remote_client_exports(source_file, code, namespace) {
|
|
77
88
|
return source_file.statements.flatMap((statement) => collect_remote_client_export(source_file, code, namespace, statement));
|
|
78
89
|
}
|
|
@@ -109,6 +120,6 @@ function is_const_declaration_list(declaration_list) {
|
|
|
109
120
|
return (ts.getCombinedNodeFlags(declaration_list) & ts.NodeFlags.Const) !== 0;
|
|
110
121
|
}
|
|
111
122
|
//#endregion
|
|
112
|
-
export { rewrite_remote_client_exports };
|
|
123
|
+
export { find_remote_client_runtime_specifier, rewrite_remote_client_exports };
|
|
113
124
|
|
|
114
|
-
//# sourceMappingURL=remote-client-
|
|
125
|
+
//# sourceMappingURL=remote-client-C_3kdug0.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-client-C_3kdug0.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/compiler/remote-client.ts"],"sourcesContent":["import type {\n\tExpression,\n\tImportDeclaration,\n\tSourceFile,\n\tStatement,\n\tVariableStatement,\n} from \"typescript\";\n\nimport MagicString from \"magic-string\";\nimport ts from \"typescript\";\n\ninterface RemoteClientRewriteOptions {\n\tdebug?: boolean;\n}\n\ntype RemoteClientExportType =\n\t| \"query_batch\"\n\t| \"query_live\"\n\t| \"query\"\n\t| \"command\"\n\t| \"form\"\n\t| \"prerender\";\n\ninterface RemoteNamespaceImport {\n\tname: string;\n\tspecifier: string;\n\tstatement: ImportDeclaration;\n}\n\ninterface RemoteClientExport {\n\tname: string;\n\ttype: RemoteClientExportType;\n\tstatement: VariableStatement;\n\tnative_call: string;\n}\n\nconst remote_client_export_types = new Set<RemoteClientExportType>([\n\t\"query_batch\",\n\t\"query_live\",\n\t\"query\",\n\t\"command\",\n\t\"form\",\n\t\"prerender\",\n]);\n\n/** Rewrites SvelteKit's generated remote client exports to SER adapters. */\nexport function rewrite_remote_client_exports(\n\tcode: string,\n\toptions?: RemoteClientRewriteOptions,\n): string {\n\tconst source_file = create_remote_client_source_file(code);\n\tconst namespace_import = find_remote_namespace_import(source_file);\n\n\tif (!namespace_import) {\n\t\treturn code;\n\t}\n\n\tconst remote_exports = collect_remote_client_exports(source_file, code, namespace_import.name);\n\n\tif (remote_exports.length === 0) {\n\t\treturn code;\n\t}\n\n\tconst magic = new MagicString(code);\n\tconst has_remote_form = remote_exports.some((remote_export) => remote_export.type === \"form\");\n\tconst imports = [\n\t\t`import { create_remote_query_adapter, create_remote_live_query_adapter, create_remote_prerender_adapter, create_remote_command_adapter, create_remote_form_adapter } from \"svelte-effect-runtime/internal/remote-client\";`,\n\t\thas_remote_form &&\n\t\t\t`import { goto as __SER___goto, invalidateAll as __SER___invalidate_all } from \"$app/navigation\";`,\n\t\t`import { app_dir, base } from \"$app/paths/internal/client\";`,\n\t]\n\t\t.filter(Boolean)\n\t\t.join(\"\\n\");\n\n\tconst helpers = [\n\t\t`const __SER___remote_base = \\`\\${base}/\\${app_dir}/remote\\`;`,\n\t\t`function __SER___decode_payload(value) { return value; }`,\n\t\thas_remote_form &&\n\t\t\t[\n\t\t\t\t`function __SER___navigate_remote_form(location, invalidate_all) {`,\n\t\t\t\t`\\tconst target = new URL(location, globalThis.location.href);`,\n\t\t\t\t``,\n\t\t\t\t`\\tif (target.origin !== globalThis.location.origin) {`,\n\t\t\t\t`\\t\\tglobalThis.location.assign(target.href);`,\n\t\t\t\t``,\n\t\t\t\t`\\t\\treturn Promise.resolve();`,\n\t\t\t\t`\\t}`,\n\t\t\t\t``,\n\t\t\t\t`\\treturn __SER___goto(target, { invalidateAll: invalidate_all });`,\n\t\t\t\t`}`,\n\t\t\t].join(\"\\n\"),\n\t\thas_remote_form &&\n\t\t\t`const __SER___remote_form_transport = { binary_form_content_type: ${namespace_import.name}.__SER___binary_form_content_type, navigate: __SER___navigate_remote_form, refresh: __SER___invalidate_all, remote_request: ${namespace_import.name}.__SER___remote_request, serialize_binary_form: ${namespace_import.name}.__SER___serialize_binary_form };`,\n\t]\n\t\t.filter(Boolean)\n\t\t.join(\"\\n\");\n\tconst debug_line = options?.debug ? `console.log(\"[ser] remote client wrappers loaded\");` : \"\";\n\tconst injected = [imports, helpers, debug_line].filter(Boolean).join(\"\\n\");\n\n\tmagic.appendRight(namespace_import.statement.end, `\\n${injected}`);\n\n\tfor (const remote_export of remote_exports) {\n\t\tmagic.overwrite(\n\t\t\tremote_export.statement.getStart(source_file),\n\t\t\tremote_export.statement.end,\n\t\t\tmake_remote_export(remote_export.name, remote_export.type, remote_export.native_call),\n\t\t);\n\t}\n\n\treturn magic.toString();\n}\n\nexport function find_remote_client_runtime_specifier(code: string): string | undefined {\n\tconst source_file = create_remote_client_source_file(code);\n\n\treturn find_remote_namespace_import(source_file)?.specifier;\n}\n\nfunction create_remote_client_source_file(code: string): SourceFile {\n\treturn ts.createSourceFile(\n\t\t\"sveltekit-remote-client.ts\",\n\t\tcode,\n\t\tts.ScriptTarget.Latest,\n\t\ttrue,\n\t\tts.ScriptKind.TS,\n\t);\n}\n\nfunction make_remote_export(\n\tname: string,\n\tremote_type: RemoteClientExportType,\n\tnative_call: string,\n): string {\n\tif (remote_type === \"command\") {\n\t\treturn `export const ${name} = create_remote_command_adapter(${native_call}, __SER___decode_payload);`;\n\t}\n\n\tif (remote_type === \"form\") {\n\t\treturn `export const ${name} = create_remote_form_adapter(${native_call}, __SER___decode_payload, __SER___remote_base, __SER___remote_form_transport);`;\n\t}\n\n\tif (remote_type === \"query_live\") {\n\t\treturn `export const ${name} = create_remote_live_query_adapter(${native_call}, __SER___decode_payload);`;\n\t}\n\n\tif (remote_type === \"prerender\") {\n\t\treturn `export const ${name} = create_remote_prerender_adapter(${native_call}, __SER___decode_payload);`;\n\t}\n\n\tif (remote_type === \"query_batch\") {\n\t\treturn `export const ${name} = create_remote_query_adapter(${native_call}, __SER___decode_payload, \"\", \"batch\");`;\n\t}\n\n\treturn `export const ${name} = create_remote_query_adapter(${native_call}, __SER___decode_payload);`;\n}\n\nfunction find_remote_namespace_import(source_file: SourceFile): RemoteNamespaceImport | undefined {\n\tfor (const statement of source_file.statements) {\n\t\tif (!ts.isImportDeclaration(statement)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst namespace_import = get_remote_namespace_import(statement);\n\n\t\tif (namespace_import) {\n\t\t\treturn namespace_import;\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\nfunction get_remote_namespace_import(\n\tstatement: ImportDeclaration,\n): RemoteNamespaceImport | undefined {\n\tif (\n\t\t!ts.isStringLiteral(statement.moduleSpecifier) ||\n\t\t!is_sveltekit_remote_client_specifier(statement.moduleSpecifier.text)\n\t) {\n\t\treturn undefined;\n\t}\n\n\tconst import_clause = statement.importClause;\n\tconst bindings = import_clause?.namedBindings;\n\n\tif (import_clause?.isTypeOnly || !bindings || !ts.isNamespaceImport(bindings)) {\n\t\treturn undefined;\n\t}\n\n\treturn {\n\t\tname: bindings.name.text,\n\t\tspecifier: statement.moduleSpecifier.text,\n\t\tstatement,\n\t};\n}\n\nfunction is_sveltekit_remote_client_specifier(specifier: string): boolean {\n\tconst normalized_specifier = specifier.replaceAll(\"\\\\\", \"/\");\n\n\treturn (\n\t\tnormalized_specifier === \"__sveltekit/remote\" ||\n\t\tnormalized_specifier.endsWith(\"/@sveltejs/kit/src/runtime/client/remote-functions/index.js\")\n\t);\n}\n\nfunction collect_remote_client_exports(\n\tsource_file: SourceFile,\n\tcode: string,\n\tnamespace: string,\n): RemoteClientExport[] {\n\treturn source_file.statements.flatMap((statement) =>\n\t\tcollect_remote_client_export(source_file, code, namespace, statement),\n\t);\n}\n\nfunction collect_remote_client_export(\n\tsource_file: SourceFile,\n\tcode: string,\n\tnamespace: string,\n\tstatement: Statement,\n): RemoteClientExport[] {\n\tif (\n\t\t!ts.isVariableStatement(statement) ||\n\t\t!is_export_statement(statement) ||\n\t\t!is_const_declaration_list(statement.declarationList) ||\n\t\tstatement.declarationList.declarations.length !== 1\n\t) {\n\t\treturn [];\n\t}\n\n\tconst declaration = statement.declarationList.declarations[0];\n\tconst initializer = declaration.initializer;\n\n\tif (!ts.isIdentifier(declaration.name) || !initializer) {\n\t\treturn [];\n\t}\n\n\tconst remote_type = get_remote_client_export_type(initializer, namespace);\n\n\tif (!remote_type) {\n\t\treturn [];\n\t}\n\n\treturn [\n\t\t{\n\t\t\tname: declaration.name.text,\n\t\t\ttype: remote_type,\n\t\t\tstatement,\n\t\t\tnative_call: code.slice(initializer.getStart(source_file), initializer.end),\n\t\t},\n\t];\n}\n\nfunction get_remote_client_export_type(\n\tinitializer: Expression,\n\tnamespace: string,\n): RemoteClientExportType | undefined {\n\tif (!ts.isCallExpression(initializer)) {\n\t\treturn undefined;\n\t}\n\n\tconst expression = initializer.expression;\n\n\tif (!ts.isPropertyAccessExpression(expression)) {\n\t\treturn undefined;\n\t}\n\n\tif (!ts.isIdentifier(expression.expression) || expression.expression.text !== namespace) {\n\t\treturn undefined;\n\t}\n\n\tconst remote_type = expression.name.text;\n\n\tif (!is_remote_client_export_type(remote_type)) {\n\t\treturn undefined;\n\t}\n\n\treturn remote_type;\n}\n\nfunction is_remote_client_export_type(value: string): value is RemoteClientExportType {\n\treturn remote_client_export_types.has(value as RemoteClientExportType);\n}\n\nfunction is_export_statement(statement: Statement): boolean {\n\tconst modifiers = ts.canHaveModifiers(statement) ? ts.getModifiers(statement) : undefined;\n\n\treturn modifiers?.some((modifier) => modifier.kind === ts.SyntaxKind.ExportKeyword) ?? false;\n}\n\nfunction is_const_declaration_list(declaration_list: ts.VariableDeclarationList): boolean {\n\treturn (ts.getCombinedNodeFlags(declaration_list) & ts.NodeFlags.Const) !== 0;\n}\n"],"mappings":";;;AAoCA,MAAM,6CAA6B,IAAI,IAA4B;CAClE;CACA;CACA;CACA;CACA;CACA;AACD,CAAC;;AAGD,SAAgB,8BACf,MACA,SACS;CACT,MAAM,cAAc,iCAAiC,IAAI;CACzD,MAAM,mBAAmB,6BAA6B,WAAW;CAEjE,IAAI,CA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aAAa,YAAY,IAAI,KAAK,CAAC,aAC1C,OAAO,CAAC;CAGT,MAAM,cAAc,8BAA8B,aAAa,SAAS;CAExE,IAAI,CAAC,aACJ,OAAO,CAAC;CAGT,OAAO,CACN;EACC,MAAM,YAAY,KAAK;EACvB,MAAM;EACN;EACA,aAAa,KAAK,MAAM,YAAY,SAAS,WAAW,GAAG,YAAY,GAAG;CAC3E,CACD;AACD;AAEA,SAAS,8BACR,aACA,WACqC;CACrC,IAAI,CAAC,GAAG,iBAAiB,WAAW,GACnC;CAGD,MAAM,aAAa,YAAY;CAE/B,IAAI,CAAC,GAAG,2BAA2B,UAAU,GAC5C;CAGD,IAAI,CAAC,GAAG,aAAa,WAAW,UAAU,KAAK,WAAW,WAAW,SAAS,WAC7E;CAGD,MAAM,cAAc,WAAW,KAAK;CAEpC,IAAI,CAAC,6BAA6B,WAAW,GAC5C;CAGD,OAAO;AACR;AAEA,SAAS,6BAA6B,OAAgD;CACrF,OAAO,2BAA2B,IAAI,KAA+B;AACtE;AAEA,SAAS,oBAAoB,WAA+B;CAG3D,QAFkB,GAAG,iBAAiB,SAAS,IAAI,GAAG,aAAa,SAAS,IAAI,KAAA,EAAA,EAE9D,MAAM,aAAa,SAAS,SAAS,GAAG,WAAW,aAAa,KAAK;AACxF;AAEA,SAAS,0BAA0B,kBAAuD;CACzF,QAAQ,GAAG,qBAAqB,gBAAgB,IAAI,GAAG,UAAU,WAAW;AAC7E"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { _ as RemoteHelperContextError, v as RemoteHelperError } from "./errors-qhcbUH6o.js";
|
|
2
2
|
import { create_serialized_remote_failure_envelope, is_form_error } from "../remote/shared.js";
|
|
3
3
|
import { Cause, Effect, Exit, Schema } from "effect";
|
|
4
|
-
import
|
|
4
|
+
import * as SvelteKit from "@sveltejs/kit";
|
|
5
|
+
import { isHttpError, isRedirect } from "@sveltejs/kit";
|
|
5
6
|
import { stringify } from "devalue";
|
|
6
7
|
//#region src/remote/diagnostics.ts
|
|
7
8
|
const explanations = {
|
|
@@ -220,7 +221,19 @@ function get_form_error_issues(value) {
|
|
|
220
221
|
return is_tagged_form_error(value) ? [] : void 0;
|
|
221
222
|
}
|
|
222
223
|
function is_sveltekit_control_flow(value) {
|
|
223
|
-
return isRedirect(value) || isHttpError(value) ||
|
|
224
|
+
return isRedirect(value) || isHttpError(value) || is_validation_error(value);
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* SvelteKit `3.0.0-next.21` and `3.0.0-next.22` removed `isValidationError`
|
|
228
|
+
* from the `@sveltejs/kit` index (`3.0.0-next.23` restored it), so a named
|
|
229
|
+
* import would crash module evaluation on those versions. The namespace access
|
|
230
|
+
* stays safe on every version and the structural check mirrors SvelteKit's
|
|
231
|
+
* `ValidationError` (`Error` named `ValidationError` carrying `issues`).
|
|
232
|
+
*/
|
|
233
|
+
function is_validation_error(value) {
|
|
234
|
+
const native = SvelteKit.isValidationError;
|
|
235
|
+
if (native !== void 0) return native(value);
|
|
236
|
+
return value instanceof globalThis.Error && value.name === "ValidationError" && Array.isArray(value.issues);
|
|
224
237
|
}
|
|
225
238
|
function stringify_failure(value) {
|
|
226
239
|
try {
|
|
@@ -351,4 +364,4 @@ function is_sveltekit_remote_context_error(err) {
|
|
|
351
364
|
//#endregion
|
|
352
365
|
export { to_remote_failure_context as a, throw_remote_cause as i, run_remote_effect as n, encode_remote_failure as o, throw_form_error as r, normalize_remote_helper_error as t };
|
|
353
366
|
|
|
354
|
-
//# sourceMappingURL=server-
|
|
367
|
+
//# sourceMappingURL=server-Dxb9zr99.js.map
|