svelte-effect-runtime 1.3.2 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/dist/chunks/{client-DkW4e4dD.js → client-vV6UAwoP.js} +3 -3
  2. package/dist/chunks/client-vV6UAwoP.js.map +1 -0
  3. package/dist/chunks/{effect-CL8GJs8A.js → effect-Cx8OzrcW.js} +3 -3
  4. package/dist/chunks/{effect-CL8GJs8A.js.map → effect-Cx8OzrcW.js.map} +1 -1
  5. package/dist/chunks/effect-compat-BhW0YPIs.js.map +1 -1
  6. package/dist/chunks/{markup-BpSHnnYD.js → markup-BMn2sQOB.js} +3 -1
  7. package/dist/chunks/{markup-BpSHnnYD.js.map → markup-BMn2sQOB.js.map} +1 -1
  8. package/dist/chunks/{preprocess-CtLrnJcK.js → preprocess-CGKEA3Py.js} +13 -8
  9. package/dist/chunks/preprocess-CGKEA3Py.js.map +1 -0
  10. package/dist/chunks/{server-CQcF2W3T.js → server-7YVuxUNk.js} +53 -2
  11. package/dist/chunks/server-7YVuxUNk.js.map +1 -0
  12. package/dist/chunks/v3-D0c0MKPf.js +1 -0
  13. package/dist/chunks/v4-MMhHmzIG.js +1 -0
  14. package/dist/chunks/{vite-DqjXRZd4.js → vite-C8ujN78r.js} +14 -5
  15. package/dist/chunks/vite-C8ujN78r.js.map +1 -0
  16. package/dist/client.js +1 -1
  17. package/dist/effect.js +1 -1
  18. package/dist/internal/markup.js +1 -1
  19. package/dist/internal/remote-client.js +3 -3
  20. package/dist/internal/remote-client.js.map +1 -1
  21. package/dist/internal/remote-shared.d.ts +134 -1
  22. package/dist/internal/remote-shared.js +64 -0
  23. package/dist/internal/remote-shared.js.map +1 -1
  24. package/dist/internal/transform.d.ts +7 -0
  25. package/dist/internal/transform.js +172 -15
  26. package/dist/internal/transform.js.map +1 -1
  27. package/dist/language-server.js +1 -1
  28. package/dist/mod.d.ts +21 -0
  29. package/dist/mod.js +2 -2
  30. package/dist/preprocess.d.ts +5 -0
  31. package/dist/preprocess.js +7 -2
  32. package/dist/preprocess.js.map +1 -1
  33. package/dist/root-node.js +4 -4
  34. package/dist/root-node.js.map +1 -1
  35. package/dist/server.d.ts +25 -0
  36. package/dist/server.js +26 -1
  37. package/dist/server.js.map +1 -1
  38. package/dist/v3/client.d.ts +24 -0
  39. package/dist/v3/mod.d.ts +24 -0
  40. package/dist/v3/server.d.ts +106 -0
  41. package/dist/v4/effect.js +1 -1
  42. package/dist/v4/mod.d.ts +24 -0
  43. package/dist/v4/mod.js +2 -2
  44. package/dist/v4/preprocess.d.ts +4 -0
  45. package/dist/v4/preprocess.js +6 -2
  46. package/dist/v4/preprocess.js.map +1 -1
  47. package/dist/v4/root-node.js +2 -2
  48. package/dist/v4/server.d.ts +196 -0
  49. package/dist/v4/server.js +50 -1
  50. package/dist/v4/server.js.map +1 -1
  51. package/dist/v4/vite.js +1 -1
  52. package/dist/vite.js +1 -1
  53. package/package.json +1 -1
  54. package/dist/chunks/client-DkW4e4dD.js.map +0 -1
  55. package/dist/chunks/preprocess-CtLrnJcK.js.map +0 -1
  56. package/dist/chunks/server-CQcF2W3T.js.map +0 -1
  57. package/dist/chunks/v3-p8V3Drpp.js +0 -1
  58. package/dist/chunks/v4-DIhYCbb_.js +0 -1
  59. package/dist/chunks/vite-DqjXRZd4.js.map +0 -1
@@ -35,6 +35,7 @@ function transformEffectScript(content, options) {
35
35
  const sourceFile = ts.createSourceFile(options.filename, content, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
36
36
  const effectStatements = [];
37
37
  const runtimeStatements = [];
38
+ const pendingRelocations = [];
38
39
  const magicString = new MagicString(content);
39
40
  const effectBoundBindings = /* @__PURE__ */ new Set();
40
41
  for (const statement of sourceFile.statements) {
@@ -44,6 +45,7 @@ function transformEffectScript(content, options) {
44
45
  if (transformed.hoistedText.length === 0) magicString.remove(statement.getFullStart(), statement.end);
45
46
  else magicString.overwrite(statement.getStart(sourceFile), statement.end, transformed.hoistedText);
46
47
  runtimeStatements.push(...transformed.effectTexts);
48
+ pendingRelocations.push(...transformed.pendingRelocations);
47
49
  for (const bindingName of transformed.loweredBindings) effectBoundBindings.add(bindingName);
48
50
  continue;
49
51
  }
@@ -54,6 +56,13 @@ function transformEffectScript(content, options) {
54
56
  node: statement,
55
57
  text: normalizeStatementText(sliceNode(content, statement))
56
58
  });
59
+ pendingRelocations.push({
60
+ originalStart: statement.getStart(sourceFile),
61
+ originalEnd: statement.end,
62
+ generatedSnippet: normalizeStatementText(sliceNode(content, statement)),
63
+ generatedInnerStart: 0,
64
+ generatedInnerEnd: normalizeStatementText(sliceNode(content, statement)).length
65
+ });
57
66
  }
58
67
  for (const statement of [...effectStatements].reverse()) magicString.remove(statement.node.getFullStart(), statement.node.end);
59
68
  const allRuntimeStatements = [...runtimeStatements, ...effectStatements.map((statement) => statement.text)];
@@ -61,13 +70,15 @@ function transformEffectScript(content, options) {
61
70
  magicString.prepend(makeInjectedImports(options));
62
71
  magicString.append(makeRuntimeBlock(allRuntimeStatements));
63
72
  }
73
+ const code = magicString.toString();
64
74
  return {
65
- code: magicString.toString(),
75
+ code,
66
76
  map: magicString.generateMap({
67
77
  hires: true,
68
78
  includeContent: true,
69
79
  source: options.filename
70
- })
80
+ }),
81
+ relocations: resolvePendingRelocations(pendingRelocations, code)
71
82
  };
72
83
  }
73
84
  function isHoistedStatement(statement) {
@@ -91,34 +102,60 @@ function transformVariableStatement(statement, content, filename, effectBoundBin
91
102
  return {
92
103
  effectTexts: [],
93
104
  hoistedText: normalizeStatementText(sliceNode(content, statement)),
94
- loweredBindings: []
105
+ loweredBindings: [],
106
+ pendingRelocations: [],
107
+ usesPendingYieldHelper: false
95
108
  };
96
109
  }
97
110
  const effectTexts = [];
98
111
  const hoistedDeclarations = [];
99
112
  const loweredBindings = [];
113
+ const pendingRelocations = [];
100
114
  for (const declaration of statement.declarationList.declarations) {
101
115
  if (declaration.initializer && containsTopLevelAwait(declaration.initializer)) {
102
116
  const statementText = normalizeStatementText(sliceNode(content, statement));
103
117
  throw new Error(`${filename}: declarations in <script effect> cannot depend on await.\nUse yield* Effect.promise(...) or yield* Effect.tryPromise(...) instead.\n\nProblematic statement:\n${statementText}`);
104
118
  }
105
119
  if (declaration.initializer && isRuneInitializer(declaration.initializer)) {
106
- hoistedDeclarations.push(`${getDeclarationKind(statement.declarationList.flags)} ${normalizeStatementText(sliceNode(content, declaration))};`);
120
+ const renderedDeclaration = `${getDeclarationKind(statement.declarationList.flags)} ${normalizeStatementText(sliceNode(content, declaration))};`;
121
+ hoistedDeclarations.push(renderedDeclaration);
122
+ pendingRelocations.push(...make_declaration_relocations(declaration, renderedDeclaration, content));
107
123
  continue;
108
124
  }
109
125
  if (shouldHoistDeclaration(statement.declarationList.flags, declaration, effectBoundBindings)) {
110
- hoistedDeclarations.push(`${getDeclarationKind(statement.declarationList.flags)} ${normalizeStatementText(sliceNode(content, declaration))};`);
126
+ const renderedDeclaration = `${getDeclarationKind(statement.declarationList.flags)} ${normalizeStatementText(sliceNode(content, declaration))};`;
127
+ hoistedDeclarations.push(renderedDeclaration);
128
+ pendingRelocations.push(...make_declaration_relocations(declaration, renderedDeclaration, content));
111
129
  continue;
112
130
  }
113
131
  const bindingNames = extractBindingNames(declaration.name);
114
- for (const bindingName of bindingNames) hoistedDeclarations.push(makeStateDeclaration(bindingName, declaration, content));
132
+ const helper = create_lowered_declaration_helper(declaration, content);
133
+ if (helper) {
134
+ hoistedDeclarations.push(helper.declarationText);
135
+ pendingRelocations.push(helper.expressionRelocation);
136
+ }
137
+ if (helper?.tempName) hoistedDeclarations.push(makeTypedStateBinding(helper.tempName, helper.stateTypeText));
138
+ for (const bindingName of bindingNames) {
139
+ const stateDeclaration = makeStateDeclaration(bindingName, declaration, content, helper?.tempName ? null : helper?.stateTypeText);
140
+ hoistedDeclarations.push(stateDeclaration.code);
141
+ pendingRelocations.push(...stateDeclaration.pendingRelocations);
142
+ }
115
143
  loweredBindings.push(...bindingNames);
116
- if (declaration.initializer) effectTexts.push(makeEffectAssignment(declaration.name, declaration.initializer, content));
144
+ if (declaration.initializer) if (helper?.tempName) {
145
+ effectTexts.push(`${helper.tempName} = ${helper.assignmentExpression};`);
146
+ effectTexts.push(makeEffectAssignment(declaration.name, helper.tempName, content));
147
+ } else {
148
+ const effectAssignment = helper ? `${bindingNames[0]} = ${helper.assignmentExpression};` : makeEffectAssignment(declaration.name, declaration.initializer, content);
149
+ effectTexts.push(effectAssignment);
150
+ if (!helper) pendingRelocations.push(makeEffectAssignmentRelocation(declaration.initializer, effectAssignment, content));
151
+ }
117
152
  }
118
153
  return {
119
154
  effectTexts,
120
155
  hoistedText: hoistedDeclarations.join("\n"),
121
- loweredBindings
156
+ loweredBindings,
157
+ pendingRelocations,
158
+ usesPendingYieldHelper: false
122
159
  };
123
160
  }
124
161
  function shouldHoistDeclaration(flags, declaration, effectBoundBindings) {
@@ -178,16 +215,45 @@ function getDeclarationKind(flags) {
178
215
  if ((flags & ts.NodeFlags.Let) !== 0) return "let";
179
216
  return "var";
180
217
  }
181
- function makeStateDeclaration(name, declaration, content) {
182
- if (ts.isIdentifier(declaration.name) && declaration.type) return `let ${name} = $state<${normalizeStatementText(sliceNode(content, declaration.type))} | undefined>(undefined);`;
183
- return `let ${name} = $state<any>(undefined);`;
218
+ function makeStateDeclaration(name, declaration, content, inferredTypeText) {
219
+ let stateTypeText = null;
220
+ if (ts.isIdentifier(declaration.name) && declaration.type) stateTypeText = normalizeStatementText(sliceNode(content, declaration.type));
221
+ else if (inferredTypeText) stateTypeText = inferredTypeText;
222
+ const code = stateTypeText ? makeTypedStateBinding(name, stateTypeText) : `let ${name} = $state<any>(undefined);`;
223
+ const nameStart = code.indexOf(name);
224
+ const pendingRelocations = [{
225
+ originalStart: find_binding_name_start(declaration.name, name),
226
+ originalEnd: find_binding_name_end(declaration.name, name),
227
+ generatedSnippet: "",
228
+ generatedInnerStart: nameStart,
229
+ generatedInnerEnd: nameStart + name.length
230
+ }];
231
+ pendingRelocations[0] = {
232
+ ...pendingRelocations[0],
233
+ generatedSnippet: code
234
+ };
235
+ return {
236
+ code,
237
+ pendingRelocations
238
+ };
184
239
  }
185
240
  function makeEffectAssignment(name, initializer, content) {
186
241
  const target = normalizeStatementText(sliceNode(content, name));
187
- const expression = normalizeStatementText(sliceNode(content, initializer));
242
+ const expression = typeof initializer === "string" ? initializer : normalizeStatementText(sliceNode(content, initializer));
188
243
  if (ts.isIdentifier(name)) return `${target} = ${expression};`;
189
244
  return `(${target} = ${expression});`;
190
245
  }
246
+ function makeEffectAssignmentRelocation(initializer, effectAssignment, content) {
247
+ const expression = normalizeStatementText(sliceNode(content, initializer));
248
+ const generatedInnerStart = effectAssignment.lastIndexOf(expression);
249
+ return {
250
+ originalStart: initializer.getStart(),
251
+ originalEnd: initializer.end,
252
+ generatedSnippet: effectAssignment,
253
+ generatedInnerStart,
254
+ generatedInnerEnd: generatedInnerStart + expression.length
255
+ };
256
+ }
191
257
  function extractBindingNames(name) {
192
258
  if (ts.isIdentifier(name)) return [name.text];
193
259
  const names = [];
@@ -210,6 +276,10 @@ function containsYieldStar(node) {
210
276
  if (ts.isBinaryExpression(node) && node.operatorToken.kind === ts.SyntaxKind.AsteriskToken && ts.isIdentifier(node.left) && node.left.text === "yield") return true;
211
277
  return node.getChildren().some((child) => isFunctionBoundary(child) ? false : containsYieldStar(child));
212
278
  }
279
+ function getYieldOperand(node) {
280
+ if (node && ts.isBinaryExpression(node) && node.operatorToken.kind === ts.SyntaxKind.AsteriskToken && ts.isIdentifier(node.left) && node.left.text === "yield") return node.right;
281
+ return null;
282
+ }
213
283
  function containsTopLevelAwait(node) {
214
284
  if (ts.isAwaitExpression(node)) return true;
215
285
  return node.getChildren().some((child) => isFunctionBoundary(child) ? false : containsTopLevelAwait(child));
@@ -229,12 +299,83 @@ function indentBlock(text, indent) {
229
299
  function makeInjectedImports(options) {
230
300
  const runtimeModuleId = options.runtimeModuleId ?? DEFAULT_RUNTIME_MODULE_ID;
231
301
  const effectModuleId = options.effectModuleId ?? DEFAULT_EFFECT_MODULE_ID;
232
- return [
302
+ const lines = [
233
303
  `import { onMount as __svelteEffectRuntimeOnMount } from "${options.svelteModuleId ?? DEFAULT_SVELTE_MODULE_ID}";`,
234
304
  `import { Effect as __svelteEffectRuntimeEffect } from "${effectModuleId}";`,
235
305
  `import { get_effect_runtime_or_throw as __svelteEffectRuntimeGetRuntime, run_component_effect as __svelteEffectRuntimeRunComponentEffect } from "${runtimeModuleId}";`,
236
- ""
237
- ].join("\n");
306
+ `type __svelteEffectRuntimeYielded<T> = T extends __svelteEffectRuntimeEffect.Effect<infer A, any, any> ? A : T;`
307
+ ];
308
+ lines.push("");
309
+ return lines.join("\n");
310
+ }
311
+ function makeTypedStateBinding(name, stateTypeText) {
312
+ return `let ${name}: ${stateTypeText} = $state(undefined as unknown as ${stateTypeText});`;
313
+ }
314
+ function create_lowered_declaration_helper(declaration, content) {
315
+ if (declaration.type || !declaration.initializer) return null;
316
+ const bindingNames = extractBindingNames(declaration.name);
317
+ const suffix = declaration.getStart();
318
+ const helperName = `__svelteEffectRuntime_${bindingNames[0] ?? "binding"}_${suffix}`;
319
+ const expressionNode = getYieldOperand(declaration.initializer) ?? declaration.initializer;
320
+ const expressionText = normalizeStatementText(sliceNode(content, expressionNode));
321
+ const declarationText = `const ${helperName} = () => ${expressionText};`;
322
+ const yieldedExpression = getYieldOperand(declaration.initializer);
323
+ return {
324
+ declarationText,
325
+ stateTypeText: yieldedExpression ? `__svelteEffectRuntimeYielded<ReturnType<typeof ${helperName}>>` : `ReturnType<typeof ${helperName}>`,
326
+ assignmentExpression: yieldedExpression ? `yield* ${helperName}()` : `${helperName}()`,
327
+ tempName: ts.isIdentifier(declaration.name) ? void 0 : `__svelteEffectRuntimeTemp_${suffix}`,
328
+ expressionRelocation: {
329
+ originalStart: expressionNode.getStart(),
330
+ originalEnd: expressionNode.end,
331
+ generatedSnippet: declarationText,
332
+ generatedInnerStart: declarationText.lastIndexOf(expressionText),
333
+ generatedInnerEnd: declarationText.lastIndexOf(expressionText) + expressionText.length
334
+ }
335
+ };
336
+ }
337
+ function make_declaration_relocations(declaration, renderedDeclaration, content) {
338
+ const relocations = [];
339
+ if (ts.isIdentifier(declaration.name)) {
340
+ const nameStart = renderedDeclaration.indexOf(declaration.name.text);
341
+ relocations.push({
342
+ originalStart: declaration.name.getStart(),
343
+ originalEnd: declaration.name.end,
344
+ generatedSnippet: renderedDeclaration,
345
+ generatedInnerStart: nameStart,
346
+ generatedInnerEnd: nameStart + declaration.name.text.length
347
+ });
348
+ }
349
+ if (declaration.initializer) {
350
+ const initializerText = normalizeStatementText(sliceNode(content, declaration.initializer));
351
+ const initializerStart = renderedDeclaration.lastIndexOf(initializerText);
352
+ if (initializerStart >= 0) relocations.push({
353
+ originalStart: declaration.initializer.getStart(),
354
+ originalEnd: declaration.initializer.end,
355
+ generatedSnippet: renderedDeclaration,
356
+ generatedInnerStart: initializerStart,
357
+ generatedInnerEnd: initializerStart + initializerText.length
358
+ });
359
+ }
360
+ return relocations;
361
+ }
362
+ function find_binding_name_start(name, bindingName) {
363
+ if (ts.isIdentifier(name)) return name.text === bindingName ? name.getStart() : -1;
364
+ for (const element of name.elements) {
365
+ if (ts.isOmittedExpression(element)) continue;
366
+ const start = find_binding_name_start(element.name, bindingName);
367
+ if (start !== -1) return start;
368
+ }
369
+ return -1;
370
+ }
371
+ function find_binding_name_end(name, bindingName) {
372
+ if (ts.isIdentifier(name)) return name.text === bindingName ? name.end : -1;
373
+ for (const element of name.elements) {
374
+ if (ts.isOmittedExpression(element)) continue;
375
+ const end = find_binding_name_end(element.name, bindingName);
376
+ if (end !== -1) return end;
377
+ }
378
+ return -1;
238
379
  }
239
380
  function makeRuntimeBlock(statements) {
240
381
  return [
@@ -255,6 +396,22 @@ function makeRuntimeBlock(statements) {
255
396
  ""
256
397
  ].join("\n");
257
398
  }
399
+ function resolvePendingRelocations(pendingRelocations, code) {
400
+ const relocations = [];
401
+ let searchStart = 0;
402
+ for (const relocation of pendingRelocations) {
403
+ const generatedStart = code.indexOf(relocation.generatedSnippet, searchStart);
404
+ if (generatedStart === -1) continue;
405
+ searchStart = generatedStart + relocation.generatedSnippet.length;
406
+ relocations.push({
407
+ originalStart: relocation.originalStart,
408
+ originalEnd: relocation.originalEnd,
409
+ generatedStart: generatedStart + relocation.generatedInnerStart,
410
+ generatedEnd: generatedStart + relocation.generatedInnerEnd
411
+ });
412
+ }
413
+ return relocations;
414
+ }
258
415
  //#endregion
259
416
  export { transformEffectScript };
260
417
 
@@ -1 +1 @@
1
- {"version":3,"file":"transform.js","names":[],"sources":["../../../modules/svelte-effect-runtime/internal/transform.ts"],"sourcesContent":["import MagicString, { type SourceMap } from \"magic-string\";\nimport ts from \"typescript\";\nimport type { EffectPreprocessOptions } from \"$/preprocess.ts\";\n\nconst DEFAULT_RUNTIME_MODULE_ID = \"svelte-effect-runtime\";\nconst DEFAULT_EFFECT_MODULE_ID = \"effect\";\nconst DEFAULT_SVELTE_MODULE_ID = \"svelte\";\n\nconst RUNE_IDENTIFIERS = new Set([\n \"$bindable\",\n \"$derived\",\n \"$effect\",\n \"$host\",\n \"$inspect\",\n \"$props\",\n \"$state\",\n]);\n\ninterface TransformEffectScriptOptions extends EffectPreprocessOptions {\n filename: string;\n}\n\ninterface TransformEffectScriptResult {\n code: string;\n map: SourceMap;\n}\n\ninterface VariableStatementTransform {\n effectTexts: string[];\n hoistedText: string;\n loweredBindings: string[];\n}\n\nconst HOISTED_KINDS = new Set<ts.SyntaxKind>([\n ts.SyntaxKind.ClassDeclaration,\n ts.SyntaxKind.EmptyStatement,\n ts.SyntaxKind.EnumDeclaration,\n ts.SyntaxKind.ExportAssignment,\n ts.SyntaxKind.ExportDeclaration,\n ts.SyntaxKind.FunctionDeclaration,\n ts.SyntaxKind.ImportDeclaration,\n ts.SyntaxKind.ImportEqualsDeclaration,\n ts.SyntaxKind.InterfaceDeclaration,\n ts.SyntaxKind.ModuleDeclaration,\n ts.SyntaxKind.TypeAliasDeclaration,\n]);\n\nconst HOISTED_CALL_IDENTIFIERS = new Set([\n \"$effect\",\n \"__svelteEffectRuntimeMarkupOnDestroy\",\n \"onDestroy\",\n]);\n\nexport function transformEffectScript(\n content: string,\n options: TransformEffectScriptOptions,\n): TransformEffectScriptResult {\n const sourceFile = ts.createSourceFile(\n options.filename,\n content,\n ts.ScriptTarget.Latest,\n true,\n ts.ScriptKind.TS,\n );\n\n const effectStatements: Array<{ node: ts.Statement; text: string }> = [];\n const runtimeStatements: string[] = [];\n const magicString = new MagicString(content);\n const effectBoundBindings = new Set<string>();\n\n for (const statement of sourceFile.statements) {\n if (ts.isVariableStatement(statement)) {\n if (isGeneratedMarkupHelperStatement(statement, content)) {\n continue;\n }\n\n const transformed = transformVariableStatement(\n statement,\n content,\n options.filename,\n effectBoundBindings,\n );\n\n if (transformed.hoistedText.length === 0) {\n magicString.remove(statement.getFullStart(), statement.end);\n } else {\n magicString.overwrite(\n statement.getStart(sourceFile),\n statement.end,\n transformed.hoistedText,\n );\n }\n\n runtimeStatements.push(...transformed.effectTexts);\n for (const bindingName of transformed.loweredBindings) {\n effectBoundBindings.add(bindingName);\n }\n continue;\n }\n\n if (isHoistedExpressionStatement(statement)) {\n continue;\n }\n\n if (isHoistedStatement(statement)) {\n continue;\n }\n\n if (containsTopLevelAwait(statement)) {\n throw new Error(\n `${options.filename}: top-level await is not supported in <script effect>. Use yield* Effect.promise(...) or yield* Effect.tryPromise(...) instead.`,\n );\n }\n\n effectStatements.push({\n node: statement,\n text: normalizeStatementText(sliceNode(content, statement)),\n });\n }\n\n for (const statement of [...effectStatements].reverse()) {\n magicString.remove(statement.node.getFullStart(), statement.node.end);\n }\n\n const allRuntimeStatements = [\n ...runtimeStatements,\n ...effectStatements.map((statement) => statement.text),\n ];\n\n if (allRuntimeStatements.length > 0) {\n magicString.prepend(makeInjectedImports(options));\n magicString.append(makeRuntimeBlock(allRuntimeStatements));\n }\n\n return {\n code: magicString.toString(),\n map: magicString.generateMap({\n hires: true,\n includeContent: true,\n source: options.filename,\n }),\n };\n}\n\nfunction isHoistedStatement(statement: ts.Statement): boolean {\n return HOISTED_KINDS.has(statement.kind);\n}\n\nfunction isHoistedExpressionStatement(statement: ts.Statement): boolean {\n if (!ts.isExpressionStatement(statement)) {\n return false;\n }\n\n if (!ts.isCallExpression(statement.expression)) {\n return false;\n }\n\n return getCalledIdentifierText(statement.expression.expression) !==\n undefined &&\n HOISTED_CALL_IDENTIFIERS.has(\n getCalledIdentifierText(statement.expression.expression)!,\n );\n}\n\nfunction getCalledIdentifierText(\n expression: ts.Expression,\n): string | undefined {\n if (ts.isIdentifier(expression)) {\n return expression.text;\n }\n\n if (ts.isPropertyAccessExpression(expression)) {\n const base = getCalledIdentifierText(expression.expression);\n return base ? `${base}.${expression.name.text}` : expression.name.text;\n }\n\n return undefined;\n}\n\nfunction transformVariableStatement(\n statement: ts.VariableStatement,\n content: string,\n filename: string,\n effectBoundBindings: ReadonlySet<string>,\n): VariableStatementTransform {\n if ((statement.modifiers?.length ?? 0) > 0) {\n validateModifiedVariableStatement(statement, content, filename);\n return {\n effectTexts: [],\n hoistedText: normalizeStatementText(sliceNode(content, statement)),\n loweredBindings: [],\n };\n }\n\n const effectTexts: string[] = [];\n const hoistedDeclarations: string[] = [];\n const loweredBindings: string[] = [];\n\n for (const declaration of statement.declarationList.declarations) {\n if (\n declaration.initializer && containsTopLevelAwait(declaration.initializer)\n ) {\n const statementText = normalizeStatementText(\n sliceNode(content, statement),\n );\n\n throw new Error(\n `${filename}: declarations in <script effect> cannot depend on await.\\nUse yield* Effect.promise(...) or yield* Effect.tryPromise(...) instead.\\n\\nProblematic statement:\\n${statementText}`,\n );\n }\n\n if (declaration.initializer && isRuneInitializer(declaration.initializer)) {\n hoistedDeclarations.push(\n `${getDeclarationKind(statement.declarationList.flags)} ${\n normalizeStatementText(sliceNode(content, declaration))\n };`,\n );\n continue;\n }\n\n if (\n shouldHoistDeclaration(\n statement.declarationList.flags,\n declaration,\n effectBoundBindings,\n )\n ) {\n hoistedDeclarations.push(\n `${getDeclarationKind(statement.declarationList.flags)} ${\n normalizeStatementText(sliceNode(content, declaration))\n };`,\n );\n continue;\n }\n\n const bindingNames = extractBindingNames(declaration.name);\n\n for (const bindingName of bindingNames) {\n hoistedDeclarations.push(\n makeStateDeclaration(bindingName, declaration, content),\n );\n }\n loweredBindings.push(...bindingNames);\n\n if (declaration.initializer) {\n effectTexts.push(\n makeEffectAssignment(\n declaration.name,\n declaration.initializer,\n content,\n ),\n );\n }\n }\n\n return {\n effectTexts,\n hoistedText: hoistedDeclarations.join(\"\\n\"),\n loweredBindings,\n };\n}\n\nfunction shouldHoistDeclaration(\n flags: ts.NodeFlags,\n declaration: ts.VariableDeclaration,\n effectBoundBindings: ReadonlySet<string>,\n): boolean {\n if ((flags & ts.NodeFlags.Const) === 0) {\n return false;\n }\n\n if (!declaration.initializer) {\n return false;\n }\n\n if (\n containsYieldStar(declaration.initializer) ||\n containsTopLevelAwait(declaration.initializer)\n ) {\n return false;\n }\n\n return !referencesEffectBoundBindings(\n declaration.initializer,\n effectBoundBindings,\n );\n}\n\nfunction referencesEffectBoundBindings(\n node: ts.Node,\n effectBoundBindings: ReadonlySet<string>,\n): boolean {\n const localScopes: Array<Set<string>> = [new Set()];\n let found = false;\n\n const visit = (current: ts.Node): void => {\n if (found) {\n return;\n }\n\n if (\n ts.isArrowFunction(current) || ts.isFunctionDeclaration(current) ||\n ts.isFunctionExpression(current)\n ) {\n const scope = new Set<string>();\n\n if (current.name) {\n scope.add(current.name.text);\n }\n\n for (const parameter of current.parameters) {\n declareBindingInto(scope, parameter.name);\n }\n\n localScopes.unshift(scope);\n current.forEachChild(visit);\n localScopes.shift();\n return;\n }\n\n if (ts.isIdentifier(current)) {\n if (\n !isSkippedReference(current) &&\n effectBoundBindings.has(current.text) &&\n !localScopes.some((scope) => scope.has(current.text))\n ) {\n found = true;\n }\n\n return;\n }\n\n current.forEachChild(visit);\n };\n\n const declareBindingInto = (\n scope: Set<string>,\n name: ts.BindingName,\n ): void => {\n if (ts.isIdentifier(name)) {\n scope.add(name.text);\n return;\n }\n\n for (const element of name.elements) {\n if (ts.isOmittedExpression(element)) {\n continue;\n }\n\n declareBindingInto(scope, element.name);\n }\n };\n\n visit(node);\n return found;\n}\n\nfunction isSkippedReference(identifier: ts.Identifier): boolean {\n const parent = identifier.parent;\n\n return ts.isPropertyAccessExpression(parent) && parent.name === identifier ||\n ts.isPropertyAssignment(parent) && parent.name === identifier ||\n ts.isShorthandPropertyAssignment(parent) &&\n parent.objectAssignmentInitializer === identifier ||\n ts.isBindingElement(parent) && parent.propertyName === identifier ||\n ts.isImportSpecifier(parent) ||\n ts.isExportSpecifier(parent) ||\n ts.isLabeledStatement(parent) && parent.label === identifier;\n}\n\nfunction isGeneratedMarkupHelperStatement(\n statement: ts.VariableStatement,\n content: string,\n): boolean {\n return statement.declarationList.declarations.every((declaration) =>\n extractBindingNames(declaration.name).every((name) =>\n name.startsWith(\"__svelteEffectRuntimeMarkup\")\n ) ||\n normalizeStatementText(sliceNode(content, declaration)).startsWith(\n \"__svelteEffectRuntimeMarkup\",\n )\n );\n}\n\nfunction validateModifiedVariableStatement(\n statement: ts.VariableStatement,\n content: string,\n filename: string,\n): void {\n for (const declaration of statement.declarationList.declarations) {\n if (\n declaration.initializer &&\n (containsYieldStar(declaration.initializer) ||\n containsTopLevelAwait(declaration.initializer))\n ) {\n const statementText = normalizeStatementText(\n sliceNode(content, statement),\n );\n\n throw new Error(\n `${filename}: declarations with modifiers cannot depend on yield* or await in <script effect> right now.\\nSplit the declaration into a plain top-level binding and assign inside the effect body instead.\\n\\nProblematic statement:\\n${statementText}`,\n );\n }\n }\n}\n\nfunction getDeclarationKind(flags: ts.NodeFlags): \"const\" | \"let\" | \"var\" {\n if ((flags & ts.NodeFlags.Const) !== 0) {\n return \"const\";\n }\n\n if ((flags & ts.NodeFlags.Let) !== 0) {\n return \"let\";\n }\n\n return \"var\";\n}\n\nfunction makeStateDeclaration(\n name: string,\n declaration: ts.VariableDeclaration,\n content: string,\n): string {\n if (ts.isIdentifier(declaration.name) && declaration.type) {\n const typeText = normalizeStatementText(\n sliceNode(content, declaration.type),\n );\n return `let ${name} = $state<${typeText} | undefined>(undefined);`;\n }\n\n return `let ${name} = $state<any>(undefined);`;\n}\n\nfunction makeEffectAssignment(\n name: ts.BindingName,\n initializer: ts.Expression,\n content: string,\n): string {\n const target = normalizeStatementText(sliceNode(content, name));\n const expression = normalizeStatementText(sliceNode(content, initializer));\n\n if (ts.isIdentifier(name)) {\n return `${target} = ${expression};`;\n }\n\n return `(${target} = ${expression});`;\n}\n\nfunction extractBindingNames(name: ts.BindingName): string[] {\n if (ts.isIdentifier(name)) {\n return [name.text];\n }\n\n const names: string[] = [];\n\n for (const element of name.elements) {\n if (ts.isOmittedExpression(element)) {\n continue;\n }\n\n names.push(...extractBindingNames(element.name));\n }\n\n return names;\n}\n\nfunction isRuneInitializer(expression: ts.Expression): boolean {\n if (!ts.isCallExpression(expression)) {\n return false;\n }\n\n return isRuneCallee(expression.expression);\n}\n\nfunction isRuneCallee(expression: ts.Expression): boolean {\n if (ts.isIdentifier(expression)) {\n return RUNE_IDENTIFIERS.has(expression.text);\n }\n\n if (ts.isPropertyAccessExpression(expression)) {\n return isRuneCallee(expression.expression);\n }\n\n return false;\n}\n\nfunction containsYieldStar(node: ts.Node): boolean {\n if (\n ts.isBinaryExpression(node) &&\n node.operatorToken.kind === ts.SyntaxKind.AsteriskToken &&\n ts.isIdentifier(node.left) &&\n node.left.text === \"yield\"\n ) {\n return true;\n }\n\n return node.getChildren().some((child) =>\n isFunctionBoundary(child) ? false : containsYieldStar(child)\n );\n}\n\nfunction containsTopLevelAwait(node: ts.Node): boolean {\n if (ts.isAwaitExpression(node)) {\n return true;\n }\n\n return node.getChildren().some((child) =>\n isFunctionBoundary(child) ? false : containsTopLevelAwait(child)\n );\n}\n\nfunction isFunctionBoundary(node: ts.Node): boolean {\n return ts.isArrowFunction(node) ||\n ts.isFunctionDeclaration(node) ||\n ts.isFunctionExpression(node) ||\n ts.isMethodDeclaration(node) ||\n ts.isGetAccessorDeclaration(node) ||\n ts.isSetAccessorDeclaration(node);\n}\n\nfunction sliceNode(content: string, node: ts.Node): string {\n return content.slice(node.getFullStart(), node.end);\n}\n\nfunction normalizeStatementText(text: string): string {\n return text.trim();\n}\n\nfunction indentBlock(text: string, indent: string): string {\n return text.split(\"\\n\").map((line) =>\n line.length > 0 ? `${indent}${line}` : line\n ).join(\"\\n\");\n}\n\nfunction makeInjectedImports(options: TransformEffectScriptOptions): string {\n const runtimeModuleId = options.runtimeModuleId ?? DEFAULT_RUNTIME_MODULE_ID;\n const effectModuleId = options.effectModuleId ?? DEFAULT_EFFECT_MODULE_ID;\n const svelteModuleId = options.svelteModuleId ?? DEFAULT_SVELTE_MODULE_ID;\n\n return [\n `import { onMount as __svelteEffectRuntimeOnMount } from \"${svelteModuleId}\";`,\n `import { Effect as __svelteEffectRuntimeEffect } from \"${effectModuleId}\";`,\n `import { get_effect_runtime_or_throw as __svelteEffectRuntimeGetRuntime, run_component_effect as __svelteEffectRuntimeRunComponentEffect } from \"${runtimeModuleId}\";`,\n \"\",\n ].join(\"\\n\");\n}\n\nfunction makeRuntimeBlock(statements: string[]): string {\n const body = statements.map((statement) => indentBlock(statement, \" \"))\n .join(\"\\n\\n\");\n\n return [\n \"\",\n \"const __svelteEffectRuntimeProgram = __svelteEffectRuntimeEffect.gen(function* () {\",\n body,\n \"});\",\n \"\",\n \"__svelteEffectRuntimeOnMount(() => {\",\n \" const __svelteEffectRuntimeCleanup = __svelteEffectRuntimeRunComponentEffect(\",\n \" __svelteEffectRuntimeGetRuntime(),\",\n \" __svelteEffectRuntimeProgram,\",\n \" );\",\n \"\",\n \" import.meta.hot?.dispose(__svelteEffectRuntimeCleanup);\",\n \" return __svelteEffectRuntimeCleanup;\",\n \"});\",\n \"\",\n ].join(\"\\n\");\n}\n"],"mappings":";;;AAIA,MAAM,4B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AAoB,SAA+C;CAC1E,MAAM,kBAAkB,QAAQ,mBAAmB;CACnD,MAAM,iBAAiB,QAAQ,kBAAkB;AAGjD,QAAO;EACL,4DAHqB,QAAQ,kBAAkB,yBAG4B;EAC3E,0DAA0D,eAAe;EACzE,oJAAoJ,gBAAgB;EACpK;EACD,CAAC,KAAK,KAAK;;AAGd,SAAS,iBAAiB,YAA8B;AAItD,QAAO;EACL;EACA;EALW,WAAW,KAAK,cAAc,YAAY,WAAW,OAAO,CAAC,CACvE,KAAK,OAAO;EAMb;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC,KAAK,KAAK"}
1
+ {"version":3,"file":"transform.js","names":[],"sources":["../../../modules/svelte-effect-runtime/internal/transform.ts"],"sourcesContent":["import MagicString, { type SourceMap } from \"magic-string\";\nimport ts from \"typescript\";\nimport type { EffectPreprocessOptions } from \"$/preprocess.ts\";\n\nconst DEFAULT_RUNTIME_MODULE_ID = \"svelte-effect-runtime\";\nconst DEFAULT_EFFECT_MODULE_ID = \"effect\";\nconst DEFAULT_SVELTE_MODULE_ID = \"svelte\";\n\nconst RUNE_IDENTIFIERS = new Set([\n \"$bindable\",\n \"$derived\",\n \"$effect\",\n \"$host\",\n \"$inspect\",\n \"$props\",\n \"$state\",\n]);\n\ninterface TransformEffectScriptOptions extends EffectPreprocessOptions {\n filename: string;\n}\n\ninterface TransformEffectScriptResult {\n code: string;\n map: SourceMap;\n relocations: Array<TransformRelocation>;\n}\n\ninterface VariableStatementTransform {\n effectTexts: string[];\n hoistedText: string;\n loweredBindings: string[];\n pendingRelocations: Array<PendingRelocation>;\n usesPendingYieldHelper: boolean;\n}\n\ninterface TransformRelocation {\n originalStart: number;\n originalEnd: number;\n generatedStart: number;\n generatedEnd: number;\n}\n\ninterface PendingRelocation {\n originalStart: number;\n originalEnd: number;\n generatedSnippet: string;\n generatedInnerStart: number;\n generatedInnerEnd: number;\n}\n\ninterface StateDeclarationTransform {\n code: string;\n pendingRelocations: Array<PendingRelocation>;\n}\n\ninterface LoweredDeclarationHelper {\n declarationText: string;\n stateTypeText: string;\n assignmentExpression: string;\n expressionRelocation: PendingRelocation;\n tempName?: string;\n}\n\nconst HOISTED_KINDS = new Set<ts.SyntaxKind>([\n ts.SyntaxKind.ClassDeclaration,\n ts.SyntaxKind.EmptyStatement,\n ts.SyntaxKind.EnumDeclaration,\n ts.SyntaxKind.ExportAssignment,\n ts.SyntaxKind.ExportDeclaration,\n ts.SyntaxKind.FunctionDeclaration,\n ts.SyntaxKind.ImportDeclaration,\n ts.SyntaxKind.ImportEqualsDeclaration,\n ts.SyntaxKind.InterfaceDeclaration,\n ts.SyntaxKind.ModuleDeclaration,\n ts.SyntaxKind.TypeAliasDeclaration,\n]);\n\nconst HOISTED_CALL_IDENTIFIERS = new Set([\n \"$effect\",\n \"__svelteEffectRuntimeMarkupOnDestroy\",\n \"onDestroy\",\n]);\n\nexport function transformEffectScript(\n content: string,\n options: TransformEffectScriptOptions,\n): TransformEffectScriptResult {\n const sourceFile = ts.createSourceFile(\n options.filename,\n content,\n ts.ScriptTarget.Latest,\n true,\n ts.ScriptKind.TS,\n );\n\n const effectStatements: Array<{ node: ts.Statement; text: string }> = [];\n const runtimeStatements: string[] = [];\n const pendingRelocations: Array<PendingRelocation> = [];\n const magicString = new MagicString(content);\n const effectBoundBindings = new Set<string>();\n\n for (const statement of sourceFile.statements) {\n if (ts.isVariableStatement(statement)) {\n if (isGeneratedMarkupHelperStatement(statement, content)) {\n continue;\n }\n\n const transformed = transformVariableStatement(\n statement,\n content,\n options.filename,\n effectBoundBindings,\n );\n\n if (transformed.hoistedText.length === 0) {\n magicString.remove(statement.getFullStart(), statement.end);\n } else {\n magicString.overwrite(\n statement.getStart(sourceFile),\n statement.end,\n transformed.hoistedText,\n );\n }\n\n runtimeStatements.push(...transformed.effectTexts);\n pendingRelocations.push(...transformed.pendingRelocations);\n for (const bindingName of transformed.loweredBindings) {\n effectBoundBindings.add(bindingName);\n }\n continue;\n }\n\n if (isHoistedExpressionStatement(statement)) {\n continue;\n }\n\n if (isHoistedStatement(statement)) {\n continue;\n }\n\n if (containsTopLevelAwait(statement)) {\n throw new Error(\n `${options.filename}: top-level await is not supported in <script effect>. Use yield* Effect.promise(...) or yield* Effect.tryPromise(...) instead.`,\n );\n }\n\n effectStatements.push({\n node: statement,\n text: normalizeStatementText(sliceNode(content, statement)),\n });\n pendingRelocations.push({\n originalStart: statement.getStart(sourceFile),\n originalEnd: statement.end,\n generatedSnippet: normalizeStatementText(sliceNode(content, statement)),\n generatedInnerStart: 0,\n generatedInnerEnd: normalizeStatementText(sliceNode(content, statement))\n .length,\n });\n }\n\n for (const statement of [...effectStatements].reverse()) {\n magicString.remove(statement.node.getFullStart(), statement.node.end);\n }\n\n const allRuntimeStatements = [\n ...runtimeStatements,\n ...effectStatements.map((statement) => statement.text),\n ];\n\n if (allRuntimeStatements.length > 0) {\n magicString.prepend(makeInjectedImports(options));\n magicString.append(makeRuntimeBlock(allRuntimeStatements));\n }\n\n const code = magicString.toString();\n\n return {\n code,\n map: magicString.generateMap({\n hires: true,\n includeContent: true,\n source: options.filename,\n }),\n relocations: resolvePendingRelocations(pendingRelocations, code),\n };\n}\n\nfunction isHoistedStatement(statement: ts.Statement): boolean {\n return HOISTED_KINDS.has(statement.kind);\n}\n\nfunction isHoistedExpressionStatement(statement: ts.Statement): boolean {\n if (!ts.isExpressionStatement(statement)) {\n return false;\n }\n\n if (!ts.isCallExpression(statement.expression)) {\n return false;\n }\n\n return getCalledIdentifierText(statement.expression.expression) !==\n undefined &&\n HOISTED_CALL_IDENTIFIERS.has(\n getCalledIdentifierText(statement.expression.expression)!,\n );\n}\n\nfunction getCalledIdentifierText(\n expression: ts.Expression,\n): string | undefined {\n if (ts.isIdentifier(expression)) {\n return expression.text;\n }\n\n if (ts.isPropertyAccessExpression(expression)) {\n const base = getCalledIdentifierText(expression.expression);\n return base ? `${base}.${expression.name.text}` : expression.name.text;\n }\n\n return undefined;\n}\n\nfunction transformVariableStatement(\n statement: ts.VariableStatement,\n content: string,\n filename: string,\n effectBoundBindings: ReadonlySet<string>,\n): VariableStatementTransform {\n if ((statement.modifiers?.length ?? 0) > 0) {\n validateModifiedVariableStatement(statement, content, filename);\n return {\n effectTexts: [],\n hoistedText: normalizeStatementText(sliceNode(content, statement)),\n loweredBindings: [],\n pendingRelocations: [],\n usesPendingYieldHelper: false,\n };\n }\n\n const effectTexts: string[] = [];\n const hoistedDeclarations: string[] = [];\n const loweredBindings: string[] = [];\n const pendingRelocations: Array<PendingRelocation> = [];\n\n for (const declaration of statement.declarationList.declarations) {\n if (\n declaration.initializer && containsTopLevelAwait(declaration.initializer)\n ) {\n const statementText = normalizeStatementText(\n sliceNode(content, statement),\n );\n\n throw new Error(\n `${filename}: declarations in <script effect> cannot depend on await.\\nUse yield* Effect.promise(...) or yield* Effect.tryPromise(...) instead.\\n\\nProblematic statement:\\n${statementText}`,\n );\n }\n\n if (declaration.initializer && isRuneInitializer(declaration.initializer)) {\n const renderedDeclaration = `${\n getDeclarationKind(statement.declarationList.flags)\n } ${normalizeStatementText(sliceNode(content, declaration))};`;\n hoistedDeclarations.push(renderedDeclaration);\n pendingRelocations.push(\n ...make_declaration_relocations(\n declaration,\n renderedDeclaration,\n content,\n ),\n );\n continue;\n }\n\n if (\n shouldHoistDeclaration(\n statement.declarationList.flags,\n declaration,\n effectBoundBindings,\n )\n ) {\n const renderedDeclaration = `${\n getDeclarationKind(statement.declarationList.flags)\n } ${normalizeStatementText(sliceNode(content, declaration))};`;\n hoistedDeclarations.push(renderedDeclaration);\n pendingRelocations.push(\n ...make_declaration_relocations(\n declaration,\n renderedDeclaration,\n content,\n ),\n );\n continue;\n }\n\n const bindingNames = extractBindingNames(declaration.name);\n const helper = create_lowered_declaration_helper(declaration, content);\n\n if (helper) {\n hoistedDeclarations.push(helper.declarationText);\n pendingRelocations.push(helper.expressionRelocation);\n }\n\n if (helper?.tempName) {\n hoistedDeclarations.push(\n makeTypedStateBinding(helper.tempName, helper.stateTypeText),\n );\n }\n\n for (const bindingName of bindingNames) {\n const stateDeclaration = makeStateDeclaration(\n bindingName,\n declaration,\n content,\n helper?.tempName ? null : helper?.stateTypeText,\n );\n hoistedDeclarations.push(stateDeclaration.code);\n pendingRelocations.push(...stateDeclaration.pendingRelocations);\n }\n loweredBindings.push(...bindingNames);\n\n if (declaration.initializer) {\n if (helper?.tempName) {\n effectTexts.push(\n `${helper.tempName} = ${helper.assignmentExpression};`,\n );\n effectTexts.push(\n makeEffectAssignment(\n declaration.name,\n helper.tempName,\n content,\n ),\n );\n } else {\n const effectAssignment = helper\n ? `${bindingNames[0]} = ${helper.assignmentExpression};`\n : makeEffectAssignment(\n declaration.name,\n declaration.initializer,\n content,\n );\n effectTexts.push(effectAssignment);\n if (!helper) {\n pendingRelocations.push(\n makeEffectAssignmentRelocation(\n declaration.initializer,\n effectAssignment,\n content,\n ),\n );\n }\n }\n }\n }\n\n return {\n effectTexts,\n hoistedText: hoistedDeclarations.join(\"\\n\"),\n loweredBindings,\n pendingRelocations,\n usesPendingYieldHelper: false,\n };\n}\n\nfunction shouldHoistDeclaration(\n flags: ts.NodeFlags,\n declaration: ts.VariableDeclaration,\n effectBoundBindings: ReadonlySet<string>,\n): boolean {\n if ((flags & ts.NodeFlags.Const) === 0) {\n return false;\n }\n\n if (!declaration.initializer) {\n return false;\n }\n\n if (\n containsYieldStar(declaration.initializer) ||\n containsTopLevelAwait(declaration.initializer)\n ) {\n return false;\n }\n\n return !referencesEffectBoundBindings(\n declaration.initializer,\n effectBoundBindings,\n );\n}\n\nfunction referencesEffectBoundBindings(\n node: ts.Node,\n effectBoundBindings: ReadonlySet<string>,\n): boolean {\n const localScopes: Array<Set<string>> = [new Set()];\n let found = false;\n\n const visit = (current: ts.Node): void => {\n if (found) {\n return;\n }\n\n if (\n ts.isArrowFunction(current) || ts.isFunctionDeclaration(current) ||\n ts.isFunctionExpression(current)\n ) {\n const scope = new Set<string>();\n\n if (current.name) {\n scope.add(current.name.text);\n }\n\n for (const parameter of current.parameters) {\n declareBindingInto(scope, parameter.name);\n }\n\n localScopes.unshift(scope);\n current.forEachChild(visit);\n localScopes.shift();\n return;\n }\n\n if (ts.isIdentifier(current)) {\n if (\n !isSkippedReference(current) &&\n effectBoundBindings.has(current.text) &&\n !localScopes.some((scope) => scope.has(current.text))\n ) {\n found = true;\n }\n\n return;\n }\n\n current.forEachChild(visit);\n };\n\n const declareBindingInto = (\n scope: Set<string>,\n name: ts.BindingName,\n ): void => {\n if (ts.isIdentifier(name)) {\n scope.add(name.text);\n return;\n }\n\n for (const element of name.elements) {\n if (ts.isOmittedExpression(element)) {\n continue;\n }\n\n declareBindingInto(scope, element.name);\n }\n };\n\n visit(node);\n return found;\n}\n\nfunction isSkippedReference(identifier: ts.Identifier): boolean {\n const parent = identifier.parent;\n\n return ts.isPropertyAccessExpression(parent) && parent.name === identifier ||\n ts.isPropertyAssignment(parent) && parent.name === identifier ||\n ts.isShorthandPropertyAssignment(parent) &&\n parent.objectAssignmentInitializer === identifier ||\n ts.isBindingElement(parent) && parent.propertyName === identifier ||\n ts.isImportSpecifier(parent) ||\n ts.isExportSpecifier(parent) ||\n ts.isLabeledStatement(parent) && parent.label === identifier;\n}\n\nfunction isGeneratedMarkupHelperStatement(\n statement: ts.VariableStatement,\n content: string,\n): boolean {\n return statement.declarationList.declarations.every((declaration) =>\n extractBindingNames(declaration.name).every((name) =>\n name.startsWith(\"__svelteEffectRuntimeMarkup\")\n ) ||\n normalizeStatementText(sliceNode(content, declaration)).startsWith(\n \"__svelteEffectRuntimeMarkup\",\n )\n );\n}\n\nfunction validateModifiedVariableStatement(\n statement: ts.VariableStatement,\n content: string,\n filename: string,\n): void {\n for (const declaration of statement.declarationList.declarations) {\n if (\n declaration.initializer &&\n (containsYieldStar(declaration.initializer) ||\n containsTopLevelAwait(declaration.initializer))\n ) {\n const statementText = normalizeStatementText(\n sliceNode(content, statement),\n );\n\n throw new Error(\n `${filename}: declarations with modifiers cannot depend on yield* or await in <script effect> right now.\\nSplit the declaration into a plain top-level binding and assign inside the effect body instead.\\n\\nProblematic statement:\\n${statementText}`,\n );\n }\n }\n}\n\nfunction getDeclarationKind(flags: ts.NodeFlags): \"const\" | \"let\" | \"var\" {\n if ((flags & ts.NodeFlags.Const) !== 0) {\n return \"const\";\n }\n\n if ((flags & ts.NodeFlags.Let) !== 0) {\n return \"let\";\n }\n\n return \"var\";\n}\n\nfunction makeStateDeclaration(\n name: string,\n declaration: ts.VariableDeclaration,\n content: string,\n inferredTypeText?: string | null,\n): StateDeclarationTransform {\n let stateTypeText: string | null = null;\n\n if (ts.isIdentifier(declaration.name) && declaration.type) {\n stateTypeText = normalizeStatementText(\n sliceNode(content, declaration.type),\n );\n } else if (inferredTypeText) {\n stateTypeText = inferredTypeText;\n }\n\n const code = stateTypeText\n ? makeTypedStateBinding(name, stateTypeText)\n : `let ${name} = $state<any>(undefined);`;\n\n const nameStart = code.indexOf(name);\n const pendingRelocations: Array<PendingRelocation> = [{\n originalStart: find_binding_name_start(declaration.name, name),\n originalEnd: find_binding_name_end(declaration.name, name),\n generatedSnippet: \"\",\n generatedInnerStart: nameStart,\n generatedInnerEnd: nameStart + name.length,\n }];\n\n pendingRelocations[0] = {\n ...pendingRelocations[0],\n generatedSnippet: code,\n };\n\n return {\n code,\n pendingRelocations,\n };\n}\n\nfunction makeEffectAssignment(\n name: ts.BindingName,\n initializer: ts.Expression | string,\n content: string,\n): string {\n const target = normalizeStatementText(sliceNode(content, name));\n const expression = typeof initializer === \"string\"\n ? initializer\n : normalizeStatementText(sliceNode(content, initializer));\n\n if (ts.isIdentifier(name)) {\n return `${target} = ${expression};`;\n }\n\n return `(${target} = ${expression});`;\n}\n\nfunction makeEffectAssignmentRelocation(\n initializer: ts.Expression,\n effectAssignment: string,\n content: string,\n): PendingRelocation {\n const expression = normalizeStatementText(sliceNode(content, initializer));\n const generatedInnerStart = effectAssignment.lastIndexOf(expression);\n\n return {\n originalStart: initializer.getStart(),\n originalEnd: initializer.end,\n generatedSnippet: effectAssignment,\n generatedInnerStart,\n generatedInnerEnd: generatedInnerStart + expression.length,\n };\n}\n\nfunction extractBindingNames(name: ts.BindingName): string[] {\n if (ts.isIdentifier(name)) {\n return [name.text];\n }\n\n const names: string[] = [];\n\n for (const element of name.elements) {\n if (ts.isOmittedExpression(element)) {\n continue;\n }\n\n names.push(...extractBindingNames(element.name));\n }\n\n return names;\n}\n\nfunction isRuneInitializer(expression: ts.Expression): boolean {\n if (!ts.isCallExpression(expression)) {\n return false;\n }\n\n return isRuneCallee(expression.expression);\n}\n\nfunction isRuneCallee(expression: ts.Expression): boolean {\n if (ts.isIdentifier(expression)) {\n return RUNE_IDENTIFIERS.has(expression.text);\n }\n\n if (ts.isPropertyAccessExpression(expression)) {\n return isRuneCallee(expression.expression);\n }\n\n return false;\n}\n\nfunction containsYieldStar(node: ts.Node): boolean {\n if (\n ts.isBinaryExpression(node) &&\n node.operatorToken.kind === ts.SyntaxKind.AsteriskToken &&\n ts.isIdentifier(node.left) &&\n node.left.text === \"yield\"\n ) {\n return true;\n }\n\n return node.getChildren().some((child) =>\n isFunctionBoundary(child) ? false : containsYieldStar(child)\n );\n}\n\nfunction getYieldOperand(node: ts.Node | undefined): ts.Expression | null {\n if (\n node &&\n ts.isBinaryExpression(node) &&\n node.operatorToken.kind === ts.SyntaxKind.AsteriskToken &&\n ts.isIdentifier(node.left) &&\n node.left.text === \"yield\"\n ) {\n return node.right;\n }\n\n return null;\n}\n\nfunction containsTopLevelAwait(node: ts.Node): boolean {\n if (ts.isAwaitExpression(node)) {\n return true;\n }\n\n return node.getChildren().some((child) =>\n isFunctionBoundary(child) ? false : containsTopLevelAwait(child)\n );\n}\n\nfunction isFunctionBoundary(node: ts.Node): boolean {\n return ts.isArrowFunction(node) ||\n ts.isFunctionDeclaration(node) ||\n ts.isFunctionExpression(node) ||\n ts.isMethodDeclaration(node) ||\n ts.isGetAccessorDeclaration(node) ||\n ts.isSetAccessorDeclaration(node);\n}\n\nfunction sliceNode(content: string, node: ts.Node): string {\n return content.slice(node.getFullStart(), node.end);\n}\n\nfunction normalizeStatementText(text: string): string {\n return text.trim();\n}\n\nfunction indentBlock(text: string, indent: string): string {\n return text.split(\"\\n\").map((line) =>\n line.length > 0 ? `${indent}${line}` : line\n ).join(\"\\n\");\n}\n\nfunction makeInjectedImports(\n options: TransformEffectScriptOptions,\n): string {\n const runtimeModuleId = options.runtimeModuleId ?? DEFAULT_RUNTIME_MODULE_ID;\n const effectModuleId = options.effectModuleId ?? DEFAULT_EFFECT_MODULE_ID;\n const svelteModuleId = options.svelteModuleId ?? DEFAULT_SVELTE_MODULE_ID;\n\n const lines = [\n `import { onMount as __svelteEffectRuntimeOnMount } from \"${svelteModuleId}\";`,\n `import { Effect as __svelteEffectRuntimeEffect } from \"${effectModuleId}\";`,\n `import { get_effect_runtime_or_throw as __svelteEffectRuntimeGetRuntime, run_component_effect as __svelteEffectRuntimeRunComponentEffect } from \"${runtimeModuleId}\";`,\n `type __svelteEffectRuntimeYielded<T> = T extends __svelteEffectRuntimeEffect.Effect<infer A, any, any> ? A : T;`,\n ];\n\n lines.push(\"\");\n return lines.join(\"\\n\");\n}\n\nfunction makeTypedStateBinding(name: string, stateTypeText: string): string {\n return `let ${name}: ${stateTypeText} = $state(undefined as unknown as ${stateTypeText});`;\n}\n\nfunction create_lowered_declaration_helper(\n declaration: ts.VariableDeclaration,\n content: string,\n): LoweredDeclarationHelper | null {\n if (declaration.type || !declaration.initializer) {\n return null;\n }\n\n const bindingNames = extractBindingNames(declaration.name);\n const suffix = declaration.getStart();\n const baseName = bindingNames[0] ?? \"binding\";\n const helperName = `__svelteEffectRuntime_${baseName}_${suffix}`;\n const expressionNode = getYieldOperand(declaration.initializer) ??\n declaration.initializer;\n const expressionText = normalizeStatementText(\n sliceNode(content, expressionNode),\n );\n const declarationText = `const ${helperName} = () => ${expressionText};`;\n const yieldedExpression = getYieldOperand(declaration.initializer);\n const stateTypeText = yieldedExpression\n ? `__svelteEffectRuntimeYielded<ReturnType<typeof ${helperName}>>`\n : `ReturnType<typeof ${helperName}>`;\n const assignmentExpression = yieldedExpression\n ? `yield* ${helperName}()`\n : `${helperName}()`;\n\n return {\n declarationText,\n stateTypeText,\n assignmentExpression,\n tempName: ts.isIdentifier(declaration.name)\n ? undefined\n : `__svelteEffectRuntimeTemp_${suffix}`,\n expressionRelocation: {\n originalStart: expressionNode.getStart(),\n originalEnd: expressionNode.end,\n generatedSnippet: declarationText,\n generatedInnerStart: declarationText.lastIndexOf(expressionText),\n generatedInnerEnd: declarationText.lastIndexOf(expressionText) +\n expressionText.length,\n },\n };\n}\n\nfunction make_declaration_relocations(\n declaration: ts.VariableDeclaration,\n renderedDeclaration: string,\n content: string,\n): Array<PendingRelocation> {\n const relocations: Array<PendingRelocation> = [];\n\n if (ts.isIdentifier(declaration.name)) {\n const nameStart = renderedDeclaration.indexOf(declaration.name.text);\n relocations.push({\n originalStart: declaration.name.getStart(),\n originalEnd: declaration.name.end,\n generatedSnippet: renderedDeclaration,\n generatedInnerStart: nameStart,\n generatedInnerEnd: nameStart + declaration.name.text.length,\n });\n }\n\n if (declaration.initializer) {\n const initializerText = normalizeStatementText(\n sliceNode(content, declaration.initializer),\n );\n const initializerStart = renderedDeclaration.lastIndexOf(initializerText);\n if (initializerStart >= 0) {\n relocations.push({\n originalStart: declaration.initializer.getStart(),\n originalEnd: declaration.initializer.end,\n generatedSnippet: renderedDeclaration,\n generatedInnerStart: initializerStart,\n generatedInnerEnd: initializerStart + initializerText.length,\n });\n }\n }\n\n return relocations;\n}\n\nfunction find_binding_name_start(\n name: ts.BindingName,\n bindingName: string,\n): number {\n if (ts.isIdentifier(name)) {\n return name.text === bindingName ? name.getStart() : -1;\n }\n\n for (const element of name.elements) {\n if (ts.isOmittedExpression(element)) {\n continue;\n }\n\n const start = find_binding_name_start(element.name, bindingName);\n if (start !== -1) {\n return start;\n }\n }\n\n return -1;\n}\n\nfunction find_binding_name_end(\n name: ts.BindingName,\n bindingName: string,\n): number {\n if (ts.isIdentifier(name)) {\n return name.text === bindingName ? name.end : -1;\n }\n\n for (const element of name.elements) {\n if (ts.isOmittedExpression(element)) {\n continue;\n }\n\n const end = find_binding_name_end(element.name, bindingName);\n if (end !== -1) {\n return end;\n }\n }\n\n return -1;\n}\n\nfunction makeRuntimeBlock(statements: string[]): string {\n const body = statements.map((statement) => indentBlock(statement, \" \"))\n .join(\"\\n\\n\");\n\n return [\n \"\",\n \"const __svelteEffectRuntimeProgram = __svelteEffectRuntimeEffect.gen(function* () {\",\n body,\n \"});\",\n \"\",\n \"__svelteEffectRuntimeOnMount(() => {\",\n \" const __svelteEffectRuntimeCleanup = __svelteEffectRuntimeRunComponentEffect(\",\n \" __svelteEffectRuntimeGetRuntime(),\",\n \" __svelteEffectRuntimeProgram,\",\n \" );\",\n \"\",\n \" import.meta.hot?.dispose(__svelteEffectRuntimeCleanup);\",\n \" return __svelteEffectRuntimeCleanup;\",\n \"});\",\n \"\",\n ].join(\"\\n\");\n}\n\nfunction resolvePendingRelocations(\n pendingRelocations: Array<PendingRelocation>,\n code: string,\n): Array<TransformRelocation> {\n const relocations: Array<TransformRelocation> = [];\n let searchStart = 0;\n\n for (const relocation of pendingRelocations) {\n const generatedStart = code.indexOf(\n relocation.generatedSnippet,\n searchStart,\n );\n\n if (generatedStart === -1) {\n continue;\n }\n\n searchStart = generatedStart + relocation.generatedSnippet.length;\n relocations.push({\n originalStart: relocation.originalStart,\n originalEnd: relocation.originalEnd,\n generatedStart: generatedStart + relocation.generatedInnerStart,\n generatedEnd: generatedStart + relocation.generatedInnerEnd,\n });\n }\n\n return relocations;\n}\n"],"mappings":";;;AAIA,MAAM,4BAA4B;AAClC,MAAM,2BAA2B;AACjC,MAAM,2BAA2B;AAEjC,MAAM,mBAAmB,IAAI,IAAI;CAC/B;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AAgDF,MAAM,gBAAgB,IAAI,IAAmB;CAC3C,GAAG,WAAW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wBAAwB,QAAQ,MAAM,YAAY;AAChE,MAAI,UAAU,GACZ,QAAO;;AAIX,QAAO;;AAGT,SAAS,sBACP,MACA,aACQ;AACR,KAAI,GAAG,aAAa,KAAK,CACvB,QAAO,KAAK,SAAS,cAAc,KAAK,MAAM;AAGhD,MAAK,MAAM,WAAW,KAAK,UAAU;AACnC,MAAI,GAAG,oBAAoB,QAAQ,CACjC;EAGF,MAAM,MAAM,sBAAsB,QAAQ,MAAM,YAAY;AAC5D,MAAI,QAAQ,GACV,QAAO;;AAIX,QAAO;;AAGT,SAAS,iBAAiB,YAA8B;AAItD,QAAO;EACL;EACA;EALW,WAAW,KAAK,cAAc,YAAY,WAAW,OAAO,CAAC,CACvE,KAAK,OAAO;EAMb;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC,KAAK,KAAK;;AAGd,SAAS,0BACP,oBACA,MAC4B;CAC5B,MAAM,cAA0C,EAAE;CAClD,IAAI,cAAc;AAElB,MAAK,MAAM,cAAc,oBAAoB;EAC3C,MAAM,iBAAiB,KAAK,QAC1B,WAAW,kBACX,YACD;AAED,MAAI,mBAAmB,GACrB;AAGF,gBAAc,iBAAiB,WAAW,iBAAiB;AAC3D,cAAY,KAAK;GACf,eAAe,WAAW;GAC1B,aAAa,WAAW;GACxB,gBAAgB,iBAAiB,WAAW;GAC5C,cAAc,iBAAiB,WAAW;GAC3C,CAAC;;AAGJ,QAAO"}
@@ -1,4 +1,4 @@
1
- import { t as transformEffectMarkup } from "./chunks/markup-BpSHnnYD.js";
1
+ import { t as transformEffectMarkup } from "./chunks/markup-BMn2sQOB.js";
2
2
  import { transformEffectScript } from "./internal/transform.js";
3
3
  import { effect_preprocess } from "./preprocess.js";
4
4
  export { effect_preprocess, transformEffectMarkup as transform_effect_markup, transformEffectScript as transform_effect_script };
package/dist/mod.d.ts CHANGED
@@ -1 +1,22 @@
1
+ /**
2
+ * Main entrypoint for `svelte-effect-runtime`.
3
+ *
4
+ * Re-exports the v3 public surface so that plain
5
+ * `import { ClientRuntime } from "svelte-effect-runtime"` resolves to the
6
+ * stable default runtime. For explicit version targeting see
7
+ * `svelte-effect-runtime/v3` and `svelte-effect-runtime/v4`.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * import { ClientRuntime, run_component_effect } from "svelte-effect-runtime";
12
+ * import { Effect } from "effect";
13
+ *
14
+ * const runtime = ClientRuntime.make();
15
+ * run_component_effect(runtime, Effect.log("hello from effect"));
16
+ * ```
17
+ *
18
+ * @see https://ser.barekey.dev/
19
+ *
20
+ * @module
21
+ */
1
22
  export * from "./v3/mod.js";
package/dist/mod.js CHANGED
@@ -1,3 +1,3 @@
1
- import { a as run_component_effect, c as to_native, o as run_inline_effect, r as get_effect_runtime_or_throw, s as to_effect, t as ClientRuntime } from "./chunks/client-DkW4e4dD.js";
2
- import "./chunks/v3-p8V3Drpp.js";
1
+ import { a as run_component_effect, c as to_native, o as run_inline_effect, r as get_effect_runtime_or_throw, s as to_effect, t as ClientRuntime } from "./chunks/client-vV6UAwoP.js";
2
+ import "./chunks/v3-D0c0MKPf.js";
3
3
  export { ClientRuntime, get_effect_runtime_or_throw, run_component_effect, run_inline_effect, to_effect, to_native };
@@ -22,3 +22,8 @@ export type { EffectPreprocessOptions } from "./v3/preprocess.js";
22
22
  * @see https://ser.barekey.dev/content/reference/preprocess
23
23
  */
24
24
  export declare function effect_preprocess(options?: EffectPreprocessOptions): PreprocessorGroup;
25
+ /**
26
+ * Backwards-compatible camelCase alias retained for older test fixtures and
27
+ * downstream code that imported the preprocessor before the snake_case rename.
28
+ */
29
+ export declare const effectPreprocess: typeof effect_preprocess;
@@ -1,4 +1,4 @@
1
- import { t as effect_preprocess$1 } from "./chunks/preprocess-CtLrnJcK.js";
1
+ import { t as effect_preprocess$1 } from "./chunks/preprocess-CGKEA3Py.js";
2
2
  //#region preprocess.ts
3
3
  /**
4
4
  * Low-level `.svelte` preprocessor used by the higher-level `effect()`
@@ -9,7 +9,12 @@ import { t as effect_preprocess$1 } from "./chunks/preprocess-CtLrnJcK.js";
9
9
  function effect_preprocess(options) {
10
10
  return effect_preprocess$1(options);
11
11
  }
12
+ /**
13
+ * Backwards-compatible camelCase alias retained for older test fixtures and
14
+ * downstream code that imported the preprocessor before the snake_case rename.
15
+ */
16
+ const effectPreprocess = effect_preprocess;
12
17
  //#endregion
13
- export { effect_preprocess };
18
+ export { effectPreprocess, effect_preprocess };
14
19
 
15
20
  //# sourceMappingURL=preprocess.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"preprocess.js","names":["create_effect_preprocess"],"sources":["../../modules/svelte-effect-runtime/preprocess.ts"],"sourcesContent":["/**\n * Public preprocess entrypoint for `svelte-effect-runtime`.\n *\n * @example\n * ```ts\n * import { effect_preprocess } from \"svelte-effect-runtime/preprocess\";\n *\n * export default {\n * preprocess: [effect_preprocess()],\n * };\n * ```\n *\n * @module\n */\nimport type { PreprocessorGroup } from \"svelte/compiler\";\nimport {\n effect_preprocess as create_effect_preprocess,\n type EffectPreprocessOptions,\n} from \"$/v3/preprocess.ts\";\n\nexport type { EffectPreprocessOptions } from \"$/v3/preprocess.ts\";\n\n/**\n * Low-level `.svelte` preprocessor used by the higher-level `effect()`\n * plugin.\n *\n * @see https://ser.barekey.dev/content/reference/preprocess\n */\nexport function effect_preprocess(\n options?: EffectPreprocessOptions,\n): PreprocessorGroup {\n return create_effect_preprocess(options);\n}\n"],"mappings":";;;;;;;;AA4BA,SAAgB,kBACd,SACmB;AACnB,QAAOA,oBAAyB,QAAQ"}
1
+ {"version":3,"file":"preprocess.js","names":["create_effect_preprocess"],"sources":["../../modules/svelte-effect-runtime/preprocess.ts"],"sourcesContent":["/**\n * Public preprocess entrypoint for `svelte-effect-runtime`.\n *\n * @example\n * ```ts\n * import { effect_preprocess } from \"svelte-effect-runtime/preprocess\";\n *\n * export default {\n * preprocess: [effect_preprocess()],\n * };\n * ```\n *\n * @module\n */\nimport type { PreprocessorGroup } from \"svelte/compiler\";\nimport {\n effect_preprocess as create_effect_preprocess,\n type EffectPreprocessOptions,\n} from \"$/v3/preprocess.ts\";\n\nexport type { EffectPreprocessOptions } from \"$/v3/preprocess.ts\";\n\n/**\n * Low-level `.svelte` preprocessor used by the higher-level `effect()`\n * plugin.\n *\n * @see https://ser.barekey.dev/content/reference/preprocess\n */\nexport function effect_preprocess(\n options?: EffectPreprocessOptions,\n): PreprocessorGroup {\n return create_effect_preprocess(options);\n}\n\n/**\n * Backwards-compatible camelCase alias retained for older test fixtures and\n * downstream code that imported the preprocessor before the snake_case rename.\n */\nexport const effectPreprocess = effect_preprocess;\n"],"mappings":";;;;;;;;AA4BA,SAAgB,kBACd,SACmB;AACnB,QAAOA,oBAAyB,QAAQ;;;;;;AAO1C,MAAa,mBAAmB"}
package/dist/root-node.js CHANGED
@@ -1,7 +1,7 @@
1
- import { a as run_component_effect, c as to_native, o as run_inline_effect, r as get_effect_runtime_or_throw, s as to_effect, t as ClientRuntime } from "./chunks/client-DkW4e4dD.js";
2
- import "./chunks/v3-p8V3Drpp.js";
3
- import { a as RequestEvent$1, c as get_server_runtime_or_throw$1, i as Query$1, n as Form$1, o as ServerRuntime$1, r as Prerender$1, s as create_effect_transport$1, t as Command$1 } from "./chunks/server-CQcF2W3T.js";
4
- import { t as effect } from "./chunks/effect-CL8GJs8A.js";
1
+ import { a as run_component_effect, c as to_native, o as run_inline_effect, r as get_effect_runtime_or_throw, s as to_effect, t as ClientRuntime } from "./chunks/client-vV6UAwoP.js";
2
+ import "./chunks/v3-D0c0MKPf.js";
3
+ import { a as RequestEvent$1, c as get_server_runtime_or_throw$1, i as Query$1, n as Form$1, o as ServerRuntime$1, r as Prerender$1, s as create_effect_transport$1, t as Command$1 } from "./chunks/server-7YVuxUNk.js";
4
+ import { t as effect } from "./chunks/effect-Cx8OzrcW.js";
5
5
  //#region v3/root-node.ts
6
6
  /**
7
7
  * Define a read-only remote function that returns an `Effect` on the client.
@@ -1 +1 @@
1
- {"version":3,"file":"root-node.js","names":["Server_module.Query","Server_module.Command","Server_module.Form","Server_module.Prerender","Server_module.RequestEvent","Server_module.ServerRuntime","Server_module.create_effect_transport","Server_module.get_server_runtime_or_throw"],"sources":["../../modules/svelte-effect-runtime/v3/root-node.ts"],"sourcesContent":["import * as Server_module from \"$/v3/server.ts\";\n\nexport * from \"$/v3/mod.ts\";\nexport type * from \"$/v3/server.ts\";\nexport type { EffectPluginOptions } from \"$/v3/effect.ts\";\nexport { effect } from \"$/v3/effect.ts\";\n\n/**\n * Define a read-only remote function that returns an `Effect` on the client.\n *\n * @see https://ser.barekey.dev/content/remote-functions/query\n */\nexport const Query: typeof Server_module.Query = Server_module.Query;\n/**\n * Define a write-oriented remote function that returns an `Effect` on the\n * client.\n *\n * @see https://ser.barekey.dev/content/remote-functions/command\n */\nexport const Command: typeof Server_module.Command = Server_module.Command;\n/**\n * Define a remote form handler that maps submitted data into an Effect\n * program.\n *\n * @see https://ser.barekey.dev/content/remote-functions/form\n */\nexport const Form: typeof Server_module.Form = Server_module.Form;\n/**\n * Define a prerenderable remote function backed by an Effect program.\n *\n * @see https://ser.barekey.dev/content/remote-functions/prerender\n */\nexport const Prerender: typeof Server_module.Prerender = Server_module.Prerender;\n/**\n * Effect `Context.Tag` for the current SvelteKit `RequestEvent`.\n *\n * @see https://ser.barekey.dev/content/runtimes/server\n */\nexport const RequestEvent: typeof Server_module.RequestEvent =\n Server_module.RequestEvent;\n/**\n * Server-side runtime builder used to provide long-lived Effect services to\n * remote functions.\n *\n * @see https://ser.barekey.dev/content/reference/server-runtime\n */\nexport const ServerRuntime: typeof Server_module.ServerRuntime =\n Server_module.ServerRuntime;\n/**\n * Build a devalue transport table from Effect schemas so remote payloads can\n * round-trip custom data across the client/server boundary.\n *\n * @see https://ser.barekey.dev/content/reference/transport\n */\nexport const create_effect_transport: typeof Server_module.create_effect_transport =\n Server_module.create_effect_transport;\n/**\n * Resolve the active server runtime, lazily creating a default empty runtime\n * when no explicit one has been registered.\n *\n * @internal Internal - do not use.\n * @see https://ser.barekey.dev/content/reference/server-runtime\n */\nexport const get_server_runtime_or_throw:\n typeof Server_module.get_server_runtime_or_throw =\n Server_module.get_server_runtime_or_throw;\n"],"mappings":";;;;;;;;;;AAYA,MAAa,QAAoCA;;;;;;;AAOjD,MAAa,UAAwCC;;;;;;;AAOrD,MAAa,OAAkCC;;;;;;AAM/C,MAAa,YAA4CC;;;;;;AAMzD,MAAa,eACXC;;;;;;;AAOF,MAAa,gBACXC;;;;;;;AAOF,MAAa,0BACXC;;;;;;;;AAQF,MAAa,8BAETC"}
1
+ {"version":3,"file":"root-node.js","names":["Server_module.Query","Server_module.Command","Server_module.Form","Server_module.Prerender","Server_module.RequestEvent","Server_module.ServerRuntime","Server_module.create_effect_transport","Server_module.get_server_runtime_or_throw"],"sources":["../../modules/svelte-effect-runtime/v3/root-node.ts"],"sourcesContent":["import * as Server_module from \"$/v3/server.ts\";\n\nexport * from \"$/v3/mod.ts\";\nexport type * from \"$/v3/server.ts\";\nexport type { EffectPluginOptions } from \"$/v3/effect.ts\";\nexport { effect } from \"$/v3/effect.ts\";\n\n/**\n * Define a read-only remote function that returns an `Effect` on the client.\n *\n * @see https://ser.barekey.dev/content/remote-functions/query\n */\nexport const Query: typeof Server_module.Query = Server_module.Query;\n/**\n * Define a write-oriented remote function that returns an `Effect` on the\n * client.\n *\n * @see https://ser.barekey.dev/content/remote-functions/command\n */\nexport const Command: typeof Server_module.Command = Server_module.Command;\n/**\n * Define a remote form handler that maps submitted data into an Effect\n * program.\n *\n * @see https://ser.barekey.dev/content/remote-functions/form\n */\nexport const Form: typeof Server_module.Form = Server_module.Form;\n/**\n * Define a prerenderable remote function backed by an Effect program.\n *\n * @see https://ser.barekey.dev/content/remote-functions/prerender\n */\nexport const Prerender: typeof Server_module.Prerender =\n Server_module.Prerender;\n/**\n * Effect `Context.Tag` for the current SvelteKit `RequestEvent`.\n *\n * @see https://ser.barekey.dev/content/runtimes/server\n */\nexport const RequestEvent: typeof Server_module.RequestEvent =\n Server_module.RequestEvent;\n/**\n * Server-side runtime builder used to provide long-lived Effect services to\n * remote functions.\n *\n * @see https://ser.barekey.dev/content/reference/server-runtime\n */\nexport const ServerRuntime: typeof Server_module.ServerRuntime =\n Server_module.ServerRuntime;\n/**\n * Build a devalue transport table from Effect schemas so remote payloads can\n * round-trip custom data across the client/server boundary.\n *\n * @see https://ser.barekey.dev/content/reference/transport\n */\nexport const create_effect_transport:\n typeof Server_module.create_effect_transport =\n Server_module.create_effect_transport;\n/**\n * Resolve the active server runtime, lazily creating a default empty runtime\n * when no explicit one has been registered.\n *\n * @internal Internal - do not use.\n * @see https://ser.barekey.dev/content/reference/server-runtime\n */\nexport const get_server_runtime_or_throw:\n typeof Server_module.get_server_runtime_or_throw =\n Server_module.get_server_runtime_or_throw;\n"],"mappings":";;;;;;;;;;AAYA,MAAa,QAAoCA;;;;;;;AAOjD,MAAa,UAAwCC;;;;;;;AAOrD,MAAa,OAAkCC;;;;;;AAM/C,MAAa,YACXC;;;;;;AAMF,MAAa,eACXC;;;;;;;AAOF,MAAa,gBACXC;;;;;;;AAOF,MAAa,0BAETC;;;;;;;;AAQJ,MAAa,8BAETC"}
package/dist/server.d.ts CHANGED
@@ -1,3 +1,28 @@
1
+ /**
2
+ * Default server-side entrypoint for `svelte-effect-runtime`.
3
+ *
4
+ * Re-exports the v3 remote-function helpers (`Query`, `Command`, `Form`,
5
+ * `Prerender`), the `ServerRuntime` builder, and the `RequestEvent` service
6
+ * tag. Consumers normally import this module indirectly: the Vite plugin
7
+ * rewrites the public runtime specifier to this subpath inside `.remote.ts`
8
+ * files so the real implementation runs server-side.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * import { Query, ServerRuntime } from "svelte-effect-runtime/_server";
13
+ * import { Effect, Schema } from "effect";
14
+ *
15
+ * ServerRuntime.make();
16
+ *
17
+ * export const hello = Query(Schema.String, (name) =>
18
+ * Effect.succeed(`hello ${name}`)
19
+ * );
20
+ * ```
21
+ *
22
+ * @see https://ser.barekey.dev/content/reference/server-runtime
23
+ *
24
+ * @module
25
+ */
1
26
  import * as Server_module from "./v3/server.js";
2
27
  export type * from "./v3/server.js";
3
28
  /**
package/dist/server.js CHANGED
@@ -1,6 +1,31 @@
1
- import { a as RequestEvent$1, c as get_server_runtime_or_throw$1, i as Query$1, n as Form$1, o as ServerRuntime$1, r as Prerender$1, s as create_effect_transport$1, t as Command$1 } from "./chunks/server-CQcF2W3T.js";
1
+ import { a as RequestEvent$1, c as get_server_runtime_or_throw$1, i as Query$1, n as Form$1, o as ServerRuntime$1, r as Prerender$1, s as create_effect_transport$1, t as Command$1 } from "./chunks/server-7YVuxUNk.js";
2
2
  //#region server.ts
3
3
  /**
4
+ * Default server-side entrypoint for `svelte-effect-runtime`.
5
+ *
6
+ * Re-exports the v3 remote-function helpers (`Query`, `Command`, `Form`,
7
+ * `Prerender`), the `ServerRuntime` builder, and the `RequestEvent` service
8
+ * tag. Consumers normally import this module indirectly: the Vite plugin
9
+ * rewrites the public runtime specifier to this subpath inside `.remote.ts`
10
+ * files so the real implementation runs server-side.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * import { Query, ServerRuntime } from "svelte-effect-runtime/_server";
15
+ * import { Effect, Schema } from "effect";
16
+ *
17
+ * ServerRuntime.make();
18
+ *
19
+ * export const hello = Query(Schema.String, (name) =>
20
+ * Effect.succeed(`hello ${name}`)
21
+ * );
22
+ * ```
23
+ *
24
+ * @see https://ser.barekey.dev/content/reference/server-runtime
25
+ *
26
+ * @module
27
+ */
28
+ /**
4
29
  * Define a read-only remote function that returns an `Effect` on the client.
5
30
  *
6
31
  * @see https://ser.barekey.dev/content/remote-functions/query
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","names":["Server_module.Query","Server_module.Command","Server_module.Form","Server_module.Prerender","Server_module.RequestEvent","Server_module.ServerRuntime","Server_module.create_effect_transport","Server_module\n .get_server_runtime_or_throw"],"sources":["../../modules/svelte-effect-runtime/server.ts"],"sourcesContent":["import * as Server_module from \"$/v3/server.ts\";\n\nexport type * from \"$/v3/server.ts\";\n\n/**\n * Define a read-only remote function that returns an `Effect` on the client.\n *\n * @see https://ser.barekey.dev/content/remote-functions/query\n */\nexport const Query: typeof Server_module.Query = Server_module.Query;\n/**\n * Define a write-oriented remote function that returns an `Effect` on the\n * client.\n *\n * @see https://ser.barekey.dev/content/remote-functions/command\n */\nexport const Command: typeof Server_module.Command = Server_module.Command;\n/**\n * Define a remote form handler that maps submitted data into an Effect\n * program.\n *\n * @see https://ser.barekey.dev/content/remote-functions/form\n */\nexport const Form: typeof Server_module.Form = Server_module.Form;\n/**\n * Define a prerenderable remote function backed by an Effect program.\n *\n * @see https://ser.barekey.dev/content/remote-functions/prerender\n */\nexport const Prerender: typeof Server_module.Prerender =\n Server_module.Prerender;\n/**\n * Effect `Context.Tag` for the current SvelteKit `RequestEvent`.\n *\n * @see https://ser.barekey.dev/content/runtimes/server\n */\nexport const RequestEvent: typeof Server_module.RequestEvent =\n Server_module.RequestEvent;\n/**\n * Server-side runtime builder used to provide long-lived Effect services to\n * remote functions.\n *\n * @see https://ser.barekey.dev/content/reference/server-runtime\n */\nexport const ServerRuntime: typeof Server_module.ServerRuntime =\n Server_module.ServerRuntime;\n/**\n * Build a devalue transport table from Effect schemas so remote payloads can\n * round-trip custom data across the client/server boundary.\n *\n * @see https://ser.barekey.dev/content/reference/transport\n */\nexport const create_effect_transport:\n typeof Server_module.create_effect_transport =\n Server_module.create_effect_transport;\n/**\n * Resolve the active server runtime, lazily creating a default empty runtime\n * when no explicit one has been registered.\n *\n * @internal Internal - do not use.\n * @see https://ser.barekey.dev/content/reference/server-runtime\n */\nexport const get_server_runtime_or_throw = Server_module\n .get_server_runtime_or_throw as typeof Server_module.get_server_runtime_or_throw;\n"],"mappings":";;;;;;;AASA,MAAa,QAAoCA;;;;;;;AAOjD,MAAa,UAAwCC;;;;;;;AAOrD,MAAa,OAAkCC;;;;;;AAM/C,MAAa,YACXC;;;;;;AAMF,MAAa,eACXC;;;;;;;AAOF,MAAa,gBACXC;;;;;;;AAOF,MAAa,0BAETC;;;;;;;;AAQJ,MAAa,8BAA8BC"}
1
+ {"version":3,"file":"server.js","names":["Server_module.Query","Server_module.Command","Server_module.Form","Server_module.Prerender","Server_module.RequestEvent","Server_module.ServerRuntime","Server_module.create_effect_transport","Server_module\n .get_server_runtime_or_throw"],"sources":["../../modules/svelte-effect-runtime/server.ts"],"sourcesContent":["/**\n * Default server-side entrypoint for `svelte-effect-runtime`.\n *\n * Re-exports the v3 remote-function helpers (`Query`, `Command`, `Form`,\n * `Prerender`), the `ServerRuntime` builder, and the `RequestEvent` service\n * tag. Consumers normally import this module indirectly: the Vite plugin\n * rewrites the public runtime specifier to this subpath inside `.remote.ts`\n * files so the real implementation runs server-side.\n *\n * @example\n * ```ts\n * import { Query, ServerRuntime } from \"svelte-effect-runtime/_server\";\n * import { Effect, Schema } from \"effect\";\n *\n * ServerRuntime.make();\n *\n * export const hello = Query(Schema.String, (name) =>\n * Effect.succeed(`hello ${name}`)\n * );\n * ```\n *\n * @see https://ser.barekey.dev/content/reference/server-runtime\n *\n * @module\n */\nimport * as Server_module from \"$/v3/server.ts\";\n\nexport type * from \"$/v3/server.ts\";\n\n/**\n * Define a read-only remote function that returns an `Effect` on the client.\n *\n * @see https://ser.barekey.dev/content/remote-functions/query\n */\nexport const Query: typeof Server_module.Query = Server_module.Query;\n/**\n * Define a write-oriented remote function that returns an `Effect` on the\n * client.\n *\n * @see https://ser.barekey.dev/content/remote-functions/command\n */\nexport const Command: typeof Server_module.Command = Server_module.Command;\n/**\n * Define a remote form handler that maps submitted data into an Effect\n * program.\n *\n * @see https://ser.barekey.dev/content/remote-functions/form\n */\nexport const Form: typeof Server_module.Form = Server_module.Form;\n/**\n * Define a prerenderable remote function backed by an Effect program.\n *\n * @see https://ser.barekey.dev/content/remote-functions/prerender\n */\nexport const Prerender: typeof Server_module.Prerender =\n Server_module.Prerender;\n/**\n * Effect `Context.Tag` for the current SvelteKit `RequestEvent`.\n *\n * @see https://ser.barekey.dev/content/runtimes/server\n */\nexport const RequestEvent: typeof Server_module.RequestEvent =\n Server_module.RequestEvent;\n/**\n * Server-side runtime builder used to provide long-lived Effect services to\n * remote functions.\n *\n * @see https://ser.barekey.dev/content/reference/server-runtime\n */\nexport const ServerRuntime: typeof Server_module.ServerRuntime =\n Server_module.ServerRuntime;\n/**\n * Build a devalue transport table from Effect schemas so remote payloads can\n * round-trip custom data across the client/server boundary.\n *\n * @see https://ser.barekey.dev/content/reference/transport\n */\nexport const create_effect_transport:\n typeof Server_module.create_effect_transport =\n Server_module.create_effect_transport;\n/**\n * Resolve the active server runtime, lazily creating a default empty runtime\n * when no explicit one has been registered.\n *\n * @internal Internal - do not use.\n * @see https://ser.barekey.dev/content/reference/server-runtime\n */\nexport const get_server_runtime_or_throw = Server_module\n .get_server_runtime_or_throw as typeof Server_module.get_server_runtime_or_throw;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAa,QAAoCA;;;;;;;AAOjD,MAAa,UAAwCC;;;;;;;AAOrD,MAAa,OAAkCC;;;;;;AAM/C,MAAa,YACXC;;;;;;AAMF,MAAa,eACXC;;;;;;;AAOF,MAAa,gBACXC;;;;;;;AAOF,MAAa,0BAETC;;;;;;;;AAQJ,MAAa,8BAA8BC"}