svelte-effect-runtime 4.0.0 → 4.0.1

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.
Files changed (146) hide show
  1. package/.dist/chunks/client-BrZka6DW.js +530 -0
  2. package/.dist/chunks/client-BrZka6DW.js.map +1 -0
  3. package/.dist/chunks/compiler-COVzgLYo.js +412 -0
  4. package/.dist/chunks/compiler-COVzgLYo.js.map +1 -0
  5. package/.dist/chunks/descriptors-B4otDlm1.js +216 -0
  6. package/.dist/chunks/descriptors-B4otDlm1.js.map +1 -0
  7. package/.dist/chunks/diagnostics-BDrky-Di.js +359 -0
  8. package/.dist/chunks/diagnostics-BDrky-Di.js.map +1 -0
  9. package/.dist/chunks/dispatcher-BA0PLQhA.js +16 -0
  10. package/.dist/chunks/dispatcher-BA0PLQhA.js.map +1 -0
  11. package/.dist/chunks/{dispatcher-DOx8iC6r.js → dispatcher-_x0MQZBS.js} +84 -258
  12. package/.dist/chunks/dispatcher-_x0MQZBS.js.map +1 -0
  13. package/.dist/chunks/{errors-IJjsUwrE.js → errors-CLsbGjIa.js} +39 -44
  14. package/.dist/chunks/errors-CLsbGjIa.js.map +1 -0
  15. package/.dist/chunks/live-BundLSoY.js +146 -0
  16. package/.dist/chunks/live-BundLSoY.js.map +1 -0
  17. package/.dist/chunks/live-CHK0RrZu.js +10 -0
  18. package/.dist/chunks/live-CHK0RrZu.js.map +1 -0
  19. package/.dist/chunks/{remote-client-CVI4t66c.js → remote-client-mkQAfP1G.js} +29 -23
  20. package/.dist/chunks/remote-client-mkQAfP1G.js.map +1 -0
  21. package/.dist/chunks/{runtime-GBQz32DZ.js → runtime-HDTlEnzp.js} +3 -27
  22. package/.dist/chunks/runtime-HDTlEnzp.js.map +1 -0
  23. package/.dist/chunks/{server-D1LcDnZE.js → server-BNrA1I-u.js} +15 -84
  24. package/.dist/chunks/server-BNrA1I-u.js.map +1 -0
  25. package/.dist/chunks/source-scan-9pZxnfct.js +1059 -0
  26. package/.dist/chunks/source-scan-9pZxnfct.js.map +1 -0
  27. package/.dist/chunks/{transform-jNUr65K9.js → transform-BXyYUAez.js} +184 -358
  28. package/.dist/chunks/transform-BXyYUAez.js.map +1 -0
  29. package/.dist/compiler/markup-identifiers.d.ts +2 -0
  30. package/.dist/compiler/remote-client.d.ts +1 -19
  31. package/.dist/compiler/source-scan.d.ts +11 -108
  32. package/.dist/compiler/sveltekit-remote-bridge.d.ts +3 -0
  33. package/.dist/compiler.d.ts +6 -0
  34. package/.dist/compiler.js +1 -1
  35. package/.dist/detect.d.ts +0 -31
  36. package/.dist/detect.js +0 -39
  37. package/.dist/detect.js.map +1 -1
  38. package/.dist/diagnostics.d.ts +0 -16
  39. package/.dist/dispatcher/deps.d.ts +3 -14
  40. package/.dist/dispatcher/fibers.d.ts +5 -46
  41. package/.dist/dispatcher/index.d.ts +1 -143
  42. package/.dist/dispatcher/types.d.ts +0 -151
  43. package/.dist/dispatcher.js +1 -1
  44. package/.dist/errors.d.ts +30 -42
  45. package/.dist/generated/dispatcher.d.ts +0 -50
  46. package/.dist/generators.d.ts +1 -12
  47. package/.dist/internal/descriptors.d.ts +0 -16
  48. package/.dist/internal/generators.js +13 -8
  49. package/.dist/internal/generators.js.map +1 -1
  50. package/.dist/internal/live.d.ts +9 -0
  51. package/.dist/internal/remote-client.js +2 -2
  52. package/.dist/internal/remote-server.js +2 -2
  53. package/.dist/internal/schema.d.ts +0 -54
  54. package/.dist/live.d.ts +9 -26
  55. package/.dist/markup/event-attributes.d.ts +0 -32
  56. package/.dist/markup/promise.d.ts +1 -23
  57. package/.dist/markup/promise.js +2 -18
  58. package/.dist/markup/promise.js.map +1 -1
  59. package/.dist/markup/run.d.ts +1 -10
  60. package/.dist/markup/run.js +2 -11
  61. package/.dist/markup/run.js.map +1 -1
  62. package/.dist/markup/transform/apply.d.ts +4 -4
  63. package/.dist/markup/transform/classify.d.ts +2 -11
  64. package/.dist/markup/transform/constants.d.ts +1 -1
  65. package/.dist/markup/transform/effect-bindings.d.ts +2 -26
  66. package/.dist/markup/transform/effect-callbacks.d.ts +0 -20
  67. package/.dist/markup/transform/emit.d.ts +2 -11
  68. package/.dist/markup/transform/expressions.d.ts +0 -35
  69. package/.dist/markup/transform/scan.d.ts +3 -22
  70. package/.dist/markup/transform/types.d.ts +1 -129
  71. package/.dist/markup/transform.js +1 -1
  72. package/.dist/markup/value.d.ts +1 -18
  73. package/.dist/markup/value.js +2 -19
  74. package/.dist/markup/value.js.map +1 -1
  75. package/.dist/mod.d.ts +3 -8
  76. package/.dist/mod.js +5 -5
  77. package/.dist/mod.js.map +1 -1
  78. package/.dist/remote/cause-codec.d.ts +3 -37
  79. package/.dist/remote/client/command.d.ts +3 -17
  80. package/.dist/remote/client/form-data.d.ts +0 -7
  81. package/.dist/remote/client/form-enhance.d.ts +0 -7
  82. package/.dist/remote/client/form-transport.d.ts +14 -20
  83. package/.dist/remote/client/form.d.ts +4 -24
  84. package/.dist/remote/client/index.d.ts +2 -1
  85. package/.dist/remote/client/prerender.d.ts +6 -0
  86. package/.dist/remote/client/query-result.d.ts +2 -14
  87. package/.dist/remote/client/query.d.ts +8 -48
  88. package/.dist/remote/client/responses.d.ts +3 -27
  89. package/.dist/remote/client/types.d.ts +16 -110
  90. package/.dist/remote/client/utils.d.ts +0 -8
  91. package/.dist/remote/client.d.ts +2 -2
  92. package/.dist/remote/client.js +2 -2
  93. package/.dist/remote/effect.d.ts +6 -0
  94. package/.dist/remote/failures.d.ts +4 -0
  95. package/.dist/remote/query-update.d.ts +2 -0
  96. package/.dist/remote/resource.d.ts +25 -0
  97. package/.dist/remote/server.d.ts +5 -50
  98. package/.dist/remote/server.js +2 -2
  99. package/.dist/remote/shared.d.ts +6 -145
  100. package/.dist/remote/shared.js +6 -127
  101. package/.dist/remote/shared.js.map +1 -1
  102. package/.dist/runtime/transform.js +5 -22
  103. package/.dist/runtime/transform.js.map +1 -1
  104. package/.dist/script-transform/ast.d.ts +0 -46
  105. package/.dist/script-transform/imports.d.ts +0 -38
  106. package/.dist/script-transform/lower.d.ts +0 -9
  107. package/.dist/script-transform/runes.d.ts +0 -10
  108. package/.dist/script-transform/runtime-block.d.ts +0 -17
  109. package/.dist/script-transform/source.d.ts +0 -24
  110. package/.dist/script-transform/types.d.ts +1 -126
  111. package/.dist/server/effects.d.ts +4 -53
  112. package/.dist/server/factories.d.ts +7 -7
  113. package/.dist/server/index.d.ts +1 -1
  114. package/.dist/server/invalid.d.ts +0 -7
  115. package/.dist/server/live-snapshot.d.ts +5 -0
  116. package/.dist/server/remote-handler-context.d.ts +5 -0
  117. package/.dist/server/runtime.d.ts +6 -24
  118. package/.dist/server/schema.d.ts +0 -14
  119. package/.dist/server/transport.d.ts +2 -0
  120. package/.dist/server/types.d.ts +49 -26
  121. package/.dist/server/wrappers.d.ts +3 -40
  122. package/.dist/server.d.ts +1 -1
  123. package/.dist/server.js +200 -215
  124. package/.dist/server.js.map +1 -1
  125. package/.dist/yieldable.d.ts +1 -35
  126. package/package.json +2 -2
  127. package/.dist/chunks/client-DcZUV4rR.js +0 -653
  128. package/.dist/chunks/client-DcZUV4rR.js.map +0 -1
  129. package/.dist/chunks/compiler-BBPNyXmQ.js +0 -460
  130. package/.dist/chunks/compiler-BBPNyXmQ.js.map +0 -1
  131. package/.dist/chunks/dispatcher-DOx8iC6r.js.map +0 -1
  132. package/.dist/chunks/dispatcher-H-Ia0Os4.js +0 -47
  133. package/.dist/chunks/dispatcher-H-Ia0Os4.js.map +0 -1
  134. package/.dist/chunks/errors-IJjsUwrE.js.map +0 -1
  135. package/.dist/chunks/live-BXAKre_4.js +0 -104
  136. package/.dist/chunks/live-BXAKre_4.js.map +0 -1
  137. package/.dist/chunks/remote-client-CVI4t66c.js.map +0 -1
  138. package/.dist/chunks/runtime-GBQz32DZ.js.map +0 -1
  139. package/.dist/chunks/schema-D9pct6Y5.js +0 -89
  140. package/.dist/chunks/schema-D9pct6Y5.js.map +0 -1
  141. package/.dist/chunks/server-D1LcDnZE.js.map +0 -1
  142. package/.dist/chunks/source-scan-C4PsggID.js +0 -341
  143. package/.dist/chunks/source-scan-C4PsggID.js.map +0 -1
  144. package/.dist/chunks/transform-jNUr65K9.js.map +0 -1
  145. package/.dist/remote/client/effect.d.ts +0 -29
  146. package/.dist/remote/client/failures.d.ts +0 -42
@@ -1 +0,0 @@
1
- {"version":3,"file":"client-DcZUV4rR.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/remote/client/utils.ts","../../../modules/svelte-effect-runtime/src/remote/client/failures.ts","../../../modules/svelte-effect-runtime/src/remote/client/responses.ts","../../../modules/svelte-effect-runtime/src/remote/client/effect.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/query.ts"],"sourcesContent":["export { copy_property_descriptors } from \"$/internal/descriptors.ts\";\nimport type { NativeMethod } from \"./types.ts\";\n\n/**\n * Checks whether a value has a callable method property.\n *\n * @since 2.0.0\n * @param value - Value to inspect.\n * @param key - Method key to look up.\n * @returns Whether the value has a function at `key`.\n */\nexport function has_method<K extends PropertyKey>(\n\tvalue: unknown,\n\tkey: K,\n): value is Record<K, NativeMethod> {\n\treturn (\n\t\ttypeof value === \"object\" &&\n\t\tvalue !== null &&\n\t\ttypeof (value as Record<PropertyKey, unknown>)[key] === \"function\"\n\t);\n}\n","import {\n\tcreate_remote_http_error,\n\tcreate_remote_transport_error,\n\tis_serialized_remote_failure_envelope,\n} from \"$/remote/shared.ts\";\nimport type { RemoteFailure } from \"$/remote/shared.ts\";\nimport { RemoteErrorDecodeError } from \"$/errors.ts\";\nimport { Option, Schema } from \"effect\";\nimport { parse } from \"devalue\";\n\ntype JsonStringDecode =\n\t| {\n\t\t\treadonly _tag: \"JsonStringDecoded\";\n\t\t\treadonly value: unknown;\n\t }\n\t| {\n\t\t\treadonly _tag: \"JsonStringIgnored\";\n\t };\n\ntype EmbeddedRemoteFailureDecode =\n\t| {\n\t\t\treadonly _tag: \"EmbeddedRemoteFailureDecoded\";\n\t\t\treadonly value: unknown;\n\t }\n\t| {\n\t\t\treadonly _tag: \"EmbeddedRemoteFailureIgnored\";\n\t };\n\ntype SerializedRemoteFailureDecode<ErrorType> =\n\t| {\n\t\t\treadonly _tag: \"SerializedRemoteFailureDecoded\";\n\t\t\treadonly value: RemoteFailure<ErrorType>;\n\t }\n\t| {\n\t\t\treadonly _tag: \"SerializedRemoteFailureInvalid\";\n\t };\n\nconst RemoteErrorMessageEnvelopeSchema = Schema.Struct({\n\tmessage: Schema.String,\n});\n\nconst DecodedRemoteFailureSchema = Schema.Struct({\n\t_tag: Schema.String,\n});\n\nconst DecodeJsonString = Schema.decodeUnknownOption(Schema.UnknownFromJsonString);\nconst is_decoded_remote_failure_value = Schema.is(DecodedRemoteFailureSchema);\nconst is_remote_error_message_envelope = Schema.is(RemoteErrorMessageEnvelopeSchema);\n\n/**\n * Decodes a raw wire value into a remote failure when it uses the runtime\n * failure envelope.\n *\n * @example\n * ```ts\n * const failure = decode_remote_error(body);\n * ```\n *\n * @since 2.0.0\n * @param raw - Raw value received from the network or SvelteKit error body.\n * @param decode - Optional devalue decoder for custom error payloads.\n * @returns The decoded failure/value, or a transport error when decoding fails.\n */\nexport function decode_remote_error<ErrorType = never>(\n\traw: unknown,\n\tdecode?: (encoded: string) => unknown,\n): RemoteFailure<ErrorType> | unknown {\n\tconst embedded = decode_embedded_remote_failure(raw);\n\n\tif (embedded._tag === \"EmbeddedRemoteFailureDecoded\") {\n\t\treturn decode_remote_error<ErrorType>(embedded.value, decode);\n\t}\n\n\tif (is_serialized_remote_failure_envelope(raw)) {\n\t\tconst decoded = decode_serialized_remote_failure<ErrorType>(raw.encoded, decode);\n\n\t\tif (decoded._tag === \"SerializedRemoteFailureInvalid\") {\n\t\t\treturn create_remote_transport_error(new RemoteErrorDecodeError(raw), raw);\n\t\t}\n\n\t\treturn decoded.value;\n\t}\n\n\treturn raw;\n}\n\nfunction decode_embedded_remote_failure(raw: unknown): EmbeddedRemoteFailureDecode {\n\tif (typeof raw === \"string\") {\n\t\treturn decode_embedded_json_remote_failure(raw);\n\t}\n\n\tif (!is_remote_error_message_envelope(raw)) {\n\t\treturn { _tag: \"EmbeddedRemoteFailureIgnored\" };\n\t}\n\n\treturn decode_embedded_json_remote_failure(raw.message);\n}\n\nfunction decode_embedded_json_remote_failure(value: string): EmbeddedRemoteFailureDecode {\n\tconst decoded = decode_json_string(value);\n\n\tif (decoded._tag === \"JsonStringIgnored\") {\n\t\treturn { _tag: \"EmbeddedRemoteFailureIgnored\" };\n\t}\n\n\treturn {\n\t\t_tag: \"EmbeddedRemoteFailureDecoded\",\n\t\tvalue: decoded.value,\n\t};\n}\n\nfunction decode_json_string(value: string): JsonStringDecode {\n\tconst decoded = DecodeJsonString(value);\n\n\tif (!Option.isSome(decoded)) {\n\t\treturn { _tag: \"JsonStringIgnored\" };\n\t}\n\n\treturn {\n\t\t_tag: \"JsonStringDecoded\",\n\t\tvalue: decoded.value,\n\t};\n}\n\nfunction decode_serialized_remote_failure<ErrorType>(\n\tencoded: string,\n\tdecode: ((encoded: string) => unknown) | undefined,\n): SerializedRemoteFailureDecode<ErrorType> {\n\ttry {\n\t\tconst decoded = decode ? decode(encoded) : parse(encoded);\n\n\t\treturn {\n\t\t\t_tag: \"SerializedRemoteFailureDecoded\",\n\t\t\tvalue: decoded as RemoteFailure<ErrorType>,\n\t\t};\n\t} catch {\n\t\treturn { _tag: \"SerializedRemoteFailureInvalid\" };\n\t}\n}\n\n/**\n * Checks whether a decoded value is a tagged remote failure.\n *\n * @example\n * ```ts\n * if (is_decoded_remote_failure(value)) throw value;\n * ```\n *\n * @since 2.0.0\n * @param value - Value to inspect.\n * @returns Whether the value carries a `_tag` discriminator.\n */\nexport function is_decoded_remote_failure(value: unknown): value is RemoteFailure<never> {\n\treturn is_decoded_remote_failure_value(value);\n}\n\n/**\n * Normalizes native thrown values into the runtime's remote failure model.\n *\n * @example\n * ```ts\n * const failure = normalize_native_error(error);\n * ```\n *\n * @since 2.0.0\n * @param error - Unknown value thrown by a native remote helper.\n * @returns A typed remote failure.\n */\nexport function normalize_native_error<ErrorType = never>(\n\terror: unknown,\n): RemoteFailure<ErrorType> {\n\tconst body = get_error_body(error);\n\tconst decoded = decode_remote_error<ErrorType>(body);\n\tconst status = get_error_status(error);\n\n\tif (is_decoded_remote_failure(decoded)) {\n\t\treturn decoded;\n\t}\n\n\tif (status !== undefined) {\n\t\treturn create_remote_http_error(status, body, error);\n\t}\n\n\treturn create_remote_transport_error(error);\n}\n\nfunction get_error_status(error: unknown): number | undefined {\n\tif (typeof error !== \"object\" || error === null) {\n\t\treturn undefined;\n\t}\n\n\tconst status = (error as { status?: unknown }).status;\n\n\treturn typeof status === \"number\" ? status : undefined;\n}\n\nfunction get_error_body(error: unknown): unknown {\n\tif (typeof error !== \"object\" || error === null) {\n\t\treturn undefined;\n\t}\n\n\tif (\"body\" in error) {\n\t\treturn (error as { body?: unknown }).body;\n\t}\n\n\tif (\"data\" in error) {\n\t\treturn (error as { data?: unknown }).data;\n\t}\n\n\treturn undefined;\n}\n","import { create_remote_http_error } from \"$/remote/shared.ts\";\nimport type { RemoteFailure } from \"$/remote/shared.ts\";\n\nimport { decode_remote_error, is_decoded_remote_failure } from \"./failures.ts\";\n\n/**\n * Decodes a failed fetch response into the runtime failure model.\n *\n * @example\n * ```ts\n * const failure = await decode_response_failure(response);\n * ```\n *\n * @since 2.0.0\n * @param response - Failed fetch response returned by the remote endpoint.\n * @returns Remote failure represented by the response.\n */\nexport async function decode_response_failure<ErrorType = never>(\n\tresponse: Response,\n): Promise<RemoteFailure<ErrorType>> {\n\tconst body = await response.json().catch(() => undefined);\n\tconst decoded = decode_remote_error<ErrorType>(body);\n\n\tif (is_decoded_remote_failure(decoded)) {\n\t\treturn decoded;\n\t}\n\n\treturn create_remote_http_error(response.status, body);\n}\n\n/**\n * Decodes either a raw value or `Response` returned by a native remote helper.\n *\n * @example\n * ```ts\n * const output = await decode_response_or_value(result, decode_payload);\n * ```\n *\n * @since 2.0.0\n * @param value - Native result value or fetch response.\n * @param decode_payload - Function used to decode successful payloads.\n * @returns Decoded successful output.\n */\nexport async function decode_response_or_value<Output, ErrorType = never>(\n\tvalue: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n): Promise<Output> {\n\tif (value instanceof Response) {\n\t\tif (!value.ok) {\n\t\t\tthrow await decode_response_failure<ErrorType>(value);\n\t\t}\n\n\t\tconst data = await decode_success_response_body(value);\n\n\t\treturn decode_payload(data) as Output;\n\t}\n\n\treturn decode_payload(value) as Output;\n}\n\nasync function decode_success_response_body(response: Response): Promise<unknown> {\n\tif (response.status === 204 || response.status === 205) {\n\t\treturn undefined;\n\t}\n\n\tconst text = await response.text();\n\n\tif (text.length === 0) {\n\t\treturn undefined;\n\t}\n\n\treturn JSON.parse(text);\n}\n","import type { RemoteFailure } from \"$/remote/shared.ts\";\nimport { isRedirect } from \"@sveltejs/kit\";\nimport { Effect } from \"effect\";\n\nimport { is_decoded_remote_failure, normalize_native_error } from \"./failures.ts\";\n\n/**\n * Wraps a promise-producing remote operation in an Effect with failure mapping.\n *\n * @example\n * ```ts\n * const program = make_effect_from_promise(() => native_remote(input));\n * ```\n *\n * @since 2.0.0\n * @param run - Promise-producing operation that invokes a native remote helper.\n * @returns Effect that maps thrown values into remote failures.\n */\nexport function MakeEffectFromPromise<Output, ErrorType = never>(\n\trun: () => Promise<Output>,\n): Effect.Effect<Output, RemoteFailure<ErrorType>> {\n\treturn Effect.tryPromise({\n\t\ttry: run,\n\t\tcatch: (error: unknown) => {\n\t\t\tif (isRedirect(error)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\tif (is_decoded_remote_failure(error)) {\n\t\t\t\treturn error;\n\t\t\t}\n\n\t\t\treturn normalize_native_error<ErrorType>(error);\n\t\t},\n\t}) as Effect.Effect<Output, RemoteFailure<ErrorType>>;\n}\n\n/**\n * Compatibility alias for {@link MakeEffectFromPromise}.\n *\n * @example\n * ```ts\n * const program = make_effect_from_promise(() => native_remote(input));\n * ```\n *\n * @since 2.0.0\n * @param run - Promise-producing operation that invokes a native remote helper.\n * @returns Effect that maps thrown values into remote failures.\n * @internal\n */\nexport const make_effect_from_promise = MakeEffectFromPromise;\n","import { copy_property_descriptors, has_method } from \"./utils.ts\";\nimport { decode_response_or_value } from \"./responses.ts\";\nimport { InvalidCommandFactoryError } from \"$/errors.ts\";\nimport type { RemoteFailure } from \"$/remote/shared.ts\";\nimport type { NativeMethod, Pending } from \"./types.ts\";\nimport { MakeEffectFromPromise } from \"./effect.ts\";\nimport type { Effect } from \"effect\";\n\ntype EffectRemoteCommandAdapter<Input, Output, ErrorType = never> = ((\n\tinput: undefined extends Input ? Input | void : Input,\n) => Effect.Effect<Output, RemoteFailure<ErrorType>>) & {\n\treadonly pending: number;\n};\n\n/**\n * Creates a remote command adapter. The adapter preserves the native\n * pending getter and turns each invocation into an Effect.\n *\n * @since 2.0.0\n * @param native_factory - SvelteKit's native command function or a legacy\n * response factory used by tests.\n * @param decode_payload - Function to decode the response payload.\n * @param _base - Deprecated transport base retained for compatibility.\n * @param pending - Optional pending counter for legacy response factories.\n * @returns A function returning an Effect of the response.\n * @internal\n */\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\tMakeEffectFromPromise<Output, ErrorType>(async () => {\n\t\t\tcount.value += 1;\n\n\t\t\ttry {\n\t\t\t\tconst result = invoke\n\t\t\t\t\t? await invoke(input)\n\t\t\t\t\t: await (native_factory as NativeMethod)(input);\n\n\t\t\t\treturn await decode_response_or_value<Output, ErrorType>(result, decode_payload);\n\t\t\t} finally {\n\t\t\t\tcount.value -= 1;\n\t\t\t}\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","/**\n * Encodes remote form input into SvelteKit-compatible form data.\n *\n * @since 2.0.0\n * @param input - Input value supplied to the remote form.\n * @returns FormData payload for the remote endpoint.\n */\nexport 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\tif (value) {\n\t\t\tform_data.append(`b:${path}`, \"on\");\n\t\t}\n\n\t\treturn;\n\t}\n\n\tform_data.append(path, value === null ? \"\" : String(value));\n}\n","import {\n\tcreate_remote_http_error,\n\tcreate_remote_transport_error,\n\tcreate_remote_validation_error,\n} from \"$/remote/shared.ts\";\nimport {\n\tInvalidRemoteFormResponseError,\n\tRemoteFormEndpointMissingError,\n\tUnsupportedRemoteFormResponseError,\n} from \"$/errors.ts\";\nimport type { StandardSchema } from \"$/internal/schema.ts\";\nimport type { FormIssue } from \"$/remote/shared.ts\";\nimport { Option, Schema } from \"effect\";\nimport { parse } from \"devalue\";\n\nimport { decode_remote_error, is_decoded_remote_failure } from \"./failures.ts\";\nimport { decode_response_failure } from \"./responses.ts\";\nimport { to_form_data } from \"./form-data.ts\";\nimport type { NativeFormRecord } from \"./types.ts\";\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 | undefined;\n\t\t\treadonly result?: string | undefined;\n\t };\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.optional(Schema.String),\n\tresult: Schema.optional(Schema.String),\n});\n\nconst RemoteFormResponseEnvelopeSchema = Schema.Union([\n\tRemoteFormErrorEnvelopeSchema,\n\tRemoteFormResultEnvelopeSchema,\n]);\n\nconst RemoteFormDecodedPayloadSchema = Schema.Struct({\n\tissues: Schema.optional(Schema.Array(FormIssueSchema)),\n\tresult: Schema.optional(Schema.Unknown),\n});\n\nconst DecodeRemoteFormResponseEnvelope = Schema.decodeUnknownOption(\n\tRemoteFormResponseEnvelopeSchema,\n);\nconst DecodeRemoteFormPayload = Schema.decodeUnknownOption(RemoteFormDecodedPayloadSchema);\n\n/**\n * Submits a native remote form through the SvelteKit remote endpoint.\n *\n * @since 2.0.0\n * @param form_obj - Native form object being adapted.\n * @param input - Form input value.\n * @param decode_payload - Function to decode successful payloads.\n * @param remote_base - Base URL for the remote endpoint.\n * @param preflight_schema - Optional schema used to mirror SvelteKit's\n * client-side preflight before posting direct programmatic input.\n * @returns Decoded form output.\n */\nexport async function submit_remote_form<Output>(\n\tform_obj: NativeFormRecord,\n\tinput: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n\tremote_base: string,\n\tpreflight_schema?: StandardSchema,\n): Promise<Output> {\n\tconst action_id = get_remote_action_id(form_obj);\n\n\tif (!action_id || remote_base.length === 0) {\n\t\tthrow create_remote_transport_error(new RemoteFormEndpointMissingError());\n\t}\n\n\tawait validate_preflight_input(preflight_schema, input);\n\n\tconst response = await fetch(to_remote_form_url(remote_base, action_id), {\n\t\tmethod: \"POST\",\n\t\theaders: get_remote_request_headers(),\n\t\tbody: to_form_data(input),\n\t});\n\n\tif (!response.ok) {\n\t\tthrow await decode_response_failure(response);\n\t}\n\n\tconst envelope = await response.json();\n\n\treturn decode_form_response<Output>(envelope, decode_payload);\n}\n\n/**\n * Extracts SvelteKit's remote action id from a native form action URL.\n *\n * @since 2.0.0\n * @param form_obj - Native form object being adapted.\n * @returns Remote action id when present.\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 tail = parts.slice(2).join(\"/\");\n\tconst normalized_base = remote_base.replace(/\\/$/, \"\");\n\n\tif (tail.length === 0) {\n\t\treturn `${normalized_base}/${head}`;\n\t}\n\n\treturn `${normalized_base}/${head}/${encodeURIComponent(tail)}`;\n}\n\nfunction get_remote_request_headers(): HeadersInit {\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\nasync function validate_preflight_input(\n\tschema: StandardSchema | undefined,\n\tinput: unknown,\n): Promise<void> {\n\tif (!schema) {\n\t\treturn;\n\t}\n\n\tconst validated = await schema[\"~standard\"].validate(input);\n\n\tif (!is_record(validated) || !Array.isArray(validated.issues)) {\n\t\treturn;\n\t}\n\n\tconst issues = validated.issues.map(normalize_standard_issue);\n\n\tthrow create_remote_validation_error(issues, { issues }, 400);\n}\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\nfunction decode_form_response<Output>(\n\tenvelope: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n): Output {\n\tconst response = decode_remote_form_response_envelope(envelope);\n\n\tif (!response) {\n\t\tthrow create_remote_transport_error(new InvalidRemoteFormResponseError(envelope), envelope);\n\t}\n\n\tif (response._tag === \"RemoteFormErrorEnvelope\") {\n\t\tconst decoded = decode_remote_error(response.error);\n\n\t\tif (is_decoded_remote_failure(decoded)) {\n\t\t\tthrow decoded;\n\t\t}\n\n\t\tthrow create_remote_http_error(response.status ?? 500, response.error);\n\t}\n\n\tconst result_text = response.result ?? response.data;\n\n\tif (result_text === undefined) {\n\t\tthrow create_remote_transport_error(\n\t\t\tnew UnsupportedRemoteFormResponseError(envelope),\n\t\t\tenvelope,\n\t\t);\n\t}\n\n\tconst parsed = parse(result_text);\n\tconst decoded = decode_remote_form_payload<Output>(decode_payload(parsed));\n\n\tif (!decoded) {\n\t\tthrow create_remote_transport_error(\n\t\t\tnew UnsupportedRemoteFormResponseError(envelope),\n\t\t\tenvelope,\n\t\t);\n\t}\n\n\tif (decoded.issues && decoded.issues.length > 0) {\n\t\tthrow create_remote_validation_error(decoded.issues, decoded, 400);\n\t}\n\n\treturn decoded.result as Output;\n}\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\treturn {\n\t\t_tag: \"RemoteFormResultEnvelope\",\n\t\tdata: decoded.value.data,\n\t\tresult: decoded.value.result,\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 { get_dispatcher } from \"$/dispatcher.ts\";\nimport { Effect } from \"effect\";\n\nimport { MakeEffectFromPromise } from \"./effect.ts\";\nimport { has_method } from \"./utils.ts\";\nimport type { EffectRemoteFormSubmit, NativeMethod } from \"./types.ts\";\n\n/**\n * Wraps a remote form enhance callback so Effect return values are run.\n *\n * @since 2.0.0\n * @param callback - Native enhance callback to wrap.\n * @returns Wrapped callback or undefined.\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: () => make_submit_effect<Output, ErrorType>(original_submit, event),\n\t\t\t},\n\t\t},\n\t);\n}\n\nfunction make_submit_effect<Output, ErrorType>(\n\toriginal_submit: NativeMethod,\n\tevent: unknown,\n): EffectRemoteFormSubmit<Output, ErrorType> {\n\tlet updates_args: unknown[] | undefined;\n\n\tconst SubmitEffect = MakeEffectFromPromise<Output | undefined, ErrorType>(\n\t\tasync (): Promise<Output | undefined> => {\n\t\t\tconst result = original_submit();\n\t\t\tconst value =\n\t\t\t\tupdates_args && has_method(result, \"updates\")\n\t\t\t\t\t? await Promise.resolve(result.updates(...updates_args))\n\t\t\t\t\t: await Promise.resolve(result);\n\n\t\t\tif (typeof value === \"boolean\") {\n\t\t\t\treturn read_submit_result<Output>(event);\n\t\t\t}\n\n\t\t\treturn value as Output;\n\t\t},\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\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 type { RemoteFormInput } from \"@sveltejs/kit\";\n\nimport {\n\tis_standard_schema,\n\tnormalize_validator,\n\ttype StandardSchema,\n} from \"$/internal/schema.ts\";\nimport { decode_response_or_value } from \"./responses.ts\";\nimport { MakeEffectFromPromise } from \"./effect.ts\";\nimport { get_remote_action_id, submit_remote_form } from \"./form-transport.ts\";\nimport { copy_property_descriptors, has_method } from \"./utils.ts\";\nimport { wrap_enhance_callback } from \"./form-enhance.ts\";\nimport type { EffectRemoteForm, NativeFormRecord, NativeMethod } from \"./types.ts\";\n\ntype RemoteInput<Input> = undefined extends Input ? Input | void : Input;\n\ninterface RemoteFormAdapterState {\n\tshared_preflight_schema?: StandardSchema;\n}\n\n/**\n * Creates a remote form adapter. The callable preserves SvelteKit's native\n * form descriptors while wrapping `validate`, `enhance`, and programmatic\n * submission in Effect-returning APIs.\n *\n * @example\n * ```ts\n * const createPost = create_remote_form_adapter(nativeForm, (value) => value);\n * yield* createPost.validate({ includeUntouched: true });\n * ```\n *\n * @since 2.0.0\n * @param native_factory - SvelteKit's native form object.\n * @param decode_payload - Function to decode the response payload.\n * @param remote_base - Base URL for SvelteKit's remote endpoint.\n * @param adapter_state - Shared mutable state used to mirror root form\n * preflight schemas across keyed form instances.\n * @param keyed - Whether this adapter wraps a keyed form instance returned by\n * SvelteKit's native `for(...)` helper.\n * @returns A callable form function whose properties mirror the native form.\n * @internal\n */\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\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 submit_effect = (input?: RemoteInput<Input>) =>\n\t\tMakeEffectFromPromise<Output, ErrorType>(async () => {\n\t\t\tconst can_use_remote_endpoint =\n\t\t\t\tremote_base.length > 0 && get_remote_action_id(form_obj) !== undefined;\n\n\t\t\tif (has_method(form_obj, \"submit\") && !can_use_remote_endpoint) {\n\t\t\t\tconst result = await form_obj.submit(input);\n\n\t\t\t\treturn await decode_response_or_value<Output>(result, decode_payload);\n\t\t\t}\n\n\t\t\treturn await submit_remote_form<Output>(\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\tlocal_preflight_schema ?? adapter_state.shared_preflight_schema,\n\t\t\t);\n\t\t});\n\n\tconst callable = ((input?: RemoteInput<Input>) => submit_effect(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: submit_effect,\n\t});\n\n\tif (has_method(form_obj, \"validate\")) {\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\tMakeEffectFromPromise<void, ErrorType>(async () => {\n\t\t\t\t\tawait form_obj.validate(normalize_validate_options(form_obj.validate, options));\n\t\t\t\t}),\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\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\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 =\n\t\tsource.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 { decode_response_or_value } from \"./responses.ts\";\nimport { has_method } from \"./utils.ts\";\n\n/**\n * Resolves native query results, including SvelteKit run handles.\n *\n * @example\n * ```ts\n * const output = await resolve_query_result(result, decode_payload);\n * ```\n *\n * @since 2.0.0\n * @param value - Native query result or query run handle.\n * @param decode_payload - Function used to decode successful payloads.\n * @returns Decoded query output.\n */\nexport async function resolve_query_result<Output>(\n\tvalue: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n): Promise<Output> {\n\tif (has_method(value, \"then\")) {\n\t\tconst result = await Promise.resolve(value);\n\n\t\treturn decode_response_or_value(result, decode_payload);\n\t}\n\n\tif (has_method(value, \"run\")) {\n\t\tconst result = await value.run();\n\n\t\treturn decode_response_or_value(result, decode_payload);\n\t}\n\n\tconst result = await Promise.resolve(value);\n\n\treturn decode_response_or_value(result, decode_payload);\n}\n","import { InvalidLiveQueryFactoryError, InvalidQueryFactoryError } from \"$/errors.ts\";\nimport { copy_property_descriptors, has_method } from \"./utils.ts\";\nimport { normalize_native_error } from \"./failures.ts\";\nimport { resolve_query_result } from \"./query-result.ts\";\nimport { MakeEffectFromPromise } from \"./effect.ts\";\nimport type { EffectRemoteQueryUpdateBrand, NativeMethod } from \"./types.ts\";\nimport type { RemoteFailure } from \"$/remote/shared.ts\";\nimport { make_remote_live_stream, type RemoteLiveStream } from \"$/live.ts\";\nimport { Effect } from \"effect\";\n\ntype RemoteInput<Input> = undefined extends Input ? Input | void : Input;\n\ntype DecodePayload<Output> = (value: unknown) => Output;\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 RemoteResourceEffect<Output, ErrorType = never> = Effect.Effect<\n\tOutput,\n\tRemoteFailure<ErrorType>\n> & {\n\treadonly current: Output | undefined;\n\treadonly error: unknown;\n\treadonly loading: boolean;\n\treadonly ready: boolean;\n};\n\ntype RemoteResourceLike<Output, ErrorType = never> = RemoteResourceEffect<Output, ErrorType>;\n\ntype RemoteQueryEffect<Output, ErrorType = never> = RemoteResourceEffect<Output, ErrorType> & {\n\treadonly refresh: () => Effect.Effect<void, unknown, never>;\n\treadonly set: (value: Output) => void;\n\treadonly withOverride: (update: (current: Output) => Output) => unknown;\n};\n\ntype NativeRemoteResource<Output> = {\n\treadonly current?: Output;\n\treadonly error?: unknown;\n\treadonly loading?: boolean;\n\treadonly ready?: boolean;\n\treadonly refresh?: () => Promise<void>;\n\treadonly set?: (value: Output) => void;\n\treadonly withOverride?: (update: (current: Output) => Output) => unknown;\n};\n\n/**\n * Creates a remote query adapter. The returned function takes input and\n * returns an `Effect` that executes SvelteKit's native query function.\n *\n * @example\n * ```ts\n * const getUser = create_remote_query_adapter(nativeQuery, (value) => value);\n * const user = yield* getUser({ id: 1 });\n * ```\n *\n * @since 2.0.0\n * @param native_factory - SvelteKit's native query function or a legacy\n * response factory used by tests.\n * @param decode_payload - Function to decode the response payload.\n * @param _base - Deprecated transport base retained for compatibility.\n * @returns A function returning an Effect of the response.\n * @internal\n */\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): 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): 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): 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 MakeEffectFromPromise<Output, ErrorType>(async () => {\n\t\t\t\tconst result = await load?.(input);\n\n\t\t\t\treturn await resolve_query_result<Output>(result, decode_payload);\n\t\t\t}) as RemoteQueryEffect<Output, ErrorType>;\n\t\t}\n\n\t\tconst resource = query(input);\n\t\tconst QueryEffect = MakeEffectFromPromise<Output, ErrorType>(\n\t\t\tasync () => await resolve_query_result<Output>(resource, decode_payload),\n\t\t) as RemoteQueryEffect<Output, ErrorType>;\n\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\n\treturn wrapped;\n}\n\n/**\n * Creates a remote live query adapter. The returned function takes input and\n * returns an Effect Stream whose transport state is exposed through `Live`.\n *\n * @example\n * ```ts\n * const getTime = create_remote_live_query_adapter(nativeLive, (value) => value);\n * const time = getTime();\n * const first = yield* Stream.runHead(time);\n * ```\n *\n * @since 2.0.0\n * @param native_factory - SvelteKit's native live query function.\n * @param _decode_payload - Deprecated payload decoder retained for parity with\n * other remote adapters.\n * @param _base - Deprecated transport base retained for compatibility.\n * @returns A function returning a remote live stream.\n * @internal\n */\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 = query(input);\n\n\t\treturn make_remote_live_stream<Output, ErrorType>(resource, normalize_native_error);\n\t}) as EffectRemoteQueryUpdateBrand &\n\t\t((input: RemoteInput<Input>) => RemoteLiveStream<Output, ErrorType>);\n\n\tcopy_property_descriptors(native_factory, wrapped);\n\n\treturn wrapped;\n}\n\nfunction is_resource<Output>(resource: unknown): resource is NativeRemoteResource<Output> {\n\tconst resource_type = typeof resource;\n\n\treturn (resource_type === \"object\" && resource !== null) || resource_type === \"function\";\n}\n\nfunction attach_resource_getters<Output, ErrorType = never>(\n\tresource: unknown,\n\teffect: RemoteResourceLike<Output, ErrorType>,\n): void {\n\tconst methods = is_resource<Output>(resource) ? resource : undefined;\n\tconst keys = [\"current\", \"error\", \"loading\", \"ready\"] as const;\n\n\tif (!methods) {\n\t\treturn;\n\t}\n\n\tfor (const key of keys) {\n\t\tif (!(key in methods)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tObject.defineProperty(effect, key, {\n\t\t\tconfigurable: true,\n\t\t\tget: () => methods[key],\n\t\t});\n\t}\n}\n\nfunction attach_query_resource<Output, ErrorType = never>(\n\tresource: unknown,\n\teffect: RemoteQueryEffect<Output, ErrorType>,\n): void {\n\tconst methods = is_resource<Output>(resource) ? resource : undefined;\n\tconst refresh = methods?.refresh;\n\tconst set = methods?.set;\n\tconst with_override = methods?.withOverride;\n\n\tattach_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: () => MakeEffectFromPromise(() => Promise.resolve(refresh.call(resource))),\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"],"mappings":";;;;;;;;;;;;;;;;;AAWA,SAAgB,WACf,OACA,KACmC;CACnC,OACC,OAAO,UAAU,YACjB,UAAU,QACV,OAAQ,MAAuC,SAAS;AAE1D;;;ACiBA,MAAM,mCAAmC,OAAO,OAAO,EACtD,SAAS,OAAO,OACjB,CAAC;AAED,MAAM,6BAA6B,OAAO,OAAO,EAChD,MAAM,OAAO,OACd,CAAC;AAED,MAAM,mBAAmB,OAAO,oBAAoB,OAAO,qBAAqB;AAChF,MAAM,kCAAkC,OAAO,GAAG,0BAA0B;AAC5E,MAAM,mCAAmC,OAAO,GAAG,gCAAgC;;;;;;;;;;;;;;;AAgBnF,SAAgB,oBACf,KACA,QACqC;CACrC,MAAM,WAAW,+BAA+B,GAAG;CAEnD,IAAI,SAAS,SAAS,gCACrB,OAAO,oBAA+B,SAAS,OAAO,MAAM;CAG7D,IAAI,sCAAsC,GAAG,GAAG;EAC/C,MAAM,UAAU,iCAA4C,IAAI,SAAS,MAAM;EAE/E,IAAI,QAAQ,SAAS,kCACpB,OAAO,8BAA8B,IAAI,uBAAuB,GAAG,GAAG,GAAG;EAG1E,OAAO,QAAQ;CAChB;CAEA,OAAO;AACR;AAEA,SAAS,+BAA+B,KAA2C;CAClF,IAAI,OAAO,QAAQ,UAClB,OAAO,oCAAoC,GAAG;CAG/C,IAAI,CAAC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AClB,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"}
@@ -1,460 +0,0 @@
1
- import { t as scan_svelte_effect_source } from "./source-scan-C4PsggID.js";
2
- //#region src/diagnostics.ts
3
- /**
4
- * Finds best-effort SER usage diagnostics in Svelte component markup.
5
- *
6
- * @example
7
- * ```ts
8
- * const diagnostics = find_svelte_effect_diagnostics(
9
- * `<button onclick={Effect.gen}>save</button>`,
10
- * "Button.svelte",
11
- * );
12
- * ```
13
- *
14
- * @since 2.0.0
15
- * @param code - Svelte component source to scan for suspicious Effect usage.
16
- * @param filename - Filename used in diagnostic messages.
17
- * @returns Warning diagnostics with a message and source location.
18
- */
19
- function find_svelte_effect_diagnostics(code, filename) {
20
- const scan = scan_svelte_effect_source(code, filename);
21
- const effect_names = find_effect_local_names(scan.scripts);
22
- const line_starts = make_line_starts(code);
23
- return scan.markup_expressions.flatMap((expression) => make_expression_diagnostics(filename, effect_names, expression, line_starts));
24
- }
25
- function find_effect_local_names(scripts) {
26
- const names = /* @__PURE__ */ new Set(["Effect"]);
27
- for (const script of scripts) for (const import_match of script.text.matchAll(/import\s+(type\s+)?\{([^}]+)\}\s+from\s+["']effect["']/g)) {
28
- const is_type_only_import = import_match[1] !== void 0;
29
- const specifiers = import_match[2].split(",");
30
- if (is_type_only_import) continue;
31
- for (const specifier of specifiers) {
32
- const local_name = parse_effect_import_local_name(specifier);
33
- if (local_name) names.add(local_name);
34
- }
35
- }
36
- return names;
37
- }
38
- function parse_effect_import_local_name(specifier) {
39
- const match = specifier.trim().match(/^Effect(?:\s+as\s+([A-Za-z_$][\w$]*))?$/);
40
- if (!match) return;
41
- return match[1] ?? "Effect";
42
- }
43
- function make_expression_diagnostics(filename, effect_names, expression, line_starts) {
44
- const attribute_name = expression.attribute_name;
45
- const expression_text = expression.expression_text;
46
- /** The source scanner exposes a name only for a direct single-expression value. */
47
- const is_event_attribute = attribute_name !== void 0 && attribute_name.startsWith("on");
48
- const is_attribute = attribute_name !== void 0;
49
- if (!contains_effect_reference(expression_text, effect_names)) return [];
50
- if (starts_with_yield_star(expression_text)) return [];
51
- const loc = get_line_column(line_starts, expression.open);
52
- if (is_event_attribute && is_callback_expression(expression_text) && contains_yield_star(expression_text)) return [make_diagnostic(loc, make_hidden_event_yield_warning(filename, attribute_name, expression_text))];
53
- if (contains_effect_runner(expression_text, effect_names)) return [make_diagnostic(loc, make_explicit_runner_warning(filename, attribute_name, expression_text))];
54
- if (is_bare_effect_gen(expression_text, effect_names)) return [make_diagnostic(loc, make_bare_effect_gen_warning(filename, attribute_name, expression_text))];
55
- if (is_event_attribute && is_callback_expression(expression_text)) return [make_diagnostic(loc, make_event_callback_returns_effect_warning(filename, attribute_name, expression_text))];
56
- if (is_event_attribute) return [make_diagnostic(loc, make_event_attribute_effect_warning(filename, attribute_name, expression_text))];
57
- if (is_attribute) return [make_diagnostic(loc, make_attribute_effect_warning(filename, attribute_name, expression_text))];
58
- return [make_diagnostic(loc, make_sync_markup_effect_warning(filename, expression_text))];
59
- }
60
- function make_diagnostic(loc, message) {
61
- return {
62
- message,
63
- line: loc.line,
64
- column: loc.column
65
- };
66
- }
67
- function make_hidden_event_yield_warning(filename, attribute_name, expression_text) {
68
- return [
69
- `[svelte-effect-runtime] Detected yield* hidden inside an event callback.`,
70
- `${filename}: ${attribute_name}={${expression_text}}`,
71
- `SER can only lower yield* at the event attribute boundary.`,
72
- `Write the event expression directly, for example: ${attribute_name}={yield* save()}`
73
- ].join("\n");
74
- }
75
- function make_explicit_runner_warning(filename, attribute_name, expression_text) {
76
- return [
77
- `[svelte-effect-runtime] Detected an explicit Effect runner inside Svelte markup.`,
78
- `${filename}: ${attribute_name ? `${attribute_name}={${expression_text}}` : `{${expression_text}}`}`,
79
- `Explicit runners bypass SER cancellation and error handling for markup effects.`,
80
- `Prefer yield* so SER can manage the Effect lifecycle.`
81
- ].join("\n");
82
- }
83
- function make_bare_effect_gen_warning(filename, attribute_name, expression_text) {
84
- const location = attribute_name ? `${attribute_name}={${expression_text}}` : `{${expression_text}}`;
85
- const fixed = attribute_name ? `${attribute_name}={yield* ${expression_text}(function* () { ... })}` : `{yield* ${expression_text}(function* () { ... })}`;
86
- return [
87
- `[svelte-effect-runtime] Detected Effect.gen used as a value instead of an Effect program.`,
88
- `${filename}: ${location}`,
89
- `${expression_text} is a constructor, not the result of running a generator.`,
90
- `Use: ${fixed}`
91
- ].join("\n");
92
- }
93
- function make_event_callback_returns_effect_warning(filename, attribute_name, expression_text) {
94
- return [
95
- `[svelte-effect-runtime] Detected an event callback that returns an Effect but does not run it.`,
96
- `${filename}: ${attribute_name}={${expression_text}}`,
97
- `Svelte will call the callback and receive an Effect value, but SER will not manage it from inside the callback.`,
98
- `Use yield* at the event attribute boundary or explicitly run the Effect if you really want to bypass SER.`
99
- ].join("\n");
100
- }
101
- function make_event_attribute_effect_warning(filename, attribute_name, expression_text) {
102
- const fixed = `${attribute_name}={yield* ${expression_text}}`;
103
- return [
104
- `[svelte-effect-runtime] Detected an event attribute that looks like an Effect but is not written with yield*.`,
105
- `${filename}: ${attribute_name}={${expression_text}}`,
106
- `If you are trying to use Effect in this event handler, use yield* at the beginning.`,
107
- `Use: ${fixed}`
108
- ].join("\n");
109
- }
110
- function make_attribute_effect_warning(filename, attribute_name, expression_text) {
111
- const fixed = `${attribute_name}={yield* ${expression_text}}`;
112
- return [
113
- `[svelte-effect-runtime] Detected an attribute value that looks like an Effect but is not written with yield*.`,
114
- `${filename}: ${attribute_name}={${expression_text}}`,
115
- `Svelte attributes need the resolved Effect value, not the Effect object itself.`,
116
- `Use: ${fixed}`
117
- ].join("\n");
118
- }
119
- function make_sync_markup_effect_warning(filename, expression_text) {
120
- return [
121
- `[svelte-effect-runtime] Detected a markup expression that creates an Effect but is not written with yield*.`,
122
- `${filename}: {${expression_text}}`,
123
- `This expression will produce an Effect value, not its result.`,
124
- `Use yield* where Svelte expects the resolved value.`
125
- ].join("\n");
126
- }
127
- function contains_effect_reference(expression_text, effect_names) {
128
- const name_pattern = make_effect_name_pattern(effect_names);
129
- return new RegExp(`\\b(?:${name_pattern})\\.(?:gen|succeed|fail|try|tryPromise|promise|sync|all|void|log|runPromise|runSync|runFork)\\b`).test(expression_text);
130
- }
131
- function contains_effect_runner(expression_text, effect_names) {
132
- const name_pattern = make_effect_name_pattern(effect_names);
133
- return new RegExp(`\\b(?:${name_pattern})\\.run(?:Promise|Sync|Fork)\\b`).test(expression_text);
134
- }
135
- function is_bare_effect_gen(expression_text, effect_names) {
136
- const name_pattern = make_effect_name_pattern(effect_names);
137
- return new RegExp(`^(?:${name_pattern})\\.gen$`).test(expression_text);
138
- }
139
- function make_effect_name_pattern(effect_names) {
140
- return [...effect_names].map(escape_regexp).sort((a, b) => b.length - a.length).join("|");
141
- }
142
- function starts_with_yield_star(expression_text) {
143
- return /^yield\s*\*/.test(expression_text);
144
- }
145
- function contains_yield_star(expression_text) {
146
- return /\byield\s*\*/.test(expression_text);
147
- }
148
- function is_callback_expression(expression_text) {
149
- return /^(?:async\s+)?(?:\([^)]*\)|[A-Za-z_$][\w$]*)\s*=>/.test(expression_text) || /^(?:async\s+)?function\b/.test(expression_text);
150
- }
151
- function get_line_column(line_starts, position) {
152
- let low = 0;
153
- let high = line_starts.length - 1;
154
- while (low <= high) {
155
- const mid = Math.floor((low + high) / 2);
156
- if (line_starts[mid] <= position) low = mid + 1;
157
- else high = mid - 1;
158
- }
159
- const line_index = Math.max(0, high);
160
- return {
161
- line: line_index + 1,
162
- column: position - line_starts[line_index]
163
- };
164
- }
165
- function make_line_starts(code) {
166
- const line_starts = [0];
167
- for (let i = 0; i < code.length; i += 1) {
168
- if (code[i] !== "\n") continue;
169
- line_starts.push(i + 1);
170
- }
171
- return line_starts;
172
- }
173
- function escape_regexp(value) {
174
- return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
175
- }
176
- //#endregion
177
- //#region src/compiler.ts
178
- const default_svelte_component_extensions = [".svelte"];
179
- /**
180
- * Vite plugin for SvelteKit. The server import plugin rewrites server-side
181
- * imports to the server entrypoint; the remote client plugin wraps SvelteKit's
182
- * generated client remote exports in Effect-returning adapters.
183
- *
184
- * @example
185
- * ```ts
186
- * import { effect } from "svelte-effect-runtime/compiler";
187
- * import { sveltekit } from "@sveltejs/kit/vite";
188
- *
189
- * export default defineConfig({ plugins: [effect(), sveltekit()] });
190
- * ```
191
- *
192
- * @since 2.0.0
193
- * @param options - Optional configuration.
194
- * @returns Vite plugins that integrate the runtime with SvelteKit.
195
- */
196
- function effect(options) {
197
- const component_filter = make_svelte_component_module_filter();
198
- return [
199
- make_diagnostics_plugin(component_filter),
200
- make_reserved_helper_guard_plugin(component_filter),
201
- make_svelte_transform_plugin(component_filter),
202
- make_server_rewrite_plugin(),
203
- make_remote_client_wrapper_plugin(options)
204
- ];
205
- }
206
- function make_diagnostics_plugin(component_filter) {
207
- const warned_diagnostics = /* @__PURE__ */ new Set();
208
- return {
209
- name: "svelte-effect-runtime:diagnostics",
210
- transform(code, id) {
211
- if (!component_filter.is_module(id)) return;
212
- const clean_id = id.split("?")[0] ?? id;
213
- const diagnostics = find_svelte_effect_diagnostics(code, clean_id);
214
- for (const diagnostic of diagnostics) {
215
- const diagnostic_key = [
216
- clean_id,
217
- diagnostic.line,
218
- diagnostic.column,
219
- diagnostic.message
220
- ].join(":");
221
- if (warned_diagnostics.has(diagnostic_key)) continue;
222
- warned_diagnostics.add(diagnostic_key);
223
- this.warn({
224
- id: clean_id,
225
- message: diagnostic.message,
226
- loc: {
227
- line: diagnostic.line,
228
- column: diagnostic.column
229
- }
230
- });
231
- }
232
- }
233
- };
234
- }
235
- function make_reserved_helper_guard_plugin(component_filter) {
236
- return {
237
- name: "svelte-effect-runtime:reserved-helper-guard",
238
- transform(code, id) {
239
- if (!component_filter.is_module(id) || !has_ser_syntax(code)) return;
240
- const reserved_names = find_reserved_helper_names(code);
241
- if (reserved_names.length === 0) return;
242
- this.warn(make_reserved_helper_warning(reserved_names));
243
- }
244
- };
245
- }
246
- function make_svelte_transform_plugin(component_filter) {
247
- return {
248
- name: "svelte-effect-runtime:svelte-transform",
249
- configResolved(config) {
250
- const extensions = find_svelte_component_extensions(config.plugins);
251
- const conflicting_plugin_names = find_pre_transform_plugin_names(config.plugins);
252
- if (extensions) component_filter.set_extensions(extensions);
253
- if (conflicting_plugin_names.length === 0) return;
254
- config.logger.info(make_pre_transform_plugin_notice(conflicting_plugin_names));
255
- },
256
- async transform(code, id, options) {
257
- if (!component_filter.is_module(id)) return;
258
- const { transform_svelte_effect } = await import("../runtime/transform.js");
259
- const result = transform_svelte_effect(code, id, { target: options?.ssr ? "server" : "client" });
260
- if (result.code === code) return;
261
- return {
262
- code: result.code,
263
- map: null
264
- };
265
- }
266
- };
267
- }
268
- function make_svelte_component_module_filter() {
269
- let extensions = default_svelte_component_extensions;
270
- return {
271
- set_extensions(next_extensions) {
272
- const normalized_extensions = normalize_svelte_component_extensions(next_extensions);
273
- if (normalized_extensions.length === 0) return;
274
- extensions = normalized_extensions;
275
- },
276
- is_module(id) {
277
- return is_svelte_component_module(id, extensions);
278
- }
279
- };
280
- }
281
- function normalize_svelte_component_extensions(extensions) {
282
- const normalized_extensions = extensions.filter((extension) => extension.length > 0).map((extension) => extension.startsWith(".") ? extension : `.${extension}`);
283
- return [...new Set(normalized_extensions)];
284
- }
285
- function find_svelte_component_extensions(plugins) {
286
- return plugins.find(has_svelte_component_extensions)?.api?.options?.extensions;
287
- }
288
- function has_svelte_component_extensions(plugin) {
289
- const extensions = plugin.api?.options?.extensions;
290
- if (!plugin.name.startsWith("vite-plugin-svelte")) return false;
291
- return Array.isArray(extensions) && extensions.every((extension) => typeof extension === "string");
292
- }
293
- function find_pre_transform_plugin_names(plugins) {
294
- 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);
295
- }
296
- const ansi_reset = "\x1B[0m";
297
- const ansi_light_green = "\x1B[92m";
298
- function make_pre_transform_plugin_notice(plugin_names) {
299
- const formatted_plugins = plugin_names.map((plugin_name) => ` - ${plugin_name}`).join("\n");
300
- return [
301
- `${ansi_light_green}[svelte-effect-runtime]${ansi_reset} Svelte Effect Runtime noticed possible Vite plugin ordering conflicts.`,
302
- "",
303
- "These plugins run before normal Svelte component transforms:",
304
- formatted_plugins,
305
- "",
306
- "This is usually fine, but if you see Svelte parser errors around <script effect>",
307
- "or yield* in components, one of those plugins may be reading component files before",
308
- "SER has lowered its syntax."
309
- ].join("\n");
310
- }
311
- function is_known_framework_pre_transform_plugin(name) {
312
- return name.startsWith("vite:") || name === "vite-plugin-svelte:preprocess";
313
- }
314
- function has_pre_transform_priority(plugin) {
315
- if (plugin.enforce === "pre" && plugin.transform) return true;
316
- if (typeof plugin.transform === "object" && plugin.transform !== null && "order" in plugin.transform && plugin.transform.order === "pre") return true;
317
- return false;
318
- }
319
- function make_server_rewrite_plugin() {
320
- return {
321
- name: "svelte-effect-runtime:server-imports",
322
- config() {
323
- return { optimizeDeps: { exclude: ["svelte-effect-runtime"] } };
324
- },
325
- async transform(code, id) {
326
- if (!is_server_runtime_module(id)) return;
327
- if (!code.includes("svelte-effect-runtime")) return;
328
- const rewritten = await rewrite_server_imports(code, id);
329
- if (rewritten === code) return;
330
- return {
331
- code: rewritten,
332
- map: null
333
- };
334
- }
335
- };
336
- }
337
- async function rewrite_server_imports(code, id) {
338
- const [{ default: MagicString }, ts] = await Promise.all([import("magic-string"), import("typescript")]);
339
- const filename = id.split("?", 2)[0] ?? id;
340
- const source_file = ts.createSourceFile(filename, code, ts.ScriptTarget.Latest, true, get_script_kind(filename, ts));
341
- const magic = new MagicString(code);
342
- let changed = false;
343
- const rewrite_specifier = (specifier) => {
344
- const replacement = get_server_import_replacement(specifier.text);
345
- if (!replacement) return;
346
- magic.overwrite(specifier.getStart(source_file), specifier.end, JSON.stringify(replacement));
347
- changed = true;
348
- };
349
- const visit = (node) => {
350
- if (ts.isImportDeclaration(node) && ts.isStringLiteralLike(node.moduleSpecifier)) rewrite_specifier(node.moduleSpecifier);
351
- if (ts.isExportDeclaration(node) && node.moduleSpecifier && ts.isStringLiteralLike(node.moduleSpecifier)) rewrite_specifier(node.moduleSpecifier);
352
- if (ts.isCallExpression(node) && node.expression.kind === ts.SyntaxKind.ImportKeyword) {
353
- const [specifier] = node.arguments;
354
- if (specifier && ts.isStringLiteralLike(specifier)) rewrite_specifier(specifier);
355
- }
356
- ts.forEachChild(node, visit);
357
- };
358
- visit(source_file);
359
- return changed ? magic.toString() : code;
360
- }
361
- function get_server_import_replacement(specifier) {
362
- if (specifier === "svelte-effect-runtime") return "svelte-effect-runtime/server";
363
- if (specifier === "svelte-effect-runtime/internal/generators") return "svelte-effect-runtime/server";
364
- }
365
- function get_script_kind(filename, ts) {
366
- const normalized_filename = filename.toLowerCase();
367
- if (has_file_extension(normalized_filename, [".tsx"])) return ts.ScriptKind.TSX;
368
- if (has_file_extension(normalized_filename, [".jsx"])) return ts.ScriptKind.JSX;
369
- if (has_file_extension(normalized_filename, [
370
- ".js",
371
- ".mjs",
372
- ".cjs"
373
- ])) return ts.ScriptKind.JS;
374
- return ts.ScriptKind.TS;
375
- }
376
- function has_file_extension(filename, extensions) {
377
- return extensions.some((extension) => filename.endsWith(extension));
378
- }
379
- function make_remote_client_wrapper_plugin(options) {
380
- return {
381
- name: "svelte-effect-runtime:remote-client",
382
- enforce: "post",
383
- config() {
384
- return { ssr: { noExternal: ["svelte-effect-runtime"] } };
385
- },
386
- configResolved(config) {
387
- const no_external = config.ssr.noExternal;
388
- const runtime_package = "svelte-effect-runtime";
389
- if (no_external === true) return;
390
- if (Array.isArray(no_external)) {
391
- if (!no_external.some((entry) => entry === runtime_package)) no_external.push(runtime_package);
392
- return;
393
- }
394
- config.ssr.noExternal = [no_external, runtime_package].filter((value) => value !== void 0);
395
- },
396
- async transform(code, id) {
397
- if (!is_remote_module(id) || !code.includes("__sveltekit/remote")) return;
398
- const rewritten = await rewrite_remote_client_exports(code, options);
399
- if (rewritten === code) return;
400
- return {
401
- code: rewritten,
402
- map: null
403
- };
404
- }
405
- };
406
- }
407
- function is_server_runtime_module(id) {
408
- const [filename] = id.split("?", 2);
409
- return /\.(server|remote)(?:\.[cm])?\.[jt]s$/.test(filename) || /(?:^|[\\/])hooks\.server(?:\.[cm])?\.[jt]s$/.test(filename);
410
- }
411
- function is_remote_module(id) {
412
- return /\.(remote|remote\.[cm]?)\.[jt]s(?:\?.*)?$/.test(id) || id.includes(".remote.");
413
- }
414
- function is_svelte_component_module(id, extensions) {
415
- const [filename, query = ""] = id.split("?", 2);
416
- if (!extensions.some((extension) => filename.endsWith(extension))) return false;
417
- if (query.length === 0) return true;
418
- const params = new URLSearchParams(query);
419
- const allowed_params = ["t", "v"];
420
- return [...params.keys()].every((key) => allowed_params.includes(key));
421
- }
422
- function has_ser_syntax(code) {
423
- return /\byield\s*\*/.test(code) || /<script\b[^>]*\beffect(?:[\s=>]|$)/.test(code);
424
- }
425
- function find_reserved_helper_names(code) {
426
- const script_segments = [...code.matchAll(/<script\b[^>]*>([\s\S]*?)<\/script\s*>/gi)].map((match) => match[1] ?? "");
427
- const markup_segments = [...code.matchAll(/\{[^{}]*(?:Dispatcher|Code)[^{}]*\}/g)].map((match) => match[0]);
428
- const search_segments = [...script_segments, ...markup_segments];
429
- return ["Dispatcher", "Code"].filter((name) => search_segments.some((segment) => new RegExp(`\\b${name}\\b`).test(segment)));
430
- }
431
- function make_reserved_helper_warning(names) {
432
- const quoted_names = names.map((name) => `\`${name}\``);
433
- const subject = quoted_names.length === 1 ? quoted_names[0] : `${quoted_names.slice(0, -1).join(", ")} and ${quoted_names[quoted_names.length - 1]}`;
434
- return [`[svelte-effect-runtime] ${subject} ${names.length === 1 ? "is" : "are"} reserved for generated markup helpers.`, `Rename or alias local bindings that use ${subject} before using SER syntax in this component.`].join(" ");
435
- }
436
- /**
437
- * Rewrites SvelteKit's generated client remote module from:
438
- *
439
- * `export const get_post = __remote.query("hash/get_post")`
440
- *
441
- * into an Effect-aware wrapper around the same native function.
442
- *
443
- * @example
444
- * ```ts
445
- * const rewritten = await rewrite_remote_client_exports(remote_module_code);
446
- * ```
447
- *
448
- * @since 2.0.0
449
- * @param code - The generated client remote module code.
450
- * @param options - Optional plugin options.
451
- * @returns A promise that resolves to the rewritten module code.
452
- * @internal
453
- */
454
- async function rewrite_remote_client_exports(code, options) {
455
- return (await import("./remote-client-CVI4t66c.js")).rewrite_remote_client_exports(code, options);
456
- }
457
- //#endregion
458
- export { rewrite_remote_client_exports as n, effect as t };
459
-
460
- //# sourceMappingURL=compiler-BBPNyXmQ.js.map