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.
- package/dist/cli/builders/locale/LocaleBuilder.js +2 -11
- package/dist/cli/builders/locale/LocaleBuilder.js.map +1 -1
- package/dist/cli/builders/locale/index.js +1 -1
- package/dist/cli/builders/locale/index.js.map +1 -1
- package/dist/cli/builders/manifest/ManifestBase.d.ts +4 -1
- package/dist/cli/builders/manifest/ManifestBase.js +35 -6
- package/dist/cli/builders/manifest/ManifestBase.js.map +1 -1
- package/dist/cli/builders/manifest/ManifestV2.js +1 -1
- package/dist/cli/builders/manifest/ManifestV3.js +12 -5
- package/dist/cli/builders/manifest/ManifestV3.js.map +1 -1
- package/dist/cli/builders/manifest/utils/data-collection-permissions.d.ts +15 -0
- package/dist/cli/builders/manifest/utils/data-collection-permissions.js +26 -0
- package/dist/cli/builders/manifest/utils/data-collection-permissions.js.map +1 -0
- package/dist/cli/builders/manifest/utils/host-patterns.d.ts +1 -0
- package/dist/cli/builders/manifest/utils/host-patterns.js +40 -0
- package/dist/cli/builders/manifest/utils/host-patterns.js.map +1 -0
- package/dist/cli/builders/manifest/utils/index.d.ts +4 -0
- package/dist/cli/builders/manifest/utils/index.js +19 -0
- package/dist/cli/builders/manifest/utils/index.js.map +1 -0
- package/dist/cli/builders/manifest/utils/permissions.d.ts +14 -0
- package/dist/cli/builders/manifest/utils/permissions.js +34 -0
- package/dist/cli/builders/manifest/utils/permissions.js.map +1 -0
- package/dist/cli/builders/manifest/utils/web-accessible-resources.d.ts +2 -0
- package/dist/cli/builders/manifest/utils/web-accessible-resources.js +92 -0
- package/dist/cli/builders/manifest/utils/web-accessible-resources.js.map +1 -0
- package/dist/cli/bundler/plugins/build-assets-map/BuildAssetsMapPlugin.d.ts +14 -0
- package/dist/cli/bundler/plugins/build-assets-map/BuildAssetsMapPlugin.js +523 -0
- package/dist/cli/bundler/plugins/build-assets-map/BuildAssetsMapPlugin.js.map +1 -0
- package/dist/cli/bundler/plugins/build-assets-map/entrypoint-module.d.ts +13 -0
- package/dist/cli/bundler/plugins/build-assets-map/entrypoint-module.js +16 -0
- package/dist/cli/bundler/plugins/build-assets-map/entrypoint-module.js.map +1 -0
- package/dist/cli/bundler/plugins/build-assets-map/index.d.ts +3 -0
- package/dist/cli/bundler/plugins/build-assets-map/index.js +8 -0
- package/dist/cli/bundler/plugins/build-assets-map/index.js.map +1 -0
- package/dist/cli/bundler/plugins/build-assets-map/usage.d.ts +12 -0
- package/dist/cli/bundler/plugins/build-assets-map/usage.js +28 -0
- package/dist/cli/bundler/plugins/build-assets-map/usage.js.map +1 -0
- package/dist/cli/bundler/plugins/chunk-loader/ChunkLoaderPlugin.d.ts +9 -0
- package/dist/cli/bundler/plugins/chunk-loader/ChunkLoaderPlugin.js +43 -0
- package/dist/cli/bundler/plugins/chunk-loader/ChunkLoaderPlugin.js.map +1 -0
- package/dist/cli/bundler/plugins/chunk-loader/index.d.ts +1 -0
- package/dist/cli/bundler/plugins/chunk-loader/index.js +5 -0
- package/dist/cli/bundler/plugins/chunk-loader/index.js.map +1 -0
- package/dist/cli/bundler/plugins/chunk-loader/templates/runtime.template.d.ts +2 -0
- package/dist/cli/bundler/plugins/chunk-loader/templates.d.ts +7 -0
- package/dist/cli/bundler/plugins/chunk-loader/templates.js +30 -0
- package/dist/cli/bundler/plugins/{EntrypointPlugin.d.ts → entrypoint/EntrypointPlugin.d.ts} +7 -2
- package/dist/cli/bundler/plugins/{EntrypointPlugin.js → entrypoint/EntrypointPlugin.js} +46 -26
- package/dist/cli/bundler/plugins/entrypoint/EntrypointPlugin.js.map +1 -0
- package/dist/cli/bundler/plugins/entrypoint/index.d.ts +1 -0
- package/dist/cli/bundler/plugins/entrypoint/index.js +7 -0
- package/dist/cli/bundler/plugins/entrypoint/index.js.map +1 -0
- package/dist/cli/bundler/plugins/{GenerateJsonPlugin.d.ts → generate-json/GenerateJsonPlugin.d.ts} +1 -0
- package/dist/cli/bundler/plugins/generate-json/GenerateJsonPlugin.js +73 -0
- package/dist/cli/bundler/plugins/generate-json/GenerateJsonPlugin.js.map +1 -0
- package/dist/cli/bundler/plugins/generate-json/index.d.ts +1 -0
- package/dist/cli/bundler/plugins/generate-json/index.js +5 -0
- package/dist/cli/bundler/plugins/generate-json/index.js.map +1 -0
- package/dist/cli/bundler/plugins/generate-module/GenerateModulePlugin.d.ts +23 -0
- package/dist/cli/bundler/plugins/generate-module/GenerateModulePlugin.js +88 -0
- package/dist/cli/bundler/plugins/generate-module/GenerateModulePlugin.js.map +1 -0
- package/dist/cli/bundler/plugins/generate-module/index.d.ts +1 -0
- package/dist/cli/bundler/plugins/generate-module/index.js +7 -0
- package/dist/cli/bundler/plugins/generate-module/index.js.map +1 -0
- package/dist/cli/bundler/plugins/index.d.ts +11 -5
- package/dist/cli/bundler/plugins/index.js +32 -10
- package/dist/cli/bundler/plugins/index.js.map +1 -1
- package/dist/cli/bundler/plugins/isolated-styles/IsolatedStylesPlugin.d.ts +21 -0
- package/dist/cli/bundler/plugins/isolated-styles/IsolatedStylesPlugin.js +174 -0
- package/dist/cli/bundler/plugins/isolated-styles/IsolatedStylesPlugin.js.map +1 -0
- package/dist/cli/bundler/plugins/isolated-styles/index.d.ts +1 -0
- package/dist/cli/bundler/plugins/isolated-styles/index.js +5 -0
- package/dist/cli/bundler/plugins/isolated-styles/index.js.map +1 -0
- package/dist/cli/bundler/plugins/isolated-styles/templates/css-loader.template.d.ts +1 -0
- package/dist/cli/bundler/plugins/isolated-styles/templates/runtime.template.d.ts +7 -0
- package/dist/cli/bundler/plugins/isolated-styles/templates.d.ts +18 -0
- package/dist/cli/bundler/plugins/isolated-styles/templates.js +174 -0
- package/dist/cli/bundler/plugins/manifest/ManifestPlugin.d.ts +10 -0
- package/dist/cli/bundler/plugins/manifest/ManifestPlugin.js +55 -0
- package/dist/cli/bundler/plugins/manifest/ManifestPlugin.js.map +1 -0
- package/dist/cli/bundler/plugins/manifest/index.d.ts +1 -0
- package/dist/cli/bundler/plugins/manifest/index.js +6 -0
- package/dist/cli/bundler/plugins/manifest/index.js.map +1 -0
- package/dist/cli/bundler/plugins/replace/ReplacePlugin.js.map +1 -0
- package/dist/cli/bundler/plugins/replace/index.d.ts +1 -0
- package/dist/cli/bundler/plugins/replace/index.js +5 -0
- package/dist/cli/bundler/plugins/replace/index.js.map +1 -0
- package/dist/cli/bundler/plugins/resource-access/ResourceAccessPlugin.d.ts +19 -0
- package/dist/cli/bundler/plugins/resource-access/ResourceAccessPlugin.js +20 -0
- package/dist/cli/bundler/plugins/resource-access/ResourceAccessPlugin.js.map +1 -0
- package/dist/cli/bundler/plugins/resource-access/index.d.ts +1 -0
- package/dist/cli/bundler/plugins/resource-access/index.js +5 -0
- package/dist/cli/bundler/plugins/resource-access/index.js.map +1 -0
- package/dist/cli/bundler/plugins/resource-access/utils.d.ts +8 -0
- package/dist/cli/bundler/plugins/resource-access/utils.js +42 -0
- package/dist/cli/bundler/plugins/resource-access/utils.js.map +1 -0
- package/dist/cli/bundler/plugins/types.d.ts +4 -0
- package/dist/cli/bundler/plugins/types.js +1 -0
- package/dist/cli/bundler/plugins/types.js.map +1 -0
- package/dist/cli/bundler/plugins/utils/index.d.ts +3 -0
- package/dist/cli/bundler/plugins/utils/index.js +9 -0
- package/dist/cli/bundler/plugins/utils/index.js.map +1 -0
- package/dist/cli/bundler/plugins/utils/manifest-hooks.d.ts +13 -0
- package/dist/cli/bundler/plugins/utils/manifest-hooks.js +17 -0
- package/dist/cli/bundler/plugins/utils/manifest-hooks.js.map +1 -0
- package/dist/cli/bundler/plugins/utils/runtime-template.d.ts +1 -0
- package/dist/cli/bundler/plugins/utils/runtime-template.js +18 -0
- package/dist/cli/bundler/plugins/utils/runtime-template.js.map +1 -0
- package/dist/cli/bundler/plugins/utils/watch-compilation.d.ts +3 -0
- package/dist/cli/bundler/plugins/utils/watch-compilation.js +18 -0
- package/dist/cli/bundler/plugins/utils/watch-compilation.js.map +1 -0
- package/dist/cli/bundler/plugins/watch/WatchPlugin.js +16 -0
- package/dist/cli/bundler/plugins/watch/WatchPlugin.js.map +1 -0
- package/dist/cli/bundler/plugins/watch/index.d.ts +1 -0
- package/dist/cli/bundler/plugins/watch/index.js +5 -0
- package/dist/cli/bundler/plugins/watch/index.js.map +1 -0
- package/dist/cli/bundler/utils/chunk-filename.d.ts +6 -0
- package/dist/cli/bundler/utils/chunk-filename.js +93 -0
- package/dist/cli/bundler/utils/chunk-filename.js.map +1 -0
- package/dist/cli/bundler/utils/index.d.ts +2 -0
- package/dist/cli/bundler/utils/index.js +2 -0
- package/dist/cli/bundler/utils/index.js.map +1 -1
- package/dist/cli/bundler/utils/layers.d.ts +4 -0
- package/dist/cli/bundler/utils/layers.js +10 -0
- package/dist/cli/bundler/utils/layers.js.map +1 -0
- package/dist/cli/bundler/utils/output.d.ts +6 -2
- package/dist/cli/bundler/utils/output.js +165 -7
- package/dist/cli/bundler/utils/output.js.map +1 -1
- package/dist/cli/bundler/utils/styles.d.ts +5 -0
- package/dist/cli/bundler/utils/styles.js +30 -0
- package/dist/cli/bundler/utils/styles.js.map +1 -0
- package/dist/cli/entrypoint/file/ExpressionFile.d.ts +4 -1
- package/dist/cli/entrypoint/file/ExpressionFile.js +11 -0
- package/dist/cli/entrypoint/file/ExpressionFile.js.map +1 -1
- package/dist/cli/entrypoint/file/OptionFile.d.ts +4 -2
- package/dist/cli/entrypoint/file/OptionFile.js +35 -31
- package/dist/cli/entrypoint/file/OptionFile.js.map +1 -1
- package/dist/cli/entrypoint/file/SourceFile.d.ts +18 -7
- package/dist/cli/entrypoint/file/SourceFile.js +260 -156
- package/dist/cli/entrypoint/file/SourceFile.js.map +1 -1
- package/dist/cli/entrypoint/file/index.d.ts +2 -0
- package/dist/cli/entrypoint/file/index.js +2 -0
- package/dist/cli/entrypoint/file/index.js.map +1 -1
- package/dist/cli/entrypoint/file/injectors/core.js +22 -1
- package/dist/cli/entrypoint/file/injectors/core.js.map +1 -1
- package/dist/cli/entrypoint/file/parsers/ExportParser.d.ts +14 -0
- package/dist/cli/entrypoint/file/parsers/ExportParser.js +71 -0
- package/dist/cli/entrypoint/file/parsers/ExportParser.js.map +1 -0
- package/dist/cli/entrypoint/file/parsers/NodeFinder.d.ts +2 -0
- package/dist/cli/entrypoint/file/parsers/NodeFinder.js +9 -0
- package/dist/cli/entrypoint/file/parsers/NodeFinder.js.map +1 -1
- package/dist/cli/entrypoint/file/parsers/ObjectParser.js +5 -1
- package/dist/cli/entrypoint/file/parsers/ObjectParser.js.map +1 -1
- package/dist/cli/entrypoint/file/parsers/index.d.ts +1 -0
- package/dist/cli/entrypoint/file/parsers/index.js +2 -0
- package/dist/cli/entrypoint/file/parsers/index.js.map +1 -1
- package/dist/cli/entrypoint/file/parsers/types.d.ts +16 -0
- package/dist/cli/entrypoint/file/parsers/types.js +13 -0
- package/dist/cli/entrypoint/file/parsers/types.js.map +1 -1
- package/dist/cli/entrypoint/file/resolvers/ImportResolver.d.ts +1 -0
- package/dist/cli/entrypoint/file/resolvers/ImportResolver.js +3 -0
- package/dist/cli/entrypoint/file/resolvers/ImportResolver.js.map +1 -1
- package/dist/cli/entrypoint/file/types.d.ts +26 -1
- package/dist/cli/entrypoint/finder/AbstractEntrypointFinder.d.ts +2 -2
- package/dist/cli/entrypoint/finder/AbstractEntrypointFinder.js +2 -2
- package/dist/cli/entrypoint/finder/AbstractEntrypointFinder.js.map +1 -1
- package/dist/cli/entrypoint/finder/{AbstractOptionsFinder.js → AbstractParsedFinder.js} +3 -3
- package/dist/cli/entrypoint/finder/AbstractParsedFinder.js.map +1 -0
- package/dist/cli/entrypoint/finder/OptionsFinder.d.ts +13 -0
- package/dist/cli/entrypoint/finder/OptionsFinder.js +33 -0
- package/dist/cli/entrypoint/finder/OptionsFinder.js.map +1 -0
- package/dist/cli/entrypoint/finder/PluginFinder.d.ts +4 -4
- package/dist/cli/entrypoint/finder/PluginFinder.js +2 -2
- package/dist/cli/entrypoint/finder/PluginFinder.js.map +1 -1
- package/dist/cli/entrypoint/finder/index.d.ts +2 -1
- package/dist/cli/entrypoint/finder/index.js +20 -18
- package/dist/cli/entrypoint/finder/index.js.map +1 -1
- package/dist/cli/entrypoint/parser/AbstractParser.d.ts +3 -2
- package/dist/cli/entrypoint/parser/AbstractParser.js +6 -3
- package/dist/cli/entrypoint/parser/AbstractParser.js.map +1 -1
- package/dist/cli/entrypoint/parser/CommandParser.js +1 -1
- package/dist/cli/entrypoint/parser/CommandParser.js.map +1 -1
- package/dist/cli/entrypoint/parser/ContentParser.d.ts +5 -1
- package/dist/cli/entrypoint/parser/ContentParser.js +55 -3
- package/dist/cli/entrypoint/parser/ContentParser.js.map +1 -1
- package/dist/cli/entrypoint/parser/OptionsParser.d.ts +6 -0
- package/dist/cli/entrypoint/parser/OptionsParser.js +16 -0
- package/dist/cli/entrypoint/parser/OptionsParser.js.map +1 -0
- package/dist/cli/entrypoint/parser/RelayParser.d.ts +21 -2
- package/dist/cli/entrypoint/parser/RelayParser.js +4 -0
- package/dist/cli/entrypoint/parser/RelayParser.js.map +1 -1
- package/dist/cli/entrypoint/parser/index.d.ts +1 -0
- package/dist/cli/entrypoint/parser/index.js +16 -14
- package/dist/cli/entrypoint/parser/index.js.map +1 -1
- package/dist/cli/plugins/asset.js +9 -4
- package/dist/cli/plugins/asset.js.map +1 -1
- package/dist/cli/plugins/background/index.js +1 -1
- package/dist/cli/plugins/background/index.js.map +1 -1
- package/dist/cli/plugins/content/Content.d.ts +1 -1
- package/dist/cli/plugins/content/Content.js +3 -2
- package/dist/cli/plugins/content/Content.js.map +1 -1
- package/dist/cli/plugins/content/ContentManager.d.ts +8 -5
- package/dist/cli/plugins/content/ContentManager.js +79 -28
- package/dist/cli/plugins/content/ContentManager.js.map +1 -1
- package/dist/cli/plugins/content/ContentName.d.ts +1 -1
- package/dist/cli/plugins/content/ContentName.js +8 -7
- package/dist/cli/plugins/content/ContentName.js.map +1 -1
- package/dist/cli/plugins/content/Relay.d.ts +1 -1
- package/dist/cli/plugins/content/Relay.js +3 -2
- package/dist/cli/plugins/content/Relay.js.map +1 -1
- package/dist/cli/plugins/content/bundler.d.ts +7 -0
- package/dist/cli/plugins/content/bundler.js +47 -0
- package/dist/cli/plugins/content/bundler.js.map +1 -0
- package/dist/cli/plugins/content/index.js +121 -62
- package/dist/cli/plugins/content/index.js.map +1 -1
- package/dist/cli/plugins/content/relay-module.d.ts +3 -0
- package/dist/cli/plugins/content/relay-module.js +11 -0
- package/dist/cli/plugins/content/relay-module.js.map +1 -0
- package/dist/cli/plugins/content/types.d.ts +1 -1
- package/dist/cli/plugins/content/utils.d.ts +2 -0
- package/dist/cli/plugins/content/utils.js +8 -1
- package/dist/cli/plugins/content/utils.js.map +1 -1
- package/dist/cli/plugins/icon/declaration/IconDeclaration.d.ts +1 -1
- package/dist/cli/plugins/icon/declaration/IconDeclaration.js +6 -6
- package/dist/cli/plugins/icon/declaration/IconDeclaration.js.map +1 -1
- package/dist/cli/plugins/icon/declaration/icon.d.ts +3 -5
- package/dist/cli/plugins/icon/icon-module.d.ts +2 -0
- package/dist/cli/plugins/icon/icon-module.js +11 -0
- package/dist/cli/plugins/icon/icon-module.js.map +1 -0
- package/dist/cli/plugins/icon/index.js +5 -3
- package/dist/cli/plugins/icon/index.js.map +1 -1
- package/dist/cli/plugins/index.d.ts +1 -0
- package/dist/cli/plugins/index.js +22 -20
- package/dist/cli/plugins/index.js.map +1 -1
- package/dist/cli/plugins/locale/Locale.d.ts +9 -2
- package/dist/cli/plugins/locale/Locale.js +37 -5
- package/dist/cli/plugins/locale/Locale.js.map +1 -1
- package/dist/cli/plugins/locale/declaration/locale.d.ts +1 -1
- package/dist/cli/plugins/locale/index.js +57 -22
- package/dist/cli/plugins/locale/index.js.map +1 -1
- package/dist/cli/plugins/locale/locale-module.d.ts +4 -0
- package/dist/cli/plugins/locale/locale-module.js +16 -0
- package/dist/cli/plugins/locale/locale-module.js.map +1 -0
- package/dist/cli/plugins/offscreen/Offscreen.d.ts +2 -3
- package/dist/cli/plugins/offscreen/Offscreen.js.map +1 -1
- package/dist/cli/plugins/offscreen/index.js +5 -4
- package/dist/cli/plugins/offscreen/index.js.map +1 -1
- package/dist/cli/plugins/offscreen/offscreen-module.d.ts +3 -0
- package/dist/cli/plugins/offscreen/offscreen-module.js +11 -0
- package/dist/cli/plugins/offscreen/offscreen-module.js.map +1 -0
- package/dist/cli/plugins/options/Options.d.ts +10 -0
- package/dist/cli/plugins/options/Options.js +24 -0
- package/dist/cli/plugins/options/Options.js.map +1 -0
- package/dist/cli/plugins/options/index.d.ts +2 -0
- package/dist/cli/plugins/options/index.js +41 -0
- package/dist/cli/plugins/options/index.js.map +1 -0
- package/dist/cli/plugins/output.js +33 -3
- package/dist/cli/plugins/output.js.map +1 -1
- package/dist/cli/plugins/page/declaration/PageDeclaration.js +4 -4
- package/dist/cli/plugins/page/declaration/PageDeclaration.js.map +1 -1
- package/dist/cli/plugins/page/declaration/page.d.ts +3 -3
- package/dist/cli/plugins/page/index.js +14 -10
- package/dist/cli/plugins/page/index.js.map +1 -1
- package/dist/cli/plugins/page/page-module.d.ts +2 -0
- package/dist/cli/plugins/page/page-module.js +11 -0
- package/dist/cli/plugins/page/page-module.js.map +1 -0
- package/dist/cli/plugins/popup/Popup.d.ts +1 -1
- package/dist/cli/plugins/popup/Popup.js +2 -2
- package/dist/cli/plugins/popup/Popup.js.map +1 -1
- package/dist/cli/plugins/popup/declaration/PopupDeclaration.d.ts +1 -1
- package/dist/cli/plugins/popup/declaration/PopupDeclaration.js +6 -6
- package/dist/cli/plugins/popup/declaration/PopupDeclaration.js.map +1 -1
- package/dist/cli/plugins/popup/declaration/popup.d.ts +3 -3
- package/dist/cli/plugins/popup/index.js +6 -5
- package/dist/cli/plugins/popup/index.js.map +1 -1
- package/dist/cli/plugins/popup/popup-module.d.ts +3 -0
- package/dist/cli/plugins/popup/popup-module.js +11 -0
- package/dist/cli/plugins/popup/popup-module.js.map +1 -0
- package/dist/cli/plugins/sandbox/Sandbox.d.ts +1 -2
- package/dist/cli/plugins/sandbox/Sandbox.js.map +1 -1
- package/dist/cli/plugins/sandbox/index.js +5 -4
- package/dist/cli/plugins/sandbox/index.js.map +1 -1
- package/dist/cli/plugins/sandbox/sandbox-module.d.ts +3 -0
- package/dist/cli/plugins/sandbox/sandbox-module.js +11 -0
- package/dist/cli/plugins/sandbox/sandbox-module.js.map +1 -0
- package/dist/cli/plugins/sidebar/Sidebar.d.ts +1 -1
- package/dist/cli/plugins/sidebar/Sidebar.js +2 -2
- package/dist/cli/plugins/sidebar/Sidebar.js.map +1 -1
- package/dist/cli/plugins/sidebar/declaration/SidebarDeclaration.d.ts +1 -1
- package/dist/cli/plugins/sidebar/declaration/SidebarDeclaration.js +6 -6
- package/dist/cli/plugins/sidebar/declaration/SidebarDeclaration.js.map +1 -1
- package/dist/cli/plugins/sidebar/declaration/sidebar.d.ts +3 -3
- package/dist/cli/plugins/sidebar/index.js +6 -5
- package/dist/cli/plugins/sidebar/index.js.map +1 -1
- package/dist/cli/plugins/sidebar/sidebar-module.d.ts +3 -0
- package/dist/cli/plugins/sidebar/sidebar-module.js +11 -0
- package/dist/cli/plugins/sidebar/sidebar-module.js.map +1 -0
- package/dist/cli/plugins/style/index.d.ts +2 -1
- package/dist/cli/plugins/style/index.js +52 -25
- package/dist/cli/plugins/style/index.js.map +1 -1
- package/dist/cli/plugins/style/types.d.ts +5 -0
- package/dist/cli/plugins/style/types.js +1 -0
- package/dist/cli/plugins/style/types.js.map +1 -0
- package/dist/cli/plugins/view/index.js +1 -1
- package/dist/cli/plugins/view/index.js.map +1 -1
- package/dist/cli/raw.d.ts +4 -0
- package/dist/cli/resolvers/bundler.js +9 -7
- package/dist/cli/resolvers/bundler.js.map +1 -1
- package/dist/cli/resolvers/config.js +4 -1
- package/dist/cli/resolvers/config.js.map +1 -1
- package/dist/cli/virtual/index.d.ts +2 -2
- package/dist/cli/virtual/index.js +11 -8
- package/dist/cli/virtual/virtual.d.ts +8 -10
- package/dist/entry/content/adapters/react/Builder.js +1 -1
- package/dist/entry/content/adapters/react/Builder.js.map +1 -1
- package/dist/entry/content/adapters/react/Node.d.ts +2 -0
- package/dist/entry/content/adapters/react/Node.js +10 -2
- package/dist/entry/content/adapters/react/Node.js.map +1 -1
- package/dist/entry/content/adapters/vanilla/Builder.js +1 -1
- package/dist/entry/content/adapters/vanilla/Builder.js.map +1 -1
- package/dist/entry/content/adapters/vanilla/Node.d.ts +2 -1
- package/dist/entry/content/adapters/vanilla/Node.js +10 -7
- package/dist/entry/content/adapters/vanilla/Node.js.map +1 -1
- package/dist/entry/content/core/Builder.d.ts +1 -2
- package/dist/entry/content/core/Builder.js +9 -5
- package/dist/entry/content/core/Builder.js.map +1 -1
- package/dist/entry/content/core/MountBuilder.js +14 -6
- package/dist/entry/content/core/MountBuilder.js.map +1 -1
- package/dist/entry/content/core/{Context.d.ts → context/Context.d.ts} +2 -1
- package/dist/entry/content/core/{Context.js → context/Context.js} +7 -0
- package/dist/entry/content/core/context/Context.js.map +1 -0
- package/dist/entry/content/core/{EventEmitter.d.ts → context/EventEmitter.d.ts} +1 -1
- package/dist/entry/content/core/{EventEmitter.js → context/EventEmitter.js} +1 -1
- package/dist/entry/content/core/context/EventEmitter.js.map +1 -0
- package/dist/entry/content/core/{ManagedContext.d.ts → context/ManagedContext.d.ts} +1 -1
- package/dist/entry/content/core/context/ManagedContext.js.map +1 -0
- package/dist/entry/content/core/context/index.d.ts +3 -0
- package/dist/entry/content/core/context/index.js +9 -0
- package/dist/entry/content/core/context/index.js.map +1 -0
- package/dist/entry/content/core/{AbstractMarker.d.ts → markers/AbstractMarker.d.ts} +1 -1
- package/dist/entry/content/core/{AbstractMarker.js → markers/AbstractMarker.js} +1 -1
- package/dist/entry/content/core/markers/AbstractMarker.js.map +1 -0
- package/dist/entry/content/core/{AttributeMarker.d.ts → markers/AttributeMarker.d.ts} +1 -1
- package/dist/entry/content/core/markers/AttributeMarker.js.map +1 -0
- package/dist/entry/content/core/{WeakMarker.d.ts → markers/WeakMarker.d.ts} +1 -1
- package/dist/entry/content/core/markers/WeakMarker.js.map +1 -0
- package/dist/entry/content/core/markers/index.d.ts +3 -0
- package/dist/entry/content/core/markers/index.js +9 -0
- package/dist/entry/content/core/markers/index.js.map +1 -0
- package/dist/entry/content/core/{EventNode.d.ts → nodes/EventNode.d.ts} +2 -1
- package/dist/entry/content/core/{EventNode.js → nodes/EventNode.js} +3 -0
- package/dist/entry/content/core/nodes/EventNode.js.map +1 -0
- package/dist/entry/content/core/nodes/FrameNode.d.ts +23 -0
- package/dist/entry/content/core/nodes/FrameNode.js +125 -0
- package/dist/entry/content/core/nodes/FrameNode.js.map +1 -0
- package/dist/entry/content/core/{MarkerNode.d.ts → nodes/MarkerNode.d.ts} +2 -1
- package/dist/entry/content/core/{MarkerNode.js → nodes/MarkerNode.js} +3 -0
- package/dist/entry/content/core/nodes/MarkerNode.js.map +1 -0
- package/dist/entry/content/core/{MountNode.d.ts → nodes/MountNode.d.ts} +2 -1
- package/dist/entry/content/core/{MountNode.js → nodes/MountNode.js} +3 -0
- package/dist/entry/content/core/nodes/MountNode.js.map +1 -0
- package/dist/entry/content/core/{Node.d.ts → nodes/Node.d.ts} +2 -1
- package/dist/entry/content/core/{Node.js → nodes/Node.js} +3 -0
- package/dist/entry/content/core/nodes/Node.js.map +1 -0
- package/dist/entry/content/core/nodes/ShadowNode.d.ts +14 -0
- package/dist/entry/content/core/nodes/ShadowNode.js +67 -0
- package/dist/entry/content/core/nodes/ShadowNode.js.map +1 -0
- package/dist/entry/content/core/nodes/index.d.ts +6 -0
- package/dist/entry/content/core/nodes/index.js +15 -0
- package/dist/entry/content/core/nodes/index.js.map +1 -0
- package/dist/entry/content/core/nodes/isolated-styles.d.ts +2 -0
- package/dist/entry/content/core/nodes/isolated-styles.js +14 -0
- package/dist/entry/content/core/nodes/isolated-styles.js.map +1 -0
- package/dist/entry/content/core/resolvers/watch.js +1 -1
- package/dist/entry/content/core/resolvers/watch.js.map +1 -1
- package/dist/entry/content/frame/Builder.d.ts +7 -0
- package/dist/entry/content/frame/Builder.js +14 -0
- package/dist/entry/content/frame/Builder.js.map +1 -0
- package/dist/entry/content/frame/index.d.ts +4 -0
- package/dist/entry/content/frame/index.js +7 -0
- package/dist/entry/content/frame/index.js.map +1 -0
- package/dist/entry/relay/Builder.js +5 -1
- package/dist/entry/relay/Builder.js.map +1 -1
- package/dist/entry/relay/index.d.ts +1 -1
- package/dist/locale/adapters/react/ReactLocale.d.ts +18 -0
- package/dist/locale/adapters/react/ReactLocale.js +41 -0
- package/dist/locale/adapters/react/ReactLocale.js.map +1 -0
- package/dist/locale/adapters/react/hooks/use-locale-attributes.d.ts +7 -0
- package/dist/locale/adapters/react/hooks/use-locale-attributes.js +30 -0
- package/dist/locale/adapters/react/hooks/use-locale-attributes.js.map +1 -0
- package/dist/locale/adapters/react/hooks/use-locale.d.ts +3 -0
- package/dist/locale/adapters/react/hooks/use-locale.js +17 -0
- package/dist/locale/adapters/react/hooks/use-locale.js.map +1 -0
- package/dist/locale/adapters/react/hooks/use-native-locale.d.ts +3 -0
- package/dist/locale/adapters/react/hooks/use-native-locale.js +10 -0
- package/dist/locale/adapters/react/hooks/use-native-locale.js.map +1 -0
- package/dist/locale/adapters/react/index.d.ts +4 -2
- package/dist/locale/adapters/react/index.js +6 -4
- package/dist/locale/adapters/react/index.js.map +1 -1
- package/dist/locale/adapters/react/types.d.ts +22 -0
- package/dist/locale/adapters/react/types.js +1 -0
- package/dist/locale/adapters/react/types.js.map +1 -0
- package/dist/locale/helpers.d.ts +4 -5
- package/dist/locale/helpers.js +1 -1
- package/dist/locale/helpers.js.map +1 -1
- package/dist/locale/index.d.ts +2 -1
- package/dist/locale/index.js +1 -0
- package/dist/locale/index.js.map +1 -1
- package/dist/locale/providers/AbstractLocale.d.ts +4 -4
- package/dist/locale/providers/AbstractLocale.js +13 -94
- package/dist/locale/providers/AbstractLocale.js.map +1 -1
- package/dist/locale/providers/CustomLocale.d.ts +3 -3
- package/dist/locale/providers/CustomLocale.js +6 -5
- package/dist/locale/providers/CustomLocale.js.map +1 -1
- package/dist/locale/providers/DynamicLocale.d.ts +18 -11
- package/dist/locale/providers/DynamicLocale.js +60 -47
- package/dist/locale/providers/DynamicLocale.js.map +1 -1
- package/dist/locale/providers/NativeLocale.d.ts +4 -7
- package/dist/locale/providers/NativeLocale.js +5 -14
- package/dist/locale/providers/NativeLocale.js.map +1 -1
- package/dist/locale/providers/ObservableLocale.d.ts +35 -0
- package/dist/locale/providers/ObservableLocale.js +179 -0
- package/dist/locale/providers/ObservableLocale.js.map +1 -0
- package/dist/locale/providers/index.d.ts +2 -1
- package/dist/locale/providers/index.js +3 -1
- package/dist/locale/providers/index.js.map +1 -1
- package/dist/locale/storage/LocaleStorage.d.ts +11 -0
- package/dist/locale/storage/LocaleStorage.js +40 -0
- package/dist/locale/storage/LocaleStorage.js.map +1 -0
- package/dist/locale/storage/index.d.ts +1 -0
- package/dist/locale/storage/index.js +5 -0
- package/dist/locale/storage/index.js.map +1 -0
- package/dist/main/entrypoint.d.ts +4 -0
- package/dist/main/entrypoint.js +20 -0
- package/dist/main/entrypoint.js.map +1 -0
- package/dist/main/icon.d.ts +2 -3
- package/dist/main/icon.js +2 -1
- package/dist/main/icon.js.map +1 -1
- package/dist/main/index.d.ts +2 -0
- package/dist/main/index.js +2 -0
- package/dist/main/index.js.map +1 -1
- package/dist/main/offscreen.d.ts +2 -5
- package/dist/main/offscreen.js +5 -2
- package/dist/main/offscreen.js.map +1 -1
- package/dist/main/options.d.ts +3 -0
- package/dist/main/options.js +7 -0
- package/dist/main/options.js.map +1 -0
- package/dist/main/page.d.ts +2 -4
- package/dist/main/page.js +2 -1
- package/dist/main/page.js.map +1 -1
- package/dist/main/popup.d.ts +2 -5
- package/dist/main/popup.js +3 -3
- package/dist/main/popup.js.map +1 -1
- package/dist/main/relay.d.ts +1 -2
- package/dist/main/relay.js +2 -1
- package/dist/main/relay.js.map +1 -1
- package/dist/main/sandbox.d.ts +1 -4
- package/dist/main/sandbox.js +2 -1
- package/dist/main/sandbox.js.map +1 -1
- package/dist/main/service.d.ts +1 -2
- package/dist/main/service.js.map +1 -1
- package/dist/main/sidebar.d.ts +2 -5
- package/dist/main/sidebar.js +3 -3
- package/dist/main/sidebar.js.map +1 -1
- package/dist/message/index.d.ts +2 -4
- package/dist/message/index.js.map +1 -1
- package/dist/offscreen/index.d.ts +2 -6
- package/dist/offscreen/index.js.map +1 -1
- package/dist/relay/index.d.ts +2 -5
- package/dist/relay/index.js.map +1 -1
- package/dist/sandbox/index.d.ts +1 -5
- package/dist/sandbox/index.js.map +1 -1
- package/dist/service/index.d.ts +2 -6
- package/dist/service/index.js.map +1 -1
- package/dist/shared/content/index.d.ts +1 -0
- package/dist/shared/content/index.js +6 -0
- package/dist/shared/content/index.js.map +1 -0
- package/dist/shared/content/isolation.d.ts +4 -0
- package/dist/shared/content/isolation.js +70 -0
- package/dist/shared/content/isolation.js.map +1 -0
- package/dist/shared/locale/index.d.ts +5 -0
- package/dist/shared/locale/index.js +21 -0
- package/dist/shared/locale/index.js.map +1 -0
- package/dist/shared/locale/keys.d.ts +5 -0
- package/dist/shared/locale/keys.js +33 -0
- package/dist/shared/locale/keys.js.map +1 -0
- package/dist/shared/locale/language.d.ts +4 -0
- package/dist/shared/locale/language.js +23 -0
- package/dist/shared/locale/language.js.map +1 -0
- package/dist/shared/locale/messages.d.ts +3 -0
- package/dist/shared/locale/messages.js +9 -0
- package/dist/shared/locale/messages.js.map +1 -0
- package/dist/shared/locale/plural.d.ts +2 -0
- package/dist/shared/locale/plural.js +81 -0
- package/dist/shared/locale/plural.js.map +1 -0
- package/dist/shared/locale/substitutions.d.ts +10 -0
- package/dist/shared/locale/substitutions.js +32 -0
- package/dist/shared/locale/substitutions.js.map +1 -0
- package/dist/types/background.d.ts +1 -1
- package/dist/types/background.js.map +1 -1
- package/dist/types/command.d.ts +1 -1
- package/dist/types/command.js.map +1 -1
- package/dist/types/content.d.ts +120 -31
- package/dist/types/content.js +22 -1
- package/dist/types/content.js.map +1 -1
- package/dist/types/entrypoint.d.ts +20 -0
- package/dist/types/entrypoint.js +4 -0
- package/dist/types/entrypoint.js.map +1 -1
- package/dist/types/icon.d.ts +8 -0
- package/dist/types/icon.js.map +1 -1
- package/dist/types/language.d.ts +57 -0
- package/dist/types/language.js +62 -0
- package/dist/types/language.js.map +1 -0
- package/dist/types/locale.d.ts +34 -63
- package/dist/types/locale.js +62 -119
- package/dist/types/locale.js.map +1 -1
- package/dist/types/manifest.d.ts +24 -7
- package/dist/types/manifest.js.map +1 -1
- package/dist/types/message.d.ts +7 -0
- package/dist/types/message.js.map +1 -1
- package/dist/types/offscreen.d.ts +14 -1
- package/dist/types/offscreen.js.map +1 -1
- package/dist/types/options.d.ts +9 -0
- package/dist/types/options.js +1 -0
- package/dist/types/options.js.map +1 -0
- package/dist/types/page.d.ts +8 -0
- package/dist/types/plugin.d.ts +2 -1
- package/dist/types/popup.d.ts +9 -0
- package/dist/types/relay.d.ts +16 -7
- package/dist/types/relay.js.map +1 -1
- package/dist/types/sandbox.d.ts +12 -0
- package/dist/types/sandbox.js.map +1 -1
- package/dist/types/service.d.ts +10 -1
- package/dist/types/service.js.map +1 -1
- package/dist/types/sidebar.d.ts +9 -0
- package/dist/types/sidebar.js.map +1 -1
- package/dist/types/transport.d.ts +4 -0
- package/dist/virtual/entrypoint.d.ts +5 -0
- package/dist/virtual/entrypoint.js +7 -0
- package/dist/virtual/entrypoint.js.map +1 -0
- package/dist/virtual/icon.d.ts +2 -0
- package/dist/virtual/icon.js +5 -0
- package/dist/virtual/icon.js.map +1 -0
- package/dist/virtual/locale.d.ts +7 -0
- package/dist/virtual/locale.js +13 -0
- package/dist/virtual/locale.js.map +1 -0
- package/dist/virtual/modules.d.ts +40 -0
- package/dist/virtual/offscreen.d.ts +3 -0
- package/dist/virtual/offscreen.js +5 -0
- package/dist/virtual/offscreen.js.map +1 -0
- package/dist/virtual/page.d.ts +2 -0
- package/dist/virtual/page.js +5 -0
- package/dist/virtual/page.js.map +1 -0
- package/dist/virtual/popup.d.ts +3 -0
- package/dist/virtual/popup.js +5 -0
- package/dist/virtual/popup.js.map +1 -0
- package/dist/virtual/relay.d.ts +3 -0
- package/dist/virtual/relay.js +5 -0
- package/dist/virtual/relay.js.map +1 -0
- package/dist/virtual/sandbox.d.ts +3 -0
- package/dist/virtual/sandbox.js +5 -0
- package/dist/virtual/sandbox.js.map +1 -0
- package/dist/virtual/sidebar.d.ts +3 -0
- package/dist/virtual/sidebar.js +5 -0
- package/dist/virtual/sidebar.js.map +1 -0
- package/package.json +31 -10
- package/scripts/clean-dist.js +7 -0
- package/scripts/copy-dts.js +11 -1
- package/types/client.d.ts +15 -0
- package/dist/cli/builders/manifest/utils.d.ts +0 -32
- package/dist/cli/builders/manifest/utils.js +0 -209
- package/dist/cli/builders/manifest/utils.js.map +0 -1
- package/dist/cli/bundler/plugins/EntrypointPlugin.js.map +0 -1
- package/dist/cli/bundler/plugins/GenerateJsonPlugin.js +0 -40
- package/dist/cli/bundler/plugins/GenerateJsonPlugin.js.map +0 -1
- package/dist/cli/bundler/plugins/ManifestPlugin.d.ts +0 -10
- package/dist/cli/bundler/plugins/ManifestPlugin.js +0 -78
- package/dist/cli/bundler/plugins/ManifestPlugin.js.map +0 -1
- package/dist/cli/bundler/plugins/ReplacePlugin.js.map +0 -1
- package/dist/cli/bundler/plugins/WatchPlugin.js +0 -21
- package/dist/cli/bundler/plugins/WatchPlugin.js.map +0 -1
- package/dist/cli/entrypoint/finder/AbstractOptionsFinder.js.map +0 -1
- package/dist/entry/content/core/AbstractMarker.js.map +0 -1
- package/dist/entry/content/core/AttributeMarker.js.map +0 -1
- package/dist/entry/content/core/Context.js.map +0 -1
- package/dist/entry/content/core/EventEmitter.js.map +0 -1
- package/dist/entry/content/core/EventNode.js.map +0 -1
- package/dist/entry/content/core/ManagedContext.js.map +0 -1
- package/dist/entry/content/core/MarkerNode.js.map +0 -1
- package/dist/entry/content/core/MountNode.js.map +0 -1
- package/dist/entry/content/core/Node.js.map +0 -1
- package/dist/entry/content/core/WeakMarker.js.map +0 -1
- package/dist/locale/adapters/react/LocaleProvider.d.ts +0 -7
- package/dist/locale/adapters/react/LocaleProvider.js +0 -58
- package/dist/locale/adapters/react/LocaleProvider.js.map +0 -1
- package/dist/locale/adapters/react/context.d.ts +0 -14
- package/dist/locale/adapters/react/context.js +0 -25
- package/dist/locale/adapters/react/context.js.map +0 -1
- package/dist/locale/utils.d.ts +0 -11
- package/dist/locale/utils.js +0 -67
- package/dist/locale/utils.js.map +0 -1
- /package/dist/cli/bundler/plugins/{ReplacePlugin.d.ts → replace/ReplacePlugin.d.ts} +0 -0
- /package/dist/cli/bundler/plugins/{ReplacePlugin.js → replace/ReplacePlugin.js} +0 -0
- /package/dist/cli/bundler/plugins/{WatchPlugin.d.ts → watch/WatchPlugin.d.ts} +0 -0
- /package/dist/cli/entrypoint/finder/{AbstractOptionsFinder.d.ts → AbstractParsedFinder.d.ts} +0 -0
- /package/dist/entry/content/core/{ManagedContext.js → context/ManagedContext.js} +0 -0
- /package/dist/entry/content/core/{AttributeMarker.js → markers/AttributeMarker.js} +0 -0
- /package/dist/entry/content/core/{WeakMarker.js → markers/WeakMarker.js} +0 -0
package/dist/locale/helpers.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { LocaleNonPluralKeys, LocalePluralKeys, LocaleSubstitutionArgs } from "../types/locale.js";
|
|
1
|
+
import type { LocaleNonPluralKeys, LocalePluralKeys, LocaleRegistry, LocaleSubstitutionArgs } from "../types/locale.js";
|
|
3
2
|
/**
|
|
4
3
|
* Translates a non-plural locale key.
|
|
5
4
|
*
|
|
@@ -17,7 +16,7 @@ import { LocaleNonPluralKeys, LocalePluralKeys, LocaleSubstitutionArgs } from ".
|
|
|
17
16
|
* @param args
|
|
18
17
|
* @returns The translated string.
|
|
19
18
|
*/
|
|
20
|
-
export declare const t: <K extends LocaleNonPluralKeys<
|
|
19
|
+
export declare const t: <K extends LocaleNonPluralKeys<LocaleRegistry>>(key: K, ...args: LocaleSubstitutionArgs<LocaleRegistry, K>) => string;
|
|
21
20
|
/**
|
|
22
21
|
* Translates a plural locale key using the provided count.
|
|
23
22
|
*
|
|
@@ -35,7 +34,7 @@ export declare const t: <K extends LocaleNonPluralKeys<LocaleNativeStructure>>(k
|
|
|
35
34
|
* @param args
|
|
36
35
|
* @returns The translated string.
|
|
37
36
|
*/
|
|
38
|
-
export declare const choice: <K extends LocalePluralKeys<
|
|
37
|
+
export declare const choice: <K extends LocalePluralKeys<LocaleRegistry>>(key: K, count: number, ...args: LocaleSubstitutionArgs<LocaleRegistry, K>) => string;
|
|
39
38
|
/**
|
|
40
39
|
* Converts a locale key to a browser message reference.
|
|
41
40
|
*
|
|
@@ -52,7 +51,7 @@ export declare const choice: <K extends LocalePluralKeys<LocaleNativeStructure>>
|
|
|
52
51
|
* @param value - The locale key to convert.
|
|
53
52
|
* @returns The browser message reference.
|
|
54
53
|
*/
|
|
55
|
-
export declare const key: (value: keyof
|
|
54
|
+
export declare const key: (value: keyof LocaleRegistry & string) => string;
|
|
56
55
|
/**
|
|
57
56
|
* Resolves a string that may contain a locale marker.
|
|
58
57
|
*
|
package/dist/locale/helpers.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NativeLocale } from "./../locale/providers/index.js";
|
|
2
|
-
import { convertLocaleMessageKey, extractLocaleKey } from "./../locale/
|
|
2
|
+
import { convertLocaleMessageKey, extractLocaleKey } from "./../shared/locale/index.js";
|
|
3
3
|
const t = (key2, ...args) => {
|
|
4
4
|
return NativeLocale.getInstance().trans(key2, ...args);
|
|
5
5
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/locale/helpers.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../src/locale/helpers.ts"],"sourcesContent":["import {NativeLocale} from \"@locale/providers\";\nimport {convertLocaleMessageKey, extractLocaleKey} from \"@shared/locale\";\nimport type {LocaleNonPluralKeys, LocalePluralKeys, LocaleRegistry, LocaleSubstitutionArgs} from \"@typing/locale\";\n\n/**\n * Translates a non-plural locale key.\n *\n * Substitutions are type-checked from the generated locale structure:\n * keys without placeholders do not accept substitutions, while keys with\n * placeholders require all declared substitution values.\n *\n * @example\n * ```ts\n * t(\"app.name\");\n * t(\"app.greeting\", {name: \"Alice\"});\n * ```\n *\n * @param key - The locale key to translate.\n * @param args\n * @returns The translated string.\n */\nexport const t = <K extends LocaleNonPluralKeys<LocaleRegistry>>(\n key: K,\n ...args: LocaleSubstitutionArgs<LocaleRegistry, K>\n): string => {\n return NativeLocale.getInstance().trans(key, ...args);\n};\n\n/**\n * Translates a plural locale key using the provided count.\n *\n * Substitutions are type-checked from the generated locale structure:\n * keys without placeholders do not accept substitutions, while keys with\n * placeholders require all declared substitution values.\n *\n * @example\n * ```ts\n * choice(\"cart.items\", count, {count});\n * ```\n *\n * @param key - The locale key to translate.\n * @param count - The count used to select the plural form.\n * @param args\n * @returns The translated string.\n */\nexport const choice = <K extends LocalePluralKeys<LocaleRegistry>>(\n key: K,\n count: number,\n ...args: LocaleSubstitutionArgs<LocaleRegistry, K>\n): string => {\n return NativeLocale.getInstance().choice(key, count, ...args);\n};\n\n/**\n * Converts a locale key to a browser message reference.\n *\n * This is useful for browser-managed extension fields that expect\n * `__MSG_name__` references instead of already translated text.\n *\n * A warning is logged when the key does not exist in the generated locale keys.\n *\n * @example\n * ```ts\n * key(\"app.name\"); // \"__MSG_app_name__\"\n * ```\n *\n * @param value - The locale key to convert.\n * @returns The browser message reference.\n */\nexport const key = (value: keyof LocaleRegistry & string): string => {\n const locale = NativeLocale.getInstance();\n\n if (!locale.keys().has(value)) {\n console.warn(`Locale key \"${value}\" not found in \"${locale.lang()}\" language.`);\n }\n\n return convertLocaleMessageKey(value);\n};\n\n/**\n * Resolves a string that may contain a locale marker.\n *\n * When the input contains a locale marker, the marker is extracted and translated.\n * Plain strings are returned unchanged.\n *\n * @example\n * ```ts\n * resolve(\"@app.name\");\n * resolve(\"Plain title\");\n * ```\n *\n * @param input - A plain string or a marked locale key string.\n * @returns The translated text when a marker is found, otherwise the original input.\n */\nexport const resolve = (input: string): string => {\n const localeKey = extractLocaleKey(input);\n\n if (localeKey) {\n // Markers are runtime strings without substitutions; keep t() strict for typed callers.\n return (t as (key: string) => string)(localeKey);\n }\n\n return input;\n};\n"],"mappings":"AAAA,SAAQ,oBAAmB;AAC3B,SAAQ,yBAAyB,wBAAuB;AAoBjD,MAAM,IAAI,CACbA,SACG,SACM;AACT,SAAO,aAAa,YAAY,EAAE,MAAMA,MAAK,GAAG,IAAI;AACxD;AAmBO,MAAM,SAAS,CAClBA,MACA,UACG,SACM;AACT,SAAO,aAAa,YAAY,EAAE,OAAOA,MAAK,OAAO,GAAG,IAAI;AAChE;AAkBO,MAAM,MAAM,CAAC,UAAiD;AACjE,QAAM,SAAS,aAAa,YAAY;AAExC,MAAI,CAAC,OAAO,KAAK,EAAE,IAAI,KAAK,GAAG;AAC3B,YAAQ,KAAK,eAAe,KAAK,mBAAmB,OAAO,KAAK,CAAC,aAAa;AAAA,EAClF;AAEA,SAAO,wBAAwB,KAAK;AACxC;AAiBO,MAAM,UAAU,CAAC,UAA0B;AAC9C,QAAM,YAAY,iBAAiB,KAAK;AAExC,MAAI,WAAW;AAEX,WAAQ,EAA8B,SAAS;AAAA,EACnD;AAEA,SAAO;AACX;","names":["key"]}
|
package/dist/locale/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export * from "./providers/index.js";
|
|
2
2
|
export * from "./helpers.js";
|
|
3
|
-
export
|
|
3
|
+
export * from "./storage/index.js";
|
|
4
|
+
export { Language, LanguageCodes, LocaleDir, type LocaleStructure, type LocaleRegistry, type LocaleProvider, type LocaleDynamicProvider, type LocaleSnapshot, type LocaleStorageDriver, type LocaleKeys, type LocaleSubstitutionArgs, type LocaleSubstitutionKeys, type LocaleSubstitutionValue, type LocaleNonPluralKeys, type LocalePluralKeys, } from "../types/locale.js";
|
package/dist/locale/index.js
CHANGED
package/dist/locale/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/locale/index.ts"],"sourcesContent":["export * from \"./providers\";\nexport * from \"./helpers\";\n\nexport {\n Language,\n LanguageCodes,\n LocaleDir,\n type LocaleStructure,\n type LocaleProvider,\n type LocaleDynamicProvider,\n type LocaleKeys,\n type LocaleSubstitutionArgs,\n type LocaleSubstitutionKeys,\n type LocaleSubstitutionValue,\n type LocaleNonPluralKeys,\n type LocalePluralKeys,\n} from \"@typing/locale\";\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AAEd;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,
|
|
1
|
+
{"version":3,"sources":["../../src/locale/index.ts"],"sourcesContent":["export * from \"./providers\";\nexport * from \"./helpers\";\nexport * from \"./storage\";\n\nexport {\n Language,\n LanguageCodes,\n LocaleDir,\n type LocaleStructure,\n type LocaleRegistry,\n type LocaleProvider,\n type LocaleDynamicProvider,\n type LocaleSnapshot,\n type LocaleStorageDriver,\n type LocaleKeys,\n type LocaleSubstitutionArgs,\n type LocaleSubstitutionKeys,\n type LocaleSubstitutionValue,\n type LocaleNonPluralKeys,\n type LocalePluralKeys,\n} from \"@typing/locale\";\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AAEd;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,OAaG;","names":[]}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Language, LocaleNonPluralKeys, LocalePluralKeys, LocaleProvider, LocaleStructure, LocaleSubstitutionArgs, LocaleSubstitutionValue } from "../../types/locale.js";
|
|
2
|
-
export default abstract class<S extends object = LocaleStructure> implements LocaleProvider<S> {
|
|
2
|
+
export default abstract class AbstractLocale<S extends object = LocaleStructure> implements LocaleProvider<S> {
|
|
3
3
|
abstract lang(): Language;
|
|
4
4
|
abstract keys(): Set<keyof S>;
|
|
5
|
-
abstract
|
|
5
|
+
abstract langs(): ReadonlySet<Language>;
|
|
6
6
|
/** Returns native names for this provider's languages, preserving their order. */
|
|
7
|
-
|
|
7
|
+
langNames(): ReadonlyMap<Language, string>;
|
|
8
8
|
protected abstract value(key: keyof S & string): string | undefined;
|
|
9
9
|
trans<K extends LocaleNonPluralKeys<S>>(key: K, ...args: LocaleSubstitutionArgs<S, K>): string;
|
|
10
10
|
choice<K extends LocalePluralKeys<S>>(key: K, count: number, ...args: LocaleSubstitutionArgs<S, K>): string;
|
|
11
11
|
get<K extends keyof S & string>(key: K, substitutions?: Record<string, LocaleSubstitutionValue>): string;
|
|
12
|
-
private
|
|
12
|
+
private substitute;
|
|
13
13
|
}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
+
import { selectPluralForm, applySubstitutions } from "./../../shared/locale/index.js";
|
|
1
2
|
import {
|
|
2
|
-
|
|
3
|
-
LanguageNames,
|
|
4
|
-
LocaleValuesSeparator
|
|
3
|
+
LanguageNames
|
|
5
4
|
} from "./../../types/locale.js";
|
|
6
|
-
class
|
|
5
|
+
class AbstractLocale {
|
|
7
6
|
/** Returns native names for this provider's languages, preserving their order. */
|
|
8
|
-
|
|
9
|
-
return new Map([...this.
|
|
7
|
+
langNames() {
|
|
8
|
+
return new Map([...this.langs()].map((language) => [language, LanguageNames[language]]));
|
|
10
9
|
}
|
|
11
10
|
trans(key, ...args) {
|
|
12
11
|
const [substitutions] = args;
|
|
@@ -14,9 +13,8 @@ class AbstractLocale_default {
|
|
|
14
13
|
}
|
|
15
14
|
choice(key, count, ...args) {
|
|
16
15
|
const [substitutions] = args;
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
return parts[idx] ?? parts[0] ?? key;
|
|
16
|
+
const message = selectPluralForm(this.get(key), this.lang(), count);
|
|
17
|
+
return this.substitute(message, key, substitutions);
|
|
20
18
|
}
|
|
21
19
|
get(key, substitutions) {
|
|
22
20
|
const template = this.value(key);
|
|
@@ -24,94 +22,15 @@ class AbstractLocale_default {
|
|
|
24
22
|
console.warn(`Locale key "${key}" not found in "${this.lang()}" language.`);
|
|
25
23
|
return key;
|
|
26
24
|
}
|
|
27
|
-
|
|
28
|
-
return template.replace(/{{(.*?)}}/g, (_, placeholder) => {
|
|
29
|
-
const substitution = placeholder.trim();
|
|
30
|
-
if (substitution in substitutions) {
|
|
31
|
-
return substitutions[substitution].toString();
|
|
32
|
-
}
|
|
33
|
-
console.warn(
|
|
34
|
-
`Locale substitution "${substitution}" not found for key "${key}" in "${this.lang()}" language.`
|
|
35
|
-
);
|
|
36
|
-
return substitution;
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
return template;
|
|
25
|
+
return this.substitute(template, key, substitutions);
|
|
40
26
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
case Language.Kannada:
|
|
46
|
-
case Language.Korean:
|
|
47
|
-
case Language.Malay:
|
|
48
|
-
case Language.Thai:
|
|
49
|
-
case Language.Turkish:
|
|
50
|
-
case Language.Vietnamese:
|
|
51
|
-
return 0;
|
|
52
|
-
case Language.Bengali:
|
|
53
|
-
case Language.Bulgarian:
|
|
54
|
-
case Language.Catalan:
|
|
55
|
-
case Language.Danish:
|
|
56
|
-
case Language.German:
|
|
57
|
-
case Language.Greek:
|
|
58
|
-
case Language.English:
|
|
59
|
-
case Language.EnglishAustralia:
|
|
60
|
-
case Language.EnglishGreatBritain:
|
|
61
|
-
case Language.EnglishUSA:
|
|
62
|
-
case Language.Spanish:
|
|
63
|
-
case Language.SpanishLatinAmericaAndCaribbean:
|
|
64
|
-
case Language.Estonian:
|
|
65
|
-
case Language.Persian:
|
|
66
|
-
case Language.Finnish:
|
|
67
|
-
case Language.Gujarati:
|
|
68
|
-
case Language.Hebrew:
|
|
69
|
-
case Language.Hungarian:
|
|
70
|
-
case Language.Italian:
|
|
71
|
-
case Language.Malayalam:
|
|
72
|
-
case Language.Marathi:
|
|
73
|
-
case Language.Dutch:
|
|
74
|
-
case Language.Norwegian:
|
|
75
|
-
case Language.Swedish:
|
|
76
|
-
case Language.Swahili:
|
|
77
|
-
case Language.Tamil:
|
|
78
|
-
case Language.Telugu:
|
|
79
|
-
case Language.ChineseChina:
|
|
80
|
-
case Language.ChineseTaiwan:
|
|
81
|
-
case Language.PortugueseBrazil:
|
|
82
|
-
case Language.PortuguesePortugal:
|
|
83
|
-
return count == 1 ? 0 : 1;
|
|
84
|
-
case Language.Amharic:
|
|
85
|
-
case Language.Filipino:
|
|
86
|
-
case Language.French:
|
|
87
|
-
case Language.Hindi:
|
|
88
|
-
return count == 0 || count == 1 ? 0 : 1;
|
|
89
|
-
case Language.Croatian:
|
|
90
|
-
case Language.Russian:
|
|
91
|
-
case Language.Serbian:
|
|
92
|
-
case Language.Ukrainian:
|
|
93
|
-
return count % 10 == 1 && count % 100 != 11 ? 0 : count % 10 >= 2 && count % 10 <= 4 && (count % 100 < 10 || count % 100 >= 20) ? 1 : 2;
|
|
94
|
-
case Language.Czech:
|
|
95
|
-
case Language.Slovak:
|
|
96
|
-
return count == 1 ? 0 : count >= 2 && count <= 4 ? 1 : 2;
|
|
97
|
-
case Language.Lithuanian:
|
|
98
|
-
return count % 10 == 1 && count % 100 != 11 ? 0 : count % 10 >= 2 && (count % 100 < 10 || count % 100 >= 20) ? 1 : 2;
|
|
99
|
-
case Language.Slovenian:
|
|
100
|
-
return count % 100 == 1 ? 0 : count % 100 == 2 ? 1 : count % 100 == 3 || count % 100 == 4 ? 2 : 3;
|
|
101
|
-
case Language.Latvian:
|
|
102
|
-
return count == 0 ? 0 : count % 10 == 1 && count % 100 != 11 ? 1 : 2;
|
|
103
|
-
case Language.Polish:
|
|
104
|
-
return count == 1 ? 0 : count % 10 >= 2 && count % 10 <= 4 && (count % 100 < 12 || count % 100 > 14) ? 1 : 2;
|
|
105
|
-
case Language.Romanian:
|
|
106
|
-
return count == 1 ? 0 : count == 0 || count % 100 > 0 && count % 100 < 20 ? 1 : 2;
|
|
107
|
-
case Language.Arabic:
|
|
108
|
-
return count == 0 ? 0 : count == 1 ? 1 : count == 2 ? 2 : count % 100 >= 3 && count % 100 <= 10 ? 3 : count % 100 >= 11 && count % 100 <= 99 ? 4 : 5;
|
|
109
|
-
default:
|
|
110
|
-
return 0;
|
|
111
|
-
}
|
|
27
|
+
substitute(message, key, substitutions) {
|
|
28
|
+
return applySubstitutions(message, substitutions, (name) => {
|
|
29
|
+
console.warn(`Locale substitution "${name}" not found for key "${key}" in "${this.lang()}" language.`);
|
|
30
|
+
}).join("");
|
|
112
31
|
}
|
|
113
32
|
}
|
|
114
33
|
export {
|
|
115
|
-
|
|
34
|
+
AbstractLocale as default
|
|
116
35
|
};
|
|
117
36
|
//# sourceMappingURL=AbstractLocale.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/locale/providers/AbstractLocale.ts"],"sourcesContent":["import {\n Language,\n LanguageNames,\n LocaleNonPluralKeys,\n LocalePluralKeys,\n LocaleProvider,\n LocaleStructure,\n LocaleSubstitutionArgs,\n LocaleSubstitutionValue,\n
|
|
1
|
+
{"version":3,"sources":["../../../src/locale/providers/AbstractLocale.ts"],"sourcesContent":["import {selectPluralForm, applySubstitutions} from \"@shared/locale\";\n\nimport {\n Language,\n LanguageNames,\n LocaleNonPluralKeys,\n LocalePluralKeys,\n LocaleProvider,\n LocaleStructure,\n LocaleSubstitutionArgs,\n LocaleSubstitutionValue,\n} from \"@typing/locale\";\n\nexport default abstract class AbstractLocale<S extends object = LocaleStructure> implements LocaleProvider<S> {\n public abstract lang(): Language;\n\n public abstract keys(): Set<keyof S>;\n\n public abstract langs(): ReadonlySet<Language>;\n\n /** Returns native names for this provider's languages, preserving their order. */\n public langNames(): ReadonlyMap<Language, string> {\n return new Map([...this.langs()].map(language => [language, LanguageNames[language]]));\n }\n\n protected abstract value(key: keyof S & string): string | undefined;\n\n public trans<K extends LocaleNonPluralKeys<S>>(key: K, ...args: LocaleSubstitutionArgs<S, K>): string {\n const [substitutions] = args;\n\n return this.get(key, substitutions);\n }\n\n public choice<K extends LocalePluralKeys<S>>(key: K, count: number, ...args: LocaleSubstitutionArgs<S, K>): string {\n const [substitutions] = args;\n const message = selectPluralForm(this.get(key), this.lang(), count);\n\n return this.substitute(message, key, substitutions);\n }\n\n public get<K extends keyof S & string>(key: K, substitutions?: Record<string, LocaleSubstitutionValue>): string {\n const template = this.value(key);\n\n if (template === undefined) {\n console.warn(`Locale key \"${key}\" not found in \"${this.lang()}\" language.`);\n\n return key as string;\n }\n\n return this.substitute(template, key, substitutions);\n }\n\n private substitute(message: string, key: string, substitutions?: Record<string, LocaleSubstitutionValue>): string {\n return applySubstitutions(message, substitutions, name => {\n console.warn(`Locale substitution \"${name}\" not found for key \"${key}\" in \"${this.lang()}\" language.`);\n }).join(\"\");\n }\n}\n"],"mappings":"AAAA,SAAQ,kBAAkB,0BAAyB;AAEnD;AAAA,EAEI;AAAA,OAOG;AAEP,MAAO,eAAuG;AAAA;AAAA,EAQnG,YAA2C;AAC9C,WAAO,IAAI,IAAI,CAAC,GAAG,KAAK,MAAM,CAAC,EAAE,IAAI,cAAY,CAAC,UAAU,cAAc,QAAQ,CAAC,CAAC,CAAC;AAAA,EACzF;AAAA,EAIO,MAAwC,QAAW,MAA4C;AAClG,UAAM,CAAC,aAAa,IAAI;AAExB,WAAO,KAAK,IAAI,KAAK,aAAa;AAAA,EACtC;AAAA,EAEO,OAAsC,KAAQ,UAAkB,MAA4C;AAC/G,UAAM,CAAC,aAAa,IAAI;AACxB,UAAM,UAAU,iBAAiB,KAAK,IAAI,GAAG,GAAG,KAAK,KAAK,GAAG,KAAK;AAElE,WAAO,KAAK,WAAW,SAAS,KAAK,aAAa;AAAA,EACtD;AAAA,EAEO,IAAgC,KAAQ,eAAiE;AAC5G,UAAM,WAAW,KAAK,MAAM,GAAG;AAE/B,QAAI,aAAa,QAAW;AACxB,cAAQ,KAAK,eAAe,GAAG,mBAAmB,KAAK,KAAK,CAAC,aAAa;AAE1E,aAAO;AAAA,IACX;AAEA,WAAO,KAAK,WAAW,UAAU,KAAK,aAAa;AAAA,EACvD;AAAA,EAEQ,WAAW,SAAiB,KAAa,eAAiE;AAC9G,WAAO,mBAAmB,SAAS,eAAe,UAAQ;AACtD,cAAQ,KAAK,wBAAwB,IAAI,wBAAwB,GAAG,SAAS,KAAK,KAAK,CAAC,aAAa;AAAA,IACzG,CAAC,EAAE,KAAK,EAAE;AAAA,EACd;AACJ;","names":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import AbstractLocale from "./AbstractLocale.js";
|
|
2
2
|
import { Language, LocaleStructure } from "../../types/locale.js";
|
|
3
|
-
export type CustomLocaleData = Record<string, string
|
|
4
|
-
export default class<T extends object = LocaleStructure> extends AbstractLocale<T> {
|
|
3
|
+
export type CustomLocaleData = Readonly<Record<string, string>>;
|
|
4
|
+
export default class CustomLocale<T extends object = LocaleStructure> extends AbstractLocale<T> {
|
|
5
5
|
protected language: Language;
|
|
6
6
|
protected data: CustomLocaleData;
|
|
7
7
|
constructor(language?: Language, data?: CustomLocaleData);
|
|
@@ -9,6 +9,6 @@ export default class<T extends object = LocaleStructure> extends AbstractLocale<
|
|
|
9
9
|
setData(data: CustomLocaleData): this;
|
|
10
10
|
lang(): Language;
|
|
11
11
|
keys(): Set<keyof T>;
|
|
12
|
-
|
|
12
|
+
langs(): ReadonlySet<Language>;
|
|
13
13
|
protected value(key: string): string | undefined;
|
|
14
14
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { convertLocaleKey } from "
|
|
1
|
+
import { convertLocaleKey } from "./../../shared/locale/index.js";
|
|
2
2
|
import AbstractLocale from "./AbstractLocale.js";
|
|
3
3
|
import { Language } from "./../../types/locale.js";
|
|
4
|
-
class
|
|
4
|
+
class CustomLocale extends AbstractLocale {
|
|
5
5
|
constructor(language = Language.English, data = {}) {
|
|
6
6
|
super();
|
|
7
7
|
this.language = language;
|
|
@@ -23,11 +23,12 @@ class CustomLocale_default extends AbstractLocale {
|
|
|
23
23
|
keys() {
|
|
24
24
|
return new Set(Object.keys(this.data));
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
langs() {
|
|
27
27
|
return /* @__PURE__ */ new Set([this.lang()]);
|
|
28
28
|
}
|
|
29
29
|
value(key) {
|
|
30
|
-
const
|
|
30
|
+
const name = convertLocaleKey(key);
|
|
31
|
+
const value = Object.hasOwn(this.data, name) ? this.data[name] : void 0;
|
|
31
32
|
if (value === void 0) {
|
|
32
33
|
return void 0;
|
|
33
34
|
}
|
|
@@ -35,6 +36,6 @@ class CustomLocale_default extends AbstractLocale {
|
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
38
|
export {
|
|
38
|
-
|
|
39
|
+
CustomLocale as default
|
|
39
40
|
};
|
|
40
41
|
//# sourceMappingURL=CustomLocale.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/locale/providers/CustomLocale.ts"],"sourcesContent":["import {convertLocaleKey} from \"
|
|
1
|
+
{"version":3,"sources":["../../../src/locale/providers/CustomLocale.ts"],"sourcesContent":["import {convertLocaleKey} from \"@shared/locale\";\n\nimport AbstractLocale from \"./AbstractLocale\";\n\nimport {Language, LocaleStructure} from \"@typing/locale\";\n\nexport type CustomLocaleData = Readonly<Record<string, string>>;\n\nexport default class CustomLocale<T extends object = LocaleStructure> extends AbstractLocale<T> {\n constructor(\n protected language: Language = Language.English,\n protected data: CustomLocaleData = {}\n ) {\n super();\n }\n\n public setLang(lang: Language): this {\n this.language = lang;\n\n return this;\n }\n\n public setData(data: CustomLocaleData): this {\n this.data = data;\n\n return this;\n }\n\n public lang(): Language {\n return this.language;\n }\n\n public keys(): Set<keyof T> {\n return new Set(Object.keys(this.data)) as Set<keyof T>;\n }\n\n public langs(): ReadonlySet<Language> {\n return new Set([this.lang()]);\n }\n\n protected value(key: string): string | undefined {\n const name = convertLocaleKey(key);\n const value = Object.hasOwn(this.data, name) ? this.data[name] : undefined;\n\n if (value === undefined) {\n return undefined;\n }\n\n return value;\n }\n}\n"],"mappings":"AAAA,SAAQ,wBAAuB;AAE/B,OAAO,oBAAoB;AAE3B,SAAQ,gBAAgC;AAIxC,MAAO,qBAAuE,eAAkB;AAAA,EAC5F,YACc,WAAqB,SAAS,SAC9B,OAAyB,CAAC,GACtC;AACE,UAAM;AAHI;AACA;AAAA,EAGd;AAAA,EAJc;AAAA,EACA;AAAA,EAKP,QAAQ,MAAsB;AACjC,SAAK,WAAW;AAEhB,WAAO;AAAA,EACX;AAAA,EAEO,QAAQ,MAA8B;AACzC,SAAK,OAAO;AAEZ,WAAO;AAAA,EACX;AAAA,EAEO,OAAiB;AACpB,WAAO,KAAK;AAAA,EAChB;AAAA,EAEO,OAAqB;AACxB,WAAO,IAAI,IAAI,OAAO,KAAK,KAAK,IAAI,CAAC;AAAA,EACzC;AAAA,EAEO,QAA+B;AAClC,WAAO,oBAAI,IAAI,CAAC,KAAK,KAAK,CAAC,CAAC;AAAA,EAChC;AAAA,EAEU,MAAM,KAAiC;AAC7C,UAAM,OAAO,iBAAiB,GAAG;AACjC,UAAM,QAAQ,OAAO,OAAO,KAAK,MAAM,IAAI,IAAI,KAAK,KAAK,IAAI,IAAI;AAEjE,QAAI,UAAU,QAAW;AACrB,aAAO;AAAA,IACX;AAEA,WAAO;AAAA,EACX;AACJ;","names":[]}
|
|
@@ -1,19 +1,26 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
protected
|
|
7
|
-
protected locale?: CustomLocale<T>;
|
|
8
|
-
protected storage?: StorageProvider<Record<string, Language>>;
|
|
9
|
-
protected storageKey?: string;
|
|
1
|
+
import AbstractLocale from "./AbstractLocale.js";
|
|
2
|
+
import { Language, type LocaleDynamicProvider, type LocaleRegistry, type LocaleStorageDriver } from "../../types/locale.js";
|
|
3
|
+
export default class DynamicLocale<T extends object = LocaleRegistry> extends AbstractLocale<T> implements LocaleDynamicProvider<T> {
|
|
4
|
+
private language;
|
|
5
|
+
private data;
|
|
6
|
+
protected storage?: LocaleStorageDriver;
|
|
10
7
|
protected unsubscribe?: () => void;
|
|
11
|
-
constructor(storage?:
|
|
8
|
+
constructor(storage?: LocaleStorageDriver | false);
|
|
9
|
+
/**
|
|
10
|
+
* Selects a language synchronously without saving it.
|
|
11
|
+
* With storage enabled, a later sync() or watched storage update can replace this local selection.
|
|
12
|
+
* @throws If the language is absent from the catalogue.
|
|
13
|
+
*/
|
|
14
|
+
select(lang: Language): Language;
|
|
15
|
+
/** Selects a language immediately and saves it when storage is enabled. */
|
|
12
16
|
change(lang: Language): Promise<Language>;
|
|
13
17
|
sync(): Promise<Language>;
|
|
14
18
|
watch(handler?: (lang: Language) => void): () => void;
|
|
15
19
|
unwatch(): void;
|
|
16
20
|
lang(): Language;
|
|
21
|
+
/** Completed messages for the current language, with underscore keys and no substitutions applied. */
|
|
22
|
+
messages(): Readonly<Record<string, string>>;
|
|
23
|
+
keys(): Set<keyof T>;
|
|
24
|
+
langs(): ReadonlySet<Language>;
|
|
17
25
|
protected value(key: Extract<keyof T, string>): string | undefined;
|
|
18
|
-
protected fetch(lang: Language): Promise<CustomLocaleData>;
|
|
19
26
|
}
|
|
@@ -1,58 +1,74 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { getI18nMessage } from "@addon-core/browser";
|
|
2
|
+
import catalogue, { keys, lang as defaultLanguage, languages } from "#adnbn/locale";
|
|
3
|
+
import AbstractLocale from "./AbstractLocale.js";
|
|
4
|
+
import { LocaleStorage } from "../storage/index.js";
|
|
5
|
+
import { convertLocaleKey, resolveLanguage } from "./../../shared/locale/index.js";
|
|
6
|
+
import {
|
|
7
|
+
LocaleCustomKeyForLanguage
|
|
8
|
+
} from "./../../types/locale.js";
|
|
9
|
+
class DynamicLocale extends AbstractLocale {
|
|
10
|
+
language;
|
|
11
|
+
data;
|
|
9
12
|
storage;
|
|
10
|
-
storageKey;
|
|
11
13
|
unsubscribe;
|
|
12
|
-
constructor(storage
|
|
14
|
+
constructor(storage) {
|
|
13
15
|
super();
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
let marker;
|
|
17
|
+
try {
|
|
18
|
+
marker = getI18nMessage(LocaleCustomKeyForLanguage);
|
|
19
|
+
} catch {
|
|
17
20
|
}
|
|
21
|
+
this.select(resolveLanguage(marker) ?? defaultLanguage);
|
|
22
|
+
this.storage = storage === false ? void 0 : storage ?? new LocaleStorage();
|
|
18
23
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Selects a language synchronously without saving it.
|
|
26
|
+
* With storage enabled, a later sync() or watched storage update can replace this local selection.
|
|
27
|
+
* @throws If the language is absent from the catalogue.
|
|
28
|
+
*/
|
|
29
|
+
select(lang) {
|
|
30
|
+
if (!Object.hasOwn(catalogue, lang)) {
|
|
31
|
+
throw new Error(`[DynamicLocale] Language "${lang}" is not available in the catalogue.`);
|
|
22
32
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
33
|
+
this.language = lang;
|
|
34
|
+
this.data = catalogue[lang];
|
|
35
|
+
return lang;
|
|
36
|
+
}
|
|
37
|
+
/** Selects a language immediately and saves it when storage is enabled. */
|
|
38
|
+
async change(lang) {
|
|
39
|
+
this.select(lang);
|
|
40
|
+
if (this.storage) {
|
|
41
|
+
await this.storage.set(lang);
|
|
27
42
|
}
|
|
28
43
|
return lang;
|
|
29
44
|
}
|
|
30
45
|
async sync() {
|
|
31
|
-
if (!this.storage
|
|
46
|
+
if (!this.storage) {
|
|
32
47
|
throw new Error("Language is not saving in storage");
|
|
33
48
|
}
|
|
34
|
-
const lang = await this.storage.get(
|
|
49
|
+
const lang = await this.storage.get();
|
|
35
50
|
if (!lang) {
|
|
36
51
|
return this.lang();
|
|
37
52
|
}
|
|
38
|
-
if (!
|
|
53
|
+
if (!Object.hasOwn(catalogue, lang)) {
|
|
39
54
|
console.warn(`Incorrect language code in storage - "${lang}"`);
|
|
40
55
|
return this.lang();
|
|
41
56
|
}
|
|
42
|
-
return this.
|
|
57
|
+
return this.select(lang);
|
|
43
58
|
}
|
|
44
59
|
watch(handler) {
|
|
45
|
-
if (!this.storage
|
|
60
|
+
if (!this.storage) {
|
|
46
61
|
throw new Error("Language is not saved in storage");
|
|
47
62
|
}
|
|
48
63
|
if (this.unsubscribe) {
|
|
49
64
|
throw new Error("Already subscribed to language changes in storage");
|
|
50
65
|
}
|
|
51
|
-
this.unsubscribe = this.storage.watch({
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
66
|
+
this.unsubscribe = this.storage.watch((lang) => {
|
|
67
|
+
try {
|
|
68
|
+
this.select(lang);
|
|
69
|
+
handler == null ? void 0 : handler(lang);
|
|
70
|
+
} catch (error) {
|
|
71
|
+
console.error("Error while changing language:", error);
|
|
56
72
|
}
|
|
57
73
|
});
|
|
58
74
|
return this.unwatch.bind(this);
|
|
@@ -63,27 +79,24 @@ class DynamicLocale_default extends NativeLocale {
|
|
|
63
79
|
this.unsubscribe = void 0;
|
|
64
80
|
}
|
|
65
81
|
lang() {
|
|
66
|
-
|
|
67
|
-
return ((_a = this.locale) == null ? void 0 : _a.lang()) || super.lang();
|
|
82
|
+
return this.language;
|
|
68
83
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
return
|
|
84
|
+
/** Completed messages for the current language, with underscore keys and no substitutions applied. */
|
|
85
|
+
messages() {
|
|
86
|
+
return this.data;
|
|
72
87
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
return messages;
|
|
88
|
+
keys() {
|
|
89
|
+
return new Set(keys);
|
|
90
|
+
}
|
|
91
|
+
langs() {
|
|
92
|
+
return new Set(languages);
|
|
93
|
+
}
|
|
94
|
+
value(key) {
|
|
95
|
+
const name = convertLocaleKey(key);
|
|
96
|
+
return Object.hasOwn(this.data, name) ? this.data[name] : void 0;
|
|
84
97
|
}
|
|
85
98
|
}
|
|
86
99
|
export {
|
|
87
|
-
|
|
100
|
+
DynamicLocale as default
|
|
88
101
|
};
|
|
89
102
|
//# sourceMappingURL=DynamicLocale.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/locale/providers/DynamicLocale.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../src/locale/providers/DynamicLocale.ts"],"sourcesContent":["import {getI18nMessage} from \"@addon-core/browser\";\n\nimport catalogue, {keys, lang as defaultLanguage, languages} from \"#adnbn/locale\";\n\nimport AbstractLocale from \"./AbstractLocale\";\nimport {LocaleStorage} from \"../storage\";\n\nimport {convertLocaleKey, resolveLanguage} from \"@shared/locale\";\nimport {\n Language,\n LocaleCustomKeyForLanguage,\n type LocaleDynamicProvider,\n type LocaleRegistry,\n type LocaleStorageDriver,\n} from \"@typing/locale\";\n\nexport default class DynamicLocale<T extends object = LocaleRegistry>\n extends AbstractLocale<T>\n implements LocaleDynamicProvider<T>\n{\n private language!: Language;\n private data!: Readonly<Record<string, string>>;\n\n protected storage?: LocaleStorageDriver;\n protected unsubscribe?: () => void;\n\n constructor(storage?: LocaleStorageDriver | false) {\n super();\n\n let marker: string | undefined;\n\n try {\n marker = getI18nMessage(LocaleCustomKeyForLanguage);\n } catch {\n // MAIN has no extension i18n; use the configured language from the bundled catalogue.\n }\n\n this.select(resolveLanguage(marker) ?? defaultLanguage);\n\n this.storage = storage === false ? undefined : (storage ?? new LocaleStorage());\n }\n\n /**\n * Selects a language synchronously without saving it.\n * With storage enabled, a later sync() or watched storage update can replace this local selection.\n * @throws If the language is absent from the catalogue.\n */\n public select(lang: Language): Language {\n if (!Object.hasOwn(catalogue, lang)) {\n throw new Error(`[DynamicLocale] Language \"${lang}\" is not available in the catalogue.`);\n }\n\n this.language = lang;\n this.data = catalogue[lang]!;\n\n return lang;\n }\n\n /** Selects a language immediately and saves it when storage is enabled. */\n public async change(lang: Language): Promise<Language> {\n this.select(lang);\n\n if (this.storage) {\n await this.storage.set(lang);\n }\n\n return lang;\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 const lang = await this.storage.get();\n\n if (!lang) {\n return this.lang();\n }\n\n if (!Object.hasOwn(catalogue, lang)) {\n console.warn(`Incorrect language code in storage - \"${lang}\"`);\n\n return this.lang();\n }\n\n return this.select(lang);\n }\n\n public watch(handler?: (lang: Language) => void): () => void {\n if (!this.storage) {\n throw new Error(\"Language is not saved in storage\");\n }\n\n if (this.unsubscribe) {\n throw new Error(\"Already subscribed to language changes in storage\");\n }\n\n this.unsubscribe = this.storage.watch(lang => {\n try {\n this.select(lang);\n handler?.(lang);\n } catch (error) {\n console.error(\"Error while changing language:\", error);\n }\n });\n\n return this.unwatch.bind(this);\n }\n\n public unwatch(): void {\n this.unsubscribe?.();\n this.unsubscribe = undefined;\n }\n\n public lang(): Language {\n return this.language;\n }\n\n /** Completed messages for the current language, with underscore keys and no substitutions applied. */\n public messages(): Readonly<Record<string, string>> {\n return this.data;\n }\n\n public keys(): Set<keyof T> {\n return new Set(keys) as Set<keyof T>;\n }\n\n public langs(): ReadonlySet<Language> {\n return new Set(languages);\n }\n\n protected value(key: Extract<keyof T, string>): string | undefined {\n const name = convertLocaleKey(key);\n\n return Object.hasOwn(this.data, name) ? this.data[name] : undefined;\n }\n}\n"],"mappings":"AAAA,SAAQ,sBAAqB;AAE7B,OAAO,aAAY,MAAM,QAAQ,iBAAiB,iBAAgB;AAElE,OAAO,oBAAoB;AAC3B,SAAQ,qBAAoB;AAE5B,SAAQ,kBAAkB,uBAAsB;AAChD;AAAA,EAEI;AAAA,OAIG;AAEP,MAAO,sBACK,eAEZ;AAAA,EACY;AAAA,EACA;AAAA,EAEE;AAAA,EACA;AAAA,EAEV,YAAY,SAAuC;AAC/C,UAAM;AAEN,QAAI;AAEJ,QAAI;AACA,eAAS,eAAe,0BAA0B;AAAA,IACtD,QAAQ;AAAA,IAER;AAEA,SAAK,OAAO,gBAAgB,MAAM,KAAK,eAAe;AAEtD,SAAK,UAAU,YAAY,QAAQ,SAAa,WAAW,IAAI,cAAc;AAAA,EACjF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOO,OAAO,MAA0B;AACpC,QAAI,CAAC,OAAO,OAAO,WAAW,IAAI,GAAG;AACjC,YAAM,IAAI,MAAM,6BAA6B,IAAI,sCAAsC;AAAA,IAC3F;AAEA,SAAK,WAAW;AAChB,SAAK,OAAO,UAAU,IAAI;AAE1B,WAAO;AAAA,EACX;AAAA;AAAA,EAGA,MAAa,OAAO,MAAmC;AACnD,SAAK,OAAO,IAAI;AAEhB,QAAI,KAAK,SAAS;AACd,YAAM,KAAK,QAAQ,IAAI,IAAI;AAAA,IAC/B;AAEA,WAAO;AAAA,EACX;AAAA,EAEA,MAAa,OAA0B;AACnC,QAAI,CAAC,KAAK,SAAS;AACf,YAAM,IAAI,MAAM,mCAAmC;AAAA,IACvD;AAEA,UAAM,OAAO,MAAM,KAAK,QAAQ,IAAI;AAEpC,QAAI,CAAC,MAAM;AACP,aAAO,KAAK,KAAK;AAAA,IACrB;AAEA,QAAI,CAAC,OAAO,OAAO,WAAW,IAAI,GAAG;AACjC,cAAQ,KAAK,yCAAyC,IAAI,GAAG;AAE7D,aAAO,KAAK,KAAK;AAAA,IACrB;AAEA,WAAO,KAAK,OAAO,IAAI;AAAA,EAC3B;AAAA,EAEO,MAAM,SAAgD;AACzD,QAAI,CAAC,KAAK,SAAS;AACf,YAAM,IAAI,MAAM,kCAAkC;AAAA,IACtD;AAEA,QAAI,KAAK,aAAa;AAClB,YAAM,IAAI,MAAM,mDAAmD;AAAA,IACvE;AAEA,SAAK,cAAc,KAAK,QAAQ,MAAM,UAAQ;AAC1C,UAAI;AACA,aAAK,OAAO,IAAI;AAChB,2CAAU;AAAA,MACd,SAAS,OAAO;AACZ,gBAAQ,MAAM,kCAAkC,KAAK;AAAA,MACzD;AAAA,IACJ,CAAC;AAED,WAAO,KAAK,QAAQ,KAAK,IAAI;AAAA,EACjC;AAAA,EAEO,UAAgB;AA9G3B;AA+GQ,eAAK,gBAAL;AACA,SAAK,cAAc;AAAA,EACvB;AAAA,EAEO,OAAiB;AACpB,WAAO,KAAK;AAAA,EAChB;AAAA;AAAA,EAGO,WAA6C;AAChD,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,OAAO,iBAAiB,GAAG;AAEjC,WAAO,OAAO,OAAO,KAAK,MAAM,IAAI,IAAI,KAAK,KAAK,IAAI,IAAI;AAAA,EAC9D;AACJ;","names":[]}
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import AbstractLocale from "./AbstractLocale.js";
|
|
2
|
-
import { Language,
|
|
3
|
-
|
|
4
|
-
export interface LocaleNativeStructure {
|
|
5
|
-
}
|
|
6
|
-
export default class NativeLocale<S extends object = LocaleNativeStructure> extends AbstractLocale<S> {
|
|
2
|
+
import { Language, type LocaleRegistry } from "../../types/locale.js";
|
|
3
|
+
export default class NativeLocale<S extends object = LocaleRegistry> extends AbstractLocale<S> {
|
|
7
4
|
private static instance?;
|
|
8
|
-
static getInstance():
|
|
5
|
+
static getInstance(): NativeLocale<LocaleRegistry>;
|
|
9
6
|
private readonly language?;
|
|
10
7
|
constructor();
|
|
11
8
|
lang(): Language;
|
|
12
9
|
keys(): Set<keyof S>;
|
|
13
|
-
|
|
10
|
+
langs(): ReadonlySet<Language>;
|
|
14
11
|
protected value(key: Extract<keyof S, string>): string | undefined;
|
|
15
12
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getI18nMessage } from "@addon-core/browser";
|
|
2
|
+
import { keys, languages } from "#adnbn/locale";
|
|
2
3
|
import AbstractLocale from "./AbstractLocale.js";
|
|
3
|
-
import { convertLocaleKey, resolveLanguage } from "./../../locale/
|
|
4
|
+
import { convertLocaleKey, resolveLanguage } from "./../../shared/locale/index.js";
|
|
4
5
|
import { LocaleCustomKeyForLanguage } from "./../../types/locale.js";
|
|
5
6
|
class NativeLocale extends AbstractLocale {
|
|
6
7
|
static instance;
|
|
@@ -27,20 +28,10 @@ class NativeLocale extends AbstractLocale {
|
|
|
27
28
|
return this.language;
|
|
28
29
|
}
|
|
29
30
|
keys() {
|
|
30
|
-
|
|
31
|
-
return new Set(__ADNBN_LOCALE_KEYS__);
|
|
32
|
-
} catch (e) {
|
|
33
|
-
console.error("[NativeLocale] Failed to access locale keys. Ensure the bundler plugin is active.", e);
|
|
34
|
-
return /* @__PURE__ */ new Set();
|
|
35
|
-
}
|
|
31
|
+
return new Set(keys);
|
|
36
32
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return new Set(__ADNBN_DEFINED_LOCALES__);
|
|
40
|
-
} catch (e) {
|
|
41
|
-
console.error("[NativeLocale] Failed to access defined locales. Check virtual variables configuration.", e);
|
|
42
|
-
return /* @__PURE__ */ new Set();
|
|
43
|
-
}
|
|
33
|
+
langs() {
|
|
34
|
+
return new Set(languages);
|
|
44
35
|
}
|
|
45
36
|
value(key) {
|
|
46
37
|
const value = getI18nMessage(convertLocaleKey(key));
|