svelte-effect-runtime 3.4.11 → 4.0.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 (147) hide show
  1. package/.dist/chunks/client-BrZka6DW.js +530 -0
  2. package/.dist/chunks/client-BrZka6DW.js.map +1 -0
  3. package/.dist/chunks/compiler-COVzgLYo.js +412 -0
  4. package/.dist/chunks/compiler-COVzgLYo.js.map +1 -0
  5. package/.dist/chunks/descriptors-B4otDlm1.js +216 -0
  6. package/.dist/chunks/descriptors-B4otDlm1.js.map +1 -0
  7. package/.dist/chunks/diagnostics-BDrky-Di.js +359 -0
  8. package/.dist/chunks/diagnostics-BDrky-Di.js.map +1 -0
  9. package/.dist/chunks/dispatcher-BA0PLQhA.js +16 -0
  10. package/.dist/chunks/dispatcher-BA0PLQhA.js.map +1 -0
  11. package/.dist/chunks/{dispatcher-pHH4JcFR.js → dispatcher-_x0MQZBS.js} +84 -258
  12. package/.dist/chunks/dispatcher-_x0MQZBS.js.map +1 -0
  13. package/.dist/chunks/{errors-Dcf0MVbq.js → errors-CLsbGjIa.js} +57 -106
  14. package/.dist/chunks/errors-CLsbGjIa.js.map +1 -0
  15. package/.dist/chunks/live-BundLSoY.js +146 -0
  16. package/.dist/chunks/live-BundLSoY.js.map +1 -0
  17. package/.dist/chunks/live-CHK0RrZu.js +10 -0
  18. package/.dist/chunks/live-CHK0RrZu.js.map +1 -0
  19. package/.dist/chunks/{remote-client-Bj1pZXgq.js → remote-client-mkQAfP1G.js} +30 -24
  20. package/.dist/chunks/remote-client-mkQAfP1G.js.map +1 -0
  21. package/.dist/chunks/{runtime-ekkMQ-wL.js → runtime-HDTlEnzp.js} +3 -27
  22. package/.dist/chunks/runtime-HDTlEnzp.js.map +1 -0
  23. package/.dist/chunks/server-BNrA1I-u.js +144 -0
  24. package/.dist/chunks/server-BNrA1I-u.js.map +1 -0
  25. package/.dist/chunks/source-scan-9pZxnfct.js +1059 -0
  26. package/.dist/chunks/source-scan-9pZxnfct.js.map +1 -0
  27. package/.dist/chunks/{transform-CtQDGS9c.js → transform-BXyYUAez.js} +308 -484
  28. package/.dist/chunks/transform-BXyYUAez.js.map +1 -0
  29. package/.dist/compiler/markup-identifiers.d.ts +2 -0
  30. package/.dist/compiler/remote-client.d.ts +6 -0
  31. package/.dist/compiler/source-scan.d.ts +101 -0
  32. package/.dist/compiler/sveltekit-remote-bridge.d.ts +3 -0
  33. package/.dist/{vite.d.ts → compiler.d.ts} +7 -1
  34. package/.dist/{vite.js → compiler.js} +1 -1
  35. package/.dist/detect.d.ts +0 -31
  36. package/.dist/detect.js +0 -39
  37. package/.dist/detect.js.map +1 -1
  38. package/.dist/diagnostics.d.ts +0 -16
  39. package/.dist/dispatcher/deps.d.ts +3 -14
  40. package/.dist/dispatcher/fibers.d.ts +5 -46
  41. package/.dist/dispatcher/index.d.ts +1 -143
  42. package/.dist/dispatcher/types.d.ts +0 -151
  43. package/.dist/dispatcher.js +1 -1
  44. package/.dist/errors.d.ts +44 -86
  45. package/.dist/generated/dispatcher.d.ts +0 -50
  46. package/.dist/generators.d.ts +3 -12
  47. package/.dist/internal/descriptors.d.ts +0 -16
  48. package/.dist/internal/generators.js +25 -3
  49. package/.dist/internal/generators.js.map +1 -0
  50. package/.dist/internal/live.d.ts +9 -0
  51. package/.dist/internal/remote-client.js +2 -2
  52. package/.dist/internal/remote-server.js +2 -2
  53. package/.dist/internal/schema.d.ts +13 -0
  54. package/.dist/live.d.ts +106 -0
  55. package/.dist/markup/event-attributes.d.ts +5 -28
  56. package/.dist/markup/promise.d.ts +1 -23
  57. package/.dist/markup/promise.js +2 -18
  58. package/.dist/markup/promise.js.map +1 -1
  59. package/.dist/markup/run.d.ts +1 -10
  60. package/.dist/markup/run.js +2 -11
  61. package/.dist/markup/run.js.map +1 -1
  62. package/.dist/markup/transform/apply.d.ts +4 -4
  63. package/.dist/markup/transform/classify.d.ts +2 -11
  64. package/.dist/markup/transform/constants.d.ts +2 -1
  65. package/.dist/markup/transform/effect-bindings.d.ts +2 -26
  66. package/.dist/markup/transform/effect-callbacks.d.ts +0 -20
  67. package/.dist/markup/transform/emit.d.ts +2 -11
  68. package/.dist/markup/transform/expressions.d.ts +0 -35
  69. package/.dist/markup/transform/scan.d.ts +3 -22
  70. package/.dist/markup/transform/types.d.ts +2 -129
  71. package/.dist/markup/transform.js +1 -1
  72. package/.dist/markup/value.d.ts +1 -18
  73. package/.dist/markup/value.js +2 -19
  74. package/.dist/markup/value.js.map +1 -1
  75. package/.dist/mod.d.ts +6 -8
  76. package/.dist/mod.js +5 -4
  77. package/.dist/mod.js.map +1 -1
  78. package/.dist/remote/cause-codec.d.ts +19 -0
  79. package/.dist/remote/client/command.d.ts +3 -17
  80. package/.dist/remote/client/form-data.d.ts +0 -7
  81. package/.dist/remote/client/form-enhance.d.ts +0 -7
  82. package/.dist/remote/client/form-transport.d.ts +15 -18
  83. package/.dist/remote/client/form.d.ts +9 -20
  84. package/.dist/remote/client/index.d.ts +2 -1
  85. package/.dist/remote/client/prerender.d.ts +6 -0
  86. package/.dist/remote/client/query-result.d.ts +2 -14
  87. package/.dist/remote/client/query.d.ts +9 -59
  88. package/.dist/remote/client/responses.d.ts +3 -27
  89. package/.dist/remote/client/types.d.ts +26 -101
  90. package/.dist/remote/client/utils.d.ts +0 -8
  91. package/.dist/remote/client.d.ts +2 -2
  92. package/.dist/remote/client.js +2 -2
  93. package/.dist/remote/effect.d.ts +6 -0
  94. package/.dist/remote/failures.d.ts +4 -0
  95. package/.dist/remote/query-update.d.ts +2 -0
  96. package/.dist/remote/resource.d.ts +25 -0
  97. package/.dist/remote/server.d.ts +5 -60
  98. package/.dist/remote/server.js +2 -179
  99. package/.dist/remote/shared.d.ts +6 -145
  100. package/.dist/remote/shared.js +6 -127
  101. package/.dist/remote/shared.js.map +1 -1
  102. package/.dist/runtime/transform.js +83 -87
  103. package/.dist/runtime/transform.js.map +1 -1
  104. package/.dist/script-transform/ast.d.ts +0 -46
  105. package/.dist/script-transform/imports.d.ts +2 -38
  106. package/.dist/script-transform/lower.d.ts +0 -9
  107. package/.dist/script-transform/runes.d.ts +0 -10
  108. package/.dist/script-transform/runtime-block.d.ts +0 -17
  109. package/.dist/script-transform/source.d.ts +0 -24
  110. package/.dist/script-transform/types.d.ts +9 -126
  111. package/.dist/server/effects.d.ts +8 -57
  112. package/.dist/server/factories.d.ts +7 -7
  113. package/.dist/server/handler.d.ts +37 -0
  114. package/.dist/server/index.d.ts +4 -1
  115. package/.dist/server/invalid.d.ts +0 -7
  116. package/.dist/server/live-snapshot.d.ts +5 -0
  117. package/.dist/server/remote-handler-context.d.ts +5 -0
  118. package/.dist/server/runtime.d.ts +6 -24
  119. package/.dist/server/schema.d.ts +2 -40
  120. package/.dist/server/transport.d.ts +2 -0
  121. package/.dist/server/types.d.ts +88 -71
  122. package/.dist/server/wrappers.d.ts +4 -41
  123. package/.dist/server.d.ts +2 -2
  124. package/.dist/server.js +255 -279
  125. package/.dist/server.js.map +1 -1
  126. package/.dist/yieldable.d.ts +7 -0
  127. package/README.md +1 -1
  128. package/package.json +5 -5
  129. package/.dist/chunks/client-CsVu54pU.js +0 -627
  130. package/.dist/chunks/client-CsVu54pU.js.map +0 -1
  131. package/.dist/chunks/descriptors-cOe9uRJz.js +0 -36
  132. package/.dist/chunks/descriptors-cOe9uRJz.js.map +0 -1
  133. package/.dist/chunks/dispatcher-LtvFKYUp.js +0 -47
  134. package/.dist/chunks/dispatcher-LtvFKYUp.js.map +0 -1
  135. package/.dist/chunks/dispatcher-pHH4JcFR.js.map +0 -1
  136. package/.dist/chunks/errors-Dcf0MVbq.js.map +0 -1
  137. package/.dist/chunks/event-attributes-gHzP2ycp.js +0 -39
  138. package/.dist/chunks/event-attributes-gHzP2ycp.js.map +0 -1
  139. package/.dist/chunks/remote-client-Bj1pZXgq.js.map +0 -1
  140. package/.dist/chunks/runtime-ekkMQ-wL.js.map +0 -1
  141. package/.dist/chunks/transform-CtQDGS9c.js.map +0 -1
  142. package/.dist/chunks/vite-WGlbSnso.js +0 -486
  143. package/.dist/chunks/vite-WGlbSnso.js.map +0 -1
  144. package/.dist/remote/client/effect.d.ts +0 -29
  145. package/.dist/remote/client/failures.d.ts +0 -42
  146. package/.dist/remote/server.js.map +0 -1
  147. package/.dist/vite/remote-client.d.ts +0 -24
@@ -1,486 +0,0 @@
1
- import { t as is_event_attribute_name } from "./event-attributes-gHzP2ycp.js";
2
- //#region src/diagnostics.ts
3
- /**
4
- * Finds best-effort SER usage diagnostics in Svelte component markup.
5
- *
6
- * @example
7
- * ```ts
8
- * const diagnostics = find_svelte_effect_diagnostics(
9
- * `<button onclick={Effect.gen}>save</button>`,
10
- * "Button.svelte",
11
- * );
12
- * ```
13
- *
14
- * @since 2.0.0
15
- * @param code - Svelte component source to scan for suspicious Effect usage.
16
- * @param filename - Filename used in diagnostic messages.
17
- * @returns Warning diagnostics with a message and source location.
18
- */
19
- function find_svelte_effect_diagnostics(code, filename) {
20
- const effect_names = find_effect_local_names(code);
21
- return find_markup_expressions(code).flatMap((expression) => make_expression_diagnostics(code, filename, effect_names, expression));
22
- }
23
- function find_effect_local_names(code) {
24
- const names = /* @__PURE__ */ new Set(["Effect"]);
25
- for (const script_match of code.matchAll(/<script\b[^>]*>([\s\S]*?)<\/script\s*>/gi)) {
26
- const script = script_match[1];
27
- for (const import_match of script.matchAll(/import\s+(type\s+)?\{([^}]+)\}\s+from\s+["']effect["']/g)) {
28
- const is_type_only_import = import_match[1] !== void 0;
29
- const specifiers = import_match[2].split(",");
30
- if (is_type_only_import) continue;
31
- for (const specifier of specifiers) {
32
- const local_name = parse_effect_import_local_name(specifier);
33
- if (local_name) names.add(local_name);
34
- }
35
- }
36
- }
37
- return names;
38
- }
39
- function parse_effect_import_local_name(specifier) {
40
- const match = specifier.trim().match(/^Effect(?:\s+as\s+([A-Za-z_$][\w$]*))?$/);
41
- if (!match) return;
42
- return match[1] ?? "Effect";
43
- }
44
- function find_markup_expressions(code) {
45
- const expressions = [];
46
- let cursor = 0;
47
- while (cursor < code.length) {
48
- const open = code.indexOf("{", cursor);
49
- if (open === -1) break;
50
- if (is_inside_svelte_excluded_block(code, open)) {
51
- cursor = open + 1;
52
- continue;
53
- }
54
- const close = find_closing_brace(code, open + 1);
55
- if (close === -1) {
56
- cursor = open + 1;
57
- continue;
58
- }
59
- expressions.push({
60
- start: open,
61
- end: close,
62
- expression_text: code.slice(open + 1, close).trim(),
63
- attribute_name: find_attribute_name_before_expression(code, open)
64
- });
65
- cursor = close + 1;
66
- }
67
- return expressions;
68
- }
69
- function make_expression_diagnostics(code, filename, effect_names, expression) {
70
- const attribute_name = expression.attribute_name;
71
- const expression_text = expression.expression_text;
72
- const is_event_attribute = attribute_name !== void 0 && is_event_attribute_name(attribute_name);
73
- const is_attribute = attribute_name !== void 0;
74
- const loc = get_line_column(code, expression.start);
75
- if (!contains_effect_reference(expression_text, effect_names)) return [];
76
- if (starts_with_yield_star(expression_text)) return [];
77
- if (is_event_attribute && is_callback_expression(expression_text) && contains_yield_star(expression_text)) return [make_diagnostic(loc, make_hidden_event_yield_warning(filename, attribute_name, expression_text))];
78
- if (contains_effect_runner(expression_text, effect_names)) return [make_diagnostic(loc, make_explicit_runner_warning(filename, attribute_name, expression_text))];
79
- if (is_bare_effect_gen(expression_text, effect_names)) return [make_diagnostic(loc, make_bare_effect_gen_warning(filename, attribute_name, expression_text))];
80
- if (is_event_attribute && is_callback_expression(expression_text)) return [make_diagnostic(loc, make_event_callback_returns_effect_warning(filename, attribute_name, expression_text))];
81
- if (is_event_attribute) return [make_diagnostic(loc, make_event_attribute_effect_warning(filename, attribute_name, expression_text))];
82
- if (is_attribute) return [make_diagnostic(loc, make_attribute_effect_warning(filename, attribute_name, expression_text))];
83
- return [make_diagnostic(loc, make_sync_markup_effect_warning(filename, expression_text))];
84
- }
85
- function make_diagnostic(loc, message) {
86
- return {
87
- message,
88
- line: loc.line,
89
- column: loc.column
90
- };
91
- }
92
- function make_hidden_event_yield_warning(filename, attribute_name, expression_text) {
93
- return [
94
- `[svelte-effect-runtime] Detected yield* hidden inside an event callback.`,
95
- `${filename}: ${attribute_name}={${expression_text}}`,
96
- `SER can only lower yield* at the event attribute boundary.`,
97
- `Write the event expression directly, for example: ${attribute_name}={yield* save()}`
98
- ].join("\n");
99
- }
100
- function make_explicit_runner_warning(filename, attribute_name, expression_text) {
101
- return [
102
- `[svelte-effect-runtime] Detected an explicit Effect runner inside Svelte markup.`,
103
- `${filename}: ${attribute_name ? `${attribute_name}={${expression_text}}` : `{${expression_text}}`}`,
104
- `Explicit runners bypass SER cancellation and error handling for markup effects.`,
105
- `Prefer yield* so SER can manage the Effect lifecycle.`
106
- ].join("\n");
107
- }
108
- function make_bare_effect_gen_warning(filename, attribute_name, expression_text) {
109
- const location = attribute_name ? `${attribute_name}={${expression_text}}` : `{${expression_text}}`;
110
- const fixed = attribute_name ? `${attribute_name}={yield* ${expression_text}(function* () { ... })}` : `{yield* ${expression_text}(function* () { ... })}`;
111
- return [
112
- `[svelte-effect-runtime] Detected Effect.gen used as a value instead of an Effect program.`,
113
- `${filename}: ${location}`,
114
- `${expression_text} is a constructor, not the result of running a generator.`,
115
- `Use: ${fixed}`
116
- ].join("\n");
117
- }
118
- function make_event_callback_returns_effect_warning(filename, attribute_name, expression_text) {
119
- return [
120
- `[svelte-effect-runtime] Detected an event callback that returns an Effect but does not run it.`,
121
- `${filename}: ${attribute_name}={${expression_text}}`,
122
- `Svelte will call the callback and receive an Effect value, but SER will not manage it from inside the callback.`,
123
- `Use yield* at the event attribute boundary or explicitly run the Effect if you really want to bypass SER.`
124
- ].join("\n");
125
- }
126
- function make_event_attribute_effect_warning(filename, attribute_name, expression_text) {
127
- const fixed = `${attribute_name}={yield* ${expression_text}}`;
128
- return [
129
- `[svelte-effect-runtime] Detected an event attribute that looks like an Effect but is not written with yield*.`,
130
- `${filename}: ${attribute_name}={${expression_text}}`,
131
- `If you are trying to use Effect in this event handler, use yield* at the beginning.`,
132
- `Use: ${fixed}`
133
- ].join("\n");
134
- }
135
- function make_attribute_effect_warning(filename, attribute_name, expression_text) {
136
- const fixed = `${attribute_name}={yield* ${expression_text}}`;
137
- return [
138
- `[svelte-effect-runtime] Detected an attribute value that looks like an Effect but is not written with yield*.`,
139
- `${filename}: ${attribute_name}={${expression_text}}`,
140
- `Svelte attributes need the resolved Effect value, not the Effect object itself.`,
141
- `Use: ${fixed}`
142
- ].join("\n");
143
- }
144
- function make_sync_markup_effect_warning(filename, expression_text) {
145
- return [
146
- `[svelte-effect-runtime] Detected a markup expression that creates an Effect but is not written with yield*.`,
147
- `${filename}: {${expression_text}}`,
148
- `This expression will produce an Effect value, not its result.`,
149
- `Use yield* where Svelte expects the resolved value.`
150
- ].join("\n");
151
- }
152
- function contains_effect_reference(expression_text, effect_names) {
153
- const name_pattern = make_effect_name_pattern(effect_names);
154
- return new RegExp(`\\b(?:${name_pattern})\\.(?:gen|succeed|fail|try|tryPromise|promise|sync|all|void|log|runPromise|runSync|runFork)\\b`).test(expression_text);
155
- }
156
- function contains_effect_runner(expression_text, effect_names) {
157
- const name_pattern = make_effect_name_pattern(effect_names);
158
- return new RegExp(`\\b(?:${name_pattern})\\.run(?:Promise|Sync|Fork)\\b`).test(expression_text);
159
- }
160
- function is_bare_effect_gen(expression_text, effect_names) {
161
- const name_pattern = make_effect_name_pattern(effect_names);
162
- return new RegExp(`^(?:${name_pattern})\\.gen$`).test(expression_text);
163
- }
164
- function make_effect_name_pattern(effect_names) {
165
- return [...effect_names].map(escape_regexp).sort((a, b) => b.length - a.length).join("|");
166
- }
167
- function starts_with_yield_star(expression_text) {
168
- return /^yield\s*\*/.test(expression_text);
169
- }
170
- function contains_yield_star(expression_text) {
171
- return /\byield\s*\*/.test(expression_text);
172
- }
173
- function is_callback_expression(expression_text) {
174
- return /^(?:async\s+)?(?:\([^)]*\)|[A-Za-z_$][\w$]*)\s*=>/.test(expression_text) || /^(?:async\s+)?function\b/.test(expression_text);
175
- }
176
- function find_attribute_name_before_expression(code, open) {
177
- const tag_start = code.lastIndexOf("<", open);
178
- const last_tag_end = code.lastIndexOf(">", open);
179
- if (tag_start === -1 || tag_start < last_tag_end) return;
180
- return code.slice(tag_start + 1, open).match(/(?:^|\s)([A-Za-z_$:][\w$:-]*)\s*=\s*$/)?.[1];
181
- }
182
- function is_inside_svelte_excluded_block(code, pos) {
183
- const script = find_svelte_tag_range(code, "script", pos);
184
- const style = find_svelte_tag_range(code, "style", pos);
185
- return script !== void 0 && pos < script.end && pos > script.start || style !== void 0 && pos < style.end && pos > style.start;
186
- }
187
- function find_svelte_tag_range(code, tag, after_pos) {
188
- const pattern = new RegExp(`<${tag}\\b[^>]*>([\\s\\S]*?)<\\/${tag}\\s*>`, "gi");
189
- for (const match of code.matchAll(pattern)) {
190
- if (match.index === void 0) continue;
191
- const end = match.index + match[0].length;
192
- if (match.index <= after_pos && after_pos < end) return {
193
- start: match.index,
194
- end
195
- };
196
- }
197
- }
198
- function find_closing_brace(code, start) {
199
- let depth = 0;
200
- for (let i = start; i < code.length; i += 1) {
201
- const ch = code[i];
202
- if (ch === "{" && code[i - 1] !== "$") depth += 1;
203
- else if (ch === "}") {
204
- if (depth === 0) return i;
205
- depth -= 1;
206
- } else if (ch === "'" || ch === "\"" || ch === "`") {
207
- i = skip_string(code, i, ch);
208
- if (i === -1) return -1;
209
- } else if (ch === "/" && code[i + 1] === "/") i = skip_line_comment(code, i);
210
- else if (ch === "/" && code[i + 1] === "*") {
211
- i = skip_block_comment(code, i);
212
- if (i === -1) return -1;
213
- }
214
- }
215
- return -1;
216
- }
217
- function skip_string(code, start, quote) {
218
- for (let i = start + 1; i < code.length; i += 1) {
219
- if (code[i] === "\\") {
220
- i += 1;
221
- continue;
222
- }
223
- if (code[i] === quote) return i;
224
- }
225
- return -1;
226
- }
227
- function skip_line_comment(code, start) {
228
- for (let i = start + 2; i < code.length; i += 1) if (code[i] === "\n") return i;
229
- return code.length;
230
- }
231
- function skip_block_comment(code, start) {
232
- for (let i = start + 2; i < code.length; i += 1) if (code[i] === "*" && code[i + 1] === "/") return i + 1;
233
- return -1;
234
- }
235
- function get_line_column(code, position) {
236
- const lines = code.slice(0, position).split("\n");
237
- return {
238
- line: lines.length,
239
- column: lines.at(-1)?.length ?? 0
240
- };
241
- }
242
- function escape_regexp(value) {
243
- return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
244
- }
245
- //#endregion
246
- //#region src/vite.ts
247
- const default_svelte_component_extensions = [".svelte"];
248
- /**
249
- * Vite plugin for SvelteKit. The server import plugin rewrites server-side
250
- * imports to the server entrypoint; the remote client plugin wraps SvelteKit's
251
- * generated client remote exports in Effect-returning adapters.
252
- *
253
- * @example
254
- * ```ts
255
- * import { effect } from "svelte-effect-runtime/vite";
256
- * import { sveltekit } from "@sveltejs/kit/vite";
257
- *
258
- * export default defineConfig({ plugins: [effect(), sveltekit()] });
259
- * ```
260
- *
261
- * @since 2.0.0
262
- * @param options - Optional configuration.
263
- * @returns Vite plugins that integrate the runtime with SvelteKit.
264
- */
265
- function effect(options) {
266
- const component_filter = make_svelte_component_module_filter();
267
- return [
268
- make_diagnostics_plugin(component_filter),
269
- make_reserved_helper_guard_plugin(component_filter),
270
- make_svelte_transform_plugin(component_filter),
271
- make_server_rewrite_plugin(),
272
- make_remote_client_wrapper_plugin(options)
273
- ];
274
- }
275
- function make_diagnostics_plugin(component_filter) {
276
- const warned_diagnostics = /* @__PURE__ */ new Set();
277
- return {
278
- name: "svelte-effect-runtime:diagnostics",
279
- transform(code, id) {
280
- if (!component_filter.is_module(id)) return;
281
- const clean_id = id.split("?")[0] ?? id;
282
- const diagnostics = find_svelte_effect_diagnostics(code, clean_id);
283
- for (const diagnostic of diagnostics) {
284
- const diagnostic_key = [
285
- clean_id,
286
- diagnostic.line,
287
- diagnostic.column,
288
- diagnostic.message
289
- ].join(":");
290
- if (warned_diagnostics.has(diagnostic_key)) continue;
291
- warned_diagnostics.add(diagnostic_key);
292
- this.warn({
293
- id: clean_id,
294
- message: diagnostic.message,
295
- loc: {
296
- line: diagnostic.line,
297
- column: diagnostic.column
298
- }
299
- });
300
- }
301
- }
302
- };
303
- }
304
- function make_reserved_helper_guard_plugin(component_filter) {
305
- return {
306
- name: "svelte-effect-runtime:reserved-helper-guard",
307
- transform(code, id) {
308
- if (!component_filter.is_module(id) || !has_ser_syntax(code)) return;
309
- const reserved_names = find_reserved_helper_names(code);
310
- if (reserved_names.length === 0) return;
311
- this.warn(make_reserved_helper_warning(reserved_names));
312
- }
313
- };
314
- }
315
- function make_svelte_transform_plugin(component_filter) {
316
- return {
317
- name: "svelte-effect-runtime:svelte-transform",
318
- configResolved(config) {
319
- const extensions = find_svelte_component_extensions(config.plugins);
320
- const conflicting_plugin_names = find_pre_transform_plugin_names(config.plugins);
321
- if (extensions) component_filter.set_extensions(extensions);
322
- if (conflicting_plugin_names.length === 0) return;
323
- config.logger.info(make_pre_transform_plugin_notice(conflicting_plugin_names));
324
- },
325
- async transform(code, id, options) {
326
- if (!component_filter.is_module(id)) return;
327
- const { transform_svelte_effect } = await import("../runtime/transform.js");
328
- const result = transform_svelte_effect(code, id, { target: options?.ssr ? "server" : "client" });
329
- if (result.code === code) return;
330
- return {
331
- code: result.code,
332
- map: null
333
- };
334
- }
335
- };
336
- }
337
- function make_svelte_component_module_filter() {
338
- let extensions = default_svelte_component_extensions;
339
- return {
340
- set_extensions(next_extensions) {
341
- const normalized_extensions = normalize_svelte_component_extensions(next_extensions);
342
- if (normalized_extensions.length === 0) return;
343
- extensions = normalized_extensions;
344
- },
345
- is_module(id) {
346
- return is_svelte_component_module(id, extensions);
347
- }
348
- };
349
- }
350
- function normalize_svelte_component_extensions(extensions) {
351
- const normalized_extensions = extensions.filter((extension) => extension.length > 0).map((extension) => extension.startsWith(".") ? extension : `.${extension}`);
352
- return [...new Set(normalized_extensions)];
353
- }
354
- function find_svelte_component_extensions(plugins) {
355
- return plugins.find(has_svelte_component_extensions)?.api?.options?.extensions;
356
- }
357
- function has_svelte_component_extensions(plugin) {
358
- const extensions = plugin.api?.options?.extensions;
359
- if (!plugin.name.startsWith("vite-plugin-svelte")) return false;
360
- return Array.isArray(extensions) && extensions.every((extension) => typeof extension === "string");
361
- }
362
- function find_pre_transform_plugin_names(plugins) {
363
- return plugins.filter((plugin) => !plugin.name.startsWith("svelte-effect-runtime:") && !is_known_framework_pre_transform_plugin(plugin.name) && has_pre_transform_priority(plugin)).map((plugin) => plugin.name);
364
- }
365
- const ansi_reset = "\x1B[0m";
366
- const ansi_light_green = "\x1B[92m";
367
- function make_pre_transform_plugin_notice(plugin_names) {
368
- const formatted_plugins = plugin_names.map((plugin_name) => ` - ${plugin_name}`).join("\n");
369
- return [
370
- `${ansi_light_green}[svelte-effect-runtime]${ansi_reset} Svelte Effect Runtime noticed possible Vite plugin ordering conflicts.`,
371
- "",
372
- "These plugins run before normal Svelte component transforms:",
373
- formatted_plugins,
374
- "",
375
- "This is usually fine, but if you see Svelte parser errors around <script effect>",
376
- "or yield* in components, one of those plugins may be reading component files before",
377
- "SER has lowered its syntax."
378
- ].join("\n");
379
- }
380
- function is_known_framework_pre_transform_plugin(name) {
381
- return name.startsWith("vite:") || name === "vite-plugin-svelte:preprocess";
382
- }
383
- function has_pre_transform_priority(plugin) {
384
- if (plugin.enforce === "pre" && plugin.transform) return true;
385
- if (typeof plugin.transform === "object" && plugin.transform !== null && "order" in plugin.transform && plugin.transform.order === "pre") return true;
386
- return false;
387
- }
388
- function make_server_rewrite_plugin() {
389
- return {
390
- name: "svelte-effect-runtime:server-imports",
391
- config() {
392
- return { optimizeDeps: { exclude: ["svelte-effect-runtime"] } };
393
- },
394
- transform(code, id) {
395
- if (!is_server_runtime_module(id)) return;
396
- const rewritten = code.replace(/from\s+["']svelte-effect-runtime["']/g, `from "svelte-effect-runtime/server"`).replace(/from\s+["']svelte-effect-runtime\/internal\/generators["']/g, `from "svelte-effect-runtime/server"`);
397
- if (rewritten === code) return;
398
- return {
399
- code: rewritten,
400
- map: null
401
- };
402
- }
403
- };
404
- }
405
- function make_remote_client_wrapper_plugin(options) {
406
- return {
407
- name: "svelte-effect-runtime:remote-client",
408
- enforce: "post",
409
- config() {
410
- return { ssr: { noExternal: ["svelte-effect-runtime"] } };
411
- },
412
- configResolved(config) {
413
- const no_external = config.ssr.noExternal;
414
- const runtime_package = "svelte-effect-runtime";
415
- if (no_external === true) return;
416
- if (Array.isArray(no_external)) {
417
- if (!no_external.some((entry) => entry === runtime_package)) no_external.push(runtime_package);
418
- return;
419
- }
420
- config.ssr.noExternal = [no_external, runtime_package].filter((value) => value !== void 0);
421
- },
422
- async transform(code, id) {
423
- if (!is_remote_module(id) || !code.includes("__sveltekit/remote")) return;
424
- const rewritten = await rewrite_remote_client_exports(code, options);
425
- if (rewritten === code) return;
426
- return {
427
- code: rewritten,
428
- map: null
429
- };
430
- }
431
- };
432
- }
433
- function is_server_runtime_module(id) {
434
- const [filename] = id.split("?", 2);
435
- return /\.(server|remote)(?:\.[cm])?\.[jt]s$/.test(filename) || /(?:^|[\\/])hooks\.server(?:\.[cm])?\.[jt]s$/.test(filename);
436
- }
437
- function is_remote_module(id) {
438
- return /\.(remote|remote\.[cm]?)\.[jt]s(?:\?.*)?$/.test(id) || id.includes(".remote.");
439
- }
440
- function is_svelte_component_module(id, extensions) {
441
- const [filename, query = ""] = id.split("?", 2);
442
- if (!extensions.some((extension) => filename.endsWith(extension))) return false;
443
- if (query.length === 0) return true;
444
- const params = new URLSearchParams(query);
445
- const allowed_params = ["t", "v"];
446
- return [...params.keys()].every((key) => allowed_params.includes(key));
447
- }
448
- function has_ser_syntax(code) {
449
- return /\byield\s*\*/.test(code) || /<script\b[^>]*\beffect(?:[\s=>]|$)/.test(code);
450
- }
451
- function find_reserved_helper_names(code) {
452
- const script_segments = [...code.matchAll(/<script\b[^>]*>([\s\S]*?)<\/script\s*>/gi)].map((match) => match[1] ?? "");
453
- const markup_segments = [...code.matchAll(/\{[^{}]*(?:Dispatcher|Code)[^{}]*\}/g)].map((match) => match[0]);
454
- const search_segments = [...script_segments, ...markup_segments];
455
- return ["Dispatcher", "Code"].filter((name) => search_segments.some((segment) => new RegExp(`\\b${name}\\b`).test(segment)));
456
- }
457
- function make_reserved_helper_warning(names) {
458
- const quoted_names = names.map((name) => `\`${name}\``);
459
- const subject = quoted_names.length === 1 ? quoted_names[0] : `${quoted_names.slice(0, -1).join(", ")} and ${quoted_names[quoted_names.length - 1]}`;
460
- return [`[svelte-effect-runtime] ${subject} ${names.length === 1 ? "is" : "are"} reserved for generated markup helpers.`, `Rename or alias local bindings that use ${subject} before using SER syntax in this component.`].join(" ");
461
- }
462
- /**
463
- * Rewrites SvelteKit's generated client remote module from:
464
- *
465
- * `export const get_post = __remote.query("hash/get_post")`
466
- *
467
- * into an Effect-aware wrapper around the same native function.
468
- *
469
- * @example
470
- * ```ts
471
- * const rewritten = await rewrite_remote_client_exports(remote_module_code);
472
- * ```
473
- *
474
- * @since 2.0.0
475
- * @param code - The generated client remote module code.
476
- * @param options - Optional plugin options.
477
- * @returns A promise that resolves to the rewritten module code.
478
- * @internal
479
- */
480
- async function rewrite_remote_client_exports(code, options) {
481
- return (await import("./remote-client-Bj1pZXgq.js")).rewrite_remote_client_exports(code, options);
482
- }
483
- //#endregion
484
- export { rewrite_remote_client_exports as n, effect as t };
485
-
486
- //# sourceMappingURL=vite-WGlbSnso.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"vite-WGlbSnso.js","names":["candidate"],"sources":["../../../modules/svelte-effect-runtime/src/diagnostics.ts","../../../modules/svelte-effect-runtime/src/vite.ts"],"sourcesContent":["import { is_event_attribute_name } from \"./markup/event-attributes.ts\";\n\n/**\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 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":";;;;;;;;;;;;;;;;;;AAkCA,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,IAA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iB,GAAG,eAAe;CAE/D,OAAO,CAAC,cAAc,MAAM,CAAC,CAAC,QAAQ,SACrC,gBAAgB,MAAM,YAAY,IAAI,OAAO,MAAM,KAAK,IAAI,CAAC,CAAC,KAAK,OAAO,CAAC,CAC5E;AACD;AAEA,SAAS,6BAA6B,OAAyB;CAC9D,MAAM,eAAe,MAAM,KAAK,SAAS,KAAK,KAAK,GAAG;CACtD,MAAM,UACL,aAAa,WAAW,IACrB,aAAa,KACb,GAAG,aAAa,MAAM,GAAG,EAAE,CAAC,CAAC,KAAK,IAAI,EAAE,OACxC,aAAa,aAAa,SAAS;CAIvC,OAAO,CACN,2BAA2B,QAAQ,GAHvB,MAAM,WAAW,IAAI,OAAO,MAGG,0CAC3C,2CAA2C,QAAQ,4CACpD,CAAC,CAAC,KAAK,GAAG;AACX;;;;;;;;;;;;;;;;;;;AAoBA,eAAsB,8BACrB,MACA,SACkB;CAGlB,QAAO,MAFqB,OAAO,+BAAA,CAEd,8BAA8B,MAAM,OAAO;AACjE"}
@@ -1,29 +0,0 @@
1
- import type { RemoteFailure } from "../shared.js";
2
- import { Effect } from "effect";
3
- /**
4
- * Wraps a promise-producing remote operation in an Effect with failure mapping.
5
- *
6
- * @example
7
- * ```ts
8
- * const program = make_effect_from_promise(() => native_remote(input));
9
- * ```
10
- *
11
- * @since 2.0.0
12
- * @param run - Promise-producing operation that invokes a native remote helper.
13
- * @returns Effect that maps thrown values into remote failures.
14
- */
15
- export declare function MakeEffectFromPromise<Output, ErrorType = never>(run: () => Promise<Output>): Effect.Effect<Output, RemoteFailure<ErrorType>>;
16
- /**
17
- * Compatibility alias for {@link MakeEffectFromPromise}.
18
- *
19
- * @example
20
- * ```ts
21
- * const program = make_effect_from_promise(() => native_remote(input));
22
- * ```
23
- *
24
- * @since 2.0.0
25
- * @param run - Promise-producing operation that invokes a native remote helper.
26
- * @returns Effect that maps thrown values into remote failures.
27
- * @internal
28
- */
29
- export declare const make_effect_from_promise: typeof MakeEffectFromPromise;
@@ -1,42 +0,0 @@
1
- import type { RemoteFailure } from "../shared.js";
2
- /**
3
- * Decodes a raw wire value into a remote failure when it uses the runtime
4
- * failure envelope.
5
- *
6
- * @example
7
- * ```ts
8
- * const failure = decode_remote_error(body);
9
- * ```
10
- *
11
- * @since 2.0.0
12
- * @param raw - Raw value received from the network or SvelteKit error body.
13
- * @param decode - Optional devalue decoder for custom error payloads.
14
- * @returns The decoded failure/value, or a transport error when decoding fails.
15
- */
16
- export declare function decode_remote_error<ErrorType = never>(raw: unknown, decode?: (encoded: string) => unknown): RemoteFailure<ErrorType> | unknown;
17
- /**
18
- * Checks whether a decoded value is a tagged remote failure.
19
- *
20
- * @example
21
- * ```ts
22
- * if (is_decoded_remote_failure(value)) throw value;
23
- * ```
24
- *
25
- * @since 2.0.0
26
- * @param value - Value to inspect.
27
- * @returns Whether the value carries a `_tag` discriminator.
28
- */
29
- export declare function is_decoded_remote_failure(value: unknown): value is RemoteFailure<never>;
30
- /**
31
- * Normalizes native thrown values into the runtime's remote failure model.
32
- *
33
- * @example
34
- * ```ts
35
- * const failure = normalize_native_error(error);
36
- * ```
37
- *
38
- * @since 2.0.0
39
- * @param error - Unknown value thrown by a native remote helper.
40
- * @returns A typed remote failure.
41
- */
42
- export declare function normalize_native_error<ErrorType = never>(error: unknown): RemoteFailure<ErrorType>;