@idlizer/arktscgen 2.1.10-arktscgen-6 → 2.1.10-arktscgen-9
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/build/libarkts-copy/generator/options.json5 +88 -97
- package/build/libarkts-copy/native/meson.build +60 -7
- package/build/libarkts-copy/native/mingw.cross +2 -5
- package/build/libarkts-copy/native/src/bridges.cpp +175 -0
- package/build/libarkts-copy/native/src/{common.cc → common.cpp} +176 -139
- package/build/libarkts-copy/native/src/common.h +22 -37
- package/build/libarkts-copy/native/src/{memoryTracker.cc → memoryTracker.cpp} +9 -3
- package/build/libarkts-copy/package.json +5 -9
- package/build/libarkts-copy/src/Es2pandaNativeModule.ts +0 -56
- package/build/libarkts-copy/src/arkts-api/ImportStorage.ts +8 -3
- package/build/libarkts-copy/src/arkts-api/factory/nodeFactory.ts +4 -0
- package/build/libarkts-copy/src/arkts-api/index.ts +0 -2
- package/build/libarkts-copy/src/arkts-api/node-utilities/OpaqueTypeNode.ts +1 -1
- package/build/libarkts-copy/src/arkts-api/node-utilities/OverloadDeclaration.ts +29 -0
- package/build/libarkts-copy/src/arkts-api/peers/Context.ts +25 -59
- package/build/libarkts-copy/src/arkts-api/peers/ExternalSource.ts +8 -13
- package/build/libarkts-copy/src/arkts-api/plugins.ts +5 -12
- package/build/libarkts-copy/src/arkts-api/static/global.ts +8 -4
- package/build/libarkts-copy/src/arkts-api/static/profiler.ts +4 -4
- package/build/libarkts-copy/src/arkts-api/utilities/extensions.ts +9 -12
- package/build/libarkts-copy/src/arkts-api/utilities/private.ts +10 -34
- package/build/libarkts-copy/src/arkts-api/utilities/public.ts +8 -5
- package/build/libarkts-copy/src/index.ts +0 -2
- package/build/libarkts-copy/src/plugin-utils.ts +60 -34
- package/build/libarkts-copy/src/reexport-for-generated.ts +3 -2
- package/build/libarkts-copy/tsconfig.json +0 -3
- package/lib/index.js +505 -216
- package/package.json +3 -4
- package/templates/Es2pandaNativeModule.ts +1 -0
- package/templates/{bridges.cc → bridges.cpp} +1 -1
- package/templates/peer.ts +1 -0
- package/build/libarkts-copy/native/src/bridges.cc +0 -443
- package/build/libarkts-copy/src/arkts-api/node-utilities/Program.ts +0 -45
- package/build/libarkts-copy/src/ts-api/factory/nodeFactory.ts +0 -1250
- package/build/libarkts-copy/src/ts-api/factory/nodeTests.ts +0 -125
- package/build/libarkts-copy/src/ts-api/index.ts +0 -27
- package/build/libarkts-copy/src/ts-api/static/enums.ts +0 -18
- package/build/libarkts-copy/src/ts-api/types.ts +0 -1075
- package/build/libarkts-copy/src/ts-api/utilities/private.ts +0 -292
- package/build/libarkts-copy/src/ts-api/utilities/public.ts +0 -55
- package/build/libarkts-copy/src/ts-api/visitor/visitor.ts +0 -139
|
@@ -28,13 +28,11 @@ export * from './arkts-api/AbstractVisitor';
|
|
|
28
28
|
export * from './arkts-api/plugins';
|
|
29
29
|
export * from './arkts-api/ImportStorage';
|
|
30
30
|
export * from './arkts-api/ProgramProvider';
|
|
31
|
-
export * from './arkts-api/node-utilities/Program';
|
|
32
31
|
export * from './arkts-api/node-utilities/ArkTsConfig';
|
|
33
32
|
|
|
34
33
|
export * from './arkts-api/peers/AstNode';
|
|
35
34
|
export * from './arkts-api/peers/Config';
|
|
36
35
|
export * from './arkts-api/peers/Context';
|
|
37
|
-
export { GlobalContext } from './arkts-api/peers/Context';
|
|
38
36
|
export * from './arkts-api/peers/ExternalSource';
|
|
39
37
|
export * from './arkts-api/peers/ImportPathManager';
|
|
40
38
|
export * from './arkts-api/peers/Options';
|
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
* limitations under the License.
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
+
import * as fs from "node:fs";
|
|
17
|
+
import * as path from "node:path";
|
|
16
18
|
import {
|
|
17
19
|
Es2pandaContextState,
|
|
18
20
|
PluginContext,
|
|
@@ -22,49 +24,25 @@ import {
|
|
|
22
24
|
Program,
|
|
23
25
|
ProgramProvider,
|
|
24
26
|
CompilationOptions,
|
|
25
|
-
|
|
27
|
+
PluginContextImpl,
|
|
28
|
+
Es2pandaCompilationMode,
|
|
26
29
|
} from './arkts-api';
|
|
27
30
|
import { Tracer } from './tracer';
|
|
31
|
+
import { global } from "./arkts-api/static/global";
|
|
28
32
|
|
|
29
33
|
export interface RunTransformerHooks {
|
|
30
34
|
onProgramTransformStart?(options: CompilationOptions, program: Program): void;
|
|
31
35
|
onProgramTransformEnd?(options: CompilationOptions, program: Program): void;
|
|
32
36
|
}
|
|
33
37
|
|
|
34
|
-
class
|
|
35
|
-
|
|
36
|
-
constructor() {}
|
|
37
|
-
find(program: Program): boolean {
|
|
38
|
-
return this.processedPrograms.has(program.absoluteName);
|
|
39
|
-
}
|
|
40
|
-
update(program: Program) {
|
|
41
|
-
this.processedPrograms.add(program.absoluteName);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export class DumpingHooks implements RunTransformerHooks {
|
|
46
|
-
constructor(
|
|
47
|
-
private state: Es2pandaContextState,
|
|
48
|
-
private pluginName: string,
|
|
49
|
-
private dumpAst: boolean = false
|
|
50
|
-
) {
|
|
51
|
-
if (process.env.KOALA_DUMP_PLUGIN_AST) {
|
|
52
|
-
this.dumpAst = true;
|
|
53
|
-
}
|
|
38
|
+
export class ProfilerHooks implements RunTransformerHooks {
|
|
39
|
+
constructor() {
|
|
54
40
|
}
|
|
55
41
|
onProgramTransformStart(options: CompilationOptions, program: Program) {
|
|
56
|
-
if (this.dumpAst && !program.absoluteName.includes("absolute-sdk-patched")) {
|
|
57
|
-
console.log(`BEFORE ${this.pluginName}:`);
|
|
58
|
-
dumpProgramSrcFormatted(program, true);
|
|
59
|
-
}
|
|
60
42
|
if (!options.isProgramForCodegeneration) arktsGlobal.profiler.transformDepStarted();
|
|
61
43
|
}
|
|
62
44
|
onProgramTransformEnd(options: CompilationOptions, program: Program) {
|
|
63
|
-
if (!options.isProgramForCodegeneration) arktsGlobal.profiler.transformDepEnded(
|
|
64
|
-
if (this.dumpAst && !program.absoluteName.includes("absolute-sdk-patched")) {
|
|
65
|
-
console.log(`AFTER ${this.pluginName}:`);
|
|
66
|
-
dumpProgramSrcFormatted(program, true);
|
|
67
|
-
}
|
|
45
|
+
if (!options.isProgramForCodegeneration) arktsGlobal.profiler.transformDepEnded();
|
|
68
46
|
}
|
|
69
47
|
}
|
|
70
48
|
|
|
@@ -73,8 +51,8 @@ export function runTransformerOnProgram(
|
|
|
73
51
|
options: CompilationOptions,
|
|
74
52
|
transform: ProgramTransformer | undefined,
|
|
75
53
|
pluginContext: PluginContext,
|
|
76
|
-
hooks: RunTransformerHooks
|
|
77
|
-
stableDeps: boolean
|
|
54
|
+
hooks: RunTransformerHooks,
|
|
55
|
+
stableDeps: boolean,
|
|
78
56
|
) {
|
|
79
57
|
arktsGlobal.filePath = program.absoluteName;
|
|
80
58
|
|
|
@@ -108,9 +86,10 @@ export function runTransformer(
|
|
|
108
86
|
state: Es2pandaContextState,
|
|
109
87
|
transform: ProgramTransformer | undefined,
|
|
110
88
|
pluginContext: PluginContext,
|
|
111
|
-
hooks: RunTransformerHooks = {},
|
|
112
89
|
stableDeps: boolean = false,
|
|
113
90
|
) {
|
|
91
|
+
const hooks = new ProfilerHooks()
|
|
92
|
+
|
|
114
93
|
// Program provider used to provide programs to transformer dynamically relative to inserted imports
|
|
115
94
|
const provider = new ProgramProvider(prog, stableDeps);
|
|
116
95
|
|
|
@@ -136,8 +115,55 @@ export function runTransformer(
|
|
|
136
115
|
}
|
|
137
116
|
|
|
138
117
|
function isProgramForCodegeneration(program: Program, isMainProgram: boolean): boolean {
|
|
139
|
-
if (
|
|
118
|
+
if (arktsGlobal.configObj?.compilationMode != Es2pandaCompilationMode.COMPILATION_MODE_GEN_ABC_FOR_EXTERNAL_SOURCE) {
|
|
140
119
|
return isMainProgram;
|
|
141
120
|
}
|
|
142
121
|
return program.isGenAbcForExternal;
|
|
143
122
|
}
|
|
123
|
+
|
|
124
|
+
const isDebugDump: boolean = false;
|
|
125
|
+
|
|
126
|
+
function checkDebugDump() {
|
|
127
|
+
return isDebugDump || process.env.KOALA_DUMP_PLUGIN_AST == "1";
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export function debugDump(
|
|
131
|
+
dumpDir: string | undefined,
|
|
132
|
+
state: Es2pandaContextState,
|
|
133
|
+
pluginName: string,
|
|
134
|
+
isAfter: boolean,
|
|
135
|
+
program: Program,
|
|
136
|
+
) {
|
|
137
|
+
if (!checkDebugDump()) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
if (!dumpDir) {
|
|
141
|
+
const outDir = global.arktsconfig?.outDir
|
|
142
|
+
if (outDir) {
|
|
143
|
+
dumpDir = path.join(outDir, "../dist/cache")
|
|
144
|
+
} else {
|
|
145
|
+
dumpDir = "dist/cache"
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
const baseDir = path.join(dumpDir,
|
|
149
|
+
`${state}_${isAfter ? "" : "ORI"}_${pluginName}`
|
|
150
|
+
);
|
|
151
|
+
runTransformer(
|
|
152
|
+
program,
|
|
153
|
+
state,
|
|
154
|
+
(program: Program) => {
|
|
155
|
+
if (program.absoluteName == "") {
|
|
156
|
+
return
|
|
157
|
+
}
|
|
158
|
+
const dumpFilePath = path.join(baseDir, path.sep + program.absoluteName)
|
|
159
|
+
fs.mkdirSync(path.dirname(dumpFilePath), { recursive: true })
|
|
160
|
+
fs.writeFileSync(
|
|
161
|
+
dumpFilePath,
|
|
162
|
+
program.ast.dumpSrc(),
|
|
163
|
+
'utf-8',
|
|
164
|
+
)
|
|
165
|
+
},
|
|
166
|
+
new PluginContextImpl(),
|
|
167
|
+
true,
|
|
168
|
+
)
|
|
169
|
+
}
|
|
@@ -13,11 +13,12 @@
|
|
|
13
13
|
* limitations under the License.
|
|
14
14
|
*/
|
|
15
15
|
export { KNativePointer } from '@koalaui/interop';
|
|
16
|
+
export { ArktsObject, isSameNativeObject } from './arkts-api/peers/ArktsObject';
|
|
16
17
|
export { AstNode } from './arkts-api/peers/AstNode';
|
|
17
18
|
export { Config } from './arkts-api/peers/Config';
|
|
18
19
|
export { Context, GlobalContext } from './arkts-api/peers/Context';
|
|
19
|
-
export { ArktsObject, isSameNativeObject } from './arkts-api/peers/ArktsObject';
|
|
20
20
|
export { NodeCache } from './arkts-api/node-cache';
|
|
21
|
+
export { ExternalSource } from './arkts-api/peers/ExternalSource';
|
|
21
22
|
export {
|
|
22
23
|
passNode,
|
|
23
24
|
unpackNonNullableNode,
|
|
@@ -26,8 +27,8 @@ export {
|
|
|
26
27
|
passStringArray,
|
|
27
28
|
unpackNode,
|
|
28
29
|
unpackString,
|
|
29
|
-
assertValidPeer,
|
|
30
30
|
updateNodeByNode,
|
|
31
|
+
unpackNativeObjectArray,
|
|
31
32
|
} from './arkts-api/utilities/private';
|
|
32
33
|
export { nodeByType } from './arkts-api/class-by-peer';
|
|
33
34
|
export { global } from './arkts-api/static/global';
|