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 +1 @@
1
- {"version":3,"sources":["../../../src/locale/providers/NativeLocale.ts"],"sourcesContent":["import {getI18nMessage} from \"@addon-core/browser\";\n\nimport AbstractLocale from \"./AbstractLocale\";\n\nimport {convertLocaleKey, resolveLanguage} from \"@locale/utils\";\n\nimport {Language, LocaleCustomKeyForLanguage, LocaleProvider} from \"@typing/locale\";\n\n/** Augmented by the generated .adnbn/locale.d.ts for the current app. */\nexport interface LocaleNativeStructure {}\n\nexport default class NativeLocale<S extends object = LocaleNativeStructure> extends AbstractLocale<S> {\n private static instance?: LocaleProvider<LocaleNativeStructure>;\n\n public static getInstance(): LocaleProvider<LocaleNativeStructure> {\n return (NativeLocale.instance ??= new NativeLocale());\n }\n\n private readonly language?: Language;\n\n constructor() {\n super();\n\n /**\n Locale detection note:\n Chrome does NOT expose an API to get the effective translation locale.\n getUILanguage() returns browser UI language (e.g., es-MX),\n even if extension translations fall back to default_locale (e.g., en).\n To detect the actual language used by i18n, we read a locale marker\n from messages.json via chrome.i18n.getMessage().\n */\n const markerLang = getI18nMessage(LocaleCustomKeyForLanguage);\n const resolvedLang = resolveLanguage(markerLang);\n\n if (!resolvedLang) {\n console.warn(`[NativeLocale] Unsupported language detected: \"${markerLang}\".`);\n }\n\n if (markerLang && resolvedLang && markerLang !== resolvedLang) {\n console.info(`[NativeLocale] Language normalized: using \"${resolvedLang}\" instead of \"${markerLang}\".`);\n }\n\n this.language = resolvedLang;\n }\n\n public lang(): Language {\n if (!this.language) {\n throw new Error(\"[NativeLocale] Language is not defined. Failed to determine a supported locale.\");\n }\n\n return this.language;\n }\n\n public keys(): Set<keyof S> {\n try {\n // @ts-expect-error: __ADNBN_LOCALE_KEYS__ is a virtual variable generated by the bundler `src/cli/plugins/locale/index.ts`\n return new Set<string>(__ADNBN_LOCALE_KEYS__) as Set<keyof S>;\n } catch (e) {\n console.error(\"[NativeLocale] Failed to access locale keys. Ensure the bundler plugin is active.\", e);\n\n return new Set<keyof S>();\n }\n }\n\n public languages(): Set<Language> {\n try {\n // @ts-expect-error: __ADNBN_DEFINED_LOCALES__ is a virtual variable generated by the bundler `src/cli/plugins/locale/index.ts`\n return new Set<Language>(__ADNBN_DEFINED_LOCALES__);\n } catch (e) {\n console.error(\"[NativeLocale] Failed to access defined locales. Check virtual variables configuration.\", e);\n\n return new Set<Language>();\n }\n }\n\n protected value(key: Extract<keyof S, string>): string | undefined {\n const value = getI18nMessage(convertLocaleKey(key));\n\n // Native i18n returns an empty string for missing messages too; build keys distinguish valid empty translations.\n if (value === \"\" && !this.keys().has(key)) {\n return undefined;\n }\n\n return value;\n }\n}\n"],"mappings":"AAAA,SAAQ,sBAAqB;AAE7B,OAAO,oBAAoB;AAE3B,SAAQ,kBAAkB,uBAAsB;AAEhD,SAAkB,kCAAiD;AAKnE,MAAO,qBAA6E,eAAkB;AAAA,EAClG,OAAe;AAAA,EAEf,OAAc,cAAqD;AAC/D,WAAQ,aAAa,aAAb,aAAa,WAAa,IAAI,aAAa;AAAA,EACvD;AAAA,EAEiB;AAAA,EAEjB,cAAc;AACV,UAAM;AAUN,UAAM,aAAa,eAAe,0BAA0B;AAC5D,UAAM,eAAe,gBAAgB,UAAU;AAE/C,QAAI,CAAC,cAAc;AACf,cAAQ,KAAK,kDAAkD,UAAU,IAAI;AAAA,IACjF;AAEA,QAAI,cAAc,gBAAgB,eAAe,cAAc;AAC3D,cAAQ,KAAK,8CAA8C,YAAY,iBAAiB,UAAU,IAAI;AAAA,IAC1G;AAEA,SAAK,WAAW;AAAA,EACpB;AAAA,EAEO,OAAiB;AACpB,QAAI,CAAC,KAAK,UAAU;AAChB,YAAM,IAAI,MAAM,iFAAiF;AAAA,IACrG;AAEA,WAAO,KAAK;AAAA,EAChB;AAAA,EAEO,OAAqB;AACxB,QAAI;AAEA,aAAO,IAAI,IAAY,qBAAqB;AAAA,IAChD,SAAS,GAAG;AACR,cAAQ,MAAM,qFAAqF,CAAC;AAEpG,aAAO,oBAAI,IAAa;AAAA,IAC5B;AAAA,EACJ;AAAA,EAEO,YAA2B;AAC9B,QAAI;AAEA,aAAO,IAAI,IAAc,yBAAyB;AAAA,IACtD,SAAS,GAAG;AACR,cAAQ,MAAM,2FAA2F,CAAC;AAE1G,aAAO,oBAAI,IAAc;AAAA,IAC7B;AAAA,EACJ;AAAA,EAEU,MAAM,KAAmD;AAC/D,UAAM,QAAQ,eAAe,iBAAiB,GAAG,CAAC;AAGlD,QAAI,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE,IAAI,GAAG,GAAG;AACvC,aAAO;AAAA,IACX;AAEA,WAAO;AAAA,EACX;AACJ;","names":[]}
1
+ {"version":3,"sources":["../../../src/locale/providers/NativeLocale.ts"],"sourcesContent":["import {getI18nMessage} from \"@addon-core/browser\";\nimport {keys, languages} from \"#adnbn/locale\";\n\nimport AbstractLocale from \"./AbstractLocale\";\n\nimport {convertLocaleKey, resolveLanguage} from \"@shared/locale\";\n\nimport {Language, LocaleCustomKeyForLanguage, type LocaleRegistry} from \"@typing/locale\";\n\nexport default class NativeLocale<S extends object = LocaleRegistry> extends AbstractLocale<S> {\n private static instance?: NativeLocale<LocaleRegistry>;\n\n public static getInstance(): NativeLocale<LocaleRegistry> {\n return (NativeLocale.instance ??= new NativeLocale());\n }\n\n private readonly language?: Language;\n\n constructor() {\n super();\n\n /**\n Locale detection note:\n Chrome does NOT expose an API to get the effective translation locale.\n getUILanguage() returns browser UI language (e.g., es-MX),\n even if extension translations fall back to default_locale (e.g., en).\n To detect the actual language used by i18n, we read a locale marker\n from messages.json via chrome.i18n.getMessage().\n */\n const markerLang = getI18nMessage(LocaleCustomKeyForLanguage);\n const resolvedLang = resolveLanguage(markerLang);\n\n if (!resolvedLang) {\n console.warn(`[NativeLocale] Unsupported language detected: \"${markerLang}\".`);\n }\n\n if (markerLang && resolvedLang && markerLang !== resolvedLang) {\n console.info(`[NativeLocale] Language normalized: using \"${resolvedLang}\" instead of \"${markerLang}\".`);\n }\n\n this.language = resolvedLang;\n }\n\n public lang(): Language {\n if (!this.language) {\n throw new Error(\"[NativeLocale] Language is not defined. Failed to determine a supported locale.\");\n }\n\n return this.language;\n }\n\n public keys(): Set<keyof S> {\n return new Set(keys) as Set<keyof S>;\n }\n\n public langs(): ReadonlySet<Language> {\n return new Set(languages);\n }\n\n protected value(key: Extract<keyof S, string>): string | undefined {\n const value = getI18nMessage(convertLocaleKey(key));\n\n // Native i18n returns an empty string for missing messages too; build keys distinguish valid empty translations.\n if (value === \"\" && !this.keys().has(key)) {\n return undefined;\n }\n\n return value;\n }\n}\n"],"mappings":"AAAA,SAAQ,sBAAqB;AAC7B,SAAQ,MAAM,iBAAgB;AAE9B,OAAO,oBAAoB;AAE3B,SAAQ,kBAAkB,uBAAsB;AAEhD,SAAkB,kCAAsD;AAExE,MAAO,qBAAsE,eAAkB;AAAA,EAC3F,OAAe;AAAA,EAEf,OAAc,cAA4C;AACtD,WAAQ,aAAa,aAAb,aAAa,WAAa,IAAI,aAAa;AAAA,EACvD;AAAA,EAEiB;AAAA,EAEjB,cAAc;AACV,UAAM;AAUN,UAAM,aAAa,eAAe,0BAA0B;AAC5D,UAAM,eAAe,gBAAgB,UAAU;AAE/C,QAAI,CAAC,cAAc;AACf,cAAQ,KAAK,kDAAkD,UAAU,IAAI;AAAA,IACjF;AAEA,QAAI,cAAc,gBAAgB,eAAe,cAAc;AAC3D,cAAQ,KAAK,8CAA8C,YAAY,iBAAiB,UAAU,IAAI;AAAA,IAC1G;AAEA,SAAK,WAAW;AAAA,EACpB;AAAA,EAEO,OAAiB;AACpB,QAAI,CAAC,KAAK,UAAU;AAChB,YAAM,IAAI,MAAM,iFAAiF;AAAA,IACrG;AAEA,WAAO,KAAK;AAAA,EAChB;AAAA,EAEO,OAAqB;AACxB,WAAO,IAAI,IAAI,IAAI;AAAA,EACvB;AAAA,EAEO,QAA+B;AAClC,WAAO,IAAI,IAAI,SAAS;AAAA,EAC5B;AAAA,EAEU,MAAM,KAAmD;AAC/D,UAAM,QAAQ,eAAe,iBAAiB,GAAG,CAAC;AAGlD,QAAI,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE,IAAI,GAAG,GAAG;AACvC,aAAO;AAAA,IACX;AAEA,WAAO;AAAA,EACX;AACJ;","names":[]}
@@ -0,0 +1,35 @@
1
+ import type { Language, LocaleDynamicProvider, LocaleNonPluralKeys, LocalePluralKeys, LocaleRegistry, LocaleSnapshot, LocaleStorageDriver, LocaleSubstitutionArgs, LocaleSubstitutionValue } from "../../types/locale.js";
2
+ /** Dynamic translations with shared instances and subscriptions independent of any UI framework. */
3
+ export default class ObservableLocale<T extends object = LocaleRegistry> implements LocaleDynamicProvider<T> {
4
+ private static defaultInstance?;
5
+ private static memoryInstance?;
6
+ private static readonly drivers;
7
+ static getInstance(storage?: LocaleStorageDriver | false): ObservableLocale;
8
+ private readonly locale;
9
+ private readonly storage?;
10
+ private readonly listeners;
11
+ private readonly languages;
12
+ private readonly languageNames;
13
+ private currentSnapshot;
14
+ private revision;
15
+ private writes;
16
+ private pendingWrites;
17
+ private unsubscribe?;
18
+ constructor(storage?: LocaleStorageDriver | false);
19
+ lang(): Language;
20
+ langs(): ReadonlySet<Language>;
21
+ langNames(): ReadonlyMap<Language, string>;
22
+ keys(): Set<keyof T>;
23
+ get<K extends keyof T & string>(key: K, substitutions?: Record<string, LocaleSubstitutionValue>): string;
24
+ trans<K extends LocaleNonPluralKeys<T>>(key: K, ...args: LocaleSubstitutionArgs<T, K>): string;
25
+ choice<K extends LocalePluralKeys<T>>(key: K, count: number, ...args: LocaleSubstitutionArgs<T, K>): string;
26
+ readonly snapshot: () => LocaleSnapshot<T>;
27
+ readonly subscribe: (listener: () => void) => (() => void);
28
+ readonly change: (lang: Language) => Promise<Language>;
29
+ sync(): Promise<Language>;
30
+ private connect;
31
+ private disconnect;
32
+ private refresh;
33
+ private createSnapshot;
34
+ private publish;
35
+ }
@@ -0,0 +1,179 @@
1
+ import DynamicLocale from "./DynamicLocale.js";
2
+ import CustomLocale from "./CustomLocale.js";
3
+ import { LocaleStorage } from "../storage/index.js";
4
+ class ObservableLocale {
5
+ static defaultInstance;
6
+ static memoryInstance;
7
+ static drivers = /* @__PURE__ */ new WeakMap();
8
+ static getInstance(storage) {
9
+ if (typeof storage === "object") {
10
+ let instance = this.drivers.get(storage);
11
+ if (!instance) {
12
+ instance = new ObservableLocale(storage);
13
+ this.drivers.set(storage, instance);
14
+ }
15
+ return instance;
16
+ }
17
+ if (storage === false) {
18
+ return this.memoryInstance ?? (this.memoryInstance = new ObservableLocale(false));
19
+ }
20
+ return this.defaultInstance ?? (this.defaultInstance = new ObservableLocale());
21
+ }
22
+ locale = new DynamicLocale(false);
23
+ storage;
24
+ listeners = /* @__PURE__ */ new Set();
25
+ languages;
26
+ languageNames;
27
+ currentSnapshot;
28
+ revision = 0;
29
+ writes = Promise.resolve();
30
+ pendingWrites = 0;
31
+ unsubscribe;
32
+ constructor(storage) {
33
+ this.storage = storage === false ? void 0 : storage ?? new LocaleStorage();
34
+ this.languages = this.langs();
35
+ this.languageNames = this.langNames();
36
+ this.currentSnapshot = this.createSnapshot();
37
+ }
38
+ lang() {
39
+ return this.locale.lang();
40
+ }
41
+ langs() {
42
+ return this.locale.langs();
43
+ }
44
+ langNames() {
45
+ return this.locale.langNames();
46
+ }
47
+ keys() {
48
+ return this.locale.keys();
49
+ }
50
+ get(key, substitutions) {
51
+ return this.locale.get(key, substitutions);
52
+ }
53
+ trans(key, ...args) {
54
+ return this.locale.trans(key, ...args);
55
+ }
56
+ choice(key, count, ...args) {
57
+ return this.locale.choice(key, count, ...args);
58
+ }
59
+ snapshot = () => this.currentSnapshot;
60
+ subscribe = (listener) => {
61
+ const notify = () => listener();
62
+ this.listeners.add(notify);
63
+ try {
64
+ this.connect();
65
+ } catch (error) {
66
+ this.listeners.delete(notify);
67
+ throw error;
68
+ }
69
+ if (this.listeners.size === 1) {
70
+ void this.refresh();
71
+ }
72
+ return () => {
73
+ this.listeners.delete(notify);
74
+ this.disconnect();
75
+ };
76
+ };
77
+ change = async (lang) => {
78
+ this.locale.select(lang);
79
+ const storage = this.storage;
80
+ if (!storage) {
81
+ this.publish();
82
+ return lang;
83
+ }
84
+ this.revision++;
85
+ this.pendingWrites++;
86
+ const saved = this.writes.then(() => storage.set(lang));
87
+ this.writes = saved.catch(() => void 0);
88
+ this.publish();
89
+ let succeeded = false;
90
+ try {
91
+ await saved;
92
+ succeeded = true;
93
+ return lang;
94
+ } finally {
95
+ if (--this.pendingWrites === 0 && succeeded) {
96
+ void this.refresh();
97
+ }
98
+ }
99
+ };
100
+ async sync() {
101
+ if (!this.storage) {
102
+ throw new Error("Language is not saving in storage");
103
+ }
104
+ if (this.pendingWrites) {
105
+ return this.lang();
106
+ }
107
+ const revision = ++this.revision;
108
+ const lang = await this.storage.get();
109
+ if (revision !== this.revision || this.pendingWrites) {
110
+ return this.lang();
111
+ }
112
+ if (lang === void 0) {
113
+ return this.lang();
114
+ }
115
+ if (!this.langs().has(lang)) {
116
+ console.warn(`Incorrect language code in storage - "${lang}"`);
117
+ return this.lang();
118
+ }
119
+ this.locale.select(lang);
120
+ this.publish();
121
+ return this.lang();
122
+ }
123
+ connect() {
124
+ if (!this.storage || this.unsubscribe) {
125
+ return;
126
+ }
127
+ this.unsubscribe = this.storage.watch(() => {
128
+ void this.refresh();
129
+ });
130
+ }
131
+ disconnect() {
132
+ var _a;
133
+ if (this.listeners.size) {
134
+ return;
135
+ }
136
+ this.revision++;
137
+ (_a = this.unsubscribe) == null ? void 0 : _a.call(this);
138
+ this.unsubscribe = void 0;
139
+ }
140
+ async refresh() {
141
+ if (!this.storage || this.pendingWrites) {
142
+ return;
143
+ }
144
+ try {
145
+ await this.sync();
146
+ } catch (error) {
147
+ console.error("[ObservableLocale] Cannot synchronize language:", error);
148
+ }
149
+ }
150
+ createSnapshot() {
151
+ const lang = this.lang();
152
+ const langs = this.languages;
153
+ const langNames = this.languageNames;
154
+ const reader = new CustomLocale(lang, this.locale.messages());
155
+ return Object.freeze({
156
+ lang: () => lang,
157
+ langs: () => langs,
158
+ langNames: () => langNames,
159
+ get: reader.get.bind(reader)
160
+ });
161
+ }
162
+ publish() {
163
+ if (this.currentSnapshot.lang() === this.lang()) {
164
+ return;
165
+ }
166
+ this.currentSnapshot = this.createSnapshot();
167
+ for (const listener of [...this.listeners]) {
168
+ try {
169
+ listener();
170
+ } catch (error) {
171
+ console.error("[ObservableLocale] Language subscriber failed:", error);
172
+ }
173
+ }
174
+ }
175
+ }
176
+ export {
177
+ ObservableLocale as default
178
+ };
179
+ //# sourceMappingURL=ObservableLocale.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/locale/providers/ObservableLocale.ts"],"sourcesContent":["import DynamicLocale from \"./DynamicLocale\";\nimport CustomLocale from \"./CustomLocale\";\n\nimport {LocaleStorage} from \"../storage\";\n\nimport type {\n Language,\n LocaleDynamicProvider,\n LocaleNonPluralKeys,\n LocalePluralKeys,\n LocaleRegistry,\n LocaleSnapshot,\n LocaleStorageDriver,\n LocaleSubstitutionArgs,\n LocaleSubstitutionValue,\n} from \"@typing/locale\";\n\n/** Dynamic translations with shared instances and subscriptions independent of any UI framework. */\nexport default class ObservableLocale<T extends object = LocaleRegistry> implements LocaleDynamicProvider<T> {\n private static defaultInstance?: ObservableLocale;\n private static memoryInstance?: ObservableLocale;\n\n private static readonly drivers = new WeakMap<LocaleStorageDriver, ObservableLocale>();\n\n public static getInstance(storage?: LocaleStorageDriver | false): ObservableLocale {\n if (typeof storage === \"object\") {\n let instance = this.drivers.get(storage);\n\n if (!instance) {\n instance = new ObservableLocale(storage);\n this.drivers.set(storage, instance);\n }\n\n return instance;\n }\n\n if (storage === false) {\n return (this.memoryInstance ??= new ObservableLocale(false));\n }\n\n return (this.defaultInstance ??= new ObservableLocale());\n }\n\n private readonly locale = new DynamicLocale<T>(false);\n private readonly storage?: LocaleStorageDriver;\n private readonly listeners = new Set<() => void>();\n private readonly languages: ReadonlySet<Language>;\n private readonly languageNames: ReadonlyMap<Language, string>;\n private currentSnapshot: LocaleSnapshot<T>;\n private revision = 0;\n private writes: Promise<void> = Promise.resolve();\n private pendingWrites = 0;\n private unsubscribe?: () => void;\n\n constructor(storage?: LocaleStorageDriver | false) {\n this.storage = storage === false ? undefined : (storage ?? new LocaleStorage());\n this.languages = this.langs();\n this.languageNames = this.langNames();\n this.currentSnapshot = this.createSnapshot();\n }\n\n public lang(): Language {\n return this.locale.lang();\n }\n\n public langs(): ReadonlySet<Language> {\n return this.locale.langs();\n }\n\n public langNames(): ReadonlyMap<Language, string> {\n return this.locale.langNames();\n }\n\n public keys(): Set<keyof T> {\n return this.locale.keys();\n }\n\n public get<K extends keyof T & string>(key: K, substitutions?: Record<string, LocaleSubstitutionValue>): string {\n return this.locale.get(key, substitutions);\n }\n\n public trans<K extends LocaleNonPluralKeys<T>>(key: K, ...args: LocaleSubstitutionArgs<T, K>): string {\n return this.locale.trans(key, ...args);\n }\n\n public choice<K extends LocalePluralKeys<T>>(key: K, count: number, ...args: LocaleSubstitutionArgs<T, K>): string {\n return this.locale.choice(key, count, ...args);\n }\n\n public readonly snapshot = (): LocaleSnapshot<T> => this.currentSnapshot;\n\n public readonly subscribe = (listener: () => void): (() => void) => {\n // Each subscription owns its cleanup, even when the same callback is subscribed twice.\n const notify = () => listener();\n\n this.listeners.add(notify);\n\n try {\n this.connect();\n } catch (error) {\n this.listeners.delete(notify);\n throw error;\n }\n\n if (this.listeners.size === 1) {\n void this.refresh();\n }\n\n return () => {\n this.listeners.delete(notify);\n this.disconnect();\n };\n };\n\n public readonly change = async (lang: Language): Promise<Language> => {\n this.locale.select(lang);\n\n const storage = this.storage;\n\n if (!storage) {\n this.publish();\n return lang;\n }\n\n this.revision++;\n\n // Register persistence before notifying: a subscriber may select another language immediately.\n this.pendingWrites++;\n\n const saved = this.writes.then(() => storage.set(lang));\n\n this.writes = saved.catch(() => undefined);\n\n this.publish();\n\n let succeeded = false;\n\n try {\n await saved;\n succeeded = true;\n\n return lang;\n } finally {\n if (--this.pendingWrites === 0 && succeeded) {\n void this.refresh();\n }\n }\n };\n\n public async sync(): Promise<Language> {\n if (!this.storage) {\n throw new Error(\"Language is not saving in storage\");\n }\n\n if (this.pendingWrites) {\n return this.lang();\n }\n\n const revision = ++this.revision;\n const lang = await this.storage.get();\n\n if (revision !== this.revision || this.pendingWrites) {\n return this.lang();\n }\n\n if (lang === undefined) {\n return this.lang();\n }\n\n if (!this.langs().has(lang)) {\n console.warn(`Incorrect language code in storage - \"${lang}\"`);\n\n return this.lang();\n }\n\n this.locale.select(lang);\n\n this.publish();\n\n return this.lang();\n }\n\n private connect(): void {\n if (!this.storage || this.unsubscribe) {\n return;\n }\n\n this.unsubscribe = this.storage.watch(() => {\n void this.refresh();\n });\n }\n\n private disconnect(): void {\n if (this.listeners.size) {\n return;\n }\n\n this.revision++;\n\n this.unsubscribe?.();\n this.unsubscribe = undefined;\n }\n\n private async refresh(): Promise<void> {\n if (!this.storage || this.pendingWrites) {\n return;\n }\n\n try {\n await this.sync();\n } catch (error) {\n console.error(\"[ObservableLocale] Cannot synchronize language:\", error);\n }\n }\n\n private createSnapshot(): LocaleSnapshot<T> {\n const lang = this.lang();\n const langs = this.languages;\n const langNames = this.languageNames;\n\n const reader = new CustomLocale<T>(lang, this.locale.messages());\n\n return Object.freeze({\n lang: () => lang,\n langs: () => langs,\n langNames: () => langNames,\n get: reader.get.bind(reader),\n });\n }\n\n private publish(): void {\n if (this.currentSnapshot.lang() === this.lang()) {\n return;\n }\n\n this.currentSnapshot = this.createSnapshot();\n\n for (const listener of [...this.listeners]) {\n try {\n listener();\n } catch (error) {\n console.error(\"[ObservableLocale] Language subscriber failed:\", error);\n }\n }\n }\n}\n"],"mappings":"AAAA,OAAO,mBAAmB;AAC1B,OAAO,kBAAkB;AAEzB,SAAQ,qBAAoB;AAe5B,MAAO,iBAAsG;AAAA,EACzG,OAAe;AAAA,EACf,OAAe;AAAA,EAEf,OAAwB,UAAU,oBAAI,QAA+C;AAAA,EAErF,OAAc,YAAY,SAAyD;AAC/E,QAAI,OAAO,YAAY,UAAU;AAC7B,UAAI,WAAW,KAAK,QAAQ,IAAI,OAAO;AAEvC,UAAI,CAAC,UAAU;AACX,mBAAW,IAAI,iBAAiB,OAAO;AACvC,aAAK,QAAQ,IAAI,SAAS,QAAQ;AAAA,MACtC;AAEA,aAAO;AAAA,IACX;AAEA,QAAI,YAAY,OAAO;AACnB,aAAQ,KAAK,mBAAL,KAAK,iBAAmB,IAAI,iBAAiB,KAAK;AAAA,IAC9D;AAEA,WAAQ,KAAK,oBAAL,KAAK,kBAAoB,IAAI,iBAAiB;AAAA,EAC1D;AAAA,EAEiB,SAAS,IAAI,cAAiB,KAAK;AAAA,EACnC;AAAA,EACA,YAAY,oBAAI,IAAgB;AAAA,EAChC;AAAA,EACA;AAAA,EACT;AAAA,EACA,WAAW;AAAA,EACX,SAAwB,QAAQ,QAAQ;AAAA,EACxC,gBAAgB;AAAA,EAChB;AAAA,EAER,YAAY,SAAuC;AAC/C,SAAK,UAAU,YAAY,QAAQ,SAAa,WAAW,IAAI,cAAc;AAC7E,SAAK,YAAY,KAAK,MAAM;AAC5B,SAAK,gBAAgB,KAAK,UAAU;AACpC,SAAK,kBAAkB,KAAK,eAAe;AAAA,EAC/C;AAAA,EAEO,OAAiB;AACpB,WAAO,KAAK,OAAO,KAAK;AAAA,EAC5B;AAAA,EAEO,QAA+B;AAClC,WAAO,KAAK,OAAO,MAAM;AAAA,EAC7B;AAAA,EAEO,YAA2C;AAC9C,WAAO,KAAK,OAAO,UAAU;AAAA,EACjC;AAAA,EAEO,OAAqB;AACxB,WAAO,KAAK,OAAO,KAAK;AAAA,EAC5B;AAAA,EAEO,IAAgC,KAAQ,eAAiE;AAC5G,WAAO,KAAK,OAAO,IAAI,KAAK,aAAa;AAAA,EAC7C;AAAA,EAEO,MAAwC,QAAW,MAA4C;AAClG,WAAO,KAAK,OAAO,MAAM,KAAK,GAAG,IAAI;AAAA,EACzC;AAAA,EAEO,OAAsC,KAAQ,UAAkB,MAA4C;AAC/G,WAAO,KAAK,OAAO,OAAO,KAAK,OAAO,GAAG,IAAI;AAAA,EACjD;AAAA,EAEgB,WAAW,MAAyB,KAAK;AAAA,EAEzC,YAAY,CAAC,aAAuC;AAEhE,UAAM,SAAS,MAAM,SAAS;AAE9B,SAAK,UAAU,IAAI,MAAM;AAEzB,QAAI;AACA,WAAK,QAAQ;AAAA,IACjB,SAAS,OAAO;AACZ,WAAK,UAAU,OAAO,MAAM;AAC5B,YAAM;AAAA,IACV;AAEA,QAAI,KAAK,UAAU,SAAS,GAAG;AAC3B,WAAK,KAAK,QAAQ;AAAA,IACtB;AAEA,WAAO,MAAM;AACT,WAAK,UAAU,OAAO,MAAM;AAC5B,WAAK,WAAW;AAAA,IACpB;AAAA,EACJ;AAAA,EAEgB,SAAS,OAAO,SAAsC;AAClE,SAAK,OAAO,OAAO,IAAI;AAEvB,UAAM,UAAU,KAAK;AAErB,QAAI,CAAC,SAAS;AACV,WAAK,QAAQ;AACb,aAAO;AAAA,IACX;AAEA,SAAK;AAGL,SAAK;AAEL,UAAM,QAAQ,KAAK,OAAO,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC;AAEtD,SAAK,SAAS,MAAM,MAAM,MAAM,MAAS;AAEzC,SAAK,QAAQ;AAEb,QAAI,YAAY;AAEhB,QAAI;AACA,YAAM;AACN,kBAAY;AAEZ,aAAO;AAAA,IACX,UAAE;AACE,UAAI,EAAE,KAAK,kBAAkB,KAAK,WAAW;AACzC,aAAK,KAAK,QAAQ;AAAA,MACtB;AAAA,IACJ;AAAA,EACJ;AAAA,EAEA,MAAa,OAA0B;AACnC,QAAI,CAAC,KAAK,SAAS;AACf,YAAM,IAAI,MAAM,mCAAmC;AAAA,IACvD;AAEA,QAAI,KAAK,eAAe;AACpB,aAAO,KAAK,KAAK;AAAA,IACrB;AAEA,UAAM,WAAW,EAAE,KAAK;AACxB,UAAM,OAAO,MAAM,KAAK,QAAQ,IAAI;AAEpC,QAAI,aAAa,KAAK,YAAY,KAAK,eAAe;AAClD,aAAO,KAAK,KAAK;AAAA,IACrB;AAEA,QAAI,SAAS,QAAW;AACpB,aAAO,KAAK,KAAK;AAAA,IACrB;AAEA,QAAI,CAAC,KAAK,MAAM,EAAE,IAAI,IAAI,GAAG;AACzB,cAAQ,KAAK,yCAAyC,IAAI,GAAG;AAE7D,aAAO,KAAK,KAAK;AAAA,IACrB;AAEA,SAAK,OAAO,OAAO,IAAI;AAEvB,SAAK,QAAQ;AAEb,WAAO,KAAK,KAAK;AAAA,EACrB;AAAA,EAEQ,UAAgB;AACpB,QAAI,CAAC,KAAK,WAAW,KAAK,aAAa;AACnC;AAAA,IACJ;AAEA,SAAK,cAAc,KAAK,QAAQ,MAAM,MAAM;AACxC,WAAK,KAAK,QAAQ;AAAA,IACtB,CAAC;AAAA,EACL;AAAA,EAEQ,aAAmB;AAhM/B;AAiMQ,QAAI,KAAK,UAAU,MAAM;AACrB;AAAA,IACJ;AAEA,SAAK;AAEL,eAAK,gBAAL;AACA,SAAK,cAAc;AAAA,EACvB;AAAA,EAEA,MAAc,UAAyB;AACnC,QAAI,CAAC,KAAK,WAAW,KAAK,eAAe;AACrC;AAAA,IACJ;AAEA,QAAI;AACA,YAAM,KAAK,KAAK;AAAA,IACpB,SAAS,OAAO;AACZ,cAAQ,MAAM,mDAAmD,KAAK;AAAA,IAC1E;AAAA,EACJ;AAAA,EAEQ,iBAAoC;AACxC,UAAM,OAAO,KAAK,KAAK;AACvB,UAAM,QAAQ,KAAK;AACnB,UAAM,YAAY,KAAK;AAEvB,UAAM,SAAS,IAAI,aAAgB,MAAM,KAAK,OAAO,SAAS,CAAC;AAE/D,WAAO,OAAO,OAAO;AAAA,MACjB,MAAM,MAAM;AAAA,MACZ,OAAO,MAAM;AAAA,MACb,WAAW,MAAM;AAAA,MACjB,KAAK,OAAO,IAAI,KAAK,MAAM;AAAA,IAC/B,CAAC;AAAA,EACL;AAAA,EAEQ,UAAgB;AACpB,QAAI,KAAK,gBAAgB,KAAK,MAAM,KAAK,KAAK,GAAG;AAC7C;AAAA,IACJ;AAEA,SAAK,kBAAkB,KAAK,eAAe;AAE3C,eAAW,YAAY,CAAC,GAAG,KAAK,SAAS,GAAG;AACxC,UAAI;AACA,iBAAS;AAAA,MACb,SAAS,OAAO;AACZ,gBAAQ,MAAM,kDAAkD,KAAK;AAAA,MACzE;AAAA,IACJ;AAAA,EACJ;AACJ;","names":[]}
@@ -1,3 +1,4 @@
1
1
  export { default as AbstractLocale } from "./AbstractLocale.js";
2
2
  export { default as DynamicLocale } from "./DynamicLocale.js";
3
- export { default as NativeLocale, type LocaleNativeStructure } from "./NativeLocale.js";
3
+ export { default as NativeLocale } from "./NativeLocale.js";
4
+ export { default as ObservableLocale } from "./ObservableLocale.js";
@@ -1,9 +1,11 @@
1
1
  import { default as default2 } from "./AbstractLocale.js";
2
2
  import { default as default3 } from "./DynamicLocale.js";
3
3
  import { default as default4 } from "./NativeLocale.js";
4
+ import { default as default5 } from "./ObservableLocale.js";
4
5
  export {
5
6
  default2 as AbstractLocale,
6
7
  default3 as DynamicLocale,
7
- default4 as NativeLocale
8
+ default4 as NativeLocale,
9
+ default5 as ObservableLocale
8
10
  };
9
11
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/locale/providers/index.ts"],"sourcesContent":["export {default as AbstractLocale} from \"./AbstractLocale\";\nexport {default as DynamicLocale} from \"./DynamicLocale\";\nexport {default as NativeLocale, type LocaleNativeStructure} from \"./NativeLocale\";\n"],"mappings":"AAAA,SAAmB,WAAXA,gBAAgC;AACxC,SAAmB,WAAXA,gBAA+B;AACvC,SAAmB,WAAXA,gBAA0D;","names":["default"]}
1
+ {"version":3,"sources":["../../../src/locale/providers/index.ts"],"sourcesContent":["export {default as AbstractLocale} from \"./AbstractLocale\";\nexport {default as DynamicLocale} from \"./DynamicLocale\";\nexport {default as NativeLocale} from \"./NativeLocale\";\nexport {default as ObservableLocale} from \"./ObservableLocale\";\n"],"mappings":"AAAA,SAAmB,WAAXA,gBAAgC;AACxC,SAAmB,WAAXA,gBAA+B;AACvC,SAAmB,WAAXA,gBAA8B;AACtC,SAAmB,WAAXA,gBAAkC;","names":["default"]}
@@ -0,0 +1,11 @@
1
+ import { Language, type LocaleStorageDriver } from "../../types/locale.js";
2
+ /** Stores the selected language in extension local storage under the framework namespace. */
3
+ export default class LocaleStorage implements LocaleStorageDriver {
4
+ protected key: string;
5
+ private readonly storage;
6
+ constructor(key?: string);
7
+ get(): Promise<Language | undefined>;
8
+ set(lang: Language): Promise<void>;
9
+ watch(handler: (lang: Language) => void): () => void;
10
+ private parse;
11
+ }
@@ -0,0 +1,40 @@
1
+ import { Storage } from "@addon-core/storage";
2
+ import { PackageName } from "./../../types/app.js";
3
+ import { LanguageCodes } from "./../../types/locale.js";
4
+ class LocaleStorage {
5
+ constructor(key = "locale") {
6
+ this.key = key;
7
+ }
8
+ key;
9
+ storage = Storage.Local({ namespace: PackageName });
10
+ async get() {
11
+ return this.parse(await this.storage.get(this.key));
12
+ }
13
+ set(lang) {
14
+ return this.storage.set(this.key, lang);
15
+ }
16
+ watch(handler) {
17
+ return this.storage.watch({
18
+ [this.key]: (value) => {
19
+ const lang = this.parse(value);
20
+ if (lang !== void 0) {
21
+ handler(lang);
22
+ }
23
+ }
24
+ });
25
+ }
26
+ parse(value) {
27
+ if (value === void 0) {
28
+ return void 0;
29
+ }
30
+ if (typeof value === "string" && LanguageCodes.has(value)) {
31
+ return value;
32
+ }
33
+ console.warn("[LocaleStorage] Invalid language code in storage:", value);
34
+ return void 0;
35
+ }
36
+ }
37
+ export {
38
+ LocaleStorage as default
39
+ };
40
+ //# sourceMappingURL=LocaleStorage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/locale/storage/LocaleStorage.ts"],"sourcesContent":["import {Storage} from \"@addon-core/storage\";\n\nimport {PackageName} from \"@typing/app\";\nimport {Language, LanguageCodes, type LocaleStorageDriver} from \"@typing/locale\";\n\n/** Stores the selected language in extension local storage under the framework namespace. */\nexport default class LocaleStorage implements LocaleStorageDriver {\n private readonly storage = Storage.Local<Record<string, Language>>({namespace: PackageName});\n\n constructor(protected key: string = \"locale\") {}\n\n public async get(): Promise<Language | undefined> {\n return this.parse(await this.storage.get(this.key));\n }\n\n public set(lang: Language): Promise<void> {\n return this.storage.set(this.key, lang);\n }\n\n public watch(handler: (lang: Language) => void): () => void {\n return this.storage.watch({\n [this.key]: value => {\n const lang = this.parse(value);\n\n if (lang !== undefined) {\n handler(lang);\n }\n },\n });\n }\n\n private parse(value: unknown): Language | undefined {\n if (value === undefined) {\n return undefined;\n }\n\n if (typeof value === \"string\" && LanguageCodes.has(value)) {\n return value as Language;\n }\n\n console.warn(\"[LocaleStorage] Invalid language code in storage:\", value);\n\n return undefined;\n }\n}\n"],"mappings":"AAAA,SAAQ,eAAc;AAEtB,SAAQ,mBAAkB;AAC1B,SAAkB,qBAA8C;AAGhE,MAAO,cAA2D;AAAA,EAG9D,YAAsB,MAAc,UAAU;AAAxB;AAAA,EAAyB;AAAA,EAAzB;AAAA,EAFL,UAAU,QAAQ,MAAgC,EAAC,WAAW,YAAW,CAAC;AAAA,EAI3F,MAAa,MAAqC;AAC9C,WAAO,KAAK,MAAM,MAAM,KAAK,QAAQ,IAAI,KAAK,GAAG,CAAC;AAAA,EACtD;AAAA,EAEO,IAAI,MAA+B;AACtC,WAAO,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;AAAA,EAC1C;AAAA,EAEO,MAAM,SAA+C;AACxD,WAAO,KAAK,QAAQ,MAAM;AAAA,MACtB,CAAC,KAAK,GAAG,GAAG,WAAS;AACjB,cAAM,OAAO,KAAK,MAAM,KAAK;AAE7B,YAAI,SAAS,QAAW;AACpB,kBAAQ,IAAI;AAAA,QAChB;AAAA,MACJ;AAAA,IACJ,CAAC;AAAA,EACL;AAAA,EAEQ,MAAM,OAAsC;AAChD,QAAI,UAAU,QAAW;AACrB,aAAO;AAAA,IACX;AAEA,QAAI,OAAO,UAAU,YAAY,cAAc,IAAI,KAAK,GAAG;AACvD,aAAO;AAAA,IACX;AAEA,YAAQ,KAAK,qDAAqD,KAAK;AAEvE,WAAO;AAAA,EACX;AACJ;","names":[]}
@@ -0,0 +1 @@
1
+ export { default as LocaleStorage } from "./LocaleStorage.js";
@@ -0,0 +1,5 @@
1
+ import { default as default2 } from "./LocaleStorage.js";
2
+ export {
3
+ default2 as LocaleStorage
4
+ };
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/locale/storage/index.ts"],"sourcesContent":["export {default as LocaleStorage} from \"./LocaleStorage\";\n"],"mappings":"AAAA,SAAmB,WAAXA,gBAA+B;","names":["default"]}
@@ -0,0 +1,4 @@
1
+ import type { EntrypointAssets, EntrypointAssetsMap } from "../types/entrypoint.js";
2
+ export type { EntrypointAssets, EntrypointAssetsFiles, EntrypointAssetsMap, EntrypointAssetsMapEntry, } from "../types/entrypoint.js";
3
+ export declare const getEntrypointAssetsMap: () => EntrypointAssetsMap;
4
+ export declare const getEntrypointAssets: () => EntrypointAssets;
@@ -0,0 +1,20 @@
1
+ import { readAssets, readAssetsMap } from "#adnbn/entrypoint";
2
+ const getEntrypointAssetsMap = () => {
3
+ const assets = readAssetsMap();
4
+ if (!assets) {
5
+ throw new Error("getEntrypointAssetsMap() is available only in the background entrypoint");
6
+ }
7
+ return assets;
8
+ };
9
+ const getEntrypointAssets = () => {
10
+ const assets = readAssets();
11
+ if (!assets) {
12
+ throw new Error("Current entrypoint assets are unavailable in this runtime");
13
+ }
14
+ return assets;
15
+ };
16
+ export {
17
+ getEntrypointAssets,
18
+ getEntrypointAssetsMap
19
+ };
20
+ //# sourceMappingURL=entrypoint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/main/entrypoint.ts"],"sourcesContent":["import {readAssets, readAssetsMap} from \"#adnbn/entrypoint\";\n\nimport type {EntrypointAssets, EntrypointAssetsMap} from \"@typing/entrypoint\";\n\nexport type {\n EntrypointAssets,\n EntrypointAssetsFiles,\n EntrypointAssetsMap,\n EntrypointAssetsMapEntry,\n} from \"@typing/entrypoint\";\n\nexport const getEntrypointAssetsMap = (): EntrypointAssetsMap => {\n const assets = readAssetsMap();\n\n if (!assets) {\n throw new Error(\"getEntrypointAssetsMap() is available only in the background entrypoint\");\n }\n\n return assets;\n};\n\nexport const getEntrypointAssets = (): EntrypointAssets => {\n const assets = readAssets();\n\n if (!assets) {\n throw new Error(\"Current entrypoint assets are unavailable in this runtime\");\n }\n\n return assets;\n};\n"],"mappings":"AAAA,SAAQ,YAAY,qBAAoB;AAWjC,MAAM,yBAAyB,MAA2B;AAC7D,QAAM,SAAS,cAAc;AAE7B,MAAI,CAAC,QAAQ;AACT,UAAM,IAAI,MAAM,yEAAyE;AAAA,EAC7F;AAEA,SAAO;AACX;AAEO,MAAM,sBAAsB,MAAwB;AACvD,QAAM,SAAS,WAAW;AAE1B,MAAI,CAAC,QAAQ;AACT,UAAM,IAAI,MAAM,2DAA2D;AAAA,EAC/E;AAEA,SAAO;AACX;","names":[]}
@@ -1,7 +1,6 @@
1
+ import { type IconName, type IconsMap } from "../types/icon.js";
1
2
  type Tab = chrome.tabs.Tab;
2
- export type IconName = string;
3
- export type IconsMap = Map<IconName, Record<number, string>>;
3
+ export type { IconNameRegistry, IconName, IconsMap } from "../types/icon.js";
4
4
  export declare const getIcons: () => IconsMap;
5
5
  export declare const changeActionIcon: (icon?: IconName, tab?: number | Tab) => Promise<void>;
6
6
  export declare const changeSidebarIcon: (icon?: IconName, tab?: number | Tab) => Promise<void>;
7
- export {};
package/dist/main/icon.js CHANGED
@@ -1,9 +1,10 @@
1
1
  import { setActionIcon, setSidebarIcon } from "@addon-core/browser";
2
+ import { groups } from "#adnbn/icon";
2
3
  import { DefaultIconGroupName } from "./../types/icon.js";
3
4
  const getIcons = () => {
4
5
  const icons = /* @__PURE__ */ new Map();
5
6
  try {
6
- Object.entries(__ADNBN_ICONS__).forEach(([key, value]) => {
7
+ Object.entries(groups).forEach(([key, value]) => {
7
8
  icons.set(key, value);
8
9
  });
9
10
  } catch (e) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/main/icon.ts"],"sourcesContent":["import {setActionIcon, setSidebarIcon} from \"@addon-core/browser\";\n\nimport {DefaultIconGroupName} from \"@typing/icon\";\n\ntype Tab = chrome.tabs.Tab;\n\nexport type IconName = string;\n\nexport type IconsMap = Map<IconName, Record<number, string>>;\n\nexport const getIcons = (): IconsMap => {\n const icons: IconsMap = new Map();\n\n try {\n // @ts-expect-error: __ADNBN_ICONS__ is a virtual variable generated by the bundler `src/cli/plugins/icon/index.ts`\n Object.entries<Record<number, string>>(__ADNBN_ICONS__).forEach(([key, value]) => {\n icons.set(key, value);\n });\n } catch (e) {\n console.error(\"Failed getting icons: \", e);\n }\n\n return icons;\n};\n\nexport const changeActionIcon = async (icon?: IconName, tab?: number | Tab): Promise<void> => {\n if (!icon) {\n icon = DefaultIconGroupName;\n }\n\n const icons = getIcons().get(icon);\n\n if (!icons) {\n throw new Error(`Icon group name \"${icon}\" not found for action icon.`);\n }\n\n if (tab && typeof tab === \"object\") {\n tab = tab.id;\n }\n\n await setActionIcon({path: icons, tabId: tab});\n};\n\nexport const changeSidebarIcon = async (icon?: IconName, tab?: number | Tab): Promise<void> => {\n if (!icon) {\n icon = DefaultIconGroupName;\n }\n\n const icons = getIcons().get(icon);\n\n if (!icons) {\n throw new Error(`Icon group name \"${icon}\" not found for sidebar icon.`);\n }\n\n if (tab && typeof tab === \"object\") {\n tab = tab.id;\n }\n\n await setSidebarIcon({path: icons, tabId: tab});\n};\n"],"mappings":"AAAA,SAAQ,eAAe,sBAAqB;AAE5C,SAAQ,4BAA2B;AAQ5B,MAAM,WAAW,MAAgB;AACpC,QAAM,QAAkB,oBAAI,IAAI;AAEhC,MAAI;AAEA,WAAO,QAAgC,eAAe,EAAE,QAAQ,CAAC,CAAC,KAAK,KAAK,MAAM;AAC9E,YAAM,IAAI,KAAK,KAAK;AAAA,IACxB,CAAC;AAAA,EACL,SAAS,GAAG;AACR,YAAQ,MAAM,0BAA0B,CAAC;AAAA,EAC7C;AAEA,SAAO;AACX;AAEO,MAAM,mBAAmB,OAAO,MAAiB,QAAsC;AAC1F,MAAI,CAAC,MAAM;AACP,WAAO;AAAA,EACX;AAEA,QAAM,QAAQ,SAAS,EAAE,IAAI,IAAI;AAEjC,MAAI,CAAC,OAAO;AACR,UAAM,IAAI,MAAM,oBAAoB,IAAI,8BAA8B;AAAA,EAC1E;AAEA,MAAI,OAAO,OAAO,QAAQ,UAAU;AAChC,UAAM,IAAI;AAAA,EACd;AAEA,QAAM,cAAc,EAAC,MAAM,OAAO,OAAO,IAAG,CAAC;AACjD;AAEO,MAAM,oBAAoB,OAAO,MAAiB,QAAsC;AAC3F,MAAI,CAAC,MAAM;AACP,WAAO;AAAA,EACX;AAEA,QAAM,QAAQ,SAAS,EAAE,IAAI,IAAI;AAEjC,MAAI,CAAC,OAAO;AACR,UAAM,IAAI,MAAM,oBAAoB,IAAI,+BAA+B;AAAA,EAC3E;AAEA,MAAI,OAAO,OAAO,QAAQ,UAAU;AAChC,UAAM,IAAI;AAAA,EACd;AAEA,QAAM,eAAe,EAAC,MAAM,OAAO,OAAO,IAAG,CAAC;AAClD;","names":[]}
1
+ {"version":3,"sources":["../../src/main/icon.ts"],"sourcesContent":["import {setActionIcon, setSidebarIcon} from \"@addon-core/browser\";\nimport {groups} from \"#adnbn/icon\";\n\nimport {DefaultIconGroupName, type IconName, type IconsMap} from \"@typing/icon\";\n\ntype Tab = chrome.tabs.Tab;\n\nexport type {IconNameRegistry, IconName, IconsMap} from \"@typing/icon\";\n\nexport const getIcons = (): IconsMap => {\n const icons: IconsMap = new Map();\n\n try {\n Object.entries(groups).forEach(([key, value]) => {\n icons.set(key as IconName, value);\n });\n } catch (e) {\n console.error(\"Failed getting icons: \", e);\n }\n\n return icons;\n};\n\nexport const changeActionIcon = async (icon?: IconName, tab?: number | Tab): Promise<void> => {\n if (!icon) {\n icon = DefaultIconGroupName as IconName;\n }\n\n const icons = getIcons().get(icon);\n\n if (!icons) {\n throw new Error(`Icon group name \"${icon}\" not found for action icon.`);\n }\n\n if (tab && typeof tab === \"object\") {\n tab = tab.id;\n }\n\n await setActionIcon({path: icons, tabId: tab});\n};\n\nexport const changeSidebarIcon = async (icon?: IconName, tab?: number | Tab): Promise<void> => {\n if (!icon) {\n icon = DefaultIconGroupName as IconName;\n }\n\n const icons = getIcons().get(icon);\n\n if (!icons) {\n throw new Error(`Icon group name \"${icon}\" not found for sidebar icon.`);\n }\n\n if (tab && typeof tab === \"object\") {\n tab = tab.id;\n }\n\n await setSidebarIcon({path: icons, tabId: tab});\n};\n"],"mappings":"AAAA,SAAQ,eAAe,sBAAqB;AAC5C,SAAQ,cAAa;AAErB,SAAQ,4BAAyD;AAM1D,MAAM,WAAW,MAAgB;AACpC,QAAM,QAAkB,oBAAI,IAAI;AAEhC,MAAI;AACA,WAAO,QAAQ,MAAM,EAAE,QAAQ,CAAC,CAAC,KAAK,KAAK,MAAM;AAC7C,YAAM,IAAI,KAAiB,KAAK;AAAA,IACpC,CAAC;AAAA,EACL,SAAS,GAAG;AACR,YAAQ,MAAM,0BAA0B,CAAC;AAAA,EAC7C;AAEA,SAAO;AACX;AAEO,MAAM,mBAAmB,OAAO,MAAiB,QAAsC;AAC1F,MAAI,CAAC,MAAM;AACP,WAAO;AAAA,EACX;AAEA,QAAM,QAAQ,SAAS,EAAE,IAAI,IAAI;AAEjC,MAAI,CAAC,OAAO;AACR,UAAM,IAAI,MAAM,oBAAoB,IAAI,8BAA8B;AAAA,EAC1E;AAEA,MAAI,OAAO,OAAO,QAAQ,UAAU;AAChC,UAAM,IAAI;AAAA,EACd;AAEA,QAAM,cAAc,EAAC,MAAM,OAAO,OAAO,IAAG,CAAC;AACjD;AAEO,MAAM,oBAAoB,OAAO,MAAiB,QAAsC;AAC3F,MAAI,CAAC,MAAM;AACP,WAAO;AAAA,EACX;AAEA,QAAM,QAAQ,SAAS,EAAE,IAAI,IAAI;AAEjC,MAAI,CAAC,OAAO;AACR,UAAM,IAAI,MAAM,oBAAoB,IAAI,+BAA+B;AAAA,EAC3E;AAEA,MAAI,OAAO,OAAO,QAAQ,UAAU;AAChC,UAAM,IAAI;AAAA,EACd;AAEA,QAAM,eAAe,EAAC,MAAM,OAAO,OAAO,IAAG,CAAC;AAClD;","names":[]}
@@ -5,10 +5,12 @@ export * from "./command.js";
5
5
  export * from "./config.js";
6
6
  export * from "./content.js";
7
7
  export * from "./csp.js";
8
+ export * from "./entrypoint.js";
8
9
  export * from "./env.js";
9
10
  export * from "./icon.js";
10
11
  export * from "./manifest.js";
11
12
  export * from "./offscreen.js";
13
+ export * from "./options.js";
12
14
  export * from "./page.js";
13
15
  export * from "./plugin.js";
14
16
  export * from "./popup.js";
@@ -5,10 +5,12 @@ export * from "./command.js";
5
5
  export * from "./config.js";
6
6
  export * from "./content.js";
7
7
  export * from "./csp.js";
8
+ export * from "./entrypoint.js";
8
9
  export * from "./env.js";
9
10
  export * from "./icon.js";
10
11
  export * from "./manifest.js";
11
12
  export * from "./offscreen.js";
13
+ export * from "./options.js";
12
14
  export * from "./page.js";
13
15
  export * from "./plugin.js";
14
16
  export * from "./popup.js";
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/main/index.ts"],"sourcesContent":["export * from \"./app\";\nexport * from \"./background\";\nexport * from \"./browser\";\nexport * from \"./command\";\nexport * from \"./config\";\nexport * from \"./content\";\nexport * from \"./csp\";\nexport * from \"./env\";\nexport * from \"./icon\";\nexport * from \"./manifest\";\nexport * from \"./offscreen\";\nexport * from \"./page\";\nexport * from \"./plugin\";\nexport * from \"./popup\";\nexport * from \"./relay\";\nexport * from \"./sandbox\";\nexport * from \"./service\";\nexport * from \"./sidebar\";\nexport * from \"./view\";\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
1
+ {"version":3,"sources":["../../src/main/index.ts"],"sourcesContent":["export * from \"./app\";\nexport * from \"./background\";\nexport * from \"./browser\";\nexport * from \"./command\";\nexport * from \"./config\";\nexport * from \"./content\";\nexport * from \"./csp\";\nexport * from \"./entrypoint\";\nexport * from \"./env\";\nexport * from \"./icon\";\nexport * from \"./manifest\";\nexport * from \"./offscreen\";\nexport * from \"./options\";\nexport * from \"./page\";\nexport * from \"./plugin\";\nexport * from \"./popup\";\nexport * from \"./relay\";\nexport * from \"./sandbox\";\nexport * from \"./service\";\nexport * from \"./sidebar\";\nexport * from \"./view\";\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
@@ -1,10 +1,7 @@
1
- import { type OffscreenDefinition, OffscreenReason, type OffscreenUnresolvedDefinition } from "../types/offscreen.js";
2
- import type { OffscreenName, OffscreenProxyTarget } from "../offscreen/index.js";
1
+ import { type OffscreenDefinition, type OffscreenMap, type OffscreenName, type OffscreenProxyTarget, OffscreenReason, type OffscreenUnresolvedDefinition } from "../types/offscreen.js";
3
2
  import type { TransportType } from "../types/transport.js";
4
- type OffscreenParameters = chrome.offscreen.CreateParameters;
5
3
  export { OffscreenReason, OffscreenDefinition, OffscreenUnresolvedDefinition };
6
- export type OffscreenAlias = string;
7
- export type OffscreenMap = Map<OffscreenAlias, OffscreenParameters>;
4
+ export type { OffscreenAlias, OffscreenMap } from "../types/offscreen.js";
8
5
  export declare const defineOffscreen: <T extends TransportType>(options: OffscreenDefinition<T>) => OffscreenDefinition<T>;
9
6
  export declare const getOffscreens: () => OffscreenMap;
10
7
  export declare const getOffscreen: <N extends OffscreenName>(name: N) => OffscreenProxyTarget<N>;
@@ -1,12 +1,15 @@
1
1
  import ProxyOffscreen from "./../offscreen/providers/ProxyOffscreen.js";
2
- import { OffscreenReason } from "./../types/offscreen.js";
2
+ import { parameters as offscreenParameters } from "#adnbn/offscreen";
3
+ import {
4
+ OffscreenReason
5
+ } from "./../types/offscreen.js";
3
6
  const defineOffscreen = (options) => {
4
7
  return options;
5
8
  };
6
9
  const getOffscreens = () => {
7
10
  const offscreens = /* @__PURE__ */ new Map();
8
11
  try {
9
- Object.entries(__ADNBN_OFFSCREEN_PARAMETERS__).forEach(([key, value]) => {
12
+ Object.entries(offscreenParameters).forEach(([key, value]) => {
10
13
  offscreens.set(key, value);
11
14
  });
12
15
  } catch (e) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/main/offscreen.ts"],"sourcesContent":["import ProxyOffscreen from \"@offscreen/providers/ProxyOffscreen\";\n\nimport {type OffscreenDefinition, OffscreenReason, type OffscreenUnresolvedDefinition} from \"@typing/offscreen\";\nimport type {OffscreenName, OffscreenProxyTarget} from \"@offscreen/index\";\nimport type {TransportType} from \"@typing/transport\";\n\ntype OffscreenParameters = chrome.offscreen.CreateParameters;\n\nexport {OffscreenReason, OffscreenDefinition, OffscreenUnresolvedDefinition};\n\nexport type OffscreenAlias = string;\n\nexport type OffscreenMap = Map<OffscreenAlias, OffscreenParameters>;\n\nexport const defineOffscreen = <T extends TransportType>(options: OffscreenDefinition<T>): OffscreenDefinition<T> => {\n return options;\n};\n\nexport const getOffscreens = (): OffscreenMap => {\n const offscreens: OffscreenMap = new Map();\n\n try {\n // @ts-expect-error: __ADNBN_OFFSCREEN_PARAMETERS__ is a virtual variable generated by the bundler `src/cli/plugins/offscreen/index.ts`\n Object.entries<OffscreenParameters>(__ADNBN_OFFSCREEN_PARAMETERS__).forEach(([key, value]) => {\n offscreens.set(key, value);\n });\n } catch (e) {\n console.error(\"Failed getting offscreens: \", e);\n }\n\n return offscreens;\n};\n\nexport const getOffscreen = <N extends OffscreenName>(name: N): OffscreenProxyTarget<N> => {\n const parameters = getOffscreens().get(name);\n\n if (!parameters) {\n throw new Error(`Unable to get offscreen: ${name}`);\n }\n\n return new ProxyOffscreen(name, parameters).get();\n};\n"],"mappings":"AAAA,OAAO,oBAAoB;AAE3B,SAAkC,uBAA0D;AAYrF,MAAM,kBAAkB,CAA0B,YAA4D;AACjH,SAAO;AACX;AAEO,MAAM,gBAAgB,MAAoB;AAC7C,QAAM,aAA2B,oBAAI,IAAI;AAEzC,MAAI;AAEA,WAAO,QAA6B,8BAA8B,EAAE,QAAQ,CAAC,CAAC,KAAK,KAAK,MAAM;AAC1F,iBAAW,IAAI,KAAK,KAAK;AAAA,IAC7B,CAAC;AAAA,EACL,SAAS,GAAG;AACR,YAAQ,MAAM,+BAA+B,CAAC;AAAA,EAClD;AAEA,SAAO;AACX;AAEO,MAAM,eAAe,CAA0B,SAAqC;AACvF,QAAM,aAAa,cAAc,EAAE,IAAI,IAAI;AAE3C,MAAI,CAAC,YAAY;AACb,UAAM,IAAI,MAAM,4BAA4B,IAAI,EAAE;AAAA,EACtD;AAEA,SAAO,IAAI,eAAe,MAAM,UAAU,EAAE,IAAI;AACpD;","names":[]}
1
+ {"version":3,"sources":["../../src/main/offscreen.ts"],"sourcesContent":["import ProxyOffscreen from \"@offscreen/providers/ProxyOffscreen\";\nimport {parameters as offscreenParameters} from \"#adnbn/offscreen\";\n\nimport {\n type OffscreenDefinition,\n type OffscreenMap,\n type OffscreenName,\n type OffscreenProxyTarget,\n OffscreenReason,\n type OffscreenUnresolvedDefinition,\n} from \"@typing/offscreen\";\nimport type {TransportType} from \"@typing/transport\";\n\nexport {OffscreenReason, OffscreenDefinition, OffscreenUnresolvedDefinition};\n\nexport type {OffscreenAlias, OffscreenMap} from \"@typing/offscreen\";\n\nexport const defineOffscreen = <T extends TransportType>(options: OffscreenDefinition<T>): OffscreenDefinition<T> => {\n return options;\n};\n\nexport const getOffscreens = (): OffscreenMap => {\n const offscreens: OffscreenMap = new Map();\n\n try {\n Object.entries(offscreenParameters).forEach(([key, value]) => {\n offscreens.set(key, value);\n });\n } catch (e) {\n console.error(\"Failed getting offscreens: \", e);\n }\n\n return offscreens;\n};\n\nexport const getOffscreen = <N extends OffscreenName>(name: N): OffscreenProxyTarget<N> => {\n const parameters = getOffscreens().get(name);\n\n if (!parameters) {\n throw new Error(`Unable to get offscreen: ${name}`);\n }\n\n return new ProxyOffscreen(name, parameters).get();\n};\n"],"mappings":"AAAA,OAAO,oBAAoB;AAC3B,SAAQ,cAAc,2BAA0B;AAEhD;AAAA,EAKI;AAAA,OAEG;AAOA,MAAM,kBAAkB,CAA0B,YAA4D;AACjH,SAAO;AACX;AAEO,MAAM,gBAAgB,MAAoB;AAC7C,QAAM,aAA2B,oBAAI,IAAI;AAEzC,MAAI;AACA,WAAO,QAAQ,mBAAmB,EAAE,QAAQ,CAAC,CAAC,KAAK,KAAK,MAAM;AAC1D,iBAAW,IAAI,KAAK,KAAK;AAAA,IAC7B,CAAC;AAAA,EACL,SAAS,GAAG;AACR,YAAQ,MAAM,+BAA+B,CAAC;AAAA,EAClD;AAEA,SAAO;AACX;AAEO,MAAM,eAAe,CAA0B,SAAqC;AACvF,QAAM,aAAa,cAAc,EAAE,IAAI,IAAI;AAE3C,MAAI,CAAC,YAAY;AACb,UAAM,IAAI,MAAM,4BAA4B,IAAI,EAAE;AAAA,EACtD;AAEA,SAAO,IAAI,eAAe,MAAM,UAAU,EAAE,IAAI;AACpD;","names":[]}
@@ -0,0 +1,3 @@
1
+ import { OptionsConfig, OptionsDefinition, OptionsProps } from "../types/options.js";
2
+ export type { OptionsDefinition, OptionsProps, OptionsConfig };
3
+ export declare const defineOptions: (options: OptionsDefinition) => OptionsDefinition;
@@ -0,0 +1,7 @@
1
+ const defineOptions = (options) => {
2
+ return options;
3
+ };
4
+ export {
5
+ defineOptions
6
+ };
7
+ //# sourceMappingURL=options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/main/options.ts"],"sourcesContent":["import {OptionsConfig, OptionsDefinition, OptionsProps} from \"@typing/options\";\n\nexport type {OptionsDefinition, OptionsProps, OptionsConfig};\n\nexport const defineOptions = (options: OptionsDefinition): OptionsDefinition => {\n return options;\n};\n"],"mappings":"AAIO,MAAM,gBAAgB,CAAC,YAAkD;AAC5E,SAAO;AACX;","names":[]}
@@ -1,7 +1,5 @@
1
- import { PageConfig, PageDefinition, PageProps } from "../types/page.js";
2
- export type { PageDefinition, PageProps, PageConfig };
3
- export type PageAlias = string;
4
- export type PageMap = Map<PageAlias, string>;
1
+ import type { PageAlias, PageDefinition, PageMap } from "../types/page.js";
2
+ export type { PageDefinition, PageProps, PageConfig, PageAliasRegistry, PageAlias, PageMap } from "../types/page.js";
5
3
  export declare const definePage: (options: PageDefinition) => PageDefinition;
6
4
  export declare const getPages: () => PageMap;
7
5
  export declare const getPageUrl: (alias: PageAlias) => string;
package/dist/main/page.js CHANGED
@@ -1,11 +1,12 @@
1
1
  import { getUrl } from "@addon-core/browser";
2
+ import { aliases } from "#adnbn/page";
2
3
  const definePage = (options) => {
3
4
  return options;
4
5
  };
5
6
  const getPages = () => {
6
7
  const pages = /* @__PURE__ */ new Map();
7
8
  try {
8
- Object.entries(__ADNBN_PAGE_ALIAS__).forEach(([key, value]) => {
9
+ Object.entries(aliases).forEach(([key, value]) => {
9
10
  pages.set(key, value);
10
11
  });
11
12
  } catch (e) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/main/page.ts"],"sourcesContent":["import {getUrl} from \"@addon-core/browser\";\n\nimport {PageConfig, PageDefinition, PageProps} from \"@typing/page\";\n\nexport type {PageDefinition, PageProps, PageConfig};\n\nexport type PageAlias = string;\n\nexport type PageMap = Map<PageAlias, string>;\n\nexport const definePage = (options: PageDefinition): PageDefinition => {\n return options;\n};\n\nexport const getPages = (): PageMap => {\n const pages: PageMap = new Map();\n\n try {\n // @ts-expect-error: __ADNBN_PAGE_ALIAS__ is a virtual variable generated by the bundler `src/cli/plugins/page/index.ts`\n Object.entries<string>(__ADNBN_PAGE_ALIAS__).forEach(([key, value]) => {\n pages.set(key, value);\n });\n } catch (e) {\n console.error(\"Failed getting pages: \", e);\n }\n\n return pages;\n};\n\nexport const getPageUrl = (alias: PageAlias): string => {\n let path = getPages().get(alias);\n\n if (!path) {\n console.warn(`Cannot find page: ${alias}`);\n\n path = alias;\n }\n\n return getUrl(path);\n};\n"],"mappings":"AAAA,SAAQ,cAAa;AAUd,MAAM,aAAa,CAAC,YAA4C;AACnE,SAAO;AACX;AAEO,MAAM,WAAW,MAAe;AACnC,QAAM,QAAiB,oBAAI,IAAI;AAE/B,MAAI;AAEA,WAAO,QAAgB,oBAAoB,EAAE,QAAQ,CAAC,CAAC,KAAK,KAAK,MAAM;AACnE,YAAM,IAAI,KAAK,KAAK;AAAA,IACxB,CAAC;AAAA,EACL,SAAS,GAAG;AACR,YAAQ,MAAM,0BAA0B,CAAC;AAAA,EAC7C;AAEA,SAAO;AACX;AAEO,MAAM,aAAa,CAAC,UAA6B;AACpD,MAAI,OAAO,SAAS,EAAE,IAAI,KAAK;AAE/B,MAAI,CAAC,MAAM;AACP,YAAQ,KAAK,qBAAqB,KAAK,EAAE;AAEzC,WAAO;AAAA,EACX;AAEA,SAAO,OAAO,IAAI;AACtB;","names":[]}
1
+ {"version":3,"sources":["../../src/main/page.ts"],"sourcesContent":["import {getUrl} from \"@addon-core/browser\";\nimport {aliases} from \"#adnbn/page\";\n\nimport type {PageAlias, PageDefinition, PageMap} from \"@typing/page\";\n\nexport type {PageDefinition, PageProps, PageConfig, PageAliasRegistry, PageAlias, PageMap} from \"@typing/page\";\n\nexport const definePage = (options: PageDefinition): PageDefinition => {\n return options;\n};\n\nexport const getPages = (): PageMap => {\n const pages: PageMap = new Map();\n\n try {\n Object.entries(aliases).forEach(([key, value]) => {\n pages.set(key, value);\n });\n } catch (e) {\n console.error(\"Failed getting pages: \", e);\n }\n\n return pages;\n};\n\nexport const getPageUrl = (alias: PageAlias): string => {\n let path = getPages().get(alias);\n\n if (!path) {\n console.warn(`Cannot find page: ${alias}`);\n\n path = alias;\n }\n\n return getUrl(path);\n};\n"],"mappings":"AAAA,SAAQ,cAAa;AACrB,SAAQ,eAAc;AAMf,MAAM,aAAa,CAAC,YAA4C;AACnE,SAAO;AACX;AAEO,MAAM,WAAW,MAAe;AACnC,QAAM,QAAiB,oBAAI,IAAI;AAE/B,MAAI;AACA,WAAO,QAAQ,OAAO,EAAE,QAAQ,CAAC,CAAC,KAAK,KAAK,MAAM;AAC9C,YAAM,IAAI,KAAK,KAAK;AAAA,IACxB,CAAC;AAAA,EACL,SAAS,GAAG;AACR,YAAQ,MAAM,0BAA0B,CAAC;AAAA,EAC7C;AAEA,SAAO;AACX;AAEO,MAAM,aAAa,CAAC,UAA6B;AACpD,MAAI,OAAO,SAAS,EAAE,IAAI,KAAK;AAE/B,MAAI,CAAC,MAAM;AACP,YAAQ,KAAK,qBAAqB,KAAK,EAAE;AAEzC,WAAO;AAAA,EACX;AAEA,SAAO,OAAO,IAAI;AACtB;","names":[]}
@@ -1,9 +1,6 @@
1
- import { PopupDefinition } from "../types/popup.js";
2
- import { ManifestPopup } from "../types/manifest.js";
1
+ import type { PopupAlias, PopupDefinition, PopupMap } from "../types/popup.js";
3
2
  type Tab = chrome.tabs.Tab;
4
- export type PopupAlias = string;
5
- export type PopupMap = Map<PopupAlias, ManifestPopup>;
3
+ export type { PopupAliasRegistry, PopupAlias, PopupMap } from "../types/popup.js";
6
4
  export declare const definePopup: (options: PopupDefinition) => PopupDefinition;
7
5
  export declare const getPopups: () => PopupMap;
8
6
  export declare const changePopup: (alias: PopupAlias, tab?: number | Tab) => Promise<void>;
9
- export {};
@@ -1,5 +1,5 @@
1
1
  import { setActionPopup, setActionTitle } from "@addon-core/browser";
2
- import { resolve } from "./../locale/helpers.js";
2
+ import { aliases } from "#adnbn/popup";
3
3
  import { changeActionIcon } from "./icon.js";
4
4
  const definePopup = (options) => {
5
5
  return options;
@@ -7,7 +7,7 @@ const definePopup = (options) => {
7
7
  const getPopups = () => {
8
8
  const popups = /* @__PURE__ */ new Map();
9
9
  try {
10
- Object.entries(__ADNBN_POPUP_MAP__).forEach(([key, value]) => {
10
+ Object.entries(aliases).forEach(([key, value]) => {
11
11
  popups.set(key, value);
12
12
  });
13
13
  } catch (e) {
@@ -29,7 +29,7 @@ const changePopup = async (alias, tab) => {
29
29
  }
30
30
  await setActionPopup(path, tab);
31
31
  if (title) {
32
- await setActionTitle(resolve(title), tab);
32
+ await setActionTitle(title, tab);
33
33
  }
34
34
  if (icon) {
35
35
  await changeActionIcon(icon, tab);