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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/entry/content/core/nodes/FrameNode.ts"],"sourcesContent":["import type {ContentScriptIsolationFrameOptions, ContentScriptNode, ContentScriptStylesRuntime} from \"@typing/content\";\nimport {ContentScriptIsolation} from \"@typing/content\";\nimport {getPageUrl} from \"@main/page\";\n\nimport {getContentScriptStylesRuntime} from \"./isolated-styles\";\n\nimport {isContentScriptFrameNavigation} from \"@shared/content\";\n\n/** Owns the child document, but never moves the content script's JavaScript into it. */\nexport default class FrameNode implements ContentScriptNode {\n private frame?: HTMLIFrameElement;\n private head?: HTMLHeadElement;\n private _target?: Element;\n private runtime?: ContentScriptStylesRuntime;\n private generation = 0;\n private queued = false;\n\n public constructor(\n private readonly node: ContentScriptNode,\n private readonly options: ContentScriptIsolationFrameOptions = {type: ContentScriptIsolation.Iframe},\n private readonly recover: () => void\n ) {}\n\n public get anchor(): Element {\n return this.node.anchor;\n }\n\n public get container(): Element | undefined {\n return this.node.container;\n }\n\n public get target(): Element | undefined {\n return this._target;\n }\n\n private readonly onLoad = (): void => {\n if (!this.frame || this.queued || this.intact()) {\n return;\n }\n\n const generation = this.generation;\n\n this.queued = true;\n\n queueMicrotask(() => {\n if (generation !== this.generation) {\n return;\n }\n\n this.queued = false;\n\n if (this.container?.isConnected && this.anchor.isConnected) {\n try {\n this.recover();\n } catch (error) {\n console.error(\"Restoring content iframe failed\", error);\n }\n }\n });\n };\n\n private intact(): boolean {\n const doc = this.frame?.contentDocument;\n\n return !!doc && this._target?.ownerDocument === doc && this._target.isConnected && this.head === doc.head;\n }\n\n public mount(): boolean {\n const mounted = !!this.node.mount();\n\n if (!this.container) {\n return mounted;\n }\n\n if (!isContentScriptFrameNavigation(this.options) && !this.container.isConnected) {\n throw new Error(\n \"Content iframe container is not connected to the document; mount must attach the container before returning\"\n );\n }\n\n let created = false;\n\n if (!this.frame) {\n const frame = this.container.ownerDocument.createElement(\"iframe\");\n\n frame.style.width = this.size(this.options.width ?? \"100%\");\n frame.style.height = this.size(this.options.height ?? 150);\n frame.style.border = \"0\";\n frame.style.display = \"block\";\n\n this.frame = frame;\n\n if (isContentScriptFrameNavigation(this.options)) {\n frame.src = this.options.page !== undefined ? getPageUrl(this.options.page) : this.options.src!;\n } else {\n frame.addEventListener(\"load\", this.onLoad);\n }\n\n this.container.append(frame);\n\n created = true;\n }\n\n if (isContentScriptFrameNavigation(this.options) || this.intact()) {\n return mounted || created;\n }\n\n const doc = this.frame.contentDocument;\n\n if (!doc?.head || !doc.body) {\n throw new Error(\n \"Content iframe has no accessible document; only an empty same-origin iframe can render UI\"\n );\n }\n\n const recovering = this.head !== undefined;\n\n this.releaseStyles();\n\n const target = doc.createElement(\"div\");\n\n doc.body.append(target);\n\n this._target = target;\n this.head = doc.head;\n this.runtime = getContentScriptStylesRuntime();\n this.runtime.add(doc.head, null, recovering);\n\n return true;\n }\n\n public unmount(): boolean {\n this.generation++;\n this.queued = false;\n this.frame?.removeEventListener(\"load\", this.onLoad);\n\n this.releaseStyles();\n\n this.frame = undefined;\n\n return !!this.node.unmount();\n }\n\n private releaseStyles(): void {\n if (this.head) {\n this.runtime?.delete(this.head);\n }\n\n this.head = undefined;\n this.runtime = undefined;\n this._target = undefined;\n }\n\n private size(value: number | string): string {\n return typeof value === \"number\" ? `${value}px` : value;\n }\n}\n"],"mappings":"AACA,SAAQ,8BAA6B;AACrC,SAAQ,kBAAiB;AAEzB,SAAQ,qCAAoC;AAE5C,SAAQ,sCAAqC;AAG7C,MAAO,UAAqD;AAAA,EAQjD,YACc,MACA,UAA8C,EAAC,MAAM,uBAAuB,OAAM,GAClF,SACnB;AAHmB;AACA;AACA;AAAA,EAClB;AAAA,EAHkB;AAAA,EACA;AAAA,EACA;AAAA,EAVb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb,SAAS;AAAA,EAQjB,IAAW,SAAkB;AACzB,WAAO,KAAK,KAAK;AAAA,EACrB;AAAA,EAEA,IAAW,YAAiC;AACxC,WAAO,KAAK,KAAK;AAAA,EACrB;AAAA,EAEA,IAAW,SAA8B;AACrC,WAAO,KAAK;AAAA,EAChB;AAAA,EAEiB,SAAS,MAAY;AAClC,QAAI,CAAC,KAAK,SAAS,KAAK,UAAU,KAAK,OAAO,GAAG;AAC7C;AAAA,IACJ;AAEA,UAAM,aAAa,KAAK;AAExB,SAAK,SAAS;AAEd,mBAAe,MAAM;AA5C7B;AA6CY,UAAI,eAAe,KAAK,YAAY;AAChC;AAAA,MACJ;AAEA,WAAK,SAAS;AAEd,YAAI,UAAK,cAAL,mBAAgB,gBAAe,KAAK,OAAO,aAAa;AACxD,YAAI;AACA,eAAK,QAAQ;AAAA,QACjB,SAAS,OAAO;AACZ,kBAAQ,MAAM,mCAAmC,KAAK;AAAA,QAC1D;AAAA,MACJ;AAAA,IACJ,CAAC;AAAA,EACL;AAAA,EAEQ,SAAkB;AA7D9B;AA8DQ,UAAM,OAAM,UAAK,UAAL,mBAAY;AAExB,WAAO,CAAC,CAAC,SAAO,UAAK,YAAL,mBAAc,mBAAkB,OAAO,KAAK,QAAQ,eAAe,KAAK,SAAS,IAAI;AAAA,EACzG;AAAA,EAEO,QAAiB;AACpB,UAAM,UAAU,CAAC,CAAC,KAAK,KAAK,MAAM;AAElC,QAAI,CAAC,KAAK,WAAW;AACjB,aAAO;AAAA,IACX;AAEA,QAAI,CAAC,+BAA+B,KAAK,OAAO,KAAK,CAAC,KAAK,UAAU,aAAa;AAC9E,YAAM,IAAI;AAAA,QACN;AAAA,MACJ;AAAA,IACJ;AAEA,QAAI,UAAU;AAEd,QAAI,CAAC,KAAK,OAAO;AACb,YAAM,QAAQ,KAAK,UAAU,cAAc,cAAc,QAAQ;AAEjE,YAAM,MAAM,QAAQ,KAAK,KAAK,KAAK,QAAQ,SAAS,MAAM;AAC1D,YAAM,MAAM,SAAS,KAAK,KAAK,KAAK,QAAQ,UAAU,GAAG;AACzD,YAAM,MAAM,SAAS;AACrB,YAAM,MAAM,UAAU;AAEtB,WAAK,QAAQ;AAEb,UAAI,+BAA+B,KAAK,OAAO,GAAG;AAC9C,cAAM,MAAM,KAAK,QAAQ,SAAS,SAAY,WAAW,KAAK,QAAQ,IAAI,IAAI,KAAK,QAAQ;AAAA,MAC/F,OAAO;AACH,cAAM,iBAAiB,QAAQ,KAAK,MAAM;AAAA,MAC9C;AAEA,WAAK,UAAU,OAAO,KAAK;AAE3B,gBAAU;AAAA,IACd;AAEA,QAAI,+BAA+B,KAAK,OAAO,KAAK,KAAK,OAAO,GAAG;AAC/D,aAAO,WAAW;AAAA,IACtB;AAEA,UAAM,MAAM,KAAK,MAAM;AAEvB,QAAI,EAAC,2BAAK,SAAQ,CAAC,IAAI,MAAM;AACzB,YAAM,IAAI;AAAA,QACN;AAAA,MACJ;AAAA,IACJ;AAEA,UAAM,aAAa,KAAK,SAAS;AAEjC,SAAK,cAAc;AAEnB,UAAM,SAAS,IAAI,cAAc,KAAK;AAEtC,QAAI,KAAK,OAAO,MAAM;AAEtB,SAAK,UAAU;AACf,SAAK,OAAO,IAAI;AAChB,SAAK,UAAU,8BAA8B;AAC7C,SAAK,QAAQ,IAAI,IAAI,MAAM,MAAM,UAAU;AAE3C,WAAO;AAAA,EACX;AAAA,EAEO,UAAmB;AAnI9B;AAoIQ,SAAK;AACL,SAAK,SAAS;AACd,eAAK,UAAL,mBAAY,oBAAoB,QAAQ,KAAK;AAE7C,SAAK,cAAc;AAEnB,SAAK,QAAQ;AAEb,WAAO,CAAC,CAAC,KAAK,KAAK,QAAQ;AAAA,EAC/B;AAAA,EAEQ,gBAAsB;AA/IlC;AAgJQ,QAAI,KAAK,MAAM;AACX,iBAAK,YAAL,mBAAc,OAAO,KAAK;AAAA,IAC9B;AAEA,SAAK,OAAO;AACZ,SAAK,UAAU;AACf,SAAK,UAAU;AAAA,EACnB;AAAA,EAEQ,KAAK,OAAgC;AACzC,WAAO,OAAO,UAAU,WAAW,GAAG,KAAK,OAAO;AAAA,EACtD;AACJ;","names":[]}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { ContentScriptMarkerContract, ContentScriptNode } from "
|
|
1
|
+
import { ContentScriptMarkerContract, ContentScriptNode } from "../../../../types/content.js";
|
|
2
2
|
export default class implements ContentScriptNode {
|
|
3
3
|
protected readonly node: ContentScriptNode;
|
|
4
4
|
protected readonly marker: ContentScriptMarkerContract;
|
|
5
5
|
constructor(node: ContentScriptNode, marker: ContentScriptMarkerContract);
|
|
6
6
|
get anchor(): Element;
|
|
7
7
|
get container(): Element | undefined;
|
|
8
|
+
get target(): Element | undefined;
|
|
8
9
|
mount(): boolean | undefined | void;
|
|
9
10
|
unmount(): boolean | undefined | void;
|
|
10
11
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/entry/content/core/nodes/MarkerNode.ts"],"sourcesContent":["import {ContentScriptMarkerContract, ContentScriptNode} from \"@typing/content\";\n\nexport default class implements ContentScriptNode {\n constructor(\n protected readonly node: ContentScriptNode,\n protected readonly marker: ContentScriptMarkerContract\n ) {}\n\n public get anchor(): Element {\n return this.node.anchor;\n }\n\n public get container(): Element | undefined {\n return this.node.container;\n }\n\n public get target(): Element | undefined {\n return this.node.target;\n }\n\n public mount(): boolean | undefined | void {\n this.marker.mount(this.anchor);\n\n return this.node.mount();\n }\n\n public unmount(): boolean | undefined | void {\n this.marker.unmount(this.anchor);\n\n return this.node.unmount();\n }\n}\n"],"mappings":"AAEA,MAAO,mBAA2C;AAAA,EAC9C,YACuB,MACA,QACrB;AAFqB;AACA;AAAA,EACpB;AAAA,EAFoB;AAAA,EACA;AAAA,EAGvB,IAAW,SAAkB;AACzB,WAAO,KAAK,KAAK;AAAA,EACrB;AAAA,EAEA,IAAW,YAAiC;AACxC,WAAO,KAAK,KAAK;AAAA,EACrB;AAAA,EAEA,IAAW,SAA8B;AACrC,WAAO,KAAK,KAAK;AAAA,EACrB;AAAA,EAEO,QAAoC;AACvC,SAAK,OAAO,MAAM,KAAK,MAAM;AAE7B,WAAO,KAAK,KAAK,MAAM;AAAA,EAC3B;AAAA,EAEO,UAAsC;AACzC,SAAK,OAAO,QAAQ,KAAK,MAAM;AAE/B,WAAO,KAAK,KAAK,QAAQ;AAAA,EAC7B;AACJ;","names":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ContentScriptMountFunction, ContentScriptNode } from "
|
|
1
|
+
import { ContentScriptMountFunction, ContentScriptNode } from "../../../../types/content.js";
|
|
2
2
|
export default class implements ContentScriptNode {
|
|
3
3
|
protected node: ContentScriptNode;
|
|
4
4
|
protected mounter?: ContentScriptMountFunction | undefined;
|
|
@@ -6,6 +6,7 @@ export default class implements ContentScriptNode {
|
|
|
6
6
|
constructor(node: ContentScriptNode, mounter?: ContentScriptMountFunction | undefined);
|
|
7
7
|
get anchor(): Element;
|
|
8
8
|
get container(): Element | undefined;
|
|
9
|
+
get target(): Element | undefined;
|
|
9
10
|
mount(): boolean;
|
|
10
11
|
unmount(): boolean;
|
|
11
12
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/entry/content/core/nodes/MountNode.ts"],"sourcesContent":["import {ContentScriptMountFunction, ContentScriptNode} from \"@typing/content\";\n\nexport default class implements ContentScriptNode {\n private unmounting?: () => void;\n\n constructor(\n protected node: ContentScriptNode,\n protected mounter?: ContentScriptMountFunction\n ) {}\n\n public get anchor(): Element {\n return this.node.anchor;\n }\n\n public get container(): Element | undefined {\n return this.node.container;\n }\n\n public get target(): Element | undefined {\n return this.node.target;\n }\n\n public mount(): boolean {\n this.node.mount();\n\n if (!this.container || this.container.isConnected) {\n return false;\n }\n\n if (this.mounter) {\n const unmounting = this.mounter(this.anchor, this.container);\n\n if (unmounting) {\n this.unmounting = unmounting;\n }\n\n return true;\n }\n\n return false;\n }\n\n public unmount(): boolean {\n this.unmounting?.();\n this.unmounting = undefined;\n\n return !!this.node.unmount();\n }\n}\n"],"mappings":"AAEA,MAAO,kBAA2C;AAAA,EAG9C,YACc,MACA,SACZ;AAFY;AACA;AAAA,EACX;AAAA,EAFW;AAAA,EACA;AAAA,EAJN;AAAA,EAOR,IAAW,SAAkB;AACzB,WAAO,KAAK,KAAK;AAAA,EACrB;AAAA,EAEA,IAAW,YAAiC;AACxC,WAAO,KAAK,KAAK;AAAA,EACrB;AAAA,EAEA,IAAW,SAA8B;AACrC,WAAO,KAAK,KAAK;AAAA,EACrB;AAAA,EAEO,QAAiB;AACpB,SAAK,KAAK,MAAM;AAEhB,QAAI,CAAC,KAAK,aAAa,KAAK,UAAU,aAAa;AAC/C,aAAO;AAAA,IACX;AAEA,QAAI,KAAK,SAAS;AACd,YAAM,aAAa,KAAK,QAAQ,KAAK,QAAQ,KAAK,SAAS;AAE3D,UAAI,YAAY;AACZ,aAAK,aAAa;AAAA,MACtB;AAEA,aAAO;AAAA,IACX;AAEA,WAAO;AAAA,EACX;AAAA,EAEO,UAAmB;AA1C9B;AA2CQ,eAAK,eAAL;AACA,SAAK,aAAa;AAElB,WAAO,CAAC,CAAC,KAAK,KAAK,QAAQ;AAAA,EAC/B;AACJ;","names":[]}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { ContentScriptNode } from "
|
|
1
|
+
import { ContentScriptNode } from "../../../../types/content.js";
|
|
2
2
|
export default class implements ContentScriptNode {
|
|
3
3
|
readonly anchor: Element;
|
|
4
4
|
container?: Element | undefined;
|
|
5
5
|
private readonly _container?;
|
|
6
6
|
constructor(anchor: Element, container?: Element | undefined);
|
|
7
|
+
get target(): Element | undefined;
|
|
7
8
|
mount(): boolean;
|
|
8
9
|
unmount(): boolean;
|
|
9
10
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/entry/content/core/nodes/Node.ts"],"sourcesContent":["import {ContentScriptNode} from \"@typing/content\";\n\nexport default class implements ContentScriptNode {\n private readonly _container?: Element;\n\n constructor(\n public readonly anchor: Element,\n public container?: Element\n ) {\n if (this.container) {\n this._container = this.container.cloneNode(false) as Element;\n }\n }\n\n public get target(): Element | undefined {\n return this.container;\n }\n\n public mount(): boolean {\n if (!this.container && this._container) {\n this.container = this._container.cloneNode(false) as Element;\n\n return true;\n }\n\n return false;\n }\n\n public unmount(): boolean {\n if (this.container) {\n this.container.remove();\n this.container = undefined;\n\n return true;\n }\n\n return false;\n }\n}\n"],"mappings":"AAEA,MAAO,aAA2C;AAAA,EAG9C,YACoB,QACT,WACT;AAFkB;AACT;AAEP,QAAI,KAAK,WAAW;AAChB,WAAK,aAAa,KAAK,UAAU,UAAU,KAAK;AAAA,IACpD;AAAA,EACJ;AAAA,EANoB;AAAA,EACT;AAAA,EAJM;AAAA,EAWjB,IAAW,SAA8B;AACrC,WAAO,KAAK;AAAA,EAChB;AAAA,EAEO,QAAiB;AACpB,QAAI,CAAC,KAAK,aAAa,KAAK,YAAY;AACpC,WAAK,YAAY,KAAK,WAAW,UAAU,KAAK;AAEhD,aAAO;AAAA,IACX;AAEA,WAAO;AAAA,EACX;AAAA,EAEO,UAAmB;AACtB,QAAI,KAAK,WAAW;AAChB,WAAK,UAAU,OAAO;AACtB,WAAK,YAAY;AAEjB,aAAO;AAAA,IACX;AAEA,WAAO;AAAA,EACX;AACJ;","names":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type ContentScriptShadowOptions, type ContentScriptNode } from "../../../../types/content.js";
|
|
2
|
+
export default class ShadowNode implements ContentScriptNode {
|
|
3
|
+
protected readonly node: ContentScriptNode;
|
|
4
|
+
private readonly options;
|
|
5
|
+
private root?;
|
|
6
|
+
private _target?;
|
|
7
|
+
private runtime?;
|
|
8
|
+
constructor(node: ContentScriptNode, options?: ContentScriptShadowOptions);
|
|
9
|
+
get anchor(): Element;
|
|
10
|
+
get container(): Element | undefined;
|
|
11
|
+
get target(): Element | undefined;
|
|
12
|
+
mount(): boolean;
|
|
13
|
+
unmount(): boolean;
|
|
14
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { getContentScriptStylesRuntime } from "./isolated-styles.js";
|
|
2
|
+
import {
|
|
3
|
+
ContentScriptShadowMode
|
|
4
|
+
} from "./../../../../types/content.js";
|
|
5
|
+
class ShadowNode {
|
|
6
|
+
constructor(node, options = {}) {
|
|
7
|
+
this.node = node;
|
|
8
|
+
this.options = options;
|
|
9
|
+
}
|
|
10
|
+
node;
|
|
11
|
+
options;
|
|
12
|
+
root;
|
|
13
|
+
_target;
|
|
14
|
+
runtime;
|
|
15
|
+
get anchor() {
|
|
16
|
+
return this.node.anchor;
|
|
17
|
+
}
|
|
18
|
+
get container() {
|
|
19
|
+
return this.node.container;
|
|
20
|
+
}
|
|
21
|
+
get target() {
|
|
22
|
+
return this._target;
|
|
23
|
+
}
|
|
24
|
+
mount() {
|
|
25
|
+
const mounted = !!this.node.mount();
|
|
26
|
+
if (!this.container || this.root) {
|
|
27
|
+
return mounted;
|
|
28
|
+
}
|
|
29
|
+
if (!("attachShadow" in this.container) || typeof this.container.attachShadow !== "function") {
|
|
30
|
+
throw new Error("Content script container does not support Shadow DOM");
|
|
31
|
+
}
|
|
32
|
+
if (this.container.shadowRoot) {
|
|
33
|
+
throw new Error("Content script container already has an open ShadowRoot");
|
|
34
|
+
}
|
|
35
|
+
let root;
|
|
36
|
+
try {
|
|
37
|
+
root = this.container.attachShadow({ mode: this.options.mode ?? ContentScriptShadowMode.Open });
|
|
38
|
+
} catch (cause) {
|
|
39
|
+
throw new Error(
|
|
40
|
+
"Cannot attach ShadowRoot: the content script container may already have a root or not support Shadow DOM",
|
|
41
|
+
{ cause }
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
const target = this.container.ownerDocument.createElement("div");
|
|
45
|
+
root.appendChild(target);
|
|
46
|
+
const runtime = getContentScriptStylesRuntime();
|
|
47
|
+
runtime.add(root, target);
|
|
48
|
+
this.root = root;
|
|
49
|
+
this._target = target;
|
|
50
|
+
this.runtime = runtime;
|
|
51
|
+
return mounted;
|
|
52
|
+
}
|
|
53
|
+
unmount() {
|
|
54
|
+
var _a;
|
|
55
|
+
if (this.root) {
|
|
56
|
+
(_a = this.runtime) == null ? void 0 : _a.delete(this.root);
|
|
57
|
+
}
|
|
58
|
+
this.root = void 0;
|
|
59
|
+
this._target = void 0;
|
|
60
|
+
this.runtime = void 0;
|
|
61
|
+
return !!this.node.unmount();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
export {
|
|
65
|
+
ShadowNode as default
|
|
66
|
+
};
|
|
67
|
+
//# sourceMappingURL=ShadowNode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/entry/content/core/nodes/ShadowNode.ts"],"sourcesContent":["import {getContentScriptStylesRuntime} from \"./isolated-styles\";\nimport {\n ContentScriptShadowMode,\n type ContentScriptShadowOptions,\n type ContentScriptStylesRuntime,\n type ContentScriptNode,\n} from \"@typing/content\";\n\nexport default class ShadowNode implements ContentScriptNode {\n private root?: ShadowRoot;\n\n private _target?: Element;\n\n private runtime?: ContentScriptStylesRuntime;\n\n public constructor(\n protected readonly node: ContentScriptNode,\n private readonly options: ContentScriptShadowOptions = {}\n ) {}\n\n public get anchor(): Element {\n return this.node.anchor;\n }\n\n public get container(): Element | undefined {\n return this.node.container;\n }\n\n public get target(): Element | undefined {\n return this._target;\n }\n\n public mount(): boolean {\n const mounted = !!this.node.mount();\n\n if (!this.container || this.root) {\n return mounted;\n }\n\n if (!(\"attachShadow\" in this.container) || typeof this.container.attachShadow !== \"function\") {\n throw new Error(\"Content script container does not support Shadow DOM\");\n }\n\n if (this.container.shadowRoot) {\n throw new Error(\"Content script container already has an open ShadowRoot\");\n }\n\n let root: ShadowRoot;\n try {\n root = this.container.attachShadow({mode: this.options.mode ?? ContentScriptShadowMode.Open});\n } catch (cause) {\n // A pre-existing closed root is not observable through container.shadowRoot.\n throw new Error(\n \"Cannot attach ShadowRoot: the content script container may already have a root or not support Shadow DOM\",\n {cause}\n );\n }\n const target = this.container.ownerDocument.createElement(\"div\");\n root.appendChild(target);\n\n const runtime = getContentScriptStylesRuntime();\n runtime.add(root, target);\n\n this.root = root;\n this._target = target;\n this.runtime = runtime;\n\n return mounted;\n }\n\n public unmount(): boolean {\n if (this.root) {\n this.runtime?.delete(this.root);\n }\n\n this.root = undefined;\n this._target = undefined;\n this.runtime = undefined;\n\n return !!this.node.unmount();\n }\n}\n"],"mappings":"AAAA,SAAQ,qCAAoC;AAC5C;AAAA,EACI;AAAA,OAIG;AAEP,MAAO,WAAsD;AAAA,EAOlD,YACgB,MACF,UAAsC,CAAC,GAC1D;AAFqB;AACF;AAAA,EAClB;AAAA,EAFoB;AAAA,EACF;AAAA,EARb;AAAA,EAEA;AAAA,EAEA;AAAA,EAOR,IAAW,SAAkB;AACzB,WAAO,KAAK,KAAK;AAAA,EACrB;AAAA,EAEA,IAAW,YAAiC;AACxC,WAAO,KAAK,KAAK;AAAA,EACrB;AAAA,EAEA,IAAW,SAA8B;AACrC,WAAO,KAAK;AAAA,EAChB;AAAA,EAEO,QAAiB;AACpB,UAAM,UAAU,CAAC,CAAC,KAAK,KAAK,MAAM;AAElC,QAAI,CAAC,KAAK,aAAa,KAAK,MAAM;AAC9B,aAAO;AAAA,IACX;AAEA,QAAI,EAAE,kBAAkB,KAAK,cAAc,OAAO,KAAK,UAAU,iBAAiB,YAAY;AAC1F,YAAM,IAAI,MAAM,sDAAsD;AAAA,IAC1E;AAEA,QAAI,KAAK,UAAU,YAAY;AAC3B,YAAM,IAAI,MAAM,yDAAyD;AAAA,IAC7E;AAEA,QAAI;AACJ,QAAI;AACA,aAAO,KAAK,UAAU,aAAa,EAAC,MAAM,KAAK,QAAQ,QAAQ,wBAAwB,KAAI,CAAC;AAAA,IAChG,SAAS,OAAO;AAEZ,YAAM,IAAI;AAAA,QACN;AAAA,QACA,EAAC,MAAK;AAAA,MACV;AAAA,IACJ;AACA,UAAM,SAAS,KAAK,UAAU,cAAc,cAAc,KAAK;AAC/D,SAAK,YAAY,MAAM;AAEvB,UAAM,UAAU,8BAA8B;AAC9C,YAAQ,IAAI,MAAM,MAAM;AAExB,SAAK,OAAO;AACZ,SAAK,UAAU;AACf,SAAK,UAAU;AAEf,WAAO;AAAA,EACX;AAAA,EAEO,UAAmB;AAtE9B;AAuEQ,QAAI,KAAK,MAAM;AACX,iBAAK,YAAL,mBAAc,OAAO,KAAK;AAAA,IAC9B;AAEA,SAAK,OAAO;AACZ,SAAK,UAAU;AACf,SAAK,UAAU;AAEf,WAAO,CAAC,CAAC,KAAK,KAAK,QAAQ;AAAA,EAC/B;AACJ;","names":[]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as Node } from "./Node.js";
|
|
2
|
+
export { default as MountNode } from "./MountNode.js";
|
|
3
|
+
export { default as MarkerNode } from "./MarkerNode.js";
|
|
4
|
+
export { default as EventNode } from "./EventNode.js";
|
|
5
|
+
export { default as ShadowNode } from "./ShadowNode.js";
|
|
6
|
+
export { default as FrameNode } from "./FrameNode.js";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { default as default2 } from "./Node.js";
|
|
2
|
+
import { default as default3 } from "./MountNode.js";
|
|
3
|
+
import { default as default4 } from "./MarkerNode.js";
|
|
4
|
+
import { default as default5 } from "./EventNode.js";
|
|
5
|
+
import { default as default6 } from "./ShadowNode.js";
|
|
6
|
+
import { default as default7 } from "./FrameNode.js";
|
|
7
|
+
export {
|
|
8
|
+
default5 as EventNode,
|
|
9
|
+
default7 as FrameNode,
|
|
10
|
+
default4 as MarkerNode,
|
|
11
|
+
default3 as MountNode,
|
|
12
|
+
default2 as Node,
|
|
13
|
+
default6 as ShadowNode
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/entry/content/core/nodes/index.ts"],"sourcesContent":["export {default as Node} from \"./Node\";\nexport {default as MountNode} from \"./MountNode\";\nexport {default as MarkerNode} from \"./MarkerNode\";\nexport {default as EventNode} from \"./EventNode\";\nexport {default as ShadowNode} from \"./ShadowNode\";\nexport {default as FrameNode} from \"./FrameNode\";\n"],"mappings":"AAAA,SAAmB,WAAXA,gBAAsB;AAC9B,SAAmB,WAAXA,gBAA2B;AACnC,SAAmB,WAAXA,gBAA4B;AACpC,SAAmB,WAAXA,gBAA2B;AACnC,SAAmB,WAAXA,gBAA4B;AACpC,SAAmB,WAAXA,gBAA2B;","names":["default"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { getUrl } from "@addon-core/browser";
|
|
2
|
+
import { ContentScriptStylesRuntimeProperty } from "./../../../../types/content.js";
|
|
3
|
+
const getContentScriptStylesRuntime = () => {
|
|
4
|
+
const runtime = typeof __webpack_require__ === "function" ? __webpack_require__[ContentScriptStylesRuntimeProperty] : void 0;
|
|
5
|
+
if (!runtime) {
|
|
6
|
+
throw new Error("Isolated styles runtime is unavailable in this content entrypoint");
|
|
7
|
+
}
|
|
8
|
+
runtime.initialize(getUrl);
|
|
9
|
+
return runtime;
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
getContentScriptStylesRuntime
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=isolated-styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/entry/content/core/nodes/isolated-styles.ts"],"sourcesContent":["import {getUrl} from \"@addon-core/browser\";\n\nimport {ContentScriptStylesRuntimeProperty, type ContentScriptStylesRuntime} from \"@typing/content\";\n\ninterface WebpackRuntime {\n (moduleId: string | number): unknown;\n [ContentScriptStylesRuntimeProperty]?: ContentScriptStylesRuntime;\n}\n\ndeclare const __webpack_require__: WebpackRuntime;\n\nexport const getContentScriptStylesRuntime = (): ContentScriptStylesRuntime => {\n const runtime =\n typeof __webpack_require__ === \"function\" ? __webpack_require__[ContentScriptStylesRuntimeProperty] : undefined;\n\n if (!runtime) {\n throw new Error(\"Isolated styles runtime is unavailable in this content entrypoint\");\n }\n\n runtime.initialize(getUrl);\n\n return runtime;\n};\n"],"mappings":"AAAA,SAAQ,cAAa;AAErB,SAAQ,0CAA0E;AAS3E,MAAM,gCAAgC,MAAkC;AAC3E,QAAM,UACF,OAAO,wBAAwB,aAAa,oBAAoB,kCAAkC,IAAI;AAE1G,MAAI,CAAC,SAAS;AACV,UAAM,IAAI,MAAM,mEAAmE;AAAA,EACvF;AAEA,UAAQ,WAAW,MAAM;AAEzB,SAAO;AACX;","names":[]}
|
|
@@ -5,7 +5,7 @@ const contentScriptMutationObserverResolver = (options) => (update) => {
|
|
|
5
5
|
}
|
|
6
6
|
const handle = debounce(update, 200);
|
|
7
7
|
const observer = new MutationObserver(handle);
|
|
8
|
-
observer.observe(document.body, {
|
|
8
|
+
observer.observe(document.body ?? document.documentElement ?? document, {
|
|
9
9
|
childList: true,
|
|
10
10
|
subtree: true,
|
|
11
11
|
attributes: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/entry/content/core/resolvers/watch.ts"],"sourcesContent":["import debounce from \"debounce\";\n\nimport {ContentScriptWatchStrategy} from \"@typing/content\";\n\n// prettier-ignore\nexport const contentScriptMutationObserverResolver =\n (options?: MutationObserverInit): ContentScriptWatchStrategy =>\n update => {\n if (!options) {\n options = {};\n }\n\n const handle = debounce(update, 200);\n\n const observer = new MutationObserver(handle);\n\n observer.observe(document.body, {\n childList: true,\n subtree: true,\n attributes: true,\n characterData: true,\n ...options,\n });\n\n return () => {\n handle.clear();\n observer.disconnect();\n };\n };\n\n// prettier-ignore\nexport const contentScriptAwaitFirstResolver =\n (options?: MutationObserverInit): ContentScriptWatchStrategy =>\n (update, context) => {\n const resolver = contentScriptMutationObserverResolver({\n attributes: false,\n characterData: false,\n ...options,\n });\n\n let unwatch: { (): void } | undefined;\n\n const clear = () => {\n unwatch && unwatch();\n unwatch = undefined;\n };\n\n if (context.nodes.size === 0) {\n unwatch = resolver(() => {\n update();\n\n if (context.nodes.size > 0) {\n clear();\n }\n }, context);\n }\n\n return () => {\n clear();\n };\n };\n\n// prettier-ignore\nexport const contentScriptLocationResolver =\n (strategy: ContentScriptWatchStrategy): ContentScriptWatchStrategy =>\n (update, context) => {\n let currentUrl = location.href;\n\n const interval = setInterval(() => {\n if (currentUrl !== location.href) {\n currentUrl = location.href;\n\n context.mount();\n }\n }, 300);\n\n const unwatch = strategy(update, context);\n\n return () => {\n clearInterval(interval);\n unwatch();\n };\n };\n"],"mappings":"AAAA,OAAO,cAAc;AAKd,MAAM,wCACT,CAAC,YACG,YAAU;AACN,MAAI,CAAC,SAAS;AACV,cAAU,CAAC;AAAA,EACf;AAEA,QAAM,SAAS,SAAS,QAAQ,GAAG;AAEnC,QAAM,WAAW,IAAI,iBAAiB,MAAM;AAE5C,WAAS,QAAQ,SAAS,
|
|
1
|
+
{"version":3,"sources":["../../../../../src/entry/content/core/resolvers/watch.ts"],"sourcesContent":["import debounce from \"debounce\";\n\nimport {ContentScriptWatchStrategy} from \"@typing/content\";\n\n// prettier-ignore\nexport const contentScriptMutationObserverResolver =\n (options?: MutationObserverInit): ContentScriptWatchStrategy =>\n update => {\n if (!options) {\n options = {};\n }\n\n const handle = debounce(update, 200);\n\n const observer = new MutationObserver(handle);\n\n observer.observe(document.body ?? document.documentElement ?? document, {\n childList: true,\n subtree: true,\n attributes: true,\n characterData: true,\n ...options,\n });\n\n return () => {\n handle.clear();\n observer.disconnect();\n };\n };\n\n// prettier-ignore\nexport const contentScriptAwaitFirstResolver =\n (options?: MutationObserverInit): ContentScriptWatchStrategy =>\n (update, context) => {\n const resolver = contentScriptMutationObserverResolver({\n attributes: false,\n characterData: false,\n ...options,\n });\n\n let unwatch: { (): void } | undefined;\n\n const clear = () => {\n unwatch && unwatch();\n unwatch = undefined;\n };\n\n if (context.nodes.size === 0) {\n unwatch = resolver(() => {\n update();\n\n if (context.nodes.size > 0) {\n clear();\n }\n }, context);\n }\n\n return () => {\n clear();\n };\n };\n\n// prettier-ignore\nexport const contentScriptLocationResolver =\n (strategy: ContentScriptWatchStrategy): ContentScriptWatchStrategy =>\n (update, context) => {\n let currentUrl = location.href;\n\n const interval = setInterval(() => {\n if (currentUrl !== location.href) {\n currentUrl = location.href;\n\n context.mount();\n }\n }, 300);\n\n const unwatch = strategy(update, context);\n\n return () => {\n clearInterval(interval);\n unwatch();\n };\n };\n"],"mappings":"AAAA,OAAO,cAAc;AAKd,MAAM,wCACT,CAAC,YACG,YAAU;AACN,MAAI,CAAC,SAAS;AACV,cAAU,CAAC;AAAA,EACf;AAEA,QAAM,SAAS,SAAS,QAAQ,GAAG;AAEnC,QAAM,WAAW,IAAI,iBAAiB,MAAM;AAE5C,WAAS,QAAQ,SAAS,QAAQ,SAAS,mBAAmB,UAAU;AAAA,IACpE,WAAW;AAAA,IACX,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,eAAe;AAAA,IACf,GAAG;AAAA,EACP,CAAC;AAED,SAAO,MAAM;AACT,WAAO,MAAM;AACb,aAAS,WAAW;AAAA,EACxB;AACJ;AAGD,MAAM,kCACT,CAAC,YACG,CAAC,QAAQ,YAAY;AACjB,QAAM,WAAW,sCAAsC;AAAA,IACnD,YAAY;AAAA,IACZ,eAAe;AAAA,IACf,GAAG;AAAA,EACP,CAAC;AAED,MAAI;AAEJ,QAAM,QAAQ,MAAM;AAChB,eAAW,QAAQ;AACnB,cAAU;AAAA,EACd;AAEA,MAAI,QAAQ,MAAM,SAAS,GAAG;AAC1B,cAAU,SAAS,MAAM;AACrB,aAAO;AAEP,UAAI,QAAQ,MAAM,OAAO,GAAG;AACxB,cAAM;AAAA,MACV;AAAA,IACJ,GAAG,OAAO;AAAA,EACd;AAEA,SAAO,MAAM;AACT,UAAM;AAAA,EACV;AACJ;AAGD,MAAM,gCACT,CAAC,aACG,CAAC,QAAQ,YAAY;AACjB,MAAI,aAAa,SAAS;AAE1B,QAAM,WAAW,YAAY,MAAM;AAC/B,QAAI,eAAe,SAAS,MAAM;AAC9B,mBAAa,SAAS;AAEtB,cAAQ,MAAM;AAAA,IAClB;AAAA,EACJ,GAAG,GAAG;AAEN,QAAM,UAAU,SAAS,QAAQ,OAAO;AAExC,SAAO,MAAM;AACT,kBAAc,QAAQ;AACtB,YAAQ;AAAA,EACZ;AACJ;","names":[]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import MountBuilder from "../core/MountBuilder.js";
|
|
2
|
+
import type { ContentScriptDefinition, ContentScriptNode } from "../../../types/content.js";
|
|
3
|
+
/** Page/src navigation has a document owner of its own and does not use a UI renderer. */
|
|
4
|
+
export default class Builder extends MountBuilder {
|
|
5
|
+
constructor(definition: ContentScriptDefinition);
|
|
6
|
+
protected createNode(anchor: Element): Promise<ContentScriptNode>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import MountBuilder from "../core/MountBuilder.js";
|
|
2
|
+
import EventNode from "../core/nodes/EventNode.js";
|
|
3
|
+
class Builder extends MountBuilder {
|
|
4
|
+
constructor(definition) {
|
|
5
|
+
super(definition);
|
|
6
|
+
}
|
|
7
|
+
async createNode(anchor) {
|
|
8
|
+
return new EventNode(await super.createNode(anchor), this.emitter);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
Builder as default
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=Builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/entry/content/frame/Builder.ts"],"sourcesContent":["import MountBuilder from \"../core/MountBuilder\";\nimport EventNode from \"../core/nodes/EventNode\";\nimport type {ContentScriptDefinition, ContentScriptNode} from \"@typing/content\";\n\n/** Page/src navigation has a document owner of its own and does not use a UI renderer. */\nexport default class Builder extends MountBuilder {\n public constructor(definition: ContentScriptDefinition) {\n super(definition);\n }\n\n protected async createNode(anchor: Element): Promise<ContentScriptNode> {\n return new EventNode(await super.createNode(anchor), this.emitter);\n }\n}\n"],"mappings":"AAAA,OAAO,kBAAkB;AACzB,OAAO,eAAe;AAItB,MAAO,gBAA8B,aAAa;AAAA,EACvC,YAAY,YAAqC;AACpD,UAAM,UAAU;AAAA,EACpB;AAAA,EAEA,MAAgB,WAAW,QAA6C;AACpE,WAAO,IAAI,UAAU,MAAM,MAAM,WAAW,MAAM,GAAG,KAAK,OAAO;AAAA,EACrE;AACJ;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/entry/content/frame/index.ts"],"sourcesContent":["import Builder from \"./Builder\";\n\nexport {Builder};\nexport default Builder.resolver();\n"],"mappings":"AAAA,OAAO,aAAa;AAGpB,IAAO,gBAAQ,QAAQ,SAAS;","names":[]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { resolveContentScriptIsolation } from "./../../shared/content/index.js";
|
|
1
2
|
import TransportBuilder from "./TransportBuilder.js";
|
|
2
3
|
import Builder from "../core/Builder.js";
|
|
3
4
|
class Builder_default extends Builder {
|
|
@@ -23,7 +24,10 @@ class Builder_default extends Builder {
|
|
|
23
24
|
if (!this._content) {
|
|
24
25
|
throw new Error("Content script builder not set");
|
|
25
26
|
}
|
|
26
|
-
await main(this._transport.get(), this._content.getContext(),
|
|
27
|
+
await main(this._transport.get(), this._content.getContext(), {
|
|
28
|
+
...this.definition,
|
|
29
|
+
isolation: resolveContentScriptIsolation(this.definition.isolation, "render" in this.definition)
|
|
30
|
+
});
|
|
27
31
|
}
|
|
28
32
|
}
|
|
29
33
|
async destroy() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/entry/relay/Builder.ts"],"sourcesContent":["import TransportBuilder from \"./TransportBuilder\";\n\nimport Builder from \"../core/Builder\";\n\nimport {RelayUnresolvedDefinition} from \"@typing/relay\";\nimport {ContentScriptBuilder} from \"@typing/content\";\nimport {TransportType} from \"@typing/transport\";\n\nexport default class<T extends TransportType> extends Builder {\n protected readonly _transport: TransportBuilder<T>;\n protected _content?: ContentScriptBuilder;\n\n constructor(protected readonly definition: RelayUnresolvedDefinition<T>) {\n super();\n\n this._transport = new TransportBuilder(definition);\n }\n\n public content(content: ContentScriptBuilder): this {\n this._content = content;\n\n return this;\n }\n\n public async build(): Promise<void> {\n await this.destroy();\n\n await this._transport.build();\n await this._content?.build();\n\n const {main} = this.definition;\n\n if (main) {\n if (!this._content) {\n throw new Error(\"Content script builder not set\");\n }\n\n await main(this._transport.get(), this._content.getContext(), this.definition);\n }\n }\n\n public async destroy(): Promise<void> {\n await this._transport.destroy();\n await this._content?.destroy();\n }\n}\n"],"mappings":"AAAA,OAAO,sBAAsB;AAE7B,OAAO,aAAa;AAMpB,MAAO,wBAA+C,QAAQ;AAAA,EAI1D,YAA+B,YAA0C;AACrE,UAAM;AADqB;AAG3B,SAAK,aAAa,IAAI,iBAAiB,UAAU;AAAA,EACrD;AAAA,EAJ+B;AAAA,EAHZ;AAAA,EACT;AAAA,EAQH,QAAQ,SAAqC;AAChD,SAAK,WAAW;AAEhB,WAAO;AAAA,EACX;AAAA,EAEA,MAAa,QAAuB;
|
|
1
|
+
{"version":3,"sources":["../../../src/entry/relay/Builder.ts"],"sourcesContent":["import {resolveContentScriptIsolation} from \"@shared/content\";\n\nimport TransportBuilder from \"./TransportBuilder\";\n\nimport Builder from \"../core/Builder\";\n\nimport {RelayUnresolvedDefinition} from \"@typing/relay\";\nimport {ContentScriptBuilder} from \"@typing/content\";\nimport {TransportType} from \"@typing/transport\";\n\nexport default class<T extends TransportType> extends Builder {\n protected readonly _transport: TransportBuilder<T>;\n protected _content?: ContentScriptBuilder;\n\n constructor(protected readonly definition: RelayUnresolvedDefinition<T>) {\n super();\n\n this._transport = new TransportBuilder(definition);\n }\n\n public content(content: ContentScriptBuilder): this {\n this._content = content;\n\n return this;\n }\n\n public async build(): Promise<void> {\n await this.destroy();\n\n await this._transport.build();\n await this._content?.build();\n\n const {main} = this.definition;\n\n if (main) {\n if (!this._content) {\n throw new Error(\"Content script builder not set\");\n }\n\n await main(this._transport.get(), this._content.getContext(), {\n ...this.definition,\n isolation: resolveContentScriptIsolation(this.definition.isolation, \"render\" in this.definition),\n });\n }\n }\n\n public async destroy(): Promise<void> {\n await this._transport.destroy();\n await this._content?.destroy();\n }\n}\n"],"mappings":"AAAA,SAAQ,qCAAoC;AAE5C,OAAO,sBAAsB;AAE7B,OAAO,aAAa;AAMpB,MAAO,wBAA+C,QAAQ;AAAA,EAI1D,YAA+B,YAA0C;AACrE,UAAM;AADqB;AAG3B,SAAK,aAAa,IAAI,iBAAiB,UAAU;AAAA,EACrD;AAAA,EAJ+B;AAAA,EAHZ;AAAA,EACT;AAAA,EAQH,QAAQ,SAAqC;AAChD,SAAK,WAAW;AAEhB,WAAO;AAAA,EACX;AAAA,EAEA,MAAa,QAAuB;AA1BxC;AA2BQ,UAAM,KAAK,QAAQ;AAEnB,UAAM,KAAK,WAAW,MAAM;AAC5B,YAAM,UAAK,aAAL,mBAAe;AAErB,UAAM,EAAC,KAAI,IAAI,KAAK;AAEpB,QAAI,MAAM;AACN,UAAI,CAAC,KAAK,UAAU;AAChB,cAAM,IAAI,MAAM,gCAAgC;AAAA,MACpD;AAEA,YAAM,KAAK,KAAK,WAAW,IAAI,GAAG,KAAK,SAAS,WAAW,GAAG;AAAA,QAC1D,GAAG,KAAK;AAAA,QACR,WAAW,8BAA8B,KAAK,WAAW,WAAW,YAAY,KAAK,UAAU;AAAA,MACnG,CAAC;AAAA,IACL;AAAA,EACJ;AAAA,EAEA,MAAa,UAAyB;AA9C1C;AA+CQ,UAAM,KAAK,WAAW,QAAQ;AAC9B,YAAM,UAAK,aAAL,mBAAe;AAAA,EACzB;AACJ;","names":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Builder from "./Builder.js";
|
|
2
2
|
export { Builder };
|
|
3
3
|
export type { RelayUnresolvedDefinition } from "../../types/relay.js";
|
|
4
|
-
declare const _default: (definition: Partial<import("../../types/relay.js").RelayDefinition<import("../../transport/index.js").TransportType>>) => void;
|
|
4
|
+
declare const _default: (definition: Partial<Omit<import("../../types/relay.js").RelayDefinition<import("../../transport/index.js").TransportType>, never>>) => void;
|
|
5
5
|
export default _default;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import type { Language, LocaleDir, LocaleNonPluralKeys, LocalePluralKeys, LocaleRegistry, LocaleSubstitutionArgs, LocaleSnapshot } from "../../../types/locale.js";
|
|
3
|
+
import type { LocaleReactContract, LocaleReactSubstitutionArgs } from "./types.js";
|
|
4
|
+
/** Adapts an existing message provider to React without owning storage or language changes. */
|
|
5
|
+
export default class ReactLocale<S extends object = LocaleRegistry> implements LocaleReactContract<S> {
|
|
6
|
+
private readonly locale;
|
|
7
|
+
readonly lang: Language;
|
|
8
|
+
readonly langs: ReadonlySet<Language>;
|
|
9
|
+
readonly langNames: ReadonlyMap<Language, string>;
|
|
10
|
+
readonly dir: LocaleDir;
|
|
11
|
+
readonly isRtl: boolean;
|
|
12
|
+
constructor(locale: LocaleSnapshot<S>);
|
|
13
|
+
t<K extends LocaleNonPluralKeys<S>>(key: K, ...args: LocaleSubstitutionArgs<S, K>): string;
|
|
14
|
+
t<K extends LocaleNonPluralKeys<S>>(key: K, ...args: LocaleReactSubstitutionArgs<S, K>): ReactNode;
|
|
15
|
+
choice<K extends LocalePluralKeys<S>>(key: K, count: number, ...args: LocaleSubstitutionArgs<S, K>): string;
|
|
16
|
+
choice<K extends LocalePluralKeys<S>>(key: K, count: number, ...args: LocaleReactSubstitutionArgs<S, K>): ReactNode;
|
|
17
|
+
private render;
|
|
18
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { createElement, Fragment } from "react";
|
|
2
|
+
import { selectPluralForm, applySubstitutions, getLocaleDir, isLocaleRtl } from "./../../../shared/locale/index.js";
|
|
3
|
+
class ReactLocale {
|
|
4
|
+
constructor(locale) {
|
|
5
|
+
this.locale = locale;
|
|
6
|
+
this.lang = locale.lang();
|
|
7
|
+
this.langs = locale.langs();
|
|
8
|
+
this.langNames = locale.langNames();
|
|
9
|
+
this.dir = getLocaleDir(this.lang);
|
|
10
|
+
this.isRtl = isLocaleRtl(this.lang);
|
|
11
|
+
this.t = this.t.bind(this);
|
|
12
|
+
this.choice = this.choice.bind(this);
|
|
13
|
+
}
|
|
14
|
+
locale;
|
|
15
|
+
lang;
|
|
16
|
+
langs;
|
|
17
|
+
langNames;
|
|
18
|
+
dir;
|
|
19
|
+
isRtl;
|
|
20
|
+
t(key, substitutions) {
|
|
21
|
+
return this.render(key, substitutions);
|
|
22
|
+
}
|
|
23
|
+
choice(key, count, substitutions) {
|
|
24
|
+
return this.render(key, substitutions, count);
|
|
25
|
+
}
|
|
26
|
+
render(key, substitutions, count) {
|
|
27
|
+
const message = this.locale.get(key);
|
|
28
|
+
const template = count === void 0 ? message : selectPluralForm(message, this.lang, count);
|
|
29
|
+
const parts = applySubstitutions(template, substitutions, (name) => {
|
|
30
|
+
console.warn(`Locale substitution "${name}" not found for key "${key}" in "${this.lang}" language.`);
|
|
31
|
+
});
|
|
32
|
+
if (parts.every((part) => typeof part === "string" || typeof part === "number")) {
|
|
33
|
+
return parts.join("");
|
|
34
|
+
}
|
|
35
|
+
return parts.map((part, index) => createElement(Fragment, { key: index }, part));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export {
|
|
39
|
+
ReactLocale as default
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=ReactLocale.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/locale/adapters/react/ReactLocale.ts"],"sourcesContent":["import {createElement, Fragment, type ReactNode} from \"react\";\n\nimport {selectPluralForm, applySubstitutions, getLocaleDir, isLocaleRtl} from \"@shared/locale\";\n\nimport type {\n Language,\n LocaleDir,\n LocaleNonPluralKeys,\n LocalePluralKeys,\n LocaleRegistry,\n LocaleSubstitutionArgs,\n LocaleSnapshot,\n} from \"@typing/locale\";\n\nimport type {LocaleReactContract, LocaleReactSubstitutionArgs} from \"./types\";\n\n/** Adapts an existing message provider to React without owning storage or language changes. */\nexport default class ReactLocale<S extends object = LocaleRegistry> implements LocaleReactContract<S> {\n public readonly lang: Language;\n public readonly langs: ReadonlySet<Language>;\n public readonly langNames: ReadonlyMap<Language, string>;\n public readonly dir: LocaleDir;\n public readonly isRtl: boolean;\n\n constructor(private readonly locale: LocaleSnapshot<S>) {\n this.lang = locale.lang();\n this.langs = locale.langs();\n this.langNames = locale.langNames();\n this.dir = getLocaleDir(this.lang);\n this.isRtl = isLocaleRtl(this.lang);\n\n this.t = this.t.bind(this);\n this.choice = this.choice.bind(this);\n }\n\n public t<K extends LocaleNonPluralKeys<S>>(key: K, ...args: LocaleSubstitutionArgs<S, K>): string;\n public t<K extends LocaleNonPluralKeys<S>>(key: K, ...args: LocaleReactSubstitutionArgs<S, K>): ReactNode;\n public t(key: LocaleNonPluralKeys<S>, substitutions?: Record<string, ReactNode>): ReactNode {\n return this.render(key, substitutions);\n }\n\n public choice<K extends LocalePluralKeys<S>>(key: K, count: number, ...args: LocaleSubstitutionArgs<S, K>): string;\n public choice<K extends LocalePluralKeys<S>>(\n key: K,\n count: number,\n ...args: LocaleReactSubstitutionArgs<S, K>\n ): ReactNode;\n public choice(key: LocalePluralKeys<S>, count: number, substitutions?: Record<string, ReactNode>): ReactNode {\n return this.render(key, substitutions, count);\n }\n\n private render(key: keyof S & string, substitutions?: Record<string, ReactNode>, count?: number): ReactNode {\n const message = this.locale.get(key);\n\n const template = count === undefined ? message : selectPluralForm(message, this.lang, count);\n\n const parts = applySubstitutions(template, substitutions, name => {\n console.warn(`Locale substitution \"${name}\" not found for key \"${key}\" in \"${this.lang}\" language.`);\n });\n\n if (parts.every(part => typeof part === \"string\" || typeof part === \"number\")) {\n return parts.join(\"\");\n }\n\n return parts.map((part, index) => createElement(Fragment, {key: index}, part));\n }\n}\n"],"mappings":"AAAA,SAAQ,eAAe,gBAA+B;AAEtD,SAAQ,kBAAkB,oBAAoB,cAAc,mBAAkB;AAe9E,MAAO,YAA+F;AAAA,EAOlG,YAA6B,QAA2B;AAA3B;AACzB,SAAK,OAAO,OAAO,KAAK;AACxB,SAAK,QAAQ,OAAO,MAAM;AAC1B,SAAK,YAAY,OAAO,UAAU;AAClC,SAAK,MAAM,aAAa,KAAK,IAAI;AACjC,SAAK,QAAQ,YAAY,KAAK,IAAI;AAElC,SAAK,IAAI,KAAK,EAAE,KAAK,IAAI;AACzB,SAAK,SAAS,KAAK,OAAO,KAAK,IAAI;AAAA,EACvC;AAAA,EAT6B;AAAA,EANb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAeT,EAAE,KAA6B,eAAsD;AACxF,WAAO,KAAK,OAAO,KAAK,aAAa;AAAA,EACzC;AAAA,EAQO,OAAO,KAA0B,OAAe,eAAsD;AACzG,WAAO,KAAK,OAAO,KAAK,eAAe,KAAK;AAAA,EAChD;AAAA,EAEQ,OAAO,KAAuB,eAA2C,OAA2B;AACxG,UAAM,UAAU,KAAK,OAAO,IAAI,GAAG;AAEnC,UAAM,WAAW,UAAU,SAAY,UAAU,iBAAiB,SAAS,KAAK,MAAM,KAAK;AAE3F,UAAM,QAAQ,mBAAmB,UAAU,eAAe,UAAQ;AAC9D,cAAQ,KAAK,wBAAwB,IAAI,wBAAwB,GAAG,SAAS,KAAK,IAAI,aAAa;AAAA,IACvG,CAAC;AAED,QAAI,MAAM,MAAM,UAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,QAAQ,GAAG;AAC3E,aAAO,MAAM,KAAK,EAAE;AAAA,IACxB;AAEA,WAAO,MAAM,IAAI,CAAC,MAAM,UAAU,cAAc,UAAU,EAAC,KAAK,MAAK,GAAG,IAAI,CAAC;AAAA,EACjF;AACJ;","names":[]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { LocaleReactContract } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Applies language attributes from either locale hook to an element after render.
|
|
4
|
+
* An omitted target or undefined selects html; null disables application.
|
|
5
|
+
* Cleanup restores each previous attribute only while its applied value is unchanged.
|
|
6
|
+
*/
|
|
7
|
+
export declare const useLocaleAttributes: (locale: Pick<LocaleReactContract, "lang" | "dir">, target?: string | Element | null) => void;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
const useLocaleAttributes = (locale, target = "html") => {
|
|
3
|
+
const { lang, dir } = locale;
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
const element = typeof target === "string" ? document.querySelector(target) : target;
|
|
6
|
+
if (!element) return;
|
|
7
|
+
const attributes = Object.entries({ lang, dir }).map(([name, value]) => ({
|
|
8
|
+
name,
|
|
9
|
+
value,
|
|
10
|
+
previous: element.getAttribute(name)
|
|
11
|
+
}));
|
|
12
|
+
for (const { name, value } of attributes) {
|
|
13
|
+
element.setAttribute(name, value);
|
|
14
|
+
}
|
|
15
|
+
return () => {
|
|
16
|
+
for (const { name, value, previous } of attributes) {
|
|
17
|
+
if (element.getAttribute(name) !== value) continue;
|
|
18
|
+
if (previous === null) {
|
|
19
|
+
element.removeAttribute(name);
|
|
20
|
+
} else {
|
|
21
|
+
element.setAttribute(name, previous);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}, [target, lang, dir]);
|
|
26
|
+
};
|
|
27
|
+
export {
|
|
28
|
+
useLocaleAttributes
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=use-locale-attributes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/locale/adapters/react/hooks/use-locale-attributes.ts"],"sourcesContent":["import {useEffect} from \"react\";\nimport type {LocaleReactContract} from \"../types\";\n\n/**\n * Applies language attributes from either locale hook to an element after render.\n * An omitted target or undefined selects html; null disables application.\n * Cleanup restores each previous attribute only while its applied value is unchanged.\n */\nexport const useLocaleAttributes = (\n locale: Pick<LocaleReactContract, \"lang\" | \"dir\">,\n target: string | Element | null = \"html\"\n): void => {\n const {lang, dir} = locale;\n\n useEffect(() => {\n const element = typeof target === \"string\" ? document.querySelector(target) : target;\n\n if (!element) return;\n\n const attributes = Object.entries({lang, dir}).map(([name, value]) => ({\n name,\n value,\n previous: element.getAttribute(name),\n }));\n\n for (const {name, value} of attributes) {\n element.setAttribute(name, value);\n }\n\n return () => {\n for (const {name, value, previous} of attributes) {\n if (element.getAttribute(name) !== value) continue;\n\n if (previous === null) {\n element.removeAttribute(name);\n } else {\n element.setAttribute(name, previous);\n }\n }\n };\n }, [target, lang, dir]);\n};\n"],"mappings":"AAAA,SAAQ,iBAAgB;AAQjB,MAAM,sBAAsB,CAC/B,QACA,SAAkC,WAC3B;AACP,QAAM,EAAC,MAAM,IAAG,IAAI;AAEpB,YAAU,MAAM;AACZ,UAAM,UAAU,OAAO,WAAW,WAAW,SAAS,cAAc,MAAM,IAAI;AAE9E,QAAI,CAAC,QAAS;AAEd,UAAM,aAAa,OAAO,QAAQ,EAAC,MAAM,IAAG,CAAC,EAAE,IAAI,CAAC,CAAC,MAAM,KAAK,OAAO;AAAA,MACnE;AAAA,MACA;AAAA,MACA,UAAU,QAAQ,aAAa,IAAI;AAAA,IACvC,EAAE;AAEF,eAAW,EAAC,MAAM,MAAK,KAAK,YAAY;AACpC,cAAQ,aAAa,MAAM,KAAK;AAAA,IACpC;AAEA,WAAO,MAAM;AACT,iBAAW,EAAC,MAAM,OAAO,SAAQ,KAAK,YAAY;AAC9C,YAAI,QAAQ,aAAa,IAAI,MAAM,MAAO;AAE1C,YAAI,aAAa,MAAM;AACnB,kBAAQ,gBAAgB,IAAI;AAAA,QAChC,OAAO;AACH,kBAAQ,aAAa,MAAM,QAAQ;AAAA,QACvC;AAAA,MACJ;AAAA,IACJ;AAAA,EACJ,GAAG,CAAC,QAAQ,MAAM,GAAG,CAAC;AAC1B;","names":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useMemo, useSyncExternalStore } from "react";
|
|
2
|
+
import ReactLocale from "../ReactLocale.js";
|
|
3
|
+
import { ObservableLocale } from "./../../../../locale/providers/index.js";
|
|
4
|
+
const useLocale = (storage) => {
|
|
5
|
+
const locale = useMemo(() => ObservableLocale.getInstance(storage), [storage]);
|
|
6
|
+
const snapshot = useSyncExternalStore(locale.subscribe, locale.snapshot);
|
|
7
|
+
return useMemo(
|
|
8
|
+
() => Object.assign(new ReactLocale(snapshot), {
|
|
9
|
+
change: locale.change
|
|
10
|
+
}),
|
|
11
|
+
[locale, snapshot]
|
|
12
|
+
);
|
|
13
|
+
};
|
|
14
|
+
export {
|
|
15
|
+
useLocale
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=use-locale.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/locale/adapters/react/hooks/use-locale.ts"],"sourcesContent":["import {useMemo, useSyncExternalStore} from \"react\";\n\nimport ReactLocale from \"../ReactLocale\";\n\nimport {ObservableLocale} from \"@locale/providers\";\n\nimport type {LocaleReactDynamicContract} from \"../types\";\nimport type {LocaleRegistry, LocaleStorageDriver} from \"@typing/locale\";\n\nexport const useLocale = (storage?: LocaleStorageDriver | false): LocaleReactDynamicContract => {\n const locale = useMemo(() => ObservableLocale.getInstance(storage), [storage]);\n const snapshot = useSyncExternalStore(locale.subscribe, locale.snapshot);\n\n return useMemo(\n () =>\n Object.assign(new ReactLocale<LocaleRegistry>(snapshot), {\n change: locale.change,\n }),\n [locale, snapshot]\n );\n};\n"],"mappings":"AAAA,SAAQ,SAAS,4BAA2B;AAE5C,OAAO,iBAAiB;AAExB,SAAQ,wBAAuB;AAKxB,MAAM,YAAY,CAAC,YAAsE;AAC5F,QAAM,SAAS,QAAQ,MAAM,iBAAiB,YAAY,OAAO,GAAG,CAAC,OAAO,CAAC;AAC7E,QAAM,WAAW,qBAAqB,OAAO,WAAW,OAAO,QAAQ;AAEvE,SAAO;AAAA,IACH,MACI,OAAO,OAAO,IAAI,YAA4B,QAAQ,GAAG;AAAA,MACrD,QAAQ,OAAO;AAAA,IACnB,CAAC;AAAA,IACL,CAAC,QAAQ,QAAQ;AAAA,EACrB;AACJ;","names":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import NativeLocale from "./../../../../locale/providers/NativeLocale.js";
|
|
3
|
+
import ReactLocale from "../ReactLocale.js";
|
|
4
|
+
const useNativeLocale = () => {
|
|
5
|
+
return useMemo(() => new ReactLocale(NativeLocale.getInstance()), []);
|
|
6
|
+
};
|
|
7
|
+
export {
|
|
8
|
+
useNativeLocale
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=use-native-locale.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/locale/adapters/react/hooks/use-native-locale.ts"],"sourcesContent":["import {useMemo} from \"react\";\nimport NativeLocale from \"@locale/providers/NativeLocale\";\nimport ReactLocale from \"../ReactLocale\";\nimport type {LocaleRegistry} from \"@typing/locale\";\nimport type {LocaleReactContract} from \"../types\";\n\n/** Uses browser-selected translations with React substitutions. */\nexport const useNativeLocale = (): LocaleReactContract => {\n return useMemo(() => new ReactLocale<LocaleRegistry>(NativeLocale.getInstance()), []);\n};\n"],"mappings":"AAAA,SAAQ,eAAc;AACtB,OAAO,kBAAkB;AACzB,OAAO,iBAAiB;AAKjB,MAAM,kBAAkB,MAA2B;AACtD,SAAO,QAAQ,MAAM,IAAI,YAA4B,aAAa,YAAY,CAAC,GAAG,CAAC,CAAC;AACxF;","names":[]}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { useLocale
|
|
1
|
+
export { useNativeLocale } from "./hooks/use-native-locale.js";
|
|
2
|
+
export { useLocale } from "./hooks/use-locale.js";
|
|
3
|
+
export { useLocaleAttributes } from "./hooks/use-locale-attributes.js";
|
|
4
|
+
export type { LocaleReactContract, LocaleReactDynamicContract } from "./types.js";
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useLocale } from "./
|
|
1
|
+
import { useNativeLocale } from "./hooks/use-native-locale.js";
|
|
2
|
+
import { useLocale } from "./hooks/use-locale.js";
|
|
3
|
+
import { useLocaleAttributes } from "./hooks/use-locale-attributes.js";
|
|
3
4
|
export {
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
useLocale,
|
|
6
|
+
useLocaleAttributes,
|
|
7
|
+
useNativeLocale
|
|
6
8
|
};
|
|
7
9
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/locale/adapters/react/index.ts"],"sourcesContent":["export {
|
|
1
|
+
{"version":3,"sources":["../../../../src/locale/adapters/react/index.ts"],"sourcesContent":["export {useNativeLocale} from \"./hooks/use-native-locale\";\nexport {useLocale} from \"./hooks/use-locale\";\nexport {useLocaleAttributes} from \"./hooks/use-locale-attributes\";\nexport type {LocaleReactContract, LocaleReactDynamicContract} from \"./types\";\n"],"mappings":"AAAA,SAAQ,uBAAsB;AAC9B,SAAQ,iBAAgB;AACxB,SAAQ,2BAA0B;","names":[]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { Language, LocaleDir, LocaleNonPluralKeys, LocalePluralKeys, LocaleRegistry, LocaleSubstitutionArgs, LocaleSubstitutionKeys } from "../../../types/locale.js";
|
|
3
|
+
export type LocaleReactSubstitutionArgs<S, K extends keyof S> = string extends keyof S ? [substitutions?: Record<string, ReactNode>] : [LocaleSubstitutionKeys<S, K>] extends [never] ? [] : [substitutions: Record<LocaleSubstitutionKeys<S, K>, ReactNode>];
|
|
4
|
+
/** Translation capabilities shared by React adapters, without language mutation or storage. */
|
|
5
|
+
export interface LocaleReactContract<S extends object = LocaleRegistry> {
|
|
6
|
+
/** Currently selected language code. */
|
|
7
|
+
readonly lang: Language;
|
|
8
|
+
/** Available language codes. */
|
|
9
|
+
readonly langs: ReadonlySet<Language>;
|
|
10
|
+
/** Native names keyed by the available language codes. */
|
|
11
|
+
readonly langNames: ReadonlyMap<Language, string>;
|
|
12
|
+
readonly dir: LocaleDir;
|
|
13
|
+
readonly isRtl: boolean;
|
|
14
|
+
t<K extends LocaleNonPluralKeys<S>>(key: K, ...args: LocaleSubstitutionArgs<S, K>): string;
|
|
15
|
+
t<K extends LocaleNonPluralKeys<S>>(key: K, ...args: LocaleReactSubstitutionArgs<S, K>): ReactNode;
|
|
16
|
+
choice<K extends LocalePluralKeys<S>>(key: K, count: number, ...args: LocaleSubstitutionArgs<S, K>): string;
|
|
17
|
+
choice<K extends LocalePluralKeys<S>>(key: K, count: number, ...args: LocaleReactSubstitutionArgs<S, K>): ReactNode;
|
|
18
|
+
}
|
|
19
|
+
/** React translations with an observable language selection. */
|
|
20
|
+
export interface LocaleReactDynamicContract<S extends object = LocaleRegistry> extends LocaleReactContract<S> {
|
|
21
|
+
change(lang: Language): Promise<Language>;
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|