xml-model 1.3.2 → 2.0.0-beta.1
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 +39 -35
- package/dist/index.d.ts +3 -7
- package/dist/index.js +18 -17
- package/dist/model.d.ts +53 -0
- package/dist/model.js +69 -0
- package/dist/util/zod.d.ts +4 -0
- package/dist/util/zod.js +21 -0
- package/dist/xml/codec.d.ts +87 -0
- package/dist/xml/codec.js +385 -0
- package/dist/xml/examples.d.ts +188 -0
- package/dist/xml/index.d.ts +5 -32
- package/dist/xml/index.js +14 -54
- package/dist/xml/model.d.ts +18 -0
- package/dist/xml/model.js +37 -0
- package/dist/xml/schema-meta.d.ts +57 -0
- package/dist/xml/schema-meta.js +96 -0
- package/dist/xml/xml-js.d.ts +138 -3
- package/dist/xml/xml-js.js +89 -5
- package/package.json +10 -23
- package/dist/_virtual/Reflect.js +0 -8
- package/dist/_virtual/Reflect2.js +0 -5
- package/dist/_virtual/_commonjsHelpers.js +0 -47
- package/dist/defaults.d.ts +0 -15
- package/dist/defaults.js +0 -130
- package/dist/errors.d.ts +0 -24
- package/dist/errors.js +0 -45
- package/dist/middleware.d.ts +0 -10
- package/dist/middleware.js +0 -25
- package/dist/model/built-ins.d.ts +0 -3
- package/dist/model/built-ins.js +0 -43
- package/dist/model/index.d.ts +0 -21
- package/dist/model/index.js +0 -236
- package/dist/model/property.d.ts +0 -6
- package/dist/model/property.js +0 -67
- package/dist/model/registry.d.ts +0 -9
- package/dist/model/registry.js +0 -19
- package/dist/model/types.d.ts +0 -74
- package/dist/node_modules/reflect-metadata/Reflect.js +0 -806
- package/dist/types.d.ts +0 -17
- package/dist/util/is-regexp.d.ts +0 -12
- package/dist/util/is-regexp.js +0 -8
- package/dist/util/merge-maps.d.ts +0 -2
- package/dist/util/merge-maps.js +0 -23
- package/dist/vite/index.d.ts +0 -53
- package/dist/vite/index.js +0 -63
- package/dist/vite/node_modules/typescript-rtti/dist.esm/common/format.js +0 -105
- package/dist/vite/node_modules/typescript-rtti/dist.esm/common/index.js +0 -55
- package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/api-call-transformer.js +0 -152
- package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/common/class-analyzer.js +0 -83
- package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/common/compile-error.js +0 -8
- package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/common/import-analyzer.js +0 -89
- package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/common/interface-analyzer.js +0 -58
- package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/common/visitor-base.js +0 -93
- package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/declarations-emitter.js +0 -31
- package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/encode-parameter.js +0 -64
- package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/find-relative-path.js +0 -41
- package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/flags.js +0 -43
- package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/forward-ref.js +0 -20
- package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/get-exports-for-symbol.js +0 -64
- package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/index.js +0 -130
- package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/legacy-decorator.js +0 -10
- package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/legacy-type-encoder.js +0 -82
- package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/literal-node.js +0 -9
- package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/metadata-collector.js +0 -56
- package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/metadata-decorator.js +0 -80
- package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/metadata-emitter.js +0 -425
- package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/metadata-encoder.js +0 -212
- package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/rt-helper.js +0 -96
- package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/rtti-visitor-base.js +0 -28
- package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/serialize.js +0 -31
- package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/type-encoder.js +0 -76
- package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/type-literal.js +0 -499
- package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/utils.js +0 -906
- package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/workarounds.js +0 -7
package/dist/types.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export type { Constructor } from 'typescript-rtti';
|
|
2
|
-
export type UnknownRecord = Record<string | number | symbol, unknown>;
|
|
3
|
-
export type UnknownObject = object;
|
|
4
|
-
export interface XMLAttributes {
|
|
5
|
-
[key: string]: string | number | undefined;
|
|
6
|
-
}
|
|
7
|
-
export interface XMLElement {
|
|
8
|
-
type?: string;
|
|
9
|
-
name?: string;
|
|
10
|
-
attributes?: XMLAttributes;
|
|
11
|
-
elements?: Array<XMLElement>;
|
|
12
|
-
text?: string | number | boolean;
|
|
13
|
-
}
|
|
14
|
-
export type XMLRoot = {
|
|
15
|
-
elements: XMLElement[];
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/util/is-regexp.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Stolen from https://github.com/sindresorhus/is-regexp/blob/main/index.js
|
|
3
|
-
*
|
|
4
|
-
* see https://github.com/sindresorhus/is#why-not-just-use-instanceof-instead-of-this-package
|
|
5
|
-
*
|
|
6
|
-
* could use `import { isRegExp } from "node:util/types"` but I want isomorphic lib
|
|
7
|
-
* @param value
|
|
8
|
-
* @returns
|
|
9
|
-
*/
|
|
10
|
-
export declare function isRegExp(value: unknown): value is RegExp;
|
|
11
|
-
export default isRegExp;
|
|
12
|
-
//# sourceMappingURL=is-regexp.d.ts.map
|
package/dist/util/is-regexp.js
DELETED
package/dist/util/merge-maps.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
function mergeMaps(...sources) {
|
|
2
|
-
const res = /* @__PURE__ */ new Map();
|
|
3
|
-
sources.forEach((source) => {
|
|
4
|
-
const overrides = /* @__PURE__ */ new Map();
|
|
5
|
-
const additions = /* @__PURE__ */ new Map();
|
|
6
|
-
source.forEach((val, key) => (res.has(key) ? overrides : additions).set(key, val));
|
|
7
|
-
if (overrides.size) {
|
|
8
|
-
const entries = Array.from(res.entries());
|
|
9
|
-
entries.forEach((entry) => {
|
|
10
|
-
const key = entry[0];
|
|
11
|
-
if (overrides.has(key)) entry[1] = overrides.get(key);
|
|
12
|
-
});
|
|
13
|
-
res.clear();
|
|
14
|
-
entries.forEach(([key, val]) => res.set(key, val));
|
|
15
|
-
}
|
|
16
|
-
additions.forEach((val, key) => res.set(key, val));
|
|
17
|
-
});
|
|
18
|
-
return res;
|
|
19
|
-
}
|
|
20
|
-
export {
|
|
21
|
-
mergeMaps as default
|
|
22
|
-
};
|
|
23
|
-
//# sourceMappingURL=merge-maps.js.map
|
package/dist/vite/index.d.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { RollupTypescriptOptions } from '@rollup/plugin-typescript';
|
|
2
|
-
/**
|
|
3
|
-
* When Building, class names are changed but the library relies on them
|
|
4
|
-
* so they need to be preserved
|
|
5
|
-
* @returns
|
|
6
|
-
*/
|
|
7
|
-
export declare function FixClassNames(): {
|
|
8
|
-
name: string;
|
|
9
|
-
enforce: "post";
|
|
10
|
-
transform(this: import('rollup').TransformPluginContext, code: string, id: string): {
|
|
11
|
-
code: string;
|
|
12
|
-
map: any;
|
|
13
|
-
};
|
|
14
|
-
config(this: import('vite').ConfigPluginContext): {
|
|
15
|
-
esbuild: {
|
|
16
|
-
keepNames: true;
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
export type RTTIPluginOptions = {
|
|
21
|
-
/**
|
|
22
|
-
* options for @rollup/plugin-typescript
|
|
23
|
-
*
|
|
24
|
-
* Plugin might not work if you override the `transformers` property as these options are assigned and not deep merged
|
|
25
|
-
*/
|
|
26
|
-
typescript?: RollupTypescriptOptions;
|
|
27
|
-
/** Files where the rtti transformer should be applied
|
|
28
|
-
*
|
|
29
|
-
* If not set, will include every files by default
|
|
30
|
-
*/
|
|
31
|
-
include?: RegExp;
|
|
32
|
-
/** Files where the rtti transformer should not be applied */
|
|
33
|
-
exclude?: RegExp;
|
|
34
|
-
/** Print debug logs */
|
|
35
|
-
debug?: boolean;
|
|
36
|
-
};
|
|
37
|
-
export declare function TypescriptRTTI(options?: RTTIPluginOptions): import('rollup').Plugin<any>;
|
|
38
|
-
export type XMLModelVitePluginOptions = RTTIPluginOptions;
|
|
39
|
-
export declare function XMLModelVitePlugin(options?: RTTIPluginOptions): (import('rollup').Plugin<any> | {
|
|
40
|
-
name: string;
|
|
41
|
-
enforce: "post";
|
|
42
|
-
transform(this: import('rollup').TransformPluginContext, code: string, id: string): {
|
|
43
|
-
code: string;
|
|
44
|
-
map: any;
|
|
45
|
-
};
|
|
46
|
-
config(this: import('vite').ConfigPluginContext): {
|
|
47
|
-
esbuild: {
|
|
48
|
-
keepNames: true;
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
})[];
|
|
52
|
-
export default XMLModelVitePlugin;
|
|
53
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/vite/index.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import typescript from "@rollup/plugin-typescript";
|
|
2
|
-
import transformer from "./node_modules/typescript-rtti/dist.esm/transformer/index.js";
|
|
3
|
-
function FixClassNames() {
|
|
4
|
-
return {
|
|
5
|
-
name: "fix-class-names",
|
|
6
|
-
enforce: "post",
|
|
7
|
-
transform(code, id) {
|
|
8
|
-
if (!id.endsWith(".ts") && !id.endsWith(".tsx")) return;
|
|
9
|
-
const fixed = code.replace(/let\s+(\w+)\s*=\s*class\s+(?!extends)\w+/g, "let $1 = class $1");
|
|
10
|
-
return { code: fixed, map: null };
|
|
11
|
-
},
|
|
12
|
-
config() {
|
|
13
|
-
return {
|
|
14
|
-
esbuild: {
|
|
15
|
-
// if not using this ClassName is changed back to ClassName2 on build
|
|
16
|
-
keepNames: true
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
function TypescriptRTTI(options = {}) {
|
|
23
|
-
const { typescript: rollupPluginTypescriptOptions, include, exclude, debug = false } = options;
|
|
24
|
-
const doTransform = !include && !exclude ? () => true : (path) => {
|
|
25
|
-
if (exclude?.test(path)) return false;
|
|
26
|
-
return include ? include.test(path) : true;
|
|
27
|
-
};
|
|
28
|
-
return typescript({
|
|
29
|
-
transformers: {
|
|
30
|
-
before: [
|
|
31
|
-
{
|
|
32
|
-
type: "program",
|
|
33
|
-
factory: (program) => {
|
|
34
|
-
if (debug) console.debug("[RTTI] Transformer is running!");
|
|
35
|
-
const transformerFactory = transformer(program);
|
|
36
|
-
return (context) => {
|
|
37
|
-
const transform = transformerFactory(context);
|
|
38
|
-
return (source) => {
|
|
39
|
-
if (doTransform(source.fileName)) {
|
|
40
|
-
if (debug) console.debug(`[RTTI] transforming ${source.fileName}`);
|
|
41
|
-
return transform(source);
|
|
42
|
-
} else return source;
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
]
|
|
48
|
-
},
|
|
49
|
-
// set declaration to `false` to let plugin dts handle the declarations
|
|
50
|
-
declaration: false,
|
|
51
|
-
...rollupPluginTypescriptOptions
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
function XMLModelVitePlugin(options = {}) {
|
|
55
|
-
return [FixClassNames(), TypescriptRTTI(options)];
|
|
56
|
-
}
|
|
57
|
-
export {
|
|
58
|
-
FixClassNames,
|
|
59
|
-
TypescriptRTTI,
|
|
60
|
-
XMLModelVitePlugin,
|
|
61
|
-
XMLModelVitePlugin as default
|
|
62
|
-
};
|
|
63
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { createRequire } from "node:module";
|
|
2
|
-
const require$1 = createRequire(import.meta.url);
|
|
3
|
-
const F_READONLY = "R";
|
|
4
|
-
const F_ABSTRACT = "A";
|
|
5
|
-
const F_PUBLIC = "$";
|
|
6
|
-
const F_PRIVATE = "#";
|
|
7
|
-
const F_PROTECTED = "@";
|
|
8
|
-
const F_PROPERTY = "P";
|
|
9
|
-
const F_METHOD = "M";
|
|
10
|
-
const F_STATIC = "S";
|
|
11
|
-
const F_CLASS = "C";
|
|
12
|
-
const F_INTERFACE = "I";
|
|
13
|
-
const F_FUNCTION = "F";
|
|
14
|
-
const F_ARROW_FUNCTION = ">";
|
|
15
|
-
const F_OPTIONAL = "?";
|
|
16
|
-
const F_REST = "3";
|
|
17
|
-
const F_ASYNC = "a";
|
|
18
|
-
const F_EXPORTED = "e";
|
|
19
|
-
const F_INFERRED = ".";
|
|
20
|
-
const F_OMITTED = ",";
|
|
21
|
-
const F_ARRAY_BINDING = "[";
|
|
22
|
-
const F_OBJECT_BINDING = "O";
|
|
23
|
-
const T_UNION = "|";
|
|
24
|
-
const T_INTERSECTION = "&";
|
|
25
|
-
const T_ANY = "~";
|
|
26
|
-
const T_UNKNOWN = "U";
|
|
27
|
-
const T_VOID = "V";
|
|
28
|
-
const T_UNDEFINED = "u";
|
|
29
|
-
const T_NULL = "n";
|
|
30
|
-
const T_TUPLE = "T";
|
|
31
|
-
const T_ARRAY = "[";
|
|
32
|
-
const T_THIS = "t";
|
|
33
|
-
const T_GENERIC = "g";
|
|
34
|
-
const T_MAPPED = "m";
|
|
35
|
-
const T_TRUE = "1";
|
|
36
|
-
const T_FALSE = "0";
|
|
37
|
-
const T_CALLSITE = "c";
|
|
38
|
-
const T_STAND_IN = "5";
|
|
39
|
-
const T_OBJECT = "O";
|
|
40
|
-
const T_ENUM = "e";
|
|
41
|
-
const T_FUNCTION = "F";
|
|
42
|
-
const T_INTRINSICS = [T_VOID, T_ANY, T_UNKNOWN, T_UNDEFINED, T_TRUE, T_FALSE, T_THIS, T_NULL];
|
|
43
|
-
const TI_VOID = { TΦ: T_VOID };
|
|
44
|
-
const TI_ANY = { TΦ: T_ANY };
|
|
45
|
-
const TI_UNKNOWN = { TΦ: T_UNKNOWN };
|
|
46
|
-
const TI_UNDEFINED = { TΦ: T_UNDEFINED };
|
|
47
|
-
const TI_TRUE = { TΦ: T_TRUE };
|
|
48
|
-
const TI_FALSE = { TΦ: T_FALSE };
|
|
49
|
-
const TI_THIS = { TΦ: T_THIS };
|
|
50
|
-
const TI_NULL = { TΦ: T_NULL };
|
|
51
|
-
function isLiteralNode(node) {
|
|
52
|
-
return !!node["$__isTSNode"];
|
|
53
|
-
}
|
|
54
|
-
export {
|
|
55
|
-
F_ABSTRACT,
|
|
56
|
-
F_ARRAY_BINDING,
|
|
57
|
-
F_ARROW_FUNCTION,
|
|
58
|
-
F_ASYNC,
|
|
59
|
-
F_CLASS,
|
|
60
|
-
F_EXPORTED,
|
|
61
|
-
F_FUNCTION,
|
|
62
|
-
F_INFERRED,
|
|
63
|
-
F_INTERFACE,
|
|
64
|
-
F_METHOD,
|
|
65
|
-
F_OBJECT_BINDING,
|
|
66
|
-
F_OMITTED,
|
|
67
|
-
F_OPTIONAL,
|
|
68
|
-
F_PRIVATE,
|
|
69
|
-
F_PROPERTY,
|
|
70
|
-
F_PROTECTED,
|
|
71
|
-
F_PUBLIC,
|
|
72
|
-
F_READONLY,
|
|
73
|
-
F_REST,
|
|
74
|
-
F_STATIC,
|
|
75
|
-
TI_ANY,
|
|
76
|
-
TI_FALSE,
|
|
77
|
-
TI_NULL,
|
|
78
|
-
TI_THIS,
|
|
79
|
-
TI_TRUE,
|
|
80
|
-
TI_UNDEFINED,
|
|
81
|
-
TI_UNKNOWN,
|
|
82
|
-
TI_VOID,
|
|
83
|
-
T_ANY,
|
|
84
|
-
T_ARRAY,
|
|
85
|
-
T_CALLSITE,
|
|
86
|
-
T_ENUM,
|
|
87
|
-
T_FALSE,
|
|
88
|
-
T_FUNCTION,
|
|
89
|
-
T_GENERIC,
|
|
90
|
-
T_INTERSECTION,
|
|
91
|
-
T_INTRINSICS,
|
|
92
|
-
T_MAPPED,
|
|
93
|
-
T_NULL,
|
|
94
|
-
T_OBJECT,
|
|
95
|
-
T_STAND_IN,
|
|
96
|
-
T_THIS,
|
|
97
|
-
T_TRUE,
|
|
98
|
-
T_TUPLE,
|
|
99
|
-
T_UNDEFINED,
|
|
100
|
-
T_UNION,
|
|
101
|
-
T_UNKNOWN,
|
|
102
|
-
T_VOID,
|
|
103
|
-
isLiteralNode
|
|
104
|
-
};
|
|
105
|
-
//# sourceMappingURL=format.js.map
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { createRequire } from "node:module";
|
|
2
|
-
import { F_ABSTRACT, F_ARRAY_BINDING, F_ARROW_FUNCTION, F_ASYNC, F_CLASS, F_EXPORTED, F_FUNCTION, F_INFERRED, F_INTERFACE, F_METHOD, F_OBJECT_BINDING, F_OMITTED, F_OPTIONAL, F_PRIVATE, F_PROPERTY, F_PROTECTED, F_PUBLIC, F_READONLY, F_REST, F_STATIC, TI_ANY, TI_FALSE, TI_NULL, TI_THIS, TI_TRUE, TI_UNDEFINED, TI_UNKNOWN, TI_VOID, T_ANY, T_ARRAY, T_CALLSITE, T_ENUM, T_FALSE, T_FUNCTION, T_GENERIC, T_INTERSECTION, T_INTRINSICS, T_MAPPED, T_NULL, T_OBJECT, T_STAND_IN, T_THIS, T_TRUE, T_TUPLE, T_UNDEFINED, T_UNION, T_UNKNOWN, T_VOID, isLiteralNode } from "./format.js";
|
|
3
|
-
const require$1 = createRequire(import.meta.url);
|
|
4
|
-
export {
|
|
5
|
-
F_ABSTRACT,
|
|
6
|
-
F_ARRAY_BINDING,
|
|
7
|
-
F_ARROW_FUNCTION,
|
|
8
|
-
F_ASYNC,
|
|
9
|
-
F_CLASS,
|
|
10
|
-
F_EXPORTED,
|
|
11
|
-
F_FUNCTION,
|
|
12
|
-
F_INFERRED,
|
|
13
|
-
F_INTERFACE,
|
|
14
|
-
F_METHOD,
|
|
15
|
-
F_OBJECT_BINDING,
|
|
16
|
-
F_OMITTED,
|
|
17
|
-
F_OPTIONAL,
|
|
18
|
-
F_PRIVATE,
|
|
19
|
-
F_PROPERTY,
|
|
20
|
-
F_PROTECTED,
|
|
21
|
-
F_PUBLIC,
|
|
22
|
-
F_READONLY,
|
|
23
|
-
F_REST,
|
|
24
|
-
F_STATIC,
|
|
25
|
-
TI_ANY,
|
|
26
|
-
TI_FALSE,
|
|
27
|
-
TI_NULL,
|
|
28
|
-
TI_THIS,
|
|
29
|
-
TI_TRUE,
|
|
30
|
-
TI_UNDEFINED,
|
|
31
|
-
TI_UNKNOWN,
|
|
32
|
-
TI_VOID,
|
|
33
|
-
T_ANY,
|
|
34
|
-
T_ARRAY,
|
|
35
|
-
T_CALLSITE,
|
|
36
|
-
T_ENUM,
|
|
37
|
-
T_FALSE,
|
|
38
|
-
T_FUNCTION,
|
|
39
|
-
T_GENERIC,
|
|
40
|
-
T_INTERSECTION,
|
|
41
|
-
T_INTRINSICS,
|
|
42
|
-
T_MAPPED,
|
|
43
|
-
T_NULL,
|
|
44
|
-
T_OBJECT,
|
|
45
|
-
T_STAND_IN,
|
|
46
|
-
T_THIS,
|
|
47
|
-
T_TRUE,
|
|
48
|
-
T_TUPLE,
|
|
49
|
-
T_UNDEFINED,
|
|
50
|
-
T_UNION,
|
|
51
|
-
T_UNKNOWN,
|
|
52
|
-
T_VOID,
|
|
53
|
-
isLiteralNode
|
|
54
|
-
};
|
|
55
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import { Visit } from "./common/visitor-base.js";
|
|
2
|
-
import ts from "typescript";
|
|
3
|
-
import { isStatement, getRttiDocTagFromSignature, hasFlag } from "./utils.js";
|
|
4
|
-
import { RttiVisitor } from "./rtti-visitor-base.js";
|
|
5
|
-
import { serialize } from "./serialize.js";
|
|
6
|
-
import { TypeEncoder } from "./type-encoder.js";
|
|
7
|
-
import { literalNode } from "./literal-node.js";
|
|
8
|
-
import { createRequire } from "node:module";
|
|
9
|
-
var __decorate = function(decorators, target, key, desc) {
|
|
10
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
11
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
12
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
13
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
14
|
-
};
|
|
15
|
-
var __metadata = function(k, v) {
|
|
16
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
17
|
-
};
|
|
18
|
-
const require$1 = createRequire(import.meta.url);
|
|
19
|
-
class ApiCallTransformer extends RttiVisitor {
|
|
20
|
-
constructor() {
|
|
21
|
-
super(...arguments);
|
|
22
|
-
this.typeEncoder = new TypeEncoder(this.ctx);
|
|
23
|
-
}
|
|
24
|
-
static transform(node, ctx) {
|
|
25
|
-
let transformer = new ApiCallTransformer(ctx);
|
|
26
|
-
return transformer.visitNode(node);
|
|
27
|
-
}
|
|
28
|
-
everyNode(node) {
|
|
29
|
-
if (isStatement(node) && node.parent && ts.isSourceFile(node.parent)) {
|
|
30
|
-
this.ctx.currentTopStatement = node;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
isRttiCall(expr, name) {
|
|
34
|
-
if (!ts.isIdentifier(expr.expression))
|
|
35
|
-
return false;
|
|
36
|
-
return ts.isIdentifier(expr.expression) && this.isAnyImportedSymbol(this.checker.getSymbolAtLocation(expr.expression), ["typescript-rtti", "./FΦtypescript-rtti", "./FΦtypescript-rtti.js"], name ? [name] : ["reify", "reflect"]);
|
|
37
|
-
}
|
|
38
|
-
isAnyImportedSymbol(symbol, packageName, names) {
|
|
39
|
-
if (!symbol || !names.includes(symbol.name))
|
|
40
|
-
return false;
|
|
41
|
-
return this.isSymbolFromPackage(symbol, packageName);
|
|
42
|
-
}
|
|
43
|
-
isImportedSymbol(symbol, packageName, name) {
|
|
44
|
-
return this.isAnyImportedSymbol(symbol, [packageName], [name]);
|
|
45
|
-
}
|
|
46
|
-
isSymbolFromPackage(symbol, packageNames) {
|
|
47
|
-
let decls = Array.from(symbol.getDeclarations());
|
|
48
|
-
let importSpecifier = decls.find((x) => x.kind === ts.SyntaxKind.ImportSpecifier);
|
|
49
|
-
if (!importSpecifier)
|
|
50
|
-
return false;
|
|
51
|
-
let modSpecifier = importSpecifier.parent.parent.parent.moduleSpecifier;
|
|
52
|
-
if (!ts.isStringLiteral(modSpecifier))
|
|
53
|
-
return false;
|
|
54
|
-
for (let packageName of packageNames) {
|
|
55
|
-
let matches = modSpecifier.text === packageName || modSpecifier.text.match(new RegExp(`^https?:.*/${packageName}/index.js$`)) || modSpecifier.text.match(new RegExp(`^https?:.*/${packageName}/index.ts$`)) || modSpecifier.text.match(new RegExp(`^https?:.*/${packageName}/?$`));
|
|
56
|
-
if (matches)
|
|
57
|
-
return true;
|
|
58
|
-
}
|
|
59
|
-
return false;
|
|
60
|
-
}
|
|
61
|
-
isCallSiteTypeRef(typeNode) {
|
|
62
|
-
if (!typeNode)
|
|
63
|
-
return false;
|
|
64
|
-
if (typeNode.kind === ts.SyntaxKind.TypeReference) {
|
|
65
|
-
let typeRef = typeNode;
|
|
66
|
-
if (!typeRef.typeName)
|
|
67
|
-
return false;
|
|
68
|
-
if (typeRef.typeName.kind === ts.SyntaxKind.Identifier && typeRef.typeName.text === "CallSite") {
|
|
69
|
-
let symbol = this.checker.getSymbolAtLocation(typeRef.typeName);
|
|
70
|
-
return this.isImportedSymbol(symbol, "typescript-rtti", "CallSite");
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
return false;
|
|
74
|
-
}
|
|
75
|
-
isCallSiteParameter(param) {
|
|
76
|
-
return !!(param === null || param === void 0 ? void 0 : param.questionToken) && this.isCallSiteTypeRef(param === null || param === void 0 ? void 0 : param.type);
|
|
77
|
-
}
|
|
78
|
-
typeOfParamSymbol(symbol) {
|
|
79
|
-
return this.checker.getTypeOfSymbolAtLocation(symbol, symbol.getDeclarations()[0]);
|
|
80
|
-
}
|
|
81
|
-
callExpr(expr) {
|
|
82
|
-
var _a;
|
|
83
|
-
let signature = this.checker.getResolvedSignature(expr);
|
|
84
|
-
if (!signature) {
|
|
85
|
-
debugger;
|
|
86
|
-
if (globalThis.RTTI_TRACE)
|
|
87
|
-
console.warn(`RTTI: Could not find signature for call expression '${expr.getText()}'`);
|
|
88
|
-
return expr;
|
|
89
|
-
}
|
|
90
|
-
let params = signature.parameters;
|
|
91
|
-
let callSiteArgIndex = params.findIndex((x) => this.isCallSiteParameter(x.valueDeclaration));
|
|
92
|
-
if (callSiteArgIndex < 0) {
|
|
93
|
-
let callSiteArgFromJsDoc = getRttiDocTagFromSignature(signature, "callsite");
|
|
94
|
-
if (callSiteArgFromJsDoc)
|
|
95
|
-
callSiteArgIndex = Number(callSiteArgFromJsDoc);
|
|
96
|
-
}
|
|
97
|
-
if (this.isRttiCall(expr, "reflect") && callSiteArgIndex < 0) {
|
|
98
|
-
callSiteArgIndex = 1;
|
|
99
|
-
} else if (this.isRttiCall(expr, "reify") && callSiteArgIndex < 0) {
|
|
100
|
-
callSiteArgIndex = 0;
|
|
101
|
-
}
|
|
102
|
-
if (callSiteArgIndex >= 0 && callSiteArgIndex >= expr.arguments.length) {
|
|
103
|
-
let args = Array.from(expr.arguments);
|
|
104
|
-
while (callSiteArgIndex > args.length) {
|
|
105
|
-
args.push(ts.factory.createVoidZero());
|
|
106
|
-
}
|
|
107
|
-
args.push(serialize({
|
|
108
|
-
TΦ: "c",
|
|
109
|
-
t: void 0,
|
|
110
|
-
p: expr.arguments.map((x) => literalNode(this.referToType(this.checker.getTypeAtLocation(x)))),
|
|
111
|
-
r: void 0,
|
|
112
|
-
tp: ((_a = expr.typeArguments) !== null && _a !== void 0 ? _a : []).map((x) => literalNode(this.referToType(this.checker.getTypeAtLocation(x))))
|
|
113
|
-
}));
|
|
114
|
-
return ts.factory.updateCallExpression(this.visitEachChild(expr), expr.expression, expr.typeArguments, args);
|
|
115
|
-
} else {
|
|
116
|
-
return this.visitEachChild(expr);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
referToType(type) {
|
|
120
|
-
if (hasFlag(type.flags, ts.TypeFlags.TypeVariable)) {
|
|
121
|
-
let symbol = type.symbol;
|
|
122
|
-
let decl = symbol.declarations[0];
|
|
123
|
-
if (ts.isTypeParameterDeclaration(decl)) {
|
|
124
|
-
let parentDecl = decl.parent;
|
|
125
|
-
if (ts.isFunctionDeclaration(parentDecl) || ts.isArrowFunction(parentDecl) || ts.isMethodDeclaration(parentDecl) || ts.isFunctionExpression(parentDecl)) {
|
|
126
|
-
let typeIndex = parentDecl.typeParameters.findIndex((tp) => this.checker.getTypeAtLocation(tp) === type);
|
|
127
|
-
if (typeIndex >= 0) {
|
|
128
|
-
let callSiteArgIndex = parentDecl.parameters.findIndex((p) => this.isCallSiteParameter(p));
|
|
129
|
-
if (callSiteArgIndex >= 0) {
|
|
130
|
-
let callSiteArg = parentDecl.parameters[callSiteArgIndex];
|
|
131
|
-
if (ts.isIdentifier(callSiteArg.name)) {
|
|
132
|
-
let callSiteName = callSiteArg.name.text;
|
|
133
|
-
return ts.factory.createElementAccessExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier(callSiteName), "tp"), typeIndex);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
return this.typeEncoder.referToType(type);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
__decorate([
|
|
144
|
-
Visit(ts.SyntaxKind.CallExpression),
|
|
145
|
-
__metadata("design:type", Function),
|
|
146
|
-
__metadata("design:paramtypes", [Object]),
|
|
147
|
-
__metadata("design:returntype", void 0)
|
|
148
|
-
], ApiCallTransformer.prototype, "callExpr", null);
|
|
149
|
-
export {
|
|
150
|
-
ApiCallTransformer
|
|
151
|
-
};
|
|
152
|
-
//# sourceMappingURL=api-call-transformer.js.map
|
package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/common/class-analyzer.js
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { VisitorBase, Visit } from "./visitor-base.js";
|
|
2
|
-
import ts from "typescript";
|
|
3
|
-
import { getModifiers } from "../utils.js";
|
|
4
|
-
import { createRequire } from "node:module";
|
|
5
|
-
var __decorate = function(decorators, target, key, desc) {
|
|
6
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
7
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
8
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
9
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
10
|
-
};
|
|
11
|
-
var __metadata = function(k, v) {
|
|
12
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
13
|
-
};
|
|
14
|
-
const require$1 = createRequire(import.meta.url);
|
|
15
|
-
class ClassAnalyzer extends VisitorBase {
|
|
16
|
-
constructor() {
|
|
17
|
-
super(...arguments);
|
|
18
|
-
this.details = {
|
|
19
|
-
methodNames: [],
|
|
20
|
-
propertyNames: [],
|
|
21
|
-
staticMethodNames: [],
|
|
22
|
-
staticPropertyNames: []
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
isStatic(decl) {
|
|
26
|
-
return getModifiers(decl).some((x) => x.kind === ts.SyntaxKind.StaticKeyword);
|
|
27
|
-
}
|
|
28
|
-
static analyze(decl, context) {
|
|
29
|
-
try {
|
|
30
|
-
let analyzer = new ClassAnalyzer(context);
|
|
31
|
-
analyzer.visitEachChild(decl);
|
|
32
|
-
return analyzer.details;
|
|
33
|
-
} catch (e) {
|
|
34
|
-
console.error(`RTTI: During analyzer for class ${decl.name.getText()}: ${e.message}`);
|
|
35
|
-
throw e;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
addItem(list, prop) {
|
|
39
|
-
if (!list.includes(prop))
|
|
40
|
-
list.push(prop);
|
|
41
|
-
}
|
|
42
|
-
property(decl) {
|
|
43
|
-
this.addItem(this.isStatic(decl) ? this.details.staticPropertyNames : this.details.propertyNames, decl.name);
|
|
44
|
-
}
|
|
45
|
-
method(decl) {
|
|
46
|
-
this.addItem(this.isStatic(decl) ? this.details.staticMethodNames : this.details.methodNames, decl.name);
|
|
47
|
-
}
|
|
48
|
-
ctor(decl) {
|
|
49
|
-
for (let param of decl.parameters) {
|
|
50
|
-
let paramModifiers = getModifiers(param);
|
|
51
|
-
let isProperty = paramModifiers && (paramModifiers.some((x) => x.kind === ts.SyntaxKind.PublicKeyword) || paramModifiers.some((x) => x.kind === ts.SyntaxKind.ProtectedKeyword) || paramModifiers.some((x) => x.kind === ts.SyntaxKind.PrivateKeyword) || paramModifiers.some((x) => x.kind === ts.SyntaxKind.ReadonlyKeyword));
|
|
52
|
-
if (isProperty) {
|
|
53
|
-
if (ts.isIdentifier(param.name)) {
|
|
54
|
-
this.addItem(this.details.propertyNames, param.name);
|
|
55
|
-
} else {
|
|
56
|
-
throw new Error(`Unexpected binding name as property in constructor for class ${decl.name.getText()}! Please file a bug!`);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
__decorate([
|
|
63
|
-
Visit([ts.SyntaxKind.PropertyDeclaration, ts.SyntaxKind.GetAccessor, ts.SyntaxKind.SetAccessor]),
|
|
64
|
-
__metadata("design:type", Function),
|
|
65
|
-
__metadata("design:paramtypes", [Object]),
|
|
66
|
-
__metadata("design:returntype", void 0)
|
|
67
|
-
], ClassAnalyzer.prototype, "property", null);
|
|
68
|
-
__decorate([
|
|
69
|
-
Visit(ts.SyntaxKind.MethodDeclaration),
|
|
70
|
-
__metadata("design:type", Function),
|
|
71
|
-
__metadata("design:paramtypes", [Object]),
|
|
72
|
-
__metadata("design:returntype", void 0)
|
|
73
|
-
], ClassAnalyzer.prototype, "method", null);
|
|
74
|
-
__decorate([
|
|
75
|
-
Visit(ts.SyntaxKind.Constructor),
|
|
76
|
-
__metadata("design:type", Function),
|
|
77
|
-
__metadata("design:paramtypes", [Object]),
|
|
78
|
-
__metadata("design:returntype", void 0)
|
|
79
|
-
], ClassAnalyzer.prototype, "ctor", null);
|
|
80
|
-
export {
|
|
81
|
-
ClassAnalyzer
|
|
82
|
-
};
|
|
83
|
-
//# sourceMappingURL=class-analyzer.js.map
|
package/dist/vite/node_modules/typescript-rtti/dist.esm/transformer/common/import-analyzer.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { Visit } from "./visitor-base.js";
|
|
2
|
-
import ts from "typescript";
|
|
3
|
-
import { RttiVisitor } from "../rtti-visitor-base.js";
|
|
4
|
-
import { createRequire } from "node:module";
|
|
5
|
-
var __decorate = function(decorators, target, key, desc) {
|
|
6
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
7
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
8
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
9
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
10
|
-
};
|
|
11
|
-
var __metadata = function(k, v) {
|
|
12
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
13
|
-
};
|
|
14
|
-
const require$1 = createRequire(import.meta.url);
|
|
15
|
-
class ImportAnalyzer extends RttiVisitor {
|
|
16
|
-
static analyze(file, ctx) {
|
|
17
|
-
let analyzer = new ImportAnalyzer(ctx);
|
|
18
|
-
try {
|
|
19
|
-
analyzer.visitEachChild(file);
|
|
20
|
-
} catch (e) {
|
|
21
|
-
console.error(`RTTI: While analyzing imports for file '${file.fileName}': ${e.message}`);
|
|
22
|
-
throw e;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
import(decl) {
|
|
26
|
-
var _a, _b;
|
|
27
|
-
if (decl.importClause) {
|
|
28
|
-
let bindings = decl.importClause.namedBindings;
|
|
29
|
-
if (!bindings) {
|
|
30
|
-
let name = decl.importClause.name.text;
|
|
31
|
-
this.ctx.importMap.set(name, {
|
|
32
|
-
name,
|
|
33
|
-
localName: name,
|
|
34
|
-
refName: name,
|
|
35
|
-
modulePath: decl.moduleSpecifier.text,
|
|
36
|
-
isNamespace: false,
|
|
37
|
-
isDefault: true,
|
|
38
|
-
importDeclaration: decl
|
|
39
|
-
});
|
|
40
|
-
} else if (bindings) {
|
|
41
|
-
if (ts.isNamedImports(bindings)) {
|
|
42
|
-
for (let binding of bindings.elements) {
|
|
43
|
-
this.ctx.importMap.set(binding.name.text, {
|
|
44
|
-
name: binding.name.text,
|
|
45
|
-
symbol: this.checker.getSymbolAtLocation(binding.name),
|
|
46
|
-
localName: `${(_b = (_a = binding.propertyName) === null || _a === void 0 ? void 0 : _a.text) !== null && _b !== void 0 ? _b : binding.name.text}Φ`,
|
|
47
|
-
refName: binding.name.text,
|
|
48
|
-
modulePath: decl.moduleSpecifier.text,
|
|
49
|
-
isNamespace: false,
|
|
50
|
-
isDefault: false,
|
|
51
|
-
importDeclaration: decl
|
|
52
|
-
});
|
|
53
|
-
let nameAsInterface = `IΦ${binding.name.text}`;
|
|
54
|
-
this.ctx.importMap.set(nameAsInterface, {
|
|
55
|
-
name: nameAsInterface,
|
|
56
|
-
localName: nameAsInterface,
|
|
57
|
-
refName: nameAsInterface,
|
|
58
|
-
modulePath: decl.moduleSpecifier.text,
|
|
59
|
-
isNamespace: false,
|
|
60
|
-
isDefault: false,
|
|
61
|
-
importDeclaration: decl
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
} else if (ts.isNamespaceImport(bindings)) {
|
|
65
|
-
this.ctx.importMap.set(bindings.name.text, {
|
|
66
|
-
name: bindings.name.text,
|
|
67
|
-
localName: `${bindings.name.text}Φ`,
|
|
68
|
-
modulePath: decl.moduleSpecifier.text,
|
|
69
|
-
refName: bindings.name.text,
|
|
70
|
-
isNamespace: true,
|
|
71
|
-
isDefault: false,
|
|
72
|
-
importDeclaration: decl
|
|
73
|
-
});
|
|
74
|
-
bindings.name;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
__decorate([
|
|
81
|
-
Visit(ts.SyntaxKind.ImportDeclaration),
|
|
82
|
-
__metadata("design:type", Function),
|
|
83
|
-
__metadata("design:paramtypes", [Object]),
|
|
84
|
-
__metadata("design:returntype", void 0)
|
|
85
|
-
], ImportAnalyzer.prototype, "import", null);
|
|
86
|
-
export {
|
|
87
|
-
ImportAnalyzer
|
|
88
|
-
};
|
|
89
|
-
//# sourceMappingURL=import-analyzer.js.map
|