svelte-effect-runtime 3.4.10 → 4.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 (83) hide show
  1. package/.dist/chunks/{client-CsVu54pU.js → client-DcZUV4rR.js} +76 -50
  2. package/.dist/chunks/client-DcZUV4rR.js.map +1 -0
  3. package/.dist/chunks/{vite-Dm3bXmR3.js → compiler-BBPNyXmQ.js} +84 -112
  4. package/.dist/chunks/compiler-BBPNyXmQ.js.map +1 -0
  5. package/.dist/chunks/{dispatcher-pHH4JcFR.js → dispatcher-DOx8iC6r.js} +2 -2
  6. package/.dist/chunks/{dispatcher-pHH4JcFR.js.map → dispatcher-DOx8iC6r.js.map} +1 -1
  7. package/.dist/chunks/{dispatcher-LtvFKYUp.js → dispatcher-H-Ia0Os4.js} +3 -3
  8. package/.dist/chunks/{dispatcher-LtvFKYUp.js.map → dispatcher-H-Ia0Os4.js.map} +1 -1
  9. package/.dist/chunks/{errors-Dcf0MVbq.js → errors-IJjsUwrE.js} +21 -65
  10. package/.dist/chunks/errors-IJjsUwrE.js.map +1 -0
  11. package/.dist/chunks/live-BXAKre_4.js +104 -0
  12. package/.dist/chunks/live-BXAKre_4.js.map +1 -0
  13. package/.dist/chunks/{remote-client-Bj1pZXgq.js → remote-client-CVI4t66c.js} +2 -2
  14. package/.dist/chunks/remote-client-CVI4t66c.js.map +1 -0
  15. package/.dist/chunks/{runtime-ekkMQ-wL.js → runtime-GBQz32DZ.js} +3 -3
  16. package/.dist/chunks/{runtime-ekkMQ-wL.js.map → runtime-GBQz32DZ.js.map} +1 -1
  17. package/.dist/chunks/schema-D9pct6Y5.js +89 -0
  18. package/.dist/chunks/schema-D9pct6Y5.js.map +1 -0
  19. package/.dist/chunks/server-D1LcDnZE.js +213 -0
  20. package/.dist/chunks/server-D1LcDnZE.js.map +1 -0
  21. package/.dist/chunks/source-scan-C4PsggID.js +341 -0
  22. package/.dist/chunks/source-scan-C4PsggID.js.map +1 -0
  23. package/.dist/chunks/{transform-CEK6Ccll.js → transform-jNUr65K9.js} +289 -248
  24. package/.dist/chunks/transform-jNUr65K9.js.map +1 -0
  25. package/.dist/compiler/source-scan.d.ts +198 -0
  26. package/.dist/{vite.d.ts → compiler.d.ts} +1 -1
  27. package/.dist/{vite.js → compiler.js} +1 -1
  28. package/.dist/dispatcher.js +1 -1
  29. package/.dist/errors.d.ts +15 -45
  30. package/.dist/generators.d.ts +3 -1
  31. package/.dist/internal/generators.js +20 -3
  32. package/.dist/internal/generators.js.map +1 -0
  33. package/.dist/internal/remote-client.js +1 -1
  34. package/.dist/internal/remote-server.js +1 -1
  35. package/.dist/internal/schema.d.ts +67 -0
  36. package/.dist/live.d.ts +123 -0
  37. package/.dist/markup/event-attributes.d.ts +38 -0
  38. package/.dist/markup/promise.js +1 -1
  39. package/.dist/markup/run.js +1 -1
  40. package/.dist/markup/transform/classify.d.ts +12 -4
  41. package/.dist/markup/transform/constants.d.ts +1 -0
  42. package/.dist/markup/transform/emit.d.ts +12 -4
  43. package/.dist/markup/transform/types.d.ts +1 -0
  44. package/.dist/markup/transform.js +1 -1
  45. package/.dist/markup/value.js +1 -1
  46. package/.dist/mod.d.ts +6 -3
  47. package/.dist/mod.js +5 -4
  48. package/.dist/mod.js.map +1 -1
  49. package/.dist/remote/cause-codec.d.ts +53 -0
  50. package/.dist/remote/client/form-transport.d.ts +4 -1
  51. package/.dist/remote/client/form.d.ts +10 -1
  52. package/.dist/remote/client/index.d.ts +1 -1
  53. package/.dist/remote/client/query.d.ts +6 -16
  54. package/.dist/remote/client/types.d.ts +32 -13
  55. package/.dist/remote/client.d.ts +1 -1
  56. package/.dist/remote/client.js +1 -1
  57. package/.dist/remote/server.d.ts +2 -12
  58. package/.dist/remote/server.js +1 -178
  59. package/.dist/runtime/transform.js +81 -68
  60. package/.dist/runtime/transform.js.map +1 -1
  61. package/.dist/script-transform/imports.d.ts +2 -0
  62. package/.dist/script-transform/types.d.ts +8 -0
  63. package/.dist/server/effects.d.ts +7 -7
  64. package/.dist/server/handler.d.ts +37 -0
  65. package/.dist/server/index.d.ts +4 -1
  66. package/.dist/server/schema.d.ts +2 -26
  67. package/.dist/server/types.d.ts +44 -50
  68. package/.dist/server/wrappers.d.ts +2 -2
  69. package/.dist/server.d.ts +2 -2
  70. package/.dist/server.js +88 -97
  71. package/.dist/server.js.map +1 -1
  72. package/.dist/yieldable.d.ts +41 -0
  73. package/README.md +1 -1
  74. package/package.json +4 -4
  75. package/.dist/chunks/client-CsVu54pU.js.map +0 -1
  76. package/.dist/chunks/descriptors-cOe9uRJz.js +0 -36
  77. package/.dist/chunks/descriptors-cOe9uRJz.js.map +0 -1
  78. package/.dist/chunks/errors-Dcf0MVbq.js.map +0 -1
  79. package/.dist/chunks/remote-client-Bj1pZXgq.js.map +0 -1
  80. package/.dist/chunks/transform-CEK6Ccll.js.map +0 -1
  81. package/.dist/chunks/vite-Dm3bXmR3.js.map +0 -1
  82. package/.dist/remote/server.js.map +0 -1
  83. /package/.dist/{vite → compiler}/remote-client.d.ts +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"file":"vite-Dm3bXmR3.js","names":["candidate"],"sources":["../../../modules/svelte-effect-runtime/src/diagnostics.ts","../../../modules/svelte-effect-runtime/src/vite.ts"],"sourcesContent":["/**\n * Warning diagnostic produced by the SER Vite diagnostics plugin.\n */\ninterface Diagnostic {\n\tmessage: string;\n\tline: number;\n\tcolumn: number;\n}\n\ninterface MarkupExpression {\n\tstart: number;\n\tend: number;\n\texpression_text: string;\n\tattribute_name?: string;\n}\n\n/**\n * Finds best-effort SER usage diagnostics in Svelte component markup.\n *\n * @example\n * ```ts\n * const diagnostics = find_svelte_effect_diagnostics(\n * `<button onclick={Effect.gen}>save</button>`,\n * \"Button.svelte\",\n * );\n * ```\n *\n * @since 2.0.0\n * @param code - Svelte component source to scan for suspicious Effect usage.\n * @param filename - Filename used in diagnostic messages.\n * @returns Warning diagnostics with a message and source location.\n */\nexport function find_svelte_effect_diagnostics(\n\tcode: string,\n\tfilename: string,\n): Array<{ message: string; line: number; column: number }> {\n\tconst effect_names = find_effect_local_names(code);\n\tconst expressions = find_markup_expressions(code);\n\n\treturn expressions.flatMap((expression) =>\n\t\tmake_expression_diagnostics(code, filename, effect_names, expression),\n\t);\n}\n\nfunction find_effect_local_names(code: string): Set<string> {\n\tconst names = new Set<string>([\"Effect\"]);\n\tconst script_pattern = /<script\\b[^>]*>([\\s\\S]*?)<\\/script\\s*>/gi;\n\n\tfor (const script_match of code.matchAll(script_pattern)) {\n\t\tconst script = script_match[1];\n\t\tconst import_pattern = /import\\s+(type\\s+)?\\{([^}]+)\\}\\s+from\\s+[\"']effect[\"']/g;\n\n\t\tfor (const import_match of script.matchAll(import_pattern)) {\n\t\t\tconst is_type_only_import = import_match[1] !== undefined;\n\t\t\tconst specifiers = import_match[2].split(\",\");\n\n\t\t\tif (is_type_only_import) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tfor (const specifier of specifiers) {\n\t\t\t\tconst local_name = parse_effect_import_local_name(specifier);\n\n\t\t\t\tif (local_name) {\n\t\t\t\t\tnames.add(local_name);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn names;\n}\n\nfunction parse_effect_import_local_name(specifier: string): string | undefined {\n\tconst trimmed = specifier.trim();\n\tconst match = trimmed.match(/^Effect(?:\\s+as\\s+([A-Za-z_$][\\w$]*))?$/);\n\n\tif (!match) {\n\t\treturn undefined;\n\t}\n\n\treturn match[1] ?? \"Effect\";\n}\n\nfunction find_markup_expressions(code: string): MarkupExpression[] {\n\tconst expressions: MarkupExpression[] = [];\n\tlet cursor = 0;\n\n\twhile (cursor < code.length) {\n\t\tconst open = code.indexOf(\"{\", cursor);\n\n\t\tif (open === -1) {\n\t\t\tbreak;\n\t\t}\n\n\t\tif (is_inside_svelte_excluded_block(code, open)) {\n\t\t\tcursor = open + 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst close = find_closing_brace(code, open + 1);\n\n\t\tif (close === -1) {\n\t\t\tcursor = open + 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\texpressions.push({\n\t\t\tstart: open,\n\t\t\tend: close,\n\t\t\texpression_text: code.slice(open + 1, close).trim(),\n\t\t\tattribute_name: find_attribute_name_before_expression(code, open),\n\t\t});\n\n\t\tcursor = close + 1;\n\t}\n\n\treturn expressions;\n}\n\nfunction make_expression_diagnostics(\n\tcode: string,\n\tfilename: string,\n\teffect_names: Set<string>,\n\texpression: MarkupExpression,\n): Diagnostic[] {\n\tconst attribute_name = expression.attribute_name;\n\tconst expression_text = expression.expression_text;\n\tconst is_event_attribute =\n\t\tattribute_name !== undefined && is_event_attribute_name(attribute_name);\n\tconst is_attribute = attribute_name !== undefined;\n\tconst loc = get_line_column(code, expression.start);\n\n\tif (!contains_effect_reference(expression_text, effect_names)) {\n\t\treturn [];\n\t}\n\n\tif (starts_with_yield_star(expression_text)) {\n\t\treturn [];\n\t}\n\n\tif (\n\t\tis_event_attribute &&\n\t\tis_callback_expression(expression_text) &&\n\t\tcontains_yield_star(expression_text)\n\t) {\n\t\treturn [\n\t\t\tmake_diagnostic(\n\t\t\t\tloc,\n\t\t\t\tmake_hidden_event_yield_warning(filename, attribute_name, expression_text),\n\t\t\t),\n\t\t];\n\t}\n\n\tif (contains_effect_runner(expression_text, effect_names)) {\n\t\treturn [\n\t\t\tmake_diagnostic(\n\t\t\t\tloc,\n\t\t\t\tmake_explicit_runner_warning(filename, attribute_name, expression_text),\n\t\t\t),\n\t\t];\n\t}\n\n\tif (is_bare_effect_gen(expression_text, effect_names)) {\n\t\treturn [\n\t\t\tmake_diagnostic(\n\t\t\t\tloc,\n\t\t\t\tmake_bare_effect_gen_warning(filename, attribute_name, expression_text),\n\t\t\t),\n\t\t];\n\t}\n\n\tif (is_event_attribute && is_callback_expression(expression_text)) {\n\t\treturn [\n\t\t\tmake_diagnostic(\n\t\t\t\tloc,\n\t\t\t\tmake_event_callback_returns_effect_warning(\n\t\t\t\t\tfilename,\n\t\t\t\t\tattribute_name,\n\t\t\t\t\texpression_text,\n\t\t\t\t),\n\t\t\t),\n\t\t];\n\t}\n\n\tif (is_event_attribute) {\n\t\treturn [\n\t\t\tmake_diagnostic(\n\t\t\t\tloc,\n\t\t\t\tmake_event_attribute_effect_warning(filename, attribute_name, expression_text),\n\t\t\t),\n\t\t];\n\t}\n\n\tif (is_attribute) {\n\t\treturn [\n\t\t\tmake_diagnostic(\n\t\t\t\tloc,\n\t\t\t\tmake_attribute_effect_warning(filename, attribute_name, expression_text),\n\t\t\t),\n\t\t];\n\t}\n\n\treturn [make_diagnostic(loc, make_sync_markup_effect_warning(filename, expression_text))];\n}\n\nfunction make_diagnostic(loc: { line: number; column: number }, message: string): Diagnostic {\n\treturn {\n\t\tmessage,\n\t\tline: loc.line,\n\t\tcolumn: loc.column,\n\t};\n}\n\nfunction make_hidden_event_yield_warning(\n\tfilename: string,\n\tattribute_name: string,\n\texpression_text: string,\n): string {\n\treturn [\n\t\t`[svelte-effect-runtime] Detected yield* hidden inside an event callback.`,\n\t\t`${filename}: ${attribute_name}={${expression_text}}`,\n\t\t`SER can only lower yield* at the event attribute boundary.`,\n\t\t`Write the event expression directly, for example: ${attribute_name}={yield* save()}`,\n\t].join(\"\\n\");\n}\n\nfunction make_explicit_runner_warning(\n\tfilename: string,\n\tattribute_name: string | undefined,\n\texpression_text: string,\n): string {\n\tconst location = attribute_name\n\t\t? `${attribute_name}={${expression_text}}`\n\t\t: `{${expression_text}}`;\n\n\treturn [\n\t\t`[svelte-effect-runtime] Detected an explicit Effect runner inside Svelte markup.`,\n\t\t`${filename}: ${location}`,\n\t\t`Explicit runners bypass SER cancellation and error handling for markup effects.`,\n\t\t`Prefer yield* so SER can manage the Effect lifecycle.`,\n\t].join(\"\\n\");\n}\n\nfunction make_bare_effect_gen_warning(\n\tfilename: string,\n\tattribute_name: string | undefined,\n\texpression_text: string,\n): string {\n\tconst location = attribute_name\n\t\t? `${attribute_name}={${expression_text}}`\n\t\t: `{${expression_text}}`;\n\tconst fixed = attribute_name\n\t\t? `${attribute_name}={yield* ${expression_text}(function* () { ... })}`\n\t\t: `{yield* ${expression_text}(function* () { ... })}`;\n\n\treturn [\n\t\t`[svelte-effect-runtime] Detected Effect.gen used as a value instead of an Effect program.`,\n\t\t`${filename}: ${location}`,\n\t\t`${expression_text} is a constructor, not the result of running a generator.`,\n\t\t`Use: ${fixed}`,\n\t].join(\"\\n\");\n}\n\nfunction make_event_callback_returns_effect_warning(\n\tfilename: string,\n\tattribute_name: string,\n\texpression_text: string,\n): string {\n\treturn [\n\t\t`[svelte-effect-runtime] Detected an event callback that returns an Effect but does not run it.`,\n\t\t`${filename}: ${attribute_name}={${expression_text}}`,\n\t\t`Svelte will call the callback and receive an Effect value, but SER will not manage it from inside the callback.`,\n\t\t`Use yield* at the event attribute boundary or explicitly run the Effect if you really want to bypass SER.`,\n\t].join(\"\\n\");\n}\n\nfunction make_event_attribute_effect_warning(\n\tfilename: string,\n\tattribute_name: string,\n\texpression_text: string,\n): string {\n\tconst fixed = `${attribute_name}={yield* ${expression_text}}`;\n\n\treturn [\n\t\t`[svelte-effect-runtime] Detected an event attribute that looks like an Effect but is not written with yield*.`,\n\t\t`${filename}: ${attribute_name}={${expression_text}}`,\n\t\t`If you are trying to use Effect in this event handler, use yield* at the beginning.`,\n\t\t`Use: ${fixed}`,\n\t].join(\"\\n\");\n}\n\nfunction make_attribute_effect_warning(\n\tfilename: string,\n\tattribute_name: string,\n\texpression_text: string,\n): string {\n\tconst fixed = `${attribute_name}={yield* ${expression_text}}`;\n\n\treturn [\n\t\t`[svelte-effect-runtime] Detected an attribute value that looks like an Effect but is not written with yield*.`,\n\t\t`${filename}: ${attribute_name}={${expression_text}}`,\n\t\t`Svelte attributes need the resolved Effect value, not the Effect object itself.`,\n\t\t`Use: ${fixed}`,\n\t].join(\"\\n\");\n}\n\nfunction make_sync_markup_effect_warning(filename: string, expression_text: string): string {\n\treturn [\n\t\t`[svelte-effect-runtime] Detected a markup expression that creates an Effect but is not written with yield*.`,\n\t\t`${filename}: {${expression_text}}`,\n\t\t`This expression will produce an Effect value, not its result.`,\n\t\t`Use yield* where Svelte expects the resolved value.`,\n\t].join(\"\\n\");\n}\n\nfunction contains_effect_reference(expression_text: string, effect_names: Set<string>): boolean {\n\tconst name_pattern = make_effect_name_pattern(effect_names);\n\tconst effect_pattern = new RegExp(\n\t\t`\\\\b(?:${name_pattern})\\\\.(?:gen|succeed|fail|try|tryPromise|promise|sync|all|void|log|runPromise|runSync|runFork)\\\\b`,\n\t);\n\n\treturn effect_pattern.test(expression_text);\n}\n\nfunction contains_effect_runner(expression_text: string, effect_names: Set<string>): boolean {\n\tconst name_pattern = make_effect_name_pattern(effect_names);\n\tconst runner_pattern = new RegExp(`\\\\b(?:${name_pattern})\\\\.run(?:Promise|Sync|Fork)\\\\b`);\n\n\treturn runner_pattern.test(expression_text);\n}\n\nfunction is_bare_effect_gen(expression_text: string, effect_names: Set<string>): boolean {\n\tconst name_pattern = make_effect_name_pattern(effect_names);\n\tconst bare_gen_pattern = new RegExp(`^(?:${name_pattern})\\\\.gen$`);\n\n\treturn bare_gen_pattern.test(expression_text);\n}\n\nfunction make_effect_name_pattern(effect_names: Set<string>): string {\n\treturn [...effect_names]\n\t\t.map(escape_regexp)\n\t\t.sort((a, b) => b.length - a.length)\n\t\t.join(\"|\");\n}\n\nfunction starts_with_yield_star(expression_text: string): boolean {\n\treturn /^yield\\s*\\*/.test(expression_text);\n}\n\nfunction contains_yield_star(expression_text: string): boolean {\n\treturn /\\byield\\s*\\*/.test(expression_text);\n}\n\nfunction is_callback_expression(expression_text: string): boolean {\n\treturn (\n\t\t/^(?:async\\s+)?(?:\\([^)]*\\)|[A-Za-z_$][\\w$]*)\\s*=>/.test(expression_text) ||\n\t\t/^(?:async\\s+)?function\\b/.test(expression_text)\n\t);\n}\n\nfunction is_event_attribute_name(name: string): boolean {\n\treturn /^on(?::[A-Za-z_$][\\w$-]*|[a-z][\\w$-]*)$/.test(name);\n}\n\nfunction find_attribute_name_before_expression(code: string, open: number): string | undefined {\n\tconst tag_start = code.lastIndexOf(\"<\", open);\n\tconst last_tag_end = code.lastIndexOf(\">\", open);\n\n\tif (tag_start === -1 || tag_start < last_tag_end) {\n\t\treturn undefined;\n\t}\n\n\tconst before_expression = code.slice(tag_start + 1, open);\n\tconst match = before_expression.match(/(?:^|\\s)([A-Za-z_$:][\\w$:-]*)\\s*=\\s*$/);\n\n\treturn match?.[1];\n}\n\nfunction is_inside_svelte_excluded_block(code: string, pos: number): boolean {\n\tconst script = find_svelte_tag_range(code, \"script\", pos);\n\tconst style = find_svelte_tag_range(code, \"style\", pos);\n\n\treturn (\n\t\t(script !== undefined && pos < script.end && pos > script.start) ||\n\t\t(style !== undefined && pos < style.end && pos > style.start)\n\t);\n}\n\nfunction find_svelte_tag_range(\n\tcode: string,\n\ttag: string,\n\tafter_pos: number,\n): { start: number; end: number } | undefined {\n\tconst pattern = new RegExp(`<${tag}\\\\b[^>]*>([\\\\s\\\\S]*?)<\\\\/${tag}\\\\s*>`, \"gi\");\n\n\tfor (const match of code.matchAll(pattern)) {\n\t\tif (match.index === undefined) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst end = match.index + match[0].length;\n\n\t\tif (match.index <= after_pos && after_pos < end) {\n\t\t\treturn { start: match.index, end };\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\nfunction find_closing_brace(code: string, start: number): number {\n\tlet depth = 0;\n\n\tfor (let i = start; i < code.length; i += 1) {\n\t\tconst ch = code[i];\n\n\t\tif (ch === \"{\" && code[i - 1] !== \"$\") {\n\t\t\tdepth += 1;\n\t\t} else if (ch === \"}\") {\n\t\t\tif (depth === 0) {\n\t\t\t\treturn i;\n\t\t\t}\n\n\t\t\tdepth -= 1;\n\t\t} else if (ch === \"'\" || ch === '\"' || ch === \"`\") {\n\t\t\ti = skip_string(code, i, ch);\n\n\t\t\tif (i === -1) {\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t} else if (ch === \"/\" && code[i + 1] === \"/\") {\n\t\t\ti = skip_line_comment(code, i);\n\t\t} else if (ch === \"/\" && code[i + 1] === \"*\") {\n\t\t\ti = skip_block_comment(code, i);\n\n\t\t\tif (i === -1) {\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn -1;\n}\n\nfunction skip_string(code: string, start: number, quote: string): number {\n\tfor (let i = start + 1; i < code.length; i += 1) {\n\t\tif (code[i] === \"\\\\\") {\n\t\t\ti += 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (code[i] === quote) {\n\t\t\treturn i;\n\t\t}\n\t}\n\n\treturn -1;\n}\n\nfunction skip_line_comment(code: string, start: number): number {\n\tfor (let i = start + 2; i < code.length; i += 1) {\n\t\tif (code[i] === \"\\n\") {\n\t\t\treturn i;\n\t\t}\n\t}\n\n\treturn code.length;\n}\n\nfunction skip_block_comment(code: string, start: number): number {\n\tfor (let i = start + 2; i < code.length; i += 1) {\n\t\tif (code[i] === \"*\" && code[i + 1] === \"/\") {\n\t\t\treturn i + 1;\n\t\t}\n\t}\n\n\treturn -1;\n}\n\nfunction get_line_column(code: string, position: number): { line: number; column: number } {\n\tconst before = code.slice(0, position);\n\tconst lines = before.split(\"\\n\");\n\tconst line = lines.length;\n\tconst column = lines.at(-1)?.length ?? 0;\n\n\treturn { line, column };\n}\n\nfunction escape_regexp(value: string): string {\n\treturn value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n","import { find_svelte_effect_diagnostics } from \"./diagnostics.ts\";\nimport type { Plugin } from \"vite\";\n\n/**\n * Options for the {@link effect} Vite plugin.\n *\n * @since 2.0.0\n */\nexport interface EffectOptions {\n\t/** Whether to emit debug logging in the generated remote client module. */\n\tdebug?: boolean;\n}\n\ninterface SvelteComponentModuleFilter {\n\tset_extensions(extensions: readonly string[]): void;\n\tis_module(id: string): boolean;\n}\n\ninterface VitePluginSvelteApi {\n\toptions?: {\n\t\textensions?: readonly unknown[];\n\t};\n}\n\ntype VitePluginSvelte = Plugin & {\n\tapi?: VitePluginSvelteApi;\n};\n\ntype VitePluginSvelteWithExtensions = Plugin & {\n\tapi: {\n\t\toptions: {\n\t\t\textensions: readonly string[];\n\t\t};\n\t};\n};\n\nconst default_svelte_component_extensions = [\".svelte\"] as const;\n\n/**\n * Vite plugin for SvelteKit. The server import plugin rewrites server-side\n * imports to the server entrypoint; the remote client plugin wraps SvelteKit's\n * generated client remote exports in Effect-returning adapters.\n *\n * @example\n * ```ts\n * import { effect } from \"svelte-effect-runtime/vite\";\n * import { sveltekit } from \"@sveltejs/kit/vite\";\n *\n * export default defineConfig({ plugins: [effect(), sveltekit()] });\n * ```\n *\n * @since 2.0.0\n * @param options - Optional configuration.\n * @returns Vite plugins that integrate the runtime with SvelteKit.\n */\nexport function effect(options?: EffectOptions): Plugin[] {\n\tconst component_filter = make_svelte_component_module_filter();\n\n\treturn [\n\t\tmake_diagnostics_plugin(component_filter),\n\t\tmake_reserved_helper_guard_plugin(component_filter),\n\t\tmake_svelte_transform_plugin(component_filter),\n\t\tmake_server_rewrite_plugin(),\n\t\tmake_remote_client_wrapper_plugin(options),\n\t];\n}\n\nfunction make_diagnostics_plugin(component_filter: SvelteComponentModuleFilter): Plugin {\n\tconst warned_diagnostics = new Set<string>();\n\n\treturn {\n\t\tname: \"svelte-effect-runtime:diagnostics\",\n\n\t\ttransform(code: string, id: string) {\n\t\t\tif (!component_filter.is_module(id)) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst clean_id = id.split(\"?\")[0] ?? id;\n\t\t\tconst diagnostics = find_svelte_effect_diagnostics(code, clean_id);\n\n\t\t\tfor (const diagnostic of diagnostics) {\n\t\t\t\tconst diagnostic_key = [\n\t\t\t\t\tclean_id,\n\t\t\t\t\tdiagnostic.line,\n\t\t\t\t\tdiagnostic.column,\n\t\t\t\t\tdiagnostic.message,\n\t\t\t\t].join(\":\");\n\n\t\t\t\tif (warned_diagnostics.has(diagnostic_key)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\twarned_diagnostics.add(diagnostic_key);\n\n\t\t\t\tthis.warn({\n\t\t\t\t\tid: clean_id,\n\t\t\t\t\tmessage: diagnostic.message,\n\t\t\t\t\tloc: {\n\t\t\t\t\t\tline: diagnostic.line,\n\t\t\t\t\t\tcolumn: diagnostic.column,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn undefined;\n\t\t},\n\t};\n}\n\nfunction make_reserved_helper_guard_plugin(component_filter: SvelteComponentModuleFilter): Plugin {\n\treturn {\n\t\tname: \"svelte-effect-runtime:reserved-helper-guard\",\n\n\t\ttransform(code: string, id: string) {\n\t\t\tif (!component_filter.is_module(id) || !has_ser_syntax(code)) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst reserved_names = find_reserved_helper_names(code);\n\n\t\t\tif (reserved_names.length === 0) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tthis.warn(make_reserved_helper_warning(reserved_names));\n\n\t\t\treturn undefined;\n\t\t},\n\t};\n}\n\nfunction make_svelte_transform_plugin(component_filter: SvelteComponentModuleFilter): Plugin {\n\treturn {\n\t\tname: \"svelte-effect-runtime:svelte-transform\",\n\n\t\tconfigResolved(config) {\n\t\t\tconst extensions = find_svelte_component_extensions(config.plugins);\n\t\t\tconst conflicting_plugin_names = find_pre_transform_plugin_names(config.plugins);\n\n\t\t\tif (extensions) {\n\t\t\t\tcomponent_filter.set_extensions(extensions);\n\t\t\t}\n\n\t\t\tif (conflicting_plugin_names.length === 0) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconfig.logger.info(make_pre_transform_plugin_notice(conflicting_plugin_names));\n\t\t},\n\n\t\tasync transform(code: string, id: string, options?: { ssr?: boolean }) {\n\t\t\tif (!component_filter.is_module(id)) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst { transform_svelte_effect } = await import(\"./runtime/transform.ts\");\n\t\t\tconst result = transform_svelte_effect(code, id, {\n\t\t\t\ttarget: options?.ssr ? \"server\" : \"client\",\n\t\t\t});\n\n\t\t\tif (result.code === code) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\treturn { code: result.code, map: null };\n\t\t},\n\t};\n}\n\nfunction make_svelte_component_module_filter(): SvelteComponentModuleFilter {\n\tlet extensions: readonly string[] = default_svelte_component_extensions;\n\n\treturn {\n\t\tset_extensions(next_extensions) {\n\t\t\tconst normalized_extensions = normalize_svelte_component_extensions(next_extensions);\n\n\t\t\tif (normalized_extensions.length === 0) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\textensions = normalized_extensions;\n\t\t},\n\n\t\tis_module(id) {\n\t\t\treturn is_svelte_component_module(id, extensions);\n\t\t},\n\t};\n}\n\nfunction normalize_svelte_component_extensions(extensions: readonly string[]): string[] {\n\tconst normalized_extensions = extensions\n\t\t.filter((extension) => extension.length > 0)\n\t\t.map((extension) => (extension.startsWith(\".\") ? extension : `.${extension}`));\n\n\treturn [...new Set(normalized_extensions)];\n}\n\nfunction find_svelte_component_extensions(\n\tplugins: readonly Plugin[],\n): readonly string[] | undefined {\n\tconst svelte_plugin = plugins.find(has_svelte_component_extensions);\n\n\treturn svelte_plugin?.api?.options?.extensions;\n}\n\nfunction has_svelte_component_extensions(plugin: Plugin): plugin is VitePluginSvelteWithExtensions {\n\tconst candidate = plugin as VitePluginSvelte;\n\tconst extensions = candidate.api?.options?.extensions;\n\n\tif (!plugin.name.startsWith(\"vite-plugin-svelte\")) {\n\t\treturn false;\n\t}\n\n\treturn (\n\t\tArray.isArray(extensions) && extensions.every((extension) => typeof extension === \"string\")\n\t);\n}\n\nfunction find_pre_transform_plugin_names(plugins: readonly Plugin[]): string[] {\n\treturn plugins\n\t\t.filter(\n\t\t\t(plugin) =>\n\t\t\t\t!plugin.name.startsWith(\"svelte-effect-runtime:\") &&\n\t\t\t\t!is_known_framework_pre_transform_plugin(plugin.name) &&\n\t\t\t\thas_pre_transform_priority(plugin),\n\t\t)\n\t\t.map((plugin) => plugin.name);\n}\n\nconst ansi_reset = \"\\x1b[0m\";\nconst ansi_light_green = \"\\x1b[92m\";\n\nfunction make_pre_transform_plugin_notice(plugin_names: readonly string[]): string {\n\tconst formatted_plugins = plugin_names.map((plugin_name) => ` - ${plugin_name}`).join(\"\\n\");\n\n\treturn [\n\t\t`${ansi_light_green}[svelte-effect-runtime]${ansi_reset} Svelte Effect Runtime noticed possible Vite plugin ordering conflicts.`,\n\t\t\"\",\n\t\t\"These plugins run before normal Svelte component transforms:\",\n\t\tformatted_plugins,\n\t\t\"\",\n\t\t\"This is usually fine, but if you see Svelte parser errors around <script effect>\",\n\t\t\"or yield* in components, one of those plugins may be reading component files before\",\n\t\t\"SER has lowered its syntax.\",\n\t].join(\"\\n\");\n}\n\nfunction is_known_framework_pre_transform_plugin(name: string): boolean {\n\treturn name.startsWith(\"vite:\") || name === \"vite-plugin-svelte:preprocess\";\n}\n\nfunction has_pre_transform_priority(plugin: Plugin): boolean {\n\tif (plugin.enforce === \"pre\" && plugin.transform) {\n\t\treturn true;\n\t}\n\n\tif (\n\t\ttypeof plugin.transform === \"object\" &&\n\t\tplugin.transform !== null &&\n\t\t\"order\" in plugin.transform &&\n\t\tplugin.transform.order === \"pre\"\n\t) {\n\t\treturn true;\n\t}\n\n\treturn false;\n}\n\nfunction make_server_rewrite_plugin(): Plugin {\n\treturn {\n\t\tname: \"svelte-effect-runtime:server-imports\",\n\n\t\tconfig() {\n\t\t\treturn { optimizeDeps: { exclude: [\"svelte-effect-runtime\"] } };\n\t\t},\n\n\t\ttransform(code: string, id: string) {\n\t\t\tif (!is_server_runtime_module(id)) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst rewritten = code\n\t\t\t\t.replace(\n\t\t\t\t\t/from\\s+[\"']svelte-effect-runtime[\"']/g,\n\t\t\t\t\t`from \"svelte-effect-runtime/server\"`,\n\t\t\t\t)\n\t\t\t\t.replace(\n\t\t\t\t\t/from\\s+[\"']svelte-effect-runtime\\/internal\\/generators[\"']/g,\n\t\t\t\t\t`from \"svelte-effect-runtime/server\"`,\n\t\t\t\t);\n\n\t\t\tif (rewritten === code) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\treturn { code: rewritten, map: null };\n\t\t},\n\t};\n}\n\nfunction make_remote_client_wrapper_plugin(options?: EffectOptions): Plugin {\n\treturn {\n\t\tname: \"svelte-effect-runtime:remote-client\",\n\t\tenforce: \"post\",\n\n\t\tconfig() {\n\t\t\treturn { ssr: { noExternal: [\"svelte-effect-runtime\"] } };\n\t\t},\n\n\t\tconfigResolved(config) {\n\t\t\tconst no_external = config.ssr.noExternal;\n\t\t\tconst runtime_package = \"svelte-effect-runtime\";\n\n\t\t\tif (no_external === true) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (Array.isArray(no_external)) {\n\t\t\t\tconst has_runtime_package = no_external.some((entry) => entry === runtime_package);\n\n\t\t\t\tif (!has_runtime_package) {\n\t\t\t\t\tno_external.push(runtime_package);\n\t\t\t\t}\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconfig.ssr.noExternal = [no_external, runtime_package].filter(\n\t\t\t\t(value): value is string | RegExp => value !== undefined,\n\t\t\t);\n\t\t},\n\n\t\tasync transform(code: string, id: string) {\n\t\t\tif (!is_remote_module(id) || !code.includes(\"__sveltekit/remote\")) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst rewritten = await rewrite_remote_client_exports(code, options);\n\n\t\t\tif (rewritten === code) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\treturn { code: rewritten, map: null };\n\t\t},\n\t};\n}\n\nfunction is_server_runtime_module(id: string): boolean {\n\tconst [filename] = id.split(\"?\", 2);\n\n\treturn (\n\t\t/\\.(server|remote)(?:\\.[cm])?\\.[jt]s$/.test(filename) ||\n\t\t/(?:^|[\\\\/])hooks\\.server(?:\\.[cm])?\\.[jt]s$/.test(filename)\n\t);\n}\n\nfunction is_remote_module(id: string): boolean {\n\treturn /\\.(remote|remote\\.[cm]?)\\.[jt]s(?:\\?.*)?$/.test(id) || id.includes(\".remote.\");\n}\n\nfunction is_svelte_component_module(id: string, extensions: readonly string[]): boolean {\n\tconst [filename, query = \"\"] = id.split(\"?\", 2);\n\n\tif (!extensions.some((extension) => filename.endsWith(extension))) {\n\t\treturn false;\n\t}\n\n\tif (query.length === 0) {\n\t\treturn true;\n\t}\n\n\tconst params = new URLSearchParams(query);\n\tconst allowed_params = [\"t\", \"v\"];\n\n\treturn [...params.keys()].every((key) => allowed_params.includes(key));\n}\n\nfunction has_ser_syntax(code: string): boolean {\n\treturn /\\byield\\s*\\*/.test(code) || /<script\\b[^>]*\\beffect(?:[\\s=>]|$)/.test(code);\n}\n\nfunction find_reserved_helper_names(code: string): string[] {\n\tconst script_segments = [...code.matchAll(/<script\\b[^>]*>([\\s\\S]*?)<\\/script\\s*>/gi)].map(\n\t\t(match) => match[1] ?? \"\",\n\t);\n\tconst markup_segments = [...code.matchAll(/\\{[^{}]*(?:Dispatcher|Code)[^{}]*\\}/g)].map(\n\t\t(match) => match[0],\n\t);\n\tconst search_segments = [...script_segments, ...markup_segments];\n\n\treturn [\"Dispatcher\", \"Code\"].filter((name) =>\n\t\tsearch_segments.some((segment) => new RegExp(`\\\\b${name}\\\\b`).test(segment)),\n\t);\n}\n\nfunction make_reserved_helper_warning(names: string[]): string {\n\tconst quoted_names = names.map((name) => `\\`${name}\\``);\n\tconst subject =\n\t\tquoted_names.length === 1\n\t\t\t? quoted_names[0]\n\t\t\t: `${quoted_names.slice(0, -1).join(\", \")} and ${\n\t\t\t\t\tquoted_names[quoted_names.length - 1]\n\t\t\t\t}`;\n\tconst verb = names.length === 1 ? \"is\" : \"are\";\n\n\treturn [\n\t\t`[svelte-effect-runtime] ${subject} ${verb} reserved for generated markup helpers.`,\n\t\t`Rename or alias local bindings that use ${subject} before using SER syntax in this component.`,\n\t].join(\" \");\n}\n\n/**\n * Rewrites SvelteKit's generated client remote module from:\n *\n * `export const get_post = __remote.query(\"hash/get_post\")`\n *\n * into an Effect-aware wrapper around the same native function.\n *\n * @example\n * ```ts\n * const rewritten = await rewrite_remote_client_exports(remote_module_code);\n * ```\n *\n * @since 2.0.0\n * @param code - The generated client remote module code.\n * @param options - Optional plugin options.\n * @returns A promise that resolves to the rewritten module code.\n * @internal\n */\nexport async function rewrite_remote_client_exports(\n\tcode: string,\n\toptions?: EffectOptions,\n): Promise<string> {\n\tconst remote_client = await import(\"./vite/remote-client.ts\");\n\n\treturn remote_client.rewrite_remote_client_exports(code, options);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAgCA,SAAgB,+BACf,MACA,UAC2D;CAC3D,MAAM,eAAe,wBAAwB,IAAI;CAGjD,OAFoB,wBAAwB,IAE3B,CAAC,CAAC,SAAS,eAC3B,4BAA4B,MAAM,UAAU,cAAc,UAAU,CACrE;AACD;AAEA,SAAS,wBAAwB,MAA2B;CAC3D,MAAM,wBAAQ,IAAI,IAAY,CAAC,QAAQ,CAAC;CAGxC,KAAK,MAAM,gBAAgB,KAAK,SAAS,0CAAc,GAAG;EACzD,MAAM,SAAS,aAAa;EAG5B,KAAK,MAAM,gBAAgB,OAAO,SAAS,yDAAc,GAAG;GAC3D,MAAM,sBAAsB,aAAa,OAAO,KAAA;GAChD,MAAM,aAAa,aAAa,EAAE,CAAC,MAAM,GAAG;GAE5C,IAAI,qBACH;GAGD,KAAK,MAAM,aAAa,YAAY;IACnC,MAAM,aAAa,+BAA+B,SAAS;IAE3D,IAAI,YACH,MAAM,IAAI,UAAU;GAEtB;EACD;CACD;CAEA,OAAO;AACR;AAEA,SAAS,+BAA+B,WAAuC;CAE9E,MAAM,QADU,UAAU,KACN,CAAC,CAAC,MAAM,yCAAyC;CAErE,IAAI,CAAC,OACJ;CAGD,OAAO,MAAM,MAAM;AACpB;AAEA,SAAS,wBAAwB,MAAkC;CAClE,MAAM,cAAkC,CAAC;CACzC,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AAc,MAAM,CAAC,CAAC,QAAQ,SACrC,gBAAgB,MAAM,YAAY,IAAI,OAAO,MAAM,KAAK,IAAI,CAAC,CAAC,KAAK,OAAO,CAAC,CAC5E;AACD;AAEA,SAAS,6BAA6B,OAAyB;CAC9D,MAAM,eAAe,MAAM,KAAK,SAAS,KAAK,KAAK,GAAG;CACtD,MAAM,UACL,aAAa,WAAW,IACrB,aAAa,KACb,GAAG,aAAa,MAAM,GAAG,EAAE,CAAC,CAAC,KAAK,IAAI,EAAE,OACxC,aAAa,aAAa,SAAS;CAIvC,OAAO,CACN,2BAA2B,QAAQ,GAHvB,MAAM,WAAW,IAAI,OAAO,MAGG,0CAC3C,2CAA2C,QAAQ,4CACpD,CAAC,CAAC,KAAK,GAAG;AACX;;;;;;;;;;;;;;;;;;;AAoBA,eAAsB,8BACrB,MACA,SACkB;CAGlB,QAAO,MAFqB,OAAO,+BAAA,CAEd,8BAA8B,MAAM,OAAO;AACjE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"server.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/remote/server.ts"],"sourcesContent":["import { create_serialized_remote_failure_envelope } from \"$/remote/shared.ts\";\nimport type { FormIssue } from \"$/remote/shared.ts\";\nimport { RemoteHelperContextError, RemoteHelperError } from \"$/errors.ts\";\nimport { isHttpError, isRedirect, isValidationError } from \"@sveltejs/kit\";\nimport { Cause, Effect, Exit } from \"effect\";\nimport { stringify } from \"devalue\";\n\ntype CauseReason = {\n\treadonly _tag: string;\n\treadonly defect?: unknown;\n\treadonly error?: unknown;\n};\n\ntype SvelteInvalid = (...issues: readonly (FormIssue | string)[]) => never;\n\ntype SvelteError = (status: number, body: unknown) => never;\n\nconst request_event_context_error_start =\n\t\"Can only read the current request event inside functions invoked during `handle`\";\n\nconst request_store_context_error = \"Could not get the request store.\";\n\n/**\n * Runs a user-supplied Effect program through a ManagedRuntime, maps its\n * exit into the shape expected by SvelteKit, and returns the result or\n * throws a SvelteKit-compatible error.\n *\n * @since 2.0.0\n * @param effect - The Effect program to execute.\n * @param runtime - The server-side ManagedRuntime.\n * @param invalid - SvelteKit's `invalid` helper (bound per-request).\n * @param error - SvelteKit's `error` helper.\n * @returns A Promise that resolves with the effect's success value.\n * @internal\n */\nexport async function run_remote_effect<A>(\n\teffect: Effect.Effect<A, unknown, unknown>,\n\truntime: {\n\t\trunPromise: (e: Effect.Effect<unknown, unknown, unknown>) => Promise<unknown>;\n\t},\n\tinvalid: SvelteInvalid,\n\terror: SvelteError,\n): Promise<A> {\n\tconst exit: Exit.Exit<A, unknown> = (await runtime.runPromise(\n\t\tEffect.exit(effect) as Effect.Effect<unknown, unknown, unknown>,\n\t)) as Exit.Exit<A, unknown>;\n\n\tif (Exit.isSuccess(exit)) {\n\t\treturn exit.value;\n\t}\n\n\thandle_failure(exit.cause, invalid, error);\n}\n\n/**\n * Inspects the Effect Cause for failures and either throws a form\n * validation error (via SvelteKit's `invalid`) or encodes the error\n * and throws it via SvelteKit's `error`.\n */\nfunction handle_failure(\n\tcause: Cause.Cause<unknown>,\n\tinvalid: SvelteInvalid,\n\terror: SvelteError,\n): never {\n\tconst reasons = get_cause_reasons(cause);\n\n\t/**\n\t * Phase 1 — let SvelteKit's thrown control-flow sentinels escape.\n\t */\n\tfor (const reason of reasons) {\n\t\tif (!Cause.isDieReason(reason as never)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst defect = reason.defect;\n\n\t\tif (is_sveltekit_control_flow(defect)) {\n\t\t\tthrow defect;\n\t\t}\n\t}\n\n\t/**\n\t * Phase 2 — let cancellation escape without becoming a remote failure.\n\t */\n\tif (Cause.hasInterruptsOnly(cause)) {\n\t\tthrow Cause.squash(cause);\n\t}\n\n\t/**\n\t * Phase 3 — preserve typed form validation failures.\n\t */\n\tfor (const reason of reasons) {\n\t\tif (Cause.isFailReason(reason as never)) {\n\t\t\tconst failure = reason.error;\n\t\t\tif (\n\t\t\t\ttypeof failure === \"object\" &&\n\t\t\t\tfailure !== null &&\n\t\t\t\t(failure as Record<string, unknown>)._tag === \"FormError\"\n\t\t\t) {\n\t\t\t\tconst issues = (failure as { issues?: readonly FormIssue[] }).issues ?? [];\n\t\t\t\tinvalid(...issues);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Phase 4 — encode all other failures for the remote client.\n\t */\n\tconst encoded = encode_remote_failure(cause);\n\tconst envelope = create_serialized_remote_failure_envelope(encoded);\n\n\terror(500, envelope);\n}\n\n/**\n * Encodes an Effect Cause into a string that the client-side adapter can\n * decode back into a typed `RemoteFailure`.\n *\n * @since 2.0.0\n * @param cause - The Effect Cause from a failed execution.\n * @returns A devalue-encoded string representing the serialised failure.\n * @internal\n */\nexport function encode_remote_failure(cause: Cause.Cause<unknown>): string {\n\tconst reasons = get_cause_reasons(cause);\n\n\tfor (const reason of reasons) {\n\t\tif (Cause.isFailReason(reason as never)) {\n\t\t\tconst failure = to_public_remote_failure(reason.error);\n\t\t\tconst encoded = stringify_failure(failure);\n\n\t\t\tif (encoded !== undefined) {\n\t\t\t\treturn encoded;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn stringify_unknown_remote_failure();\n}\n\nfunction get_cause_reasons(cause: Cause.Cause<unknown>): readonly CauseReason[] {\n\tconst reasons = (cause as unknown as { reasons?: readonly CauseReason[] }).reasons;\n\n\treturn reasons ?? [];\n}\n\nfunction is_sveltekit_control_flow(value: unknown): boolean {\n\treturn isRedirect(value) || isHttpError(value) || isValidationError(value);\n}\n\nfunction stringify_failure(value: unknown): string | undefined {\n\ttry {\n\t\treturn stringify(value);\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nfunction to_public_remote_failure(value: unknown): unknown {\n\tif (!has_public_remote_failure_tag(value)) {\n\t\treturn create_unknown_remote_failure();\n\t}\n\n\tconst serializable_failure = to_serializable_public_failure(value);\n\n\treturn serializable_failure ?? create_unknown_remote_failure();\n}\n\nfunction to_serializable_public_failure(value: unknown, seen = new WeakSet<object>()): unknown {\n\tif (typeof value === \"function\" || typeof value === \"symbol\") {\n\t\treturn undefined;\n\t}\n\n\tif (!is_object_like(value)) {\n\t\treturn value;\n\t}\n\n\tif (stringify_failure(value) !== undefined) {\n\t\treturn value;\n\t}\n\n\tif (is_internal_object(value)) {\n\t\treturn undefined;\n\t}\n\n\tif (seen.has(value)) {\n\t\treturn undefined;\n\t}\n\n\tseen.add(value);\n\n\tconst serializable = Array.isArray(value)\n\t\t? value.map((item) => to_serializable_public_failure(item, seen))\n\t\t: to_plain_record(value, seen);\n\n\tseen.delete(value);\n\n\treturn serializable;\n}\n\nfunction to_plain_record(value: object, seen: WeakSet<object>): Record<string, unknown> {\n\tconst descriptors = Object.getOwnPropertyDescriptors(value);\n\tconst record: Record<string, unknown> = {};\n\n\tfor (const [key, descriptor] of Object.entries(descriptors)) {\n\t\tif (key === \"stack\" || !(\"value\" in descriptor)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\trecord[key] = to_serializable_public_failure(descriptor.value, seen);\n\t}\n\n\tif (value instanceof Error && !(\"message\" in record)) {\n\t\trecord.message = value.message;\n\t}\n\n\treturn record;\n}\n\nfunction is_object_like(value: unknown): value is object {\n\treturn typeof value === \"object\" && value !== null;\n}\n\nfunction has_public_remote_failure_tag(value: unknown): boolean {\n\treturn is_object_like(value) && typeof (value as { _tag?: unknown })._tag === \"string\";\n}\n\nfunction is_internal_object(value: object): boolean {\n\treturn (\n\t\t!Array.isArray(value) && !is_plain_record(value) && !has_public_remote_failure_tag(value)\n\t);\n}\n\nfunction is_plain_record(value: object): boolean {\n\tconst prototype = Object.getPrototypeOf(value);\n\n\treturn prototype === Object.prototype || prototype === null;\n}\n\nfunction create_unknown_remote_failure(): { readonly message: string } {\n\treturn { message: \"[UNKNOWN_REMOTE_FAILURE]: Unknown error\" };\n}\n\nfunction stringify_unknown_remote_failure(): string {\n\treturn stringify(create_unknown_remote_failure());\n}\n\n/**\n * Throws a SvelteKit `invalid` response from a {@link FormError}, calling\n * through to the request-scoped `invalid` helper.\n *\n * @example\n * ```ts\n * throw_form_error(\n * [{ message: \"Name is required\", path: [\"name\"] }],\n * invalid,\n * );\n * ```\n *\n * @since 2.0.0\n * @param issues - The list of form validation issues.\n * @param invalid - SvelteKit's `invalid` helper bound to the current request.\n * @internal\n */\nexport function throw_form_error(issues: readonly FormIssue[], invalid: SvelteInvalid): never {\n\tinvalid(...issues);\n}\n\n/**\n * Remaps SvelteKit's unbranded request-context errors into clear, actionable\n * messages.\n *\n * @example\n * ```ts\n * try {\n * return native_query(handler);\n * } catch (err) {\n * throw normalize_remote_helper_error(err, \"Query\");\n * }\n * ```\n *\n * @since 2.0.0\n * @param err - The error thrown by SvelteKit's native functions.\n * @param helper_name - Name of the helper that triggered the error.\n * @returns A more descriptive error.\n * @internal\n */\nexport function normalize_remote_helper_error(err: unknown, helper_name: string): Error {\n\tif (is_sveltekit_remote_context_error(err)) {\n\t\treturn new RemoteHelperContextError(helper_name);\n\t}\n\n\treturn err instanceof Error ? err : new RemoteHelperError(err);\n}\n\nfunction is_sveltekit_remote_context_error(err: unknown): err is Error {\n\tif (!(err instanceof Error)) {\n\t\treturn false;\n\t}\n\n\treturn (\n\t\terr.message.startsWith(request_event_context_error_start) ||\n\t\terr.message === request_store_context_error\n\t);\n}\n"],"mappings":";;;;;;AAiBA,MAAM,oCACL;AAED,MAAM,8BAA8B;;;;;;;;;;;;;;AAepC,eAAsB,kBACrB,QACA,SAGA,SACA,OACa;CACb,MAAM,OAA+B,MAAM,QAAQ,WAClD,OAAO,KAAK,MAAM,CACnB;CAEA,IAAI,KAAK,UAAU,IAAI,GACtB,OAAO,KAAK;CAGb,eAAe,KAAK,OAAO,SAAS,KAAK;AAC1C;;;;;;AAOA,SAAS,eACR,OACA,SACA,OACQ;CACR,MAAM,UAAU,kBAAkB,KAAK;;;;CAKvC,KAAK,MAAM,UAAU,SAAS;EAC7B,IAAI,CAAC,MAAM,YAAY,MAAe,GACrC;EAGD,MAAM,SAAS,OAAO;EAEtB,IAAI,0BAA0B,MAAM,GACnC,MA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