svelte-effect-runtime 4.1.0 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dist/chunks/{client-DbwVAMWm.js → client-CkxjaRTA.js} +2 -2
- package/.dist/chunks/{client-DbwVAMWm.js.map → client-CkxjaRTA.js.map} +1 -1
- package/.dist/chunks/{dispatcher-CTWINW5I.js → dispatcher-B6ZRUsjN.js} +139 -44
- package/.dist/chunks/dispatcher-B6ZRUsjN.js.map +1 -0
- package/.dist/chunks/{dispatcher-pZPzarul.js → dispatcher-D8j5wTx6.js} +3 -3
- package/.dist/chunks/{dispatcher-pZPzarul.js.map → dispatcher-D8j5wTx6.js.map} +1 -1
- package/.dist/chunks/{runtime-CPosEhGl.js → runtime-B8RHHy3v.js} +2 -2
- package/.dist/chunks/{runtime-CPosEhGl.js.map → runtime-B8RHHy3v.js.map} +1 -1
- package/.dist/chunks/server-NeyeDSax.js +339 -0
- package/.dist/chunks/server-NeyeDSax.js.map +1 -0
- package/.dist/chunks/{transform-D7TTlPpK.js → transform-C0jW8Qta.js} +38 -5
- package/.dist/chunks/transform-C0jW8Qta.js.map +1 -0
- package/.dist/dispatcher.js +1 -1
- package/.dist/environment.d.ts +87 -0
- package/.dist/environment.js +44 -0
- package/.dist/environment.js.map +1 -0
- package/.dist/internal/generators.js +2 -2
- package/.dist/internal/remote-client.js +1 -1
- package/.dist/internal/remote-server.js +2 -2
- package/.dist/markup/promise.js +1 -1
- package/.dist/markup/run.js +1 -1
- package/.dist/markup/transform.js +1 -1
- package/.dist/markup/value.js +1 -1
- package/.dist/mod.d.ts +2 -0
- package/.dist/mod.js +3 -2
- package/.dist/mod.js.map +1 -1
- package/.dist/remote/cause-codec.d.ts +35 -0
- package/.dist/remote/client.js +1 -1
- package/.dist/remote/diagnostics.d.ts +67 -0
- package/.dist/remote/server.d.ts +26 -2
- package/.dist/remote/server.js +2 -2
- package/.dist/runtime/transform.js +12 -7
- package/.dist/runtime/transform.js.map +1 -1
- package/.dist/script-transform/imports.d.ts +1 -1
- package/.dist/server.js +6 -6
- package/.dist/server.js.map +1 -1
- package/package.json +5 -1
- package/.dist/chunks/dispatcher-CTWINW5I.js.map +0 -1
- package/.dist/chunks/server-yQrNoiCR.js +0 -144
- package/.dist/chunks/server-yQrNoiCR.js.map +0 -1
- package/.dist/chunks/transform-D7TTlPpK.js.map +0 -1
|
@@ -50,7 +50,7 @@ function make_named_import(imported_name, local_name, type_only = false) {
|
|
|
50
50
|
const prefix = type_only ? "type " : "";
|
|
51
51
|
return imported_name === local_name ? `${prefix}${imported_name}` : `${prefix}${imported_name} as ${local_name}`;
|
|
52
52
|
}
|
|
53
|
-
function has_local_import_binding(source_file, module_name, local_name) {
|
|
53
|
+
function has_local_import_binding(source_file, module_name, local_name, allow_namespace_import = true) {
|
|
54
54
|
return source_file.statements.some((stmt) => {
|
|
55
55
|
if (!ts.isImportDeclaration(stmt) || !ts.isStringLiteral(stmt.moduleSpecifier) || stmt.moduleSpecifier.text !== module_name) return false;
|
|
56
56
|
const clause = stmt.importClause;
|
|
@@ -58,7 +58,7 @@ function has_local_import_binding(source_file, module_name, local_name) {
|
|
|
58
58
|
if (clause.name?.text === local_name) return true;
|
|
59
59
|
const named_bindings = clause.namedBindings;
|
|
60
60
|
if (!named_bindings) return false;
|
|
61
|
-
if (ts.isNamespaceImport(named_bindings)) return named_bindings.name.text === local_name;
|
|
61
|
+
if (ts.isNamespaceImport(named_bindings)) return allow_namespace_import && named_bindings.name.text === local_name;
|
|
62
62
|
return named_bindings.elements.some((element) => !element.isTypeOnly && element.name.text === local_name);
|
|
63
63
|
});
|
|
64
64
|
}
|
|
@@ -186,18 +186,20 @@ function inject_helpers(magic, source_scan, helpers = [], bindings = default_hel
|
|
|
186
186
|
function make_markup_helper_bindings(source_scan, target = "client") {
|
|
187
187
|
const script_binding_names = source_scan.scripts.flatMap((script) => collect_script_binding_names(script.text));
|
|
188
188
|
const markup_identifier_names = collect_markup_identifier_names(source_scan);
|
|
189
|
+
const detected_scope_name = extract_script_scope_binding(source_scan.scripts);
|
|
189
190
|
const name_allocator = make_name_allocator([...script_binding_names, ...markup_identifier_names]);
|
|
191
|
+
const scope = detected_scope_name ?? name_allocator.reserve(default_helper_bindings.scope);
|
|
190
192
|
const bindings = {
|
|
191
193
|
codes: name_allocator.reserve(default_helper_bindings.codes),
|
|
192
194
|
dispatcher: name_allocator.reserve(default_helper_bindings.dispatcher),
|
|
193
195
|
yieldable: name_allocator.reserve(default_helper_bindings.yieldable),
|
|
194
|
-
scope
|
|
196
|
+
scope
|
|
195
197
|
};
|
|
196
198
|
const is_server_target = target === "server";
|
|
197
199
|
return {
|
|
198
200
|
bindings,
|
|
199
201
|
name_allocator,
|
|
200
|
-
scope_wiring:
|
|
202
|
+
scope_wiring: detected_scope_name !== void 0 ? void 0 : {
|
|
201
203
|
component_scope_ref: name_allocator.reserve("ComponentScopeRef"),
|
|
202
204
|
get_dispatcher: name_allocator.reserve("get_dispatcher"),
|
|
203
205
|
...is_server_target ? {} : { on_destroy: name_allocator.reserve("onDestroy") }
|
|
@@ -300,6 +302,37 @@ function is_import_helper(helper) {
|
|
|
300
302
|
function collect_script_binding_names(script_content) {
|
|
301
303
|
return collect_top_level_binding_names(ts.createSourceFile("markup-script.ts", script_content, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS));
|
|
302
304
|
}
|
|
305
|
+
function extract_script_scope_binding(scripts) {
|
|
306
|
+
for (const { text } of scripts) {
|
|
307
|
+
const source_file = ts.createSourceFile("markup-script.ts", text, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
|
|
308
|
+
const component_scope_refs = collect_component_scope_ref_names(source_file);
|
|
309
|
+
for (const stmt of source_file.statements) {
|
|
310
|
+
if (!ts.isVariableStatement(stmt)) continue;
|
|
311
|
+
for (const decl of stmt.declarationList.declarations) {
|
|
312
|
+
if (!ts.isIdentifier(decl.name)) continue;
|
|
313
|
+
if (!is_generated_scope_name(decl.name.text)) continue;
|
|
314
|
+
if (!decl.initializer || !ts.isNewExpression(decl.initializer)) continue;
|
|
315
|
+
if (ts.isIdentifier(decl.initializer.expression) && component_scope_refs.has(decl.initializer.expression.text)) return decl.name.text;
|
|
316
|
+
if (ts.isPropertyAccessExpression(decl.initializer.expression) && ts.isIdentifier(decl.initializer.expression.expression) && component_scope_refs.has(decl.initializer.expression.expression.text) && decl.initializer.expression.name.text === "ComponentScopeRef") return decl.name.text;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
function collect_component_scope_ref_names(source_file) {
|
|
322
|
+
const scope_ref_names = /* @__PURE__ */ new Set(["ComponentScopeRef"]);
|
|
323
|
+
for (const stmt of source_file.statements) {
|
|
324
|
+
if (!ts.isImportDeclaration(stmt) || !ts.isStringLiteral(stmt.moduleSpecifier) || stmt.moduleSpecifier.text !== "svelte-effect-runtime/internal/generators") continue;
|
|
325
|
+
const clause = stmt.importClause;
|
|
326
|
+
if (!clause || clause.isTypeOnly) continue;
|
|
327
|
+
const named_bindings = clause.namedBindings;
|
|
328
|
+
if (!named_bindings || !ts.isNamedImports(named_bindings)) continue;
|
|
329
|
+
for (const element of named_bindings.elements) if (element.propertyName?.text === "ComponentScopeRef") scope_ref_names.add(element.name.text);
|
|
330
|
+
}
|
|
331
|
+
return scope_ref_names;
|
|
332
|
+
}
|
|
333
|
+
function is_generated_scope_name(name) {
|
|
334
|
+
return /^__SER___scope(?:_\d+)?$/.test(name);
|
|
335
|
+
}
|
|
303
336
|
function make_name_allocator(initial_names) {
|
|
304
337
|
const used_names = new Set(initial_names);
|
|
305
338
|
return { reserve(name) {
|
|
@@ -1561,4 +1594,4 @@ function transform_markup_effect(content, filename, options = {}) {
|
|
|
1561
1594
|
//#endregion
|
|
1562
1595
|
export { slice_start as a, find_yield_star_node as c, collect_top_level_binding_names as d, has_local_import_binding as f, slice as i, is_yield_star_expression as l, validate_rune_yield_usage as n, collect_yield_star_nodes as o, make_imports as p, create_source_map as r, contains_top_level_await as s, transform_markup_effect as t, collect_free_identifiers as u };
|
|
1563
1596
|
|
|
1564
|
-
//# sourceMappingURL=transform-
|
|
1597
|
+
//# sourceMappingURL=transform-C0jW8Qta.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform-C0jW8Qta.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/compiler/markup-identifiers.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/event-attributes.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/script-transform/ast.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/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\tneeds_on_destroy?: boolean;\n\tneeds_yield_success?: boolean;\n\tneeds_yieldable?: boolean;\n\tneeds_scope_ref?: boolean;\n}\n\nexport function make_imports(\n\thas_effect_import: boolean,\n\thas_dispatcher_import: boolean,\n\thas_untrack_import: boolean,\n\thas_on_destroy_import: boolean,\n\tbindings: RuntimeImportBindings = {\n\t\tcancel: \"__SER___cancel\",\n\t\tcomponent_scope_ref: \"ComponentScopeRef\",\n\t\tdispatcher: \"get_dispatcher\",\n\t\tdispatcher_value: \"__SER___dispatcher\",\n\t\teffect: \"Effect\",\n\t\ton_destroy: \"onDestroy\",\n\t\tprogram: \"__SER___program\",\n\t\tscope: \"__SER___scope\",\n\t\tuntrack: \"untrack\",\n\t\tyield_success: \"YieldSuccess\",\n\t\tyieldable: \"ToEffect\",\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\tconst needs_on_destroy = options.needs_on_destroy ?? false;\n\tconst needs_yield_success = options.needs_yield_success ?? false;\n\tconst needs_yieldable = options.needs_yieldable ?? false;\n\tconst needs_scope_ref = options.needs_scope_ref ?? true;\n\n\tconst generator_import = make_generator_import(\n\t\tbindings,\n\t\tneeds_dispatcher && !has_dispatcher_import,\n\t\tneeds_yieldable,\n\t\tneeds_yield_success,\n\t\tneeds_scope_ref,\n\t);\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 on_destroy_import =\n\t\tbindings.on_destroy === \"onDestroy\"\n\t\t\t? `import { onDestroy } from \"svelte\";`\n\t\t\t: `import { onDestroy as ${bindings.on_destroy} } 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\tgenerator_import,\n\t\tneeds_untrack && !has_untrack_import && untrack_import,\n\t\tneeds_on_destroy && !has_on_destroy_import && on_destroy_import,\n\t\tneeds_effect && effect_import,\n\t]\n\t\t.filter(Boolean)\n\t\t.join(\"\\n\");\n}\n\nfunction make_generator_import(\n\tbindings: RuntimeImportBindings,\n\tneeds_dispatcher: boolean,\n\tneeds_yieldable: boolean,\n\tneeds_yield_success: boolean,\n\tneeds_scope_ref: boolean,\n): string | false {\n\tconst specifiers = [\n\t\tneeds_dispatcher && make_named_import(\"get_dispatcher\", bindings.dispatcher),\n\t\tneeds_yieldable && make_named_import(\"ToEffect\", bindings.yieldable),\n\t\tneeds_yield_success && make_named_import(\"YieldSuccess\", bindings.yield_success, true),\n\t\tneeds_scope_ref && make_named_import(\"ComponentScopeRef\", bindings.component_scope_ref),\n\t].filter((specifier): specifier is string => specifier !== false);\n\n\tif (specifiers.length === 0) {\n\t\treturn false;\n\t}\n\n\treturn `import { ${specifiers.join(\", \")} } from \"svelte-effect-runtime/internal/generators\";`;\n}\n\nfunction make_named_import(imported_name: string, local_name: string, type_only = false): string {\n\tconst prefix = type_only ? \"type \" : \"\";\n\n\treturn imported_name === local_name\n\t\t? `${prefix}${imported_name}`\n\t\t: `${prefix}${imported_name} as ${local_name}`;\n}\n\nexport function has_local_import_binding(\n\tsource_file: ts.SourceFile,\n\tmodule_name: string,\n\tlocal_name: string,\n\tallow_namespace_import = true,\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 allow_namespace_import && 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\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","import type { SvelteEffectSourceScan } from \"./source-scan.ts\";\n\nimport ts from \"typescript\";\n\nconst wrapper_name = \"__SER___markup_identifiers\";\nconst identifier_names_by_scan = new WeakMap<SvelteEffectSourceScan, ReadonlySet<string>>();\n\nexport function collect_markup_identifier_names(\n\tsource_scan: SvelteEffectSourceScan,\n): ReadonlySet<string> {\n\tconst cached_names = identifier_names_by_scan.get(source_scan);\n\n\tif (cached_names) {\n\t\treturn cached_names;\n\t}\n\n\tconst names = new Set(source_scan.markup_binding_names);\n\n\tfor (const expression of source_scan.markup_expressions) {\n\t\tconst source_file = ts.createSourceFile(\n\t\t\t\"markup-identifiers.ts\",\n\t\t\tmake_identifier_parse_source(expression.inner),\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_identifier_names(source_file, names);\n\t}\n\n\tnames.delete(wrapper_name);\n\tidentifier_names_by_scan.set(source_scan, names);\n\n\treturn names;\n}\n\nfunction make_identifier_parse_source(expression: string): string {\n\tconst snippet = expression.match(/^(\\s*)#snippet\\s+([\\s\\S]*)$/);\n\n\tif (snippet) {\n\t\treturn `function* ${wrapper_name}() { ${snippet[1]}function ${snippet[2]} {} }`;\n\t}\n\n\treturn `function* ${wrapper_name}() { ${expression} }`;\n}\n\nfunction collect_source_file_identifier_names(\n\tsource_file: ts.SourceFile,\n\tnames: Set<string>,\n): void {\n\tconst visit = (node: ts.Node): void => {\n\t\tif (ts.isIdentifier(node) && !is_non_runtime_property_name(node)) {\n\t\t\tnames.add(node.text);\n\t\t}\n\n\t\tts.forEachChild(node, visit);\n\t};\n\n\tvisit(source_file);\n}\n\nfunction is_non_runtime_property_name(identifier: ts.Identifier): boolean {\n\tconst parent = identifier.parent;\n\n\treturn (\n\t\tis_within_type_node(identifier) ||\n\t\t(ts.isPropertyAccessExpression(parent) && parent.name === identifier) ||\n\t\t(ts.isPropertyAssignment(parent) && parent.name === identifier) ||\n\t\t(ts.isPropertySignature(parent) && parent.name === identifier) ||\n\t\t(ts.isMethodDeclaration(parent) && parent.name === identifier) ||\n\t\t(ts.isMethodSignature(parent) && parent.name === identifier) ||\n\t\t(ts.isGetAccessorDeclaration(parent) && parent.name === identifier) ||\n\t\t(ts.isSetAccessorDeclaration(parent) && parent.name === identifier) ||\n\t\t(ts.isPropertyDeclaration(parent) && parent.name === identifier) ||\n\t\t(ts.isEnumMember(parent) && parent.name === identifier) ||\n\t\t(ts.isBindingElement(parent) && parent.propertyName === identifier)\n\t);\n}\n\nfunction is_within_type_node(identifier: ts.Identifier): boolean {\n\tlet ancestor: ts.Node | undefined = identifier.parent;\n\n\twhile (ancestor) {\n\t\tif (ts.isTypeNode(ancestor)) {\n\t\t\treturn true;\n\t\t}\n\n\t\tancestor = ancestor.parent;\n\t}\n\n\treturn false;\n}\n","export const default_helper_bindings = {\n\tcodes: \"Code\",\n\tdispatcher: \"Dispatcher\",\n\tyieldable: \"ToEffect\",\n\tscope: \"__SER___scope\",\n} as const;\n","import type {\n\tHelperDeclaration,\n\tInsertion,\n\tMarkupTransformTarget,\n\tMarkupHelperBindings,\n\tMarkupRelocation,\n\tMarkupScopeWiring,\n\tPendingRelocation,\n\tReplacement,\n} from \"./types.ts\";\nimport type { SvelteEffectSourceScan } from \"$/compiler/source-scan.ts\";\nimport { collect_top_level_binding_names } from \"$/script-transform/imports.ts\";\nimport { collect_markup_identifier_names } from \"$/compiler/markup-identifiers.ts\";\nimport { default_helper_bindings } from \"./constants.ts\";\n\nimport type MagicString from \"magic-string\";\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 inject_helpers(\n\tmagic: MagicString,\n\tsource_scan: SvelteEffectSourceScan,\n\thelpers: HelperDeclaration[] = [],\n\tbindings: MarkupHelperBindings = default_helper_bindings,\n\tscope_wiring?: MarkupScopeWiring | undefined,\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}> = [make_dispatcher_import(bindings, scope_wiring), ...import_helpers, ...local_helpers]\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\tconst scope_block = scope_wiring ? make_scope_wiring_block(bindings, scope_wiring) : undefined;\n\n\tconst instance_script = source_scan.instance_script;\n\n\tif (instance_script) {\n\t\t/**\n\t\t * The scope holder must be declared before any user statement so its\n\t\t * `onDestroy` runs during component initialisation, ahead of any\n\t\t * top-level `await`.\n\t\t */\n\t\tconst scope_text = scope_block ? `\\n${scope_block}\\n` : undefined;\n\n\t\tif (scope_text) {\n\t\t\tmagic.appendLeft(instance_script.content_start, scope_text);\n\t\t}\n\n\t\tconst text = `\\n${helper_block}\\n`;\n\n\t\tmagic.appendLeft(instance_script.content_end, text);\n\n\t\treturn {\n\t\t\tstart: instance_script.content_end,\n\t\t\ttext,\n\t\t\textra_insertions: scope_text\n\t\t\t\t? [{ start: instance_script.content_start, text: scope_text }]\n\t\t\t\t: [],\n\t\t\trelocations: make_insertion_relocations(helper_segments, \"\\n\"),\n\t\t};\n\t} else {\n\t\tconst text = `<script>\\n${[scope_block, helper_block].filter(Boolean).join(\"\\n\")}\\n</script>\\n\\n`;\n\t\tconst helper_prefix = `<script>\\n${scope_block ? scope_block + \"\\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, helper_prefix),\n\t\t};\n\t}\n}\n\nexport function make_markup_helper_bindings(\n\tsource_scan: SvelteEffectSourceScan,\n\ttarget: MarkupTransformTarget = \"client\",\n): {\n\tbindings: MarkupHelperBindings;\n\tname_allocator: { reserve(name: string): string };\n\tscope_wiring: MarkupScopeWiring | undefined;\n} {\n\tconst script_binding_names = source_scan.scripts.flatMap((script) =>\n\t\tcollect_script_binding_names(script.text),\n\t);\n\tconst markup_identifier_names = collect_markup_identifier_names(source_scan);\n\tconst detected_scope_name = extract_script_scope_binding(source_scan.scripts);\n\tconst name_allocator = make_name_allocator([\n\t\t...script_binding_names,\n\t\t...markup_identifier_names,\n\t]);\n\n\tconst scope = detected_scope_name ?? name_allocator.reserve(default_helper_bindings.scope);\n\n\tconst bindings = {\n\t\tcodes: name_allocator.reserve(default_helper_bindings.codes),\n\t\tdispatcher: name_allocator.reserve(default_helper_bindings.dispatcher),\n\t\tyieldable: name_allocator.reserve(default_helper_bindings.yieldable),\n\t\tscope,\n\t};\n\n\tconst is_server_target = target === \"server\";\n\n\t/**\n\t * The script transform declares the component scope holder when it lowers\n\t * a `<script effect>`. When no script declares one — a markup-only\n\t * component for client/editor targets — reserve the names the injected scope\n\t * wiring needs so markup emit calls still have a scope to enter.\n\t */\n\tconst scope_present = detected_scope_name !== undefined;\n\tconst scope_wiring = scope_present\n\t\t? undefined\n\t\t: {\n\t\t\t\tcomponent_scope_ref: name_allocator.reserve(\"ComponentScopeRef\"),\n\t\t\t\tget_dispatcher: name_allocator.reserve(\"get_dispatcher\"),\n\t\t\t\t...(is_server_target ? {} : { on_destroy: name_allocator.reserve(\"onDestroy\") }),\n\t\t\t};\n\n\treturn {\n\t\tbindings,\n\t\tname_allocator,\n\t\tscope_wiring,\n\t};\n}\n\nexport function create_relocations(\n\treplacements: Replacement[],\n\thelper_insertion: Insertion | undefined,\n): MarkupRelocation[] {\n\tconst ordered_replacements = [...replacements].sort((left, right) => left.start - right.start);\n\tconst replacement_deltas = new Map<Replacement, number>();\n\tlet accumulated_delta = 0;\n\tlet replacement_delta_before_helper = 0;\n\tlet cursor = 0;\n\n\twhile (cursor < ordered_replacements.length) {\n\t\tconst start = ordered_replacements[cursor]?.start;\n\t\tlet group_end = cursor;\n\t\tlet group_delta = 0;\n\n\t\twhile (ordered_replacements[group_end]?.start === start) {\n\t\t\tconst replacement = ordered_replacements[group_end];\n\n\t\t\tif (replacement) {\n\t\t\t\treplacement_deltas.set(replacement, accumulated_delta);\n\t\t\t\tgroup_delta += replacement.text.length - (replacement.end - replacement.start);\n\t\t\t}\n\n\t\t\tgroup_end += 1;\n\t\t}\n\n\t\tif (helper_insertion && start !== undefined && start < helper_insertion.start) {\n\t\t\treplacement_delta_before_helper += group_delta;\n\t\t}\n\n\t\taccumulated_delta += group_delta;\n\t\tcursor = group_end;\n\t}\n\n\tconst insertion_shift_before = (point: number): number => {\n\t\tif (!helper_insertion) {\n\t\t\treturn 0;\n\t\t}\n\n\t\tconst helper_shift = helper_insertion.start <= point ? helper_insertion.text.length : 0;\n\t\tconst extra_shift = (helper_insertion.extra_insertions ?? [])\n\t\t\t.filter((insertion) => insertion.start <= point)\n\t\t\t.reduce((shift, insertion) => shift + insertion.text.length, 0);\n\n\t\treturn helper_shift + extra_shift;\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 replacement_delta_before = replacement_deltas.get(replacement) ?? 0;\n\t\tconst delta_before = replacement_delta_before + insertion_shift_before(replacement.start);\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_generated_start =\n\t\t(helper_insertion?.start ?? 0) +\n\t\treplacement_delta_before_helper +\n\t\t(helper_insertion?.extra_insertions ?? [])\n\t\t\t.filter((insertion) => helper_insertion && insertion.start <= helper_insertion.start)\n\t\t\t.reduce((shift, insertion) => shift + insertion.text.length, 0);\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_generated_start + relocation.generatedStartInReplacement,\n\t\t\tgeneratedEnd: helper_generated_start + relocation.generatedEndInReplacement,\n\t\t})) ?? [];\n\n\treturn [...replacement_relocations, ...helper_relocations];\n}\n\nfunction make_dispatcher_import(\n\tbindings: MarkupHelperBindings,\n\tscope_wiring?: MarkupScopeWiring | undefined,\n): string {\n\tconst dispatcher = make_import_specifier(\n\t\tdefault_helper_bindings.dispatcher,\n\t\tbindings.dispatcher,\n\t);\n\tconst codes = make_import_specifier(default_helper_bindings.codes, bindings.codes);\n\tconst yieldable = make_import_specifier(default_helper_bindings.yieldable, bindings.yieldable);\n\n\t/**\n\t * The scope holder's imports ride on the shared generators import so the\n\t * component keeps a single import from the runtime entrypoint.\n\t */\n\tconst scope_specifiers = scope_wiring\n\t\t? [\n\t\t\t\tmake_import_specifier(\"ComponentScopeRef\", scope_wiring.component_scope_ref),\n\t\t\t\tmake_import_specifier(\"get_dispatcher\", scope_wiring.get_dispatcher),\n\t\t\t]\n\t\t: [];\n\n\treturn `import { ${[dispatcher, codes, yieldable, ...scope_specifiers].join(\", \")} } 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_scope_wiring_block(\n\tbindings: MarkupHelperBindings,\n\tscope_wiring: MarkupScopeWiring,\n): string {\n\tconst on_destroy_import = scope_wiring.on_destroy\n\t\t? make_import_specifier(\"onDestroy\", scope_wiring.on_destroy)\n\t\t: undefined;\n\tconst on_destroy_call = scope_wiring.on_destroy\n\t\t? `${scope_wiring.on_destroy}(() => ${bindings.scope}.dispose());`\n\t\t: undefined;\n\tconst import_statement = on_destroy_import\n\t\t? `import { ${on_destroy_import} } from \"svelte\";`\n\t\t: undefined;\n\n\treturn [\n\t\timport_statement,\n\t\t`const ${bindings.scope} = new ${scope_wiring.component_scope_ref}(${scope_wiring.get_dispatcher});`,\n\t\ton_destroy_call,\n\t].join(\"\\n\");\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 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 extract_script_scope_binding(\n\tscripts: ReadonlyArray<{ readonly text: string }>,\n): string | undefined {\n\tfor (const { text } of scripts) {\n\t\tconst source_file = ts.createSourceFile(\n\t\t\t\"markup-script.ts\",\n\t\t\ttext,\n\t\t\tts.ScriptTarget.Latest,\n\t\t\ttrue,\n\t\t\tts.ScriptKind.TS,\n\t\t);\n\n\t\tconst component_scope_refs = collect_component_scope_ref_names(source_file);\n\n\t\tfor (const stmt of source_file.statements) {\n\t\t\tif (!ts.isVariableStatement(stmt)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tfor (const decl of stmt.declarationList.declarations) {\n\t\t\t\tif (!ts.isIdentifier(decl.name)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif (!is_generated_scope_name(decl.name.text)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif (!decl.initializer || !ts.isNewExpression(decl.initializer)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\tts.isIdentifier(decl.initializer.expression) &&\n\t\t\t\t\tcomponent_scope_refs.has(decl.initializer.expression.text)\n\t\t\t\t) {\n\t\t\t\t\treturn decl.name.text;\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\tts.isPropertyAccessExpression(decl.initializer.expression) &&\n\t\t\t\t\tts.isIdentifier(decl.initializer.expression.expression) &&\n\t\t\t\t\tcomponent_scope_refs.has(decl.initializer.expression.expression.text) &&\n\t\t\t\t\tdecl.initializer.expression.name.text === \"ComponentScopeRef\"\n\t\t\t\t) {\n\t\t\t\t\treturn decl.name.text;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\nfunction collect_component_scope_ref_names(source_file: ts.SourceFile): Set<string> {\n\tconst scope_ref_names = new Set([\"ComponentScopeRef\"]);\n\n\tfor (const stmt of source_file.statements) {\n\t\tif (\n\t\t\t!ts.isImportDeclaration(stmt) ||\n\t\t\t!ts.isStringLiteral(stmt.moduleSpecifier) ||\n\t\t\tstmt.moduleSpecifier.text !== \"svelte-effect-runtime/internal/generators\"\n\t\t) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst clause = stmt.importClause;\n\n\t\tif (!clause || clause.isTypeOnly) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst named_bindings = clause.namedBindings;\n\n\t\tif (!named_bindings || !ts.isNamedImports(named_bindings)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tfor (const element of named_bindings.elements) {\n\t\t\tif (element.propertyName?.text === \"ComponentScopeRef\") {\n\t\t\t\tscope_ref_names.add(element.name.text);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn scope_ref_names;\n}\n\nfunction is_generated_scope_name(name: string): boolean {\n\treturn /^__SER___scope(?:_\\d+)?$/.test(name);\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 { ScriptRegion } from \"$/compiler/source-scan.ts\";\nimport 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\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\nexport function collect_effect_callback_bindings(\n\tscripts: readonly ScriptRegion[],\n): EffectCallbackRewriteContext {\n\tconst state = make_effect_binding_state();\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.text,\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_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 state.implicit_effect_import\n\t\t\t? {\n\t\t\t\t\texpression: effect_object,\n\t\t\t\t\timport_text: `import { Effect } from \"effect\";`,\n\t\t\t\t}\n\t\t\t: { expression: effect_object };\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","export function is_svelte_event_attribute(attribute: {\n\ttype: string;\n\tname?: string;\n\tvalue?: unknown;\n}): boolean {\n\tif (attribute.type !== \"Attribute\" || !attribute.name?.startsWith(\"on\")) {\n\t\treturn false;\n\t}\n\n\tconst value = attribute.value;\n\n\treturn (\n\t\t(value !== true && !Array.isArray(value)) ||\n\t\t(Array.isArray(value) && value.length === 1 && value[0]?.type === \"ExpressionTag\")\n\t);\n}\n\nexport function normalize_event_attribute_name(name: string): string {\n\tif (name.startsWith(\"on:\")) {\n\t\treturn `on:${name.slice(3).toLowerCase()}`;\n\t}\n\n\treturn name.toLowerCase();\n}\n","import { is_svelte_event_attribute, normalize_event_attribute_name } from \"../event-attributes.ts\";\nimport type { MarkupCandidate, TagKind } from \"./types.ts\";\nimport type { AST } from \"svelte/compiler\";\n\ninterface ClassifiedCandidate {\n\tcandidate: MarkupCandidate;\n\tkind: TagKind;\n\tattribute_name_replacement: AttributeNameReplacement | undefined;\n}\n\ninterface AttributeNameReplacement {\n\tstart: number;\n\tend: number;\n\ttext: string;\n}\n\nexport function classify_candidates(\n\tast: AST.Root,\n\tcandidates: MarkupCandidate[],\n): ClassifiedCandidate[] {\n\tconst by_placeholder = new Map(\n\t\tcandidates.map((candidate) => [candidate.placeholder, candidate]),\n\t);\n\n\tconst classified: ClassifiedCandidate[] = [];\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: ClassifiedCandidate[],\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: ClassifiedCandidate[],\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, \"html\", 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 \"SnippetBlock\":\n\t\t\twalk_ast(node.body, candidates, matched, classified);\n\t\t\treturn;\n\n\t\tcase \"SvelteElement\":\n\t\t\tclassify_expression(\n\t\t\t\tnode.tag as ExpressionLike,\n\t\t\t\t\"plain\",\n\t\t\t\tcandidates,\n\t\t\t\tmatched,\n\t\t\t\tclassified,\n\t\t\t);\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\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 \"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: ClassifiedCandidate[],\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: ClassifiedCandidate[],\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\ttype: string;\n\tattributes: Array<{\n\t\ttype: string;\n\t\tstart?: number;\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: ClassifiedCandidate[],\n): void {\n\tfor (const attr of node.attributes) {\n\t\tif (is_svelte_event_attribute(attr)) {\n\t\t\tconst attribute_name_replacement = make_attribute_name_replacement(node, attr);\n\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\tattribute_name_replacement,\n\t\t\t);\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (attr.type === \"OnDirective\" && attr.expression) {\n\t\t\tconst attribute_name_replacement = make_directive_name_replacement(node, attr);\n\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\tattribute_name_replacement,\n\t\t\t);\n\t\t\tcontinue;\n\t\t}\n\t}\n}\n\nfunction make_attribute_name_replacement(\n\tnode: ElementLikeNode,\n\tattr: { start?: number; name?: string },\n): AttributeNameReplacement | undefined {\n\tif (!attr.name || !should_normalize_event_attribute_name(node) || attr.start === undefined) {\n\t\treturn undefined;\n\t}\n\n\tconst normalized_name = normalize_event_attribute_name(attr.name);\n\n\tif (normalized_name === attr.name) {\n\t\treturn undefined;\n\t}\n\n\treturn {\n\t\tstart: attr.start,\n\t\tend: attr.start + attr.name.length,\n\t\ttext: normalized_name,\n\t};\n}\n\nfunction make_directive_name_replacement(\n\tnode: ElementLikeNode,\n\tattr: { start?: number; name?: string },\n): AttributeNameReplacement | undefined {\n\tif (!attr.name || !should_normalize_event_attribute_name(node) || attr.start === undefined) {\n\t\treturn undefined;\n\t}\n\n\tconst original_name = `on:${attr.name}`;\n\tconst normalized_name = normalize_event_attribute_name(original_name);\n\n\tif (normalized_name === original_name) {\n\t\treturn undefined;\n\t}\n\n\treturn {\n\t\tstart: attr.start,\n\t\tend: attr.start + original_name.length,\n\t\ttext: normalized_name,\n\t};\n}\n\nfunction should_normalize_event_attribute_name(node: ElementLikeNode): boolean {\n\treturn (\n\t\tnode.type !== \"Component\" && node.type !== \"SvelteComponent\" && node.type !== \"SvelteSelf\"\n\t);\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: ClassifiedCandidate[],\n\tattribute_name_replacement?: AttributeNameReplacement,\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(\n\t\t\t\t\tpart.expression,\n\t\t\t\t\tkind,\n\t\t\t\t\tcandidates,\n\t\t\t\t\tmatched,\n\t\t\t\t\tclassified,\n\t\t\t\t\tattribute_name_replacement,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\treturn;\n\t}\n\n\tclassify_expression(\n\t\tvalue.expression,\n\t\tkind,\n\t\tcandidates,\n\t\tmatched,\n\t\tclassified,\n\t\tattribute_name_replacement,\n\t);\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: ClassifiedCandidate[],\n\tattribute_name_replacement?: AttributeNameReplacement,\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\tattribute_name_replacement,\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\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\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\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\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 type { EffectCallbackRewriteContext } from \"./effect-bindings.ts\";\nimport { contains_top_level_yield_star } from \"$/detect.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\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 ts from \"typescript\";\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\nfunction 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\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\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\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","import type {\n\tHelperDeclaration,\n\tMarkupCandidate,\n\tMarkupHelperBindings,\n\tMarkupNameAllocator,\n\tMarkupTransformTarget,\n\tPendingRelocation,\n\tReplacement,\n\tTagKind,\n} from \"./types.ts\";\nimport {\n\tanalyze_event_body_yield_star,\n\tcollect_free_identifiers,\n\tis_callback_function_expression,\n} from \"./expressions.ts\";\nimport { AsyncEffectInEventCallbackError, YieldStarInEventCallbackError } from \"$/errors.ts\";\nimport type { EffectCallbackRewriteContext } from \"./effect-bindings.ts\";\nimport { normalize_effect_callback_yields } from \"./effect-callbacks.ts\";\nimport { collect_yield_star_nodes } from \"$/script-transform/ast.ts\";\n\nimport ts from \"typescript\";\n\ninterface ClassifiedCandidate {\n\tcandidate: MarkupCandidate;\n\tkind: TagKind;\n\tattribute_name_replacement: AttributeNameReplacement | undefined;\n}\n\ninterface AttributeNameReplacement {\n\tstart: number;\n\tend: number;\n\ttext: string;\n}\n\ntype ExpressionRelocation = {\n\toriginalStart: number;\n\toriginalEnd: number;\n\tgeneratedStart: number;\n\tgeneratedEnd: number;\n};\n\nexport function emit_replacements(\n\tclassified: ClassifiedCandidate[],\n\teffect_context: EffectCallbackRewriteContext,\n\thelper_bindings: MarkupHelperBindings,\n\tname_allocator: MarkupNameAllocator,\n\ttarget: MarkupTransformTarget,\n): Replacement[] {\n\tconst expression_replacements = classified.map(({ candidate, kind }) =>\n\t\temit_replacement(candidate, kind, effect_context, helper_bindings, name_allocator, target),\n\t);\n\tconst attribute_replacements = unique_attribute_name_replacements(classified).map(\n\t\t(replacement) => ({\n\t\t\tstart: replacement.start,\n\t\t\tend: replacement.end,\n\t\t\ttext: replacement.text,\n\t\t}),\n\t);\n\n\treturn [...attribute_replacements, ...expression_replacements];\n}\n\nfunction unique_attribute_name_replacements(\n\tclassified: ClassifiedCandidate[],\n): AttributeNameReplacement[] {\n\tconst seen = new Set<string>();\n\n\treturn classified\n\t\t.map((entry) => entry.attribute_name_replacement)\n\t\t.filter((replacement): replacement is AttributeNameReplacement => {\n\t\t\tif (!replacement) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst key = `${replacement.start}:${replacement.end}:${replacement.text}`;\n\n\t\t\tif (seen.has(key)) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tseen.add(key);\n\n\t\t\treturn true;\n\t\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, helper_bindings);\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, helper_bindings);\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, helper_bindings);\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, helper_bindings);\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_pending_relocation(\n\t\t\tcandidate,\n\t\t\treplacement_text,\n\t\t\tevent.expr_text,\n\t\t\tevent.relocation,\n\t\t);\n\t} else if (kind === \"html\") {\n\t\tconst effect = make_inline_effect(normalized_candidate, helper_bindings);\n\n\t\treplacement_text = emit_await_expression(id_text, effect, helper_bindings);\n\t\thelpers = normalized.helpers;\n\t\trelocation = make_pending_relocation(\n\t\t\tcandidate,\n\t\t\treplacement_text,\n\t\t\teffect.effect_text,\n\t\t\teffect.relocation,\n\t\t);\n\t} else {\n\t\tconst effect = make_effect_helper(normalized_candidate, helper_name, helper_bindings);\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\t...(relocation ? { relocation } : {}),\n\t};\n}\n\nfunction make_event_handler(\n\tcandidate: MarkupCandidate,\n\thelper_bindings: MarkupHelperBindings,\n): { text: string; expr_text: string; relocation: ExpressionRelocation | undefined } {\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\tconst wrapped_expr_text = wrap_yield_stars(expr_text, helper_bindings);\n\n\treturn {\n\t\texpr_text: wrapped_expr_text,\n\t\trelocation: make_yield_operand_relocation(expr_text, wrapped_expr_text, helper_bindings),\n\t\ttext: `(event) => { ${helper_bindings.dispatcher}.with_scope(${helper_bindings.scope}.scope, () => ${helper_bindings.dispatcher}.emit({ type: ${helper_bindings.codes}.Markup.Run, fn: function* () { ${wrapped_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}.with_scope(${helper_bindings.scope}.scope, () => ${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\tcall: string;\n\tdeps_text: string;\n}\n\ninterface DeclaredEffectHelper extends EffectHelper {\n\thelper: HelperDeclaration;\n}\n\ninterface InlineEffectHelper extends EffectHelper {\n\teffect_text: string;\n\trelocation: ExpressionRelocation | undefined;\n}\n\nfunction make_effect_helper(\n\tcandidate: MarkupCandidate,\n\thelper_name: string,\n\thelper_bindings: Pick<MarkupHelperBindings, \"yieldable\">,\n): DeclaredEffectHelper {\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 effect_text = wrap_yield_stars(candidate.expr_text, helper_bindings);\n\tconst text = `function* ${helper_name}() { return (${effect_text}); }`;\n\tconst generated_start = text.indexOf(effect_text);\n\tconst operand_relocation = make_yield_operand_relocation(\n\t\tcandidate.expr_text,\n\t\teffect_text,\n\t\thelper_bindings,\n\t);\n\tconst relocation =\n\t\toperand_relocation ??\n\t\t({\n\t\t\toriginalStart: 0,\n\t\t\toriginalEnd: candidate.expr_text.length,\n\t\t\tgeneratedStart: 0,\n\t\t\tgeneratedEnd: effect_text.length,\n\t\t} satisfies ExpressionRelocation);\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 + relocation.originalStart,\n\t\t\t\toriginalEnd: candidate.start + relocation.originalEnd,\n\t\t\t\tgeneratedStartInReplacement: generated_start + relocation.generatedStart,\n\t\t\t\tgeneratedEndInReplacement: generated_start + relocation.generatedEnd,\n\t\t\t},\n\t\t},\n\t};\n}\n\nfunction make_inline_effect(\n\tcandidate: MarkupCandidate,\n\thelper_bindings: Pick<MarkupHelperBindings, \"yieldable\">,\n): InlineEffectHelper {\n\tconst deps = collect_free_identifiers(candidate.expr_text);\n\tconst deps_text = deps.length === 0 ? \"[]\" : `[${deps.join(\", \")}]`;\n\tconst effect_text = wrap_yield_stars(candidate.expr_text, helper_bindings);\n\tconst relocation = make_yield_operand_relocation(\n\t\tcandidate.expr_text,\n\t\teffect_text,\n\t\thelper_bindings,\n\t);\n\n\treturn {\n\t\tcall: `(function* () { return (${effect_text}); })()`,\n\t\tdeps_text,\n\t\teffect_text,\n\t\trelocation,\n\t};\n}\n\nfunction wrap_yield_stars(\n\ttext: string,\n\thelper_bindings: Pick<MarkupHelperBindings, \"yieldable\">,\n): string {\n\tconst source_file = ts.createSourceFile(\n\t\t\"markup-yield.ts\",\n\t\ttext,\n\t\tts.ScriptTarget.Latest,\n\t\ttrue,\n\t\tts.ScriptKind.TS,\n\t);\n\tconst replacements: Array<{\n\t\tstart: number;\n\t\tend: number;\n\t\ttext: string;\n\t}> = [];\n\n\tcollect_yield_star_nodes(source_file, (node) => {\n\t\tconst yield_text = text.slice(node.getStart(source_file), node.end).trim();\n\n\t\treplacements.push({\n\t\t\tstart: node.getStart(source_file),\n\t\t\tend: node.end,\n\t\t\ttext: `yield* ${helper_bindings.yieldable}(${strip_yield_star(yield_text)})`,\n\t\t});\n\t});\n\n\tif (replacements.length === 0) {\n\t\treturn text;\n\t}\n\n\treplacements.sort((a, b) => b.start - a.start);\n\n\tlet output = text;\n\n\tfor (const replacement of replacements) {\n\t\toutput =\n\t\t\toutput.slice(0, replacement.start) + replacement.text + output.slice(replacement.end);\n\t}\n\n\treturn output;\n}\n\nfunction strip_yield_star(yield_text: string): string {\n\treturn yield_text.replace(/^yield\\s*\\*\\s*/, \"\");\n}\n\nfunction make_yield_operand_relocation(\n\toriginal_text: string,\n\tgenerated_text: string,\n\thelper_bindings: Pick<MarkupHelperBindings, \"yieldable\">,\n): ExpressionRelocation | undefined {\n\tconst source_file = ts.createSourceFile(\n\t\t\"markup-yield-relocation.ts\",\n\t\toriginal_text,\n\t\tts.ScriptTarget.Latest,\n\t\ttrue,\n\t\tts.ScriptKind.TS,\n\t);\n\tlet yield_node: ts.Node | undefined;\n\n\tcollect_yield_star_nodes(source_file, (node) => {\n\t\tyield_node ??= node;\n\t});\n\n\tif (!yield_node || !ts.isBinaryExpression(yield_node)) {\n\t\treturn undefined;\n\t}\n\n\tconst operand = yield_node.right;\n\tconst original_start = operand.getStart(source_file);\n\tconst original_end = operand.end;\n\tconst operand_text = original_text.slice(original_start, original_end).trim();\n\tconst wrapper_text = `${helper_bindings.yieldable}(${operand_text})`;\n\tconst wrapper_start = generated_text.indexOf(wrapper_text);\n\n\tif (wrapper_start === -1) {\n\t\treturn undefined;\n\t}\n\n\tconst generated_start = wrapper_start + wrapper_text.indexOf(operand_text);\n\n\treturn {\n\t\toriginalStart: original_start,\n\t\toriginalEnd: original_end,\n\t\tgeneratedStart: generated_start,\n\t\tgeneratedEnd: generated_start + operand_text.length,\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_pending_relocation(\n\tcandidate: MarkupCandidate,\n\treplacement_text: string,\n\texpression_text: string,\n\trelocation: ExpressionRelocation | undefined,\n): PendingRelocation | undefined {\n\tif (!relocation) {\n\t\treturn undefined;\n\t}\n\n\tconst generated_start = replacement_text.indexOf(expression_text);\n\n\tif (generated_start === -1) {\n\t\treturn undefined;\n\t}\n\n\treturn {\n\t\toriginalStart: candidate.start + relocation.originalStart,\n\t\toriginalEnd: candidate.start + relocation.originalEnd,\n\t\tgeneratedStartInReplacement: generated_start + relocation.generatedStart,\n\t\tgeneratedEndInReplacement: generated_start + relocation.generatedEnd,\n\t};\n}\n","import type MagicString from \"magic-string\";\nimport type 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 slice(content: string, node: ts.Node): string {\n\treturn content.slice(node.getFullStart(), node.end);\n}\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\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 { analyze_event_body_yield_star, strip_arrow_function } from \"./expressions.ts\";\nimport { validate_rune_yield_usage } from \"$/script-transform/runes.ts\";\nimport type { SvelteEffectSourceScan } from \"$/compiler/source-scan.ts\";\nimport { collect_yield_star_nodes } from \"$/script-transform/ast.ts\";\nimport { contains_top_level_yield_star } from \"$/detect.ts\";\nimport type { MarkupCandidate, TagKind } from \"./types.ts\";\nimport { default_helper_bindings } from \"./constants.ts\";\n\nimport MagicString from \"magic-string\";\nimport ts from \"typescript\";\n\ninterface SanitizeResult {\n\tparse_code: string;\n\tcandidates: MarkupCandidate[];\n}\n\ninterface DeclarationYieldExpression {\n\tstart: number;\n\tend: number;\n\texpr_text: string;\n}\n\nexport function sanitize_markup(source_scan: SvelteEffectSourceScan): SanitizeResult {\n\tconst content = source_scan.source;\n\tconst filename = source_scan.filename;\n\tconst candidates: MarkupCandidate[] = [];\n\tconst magic = new MagicString(content);\n\tlet helper_index = 0;\n\n\tfor (const expression of source_scan.markup_expressions) {\n\t\tconst open = expression.open;\n\t\tconst close = expression.close;\n\t\tconst inner = expression.inner;\n\t\tconst trimmed = inner.trimStart();\n\t\tconst leading_ws = inner.length - trimmed.length;\n\t\tconst tag_info = get_tag_info(trimmed);\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\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\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\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\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\t}\n\n\tif (candidates.length === 0) {\n\t\treturn { parse_code: content, candidates };\n\t}\n\n\tfor (const region of source_scan.scripts) {\n\t\tconst region_source = content.slice(region.start, region.end);\n\n\t\tmagic.overwrite(\n\t\t\tregion.start,\n\t\t\tregion.end,\n\t\t\tblank_script_region(region_source, region.is_module, region.is_typescript),\n\t\t);\n\t}\n\n\tfor (const region of source_scan.styles) {\n\t\tconst region_source = content.slice(region.start, region.end);\n\n\t\tmagic.overwrite(region.start, region.end, blank_source_region(region_source));\n\t}\n\n\treturn { parse_code: magic.toString(), candidates };\n}\n\nfunction blank_source_region(source: string): string {\n\treturn source.replace(/[^\\r\\n]/g, \" \");\n}\n\nfunction blank_script_region(source: string, is_module: boolean, is_typescript: boolean): string {\n\tconst module_attribute = is_module ? \" module\" : \"\";\n\tconst lang_attribute = is_typescript ? \" lang=ts\" : \"\";\n\tconst scaffold = `<script${module_attribute}${lang_attribute}></script>`;\n\n\treturn scaffold + blank_source_region(source.slice(scaffold.length));\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\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(\"@attach \")) {\n\t\treturn { kind: \"plain\", prefix_length: \"@attach \".length };\n\t}\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: \"html\", prefix_length: \"@html \".length };\n\t}\n\tif (trimmed.startsWith(\"@debug \")) {\n\t\treturn { kind: \"plain\", prefix_length: \"@debug \".length };\n\t}\n\tif (trimmed.startsWith(\"...\")) {\n\t\treturn { kind: \"plain\", prefix_length: \"...\".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`${default_helper_bindings.dispatcher}(?:_\\\\d+)?\\\\.emit\\\\(\\\\{\\\\s*type:\\\\s*${default_helper_bindings.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\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 { scan_svelte_effect_source } from \"$/compiler/source-scan.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\tconst source_scan = scan_svelte_effect_source(content, filename);\n\n\t/** Find all brace expressions containing yield* and replace with placeholders. */\n\tconst work = sanitize_markup(source_scan);\n\n\tif (work.candidates.length === 0) {\n\t\treturn { code: content, has_yield: false };\n\t}\n\n\tconst effect_context = collect_effect_callback_bindings(source_scan.scripts);\n\tconst helper_context = make_markup_helper_bindings(source_scan, options.target ?? \"client\");\n\n\t/** Parse the sanitized markup with Svelte's AST. */\n\tconst ast = parse(work.parse_code, { 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(\n\t\tmagic,\n\t\tsource_scan,\n\t\thelpers,\n\t\thelper_context.bindings,\n\t\thelper_context.scope_wiring,\n\t);\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":";;;;;;;AAcA,SAAgB,aACf,mBACA,uBACA,oBACA,uBACA,WAAkC;CACjC,QAAQ;CACR,qBAAqB;CACrB,YAAY;CACZ,kBAAkB;CAClB,QAAQ;CACR,YAAY;CACZ,SAAS;CACT,OAAO;CACP,SAAS;CACT,eAAe;CACf,WAAW;AACZ,GACA,UAAgC,CAAC,GACxB;CACT,MAAM,mBAAmB,QAAQ,oBAAoB;CACrD,MAAM,eAAe,QAAQ,gBAAgB;CAC7C,MAAM,gBAAgB,QAAQ,iBAAiB;CAC/C,MAAM,mBAAmB,QAAQ,oBAAoB;CACrD,MAAM,sBAAsB,QAAQ,uBAAuB;CAC3D,MAAM,kBAAkB,QAAQ,mBAAmB;CACnD,MAAM,kBAAkB,QAAQ,mBAAmB;CAEnD,MAAM,mBAAmB,sBACxB,UACA,oBAAoB,CAAC,uBACrB,iBACA,qBACA,eACD;CAEA,MAAM,iBACL,SAAS,YAAY,YAClB,sCACA,uBAAuB,SAAS,QAAQ;CAE5C,MAAM,oBACL,SAAS,eAAe,cACrB,wCACA,yBAAyB,SAAS,WAAW;CAEjD,MAAM,gBAAgB,oBACnB,QACA,SAAS,WAAW,WACnB,qCACA,sBAAsB,SAAS,OAAO;CAE1C,OAAO;EACN;EACA,iBAAiB,CAAC,sBAAsB;EACxC,oBAAoB,CAAC,yBAAyB;EAC9C,gBAAgB;CACjB,CAAC,CACC,OAAO,OAAO,CAAC,CACf,KAAK,IAAI;AACZ;AAEA,SAAS,sBACR,UACA,kBACA,iB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M;CAG1C,MAAM,iBAAiB,iCAAiC,YAAY,OAAO;CAC3E,MAAM,iBAAiB,4BAA4B,aAAa,QAAQ,UAAU,QAAQ;;CAM1F,MAAM,aAAa,oBAHP,MAAM,KAAK,YAAY;EAAE;EAAU,QAAQ;CAAK,CAGnB,GAAG,KAAK,UAAU;CAC3D,MAAM,UAAU,IAAI,IAAI,WAAW,KAAK,EAAE,gBAAgB,UAAU,WAAW,CAAC;CAChF,MAAM,YAAY,KAAK,WAAW,MAAM,cAAc,CAAC,QAAQ,IAAI,UAAU,WAAW,CAAC;CAEzF,IAAI,WACH,MAAM,IAAI,qCAAqC,UAAU,UAAU,SAAS;CAG7E,MAAM,eAAe,kBACpB,YACA,gBACA,eAAe,UACf,eAAe,gBACf,QAAQ,UAAU,QACnB;CACA,MAAM,UAAU,aAAa,SAAS,gBAAgB,YAAY,WAAW,CAAC,CAAC;CAE/E,MAAM,QAAQ,IAAI,YAAY,OAAO;CAErC,aAAa,MAAM,GAAG,MAAM,EAAE,QAAQ,EAAE,KAAK;CAE7C,KAAK,MAAM,KAAK,cACf,MAAM,UAAU,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI;CAUvC,MAAM,cAAc,mBAAmB,cAPd,eACxB,OACA,aACA,SACA,eAAe,UACf,eAAe,YAEoD,CAAC;CAErE,OAAO;EACN,MAAM,MAAM,SAAS;EACrB,WAAW;EACX,KAAKC,oBAAkB,OAAO,QAAQ;EACtC;CACD;AACD"}
|
package/.dist/dispatcher.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as Code, i as reset_dispatcher, n as Dispatcher, o as ComponentScope, r as get_dispatcher, t as ComponentScopeRef } from "./chunks/dispatcher-
|
|
1
|
+
import { a as Code, i as reset_dispatcher, n as Dispatcher, o as ComponentScope, r as get_dispatcher, t as ComponentScopeRef } from "./chunks/dispatcher-B6ZRUsjN.js";
|
|
2
2
|
export { Code, ComponentScope, ComponentScopeRef, Dispatcher, get_dispatcher, reset_dispatcher };
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { EnvVarConfig } from "@sveltejs/kit";
|
|
2
|
+
import { Schema } from "effect";
|
|
3
|
+
/**
|
|
4
|
+
* The Standard Schema validator shape SvelteKit accepts for an environment variable.
|
|
5
|
+
*
|
|
6
|
+
* @since 4.2.0
|
|
7
|
+
*/
|
|
8
|
+
export type StandardSchema<Output = unknown> = NonNullable<EnvVarConfig<Output>["schema"]>;
|
|
9
|
+
/**
|
|
10
|
+
* A validator accepted by {@link DefineEnvVars}: an Effect Schema that decodes
|
|
11
|
+
* synchronously from the raw string value, or an existing Standard Schema.
|
|
12
|
+
*
|
|
13
|
+
* @since 4.2.0
|
|
14
|
+
*/
|
|
15
|
+
export type EnvironmentSchema = (Schema.ConstraintDecoder<unknown, never> & {
|
|
16
|
+
readonly Encoded: string | undefined;
|
|
17
|
+
}) | StandardSchema<unknown>;
|
|
18
|
+
/**
|
|
19
|
+
* The decoded output type an environment schema produces.
|
|
20
|
+
*
|
|
21
|
+
* @since 4.2.0
|
|
22
|
+
*/
|
|
23
|
+
export type EnvironmentSchemaOutput<S extends EnvironmentSchema> = S extends Schema.Constraint ? S["Type"] : S extends StandardSchema<infer Output> ? Output : never;
|
|
24
|
+
/**
|
|
25
|
+
* One environment variable declaration: SvelteKit's metadata plus an Effect
|
|
26
|
+
* Schema or Standard Schema validator.
|
|
27
|
+
*
|
|
28
|
+
* @since 4.2.0
|
|
29
|
+
*/
|
|
30
|
+
export interface EnvironmentVariable<S extends EnvironmentSchema = EnvironmentSchema> {
|
|
31
|
+
readonly public?: boolean;
|
|
32
|
+
readonly static?: boolean;
|
|
33
|
+
readonly description?: string;
|
|
34
|
+
readonly schema?: S;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Environment variable declarations keyed by variable name.
|
|
38
|
+
*
|
|
39
|
+
* @since 4.2.0
|
|
40
|
+
*/
|
|
41
|
+
export type EnvironmentDefinition = Record<string, EnvironmentVariable>;
|
|
42
|
+
/**
|
|
43
|
+
* The normalized declarations {@link DefineEnvVars} returns, with every Effect
|
|
44
|
+
* Schema converted to a Standard Schema of the same decoded output type.
|
|
45
|
+
*
|
|
46
|
+
* @since 4.2.0
|
|
47
|
+
*/
|
|
48
|
+
export type EnvironmentVariables<Definition extends EnvironmentDefinition> = {
|
|
49
|
+
readonly [Name in keyof Definition]: Omit<Definition[Name], "schema"> & NormalizedVariableSchema<Definition[Name]["schema"]>;
|
|
50
|
+
};
|
|
51
|
+
/** Keeps the schema member sound when a declaration's schema type includes undefined. */
|
|
52
|
+
type NormalizedVariableSchema<S> = [S] extends [EnvironmentSchema] ? {
|
|
53
|
+
readonly schema: StandardSchema<EnvironmentSchemaOutput<S>>;
|
|
54
|
+
} : [S] extends [undefined] ? {
|
|
55
|
+
readonly schema?: undefined;
|
|
56
|
+
} : {
|
|
57
|
+
readonly schema?: StandardSchema<EnvironmentSchemaOutput<Extract<S, EnvironmentSchema>>>;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Declares SvelteKit environment variables with Effect Schema validators.
|
|
61
|
+
*
|
|
62
|
+
* A thin wrapper over SvelteKit's `defineEnvVars` that converts Effect Schemas
|
|
63
|
+
* to the Standard Schema interface SvelteKit validates at startup. Standard
|
|
64
|
+
* Schema validators and schema-less declarations pass through unchanged, and
|
|
65
|
+
* SvelteKit remains responsible for loading, visibility, and validation.
|
|
66
|
+
* Schemas must decode synchronously from the raw string value.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* // src/env.ts
|
|
71
|
+
* import { DefineEnvVars } from "svelte-effect-runtime/environment";
|
|
72
|
+
* import { Schema } from "effect";
|
|
73
|
+
*
|
|
74
|
+
* export const variables = DefineEnvVars({
|
|
75
|
+
* PORT: { schema: Schema.NumberFromString, description: "Server port." },
|
|
76
|
+
* PUBLIC_ORIGIN: { public: true, schema: Schema.URLFromString },
|
|
77
|
+
* });
|
|
78
|
+
* ```
|
|
79
|
+
*
|
|
80
|
+
* @since 4.2.0
|
|
81
|
+
* @param definition - Environment variable declarations keyed by variable name,
|
|
82
|
+
* each carrying SvelteKit's metadata plus an Effect Schema or Standard Schema.
|
|
83
|
+
* @returns The same declarations with every Effect Schema converted to a
|
|
84
|
+
* Standard Schema, ready to export as `variables` from `src/env.ts`.
|
|
85
|
+
*/
|
|
86
|
+
export declare function DefineEnvVars<const Definition extends EnvironmentDefinition>(definition: Definition): EnvironmentVariables<Definition>;
|
|
87
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
//#region src/environment.ts
|
|
3
|
+
/**
|
|
4
|
+
* Declares SvelteKit environment variables with Effect Schema validators.
|
|
5
|
+
*
|
|
6
|
+
* A thin wrapper over SvelteKit's `defineEnvVars` that converts Effect Schemas
|
|
7
|
+
* to the Standard Schema interface SvelteKit validates at startup. Standard
|
|
8
|
+
* Schema validators and schema-less declarations pass through unchanged, and
|
|
9
|
+
* SvelteKit remains responsible for loading, visibility, and validation.
|
|
10
|
+
* Schemas must decode synchronously from the raw string value.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* // src/env.ts
|
|
15
|
+
* import { DefineEnvVars } from "svelte-effect-runtime/environment";
|
|
16
|
+
* import { Schema } from "effect";
|
|
17
|
+
*
|
|
18
|
+
* export const variables = DefineEnvVars({
|
|
19
|
+
* PORT: { schema: Schema.NumberFromString, description: "Server port." },
|
|
20
|
+
* PUBLIC_ORIGIN: { public: true, schema: Schema.URLFromString },
|
|
21
|
+
* });
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @since 4.2.0
|
|
25
|
+
* @param definition - Environment variable declarations keyed by variable name,
|
|
26
|
+
* each carrying SvelteKit's metadata plus an Effect Schema or Standard Schema.
|
|
27
|
+
* @returns The same declarations with every Effect Schema converted to a
|
|
28
|
+
* Standard Schema, ready to export as `variables` from `src/env.ts`.
|
|
29
|
+
*/
|
|
30
|
+
function DefineEnvVars(definition) {
|
|
31
|
+
const entries = Object.entries(definition).map(([name, variable]) => [name, normalize_variable(variable)]);
|
|
32
|
+
return Object.fromEntries(entries);
|
|
33
|
+
}
|
|
34
|
+
function normalize_variable(variable) {
|
|
35
|
+
if (variable.schema === void 0 || !Schema.isSchema(variable.schema)) return variable;
|
|
36
|
+
return {
|
|
37
|
+
...variable,
|
|
38
|
+
schema: Schema.toStandardSchemaV1(variable.schema)
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
export { DefineEnvVars };
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=environment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment.js","names":[],"sources":["../../modules/svelte-effect-runtime/src/environment.ts"],"sourcesContent":["import type { EnvVarConfig } from \"@sveltejs/kit\";\nimport { Schema } from \"effect\";\n\n/**\n * The Standard Schema validator shape SvelteKit accepts for an environment variable.\n *\n * @since 4.2.0\n */\nexport type StandardSchema<Output = unknown> = NonNullable<EnvVarConfig<Output>[\"schema\"]>;\n\n/**\n * A validator accepted by {@link DefineEnvVars}: an Effect Schema that decodes\n * synchronously from the raw string value, or an existing Standard Schema.\n *\n * @since 4.2.0\n */\nexport type EnvironmentSchema =\n\t| (Schema.ConstraintDecoder<unknown, never> & {\n\t\t\treadonly Encoded: string | undefined;\n\t })\n\t| StandardSchema<unknown>;\n\n/**\n * The decoded output type an environment schema produces.\n *\n * @since 4.2.0\n */\nexport type EnvironmentSchemaOutput<S extends EnvironmentSchema> = S extends Schema.Constraint\n\t? S[\"Type\"]\n\t: S extends StandardSchema<infer Output>\n\t\t? Output\n\t\t: never;\n\n/**\n * One environment variable declaration: SvelteKit's metadata plus an Effect\n * Schema or Standard Schema validator.\n *\n * @since 4.2.0\n */\nexport interface EnvironmentVariable<S extends EnvironmentSchema = EnvironmentSchema> {\n\treadonly public?: boolean;\n\treadonly static?: boolean;\n\treadonly description?: string;\n\treadonly schema?: S;\n}\n\n/**\n * Environment variable declarations keyed by variable name.\n *\n * @since 4.2.0\n */\nexport type EnvironmentDefinition = Record<string, EnvironmentVariable>;\n\n/**\n * The normalized declarations {@link DefineEnvVars} returns, with every Effect\n * Schema converted to a Standard Schema of the same decoded output type.\n *\n * @since 4.2.0\n */\nexport type EnvironmentVariables<Definition extends EnvironmentDefinition> = {\n\treadonly [Name in keyof Definition]: Omit<Definition[Name], \"schema\"> &\n\t\tNormalizedVariableSchema<Definition[Name][\"schema\"]>;\n};\n\n/** Keeps the schema member sound when a declaration's schema type includes undefined. */\ntype NormalizedVariableSchema<S> = [S] extends [EnvironmentSchema]\n\t? { readonly schema: StandardSchema<EnvironmentSchemaOutput<S>> }\n\t: [S] extends [undefined]\n\t\t? { readonly schema?: undefined }\n\t\t: {\n\t\t\t\treadonly schema?: StandardSchema<\n\t\t\t\t\tEnvironmentSchemaOutput<Extract<S, EnvironmentSchema>>\n\t\t\t\t>;\n\t\t\t};\n\n/**\n * Declares SvelteKit environment variables with Effect Schema validators.\n *\n * A thin wrapper over SvelteKit's `defineEnvVars` that converts Effect Schemas\n * to the Standard Schema interface SvelteKit validates at startup. Standard\n * Schema validators and schema-less declarations pass through unchanged, and\n * SvelteKit remains responsible for loading, visibility, and validation.\n * Schemas must decode synchronously from the raw string value.\n *\n * @example\n * ```ts\n * // src/env.ts\n * import { DefineEnvVars } from \"svelte-effect-runtime/environment\";\n * import { Schema } from \"effect\";\n *\n * export const variables = DefineEnvVars({\n * PORT: { schema: Schema.NumberFromString, description: \"Server port.\" },\n * PUBLIC_ORIGIN: { public: true, schema: Schema.URLFromString },\n * });\n * ```\n *\n * @since 4.2.0\n * @param definition - Environment variable declarations keyed by variable name,\n * each carrying SvelteKit's metadata plus an Effect Schema or Standard Schema.\n * @returns The same declarations with every Effect Schema converted to a\n * Standard Schema, ready to export as `variables` from `src/env.ts`.\n */\nexport function DefineEnvVars<const Definition extends EnvironmentDefinition>(\n\tdefinition: Definition,\n): EnvironmentVariables<Definition> {\n\tconst entries = Object.entries(definition).map(([name, variable]) => [\n\t\tname,\n\t\tnormalize_variable(variable),\n\t]);\n\n\treturn Object.fromEntries(entries) as EnvironmentVariables<Definition>;\n}\n\nfunction normalize_variable(variable: EnvironmentVariable): EnvironmentVariable {\n\tif (variable.schema === undefined || !Schema.isSchema(variable.schema)) {\n\t\treturn variable;\n\t}\n\n\treturn {\n\t\t...variable,\n\t\tschema: Schema.toStandardSchemaV1(\n\t\t\tvariable.schema as Schema.ConstraintDecoder<unknown, never>,\n\t\t) as StandardSchema,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsGA,SAAgB,cACf,YACmC;CACnC,MAAM,UAAU,OAAO,QAAQ,UAAU,CAAC,CAAC,KAAK,CAAC,MAAM,cAAc,CACpE,MACA,mBAAmB,QAAQ,CAC5B,CAAC;CAED,OAAO,OAAO,YAAY,OAAO;AAClC;AAEA,SAAS,mBAAmB,UAAoD;CAC/E,IAAI,SAAS,WAAW,KAAA,KAAa,CAAC,OAAO,SAAS,SAAS,MAAM,GACpE,OAAO;CAGR,OAAO;EACN,GAAG;EACH,QAAQ,OAAO,mBACd,SAAS,MACV;CACD;AACD"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { o as EmptyStreamYieldError, p as InvalidYieldableError } from "../chunks/errors-qhcbUH6o.js";
|
|
2
|
-
import { a as Code, t as ComponentScopeRef } from "../chunks/dispatcher-
|
|
2
|
+
import { a as Code, t as ComponentScopeRef } from "../chunks/dispatcher-B6ZRUsjN.js";
|
|
3
3
|
import { t as RemoteLiveYield } from "../chunks/live-CHK0RrZu.js";
|
|
4
|
-
import { n as get_dispatcher, t as Dispatcher } from "../chunks/dispatcher-
|
|
4
|
+
import { n as get_dispatcher, t as Dispatcher } from "../chunks/dispatcher-D8j5wTx6.js";
|
|
5
5
|
import { value } from "../markup/value.js";
|
|
6
6
|
import { promise } from "../markup/promise.js";
|
|
7
7
|
import { run } from "../markup/run.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as create_remote_command_adapter, i as create_remote_form_adapter, n as create_remote_query_adapter, r as create_remote_prerender_adapter, t as create_remote_live_query_adapter } from "../chunks/client-
|
|
1
|
+
import { a as create_remote_command_adapter, i as create_remote_form_adapter, n as create_remote_query_adapter, r as create_remote_prerender_adapter, t as create_remote_live_query_adapter } from "../chunks/client-CkxjaRTA.js";
|
|
2
2
|
export { create_remote_command_adapter, create_remote_form_adapter, create_remote_live_query_adapter, create_remote_prerender_adapter, create_remote_query_adapter };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { encode_remote_failure, normalize_remote_helper_error, run_remote_effect, throw_form_error, throw_remote_cause };
|
|
1
|
+
import { a as to_remote_failure_context, i as throw_remote_cause, n as run_remote_effect, o as encode_remote_failure, r as throw_form_error, t as normalize_remote_helper_error } from "../chunks/server-NeyeDSax.js";
|
|
2
|
+
export { encode_remote_failure, normalize_remote_helper_error, run_remote_effect, throw_form_error, throw_remote_cause, to_remote_failure_context };
|
package/.dist/markup/promise.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as get_dispatcher } from "../chunks/dispatcher-
|
|
1
|
+
import { n as get_dispatcher } from "../chunks/dispatcher-D8j5wTx6.js";
|
|
2
2
|
//#region src/markup/promise.ts
|
|
3
3
|
/** Runs a transform-generated promise block through the active dispatcher. */
|
|
4
4
|
function promise(id, deps, factory, ssr_fallback, options) {
|
package/.dist/markup/run.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as get_dispatcher } from "../chunks/dispatcher-
|
|
1
|
+
import { n as get_dispatcher } from "../chunks/dispatcher-D8j5wTx6.js";
|
|
2
2
|
import { Effect } from "effect";
|
|
3
3
|
//#region src/markup/run.ts
|
|
4
4
|
/** Runs a transform-generated event block through the active dispatcher. */
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as transform_markup_effect } from "../chunks/transform-
|
|
1
|
+
import { t as transform_markup_effect } from "../chunks/transform-C0jW8Qta.js";
|
|
2
2
|
export { transform_markup_effect };
|