arkanalyzer 1.0.94 → 2.0.0-beta1

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 (291) hide show
  1. package/lib/Config.d.ts +7 -0
  2. package/lib/Config.d.ts.map +1 -1
  3. package/lib/Scene.d.ts +134 -170
  4. package/lib/Scene.d.ts.map +1 -1
  5. package/lib/Scene.js +412 -976
  6. package/lib/callgraph/algorithm/AbstractAnalysis.js +3 -2
  7. package/lib/callgraph/algorithm/RapidTypeAnalysis.js +1 -1
  8. package/lib/callgraph/model/CallGraph.js +1 -1
  9. package/lib/callgraph/pointerAnalysis/PTAUtils.d.ts +1 -3
  10. package/lib/callgraph/pointerAnalysis/PTAUtils.d.ts.map +1 -1
  11. package/lib/callgraph/pointerAnalysis/PTAUtils.js +17 -7
  12. package/lib/callgraph/pointerAnalysis/Pag.d.ts.map +1 -1
  13. package/lib/callgraph/pointerAnalysis/Pag.js +4 -14
  14. package/lib/callgraph/pointerAnalysis/PagBuilder.d.ts.map +1 -1
  15. package/lib/callgraph/pointerAnalysis/PagBuilder.js +2 -1
  16. package/lib/callgraph/pointerAnalysis/PointerAnalysis.d.ts.map +1 -1
  17. package/lib/callgraph/pointerAnalysis/PointerAnalysis.js +1 -2
  18. package/lib/callgraph/pointerAnalysis/plugins/WorkerPlugin.d.ts.map +1 -1
  19. package/lib/callgraph/pointerAnalysis/plugins/WorkerPlugin.js +0 -1
  20. package/lib/cli/commands/cg.d.ts +1 -0
  21. package/lib/cli/commands/cg.d.ts.map +1 -1
  22. package/lib/cli/commands/cg.js +22 -18
  23. package/lib/cli/commands/ir.d.ts +1 -0
  24. package/lib/cli/commands/ir.d.ts.map +1 -1
  25. package/lib/cli/commands/ir.js +5 -2
  26. package/lib/core/base/Constant.d.ts +5 -5
  27. package/lib/core/base/Constant.d.ts.map +1 -1
  28. package/lib/core/base/Constant.js +12 -9
  29. package/lib/core/base/Expr.d.ts +36 -20
  30. package/lib/core/base/Expr.d.ts.map +1 -1
  31. package/lib/core/base/Expr.js +206 -94
  32. package/lib/core/base/Local.d.ts +10 -20
  33. package/lib/core/base/Local.d.ts.map +1 -1
  34. package/lib/core/base/Local.js +25 -28
  35. package/lib/core/base/Position.d.ts +6 -0
  36. package/lib/core/base/Position.d.ts.map +1 -1
  37. package/lib/core/base/Position.js +37 -11
  38. package/lib/core/base/Ref.d.ts +45 -33
  39. package/lib/core/base/Ref.d.ts.map +1 -1
  40. package/lib/core/base/Ref.js +225 -51
  41. package/lib/core/base/Stmt.d.ts +19 -9
  42. package/lib/core/base/Stmt.d.ts.map +1 -1
  43. package/lib/core/base/Stmt.js +135 -52
  44. package/lib/core/base/Type.d.ts +67 -4
  45. package/lib/core/base/Type.d.ts.map +1 -1
  46. package/lib/core/base/Type.js +391 -20
  47. package/lib/core/base/TypeExpr.d.ts +6 -4
  48. package/lib/core/base/TypeExpr.d.ts.map +1 -1
  49. package/lib/core/base/TypeExpr.js +34 -10
  50. package/lib/core/base/Value.d.ts +20 -2
  51. package/lib/core/base/Value.d.ts.map +1 -1
  52. package/lib/core/base/Value.js +12 -0
  53. package/lib/core/common/ArkIRTransformer.d.ts +18 -0
  54. package/lib/core/common/ArkIRTransformer.d.ts.map +1 -1
  55. package/lib/core/common/ArkIRTransformer.js +94 -75
  56. package/lib/core/common/ArkValueTransformer.d.ts +21 -3
  57. package/lib/core/common/ArkValueTransformer.d.ts.map +1 -1
  58. package/lib/core/common/ArkValueTransformer.js +455 -265
  59. package/lib/core/common/Builtin.d.ts +48 -24
  60. package/lib/core/common/Builtin.d.ts.map +1 -1
  61. package/lib/core/common/Builtin.js +90 -52
  62. package/lib/core/common/CanonicalizerValidator.d.ts +308 -0
  63. package/lib/core/common/CanonicalizerValidator.d.ts.map +1 -0
  64. package/lib/core/common/CanonicalizerValidator.js +888 -0
  65. package/lib/core/common/Const.d.ts +3 -3
  66. package/lib/core/common/Const.d.ts.map +1 -1
  67. package/lib/core/common/Const.js +3 -3
  68. package/lib/core/common/DummyMainCreater.d.ts +2 -21
  69. package/lib/core/common/DummyMainCreater.d.ts.map +1 -1
  70. package/lib/core/common/DummyMainCreater.js +8 -105
  71. package/lib/core/common/IRInference.d.ts +55 -3
  72. package/lib/core/common/IRInference.d.ts.map +1 -1
  73. package/lib/core/common/IRInference.js +407 -126
  74. package/lib/core/common/IRUtils.d.ts +1 -0
  75. package/lib/core/common/IRUtils.d.ts.map +1 -1
  76. package/lib/core/common/IRUtils.js +44 -13
  77. package/lib/core/common/ModelUtils.d.ts +44 -20
  78. package/lib/core/common/ModelUtils.d.ts.map +1 -1
  79. package/lib/core/common/ModelUtils.js +378 -208
  80. package/lib/core/common/SdkUtils.d.ts +35 -5
  81. package/lib/core/common/SdkUtils.d.ts.map +1 -1
  82. package/lib/core/common/SdkUtils.js +181 -53
  83. package/lib/core/common/SignatureCanonicalizer.d.ts +95 -0
  84. package/lib/core/common/SignatureCanonicalizer.d.ts.map +1 -0
  85. package/lib/core/common/SignatureCanonicalizer.js +116 -0
  86. package/lib/core/common/SignatureCanonicalizerRegistry.d.ts +176 -0
  87. package/lib/core/common/SignatureCanonicalizerRegistry.d.ts.map +1 -0
  88. package/lib/core/common/SignatureCanonicalizerRegistry.js +343 -0
  89. package/lib/core/common/SignatureModelCanonicalizer.d.ts +69 -0
  90. package/lib/core/common/SignatureModelCanonicalizer.d.ts.map +1 -0
  91. package/lib/core/common/SignatureModelCanonicalizer.js +109 -0
  92. package/lib/core/common/StmtUseReplacer.d.ts +1 -0
  93. package/lib/core/common/StmtUseReplacer.d.ts.map +1 -1
  94. package/lib/core/common/StmtUseReplacer.js +9 -0
  95. package/lib/core/common/StringUtils.d.ts +12 -1
  96. package/lib/core/common/StringUtils.d.ts.map +1 -1
  97. package/lib/core/common/StringUtils.js +36 -17
  98. package/lib/core/common/TempSignatureCanonicalizer.d.ts +82 -0
  99. package/lib/core/common/TempSignatureCanonicalizer.d.ts.map +1 -0
  100. package/lib/core/common/TempSignatureCanonicalizer.js +177 -0
  101. package/lib/core/common/TypeInference.d.ts +24 -6
  102. package/lib/core/common/TypeInference.d.ts.map +1 -1
  103. package/lib/core/common/TypeInference.js +243 -117
  104. package/lib/core/common/ValueUtil.d.ts +2 -1
  105. package/lib/core/common/ValueUtil.d.ts.map +1 -1
  106. package/lib/core/common/ValueUtil.js +4 -1
  107. package/lib/core/graph/Cfg.d.ts.map +1 -1
  108. package/lib/core/graph/Cfg.js +21 -6
  109. package/lib/core/graph/builder/CfgBuilder.d.ts.map +1 -1
  110. package/lib/core/graph/builder/CfgBuilder.js +46 -33
  111. package/lib/core/graph/builder/IfBuilder.d.ts.map +1 -1
  112. package/lib/core/graph/builder/IfBuilder.js +6 -2
  113. package/lib/core/graph/builder/ViewTreeBuilder.d.ts.map +1 -1
  114. package/lib/core/graph/builder/ViewTreeBuilder.js +6 -2
  115. package/lib/core/inference/ModelInference.d.ts +24 -4
  116. package/lib/core/inference/ModelInference.d.ts.map +1 -1
  117. package/lib/core/inference/ModelInference.js +273 -79
  118. package/lib/core/inference/ValueInference.d.ts +3 -2
  119. package/lib/core/inference/ValueInference.d.ts.map +1 -1
  120. package/lib/core/inference/ValueInference.js +90 -40
  121. package/lib/core/inference/abc/AbcInference.d.ts.map +1 -1
  122. package/lib/core/inference/abc/AbcInference.js +28 -15
  123. package/lib/core/inference/arkts/ArkTsInference.d.ts +9 -3
  124. package/lib/core/inference/arkts/ArkTsInference.d.ts.map +1 -1
  125. package/lib/core/inference/arkts/ArkTsInference.js +54 -16
  126. package/lib/core/model/ArkClass.d.ts +192 -18
  127. package/lib/core/model/ArkClass.d.ts.map +1 -1
  128. package/lib/core/model/ArkClass.js +852 -122
  129. package/lib/core/model/ArkExport.d.ts.map +1 -1
  130. package/lib/core/model/ArkExport.js +1 -2
  131. package/lib/core/model/ArkField.d.ts +34 -2
  132. package/lib/core/model/ArkField.d.ts.map +1 -1
  133. package/lib/core/model/ArkField.js +89 -14
  134. package/lib/core/model/ArkFile.d.ts +72 -12
  135. package/lib/core/model/ArkFile.d.ts.map +1 -1
  136. package/lib/core/model/ArkFile.js +275 -65
  137. package/lib/core/model/ArkImport.d.ts.map +1 -1
  138. package/lib/core/model/ArkImport.js +1 -2
  139. package/lib/core/model/ArkMethod.d.ts +101 -15
  140. package/lib/core/model/ArkMethod.d.ts.map +1 -1
  141. package/lib/core/model/ArkMethod.js +252 -39
  142. package/lib/core/model/ArkModule.d.ts +1 -1
  143. package/lib/core/model/ArkModule.js +1 -1
  144. package/lib/core/model/ArkNamespace.d.ts +80 -10
  145. package/lib/core/model/ArkNamespace.d.ts.map +1 -1
  146. package/lib/core/model/ArkNamespace.js +309 -76
  147. package/lib/core/model/ArkSignature.d.ts +242 -18
  148. package/lib/core/model/ArkSignature.d.ts.map +1 -1
  149. package/lib/core/model/ArkSignature.js +725 -95
  150. package/lib/core/model/builder/ArkClassBuilder.d.ts +6 -3
  151. package/lib/core/model/builder/ArkClassBuilder.d.ts.map +1 -1
  152. package/lib/core/model/builder/ArkClassBuilder.js +116 -71
  153. package/lib/core/model/builder/ArkExportBuilder.d.ts +1 -1
  154. package/lib/core/model/builder/ArkExportBuilder.d.ts.map +1 -1
  155. package/lib/core/model/builder/ArkExportBuilder.js +1 -1
  156. package/lib/core/model/builder/ArkFieldBuilder.d.ts +0 -2
  157. package/lib/core/model/builder/ArkFieldBuilder.d.ts.map +1 -1
  158. package/lib/core/model/builder/ArkFieldBuilder.js +9 -43
  159. package/lib/core/model/builder/ArkFileBuilder.d.ts.map +1 -1
  160. package/lib/core/model/builder/ArkFileBuilder.js +32 -33
  161. package/lib/core/model/builder/ArkMethodBuilder.d.ts +10 -3
  162. package/lib/core/model/builder/ArkMethodBuilder.d.ts.map +1 -1
  163. package/lib/core/model/builder/ArkMethodBuilder.js +40 -26
  164. package/lib/core/model/builder/ArkNamespaceBuilder.d.ts +3 -2
  165. package/lib/core/model/builder/ArkNamespaceBuilder.d.ts.map +1 -1
  166. package/lib/core/model/builder/ArkNamespaceBuilder.js +45 -77
  167. package/lib/core/model/builder/ArkSignatureBuilder.d.ts +9 -0
  168. package/lib/core/model/builder/ArkSignatureBuilder.d.ts.map +1 -1
  169. package/lib/core/model/builder/ArkSignatureBuilder.js +26 -3
  170. package/lib/core/model/builder/BodyBuilder.d.ts +1 -0
  171. package/lib/core/model/builder/BodyBuilder.d.ts.map +1 -1
  172. package/lib/core/model/builder/BodyBuilder.js +37 -11
  173. package/lib/core/model/builder/builderUtils.d.ts +11 -1
  174. package/lib/core/model/builder/builderUtils.d.ts.map +1 -1
  175. package/lib/core/model/builder/builderUtils.js +124 -90
  176. package/lib/frontend/FrontendBuilder.d.ts +10 -6
  177. package/lib/frontend/FrontendBuilder.d.ts.map +1 -1
  178. package/lib/frontend/FrontendBuilder.js +19 -45
  179. package/lib/frontend/ModuleScene.d.ts +43 -0
  180. package/lib/frontend/ModuleScene.d.ts.map +1 -0
  181. package/lib/frontend/ModuleScene.js +143 -0
  182. package/lib/frontend/SceneBuildStage.d.ts +15 -0
  183. package/lib/frontend/SceneBuildStage.d.ts.map +1 -0
  184. package/lib/frontend/SceneBuildStage.js +32 -0
  185. package/lib/frontend/SceneBuilder.d.ts +153 -0
  186. package/lib/frontend/SceneBuilder.d.ts.map +1 -0
  187. package/lib/frontend/SceneBuilder.js +859 -0
  188. package/lib/frontend/arktsFrontend/ArktsFrontend.d.ts +0 -2
  189. package/lib/frontend/arktsFrontend/ArktsFrontend.d.ts.map +1 -1
  190. package/lib/frontend/arktsFrontend/ArktsFrontend.js +0 -18
  191. package/lib/frontend/arktsFrontend/FileBodyRemount.d.ts +17 -0
  192. package/lib/frontend/arktsFrontend/FileBodyRemount.d.ts.map +1 -0
  193. package/lib/frontend/arktsFrontend/FileBodyRemount.js +187 -0
  194. package/lib/frontend/common/ModuleBuilder.d.ts +4 -2
  195. package/lib/frontend/common/ModuleBuilder.d.ts.map +1 -1
  196. package/lib/frontend/common/ModuleBuilder.js +19 -9
  197. package/lib/frontend/cppFrontend/CppFrontend.d.ts +0 -6
  198. package/lib/frontend/cppFrontend/CppFrontend.d.ts.map +1 -1
  199. package/lib/frontend/cppFrontend/CppFrontend.js +0 -56
  200. package/lib/frontend/cppFrontend/base/Type.d.ts +7 -0
  201. package/lib/frontend/cppFrontend/base/Type.d.ts.map +1 -1
  202. package/lib/frontend/cppFrontend/base/Type.js +29 -0
  203. package/lib/frontend/cppFrontend/common/ArkIRTransformer.d.ts.map +1 -1
  204. package/lib/frontend/cppFrontend/common/ArkIRTransformer.js +56 -56
  205. package/lib/frontend/cppFrontend/common/ArkValueTransformer.d.ts +1 -1
  206. package/lib/frontend/cppFrontend/common/ArkValueTransformer.d.ts.map +1 -1
  207. package/lib/frontend/cppFrontend/common/ArkValueTransformer.js +124 -113
  208. package/lib/frontend/cppFrontend/common/Builtin.d.ts +29 -19
  209. package/lib/frontend/cppFrontend/common/Builtin.d.ts.map +1 -1
  210. package/lib/frontend/cppFrontend/common/Builtin.js +56 -35
  211. package/lib/frontend/cppFrontend/common/IRInference.d.ts +7 -2
  212. package/lib/frontend/cppFrontend/common/IRInference.d.ts.map +1 -1
  213. package/lib/frontend/cppFrontend/common/IRInference.js +61 -28
  214. package/lib/frontend/cppFrontend/common/IRUtils.d.ts +1 -0
  215. package/lib/frontend/cppFrontend/common/IRUtils.d.ts.map +1 -1
  216. package/lib/frontend/cppFrontend/common/IRUtils.js +22 -10
  217. package/lib/frontend/cppFrontend/common/ModelUtils.d.ts +19 -0
  218. package/lib/frontend/cppFrontend/common/ModelUtils.d.ts.map +1 -1
  219. package/lib/frontend/cppFrontend/common/ModelUtils.js +84 -3
  220. package/lib/frontend/cppFrontend/common/TypeInference.d.ts.map +1 -1
  221. package/lib/frontend/cppFrontend/common/TypeInference.js +44 -54
  222. package/lib/frontend/cppFrontend/graph/builder/CfgBuilder.d.ts.map +1 -1
  223. package/lib/frontend/cppFrontend/graph/builder/CfgBuilder.js +2 -1
  224. package/lib/frontend/cppFrontend/inference/CxxModelInference.d.ts +1 -1
  225. package/lib/frontend/cppFrontend/inference/CxxModelInference.d.ts.map +1 -1
  226. package/lib/frontend/cppFrontend/inference/CxxValueInference.d.ts.map +1 -1
  227. package/lib/frontend/cppFrontend/inference/CxxValueInference.js +41 -5
  228. package/lib/frontend/cppFrontend/model/builder/ArkClassBuilder.d.ts.map +1 -1
  229. package/lib/frontend/cppFrontend/model/builder/ArkClassBuilder.js +18 -28
  230. package/lib/frontend/cppFrontend/model/builder/ArkFieldBuilder.d.ts.map +1 -1
  231. package/lib/frontend/cppFrontend/model/builder/ArkFieldBuilder.js +2 -3
  232. package/lib/frontend/cppFrontend/model/builder/ArkFileBuilder.d.ts +2 -2
  233. package/lib/frontend/cppFrontend/model/builder/ArkFileBuilder.d.ts.map +1 -1
  234. package/lib/frontend/cppFrontend/model/builder/ArkFileBuilder.js +31 -24
  235. package/lib/frontend/cppFrontend/model/builder/ArkMethodBuilder.d.ts.map +1 -1
  236. package/lib/frontend/cppFrontend/model/builder/ArkMethodBuilder.js +10 -16
  237. package/lib/frontend/cppFrontend/model/builder/ArkNamespaceBuilder.d.ts +0 -2
  238. package/lib/frontend/cppFrontend/model/builder/ArkNamespaceBuilder.d.ts.map +1 -1
  239. package/lib/frontend/cppFrontend/model/builder/ArkNamespaceBuilder.js +19 -37
  240. package/lib/frontend/cppFrontend/model/builder/BodyBuilder.d.ts +1 -0
  241. package/lib/frontend/cppFrontend/model/builder/BodyBuilder.d.ts.map +1 -1
  242. package/lib/frontend/cppFrontend/model/builder/BodyBuilder.js +30 -3
  243. package/lib/frontend/cppFrontend/model/builder/builderUtils.d.ts.map +1 -1
  244. package/lib/frontend/cppFrontend/model/builder/builderUtils.js +8 -4
  245. package/lib/index.d.ts +3 -0
  246. package/lib/index.d.ts.map +1 -1
  247. package/lib/index.js +10 -2
  248. package/lib/save/json/JsonSerialization.js +2 -2
  249. package/lib/save/source/SourceStmt.js +1 -1
  250. package/lib/save/source/SourceTransformer.d.ts.map +1 -1
  251. package/lib/save/source/SourceTransformer.js +0 -9
  252. package/lib/statistics/StageStatistics.d.ts +195 -0
  253. package/lib/statistics/StageStatistics.d.ts.map +1 -0
  254. package/lib/statistics/StageStatistics.js +346 -0
  255. package/lib/statistics/StageStatisticsReporter.d.ts +58 -0
  256. package/lib/statistics/StageStatisticsReporter.d.ts.map +1 -0
  257. package/lib/statistics/StageStatisticsReporter.js +255 -0
  258. package/lib/utils/Canonicalizer.d.ts +9 -2
  259. package/lib/utils/Canonicalizer.d.ts.map +1 -1
  260. package/lib/utils/Canonicalizer.js +19 -2
  261. package/lib/utils/CxxSceneUtils.d.ts +7 -0
  262. package/lib/utils/CxxSceneUtils.d.ts.map +1 -1
  263. package/lib/utils/CxxSceneUtils.js +10 -1
  264. package/lib/utils/FileUtils.d.ts +0 -1
  265. package/lib/utils/FileUtils.d.ts.map +1 -1
  266. package/lib/utils/FileUtils.js +1 -9
  267. package/lib/utils/HashUtils.d.ts +9 -0
  268. package/lib/utils/HashUtils.d.ts.map +1 -0
  269. package/lib/utils/HashUtils.js +65 -0
  270. package/lib/utils/ModuleUtils.d.ts.map +1 -1
  271. package/lib/utils/ModuleUtils.js +24 -5
  272. package/lib/utils/VisitedSegment.d.ts +23 -0
  273. package/lib/utils/VisitedSegment.d.ts.map +1 -0
  274. package/lib/utils/VisitedSegment.js +64 -0
  275. package/lib/utils/callGraphUtils.d.ts.map +1 -1
  276. package/lib/utils/callGraphUtils.js +7 -7
  277. package/lib/utils/getAllFiles.d.ts.map +1 -1
  278. package/lib/utils/getAllFiles.js +11 -8
  279. package/lib/utils/logger.d.ts +4 -0
  280. package/lib/utils/logger.d.ts.map +1 -1
  281. package/lib/utils/logger.js +16 -0
  282. package/lib/utils/parseArkSourceFile.d.ts +33 -0
  283. package/lib/utils/parseArkSourceFile.d.ts.map +1 -0
  284. package/lib/utils/parseArkSourceFile.js +131 -0
  285. package/package.json +1 -1
  286. package/lib/utils/DependenciesSort.d.ts +0 -3
  287. package/lib/utils/DependenciesSort.d.ts.map +0 -1
  288. package/lib/utils/DependenciesSort.js +0 -72
  289. package/lib/utils/crypto_utils.d.ts +0 -6
  290. package/lib/utils/crypto_utils.d.ts.map +0 -1
  291. package/lib/utils/crypto_utils.js +0 -57
@@ -17,15 +17,45 @@ export declare class SdkUtils {
17
17
  private static dfsFiles;
18
18
  static dispose(): void;
19
19
  static buildSdkImportMap(file: ArkFile): void;
20
+ /**
21
+ * Entry count of the SDK import map, read as part of the resolution table state that decides
22
+ * whether a cached "no file" answer is still valid.
23
+ */
24
+ static getSdkImportMapSize(): number;
20
25
  static getImportSdkFile(from: string): ArkFile | undefined;
21
26
  private static isGlobalPath;
22
- static loadGlobalAPI(file: ArkFile, globalMap: Map<string, ArkExport>): void;
23
- static mergeGlobalAPI(file: ArkFile, globalMap: Map<string, ArkExport>): void;
24
- private static copyNamespace;
25
- static loadAPI(api: ArkExport, globalMap: Map<string, ArkExport>, override?: boolean): void;
26
- static postInferredSdk(file: ArkFile, globalMap: Map<string, ArkExport>): void;
27
+ /** @internal 取名字下的首实体(单值视图语义)。 */
28
+ private static getFirstGlobal;
29
+ /** @internal first-win 登记:append 到列表尾部(首实体不变)。 */
30
+ private static appendGlobal;
31
+ /** @internal override 登记:移到列表头部(等价旧单值覆盖语义)。 */
32
+ private static promoteGlobal;
33
+ static loadGlobalAPI(file: ArkFile, globalMap: Map<string, ArkExport[]>): void;
34
+ static mergeGlobalAPI(file: ArkFile, globalMap: Map<string, ArkExport[]>): void;
35
+ static loadAPI(api: ArkExport, globalMap: Map<string, ArkExport[]>, override?: boolean): void;
36
+ static postInferredSdk(file: ArkFile, globalMap: Map<string, ArkExport[]>): void;
27
37
  private static loadClass;
28
38
  private static loadGlobalLocal;
39
+ /** @internal, Get all member-provider classes of a global symbol for member probing. */
40
+ static getSdkGlobalMemberClasses(globalName: string): ArkClass[];
41
+ /**
42
+ * Get the same-name classes mounted in sibling entities of a class's declaring
43
+ * namespace — for cross-file same-name namespaces (e.g. `Intl` declared across
44
+ * lib.es5 + lib.es20XX.intl), the class's counterpart in each sibling namespace
45
+ * carries members declared in that file. Sibling order follows registration
46
+ * order (= DFS file order); returns [] for non-global namespaces.
47
+ */
48
+ static getNamespacedSiblingClasses(arkClass: ArkClass): ArkClass[];
49
+ /**
50
+ * Single-value view of the SDK global map: the first entity registered under the name (first-win 语义). Returns null when unregistered.
51
+ */
52
+ static getSdkGlobal(globalName: string): ArkExport | null;
53
+ /**
54
+ * All SDK global entities registered under the given name (multi-declaration
55
+ * scenario: e.g. `interface Object` + `declare var Object: ObjectConstructor` are
56
+ * two entities). Order is the registration order; entry [0] equals {@link getSdkGlobal}.
57
+ */
58
+ static getSdkGlobals(globalName: string): ArkExport[];
29
59
  static copyMembers(from: ArkClass, to: ArkClass): void;
30
60
  static computeGlobalThis(leftOp: AbstractFieldRef, arkMethod: ArkMethod): void;
31
61
  static extendArkUI(scene: Scene): void;
@@ -1 +1 @@
1
- {"version":3,"file":"SdkUtils.d.ts","sourceRoot":"","sources":["../../../src/core/common/SdkUtils.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAc,MAAM,oBAAoB,CAAC;AAU3D,OAAO,EAAE,QAAQ,EAAiB,MAAM,mBAAmB,CAAC;AAG5D,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG/C,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAGnC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAMpC,qBAAa,QAAQ;IACjB,OAAO,CAAC,MAAM,CAAC,SAAS,CAA8B;IACtD,OAAO,CAAC,MAAM,CAAC,YAAY,CAGxB;IAEH,OAAO,CAAC,MAAM,CAAC,YAAY,CAAoD;IAC/E,OAAc,aAAa,SAAc;IACzC,OAAO,CAAC,MAAM,CAAC,cAAc,CAG3B;WAEY,YAAY,CAAC,YAAY,EAAE,GAAG,GAAG,IAAI;WAsBrC,aAAa,IAAI,GAAG;WAoBpB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE;IAW9D,OAAO,CAAC,MAAM,CAAC,QAAQ;WAaT,OAAO,IAAI,IAAI;WAIf,iBAAiB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI;WAStC,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAIjE,OAAO,CAAC,MAAM,CAAC,YAAY;WAUb,aAAa,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAI;WAqBrE,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAI;IAiBpF,OAAO,CAAC,MAAM,CAAC,aAAa;WAWd,OAAO,CAAC,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,QAAQ,GAAE,OAAe,GAAG,IAAI;WAY3F,eAAe,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAI;IAgBrF,OAAO,CAAC,MAAM,CAAC,SAAS;IAiBxB,OAAO,CAAC,MAAM,CAAC,eAAe;WA0BhB,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,GAAG,IAAI;WAqB/C,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,EAAE,SAAS,EAAE,SAAS,GAAG,IAAI;WAWvE,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;WAgB/B,2BAA2B,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;CAwBnE"}
1
+ {"version":3,"file":"SdkUtils.d.ts","sourceRoot":"","sources":["../../../src/core/common/SdkUtils.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAc,MAAM,oBAAoB,CAAC;AAY3D,OAAO,EAAE,QAAQ,EAAiB,MAAM,mBAAmB,CAAC;AAG5D,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG/C,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAEnC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAQpC,qBAAa,QAAQ;IACjB,OAAO,CAAC,MAAM,CAAC,SAAS,CAA8B;IACtD,OAAO,CAAC,MAAM,CAAC,YAAY,CAGxB;IAEH,OAAO,CAAC,MAAM,CAAC,YAAY,CAAkD;IAC7E,OAAc,aAAa,SAAc;IACzC,OAAO,CAAC,MAAM,CAAC,cAAc,CAAgF;WAE/F,YAAY,CAAC,YAAY,EAAE,GAAG,GAAG,IAAI;WAsBrC,aAAa,IAAI,GAAG;WAoBpB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE;IAW9D,OAAO,CAAC,MAAM,CAAC,QAAQ;WAaT,OAAO,IAAI,IAAI;WAIf,iBAAiB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI;IAUpD;;;OAGG;WACW,mBAAmB,IAAI,MAAM;WAI7B,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAQjE,OAAO,CAAC,MAAM,CAAC,YAAY;IAkB3B,kCAAkC;IAClC,OAAO,CAAC,MAAM,CAAC,cAAc;IAI7B,kDAAkD;IAClD,OAAO,CAAC,MAAM,CAAC,YAAY;IAW3B,+CAA+C;IAC/C,OAAO,CAAC,MAAM,CAAC,aAAa;WAad,aAAa,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,GAAG,IAAI;WAsBvE,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,GAAG,IAAI;WAexE,OAAO,CAAC,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,EAAE,QAAQ,GAAE,OAAe,GAAG,IAAI;WAe7F,eAAe,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,GAAG,IAAI;IAgBvF,OAAO,CAAC,MAAM,CAAC,SAAS;IAqBxB,OAAO,CAAC,MAAM,CAAC,eAAe;IAiC9B,wFAAwF;WAC1E,yBAAyB,CAAC,UAAU,EAAE,MAAM,GAAG,QAAQ,EAAE;IAuCvE;;;;;;OAMG;WACW,2BAA2B,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ,EAAE;IAkBzE;;OAEG;WACW,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAIhE;;;;OAIG;WACW,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,EAAE;WAI9C,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,GAAG,IAAI;WA8B/C,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,EAAE,SAAS,EAAE,SAAS,GAAG,IAAI;WAWvE,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;WAc/B,2BAA2B,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;CAuBnE"}
@@ -53,8 +53,9 @@ const path_1 = __importDefault(require("path"));
53
53
  const Type_1 = require("../base/Type");
54
54
  const ArkNamespace_1 = require("../model/ArkNamespace");
55
55
  const logger_1 = __importStar(require("../../utils/logger"));
56
- const ohos_typescript_1 = __importDefault(require("ohos-typescript"));
57
56
  const fs_1 = __importDefault(require("fs"));
57
+ const parseArkSourceFile_1 = require("../../utils/parseArkSourceFile");
58
+ const SignatureCanonicalizerRegistry_1 = require("./SignatureCanonicalizerRegistry");
58
59
  const logger = logger_1.default.getLogger(logger_1.LOG_MODULE_TYPE.ARKANALYZER, 'SdkUtils');
59
60
  const DEFAULT_ES_VERSION = 'ES2021';
60
61
  class SdkUtils {
@@ -113,7 +114,7 @@ class SdkUtils {
113
114
  return Array.from(result);
114
115
  }
115
116
  static dfsFiles(filePath, files) {
116
- const sourceFile = ohos_typescript_1.default.createSourceFile(filePath, fs_1.default.readFileSync(filePath, 'utf8'), ohos_typescript_1.default.ScriptTarget.Latest);
117
+ const sourceFile = (0, parseArkSourceFile_1.parseArkSourceFile)(filePath, fs_1.default.readFileSync(filePath, 'utf8'), false);
117
118
  const references = sourceFile.libReferenceDirectives;
118
119
  references.forEach(ref => {
119
120
  this.dfsFiles(path_1.default.join(path_1.default.dirname(filePath), `lib.${ref.fileName}.d.ts`), files);
@@ -129,19 +130,34 @@ class SdkUtils {
129
130
  }
130
131
  static buildSdkImportMap(file) {
131
132
  const fileName = path_1.default.basename(file.getName());
133
+ const fileSigID = file.getFileSigID();
132
134
  if (fileName.startsWith(EtsConst_1.SCOPE_PREFIX)) {
133
- this.sdkImportMap.set(fileName.replace(/\.d\.e?ts$/, ''), file);
135
+ this.sdkImportMap.set(fileName.replace(/\.d\.e?ts$/, ''), fileSigID);
134
136
  }
135
137
  else if (file.getName().startsWith('api')) {
136
- this.sdkImportMap.set(file.getName().replace(/^api[/\\]|\.d\.e?ts$/g, ''), file);
138
+ this.sdkImportMap.set(file.getName().replace(/^api[/\\]|\.d\.e?ts$/g, ''), fileSigID);
137
139
  }
138
140
  }
141
+ /**
142
+ * Entry count of the SDK import map, read as part of the resolution table state that decides
143
+ * whether a cached "no file" answer is still valid.
144
+ */
145
+ static getSdkImportMapSize() {
146
+ return this.sdkImportMap.size;
147
+ }
139
148
  static getImportSdkFile(from) {
140
- return this.sdkImportMap.get(from);
149
+ const fileSigID = this.sdkImportMap.get(from);
150
+ if (fileSigID === undefined) {
151
+ return undefined;
152
+ }
153
+ return SignatureCanonicalizerRegistry_1.SignatureCanonicalizerRegistry.getInstance().getFileById(fileSigID);
141
154
  }
142
155
  static isGlobalPath(file) {
143
156
  var _a;
144
- return !!((_a = file.getScene().getOptions().sdkGlobalFolders) === null || _a === void 0 ? void 0 : _a.find(x => {
157
+ return !!((_a = file
158
+ .getScene()
159
+ .getOptions()
160
+ .sdkGlobalFolders) === null || _a === void 0 ? void 0 : _a.find(x => {
145
161
  if (path_1.default.isAbsolute(x)) {
146
162
  return file.getFilePath().startsWith(x);
147
163
  }
@@ -150,6 +166,39 @@ class SdkUtils {
150
166
  }
151
167
  }));
152
168
  }
169
+ // --- 多值登记 helpers(单值视图兼容语义) ---
170
+ // globalMap 为多值主存(名字 → 实体列表,登记序)。单值视图 = 列表 [0]:
171
+ // appendGlobal 保持首实体不变(旧 first-win 语义);promoteGlobal 移至头部
172
+ //(旧 override 覆盖语义)。
173
+ /** @internal 取名字下的首实体(单值视图语义)。 */
174
+ static getFirstGlobal(globalMap, name) {
175
+ var _a;
176
+ return (_a = globalMap.get(name)) === null || _a === void 0 ? void 0 : _a[0];
177
+ }
178
+ /** @internal first-win 登记:append 到列表尾部(首实体不变)。 */
179
+ static appendGlobal(globalMap, name, entity) {
180
+ const list = globalMap.get(name);
181
+ if (!list) {
182
+ globalMap.set(name, [entity]);
183
+ return;
184
+ }
185
+ if (!list.includes(entity)) {
186
+ list.push(entity);
187
+ }
188
+ }
189
+ /** @internal override 登记:移到列表头部(等价旧单值覆盖语义)。 */
190
+ static promoteGlobal(globalMap, name, entity) {
191
+ const list = globalMap.get(name);
192
+ if (!list) {
193
+ globalMap.set(name, [entity]);
194
+ return;
195
+ }
196
+ const idx = list.indexOf(entity);
197
+ if (idx >= 0) {
198
+ list.splice(idx, 1);
199
+ }
200
+ list.unshift(entity);
201
+ }
153
202
  static loadGlobalAPI(file, globalMap) {
154
203
  var _a, _b, _c;
155
204
  if (!this.isGlobalPath(file)) {
@@ -165,7 +214,8 @@ class SdkUtils {
165
214
  .forEach(mtd => this.loadAPI(mtd, globalMap));
166
215
  }
167
216
  });
168
- (_c = (_b = (_a = file.getDefaultClass().getDefaultArkMethod()) === null || _a === void 0 ? void 0 : _a.getBody()) === null || _b === void 0 ? void 0 : _b.getAliasTypeMap()) === null || _c === void 0 ? void 0 : _c.forEach(a => this.loadAPI(a[0], globalMap, true));
217
+ (_c = (_b = (_a = file.getDefaultClass()
218
+ .getDefaultArkMethod()) === null || _a === void 0 ? void 0 : _a.getBody()) === null || _b === void 0 ? void 0 : _b.getAliasTypeMap()) === null || _c === void 0 ? void 0 : _c.forEach(a => this.loadAPI(a[0], globalMap, true));
169
219
  file.getNamespaces().forEach(ns => this.loadAPI(ns, globalMap));
170
220
  }
171
221
  static mergeGlobalAPI(file, globalMap) {
@@ -177,35 +227,25 @@ class SdkUtils {
177
227
  this.loadClass(globalMap, cls);
178
228
  }
179
229
  });
180
- file.getNamespaces().forEach(ns => {
181
- const oldNs = globalMap.get(ns.getName());
182
- if (oldNs instanceof ArkNamespace_1.ArkNamespace && oldNs !== ns) {
183
- SdkUtils.copyNamespace(ns, oldNs);
184
- }
185
- });
186
- }
187
- static copyNamespace(ns, oldNs) {
188
- ns.getClasses().forEach(cls => {
189
- const oldCls = oldNs.getClassWithName(cls.getName());
190
- if (oldCls) {
191
- this.copyMembers(cls, oldCls);
192
- }
193
- else {
194
- oldNs.addArkClass(cls);
195
- }
196
- });
230
+ // 跨文件同名 namespace 不再合并(copyNamespace 退役):ns 实体已在阶段 1
231
+ // 多值登记(各文件的实体共存),成员可见性由探测层承担——
232
+ // ModelUtils.findPropertyInNamespaces 逐实体探测(%dflt locals / ns 内类 /
233
+ // 嵌套 ns / export),成员签名归属真实声明文件。
197
234
  }
198
235
  static loadAPI(api, globalMap, override = false) {
199
- const old = globalMap.get(api.getName());
236
+ const old = this.getFirstGlobal(globalMap, api.getName());
200
237
  if (!old) {
201
- globalMap.set(api.getName(), api);
238
+ this.appendGlobal(globalMap, api.getName(), api);
202
239
  }
203
240
  else if (override) {
204
241
  logger.trace(`${old.getSignature()} is override`);
205
- globalMap.set(api.getName(), api);
242
+ this.promoteGlobal(globalMap, api.getName(), api);
206
243
  }
207
244
  else {
245
+ // first-win(单值视图保持首实体),但后续同名实体仍多值登记(append 尾部)
246
+ //——同名多声明(跨文件 interface 增补等)的成员探测依赖完整实体列表。
208
247
  logger.trace(`duplicated api: ${api.getSignature()}`);
248
+ this.appendGlobal(globalMap, api.getName(), api);
209
249
  }
210
250
  }
211
251
  static postInferredSdk(file, globalMap) {
@@ -222,18 +262,22 @@ class SdkUtils {
222
262
  });
223
263
  }
224
264
  static loadClass(globalMap, cls) {
225
- const old = globalMap.get(cls.getName());
265
+ const old = this.getFirstGlobal(globalMap, cls.getName());
226
266
  if (cls === old) {
227
267
  return;
228
268
  }
229
269
  else if (old instanceof ArkClass_1.ArkClass && old.getDeclaringArkFile().getProjectName() === cls.getDeclaringArkFile().getProjectName()) {
230
270
  if (old.getCategory() === ArkClass_1.ClassCategory.CLASS || old.getCategory() === ArkClass_1.ClassCategory.INTERFACE) {
231
- this.copyMembers(cls, old);
271
+ // 同名 interface 跨文件增补(TS 语义为同一实体):不再 copyMembers 灌
272
+ // 入首实体——各文件的实体共存在多值列表(阶段1已登记),成员留在
273
+ // 声明类,探测层逐实体查找(成员签名归属真实声明文件)。
274
+ return;
232
275
  }
233
276
  else {
234
- this.copyMembers(old, cls);
235
- globalMap.delete(cls.getName());
236
- this.loadAPI(cls, globalMap, true);
277
+ // 类别冲突(旧 enum 等 vs 新 interface/class):不再 copyMembers(old, cls)
278
+ //——两实体共存多值(cls 提升为单值视图,与旧 delete+override 语义
279
+ // 一致),成员探测并集可见。
280
+ this.promoteGlobal(globalMap, cls.getName(), cls);
237
281
  }
238
282
  }
239
283
  else {
@@ -245,19 +289,20 @@ class SdkUtils {
245
289
  local.setSignature(new ArkSignature_1.LocalSignature(name, defaultArkMethod.getSignature()));
246
290
  const scene = defaultArkMethod.getDeclaringArkFile().getScene();
247
291
  if (scene.getOptions().isScanAbc) {
248
- const instance = globalMap.get(name + 'Interface');
249
- const attr = globalMap.get(name + EtsConst_1.COMPONENT_ATTRIBUTE);
292
+ const instance = this.getFirstGlobal(globalMap, name + 'Interface');
293
+ const attr = this.getFirstGlobal(globalMap, name + EtsConst_1.COMPONENT_ATTRIBUTE);
250
294
  if (attr instanceof ArkClass_1.ArkClass && instance instanceof ArkClass_1.ArkClass) {
251
- this.copyMembers(instance, attr);
252
- globalMap.set(name, attr);
295
+ // abc 场景不再 copyMembers 合并(挂载分裂来源):attr 提升为单值视图
296
+ //(与旧 set 语义一致),成员留在各自声明类,由探测层逐实体查找。
297
+ this.promoteGlobal(globalMap, name, attr);
253
298
  return;
254
299
  }
255
300
  }
256
- const old = globalMap.get(name);
301
+ const old = this.getFirstGlobal(globalMap, name);
257
302
  if (old instanceof ArkClass_1.ArkClass && local.getType() instanceof Type_1.ClassType) {
258
- const localConstructor = globalMap.get(local.getType().getClassSignature().getClassName());
303
+ const localConstructor = this.getFirstGlobal(globalMap, local.getType().getClassSignature().getClassName());
259
304
  if (localConstructor instanceof ArkClass_1.ArkClass) {
260
- this.copyMembers(localConstructor, old);
305
+ this.appendGlobal(globalMap, name, local);
261
306
  }
262
307
  else {
263
308
  this.loadAPI(local, globalMap, true);
@@ -267,17 +312,106 @@ class SdkUtils {
267
312
  this.loadAPI(local, globalMap, true);
268
313
  }
269
314
  }
315
+ // --- SDK global symbol member probing (migrated from Registry — work item L) ---
316
+ // This layer MAY use instanceof on model classes freely (SdkUtils sits above the
317
+ // dependency-graph floor); the Registry must not (value imports of model classes
318
+ // would create real module-loading edges that flip the ESM cycle, see Registry's
319
+ // dependency-graph constraint note).
320
+ /** @internal, Get all member-provider classes of a global symbol for member probing. */
321
+ static getSdkGlobalMemberClasses(globalName) {
322
+ const result = [];
323
+ const seen = new Set();
324
+ const push = (c) => {
325
+ if (!seen.has(c)) {
326
+ seen.add(c);
327
+ result.push(c);
328
+ }
329
+ };
330
+ const reg = SignatureCanonicalizerRegistry_1.SignatureCanonicalizerRegistry.getInstance();
331
+ for (const e of SdkUtils.getSdkGlobals(globalName)) {
332
+ if (e instanceof ArkClass_1.ArkClass) {
333
+ push(e);
334
+ continue;
335
+ }
336
+ if (!(e instanceof Local_1.Local)) {
337
+ continue;
338
+ }
339
+ const localType = e.getType();
340
+ if (!(localType instanceof Type_1.ClassType)) {
341
+ continue;
342
+ }
343
+ // Local → ctor class via canonicalizer direct lookup: SDK classes are registered (setModel) at build time
344
+ // before their var locals enter the global map; evicted models miss this lookup.
345
+ const ctorSig = localType.getClassSignature();
346
+ const id = reg.classSigCanonicalizer.getExistingId(ctorSig);
347
+ const ctorClass = id !== -1 ? reg.classSigCanonicalizer.getModel(id) : undefined;
348
+ if (ctorClass !== undefined) {
349
+ push(ctorClass);
350
+ }
351
+ for (const c of SdkUtils.getSdkGlobals(ctorSig.getClassName())) {
352
+ if (c instanceof ArkClass_1.ArkClass) {
353
+ push(c);
354
+ }
355
+ }
356
+ }
357
+ return result;
358
+ }
359
+ /**
360
+ * Get the same-name classes mounted in sibling entities of a class's declaring
361
+ * namespace — for cross-file same-name namespaces (e.g. `Intl` declared across
362
+ * lib.es5 + lib.es20XX.intl), the class's counterpart in each sibling namespace
363
+ * carries members declared in that file. Sibling order follows registration
364
+ * order (= DFS file order); returns [] for non-global namespaces.
365
+ */
366
+ static getNamespacedSiblingClasses(arkClass) {
367
+ const ns = arkClass.getDeclaringArkNamespace();
368
+ if (!ns) {
369
+ return [];
370
+ }
371
+ const result = [];
372
+ const className = arkClass.getName();
373
+ for (const e of SdkUtils.getSdkGlobals(ns.getName())) {
374
+ if (e instanceof ArkNamespace_1.ArkNamespace && e !== ns) {
375
+ const c = e.getClassWithName(className);
376
+ if (c) {
377
+ result.push(c);
378
+ }
379
+ }
380
+ }
381
+ return result;
382
+ }
383
+ /**
384
+ * Single-value view of the SDK global map: the first entity registered under the name (first-win 语义). Returns null when unregistered.
385
+ */
386
+ static getSdkGlobal(globalName) {
387
+ var _a, _b;
388
+ return (_b = (_a = SignatureCanonicalizerRegistry_1.SignatureCanonicalizerRegistry.getInstance().sdkGlobalMap.get(globalName)) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : null;
389
+ }
390
+ /**
391
+ * All SDK global entities registered under the given name (multi-declaration
392
+ * scenario: e.g. `interface Object` + `declare var Object: ObjectConstructor` are
393
+ * two entities). Order is the registration order; entry [0] equals {@link getSdkGlobal}.
394
+ */
395
+ static getSdkGlobals(globalName) {
396
+ var _a;
397
+ return (_a = SignatureCanonicalizerRegistry_1.SignatureCanonicalizerRegistry.getInstance().sdkGlobalMap.get(globalName)) !== null && _a !== void 0 ? _a : [];
398
+ }
270
399
  static copyMembers(from, to) {
271
400
  from.getMethods().forEach(method => {
272
401
  var _a, _b, _c, _d;
273
402
  const dist = method.isStatic() ? to.getStaticMethodWithName(method.getName()) : to.getMethodWithName(method.getName());
274
403
  const distSignatures = dist === null || dist === void 0 ? void 0 : dist.getDeclareSignatures();
275
404
  if (distSignatures) {
276
- (_a = method.getDeclareSignatures()) === null || _a === void 0 ? void 0 : _a.forEach(x => distSignatures.push(x));
405
+ // getDeclareSignatures() returns a rebuilt copy — write the merged list back explicitly.
406
+ const merged = [...distSignatures];
407
+ (_a = method.getDeclareSignatures()) === null || _a === void 0 ? void 0 : _a.forEach(x => merged.push(x));
408
+ dist.setDeclareSignatures(merged);
277
409
  }
278
410
  else if (method.getName() === Const_1.DEFAULT_ARK_METHOD_NAME && dist) {
279
- (_b = method.getBody()) === null || _b === void 0 ? void 0 : _b.getLocals().forEach(local => { var _a; return (_a = dist.getBody()) === null || _a === void 0 ? void 0 : _a.getLocals().set(local.getName(), local); });
280
- (_d = (_c = method.getBody()) === null || _c === void 0 ? void 0 : _c.getAliasTypeMap()) === null || _d === void 0 ? void 0 : _d.forEach(type => { var _a, _b; return (_b = (_a = dist.getBody()) === null || _a === void 0 ? void 0 : _a.getAliasTypeMap()) === null || _b === void 0 ? void 0 : _b.set(type[0].getName(), type); });
411
+ (_b = method
412
+ .getBody()) === null || _b === void 0 ? void 0 : _b.getLocals().forEach(local => { var _a; return (_a = dist.getBody()) === null || _a === void 0 ? void 0 : _a.getLocals().set(local.getName(), local); });
413
+ (_d = (_c = method
414
+ .getBody()) === null || _c === void 0 ? void 0 : _c.getAliasTypeMap()) === null || _d === void 0 ? void 0 : _d.forEach(type => { var _a, _b; return (_b = (_a = dist.getBody()) === null || _a === void 0 ? void 0 : _a.getAliasTypeMap()) === null || _b === void 0 ? void 0 : _b.set(type[0].getName(), type); });
281
415
  }
282
416
  else {
283
417
  to.addMethod(method);
@@ -291,7 +425,7 @@ class SdkUtils {
291
425
  });
292
426
  }
293
427
  static computeGlobalThis(leftOp, arkMethod) {
294
- const globalThis = arkMethod.getDeclaringArkFile().getScene().getSdkGlobal(TSConst_1.GLOBAL_THIS_NAME);
428
+ const globalThis = SdkUtils.getSdkGlobal(TSConst_1.GLOBAL_THIS_NAME);
295
429
  if (globalThis instanceof ArkNamespace_1.ArkNamespace) {
296
430
  const exportInfo = new ArkExport_1.ExportInfo.Builder()
297
431
  .exportClauseName(leftOp.getFieldName())
@@ -301,12 +435,10 @@ class SdkUtils {
301
435
  }
302
436
  }
303
437
  static extendArkUI(scene) {
304
- const cls = scene.getSdkGlobal(EtsConst_1.COMMON_METHOD);
438
+ const cls = SdkUtils.getSdkGlobal(EtsConst_1.COMMON_METHOD);
305
439
  if (cls instanceof ArkClass_1.ArkClass) {
306
- const mtd = new ArkMethod_1.ArkMethod();
307
- mtd.setDeclaringArkClass(cls);
308
440
  const methodSubSignature = new ArkSignature_1.MethodSubSignature(EtsConst_1.COMPONENT_POP_FUNCTION, [], Type_1.VoidType.getInstance(), false);
309
- mtd.setDeclareSignatures(new ArkSignature_1.MethodSignature(cls.getSignature(), methodSubSignature));
441
+ const mtd = new ArkMethod_1.ArkMethod(cls.getClassSigID(), undefined, new ArkSignature_1.MethodSignature(cls.getClassSigID(), methodSubSignature));
310
442
  mtd.setIsGeneratedFlag(true);
311
443
  cls.addMethod(mtd);
312
444
  }
@@ -320,8 +452,7 @@ class SdkUtils {
320
452
  if (!fs_1.default.existsSync(componentsDir)) {
321
453
  return;
322
454
  }
323
- const componentFiles = fs_1.default.readdirSync(componentsDir)
324
- .filter(file => file.endsWith('.json'));
455
+ const componentFiles = fs_1.default.readdirSync(componentsDir).filter(file => file.endsWith('.json'));
325
456
  const componentNames = [];
326
457
  componentFiles.forEach(file => {
327
458
  const filePath = path_1.default.join(componentsDir, file);
@@ -349,7 +480,4 @@ SdkUtils.esVersionMap = new Map([
349
480
  ]);
350
481
  SdkUtils.sdkImportMap = new Map();
351
482
  SdkUtils.BUILT_IN_NAME = 'built-in';
352
- SdkUtils.BUILT_IN_PATHS = [
353
- 'lib/node_modules/ohos-typescript/lib',
354
- 'node_modules/ohos-typescript/lib',
355
- ];
483
+ SdkUtils.BUILT_IN_PATHS = ['lib/node_modules/ohos-typescript/lib', 'node_modules/ohos-typescript/lib'];
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Interface that signatures must implement to participate in hash-based canonicalization.
3
+ *
4
+ * The three-layer architecture:
5
+ * - Layer 1: `getHashCode()` — 32-bit hash computed at construction time, cached in a readonly field
6
+ * - Layer 2: `Canonicalizer<number>` with `numberWithEquality` strategy — open-addressing + chaining
7
+ * - Layer 3: `equals()` — per-field semantic comparison, used when hash collisions occur
8
+ */
9
+ export interface Canonicalizable {
10
+ /** Stable 32-bit hash code. Two equal signatures must have the same hash code. */
11
+ getHashCode(): number;
12
+ /** Semantic equality. Used for collision resolution in Layer 2. */
13
+ equals(other: this): boolean;
14
+ }
15
+ /**
16
+ * Value-semantic identity comparison between two signatures:
17
+ * cached-hash fast reject + `equals()` final verdict.
18
+ *
19
+ * Execution rules: the hash comparison short-circuits only comparisons whose
20
+ * result is "unequal"; comparisons whose result is "equal" necessarily run
21
+ * `equals()` (the Canonicalizable contract "equals ⇒ same hash" guarantees the
22
+ * hashes match), where canonical instances short-circuit on the first line
23
+ * (`this === other`). This is the same hash-then-equals protocol the
24
+ * canonicalizer probe uses internally — running it once directly between the
25
+ * two objects, instead of twice (once per probe) plus an ID comparison, and
26
+ * without depending on registration state.
27
+ *
28
+ * Why not compare canonicalizer IDs ("same ID ⇒ equal")? IDs are a function
29
+ * of value × registration history, not of value alone: two unregistered
30
+ * signatures (e.g. temp stubs) both yield getExistingId() === -1 and would be
31
+ * wrongly judged equal; one registered + one unregistered would be wrongly
32
+ * judged unequal; and the getId() variant would blind-write unregistered
33
+ * values into the formal space (permanent holes, see the temp-space design).
34
+ *
35
+ * No string building, no string hashing.
36
+ */
37
+ export declare function signatureEquals(a: Canonicalizable, b: Canonicalizable): boolean;
38
+ /**
39
+ * A canonicalizer that deduplicates signatures by value semantics using hash + equals.
40
+ *
41
+ * Uses a three-layer hash-collision-handling architecture:
42
+ *
43
+ * 1. `sig.getHashCode()` returns a cached 32-bit hash (computed once at construction)
44
+ * 2. `Canonicalizer<S>` with `numberWithEquality` strategy uses TypedArray hash tables
45
+ * with open addressing + chaining for collision handling
46
+ * 3. `sig.equals()` does per-field comparison when hash collisions occur
47
+ *
48
+ * This eliminates the `list: string[]` storage of `toMapKey()` strings (~500 KB-1 MB
49
+ * for 10k-level signatures) and avoids repeated string concatenation in `toMapKey()`.
50
+ *
51
+ * IDs are dense integers starting from 0.
52
+ *
53
+ * @template S - The signature type, must implement {@link Canonicalizable}
54
+ */
55
+ export declare class SignatureCanonicalizer<S extends Canonicalizable> {
56
+ private canonicalizer;
57
+ /**
58
+ * Get the unique integer ID for a signature.
59
+ * If a signature with the same hash and `equals()` result has been seen before, returns the existing ID.
60
+ * Otherwise, assigns a new ID and records the signature as the canonical instance.
61
+ *
62
+ * @param sig - The signature to canonicalize
63
+ * @returns The integer ID (>= 0)
64
+ */
65
+ getOrCreateId(sig: S): number;
66
+ /**
67
+ * Get the integer ID of a signature if it already exists.
68
+ * Returns -1 if the signature has not been canonicalized.
69
+ * Does not create a new ID or modify internal state.
70
+ *
71
+ * @param sig - The signature to query
72
+ * @returns The integer ID (>= 0) if found, -1 otherwise
73
+ */
74
+ getExistingId(sig: S): number;
75
+ /**
76
+ * Get the canonical signature instance associated with an integer ID.
77
+ *
78
+ * @param id - The integer ID
79
+ * @returns The canonical signature instance, or `undefined` if the ID is out of bounds
80
+ */
81
+ get(id: number): S | undefined;
82
+ /**
83
+ * Get the total number of unique signatures registered so far.
84
+ */
85
+ size(): number;
86
+ /**
87
+ * Get hash table statistics (for debugging/profiling).
88
+ */
89
+ getStats(): import("../../utils/Canonicalizer").CanonicalizerStats;
90
+ /**
91
+ * Clear all registered signatures and reset the canonicalizer.
92
+ */
93
+ clear(): void;
94
+ }
95
+ //# sourceMappingURL=SignatureCanonicalizer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SignatureCanonicalizer.d.ts","sourceRoot":"","sources":["../../../src/core/common/SignatureCanonicalizer.ts"],"names":[],"mappings":"AAiBA;;;;;;;GAOG;AACH,MAAM,WAAW,eAAe;IAC5B,kFAAkF;IAClF,WAAW,IAAI,MAAM,CAAC;IACtB,mEAAmE;IACnE,MAAM,CAAC,KAAK,EAAE,IAAI,GAAG,OAAO,CAAC;CAChC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,eAAe,EAAE,CAAC,EAAE,eAAe,GAAG,OAAO,CAE/E;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,sBAAsB,CAAC,CAAC,SAAS,eAAe;IACzD,OAAO,CAAC,aAAa,CAGnB;IAEF;;;;;;;OAOG;IACI,aAAa,CAAC,GAAG,EAAE,CAAC,GAAG,MAAM;IAIpC;;;;;;;OAOG;IACI,aAAa,CAAC,GAAG,EAAE,CAAC,GAAG,MAAM;IAIpC;;;;;OAKG;IACI,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAIrC;;OAEG;IACI,IAAI,IAAI,MAAM;IAIrB;;OAEG;IACI,QAAQ;IAIf;;OAEG;IACI,KAAK,IAAI,IAAI;CAGvB"}
@@ -0,0 +1,116 @@
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.SignatureCanonicalizer = exports.signatureEquals = void 0;
18
+ const Canonicalizer_1 = require("../../utils/Canonicalizer");
19
+ /**
20
+ * Value-semantic identity comparison between two signatures:
21
+ * cached-hash fast reject + `equals()` final verdict.
22
+ *
23
+ * Execution rules: the hash comparison short-circuits only comparisons whose
24
+ * result is "unequal"; comparisons whose result is "equal" necessarily run
25
+ * `equals()` (the Canonicalizable contract "equals ⇒ same hash" guarantees the
26
+ * hashes match), where canonical instances short-circuit on the first line
27
+ * (`this === other`). This is the same hash-then-equals protocol the
28
+ * canonicalizer probe uses internally — running it once directly between the
29
+ * two objects, instead of twice (once per probe) plus an ID comparison, and
30
+ * without depending on registration state.
31
+ *
32
+ * Why not compare canonicalizer IDs ("same ID ⇒ equal")? IDs are a function
33
+ * of value × registration history, not of value alone: two unregistered
34
+ * signatures (e.g. temp stubs) both yield getExistingId() === -1 and would be
35
+ * wrongly judged equal; one registered + one unregistered would be wrongly
36
+ * judged unequal; and the getId() variant would blind-write unregistered
37
+ * values into the formal space (permanent holes, see the temp-space design).
38
+ *
39
+ * No string building, no string hashing.
40
+ */
41
+ function signatureEquals(a, b) {
42
+ return a.getHashCode() === b.getHashCode() && a.equals(b);
43
+ }
44
+ exports.signatureEquals = signatureEquals;
45
+ /**
46
+ * A canonicalizer that deduplicates signatures by value semantics using hash + equals.
47
+ *
48
+ * Uses a three-layer hash-collision-handling architecture:
49
+ *
50
+ * 1. `sig.getHashCode()` returns a cached 32-bit hash (computed once at construction)
51
+ * 2. `Canonicalizer<S>` with `numberWithEquality` strategy uses TypedArray hash tables
52
+ * with open addressing + chaining for collision handling
53
+ * 3. `sig.equals()` does per-field comparison when hash collisions occur
54
+ *
55
+ * This eliminates the `list: string[]` storage of `toMapKey()` strings (~500 KB-1 MB
56
+ * for 10k-level signatures) and avoids repeated string concatenation in `toMapKey()`.
57
+ *
58
+ * IDs are dense integers starting from 0.
59
+ *
60
+ * @template S - The signature type, must implement {@link Canonicalizable}
61
+ */
62
+ class SignatureCanonicalizer {
63
+ constructor() {
64
+ this.canonicalizer = new Canonicalizer_1.Canonicalizer((s) => s.getHashCode(), (a, b) => a.equals(b));
65
+ }
66
+ /**
67
+ * Get the unique integer ID for a signature.
68
+ * If a signature with the same hash and `equals()` result has been seen before, returns the existing ID.
69
+ * Otherwise, assigns a new ID and records the signature as the canonical instance.
70
+ *
71
+ * @param sig - The signature to canonicalize
72
+ * @returns The integer ID (>= 0)
73
+ */
74
+ getOrCreateId(sig) {
75
+ return this.canonicalizer.getId(sig);
76
+ }
77
+ /**
78
+ * Get the integer ID of a signature if it already exists.
79
+ * Returns -1 if the signature has not been canonicalized.
80
+ * Does not create a new ID or modify internal state.
81
+ *
82
+ * @param sig - The signature to query
83
+ * @returns The integer ID (>= 0) if found, -1 otherwise
84
+ */
85
+ getExistingId(sig) {
86
+ return this.canonicalizer.getExistingId(sig);
87
+ }
88
+ /**
89
+ * Get the canonical signature instance associated with an integer ID.
90
+ *
91
+ * @param id - The integer ID
92
+ * @returns The canonical signature instance, or `undefined` if the ID is out of bounds
93
+ */
94
+ get(id) {
95
+ return this.canonicalizer.get(id);
96
+ }
97
+ /**
98
+ * Get the total number of unique signatures registered so far.
99
+ */
100
+ size() {
101
+ return this.canonicalizer.size();
102
+ }
103
+ /**
104
+ * Get hash table statistics (for debugging/profiling).
105
+ */
106
+ getStats() {
107
+ return this.canonicalizer.getStats();
108
+ }
109
+ /**
110
+ * Clear all registered signatures and reset the canonicalizer.
111
+ */
112
+ clear() {
113
+ this.canonicalizer.clear();
114
+ }
115
+ }
116
+ exports.SignatureCanonicalizer = SignatureCanonicalizer;