@idlizer/arktscgen 2.1.10-arktscgen-5 → 2.1.10-arktscgen-6

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.
Files changed (39) hide show
  1. package/build/libarkts-copy/generator/options.json5 +24 -47
  2. package/build/libarkts-copy/native/meson.build +25 -9
  3. package/build/libarkts-copy/native/meson_options.txt +9 -3
  4. package/build/libarkts-copy/native/mingw.cross +2 -0
  5. package/build/libarkts-copy/native/src/bridges.cc +20 -81
  6. package/build/libarkts-copy/native/src/common.cc +127 -49
  7. package/build/libarkts-copy/native/src/memoryTracker.cc +42 -35
  8. package/build/libarkts-copy/package.json +12 -10
  9. package/build/libarkts-copy/src/Es2pandaNativeModule.ts +10 -63
  10. package/build/libarkts-copy/src/arkts-api/AbstractVisitor.ts +9 -3
  11. package/build/libarkts-copy/src/arkts-api/ImportStorage.ts +2 -4
  12. package/build/libarkts-copy/src/arkts-api/ProgramProvider.ts +14 -5
  13. package/build/libarkts-copy/src/arkts-api/class-by-peer.ts +19 -1
  14. package/build/libarkts-copy/src/arkts-api/index.ts +0 -1
  15. package/build/libarkts-copy/src/arkts-api/node-cache.ts +12 -3
  16. package/build/libarkts-copy/src/arkts-api/node-utilities/ObjectExpression.ts +1 -1
  17. package/build/libarkts-copy/src/arkts-api/node-utilities/ScriptFunction.ts +4 -4
  18. package/build/libarkts-copy/src/arkts-api/peers/AstNode.ts +0 -16
  19. package/build/libarkts-copy/src/arkts-api/peers/Config.ts +1 -1
  20. package/build/libarkts-copy/src/arkts-api/peers/Context.ts +10 -9
  21. package/build/libarkts-copy/src/arkts-api/plugins.ts +110 -5
  22. package/build/libarkts-copy/src/arkts-api/static/global.ts +1 -1
  23. package/build/libarkts-copy/src/arkts-api/static/profiler.ts +1 -1
  24. package/build/libarkts-copy/src/arkts-api/utilities/performance.ts +2 -1
  25. package/build/libarkts-copy/src/arkts-api/utilities/private.ts +4 -9
  26. package/build/libarkts-copy/src/arkts-api/utilities/public.ts +41 -9
  27. package/build/libarkts-copy/src/arkts-api/visitor.ts +4 -25
  28. package/build/libarkts-copy/src/checkSdk.ts +1 -1
  29. package/build/libarkts-copy/src/index.ts +1 -1
  30. package/build/libarkts-copy/src/memo-node-cache.ts +143 -0
  31. package/build/libarkts-copy/src/plugin-utils.ts +19 -12
  32. package/build/libarkts-copy/src/reexport-for-generated.ts +2 -0
  33. package/build/libarkts-copy/src/tracer.ts +2 -2
  34. package/build/libarkts-copy/src/ts-api/factory/nodeFactory.ts +2 -2
  35. package/build/libarkts-copy/src/ts-api/utilities/private.ts +2 -2
  36. package/build/libarkts-copy/src/utils.ts +10 -14
  37. package/lib/index.js +5316 -10427
  38. package/package.json +9 -7
  39. package/build/libarkts-copy/src/arkts-api/peers/DiagnosticKind.ts +0 -23
@@ -41,7 +41,7 @@ export class Tracer {
41
41
  return;
42
42
  }
43
43
  const programPath = program.absoluteName;
44
- if (programPath == '') {
44
+ if (!programPath.length) {
45
45
  return;
46
46
  }
47
47
  const suggestedTracer = Tracer.Tracers.get(programPath);
@@ -123,7 +123,7 @@ export class Tracer {
123
123
  this.trace(`${`Event "${event}"`.padEnd(maxLength)}: ${eventCnt}`);
124
124
  this.eventsPerContext?.forEach((localizedEventsMap: Map<string, number>, context: string) => {
125
125
  localizedEventsMap.forEach((localizedEventCnt: number, localizedEvent: string) => {
126
- if (localizedEvent == event) {
126
+ if (localizedEvent === event) {
127
127
  this.trace(`${` in context [${context}]`.padEnd(maxLength)}: ${localizedEventCnt}`);
128
128
  }
129
129
  });
@@ -678,7 +678,7 @@ export function createNodeFactory() {
678
678
  return new CallExpression(
679
679
  arkts.factory.createCallExpression(
680
680
  expression.node,
681
- typeArguments !== undefined
681
+ !!typeArguments
682
682
  ? arkts.factory.createTypeParameterDeclaration(passNodeArray(typeArguments))
683
683
  : undefined,
684
684
  passNodeArray(argumentsArray)
@@ -703,7 +703,7 @@ export function createNodeFactory() {
703
703
  arkts.factory.updateCallExpression(
704
704
  node.node,
705
705
  expression.node,
706
- typeArguments !== undefined
706
+ !!typeArguments
707
707
  ? arkts.factory.createTypeParameterDeclaration(passNodeArray(typeArguments))
708
708
  : undefined,
709
709
  passNodeArray(argumentsArray)
@@ -28,8 +28,8 @@ import {
28
28
  Es2pandaVariableDeclarationKind,
29
29
  } from '../../arkts-api';
30
30
 
31
- export function emptyImplementation(): any {
32
- throwError('Not yet implemented');
31
+ export function emptyImplementation(): never {
32
+ return throwError('Not yet implemented');
33
33
  }
34
34
 
35
35
  type kindTypes =
@@ -22,7 +22,7 @@ export function withWarning<T>(value: T, message: string): T {
22
22
  return value;
23
23
  }
24
24
 
25
- export function isNumber(value: any): value is number {
25
+ export function isNumber(value: unknown): value is number {
26
26
  return typeof value === `number`;
27
27
  }
28
28
 
@@ -72,11 +72,11 @@ function replaceIllegalHashes(code: string): string {
72
72
  function replaceGensymWrappers(code: string): string {
73
73
  const indices = [...code.matchAll(/\({let/g)].map((it) => it.index);
74
74
  const replacements: string[][] = [];
75
- for (var i of indices) {
75
+ for (let i of indices) {
76
76
  if (!i) {
77
77
  continue;
78
78
  }
79
- var j = i + 1,
79
+ let j: number = i + 1,
80
80
  depth = 1;
81
81
  while (j < code.length) {
82
82
  if (code[j] == '(') {
@@ -91,7 +91,7 @@ function replaceGensymWrappers(code: string): string {
91
91
  j++;
92
92
  }
93
93
 
94
- if (j == code.length) {
94
+ if (j === code.length) {
95
95
  continue;
96
96
  }
97
97
 
@@ -104,7 +104,7 @@ function replaceGensymWrappers(code: string): string {
104
104
  /^\({let ([_%a-zA-Z0-9]+?) = (?!\({let)([\s\S]*?);\n([\s\S]*?)}\)$/g,
105
105
  (match, name: string, val: string, expr: string) => {
106
106
  let rightExpr = expr.slice(expr.lastIndexOf(name) + name.length, -1);
107
- if (rightExpr[0] != '.') {
107
+ if (rightExpr[0] !== '.') {
108
108
  rightExpr = `.${rightExpr}`;
109
109
  }
110
110
  return `(${val}?${rightExpr})`;
@@ -112,7 +112,7 @@ function replaceGensymWrappers(code: string): string {
112
112
  );
113
113
  replacements.push([base, fixed]);
114
114
  }
115
- for (var [b, f] of replacements) {
115
+ for (let [b, f] of replacements) {
116
116
  code = code.replace(b, f);
117
117
  }
118
118
  return code;
@@ -153,7 +153,7 @@ function addExports(code: string): string {
153
153
  ['export @memo_stable()', '@memo_stable() export'],
154
154
  ['export class OhosRouter', 'export default class OhosRouter'],
155
155
  ];
156
- for (var [f, t] of fix) {
156
+ for (let [f, t] of fix) {
157
157
  code = code.replaceAll(f, t);
158
158
  }
159
159
  return code.replaceAll('\nexport function main()', '\nfunction main()');
@@ -179,15 +179,15 @@ function fixEnums(code: string) {
179
179
  }
180
180
  enums.forEach((name) => {
181
181
  const regexp = new RegExp(`${name}\\.(\\w+)(.)`, `g`);
182
- code = code.replaceAll(regexp, (match, p1, p2) => {
183
- if (!p1.startsWith('_') && p2 == ':') {
182
+ code = code.replaceAll(regexp, (match: string, p1: string, p2: string) => {
183
+ if (!p1.startsWith('_') && p2 === ':') {
184
184
  // this colon is for switch case, not for type
185
185
  return `${name}.${p1}.valueOf()${p2}`;
186
186
  }
187
187
  return match;
188
188
  });
189
189
  const idents = [...code.matchAll(new RegExp(`(\\w+?)([\\W])(\\w+?): ${name}`, `g`))]
190
- .filter((it) => it[1] != 'readonly' && it[1] != '_get')
190
+ .filter((it) => it[1] !== 'readonly' && it[1] !== '_get')
191
191
  .map((it) => it[3]);
192
192
  // work manually with a couple of cases not to write one more bracket parser
193
193
  if (code.includes(`const eventKind = (deserializer.readInt32() as CallbackEventKind);`)) {
@@ -245,7 +245,3 @@ export function filterSource(text: string): string {
245
245
  // console.error(dumperUnwrappers.reduceRight((code, f) => f(code), text).split('\n').map((it, index) => `${`${index + 1}`.padStart(4)} |${it}`).join('\n'))
246
246
  return dumperUnwrappers.reduceRight((code, f) => f(code), text);
247
247
  }
248
-
249
- export function getEnumName(enumType: any, value: number): string | undefined {
250
- return enumType[value];
251
- }