adnbn 0.9.0 → 0.11.0

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 (608) hide show
  1. package/dist/cli/builders/locale/LocaleBuilder.js +2 -11
  2. package/dist/cli/builders/locale/LocaleBuilder.js.map +1 -1
  3. package/dist/cli/builders/locale/index.js +1 -1
  4. package/dist/cli/builders/locale/index.js.map +1 -1
  5. package/dist/cli/builders/manifest/ManifestBase.d.ts +4 -1
  6. package/dist/cli/builders/manifest/ManifestBase.js +35 -6
  7. package/dist/cli/builders/manifest/ManifestBase.js.map +1 -1
  8. package/dist/cli/builders/manifest/ManifestV2.js +1 -1
  9. package/dist/cli/builders/manifest/ManifestV3.js +12 -5
  10. package/dist/cli/builders/manifest/ManifestV3.js.map +1 -1
  11. package/dist/cli/builders/manifest/utils/data-collection-permissions.d.ts +15 -0
  12. package/dist/cli/builders/manifest/utils/data-collection-permissions.js +26 -0
  13. package/dist/cli/builders/manifest/utils/data-collection-permissions.js.map +1 -0
  14. package/dist/cli/builders/manifest/utils/host-patterns.d.ts +1 -0
  15. package/dist/cli/builders/manifest/utils/host-patterns.js +40 -0
  16. package/dist/cli/builders/manifest/utils/host-patterns.js.map +1 -0
  17. package/dist/cli/builders/manifest/utils/index.d.ts +4 -0
  18. package/dist/cli/builders/manifest/utils/index.js +19 -0
  19. package/dist/cli/builders/manifest/utils/index.js.map +1 -0
  20. package/dist/cli/builders/manifest/utils/permissions.d.ts +14 -0
  21. package/dist/cli/builders/manifest/utils/permissions.js +34 -0
  22. package/dist/cli/builders/manifest/utils/permissions.js.map +1 -0
  23. package/dist/cli/builders/manifest/utils/web-accessible-resources.d.ts +2 -0
  24. package/dist/cli/builders/manifest/utils/web-accessible-resources.js +92 -0
  25. package/dist/cli/builders/manifest/utils/web-accessible-resources.js.map +1 -0
  26. package/dist/cli/bundler/plugins/build-assets-map/BuildAssetsMapPlugin.d.ts +14 -0
  27. package/dist/cli/bundler/plugins/build-assets-map/BuildAssetsMapPlugin.js +523 -0
  28. package/dist/cli/bundler/plugins/build-assets-map/BuildAssetsMapPlugin.js.map +1 -0
  29. package/dist/cli/bundler/plugins/build-assets-map/entrypoint-module.d.ts +13 -0
  30. package/dist/cli/bundler/plugins/build-assets-map/entrypoint-module.js +16 -0
  31. package/dist/cli/bundler/plugins/build-assets-map/entrypoint-module.js.map +1 -0
  32. package/dist/cli/bundler/plugins/build-assets-map/index.d.ts +3 -0
  33. package/dist/cli/bundler/plugins/build-assets-map/index.js +8 -0
  34. package/dist/cli/bundler/plugins/build-assets-map/index.js.map +1 -0
  35. package/dist/cli/bundler/plugins/build-assets-map/usage.d.ts +12 -0
  36. package/dist/cli/bundler/plugins/build-assets-map/usage.js +28 -0
  37. package/dist/cli/bundler/plugins/build-assets-map/usage.js.map +1 -0
  38. package/dist/cli/bundler/plugins/chunk-loader/ChunkLoaderPlugin.d.ts +9 -0
  39. package/dist/cli/bundler/plugins/chunk-loader/ChunkLoaderPlugin.js +43 -0
  40. package/dist/cli/bundler/plugins/chunk-loader/ChunkLoaderPlugin.js.map +1 -0
  41. package/dist/cli/bundler/plugins/chunk-loader/index.d.ts +1 -0
  42. package/dist/cli/bundler/plugins/chunk-loader/index.js +5 -0
  43. package/dist/cli/bundler/plugins/chunk-loader/index.js.map +1 -0
  44. package/dist/cli/bundler/plugins/chunk-loader/templates/runtime.template.d.ts +2 -0
  45. package/dist/cli/bundler/plugins/chunk-loader/templates.d.ts +7 -0
  46. package/dist/cli/bundler/plugins/chunk-loader/templates.js +30 -0
  47. package/dist/cli/bundler/plugins/{EntrypointPlugin.d.ts → entrypoint/EntrypointPlugin.d.ts} +7 -2
  48. package/dist/cli/bundler/plugins/{EntrypointPlugin.js → entrypoint/EntrypointPlugin.js} +46 -26
  49. package/dist/cli/bundler/plugins/entrypoint/EntrypointPlugin.js.map +1 -0
  50. package/dist/cli/bundler/plugins/entrypoint/index.d.ts +1 -0
  51. package/dist/cli/bundler/plugins/entrypoint/index.js +7 -0
  52. package/dist/cli/bundler/plugins/entrypoint/index.js.map +1 -0
  53. package/dist/cli/bundler/plugins/{GenerateJsonPlugin.d.ts → generate-json/GenerateJsonPlugin.d.ts} +1 -0
  54. package/dist/cli/bundler/plugins/generate-json/GenerateJsonPlugin.js +73 -0
  55. package/dist/cli/bundler/plugins/generate-json/GenerateJsonPlugin.js.map +1 -0
  56. package/dist/cli/bundler/plugins/generate-json/index.d.ts +1 -0
  57. package/dist/cli/bundler/plugins/generate-json/index.js +5 -0
  58. package/dist/cli/bundler/plugins/generate-json/index.js.map +1 -0
  59. package/dist/cli/bundler/plugins/generate-module/GenerateModulePlugin.d.ts +23 -0
  60. package/dist/cli/bundler/plugins/generate-module/GenerateModulePlugin.js +88 -0
  61. package/dist/cli/bundler/plugins/generate-module/GenerateModulePlugin.js.map +1 -0
  62. package/dist/cli/bundler/plugins/generate-module/index.d.ts +1 -0
  63. package/dist/cli/bundler/plugins/generate-module/index.js +7 -0
  64. package/dist/cli/bundler/plugins/generate-module/index.js.map +1 -0
  65. package/dist/cli/bundler/plugins/index.d.ts +11 -5
  66. package/dist/cli/bundler/plugins/index.js +32 -10
  67. package/dist/cli/bundler/plugins/index.js.map +1 -1
  68. package/dist/cli/bundler/plugins/isolated-styles/IsolatedStylesPlugin.d.ts +21 -0
  69. package/dist/cli/bundler/plugins/isolated-styles/IsolatedStylesPlugin.js +174 -0
  70. package/dist/cli/bundler/plugins/isolated-styles/IsolatedStylesPlugin.js.map +1 -0
  71. package/dist/cli/bundler/plugins/isolated-styles/index.d.ts +1 -0
  72. package/dist/cli/bundler/plugins/isolated-styles/index.js +5 -0
  73. package/dist/cli/bundler/plugins/isolated-styles/index.js.map +1 -0
  74. package/dist/cli/bundler/plugins/isolated-styles/templates/css-loader.template.d.ts +1 -0
  75. package/dist/cli/bundler/plugins/isolated-styles/templates/runtime.template.d.ts +7 -0
  76. package/dist/cli/bundler/plugins/isolated-styles/templates.d.ts +18 -0
  77. package/dist/cli/bundler/plugins/isolated-styles/templates.js +174 -0
  78. package/dist/cli/bundler/plugins/manifest/ManifestPlugin.d.ts +10 -0
  79. package/dist/cli/bundler/plugins/manifest/ManifestPlugin.js +55 -0
  80. package/dist/cli/bundler/plugins/manifest/ManifestPlugin.js.map +1 -0
  81. package/dist/cli/bundler/plugins/manifest/index.d.ts +1 -0
  82. package/dist/cli/bundler/plugins/manifest/index.js +6 -0
  83. package/dist/cli/bundler/plugins/manifest/index.js.map +1 -0
  84. package/dist/cli/bundler/plugins/replace/ReplacePlugin.js.map +1 -0
  85. package/dist/cli/bundler/plugins/replace/index.d.ts +1 -0
  86. package/dist/cli/bundler/plugins/replace/index.js +5 -0
  87. package/dist/cli/bundler/plugins/replace/index.js.map +1 -0
  88. package/dist/cli/bundler/plugins/resource-access/ResourceAccessPlugin.d.ts +19 -0
  89. package/dist/cli/bundler/plugins/resource-access/ResourceAccessPlugin.js +20 -0
  90. package/dist/cli/bundler/plugins/resource-access/ResourceAccessPlugin.js.map +1 -0
  91. package/dist/cli/bundler/plugins/resource-access/index.d.ts +1 -0
  92. package/dist/cli/bundler/plugins/resource-access/index.js +5 -0
  93. package/dist/cli/bundler/plugins/resource-access/index.js.map +1 -0
  94. package/dist/cli/bundler/plugins/resource-access/utils.d.ts +8 -0
  95. package/dist/cli/bundler/plugins/resource-access/utils.js +42 -0
  96. package/dist/cli/bundler/plugins/resource-access/utils.js.map +1 -0
  97. package/dist/cli/bundler/plugins/types.d.ts +4 -0
  98. package/dist/cli/bundler/plugins/types.js +1 -0
  99. package/dist/cli/bundler/plugins/types.js.map +1 -0
  100. package/dist/cli/bundler/plugins/utils/index.d.ts +3 -0
  101. package/dist/cli/bundler/plugins/utils/index.js +9 -0
  102. package/dist/cli/bundler/plugins/utils/index.js.map +1 -0
  103. package/dist/cli/bundler/plugins/utils/manifest-hooks.d.ts +13 -0
  104. package/dist/cli/bundler/plugins/utils/manifest-hooks.js +17 -0
  105. package/dist/cli/bundler/plugins/utils/manifest-hooks.js.map +1 -0
  106. package/dist/cli/bundler/plugins/utils/runtime-template.d.ts +1 -0
  107. package/dist/cli/bundler/plugins/utils/runtime-template.js +18 -0
  108. package/dist/cli/bundler/plugins/utils/runtime-template.js.map +1 -0
  109. package/dist/cli/bundler/plugins/utils/watch-compilation.d.ts +3 -0
  110. package/dist/cli/bundler/plugins/utils/watch-compilation.js +18 -0
  111. package/dist/cli/bundler/plugins/utils/watch-compilation.js.map +1 -0
  112. package/dist/cli/bundler/plugins/watch/WatchPlugin.js +16 -0
  113. package/dist/cli/bundler/plugins/watch/WatchPlugin.js.map +1 -0
  114. package/dist/cli/bundler/plugins/watch/index.d.ts +1 -0
  115. package/dist/cli/bundler/plugins/watch/index.js +5 -0
  116. package/dist/cli/bundler/plugins/watch/index.js.map +1 -0
  117. package/dist/cli/bundler/utils/chunk-filename.d.ts +6 -0
  118. package/dist/cli/bundler/utils/chunk-filename.js +93 -0
  119. package/dist/cli/bundler/utils/chunk-filename.js.map +1 -0
  120. package/dist/cli/bundler/utils/index.d.ts +2 -0
  121. package/dist/cli/bundler/utils/index.js +2 -0
  122. package/dist/cli/bundler/utils/index.js.map +1 -1
  123. package/dist/cli/bundler/utils/layers.d.ts +4 -0
  124. package/dist/cli/bundler/utils/layers.js +10 -0
  125. package/dist/cli/bundler/utils/layers.js.map +1 -0
  126. package/dist/cli/bundler/utils/output.d.ts +6 -2
  127. package/dist/cli/bundler/utils/output.js +165 -7
  128. package/dist/cli/bundler/utils/output.js.map +1 -1
  129. package/dist/cli/bundler/utils/styles.d.ts +5 -0
  130. package/dist/cli/bundler/utils/styles.js +30 -0
  131. package/dist/cli/bundler/utils/styles.js.map +1 -0
  132. package/dist/cli/entrypoint/file/ExpressionFile.d.ts +4 -1
  133. package/dist/cli/entrypoint/file/ExpressionFile.js +11 -0
  134. package/dist/cli/entrypoint/file/ExpressionFile.js.map +1 -1
  135. package/dist/cli/entrypoint/file/OptionFile.d.ts +4 -2
  136. package/dist/cli/entrypoint/file/OptionFile.js +35 -31
  137. package/dist/cli/entrypoint/file/OptionFile.js.map +1 -1
  138. package/dist/cli/entrypoint/file/SourceFile.d.ts +18 -7
  139. package/dist/cli/entrypoint/file/SourceFile.js +260 -156
  140. package/dist/cli/entrypoint/file/SourceFile.js.map +1 -1
  141. package/dist/cli/entrypoint/file/index.d.ts +2 -0
  142. package/dist/cli/entrypoint/file/index.js +2 -0
  143. package/dist/cli/entrypoint/file/index.js.map +1 -1
  144. package/dist/cli/entrypoint/file/injectors/core.js +22 -1
  145. package/dist/cli/entrypoint/file/injectors/core.js.map +1 -1
  146. package/dist/cli/entrypoint/file/parsers/ExportParser.d.ts +14 -0
  147. package/dist/cli/entrypoint/file/parsers/ExportParser.js +71 -0
  148. package/dist/cli/entrypoint/file/parsers/ExportParser.js.map +1 -0
  149. package/dist/cli/entrypoint/file/parsers/NodeFinder.d.ts +2 -0
  150. package/dist/cli/entrypoint/file/parsers/NodeFinder.js +9 -0
  151. package/dist/cli/entrypoint/file/parsers/NodeFinder.js.map +1 -1
  152. package/dist/cli/entrypoint/file/parsers/ObjectParser.js +5 -1
  153. package/dist/cli/entrypoint/file/parsers/ObjectParser.js.map +1 -1
  154. package/dist/cli/entrypoint/file/parsers/index.d.ts +1 -0
  155. package/dist/cli/entrypoint/file/parsers/index.js +2 -0
  156. package/dist/cli/entrypoint/file/parsers/index.js.map +1 -1
  157. package/dist/cli/entrypoint/file/parsers/types.d.ts +16 -0
  158. package/dist/cli/entrypoint/file/parsers/types.js +13 -0
  159. package/dist/cli/entrypoint/file/parsers/types.js.map +1 -1
  160. package/dist/cli/entrypoint/file/resolvers/ImportResolver.d.ts +1 -0
  161. package/dist/cli/entrypoint/file/resolvers/ImportResolver.js +3 -0
  162. package/dist/cli/entrypoint/file/resolvers/ImportResolver.js.map +1 -1
  163. package/dist/cli/entrypoint/file/types.d.ts +26 -1
  164. package/dist/cli/entrypoint/finder/AbstractEntrypointFinder.d.ts +2 -2
  165. package/dist/cli/entrypoint/finder/AbstractEntrypointFinder.js +2 -2
  166. package/dist/cli/entrypoint/finder/AbstractEntrypointFinder.js.map +1 -1
  167. package/dist/cli/entrypoint/finder/{AbstractOptionsFinder.js → AbstractParsedFinder.js} +3 -3
  168. package/dist/cli/entrypoint/finder/AbstractParsedFinder.js.map +1 -0
  169. package/dist/cli/entrypoint/finder/OptionsFinder.d.ts +13 -0
  170. package/dist/cli/entrypoint/finder/OptionsFinder.js +33 -0
  171. package/dist/cli/entrypoint/finder/OptionsFinder.js.map +1 -0
  172. package/dist/cli/entrypoint/finder/PluginFinder.d.ts +4 -4
  173. package/dist/cli/entrypoint/finder/PluginFinder.js +2 -2
  174. package/dist/cli/entrypoint/finder/PluginFinder.js.map +1 -1
  175. package/dist/cli/entrypoint/finder/index.d.ts +2 -1
  176. package/dist/cli/entrypoint/finder/index.js +20 -18
  177. package/dist/cli/entrypoint/finder/index.js.map +1 -1
  178. package/dist/cli/entrypoint/parser/AbstractParser.d.ts +3 -2
  179. package/dist/cli/entrypoint/parser/AbstractParser.js +6 -3
  180. package/dist/cli/entrypoint/parser/AbstractParser.js.map +1 -1
  181. package/dist/cli/entrypoint/parser/CommandParser.js +1 -1
  182. package/dist/cli/entrypoint/parser/CommandParser.js.map +1 -1
  183. package/dist/cli/entrypoint/parser/ContentParser.d.ts +5 -1
  184. package/dist/cli/entrypoint/parser/ContentParser.js +55 -3
  185. package/dist/cli/entrypoint/parser/ContentParser.js.map +1 -1
  186. package/dist/cli/entrypoint/parser/OptionsParser.d.ts +6 -0
  187. package/dist/cli/entrypoint/parser/OptionsParser.js +16 -0
  188. package/dist/cli/entrypoint/parser/OptionsParser.js.map +1 -0
  189. package/dist/cli/entrypoint/parser/RelayParser.d.ts +21 -2
  190. package/dist/cli/entrypoint/parser/RelayParser.js +4 -0
  191. package/dist/cli/entrypoint/parser/RelayParser.js.map +1 -1
  192. package/dist/cli/entrypoint/parser/index.d.ts +1 -0
  193. package/dist/cli/entrypoint/parser/index.js +16 -14
  194. package/dist/cli/entrypoint/parser/index.js.map +1 -1
  195. package/dist/cli/plugins/asset.js +9 -4
  196. package/dist/cli/plugins/asset.js.map +1 -1
  197. package/dist/cli/plugins/background/index.js +1 -1
  198. package/dist/cli/plugins/background/index.js.map +1 -1
  199. package/dist/cli/plugins/content/Content.d.ts +1 -1
  200. package/dist/cli/plugins/content/Content.js +3 -2
  201. package/dist/cli/plugins/content/Content.js.map +1 -1
  202. package/dist/cli/plugins/content/ContentManager.d.ts +8 -5
  203. package/dist/cli/plugins/content/ContentManager.js +79 -28
  204. package/dist/cli/plugins/content/ContentManager.js.map +1 -1
  205. package/dist/cli/plugins/content/ContentName.d.ts +1 -1
  206. package/dist/cli/plugins/content/ContentName.js +8 -7
  207. package/dist/cli/plugins/content/ContentName.js.map +1 -1
  208. package/dist/cli/plugins/content/Relay.d.ts +1 -1
  209. package/dist/cli/plugins/content/Relay.js +3 -2
  210. package/dist/cli/plugins/content/Relay.js.map +1 -1
  211. package/dist/cli/plugins/content/bundler.d.ts +7 -0
  212. package/dist/cli/plugins/content/bundler.js +47 -0
  213. package/dist/cli/plugins/content/bundler.js.map +1 -0
  214. package/dist/cli/plugins/content/index.js +121 -62
  215. package/dist/cli/plugins/content/index.js.map +1 -1
  216. package/dist/cli/plugins/content/relay-module.d.ts +3 -0
  217. package/dist/cli/plugins/content/relay-module.js +11 -0
  218. package/dist/cli/plugins/content/relay-module.js.map +1 -0
  219. package/dist/cli/plugins/content/types.d.ts +1 -1
  220. package/dist/cli/plugins/content/utils.d.ts +2 -0
  221. package/dist/cli/plugins/content/utils.js +8 -1
  222. package/dist/cli/plugins/content/utils.js.map +1 -1
  223. package/dist/cli/plugins/icon/declaration/IconDeclaration.d.ts +1 -1
  224. package/dist/cli/plugins/icon/declaration/IconDeclaration.js +6 -6
  225. package/dist/cli/plugins/icon/declaration/IconDeclaration.js.map +1 -1
  226. package/dist/cli/plugins/icon/declaration/icon.d.ts +3 -5
  227. package/dist/cli/plugins/icon/icon-module.d.ts +2 -0
  228. package/dist/cli/plugins/icon/icon-module.js +11 -0
  229. package/dist/cli/plugins/icon/icon-module.js.map +1 -0
  230. package/dist/cli/plugins/icon/index.js +5 -3
  231. package/dist/cli/plugins/icon/index.js.map +1 -1
  232. package/dist/cli/plugins/index.d.ts +1 -0
  233. package/dist/cli/plugins/index.js +22 -20
  234. package/dist/cli/plugins/index.js.map +1 -1
  235. package/dist/cli/plugins/locale/Locale.d.ts +9 -2
  236. package/dist/cli/plugins/locale/Locale.js +37 -5
  237. package/dist/cli/plugins/locale/Locale.js.map +1 -1
  238. package/dist/cli/plugins/locale/declaration/locale.d.ts +1 -1
  239. package/dist/cli/plugins/locale/index.js +57 -22
  240. package/dist/cli/plugins/locale/index.js.map +1 -1
  241. package/dist/cli/plugins/locale/locale-module.d.ts +4 -0
  242. package/dist/cli/plugins/locale/locale-module.js +16 -0
  243. package/dist/cli/plugins/locale/locale-module.js.map +1 -0
  244. package/dist/cli/plugins/offscreen/Offscreen.d.ts +2 -3
  245. package/dist/cli/plugins/offscreen/Offscreen.js.map +1 -1
  246. package/dist/cli/plugins/offscreen/index.js +5 -4
  247. package/dist/cli/plugins/offscreen/index.js.map +1 -1
  248. package/dist/cli/plugins/offscreen/offscreen-module.d.ts +3 -0
  249. package/dist/cli/plugins/offscreen/offscreen-module.js +11 -0
  250. package/dist/cli/plugins/offscreen/offscreen-module.js.map +1 -0
  251. package/dist/cli/plugins/options/Options.d.ts +10 -0
  252. package/dist/cli/plugins/options/Options.js +24 -0
  253. package/dist/cli/plugins/options/Options.js.map +1 -0
  254. package/dist/cli/plugins/options/index.d.ts +2 -0
  255. package/dist/cli/plugins/options/index.js +41 -0
  256. package/dist/cli/plugins/options/index.js.map +1 -0
  257. package/dist/cli/plugins/output.js +33 -3
  258. package/dist/cli/plugins/output.js.map +1 -1
  259. package/dist/cli/plugins/page/declaration/PageDeclaration.js +4 -4
  260. package/dist/cli/plugins/page/declaration/PageDeclaration.js.map +1 -1
  261. package/dist/cli/plugins/page/declaration/page.d.ts +3 -3
  262. package/dist/cli/plugins/page/index.js +14 -10
  263. package/dist/cli/plugins/page/index.js.map +1 -1
  264. package/dist/cli/plugins/page/page-module.d.ts +2 -0
  265. package/dist/cli/plugins/page/page-module.js +11 -0
  266. package/dist/cli/plugins/page/page-module.js.map +1 -0
  267. package/dist/cli/plugins/popup/Popup.d.ts +1 -1
  268. package/dist/cli/plugins/popup/Popup.js +2 -2
  269. package/dist/cli/plugins/popup/Popup.js.map +1 -1
  270. package/dist/cli/plugins/popup/declaration/PopupDeclaration.d.ts +1 -1
  271. package/dist/cli/plugins/popup/declaration/PopupDeclaration.js +6 -6
  272. package/dist/cli/plugins/popup/declaration/PopupDeclaration.js.map +1 -1
  273. package/dist/cli/plugins/popup/declaration/popup.d.ts +3 -3
  274. package/dist/cli/plugins/popup/index.js +6 -5
  275. package/dist/cli/plugins/popup/index.js.map +1 -1
  276. package/dist/cli/plugins/popup/popup-module.d.ts +3 -0
  277. package/dist/cli/plugins/popup/popup-module.js +11 -0
  278. package/dist/cli/plugins/popup/popup-module.js.map +1 -0
  279. package/dist/cli/plugins/sandbox/Sandbox.d.ts +1 -2
  280. package/dist/cli/plugins/sandbox/Sandbox.js.map +1 -1
  281. package/dist/cli/plugins/sandbox/index.js +5 -4
  282. package/dist/cli/plugins/sandbox/index.js.map +1 -1
  283. package/dist/cli/plugins/sandbox/sandbox-module.d.ts +3 -0
  284. package/dist/cli/plugins/sandbox/sandbox-module.js +11 -0
  285. package/dist/cli/plugins/sandbox/sandbox-module.js.map +1 -0
  286. package/dist/cli/plugins/sidebar/Sidebar.d.ts +1 -1
  287. package/dist/cli/plugins/sidebar/Sidebar.js +2 -2
  288. package/dist/cli/plugins/sidebar/Sidebar.js.map +1 -1
  289. package/dist/cli/plugins/sidebar/declaration/SidebarDeclaration.d.ts +1 -1
  290. package/dist/cli/plugins/sidebar/declaration/SidebarDeclaration.js +6 -6
  291. package/dist/cli/plugins/sidebar/declaration/SidebarDeclaration.js.map +1 -1
  292. package/dist/cli/plugins/sidebar/declaration/sidebar.d.ts +3 -3
  293. package/dist/cli/plugins/sidebar/index.js +6 -5
  294. package/dist/cli/plugins/sidebar/index.js.map +1 -1
  295. package/dist/cli/plugins/sidebar/sidebar-module.d.ts +3 -0
  296. package/dist/cli/plugins/sidebar/sidebar-module.js +11 -0
  297. package/dist/cli/plugins/sidebar/sidebar-module.js.map +1 -0
  298. package/dist/cli/plugins/style/index.d.ts +2 -1
  299. package/dist/cli/plugins/style/index.js +52 -25
  300. package/dist/cli/plugins/style/index.js.map +1 -1
  301. package/dist/cli/plugins/style/types.d.ts +5 -0
  302. package/dist/cli/plugins/style/types.js +1 -0
  303. package/dist/cli/plugins/style/types.js.map +1 -0
  304. package/dist/cli/plugins/view/index.js +1 -1
  305. package/dist/cli/plugins/view/index.js.map +1 -1
  306. package/dist/cli/raw.d.ts +4 -0
  307. package/dist/cli/resolvers/bundler.js +9 -7
  308. package/dist/cli/resolvers/bundler.js.map +1 -1
  309. package/dist/cli/resolvers/config.js +4 -1
  310. package/dist/cli/resolvers/config.js.map +1 -1
  311. package/dist/cli/virtual/index.d.ts +2 -2
  312. package/dist/cli/virtual/index.js +11 -8
  313. package/dist/cli/virtual/virtual.d.ts +8 -10
  314. package/dist/entry/content/adapters/react/Builder.js +1 -1
  315. package/dist/entry/content/adapters/react/Builder.js.map +1 -1
  316. package/dist/entry/content/adapters/react/Node.d.ts +2 -0
  317. package/dist/entry/content/adapters/react/Node.js +10 -2
  318. package/dist/entry/content/adapters/react/Node.js.map +1 -1
  319. package/dist/entry/content/adapters/vanilla/Builder.js +1 -1
  320. package/dist/entry/content/adapters/vanilla/Builder.js.map +1 -1
  321. package/dist/entry/content/adapters/vanilla/Node.d.ts +2 -1
  322. package/dist/entry/content/adapters/vanilla/Node.js +10 -7
  323. package/dist/entry/content/adapters/vanilla/Node.js.map +1 -1
  324. package/dist/entry/content/core/Builder.d.ts +1 -2
  325. package/dist/entry/content/core/Builder.js +9 -5
  326. package/dist/entry/content/core/Builder.js.map +1 -1
  327. package/dist/entry/content/core/MountBuilder.js +14 -6
  328. package/dist/entry/content/core/MountBuilder.js.map +1 -1
  329. package/dist/entry/content/core/{Context.d.ts → context/Context.d.ts} +2 -1
  330. package/dist/entry/content/core/{Context.js → context/Context.js} +7 -0
  331. package/dist/entry/content/core/context/Context.js.map +1 -0
  332. package/dist/entry/content/core/{EventEmitter.d.ts → context/EventEmitter.d.ts} +1 -1
  333. package/dist/entry/content/core/{EventEmitter.js → context/EventEmitter.js} +1 -1
  334. package/dist/entry/content/core/context/EventEmitter.js.map +1 -0
  335. package/dist/entry/content/core/{ManagedContext.d.ts → context/ManagedContext.d.ts} +1 -1
  336. package/dist/entry/content/core/context/ManagedContext.js.map +1 -0
  337. package/dist/entry/content/core/context/index.d.ts +3 -0
  338. package/dist/entry/content/core/context/index.js +9 -0
  339. package/dist/entry/content/core/context/index.js.map +1 -0
  340. package/dist/entry/content/core/{AbstractMarker.d.ts → markers/AbstractMarker.d.ts} +1 -1
  341. package/dist/entry/content/core/{AbstractMarker.js → markers/AbstractMarker.js} +1 -1
  342. package/dist/entry/content/core/markers/AbstractMarker.js.map +1 -0
  343. package/dist/entry/content/core/{AttributeMarker.d.ts → markers/AttributeMarker.d.ts} +1 -1
  344. package/dist/entry/content/core/markers/AttributeMarker.js.map +1 -0
  345. package/dist/entry/content/core/{WeakMarker.d.ts → markers/WeakMarker.d.ts} +1 -1
  346. package/dist/entry/content/core/markers/WeakMarker.js.map +1 -0
  347. package/dist/entry/content/core/markers/index.d.ts +3 -0
  348. package/dist/entry/content/core/markers/index.js +9 -0
  349. package/dist/entry/content/core/markers/index.js.map +1 -0
  350. package/dist/entry/content/core/{EventNode.d.ts → nodes/EventNode.d.ts} +2 -1
  351. package/dist/entry/content/core/{EventNode.js → nodes/EventNode.js} +3 -0
  352. package/dist/entry/content/core/nodes/EventNode.js.map +1 -0
  353. package/dist/entry/content/core/nodes/FrameNode.d.ts +23 -0
  354. package/dist/entry/content/core/nodes/FrameNode.js +125 -0
  355. package/dist/entry/content/core/nodes/FrameNode.js.map +1 -0
  356. package/dist/entry/content/core/{MarkerNode.d.ts → nodes/MarkerNode.d.ts} +2 -1
  357. package/dist/entry/content/core/{MarkerNode.js → nodes/MarkerNode.js} +3 -0
  358. package/dist/entry/content/core/nodes/MarkerNode.js.map +1 -0
  359. package/dist/entry/content/core/{MountNode.d.ts → nodes/MountNode.d.ts} +2 -1
  360. package/dist/entry/content/core/{MountNode.js → nodes/MountNode.js} +3 -0
  361. package/dist/entry/content/core/nodes/MountNode.js.map +1 -0
  362. package/dist/entry/content/core/{Node.d.ts → nodes/Node.d.ts} +2 -1
  363. package/dist/entry/content/core/{Node.js → nodes/Node.js} +3 -0
  364. package/dist/entry/content/core/nodes/Node.js.map +1 -0
  365. package/dist/entry/content/core/nodes/ShadowNode.d.ts +14 -0
  366. package/dist/entry/content/core/nodes/ShadowNode.js +67 -0
  367. package/dist/entry/content/core/nodes/ShadowNode.js.map +1 -0
  368. package/dist/entry/content/core/nodes/index.d.ts +6 -0
  369. package/dist/entry/content/core/nodes/index.js +15 -0
  370. package/dist/entry/content/core/nodes/index.js.map +1 -0
  371. package/dist/entry/content/core/nodes/isolated-styles.d.ts +2 -0
  372. package/dist/entry/content/core/nodes/isolated-styles.js +14 -0
  373. package/dist/entry/content/core/nodes/isolated-styles.js.map +1 -0
  374. package/dist/entry/content/core/resolvers/watch.js +1 -1
  375. package/dist/entry/content/core/resolvers/watch.js.map +1 -1
  376. package/dist/entry/content/frame/Builder.d.ts +7 -0
  377. package/dist/entry/content/frame/Builder.js +14 -0
  378. package/dist/entry/content/frame/Builder.js.map +1 -0
  379. package/dist/entry/content/frame/index.d.ts +4 -0
  380. package/dist/entry/content/frame/index.js +7 -0
  381. package/dist/entry/content/frame/index.js.map +1 -0
  382. package/dist/entry/relay/Builder.js +5 -1
  383. package/dist/entry/relay/Builder.js.map +1 -1
  384. package/dist/entry/relay/index.d.ts +1 -1
  385. package/dist/locale/adapters/react/ReactLocale.d.ts +18 -0
  386. package/dist/locale/adapters/react/ReactLocale.js +41 -0
  387. package/dist/locale/adapters/react/ReactLocale.js.map +1 -0
  388. package/dist/locale/adapters/react/hooks/use-locale-attributes.d.ts +7 -0
  389. package/dist/locale/adapters/react/hooks/use-locale-attributes.js +30 -0
  390. package/dist/locale/adapters/react/hooks/use-locale-attributes.js.map +1 -0
  391. package/dist/locale/adapters/react/hooks/use-locale.d.ts +3 -0
  392. package/dist/locale/adapters/react/hooks/use-locale.js +17 -0
  393. package/dist/locale/adapters/react/hooks/use-locale.js.map +1 -0
  394. package/dist/locale/adapters/react/hooks/use-native-locale.d.ts +3 -0
  395. package/dist/locale/adapters/react/hooks/use-native-locale.js +10 -0
  396. package/dist/locale/adapters/react/hooks/use-native-locale.js.map +1 -0
  397. package/dist/locale/adapters/react/index.d.ts +4 -2
  398. package/dist/locale/adapters/react/index.js +6 -4
  399. package/dist/locale/adapters/react/index.js.map +1 -1
  400. package/dist/locale/adapters/react/types.d.ts +22 -0
  401. package/dist/locale/adapters/react/types.js +1 -0
  402. package/dist/locale/adapters/react/types.js.map +1 -0
  403. package/dist/locale/helpers.d.ts +4 -5
  404. package/dist/locale/helpers.js +1 -1
  405. package/dist/locale/helpers.js.map +1 -1
  406. package/dist/locale/index.d.ts +2 -1
  407. package/dist/locale/index.js +1 -0
  408. package/dist/locale/index.js.map +1 -1
  409. package/dist/locale/providers/AbstractLocale.d.ts +4 -4
  410. package/dist/locale/providers/AbstractLocale.js +13 -94
  411. package/dist/locale/providers/AbstractLocale.js.map +1 -1
  412. package/dist/locale/providers/CustomLocale.d.ts +3 -3
  413. package/dist/locale/providers/CustomLocale.js +6 -5
  414. package/dist/locale/providers/CustomLocale.js.map +1 -1
  415. package/dist/locale/providers/DynamicLocale.d.ts +18 -11
  416. package/dist/locale/providers/DynamicLocale.js +60 -47
  417. package/dist/locale/providers/DynamicLocale.js.map +1 -1
  418. package/dist/locale/providers/NativeLocale.d.ts +4 -7
  419. package/dist/locale/providers/NativeLocale.js +5 -14
  420. package/dist/locale/providers/NativeLocale.js.map +1 -1
  421. package/dist/locale/providers/ObservableLocale.d.ts +35 -0
  422. package/dist/locale/providers/ObservableLocale.js +179 -0
  423. package/dist/locale/providers/ObservableLocale.js.map +1 -0
  424. package/dist/locale/providers/index.d.ts +2 -1
  425. package/dist/locale/providers/index.js +3 -1
  426. package/dist/locale/providers/index.js.map +1 -1
  427. package/dist/locale/storage/LocaleStorage.d.ts +11 -0
  428. package/dist/locale/storage/LocaleStorage.js +40 -0
  429. package/dist/locale/storage/LocaleStorage.js.map +1 -0
  430. package/dist/locale/storage/index.d.ts +1 -0
  431. package/dist/locale/storage/index.js +5 -0
  432. package/dist/locale/storage/index.js.map +1 -0
  433. package/dist/main/entrypoint.d.ts +4 -0
  434. package/dist/main/entrypoint.js +20 -0
  435. package/dist/main/entrypoint.js.map +1 -0
  436. package/dist/main/icon.d.ts +2 -3
  437. package/dist/main/icon.js +2 -1
  438. package/dist/main/icon.js.map +1 -1
  439. package/dist/main/index.d.ts +2 -0
  440. package/dist/main/index.js +2 -0
  441. package/dist/main/index.js.map +1 -1
  442. package/dist/main/offscreen.d.ts +2 -5
  443. package/dist/main/offscreen.js +5 -2
  444. package/dist/main/offscreen.js.map +1 -1
  445. package/dist/main/options.d.ts +3 -0
  446. package/dist/main/options.js +7 -0
  447. package/dist/main/options.js.map +1 -0
  448. package/dist/main/page.d.ts +2 -4
  449. package/dist/main/page.js +2 -1
  450. package/dist/main/page.js.map +1 -1
  451. package/dist/main/popup.d.ts +2 -5
  452. package/dist/main/popup.js +3 -3
  453. package/dist/main/popup.js.map +1 -1
  454. package/dist/main/relay.d.ts +1 -2
  455. package/dist/main/relay.js +2 -1
  456. package/dist/main/relay.js.map +1 -1
  457. package/dist/main/sandbox.d.ts +1 -4
  458. package/dist/main/sandbox.js +2 -1
  459. package/dist/main/sandbox.js.map +1 -1
  460. package/dist/main/service.d.ts +1 -2
  461. package/dist/main/service.js.map +1 -1
  462. package/dist/main/sidebar.d.ts +2 -5
  463. package/dist/main/sidebar.js +3 -3
  464. package/dist/main/sidebar.js.map +1 -1
  465. package/dist/message/index.d.ts +2 -4
  466. package/dist/message/index.js.map +1 -1
  467. package/dist/offscreen/index.d.ts +2 -6
  468. package/dist/offscreen/index.js.map +1 -1
  469. package/dist/relay/index.d.ts +2 -5
  470. package/dist/relay/index.js.map +1 -1
  471. package/dist/sandbox/index.d.ts +1 -5
  472. package/dist/sandbox/index.js.map +1 -1
  473. package/dist/service/index.d.ts +2 -6
  474. package/dist/service/index.js.map +1 -1
  475. package/dist/shared/content/index.d.ts +1 -0
  476. package/dist/shared/content/index.js +6 -0
  477. package/dist/shared/content/index.js.map +1 -0
  478. package/dist/shared/content/isolation.d.ts +4 -0
  479. package/dist/shared/content/isolation.js +70 -0
  480. package/dist/shared/content/isolation.js.map +1 -0
  481. package/dist/shared/locale/index.d.ts +5 -0
  482. package/dist/shared/locale/index.js +21 -0
  483. package/dist/shared/locale/index.js.map +1 -0
  484. package/dist/shared/locale/keys.d.ts +5 -0
  485. package/dist/shared/locale/keys.js +33 -0
  486. package/dist/shared/locale/keys.js.map +1 -0
  487. package/dist/shared/locale/language.d.ts +4 -0
  488. package/dist/shared/locale/language.js +23 -0
  489. package/dist/shared/locale/language.js.map +1 -0
  490. package/dist/shared/locale/messages.d.ts +3 -0
  491. package/dist/shared/locale/messages.js +9 -0
  492. package/dist/shared/locale/messages.js.map +1 -0
  493. package/dist/shared/locale/plural.d.ts +2 -0
  494. package/dist/shared/locale/plural.js +81 -0
  495. package/dist/shared/locale/plural.js.map +1 -0
  496. package/dist/shared/locale/substitutions.d.ts +10 -0
  497. package/dist/shared/locale/substitutions.js +32 -0
  498. package/dist/shared/locale/substitutions.js.map +1 -0
  499. package/dist/types/background.d.ts +1 -1
  500. package/dist/types/background.js.map +1 -1
  501. package/dist/types/command.d.ts +1 -1
  502. package/dist/types/command.js.map +1 -1
  503. package/dist/types/content.d.ts +120 -31
  504. package/dist/types/content.js +22 -1
  505. package/dist/types/content.js.map +1 -1
  506. package/dist/types/entrypoint.d.ts +20 -0
  507. package/dist/types/entrypoint.js +4 -0
  508. package/dist/types/entrypoint.js.map +1 -1
  509. package/dist/types/icon.d.ts +8 -0
  510. package/dist/types/icon.js.map +1 -1
  511. package/dist/types/language.d.ts +57 -0
  512. package/dist/types/language.js +62 -0
  513. package/dist/types/language.js.map +1 -0
  514. package/dist/types/locale.d.ts +34 -63
  515. package/dist/types/locale.js +62 -119
  516. package/dist/types/locale.js.map +1 -1
  517. package/dist/types/manifest.d.ts +24 -7
  518. package/dist/types/manifest.js.map +1 -1
  519. package/dist/types/message.d.ts +7 -0
  520. package/dist/types/message.js.map +1 -1
  521. package/dist/types/offscreen.d.ts +14 -1
  522. package/dist/types/offscreen.js.map +1 -1
  523. package/dist/types/options.d.ts +9 -0
  524. package/dist/types/options.js +1 -0
  525. package/dist/types/options.js.map +1 -0
  526. package/dist/types/page.d.ts +8 -0
  527. package/dist/types/plugin.d.ts +2 -1
  528. package/dist/types/popup.d.ts +9 -0
  529. package/dist/types/relay.d.ts +16 -7
  530. package/dist/types/relay.js.map +1 -1
  531. package/dist/types/sandbox.d.ts +12 -0
  532. package/dist/types/sandbox.js.map +1 -1
  533. package/dist/types/service.d.ts +10 -1
  534. package/dist/types/service.js.map +1 -1
  535. package/dist/types/sidebar.d.ts +9 -0
  536. package/dist/types/sidebar.js.map +1 -1
  537. package/dist/types/transport.d.ts +4 -0
  538. package/dist/virtual/entrypoint.d.ts +5 -0
  539. package/dist/virtual/entrypoint.js +7 -0
  540. package/dist/virtual/entrypoint.js.map +1 -0
  541. package/dist/virtual/icon.d.ts +2 -0
  542. package/dist/virtual/icon.js +5 -0
  543. package/dist/virtual/icon.js.map +1 -0
  544. package/dist/virtual/locale.d.ts +7 -0
  545. package/dist/virtual/locale.js +13 -0
  546. package/dist/virtual/locale.js.map +1 -0
  547. package/dist/virtual/modules.d.ts +40 -0
  548. package/dist/virtual/offscreen.d.ts +3 -0
  549. package/dist/virtual/offscreen.js +5 -0
  550. package/dist/virtual/offscreen.js.map +1 -0
  551. package/dist/virtual/page.d.ts +2 -0
  552. package/dist/virtual/page.js +5 -0
  553. package/dist/virtual/page.js.map +1 -0
  554. package/dist/virtual/popup.d.ts +3 -0
  555. package/dist/virtual/popup.js +5 -0
  556. package/dist/virtual/popup.js.map +1 -0
  557. package/dist/virtual/relay.d.ts +3 -0
  558. package/dist/virtual/relay.js +5 -0
  559. package/dist/virtual/relay.js.map +1 -0
  560. package/dist/virtual/sandbox.d.ts +3 -0
  561. package/dist/virtual/sandbox.js +5 -0
  562. package/dist/virtual/sandbox.js.map +1 -0
  563. package/dist/virtual/sidebar.d.ts +3 -0
  564. package/dist/virtual/sidebar.js +5 -0
  565. package/dist/virtual/sidebar.js.map +1 -0
  566. package/package.json +31 -10
  567. package/scripts/clean-dist.js +7 -0
  568. package/scripts/copy-dts.js +11 -1
  569. package/types/client.d.ts +15 -0
  570. package/dist/cli/builders/manifest/utils.d.ts +0 -32
  571. package/dist/cli/builders/manifest/utils.js +0 -209
  572. package/dist/cli/builders/manifest/utils.js.map +0 -1
  573. package/dist/cli/bundler/plugins/EntrypointPlugin.js.map +0 -1
  574. package/dist/cli/bundler/plugins/GenerateJsonPlugin.js +0 -40
  575. package/dist/cli/bundler/plugins/GenerateJsonPlugin.js.map +0 -1
  576. package/dist/cli/bundler/plugins/ManifestPlugin.d.ts +0 -10
  577. package/dist/cli/bundler/plugins/ManifestPlugin.js +0 -78
  578. package/dist/cli/bundler/plugins/ManifestPlugin.js.map +0 -1
  579. package/dist/cli/bundler/plugins/ReplacePlugin.js.map +0 -1
  580. package/dist/cli/bundler/plugins/WatchPlugin.js +0 -21
  581. package/dist/cli/bundler/plugins/WatchPlugin.js.map +0 -1
  582. package/dist/cli/entrypoint/finder/AbstractOptionsFinder.js.map +0 -1
  583. package/dist/entry/content/core/AbstractMarker.js.map +0 -1
  584. package/dist/entry/content/core/AttributeMarker.js.map +0 -1
  585. package/dist/entry/content/core/Context.js.map +0 -1
  586. package/dist/entry/content/core/EventEmitter.js.map +0 -1
  587. package/dist/entry/content/core/EventNode.js.map +0 -1
  588. package/dist/entry/content/core/ManagedContext.js.map +0 -1
  589. package/dist/entry/content/core/MarkerNode.js.map +0 -1
  590. package/dist/entry/content/core/MountNode.js.map +0 -1
  591. package/dist/entry/content/core/Node.js.map +0 -1
  592. package/dist/entry/content/core/WeakMarker.js.map +0 -1
  593. package/dist/locale/adapters/react/LocaleProvider.d.ts +0 -7
  594. package/dist/locale/adapters/react/LocaleProvider.js +0 -58
  595. package/dist/locale/adapters/react/LocaleProvider.js.map +0 -1
  596. package/dist/locale/adapters/react/context.d.ts +0 -14
  597. package/dist/locale/adapters/react/context.js +0 -25
  598. package/dist/locale/adapters/react/context.js.map +0 -1
  599. package/dist/locale/utils.d.ts +0 -11
  600. package/dist/locale/utils.js +0 -67
  601. package/dist/locale/utils.js.map +0 -1
  602. /package/dist/cli/bundler/plugins/{ReplacePlugin.d.ts → replace/ReplacePlugin.d.ts} +0 -0
  603. /package/dist/cli/bundler/plugins/{ReplacePlugin.js → replace/ReplacePlugin.js} +0 -0
  604. /package/dist/cli/bundler/plugins/{WatchPlugin.d.ts → watch/WatchPlugin.d.ts} +0 -0
  605. /package/dist/cli/entrypoint/finder/{AbstractOptionsFinder.d.ts → AbstractParsedFinder.d.ts} +0 -0
  606. /package/dist/entry/content/core/{ManagedContext.js → context/ManagedContext.js} +0 -0
  607. /package/dist/entry/content/core/{AttributeMarker.js → markers/AttributeMarker.js} +0 -0
  608. /package/dist/entry/content/core/{WeakMarker.js → markers/WeakMarker.js} +0 -0
@@ -1,15 +1,173 @@
1
1
  import _ from "lodash";
2
2
  import path from "path";
3
- const appFilenameResolver = (app, filename, dirname) => (pathData, assetInfo) => {
3
+ import postcss from "postcss";
4
+ import valueParser from "postcss-value-parser";
5
+ import { toPosix } from "./../../../cli/utils/path.js";
6
+ const compilationBuildAssets = /* @__PURE__ */ new WeakMap();
7
+ const appFilenameResolver = (app, filename, dirname) => {
4
8
  app = _.kebabCase(app);
5
- let name = _.isFunction(filename) ? filename(pathData, assetInfo) : filename;
6
- name = name.replaceAll("[app]", app);
7
- if (dirname) {
8
- return path.posix.join(dirname, name);
9
+ const resolve = (name) => {
10
+ name = name.replaceAll("[app]", app);
11
+ return dirname ? path.posix.join(dirname, name) : name;
12
+ };
13
+ if (!_.isFunction(filename)) {
14
+ return resolve(filename);
9
15
  }
10
- return name;
16
+ return (pathData, assetInfo) => {
17
+ return resolve(filename(pathData, assetInfo));
18
+ };
19
+ };
20
+ const addRelatedSourceMaps = (sourceMaps, related) => {
21
+ const sourceMap = related == null ? void 0 : related.sourceMap;
22
+ if (Array.isArray(sourceMap)) {
23
+ sourceMap.forEach((file) => sourceMaps.add(toPosix(file)));
24
+ } else if (sourceMap) {
25
+ sourceMaps.add(toPosix(sourceMap));
26
+ }
27
+ };
28
+ const getRelatedSourceMaps = (compilation) => {
29
+ const sourceMaps = /* @__PURE__ */ new Set();
30
+ compilation.getAssets().forEach(({ info }) => addRelatedSourceMaps(sourceMaps, info.related));
31
+ return sourceMaps;
32
+ };
33
+ const isIgnoredAsset = (file, info, sourceMaps) => {
34
+ return Boolean(info.development || info.hotModuleReplacement || sourceMaps.has(file));
35
+ };
36
+ const classifyAsset = (file, info, fromModuleAssets) => {
37
+ if (info.assetType === "javascript") {
38
+ return "js";
39
+ }
40
+ if (info.assetType === "css" || info.assetType === "extract-css") {
41
+ return "css";
42
+ }
43
+ if (info.assetType || info.sourceFilename || fromModuleAssets) {
44
+ return "asset";
45
+ }
46
+ if (file.endsWith(".js") || file.endsWith(".mjs") || file.endsWith(".cjs")) {
47
+ return "js";
48
+ }
49
+ if (file.endsWith(".css")) {
50
+ return "css";
51
+ }
52
+ return "asset";
53
+ };
54
+ const getAssetKind = (compilation, file, sourceMaps, fromModuleAssets = false) => {
55
+ file = toPosix(file);
56
+ const asset = compilation.getAsset(file);
57
+ if (!asset || isIgnoredAsset(file, asset.info, sourceMaps)) {
58
+ return;
59
+ }
60
+ return classifyAsset(file, asset.info, fromModuleAssets);
61
+ };
62
+ const getModuleAssetNames = (module) => {
63
+ var _a;
64
+ return Object.keys(((_a = module.buildInfo) == null ? void 0 : _a.assets) ?? {});
65
+ };
66
+ const collectResources = (compilation, chunks, sourceMaps) => {
67
+ var _a, _b;
68
+ const candidates = /* @__PURE__ */ new Map();
69
+ const cssFiles = /* @__PURE__ */ new Set();
70
+ const sourceFiles = /* @__PURE__ */ new Set();
71
+ for (const chunk of chunks) {
72
+ for (const file of [...chunk.files, ...chunk.auxiliaryFiles]) {
73
+ const normalized = toPosix(file);
74
+ candidates.set(normalized, candidates.get(normalized) ?? false);
75
+ if (getAssetKind(compilation, normalized, sourceMaps) === "css") cssFiles.add(normalized);
76
+ }
77
+ for (const module of compilation.chunkGraph.getChunkModulesIterable(chunk)) {
78
+ for (const file of getModuleAssetNames(module)) {
79
+ candidates.set(toPosix(file), true);
80
+ }
81
+ if (module.type === "css/mini-extract") {
82
+ for (const dependency of ((_a = module.buildInfo) == null ? void 0 : _a.fileDependencies) ?? [])
83
+ sourceFiles.add(path.resolve(dependency));
84
+ }
85
+ }
86
+ }
87
+ const resources = compilation.getAssets().filter(
88
+ (asset) => getAssetKind(compilation, asset.name, sourceMaps) === "asset" && (!asset.info.sourceFilename || sourceFiles.has(
89
+ path.resolve(compilation.compiler.context, asset.info.sourceFilename.split(/[?#]/)[0])
90
+ ))
91
+ ).map((asset) => asset.name).sort((left, right) => right.length - left.length);
92
+ for (const file of cssFiles) {
93
+ const css = (_b = compilation.getAsset(file)) == null ? void 0 : _b.source.source().toString();
94
+ if (!css) continue;
95
+ postcss.parse(css, { from: file }).walkDecls((declaration) => {
96
+ valueParser(declaration.value).walk((node) => {
97
+ if (node.type !== "function" || node.value.toLowerCase() !== "url") return;
98
+ const argument = node.nodes[0];
99
+ if (!argument || argument.type !== "string" && argument.type !== "word") return false;
100
+ const url = argument.value.replace(
101
+ /\\([\da-f]{1,6}\s?|.)/gi,
102
+ (_match, escape) => /^[\da-f]{1,6}\s?$/i.test(escape) ? String.fromCodePoint(parseInt(escape.trim(), 16) || 65533) : escape
103
+ );
104
+ if (/^(?:data|blob):/i.test(url)) return false;
105
+ try {
106
+ const pathname = decodeURIComponent(new URL(url, `https://adnbn.invalid/${file}`).pathname);
107
+ const resource = resources.find((candidate) => pathname.endsWith(`/${candidate}`));
108
+ if (resource) candidates.set(resource, true);
109
+ } catch {
110
+ }
111
+ return false;
112
+ });
113
+ });
114
+ }
115
+ return Array.from(candidates).filter(([file, fromModuleAssets]) => {
116
+ return getAssetKind(compilation, file, sourceMaps, fromModuleAssets) === "asset";
117
+ }).map(([file]) => file).toSorted();
118
+ };
119
+ const collectCodeFiles = (compilation, files, sourceMaps) => {
120
+ const css = /* @__PURE__ */ new Set();
121
+ const js = /* @__PURE__ */ new Set();
122
+ for (const rawFile of files) {
123
+ const file = toPosix(rawFile);
124
+ const kind = getAssetKind(compilation, file, sourceMaps);
125
+ if (kind === "js") {
126
+ js.add(file);
127
+ } else if (kind === "css") {
128
+ css.add(file);
129
+ }
130
+ }
131
+ return { js: Array.from(js), css: Array.from(css) };
132
+ };
133
+ const collectAsyncCodeFiles = (compilation, chunks, sourceMaps, initialFiles) => {
134
+ const files = /* @__PURE__ */ new Set();
135
+ for (const chunk of chunks) {
136
+ for (const file of [...chunk.files, ...chunk.auxiliaryFiles]) {
137
+ const normalized = toPosix(file);
138
+ if (!initialFiles.has(normalized)) {
139
+ files.add(normalized);
140
+ }
141
+ }
142
+ }
143
+ return collectCodeFiles(compilation, files, sourceMaps);
144
+ };
145
+ const collectBuildAssets = (compilation) => {
146
+ const sourceMaps = getRelatedSourceMaps(compilation);
147
+ const assets = /* @__PURE__ */ Object.create(null);
148
+ const entrypoints = Array.from(compilation.entrypoints).toSorted(([left], [right]) => left.localeCompare(right));
149
+ for (const [name, entrypoint] of entrypoints) {
150
+ const initial = collectCodeFiles(compilation, entrypoint.getFiles(), sourceMaps);
151
+ const initialFiles = /* @__PURE__ */ new Set([...initial.js, ...initial.css]);
152
+ const entryChunk = entrypoint.getEntrypointChunk();
153
+ assets[name] = {
154
+ initial,
155
+ async: collectAsyncCodeFiles(compilation, entryChunk.getAllAsyncChunks(), sourceMaps, initialFiles),
156
+ assets: collectResources(compilation, entryChunk.getAllReferencedChunks(), sourceMaps)
157
+ };
158
+ }
159
+ return assets;
160
+ };
161
+ const setCompilationBuildAssets = (compilation, assets) => {
162
+ compilationBuildAssets.set(compilation, assets);
163
+ };
164
+ const getCompilationBuildAssets = (compilation) => {
165
+ return compilationBuildAssets.get(compilation);
11
166
  };
12
167
  export {
13
- appFilenameResolver
168
+ appFilenameResolver,
169
+ collectBuildAssets,
170
+ getCompilationBuildAssets,
171
+ setCompilationBuildAssets
14
172
  };
15
173
  //# sourceMappingURL=output.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/cli/bundler/utils/output.ts"],"sourcesContent":["import {Filename} from \"@rspack/core\";\nimport _ from \"lodash\";\nimport path from \"path\";\n\n// prettier-ignore\nexport const appFilenameResolver =\n (app: string, filename: Filename, dirname?: string): Extract<Filename, Filename> =>\n (pathData, assetInfo): string => {\n app = _.kebabCase(app);\n\n let name = _.isFunction(filename) ? filename(pathData, assetInfo) : filename;\n\n name = name.replaceAll(\"[app]\", app);\n\n if (dirname) {\n return path.posix.join(dirname, name);\n }\n\n return name;\n };\n"],"mappings":"AACA,OAAO,OAAO;AACd,OAAO,UAAU;AAGV,MAAM,sBACT,CAAC,KAAa,UAAoB,YAC9B,CAAC,UAAU,cAAsB;AAC7B,QAAM,EAAE,UAAU,GAAG;AAErB,MAAI,OAAO,EAAE,WAAW,QAAQ,IAAI,SAAS,UAAU,SAAS,IAAI;AAEpE,SAAO,KAAK,WAAW,SAAS,GAAG;AAEnC,MAAI,SAAS;AACT,WAAO,KAAK,MAAM,KAAK,SAAS,IAAI;AAAA,EACxC;AAEA,SAAO;AACX;","names":[]}
1
+ {"version":3,"sources":["../../../../src/cli/bundler/utils/output.ts"],"sourcesContent":["import type {AssetInfo, Chunk, Compilation, Filename, Module} from \"@rspack/core\";\nimport _ from \"lodash\";\nimport path from \"path\";\nimport postcss from \"postcss\";\nimport valueParser from \"postcss-value-parser\";\n\nimport {toPosix} from \"@cli/utils/path\";\n\nimport type {EntrypointAssetsMap, EntrypointAssetsMapEntry, EntrypointAssetsFiles} from \"@typing/entrypoint\";\n\ntype AssetKind = \"asset\" | \"css\" | \"js\";\n\nconst compilationBuildAssets = new WeakMap<Compilation, EntrypointAssetsMap>();\n\n// prettier-ignore\nexport const appFilenameResolver =\n (app: string, filename: Filename, dirname?: string): Filename => {\n app = _.kebabCase(app);\n\n const resolve = (name: string): string => {\n name = name.replaceAll(\"[app]\", app);\n\n return dirname ? path.posix.join(dirname, name) : name;\n };\n\n if (!_.isFunction(filename)) {\n return resolve(filename);\n }\n\n return (pathData, assetInfo): string => {\n return resolve(filename(pathData, assetInfo));\n };\n };\n\nconst addRelatedSourceMaps = (sourceMaps: Set<string>, related: AssetInfo[\"related\"]): void => {\n const sourceMap = related?.sourceMap;\n\n if (Array.isArray(sourceMap)) {\n sourceMap.forEach(file => sourceMaps.add(toPosix(file)));\n } else if (sourceMap) {\n sourceMaps.add(toPosix(sourceMap));\n }\n};\n\nconst getRelatedSourceMaps = (compilation: Compilation): ReadonlySet<string> => {\n const sourceMaps = new Set<string>();\n\n compilation.getAssets().forEach(({info}) => addRelatedSourceMaps(sourceMaps, info.related));\n\n return sourceMaps;\n};\n\nconst isIgnoredAsset = (file: string, info: AssetInfo, sourceMaps: ReadonlySet<string>): boolean => {\n return Boolean(info.development || info.hotModuleReplacement || sourceMaps.has(file));\n};\n\nconst classifyAsset = (file: string, info: AssetInfo, fromModuleAssets: boolean): AssetKind => {\n if (info.assetType === \"javascript\") {\n return \"js\";\n }\n\n if (info.assetType === \"css\" || info.assetType === \"extract-css\") {\n return \"css\";\n }\n\n if (info.assetType || info.sourceFilename || fromModuleAssets) {\n return \"asset\";\n }\n\n if (file.endsWith(\".js\") || file.endsWith(\".mjs\") || file.endsWith(\".cjs\")) {\n return \"js\";\n }\n\n if (file.endsWith(\".css\")) {\n return \"css\";\n }\n\n return \"asset\";\n};\n\nconst getAssetKind = (\n compilation: Compilation,\n file: string,\n sourceMaps: ReadonlySet<string>,\n fromModuleAssets = false\n): AssetKind | undefined => {\n file = toPosix(file);\n\n const asset = compilation.getAsset(file);\n\n if (!asset || isIgnoredAsset(file, asset.info, sourceMaps)) {\n return;\n }\n\n return classifyAsset(file, asset.info, fromModuleAssets);\n};\n\nconst getModuleAssetNames = (module: Module): readonly string[] => {\n return Object.keys(module.buildInfo?.assets ?? {});\n};\n\nconst collectResources = (\n compilation: Compilation,\n chunks: Iterable<Chunk>,\n sourceMaps: ReadonlySet<string>\n): readonly string[] => {\n const candidates = new Map<string, boolean>();\n const cssFiles = new Set<string>();\n const sourceFiles = new Set<string>();\n\n for (const chunk of chunks) {\n for (const file of [...chunk.files, ...chunk.auxiliaryFiles]) {\n const normalized = toPosix(file);\n\n candidates.set(normalized, candidates.get(normalized) ?? false);\n if (getAssetKind(compilation, normalized, sourceMaps) === \"css\") cssFiles.add(normalized);\n }\n\n for (const module of compilation.chunkGraph.getChunkModulesIterable(chunk)) {\n for (const file of getModuleAssetNames(module)) {\n candidates.set(toPosix(file), true);\n }\n if (module.type === \"css/mini-extract\") {\n for (const dependency of module.buildInfo?.fileDependencies ?? [])\n sourceFiles.add(path.resolve(dependency));\n }\n }\n }\n\n // CssExtract executes url() asset modules during the build. They are not\n // runtime chunk modules, so follow the emitted CSS references as well.\n // This only reads assets; it never rewrites CSS or its filenames.\n const resources = compilation\n .getAssets()\n .filter(\n asset =>\n getAssetKind(compilation, asset.name, sourceMaps) === \"asset\" &&\n (!asset.info.sourceFilename ||\n sourceFiles.has(\n path.resolve(compilation.compiler.context, asset.info.sourceFilename.split(/[?#]/)[0])\n ))\n )\n .map(asset => asset.name)\n .sort((left, right) => right.length - left.length);\n for (const file of cssFiles) {\n const css = compilation.getAsset(file)?.source.source().toString();\n if (!css) continue;\n postcss.parse(css, {from: file}).walkDecls(declaration => {\n valueParser(declaration.value).walk(node => {\n if (node.type !== \"function\" || node.value.toLowerCase() !== \"url\") return;\n const argument = node.nodes[0];\n if (!argument || (argument.type !== \"string\" && argument.type !== \"word\")) return false;\n const url = argument.value.replace(/\\\\([\\da-f]{1,6}\\s?|.)/gi, (_match, escape: string) =>\n /^[\\da-f]{1,6}\\s?$/i.test(escape)\n ? String.fromCodePoint(parseInt(escape.trim(), 16) || 0xfffd)\n : escape\n );\n if (/^(?:data|blob):/i.test(url)) return false;\n try {\n const pathname = decodeURIComponent(new URL(url, `https://adnbn.invalid/${file}`).pathname);\n const resource = resources.find(candidate => pathname.endsWith(`/${candidate}`));\n if (resource) candidates.set(resource, true);\n } catch {\n // External or malformed URLs do not name an emitted build resource.\n }\n return false;\n });\n });\n }\n\n return Array.from(candidates)\n .filter(([file, fromModuleAssets]) => {\n return getAssetKind(compilation, file, sourceMaps, fromModuleAssets) === \"asset\";\n })\n .map(([file]) => file)\n .toSorted();\n};\n\nconst collectCodeFiles = (\n compilation: Compilation,\n files: Iterable<string>,\n sourceMaps: ReadonlySet<string>\n): EntrypointAssetsFiles => {\n const css = new Set<string>();\n const js = new Set<string>();\n\n for (const rawFile of files) {\n const file = toPosix(rawFile);\n const kind = getAssetKind(compilation, file, sourceMaps);\n\n if (kind === \"js\") {\n js.add(file);\n } else if (kind === \"css\") {\n css.add(file);\n }\n }\n\n return {js: Array.from(js), css: Array.from(css)};\n};\n\nconst collectAsyncCodeFiles = (\n compilation: Compilation,\n chunks: Iterable<Chunk>,\n sourceMaps: ReadonlySet<string>,\n initialFiles: ReadonlySet<string>\n): EntrypointAssetsFiles => {\n const files = new Set<string>();\n\n for (const chunk of chunks) {\n for (const file of [...chunk.files, ...chunk.auxiliaryFiles]) {\n const normalized = toPosix(file);\n\n if (!initialFiles.has(normalized)) {\n files.add(normalized);\n }\n }\n }\n\n return collectCodeFiles(compilation, files, sourceMaps);\n};\n\nexport const collectBuildAssets = (compilation: Compilation): EntrypointAssetsMap => {\n const sourceMaps = getRelatedSourceMaps(compilation);\n const assets = Object.create(null) as Record<string, EntrypointAssetsMapEntry>;\n\n const entrypoints = Array.from(compilation.entrypoints).toSorted(([left], [right]) => left.localeCompare(right));\n\n for (const [name, entrypoint] of entrypoints) {\n const initial = collectCodeFiles(compilation, entrypoint.getFiles(), sourceMaps);\n const initialFiles = new Set([...initial.js, ...initial.css]);\n const entryChunk = entrypoint.getEntrypointChunk();\n\n assets[name] = {\n initial,\n async: collectAsyncCodeFiles(compilation, entryChunk.getAllAsyncChunks(), sourceMaps, initialFiles),\n assets: collectResources(compilation, entryChunk.getAllReferencedChunks(), sourceMaps),\n };\n }\n\n return assets;\n};\n\nexport const setCompilationBuildAssets = (compilation: Compilation, assets: EntrypointAssetsMap): void => {\n compilationBuildAssets.set(compilation, assets);\n};\n\nexport const getCompilationBuildAssets = (compilation: Compilation): EntrypointAssetsMap | undefined => {\n return compilationBuildAssets.get(compilation);\n};\n"],"mappings":"AACA,OAAO,OAAO;AACd,OAAO,UAAU;AACjB,OAAO,aAAa;AACpB,OAAO,iBAAiB;AAExB,SAAQ,eAAc;AAMtB,MAAM,yBAAyB,oBAAI,QAA0C;AAGtE,MAAM,sBACT,CAAC,KAAa,UAAoB,YAA+B;AAC7D,QAAM,EAAE,UAAU,GAAG;AAErB,QAAM,UAAU,CAAC,SAAyB;AACtC,WAAO,KAAK,WAAW,SAAS,GAAG;AAEnC,WAAO,UAAU,KAAK,MAAM,KAAK,SAAS,IAAI,IAAI;AAAA,EACtD;AAEA,MAAI,CAAC,EAAE,WAAW,QAAQ,GAAG;AACzB,WAAO,QAAQ,QAAQ;AAAA,EAC3B;AAEA,SAAO,CAAC,UAAU,cAAsB;AACpC,WAAO,QAAQ,SAAS,UAAU,SAAS,CAAC;AAAA,EAChD;AACJ;AAEJ,MAAM,uBAAuB,CAAC,YAA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AAuB,IAAI,aAAa,MAAM;AAClD;AAEO,MAAM,4BAA4B,CAAC,gBAA8D;AACpG,SAAO,uBAAuB,IAAI,WAAW;AACjD;","names":[]}
@@ -0,0 +1,5 @@
1
+ import type { Chunk, Compilation, Module } from "@rspack/core";
2
+ export declare const IsolatedStylesLayer = "adnbn:css:isolation";
3
+ export declare const isIsolatedStylesModule: (module: Module) => boolean;
4
+ export declare const isIsolatedStylesChunk: (compilation: Compilation, chunk: Chunk) => boolean;
5
+ export declare const getIsolatedStylesFiles: (compilation: Compilation) => ReadonlySet<string>;
@@ -0,0 +1,30 @@
1
+ const IsolatedStylesLayer = "adnbn:css:isolation";
2
+ const isIsolatedStylesModule = (module) => module.type === "css/mini-extract" && module.layer === IsolatedStylesLayer;
3
+ const isIsolatedStylesChunk = (compilation, chunk) => {
4
+ const modules = [...compilation.chunkGraph.getChunkModulesIterable(chunk)].filter(
5
+ (module) => module.type === "css/mini-extract"
6
+ );
7
+ const isolated = modules.some(isIsolatedStylesModule);
8
+ if (isolated && !modules.every(isIsolatedStylesModule)) {
9
+ throw new Error(
10
+ `CSS chunk "${chunk.name ?? chunk.id}" mixes document and ?isolation styles. Preserve the adnbnIsolatedStyles CSS cache group in your bundler configuration.`
11
+ );
12
+ }
13
+ return isolated;
14
+ };
15
+ const getIsolatedStylesFiles = (compilation) => {
16
+ const files = /* @__PURE__ */ new Set();
17
+ for (const chunk of compilation.chunks) {
18
+ if (isIsolatedStylesChunk(compilation, chunk)) {
19
+ for (const file of chunk.files) if (file.endsWith(".css")) files.add(file);
20
+ }
21
+ }
22
+ return files;
23
+ };
24
+ export {
25
+ IsolatedStylesLayer,
26
+ getIsolatedStylesFiles,
27
+ isIsolatedStylesChunk,
28
+ isIsolatedStylesModule
29
+ };
30
+ //# sourceMappingURL=styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/cli/bundler/utils/styles.ts"],"sourcesContent":["import type {Chunk, Compilation, Module} from \"@rspack/core\";\n\n// This is a bundler layer, not a CSS @layer. A distinct css-loader identity is\n// also required: CssExtract deduplicates dependencies by their loader request.\nexport const IsolatedStylesLayer = \"adnbn:css:isolation\";\n\nexport const isIsolatedStylesModule = (module: Module): boolean =>\n module.type === \"css/mini-extract\" && module.layer === IsolatedStylesLayer;\n\nexport const isIsolatedStylesChunk = (compilation: Compilation, chunk: Chunk): boolean => {\n const modules = [...compilation.chunkGraph.getChunkModulesIterable(chunk)].filter(\n module => module.type === \"css/mini-extract\"\n );\n const isolated = modules.some(isIsolatedStylesModule);\n if (isolated && !modules.every(isIsolatedStylesModule)) {\n throw new Error(\n `CSS chunk \"${chunk.name ?? chunk.id}\" mixes document and ?isolation styles. Preserve the adnbnIsolatedStyles CSS cache group in your bundler configuration.`\n );\n }\n return isolated;\n};\n\nexport const getIsolatedStylesFiles = (compilation: Compilation): ReadonlySet<string> => {\n const files = new Set<string>();\n for (const chunk of compilation.chunks) {\n if (isIsolatedStylesChunk(compilation, chunk)) {\n for (const file of chunk.files) if (file.endsWith(\".css\")) files.add(file);\n }\n }\n return files;\n};\n"],"mappings":"AAIO,MAAM,sBAAsB;AAE5B,MAAM,yBAAyB,CAAC,WACnC,OAAO,SAAS,sBAAsB,OAAO,UAAU;AAEpD,MAAM,wBAAwB,CAAC,aAA0B,UAA0B;AACtF,QAAM,UAAU,CAAC,GAAG,YAAY,WAAW,wBAAwB,KAAK,CAAC,EAAE;AAAA,IACvE,YAAU,OAAO,SAAS;AAAA,EAC9B;AACA,QAAM,WAAW,QAAQ,KAAK,sBAAsB;AACpD,MAAI,YAAY,CAAC,QAAQ,MAAM,sBAAsB,GAAG;AACpD,UAAM,IAAI;AAAA,MACN,cAAc,MAAM,QAAQ,MAAM,EAAE;AAAA,IACxC;AAAA,EACJ;AACA,SAAO;AACX;AAEO,MAAM,yBAAyB,CAAC,gBAAkD;AACrF,QAAM,QAAQ,oBAAI,IAAY;AAC9B,aAAW,SAAS,YAAY,QAAQ;AACpC,QAAI,sBAAsB,aAAa,KAAK,GAAG;AAC3C,iBAAW,QAAQ,MAAM,MAAO,KAAI,KAAK,SAAS,MAAM,EAAG,OAAM,IAAI,IAAI;AAAA,IAC7E;AAAA,EACJ;AACA,SAAO;AACX;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import ts from "typescript";
2
2
  import SourceFile from "./SourceFile.js";
3
- import { MemberSignature } from "./parsers/types.js";
3
+ import type { ExportValue, MemberSignature } from "./parsers/types.js";
4
4
  /**
5
5
  * Parses a TypeScript expression (object literal, function, or class)
6
6
  * and builds a full interface of its public members (methods and properties).
@@ -18,7 +18,10 @@ export default class ExpressionFile extends SourceFile {
18
18
  private readonly objectParser;
19
19
  private readonly classParser;
20
20
  private readonly jsDocParser;
21
+ private readonly exportParser;
21
22
  constructor(filePath: string);
23
+ /** Returns export metadata; consumers decide what that export means for their entrypoint. */
24
+ getDefaultExport(): ExportValue | undefined;
22
25
  getType(): string | undefined;
23
26
  setProperty(property: string): this;
24
27
  /**
@@ -2,6 +2,7 @@ import ts from "typescript";
2
2
  import SourceFile from "./SourceFile.js";
3
3
  import {
4
4
  ClassParser,
5
+ ExportParser,
5
6
  FunctionParser,
6
7
  JSDocParser,
7
8
  NodeFinder,
@@ -23,6 +24,7 @@ class ExpressionFile extends SourceFile {
23
24
  objectParser;
24
25
  classParser;
25
26
  jsDocParser;
27
+ exportParser;
26
28
  constructor(filePath) {
27
29
  super(filePath);
28
30
  this.typeResolver = new TypeResolver(this);
@@ -32,6 +34,15 @@ class ExpressionFile extends SourceFile {
32
34
  this.classParser = new ClassParser(this, this.typeResolver, this.signatureBuilder, this.nodeFinder);
33
35
  this.functionParser = new FunctionParser(this, this.nodeFinder, this.objectParser, this.classParser);
34
36
  this.jsDocParser = new JSDocParser();
37
+ this.exportParser = new ExportParser(
38
+ this,
39
+ this.nodeFinder,
40
+ () => this.getInputResolver().getTs().getConfig().options
41
+ );
42
+ }
43
+ /** Returns export metadata; consumers decide what that export means for their entrypoint. */
44
+ getDefaultExport() {
45
+ return this.exportParser.parseDefault();
35
46
  }
36
47
  getType() {
37
48
  if (this.property) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/cli/entrypoint/file/ExpressionFile.ts"],"sourcesContent":["import ts from \"typescript\";\n\nimport SourceFile from \"./SourceFile\";\nimport {\n ClassParser,\n FunctionParser,\n JSDocParser,\n NodeFinder,\n ObjectParser,\n SignatureBuilder,\n TypeResolver,\n} from \"./parsers\";\nimport {MemberSignature} from \"./parsers/types\";\n\nimport {PackageName} from \"@typing/app\";\n\n/**\n * Parses a TypeScript expression (object literal, function, or class)\n * and builds a full interface of its public members (methods and properties).\n */\nexport default class ExpressionFile extends SourceFile {\n protected property?: string;\n /**\n * Names of wrapper functions whose first argument should be unwrapped for parsing.\n */\n protected definition = new Set<string>();\n\n private readonly typeResolver: TypeResolver;\n private readonly nodeFinder: NodeFinder;\n private readonly signatureBuilder: SignatureBuilder;\n private readonly functionParser: FunctionParser;\n private readonly objectParser: ObjectParser;\n private readonly classParser: ClassParser;\n private readonly jsDocParser: JSDocParser;\n\n constructor(filePath: string) {\n super(filePath);\n\n this.typeResolver = new TypeResolver(this);\n this.nodeFinder = new NodeFinder(this);\n this.signatureBuilder = new SignatureBuilder(this.typeResolver);\n this.objectParser = new ObjectParser(this, this.signatureBuilder);\n this.classParser = new ClassParser(this, this.typeResolver, this.signatureBuilder, this.nodeFinder);\n this.functionParser = new FunctionParser(this, this.nodeFinder, this.objectParser, this.classParser);\n this.jsDocParser = new JSDocParser();\n }\n\n public getType(): string | undefined {\n // If a specific variable or property is requested, extract its type\n if (this.property) {\n // 1) Named variable scenario: e.g. export const init = () => ...\n const varDecl = this.nodeFinder.findVariableDeclaration(this.property);\n\n if (varDecl && varDecl.initializer) {\n return this.getTypeFromInitializer(varDecl.initializer);\n }\n\n // 2) Property on default export object: unwrap and look up key\n let exportExpr: ts.Expression | undefined;\n const sf = this.getSourceFile();\n\n const findExport = (node: ts.Node) => {\n if (ts.isExportAssignment(node)) {\n exportExpr = node.expression;\n }\n ts.forEachChild(node, findExport);\n };\n\n findExport(sf);\n\n if (!exportExpr) return undefined;\n\n // Special case for service definitions with JSDoc annotations\n if (this.definition.size > 0 && ts.isCallExpression(exportExpr) && ts.isIdentifier(exportExpr.expression)) {\n const fnName = exportExpr.expression.text;\n\n if (this.definition.has(fnName)) {\n // Check if the wrapper function is imported from the designated package name\n let importPath: string | undefined;\n try {\n importPath = this.getImports().get(fnName);\n } catch {\n // unable to resolve import source -> ignore wrapper\n return undefined;\n }\n\n if (importPath !== PackageName) {\n // Function is not imported from the designated package name -> ignore wrapper\n console.warn(`Function ${fnName} is not imported from '${PackageName}' in file ${this.file}`);\n return undefined;\n }\n\n if (exportExpr.arguments.length > 0) {\n const firstArg = exportExpr.arguments[0];\n\n if (ts.isObjectLiteralExpression(firstArg)) {\n for (const prop of firstArg.properties) {\n const key = this.objectParser.getName(prop.name ?? prop);\n\n if (key !== this.property) continue;\n\n if (ts.isPropertyAssignment(prop)) {\n const initType = this.getTypeFromInitializer(prop.initializer);\n if (initType) return initType;\n } else if (ts.isMethodDeclaration(prop)) {\n // Get the return type of the method\n const returnType = this.getTypeFromMethodReturn(prop);\n if (returnType) return returnType;\n } else if (ts.isShorthandPropertyAssignment(prop)) {\n return this.resolveTypeFromShorthand(prop.name.text);\n }\n }\n }\n }\n }\n }\n\n const expr = this.unwrapExpression(exportExpr);\n\n if (ts.isObjectLiteralExpression(expr)) {\n for (const prop of expr.properties) {\n const key = this.objectParser.getName(prop.name ?? prop);\n\n if (key !== this.property) continue;\n\n if (ts.isPropertyAssignment(prop)) {\n return this.getTypeFromInitializer(prop.initializer);\n } else if (ts.isMethodDeclaration(prop) || ts.isGetAccessorDeclaration(prop)) {\n const sig = this.signatureBuilder.getMethodSignature(prop as ts.MethodDeclaration);\n\n return this.signatureBuilder.buildFunctionType(sig);\n } else if (ts.isShorthandPropertyAssignment(prop)) {\n return this.resolveTypeFromShorthand(prop.name.text);\n }\n }\n return undefined;\n }\n\n // Fallback: treat default export expression as initializer\n return this.getTypeFromInitializer(expr);\n }\n\n // Default: parse full default export into interface-like string\n let members: Record<string, MemberSignature> | undefined;\n const sf = this.getSourceFile();\n\n const collect = (node: ts.Node) => {\n if (ts.isExportAssignment(node)) {\n const expr0 = node.expression;\n const expr = this.unwrapExpression(expr0);\n const parsed = this.parse(expr);\n if (parsed) members = parsed;\n }\n ts.forEachChild(node, collect);\n };\n\n collect(sf);\n if (!members) return undefined;\n return this.signatureBuilder.formatMembers(members);\n }\n\n public setProperty(property: string): this {\n this.property = property;\n\n return this;\n }\n\n /**\n * Entry point: accepts an expression and returns a map of member signatures,\n * or undefined if the expression cannot be parsed.\n */\n protected parse(expr: ts.Expression): Record<string, MemberSignature> | undefined {\n if (ts.isFunctionExpression(expr) || ts.isArrowFunction(expr)) {\n return this.functionParser.parse(expr);\n } else if (ts.isObjectLiteralExpression(expr)) {\n return this.objectParser.parse(expr);\n } else if (ts.isClassExpression(expr)) {\n return this.classParser.parse(expr);\n }\n\n return undefined;\n }\n\n /**\n * Specify wrapper functions whose first argument should be unwrapped for parsing.\n */\n public setDefinition(definition: string | string[]): this {\n const defs = typeof definition === \"string\" ? [definition] : definition;\n\n defs.forEach(def => this.definition.add(def));\n\n return this;\n }\n\n /**\n * Recursively unwraps type assertions, satisfies, parentheses, and allowed wrapper calls.\n */\n private unwrapExpression(expr: ts.Expression): ts.Expression {\n // First use the AbstractExpressionParser's unwrapExpression for basic unwrapping\n expr = this.functionParser.unwrapExpression(expr);\n\n // Explicitly handle type assertions\n if (ts.isAsExpression(expr)) {\n return this.unwrapExpression(expr.expression);\n }\n\n // Then handle the additional unwrapping for known definition wrappers\n if (ts.isCallExpression(expr) && ts.isIdentifier(expr.expression)) {\n const fnName = expr.expression.text;\n\n if (this.definition.has(fnName)) {\n let importPath: string | undefined;\n\n try {\n importPath = this.getImports().get(fnName);\n } catch {\n // unable to resolve import source -> ignore wrapper\n return expr;\n }\n\n if (importPath !== PackageName) {\n console.warn(`Function ${fnName} is not imported from '${PackageName}' in file ${this.file}`);\n } else if (expr.arguments.length > 0) {\n const first = expr.arguments[0];\n return this.unwrapExpression(first as ts.Expression);\n }\n }\n }\n\n return expr;\n }\n\n /**\n * Given an initializer or expression, extracts its type: function signature or interface.\n */\n private getTypeFromInitializer(\n node: ts.Expression | ts.MethodDeclaration | ts.GetAccessorDeclaration\n ): string | undefined {\n // Unwrap type assertions\n if (ts.isAsExpression(node)) {\n return this.getTypeFromInitializer(node.expression);\n }\n\n // Function or arrow function: try to parse returned object or instance\n if (ts.isFunctionExpression(node) || ts.isArrowFunction(node)) {\n // attempt to parse returned expression into members\n const members = this.functionParser.parse(node as ts.FunctionExpression | ts.ArrowFunction);\n\n if (members) {\n return this.signatureBuilder.formatMembers(members);\n }\n\n // fallback to function signature\n const sig = this.signatureBuilder.getMethodSignature(node as ts.FunctionExpression | ts.ArrowFunction);\n\n return this.signatureBuilder.buildFunctionType(sig);\n }\n\n // Class or method-like: signature of accessor/method\n if (ts.isMethodDeclaration(node) || ts.isGetAccessorDeclaration(node)) {\n const sig = this.signatureBuilder.getMethodSignature(node as ts.MethodDeclaration);\n return this.signatureBuilder.buildFunctionType(sig);\n }\n\n // Object literal, class expression/declaration, or new expression: return interface of members\n let members: Record<string, MemberSignature> | undefined;\n\n if (ts.isObjectLiteralExpression(node) || ts.isClassExpression(node) || ts.isClassDeclaration(node)) {\n members = this.parse(node as ts.Expression);\n } else if (ts.isNewExpression(node)) {\n const ctor = node.expression;\n\n if (ts.isIdentifier(ctor)) {\n members = this.classParser.parseFileClass(ctor.text);\n } else if (ts.isClassExpression(ctor)) {\n members = this.classParser.parse(ctor);\n }\n }\n\n if (members) {\n return this.signatureBuilder.formatMembers(members);\n }\n\n if (ts.isLiteralExpression(node) || ts.isArrayLiteralExpression(node) || ts.isObjectLiteralExpression(node)) {\n return this.objectParser.inferTypeFromExpression(node as ts.Expression);\n }\n\n return undefined;\n }\n\n private resolveTypeFromShorthand(name: string): string | undefined {\n const varDecl = this.nodeFinder.findVariableDeclaration(name);\n if (varDecl && varDecl.initializer) {\n const t = this.getTypeFromInitializer(varDecl.initializer);\n if (t) return t;\n }\n const variable = this.getVariables().get(name);\n if (variable) {\n const val = variable.value;\n switch (typeof val) {\n case \"string\":\n return \"string\";\n case \"number\":\n return \"number\";\n case \"boolean\":\n return \"boolean\";\n case \"object\":\n if (val === null) return \"null\";\n if (Array.isArray(val)) return \"array\";\n return \"object\";\n default:\n return \"any\";\n }\n }\n return \"any\";\n }\n\n /**\n * Extracts the type of the return value of a method, taking into account JSDoc annotations.\n *\n * @param method The method declaration to extract the return type from\n * @returns The extracted return type as a string, or undefined if it cannot be extracted\n */\n private getTypeFromMethodReturn(method: ts.MethodDeclaration): string | undefined {\n // Try to find a return statement in the method body\n if (method.body) {\n // First, check if there's a JSDoc return type annotation\n const jsDocReturnType = this.jsDocParser.getJSDocReturnType(method);\n if (jsDocReturnType) {\n // If the return type is a new expression, try to parse it\n if (jsDocReturnType.includes(\"new \")) {\n const className = jsDocReturnType.replace(\"new \", \"\").trim();\n const members = this.classParser.parseFileClass(className);\n if (members) {\n return this.signatureBuilder.formatMembers(members);\n }\n }\n\n // If the return type is a class name, try to parse it\n const members = this.classParser.parseFileClass(jsDocReturnType);\n if (members) {\n return this.signatureBuilder.formatMembers(members);\n }\n\n return jsDocReturnType;\n }\n\n // If there's no JSDoc return type, try to find a return statement\n let returnExpr: ts.Expression | undefined;\n\n const findReturn = (node: ts.Node): void => {\n if (ts.isReturnStatement(node) && node.expression) {\n returnExpr = node.expression;\n return;\n }\n ts.forEachChild(node, findReturn);\n };\n\n findReturn(method.body);\n\n if (returnExpr) {\n return this.getTypeFromInitializer(returnExpr);\n }\n }\n\n // If we couldn't find a return statement, use the method's return type\n if (method.type) {\n return this.typeResolver.resolveTypeNode(method.type);\n }\n\n return undefined;\n }\n}\n"],"mappings":"AAAA,OAAO,QAAQ;AAEf,OAAO,gBAAgB;AACvB;AAAA,EACI;AAAA,EACA;AAAA,EACA;AA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AAAA,IACJ;AACA,WAAO;AAAA,EACX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQQ,wBAAwB,QAAkD;AAE9E,QAAI,OAAO,MAAM;AAEb,YAAM,kBAAkB,KAAK,YAAY,mBAAmB,MAAM;AAClE,UAAI,iBAAiB;AAEjB,YAAI,gBAAgB,SAAS,MAAM,GAAG;AAClC,gBAAM,YAAY,gBAAgB,QAAQ,QAAQ,EAAE,EAAE,KAAK;AAC3D,gBAAMA,WAAU,KAAK,YAAY,eAAe,SAAS;AACzD,cAAIA,UAAS;AACT,mBAAO,KAAK,iBAAiB,cAAcA,QAAO;AAAA,UACtD;AAAA,QACJ;AAGA,cAAM,UAAU,KAAK,YAAY,eAAe,eAAe;AAC/D,YAAI,SAAS;AACT,iBAAO,KAAK,iBAAiB,cAAc,OAAO;AAAA,QACtD;AAEA,eAAO;AAAA,MACX;AAGA,UAAI;AAEJ,YAAM,aAAa,CAAC,SAAwB;AACxC,YAAI,GAAG,kBAAkB,IAAI,KAAK,KAAK,YAAY;AAC/C,uBAAa,KAAK;AAClB;AAAA,QACJ;AACA,WAAG,aAAa,MAAM,UAAU;AAAA,MACpC;AAEA,iBAAW,OAAO,IAAI;AAEtB,UAAI,YAAY;AACZ,eAAO,KAAK,uBAAuB,UAAU;AAAA,MACjD;AAAA,IACJ;AAGA,QAAI,OAAO,MAAM;AACb,aAAO,KAAK,aAAa,gBAAgB,OAAO,IAAI;AAAA,IACxD;AAEA,WAAO;AAAA,EACX;AACJ;","names":["sf","members"]}
1
+ {"version":3,"sources":["../../../../src/cli/entrypoint/file/ExpressionFile.ts"],"sourcesContent":["import ts from \"typescript\";\n\nimport SourceFile from \"./SourceFile\";\nimport {\n ClassParser,\n ExportParser,\n FunctionParser,\n JSDocParser,\n NodeFinder,\n ObjectParser,\n SignatureBuilder,\n TypeResolver,\n} from \"./parsers\";\nimport type {ExportValue, MemberSignature} from \"./parsers/types\";\n\nimport {PackageName} from \"@typing/app\";\n\n/**\n * Parses a TypeScript expression (object literal, function, or class)\n * and builds a full interface of its public members (methods and properties).\n */\nexport default class ExpressionFile extends SourceFile {\n protected property?: string;\n /**\n * Names of wrapper functions whose first argument should be unwrapped for parsing.\n */\n protected definition = new Set<string>();\n\n private readonly typeResolver: TypeResolver;\n private readonly nodeFinder: NodeFinder;\n private readonly signatureBuilder: SignatureBuilder;\n private readonly functionParser: FunctionParser;\n private readonly objectParser: ObjectParser;\n private readonly classParser: ClassParser;\n private readonly jsDocParser: JSDocParser;\n private readonly exportParser: ExportParser;\n\n constructor(filePath: string) {\n super(filePath);\n\n this.typeResolver = new TypeResolver(this);\n this.nodeFinder = new NodeFinder(this);\n this.signatureBuilder = new SignatureBuilder(this.typeResolver);\n this.objectParser = new ObjectParser(this, this.signatureBuilder);\n this.classParser = new ClassParser(this, this.typeResolver, this.signatureBuilder, this.nodeFinder);\n this.functionParser = new FunctionParser(this, this.nodeFinder, this.objectParser, this.classParser);\n this.jsDocParser = new JSDocParser();\n this.exportParser = new ExportParser(\n this,\n this.nodeFinder,\n () => this.getInputResolver().getTs().getConfig().options\n );\n }\n\n /** Returns export metadata; consumers decide what that export means for their entrypoint. */\n public getDefaultExport(): ExportValue | undefined {\n return this.exportParser.parseDefault();\n }\n\n public getType(): string | undefined {\n // If a specific variable or property is requested, extract its type\n if (this.property) {\n // 1) Named variable scenario: e.g. export const init = () => ...\n const varDecl = this.nodeFinder.findVariableDeclaration(this.property);\n\n if (varDecl && varDecl.initializer) {\n return this.getTypeFromInitializer(varDecl.initializer);\n }\n\n // 2) Property on default export object: unwrap and look up key\n let exportExpr: ts.Expression | undefined;\n const sf = this.getSourceFile();\n\n const findExport = (node: ts.Node) => {\n if (ts.isExportAssignment(node)) {\n exportExpr = node.expression;\n }\n ts.forEachChild(node, findExport);\n };\n\n findExport(sf);\n\n if (!exportExpr) return undefined;\n\n // Special case for service definitions with JSDoc annotations\n if (this.definition.size > 0 && ts.isCallExpression(exportExpr) && ts.isIdentifier(exportExpr.expression)) {\n const fnName = exportExpr.expression.text;\n\n if (this.definition.has(fnName)) {\n // Check if the wrapper function is imported from the designated package name\n let importPath: string | undefined;\n try {\n importPath = this.getImports().get(fnName);\n } catch {\n // unable to resolve import source -> ignore wrapper\n return undefined;\n }\n\n if (importPath !== PackageName) {\n // Function is not imported from the designated package name -> ignore wrapper\n console.warn(`Function ${fnName} is not imported from '${PackageName}' in file ${this.file}`);\n return undefined;\n }\n\n if (exportExpr.arguments.length > 0) {\n const firstArg = exportExpr.arguments[0];\n\n if (ts.isObjectLiteralExpression(firstArg)) {\n for (const prop of firstArg.properties) {\n const key = this.objectParser.getName(prop.name ?? prop);\n\n if (key !== this.property) continue;\n\n if (ts.isPropertyAssignment(prop)) {\n const initType = this.getTypeFromInitializer(prop.initializer);\n if (initType) return initType;\n } else if (ts.isMethodDeclaration(prop)) {\n // Get the return type of the method\n const returnType = this.getTypeFromMethodReturn(prop);\n if (returnType) return returnType;\n } else if (ts.isShorthandPropertyAssignment(prop)) {\n return this.resolveTypeFromShorthand(prop.name.text);\n }\n }\n }\n }\n }\n }\n\n const expr = this.unwrapExpression(exportExpr);\n\n if (ts.isObjectLiteralExpression(expr)) {\n for (const prop of expr.properties) {\n const key = this.objectParser.getName(prop.name ?? prop);\n\n if (key !== this.property) continue;\n\n if (ts.isPropertyAssignment(prop)) {\n return this.getTypeFromInitializer(prop.initializer);\n } else if (ts.isMethodDeclaration(prop) || ts.isGetAccessorDeclaration(prop)) {\n const sig = this.signatureBuilder.getMethodSignature(prop as ts.MethodDeclaration);\n\n return this.signatureBuilder.buildFunctionType(sig);\n } else if (ts.isShorthandPropertyAssignment(prop)) {\n return this.resolveTypeFromShorthand(prop.name.text);\n }\n }\n return undefined;\n }\n\n // Fallback: treat default export expression as initializer\n return this.getTypeFromInitializer(expr);\n }\n\n // Default: parse full default export into interface-like string\n let members: Record<string, MemberSignature> | undefined;\n const sf = this.getSourceFile();\n\n const collect = (node: ts.Node) => {\n if (ts.isExportAssignment(node)) {\n const expr0 = node.expression;\n const expr = this.unwrapExpression(expr0);\n const parsed = this.parse(expr);\n if (parsed) members = parsed;\n }\n ts.forEachChild(node, collect);\n };\n\n collect(sf);\n if (!members) return undefined;\n return this.signatureBuilder.formatMembers(members);\n }\n\n public setProperty(property: string): this {\n this.property = property;\n\n return this;\n }\n\n /**\n * Entry point: accepts an expression and returns a map of member signatures,\n * or undefined if the expression cannot be parsed.\n */\n protected parse(expr: ts.Expression): Record<string, MemberSignature> | undefined {\n if (ts.isFunctionExpression(expr) || ts.isArrowFunction(expr)) {\n return this.functionParser.parse(expr);\n } else if (ts.isObjectLiteralExpression(expr)) {\n return this.objectParser.parse(expr);\n } else if (ts.isClassExpression(expr)) {\n return this.classParser.parse(expr);\n }\n\n return undefined;\n }\n\n /**\n * Specify wrapper functions whose first argument should be unwrapped for parsing.\n */\n public setDefinition(definition: string | string[]): this {\n const defs = typeof definition === \"string\" ? [definition] : definition;\n\n defs.forEach(def => this.definition.add(def));\n\n return this;\n }\n\n /**\n * Recursively unwraps type assertions, satisfies, parentheses, and allowed wrapper calls.\n */\n private unwrapExpression(expr: ts.Expression): ts.Expression {\n // First use the AbstractExpressionParser's unwrapExpression for basic unwrapping\n expr = this.functionParser.unwrapExpression(expr);\n\n // Explicitly handle type assertions\n if (ts.isAsExpression(expr)) {\n return this.unwrapExpression(expr.expression);\n }\n\n // Then handle the additional unwrapping for known definition wrappers\n if (ts.isCallExpression(expr) && ts.isIdentifier(expr.expression)) {\n const fnName = expr.expression.text;\n\n if (this.definition.has(fnName)) {\n let importPath: string | undefined;\n\n try {\n importPath = this.getImports().get(fnName);\n } catch {\n // unable to resolve import source -> ignore wrapper\n return expr;\n }\n\n if (importPath !== PackageName) {\n console.warn(`Function ${fnName} is not imported from '${PackageName}' in file ${this.file}`);\n } else if (expr.arguments.length > 0) {\n const first = expr.arguments[0];\n return this.unwrapExpression(first as ts.Expression);\n }\n }\n }\n\n return expr;\n }\n\n /**\n * Given an initializer or expression, extracts its type: function signature or interface.\n */\n private getTypeFromInitializer(\n node: ts.Expression | ts.MethodDeclaration | ts.GetAccessorDeclaration\n ): string | undefined {\n // Unwrap type assertions\n if (ts.isAsExpression(node)) {\n return this.getTypeFromInitializer(node.expression);\n }\n\n // Function or arrow function: try to parse returned object or instance\n if (ts.isFunctionExpression(node) || ts.isArrowFunction(node)) {\n // attempt to parse returned expression into members\n const members = this.functionParser.parse(node as ts.FunctionExpression | ts.ArrowFunction);\n\n if (members) {\n return this.signatureBuilder.formatMembers(members);\n }\n\n // fallback to function signature\n const sig = this.signatureBuilder.getMethodSignature(node as ts.FunctionExpression | ts.ArrowFunction);\n\n return this.signatureBuilder.buildFunctionType(sig);\n }\n\n // Class or method-like: signature of accessor/method\n if (ts.isMethodDeclaration(node) || ts.isGetAccessorDeclaration(node)) {\n const sig = this.signatureBuilder.getMethodSignature(node as ts.MethodDeclaration);\n return this.signatureBuilder.buildFunctionType(sig);\n }\n\n // Object literal, class expression/declaration, or new expression: return interface of members\n let members: Record<string, MemberSignature> | undefined;\n\n if (ts.isObjectLiteralExpression(node) || ts.isClassExpression(node) || ts.isClassDeclaration(node)) {\n members = this.parse(node as ts.Expression);\n } else if (ts.isNewExpression(node)) {\n const ctor = node.expression;\n\n if (ts.isIdentifier(ctor)) {\n members = this.classParser.parseFileClass(ctor.text);\n } else if (ts.isClassExpression(ctor)) {\n members = this.classParser.parse(ctor);\n }\n }\n\n if (members) {\n return this.signatureBuilder.formatMembers(members);\n }\n\n if (ts.isLiteralExpression(node) || ts.isArrayLiteralExpression(node) || ts.isObjectLiteralExpression(node)) {\n return this.objectParser.inferTypeFromExpression(node as ts.Expression);\n }\n\n return undefined;\n }\n\n private resolveTypeFromShorthand(name: string): string | undefined {\n const varDecl = this.nodeFinder.findVariableDeclaration(name);\n if (varDecl && varDecl.initializer) {\n const t = this.getTypeFromInitializer(varDecl.initializer);\n if (t) return t;\n }\n const variable = this.getVariables().get(name);\n if (variable) {\n const val = variable.value;\n switch (typeof val) {\n case \"string\":\n return \"string\";\n case \"number\":\n return \"number\";\n case \"boolean\":\n return \"boolean\";\n case \"object\":\n if (val === null) return \"null\";\n if (Array.isArray(val)) return \"array\";\n return \"object\";\n default:\n return \"any\";\n }\n }\n return \"any\";\n }\n\n /**\n * Extracts the type of the return value of a method, taking into account JSDoc annotations.\n *\n * @param method The method declaration to extract the return type from\n * @returns The extracted return type as a string, or undefined if it cannot be extracted\n */\n private getTypeFromMethodReturn(method: ts.MethodDeclaration): string | undefined {\n // Try to find a return statement in the method body\n if (method.body) {\n // First, check if there's a JSDoc return type annotation\n const jsDocReturnType = this.jsDocParser.getJSDocReturnType(method);\n if (jsDocReturnType) {\n // If the return type is a new expression, try to parse it\n if (jsDocReturnType.includes(\"new \")) {\n const className = jsDocReturnType.replace(\"new \", \"\").trim();\n const members = this.classParser.parseFileClass(className);\n if (members) {\n return this.signatureBuilder.formatMembers(members);\n }\n }\n\n // If the return type is a class name, try to parse it\n const members = this.classParser.parseFileClass(jsDocReturnType);\n if (members) {\n return this.signatureBuilder.formatMembers(members);\n }\n\n return jsDocReturnType;\n }\n\n // If there's no JSDoc return type, try to find a return statement\n let returnExpr: ts.Expression | undefined;\n\n const findReturn = (node: ts.Node): void => {\n if (ts.isReturnStatement(node) && node.expression) {\n returnExpr = node.expression;\n return;\n }\n ts.forEachChild(node, findReturn);\n };\n\n findReturn(method.body);\n\n if (returnExpr) {\n return this.getTypeFromInitializer(returnExpr);\n }\n }\n\n // If we couldn't find a return statement, use the method's return type\n if (method.type) {\n return this.typeResolver.resolveTypeNode(method.type);\n }\n\n return undefined;\n }\n}\n"],"mappings":"AAAA,OAAO,QAAQ;AAEf,OAAO,gBAAgB;AACvB;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AAGP,SAAQ,mBAAkB;AAM1B,MAAO,uBAAqC,WAAW;AAAA,EACzC;AAAA;AAAA;AAAA;AAAA,EA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,GAAG,EAAG,QAAO;AAC/B,iBAAO;AAAA,QACX;AACI,iBAAO;AAAA,MACf;AAAA,IACJ;AACA,WAAO;AAAA,EACX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQQ,wBAAwB,QAAkD;AAE9E,QAAI,OAAO,MAAM;AAEb,YAAM,kBAAkB,KAAK,YAAY,mBAAmB,MAAM;AAClE,UAAI,iBAAiB;AAEjB,YAAI,gBAAgB,SAAS,MAAM,GAAG;AAClC,gBAAM,YAAY,gBAAgB,QAAQ,QAAQ,EAAE,EAAE,KAAK;AAC3D,gBAAMA,WAAU,KAAK,YAAY,eAAe,SAAS;AACzD,cAAIA,UAAS;AACT,mBAAO,KAAK,iBAAiB,cAAcA,QAAO;AAAA,UACtD;AAAA,QACJ;AAGA,cAAM,UAAU,KAAK,YAAY,eAAe,eAAe;AAC/D,YAAI,SAAS;AACT,iBAAO,KAAK,iBAAiB,cAAc,OAAO;AAAA,QACtD;AAEA,eAAO;AAAA,MACX;AAGA,UAAI;AAEJ,YAAM,aAAa,CAAC,SAAwB;AACxC,YAAI,GAAG,kBAAkB,IAAI,KAAK,KAAK,YAAY;AAC/C,uBAAa,KAAK;AAClB;AAAA,QACJ;AACA,WAAG,aAAa,MAAM,UAAU;AAAA,MACpC;AAEA,iBAAW,OAAO,IAAI;AAEtB,UAAI,YAAY;AACZ,eAAO,KAAK,uBAAuB,UAAU;AAAA,MACjD;AAAA,IACJ;AAGA,QAAI,OAAO,MAAM;AACb,aAAO,KAAK,aAAa,gBAAgB,OAAO,IAAI;AAAA,IACxD;AAEA,WAAO;AAAA,EACX;AACJ;","names":["sf","members"]}
@@ -7,8 +7,10 @@ export default class<T extends Record<string, any>> extends SourceFile {
7
7
  setDefinition(definition: string | string[]): this;
8
8
  setProperties(properties: string[]): this;
9
9
  getOptions(): T;
10
+ /** Presence does not require evaluating the property's value (for example a render method). */
11
+ getDeclaredProperties(): Set<string>;
10
12
  getDefinition(): string | undefined;
11
- protected getOptionsFromVariables(): T;
12
- protected getOptionsFromDefinition(): T;
13
+ private requireValue;
14
+ private getOptionBindings;
13
15
  protected getExpressionForOptions(expr: ts.Expression): ts.Expression | undefined;
14
16
  }
@@ -18,41 +18,48 @@ class OptionFile_default extends SourceFile {
18
18
  return this;
19
19
  }
20
20
  getOptions() {
21
- return { ...this.getOptionsFromVariables(), ...this.getOptionsFromDefinition() };
21
+ const options = [];
22
+ for (const [name, binding] of this.getOptionBindings()) {
23
+ if (!this.properties.has(name)) continue;
24
+ const value = this.requireValue(binding.source.parseNode(binding.node, name));
25
+ options.push([name, value]);
26
+ }
27
+ return Object.fromEntries(options);
28
+ }
29
+ /** Presence does not require evaluating the property's value (for example a render method). */
30
+ getDeclaredProperties() {
31
+ return new Set(this.getOptionBindings().keys());
22
32
  }
23
33
  getDefinition() {
24
- if (this.definition === void 0) {
25
- this.getOptionsFromDefinition();
26
- }
27
- if (this.definition === null) {
28
- return;
29
- }
30
- return this.definition;
34
+ if (this.definition === void 0) this.getOptionBindings();
35
+ return this.definition ?? void 0;
31
36
  }
32
- getOptionsFromVariables() {
33
- const options = Array.from(this.getVariables().values()).filter(({ name, exported }) => exported && this.properties.has(name)).reduce((config, { name, value }) => ({ ...config, [name]: value }), {});
34
- return options;
37
+ requireValue(result) {
38
+ if (result.resolved) return result.value;
39
+ const origin = result.file === this.file ? "" : ` (declared in "${result.file}")`;
40
+ throw new Error(
41
+ `Invalid options in "${this.file}": ${result.path || "options"} must be statically known: ${result.reason}${origin}`
42
+ );
35
43
  }
36
- getOptionsFromDefinition() {
37
- let options = {};
38
- const parse = (node) => {
39
- if (ts.isExportAssignment(node)) {
40
- const expr = this.getExpressionForOptions(node.expression);
41
- if (expr) {
42
- options = this.parseNode(expr);
43
- }
44
- }
45
- ts.forEachChild(node, parse);
46
- };
47
- parse(this.getSourceFile());
48
- return _.pickBy(options, (_2, key) => this.properties.has(key));
44
+ getOptionBindings() {
45
+ const bindings = this.getBindings(true);
46
+ bindings.delete("default");
47
+ for (const statement of this.getSourceFile().statements) {
48
+ if (!ts.isExportAssignment(statement)) continue;
49
+ const expression = this.getExpressionForOptions(statement.expression);
50
+ if (!expression) continue;
51
+ const properties = this.requireValue(this.getProperties(expression));
52
+ for (const [name, binding] of properties) bindings.set(name, binding);
53
+ }
54
+ return bindings;
49
55
  }
50
56
  getExpressionForOptions(expr) {
51
57
  this.definition = null;
58
+ while (ts.isAsExpression(expr) || ts.isSatisfiesExpression(expr) || ts.isParenthesizedExpression(expr) || ts.isTypeAssertionExpression(expr)) {
59
+ expr = expr.expression;
60
+ }
52
61
  if (ts.isObjectLiteralExpression(expr)) {
53
62
  return expr;
54
- } else if ((ts.isAsExpression(expr) || ts.isSatisfiesExpression(expr)) && ts.isObjectLiteralExpression(expr.expression)) {
55
- return expr.expression;
56
63
  } else if (ts.isCallExpression(expr) && ts.isIdentifier(expr.expression)) {
57
64
  const functionName = expr.expression.text;
58
65
  if (this.getImports().get(functionName) !== PackageName) {
@@ -60,11 +67,8 @@ class OptionFile_default extends SourceFile {
60
67
  return;
61
68
  }
62
69
  if (this.definitions.has(functionName) && expr.arguments.length > 0) {
63
- const arg = expr.arguments[0];
64
- if (ts.isObjectLiteralExpression(arg)) {
65
- this.definition = functionName;
66
- return arg;
67
- }
70
+ this.definition = functionName;
71
+ return expr.arguments[0];
68
72
  }
69
73
  }
70
74
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/cli/entrypoint/file/OptionFile.ts"],"sourcesContent":["import ts from \"typescript\";\nimport _ from \"lodash\";\n\nimport SourceFile from \"./SourceFile\";\n\nimport {PackageName} from \"@typing/app\";\n\nexport default class<T extends Record<string, any>> extends SourceFile {\n protected definitions = new Set<string>();\n\n protected definition: string | null | undefined = undefined;\n\n protected properties = new Set<string>();\n\n public setDefinition(definition: string | string[]): this {\n if (_.isString(definition)) {\n definition = [definition];\n }\n\n definition.forEach(definition => this.definitions.add(definition));\n\n return this;\n }\n\n public setProperties(properties: string[]): this {\n properties.forEach(property => this.properties.add(property));\n\n return this;\n }\n\n public getOptions(): T {\n return {...this.getOptionsFromVariables(), ...this.getOptionsFromDefinition()};\n }\n\n public getDefinition(): string | undefined {\n if (this.definition === undefined) {\n this.getOptionsFromDefinition();\n }\n\n if (this.definition === null) {\n return;\n }\n\n return this.definition;\n }\n\n protected getOptionsFromVariables(): T {\n const options = Array.from(this.getVariables().values())\n .filter(({name, exported}) => exported && this.properties.has(name))\n .reduce((config, {name, value}) => ({...config, [name]: value}), {});\n\n return options as T;\n }\n\n protected getOptionsFromDefinition(): T {\n let options = {} as T;\n\n const parse = (node: ts.Node) => {\n if (ts.isExportAssignment(node)) {\n const expr = this.getExpressionForOptions(node.expression);\n\n if (expr) {\n options = this.parseNode(expr);\n }\n }\n\n ts.forEachChild(node, parse);\n };\n\n parse(this.getSourceFile());\n\n return _.pickBy(options, (_, key) => this.properties.has(key)) as T;\n }\n\n protected getExpressionForOptions(expr: ts.Expression): ts.Expression | undefined {\n this.definition = null;\n\n if (ts.isObjectLiteralExpression(expr)) {\n return expr;\n } else if (\n (ts.isAsExpression(expr) || ts.isSatisfiesExpression(expr)) &&\n ts.isObjectLiteralExpression(expr.expression)\n ) {\n return expr.expression;\n } else if (ts.isCallExpression(expr) && ts.isIdentifier(expr.expression)) {\n const functionName = expr.expression.text;\n\n if (this.getImports().get(functionName) !== PackageName) {\n console.warn(`Function ${functionName} is not imported from '${PackageName}' on file ${this.file}`);\n\n return;\n }\n\n if (this.definitions.has(functionName) && expr.arguments.length > 0) {\n const arg = expr.arguments[0];\n\n if (ts.isObjectLiteralExpression(arg)) {\n this.definition = functionName;\n\n return arg;\n }\n }\n }\n }\n}\n"],"mappings":"AAAA,OAAO,QAAQ;AACf,OAAO,OAAO;AAEd,OAAO,gBAAgB;AAEvB,SAAQ,mBAAkB;AAE1B,MAAO,2BAAqD,WAAW;AAAA,EACzD,cAAc,oBAAI,IAAY;AAAA,EAE9B,aAAwC;AAAA,EAExC,aAAa,oBAAI,IAAY;AAAA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AAG,CAAC;AAAA,EACjE;AAAA,EAEU,wBAAwB,MAAgD;AAC9E,SAAK,aAAa;AAElB,QAAI,GAAG,0BAA0B,IAAI,GAAG;AACpC,aAAO;AAAA,IACX,YACK,GAAG,eAAe,IAAI,KAAK,GAAG,sBAAsB,IAAI,MACzD,GAAG,0BAA0B,KAAK,UAAU,GAC9C;AACE,aAAO,KAAK;AAAA,IAChB,WAAW,GAAG,iBAAiB,IAAI,KAAK,GAAG,aAAa,KAAK,UAAU,GAAG;AACtE,YAAM,eAAe,KAAK,WAAW;AAErC,UAAI,KAAK,WAAW,EAAE,IAAI,YAAY,MAAM,aAAa;AACrD,gBAAQ,KAAK,YAAY,YAAY,0BAA0B,WAAW,aAAa,KAAK,IAAI,EAAE;AAElG;AAAA,MACJ;AAEA,UAAI,KAAK,YAAY,IAAI,YAAY,KAAK,KAAK,UAAU,SAAS,GAAG;AACjE,cAAM,MAAM,KAAK,UAAU,CAAC;AAE5B,YAAI,GAAG,0BAA0B,GAAG,GAAG;AACnC,eAAK,aAAa;AAElB,iBAAO;AAAA,QACX;AAAA,MACJ;AAAA,IACJ;AAAA,EACJ;AACJ;","names":["definition","_"]}
1
+ {"version":3,"sources":["../../../../src/cli/entrypoint/file/OptionFile.ts"],"sourcesContent":["import ts from \"typescript\";\nimport _ from \"lodash\";\n\nimport SourceFile from \"./SourceFile\";\nimport type {SourceBinding, SourceReadResult} from \"./types\";\n\nimport {PackageName} from \"@typing/app\";\n\nexport default class<T extends Record<string, any>> extends SourceFile {\n protected definitions = new Set<string>();\n\n protected definition: string | null | undefined = undefined;\n\n protected properties = new Set<string>();\n\n public setDefinition(definition: string | string[]): this {\n if (_.isString(definition)) {\n definition = [definition];\n }\n\n definition.forEach(definition => this.definitions.add(definition));\n\n return this;\n }\n\n public setProperties(properties: string[]): this {\n properties.forEach(property => this.properties.add(property));\n\n return this;\n }\n\n public getOptions(): T {\n const options: [string, unknown][] = [];\n for (const [name, binding] of this.getOptionBindings()) {\n if (!this.properties.has(name)) continue;\n const value = this.requireValue(binding.source.parseNode(binding.node, name));\n options.push([name, value]);\n }\n return Object.fromEntries(options) as T;\n }\n\n /** Presence does not require evaluating the property's value (for example a render method). */\n public getDeclaredProperties(): Set<string> {\n return new Set(this.getOptionBindings().keys());\n }\n\n public getDefinition(): string | undefined {\n if (this.definition === undefined) this.getOptionBindings();\n return this.definition ?? undefined;\n }\n\n private requireValue<V>(result: SourceReadResult<V>): V {\n if (result.resolved) return result.value;\n const origin = result.file === this.file ? \"\" : ` (declared in \"${result.file}\")`;\n throw new Error(\n `Invalid options in \"${this.file}\": ${result.path || \"options\"} must be statically known: ${result.reason}${origin}`\n );\n }\n\n private getOptionBindings(): Map<string, SourceBinding> {\n const bindings = this.getBindings(true);\n bindings.delete(\"default\");\n for (const statement of this.getSourceFile().statements) {\n if (!ts.isExportAssignment(statement)) continue;\n const expression = this.getExpressionForOptions(statement.expression);\n if (!expression) continue;\n const properties = this.requireValue(this.getProperties(expression));\n for (const [name, binding] of properties) bindings.set(name, binding);\n }\n return bindings;\n }\n\n protected getExpressionForOptions(expr: ts.Expression): ts.Expression | undefined {\n this.definition = null;\n\n while (\n ts.isAsExpression(expr) ||\n ts.isSatisfiesExpression(expr) ||\n ts.isParenthesizedExpression(expr) ||\n ts.isTypeAssertionExpression(expr)\n ) {\n expr = expr.expression;\n }\n\n if (ts.isObjectLiteralExpression(expr)) {\n return expr;\n } else if (ts.isCallExpression(expr) && ts.isIdentifier(expr.expression)) {\n const functionName = expr.expression.text;\n\n if (this.getImports().get(functionName) !== PackageName) {\n console.warn(`Function ${functionName} is not imported from '${PackageName}' on file ${this.file}`);\n\n return;\n }\n\n if (this.definitions.has(functionName) && expr.arguments.length > 0) {\n this.definition = functionName;\n return expr.arguments[0];\n }\n }\n }\n}\n"],"mappings":"AAAA,OAAO,QAAQ;AACf,OAAO,OAAO;AAEd,OAAO,gBAAgB;AAGvB,SAAQ,mBAAkB;AAE1B,MAAO,2BAAqD,WAAW;AAAA,EAC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O,SAAS;AACzB,eAAW,aAAa,KAAK,cAAc,EAAE,YAAY;AACrD,UAAI,CAAC,GAAG,mBAAmB,SAAS,EAAG;AACvC,YAAM,aAAa,KAAK,wBAAwB,UAAU,UAAU;AACpE,UAAI,CAAC,WAAY;AACjB,YAAM,aAAa,KAAK,aAAa,KAAK,cAAc,UAAU,CAAC;AACnE,iBAAW,CAAC,MAAM,OAAO,KAAK,WAAY,UAAS,IAAI,MAAM,OAAO;AAAA,IACxE;AACA,WAAO;AAAA,EACX;AAAA,EAEU,wBAAwB,MAAgD;AAC9E,SAAK,aAAa;AAElB,WACI,GAAG,eAAe,IAAI,KACtB,GAAG,sBAAsB,IAAI,KAC7B,GAAG,0BAA0B,IAAI,KACjC,GAAG,0BAA0B,IAAI,GACnC;AACE,aAAO,KAAK;AAAA,IAChB;AAEA,QAAI,GAAG,0BAA0B,IAAI,GAAG;AACpC,aAAO;AAAA,IACX,WAAW,GAAG,iBAAiB,IAAI,KAAK,GAAG,aAAa,KAAK,UAAU,GAAG;AACtE,YAAM,eAAe,KAAK,WAAW;AAErC,UAAI,KAAK,WAAW,EAAE,IAAI,YAAY,MAAM,aAAa;AACrD,gBAAQ,KAAK,YAAY,YAAY,0BAA0B,WAAW,aAAa,KAAK,IAAI,EAAE;AAElG;AAAA,MACJ;AAEA,UAAI,KAAK,YAAY,IAAI,YAAY,KAAK,KAAK,UAAU,SAAS,GAAG;AACjE,aAAK,aAAa;AAClB,eAAO,KAAK,UAAU,CAAC;AAAA,MAC3B;AAAA,IACJ;AAAA,EACJ;AACJ;","names":["definition"]}
@@ -1,22 +1,33 @@
1
1
  import ts from "typescript";
2
2
  import { ImportResolver } from "./resolvers/index.js";
3
- import { EnumMap, ImportMap, VariableMap } from "./types.js";
4
- export default class EntryFile {
3
+ import type { ImportMap, VariableMap, SourceReadResult, SourceBinding } from "./types.js";
4
+ export default class SourceFile {
5
5
  protected readonly file: string;
6
6
  private sourceFile?;
7
7
  private variables?;
8
8
  private imports?;
9
- private enums?;
9
+ private sources;
10
10
  protected importResolver?: ImportResolver;
11
- static make<T extends EntryFile>(this: new (file: string) => T, file: string): T;
11
+ static make<T extends SourceFile>(this: new (file: string) => T, file: string): T;
12
12
  constructor(file: string);
13
13
  getSourceFile(): ts.SourceFile;
14
14
  getImports(): ImportMap;
15
- getEnums(): EnumMap;
15
+ /** Collect declarations without evaluating runtime functions or unrelated initializers. */
16
+ protected getBindings(exportedOnly?: boolean): Map<string, SourceBinding>;
16
17
  getVariables(): VariableMap;
17
18
  protected resolveValue(from: string, target: string, name: string): any;
18
- protected findPropertyAccessValue(property: ts.Node): any;
19
- parseNode(node?: ts.Node): any;
19
+ private getImportBinding;
20
+ private getImportedSource;
21
+ private failure;
22
+ /** Follow static bindings, retaining their source module and detecting reference cycles. */
23
+ private resolveNode;
24
+ parseNode(node?: ts.Node, property?: string): SourceReadResult;
25
+ /** Read an object's shape first so callers can select build fields before evaluating values. */
26
+ protected getProperties(node: ts.Node, property?: string): SourceReadResult<Map<string, SourceBinding>>;
27
+ private readProperties;
28
+ private objectProperties;
29
+ private readValue;
30
+ private readResolvedValue;
20
31
  protected getInputResolver(): ImportResolver;
21
32
  setImportResolver(resolver: ImportResolver): ImportResolver;
22
33
  }