@playcanvas/attribute-parser 1.0.4 → 1.0.5
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/.eslintignore +1 -0
- package/.eslintrc +19 -0
- package/.github/workflows/ci.yml +3 -0
- package/package.json +6 -2
- package/src/index.js +13 -17
- package/src/parsers/attribute-parser.js +8 -9
- package/src/parsers/script-parser.js +20 -19
- package/src/utils/attribute-utils.js +6 -8
- package/src/utils/tag-utils.js +3 -3
- package/src/utils/ts-utils.js +2 -3
- package/test/fixtures/asset.invalid.js +1 -1
- package/test/fixtures/asset.valid.js +1 -0
- package/test/fixtures/curve.invalid.js +1 -0
- package/test/fixtures/enum.valid.js +5 -2
- package/test/fixtures/export.import.js +1 -1
- package/test/fixtures/export.valid.js +5 -5
- package/test/fixtures/inherit.valid.js +2 -3
- package/test/fixtures/json.invalid.js +1 -0
- package/test/fixtures/json.valid.js +3 -0
- package/test/fixtures/misc.invalid.js +2 -3
- package/test/fixtures/misc.valid.js +1 -1
- package/test/fixtures/program.invalid.js +2 -1
- package/test/fixtures/program.valid.js +3 -3
- package/test/fixtures/text.valid.js +1 -0
- package/test/fixtures/vector.invalid.js +1 -0
- package/test/fixtures/vector.valid.js +1 -0
- package/test/tests/invalid/asset.test.js +1 -2
- package/test/tests/invalid/curve.test.js +1 -2
- package/test/tests/invalid/json.test.js +1 -2
- package/test/tests/invalid/misc.test.js +1 -2
- package/test/tests/invalid/numeric.test.js +1 -2
- package/test/tests/invalid/program.test.js +2 -3
- package/test/tests/invalid/vector.test.js +1 -2
- package/test/tests/valid/asset.test.js +1 -2
- package/test/tests/valid/checkbox.test.js +1 -2
- package/test/tests/valid/color.test.js +1 -2
- package/test/tests/valid/curve.test.js +1 -2
- package/test/tests/valid/entity.test.js +1 -2
- package/test/tests/valid/enum.test.js +1 -2
- package/test/tests/valid/export.test.js +1 -2
- package/test/tests/valid/inherit.test.js +1 -2
- package/test/tests/valid/intellisense.test.js +1 -2
- package/test/tests/valid/json.test.js +1 -2
- package/test/tests/valid/misc.test.js +1 -2
- package/test/tests/valid/numeric.test.js +1 -2
- package/test/tests/valid/program.test.js +1 -2
- package/test/tests/valid/text.test.js +1 -2
- package/test/tests/valid/vector.test.js +1 -2
- package/test/utils.js +2 -1
- package/src/global.types.js +0 -18
package/.eslintignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/**/program.invalid.js
|
package/.eslintrc
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": [
|
|
3
|
+
"@playcanvas/eslint-config"
|
|
4
|
+
],
|
|
5
|
+
"rules": {
|
|
6
|
+
"no-unused-expressions": "off",
|
|
7
|
+
"jsdoc/check-tag-names": "off",
|
|
8
|
+
"import/no-unresolved": "off"
|
|
9
|
+
},
|
|
10
|
+
"overrides": [
|
|
11
|
+
{
|
|
12
|
+
"files": ["./**/*.test.js"],
|
|
13
|
+
"rules": {
|
|
14
|
+
"prefer-arrow-callback": "off",
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
|
19
|
+
|
package/.github/workflows/ci.yml
CHANGED
package/package.json
CHANGED
|
@@ -5,18 +5,22 @@
|
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=18.0.0"
|
|
7
7
|
},
|
|
8
|
-
"version": "1.0.
|
|
8
|
+
"version": "1.0.5",
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@microsoft/tsdoc": "^0.15.0",
|
|
11
|
+
"@playcanvas/eslint-config": "^1.7.4",
|
|
11
12
|
"@typescript/vfs": "^1.6.0",
|
|
13
|
+
"eslint": "^8.56.0",
|
|
12
14
|
"typescript": "^5.5.3"
|
|
13
15
|
},
|
|
14
16
|
"devDependencies": {
|
|
15
17
|
"chai": "^5.1.1",
|
|
18
|
+
"globals": "^15.9.0",
|
|
16
19
|
"mocha": "^10.6.0"
|
|
17
20
|
},
|
|
18
21
|
"scripts": {
|
|
19
|
-
"test": "mocha test/**/*.test.js --timeout 10000"
|
|
22
|
+
"test": "mocha test/**/*.test.js --timeout 10000",
|
|
23
|
+
"lint": "eslint ."
|
|
20
24
|
},
|
|
21
25
|
"publishConfig": {
|
|
22
26
|
"access": "public"
|
package/src/index.js
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
import * as ts from 'typescript';
|
|
2
1
|
import { createSystem, createDefaultMapFromNodeModules, createVirtualTypeScriptEnvironment } from '@typescript/vfs';
|
|
3
|
-
import
|
|
2
|
+
import * as ts from 'typescript';
|
|
3
|
+
|
|
4
4
|
import { ScriptParser } from './parsers/script-parser.js';
|
|
5
5
|
import { createDefaultMapFromCDN, flatMapAnyNodes, getExportedNodes, getType, inheritsFrom, isAliasedClassDeclaration } from './utils/ts-utils.js';
|
|
6
6
|
|
|
7
7
|
const toLowerCamelCase = str => str[0].toLowerCase() + str.substring(1);
|
|
8
8
|
|
|
9
9
|
const COMPILER_OPTIONS = {
|
|
10
|
-
|
|
10
|
+
strict: false,
|
|
11
11
|
skipLibCheck: true, // Skip type checking of declaration files
|
|
12
12
|
target: ts.ScriptTarget.ES2022, // If this version changes, the types must be updated in the /rollup.config.mjs
|
|
13
13
|
module: ts.ModuleKind.CommonJS,
|
|
14
14
|
checkJs: true, // Enable JSDoc parsing
|
|
15
15
|
allowJs: true,
|
|
16
|
-
noImplicitAny: false, // Allow implicit any
|
|
17
16
|
baseUrl: './',
|
|
18
17
|
paths: {
|
|
19
|
-
|
|
18
|
+
'playcanvas': ['/playcanvas.js']
|
|
20
19
|
}
|
|
21
20
|
};
|
|
22
21
|
|
|
@@ -35,7 +34,7 @@ export class JSDocParser {
|
|
|
35
34
|
|
|
36
35
|
/**
|
|
37
36
|
* Initializes the JSDocParser with the standard library files
|
|
38
|
-
*
|
|
37
|
+
*
|
|
39
38
|
* @param {string} libPath - The path to standard library files
|
|
40
39
|
* @returns {Promise<JSDocParser>} - The initialized JSDocParser
|
|
41
40
|
*/
|
|
@@ -55,9 +54,6 @@ export class JSDocParser {
|
|
|
55
54
|
const system = createSystem(fsMap);
|
|
56
55
|
this._env = createVirtualTypeScriptEnvironment(system, Array.from(fsMap.keys()), ts, COMPILER_OPTIONS);
|
|
57
56
|
|
|
58
|
-
// Add global types to the parser
|
|
59
|
-
this._env.createFile('/global.d.ts', globalTypes);
|
|
60
|
-
|
|
61
57
|
return this;
|
|
62
58
|
}
|
|
63
59
|
|
|
@@ -100,7 +96,7 @@ export class JSDocParser {
|
|
|
100
96
|
|
|
101
97
|
/**
|
|
102
98
|
* Returns all the valid ESM Scripts within a file
|
|
103
|
-
* @param fileName - The file name in the program to check
|
|
99
|
+
* @param {string} fileName - The file name in the program to check
|
|
104
100
|
* @returns {import('typescript').Node[]} - An array of any exported ESM Script nodes within the file
|
|
105
101
|
*/
|
|
106
102
|
getAllEsmScripts(fileName) {
|
|
@@ -111,16 +107,16 @@ export class JSDocParser {
|
|
|
111
107
|
const pcTypes = this.program.getSourceFile('/playcanvas.d.ts');
|
|
112
108
|
|
|
113
109
|
if (!pcTypes) {
|
|
114
|
-
throw new Error(
|
|
110
|
+
throw new Error('PlayCanvas Types must be supplied');
|
|
115
111
|
}
|
|
116
|
-
|
|
112
|
+
|
|
117
113
|
// Parse the source file and pc types
|
|
118
114
|
const sourceFile = this.program.getSourceFile(fileName);
|
|
119
|
-
|
|
115
|
+
|
|
120
116
|
if (!sourceFile) {
|
|
121
117
|
throw new Error(`Source file ${fileName} not found`);
|
|
122
118
|
}
|
|
123
|
-
|
|
119
|
+
|
|
124
120
|
// Extract all exported nodes
|
|
125
121
|
const nodes = getExportedNodes(this.program, sourceFile);
|
|
126
122
|
|
|
@@ -141,7 +137,7 @@ export class JSDocParser {
|
|
|
141
137
|
const results = {};
|
|
142
138
|
const errors = [...this._errors];
|
|
143
139
|
|
|
144
|
-
if(errors.length > 0
|
|
140
|
+
if (errors.length > 0) {
|
|
145
141
|
return [results, errors];
|
|
146
142
|
}
|
|
147
143
|
|
|
@@ -167,7 +163,7 @@ export class JSDocParser {
|
|
|
167
163
|
const results = {};
|
|
168
164
|
const errors = [...this._errors];
|
|
169
165
|
|
|
170
|
-
if(errors.length > 0
|
|
166
|
+
if (errors.length > 0) {
|
|
171
167
|
return [results, errors];
|
|
172
168
|
}
|
|
173
169
|
|
|
@@ -205,7 +201,7 @@ export class JSDocParser {
|
|
|
205
201
|
}
|
|
206
202
|
|
|
207
203
|
// Extract JSDoc tags
|
|
208
|
-
const tags = member.jsDoc.map(jsdoc => jsdoc.tags?.map(tag => tag.tagName.getText()) ?? []).flat();
|
|
204
|
+
const tags = member.jsDoc ? member.jsDoc.map(jsdoc => jsdoc.tags?.map(tag => tag.tagName.getText()) ?? []).flat() : [];
|
|
209
205
|
|
|
210
206
|
const name = member.name.getText();
|
|
211
207
|
const type = getType(member, typeChecker);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { TSDocConfiguration, TSDocTagDefinition, TSDocTagSyntaxKind, TextRange, TSDocParser } from '@microsoft/tsdoc';
|
|
1
2
|
import * as ts from 'typescript';
|
|
2
|
-
import { TSDocConfiguration, TSDocTagDefinition, TSDocTagSyntaxKind, TextRange, TSDocParser } from "@microsoft/tsdoc";
|
|
3
|
-
import { extractTextFromDocNode, getLeadingBlockCommentRanges, getType } from '../utils/ts-utils.js';
|
|
4
3
|
|
|
5
|
-
import { ParsingError } from
|
|
6
|
-
import { hasTag } from
|
|
7
|
-
import { parseTag, validateTag } from
|
|
4
|
+
import { ParsingError } from './parsing-error.js';
|
|
5
|
+
import { hasTag } from '../utils/attribute-utils.js';
|
|
6
|
+
import { parseTag, validateTag } from '../utils/tag-utils.js';
|
|
7
|
+
import { extractTextFromDocNode, getLeadingBlockCommentRanges, getType } from '../utils/ts-utils.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* A class to parse JSDoc comments and extract attribute metadata.
|
|
@@ -197,7 +197,7 @@ export class AttributeParser {
|
|
|
197
197
|
} else {
|
|
198
198
|
// Check for JSDoc annotations
|
|
199
199
|
const jsDocs = ts.getJSDocTags(node);
|
|
200
|
-
const typeTag = jsDocs.find(doc => doc.tagName.text ===
|
|
200
|
+
const typeTag = jsDocs.find(doc => doc.tagName.text === 'type');
|
|
201
201
|
if (typeTag && ts.isJSDocTypeTag(typeTag)) {
|
|
202
202
|
typeNode = typeTag.typeExpression;
|
|
203
203
|
}
|
|
@@ -227,7 +227,7 @@ export class AttributeParser {
|
|
|
227
227
|
|
|
228
228
|
// Additionally check for JSDoc enum tag
|
|
229
229
|
const jsDocs = ts.getJSDocTags(declaration);
|
|
230
|
-
const enumTag = jsDocs.find(doc => doc.tagName.text ===
|
|
230
|
+
const enumTag = jsDocs.find(doc => doc.tagName.text === 'enum');
|
|
231
231
|
if (enumTag && ts.isJSDocEnumTag(enumTag)) {
|
|
232
232
|
// This assumes enum members are correctly annotated in JSDoc comments
|
|
233
233
|
// Example: @enum {type} EnumName { Member1, Member2 }
|
|
@@ -245,10 +245,9 @@ export class AttributeParser {
|
|
|
245
245
|
* Extract the public members and their values from a TypeScript node.
|
|
246
246
|
*
|
|
247
247
|
* @param {ts.Node} node - The node to parse
|
|
248
|
-
* @param {ParsingError[]} errors - An array to store any parsing errors
|
|
249
248
|
* @returns {any[]} - The extracted members
|
|
250
249
|
*/
|
|
251
|
-
getMembers(node
|
|
250
|
+
getMembers(node) {
|
|
252
251
|
|
|
253
252
|
const members = [];
|
|
254
253
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import * as ts from 'typescript';
|
|
2
1
|
import { TextRange } from '@microsoft/tsdoc';
|
|
2
|
+
import * as ts from 'typescript';
|
|
3
3
|
|
|
4
4
|
import { AttributeParser } from './attribute-parser.js';
|
|
5
5
|
import { ParsingError } from './parsing-error.js';
|
|
6
|
-
import { zipArrays } from '../utils/generic-utils.js';
|
|
7
6
|
import { hasTag } from '../utils/attribute-utils.js';
|
|
8
|
-
import {
|
|
7
|
+
import { zipArrays } from '../utils/generic-utils.js';
|
|
8
|
+
import { flatMapAnyNodes, getJSDocCommentRanges, parseArrayLiteral, parseBooleanNode, parseFloatNode, parseStringNode } from '../utils/ts-utils.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* @typedef {object} Attribute
|
|
@@ -72,27 +72,27 @@ const createArrayArgumentParser = (name, defaultArr = []) => (
|
|
|
72
72
|
* eg `new Vec3(1, 2, 3)`
|
|
73
73
|
*/
|
|
74
74
|
const SUPPORTED_INITIALIZABLE_TYPE_NAMES = new Map([
|
|
75
|
-
[
|
|
76
|
-
[
|
|
77
|
-
[
|
|
78
|
-
[
|
|
79
|
-
[
|
|
80
|
-
[
|
|
81
|
-
[
|
|
82
|
-
[
|
|
75
|
+
['Curve', createArrayArgumentParser('Curve')],
|
|
76
|
+
['Vec2', createNumberArgumentParser('Vec2', [0, 0])],
|
|
77
|
+
['Vec3', createNumberArgumentParser('Vec3', [0, 0, 0])],
|
|
78
|
+
['Vec4', createNumberArgumentParser('Vec4', [0, 0, 0, 0])],
|
|
79
|
+
['Color', createNumberArgumentParser('Color', [1, 1, 1, 1])],
|
|
80
|
+
['number', parseFloatNode],
|
|
81
|
+
['string', parseStringNode],
|
|
82
|
+
['boolean', parseBooleanNode]
|
|
83
83
|
]);
|
|
84
84
|
|
|
85
85
|
/**
|
|
86
86
|
* The full set of supported PlayCanvas types.
|
|
87
87
|
*/
|
|
88
88
|
const SUPPORTED_PLAYCANVAS_TYPES = new Set([
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
89
|
+
'Curve',
|
|
90
|
+
'Asset',
|
|
91
|
+
'Entity',
|
|
92
|
+
'Vec2',
|
|
93
|
+
'Vec3',
|
|
94
|
+
'Vec4',
|
|
95
|
+
'Color'
|
|
96
96
|
]);
|
|
97
97
|
|
|
98
98
|
/**
|
|
@@ -260,7 +260,8 @@ export class ScriptParser {
|
|
|
260
260
|
validateProgram(errors = []) {
|
|
261
261
|
|
|
262
262
|
// Report any compiler errors
|
|
263
|
-
const compilerDiagnostics = this.program.
|
|
263
|
+
const compilerDiagnostics = this.program.getSyntacticDiagnostics();
|
|
264
|
+
|
|
264
265
|
if (compilerDiagnostics.length > 0) {
|
|
265
266
|
for (const diagnostic of compilerDiagnostics) {
|
|
266
267
|
const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
|
|
@@ -13,26 +13,24 @@ export const getTagFromJsdoc = (tag, doc) => {
|
|
|
13
13
|
return doc?.tags?.find(doc => doc.tagName.text === tag);
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
|
|
17
16
|
/**
|
|
18
17
|
* Checks if a node has a specific JSDoc tag.
|
|
19
18
|
* @param {string} tag - The tag to search for
|
|
20
19
|
* @param {import("typescript").Node} node - The node to analyze
|
|
21
|
-
* @returns {
|
|
20
|
+
* @returns {import('typescript').Node} - True if the tag is found
|
|
22
21
|
*/
|
|
23
|
-
export const
|
|
24
|
-
return
|
|
22
|
+
export const getTag = (tag, node) => {
|
|
23
|
+
return node?.jsDoc?.find(doc => getTagFromJsdoc(tag, doc));
|
|
25
24
|
};
|
|
26
25
|
|
|
27
|
-
|
|
28
26
|
/**
|
|
29
27
|
* Checks if a node has a specific JSDoc tag.
|
|
30
28
|
* @param {string} tag - The tag to search for
|
|
31
29
|
* @param {import("typescript").Node} node - The node to analyze
|
|
32
|
-
* @returns {
|
|
30
|
+
* @returns {boolean} - True if the tag is found
|
|
33
31
|
*/
|
|
34
|
-
export const
|
|
35
|
-
return
|
|
32
|
+
export const hasTag = (tag, node) => {
|
|
33
|
+
return !!getTag(tag, node);
|
|
36
34
|
};
|
|
37
35
|
|
|
38
36
|
|
package/src/utils/tag-utils.js
CHANGED
|
@@ -22,12 +22,12 @@ export function parseTag(input = '') {
|
|
|
22
22
|
try {
|
|
23
23
|
const arr = parseStringToNumericalArray(input);
|
|
24
24
|
if (Array.isArray(arr)) return arr;
|
|
25
|
-
} catch
|
|
25
|
+
} catch { /* eslint-disable-next-line no-empty */ }
|
|
26
26
|
|
|
27
27
|
try {
|
|
28
28
|
const arr = JSON.parse(input);
|
|
29
29
|
if (Array.isArray(arr)) return arr;
|
|
30
|
-
} catch
|
|
30
|
+
} catch { /* eslint-disable-next-line no-empty */ }
|
|
31
31
|
|
|
32
32
|
// If none of the above, return the string
|
|
33
33
|
return input;
|
|
@@ -45,7 +45,7 @@ export function parseTag(input = '') {
|
|
|
45
45
|
export function validateTag(value, typeAnnotation, env) {
|
|
46
46
|
|
|
47
47
|
const sourceText = `let a: ${typeAnnotation} = ${value};`;
|
|
48
|
-
env.createFile(
|
|
48
|
+
env.createFile('/___virtual__.ts', sourceText);
|
|
49
49
|
|
|
50
50
|
// Get the program and check for semantic errors
|
|
51
51
|
const program = env.languageService.getProgram();
|
package/src/utils/ts-utils.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DocNodeKind } from '@microsoft/tsdoc';
|
|
2
2
|
import { knownLibFilesForCompilerOptions } from '@typescript/vfs';
|
|
3
3
|
import * as ts from 'typescript';
|
|
4
|
+
|
|
4
5
|
import { ParsingError } from '../parsers/parsing-error.js';
|
|
5
6
|
|
|
6
7
|
export function createDefaultMapFromCDN(options, prefix, ts) {
|
|
@@ -19,9 +20,7 @@ export function createDefaultMapFromCDN(options, prefix, ts) {
|
|
|
19
20
|
|
|
20
21
|
const contents = await Promise.all(contentPromises);
|
|
21
22
|
|
|
22
|
-
contents.forEach(
|
|
23
|
-
return fsMap.set('/' + files[index], text);
|
|
24
|
-
});
|
|
23
|
+
contents.forEach((text, index) => fsMap.set(`/${files[index]}`, text));
|
|
25
24
|
|
|
26
25
|
return fsMap;
|
|
27
26
|
}
|
|
@@ -12,15 +12,17 @@ const NumberEnum = {
|
|
|
12
12
|
/**
|
|
13
13
|
* @enum {string}
|
|
14
14
|
*/
|
|
15
|
+
// eslint-disable-next-line
|
|
15
16
|
const StringEnum = {
|
|
16
17
|
A: 'a',
|
|
17
18
|
B: 'b',
|
|
18
19
|
C: 'c'
|
|
19
|
-
}
|
|
20
|
+
};
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* @enum {Vec3}
|
|
23
24
|
*/
|
|
25
|
+
// eslint-disable-next-line
|
|
24
26
|
const Vec3Enum = {
|
|
25
27
|
A: new Vec3(1, 2, 3),
|
|
26
28
|
B: new Vec3(4, 5, 6),
|
|
@@ -30,11 +32,12 @@ const Vec3Enum = {
|
|
|
30
32
|
/**
|
|
31
33
|
* @enum {NumberEnum}
|
|
32
34
|
*/
|
|
35
|
+
// eslint-disable-next-line
|
|
33
36
|
const NumberNumberEnum = {
|
|
34
37
|
A: NumberEnum.A,
|
|
35
38
|
B: NumberEnum.B,
|
|
36
39
|
C: NumberEnum.C
|
|
37
|
-
}
|
|
40
|
+
};
|
|
38
41
|
|
|
39
42
|
class Example extends Script {
|
|
40
43
|
/**
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
|
|
2
1
|
import { Script } from 'playcanvas';
|
|
3
2
|
|
|
4
3
|
import { ExampleImport } from './export.import.js';
|
|
5
4
|
|
|
6
|
-
class ExampleImportExtend extends ExampleImport {}
|
|
5
|
+
class ExampleImportExtend extends ExampleImport {}
|
|
7
6
|
|
|
8
7
|
export { ExampleImport as ExampleImportExportAs } from './export.import.js';
|
|
9
8
|
|
|
10
|
-
class Example extends Script {}
|
|
9
|
+
class Example extends Script {}
|
|
11
10
|
|
|
12
|
-
export default class ExampleDefault extends Script {}
|
|
11
|
+
export default class ExampleDefault extends Script {}
|
|
13
12
|
|
|
14
13
|
export class ExampleExport extends Script {}
|
|
15
14
|
|
|
15
|
+
// eslint-disable-next-line
|
|
16
16
|
class ExampleNotExported extends Script {}
|
|
17
17
|
|
|
18
18
|
export {
|
|
@@ -20,4 +20,4 @@ export {
|
|
|
20
20
|
Example as ExampleExportAs,
|
|
21
21
|
ExampleImport,
|
|
22
22
|
ExampleImportExtend
|
|
23
|
-
}
|
|
23
|
+
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
import { Script } from 'playcanvas';
|
|
3
2
|
|
|
4
3
|
class Example extends Script {
|
|
@@ -7,7 +6,7 @@ class Example extends Script {
|
|
|
7
6
|
* @type {boolean}
|
|
8
7
|
*/
|
|
9
8
|
a;
|
|
10
|
-
}
|
|
9
|
+
}
|
|
11
10
|
|
|
12
11
|
class ExampleExtended extends Example {
|
|
13
12
|
/**
|
|
@@ -15,7 +14,7 @@ class ExampleExtended extends Example {
|
|
|
15
14
|
* @type {number}
|
|
16
15
|
*/
|
|
17
16
|
b;
|
|
18
|
-
}
|
|
17
|
+
}
|
|
19
18
|
|
|
20
19
|
class ExampleExtendedExtended extends ExampleExtended {
|
|
21
20
|
/**
|
|
@@ -3,6 +3,7 @@ import { Script, Vec3 } from 'playcanvas';
|
|
|
3
3
|
/**
|
|
4
4
|
* @interface
|
|
5
5
|
*/
|
|
6
|
+
// eslint-disable-next-line
|
|
6
7
|
class Folder {
|
|
7
8
|
/**
|
|
8
9
|
* @attribute
|
|
@@ -26,7 +27,9 @@ class Folder {
|
|
|
26
27
|
|
|
27
28
|
/**
|
|
28
29
|
* @interface
|
|
30
|
+
*
|
|
29
31
|
*/
|
|
32
|
+
// eslint-disable-next-line
|
|
30
33
|
class NestedFolder {
|
|
31
34
|
/**
|
|
32
35
|
* @attribute
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
+
import * as TWEEN from 'https://cdnjs.cloudflare.com/ajax/libs/tween.js/23.1.2/tween.esm.js';
|
|
2
|
+
import confetti from 'https://esm.sh/canvas-confetti@1.6.0';
|
|
1
3
|
import { Script } from 'playcanvas';
|
|
2
4
|
|
|
3
|
-
// The parser should ignore https imports and not throw an error
|
|
4
|
-
import confetti from "https://esm.sh/canvas-confetti@1.6.0"
|
|
5
|
-
|
|
6
5
|
class Example extends Script {
|
|
7
6
|
/**
|
|
8
7
|
* @attribute
|
|
@@ -12,6 +11,7 @@ class Example extends Script {
|
|
|
12
11
|
|
|
13
12
|
initialize() {
|
|
14
13
|
confetti();
|
|
14
|
+
new TWEEN.Tween({ x: 0 }).to({ x: 100 }, 1000).start();
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
/* eslint-disable no-unused-expressions */
|
|
2
|
-
import { describe, it, before } from 'mocha';
|
|
3
1
|
import { expect } from 'chai';
|
|
2
|
+
import { describe, it, before } from 'mocha';
|
|
4
3
|
|
|
5
4
|
import { parseAttributes } from '../../utils.js';
|
|
6
5
|
|
|
@@ -13,6 +12,6 @@ describe('INVALID: Program ', function () {
|
|
|
13
12
|
it('only errors should exist (1)', function () {
|
|
14
13
|
expect(data).to.exist;
|
|
15
14
|
expect(data[0]).to.be.empty;
|
|
16
|
-
expect(data[1].length).to.equal(
|
|
15
|
+
expect(data[1].length).to.equal(4);
|
|
17
16
|
});
|
|
18
17
|
});
|
package/test/utils.js
CHANGED
package/src/global.types.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* These types are use to extend the global types in the program being parsed.
|
|
3
|
-
* It's useful to add types to modules that are not written in TypeScript.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
// This allows http/s modules to be imported without TypeScript errors
|
|
7
|
-
|
|
8
|
-
export default `
|
|
9
|
-
declare module 'http://*' {
|
|
10
|
-
const value: any;
|
|
11
|
-
export default value;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
declare module 'https://*' {
|
|
15
|
-
const value: any;
|
|
16
|
-
export default value;
|
|
17
|
-
}
|
|
18
|
-
`
|