svelte-effect-runtime 1.6.1 → 2.0.0-beta.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 (174) hide show
  1. package/.dist/chunks/client-BeOE81fW.js +577 -0
  2. package/.dist/chunks/client-BeOE81fW.js.map +1 -0
  3. package/.dist/chunks/descriptors-CU2g4U_i.js +36 -0
  4. package/.dist/chunks/descriptors-CU2g4U_i.js.map +1 -0
  5. package/.dist/chunks/dispatcher-BSg2-ttN.js +339 -0
  6. package/.dist/chunks/dispatcher-BSg2-ttN.js.map +1 -0
  7. package/.dist/chunks/preprocess-BZyUYWY7.js +430 -0
  8. package/.dist/chunks/preprocess-BZyUYWY7.js.map +1 -0
  9. package/.dist/chunks/transform-BtlxgJrg.js +836 -0
  10. package/.dist/chunks/transform-BtlxgJrg.js.map +1 -0
  11. package/.dist/detect.d.ts +34 -0
  12. package/.dist/detect.js +56 -0
  13. package/.dist/detect.js.map +1 -0
  14. package/.dist/dispatcher/deps.d.ts +14 -0
  15. package/.dist/dispatcher/fibers.d.ts +52 -0
  16. package/.dist/dispatcher/index.d.ts +138 -0
  17. package/.dist/dispatcher/types.d.ts +63 -0
  18. package/.dist/dispatcher.d.ts +2 -0
  19. package/.dist/dispatcher.js +2 -0
  20. package/.dist/error.d.ts +77 -0
  21. package/.dist/generators.d.ts +16 -0
  22. package/.dist/internal/descriptors.d.ts +17 -0
  23. package/.dist/internal/generators.d.ts +6 -0
  24. package/.dist/internal/generators.js +5 -0
  25. package/.dist/internal/remote-client.d.ts +6 -0
  26. package/.dist/internal/remote-client.js +2 -0
  27. package/.dist/internal/remote-server.d.ts +6 -0
  28. package/.dist/internal/remote-server.js +2 -0
  29. package/.dist/markup/promise.d.ts +15 -0
  30. package/.dist/markup/promise.js +26 -0
  31. package/.dist/markup/promise.js.map +1 -0
  32. package/.dist/markup/run.d.ts +12 -0
  33. package/.dist/markup/run.js +21 -0
  34. package/.dist/markup/run.js.map +1 -0
  35. package/.dist/markup/transform/apply.d.ts +6 -0
  36. package/.dist/markup/transform/classify.d.ts +15 -0
  37. package/.dist/markup/transform/constants.d.ts +5 -0
  38. package/.dist/markup/transform/emit.d.ts +12 -0
  39. package/.dist/markup/transform/expressions.d.ts +39 -0
  40. package/.dist/markup/transform/index.d.ts +19 -0
  41. package/.dist/markup/transform/scan.d.ts +8 -0
  42. package/.dist/markup/transform/types.d.ts +64 -0
  43. package/.dist/markup/transform.d.ts +1 -0
  44. package/.dist/markup/transform.js +2 -0
  45. package/.dist/markup/value.d.ts +20 -0
  46. package/.dist/markup/value.js +32 -0
  47. package/.dist/markup/value.js.map +1 -0
  48. package/.dist/mod.d.ts +186 -0
  49. package/.dist/mod.js +190 -0
  50. package/.dist/mod.js.map +1 -0
  51. package/.dist/preprocess/ast.d.ts +51 -0
  52. package/.dist/preprocess/imports.d.ts +22 -0
  53. package/.dist/preprocess/index.d.ts +21 -0
  54. package/.dist/preprocess/lower.d.ts +12 -0
  55. package/.dist/preprocess/runtime-block.d.ts +8 -0
  56. package/.dist/preprocess/source.d.ts +29 -0
  57. package/.dist/preprocess/types.d.ts +70 -0
  58. package/.dist/preprocess.d.ts +2 -0
  59. package/.dist/preprocess.js +3 -0
  60. package/.dist/remote/client/command.d.ts +17 -0
  61. package/.dist/remote/client/effect.d.ts +15 -0
  62. package/.dist/remote/client/failures.d.ts +57 -0
  63. package/.dist/remote/client/form-data.d.ts +8 -0
  64. package/.dist/remote/client/form-enhance.d.ts +9 -0
  65. package/.dist/remote/client/form-transport.d.ts +20 -0
  66. package/.dist/remote/client/form.d.ts +21 -0
  67. package/.dist/remote/client/index.d.ts +4 -0
  68. package/.dist/remote/client/query-result.d.ts +14 -0
  69. package/.dist/remote/client/query.d.ts +57 -0
  70. package/.dist/remote/client/responses.d.ts +28 -0
  71. package/.dist/remote/client/types.d.ts +83 -0
  72. package/.dist/remote/client/utils.d.ts +11 -0
  73. package/.dist/remote/client.d.ts +2 -0
  74. package/.dist/remote/client.js +2 -0
  75. package/.dist/remote/server.d.ts +66 -0
  76. package/.dist/remote/server.js +104 -0
  77. package/.dist/remote/server.js.map +1 -0
  78. package/.dist/remote/shared.d.ts +202 -0
  79. package/.dist/remote/shared.js +161 -0
  80. package/.dist/remote/shared.js.map +1 -0
  81. package/.dist/runtime/preprocess.d.ts +38 -0
  82. package/.dist/runtime/preprocess.js +54 -0
  83. package/.dist/runtime/preprocess.js.map +1 -0
  84. package/.dist/server/effects.d.ts +49 -0
  85. package/.dist/server/factories.d.ts +97 -0
  86. package/.dist/server/index.d.ts +3 -0
  87. package/.dist/server/invalid.d.ts +9 -0
  88. package/.dist/server/runtime.d.ts +66 -0
  89. package/.dist/server/schema.d.ts +42 -0
  90. package/.dist/server/types.d.ts +271 -0
  91. package/.dist/server/wrappers.d.ts +45 -0
  92. package/.dist/server.d.ts +2 -0
  93. package/.dist/server.js +527 -0
  94. package/.dist/server.js.map +1 -0
  95. package/.dist/vite.d.ts +42 -0
  96. package/.dist/vite.js +118 -0
  97. package/.dist/vite.js.map +1 -0
  98. package/README.md +2 -0
  99. package/package.json +66 -101
  100. package/dist/chunks/client-vV6UAwoP.js +0 -199
  101. package/dist/chunks/client-vV6UAwoP.js.map +0 -1
  102. package/dist/chunks/effect-compat-BhW0YPIs.js +0 -103
  103. package/dist/chunks/effect-compat-BhW0YPIs.js.map +0 -1
  104. package/dist/chunks/effect-zCli5qgO.js +0 -51
  105. package/dist/chunks/effect-zCli5qgO.js.map +0 -1
  106. package/dist/chunks/magic-string.es-BnGH-5YR.js +0 -1013
  107. package/dist/chunks/magic-string.es-BnGH-5YR.js.map +0 -1
  108. package/dist/chunks/markup-D4zJP7U1.js +0 -13383
  109. package/dist/chunks/markup-D4zJP7U1.js.map +0 -1
  110. package/dist/chunks/preprocess-DIC5iR0_.js +0 -49
  111. package/dist/chunks/preprocess-DIC5iR0_.js.map +0 -1
  112. package/dist/chunks/server-Dea1CJuY.js +0 -704
  113. package/dist/chunks/server-Dea1CJuY.js.map +0 -1
  114. package/dist/chunks/v3-D0c0MKPf.js +0 -1
  115. package/dist/chunks/v4-MMhHmzIG.js +0 -1
  116. package/dist/chunks/vite-Bm2RdiT3.js +0 -152
  117. package/dist/chunks/vite-Bm2RdiT3.js.map +0 -1
  118. package/dist/client.d.ts +0 -1
  119. package/dist/client.js +0 -2
  120. package/dist/effect.d.ts +0 -1
  121. package/dist/effect.js +0 -2
  122. package/dist/internal/app-server-shim.d.ts +0 -8
  123. package/dist/internal/effect-compat.d.ts +0 -21
  124. package/dist/internal/markup.d.ts +0 -11
  125. package/dist/internal/markup.js +0 -2
  126. package/dist/internal/remote-client.d.ts +0 -36
  127. package/dist/internal/remote-client.js +0 -527
  128. package/dist/internal/remote-client.js.map +0 -1
  129. package/dist/internal/remote-shared.d.ts +0 -186
  130. package/dist/internal/remote-shared.js +0 -122
  131. package/dist/internal/remote-shared.js.map +0 -1
  132. package/dist/internal/transform.d.ts +0 -18
  133. package/dist/internal/transform.js +0 -418
  134. package/dist/internal/transform.js.map +0 -1
  135. package/dist/language-server.d.ts +0 -9
  136. package/dist/language-server.js +0 -4
  137. package/dist/mod.d.ts +0 -22
  138. package/dist/mod.js +0 -3
  139. package/dist/preprocess.d.ts +0 -29
  140. package/dist/preprocess.js +0 -20
  141. package/dist/preprocess.js.map +0 -1
  142. package/dist/root-node.d.ts +0 -1
  143. package/dist/root-node.js +0 -63
  144. package/dist/root-node.js.map +0 -1
  145. package/dist/server.d.ts +0 -81
  146. package/dist/server.js +0 -85
  147. package/dist/server.js.map +0 -1
  148. package/dist/v3/client.d.ts +0 -117
  149. package/dist/v3/effect.d.ts +0 -17
  150. package/dist/v3/mod.d.ts +0 -27
  151. package/dist/v3/preprocess.d.ts +0 -28
  152. package/dist/v3/root-node.d.ts +0 -59
  153. package/dist/v3/server.d.ts +0 -297
  154. package/dist/v3/vite.d.ts +0 -46
  155. package/dist/v4/client.d.ts +0 -2
  156. package/dist/v4/effect.d.ts +0 -24
  157. package/dist/v4/effect.js +0 -19
  158. package/dist/v4/effect.js.map +0 -1
  159. package/dist/v4/mod.d.ts +0 -27
  160. package/dist/v4/mod.js +0 -3
  161. package/dist/v4/preprocess.d.ts +0 -34
  162. package/dist/v4/preprocess.js +0 -32
  163. package/dist/v4/preprocess.js.map +0 -1
  164. package/dist/v4/root-node.d.ts +0 -59
  165. package/dist/v4/root-node.js +0 -4
  166. package/dist/v4/server.d.ts +0 -340
  167. package/dist/v4/server.js +0 -71
  168. package/dist/v4/server.js.map +0 -1
  169. package/dist/v4/vite.d.ts +0 -34
  170. package/dist/v4/vite.js +0 -31
  171. package/dist/v4/vite.js.map +0 -1
  172. package/dist/vite.d.ts +0 -31
  173. package/dist/vite.js +0 -24
  174. package/dist/vite.js.map +0 -1
@@ -1,418 +0,0 @@
1
- import { t as MagicString } from "../chunks/magic-string.es-BnGH-5YR.js";
2
- import ts from "typescript";
3
- //#region internal/transform.ts
4
- const DEFAULT_RUNTIME_MODULE_ID = "svelte-effect-runtime";
5
- const DEFAULT_EFFECT_MODULE_ID = "effect";
6
- const DEFAULT_SVELTE_MODULE_ID = "svelte";
7
- const RUNE_IDENTIFIERS = new Set([
8
- "$bindable",
9
- "$derived",
10
- "$effect",
11
- "$host",
12
- "$inspect",
13
- "$props",
14
- "$state"
15
- ]);
16
- const HOISTED_KINDS = new Set([
17
- ts.SyntaxKind.ClassDeclaration,
18
- ts.SyntaxKind.EmptyStatement,
19
- ts.SyntaxKind.EnumDeclaration,
20
- ts.SyntaxKind.ExportAssignment,
21
- ts.SyntaxKind.ExportDeclaration,
22
- ts.SyntaxKind.FunctionDeclaration,
23
- ts.SyntaxKind.ImportDeclaration,
24
- ts.SyntaxKind.ImportEqualsDeclaration,
25
- ts.SyntaxKind.InterfaceDeclaration,
26
- ts.SyntaxKind.ModuleDeclaration,
27
- ts.SyntaxKind.TypeAliasDeclaration
28
- ]);
29
- const HOISTED_CALL_IDENTIFIERS = new Set([
30
- "$effect",
31
- "__svelteEffectRuntimeMarkupOnDestroy",
32
- "onDestroy"
33
- ]);
34
- function transformEffectScript(content, options) {
35
- const sourceFile = ts.createSourceFile(options.filename, content, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
36
- const effectStatements = [];
37
- const runtimeStatements = [];
38
- const pendingRelocations = [];
39
- const magicString = new MagicString(content);
40
- const effectBoundBindings = /* @__PURE__ */ new Set();
41
- for (const statement of sourceFile.statements) {
42
- if (ts.isVariableStatement(statement)) {
43
- if (isGeneratedMarkupHelperStatement(statement, content)) continue;
44
- const transformed = transformVariableStatement(statement, content, options.filename, effectBoundBindings);
45
- if (transformed.hoistedText.length === 0) magicString.remove(statement.getFullStart(), statement.end);
46
- else magicString.overwrite(statement.getStart(sourceFile), statement.end, transformed.hoistedText);
47
- runtimeStatements.push(...transformed.effectTexts);
48
- pendingRelocations.push(...transformed.pendingRelocations);
49
- for (const bindingName of transformed.loweredBindings) effectBoundBindings.add(bindingName);
50
- continue;
51
- }
52
- if (isHoistedExpressionStatement(statement)) continue;
53
- if (isHoistedStatement(statement)) continue;
54
- if (containsTopLevelAwait(statement)) throw new Error(`${options.filename}: top-level await is not supported in <script effect>. Use yield* Effect.promise(...) or yield* Effect.tryPromise(...) instead.`);
55
- effectStatements.push({
56
- node: statement,
57
- text: normalizeStatementText(sliceNode(content, statement))
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
- });
66
- }
67
- for (const statement of [...effectStatements].reverse()) magicString.remove(statement.node.getFullStart(), statement.node.end);
68
- const allRuntimeStatements = [...runtimeStatements, ...effectStatements.map((statement) => statement.text)];
69
- if (allRuntimeStatements.length > 0) {
70
- magicString.prepend(makeInjectedImports(options));
71
- magicString.append(makeRuntimeBlock(allRuntimeStatements));
72
- }
73
- const code = magicString.toString();
74
- return {
75
- code,
76
- map: magicString.generateMap({
77
- hires: true,
78
- includeContent: true,
79
- source: options.filename
80
- }),
81
- relocations: resolvePendingRelocations(pendingRelocations, code)
82
- };
83
- }
84
- function isHoistedStatement(statement) {
85
- return HOISTED_KINDS.has(statement.kind);
86
- }
87
- function isHoistedExpressionStatement(statement) {
88
- if (!ts.isExpressionStatement(statement)) return false;
89
- if (!ts.isCallExpression(statement.expression)) return false;
90
- return getCalledIdentifierText(statement.expression.expression) !== void 0 && HOISTED_CALL_IDENTIFIERS.has(getCalledIdentifierText(statement.expression.expression));
91
- }
92
- function getCalledIdentifierText(expression) {
93
- if (ts.isIdentifier(expression)) return expression.text;
94
- if (ts.isPropertyAccessExpression(expression)) {
95
- const base = getCalledIdentifierText(expression.expression);
96
- return base ? `${base}.${expression.name.text}` : expression.name.text;
97
- }
98
- }
99
- function transformVariableStatement(statement, content, filename, effectBoundBindings) {
100
- if ((statement.modifiers?.length ?? 0) > 0) {
101
- validateModifiedVariableStatement(statement, content, filename);
102
- return {
103
- effectTexts: [],
104
- hoistedText: normalizeStatementText(sliceNode(content, statement)),
105
- loweredBindings: [],
106
- pendingRelocations: [],
107
- usesPendingYieldHelper: false
108
- };
109
- }
110
- const effectTexts = [];
111
- const hoistedDeclarations = [];
112
- const loweredBindings = [];
113
- const pendingRelocations = [];
114
- for (const declaration of statement.declarationList.declarations) {
115
- if (declaration.initializer && containsTopLevelAwait(declaration.initializer)) {
116
- const statementText = normalizeStatementText(sliceNode(content, statement));
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}`);
118
- }
119
- if (declaration.initializer && isRuneInitializer(declaration.initializer)) {
120
- const renderedDeclaration = `${getDeclarationKind(statement.declarationList.flags)} ${normalizeStatementText(sliceNode(content, declaration))};`;
121
- hoistedDeclarations.push(renderedDeclaration);
122
- pendingRelocations.push(...make_declaration_relocations(declaration, renderedDeclaration, content));
123
- continue;
124
- }
125
- if (shouldHoistDeclaration(statement.declarationList.flags, declaration, effectBoundBindings)) {
126
- const renderedDeclaration = `${getDeclarationKind(statement.declarationList.flags)} ${normalizeStatementText(sliceNode(content, declaration))};`;
127
- hoistedDeclarations.push(renderedDeclaration);
128
- pendingRelocations.push(...make_declaration_relocations(declaration, renderedDeclaration, content));
129
- continue;
130
- }
131
- const bindingNames = extractBindingNames(declaration.name);
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
- }
143
- loweredBindings.push(...bindingNames);
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
- }
152
- }
153
- return {
154
- effectTexts,
155
- hoistedText: hoistedDeclarations.join("\n"),
156
- loweredBindings,
157
- pendingRelocations,
158
- usesPendingYieldHelper: false
159
- };
160
- }
161
- function shouldHoistDeclaration(flags, declaration, effectBoundBindings) {
162
- if ((flags & ts.NodeFlags.Const) === 0) return false;
163
- if (!declaration.initializer) return false;
164
- if (containsYieldStar(declaration.initializer) || containsTopLevelAwait(declaration.initializer)) return false;
165
- return !referencesEffectBoundBindings(declaration.initializer, effectBoundBindings);
166
- }
167
- function referencesEffectBoundBindings(node, effectBoundBindings) {
168
- const localScopes = [/* @__PURE__ */ new Set()];
169
- let found = false;
170
- const visit = (current) => {
171
- if (found) return;
172
- if (ts.isArrowFunction(current) || ts.isFunctionDeclaration(current) || ts.isFunctionExpression(current)) {
173
- const scope = /* @__PURE__ */ new Set();
174
- if (current.name) scope.add(current.name.text);
175
- for (const parameter of current.parameters) declareBindingInto(scope, parameter.name);
176
- localScopes.unshift(scope);
177
- current.forEachChild(visit);
178
- localScopes.shift();
179
- return;
180
- }
181
- if (ts.isIdentifier(current)) {
182
- if (!isSkippedReference(current) && effectBoundBindings.has(current.text) && !localScopes.some((scope) => scope.has(current.text))) found = true;
183
- return;
184
- }
185
- current.forEachChild(visit);
186
- };
187
- const declareBindingInto = (scope, name) => {
188
- if (ts.isIdentifier(name)) {
189
- scope.add(name.text);
190
- return;
191
- }
192
- for (const element of name.elements) {
193
- if (ts.isOmittedExpression(element)) continue;
194
- declareBindingInto(scope, element.name);
195
- }
196
- };
197
- visit(node);
198
- return found;
199
- }
200
- function isSkippedReference(identifier) {
201
- const parent = identifier.parent;
202
- return ts.isPropertyAccessExpression(parent) && parent.name === identifier || ts.isPropertyAssignment(parent) && parent.name === identifier || ts.isShorthandPropertyAssignment(parent) && parent.objectAssignmentInitializer === identifier || ts.isBindingElement(parent) && parent.propertyName === identifier || ts.isImportSpecifier(parent) || ts.isExportSpecifier(parent) || ts.isLabeledStatement(parent) && parent.label === identifier;
203
- }
204
- function isGeneratedMarkupHelperStatement(statement, content) {
205
- return statement.declarationList.declarations.every((declaration) => extractBindingNames(declaration.name).every((name) => name.startsWith("__svelteEffectRuntimeMarkup")) || normalizeStatementText(sliceNode(content, declaration)).startsWith("__svelteEffectRuntimeMarkup"));
206
- }
207
- function validateModifiedVariableStatement(statement, content, filename) {
208
- for (const declaration of statement.declarationList.declarations) if (declaration.initializer && (containsYieldStar(declaration.initializer) || containsTopLevelAwait(declaration.initializer))) {
209
- const statementText = normalizeStatementText(sliceNode(content, statement));
210
- throw new Error(`${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}`);
211
- }
212
- }
213
- function getDeclarationKind(flags) {
214
- if ((flags & ts.NodeFlags.Const) !== 0) return "const";
215
- if ((flags & ts.NodeFlags.Let) !== 0) return "let";
216
- return "var";
217
- }
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
- };
239
- }
240
- function makeEffectAssignment(name, initializer, content) {
241
- const target = normalizeStatementText(sliceNode(content, name));
242
- const expression = typeof initializer === "string" ? initializer : normalizeStatementText(sliceNode(content, initializer));
243
- if (ts.isIdentifier(name)) return `${target} = ${expression};`;
244
- return `(${target} = ${expression});`;
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
- }
257
- function extractBindingNames(name) {
258
- if (ts.isIdentifier(name)) return [name.text];
259
- const names = [];
260
- for (const element of name.elements) {
261
- if (ts.isOmittedExpression(element)) continue;
262
- names.push(...extractBindingNames(element.name));
263
- }
264
- return names;
265
- }
266
- function isRuneInitializer(expression) {
267
- if (!ts.isCallExpression(expression)) return false;
268
- return isRuneCallee(expression.expression);
269
- }
270
- function isRuneCallee(expression) {
271
- if (ts.isIdentifier(expression)) return RUNE_IDENTIFIERS.has(expression.text);
272
- if (ts.isPropertyAccessExpression(expression)) return isRuneCallee(expression.expression);
273
- return false;
274
- }
275
- function containsYieldStar(node) {
276
- if (ts.isBinaryExpression(node) && node.operatorToken.kind === ts.SyntaxKind.AsteriskToken && ts.isIdentifier(node.left) && node.left.text === "yield") return true;
277
- return node.getChildren().some((child) => isFunctionBoundary(child) ? false : containsYieldStar(child));
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
- }
283
- function containsTopLevelAwait(node) {
284
- if (ts.isAwaitExpression(node)) return true;
285
- return node.getChildren().some((child) => isFunctionBoundary(child) ? false : containsTopLevelAwait(child));
286
- }
287
- function isFunctionBoundary(node) {
288
- return ts.isArrowFunction(node) || ts.isFunctionDeclaration(node) || ts.isFunctionExpression(node) || ts.isMethodDeclaration(node) || ts.isGetAccessorDeclaration(node) || ts.isSetAccessorDeclaration(node);
289
- }
290
- function sliceNode(content, node) {
291
- return content.slice(node.getFullStart(), node.end);
292
- }
293
- function normalizeStatementText(text) {
294
- return text.trim();
295
- }
296
- function indentBlock(text, indent) {
297
- return text.split("\n").map((line) => line.length > 0 ? `${indent}${line}` : line).join("\n");
298
- }
299
- function makeInjectedImports(options) {
300
- const runtimeModuleId = options.runtimeModuleId ?? DEFAULT_RUNTIME_MODULE_ID;
301
- const effectModuleId = options.effectModuleId ?? DEFAULT_EFFECT_MODULE_ID;
302
- const lines = [
303
- `import { onMount as __svelteEffectRuntimeOnMount } from "${options.svelteModuleId ?? DEFAULT_SVELTE_MODULE_ID}";`,
304
- `import { Effect as __svelteEffectRuntimeEffect } from "${effectModuleId}";`,
305
- `import { get_effect_runtime_or_throw as __svelteEffectRuntimeGetRuntime, run_component_effect as __svelteEffectRuntimeRunComponentEffect } from "${runtimeModuleId}";`,
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;
379
- }
380
- function makeRuntimeBlock(statements) {
381
- return [
382
- "",
383
- "const __svelteEffectRuntimeProgram = __svelteEffectRuntimeEffect.gen(function* () {",
384
- statements.map((statement) => indentBlock(statement, " ")).join("\n\n"),
385
- "});",
386
- "",
387
- "__svelteEffectRuntimeOnMount(() => {",
388
- " const __svelteEffectRuntimeCleanup = __svelteEffectRuntimeRunComponentEffect(",
389
- " __svelteEffectRuntimeGetRuntime(),",
390
- " __svelteEffectRuntimeProgram,",
391
- " );",
392
- "",
393
- " import.meta.hot?.dispose(__svelteEffectRuntimeCleanup);",
394
- " return __svelteEffectRuntimeCleanup;",
395
- "});",
396
- ""
397
- ].join("\n");
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
- }
415
- //#endregion
416
- export { transformEffectScript };
417
-
418
- //# sourceMappingURL=transform.js.map
@@ -1 +0,0 @@
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,gBAAg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,QAAQ,CACjC;EAGF,MAAM,QAAQ,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,9 +0,0 @@
1
- /**
2
- * Language-server-facing exports used to apply the `svelte-effect-runtime`
3
- * transforms inside editor tooling.
4
- *
5
- * @module
6
- */
7
- export { effect_preprocess } from "./preprocess.js";
8
- export { transformEffectMarkup as transform_effect_markup } from "./internal/markup.js";
9
- export { transformEffectScript as transform_effect_script } from "./internal/transform.js";
@@ -1,4 +0,0 @@
1
- import { t as transformEffectMarkup } from "./chunks/markup-D4zJP7U1.js";
2
- import { transformEffectScript } from "./internal/transform.js";
3
- import { effect_preprocess } from "./preprocess.js";
4
- export { effect_preprocess, transformEffectMarkup as transform_effect_markup, transformEffectScript as transform_effect_script };
package/dist/mod.d.ts DELETED
@@ -1,22 +0,0 @@
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
- */
22
- export * from "./v3/mod.js";
package/dist/mod.js DELETED
@@ -1,3 +0,0 @@
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
- export { ClientRuntime, get_effect_runtime_or_throw, run_component_effect, run_inline_effect, to_effect, to_native };
@@ -1,29 +0,0 @@
1
- /**
2
- * Public preprocess entrypoint for `svelte-effect-runtime`.
3
- *
4
- * @example
5
- * ```ts
6
- * import { effect_preprocess } from "svelte-effect-runtime/preprocess";
7
- *
8
- * export default {
9
- * preprocess: [effect_preprocess()],
10
- * };
11
- * ```
12
- *
13
- * @module
14
- */
15
- import type { PreprocessorGroup } from "svelte/compiler";
16
- import { type EffectPreprocessOptions } from "./v3/preprocess.js";
17
- export type { EffectPreprocessOptions } from "./v3/preprocess.js";
18
- /**
19
- * Low-level `.svelte` preprocessor used by the higher-level `effect()`
20
- * plugin.
21
- *
22
- * @see https://ser.barekey.dev/content/reference/preprocess
23
- */
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,20 +0,0 @@
1
- import { t as effect_preprocess$1 } from "./chunks/preprocess-DIC5iR0_.js";
2
- //#region preprocess.ts
3
- /**
4
- * Low-level `.svelte` preprocessor used by the higher-level `effect()`
5
- * plugin.
6
- *
7
- * @see https://ser.barekey.dev/content/reference/preprocess
8
- */
9
- function effect_preprocess(options) {
10
- return effect_preprocess$1(options);
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;
17
- //#endregion
18
- export { effectPreprocess, effect_preprocess };
19
-
20
- //# sourceMappingURL=preprocess.js.map
@@ -1 +0,0 @@
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"}
@@ -1 +0,0 @@
1
- export * from "./v3/root-node.js";