crankscript 0.9.9 → 0.9.10
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/assets/plugin.js +23 -22
- package/assets/plugin.ts +26 -24
- package/package.json +1 -1
- package/src/constants.d.ts +0 -1
- package/src/constants.js +0 -1
- package/src/constants.js.map +1 -1
package/assets/plugin.js
CHANGED
@@ -34,6 +34,25 @@ var call_1 = require("typescript-to-lua/dist/transformation/visitors/call");
|
|
34
34
|
var fields_1 = require("typescript-to-lua/dist/transformation/visitors/class/members/fields");
|
35
35
|
var utils_1 = require("typescript-to-lua/dist/transformation/visitors/class/utils");
|
36
36
|
var function_1 = require("typescript-to-lua/dist/transformation/visitors/function");
|
37
|
+
var importMap = {
|
38
|
+
graphics: new Set(['graphics']),
|
39
|
+
sprites: new Set(['sprite']),
|
40
|
+
crank: new Set(['getCrankTicks']),
|
41
|
+
object: new Set(['printTable']),
|
42
|
+
'utilities/where': new Set(['where']),
|
43
|
+
easing: new Set(['easingFunctions']),
|
44
|
+
nineSlice: new Set(['nineSlice']),
|
45
|
+
qrcode: new Set(['generateQRCode']),
|
46
|
+
animation: new Set(['animation']),
|
47
|
+
animator: new Set(['animator']),
|
48
|
+
keyboard: new Set(['keyboard']),
|
49
|
+
math: new Set(['math']),
|
50
|
+
string: new Set(['string']),
|
51
|
+
timer: new Set(['timer']),
|
52
|
+
frameTimer: new Set(['frameTimer']),
|
53
|
+
ui: new Set(['ui']),
|
54
|
+
};
|
55
|
+
var imports = new Set();
|
37
56
|
function createClassCall(context, className, extendsNode) {
|
38
57
|
// class('X')
|
39
58
|
var classCall = tstl.createCallExpression(tstl.createIdentifier('class'), [tstl.createStringLiteral(className.text)]);
|
@@ -101,6 +120,7 @@ function transformMethodDeclaration(context, node, className) {
|
|
101
120
|
return tstl.createAssignmentStatement(tstl.createTableIndexExpression(className, transformPropertyName(context, node.name)), functionExpression);
|
102
121
|
}
|
103
122
|
var transformClassDeclaration = function (declaration, context) {
|
123
|
+
imports.add('object');
|
104
124
|
var className;
|
105
125
|
if (declaration.name) {
|
106
126
|
className = tstl.createIdentifier(declaration.name.text);
|
@@ -181,26 +201,7 @@ var transformSuperExpression = function (expression, context) {
|
|
181
201
|
return lua.createTableIndexExpression(className, lua.createStringLiteral('super'));
|
182
202
|
};
|
183
203
|
exports.transformSuperExpression = transformSuperExpression;
|
184
|
-
var
|
185
|
-
graphics: new Set(['graphics']),
|
186
|
-
sprites: new Set(['sprite']),
|
187
|
-
crank: new Set(['getCrankTicks']),
|
188
|
-
object: new Set(['printTable']),
|
189
|
-
'utilities/where': new Set(['where']),
|
190
|
-
easing: new Set(['easingFunctions']),
|
191
|
-
nineSlice: new Set(['nineSlice']),
|
192
|
-
qrcode: new Set(['generateQRCode']),
|
193
|
-
animation: new Set(['animation']),
|
194
|
-
animator: new Set(['animator']),
|
195
|
-
keyboard: new Set(['keyboard']),
|
196
|
-
math: new Set(['math']),
|
197
|
-
string: new Set(['string']),
|
198
|
-
timer: new Set(['timer']),
|
199
|
-
frameTimer: new Set(['frameTimer']),
|
200
|
-
ui: new Set(['ui']),
|
201
|
-
};
|
202
|
-
var imports = new Set();
|
203
|
-
var processFunction = function (name) {
|
204
|
+
var processName = function (name) {
|
204
205
|
for (var _i = 0, _a = Object.entries(importMap); _i < _a.length; _i++) {
|
205
206
|
var _b = _a[_i], key = _b[0], value = _b[1];
|
206
207
|
if (value instanceof Set && value.has(name)) {
|
@@ -224,13 +225,13 @@ var plugin = {
|
|
224
225
|
_a[ts.SyntaxKind.NewExpression] = transformNewExpression,
|
225
226
|
_a[ts.SyntaxKind.PropertyAccessExpression] = function (node, context) {
|
226
227
|
if (ts.isIdentifier(node.expression)) {
|
227
|
-
|
228
|
+
processName(node.name.text);
|
228
229
|
}
|
229
230
|
return context.superTransformExpression(node);
|
230
231
|
},
|
231
232
|
_a[ts.SyntaxKind.CallExpression] = function (node, context) {
|
232
233
|
if (ts.isIdentifier(node.expression)) {
|
233
|
-
|
234
|
+
processName(node.expression.escapedText.toString());
|
234
235
|
}
|
235
236
|
if (ts.isIdentifier(node.expression) &&
|
236
237
|
node.expression.escapedText === 'require') {
|
package/assets/plugin.ts
CHANGED
@@ -15,6 +15,27 @@ import {
|
|
15
15
|
transformParameters,
|
16
16
|
} from 'typescript-to-lua/dist/transformation/visitors/function';
|
17
17
|
|
18
|
+
const importMap = {
|
19
|
+
graphics: new Set(['graphics']),
|
20
|
+
sprites: new Set(['sprite']),
|
21
|
+
crank: new Set(['getCrankTicks']),
|
22
|
+
object: new Set(['printTable']),
|
23
|
+
'utilities/where': new Set(['where']),
|
24
|
+
easing: new Set(['easingFunctions']),
|
25
|
+
nineSlice: new Set(['nineSlice']),
|
26
|
+
qrcode: new Set(['generateQRCode']),
|
27
|
+
animation: new Set(['animation']),
|
28
|
+
animator: new Set(['animator']),
|
29
|
+
keyboard: new Set(['keyboard']),
|
30
|
+
math: new Set(['math']),
|
31
|
+
string: new Set(['string']),
|
32
|
+
timer: new Set(['timer']),
|
33
|
+
frameTimer: new Set(['frameTimer']),
|
34
|
+
ui: new Set(['ui']),
|
35
|
+
};
|
36
|
+
|
37
|
+
const imports = new Set<string>();
|
38
|
+
|
18
39
|
function createClassCall(
|
19
40
|
context: tstl.TransformationContext,
|
20
41
|
className: tstl.Identifier,
|
@@ -154,6 +175,8 @@ export const transformClassDeclaration: FunctionVisitor<
|
|
154
175
|
declaration,
|
155
176
|
context: TransformationContext & { classSuperInfos?: [ClassSuperInfo] }
|
156
177
|
) => {
|
178
|
+
imports.add('object');
|
179
|
+
|
157
180
|
let className: tstl.Identifier;
|
158
181
|
if (declaration.name) {
|
159
182
|
className = tstl.createIdentifier(declaration.name.text);
|
@@ -266,28 +289,7 @@ export const transformSuperExpression: FunctionVisitor<ts.SuperExpression> = (
|
|
266
289
|
);
|
267
290
|
};
|
268
291
|
|
269
|
-
const
|
270
|
-
graphics: new Set(['graphics']),
|
271
|
-
sprites: new Set(['sprite']),
|
272
|
-
crank: new Set(['getCrankTicks']),
|
273
|
-
object: new Set(['printTable']),
|
274
|
-
'utilities/where': new Set(['where']),
|
275
|
-
easing: new Set(['easingFunctions']),
|
276
|
-
nineSlice: new Set(['nineSlice']),
|
277
|
-
qrcode: new Set(['generateQRCode']),
|
278
|
-
animation: new Set(['animation']),
|
279
|
-
animator: new Set(['animator']),
|
280
|
-
keyboard: new Set(['keyboard']),
|
281
|
-
math: new Set(['math']),
|
282
|
-
string: new Set(['string']),
|
283
|
-
timer: new Set(['timer']),
|
284
|
-
frameTimer: new Set(['frameTimer']),
|
285
|
-
ui: new Set(['ui']),
|
286
|
-
};
|
287
|
-
|
288
|
-
const imports = new Set<string>();
|
289
|
-
|
290
|
-
const processFunction = (name: string) => {
|
292
|
+
const processName = (name: string) => {
|
291
293
|
for (const [key, value] of Object.entries(importMap)) {
|
292
294
|
if (value instanceof Set && value.has(name)) {
|
293
295
|
imports.add(key);
|
@@ -313,14 +315,14 @@ const plugin = {
|
|
313
315
|
[ts.SyntaxKind.NewExpression]: transformNewExpression,
|
314
316
|
[ts.SyntaxKind.PropertyAccessExpression]: (node, context) => {
|
315
317
|
if (ts.isIdentifier(node.expression)) {
|
316
|
-
|
318
|
+
processName(node.name.text);
|
317
319
|
}
|
318
320
|
|
319
321
|
return context.superTransformExpression(node);
|
320
322
|
},
|
321
323
|
[ts.SyntaxKind.CallExpression]: (node, context) => {
|
322
324
|
if (ts.isIdentifier(node.expression)) {
|
323
|
-
|
325
|
+
processName(node.expression.escapedText.toString());
|
324
326
|
}
|
325
327
|
|
326
328
|
if (
|
package/package.json
CHANGED
package/src/constants.d.ts
CHANGED
package/src/constants.js
CHANGED
package/src/constants.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../libs/cli/src/constants.ts"],"sourcesContent":["import { join } from 'node:path';\nimport { __dirname } from './utils/dirname.js';\n\nexport const
|
1
|
+
{"version":3,"sources":["../../../../libs/cli/src/constants.ts"],"sourcesContent":["import { join } from 'node:path';\nimport { __dirname } from './utils/dirname.js';\n\nexport const TypescriptReservedNamed = ['delete', 'new', 'function'];\nexport const RootFolder = join(__dirname, '..', '..');\nexport const DataFolder = join(RootFolder, 'src', 'data');\n"],"names":["join","__dirname","TypescriptReservedNamed","RootFolder","DataFolder"],"rangeMappings":";;;;;;;;","mappings":"AAAA,SAASA,IAAI,QAAQ,YAAY;AACjC,SAASC,SAAS,QAAQ,qBAAqB;AAE/C,OAAO,MAAMC,0BAA0B;IAAC;IAAU;IAAO;CAAW,CAAC;AACrE,OAAO,MAAMC,aAAaH,KAAKC,WAAW,MAAM,MAAM;AACtD,OAAO,MAAMG,aAAaJ,KAAKG,YAAY,OAAO,QAAQ"}
|