svelte-effect-runtime 2.5.1 → 3.0.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-Cj2X9lY-.js → client-Cruhk6Oo.js} +12 -5
- package/.dist/chunks/client-Cruhk6Oo.js.map +1 -0
- package/.dist/chunks/{dispatcher-BVkm8qbG.js → dispatcher-CgCdn6bj.js} +12 -2
- package/.dist/chunks/{dispatcher-BVkm8qbG.js.map → dispatcher-CgCdn6bj.js.map} +1 -1
- package/.dist/chunks/{preprocess-DseI9Doo.js → preprocess-BhoCga82.js} +49 -6
- package/.dist/chunks/preprocess-BhoCga82.js.map +1 -0
- package/.dist/chunks/{transform-Cx5bjmP6.js → transform-CMvL4SBp.js} +19 -9
- package/.dist/chunks/transform-CMvL4SBp.js.map +1 -0
- package/.dist/dispatcher.js +1 -1
- package/.dist/internal/generators.js +1 -1
- package/.dist/internal/remote-client.js +1 -1
- package/.dist/markup/promise.js +1 -1
- package/.dist/markup/run.js +1 -1
- package/.dist/markup/transform.js +1 -1
- package/.dist/markup/value.js +1 -1
- package/.dist/mod.d.ts +1 -40
- package/.dist/mod.js +2 -27
- package/.dist/mod.js.map +1 -1
- package/.dist/preprocess/imports.d.ts +10 -2
- package/.dist/preprocess/types.d.ts +8 -1
- package/.dist/preprocess.js +2 -2
- package/.dist/remote/client.js +1 -1
- package/.dist/remote/server.js +5 -1
- package/.dist/remote/server.js.map +1 -1
- package/.dist/runtime/transform.d.ts +2 -0
- package/.dist/{chunks/transform-BotzDlj3.js → runtime/transform.js} +4 -17
- package/.dist/runtime/transform.js.map +1 -0
- package/.dist/server/factories.d.ts +5 -1
- package/.dist/server/index.d.ts +1 -1
- package/.dist/server/types.d.ts +44 -1
- package/.dist/server.d.ts +1 -1
- package/.dist/server.js.map +1 -1
- package/.dist/vite.js +9 -13
- package/.dist/vite.js.map +1 -1
- package/package.json +4 -4
- package/.dist/chunks/client-Cj2X9lY-.js.map +0 -1
- package/.dist/chunks/preprocess-DseI9Doo.js.map +0 -1
- package/.dist/chunks/transform-BotzDlj3.js.map +0 -1
- package/.dist/chunks/transform-Cx5bjmP6.js.map +0 -1
- package/.dist/runtime/preprocess.d.ts +0 -39
- package/.dist/runtime/preprocess.js +0 -31
- package/.dist/runtime/preprocess.js.map +0 -1
package/.dist/vite.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.js","names":[],"sources":["../../modules/svelte-effect-runtime/src/vite.ts"],"sourcesContent":["import type { Plugin } from \"vite\";\n\n/**\n * Options for the {@link effect} Vite plugin.\n *\n * @since 2.0.0\n */\nexport interface EffectOptions {\n /** Whether to emit debug logging in the generated remote client module. */\n debug?: boolean;\n}\n\n/**\n * Vite plugin for SvelteKit. The pre plugin rewrites server-side imports\n * to the server entrypoint; the post plugin wraps SvelteKit's generated\n * client remote exports in Effect-returning adapters.\n *\n * @example\n * ```ts\n * import { effect } from \"svelte-effect-runtime\";\n * import { sveltekit } from \"@sveltejs/kit/vite\";\n *\n * export default defineConfig({ plugins: [effect(), sveltekit()] });\n * ```\n *\n * @since 2.0.0\n * @param options - Optional configuration.\n * @returns Vite plugins that integrate the runtime with SvelteKit.\n */\nexport function effect(options?: EffectOptions): Plugin[] {\n return [\n make_svelte_transform_plugin(),\n make_server_rewrite_plugin(),\n make_remote_client_wrapper_plugin(options),\n ];\n}\n\nfunction make_svelte_transform_plugin(): Plugin {\n return {\n name: \"svelte-effect-runtime:svelte-transform\",\n enforce: \"pre\",\n\n transform: {\n order: \"pre\",\n async handler(code: string, id: string) {\n if (!is_svelte_component_module(id)) {\n return undefined;\n }\n\n const { transform_svelte_effect } = await import(\n \"./runtime/transform.ts\"\n );\n const result = transform_svelte_effect(code, id);\n\n if (result.code === code) {\n return undefined;\n }\n\n return { code: result.code, map: null };\n },\n },\n };\n}\n\nfunction make_server_rewrite_plugin(): Plugin {\n return {\n name: \"svelte-effect-runtime:server-imports\",\n enforce: \"pre\",\n\n config() {\n return { optimizeDeps: { exclude: [\"svelte-effect-runtime\"] } };\n },\n\n transform(code: string, id: string) {\n if (!is_server_runtime_module(id)) {\n return undefined;\n }\n\n const rewritten = code\n .replace(\n /from\\s+[\"']svelte-effect-runtime[\"']/g,\n `from \"svelte-effect-runtime/server\"`,\n )\n .replace(\n /from\\s+[\"']svelte-effect-runtime\\/internal\\/generators[\"']/g,\n `from \"svelte-effect-runtime/server\"`,\n );\n\n if (rewritten === code) {\n return undefined;\n }\n\n return { code: rewritten, map: null };\n },\n };\n}\n\nfunction make_remote_client_wrapper_plugin(options?: EffectOptions): Plugin {\n return {\n name: \"svelte-effect-runtime:remote-client\",\n enforce: \"post\",\n\n config() {\n return { ssr: { noExternal: [\"svelte-effect-runtime\"] } };\n },\n\n configResolved(config) {\n const no_external = config.ssr.noExternal;\n const runtime_package = \"svelte-effect-runtime\";\n\n if (no_external === true) {\n return;\n }\n\n if (Array.isArray(no_external)) {\n const has_runtime_package = no_external.some(\n (entry) => entry === runtime_package,\n );\n\n if (!has_runtime_package) {\n no_external.push(runtime_package);\n }\n\n return;\n }\n\n config.ssr.noExternal = [\n no_external,\n runtime_package,\n ].filter((value): value is string | RegExp => value !== undefined);\n },\n\n transform(code: string, id: string) {\n if (!is_remote_module(id) || !code.includes(\"__sveltekit/remote\")) {\n return undefined;\n }\n\n const rewritten = rewrite_remote_client_exports(code, options);\n\n if (rewritten === code) {\n return undefined;\n }\n\n return { code: rewritten, map: null };\n },\n };\n}\n\nfunction is_server_runtime_module(id: string): boolean {\n return (\n id.endsWith(\".server.ts\") ||\n id.endsWith(\".remote.ts\") ||\n id.includes(\"hooks.server.\")\n );\n}\n\nfunction is_remote_module(id: string): boolean {\n return /\\.(remote|remote\\.[cm]?)\\.[jt]s(?:\\?.*)?$/.test(id) ||\n id.includes(\".remote.\");\n}\n\nfunction is_svelte_component_module(id: string): boolean {\n const [filename, query = \"\"] = id.split(\"?\", 2);\n\n if (!filename.endsWith(\".svelte\")) {\n return false;\n }\n\n if (query.length === 0) {\n return true;\n }\n\n const params = new URLSearchParams(query);\n const allowed_params = [\"t\", \"v\"];\n\n return [...params.keys()].every((key) => allowed_params.includes(key));\n}\n\n/**\n * Rewrites SvelteKit's generated client remote module from:\n *\n * `export const get_post = __remote.query(\"hash/get_post\")`\n *\n * into an Effect-aware wrapper around the same native function.\n *\n * @since 2.0.0\n * @param code - The generated client remote module code.\n * @param options - Optional plugin options.\n * @returns The rewritten module code.\n * @internal\n */\nexport function rewrite_remote_client_exports(\n code: string,\n options?: EffectOptions,\n): string {\n const import_match = code.match(\n /import\\s+\\*\\s+as\\s+([A-Za-z_$][\\w$]*)\\s+from\\s+[\"']__sveltekit\\/remote[\"'];?/,\n );\n\n if (!import_match) {\n return code;\n }\n\n const namespace = import_match[1];\n const export_pattern = new RegExp(\n `export\\\\s+const\\\\s+([A-Za-z_$][\\\\w$]*)\\\\s*=\\\\s*${namespace}\\\\.(query_batch|query_live|query|command|form|prerender)\\\\(([\"'][^\"']+[\"'])\\\\);?`,\n \"g\",\n );\n\n let replaced_any = false;\n const body = code.replace(\n export_pattern,\n (_match, name, type, id_literal) => {\n replaced_any = true;\n\n return make_remote_export(name, type, id_literal, namespace);\n },\n );\n\n if (!replaced_any) {\n return code;\n }\n\n const imports = [\n `import { app_dir, base } from \"$app/paths/internal/client\";`,\n `import { create_remote_query_adapter, create_remote_live_query_adapter, create_remote_command_adapter, create_remote_form_adapter } from \"svelte-effect-runtime/internal/remote-client\";`,\n ].join(\"\\n\");\n\n const helpers = [\n `const __SER___remote_base = \\`\\${base}/\\${app_dir}/remote\\`;`,\n `function __SER___decode_payload(value) { return value; }`,\n ].join(\"\\n\");\n\n const debug_line = options?.debug\n ? `console.log(\"[ser] remote client wrappers loaded\");`\n : \"\";\n\n const injected = [\n import_match[0],\n imports,\n helpers,\n debug_line,\n ].filter(Boolean).join(\"\\n\");\n\n return body.replace(import_match[0], injected);\n}\n\nfunction make_remote_export(\n name: string,\n type: string,\n id_literal: string,\n namespace: string,\n): string {\n const native_call = `${namespace}.${type}(${id_literal})`;\n\n if (type === \"command\") {\n return `export const ${name} = create_remote_command_adapter(${native_call}, __SER___decode_payload);`;\n }\n\n if (type === \"form\") {\n return `export const ${name} = create_remote_form_adapter(${native_call}, __SER___decode_payload, __SER___remote_base);`;\n }\n\n if (type === \"query_live\") {\n return `export const ${name} = create_remote_live_query_adapter(${native_call}, __SER___decode_payload);`;\n }\n\n return `export const ${name} = create_remote_query_adapter(${native_call}, __SER___decode_payload);`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA6BA,SAAgB,OAAO,SAAmC;CACxD,OAAO;EACL,6BAA6B;EAC7B,2BAA2B;EAC3B,kCAAkC,OAAO;CAC3C;AACF;AAEA,SAAS,+BAAuC;CAC9C,OAAO;EACL,MAAM;EACN,SAAS;EAET,WAAW;GACT,OAAO;GACP,MAAM,QAAQ,MAAc,IAAY;IACtC,IAAI,CAAC,2BAA2B,EAAE,GAChC;IAGF,MAAM,EAAE,4BAA4B,MAAM,OACxC,kCAAA,MAAA,MAAA,EAAA,CAAA;IAEF,MAAM,SAAS,wBAAwB,MAAM,EAAE;IAE/C,IAAI,OAAO,SAAS,MAClB;IAGF,OAAO;KAAE,MAAM,OAAO;KAAM,KAAK;IAAK;GACxC;EACF;CACF;AACF;AAEA,SAAS,6BAAqC;CAC5C,OAAO;EACL,MAAM;EACN,SAAS;EAET,SAAS;GACP,OAAO,EAAE,cAAc,EAAE,SAAS,CAAC,uBAAuB,EAAE,EAAE;EAChE;EAEA,UAAU,MAAc,IAAY;GAClC,IAAI,CAAC,yBAAyB,EAAE,GAC9B;GAGF,MAAM,YAAY,KACf,QACC,yCACA,qCACF,EACC,QACC,+DACA,qCACF;GAEF,IAAI,cAAc,MAChB;GAGF,OAAO;IAAE,MAAM;IAAW,KAAK;GAAK;EACtC;CACF;AACF;AAEA,SAAS,kCAAkC,SAAiC;CAC1E,OAAO;EACL,MAAM;EACN,SAAS;EAET,SAAS;GAC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CAAC,cACH,OAAO;CAGT,MAAM,YAAY,aAAa;CAC/B,MAAM,iBAAiB,IAAI,OACzB,kDAAkD,UAAU,mFAC5D,GACF;CAEA,IAAI,eAAe;CACnB,MAAM,OAAO,KAAK,QAChB,iBACC,QAAQ,MAAM,MAAM,eAAe;EAClC,eAAe;EAEf,OAAO,mBAAmB,MAAM,MAAM,YAAY,SAAS;CAC7D,CACF;CAEA,IAAI,CAAC,cACH,OAAO;CAGT,MAAM,UAAU,CACd,+DACA,0LACF,EAAE,KAAK,IAAI;CAEX,MAAM,UAAU,CACd,gEACA,0DACF,EAAE,KAAK,IAAI;CAEX,MAAM,aAAa,SAAS,QACxB,wDACA;CAEJ,MAAM,WAAW;EACf,aAAa;EACb;EACA;EACA;CACF,EAAE,OAAO,OAAO,EAAE,KAAK,IAAI;CAE3B,OAAO,KAAK,QAAQ,aAAa,IAAI,QAAQ;AAC/C;AAEA,SAAS,mBACP,MACA,MACA,YACA,WACQ;CACR,MAAM,cAAc,GAAG,UAAU,GAAG,KAAK,GAAG,WAAW;CAEvD,IAAI,SAAS,WACX,OAAO,gBAAgB,KAAK,mCAAmC,YAAY;CAG7E,IAAI,SAAS,QACX,OAAO,gBAAgB,KAAK,gCAAgC,YAAY;CAG1E,IAAI,SAAS,cACX,OAAO,gBAAgB,KAAK,sCAAsC,YAAY;CAGhF,OAAO,gBAAgB,KAAK,iCAAiC,YAAY;AAC3E"}
|
|
1
|
+
{"version":3,"file":"vite.js","names":[],"sources":["../../modules/svelte-effect-runtime/src/vite.ts"],"sourcesContent":["import type { Plugin } from \"vite\";\n\n/**\n * Options for the {@link effect} Vite plugin.\n *\n * @since 2.0.0\n */\nexport interface EffectOptions {\n /** Whether to emit debug logging in the generated remote client module. */\n debug?: boolean;\n}\n\n/**\n * Vite plugin for SvelteKit. The pre plugin rewrites server-side imports\n * to the server entrypoint; the post plugin wraps SvelteKit's generated\n * client remote exports in Effect-returning adapters.\n *\n * @example\n * ```ts\n * import { effect } from \"svelte-effect-runtime\";\n * import { sveltekit } from \"@sveltejs/kit/vite\";\n *\n * export default defineConfig({ plugins: [effect(), sveltekit()] });\n * ```\n *\n * @since 2.0.0\n * @param options - Optional configuration.\n * @returns Vite plugins that integrate the runtime with SvelteKit.\n */\nexport function effect(options?: EffectOptions): Plugin[] {\n return [\n make_svelte_transform_plugin(),\n make_server_rewrite_plugin(),\n make_remote_client_wrapper_plugin(options),\n ];\n}\n\nfunction make_svelte_transform_plugin(): Plugin {\n return {\n name: \"svelte-effect-runtime:svelte-transform\",\n\n async transform(code: string, id: string) {\n if (!is_svelte_component_module(id)) {\n return undefined;\n }\n\n const { transform_svelte_effect } = await import(\n \"./runtime/transform.ts\"\n );\n const result = transform_svelte_effect(code, id);\n\n if (result.code === code) {\n return undefined;\n }\n\n return { code: result.code, map: null };\n },\n };\n}\n\nfunction make_server_rewrite_plugin(): Plugin {\n return {\n name: \"svelte-effect-runtime:server-imports\",\n enforce: \"pre\",\n\n config() {\n return { optimizeDeps: { exclude: [\"svelte-effect-runtime\"] } };\n },\n\n transform(code: string, id: string) {\n if (!is_server_runtime_module(id)) {\n return undefined;\n }\n\n const rewritten = code\n .replace(\n /from\\s+[\"']svelte-effect-runtime[\"']/g,\n `from \"svelte-effect-runtime/server\"`,\n )\n .replace(\n /from\\s+[\"']svelte-effect-runtime\\/internal\\/generators[\"']/g,\n `from \"svelte-effect-runtime/server\"`,\n );\n\n if (rewritten === code) {\n return undefined;\n }\n\n return { code: rewritten, map: null };\n },\n };\n}\n\nfunction make_remote_client_wrapper_plugin(options?: EffectOptions): Plugin {\n return {\n name: \"svelte-effect-runtime:remote-client\",\n enforce: \"post\",\n\n config() {\n return { ssr: { noExternal: [\"svelte-effect-runtime\"] } };\n },\n\n configResolved(config) {\n const no_external = config.ssr.noExternal;\n const runtime_package = \"svelte-effect-runtime\";\n\n if (no_external === true) {\n return;\n }\n\n if (Array.isArray(no_external)) {\n const has_runtime_package = no_external.some(\n (entry) => entry === runtime_package,\n );\n\n if (!has_runtime_package) {\n no_external.push(runtime_package);\n }\n\n return;\n }\n\n config.ssr.noExternal = [\n no_external,\n runtime_package,\n ].filter((value): value is string | RegExp => value !== undefined);\n },\n\n transform(code: string, id: string) {\n if (!is_remote_module(id) || !code.includes(\"__sveltekit/remote\")) {\n return undefined;\n }\n\n const rewritten = rewrite_remote_client_exports(code, options);\n\n if (rewritten === code) {\n return undefined;\n }\n\n return { code: rewritten, map: null };\n },\n };\n}\n\nfunction is_server_runtime_module(id: string): boolean {\n return (\n id.endsWith(\".server.ts\") ||\n id.endsWith(\".remote.ts\") ||\n id.includes(\"hooks.server.\")\n );\n}\n\nfunction is_remote_module(id: string): boolean {\n return /\\.(remote|remote\\.[cm]?)\\.[jt]s(?:\\?.*)?$/.test(id) ||\n id.includes(\".remote.\");\n}\n\nfunction is_svelte_component_module(id: string): boolean {\n const [filename, query = \"\"] = id.split(\"?\", 2);\n\n if (!filename.endsWith(\".svelte\")) {\n return false;\n }\n\n if (query.length === 0) {\n return true;\n }\n\n const params = new URLSearchParams(query);\n const allowed_params = [\"t\", \"v\"];\n\n return [...params.keys()].every((key) => allowed_params.includes(key));\n}\n\n/**\n * Rewrites SvelteKit's generated client remote module from:\n *\n * `export const get_post = __remote.query(\"hash/get_post\")`\n *\n * into an Effect-aware wrapper around the same native function.\n *\n * @since 2.0.0\n * @param code - The generated client remote module code.\n * @param options - Optional plugin options.\n * @returns The rewritten module code.\n * @internal\n */\nexport function rewrite_remote_client_exports(\n code: string,\n options?: EffectOptions,\n): string {\n const import_match = code.match(\n /import\\s+\\*\\s+as\\s+([A-Za-z_$][\\w$]*)\\s+from\\s+[\"']__sveltekit\\/remote[\"'];?/,\n );\n\n if (!import_match) {\n return code;\n }\n\n const namespace = import_match[1];\n const export_pattern = new RegExp(\n `export\\\\s+const\\\\s+([A-Za-z_$][\\\\w$]*)\\\\s*=\\\\s*${namespace}\\\\.(query_batch|query_live|query|command|form|prerender)\\\\(([\"'][^\"']+[\"'])\\\\);?`,\n \"g\",\n );\n\n let replaced_any = false;\n const body = code.replace(\n export_pattern,\n (_match, name, type, id_literal) => {\n replaced_any = true;\n\n return make_remote_export(name, type, id_literal, namespace);\n },\n );\n\n if (!replaced_any) {\n return code;\n }\n\n const imports = [\n `import { app_dir, base } from \"$app/paths/internal/client\";`,\n `import { create_remote_query_adapter, create_remote_live_query_adapter, create_remote_command_adapter, create_remote_form_adapter } from \"svelte-effect-runtime/internal/remote-client\";`,\n ].join(\"\\n\");\n\n const helpers = [\n `const __SER___remote_base = \\`\\${base}/\\${app_dir}/remote\\`;`,\n `function __SER___decode_payload(value) { return value; }`,\n ].join(\"\\n\");\n\n const debug_line = options?.debug\n ? `console.log(\"[ser] remote client wrappers loaded\");`\n : \"\";\n\n const injected = [\n import_match[0],\n imports,\n helpers,\n debug_line,\n ].filter(Boolean).join(\"\\n\");\n\n return body.replace(import_match[0], injected);\n}\n\nfunction make_remote_export(\n name: string,\n type: string,\n id_literal: string,\n namespace: string,\n): string {\n const native_call = `${namespace}.${type}(${id_literal})`;\n\n if (type === \"command\") {\n return `export const ${name} = create_remote_command_adapter(${native_call}, __SER___decode_payload);`;\n }\n\n if (type === \"form\") {\n return `export const ${name} = create_remote_form_adapter(${native_call}, __SER___decode_payload, __SER___remote_base);`;\n }\n\n if (type === \"query_live\") {\n return `export const ${name} = create_remote_live_query_adapter(${native_call}, __SER___decode_payload);`;\n }\n\n return `export const ${name} = create_remote_query_adapter(${native_call}, __SER___decode_payload);`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA6BA,SAAgB,OAAO,SAAmC;CACxD,OAAO;EACL,6BAA6B;EAC7B,2BAA2B;EAC3B,kCAAkC,OAAO;CAC3C;AACF;AAEA,SAAS,+BAAuC;CAC9C,OAAO;EACL,MAAM;EAEN,MAAM,UAAU,MAAc,IAAY;GACxC,IAAI,CAAC,2BAA2B,EAAE,GAChC;GAGF,MAAM,EAAE,4BAA4B,MAAM,OACxC;GAEF,MAAM,SAAS,wBAAwB,MAA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G7E,IAAI,SAAS,QACX,OAAO,gBAAgB,KAAK,gCAAgC,YAAY;CAG1E,IAAI,SAAS,cACX,OAAO,gBAAgB,KAAK,sCAAsC,YAAY;CAGhF,OAAO,gBAAgB,KAAK,iCAAiC,YAAY;AAC3E"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelte-effect-runtime",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Core module that houses the Vite plugin to enable effectful execution.",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"type": "module",
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"types": "./.dist/vite.d.ts",
|
|
32
32
|
"default": "./.dist/vite.js"
|
|
33
33
|
},
|
|
34
|
-
"./runtime/
|
|
35
|
-
"types": "./.dist/runtime/
|
|
36
|
-
"default": "./.dist/runtime/
|
|
34
|
+
"./runtime/transform": {
|
|
35
|
+
"types": "./.dist/runtime/transform.d.ts",
|
|
36
|
+
"default": "./.dist/runtime/transform.js"
|
|
37
37
|
},
|
|
38
38
|
"./internal/generators": {
|
|
39
39
|
"types": "./.dist/internal/generators.d.ts",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client-Cj2X9lY-.js","names":[],"sources":["../../../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/utils.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":["import {\n create_remote_http_error,\n create_remote_transport_error,\n create_remote_validation_error,\n is_serialized_remote_failure_envelope,\n} from \"$/remote/shared.ts\";\nimport type { FormIssue, RemoteFailure } from \"$/remote/shared.ts\";\nimport { parse } from \"devalue\";\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 raw: unknown,\n decode?: (encoded: string) => unknown,\n): RemoteFailure<ErrorType> | unknown {\n const embedded = parse_embedded_remote_failure(raw);\n\n if (embedded !== raw) {\n return decode_remote_error<ErrorType>(embedded, decode);\n }\n\n if (is_serialized_remote_failure_envelope(raw)) {\n try {\n const decoded = decode ? decode(raw.encoded) : parse(raw.encoded);\n\n return decoded as RemoteFailure<ErrorType>;\n } catch {\n return create_remote_transport_error(\n new Error(\n \"[REMOTE_ERROR_DECODE_FAILED]: Failed to decode remote error payload\",\n ),\n raw,\n );\n }\n }\n\n return raw;\n}\n\nfunction parse_embedded_remote_failure(raw: unknown): unknown {\n if (typeof raw === \"string\") {\n return parse_json_or_original(raw);\n }\n\n if (typeof raw !== \"object\" || raw === null || !(\"message\" in raw)) {\n return raw;\n }\n\n const message = (raw as { message?: unknown }).message;\n\n if (typeof message !== \"string\") {\n return raw;\n }\n\n const parsed = parse_json_or_original(message);\n\n return parsed === message ? raw : parsed;\n}\n\nfunction parse_json_or_original(value: string): unknown {\n try {\n return JSON.parse(value);\n } catch {\n return value;\n }\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(\n value: unknown,\n): value is RemoteFailure<never> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"_tag\" in value\n );\n}\n\n/**\n * Checks whether a response body represents SvelteKit validation issues.\n *\n * @example\n * ```ts\n * if (is_validation_body(body)) return body.issues;\n * ```\n *\n * @since 2.0.0\n * @param value - Value to inspect.\n * @returns Whether the value contains a form issue list.\n */\nexport function is_validation_body(\n value: unknown,\n): value is { issues: readonly FormIssue[] } {\n return (\n typeof value === \"object\" &&\n value !== null &&\n Array.isArray((value as { issues?: unknown }).issues)\n );\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 error: unknown,\n): RemoteFailure<ErrorType> {\n const body = get_error_body(error);\n const decoded = decode_remote_error<ErrorType>(body);\n const status = get_error_status(error);\n\n if (is_decoded_remote_failure(decoded)) {\n return decoded;\n }\n\n if (status === 400 && is_validation_body(body)) {\n return create_remote_validation_error(body.issues, body, status);\n }\n\n if (status !== undefined) {\n return create_remote_http_error(status, body, error);\n }\n\n return create_remote_transport_error(error);\n}\n\nfunction get_error_status(error: unknown): number | undefined {\n if (typeof error !== \"object\" || error === null) {\n return undefined;\n }\n\n const status = (error as { status?: unknown }).status;\n\n return typeof status === \"number\" ? status : undefined;\n}\n\nfunction get_error_body(error: unknown): unknown {\n if (typeof error !== \"object\" || error === null) {\n return undefined;\n }\n\n if (\"body\" in error) {\n return (error as { body?: unknown }).body;\n }\n\n if (\"data\" in error) {\n return (error as { data?: unknown }).data;\n }\n\n return undefined;\n}\n","import {\n create_remote_http_error,\n create_remote_validation_error,\n} from \"$/remote/shared.ts\";\nimport type { RemoteFailure } from \"$/remote/shared.ts\";\n\nimport {\n decode_remote_error,\n is_decoded_remote_failure,\n is_validation_body,\n} 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 response: Response,\n): Promise<RemoteFailure<ErrorType>> {\n const body = await response.json().catch(() => undefined);\n const decoded = decode_remote_error<ErrorType>(body);\n\n if (is_decoded_remote_failure(decoded)) {\n return decoded;\n }\n\n if (response.status === 400 && is_validation_body(body)) {\n return create_remote_validation_error(body.issues, body, response.status);\n }\n\n return 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 value: unknown,\n decode_payload: (value: unknown) => unknown,\n): Promise<Output> {\n if (value instanceof Response) {\n if (!value.ok) {\n throw await decode_response_failure<ErrorType>(value);\n }\n\n const data = await value.json();\n\n return decode_payload(data) as Output;\n }\n\n return decode_payload(value) as Output;\n}\n","import type { RemoteFailure } from \"$/remote/shared.ts\";\nimport { Effect } from \"effect\";\n\nimport {\n is_decoded_remote_failure,\n normalize_native_error,\n} 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 make_effect_from_promise<Output, ErrorType = never>(\n run: () => Promise<Output>,\n): Effect.Effect<Output, RemoteFailure<ErrorType>> {\n return Effect.tryPromise({\n try: run,\n catch: (error: unknown) => {\n if (is_decoded_remote_failure(error)) {\n return error;\n }\n\n return normalize_native_error<ErrorType>(error);\n },\n }) as Effect.Effect<Output, RemoteFailure<ErrorType>>;\n}\n","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 value: unknown,\n key: K,\n): value is Record<K, NativeMethod> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n typeof (value as Record<PropertyKey, unknown>)[key] === \"function\"\n );\n}\n","import type { RemoteFailure } from \"$/remote/shared.ts\";\nimport type { Effect } from \"effect\";\n\nimport { decode_response_or_value } from \"./responses.ts\";\nimport { make_effect_from_promise } from \"./effect.ts\";\nimport { copy_property_descriptors, has_method } from \"./utils.ts\";\nimport type { NativeMethod, Pending } from \"./types.ts\";\n\ntype EffectRemoteCommandAdapter<Input, Output, ErrorType = never> =\n & ((\n input: undefined extends Input ? Input | void : Input,\n ) => Effect.Effect<Output, RemoteFailure<ErrorType>>)\n & {\n readonly 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<\n Input,\n Output,\n ErrorType = never,\n>(\n native_factory: unknown,\n decode_payload: (value: unknown) => unknown,\n _base = \"\",\n pending?: Pending,\n): EffectRemoteCommandAdapter<Input, Output, ErrorType> {\n const invoke = has_method(native_factory, \"invoke\")\n ? native_factory.invoke\n : undefined;\n\n if (typeof native_factory !== \"function\" && !invoke) {\n throw new Error(\n \"[INVALID_COMMAND_FACTORY]: Invalid command factory: expected a function\",\n );\n }\n\n const count = pending ?? { value: 0 };\n\n const adapter = (input: undefined extends Input ? Input | void : Input) =>\n make_effect_from_promise<Output, ErrorType>(async () => {\n count.value += 1;\n\n try {\n const result = invoke\n ? await invoke(input)\n : await (native_factory as NativeMethod)(input);\n\n return await decode_response_or_value<Output, ErrorType>(\n result,\n decode_payload,\n );\n } finally {\n count.value -= 1;\n }\n });\n\n copy_property_descriptors(native_factory, adapter);\n\n if (!Object.prototype.hasOwnProperty.call(adapter, \"pending\")) {\n Object.defineProperty(adapter, \"pending\", {\n get: () => count.value,\n });\n }\n\n return 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 const form_data = new FormData();\n\n append_form_value(form_data, \"\", input);\n\n return form_data;\n}\n\nfunction append_form_value(\n form_data: FormData,\n path: string,\n value: unknown,\n): void {\n if (value === undefined) {\n return;\n }\n\n if (Array.isArray(value)) {\n for (const item of value) {\n append_form_value(form_data, `${path}[]`, item);\n }\n\n return;\n }\n\n if (value instanceof Blob) {\n form_data.append(path, value);\n\n return;\n }\n\n if (typeof value === \"object\" && value !== null) {\n for (const [key, child] of Object.entries(value)) {\n const child_path = path.length === 0 ? key : `${path}.${key}`;\n\n append_form_value(form_data, child_path, child);\n }\n\n return;\n }\n\n if (typeof value === \"number\") {\n form_data.append(`n:${path}`, String(value));\n\n return;\n }\n\n if (typeof value === \"boolean\") {\n if (value) {\n form_data.append(`b:${path}`, \"on\");\n }\n\n return;\n }\n\n form_data.append(path, value === null ? \"\" : String(value));\n}\n","import {\n create_remote_http_error,\n create_remote_transport_error,\n create_remote_validation_error,\n} from \"$/remote/shared.ts\";\nimport type { FormIssue } from \"$/remote/shared.ts\";\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\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 * @returns Decoded form output.\n */\nexport async function submit_remote_form<Output>(\n form_obj: NativeFormRecord,\n input: unknown,\n decode_payload: (value: unknown) => unknown,\n remote_base: string,\n): Promise<Output> {\n const action_id = get_remote_action_id(form_obj);\n\n if (!action_id || remote_base.length === 0) {\n throw create_remote_transport_error(\n new Error(\n \"[REMOTE_FORM_ENDPOINT_MISSING]: Form has no submit method or remote endpoint\",\n ),\n );\n }\n\n const response = await fetch(to_remote_form_url(remote_base, action_id), {\n method: \"POST\",\n body: to_form_data(input),\n });\n\n if (!response.ok) {\n throw await decode_response_failure(response);\n }\n\n const envelope = await response.json();\n\n return 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(\n form_obj: NativeFormRecord,\n): string | undefined {\n const action = form_obj.action;\n\n if (typeof action !== \"string\") {\n return undefined;\n }\n\n const fallback = \"http://localhost/\";\n const href = typeof location === \"undefined\" ? fallback : location.href;\n const url = new URL(action, href);\n\n return url.searchParams.get(\"/remote\") ??\n url.searchParams.get(\"remote\") ??\n undefined;\n}\n\nfunction to_remote_form_url(remote_base: string, action_id: string): string {\n const parts = action_id.split(\"/\");\n const head = parts.slice(0, 2).join(\"/\");\n const tail = parts.slice(2).join(\"/\");\n const normalized_base = remote_base.replace(/\\/$/, \"\");\n\n if (tail.length === 0) {\n return `${normalized_base}/${head}`;\n }\n\n return `${normalized_base}/${head}/${encodeURIComponent(tail)}`;\n}\n\nfunction decode_form_response<Output>(\n envelope: unknown,\n decode_payload: (value: unknown) => unknown,\n): Output {\n if (\n typeof envelope !== \"object\" ||\n envelope === null ||\n !(\"type\" in envelope)\n ) {\n throw create_remote_transport_error(\n new Error(\n \"[REMOTE_FORM_RESPONSE_INVALID]: Invalid remote form response\",\n ),\n envelope,\n );\n }\n\n const response = envelope as {\n type: string;\n result?: unknown;\n error?: unknown;\n status?: number;\n };\n\n if (response.type === \"error\") {\n const decoded = decode_remote_error(response.error);\n\n if (is_decoded_remote_failure(decoded)) {\n throw decoded;\n }\n\n throw create_remote_http_error(\n response.status ?? 500,\n response.error,\n );\n }\n\n if (response.type !== \"result\" || typeof response.result !== \"string\") {\n throw create_remote_transport_error(\n new Error(\n \"[REMOTE_FORM_RESPONSE_UNSUPPORTED]: Unsupported remote form response\",\n ),\n envelope,\n );\n }\n\n const parsed = parse(response.result);\n const decoded = decode_payload(parsed) as {\n issues?: readonly FormIssue[];\n result?: Output;\n };\n\n if (decoded.issues && decoded.issues.length > 0) {\n throw create_remote_validation_error(decoded.issues, decoded, 400);\n }\n\n return decoded.result as Output;\n}\n","import { get_dispatcher } from \"$/dispatcher.ts\";\nimport { Effect } from \"effect\";\n\nimport { make_effect_from_promise } 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 callback: NativeMethod | undefined,\n): NativeMethod | undefined {\n if (!callback) {\n return undefined;\n }\n\n return (event: unknown) => {\n const wrapped_event = wrap_submit_callback<Output, ErrorType>(event);\n const result = callback(wrapped_event);\n\n if (Effect.isEffect(result)) {\n return get_dispatcher().run(result);\n }\n\n return result;\n };\n}\n\nfunction wrap_submit_callback<Output, ErrorType>(event: unknown): unknown {\n if (\n typeof event !== \"object\" || event === null || !has_method(event, \"submit\")\n ) {\n return event;\n }\n\n const original_submit = event.submit;\n const { submit: _submit, ...descriptors } = Object.getOwnPropertyDescriptors(\n event,\n );\n\n void _submit;\n\n return Object.defineProperties({}, {\n ...descriptors,\n submit: {\n configurable: true,\n enumerable: false,\n value: () =>\n make_submit_effect<Output, ErrorType>(original_submit, event),\n },\n });\n}\n\nfunction make_submit_effect<Output, ErrorType>(\n original_submit: NativeMethod,\n event: unknown,\n): EffectRemoteFormSubmit<Output, ErrorType> {\n let updates_args: unknown[] | undefined;\n\n const effect = make_effect_from_promise<Output | undefined, ErrorType>(\n async (): Promise<Output | undefined> => {\n const result = original_submit();\n const value = updates_args && has_method(result, \"updates\")\n ? await Promise.resolve(result.updates(...updates_args))\n : await Promise.resolve(result);\n\n if (typeof value === \"boolean\") {\n return read_submit_result<Output>(event);\n }\n\n return value as Output;\n },\n ) as EffectRemoteFormSubmit<Output, ErrorType>;\n\n Object.defineProperty(effect, \"updates\", {\n configurable: true,\n enumerable: false,\n value: (...args: unknown[]) => {\n updates_args ??= args;\n\n return effect;\n },\n });\n\n return effect;\n}\n\nfunction read_submit_result<Output>(event: unknown): Output | undefined {\n if (typeof event !== \"object\" || event === null || !(\"result\" in event)) {\n return undefined;\n }\n\n return Reflect.get(event, \"result\") as Output | undefined;\n}\n","import type { RemoteFormInput } from \"@sveltejs/kit\";\n\nimport { decode_response_or_value } from \"./responses.ts\";\nimport { make_effect_from_promise } 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 {\n EffectRemoteForm,\n NativeFormRecord,\n NativeMethod,\n} from \"./types.ts\";\n\ntype RemoteInput<Input> = undefined extends Input ? Input | void : Input;\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 * @returns A callable form function whose properties mirror the native form.\n * @internal\n */\nexport function create_remote_form_adapter<\n Input extends RemoteFormInput | void,\n Output,\n ErrorType = never,\n>(\n native_factory: unknown,\n decode_payload: (value: unknown) => unknown,\n remote_base = \"\",\n): EffectRemoteForm<Input, Output, ErrorType> {\n const form_obj = native_factory as NativeFormRecord;\n\n const submit_effect = (input?: RemoteInput<Input>) =>\n make_effect_from_promise<Output, ErrorType>(async () => {\n const can_use_remote_endpoint = remote_base.length > 0 &&\n get_remote_action_id(form_obj) !== undefined;\n\n if (has_method(form_obj, \"submit\") && !can_use_remote_endpoint) {\n const result = await form_obj.submit(input);\n\n return await decode_response_or_value<Output>(result, decode_payload);\n }\n\n return await submit_remote_form<Output>(\n form_obj,\n input,\n decode_payload,\n remote_base,\n );\n });\n\n const callable =\n ((input?: RemoteInput<Input>) => submit_effect(input)) as EffectRemoteForm<\n Input,\n Output,\n ErrorType\n >;\n\n copy_property_descriptors(\n form_obj,\n callable,\n new Set([\"submit\", \"validate\", \"enhance\", \"for\", \"preflight\"]),\n );\n\n Object.defineProperty(callable, \"submit\", {\n configurable: true,\n enumerable: false,\n value: submit_effect,\n });\n\n if (has_method(form_obj, \"validate\")) {\n Object.defineProperty(callable, \"validate\", {\n configurable: true,\n enumerable: false,\n value: (options?: Record<string, unknown>) =>\n make_effect_from_promise<void, ErrorType>(async () => {\n await form_obj.validate(options);\n }),\n });\n }\n\n if (has_method(form_obj, \"enhance\")) {\n Object.defineProperty(callable, \"enhance\", {\n configurable: true,\n enumerable: false,\n value: (callback?: NativeMethod) =>\n form_obj.enhance(\n wrap_enhance_callback<Output, ErrorType>(callback),\n ),\n });\n }\n\n if (has_method(form_obj, \"for\")) {\n Object.defineProperty(callable, \"for\", {\n configurable: true,\n enumerable: false,\n value: (key: string | number | boolean) =>\n create_remote_form_adapter<Input, Output, ErrorType>(\n form_obj.for(key),\n decode_payload,\n remote_base,\n ),\n });\n }\n\n if (has_method(form_obj, \"preflight\")) {\n Object.defineProperty(callable, \"preflight\", {\n configurable: true,\n enumerable: false,\n value: (schema: unknown) => {\n form_obj.preflight(schema);\n\n return callable;\n },\n });\n }\n\n return callable;\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 value: unknown,\n decode_payload: (value: unknown) => unknown,\n): Promise<Output> {\n if (has_method(value, \"then\")) {\n const result = await Promise.resolve(value);\n\n return decode_response_or_value(result, decode_payload);\n }\n\n if (has_method(value, \"run\")) {\n const result = await value.run();\n\n return decode_response_or_value(result, decode_payload);\n }\n\n const result = await Promise.resolve(value);\n\n return decode_response_or_value(result, decode_payload);\n}\n","import { copy_property_descriptors, has_method } from \"./utils.ts\";\nimport { normalize_native_error } from \"./failures.ts\";\nimport { resolve_query_result } from \"./query-result.ts\";\nimport { make_effect_from_promise } from \"./effect.ts\";\nimport type { EffectRemoteQueryUpdateBrand, NativeMethod } from \"./types.ts\";\nimport type { RemoteFailure } from \"$/remote/shared.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 | ((input: RemoteInput<Input>) => unknown)\n | {\n readonly load: (input: RemoteInput<Input>) => unknown;\n };\n\ntype RemoteResourceEffect<Output, ErrorType = never> =\n & Effect.Effect<Output, RemoteFailure<ErrorType>>\n & {\n readonly current: Output | undefined;\n readonly error: unknown;\n readonly loading: boolean;\n readonly ready: boolean;\n };\n\ntype RemoteResourceLike<Output, ErrorType = never> =\n | RemoteResourceEffect<Output, ErrorType>\n | RemoteLiveQueryResource<Output>;\n\ntype RemoteQueryEffect<Output, ErrorType = never> =\n & RemoteResourceEffect<Output, ErrorType>\n & {\n readonly refresh: () => Effect.Effect<void, unknown, never>;\n readonly set: (value: Output) => void;\n readonly withOverride: (\n update: (current: Output) => Output,\n ) => unknown;\n };\n\ntype RemoteLiveQueryEffect<Output, ErrorType = never> = Effect.Effect<\n RemoteLiveQueryResource<Output>,\n RemoteFailure<ErrorType>\n>;\n\ntype RemoteLiveQueryResource<Output> =\n & {\n readonly connected: boolean;\n readonly current: Output | undefined;\n readonly done: boolean;\n readonly error: unknown;\n readonly loading: boolean;\n readonly ready: boolean;\n readonly reconnect: () => Effect.Effect<void, unknown, never>;\n }\n & AsyncIterable<Output>;\n\ntype NativeRemoteResource<Output> = {\n readonly connected?: boolean;\n readonly current?: Output;\n readonly done?: boolean;\n readonly error?: unknown;\n readonly loading?: boolean;\n readonly ready?: boolean;\n readonly reconnect?: () => Promise<void>;\n readonly refresh?: () => Promise<void>;\n readonly set?: (value: Output) => void;\n readonly withOverride?: (update: (current: Output) => Output) => unknown;\n readonly [Symbol.asyncIterator]?: () => AsyncIterator<Output>;\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<\n Input,\n Output,\n ErrorType = never,\n>(\n native_factory: NativeQueryFactory<Input>,\n decode_payload: DecodePayload<Output>,\n _base?: string,\n):\n & EffectRemoteQueryUpdateBrand\n & ((input: RemoteInput<Input>) => RemoteQueryEffect<Output, ErrorType>);\nexport function create_remote_query_adapter<\n Input,\n Output,\n ErrorType = never,\n>(\n native_factory: NativeQueryFactory<Input>,\n decode_payload: (value: unknown) => unknown,\n _base?: string,\n):\n & EffectRemoteQueryUpdateBrand\n & ((input: RemoteInput<Input>) => RemoteQueryEffect<Output, ErrorType>);\nexport function create_remote_query_adapter<\n Input,\n Output,\n ErrorType = never,\n>(\n native_factory: unknown,\n decode_payload: DecodePayload<Output>,\n _base = \"\",\n):\n & EffectRemoteQueryUpdateBrand\n & ((input: RemoteInput<Input>) => RemoteQueryEffect<Output, ErrorType>) {\n const load = has_method(native_factory, \"load\")\n ? native_factory.load\n : undefined;\n const query = typeof native_factory === \"function\"\n ? native_factory as NativeMethod\n : undefined;\n\n if (!query && !load) {\n throw new Error(\n \"[INVALID_QUERY_FACTORY]: Invalid query factory: expected a function\",\n );\n }\n\n const wrapped = ((input: RemoteInput<Input>) => {\n if (!query) {\n return make_effect_from_promise<Output, ErrorType>(async () => {\n const result = await load?.(input);\n\n return await resolve_query_result<Output>(result, decode_payload);\n }) as RemoteQueryEffect<Output, ErrorType>;\n }\n\n const resource = query(input);\n const effect = make_effect_from_promise<Output, ErrorType>(async () =>\n await resolve_query_result<Output>(resource, decode_payload)\n ) as RemoteQueryEffect<Output, ErrorType>;\n\n attach_query_resource(resource, effect);\n\n return effect;\n }) as\n & EffectRemoteQueryUpdateBrand\n & ((input: RemoteInput<Input>) => RemoteQueryEffect<Output, ErrorType>);\n\n copy_property_descriptors(native_factory, wrapped);\n\n return wrapped;\n}\n\n/**\n * Creates a remote live query adapter. The returned function takes input and\n * returns an `Effect` that resolves to a live query resource with stream state\n * and reconnect controls.\n *\n * @example\n * ```ts\n * const getTime = create_remote_live_query_adapter(nativeLive, (value) => value);\n * const time = yield* getTime();\n * const current = time.current;\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 an Effect-backed live query resource.\n * @internal\n */\nexport function create_remote_live_query_adapter<\n Input,\n Output,\n ErrorType = never,\n>(\n native_factory: unknown,\n _decode_payload: (value: unknown) => unknown,\n _base = \"\",\n):\n & EffectRemoteQueryUpdateBrand\n & ((input: RemoteInput<Input>) => RemoteLiveQueryEffect<Output, ErrorType>) {\n const query = typeof native_factory === \"function\"\n ? native_factory as NativeMethod\n : undefined;\n\n if (!query) {\n throw new Error(\n \"[INVALID_LIVE_QUERY_FACTORY]: Invalid live query factory: expected a function\",\n );\n }\n\n const wrapped = ((input: Input) =>\n Effect.try({\n try: () => {\n const resource = query(input);\n\n return make_live_query_resource<Output>(resource);\n },\n catch: normalize_native_error,\n }) as RemoteLiveQueryEffect<Output>) as\n & EffectRemoteQueryUpdateBrand\n & ((\n input: RemoteInput<Input>,\n ) => RemoteLiveQueryEffect<Output, ErrorType>);\n\n copy_property_descriptors(native_factory, wrapped);\n\n return wrapped;\n}\n\nfunction is_resource<Output>(\n resource: unknown,\n): resource is NativeRemoteResource<Output> {\n const resource_type = typeof resource;\n\n return (\n (resource_type === \"object\" && resource !== null) ||\n resource_type === \"function\"\n );\n}\n\nfunction attach_resource_getters<Output, ErrorType = never>(\n resource: unknown,\n effect: RemoteResourceLike<Output, ErrorType>,\n): void {\n const methods = is_resource<Output>(resource) ? resource : undefined;\n const keys = [\"current\", \"error\", \"loading\", \"ready\"] as const;\n\n if (!methods) {\n return;\n }\n\n for (const key of keys) {\n if (!(key in methods)) {\n continue;\n }\n\n Object.defineProperty(effect, key, {\n configurable: true,\n get: () => methods[key],\n });\n }\n}\n\nfunction attach_query_resource<Output, ErrorType = never>(\n resource: unknown,\n effect: RemoteQueryEffect<Output, ErrorType>,\n): void {\n const methods = is_resource<Output>(resource) ? resource : undefined;\n const refresh = methods?.refresh;\n const set = methods?.set;\n const with_override = methods?.withOverride;\n\n attach_resource_getters(resource, effect);\n\n if (!methods) {\n return;\n }\n\n if (typeof refresh === \"function\") {\n Object.defineProperty(effect, \"refresh\", {\n configurable: true,\n value: () =>\n make_effect_from_promise(() => Promise.resolve(refresh.call(resource))),\n });\n }\n\n if (typeof set === \"function\") {\n Object.defineProperty(effect, \"set\", {\n configurable: true,\n value: (value: Output) => set.call(resource, value),\n });\n }\n\n if (typeof with_override === \"function\") {\n Object.defineProperty(effect, \"withOverride\", {\n configurable: true,\n value: (update: (current: Output) => Output) =>\n with_override.call(resource, update),\n });\n }\n}\n\nfunction attach_live_query_resource<Output>(\n resource: unknown,\n effect: RemoteLiveQueryResource<Output>,\n): void {\n const methods = is_resource<Output>(resource) ? resource : undefined;\n const async_iterator = methods?.[Symbol.asyncIterator];\n const reconnect = methods?.reconnect;\n const keys = [\"connected\", \"done\"] as const;\n\n attach_resource_getters(resource, effect);\n\n if (!methods) {\n return;\n }\n\n for (const key of keys) {\n if (!(key in methods)) {\n continue;\n }\n\n Object.defineProperty(effect, key, {\n configurable: true,\n get: () => methods[key],\n });\n }\n\n if (typeof reconnect === \"function\") {\n Object.defineProperty(effect, \"reconnect\", {\n configurable: true,\n value: () =>\n make_effect_from_promise(() =>\n Promise.resolve(reconnect.call(resource))\n ),\n });\n }\n\n if (typeof async_iterator === \"function\") {\n Object.defineProperty(effect, Symbol.asyncIterator, {\n configurable: true,\n value: () => async_iterator.call(resource),\n });\n }\n}\n\nfunction make_live_query_resource<Output>(\n resource: unknown,\n): RemoteLiveQueryResource<Output> {\n const live_resource = {} as RemoteLiveQueryResource<Output>;\n\n attach_live_query_resource(resource, live_resource);\n\n return live_resource;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuBA,SAAgB,oBACd,KACA,QACoC;CACpC,MAAM,WAAW,8BAA8B,GAAG;CAElD,IAAI,aAAa,KACf,OAAO,oBAA+B,UAAU,MAAM;CAGxD,IAAI,sCAAsC,GAAG,GAC3C,IAAI;EAGF,OAFgB,SAAS,OAAO,IAAI,OAAO,IAAI,M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AAM,OAAO,CAAC,aAAa,MAAM;CAEjC,wBAAwB,UAAU,MAAM;CAExC,IAAI,CAAC,SACH;CAGF,KAAK,MAAM,OAAO,MAAM;EACtB,IAAI,EAAE,OAAO,UACX;EAGF,OAAO,eAAe,QAAQ,KAAK;GACjC,cAAc;GACd,WAAW,QAAQ;EACrB,CAAC;CACH;CAEA,IAAI,OAAO,cAAc,YACvB,OAAO,eAAe,QAAQ,aAAa;EACzC,cAAc;EACd,aACE,+BACE,QAAQ,QAAQ,UAAU,KAAK,QAAQ,CAAC,CAC1C;CACJ,CAAC;CAGH,IAAI,OAAO,mBAAmB,YAC5B,OAAO,eAAe,QAAQ,OAAO,eAAe;EAClD,cAAc;EACd,aAAa,eAAe,KAAK,QAAQ;CAC3C,CAAC;AAEL;AAEA,SAAS,yBACP,UACiC;CACjC,MAAM,gBAAgB,CAAC;CAEvB,2BAA2B,UAAU,aAAa;CAElD,OAAO;AACT"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"preprocess-DseI9Doo.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/preprocess/source.ts","../../../modules/svelte-effect-runtime/src/preprocess/runtime-block.ts","../../../modules/svelte-effect-runtime/src/preprocess/runes.ts","../../../modules/svelte-effect-runtime/src/preprocess/lower.ts","../../../modules/svelte-effect-runtime/src/preprocess/index.ts"],"sourcesContent":["import type MagicString from \"magic-string\";\nimport type ts from \"typescript\";\n\n/**\n * Creates a source map from transformed script back to the original block.\n *\n * @since 2.0.0\n * @param magic - MagicString instance holding the transformed source.\n * @param filename - Source filename used for the source map entry.\n * @returns A plain source map object.\n */\nexport function create_source_map(\n magic: MagicString,\n filename: string,\n): Record<string, unknown> {\n const map = magic.generateMap({\n hires: true,\n includeContent: true,\n source: filename,\n });\n\n return map as unknown as Record<string, unknown>;\n}\n\n/**\n * Slices a substring matching a node's full source range.\n *\n * @since 2.0.0\n * @param content - Original source text.\n * @param node - AST node whose full range should be extracted.\n * @returns Source text including leading trivia.\n */\nexport function slice(content: string, node: ts.Node): string {\n return content.slice(node.getFullStart(), node.end);\n}\n\n/**\n * Slices a substring matching a node's source range without leading trivia.\n *\n * @since 2.0.0\n * @param content - Original source text.\n * @param node - AST node whose non-trivia range should be extracted.\n * @returns Source text excluding leading trivia.\n */\nexport function slice_start(content: string, node: ts.Node): string {\n return content.slice(node.getStart(), node.end);\n}\n","import type { EffectBlock, RuntimeImportBindings } from \"./types.ts\";\n\n/**\n * Builds the runtime blocks appended to lowered script effect code.\n *\n * @since 2.0.0\n * @param blocks - Effect bodies and dependency reads to emit.\n * @returns Full `$effect` blocks that fork generated `Effect.gen` programs.\n */\nexport function make_runtime_block(blocks: EffectBlock[]): string {\n const bindings: RuntimeImportBindings = {\n cancel: \"__SER___cancel\",\n dispatcher: \"get_dispatcher\",\n dispatcher_value: \"__SER___dispatcher\",\n effect: \"Effect\",\n program: \"__SER___program\",\n untrack: \"untrack\",\n };\n\n return make_runtime_block_with_bindings(blocks, bindings);\n}\n\n/**\n * Builds the runtime blocks appended to lowered script effect code with\n * explicit runtime import bindings.\n *\n * @since 2.4.2\n * @param blocks - Effect bodies and dependency reads to emit.\n * @param bindings - Runtime binding names available in the generated code.\n * @returns Full `$effect` blocks that fork generated `Effect.gen` programs.\n */\nexport function make_runtime_block_with_bindings(\n blocks: EffectBlock[],\n bindings: RuntimeImportBindings,\n): string {\n const merged_block = merge_effect_blocks(blocks);\n const dep_reads = merged_block.deps.map((dep) => ` ${dep};`);\n\n const body = merged_block.statements\n .map((statement) => ` ${statement}`)\n .join(\"\\n\");\n\n return [\n \"\",\n \"$effect(() => {\",\n ...dep_reads,\n ` const ${bindings.dispatcher_value} = ${bindings.dispatcher}();`,\n ` const ${bindings.program} = ${bindings.effect}.gen(function* () {`,\n body,\n \" });\",\n ` const ${bindings.cancel} = ${bindings.untrack}(() => ${bindings.dispatcher_value}.fork(${bindings.program}));`,\n ` import.meta.hot?.dispose(${bindings.cancel});`,\n ` return ${bindings.cancel};`,\n \"});\",\n \"\",\n ].join(\"\\n\");\n}\n\nfunction merge_effect_blocks(blocks: EffectBlock[]): EffectBlock {\n const statements = blocks.flatMap((block) => block.statements);\n const deps = blocks.flatMap((block) => block.deps);\n\n return {\n statements,\n deps: [...new Set(deps)],\n };\n}\n","import { contains_top_level_yield_star } from \"$/detect.ts\";\nimport { AsyncEffectInSyncRuneError } from \"$/error.ts\";\nimport { slice } from \"./source.ts\";\n\nimport ts from \"typescript\";\n\nconst ASYNC_EXPRESSION_RUNES = new Set([\n \"$derived\",\n \"$inspect\",\n \"$state\",\n \"$state.raw\",\n]);\n\nconst CALLBACK_RUNES = new Set([\n \"$derived.by\",\n \"$effect\",\n \"$effect.pre\",\n \"$effect.root\",\n]);\n\n/**\n * Validates that `yield*` only appears in rune positions the script-effect\n * transform can lower without changing the rune's normal Svelte contract.\n *\n * @since 2.0.0\n * @param node - AST node to scan.\n * @param content - Original script source used for diagnostics.\n * @param filename - Source filename used for diagnostics.\n * @returns Nothing.\n */\nexport function validate_rune_yield_usage(\n node: ts.Node,\n content: string,\n filename: string,\n): void {\n visit_rune_yield_usage(node, content, filename);\n}\n\n/**\n * Identifies `$state(...)` and `$state.raw(...)` initializer calls.\n *\n * @since 2.0.0\n * @param expr - Expression to classify.\n * @param content - Original script source used to preserve argument text.\n * @returns State rune details when the expression is a state initializer.\n */\nexport function get_state_rune_initializer(\n expr: ts.Expression,\n content: string,\n): { rune_name: \"$state\" | \"$state.raw\"; value_text: string } | undefined {\n if (!ts.isCallExpression(expr)) {\n return undefined;\n }\n\n const rune_name = get_rune_name(expr.expression);\n\n if (rune_name !== \"$state\" && rune_name !== \"$state.raw\") {\n return undefined;\n }\n\n const first_arg = expr.arguments[0];\n\n if (!first_arg) {\n return undefined;\n }\n\n return {\n rune_name,\n value_text: slice(content, first_arg).trim(),\n };\n}\n\nfunction visit_rune_yield_usage(\n node: ts.Node,\n content: string,\n filename: string,\n): void {\n if (ts.isCallExpression(node)) {\n validate_call_expression(node, content, filename);\n }\n\n node.forEachChild((child) => {\n visit_rune_yield_usage(child, content, filename);\n });\n}\n\nfunction validate_call_expression(\n call: ts.CallExpression,\n content: string,\n filename: string,\n): void {\n const rune_name = get_rune_name(call.expression);\n\n if (!rune_name) {\n return;\n }\n\n if (\n !ASYNC_EXPRESSION_RUNES.has(rune_name) &&\n contains_top_level_yield_star(call)\n ) {\n throw new AsyncEffectInSyncRuneError(\n rune_name,\n slice(content, call),\n filename,\n );\n }\n\n if (!CALLBACK_RUNES.has(rune_name)) {\n return;\n }\n\n const callback = call.arguments[0];\n\n if (!callback || !callback_has_top_level_yield_star(callback)) {\n return;\n }\n\n throw new AsyncEffectInSyncRuneError(\n rune_name,\n slice(content, call),\n filename,\n );\n}\n\nfunction callback_has_top_level_yield_star(node: ts.Expression): boolean {\n if (\n (ts.isArrowFunction(node) ||\n ts.isFunctionExpression(node)) &&\n node.body !== undefined\n ) {\n return contains_top_level_yield_star(node.body);\n }\n\n return contains_top_level_yield_star(node);\n}\n\nfunction get_rune_name(expr: ts.Expression): string | undefined {\n if (ts.isIdentifier(expr) && is_rune_root(expr.text)) {\n return expr.text;\n }\n\n if (!ts.isPropertyAccessExpression(expr)) {\n return undefined;\n }\n\n const root_name = get_rune_name(expr.expression);\n\n if (!root_name) {\n return undefined;\n }\n\n return `${root_name}.${expr.name.text}`;\n}\n\nfunction is_rune_root(name: string): boolean {\n return (\n name === \"$bindable\" ||\n name === \"$derived\" ||\n name === \"$effect\" ||\n name === \"$host\" ||\n name === \"$inspect\" ||\n name === \"$props\" ||\n name === \"$state\"\n );\n}\n","import { collect_free_identifiers } from \"$/markup/transform/expressions.ts\";\nimport { contains_top_level_yield_star } from \"$/detect.ts\";\nimport {\n collect_yield_star_nodes,\n extract_binding_names,\n find_yield_star_node,\n is_yield_star_expression,\n} from \"./ast.ts\";\nimport { get_state_rune_initializer } from \"./runes.ts\";\nimport { slice, slice_start } from \"./source.ts\";\nimport type {\n EffectBlock,\n LoweredExpression,\n LoweredStatement,\n ScriptLoweringContext,\n TempBinding,\n} from \"./types.ts\";\n\nimport ts from \"typescript\";\n\n/**\n * Delegates a statement to the correct lowerer based on syntax kind.\n *\n * @since 2.0.0\n * @param stmt - Statement to lower.\n * @param content - Original source text.\n * @param context - Lowering services for this transform pass.\n * @returns Lowered statement descriptor.\n */\nexport function lower_statement(\n stmt: ts.Statement,\n content: string,\n context: ScriptLoweringContext,\n): LoweredStatement {\n if (ts.isExpressionStatement(stmt)) {\n return lower_expression_statement(stmt, content, context);\n }\n\n if (ts.isVariableStatement(stmt)) {\n return lower_variable_statement(stmt, content, context);\n }\n\n const text = slice(content, stmt);\n\n return {\n temps: [],\n rewritten_text: \"\",\n effect_blocks: [make_effect_block([text], collect_deps(text))],\n range: { start: stmt.getFullStart(), end: stmt.end },\n };\n}\n\nfunction lower_variable_statement(\n stmt: ts.VariableStatement,\n content: string,\n context: ScriptLoweringContext,\n): LoweredStatement {\n const temps: TempBinding[] = [];\n const type_helpers: string[] = [];\n const rewritten_decls: string[] = [];\n const statements: string[] = [];\n const deps: string[] = [];\n\n const decl_list = stmt.declarationList;\n const kind = (decl_list.flags & ts.NodeFlags.Let) !== 0 ? \"let\" : \"const\";\n let has_bare_yield = false;\n\n for (const decl of decl_list.declarations) {\n if (!decl.initializer || !contains_top_level_yield_star(decl.initializer)) {\n if (contains_top_level_yield_star(decl.name)) {\n has_bare_yield = true;\n\n const binding_text = slice(content, decl.name).trim();\n const initializer_text = decl.initializer\n ? slice(content, decl.initializer).trim()\n : \"undefined\";\n const names = extract_binding_names(decl.name);\n const statement = `(${binding_text} = ${initializer_text});`;\n\n temps.push(...names.map((name) => make_unknown_temp(name, context)));\n statements.push(statement);\n deps.push(...collect_deps(statement, names));\n\n continue;\n }\n\n rewritten_decls.push(slice(content, decl).trim());\n continue;\n }\n\n const binding_text = slice(content, decl.name).trim();\n\n if (ts.isIdentifier(decl.name)) {\n const original_name = binding_text;\n\n if (is_yield_star_expression(decl.initializer)) {\n const temp_name = context.next_temp_name(original_name);\n const yield_text = extract_yield_star_full_text(\n decl.initializer,\n content,\n );\n const type_helper = make_yield_type_helper(\n yield_text,\n original_name,\n context,\n );\n\n if (type_helper) {\n type_helpers.push(type_helper.declaration);\n temps.push({ name: temp_name, type: type_helper.type });\n } else {\n temps.push({ name: temp_name });\n }\n\n has_bare_yield = true;\n rewritten_decls.push(`${original_name} = $derived(${temp_name})`);\n\n statements.push(`${temp_name} = ${yield_text};`);\n deps.push(...collect_deps(yield_text));\n } else {\n const state_rune = get_state_rune_initializer(\n decl.initializer,\n content,\n );\n\n if (state_rune) {\n const direct_yield_text = extract_yield_star_full_text(\n decl.initializer,\n content,\n );\n const state_type = direct_yield_text === state_rune.value_text\n ? make_yield_type_helper(\n state_rune.value_text,\n original_name,\n context,\n )\n : undefined;\n\n if (state_type) {\n type_helpers.push(state_type.declaration);\n }\n\n has_bare_yield = true;\n rewritten_decls.push(\n `${original_name} = ${\n make_state_placeholder(\n state_rune.rune_name,\n state_type?.type,\n context,\n )\n }`,\n );\n statements.push(`${original_name} = ${state_rune.value_text};`);\n deps.push(...collect_deps(state_rune.value_text));\n continue;\n }\n\n const lowered = lower_expression_yields(\n decl.initializer,\n content,\n original_name,\n context,\n );\n\n temps.push(...lowered.temps);\n type_helpers.push(...(lowered.type_helpers ?? []));\n for (const block of lowered.effect_blocks) {\n statements.push(...block.statements);\n deps.push(...block.deps);\n }\n\n const rewritten_expr = rewrite_state_rune_as_derived(\n lowered.rewritten_expr,\n );\n const final_expr = should_wrap_complex_initializer_as_derived(\n decl.initializer,\n content,\n )\n ? `$derived(${rewritten_expr})`\n : rewritten_expr;\n\n if (final_expr !== rewritten_expr) {\n has_bare_yield = true;\n }\n\n rewritten_decls.push(`${original_name} = ${final_expr}`);\n }\n } else {\n has_bare_yield = true;\n\n const temp_name = context.next_temp_name(\"destructure\");\n const names = extract_binding_names(decl.name);\n const yield_text = extract_yield_star_full_text(\n decl.initializer,\n content,\n );\n const type_helper = make_yield_type_helper(\n yield_text,\n \"destructure\",\n context,\n );\n\n if (type_helper) {\n type_helpers.push(type_helper.declaration);\n temps.push({ name: temp_name, type: type_helper.type });\n } else {\n temps.push({ name: temp_name });\n }\n\n temps.push(...names.map((name) => make_unknown_temp(name, context)));\n\n statements.push(`${temp_name} = ${yield_text};`);\n statements.push(`(${binding_text} = ${temp_name});`);\n deps.push(...collect_deps(yield_text));\n }\n }\n\n const rewritten_text = rewritten_decls.length === 0\n ? \"\"\n : `${has_bare_yield ? \"let\" : kind} ${rewritten_decls.join(\", \")};`;\n\n return {\n temps,\n type_helpers,\n rewritten_text,\n effect_blocks: statements.length === 0\n ? []\n : [make_effect_block(statements, deps)],\n range: { start: stmt.getStart(), end: stmt.end },\n };\n}\n\nfunction lower_expression_statement(\n stmt: ts.ExpressionStatement,\n content: string,\n context: ScriptLoweringContext,\n): LoweredStatement {\n const expr = stmt.expression;\n\n if (!contains_top_level_yield_star(expr)) {\n return {\n temps: [],\n rewritten_text: slice(content, stmt).trim(),\n effect_blocks: [],\n range: { start: stmt.getStart(), end: stmt.end },\n };\n }\n\n if (is_yield_star_expression(expr)) {\n const text = slice(content, expr).trim();\n\n return {\n temps: [],\n rewritten_text: \"\",\n effect_blocks: [make_effect_block([text + \";\"], collect_deps(text))],\n range: { start: stmt.getFullStart(), end: stmt.end },\n };\n }\n\n if (ts.isBinaryExpression(expr) && is_assignment_operator(expr)) {\n const target = slice(content, expr.left).trim();\n const target_names = collect_assignment_target_names(expr.left);\n\n if (\n expr.operatorToken.kind === ts.SyntaxKind.EqualsToken &&\n is_yield_star_expression(expr.right)\n ) {\n const yield_text = extract_yield_star_full_text(expr.right, content);\n\n return {\n temps: [],\n rewritten_text: \"\",\n effect_blocks: [\n make_effect_block(\n [`${target} = ${yield_text};`],\n collect_deps(yield_text, target_names),\n ),\n ],\n range: { start: stmt.getStart(), end: stmt.end },\n };\n }\n\n const lowered = lower_expression_yields(\n expr.right,\n content,\n make_temp_hint(target),\n context,\n );\n const temp_names = lowered.temps.map((temp) => temp.name);\n const statement = `${target} ${\n slice(content, expr.operatorToken).trim()\n } ${lowered.rewritten_expr};`;\n\n return {\n temps: lowered.temps,\n type_helpers: lowered.type_helpers,\n rewritten_text: \"\",\n effect_blocks: [\n make_effect_block(\n [\n ...lowered.effect_blocks.flatMap((block) => block.statements),\n statement,\n ],\n [\n ...lowered.effect_blocks.flatMap((block) => block.deps),\n ...collect_deps(lowered.rewritten_expr, [\n ...target_names,\n ...temp_names,\n ]),\n ],\n ),\n ],\n range: { start: stmt.getStart(), end: stmt.end },\n };\n }\n\n const lowered = lower_expression_yields(\n expr,\n content,\n \"call\",\n context,\n );\n\n if (is_top_level_rune_call(expr)) {\n return {\n temps: lowered.temps,\n type_helpers: lowered.type_helpers,\n rewritten_text: lowered.rewritten_expr + \";\",\n effect_blocks: lowered.effect_blocks,\n range: { start: stmt.getStart(), end: stmt.end },\n };\n }\n\n const temp_names = lowered.temps.map((temp) => temp.name);\n\n return {\n temps: lowered.temps,\n type_helpers: lowered.type_helpers,\n rewritten_text: \"\",\n effect_blocks: [\n make_effect_block(\n [\n ...lowered.effect_blocks.flatMap((block) => block.statements),\n lowered.rewritten_expr + \";\",\n ],\n [\n ...lowered.effect_blocks.flatMap((block) => block.deps),\n ...collect_deps(lowered.rewritten_expr, temp_names),\n ],\n ),\n ],\n range: { start: stmt.getStart(), end: stmt.end },\n };\n}\n\nfunction lower_expression_yields(\n expr: ts.Expression,\n content: string,\n hint: string,\n context: ScriptLoweringContext,\n): LoweredExpression {\n const replacements: Array<{\n start: number;\n end: number;\n text: string;\n }> = [];\n\n const temps: TempBinding[] = [];\n const type_helpers: string[] = [];\n const statements: string[] = [];\n const deps: string[] = [];\n\n collect_yield_star_nodes(expr, (node) => {\n const temp_name = context.next_temp_name(hint);\n const yield_text = slice_start(content, node).trim();\n const type_helper = make_yield_type_helper(yield_text, hint, context);\n\n if (type_helper) {\n type_helpers.push(type_helper.declaration);\n temps.push({ name: temp_name, type: type_helper.type });\n } else {\n temps.push({ name: temp_name });\n }\n\n statements.push(`${temp_name} = ${yield_text};`);\n deps.push(...collect_deps(yield_text));\n replacements.push({\n start: node.getStart(),\n end: node.end,\n text: temp_name,\n });\n });\n\n if (replacements.length === 0) {\n return {\n temps,\n type_helpers,\n rewritten_expr: slice(content, expr).trim(),\n effect_blocks: [],\n };\n }\n\n replacements.sort((a, b) => b.start - a.start);\n\n let text = slice(content, expr);\n\n const offset_in_expr = expr.getFullStart();\n\n for (const replacement of replacements) {\n text = text.slice(0, replacement.start - offset_in_expr) +\n replacement.text +\n text.slice(replacement.end - offset_in_expr);\n }\n\n return {\n temps,\n type_helpers,\n rewritten_expr: text.trim(),\n effect_blocks: [make_effect_block(statements, deps)],\n };\n}\n\nfunction make_yield_type_helper(\n yield_text: string,\n hint: string,\n context: ScriptLoweringContext,\n): { declaration: string; type: string } | undefined {\n if (!context.emit_types) {\n return undefined;\n }\n\n const helper_name = context.next_type_helper_name(hint);\n const effect_text = strip_yield_star(yield_text);\n\n return {\n declaration: `function ${helper_name}() { return (${effect_text}); }`,\n type:\n `${context.effect_name}.Success<ReturnType<typeof ${helper_name}>> | undefined`,\n };\n}\n\nfunction make_unknown_temp(\n name: string,\n context: ScriptLoweringContext,\n): TempBinding {\n return {\n name,\n type: context.emit_types ? \"unknown\" : undefined,\n };\n}\n\nfunction make_state_placeholder(\n rune_name: string,\n type: string | undefined,\n context: ScriptLoweringContext,\n): string {\n if (type) {\n return `${rune_name}<${type}>(undefined)`;\n }\n\n if (context.emit_types) {\n return `${rune_name}<unknown>(undefined)`;\n }\n\n return `${rune_name}(undefined)`;\n}\n\nfunction strip_yield_star(yield_text: string): string {\n return yield_text.replace(/^yield\\*\\s*/, \"\");\n}\n\nfunction rewrite_state_rune_as_derived(expression: string): string {\n const state_call = expression.match(/^\\$state(?:\\.raw)?\\(([\\s\\S]*)\\)$/);\n\n if (!state_call) {\n return expression;\n }\n\n return `$derived(${state_call[1]})`;\n}\n\nfunction should_wrap_complex_initializer_as_derived(\n expr: ts.Expression,\n content: string,\n): boolean {\n const text = slice(content, expr).trim();\n\n return !/^\\$derived(?:\\.by)?\\(/.test(text) &&\n !/^\\$inspect(?:\\.trace)?\\(/.test(text);\n}\n\nfunction is_assignment_operator(expr: ts.BinaryExpression): boolean {\n return expr.operatorToken.kind >= ts.SyntaxKind.FirstAssignment &&\n expr.operatorToken.kind <= ts.SyntaxKind.LastAssignment;\n}\n\nfunction is_top_level_rune_call(expr: ts.Expression): boolean {\n if (!ts.isCallExpression(expr)) {\n return false;\n }\n\n const callee = expr.expression;\n\n if (ts.isIdentifier(callee)) {\n return callee.text.startsWith(\"$\");\n }\n\n return ts.isPropertyAccessExpression(callee) &&\n ts.isIdentifier(callee.expression) &&\n callee.expression.text.startsWith(\"$\");\n}\n\nfunction make_temp_hint(target: string): string {\n const match = target.match(/[A-Za-z_$][\\w$]*$/);\n\n return match?.[0] ?? \"assignment\";\n}\n\nfunction extract_yield_star_full_text(\n expr: ts.Expression,\n content: string,\n): string {\n let found: string | undefined;\n\n find_yield_star_node(expr, (node) => {\n found = slice_start(content, node).trim();\n });\n\n return found ?? \"undefined\";\n}\n\nfunction make_effect_block(\n statements: string[],\n deps: string[],\n): EffectBlock {\n return {\n statements,\n deps: [...new Set(deps)],\n };\n}\n\nfunction collect_deps(\n expr_text: string,\n excluded_names: readonly string[] = [],\n): string[] {\n const excluded = new Set(excluded_names);\n\n return collect_free_identifiers(expr_text).filter(\n (identifier) =>\n !identifier.startsWith(\"__SER___\") && !excluded.has(identifier),\n );\n}\n\nfunction collect_assignment_target_names(node: ts.Node): string[] {\n if (ts.isIdentifier(node)) {\n return [node.text];\n }\n\n if (ts.isParenthesizedExpression(node)) {\n return collect_assignment_target_names(node.expression);\n }\n\n if (\n ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)\n ) {\n return collect_assignment_target_names(node.expression);\n }\n\n if (ts.isObjectLiteralExpression(node)) {\n return node.properties.flatMap((property) => {\n if (ts.isShorthandPropertyAssignment(property)) {\n return [property.name.text];\n }\n\n if (ts.isPropertyAssignment(property)) {\n return collect_assignment_target_names(property.initializer);\n }\n\n if (ts.isSpreadAssignment(property)) {\n return collect_assignment_target_names(property.expression);\n }\n\n return [];\n });\n }\n\n if (ts.isArrayLiteralExpression(node)) {\n return node.elements.flatMap((element) =>\n ts.isSpreadElement(element)\n ? collect_assignment_target_names(element.expression)\n : collect_assignment_target_names(element)\n );\n }\n\n return [];\n}\n","import { contains_top_level_yield_star } from \"$/detect.ts\";\nimport {\n collect_top_level_binding_names,\n has_local_import_binding,\n make_imports,\n} from \"./imports.ts\";\nimport { create_source_map, slice } from \"./source.ts\";\nimport { AwaitInEffectWorkError, PreprocessError } from \"$/error.ts\";\nimport { make_runtime_block_with_bindings } from \"./runtime-block.ts\";\nimport { contains_top_level_await } from \"./ast.ts\";\nimport { lower_statement } from \"./lower.ts\";\nimport { validate_rune_yield_usage } from \"./runes.ts\";\nimport type {\n BlockRef,\n EffectBlock,\n RuntimeImportBindings,\n ScriptLoweringContext,\n ScriptTransformResult,\n} from \"./types.ts\";\n\nimport MagicString from \"magic-string\";\nimport ts from \"typescript\";\n\nexport type { BlockRef, ScriptTransformResult } from \"./types.ts\";\n\ninterface ScriptTransformOptions {\n emit_types?: boolean;\n}\n\n/**\n * Transforms a `<script effect>` body by extracting top-level `yield*`\n * expressions into `$state` temp bindings and wrapping the lowered\n * assignments in a dependency-tracked `$effect` block.\n *\n * @example\n * ```ts\n * const result = transform_script_effect(\n * `let user = $state(yield* getUser(id));`,\n * \"App.svelte\",\n * );\n * ```\n *\n * @since 2.0.0\n * @param content - The raw `<script effect>` body content.\n * @param filename - The source filename, used in error messages.\n * @param options - Optional transform settings for generated script code.\n * @returns The transformed code and any block references.\n */\nexport function transform_script_effect(\n content: string,\n filename: string,\n options: ScriptTransformOptions = {},\n): ScriptTransformResult {\n let temp_counter = 0;\n\n const source_file = ts.createSourceFile(\n filename,\n content,\n ts.ScriptTarget.Latest,\n true,\n ts.ScriptKind.TS,\n );\n\n const magic = new MagicString(content);\n const effect_blocks: EffectBlock[] = [];\n const block_refs: BlockRef[] = [];\n const top_level_binding_names = collect_top_level_binding_names(source_file);\n const top_level_binding_names_set = new Set(top_level_binding_names);\n const name_allocator = make_name_allocator(top_level_binding_names);\n const emit_types = options.emit_types ?? true;\n\n let has_effect = false;\n\n /** Phase 1: detect imports already provided by the user. */\n const has_effect_import = has_local_import_binding(\n source_file,\n \"effect\",\n \"Effect\",\n );\n\n const has_dispatcher_import = has_local_import_binding(\n source_file,\n \"svelte-effect-runtime/internal/generators\",\n \"get_dispatcher\",\n );\n\n const has_untrack_import = has_local_import_binding(\n source_file,\n \"svelte\",\n \"untrack\",\n );\n\n const reserve_runtime_import = (name: string) =>\n top_level_binding_names_set.has(name)\n ? name_allocator.reserve(make_generated_name(name, \"\"))\n : name_allocator.reserve(name);\n\n const runtime_bindings: RuntimeImportBindings = {\n cancel: name_allocator.reserve(\"__SER___cancel\"),\n dispatcher: has_dispatcher_import\n ? \"get_dispatcher\"\n : reserve_runtime_import(\"get_dispatcher\"),\n dispatcher_value: name_allocator.reserve(\"__SER___dispatcher\"),\n effect: has_effect_import ? \"Effect\" : reserve_runtime_import(\"Effect\"),\n program: name_allocator.reserve(\"__SER___program\"),\n untrack: has_untrack_import ? \"untrack\" : reserve_runtime_import(\"untrack\"),\n };\n\n const context: ScriptLoweringContext = {\n effect_name: runtime_bindings.effect,\n emit_types,\n next_temp_name(hint?: string) {\n const suffix = temp_counter === 0 ? \"\" : `_${temp_counter}`;\n const name = make_generated_name(hint ?? String(temp_counter), suffix);\n\n temp_counter += 1;\n\n return name_allocator.reserve(name);\n },\n next_type_helper_name(hint?: string) {\n return name_allocator.reserve(\n make_generated_name(`type_${hint ?? \"effect\"}`, \"\"),\n );\n },\n };\n\n /** Phase 2: lower every top-level statement that contains `yield*`. */\n for (const stmt of source_file.statements) {\n validate_rune_yield_usage(stmt, content, filename);\n validate_script_yield_boundaries(stmt, content, filename);\n\n const has_top_level_yield_star = contains_top_level_yield_star(stmt);\n\n if (!has_top_level_yield_star) {\n continue;\n }\n\n if (contains_top_level_await(stmt)) {\n const text = slice(content, stmt);\n throw new AwaitInEffectWorkError(filename, text);\n }\n\n has_effect = true;\n const lowered = lower_statement(stmt, content, context);\n\n magic.overwrite(\n lowered.range.start,\n lowered.range.end,\n lowered.rewritten_text,\n );\n\n if (lowered.temps.length > 0 || lowered.type_helpers?.length) {\n const temp_declarations = lowered.temps.map((temp) =>\n temp.type\n ? `let ${temp.name} = $state<${temp.type}>(undefined);`\n : `let ${temp.name} = $state(undefined);`\n );\n\n const prefix = [\n ...(lowered.type_helpers ?? []),\n ...temp_declarations,\n ].join(\"\\n\");\n\n magic.appendLeft(lowered.range.start, prefix + \"\\n\");\n }\n\n effect_blocks.push(...lowered.effect_blocks);\n }\n\n if (!has_effect) {\n block_refs.push({ id: filename, kind: \"script\" });\n\n return { code: content, blocks: block_refs };\n }\n\n /** Phase 3: inject runtime imports after the last user import. */\n const imports = make_imports(\n has_effect_import,\n has_dispatcher_import,\n has_untrack_import,\n runtime_bindings,\n );\n\n const last_import = [...source_file.statements]\n .reverse()\n .find(ts.isImportDeclaration);\n\n if (last_import) {\n magic.appendRight(last_import.end, \"\\n\" + imports);\n } else {\n magic.prepend(imports + \"\\n\");\n }\n\n /** Phase 4: append the runtime program and lifecycle wiring. */\n const runtime_block = make_runtime_block_with_bindings(\n effect_blocks,\n runtime_bindings,\n );\n magic.append(\"\\n\" + runtime_block);\n\n block_refs.push({ id: filename, kind: \"script\" });\n\n return {\n code: magic.toString(),\n blocks: block_refs,\n map: create_source_map(magic, filename),\n };\n}\n\nfunction validate_script_yield_boundaries(\n stmt: ts.Statement,\n content: string,\n filename: string,\n): void {\n const bad_member = find_class_member_with_yield_star(stmt);\n\n if (!bad_member) {\n return;\n }\n\n throw new PreprocessError(\n [\n `[ASYNC_EFFECT_IN_CLASS_MEMBER]: ${filename}: yield* cannot be used inside class members.`,\n `Class fields and methods are not component top-level reactive work. Move the Effect work into a script effect statement before assigning it to the class instance.`,\n \"\",\n \"Problematic member:\",\n slice(content, bad_member),\n ].join(\"\\n\"),\n filename,\n );\n}\n\nfunction find_class_member_with_yield_star(\n stmt: ts.Statement,\n): ts.Node | undefined {\n let found: ts.Node | undefined;\n\n function visit(node: ts.Node): void {\n if (found) {\n return;\n }\n\n if (\n ts.isPropertyDeclaration(node) &&\n node.initializer &&\n contains_top_level_yield_star(node.initializer)\n ) {\n found = node;\n return;\n }\n\n node.forEachChild(visit);\n }\n\n visit(stmt);\n\n return found;\n}\n\nfunction make_name_allocator(initial_names: readonly string[]): {\n reserve(name: string): string;\n} {\n const used_names = new Set(initial_names);\n\n return {\n reserve(name: string): string {\n let candidate = name;\n let suffix = 1;\n\n while (used_names.has(candidate)) {\n candidate = `${name}_${suffix}`;\n suffix += 1;\n }\n\n used_names.add(candidate);\n\n return candidate;\n },\n };\n}\n\nfunction make_generated_name(hint: string, suffix: string): string {\n const normalized_hint = hint.replace(/[^A-Za-z0-9_$]/g, \"_\");\n const safe_hint = /^[A-Za-z_$]/.test(normalized_hint)\n ? normalized_hint\n : `temp_${normalized_hint}`;\n\n return `__SER___${safe_hint}${suffix}`;\n}\n"],"mappings":";;;;;;;;;;;;;AAWA,SAAgB,kBACd,OACA,UACyB;CAOzB,OANY,MAAM,YAAY;EAC5B,OAAO;EACP,gBAAgB;EAChB,QAAQ;CACV,CAES;AACX;;;;;;;;;AAUA,SAAgB,MAAM,SAAiB,MAAuB;CAC5D,OAAO,QAAQ,MAAM,KAAK,aAAa,GAAG,KAAK,GAAG;AACpD;;;;;;;;;AAUA,SAAgB,YAAY,SAAiB,MAAuB;CAClE,OAAO,QAAQ,MAAM,KAAK,SAAS,GAAG,KAAK,GAAG;AAChD;;;;;;;;;;;;ACfA,SAAgB,iCACd,QACA,UACQ;CACR,MAAM,eAAe,oBAAoB,MAAM;CAC/C,MAAM,YAAY,aAAa,KAAK,KAAK,QAAQ,KAAK,IAAI,EAAE;CAE5D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SAAS;EAExB,OAAO;CACT,EACF;AACF;AAEA,SAAS,oBAAoB,MAAc,QAAwB;CACjE,MAAM,kBAAkB,KAAK,QAAQ,mBAAmB,GAAG;CAK3D,OAAO,WAJW,cAAc,KAAK,eAAe,IAChD,kBACA,QAAQ,oBAEkB;AAChC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transform-BotzDlj3.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/runtime/transform.ts"],"sourcesContent":["import { transform_markup_effect } from \"$/markup/transform.ts\";\nimport { transform_script_effect } from \"$/preprocess.ts\";\n\n/**\n * Result returned by the direct whole-file Svelte transform.\n *\n * @example\n * ```ts\n * const result = transform_svelte_effect(\"<p>{yield* load()}</p>\", \"App.svelte\");\n * result.code;\n * ```\n *\n * @since 2.5.0\n */\nexport interface SvelteTransformResult {\n /** Transformed Svelte source. */\n code: string;\n}\n\n/**\n * Lowers SER syntax in a complete Svelte component without using Svelte's\n * preprocessor adapter API.\n *\n * @example\n * ```ts\n * const result = transform_svelte_effect(\n * \"<script effect>const value = yield* load()</script>\",\n * \"App.svelte\",\n * );\n * ```\n *\n * @since 2.5.0\n * @param content - Full Svelte component source to lower before Svelte parses\n * it.\n * @param filename - Component filename used in generated cache identifiers and\n * diagnostics.\n * @returns The transformed component source.\n */\nexport function transform_svelte_effect(\n content: string,\n filename = \"unknown.svelte\",\n): SvelteTransformResult {\n const script = find_script(content);\n\n let combined = content;\n\n if (script?.has_effect) {\n const result = transform_script_effect(script.text, filename, {\n emit_types: script.is_typescript,\n });\n\n combined = content.slice(0, script.effect_attr_start) +\n content.slice(script.effect_attr_end, script.open_end) +\n result.code +\n content.slice(script.close_start);\n }\n\n const result = transform_markup_effect(combined, filename);\n\n return { code: result.code };\n}\n\nfunction find_script(content: string):\n | {\n text: string;\n open_end: number;\n close_start: number;\n has_effect: boolean;\n effect_attr_start: number;\n effect_attr_end: number;\n is_typescript: boolean;\n }\n | undefined {\n const pattern = /<script\\b([^>]*)>([\\s\\S]*?)<\\/script\\s*>/gi;\n\n for (const match of content.matchAll(pattern)) {\n if (match.index === undefined || /\\bmodule\\b/.test(match[1] ?? \"\")) {\n continue;\n }\n\n const attrs = match[1] ?? \"\";\n const effect_match = /\\s+effect(?:\\s*=\\s*(?:\"[^\"]*\"|'[^']*'|[^\\s>]+))?/\n .exec(attrs);\n const open_end = match.index + match[0].indexOf(\">\") + 1;\n const attr_start = effect_match?.index ?? attrs.length;\n const attr_end = attr_start + (effect_match?.[0].length ?? 0);\n\n return {\n text: match[2],\n open_end,\n close_start: match.index + match[0].lastIndexOf(\"<\"),\n has_effect: effect_match !== null,\n effect_attr_start: match.index + \"<script\".length + attr_start,\n effect_attr_end: match.index + \"<script\".length + attr_end,\n is_typescript: has_typescript_lang(attrs),\n };\n }\n\n return undefined;\n}\n\nfunction has_typescript_lang(attrs: string): boolean {\n const lang_match = /\\blang\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)'|([^\\s>]+))/i.exec(\n attrs,\n );\n const lang = (lang_match?.[1] ?? lang_match?.[2] ?? lang_match?.[3] ?? \"\")\n .toLowerCase();\n\n return lang === \"ts\" || lang === \"typescript\";\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,SAAgB,wBACd,SACA,WAAW,kBACY;CACvB,MAAM,SAAS,YAAY,OAAO;CAElC,IAAI,WAAW;CAEf,IAAI,QAAQ,YAAY;EACtB,MAAM,SAAS,wBAAwB,OAAO,MAAM,UAAU,EAC5D,YAAY,OAAO,cACrB,CAAC;EAED,WAAW,QAAQ,MAAM,GAAG,OAAO,iBAAiB,IAClD,QAAQ,MAAM,OAAO,iBAAiB,OAAO,QAAQ,IACrD,OAAO,OACP,QAAQ,MAAM,OAAO,WAAW;CACpC;CAIA,OAAO,EAAE,MAFM,wBAAwB,UAAU,QAE7B,EAAE,KAAK;AAC7B;AAEA,SAAS,YAAY,SAUP;CAGZ,KAAK,MAAM,SAAS,QAAQ,SA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