svelte-effect-runtime 4.0.1 → 4.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/.dist/chunks/{client-BrZka6DW.js → client-DbwVAMWm.js} +5 -5
  2. package/.dist/chunks/{client-BrZka6DW.js.map → client-DbwVAMWm.js.map} +1 -1
  3. package/.dist/chunks/{compiler-COVzgLYo.js → compiler-Dpyu4Owd.js} +2 -2
  4. package/.dist/chunks/{compiler-COVzgLYo.js.map → compiler-Dpyu4Owd.js.map} +1 -1
  5. package/.dist/chunks/{descriptors-B4otDlm1.js → descriptors-q909VWyR.js} +3 -3
  6. package/.dist/chunks/{descriptors-B4otDlm1.js.map → descriptors-q909VWyR.js.map} +1 -1
  7. package/.dist/chunks/{diagnostics-BDrky-Di.js → diagnostics-DLwwrBWb.js} +2 -2
  8. package/.dist/chunks/{diagnostics-BDrky-Di.js.map → diagnostics-DLwwrBWb.js.map} +1 -1
  9. package/.dist/chunks/{dispatcher-_x0MQZBS.js → dispatcher-CTWINW5I.js} +219 -16
  10. package/.dist/chunks/dispatcher-CTWINW5I.js.map +1 -0
  11. package/.dist/chunks/dispatcher-pZPzarul.js +23 -0
  12. package/.dist/chunks/dispatcher-pZPzarul.js.map +1 -0
  13. package/.dist/chunks/{errors-CLsbGjIa.js → errors-qhcbUH6o.js} +19 -2
  14. package/.dist/chunks/{errors-CLsbGjIa.js.map → errors-qhcbUH6o.js.map} +1 -1
  15. package/.dist/chunks/{live-BundLSoY.js → live-BW7xZKjb.js} +2 -2
  16. package/.dist/chunks/{live-BundLSoY.js.map → live-BW7xZKjb.js.map} +1 -1
  17. package/.dist/chunks/{runtime-HDTlEnzp.js → runtime-CPosEhGl.js} +3 -3
  18. package/.dist/chunks/{runtime-HDTlEnzp.js.map → runtime-CPosEhGl.js.map} +1 -1
  19. package/.dist/chunks/{server-BNrA1I-u.js → server-yQrNoiCR.js} +2 -2
  20. package/.dist/chunks/{server-BNrA1I-u.js.map → server-yQrNoiCR.js.map} +1 -1
  21. package/.dist/chunks/{source-scan-9pZxnfct.js → source-scan-cSawCvsg.js} +2 -2
  22. package/.dist/chunks/source-scan-cSawCvsg.js.map +1 -0
  23. package/.dist/chunks/{transform-BXyYUAez.js → transform-D7TTlPpK.js} +75 -27
  24. package/.dist/chunks/transform-D7TTlPpK.js.map +1 -0
  25. package/.dist/compiler.js +1 -1
  26. package/.dist/dispatcher/index.d.ts +49 -0
  27. package/.dist/dispatcher/scope.d.ts +36 -0
  28. package/.dist/dispatcher.d.ts +2 -1
  29. package/.dist/dispatcher.js +2 -2
  30. package/.dist/errors.d.ts +14 -0
  31. package/.dist/generated/dispatcher.d.ts +6 -1
  32. package/.dist/generators.d.ts +1 -0
  33. package/.dist/internal/generators.js +4 -4
  34. package/.dist/internal/remote-client.js +1 -1
  35. package/.dist/internal/remote-server.js +1 -1
  36. package/.dist/markup/promise.js +1 -1
  37. package/.dist/markup/run.js +1 -1
  38. package/.dist/markup/transform/apply.d.ts +4 -3
  39. package/.dist/markup/transform/constants.d.ts +1 -0
  40. package/.dist/markup/transform/types.d.ts +16 -0
  41. package/.dist/markup/transform.js +1 -1
  42. package/.dist/markup/value.js +1 -1
  43. package/.dist/mod.d.ts +1 -1
  44. package/.dist/mod.js +5 -5
  45. package/.dist/mod.js.map +1 -1
  46. package/.dist/remote/client.js +1 -1
  47. package/.dist/remote/server.js +1 -1
  48. package/.dist/runtime/transform.js +26 -12
  49. package/.dist/runtime/transform.js.map +1 -1
  50. package/.dist/script-transform/imports.d.ts +3 -1
  51. package/.dist/script-transform/index.d.ts +2 -0
  52. package/.dist/script-transform/types.d.ts +8 -0
  53. package/.dist/server.js +5 -5
  54. package/package.json +2 -2
  55. package/.dist/chunks/dispatcher-BA0PLQhA.js +0 -16
  56. package/.dist/chunks/dispatcher-BA0PLQhA.js.map +0 -1
  57. package/.dist/chunks/dispatcher-_x0MQZBS.js.map +0 -1
  58. package/.dist/chunks/source-scan-9pZxnfct.js.map +0 -1
  59. package/.dist/chunks/transform-BXyYUAez.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source-scan-cSawCvsg.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/compiler/source-scan.ts"],"sourcesContent":["import { type AST, parse } from \"svelte/compiler\";\n\nimport ts from \"typescript\";\n\nexport interface SourceRange {\n\t/** Inclusive start offset. */\n\tstart: number;\n\t/** Exclusive end offset. */\n\tend: number;\n}\n\nexport interface SourceAttribute extends SourceRange {\n\t/** Attribute name exactly as written in source. */\n\tname: string;\n\t/** Inclusive offset where the attribute name starts. */\n\tname_start: number;\n\t/** Exclusive offset where the attribute name ends. */\n\tname_end: number;\n\t/** Parsed string value when the attribute has one. */\n\tvalue?: string | undefined;\n}\n\nexport interface ScriptRegion extends SourceRange {\n\t/** Offset where the opening `<script` tag starts. */\n\topening_tag_start: number;\n\t/** Offset immediately after the opening tag's `>` character. */\n\topening_tag_end: number;\n\t/** Offset immediately after the `script` tag name. */\n\ttag_name_end: number;\n\t/** Offset where script content starts. */\n\tcontent_start: number;\n\t/** Offset where script content ends. */\n\tcontent_end: number;\n\t/** Offset where the closing `</script>` tag starts. */\n\tclosing_tag_start: number;\n\t/** Offset immediately after the closing `</script>` tag. */\n\tclosing_tag_end: number;\n\t/** Raw attribute text between `script` and `>`. */\n\tattributes_text: string;\n\t/** Parsed opening tag attributes. */\n\tattributes: readonly SourceAttribute[];\n\t/** Script content between the opening and closing tags. */\n\ttext: string;\n\t/** Whether this is a module script. */\n\tis_module: boolean;\n\t/** Whether the script has a `lang` attribute. */\n\thas_lang: boolean;\n\t/** Parsed `lang` value when present. */\n\tlang?: string | undefined;\n\t/** Whether this script should be parsed as TypeScript. */\n\tis_typescript: boolean;\n\t/** Whether this script has SER's `effect` attribute. */\n\thas_effect: boolean;\n\t/** Range of the `effect` attribute, including leading whitespace. */\n\teffect_attribute?: SourceRange | undefined;\n}\n\nexport interface MarkupBraceExpression {\n\t/** Offset of the opening `{`. */\n\topen: number;\n\t/** Offset of the closing `}`. */\n\tclose: number;\n\t/** Offset where the expression body starts. */\n\tinner_start: number;\n\t/** Offset where the expression body ends. */\n\tinner_end: number;\n\t/** Raw expression body between braces. */\n\tinner: string;\n\t/** Trimmed expression body. */\n\texpression_text: string;\n\t/** Attribute name when the expression is an attribute value. */\n\tattribute_name?: string | undefined;\n}\n\nexport interface BareConstDeclarationTag {\n\t/** Offset of the opening `{`. */\n\topen: number;\n\t/** Offset after `{` where `@` should be inserted. */\n\tinsert_position: number;\n\t/** Brace expression that contains the bare declaration. */\n\texpression: MarkupBraceExpression;\n}\n\nexport interface SvelteEffectSourceScan {\n\t/** Source filename used for diagnostics and debugging. */\n\tfilename: string;\n\t/** Full component source that was scanned. */\n\tsource: string;\n\t/** Complete root-level script regions in source order. */\n\tscripts: readonly ScriptRegion[];\n\t/** Complete root-level style tag ranges in source order. */\n\tstyles: readonly SourceRange[];\n\t/** HTML comment ranges in source order. */\n\tcomments: readonly SourceRange[];\n\t/** Merged ranges where markup brace scanning should not enter. */\n\texcluded_ranges: readonly SourceRange[];\n\t/** Markup brace expressions outside excluded ranges. */\n\tmarkup_expressions: readonly MarkupBraceExpression[];\n\t/** Lexical binding names introduced by markup blocks and directives. */\n\tmarkup_binding_names: readonly string[];\n\t/** Bare `{const ...}` tags outside excluded ranges. */\n\tbare_const_tags: readonly BareConstDeclarationTag[];\n\t/** First non-module script, if present. */\n\tinstance_script?: ScriptRegion | undefined;\n\t/** First non-module script with SER's `effect` attribute, if present. */\n\teffect_script?: ScriptRegion | undefined;\n}\n\ninterface SourceRegions {\n\tscripts: ScriptRegion[];\n\tstyles: SourceRange[];\n\tcomments: SourceRange[];\n\topaque_ranges: SourceRange[];\n\tattribute_names: ReadonlyMap<number, string>;\n\tmarkup_binding_names: ReadonlySet<string>;\n}\n\ninterface ParserDiagnostic {\n\tcode?: unknown;\n\tposition?: unknown;\n}\n\ninterface ParsedSourceFile extends ts.SourceFile {\n\tparseDiagnostics?: readonly ts.Diagnostic[];\n}\n\ntype MarkupBindingPattern = NonNullable<AST.EachBlock[\"context\"]>;\n\ninterface LocatedRawTag extends SourceRange {\n\tname: \"script\" | \"style\";\n\tcontent_start: number;\n\tcontent_end: number;\n}\n\nlet latest_scan: SvelteEffectSourceScan | undefined;\n\nfunction parse_svelte_source(source: string): AST.Root | undefined {\n\tlet parse_source = source;\n\tconst yield_count = source.match(/\\byield\\s*\\*/g)?.length ?? 0;\n\tconst max_attempts = yield_count + 1;\n\n\tfor (let attempt = 0; attempt < max_attempts; attempt += 1) {\n\t\ttry {\n\t\t\treturn parse(parse_source, { modern: true, loose: true });\n\t\t} catch (error) {\n\t\t\tconst normalized = normalize_parser_error(parse_source, error);\n\n\t\t\tif (!normalized || normalized === parse_source) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tparse_source = normalized;\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\nfunction normalize_parser_error(source: string, error: unknown): string | undefined {\n\tif (!is_parser_diagnostic(error) || !is_parser_position(error.position)) {\n\t\treturn undefined;\n\t}\n\n\tconst [start, end] = error.position;\n\n\tif (error.code === \"js_parse_error\") {\n\t\tconst match = source.slice(start).match(/^yield\\s*\\*/);\n\n\t\tif (!match) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn replace_range(source, start, start + match[0].length, blank_source(match[0]));\n\t}\n\n\tif (error.code !== \"render_tag_invalid_expression\") {\n\t\treturn undefined;\n\t}\n\n\tconst expression = source.slice(start, end);\n\tconst yield_index = expression.search(/\\byield\\s*\\*/);\n\n\tif (yield_index === -1) {\n\t\treturn undefined;\n\t}\n\n\treturn normalize_render_yield_expressions(source);\n}\n\nfunction normalize_render_yield_expressions(source: string): string {\n\tconst replacements: Array<SourceRange & { text: string }> = [];\n\tlet cursor = 0;\n\n\twhile (cursor < source.length) {\n\t\tconst open = source.indexOf(\"{@render\", cursor);\n\n\t\tif (open === -1) {\n\t\t\tbreak;\n\t\t}\n\n\t\tconst close = find_closing_brace(source, open);\n\n\t\tif (close === -1) {\n\t\t\tcursor = open + 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst tag = source.slice(open + 1, close);\n\t\tconst prefix = tag.match(/^@render\\b\\s*/)?.[0];\n\t\tconst expression_start = prefix ? open + 1 + prefix.length : -1;\n\t\tconst expression = expression_start === -1 ? \"\" : source.slice(expression_start, close);\n\n\t\tif (/\\byield\\s*\\*/.test(expression)) {\n\t\t\tconst blanked = blank_source(expression);\n\n\t\t\treplacements.push({\n\t\t\t\tstart: expression_start,\n\t\t\t\tend: close,\n\t\t\t\ttext: \"x()\" + blanked.slice(3),\n\t\t\t});\n\t\t}\n\n\t\tcursor = close + 1;\n\t}\n\n\tif (replacements.length === 0) {\n\t\treturn source;\n\t}\n\n\tconst parts: string[] = [];\n\tlet source_cursor = 0;\n\n\tfor (const replacement of replacements) {\n\t\tparts.push(source.slice(source_cursor, replacement.start), replacement.text);\n\t\tsource_cursor = replacement.end;\n\t}\n\n\tparts.push(source.slice(source_cursor));\n\n\treturn parts.join(\"\");\n}\n\nfunction is_parser_diagnostic(error: unknown): error is ParserDiagnostic {\n\treturn typeof error === \"object\" && error !== null;\n}\n\nfunction is_parser_position(position: unknown): position is [number, number] {\n\treturn (\n\t\tArray.isArray(position) &&\n\t\tposition.length === 2 &&\n\t\tposition.every((offset) => typeof offset === \"number\")\n\t);\n}\n\nfunction replace_range(source: string, start: number, end: number, replacement: string): string {\n\treturn source.slice(0, start) + replacement + source.slice(end);\n}\n\nfunction blank_source(source: string): string {\n\treturn source.replace(/[^\\r\\n]/g, \" \");\n}\n\nexport function scan_svelte_effect_source(\n\tsource: string,\n\tfilename = \"unknown.svelte\",\n): SvelteEffectSourceScan {\n\tif (latest_scan?.source === source && latest_scan.filename === filename) {\n\t\treturn latest_scan;\n\t}\n\n\tconst scan = scan_svelte_effect_source_uncached(source, filename);\n\n\tlatest_scan = scan;\n\n\treturn scan;\n}\n\nfunction scan_svelte_effect_source_uncached(\n\tsource: string,\n\tfilename: string,\n): SvelteEffectSourceScan {\n\tconst fast_regions = collect_fast_source_regions(source);\n\n\tif (fast_regions) {\n\t\treturn make_source_scan(source, filename, fast_regions);\n\t}\n\n\tconst parse_source = make_svelte_parse_shadow(source);\n\tconst ast = parse_svelte_source(parse_source);\n\n\tif (!ast) {\n\t\treturn make_opaque_scan(source, filename);\n\t}\n\n\tconst regions = collect_source_regions(source, ast);\n\n\treturn make_source_scan(source, filename, regions);\n}\n\nfunction make_source_scan(\n\tsource: string,\n\tfilename: string,\n\tregions: SourceRegions,\n): SvelteEffectSourceScan {\n\tconst scripts = regions.scripts;\n\tconst styles = regions.styles;\n\tconst comments = regions.comments;\n\tconst excluded_ranges = merge_ranges([...comments, ...regions.opaque_ranges]);\n\tconst markup_expressions = collect_scanned_markup_expressions(\n\t\tsource,\n\t\texcluded_ranges,\n\t\tregions.attribute_names,\n\t);\n\tconst bare_const_tags = markup_expressions.flatMap((expression) =>\n\t\tmake_bare_const_tag(expression),\n\t);\n\tconst instance_script = scripts.find((script) => !script.is_module);\n\tconst effect_script = scripts.find((script) => !script.is_module && script.has_effect);\n\n\treturn {\n\t\tfilename,\n\t\tsource,\n\t\tscripts,\n\t\tstyles,\n\t\tcomments,\n\t\texcluded_ranges,\n\t\tmarkup_expressions,\n\t\tmarkup_binding_names: [...regions.markup_binding_names],\n\t\tbare_const_tags,\n\t\tinstance_script,\n\t\teffect_script,\n\t};\n}\n\nfunction make_opaque_scan(source: string, filename: string): SvelteEffectSourceScan {\n\treturn {\n\t\tfilename,\n\t\tsource,\n\t\tscripts: [],\n\t\tstyles: [],\n\t\tcomments: [],\n\t\texcluded_ranges: source.length === 0 ? [] : [{ start: 0, end: source.length }],\n\t\tmarkup_expressions: [],\n\t\tmarkup_binding_names: [],\n\t\tbare_const_tags: [],\n\t\tinstance_script: undefined,\n\t\teffect_script: undefined,\n\t};\n}\n\n/** Reuses scan offsets after bare-const normalization inserts characters. */\nexport function shift_scan_after_at_insertions(\n\tscan: SvelteEffectSourceScan,\n\tnormalized_source: string,\n\tinsert_positions: readonly number[],\n): SvelteEffectSourceScan {\n\tconst inserts = [...insert_positions].sort((left, right) => left - right);\n\tconst shift = (offset: number) => offset + count_insertions_at_or_before(inserts, offset);\n\n\tconst shift_range = <T extends SourceRange>(range: T): T => ({\n\t\t...range,\n\t\tstart: shift(range.start),\n\t\tend: shift(range.end),\n\t});\n\n\tconst shift_attribute = (attribute: SourceAttribute): SourceAttribute => ({\n\t\t...shift_range(attribute),\n\t\tname: attribute.name,\n\t\tname_start: shift(attribute.name_start),\n\t\tname_end: shift(attribute.name_end),\n\t\tvalue: attribute.value,\n\t});\n\n\tconst shift_script = (script: ScriptRegion): ScriptRegion => {\n\t\tconst shifted = {\n\t\t\t...shift_range(script),\n\t\t\topening_tag_start: shift(script.opening_tag_start),\n\t\t\topening_tag_end: shift(script.opening_tag_end),\n\t\t\ttag_name_end: shift(script.tag_name_end),\n\t\t\tcontent_start: shift(script.content_start),\n\t\t\tcontent_end: shift(script.content_end),\n\t\t\tclosing_tag_start: shift(script.closing_tag_start),\n\t\t\tclosing_tag_end: shift(script.closing_tag_end),\n\t\t\tattributes_text: normalized_source.slice(\n\t\t\t\tshift(script.tag_name_end),\n\t\t\t\tshift(script.opening_tag_end) - 1,\n\t\t\t),\n\t\t\tattributes: script.attributes.map(shift_attribute),\n\t\t\ttext: normalized_source.slice(shift(script.content_start), shift(script.content_end)),\n\t\t\tis_module: script.is_module,\n\t\t\thas_lang: script.has_lang,\n\t\t\tlang: script.lang,\n\t\t\tis_typescript: script.is_typescript,\n\t\t\thas_effect: script.has_effect,\n\t\t\teffect_attribute: script.effect_attribute\n\t\t\t\t? shift_range(script.effect_attribute)\n\t\t\t\t: undefined,\n\t\t};\n\n\t\treturn shifted;\n\t};\n\n\tconst shift_expression = (expression: MarkupBraceExpression): MarkupBraceExpression => {\n\t\tconst open = shift(expression.open);\n\t\tconst close = shift(expression.close);\n\t\tconst inner_start = shift(expression.inner_start);\n\t\tconst inner_end = shift(expression.inner_end);\n\t\tconst inner = normalized_source.slice(inner_start, inner_end);\n\n\t\treturn {\n\t\t\topen,\n\t\t\tclose,\n\t\t\tinner_start,\n\t\t\tinner_end,\n\t\t\tinner,\n\t\t\texpression_text: inner.trim(),\n\t\t\tattribute_name: expression.attribute_name,\n\t\t};\n\t};\n\n\tconst scripts = scan.scripts.map(shift_script);\n\n\treturn {\n\t\tfilename: scan.filename,\n\t\tsource: normalized_source,\n\t\tscripts,\n\t\tstyles: scan.styles.map(shift_range),\n\t\tcomments: scan.comments.map(shift_range),\n\t\texcluded_ranges: scan.excluded_ranges.map(shift_range),\n\t\tmarkup_expressions: scan.markup_expressions.map(shift_expression),\n\t\tmarkup_binding_names: scan.markup_binding_names,\n\t\tbare_const_tags: [],\n\t\tinstance_script: scan.instance_script ? shift_script(scan.instance_script) : undefined,\n\t\teffect_script: scan.effect_script ? shift_script(scan.effect_script) : undefined,\n\t};\n}\n\nfunction count_insertions_at_or_before(\n\tinsert_positions: readonly number[],\n\toffset: number,\n): number {\n\tlet low = 0;\n\tlet high = insert_positions.length;\n\n\twhile (low < high) {\n\t\tconst middle = Math.floor((low + high) / 2);\n\n\t\tif ((insert_positions[middle] ?? Infinity) <= offset) {\n\t\t\tlow = middle + 1;\n\t\t} else {\n\t\t\thigh = middle;\n\t\t}\n\t}\n\n\treturn low;\n}\n\nfunction collect_fast_source_regions(source: string): SourceRegions | undefined {\n\tconst element_stack: string[] = [];\n\tconst scripts: ScriptRegion[] = [];\n\tconst styles: SourceRange[] = [];\n\tconst comments: SourceRange[] = [];\n\tconst opaque_ranges: SourceRange[] = [];\n\tlet optional_element_count = 0;\n\tlet cursor = 0;\n\n\twhile (cursor < source.length) {\n\t\tif (source.startsWith(\"<!--\", cursor)) {\n\t\t\tconst close = source.indexOf(\"-->\", cursor + 4);\n\n\t\t\tif (close === -1) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst comment = { start: cursor, end: close + 3 };\n\n\t\t\tcomments.push(comment);\n\t\t\tcursor = comment.end;\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst char = source[cursor];\n\n\t\tif (char === \"&\") {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tif (char === \"{\") {\n\t\t\tconst close = find_fast_closing_brace(source, cursor);\n\n\t\t\tif (close === -1 || /^\\s*[#/:@]/.test(source.slice(cursor + 1, close))) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tcursor = close + 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char !== \"<\") {\n\t\t\tcursor += 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst raw_name = read_raw_opening_name(source, cursor);\n\n\t\tif (raw_name) {\n\t\t\tif (element_stack.length > 0) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst raw_tag = locate_raw_tag(source, cursor, raw_name);\n\n\t\t\tif (!raw_tag || !is_fast_raw_opening(source, raw_tag)) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tif (raw_name === \"script\") {\n\t\t\t\tif (scripts.length > 0) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\tscripts.push(make_fast_script_region(source, raw_tag));\n\t\t\t} else {\n\t\t\t\tif (styles.length > 0) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\tstyles.push({ start: raw_tag.start, end: raw_tag.end });\n\t\t\t}\n\n\t\t\topaque_ranges.push({ start: raw_tag.start, end: raw_tag.end });\n\t\t\tcursor = raw_tag.end;\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst tag = read_fast_ordinary_tag(source, cursor);\n\n\t\tif (!tag) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tif (tag.is_closing) {\n\t\t\tif (fast_void_tag_names.has(tag.name) || element_stack.at(-1) !== tag.name) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\telement_stack.pop();\n\n\t\t\tif (fast_optional_end_tag_names.has(tag.name)) {\n\t\t\t\toptional_element_count -= 1;\n\t\t\t}\n\t\t} else if (!tag.is_self_closing && !fast_void_tag_names.has(tag.name)) {\n\t\t\tif (optional_element_count > 0) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\telement_stack.push(tag.name);\n\n\t\t\tif (fast_optional_end_tag_names.has(tag.name)) {\n\t\t\t\toptional_element_count += 1;\n\t\t\t}\n\t\t}\n\n\t\tcursor = tag.end;\n\t}\n\n\tif (element_stack.length > 0) {\n\t\treturn undefined;\n\t}\n\n\treturn {\n\t\tscripts,\n\t\tstyles,\n\t\tcomments,\n\t\topaque_ranges,\n\t\tattribute_names: new Map(),\n\t\tmarkup_binding_names: new Set(),\n\t};\n}\n\nconst fast_void_tag_names = new Set([\n\t\"area\",\n\t\"base\",\n\t\"br\",\n\t\"col\",\n\t\"embed\",\n\t\"hr\",\n\t\"img\",\n\t\"input\",\n\t\"link\",\n\t\"meta\",\n\t\"param\",\n\t\"source\",\n\t\"track\",\n\t\"wbr\",\n]);\n\nconst fast_optional_end_tag_names = new Set([\n\t\"colgroup\",\n\t\"dd\",\n\t\"dt\",\n\t\"li\",\n\t\"optgroup\",\n\t\"option\",\n\t\"p\",\n\t\"rp\",\n\t\"rt\",\n\t\"tbody\",\n\t\"td\",\n\t\"tfoot\",\n\t\"th\",\n\t\"thead\",\n\t\"tr\",\n]);\n\nfunction read_fast_ordinary_tag(\n\tsource: string,\n\tstart: number,\n): { name: string; end: number; is_closing: boolean; is_self_closing: boolean } | undefined {\n\tlet cursor = start + 1;\n\tconst is_closing = source[cursor] === \"/\";\n\n\tif (is_closing) {\n\t\tcursor += 1;\n\t}\n\n\tconst name_start = cursor;\n\n\tif (!/[a-z]/.test(source[cursor] ?? \"\")) {\n\t\treturn undefined;\n\t}\n\n\twhile (/[a-z0-9-]/.test(source[cursor] ?? \"\")) {\n\t\tcursor += 1;\n\t}\n\n\tconst name = source.slice(name_start, cursor);\n\n\twhile (/\\s/.test(source[cursor] ?? \"\")) {\n\t\tcursor += 1;\n\t}\n\n\tconst is_self_closing = !is_closing && source[cursor] === \"/\";\n\n\tif (is_self_closing) {\n\t\tcursor += 1;\n\t}\n\n\tif (source[cursor] !== \">\") {\n\t\treturn undefined;\n\t}\n\n\treturn { name, end: cursor + 1, is_closing, is_self_closing };\n}\n\nfunction find_fast_closing_brace(source: string, open: number): number {\n\tlet depth = 1;\n\tlet cursor = open + 1;\n\n\twhile (cursor < source.length) {\n\t\tconst char = source[cursor];\n\n\t\tif (char === \"'\" || char === '\"') {\n\t\t\tconst close = skip_quoted_string(source, cursor, char);\n\n\t\t\tif (close === -1) {\n\t\t\t\treturn -1;\n\t\t\t}\n\n\t\t\tcursor = close + 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \"`\" || char === \"/\") {\n\t\t\treturn -1;\n\t\t}\n\n\t\tif (char === \"{\") {\n\t\t\tdepth += 1;\n\t\t} else if (char === \"}\") {\n\t\t\tdepth -= 1;\n\n\t\t\tif (depth === 0) {\n\t\t\t\treturn cursor;\n\t\t\t}\n\t\t}\n\n\t\tcursor += 1;\n\t}\n\n\treturn -1;\n}\n\nfunction read_raw_opening_name(source: string, start: number): \"script\" | \"style\" | undefined {\n\tfor (const name of [\"script\", \"style\"] as const) {\n\t\tconst name_end = start + name.length + 1;\n\n\t\tif (\n\t\t\tsource.startsWith(`<${name}`, start) &&\n\t\t\t(source[name_end] === \">\" || /\\s/.test(source[name_end] ?? \"\"))\n\t\t) {\n\t\t\treturn name;\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\nfunction locate_raw_tag(\n\tsource: string,\n\tstart: number,\n\tname: \"script\" | \"style\",\n): LocatedRawTag | undefined {\n\tconst content_start = find_static_opening_tag_end(source, start, name);\n\n\tif (content_start === -1) {\n\t\treturn undefined;\n\t}\n\n\tconst opening_tag = source.slice(start, content_start);\n\tconst is_preprocessor_style = name === \"style\" && has_style_lang_attribute(opening_tag);\n\tconst parsed_style_end =\n\t\tname === \"style\"\n\t\t\t? find_style_closing_tag(source, content_start, is_preprocessor_style)\n\t\t\t: undefined;\n\tconst content_end =\n\t\tname === \"script\"\n\t\t\t? find_raw_closing_tag(source, content_start, name)\n\t\t\t: (parsed_style_end ??\n\t\t\t\t(is_preprocessor_style\n\t\t\t\t\t? find_raw_closing_tag(source, content_start, name)\n\t\t\t\t\t: undefined));\n\n\tif (!content_end) {\n\t\treturn undefined;\n\t}\n\n\treturn {\n\t\tname,\n\t\tstart,\n\t\tend: content_end.end,\n\t\tcontent_start,\n\t\tcontent_end: content_end.start,\n\t};\n}\n\nfunction has_style_lang_attribute(opening_tag: string): boolean {\n\ttry {\n\t\tconst ast = parse(`${opening_tag}</style>`, { modern: true, loose: true });\n\n\t\treturn (\n\t\t\tast.css?.attributes.some((attribute) => attribute.name.toLowerCase() === \"lang\") ??\n\t\t\tfalse\n\t\t);\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nfunction find_raw_closing_tag(\n\tsource: string,\n\tstart: number,\n\tname: \"script\" | \"style\",\n): SourceRange | undefined {\n\tlet cursor = start;\n\n\twhile (cursor < source.length) {\n\t\tconst closing_start = source.indexOf(`</${name}`, cursor);\n\n\t\tif (closing_start === -1) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst closing_end = find_closing_tag_end_at(source, closing_start, name, false);\n\n\t\tif (closing_end !== undefined) {\n\t\t\treturn { start: closing_start, end: closing_end };\n\t\t}\n\n\t\tcursor = closing_start + name.length + 2;\n\t}\n\n\treturn undefined;\n}\n\nfunction find_static_opening_tag_end(\n\tsource: string,\n\tstart: number,\n\tname: \"script\" | \"style\",\n): number {\n\tlet cursor = start + name.length + 1;\n\tlet quote: string | undefined;\n\n\twhile (cursor < source.length) {\n\t\tconst char = source[cursor];\n\n\t\tif (quote) {\n\t\t\tif (char === quote) {\n\t\t\t\tquote = undefined;\n\t\t\t}\n\n\t\t\tcursor += 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === '\"' || char === \"'\") {\n\t\t\tquote = char;\n\t\t\tcursor += 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (\n\t\t\tchar === \"{\" ||\n\t\t\tchar === \"}\" ||\n\t\t\tchar === \"<\" ||\n\t\t\tsource.startsWith(\"/*\", cursor) ||\n\t\t\tsource.startsWith(\"//\", cursor)\n\t\t) {\n\t\t\treturn -1;\n\t\t}\n\n\t\tif (char === \">\") {\n\t\t\treturn source.slice(start, cursor).trimEnd().endsWith(\"/\") ? -1 : cursor + 1;\n\t\t}\n\n\t\tcursor += 1;\n\t}\n\n\treturn -1;\n}\n\nfunction find_style_closing_tag(\n\tsource: string,\n\tstart: number,\n\tskip_line_comments: boolean,\n): SourceRange | undefined {\n\tlet cursor = start;\n\n\twhile (cursor < source.length) {\n\t\tconst char = source[cursor];\n\t\tconst identifier_end = skip_line_comments\n\t\t\t? find_css_identifier_end(source, cursor)\n\t\t\t: undefined;\n\n\t\tif (identifier_end !== undefined) {\n\t\t\tconst url_end = skip_css_url(source, cursor, identifier_end);\n\n\t\t\tif (url_end === -1) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tcursor = url_end === undefined ? identifier_end : url_end + 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === '\"' || char === \"'\") {\n\t\t\tconst close = skip_quoted_string(source, cursor, char);\n\n\t\t\tif (close === -1) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tcursor = close + 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (source.startsWith(\"/*\", cursor)) {\n\t\t\tconst close = skip_block_comment(source, cursor);\n\n\t\t\tif (close === -1) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tcursor = close + 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (skip_line_comments && source.startsWith(\"//\", cursor)) {\n\t\t\tcursor = skip_line_comment(source, cursor) + 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst closing_end = find_closing_tag_end_at(source, cursor, \"style\", false);\n\n\t\tif (closing_end !== undefined) {\n\t\t\treturn { start: cursor, end: closing_end };\n\t\t}\n\n\t\tcursor += 1;\n\t}\n\n\treturn undefined;\n}\n\nfunction find_css_identifier_end(source: string, start: number): number | undefined {\n\tconst first = source[start];\n\n\tif (!is_css_identifier_start(first)) {\n\t\treturn undefined;\n\t}\n\n\tlet cursor = start;\n\n\twhile (cursor < source.length) {\n\t\tconst char = source[cursor];\n\n\t\tif (is_css_identifier_character(char)) {\n\t\t\tcursor += 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \"\\\\\") {\n\t\t\tcursor = skip_css_escape(source, cursor);\n\t\t\tcontinue;\n\t\t}\n\n\t\tbreak;\n\t}\n\n\treturn cursor;\n}\n\nfunction skip_css_url(source: string, start: number, identifier_end: number): number | undefined {\n\tif (source.slice(start, identifier_end).toLowerCase() !== \"url\") {\n\t\treturn undefined;\n\t}\n\n\tlet cursor = skip_css_whitespace(source, identifier_end);\n\n\tif (source[cursor] !== \"(\") {\n\t\treturn undefined;\n\t}\n\n\tcursor = skip_css_whitespace(source, cursor + 1);\n\n\tconst quote = source[cursor];\n\n\tif (quote === '\"' || quote === \"'\") {\n\t\tconst close = skip_quoted_string(source, cursor, quote);\n\n\t\tif (close === -1) {\n\t\t\treturn -1;\n\t\t}\n\n\t\tcursor = skip_css_url_trivia(source, close + 1);\n\n\t\tif (cursor === -1) {\n\t\t\treturn -1;\n\t\t}\n\n\t\treturn source[cursor] === \")\" ? cursor : -1;\n\t}\n\n\twhile (cursor < source.length) {\n\t\tconst char = source[cursor];\n\n\t\tif (char === \"\\\\\") {\n\t\t\tcursor = skip_css_escape(source, cursor);\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \")\") {\n\t\t\treturn cursor;\n\t\t}\n\n\t\tcursor += 1;\n\t}\n\n\treturn -1;\n}\n\nfunction skip_css_whitespace(source: string, start: number): number {\n\tlet cursor = start;\n\n\twhile (cursor < source.length && /[\\t\\n\\f\\r ]/.test(source[cursor] ?? \"\")) {\n\t\tcursor += 1;\n\t}\n\n\treturn cursor;\n}\n\nfunction skip_css_url_trivia(source: string, start: number): number {\n\tlet cursor = start;\n\n\twhile (cursor < source.length) {\n\t\tcursor = skip_css_whitespace(source, cursor);\n\n\t\tif (!source.startsWith(\"/*\", cursor)) {\n\t\t\treturn cursor;\n\t\t}\n\n\t\tconst close = skip_block_comment(source, cursor);\n\n\t\tif (close === -1) {\n\t\t\treturn -1;\n\t\t}\n\n\t\tcursor = close + 1;\n\t}\n\n\treturn cursor;\n}\n\nfunction skip_css_escape(source: string, start: number): number {\n\treturn Math.min(start + 2, source.length);\n}\n\nfunction is_css_identifier_start(char: string | undefined): boolean {\n\treturn (\n\t\tchar !== undefined &&\n\t\t(/[A-Za-z_-]/.test(char) || char === \"\\\\\" || char.charCodeAt(0) >= 0x80)\n\t);\n}\n\nfunction is_css_identifier_character(char: string | undefined): boolean {\n\treturn char !== undefined && (/[A-Za-z0-9_-]/.test(char) || char.charCodeAt(0) >= 0x80);\n}\n\nfunction is_fast_raw_opening(source: string, raw_tag: LocatedRawTag): boolean {\n\tconst opening = source.slice(raw_tag.start, raw_tag.content_start);\n\n\tif (raw_tag.name === \"script\") {\n\t\treturn opening === \"<script>\";\n\t}\n\n\treturn /^<style(?:\\s+lang=(?:\"[A-Za-z0-9_-]+\"|'[A-Za-z0-9_-]+'|[A-Za-z0-9_-]+))?\\s*>$/.test(\n\t\topening,\n\t);\n}\n\nfunction make_fast_script_region(source: string, raw_tag: LocatedRawTag): ScriptRegion {\n\treturn {\n\t\tstart: raw_tag.start,\n\t\tend: raw_tag.end,\n\t\topening_tag_start: raw_tag.start,\n\t\topening_tag_end: raw_tag.content_start,\n\t\ttag_name_end: raw_tag.start + \"<script\".length,\n\t\tcontent_start: raw_tag.content_start,\n\t\tcontent_end: raw_tag.content_end,\n\t\tclosing_tag_start: raw_tag.content_end,\n\t\tclosing_tag_end: raw_tag.end,\n\t\tattributes_text: \"\",\n\t\tattributes: [],\n\t\ttext: source.slice(raw_tag.content_start, raw_tag.content_end),\n\t\tis_module: false,\n\t\thas_lang: false,\n\t\tlang: undefined,\n\t\tis_typescript: false,\n\t\thas_effect: false,\n\t\teffect_attribute: undefined,\n\t};\n}\n\nfunction make_svelte_parse_shadow(source: string): string {\n\tconst raw_tags = collect_shadow_raw_tags(source);\n\n\tif (!raw_tags) {\n\t\treturn source;\n\t}\n\n\tconst parts: string[] = [];\n\tlet cursor = 0;\n\n\tfor (const raw_tag of raw_tags) {\n\t\tparts.push(source.slice(cursor, raw_tag.content_start));\n\t\tparts.push(blank_source(source.slice(raw_tag.content_start, raw_tag.content_end)));\n\t\tcursor = raw_tag.content_end;\n\t}\n\n\tparts.push(source.slice(cursor));\n\n\treturn normalize_markup_yield_operators(parts.join(\"\"));\n}\n\nfunction normalize_markup_yield_operators(source: string): string {\n\tconst replacements: Array<SourceRange & { text: string }> = [];\n\tlet cursor = 0;\n\n\twhile (cursor < source.length) {\n\t\tconst open = source.indexOf(\"{\", cursor);\n\n\t\tif (open === -1) {\n\t\t\tbreak;\n\t\t}\n\n\t\tconst close = find_closing_brace(source, open);\n\n\t\tif (close === -1) {\n\t\t\tcursor = open + 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst inner = source.slice(open + 1, close);\n\t\tconst trimmed = inner.trimStart();\n\n\t\tif (!/\\byield\\s*\\*/.test(inner) || /^@debug\\b/.test(trimmed)) {\n\t\t\tcursor = close + 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst render_prefix = inner.match(/^(\\s*@render\\b\\s*)/)?.[0];\n\t\tconst text = render_prefix\n\t\t\t? render_prefix + \"x()\" + blank_source(inner.slice(render_prefix.length)).slice(3)\n\t\t\t: inner.replace(/\\byield\\s*\\*/g, blank_source);\n\n\t\treplacements.push({ start: open + 1, end: close, text });\n\t\tcursor = close + 1;\n\t}\n\n\tif (replacements.length === 0) {\n\t\treturn source;\n\t}\n\n\tconst parts: string[] = [];\n\tlet source_cursor = 0;\n\n\tfor (const replacement of replacements) {\n\t\tparts.push(source.slice(source_cursor, replacement.start), replacement.text);\n\t\tsource_cursor = replacement.end;\n\t}\n\n\tparts.push(source.slice(source_cursor));\n\n\treturn parts.join(\"\");\n}\n\nfunction collect_shadow_raw_tags(source: string): LocatedRawTag[] | undefined {\n\tconst raw_tags: LocatedRawTag[] = [];\n\tlet cursor = 0;\n\n\twhile (cursor < source.length) {\n\t\tif (source.startsWith(\"<!--\", cursor)) {\n\t\t\tconst close = source.indexOf(\"-->\", cursor + 4);\n\n\t\t\tif (close === -1) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tcursor = close + 3;\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst char = source[cursor];\n\n\t\tif (char === \"{\") {\n\t\t\tconst close = find_closing_brace(source, cursor);\n\n\t\t\tif (close === -1) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tcursor = close + 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char !== \"<\") {\n\t\t\tcursor += 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst rcdata_name = read_rcdata_opening_name(source, cursor);\n\n\t\tif (rcdata_name) {\n\t\t\tconst content_start = find_markup_tag_end(source, cursor);\n\t\t\tconst closing_tag =\n\t\t\t\tcontent_start === -1\n\t\t\t\t\t? undefined\n\t\t\t\t\t: find_rcdata_closing_tag(source, content_start, rcdata_name);\n\n\t\t\tif (!closing_tag) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tcursor = closing_tag.end;\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst raw_name = read_raw_opening_name(source, cursor);\n\n\t\tif (raw_name) {\n\t\t\tconst raw_tag = locate_raw_tag(source, cursor, raw_name);\n\n\t\t\tif (!raw_tag) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\traw_tags.push(raw_tag);\n\t\t\tcursor = raw_tag.end;\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst tag_end = find_markup_tag_end(source, cursor);\n\n\t\tif (tag_end === -1) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tcursor = tag_end;\n\t}\n\n\treturn raw_tags;\n}\n\nfunction read_rcdata_opening_name(source: string, start: number): \"textarea\" | \"title\" | undefined {\n\tfor (const name of [\"textarea\", \"title\"] as const) {\n\t\tconst name_end = start + name.length + 1;\n\t\tconst opening_name = source.slice(start, name_end).toLowerCase();\n\n\t\tif (\n\t\t\topening_name === `<${name}` &&\n\t\t\t(source[name_end] === \">\" || /\\s/.test(source[name_end] ?? \"\"))\n\t\t) {\n\t\t\treturn name;\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\nfunction find_rcdata_closing_tag(\n\tsource: string,\n\tstart: number,\n\tname: \"textarea\" | \"title\",\n): SourceRange | undefined {\n\tlet cursor = start;\n\n\twhile (cursor < source.length) {\n\t\tif (source[cursor] === \"{\") {\n\t\t\tconst close = find_closing_brace(source, cursor);\n\n\t\t\tif (close === -1) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tcursor = close + 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst closing_end = find_closing_tag_end_at(source, cursor, name, true);\n\n\t\tif (closing_end !== undefined) {\n\t\t\treturn { start: cursor, end: closing_end };\n\t\t}\n\n\t\tcursor += 1;\n\t}\n\n\treturn undefined;\n}\n\nfunction find_closing_tag_end_at(\n\tsource: string,\n\tstart: number,\n\tname: string,\n\tcase_insensitive: boolean,\n): number | undefined {\n\tif (source[start] !== \"<\") {\n\t\treturn undefined;\n\t}\n\n\tconst prefix = source.slice(start, start + name.length + 2);\n\tconst expected = `</${name}`;\n\tconst matches = case_insensitive ? prefix.toLowerCase() === expected : prefix === expected;\n\n\tif (!matches) {\n\t\treturn undefined;\n\t}\n\n\tlet cursor = start + expected.length;\n\n\twhile (/\\s/.test(source[cursor] ?? \"\")) {\n\t\tcursor += 1;\n\t}\n\n\treturn source[cursor] === \">\" ? cursor + 1 : undefined;\n}\n\nfunction find_markup_tag_end(source: string, start: number): number {\n\tlet cursor = start + 1;\n\tlet quote: string | undefined;\n\n\twhile (cursor < source.length) {\n\t\tconst char = source[cursor];\n\n\t\tif (quote) {\n\t\t\tif (char === quote) {\n\t\t\t\tquote = undefined;\n\t\t\t}\n\n\t\t\tcursor += 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === '\"' || char === \"'\") {\n\t\t\tquote = char;\n\t\t\tcursor += 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \"{\") {\n\t\t\tconst close = find_closing_brace(source, cursor);\n\n\t\t\tif (close === -1) {\n\t\t\t\treturn -1;\n\t\t\t}\n\n\t\t\tcursor = close + 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (source.startsWith(\"/*\", cursor)) {\n\t\t\tconst close = skip_block_comment(source, cursor);\n\n\t\t\tif (close === -1) {\n\t\t\t\treturn -1;\n\t\t\t}\n\n\t\t\tcursor = close + 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (source.startsWith(\"//\", cursor)) {\n\t\t\tcursor = skip_line_comment(source, cursor) + 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \">\") {\n\t\t\treturn cursor + 1;\n\t\t}\n\n\t\tif (char === \"<\") {\n\t\t\treturn -1;\n\t\t}\n\n\t\tcursor += 1;\n\t}\n\n\treturn -1;\n}\n\nfunction collect_source_regions(source: string, ast: AST.Root): SourceRegions {\n\tconst scripts = [ast.module, ast.instance]\n\t\t.filter((script): script is AST.Script => script != null)\n\t\t.map((script) => make_ast_script_region(source, script))\n\t\t.sort((left, right) => left.start - right.start);\n\tconst styles = ast.css ? [{ start: ast.css.start, end: ast.css.end }] : [];\n\tconst comments: SourceRange[] = [];\n\tconst opaque_ranges: SourceRange[] = [\n\t\t...scripts.map(({ start, end }) => ({ start, end })),\n\t\t...styles,\n\t\t...(ast.comments ?? []).map(({ start, end }) => ({ start, end })),\n\t];\n\tconst attribute_names = new Map<number, string>();\n\tconst markup_binding_names = new Set<string>();\n\n\tcollect_fragment_regions(\n\t\tsource,\n\t\tast.fragment,\n\t\tcomments,\n\t\topaque_ranges,\n\t\tattribute_names,\n\t\tmarkup_binding_names,\n\t);\n\n\treturn {\n\t\tscripts,\n\t\tstyles,\n\t\tcomments,\n\t\topaque_ranges,\n\t\tattribute_names,\n\t\tmarkup_binding_names,\n\t};\n}\n\nfunction collect_fragment_regions(\n\tsource: string,\n\tfragment: AST.Fragment,\n\tcomments: SourceRange[],\n\topaque_ranges: SourceRange[],\n\tattribute_names: Map<number, string>,\n\tmarkup_binding_names: Set<string>,\n): void {\n\tfor (const node of fragment.nodes) {\n\t\tif (node.type === \"Comment\") {\n\t\t\tcomments.push({ start: node.start, end: node.end });\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (node.type === \"RegularElement\" && (node.name === \"script\" || node.name === \"style\")) {\n\t\t\topaque_ranges.push({ start: node.start, end: node.end });\n\t\t\tcontinue;\n\t\t}\n\n\t\tcollect_node_markup_binding_names(node, markup_binding_names);\n\t\tcollect_node_attribute_names(source, node, attribute_names, markup_binding_names);\n\t\tcollect_node_fragments(\n\t\t\tsource,\n\t\t\tnode,\n\t\t\tcomments,\n\t\t\topaque_ranges,\n\t\t\tattribute_names,\n\t\t\tmarkup_binding_names,\n\t\t);\n\t}\n}\n\nfunction collect_node_markup_binding_names(\n\tnode: AST.Fragment[\"nodes\"][number],\n\tmarkup_binding_names: Set<string>,\n): void {\n\tswitch (node.type) {\n\t\tcase \"EachBlock\":\n\t\t\tif (node.context) {\n\t\t\t\tcollect_markup_binding_pattern_names(node.context, markup_binding_names);\n\t\t\t}\n\n\t\t\tif (node.index) {\n\t\t\t\tmarkup_binding_names.add(node.index);\n\t\t\t}\n\n\t\t\treturn;\n\n\t\tcase \"AwaitBlock\":\n\t\t\tfor (const pattern of [node.value, node.error]) {\n\t\t\t\tif (pattern) {\n\t\t\t\t\tcollect_markup_binding_pattern_names(pattern, markup_binding_names);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn;\n\n\t\tcase \"SnippetBlock\":\n\t\t\tmarkup_binding_names.add(node.expression.name);\n\n\t\t\tfor (const parameter of node.parameters) {\n\t\t\t\tcollect_markup_binding_pattern_names(parameter, markup_binding_names);\n\t\t\t}\n\n\t\t\treturn;\n\n\t\tcase \"ConstTag\":\n\t\tcase \"DeclarationTag\":\n\t\t\tfor (const declaration of node.declaration.declarations) {\n\t\t\t\tcollect_markup_binding_pattern_names(declaration.id, markup_binding_names);\n\t\t\t}\n\n\t\t\treturn;\n\n\t\tdefault:\n\t\t\treturn;\n\t}\n}\n\nfunction collect_markup_binding_pattern_names(\n\tpattern: MarkupBindingPattern,\n\tmarkup_binding_names: Set<string>,\n): void {\n\tswitch (pattern.type) {\n\t\tcase \"Identifier\":\n\t\t\tmarkup_binding_names.add(pattern.name);\n\t\t\treturn;\n\n\t\tcase \"ArrayPattern\":\n\t\t\tfor (const element of pattern.elements) {\n\t\t\t\tif (element) {\n\t\t\t\t\tcollect_markup_binding_pattern_names(element, markup_binding_names);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn;\n\n\t\tcase \"ObjectPattern\":\n\t\t\tfor (const property of pattern.properties) {\n\t\t\t\tconst value = property.type === \"RestElement\" ? property.argument : property.value;\n\n\t\t\t\tcollect_markup_binding_pattern_names(value, markup_binding_names);\n\t\t\t}\n\n\t\t\treturn;\n\n\t\tcase \"RestElement\":\n\t\t\tcollect_markup_binding_pattern_names(pattern.argument, markup_binding_names);\n\t\t\treturn;\n\n\t\tcase \"AssignmentPattern\":\n\t\t\tcollect_markup_binding_pattern_names(pattern.left, markup_binding_names);\n\t\t\treturn;\n\n\t\tcase \"MemberExpression\":\n\t\t\treturn;\n\t}\n}\n\nfunction collect_node_fragments(\n\tsource: string,\n\tnode: AST.Fragment[\"nodes\"][number],\n\tcomments: SourceRange[],\n\topaque_ranges: SourceRange[],\n\tattribute_names: Map<number, string>,\n\tmarkup_binding_names: Set<string>,\n): void {\n\tif (\"fragment\" in node) {\n\t\tcollect_fragment_regions(\n\t\t\tsource,\n\t\t\tnode.fragment,\n\t\t\tcomments,\n\t\t\topaque_ranges,\n\t\t\tattribute_names,\n\t\t\tmarkup_binding_names,\n\t\t);\n\t}\n\n\tswitch (node.type) {\n\t\tcase \"IfBlock\":\n\t\t\tcollect_fragment_regions(\n\t\t\t\tsource,\n\t\t\t\tnode.consequent,\n\t\t\t\tcomments,\n\t\t\t\topaque_ranges,\n\t\t\t\tattribute_names,\n\t\t\t\tmarkup_binding_names,\n\t\t\t);\n\n\t\t\tif (node.alternate) {\n\t\t\t\tcollect_fragment_regions(\n\t\t\t\t\tsource,\n\t\t\t\t\tnode.alternate,\n\t\t\t\t\tcomments,\n\t\t\t\t\topaque_ranges,\n\t\t\t\t\tattribute_names,\n\t\t\t\t\tmarkup_binding_names,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn;\n\n\t\tcase \"EachBlock\":\n\t\t\tcollect_fragment_regions(\n\t\t\t\tsource,\n\t\t\t\tnode.body,\n\t\t\t\tcomments,\n\t\t\t\topaque_ranges,\n\t\t\t\tattribute_names,\n\t\t\t\tmarkup_binding_names,\n\t\t\t);\n\n\t\t\tif (node.fallback) {\n\t\t\t\tcollect_fragment_regions(\n\t\t\t\t\tsource,\n\t\t\t\t\tnode.fallback,\n\t\t\t\t\tcomments,\n\t\t\t\t\topaque_ranges,\n\t\t\t\t\tattribute_names,\n\t\t\t\t\tmarkup_binding_names,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn;\n\n\t\tcase \"AwaitBlock\":\n\t\t\tfor (const branch of [node.pending, node.then, node.catch]) {\n\t\t\t\tif (branch) {\n\t\t\t\t\tcollect_fragment_regions(\n\t\t\t\t\t\tsource,\n\t\t\t\t\t\tbranch,\n\t\t\t\t\t\tcomments,\n\t\t\t\t\t\topaque_ranges,\n\t\t\t\t\t\tattribute_names,\n\t\t\t\t\t\tmarkup_binding_names,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn;\n\n\t\tcase \"SnippetBlock\":\n\t\t\tcollect_fragment_regions(\n\t\t\t\tsource,\n\t\t\t\tnode.body,\n\t\t\t\tcomments,\n\t\t\t\topaque_ranges,\n\t\t\t\tattribute_names,\n\t\t\t\tmarkup_binding_names,\n\t\t\t);\n\t\t\treturn;\n\n\t\tdefault:\n\t\t\treturn;\n\t}\n}\n\nfunction collect_node_attribute_names(\n\tsource: string,\n\tnode: AST.Fragment[\"nodes\"][number],\n\tattribute_names: Map<number, string>,\n\tmarkup_binding_names: Set<string>,\n): void {\n\tif (!(\"attributes\" in node)) {\n\t\treturn;\n\t}\n\n\tfor (const attribute of node.attributes) {\n\t\tif (attribute.type === \"LetDirective\" && attribute.expression === null) {\n\t\t\tmarkup_binding_names.add(attribute.name);\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (attribute.type === \"Attribute\") {\n\t\t\tcollect_attribute_value_names(attribute.value, attribute.name, attribute_names);\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (attribute.type === \"StyleDirective\") {\n\t\t\tconst source_name = read_source_attribute_name(source, attribute.start, attribute.end);\n\n\t\t\tif (source_name) {\n\t\t\t\tcollect_attribute_value_names(attribute.value, source_name, attribute_names);\n\t\t\t}\n\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (!(\"expression\" in attribute) || !attribute.expression) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst open = source.indexOf(\"{\", attribute.start);\n\n\t\tif (open < attribute.start || open >= attribute.end) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst source_name = read_source_attribute_name(source, attribute.start, attribute.end);\n\n\t\tif (source_name && source.slice(attribute.start, open).includes(\"=\")) {\n\t\t\tattribute_names.set(open, source_name);\n\t\t}\n\t}\n}\n\nfunction collect_attribute_value_names(\n\tvalue: AST.Attribute[\"value\"],\n\tattribute_name: string,\n\tattribute_names: Map<number, string>,\n): void {\n\tif (value === true) {\n\t\treturn;\n\t}\n\n\tconst parts = Array.isArray(value) ? value : [value];\n\tconst expression = parts.length === 1 ? parts[0] : undefined;\n\n\tif (expression?.type !== \"ExpressionTag\") {\n\t\treturn;\n\t}\n\n\tattribute_names.set(expression.start, attribute_name);\n}\n\nfunction read_source_attribute_name(\n\tsource: string,\n\tstart: number,\n\tend: number,\n): string | undefined {\n\treturn source.slice(start, end).match(/^[^\\s=]+/)?.[0];\n}\n\nfunction make_ast_script_region(source: string, script: AST.Script): ScriptRegion {\n\tconst tag_name_end = script.start + \"<script\".length;\n\tconst attributes = collect_ast_script_attributes(source, script, tag_name_end);\n\tconst content_start = get_program_offset(script.content, \"start\");\n\tconst content_end = get_program_offset(script.content, \"end\");\n\tconst lang = get_attribute(attributes, \"lang\")?.value?.toLowerCase();\n\tconst effect_attribute = get_attribute(attributes, \"effect\");\n\n\treturn {\n\t\tstart: script.start,\n\t\tend: script.end,\n\t\topening_tag_start: script.start,\n\t\topening_tag_end: content_start,\n\t\ttag_name_end,\n\t\tcontent_start,\n\t\tcontent_end,\n\t\tclosing_tag_start: content_end,\n\t\tclosing_tag_end: script.end,\n\t\tattributes_text: source.slice(tag_name_end, content_start - 1),\n\t\tattributes,\n\t\ttext: source.slice(content_start, content_end),\n\t\tis_module: script.context === \"module\",\n\t\thas_lang: get_attribute(attributes, \"lang\") !== undefined,\n\t\tlang,\n\t\tis_typescript: lang === \"ts\" || lang === \"typescript\",\n\t\thas_effect: effect_attribute !== undefined,\n\t\teffect_attribute: effect_attribute\n\t\t\t? { start: effect_attribute.start, end: effect_attribute.end }\n\t\t\t: undefined,\n\t};\n}\n\nfunction get_program_offset(program: AST.Script[\"content\"], key: \"start\" | \"end\"): number {\n\tif (key === \"start\" && \"start\" in program && typeof program.start === \"number\") {\n\t\treturn program.start;\n\t}\n\n\tif (key === \"end\" && \"end\" in program && typeof program.end === \"number\") {\n\t\treturn program.end;\n\t}\n\n\tthrow new Error(`Svelte script content has no ${key} offset`);\n}\n\nfunction collect_ast_script_attributes(\n\tsource: string,\n\tscript: AST.Script,\n\ttag_name_end: number,\n): SourceAttribute[] {\n\tlet previous_end = tag_name_end;\n\n\treturn script.attributes.map((attribute) => {\n\t\tconst name_start = attribute.start;\n\t\tconst source_name = read_source_attribute_name(source, attribute.start, attribute.end);\n\t\tconst name_end = name_start + (source_name?.length ?? attribute.name.length);\n\t\tlet start = attribute.start;\n\n\t\twhile (start > previous_end && /\\s/.test(source[start - 1] ?? \"\")) {\n\t\t\tstart -= 1;\n\t\t}\n\n\t\tprevious_end = attribute.end;\n\n\t\treturn {\n\t\t\tname: source_name ?? attribute.name,\n\t\t\tstart,\n\t\t\tend: attribute.end,\n\t\t\tname_start,\n\t\t\tname_end,\n\t\t\tvalue: get_static_attribute_value(attribute.value),\n\t\t};\n\t});\n}\n\nfunction get_static_attribute_value(value: AST.Attribute[\"value\"]): string | undefined {\n\tif (value === true) {\n\t\treturn undefined;\n\t}\n\n\tconst parts = Array.isArray(value) ? value : [value];\n\n\tif (!parts.every((part): part is AST.Text => part.type === \"Text\")) {\n\t\treturn undefined;\n\t}\n\n\treturn parts.map((part) => part.data).join(\"\");\n}\n\nfunction collect_scanned_markup_expressions(\n\tsource: string,\n\texcluded_ranges: readonly SourceRange[],\n\tattribute_names: ReadonlyMap<number, string>,\n): MarkupBraceExpression[] {\n\tconst expressions: MarkupBraceExpression[] = [];\n\tlet cursor = 0;\n\n\twhile (cursor < source.length) {\n\t\tconst open = source.indexOf(\"{\", cursor);\n\n\t\tif (open === -1) {\n\t\t\tbreak;\n\t\t}\n\n\t\tconst excluded_range = find_range_containing(excluded_ranges, open);\n\n\t\tif (excluded_range) {\n\t\t\tcursor = excluded_range.end;\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst close = find_closing_brace(source, open);\n\n\t\tif (close === -1) {\n\t\t\tcursor = open + 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst inner_start = open + 1;\n\t\tconst inner_end = close;\n\t\tconst inner = source.slice(inner_start, inner_end);\n\n\t\texpressions.push({\n\t\t\topen,\n\t\t\tclose,\n\t\t\tinner_start,\n\t\t\tinner_end,\n\t\t\tinner,\n\t\t\texpression_text: inner.trim(),\n\t\t\tattribute_name: attribute_names.get(open),\n\t\t});\n\n\t\tcursor = close + 1;\n\t}\n\n\treturn expressions;\n}\n\nfunction find_range_containing(\n\tranges: readonly SourceRange[],\n\tposition: number,\n): SourceRange | undefined {\n\tlet low = 0;\n\tlet high = ranges.length - 1;\n\n\twhile (low <= high) {\n\t\tconst mid = Math.floor((low + high) / 2);\n\t\tconst range = ranges[mid];\n\n\t\tif (position < range.start) {\n\t\t\thigh = mid - 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (position >= range.end) {\n\t\t\tlow = mid + 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\treturn range;\n\t}\n\n\treturn undefined;\n}\n\nfunction make_bare_const_tag(\n\texpression: MarkupBraceExpression,\n): readonly BareConstDeclarationTag[] {\n\tif (!/^(\\s*)const\\s/.test(expression.inner)) {\n\t\treturn [];\n\t}\n\n\treturn [\n\t\t{\n\t\t\topen: expression.open,\n\t\t\tinsert_position: expression.open + 1,\n\t\t\texpression,\n\t\t},\n\t];\n}\n\nfunction merge_ranges(ranges: SourceRange[]): SourceRange[] {\n\tconst sorted = [...ranges].sort((a, b) => a.start - b.start);\n\tconst merged: SourceRange[] = [];\n\n\tfor (const range of sorted) {\n\t\tconst previous = merged.at(-1);\n\n\t\tif (!previous || range.start > previous.end) {\n\t\t\tmerged.push({ ...range });\n\t\t\tcontinue;\n\t\t}\n\n\t\tprevious.end = Math.max(previous.end, range.end);\n\t}\n\n\treturn merged;\n}\n\nfunction get_attribute(\n\tattributes: readonly SourceAttribute[],\n\tname: string,\n): SourceAttribute | undefined {\n\tconst normalized_name = name.toLowerCase();\n\n\treturn attributes.find((attribute) => attribute.name.toLowerCase() === normalized_name);\n}\n\nfunction find_closing_brace(source: string, open: number): number {\n\tconst closing_directive = source\n\t\t.slice(open + 1)\n\t\t.match(/^\\s*\\/(?:if|each|await|key|snippet)\\s*}/);\n\n\tif (closing_directive) {\n\t\treturn open + 1 + closing_directive[0].lastIndexOf(\"}\");\n\t}\n\n\tlet depth = 1;\n\tlet cursor = open + 1;\n\n\twhile (cursor < source.length) {\n\t\tconst char = source[cursor];\n\n\t\tif (char === \"'\" || char === '\"') {\n\t\t\tconst close = skip_quoted_string(source, cursor, char);\n\n\t\t\tif (close === -1) {\n\t\t\t\treturn -1;\n\t\t\t}\n\n\t\t\tcursor = close + 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \"`\") {\n\t\t\tconst close = skip_template_literal(source, cursor);\n\n\t\t\tif (close === -1) {\n\t\t\t\treturn -1;\n\t\t\t}\n\n\t\t\tcursor = close + 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \"/\" && source[cursor + 1] === \"/\") {\n\t\t\tcursor = skip_line_comment(source, cursor) + 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \"/\" && source[cursor + 1] === \"*\") {\n\t\t\tconst close = skip_block_comment(source, cursor);\n\n\t\t\tif (close === -1) {\n\t\t\t\treturn -1;\n\t\t\t}\n\n\t\t\tcursor = close + 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \"/\") {\n\t\t\treturn find_closing_brace_with_typescript(source, open, cursor);\n\t\t}\n\n\t\tif (char === \"{\") {\n\t\t\tdepth += 1;\n\t\t} else if (char === \"}\") {\n\t\t\tdepth -= 1;\n\n\t\t\tif (depth === 0) {\n\t\t\t\treturn cursor;\n\t\t\t}\n\t\t}\n\n\t\tcursor += 1;\n\t}\n\n\treturn -1;\n}\n\nfunction find_closing_brace_with_typescript(source: string, open: number, slash: number): number {\n\tlet candidate = source.indexOf(\"}\", slash + 1);\n\tlet candidate_index = 0;\n\tlet next_probe_index = 0;\n\tlet last_candidate = -1;\n\tlet last_probed_candidate = -1;\n\n\twhile (candidate !== -1) {\n\t\tlast_candidate = candidate;\n\n\t\tif (candidate_index === next_probe_index) {\n\t\t\tconst resolved = resolve_closing_brace_probe(source, open, slash, candidate);\n\n\t\t\tif (resolved !== -1) {\n\t\t\t\treturn resolved;\n\t\t\t}\n\n\t\t\tlast_probed_candidate = candidate;\n\t\t\tnext_probe_index = next_probe_index * 2 + 1;\n\t\t}\n\n\t\tcandidate_index += 1;\n\t\tcandidate = source.indexOf(\"}\", candidate + 1);\n\t}\n\n\tif (last_candidate !== last_probed_candidate) {\n\t\treturn resolve_closing_brace_probe(source, open, slash, last_candidate);\n\t}\n\n\treturn -1;\n}\n\nfunction resolve_closing_brace_probe(\n\tsource: string,\n\topen: number,\n\tslash: number,\n\tcandidate: number,\n): number {\n\tif (candidate === -1) {\n\t\treturn -1;\n\t}\n\n\tconst probe = parse_closing_brace_probe(source, open, candidate);\n\n\tif (probe.is_exact) {\n\t\treturn candidate;\n\t}\n\n\tif (probe.close < slash || probe.close >= candidate || source[probe.close] !== \"}\") {\n\t\treturn -1;\n\t}\n\n\tconst exact_probe = parse_closing_brace_probe(source, open, probe.close);\n\n\treturn exact_probe.is_exact ? probe.close : -1;\n}\n\nfunction parse_closing_brace_probe(\n\tsource: string,\n\topen: number,\n\tcandidate: number,\n): { close: number; is_exact: boolean } {\n\tconst generator_prefix = \"function* __SER__(){\";\n\tconst boundary_name = \"__SER___expression_boundary\";\n\tconst boundary_statement = `\\nconst ${boundary_name} = 0;`;\n\tconst tail = adapt_svelte_directive_tail(source.slice(open + 1, candidate + 1));\n\tconst source_file = ts.createSourceFile(\n\t\t\"svelte-expression.ts\",\n\t\tgenerator_prefix + tail + boundary_statement,\n\t\tts.ScriptTarget.Latest,\n\t\ttrue,\n\t\tts.ScriptKind.TS,\n\t) as ParsedSourceFile;\n\tconst declaration = source_file.statements[0];\n\tconst boundary = source_file.statements[1];\n\tconst boundary_declaration =\n\t\tboundary && ts.isVariableStatement(boundary)\n\t\t\t? boundary.declarationList.declarations[0]\n\t\t\t: undefined;\n\tconst has_boundary =\n\t\tboundary_declaration?.name !== undefined &&\n\t\tts.isIdentifier(boundary_declaration.name) &&\n\t\tboundary_declaration.name.text === boundary_name;\n\tconst has_unterminated_regex = source_file.parseDiagnostics?.some(\n\t\t(diagnostic) => diagnostic.code === 1161,\n\t);\n\n\tif (!declaration || !ts.isFunctionDeclaration(declaration) || !declaration.body) {\n\t\treturn { close: -1, is_exact: false };\n\t}\n\n\tconst close = open + declaration.body.end - generator_prefix.length;\n\n\treturn {\n\t\tclose,\n\t\tis_exact: close === candidate && has_boundary && !has_unterminated_regex,\n\t};\n}\n\nfunction adapt_svelte_directive_tail(tail: string): string {\n\tconst const_directive = tail.match(/^(\\s*)@(?=const\\b)/);\n\n\tif (const_directive) {\n\t\tconst at = const_directive[1].length;\n\n\t\treturn tail.slice(0, at) + \" \" + tail.slice(at + 1);\n\t}\n\n\tconst prefix = tail.match(\n\t\t/^\\s*(?:(?:#(?:if|each|await|key|snippet)|@(?:render|html|debug|attach)|:(?:else\\s+if|else|then|catch))\\b\\s*|\\.\\.\\.\\s*)/,\n\t)?.[0];\n\n\tif (!prefix) {\n\t\treturn tail;\n\t}\n\n\treturn blank_source(prefix) + tail.slice(prefix.length);\n}\n\nfunction skip_quoted_string(source: string, start: number, quote: string): number {\n\tfor (let cursor = start + 1; cursor < source.length; cursor += 1) {\n\t\tif (source[cursor] === \"\\\\\") {\n\t\t\tcursor += 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (source[cursor] === quote) {\n\t\t\treturn cursor;\n\t\t}\n\t}\n\n\treturn -1;\n}\n\nfunction skip_template_literal(source: string, start: number): number {\n\tlet cursor = start + 1;\n\n\twhile (cursor < source.length) {\n\t\tif (source[cursor] === \"\\\\\") {\n\t\t\tcursor += 2;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (source[cursor] === \"`\") {\n\t\t\treturn cursor;\n\t\t}\n\n\t\tif (source[cursor] === \"$\" && source[cursor + 1] === \"{\") {\n\t\t\tconst close = find_closing_brace(source, cursor + 1);\n\n\t\t\tif (close === -1) {\n\t\t\t\treturn -1;\n\t\t\t}\n\n\t\t\tcursor = close + 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tcursor += 1;\n\t}\n\n\treturn -1;\n}\n\nfunction skip_line_comment(source: string, start: number): number {\n\tfor (let cursor = start + 2; cursor < source.length; cursor += 1) {\n\t\tconst char = source[cursor];\n\n\t\tif (char === \"\\n\" || char === \"\\r\" || char === \"\\u2028\" || char === \"\\u2029\") {\n\t\t\treturn cursor;\n\t\t}\n\t}\n\n\treturn source.length;\n}\n\nfunction skip_block_comment(source: string, start: number): number {\n\tconst close = source.indexOf(\"*/\", start + 2);\n\n\treturn close === -1 ? -1 : close + 1;\n}\n"],"mappings":";;;AAsIA,IAAI;AAEJ,SAAS,oBAAoB,QAAsC;CAClE,IAAI,eAAe;CAEnB,MAAM,gBADc,OAAO,MAAM,eAAe,CAAC,EAAE,UAAU,KAC1B;CAEnC,KAAK,IAAI,UAAU,GAAG,UAAU,cAAc,WAAW,GACxD,IAAI;EACH,OAAO,MAAM,cAAc;GAAE,QAAQ;GAAM,OAAO;EAAK,CAAC;CACzD,SAAS,OAAO;EACf,MAAM,aAAa,uBAAuB,cAAc,KAAK;EAE7D,IAAI,CAAC,cAAc,eAAe,cACjC;EAGD,eAAe;CAChB;AAIF;AAEA,SAAS,uBAAuB,QAAgB,OAAoC;CACnF,IAAI,CAAC,qBAAqB,KAAK,KAAK,CAAC,mBAAmB,MAAM,QAAQ,GACrE;CAGD,MAAM,CAAC,OAAO,OAAO,MAAM;CAE3B,IAAI,MAAM,SAAS,kBAAkB;EACpC,MAAM,QAAQ,OAAO,MAAM,KAAK,CAAC,CAAC,MAAM,aAAa;EAErD,IAAI,CAAC,OACJ;EAGD,OAAO,cAAc,QAAQ,OAAO,QAAQ,MAAM,EAAE,CAAC,QAAQ,aAAa,MAAM,EAAE,CAAC;CACpF;CAEA,IAAI,MAAM,SAAS,iCAClB;CAMD,IAHmB,OAAO,MAAM,OAAO,GACV,CAAC,CAAC,OAAO,cAExB,MAAM,IACnB;CAGD,OAAO,mCAAmC,MAAM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B,OAAuB;CAClE,MAAM,QAAQ,OAAO,QAAQ,MAAM,QAAQ,CAAC;CAE5C,OAAO,UAAU,KAAK,KAAK,QAAQ;AACpC"}
@@ -1,16 +1,19 @@
1
- import { j as YieldStarInEventCallbackError, k as UnsupportedMarkupEffectPositionError, n as AsyncEffectInSyncRuneError, t as AsyncEffectInEventCallbackError } from "./errors-CLsbGjIa.js";
2
- import { t as scan_svelte_effect_source } from "./source-scan-9pZxnfct.js";
1
+ import { A as UnsupportedMarkupEffectPositionError, M as YieldStarInEventCallbackError, n as AsyncEffectInSyncRuneError, t as AsyncEffectInEventCallbackError } from "./errors-qhcbUH6o.js";
2
+ import { t as scan_svelte_effect_source } from "./source-scan-cSawCvsg.js";
3
3
  import { contains_top_level_yield_star } from "../detect.js";
4
4
  import ts from "typescript";
5
5
  import { parse } from "svelte/compiler";
6
6
  import MagicString from "magic-string";
7
7
  //#region src/script-transform/imports.ts
8
- function make_imports(has_effect_import, has_dispatcher_import, has_untrack_import, bindings = {
8
+ function make_imports(has_effect_import, has_dispatcher_import, has_untrack_import, has_on_destroy_import, bindings = {
9
9
  cancel: "__SER___cancel",
10
+ component_scope_ref: "ComponentScopeRef",
10
11
  dispatcher: "get_dispatcher",
11
12
  dispatcher_value: "__SER___dispatcher",
12
13
  effect: "Effect",
14
+ on_destroy: "onDestroy",
13
15
  program: "__SER___program",
16
+ scope: "__SER___scope",
14
17
  untrack: "untrack",
15
18
  yield_success: "YieldSuccess",
16
19
  yieldable: "ToEffect"
@@ -18,22 +21,27 @@ function make_imports(has_effect_import, has_dispatcher_import, has_untrack_impo
18
21
  const needs_dispatcher = options.needs_dispatcher ?? true;
19
22
  const needs_effect = options.needs_effect ?? true;
20
23
  const needs_untrack = options.needs_untrack ?? true;
24
+ const needs_on_destroy = options.needs_on_destroy ?? false;
21
25
  const needs_yield_success = options.needs_yield_success ?? false;
22
26
  const needs_yieldable = options.needs_yieldable ?? false;
23
- const generator_import = make_generator_import(bindings, needs_dispatcher && !has_dispatcher_import, needs_yieldable, needs_yield_success);
27
+ const needs_scope_ref = options.needs_scope_ref ?? true;
28
+ const generator_import = make_generator_import(bindings, needs_dispatcher && !has_dispatcher_import, needs_yieldable, needs_yield_success, needs_scope_ref);
24
29
  const untrack_import = bindings.untrack === "untrack" ? `import { untrack } from "svelte";` : `import { untrack as ${bindings.untrack} } from "svelte";`;
30
+ const on_destroy_import = bindings.on_destroy === "onDestroy" ? `import { onDestroy } from "svelte";` : `import { onDestroy as ${bindings.on_destroy} } from "svelte";`;
25
31
  const effect_import = has_effect_import ? false : bindings.effect === "Effect" ? `import { Effect } from "effect";` : `import { Effect as ${bindings.effect} } from "effect";`;
26
32
  return [
27
33
  generator_import,
28
34
  needs_untrack && !has_untrack_import && untrack_import,
35
+ needs_on_destroy && !has_on_destroy_import && on_destroy_import,
29
36
  needs_effect && effect_import
30
37
  ].filter(Boolean).join("\n");
31
38
  }
32
- function make_generator_import(bindings, needs_dispatcher, needs_yieldable, needs_yield_success) {
39
+ function make_generator_import(bindings, needs_dispatcher, needs_yieldable, needs_yield_success, needs_scope_ref) {
33
40
  const specifiers = [
34
41
  needs_dispatcher && make_named_import("get_dispatcher", bindings.dispatcher),
35
42
  needs_yieldable && make_named_import("ToEffect", bindings.yieldable),
36
- needs_yield_success && make_named_import("YieldSuccess", bindings.yield_success, true)
43
+ needs_yield_success && make_named_import("YieldSuccess", bindings.yield_success, true),
44
+ needs_scope_ref && make_named_import("ComponentScopeRef", bindings.component_scope_ref)
37
45
  ].filter((specifier) => specifier !== false);
38
46
  if (specifiers.length === 0) return false;
39
47
  return `import { ${specifiers.join(", ")} } from "svelte-effect-runtime/internal/generators";`;
@@ -121,7 +129,8 @@ function is_within_type_node(identifier) {
121
129
  const default_helper_bindings = {
122
130
  codes: "Code",
123
131
  dispatcher: "Dispatcher",
124
- yieldable: "ToEffect"
132
+ yieldable: "ToEffect",
133
+ scope: "__SER___scope"
125
134
  };
126
135
  //#endregion
127
136
  //#region src/markup/transform/apply.ts
@@ -132,46 +141,67 @@ function create_source_map$1(magic, filename) {
132
141
  source: filename
133
142
  });
134
143
  }
135
- function inject_helpers(magic, source_scan, helpers = [], bindings = default_helper_bindings) {
144
+ function inject_helpers(magic, source_scan, helpers = [], bindings = default_helper_bindings, scope_wiring) {
136
145
  const import_helpers = unique_import_helpers(helpers);
137
146
  const local_helpers = helpers.filter((helper) => !is_import_helper(helper));
138
147
  const helper_segments = [
139
- make_dispatcher_import(bindings),
148
+ make_dispatcher_import(bindings, scope_wiring),
140
149
  ...import_helpers,
141
150
  ...local_helpers
142
151
  ].filter((helper) => helper !== void 0).map((helper) => typeof helper === "string" ? { text: helper } : helper);
143
152
  if (helper_segments.length === 0) return;
144
153
  const helper_block = helper_segments.map((segment) => segment.text).join("\n");
154
+ const scope_block = scope_wiring ? make_scope_wiring_block(bindings, scope_wiring) : void 0;
145
155
  const instance_script = source_scan.instance_script;
146
156
  if (instance_script) {
157
+ /**
158
+ * The scope holder must be declared before any user statement so its
159
+ * `onDestroy` runs during component initialisation, ahead of any
160
+ * top-level `await`.
161
+ */
162
+ const scope_text = scope_block ? `\n${scope_block}\n` : void 0;
163
+ if (scope_text) magic.appendLeft(instance_script.content_start, scope_text);
147
164
  const text = `\n${helper_block}\n`;
148
165
  magic.appendLeft(instance_script.content_end, text);
149
166
  return {
150
167
  start: instance_script.content_end,
151
168
  text,
169
+ extra_insertions: scope_text ? [{
170
+ start: instance_script.content_start,
171
+ text: scope_text
172
+ }] : [],
152
173
  relocations: make_insertion_relocations(helper_segments, "\n")
153
174
  };
154
175
  } else {
155
- const text = `<script>\n${helper_block}\n<\/script>\n\n`;
176
+ const text = `<script>\n${[scope_block, helper_block].filter(Boolean).join("\n")}\n<\/script>\n\n`;
177
+ const helper_prefix = `<script>\n${scope_block ? scope_block + "\n" : ""}`;
156
178
  magic.prepend(text);
157
179
  return {
158
180
  start: 0,
159
181
  text,
160
- relocations: make_insertion_relocations(helper_segments, "<script>\n")
182
+ relocations: make_insertion_relocations(helper_segments, helper_prefix)
161
183
  };
162
184
  }
163
185
  }
164
- function make_markup_helper_bindings(source_scan) {
186
+ function make_markup_helper_bindings(source_scan, target = "client") {
165
187
  const script_binding_names = source_scan.scripts.flatMap((script) => collect_script_binding_names(script.text));
166
188
  const markup_identifier_names = collect_markup_identifier_names(source_scan);
167
189
  const name_allocator = make_name_allocator([...script_binding_names, ...markup_identifier_names]);
190
+ const bindings = {
191
+ codes: name_allocator.reserve(default_helper_bindings.codes),
192
+ dispatcher: name_allocator.reserve(default_helper_bindings.dispatcher),
193
+ yieldable: name_allocator.reserve(default_helper_bindings.yieldable),
194
+ scope: default_helper_bindings.scope
195
+ };
196
+ const is_server_target = target === "server";
168
197
  return {
169
- bindings: {
170
- codes: name_allocator.reserve(default_helper_bindings.codes),
171
- dispatcher: name_allocator.reserve(default_helper_bindings.dispatcher),
172
- yieldable: name_allocator.reserve(default_helper_bindings.yieldable)
173
- },
174
- name_allocator
198
+ bindings,
199
+ name_allocator,
200
+ scope_wiring: script_binding_names.includes(default_helper_bindings.scope) ? void 0 : {
201
+ component_scope_ref: name_allocator.reserve("ComponentScopeRef"),
202
+ get_dispatcher: name_allocator.reserve("get_dispatcher"),
203
+ ...is_server_target ? {} : { on_destroy: name_allocator.reserve("onDestroy") }
204
+ }
175
205
  };
176
206
  }
177
207
  function create_relocations(replacements, helper_insertion) {
@@ -196,9 +226,13 @@ function create_relocations(replacements, helper_insertion) {
196
226
  accumulated_delta += group_delta;
197
227
  cursor = group_end;
198
228
  }
229
+ const insertion_shift_before = (point) => {
230
+ if (!helper_insertion) return 0;
231
+ return (helper_insertion.start <= point ? helper_insertion.text.length : 0) + (helper_insertion.extra_insertions ?? []).filter((insertion) => insertion.start <= point).reduce((shift, insertion) => shift + insertion.text.length, 0);
232
+ };
199
233
  const replacement_relocations = replacements.flatMap((replacement) => {
200
234
  if (!replacement.relocation) return [];
201
- const delta_before = (replacement_deltas.get(replacement) ?? 0) + (helper_insertion && helper_insertion.start <= replacement.start ? helper_insertion.text.length : 0);
235
+ const delta_before = (replacement_deltas.get(replacement) ?? 0) + insertion_shift_before(replacement.start);
202
236
  const generated_start = replacement.start + delta_before;
203
237
  return [{
204
238
  originalStart: replacement.relocation.originalStart,
@@ -207,7 +241,7 @@ function create_relocations(replacements, helper_insertion) {
207
241
  generatedEnd: generated_start + replacement.relocation.generatedEndInReplacement
208
242
  }];
209
243
  });
210
- const helper_generated_start = (helper_insertion?.start ?? 0) + replacement_delta_before_helper;
244
+ const helper_generated_start = (helper_insertion?.start ?? 0) + replacement_delta_before_helper + (helper_insertion?.extra_insertions ?? []).filter((insertion) => helper_insertion && insertion.start <= helper_insertion.start).reduce((shift, insertion) => shift + insertion.text.length, 0);
211
245
  const helper_relocations = helper_insertion?.relocations?.map((relocation) => ({
212
246
  originalStart: relocation.originalStart,
213
247
  originalEnd: relocation.originalEnd,
@@ -216,13 +250,27 @@ function create_relocations(replacements, helper_insertion) {
216
250
  })) ?? [];
217
251
  return [...replacement_relocations, ...helper_relocations];
218
252
  }
219
- function make_dispatcher_import(bindings) {
220
- return `import { ${make_import_specifier(default_helper_bindings.dispatcher, bindings.dispatcher)}, ${make_import_specifier(default_helper_bindings.codes, bindings.codes)}, ${make_import_specifier(default_helper_bindings.yieldable, bindings.yieldable)} } from "svelte-effect-runtime/internal/generators";`;
253
+ function make_dispatcher_import(bindings, scope_wiring) {
254
+ return `import { ${[
255
+ make_import_specifier(default_helper_bindings.dispatcher, bindings.dispatcher),
256
+ make_import_specifier(default_helper_bindings.codes, bindings.codes),
257
+ make_import_specifier(default_helper_bindings.yieldable, bindings.yieldable),
258
+ ...scope_wiring ? [make_import_specifier("ComponentScopeRef", scope_wiring.component_scope_ref), make_import_specifier("get_dispatcher", scope_wiring.get_dispatcher)] : []
259
+ ].join(", ")} } from "svelte-effect-runtime/internal/generators";`;
221
260
  }
222
261
  function make_import_specifier(imported_name, local_name) {
223
262
  if (imported_name === local_name) return imported_name;
224
263
  return `${imported_name} as ${local_name}`;
225
264
  }
265
+ function make_scope_wiring_block(bindings, scope_wiring) {
266
+ const on_destroy_import = scope_wiring.on_destroy ? make_import_specifier("onDestroy", scope_wiring.on_destroy) : void 0;
267
+ const on_destroy_call = scope_wiring.on_destroy ? `${scope_wiring.on_destroy}(() => ${bindings.scope}.dispose());` : void 0;
268
+ return [
269
+ on_destroy_import ? `import { ${on_destroy_import} } from "svelte";` : void 0,
270
+ `const ${bindings.scope} = new ${scope_wiring.component_scope_ref}(${scope_wiring.get_dispatcher});`,
271
+ on_destroy_call
272
+ ].join("\n");
273
+ }
226
274
  function make_insertion_relocations(segments, prefix) {
227
275
  const relocations = [];
228
276
  let offset = prefix.length;
@@ -1019,7 +1067,7 @@ function make_event_handler(candidate, helper_bindings) {
1019
1067
  return {
1020
1068
  expr_text: wrapped_expr_text,
1021
1069
  relocation: make_yield_operand_relocation(expr_text, wrapped_expr_text, helper_bindings),
1022
- text: `(event) => { ${helper_bindings.dispatcher}.emit({ type: ${helper_bindings.codes}.Markup.Run, fn: function* () { ${wrapped_expr_text}; } }); }`
1070
+ text: `(event) => { ${helper_bindings.dispatcher}.with_scope(${helper_bindings.scope}.scope, () => ${helper_bindings.dispatcher}.emit({ type: ${helper_bindings.codes}.Markup.Run, fn: function* () { ${wrapped_expr_text}; } })); }`
1023
1071
  };
1024
1072
  }
1025
1073
  function emit_promise_expression(id_text, effect, helper_bindings, ssr_fallback, options) {
@@ -1031,7 +1079,7 @@ function emit_promise_expression(id_text, effect, helper_bindings, ssr_fallback,
1031
1079
  ssr_fallback !== void 0 && `ssr_fallback: ${ssr_fallback}`,
1032
1080
  options !== void 0 && `options: ${options}`
1033
1081
  ].filter((property) => property !== false);
1034
- return `${helper_bindings.dispatcher}.emit({ ${properties.join(", ")} })`;
1082
+ return `${helper_bindings.dispatcher}.with_scope(${helper_bindings.scope}.scope, () => ${helper_bindings.dispatcher}.emit({ ${properties.join(", ")} }))`;
1035
1083
  }
1036
1084
  function emit_render_expression(id_text, effect, candidate, helper_bindings, is_server_target) {
1037
1085
  const expression = emit_promise_expression(id_text, effect, helper_bindings, server_fallback(is_server_target, `() => undefined`));
@@ -1488,7 +1536,7 @@ function transform_markup_effect(content, filename, options = {}) {
1488
1536
  has_yield: false
1489
1537
  };
1490
1538
  const effect_context = collect_effect_callback_bindings(source_scan.scripts);
1491
- const helper_context = make_markup_helper_bindings(source_scan);
1539
+ const helper_context = make_markup_helper_bindings(source_scan, options.target ?? "client");
1492
1540
  /** Match placeholders to their AST context and build replacements. */
1493
1541
  const classified = classify_candidates(parse(work.parse_code, {
1494
1542
  filename,
@@ -1502,7 +1550,7 @@ function transform_markup_effect(content, filename, options = {}) {
1502
1550
  const magic = new MagicString(content);
1503
1551
  replacements.sort((a, b) => b.start - a.start);
1504
1552
  for (const r of replacements) magic.overwrite(r.start, r.end, r.text);
1505
- const relocations = create_relocations(replacements, inject_helpers(magic, source_scan, helpers, helper_context.bindings));
1553
+ const relocations = create_relocations(replacements, inject_helpers(magic, source_scan, helpers, helper_context.bindings, helper_context.scope_wiring));
1506
1554
  return {
1507
1555
  code: magic.toString(),
1508
1556
  has_yield: true,
@@ -1513,4 +1561,4 @@ function transform_markup_effect(content, filename, options = {}) {
1513
1561
  //#endregion
1514
1562
  export { slice_start as a, find_yield_star_node as c, collect_top_level_binding_names as d, has_local_import_binding as f, slice as i, is_yield_star_expression as l, validate_rune_yield_usage as n, collect_yield_star_nodes as o, make_imports as p, create_source_map as r, contains_top_level_await as s, transform_markup_effect as t, collect_free_identifiers as u };
1515
1563
 
1516
- //# sourceMappingURL=transform-BXyYUAez.js.map
1564
+ //# sourceMappingURL=transform-D7TTlPpK.js.map