adnbn 0.10.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.js +16 -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.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/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/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/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/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/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 +2 -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 +1 -0
- package/dist/main/index.js +1 -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/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 +10 -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/page.d.ts +8 -0
- 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/tests/fixtures/options/discovery/account.options.d.ts +0 -1
- package/dist/cli/entrypoint/finder/tests/fixtures/options/discovery/advanced.options/index.d.ts +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/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
|
@@ -1,15 +1,35 @@
|
|
|
1
|
+
import { isContentScriptFrameNavigation, resolveContentScriptIsolation } from "./../../../shared/content/index.js";
|
|
1
2
|
import z from "zod";
|
|
2
3
|
import AbstractParser from "./AbstractParser.js";
|
|
4
|
+
import { ExportValueKind } from "../file/index.js";
|
|
3
5
|
import {
|
|
4
6
|
ContentScriptDeclarative,
|
|
5
7
|
ContentScriptMarker,
|
|
6
|
-
ContentScriptMatches
|
|
8
|
+
ContentScriptMatches,
|
|
9
|
+
ContentScriptWorld,
|
|
10
|
+
ContentScriptIsolation,
|
|
11
|
+
ContentScriptShadowMode
|
|
7
12
|
} from "./../../../types/content.js";
|
|
8
13
|
class ContentParser_default extends AbstractParser {
|
|
9
14
|
definition() {
|
|
10
15
|
return ["defineContentScript", "defineContentScriptAppend"];
|
|
11
16
|
}
|
|
12
17
|
schema() {
|
|
18
|
+
const frameSchema = z.object({
|
|
19
|
+
type: z.literal(ContentScriptIsolation.Iframe),
|
|
20
|
+
width: z.union([z.number(), z.string()]),
|
|
21
|
+
height: z.union([z.number(), z.string()])
|
|
22
|
+
}).strict();
|
|
23
|
+
const isolationSchema = z.union([
|
|
24
|
+
z.object({ type: z.literal(ContentScriptIsolation.None) }).strict(),
|
|
25
|
+
z.object({
|
|
26
|
+
type: z.literal(ContentScriptIsolation.Shadow),
|
|
27
|
+
mode: z.nativeEnum(ContentScriptShadowMode)
|
|
28
|
+
}).strict(),
|
|
29
|
+
frameSchema,
|
|
30
|
+
frameSchema.extend({ page: z.string() }),
|
|
31
|
+
frameSchema.extend({ src: z.string() })
|
|
32
|
+
]);
|
|
13
33
|
return this.CommonPropertiesSchema.extend({
|
|
14
34
|
matches: z.array(z.string()).optional(),
|
|
15
35
|
excludeMatches: z.array(z.string()).optional(),
|
|
@@ -17,13 +37,27 @@ class ContentParser_default extends AbstractParser {
|
|
|
17
37
|
includeGlobs: z.array(z.string()).optional(),
|
|
18
38
|
excludeGlobs: z.array(z.string()).optional(),
|
|
19
39
|
allFrames: z.boolean().optional(),
|
|
20
|
-
world: z.
|
|
40
|
+
world: z.nativeEnum(ContentScriptWorld).optional(),
|
|
21
41
|
runAt: z.enum(["document_start", "document_end", "document_idle"]).optional(),
|
|
22
42
|
matchOriginAsFallback: z.boolean().optional(),
|
|
23
43
|
declarative: z.union([z.nativeEnum(ContentScriptDeclarative), z.boolean()]).optional(),
|
|
24
|
-
marker: z.union([z.nativeEnum(ContentScriptMarker), z.boolean()]).optional()
|
|
44
|
+
marker: z.union([z.nativeEnum(ContentScriptMarker), z.boolean()]).optional(),
|
|
45
|
+
isolation: isolationSchema
|
|
25
46
|
});
|
|
26
47
|
}
|
|
48
|
+
getOptions(file) {
|
|
49
|
+
const optionFile = this.optionFile(file);
|
|
50
|
+
const declared = optionFile.getDeclaredProperties();
|
|
51
|
+
const values = optionFile.getOptions();
|
|
52
|
+
try {
|
|
53
|
+
const hasRender = declared.has("render") || isContentScriptFrameNavigation(values.isolation) && !optionFile.getDefinition() && this.hasDefaultRender(file);
|
|
54
|
+
return { ...values, isolation: resolveContentScriptIsolation(values.isolation, hasRender) };
|
|
55
|
+
} catch (error) {
|
|
56
|
+
throw new Error(
|
|
57
|
+
`Invalid content isolation in "${file.file}": ${error instanceof Error ? error.message : String(error)}`
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
27
61
|
options(file) {
|
|
28
62
|
const options = super.options(file);
|
|
29
63
|
return {
|
|
@@ -32,6 +66,24 @@ class ContentParser_default extends AbstractParser {
|
|
|
32
66
|
...options
|
|
33
67
|
};
|
|
34
68
|
}
|
|
69
|
+
/** Interprets generic export metadata using content render rules; Relay overrides this policy. */
|
|
70
|
+
hasDefaultRender(file) {
|
|
71
|
+
const exported = this.expressionFile(file).getDefaultExport();
|
|
72
|
+
if (!exported) {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
switch (exported.kind) {
|
|
76
|
+
case ExportValueKind.Function:
|
|
77
|
+
case ExportValueKind.Class:
|
|
78
|
+
case ExportValueKind.Jsx:
|
|
79
|
+
case ExportValueKind.Number:
|
|
80
|
+
return true;
|
|
81
|
+
case ExportValueKind.String:
|
|
82
|
+
return exported.value !== "";
|
|
83
|
+
default:
|
|
84
|
+
return exported.properties.includes("$$typeof");
|
|
85
|
+
}
|
|
86
|
+
}
|
|
35
87
|
}
|
|
36
88
|
export {
|
|
37
89
|
ContentParser_default as default
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/cli/entrypoint/parser/ContentParser.ts"],"sourcesContent":["import z from \"zod\";\n\nimport AbstractParser from \"./AbstractParser\";\n\nimport {\n ContentScriptDeclarative,\n ContentScriptEntrypointOptions,\n ContentScriptMarker,\n ContentScriptMatches,\n} from \"@typing/content\";\nimport {EntrypointFile, EntrypointOptions} from \"@typing/entrypoint\";\n\nexport default class<O extends EntrypointOptions = ContentScriptEntrypointOptions> extends AbstractParser<O> {\n protected definition(): string | string[] {\n return [\"defineContentScript\", \"defineContentScriptAppend\"];\n }\n\n protected schema():
|
|
1
|
+
{"version":3,"sources":["../../../../src/cli/entrypoint/parser/ContentParser.ts"],"sourcesContent":["import {isContentScriptFrameNavigation, resolveContentScriptIsolation} from \"@shared/content\";\nimport z from \"zod\";\n\nimport AbstractParser from \"./AbstractParser\";\nimport {ExportValueKind} from \"../file\";\n\nimport {\n ContentScriptDeclarative,\n ContentScriptEntrypointOptions,\n ContentScriptMarker,\n ContentScriptMatches,\n ContentScriptWorld,\n ContentScriptIsolation,\n ContentScriptIsolationOptions,\n ContentScriptShadowMode,\n} from \"@typing/content\";\nimport {EntrypointFile, EntrypointOptions} from \"@typing/entrypoint\";\n\nexport default class<O extends EntrypointOptions = ContentScriptEntrypointOptions> extends AbstractParser<O> {\n protected definition(): string | string[] {\n return [\"defineContentScript\", \"defineContentScriptAppend\"];\n }\n\n protected schema(): z.AnyZodObject {\n const frameSchema = z\n .object({\n type: z.literal(ContentScriptIsolation.Iframe),\n width: z.union([z.number(), z.string()]),\n height: z.union([z.number(), z.string()]),\n })\n .strict();\n\n // getOptions normalizes shorthand and defaults before validating this object contract.\n const isolationSchema = z.union([\n z.object({type: z.literal(ContentScriptIsolation.None)}).strict(),\n z\n .object({\n type: z.literal(ContentScriptIsolation.Shadow),\n mode: z.nativeEnum(ContentScriptShadowMode),\n })\n .strict(),\n frameSchema,\n frameSchema.extend({page: z.string()}),\n frameSchema.extend({src: z.string()}),\n ]) satisfies z.ZodType<ContentScriptIsolationOptions>;\n\n return this.CommonPropertiesSchema.extend({\n matches: z.array(z.string()).optional(),\n excludeMatches: z.array(z.string()).optional(),\n matchAboutBlank: z.boolean().optional(),\n includeGlobs: z.array(z.string()).optional(),\n excludeGlobs: z.array(z.string()).optional(),\n allFrames: z.boolean().optional(),\n world: z.nativeEnum(ContentScriptWorld).optional(),\n runAt: z.enum([\"document_start\", \"document_end\", \"document_idle\"]).optional(),\n matchOriginAsFallback: z.boolean().optional(),\n declarative: z.union([z.nativeEnum(ContentScriptDeclarative), z.boolean()]).optional(),\n marker: z.union([z.nativeEnum(ContentScriptMarker), z.boolean()]).optional(),\n isolation: isolationSchema,\n });\n }\n\n protected getOptions(file: EntrypointFile): Record<string, any> {\n const optionFile = this.optionFile(file);\n const declared = optionFile.getDeclaredProperties();\n const values = optionFile.getOptions();\n\n try {\n const hasRender =\n declared.has(\"render\") ||\n (isContentScriptFrameNavigation(values.isolation) &&\n !optionFile.getDefinition() &&\n this.hasDefaultRender(file));\n return {...values, isolation: resolveContentScriptIsolation(values.isolation, hasRender)};\n } catch (error) {\n throw new Error(\n `Invalid content isolation in \"${file.file}\": ${error instanceof Error ? error.message : String(error)}`\n );\n }\n }\n\n public options(file: EntrypointFile): O {\n const options = super.options(file);\n\n return {\n matches: ContentScriptMatches,\n runAt: \"document_idle\",\n ...options,\n };\n }\n\n /** Interprets generic export metadata using content render rules; Relay overrides this policy. */\n protected hasDefaultRender(file: EntrypointFile): boolean {\n const exported = this.expressionFile(file).getDefaultExport();\n\n if (!exported) {\n return false;\n }\n\n switch (exported.kind) {\n case ExportValueKind.Function:\n case ExportValueKind.Class:\n case ExportValueKind.Jsx:\n case ExportValueKind.Number:\n return true;\n case ExportValueKind.String:\n return exported.value !== \"\";\n default:\n return exported.properties.includes(\"$$typeof\");\n }\n }\n}\n"],"mappings":"AAAA,SAAQ,gCAAgC,qCAAoC;AAC5E,OAAO,OAAO;AAEd,OAAO,oBAAoB;AAC3B,SAAQ,uBAAsB;AAE9B;AAAA,EACI;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,OACG;AAGP,MAAO,8BAAoF,eAAkB;AAAA,EAC/F,aAAgC;AACtC,WAAO,CAAC,uBAAuB,2BAA2B;AAAA,EAC9D;AAAA,EAEU,SAAyB;AAC/B,UAAM,cAAc,EACf,OAAO;AAAA,MACJ,MAAM,EAAE,QAAQ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+1,28 @@
|
|
|
1
|
+
import z from "zod";
|
|
1
2
|
import ContentParser from "./ContentParser.js";
|
|
2
|
-
import { RelayEntrypointOptions } from "../../../types/relay.js";
|
|
3
|
+
import { RelayAllFrames, RelayEntrypointOptions, RelayMethod } from "../../../types/relay.js";
|
|
3
4
|
import { EntrypointFile } from "../../../types/entrypoint.js";
|
|
4
5
|
export default class extends ContentParser<RelayEntrypointOptions> {
|
|
5
6
|
protected definition(): string;
|
|
6
7
|
protected agreement(): string;
|
|
7
|
-
|
|
8
|
+
/** A Relay's default function initializes its transport; it is never an implicit content renderer. */
|
|
9
|
+
protected hasDefaultRender(): boolean;
|
|
10
|
+
protected schema(): z.ZodObject<{
|
|
11
|
+
[x: string]: any;
|
|
12
|
+
} & {
|
|
13
|
+
allFrames: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodNativeEnum<typeof RelayAllFrames>]>>;
|
|
14
|
+
name: z.ZodOptional<z.ZodString>;
|
|
15
|
+
method: z.ZodOptional<z.ZodNativeEnum<typeof RelayMethod>>;
|
|
16
|
+
}, any, any, {
|
|
17
|
+
[x: string]: any;
|
|
18
|
+
allFrames?: unknown;
|
|
19
|
+
name?: unknown;
|
|
20
|
+
method?: unknown;
|
|
21
|
+
}, {
|
|
22
|
+
[x: string]: any;
|
|
23
|
+
allFrames?: unknown;
|
|
24
|
+
name?: unknown;
|
|
25
|
+
method?: unknown;
|
|
26
|
+
}>;
|
|
8
27
|
options(file: EntrypointFile): RelayEntrypointOptions;
|
|
9
28
|
}
|
|
@@ -9,6 +9,10 @@ class RelayParser_default extends ContentParser {
|
|
|
9
9
|
agreement() {
|
|
10
10
|
return "init";
|
|
11
11
|
}
|
|
12
|
+
/** A Relay's default function initializes its transport; it is never an implicit content renderer. */
|
|
13
|
+
hasDefaultRender() {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
12
16
|
schema() {
|
|
13
17
|
return super.schema().extend({
|
|
14
18
|
allFrames: z.union([z.boolean(), z.nativeEnum(RelayAllFrames)]).optional(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/cli/entrypoint/parser/RelayParser.ts"],"sourcesContent":["import z from \"zod\";\n\nimport ContentParser from \"./ContentParser\";\n\nimport {RelayAllFrames, RelayEntrypointOptions, RelayMethod} from \"@typing/relay\";\nimport {EntrypointFile} from \"@typing/entrypoint\";\nimport {ContentScriptDeclarative} from \"@typing/content\";\n\nexport default class extends ContentParser<RelayEntrypointOptions> {\n protected definition(): string {\n return \"defineRelay\";\n }\n\n protected agreement(): string {\n return \"init\";\n }\n\n protected
|
|
1
|
+
{"version":3,"sources":["../../../../src/cli/entrypoint/parser/RelayParser.ts"],"sourcesContent":["import z from \"zod\";\n\nimport ContentParser from \"./ContentParser\";\n\nimport {RelayAllFrames, RelayEntrypointOptions, RelayMethod} from \"@typing/relay\";\nimport {EntrypointFile} from \"@typing/entrypoint\";\nimport {ContentScriptDeclarative} from \"@typing/content\";\n\nexport default class extends ContentParser<RelayEntrypointOptions> {\n protected definition(): string {\n return \"defineRelay\";\n }\n\n protected agreement(): string {\n return \"init\";\n }\n\n /** A Relay's default function initializes its transport; it is never an implicit content renderer. */\n protected hasDefaultRender(): boolean {\n return false;\n }\n\n protected schema() {\n return super.schema().extend({\n allFrames: z.union([z.boolean(), z.nativeEnum(RelayAllFrames)]).optional(),\n name: z\n .string()\n .trim()\n .min(1)\n .max(100)\n .regex(/^[\\p{L}_$][\\p{L}\\p{N}_$]*$/u, {\n message:\n \"Key must start with a Unicode letter, `$` or `_`, and may only contain letters, digits, `$` or `_`\",\n })\n .optional(),\n method: z.nativeEnum(RelayMethod).optional(),\n });\n }\n\n public options(file: EntrypointFile): RelayEntrypointOptions {\n const {declarative, method, ...options} = super.options(file);\n\n return {\n ...options,\n method,\n declarative:\n declarative === undefined\n ? method === RelayMethod.Scripting\n ? ContentScriptDeclarative.Optional\n : undefined\n : declarative,\n };\n }\n}\n"],"mappings":"AAAA,OAAO,OAAO;AAEd,OAAO,mBAAmB;AAE1B,SAAQ,gBAAwC,mBAAkB;AAElE,SAAQ,gCAA+B;AAEvC,MAAO,4BAAsB,cAAsC;AAAA,EACrD,aAAqB;AAC3B,WAAO;AAAA,EACX;AAAA,EAEU,YAAoB;AAC1B,WAAO;AAAA,EACX;AAAA;AAAA,EAGU,mBAA4B;AAClC,WAAO;AAAA,EACX;AAAA,EAEU,SAAS;AACf,WAAO,MAAM,OAAO,EAAE,OAAO;AAAA,MACzB,WAAW,EAAE,MAAM,CAAC,EAAE,QAAQ,GAAG,EAAE,WAAW,cAAc,CAAC,CAAC,EAAE,SAAS;AAAA,MACzE,MAAM,EACD,OAAO,EACP,KAAK,EACL,IAAI,CAAC,EACL,IAAI,GAAG,EACP,MAAM,+BAA+B;AAAA,QAClC,SACI;AAAA,MACR,CAAC,EACA,SAAS;AAAA,MACd,QAAQ,EAAE,WAAW,WAAW,EAAE,SAAS;AAAA,IAC/C,CAAC;AAAA,EACL;AAAA,EAEO,QAAQ,MAA8C;AACzD,UAAM,EAAC,aAAa,QAAQ,GAAG,QAAO,IAAI,MAAM,QAAQ,IAAI;AAE5D,WAAO;AAAA,MACH,GAAG;AAAA,MACH;AAAA,MACA,aACI,gBAAgB,SACV,WAAW,YAAY,YACnB,yBAAyB,WACzB,SACJ;AAAA,IACd;AAAA,EACJ;AACJ;","names":[]}
|
|
@@ -13,23 +13,28 @@ var asset_default = definePlugin(() => {
|
|
|
13
13
|
module: {
|
|
14
14
|
rules: [
|
|
15
15
|
{
|
|
16
|
-
|
|
16
|
+
// Common binary resources work without a query. An explicit asset
|
|
17
|
+
// query also supports less common file formats, without hijacking code.
|
|
18
|
+
test: (file) => !/\.(?:[cm]?[jt]sx?|json|css|s[ac]ss|less|styl|vue|svelte)$/i.test(file),
|
|
17
19
|
resourceQuery: {
|
|
18
|
-
not: [/react/]
|
|
20
|
+
not: [/[?&]react(?:[=&]|$)/, /[?&]raw(?:[=&]|$)/]
|
|
19
21
|
},
|
|
20
22
|
oneOf: [
|
|
21
23
|
{
|
|
22
|
-
resourceQuery: /(chrome|browser)/,
|
|
24
|
+
resourceQuery: /[?&](chrome|browser)(?:[=&]|$)/,
|
|
23
25
|
type: "asset/resource",
|
|
26
|
+
// Both queries explicitly opt into an extension URL. Native CSS
|
|
27
|
+
// localization substitutes the installed extension ID/UUID on load.
|
|
24
28
|
generator: {
|
|
25
29
|
publicPath: `${browser === Browser.Firefox ? "moz" : "chrome"}-extension://__MSG_@@extension_id__/`
|
|
26
30
|
}
|
|
27
31
|
},
|
|
28
32
|
{
|
|
29
|
-
resourceQuery: /base64/,
|
|
33
|
+
resourceQuery: /[?&]base64(?:[=&]|$)/,
|
|
30
34
|
type: "asset/inline"
|
|
31
35
|
},
|
|
32
36
|
{
|
|
37
|
+
test: /\.(png|apng|jpe?g|gif|webp|svg|avif|tiff|bmp|ico|woff2?|eot|ttf|otf|mp3|wav|ogg|oga|opus|flac|aac|m4a|mp4|webm|ogv|mov|pdf|zip|gz|wasm)$/i,
|
|
33
38
|
type: "asset/resource"
|
|
34
39
|
}
|
|
35
40
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/cli/plugins/asset.ts"],"sourcesContent":["import {Configuration as RspackConfig} from \"@rspack/core\";\n\nimport {definePlugin} from \"@main/plugin\";\n\nimport {appFilenameResolver, ReplacePlugin} from \"@cli/bundler\";\n\nimport {Browser} from \"@typing/browser\";\n\nexport default definePlugin(() => {\n return {\n name: \"adnbn:asset\",\n bundler: ({config}) => {\n const {app, browser, assetsDir, assetsFilename} = config;\n\n return {\n output: {\n assetModuleFilename: appFilenameResolver(app, assetsFilename, assetsDir),\n },\n module: {\n rules: [\n {\n test:
|
|
1
|
+
{"version":3,"sources":["../../../src/cli/plugins/asset.ts"],"sourcesContent":["import {Configuration as RspackConfig} from \"@rspack/core\";\n\nimport {definePlugin} from \"@main/plugin\";\n\nimport {appFilenameResolver, ReplacePlugin} from \"@cli/bundler\";\n\nimport {Browser} from \"@typing/browser\";\n\nexport default definePlugin(() => {\n return {\n name: \"adnbn:asset\",\n bundler: ({config}) => {\n const {app, browser, assetsDir, assetsFilename} = config;\n\n return {\n output: {\n assetModuleFilename: appFilenameResolver(app, assetsFilename, assetsDir),\n },\n module: {\n rules: [\n {\n // Common binary resources work without a query. An explicit asset\n // query also supports less common file formats, without hijacking code.\n test: (file: string) =>\n !/\\.(?:[cm]?[jt]sx?|json|css|s[ac]ss|less|styl|vue|svelte)$/i.test(file),\n resourceQuery: {\n not: [/[?&]react(?:[=&]|$)/, /[?&]raw(?:[=&]|$)/],\n },\n oneOf: [\n {\n resourceQuery: /[?&](chrome|browser)(?:[=&]|$)/,\n type: \"asset/resource\",\n // Both queries explicitly opt into an extension URL. Native CSS\n // localization substitutes the installed extension ID/UUID on load.\n generator: {\n publicPath: `${browser === Browser.Firefox ? \"moz\" : \"chrome\"}-extension://__MSG_@@extension_id__/`,\n },\n },\n {\n resourceQuery: /[?&]base64(?:[=&]|$)/,\n type: \"asset/inline\",\n },\n {\n test: /\\.(png|apng|jpe?g|gif|webp|svg|avif|tiff|bmp|ico|woff2?|eot|ttf|otf|mp3|wav|ogg|oga|opus|flac|aac|m4a|mp4|webm|ogv|mov|pdf|zip|gz|wasm)$/i,\n type: \"asset/resource\",\n },\n ],\n },\n ],\n },\n plugins: [\n new ReplacePlugin({\n // Fix for asset/resource publicPath\n values: {\n \"__MSG_%40@extension_id__\": \"__MSG_@@extension_id__\",\n },\n }),\n ],\n } satisfies RspackConfig;\n },\n };\n});\n"],"mappings":"AAEA,SAAQ,oBAAmB;AAE3B,SAAQ,qBAAqB,qBAAoB;AAEjD,SAAQ,eAAc;AAEtB,IAAO,gBAAQ,aAAa,MAAM;AAC9B,SAAO;AAAA,IACH,MAAM;AAAA,IACN,SAAS,CAAC,EAAC,OAAM,MAAM;AACnB,YAAM,EAAC,KAAK,SAAS,WAAW,eAAc,IAAI;AAElD,aAAO;AAAA,QACH,QAAQ;AAAA,UACJ,qBAAqB,oBAAoB,KAAK,gBAAgB,SAAS;AAAA,QAC3E;AAAA,QACA,QAAQ;AAAA,UACJ,OAAO;AAAA,YACH;AAAA;AAAA;AAAA,cAGI,MAAM,CAAC,SACH,CAAC,6DAA6D,KAAK,IAAI;AAAA,cAC3E,eAAe;AAAA,gBACX,KAAK,CAAC,uBAAuB,mBAAmB;AAAA,cACpD;AAAA,cACA,OAAO;AAAA,gBACH;AAAA,kBACI,eAAe;AAAA,kBACf,MAAM;AAAA;AAAA;AAAA,kBAGN,WAAW;AAAA,oBACP,YAAY,GAAG,YAAY,QAAQ,UAAU,QAAQ,QAAQ;AAAA,kBACjE;AAAA,gBACJ;AAAA,gBACA;AAAA,kBACI,eAAe;AAAA,kBACf,MAAM;AAAA,gBACV;AAAA,gBACA;AAAA,kBACI,MAAM;AAAA,kBACN,MAAM;AAAA,gBACV;AAAA,cACJ;AAAA,YACJ;AAAA,UACJ;AAAA,QACJ;AAAA,QACA,SAAS;AAAA,UACL,IAAI,cAAc;AAAA;AAAA,YAEd,QAAQ;AAAA,cACJ,4BAA4B;AAAA,YAChC;AAAA,UACJ,CAAC;AAAA,QACL;AAAA,MACJ;AAAA,IACJ;AAAA,EACJ;AACJ,CAAC;","names":[]}
|
|
@@ -32,7 +32,7 @@ var background_default = definePlugin(() => {
|
|
|
32
32
|
}
|
|
33
33
|
return {};
|
|
34
34
|
}
|
|
35
|
-
const backgroundPlugin = EntrypointPlugin.from(await background.entry().entries()).virtual((file) => virtualBackgroundModule(file));
|
|
35
|
+
const backgroundPlugin = EntrypointPlugin.from(await background.entry().entries()).entryOptions({ asyncChunks: false, runtime: false }).virtual((file) => virtualBackgroundModule(file));
|
|
36
36
|
const commandPlugin = EntrypointPlugin.from(await command.entry().entries()).virtual((file) => command.virtual(file));
|
|
37
37
|
const servicePlugin = EntrypointPlugin.from(await service.entry().entries()).virtual((file) => service.virtual(file));
|
|
38
38
|
if (config.command === AppCommand.Watch) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/cli/plugins/background/index.ts"],"sourcesContent":["import {Configuration as RspackConfig} from \"@rspack/core\";\n\nimport {definePlugin} from \"@main/plugin\";\nimport {virtualBackgroundModule} from \"@cli/virtual/index.js\";\n\nimport {EntrypointPlugin} from \"@cli/bundler\";\n\nimport Background from \"./Background\";\nimport BackgroundEntry from \"./BackgroundEntry\";\nimport BackgroundManifest from \"./BackgroundManifest\";\nimport Command from \"./Command\";\nimport Service from \"./Service\";\nimport ServiceDeclaration from \"./ServiceDeclaration\";\n\nimport {Command as AppCommand} from \"@typing/app\";\n\nexport default definePlugin(() => {\n let background: Background;\n let command: Command;\n let service: Service;\n let serviceDeclaration: ServiceDeclaration;\n\n return {\n name: \"adnbn:background\",\n startup: async ({config}) => {\n background = new Background(config);\n command = new Command(config);\n service = new Service(config);\n serviceDeclaration = new ServiceDeclaration(config);\n },\n background: () => background.files(),\n command: () => command.files(),\n service: () => service.files(),\n bundler: async ({config}) => {\n serviceDeclaration.dictionary(await service.dictionary()).build();\n\n if ((await background.empty()) && (await command.empty()) && (await service.empty())) {\n if (config.debug) {\n console.warn(\"Background, command or service entries not found\");\n }\n\n return {};\n }\n\n // prettier-ignore\n const backgroundPlugin = EntrypointPlugin.from(await background.entry().entries())\n .virtual(file => virtualBackgroundModule(file));\n\n // prettier-ignore\n const commandPlugin = EntrypointPlugin.from(await command.entry().entries())\n .virtual(file => command.virtual(file));\n\n // prettier-ignore\n const servicePlugin = EntrypointPlugin.from(await service.entry().entries())\n .virtual(file => service.virtual(file));\n\n if (config.command === AppCommand.Watch) {\n backgroundPlugin.watch(() => background.clear().entry().entries());\n\n commandPlugin.watch(async () => {\n // Clear the command cache\n await command.clear().commands();\n\n return command.entry().entries();\n });\n\n servicePlugin.watch(async () => {\n serviceDeclaration.dictionary(await service.clear().dictionary()).build();\n\n return service.entry().entries();\n });\n }\n\n return {\n plugins: [servicePlugin, commandPlugin, backgroundPlugin],\n optimization: {\n splitChunks: {\n chunks(chunk) {\n return chunk.name !== BackgroundEntry.name;\n },\n },\n },\n } satisfies RspackConfig;\n },\n manifest: async ({manifest}) => {\n // prettier-ignore\n const mft = new BackgroundManifest()\n .add(background.entry())\n .add(command.entry())\n .add(service.entry());\n\n manifest\n .setBackground(\n (await mft.hasBackground())\n ? {\n entry: BackgroundEntry.name,\n persistent: await mft.isPersistent(),\n }\n : undefined\n )\n .setCommands(await command.manifest());\n\n const permissions = await mft.getPermissions();\n const optionalPermissions = await mft.getOptionalPermissions();\n const hostPermissions = await mft.getHostPermissions();\n const optionalHostPermissions = await mft.getOptionalHostPermissions();\n\n if (permissions.size > 0) {\n manifest.appendPermissions(permissions);\n }\n\n if (optionalPermissions.size > 0) {\n manifest.appendOptionalPermissions(optionalPermissions);\n }\n\n if (hostPermissions.size > 0) {\n manifest.appendHostPermissions(hostPermissions);\n }\n\n if (optionalHostPermissions.size > 0) {\n manifest.appendOptionalHostPermissions(optionalHostPermissions);\n }\n },\n };\n});\n"],"mappings":"AAEA,SAAQ,oBAAmB;AAC3B,SAAQ,+BAA8B;AAEtC,SAAQ,wBAAuB;AAE/B,OAAO,gBAAgB;AACvB,OAAO,qBAAqB;AAC5B,OAAO,wBAAwB;AAC/B,OAAO,aAAa;AACpB,OAAO,aAAa;AACpB,OAAO,wBAAwB;AAE/B,SAAQ,WAAW,kBAAiB;AAEpC,IAAO,qBAAQ,aAAa,MAAM;AAC9B,MAAI;AACJ,MAAI;AACJ,MAAI;AACJ,MAAI;AAEJ,SAAO;AAAA,IACH,MAAM;AAAA,IACN,SAAS,OAAO,EAAC,OAAM,MAAM;AACzB,mBAAa,IAAI,WAAW,MAAM;AAClC,gBAAU,IAAI,QAAQ,MAAM;AAC5B,gBAAU,IAAI,QAAQ,MAAM;AAC5B,2BAAqB,IAAI,mBAAmB,MAAM;AAAA,IACtD;AAAA,IACA,YAAY,MAAM,WAAW,MAAM;AAAA,IACnC,SAAS,MAAM,QAAQ,MAAM;AAAA,IAC7B,SAAS,MAAM,QAAQ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,MACJ;AAAA,IACJ;AAAA,IACA,UAAU,OAAO,EAAC,SAAQ,MAAM;AAE5B,YAAM,MAAM,IAAI,mBAAmB,EAC9B,IAAI,WAAW,MAAM,CAAC,EACtB,IAAI,QAAQ,MAAM,CAAC,EACnB,IAAI,QAAQ,MAAM,CAAC;AAExB,eACK;AAAA,QACI,MAAM,IAAI,cAAc,IACnB;AAAA,UACI,OAAO,gBAAgB;AAAA,UACvB,YAAY,MAAM,IAAI,aAAa;AAAA,QACvC,IACA;AAAA,MACV,EACC,YAAY,MAAM,QAAQ,SAAS,CAAC;AAEzC,YAAM,cAAc,MAAM,IAAI,eAAe;AAC7C,YAAM,sBAAsB,MAAM,IAAI,uBAAuB;AAC7D,YAAM,kBAAkB,MAAM,IAAI,mBAAmB;AACrD,YAAM,0BAA0B,MAAM,IAAI,2BAA2B;AAErE,UAAI,YAAY,OAAO,GAAG;AACtB,iBAAS,kBAAkB,WAAW;AAAA,MAC1C;AAEA,UAAI,oBAAoB,OAAO,GAAG;AAC9B,iBAAS,0BAA0B,mBAAmB;AAAA,MAC1D;AAEA,UAAI,gBAAgB,OAAO,GAAG;AAC1B,iBAAS,sBAAsB,eAAe;AAAA,MAClD;AAEA,UAAI,wBAAwB,OAAO,GAAG;AAClC,iBAAS,8BAA8B,uBAAuB;AAAA,MAClE;AAAA,IACJ;AAAA,EACJ;AACJ,CAAC;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/cli/plugins/background/index.ts"],"sourcesContent":["import {Configuration as RspackConfig} from \"@rspack/core\";\n\nimport {definePlugin} from \"@main/plugin\";\nimport {virtualBackgroundModule} from \"@cli/virtual/index.js\";\n\nimport {EntrypointPlugin} from \"@cli/bundler\";\n\nimport Background from \"./Background\";\nimport BackgroundEntry from \"./BackgroundEntry\";\nimport BackgroundManifest from \"./BackgroundManifest\";\nimport Command from \"./Command\";\nimport Service from \"./Service\";\nimport ServiceDeclaration from \"./ServiceDeclaration\";\n\nimport {Command as AppCommand} from \"@typing/app\";\n\nexport default definePlugin(() => {\n let background: Background;\n let command: Command;\n let service: Service;\n let serviceDeclaration: ServiceDeclaration;\n\n return {\n name: \"adnbn:background\",\n startup: async ({config}) => {\n background = new Background(config);\n command = new Command(config);\n service = new Service(config);\n serviceDeclaration = new ServiceDeclaration(config);\n },\n background: () => background.files(),\n command: () => command.files(),\n service: () => service.files(),\n bundler: async ({config}) => {\n serviceDeclaration.dictionary(await service.dictionary()).build();\n\n if ((await background.empty()) && (await command.empty()) && (await service.empty())) {\n if (config.debug) {\n console.warn(\"Background, command or service entries not found\");\n }\n\n return {};\n }\n\n // prettier-ignore\n const backgroundPlugin = EntrypointPlugin.from(await background.entry().entries())\n .entryOptions({asyncChunks: false, runtime: false})\n .virtual(file => virtualBackgroundModule(file));\n\n // prettier-ignore\n const commandPlugin = EntrypointPlugin.from(await command.entry().entries())\n .virtual(file => command.virtual(file));\n\n // prettier-ignore\n const servicePlugin = EntrypointPlugin.from(await service.entry().entries())\n .virtual(file => service.virtual(file));\n\n if (config.command === AppCommand.Watch) {\n backgroundPlugin.watch(() => background.clear().entry().entries());\n\n commandPlugin.watch(async () => {\n // Clear the command cache\n await command.clear().commands();\n\n return command.entry().entries();\n });\n\n servicePlugin.watch(async () => {\n serviceDeclaration.dictionary(await service.clear().dictionary()).build();\n\n return service.entry().entries();\n });\n }\n\n return {\n plugins: [servicePlugin, commandPlugin, backgroundPlugin],\n optimization: {\n splitChunks: {\n chunks(chunk) {\n return chunk.name !== BackgroundEntry.name;\n },\n },\n },\n } satisfies RspackConfig;\n },\n manifest: async ({manifest}) => {\n // prettier-ignore\n const mft = new BackgroundManifest()\n .add(background.entry())\n .add(command.entry())\n .add(service.entry());\n\n manifest\n .setBackground(\n (await mft.hasBackground())\n ? {\n entry: BackgroundEntry.name,\n persistent: await mft.isPersistent(),\n }\n : undefined\n )\n .setCommands(await command.manifest());\n\n const permissions = await mft.getPermissions();\n const optionalPermissions = await mft.getOptionalPermissions();\n const hostPermissions = await mft.getHostPermissions();\n const optionalHostPermissions = await mft.getOptionalHostPermissions();\n\n if (permissions.size > 0) {\n manifest.appendPermissions(permissions);\n }\n\n if (optionalPermissions.size > 0) {\n manifest.appendOptionalPermissions(optionalPermissions);\n }\n\n if (hostPermissions.size > 0) {\n manifest.appendHostPermissions(hostPermissions);\n }\n\n if (optionalHostPermissions.size > 0) {\n manifest.appendOptionalHostPermissions(optionalHostPermissions);\n }\n },\n };\n});\n"],"mappings":"AAEA,SAAQ,oBAAmB;AAC3B,SAAQ,+BAA8B;AAEtC,SAAQ,wBAAuB;AAE/B,OAAO,gBAAgB;AACvB,OAAO,qBAAqB;AAC5B,OAAO,wBAAwB;AAC/B,OAAO,aAAa;AACpB,OAAO,aAAa;AACpB,OAAO,wBAAwB;AAE/B,SAAQ,WAAW,kBAAiB;AAEpC,IAAO,qBAAQ,aAAa,MAAM;AAC9B,MAAI;AACJ,MAAI;AACJ,MAAI;AACJ,MAAI;AAEJ,SAAO;AAAA,IACH,MAAM;AAAA,IACN,SAAS,OAAO,EAAC,OAAM,MAAM;AACzB,mBAAa,IAAI,WAAW,MAAM;AAClC,gBAAU,IAAI,QAAQ,MAAM;AAC5B,gBAAU,IAAI,QAAQ,MAAM;AAC5B,2BAAqB,IAAI,mBAAmB,MAAM;AAAA,IACtD;AAAA,IACA,YAAY,MAAM,WAAW,MAAM;AAAA,IACnC,SAAS,MAAM,QAAQ,MAAM;AAAA,IAC7B,SAAS,MAAM,QAAQ,MAAM;AAAA,IAC7B,SAAS,OAAO,EAAC,OAAM,MAAM;AACzB,yBAAmB,WAAW,MAAM,QAAQ,WAAW,CAAC,EAAE,MAAM;AAEhE,UAAK,MAAM,WAAW,MAAM,KAAO,MAAM,QAAQ,MAAM,KAAO,MAAM,QAAQ,MAAM,GAAI;AAClF,YAAI,OAAO,OAAO;AACd,kBAAQ,KAAK,kDAAkD;AAAA,QACnE;AAEA,eAAO,CAAC;AAAA,MACZ;AAGA,YAAM,mBAAmB,iBAAiB,KAAK,MAA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M,IAAI,aAAa;AAAA,QACvC,IACA;AAAA,MACV,EACC,YAAY,MAAM,QAAQ,SAAS,CAAC;AAEzC,YAAM,cAAc,MAAM,IAAI,eAAe;AAC7C,YAAM,sBAAsB,MAAM,IAAI,uBAAuB;AAC7D,YAAM,kBAAkB,MAAM,IAAI,mBAAmB;AACrD,YAAM,0BAA0B,MAAM,IAAI,2BAA2B;AAErE,UAAI,YAAY,OAAO,GAAG;AACtB,iBAAS,kBAAkB,WAAW;AAAA,MAC1C;AAEA,UAAI,oBAAoB,OAAO,GAAG;AAC9B,iBAAS,0BAA0B,mBAAmB;AAAA,MAC1D;AAEA,UAAI,gBAAgB,OAAO,GAAG;AAC1B,iBAAS,sBAAsB,eAAe;AAAA,MAClD;AAEA,UAAI,wBAAwB,OAAO,GAAG;AAClC,iBAAS,8BAA8B,uBAAuB;AAAA,MAClE;AAAA,IACJ;AAAA,EACJ;AACJ,CAAC;","names":[]}
|
|
@@ -8,6 +8,6 @@ export default class extends ContentFinder implements ContentProvider<ContentScr
|
|
|
8
8
|
protected _driver?: ContentDriver<ContentScriptEntrypointOptions>;
|
|
9
9
|
constructor(config: ReadonlyConfig);
|
|
10
10
|
driver(): ContentDriver<ContentScriptEntrypointOptions>;
|
|
11
|
-
virtual(file: EntrypointFile): string;
|
|
11
|
+
virtual(file: EntrypointFile, options?: ContentScriptEntrypointOptions): string;
|
|
12
12
|
clear(): this;
|
|
13
13
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import ContentDriver from "./ContentDriver.js";
|
|
2
2
|
import { ContentFinder } from "./../../../cli/entrypoint/index.js";
|
|
3
3
|
import { virtualContentScriptModule } from "./../../../cli/virtual/index.js";
|
|
4
|
+
import { isContentScriptFrameNavigation } from "./../../../shared/content/index.js";
|
|
4
5
|
class Content_default extends ContentFinder {
|
|
5
6
|
_driver;
|
|
6
7
|
constructor(config) {
|
|
@@ -9,11 +10,11 @@ class Content_default extends ContentFinder {
|
|
|
9
10
|
driver() {
|
|
10
11
|
return this._driver ?? (this._driver = new ContentDriver(this));
|
|
11
12
|
}
|
|
12
|
-
virtual(file) {
|
|
13
|
+
virtual(file, options) {
|
|
13
14
|
if (!this.holds(file)) {
|
|
14
15
|
throw new Error(`File ${file} not found for content script`);
|
|
15
16
|
}
|
|
16
|
-
return virtualContentScriptModule(file);
|
|
17
|
+
return virtualContentScriptModule(file, isContentScriptFrameNavigation(options == null ? void 0 : options.isolation));
|
|
17
18
|
}
|
|
18
19
|
clear() {
|
|
19
20
|
var _a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/cli/plugins/content/Content.ts"],"sourcesContent":["import ContentDriver from \"./ContentDriver\";\n\nimport {ContentProvider} from \"./types\";\n\nimport {ContentFinder} from \"@cli/entrypoint/index.js\";\nimport {virtualContentScriptModule} from \"@cli/virtual/index.js\";\n\nimport {ReadonlyConfig} from \"@typing/config\";\nimport {ContentScriptEntrypointOptions} from \"@typing/content\";\nimport {EntrypointFile} from \"@typing/entrypoint\";\n\nexport default class extends ContentFinder implements ContentProvider<ContentScriptEntrypointOptions> {\n protected _driver?: ContentDriver<ContentScriptEntrypointOptions>;\n\n constructor(config: ReadonlyConfig) {\n super(config);\n }\n\n public driver(): ContentDriver<ContentScriptEntrypointOptions> {\n return (this._driver ??= new ContentDriver(this));\n }\n\n public virtual(file: EntrypointFile): string {\n if (!this.holds(file)) {\n throw new Error(`File ${file} not found for content script`);\n }\n\n return virtualContentScriptModule(file);\n }\n\n public clear(): this {\n this._driver?.clear();\n\n return super.clear();\n }\n}\n"],"mappings":"AAAA,OAAO,mBAAmB;AAI1B,SAAQ,qBAAoB;AAC5B,SAAQ,kCAAiC;
|
|
1
|
+
{"version":3,"sources":["../../../../src/cli/plugins/content/Content.ts"],"sourcesContent":["import ContentDriver from \"./ContentDriver\";\n\nimport {ContentProvider} from \"./types\";\n\nimport {ContentFinder} from \"@cli/entrypoint/index.js\";\nimport {virtualContentScriptModule} from \"@cli/virtual/index.js\";\nimport {isContentScriptFrameNavigation} from \"@shared/content\";\n\nimport {ReadonlyConfig} from \"@typing/config\";\nimport {ContentScriptEntrypointOptions} from \"@typing/content\";\nimport {EntrypointFile} from \"@typing/entrypoint\";\n\nexport default class extends ContentFinder implements ContentProvider<ContentScriptEntrypointOptions> {\n protected _driver?: ContentDriver<ContentScriptEntrypointOptions>;\n\n constructor(config: ReadonlyConfig) {\n super(config);\n }\n\n public driver(): ContentDriver<ContentScriptEntrypointOptions> {\n return (this._driver ??= new ContentDriver(this));\n }\n\n public virtual(file: EntrypointFile, options?: ContentScriptEntrypointOptions): string {\n if (!this.holds(file)) {\n throw new Error(`File ${file} not found for content script`);\n }\n\n return virtualContentScriptModule(file, isContentScriptFrameNavigation(options?.isolation));\n }\n\n public clear(): this {\n this._driver?.clear();\n\n return super.clear();\n }\n}\n"],"mappings":"AAAA,OAAO,mBAAmB;AAI1B,SAAQ,qBAAoB;AAC5B,SAAQ,kCAAiC;AACzC,SAAQ,sCAAqC;AAM7C,MAAO,wBAAsB,cAAyE;AAAA,EACxF;AAAA,EAEV,YAAY,QAAwB;AAChC,UAAM,MAAM;AAAA,EAChB;AAAA,EAEO,SAAwD;AAC3D,WAAQ,KAAK,YAAL,KAAK,UAAY,IAAI,cAAc,IAAI;AAAA,EACnD;AAAA,EAEO,QAAQ,MAAsB,SAAkD;AACnF,QAAI,CAAC,KAAK,MAAM,IAAI,GAAG;AACnB,YAAM,IAAI,MAAM,QAAQ,IAAI,+BAA+B;AAAA,IAC/D;AAEA,WAAO,2BAA2B,MAAM,+BAA+B,mCAAS,SAAS,CAAC;AAAA,EAC9F;AAAA,EAEO,QAAc;AA/BzB;AAgCQ,eAAK,YAAL,mBAAc;AAEd,WAAO,MAAM,MAAM;AAAA,EACvB;AACJ;","names":[]}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import ContentName from "./ContentName.js";
|
|
2
2
|
import { ContentGroupItems, ContentProvider } from "./types.js";
|
|
3
3
|
import { ReadonlyConfig } from "../../../types/config.js";
|
|
4
|
-
import { ContentScriptEntrypointOptions } from "../../../types/content.js";
|
|
4
|
+
import { ContentScriptEntrypointOptions, ContentScriptWorld, type ContentScriptWorldValue } from "../../../types/content.js";
|
|
5
5
|
import { EntrypointEntries, EntrypointFile } from "../../../types/entrypoint.js";
|
|
6
6
|
import { ManifestContentScripts, ManifestHostPermissions, ManifestOptionalPermissions, ManifestPermissions } from "../../../types/manifest.js";
|
|
7
|
-
export default class {
|
|
8
|
-
protected readonly
|
|
7
|
+
export default class ContentManager {
|
|
8
|
+
protected readonly config: ReadonlyConfig;
|
|
9
|
+
protected readonly providers: Set<ContentProvider<ContentScriptEntrypointOptions>>;
|
|
9
10
|
protected readonly names: ContentName;
|
|
10
11
|
protected _group?: ContentGroupItems<ContentScriptEntrypointOptions>;
|
|
11
12
|
protected _hostPermissions?: [ManifestHostPermissions, ManifestHostPermissions];
|
|
@@ -13,8 +14,11 @@ export default class {
|
|
|
13
14
|
constructor(config: ReadonlyConfig);
|
|
14
15
|
provider(provider: ContentProvider<ContentScriptEntrypointOptions>): this;
|
|
15
16
|
protected getGroup(): Promise<ContentGroupItems<ContentScriptEntrypointOptions>>;
|
|
17
|
+
protected normalizeOptions(file: EntrypointFile, options: ContentScriptEntrypointOptions): ContentScriptEntrypointOptions;
|
|
16
18
|
group(): Promise<ContentGroupItems<ContentScriptEntrypointOptions>>;
|
|
17
19
|
entries(): Promise<EntrypointEntries>;
|
|
20
|
+
/** Settings are keyed by the final grouped entrypoint name, not the original source files. */
|
|
21
|
+
entryOptions(): Promise<ReadonlyMap<string, ContentScriptEntrypointOptions>>;
|
|
18
22
|
manifest(): Promise<ManifestContentScripts>;
|
|
19
23
|
hostPermissions(): Promise<ManifestHostPermissions>;
|
|
20
24
|
optionalHostPermissions(): Promise<ManifestHostPermissions>;
|
|
@@ -25,7 +29,6 @@ export default class {
|
|
|
25
29
|
protected calculatePermissions(): Promise<[ManifestPermissions, ManifestOptionalPermissions]>;
|
|
26
30
|
virtual(file: EntrypointFile): string;
|
|
27
31
|
empty(): Promise<boolean>;
|
|
28
|
-
|
|
29
|
-
likely(name?: string): boolean;
|
|
32
|
+
protected resolveWorld(world?: ContentScriptWorldValue): ContentScriptWorld;
|
|
30
33
|
clear(): this;
|
|
31
34
|
}
|
|
@@ -1,31 +1,59 @@
|
|
|
1
1
|
import ContentName from "./ContentName.js";
|
|
2
|
-
import { getContentScriptConfigFromOptions } from "./utils.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
2
|
+
import { getContentScriptConfigFromOptions, hasIsolatedTarget } from "./utils.js";
|
|
3
|
+
import { getContentChunkName } from "./bundler.js";
|
|
4
|
+
import {
|
|
5
|
+
ContentScriptDeclarative,
|
|
6
|
+
ContentScriptIsolation,
|
|
7
|
+
ContentScriptWorld
|
|
8
|
+
} from "./../../../types/content.js";
|
|
9
|
+
class ContentManager {
|
|
10
|
+
constructor(config) {
|
|
11
|
+
this.config = config;
|
|
12
|
+
this.names = new ContentName(config);
|
|
13
|
+
Object.values(ContentScriptWorld).forEach((world) => this.names.reserve(getContentChunkName(world)));
|
|
14
|
+
}
|
|
15
|
+
config;
|
|
6
16
|
providers = /* @__PURE__ */ new Set();
|
|
7
17
|
names;
|
|
8
18
|
_group;
|
|
9
19
|
_hostPermissions;
|
|
10
20
|
_permissions;
|
|
11
|
-
constructor(config) {
|
|
12
|
-
this.names = new ContentName(config);
|
|
13
|
-
}
|
|
14
21
|
provider(provider) {
|
|
15
22
|
this.providers.add(provider);
|
|
16
23
|
return this;
|
|
17
24
|
}
|
|
18
25
|
async getGroup() {
|
|
19
|
-
const content = await Promise.all(
|
|
26
|
+
const content = await Promise.all(
|
|
27
|
+
Array.from(this.providers, (provider) => provider.driver().items())
|
|
28
|
+
);
|
|
20
29
|
const group = /* @__PURE__ */ new Map();
|
|
21
30
|
for (const items of content) {
|
|
22
31
|
for (const [name, item] of items) {
|
|
23
|
-
const
|
|
24
|
-
|
|
32
|
+
const options = this.normalizeOptions(item.file, item.options);
|
|
33
|
+
const entry = this.names.create(name, options);
|
|
34
|
+
group.set(entry, /* @__PURE__ */ new Set([...group.get(entry) || [], { ...item, options }]));
|
|
25
35
|
}
|
|
26
36
|
}
|
|
27
37
|
return group;
|
|
28
38
|
}
|
|
39
|
+
normalizeOptions(file, options) {
|
|
40
|
+
var _a, _b, _c;
|
|
41
|
+
const world = this.resolveWorld(options.world);
|
|
42
|
+
if (this.config.manifestVersion !== 2) {
|
|
43
|
+
if (world === ContentScriptWorld.Main && (((_a = options.isolation) == null ? void 0 : _a.type) === ContentScriptIsolation.Shadow || ((_b = options.isolation) == null ? void 0 : _b.type) === ContentScriptIsolation.Iframe && !(((_c = options.isolation) == null ? void 0 : _c.src) && /^https?:\/\//.test(options.isolation.src)))) {
|
|
44
|
+
throw new Error(
|
|
45
|
+
`Content script "${file.file}" cannot use this isolation in the MAIN execution world; only external HTTP(S) isolation.src is supported`
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
return options;
|
|
49
|
+
}
|
|
50
|
+
if (world === ContentScriptWorld.Main) {
|
|
51
|
+
console.warn(
|
|
52
|
+
`Content script "${file.file}" requests world "MAIN", but Addon Bone does not support MAIN content scripts in Manifest V2. It will be built and run in ISOLATED.`
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
return { ...options, world: ContentScriptWorld.Isolated };
|
|
56
|
+
}
|
|
29
57
|
async group() {
|
|
30
58
|
return this._group ?? (this._group = await this.getGroup());
|
|
31
59
|
}
|
|
@@ -36,15 +64,29 @@ class ContentManager_default {
|
|
|
36
64
|
}
|
|
37
65
|
return entries;
|
|
38
66
|
}
|
|
39
|
-
|
|
40
|
-
|
|
67
|
+
/** Settings are keyed by the final grouped entrypoint name, not the original source files. */
|
|
68
|
+
async entryOptions() {
|
|
69
|
+
const entries = /* @__PURE__ */ new Map();
|
|
41
70
|
for (const [entry, items] of await this.group()) {
|
|
42
|
-
const options = Array.from(items, (
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
71
|
+
const options = Array.from(items, (item) => item.options);
|
|
72
|
+
const worlds = new Set(options.map((option) => this.resolveWorld(option.world)));
|
|
73
|
+
if (worlds.size !== 1) {
|
|
74
|
+
throw new Error(`Content entrypoint "${entry}" cannot mix execution worlds`);
|
|
75
|
+
}
|
|
76
|
+
if (new Set(options.map(hasIsolatedTarget)).size !== 1) {
|
|
77
|
+
throw new Error(`Content entrypoint "${entry}" cannot mix isolation style delivery modes`);
|
|
78
|
+
}
|
|
79
|
+
entries.set(entry, Object.assign({}, ...options));
|
|
46
80
|
}
|
|
47
|
-
return
|
|
81
|
+
return entries;
|
|
82
|
+
}
|
|
83
|
+
async manifest() {
|
|
84
|
+
return new Set(
|
|
85
|
+
Array.from(await this.entryOptions(), ([entry, options]) => ({
|
|
86
|
+
entry,
|
|
87
|
+
...getContentScriptConfigFromOptions(options)
|
|
88
|
+
}))
|
|
89
|
+
);
|
|
48
90
|
}
|
|
49
91
|
async hostPermissions() {
|
|
50
92
|
return (await this.calculateHostPermissions())[0];
|
|
@@ -114,9 +156,18 @@ class ContentManager_default {
|
|
|
114
156
|
return [permissions, optionalPermissions];
|
|
115
157
|
}
|
|
116
158
|
virtual(file) {
|
|
159
|
+
if (!this._group) {
|
|
160
|
+
throw new Error(
|
|
161
|
+
`Cannot create virtual file "${file.file}": content group is not prepared. Await entries() or entryOptions() before virtual().`
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
const item = Array.from(this._group.values()).flatMap((items) => Array.from(items)).find((item2) => item2.file.file === file.file);
|
|
165
|
+
if (!item) {
|
|
166
|
+
throw new Error(`Virtual file "${file.file}" is not in the prepared content group.`);
|
|
167
|
+
}
|
|
117
168
|
for (const provider of this.providers) {
|
|
118
169
|
try {
|
|
119
|
-
return provider.virtual(file);
|
|
170
|
+
return provider.virtual(file, item.options);
|
|
120
171
|
} catch {
|
|
121
172
|
}
|
|
122
173
|
}
|
|
@@ -125,16 +176,16 @@ class ContentManager_default {
|
|
|
125
176
|
async empty() {
|
|
126
177
|
return (await this.group()).size === 0;
|
|
127
178
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
179
|
+
resolveWorld(world) {
|
|
180
|
+
switch (world) {
|
|
181
|
+
case void 0:
|
|
182
|
+
case ContentScriptWorld.Isolated:
|
|
183
|
+
return ContentScriptWorld.Isolated;
|
|
184
|
+
case ContentScriptWorld.Main:
|
|
185
|
+
return ContentScriptWorld.Main;
|
|
186
|
+
default:
|
|
187
|
+
throw new Error(`Unsupported content script execution world "${String(world)}"`);
|
|
134
188
|
}
|
|
135
|
-
return [EntrypointType.Relay, EntrypointType.ContentScript].some(
|
|
136
|
-
(type) => name === type || name.endsWith(`.${type}`)
|
|
137
|
-
);
|
|
138
189
|
}
|
|
139
190
|
clear() {
|
|
140
191
|
for (const provider of this.providers) {
|
|
@@ -148,6 +199,6 @@ class ContentManager_default {
|
|
|
148
199
|
}
|
|
149
200
|
}
|
|
150
201
|
export {
|
|
151
|
-
|
|
202
|
+
ContentManager as default
|
|
152
203
|
};
|
|
153
204
|
//# sourceMappingURL=ContentManager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/cli/plugins/content/ContentManager.ts"],"sourcesContent":["import ContentName from \"./ContentName\";\n\nimport {ContentGroupItems, ContentProvider} from \"./types\";\nimport {getContentScriptConfigFromOptions} from \"./utils\";\n\nimport {ReadonlyConfig} from \"@typing/config\";\nimport {ContentScriptDeclarative, ContentScriptEntrypointOptions} from \"@typing/content\";\nimport {EntrypointEntries, EntrypointFile, EntrypointType} from \"@typing/entrypoint\";\nimport {\n ManifestContentScripts,\n ManifestHostPermissions,\n ManifestOptionalPermissions,\n ManifestPermissions,\n} from \"@typing/manifest\";\n\nexport default class {\n protected readonly providers = new Set<ContentProvider<ContentScriptEntrypointOptions>>();\n\n protected readonly names: ContentName;\n\n protected _group?: ContentGroupItems<ContentScriptEntrypointOptions>;\n\n protected _hostPermissions?: [ManifestHostPermissions, ManifestHostPermissions];\n\n protected _permissions?: Promise<[ManifestPermissions, ManifestOptionalPermissions]>;\n\n constructor(config: ReadonlyConfig) {\n this.names = new ContentName(config);\n }\n\n public provider(provider: ContentProvider<ContentScriptEntrypointOptions>): this {\n this.providers.add(provider);\n\n return this;\n }\n\n protected async getGroup(): Promise<ContentGroupItems<ContentScriptEntrypointOptions>> {\n const content = await Promise.all(Array.from(this.providers, provider => provider.driver().items()));\n\n const group: ContentGroupItems<ContentScriptEntrypointOptions> = new Map();\n\n for (const items of content) {\n for (const [name, item] of items) {\n const entry = this.names.create(name, item.options);\n\n group.set(entry, new Set([...(group.get(entry) || []), item]));\n }\n }\n\n return group;\n }\n\n public async group(): Promise<ContentGroupItems<ContentScriptEntrypointOptions>> {\n return (this._group ??= await this.getGroup());\n }\n\n public async entries(): Promise<EntrypointEntries> {\n const entries: EntrypointEntries = new Map();\n\n for (const [entry, items] of await this.group()) {\n entries.set(entry, new Set(Array.from(items, ({file}) => file)));\n }\n\n return entries;\n }\n\n public async manifest(): Promise<ManifestContentScripts> {\n const manifest: ManifestContentScripts = new Set();\n\n for (const [entry, items] of await this.group()) {\n const options = Array.from(items, ({options}) => options).reduce((acc, opt) => {\n return {...acc, ...opt};\n }, {} as ContentScriptEntrypointOptions);\n\n manifest.add({entry, ...getContentScriptConfigFromOptions(options)});\n }\n\n return manifest;\n }\n\n public async hostPermissions(): Promise<ManifestHostPermissions> {\n return (await this.calculateHostPermissions())[0];\n }\n\n public async optionalHostPermissions(): Promise<ManifestHostPermissions> {\n return (await this.calculateHostPermissions())[1];\n }\n\n protected async calculateHostPermissions(): Promise<[ManifestHostPermissions, ManifestHostPermissions]> {\n if (this._hostPermissions) {\n return this._hostPermissions;\n }\n\n const hostPermissions = new Set<string>();\n const optionalHostPermissions = new Set<string>();\n\n const group = await this.group();\n\n for (const items of group.values()) {\n for (const {options} of items) {\n const {matches, declarative} = options;\n\n if (!declarative || !matches) {\n continue;\n }\n\n for (const match of matches) {\n switch (declarative) {\n case ContentScriptDeclarative.Optional:\n optionalHostPermissions.add(match);\n\n break;\n case ContentScriptDeclarative.Required:\n case true:\n hostPermissions.add(match);\n\n break;\n }\n }\n }\n }\n\n return (this._hostPermissions = [hostPermissions, optionalHostPermissions]);\n }\n\n public async permissions(): Promise<ManifestPermissions> {\n return (await this.getPermissions())[0];\n }\n\n public async optionalPermissions(): Promise<ManifestOptionalPermissions> {\n return (await this.getPermissions())[1];\n }\n\n protected getPermissions(): Promise<[ManifestPermissions, ManifestOptionalPermissions]> {\n return (this._permissions ??= this.calculatePermissions());\n }\n\n protected async calculatePermissions(): Promise<[ManifestPermissions, ManifestOptionalPermissions]> {\n const permissions: ManifestPermissions = new Set();\n const optionalPermissions: ManifestOptionalPermissions = new Set();\n\n const contributions = await Promise.all(\n Array.from(this.providers, async provider => {\n const driver = provider.driver();\n\n return Promise.all([driver.permissions(), driver.optionalPermissions()]);\n })\n );\n\n for (const [required, optional] of contributions) {\n for (const permission of required) {\n permissions.add(permission);\n }\n\n for (const permission of optional) {\n optionalPermissions.add(permission);\n }\n }\n\n for (const permission of optionalPermissions) {\n if (permissions.has(permission)) {\n optionalPermissions.delete(permission);\n }\n }\n\n return [permissions, optionalPermissions];\n }\n\n public virtual(file: EntrypointFile): string {\n for (const provider of this.providers) {\n try {\n return provider.virtual(file);\n } catch {}\n }\n\n throw new Error(`Virtual file \"${file.file}\" not found.`);\n }\n\n public async empty(): Promise<boolean> {\n return (await this.group()).size === 0;\n }\n\n public chunkName(): string {\n return this.names.getChunkName();\n }\n\n public likely(name?: string): boolean {\n if (!name) {\n return false;\n }\n\n return [EntrypointType.Relay, EntrypointType.ContentScript].some(\n type => name === type || name.endsWith(`.${type}`)\n );\n }\n\n public clear(): this {\n for (const provider of this.providers) {\n provider.clear();\n }\n\n this.names.reset();\n\n this._group = undefined;\n this._hostPermissions = undefined;\n this._permissions = undefined;\n\n return this;\n }\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IACX;AAEA,WAAO,CAAC,eAAe,OAAO,eAAe,aAAa,EAAE;AAAA,MACxD,UAAQ,SAAS,QAAQ,KAAK,SAAS,IAAI,IAAI,EAAE;AAAA,IACrD;AAAA,EACJ;AAAA,EAEO,QAAc;AACjB,eAAW,YAAY,KAAK,WAAW;AACnC,eAAS,MAAM;AAAA,IACnB;AAEA,SAAK,MAAM,MAAM;AAEjB,SAAK,SAAS;AACd,SAAK,mBAAmB;AACxB,SAAK,eAAe;AAEpB,WAAO;AAAA,EACX;AACJ;","names":["options"]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/cli/plugins/content/ContentManager.ts"],"sourcesContent":["import ContentName from \"./ContentName\";\n\nimport {ContentGroupItems, ContentProvider} from \"./types\";\nimport {getContentScriptConfigFromOptions, hasIsolatedTarget} from \"./utils\";\nimport {getContentChunkName} from \"./bundler\";\n\nimport {ReadonlyConfig} from \"@typing/config\";\nimport {\n ContentScriptDeclarative,\n ContentScriptIsolation,\n ContentScriptEntrypointOptions,\n ContentScriptWorld,\n type ContentScriptWorldValue,\n} from \"@typing/content\";\nimport {EntrypointEntries, EntrypointFile} from \"@typing/entrypoint\";\nimport {\n ManifestContentScripts,\n ManifestHostPermissions,\n ManifestOptionalPermissions,\n ManifestPermissions,\n} from \"@typing/manifest\";\n\nexport default class ContentManager {\n protected readonly providers = new Set<ContentProvider<ContentScriptEntrypointOptions>>();\n\n protected readonly names: ContentName;\n\n protected _group?: ContentGroupItems<ContentScriptEntrypointOptions>;\n\n protected _hostPermissions?: [ManifestHostPermissions, ManifestHostPermissions];\n\n protected _permissions?: Promise<[ManifestPermissions, ManifestOptionalPermissions]>;\n\n constructor(protected readonly config: ReadonlyConfig) {\n this.names = new ContentName(config);\n\n Object.values(ContentScriptWorld).forEach(world => this.names.reserve(getContentChunkName(world)));\n }\n\n public provider(provider: ContentProvider<ContentScriptEntrypointOptions>): this {\n this.providers.add(provider);\n\n return this;\n }\n\n protected async getGroup(): Promise<ContentGroupItems<ContentScriptEntrypointOptions>> {\n // prettier-ignore\n const content = await Promise.all(\n Array.from(this.providers, provider => provider.driver().items())\n );\n\n const group: ContentGroupItems<ContentScriptEntrypointOptions> = new Map();\n\n for (const items of content) {\n for (const [name, item] of items) {\n const options = this.normalizeOptions(item.file, item.options);\n const entry = this.names.create(name, options);\n\n group.set(entry, new Set([...(group.get(entry) || []), {...item, options}]));\n }\n }\n\n return group;\n }\n\n protected normalizeOptions(\n file: EntrypointFile,\n options: ContentScriptEntrypointOptions\n ): ContentScriptEntrypointOptions {\n const world = this.resolveWorld(options.world);\n\n if (this.config.manifestVersion !== 2) {\n if (\n world === ContentScriptWorld.Main &&\n (options.isolation?.type === ContentScriptIsolation.Shadow ||\n (options.isolation?.type === ContentScriptIsolation.Iframe &&\n !(options.isolation?.src && /^https?:\\/\\//.test(options.isolation.src))))\n ) {\n throw new Error(\n `Content script \"${file.file}\" cannot use this isolation in the MAIN execution world; only external HTTP(S) isolation.src is supported`\n );\n }\n\n return options;\n }\n\n if (world === ContentScriptWorld.Main) {\n console.warn(\n `Content script \"${file.file}\" requests world \"MAIN\", but Addon Bone does not support MAIN content scripts in Manifest V2. It will be built and run in ISOLATED.`\n );\n }\n\n return {...options, world: ContentScriptWorld.Isolated};\n }\n\n public async group(): Promise<ContentGroupItems<ContentScriptEntrypointOptions>> {\n return (this._group ??= await this.getGroup());\n }\n\n public async entries(): Promise<EntrypointEntries> {\n const entries: EntrypointEntries = new Map();\n\n for (const [entry, items] of await this.group()) {\n entries.set(entry, new Set(Array.from(items, ({file}) => file)));\n }\n\n return entries;\n }\n\n /** Settings are keyed by the final grouped entrypoint name, not the original source files. */\n public async entryOptions(): Promise<ReadonlyMap<string, ContentScriptEntrypointOptions>> {\n const entries = new Map<string, ContentScriptEntrypointOptions>();\n\n for (const [entry, items] of await this.group()) {\n const options = Array.from(items, item => item.options);\n const worlds = new Set(options.map(option => this.resolveWorld(option.world)));\n if (worlds.size !== 1) {\n throw new Error(`Content entrypoint \"${entry}\" cannot mix execution worlds`);\n }\n\n if (new Set(options.map(hasIsolatedTarget)).size !== 1) {\n throw new Error(`Content entrypoint \"${entry}\" cannot mix isolation style delivery modes`);\n }\n\n entries.set(entry, Object.assign({}, ...options));\n }\n\n return entries;\n }\n\n public async manifest(): Promise<ManifestContentScripts> {\n return new Set(\n Array.from(await this.entryOptions(), ([entry, options]) => ({\n entry,\n ...getContentScriptConfigFromOptions(options),\n }))\n );\n }\n\n public async hostPermissions(): Promise<ManifestHostPermissions> {\n return (await this.calculateHostPermissions())[0];\n }\n\n public async optionalHostPermissions(): Promise<ManifestHostPermissions> {\n return (await this.calculateHostPermissions())[1];\n }\n\n protected async calculateHostPermissions(): Promise<[ManifestHostPermissions, ManifestHostPermissions]> {\n if (this._hostPermissions) {\n return this._hostPermissions;\n }\n\n const hostPermissions = new Set<string>();\n const optionalHostPermissions = new Set<string>();\n\n const group = await this.group();\n\n for (const items of group.values()) {\n for (const {options} of items) {\n const {matches, declarative} = options;\n\n if (!declarative || !matches) {\n continue;\n }\n\n for (const match of matches) {\n switch (declarative) {\n case ContentScriptDeclarative.Optional:\n optionalHostPermissions.add(match);\n\n break;\n case ContentScriptDeclarative.Required:\n case true:\n hostPermissions.add(match);\n\n break;\n }\n }\n }\n }\n\n return (this._hostPermissions = [hostPermissions, optionalHostPermissions]);\n }\n\n public async permissions(): Promise<ManifestPermissions> {\n return (await this.getPermissions())[0];\n }\n\n public async optionalPermissions(): Promise<ManifestOptionalPermissions> {\n return (await this.getPermissions())[1];\n }\n\n protected getPermissions(): Promise<[ManifestPermissions, ManifestOptionalPermissions]> {\n return (this._permissions ??= this.calculatePermissions());\n }\n\n protected async calculatePermissions(): Promise<[ManifestPermissions, ManifestOptionalPermissions]> {\n const permissions: ManifestPermissions = new Set();\n const optionalPermissions: ManifestOptionalPermissions = new Set();\n\n const contributions = await Promise.all(\n Array.from(this.providers, async provider => {\n const driver = provider.driver();\n\n return Promise.all([driver.permissions(), driver.optionalPermissions()]);\n })\n );\n\n for (const [required, optional] of contributions) {\n for (const permission of required) {\n permissions.add(permission);\n }\n\n for (const permission of optional) {\n optionalPermissions.add(permission);\n }\n }\n\n for (const permission of optionalPermissions) {\n if (permissions.has(permission)) {\n optionalPermissions.delete(permission);\n }\n }\n\n return [permissions, optionalPermissions];\n }\n\n public virtual(file: EntrypointFile): string {\n if (!this._group) {\n throw new Error(\n `Cannot create virtual file \"${file.file}\": content group is not prepared. Await entries() or entryOptions() before virtual().`\n );\n }\n\n const item = Array.from(this._group.values())\n .flatMap(items => Array.from(items))\n .find(item => item.file.file === file.file);\n\n if (!item) {\n throw new Error(`Virtual file \"${file.file}\" is not in the prepared content group.`);\n }\n\n for (const provider of this.providers) {\n try {\n return provider.virtual(file, item.options);\n } catch {}\n }\n\n throw new Error(`Virtual file \"${file.file}\" not found.`);\n }\n\n public async empty(): Promise<boolean> {\n return (await this.group()).size === 0;\n }\n\n protected resolveWorld(world?: ContentScriptWorldValue): ContentScriptWorld {\n switch (world) {\n case undefined:\n case ContentScriptWorld.Isolated:\n return ContentScriptWorld.Isolated;\n case ContentScriptWorld.Main:\n return ContentScriptWorld.Main;\n default:\n throw new Error(`Unsupported content script execution world \"${String(world)}\"`);\n }\n }\n\n public clear(): this {\n for (const provider of this.providers) {\n provider.clear();\n }\n\n this.names.reset();\n\n this._group = undefined;\n this._hostPermissions = undefined;\n this._permissions = undefined;\n\n return this;\n }\n}\n"],"mappings":"AAAA,OAAO,iBAAiB;AAGxB,SAAQ,mCAAmC,yBAAwB;AACnE,SAAQ,2BAA0B;AAGlC;AAAA,EACI;AAAA,EACA;AAAA,EAEA;AAAA,OAEG;AASP,MAAO,eAA6B;AAAA,EAWhC,YAA+B,QAAwB;AAAxB;AAC3B,SAAK,QAAQ,IAAI,YAAY,MAAM;AAEnC,WAAO,OAAO,kBAAkB,EAAE,QAAQ,WAAS,KAAK,MAAM,QAAQ,oBAAoB,KAAK,CAAC,CAAC;AAAA,EACrG;AAAA,EAJ+B;AAAA,EAVZ,YA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mBAAmB;AAAA,MAC9B;AACI,cAAM,IAAI,MAAM,+CAA+C,OAAO,KAAK,CAAC,GAAG;AAAA,IACvF;AAAA,EACJ;AAAA,EAEO,QAAc;AACjB,eAAW,YAAY,KAAK,WAAW;AACnC,eAAS,MAAM;AAAA,IACnB;AAEA,SAAK,MAAM,MAAM;AAEjB,SAAK,SAAS;AACd,SAAK,mBAAmB;AACxB,SAAK,eAAe;AAEpB,WAAO;AAAA,EACX;AACJ;","names":["item"]}
|
|
@@ -6,6 +6,6 @@ export default class ContentName extends NameGenerator implements ContentNameGen
|
|
|
6
6
|
protected readonly config: ReadonlyConfig;
|
|
7
7
|
protected readonly _names: Map<string, string>;
|
|
8
8
|
constructor(config: ReadonlyConfig);
|
|
9
|
-
getChunkName(): string;
|
|
10
9
|
create(name: string, options: ContentScriptEntrypointOptions): string;
|
|
10
|
+
reset(): this;
|
|
11
11
|
}
|