svelte-effect-runtime 3.4.6 → 3.4.7
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/remote-client-Bj1pZXgq.js +108 -0
- package/.dist/chunks/remote-client-Bj1pZXgq.js.map +1 -0
- package/.dist/chunks/{transform-02e-RvXH.js → transform-CEK6Ccll.js} +2 -2
- package/.dist/chunks/{transform-02e-RvXH.js.map → transform-CEK6Ccll.js.map} +1 -1
- package/.dist/chunks/{vite-Dkwdtbgj.js → vite-Dm3bXmR3.js} +12 -88
- package/.dist/chunks/vite-Dm3bXmR3.js.map +1 -0
- package/.dist/markup/transform.js +1 -1
- package/.dist/mod.js +1 -1
- package/.dist/runtime/transform.js +2 -2
- package/.dist/vite/remote-client.d.ts +24 -0
- package/.dist/vite.d.ts +8 -3
- package/.dist/vite.js +1 -1
- package/package.json +1 -1
- package/.dist/chunks/vite-Dkwdtbgj.js.map +0 -1
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import MagicString from "magic-string";
|
|
3
|
+
//#region src/vite/remote-client.ts
|
|
4
|
+
const remote_client_export_types = /* @__PURE__ */ new Set([
|
|
5
|
+
"query_batch",
|
|
6
|
+
"query_live",
|
|
7
|
+
"query",
|
|
8
|
+
"command",
|
|
9
|
+
"form",
|
|
10
|
+
"prerender"
|
|
11
|
+
]);
|
|
12
|
+
/**
|
|
13
|
+
* Rewrites SvelteKit's generated client remote module into Effect-aware
|
|
14
|
+
* wrappers while preserving the native remote factory calls.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* const rewritten = rewrite_remote_client_exports(
|
|
19
|
+
* `export const get_post = __remote.query("hash/get_post")`,
|
|
20
|
+
* );
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @since 2.0.0
|
|
24
|
+
* @param code - Generated SvelteKit remote client module source to inspect and
|
|
25
|
+
* rewrite.
|
|
26
|
+
* @param options - Optional rewrite options forwarded from the SER Vite plugin.
|
|
27
|
+
* @returns The rewritten module source, or the original source when no remote
|
|
28
|
+
* exports are found.
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
function rewrite_remote_client_exports(code, options) {
|
|
32
|
+
const source_file = ts.createSourceFile("sveltekit-remote-client.ts", code, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
|
|
33
|
+
const namespace_import = find_remote_namespace_import(source_file);
|
|
34
|
+
if (!namespace_import) return code;
|
|
35
|
+
const remote_exports = collect_remote_client_exports(source_file, code, namespace_import.name);
|
|
36
|
+
if (remote_exports.length === 0) return code;
|
|
37
|
+
const magic = new MagicString(code);
|
|
38
|
+
const injected = [
|
|
39
|
+
[`import { app_dir, base } from "$app/paths/internal/client";`, `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";`].join("\n"),
|
|
40
|
+
[`const __SER___remote_base = \`\${base}/\${app_dir}/remote\`;`, `function __SER___decode_payload(value) { return value; }`].join("\n"),
|
|
41
|
+
options?.debug ? `console.log("[ser] remote client wrappers loaded");` : ""
|
|
42
|
+
].filter(Boolean).join("\n");
|
|
43
|
+
magic.appendRight(namespace_import.statement.end, `\n${injected}`);
|
|
44
|
+
for (const remote_export of remote_exports) magic.overwrite(remote_export.statement.getStart(source_file), remote_export.statement.end, make_remote_export(remote_export.name, remote_export.type, remote_export.native_call));
|
|
45
|
+
return magic.toString();
|
|
46
|
+
}
|
|
47
|
+
function make_remote_export(name, remote_type, native_call) {
|
|
48
|
+
if (remote_type === "command") return `export const ${name} = create_remote_command_adapter(${native_call}, __SER___decode_payload);`;
|
|
49
|
+
if (remote_type === "form") return `export const ${name} = create_remote_form_adapter(${native_call}, __SER___decode_payload, __SER___remote_base);`;
|
|
50
|
+
if (remote_type === "query_live") return `export const ${name} = create_remote_live_query_adapter(${native_call}, __SER___decode_payload);`;
|
|
51
|
+
return `export const ${name} = create_remote_query_adapter(${native_call}, __SER___decode_payload);`;
|
|
52
|
+
}
|
|
53
|
+
function find_remote_namespace_import(source_file) {
|
|
54
|
+
for (const statement of source_file.statements) {
|
|
55
|
+
if (!ts.isImportDeclaration(statement)) continue;
|
|
56
|
+
const namespace_import = get_remote_namespace_import(statement);
|
|
57
|
+
if (namespace_import) return namespace_import;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function get_remote_namespace_import(statement) {
|
|
61
|
+
if (!ts.isStringLiteral(statement.moduleSpecifier) || statement.moduleSpecifier.text !== "__sveltekit/remote") return;
|
|
62
|
+
const import_clause = statement.importClause;
|
|
63
|
+
const bindings = import_clause?.namedBindings;
|
|
64
|
+
if (import_clause?.isTypeOnly || !bindings || !ts.isNamespaceImport(bindings)) return;
|
|
65
|
+
return {
|
|
66
|
+
name: bindings.name.text,
|
|
67
|
+
statement
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function collect_remote_client_exports(source_file, code, namespace) {
|
|
71
|
+
return source_file.statements.flatMap((statement) => collect_remote_client_export(source_file, code, namespace, statement));
|
|
72
|
+
}
|
|
73
|
+
function collect_remote_client_export(source_file, code, namespace, statement) {
|
|
74
|
+
if (!ts.isVariableStatement(statement) || !is_export_statement(statement) || !is_const_declaration_list(statement.declarationList) || statement.declarationList.declarations.length !== 1) return [];
|
|
75
|
+
const declaration = statement.declarationList.declarations[0];
|
|
76
|
+
const initializer = declaration.initializer;
|
|
77
|
+
if (!ts.isIdentifier(declaration.name) || !initializer) return [];
|
|
78
|
+
const remote_type = get_remote_client_export_type(initializer, namespace);
|
|
79
|
+
if (!remote_type) return [];
|
|
80
|
+
return [{
|
|
81
|
+
name: declaration.name.text,
|
|
82
|
+
type: remote_type,
|
|
83
|
+
statement,
|
|
84
|
+
native_call: code.slice(initializer.getStart(source_file), initializer.end)
|
|
85
|
+
}];
|
|
86
|
+
}
|
|
87
|
+
function get_remote_client_export_type(initializer, namespace) {
|
|
88
|
+
if (!ts.isCallExpression(initializer)) return;
|
|
89
|
+
const expression = initializer.expression;
|
|
90
|
+
if (!ts.isPropertyAccessExpression(expression)) return;
|
|
91
|
+
if (!ts.isIdentifier(expression.expression) || expression.expression.text !== namespace) return;
|
|
92
|
+
const remote_type = expression.name.text;
|
|
93
|
+
if (!is_remote_client_export_type(remote_type)) return;
|
|
94
|
+
return remote_type;
|
|
95
|
+
}
|
|
96
|
+
function is_remote_client_export_type(value) {
|
|
97
|
+
return remote_client_export_types.has(value);
|
|
98
|
+
}
|
|
99
|
+
function is_export_statement(statement) {
|
|
100
|
+
return (ts.canHaveModifiers(statement) ? ts.getModifiers(statement) : void 0)?.some((modifier) => modifier.kind === ts.SyntaxKind.ExportKeyword) ?? false;
|
|
101
|
+
}
|
|
102
|
+
function is_const_declaration_list(declaration_list) {
|
|
103
|
+
return (ts.getCombinedNodeFlags(declaration_list) & ts.NodeFlags.Const) !== 0;
|
|
104
|
+
}
|
|
105
|
+
//#endregion
|
|
106
|
+
export { rewrite_remote_client_exports };
|
|
107
|
+
|
|
108
|
+
//# sourceMappingURL=remote-client-Bj1pZXgq.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-client-Bj1pZXgq.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/vite/remote-client.ts"],"sourcesContent":["import type {\n\tExpression,\n\tImportDeclaration,\n\tSourceFile,\n\tStatement,\n\tVariableStatement,\n} from \"typescript\";\n\nimport MagicString from \"magic-string\";\nimport ts from \"typescript\";\n\ninterface RemoteClientRewriteOptions {\n\tdebug?: boolean;\n}\n\ntype RemoteClientExportType =\n\t| \"query_batch\"\n\t| \"query_live\"\n\t| \"query\"\n\t| \"command\"\n\t| \"form\"\n\t| \"prerender\";\n\ninterface RemoteNamespaceImport {\n\tname: string;\n\tstatement: ImportDeclaration;\n}\n\ninterface RemoteClientExport {\n\tname: string;\n\ttype: RemoteClientExportType;\n\tstatement: VariableStatement;\n\tnative_call: string;\n}\n\nconst remote_client_export_types = new Set<RemoteClientExportType>([\n\t\"query_batch\",\n\t\"query_live\",\n\t\"query\",\n\t\"command\",\n\t\"form\",\n\t\"prerender\",\n]);\n\n/**\n * Rewrites SvelteKit's generated client remote module into Effect-aware\n * wrappers while preserving the native remote factory calls.\n *\n * @example\n * ```ts\n * const rewritten = rewrite_remote_client_exports(\n * `export const get_post = __remote.query(\"hash/get_post\")`,\n * );\n * ```\n *\n * @since 2.0.0\n * @param code - Generated SvelteKit remote client module source to inspect and\n * rewrite.\n * @param options - Optional rewrite options forwarded from the SER Vite plugin.\n * @returns The rewritten module source, or the original source when no remote\n * exports are found.\n * @internal\n */\nexport function rewrite_remote_client_exports(\n\tcode: string,\n\toptions?: RemoteClientRewriteOptions,\n): string {\n\tconst source_file = ts.createSourceFile(\n\t\t\"sveltekit-remote-client.ts\",\n\t\tcode,\n\t\tts.ScriptTarget.Latest,\n\t\ttrue,\n\t\tts.ScriptKind.TS,\n\t);\n\tconst namespace_import = find_remote_namespace_import(source_file);\n\n\tif (!namespace_import) {\n\t\treturn code;\n\t}\n\n\tconst remote_exports = collect_remote_client_exports(source_file, code, namespace_import.name);\n\n\tif (remote_exports.length === 0) {\n\t\treturn code;\n\t}\n\n\tconst magic = new MagicString(code);\n\tconst imports = [\n\t\t`import { app_dir, base } from \"$app/paths/internal/client\";`,\n\t\t`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\t].join(\"\\n\");\n\tconst helpers = [\n\t\t`const __SER___remote_base = \\`\\${base}/\\${app_dir}/remote\\`;`,\n\t\t`function __SER___decode_payload(value) { return value; }`,\n\t].join(\"\\n\");\n\tconst debug_line = options?.debug ? `console.log(\"[ser] remote client wrappers loaded\");` : \"\";\n\tconst injected = [imports, helpers, debug_line].filter(Boolean).join(\"\\n\");\n\n\tmagic.appendRight(namespace_import.statement.end, `\\n${injected}`);\n\n\tfor (const remote_export of remote_exports) {\n\t\tmagic.overwrite(\n\t\t\tremote_export.statement.getStart(source_file),\n\t\t\tremote_export.statement.end,\n\t\t\tmake_remote_export(remote_export.name, remote_export.type, remote_export.native_call),\n\t\t);\n\t}\n\n\treturn magic.toString();\n}\n\nfunction make_remote_export(\n\tname: string,\n\tremote_type: RemoteClientExportType,\n\tnative_call: string,\n): string {\n\tif (remote_type === \"command\") {\n\t\treturn `export const ${name} = create_remote_command_adapter(${native_call}, __SER___decode_payload);`;\n\t}\n\n\tif (remote_type === \"form\") {\n\t\treturn `export const ${name} = create_remote_form_adapter(${native_call}, __SER___decode_payload, __SER___remote_base);`;\n\t}\n\n\tif (remote_type === \"query_live\") {\n\t\treturn `export const ${name} = create_remote_live_query_adapter(${native_call}, __SER___decode_payload);`;\n\t}\n\n\treturn `export const ${name} = create_remote_query_adapter(${native_call}, __SER___decode_payload);`;\n}\n\nfunction find_remote_namespace_import(source_file: SourceFile): RemoteNamespaceImport | undefined {\n\tfor (const statement of source_file.statements) {\n\t\tif (!ts.isImportDeclaration(statement)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst namespace_import = get_remote_namespace_import(statement);\n\n\t\tif (namespace_import) {\n\t\t\treturn namespace_import;\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\nfunction get_remote_namespace_import(\n\tstatement: ImportDeclaration,\n): RemoteNamespaceImport | undefined {\n\tif (\n\t\t!ts.isStringLiteral(statement.moduleSpecifier) ||\n\t\tstatement.moduleSpecifier.text !== \"__sveltekit/remote\"\n\t) {\n\t\treturn undefined;\n\t}\n\n\tconst import_clause = statement.importClause;\n\tconst bindings = import_clause?.namedBindings;\n\n\tif (import_clause?.isTypeOnly || !bindings || !ts.isNamespaceImport(bindings)) {\n\t\treturn undefined;\n\t}\n\n\treturn {\n\t\tname: bindings.name.text,\n\t\tstatement,\n\t};\n}\n\nfunction collect_remote_client_exports(\n\tsource_file: SourceFile,\n\tcode: string,\n\tnamespace: string,\n): RemoteClientExport[] {\n\treturn source_file.statements.flatMap((statement) =>\n\t\tcollect_remote_client_export(source_file, code, namespace, statement),\n\t);\n}\n\nfunction collect_remote_client_export(\n\tsource_file: SourceFile,\n\tcode: string,\n\tnamespace: string,\n\tstatement: Statement,\n): RemoteClientExport[] {\n\tif (\n\t\t!ts.isVariableStatement(statement) ||\n\t\t!is_export_statement(statement) ||\n\t\t!is_const_declaration_list(statement.declarationList) ||\n\t\tstatement.declarationList.declarations.length !== 1\n\t) {\n\t\treturn [];\n\t}\n\n\tconst declaration = statement.declarationList.declarations[0];\n\tconst initializer = declaration.initializer;\n\n\tif (!ts.isIdentifier(declaration.name) || !initializer) {\n\t\treturn [];\n\t}\n\n\tconst remote_type = get_remote_client_export_type(initializer, namespace);\n\n\tif (!remote_type) {\n\t\treturn [];\n\t}\n\n\treturn [\n\t\t{\n\t\t\tname: declaration.name.text,\n\t\t\ttype: remote_type,\n\t\t\tstatement,\n\t\t\tnative_call: code.slice(initializer.getStart(source_file), initializer.end),\n\t\t},\n\t];\n}\n\nfunction get_remote_client_export_type(\n\tinitializer: Expression,\n\tnamespace: string,\n): RemoteClientExportType | undefined {\n\tif (!ts.isCallExpression(initializer)) {\n\t\treturn undefined;\n\t}\n\n\tconst expression = initializer.expression;\n\n\tif (!ts.isPropertyAccessExpression(expression)) {\n\t\treturn undefined;\n\t}\n\n\tif (!ts.isIdentifier(expression.expression) || expression.expression.text !== namespace) {\n\t\treturn undefined;\n\t}\n\n\tconst remote_type = expression.name.text;\n\n\tif (!is_remote_client_export_type(remote_type)) {\n\t\treturn undefined;\n\t}\n\n\treturn remote_type;\n}\n\nfunction is_remote_client_export_type(value: string): value is RemoteClientExportType {\n\treturn remote_client_export_types.has(value as RemoteClientExportType);\n}\n\nfunction is_export_statement(statement: Statement): boolean {\n\tconst modifiers = ts.canHaveModifiers(statement) ? ts.getModifiers(statement) : undefined;\n\n\treturn modifiers?.some((modifier) => modifier.kind === ts.SyntaxKind.ExportKeyword) ?? false;\n}\n\nfunction is_const_declaration_list(declaration_list: ts.VariableDeclarationList): boolean {\n\treturn (ts.getCombinedNodeFlags(declaration_list) & ts.NodeFlags.Const) !== 0;\n}\n"],"mappings":";;;AAmCA,MAAM,6CAA6B,IAAI,IAA4B;CAClE;CACA;CACA;CACA;CACA;CACA;AACD,CAAC;;;;;;;;;;;;;;;;;;;;AAqBD,SAAgB,8BACf,MACA,SACS;CACT,MAAM,cAAc,GAAG,iBACtB,8BACA,MACA,GAAG,aAAa,QAChB,MACA,GAAG,WAAW,EACf;CACA,MAAM,mBAAmB,6BAA6B,WAAW;CAEjE,IAAI,CAAC,kBACJ,OAAO;CAGR,MAAM,iBAAiB,8BAA8B,aAAa,MAAM,iBAAiB,IAAI;CAE7F,IAAI,eAAe,WAAW,GAC7B,OAAO;CAGR,MAAM,QAAQ,IAAI,YAAY,IAAI;CAUlC,MAAM,WAAW;EATD,CACf,+DACA,0LACD,CAAC,CAAC,KAAK,IAMiB;EALR,CACf,gEACA,0DACD,CAAC,CAAC,KAAK,IAE0B;EADd,SAAS,QAAQ,wDAAwD;CAC9C,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,IAAI;CAEzE,MAAM,YAAY,iBAAiB,UAAU,KAAK,KAAK,UAAU;CAEjE,KAAK,MAAM,iBAAiB,gBAC3B,MAAM,UACL,cAAc,UAAU,SAAS,WAAW,GAC5C,cAAc,UAAU,KACxB,mBAAmB,cAAc,MAAM,cAAc,MAAM,cAAc,WAAW,CACrF;CAGD,OAAO,MAAM,SAAS;AACvB;AAEA,SAAS,mBACR,MACA,aACA,aACS;CACT,IAAI,gBAAgB,WACnB,OAAO,gBAAgB,KAAK,mCAAmC,YAAY;CAG5E,IAAI,gBAAgB,QACnB,OAAO,gBAAgB,KAAK,gCAAgC,YAAY;CAGzE,IAAI,gBAAgB,cACnB,OAAO,gBAAgB,KAAK,sCAAsC,YAAY;CAG/E,OAAO,gBAAgB,KAAK,iCAAiC,YAAY;AAC1E;AAEA,SAAS,6BAA6B,aAA4D;CACj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,GAAG,aAAa,WAAW,UAAU,KAAK,WAAW,WAAW,SAAS,WAC7E;CAGD,MAAM,cAAc,WAAW,KAAK;CAEpC,IAAI,CAAC,6BAA6B,WAAW,GAC5C;CAGD,OAAO;AACR;AAEA,SAAS,6BAA6B,OAAgD;CACrF,OAAO,2BAA2B,IAAI,KAA+B;AACtE;AAEA,SAAS,oBAAoB,WAA+B;CAG3D,QAFkB,GAAG,iBAAiB,SAAS,IAAI,GAAG,aAAa,SAAS,IAAI,KAAA,EAAA,EAE9D,MAAM,aAAa,SAAS,SAAS,GAAG,WAAW,aAAa,KAAK;AACxF;AAEA,SAAS,0BAA0B,kBAAuD;CACzF,QAAQ,GAAG,qBAAqB,gBAAgB,IAAI,GAAG,UAAU,WAAW;AAC7E"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { A as YieldStarInEventCallbackError, D as UnsupportedMarkupEffectPositionError, n as AsyncEffectInSyncRuneError, t as AsyncEffectInEventCallbackError } from "./errors-Dcf0MVbq.js";
|
|
2
2
|
import { contains_top_level_yield_star } from "../detect.js";
|
|
3
|
-
import MagicString from "magic-string";
|
|
4
3
|
import ts from "typescript";
|
|
5
4
|
import { parse } from "svelte/compiler";
|
|
5
|
+
import MagicString from "magic-string";
|
|
6
6
|
//#region src/script-transform/imports.ts
|
|
7
7
|
/**
|
|
8
8
|
* Builds the import statements injected by the script transform.
|
|
@@ -1646,4 +1646,4 @@ function transform_markup_effect(content, filename, options = {}) {
|
|
|
1646
1646
|
//#endregion
|
|
1647
1647
|
export { is_yield_star_expression as a, slice as c, collect_top_level_binding_names as d, has_local_import_binding as f, find_yield_star_node as i, slice_start as l, collect_yield_star_nodes as n, validate_rune_yield_usage as o, make_imports as p, contains_top_level_await as r, create_source_map as s, transform_markup_effect as t, collect_free_identifiers as u };
|
|
1648
1648
|
|
|
1649
|
-
//# sourceMappingURL=transform-
|
|
1649
|
+
//# sourceMappingURL=transform-CEK6Ccll.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform-02e-RvXH.js","names":["create_source_map","is_yield_star_expression","create_source_map"],"sources":["../../../modules/svelte-effect-runtime/src/script-transform/imports.ts","../../../modules/svelte-effect-runtime/src/markup/transform/constants.ts","../../../modules/svelte-effect-runtime/src/markup/transform/apply.ts","../../../modules/svelte-effect-runtime/src/markup/transform/effect-bindings.ts","../../../modules/svelte-effect-runtime/src/markup/transform/classify.ts","../../../modules/svelte-effect-runtime/src/markup/transform/expressions.ts","../../../modules/svelte-effect-runtime/src/markup/transform/effect-callbacks.ts","../../../modules/svelte-effect-runtime/src/markup/transform/emit.ts","../../../modules/svelte-effect-runtime/src/script-transform/source.ts","../../../modules/svelte-effect-runtime/src/script-transform/runes.ts","../../../modules/svelte-effect-runtime/src/script-transform/ast.ts","../../../modules/svelte-effect-runtime/src/markup/transform/scan.ts","../../../modules/svelte-effect-runtime/src/markup/transform/index.ts"],"sourcesContent":["import type { RuntimeImportBindings } from \"./types.ts\";\n\nimport ts from \"typescript\";\n\ninterface RuntimeImportOptions {\n\tneeds_dispatcher?: boolean;\n\tneeds_effect?: boolean;\n\tneeds_untrack?: boolean;\n}\n\n/**\n * Builds the import statements injected by the script transform.\n *\n * @since 2.0.0\n * @param has_effect_import - Whether the user already imports `Effect`.\n * @param has_dispatcher_import - Whether the user already imports\n * `get_dispatcher`.\n * @param has_untrack_import - Whether the user already imports `untrack`.\n * @param bindings - Local names reserved for generated runtime helpers.\n * @param options - Runtime helper imports required by this transformed script.\n * @returns Newline-separated import statements to inject.\n */\nexport function make_imports(\n\thas_effect_import: boolean,\n\thas_dispatcher_import: boolean,\n\thas_untrack_import: boolean,\n\tbindings: RuntimeImportBindings = {\n\t\tcancel: \"__SER___cancel\",\n\t\tdispatcher: \"get_dispatcher\",\n\t\tdispatcher_value: \"__SER___dispatcher\",\n\t\teffect: \"Effect\",\n\t\tprogram: \"__SER___program\",\n\t\tuntrack: \"untrack\",\n\t},\n\toptions: RuntimeImportOptions = {},\n): string {\n\tconst needs_dispatcher = options.needs_dispatcher ?? true;\n\tconst needs_effect = options.needs_effect ?? true;\n\tconst needs_untrack = options.needs_untrack ?? true;\n\n\tconst dispatcher_import =\n\t\tbindings.dispatcher === \"get_dispatcher\"\n\t\t\t? `import { get_dispatcher } from \"svelte-effect-runtime/internal/generators\";`\n\t\t\t: `import { get_dispatcher as ${bindings.dispatcher} } from \"svelte-effect-runtime/internal/generators\";`;\n\n\tconst untrack_import =\n\t\tbindings.untrack === \"untrack\"\n\t\t\t? `import { untrack } from \"svelte\";`\n\t\t\t: `import { untrack as ${bindings.untrack} } from \"svelte\";`;\n\n\tconst effect_import = has_effect_import\n\t\t? false\n\t\t: bindings.effect === \"Effect\"\n\t\t\t? `import { Effect } from \"effect\";`\n\t\t\t: `import { Effect as ${bindings.effect} } from \"effect\";`;\n\n\treturn [\n\t\tneeds_dispatcher && !has_dispatcher_import && dispatcher_import,\n\t\tneeds_untrack && !has_untrack_import && untrack_import,\n\t\tneeds_effect && effect_import,\n\t]\n\t\t.filter(Boolean)\n\t\t.join(\"\\n\");\n}\n\n/**\n * Checks whether a source file imports a local binding from a module.\n *\n * @since 2.0.0\n * @param source_file - Parsed TypeScript source file to inspect.\n * @param module_name - Module specifier to match.\n * @param local_name - Local binding name to look for.\n * @returns Whether that binding is already locally available.\n */\nexport function has_local_import_binding(\n\tsource_file: ts.SourceFile,\n\tmodule_name: string,\n\tlocal_name: string,\n): boolean {\n\treturn source_file.statements.some((stmt) => {\n\t\tif (\n\t\t\t!ts.isImportDeclaration(stmt) ||\n\t\t\t!ts.isStringLiteral(stmt.moduleSpecifier) ||\n\t\t\tstmt.moduleSpecifier.text !== module_name\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst clause = stmt.importClause;\n\n\t\tif (!clause || clause.isTypeOnly) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (clause.name?.text === local_name) {\n\t\t\treturn true;\n\t\t}\n\n\t\tconst named_bindings = clause.namedBindings;\n\n\t\tif (!named_bindings) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (ts.isNamespaceImport(named_bindings)) {\n\t\t\treturn named_bindings.name.text === local_name;\n\t\t}\n\n\t\treturn named_bindings.elements.some(\n\t\t\t(element) => !element.isTypeOnly && element.name.text === local_name,\n\t\t);\n\t});\n}\n\n/**\n * Checks whether a source file already has any top-level binding with a local\n * name.\n *\n * @since 2.4.2\n * @param source_file - Parsed TypeScript source file to inspect.\n * @param local_name - Local binding name to look for.\n * @returns Whether that local name is already declared in the file.\n */\nexport function has_top_level_binding(source_file: ts.SourceFile, local_name: string): boolean {\n\treturn collect_top_level_binding_names(source_file).includes(local_name);\n}\n\n/**\n * Collects every local binding declared at module top level.\n *\n * @since 2.4.2\n * @param source_file - Parsed TypeScript source file to inspect.\n * @returns Top-level names declared by imports, declarations, and variables.\n */\nexport function collect_top_level_binding_names(source_file: ts.SourceFile): string[] {\n\treturn source_file.statements.flatMap(collect_statement_binding_names);\n}\n\nfunction collect_statement_binding_names(stmt: ts.Statement): string[] {\n\tif (ts.isImportDeclaration(stmt)) {\n\t\treturn collect_import_binding_names(stmt);\n\t}\n\n\tif (ts.isVariableStatement(stmt)) {\n\t\treturn stmt.declarationList.declarations.flatMap((decl) =>\n\t\t\tcollect_binding_name_text(decl.name),\n\t\t);\n\t}\n\n\tif (\n\t\tts.isFunctionDeclaration(stmt) ||\n\t\tts.isClassDeclaration(stmt) ||\n\t\tts.isInterfaceDeclaration(stmt) ||\n\t\tts.isTypeAliasDeclaration(stmt) ||\n\t\tts.isEnumDeclaration(stmt) ||\n\t\tts.isModuleDeclaration(stmt)\n\t) {\n\t\treturn stmt.name ? [stmt.name.text] : [];\n\t}\n\n\treturn [];\n}\n\nfunction collect_import_binding_names(stmt: ts.ImportDeclaration): string[] {\n\tconst clause = stmt.importClause;\n\n\tif (!clause) {\n\t\treturn [];\n\t}\n\n\treturn [\n\t\tclause.name?.text,\n\t\tclause.namedBindings && ts.isNamespaceImport(clause.namedBindings)\n\t\t\t? clause.namedBindings.name.text\n\t\t\t: undefined,\n\t\tclause.namedBindings && ts.isNamedImports(clause.namedBindings)\n\t\t\t? clause.namedBindings.elements.map((element) => element.name.text)\n\t\t\t: undefined,\n\t]\n\t\t.flat()\n\t\t.filter((name): name is string => name !== undefined);\n}\n\nfunction collect_binding_name_text(name: ts.BindingName): string[] {\n\tif (ts.isIdentifier(name)) {\n\t\treturn [name.text];\n\t}\n\n\treturn name.elements.flatMap((element) => {\n\t\tif (ts.isOmittedExpression(element)) {\n\t\t\treturn [];\n\t\t}\n\n\t\treturn collect_binding_name_text(element.name);\n\t});\n}\n","export const HELPERS = {\n\tcodes: \"Code\",\n\tdispatcher: \"Dispatcher\",\n} as const;\n","import type MagicString from \"magic-string\";\n\nimport { collect_top_level_binding_names } from \"$/script-transform/imports.ts\";\nimport { HELPERS } from \"./constants.ts\";\nimport type {\n\tHelperDeclaration,\n\tInsertion,\n\tMarkupHelperBindings,\n\tMarkupRelocation,\n\tPendingRelocation,\n\tReplacement,\n} from \"./types.ts\";\nimport ts from \"typescript\";\n\nexport function create_source_map(magic: MagicString, filename: string): Record<string, unknown> {\n\tconst map = magic.generateMap({\n\t\thires: true,\n\t\tincludeContent: true,\n\t\tsource: filename,\n\t});\n\n\treturn map as unknown as Record<string, unknown>;\n}\n\nexport function blank_script_blocks(content: string): string {\n\treturn content.replace(/<script\\b[^>]*>[\\s\\S]*?<\\/script\\s*>/gi, (match) => {\n\t\tconst lines = match.split(\"\\n\");\n\t\treturn lines.map((l) => \" \".repeat(l.length)).join(\"\\n\");\n\t});\n}\n\nexport function inject_helpers(\n\tmagic: MagicString,\n\tcontent: string,\n\thelpers: HelperDeclaration[] = [],\n\tbindings: MarkupHelperBindings = HELPERS,\n): Insertion | undefined {\n\tconst import_helpers = unique_import_helpers(helpers);\n\tconst local_helpers = helpers.filter((helper) => !is_import_helper(helper));\n\n\tconst helper_segments: Array<{\n\t\ttext: string;\n\t\trelocation?: PendingRelocation;\n\t}> = [\n\t\tmake_import_helper(content, make_dispatcher_import(bindings)),\n\t\t...import_helpers,\n\t\t...local_helpers,\n\t]\n\t\t.filter((helper): helper is string | HelperDeclaration => helper !== undefined)\n\t\t.map((helper) => (typeof helper === \"string\" ? { text: helper } : helper));\n\n\tif (helper_segments.length === 0) {\n\t\treturn undefined;\n\t}\n\n\tconst helper_block = helper_segments.map((segment) => segment.text).join(\"\\n\");\n\n\tconst script_tag = find_instance_script_tag(content);\n\n\tif (script_tag) {\n\t\tconst text = `\\n${helper_block}\\n`;\n\n\t\tmagic.appendLeft(script_tag.end, text);\n\n\t\treturn {\n\t\t\tstart: script_tag.end,\n\t\t\ttext,\n\t\t\trelocations: make_insertion_relocations(helper_segments, \"\\n\"),\n\t\t};\n\t} else {\n\t\tconst text = `<script>\\n${helper_block}\\n</script>\\n\\n`;\n\n\t\tmagic.prepend(text);\n\n\t\treturn {\n\t\t\tstart: 0,\n\t\t\ttext,\n\t\t\trelocations: make_insertion_relocations(helper_segments, \"<script>\\n\"),\n\t\t};\n\t}\n}\n\nexport function make_markup_helper_bindings(content: string): {\n\tbindings: MarkupHelperBindings;\n\tname_allocator: { reserve(name: string): string };\n} {\n\tconst script_tag = find_instance_script_tag(content);\n\tconst binding_names = script_tag\n\t\t? collect_script_binding_names(content.slice(script_tag.start, script_tag.end))\n\t\t: [];\n\tconst name_allocator = make_name_allocator(binding_names);\n\n\treturn {\n\t\tbindings: {\n\t\t\tcodes: name_allocator.reserve(HELPERS.codes),\n\t\t\tdispatcher: name_allocator.reserve(HELPERS.dispatcher),\n\t\t},\n\t\tname_allocator,\n\t};\n}\n\nexport function create_relocations(\n\treplacements: Replacement[],\n\thelper_insertion: Insertion | undefined,\n): MarkupRelocation[] {\n\tconst edits = [\n\t\thelper_insertion && {\n\t\t\tstart: helper_insertion.start,\n\t\t\tremovedLength: 0,\n\t\t\tinsertedLength: helper_insertion.text.length,\n\t\t},\n\t\t...replacements.map((replacement) => ({\n\t\t\tstart: replacement.start,\n\t\t\tremovedLength: replacement.end - replacement.start,\n\t\t\tinsertedLength: replacement.text.length,\n\t\t})),\n\t].filter(Boolean) as Array<{\n\t\tstart: number;\n\t\tremovedLength: number;\n\t\tinsertedLength: number;\n\t}>;\n\n\tconst replacement_relocations = replacements.flatMap((replacement) => {\n\t\tif (!replacement.relocation) {\n\t\t\treturn [];\n\t\t}\n\n\t\tconst delta_before = edits\n\t\t\t.filter((edit) => edit.start < replacement.start)\n\t\t\t.reduce((total, edit) => total + edit.insertedLength - edit.removedLength, 0);\n\t\tconst generated_start = replacement.start + delta_before;\n\n\t\treturn [\n\t\t\t{\n\t\t\t\toriginalStart: replacement.relocation.originalStart,\n\t\t\t\toriginalEnd: replacement.relocation.originalEnd,\n\t\t\t\tgeneratedStart:\n\t\t\t\t\tgenerated_start + replacement.relocation.generatedStartInReplacement,\n\t\t\t\tgeneratedEnd: generated_start + replacement.relocation.generatedEndInReplacement,\n\t\t\t},\n\t\t];\n\t});\n\n\tconst helper_relocations =\n\t\thelper_insertion?.relocations?.map((relocation) => ({\n\t\t\toriginalStart: relocation.originalStart,\n\t\t\toriginalEnd: relocation.originalEnd,\n\t\t\tgeneratedStart: helper_insertion.start + relocation.generatedStartInReplacement,\n\t\t\tgeneratedEnd: helper_insertion.start + relocation.generatedEndInReplacement,\n\t\t})) ?? [];\n\n\treturn [...replacement_relocations, ...helper_relocations];\n}\n\nfunction make_import_helper(content: string, import_text: string): string | undefined {\n\tif (content.includes(import_text)) {\n\t\treturn undefined;\n\t}\n\n\treturn import_text;\n}\n\nfunction make_dispatcher_import(bindings: MarkupHelperBindings): string {\n\tconst dispatcher = make_import_specifier(HELPERS.dispatcher, bindings.dispatcher);\n\tconst codes = make_import_specifier(HELPERS.codes, bindings.codes);\n\n\treturn `import { ${dispatcher}, ${codes} } from \"svelte-effect-runtime/internal/generators\";`;\n}\n\nfunction make_import_specifier(imported_name: string, local_name: string): string {\n\tif (imported_name === local_name) {\n\t\treturn imported_name;\n\t}\n\n\treturn `${imported_name} as ${local_name}`;\n}\n\nfunction make_insertion_relocations(\n\tsegments: Array<{\n\t\ttext: string;\n\t\trelocation?: PendingRelocation;\n\t}>,\n\tprefix: string,\n): PendingRelocation[] {\n\tconst relocations: PendingRelocation[] = [];\n\tlet offset = prefix.length;\n\n\tfor (const segment of segments) {\n\t\tif (segment.relocation) {\n\t\t\trelocations.push({\n\t\t\t\toriginalStart: segment.relocation.originalStart,\n\t\t\t\toriginalEnd: segment.relocation.originalEnd,\n\t\t\t\tgeneratedStartInReplacement:\n\t\t\t\t\toffset + segment.relocation.generatedStartInReplacement,\n\t\t\t\tgeneratedEndInReplacement: offset + segment.relocation.generatedEndInReplacement,\n\t\t\t});\n\t\t}\n\n\t\toffset += segment.text.length + 1;\n\t}\n\n\treturn relocations;\n}\n\nfunction find_instance_script_tag(content: string): { start: number; end: number } | undefined {\n\tconst pattern = /<script\\b([^>]*)>([\\s\\S]*?)<\\/script\\s*>/gi;\n\n\tfor (const match of content.matchAll(pattern)) {\n\t\tif (match.index === undefined) continue;\n\n\t\tconst attrs = match[1] ?? \"\";\n\t\tif (/\\bcontext\\s*=\\s*[\"']module[\"']/.test(attrs) || /\\bmodule\\b/.test(attrs)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst open_end = match[0].indexOf(\">\") + 1;\n\t\treturn {\n\t\t\tstart: match.index + open_end,\n\t\t\tend: match.index + match[0].length - \"</script>\".length,\n\t\t};\n\t}\n\n\treturn undefined;\n}\n\nfunction unique_import_helpers(helpers: HelperDeclaration[]): HelperDeclaration[] {\n\tconst seen = new Set<string>();\n\n\treturn helpers.filter((helper) => {\n\t\tif (!is_import_helper(helper)) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (seen.has(helper.text)) {\n\t\t\treturn false;\n\t\t}\n\n\t\tseen.add(helper.text);\n\n\t\treturn true;\n\t});\n}\n\nfunction is_import_helper(helper: HelperDeclaration): boolean {\n\treturn helper.text.trimStart().startsWith(\"import \");\n}\n\nfunction collect_script_binding_names(script_content: string): string[] {\n\tconst source_file = ts.createSourceFile(\n\t\t\"markup-script.ts\",\n\t\tscript_content,\n\t\tts.ScriptTarget.Latest,\n\t\ttrue,\n\t\tts.ScriptKind.TS,\n\t);\n\n\treturn collect_top_level_binding_names(source_file);\n}\n\nfunction make_name_allocator(initial_names: readonly string[]): {\n\treserve(name: string): string;\n} {\n\tconst used_names = new Set(initial_names);\n\n\treturn {\n\t\treserve(name: string): string {\n\t\t\tlet candidate = name;\n\t\t\tlet suffix = 1;\n\n\t\t\twhile (used_names.has(candidate)) {\n\t\t\t\tcandidate = `${name}_${suffix}`;\n\t\t\t\tsuffix += 1;\n\t\t\t}\n\n\t\t\tused_names.add(candidate);\n\n\t\t\treturn candidate;\n\t\t},\n\t};\n}\n","import type { HelperDeclaration } from \"./types.ts\";\n\nimport ts from \"typescript\";\n\nconst EFFECT_PACKAGE_MODULE = \"effect\";\nconst EFFECT_DIRECT_MODULE = \"effect/Effect\";\nconst GENERATED_EFFECT_NAME = \"__SER___Effect\";\n\n/**\n * Describes local bindings that resolve to Effect APIs in markup expressions.\n *\n * @example\n * ```ts\n * const context = collect_effect_callback_bindings(source);\n * context.effect_object_names.has(\"E\");\n * ```\n *\n * @since 2.4.0\n */\nexport interface EffectCallbackRewriteContext {\n\t/** Local names imported as the Effect object, such as `Effect` or `E`. */\n\teffect_object_names: ReadonlySet<string>;\n\t/** Namespace names imported from `effect/Effect`, such as `E.flatMap`. */\n\teffect_module_names: ReadonlySet<string>;\n\t/** Package namespace names imported from `effect`, such as `Fx.Effect`. */\n\teffect_package_names: ReadonlySet<string>;\n\t/** Direct `effect/Effect` imports mapped from local name to exported name. */\n\tdirect_members: ReadonlyMap<string, string>;\n\t/** Expression used for generated `gen`, `sync`, and upgraded direct calls. */\n\twrapper_expression: string;\n\t/** Import inserted when generated code needs a fresh Effect binding. */\n\twrapper_import: HelperDeclaration | undefined;\n}\n\ninterface EffectBindingState {\n\teffect_object_names: string[];\n\teffect_module_names: string[];\n\teffect_package_names: string[];\n\tdirect_members: Map<string, string>;\n\tlocal_names: Set<string>;\n\timplicit_effect_import: boolean;\n}\n\n/**\n * Collects Effect import bindings that markup callback rewriting can trust.\n *\n * @example\n * ```ts\n * const bindings = collect_effect_callback_bindings(\n * `<script>import { Effect as E } from \"effect\";</script>`,\n * );\n * ```\n *\n * @since 2.4.0\n * @param content - Full Svelte component source before markup lowering.\n * @returns Binding metadata used to identify Effect callback combinators.\n */\nexport function collect_effect_callback_bindings(content: string): EffectCallbackRewriteContext {\n\tconst state = make_effect_binding_state();\n\tconst scripts = collect_script_blocks(content);\n\n\tfor (const script of scripts) {\n\t\tconst source_file = ts.createSourceFile(\n\t\t\t\"component-script.ts\",\n\t\t\tscript,\n\t\t\tts.ScriptTarget.Latest,\n\t\t\ttrue,\n\t\t\tts.ScriptKind.TS,\n\t\t);\n\n\t\tcollect_source_file_bindings(source_file, state);\n\t}\n\n\tensure_implicit_effect_binding(state);\n\n\tconst wrapper = choose_effect_wrapper(state);\n\n\treturn {\n\t\teffect_object_names: new Set(state.effect_object_names),\n\t\teffect_module_names: new Set(state.effect_module_names),\n\t\teffect_package_names: new Set(state.effect_package_names),\n\t\tdirect_members: new Map(state.direct_members),\n\t\twrapper_expression: wrapper.expression,\n\t\twrapper_import: wrapper.import_text ? { text: wrapper.import_text } : undefined,\n\t};\n}\n\nfunction make_effect_binding_state(): EffectBindingState {\n\treturn {\n\t\teffect_object_names: [],\n\t\teffect_module_names: [],\n\t\teffect_package_names: [],\n\t\tdirect_members: new Map(),\n\t\tlocal_names: new Set(),\n\t\timplicit_effect_import: false,\n\t};\n}\n\nfunction collect_script_blocks(content: string): string[] {\n\tconst pattern = /<script\\b[^>]*>([\\s\\S]*?)<\\/script\\s*>/gi;\n\n\treturn [...content.matchAll(pattern)].map((match) => match[1] ?? \"\");\n}\n\nfunction collect_source_file_bindings(source_file: ts.SourceFile, state: EffectBindingState): void {\n\tfor (const statement of source_file.statements) {\n\t\tcollect_statement_binding(statement, state);\n\t}\n}\n\nfunction collect_statement_binding(statement: ts.Statement, state: EffectBindingState): void {\n\tif (ts.isImportDeclaration(statement)) {\n\t\tcollect_import_binding(statement, state);\n\t\treturn;\n\t}\n\n\tif (ts.isImportEqualsDeclaration(statement)) {\n\t\tstate.local_names.add(statement.name.text);\n\t\treturn;\n\t}\n\n\tif (ts.isVariableStatement(statement)) {\n\t\tfor (const declaration of statement.declarationList.declarations) {\n\t\t\tcollect_binding_name(declaration.name, state.local_names);\n\t\t}\n\n\t\treturn;\n\t}\n\n\tif (\n\t\tts.isFunctionDeclaration(statement) ||\n\t\tts.isClassDeclaration(statement) ||\n\t\tts.isInterfaceDeclaration(statement) ||\n\t\tts.isTypeAliasDeclaration(statement) ||\n\t\tts.isEnumDeclaration(statement) ||\n\t\tts.isModuleDeclaration(statement)\n\t) {\n\t\tif (statement.name) {\n\t\t\tstate.local_names.add(statement.name.text);\n\t\t}\n\t}\n}\n\nfunction collect_import_binding(statement: ts.ImportDeclaration, state: EffectBindingState): void {\n\tif (!ts.isStringLiteral(statement.moduleSpecifier)) {\n\t\treturn;\n\t}\n\n\tconst module_name = statement.moduleSpecifier.text;\n\tconst clause = statement.importClause;\n\n\tif (!clause) {\n\t\treturn;\n\t}\n\n\tif (clause.name) {\n\t\tstate.local_names.add(clause.name.text);\n\t}\n\n\tconst named_bindings = clause.namedBindings;\n\n\tif (!named_bindings) {\n\t\treturn;\n\t}\n\n\tif (ts.isNamespaceImport(named_bindings)) {\n\t\tcollect_namespace_import_binding(module_name, named_bindings.name.text, state);\n\t\treturn;\n\t}\n\n\tfor (const element of named_bindings.elements) {\n\t\tcollect_named_import_binding(module_name, element, state);\n\t}\n}\n\nfunction collect_namespace_import_binding(\n\tmodule_name: string,\n\tlocal_name: string,\n\tstate: EffectBindingState,\n): void {\n\tstate.local_names.add(local_name);\n\n\tif (module_name === EFFECT_DIRECT_MODULE) {\n\t\tadd_ordered_name(state.effect_module_names, local_name);\n\t\treturn;\n\t}\n\n\tif (module_name === EFFECT_PACKAGE_MODULE) {\n\t\tadd_ordered_name(state.effect_package_names, local_name);\n\t}\n}\n\nfunction collect_named_import_binding(\n\tmodule_name: string,\n\telement: ts.ImportSpecifier,\n\tstate: EffectBindingState,\n): void {\n\tconst imported_name = element.propertyName?.text ?? element.name.text;\n\tconst local_name = element.name.text;\n\n\tstate.local_names.add(local_name);\n\n\tif (module_name === EFFECT_PACKAGE_MODULE && imported_name === \"Effect\") {\n\t\tadd_ordered_name(state.effect_object_names, local_name);\n\t\treturn;\n\t}\n\n\tif (module_name === EFFECT_DIRECT_MODULE) {\n\t\tstate.direct_members.set(local_name, imported_name);\n\t}\n}\n\nfunction collect_binding_name(name: ts.BindingName, local_names: Set<string>): void {\n\tif (ts.isIdentifier(name)) {\n\t\tlocal_names.add(name.text);\n\t\treturn;\n\t}\n\n\tfor (const element of name.elements) {\n\t\tif (ts.isOmittedExpression(element)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tcollect_binding_name(element.name, local_names);\n\t}\n}\n\nfunction ensure_implicit_effect_binding(state: EffectBindingState): void {\n\tif (has_effect_binding(state) || state.local_names.has(\"Effect\")) {\n\t\treturn;\n\t}\n\n\tadd_ordered_name(state.effect_object_names, \"Effect\");\n\tstate.implicit_effect_import = true;\n}\n\nfunction has_effect_binding(state: EffectBindingState): boolean {\n\treturn (\n\t\tstate.effect_object_names.length > 0 ||\n\t\tstate.effect_module_names.length > 0 ||\n\t\tstate.effect_package_names.length > 0 ||\n\t\tstate.direct_members.size > 0\n\t);\n}\n\nfunction choose_effect_wrapper(state: EffectBindingState): {\n\texpression: string;\n\timport_text?: string;\n} {\n\tconst effect_object = state.effect_object_names[0];\n\n\tif (effect_object) {\n\t\treturn {\n\t\t\texpression: effect_object,\n\t\t\timport_text: state.implicit_effect_import\n\t\t\t\t? `import { Effect } from \"effect\";`\n\t\t\t\t: undefined,\n\t\t};\n\t}\n\n\tconst effect_module = state.effect_module_names[0];\n\n\tif (effect_module) {\n\t\treturn { expression: effect_module };\n\t}\n\n\tconst effect_package = state.effect_package_names[0];\n\n\tif (effect_package) {\n\t\treturn { expression: `${effect_package}.Effect` };\n\t}\n\n\tconst generated_name = make_generated_effect_name(state.local_names);\n\n\treturn {\n\t\texpression: generated_name,\n\t\timport_text: `import { Effect as ${generated_name} } from \"effect\";`,\n\t};\n}\n\nfunction make_generated_effect_name(local_names: ReadonlySet<string>): string {\n\tif (!local_names.has(GENERATED_EFFECT_NAME)) {\n\t\treturn GENERATED_EFFECT_NAME;\n\t}\n\n\tlet index = 1;\n\n\twhile (local_names.has(`${GENERATED_EFFECT_NAME}_${index}`)) {\n\t\tindex += 1;\n\t}\n\n\treturn `${GENERATED_EFFECT_NAME}_${index}`;\n}\n\nfunction add_ordered_name(names: string[], name: string): void {\n\tif (names.includes(name)) {\n\t\treturn;\n\t}\n\n\tnames.push(name);\n}\n","import type { AST } from \"svelte/compiler\";\n\nimport type { MarkupCandidate, TagKind } from \"./types.ts\";\n\n/**\n * Matches sanitized placeholders back to their Svelte AST context.\n *\n * @since 2.0.0\n * @param ast - Parsed Svelte AST for the sanitized component markup.\n * @param candidates - Placeholder candidates produced by the scanner.\n * @returns Candidates paired with the markup context that determines how they\n * should be emitted.\n */\nexport function classify_candidates(\n\tast: AST.Root,\n\tcandidates: MarkupCandidate[],\n): Array<{ candidate: MarkupCandidate; kind: TagKind }> {\n\tconst by_placeholder = new Map(\n\t\tcandidates.map((candidate) => [candidate.placeholder, candidate]),\n\t);\n\n\tconst classified: Array<{ candidate: MarkupCandidate; kind: TagKind }> = [];\n\tconst matched = new Set<string>();\n\n\twalk_ast(ast.fragment, by_placeholder, matched, classified);\n\n\treturn classified;\n}\n\nfunction walk_ast(\n\tfragment: AST.Fragment,\n\tcandidates: Map<string, MarkupCandidate>,\n\tmatched: Set<string>,\n\tclassified: Array<{ candidate: MarkupCandidate; kind: TagKind }>,\n): void {\n\tfor (const node of fragment.nodes) {\n\t\tvisit_ast_node(node, candidates, matched, classified);\n\t}\n}\n\nfunction visit_ast_node(\n\tnode: AST.Fragment[\"nodes\"][number],\n\tcandidates: Map<string, MarkupCandidate>,\n\tmatched: Set<string>,\n\tclassified: Array<{ candidate: MarkupCandidate; kind: TagKind }>,\n): void {\n\tswitch (node.type) {\n\t\tcase \"ExpressionTag\":\n\t\t\tclassify_expression(node.expression, \"plain\", candidates, matched, classified);\n\t\t\treturn;\n\n\t\tcase \"IfBlock\":\n\t\t\tclassify_expression(node.test, \"plain\", candidates, matched, classified);\n\t\t\twalk_ast(node.consequent, candidates, matched, classified);\n\t\t\tif (node.alternate) {\n\t\t\t\twalk_ast(node.alternate, candidates, matched, classified);\n\t\t\t}\n\t\t\treturn;\n\n\t\tcase \"EachBlock\":\n\t\t\tclassify_expression(node.expression, \"each\", candidates, matched, classified);\n\t\t\twalk_ast(node.body, candidates, matched, classified);\n\t\t\tif (node.fallback) {\n\t\t\t\twalk_ast(node.fallback, candidates, matched, classified);\n\t\t\t}\n\t\t\treturn;\n\n\t\tcase \"AwaitBlock\":\n\t\t\tclassify_expression(node.expression, \"await\", candidates, matched, classified);\n\t\t\tif (node.pending) {\n\t\t\t\twalk_ast(node.pending, candidates, matched, classified);\n\t\t\t}\n\t\t\tif (node.then) walk_ast(node.then, candidates, matched, classified);\n\t\t\tif (node.catch) walk_ast(node.catch, candidates, matched, classified);\n\t\t\treturn;\n\n\t\tcase \"RenderTag\":\n\t\t\tclassify_expression(node.expression, \"render\", candidates, matched, classified);\n\t\t\treturn;\n\n\t\tcase \"HtmlTag\":\n\t\t\tclassify_expression(node.expression, \"plain\", candidates, matched, classified);\n\t\t\treturn;\n\n\t\tcase \"DebugTag\":\n\t\t\tclassify_debug_tag(node, candidates, matched, classified);\n\t\t\treturn;\n\n\t\tcase \"ConstTag\":\n\t\tcase \"DeclarationTag\":\n\t\t\tclassify_declaration_tag(node, candidates, matched, classified);\n\t\t\treturn;\n\n\t\tcase \"KeyBlock\":\n\t\t\tclassify_expression(node.expression, \"plain\", candidates, matched, classified);\n\t\t\twalk_ast(node.fragment, candidates, matched, classified);\n\t\t\treturn;\n\n\t\tcase \"RegularElement\":\n\t\tcase \"Component\":\n\t\tcase \"TitleElement\":\n\t\tcase \"SlotElement\":\n\t\tcase \"SvelteBody\":\n\t\tcase \"SvelteBoundary\":\n\t\tcase \"SvelteComponent\":\n\t\tcase \"SvelteDocument\":\n\t\tcase \"SvelteElement\":\n\t\tcase \"SvelteFragment\":\n\t\tcase \"SvelteHead\":\n\t\tcase \"SvelteSelf\":\n\t\tcase \"SvelteWindow\":\n\t\t\tvisit_element_attributes(node, candidates, matched, classified);\n\t\t\twalk_ast(node.fragment, candidates, matched, classified);\n\t\t\treturn;\n\n\t\tdefault:\n\t\t\treturn;\n\t}\n}\n\nfunction classify_debug_tag(\n\t_node: Extract<AST.Fragment[\"nodes\"][number], { type: \"DebugTag\" }>,\n\t_candidates: Map<string, MarkupCandidate>,\n\t_matched: Set<string>,\n\t_classified: Array<{ candidate: MarkupCandidate; kind: TagKind }>,\n): void {\n\treturn;\n}\n\nfunction classify_declaration_tag(\n\tnode: Extract<AST.Fragment[\"nodes\"][number], { type: \"ConstTag\" | \"DeclarationTag\" }>,\n\tcandidates: Map<string, MarkupCandidate>,\n\tmatched: Set<string>,\n\tclassified: Array<{ candidate: MarkupCandidate; kind: TagKind }>,\n): void {\n\tfor (const decl of node.declaration.declarations) {\n\t\tclassify_expression(decl as ExpressionLike, \"plain\", candidates, matched, classified);\n\t}\n}\n\ninterface ElementLikeNode {\n\tattributes: Array<{\n\t\ttype: string;\n\t\tname?: string;\n\t\tvalue?: unknown;\n\t\texpression?: unknown;\n\t}>;\n\tfragment: AST.Fragment;\n}\n\nfunction visit_element_attributes(\n\tnode: ElementLikeNode,\n\tcandidates: Map<string, MarkupCandidate>,\n\tmatched: Set<string>,\n\tclassified: Array<{ candidate: MarkupCandidate; kind: TagKind }>,\n): void {\n\tfor (const attr of node.attributes) {\n\t\tif (attr.type === \"Attribute\" && attr.name && is_event_attribute_name(attr.name)) {\n\t\t\tvisit_attribute_value(\n\t\t\t\tattr.value as true | AST.ExpressionTag | Array<AST.Text | AST.ExpressionTag>,\n\t\t\t\t\"event\",\n\t\t\t\tcandidates,\n\t\t\t\tmatched,\n\t\t\t\tclassified,\n\t\t\t);\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (attr.type === \"OnDirective\" && attr.expression) {\n\t\t\tclassify_expression(\n\t\t\t\tattr.expression as ExpressionLike,\n\t\t\t\t\"event\",\n\t\t\t\tcandidates,\n\t\t\t\tmatched,\n\t\t\t\tclassified,\n\t\t\t);\n\t\t\tcontinue;\n\t\t}\n\t}\n}\n\nfunction is_event_attribute_name(name: string): boolean {\n\treturn name.startsWith(\"on:\") || /^on[a-z]/.test(name);\n}\n\nfunction visit_attribute_value(\n\tvalue: true | AST.ExpressionTag | Array<AST.Text | AST.ExpressionTag>,\n\tkind: TagKind,\n\tcandidates: Map<string, MarkupCandidate>,\n\tmatched: Set<string>,\n\tclassified: Array<{ candidate: MarkupCandidate; kind: TagKind }>,\n): void {\n\tif (value === true) {\n\t\treturn;\n\t}\n\n\tif (Array.isArray(value)) {\n\t\tfor (const part of value) {\n\t\t\tif (part.type === \"ExpressionTag\") {\n\t\t\t\tclassify_expression(part.expression, kind, candidates, matched, classified);\n\t\t\t}\n\t\t}\n\t\treturn;\n\t}\n\n\tclassify_expression(value.expression, kind, candidates, matched, classified);\n}\n\ntype ExpressionLike = {\n\ttype: string;\n\tname?: string;\n\tcallee?: { type: string; name?: string };\n};\n\nfunction classify_expression(\n\texpression: ExpressionLike | null | undefined,\n\tkind: TagKind,\n\tcandidates: Map<string, MarkupCandidate>,\n\tmatched: Set<string>,\n\tclassified: Array<{ candidate: MarkupCandidate; kind: TagKind }>,\n): void {\n\tif (!expression) {\n\t\treturn;\n\t}\n\n\tconst found_candidates = find_candidates(expression, candidates);\n\n\tfor (const candidate of found_candidates) {\n\t\tif (matched.has(candidate.placeholder)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tmatched.add(candidate.placeholder);\n\t\tclassified.push({\n\t\t\tcandidate,\n\t\t\tkind: resolve_candidate_kind(candidate, kind),\n\t\t});\n\t}\n}\n\nfunction resolve_candidate_kind(candidate: MarkupCandidate, context_kind: TagKind): TagKind {\n\tif (candidate.key === \"render_argument\") {\n\t\treturn \"render_argument\";\n\t}\n\n\treturn context_kind;\n}\n\nfunction find_candidates(\n\texpression: ExpressionLike,\n\tcandidates: Map<string, MarkupCandidate>,\n): MarkupCandidate[] {\n\tconst found: MarkupCandidate[] = [];\n\tconst seen_nodes = new Set<unknown>();\n\tconst seen_placeholders = new Set<string>();\n\n\tvisit_expression_value(expression, candidates, seen_nodes, seen_placeholders, found);\n\n\treturn found;\n}\n\nfunction visit_expression_value(\n\tvalue: unknown,\n\tcandidates: Map<string, MarkupCandidate>,\n\tseen_nodes: Set<unknown>,\n\tseen_placeholders: Set<string>,\n\tfound: MarkupCandidate[],\n): void {\n\tif (Array.isArray(value)) {\n\t\tfor (const item of value) {\n\t\t\tvisit_expression_value(item, candidates, seen_nodes, seen_placeholders, found);\n\t\t}\n\n\t\treturn;\n\t}\n\n\tif (!is_record(value) || seen_nodes.has(value)) {\n\t\treturn;\n\t}\n\n\tseen_nodes.add(value);\n\n\tif (value.type === \"Identifier\" && typeof value.name === \"string\") {\n\t\tconst candidate = candidates.get(value.name);\n\n\t\tif (candidate && !seen_placeholders.has(candidate.placeholder)) {\n\t\t\tseen_placeholders.add(candidate.placeholder);\n\t\t\tfound.push(candidate);\n\t\t}\n\t}\n\n\tfor (const child of Object.values(value)) {\n\t\tvisit_expression_value(child, candidates, seen_nodes, seen_placeholders, found);\n\t}\n}\n\nfunction is_record(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null;\n}\n","import ts from \"typescript\";\n\n/**\n * Strips an event handler arrow function down to its executable body.\n *\n * @since 2.0.0\n * @param expr - Event handler expression text from the original markup.\n * @returns Handler parameters, body text, and body offsets inside `expr`.\n */\nexport function strip_arrow_function(expr: string): {\n\tparams: string;\n\tbody: string;\n\tbody_start: number;\n\tbody_end: number;\n} {\n\tconst arrow_idx = expr.indexOf(\"=>\");\n\n\tif (arrow_idx === -1) {\n\t\treturn { params: \"()\", body: expr, body_start: 0, body_end: expr.length };\n\t}\n\n\tconst params = expr.slice(0, arrow_idx).trim();\n\tconst raw_body = expr.slice(arrow_idx + 2);\n\tconst leading_ws = raw_body.length - raw_body.trimStart().length;\n\tlet body_start = arrow_idx + 2 + leading_ws;\n\tlet body_end = expr.length - (raw_body.length - raw_body.trimEnd().length);\n\tlet body = expr.slice(body_start, body_end);\n\n\tif (body.startsWith(\"{\") && body.endsWith(\"}\")) {\n\t\tbody_start += 1;\n\t\tbody_end -= 1;\n\t\tbody = body.slice(1, -1);\n\t}\n\n\tconst body_leading_ws = body.length - body.trimStart().length;\n\tconst body_trailing_ws = body.length - body.trimEnd().length;\n\n\tbody_start += body_leading_ws;\n\tbody_end -= body_trailing_ws;\n\tbody = body.trim();\n\n\tif (body.endsWith(\";\")) {\n\t\tbody = body.slice(0, -1);\n\t\tbody_end -= 1;\n\t}\n\n\treturn { params, body, body_start, body_end };\n}\n\n/**\n * Returns whether an expression is a callback function.\n *\n * @since 2.0.0\n * @param expr - Expression text from a markup attribute or expression tag.\n * @returns Whether the expression parses as an arrow or function expression.\n */\nexport function is_callback_function_expression(expr: string): boolean {\n\tconst wrapped = `const __SER___callback = ${expr};`;\n\tconst sf = ts.createSourceFile(\n\t\t\"callback.ts\",\n\t\twrapped,\n\t\tts.ScriptTarget.Latest,\n\t\ttrue,\n\t\tts.ScriptKind.TS,\n\t);\n\tconst stmt = sf.statements[0];\n\n\tif (!ts.isVariableStatement(stmt)) {\n\t\treturn false;\n\t}\n\n\tconst initializer = stmt.declarationList.declarations[0]?.initializer;\n\n\treturn (\n\t\tinitializer !== undefined &&\n\t\t(ts.isArrowFunction(initializer) || ts.isFunctionExpression(initializer))\n\t);\n}\n\n/**\n * Classifies `yield*` placement inside an event handler body.\n *\n * @example\n * ```ts\n * analyze_event_body_yield_star(\"yield* save()\");\n * ```\n *\n * @since 2.0.0\n * @param body - Event handler body text after the outer arrow has been\n * stripped.\n * @returns Whether the body has top-level yield* expressions and whether any\n * yield* appears inside a nested non-generator callback.\n */\nexport function analyze_event_body_yield_star(body: string): {\n\thas_top_level_yield_star: boolean;\n\thas_nested_invalid_yield_star: boolean;\n} {\n\tconst wrapped = `function* __SER___event() { ${body}; }`;\n\tconst sf = ts.createSourceFile(\n\t\t\"event.ts\",\n\t\twrapped,\n\t\tts.ScriptTarget.Latest,\n\t\ttrue,\n\t\tts.ScriptKind.TS,\n\t);\n\tconst stmt = sf.statements[0];\n\n\tif (!ts.isFunctionDeclaration(stmt) || !stmt.body) {\n\t\treturn {\n\t\t\thas_top_level_yield_star: false,\n\t\t\thas_nested_invalid_yield_star: /\\byield\\s*\\*/.test(body),\n\t\t};\n\t}\n\n\tconst result = {\n\t\thas_top_level_yield_star: false,\n\t\thas_nested_invalid_yield_star: false,\n\t};\n\n\tvisit_event_body(stmt.body, \"top_level\", result);\n\n\treturn result;\n}\n\n/**\n * Collects free identifiers that must be captured as reactive dependencies.\n *\n * @since 2.0.0\n * @param expr_text - Markup expression text to inspect.\n * @returns Identifier names referenced by the expression.\n */\nexport function collect_free_identifiers(expr_text: string): string[] {\n\tconst wrapped = `function* __SER___w() { return (${expr_text}); }`;\n\tlet sf: ts.SourceFile;\n\n\ttry {\n\t\tsf = ts.createSourceFile(\n\t\t\t\"expr.ts\",\n\t\t\twrapped,\n\t\t\tts.ScriptTarget.Latest,\n\t\t\ttrue,\n\t\t\tts.ScriptKind.TS,\n\t\t);\n\t} catch {\n\t\treturn [];\n\t}\n\n\tconst fn = sf.statements[0];\n\n\tif (!ts.isFunctionDeclaration(fn) || !fn.body) {\n\t\treturn [];\n\t}\n\n\tconst ids: string[] = [];\n\tconst locals = new Set<string>();\n\tconst seen = new Set<string>();\n\n\tvisit_ids(fn.body, locals, seen, ids);\n\n\treturn ids;\n}\n\nfunction visit_ids(node: ts.Node, locals: Set<string>, seen: Set<string>, ids: string[]): void {\n\tif (\n\t\tts.isArrowFunction(node) ||\n\t\tts.isFunctionExpression(node) ||\n\t\tts.isFunctionDeclaration(node)\n\t) {\n\t\tconst scoped = new Set(locals);\n\n\t\tif (ts.isFunctionDeclaration(node) && node.name) {\n\t\t\tscoped.add(node.name.text);\n\t\t}\n\n\t\tfor (const parameter of node.parameters) {\n\t\t\tadd_binding_names(parameter.name, scoped);\n\t\t}\n\n\t\tif (node.body) {\n\t\t\tvisit_ids(node.body, scoped, seen, ids);\n\t\t}\n\n\t\treturn;\n\t}\n\n\tif (ts.isVariableDeclaration(node)) {\n\t\tif (node.initializer) {\n\t\t\tvisit_ids(node.initializer, locals, seen, ids);\n\t\t}\n\n\t\tadd_binding_names(node.name, locals);\n\n\t\treturn;\n\t}\n\n\tif (ts.isTypeReferenceNode(node)) {\n\t\treturn;\n\t}\n\n\tif (ts.isIdentifier(node)) {\n\t\tif (\n\t\t\tnode.text === \"yield\" ||\n\t\t\tnode.text === \"undefined\" ||\n\t\t\tnode.text === \"null\" ||\n\t\t\tnode.text === \"true\" ||\n\t\t\tnode.text === \"false\" ||\n\t\t\tnode.text === \"this\"\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (is_property_access_name(node)) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (!locals.has(node.text) && !seen.has(node.text)) {\n\t\t\tseen.add(node.text);\n\t\t\tids.push(node.text);\n\t\t}\n\t\treturn;\n\t}\n\n\tnode.forEachChild((child) => visit_ids(child, locals, seen, ids));\n}\n\nfunction add_binding_names(name: ts.BindingName, locals: Set<string>): void {\n\tif (ts.isIdentifier(name)) {\n\t\tlocals.add(name.text);\n\t\treturn;\n\t}\n\n\tfor (const element of name.elements) {\n\t\tif (ts.isOmittedExpression(element)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tadd_binding_names(element.name, locals);\n\t}\n}\n\ntype EventYieldContext = \"top_level\" | \"nested_generator\" | \"nested_invalid\";\n\ninterface EventYieldAnalysis {\n\thas_top_level_yield_star: boolean;\n\thas_nested_invalid_yield_star: boolean;\n}\n\nfunction visit_event_body(\n\tnode: ts.Node,\n\tcontext: EventYieldContext,\n\tresult: EventYieldAnalysis,\n): void {\n\tif (is_yield_star_expression(node)) {\n\t\tif (context === \"top_level\") {\n\t\t\tresult.has_top_level_yield_star = true;\n\t\t} else if (context === \"nested_invalid\") {\n\t\t\tresult.has_nested_invalid_yield_star = true;\n\t\t}\n\n\t\tnode.forEachChild((child) => visit_event_body(child, context, result));\n\t\treturn;\n\t}\n\n\tif (is_nested_function_boundary(node)) {\n\t\tconst next_context = is_generator_function_boundary(node)\n\t\t\t? \"nested_generator\"\n\t\t\t: \"nested_invalid\";\n\n\t\tnode.forEachChild((child) => visit_event_body(child, next_context, result));\n\t\treturn;\n\t}\n\n\tnode.forEachChild((child) => visit_event_body(child, context, result));\n}\n\nfunction is_nested_function_boundary(node: ts.Node): boolean {\n\treturn (\n\t\tts.isArrowFunction(node) ||\n\t\tts.isFunctionExpression(node) ||\n\t\tts.isFunctionDeclaration(node) ||\n\t\tts.isMethodDeclaration(node) ||\n\t\tts.isGetAccessorDeclaration(node) ||\n\t\tts.isSetAccessorDeclaration(node)\n\t);\n}\n\nfunction is_generator_function_boundary(node: ts.Node): boolean {\n\treturn (\n\t\t(ts.isFunctionExpression(node) ||\n\t\t\tts.isFunctionDeclaration(node) ||\n\t\t\tts.isMethodDeclaration(node)) &&\n\t\tnode.asteriskToken !== undefined\n\t);\n}\n\nfunction is_yield_star_expression(node: ts.Node): boolean {\n\tif (ts.isYieldExpression(node)) {\n\t\treturn node.asteriskToken !== undefined;\n\t}\n\n\treturn (\n\t\tts.isBinaryExpression(node) &&\n\t\tnode.operatorToken.kind === ts.SyntaxKind.AsteriskToken &&\n\t\tts.isIdentifier(node.left) &&\n\t\tnode.left.text === \"yield\"\n\t);\n}\n\nfunction is_property_access_name(node: ts.Identifier): boolean {\n\tconst parent = node.parent;\n\n\treturn (\n\t\t(ts.isPropertyAccessExpression(parent) && parent.name === node) ||\n\t\t(ts.isPropertyAssignment(parent) && parent.name === node) ||\n\t\t(ts.isBindingElement(parent) && parent.propertyName === node) ||\n\t\tts.isImportSpecifier(parent) ||\n\t\tts.isExportSpecifier(parent)\n\t);\n}\n","import { contains_top_level_yield_star } from \"$/detect.ts\";\nimport type { EffectCallbackRewriteContext } from \"./effect-bindings.ts\";\nimport type { HelperDeclaration } from \"./types.ts\";\n\nimport MagicString from \"magic-string\";\nimport ts from \"typescript\";\n\nconst match_effect_members = new Map([\n\t[\"match\", \"matchEffect\"],\n\t[\"matchCause\", \"matchCauseEffect\"],\n]);\n\nconst effectful_callback_members = new Set([\n\t\"andThen\",\n\t\"catchAll\",\n\t\"catchAllCause\",\n\t\"catchCause\",\n\t\"catchTag\",\n\t\"flatMap\",\n\t\"forEach\",\n\t\"tap\",\n\t\"tapError\",\n\t\"tapErrorCause\",\n]);\n\nconst effectful_handler_members = new Set([\"matchCauseEffect\", \"matchEffect\", \"tapBoth\"]);\n\nconst effectful_handler_property_names = new Set([\"onFailure\", \"onSuccess\"]);\n\ninterface RewriteContext {\n\tsource_file: ts.SourceFile;\n\tsource_text: string;\n\tmagic: MagicString;\n\toffset: number;\n\tbindings: EffectCallbackRewriteContext;\n\tchanged: boolean;\n\tuses_wrapper: boolean;\n}\n\ninterface EffectMember {\n\tname: string;\n\tname_start: number;\n\tname_end: number;\n\tdirect: boolean;\n}\n\ntype EffectWrapperMember = \"gen\" | \"sync\";\n\n/**\n * Rewrites effectful callback shorthand inside event handler expressions.\n *\n * @example\n * ```ts\n * normalize_effect_callback_yields(\n * `yield* action.pipe(Effect.flatMap((value) => yield* next(value)))`,\n * collect_effect_callback_bindings(source),\n * );\n * ```\n *\n * @since 2.0.0\n * @param expr_text - Markup expression text before it is wrapped in the\n * generated Effect runner.\n * @param bindings - Local Effect import bindings collected from the Svelte\n * component's script blocks.\n * @returns The expression with nested Effect callback `yield*` shorthand\n * lowered into explicit Effect callbacks, plus any import needed by generated\n * wrapper calls.\n */\nexport function normalize_effect_callback_yields(\n\texpr_text: string,\n\tbindings: EffectCallbackRewriteContext,\n): { expr_text: string; helpers: HelperDeclaration[] } {\n\tconst prefix = \"const __SER___expression = \";\n\tconst source_text = `${prefix}${expr_text};`;\n\tconst source_file = ts.createSourceFile(\n\t\t\"event-expression.ts\",\n\t\tsource_text,\n\t\tts.ScriptTarget.Latest,\n\t\ttrue,\n\t\tts.ScriptKind.TS,\n\t);\n\tconst statement = source_file.statements[0];\n\tconst magic = new MagicString(expr_text);\n\tconst context: RewriteContext = {\n\t\tsource_file,\n\t\tsource_text,\n\t\tmagic,\n\t\toffset: prefix.length,\n\t\tbindings,\n\t\tchanged: false,\n\t\tuses_wrapper: false,\n\t};\n\n\tif (!ts.isVariableStatement(statement)) {\n\t\treturn { expr_text, helpers: [] };\n\t}\n\n\tconst expression = statement.declarationList.declarations[0]?.initializer;\n\n\tif (!expression) {\n\t\treturn { expr_text, helpers: [] };\n\t}\n\n\tvisit_expression(expression, context);\n\n\tif (!context.changed) {\n\t\treturn { expr_text, helpers: [] };\n\t}\n\n\tconst helpers =\n\t\tcontext.uses_wrapper && bindings.wrapper_import ? [bindings.wrapper_import] : [];\n\n\treturn {\n\t\texpr_text: magic.toString(),\n\t\thelpers,\n\t};\n}\n\nfunction visit_expression(node: ts.Node, context: RewriteContext): void {\n\tif (is_non_generator_callback_with_top_level_yield(node)) {\n\t\treturn;\n\t}\n\n\tif (ts.isCallExpression(node)) {\n\t\trewrite_match_call(node, context);\n\t\trewrite_effectful_handler_call(node, context);\n\t\trewrite_effectful_callback_arguments(node, context);\n\t}\n\n\tnode.forEachChild((child) => {\n\t\tvisit_expression(child, context);\n\t});\n}\n\nfunction rewrite_match_call(call: ts.CallExpression, context: RewriteContext): void {\n\tconst member = get_effect_member(call.expression, context);\n\tconst upgraded_name = member && match_effect_members.get(member.name);\n\tconst options = get_last_object_argument(call);\n\n\tif (!member || !upgraded_name || !options) {\n\t\treturn;\n\t}\n\n\tconst handlers = get_handler_properties(options);\n\tconst should_upgrade = handlers.some(\n\t\t(handler) =>\n\t\t\thandler.callback && is_non_generator_callback_with_top_level_yield(handler.callback),\n\t);\n\n\tif (!should_upgrade) {\n\t\treturn;\n\t}\n\n\trewrite_effect_member_name(member, upgraded_name, context);\n\tcontext.changed = true;\n\n\tfor (const handler of handlers) {\n\t\tif (!handler.callback) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (is_non_generator_callback_with_top_level_yield(handler.callback)) {\n\t\t\trewrite_callback_to_effect_gen(handler.callback, context);\n\t\t} else {\n\t\t\trewrite_callback_to_effect_sync(handler.callback, context);\n\t\t}\n\t}\n}\n\nfunction rewrite_effectful_handler_call(call: ts.CallExpression, context: RewriteContext): void {\n\tconst member = get_effect_member(call.expression, context);\n\tconst options = get_last_object_argument(call);\n\n\tif (!member || !effectful_handler_members.has(member.name) || !options) {\n\t\treturn;\n\t}\n\n\tfor (const handler of get_handler_properties(options)) {\n\t\tif (handler.callback && is_non_generator_callback_with_top_level_yield(handler.callback)) {\n\t\t\trewrite_callback_to_effect_gen(handler.callback, context);\n\t\t}\n\t}\n}\n\nfunction rewrite_effectful_callback_arguments(\n\tcall: ts.CallExpression,\n\tcontext: RewriteContext,\n): void {\n\tconst member = get_effect_member(call.expression, context);\n\n\tif (!member || !effectful_callback_members.has(member.name)) {\n\t\treturn;\n\t}\n\n\tfor (const argument of call.arguments) {\n\t\tif (\n\t\t\tis_callback_expression(argument) &&\n\t\t\tis_non_generator_callback_with_top_level_yield(argument)\n\t\t) {\n\t\t\trewrite_callback_to_effect_gen(argument, context);\n\t\t}\n\t}\n}\n\nfunction rewrite_callback_to_effect_gen(\n\tcallback: ts.ArrowFunction | ts.FunctionExpression,\n\tcontext: RewriteContext,\n): void {\n\tif (is_async_function(callback)) {\n\t\treturn;\n\t}\n\n\tif (ts.isArrowFunction(callback)) {\n\t\trewrite_arrow_callback(callback, \"gen\", context);\n\t\treturn;\n\t}\n\n\trewrite_function_body(callback, \"gen\", context);\n}\n\nfunction rewrite_callback_to_effect_sync(\n\tcallback: ts.ArrowFunction | ts.FunctionExpression,\n\tcontext: RewriteContext,\n): void {\n\tif (is_async_function(callback)) {\n\t\treturn;\n\t}\n\n\tif (ts.isArrowFunction(callback)) {\n\t\trewrite_arrow_callback(callback, \"sync\", context);\n\t\treturn;\n\t}\n\n\trewrite_function_body(callback, \"sync\", context);\n}\n\nfunction rewrite_arrow_callback(\n\tcallback: ts.ArrowFunction,\n\twrapper: EffectWrapperMember,\n\tcontext: RewriteContext,\n): void {\n\tconst start = to_expr_pos(callback.getStart(context.source_file), context);\n\tconst end = to_expr_pos(callback.end, context);\n\tconst params_text = context.source_text\n\t\t.slice(\n\t\t\tcallback.getStart(context.source_file),\n\t\t\tcallback.equalsGreaterThanToken.getStart(context.source_file),\n\t\t)\n\t\t.trim();\n\tconst body_text = get_body_text(callback.body, context);\n\tconst rewritten_body = make_effect_body(callback.body, body_text, wrapper, context);\n\tconst replacement = `${params_text} => ${rewritten_body}`;\n\n\tcontext.magic.overwrite(start, end, replacement);\n\tcontext.changed = true;\n}\n\nfunction rewrite_function_body(\n\tcallback: ts.FunctionExpression,\n\twrapper: EffectWrapperMember,\n\tcontext: RewriteContext,\n): void {\n\tconst body_start = to_expr_pos(callback.body.getStart(context.source_file), context);\n\tconst body_end = to_expr_pos(callback.body.end, context);\n\tconst body_text = get_body_text(callback.body, context);\n\tconst rewritten_body = make_effect_body(callback.body, body_text, wrapper, context);\n\n\tcontext.magic.overwrite(body_start, body_end, `{ return ${rewritten_body}; }`);\n\tcontext.changed = true;\n}\n\nfunction make_effect_body(\n\tbody: ts.ConciseBody,\n\tbody_text: string,\n\twrapper: EffectWrapperMember,\n\tcontext: RewriteContext,\n): string {\n\tconst wrapper_access = make_effect_access(wrapper, context);\n\n\tif (wrapper === \"gen\") {\n\t\tif (ts.isBlock(body)) {\n\t\t\treturn `${wrapper_access}(function* () ${body_text})`;\n\t\t}\n\n\t\treturn `${wrapper_access}(function* () { return (${body_text}); })`;\n\t}\n\n\tif (ts.isBlock(body)) {\n\t\treturn `${wrapper_access}(() => ${body_text})`;\n\t}\n\n\treturn `${wrapper_access}(() => (${body_text}))`;\n}\n\nfunction get_body_text(body: ts.ConciseBody, context: RewriteContext): string {\n\treturn context.source_text.slice(body.getStart(context.source_file), body.end).trim();\n}\n\nfunction get_handler_properties(object_literal: ts.ObjectLiteralExpression): Array<{\n\tcallback: ts.ArrowFunction | ts.FunctionExpression | undefined;\n}> {\n\treturn object_literal.properties.flatMap((property) => {\n\t\tif (!ts.isPropertyAssignment(property)) {\n\t\t\treturn [];\n\t\t}\n\n\t\tconst name = get_property_name(property.name);\n\n\t\tif (!name || !effectful_handler_property_names.has(name)) {\n\t\t\treturn [];\n\t\t}\n\n\t\tconst callback = is_callback_expression(property.initializer)\n\t\t\t? property.initializer\n\t\t\t: undefined;\n\n\t\treturn [{ callback }];\n\t});\n}\n\nfunction get_last_object_argument(call: ts.CallExpression): ts.ObjectLiteralExpression | undefined {\n\tconst last_argument = call.arguments[call.arguments.length - 1];\n\n\tif (!last_argument || !ts.isObjectLiteralExpression(last_argument)) {\n\t\treturn undefined;\n\t}\n\n\treturn last_argument;\n}\n\nfunction get_effect_member(\n\texpression: ts.Expression,\n\tcontext: RewriteContext,\n): EffectMember | undefined {\n\tif (ts.isIdentifier(expression)) {\n\t\tconst direct_member = context.bindings.direct_members.get(expression.text);\n\n\t\tif (!direct_member) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn {\n\t\t\tname: direct_member,\n\t\t\tname_start: to_expr_pos(expression.getStart(context.source_file), context),\n\t\t\tname_end: to_expr_pos(expression.end, context),\n\t\t\tdirect: true,\n\t\t};\n\t}\n\n\tif (!ts.isPropertyAccessExpression(expression)) {\n\t\treturn undefined;\n\t}\n\n\tif (!is_effect_namespace_expression(expression.expression, context)) {\n\t\treturn undefined;\n\t}\n\n\treturn {\n\t\tname: expression.name.text,\n\t\tname_start: to_expr_pos(expression.name.getStart(context.source_file), context),\n\t\tname_end: to_expr_pos(expression.name.end, context),\n\t\tdirect: false,\n\t};\n}\n\nfunction rewrite_effect_member_name(\n\tmember: EffectMember,\n\tupgraded_name: string,\n\tcontext: RewriteContext,\n): void {\n\tif (member.direct) {\n\t\tcontext.magic.overwrite(\n\t\t\tmember.name_start,\n\t\t\tmember.name_end,\n\t\t\tmake_effect_access(upgraded_name, context),\n\t\t);\n\n\t\treturn;\n\t}\n\n\tcontext.magic.overwrite(member.name_start, member.name_end, upgraded_name);\n}\n\nfunction make_effect_access(member_name: string, context: RewriteContext): string {\n\tcontext.uses_wrapper = true;\n\n\treturn `${context.bindings.wrapper_expression}.${member_name}`;\n}\n\nfunction is_effect_namespace_expression(\n\texpression: ts.Expression,\n\tcontext: RewriteContext,\n): boolean {\n\tif (ts.isIdentifier(expression)) {\n\t\treturn (\n\t\t\tcontext.bindings.effect_object_names.has(expression.text) ||\n\t\t\tcontext.bindings.effect_module_names.has(expression.text)\n\t\t);\n\t}\n\n\tif (!ts.isPropertyAccessExpression(expression)) {\n\t\treturn false;\n\t}\n\n\tif (expression.name.text !== \"Effect\") {\n\t\treturn false;\n\t}\n\n\tif (!ts.isIdentifier(expression.expression)) {\n\t\treturn false;\n\t}\n\n\treturn context.bindings.effect_package_names.has(expression.expression.text);\n}\n\nfunction get_property_name(name: ts.PropertyName): string | undefined {\n\tif (ts.isIdentifier(name) || ts.isStringLiteral(name)) {\n\t\treturn name.text;\n\t}\n\n\treturn undefined;\n}\n\nfunction is_callback_expression(node: ts.Node): node is ts.ArrowFunction | ts.FunctionExpression {\n\treturn ts.isArrowFunction(node) || ts.isFunctionExpression(node);\n}\n\nfunction is_non_generator_callback_with_top_level_yield(\n\tnode: ts.Node,\n): node is ts.ArrowFunction | ts.FunctionExpression {\n\tif (!is_callback_expression(node)) {\n\t\treturn false;\n\t}\n\n\tif (ts.isFunctionExpression(node) && node.asteriskToken) {\n\t\treturn false;\n\t}\n\n\treturn contains_top_level_yield_star(node.body);\n}\n\nfunction is_async_function(node: ts.ArrowFunction | ts.FunctionExpression): boolean {\n\treturn (\n\t\tnode.modifiers?.some((modifier) => modifier.kind === ts.SyntaxKind.AsyncKeyword) ?? false\n\t);\n}\n\nfunction to_expr_pos(pos: number, context: RewriteContext): number {\n\treturn pos - context.offset;\n}\n","import { AsyncEffectInEventCallbackError, YieldStarInEventCallbackError } from \"$/errors.ts\";\nimport type { EffectCallbackRewriteContext } from \"./effect-bindings.ts\";\nimport {\n\tanalyze_event_body_yield_star,\n\tcollect_free_identifiers,\n\tis_callback_function_expression,\n} from \"./expressions.ts\";\nimport { normalize_effect_callback_yields } from \"./effect-callbacks.ts\";\nimport type {\n\tHelperDeclaration,\n\tMarkupCandidate,\n\tMarkupHelperBindings,\n\tMarkupNameAllocator,\n\tMarkupTransformTarget,\n\tPendingRelocation,\n\tReplacement,\n\tTagKind,\n} from \"./types.ts\";\n\n/**\n * Emits source edits for classified markup Effect expressions.\n *\n * @since 2.0.0\n * @param classified - Candidates paired with their Svelte markup context.\n * @param effect_context - Effect import bindings available to markup\n * expression rewrites.\n * @returns Replacements ready to apply to the original component source.\n */\nexport function emit_replacements(\n\tclassified: Array<{ candidate: MarkupCandidate; kind: TagKind }>,\n\teffect_context: EffectCallbackRewriteContext,\n\thelper_bindings: MarkupHelperBindings,\n\tname_allocator: MarkupNameAllocator,\n\ttarget: MarkupTransformTarget,\n): Replacement[] {\n\treturn classified.map(({ candidate, kind }) =>\n\t\temit_replacement(candidate, kind, effect_context, helper_bindings, name_allocator, target),\n\t);\n}\n\nfunction emit_replacement(\n\tcandidate: MarkupCandidate,\n\tkind: TagKind,\n\teffect_context: EffectCallbackRewriteContext,\n\thelper_bindings: MarkupHelperBindings,\n\tname_allocator: MarkupNameAllocator,\n\ttarget: MarkupTransformTarget,\n): Replacement {\n\tconst normalized = normalize_effect_callback_yields(candidate.expr_text, effect_context);\n\tconst normalized_candidate = {\n\t\t...candidate,\n\t\texpr_text: normalized.expr_text,\n\t};\n\tconst id = make_cache_id(candidate);\n\tconst id_text = JSON.stringify(id);\n\tconst helper_name = make_helper_name(candidate, name_allocator);\n\tconst is_server_target = target === \"server\";\n\n\tlet replacement_text: string;\n\tlet helpers: HelperDeclaration[];\n\tlet relocation: PendingRelocation | undefined;\n\n\tif (kind === \"await\") {\n\t\tconst effect = make_effect_helper(normalized_candidate, helper_name);\n\n\t\treplacement_text = emit_promise_expression(\n\t\t\tid_text,\n\t\t\teffect,\n\t\t\thelper_bindings,\n\t\t\t\"undefined\",\n\t\t\t`{ ssr: \"pending\" }`,\n\t\t);\n\t\thelpers = [...normalized.helpers, effect.helper];\n\t} else if (kind === \"render\") {\n\t\tconst effect = make_effect_helper(normalized_candidate, helper_name);\n\n\t\treplacement_text = emit_render_expression(\n\t\t\tid_text,\n\t\t\teffect,\n\t\t\tcandidate,\n\t\t\thelper_bindings,\n\t\t\tis_server_target,\n\t\t);\n\t\thelpers = [...normalized.helpers, effect.helper];\n\t} else if (kind === \"render_argument\") {\n\t\tconst effect = make_effect_helper(normalized_candidate, helper_name);\n\n\t\treplacement_text = emit_await_expression(\n\t\t\tid_text,\n\t\t\teffect,\n\t\t\thelper_bindings,\n\t\t\tserver_fallback(is_server_target, \"undefined\"),\n\t\t);\n\t\thelpers = [...normalized.helpers, effect.helper];\n\t} else if (kind === \"each\") {\n\t\tconst effect = make_effect_helper(normalized_candidate, helper_name);\n\n\t\treplacement_text = emit_await_expression(\n\t\t\tid_text,\n\t\t\teffect,\n\t\t\thelper_bindings,\n\t\t\tserver_fallback(is_server_target, \"[]\"),\n\t\t);\n\t\thelpers = [...normalized.helpers, effect.helper];\n\t} else if (kind === \"event\") {\n\t\tconst event = make_event_handler(normalized_candidate, helper_bindings);\n\n\t\treplacement_text = event.text;\n\t\thelpers = normalized.helpers;\n\t\trelocation = make_relocation(candidate, replacement_text, {\n\t\t\toriginalStart: 0,\n\t\t\toriginalEnd: candidate.expr_text.length,\n\t\t\tgeneratedText: event.expr_text,\n\t\t});\n\t} else {\n\t\tconst effect = make_effect_helper(normalized_candidate, helper_name);\n\n\t\treplacement_text = emit_await_expression(\n\t\t\tid_text,\n\t\t\teffect,\n\t\t\thelper_bindings,\n\t\t\tserver_fallback(is_server_target, \"undefined\"),\n\t\t);\n\t\thelpers = [...normalized.helpers, effect.helper];\n\t}\n\n\treturn {\n\t\tstart: candidate.start,\n\t\tend: candidate.end,\n\t\ttext: replacement_text,\n\t\thelpers,\n\t\trelocation,\n\t};\n}\n\nfunction make_event_handler(\n\tcandidate: MarkupCandidate,\n\thelper_bindings: MarkupHelperBindings,\n): { text: string; expr_text: string } {\n\tconst expr_text = candidate.expr_text;\n\n\tif (is_callback_function_expression(expr_text)) {\n\t\tthrow new YieldStarInEventCallbackError(candidate.filename, expr_text);\n\t}\n\n\tconst analysis = analyze_event_body_yield_star(expr_text);\n\n\tif (analysis.has_nested_invalid_yield_star) {\n\t\tthrow new AsyncEffectInEventCallbackError(candidate.filename, expr_text);\n\t}\n\n\treturn {\n\t\texpr_text,\n\t\ttext: `(event) => { ${helper_bindings.dispatcher}.emit({ type: ${helper_bindings.codes}.Markup.Run, fn: function* () { ${expr_text}; } }); }`,\n\t};\n}\n\nfunction emit_promise_expression(\n\tid_text: string,\n\teffect: EffectHelper,\n\thelper_bindings: MarkupHelperBindings,\n\tssr_fallback?: string,\n\toptions?: string,\n): string {\n\tconst properties = [\n\t\t`type: ${helper_bindings.codes}.Markup.Promise`,\n\t\t`id: ${id_text}`,\n\t\t`deps: ${effect.deps_text}`,\n\t\t`fn: () => ${effect.call}`,\n\t\tssr_fallback !== undefined && `ssr_fallback: ${ssr_fallback}`,\n\t\toptions !== undefined && `options: ${options}`,\n\t].filter((property): property is string => property !== false);\n\n\treturn `${helper_bindings.dispatcher}.emit({ ${properties.join(\", \")} })`;\n}\n\nfunction emit_render_expression(\n\tid_text: string,\n\teffect: EffectHelper,\n\tcandidate: MarkupCandidate,\n\thelper_bindings: MarkupHelperBindings,\n\tis_server_target: boolean,\n): string {\n\tconst expression = emit_promise_expression(\n\t\tid_text,\n\t\teffect,\n\t\thelper_bindings,\n\t\tserver_fallback(is_server_target, `() => undefined`),\n\t);\n\n\tif (/^\\s*yield\\s*\\*/.test(candidate.expr_text)) {\n\t\treturn `(await ${expression})()`;\n\t}\n\n\treturn `await ${expression}`;\n}\n\nfunction emit_await_expression(\n\tid_text: string,\n\teffect: EffectHelper,\n\thelper_bindings: MarkupHelperBindings,\n\tssr_fallback?: string,\n): string {\n\treturn `await ${emit_promise_expression(id_text, effect, helper_bindings, ssr_fallback)}`;\n}\n\nfunction server_fallback(is_server_target: boolean, fallback: string): string | undefined {\n\treturn is_server_target ? fallback : undefined;\n}\n\ninterface EffectHelper {\n\thelper: HelperDeclaration;\n\tcall: string;\n\tdeps_text: string;\n}\n\nfunction make_effect_helper(candidate: MarkupCandidate, helper_name: string): EffectHelper {\n\tconst deps = collect_free_identifiers(candidate.expr_text);\n\tconst args_text = deps.join(\", \");\n\tconst deps_text = deps.length === 0 ? \"[]\" : `[${args_text}]`;\n\tconst call = `${helper_name}()`;\n\tconst text = `function* ${helper_name}() { return (${candidate.expr_text}); }`;\n\tconst generated_start = text.indexOf(candidate.expr_text);\n\n\treturn {\n\t\tcall,\n\t\tdeps_text,\n\t\thelper: {\n\t\t\ttext,\n\t\t\trelocation: {\n\t\t\t\toriginalStart: candidate.start,\n\t\t\t\toriginalEnd: candidate.end,\n\t\t\t\tgeneratedStartInReplacement: generated_start,\n\t\t\t\tgeneratedEndInReplacement: generated_start + candidate.expr_text.length,\n\t\t\t},\n\t\t},\n\t};\n}\n\nfunction make_cache_id(candidate: MarkupCandidate): string {\n\tconst normalized_filename = candidate.filename.replace(/[?#].*$/, \"\");\n\n\treturn `${normalized_filename}:${candidate.start}:${candidate.end}`;\n}\n\nfunction make_helper_name(candidate: MarkupCandidate, name_allocator: MarkupNameAllocator): string {\n\treturn name_allocator.reserve(`__SER___markup_effect_${candidate.start}_${candidate.end}`);\n}\n\nfunction make_relocation(\n\tcandidate: MarkupCandidate,\n\treplacement_text: string,\n\tinner: {\n\t\toriginalStart: number;\n\t\toriginalEnd: number;\n\t\tgeneratedText: string;\n\t},\n): PendingRelocation | undefined {\n\tconst generated_start = replacement_text.indexOf(inner.generatedText);\n\n\tif (generated_start === -1) {\n\t\treturn undefined;\n\t}\n\n\treturn {\n\t\toriginalStart: candidate.start + inner.originalStart,\n\t\toriginalEnd: candidate.start + inner.originalEnd,\n\t\tgeneratedStartInReplacement: generated_start,\n\t\tgeneratedEndInReplacement: generated_start + inner.generatedText.length,\n\t};\n}\n","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(magic: MagicString, filename: string): Record<string, unknown> {\n\tconst map = magic.generateMap({\n\t\thires: true,\n\t\tincludeContent: true,\n\t\tsource: filename,\n\t});\n\n\treturn 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\treturn 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\treturn content.slice(node.getStart(), node.end);\n}\n","import { contains_top_level_yield_star } from \"$/detect.ts\";\nimport { AsyncEffectInSyncRuneError } from \"$/errors.ts\";\nimport { slice } from \"./source.ts\";\n\nimport ts from \"typescript\";\n\nconst ASYNC_EXPRESSION_RUNES = new Set([\n\t\"$derived\",\n\t\"$state\",\n\t\"$state.raw\",\n\t\"$state.snapshot\",\n\t\"$bindable\",\n]);\n\nconst CALLBACK_RUNES = new Set([\"$derived.by\", \"$effect\", \"$effect.pre\", \"$effect.root\"]);\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(node: ts.Node, content: string, filename: string): void {\n\tvisit_rune_yield_usage(node, content, filename);\n}\n\nfunction visit_rune_yield_usage(node: ts.Node, content: string, filename: string): void {\n\tif (ts.isCallExpression(node)) {\n\t\tvalidate_call_expression(node, content, filename);\n\t}\n\n\tnode.forEachChild((child) => {\n\t\tvisit_rune_yield_usage(child, content, filename);\n\t});\n}\n\nfunction validate_call_expression(\n\tcall: ts.CallExpression,\n\tcontent: string,\n\tfilename: string,\n): void {\n\tconst rune_name = get_rune_name(call.expression);\n\n\tif (!rune_name) {\n\t\treturn;\n\t}\n\n\tif (!ASYNC_EXPRESSION_RUNES.has(rune_name) && contains_top_level_yield_star(call)) {\n\t\tthrow new AsyncEffectInSyncRuneError(rune_name, slice(content, call), filename);\n\t}\n\n\tif (!CALLBACK_RUNES.has(rune_name)) {\n\t\treturn;\n\t}\n\n\tconst callback = call.arguments[0];\n\n\tif (!callback || !callback_has_top_level_yield_star(callback)) {\n\t\treturn;\n\t}\n\n\tthrow new AsyncEffectInSyncRuneError(rune_name, slice(content, call), filename);\n}\n\nfunction callback_has_top_level_yield_star(node: ts.Expression): boolean {\n\tif ((ts.isArrowFunction(node) || ts.isFunctionExpression(node)) && node.body !== undefined) {\n\t\treturn contains_top_level_yield_star(node.body);\n\t}\n\n\treturn contains_top_level_yield_star(node);\n}\n\nfunction get_rune_name(expr: ts.Expression): string | undefined {\n\tif (ts.isIdentifier(expr) && is_rune_root(expr.text)) {\n\t\treturn expr.text;\n\t}\n\n\tif (!ts.isPropertyAccessExpression(expr)) {\n\t\treturn undefined;\n\t}\n\n\tconst root_name = get_rune_name(expr.expression);\n\n\tif (!root_name) {\n\t\treturn undefined;\n\t}\n\n\treturn `${root_name}.${expr.name.text}`;\n}\n\nfunction is_rune_root(name: string): boolean {\n\treturn (\n\t\tname === \"$bindable\" ||\n\t\tname === \"$derived\" ||\n\t\tname === \"$effect\" ||\n\t\tname === \"$host\" ||\n\t\tname === \"$inspect\" ||\n\t\tname === \"$props\" ||\n\t\tname === \"$state\"\n\t);\n}\n","import ts from \"typescript\";\n\n/**\n * Checks whether a node is a `yield*` binary expression.\n *\n * @since 2.0.0\n * @param node - TypeScript AST node to check.\n * @returns Whether the node represents `yield * operand`.\n */\nexport function is_yield_star_expression(node: ts.Node): boolean {\n\treturn (\n\t\tts.isBinaryExpression(node) &&\n\t\tnode.operatorToken.kind === ts.SyntaxKind.AsteriskToken &&\n\t\tts.isIdentifier(node.left) &&\n\t\tnode.left.text === \"yield\"\n\t);\n}\n\n/**\n * Checks whether a node owns its own yield semantics.\n *\n * @since 2.0.0\n * @param node - TypeScript AST node to check.\n * @returns Whether traversal should stop at this function boundary.\n */\nexport function is_function_boundary_node(node: ts.Node): boolean {\n\treturn (\n\t\tts.isArrowFunction(node) ||\n\t\tts.isFunctionDeclaration(node) ||\n\t\tts.isFunctionExpression(node) ||\n\t\tts.isMethodDeclaration(node) ||\n\t\tts.isGetAccessorDeclaration(node) ||\n\t\tts.isSetAccessorDeclaration(node)\n\t);\n}\n\n/**\n * Returns `true` if the node tree contains a top-level `await`.\n *\n * @since 2.0.0\n * @param node - Root node to search.\n * @returns Whether a top-level await expression was found.\n */\nexport function contains_top_level_await(node: ts.Node): boolean {\n\tif (ts.isAwaitExpression(node)) {\n\t\treturn true;\n\t}\n\n\treturn node\n\t\t.getChildren()\n\t\t.some((child) => !is_function_boundary_node(child) && contains_top_level_await(child));\n}\n\n/**\n * Collects top-level `yield*` nodes under an expression.\n *\n * @since 2.0.0\n * @param node - Root node to search.\n * @param on_found - Callback invoked for each matching yield node.\n * @returns Nothing.\n */\nexport function collect_yield_star_nodes(node: ts.Node, on_found: (node: ts.Node) => void): void {\n\tif (is_function_boundary_node(node)) {\n\t\treturn;\n\t}\n\n\tif (is_yield_star_expression(node)) {\n\t\ton_found(node);\n\t\treturn;\n\t}\n\n\tnode.forEachChild((child) => {\n\t\tcollect_yield_star_nodes(child, on_found);\n\t});\n}\n\n/**\n * Finds the first top-level `yield*` expression below a node.\n *\n * @since 2.0.0\n * @param node - Root node to search.\n * @param on_found - Callback invoked with the first matching node.\n * @returns Nothing.\n */\nexport function find_yield_star_node(node: ts.Node, on_found: (node: ts.Node) => void): void {\n\tif (is_function_boundary_node(node)) {\n\t\treturn;\n\t}\n\n\tif (is_yield_star_expression(node)) {\n\t\ton_found(node);\n\t\treturn;\n\t}\n\n\tnode.forEachChild((child) => {\n\t\tfind_yield_star_node(child, on_found);\n\t});\n}\n\n/**\n * Extracts identifier names from a TypeScript binding name.\n *\n * @since 2.0.0\n * @param name - Binding name node to flatten.\n * @returns Identifier names from identifiers and destructuring patterns.\n */\nexport function extract_binding_names(name: ts.BindingName): string[] {\n\tif (ts.isIdentifier(name)) {\n\t\treturn [name.text];\n\t}\n\n\tconst result: string[] = [];\n\n\tfor (const element of name.elements) {\n\t\tif (ts.isOmittedExpression(element)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tresult.push(...extract_binding_names(element.name));\n\t}\n\n\treturn result;\n}\n","import { validate_rune_yield_usage } from \"$/script-transform/runes.ts\";\nimport { collect_yield_star_nodes } from \"$/script-transform/ast.ts\";\nimport { contains_top_level_yield_star } from \"$/detect.ts\";\nimport { analyze_event_body_yield_star, strip_arrow_function } from \"./expressions.ts\";\nimport { HELPERS } from \"./constants.ts\";\nimport type { MarkupCandidate, TagKind } from \"./types.ts\";\n\nimport MagicString from \"magic-string\";\n\nimport ts from \"typescript\";\n\ninterface SanitizeResult {\n\tcode: string;\n\tcandidates: MarkupCandidate[];\n}\n\ninterface DeclarationYieldExpression {\n\tstart: number;\n\tend: number;\n\texpr_text: string;\n}\n\ninterface SourceRange {\n\tstart: number;\n\tend: number;\n}\n\n/**\n * Replaces markup `yield*` expressions with placeholders before Svelte parses\n * the component.\n *\n * @example\n * ```ts\n * const sanitized = sanitize_markup(\n * `<p>{yield* loadLabel()}</p>`,\n * \"Label.svelte\",\n * );\n * ```\n *\n * @since 2.0.0\n * @param content - Raw Svelte component source to scan for effectful markup\n * expressions.\n * @param filename - Source filename used when validation errors need to point\n * back to the component being transformed.\n * @returns Sanitized source plus placeholder candidates that should be lowered\n * after Svelte classifies their markup positions.\n */\nexport function sanitize_markup(content: string, filename: string): SanitizeResult {\n\tconst candidates: MarkupCandidate[] = [];\n\tconst excluded_ranges = collect_excluded_ranges(content);\n\tconst magic = new MagicString(content);\n\tlet helper_index = 0;\n\tlet cursor = 0;\n\n\twhile (cursor < content.length) {\n\t\tconst open = content.indexOf(\"{\", cursor);\n\t\tif (open === -1) break;\n\n\t\t/** Skip braces inside <script> and <style> blocks. */\n\t\tconst excluded_range = find_excluded_range(excluded_ranges, open);\n\n\t\tif (excluded_range) {\n\t\t\tcursor = excluded_range.end;\n\t\t\tcontinue;\n\t\t}\n\n\t\t/** Find the matching closing brace. */\n\t\tconst close = find_closing_brace(content, open + 1);\n\t\tif (close === -1) {\n\t\t\tcursor = open + 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst inner = content.slice(open + 1, close);\n\n\t\tconst trimmed = inner.trimStart();\n\t\tconst leading_ws = inner.length - trimmed.length;\n\n\t\tconst tag_info = get_tag_info(trimmed);\n\n\t\tconst declaration_yields = collect_declaration_yield_expressions(\n\t\t\tcontent,\n\t\t\topen,\n\t\t\tleading_ws,\n\t\t\ttrimmed,\n\t\t\tfilename,\n\t\t);\n\n\t\tif (declaration_yields.length > 0) {\n\t\t\tfor (const declaration_yield of declaration_yields) {\n\t\t\t\tconst placeholder = `__SER___markup_placeholder_${helper_index}`;\n\t\t\t\thelper_index += 1;\n\n\t\t\t\tcandidates.push({\n\t\t\t\t\tplaceholder,\n\t\t\t\t\tstart: declaration_yield.start,\n\t\t\t\t\tend: declaration_yield.end,\n\t\t\t\t\texpr_text: declaration_yield.expr_text,\n\t\t\t\t\tfilename,\n\t\t\t\t\tkey: \"plain\",\n\t\t\t\t});\n\n\t\t\t\tmagic.overwrite(declaration_yield.start, declaration_yield.end, placeholder);\n\t\t\t}\n\n\t\t\tcursor = close + 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tlet expr_body = trimmed.slice(tag_info.prefix_length);\n\n\t\t/** For @const, only use the RHS after `=` as the expression body. */\n\t\tconst equal_idx =\n\t\t\ttag_info.kind === \"plain\" && trimmed.startsWith(\"@const \")\n\t\t\t\t? expr_body.indexOf(\"=\")\n\t\t\t\t: -1;\n\n\t\t/** Check if this is a callback handler containing yield*. */\n\t\tconst is_event_callback = is_event_callback_expression(inner);\n\n\t\t/** Determine if this brace contains yield* that needs lowering. */\n\t\tconst event_yield = is_event_callback ? analyze_event_yield(inner) : undefined;\n\t\tconst has_yield =\n\t\t\tevent_yield?.has_top_level_yield_star ?? contains_yield_star_in_text(expr_body);\n\n\t\tif (!has_yield) {\n\t\t\tcursor = close + 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\t/** The expression starts after the tag prefix. For @const, after the `=`. */\n\t\tlet extra_prefix = 0;\n\n\t\tif (equal_idx !== -1) {\n\t\t\tconst after_eq_raw = expr_body.slice(equal_idx + 1);\n\t\t\texpr_body = after_eq_raw.trimStart();\n\t\t\textra_prefix = equal_idx + 1 + (after_eq_raw.length - expr_body.length);\n\t\t}\n\n\t\tconst expr_start = open + 1 + leading_ws + tag_info.prefix_length + extra_prefix;\n\n\t\t/** For each/await, the expression ends before ` as ` or ` then `/` catch `. */\n\t\tlet expr_end = close;\n\n\t\tconst key = tag_info.kind;\n\n\t\tif (key === \"each\") {\n\t\t\tconst as_idx = expr_body.lastIndexOf(\" as \");\n\t\t\tif (as_idx !== -1) expr_end = expr_start + as_idx;\n\t\t}\n\n\t\tif (key === \"await\") {\n\t\t\tconst then_idx = expr_body.indexOf(\" then \");\n\t\t\tconst catch_idx = expr_body.indexOf(\" catch \");\n\t\t\tconst boundary = Math.min(\n\t\t\t\tthen_idx === -1 ? Infinity : then_idx,\n\t\t\t\tcatch_idx === -1 ? Infinity : catch_idx,\n\t\t\t);\n\t\t\tif (boundary !== Infinity) expr_end = expr_start + boundary;\n\t\t}\n\n\t\tconst expr_text = content.slice(expr_start, expr_end).trim();\n\n\t\tif (expr_text.length === 0) {\n\t\t\tcursor = close + 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tvalidate_expression_yield_usage(expr_text, filename);\n\n\t\tif (key === \"render\" && !/^\\s*yield\\s*\\*/.test(expr_text)) {\n\t\t\tconst render_arg_yields = collect_expression_yield_expressions(\n\t\t\t\tcontent,\n\t\t\t\texpr_start,\n\t\t\t\texpr_text,\n\t\t\t\tfilename,\n\t\t\t);\n\n\t\t\tif (render_arg_yields.length > 0) {\n\t\t\t\tfor (const render_arg_yield of render_arg_yields) {\n\t\t\t\t\tconst placeholder = `__SER___markup_placeholder_${helper_index}`;\n\t\t\t\t\thelper_index += 1;\n\n\t\t\t\t\tcandidates.push({\n\t\t\t\t\t\tplaceholder,\n\t\t\t\t\t\tstart: render_arg_yield.start,\n\t\t\t\t\t\tend: render_arg_yield.end,\n\t\t\t\t\t\texpr_text: render_arg_yield.expr_text,\n\t\t\t\t\t\tfilename,\n\t\t\t\t\t\tkey: \"render_argument\",\n\t\t\t\t\t});\n\n\t\t\t\t\tmagic.overwrite(render_arg_yield.start, render_arg_yield.end, placeholder);\n\t\t\t\t}\n\n\t\t\t\tcursor = close + 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\n\t\t/** Create a placeholder and replace the expression (preserving tag prefixes). */\n\t\tconst placeholder = `__SER___markup_placeholder_${helper_index}`;\n\t\thelper_index += 1;\n\n\t\tcandidates.push({\n\t\t\tplaceholder,\n\t\t\tstart: expr_start,\n\t\t\tend: expr_end,\n\t\t\texpr_text,\n\t\t\tfilename,\n\t\t\tkey,\n\t\t});\n\n\t\tmagic.overwrite(expr_start, expr_end, key === \"render\" ? `${placeholder}()` : placeholder);\n\n\t\tcursor = close + 1;\n\t}\n\n\treturn { code: magic.toString(), candidates };\n}\n\nfunction collect_expression_yield_expressions(\n\tcontent: string,\n\texpr_start: number,\n\texpr_text: string,\n\tfilename: string,\n): DeclarationYieldExpression[] {\n\tconst source_file = ts.createSourceFile(\n\t\t\"markup-expression.ts\",\n\t\t`const __SER___expr = ${expr_text};`,\n\t\tts.ScriptTarget.Latest,\n\t\ttrue,\n\t\tts.ScriptKind.TS,\n\t);\n\tconst stmt = source_file.statements[0];\n\n\tif (!stmt || !ts.isVariableStatement(stmt)) {\n\t\treturn [];\n\t}\n\n\tvalidate_rune_yield_usage(stmt, source_file.text, filename);\n\n\tconst initializer = stmt.declarationList.declarations[0]?.initializer;\n\n\tif (!initializer || !contains_top_level_yield_star(initializer)) {\n\t\treturn [];\n\t}\n\n\tconst prefix_length = source_file.text.indexOf(expr_text);\n\tconst expressions: DeclarationYieldExpression[] = [];\n\n\tcollect_yield_star_nodes(initializer, (yield_node) => {\n\t\tconst start = expr_start + yield_node.getStart(source_file) - prefix_length;\n\t\tconst end = expr_start + yield_node.end - prefix_length;\n\t\tconst yielded_text = content.slice(start, end).trim();\n\n\t\texpressions.push({\n\t\t\tstart,\n\t\t\tend,\n\t\t\texpr_text: yielded_text,\n\t\t});\n\t});\n\n\treturn expressions;\n}\n\nfunction collect_excluded_ranges(content: string): SourceRange[] {\n\tconst ranges = [\n\t\t...collect_tag_ranges(content, \"script\"),\n\t\t...collect_tag_ranges(content, \"style\"),\n\t\t...collect_html_comment_ranges(content),\n\t];\n\n\tranges.sort((a, b) => a.start - b.start);\n\n\treturn merge_ranges(ranges);\n}\n\nfunction collect_tag_ranges(content: string, tag: string): SourceRange[] {\n\tconst pattern = new RegExp(`<${tag}\\\\b[^>]*>([\\\\s\\\\S]*?)<\\\\/${tag}\\\\s*>`, \"gi\");\n\n\treturn [...content.matchAll(pattern)].flatMap((match) => {\n\t\tif (match.index === undefined) {\n\t\t\treturn [];\n\t\t}\n\n\t\treturn [\n\t\t\t{\n\t\t\t\tstart: match.index,\n\t\t\t\tend: match.index + match[0].length,\n\t\t\t},\n\t\t];\n\t});\n}\n\nfunction collect_html_comment_ranges(content: string): SourceRange[] {\n\tconst ranges: SourceRange[] = [];\n\tlet cursor = 0;\n\n\twhile (cursor < content.length) {\n\t\tconst start = content.indexOf(\"<!--\", cursor);\n\n\t\tif (start === -1) {\n\t\t\tbreak;\n\t\t}\n\n\t\tconst close = content.indexOf(\"-->\", start + \"<!--\".length);\n\t\tconst end = close === -1 ? content.length : close + \"-->\".length;\n\n\t\tranges.push({ start, end });\n\n\t\tcursor = end;\n\t}\n\n\treturn ranges;\n}\n\nfunction merge_ranges(ranges: SourceRange[]): SourceRange[] {\n\tconst merged: SourceRange[] = [];\n\n\tfor (const range of ranges) {\n\t\tconst previous = merged.at(-1);\n\n\t\tif (!previous || range.start > previous.end) {\n\t\t\tmerged.push({ ...range });\n\t\t\tcontinue;\n\t\t}\n\n\t\tprevious.end = Math.max(previous.end, range.end);\n\t}\n\n\treturn merged;\n}\n\nfunction find_excluded_range(ranges: SourceRange[], pos: number): SourceRange | undefined {\n\tlet low = 0;\n\tlet high = ranges.length - 1;\n\n\twhile (low <= high) {\n\t\tconst mid = Math.floor((low + high) / 2);\n\t\tconst range = ranges[mid];\n\n\t\tif (pos <= range.start) {\n\t\t\thigh = mid - 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (pos >= range.end) {\n\t\t\tlow = mid + 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\treturn range;\n\t}\n\n\treturn undefined;\n}\n\n/** Brace matching helpers for extracting complete markup expressions. */\n\nfunction find_closing_brace(content: string, start: number): number {\n\tlet depth = 0;\n\n\tfor (let i = start; i < content.length; i += 1) {\n\t\tconst ch = content[i];\n\n\t\tif (ch === \"{\" && content[i - 1] !== \"$\") {\n\t\t\tdepth += 1;\n\t\t} else if (ch === \"}\") {\n\t\t\tif (depth === 0) return i;\n\t\t\tdepth -= 1;\n\t\t} else if (ch === \"'\" || ch === '\"' || ch === \"`\") {\n\t\t\ti = skip_string(content, i, ch);\n\t\t\tif (i === -1) return -1;\n\t\t} else if (ch === \"/\" && content[i + 1] === \"/\") {\n\t\t\ti = skip_line_comment(content, i);\n\t\t} else if (ch === \"/\" && content[i + 1] === \"*\") {\n\t\t\ti = skip_block_comment(content, i);\n\t\t\tif (i === -1) return -1;\n\t\t}\n\t}\n\n\treturn -1;\n}\n\nfunction skip_string(content: string, start: number, quote: string): number {\n\tfor (let i = start + 1; i < content.length; i += 1) {\n\t\tif (content[i] === \"\\\\\") {\n\t\t\ti += 1;\n\t\t\tcontinue;\n\t\t}\n\t\tif (content[i] === quote) return i;\n\t}\n\treturn -1;\n}\n\nfunction skip_line_comment(content: string, start: number): number {\n\tfor (let i = start + 2; i < content.length; i += 1) {\n\t\tif (content[i] === \"\\n\") return i;\n\t}\n\treturn content.length;\n}\n\nfunction skip_block_comment(content: string, start: number): number {\n\tfor (let i = start + 2; i < content.length; i += 1) {\n\t\tif (content[i] === \"*\" && content[i + 1] === \"/\") return i + 1;\n\t}\n\treturn -1;\n}\n\ninterface TagInfo {\n\tkind: TagKind;\n\tprefix_length: number;\n}\n\nfunction get_tag_info(trimmed: string): TagInfo {\n\tif (trimmed.startsWith(\"#each \")) {\n\t\treturn { kind: \"each\", prefix_length: \"#each \".length };\n\t}\n\tif (trimmed.startsWith(\"#await \")) {\n\t\treturn { kind: \"await\", prefix_length: \"#await \".length };\n\t}\n\tif (trimmed.startsWith(\"@render \")) {\n\t\treturn { kind: \"render\", prefix_length: \"@render \".length };\n\t}\n\n\t/** Strip prefix-only tags — the expression starts after the tag keyword. */\n\tif (trimmed.startsWith(\"#if \")) {\n\t\treturn { kind: \"plain\", prefix_length: \"#if \".length };\n\t}\n\tif (trimmed.startsWith(\":else if \")) {\n\t\treturn { kind: \"plain\", prefix_length: \":else if \".length };\n\t}\n\tif (trimmed.startsWith(\"#key \")) {\n\t\treturn { kind: \"plain\", prefix_length: \"#key \".length };\n\t}\n\tif (trimmed.startsWith(\"@const \")) {\n\t\treturn { kind: \"plain\", prefix_length: \"@const \".length };\n\t}\n\tif (trimmed.startsWith(\"@html \")) {\n\t\treturn { kind: \"plain\", prefix_length: \"@html \".length };\n\t}\n\tif (trimmed.startsWith(\"@debug \")) {\n\t\treturn { kind: \"plain\", prefix_length: \"@debug \".length };\n\t}\n\n\treturn { kind: \"plain\", prefix_length: 0 };\n}\n\nfunction collect_declaration_yield_expressions(\n\tcontent: string,\n\topen: number,\n\tleading_ws: number,\n\ttrimmed: string,\n\tfilename: string,\n): DeclarationYieldExpression[] {\n\tif (!is_declaration_tag_text(trimmed)) {\n\t\treturn [];\n\t}\n\n\tconst source_text = `${trimmed};`;\n\tconst source_file = ts.createSourceFile(\n\t\t\"declaration-tag.ts\",\n\t\tsource_text,\n\t\tts.ScriptTarget.Latest,\n\t\ttrue,\n\t\tts.ScriptKind.TS,\n\t);\n\n\tconst stmt = source_file.statements[0];\n\n\tif (!stmt || !ts.isVariableStatement(stmt)) {\n\t\treturn [];\n\t}\n\n\tvalidate_rune_yield_usage(stmt, source_text, filename);\n\n\tconst tag_start = open + 1 + leading_ws;\n\n\treturn stmt.declarationList.declarations.flatMap((decl) => {\n\t\tconst expressions: DeclarationYieldExpression[] = [];\n\n\t\tcollect_yield_star_nodes(decl, (yield_node) => {\n\t\t\tconst start = tag_start + yield_node.getStart(source_file);\n\t\t\tconst end = tag_start + yield_node.end;\n\t\t\tconst expr_text = content.slice(start, end).trim();\n\n\t\t\texpressions.push({\n\t\t\t\tstart,\n\t\t\t\tend,\n\t\t\t\texpr_text,\n\t\t\t});\n\t\t});\n\n\t\treturn expressions;\n\t});\n}\n\nfunction is_declaration_tag_text(trimmed: string): boolean {\n\treturn /^(?:const|let)\\s/.test(trimmed);\n}\n\nfunction validate_expression_yield_usage(expr_text: string, filename: string): void {\n\tconst source_text = `const __SER___expr = ${expr_text};`;\n\tconst source_file = ts.createSourceFile(\n\t\t\"markup-expression.ts\",\n\t\tsource_text,\n\t\tts.ScriptTarget.Latest,\n\t\ttrue,\n\t\tts.ScriptKind.TS,\n\t);\n\tconst stmt = source_file.statements[0];\n\n\tif (!stmt) {\n\t\treturn;\n\t}\n\n\tvalidate_rune_yield_usage(stmt, source_text, filename);\n}\n\nfunction is_event_callback_expression(inner: string): boolean {\n\tconst trimmed = inner.trimStart();\n\n\treturn (\n\t\t/^(?:async\\s+)?(?:\\([^)]*\\)|[A-Za-z_$][\\w$]*)\\s*=>/.test(trimmed) ||\n\t\t/^(?:async\\s+)?function\\b/.test(trimmed)\n\t);\n}\n\nfunction analyze_event_yield(inner: string): {\n\thas_top_level_yield_star: boolean;\n} {\n\tconst event = strip_arrow_function(inner);\n\tconst analysis = analyze_event_body_yield_star(event.body);\n\tconst generated_run = new RegExp(\n\t\t`${HELPERS.dispatcher}(?:_\\\\d+)?\\\\.emit\\\\(\\\\{\\\\s*type:\\\\s*${HELPERS.codes}(?:_\\\\d+)?\\\\.Markup\\\\.Run`,\n\t);\n\n\tif (generated_run.test(event.body)) {\n\t\treturn {\n\t\t\thas_top_level_yield_star: false,\n\t\t};\n\t}\n\n\treturn {\n\t\thas_top_level_yield_star:\n\t\t\tanalysis.has_top_level_yield_star ||\n\t\t\tanalysis.has_nested_invalid_yield_star ||\n\t\t\t/\\byield\\s*\\*/.test(event.body),\n\t};\n}\n\nfunction contains_yield_star_in_text(text: string): boolean {\n\tif (!/\\byield\\s*\\*/.test(text)) return false;\n\n\ttry {\n\t\tconst sf = ts.createSourceFile(\n\t\t\t\"expr.ts\",\n\t\t\t`const x = ${text};`,\n\t\t\tts.ScriptTarget.Latest,\n\t\t\ttrue,\n\t\t\tts.ScriptKind.TS,\n\t\t);\n\t\tconst stmt = sf.statements[0];\n\t\tif (!ts.isVariableStatement(stmt)) return false;\n\t\tconst decl = stmt.declarationList.declarations[0];\n\t\tif (!decl?.initializer) return false;\n\t\treturn contains_top_level_yield_star(decl.initializer);\n\t} catch {\n\t\treturn true;\n\t}\n}\n\n/** Free identifier collection helpers for generated closures. */\n","import {\n\tblank_script_blocks,\n\tcreate_relocations,\n\tcreate_source_map,\n\tinject_helpers,\n\tmake_markup_helper_bindings,\n} from \"./apply.ts\";\nimport type { MarkupTransformOptions, MarkupTransformResult } from \"./types.ts\";\nimport { collect_effect_callback_bindings } from \"./effect-bindings.ts\";\nimport { UnsupportedMarkupEffectPositionError } from \"$/errors.ts\";\nimport { classify_candidates } from \"./classify.ts\";\nimport { type AST, parse } from \"svelte/compiler\";\nimport { emit_replacements } from \"./emit.ts\";\nimport { sanitize_markup } from \"./scan.ts\";\n\nimport MagicString from \"magic-string\";\n\nexport type {\n\tMarkupRelocation,\n\tMarkupTransformOptions,\n\tMarkupTransformResult,\n\tMarkupTransformTarget,\n} from \"./types.ts\";\n\n/**\n * Transforms Svelte markup containing `{yield* expr}` brace expressions\n * into generated dispatcher events.\n *\n * Strategy: first find all brace expressions containing `yield*` via\n * character scanning, replace them with placeholder identifiers, then\n * parse the sanitized markup with Svelte's AST to determine the correct\n * context for each placeholder (plain expression, #each, #await, event\n * handler, etc.).\n *\n * @example\n * ```ts\n * const result = transform_markup_effect(\n * \"<button onclick={yield* save()}>Save</button>\",\n * \"SaveButton.svelte\",\n * );\n * ```\n *\n * @since 2.0.0\n * @param content - The raw `.svelte` file content.\n * @param filename - The source filename, used in error messages.\n * @param options - Optional transform target configuration.\n * @returns The transformed markup and a flag indicating whether yield* was\n * found.\n */\nexport function transform_markup_effect(\n\tcontent: string,\n\tfilename: string,\n\toptions: MarkupTransformOptions = {},\n): MarkupTransformResult {\n\tif (!/\\byield\\s*\\*/.test(content)) {\n\t\treturn { code: content, has_yield: false };\n\t}\n\n\t/** Find all brace expressions containing yield* and replace with placeholders. */\n\tconst work = sanitize_markup(content, filename);\n\tconst effect_context = collect_effect_callback_bindings(content);\n\tconst helper_context = make_markup_helper_bindings(content);\n\n\tif (work.candidates.length === 0) {\n\t\treturn { code: content, has_yield: false };\n\t}\n\n\t/** Parse the sanitized markup with Svelte's AST. Strip <script> blocks\n\t * first so TypeScript syntax (import type, etc.) doesn't break the parser. */\n\tconst clean = blank_script_blocks(work.code);\n\tconst ast = parse(clean, { filename, modern: true }) as AST.Root;\n\n\t/** Match placeholders to their AST context and build replacements. */\n\tconst classified = classify_candidates(ast, work.candidates);\n\tconst matched = new Set(classified.map(({ candidate }) => candidate.placeholder));\n\tconst unmatched = work.candidates.find((candidate) => !matched.has(candidate.placeholder));\n\n\tif (unmatched) {\n\t\tthrow new UnsupportedMarkupEffectPositionError(filename, unmatched.expr_text);\n\t}\n\n\tconst replacements = emit_replacements(\n\t\tclassified,\n\t\teffect_context,\n\t\thelper_context.bindings,\n\t\thelper_context.name_allocator,\n\t\toptions.target ?? \"client\",\n\t);\n\tconst helpers = replacements.flatMap((replacement) => replacement.helpers ?? []);\n\n\tconst magic = new MagicString(content);\n\n\treplacements.sort((a, b) => b.start - a.start);\n\n\tfor (const r of replacements) {\n\t\tmagic.overwrite(r.start, r.end, r.text);\n\t}\n\n\tconst helper_insertion = inject_helpers(magic, content, helpers, helper_context.bindings);\n\tconst relocations = create_relocations(replacements, helper_insertion);\n\n\treturn {\n\t\tcode: magic.toString(),\n\t\thas_yield: true,\n\t\tmap: create_source_map(magic, filename),\n\t\trelocations,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAsBA,SAAgB,aACf,mBACA,uBACA,oBACA,WAAkC;CACjC,QAAQ;CACR,YAAY;CACZ,kBAAkB;CAClB,QAAQ;CACR,SAAS;CACT,SAAS;AACV,GACA,UAAgC,CAAC,GACxB;CACT,MAAM,mBAAmB,QAAQ,oBAAoB;CACrD,MAAM,eAAe,QAAQ,gBAAgB;CAC7C,MAAM,gBAAgB,QAAQ,iBAAiB;CAE/C,MAAM,oBACL,SAAS,eAAe,m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
|
+
{"version":3,"file":"transform-CEK6Ccll.js","names":["create_source_map","is_yield_star_expression","create_source_map"],"sources":["../../../modules/svelte-effect-runtime/src/script-transform/imports.ts","../../../modules/svelte-effect-runtime/src/markup/transform/constants.ts","../../../modules/svelte-effect-runtime/src/markup/transform/apply.ts","../../../modules/svelte-effect-runtime/src/markup/transform/effect-bindings.ts","../../../modules/svelte-effect-runtime/src/markup/transform/classify.ts","../../../modules/svelte-effect-runtime/src/markup/transform/expressions.ts","../../../modules/svelte-effect-runtime/src/markup/transform/effect-callbacks.ts","../../../modules/svelte-effect-runtime/src/markup/transform/emit.ts","../../../modules/svelte-effect-runtime/src/script-transform/source.ts","../../../modules/svelte-effect-runtime/src/script-transform/runes.ts","../../../modules/svelte-effect-runtime/src/script-transform/ast.ts","../../../modules/svelte-effect-runtime/src/markup/transform/scan.ts","../../../modules/svelte-effect-runtime/src/markup/transform/index.ts"],"sourcesContent":["import type { RuntimeImportBindings } from \"./types.ts\";\n\nimport ts from \"typescript\";\n\ninterface RuntimeImportOptions {\n\tneeds_dispatcher?: boolean;\n\tneeds_effect?: boolean;\n\tneeds_untrack?: boolean;\n}\n\n/**\n * Builds the import statements injected by the script transform.\n *\n * @since 2.0.0\n * @param has_effect_import - Whether the user already imports `Effect`.\n * @param has_dispatcher_import - Whether the user already imports\n * `get_dispatcher`.\n * @param has_untrack_import - Whether the user already imports `untrack`.\n * @param bindings - Local names reserved for generated runtime helpers.\n * @param options - Runtime helper imports required by this transformed script.\n * @returns Newline-separated import statements to inject.\n */\nexport function make_imports(\n\thas_effect_import: boolean,\n\thas_dispatcher_import: boolean,\n\thas_untrack_import: boolean,\n\tbindings: RuntimeImportBindings = {\n\t\tcancel: \"__SER___cancel\",\n\t\tdispatcher: \"get_dispatcher\",\n\t\tdispatcher_value: \"__SER___dispatcher\",\n\t\teffect: \"Effect\",\n\t\tprogram: \"__SER___program\",\n\t\tuntrack: \"untrack\",\n\t},\n\toptions: RuntimeImportOptions = {},\n): string {\n\tconst needs_dispatcher = options.needs_dispatcher ?? true;\n\tconst needs_effect = options.needs_effect ?? true;\n\tconst needs_untrack = options.needs_untrack ?? true;\n\n\tconst dispatcher_import =\n\t\tbindings.dispatcher === \"get_dispatcher\"\n\t\t\t? `import { get_dispatcher } from \"svelte-effect-runtime/internal/generators\";`\n\t\t\t: `import { get_dispatcher as ${bindings.dispatcher} } from \"svelte-effect-runtime/internal/generators\";`;\n\n\tconst untrack_import =\n\t\tbindings.untrack === \"untrack\"\n\t\t\t? `import { untrack } from \"svelte\";`\n\t\t\t: `import { untrack as ${bindings.untrack} } from \"svelte\";`;\n\n\tconst effect_import = has_effect_import\n\t\t? false\n\t\t: bindings.effect === \"Effect\"\n\t\t\t? `import { Effect } from \"effect\";`\n\t\t\t: `import { Effect as ${bindings.effect} } from \"effect\";`;\n\n\treturn [\n\t\tneeds_dispatcher && !has_dispatcher_import && dispatcher_import,\n\t\tneeds_untrack && !has_untrack_import && untrack_import,\n\t\tneeds_effect && effect_import,\n\t]\n\t\t.filter(Boolean)\n\t\t.join(\"\\n\");\n}\n\n/**\n * Checks whether a source file imports a local binding from a module.\n *\n * @since 2.0.0\n * @param source_file - Parsed TypeScript source file to inspect.\n * @param module_name - Module specifier to match.\n * @param local_name - Local binding name to look for.\n * @returns Whether that binding is already locally available.\n */\nexport function has_local_import_binding(\n\tsource_file: ts.SourceFile,\n\tmodule_name: string,\n\tlocal_name: string,\n): boolean {\n\treturn source_file.statements.some((stmt) => {\n\t\tif (\n\t\t\t!ts.isImportDeclaration(stmt) ||\n\t\t\t!ts.isStringLiteral(stmt.moduleSpecifier) ||\n\t\t\tstmt.moduleSpecifier.text !== module_name\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst clause = stmt.importClause;\n\n\t\tif (!clause || clause.isTypeOnly) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (clause.name?.text === local_name) {\n\t\t\treturn true;\n\t\t}\n\n\t\tconst named_bindings = clause.namedBindings;\n\n\t\tif (!named_bindings) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (ts.isNamespaceImport(named_bindings)) {\n\t\t\treturn named_bindings.name.text === local_name;\n\t\t}\n\n\t\treturn named_bindings.elements.some(\n\t\t\t(element) => !element.isTypeOnly && element.name.text === local_name,\n\t\t);\n\t});\n}\n\n/**\n * Checks whether a source file already has any top-level binding with a local\n * name.\n *\n * @since 2.4.2\n * @param source_file - Parsed TypeScript source file to inspect.\n * @param local_name - Local binding name to look for.\n * @returns Whether that local name is already declared in the file.\n */\nexport function has_top_level_binding(source_file: ts.SourceFile, local_name: string): boolean {\n\treturn collect_top_level_binding_names(source_file).includes(local_name);\n}\n\n/**\n * Collects every local binding declared at module top level.\n *\n * @since 2.4.2\n * @param source_file - Parsed TypeScript source file to inspect.\n * @returns Top-level names declared by imports, declarations, and variables.\n */\nexport function collect_top_level_binding_names(source_file: ts.SourceFile): string[] {\n\treturn source_file.statements.flatMap(collect_statement_binding_names);\n}\n\nfunction collect_statement_binding_names(stmt: ts.Statement): string[] {\n\tif (ts.isImportDeclaration(stmt)) {\n\t\treturn collect_import_binding_names(stmt);\n\t}\n\n\tif (ts.isVariableStatement(stmt)) {\n\t\treturn stmt.declarationList.declarations.flatMap((decl) =>\n\t\t\tcollect_binding_name_text(decl.name),\n\t\t);\n\t}\n\n\tif (\n\t\tts.isFunctionDeclaration(stmt) ||\n\t\tts.isClassDeclaration(stmt) ||\n\t\tts.isInterfaceDeclaration(stmt) ||\n\t\tts.isTypeAliasDeclaration(stmt) ||\n\t\tts.isEnumDeclaration(stmt) ||\n\t\tts.isModuleDeclaration(stmt)\n\t) {\n\t\treturn stmt.name ? [stmt.name.text] : [];\n\t}\n\n\treturn [];\n}\n\nfunction collect_import_binding_names(stmt: ts.ImportDeclaration): string[] {\n\tconst clause = stmt.importClause;\n\n\tif (!clause) {\n\t\treturn [];\n\t}\n\n\treturn [\n\t\tclause.name?.text,\n\t\tclause.namedBindings && ts.isNamespaceImport(clause.namedBindings)\n\t\t\t? clause.namedBindings.name.text\n\t\t\t: undefined,\n\t\tclause.namedBindings && ts.isNamedImports(clause.namedBindings)\n\t\t\t? clause.namedBindings.elements.map((element) => element.name.text)\n\t\t\t: undefined,\n\t]\n\t\t.flat()\n\t\t.filter((name): name is string => name !== undefined);\n}\n\nfunction collect_binding_name_text(name: ts.BindingName): string[] {\n\tif (ts.isIdentifier(name)) {\n\t\treturn [name.text];\n\t}\n\n\treturn name.elements.flatMap((element) => {\n\t\tif (ts.isOmittedExpression(element)) {\n\t\t\treturn [];\n\t\t}\n\n\t\treturn collect_binding_name_text(element.name);\n\t});\n}\n","export const HELPERS = {\n\tcodes: \"Code\",\n\tdispatcher: \"Dispatcher\",\n} as const;\n","import type MagicString from \"magic-string\";\n\nimport { collect_top_level_binding_names } from \"$/script-transform/imports.ts\";\nimport { HELPERS } from \"./constants.ts\";\nimport type {\n\tHelperDeclaration,\n\tInsertion,\n\tMarkupHelperBindings,\n\tMarkupRelocation,\n\tPendingRelocation,\n\tReplacement,\n} from \"./types.ts\";\nimport ts from \"typescript\";\n\nexport function create_source_map(magic: MagicString, filename: string): Record<string, unknown> {\n\tconst map = magic.generateMap({\n\t\thires: true,\n\t\tincludeContent: true,\n\t\tsource: filename,\n\t});\n\n\treturn map as unknown as Record<string, unknown>;\n}\n\nexport function blank_script_blocks(content: string): string {\n\treturn content.replace(/<script\\b[^>]*>[\\s\\S]*?<\\/script\\s*>/gi, (match) => {\n\t\tconst lines = match.split(\"\\n\");\n\t\treturn lines.map((l) => \" \".repeat(l.length)).join(\"\\n\");\n\t});\n}\n\nexport function inject_helpers(\n\tmagic: MagicString,\n\tcontent: string,\n\thelpers: HelperDeclaration[] = [],\n\tbindings: MarkupHelperBindings = HELPERS,\n): Insertion | undefined {\n\tconst import_helpers = unique_import_helpers(helpers);\n\tconst local_helpers = helpers.filter((helper) => !is_import_helper(helper));\n\n\tconst helper_segments: Array<{\n\t\ttext: string;\n\t\trelocation?: PendingRelocation;\n\t}> = [\n\t\tmake_import_helper(content, make_dispatcher_import(bindings)),\n\t\t...import_helpers,\n\t\t...local_helpers,\n\t]\n\t\t.filter((helper): helper is string | HelperDeclaration => helper !== undefined)\n\t\t.map((helper) => (typeof helper === \"string\" ? { text: helper } : helper));\n\n\tif (helper_segments.length === 0) {\n\t\treturn undefined;\n\t}\n\n\tconst helper_block = helper_segments.map((segment) => segment.text).join(\"\\n\");\n\n\tconst script_tag = find_instance_script_tag(content);\n\n\tif (script_tag) {\n\t\tconst text = `\\n${helper_block}\\n`;\n\n\t\tmagic.appendLeft(script_tag.end, text);\n\n\t\treturn {\n\t\t\tstart: script_tag.end,\n\t\t\ttext,\n\t\t\trelocations: make_insertion_relocations(helper_segments, \"\\n\"),\n\t\t};\n\t} else {\n\t\tconst text = `<script>\\n${helper_block}\\n</script>\\n\\n`;\n\n\t\tmagic.prepend(text);\n\n\t\treturn {\n\t\t\tstart: 0,\n\t\t\ttext,\n\t\t\trelocations: make_insertion_relocations(helper_segments, \"<script>\\n\"),\n\t\t};\n\t}\n}\n\nexport function make_markup_helper_bindings(content: string): {\n\tbindings: MarkupHelperBindings;\n\tname_allocator: { reserve(name: string): string };\n} {\n\tconst script_tag = find_instance_script_tag(content);\n\tconst binding_names = script_tag\n\t\t? collect_script_binding_names(content.slice(script_tag.start, script_tag.end))\n\t\t: [];\n\tconst name_allocator = make_name_allocator(binding_names);\n\n\treturn {\n\t\tbindings: {\n\t\t\tcodes: name_allocator.reserve(HELPERS.codes),\n\t\t\tdispatcher: name_allocator.reserve(HELPERS.dispatcher),\n\t\t},\n\t\tname_allocator,\n\t};\n}\n\nexport function create_relocations(\n\treplacements: Replacement[],\n\thelper_insertion: Insertion | undefined,\n): MarkupRelocation[] {\n\tconst edits = [\n\t\thelper_insertion && {\n\t\t\tstart: helper_insertion.start,\n\t\t\tremovedLength: 0,\n\t\t\tinsertedLength: helper_insertion.text.length,\n\t\t},\n\t\t...replacements.map((replacement) => ({\n\t\t\tstart: replacement.start,\n\t\t\tremovedLength: replacement.end - replacement.start,\n\t\t\tinsertedLength: replacement.text.length,\n\t\t})),\n\t].filter(Boolean) as Array<{\n\t\tstart: number;\n\t\tremovedLength: number;\n\t\tinsertedLength: number;\n\t}>;\n\n\tconst replacement_relocations = replacements.flatMap((replacement) => {\n\t\tif (!replacement.relocation) {\n\t\t\treturn [];\n\t\t}\n\n\t\tconst delta_before = edits\n\t\t\t.filter((edit) => edit.start < replacement.start)\n\t\t\t.reduce((total, edit) => total + edit.insertedLength - edit.removedLength, 0);\n\t\tconst generated_start = replacement.start + delta_before;\n\n\t\treturn [\n\t\t\t{\n\t\t\t\toriginalStart: replacement.relocation.originalStart,\n\t\t\t\toriginalEnd: replacement.relocation.originalEnd,\n\t\t\t\tgeneratedStart:\n\t\t\t\t\tgenerated_start + replacement.relocation.generatedStartInReplacement,\n\t\t\t\tgeneratedEnd: generated_start + replacement.relocation.generatedEndInReplacement,\n\t\t\t},\n\t\t];\n\t});\n\n\tconst helper_relocations =\n\t\thelper_insertion?.relocations?.map((relocation) => ({\n\t\t\toriginalStart: relocation.originalStart,\n\t\t\toriginalEnd: relocation.originalEnd,\n\t\t\tgeneratedStart: helper_insertion.start + relocation.generatedStartInReplacement,\n\t\t\tgeneratedEnd: helper_insertion.start + relocation.generatedEndInReplacement,\n\t\t})) ?? [];\n\n\treturn [...replacement_relocations, ...helper_relocations];\n}\n\nfunction make_import_helper(content: string, import_text: string): string | undefined {\n\tif (content.includes(import_text)) {\n\t\treturn undefined;\n\t}\n\n\treturn import_text;\n}\n\nfunction make_dispatcher_import(bindings: MarkupHelperBindings): string {\n\tconst dispatcher = make_import_specifier(HELPERS.dispatcher, bindings.dispatcher);\n\tconst codes = make_import_specifier(HELPERS.codes, bindings.codes);\n\n\treturn `import { ${dispatcher}, ${codes} } from \"svelte-effect-runtime/internal/generators\";`;\n}\n\nfunction make_import_specifier(imported_name: string, local_name: string): string {\n\tif (imported_name === local_name) {\n\t\treturn imported_name;\n\t}\n\n\treturn `${imported_name} as ${local_name}`;\n}\n\nfunction make_insertion_relocations(\n\tsegments: Array<{\n\t\ttext: string;\n\t\trelocation?: PendingRelocation;\n\t}>,\n\tprefix: string,\n): PendingRelocation[] {\n\tconst relocations: PendingRelocation[] = [];\n\tlet offset = prefix.length;\n\n\tfor (const segment of segments) {\n\t\tif (segment.relocation) {\n\t\t\trelocations.push({\n\t\t\t\toriginalStart: segment.relocation.originalStart,\n\t\t\t\toriginalEnd: segment.relocation.originalEnd,\n\t\t\t\tgeneratedStartInReplacement:\n\t\t\t\t\toffset + segment.relocation.generatedStartInReplacement,\n\t\t\t\tgeneratedEndInReplacement: offset + segment.relocation.generatedEndInReplacement,\n\t\t\t});\n\t\t}\n\n\t\toffset += segment.text.length + 1;\n\t}\n\n\treturn relocations;\n}\n\nfunction find_instance_script_tag(content: string): { start: number; end: number } | undefined {\n\tconst pattern = /<script\\b([^>]*)>([\\s\\S]*?)<\\/script\\s*>/gi;\n\n\tfor (const match of content.matchAll(pattern)) {\n\t\tif (match.index === undefined) continue;\n\n\t\tconst attrs = match[1] ?? \"\";\n\t\tif (/\\bcontext\\s*=\\s*[\"']module[\"']/.test(attrs) || /\\bmodule\\b/.test(attrs)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst open_end = match[0].indexOf(\">\") + 1;\n\t\treturn {\n\t\t\tstart: match.index + open_end,\n\t\t\tend: match.index + match[0].length - \"</script>\".length,\n\t\t};\n\t}\n\n\treturn undefined;\n}\n\nfunction unique_import_helpers(helpers: HelperDeclaration[]): HelperDeclaration[] {\n\tconst seen = new Set<string>();\n\n\treturn helpers.filter((helper) => {\n\t\tif (!is_import_helper(helper)) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (seen.has(helper.text)) {\n\t\t\treturn false;\n\t\t}\n\n\t\tseen.add(helper.text);\n\n\t\treturn true;\n\t});\n}\n\nfunction is_import_helper(helper: HelperDeclaration): boolean {\n\treturn helper.text.trimStart().startsWith(\"import \");\n}\n\nfunction collect_script_binding_names(script_content: string): string[] {\n\tconst source_file = ts.createSourceFile(\n\t\t\"markup-script.ts\",\n\t\tscript_content,\n\t\tts.ScriptTarget.Latest,\n\t\ttrue,\n\t\tts.ScriptKind.TS,\n\t);\n\n\treturn collect_top_level_binding_names(source_file);\n}\n\nfunction make_name_allocator(initial_names: readonly string[]): {\n\treserve(name: string): string;\n} {\n\tconst used_names = new Set(initial_names);\n\n\treturn {\n\t\treserve(name: string): string {\n\t\t\tlet candidate = name;\n\t\t\tlet suffix = 1;\n\n\t\t\twhile (used_names.has(candidate)) {\n\t\t\t\tcandidate = `${name}_${suffix}`;\n\t\t\t\tsuffix += 1;\n\t\t\t}\n\n\t\t\tused_names.add(candidate);\n\n\t\t\treturn candidate;\n\t\t},\n\t};\n}\n","import type { HelperDeclaration } from \"./types.ts\";\n\nimport ts from \"typescript\";\n\nconst EFFECT_PACKAGE_MODULE = \"effect\";\nconst EFFECT_DIRECT_MODULE = \"effect/Effect\";\nconst GENERATED_EFFECT_NAME = \"__SER___Effect\";\n\n/**\n * Describes local bindings that resolve to Effect APIs in markup expressions.\n *\n * @example\n * ```ts\n * const context = collect_effect_callback_bindings(source);\n * context.effect_object_names.has(\"E\");\n * ```\n *\n * @since 2.4.0\n */\nexport interface EffectCallbackRewriteContext {\n\t/** Local names imported as the Effect object, such as `Effect` or `E`. */\n\teffect_object_names: ReadonlySet<string>;\n\t/** Namespace names imported from `effect/Effect`, such as `E.flatMap`. */\n\teffect_module_names: ReadonlySet<string>;\n\t/** Package namespace names imported from `effect`, such as `Fx.Effect`. */\n\teffect_package_names: ReadonlySet<string>;\n\t/** Direct `effect/Effect` imports mapped from local name to exported name. */\n\tdirect_members: ReadonlyMap<string, string>;\n\t/** Expression used for generated `gen`, `sync`, and upgraded direct calls. */\n\twrapper_expression: string;\n\t/** Import inserted when generated code needs a fresh Effect binding. */\n\twrapper_import: HelperDeclaration | undefined;\n}\n\ninterface EffectBindingState {\n\teffect_object_names: string[];\n\teffect_module_names: string[];\n\teffect_package_names: string[];\n\tdirect_members: Map<string, string>;\n\tlocal_names: Set<string>;\n\timplicit_effect_import: boolean;\n}\n\n/**\n * Collects Effect import bindings that markup callback rewriting can trust.\n *\n * @example\n * ```ts\n * const bindings = collect_effect_callback_bindings(\n * `<script>import { Effect as E } from \"effect\";</script>`,\n * );\n * ```\n *\n * @since 2.4.0\n * @param content - Full Svelte component source before markup lowering.\n * @returns Binding metadata used to identify Effect callback combinators.\n */\nexport function collect_effect_callback_bindings(content: string): EffectCallbackRewriteContext {\n\tconst state = make_effect_binding_state();\n\tconst scripts = collect_script_blocks(content);\n\n\tfor (const script of scripts) {\n\t\tconst source_file = ts.createSourceFile(\n\t\t\t\"component-script.ts\",\n\t\t\tscript,\n\t\t\tts.ScriptTarget.Latest,\n\t\t\ttrue,\n\t\t\tts.ScriptKind.TS,\n\t\t);\n\n\t\tcollect_source_file_bindings(source_file, state);\n\t}\n\n\tensure_implicit_effect_binding(state);\n\n\tconst wrapper = choose_effect_wrapper(state);\n\n\treturn {\n\t\teffect_object_names: new Set(state.effect_object_names),\n\t\teffect_module_names: new Set(state.effect_module_names),\n\t\teffect_package_names: new Set(state.effect_package_names),\n\t\tdirect_members: new Map(state.direct_members),\n\t\twrapper_expression: wrapper.expression,\n\t\twrapper_import: wrapper.import_text ? { text: wrapper.import_text } : undefined,\n\t};\n}\n\nfunction make_effect_binding_state(): EffectBindingState {\n\treturn {\n\t\teffect_object_names: [],\n\t\teffect_module_names: [],\n\t\teffect_package_names: [],\n\t\tdirect_members: new Map(),\n\t\tlocal_names: new Set(),\n\t\timplicit_effect_import: false,\n\t};\n}\n\nfunction collect_script_blocks(content: string): string[] {\n\tconst pattern = /<script\\b[^>]*>([\\s\\S]*?)<\\/script\\s*>/gi;\n\n\treturn [...content.matchAll(pattern)].map((match) => match[1] ?? \"\");\n}\n\nfunction collect_source_file_bindings(source_file: ts.SourceFile, state: EffectBindingState): void {\n\tfor (const statement of source_file.statements) {\n\t\tcollect_statement_binding(statement, state);\n\t}\n}\n\nfunction collect_statement_binding(statement: ts.Statement, state: EffectBindingState): void {\n\tif (ts.isImportDeclaration(statement)) {\n\t\tcollect_import_binding(statement, state);\n\t\treturn;\n\t}\n\n\tif (ts.isImportEqualsDeclaration(statement)) {\n\t\tstate.local_names.add(statement.name.text);\n\t\treturn;\n\t}\n\n\tif (ts.isVariableStatement(statement)) {\n\t\tfor (const declaration of statement.declarationList.declarations) {\n\t\t\tcollect_binding_name(declaration.name, state.local_names);\n\t\t}\n\n\t\treturn;\n\t}\n\n\tif (\n\t\tts.isFunctionDeclaration(statement) ||\n\t\tts.isClassDeclaration(statement) ||\n\t\tts.isInterfaceDeclaration(statement) ||\n\t\tts.isTypeAliasDeclaration(statement) ||\n\t\tts.isEnumDeclaration(statement) ||\n\t\tts.isModuleDeclaration(statement)\n\t) {\n\t\tif (statement.name) {\n\t\t\tstate.local_names.add(statement.name.text);\n\t\t}\n\t}\n}\n\nfunction collect_import_binding(statement: ts.ImportDeclaration, state: EffectBindingState): void {\n\tif (!ts.isStringLiteral(statement.moduleSpecifier)) {\n\t\treturn;\n\t}\n\n\tconst module_name = statement.moduleSpecifier.text;\n\tconst clause = statement.importClause;\n\n\tif (!clause) {\n\t\treturn;\n\t}\n\n\tif (clause.name) {\n\t\tstate.local_names.add(clause.name.text);\n\t}\n\n\tconst named_bindings = clause.namedBindings;\n\n\tif (!named_bindings) {\n\t\treturn;\n\t}\n\n\tif (ts.isNamespaceImport(named_bindings)) {\n\t\tcollect_namespace_import_binding(module_name, named_bindings.name.text, state);\n\t\treturn;\n\t}\n\n\tfor (const element of named_bindings.elements) {\n\t\tcollect_named_import_binding(module_name, element, state);\n\t}\n}\n\nfunction collect_namespace_import_binding(\n\tmodule_name: string,\n\tlocal_name: string,\n\tstate: EffectBindingState,\n): void {\n\tstate.local_names.add(local_name);\n\n\tif (module_name === EFFECT_DIRECT_MODULE) {\n\t\tadd_ordered_name(state.effect_module_names, local_name);\n\t\treturn;\n\t}\n\n\tif (module_name === EFFECT_PACKAGE_MODULE) {\n\t\tadd_ordered_name(state.effect_package_names, local_name);\n\t}\n}\n\nfunction collect_named_import_binding(\n\tmodule_name: string,\n\telement: ts.ImportSpecifier,\n\tstate: EffectBindingState,\n): void {\n\tconst imported_name = element.propertyName?.text ?? element.name.text;\n\tconst local_name = element.name.text;\n\n\tstate.local_names.add(local_name);\n\n\tif (module_name === EFFECT_PACKAGE_MODULE && imported_name === \"Effect\") {\n\t\tadd_ordered_name(state.effect_object_names, local_name);\n\t\treturn;\n\t}\n\n\tif (module_name === EFFECT_DIRECT_MODULE) {\n\t\tstate.direct_members.set(local_name, imported_name);\n\t}\n}\n\nfunction collect_binding_name(name: ts.BindingName, local_names: Set<string>): void {\n\tif (ts.isIdentifier(name)) {\n\t\tlocal_names.add(name.text);\n\t\treturn;\n\t}\n\n\tfor (const element of name.elements) {\n\t\tif (ts.isOmittedExpression(element)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tcollect_binding_name(element.name, local_names);\n\t}\n}\n\nfunction ensure_implicit_effect_binding(state: EffectBindingState): void {\n\tif (has_effect_binding(state) || state.local_names.has(\"Effect\")) {\n\t\treturn;\n\t}\n\n\tadd_ordered_name(state.effect_object_names, \"Effect\");\n\tstate.implicit_effect_import = true;\n}\n\nfunction has_effect_binding(state: EffectBindingState): boolean {\n\treturn (\n\t\tstate.effect_object_names.length > 0 ||\n\t\tstate.effect_module_names.length > 0 ||\n\t\tstate.effect_package_names.length > 0 ||\n\t\tstate.direct_members.size > 0\n\t);\n}\n\nfunction choose_effect_wrapper(state: EffectBindingState): {\n\texpression: string;\n\timport_text?: string;\n} {\n\tconst effect_object = state.effect_object_names[0];\n\n\tif (effect_object) {\n\t\treturn {\n\t\t\texpression: effect_object,\n\t\t\timport_text: state.implicit_effect_import\n\t\t\t\t? `import { Effect } from \"effect\";`\n\t\t\t\t: undefined,\n\t\t};\n\t}\n\n\tconst effect_module = state.effect_module_names[0];\n\n\tif (effect_module) {\n\t\treturn { expression: effect_module };\n\t}\n\n\tconst effect_package = state.effect_package_names[0];\n\n\tif (effect_package) {\n\t\treturn { expression: `${effect_package}.Effect` };\n\t}\n\n\tconst generated_name = make_generated_effect_name(state.local_names);\n\n\treturn {\n\t\texpression: generated_name,\n\t\timport_text: `import { Effect as ${generated_name} } from \"effect\";`,\n\t};\n}\n\nfunction make_generated_effect_name(local_names: ReadonlySet<string>): string {\n\tif (!local_names.has(GENERATED_EFFECT_NAME)) {\n\t\treturn GENERATED_EFFECT_NAME;\n\t}\n\n\tlet index = 1;\n\n\twhile (local_names.has(`${GENERATED_EFFECT_NAME}_${index}`)) {\n\t\tindex += 1;\n\t}\n\n\treturn `${GENERATED_EFFECT_NAME}_${index}`;\n}\n\nfunction add_ordered_name(names: string[], name: string): void {\n\tif (names.includes(name)) {\n\t\treturn;\n\t}\n\n\tnames.push(name);\n}\n","import type { AST } from \"svelte/compiler\";\n\nimport type { MarkupCandidate, TagKind } from \"./types.ts\";\n\n/**\n * Matches sanitized placeholders back to their Svelte AST context.\n *\n * @since 2.0.0\n * @param ast - Parsed Svelte AST for the sanitized component markup.\n * @param candidates - Placeholder candidates produced by the scanner.\n * @returns Candidates paired with the markup context that determines how they\n * should be emitted.\n */\nexport function classify_candidates(\n\tast: AST.Root,\n\tcandidates: MarkupCandidate[],\n): Array<{ candidate: MarkupCandidate; kind: TagKind }> {\n\tconst by_placeholder = new Map(\n\t\tcandidates.map((candidate) => [candidate.placeholder, candidate]),\n\t);\n\n\tconst classified: Array<{ candidate: MarkupCandidate; kind: TagKind }> = [];\n\tconst matched = new Set<string>();\n\n\twalk_ast(ast.fragment, by_placeholder, matched, classified);\n\n\treturn classified;\n}\n\nfunction walk_ast(\n\tfragment: AST.Fragment,\n\tcandidates: Map<string, MarkupCandidate>,\n\tmatched: Set<string>,\n\tclassified: Array<{ candidate: MarkupCandidate; kind: TagKind }>,\n): void {\n\tfor (const node of fragment.nodes) {\n\t\tvisit_ast_node(node, candidates, matched, classified);\n\t}\n}\n\nfunction visit_ast_node(\n\tnode: AST.Fragment[\"nodes\"][number],\n\tcandidates: Map<string, MarkupCandidate>,\n\tmatched: Set<string>,\n\tclassified: Array<{ candidate: MarkupCandidate; kind: TagKind }>,\n): void {\n\tswitch (node.type) {\n\t\tcase \"ExpressionTag\":\n\t\t\tclassify_expression(node.expression, \"plain\", candidates, matched, classified);\n\t\t\treturn;\n\n\t\tcase \"IfBlock\":\n\t\t\tclassify_expression(node.test, \"plain\", candidates, matched, classified);\n\t\t\twalk_ast(node.consequent, candidates, matched, classified);\n\t\t\tif (node.alternate) {\n\t\t\t\twalk_ast(node.alternate, candidates, matched, classified);\n\t\t\t}\n\t\t\treturn;\n\n\t\tcase \"EachBlock\":\n\t\t\tclassify_expression(node.expression, \"each\", candidates, matched, classified);\n\t\t\twalk_ast(node.body, candidates, matched, classified);\n\t\t\tif (node.fallback) {\n\t\t\t\twalk_ast(node.fallback, candidates, matched, classified);\n\t\t\t}\n\t\t\treturn;\n\n\t\tcase \"AwaitBlock\":\n\t\t\tclassify_expression(node.expression, \"await\", candidates, matched, classified);\n\t\t\tif (node.pending) {\n\t\t\t\twalk_ast(node.pending, candidates, matched, classified);\n\t\t\t}\n\t\t\tif (node.then) walk_ast(node.then, candidates, matched, classified);\n\t\t\tif (node.catch) walk_ast(node.catch, candidates, matched, classified);\n\t\t\treturn;\n\n\t\tcase \"RenderTag\":\n\t\t\tclassify_expression(node.expression, \"render\", candidates, matched, classified);\n\t\t\treturn;\n\n\t\tcase \"HtmlTag\":\n\t\t\tclassify_expression(node.expression, \"plain\", candidates, matched, classified);\n\t\t\treturn;\n\n\t\tcase \"DebugTag\":\n\t\t\tclassify_debug_tag(node, candidates, matched, classified);\n\t\t\treturn;\n\n\t\tcase \"ConstTag\":\n\t\tcase \"DeclarationTag\":\n\t\t\tclassify_declaration_tag(node, candidates, matched, classified);\n\t\t\treturn;\n\n\t\tcase \"KeyBlock\":\n\t\t\tclassify_expression(node.expression, \"plain\", candidates, matched, classified);\n\t\t\twalk_ast(node.fragment, candidates, matched, classified);\n\t\t\treturn;\n\n\t\tcase \"RegularElement\":\n\t\tcase \"Component\":\n\t\tcase \"TitleElement\":\n\t\tcase \"SlotElement\":\n\t\tcase \"SvelteBody\":\n\t\tcase \"SvelteBoundary\":\n\t\tcase \"SvelteComponent\":\n\t\tcase \"SvelteDocument\":\n\t\tcase \"SvelteElement\":\n\t\tcase \"SvelteFragment\":\n\t\tcase \"SvelteHead\":\n\t\tcase \"SvelteSelf\":\n\t\tcase \"SvelteWindow\":\n\t\t\tvisit_element_attributes(node, candidates, matched, classified);\n\t\t\twalk_ast(node.fragment, candidates, matched, classified);\n\t\t\treturn;\n\n\t\tdefault:\n\t\t\treturn;\n\t}\n}\n\nfunction classify_debug_tag(\n\t_node: Extract<AST.Fragment[\"nodes\"][number], { type: \"DebugTag\" }>,\n\t_candidates: Map<string, MarkupCandidate>,\n\t_matched: Set<string>,\n\t_classified: Array<{ candidate: MarkupCandidate; kind: TagKind }>,\n): void {\n\treturn;\n}\n\nfunction classify_declaration_tag(\n\tnode: Extract<AST.Fragment[\"nodes\"][number], { type: \"ConstTag\" | \"DeclarationTag\" }>,\n\tcandidates: Map<string, MarkupCandidate>,\n\tmatched: Set<string>,\n\tclassified: Array<{ candidate: MarkupCandidate; kind: TagKind }>,\n): void {\n\tfor (const decl of node.declaration.declarations) {\n\t\tclassify_expression(decl as ExpressionLike, \"plain\", candidates, matched, classified);\n\t}\n}\n\ninterface ElementLikeNode {\n\tattributes: Array<{\n\t\ttype: string;\n\t\tname?: string;\n\t\tvalue?: unknown;\n\t\texpression?: unknown;\n\t}>;\n\tfragment: AST.Fragment;\n}\n\nfunction visit_element_attributes(\n\tnode: ElementLikeNode,\n\tcandidates: Map<string, MarkupCandidate>,\n\tmatched: Set<string>,\n\tclassified: Array<{ candidate: MarkupCandidate; kind: TagKind }>,\n): void {\n\tfor (const attr of node.attributes) {\n\t\tif (attr.type === \"Attribute\" && attr.name && is_event_attribute_name(attr.name)) {\n\t\t\tvisit_attribute_value(\n\t\t\t\tattr.value as true | AST.ExpressionTag | Array<AST.Text | AST.ExpressionTag>,\n\t\t\t\t\"event\",\n\t\t\t\tcandidates,\n\t\t\t\tmatched,\n\t\t\t\tclassified,\n\t\t\t);\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (attr.type === \"OnDirective\" && attr.expression) {\n\t\t\tclassify_expression(\n\t\t\t\tattr.expression as ExpressionLike,\n\t\t\t\t\"event\",\n\t\t\t\tcandidates,\n\t\t\t\tmatched,\n\t\t\t\tclassified,\n\t\t\t);\n\t\t\tcontinue;\n\t\t}\n\t}\n}\n\nfunction is_event_attribute_name(name: string): boolean {\n\treturn name.startsWith(\"on:\") || /^on[a-z]/.test(name);\n}\n\nfunction visit_attribute_value(\n\tvalue: true | AST.ExpressionTag | Array<AST.Text | AST.ExpressionTag>,\n\tkind: TagKind,\n\tcandidates: Map<string, MarkupCandidate>,\n\tmatched: Set<string>,\n\tclassified: Array<{ candidate: MarkupCandidate; kind: TagKind }>,\n): void {\n\tif (value === true) {\n\t\treturn;\n\t}\n\n\tif (Array.isArray(value)) {\n\t\tfor (const part of value) {\n\t\t\tif (part.type === \"ExpressionTag\") {\n\t\t\t\tclassify_expression(part.expression, kind, candidates, matched, classified);\n\t\t\t}\n\t\t}\n\t\treturn;\n\t}\n\n\tclassify_expression(value.expression, kind, candidates, matched, classified);\n}\n\ntype ExpressionLike = {\n\ttype: string;\n\tname?: string;\n\tcallee?: { type: string; name?: string };\n};\n\nfunction classify_expression(\n\texpression: ExpressionLike | null | undefined,\n\tkind: TagKind,\n\tcandidates: Map<string, MarkupCandidate>,\n\tmatched: Set<string>,\n\tclassified: Array<{ candidate: MarkupCandidate; kind: TagKind }>,\n): void {\n\tif (!expression) {\n\t\treturn;\n\t}\n\n\tconst found_candidates = find_candidates(expression, candidates);\n\n\tfor (const candidate of found_candidates) {\n\t\tif (matched.has(candidate.placeholder)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tmatched.add(candidate.placeholder);\n\t\tclassified.push({\n\t\t\tcandidate,\n\t\t\tkind: resolve_candidate_kind(candidate, kind),\n\t\t});\n\t}\n}\n\nfunction resolve_candidate_kind(candidate: MarkupCandidate, context_kind: TagKind): TagKind {\n\tif (candidate.key === \"render_argument\") {\n\t\treturn \"render_argument\";\n\t}\n\n\treturn context_kind;\n}\n\nfunction find_candidates(\n\texpression: ExpressionLike,\n\tcandidates: Map<string, MarkupCandidate>,\n): MarkupCandidate[] {\n\tconst found: MarkupCandidate[] = [];\n\tconst seen_nodes = new Set<unknown>();\n\tconst seen_placeholders = new Set<string>();\n\n\tvisit_expression_value(expression, candidates, seen_nodes, seen_placeholders, found);\n\n\treturn found;\n}\n\nfunction visit_expression_value(\n\tvalue: unknown,\n\tcandidates: Map<string, MarkupCandidate>,\n\tseen_nodes: Set<unknown>,\n\tseen_placeholders: Set<string>,\n\tfound: MarkupCandidate[],\n): void {\n\tif (Array.isArray(value)) {\n\t\tfor (const item of value) {\n\t\t\tvisit_expression_value(item, candidates, seen_nodes, seen_placeholders, found);\n\t\t}\n\n\t\treturn;\n\t}\n\n\tif (!is_record(value) || seen_nodes.has(value)) {\n\t\treturn;\n\t}\n\n\tseen_nodes.add(value);\n\n\tif (value.type === \"Identifier\" && typeof value.name === \"string\") {\n\t\tconst candidate = candidates.get(value.name);\n\n\t\tif (candidate && !seen_placeholders.has(candidate.placeholder)) {\n\t\t\tseen_placeholders.add(candidate.placeholder);\n\t\t\tfound.push(candidate);\n\t\t}\n\t}\n\n\tfor (const child of Object.values(value)) {\n\t\tvisit_expression_value(child, candidates, seen_nodes, seen_placeholders, found);\n\t}\n}\n\nfunction is_record(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null;\n}\n","import ts from \"typescript\";\n\n/**\n * Strips an event handler arrow function down to its executable body.\n *\n * @since 2.0.0\n * @param expr - Event handler expression text from the original markup.\n * @returns Handler parameters, body text, and body offsets inside `expr`.\n */\nexport function strip_arrow_function(expr: string): {\n\tparams: string;\n\tbody: string;\n\tbody_start: number;\n\tbody_end: number;\n} {\n\tconst arrow_idx = expr.indexOf(\"=>\");\n\n\tif (arrow_idx === -1) {\n\t\treturn { params: \"()\", body: expr, body_start: 0, body_end: expr.length };\n\t}\n\n\tconst params = expr.slice(0, arrow_idx).trim();\n\tconst raw_body = expr.slice(arrow_idx + 2);\n\tconst leading_ws = raw_body.length - raw_body.trimStart().length;\n\tlet body_start = arrow_idx + 2 + leading_ws;\n\tlet body_end = expr.length - (raw_body.length - raw_body.trimEnd().length);\n\tlet body = expr.slice(body_start, body_end);\n\n\tif (body.startsWith(\"{\") && body.endsWith(\"}\")) {\n\t\tbody_start += 1;\n\t\tbody_end -= 1;\n\t\tbody = body.slice(1, -1);\n\t}\n\n\tconst body_leading_ws = body.length - body.trimStart().length;\n\tconst body_trailing_ws = body.length - body.trimEnd().length;\n\n\tbody_start += body_leading_ws;\n\tbody_end -= body_trailing_ws;\n\tbody = body.trim();\n\n\tif (body.endsWith(\";\")) {\n\t\tbody = body.slice(0, -1);\n\t\tbody_end -= 1;\n\t}\n\n\treturn { params, body, body_start, body_end };\n}\n\n/**\n * Returns whether an expression is a callback function.\n *\n * @since 2.0.0\n * @param expr - Expression text from a markup attribute or expression tag.\n * @returns Whether the expression parses as an arrow or function expression.\n */\nexport function is_callback_function_expression(expr: string): boolean {\n\tconst wrapped = `const __SER___callback = ${expr};`;\n\tconst sf = ts.createSourceFile(\n\t\t\"callback.ts\",\n\t\twrapped,\n\t\tts.ScriptTarget.Latest,\n\t\ttrue,\n\t\tts.ScriptKind.TS,\n\t);\n\tconst stmt = sf.statements[0];\n\n\tif (!ts.isVariableStatement(stmt)) {\n\t\treturn false;\n\t}\n\n\tconst initializer = stmt.declarationList.declarations[0]?.initializer;\n\n\treturn (\n\t\tinitializer !== undefined &&\n\t\t(ts.isArrowFunction(initializer) || ts.isFunctionExpression(initializer))\n\t);\n}\n\n/**\n * Classifies `yield*` placement inside an event handler body.\n *\n * @example\n * ```ts\n * analyze_event_body_yield_star(\"yield* save()\");\n * ```\n *\n * @since 2.0.0\n * @param body - Event handler body text after the outer arrow has been\n * stripped.\n * @returns Whether the body has top-level yield* expressions and whether any\n * yield* appears inside a nested non-generator callback.\n */\nexport function analyze_event_body_yield_star(body: string): {\n\thas_top_level_yield_star: boolean;\n\thas_nested_invalid_yield_star: boolean;\n} {\n\tconst wrapped = `function* __SER___event() { ${body}; }`;\n\tconst sf = ts.createSourceFile(\n\t\t\"event.ts\",\n\t\twrapped,\n\t\tts.ScriptTarget.Latest,\n\t\ttrue,\n\t\tts.ScriptKind.TS,\n\t);\n\tconst stmt = sf.statements[0];\n\n\tif (!ts.isFunctionDeclaration(stmt) || !stmt.body) {\n\t\treturn {\n\t\t\thas_top_level_yield_star: false,\n\t\t\thas_nested_invalid_yield_star: /\\byield\\s*\\*/.test(body),\n\t\t};\n\t}\n\n\tconst result = {\n\t\thas_top_level_yield_star: false,\n\t\thas_nested_invalid_yield_star: false,\n\t};\n\n\tvisit_event_body(stmt.body, \"top_level\", result);\n\n\treturn result;\n}\n\n/**\n * Collects free identifiers that must be captured as reactive dependencies.\n *\n * @since 2.0.0\n * @param expr_text - Markup expression text to inspect.\n * @returns Identifier names referenced by the expression.\n */\nexport function collect_free_identifiers(expr_text: string): string[] {\n\tconst wrapped = `function* __SER___w() { return (${expr_text}); }`;\n\tlet sf: ts.SourceFile;\n\n\ttry {\n\t\tsf = ts.createSourceFile(\n\t\t\t\"expr.ts\",\n\t\t\twrapped,\n\t\t\tts.ScriptTarget.Latest,\n\t\t\ttrue,\n\t\t\tts.ScriptKind.TS,\n\t\t);\n\t} catch {\n\t\treturn [];\n\t}\n\n\tconst fn = sf.statements[0];\n\n\tif (!ts.isFunctionDeclaration(fn) || !fn.body) {\n\t\treturn [];\n\t}\n\n\tconst ids: string[] = [];\n\tconst locals = new Set<string>();\n\tconst seen = new Set<string>();\n\n\tvisit_ids(fn.body, locals, seen, ids);\n\n\treturn ids;\n}\n\nfunction visit_ids(node: ts.Node, locals: Set<string>, seen: Set<string>, ids: string[]): void {\n\tif (\n\t\tts.isArrowFunction(node) ||\n\t\tts.isFunctionExpression(node) ||\n\t\tts.isFunctionDeclaration(node)\n\t) {\n\t\tconst scoped = new Set(locals);\n\n\t\tif (ts.isFunctionDeclaration(node) && node.name) {\n\t\t\tscoped.add(node.name.text);\n\t\t}\n\n\t\tfor (const parameter of node.parameters) {\n\t\t\tadd_binding_names(parameter.name, scoped);\n\t\t}\n\n\t\tif (node.body) {\n\t\t\tvisit_ids(node.body, scoped, seen, ids);\n\t\t}\n\n\t\treturn;\n\t}\n\n\tif (ts.isVariableDeclaration(node)) {\n\t\tif (node.initializer) {\n\t\t\tvisit_ids(node.initializer, locals, seen, ids);\n\t\t}\n\n\t\tadd_binding_names(node.name, locals);\n\n\t\treturn;\n\t}\n\n\tif (ts.isTypeReferenceNode(node)) {\n\t\treturn;\n\t}\n\n\tif (ts.isIdentifier(node)) {\n\t\tif (\n\t\t\tnode.text === \"yield\" ||\n\t\t\tnode.text === \"undefined\" ||\n\t\t\tnode.text === \"null\" ||\n\t\t\tnode.text === \"true\" ||\n\t\t\tnode.text === \"false\" ||\n\t\t\tnode.text === \"this\"\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (is_property_access_name(node)) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (!locals.has(node.text) && !seen.has(node.text)) {\n\t\t\tseen.add(node.text);\n\t\t\tids.push(node.text);\n\t\t}\n\t\treturn;\n\t}\n\n\tnode.forEachChild((child) => visit_ids(child, locals, seen, ids));\n}\n\nfunction add_binding_names(name: ts.BindingName, locals: Set<string>): void {\n\tif (ts.isIdentifier(name)) {\n\t\tlocals.add(name.text);\n\t\treturn;\n\t}\n\n\tfor (const element of name.elements) {\n\t\tif (ts.isOmittedExpression(element)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tadd_binding_names(element.name, locals);\n\t}\n}\n\ntype EventYieldContext = \"top_level\" | \"nested_generator\" | \"nested_invalid\";\n\ninterface EventYieldAnalysis {\n\thas_top_level_yield_star: boolean;\n\thas_nested_invalid_yield_star: boolean;\n}\n\nfunction visit_event_body(\n\tnode: ts.Node,\n\tcontext: EventYieldContext,\n\tresult: EventYieldAnalysis,\n): void {\n\tif (is_yield_star_expression(node)) {\n\t\tif (context === \"top_level\") {\n\t\t\tresult.has_top_level_yield_star = true;\n\t\t} else if (context === \"nested_invalid\") {\n\t\t\tresult.has_nested_invalid_yield_star = true;\n\t\t}\n\n\t\tnode.forEachChild((child) => visit_event_body(child, context, result));\n\t\treturn;\n\t}\n\n\tif (is_nested_function_boundary(node)) {\n\t\tconst next_context = is_generator_function_boundary(node)\n\t\t\t? \"nested_generator\"\n\t\t\t: \"nested_invalid\";\n\n\t\tnode.forEachChild((child) => visit_event_body(child, next_context, result));\n\t\treturn;\n\t}\n\n\tnode.forEachChild((child) => visit_event_body(child, context, result));\n}\n\nfunction is_nested_function_boundary(node: ts.Node): boolean {\n\treturn (\n\t\tts.isArrowFunction(node) ||\n\t\tts.isFunctionExpression(node) ||\n\t\tts.isFunctionDeclaration(node) ||\n\t\tts.isMethodDeclaration(node) ||\n\t\tts.isGetAccessorDeclaration(node) ||\n\t\tts.isSetAccessorDeclaration(node)\n\t);\n}\n\nfunction is_generator_function_boundary(node: ts.Node): boolean {\n\treturn (\n\t\t(ts.isFunctionExpression(node) ||\n\t\t\tts.isFunctionDeclaration(node) ||\n\t\t\tts.isMethodDeclaration(node)) &&\n\t\tnode.asteriskToken !== undefined\n\t);\n}\n\nfunction is_yield_star_expression(node: ts.Node): boolean {\n\tif (ts.isYieldExpression(node)) {\n\t\treturn node.asteriskToken !== undefined;\n\t}\n\n\treturn (\n\t\tts.isBinaryExpression(node) &&\n\t\tnode.operatorToken.kind === ts.SyntaxKind.AsteriskToken &&\n\t\tts.isIdentifier(node.left) &&\n\t\tnode.left.text === \"yield\"\n\t);\n}\n\nfunction is_property_access_name(node: ts.Identifier): boolean {\n\tconst parent = node.parent;\n\n\treturn (\n\t\t(ts.isPropertyAccessExpression(parent) && parent.name === node) ||\n\t\t(ts.isPropertyAssignment(parent) && parent.name === node) ||\n\t\t(ts.isBindingElement(parent) && parent.propertyName === node) ||\n\t\tts.isImportSpecifier(parent) ||\n\t\tts.isExportSpecifier(parent)\n\t);\n}\n","import { contains_top_level_yield_star } from \"$/detect.ts\";\nimport type { EffectCallbackRewriteContext } from \"./effect-bindings.ts\";\nimport type { HelperDeclaration } from \"./types.ts\";\n\nimport MagicString from \"magic-string\";\nimport ts from \"typescript\";\n\nconst match_effect_members = new Map([\n\t[\"match\", \"matchEffect\"],\n\t[\"matchCause\", \"matchCauseEffect\"],\n]);\n\nconst effectful_callback_members = new Set([\n\t\"andThen\",\n\t\"catchAll\",\n\t\"catchAllCause\",\n\t\"catchCause\",\n\t\"catchTag\",\n\t\"flatMap\",\n\t\"forEach\",\n\t\"tap\",\n\t\"tapError\",\n\t\"tapErrorCause\",\n]);\n\nconst effectful_handler_members = new Set([\"matchCauseEffect\", \"matchEffect\", \"tapBoth\"]);\n\nconst effectful_handler_property_names = new Set([\"onFailure\", \"onSuccess\"]);\n\ninterface RewriteContext {\n\tsource_file: ts.SourceFile;\n\tsource_text: string;\n\tmagic: MagicString;\n\toffset: number;\n\tbindings: EffectCallbackRewriteContext;\n\tchanged: boolean;\n\tuses_wrapper: boolean;\n}\n\ninterface EffectMember {\n\tname: string;\n\tname_start: number;\n\tname_end: number;\n\tdirect: boolean;\n}\n\ntype EffectWrapperMember = \"gen\" | \"sync\";\n\n/**\n * Rewrites effectful callback shorthand inside event handler expressions.\n *\n * @example\n * ```ts\n * normalize_effect_callback_yields(\n * `yield* action.pipe(Effect.flatMap((value) => yield* next(value)))`,\n * collect_effect_callback_bindings(source),\n * );\n * ```\n *\n * @since 2.0.0\n * @param expr_text - Markup expression text before it is wrapped in the\n * generated Effect runner.\n * @param bindings - Local Effect import bindings collected from the Svelte\n * component's script blocks.\n * @returns The expression with nested Effect callback `yield*` shorthand\n * lowered into explicit Effect callbacks, plus any import needed by generated\n * wrapper calls.\n */\nexport function normalize_effect_callback_yields(\n\texpr_text: string,\n\tbindings: EffectCallbackRewriteContext,\n): { expr_text: string; helpers: HelperDeclaration[] } {\n\tconst prefix = \"const __SER___expression = \";\n\tconst source_text = `${prefix}${expr_text};`;\n\tconst source_file = ts.createSourceFile(\n\t\t\"event-expression.ts\",\n\t\tsource_text,\n\t\tts.ScriptTarget.Latest,\n\t\ttrue,\n\t\tts.ScriptKind.TS,\n\t);\n\tconst statement = source_file.statements[0];\n\tconst magic = new MagicString(expr_text);\n\tconst context: RewriteContext = {\n\t\tsource_file,\n\t\tsource_text,\n\t\tmagic,\n\t\toffset: prefix.length,\n\t\tbindings,\n\t\tchanged: false,\n\t\tuses_wrapper: false,\n\t};\n\n\tif (!ts.isVariableStatement(statement)) {\n\t\treturn { expr_text, helpers: [] };\n\t}\n\n\tconst expression = statement.declarationList.declarations[0]?.initializer;\n\n\tif (!expression) {\n\t\treturn { expr_text, helpers: [] };\n\t}\n\n\tvisit_expression(expression, context);\n\n\tif (!context.changed) {\n\t\treturn { expr_text, helpers: [] };\n\t}\n\n\tconst helpers =\n\t\tcontext.uses_wrapper && bindings.wrapper_import ? [bindings.wrapper_import] : [];\n\n\treturn {\n\t\texpr_text: magic.toString(),\n\t\thelpers,\n\t};\n}\n\nfunction visit_expression(node: ts.Node, context: RewriteContext): void {\n\tif (is_non_generator_callback_with_top_level_yield(node)) {\n\t\treturn;\n\t}\n\n\tif (ts.isCallExpression(node)) {\n\t\trewrite_match_call(node, context);\n\t\trewrite_effectful_handler_call(node, context);\n\t\trewrite_effectful_callback_arguments(node, context);\n\t}\n\n\tnode.forEachChild((child) => {\n\t\tvisit_expression(child, context);\n\t});\n}\n\nfunction rewrite_match_call(call: ts.CallExpression, context: RewriteContext): void {\n\tconst member = get_effect_member(call.expression, context);\n\tconst upgraded_name = member && match_effect_members.get(member.name);\n\tconst options = get_last_object_argument(call);\n\n\tif (!member || !upgraded_name || !options) {\n\t\treturn;\n\t}\n\n\tconst handlers = get_handler_properties(options);\n\tconst should_upgrade = handlers.some(\n\t\t(handler) =>\n\t\t\thandler.callback && is_non_generator_callback_with_top_level_yield(handler.callback),\n\t);\n\n\tif (!should_upgrade) {\n\t\treturn;\n\t}\n\n\trewrite_effect_member_name(member, upgraded_name, context);\n\tcontext.changed = true;\n\n\tfor (const handler of handlers) {\n\t\tif (!handler.callback) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (is_non_generator_callback_with_top_level_yield(handler.callback)) {\n\t\t\trewrite_callback_to_effect_gen(handler.callback, context);\n\t\t} else {\n\t\t\trewrite_callback_to_effect_sync(handler.callback, context);\n\t\t}\n\t}\n}\n\nfunction rewrite_effectful_handler_call(call: ts.CallExpression, context: RewriteContext): void {\n\tconst member = get_effect_member(call.expression, context);\n\tconst options = get_last_object_argument(call);\n\n\tif (!member || !effectful_handler_members.has(member.name) || !options) {\n\t\treturn;\n\t}\n\n\tfor (const handler of get_handler_properties(options)) {\n\t\tif (handler.callback && is_non_generator_callback_with_top_level_yield(handler.callback)) {\n\t\t\trewrite_callback_to_effect_gen(handler.callback, context);\n\t\t}\n\t}\n}\n\nfunction rewrite_effectful_callback_arguments(\n\tcall: ts.CallExpression,\n\tcontext: RewriteContext,\n): void {\n\tconst member = get_effect_member(call.expression, context);\n\n\tif (!member || !effectful_callback_members.has(member.name)) {\n\t\treturn;\n\t}\n\n\tfor (const argument of call.arguments) {\n\t\tif (\n\t\t\tis_callback_expression(argument) &&\n\t\t\tis_non_generator_callback_with_top_level_yield(argument)\n\t\t) {\n\t\t\trewrite_callback_to_effect_gen(argument, context);\n\t\t}\n\t}\n}\n\nfunction rewrite_callback_to_effect_gen(\n\tcallback: ts.ArrowFunction | ts.FunctionExpression,\n\tcontext: RewriteContext,\n): void {\n\tif (is_async_function(callback)) {\n\t\treturn;\n\t}\n\n\tif (ts.isArrowFunction(callback)) {\n\t\trewrite_arrow_callback(callback, \"gen\", context);\n\t\treturn;\n\t}\n\n\trewrite_function_body(callback, \"gen\", context);\n}\n\nfunction rewrite_callback_to_effect_sync(\n\tcallback: ts.ArrowFunction | ts.FunctionExpression,\n\tcontext: RewriteContext,\n): void {\n\tif (is_async_function(callback)) {\n\t\treturn;\n\t}\n\n\tif (ts.isArrowFunction(callback)) {\n\t\trewrite_arrow_callback(callback, \"sync\", context);\n\t\treturn;\n\t}\n\n\trewrite_function_body(callback, \"sync\", context);\n}\n\nfunction rewrite_arrow_callback(\n\tcallback: ts.ArrowFunction,\n\twrapper: EffectWrapperMember,\n\tcontext: RewriteContext,\n): void {\n\tconst start = to_expr_pos(callback.getStart(context.source_file), context);\n\tconst end = to_expr_pos(callback.end, context);\n\tconst params_text = context.source_text\n\t\t.slice(\n\t\t\tcallback.getStart(context.source_file),\n\t\t\tcallback.equalsGreaterThanToken.getStart(context.source_file),\n\t\t)\n\t\t.trim();\n\tconst body_text = get_body_text(callback.body, context);\n\tconst rewritten_body = make_effect_body(callback.body, body_text, wrapper, context);\n\tconst replacement = `${params_text} => ${rewritten_body}`;\n\n\tcontext.magic.overwrite(start, end, replacement);\n\tcontext.changed = true;\n}\n\nfunction rewrite_function_body(\n\tcallback: ts.FunctionExpression,\n\twrapper: EffectWrapperMember,\n\tcontext: RewriteContext,\n): void {\n\tconst body_start = to_expr_pos(callback.body.getStart(context.source_file), context);\n\tconst body_end = to_expr_pos(callback.body.end, context);\n\tconst body_text = get_body_text(callback.body, context);\n\tconst rewritten_body = make_effect_body(callback.body, body_text, wrapper, context);\n\n\tcontext.magic.overwrite(body_start, body_end, `{ return ${rewritten_body}; }`);\n\tcontext.changed = true;\n}\n\nfunction make_effect_body(\n\tbody: ts.ConciseBody,\n\tbody_text: string,\n\twrapper: EffectWrapperMember,\n\tcontext: RewriteContext,\n): string {\n\tconst wrapper_access = make_effect_access(wrapper, context);\n\n\tif (wrapper === \"gen\") {\n\t\tif (ts.isBlock(body)) {\n\t\t\treturn `${wrapper_access}(function* () ${body_text})`;\n\t\t}\n\n\t\treturn `${wrapper_access}(function* () { return (${body_text}); })`;\n\t}\n\n\tif (ts.isBlock(body)) {\n\t\treturn `${wrapper_access}(() => ${body_text})`;\n\t}\n\n\treturn `${wrapper_access}(() => (${body_text}))`;\n}\n\nfunction get_body_text(body: ts.ConciseBody, context: RewriteContext): string {\n\treturn context.source_text.slice(body.getStart(context.source_file), body.end).trim();\n}\n\nfunction get_handler_properties(object_literal: ts.ObjectLiteralExpression): Array<{\n\tcallback: ts.ArrowFunction | ts.FunctionExpression | undefined;\n}> {\n\treturn object_literal.properties.flatMap((property) => {\n\t\tif (!ts.isPropertyAssignment(property)) {\n\t\t\treturn [];\n\t\t}\n\n\t\tconst name = get_property_name(property.name);\n\n\t\tif (!name || !effectful_handler_property_names.has(name)) {\n\t\t\treturn [];\n\t\t}\n\n\t\tconst callback = is_callback_expression(property.initializer)\n\t\t\t? property.initializer\n\t\t\t: undefined;\n\n\t\treturn [{ callback }];\n\t});\n}\n\nfunction get_last_object_argument(call: ts.CallExpression): ts.ObjectLiteralExpression | undefined {\n\tconst last_argument = call.arguments[call.arguments.length - 1];\n\n\tif (!last_argument || !ts.isObjectLiteralExpression(last_argument)) {\n\t\treturn undefined;\n\t}\n\n\treturn last_argument;\n}\n\nfunction get_effect_member(\n\texpression: ts.Expression,\n\tcontext: RewriteContext,\n): EffectMember | undefined {\n\tif (ts.isIdentifier(expression)) {\n\t\tconst direct_member = context.bindings.direct_members.get(expression.text);\n\n\t\tif (!direct_member) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn {\n\t\t\tname: direct_member,\n\t\t\tname_start: to_expr_pos(expression.getStart(context.source_file), context),\n\t\t\tname_end: to_expr_pos(expression.end, context),\n\t\t\tdirect: true,\n\t\t};\n\t}\n\n\tif (!ts.isPropertyAccessExpression(expression)) {\n\t\treturn undefined;\n\t}\n\n\tif (!is_effect_namespace_expression(expression.expression, context)) {\n\t\treturn undefined;\n\t}\n\n\treturn {\n\t\tname: expression.name.text,\n\t\tname_start: to_expr_pos(expression.name.getStart(context.source_file), context),\n\t\tname_end: to_expr_pos(expression.name.end, context),\n\t\tdirect: false,\n\t};\n}\n\nfunction rewrite_effect_member_name(\n\tmember: EffectMember,\n\tupgraded_name: string,\n\tcontext: RewriteContext,\n): void {\n\tif (member.direct) {\n\t\tcontext.magic.overwrite(\n\t\t\tmember.name_start,\n\t\t\tmember.name_end,\n\t\t\tmake_effect_access(upgraded_name, context),\n\t\t);\n\n\t\treturn;\n\t}\n\n\tcontext.magic.overwrite(member.name_start, member.name_end, upgraded_name);\n}\n\nfunction make_effect_access(member_name: string, context: RewriteContext): string {\n\tcontext.uses_wrapper = true;\n\n\treturn `${context.bindings.wrapper_expression}.${member_name}`;\n}\n\nfunction is_effect_namespace_expression(\n\texpression: ts.Expression,\n\tcontext: RewriteContext,\n): boolean {\n\tif (ts.isIdentifier(expression)) {\n\t\treturn (\n\t\t\tcontext.bindings.effect_object_names.has(expression.text) ||\n\t\t\tcontext.bindings.effect_module_names.has(expression.text)\n\t\t);\n\t}\n\n\tif (!ts.isPropertyAccessExpression(expression)) {\n\t\treturn false;\n\t}\n\n\tif (expression.name.text !== \"Effect\") {\n\t\treturn false;\n\t}\n\n\tif (!ts.isIdentifier(expression.expression)) {\n\t\treturn false;\n\t}\n\n\treturn context.bindings.effect_package_names.has(expression.expression.text);\n}\n\nfunction get_property_name(name: ts.PropertyName): string | undefined {\n\tif (ts.isIdentifier(name) || ts.isStringLiteral(name)) {\n\t\treturn name.text;\n\t}\n\n\treturn undefined;\n}\n\nfunction is_callback_expression(node: ts.Node): node is ts.ArrowFunction | ts.FunctionExpression {\n\treturn ts.isArrowFunction(node) || ts.isFunctionExpression(node);\n}\n\nfunction is_non_generator_callback_with_top_level_yield(\n\tnode: ts.Node,\n): node is ts.ArrowFunction | ts.FunctionExpression {\n\tif (!is_callback_expression(node)) {\n\t\treturn false;\n\t}\n\n\tif (ts.isFunctionExpression(node) && node.asteriskToken) {\n\t\treturn false;\n\t}\n\n\treturn contains_top_level_yield_star(node.body);\n}\n\nfunction is_async_function(node: ts.ArrowFunction | ts.FunctionExpression): boolean {\n\treturn (\n\t\tnode.modifiers?.some((modifier) => modifier.kind === ts.SyntaxKind.AsyncKeyword) ?? false\n\t);\n}\n\nfunction to_expr_pos(pos: number, context: RewriteContext): number {\n\treturn pos - context.offset;\n}\n","import { AsyncEffectInEventCallbackError, YieldStarInEventCallbackError } from \"$/errors.ts\";\nimport type { EffectCallbackRewriteContext } from \"./effect-bindings.ts\";\nimport {\n\tanalyze_event_body_yield_star,\n\tcollect_free_identifiers,\n\tis_callback_function_expression,\n} from \"./expressions.ts\";\nimport { normalize_effect_callback_yields } from \"./effect-callbacks.ts\";\nimport type {\n\tHelperDeclaration,\n\tMarkupCandidate,\n\tMarkupHelperBindings,\n\tMarkupNameAllocator,\n\tMarkupTransformTarget,\n\tPendingRelocation,\n\tReplacement,\n\tTagKind,\n} from \"./types.ts\";\n\n/**\n * Emits source edits for classified markup Effect expressions.\n *\n * @since 2.0.0\n * @param classified - Candidates paired with their Svelte markup context.\n * @param effect_context - Effect import bindings available to markup\n * expression rewrites.\n * @returns Replacements ready to apply to the original component source.\n */\nexport function emit_replacements(\n\tclassified: Array<{ candidate: MarkupCandidate; kind: TagKind }>,\n\teffect_context: EffectCallbackRewriteContext,\n\thelper_bindings: MarkupHelperBindings,\n\tname_allocator: MarkupNameAllocator,\n\ttarget: MarkupTransformTarget,\n): Replacement[] {\n\treturn classified.map(({ candidate, kind }) =>\n\t\temit_replacement(candidate, kind, effect_context, helper_bindings, name_allocator, target),\n\t);\n}\n\nfunction emit_replacement(\n\tcandidate: MarkupCandidate,\n\tkind: TagKind,\n\teffect_context: EffectCallbackRewriteContext,\n\thelper_bindings: MarkupHelperBindings,\n\tname_allocator: MarkupNameAllocator,\n\ttarget: MarkupTransformTarget,\n): Replacement {\n\tconst normalized = normalize_effect_callback_yields(candidate.expr_text, effect_context);\n\tconst normalized_candidate = {\n\t\t...candidate,\n\t\texpr_text: normalized.expr_text,\n\t};\n\tconst id = make_cache_id(candidate);\n\tconst id_text = JSON.stringify(id);\n\tconst helper_name = make_helper_name(candidate, name_allocator);\n\tconst is_server_target = target === \"server\";\n\n\tlet replacement_text: string;\n\tlet helpers: HelperDeclaration[];\n\tlet relocation: PendingRelocation | undefined;\n\n\tif (kind === \"await\") {\n\t\tconst effect = make_effect_helper(normalized_candidate, helper_name);\n\n\t\treplacement_text = emit_promise_expression(\n\t\t\tid_text,\n\t\t\teffect,\n\t\t\thelper_bindings,\n\t\t\t\"undefined\",\n\t\t\t`{ ssr: \"pending\" }`,\n\t\t);\n\t\thelpers = [...normalized.helpers, effect.helper];\n\t} else if (kind === \"render\") {\n\t\tconst effect = make_effect_helper(normalized_candidate, helper_name);\n\n\t\treplacement_text = emit_render_expression(\n\t\t\tid_text,\n\t\t\teffect,\n\t\t\tcandidate,\n\t\t\thelper_bindings,\n\t\t\tis_server_target,\n\t\t);\n\t\thelpers = [...normalized.helpers, effect.helper];\n\t} else if (kind === \"render_argument\") {\n\t\tconst effect = make_effect_helper(normalized_candidate, helper_name);\n\n\t\treplacement_text = emit_await_expression(\n\t\t\tid_text,\n\t\t\teffect,\n\t\t\thelper_bindings,\n\t\t\tserver_fallback(is_server_target, \"undefined\"),\n\t\t);\n\t\thelpers = [...normalized.helpers, effect.helper];\n\t} else if (kind === \"each\") {\n\t\tconst effect = make_effect_helper(normalized_candidate, helper_name);\n\n\t\treplacement_text = emit_await_expression(\n\t\t\tid_text,\n\t\t\teffect,\n\t\t\thelper_bindings,\n\t\t\tserver_fallback(is_server_target, \"[]\"),\n\t\t);\n\t\thelpers = [...normalized.helpers, effect.helper];\n\t} else if (kind === \"event\") {\n\t\tconst event = make_event_handler(normalized_candidate, helper_bindings);\n\n\t\treplacement_text = event.text;\n\t\thelpers = normalized.helpers;\n\t\trelocation = make_relocation(candidate, replacement_text, {\n\t\t\toriginalStart: 0,\n\t\t\toriginalEnd: candidate.expr_text.length,\n\t\t\tgeneratedText: event.expr_text,\n\t\t});\n\t} else {\n\t\tconst effect = make_effect_helper(normalized_candidate, helper_name);\n\n\t\treplacement_text = emit_await_expression(\n\t\t\tid_text,\n\t\t\teffect,\n\t\t\thelper_bindings,\n\t\t\tserver_fallback(is_server_target, \"undefined\"),\n\t\t);\n\t\thelpers = [...normalized.helpers, effect.helper];\n\t}\n\n\treturn {\n\t\tstart: candidate.start,\n\t\tend: candidate.end,\n\t\ttext: replacement_text,\n\t\thelpers,\n\t\trelocation,\n\t};\n}\n\nfunction make_event_handler(\n\tcandidate: MarkupCandidate,\n\thelper_bindings: MarkupHelperBindings,\n): { text: string; expr_text: string } {\n\tconst expr_text = candidate.expr_text;\n\n\tif (is_callback_function_expression(expr_text)) {\n\t\tthrow new YieldStarInEventCallbackError(candidate.filename, expr_text);\n\t}\n\n\tconst analysis = analyze_event_body_yield_star(expr_text);\n\n\tif (analysis.has_nested_invalid_yield_star) {\n\t\tthrow new AsyncEffectInEventCallbackError(candidate.filename, expr_text);\n\t}\n\n\treturn {\n\t\texpr_text,\n\t\ttext: `(event) => { ${helper_bindings.dispatcher}.emit({ type: ${helper_bindings.codes}.Markup.Run, fn: function* () { ${expr_text}; } }); }`,\n\t};\n}\n\nfunction emit_promise_expression(\n\tid_text: string,\n\teffect: EffectHelper,\n\thelper_bindings: MarkupHelperBindings,\n\tssr_fallback?: string,\n\toptions?: string,\n): string {\n\tconst properties = [\n\t\t`type: ${helper_bindings.codes}.Markup.Promise`,\n\t\t`id: ${id_text}`,\n\t\t`deps: ${effect.deps_text}`,\n\t\t`fn: () => ${effect.call}`,\n\t\tssr_fallback !== undefined && `ssr_fallback: ${ssr_fallback}`,\n\t\toptions !== undefined && `options: ${options}`,\n\t].filter((property): property is string => property !== false);\n\n\treturn `${helper_bindings.dispatcher}.emit({ ${properties.join(\", \")} })`;\n}\n\nfunction emit_render_expression(\n\tid_text: string,\n\teffect: EffectHelper,\n\tcandidate: MarkupCandidate,\n\thelper_bindings: MarkupHelperBindings,\n\tis_server_target: boolean,\n): string {\n\tconst expression = emit_promise_expression(\n\t\tid_text,\n\t\teffect,\n\t\thelper_bindings,\n\t\tserver_fallback(is_server_target, `() => undefined`),\n\t);\n\n\tif (/^\\s*yield\\s*\\*/.test(candidate.expr_text)) {\n\t\treturn `(await ${expression})()`;\n\t}\n\n\treturn `await ${expression}`;\n}\n\nfunction emit_await_expression(\n\tid_text: string,\n\teffect: EffectHelper,\n\thelper_bindings: MarkupHelperBindings,\n\tssr_fallback?: string,\n): string {\n\treturn `await ${emit_promise_expression(id_text, effect, helper_bindings, ssr_fallback)}`;\n}\n\nfunction server_fallback(is_server_target: boolean, fallback: string): string | undefined {\n\treturn is_server_target ? fallback : undefined;\n}\n\ninterface EffectHelper {\n\thelper: HelperDeclaration;\n\tcall: string;\n\tdeps_text: string;\n}\n\nfunction make_effect_helper(candidate: MarkupCandidate, helper_name: string): EffectHelper {\n\tconst deps = collect_free_identifiers(candidate.expr_text);\n\tconst args_text = deps.join(\", \");\n\tconst deps_text = deps.length === 0 ? \"[]\" : `[${args_text}]`;\n\tconst call = `${helper_name}()`;\n\tconst text = `function* ${helper_name}() { return (${candidate.expr_text}); }`;\n\tconst generated_start = text.indexOf(candidate.expr_text);\n\n\treturn {\n\t\tcall,\n\t\tdeps_text,\n\t\thelper: {\n\t\t\ttext,\n\t\t\trelocation: {\n\t\t\t\toriginalStart: candidate.start,\n\t\t\t\toriginalEnd: candidate.end,\n\t\t\t\tgeneratedStartInReplacement: generated_start,\n\t\t\t\tgeneratedEndInReplacement: generated_start + candidate.expr_text.length,\n\t\t\t},\n\t\t},\n\t};\n}\n\nfunction make_cache_id(candidate: MarkupCandidate): string {\n\tconst normalized_filename = candidate.filename.replace(/[?#].*$/, \"\");\n\n\treturn `${normalized_filename}:${candidate.start}:${candidate.end}`;\n}\n\nfunction make_helper_name(candidate: MarkupCandidate, name_allocator: MarkupNameAllocator): string {\n\treturn name_allocator.reserve(`__SER___markup_effect_${candidate.start}_${candidate.end}`);\n}\n\nfunction make_relocation(\n\tcandidate: MarkupCandidate,\n\treplacement_text: string,\n\tinner: {\n\t\toriginalStart: number;\n\t\toriginalEnd: number;\n\t\tgeneratedText: string;\n\t},\n): PendingRelocation | undefined {\n\tconst generated_start = replacement_text.indexOf(inner.generatedText);\n\n\tif (generated_start === -1) {\n\t\treturn undefined;\n\t}\n\n\treturn {\n\t\toriginalStart: candidate.start + inner.originalStart,\n\t\toriginalEnd: candidate.start + inner.originalEnd,\n\t\tgeneratedStartInReplacement: generated_start,\n\t\tgeneratedEndInReplacement: generated_start + inner.generatedText.length,\n\t};\n}\n","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(magic: MagicString, filename: string): Record<string, unknown> {\n\tconst map = magic.generateMap({\n\t\thires: true,\n\t\tincludeContent: true,\n\t\tsource: filename,\n\t});\n\n\treturn 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\treturn 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\treturn content.slice(node.getStart(), node.end);\n}\n","import { contains_top_level_yield_star } from \"$/detect.ts\";\nimport { AsyncEffectInSyncRuneError } from \"$/errors.ts\";\nimport { slice } from \"./source.ts\";\n\nimport ts from \"typescript\";\n\nconst ASYNC_EXPRESSION_RUNES = new Set([\n\t\"$derived\",\n\t\"$state\",\n\t\"$state.raw\",\n\t\"$state.snapshot\",\n\t\"$bindable\",\n]);\n\nconst CALLBACK_RUNES = new Set([\"$derived.by\", \"$effect\", \"$effect.pre\", \"$effect.root\"]);\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(node: ts.Node, content: string, filename: string): void {\n\tvisit_rune_yield_usage(node, content, filename);\n}\n\nfunction visit_rune_yield_usage(node: ts.Node, content: string, filename: string): void {\n\tif (ts.isCallExpression(node)) {\n\t\tvalidate_call_expression(node, content, filename);\n\t}\n\n\tnode.forEachChild((child) => {\n\t\tvisit_rune_yield_usage(child, content, filename);\n\t});\n}\n\nfunction validate_call_expression(\n\tcall: ts.CallExpression,\n\tcontent: string,\n\tfilename: string,\n): void {\n\tconst rune_name = get_rune_name(call.expression);\n\n\tif (!rune_name) {\n\t\treturn;\n\t}\n\n\tif (!ASYNC_EXPRESSION_RUNES.has(rune_name) && contains_top_level_yield_star(call)) {\n\t\tthrow new AsyncEffectInSyncRuneError(rune_name, slice(content, call), filename);\n\t}\n\n\tif (!CALLBACK_RUNES.has(rune_name)) {\n\t\treturn;\n\t}\n\n\tconst callback = call.arguments[0];\n\n\tif (!callback || !callback_has_top_level_yield_star(callback)) {\n\t\treturn;\n\t}\n\n\tthrow new AsyncEffectInSyncRuneError(rune_name, slice(content, call), filename);\n}\n\nfunction callback_has_top_level_yield_star(node: ts.Expression): boolean {\n\tif ((ts.isArrowFunction(node) || ts.isFunctionExpression(node)) && node.body !== undefined) {\n\t\treturn contains_top_level_yield_star(node.body);\n\t}\n\n\treturn contains_top_level_yield_star(node);\n}\n\nfunction get_rune_name(expr: ts.Expression): string | undefined {\n\tif (ts.isIdentifier(expr) && is_rune_root(expr.text)) {\n\t\treturn expr.text;\n\t}\n\n\tif (!ts.isPropertyAccessExpression(expr)) {\n\t\treturn undefined;\n\t}\n\n\tconst root_name = get_rune_name(expr.expression);\n\n\tif (!root_name) {\n\t\treturn undefined;\n\t}\n\n\treturn `${root_name}.${expr.name.text}`;\n}\n\nfunction is_rune_root(name: string): boolean {\n\treturn (\n\t\tname === \"$bindable\" ||\n\t\tname === \"$derived\" ||\n\t\tname === \"$effect\" ||\n\t\tname === \"$host\" ||\n\t\tname === \"$inspect\" ||\n\t\tname === \"$props\" ||\n\t\tname === \"$state\"\n\t);\n}\n","import ts from \"typescript\";\n\n/**\n * Checks whether a node is a `yield*` binary expression.\n *\n * @since 2.0.0\n * @param node - TypeScript AST node to check.\n * @returns Whether the node represents `yield * operand`.\n */\nexport function is_yield_star_expression(node: ts.Node): boolean {\n\treturn (\n\t\tts.isBinaryExpression(node) &&\n\t\tnode.operatorToken.kind === ts.SyntaxKind.AsteriskToken &&\n\t\tts.isIdentifier(node.left) &&\n\t\tnode.left.text === \"yield\"\n\t);\n}\n\n/**\n * Checks whether a node owns its own yield semantics.\n *\n * @since 2.0.0\n * @param node - TypeScript AST node to check.\n * @returns Whether traversal should stop at this function boundary.\n */\nexport function is_function_boundary_node(node: ts.Node): boolean {\n\treturn (\n\t\tts.isArrowFunction(node) ||\n\t\tts.isFunctionDeclaration(node) ||\n\t\tts.isFunctionExpression(node) ||\n\t\tts.isMethodDeclaration(node) ||\n\t\tts.isGetAccessorDeclaration(node) ||\n\t\tts.isSetAccessorDeclaration(node)\n\t);\n}\n\n/**\n * Returns `true` if the node tree contains a top-level `await`.\n *\n * @since 2.0.0\n * @param node - Root node to search.\n * @returns Whether a top-level await expression was found.\n */\nexport function contains_top_level_await(node: ts.Node): boolean {\n\tif (ts.isAwaitExpression(node)) {\n\t\treturn true;\n\t}\n\n\treturn node\n\t\t.getChildren()\n\t\t.some((child) => !is_function_boundary_node(child) && contains_top_level_await(child));\n}\n\n/**\n * Collects top-level `yield*` nodes under an expression.\n *\n * @since 2.0.0\n * @param node - Root node to search.\n * @param on_found - Callback invoked for each matching yield node.\n * @returns Nothing.\n */\nexport function collect_yield_star_nodes(node: ts.Node, on_found: (node: ts.Node) => void): void {\n\tif (is_function_boundary_node(node)) {\n\t\treturn;\n\t}\n\n\tif (is_yield_star_expression(node)) {\n\t\ton_found(node);\n\t\treturn;\n\t}\n\n\tnode.forEachChild((child) => {\n\t\tcollect_yield_star_nodes(child, on_found);\n\t});\n}\n\n/**\n * Finds the first top-level `yield*` expression below a node.\n *\n * @since 2.0.0\n * @param node - Root node to search.\n * @param on_found - Callback invoked with the first matching node.\n * @returns Nothing.\n */\nexport function find_yield_star_node(node: ts.Node, on_found: (node: ts.Node) => void): void {\n\tif (is_function_boundary_node(node)) {\n\t\treturn;\n\t}\n\n\tif (is_yield_star_expression(node)) {\n\t\ton_found(node);\n\t\treturn;\n\t}\n\n\tnode.forEachChild((child) => {\n\t\tfind_yield_star_node(child, on_found);\n\t});\n}\n\n/**\n * Extracts identifier names from a TypeScript binding name.\n *\n * @since 2.0.0\n * @param name - Binding name node to flatten.\n * @returns Identifier names from identifiers and destructuring patterns.\n */\nexport function extract_binding_names(name: ts.BindingName): string[] {\n\tif (ts.isIdentifier(name)) {\n\t\treturn [name.text];\n\t}\n\n\tconst result: string[] = [];\n\n\tfor (const element of name.elements) {\n\t\tif (ts.isOmittedExpression(element)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tresult.push(...extract_binding_names(element.name));\n\t}\n\n\treturn result;\n}\n","import { validate_rune_yield_usage } from \"$/script-transform/runes.ts\";\nimport { collect_yield_star_nodes } from \"$/script-transform/ast.ts\";\nimport { contains_top_level_yield_star } from \"$/detect.ts\";\nimport { analyze_event_body_yield_star, strip_arrow_function } from \"./expressions.ts\";\nimport { HELPERS } from \"./constants.ts\";\nimport type { MarkupCandidate, TagKind } from \"./types.ts\";\n\nimport MagicString from \"magic-string\";\n\nimport ts from \"typescript\";\n\ninterface SanitizeResult {\n\tcode: string;\n\tcandidates: MarkupCandidate[];\n}\n\ninterface DeclarationYieldExpression {\n\tstart: number;\n\tend: number;\n\texpr_text: string;\n}\n\ninterface SourceRange {\n\tstart: number;\n\tend: number;\n}\n\n/**\n * Replaces markup `yield*` expressions with placeholders before Svelte parses\n * the component.\n *\n * @example\n * ```ts\n * const sanitized = sanitize_markup(\n * `<p>{yield* loadLabel()}</p>`,\n * \"Label.svelte\",\n * );\n * ```\n *\n * @since 2.0.0\n * @param content - Raw Svelte component source to scan for effectful markup\n * expressions.\n * @param filename - Source filename used when validation errors need to point\n * back to the component being transformed.\n * @returns Sanitized source plus placeholder candidates that should be lowered\n * after Svelte classifies their markup positions.\n */\nexport function sanitize_markup(content: string, filename: string): SanitizeResult {\n\tconst candidates: MarkupCandidate[] = [];\n\tconst excluded_ranges = collect_excluded_ranges(content);\n\tconst magic = new MagicString(content);\n\tlet helper_index = 0;\n\tlet cursor = 0;\n\n\twhile (cursor < content.length) {\n\t\tconst open = content.indexOf(\"{\", cursor);\n\t\tif (open === -1) break;\n\n\t\t/** Skip braces inside <script> and <style> blocks. */\n\t\tconst excluded_range = find_excluded_range(excluded_ranges, open);\n\n\t\tif (excluded_range) {\n\t\t\tcursor = excluded_range.end;\n\t\t\tcontinue;\n\t\t}\n\n\t\t/** Find the matching closing brace. */\n\t\tconst close = find_closing_brace(content, open + 1);\n\t\tif (close === -1) {\n\t\t\tcursor = open + 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst inner = content.slice(open + 1, close);\n\n\t\tconst trimmed = inner.trimStart();\n\t\tconst leading_ws = inner.length - trimmed.length;\n\n\t\tconst tag_info = get_tag_info(trimmed);\n\n\t\tconst declaration_yields = collect_declaration_yield_expressions(\n\t\t\tcontent,\n\t\t\topen,\n\t\t\tleading_ws,\n\t\t\ttrimmed,\n\t\t\tfilename,\n\t\t);\n\n\t\tif (declaration_yields.length > 0) {\n\t\t\tfor (const declaration_yield of declaration_yields) {\n\t\t\t\tconst placeholder = `__SER___markup_placeholder_${helper_index}`;\n\t\t\t\thelper_index += 1;\n\n\t\t\t\tcandidates.push({\n\t\t\t\t\tplaceholder,\n\t\t\t\t\tstart: declaration_yield.start,\n\t\t\t\t\tend: declaration_yield.end,\n\t\t\t\t\texpr_text: declaration_yield.expr_text,\n\t\t\t\t\tfilename,\n\t\t\t\t\tkey: \"plain\",\n\t\t\t\t});\n\n\t\t\t\tmagic.overwrite(declaration_yield.start, declaration_yield.end, placeholder);\n\t\t\t}\n\n\t\t\tcursor = close + 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tlet expr_body = trimmed.slice(tag_info.prefix_length);\n\n\t\t/** For @const, only use the RHS after `=` as the expression body. */\n\t\tconst equal_idx =\n\t\t\ttag_info.kind === \"plain\" && trimmed.startsWith(\"@const \")\n\t\t\t\t? expr_body.indexOf(\"=\")\n\t\t\t\t: -1;\n\n\t\t/** Check if this is a callback handler containing yield*. */\n\t\tconst is_event_callback = is_event_callback_expression(inner);\n\n\t\t/** Determine if this brace contains yield* that needs lowering. */\n\t\tconst event_yield = is_event_callback ? analyze_event_yield(inner) : undefined;\n\t\tconst has_yield =\n\t\t\tevent_yield?.has_top_level_yield_star ?? contains_yield_star_in_text(expr_body);\n\n\t\tif (!has_yield) {\n\t\t\tcursor = close + 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\t/** The expression starts after the tag prefix. For @const, after the `=`. */\n\t\tlet extra_prefix = 0;\n\n\t\tif (equal_idx !== -1) {\n\t\t\tconst after_eq_raw = expr_body.slice(equal_idx + 1);\n\t\t\texpr_body = after_eq_raw.trimStart();\n\t\t\textra_prefix = equal_idx + 1 + (after_eq_raw.length - expr_body.length);\n\t\t}\n\n\t\tconst expr_start = open + 1 + leading_ws + tag_info.prefix_length + extra_prefix;\n\n\t\t/** For each/await, the expression ends before ` as ` or ` then `/` catch `. */\n\t\tlet expr_end = close;\n\n\t\tconst key = tag_info.kind;\n\n\t\tif (key === \"each\") {\n\t\t\tconst as_idx = expr_body.lastIndexOf(\" as \");\n\t\t\tif (as_idx !== -1) expr_end = expr_start + as_idx;\n\t\t}\n\n\t\tif (key === \"await\") {\n\t\t\tconst then_idx = expr_body.indexOf(\" then \");\n\t\t\tconst catch_idx = expr_body.indexOf(\" catch \");\n\t\t\tconst boundary = Math.min(\n\t\t\t\tthen_idx === -1 ? Infinity : then_idx,\n\t\t\t\tcatch_idx === -1 ? Infinity : catch_idx,\n\t\t\t);\n\t\t\tif (boundary !== Infinity) expr_end = expr_start + boundary;\n\t\t}\n\n\t\tconst expr_text = content.slice(expr_start, expr_end).trim();\n\n\t\tif (expr_text.length === 0) {\n\t\t\tcursor = close + 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tvalidate_expression_yield_usage(expr_text, filename);\n\n\t\tif (key === \"render\" && !/^\\s*yield\\s*\\*/.test(expr_text)) {\n\t\t\tconst render_arg_yields = collect_expression_yield_expressions(\n\t\t\t\tcontent,\n\t\t\t\texpr_start,\n\t\t\t\texpr_text,\n\t\t\t\tfilename,\n\t\t\t);\n\n\t\t\tif (render_arg_yields.length > 0) {\n\t\t\t\tfor (const render_arg_yield of render_arg_yields) {\n\t\t\t\t\tconst placeholder = `__SER___markup_placeholder_${helper_index}`;\n\t\t\t\t\thelper_index += 1;\n\n\t\t\t\t\tcandidates.push({\n\t\t\t\t\t\tplaceholder,\n\t\t\t\t\t\tstart: render_arg_yield.start,\n\t\t\t\t\t\tend: render_arg_yield.end,\n\t\t\t\t\t\texpr_text: render_arg_yield.expr_text,\n\t\t\t\t\t\tfilename,\n\t\t\t\t\t\tkey: \"render_argument\",\n\t\t\t\t\t});\n\n\t\t\t\t\tmagic.overwrite(render_arg_yield.start, render_arg_yield.end, placeholder);\n\t\t\t\t}\n\n\t\t\t\tcursor = close + 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\n\t\t/** Create a placeholder and replace the expression (preserving tag prefixes). */\n\t\tconst placeholder = `__SER___markup_placeholder_${helper_index}`;\n\t\thelper_index += 1;\n\n\t\tcandidates.push({\n\t\t\tplaceholder,\n\t\t\tstart: expr_start,\n\t\t\tend: expr_end,\n\t\t\texpr_text,\n\t\t\tfilename,\n\t\t\tkey,\n\t\t});\n\n\t\tmagic.overwrite(expr_start, expr_end, key === \"render\" ? `${placeholder}()` : placeholder);\n\n\t\tcursor = close + 1;\n\t}\n\n\treturn { code: magic.toString(), candidates };\n}\n\nfunction collect_expression_yield_expressions(\n\tcontent: string,\n\texpr_start: number,\n\texpr_text: string,\n\tfilename: string,\n): DeclarationYieldExpression[] {\n\tconst source_file = ts.createSourceFile(\n\t\t\"markup-expression.ts\",\n\t\t`const __SER___expr = ${expr_text};`,\n\t\tts.ScriptTarget.Latest,\n\t\ttrue,\n\t\tts.ScriptKind.TS,\n\t);\n\tconst stmt = source_file.statements[0];\n\n\tif (!stmt || !ts.isVariableStatement(stmt)) {\n\t\treturn [];\n\t}\n\n\tvalidate_rune_yield_usage(stmt, source_file.text, filename);\n\n\tconst initializer = stmt.declarationList.declarations[0]?.initializer;\n\n\tif (!initializer || !contains_top_level_yield_star(initializer)) {\n\t\treturn [];\n\t}\n\n\tconst prefix_length = source_file.text.indexOf(expr_text);\n\tconst expressions: DeclarationYieldExpression[] = [];\n\n\tcollect_yield_star_nodes(initializer, (yield_node) => {\n\t\tconst start = expr_start + yield_node.getStart(source_file) - prefix_length;\n\t\tconst end = expr_start + yield_node.end - prefix_length;\n\t\tconst yielded_text = content.slice(start, end).trim();\n\n\t\texpressions.push({\n\t\t\tstart,\n\t\t\tend,\n\t\t\texpr_text: yielded_text,\n\t\t});\n\t});\n\n\treturn expressions;\n}\n\nfunction collect_excluded_ranges(content: string): SourceRange[] {\n\tconst ranges = [\n\t\t...collect_tag_ranges(content, \"script\"),\n\t\t...collect_tag_ranges(content, \"style\"),\n\t\t...collect_html_comment_ranges(content),\n\t];\n\n\tranges.sort((a, b) => a.start - b.start);\n\n\treturn merge_ranges(ranges);\n}\n\nfunction collect_tag_ranges(content: string, tag: string): SourceRange[] {\n\tconst pattern = new RegExp(`<${tag}\\\\b[^>]*>([\\\\s\\\\S]*?)<\\\\/${tag}\\\\s*>`, \"gi\");\n\n\treturn [...content.matchAll(pattern)].flatMap((match) => {\n\t\tif (match.index === undefined) {\n\t\t\treturn [];\n\t\t}\n\n\t\treturn [\n\t\t\t{\n\t\t\t\tstart: match.index,\n\t\t\t\tend: match.index + match[0].length,\n\t\t\t},\n\t\t];\n\t});\n}\n\nfunction collect_html_comment_ranges(content: string): SourceRange[] {\n\tconst ranges: SourceRange[] = [];\n\tlet cursor = 0;\n\n\twhile (cursor < content.length) {\n\t\tconst start = content.indexOf(\"<!--\", cursor);\n\n\t\tif (start === -1) {\n\t\t\tbreak;\n\t\t}\n\n\t\tconst close = content.indexOf(\"-->\", start + \"<!--\".length);\n\t\tconst end = close === -1 ? content.length : close + \"-->\".length;\n\n\t\tranges.push({ start, end });\n\n\t\tcursor = end;\n\t}\n\n\treturn ranges;\n}\n\nfunction merge_ranges(ranges: SourceRange[]): SourceRange[] {\n\tconst merged: SourceRange[] = [];\n\n\tfor (const range of ranges) {\n\t\tconst previous = merged.at(-1);\n\n\t\tif (!previous || range.start > previous.end) {\n\t\t\tmerged.push({ ...range });\n\t\t\tcontinue;\n\t\t}\n\n\t\tprevious.end = Math.max(previous.end, range.end);\n\t}\n\n\treturn merged;\n}\n\nfunction find_excluded_range(ranges: SourceRange[], pos: number): SourceRange | undefined {\n\tlet low = 0;\n\tlet high = ranges.length - 1;\n\n\twhile (low <= high) {\n\t\tconst mid = Math.floor((low + high) / 2);\n\t\tconst range = ranges[mid];\n\n\t\tif (pos <= range.start) {\n\t\t\thigh = mid - 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (pos >= range.end) {\n\t\t\tlow = mid + 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\treturn range;\n\t}\n\n\treturn undefined;\n}\n\n/** Brace matching helpers for extracting complete markup expressions. */\n\nfunction find_closing_brace(content: string, start: number): number {\n\tlet depth = 0;\n\n\tfor (let i = start; i < content.length; i += 1) {\n\t\tconst ch = content[i];\n\n\t\tif (ch === \"{\" && content[i - 1] !== \"$\") {\n\t\t\tdepth += 1;\n\t\t} else if (ch === \"}\") {\n\t\t\tif (depth === 0) return i;\n\t\t\tdepth -= 1;\n\t\t} else if (ch === \"'\" || ch === '\"' || ch === \"`\") {\n\t\t\ti = skip_string(content, i, ch);\n\t\t\tif (i === -1) return -1;\n\t\t} else if (ch === \"/\" && content[i + 1] === \"/\") {\n\t\t\ti = skip_line_comment(content, i);\n\t\t} else if (ch === \"/\" && content[i + 1] === \"*\") {\n\t\t\ti = skip_block_comment(content, i);\n\t\t\tif (i === -1) return -1;\n\t\t}\n\t}\n\n\treturn -1;\n}\n\nfunction skip_string(content: string, start: number, quote: string): number {\n\tfor (let i = start + 1; i < content.length; i += 1) {\n\t\tif (content[i] === \"\\\\\") {\n\t\t\ti += 1;\n\t\t\tcontinue;\n\t\t}\n\t\tif (content[i] === quote) return i;\n\t}\n\treturn -1;\n}\n\nfunction skip_line_comment(content: string, start: number): number {\n\tfor (let i = start + 2; i < content.length; i += 1) {\n\t\tif (content[i] === \"\\n\") return i;\n\t}\n\treturn content.length;\n}\n\nfunction skip_block_comment(content: string, start: number): number {\n\tfor (let i = start + 2; i < content.length; i += 1) {\n\t\tif (content[i] === \"*\" && content[i + 1] === \"/\") return i + 1;\n\t}\n\treturn -1;\n}\n\ninterface TagInfo {\n\tkind: TagKind;\n\tprefix_length: number;\n}\n\nfunction get_tag_info(trimmed: string): TagInfo {\n\tif (trimmed.startsWith(\"#each \")) {\n\t\treturn { kind: \"each\", prefix_length: \"#each \".length };\n\t}\n\tif (trimmed.startsWith(\"#await \")) {\n\t\treturn { kind: \"await\", prefix_length: \"#await \".length };\n\t}\n\tif (trimmed.startsWith(\"@render \")) {\n\t\treturn { kind: \"render\", prefix_length: \"@render \".length };\n\t}\n\n\t/** Strip prefix-only tags — the expression starts after the tag keyword. */\n\tif (trimmed.startsWith(\"#if \")) {\n\t\treturn { kind: \"plain\", prefix_length: \"#if \".length };\n\t}\n\tif (trimmed.startsWith(\":else if \")) {\n\t\treturn { kind: \"plain\", prefix_length: \":else if \".length };\n\t}\n\tif (trimmed.startsWith(\"#key \")) {\n\t\treturn { kind: \"plain\", prefix_length: \"#key \".length };\n\t}\n\tif (trimmed.startsWith(\"@const \")) {\n\t\treturn { kind: \"plain\", prefix_length: \"@const \".length };\n\t}\n\tif (trimmed.startsWith(\"@html \")) {\n\t\treturn { kind: \"plain\", prefix_length: \"@html \".length };\n\t}\n\tif (trimmed.startsWith(\"@debug \")) {\n\t\treturn { kind: \"plain\", prefix_length: \"@debug \".length };\n\t}\n\n\treturn { kind: \"plain\", prefix_length: 0 };\n}\n\nfunction collect_declaration_yield_expressions(\n\tcontent: string,\n\topen: number,\n\tleading_ws: number,\n\ttrimmed: string,\n\tfilename: string,\n): DeclarationYieldExpression[] {\n\tif (!is_declaration_tag_text(trimmed)) {\n\t\treturn [];\n\t}\n\n\tconst source_text = `${trimmed};`;\n\tconst source_file = ts.createSourceFile(\n\t\t\"declaration-tag.ts\",\n\t\tsource_text,\n\t\tts.ScriptTarget.Latest,\n\t\ttrue,\n\t\tts.ScriptKind.TS,\n\t);\n\n\tconst stmt = source_file.statements[0];\n\n\tif (!stmt || !ts.isVariableStatement(stmt)) {\n\t\treturn [];\n\t}\n\n\tvalidate_rune_yield_usage(stmt, source_text, filename);\n\n\tconst tag_start = open + 1 + leading_ws;\n\n\treturn stmt.declarationList.declarations.flatMap((decl) => {\n\t\tconst expressions: DeclarationYieldExpression[] = [];\n\n\t\tcollect_yield_star_nodes(decl, (yield_node) => {\n\t\t\tconst start = tag_start + yield_node.getStart(source_file);\n\t\t\tconst end = tag_start + yield_node.end;\n\t\t\tconst expr_text = content.slice(start, end).trim();\n\n\t\t\texpressions.push({\n\t\t\t\tstart,\n\t\t\t\tend,\n\t\t\t\texpr_text,\n\t\t\t});\n\t\t});\n\n\t\treturn expressions;\n\t});\n}\n\nfunction is_declaration_tag_text(trimmed: string): boolean {\n\treturn /^(?:const|let)\\s/.test(trimmed);\n}\n\nfunction validate_expression_yield_usage(expr_text: string, filename: string): void {\n\tconst source_text = `const __SER___expr = ${expr_text};`;\n\tconst source_file = ts.createSourceFile(\n\t\t\"markup-expression.ts\",\n\t\tsource_text,\n\t\tts.ScriptTarget.Latest,\n\t\ttrue,\n\t\tts.ScriptKind.TS,\n\t);\n\tconst stmt = source_file.statements[0];\n\n\tif (!stmt) {\n\t\treturn;\n\t}\n\n\tvalidate_rune_yield_usage(stmt, source_text, filename);\n}\n\nfunction is_event_callback_expression(inner: string): boolean {\n\tconst trimmed = inner.trimStart();\n\n\treturn (\n\t\t/^(?:async\\s+)?(?:\\([^)]*\\)|[A-Za-z_$][\\w$]*)\\s*=>/.test(trimmed) ||\n\t\t/^(?:async\\s+)?function\\b/.test(trimmed)\n\t);\n}\n\nfunction analyze_event_yield(inner: string): {\n\thas_top_level_yield_star: boolean;\n} {\n\tconst event = strip_arrow_function(inner);\n\tconst analysis = analyze_event_body_yield_star(event.body);\n\tconst generated_run = new RegExp(\n\t\t`${HELPERS.dispatcher}(?:_\\\\d+)?\\\\.emit\\\\(\\\\{\\\\s*type:\\\\s*${HELPERS.codes}(?:_\\\\d+)?\\\\.Markup\\\\.Run`,\n\t);\n\n\tif (generated_run.test(event.body)) {\n\t\treturn {\n\t\t\thas_top_level_yield_star: false,\n\t\t};\n\t}\n\n\treturn {\n\t\thas_top_level_yield_star:\n\t\t\tanalysis.has_top_level_yield_star ||\n\t\t\tanalysis.has_nested_invalid_yield_star ||\n\t\t\t/\\byield\\s*\\*/.test(event.body),\n\t};\n}\n\nfunction contains_yield_star_in_text(text: string): boolean {\n\tif (!/\\byield\\s*\\*/.test(text)) return false;\n\n\ttry {\n\t\tconst sf = ts.createSourceFile(\n\t\t\t\"expr.ts\",\n\t\t\t`const x = ${text};`,\n\t\t\tts.ScriptTarget.Latest,\n\t\t\ttrue,\n\t\t\tts.ScriptKind.TS,\n\t\t);\n\t\tconst stmt = sf.statements[0];\n\t\tif (!ts.isVariableStatement(stmt)) return false;\n\t\tconst decl = stmt.declarationList.declarations[0];\n\t\tif (!decl?.initializer) return false;\n\t\treturn contains_top_level_yield_star(decl.initializer);\n\t} catch {\n\t\treturn true;\n\t}\n}\n\n/** Free identifier collection helpers for generated closures. */\n","import {\n\tblank_script_blocks,\n\tcreate_relocations,\n\tcreate_source_map,\n\tinject_helpers,\n\tmake_markup_helper_bindings,\n} from \"./apply.ts\";\nimport type { MarkupTransformOptions, MarkupTransformResult } from \"./types.ts\";\nimport { collect_effect_callback_bindings } from \"./effect-bindings.ts\";\nimport { UnsupportedMarkupEffectPositionError } from \"$/errors.ts\";\nimport { classify_candidates } from \"./classify.ts\";\nimport { type AST, parse } from \"svelte/compiler\";\nimport { emit_replacements } from \"./emit.ts\";\nimport { sanitize_markup } from \"./scan.ts\";\n\nimport MagicString from \"magic-string\";\n\nexport type {\n\tMarkupRelocation,\n\tMarkupTransformOptions,\n\tMarkupTransformResult,\n\tMarkupTransformTarget,\n} from \"./types.ts\";\n\n/**\n * Transforms Svelte markup containing `{yield* expr}` brace expressions\n * into generated dispatcher events.\n *\n * Strategy: first find all brace expressions containing `yield*` via\n * character scanning, replace them with placeholder identifiers, then\n * parse the sanitized markup with Svelte's AST to determine the correct\n * context for each placeholder (plain expression, #each, #await, event\n * handler, etc.).\n *\n * @example\n * ```ts\n * const result = transform_markup_effect(\n * \"<button onclick={yield* save()}>Save</button>\",\n * \"SaveButton.svelte\",\n * );\n * ```\n *\n * @since 2.0.0\n * @param content - The raw `.svelte` file content.\n * @param filename - The source filename, used in error messages.\n * @param options - Optional transform target configuration.\n * @returns The transformed markup and a flag indicating whether yield* was\n * found.\n */\nexport function transform_markup_effect(\n\tcontent: string,\n\tfilename: string,\n\toptions: MarkupTransformOptions = {},\n): MarkupTransformResult {\n\tif (!/\\byield\\s*\\*/.test(content)) {\n\t\treturn { code: content, has_yield: false };\n\t}\n\n\t/** Find all brace expressions containing yield* and replace with placeholders. */\n\tconst work = sanitize_markup(content, filename);\n\tconst effect_context = collect_effect_callback_bindings(content);\n\tconst helper_context = make_markup_helper_bindings(content);\n\n\tif (work.candidates.length === 0) {\n\t\treturn { code: content, has_yield: false };\n\t}\n\n\t/** Parse the sanitized markup with Svelte's AST. Strip <script> blocks\n\t * first so TypeScript syntax (import type, etc.) doesn't break the parser. */\n\tconst clean = blank_script_blocks(work.code);\n\tconst ast = parse(clean, { filename, modern: true }) as AST.Root;\n\n\t/** Match placeholders to their AST context and build replacements. */\n\tconst classified = classify_candidates(ast, work.candidates);\n\tconst matched = new Set(classified.map(({ candidate }) => candidate.placeholder));\n\tconst unmatched = work.candidates.find((candidate) => !matched.has(candidate.placeholder));\n\n\tif (unmatched) {\n\t\tthrow new UnsupportedMarkupEffectPositionError(filename, unmatched.expr_text);\n\t}\n\n\tconst replacements = emit_replacements(\n\t\tclassified,\n\t\teffect_context,\n\t\thelper_context.bindings,\n\t\thelper_context.name_allocator,\n\t\toptions.target ?? \"client\",\n\t);\n\tconst helpers = replacements.flatMap((replacement) => replacement.helpers ?? []);\n\n\tconst magic = new MagicString(content);\n\n\treplacements.sort((a, b) => b.start - a.start);\n\n\tfor (const r of replacements) {\n\t\tmagic.overwrite(r.start, r.end, r.text);\n\t}\n\n\tconst helper_insertion = inject_helpers(magic, content, helpers, helper_context.bindings);\n\tconst relocations = create_relocations(replacements, helper_insertion);\n\n\treturn {\n\t\tcode: magic.toString(),\n\t\thas_yield: true,\n\t\tmap: create_source_map(magic, filename),\n\t\trelocations,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAsBA,SAAgB,aACf,mBACA,uBACA,oBACA,WAAkC;CACjC,QAAQ;CACR,YAAY;CACZ,kBAAkB;CAClB,QAAQ;CACR,SAAS;CACT,SAAS;AACV,GACA,UAAgC,CAAC,GACxB;CACT,MAAM,mBAAmB,QAAQ,oBAAoB;CACrD,MAAM,eAAe,QAAQ,gBAAgB;CAC7C,MAAM,gBAAgB,QAAQ,iBAAiB;CAE/C,MAAM,oBACL,SAAS,eAAe,mBAC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-1,5 +1,3 @@
|
|
|
1
|
-
import MagicString from "magic-string";
|
|
2
|
-
import ts from "typescript";
|
|
3
1
|
//#region src/diagnostics.ts
|
|
4
2
|
/**
|
|
5
3
|
* Finds best-effort SER usage diagnostics in Svelte component markup.
|
|
@@ -248,14 +246,6 @@ function escape_regexp(value) {
|
|
|
248
246
|
}
|
|
249
247
|
//#endregion
|
|
250
248
|
//#region src/vite.ts
|
|
251
|
-
const remote_client_export_types = /* @__PURE__ */ new Set([
|
|
252
|
-
"query_batch",
|
|
253
|
-
"query_live",
|
|
254
|
-
"query",
|
|
255
|
-
"command",
|
|
256
|
-
"form",
|
|
257
|
-
"prerender"
|
|
258
|
-
]);
|
|
259
249
|
const default_svelte_component_extensions = [".svelte"];
|
|
260
250
|
/**
|
|
261
251
|
* Vite plugin for SvelteKit. The server import plugin rewrites server-side
|
|
@@ -264,7 +254,7 @@ const default_svelte_component_extensions = [".svelte"];
|
|
|
264
254
|
*
|
|
265
255
|
* @example
|
|
266
256
|
* ```ts
|
|
267
|
-
* import { effect } from "svelte-effect-runtime";
|
|
257
|
+
* import { effect } from "svelte-effect-runtime/vite";
|
|
268
258
|
* import { sveltekit } from "@sveltejs/kit/vite";
|
|
269
259
|
*
|
|
270
260
|
* export default defineConfig({ plugins: [effect(), sveltekit()] });
|
|
@@ -431,9 +421,9 @@ function make_remote_client_wrapper_plugin(options) {
|
|
|
431
421
|
}
|
|
432
422
|
config.ssr.noExternal = [no_external, runtime_package].filter((value) => value !== void 0);
|
|
433
423
|
},
|
|
434
|
-
transform(code, id) {
|
|
424
|
+
async transform(code, id) {
|
|
435
425
|
if (!is_remote_module(id) || !code.includes("__sveltekit/remote")) return;
|
|
436
|
-
const rewritten = rewrite_remote_client_exports(code, options);
|
|
426
|
+
const rewritten = await rewrite_remote_client_exports(code, options);
|
|
437
427
|
if (rewritten === code) return;
|
|
438
428
|
return {
|
|
439
429
|
code: rewritten,
|
|
@@ -478,87 +468,21 @@ function make_reserved_helper_warning(names) {
|
|
|
478
468
|
*
|
|
479
469
|
* into an Effect-aware wrapper around the same native function.
|
|
480
470
|
*
|
|
471
|
+
* @example
|
|
472
|
+
* ```ts
|
|
473
|
+
* const rewritten = await rewrite_remote_client_exports(remote_module_code);
|
|
474
|
+
* ```
|
|
475
|
+
*
|
|
481
476
|
* @since 2.0.0
|
|
482
477
|
* @param code - The generated client remote module code.
|
|
483
478
|
* @param options - Optional plugin options.
|
|
484
|
-
* @returns
|
|
479
|
+
* @returns A promise that resolves to the rewritten module code.
|
|
485
480
|
* @internal
|
|
486
481
|
*/
|
|
487
|
-
function rewrite_remote_client_exports(code, options) {
|
|
488
|
-
|
|
489
|
-
const namespace_import = find_remote_namespace_import(source_file);
|
|
490
|
-
if (!namespace_import) return code;
|
|
491
|
-
const remote_exports = collect_remote_client_exports(source_file, code, namespace_import.name);
|
|
492
|
-
if (remote_exports.length === 0) return code;
|
|
493
|
-
const magic = new MagicString(code);
|
|
494
|
-
const injected = [
|
|
495
|
-
[`import { app_dir, base } from "$app/paths/internal/client";`, `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";`].join("\n"),
|
|
496
|
-
[`const __SER___remote_base = \`\${base}/\${app_dir}/remote\`;`, `function __SER___decode_payload(value) { return value; }`].join("\n"),
|
|
497
|
-
options?.debug ? `console.log("[ser] remote client wrappers loaded");` : ""
|
|
498
|
-
].filter(Boolean).join("\n");
|
|
499
|
-
magic.appendRight(namespace_import.statement.end, `\n${injected}`);
|
|
500
|
-
for (const remote_export of remote_exports) magic.overwrite(remote_export.statement.getStart(source_file), remote_export.statement.end, make_remote_export(remote_export.name, remote_export.type, remote_export.native_call));
|
|
501
|
-
return magic.toString();
|
|
502
|
-
}
|
|
503
|
-
function make_remote_export(name, type, native_call) {
|
|
504
|
-
if (type === "command") return `export const ${name} = create_remote_command_adapter(${native_call}, __SER___decode_payload);`;
|
|
505
|
-
if (type === "form") return `export const ${name} = create_remote_form_adapter(${native_call}, __SER___decode_payload, __SER___remote_base);`;
|
|
506
|
-
if (type === "query_live") return `export const ${name} = create_remote_live_query_adapter(${native_call}, __SER___decode_payload);`;
|
|
507
|
-
return `export const ${name} = create_remote_query_adapter(${native_call}, __SER___decode_payload);`;
|
|
508
|
-
}
|
|
509
|
-
function find_remote_namespace_import(source_file) {
|
|
510
|
-
for (const statement of source_file.statements) {
|
|
511
|
-
if (!ts.isImportDeclaration(statement)) continue;
|
|
512
|
-
const namespace_import = get_remote_namespace_import(statement);
|
|
513
|
-
if (namespace_import) return namespace_import;
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
function get_remote_namespace_import(statement) {
|
|
517
|
-
if (!ts.isStringLiteral(statement.moduleSpecifier) || statement.moduleSpecifier.text !== "__sveltekit/remote") return;
|
|
518
|
-
const import_clause = statement.importClause;
|
|
519
|
-
const bindings = import_clause?.namedBindings;
|
|
520
|
-
if (import_clause?.isTypeOnly || !bindings || !ts.isNamespaceImport(bindings)) return;
|
|
521
|
-
return {
|
|
522
|
-
name: bindings.name.text,
|
|
523
|
-
statement
|
|
524
|
-
};
|
|
525
|
-
}
|
|
526
|
-
function collect_remote_client_exports(source_file, code, namespace) {
|
|
527
|
-
return source_file.statements.flatMap((statement) => collect_remote_client_export(source_file, code, namespace, statement));
|
|
528
|
-
}
|
|
529
|
-
function collect_remote_client_export(source_file, code, namespace, statement) {
|
|
530
|
-
if (!ts.isVariableStatement(statement) || !is_export_statement(statement) || !is_const_declaration_list(statement.declarationList) || statement.declarationList.declarations.length !== 1) return [];
|
|
531
|
-
const declaration = statement.declarationList.declarations[0];
|
|
532
|
-
const initializer = declaration.initializer;
|
|
533
|
-
if (!ts.isIdentifier(declaration.name) || !initializer) return [];
|
|
534
|
-
const type = get_remote_client_export_type(initializer, namespace);
|
|
535
|
-
if (!type) return [];
|
|
536
|
-
return [{
|
|
537
|
-
name: declaration.name.text,
|
|
538
|
-
type,
|
|
539
|
-
statement,
|
|
540
|
-
native_call: code.slice(initializer.getStart(source_file), initializer.end)
|
|
541
|
-
}];
|
|
542
|
-
}
|
|
543
|
-
function get_remote_client_export_type(initializer, namespace) {
|
|
544
|
-
if (!ts.isCallExpression(initializer)) return;
|
|
545
|
-
const expression = initializer.expression;
|
|
546
|
-
if (!ts.isPropertyAccessExpression(expression)) return;
|
|
547
|
-
if (!ts.isIdentifier(expression.expression) || expression.expression.text !== namespace) return;
|
|
548
|
-
const type = expression.name.text;
|
|
549
|
-
if (!is_remote_client_export_type(type)) return;
|
|
550
|
-
return type;
|
|
551
|
-
}
|
|
552
|
-
function is_remote_client_export_type(value) {
|
|
553
|
-
return remote_client_export_types.has(value);
|
|
554
|
-
}
|
|
555
|
-
function is_export_statement(statement) {
|
|
556
|
-
return (ts.canHaveModifiers(statement) ? ts.getModifiers(statement) : void 0)?.some((modifier) => modifier.kind === ts.SyntaxKind.ExportKeyword) ?? false;
|
|
557
|
-
}
|
|
558
|
-
function is_const_declaration_list(declaration_list) {
|
|
559
|
-
return (ts.getCombinedNodeFlags(declaration_list) & ts.NodeFlags.Const) !== 0;
|
|
482
|
+
async function rewrite_remote_client_exports(code, options) {
|
|
483
|
+
return (await import("./remote-client-Bj1pZXgq.js")).rewrite_remote_client_exports(code, options);
|
|
560
484
|
}
|
|
561
485
|
//#endregion
|
|
562
486
|
export { rewrite_remote_client_exports as n, effect as t };
|
|
563
487
|
|
|
564
|
-
//# sourceMappingURL=vite-
|
|
488
|
+
//# sourceMappingURL=vite-Dm3bXmR3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite-Dm3bXmR3.js","names":["candidate"],"sources":["../../../modules/svelte-effect-runtime/src/diagnostics.ts","../../../modules/svelte-effect-runtime/src/vite.ts"],"sourcesContent":["/**\n * Warning diagnostic produced by the SER Vite diagnostics plugin.\n */\ninterface Diagnostic {\n\tmessage: string;\n\tline: number;\n\tcolumn: number;\n}\n\ninterface MarkupExpression {\n\tstart: number;\n\tend: number;\n\texpression_text: string;\n\tattribute_name?: string;\n}\n\n/**\n * Finds best-effort SER usage diagnostics in Svelte component markup.\n *\n * @example\n * ```ts\n * const diagnostics = find_svelte_effect_diagnostics(\n * `<button onclick={Effect.gen}>save</button>`,\n * \"Button.svelte\",\n * );\n * ```\n *\n * @since 2.0.0\n * @param code - Svelte component source to scan for suspicious Effect usage.\n * @param filename - Filename used in diagnostic messages.\n * @returns Warning diagnostics with a message and source location.\n */\nexport function find_svelte_effect_diagnostics(\n\tcode: string,\n\tfilename: string,\n): Array<{ message: string; line: number; column: number }> {\n\tconst effect_names = find_effect_local_names(code);\n\tconst expressions = find_markup_expressions(code);\n\n\treturn expressions.flatMap((expression) =>\n\t\tmake_expression_diagnostics(code, filename, effect_names, expression),\n\t);\n}\n\nfunction find_effect_local_names(code: string): Set<string> {\n\tconst names = new Set<string>([\"Effect\"]);\n\tconst script_pattern = /<script\\b[^>]*>([\\s\\S]*?)<\\/script\\s*>/gi;\n\n\tfor (const script_match of code.matchAll(script_pattern)) {\n\t\tconst script = script_match[1];\n\t\tconst import_pattern = /import\\s+(type\\s+)?\\{([^}]+)\\}\\s+from\\s+[\"']effect[\"']/g;\n\n\t\tfor (const import_match of script.matchAll(import_pattern)) {\n\t\t\tconst is_type_only_import = import_match[1] !== undefined;\n\t\t\tconst specifiers = import_match[2].split(\",\");\n\n\t\t\tif (is_type_only_import) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tfor (const specifier of specifiers) {\n\t\t\t\tconst local_name = parse_effect_import_local_name(specifier);\n\n\t\t\t\tif (local_name) {\n\t\t\t\t\tnames.add(local_name);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn names;\n}\n\nfunction parse_effect_import_local_name(specifier: string): string | undefined {\n\tconst trimmed = specifier.trim();\n\tconst match = trimmed.match(/^Effect(?:\\s+as\\s+([A-Za-z_$][\\w$]*))?$/);\n\n\tif (!match) {\n\t\treturn undefined;\n\t}\n\n\treturn match[1] ?? \"Effect\";\n}\n\nfunction find_markup_expressions(code: string): MarkupExpression[] {\n\tconst expressions: MarkupExpression[] = [];\n\tlet cursor = 0;\n\n\twhile (cursor < code.length) {\n\t\tconst open = code.indexOf(\"{\", cursor);\n\n\t\tif (open === -1) {\n\t\t\tbreak;\n\t\t}\n\n\t\tif (is_inside_svelte_excluded_block(code, open)) {\n\t\t\tcursor = open + 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst close = find_closing_brace(code, open + 1);\n\n\t\tif (close === -1) {\n\t\t\tcursor = open + 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\texpressions.push({\n\t\t\tstart: open,\n\t\t\tend: close,\n\t\t\texpression_text: code.slice(open + 1, close).trim(),\n\t\t\tattribute_name: find_attribute_name_before_expression(code, open),\n\t\t});\n\n\t\tcursor = close + 1;\n\t}\n\n\treturn expressions;\n}\n\nfunction make_expression_diagnostics(\n\tcode: string,\n\tfilename: string,\n\teffect_names: Set<string>,\n\texpression: MarkupExpression,\n): Diagnostic[] {\n\tconst attribute_name = expression.attribute_name;\n\tconst expression_text = expression.expression_text;\n\tconst is_event_attribute =\n\t\tattribute_name !== undefined && is_event_attribute_name(attribute_name);\n\tconst is_attribute = attribute_name !== undefined;\n\tconst loc = get_line_column(code, expression.start);\n\n\tif (!contains_effect_reference(expression_text, effect_names)) {\n\t\treturn [];\n\t}\n\n\tif (starts_with_yield_star(expression_text)) {\n\t\treturn [];\n\t}\n\n\tif (\n\t\tis_event_attribute &&\n\t\tis_callback_expression(expression_text) &&\n\t\tcontains_yield_star(expression_text)\n\t) {\n\t\treturn [\n\t\t\tmake_diagnostic(\n\t\t\t\tloc,\n\t\t\t\tmake_hidden_event_yield_warning(filename, attribute_name, expression_text),\n\t\t\t),\n\t\t];\n\t}\n\n\tif (contains_effect_runner(expression_text, effect_names)) {\n\t\treturn [\n\t\t\tmake_diagnostic(\n\t\t\t\tloc,\n\t\t\t\tmake_explicit_runner_warning(filename, attribute_name, expression_text),\n\t\t\t),\n\t\t];\n\t}\n\n\tif (is_bare_effect_gen(expression_text, effect_names)) {\n\t\treturn [\n\t\t\tmake_diagnostic(\n\t\t\t\tloc,\n\t\t\t\tmake_bare_effect_gen_warning(filename, attribute_name, expression_text),\n\t\t\t),\n\t\t];\n\t}\n\n\tif (is_event_attribute && is_callback_expression(expression_text)) {\n\t\treturn [\n\t\t\tmake_diagnostic(\n\t\t\t\tloc,\n\t\t\t\tmake_event_callback_returns_effect_warning(\n\t\t\t\t\tfilename,\n\t\t\t\t\tattribute_name,\n\t\t\t\t\texpression_text,\n\t\t\t\t),\n\t\t\t),\n\t\t];\n\t}\n\n\tif (is_event_attribute) {\n\t\treturn [\n\t\t\tmake_diagnostic(\n\t\t\t\tloc,\n\t\t\t\tmake_event_attribute_effect_warning(filename, attribute_name, expression_text),\n\t\t\t),\n\t\t];\n\t}\n\n\tif (is_attribute) {\n\t\treturn [\n\t\t\tmake_diagnostic(\n\t\t\t\tloc,\n\t\t\t\tmake_attribute_effect_warning(filename, attribute_name, expression_text),\n\t\t\t),\n\t\t];\n\t}\n\n\treturn [make_diagnostic(loc, make_sync_markup_effect_warning(filename, expression_text))];\n}\n\nfunction make_diagnostic(loc: { line: number; column: number }, message: string): Diagnostic {\n\treturn {\n\t\tmessage,\n\t\tline: loc.line,\n\t\tcolumn: loc.column,\n\t};\n}\n\nfunction make_hidden_event_yield_warning(\n\tfilename: string,\n\tattribute_name: string,\n\texpression_text: string,\n): string {\n\treturn [\n\t\t`[svelte-effect-runtime] Detected yield* hidden inside an event callback.`,\n\t\t`${filename}: ${attribute_name}={${expression_text}}`,\n\t\t`SER can only lower yield* at the event attribute boundary.`,\n\t\t`Write the event expression directly, for example: ${attribute_name}={yield* save()}`,\n\t].join(\"\\n\");\n}\n\nfunction make_explicit_runner_warning(\n\tfilename: string,\n\tattribute_name: string | undefined,\n\texpression_text: string,\n): string {\n\tconst location = attribute_name\n\t\t? `${attribute_name}={${expression_text}}`\n\t\t: `{${expression_text}}`;\n\n\treturn [\n\t\t`[svelte-effect-runtime] Detected an explicit Effect runner inside Svelte markup.`,\n\t\t`${filename}: ${location}`,\n\t\t`Explicit runners bypass SER cancellation and error handling for markup effects.`,\n\t\t`Prefer yield* so SER can manage the Effect lifecycle.`,\n\t].join(\"\\n\");\n}\n\nfunction make_bare_effect_gen_warning(\n\tfilename: string,\n\tattribute_name: string | undefined,\n\texpression_text: string,\n): string {\n\tconst location = attribute_name\n\t\t? `${attribute_name}={${expression_text}}`\n\t\t: `{${expression_text}}`;\n\tconst fixed = attribute_name\n\t\t? `${attribute_name}={yield* ${expression_text}(function* () { ... })}`\n\t\t: `{yield* ${expression_text}(function* () { ... })}`;\n\n\treturn [\n\t\t`[svelte-effect-runtime] Detected Effect.gen used as a value instead of an Effect program.`,\n\t\t`${filename}: ${location}`,\n\t\t`${expression_text} is a constructor, not the result of running a generator.`,\n\t\t`Use: ${fixed}`,\n\t].join(\"\\n\");\n}\n\nfunction make_event_callback_returns_effect_warning(\n\tfilename: string,\n\tattribute_name: string,\n\texpression_text: string,\n): string {\n\treturn [\n\t\t`[svelte-effect-runtime] Detected an event callback that returns an Effect but does not run it.`,\n\t\t`${filename}: ${attribute_name}={${expression_text}}`,\n\t\t`Svelte will call the callback and receive an Effect value, but SER will not manage it from inside the callback.`,\n\t\t`Use yield* at the event attribute boundary or explicitly run the Effect if you really want to bypass SER.`,\n\t].join(\"\\n\");\n}\n\nfunction make_event_attribute_effect_warning(\n\tfilename: string,\n\tattribute_name: string,\n\texpression_text: string,\n): string {\n\tconst fixed = `${attribute_name}={yield* ${expression_text}}`;\n\n\treturn [\n\t\t`[svelte-effect-runtime] Detected an event attribute that looks like an Effect but is not written with yield*.`,\n\t\t`${filename}: ${attribute_name}={${expression_text}}`,\n\t\t`If you are trying to use Effect in this event handler, use yield* at the beginning.`,\n\t\t`Use: ${fixed}`,\n\t].join(\"\\n\");\n}\n\nfunction make_attribute_effect_warning(\n\tfilename: string,\n\tattribute_name: string,\n\texpression_text: string,\n): string {\n\tconst fixed = `${attribute_name}={yield* ${expression_text}}`;\n\n\treturn [\n\t\t`[svelte-effect-runtime] Detected an attribute value that looks like an Effect but is not written with yield*.`,\n\t\t`${filename}: ${attribute_name}={${expression_text}}`,\n\t\t`Svelte attributes need the resolved Effect value, not the Effect object itself.`,\n\t\t`Use: ${fixed}`,\n\t].join(\"\\n\");\n}\n\nfunction make_sync_markup_effect_warning(filename: string, expression_text: string): string {\n\treturn [\n\t\t`[svelte-effect-runtime] Detected a markup expression that creates an Effect but is not written with yield*.`,\n\t\t`${filename}: {${expression_text}}`,\n\t\t`This expression will produce an Effect value, not its result.`,\n\t\t`Use yield* where Svelte expects the resolved value.`,\n\t].join(\"\\n\");\n}\n\nfunction contains_effect_reference(expression_text: string, effect_names: Set<string>): boolean {\n\tconst name_pattern = make_effect_name_pattern(effect_names);\n\tconst effect_pattern = new RegExp(\n\t\t`\\\\b(?:${name_pattern})\\\\.(?:gen|succeed|fail|try|tryPromise|promise|sync|all|void|log|runPromise|runSync|runFork)\\\\b`,\n\t);\n\n\treturn effect_pattern.test(expression_text);\n}\n\nfunction contains_effect_runner(expression_text: string, effect_names: Set<string>): boolean {\n\tconst name_pattern = make_effect_name_pattern(effect_names);\n\tconst runner_pattern = new RegExp(`\\\\b(?:${name_pattern})\\\\.run(?:Promise|Sync|Fork)\\\\b`);\n\n\treturn runner_pattern.test(expression_text);\n}\n\nfunction is_bare_effect_gen(expression_text: string, effect_names: Set<string>): boolean {\n\tconst name_pattern = make_effect_name_pattern(effect_names);\n\tconst bare_gen_pattern = new RegExp(`^(?:${name_pattern})\\\\.gen$`);\n\n\treturn bare_gen_pattern.test(expression_text);\n}\n\nfunction make_effect_name_pattern(effect_names: Set<string>): string {\n\treturn [...effect_names]\n\t\t.map(escape_regexp)\n\t\t.sort((a, b) => b.length - a.length)\n\t\t.join(\"|\");\n}\n\nfunction starts_with_yield_star(expression_text: string): boolean {\n\treturn /^yield\\s*\\*/.test(expression_text);\n}\n\nfunction contains_yield_star(expression_text: string): boolean {\n\treturn /\\byield\\s*\\*/.test(expression_text);\n}\n\nfunction is_callback_expression(expression_text: string): boolean {\n\treturn (\n\t\t/^(?:async\\s+)?(?:\\([^)]*\\)|[A-Za-z_$][\\w$]*)\\s*=>/.test(expression_text) ||\n\t\t/^(?:async\\s+)?function\\b/.test(expression_text)\n\t);\n}\n\nfunction is_event_attribute_name(name: string): boolean {\n\treturn /^on(?::[A-Za-z_$][\\w$-]*|[a-z][\\w$-]*)$/.test(name);\n}\n\nfunction find_attribute_name_before_expression(code: string, open: number): string | undefined {\n\tconst tag_start = code.lastIndexOf(\"<\", open);\n\tconst last_tag_end = code.lastIndexOf(\">\", open);\n\n\tif (tag_start === -1 || tag_start < last_tag_end) {\n\t\treturn undefined;\n\t}\n\n\tconst before_expression = code.slice(tag_start + 1, open);\n\tconst match = before_expression.match(/(?:^|\\s)([A-Za-z_$:][\\w$:-]*)\\s*=\\s*$/);\n\n\treturn match?.[1];\n}\n\nfunction is_inside_svelte_excluded_block(code: string, pos: number): boolean {\n\tconst script = find_svelte_tag_range(code, \"script\", pos);\n\tconst style = find_svelte_tag_range(code, \"style\", pos);\n\n\treturn (\n\t\t(script !== undefined && pos < script.end && pos > script.start) ||\n\t\t(style !== undefined && pos < style.end && pos > style.start)\n\t);\n}\n\nfunction find_svelte_tag_range(\n\tcode: string,\n\ttag: string,\n\tafter_pos: number,\n): { start: number; end: number } | undefined {\n\tconst pattern = new RegExp(`<${tag}\\\\b[^>]*>([\\\\s\\\\S]*?)<\\\\/${tag}\\\\s*>`, \"gi\");\n\n\tfor (const match of code.matchAll(pattern)) {\n\t\tif (match.index === undefined) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst end = match.index + match[0].length;\n\n\t\tif (match.index <= after_pos && after_pos < end) {\n\t\t\treturn { start: match.index, end };\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\nfunction find_closing_brace(code: string, start: number): number {\n\tlet depth = 0;\n\n\tfor (let i = start; i < code.length; i += 1) {\n\t\tconst ch = code[i];\n\n\t\tif (ch === \"{\" && code[i - 1] !== \"$\") {\n\t\t\tdepth += 1;\n\t\t} else if (ch === \"}\") {\n\t\t\tif (depth === 0) {\n\t\t\t\treturn i;\n\t\t\t}\n\n\t\t\tdepth -= 1;\n\t\t} else if (ch === \"'\" || ch === '\"' || ch === \"`\") {\n\t\t\ti = skip_string(code, i, ch);\n\n\t\t\tif (i === -1) {\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t} else if (ch === \"/\" && code[i + 1] === \"/\") {\n\t\t\ti = skip_line_comment(code, i);\n\t\t} else if (ch === \"/\" && code[i + 1] === \"*\") {\n\t\t\ti = skip_block_comment(code, i);\n\n\t\t\tif (i === -1) {\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn -1;\n}\n\nfunction skip_string(code: string, start: number, quote: string): number {\n\tfor (let i = start + 1; i < code.length; i += 1) {\n\t\tif (code[i] === \"\\\\\") {\n\t\t\ti += 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (code[i] === quote) {\n\t\t\treturn i;\n\t\t}\n\t}\n\n\treturn -1;\n}\n\nfunction skip_line_comment(code: string, start: number): number {\n\tfor (let i = start + 2; i < code.length; i += 1) {\n\t\tif (code[i] === \"\\n\") {\n\t\t\treturn i;\n\t\t}\n\t}\n\n\treturn code.length;\n}\n\nfunction skip_block_comment(code: string, start: number): number {\n\tfor (let i = start + 2; i < code.length; i += 1) {\n\t\tif (code[i] === \"*\" && code[i + 1] === \"/\") {\n\t\t\treturn i + 1;\n\t\t}\n\t}\n\n\treturn -1;\n}\n\nfunction get_line_column(code: string, position: number): { line: number; column: number } {\n\tconst before = code.slice(0, position);\n\tconst lines = before.split(\"\\n\");\n\tconst line = lines.length;\n\tconst column = lines.at(-1)?.length ?? 0;\n\n\treturn { line, column };\n}\n\nfunction escape_regexp(value: string): string {\n\treturn value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n","import { find_svelte_effect_diagnostics } from \"./diagnostics.ts\";\nimport 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\t/** Whether to emit debug logging in the generated remote client module. */\n\tdebug?: boolean;\n}\n\ninterface SvelteComponentModuleFilter {\n\tset_extensions(extensions: readonly string[]): void;\n\tis_module(id: string): boolean;\n}\n\ninterface VitePluginSvelteApi {\n\toptions?: {\n\t\textensions?: readonly unknown[];\n\t};\n}\n\ntype VitePluginSvelte = Plugin & {\n\tapi?: VitePluginSvelteApi;\n};\n\ntype VitePluginSvelteWithExtensions = Plugin & {\n\tapi: {\n\t\toptions: {\n\t\t\textensions: readonly string[];\n\t\t};\n\t};\n};\n\nconst default_svelte_component_extensions = [\".svelte\"] as const;\n\n/**\n * Vite plugin for SvelteKit. The server import plugin rewrites server-side\n * imports to the server entrypoint; the remote client plugin wraps SvelteKit's\n * generated client remote exports in Effect-returning adapters.\n *\n * @example\n * ```ts\n * import { effect } from \"svelte-effect-runtime/vite\";\n * import { sveltekit } from \"@sveltejs/kit/vite\";\n *\n * export default defineConfig({ plugins: [effect(), sveltekit()] });\n * ```\n *\n * @since 2.0.0\n * @param options - Optional configuration.\n * @returns Vite plugins that integrate the runtime with SvelteKit.\n */\nexport function effect(options?: EffectOptions): Plugin[] {\n\tconst component_filter = make_svelte_component_module_filter();\n\n\treturn [\n\t\tmake_diagnostics_plugin(component_filter),\n\t\tmake_reserved_helper_guard_plugin(component_filter),\n\t\tmake_svelte_transform_plugin(component_filter),\n\t\tmake_server_rewrite_plugin(),\n\t\tmake_remote_client_wrapper_plugin(options),\n\t];\n}\n\nfunction make_diagnostics_plugin(component_filter: SvelteComponentModuleFilter): Plugin {\n\tconst warned_diagnostics = new Set<string>();\n\n\treturn {\n\t\tname: \"svelte-effect-runtime:diagnostics\",\n\n\t\ttransform(code: string, id: string) {\n\t\t\tif (!component_filter.is_module(id)) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst clean_id = id.split(\"?\")[0] ?? id;\n\t\t\tconst diagnostics = find_svelte_effect_diagnostics(code, clean_id);\n\n\t\t\tfor (const diagnostic of diagnostics) {\n\t\t\t\tconst diagnostic_key = [\n\t\t\t\t\tclean_id,\n\t\t\t\t\tdiagnostic.line,\n\t\t\t\t\tdiagnostic.column,\n\t\t\t\t\tdiagnostic.message,\n\t\t\t\t].join(\":\");\n\n\t\t\t\tif (warned_diagnostics.has(diagnostic_key)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\twarned_diagnostics.add(diagnostic_key);\n\n\t\t\t\tthis.warn({\n\t\t\t\t\tid: clean_id,\n\t\t\t\t\tmessage: diagnostic.message,\n\t\t\t\t\tloc: {\n\t\t\t\t\t\tline: diagnostic.line,\n\t\t\t\t\t\tcolumn: diagnostic.column,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn undefined;\n\t\t},\n\t};\n}\n\nfunction make_reserved_helper_guard_plugin(component_filter: SvelteComponentModuleFilter): Plugin {\n\treturn {\n\t\tname: \"svelte-effect-runtime:reserved-helper-guard\",\n\n\t\ttransform(code: string, id: string) {\n\t\t\tif (!component_filter.is_module(id) || !has_ser_syntax(code)) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst reserved_names = find_reserved_helper_names(code);\n\n\t\t\tif (reserved_names.length === 0) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tthis.warn(make_reserved_helper_warning(reserved_names));\n\n\t\t\treturn undefined;\n\t\t},\n\t};\n}\n\nfunction make_svelte_transform_plugin(component_filter: SvelteComponentModuleFilter): Plugin {\n\treturn {\n\t\tname: \"svelte-effect-runtime:svelte-transform\",\n\n\t\tconfigResolved(config) {\n\t\t\tconst extensions = find_svelte_component_extensions(config.plugins);\n\t\t\tconst conflicting_plugin_names = find_pre_transform_plugin_names(config.plugins);\n\n\t\t\tif (extensions) {\n\t\t\t\tcomponent_filter.set_extensions(extensions);\n\t\t\t}\n\n\t\t\tif (conflicting_plugin_names.length === 0) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconfig.logger.info(make_pre_transform_plugin_notice(conflicting_plugin_names));\n\t\t},\n\n\t\tasync transform(code: string, id: string, options?: { ssr?: boolean }) {\n\t\t\tif (!component_filter.is_module(id)) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst { transform_svelte_effect } = await import(\"./runtime/transform.ts\");\n\t\t\tconst result = transform_svelte_effect(code, id, {\n\t\t\t\ttarget: options?.ssr ? \"server\" : \"client\",\n\t\t\t});\n\n\t\t\tif (result.code === code) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\treturn { code: result.code, map: null };\n\t\t},\n\t};\n}\n\nfunction make_svelte_component_module_filter(): SvelteComponentModuleFilter {\n\tlet extensions: readonly string[] = default_svelte_component_extensions;\n\n\treturn {\n\t\tset_extensions(next_extensions) {\n\t\t\tconst normalized_extensions = normalize_svelte_component_extensions(next_extensions);\n\n\t\t\tif (normalized_extensions.length === 0) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\textensions = normalized_extensions;\n\t\t},\n\n\t\tis_module(id) {\n\t\t\treturn is_svelte_component_module(id, extensions);\n\t\t},\n\t};\n}\n\nfunction normalize_svelte_component_extensions(extensions: readonly string[]): string[] {\n\tconst normalized_extensions = extensions\n\t\t.filter((extension) => extension.length > 0)\n\t\t.map((extension) => (extension.startsWith(\".\") ? extension : `.${extension}`));\n\n\treturn [...new Set(normalized_extensions)];\n}\n\nfunction find_svelte_component_extensions(\n\tplugins: readonly Plugin[],\n): readonly string[] | undefined {\n\tconst svelte_plugin = plugins.find(has_svelte_component_extensions);\n\n\treturn svelte_plugin?.api?.options?.extensions;\n}\n\nfunction has_svelte_component_extensions(plugin: Plugin): plugin is VitePluginSvelteWithExtensions {\n\tconst candidate = plugin as VitePluginSvelte;\n\tconst extensions = candidate.api?.options?.extensions;\n\n\tif (!plugin.name.startsWith(\"vite-plugin-svelte\")) {\n\t\treturn false;\n\t}\n\n\treturn (\n\t\tArray.isArray(extensions) && extensions.every((extension) => typeof extension === \"string\")\n\t);\n}\n\nfunction find_pre_transform_plugin_names(plugins: readonly Plugin[]): string[] {\n\treturn plugins\n\t\t.filter(\n\t\t\t(plugin) =>\n\t\t\t\t!plugin.name.startsWith(\"svelte-effect-runtime:\") &&\n\t\t\t\t!is_known_framework_pre_transform_plugin(plugin.name) &&\n\t\t\t\thas_pre_transform_priority(plugin),\n\t\t)\n\t\t.map((plugin) => plugin.name);\n}\n\nconst ansi_reset = \"\\x1b[0m\";\nconst ansi_light_green = \"\\x1b[92m\";\n\nfunction make_pre_transform_plugin_notice(plugin_names: readonly string[]): string {\n\tconst formatted_plugins = plugin_names.map((plugin_name) => ` - ${plugin_name}`).join(\"\\n\");\n\n\treturn [\n\t\t`${ansi_light_green}[svelte-effect-runtime]${ansi_reset} Svelte Effect Runtime noticed possible Vite plugin ordering conflicts.`,\n\t\t\"\",\n\t\t\"These plugins run before normal Svelte component transforms:\",\n\t\tformatted_plugins,\n\t\t\"\",\n\t\t\"This is usually fine, but if you see Svelte parser errors around <script effect>\",\n\t\t\"or yield* in components, one of those plugins may be reading component files before\",\n\t\t\"SER has lowered its syntax.\",\n\t].join(\"\\n\");\n}\n\nfunction is_known_framework_pre_transform_plugin(name: string): boolean {\n\treturn name.startsWith(\"vite:\") || name === \"vite-plugin-svelte:preprocess\";\n}\n\nfunction has_pre_transform_priority(plugin: Plugin): boolean {\n\tif (plugin.enforce === \"pre\" && plugin.transform) {\n\t\treturn true;\n\t}\n\n\tif (\n\t\ttypeof plugin.transform === \"object\" &&\n\t\tplugin.transform !== null &&\n\t\t\"order\" in plugin.transform &&\n\t\tplugin.transform.order === \"pre\"\n\t) {\n\t\treturn true;\n\t}\n\n\treturn false;\n}\n\nfunction make_server_rewrite_plugin(): Plugin {\n\treturn {\n\t\tname: \"svelte-effect-runtime:server-imports\",\n\n\t\tconfig() {\n\t\t\treturn { optimizeDeps: { exclude: [\"svelte-effect-runtime\"] } };\n\t\t},\n\n\t\ttransform(code: string, id: string) {\n\t\t\tif (!is_server_runtime_module(id)) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst rewritten = code\n\t\t\t\t.replace(\n\t\t\t\t\t/from\\s+[\"']svelte-effect-runtime[\"']/g,\n\t\t\t\t\t`from \"svelte-effect-runtime/server\"`,\n\t\t\t\t)\n\t\t\t\t.replace(\n\t\t\t\t\t/from\\s+[\"']svelte-effect-runtime\\/internal\\/generators[\"']/g,\n\t\t\t\t\t`from \"svelte-effect-runtime/server\"`,\n\t\t\t\t);\n\n\t\t\tif (rewritten === code) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\treturn { code: rewritten, map: null };\n\t\t},\n\t};\n}\n\nfunction make_remote_client_wrapper_plugin(options?: EffectOptions): Plugin {\n\treturn {\n\t\tname: \"svelte-effect-runtime:remote-client\",\n\t\tenforce: \"post\",\n\n\t\tconfig() {\n\t\t\treturn { ssr: { noExternal: [\"svelte-effect-runtime\"] } };\n\t\t},\n\n\t\tconfigResolved(config) {\n\t\t\tconst no_external = config.ssr.noExternal;\n\t\t\tconst runtime_package = \"svelte-effect-runtime\";\n\n\t\t\tif (no_external === true) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (Array.isArray(no_external)) {\n\t\t\t\tconst has_runtime_package = no_external.some((entry) => entry === runtime_package);\n\n\t\t\t\tif (!has_runtime_package) {\n\t\t\t\t\tno_external.push(runtime_package);\n\t\t\t\t}\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconfig.ssr.noExternal = [no_external, runtime_package].filter(\n\t\t\t\t(value): value is string | RegExp => value !== undefined,\n\t\t\t);\n\t\t},\n\n\t\tasync transform(code: string, id: string) {\n\t\t\tif (!is_remote_module(id) || !code.includes(\"__sveltekit/remote\")) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst rewritten = await rewrite_remote_client_exports(code, options);\n\n\t\t\tif (rewritten === code) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\treturn { code: rewritten, map: null };\n\t\t},\n\t};\n}\n\nfunction is_server_runtime_module(id: string): boolean {\n\tconst [filename] = id.split(\"?\", 2);\n\n\treturn (\n\t\t/\\.(server|remote)(?:\\.[cm])?\\.[jt]s$/.test(filename) ||\n\t\t/(?:^|[\\\\/])hooks\\.server(?:\\.[cm])?\\.[jt]s$/.test(filename)\n\t);\n}\n\nfunction is_remote_module(id: string): boolean {\n\treturn /\\.(remote|remote\\.[cm]?)\\.[jt]s(?:\\?.*)?$/.test(id) || id.includes(\".remote.\");\n}\n\nfunction is_svelte_component_module(id: string, extensions: readonly string[]): boolean {\n\tconst [filename, query = \"\"] = id.split(\"?\", 2);\n\n\tif (!extensions.some((extension) => filename.endsWith(extension))) {\n\t\treturn false;\n\t}\n\n\tif (query.length === 0) {\n\t\treturn true;\n\t}\n\n\tconst params = new URLSearchParams(query);\n\tconst allowed_params = [\"t\", \"v\"];\n\n\treturn [...params.keys()].every((key) => allowed_params.includes(key));\n}\n\nfunction has_ser_syntax(code: string): boolean {\n\treturn /\\byield\\s*\\*/.test(code) || /<script\\b[^>]*\\beffect(?:[\\s=>]|$)/.test(code);\n}\n\nfunction find_reserved_helper_names(code: string): string[] {\n\tconst script_segments = [...code.matchAll(/<script\\b[^>]*>([\\s\\S]*?)<\\/script\\s*>/gi)].map(\n\t\t(match) => match[1] ?? \"\",\n\t);\n\tconst markup_segments = [...code.matchAll(/\\{[^{}]*(?:Dispatcher|Code)[^{}]*\\}/g)].map(\n\t\t(match) => match[0],\n\t);\n\tconst search_segments = [...script_segments, ...markup_segments];\n\n\treturn [\"Dispatcher\", \"Code\"].filter((name) =>\n\t\tsearch_segments.some((segment) => new RegExp(`\\\\b${name}\\\\b`).test(segment)),\n\t);\n}\n\nfunction make_reserved_helper_warning(names: string[]): string {\n\tconst quoted_names = names.map((name) => `\\`${name}\\``);\n\tconst subject =\n\t\tquoted_names.length === 1\n\t\t\t? quoted_names[0]\n\t\t\t: `${quoted_names.slice(0, -1).join(\", \")} and ${\n\t\t\t\t\tquoted_names[quoted_names.length - 1]\n\t\t\t\t}`;\n\tconst verb = names.length === 1 ? \"is\" : \"are\";\n\n\treturn [\n\t\t`[svelte-effect-runtime] ${subject} ${verb} reserved for generated markup helpers.`,\n\t\t`Rename or alias local bindings that use ${subject} before using SER syntax in this component.`,\n\t].join(\" \");\n}\n\n/**\n * Rewrites SvelteKit's generated client remote module from:\n *\n * `export const get_post = __remote.query(\"hash/get_post\")`\n *\n * into an Effect-aware wrapper around the same native function.\n *\n * @example\n * ```ts\n * const rewritten = await rewrite_remote_client_exports(remote_module_code);\n * ```\n *\n * @since 2.0.0\n * @param code - The generated client remote module code.\n * @param options - Optional plugin options.\n * @returns A promise that resolves to the rewritten module code.\n * @internal\n */\nexport async function rewrite_remote_client_exports(\n\tcode: string,\n\toptions?: EffectOptions,\n): Promise<string> {\n\tconst remote_client = await import(\"./vite/remote-client.ts\");\n\n\treturn remote_client.rewrite_remote_client_exports(code, options);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAgCA,SAAgB,+BACf,MACA,UAC2D;CAC3D,MAAM,eAAe,wBAAwB,IAAI;CAGjD,OAFoB,wBAAwB,IAE3B,CAAC,CAAC,SAAS,eAC3B,4BAA4B,MAAM,UAAU,cAAc,UAAU,CACrE;AACD;AAEA,SAAS,wBAAwB,MAA2B;CAC3D,MAAM,wBAAQ,IAAI,IAAY,CAAC,QAAQ,CAAC;CAGxC,KAAK,MAAM,gBAAgB,KAAK,SAAS,0CAAc,GAAG;EACzD,MAAM,SAAS,aAAa;EAG5B,KAAK,MAAM,gBAAgB,OAAO,SAAS,yDAAc,GAAG;GAC3D,MAAM,sBAAsB,aAAa,OAAO,KAAA;GAChD,MAAM,aAAa,aAAa,EAAE,CAAC,MAAM,GAAG;GAE5C,IAAI,qBACH;GAGD,KAAK,MAAM,aAAa,YAAY;IACn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AEA,SAAS,2BAA2B,MAAwB;CAC3D,MAAM,kBAAkB,CAAC,GAAG,KAAK,SAAS,0CAA0C,CAAC,CAAC,CAAC,KACrF,UAAU,MAAM,MAAM,EACxB;CACA,MAAM,kBAAkB,CAAC,GAAG,KAAK,SAAS,sCAAsC,CAAC,CAAC,CAAC,KACjF,UAAU,MAAM,EAClB;CACA,MAAM,kBAAkB,CAAC,GAAG,iBAAiB,GAAG,eAAe;CAE/D,OAAO,CAAC,cAAc,MAAM,CAAC,CAAC,QAAQ,SACrC,gBAAgB,MAAM,YAAY,IAAI,OAAO,MAAM,KAAK,IAAI,CAAC,CAAC,KAAK,OAAO,CAAC,CAC5E;AACD;AAEA,SAAS,6BAA6B,OAAyB;CAC9D,MAAM,eAAe,MAAM,KAAK,SAAS,KAAK,KAAK,GAAG;CACtD,MAAM,UACL,aAAa,WAAW,IACrB,aAAa,KACb,GAAG,aAAa,MAAM,GAAG,EAAE,CAAC,CAAC,KAAK,IAAI,EAAE,OACxC,aAAa,aAAa,SAAS;CAIvC,OAAO,CACN,2BAA2B,QAAQ,GAHvB,MAAM,WAAW,IAAI,OAAO,MAGG,0CAC3C,2CAA2C,QAAQ,4CACpD,CAAC,CAAC,KAAK,GAAG;AACX;;;;;;;;;;;;;;;;;;;AAoBA,eAAsB,8BACrB,MACA,SACkB;CAGlB,QAAO,MAFqB,OAAO,+BAAA,CAEd,8BAA8B,MAAM,OAAO;AACjE"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as transform_markup_effect } from "../chunks/transform-
|
|
1
|
+
import { t as transform_markup_effect } from "../chunks/transform-CEK6Ccll.js";
|
|
2
2
|
export { transform_markup_effect };
|
package/.dist/mod.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { A as YieldStarInEventCallbackError, C as UncheckedLiveQueryHandlerMissingError, D as UnsupportedMarkupEffectPositionError, E as UnknownRuntimeError, O as UnsupportedRemoteFormResponseError, S as UncheckedFormHandlerMissingError, T as UncheckedQueryHandlerMissingError, _ as RuntimeAlreadyInitializedError, a as DispatcherDisposedError, b as SvelteKitServerExportUnavailableError, c as InvalidLiveQueryReturnError, d as PreprocessError, f as RemoteErrorDecodeError, g as RequestEventUnavailableError, h as RemoteHelperError, i as BatchQueryHandlerMissingError, k as VitePreTransformPluginConflictError, l as InvalidQueryFactoryError, m as RemoteHelperContextError, n as AsyncEffectInSyncRuneError, o as InvalidCommandFactoryError, p as RemoteFormEndpointMissingError, r as AwaitInEffectWorkError, s as InvalidLiveQueryFactoryError, t as AsyncEffectInEventCallbackError, u as InvalidRemoteFormResponseError, v as RuntimeError, w as UncheckedPrerenderHandlerMissingError, x as UncheckedCommandHandlerMissingError, y as ServerOnlyImportError } from "./chunks/errors-Dcf0MVbq.js";
|
|
2
2
|
import { t as Dispatcher } from "./chunks/dispatcher-pHH4JcFR.js";
|
|
3
3
|
import { is_form_error, is_remote_http_error, is_remote_transport_error, is_remote_validation_error } from "./remote/shared.js";
|
|
4
|
-
import { t as effect } from "./chunks/vite-
|
|
4
|
+
import { t as effect } from "./chunks/vite-Dm3bXmR3.js";
|
|
5
5
|
//#region src/mod.ts
|
|
6
6
|
/**
|
|
7
7
|
* Public API surface for `svelte-effect-runtime`.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { d as PreprocessError, r as AwaitInEffectWorkError } from "../chunks/errors-Dcf0MVbq.js";
|
|
2
|
-
import { a as is_yield_star_expression, c as slice, d as collect_top_level_binding_names, f as has_local_import_binding, i as find_yield_star_node, l as slice_start, n as collect_yield_star_nodes, o as validate_rune_yield_usage, p as make_imports, r as contains_top_level_await, s as create_source_map, t as transform_markup_effect, u as collect_free_identifiers } from "../chunks/transform-
|
|
2
|
+
import { a as is_yield_star_expression, c as slice, d as collect_top_level_binding_names, f as has_local_import_binding, i as find_yield_star_node, l as slice_start, n as collect_yield_star_nodes, o as validate_rune_yield_usage, p as make_imports, r as contains_top_level_await, s as create_source_map, t as transform_markup_effect, u as collect_free_identifiers } from "../chunks/transform-CEK6Ccll.js";
|
|
3
3
|
import { contains_top_level_yield_star } from "../detect.js";
|
|
4
|
-
import MagicString from "magic-string";
|
|
5
4
|
import ts from "typescript";
|
|
5
|
+
import MagicString from "magic-string";
|
|
6
6
|
//#region src/script-transform/runtime-block.ts
|
|
7
7
|
/**
|
|
8
8
|
* Builds the runtime blocks appended to lowered script effect code with
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
interface RemoteClientRewriteOptions {
|
|
2
|
+
debug?: boolean;
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Rewrites SvelteKit's generated client remote module into Effect-aware
|
|
6
|
+
* wrappers while preserving the native remote factory calls.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* const rewritten = rewrite_remote_client_exports(
|
|
11
|
+
* `export const get_post = __remote.query("hash/get_post")`,
|
|
12
|
+
* );
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* @since 2.0.0
|
|
16
|
+
* @param code - Generated SvelteKit remote client module source to inspect and
|
|
17
|
+
* rewrite.
|
|
18
|
+
* @param options - Optional rewrite options forwarded from the SER Vite plugin.
|
|
19
|
+
* @returns The rewritten module source, or the original source when no remote
|
|
20
|
+
* exports are found.
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
export declare function rewrite_remote_client_exports(code: string, options?: RemoteClientRewriteOptions): string;
|
|
24
|
+
export {};
|
package/.dist/vite.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export interface EffectOptions {
|
|
|
15
15
|
*
|
|
16
16
|
* @example
|
|
17
17
|
* ```ts
|
|
18
|
-
* import { effect } from "svelte-effect-runtime";
|
|
18
|
+
* import { effect } from "svelte-effect-runtime/vite";
|
|
19
19
|
* import { sveltekit } from "@sveltejs/kit/vite";
|
|
20
20
|
*
|
|
21
21
|
* export default defineConfig({ plugins: [effect(), sveltekit()] });
|
|
@@ -33,10 +33,15 @@ export declare function effect(options?: EffectOptions): Plugin[];
|
|
|
33
33
|
*
|
|
34
34
|
* into an Effect-aware wrapper around the same native function.
|
|
35
35
|
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* const rewritten = await rewrite_remote_client_exports(remote_module_code);
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
36
41
|
* @since 2.0.0
|
|
37
42
|
* @param code - The generated client remote module code.
|
|
38
43
|
* @param options - Optional plugin options.
|
|
39
|
-
* @returns
|
|
44
|
+
* @returns A promise that resolves to the rewritten module code.
|
|
40
45
|
* @internal
|
|
41
46
|
*/
|
|
42
|
-
export declare function rewrite_remote_client_exports(code: string, options?: EffectOptions): string
|
|
47
|
+
export declare function rewrite_remote_client_exports(code: string, options?: EffectOptions): Promise<string>;
|
package/.dist/vite.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as rewrite_remote_client_exports, t as effect } from "./chunks/vite-
|
|
1
|
+
import { n as rewrite_remote_client_exports, t as effect } from "./chunks/vite-Dm3bXmR3.js";
|
|
2
2
|
export { effect, rewrite_remote_client_exports };
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vite-Dkwdtbgj.js","names":["candidate"],"sources":["../../../modules/svelte-effect-runtime/src/diagnostics.ts","../../../modules/svelte-effect-runtime/src/vite.ts"],"sourcesContent":["/**\n * Warning diagnostic produced by the SER Vite diagnostics plugin.\n */\ninterface Diagnostic {\n\tmessage: string;\n\tline: number;\n\tcolumn: number;\n}\n\ninterface MarkupExpression {\n\tstart: number;\n\tend: number;\n\texpression_text: string;\n\tattribute_name?: string;\n}\n\n/**\n * Finds best-effort SER usage diagnostics in Svelte component markup.\n *\n * @example\n * ```ts\n * const diagnostics = find_svelte_effect_diagnostics(\n * `<button onclick={Effect.gen}>save</button>`,\n * \"Button.svelte\",\n * );\n * ```\n *\n * @since 2.0.0\n * @param code - Svelte component source to scan for suspicious Effect usage.\n * @param filename - Filename used in diagnostic messages.\n * @returns Warning diagnostics with a message and source location.\n */\nexport function find_svelte_effect_diagnostics(\n\tcode: string,\n\tfilename: string,\n): Array<{ message: string; line: number; column: number }> {\n\tconst effect_names = find_effect_local_names(code);\n\tconst expressions = find_markup_expressions(code);\n\n\treturn expressions.flatMap((expression) =>\n\t\tmake_expression_diagnostics(code, filename, effect_names, expression),\n\t);\n}\n\nfunction find_effect_local_names(code: string): Set<string> {\n\tconst names = new Set<string>([\"Effect\"]);\n\tconst script_pattern = /<script\\b[^>]*>([\\s\\S]*?)<\\/script\\s*>/gi;\n\n\tfor (const script_match of code.matchAll(script_pattern)) {\n\t\tconst script = script_match[1];\n\t\tconst import_pattern = /import\\s+(type\\s+)?\\{([^}]+)\\}\\s+from\\s+[\"']effect[\"']/g;\n\n\t\tfor (const import_match of script.matchAll(import_pattern)) {\n\t\t\tconst is_type_only_import = import_match[1] !== undefined;\n\t\t\tconst specifiers = import_match[2].split(\",\");\n\n\t\t\tif (is_type_only_import) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tfor (const specifier of specifiers) {\n\t\t\t\tconst local_name = parse_effect_import_local_name(specifier);\n\n\t\t\t\tif (local_name) {\n\t\t\t\t\tnames.add(local_name);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn names;\n}\n\nfunction parse_effect_import_local_name(specifier: string): string | undefined {\n\tconst trimmed = specifier.trim();\n\tconst match = trimmed.match(/^Effect(?:\\s+as\\s+([A-Za-z_$][\\w$]*))?$/);\n\n\tif (!match) {\n\t\treturn undefined;\n\t}\n\n\treturn match[1] ?? \"Effect\";\n}\n\nfunction find_markup_expressions(code: string): MarkupExpression[] {\n\tconst expressions: MarkupExpression[] = [];\n\tlet cursor = 0;\n\n\twhile (cursor < code.length) {\n\t\tconst open = code.indexOf(\"{\", cursor);\n\n\t\tif (open === -1) {\n\t\t\tbreak;\n\t\t}\n\n\t\tif (is_inside_svelte_excluded_block(code, open)) {\n\t\t\tcursor = open + 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst close = find_closing_brace(code, open + 1);\n\n\t\tif (close === -1) {\n\t\t\tcursor = open + 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\texpressions.push({\n\t\t\tstart: open,\n\t\t\tend: close,\n\t\t\texpression_text: code.slice(open + 1, close).trim(),\n\t\t\tattribute_name: find_attribute_name_before_expression(code, open),\n\t\t});\n\n\t\tcursor = close + 1;\n\t}\n\n\treturn expressions;\n}\n\nfunction make_expression_diagnostics(\n\tcode: string,\n\tfilename: string,\n\teffect_names: Set<string>,\n\texpression: MarkupExpression,\n): Diagnostic[] {\n\tconst attribute_name = expression.attribute_name;\n\tconst expression_text = expression.expression_text;\n\tconst is_event_attribute =\n\t\tattribute_name !== undefined && is_event_attribute_name(attribute_name);\n\tconst is_attribute = attribute_name !== undefined;\n\tconst loc = get_line_column(code, expression.start);\n\n\tif (!contains_effect_reference(expression_text, effect_names)) {\n\t\treturn [];\n\t}\n\n\tif (starts_with_yield_star(expression_text)) {\n\t\treturn [];\n\t}\n\n\tif (\n\t\tis_event_attribute &&\n\t\tis_callback_expression(expression_text) &&\n\t\tcontains_yield_star(expression_text)\n\t) {\n\t\treturn [\n\t\t\tmake_diagnostic(\n\t\t\t\tloc,\n\t\t\t\tmake_hidden_event_yield_warning(filename, attribute_name, expression_text),\n\t\t\t),\n\t\t];\n\t}\n\n\tif (contains_effect_runner(expression_text, effect_names)) {\n\t\treturn [\n\t\t\tmake_diagnostic(\n\t\t\t\tloc,\n\t\t\t\tmake_explicit_runner_warning(filename, attribute_name, expression_text),\n\t\t\t),\n\t\t];\n\t}\n\n\tif (is_bare_effect_gen(expression_text, effect_names)) {\n\t\treturn [\n\t\t\tmake_diagnostic(\n\t\t\t\tloc,\n\t\t\t\tmake_bare_effect_gen_warning(filename, attribute_name, expression_text),\n\t\t\t),\n\t\t];\n\t}\n\n\tif (is_event_attribute && is_callback_expression(expression_text)) {\n\t\treturn [\n\t\t\tmake_diagnostic(\n\t\t\t\tloc,\n\t\t\t\tmake_event_callback_returns_effect_warning(\n\t\t\t\t\tfilename,\n\t\t\t\t\tattribute_name,\n\t\t\t\t\texpression_text,\n\t\t\t\t),\n\t\t\t),\n\t\t];\n\t}\n\n\tif (is_event_attribute) {\n\t\treturn [\n\t\t\tmake_diagnostic(\n\t\t\t\tloc,\n\t\t\t\tmake_event_attribute_effect_warning(filename, attribute_name, expression_text),\n\t\t\t),\n\t\t];\n\t}\n\n\tif (is_attribute) {\n\t\treturn [\n\t\t\tmake_diagnostic(\n\t\t\t\tloc,\n\t\t\t\tmake_attribute_effect_warning(filename, attribute_name, expression_text),\n\t\t\t),\n\t\t];\n\t}\n\n\treturn [make_diagnostic(loc, make_sync_markup_effect_warning(filename, expression_text))];\n}\n\nfunction make_diagnostic(loc: { line: number; column: number }, message: string): Diagnostic {\n\treturn {\n\t\tmessage,\n\t\tline: loc.line,\n\t\tcolumn: loc.column,\n\t};\n}\n\nfunction make_hidden_event_yield_warning(\n\tfilename: string,\n\tattribute_name: string,\n\texpression_text: string,\n): string {\n\treturn [\n\t\t`[svelte-effect-runtime] Detected yield* hidden inside an event callback.`,\n\t\t`${filename}: ${attribute_name}={${expression_text}}`,\n\t\t`SER can only lower yield* at the event attribute boundary.`,\n\t\t`Write the event expression directly, for example: ${attribute_name}={yield* save()}`,\n\t].join(\"\\n\");\n}\n\nfunction make_explicit_runner_warning(\n\tfilename: string,\n\tattribute_name: string | undefined,\n\texpression_text: string,\n): string {\n\tconst location = attribute_name\n\t\t? `${attribute_name}={${expression_text}}`\n\t\t: `{${expression_text}}`;\n\n\treturn [\n\t\t`[svelte-effect-runtime] Detected an explicit Effect runner inside Svelte markup.`,\n\t\t`${filename}: ${location}`,\n\t\t`Explicit runners bypass SER cancellation and error handling for markup effects.`,\n\t\t`Prefer yield* so SER can manage the Effect lifecycle.`,\n\t].join(\"\\n\");\n}\n\nfunction make_bare_effect_gen_warning(\n\tfilename: string,\n\tattribute_name: string | undefined,\n\texpression_text: string,\n): string {\n\tconst location = attribute_name\n\t\t? `${attribute_name}={${expression_text}}`\n\t\t: `{${expression_text}}`;\n\tconst fixed = attribute_name\n\t\t? `${attribute_name}={yield* ${expression_text}(function* () { ... })}`\n\t\t: `{yield* ${expression_text}(function* () { ... })}`;\n\n\treturn [\n\t\t`[svelte-effect-runtime] Detected Effect.gen used as a value instead of an Effect program.`,\n\t\t`${filename}: ${location}`,\n\t\t`${expression_text} is a constructor, not the result of running a generator.`,\n\t\t`Use: ${fixed}`,\n\t].join(\"\\n\");\n}\n\nfunction make_event_callback_returns_effect_warning(\n\tfilename: string,\n\tattribute_name: string,\n\texpression_text: string,\n): string {\n\treturn [\n\t\t`[svelte-effect-runtime] Detected an event callback that returns an Effect but does not run it.`,\n\t\t`${filename}: ${attribute_name}={${expression_text}}`,\n\t\t`Svelte will call the callback and receive an Effect value, but SER will not manage it from inside the callback.`,\n\t\t`Use yield* at the event attribute boundary or explicitly run the Effect if you really want to bypass SER.`,\n\t].join(\"\\n\");\n}\n\nfunction make_event_attribute_effect_warning(\n\tfilename: string,\n\tattribute_name: string,\n\texpression_text: string,\n): string {\n\tconst fixed = `${attribute_name}={yield* ${expression_text}}`;\n\n\treturn [\n\t\t`[svelte-effect-runtime] Detected an event attribute that looks like an Effect but is not written with yield*.`,\n\t\t`${filename}: ${attribute_name}={${expression_text}}`,\n\t\t`If you are trying to use Effect in this event handler, use yield* at the beginning.`,\n\t\t`Use: ${fixed}`,\n\t].join(\"\\n\");\n}\n\nfunction make_attribute_effect_warning(\n\tfilename: string,\n\tattribute_name: string,\n\texpression_text: string,\n): string {\n\tconst fixed = `${attribute_name}={yield* ${expression_text}}`;\n\n\treturn [\n\t\t`[svelte-effect-runtime] Detected an attribute value that looks like an Effect but is not written with yield*.`,\n\t\t`${filename}: ${attribute_name}={${expression_text}}`,\n\t\t`Svelte attributes need the resolved Effect value, not the Effect object itself.`,\n\t\t`Use: ${fixed}`,\n\t].join(\"\\n\");\n}\n\nfunction make_sync_markup_effect_warning(filename: string, expression_text: string): string {\n\treturn [\n\t\t`[svelte-effect-runtime] Detected a markup expression that creates an Effect but is not written with yield*.`,\n\t\t`${filename}: {${expression_text}}`,\n\t\t`This expression will produce an Effect value, not its result.`,\n\t\t`Use yield* where Svelte expects the resolved value.`,\n\t].join(\"\\n\");\n}\n\nfunction contains_effect_reference(expression_text: string, effect_names: Set<string>): boolean {\n\tconst name_pattern = make_effect_name_pattern(effect_names);\n\tconst effect_pattern = new RegExp(\n\t\t`\\\\b(?:${name_pattern})\\\\.(?:gen|succeed|fail|try|tryPromise|promise|sync|all|void|log|runPromise|runSync|runFork)\\\\b`,\n\t);\n\n\treturn effect_pattern.test(expression_text);\n}\n\nfunction contains_effect_runner(expression_text: string, effect_names: Set<string>): boolean {\n\tconst name_pattern = make_effect_name_pattern(effect_names);\n\tconst runner_pattern = new RegExp(`\\\\b(?:${name_pattern})\\\\.run(?:Promise|Sync|Fork)\\\\b`);\n\n\treturn runner_pattern.test(expression_text);\n}\n\nfunction is_bare_effect_gen(expression_text: string, effect_names: Set<string>): boolean {\n\tconst name_pattern = make_effect_name_pattern(effect_names);\n\tconst bare_gen_pattern = new RegExp(`^(?:${name_pattern})\\\\.gen$`);\n\n\treturn bare_gen_pattern.test(expression_text);\n}\n\nfunction make_effect_name_pattern(effect_names: Set<string>): string {\n\treturn [...effect_names]\n\t\t.map(escape_regexp)\n\t\t.sort((a, b) => b.length - a.length)\n\t\t.join(\"|\");\n}\n\nfunction starts_with_yield_star(expression_text: string): boolean {\n\treturn /^yield\\s*\\*/.test(expression_text);\n}\n\nfunction contains_yield_star(expression_text: string): boolean {\n\treturn /\\byield\\s*\\*/.test(expression_text);\n}\n\nfunction is_callback_expression(expression_text: string): boolean {\n\treturn (\n\t\t/^(?:async\\s+)?(?:\\([^)]*\\)|[A-Za-z_$][\\w$]*)\\s*=>/.test(expression_text) ||\n\t\t/^(?:async\\s+)?function\\b/.test(expression_text)\n\t);\n}\n\nfunction is_event_attribute_name(name: string): boolean {\n\treturn /^on(?::[A-Za-z_$][\\w$-]*|[a-z][\\w$-]*)$/.test(name);\n}\n\nfunction find_attribute_name_before_expression(code: string, open: number): string | undefined {\n\tconst tag_start = code.lastIndexOf(\"<\", open);\n\tconst last_tag_end = code.lastIndexOf(\">\", open);\n\n\tif (tag_start === -1 || tag_start < last_tag_end) {\n\t\treturn undefined;\n\t}\n\n\tconst before_expression = code.slice(tag_start + 1, open);\n\tconst match = before_expression.match(/(?:^|\\s)([A-Za-z_$:][\\w$:-]*)\\s*=\\s*$/);\n\n\treturn match?.[1];\n}\n\nfunction is_inside_svelte_excluded_block(code: string, pos: number): boolean {\n\tconst script = find_svelte_tag_range(code, \"script\", pos);\n\tconst style = find_svelte_tag_range(code, \"style\", pos);\n\n\treturn (\n\t\t(script !== undefined && pos < script.end && pos > script.start) ||\n\t\t(style !== undefined && pos < style.end && pos > style.start)\n\t);\n}\n\nfunction find_svelte_tag_range(\n\tcode: string,\n\ttag: string,\n\tafter_pos: number,\n): { start: number; end: number } | undefined {\n\tconst pattern = new RegExp(`<${tag}\\\\b[^>]*>([\\\\s\\\\S]*?)<\\\\/${tag}\\\\s*>`, \"gi\");\n\n\tfor (const match of code.matchAll(pattern)) {\n\t\tif (match.index === undefined) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst end = match.index + match[0].length;\n\n\t\tif (match.index <= after_pos && after_pos < end) {\n\t\t\treturn { start: match.index, end };\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\nfunction find_closing_brace(code: string, start: number): number {\n\tlet depth = 0;\n\n\tfor (let i = start; i < code.length; i += 1) {\n\t\tconst ch = code[i];\n\n\t\tif (ch === \"{\" && code[i - 1] !== \"$\") {\n\t\t\tdepth += 1;\n\t\t} else if (ch === \"}\") {\n\t\t\tif (depth === 0) {\n\t\t\t\treturn i;\n\t\t\t}\n\n\t\t\tdepth -= 1;\n\t\t} else if (ch === \"'\" || ch === '\"' || ch === \"`\") {\n\t\t\ti = skip_string(code, i, ch);\n\n\t\t\tif (i === -1) {\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t} else if (ch === \"/\" && code[i + 1] === \"/\") {\n\t\t\ti = skip_line_comment(code, i);\n\t\t} else if (ch === \"/\" && code[i + 1] === \"*\") {\n\t\t\ti = skip_block_comment(code, i);\n\n\t\t\tif (i === -1) {\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn -1;\n}\n\nfunction skip_string(code: string, start: number, quote: string): number {\n\tfor (let i = start + 1; i < code.length; i += 1) {\n\t\tif (code[i] === \"\\\\\") {\n\t\t\ti += 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (code[i] === quote) {\n\t\t\treturn i;\n\t\t}\n\t}\n\n\treturn -1;\n}\n\nfunction skip_line_comment(code: string, start: number): number {\n\tfor (let i = start + 2; i < code.length; i += 1) {\n\t\tif (code[i] === \"\\n\") {\n\t\t\treturn i;\n\t\t}\n\t}\n\n\treturn code.length;\n}\n\nfunction skip_block_comment(code: string, start: number): number {\n\tfor (let i = start + 2; i < code.length; i += 1) {\n\t\tif (code[i] === \"*\" && code[i + 1] === \"/\") {\n\t\t\treturn i + 1;\n\t\t}\n\t}\n\n\treturn -1;\n}\n\nfunction get_line_column(code: string, position: number): { line: number; column: number } {\n\tconst before = code.slice(0, position);\n\tconst lines = before.split(\"\\n\");\n\tconst line = lines.length;\n\tconst column = lines.at(-1)?.length ?? 0;\n\n\treturn { line, column };\n}\n\nfunction escape_regexp(value: string): string {\n\treturn value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n","import { find_svelte_effect_diagnostics } from \"./diagnostics.ts\";\nimport type { Plugin } from \"vite\";\n\nimport MagicString from \"magic-string\";\nimport ts from \"typescript\";\n\n/**\n * Options for the {@link effect} Vite plugin.\n *\n * @since 2.0.0\n */\nexport interface EffectOptions {\n\t/** Whether to emit debug logging in the generated remote client module. */\n\tdebug?: boolean;\n}\n\ntype RemoteClientExportType =\n\t| \"query_batch\"\n\t| \"query_live\"\n\t| \"query\"\n\t| \"command\"\n\t| \"form\"\n\t| \"prerender\";\n\ninterface RemoteNamespaceImport {\n\tname: string;\n\tstatement: ts.ImportDeclaration;\n}\n\ninterface RemoteClientExport {\n\tname: string;\n\ttype: RemoteClientExportType;\n\tstatement: ts.VariableStatement;\n\tnative_call: string;\n}\n\ninterface SvelteComponentModuleFilter {\n\tset_extensions(extensions: readonly string[]): void;\n\tis_module(id: string): boolean;\n}\n\ninterface VitePluginSvelteApi {\n\toptions?: {\n\t\textensions?: readonly unknown[];\n\t};\n}\n\ntype VitePluginSvelte = Plugin & {\n\tapi?: VitePluginSvelteApi;\n};\n\ntype VitePluginSvelteWithExtensions = Plugin & {\n\tapi: {\n\t\toptions: {\n\t\t\textensions: readonly string[];\n\t\t};\n\t};\n};\n\nconst remote_client_export_types = new Set<RemoteClientExportType>([\n\t\"query_batch\",\n\t\"query_live\",\n\t\"query\",\n\t\"command\",\n\t\"form\",\n\t\"prerender\",\n]);\nconst default_svelte_component_extensions = [\".svelte\"] as const;\n\n/**\n * Vite plugin for SvelteKit. The server import plugin rewrites server-side\n * imports to the server entrypoint; the remote client plugin wraps SvelteKit's\n * generated client remote exports in Effect-returning adapters.\n *\n * @example\n * ```ts\n * import { effect } from \"svelte-effect-runtime\";\n * import { sveltekit } from \"@sveltejs/kit/vite\";\n *\n * export default defineConfig({ plugins: [effect(), sveltekit()] });\n * ```\n *\n * @since 2.0.0\n * @param options - Optional configuration.\n * @returns Vite plugins that integrate the runtime with SvelteKit.\n */\nexport function effect(options?: EffectOptions): Plugin[] {\n\tconst component_filter = make_svelte_component_module_filter();\n\n\treturn [\n\t\tmake_diagnostics_plugin(component_filter),\n\t\tmake_reserved_helper_guard_plugin(component_filter),\n\t\tmake_svelte_transform_plugin(component_filter),\n\t\tmake_server_rewrite_plugin(),\n\t\tmake_remote_client_wrapper_plugin(options),\n\t];\n}\n\nfunction make_diagnostics_plugin(component_filter: SvelteComponentModuleFilter): Plugin {\n\tconst warned_diagnostics = new Set<string>();\n\n\treturn {\n\t\tname: \"svelte-effect-runtime:diagnostics\",\n\n\t\ttransform(code: string, id: string) {\n\t\t\tif (!component_filter.is_module(id)) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst clean_id = id.split(\"?\")[0] ?? id;\n\t\t\tconst diagnostics = find_svelte_effect_diagnostics(code, clean_id);\n\n\t\t\tfor (const diagnostic of diagnostics) {\n\t\t\t\tconst diagnostic_key = [\n\t\t\t\t\tclean_id,\n\t\t\t\t\tdiagnostic.line,\n\t\t\t\t\tdiagnostic.column,\n\t\t\t\t\tdiagnostic.message,\n\t\t\t\t].join(\":\");\n\n\t\t\t\tif (warned_diagnostics.has(diagnostic_key)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\twarned_diagnostics.add(diagnostic_key);\n\n\t\t\t\tthis.warn({\n\t\t\t\t\tid: clean_id,\n\t\t\t\t\tmessage: diagnostic.message,\n\t\t\t\t\tloc: {\n\t\t\t\t\t\tline: diagnostic.line,\n\t\t\t\t\t\tcolumn: diagnostic.column,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn undefined;\n\t\t},\n\t};\n}\n\nfunction make_reserved_helper_guard_plugin(component_filter: SvelteComponentModuleFilter): Plugin {\n\treturn {\n\t\tname: \"svelte-effect-runtime:reserved-helper-guard\",\n\n\t\ttransform(code: string, id: string) {\n\t\t\tif (!component_filter.is_module(id) || !has_ser_syntax(code)) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst reserved_names = find_reserved_helper_names(code);\n\n\t\t\tif (reserved_names.length === 0) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tthis.warn(make_reserved_helper_warning(reserved_names));\n\n\t\t\treturn undefined;\n\t\t},\n\t};\n}\n\nfunction make_svelte_transform_plugin(component_filter: SvelteComponentModuleFilter): Plugin {\n\treturn {\n\t\tname: \"svelte-effect-runtime:svelte-transform\",\n\n\t\tconfigResolved(config) {\n\t\t\tconst extensions = find_svelte_component_extensions(config.plugins);\n\t\t\tconst conflicting_plugin_names = find_pre_transform_plugin_names(config.plugins);\n\n\t\t\tif (extensions) {\n\t\t\t\tcomponent_filter.set_extensions(extensions);\n\t\t\t}\n\n\t\t\tif (conflicting_plugin_names.length === 0) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconfig.logger.info(make_pre_transform_plugin_notice(conflicting_plugin_names));\n\t\t},\n\n\t\tasync transform(code: string, id: string, options?: { ssr?: boolean }) {\n\t\t\tif (!component_filter.is_module(id)) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst { transform_svelte_effect } = await import(\"./runtime/transform.ts\");\n\t\t\tconst result = transform_svelte_effect(code, id, {\n\t\t\t\ttarget: options?.ssr ? \"server\" : \"client\",\n\t\t\t});\n\n\t\t\tif (result.code === code) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\treturn { code: result.code, map: null };\n\t\t},\n\t};\n}\n\nfunction make_svelte_component_module_filter(): SvelteComponentModuleFilter {\n\tlet extensions: readonly string[] = default_svelte_component_extensions;\n\n\treturn {\n\t\tset_extensions(next_extensions) {\n\t\t\tconst normalized_extensions = normalize_svelte_component_extensions(next_extensions);\n\n\t\t\tif (normalized_extensions.length === 0) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\textensions = normalized_extensions;\n\t\t},\n\n\t\tis_module(id) {\n\t\t\treturn is_svelte_component_module(id, extensions);\n\t\t},\n\t};\n}\n\nfunction normalize_svelte_component_extensions(extensions: readonly string[]): string[] {\n\tconst normalized_extensions = extensions\n\t\t.filter((extension) => extension.length > 0)\n\t\t.map((extension) => (extension.startsWith(\".\") ? extension : `.${extension}`));\n\n\treturn [...new Set(normalized_extensions)];\n}\n\nfunction find_svelte_component_extensions(\n\tplugins: readonly Plugin[],\n): readonly string[] | undefined {\n\tconst svelte_plugin = plugins.find(has_svelte_component_extensions);\n\n\treturn svelte_plugin?.api?.options?.extensions;\n}\n\nfunction has_svelte_component_extensions(plugin: Plugin): plugin is VitePluginSvelteWithExtensions {\n\tconst candidate = plugin as VitePluginSvelte;\n\tconst extensions = candidate.api?.options?.extensions;\n\n\tif (!plugin.name.startsWith(\"vite-plugin-svelte\")) {\n\t\treturn false;\n\t}\n\n\treturn (\n\t\tArray.isArray(extensions) && extensions.every((extension) => typeof extension === \"string\")\n\t);\n}\n\nfunction find_pre_transform_plugin_names(plugins: readonly Plugin[]): string[] {\n\treturn plugins\n\t\t.filter(\n\t\t\t(plugin) =>\n\t\t\t\t!plugin.name.startsWith(\"svelte-effect-runtime:\") &&\n\t\t\t\t!is_known_framework_pre_transform_plugin(plugin.name) &&\n\t\t\t\thas_pre_transform_priority(plugin),\n\t\t)\n\t\t.map((plugin) => plugin.name);\n}\n\nconst ansi_reset = \"\\x1b[0m\";\nconst ansi_light_green = \"\\x1b[92m\";\n\nfunction make_pre_transform_plugin_notice(plugin_names: readonly string[]): string {\n\tconst formatted_plugins = plugin_names.map((plugin_name) => ` - ${plugin_name}`).join(\"\\n\");\n\n\treturn [\n\t\t`${ansi_light_green}[svelte-effect-runtime]${ansi_reset} Svelte Effect Runtime noticed possible Vite plugin ordering conflicts.`,\n\t\t\"\",\n\t\t\"These plugins run before normal Svelte component transforms:\",\n\t\tformatted_plugins,\n\t\t\"\",\n\t\t\"This is usually fine, but if you see Svelte parser errors around <script effect>\",\n\t\t\"or yield* in components, one of those plugins may be reading component files before\",\n\t\t\"SER has lowered its syntax.\",\n\t].join(\"\\n\");\n}\n\nfunction is_known_framework_pre_transform_plugin(name: string): boolean {\n\treturn name.startsWith(\"vite:\") || name === \"vite-plugin-svelte:preprocess\";\n}\n\nfunction has_pre_transform_priority(plugin: Plugin): boolean {\n\tif (plugin.enforce === \"pre\" && plugin.transform) {\n\t\treturn true;\n\t}\n\n\tif (\n\t\ttypeof plugin.transform === \"object\" &&\n\t\tplugin.transform !== null &&\n\t\t\"order\" in plugin.transform &&\n\t\tplugin.transform.order === \"pre\"\n\t) {\n\t\treturn true;\n\t}\n\n\treturn false;\n}\n\nfunction make_server_rewrite_plugin(): Plugin {\n\treturn {\n\t\tname: \"svelte-effect-runtime:server-imports\",\n\n\t\tconfig() {\n\t\t\treturn { optimizeDeps: { exclude: [\"svelte-effect-runtime\"] } };\n\t\t},\n\n\t\ttransform(code: string, id: string) {\n\t\t\tif (!is_server_runtime_module(id)) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst rewritten = code\n\t\t\t\t.replace(\n\t\t\t\t\t/from\\s+[\"']svelte-effect-runtime[\"']/g,\n\t\t\t\t\t`from \"svelte-effect-runtime/server\"`,\n\t\t\t\t)\n\t\t\t\t.replace(\n\t\t\t\t\t/from\\s+[\"']svelte-effect-runtime\\/internal\\/generators[\"']/g,\n\t\t\t\t\t`from \"svelte-effect-runtime/server\"`,\n\t\t\t\t);\n\n\t\t\tif (rewritten === code) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\treturn { code: rewritten, map: null };\n\t\t},\n\t};\n}\n\nfunction make_remote_client_wrapper_plugin(options?: EffectOptions): Plugin {\n\treturn {\n\t\tname: \"svelte-effect-runtime:remote-client\",\n\t\tenforce: \"post\",\n\n\t\tconfig() {\n\t\t\treturn { ssr: { noExternal: [\"svelte-effect-runtime\"] } };\n\t\t},\n\n\t\tconfigResolved(config) {\n\t\t\tconst no_external = config.ssr.noExternal;\n\t\t\tconst runtime_package = \"svelte-effect-runtime\";\n\n\t\t\tif (no_external === true) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (Array.isArray(no_external)) {\n\t\t\t\tconst has_runtime_package = no_external.some((entry) => entry === runtime_package);\n\n\t\t\t\tif (!has_runtime_package) {\n\t\t\t\t\tno_external.push(runtime_package);\n\t\t\t\t}\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconfig.ssr.noExternal = [no_external, runtime_package].filter(\n\t\t\t\t(value): value is string | RegExp => value !== undefined,\n\t\t\t);\n\t\t},\n\n\t\ttransform(code: string, id: string) {\n\t\t\tif (!is_remote_module(id) || !code.includes(\"__sveltekit/remote\")) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst rewritten = rewrite_remote_client_exports(code, options);\n\n\t\t\tif (rewritten === code) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\treturn { code: rewritten, map: null };\n\t\t},\n\t};\n}\n\nfunction is_server_runtime_module(id: string): boolean {\n\tconst [filename] = id.split(\"?\", 2);\n\n\treturn (\n\t\t/\\.(server|remote)(?:\\.[cm])?\\.[jt]s$/.test(filename) ||\n\t\t/(?:^|[\\\\/])hooks\\.server(?:\\.[cm])?\\.[jt]s$/.test(filename)\n\t);\n}\n\nfunction is_remote_module(id: string): boolean {\n\treturn /\\.(remote|remote\\.[cm]?)\\.[jt]s(?:\\?.*)?$/.test(id) || id.includes(\".remote.\");\n}\n\nfunction is_svelte_component_module(id: string, extensions: readonly string[]): boolean {\n\tconst [filename, query = \"\"] = id.split(\"?\", 2);\n\n\tif (!extensions.some((extension) => filename.endsWith(extension))) {\n\t\treturn false;\n\t}\n\n\tif (query.length === 0) {\n\t\treturn true;\n\t}\n\n\tconst params = new URLSearchParams(query);\n\tconst allowed_params = [\"t\", \"v\"];\n\n\treturn [...params.keys()].every((key) => allowed_params.includes(key));\n}\n\nfunction has_ser_syntax(code: string): boolean {\n\treturn /\\byield\\s*\\*/.test(code) || /<script\\b[^>]*\\beffect(?:[\\s=>]|$)/.test(code);\n}\n\nfunction find_reserved_helper_names(code: string): string[] {\n\tconst script_segments = [...code.matchAll(/<script\\b[^>]*>([\\s\\S]*?)<\\/script\\s*>/gi)].map(\n\t\t(match) => match[1] ?? \"\",\n\t);\n\tconst markup_segments = [...code.matchAll(/\\{[^{}]*(?:Dispatcher|Code)[^{}]*\\}/g)].map(\n\t\t(match) => match[0],\n\t);\n\tconst search_segments = [...script_segments, ...markup_segments];\n\n\treturn [\"Dispatcher\", \"Code\"].filter((name) =>\n\t\tsearch_segments.some((segment) => new RegExp(`\\\\b${name}\\\\b`).test(segment)),\n\t);\n}\n\nfunction make_reserved_helper_warning(names: string[]): string {\n\tconst quoted_names = names.map((name) => `\\`${name}\\``);\n\tconst subject =\n\t\tquoted_names.length === 1\n\t\t\t? quoted_names[0]\n\t\t\t: `${quoted_names.slice(0, -1).join(\", \")} and ${\n\t\t\t\t\tquoted_names[quoted_names.length - 1]\n\t\t\t\t}`;\n\tconst verb = names.length === 1 ? \"is\" : \"are\";\n\n\treturn [\n\t\t`[svelte-effect-runtime] ${subject} ${verb} reserved for generated markup helpers.`,\n\t\t`Rename or alias local bindings that use ${subject} before using SER syntax in this component.`,\n\t].join(\" \");\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(code: string, options?: EffectOptions): string {\n\tconst source_file = ts.createSourceFile(\n\t\t\"sveltekit-remote-client.ts\",\n\t\tcode,\n\t\tts.ScriptTarget.Latest,\n\t\ttrue,\n\t\tts.ScriptKind.TS,\n\t);\n\tconst namespace_import = find_remote_namespace_import(source_file);\n\n\tif (!namespace_import) {\n\t\treturn code;\n\t}\n\n\tconst remote_exports = collect_remote_client_exports(source_file, code, namespace_import.name);\n\n\tif (remote_exports.length === 0) {\n\t\treturn code;\n\t}\n\n\tconst magic = new MagicString(code);\n\tconst imports = [\n\t\t`import { app_dir, base } from \"$app/paths/internal/client\";`,\n\t\t`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\t].join(\"\\n\");\n\n\tconst helpers = [\n\t\t`const __SER___remote_base = \\`\\${base}/\\${app_dir}/remote\\`;`,\n\t\t`function __SER___decode_payload(value) { return value; }`,\n\t].join(\"\\n\");\n\n\tconst debug_line = options?.debug ? `console.log(\"[ser] remote client wrappers loaded\");` : \"\";\n\n\tconst injected = [imports, helpers, debug_line].filter(Boolean).join(\"\\n\");\n\n\tmagic.appendRight(namespace_import.statement.end, `\\n${injected}`);\n\n\tfor (const remote_export of remote_exports) {\n\t\tmagic.overwrite(\n\t\t\tremote_export.statement.getStart(source_file),\n\t\t\tremote_export.statement.end,\n\t\t\tmake_remote_export(remote_export.name, remote_export.type, remote_export.native_call),\n\t\t);\n\t}\n\n\treturn magic.toString();\n}\n\nfunction make_remote_export(\n\tname: string,\n\ttype: RemoteClientExportType,\n\tnative_call: string,\n): string {\n\tif (type === \"command\") {\n\t\treturn `export const ${name} = create_remote_command_adapter(${native_call}, __SER___decode_payload);`;\n\t}\n\n\tif (type === \"form\") {\n\t\treturn `export const ${name} = create_remote_form_adapter(${native_call}, __SER___decode_payload, __SER___remote_base);`;\n\t}\n\n\tif (type === \"query_live\") {\n\t\treturn `export const ${name} = create_remote_live_query_adapter(${native_call}, __SER___decode_payload);`;\n\t}\n\n\treturn `export const ${name} = create_remote_query_adapter(${native_call}, __SER___decode_payload);`;\n}\n\nfunction find_remote_namespace_import(\n\tsource_file: ts.SourceFile,\n): RemoteNamespaceImport | undefined {\n\tfor (const statement of source_file.statements) {\n\t\tif (!ts.isImportDeclaration(statement)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst namespace_import = get_remote_namespace_import(statement);\n\n\t\tif (namespace_import) {\n\t\t\treturn namespace_import;\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\nfunction get_remote_namespace_import(\n\tstatement: ts.ImportDeclaration,\n): RemoteNamespaceImport | undefined {\n\tif (\n\t\t!ts.isStringLiteral(statement.moduleSpecifier) ||\n\t\tstatement.moduleSpecifier.text !== \"__sveltekit/remote\"\n\t) {\n\t\treturn undefined;\n\t}\n\n\tconst import_clause = statement.importClause;\n\tconst bindings = import_clause?.namedBindings;\n\n\tif (import_clause?.isTypeOnly || !bindings || !ts.isNamespaceImport(bindings)) {\n\t\treturn undefined;\n\t}\n\n\treturn {\n\t\tname: bindings.name.text,\n\t\tstatement,\n\t};\n}\n\nfunction collect_remote_client_exports(\n\tsource_file: ts.SourceFile,\n\tcode: string,\n\tnamespace: string,\n): RemoteClientExport[] {\n\treturn source_file.statements.flatMap((statement) =>\n\t\tcollect_remote_client_export(source_file, code, namespace, statement),\n\t);\n}\n\nfunction collect_remote_client_export(\n\tsource_file: ts.SourceFile,\n\tcode: string,\n\tnamespace: string,\n\tstatement: ts.Statement,\n): RemoteClientExport[] {\n\tif (\n\t\t!ts.isVariableStatement(statement) ||\n\t\t!is_export_statement(statement) ||\n\t\t!is_const_declaration_list(statement.declarationList) ||\n\t\tstatement.declarationList.declarations.length !== 1\n\t) {\n\t\treturn [];\n\t}\n\n\tconst declaration = statement.declarationList.declarations[0];\n\tconst initializer = declaration.initializer;\n\n\tif (!ts.isIdentifier(declaration.name) || !initializer) {\n\t\treturn [];\n\t}\n\n\tconst type = get_remote_client_export_type(initializer, namespace);\n\n\tif (!type) {\n\t\treturn [];\n\t}\n\n\treturn [\n\t\t{\n\t\t\tname: declaration.name.text,\n\t\t\ttype,\n\t\t\tstatement,\n\t\t\tnative_call: code.slice(initializer.getStart(source_file), initializer.end),\n\t\t},\n\t];\n}\n\nfunction get_remote_client_export_type(\n\tinitializer: ts.Expression,\n\tnamespace: string,\n): RemoteClientExportType | undefined {\n\tif (!ts.isCallExpression(initializer)) {\n\t\treturn undefined;\n\t}\n\n\tconst expression = initializer.expression;\n\n\tif (!ts.isPropertyAccessExpression(expression)) {\n\t\treturn undefined;\n\t}\n\n\tif (!ts.isIdentifier(expression.expression) || expression.expression.text !== namespace) {\n\t\treturn undefined;\n\t}\n\n\tconst type = expression.name.text;\n\n\tif (!is_remote_client_export_type(type)) {\n\t\treturn undefined;\n\t}\n\n\treturn type;\n}\n\nfunction is_remote_client_export_type(value: string): value is RemoteClientExportType {\n\treturn remote_client_export_types.has(value as RemoteClientExportType);\n}\n\nfunction is_export_statement(statement: ts.Statement): boolean {\n\tconst modifiers = ts.canHaveModifiers(statement) ? ts.getModifiers(statement) : undefined;\n\n\treturn modifiers?.some((modifier) => modifier.kind === ts.SyntaxKind.ExportKeyword) ?? false;\n}\n\nfunction is_const_declaration_list(declaration_list: ts.VariableDeclarationList): boolean {\n\treturn (ts.getCombinedNodeFlags(declaration_list) & ts.NodeFlags.Const) !== 0;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAgCA,SAAgB,+BACf,MACA,UAC2D;CAC3D,MAAM,eAAe,wBAAwB,IAAI;CAGjD,OAFoB,wBAAwB,IAE3B,CAAC,CAAC,SAAS,eAC3B,4BAA4B,MAAM,UAAU,cAAc,UAAU,CACrE;AACD;AAEA,SAAS,wBAAwB,MAA2B;CAC3D,MAAM,wBAAQ,IAAI,IAAY,CAAC,QAAQ,CAAC;CAGxC,KAAK,MAAM,gBAAgB,KAAK,SAAS,0CAAc,GAAG;EACzD,MAAM,SAAS,aAAa;EAG5B,KAAK,MAAM,gBAAgB,OAAO,SAAS,yDAAc,GAAG;GAC3D,MAAM,sBAAsB,aAAa,OAAO,KAAA;GAChD,MAAM,aAAa,aAAa,EAAE,CAAC,MAAM,GAAG;GAE5C,IAAI,qBACH;GAGD,KAAK,MAAM,aAAa,YAAY;IACnC,MAAM,aAAa,+BAA+B,SAAS;IAE3D,IAAI,YACH,MAAM,IAAI,UAAU;GAEtB;EACD;CACD;CAEA,OAAO;AACR;AAEA,SAAS,+BAA+B,WAAuC;CAE9E,MAAM,QADU,UAAU,KACN,CAAC,CAAC,MAAM,yCAAyC;CAErE,IAAI,CAAC,OACJ;CAGD,OAAO,MAAM,MAAM;AACpB;AAEA,SAAS,wBAAwB,MAAkC;CAClE,MAAM,cAAkC,CAAC;CACzC,IAAI,SAAS;CAEb,OAAO,SAAS,KAAK,QAAQ;EAC5B,MAAM,OAAO,KAAK,QAAQ,KAAK,MAAM;EAErC,IAAI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