@bubblelab/bubble-runtime 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +202 -0
- package/dist/extraction/BubbleParser.d.ts +80 -0
- package/dist/extraction/BubbleParser.d.ts.map +1 -0
- package/dist/extraction/BubbleParser.js +926 -0
- package/dist/extraction/BubbleParser.js.map +1 -0
- package/dist/extraction/index.d.ts +2 -0
- package/dist/extraction/index.d.ts.map +1 -0
- package/dist/extraction/index.js +4 -0
- package/dist/extraction/index.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/injection/BubbleInjector.d.ts +71 -0
- package/dist/injection/BubbleInjector.d.ts.map +1 -0
- package/dist/injection/BubbleInjector.js +326 -0
- package/dist/injection/BubbleInjector.js.map +1 -0
- package/dist/injection/LoggerInjector.d.ts +33 -0
- package/dist/injection/LoggerInjector.d.ts.map +1 -0
- package/dist/injection/LoggerInjector.js +154 -0
- package/dist/injection/LoggerInjector.js.map +1 -0
- package/dist/injection/index.d.ts +3 -0
- package/dist/injection/index.d.ts.map +1 -0
- package/dist/injection/index.js +3 -0
- package/dist/injection/index.js.map +1 -0
- package/dist/parse/BubbleScript.d.ts +141 -0
- package/dist/parse/BubbleScript.d.ts.map +1 -0
- package/dist/parse/BubbleScript.js +513 -0
- package/dist/parse/BubbleScript.js.map +1 -0
- package/dist/parse/index.d.ts +3 -0
- package/dist/parse/index.d.ts.map +1 -0
- package/dist/parse/index.js +3 -0
- package/dist/parse/index.js.map +1 -0
- package/dist/parse/traceDependencies.d.ts +18 -0
- package/dist/parse/traceDependencies.d.ts.map +1 -0
- package/dist/parse/traceDependencies.js +181 -0
- package/dist/parse/traceDependencies.js.map +1 -0
- package/dist/runtime/BubbleRunner.d.ts +91 -0
- package/dist/runtime/BubbleRunner.d.ts.map +1 -0
- package/dist/runtime/BubbleRunner.js +586 -0
- package/dist/runtime/BubbleRunner.js.map +1 -0
- package/dist/runtime/index.d.ts +2 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +2 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/types.d.ts +29 -0
- package/dist/runtime/types.d.ts.map +1 -0
- package/dist/runtime/types.js +2 -0
- package/dist/runtime/types.js.map +1 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/bubble-helper.d.ts +11 -0
- package/dist/utils/bubble-helper.d.ts.map +1 -0
- package/dist/utils/bubble-helper.js +15 -0
- package/dist/utils/bubble-helper.js.map +1 -0
- package/dist/utils/parameter-formatter.d.ts +22 -0
- package/dist/utils/parameter-formatter.d.ts.map +1 -0
- package/dist/utils/parameter-formatter.js +219 -0
- package/dist/utils/parameter-formatter.js.map +1 -0
- package/dist/validation/BubbleValidator.d.ts +43 -0
- package/dist/validation/BubbleValidator.d.ts.map +1 -0
- package/dist/validation/BubbleValidator.js +172 -0
- package/dist/validation/BubbleValidator.js.map +1 -0
- package/dist/validation/index.d.ts +27 -0
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/validation/index.js +126 -0
- package/dist/validation/index.js.map +1 -0
- package/package.json +47 -0
|
@@ -0,0 +1,513 @@
|
|
|
1
|
+
import { analyze, resetIds } from '@typescript-eslint/scope-manager';
|
|
2
|
+
import { parse } from '@typescript-eslint/typescript-estree';
|
|
3
|
+
import { BubbleParser } from '../extraction/BubbleParser';
|
|
4
|
+
export class BubbleScript {
|
|
5
|
+
ast;
|
|
6
|
+
scopeManager;
|
|
7
|
+
// Stores parsed bubble information with variable $id as key
|
|
8
|
+
parsedBubbles;
|
|
9
|
+
originalParsedBubbles;
|
|
10
|
+
scriptVariables; // Maps Variable.$id to Variable
|
|
11
|
+
variableLocations; // Maps Variable.$id to location
|
|
12
|
+
handleMethodLocation;
|
|
13
|
+
bubbleScript;
|
|
14
|
+
bubbleFactory;
|
|
15
|
+
currentBubbleScript;
|
|
16
|
+
triggerEventType;
|
|
17
|
+
/**
|
|
18
|
+
* Reparse the AST and bubbles after the script has been modified
|
|
19
|
+
* This is necessary when the script text changes but we need updated bubble locations
|
|
20
|
+
*/
|
|
21
|
+
reparseAST() {
|
|
22
|
+
// Reset ID generator to ensure deterministic variable IDs
|
|
23
|
+
resetIds();
|
|
24
|
+
// Parse the modified script into a new AST
|
|
25
|
+
this.ast = parse(this.currentBubbleScript, {
|
|
26
|
+
range: true, // Required for scope-manager
|
|
27
|
+
loc: true, // Location info for line numbers
|
|
28
|
+
sourceType: 'module', // Treat as ES module
|
|
29
|
+
ecmaVersion: 2022, // Modern JS/TS features
|
|
30
|
+
});
|
|
31
|
+
console.log('Done parsing AST');
|
|
32
|
+
// Analyze scope to build variable dependency graph
|
|
33
|
+
this.scopeManager = analyze(this.ast, {
|
|
34
|
+
sourceType: 'module',
|
|
35
|
+
});
|
|
36
|
+
this.variableLocations = {};
|
|
37
|
+
console.log('Done building variable mapping');
|
|
38
|
+
// Build variable mapping first
|
|
39
|
+
this.scriptVariables = this.buildVariableMapping();
|
|
40
|
+
console.log('Done building variable mapping');
|
|
41
|
+
// Parse bubble dependencies from AST using the provided factory and scope manager
|
|
42
|
+
const bubbleParser = new BubbleParser(this.currentBubbleScript);
|
|
43
|
+
const parseResult = bubbleParser.parseBubblesFromAST(this.bubbleFactory, this.ast, this.scopeManager);
|
|
44
|
+
this.parsedBubbles = parseResult.bubbles;
|
|
45
|
+
this.triggerEventType =
|
|
46
|
+
this.getBubbleTriggerEventType();
|
|
47
|
+
}
|
|
48
|
+
constructor(bubbleScript, bubbleFactory) {
|
|
49
|
+
// Reset ID generator to ensure deterministic variable IDs
|
|
50
|
+
resetIds();
|
|
51
|
+
// Parse the bubble script into AST
|
|
52
|
+
this.bubbleScript = bubbleScript;
|
|
53
|
+
this.currentBubbleScript = bubbleScript;
|
|
54
|
+
this.bubbleFactory = bubbleFactory;
|
|
55
|
+
this.ast = parse(bubbleScript, {
|
|
56
|
+
range: true, // Required for scope-manager
|
|
57
|
+
loc: true, // Location info for line numbers
|
|
58
|
+
sourceType: 'module', // Treat as ES module
|
|
59
|
+
ecmaVersion: 2022, // Modern JS/TS features
|
|
60
|
+
});
|
|
61
|
+
// Analyze scope to build variable dependency graph
|
|
62
|
+
this.scopeManager = analyze(this.ast, {
|
|
63
|
+
sourceType: 'module',
|
|
64
|
+
});
|
|
65
|
+
this.variableLocations = {};
|
|
66
|
+
// Build variable mapping first
|
|
67
|
+
this.scriptVariables = this.buildVariableMapping();
|
|
68
|
+
// Parse bubble dependencies from AST using the provided factory and scope manager
|
|
69
|
+
const bubbleParser = new BubbleParser(bubbleScript);
|
|
70
|
+
const parseResult = bubbleParser.parseBubblesFromAST(bubbleFactory, this.ast, this.scopeManager);
|
|
71
|
+
this.parsedBubbles = parseResult.bubbles;
|
|
72
|
+
this.originalParsedBubbles = parseResult.bubbles;
|
|
73
|
+
this.handleMethodLocation = parseResult.handleMethodLocation;
|
|
74
|
+
this.triggerEventType =
|
|
75
|
+
this.getBubbleTriggerEventType();
|
|
76
|
+
}
|
|
77
|
+
// getter for bubblescript (computed property)
|
|
78
|
+
get bubblescript() {
|
|
79
|
+
// Regenerate the script
|
|
80
|
+
return this.currentBubbleScript;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Get all variable names available at a specific line (excluding globals)
|
|
84
|
+
* This is like setting a debugger breakpoint at that line
|
|
85
|
+
*/
|
|
86
|
+
getVarsForLine(lineNumber) {
|
|
87
|
+
// Find ALL scopes that contain this line (not just one)
|
|
88
|
+
const containingScopes = this.getAllScopesContainingLine(lineNumber);
|
|
89
|
+
if (containingScopes.length === 0) {
|
|
90
|
+
return [];
|
|
91
|
+
}
|
|
92
|
+
// Collect variables from all containing scopes
|
|
93
|
+
const allAccessibleVars = new Set();
|
|
94
|
+
for (const scope of containingScopes) {
|
|
95
|
+
// Add variables from this scope
|
|
96
|
+
for (const variable of scope.variables) {
|
|
97
|
+
allAccessibleVars.add(variable);
|
|
98
|
+
}
|
|
99
|
+
// Walk up the parent chain for this scope
|
|
100
|
+
let parentScope = scope.upper;
|
|
101
|
+
while (parentScope) {
|
|
102
|
+
for (const variable of parentScope.variables) {
|
|
103
|
+
allAccessibleVars.add(variable);
|
|
104
|
+
}
|
|
105
|
+
parentScope = parentScope.upper;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
// Convert to array and filter
|
|
109
|
+
const accessibleVars = Array.from(allAccessibleVars);
|
|
110
|
+
// Filter out global/built-in variables AND variables declared after this line
|
|
111
|
+
return accessibleVars
|
|
112
|
+
.filter((variable) => !this.isGlobalVariable(variable))
|
|
113
|
+
.filter((variable) => this.isVariableDeclaredBeforeLine(variable, lineNumber))
|
|
114
|
+
.map((variable) => variable);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Find ALL scopes that contain the given line number
|
|
118
|
+
* This is crucial because variables can be in sibling scopes (like block + for)
|
|
119
|
+
*/
|
|
120
|
+
getAllScopesContainingLine(lineNumber) {
|
|
121
|
+
const containingScopes = [];
|
|
122
|
+
for (const scope of this.scopeManager.scopes) {
|
|
123
|
+
const scopeStart = scope.block.loc?.start.line || 0;
|
|
124
|
+
const scopeEnd = scope.block.loc?.end.line || 0;
|
|
125
|
+
// Check if line is within this scope
|
|
126
|
+
if (lineNumber >= scopeStart && lineNumber <= scopeEnd) {
|
|
127
|
+
containingScopes.push(scope);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
// Sort by specificity (smaller ranges first, then by type priority)
|
|
131
|
+
return containingScopes.sort((a, b) => {
|
|
132
|
+
const rangeA = (a.block.loc?.end.line || 0) - (a.block.loc?.start.line || 0);
|
|
133
|
+
const rangeB = (b.block.loc?.end.line || 0) - (b.block.loc?.start.line || 0);
|
|
134
|
+
if (rangeA !== rangeB) {
|
|
135
|
+
return rangeA - rangeB; // Smaller range first
|
|
136
|
+
}
|
|
137
|
+
// Same range, prefer by type priority
|
|
138
|
+
const scopePriority = {
|
|
139
|
+
block: 5,
|
|
140
|
+
for: 4,
|
|
141
|
+
function: 3,
|
|
142
|
+
module: 2,
|
|
143
|
+
global: 1,
|
|
144
|
+
};
|
|
145
|
+
const priorityA = scopePriority[a.type] || 0;
|
|
146
|
+
const priorityB = scopePriority[b.type] || 0;
|
|
147
|
+
return priorityB - priorityA; // Higher priority first
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Find the most specific scope that contains the given line number
|
|
152
|
+
*/
|
|
153
|
+
findScopeForLine(lineNumber) {
|
|
154
|
+
let targetScope = null;
|
|
155
|
+
let smallestRange = Infinity;
|
|
156
|
+
for (const scope of this.scopeManager.scopes) {
|
|
157
|
+
const scopeStart = scope.block.loc?.start.line || 0;
|
|
158
|
+
const scopeEnd = scope.block.loc?.end.line || 0;
|
|
159
|
+
// Check if line is within this scope
|
|
160
|
+
if (lineNumber >= scopeStart && lineNumber <= scopeEnd) {
|
|
161
|
+
const scopeRange = scopeEnd - scopeStart;
|
|
162
|
+
// Prefer module scope over global scope when they have same range
|
|
163
|
+
const isPreferredScope = scope.type === 'module' && targetScope?.type === 'global';
|
|
164
|
+
// Find the most specific (smallest) scope containing this line
|
|
165
|
+
if (scopeRange < smallestRange || isPreferredScope) {
|
|
166
|
+
smallestRange = scopeRange;
|
|
167
|
+
targetScope = scope;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return targetScope;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Get all variables accessible from a scope (including parent scopes)
|
|
175
|
+
* This mimics how debugger shows variables from current scope + outer scopes
|
|
176
|
+
*/
|
|
177
|
+
getAllAccessibleVariables(scope) {
|
|
178
|
+
const variables = [];
|
|
179
|
+
let currentScope = scope;
|
|
180
|
+
// Walk up the scope chain (like debugger scope stack)
|
|
181
|
+
while (currentScope) {
|
|
182
|
+
variables.push(...currentScope.variables);
|
|
183
|
+
currentScope = currentScope.upper; // Parent scope
|
|
184
|
+
}
|
|
185
|
+
return variables;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Check if a variable is declared before a given line number
|
|
189
|
+
* This ensures we only return variables that actually exist at the breakpoint
|
|
190
|
+
*/
|
|
191
|
+
isVariableDeclaredBeforeLine(variable, lineNumber) {
|
|
192
|
+
// Get the line where this variable is declared
|
|
193
|
+
const declarations = variable.defs;
|
|
194
|
+
if (!declarations || declarations.length === 0) {
|
|
195
|
+
return true; // If no declaration info, assume it's available (like function params)
|
|
196
|
+
}
|
|
197
|
+
// Check if any declaration is at or before the target line
|
|
198
|
+
return declarations.some((def) => {
|
|
199
|
+
const declLine = def.node?.loc?.start?.line;
|
|
200
|
+
return declLine !== undefined && declLine <= lineNumber;
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Check if a variable is a global/built-in (filter these out)
|
|
205
|
+
*/
|
|
206
|
+
isGlobalVariable(variable) {
|
|
207
|
+
// Filter out TypeScript/JavaScript built-ins
|
|
208
|
+
const globalNames = new Set([
|
|
209
|
+
'console',
|
|
210
|
+
'Array',
|
|
211
|
+
'Object',
|
|
212
|
+
'String',
|
|
213
|
+
'Number',
|
|
214
|
+
'Boolean',
|
|
215
|
+
'Date',
|
|
216
|
+
'Math',
|
|
217
|
+
'JSON',
|
|
218
|
+
'Promise',
|
|
219
|
+
'Error',
|
|
220
|
+
'Function',
|
|
221
|
+
'Symbol',
|
|
222
|
+
'Map',
|
|
223
|
+
'Set',
|
|
224
|
+
'WeakMap',
|
|
225
|
+
'WeakSet',
|
|
226
|
+
'Proxy',
|
|
227
|
+
'Reflect',
|
|
228
|
+
'Buffer',
|
|
229
|
+
'process',
|
|
230
|
+
'global',
|
|
231
|
+
'require',
|
|
232
|
+
'__dirname',
|
|
233
|
+
'__filename',
|
|
234
|
+
'module',
|
|
235
|
+
'exports',
|
|
236
|
+
// TypeScript globals
|
|
237
|
+
'Intl',
|
|
238
|
+
'SymbolConstructor',
|
|
239
|
+
'ArrayConstructor',
|
|
240
|
+
'MapConstructor',
|
|
241
|
+
'SetConstructor',
|
|
242
|
+
'PromiseConstructor',
|
|
243
|
+
'ErrorConstructor',
|
|
244
|
+
'RegExp',
|
|
245
|
+
'PropertyKey',
|
|
246
|
+
'PropertyDescriptor',
|
|
247
|
+
'Partial',
|
|
248
|
+
'Required',
|
|
249
|
+
'Readonly',
|
|
250
|
+
'Pick',
|
|
251
|
+
'Record',
|
|
252
|
+
'Exclude',
|
|
253
|
+
'Extract',
|
|
254
|
+
'Omit',
|
|
255
|
+
'NonNullable',
|
|
256
|
+
]);
|
|
257
|
+
return (globalNames.has(variable.name) ||
|
|
258
|
+
variable.scope.type === 'global' ||
|
|
259
|
+
variable.name.includes('Constructor') ||
|
|
260
|
+
variable.name.includes('Array') ||
|
|
261
|
+
variable.name.includes('Iterator') ||
|
|
262
|
+
variable.name.startsWith('Disposable') ||
|
|
263
|
+
variable.name.startsWith('Async') ||
|
|
264
|
+
variable.name.includes('Decorator'));
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Debug method: Get detailed scope info for a line
|
|
268
|
+
*/
|
|
269
|
+
getScopeInfoForLine(lineNumber) {
|
|
270
|
+
const targetScope = this.findScopeForLine(lineNumber);
|
|
271
|
+
if (!targetScope) {
|
|
272
|
+
return null;
|
|
273
|
+
}
|
|
274
|
+
const scopeVars = targetScope.variables
|
|
275
|
+
.filter((v) => !this.isGlobalVariable(v))
|
|
276
|
+
.map((v) => v.name);
|
|
277
|
+
const allVars = this.getAllAccessibleVariables(targetScope)
|
|
278
|
+
.filter((v) => !this.isGlobalVariable(v))
|
|
279
|
+
.map((v) => v.name);
|
|
280
|
+
return {
|
|
281
|
+
scopeType: targetScope.type,
|
|
282
|
+
variables: scopeVars,
|
|
283
|
+
allAccessible: allVars,
|
|
284
|
+
lineRange: `${targetScope.block.loc?.start.line}-${targetScope.block.loc?.end.line}`,
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Build a mapping of all user-defined variables with unique IDs
|
|
289
|
+
* Also cross-references with parsed bubbles
|
|
290
|
+
*/
|
|
291
|
+
buildVariableMapping() {
|
|
292
|
+
const variableMap = {};
|
|
293
|
+
this.variableLocations = {};
|
|
294
|
+
// Collect all user-defined variables from all scopes
|
|
295
|
+
for (const scope of this.scopeManager.scopes) {
|
|
296
|
+
for (const variable of scope.variables) {
|
|
297
|
+
if (!this.isGlobalVariable(variable)) {
|
|
298
|
+
// Use the Variable's built-in $id as the key
|
|
299
|
+
variableMap[variable.$id] = variable;
|
|
300
|
+
// Extract location information from the variable's definition
|
|
301
|
+
const location = this.extractVariableLocation(variable);
|
|
302
|
+
if (location) {
|
|
303
|
+
this.variableLocations[variable.$id] = location;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
return variableMap;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Extract precise location (line and column) for a variable
|
|
312
|
+
*/
|
|
313
|
+
extractVariableLocation(variable) {
|
|
314
|
+
// Get the primary definition of the variable
|
|
315
|
+
const primaryDef = variable.defs[0];
|
|
316
|
+
if (!primaryDef?.node?.loc)
|
|
317
|
+
return null;
|
|
318
|
+
const loc = primaryDef.node.loc;
|
|
319
|
+
return {
|
|
320
|
+
startLine: loc.start.line,
|
|
321
|
+
startCol: loc.start.column,
|
|
322
|
+
endLine: loc.end.line,
|
|
323
|
+
endCol: loc.end.column,
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Get Variable object by its $id
|
|
328
|
+
*/
|
|
329
|
+
getVariableById(id) {
|
|
330
|
+
return this.scriptVariables[id];
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Get all user-defined variables with their $ids
|
|
334
|
+
*/
|
|
335
|
+
getAllVariablesWithIds() {
|
|
336
|
+
return { ...this.scriptVariables };
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Get all user-defined variables in the entire script
|
|
340
|
+
*/
|
|
341
|
+
getAllUserVariables() {
|
|
342
|
+
const allVars = new Set();
|
|
343
|
+
for (const scope of this.scopeManager.scopes) {
|
|
344
|
+
for (const variable of scope.variables) {
|
|
345
|
+
if (!this.isGlobalVariable(variable)) {
|
|
346
|
+
allVars.add(variable.name);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
return Array.from(allVars);
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Get the parsed AST (for debugging or further analysis)
|
|
354
|
+
*/
|
|
355
|
+
getAST() {
|
|
356
|
+
return this.ast;
|
|
357
|
+
}
|
|
358
|
+
getOriginalParsedBubbles() {
|
|
359
|
+
return this.originalParsedBubbles;
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Get the scope manager (for advanced analysis)
|
|
363
|
+
*/
|
|
364
|
+
getScopeManager() {
|
|
365
|
+
return this.scopeManager;
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Get the parsed bubbles found in the script
|
|
369
|
+
*/
|
|
370
|
+
getParsedBubbles() {
|
|
371
|
+
return this.parsedBubbles;
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Get the handle method location (start and end lines)
|
|
375
|
+
*/
|
|
376
|
+
getHandleMethodLocation() {
|
|
377
|
+
return this.handleMethodLocation;
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Get location information for a variable by its $id
|
|
381
|
+
*/
|
|
382
|
+
getVariableLocation(variableId) {
|
|
383
|
+
return this.variableLocations[variableId] || null;
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Get all variable locations
|
|
387
|
+
*/
|
|
388
|
+
getAllVariableLocations() {
|
|
389
|
+
return { ...this.variableLocations };
|
|
390
|
+
}
|
|
391
|
+
resetBubbleScript() {
|
|
392
|
+
this.currentBubbleScript = this.bubbleScript;
|
|
393
|
+
}
|
|
394
|
+
/** Reassign variable to another value and assign to the new bubble script and return the new bubble script */
|
|
395
|
+
reassignVariable(variableId, newValue) {
|
|
396
|
+
const variable = this.getVariableById(variableId);
|
|
397
|
+
if (!variable) {
|
|
398
|
+
throw new Error(`Variable with ID ${variableId} not found`);
|
|
399
|
+
}
|
|
400
|
+
const location = this.getVariableLocation(variableId);
|
|
401
|
+
if (!location) {
|
|
402
|
+
throw new Error(`Location for variable ${variable.name} (ID: ${variableId}) not found`);
|
|
403
|
+
}
|
|
404
|
+
// Split the current script into lines
|
|
405
|
+
const lines = this.currentBubbleScript.split('\n');
|
|
406
|
+
// Get the line content (convert from 1-based to 0-based indexing)
|
|
407
|
+
const lineIndex = location.startLine - 1;
|
|
408
|
+
const originalLine = lines[lineIndex];
|
|
409
|
+
// Find the variable declaration pattern and replace its value
|
|
410
|
+
// Handle different patterns: const/let/var varName = value
|
|
411
|
+
const variablePattern = new RegExp(`(\\b(?:const|let|var)\\s+${this.escapeRegExp(variable.name)}\\s*=\\s*)([^;,\\n]+)`, 'g');
|
|
412
|
+
if (variablePattern.test(originalLine)) {
|
|
413
|
+
// Replace the value part
|
|
414
|
+
const newLine = originalLine.replace(variablePattern, `$1${newValue}`);
|
|
415
|
+
lines[lineIndex] = newLine;
|
|
416
|
+
}
|
|
417
|
+
else {
|
|
418
|
+
// If pattern doesn't match, try simpler assignment pattern
|
|
419
|
+
const assignmentPattern = new RegExp(`(\\b${this.escapeRegExp(variable.name)}\\s*=\\s*)([^;,\\n]+)`, 'g');
|
|
420
|
+
if (assignmentPattern.test(originalLine)) {
|
|
421
|
+
const newLine = originalLine.replace(assignmentPattern, `$1${newValue}`);
|
|
422
|
+
lines[lineIndex] = newLine;
|
|
423
|
+
}
|
|
424
|
+
else {
|
|
425
|
+
throw new Error(`Could not find variable assignment pattern for ${variable.name} on line ${location.startLine}`);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
// Update the current script and return it
|
|
429
|
+
this.currentBubbleScript = lines.join('\n');
|
|
430
|
+
return this.currentBubbleScript;
|
|
431
|
+
}
|
|
432
|
+
/** Inject lines of script at particular locations and return the new bubble script */
|
|
433
|
+
injectLines(lines, lineNumber) {
|
|
434
|
+
if (lineNumber < 1) {
|
|
435
|
+
throw new Error('Line number must be 1 or greater');
|
|
436
|
+
}
|
|
437
|
+
// Split the current script into lines
|
|
438
|
+
const scriptLines = this.currentBubbleScript.split('\n');
|
|
439
|
+
console.log('scriptLines', scriptLines);
|
|
440
|
+
// Convert from 1-based to 0-based indexing
|
|
441
|
+
const insertIndex = lineNumber - 1;
|
|
442
|
+
// Validate the line number
|
|
443
|
+
if (insertIndex > scriptLines.length) {
|
|
444
|
+
throw new Error(`Line number ${lineNumber} exceeds script length (${scriptLines.length} lines)`);
|
|
445
|
+
}
|
|
446
|
+
// Insert the new lines at the specified position
|
|
447
|
+
scriptLines.splice(insertIndex, 0, ...lines);
|
|
448
|
+
// Update the current script and return it
|
|
449
|
+
this.currentBubbleScript = scriptLines.join('\n');
|
|
450
|
+
return this.currentBubbleScript;
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* Helper method to escape special regex characters in variable names
|
|
454
|
+
*/
|
|
455
|
+
escapeRegExp(string) {
|
|
456
|
+
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* Build a JSON Schema object for the payload parameter of the top-level `handle` entrypoint.
|
|
460
|
+
* Delegates to BubbleParser for the actual implementation.
|
|
461
|
+
*/
|
|
462
|
+
getPayloadJsonSchema() {
|
|
463
|
+
const bubbleParser = new BubbleParser(this.currentBubbleScript);
|
|
464
|
+
return bubbleParser.getPayloadJsonSchema(this.ast);
|
|
465
|
+
}
|
|
466
|
+
/**
|
|
467
|
+
* Detect the BubbleTriggerEventRegistry key from the class extends generic.
|
|
468
|
+
* Example: class X extends BubbleFlow<'slack/bot_mentioned'> {}
|
|
469
|
+
* Returns the string key (e.g., 'slack/bot_mentioned') or null if not found.
|
|
470
|
+
*/
|
|
471
|
+
getBubbleTriggerEventType() {
|
|
472
|
+
for (const stmt of this.ast.body) {
|
|
473
|
+
const tryClass = (cls) => {
|
|
474
|
+
if (!cls)
|
|
475
|
+
return null;
|
|
476
|
+
const superClass = cls.superClass;
|
|
477
|
+
if (!superClass || superClass.type !== 'Identifier')
|
|
478
|
+
return null;
|
|
479
|
+
if (superClass.name !== 'BubbleFlow')
|
|
480
|
+
return null;
|
|
481
|
+
// typescript-estree attaches generic params to superTypeParameters
|
|
482
|
+
const params = cls.superTypeParameters;
|
|
483
|
+
const firstParam = params?.params?.[0];
|
|
484
|
+
if (!firstParam)
|
|
485
|
+
return null;
|
|
486
|
+
if (firstParam.type === 'TSLiteralType' &&
|
|
487
|
+
firstParam.literal.type === 'Literal') {
|
|
488
|
+
const v = firstParam.literal.value;
|
|
489
|
+
return typeof v === 'string' ? v : null;
|
|
490
|
+
}
|
|
491
|
+
return null;
|
|
492
|
+
};
|
|
493
|
+
if (stmt.type === 'ClassDeclaration') {
|
|
494
|
+
const val = tryClass(stmt);
|
|
495
|
+
if (val)
|
|
496
|
+
return val;
|
|
497
|
+
}
|
|
498
|
+
if (stmt.type === 'ExportNamedDeclaration' &&
|
|
499
|
+
stmt.declaration?.type === 'ClassDeclaration') {
|
|
500
|
+
const val = tryClass(stmt.declaration);
|
|
501
|
+
if (val)
|
|
502
|
+
return val;
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
// Fallback: simple regex over the source to catch extends BubbleFlow<'event/key'>
|
|
506
|
+
const match = this.currentBubbleScript.match(/extends\s+BubbleFlow\s*<\s*(['"`])([^'"`]+)\1\s*>/m);
|
|
507
|
+
if (match && typeof match[2] === 'string') {
|
|
508
|
+
return match[2];
|
|
509
|
+
}
|
|
510
|
+
return null;
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
//# sourceMappingURL=BubbleScript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CAAC;YAC1C,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/parse/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/parse/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ParsedBubbleWithInfo } from '@bubblelab/shared-schemas';
|
|
2
|
+
import { BubbleFactory } from '@bubblelab/bubble-core';
|
|
3
|
+
export interface DependencyTraceResult {
|
|
4
|
+
success: boolean;
|
|
5
|
+
nodes: Record<string, ParsedBubbleWithInfo>;
|
|
6
|
+
errors?: string[];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Trace bubble dependencies from a validated BubbleFlow script.
|
|
10
|
+
* - Parses AST, extracts bubble instantiations and their parameters
|
|
11
|
+
* - Builds a className -> metadata mapping from BubbleFactory defaults
|
|
12
|
+
* - Classifies each bubble node as service/tool/workflow using metadata
|
|
13
|
+
*
|
|
14
|
+
* Note: Only dependencies explicitly constructed in the script are captured.
|
|
15
|
+
* Internal dependencies of workflow bubbles require explicit metadata.
|
|
16
|
+
*/
|
|
17
|
+
export declare function traceBubbleDependencies(code: string, bubbleFactory: BubbleFactory): DependencyTraceResult;
|
|
18
|
+
//# sourceMappingURL=traceDependencies.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"traceDependencies.d.ts","sourceRoot":"","sources":["../../src/parse/traceDependencies.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,oBAAoB,EAGrB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;IAC5C,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,MAAM,EACZ,aAAa,EAAE,aAAa,GAC3B,qBAAqB,CAsEvB"}
|