svelte-effect-runtime 2.5.1 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/.dist/chunks/{client-Cj2X9lY-.js → client-Cruhk6Oo.js} +12 -5
  2. package/.dist/chunks/client-Cruhk6Oo.js.map +1 -0
  3. package/.dist/chunks/{dispatcher-BVkm8qbG.js → dispatcher-CgCdn6bj.js} +12 -2
  4. package/.dist/chunks/{dispatcher-BVkm8qbG.js.map → dispatcher-CgCdn6bj.js.map} +1 -1
  5. package/.dist/chunks/{preprocess-DseI9Doo.js → preprocess-BhoCga82.js} +49 -6
  6. package/.dist/chunks/preprocess-BhoCga82.js.map +1 -0
  7. package/.dist/chunks/{transform-Cx5bjmP6.js → transform-CMvL4SBp.js} +19 -9
  8. package/.dist/chunks/transform-CMvL4SBp.js.map +1 -0
  9. package/.dist/dispatcher.js +1 -1
  10. package/.dist/internal/generators.js +1 -1
  11. package/.dist/internal/remote-client.js +1 -1
  12. package/.dist/markup/promise.js +1 -1
  13. package/.dist/markup/run.js +1 -1
  14. package/.dist/markup/transform.js +1 -1
  15. package/.dist/markup/value.js +1 -1
  16. package/.dist/mod.d.ts +1 -40
  17. package/.dist/mod.js +2 -27
  18. package/.dist/mod.js.map +1 -1
  19. package/.dist/preprocess/imports.d.ts +10 -2
  20. package/.dist/preprocess/types.d.ts +8 -1
  21. package/.dist/preprocess.js +2 -2
  22. package/.dist/remote/client.js +1 -1
  23. package/.dist/remote/server.js +5 -1
  24. package/.dist/remote/server.js.map +1 -1
  25. package/.dist/runtime/transform.d.ts +2 -0
  26. package/.dist/{chunks/transform-BotzDlj3.js → runtime/transform.js} +4 -17
  27. package/.dist/runtime/transform.js.map +1 -0
  28. package/.dist/server/factories.d.ts +5 -1
  29. package/.dist/server/index.d.ts +1 -1
  30. package/.dist/server/types.d.ts +44 -1
  31. package/.dist/server.d.ts +1 -1
  32. package/.dist/server.js.map +1 -1
  33. package/.dist/vite.js +9 -13
  34. package/.dist/vite.js.map +1 -1
  35. package/package.json +4 -4
  36. package/.dist/chunks/client-Cj2X9lY-.js.map +0 -1
  37. package/.dist/chunks/preprocess-DseI9Doo.js.map +0 -1
  38. package/.dist/chunks/transform-BotzDlj3.js.map +0 -1
  39. package/.dist/chunks/transform-Cx5bjmP6.js.map +0 -1
  40. package/.dist/runtime/preprocess.d.ts +0 -39
  41. package/.dist/runtime/preprocess.js +0 -31
  42. package/.dist/runtime/preprocess.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform-CMvL4SBp.js","names":["is_yield_star_expression"],"sources":["../../../modules/svelte-effect-runtime/src/preprocess/imports.ts","../../../modules/svelte-effect-runtime/src/markup/transform/constants.ts","../../../modules/svelte-effect-runtime/src/markup/transform/apply.ts","../../../modules/svelte-effect-runtime/src/markup/transform/classify.ts","../../../modules/svelte-effect-runtime/src/markup/transform/effect-bindings.ts","../../../modules/svelte-effect-runtime/src/error.ts","../../../modules/svelte-effect-runtime/src/markup/transform/expressions.ts","../../../modules/svelte-effect-runtime/src/markup/transform/effect-callbacks.ts","../../../modules/svelte-effect-runtime/src/markup/transform/emit.ts","../../../modules/svelte-effect-runtime/src/preprocess/ast.ts","../../../modules/svelte-effect-runtime/src/markup/transform/scan.ts","../../../modules/svelte-effect-runtime/src/markup/transform/index.ts"],"sourcesContent":["import type { RuntimeImportBindings } from \"./types.ts\";\n\nimport ts from \"typescript\";\n\ninterface RuntimeImportOptions {\n needs_dispatcher?: boolean;\n needs_effect?: boolean;\n needs_untrack?: boolean;\n}\n\n/**\n * Builds the import statements injected by the script preprocessor.\n *\n * @since 2.0.0\n * @param has_effect_import - Whether the user already imports `Effect`.\n * @param has_dispatcher_import - Whether the user already imports\n * `get_dispatcher`.\n * @param has_untrack_import - Whether the user already imports `untrack`.\n * @param bindings - Local names reserved for generated runtime helpers.\n * @param options - Runtime helper imports required by this transformed script.\n * @returns Newline-separated import statements to inject.\n */\nexport function make_imports(\n has_effect_import: boolean,\n has_dispatcher_import: boolean,\n has_untrack_import: boolean,\n bindings: RuntimeImportBindings = {\n cancel: \"__SER___cancel\",\n dispatcher: \"get_dispatcher\",\n dispatcher_value: \"__SER___dispatcher\",\n effect: \"Effect\",\n program: \"__SER___program\",\n untrack: \"untrack\",\n },\n options: RuntimeImportOptions = {},\n): string {\n const needs_dispatcher = options.needs_dispatcher ?? true;\n const needs_effect = options.needs_effect ?? true;\n const needs_untrack = options.needs_untrack ?? true;\n\n const dispatcher_import = bindings.dispatcher === \"get_dispatcher\"\n ? `import { get_dispatcher } from \"svelte-effect-runtime/internal/generators\";`\n : `import { get_dispatcher as ${bindings.dispatcher} } from \"svelte-effect-runtime/internal/generators\";`;\n\n const untrack_import = bindings.untrack === \"untrack\"\n ? `import { untrack } from \"svelte\";`\n : `import { untrack as ${bindings.untrack} } from \"svelte\";`;\n\n const effect_import = has_effect_import\n ? false\n : bindings.effect === \"Effect\"\n ? `import { Effect } from \"effect\";`\n : `import { Effect as ${bindings.effect} } from \"effect\";`;\n\n return [\n needs_dispatcher && !has_dispatcher_import && dispatcher_import,\n needs_untrack && !has_untrack_import && untrack_import,\n needs_effect && effect_import,\n ]\n .filter(Boolean)\n .join(\"\\n\");\n}\n\n/**\n * Checks whether a source file imports a local binding from a module.\n *\n * @since 2.0.0\n * @param source_file - Parsed TypeScript source file to inspect.\n * @param module_name - Module specifier to match.\n * @param local_name - Local binding name to look for.\n * @returns Whether that binding is already locally available.\n */\nexport function has_local_import_binding(\n source_file: ts.SourceFile,\n module_name: string,\n local_name: string,\n): boolean {\n return source_file.statements.some((stmt) => {\n if (\n !ts.isImportDeclaration(stmt) ||\n !ts.isStringLiteral(stmt.moduleSpecifier) ||\n stmt.moduleSpecifier.text !== module_name\n ) {\n return false;\n }\n\n const clause = stmt.importClause;\n\n if (!clause || clause.isTypeOnly) {\n return false;\n }\n\n if (clause.name?.text === local_name) {\n return true;\n }\n\n const named_bindings = clause.namedBindings;\n\n if (!named_bindings) {\n return false;\n }\n\n if (ts.isNamespaceImport(named_bindings)) {\n return named_bindings.name.text === local_name;\n }\n\n return named_bindings.elements.some(\n (element) => !element.isTypeOnly && element.name.text === local_name,\n );\n });\n}\n\n/**\n * Checks whether a source file already has any top-level binding with a local\n * name.\n *\n * @since 2.4.2\n * @param source_file - Parsed TypeScript source file to inspect.\n * @param local_name - Local binding name to look for.\n * @returns Whether that local name is already declared in the file.\n */\nexport function has_top_level_binding(\n source_file: ts.SourceFile,\n local_name: string,\n): boolean {\n return collect_top_level_binding_names(source_file).includes(local_name);\n}\n\n/**\n * Collects every local binding declared at module top level.\n *\n * @since 2.4.2\n * @param source_file - Parsed TypeScript source file to inspect.\n * @returns Top-level names declared by imports, declarations, and variables.\n */\nexport function collect_top_level_binding_names(\n source_file: ts.SourceFile,\n): string[] {\n return source_file.statements.flatMap(collect_statement_binding_names);\n}\n\nfunction collect_statement_binding_names(stmt: ts.Statement): string[] {\n if (ts.isImportDeclaration(stmt)) {\n return collect_import_binding_names(stmt);\n }\n\n if (ts.isVariableStatement(stmt)) {\n return stmt.declarationList.declarations.flatMap((decl) =>\n collect_binding_name_text(decl.name)\n );\n }\n\n if (\n ts.isFunctionDeclaration(stmt) ||\n ts.isClassDeclaration(stmt) ||\n ts.isInterfaceDeclaration(stmt) ||\n ts.isTypeAliasDeclaration(stmt) ||\n ts.isEnumDeclaration(stmt) ||\n ts.isModuleDeclaration(stmt)\n ) {\n return stmt.name ? [stmt.name.text] : [];\n }\n\n return [];\n}\n\nfunction collect_import_binding_names(stmt: ts.ImportDeclaration): string[] {\n const clause = stmt.importClause;\n\n if (!clause) {\n return [];\n }\n\n return [\n clause.name?.text,\n clause.namedBindings && ts.isNamespaceImport(clause.namedBindings)\n ? clause.namedBindings.name.text\n : undefined,\n clause.namedBindings && ts.isNamedImports(clause.namedBindings)\n ? clause.namedBindings.elements.map((element) => element.name.text)\n : undefined,\n ].flat().filter((name): name is string => name !== undefined);\n}\n\nfunction collect_binding_name_text(name: ts.BindingName): string[] {\n if (ts.isIdentifier(name)) {\n return [name.text];\n }\n\n return name.elements.flatMap((element) => {\n if (ts.isOmittedExpression(element)) {\n return [];\n }\n\n return collect_binding_name_text(element.name);\n });\n}\n","export const HELPERS = {\n value: \"__SER___markup_value\",\n promise: \"__SER___markup_promise\",\n run: \"__SER___markup_run\",\n} as const;\n","import type MagicString from \"magic-string\";\n\nimport { collect_top_level_binding_names } from \"$/preprocess/imports.ts\";\nimport { HELPERS } from \"./constants.ts\";\nimport type {\n HelperDeclaration,\n Insertion,\n MarkupHelperBindings,\n MarkupRelocation,\n PendingRelocation,\n Replacement,\n} from \"./types.ts\";\nimport ts from \"typescript\";\n\nexport function create_source_map(\n magic: MagicString,\n filename: string,\n): Record<string, unknown> {\n const map = magic.generateMap({\n hires: true,\n includeContent: true,\n source: filename,\n });\n\n return map as unknown as Record<string, unknown>;\n}\n\nexport function blank_script_blocks(content: string): string {\n return content.replace(\n /<script\\b[^>]*>[\\s\\S]*?<\\/script\\s*>/gi,\n (match) => {\n const lines = match.split(\"\\n\");\n return lines.map((l) => \" \".repeat(l.length)).join(\"\\n\");\n },\n );\n}\n\nexport function inject_helpers(\n magic: MagicString,\n content: string,\n helpers: HelperDeclaration[] = [],\n bindings: MarkupHelperBindings = HELPERS,\n): Insertion | undefined {\n const import_helpers = unique_import_helpers(helpers);\n const local_helpers = helpers.filter((helper) => !is_import_helper(helper));\n\n const helper_segments: Array<{\n text: string;\n relocation?: PendingRelocation;\n }> = [\n make_import_helper(\n content,\n `import { value as ${bindings.value} } from \"svelte-effect-runtime/internal/generators\";`,\n ),\n make_import_helper(\n content,\n `import { promise as ${bindings.promise} } from \"svelte-effect-runtime/internal/generators\";`,\n ),\n make_import_helper(\n content,\n `import { run as ${bindings.run} } from \"svelte-effect-runtime/internal/generators\";`,\n ),\n ...import_helpers,\n ...local_helpers,\n ].filter((helper): helper is string | HelperDeclaration =>\n helper !== undefined\n ).map((helper) => typeof helper === \"string\" ? { text: helper } : helper);\n\n if (helper_segments.length === 0) {\n return undefined;\n }\n\n const helper_block = helper_segments.map((segment) => segment.text).join(\n \"\\n\",\n );\n\n const script_tag = find_instance_script_tag(content);\n\n if (script_tag) {\n const text = `\\n${helper_block}\\n`;\n\n magic.appendLeft(script_tag.end, text);\n\n return {\n start: script_tag.end,\n text,\n relocations: make_insertion_relocations(helper_segments, \"\\n\"),\n };\n } else {\n const text = `<script>\\n${helper_block}\\n</script>\\n\\n`;\n\n magic.prepend(text);\n\n return {\n start: 0,\n text,\n relocations: make_insertion_relocations(helper_segments, \"<script>\\n\"),\n };\n }\n}\n\nexport function make_markup_helper_bindings(\n content: string,\n): {\n bindings: MarkupHelperBindings;\n name_allocator: { reserve(name: string): string };\n} {\n const script_tag = find_instance_script_tag(content);\n const binding_names = script_tag\n ? collect_script_binding_names(\n content.slice(script_tag.start, script_tag.end),\n )\n : [];\n const name_allocator = make_name_allocator(binding_names);\n\n return {\n bindings: {\n value: name_allocator.reserve(HELPERS.value),\n promise: name_allocator.reserve(HELPERS.promise),\n run: name_allocator.reserve(HELPERS.run),\n },\n name_allocator,\n };\n}\n\nexport function create_relocations(\n replacements: Replacement[],\n helper_insertion: Insertion | undefined,\n): MarkupRelocation[] {\n const edits = [\n helper_insertion && {\n start: helper_insertion.start,\n removedLength: 0,\n insertedLength: helper_insertion.text.length,\n },\n ...replacements.map((replacement) => ({\n start: replacement.start,\n removedLength: replacement.end - replacement.start,\n insertedLength: replacement.text.length,\n })),\n ].filter(Boolean) as Array<{\n start: number;\n removedLength: number;\n insertedLength: number;\n }>;\n\n const replacement_relocations = replacements.flatMap((replacement) => {\n if (!replacement.relocation) {\n return [];\n }\n\n const delta_before = edits\n .filter((edit) => edit.start < replacement.start)\n .reduce(\n (total, edit) => total + edit.insertedLength - edit.removedLength,\n 0,\n );\n const generated_start = replacement.start + delta_before;\n\n return [{\n originalStart: replacement.relocation.originalStart,\n originalEnd: replacement.relocation.originalEnd,\n generatedStart: generated_start +\n replacement.relocation.generatedStartInReplacement,\n generatedEnd: generated_start +\n replacement.relocation.generatedEndInReplacement,\n }];\n });\n\n const helper_relocations = helper_insertion?.relocations?.map(\n (relocation) => ({\n originalStart: relocation.originalStart,\n originalEnd: relocation.originalEnd,\n generatedStart: helper_insertion.start +\n relocation.generatedStartInReplacement,\n generatedEnd: helper_insertion.start +\n relocation.generatedEndInReplacement,\n }),\n ) ?? [];\n\n return [\n ...replacement_relocations,\n ...helper_relocations,\n ];\n}\n\nfunction make_import_helper(\n content: string,\n import_text: string,\n): string | undefined {\n if (content.includes(import_text)) {\n return undefined;\n }\n\n return import_text;\n}\n\nfunction make_insertion_relocations(\n segments: Array<{\n text: string;\n relocation?: PendingRelocation;\n }>,\n prefix: string,\n): PendingRelocation[] {\n const relocations: PendingRelocation[] = [];\n let offset = prefix.length;\n\n for (const segment of segments) {\n if (segment.relocation) {\n relocations.push({\n originalStart: segment.relocation.originalStart,\n originalEnd: segment.relocation.originalEnd,\n generatedStartInReplacement: offset +\n segment.relocation.generatedStartInReplacement,\n generatedEndInReplacement: offset +\n segment.relocation.generatedEndInReplacement,\n });\n }\n\n offset += segment.text.length + 1;\n }\n\n return relocations;\n}\n\nfunction find_instance_script_tag(\n content: string,\n): { start: number; end: number } | undefined {\n const pattern = /<script\\b([^>]*)>([\\s\\S]*?)<\\/script\\s*>/gi;\n\n for (const match of content.matchAll(pattern)) {\n if (match.index === undefined) continue;\n\n const attrs = match[1] ?? \"\";\n if (\n /\\bcontext\\s*=\\s*[\"']module[\"']/.test(attrs) ||\n /\\bmodule\\b/.test(attrs)\n ) {\n continue;\n }\n\n const open_end = match[0].indexOf(\">\") + 1;\n return {\n start: match.index + open_end,\n end: match.index + match[0].length - \"</script>\".length,\n };\n }\n\n return undefined;\n}\n\nfunction unique_import_helpers(\n helpers: HelperDeclaration[],\n): HelperDeclaration[] {\n const seen = new Set<string>();\n\n return helpers.filter((helper) => {\n if (!is_import_helper(helper)) {\n return false;\n }\n\n if (seen.has(helper.text)) {\n return false;\n }\n\n seen.add(helper.text);\n\n return true;\n });\n}\n\nfunction is_import_helper(helper: HelperDeclaration): boolean {\n return helper.text.trimStart().startsWith(\"import \");\n}\n\nfunction collect_script_binding_names(script_content: string): string[] {\n const source_file = ts.createSourceFile(\n \"markup-script.ts\",\n script_content,\n ts.ScriptTarget.Latest,\n true,\n ts.ScriptKind.TS,\n );\n\n return collect_top_level_binding_names(source_file);\n}\n\nfunction make_name_allocator(initial_names: readonly string[]): {\n reserve(name: string): string;\n} {\n const used_names = new Set(initial_names);\n\n return {\n reserve(name: string): string {\n let candidate = name;\n let suffix = 1;\n\n while (used_names.has(candidate)) {\n candidate = `${name}_${suffix}`;\n suffix += 1;\n }\n\n used_names.add(candidate);\n\n return candidate;\n },\n };\n}\n","import type { AST } from \"svelte/compiler\";\n\nimport type { MarkupCandidate, TagKind } from \"./types.ts\";\n\n/**\n * Matches sanitized placeholders back to their Svelte AST context.\n *\n * @since 2.0.0\n * @param ast - Parsed Svelte AST for the sanitized component markup.\n * @param candidates - Placeholder candidates produced by the scanner.\n * @returns Candidates paired with the markup context that determines how they\n * should be emitted.\n */\nexport function classify_candidates(\n ast: AST.Root,\n candidates: MarkupCandidate[],\n): Array<{ candidate: MarkupCandidate; kind: TagKind }> {\n const by_placeholder = new Map(\n candidates.map((candidate) => [candidate.placeholder, candidate]),\n );\n\n const classified: Array<{ candidate: MarkupCandidate; kind: TagKind }> = [];\n const matched = new Set<string>();\n\n walk_ast(ast.fragment, by_placeholder, matched, classified);\n\n return classified;\n}\n\nfunction walk_ast(\n fragment: AST.Fragment,\n candidates: Map<string, MarkupCandidate>,\n matched: Set<string>,\n classified: Array<{ candidate: MarkupCandidate; kind: TagKind }>,\n): void {\n for (const node of fragment.nodes) {\n visit_ast_node(node, candidates, matched, classified);\n }\n}\n\nfunction visit_ast_node(\n node: AST.Fragment[\"nodes\"][number],\n candidates: Map<string, MarkupCandidate>,\n matched: Set<string>,\n classified: Array<{ candidate: MarkupCandidate; kind: TagKind }>,\n): void {\n switch (node.type) {\n case \"ExpressionTag\":\n classify_expression(\n node.expression,\n \"plain\",\n candidates,\n matched,\n classified,\n );\n return;\n\n case \"IfBlock\":\n classify_expression(node.test, \"plain\", candidates, matched, classified);\n walk_ast(node.consequent, candidates, matched, classified);\n if (node.alternate) {\n walk_ast(node.alternate, candidates, matched, classified);\n }\n return;\n\n case \"EachBlock\":\n classify_expression(\n node.expression,\n \"each\",\n candidates,\n matched,\n classified,\n );\n walk_ast(node.body, candidates, matched, classified);\n if (node.fallback) {\n walk_ast(node.fallback, candidates, matched, classified);\n }\n return;\n\n case \"AwaitBlock\":\n classify_expression(\n node.expression,\n \"await\",\n candidates,\n matched,\n classified,\n );\n if (node.pending) {\n walk_ast(node.pending, candidates, matched, classified);\n }\n if (node.then) walk_ast(node.then, candidates, matched, classified);\n if (node.catch) walk_ast(node.catch, candidates, matched, classified);\n return;\n\n case \"RenderTag\":\n classify_expression(\n node.expression,\n \"render\",\n candidates,\n matched,\n classified,\n );\n return;\n\n case \"HtmlTag\":\n classify_expression(\n node.expression,\n \"plain\",\n candidates,\n matched,\n classified,\n );\n return;\n\n case \"DebugTag\":\n classify_debug_tag(node, candidates, matched, classified);\n return;\n\n case \"ConstTag\":\n case \"DeclarationTag\":\n classify_declaration_tag(node, candidates, matched, classified);\n return;\n\n case \"KeyBlock\":\n classify_expression(\n node.expression,\n \"plain\",\n candidates,\n matched,\n classified,\n );\n walk_ast(node.fragment, candidates, matched, classified);\n return;\n\n case \"RegularElement\":\n case \"Component\":\n case \"TitleElement\":\n case \"SlotElement\":\n case \"SvelteBody\":\n case \"SvelteBoundary\":\n case \"SvelteComponent\":\n case \"SvelteDocument\":\n case \"SvelteElement\":\n case \"SvelteFragment\":\n case \"SvelteHead\":\n case \"SvelteSelf\":\n case \"SvelteWindow\":\n visit_element_attributes(node, candidates, matched, classified);\n walk_ast(node.fragment, candidates, matched, classified);\n return;\n\n default:\n return;\n }\n}\n\nfunction classify_debug_tag(\n _node: Extract<AST.Fragment[\"nodes\"][number], { type: \"DebugTag\" }>,\n _candidates: Map<string, MarkupCandidate>,\n _matched: Set<string>,\n _classified: Array<{ candidate: MarkupCandidate; kind: TagKind }>,\n): void {\n return;\n}\n\nfunction classify_declaration_tag(\n node: Extract<\n AST.Fragment[\"nodes\"][number],\n { type: \"ConstTag\" | \"DeclarationTag\" }\n >,\n candidates: Map<string, MarkupCandidate>,\n matched: Set<string>,\n classified: Array<{ candidate: MarkupCandidate; kind: TagKind }>,\n): void {\n for (const decl of node.declaration.declarations) {\n if (!decl.init) {\n continue;\n }\n\n classify_expression(decl.init, \"plain\", candidates, matched, classified);\n }\n}\n\ninterface ElementLikeNode {\n attributes: Array<{\n type: string;\n name?: string;\n value?: unknown;\n expression?: unknown;\n }>;\n fragment: AST.Fragment;\n}\n\nfunction visit_element_attributes(\n node: ElementLikeNode,\n candidates: Map<string, MarkupCandidate>,\n matched: Set<string>,\n classified: Array<{ candidate: MarkupCandidate; kind: TagKind }>,\n): void {\n for (const attr of node.attributes) {\n if (\n attr.type === \"Attribute\" &&\n attr.name &&\n is_event_attribute_name(attr.name)\n ) {\n visit_attribute_value(\n attr.value as\n | true\n | AST.ExpressionTag\n | Array<AST.Text | AST.ExpressionTag>,\n \"event\",\n candidates,\n matched,\n classified,\n );\n continue;\n }\n\n if (attr.type === \"OnDirective\" && attr.expression) {\n classify_expression(\n attr.expression as ExpressionLike,\n \"event\",\n candidates,\n matched,\n classified,\n );\n continue;\n }\n }\n}\n\nfunction is_event_attribute_name(name: string): boolean {\n return name.startsWith(\"on:\") || /^on[a-z]/.test(name);\n}\n\nfunction visit_attribute_value(\n value: true | AST.ExpressionTag | Array<AST.Text | AST.ExpressionTag>,\n kind: TagKind,\n candidates: Map<string, MarkupCandidate>,\n matched: Set<string>,\n classified: Array<{ candidate: MarkupCandidate; kind: TagKind }>,\n): void {\n if (value === true) {\n return;\n }\n\n if (Array.isArray(value)) {\n for (const part of value) {\n if (part.type === \"ExpressionTag\") {\n classify_expression(\n part.expression,\n kind,\n candidates,\n matched,\n classified,\n );\n }\n }\n return;\n }\n\n classify_expression(\n value.expression,\n kind,\n candidates,\n matched,\n classified,\n );\n}\n\ntype ExpressionLike = {\n type: string;\n name?: string;\n callee?: { type: string; name?: string };\n};\n\nfunction classify_expression(\n expression: ExpressionLike | null | undefined,\n kind: TagKind,\n candidates: Map<string, MarkupCandidate>,\n matched: Set<string>,\n classified: Array<{ candidate: MarkupCandidate; kind: TagKind }>,\n): void {\n if (!expression) {\n return;\n }\n\n const found_candidates = find_candidates(expression, candidates);\n\n for (const candidate of found_candidates) {\n if (matched.has(candidate.placeholder)) {\n continue;\n }\n\n matched.add(candidate.placeholder);\n classified.push({\n candidate,\n kind: resolve_candidate_kind(candidate, kind),\n });\n }\n}\n\nfunction resolve_candidate_kind(\n candidate: MarkupCandidate,\n context_kind: TagKind,\n): TagKind {\n if (candidate.key === \"render_argument\") {\n return \"render_argument\";\n }\n\n return context_kind;\n}\n\nfunction find_candidates(\n expression: ExpressionLike,\n candidates: Map<string, MarkupCandidate>,\n): MarkupCandidate[] {\n const found: MarkupCandidate[] = [];\n const seen_nodes = new Set<unknown>();\n const seen_placeholders = new Set<string>();\n\n visit_expression_value(\n expression,\n candidates,\n seen_nodes,\n seen_placeholders,\n found,\n );\n\n return found;\n}\n\nfunction visit_expression_value(\n value: unknown,\n candidates: Map<string, MarkupCandidate>,\n seen_nodes: Set<unknown>,\n seen_placeholders: Set<string>,\n found: MarkupCandidate[],\n): void {\n if (Array.isArray(value)) {\n for (const item of value) {\n visit_expression_value(\n item,\n candidates,\n seen_nodes,\n seen_placeholders,\n found,\n );\n }\n\n return;\n }\n\n if (!is_record(value) || seen_nodes.has(value)) {\n return;\n }\n\n seen_nodes.add(value);\n\n if (value.type === \"Identifier\" && typeof value.name === \"string\") {\n const candidate = candidates.get(value.name);\n\n if (candidate && !seen_placeholders.has(candidate.placeholder)) {\n seen_placeholders.add(candidate.placeholder);\n found.push(candidate);\n }\n }\n\n for (const child of Object.values(value)) {\n visit_expression_value(\n child,\n candidates,\n seen_nodes,\n seen_placeholders,\n found,\n );\n }\n}\n\nfunction is_record(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null;\n}\n","import type { HelperDeclaration } from \"./types.ts\";\n\nimport ts from \"typescript\";\n\nconst EFFECT_PACKAGE_MODULE = \"effect\";\nconst EFFECT_DIRECT_MODULE = \"effect/Effect\";\nconst GENERATED_EFFECT_NAME = \"__SER___Effect\";\n\n/**\n * Describes local bindings that resolve to Effect APIs in markup expressions.\n *\n * @example\n * ```ts\n * const context = collect_effect_callback_bindings(source);\n * context.effect_object_names.has(\"E\");\n * ```\n *\n * @since 2.4.0\n */\nexport interface EffectCallbackRewriteContext {\n /** Local names imported as the Effect object, such as `Effect` or `E`. */\n effect_object_names: ReadonlySet<string>;\n /** Namespace names imported from `effect/Effect`, such as `E.flatMap`. */\n effect_module_names: ReadonlySet<string>;\n /** Package namespace names imported from `effect`, such as `Fx.Effect`. */\n effect_package_names: ReadonlySet<string>;\n /** Direct `effect/Effect` imports mapped from local name to exported name. */\n direct_members: ReadonlyMap<string, string>;\n /** Expression used for generated `gen`, `sync`, and upgraded direct calls. */\n wrapper_expression: string;\n /** Import inserted when generated code needs a fresh Effect binding. */\n wrapper_import: HelperDeclaration | undefined;\n}\n\ninterface EffectBindingState {\n effect_object_names: string[];\n effect_module_names: string[];\n effect_package_names: string[];\n direct_members: Map<string, string>;\n local_names: Set<string>;\n implicit_effect_import: boolean;\n}\n\n/**\n * Collects Effect import bindings that markup callback rewriting can trust.\n *\n * @example\n * ```ts\n * const bindings = collect_effect_callback_bindings(\n * `<script>import { Effect as E } from \"effect\";</script>`,\n * );\n * ```\n *\n * @since 2.4.0\n * @param content - Full Svelte component source before markup lowering.\n * @returns Binding metadata used to identify Effect callback combinators.\n */\nexport function collect_effect_callback_bindings(\n content: string,\n): EffectCallbackRewriteContext {\n const state = make_effect_binding_state();\n const scripts = collect_script_blocks(content);\n\n for (const script of scripts) {\n const source_file = ts.createSourceFile(\n \"component-script.ts\",\n script,\n ts.ScriptTarget.Latest,\n true,\n ts.ScriptKind.TS,\n );\n\n collect_source_file_bindings(source_file, state);\n }\n\n ensure_implicit_effect_binding(state);\n\n const wrapper = choose_effect_wrapper(state);\n\n return {\n effect_object_names: new Set(state.effect_object_names),\n effect_module_names: new Set(state.effect_module_names),\n effect_package_names: new Set(state.effect_package_names),\n direct_members: new Map(state.direct_members),\n wrapper_expression: wrapper.expression,\n wrapper_import: wrapper.import_text\n ? { text: wrapper.import_text }\n : undefined,\n };\n}\n\nfunction make_effect_binding_state(): EffectBindingState {\n return {\n effect_object_names: [],\n effect_module_names: [],\n effect_package_names: [],\n direct_members: new Map(),\n local_names: new Set(),\n implicit_effect_import: false,\n };\n}\n\nfunction collect_script_blocks(content: string): string[] {\n const pattern = /<script\\b[^>]*>([\\s\\S]*?)<\\/script\\s*>/gi;\n\n return [...content.matchAll(pattern)].map((match) => match[1] ?? \"\");\n}\n\nfunction collect_source_file_bindings(\n source_file: ts.SourceFile,\n state: EffectBindingState,\n): void {\n for (const statement of source_file.statements) {\n collect_statement_binding(statement, state);\n }\n}\n\nfunction collect_statement_binding(\n statement: ts.Statement,\n state: EffectBindingState,\n): void {\n if (ts.isImportDeclaration(statement)) {\n collect_import_binding(statement, state);\n return;\n }\n\n if (ts.isImportEqualsDeclaration(statement)) {\n state.local_names.add(statement.name.text);\n return;\n }\n\n if (ts.isVariableStatement(statement)) {\n for (const declaration of statement.declarationList.declarations) {\n collect_binding_name(declaration.name, state.local_names);\n }\n\n return;\n }\n\n if (\n ts.isFunctionDeclaration(statement) ||\n ts.isClassDeclaration(statement) ||\n ts.isInterfaceDeclaration(statement) ||\n ts.isTypeAliasDeclaration(statement) ||\n ts.isEnumDeclaration(statement) ||\n ts.isModuleDeclaration(statement)\n ) {\n if (statement.name) {\n state.local_names.add(statement.name.text);\n }\n }\n}\n\nfunction collect_import_binding(\n statement: ts.ImportDeclaration,\n state: EffectBindingState,\n): void {\n if (!ts.isStringLiteral(statement.moduleSpecifier)) {\n return;\n }\n\n const module_name = statement.moduleSpecifier.text;\n const clause = statement.importClause;\n\n if (!clause) {\n return;\n }\n\n if (clause.name) {\n state.local_names.add(clause.name.text);\n }\n\n const named_bindings = clause.namedBindings;\n\n if (!named_bindings) {\n return;\n }\n\n if (ts.isNamespaceImport(named_bindings)) {\n collect_namespace_import_binding(\n module_name,\n named_bindings.name.text,\n state,\n );\n return;\n }\n\n for (const element of named_bindings.elements) {\n collect_named_import_binding(module_name, element, state);\n }\n}\n\nfunction collect_namespace_import_binding(\n module_name: string,\n local_name: string,\n state: EffectBindingState,\n): void {\n state.local_names.add(local_name);\n\n if (module_name === EFFECT_DIRECT_MODULE) {\n add_ordered_name(state.effect_module_names, local_name);\n return;\n }\n\n if (module_name === EFFECT_PACKAGE_MODULE) {\n add_ordered_name(state.effect_package_names, local_name);\n }\n}\n\nfunction collect_named_import_binding(\n module_name: string,\n element: ts.ImportSpecifier,\n state: EffectBindingState,\n): void {\n const imported_name = element.propertyName?.text ?? element.name.text;\n const local_name = element.name.text;\n\n state.local_names.add(local_name);\n\n if (module_name === EFFECT_PACKAGE_MODULE && imported_name === \"Effect\") {\n add_ordered_name(state.effect_object_names, local_name);\n return;\n }\n\n if (module_name === EFFECT_DIRECT_MODULE) {\n state.direct_members.set(local_name, imported_name);\n }\n}\n\nfunction collect_binding_name(\n name: ts.BindingName,\n local_names: Set<string>,\n): void {\n if (ts.isIdentifier(name)) {\n local_names.add(name.text);\n return;\n }\n\n for (const element of name.elements) {\n if (ts.isOmittedExpression(element)) {\n continue;\n }\n\n collect_binding_name(element.name, local_names);\n }\n}\n\nfunction ensure_implicit_effect_binding(state: EffectBindingState): void {\n if (has_effect_binding(state) || state.local_names.has(\"Effect\")) {\n return;\n }\n\n add_ordered_name(state.effect_object_names, \"Effect\");\n state.implicit_effect_import = true;\n}\n\nfunction has_effect_binding(state: EffectBindingState): boolean {\n return state.effect_object_names.length > 0 ||\n state.effect_module_names.length > 0 ||\n state.effect_package_names.length > 0 ||\n state.direct_members.size > 0;\n}\n\nfunction choose_effect_wrapper(\n state: EffectBindingState,\n): { expression: string; import_text?: string } {\n const effect_object = state.effect_object_names[0];\n\n if (effect_object) {\n return {\n expression: effect_object,\n import_text: state.implicit_effect_import\n ? `import { Effect } from \"effect\";`\n : undefined,\n };\n }\n\n const effect_module = state.effect_module_names[0];\n\n if (effect_module) {\n return { expression: effect_module };\n }\n\n const effect_package = state.effect_package_names[0];\n\n if (effect_package) {\n return { expression: `${effect_package}.Effect` };\n }\n\n const generated_name = make_generated_effect_name(state.local_names);\n\n return {\n expression: generated_name,\n import_text: `import { Effect as ${generated_name} } from \"effect\";`,\n };\n}\n\nfunction make_generated_effect_name(local_names: ReadonlySet<string>): string {\n if (!local_names.has(GENERATED_EFFECT_NAME)) {\n return GENERATED_EFFECT_NAME;\n }\n\n let index = 1;\n\n while (local_names.has(`${GENERATED_EFFECT_NAME}_${index}`)) {\n index += 1;\n }\n\n return `${GENERATED_EFFECT_NAME}_${index}`;\n}\n\nfunction add_ordered_name(names: string[], name: string): void {\n if (names.includes(name)) {\n return;\n }\n\n names.push(name);\n}\n","/**\n * Formats a runtime-owned error message with a stable screaming-case code.\n *\n * @example\n * ```ts\n * throw new Error(make_error_message(\"DISPATCHER_DISPOSED\", \"Dispatcher has been disposed\"));\n * ```\n *\n * @since 2.0.0\n * @param code - Stable screaming-case identifier for the error category.\n * @param message - Human-readable error message without the leading code.\n * @returns The complete error message prefixed with the stable code.\n */\nexport function make_error_message(code: string, message: string): string {\n return `[${code}]: ${message}`;\n}\n\n/**\n * Base error class for all preprocessor errors emitted during script and\n * markup transformation. Carries the source filename so error messages can\n * reference the affected file.\n *\n * @since 2.0.0\n */\nexport class PreprocessError extends Error {\n /**\n * The source filename that triggered this error.\n *\n * @since 2.0.0\n */\n readonly filename: string;\n\n constructor(message: string, filename: string) {\n super(message);\n this.name = \"PreprocessError\";\n this.filename = filename;\n }\n}\n\n/**\n * Thrown when a statement mixes JavaScript `await` with Effect `yield*` work\n * that must be lowered into an `Effect.gen` program.\n *\n * @since 2.0.0\n */\nexport class AwaitInEffectWorkError extends PreprocessError {\n /**\n * The full text of the problematic statement containing mixed async work.\n *\n * @since 2.0.0\n */\n readonly statement_text: string;\n\n constructor(filename: string, statement_text: string) {\n super(\n [\n make_error_message(\n \"AWAIT_IN_EFFECT_WORK\",\n `${filename}: await cannot be mixed with yield* in Effect work.`,\n ),\n `Top-level await is supported as ordinary Svelte async rendering, but statements lowered into Effect.gen must use yield* for async Effect work.`,\n \"\",\n `Problematic statement:`,\n statement_text,\n ].join(\"\\n\"),\n filename,\n );\n this.name = \"AwaitInEffectWorkError\";\n this.statement_text = statement_text;\n }\n}\n\n/**\n * Thrown when async Effect work appears inside a Svelte rune position that\n * must stay synchronous.\n *\n * @since 2.0.0\n */\nexport class AsyncEffectInSyncRuneError extends PreprocessError {\n /**\n * The name of the rune that contained async Effect work.\n *\n * @since 2.0.0\n */\n readonly rune_name: string;\n\n /**\n * The full text of the expression that triggered the error.\n *\n * @since 2.0.0\n */\n readonly expression_text: string;\n\n constructor(rune_name: string, expression_text: string, filename: string) {\n super(\n [\n make_error_message(\n \"ASYNC_EFFECT_IN_SYNC_RUNE\",\n `${filename}: yield* cannot be used inside ${rune_name}().`,\n ),\n `${rune_name}() must stay synchronous. Do not put async Effect work inside this rune.`,\n \"\",\n `Problematic expression:`,\n expression_text,\n ].join(\"\\n\"),\n filename,\n );\n this.name = \"AsyncEffectInSyncRuneError\";\n this.rune_name = rune_name;\n this.expression_text = expression_text;\n }\n}\n/**\n * Thrown when async Effect work appears inside a non-generator callback nested\n * in a markup event handler.\n *\n * @example\n * ```ts\n * throw new AsyncEffectInEventCallbackError(\n * \"Component.svelte\",\n * \"Effect.try(() => yield* save())\",\n * );\n * ```\n *\n * @since 2.0.0\n */\nexport class AsyncEffectInEventCallbackError extends PreprocessError {\n /**\n * The full text of the problematic event handler body.\n *\n * @since 2.0.0\n */\n readonly expression_text: string;\n\n constructor(filename: string, expression_text: string) {\n super(\n [\n make_error_message(\n \"ASYNC_EFFECT_IN_EVENT_CALLBACK\",\n `${filename}: yield* cannot be used inside a nested non-generator callback in a markup event handler.`,\n ),\n `Move the yield* to the event handler body. Effect.try and Effect.sync callbacks are plain synchronous JavaScript; do not call Effect-returning functions inside them.`,\n \"\",\n `Run the remote Effect directly:`,\n ` onclick={yield* UpvotePost(id)}`,\n \"\",\n `Recover from remote failures by composing the Effect value:`,\n ` onclick={yield* UpvotePost(id).pipe(Effect.catch(() => Effect.void))}`,\n \"\",\n `Problematic expression:`,\n expression_text,\n ].join(\"\\n\"),\n filename,\n );\n this.name = \"AsyncEffectInEventCallbackError\";\n this.expression_text = expression_text;\n }\n}\n\n/**\n * Thrown when an event handler callback contains the old raw `yield*`\n * shorthand. Effectful event handlers must put `yield*` directly in the event\n * attribute so the callback boundary is generated by the markup runtime.\n *\n * @example\n * ```ts\n * throw new YieldStarInEventCallbackError(\n * \"Component.svelte\",\n * \"() => yield* save()\",\n * );\n * ```\n *\n * @since 2.0.0\n * @param filename - Svelte component filename used to identify where the\n * invalid event handler callback was found.\n * @param expression_text - Original event handler callback text that contained\n * `yield*` and should be rewritten as a direct event Effect expression.\n */\nexport class YieldStarInEventCallbackError extends PreprocessError {\n /**\n * The full text of the problematic event handler callback.\n *\n * @since 2.0.0\n */\n readonly expression_text: string;\n\n constructor(filename: string, expression_text: string) {\n super(\n [\n make_error_message(\n \"ASYNC_EFFECT_IN_EVENT_HANDLER_CALLBACK\",\n `${filename}: yield* in markup event handlers must be written directly as the event attribute value.`,\n ),\n `SER generates the event callback for effectful event handlers; do not put yield* inside a JavaScript callback.`,\n \"\",\n `Use this form:`,\n ` onclick={yield* UpvotePost(id)}`,\n \"\",\n `Instead of this form:`,\n ` onclick={() => yield* UpvotePost(id)}`,\n \"\",\n `Problematic expression:`,\n expression_text,\n ].join(\"\\n\"),\n filename,\n );\n this.name = \"YieldStarInEventCallbackError\";\n this.expression_text = expression_text;\n }\n}\n\n/**\n * Thrown when async Effect work appears in a markup position SER cannot lower\n * safely.\n *\n * @example\n * ```ts\n * throw new UnsupportedMarkupEffectPositionError(\n * \"Component.svelte\",\n * \"value={yield* load()}\",\n * );\n * ```\n *\n * @since 2.4.2\n */\nexport class UnsupportedMarkupEffectPositionError extends PreprocessError {\n /**\n * The unsupported markup expression text.\n *\n * @since 2.4.2\n */\n readonly expression_text: string;\n\n constructor(filename: string, expression_text: string) {\n super(\n [\n make_error_message(\n \"UNSUPPORTED_MARKUP_EFFECT_POSITION\",\n `${filename}: yield* cannot be used in this markup position.`,\n ),\n `Move the Effect work into a supported expression tag, block expression, render expression, declaration tag, or event handler.`,\n \"\",\n `Problematic expression:`,\n expression_text,\n ].join(\"\\n\"),\n filename,\n );\n this.name = \"UnsupportedMarkupEffectPositionError\";\n this.expression_text = expression_text;\n }\n}\n","import ts from \"typescript\";\n\n/**\n * Strips an event handler arrow function down to its executable body.\n *\n * @since 2.0.0\n * @param expr - Event handler expression text from the original markup.\n * @returns Handler parameters, body text, and body offsets inside `expr`.\n */\nexport function strip_arrow_function(\n expr: string,\n): { params: string; body: string; body_start: number; body_end: number } {\n const arrow_idx = expr.indexOf(\"=>\");\n\n if (arrow_idx === -1) {\n return { params: \"()\", body: expr, body_start: 0, body_end: expr.length };\n }\n\n const params = expr.slice(0, arrow_idx).trim();\n const raw_body = expr.slice(arrow_idx + 2);\n const leading_ws = raw_body.length - raw_body.trimStart().length;\n let body_start = arrow_idx + 2 + leading_ws;\n let body_end = expr.length - (raw_body.length - raw_body.trimEnd().length);\n let body = expr.slice(body_start, body_end);\n\n if (body.startsWith(\"{\") && body.endsWith(\"}\")) {\n body_start += 1;\n body_end -= 1;\n body = body.slice(1, -1);\n }\n\n const body_leading_ws = body.length - body.trimStart().length;\n const body_trailing_ws = body.length - body.trimEnd().length;\n\n body_start += body_leading_ws;\n body_end -= body_trailing_ws;\n body = body.trim();\n\n if (body.endsWith(\";\")) {\n body = body.slice(0, -1);\n body_end -= 1;\n }\n\n return { params, body, body_start, body_end };\n}\n\n/**\n * Returns whether an expression is a callback function.\n *\n * @since 2.0.0\n * @param expr - Expression text from a markup attribute or expression tag.\n * @returns Whether the expression parses as an arrow or function expression.\n */\nexport function is_callback_function_expression(expr: string): boolean {\n const wrapped = `const __SER___callback = ${expr};`;\n const sf = ts.createSourceFile(\n \"callback.ts\",\n wrapped,\n ts.ScriptTarget.Latest,\n true,\n ts.ScriptKind.TS,\n );\n const stmt = sf.statements[0];\n\n if (!ts.isVariableStatement(stmt)) {\n return false;\n }\n\n const initializer = stmt.declarationList.declarations[0]?.initializer;\n\n return initializer !== undefined &&\n (ts.isArrowFunction(initializer) ||\n ts.isFunctionExpression(initializer));\n}\n\n/**\n * Classifies `yield*` placement inside an event handler body.\n *\n * @example\n * ```ts\n * analyze_event_body_yield_star(\"yield* save()\");\n * ```\n *\n * @since 2.0.0\n * @param body - Event handler body text after the outer arrow has been\n * stripped.\n * @returns Whether the body has top-level yield* expressions and whether any\n * yield* appears inside a nested non-generator callback.\n */\nexport function analyze_event_body_yield_star(body: string): {\n has_top_level_yield_star: boolean;\n has_nested_invalid_yield_star: boolean;\n} {\n const wrapped = `function* __SER___event() { ${body}; }`;\n const sf = ts.createSourceFile(\n \"event.ts\",\n wrapped,\n ts.ScriptTarget.Latest,\n true,\n ts.ScriptKind.TS,\n );\n const stmt = sf.statements[0];\n\n if (!ts.isFunctionDeclaration(stmt) || !stmt.body) {\n return {\n has_top_level_yield_star: false,\n has_nested_invalid_yield_star: /\\byield\\s*\\*/.test(body),\n };\n }\n\n const result = {\n has_top_level_yield_star: false,\n has_nested_invalid_yield_star: false,\n };\n\n visit_event_body(stmt.body, \"top_level\", result);\n\n return result;\n}\n\n/**\n * Collects free identifiers that must be captured as reactive dependencies.\n *\n * @since 2.0.0\n * @param expr_text - Markup expression text to inspect.\n * @returns Identifier names referenced by the expression.\n */\nexport function collect_free_identifiers(expr_text: string): string[] {\n const wrapped = `function* __SER___w() { return (${expr_text}); }`;\n let sf: ts.SourceFile;\n\n try {\n sf = ts.createSourceFile(\n \"expr.ts\",\n wrapped,\n ts.ScriptTarget.Latest,\n true,\n ts.ScriptKind.TS,\n );\n } catch {\n return [];\n }\n\n const fn = sf.statements[0];\n\n if (!ts.isFunctionDeclaration(fn) || !fn.body) {\n return [];\n }\n\n const ids: string[] = [];\n const locals = new Set<string>();\n const seen = new Set<string>();\n\n visit_ids(fn.body, locals, seen, ids);\n\n return ids;\n}\n\nfunction visit_ids(\n node: ts.Node,\n locals: Set<string>,\n seen: Set<string>,\n ids: string[],\n): void {\n if (\n ts.isArrowFunction(node) ||\n ts.isFunctionExpression(node) ||\n ts.isFunctionDeclaration(node)\n ) {\n const scoped = new Set(locals);\n\n if (ts.isFunctionDeclaration(node) && node.name) {\n scoped.add(node.name.text);\n }\n\n for (const parameter of node.parameters) {\n add_binding_names(parameter.name, scoped);\n }\n\n if (node.body) {\n visit_ids(node.body, scoped, seen, ids);\n }\n\n return;\n }\n\n if (ts.isVariableDeclaration(node)) {\n if (node.initializer) {\n visit_ids(node.initializer, locals, seen, ids);\n }\n\n add_binding_names(node.name, locals);\n\n return;\n }\n\n if (ts.isTypeReferenceNode(node)) {\n return;\n }\n\n if (ts.isIdentifier(node)) {\n if (\n node.text === \"yield\" ||\n node.text === \"undefined\" ||\n node.text === \"null\" ||\n node.text === \"true\" ||\n node.text === \"false\" ||\n node.text === \"this\"\n ) {\n return;\n }\n\n if (is_property_access_name(node)) {\n return;\n }\n\n if (!locals.has(node.text) && !seen.has(node.text)) {\n seen.add(node.text);\n ids.push(node.text);\n }\n return;\n }\n\n node.forEachChild((child) => visit_ids(child, locals, seen, ids));\n}\n\nfunction add_binding_names(name: ts.BindingName, locals: Set<string>): void {\n if (ts.isIdentifier(name)) {\n locals.add(name.text);\n return;\n }\n\n for (const element of name.elements) {\n if (ts.isOmittedExpression(element)) {\n continue;\n }\n\n add_binding_names(element.name, locals);\n }\n}\n\ntype EventYieldContext = \"top_level\" | \"nested_generator\" | \"nested_invalid\";\n\ninterface EventYieldAnalysis {\n has_top_level_yield_star: boolean;\n has_nested_invalid_yield_star: boolean;\n}\n\nfunction visit_event_body(\n node: ts.Node,\n context: EventYieldContext,\n result: EventYieldAnalysis,\n): void {\n if (is_yield_star_expression(node)) {\n if (context === \"top_level\") {\n result.has_top_level_yield_star = true;\n } else if (context === \"nested_invalid\") {\n result.has_nested_invalid_yield_star = true;\n }\n\n node.forEachChild((child) => visit_event_body(child, context, result));\n return;\n }\n\n if (is_nested_function_boundary(node)) {\n const next_context = is_generator_function_boundary(node)\n ? \"nested_generator\"\n : \"nested_invalid\";\n\n node.forEachChild((child) => visit_event_body(child, next_context, result));\n return;\n }\n\n node.forEachChild((child) => visit_event_body(child, context, result));\n}\n\nfunction is_nested_function_boundary(node: ts.Node): boolean {\n return (\n ts.isArrowFunction(node) ||\n ts.isFunctionExpression(node) ||\n ts.isFunctionDeclaration(node) ||\n ts.isMethodDeclaration(node) ||\n ts.isGetAccessorDeclaration(node) ||\n ts.isSetAccessorDeclaration(node)\n );\n}\n\nfunction is_generator_function_boundary(node: ts.Node): boolean {\n return (\n (ts.isFunctionExpression(node) || ts.isFunctionDeclaration(node) ||\n ts.isMethodDeclaration(node)) &&\n node.asteriskToken !== undefined\n );\n}\n\nfunction is_yield_star_expression(node: ts.Node): boolean {\n if (ts.isYieldExpression(node)) {\n return node.asteriskToken !== undefined;\n }\n\n return (\n ts.isBinaryExpression(node) &&\n node.operatorToken.kind === ts.SyntaxKind.AsteriskToken &&\n ts.isIdentifier(node.left) &&\n node.left.text === \"yield\"\n );\n}\n\nfunction is_property_access_name(node: ts.Identifier): boolean {\n const parent = node.parent;\n\n return (\n (ts.isPropertyAccessExpression(parent) && parent.name === node) ||\n (ts.isPropertyAssignment(parent) && parent.name === node) ||\n (ts.isBindingElement(parent) && parent.propertyName === node) ||\n ts.isImportSpecifier(parent) ||\n ts.isExportSpecifier(parent)\n );\n}\n","import { contains_top_level_yield_star } from \"$/detect.ts\";\nimport type { EffectCallbackRewriteContext } from \"./effect-bindings.ts\";\nimport type { HelperDeclaration } from \"./types.ts\";\n\nimport MagicString from \"magic-string\";\nimport ts from \"typescript\";\n\nconst MATCH_EFFECT_MEMBERS = new Map([\n [\"match\", \"matchEffect\"],\n [\"matchCause\", \"matchCauseEffect\"],\n]);\n\nconst EFFECTFUL_CALLBACK_MEMBERS = new Set([\n \"andThen\",\n \"catchAll\",\n \"catchAllCause\",\n \"catchCause\",\n \"catchTag\",\n \"flatMap\",\n \"forEach\",\n \"tap\",\n \"tapError\",\n \"tapErrorCause\",\n]);\n\nconst EFFECTFUL_HANDLER_MEMBERS = new Set([\n \"matchCauseEffect\",\n \"matchEffect\",\n \"tapBoth\",\n]);\n\ninterface RewriteContext {\n source_file: ts.SourceFile;\n source_text: string;\n magic: MagicString;\n offset: number;\n bindings: EffectCallbackRewriteContext;\n changed: boolean;\n uses_wrapper: boolean;\n}\n\ninterface EffectMember {\n name: string;\n name_start: number;\n name_end: number;\n direct: boolean;\n}\n\ntype EffectWrapperMember = \"gen\" | \"sync\";\n\n/**\n * Rewrites effectful callback shorthand inside event handler expressions.\n *\n * @example\n * ```ts\n * normalize_effect_callback_yields(\n * `yield* action.pipe(Effect.flatMap((value) => yield* next(value)))`,\n * collect_effect_callback_bindings(source),\n * );\n * ```\n *\n * @since 2.0.0\n * @param expr_text - Markup expression text before it is wrapped in the\n * generated Effect runner.\n * @param bindings - Local Effect import bindings collected from the Svelte\n * component's script blocks.\n * @returns The expression with nested Effect callback `yield*` shorthand\n * lowered into explicit Effect callbacks, plus any import needed by generated\n * wrapper calls.\n */\nexport function normalize_effect_callback_yields(\n expr_text: string,\n bindings: EffectCallbackRewriteContext,\n): { expr_text: string; helpers: HelperDeclaration[] } {\n const prefix = \"const __SER___expression = \";\n const source_text = `${prefix}${expr_text};`;\n const source_file = ts.createSourceFile(\n \"event-expression.ts\",\n source_text,\n ts.ScriptTarget.Latest,\n true,\n ts.ScriptKind.TS,\n );\n const statement = source_file.statements[0];\n const magic = new MagicString(expr_text);\n const context: RewriteContext = {\n source_file,\n source_text,\n magic,\n offset: prefix.length,\n bindings,\n changed: false,\n uses_wrapper: false,\n };\n\n if (!ts.isVariableStatement(statement)) {\n return { expr_text, helpers: [] };\n }\n\n const expression = statement.declarationList.declarations[0]?.initializer;\n\n if (!expression) {\n return { expr_text, helpers: [] };\n }\n\n visit_expression(expression, context);\n\n if (!context.changed) {\n return { expr_text, helpers: [] };\n }\n\n const helpers = context.uses_wrapper && bindings.wrapper_import\n ? [bindings.wrapper_import]\n : [];\n\n return {\n expr_text: magic.toString(),\n helpers,\n };\n}\n\nfunction visit_expression(node: ts.Node, context: RewriteContext): void {\n if (is_non_generator_callback_with_top_level_yield(node)) {\n return;\n }\n\n if (ts.isCallExpression(node)) {\n rewrite_match_call(node, context);\n rewrite_effectful_handler_call(node, context);\n rewrite_effectful_callback_arguments(node, context);\n }\n\n node.forEachChild((child) => {\n visit_expression(child, context);\n });\n}\n\nfunction rewrite_match_call(\n call: ts.CallExpression,\n context: RewriteContext,\n): void {\n const member = get_effect_member(call.expression, context);\n const upgraded_name = member && MATCH_EFFECT_MEMBERS.get(member.name);\n const options = get_last_object_argument(call);\n\n if (!member || !upgraded_name || !options) {\n return;\n }\n\n const handlers = get_handler_properties(options);\n const should_upgrade = handlers.some((handler) =>\n handler.callback &&\n is_non_generator_callback_with_top_level_yield(handler.callback)\n );\n\n if (!should_upgrade) {\n return;\n }\n\n rewrite_effect_member_name(member, upgraded_name, context);\n context.changed = true;\n\n for (const handler of handlers) {\n if (!handler.callback) {\n continue;\n }\n\n if (is_non_generator_callback_with_top_level_yield(handler.callback)) {\n rewrite_callback_to_effect_gen(handler.callback, context);\n } else {\n rewrite_callback_to_effect_sync(handler.callback, context);\n }\n }\n}\n\nfunction rewrite_effectful_handler_call(\n call: ts.CallExpression,\n context: RewriteContext,\n): void {\n const member = get_effect_member(call.expression, context);\n const options = get_last_object_argument(call);\n\n if (!member || !EFFECTFUL_HANDLER_MEMBERS.has(member.name) || !options) {\n return;\n }\n\n for (const handler of get_handler_properties(options)) {\n if (\n handler.callback &&\n is_non_generator_callback_with_top_level_yield(handler.callback)\n ) {\n rewrite_callback_to_effect_gen(handler.callback, context);\n }\n }\n}\n\nfunction rewrite_effectful_callback_arguments(\n call: ts.CallExpression,\n context: RewriteContext,\n): void {\n const member = get_effect_member(call.expression, context);\n\n if (!member || !EFFECTFUL_CALLBACK_MEMBERS.has(member.name)) {\n return;\n }\n\n for (const argument of call.arguments) {\n if (\n is_callback_expression(argument) &&\n is_non_generator_callback_with_top_level_yield(argument)\n ) {\n rewrite_callback_to_effect_gen(argument, context);\n }\n }\n}\n\nfunction rewrite_callback_to_effect_gen(\n callback: ts.ArrowFunction | ts.FunctionExpression,\n context: RewriteContext,\n): void {\n if (is_async_function(callback)) {\n return;\n }\n\n if (ts.isArrowFunction(callback)) {\n rewrite_arrow_callback(callback, \"gen\", context);\n return;\n }\n\n rewrite_function_body(callback, \"gen\", context);\n}\n\nfunction rewrite_callback_to_effect_sync(\n callback: ts.ArrowFunction | ts.FunctionExpression,\n context: RewriteContext,\n): void {\n if (is_async_function(callback)) {\n return;\n }\n\n if (ts.isArrowFunction(callback)) {\n rewrite_arrow_callback(callback, \"sync\", context);\n return;\n }\n\n rewrite_function_body(callback, \"sync\", context);\n}\n\nfunction rewrite_arrow_callback(\n callback: ts.ArrowFunction,\n wrapper: EffectWrapperMember,\n context: RewriteContext,\n): void {\n const start = to_expr_pos(callback.getStart(context.source_file), context);\n const end = to_expr_pos(callback.end, context);\n const params_text = context.source_text\n .slice(\n callback.getStart(context.source_file),\n callback.equalsGreaterThanToken.getStart(context.source_file),\n )\n .trim();\n const body_text = get_body_text(callback.body, context);\n const rewritten_body = make_effect_body(\n callback.body,\n body_text,\n wrapper,\n context,\n );\n const replacement = `${params_text} => ${rewritten_body}`;\n\n context.magic.overwrite(start, end, replacement);\n context.changed = true;\n}\n\nfunction rewrite_function_body(\n callback: ts.FunctionExpression,\n wrapper: EffectWrapperMember,\n context: RewriteContext,\n): void {\n const body_start = to_expr_pos(\n callback.body.getStart(context.source_file),\n context,\n );\n const body_end = to_expr_pos(callback.body.end, context);\n const body_text = get_body_text(callback.body, context);\n const rewritten_body = make_effect_body(\n callback.body,\n body_text,\n wrapper,\n context,\n );\n\n context.magic.overwrite(\n body_start,\n body_end,\n `{ return ${rewritten_body}; }`,\n );\n context.changed = true;\n}\n\nfunction make_effect_body(\n body: ts.ConciseBody,\n body_text: string,\n wrapper: EffectWrapperMember,\n context: RewriteContext,\n): string {\n const wrapper_access = make_effect_access(wrapper, context);\n\n if (wrapper === \"gen\") {\n if (ts.isBlock(body)) {\n return `${wrapper_access}(function* () ${body_text})`;\n }\n\n return `${wrapper_access}(function* () { return (${body_text}); })`;\n }\n\n if (ts.isBlock(body)) {\n return `${wrapper_access}(() => ${body_text})`;\n }\n\n return `${wrapper_access}(() => (${body_text}))`;\n}\n\nfunction get_body_text(body: ts.ConciseBody, context: RewriteContext): string {\n return context.source_text\n .slice(body.getStart(context.source_file), body.end)\n .trim();\n}\n\nfunction get_handler_properties(\n object_literal: ts.ObjectLiteralExpression,\n): Array<{\n callback: ts.ArrowFunction | ts.FunctionExpression | undefined;\n}> {\n return object_literal.properties.flatMap((property) => {\n if (!ts.isPropertyAssignment(property)) {\n return [];\n }\n\n const name = get_property_name(property.name);\n\n if (name !== \"onFailure\" && name !== \"onSuccess\") {\n return [];\n }\n\n const callback = is_callback_expression(property.initializer)\n ? property.initializer\n : undefined;\n\n return [{ callback }];\n });\n}\n\nfunction get_last_object_argument(\n call: ts.CallExpression,\n): ts.ObjectLiteralExpression | undefined {\n const last_argument = call.arguments[call.arguments.length - 1];\n\n if (!last_argument || !ts.isObjectLiteralExpression(last_argument)) {\n return undefined;\n }\n\n return last_argument;\n}\n\nfunction get_effect_member(\n expression: ts.Expression,\n context: RewriteContext,\n): EffectMember | undefined {\n if (ts.isIdentifier(expression)) {\n const direct_member = context.bindings.direct_members.get(expression.text);\n\n if (!direct_member) {\n return undefined;\n }\n\n return {\n name: direct_member,\n name_start: to_expr_pos(\n expression.getStart(context.source_file),\n context,\n ),\n name_end: to_expr_pos(expression.end, context),\n direct: true,\n };\n }\n\n if (!ts.isPropertyAccessExpression(expression)) {\n return undefined;\n }\n\n if (!is_effect_namespace_expression(expression.expression, context)) {\n return undefined;\n }\n\n return {\n name: expression.name.text,\n name_start: to_expr_pos(\n expression.name.getStart(context.source_file),\n context,\n ),\n name_end: to_expr_pos(expression.name.end, context),\n direct: false,\n };\n}\n\nfunction rewrite_effect_member_name(\n member: EffectMember,\n upgraded_name: string,\n context: RewriteContext,\n): void {\n if (member.direct) {\n context.magic.overwrite(\n member.name_start,\n member.name_end,\n make_effect_access(upgraded_name, context),\n );\n\n return;\n }\n\n context.magic.overwrite(member.name_start, member.name_end, upgraded_name);\n}\n\nfunction make_effect_access(\n member_name: string,\n context: RewriteContext,\n): string {\n context.uses_wrapper = true;\n\n return `${context.bindings.wrapper_expression}.${member_name}`;\n}\n\nfunction is_effect_namespace_expression(\n expression: ts.Expression,\n context: RewriteContext,\n): boolean {\n if (ts.isIdentifier(expression)) {\n return context.bindings.effect_object_names.has(expression.text) ||\n context.bindings.effect_module_names.has(expression.text);\n }\n\n if (!ts.isPropertyAccessExpression(expression)) {\n return false;\n }\n\n if (expression.name.text !== \"Effect\") {\n return false;\n }\n\n if (!ts.isIdentifier(expression.expression)) {\n return false;\n }\n\n return context.bindings.effect_package_names.has(expression.expression.text);\n}\n\nfunction get_property_name(name: ts.PropertyName): string | undefined {\n if (ts.isIdentifier(name) || ts.isStringLiteral(name)) {\n return name.text;\n }\n\n return undefined;\n}\n\nfunction is_callback_expression(\n node: ts.Node,\n): node is ts.ArrowFunction | ts.FunctionExpression {\n return ts.isArrowFunction(node) || ts.isFunctionExpression(node);\n}\n\nfunction is_non_generator_callback_with_top_level_yield(\n node: ts.Node,\n): node is ts.ArrowFunction | ts.FunctionExpression {\n if (!is_callback_expression(node)) {\n return false;\n }\n\n if (ts.isFunctionExpression(node) && node.asteriskToken) {\n return false;\n }\n\n return contains_top_level_yield_star(node.body);\n}\n\nfunction is_async_function(\n node: ts.ArrowFunction | ts.FunctionExpression,\n): boolean {\n return node.modifiers?.some(\n (modifier) => modifier.kind === ts.SyntaxKind.AsyncKeyword,\n ) ?? false;\n}\n\nfunction to_expr_pos(pos: number, context: RewriteContext): number {\n return pos - context.offset;\n}\n","import {\n AsyncEffectInEventCallbackError,\n YieldStarInEventCallbackError,\n} from \"$/error.ts\";\nimport type { EffectCallbackRewriteContext } from \"./effect-bindings.ts\";\nimport {\n analyze_event_body_yield_star,\n collect_free_identifiers,\n is_callback_function_expression,\n} from \"./expressions.ts\";\nimport { normalize_effect_callback_yields } from \"./effect-callbacks.ts\";\nimport type {\n HelperDeclaration,\n MarkupCandidate,\n MarkupHelperBindings,\n MarkupNameAllocator,\n PendingRelocation,\n Replacement,\n TagKind,\n} from \"./types.ts\";\n\n/**\n * Emits source edits for classified markup Effect expressions.\n *\n * @since 2.0.0\n * @param classified - Candidates paired with their Svelte markup context.\n * @param effect_context - Effect import bindings available to markup\n * expression rewrites.\n * @returns Replacements ready to apply to the original component source.\n */\nexport function emit_replacements(\n classified: Array<{ candidate: MarkupCandidate; kind: TagKind }>,\n effect_context: EffectCallbackRewriteContext,\n helper_bindings: MarkupHelperBindings,\n name_allocator: MarkupNameAllocator,\n): Replacement[] {\n return classified.map(({ candidate, kind }) =>\n emit_replacement(\n candidate,\n kind,\n effect_context,\n helper_bindings,\n name_allocator,\n )\n );\n}\n\nfunction emit_replacement(\n candidate: MarkupCandidate,\n kind: TagKind,\n effect_context: EffectCallbackRewriteContext,\n helper_bindings: MarkupHelperBindings,\n name_allocator: MarkupNameAllocator,\n): Replacement {\n const normalized = normalize_effect_callback_yields(\n candidate.expr_text,\n effect_context,\n );\n const normalized_candidate = {\n ...candidate,\n expr_text: normalized.expr_text,\n };\n const id = make_cache_id(candidate);\n const id_text = JSON.stringify(id);\n const helper_name = make_helper_name(candidate, name_allocator);\n\n let replacement_text: string;\n let helpers: HelperDeclaration[];\n let relocation: PendingRelocation | undefined;\n\n if (kind === \"await\") {\n const effect = make_effect_helper(normalized_candidate, helper_name);\n\n replacement_text = emit_promise_expression(\n id_text,\n effect,\n helper_bindings,\n );\n helpers = [...normalized.helpers, effect.helper];\n } else if (kind === \"render\") {\n const effect = make_effect_helper(normalized_candidate, helper_name);\n\n replacement_text = emit_render_expression(\n id_text,\n effect,\n candidate,\n helper_bindings,\n );\n helpers = [...normalized.helpers, effect.helper];\n } else if (kind === \"render_argument\") {\n const effect = make_effect_helper(normalized_candidate, helper_name);\n\n replacement_text = emit_each_expression(id_text, effect, helper_bindings);\n helpers = [...normalized.helpers, effect.helper];\n } else if (kind === \"each\") {\n const effect = make_effect_helper(normalized_candidate, helper_name);\n\n replacement_text = emit_each_expression(id_text, effect, helper_bindings);\n helpers = [...normalized.helpers, effect.helper];\n } else if (kind === \"event\") {\n const event = make_event_handler(normalized_candidate, helper_bindings);\n\n replacement_text = event.text;\n helpers = normalized.helpers;\n relocation = make_relocation(candidate, replacement_text, {\n originalStart: 0,\n originalEnd: candidate.expr_text.length,\n generatedText: event.expr_text,\n });\n } else {\n const effect = make_effect_helper(normalized_candidate, helper_name);\n\n replacement_text = emit_each_expression(id_text, effect, helper_bindings);\n helpers = [...normalized.helpers, effect.helper];\n }\n\n return {\n start: candidate.start,\n end: candidate.end,\n text: replacement_text,\n helpers,\n relocation,\n };\n}\n\nfunction make_event_handler(\n candidate: MarkupCandidate,\n helper_bindings: MarkupHelperBindings,\n): { text: string; expr_text: string } {\n const expr_text = candidate.expr_text;\n\n if (is_callback_function_expression(expr_text)) {\n throw new YieldStarInEventCallbackError(\n candidate.filename,\n expr_text,\n );\n }\n\n const analysis = analyze_event_body_yield_star(expr_text);\n\n if (analysis.has_nested_invalid_yield_star) {\n throw new AsyncEffectInEventCallbackError(\n candidate.filename,\n expr_text,\n );\n }\n\n return {\n expr_text,\n text:\n `(event) => { ${helper_bindings.run}(function* () { ${expr_text}; }); }`,\n };\n}\n\nfunction emit_promise_expression(\n id_text: string,\n effect: EffectHelper,\n helper_bindings: MarkupHelperBindings,\n): string {\n return `${helper_bindings.promise}(${id_text}, ${effect.deps_text}, () => ${effect.call})`;\n}\n\nfunction emit_render_expression(\n id_text: string,\n effect: EffectHelper,\n candidate: MarkupCandidate,\n helper_bindings: MarkupHelperBindings,\n): string {\n const expression = emit_promise_expression(id_text, effect, helper_bindings);\n\n if (/^\\s*yield\\s*\\*/.test(candidate.expr_text)) {\n return `(await ${expression})()`;\n }\n\n return `await ${expression}`;\n}\n\nfunction emit_each_expression(\n id_text: string,\n effect: EffectHelper,\n helper_bindings: MarkupHelperBindings,\n): string {\n return `await ${emit_promise_expression(id_text, effect, helper_bindings)}`;\n}\n\ninterface EffectHelper {\n helper: HelperDeclaration;\n call: string;\n deps_text: string;\n}\n\nfunction make_effect_helper(\n candidate: MarkupCandidate,\n helper_name: string,\n): EffectHelper {\n const deps = collect_free_identifiers(candidate.expr_text);\n const args_text = deps.join(\", \");\n const deps_text = deps.length === 0 ? \"[]\" : `[${args_text}]`;\n const call = `${helper_name}()`;\n const text =\n `function* ${helper_name}() { return (${candidate.expr_text}); }`;\n const generated_start = text.indexOf(candidate.expr_text);\n\n return {\n call,\n deps_text,\n helper: {\n text,\n relocation: {\n originalStart: candidate.start,\n originalEnd: candidate.end,\n generatedStartInReplacement: generated_start,\n generatedEndInReplacement: generated_start +\n candidate.expr_text.length,\n },\n },\n };\n}\n\nfunction make_cache_id(candidate: MarkupCandidate): string {\n const normalized_filename = candidate.filename.replace(/[?#].*$/, \"\");\n\n return `${normalized_filename}:${candidate.start}:${candidate.end}`;\n}\n\nfunction make_helper_name(\n candidate: MarkupCandidate,\n name_allocator: MarkupNameAllocator,\n): string {\n return name_allocator.reserve(\n `__SER___markup_effect_${candidate.start}_${candidate.end}`,\n );\n}\n\nfunction make_relocation(\n candidate: MarkupCandidate,\n replacement_text: string,\n inner: {\n originalStart: number;\n originalEnd: number;\n generatedText: string;\n },\n): PendingRelocation | undefined {\n const generated_start = replacement_text.indexOf(inner.generatedText);\n\n if (generated_start === -1) {\n return undefined;\n }\n\n return {\n originalStart: candidate.start + inner.originalStart,\n originalEnd: candidate.start + inner.originalEnd,\n generatedStartInReplacement: generated_start,\n generatedEndInReplacement: generated_start + inner.generatedText.length,\n };\n}\n","import ts from \"typescript\";\n\n/**\n * Checks whether a node is a `yield*` binary expression.\n *\n * @since 2.0.0\n * @param node - TypeScript AST node to check.\n * @returns Whether the node represents `yield * operand`.\n */\nexport function is_yield_star_expression(node: ts.Node): boolean {\n return (\n ts.isBinaryExpression(node) &&\n node.operatorToken.kind === ts.SyntaxKind.AsteriskToken &&\n ts.isIdentifier(node.left) &&\n node.left.text === \"yield\"\n );\n}\n\n/**\n * Checks whether a node owns its own yield semantics.\n *\n * @since 2.0.0\n * @param node - TypeScript AST node to check.\n * @returns Whether traversal should stop at this function boundary.\n */\nexport function is_function_boundary_node(node: ts.Node): boolean {\n return (\n ts.isArrowFunction(node) ||\n ts.isFunctionDeclaration(node) ||\n ts.isFunctionExpression(node) ||\n ts.isMethodDeclaration(node) ||\n ts.isGetAccessorDeclaration(node) ||\n ts.isSetAccessorDeclaration(node)\n );\n}\n\n/**\n * Returns `true` if the node tree contains a top-level `await`.\n *\n * @since 2.0.0\n * @param node - Root node to search.\n * @returns Whether a top-level await expression was found.\n */\nexport function contains_top_level_await(node: ts.Node): boolean {\n if (ts.isAwaitExpression(node)) {\n return true;\n }\n\n return node.getChildren().some(\n (child) =>\n !is_function_boundary_node(child) && contains_top_level_await(child),\n );\n}\n\n/**\n * Collects top-level `yield*` nodes under an expression.\n *\n * @since 2.0.0\n * @param node - Root node to search.\n * @param on_found - Callback invoked for each matching yield node.\n * @returns Nothing.\n */\nexport function collect_yield_star_nodes(\n node: ts.Node,\n on_found: (node: ts.Node) => void,\n): void {\n if (is_function_boundary_node(node)) {\n return;\n }\n\n if (is_yield_star_expression(node)) {\n on_found(node);\n return;\n }\n\n node.forEachChild((child) => {\n collect_yield_star_nodes(child, on_found);\n });\n}\n\n/**\n * Finds the first top-level `yield*` expression below a node.\n *\n * @since 2.0.0\n * @param node - Root node to search.\n * @param on_found - Callback invoked with the first matching node.\n * @returns Nothing.\n */\nexport function find_yield_star_node(\n node: ts.Node,\n on_found: (node: ts.Node) => void,\n): void {\n if (is_function_boundary_node(node)) {\n return;\n }\n\n if (is_yield_star_expression(node)) {\n on_found(node);\n return;\n }\n\n node.forEachChild((child) => {\n find_yield_star_node(child, on_found);\n });\n}\n\n/**\n * Extracts identifier names from a TypeScript binding name.\n *\n * @since 2.0.0\n * @param name - Binding name node to flatten.\n * @returns Identifier names from identifiers and destructuring patterns.\n */\nexport function extract_binding_names(name: ts.BindingName): string[] {\n if (ts.isIdentifier(name)) {\n return [name.text];\n }\n\n const result: string[] = [];\n\n for (const element of name.elements) {\n if (ts.isOmittedExpression(element)) {\n continue;\n }\n\n result.push(...extract_binding_names(element.name));\n }\n\n return result;\n}\n","import { collect_yield_star_nodes } from \"$/preprocess/ast.ts\";\nimport { contains_top_level_yield_star } from \"$/detect.ts\";\nimport MagicString from \"magic-string\";\nimport ts from \"typescript\";\n\nimport {\n analyze_event_body_yield_star,\n strip_arrow_function,\n} from \"./expressions.ts\";\nimport { HELPERS } from \"./constants.ts\";\nimport type { MarkupCandidate, TagKind } from \"./types.ts\";\n\ninterface SanitizeResult {\n code: string;\n candidates: MarkupCandidate[];\n}\n\ninterface DeclarationYieldExpression {\n start: number;\n end: number;\n expr_text: string;\n}\n\nexport function sanitize_markup(\n content: string,\n filename: string,\n): SanitizeResult {\n const candidates: MarkupCandidate[] = [];\n const magic = new MagicString(content);\n let helper_index = 0;\n let cursor = 0;\n\n while (cursor < content.length) {\n const open = content.indexOf(\"{\", cursor);\n if (open === -1) break;\n\n /** Skip braces inside <script> and <style> blocks. */\n if (\n is_inside_excluded_block(content, open) ||\n is_inside_html_comment(content, open)\n ) {\n cursor = open + 1;\n continue;\n }\n\n /** Find the matching closing brace. */\n const close = find_closing_brace(content, open + 1);\n if (close === -1) {\n cursor = open + 1;\n continue;\n }\n\n const inner = content.slice(open + 1, close);\n\n const trimmed = inner.trimStart();\n const leading_ws = inner.length - trimmed.length;\n\n const tag_info = get_tag_info(trimmed);\n\n const declaration_yields = collect_declaration_yield_expressions(\n content,\n open,\n leading_ws,\n trimmed,\n );\n\n if (declaration_yields.length > 0) {\n for (const declaration_yield of declaration_yields) {\n const placeholder = `__SER___markup_placeholder_${helper_index}`;\n helper_index += 1;\n\n candidates.push({\n placeholder,\n start: declaration_yield.start,\n end: declaration_yield.end,\n expr_text: declaration_yield.expr_text,\n filename,\n key: \"plain\",\n });\n\n magic.overwrite(\n declaration_yield.start,\n declaration_yield.end,\n placeholder,\n );\n }\n\n cursor = close + 1;\n continue;\n }\n\n let expr_body = trimmed.slice(tag_info.prefix_length);\n\n /** For @const, only use the RHS after `=` as the expression body. */\n const equal_idx = tag_info.kind === \"plain\" && trimmed.startsWith(\"@const \")\n ? expr_body.indexOf(\"=\")\n : -1;\n\n /** Check if this is a callback handler containing yield*. */\n const is_event_callback = is_event_callback_expression(inner);\n\n /** Determine if this brace contains yield* that needs lowering. */\n const event_yield = is_event_callback\n ? analyze_event_yield(inner)\n : undefined;\n const has_yield = event_yield?.has_top_level_yield_star ??\n contains_yield_star_in_text(expr_body);\n\n if (!has_yield) {\n cursor = close + 1;\n continue;\n }\n\n /** The expression starts after the tag prefix. For @const, after the `=`. */\n let extra_prefix = 0;\n\n if (equal_idx !== -1) {\n const after_eq_raw = expr_body.slice(equal_idx + 1);\n expr_body = after_eq_raw.trimStart();\n extra_prefix = equal_idx + 1 + (after_eq_raw.length - expr_body.length);\n }\n\n const expr_start = open + 1 + leading_ws + tag_info.prefix_length +\n extra_prefix;\n\n /** For each/await, the expression ends before ` as ` or ` then `/` catch `. */\n let expr_end = close;\n\n const key = tag_info.kind;\n\n if (key === \"each\") {\n const as_idx = expr_body.lastIndexOf(\" as \");\n if (as_idx !== -1) expr_end = expr_start + as_idx;\n }\n\n if (key === \"await\") {\n const then_idx = expr_body.indexOf(\" then \");\n const catch_idx = expr_body.indexOf(\" catch \");\n const boundary = Math.min(\n then_idx === -1 ? Infinity : then_idx,\n catch_idx === -1 ? Infinity : catch_idx,\n );\n if (boundary !== Infinity) expr_end = expr_start + boundary;\n }\n\n const expr_text = content.slice(expr_start, expr_end).trim();\n\n if (expr_text.length === 0) {\n cursor = close + 1;\n continue;\n }\n\n if (key === \"render\" && !/^\\s*yield\\s*\\*/.test(expr_text)) {\n const render_arg_yields = collect_expression_yield_expressions(\n content,\n expr_start,\n expr_text,\n );\n\n if (render_arg_yields.length > 0) {\n for (const render_arg_yield of render_arg_yields) {\n const placeholder = `__SER___markup_placeholder_${helper_index}`;\n helper_index += 1;\n\n candidates.push({\n placeholder,\n start: render_arg_yield.start,\n end: render_arg_yield.end,\n expr_text: render_arg_yield.expr_text,\n filename,\n key: \"render_argument\",\n });\n\n magic.overwrite(\n render_arg_yield.start,\n render_arg_yield.end,\n placeholder,\n );\n }\n\n cursor = close + 1;\n continue;\n }\n }\n\n /** Create a placeholder and replace the expression (preserving tag prefixes). */\n const placeholder = `__SER___markup_placeholder_${helper_index}`;\n helper_index += 1;\n\n candidates.push({\n placeholder,\n start: expr_start,\n end: expr_end,\n expr_text,\n filename,\n key,\n });\n\n magic.overwrite(\n expr_start,\n expr_end,\n key === \"render\" ? `${placeholder}()` : placeholder,\n );\n\n cursor = close + 1;\n }\n\n return { code: magic.toString(), candidates };\n}\n\nfunction collect_expression_yield_expressions(\n content: string,\n expr_start: number,\n expr_text: string,\n): DeclarationYieldExpression[] {\n const source_file = ts.createSourceFile(\n \"markup-expression.ts\",\n `const __SER___expr = ${expr_text};`,\n ts.ScriptTarget.Latest,\n true,\n ts.ScriptKind.TS,\n );\n const stmt = source_file.statements[0];\n\n if (!stmt || !ts.isVariableStatement(stmt)) {\n return [];\n }\n\n const initializer = stmt.declarationList.declarations[0]?.initializer;\n\n if (!initializer || !contains_top_level_yield_star(initializer)) {\n return [];\n }\n\n const prefix_length = source_file.text.indexOf(expr_text);\n const expressions: DeclarationYieldExpression[] = [];\n\n collect_yield_star_nodes(initializer, (yield_node) => {\n const start = expr_start + yield_node.getStart(source_file) -\n prefix_length;\n const end = expr_start + yield_node.end - prefix_length;\n const yielded_text = content.slice(start, end).trim();\n\n expressions.push({\n start,\n end,\n expr_text: yielded_text,\n });\n });\n\n return expressions;\n}\n\nfunction is_inside_excluded_block(content: string, pos: number): boolean {\n const script = find_tag_end(content, \"script\", pos);\n const style = find_tag_end(content, \"style\", pos);\n\n return (\n (script !== undefined && pos < script.end && pos > script.start) ||\n (style !== undefined && pos < style.end && pos > style.start)\n );\n}\n\nfunction is_inside_html_comment(content: string, pos: number): boolean {\n const open = content.lastIndexOf(\"<!--\", pos);\n const close = content.lastIndexOf(\"-->\", pos);\n\n return open !== -1 && open > close;\n}\n\nfunction find_tag_end(\n content: string,\n tag: string,\n after_pos: number,\n): { start: number; end: number } | undefined {\n const pattern = new RegExp(\n `<${tag}\\\\b[^>]*>([\\\\s\\\\S]*?)<\\\\/${tag}\\\\s*>`,\n \"gi\",\n );\n\n for (const match of content.matchAll(pattern)) {\n if (match.index === undefined) continue;\n const end_pos = match.index + match[0].length;\n if (match.index <= after_pos && after_pos < end_pos) {\n return { start: match.index, end: end_pos };\n }\n }\n\n return undefined;\n}\n\n/** Brace matching helpers for extracting complete markup expressions. */\n\nfunction find_closing_brace(content: string, start: number): number {\n let depth = 0;\n\n for (let i = start; i < content.length; i += 1) {\n const ch = content[i];\n\n if (ch === \"{\" && content[i - 1] !== \"$\") {\n depth += 1;\n } else if (ch === \"}\") {\n if (depth === 0) return i;\n depth -= 1;\n } else if (ch === \"'\" || ch === '\"' || ch === \"`\") {\n i = skip_string(content, i, ch);\n if (i === -1) return -1;\n } else if (ch === \"/\" && content[i + 1] === \"/\") {\n i = skip_line_comment(content, i);\n } else if (ch === \"/\" && content[i + 1] === \"*\") {\n i = skip_block_comment(content, i);\n if (i === -1) return -1;\n }\n }\n\n return -1;\n}\n\nfunction skip_string(content: string, start: number, quote: string): number {\n for (let i = start + 1; i < content.length; i += 1) {\n if (content[i] === \"\\\\\") {\n i += 1;\n continue;\n }\n if (content[i] === quote) return i;\n }\n return -1;\n}\n\nfunction skip_line_comment(content: string, start: number): number {\n for (let i = start + 2; i < content.length; i += 1) {\n if (content[i] === \"\\n\") return i;\n }\n return content.length;\n}\n\nfunction skip_block_comment(content: string, start: number): number {\n for (let i = start + 2; i < content.length; i += 1) {\n if (content[i] === \"*\" && content[i + 1] === \"/\") return i + 1;\n }\n return -1;\n}\n\ninterface TagInfo {\n kind: TagKind;\n prefix_length: number;\n}\n\nfunction get_tag_info(trimmed: string): TagInfo {\n if (trimmed.startsWith(\"#each \")) {\n return { kind: \"each\", prefix_length: \"#each \".length };\n }\n if (trimmed.startsWith(\"#await \")) {\n return { kind: \"await\", prefix_length: \"#await \".length };\n }\n if (trimmed.startsWith(\"@render \")) {\n return { kind: \"render\", prefix_length: \"@render \".length };\n }\n\n /** Strip prefix-only tags — the expression starts after the tag keyword. */\n if (trimmed.startsWith(\"#if \")) {\n return { kind: \"plain\", prefix_length: \"#if \".length };\n }\n if (trimmed.startsWith(\":else if \")) {\n return { kind: \"plain\", prefix_length: \":else if \".length };\n }\n if (trimmed.startsWith(\"#key \")) {\n return { kind: \"plain\", prefix_length: \"#key \".length };\n }\n if (trimmed.startsWith(\"@const \")) {\n return { kind: \"plain\", prefix_length: \"@const \".length };\n }\n if (trimmed.startsWith(\"@html \")) {\n return { kind: \"plain\", prefix_length: \"@html \".length };\n }\n if (trimmed.startsWith(\"@debug \")) {\n return { kind: \"plain\", prefix_length: \"@debug \".length };\n }\n\n return { kind: \"plain\", prefix_length: 0 };\n}\n\nfunction collect_declaration_yield_expressions(\n content: string,\n open: number,\n leading_ws: number,\n trimmed: string,\n): DeclarationYieldExpression[] {\n if (!is_declaration_tag_text(trimmed)) {\n return [];\n }\n\n const source_file = ts.createSourceFile(\n \"declaration-tag.ts\",\n `${trimmed};`,\n ts.ScriptTarget.Latest,\n true,\n ts.ScriptKind.TS,\n );\n\n const stmt = source_file.statements[0];\n\n if (!stmt || !ts.isVariableStatement(stmt)) {\n return [];\n }\n\n const tag_start = open + 1 + leading_ws;\n\n return stmt.declarationList.declarations.flatMap((decl) => {\n const initializer = decl.initializer;\n\n if (!initializer || !contains_top_level_yield_star(initializer)) {\n return [];\n }\n\n const expressions: DeclarationYieldExpression[] = [];\n\n collect_yield_star_nodes(initializer, (yield_node) => {\n const start = tag_start + yield_node.getStart(source_file);\n const end = tag_start + yield_node.end;\n const expr_text = content.slice(start, end).trim();\n\n expressions.push({\n start,\n end,\n expr_text,\n });\n });\n\n return expressions;\n });\n}\n\nfunction is_declaration_tag_text(trimmed: string): boolean {\n return /^(?:const|let)\\s/.test(trimmed);\n}\n\nfunction is_event_callback_expression(inner: string): boolean {\n const trimmed = inner.trimStart();\n\n return /^(?:async\\s+)?(?:\\([^)]*\\)|[A-Za-z_$][\\w$]*)\\s*=>/.test(trimmed) ||\n /^(?:async\\s+)?function\\b/.test(trimmed);\n}\n\nfunction analyze_event_yield(\n inner: string,\n): {\n has_top_level_yield_star: boolean;\n} {\n const event = strip_arrow_function(inner);\n const analysis = analyze_event_body_yield_star(event.body);\n const generated_run = new RegExp(`${HELPERS.run}(?:_\\\\d+)?\\\\(function\\\\*`);\n\n if (generated_run.test(event.body)) {\n return {\n has_top_level_yield_star: false,\n };\n }\n\n return {\n has_top_level_yield_star: analysis.has_top_level_yield_star ||\n analysis.has_nested_invalid_yield_star ||\n /\\byield\\s*\\*/.test(event.body),\n };\n}\n\nfunction contains_yield_star_in_text(text: string): boolean {\n if (!/\\byield\\s*\\*/.test(text)) return false;\n\n try {\n const sf = ts.createSourceFile(\n \"expr.ts\",\n `const x = ${text};`,\n ts.ScriptTarget.Latest,\n true,\n ts.ScriptKind.TS,\n );\n const stmt = sf.statements[0];\n if (!ts.isVariableStatement(stmt)) return false;\n const decl = stmt.declarationList.declarations[0];\n if (!decl?.initializer) return false;\n return contains_top_level_yield_star(decl.initializer);\n } catch {\n return true;\n }\n}\n\n/** Free identifier collection helpers for generated closures. */\n","import { type AST, parse } from \"svelte/compiler\";\n\nimport MagicString from \"magic-string\";\n\nimport {\n blank_script_blocks,\n create_relocations,\n create_source_map,\n inject_helpers,\n make_markup_helper_bindings,\n} from \"./apply.ts\";\nimport { classify_candidates } from \"./classify.ts\";\nimport { collect_effect_callback_bindings } from \"./effect-bindings.ts\";\nimport { emit_replacements } from \"./emit.ts\";\nimport { sanitize_markup } from \"./scan.ts\";\nimport { UnsupportedMarkupEffectPositionError } from \"$/error.ts\";\nimport type { MarkupTransformResult } from \"./types.ts\";\n\nexport type { MarkupRelocation, MarkupTransformResult } from \"./types.ts\";\n\n/**\n * Transforms Svelte markup containing `{yield* expr}` brace expressions\n * into calls to the markup runtime helpers (`value`, `promise`, `run`).\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 * @since 2.0.0\n * @param content - The raw `.svelte` file content.\n * @param filename - The source filename, used in error messages.\n * @returns The transformed markup and a flag indicating whether yield* was\n * found.\n */\nexport function transform_markup_effect(\n content: string,\n filename: string,\n): MarkupTransformResult {\n if (!/\\byield\\s*\\*/.test(content)) {\n return { code: content, has_yield: false };\n }\n\n /** Find all brace expressions containing yield* and replace with placeholders. */\n const work = sanitize_markup(content, filename);\n const effect_context = collect_effect_callback_bindings(content);\n const helper_context = make_markup_helper_bindings(content);\n\n if (work.candidates.length === 0) {\n return { code: content, has_yield: false };\n }\n\n /** Parse the sanitized markup with Svelte's AST. Strip <script> blocks\n * first so TypeScript syntax (import type, etc.) doesn't break the parser. */\n const clean = blank_script_blocks(work.code);\n const ast = parse(clean, { filename, modern: true }) as AST.Root;\n\n /** Match placeholders to their AST context and build replacements. */\n const classified = classify_candidates(\n ast,\n work.candidates,\n );\n const matched = new Set(\n classified.map(({ candidate }) => candidate.placeholder),\n );\n const unmatched = work.candidates.find((candidate) =>\n !matched.has(candidate.placeholder)\n );\n\n if (unmatched) {\n throw new UnsupportedMarkupEffectPositionError(\n filename,\n unmatched.expr_text,\n );\n }\n\n const replacements = emit_replacements(\n classified,\n effect_context,\n helper_context.bindings,\n helper_context.name_allocator,\n );\n const helpers = replacements.flatMap((replacement) =>\n replacement.helpers ?? []\n );\n\n const magic = new MagicString(content);\n\n replacements.sort((a, b) => b.start - a.start);\n\n for (const r of replacements) {\n magic.overwrite(r.start, r.end, r.text);\n }\n\n const helper_insertion = inject_helpers(\n magic,\n content,\n helpers,\n helper_context.bindings,\n );\n const relocations = create_relocations(replacements, helper_insertion);\n\n return {\n code: magic.toString(),\n has_yield: true,\n map: create_source_map(magic, filename),\n relocations,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAsBA,SAAgB,aACd,mBACA,uBACA,oBACA,WAAkC;CAChC,QAAQ;CACR,YAAY;CACZ,kBAAkB;CAClB,QAAQ;CACR,SAAS;CACT,SAAS;AACX,GACA,UAAgC,CAAC,GACzB;CACR,MAAM,mBAAmB,QAAQ,oBAAoB;CACrD,MAAM,eAAe,QAAQ,gBAAgB;CAC7C,MAAM,gBAAgB,QAAQ,iBAAiB;CAE/C,MAAM,oBAAoB,SAAS,eAAe,mBAC9C,gFACA,8BAA8B,SAAS,WAAW;CAEtD,MAAM,iBAAiB,SAAS,YAAY,YACxC,sCACA,uBAAuB,SAAS,QAAQ;CAE5C,MAAM,gBAAgB,oBAClB,QACA,SAAS,WAAW,WACpB,qCACA,sBAAsB,SAAS,OAAO;CAE1C,OAAO;EACL,oBAAoB,CAAC,yBAAyB;EAC9C,iBAAiB,CAAC,sBAAsB;EACxC,gBAAgB;CAClB,EACG,OAAO,OAAO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,CAAC,eAAe,KAAK,OAAO,GAC9B,OAAO;EAAE,MAAM;EAAS,WAAW;CAAM;;CAI3C,MAAM,OAAO,gBAAgB,SAAS,QAAQ;CAC9C,MAAM,iBAAiB,iCAAiC,OAAO;CAC/D,MAAM,iBAAiB,4BAA4B,OAAO;CAE1D,IAAI,KAAK,WAAW,WAAW,GAC7B,OAAO;EAAE,MAAM;EAAS,WAAW;CAAM;;CAS3C,MAAM,aAAa,oBAHP,MADE,oBAAoB,KAAK,IACjB,GAAG;EAAE;EAAU,QAAQ;CAAK,CAI9C,GACF,KAAK,UACP;CACA,MAAM,UAAU,IAAI,IAClB,WAAW,KAAK,EAAE,gBAAgB,UAAU,WAAW,CACzD;CACA,MAAM,YAAY,KAAK,WAAW,MAAM,cACtC,CAAC,QAAQ,IAAI,UAAU,WAAW,CACpC;CAEA,IAAI,WACF,MAAM,IAAI,qCACR,UACA,UAAU,SACZ;CAGF,MAAM,eAAe,kBACnB,YACA,gBACA,eAAe,UACf,eAAe,cACjB;CACA,MAAM,UAAU,aAAa,SAAS,gBACpC,YAAY,WAAW,CAAC,CAC1B;CAEA,MAAM,QAAQ,IAAI,YAAY,OAAO;CAErC,aAAa,MAAM,GAAG,MAAM,EAAE,QAAQ,EAAE,KAAK;CAE7C,KAAK,MAAM,KAAK,cACd,MAAM,UAAU,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI;CASxC,MAAM,cAAc,mBAAmB,cANd,eACvB,OACA,SACA,SACA,eAAe,QAEmD,CAAC;CAErE,OAAO;EACL,MAAM,MAAM,SAAS;EACrB,WAAW;EACX,KAAK,kBAAkB,OAAO,QAAQ;EACtC;CACF;AACF"}
@@ -1,2 +1,2 @@
1
- import { n as get_dispatcher, r as reset_dispatcher, t as Dispatcher } from "./chunks/dispatcher-BVkm8qbG.js";
1
+ import { n as get_dispatcher, r as reset_dispatcher, t as Dispatcher } from "./chunks/dispatcher-CgCdn6bj.js";
2
2
  export { Dispatcher, get_dispatcher, reset_dispatcher };
@@ -1,4 +1,4 @@
1
- import { n as get_dispatcher } from "../chunks/dispatcher-BVkm8qbG.js";
1
+ import { n as get_dispatcher } from "../chunks/dispatcher-CgCdn6bj.js";
2
2
  import { value } from "../markup/value.js";
3
3
  import { promise } from "../markup/promise.js";
4
4
  import { run } from "../markup/run.js";
@@ -1,2 +1,2 @@
1
- import { i as create_remote_command_adapter, n as create_remote_query_adapter, r as create_remote_form_adapter, t as create_remote_live_query_adapter } from "../chunks/client-Cj2X9lY-.js";
1
+ import { i as create_remote_command_adapter, n as create_remote_query_adapter, r as create_remote_form_adapter, t as create_remote_live_query_adapter } from "../chunks/client-Cruhk6Oo.js";
2
2
  export { create_remote_command_adapter, create_remote_form_adapter, create_remote_live_query_adapter, create_remote_query_adapter };
@@ -1,4 +1,4 @@
1
- import { n as get_dispatcher } from "../chunks/dispatcher-BVkm8qbG.js";
1
+ import { n as get_dispatcher } from "../chunks/dispatcher-CgCdn6bj.js";
2
2
  //#region src/markup/promise.ts
3
3
  /**
4
4
  * Runtime helper emitted by the markup preprocessor for
@@ -1,4 +1,4 @@
1
- import { n as get_dispatcher } from "../chunks/dispatcher-BVkm8qbG.js";
1
+ import { n as get_dispatcher } from "../chunks/dispatcher-CgCdn6bj.js";
2
2
  import { Effect } from "effect";
3
3
  //#region src/markup/run.ts
4
4
  /**
@@ -1,2 +1,2 @@
1
- import { t as transform_markup_effect } from "../chunks/transform-Cx5bjmP6.js";
1
+ import { t as transform_markup_effect } from "../chunks/transform-CMvL4SBp.js";
2
2
  export { transform_markup_effect };
@@ -1,4 +1,4 @@
1
- import { n as get_dispatcher } from "../chunks/dispatcher-BVkm8qbG.js";
1
+ import { n as get_dispatcher } from "../chunks/dispatcher-CgCdn6bj.js";
2
2
  //#region src/markup/value.ts
3
3
  /**
4
4
  * Runtime helper emitted by the markup preprocessor for `{yield* expr}`
package/.dist/mod.d.ts CHANGED
@@ -2,27 +2,6 @@ import type { ErrorEffectFactory, RedirectEffectFactory } from "./server/control
2
2
  import type { RequestEvent as RequestEventShape } from "./server/runtime.js";
3
3
  import type { CommandFactory, FormFactory, PrerenderFactory, QueryFactory, ServerRuntimeFactory } from "./server/types.js";
4
4
  import type { Context, Layer, ManagedRuntime } from "effect";
5
- /**
6
- * Result returned by the root Svelte markup preprocessor hook.
7
- *
8
- * @since 2.0.0
9
- */
10
- interface MarkupResult {
11
- code: string;
12
- }
13
- /**
14
- * Root preprocessor group shape. The root export keeps transform code lazy so
15
- * client imports do not pull parser-only dependencies into the browser.
16
- *
17
- * @since 2.0.0
18
- */
19
- interface PreprocessGroup {
20
- name: string;
21
- markup(options: {
22
- content: string;
23
- filename?: string;
24
- }): MarkupResult | Promise<MarkupResult>;
25
- }
26
5
  /**
27
6
  * Public API surface for `svelte-effect-runtime`.
28
7
  *
@@ -198,22 +177,4 @@ export { effect, type EffectOptions } from "./vite.js";
198
177
  /** Re-export server helper types from the root entrypoint. */
199
178
  export type { ErrorEffectFactory, ErrorStatus, ErrorStatusName, RedirectEffectFactory, RedirectStatus, RedirectStatusName, } from "./server/control-flow.js";
200
179
  /** Re-export server helper types from the root entrypoint. */
201
- export type { CommandFactory, EffectLike, EffectRemoteBatchHandler, EffectRemoteCommand, EffectRemoteForm, EffectRemoteFunction, EffectRemoteLiveQuery, EffectRemoteLiveQueryFunction, EffectRemoteLiveQueryResource, EffectRemoteLiveSource, EffectRemoteQuery, EffectRemoteQueryFunction, FormFactory, FormInvalid, PrerenderFactory, PrerenderOptions, QueryBatchFactory, QueryFactory, QueryLiveFactory, RemoteFormHandler, RemoteHandler, RemoteLiveHandler, SchemaEncodedInput, SchemaInput, ServerRuntimeFactory, StandardSchema, } from "./server/types.js";
202
- /**
203
- * Creates the Svelte preprocessor that lowers script and markup `yield*`
204
- * expressions. The heavy transform module is loaded lazily so browser imports
205
- * from the package root stay client-safe.
206
- *
207
- * @example
208
- * ```js
209
- * import { preprocess } from "svelte-effect-runtime";
210
- *
211
- * export default {
212
- * preprocess: [preprocess()],
213
- * };
214
- * ```
215
- *
216
- * @since 2.0.0
217
- * @returns A Svelte preprocessor group with an async markup hook.
218
- */
219
- export declare function preprocess(): PreprocessGroup;
180
+ export type { CommandFactory, EffectLike, EffectRemoteBatchHandler, EffectRemoteCommand, EffectRemoteForm, EffectRemoteFunction, EffectRemoteLiveQuery, EffectRemoteLiveQueryFunction, EffectRemoteLiveQueryResource, EffectRemoteLiveSource, EffectRemoteQuery, EffectRemoteQueryFunction, FormFactory, FormInvalid, PrerenderFactory, PrerenderOptions, QueryBatchFactory, QueryFactory, QueryLiveFactory, RemoteFormHandler, RemoteHandler, RemoteLiveHandler, SchemaEncodedInput, SchemaInput, ServerRuntimeFactory, StandardSchema, StandardSchemaInput, StandardSchemaOutput, } from "./server/types.js";
package/.dist/mod.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as Dispatcher } from "./chunks/dispatcher-BVkm8qbG.js";
1
+ import { t as Dispatcher } from "./chunks/dispatcher-CgCdn6bj.js";
2
2
  import { is_form_error, is_remote_http_error, is_remote_transport_error, is_remote_validation_error } from "./remote/shared.js";
3
3
  import { effect } from "./vite.js";
4
4
  //#region src/mod.ts
@@ -174,31 +174,6 @@ const RequestEvent = make_server_only_function("RequestEvent");
174
174
  * @since 2.0.0
175
175
  */
176
176
  const get_server_runtime_or_throw = make_server_only_function("get_server_runtime_or_throw");
177
- /**
178
- * Creates the Svelte preprocessor that lowers script and markup `yield*`
179
- * expressions. The heavy transform module is loaded lazily so browser imports
180
- * from the package root stay client-safe.
181
- *
182
- * @example
183
- * ```js
184
- * import { preprocess } from "svelte-effect-runtime";
185
- *
186
- * export default {
187
- * preprocess: [preprocess()],
188
- * };
189
- * ```
190
- *
191
- * @since 2.0.0
192
- * @returns A Svelte preprocessor group with an async markup hook.
193
- */
194
- function preprocess() {
195
- return {
196
- name: "svelte-effect-runtime",
197
- async markup(options) {
198
- return await (await import("./runtime/preprocess.js")).preprocess().markup(options);
199
- }
200
- };
201
- }
202
177
  function make_server_only_class(name) {
203
178
  return class ServerOnlyRuntime {
204
179
  static make() {
@@ -215,6 +190,6 @@ function make_server_only_error(name) {
215
190
  return new globalThis.Error(`[SERVER_ONLY_IMPORT]: ${name} is only available in SvelteKit server files. Ensure the SER Vite plugin is enabled so root imports are rewritten to \`svelte-effect-runtime/server\` before evaluation.`);
216
191
  }
217
192
  //#endregion
218
- export { ClientRuntime, Command, Error, Form, Prerender, Query, Redirect, RequestEvent, ServerRuntime, effect, get_server_runtime_or_throw, is_form_error, is_remote_http_error, is_remote_transport_error, is_remote_validation_error, preprocess };
193
+ export { ClientRuntime, Command, Error, Form, Prerender, Query, Redirect, RequestEvent, ServerRuntime, effect, get_server_runtime_or_throw, is_form_error, is_remote_http_error, is_remote_transport_error, is_remote_validation_error };
219
194
 
220
195
  //# sourceMappingURL=mod.js.map
package/.dist/mod.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"mod.js","names":[],"sources":["../../modules/svelte-effect-runtime/src/mod.ts"],"sourcesContent":["import { Dispatcher as InternalDispatcher } from \"$/dispatcher.ts\";\nimport type {\n ErrorEffectFactory,\n RedirectEffectFactory,\n} from \"$/server/control-flow.ts\";\nimport type { RequestEvent as RequestEventShape } from \"$/server/runtime.ts\";\nimport type {\n CommandFactory,\n FormFactory,\n PrerenderFactory,\n QueryFactory,\n ServerRuntimeFactory,\n} from \"$/server/types.ts\";\nimport type { Context, Layer, ManagedRuntime } from \"effect\";\n\n/**\n * Result returned by the root Svelte markup preprocessor hook.\n *\n * @since 2.0.0\n */\ninterface MarkupResult {\n code: string;\n}\n\n/**\n * Root preprocessor group shape. The root export keeps transform code lazy so\n * client imports do not pull parser-only dependencies into the browser.\n *\n * @since 2.0.0\n */\ninterface PreprocessGroup {\n name: string;\n markup(\n options: { content: string; filename?: string },\n ): MarkupResult | Promise<MarkupResult>;\n}\n\n/**\n * Public API surface for `svelte-effect-runtime`.\n *\n * Call {@link ClientRuntime.make} in `hooks.client.ts`, call\n * {@link ServerRuntime.make} in `hooks.server.ts`, and let the Vite plugin\n * route server-only helpers to the server entrypoint automatically.\n *\n * @module\n */\n\n/**\n * Client-side runtime singleton. Call `ClientRuntime.make(layer?)` once\n * in `hooks.client.ts` to provide services to every component's effect\n * blocks.\n *\n * If never called, a default empty-layer runtime is created lazily on\n * the first `yield*` expression.\n *\n * @example\n * ```ts\n * import { ClientRuntime } from \"svelte-effect-runtime\";\n * import { Db } from \"./db.ts\";\n *\n * ClientRuntime.make(Db.Live);\n * ```\n *\n * @since 2.0.0\n */\nexport class ClientRuntime {\n /**\n * Build and cache the client-side dispatcher runtime.\n *\n * @since 2.0.0\n * @param layer - Optional Effect layer to provide to the runtime.\n */\n static make<R = never>(layer?: Layer.Layer<R>): void {\n InternalDispatcher.make(layer);\n }\n}\n\n/**\n * Server-side runtime singleton export. In SvelteKit server files the Vite\n * plugin rewrites root imports to `svelte-effect-runtime/server`, so this\n * name resolves to the real server implementation before it is evaluated.\n *\n * @example\n * ```ts\n * import { ServerRuntime } from \"svelte-effect-runtime\";\n *\n * ServerRuntime.make();\n * ```\n *\n * @since 2.0.0\n */\nexport const ServerRuntime: ServerRuntimeFactory = make_server_only_class(\n \"ServerRuntime\",\n) as never;\n\n/**\n * Remote query factory export for `.remote.ts` files imported from the root\n * entrypoint. The Vite plugin rewrites it to the real server implementation.\n *\n * @example\n * ```ts\n * import { Query } from \"svelte-effect-runtime\";\n *\n * export const GetPosts = Query(Effect.succeed([]));\n * ```\n *\n * @since 2.0.0\n */\nexport const Query: QueryFactory = Object.assign(\n make_server_only_function(\"Query\"),\n {\n batch: make_server_only_function(\"Query.batch\"),\n live: make_server_only_function(\"Query.live\"),\n },\n) as never;\n\n/**\n * Remote command factory export for `.remote.ts` files imported from the root\n * entrypoint. The Vite plugin rewrites it to the real server implementation.\n *\n * @example\n * ```ts\n * import { Command } from \"svelte-effect-runtime\";\n *\n * export const SavePost = Command(Schema.String, (id) => Effect.succeed(id));\n * ```\n *\n * @since 2.0.0\n */\nexport const Command: CommandFactory = make_server_only_function(\n \"Command\",\n) as never;\n\n/**\n * SvelteKit HTTP error control-flow export for `.remote.ts` files imported\n * from the root entrypoint. The Vite plugin rewrites it to the real server\n * implementation.\n *\n * @example\n * ```ts\n * import { Error } from \"svelte-effect-runtime\";\n *\n * return yield* Error(\"NotFound\", \"Post not found\");\n * ```\n *\n * @since 2.3.0\n */\nexport const Error: ErrorEffectFactory = make_server_only_function(\n \"Error\",\n) as never;\n\n/**\n * Remote form factory export for `.remote.ts` files imported from the root\n * entrypoint. The Vite plugin rewrites it to the real server implementation.\n *\n * @example\n * ```ts\n * import { Form } from \"svelte-effect-runtime\";\n *\n * export const CreatePost = Form(PostInput, ({ data }) => Effect.succeed(data));\n * ```\n *\n * @since 2.0.0\n */\nexport const Form: FormFactory = make_server_only_function(\n \"Form\",\n) as never;\n\n/**\n * Remote prerender factory export for `.remote.ts` files imported from the\n * root entrypoint. The Vite plugin rewrites it to the real server\n * implementation.\n *\n * @example\n * ```ts\n * import { Prerender } from \"svelte-effect-runtime\";\n *\n * export const GetBuildInfo = Prerender(() => Effect.succeed(\"ready\"));\n * ```\n *\n * @since 2.0.0\n */\nexport const Prerender: PrerenderFactory = make_server_only_function(\n \"Prerender\",\n) as never;\n\n/**\n * SvelteKit redirect control-flow export for `.remote.ts` files imported from\n * the root entrypoint. The Vite plugin rewrites it to the real server\n * implementation.\n *\n * @example\n * ```ts\n * import { Redirect } from \"svelte-effect-runtime\";\n *\n * return yield* Redirect(\"SeeOther\", \"/posts\");\n * ```\n *\n * @since 2.3.0\n */\nexport const Redirect: RedirectEffectFactory = make_server_only_function(\n \"Redirect\",\n) as never;\n\n/**\n * Current SvelteKit request event service export for `.remote.ts` files\n * imported from the root entrypoint. The Vite plugin rewrites it to the real\n * server implementation.\n *\n * @example\n * ```ts\n * import { RequestEvent } from \"svelte-effect-runtime\";\n *\n * const event = yield* RequestEvent;\n * ```\n *\n * @since 2.0.0\n */\nexport const RequestEvent: Context.Reference<RequestEventShape> =\n make_server_only_function(\"RequestEvent\") as never;\n\n/**\n * Returns the active server runtime when imported from a server file. The Vite\n * plugin rewrites root imports to the real server implementation.\n *\n * @example\n * ```ts\n * import { get_server_runtime_or_throw } from \"svelte-effect-runtime\";\n *\n * const runtime = get_server_runtime_or_throw();\n * ```\n *\n * @since 2.0.0\n */\nexport const get_server_runtime_or_throw: () => ManagedRuntime.ManagedRuntime<\n unknown,\n never\n> = make_server_only_function(\"get_server_runtime_or_throw\") as never;\n\n/** Re-export error types users need for typed catch handlers. */\nexport type {\n FormError,\n FormIssue,\n RemoteFailure,\n RemoteHttpError,\n RemoteTransportError,\n RemoteValidationError,\n} from \"$/remote/shared.ts\";\n\nexport {\n is_form_error,\n is_remote_http_error,\n is_remote_transport_error,\n is_remote_validation_error,\n} from \"$/remote/shared.ts\";\n\n/** Re-export app setup helpers so users can import them from root. */\nexport { effect, type EffectOptions } from \"$/vite.ts\";\n\n/** Re-export server helper types from the root entrypoint. */\nexport type {\n ErrorEffectFactory,\n ErrorStatus,\n ErrorStatusName,\n RedirectEffectFactory,\n RedirectStatus,\n RedirectStatusName,\n} from \"$/server/control-flow.ts\";\n\n/** Re-export server helper types from the root entrypoint. */\nexport type {\n CommandFactory,\n EffectLike,\n EffectRemoteBatchHandler,\n EffectRemoteCommand,\n EffectRemoteForm,\n EffectRemoteFunction,\n EffectRemoteLiveQuery,\n EffectRemoteLiveQueryFunction,\n EffectRemoteLiveQueryResource,\n EffectRemoteLiveSource,\n EffectRemoteQuery,\n EffectRemoteQueryFunction,\n FormFactory,\n FormInvalid,\n PrerenderFactory,\n PrerenderOptions,\n QueryBatchFactory,\n QueryFactory,\n QueryLiveFactory,\n RemoteFormHandler,\n RemoteHandler,\n RemoteLiveHandler,\n SchemaEncodedInput,\n SchemaInput,\n ServerRuntimeFactory,\n StandardSchema,\n} from \"$/server/types.ts\";\n\n/**\n * Creates the Svelte preprocessor that lowers script and markup `yield*`\n * expressions. The heavy transform module is loaded lazily so browser imports\n * from the package root stay client-safe.\n *\n * @example\n * ```js\n * import { preprocess } from \"svelte-effect-runtime\";\n *\n * export default {\n * preprocess: [preprocess()],\n * };\n * ```\n *\n * @since 2.0.0\n * @returns A Svelte preprocessor group with an async markup hook.\n */\nexport function preprocess(): PreprocessGroup {\n return {\n name: \"svelte-effect-runtime\",\n\n async markup(options: { content: string; filename?: string }) {\n const runtime = await import(\"./runtime/preprocess.ts\");\n const group = runtime.preprocess();\n\n return await group.markup(options);\n },\n };\n}\n\nfunction make_server_only_class(name: string): unknown {\n return class ServerOnlyRuntime {\n static make(): never {\n throw make_server_only_error(name);\n }\n };\n}\n\nfunction make_server_only_function(\n name: string,\n): (...args: unknown[]) => never {\n return (..._args: unknown[]): never => {\n throw make_server_only_error(name);\n };\n}\n\nfunction make_server_only_error(name: string): globalThis.Error {\n return new globalThis.Error(\n `[SERVER_ONLY_IMPORT]: ${name} is only available in SvelteKit server files. ` +\n `Ensure the SER Vite plugin is enabled so root imports are rewritten ` +\n `to \\`svelte-effect-runtime/server\\` before evaluation.`,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiEA,IAAa,gBAAb,MAA2B;;;;;;;CAOzB,OAAO,KAAgB,OAA8B;EACnD,WAAmB,KAAK,KAAK;CAC/B;AACF;;;;;;;;;;;;;;;AAgBA,MAAa,gBAAsC,uBACjD,eACF;;;;;;;;;;;;;;AAeA,MAAa,QAAsB,OAAO,OACxC,0BAA0B,OAAO,GACjC;CACE,OAAO,0BAA0B,aAAa;CAC9C,MAAM,0BAA0B,YAAY;AAC9C,CACF;;;;;;;;;;;;;;AAeA,MAAa,UAA0B,0BACrC,SACF;;;;;;;;;;;;;;;AAgBA,MAAa,QAA4B,0BACvC,OACF;;;;;;;;;;;;;;AAeA,MAAa,OAAoB,0BAC/B,MACF;;;;;;;;;;;;;;;AAgBA,MAAa,YAA8B,0BACzC,WACF;;;;;;;;;;;;;;;AAgBA,MAAa,WAAkC,0BAC7C,UACF;;;;;;;;;;;;;;;AAgBA,MAAa,eACX,0BAA0B,cAAc;;;;;;;;;;;;;;AAe1C,MAAa,8BAGT,0BAA0B,6BAA6B;;;;;;;;;;;;;;;;;;AA+E3D,SAAgB,aAA8B;CAC5C,OAAO;EACL,MAAM;EAEN,MAAM,OAAO,SAAiD;GAI5D,OAAO,OAFO,MADQ,OAAO,4BACP,WAEL,EAAE,OAAO,OAAO;EACnC;CACF;AACF;AAEA,SAAS,uBAAuB,MAAuB;CACrD,OAAO,MAAM,kBAAkB;EAC7B,OAAO,OAAc;GACnB,MAAM,uBAAuB,IAAI;EACnC;CACF;AACF;AAEA,SAAS,0BACP,MAC+B;CAC/B,QAAQ,GAAG,UAA4B;EACrC,MAAM,uBAAuB,IAAI;CACnC;AACF;AAEA,SAAS,uBAAuB,MAAgC;CAC9D,OAAO,IAAI,WAAW,MACpB,yBAAyB,KAAK,yKAGhC;AACF"}
1
+ {"version":3,"file":"mod.js","names":[],"sources":["../../modules/svelte-effect-runtime/src/mod.ts"],"sourcesContent":["import { Dispatcher as InternalDispatcher } from \"$/dispatcher.ts\";\nimport type {\n ErrorEffectFactory,\n RedirectEffectFactory,\n} from \"$/server/control-flow.ts\";\nimport type { RequestEvent as RequestEventShape } from \"$/server/runtime.ts\";\nimport type {\n CommandFactory,\n FormFactory,\n PrerenderFactory,\n QueryFactory,\n ServerRuntimeFactory,\n} from \"$/server/types.ts\";\nimport type { Context, Layer, ManagedRuntime } from \"effect\";\n\n/**\n * Public API surface for `svelte-effect-runtime`.\n *\n * Call {@link ClientRuntime.make} in `hooks.client.ts`, call\n * {@link ServerRuntime.make} in `hooks.server.ts`, and let the Vite plugin\n * route server-only helpers to the server entrypoint automatically.\n *\n * @module\n */\n\n/**\n * Client-side runtime singleton. Call `ClientRuntime.make(layer?)` once\n * in `hooks.client.ts` to provide services to every component's effect\n * blocks.\n *\n * If never called, a default empty-layer runtime is created lazily on\n * the first `yield*` expression.\n *\n * @example\n * ```ts\n * import { ClientRuntime } from \"svelte-effect-runtime\";\n * import { Db } from \"./db.ts\";\n *\n * ClientRuntime.make(Db.Live);\n * ```\n *\n * @since 2.0.0\n */\nexport class ClientRuntime {\n /**\n * Build and cache the client-side dispatcher runtime.\n *\n * @since 2.0.0\n * @param layer - Optional Effect layer to provide to the runtime.\n */\n static make<R = never>(layer?: Layer.Layer<R>): void {\n InternalDispatcher.make(layer);\n }\n}\n\n/**\n * Server-side runtime singleton export. In SvelteKit server files the Vite\n * plugin rewrites root imports to `svelte-effect-runtime/server`, so this\n * name resolves to the real server implementation before it is evaluated.\n *\n * @example\n * ```ts\n * import { ServerRuntime } from \"svelte-effect-runtime\";\n *\n * ServerRuntime.make();\n * ```\n *\n * @since 2.0.0\n */\nexport const ServerRuntime: ServerRuntimeFactory = make_server_only_class(\n \"ServerRuntime\",\n) as never;\n\n/**\n * Remote query factory export for `.remote.ts` files imported from the root\n * entrypoint. The Vite plugin rewrites it to the real server implementation.\n *\n * @example\n * ```ts\n * import { Query } from \"svelte-effect-runtime\";\n *\n * export const GetPosts = Query(Effect.succeed([]));\n * ```\n *\n * @since 2.0.0\n */\nexport const Query: QueryFactory = Object.assign(\n make_server_only_function(\"Query\"),\n {\n batch: make_server_only_function(\"Query.batch\"),\n live: make_server_only_function(\"Query.live\"),\n },\n) as never;\n\n/**\n * Remote command factory export for `.remote.ts` files imported from the root\n * entrypoint. The Vite plugin rewrites it to the real server implementation.\n *\n * @example\n * ```ts\n * import { Command } from \"svelte-effect-runtime\";\n *\n * export const SavePost = Command(Schema.String, (id) => Effect.succeed(id));\n * ```\n *\n * @since 2.0.0\n */\nexport const Command: CommandFactory = make_server_only_function(\n \"Command\",\n) as never;\n\n/**\n * SvelteKit HTTP error control-flow export for `.remote.ts` files imported\n * from the root entrypoint. The Vite plugin rewrites it to the real server\n * implementation.\n *\n * @example\n * ```ts\n * import { Error } from \"svelte-effect-runtime\";\n *\n * return yield* Error(\"NotFound\", \"Post not found\");\n * ```\n *\n * @since 2.3.0\n */\nexport const Error: ErrorEffectFactory = make_server_only_function(\n \"Error\",\n) as never;\n\n/**\n * Remote form factory export for `.remote.ts` files imported from the root\n * entrypoint. The Vite plugin rewrites it to the real server implementation.\n *\n * @example\n * ```ts\n * import { Form } from \"svelte-effect-runtime\";\n *\n * export const CreatePost = Form(PostInput, ({ data }) => Effect.succeed(data));\n * ```\n *\n * @since 2.0.0\n */\nexport const Form: FormFactory = make_server_only_function(\n \"Form\",\n) as never;\n\n/**\n * Remote prerender factory export for `.remote.ts` files imported from the\n * root entrypoint. The Vite plugin rewrites it to the real server\n * implementation.\n *\n * @example\n * ```ts\n * import { Prerender } from \"svelte-effect-runtime\";\n *\n * export const GetBuildInfo = Prerender(() => Effect.succeed(\"ready\"));\n * ```\n *\n * @since 2.0.0\n */\nexport const Prerender: PrerenderFactory = make_server_only_function(\n \"Prerender\",\n) as never;\n\n/**\n * SvelteKit redirect control-flow export for `.remote.ts` files imported from\n * the root entrypoint. The Vite plugin rewrites it to the real server\n * implementation.\n *\n * @example\n * ```ts\n * import { Redirect } from \"svelte-effect-runtime\";\n *\n * return yield* Redirect(\"SeeOther\", \"/posts\");\n * ```\n *\n * @since 2.3.0\n */\nexport const Redirect: RedirectEffectFactory = make_server_only_function(\n \"Redirect\",\n) as never;\n\n/**\n * Current SvelteKit request event service export for `.remote.ts` files\n * imported from the root entrypoint. The Vite plugin rewrites it to the real\n * server implementation.\n *\n * @example\n * ```ts\n * import { RequestEvent } from \"svelte-effect-runtime\";\n *\n * const event = yield* RequestEvent;\n * ```\n *\n * @since 2.0.0\n */\nexport const RequestEvent: Context.Reference<RequestEventShape> =\n make_server_only_function(\"RequestEvent\") as never;\n\n/**\n * Returns the active server runtime when imported from a server file. The Vite\n * plugin rewrites root imports to the real server implementation.\n *\n * @example\n * ```ts\n * import { get_server_runtime_or_throw } from \"svelte-effect-runtime\";\n *\n * const runtime = get_server_runtime_or_throw();\n * ```\n *\n * @since 2.0.0\n */\nexport const get_server_runtime_or_throw: () => ManagedRuntime.ManagedRuntime<\n unknown,\n never\n> = make_server_only_function(\"get_server_runtime_or_throw\") as never;\n\n/** Re-export error types users need for typed catch handlers. */\nexport type {\n FormError,\n FormIssue,\n RemoteFailure,\n RemoteHttpError,\n RemoteTransportError,\n RemoteValidationError,\n} from \"$/remote/shared.ts\";\n\nexport {\n is_form_error,\n is_remote_http_error,\n is_remote_transport_error,\n is_remote_validation_error,\n} from \"$/remote/shared.ts\";\n\n/** Re-export app setup helpers so users can import them from root. */\nexport { effect, type EffectOptions } from \"$/vite.ts\";\n\n/** Re-export server helper types from the root entrypoint. */\nexport type {\n ErrorEffectFactory,\n ErrorStatus,\n ErrorStatusName,\n RedirectEffectFactory,\n RedirectStatus,\n RedirectStatusName,\n} from \"$/server/control-flow.ts\";\n\n/** Re-export server helper types from the root entrypoint. */\nexport type {\n CommandFactory,\n EffectLike,\n EffectRemoteBatchHandler,\n EffectRemoteCommand,\n EffectRemoteForm,\n EffectRemoteFunction,\n EffectRemoteLiveQuery,\n EffectRemoteLiveQueryFunction,\n EffectRemoteLiveQueryResource,\n EffectRemoteLiveSource,\n EffectRemoteQuery,\n EffectRemoteQueryFunction,\n FormFactory,\n FormInvalid,\n PrerenderFactory,\n PrerenderOptions,\n QueryBatchFactory,\n QueryFactory,\n QueryLiveFactory,\n RemoteFormHandler,\n RemoteHandler,\n RemoteLiveHandler,\n SchemaEncodedInput,\n SchemaInput,\n ServerRuntimeFactory,\n StandardSchema,\n StandardSchemaInput,\n StandardSchemaOutput,\n} from \"$/server/types.ts\";\n\nfunction make_server_only_class(name: string): unknown {\n return class ServerOnlyRuntime {\n static make(): never {\n throw make_server_only_error(name);\n }\n };\n}\n\nfunction make_server_only_function(\n name: string,\n): (...args: unknown[]) => never {\n return (..._args: unknown[]): never => {\n throw make_server_only_error(name);\n };\n}\n\nfunction make_server_only_error(name: string): globalThis.Error {\n return new globalThis.Error(\n `[SERVER_ONLY_IMPORT]: ${name} is only available in SvelteKit server files. ` +\n `Ensure the SER Vite plugin is enabled so root imports are rewritten ` +\n `to \\`svelte-effect-runtime/server\\` before evaluation.`,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,IAAa,gBAAb,MAA2B;;;;;;;CAOzB,OAAO,KAAgB,OAA8B;EACnD,WAAmB,KAAK,KAAK;CAC/B;AACF;;;;;;;;;;;;;;;AAgBA,MAAa,gBAAsC,uBACjD,eACF;;;;;;;;;;;;;;AAeA,MAAa,QAAsB,OAAO,OACxC,0BAA0B,OAAO,GACjC;CACE,OAAO,0BAA0B,aAAa;CAC9C,MAAM,0BAA0B,YAAY;AAC9C,CACF;;;;;;;;;;;;;;AAeA,MAAa,UAA0B,0BACrC,SACF;;;;;;;;;;;;;;;AAgBA,MAAa,QAA4B,0BACvC,OACF;;;;;;;;;;;;;;AAeA,MAAa,OAAoB,0BAC/B,MACF;;;;;;;;;;;;;;;AAgBA,MAAa,YAA8B,0BACzC,WACF;;;;;;;;;;;;;;;AAgBA,MAAa,WAAkC,0BAC7C,UACF;;;;;;;;;;;;;;;AAgBA,MAAa,eACX,0BAA0B,cAAc;;;;;;;;;;;;;;AAe1C,MAAa,8BAGT,0BAA0B,6BAA6B;AAgE3D,SAAS,uBAAuB,MAAuB;CACrD,OAAO,MAAM,kBAAkB;EAC7B,OAAO,OAAc;GACnB,MAAM,uBAAuB,IAAI;EACnC;CACF;AACF;AAEA,SAAS,0BACP,MAC+B;CAC/B,QAAQ,GAAG,UAA4B;EACrC,MAAM,uBAAuB,IAAI;CACnC;AACF;AAEA,SAAS,uBAAuB,MAAgC;CAC9D,OAAO,IAAI,WAAW,MACpB,yBAAyB,KAAK,yKAGhC;AACF"}
@@ -1,5 +1,10 @@
1
- import ts from "typescript";
2
1
  import type { RuntimeImportBindings } from "./types.js";
2
+ import ts from "typescript";
3
+ interface RuntimeImportOptions {
4
+ needs_dispatcher?: boolean;
5
+ needs_effect?: boolean;
6
+ needs_untrack?: boolean;
7
+ }
3
8
  /**
4
9
  * Builds the import statements injected by the script preprocessor.
5
10
  *
@@ -8,9 +13,11 @@ import type { RuntimeImportBindings } from "./types.js";
8
13
  * @param has_dispatcher_import - Whether the user already imports
9
14
  * `get_dispatcher`.
10
15
  * @param has_untrack_import - Whether the user already imports `untrack`.
16
+ * @param bindings - Local names reserved for generated runtime helpers.
17
+ * @param options - Runtime helper imports required by this transformed script.
11
18
  * @returns Newline-separated import statements to inject.
12
19
  */
13
- export declare function make_imports(has_effect_import: boolean, has_dispatcher_import: boolean, has_untrack_import: boolean, bindings?: RuntimeImportBindings): string;
20
+ export declare function make_imports(has_effect_import: boolean, has_dispatcher_import: boolean, has_untrack_import: boolean, bindings?: RuntimeImportBindings, options?: RuntimeImportOptions): string;
14
21
  /**
15
22
  * Checks whether a source file imports a local binding from a module.
16
23
  *
@@ -39,3 +46,4 @@ export declare function has_top_level_binding(source_file: ts.SourceFile, local_
39
46
  * @returns Top-level names declared by imports, declarations, and variables.
40
47
  */
41
48
  export declare function collect_top_level_binding_names(source_file: ts.SourceFile): string[];
49
+ export {};
@@ -41,8 +41,10 @@ export interface TempBinding {
41
41
  export interface LoweredStatement {
42
42
  /** `$state` bindings to emit at component scope. */
43
43
  temps: TempBinding[];
44
- /** Helper declarations used only for generated temp types. */
44
+ /** Helper declarations to emit before the rewritten statement. */
45
45
  type_helpers?: string[];
46
+ /** Whether the rewritten statement directly awaits a dispatcher promise. */
47
+ uses_dispatcher_promise?: boolean;
46
48
  /** The rewritten statement text with yield* replaced by temp refs. */
47
49
  rewritten_text: string;
48
50
  /** Effect bodies to emit in dependency-tracked runtime blocks. */
@@ -82,9 +84,14 @@ export interface LoweredExpression {
82
84
  * @since 2.0.0
83
85
  */
84
86
  export interface ScriptLoweringContext {
87
+ /** Source filename used for stable generated runtime ids. */
88
+ filename: string;
89
+ /** Binding name used for the dispatcher factory in generated code. */
90
+ dispatcher_name: string;
85
91
  effect_name: string;
86
92
  /** Whether generated state placeholders should carry TypeScript types. */
87
93
  emit_types: boolean;
94
+ next_helper_name(hint?: string): string;
88
95
  next_temp_name(hint?: string): string;
89
96
  next_type_helper_name(hint?: string): string;
90
97
  }
@@ -1,3 +1,3 @@
1
- import { t as transform_markup_effect } from "./chunks/transform-Cx5bjmP6.js";
2
- import { t as transform_script_effect } from "./chunks/preprocess-DseI9Doo.js";
1
+ import { t as transform_markup_effect } from "./chunks/transform-CMvL4SBp.js";
2
+ import { t as transform_script_effect } from "./chunks/preprocess-BhoCga82.js";
3
3
  export { transform_markup_effect, transform_script_effect };
@@ -1,2 +1,2 @@
1
- import { i as create_remote_command_adapter, n as create_remote_query_adapter, r as create_remote_form_adapter, t as create_remote_live_query_adapter } from "../chunks/client-Cj2X9lY-.js";
1
+ import { i as create_remote_command_adapter, n as create_remote_query_adapter, r as create_remote_form_adapter, t as create_remote_live_query_adapter } from "../chunks/client-Cruhk6Oo.js";
2
2
  export { create_remote_command_adapter, create_remote_form_adapter, create_remote_live_query_adapter, create_remote_query_adapter };
@@ -37,7 +37,11 @@ function handle_failure(cause, invalid, error) {
37
37
  if (is_sveltekit_control_flow(defect)) throw defect;
38
38
  }
39
39
  /**
40
- * Phase 2 — preserve typed form validation failures.
40
+ * Phase 2 — let cancellation escape without becoming a remote failure.
41
+ */
42
+ if (Cause.hasInterruptsOnly(cause)) throw Cause.squash(cause);
43
+ /**
44
+ * Phase 3 — preserve typed form validation failures.
41
45
  */
42
46
  for (const reason of reasons) if (Cause.isFailReason(reason)) {
43
47
  const failure = reason.error;