@playcanvas/attribute-parser 1.8.0 → 1.10.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@playcanvas/attribute-parser",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"author": "PlayCanvas <support@playcanvas.com>",
|
|
5
5
|
"homepage": "https://github.com/playcanvas/attribute-parser#readme",
|
|
6
6
|
"description": "The PlayCanvas Attribute Parser",
|
|
@@ -44,11 +44,11 @@
|
|
|
44
44
|
"@rollup/plugin-commonjs": "28.0.6",
|
|
45
45
|
"@rollup/plugin-node-resolve": "16.0.1",
|
|
46
46
|
"@rollup/plugin-swc": "0.4.0",
|
|
47
|
-
"@swc/core": "1.
|
|
48
|
-
"chai": "5.2.
|
|
49
|
-
"globals": "16.
|
|
50
|
-
"mocha": "11.
|
|
51
|
-
"rollup": "4.
|
|
47
|
+
"@swc/core": "1.13.3",
|
|
48
|
+
"chai": "5.2.1",
|
|
49
|
+
"globals": "16.3.0",
|
|
50
|
+
"mocha": "11.7.1",
|
|
51
|
+
"rollup": "4.46.2",
|
|
52
52
|
"publint": "0.3.12"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
package/types/index.d.ts
CHANGED
|
@@ -34,9 +34,10 @@ export class JSDocParser {
|
|
|
34
34
|
/**
|
|
35
35
|
* Returns all the valid ESM Scripts within a file
|
|
36
36
|
* @param {string} fileName - The file name in the program to check
|
|
37
|
+
* @param {ParsingError[]} errors - An array to store any parsing errors
|
|
37
38
|
* @returns {Map<string, import('typescript').Node>} - A map of valid ESM Script <names, nodes> within the file
|
|
38
39
|
*/
|
|
39
|
-
getAllEsmScripts(fileName: string): Map<string, import("typescript").Node>;
|
|
40
|
+
getAllEsmScripts(fileName: string, errors?: ParsingError[]): Map<string, import("typescript").Node>;
|
|
40
41
|
/**
|
|
41
42
|
* Analyzes the specified TypeScript file and extracts metadata from JSDoc comments.
|
|
42
43
|
*
|
|
@@ -53,3 +54,4 @@ export class JSDocParser {
|
|
|
53
54
|
}
|
|
54
55
|
import { ScriptParser } from './parsers/script-parser.js';
|
|
55
56
|
import * as ts from 'typescript';
|
|
57
|
+
import { ParsingError } from './parsers/parsing-error.js';
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} TagDefinition
|
|
3
|
+
* @property {string} type - The type of the tag
|
|
4
|
+
* @property {() => string} supportMessage - A function to generate a support message for the tag
|
|
5
|
+
* @property {string} fix - A function to fix the tag
|
|
6
|
+
*/
|
|
1
7
|
/**
|
|
2
8
|
* A class to parse JSDoc comments and extract attribute metadata.
|
|
3
9
|
*/
|
|
@@ -5,13 +11,13 @@ export class AttributeParser {
|
|
|
5
11
|
/**
|
|
6
12
|
* Creates a new instance of the ScriptParser class.
|
|
7
13
|
*
|
|
8
|
-
* @param {Map<string,
|
|
14
|
+
* @param {Map<string, TagDefinition>} tags - An set of tag definitions and their validators to add to the parser
|
|
9
15
|
* @param {object} env - The TypeScript environment to use
|
|
10
16
|
* @param {Map<string, Function>} typeSerializerMap - A map of custom serializers
|
|
11
17
|
*/
|
|
12
|
-
constructor(tags: Map<string,
|
|
18
|
+
constructor(tags: Map<string, TagDefinition>, env: object, typeSerializerMap: Map<string, Function>);
|
|
13
19
|
env: any;
|
|
14
|
-
tagTypeAnnotations: Map<string,
|
|
20
|
+
tagTypeAnnotations: Map<string, TagDefinition>;
|
|
15
21
|
typeSerializerMap: Map<string, Function>;
|
|
16
22
|
program: any;
|
|
17
23
|
typeChecker: any;
|
|
@@ -51,5 +57,19 @@ export class AttributeParser {
|
|
|
51
57
|
*/
|
|
52
58
|
getMembers(node: ts.Node): any[];
|
|
53
59
|
}
|
|
60
|
+
export type TagDefinition = {
|
|
61
|
+
/**
|
|
62
|
+
* - The type of the tag
|
|
63
|
+
*/
|
|
64
|
+
type: string;
|
|
65
|
+
/**
|
|
66
|
+
* - A function to generate a support message for the tag
|
|
67
|
+
*/
|
|
68
|
+
supportMessage: () => string;
|
|
69
|
+
/**
|
|
70
|
+
* - A function to fix the tag
|
|
71
|
+
*/
|
|
72
|
+
fix: string;
|
|
73
|
+
};
|
|
54
74
|
import * as ts from 'typescript';
|
|
55
75
|
import { ParsingError } from './parsing-error.js';
|
|
@@ -1,6 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} Fix
|
|
3
|
+
* @property {string} text - The text to insert at the fix location
|
|
4
|
+
* @property {string} title - The title of the fix
|
|
5
|
+
* @property {{ startLineNumber: number, startColumn: number, endLineNumber: number, endColumn: number }} range - The range of the fix
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* A class representing a parsing error.
|
|
9
|
+
* @param {import('typescript').Node} node - The AST node which caused the error
|
|
10
|
+
* @param {string} type - The type of the error
|
|
11
|
+
* @param {string} message - The description of the error
|
|
12
|
+
* @param {Fix} [fix] - The fix for the error
|
|
13
|
+
*/
|
|
1
14
|
export class ParsingError {
|
|
2
|
-
constructor(node: any, message: any);
|
|
15
|
+
constructor(node: any, type: any, message: any, fix: any);
|
|
3
16
|
node: any;
|
|
17
|
+
type: any;
|
|
4
18
|
message: any;
|
|
19
|
+
fix: any;
|
|
5
20
|
toString(): string;
|
|
6
21
|
}
|
|
22
|
+
export type Fix = {
|
|
23
|
+
/**
|
|
24
|
+
* - The text to insert at the fix location
|
|
25
|
+
*/
|
|
26
|
+
text: string;
|
|
27
|
+
/**
|
|
28
|
+
* - The title of the fix
|
|
29
|
+
*/
|
|
30
|
+
title: string;
|
|
31
|
+
/**
|
|
32
|
+
* - The range of the fix
|
|
33
|
+
*/
|
|
34
|
+
range: {
|
|
35
|
+
startLineNumber: number;
|
|
36
|
+
startColumn: number;
|
|
37
|
+
endLineNumber: number;
|
|
38
|
+
endColumn: number;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export function
|
|
2
|
-
export function getTag(tag: string, node: import("typescript").Node): import("typescript").Node;
|
|
1
|
+
export function getTag(tag: string, node: import("typescript").Node): import("typescript").JSDocTag | null;
|
|
3
2
|
export function hasTag(tag: string, node: import("typescript").Node): boolean;
|
|
4
3
|
export function isInterface(node: import("typescript").Node): boolean;
|
|
5
4
|
export function isStaticMember(member: import("typescript").Node): boolean;
|