@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,154 @@
|
|
|
1
|
+
export class LoggerInjector {
|
|
2
|
+
bubbleScript;
|
|
3
|
+
options;
|
|
4
|
+
constructor(bubbleScript, options = {}) {
|
|
5
|
+
this.bubbleScript = bubbleScript;
|
|
6
|
+
this.options = {
|
|
7
|
+
enableLineByLineLogging: true,
|
|
8
|
+
enableBubbleLogging: true,
|
|
9
|
+
enableVariableLogging: true,
|
|
10
|
+
...options,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Inject comprehensive logging into the bubble script using existing analysis
|
|
15
|
+
*/
|
|
16
|
+
injectLogging() {
|
|
17
|
+
const modifiedScript = this.bubbleScript.currentBubbleScript;
|
|
18
|
+
const lines = modifiedScript.split('\n');
|
|
19
|
+
// Inject statement-level logging in handle method
|
|
20
|
+
if (this.options.enableLineByLineLogging) {
|
|
21
|
+
this.injectLineLogging(lines);
|
|
22
|
+
}
|
|
23
|
+
this.bubbleScript.currentBubbleScript = lines.join('\n');
|
|
24
|
+
return lines.join('\n');
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Inject logging using original line numbers for traceability
|
|
28
|
+
*/
|
|
29
|
+
injectLoggingWithOriginalLines(originalAST, originalHandleMethodLocation) {
|
|
30
|
+
const modifiedScript = this.bubbleScript.currentBubbleScript;
|
|
31
|
+
const lines = modifiedScript.split('\n');
|
|
32
|
+
// Inject statement-level logging using original line numbers
|
|
33
|
+
if (this.options.enableLineByLineLogging) {
|
|
34
|
+
this.injectLineLoggingWithOriginalLines(lines, originalAST, originalHandleMethodLocation);
|
|
35
|
+
}
|
|
36
|
+
this.bubbleScript.currentBubbleScript = lines.join('\n');
|
|
37
|
+
return lines.join('\n');
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Inject statement-level logging using existing AST analysis
|
|
41
|
+
*/
|
|
42
|
+
injectLineLogging(lines) {
|
|
43
|
+
const handleMethodLocation = this.bubbleScript.getHandleMethodLocation();
|
|
44
|
+
if (!handleMethodLocation) {
|
|
45
|
+
console.warn('Handle method location not found, skipping statement logging');
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
// Get the existing AST and find statements within the handle method
|
|
49
|
+
const ast = this.bubbleScript.getAST();
|
|
50
|
+
const statements = this.findStatementsInHandleMethod(ast, handleMethodLocation);
|
|
51
|
+
// Sort statements by line number (reverse order for safe insertion)
|
|
52
|
+
statements.sort((a, b) => b.line - a.line);
|
|
53
|
+
// Insert logging after each statement
|
|
54
|
+
for (const statement of statements) {
|
|
55
|
+
const arrayIndex = statement.line - 1; // Convert to 0-based index
|
|
56
|
+
if (arrayIndex >= 0 && arrayIndex < lines.length) {
|
|
57
|
+
const line = lines[arrayIndex];
|
|
58
|
+
const indentation = line.match(/^\\s*/)?.[0] || ' ';
|
|
59
|
+
const statementLog = `${indentation}this.logger?.logLine(${statement.line}, 'Statement: ${statement.type}');`;
|
|
60
|
+
// Insert after the statement line
|
|
61
|
+
lines.splice(arrayIndex + 1, 0, statementLog);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Inject statement-level logging using original line numbers for traceability
|
|
67
|
+
*/
|
|
68
|
+
injectLineLoggingWithOriginalLines(lines, originalAST, originalHandleMethodLocation) {
|
|
69
|
+
if (!originalHandleMethodLocation) {
|
|
70
|
+
console.warn('Original handle method location not found, skipping statement logging');
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
// Find statements within the original handle method
|
|
74
|
+
const statements = this.findStatementsInHandleMethod(originalAST, originalHandleMethodLocation);
|
|
75
|
+
// Sort statements by line number (reverse order for safe insertion)
|
|
76
|
+
statements.sort((a, b) => b.line - a.line);
|
|
77
|
+
// Insert logging after each statement using original line numbers
|
|
78
|
+
for (const statement of statements) {
|
|
79
|
+
const arrayIndex = statement.line - 1; // Convert to 0-based index
|
|
80
|
+
if (arrayIndex >= 0 && arrayIndex < lines.length) {
|
|
81
|
+
const line = lines[arrayIndex];
|
|
82
|
+
const indentation = line.match(/^\\s*/)?.[0] || ' ';
|
|
83
|
+
// Use original line number for traceability
|
|
84
|
+
const statementLog = `${indentation}this.logger?.logLine(${statement.line}, 'Statement: ${statement.type}');`;
|
|
85
|
+
// Insert after the statement line
|
|
86
|
+
lines.splice(arrayIndex + 1, 0, statementLog);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Find all statements within the handle method using AST
|
|
92
|
+
*/
|
|
93
|
+
findStatementsInHandleMethod(ast, handleMethodLocation) {
|
|
94
|
+
const statements = [];
|
|
95
|
+
const visitNode = (node) => {
|
|
96
|
+
if (!node || typeof node !== 'object')
|
|
97
|
+
return;
|
|
98
|
+
// Check if this node is a statement within the handle method
|
|
99
|
+
if (node.loc &&
|
|
100
|
+
node.loc.start.line >= handleMethodLocation.startLine &&
|
|
101
|
+
node.loc.end.line <= handleMethodLocation.endLine) {
|
|
102
|
+
// Check if it's a statement type we want to log
|
|
103
|
+
const statementTypes = [
|
|
104
|
+
'VariableDeclaration',
|
|
105
|
+
'ExpressionStatement',
|
|
106
|
+
'ReturnStatement',
|
|
107
|
+
'IfStatement',
|
|
108
|
+
'ForStatement',
|
|
109
|
+
'WhileStatement',
|
|
110
|
+
'TryStatement',
|
|
111
|
+
'ThrowStatement',
|
|
112
|
+
];
|
|
113
|
+
if (statementTypes.includes(node.type)) {
|
|
114
|
+
statements.push({
|
|
115
|
+
line: node.loc.end.line, // Use end line for insertion point
|
|
116
|
+
type: node.type,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
// Recursively visit child nodes using a type-safe approach
|
|
121
|
+
this.visitChildNodes(node, visitNode);
|
|
122
|
+
};
|
|
123
|
+
visitNode(ast);
|
|
124
|
+
return statements;
|
|
125
|
+
}
|
|
126
|
+
visitChildNodes(node, visitor) {
|
|
127
|
+
// Use a more comprehensive approach that handles all node types
|
|
128
|
+
const visitValue = (value) => {
|
|
129
|
+
if (value && typeof value === 'object') {
|
|
130
|
+
if (Array.isArray(value)) {
|
|
131
|
+
value.forEach(visitValue);
|
|
132
|
+
}
|
|
133
|
+
else if ('type' in value && typeof value.type === 'string') {
|
|
134
|
+
// This is likely an AST node
|
|
135
|
+
visitor(value);
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
// This is a regular object, recurse into its properties
|
|
139
|
+
Object.values(value).forEach(visitValue);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
// Get all property values of the node, excluding metadata properties
|
|
144
|
+
const nodeObj = node;
|
|
145
|
+
for (const [key, value] of Object.entries(nodeObj)) {
|
|
146
|
+
// Skip metadata properties that aren't part of the AST structure
|
|
147
|
+
if (key === 'parent' || key === 'loc' || key === 'range') {
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
visitValue(value);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=LoggerInjector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LoggerInjector.js","sourceRoot":"","sources":["../../src/injection/LoggerInjector.ts"],"names":[],"mappings":"AASA,MAAM,OAAO,cAAc;IACjB,YAAY,CAAe;IAC3B,OAAO,CAA0B;IAEzC,YACE,YAA0B,EAC1B,UAA4C,EAAE;QAE9C,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,OAAO,GAAG;YACb,uBAAuB,EAAE,IAAI;YAC7B,mBAAmB,EAAE,IAAI;YACzB,qBAAqB,EAAE,IAAI;YAC3B,GAAG,OAAO;SACX,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,aAAa;QACX,MAAM,cAAc,GAAG,IAAI,CAAC,YAAY,CAAC,mBAAmB,CAAC;QAC7D,MAAM,KAAK,GAAG,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAEzC,kDAAkD;QAClD,IAAI,IAAI,CAAC,OAAO,CAAC,uBAAuB,EAAE,CAAC;YACzC,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;QAChC,CAAC;QAED,IAAI,CAAC,YAAY,CAAC,mBAAmB,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,8BAA8B,CAC5B,WAAgB,EAChB,4BAAiC;QAEjC,MAAM,cAAc,GAAG,IAAI,CAAC,YAAY,CAAC,mBAAmB,CAAC;QAC7D,MAAM,KAAK,GAAG,c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AQ,EAAE,CAAC;gBACvC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;oBACzB,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;gBAC5B,CAAC;qBAAM,IAAI,MAAM,IAAI,KAAK,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;oBAC7D,6BAA6B;oBAC7B,OAAO,CAAC,KAAsB,CAAC,CAAC;gBAClC,CAAC;qBAAM,CAAC;oBACN,wDAAwD;oBACxD,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;gBAC3C,CAAC;YACH,CAAC;QACH,CAAC,CAAC;QAEF,qEAAqE;QACrE,MAAM,OAAO,GAAG,IAA0C,CAAC;QAC3D,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YACnD,iEAAiE;YACjE,IAAI,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,KAAK,IAAI,GAAG,KAAK,OAAO,EAAE,CAAC;gBACzD,SAAS;YACX,CAAC;YAED,UAAU,CAAC,KAAK,CAAC,CAAC;QACpB,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/injection/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/injection/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import type { TSESTree } from '@typescript-eslint/typescript-estree';
|
|
2
|
+
import type { ScopeManager, Variable } from '@typescript-eslint/scope-manager';
|
|
3
|
+
import { BubbleFactory, BubbleTriggerEventRegistry } from '@bubblelab/bubble-core';
|
|
4
|
+
import type { ParsedBubbleWithInfo } from '@bubblelab/shared-schemas';
|
|
5
|
+
export declare class BubbleScript {
|
|
6
|
+
private ast;
|
|
7
|
+
private scopeManager;
|
|
8
|
+
private parsedBubbles;
|
|
9
|
+
private originalParsedBubbles;
|
|
10
|
+
private scriptVariables;
|
|
11
|
+
private variableLocations;
|
|
12
|
+
private handleMethodLocation;
|
|
13
|
+
private bubbleScript;
|
|
14
|
+
private bubbleFactory;
|
|
15
|
+
currentBubbleScript: string;
|
|
16
|
+
triggerEventType: keyof BubbleTriggerEventRegistry;
|
|
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(): void;
|
|
22
|
+
constructor(bubbleScript: string, bubbleFactory: BubbleFactory);
|
|
23
|
+
get bubblescript(): string;
|
|
24
|
+
/**
|
|
25
|
+
* Get all variable names available at a specific line (excluding globals)
|
|
26
|
+
* This is like setting a debugger breakpoint at that line
|
|
27
|
+
*/
|
|
28
|
+
getVarsForLine(lineNumber: number): Variable[];
|
|
29
|
+
/**
|
|
30
|
+
* Find ALL scopes that contain the given line number
|
|
31
|
+
* This is crucial because variables can be in sibling scopes (like block + for)
|
|
32
|
+
*/
|
|
33
|
+
private getAllScopesContainingLine;
|
|
34
|
+
/**
|
|
35
|
+
* Find the most specific scope that contains the given line number
|
|
36
|
+
*/
|
|
37
|
+
private findScopeForLine;
|
|
38
|
+
/**
|
|
39
|
+
* Get all variables accessible from a scope (including parent scopes)
|
|
40
|
+
* This mimics how debugger shows variables from current scope + outer scopes
|
|
41
|
+
*/
|
|
42
|
+
private getAllAccessibleVariables;
|
|
43
|
+
/**
|
|
44
|
+
* Check if a variable is declared before a given line number
|
|
45
|
+
* This ensures we only return variables that actually exist at the breakpoint
|
|
46
|
+
*/
|
|
47
|
+
private isVariableDeclaredBeforeLine;
|
|
48
|
+
/**
|
|
49
|
+
* Check if a variable is a global/built-in (filter these out)
|
|
50
|
+
*/
|
|
51
|
+
private isGlobalVariable;
|
|
52
|
+
/**
|
|
53
|
+
* Debug method: Get detailed scope info for a line
|
|
54
|
+
*/
|
|
55
|
+
getScopeInfoForLine(lineNumber: number): {
|
|
56
|
+
scopeType: string;
|
|
57
|
+
variables: string[];
|
|
58
|
+
allAccessible: string[];
|
|
59
|
+
lineRange: string;
|
|
60
|
+
} | null;
|
|
61
|
+
/**
|
|
62
|
+
* Build a mapping of all user-defined variables with unique IDs
|
|
63
|
+
* Also cross-references with parsed bubbles
|
|
64
|
+
*/
|
|
65
|
+
private buildVariableMapping;
|
|
66
|
+
/**
|
|
67
|
+
* Extract precise location (line and column) for a variable
|
|
68
|
+
*/
|
|
69
|
+
private extractVariableLocation;
|
|
70
|
+
/**
|
|
71
|
+
* Get Variable object by its $id
|
|
72
|
+
*/
|
|
73
|
+
getVariableById(id: number): Variable | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* Get all user-defined variables with their $ids
|
|
76
|
+
*/
|
|
77
|
+
getAllVariablesWithIds(): Record<number, Variable>;
|
|
78
|
+
/**
|
|
79
|
+
* Get all user-defined variables in the entire script
|
|
80
|
+
*/
|
|
81
|
+
getAllUserVariables(): string[];
|
|
82
|
+
/**
|
|
83
|
+
* Get the parsed AST (for debugging or further analysis)
|
|
84
|
+
*/
|
|
85
|
+
getAST(): TSESTree.Program;
|
|
86
|
+
getOriginalParsedBubbles(): Record<number, ParsedBubbleWithInfo>;
|
|
87
|
+
/**
|
|
88
|
+
* Get the scope manager (for advanced analysis)
|
|
89
|
+
*/
|
|
90
|
+
getScopeManager(): ScopeManager;
|
|
91
|
+
/**
|
|
92
|
+
* Get the parsed bubbles found in the script
|
|
93
|
+
*/
|
|
94
|
+
getParsedBubbles(): Record<number, ParsedBubbleWithInfo>;
|
|
95
|
+
/**
|
|
96
|
+
* Get the handle method location (start and end lines)
|
|
97
|
+
*/
|
|
98
|
+
getHandleMethodLocation(): {
|
|
99
|
+
startLine: number;
|
|
100
|
+
endLine: number;
|
|
101
|
+
} | null;
|
|
102
|
+
/**
|
|
103
|
+
* Get location information for a variable by its $id
|
|
104
|
+
*/
|
|
105
|
+
getVariableLocation(variableId: number): {
|
|
106
|
+
startLine: number;
|
|
107
|
+
startCol: number;
|
|
108
|
+
endLine: number;
|
|
109
|
+
endCol: number;
|
|
110
|
+
} | null;
|
|
111
|
+
/**
|
|
112
|
+
* Get all variable locations
|
|
113
|
+
*/
|
|
114
|
+
getAllVariableLocations(): Record<number, {
|
|
115
|
+
startLine: number;
|
|
116
|
+
startCol: number;
|
|
117
|
+
endLine: number;
|
|
118
|
+
endCol: number;
|
|
119
|
+
}>;
|
|
120
|
+
resetBubbleScript(): void;
|
|
121
|
+
/** Reassign variable to another value and assign to the new bubble script and return the new bubble script */
|
|
122
|
+
reassignVariable(variableId: number, newValue: string): string;
|
|
123
|
+
/** Inject lines of script at particular locations and return the new bubble script */
|
|
124
|
+
injectLines(lines: string[], lineNumber: number): string;
|
|
125
|
+
/**
|
|
126
|
+
* Helper method to escape special regex characters in variable names
|
|
127
|
+
*/
|
|
128
|
+
private escapeRegExp;
|
|
129
|
+
/**
|
|
130
|
+
* Build a JSON Schema object for the payload parameter of the top-level `handle` entrypoint.
|
|
131
|
+
* Delegates to BubbleParser for the actual implementation.
|
|
132
|
+
*/
|
|
133
|
+
getPayloadJsonSchema(): Record<string, unknown> | null;
|
|
134
|
+
/**
|
|
135
|
+
* Detect the BubbleTriggerEventRegistry key from the class extends generic.
|
|
136
|
+
* Example: class X extends BubbleFlow<'slack/bot_mentioned'> {}
|
|
137
|
+
* Returns the string key (e.g., 'slack/bot_mentioned') or null if not found.
|
|
138
|
+
*/
|
|
139
|
+
getBubbleTriggerEventType(): string | null;
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=BubbleScript.d.ts.map
|
|
@@ -0,0 +1 @@
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