svelte-effect-runtime 4.0.0 → 4.1.0
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-DbwVAMWm.js +530 -0
- package/.dist/chunks/client-DbwVAMWm.js.map +1 -0
- package/.dist/chunks/compiler-Dpyu4Owd.js +412 -0
- package/.dist/chunks/compiler-Dpyu4Owd.js.map +1 -0
- package/.dist/chunks/descriptors-q909VWyR.js +216 -0
- package/.dist/chunks/descriptors-q909VWyR.js.map +1 -0
- package/.dist/chunks/diagnostics-DLwwrBWb.js +359 -0
- package/.dist/chunks/diagnostics-DLwwrBWb.js.map +1 -0
- package/.dist/chunks/dispatcher-CTWINW5I.js +534 -0
- package/.dist/chunks/dispatcher-CTWINW5I.js.map +1 -0
- package/.dist/chunks/dispatcher-pZPzarul.js +23 -0
- package/.dist/chunks/dispatcher-pZPzarul.js.map +1 -0
- package/.dist/chunks/{errors-IJjsUwrE.js → errors-qhcbUH6o.js} +56 -44
- package/.dist/chunks/errors-qhcbUH6o.js.map +1 -0
- package/.dist/chunks/live-BW7xZKjb.js +146 -0
- package/.dist/chunks/live-BW7xZKjb.js.map +1 -0
- package/.dist/chunks/live-CHK0RrZu.js +10 -0
- package/.dist/chunks/live-CHK0RrZu.js.map +1 -0
- package/.dist/chunks/{remote-client-CVI4t66c.js → remote-client-mkQAfP1G.js} +29 -23
- package/.dist/chunks/remote-client-mkQAfP1G.js.map +1 -0
- package/.dist/chunks/{runtime-GBQz32DZ.js → runtime-CPosEhGl.js} +3 -27
- package/.dist/chunks/runtime-CPosEhGl.js.map +1 -0
- package/.dist/chunks/{server-D1LcDnZE.js → server-yQrNoiCR.js} +15 -84
- package/.dist/chunks/server-yQrNoiCR.js.map +1 -0
- package/.dist/chunks/source-scan-cSawCvsg.js +1059 -0
- package/.dist/chunks/source-scan-cSawCvsg.js.map +1 -0
- package/.dist/chunks/{transform-jNUr65K9.js → transform-D7TTlPpK.js} +245 -371
- package/.dist/chunks/transform-D7TTlPpK.js.map +1 -0
- package/.dist/compiler/markup-identifiers.d.ts +2 -0
- package/.dist/compiler/remote-client.d.ts +1 -19
- package/.dist/compiler/source-scan.d.ts +11 -108
- package/.dist/compiler/sveltekit-remote-bridge.d.ts +3 -0
- package/.dist/compiler.d.ts +6 -0
- package/.dist/compiler.js +1 -1
- package/.dist/detect.d.ts +0 -31
- package/.dist/detect.js +0 -39
- package/.dist/detect.js.map +1 -1
- package/.dist/diagnostics.d.ts +0 -16
- package/.dist/dispatcher/deps.d.ts +3 -14
- package/.dist/dispatcher/fibers.d.ts +5 -46
- package/.dist/dispatcher/index.d.ts +42 -135
- package/.dist/dispatcher/scope.d.ts +36 -0
- package/.dist/dispatcher/types.d.ts +0 -151
- package/.dist/dispatcher.d.ts +2 -1
- package/.dist/dispatcher.js +2 -2
- package/.dist/errors.d.ts +44 -42
- package/.dist/generated/dispatcher.d.ts +6 -51
- package/.dist/generators.d.ts +2 -12
- package/.dist/internal/descriptors.d.ts +0 -16
- package/.dist/internal/generators.js +14 -9
- package/.dist/internal/generators.js.map +1 -1
- package/.dist/internal/live.d.ts +9 -0
- package/.dist/internal/remote-client.js +2 -2
- package/.dist/internal/remote-server.js +2 -2
- package/.dist/internal/schema.d.ts +0 -54
- package/.dist/live.d.ts +9 -26
- package/.dist/markup/event-attributes.d.ts +0 -32
- package/.dist/markup/promise.d.ts +1 -23
- package/.dist/markup/promise.js +2 -18
- package/.dist/markup/promise.js.map +1 -1
- package/.dist/markup/run.d.ts +1 -10
- package/.dist/markup/run.js +2 -11
- package/.dist/markup/run.js.map +1 -1
- package/.dist/markup/transform/apply.d.ts +5 -4
- package/.dist/markup/transform/classify.d.ts +2 -11
- package/.dist/markup/transform/constants.d.ts +2 -1
- package/.dist/markup/transform/effect-bindings.d.ts +2 -26
- package/.dist/markup/transform/effect-callbacks.d.ts +0 -20
- package/.dist/markup/transform/emit.d.ts +2 -11
- package/.dist/markup/transform/expressions.d.ts +0 -35
- package/.dist/markup/transform/scan.d.ts +3 -22
- package/.dist/markup/transform/types.d.ts +15 -127
- package/.dist/markup/transform.js +1 -1
- package/.dist/markup/value.d.ts +1 -18
- package/.dist/markup/value.js +2 -19
- package/.dist/markup/value.js.map +1 -1
- package/.dist/mod.d.ts +3 -8
- package/.dist/mod.js +5 -5
- package/.dist/mod.js.map +1 -1
- package/.dist/remote/cause-codec.d.ts +3 -37
- package/.dist/remote/client/command.d.ts +3 -17
- package/.dist/remote/client/form-data.d.ts +0 -7
- package/.dist/remote/client/form-enhance.d.ts +0 -7
- package/.dist/remote/client/form-transport.d.ts +14 -20
- package/.dist/remote/client/form.d.ts +4 -24
- package/.dist/remote/client/index.d.ts +2 -1
- package/.dist/remote/client/prerender.d.ts +6 -0
- package/.dist/remote/client/query-result.d.ts +2 -14
- package/.dist/remote/client/query.d.ts +8 -48
- package/.dist/remote/client/responses.d.ts +3 -27
- package/.dist/remote/client/types.d.ts +16 -110
- package/.dist/remote/client/utils.d.ts +0 -8
- package/.dist/remote/client.d.ts +2 -2
- package/.dist/remote/client.js +2 -2
- package/.dist/remote/effect.d.ts +6 -0
- package/.dist/remote/failures.d.ts +4 -0
- package/.dist/remote/query-update.d.ts +2 -0
- package/.dist/remote/resource.d.ts +25 -0
- package/.dist/remote/server.d.ts +5 -50
- package/.dist/remote/server.js +2 -2
- package/.dist/remote/shared.d.ts +6 -145
- package/.dist/remote/shared.js +6 -127
- package/.dist/remote/shared.js.map +1 -1
- package/.dist/runtime/transform.js +26 -31
- package/.dist/runtime/transform.js.map +1 -1
- package/.dist/script-transform/ast.d.ts +0 -46
- package/.dist/script-transform/imports.d.ts +3 -39
- package/.dist/script-transform/index.d.ts +2 -0
- package/.dist/script-transform/lower.d.ts +0 -9
- package/.dist/script-transform/runes.d.ts +0 -10
- package/.dist/script-transform/runtime-block.d.ts +0 -17
- package/.dist/script-transform/source.d.ts +0 -24
- package/.dist/script-transform/types.d.ts +9 -126
- package/.dist/server/effects.d.ts +4 -53
- package/.dist/server/factories.d.ts +7 -7
- package/.dist/server/index.d.ts +1 -1
- package/.dist/server/invalid.d.ts +0 -7
- package/.dist/server/live-snapshot.d.ts +5 -0
- package/.dist/server/remote-handler-context.d.ts +5 -0
- package/.dist/server/runtime.d.ts +6 -24
- package/.dist/server/schema.d.ts +0 -14
- package/.dist/server/transport.d.ts +2 -0
- package/.dist/server/types.d.ts +49 -26
- package/.dist/server/wrappers.d.ts +3 -40
- package/.dist/server.d.ts +1 -1
- package/.dist/server.js +200 -215
- package/.dist/server.js.map +1 -1
- package/.dist/yieldable.d.ts +1 -35
- package/package.json +2 -2
- package/.dist/chunks/client-DcZUV4rR.js +0 -653
- package/.dist/chunks/client-DcZUV4rR.js.map +0 -1
- package/.dist/chunks/compiler-BBPNyXmQ.js +0 -460
- package/.dist/chunks/compiler-BBPNyXmQ.js.map +0 -1
- package/.dist/chunks/dispatcher-DOx8iC6r.js +0 -505
- package/.dist/chunks/dispatcher-DOx8iC6r.js.map +0 -1
- package/.dist/chunks/dispatcher-H-Ia0Os4.js +0 -47
- package/.dist/chunks/dispatcher-H-Ia0Os4.js.map +0 -1
- package/.dist/chunks/errors-IJjsUwrE.js.map +0 -1
- package/.dist/chunks/live-BXAKre_4.js +0 -104
- package/.dist/chunks/live-BXAKre_4.js.map +0 -1
- package/.dist/chunks/remote-client-CVI4t66c.js.map +0 -1
- package/.dist/chunks/runtime-GBQz32DZ.js.map +0 -1
- package/.dist/chunks/schema-D9pct6Y5.js +0 -89
- package/.dist/chunks/schema-D9pct6Y5.js.map +0 -1
- package/.dist/chunks/server-D1LcDnZE.js.map +0 -1
- package/.dist/chunks/source-scan-C4PsggID.js +0 -341
- package/.dist/chunks/source-scan-C4PsggID.js.map +0 -1
- package/.dist/chunks/transform-jNUr65K9.js.map +0 -1
- package/.dist/remote/client/effect.d.ts +0 -29
- package/.dist/remote/client/failures.d.ts +0 -42
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-DbwVAMWm.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","export function to_form_data(input: unknown): FormData {\n\tconst form_data = new FormData();\n\n\tappend_form_value(form_data, \"\", input);\n\n\treturn form_data;\n}\n\nfunction append_form_value(form_data: FormData, path: string, value: unknown): 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}]`, item);\n\t\t}\n\n\t\treturn;\n\t}\n\n\tif (value instanceof Blob) {\n\t\tform_data.append(path, 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, child);\n\t\t}\n\n\t\treturn;\n\t}\n\n\tif (typeof value === \"number\") {\n\t\tform_data.append(`n:${path}`, String(value));\n\n\t\treturn;\n\t}\n\n\tif (typeof value === \"boolean\") {\n\t\tform_data.append(`b:${path}`, value ? \"on\" : \"off\");\n\n\t\treturn;\n\t}\n\n\tform_data.append(path, 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(to_remote_form_input(input, action_id)),\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 parts = action_id.split(\"/\");\n\tconst head = parts.slice(0, 2).join(\"/\");\n\tconst normalized_base = remote_base.replace(/\\/$/, \"\");\n\n\treturn `${normalized_base}/${head}`;\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 { RemoteFormInput } from \"@sveltejs/kit\";\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 RemoteFormInput | 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,OAAO,oBAAoB,KAAA,CAAS,CACrC;CACA,MAAM,UAAU,oBAA+B,IAAI;CAEnD,IAAI,0BAA0B,OAAO,GACpC,OAAO;CAGR,OAAO,yBAAyB,SAAS,QAAQ,IAAI;AACtD,CAAC;AAEF,MAAa,yBACZ,OACA,mBAEA,OAAO,IAAI,aAAa;CACvB,IAAI,iBAAiB,UAAU;EAC9B,IAAI,CAAC,MAAM,IAAI;GACd,MAAM,UAAU,OAAO,sBAAiC,KAAK;GAE7D,OAAO,OAAO,OAAO,KAAK,OAAO;EAClC;EAEA,MAAM,OAAO,OAAO,0BAAqC,KAAK;EAE9D,OAAO,OAAO,yBACP,eAAe,IAAI,CAC1B;CACD;CAEA,OAAO,OAAO,yBAA4C,eAAe,KAAK,CAAW;AAC1F,CAAC;AAEF,MAAM,6BAAwC,aAC7C,OAAO,IAAI,aAAa;CACvB,IAAI,SAAS,WAAW,OAAO,SAAS,WAAW,KAClD;CAGD,MAAM,OAAO,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,QAAQ,QAAQ,KAAK,QAAQ,CAAC,CAAC;AAC3E,CAAC"}
|
|
@@ -0,0 +1,412 @@
|
|
|
1
|
+
//#region src/compiler/sveltekit-remote-bridge.ts
|
|
2
|
+
const sveltekit_remote_runtime_suffix = "/node_modules/@sveltejs/kit/src/runtime/client/remote-functions/index.js";
|
|
3
|
+
const expected_sveltekit_remote_exports = [
|
|
4
|
+
["command", "./command.svelte.js"],
|
|
5
|
+
["form", "./form.svelte.js"],
|
|
6
|
+
["prerender", "./prerender.svelte.js"],
|
|
7
|
+
["query", "./query/index.js"],
|
|
8
|
+
["query_batch", "./query-batch.svelte.js"],
|
|
9
|
+
["query_live", "./query-live/index.js"]
|
|
10
|
+
];
|
|
11
|
+
const sveltekit_remote_bridge_exports = [`export { remote_request as __SER___remote_request } from './shared.svelte.js';`, `export { serialize_binary_form as __SER___serialize_binary_form, BINARY_FORM_CONTENT_TYPE as __SER___binary_form_content_type } from '../../form-utils.js';`];
|
|
12
|
+
const sveltekit_remote_bridge_names = [
|
|
13
|
+
"__SER___remote_request",
|
|
14
|
+
"__SER___serialize_binary_form",
|
|
15
|
+
"__SER___binary_form_content_type"
|
|
16
|
+
];
|
|
17
|
+
function is_sveltekit_remote_runtime_index(id) {
|
|
18
|
+
const [filename] = id.split("?", 2);
|
|
19
|
+
return filename.replaceAll("\\", "/").endsWith(sveltekit_remote_runtime_suffix);
|
|
20
|
+
}
|
|
21
|
+
function append_sveltekit_remote_transport_bridge(code) {
|
|
22
|
+
const has_complete_bridge = sveltekit_remote_bridge_exports.every((statement) => code.includes(statement));
|
|
23
|
+
const present_bridge_names = sveltekit_remote_bridge_names.filter((name) => code.includes(name));
|
|
24
|
+
if (has_complete_bridge) return code;
|
|
25
|
+
if (present_bridge_names.length > 0) throw new Error(make_unsupported_sveltekit_remote_runtime_message(`found an incomplete SER transport bridge (${present_bridge_names.join(", ")})`));
|
|
26
|
+
const missing_exports = expected_sveltekit_remote_exports.filter(([name, source]) => !has_named_reexport(code, name, source)).map(([name, source]) => `${name} from ${source}`);
|
|
27
|
+
if (missing_exports.length > 0) throw new Error(make_unsupported_sveltekit_remote_runtime_message(`missing ${missing_exports.join(", ")}`));
|
|
28
|
+
return `${code.trimEnd()}\n${sveltekit_remote_bridge_exports.join("\n")}\n`;
|
|
29
|
+
}
|
|
30
|
+
function make_missing_sveltekit_remote_runtime_message() {
|
|
31
|
+
return make_unsupported_sveltekit_remote_runtime_message("the generated client used a remote form, but the Kit client runtime index was not found");
|
|
32
|
+
}
|
|
33
|
+
function has_named_reexport(code, name, source) {
|
|
34
|
+
const escaped_name = escape_regular_expression(name);
|
|
35
|
+
const escaped_source = escape_regular_expression(source);
|
|
36
|
+
return new RegExp(`export\\s*\\{\\s*${escaped_name}\\s*\\}\\s*from\\s*["']${escaped_source}["']\\s*;?`).test(code);
|
|
37
|
+
}
|
|
38
|
+
function escape_regular_expression(value) {
|
|
39
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
40
|
+
}
|
|
41
|
+
function make_unsupported_sveltekit_remote_runtime_message(reason) {
|
|
42
|
+
return [
|
|
43
|
+
"Unsupported @sveltejs/kit remote client runtime.",
|
|
44
|
+
reason,
|
|
45
|
+
"SER expects the remote runtime layout used by SvelteKit 2.69.x and 3.0.0-next.x."
|
|
46
|
+
].join(" ");
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/compiler.ts
|
|
50
|
+
const default_svelte_component_extensions = [".svelte"];
|
|
51
|
+
/**
|
|
52
|
+
* Vite plugin for SvelteKit. The server import plugin rewrites server-side
|
|
53
|
+
* imports to the server entrypoint; the remote client plugin wraps SvelteKit's
|
|
54
|
+
* generated client remote exports in Effect-returning adapters.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* import { effect } from "svelte-effect-runtime/compiler";
|
|
59
|
+
* import { sveltekit } from "@sveltejs/kit/vite";
|
|
60
|
+
*
|
|
61
|
+
* export default defineConfig({ plugins: [effect(), sveltekit()] });
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* @since 2.0.0
|
|
65
|
+
* @param options - Optional configuration.
|
|
66
|
+
* @returns Vite plugins that integrate the runtime with SvelteKit.
|
|
67
|
+
*/
|
|
68
|
+
function effect(options) {
|
|
69
|
+
const component_filter = make_svelte_component_module_filter();
|
|
70
|
+
return [
|
|
71
|
+
make_diagnostics_plugin(component_filter),
|
|
72
|
+
make_svelte_transform_plugin(component_filter),
|
|
73
|
+
make_server_rewrite_plugin(),
|
|
74
|
+
make_remote_client_wrapper_plugin(options)
|
|
75
|
+
];
|
|
76
|
+
}
|
|
77
|
+
function make_diagnostics_plugin(component_filter) {
|
|
78
|
+
const warned_diagnostics = /* @__PURE__ */ new Set();
|
|
79
|
+
return {
|
|
80
|
+
name: "svelte-effect-runtime:diagnostics",
|
|
81
|
+
async transform(code, id) {
|
|
82
|
+
if (!component_filter.is_module(id) || !may_have_effect_diagnostics(code)) return;
|
|
83
|
+
const clean_id = id.split("?")[0] ?? id;
|
|
84
|
+
const { find_svelte_effect_diagnostics } = await import("./diagnostics-DLwwrBWb.js");
|
|
85
|
+
const diagnostics = find_svelte_effect_diagnostics(code, clean_id);
|
|
86
|
+
for (const diagnostic of diagnostics) {
|
|
87
|
+
const diagnostic_key = [
|
|
88
|
+
clean_id,
|
|
89
|
+
diagnostic.line,
|
|
90
|
+
diagnostic.column,
|
|
91
|
+
diagnostic.message
|
|
92
|
+
].join(":");
|
|
93
|
+
if (warned_diagnostics.has(diagnostic_key)) continue;
|
|
94
|
+
warned_diagnostics.add(diagnostic_key);
|
|
95
|
+
this.warn({
|
|
96
|
+
id: clean_id,
|
|
97
|
+
message: diagnostic.message,
|
|
98
|
+
loc: {
|
|
99
|
+
line: diagnostic.line,
|
|
100
|
+
column: diagnostic.column
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
function make_svelte_transform_plugin(component_filter) {
|
|
108
|
+
return {
|
|
109
|
+
name: "svelte-effect-runtime:svelte-transform",
|
|
110
|
+
configResolved(config) {
|
|
111
|
+
const extensions = find_svelte_component_extensions(config.plugins);
|
|
112
|
+
const conflicting_plugin_names = find_pre_transform_plugin_names(config.plugins);
|
|
113
|
+
if (extensions) component_filter.set_extensions(extensions);
|
|
114
|
+
if (conflicting_plugin_names.length === 0) return;
|
|
115
|
+
config.logger.info(make_pre_transform_plugin_notice(conflicting_plugin_names));
|
|
116
|
+
},
|
|
117
|
+
async transform(code, id, options) {
|
|
118
|
+
if (!component_filter.is_module(id) || !may_have_ser_syntax(code)) return;
|
|
119
|
+
const { transform_svelte_effect } = await import("../runtime/transform.js");
|
|
120
|
+
const result = transform_svelte_effect(code, id, { target: options?.ssr ? "server" : "client" });
|
|
121
|
+
if (result.code === code) return;
|
|
122
|
+
return {
|
|
123
|
+
code: result.code,
|
|
124
|
+
map: null
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
function make_svelte_component_module_filter() {
|
|
130
|
+
let extensions = default_svelte_component_extensions;
|
|
131
|
+
return {
|
|
132
|
+
set_extensions(next_extensions) {
|
|
133
|
+
const normalized_extensions = normalize_svelte_component_extensions(next_extensions);
|
|
134
|
+
if (normalized_extensions.length === 0) return;
|
|
135
|
+
extensions = normalized_extensions;
|
|
136
|
+
},
|
|
137
|
+
is_module(id) {
|
|
138
|
+
return is_svelte_component_module(id, extensions);
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
function normalize_svelte_component_extensions(extensions) {
|
|
143
|
+
const normalized_extensions = extensions.filter((extension) => extension.length > 0).map((extension) => extension.startsWith(".") ? extension : `.${extension}`);
|
|
144
|
+
return [...new Set(normalized_extensions)];
|
|
145
|
+
}
|
|
146
|
+
function find_svelte_component_extensions(plugins) {
|
|
147
|
+
return plugins.find(has_svelte_component_extensions)?.api?.options?.extensions;
|
|
148
|
+
}
|
|
149
|
+
function has_svelte_component_extensions(plugin) {
|
|
150
|
+
const extensions = plugin.api?.options?.extensions;
|
|
151
|
+
if (!plugin.name.startsWith("vite-plugin-svelte")) return false;
|
|
152
|
+
return Array.isArray(extensions) && extensions.every((extension) => typeof extension === "string");
|
|
153
|
+
}
|
|
154
|
+
function find_pre_transform_plugin_names(plugins) {
|
|
155
|
+
return plugins.filter((plugin) => !plugin.name.startsWith("svelte-effect-runtime:") && !is_known_framework_pre_transform_plugin(plugin.name) && has_pre_transform_priority(plugin)).map((plugin) => plugin.name);
|
|
156
|
+
}
|
|
157
|
+
const ansi_reset = "\x1B[0m";
|
|
158
|
+
const ansi_light_green = "\x1B[92m";
|
|
159
|
+
function make_pre_transform_plugin_notice(plugin_names) {
|
|
160
|
+
const formatted_plugins = plugin_names.map((plugin_name) => ` - ${plugin_name}`).join("\n");
|
|
161
|
+
return [
|
|
162
|
+
`${ansi_light_green}[svelte-effect-runtime]${ansi_reset} Svelte Effect Runtime noticed possible Vite plugin ordering conflicts.`,
|
|
163
|
+
"",
|
|
164
|
+
"These plugins run before normal Svelte component transforms:",
|
|
165
|
+
formatted_plugins,
|
|
166
|
+
"",
|
|
167
|
+
"This is usually fine, but if you see Svelte parser errors around <script effect>",
|
|
168
|
+
"or yield* in components, one of those plugins may be reading component files before",
|
|
169
|
+
"SER has lowered its syntax."
|
|
170
|
+
].join("\n");
|
|
171
|
+
}
|
|
172
|
+
function is_known_framework_pre_transform_plugin(name) {
|
|
173
|
+
return name.startsWith("vite:") || name === "vite-plugin-svelte:preprocess";
|
|
174
|
+
}
|
|
175
|
+
function has_pre_transform_priority(plugin) {
|
|
176
|
+
if (plugin.enforce === "pre" && plugin.transform) return true;
|
|
177
|
+
if (typeof plugin.transform === "object" && plugin.transform !== null && "order" in plugin.transform && plugin.transform.order === "pre") return true;
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
function make_server_rewrite_plugin() {
|
|
181
|
+
return {
|
|
182
|
+
name: "svelte-effect-runtime:server-imports",
|
|
183
|
+
config() {
|
|
184
|
+
return { optimizeDeps: { exclude: ["svelte-effect-runtime"] } };
|
|
185
|
+
},
|
|
186
|
+
async transform(code, id) {
|
|
187
|
+
if (!is_server_runtime_module(id)) return;
|
|
188
|
+
if (!code.includes("svelte-effect-runtime")) return;
|
|
189
|
+
const rewritten = await rewrite_server_imports(code, id);
|
|
190
|
+
if (rewritten === code) return;
|
|
191
|
+
return {
|
|
192
|
+
code: rewritten,
|
|
193
|
+
map: null
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
async function rewrite_server_imports(code, id) {
|
|
199
|
+
const [{ default: MagicString }, ts] = await Promise.all([import("magic-string"), import("typescript")]);
|
|
200
|
+
const filename = id.split("?", 2)[0] ?? id;
|
|
201
|
+
const source_file = ts.createSourceFile(filename, code, ts.ScriptTarget.Latest, true, get_script_kind(filename, ts));
|
|
202
|
+
const magic = new MagicString(code);
|
|
203
|
+
const ser_prerender_imports = is_remote_module(id) ? source_file.statements.flatMap((statement) => {
|
|
204
|
+
if (!ts.isImportDeclaration(statement) || !ts.isStringLiteralLike(statement.moduleSpecifier) || !is_ser_server_import(statement.moduleSpecifier.text)) return [];
|
|
205
|
+
const bindings = statement.importClause?.namedBindings;
|
|
206
|
+
if (statement.importClause?.isTypeOnly === true || !bindings || !ts.isNamedImports(bindings)) return [];
|
|
207
|
+
return bindings.elements.filter((element) => !element.isTypeOnly && (element.propertyName?.text ?? element.name.text) === "Prerender");
|
|
208
|
+
}) : [];
|
|
209
|
+
const ser_prerender_calls = collect_exported_ser_prerender_calls(source_file, new Set(ser_prerender_imports.map((element) => element.name.text)), new Set(is_remote_module(id) ? source_file.statements.flatMap((statement) => {
|
|
210
|
+
if (!ts.isImportDeclaration(statement) || !ts.isStringLiteralLike(statement.moduleSpecifier) || !is_ser_server_import(statement.moduleSpecifier.text) || statement.importClause?.isTypeOnly === true || statement.importClause?.namedBindings === void 0 || !ts.isNamespaceImport(statement.importClause.namedBindings)) return [];
|
|
211
|
+
return [statement.importClause.namedBindings.name.text];
|
|
212
|
+
}) : []), ts);
|
|
213
|
+
const has_sveltekit_prerender_import = source_file.statements.some((statement) => ts.isImportDeclaration(statement) && ts.isStringLiteralLike(statement.moduleSpecifier) && statement.moduleSpecifier.text === "$app/server" && statement.importClause?.isTypeOnly !== true && statement.importClause?.namedBindings !== void 0 && ts.isNamedImports(statement.importClause.namedBindings) && statement.importClause.namedBindings.elements.some((element) => !element.isTypeOnly && (element.propertyName?.text ?? element.name.text) === "prerender" && element.name.text === "prerender"));
|
|
214
|
+
const has_top_level_prerender_binding = source_file.statements.some((statement) => declares_top_level_value_binding(statement, "prerender", ts));
|
|
215
|
+
let changed = false;
|
|
216
|
+
if (ser_prerender_calls.size > 0 && !has_sveltekit_prerender_import) {
|
|
217
|
+
if (has_top_level_prerender_binding) throw new Error(`[svelte-effect-runtime] ${filename}: Prerender remote modules reserve the top-level "prerender" binding for SvelteKit. Rename the existing binding.`);
|
|
218
|
+
const last_import = [...source_file.statements].reverse().find(ts.isImportDeclaration);
|
|
219
|
+
const native_import = `import { prerender } from "$app/server";`;
|
|
220
|
+
if (last_import) magic.appendRight(last_import.end, `\n${native_import}`);
|
|
221
|
+
else magic.prepend(`${native_import}\n`);
|
|
222
|
+
changed = true;
|
|
223
|
+
}
|
|
224
|
+
const rewrite_specifier = (specifier) => {
|
|
225
|
+
const replacement = get_server_import_replacement(specifier.text);
|
|
226
|
+
if (!replacement) return;
|
|
227
|
+
magic.overwrite(specifier.getStart(source_file), specifier.end, JSON.stringify(replacement));
|
|
228
|
+
changed = true;
|
|
229
|
+
};
|
|
230
|
+
const visit = (node) => {
|
|
231
|
+
if (ts.isImportDeclaration(node) && ts.isStringLiteralLike(node.moduleSpecifier)) rewrite_specifier(node.moduleSpecifier);
|
|
232
|
+
if (ts.isExportDeclaration(node) && node.moduleSpecifier && ts.isStringLiteralLike(node.moduleSpecifier)) rewrite_specifier(node.moduleSpecifier);
|
|
233
|
+
if (ts.isCallExpression(node) && node.expression.kind === ts.SyntaxKind.ImportKeyword) {
|
|
234
|
+
const [specifier] = node.arguments;
|
|
235
|
+
if (specifier && ts.isStringLiteralLike(specifier)) rewrite_specifier(specifier);
|
|
236
|
+
}
|
|
237
|
+
if (ts.isCallExpression(node) && ser_prerender_calls.has(node)) {
|
|
238
|
+
const missing_arguments = Math.max(0, 3 - node.arguments.length);
|
|
239
|
+
const injected_arguments = [...Array.from({ length: missing_arguments }, () => "undefined"), "prerender"];
|
|
240
|
+
const separator = node.arguments.length === 0 || node.arguments.hasTrailingComma ? "" : ",";
|
|
241
|
+
magic.appendLeft(node.end - 1, `${separator} ${injected_arguments.join(", ")}`);
|
|
242
|
+
changed = true;
|
|
243
|
+
}
|
|
244
|
+
ts.forEachChild(node, visit);
|
|
245
|
+
};
|
|
246
|
+
visit(source_file);
|
|
247
|
+
return changed ? magic.toString() : code;
|
|
248
|
+
}
|
|
249
|
+
function is_ser_server_import(specifier) {
|
|
250
|
+
return specifier === "svelte-effect-runtime" || specifier === "svelte-effect-runtime/server";
|
|
251
|
+
}
|
|
252
|
+
function is_ser_prerender_callee(expression, binding_names, namespace_names, ts) {
|
|
253
|
+
if (ts.isIdentifier(expression)) return binding_names.has(expression.text);
|
|
254
|
+
return ts.isPropertyAccessExpression(expression) && ts.isIdentifier(expression.expression) && namespace_names.has(expression.expression.text) && expression.name.text === "Prerender";
|
|
255
|
+
}
|
|
256
|
+
function collect_exported_ser_prerender_calls(source_file, binding_names, namespace_names, ts) {
|
|
257
|
+
const calls = /* @__PURE__ */ new Set();
|
|
258
|
+
const visit = (node) => {
|
|
259
|
+
if (ts.isCallExpression(node) && is_ser_prerender_callee(node.expression, binding_names, namespace_names, ts) && is_exported_variable_initializer(node, ts)) calls.add(node);
|
|
260
|
+
ts.forEachChild(node, visit);
|
|
261
|
+
};
|
|
262
|
+
visit(source_file);
|
|
263
|
+
return calls;
|
|
264
|
+
}
|
|
265
|
+
function is_exported_variable_initializer(node, ts) {
|
|
266
|
+
let initializer = node;
|
|
267
|
+
let parent = initializer.parent;
|
|
268
|
+
while (is_transparent_expression_wrapper(parent, initializer, ts)) {
|
|
269
|
+
initializer = parent;
|
|
270
|
+
parent = initializer.parent;
|
|
271
|
+
}
|
|
272
|
+
if (!ts.isVariableDeclaration(parent) || parent.initializer !== initializer) return false;
|
|
273
|
+
const statement = parent.parent.parent;
|
|
274
|
+
return ts.isVariableStatement(statement) && statement.modifiers?.some((modifier) => modifier.kind === ts.SyntaxKind.ExportKeyword) === true;
|
|
275
|
+
}
|
|
276
|
+
function is_transparent_expression_wrapper(parent, expression, ts) {
|
|
277
|
+
return (ts.isParenthesizedExpression(parent) || ts.isAsExpression(parent) || ts.isSatisfiesExpression(parent) || ts.isTypeAssertionExpression(parent) || ts.isNonNullExpression(parent)) && parent.expression === expression;
|
|
278
|
+
}
|
|
279
|
+
function declares_top_level_value_binding(statement, name, ts) {
|
|
280
|
+
if (ts.isImportDeclaration(statement)) {
|
|
281
|
+
const import_clause = statement.importClause;
|
|
282
|
+
if (!import_clause || import_clause.isTypeOnly) return false;
|
|
283
|
+
if (import_clause.name?.text === name) return true;
|
|
284
|
+
const bindings = import_clause.namedBindings;
|
|
285
|
+
if (bindings && ts.isNamespaceImport(bindings)) return bindings.name.text === name;
|
|
286
|
+
return bindings?.elements.some((element) => !element.isTypeOnly && element.name.text === name) === true;
|
|
287
|
+
}
|
|
288
|
+
if (ts.isVariableStatement(statement)) return statement.declarationList.declarations.some((declaration) => binding_name_contains(declaration.name, name, ts));
|
|
289
|
+
if (ts.isFunctionDeclaration(statement) || ts.isClassDeclaration(statement) || ts.isEnumDeclaration(statement) || ts.isModuleDeclaration(statement)) return statement.name?.getText() === name;
|
|
290
|
+
return ts.isImportEqualsDeclaration(statement) && statement.name.text === name;
|
|
291
|
+
}
|
|
292
|
+
function binding_name_contains(binding, name, ts) {
|
|
293
|
+
if (ts.isIdentifier(binding)) return binding.text === name;
|
|
294
|
+
return binding.elements.some((element) => !ts.isOmittedExpression(element) && binding_name_contains(element.name, name, ts));
|
|
295
|
+
}
|
|
296
|
+
function get_server_import_replacement(specifier) {
|
|
297
|
+
if (specifier === "svelte-effect-runtime") return "svelte-effect-runtime/server";
|
|
298
|
+
if (specifier === "svelte-effect-runtime/internal/generators") return "svelte-effect-runtime/server";
|
|
299
|
+
}
|
|
300
|
+
function get_script_kind(filename, ts) {
|
|
301
|
+
const normalized_filename = filename.toLowerCase();
|
|
302
|
+
if (has_file_extension(normalized_filename, [".tsx"])) return ts.ScriptKind.TSX;
|
|
303
|
+
if (has_file_extension(normalized_filename, [".jsx"])) return ts.ScriptKind.JSX;
|
|
304
|
+
if (has_file_extension(normalized_filename, [
|
|
305
|
+
".js",
|
|
306
|
+
".mjs",
|
|
307
|
+
".cjs"
|
|
308
|
+
])) return ts.ScriptKind.JS;
|
|
309
|
+
return ts.ScriptKind.TS;
|
|
310
|
+
}
|
|
311
|
+
function has_file_extension(filename, extensions) {
|
|
312
|
+
return extensions.some((extension) => filename.endsWith(extension));
|
|
313
|
+
}
|
|
314
|
+
function make_remote_client_wrapper_plugin(options) {
|
|
315
|
+
let has_remote_form_module = false;
|
|
316
|
+
let has_sveltekit_remote_bridge = false;
|
|
317
|
+
return {
|
|
318
|
+
name: "svelte-effect-runtime:remote-client",
|
|
319
|
+
enforce: "post",
|
|
320
|
+
buildStart() {
|
|
321
|
+
has_remote_form_module = false;
|
|
322
|
+
has_sveltekit_remote_bridge = false;
|
|
323
|
+
},
|
|
324
|
+
buildEnd(error) {
|
|
325
|
+
if (error || !has_remote_form_module || has_sveltekit_remote_bridge) return;
|
|
326
|
+
this.error(make_missing_sveltekit_remote_runtime_message());
|
|
327
|
+
},
|
|
328
|
+
config() {
|
|
329
|
+
return { ssr: { noExternal: ["svelte-effect-runtime"] } };
|
|
330
|
+
},
|
|
331
|
+
configResolved(config) {
|
|
332
|
+
const no_external = config.ssr.noExternal;
|
|
333
|
+
const runtime_package = "svelte-effect-runtime";
|
|
334
|
+
if (no_external === true) return;
|
|
335
|
+
if (Array.isArray(no_external)) {
|
|
336
|
+
if (!no_external.some((entry) => entry === runtime_package)) no_external.push(runtime_package);
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
config.ssr.noExternal = [no_external, runtime_package].filter((value) => value !== void 0);
|
|
340
|
+
},
|
|
341
|
+
async transform(code, id) {
|
|
342
|
+
if (is_sveltekit_remote_runtime_index(id)) {
|
|
343
|
+
const rewritten = append_sveltekit_remote_transport_bridge(code);
|
|
344
|
+
has_sveltekit_remote_bridge = true;
|
|
345
|
+
if (rewritten === code) return;
|
|
346
|
+
return {
|
|
347
|
+
code: rewritten,
|
|
348
|
+
map: null
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
if (!is_remote_module(id) || !code.includes("__sveltekit/remote")) return;
|
|
352
|
+
const has_remote_form = /\.[\s\n]*form[\s\n]*\(/.test(code);
|
|
353
|
+
has_remote_form_module ||= has_remote_form;
|
|
354
|
+
if (has_remote_form) {
|
|
355
|
+
const resolved_runtime = await this.resolve("__sveltekit/remote", id);
|
|
356
|
+
if (!resolved_runtime || !is_sveltekit_remote_runtime_index(resolved_runtime.id)) this.error(make_missing_sveltekit_remote_runtime_message());
|
|
357
|
+
}
|
|
358
|
+
const rewritten = await rewrite_remote_client_exports(code, options);
|
|
359
|
+
if (rewritten === code) return;
|
|
360
|
+
return {
|
|
361
|
+
code: rewritten,
|
|
362
|
+
map: null
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
function is_server_runtime_module(id) {
|
|
368
|
+
const [filename] = id.split("?", 2);
|
|
369
|
+
return /\.(server|remote)(?:\.[cm])?\.[jt]s$/.test(filename) || /(?:^|[\\/])hooks\.server(?:\.[cm])?\.[jt]s$/.test(filename);
|
|
370
|
+
}
|
|
371
|
+
function is_remote_module(id) {
|
|
372
|
+
return /\.(remote|remote\.[cm]?)\.[jt]s(?:\?.*)?$/.test(id) || id.includes(".remote.");
|
|
373
|
+
}
|
|
374
|
+
function is_svelte_component_module(id, extensions) {
|
|
375
|
+
const [filename, query = ""] = id.split("?", 2);
|
|
376
|
+
if (!extensions.some((extension) => filename.endsWith(extension))) return false;
|
|
377
|
+
if (query.length === 0) return true;
|
|
378
|
+
const params = new URLSearchParams(query);
|
|
379
|
+
const allowed_params = ["t", "v"];
|
|
380
|
+
return [...params.keys()].every((key) => allowed_params.includes(key));
|
|
381
|
+
}
|
|
382
|
+
function may_have_effect_diagnostics(code) {
|
|
383
|
+
return /\byield\s*\*/.test(code) || code.includes("Effect") || /["']effect(?:\/Effect)?["']/.test(code);
|
|
384
|
+
}
|
|
385
|
+
function may_have_ser_syntax(code) {
|
|
386
|
+
return /\byield\s*\*/.test(code) || /<script\b[^>]*\beffect(?:[\s=>]|$)/i.test(code);
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* Rewrites SvelteKit's generated client remote module from:
|
|
390
|
+
*
|
|
391
|
+
* `export const get_post = __remote.query("hash/get_post")`
|
|
392
|
+
*
|
|
393
|
+
* into an Effect-aware wrapper around the same native function.
|
|
394
|
+
*
|
|
395
|
+
* @example
|
|
396
|
+
* ```ts
|
|
397
|
+
* const rewritten = await rewrite_remote_client_exports(remote_module_code);
|
|
398
|
+
* ```
|
|
399
|
+
*
|
|
400
|
+
* @since 2.0.0
|
|
401
|
+
* @param code - The generated client remote module code.
|
|
402
|
+
* @param options - Optional plugin options.
|
|
403
|
+
* @returns A promise that resolves to the rewritten module code.
|
|
404
|
+
* @internal
|
|
405
|
+
*/
|
|
406
|
+
async function rewrite_remote_client_exports(code, options) {
|
|
407
|
+
return (await import("./remote-client-mkQAfP1G.js")).rewrite_remote_client_exports(code, options);
|
|
408
|
+
}
|
|
409
|
+
//#endregion
|
|
410
|
+
export { rewrite_remote_client_exports as n, effect as t };
|
|
411
|
+
|
|
412
|
+
//# sourceMappingURL=compiler-Dpyu4Owd.js.map
|