@kudzujs/core 0.8.13 → 0.8.15
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/README.md +34 -6
- package/RELEASES.md +62 -0
- package/framework/README.md +22 -2
- package/framework/build.mjs +123 -2868
- package/framework/compiler/animation-frame-pass.mjs +103 -0
- package/framework/compiler/ast-helpers.mjs +181 -0
- package/framework/compiler/browser-signal-passes.mjs +182 -0
- package/framework/compiler/custom-hook-timer-pass.mjs +126 -0
- package/framework/compiler/effect-codegen.mjs +884 -0
- package/framework/compiler/handler-codegen.mjs +296 -0
- package/framework/compiler/normalization-pipeline.mjs +9 -0
- package/framework/compiler/react-migration-pass.mjs +338 -0
- package/framework/compiler/render-control-pass.mjs +96 -0
- package/framework/compiler/router-pass.mjs +245 -0
- package/framework/compiler/worker-compiler.mjs +163 -0
- package/framework/dev-server.mjs +244 -0
- package/package.json +1 -1
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import ts from "typescript"
|
|
2
|
+
import { isFunctionLike, isReferenceIdentifier, isShadowedByParameter, isShadowedIdentifier, sourceNodeError } from "./ast-helpers.mjs"
|
|
3
|
+
|
|
4
|
+
export function createHandlerCodegen({ cloneAst, synthesizeTree, resolveClientImport }) {
|
|
5
|
+
return function printHandlerModule({ callbacks, reactiveBindings, listExpressions, handlerPath }) {
|
|
6
|
+
return [
|
|
7
|
+
printClientImports([...callbacks, ...reactiveBindings].flatMap(handler => handler.imports ?? []), handlerPath),
|
|
8
|
+
...callbacks.map(handler => printNativeHandler(handler)),
|
|
9
|
+
...reactiveBindings.map(entry => printReactiveBinding(entry)),
|
|
10
|
+
...listExpressions.map(entry => printListExpression(entry))
|
|
11
|
+
].join("\n")
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function printClientImports(entries, handlerPath) {
|
|
15
|
+
const unique = new Map(entries.map(entry => [`${entry.target}:${entry.kind}:${entry.imported ?? ""}:${entry.local}`, entry]))
|
|
16
|
+
const groups = Map.groupBy(unique.values(), entry => entry.target)
|
|
17
|
+
const imports = []
|
|
18
|
+
for (const [target, group] of groups) {
|
|
19
|
+
const specifier = resolveClientImport(group[0], handlerPath)
|
|
20
|
+
const defaults = group.filter(entry => entry.kind === "default")
|
|
21
|
+
const named = group.filter(entry => entry.kind === "named")
|
|
22
|
+
if (defaults.length === 1 || named.length) imports.push(`import ${defaults.length === 1 ? `${defaults[0].local}${named.length ? ", " : ""}` : ""}${named.length ? `{ ${named.map(entry => entry.imported === entry.local ? entry.local : `${entry.imported} as ${entry.local}`).join(", ")} }` : ""} from ${JSON.stringify(specifier)}`)
|
|
23
|
+
if (defaults.length > 1) for (const entry of defaults) imports.push(`import ${entry.local} from ${JSON.stringify(specifier)}`)
|
|
24
|
+
for (const entry of group.filter(entry => entry.kind === "namespace")) imports.push(`import * as ${entry.local} from ${JSON.stringify(specifier)}`)
|
|
25
|
+
}
|
|
26
|
+
return imports.join("\n")
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function printNativeHandler({ exportName, expression, captures, setters, reducers = new Map(), snapshotNested, liveStates = new Set() }) {
|
|
30
|
+
const factory = ts.factory
|
|
31
|
+
const stateNames = new Set(setters.values())
|
|
32
|
+
const snapshotNames = snapshotNested ? nestedStateNames(expression, setters, liveStates) : new Set()
|
|
33
|
+
const snapshots = new Map([...snapshotNames].map(name => [name, factory.createUniqueName("__kEffectState")]))
|
|
34
|
+
const captureSnapshotNames = snapshotNested ? nestedCaptureNames(expression, captures) : new Set()
|
|
35
|
+
const captureSnapshots = new Map([...captureSnapshotNames].map(name => [name, factory.createUniqueName("__kEffectCapture")]))
|
|
36
|
+
const transformer = context => root => {
|
|
37
|
+
const visitor = node => {
|
|
38
|
+
if (ts.isCallExpression(node) && ts.isIdentifier(node.expression) && reducers.has(node.expression.text) && !isShadowedIdentifier(node.expression, expression)) {
|
|
39
|
+
const reducer = reducers.get(node.expression.text)
|
|
40
|
+
if (reducer.contextAction) {
|
|
41
|
+
const action = synthesizeTree(cloneAst(reducer.contextAction, factory, context))
|
|
42
|
+
const call = factory.createCallExpression(action, undefined, node.arguments)
|
|
43
|
+
ts.setParentRecursive(call, false)
|
|
44
|
+
return ts.visitNode(call, visitor)
|
|
45
|
+
}
|
|
46
|
+
if (reducer.store) return zustandActionDispatch(factory, reducer, node.arguments.map(argument => ts.visitNode(argument, visitor)))
|
|
47
|
+
if (node.arguments.length !== 1) throw sourceNodeError(node, expression.getSourceFile(), "Reducer dispatches require exactly one action")
|
|
48
|
+
return reducerDispatch(factory, reducer, ts.visitNode(node.arguments[0], visitor))
|
|
49
|
+
}
|
|
50
|
+
if (ts.isShorthandPropertyAssignment(node) && reducers.has(node.name.text) && !isShadowedIdentifier(node.name, expression)) {
|
|
51
|
+
if (reducers.get(node.name.text).contextAction) throw sourceNodeError(node, expression.getSourceFile(), "Context actions must be called directly inside an event handler")
|
|
52
|
+
if (reducers.get(node.name.text).store) throw sourceNodeError(node, expression.getSourceFile(), "Zustand actions must be called directly inside an event handler")
|
|
53
|
+
return factory.createPropertyAssignment(node.name, reducerReference(factory, reducers.get(node.name.text)))
|
|
54
|
+
}
|
|
55
|
+
if (ts.isIdentifier(node) && reducers.has(node.text) && isReferenceIdentifier(node) && !isShadowedIdentifier(node, expression)) {
|
|
56
|
+
if (reducers.get(node.text).contextAction) throw sourceNodeError(node, expression.getSourceFile(), "Context actions must be called directly inside an event handler")
|
|
57
|
+
if (reducers.get(node.text).store) throw sourceNodeError(node, expression.getSourceFile(), "Zustand actions must be called directly inside an event handler")
|
|
58
|
+
return reducerReference(factory, reducers.get(node.text))
|
|
59
|
+
}
|
|
60
|
+
if (ts.isCallExpression(node) && ts.isIdentifier(node.expression) && setters.has(node.expression.text) && !isShadowedIdentifier(node.expression, expression)) {
|
|
61
|
+
return factory.createCallExpression(
|
|
62
|
+
factory.createPropertyAccessExpression(factory.createIdentifier("__k"), "set"),
|
|
63
|
+
undefined,
|
|
64
|
+
[factory.createStringLiteral(setters.get(node.expression.text)), ...node.arguments.map(argument => ts.visitNode(argument, visitor))]
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
if (ts.isShorthandPropertyAssignment(node) && setters.has(node.name.text) && !isShadowedIdentifier(node.name, expression)) {
|
|
68
|
+
return factory.createPropertyAssignment(node.name, setterReference(factory, setters.get(node.name.text)))
|
|
69
|
+
}
|
|
70
|
+
if (ts.isIdentifier(node) && setters.has(node.text) && isReferenceIdentifier(node) && !isShadowedIdentifier(node, expression)) {
|
|
71
|
+
return setterReference(factory, setters.get(node.text))
|
|
72
|
+
}
|
|
73
|
+
if (ts.isShorthandPropertyAssignment(node) && stateNames.has(node.name.text) && !isShadowedIdentifier(node.name, expression)) {
|
|
74
|
+
if (snapshots.has(node.name.text) && insideNestedFunction(node, expression)) return factory.createPropertyAssignment(node.name, snapshots.get(node.name.text))
|
|
75
|
+
return factory.createPropertyAssignment(node.name, factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("__k"), "get"), undefined, [factory.createStringLiteral(node.name.text)]))
|
|
76
|
+
}
|
|
77
|
+
if (ts.isIdentifier(node) && stateNames.has(node.text) && isReferenceIdentifier(node) && !isShadowedIdentifier(node, expression)) {
|
|
78
|
+
if (snapshots.has(node.text) && insideNestedFunction(node, expression)) return snapshots.get(node.text)
|
|
79
|
+
return factory.createCallExpression(
|
|
80
|
+
factory.createPropertyAccessExpression(factory.createIdentifier("__k"), "get"),
|
|
81
|
+
undefined,
|
|
82
|
+
[factory.createStringLiteral(node.text)]
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
if (ts.isShorthandPropertyAssignment(node) && captures.has(node.name.text) && !isShadowedIdentifier(node.name, expression)) {
|
|
86
|
+
if (captureSnapshots.has(node.name.text) && insideNestedFunction(node, expression)) return factory.createPropertyAssignment(node.name, captureSnapshots.get(node.name.text))
|
|
87
|
+
return factory.createPropertyAssignment(node.name, scopeRead(factory, node.name.text))
|
|
88
|
+
}
|
|
89
|
+
if (ts.isIdentifier(node) && captures.has(node.text) && isReferenceIdentifier(node) && !isShadowedIdentifier(node, expression)) {
|
|
90
|
+
if (captureSnapshots.has(node.text) && insideNestedFunction(node, expression)) return captureSnapshots.get(node.text)
|
|
91
|
+
return scopeRead(factory, node.text)
|
|
92
|
+
}
|
|
93
|
+
return ts.visitEachChild(node, visitor, context)
|
|
94
|
+
}
|
|
95
|
+
return ts.visitNode(root, visitor)
|
|
96
|
+
}
|
|
97
|
+
const transformed = ts.transform(expression.body, [transformer])
|
|
98
|
+
try {
|
|
99
|
+
let body = ts.isBlock(expression.body)
|
|
100
|
+
? transformed.transformed[0]
|
|
101
|
+
: factory.createBlock([factory.createReturnStatement(transformed.transformed[0])], true)
|
|
102
|
+
const snapshotDeclarations = [
|
|
103
|
+
...[...snapshots].map(([name, identifier]) => factory.createVariableDeclaration(identifier, undefined, undefined, factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("__k"), "get"), undefined, [factory.createStringLiteral(name)]))),
|
|
104
|
+
...[...captureSnapshots].map(([name, identifier]) => factory.createVariableDeclaration(identifier, undefined, undefined, factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("__k"), "scope"), undefined, [factory.createStringLiteral(name)])))
|
|
105
|
+
]
|
|
106
|
+
if (snapshotDeclarations.length) body = factory.updateBlock(body, [
|
|
107
|
+
factory.createVariableStatement(undefined, factory.createVariableDeclarationList(snapshotDeclarations, ts.NodeFlags.Const)),
|
|
108
|
+
...body.statements
|
|
109
|
+
])
|
|
110
|
+
const modifiers = [factory.createModifier(ts.SyntaxKind.ExportKeyword)]
|
|
111
|
+
if (expression.modifiers?.some(modifier => modifier.kind === ts.SyntaxKind.AsyncKeyword)) modifiers.push(factory.createModifier(ts.SyntaxKind.AsyncKeyword))
|
|
112
|
+
const declaration = factory.createFunctionDeclaration(
|
|
113
|
+
modifiers,
|
|
114
|
+
expression.asteriskToken,
|
|
115
|
+
exportName,
|
|
116
|
+
undefined,
|
|
117
|
+
[factory.createParameterDeclaration(undefined, undefined, "__k"), ...expression.parameters],
|
|
118
|
+
undefined,
|
|
119
|
+
body
|
|
120
|
+
)
|
|
121
|
+
return ts.createPrinter().printNode(ts.EmitHint.Unspecified, declaration, expression.getSourceFile())
|
|
122
|
+
} finally {
|
|
123
|
+
transformed.dispose()
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function nestedCaptureNames(expression, captures) {
|
|
128
|
+
const names = new Set()
|
|
129
|
+
const visit = node => {
|
|
130
|
+
if (ts.isIdentifier(node) && captures.has(node.text) && isReferenceIdentifier(node) && insideNestedFunction(node, expression) && !isShadowedIdentifier(node, expression)) names.add(node.text)
|
|
131
|
+
ts.forEachChild(node, visit)
|
|
132
|
+
}
|
|
133
|
+
visit(expression.body)
|
|
134
|
+
return names
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function nestedStateNames(expression, setters, liveStates = new Set()) {
|
|
138
|
+
const states = new Set(setters.values())
|
|
139
|
+
const names = new Set()
|
|
140
|
+
const visit = node => {
|
|
141
|
+
if (ts.isIdentifier(node) && states.has(node.text) && !liveStates.has(node.text) && isReferenceIdentifier(node) && insideNestedFunction(node, expression) && !isShadowedIdentifier(node, expression)) names.add(node.text)
|
|
142
|
+
ts.forEachChild(node, visit)
|
|
143
|
+
}
|
|
144
|
+
visit(expression.body)
|
|
145
|
+
return names
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function insideNestedFunction(node, root) {
|
|
149
|
+
for (let current = node.parent; current && current !== root; current = current.parent) {
|
|
150
|
+
if (isFunctionLike(current)) return true
|
|
151
|
+
}
|
|
152
|
+
return false
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function setterReference(factory, stateName) {
|
|
156
|
+
return factory.createArrowFunction(
|
|
157
|
+
undefined,
|
|
158
|
+
undefined,
|
|
159
|
+
[factory.createParameterDeclaration(undefined, undefined, "value")],
|
|
160
|
+
undefined,
|
|
161
|
+
factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken),
|
|
162
|
+
factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("__k"), "set"), undefined, [factory.createStringLiteral(stateName), factory.createIdentifier("value")])
|
|
163
|
+
)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function reducerReference(factory, reducer) {
|
|
167
|
+
const action = factory.createUniqueName("__kAction")
|
|
168
|
+
return factory.createArrowFunction(undefined, undefined, [factory.createParameterDeclaration(undefined, undefined, action)], undefined, factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), reducerDispatch(factory, reducer, action))
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function reducerDispatch(factory, reducer, action) {
|
|
172
|
+
if (reducer.store) return zustandActionDispatch(factory, reducer, [action])
|
|
173
|
+
const previous = factory.createUniqueName("__kPrevious")
|
|
174
|
+
const update = factory.createArrowFunction(undefined, undefined, [factory.createParameterDeclaration(undefined, undefined, previous)], undefined, factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), factory.createCallExpression(factory.createIdentifier(reducer.reducer), undefined, [previous, action]))
|
|
175
|
+
return factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("__k"), "set"), undefined, [factory.createStringLiteral(reducer.state), update])
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function zustandActionDispatch(factory, reducer, args) {
|
|
179
|
+
const previous = factory.createUniqueName("__kPrevious")
|
|
180
|
+
const current = factory.createUniqueName("__kStore")
|
|
181
|
+
const updateValue = factory.createUniqueName("__kUpdate")
|
|
182
|
+
const partial = factory.createUniqueName("__kPartial")
|
|
183
|
+
const action = factory.createUniqueName("__kAction")
|
|
184
|
+
const set = factory.createIdentifier(reducer.store.setName)
|
|
185
|
+
const merge = factory.createExpressionStatement(factory.createBinaryExpression(current, factory.createToken(ts.SyntaxKind.EqualsToken), factory.createObjectLiteralExpression([
|
|
186
|
+
factory.createSpreadAssignment(current),
|
|
187
|
+
factory.createSpreadAssignment(partial)
|
|
188
|
+
])))
|
|
189
|
+
const setBody = factory.createBlock([
|
|
190
|
+
factory.createVariableStatement(undefined, factory.createVariableDeclarationList([factory.createVariableDeclaration(partial, undefined, undefined, factory.createConditionalExpression(
|
|
191
|
+
factory.createBinaryExpression(factory.createTypeOfExpression(updateValue), factory.createToken(ts.SyntaxKind.EqualsEqualsEqualsToken), factory.createStringLiteral("function")),
|
|
192
|
+
undefined,
|
|
193
|
+
factory.createCallExpression(updateValue, undefined, [current]),
|
|
194
|
+
undefined,
|
|
195
|
+
updateValue
|
|
196
|
+
))], ts.NodeFlags.Const)),
|
|
197
|
+
merge
|
|
198
|
+
], true)
|
|
199
|
+
const body = factory.createBlock([
|
|
200
|
+
factory.createVariableStatement(undefined, factory.createVariableDeclarationList([factory.createVariableDeclaration(current, undefined, undefined, factory.createObjectLiteralExpression([factory.createPropertyAssignment(reducer.store.field, previous)]))], ts.NodeFlags.Let)),
|
|
201
|
+
factory.createVariableStatement(undefined, factory.createVariableDeclarationList([factory.createVariableDeclaration(set, undefined, undefined, factory.createArrowFunction(undefined, undefined, [factory.createParameterDeclaration(undefined, undefined, updateValue)], undefined, factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), setBody))], ts.NodeFlags.Const)),
|
|
202
|
+
factory.createVariableStatement(undefined, factory.createVariableDeclarationList([factory.createVariableDeclaration(action, undefined, undefined, synthesizeTree(reducer.store.actions.get(reducer.action)))], ts.NodeFlags.Const)),
|
|
203
|
+
factory.createExpressionStatement(factory.createCallExpression(action, undefined, args)),
|
|
204
|
+
factory.createReturnStatement(factory.createPropertyAccessExpression(current, reducer.store.field))
|
|
205
|
+
], true)
|
|
206
|
+
const update = factory.createArrowFunction(undefined, undefined, [factory.createParameterDeclaration(undefined, undefined, previous)], undefined, factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), body)
|
|
207
|
+
return factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("__k"), "set"), undefined, [factory.createStringLiteral(reducer.state), update])
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function printReactiveBinding({ exportName, expression, captures, states }) {
|
|
211
|
+
const factory = ts.factory
|
|
212
|
+
const transformer = context => root => {
|
|
213
|
+
const visitor = node => {
|
|
214
|
+
if (ts.isShorthandPropertyAssignment(node) && states.has(node.name.text)) {
|
|
215
|
+
return factory.createPropertyAssignment(
|
|
216
|
+
node.name,
|
|
217
|
+
factory.createCallExpression(
|
|
218
|
+
factory.createPropertyAccessExpression(factory.createIdentifier("__k"), "get"),
|
|
219
|
+
undefined,
|
|
220
|
+
[factory.createStringLiteral(node.name.text)]
|
|
221
|
+
)
|
|
222
|
+
)
|
|
223
|
+
}
|
|
224
|
+
if (ts.isIdentifier(node) && states.has(node.text) && isReferenceIdentifier(node) && !isShadowedByParameter(node, expression)) {
|
|
225
|
+
return factory.createCallExpression(
|
|
226
|
+
factory.createPropertyAccessExpression(factory.createIdentifier("__k"), "get"),
|
|
227
|
+
undefined,
|
|
228
|
+
[factory.createStringLiteral(node.text)]
|
|
229
|
+
)
|
|
230
|
+
}
|
|
231
|
+
if (ts.isShorthandPropertyAssignment(node) && captures.has(node.name.text)) {
|
|
232
|
+
return factory.createPropertyAssignment(node.name, scopeRead(factory, node.name.text))
|
|
233
|
+
}
|
|
234
|
+
if (ts.isIdentifier(node) && captures.has(node.text) && isReferenceIdentifier(node)) {
|
|
235
|
+
return scopeRead(factory, node.text)
|
|
236
|
+
}
|
|
237
|
+
return ts.visitEachChild(node, visitor, context)
|
|
238
|
+
}
|
|
239
|
+
return ts.visitNode(root, visitor)
|
|
240
|
+
}
|
|
241
|
+
const transformed = ts.transform(expression, [transformer])
|
|
242
|
+
try {
|
|
243
|
+
const declaration = factory.createFunctionDeclaration(
|
|
244
|
+
[factory.createModifier(ts.SyntaxKind.ExportKeyword)],
|
|
245
|
+
undefined,
|
|
246
|
+
exportName,
|
|
247
|
+
undefined,
|
|
248
|
+
[factory.createParameterDeclaration(undefined, undefined, "__k")],
|
|
249
|
+
undefined,
|
|
250
|
+
factory.createBlock([factory.createReturnStatement(transformed.transformed[0])], true)
|
|
251
|
+
)
|
|
252
|
+
return ts.createPrinter().printNode(ts.EmitHint.Unspecified, declaration, expression.getSourceFile())
|
|
253
|
+
} finally {
|
|
254
|
+
transformed.dispose()
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function printListExpression({ exportName, expression, item, index, states = new Set() }) {
|
|
259
|
+
const factory = ts.factory
|
|
260
|
+
const transformer = context => root => {
|
|
261
|
+
const visitor = node => {
|
|
262
|
+
if (ts.isShorthandPropertyAssignment(node) && states.has(node.name.text)) {
|
|
263
|
+
return factory.createPropertyAssignment(node.name, factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("__k"), "get"), undefined, [factory.createStringLiteral(node.name.text)]))
|
|
264
|
+
}
|
|
265
|
+
if (ts.isIdentifier(node) && states.has(node.text) && isReferenceIdentifier(node) && !isShadowedByParameter(node, expression)) {
|
|
266
|
+
return factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("__k"), "get"), undefined, [factory.createStringLiteral(node.text)])
|
|
267
|
+
}
|
|
268
|
+
return ts.visitEachChild(node, visitor, context)
|
|
269
|
+
}
|
|
270
|
+
return ts.visitNode(root, visitor)
|
|
271
|
+
}
|
|
272
|
+
const transformed = ts.transform(expression, [transformer])
|
|
273
|
+
const declaration = ts.factory.createFunctionDeclaration(
|
|
274
|
+
[ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)],
|
|
275
|
+
undefined,
|
|
276
|
+
exportName,
|
|
277
|
+
undefined,
|
|
278
|
+
[ts.factory.createParameterDeclaration(undefined, undefined, item), ts.factory.createParameterDeclaration(undefined, undefined, index ?? "__kIndex"), ts.factory.createParameterDeclaration(undefined, undefined, "__k")],
|
|
279
|
+
undefined,
|
|
280
|
+
ts.factory.createBlock([ts.factory.createReturnStatement(transformed.transformed[0])], true)
|
|
281
|
+
)
|
|
282
|
+
try {
|
|
283
|
+
return ts.createPrinter().printNode(ts.EmitHint.Unspecified, declaration, expression.getSourceFile())
|
|
284
|
+
} finally {
|
|
285
|
+
transformed.dispose()
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
function scopeRead(factory, name) {
|
|
290
|
+
return factory.createCallExpression(
|
|
291
|
+
factory.createPropertyAccessExpression(factory.createIdentifier("__k"), "scope"),
|
|
292
|
+
undefined,
|
|
293
|
+
[factory.createStringLiteral(name)]
|
|
294
|
+
)
|
|
295
|
+
}
|
|
296
|
+
}
|