arkanalyzer 1.0.81 → 1.0.83

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 (71) hide show
  1. package/lib/callgraph/algorithm/AbstractAnalysis.d.ts +1 -0
  2. package/lib/callgraph/algorithm/AbstractAnalysis.d.ts.map +1 -1
  3. package/lib/callgraph/algorithm/AbstractAnalysis.js +8 -0
  4. package/lib/callgraph/algorithm/ClassHierarchyAnalysis.d.ts.map +1 -1
  5. package/lib/callgraph/algorithm/ClassHierarchyAnalysis.js +20 -16
  6. package/lib/callgraph/model/CallGraph.d.ts.map +1 -1
  7. package/lib/callgraph/model/CallGraph.js +5 -2
  8. package/lib/core/common/ArkValueTransformer.d.ts +1 -0
  9. package/lib/core/common/ArkValueTransformer.d.ts.map +1 -1
  10. package/lib/core/common/ArkValueTransformer.js +32 -4
  11. package/lib/core/common/Const.d.ts +12 -0
  12. package/lib/core/common/Const.d.ts.map +1 -1
  13. package/lib/core/common/Const.js +15 -2
  14. package/lib/core/common/DummyMainCreater.d.ts +32 -2
  15. package/lib/core/common/DummyMainCreater.d.ts.map +1 -1
  16. package/lib/core/common/DummyMainCreater.js +235 -97
  17. package/lib/core/common/EtsConst.d.ts +1 -0
  18. package/lib/core/common/EtsConst.d.ts.map +1 -1
  19. package/lib/core/common/EtsConst.js +3 -2
  20. package/lib/core/common/IRInference.d.ts +0 -7
  21. package/lib/core/common/IRInference.d.ts.map +1 -1
  22. package/lib/core/common/IRInference.js +11 -27
  23. package/lib/core/common/ModelUtils.d.ts.map +1 -1
  24. package/lib/core/common/ModelUtils.js +8 -15
  25. package/lib/core/graph/BasicBlock.d.ts +1 -1
  26. package/lib/core/graph/BasicBlock.d.ts.map +1 -1
  27. package/lib/core/graph/BasicBlock.js +4 -1
  28. package/lib/core/graph/builder/CfgBuilder.d.ts +1 -0
  29. package/lib/core/graph/builder/CfgBuilder.d.ts.map +1 -1
  30. package/lib/core/graph/builder/CfgBuilder.js +5 -1
  31. package/lib/core/graph/builder/ConditionBuilder.d.ts +1 -0
  32. package/lib/core/graph/builder/ConditionBuilder.d.ts.map +1 -1
  33. package/lib/core/graph/builder/ConditionBuilder.js +40 -24
  34. package/lib/core/inference/ModelInference.d.ts.map +1 -1
  35. package/lib/core/inference/ModelInference.js +31 -5
  36. package/lib/core/inference/ValueInference.d.ts +1 -36
  37. package/lib/core/inference/ValueInference.d.ts.map +1 -1
  38. package/lib/core/inference/ValueInference.js +1 -174
  39. package/lib/core/inference/abc/AbcInference.d.ts +7 -0
  40. package/lib/core/inference/abc/AbcInference.d.ts.map +1 -1
  41. package/lib/core/inference/abc/AbcInference.js +28 -2
  42. package/lib/core/inference/arkts/ArkTsInference.d.ts +43 -1
  43. package/lib/core/inference/arkts/ArkTsInference.d.ts.map +1 -1
  44. package/lib/core/inference/arkts/ArkTsInference.js +189 -2
  45. package/lib/core/model/builder/ArkClassBuilder.d.ts.map +1 -1
  46. package/lib/core/model/builder/ArkClassBuilder.js +2 -5
  47. package/lib/core/model/builder/ArkMethodBuilder.d.ts.map +1 -1
  48. package/lib/core/model/builder/ArkMethodBuilder.js +6 -5
  49. package/lib/index.d.ts +3 -0
  50. package/lib/index.d.ts.map +1 -1
  51. package/lib/index.js +7 -1
  52. package/lib/save/base/BasePrinter.d.ts.map +1 -1
  53. package/lib/save/base/BasePrinter.js +6 -5
  54. package/lib/save/source/SourceStmt.d.ts +2 -0
  55. package/lib/save/source/SourceStmt.d.ts.map +1 -1
  56. package/lib/save/source/SourceStmt.js +51 -8
  57. package/lib/utils/IntMap.d.ts +48 -0
  58. package/lib/utils/IntMap.d.ts.map +1 -0
  59. package/lib/utils/IntMap.js +134 -0
  60. package/lib/utils/IntWorkList.d.ts +35 -0
  61. package/lib/utils/IntWorkList.d.ts.map +1 -0
  62. package/lib/utils/IntWorkList.js +97 -0
  63. package/lib/utils/PackedSparseMap.d.ts +26 -0
  64. package/lib/utils/PackedSparseMap.d.ts.map +1 -0
  65. package/lib/utils/PackedSparseMap.js +140 -0
  66. package/lib/utils/entryMethodUtils.d.ts.map +1 -1
  67. package/lib/utils/entryMethodUtils.js +20 -11
  68. package/lib/utils/logger.d.ts +1 -0
  69. package/lib/utils/logger.d.ts.map +1 -1
  70. package/lib/utils/logger.js +1 -0
  71. package/package.json +2 -2
@@ -537,21 +537,64 @@ class SourceWhileStmt extends SourceStmt {
537
537
  code += `${this.valueToString(expr.getOp2())}) {`;
538
538
  this.setText(code);
539
539
  }
540
+ handlePrefixIncrementAndDecrement(stmt, value) {
541
+ const stmtLeftOp = stmt.getLeftOp();
542
+ if (stmtLeftOp.getName() === value.getName()) {
543
+ if (PrinterUtils_1.PrinterUtils.isDeIncrementStmt(stmt, Expr_1.NormalBinaryOperator.Addition)) {
544
+ this.context.setSkipStmt(stmt);
545
+ return `++${value.getName()}`;
546
+ }
547
+ else if (PrinterUtils_1.PrinterUtils.isDeIncrementStmt(stmt, Expr_1.NormalBinaryOperator.Subtraction)) {
548
+ this.context.setSkipStmt(stmt);
549
+ return `--${value.getName()}`;
550
+ }
551
+ }
552
+ return null;
553
+ }
554
+ handlePostfixIncrementAndDecrement(index, value, stmts) {
555
+ const stmt = stmts[index];
556
+ const stmtLeftOp = stmt.getLeftOp();
557
+ if (index <= 0 ||
558
+ index >= stmts.length - 1 ||
559
+ !(stmts[index - 1] instanceof Stmt_1.ArkAssignStmt) ||
560
+ !(stmts[stmts.length - 1] instanceof Stmt_1.ArkIfStmt)) {
561
+ return null;
562
+ }
563
+ const preStmt = stmts[index - 1];
564
+ const succesStmt = stmts[stmts.length - 1];
565
+ if (preStmt.getLeftOp() === succesStmt.getConditionExpr().getOp1() &&
566
+ preStmt.getRightOp() === stmtLeftOp &&
567
+ preStmt.getLeftOp() === value) {
568
+ if (PrinterUtils_1.PrinterUtils.isDeIncrementStmt(stmt, Expr_1.NormalBinaryOperator.Subtraction)) {
569
+ this.context.setSkipStmt(stmts[index - 1]);
570
+ this.context.setSkipStmt(stmt);
571
+ return `${stmtLeftOp.getName()}--`;
572
+ }
573
+ else if (PrinterUtils_1.PrinterUtils.isDeIncrementStmt(stmt, Expr_1.NormalBinaryOperator.Addition)) {
574
+ this.context.setSkipStmt(stmts[index - 1]);
575
+ this.context.setSkipStmt(stmt);
576
+ return `${stmtLeftOp.getName()}++`;
577
+ }
578
+ }
579
+ return null;
580
+ }
540
581
  valueToString(value) {
541
582
  if (!(value instanceof Local_1.Local)) {
542
583
  return this.transformer.valueToString(value);
543
584
  }
544
- for (const stmt of this.block.getStmts()) {
545
- if (!(stmt instanceof Stmt_1.ArkAssignStmt)) {
585
+ const stmts = this.block.getStmts();
586
+ for (let i = 0; i < stmts.length; ++i) {
587
+ if (!(stmts[i] instanceof Stmt_1.ArkAssignStmt)) {
546
588
  continue;
547
589
  }
548
- if (PrinterUtils_1.PrinterUtils.isDeIncrementStmt(stmt, Expr_1.NormalBinaryOperator.Addition) && stmt.getLeftOp().getName() === value.getName()) {
549
- this.context.setSkipStmt(stmt);
550
- return `${value.getName()}++`;
590
+ const stmt = stmts[i];
591
+ const prefixStr = this.handlePrefixIncrementAndDecrement(stmt, value);
592
+ if (prefixStr) {
593
+ return prefixStr;
551
594
  }
552
- if (PrinterUtils_1.PrinterUtils.isDeIncrementStmt(stmt, Expr_1.NormalBinaryOperator.Subtraction) && stmt.getLeftOp().getName() === value.getName()) {
553
- this.context.setSkipStmt(stmt);
554
- return `${value.getName()}--`;
595
+ const postfixStr = this.handlePostfixIncrementAndDecrement(i, value, stmts);
596
+ if (postfixStr) {
597
+ return postfixStr;
555
598
  }
556
599
  }
557
600
  return this.transformer.valueToString(value);
@@ -0,0 +1,48 @@
1
+ /**
2
+ * A memory-efficient Map-like structure where keys are integers and values are lists of integers.
3
+ * Uses a static linked list approach based on TypedArrays (SoA) to avoid JS object overhead.
4
+ *
5
+ * Memory per entry: 8 bytes (value + next pointer).
6
+ * Memory per key: 4 bytes (head pointer).
7
+ */
8
+ export declare class IntMap {
9
+ private heads;
10
+ private values;
11
+ private nexts;
12
+ private count;
13
+ private capacity;
14
+ private keyRange;
15
+ /**
16
+ * @param keyRange - The maximum value of keys (nodeCapacity).
17
+ * @param initialCapacity - The initial total number of values across all keys.
18
+ */
19
+ constructor(keyRange: number, initialCapacity?: number);
20
+ /**
21
+ * Add a value to the list associated with the key.
22
+ */
23
+ add(key: number, value: number): void;
24
+ /**
25
+ * Check if the list for a key contains a value.
26
+ */
27
+ contains(key: number, value: number): boolean;
28
+ /**
29
+ * Add a value only if it doesn't already exist in the key's list.
30
+ */
31
+ addUnique(key: number, value: number): boolean;
32
+ /**
33
+ * Get an iterator for the values associated with a key.
34
+ * Efficient for loops: for (const v of map.getValues(key)) { ... }
35
+ */
36
+ getValues(key: number): IterableIterator<number>;
37
+ /**
38
+ * Get all values as an array (less efficient due to allocation).
39
+ */
40
+ getAsArray(key: number): number[];
41
+ /**
42
+ * Check if a key has any values.
43
+ */
44
+ has(key: number): boolean;
45
+ private resizeHeads;
46
+ private resizeCapacity;
47
+ }
48
+ //# sourceMappingURL=IntMap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IntMap.d.ts","sourceRoot":"","sources":["../../src/utils/IntMap.ts"],"names":[],"mappings":"AAeA;;;;;;GAMG;AACH,qBAAa,MAAM;IACf,OAAO,CAAC,KAAK,CAAa;IAC1B,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,KAAK,CAAa;IAC1B,OAAO,CAAC,KAAK,CAAa;IAC1B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,QAAQ,CAAS;IAEzB;;;OAGG;gBACS,QAAQ,EAAE,MAAM,EAAE,eAAe,GAAE,MAAa;IAQ5D;;OAEG;IACI,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAe5C;;OAEG;IACI,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO;IAcpD;;OAEG;IACI,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO;IAQrD;;;OAGG;IACK,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAAC,MAAM,CAAC;IAWxD;;OAEG;IACI,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE;IAaxC;;OAEG;IACI,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAOhC,OAAO,CAAC,WAAW;IAOnB,OAAO,CAAC,cAAc;CAUzB"}
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2026 Huawei Device Co., Ltd.
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.IntMap = void 0;
18
+ /**
19
+ * A memory-efficient Map-like structure where keys are integers and values are lists of integers.
20
+ * Uses a static linked list approach based on TypedArrays (SoA) to avoid JS object overhead.
21
+ *
22
+ * Memory per entry: 8 bytes (value + next pointer).
23
+ * Memory per key: 4 bytes (head pointer).
24
+ */
25
+ class IntMap {
26
+ /**
27
+ * @param keyRange - The maximum value of keys (nodeCapacity).
28
+ * @param initialCapacity - The initial total number of values across all keys.
29
+ */
30
+ constructor(keyRange, initialCapacity = 1024) {
31
+ this.count = 0;
32
+ this.keyRange = keyRange;
33
+ this.capacity = initialCapacity;
34
+ this.heads = new Int32Array(keyRange).fill(-1);
35
+ this.values = new Int32Array(initialCapacity);
36
+ this.nexts = new Int32Array(initialCapacity);
37
+ }
38
+ /**
39
+ * Add a value to the list associated with the key.
40
+ */
41
+ add(key, value) {
42
+ if (key >= this.keyRange) {
43
+ this.resizeHeads(key + 1);
44
+ }
45
+ if (this.count >= this.capacity) {
46
+ this.resizeCapacity();
47
+ }
48
+ const idx = this.count++;
49
+ this.values[idx] = value;
50
+ this.nexts[idx] = this.heads[key];
51
+ this.heads[key] = idx;
52
+ }
53
+ /**
54
+ * Check if the list for a key contains a value.
55
+ */
56
+ contains(key, value) {
57
+ if (key >= this.keyRange) {
58
+ return false;
59
+ }
60
+ let curr = this.heads[key];
61
+ while (curr !== -1) {
62
+ if (this.values[curr] === value) {
63
+ return true;
64
+ }
65
+ curr = this.nexts[curr];
66
+ }
67
+ return false;
68
+ }
69
+ /**
70
+ * Add a value only if it doesn't already exist in the key's list.
71
+ */
72
+ addUnique(key, value) {
73
+ if (this.contains(key, value)) {
74
+ return false;
75
+ }
76
+ this.add(key, value);
77
+ return true;
78
+ }
79
+ /**
80
+ * Get an iterator for the values associated with a key.
81
+ * Efficient for loops: for (const v of map.getValues(key)) { ... }
82
+ */
83
+ *getValues(key) {
84
+ if (key >= this.keyRange) {
85
+ return;
86
+ }
87
+ let curr = this.heads[key];
88
+ while (curr !== -1) {
89
+ yield this.values[curr];
90
+ curr = this.nexts[curr];
91
+ }
92
+ }
93
+ /**
94
+ * Get all values as an array (less efficient due to allocation).
95
+ */
96
+ getAsArray(key) {
97
+ const result = [];
98
+ if (key >= this.keyRange) {
99
+ return result;
100
+ }
101
+ let curr = this.heads[key];
102
+ while (curr !== -1) {
103
+ result.push(this.values[curr]);
104
+ curr = this.nexts[curr];
105
+ }
106
+ return result;
107
+ }
108
+ /**
109
+ * Check if a key has any values.
110
+ */
111
+ has(key) {
112
+ if (key >= this.keyRange) {
113
+ return false;
114
+ }
115
+ return this.heads[key] !== -1;
116
+ }
117
+ resizeHeads(newRange) {
118
+ const newHeads = new Int32Array(newRange * 2).fill(-1);
119
+ newHeads.set(this.heads);
120
+ this.heads = newHeads;
121
+ this.keyRange = newHeads.length;
122
+ }
123
+ resizeCapacity() {
124
+ const newCapacity = this.capacity * 2;
125
+ const newValues = new Int32Array(newCapacity);
126
+ const newNexts = new Int32Array(newCapacity);
127
+ newValues.set(this.values);
128
+ newNexts.set(this.nexts);
129
+ this.values = newValues;
130
+ this.nexts = newNexts;
131
+ this.capacity = newCapacity;
132
+ }
133
+ }
134
+ exports.IntMap = IntMap;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * High-performance circular buffer worklist for integer IDs.
3
+ * Uses Int32Array to avoid object allocation and GC overhead.
4
+ */
5
+ export declare class IntWorkList {
6
+ private buffer;
7
+ private head;
8
+ private tail;
9
+ private count;
10
+ private capacity;
11
+ private mask;
12
+ constructor(initialCapacity?: number);
13
+ /**
14
+ * Add a value to the end of the worklist.
15
+ */
16
+ push(value: number): void;
17
+ /**
18
+ * Remove and return the value from the front of the worklist.
19
+ * Returns undefined if empty.
20
+ */
21
+ pop(): number | undefined;
22
+ /**
23
+ * Check if the worklist is empty.
24
+ */
25
+ isEmpty(): boolean;
26
+ /**
27
+ * Get the number of elements in the worklist.
28
+ */
29
+ size(): number;
30
+ /**
31
+ * Double the capacity of the buffer.
32
+ */
33
+ private resize;
34
+ }
35
+ //# sourceMappingURL=IntWorkList.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IntWorkList.d.ts","sourceRoot":"","sources":["../../src/utils/IntWorkList.ts"],"names":[],"mappings":"AAeA;;;GAGG;AACH,qBAAa,WAAW;IACpB,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,IAAI,CAAa;IACzB,OAAO,CAAC,IAAI,CAAa;IACzB,OAAO,CAAC,KAAK,CAAa;IAC1B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,IAAI,CAAS;gBAGT,eAAe,GAAE,MAAa;IAU1C;;OAEG;IACI,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAShC;;;OAGG;IACI,GAAG,IAAI,MAAM,GAAG,SAAS;IAUhC;;OAEG;IACI,OAAO,IAAI,OAAO;IAIzB;;OAEG;IACI,IAAI,IAAI,MAAM;IAIrB;;OAEG;IACH,OAAO,CAAC,MAAM;CAsBjB"}
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2026 Huawei Device Co., Ltd.
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.IntWorkList = void 0;
18
+ /**
19
+ * High-performance circular buffer worklist for integer IDs.
20
+ * Uses Int32Array to avoid object allocation and GC overhead.
21
+ */
22
+ class IntWorkList {
23
+ // Default start with 1K capacity
24
+ constructor(initialCapacity = 1024) {
25
+ this.head = 0;
26
+ this.tail = 0;
27
+ this.count = 0;
28
+ // Ensure power of 2 capacity for efficient masking
29
+ this.capacity = 1;
30
+ while (this.capacity < initialCapacity) {
31
+ this.capacity <<= 1;
32
+ }
33
+ this.mask = this.capacity - 1;
34
+ this.buffer = new Int32Array(this.capacity);
35
+ }
36
+ /**
37
+ * Add a value to the end of the worklist.
38
+ */
39
+ push(value) {
40
+ if (this.count === this.capacity) {
41
+ this.resize();
42
+ }
43
+ this.buffer[this.tail] = value;
44
+ this.tail = (this.tail + 1) & this.mask;
45
+ this.count++;
46
+ }
47
+ /**
48
+ * Remove and return the value from the front of the worklist.
49
+ * Returns undefined if empty.
50
+ */
51
+ pop() {
52
+ if (this.count === 0) {
53
+ return undefined;
54
+ }
55
+ const value = this.buffer[this.head];
56
+ this.head = (this.head + 1) & this.mask;
57
+ this.count--;
58
+ return value;
59
+ }
60
+ /**
61
+ * Check if the worklist is empty.
62
+ */
63
+ isEmpty() {
64
+ return this.count === 0;
65
+ }
66
+ /**
67
+ * Get the number of elements in the worklist.
68
+ */
69
+ size() {
70
+ return this.count;
71
+ }
72
+ /**
73
+ * Double the capacity of the buffer.
74
+ */
75
+ resize() {
76
+ const oldCapacity = this.capacity;
77
+ const newCapacity = oldCapacity << 1;
78
+ const newBuffer = new Int32Array(newCapacity);
79
+ // Copy data to the beginning of the new buffer to linearize it
80
+ if (this.count > 0) {
81
+ if (this.head < this.tail) {
82
+ newBuffer.set(this.buffer.subarray(this.head, this.tail), 0);
83
+ }
84
+ else {
85
+ const firstPartLen = oldCapacity - this.head;
86
+ newBuffer.set(this.buffer.subarray(this.head, oldCapacity), 0);
87
+ newBuffer.set(this.buffer.subarray(0, this.tail), firstPartLen);
88
+ }
89
+ }
90
+ this.buffer = newBuffer;
91
+ this.capacity = newCapacity;
92
+ this.mask = newCapacity - 1;
93
+ this.head = 0;
94
+ this.tail = this.count;
95
+ }
96
+ }
97
+ exports.IntWorkList = IntWorkList;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * PackedSparseMap - A memory-efficient sparse index with packed storage.
3
+ *
4
+ * Implements a two-level indexing structure:
5
+ * - First level: Owner-based segmentation (sparse)
6
+ * - Second level: Sorted key-value pairs within each owner (packed)
7
+ *
8
+ */
9
+ export declare class PackedSparseMap {
10
+ private offsets;
11
+ private lengths;
12
+ private capacities;
13
+ private keys;
14
+ private values;
15
+ private poolSize;
16
+ private poolCapacity;
17
+ constructor(initialOwnerCapacity: number, initialPoolCapacity: number);
18
+ getOrInsert(owner: number, key: number, createValue: () => number): number;
19
+ private binarySearch;
20
+ private binarySearchInsertPosition;
21
+ private ensureOwnerCapacity;
22
+ private ensureOwnerListCapacity;
23
+ private ensurePoolCapacity;
24
+ private resizeOwners;
25
+ }
26
+ //# sourceMappingURL=PackedSparseMap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PackedSparseMap.d.ts","sourceRoot":"","sources":["../../src/utils/PackedSparseMap.ts"],"names":[],"mappings":"AAeA;;;;;;;GAOG;AACH,qBAAa,eAAe;IACxB,OAAO,CAAC,OAAO,CAAa;IAC5B,OAAO,CAAC,OAAO,CAAa;IAC5B,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,IAAI,CAAa;IACzB,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,QAAQ,CAAa;IAC7B,OAAO,CAAC,YAAY,CAAS;gBAEjB,oBAAoB,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM;IAU9D,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,MAAM,GAAG,MAAM;IA4BjF,OAAO,CAAC,YAAY;IAoBpB,OAAO,CAAC,0BAA0B;IAIlC,OAAO,CAAC,mBAAmB;IAc3B,OAAO,CAAC,uBAAuB;IAuB/B,OAAO,CAAC,kBAAkB;IAoB1B,OAAO,CAAC,YAAY;CAWvB"}
@@ -0,0 +1,140 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2026 Huawei Device Co., Ltd.
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.PackedSparseMap = void 0;
18
+ /**
19
+ * PackedSparseMap - A memory-efficient sparse index with packed storage.
20
+ *
21
+ * Implements a two-level indexing structure:
22
+ * - First level: Owner-based segmentation (sparse)
23
+ * - Second level: Sorted key-value pairs within each owner (packed)
24
+ *
25
+ */
26
+ class PackedSparseMap {
27
+ constructor(initialOwnerCapacity, initialPoolCapacity) {
28
+ this.poolSize = 0;
29
+ const ownerSize = Math.max(1, initialOwnerCapacity);
30
+ this.offsets = new Int32Array(ownerSize).fill(0);
31
+ this.lengths = new Int32Array(ownerSize).fill(0);
32
+ this.capacities = new Int32Array(ownerSize).fill(0);
33
+ this.poolCapacity = Math.max(1024, initialPoolCapacity);
34
+ this.keys = new Int32Array(this.poolCapacity);
35
+ this.values = new Int32Array(this.poolCapacity);
36
+ }
37
+ getOrInsert(owner, key, createValue) {
38
+ this.ensureOwnerCapacity(owner);
39
+ const offset = this.offsets[owner];
40
+ const length = this.lengths[owner];
41
+ const searchResult = this.binarySearch(offset, length, key);
42
+ if (searchResult.found) {
43
+ return this.values[offset + searchResult.index];
44
+ }
45
+ this.ensureOwnerListCapacity(owner, length + 1);
46
+ const updatedOffset = this.offsets[owner];
47
+ const updatedLength = this.lengths[owner];
48
+ const insertPos = this.binarySearchInsertPosition(updatedOffset, updatedLength, key);
49
+ for (let i = updatedLength; i > insertPos; i--) {
50
+ this.keys[updatedOffset + i] = this.keys[updatedOffset + i - 1];
51
+ this.values[updatedOffset + i] = this.values[updatedOffset + i - 1];
52
+ }
53
+ const value = createValue();
54
+ this.keys[updatedOffset + insertPos] = key;
55
+ this.values[updatedOffset + insertPos] = value;
56
+ this.lengths[owner] = updatedLength + 1;
57
+ return value;
58
+ }
59
+ binarySearch(offset, length, key) {
60
+ let low = 0;
61
+ let high = length - 1;
62
+ while (low <= high) {
63
+ const mid = (low + high) >>> 1;
64
+ const current = this.keys[offset + mid];
65
+ if (current === key) {
66
+ return { found: true, index: mid };
67
+ }
68
+ if (current < key) {
69
+ low = mid + 1;
70
+ }
71
+ else {
72
+ high = mid - 1;
73
+ }
74
+ }
75
+ return { found: false, index: low };
76
+ }
77
+ binarySearchInsertPosition(offset, length, key) {
78
+ return this.binarySearch(offset, length, key).index;
79
+ }
80
+ ensureOwnerCapacity(owner) {
81
+ if (owner < this.offsets.length) {
82
+ return;
83
+ }
84
+ let newSize = this.offsets.length;
85
+ if (newSize === 0) {
86
+ newSize = 1;
87
+ }
88
+ while (newSize <= owner) {
89
+ newSize <<= 1;
90
+ }
91
+ this.resizeOwners(newSize);
92
+ }
93
+ ensureOwnerListCapacity(owner, required) {
94
+ const cap = this.capacities[owner];
95
+ if (cap >= required) {
96
+ return;
97
+ }
98
+ const newCap = cap === 0 ? Math.max(4, required) : Math.max(cap << 1, required);
99
+ this.ensurePoolCapacity(newCap);
100
+ const oldOffset = this.offsets[owner];
101
+ const len = this.lengths[owner];
102
+ const newOffset = this.poolSize;
103
+ for (let i = 0; i < len; i++) {
104
+ this.keys[newOffset + i] = this.keys[oldOffset + i];
105
+ this.values[newOffset + i] = this.values[oldOffset + i];
106
+ }
107
+ this.offsets[owner] = newOffset;
108
+ this.capacities[owner] = newCap;
109
+ this.poolSize += newCap;
110
+ }
111
+ ensurePoolCapacity(additional) {
112
+ const required = this.poolSize + additional;
113
+ if (required <= this.poolCapacity) {
114
+ return;
115
+ }
116
+ let newCapacity = Math.max(this.poolCapacity << 1, 1024);
117
+ while (newCapacity < required) {
118
+ newCapacity <<= 1;
119
+ }
120
+ const newKeys = new Int32Array(newCapacity);
121
+ const newValues = new Int32Array(newCapacity);
122
+ newKeys.set(this.keys);
123
+ newValues.set(this.values);
124
+ this.keys = newKeys;
125
+ this.values = newValues;
126
+ this.poolCapacity = newCapacity;
127
+ }
128
+ resizeOwners(newSize) {
129
+ const newOffsets = new Int32Array(newSize);
130
+ const newLengths = new Int32Array(newSize);
131
+ const newCaps = new Int32Array(newSize);
132
+ newOffsets.set(this.offsets);
133
+ newLengths.set(this.lengths);
134
+ newCaps.set(this.capacities);
135
+ this.offsets = newOffsets;
136
+ this.lengths = newLengths;
137
+ this.capacities = newCaps;
138
+ }
139
+ }
140
+ exports.PackedSparseMap = PackedSparseMap;
@@ -1 +1 @@
1
- {"version":3,"file":"entryMethodUtils.d.ts","sourceRoot":"","sources":["../../src/utils/entryMethodUtils.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAGzC,eAAO,MAAM,qBAAqB,EAAE,MAAM,EA2BzC,CAAC;AACF,eAAO,MAAM,oBAAoB,EAAE,MAAM,EAiBxC,CAAC;AAEF,eAAO,MAAM,+BAA+B,EAAE,MAAM,EAkBnD,CAAC;AAEF,MAAM,WAAW,cAAc;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,GAAG,SAAS,GAAG,IAAI,CAoBpF;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CASnD"}
1
+ {"version":3,"file":"entryMethodUtils.d.ts","sourceRoot":"","sources":["../../src/utils/entryMethodUtils.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAGzC,eAAO,MAAM,qBAAqB,EAAE,MAAM,EAmCzC,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,MAAM,EAiBxC,CAAC;AAEF,eAAO,MAAM,+BAA+B,EAAE,MAAM,EAmBnD,CAAC;AAEF,MAAM,WAAW,cAAc;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,GAAG,SAAS,GAAG,IAAI,CAoBpF;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CASnD"}
@@ -18,22 +18,31 @@ exports.addCfg2Stmt = exports.getCallbackMethodFromStmt = exports.COMPONENT_LIFE
18
18
  const Type_1 = require("../core/base/Type");
19
19
  exports.LIFECYCLE_METHOD_NAME = [
20
20
  'onCreate',
21
- 'onDestroy',
22
21
  'onWindowStageCreate',
22
+ 'onWindowStageWillDestroy',
23
23
  'onWindowStageDestroy',
24
+ 'onWindowStageRestore',
25
+ 'onDestroy',
26
+ 'onWillForeground',
24
27
  'onForeground',
28
+ 'onDidForeground',
29
+ 'onWillBackground',
25
30
  'onBackground',
26
- 'onBackup',
27
- 'onRestore',
31
+ 'onDidBackground',
28
32
  'onContinue',
29
33
  'onNewWant',
30
34
  'onDump',
31
35
  'onSaveState',
36
+ 'onSaveStateAsync',
32
37
  'onShare',
33
38
  'onPrepareToTerminate',
39
+ 'onPrepareToTerminateAsync',
34
40
  'onBackPressed',
41
+ 'onCollaborate',
35
42
  'onSessionCreate',
36
43
  'onSessionDestory',
44
+ 'onBackup',
45
+ 'onRestore',
37
46
  'onAddForm',
38
47
  'onCastToNormalForm',
39
48
  'onUpdateForm',
@@ -42,7 +51,6 @@ exports.LIFECYCLE_METHOD_NAME = [
42
51
  'onRemoveForm',
43
52
  'onConfigurationUpdate',
44
53
  'onAcquireFormState',
45
- 'onWindowStageWillDestroy',
46
54
  ];
47
55
  exports.CALLBACK_METHOD_NAME = [
48
56
  'onClick',
@@ -65,21 +73,22 @@ exports.CALLBACK_METHOD_NAME = [
65
73
  exports.COMPONENT_LIFECYCLE_METHOD_NAME = [
66
74
  'build',
67
75
  'aboutToAppear',
76
+ 'onDidBuild',
68
77
  'aboutToDisappear',
78
+ 'onPageShow',
79
+ 'onPageHide',
80
+ 'onBackPress',
81
+ 'onNewParam',
69
82
  'aboutToReuse',
70
83
  'aboutToRecycle',
71
84
  'onWillApplyTheme',
85
+ 'pageTransition',
86
+ 'onFormRecycle',
87
+ 'onFormRecover',
72
88
  'onLayout',
73
89
  'onPlaceChildren',
74
90
  'onMeasure',
75
91
  'onMeasureSize',
76
- 'onPageShow',
77
- 'onPageHide',
78
- 'onFormRecycle',
79
- 'onFormRecover',
80
- 'onBackPress',
81
- 'pageTransition',
82
- 'onDidBuild',
83
92
  ];
84
93
  function getCallbackMethodFromStmt(stmt, scene) {
85
94
  const invokeExpr = stmt.getInvokeExpr();
@@ -10,6 +10,7 @@ export declare enum LOG_MODULE_TYPE {
10
10
  DEFAULT = "default",
11
11
  ARKANALYZER = "ArkAnalyzer",
12
12
  HOMECHECK = "HomeCheck",
13
+ HOMEFLOW = "HomeFlow",
13
14
  TOOL = "Tool"
14
15
  }
15
16
  export default class ConsoleLogger {
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGrC,oBAAY,SAAS;IACjB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,IAAI,SAAS;IACb,KAAK,UAAU;IACf,KAAK,UAAU;CAClB;AAED,oBAAY,eAAe;IACvB,OAAO,YAAY;IACnB,WAAW,gBAAgB;IAC3B,SAAS,cAAc;IACvB,IAAI,SAAS;CAChB;AAED,MAAM,CAAC,OAAO,OAAO,aAAa;WAChB,SAAS,CACnB,WAAW,EAAE,MAAM,EACnB,iBAAiB,GAAE,SAA2B,EAC9C,UAAU,GAAE,SAA0B,EACtC,WAAW,GAAE,OAAe,GAC7B,IAAI;WAkDO,SAAS,CAAC,QAAQ,EAAE,eAAe,EAAE,GAAG,GAAE,MAAY,GAAG,MAAM;CAWhF"}
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGrC,oBAAY,SAAS;IACjB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,IAAI,SAAS;IACb,KAAK,UAAU;IACf,KAAK,UAAU;CAClB;AAED,oBAAY,eAAe;IACvB,OAAO,YAAY;IACnB,WAAW,gBAAgB;IAC3B,SAAS,cAAc;IACvB,QAAQ,aAAa;IACrB,IAAI,SAAS;CAChB;AAED,MAAM,CAAC,OAAO,OAAO,aAAa;WAChB,SAAS,CACnB,WAAW,EAAE,MAAM,EACnB,iBAAiB,GAAE,SAA2B,EAC9C,UAAU,GAAE,SAA0B,EACtC,WAAW,GAAE,OAAe,GAC7B,IAAI;WAkDO,SAAS,CAAC,QAAQ,EAAE,eAAe,EAAE,GAAG,GAAE,MAAY,GAAG,MAAM;CAWhF"}
@@ -29,6 +29,7 @@ var LOG_MODULE_TYPE;
29
29
  LOG_MODULE_TYPE["DEFAULT"] = "default";
30
30
  LOG_MODULE_TYPE["ARKANALYZER"] = "ArkAnalyzer";
31
31
  LOG_MODULE_TYPE["HOMECHECK"] = "HomeCheck";
32
+ LOG_MODULE_TYPE["HOMEFLOW"] = "HomeFlow";
32
33
  LOG_MODULE_TYPE["TOOL"] = "Tool";
33
34
  })(LOG_MODULE_TYPE = exports.LOG_MODULE_TYPE || (exports.LOG_MODULE_TYPE = {}));
34
35
  class ConsoleLogger {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "arkanalyzer",
3
- "version": "1.0.81",
4
- "commit_id": "32732a4b",
3
+ "version": "1.0.83",
4
+ "commit_id": "cf99dea1",
5
5
  "files": [
6
6
  "docs",
7
7
  "lib",