adnbn 0.11.0 → 0.12.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/README.md +3 -0
- package/dist/cli/builders/manifest/ManifestBase.js +1 -1
- package/dist/cli/bundler/index.d.ts +1 -0
- package/dist/cli/bundler/index.js +1 -0
- package/dist/cli/bundler/index.js.map +1 -1
- package/dist/cli/bundler/{utils/layers.d.ts → layers.d.ts} +2 -1
- package/dist/cli/bundler/{utils/layers.js → layers.js} +2 -0
- package/dist/cli/bundler/layers.js.map +1 -0
- package/dist/cli/bundler/plugins/build-assets-map/BuildAssetsMapPlugin.js +2 -1
- package/dist/cli/bundler/plugins/build-assets-map/BuildAssetsMapPlugin.js.map +1 -1
- package/dist/cli/bundler/plugins/build-assets-map/index.d.ts +1 -2
- package/dist/cli/bundler/plugins/build-assets-map/index.js +0 -3
- package/dist/cli/bundler/plugins/build-assets-map/index.js.map +1 -1
- package/dist/cli/bundler/plugins/build-assets-map/usage.d.ts +3 -6
- package/dist/cli/bundler/plugins/build-assets-map/usage.js +6 -3
- package/dist/cli/bundler/plugins/build-assets-map/usage.js.map +1 -1
- package/dist/cli/bundler/plugins/index.d.ts +2 -2
- package/dist/cli/bundler/plugins/index.js +2 -6
- package/dist/cli/bundler/plugins/index.js.map +1 -1
- package/dist/cli/bundler/plugins/isolated-styles/IsolatedStylesPlugin.js +1 -1
- package/dist/cli/bundler/plugins/isolated-styles/IsolatedStylesPlugin.js.map +1 -1
- package/dist/cli/bundler/plugins/isolated-styles/chunks.d.ts +3 -0
- package/dist/cli/bundler/{utils/styles.js → plugins/isolated-styles/chunks.js} +8 -6
- package/dist/cli/bundler/plugins/isolated-styles/chunks.js.map +1 -0
- package/dist/cli/bundler/plugins/manifest/ManifestPlugin.js +1 -2
- package/dist/cli/bundler/plugins/manifest/ManifestPlugin.js.map +1 -1
- package/dist/cli/bundler/plugins/types.d.ts +4 -0
- package/dist/cli/bundler/plugins/utils/compilation-assets.d.ts +4 -0
- package/dist/cli/bundler/plugins/utils/compilation-assets.js +12 -0
- package/dist/cli/bundler/plugins/utils/compilation-assets.js.map +1 -0
- package/dist/cli/bundler/plugins/utils/index.d.ts +2 -0
- package/dist/cli/bundler/plugins/utils/index.js +5 -0
- package/dist/cli/bundler/plugins/utils/index.js.map +1 -1
- package/dist/cli/bundler/plugins/utils/runtime-module.d.ts +3 -0
- package/dist/cli/bundler/plugins/utils/runtime-module.js +11 -0
- package/dist/cli/bundler/plugins/utils/runtime-module.js.map +1 -0
- package/dist/cli/bundler/utils/app-filename.d.ts +2 -0
- package/dist/cli/bundler/utils/app-filename.js +19 -0
- package/dist/cli/bundler/utils/app-filename.js.map +1 -0
- package/dist/cli/bundler/utils/assets.d.ts +3 -0
- package/dist/cli/bundler/utils/{output.js → assets.js} +22 -33
- package/dist/cli/bundler/utils/assets.js.map +1 -0
- package/dist/cli/bundler/utils/index.d.ts +2 -3
- package/dist/cli/bundler/utils/index.js +2 -3
- package/dist/cli/bundler/utils/index.js.map +1 -1
- package/dist/cli/entrypoint/file/injectors/core.js +1 -1
- package/dist/cli/entrypoint/finder/ContentFinder.d.ts +1 -1
- package/dist/cli/entrypoint/parser/ContentParser.d.ts +2 -2
- package/dist/cli/entrypoint/parser/ContentParser.js +6 -22
- package/dist/cli/entrypoint/parser/ContentParser.js.map +1 -1
- package/dist/cli/entrypoint/parser/RelayParser.js +1 -1
- package/dist/cli/entrypoint/parser/utils/content/default-render.d.ts +3 -0
- package/dist/cli/entrypoint/parser/utils/content/default-render.js +21 -0
- package/dist/cli/entrypoint/parser/utils/content/default-render.js.map +1 -0
- package/dist/cli/plugins/content/Content.d.ts +1 -1
- package/dist/cli/plugins/content/ContentDriver.d.ts +1 -1
- package/dist/cli/plugins/content/ContentManager.d.ts +1 -1
- package/dist/cli/plugins/content/ContentManager.js +1 -1
- package/dist/cli/plugins/content/ContentName.d.ts +1 -1
- package/dist/cli/plugins/content/ContentName.js +1 -1
- package/dist/cli/plugins/content/Relay.d.ts +1 -1
- package/dist/cli/plugins/content/RelayDriver.d.ts +1 -1
- package/dist/cli/plugins/content/RelayDriver.js +1 -1
- package/dist/cli/plugins/content/bundler.d.ts +1 -1
- package/dist/cli/plugins/content/bundler.js +1 -1
- package/dist/cli/plugins/content/index.js +2 -2
- package/dist/cli/plugins/content/index.js.map +1 -1
- package/dist/cli/plugins/content/types.d.ts +1 -1
- package/dist/cli/plugins/content/utils.d.ts +1 -1
- package/dist/cli/plugins/content/utils.js +1 -1
- package/dist/cli/plugins/index.d.ts +1 -1
- package/dist/cli/plugins/index.js +1 -1
- package/dist/cli/plugins/locale/index.js +2 -2
- package/dist/cli/plugins/locale/index.js.map +1 -1
- package/dist/cli/plugins/output/index.d.ts +2 -0
- package/dist/cli/plugins/{output.js → output/index.js} +11 -13
- package/dist/cli/plugins/output/index.js.map +1 -0
- package/dist/cli/plugins/output/runtime.d.ts +26 -0
- package/dist/cli/plugins/output/runtime.js +19 -0
- package/dist/cli/plugins/output/runtime.js.map +1 -0
- package/dist/cli/plugins/style/index.js +1 -1
- package/dist/cli/plugins/style/index.js.map +1 -1
- package/dist/cli/resolvers/config.js +1 -1
- package/dist/cli/resolvers/config.js.map +1 -1
- package/dist/cli/virtual/index.js +4 -4
- package/dist/cli/virtual/virtual.d.ts +8 -3
- package/dist/content/index.d.ts +3 -0
- package/dist/content/index.js +8 -0
- package/dist/content/index.js.map +1 -0
- package/dist/entry/content/adapters/react/Builder.d.ts +5 -6
- package/dist/entry/content/adapters/react/Builder.js +8 -21
- package/dist/entry/content/adapters/react/Builder.js.map +1 -1
- package/dist/entry/content/adapters/react/Node.d.ts +6 -14
- package/dist/entry/content/adapters/react/Node.js +9 -33
- package/dist/entry/content/adapters/react/Node.js.map +1 -1
- package/dist/entry/content/adapters/react/index.d.ts +2 -1
- package/dist/entry/content/adapters/react/index.js +3 -1
- package/dist/entry/content/adapters/react/index.js.map +1 -1
- package/dist/entry/content/adapters/react/resolvers/definition.d.ts +2 -0
- package/dist/entry/content/adapters/react/resolvers/definition.js +12 -0
- package/dist/entry/content/adapters/react/resolvers/definition.js.map +1 -0
- package/dist/entry/content/adapters/react/resolvers/render.d.ts +2 -2
- package/dist/entry/content/adapters/react/resolvers/render.js +4 -6
- package/dist/entry/content/adapters/react/resolvers/render.js.map +1 -1
- package/dist/entry/content/adapters/vanilla/Builder.d.ts +5 -5
- package/dist/entry/content/adapters/vanilla/Builder.js +9 -15
- package/dist/entry/content/adapters/vanilla/Builder.js.map +1 -1
- package/dist/entry/content/adapters/vanilla/Node.d.ts +5 -11
- package/dist/entry/content/adapters/vanilla/Node.js +11 -37
- package/dist/entry/content/adapters/vanilla/Node.js.map +1 -1
- package/dist/entry/content/adapters/vanilla/index.d.ts +2 -1
- package/dist/entry/content/adapters/vanilla/index.js +3 -1
- package/dist/entry/content/adapters/vanilla/index.js.map +1 -1
- package/dist/entry/content/adapters/vanilla/resolvers/definition.d.ts +2 -0
- package/dist/entry/content/adapters/vanilla/resolvers/definition.js +9 -0
- package/dist/entry/content/adapters/vanilla/resolvers/definition.js.map +1 -0
- package/dist/entry/content/adapters/vanilla/resolvers/render.d.ts +3 -0
- package/dist/entry/content/adapters/vanilla/resolvers/render.js +15 -0
- package/dist/entry/content/adapters/vanilla/resolvers/render.js.map +1 -0
- package/dist/entry/content/index.d.ts +5 -1
- package/dist/entry/content/index.js +8 -1
- package/dist/entry/content/index.js.map +1 -1
- package/dist/entry/content/lifecycle/Builder.d.ts +26 -0
- package/dist/entry/content/lifecycle/Builder.js +212 -0
- package/dist/entry/content/lifecycle/Builder.js.map +1 -0
- package/dist/entry/content/lifecycle/IsolationSetup.d.ts +16 -0
- package/dist/entry/content/lifecycle/IsolationSetup.js +37 -0
- package/dist/entry/content/lifecycle/IsolationSetup.js.map +1 -0
- package/dist/entry/content/lifecycle/MountBuilder.d.ts +8 -0
- package/dist/entry/content/lifecycle/MountBuilder.js +57 -0
- package/dist/entry/content/lifecycle/MountBuilder.js.map +1 -0
- package/dist/entry/content/{core → lifecycle}/context/Context.d.ts +4 -2
- package/dist/entry/content/lifecycle/context/Context.js +73 -0
- package/dist/entry/content/lifecycle/context/Context.js.map +1 -0
- package/dist/entry/content/{core → lifecycle}/context/EventEmitter.d.ts +2 -2
- package/dist/entry/content/{core → lifecycle}/context/EventEmitter.js +3 -3
- package/dist/entry/content/lifecycle/context/EventEmitter.js.map +1 -0
- package/dist/entry/content/lifecycle/context/ManagedContext.d.ts +5 -0
- package/dist/entry/content/{core → lifecycle}/context/ManagedContext.js +2 -2
- package/dist/entry/content/lifecycle/context/ManagedContext.js.map +1 -0
- package/dist/entry/content/lifecycle/context/index.js.map +1 -0
- package/dist/entry/content/{core → lifecycle}/markers/AbstractMarker.d.ts +2 -2
- package/dist/entry/content/{core → lifecycle}/markers/AbstractMarker.js +3 -3
- package/dist/entry/content/lifecycle/markers/AbstractMarker.js.map +1 -0
- package/dist/entry/content/{core → lifecycle}/markers/AttributeMarker.d.ts +2 -2
- package/dist/entry/content/{core → lifecycle}/markers/AttributeMarker.js +2 -2
- package/dist/entry/content/lifecycle/markers/AttributeMarker.js.map +1 -0
- package/dist/entry/content/{core → lifecycle}/markers/WeakMarker.d.ts +2 -2
- package/dist/entry/content/{core → lifecycle}/markers/WeakMarker.js +2 -2
- package/dist/entry/content/lifecycle/markers/WeakMarker.js.map +1 -0
- package/dist/entry/content/lifecycle/markers/index.js.map +1 -0
- package/dist/entry/content/{core → lifecycle}/nodes/EventNode.d.ts +4 -2
- package/dist/entry/content/{core → lifecycle}/nodes/EventNode.js +11 -2
- package/dist/entry/content/lifecycle/nodes/EventNode.js.map +1 -0
- package/dist/entry/content/{core → lifecycle}/nodes/FrameNode.d.ts +11 -5
- package/dist/entry/content/lifecycle/nodes/FrameNode.js +187 -0
- package/dist/entry/content/lifecycle/nodes/FrameNode.js.map +1 -0
- package/dist/entry/content/{core → lifecycle}/nodes/MarkerNode.d.ts +3 -2
- package/dist/entry/content/{core → lifecycle}/nodes/MarkerNode.js +5 -2
- package/dist/entry/content/lifecycle/nodes/MarkerNode.js.map +1 -0
- package/dist/entry/content/{core → lifecycle}/nodes/MountNode.d.ts +3 -2
- package/dist/entry/content/{core → lifecycle}/nodes/MountNode.js +5 -2
- package/dist/entry/content/lifecycle/nodes/MountNode.js.map +1 -0
- package/dist/entry/content/{core → lifecycle}/nodes/Node.d.ts +2 -2
- package/dist/entry/content/{core → lifecycle}/nodes/Node.js +2 -2
- package/dist/entry/content/lifecycle/nodes/Node.js.map +1 -0
- package/dist/entry/content/lifecycle/nodes/RenderNode.d.ts +19 -0
- package/dist/entry/content/lifecycle/nodes/RenderNode.js +75 -0
- package/dist/entry/content/lifecycle/nodes/RenderNode.js.map +1 -0
- package/dist/entry/content/lifecycle/nodes/ShadowNode.d.ts +21 -0
- package/dist/entry/content/lifecycle/nodes/ShadowNode.js +121 -0
- package/dist/entry/content/lifecycle/nodes/ShadowNode.js.map +1 -0
- package/dist/entry/content/{core → lifecycle}/nodes/index.d.ts +1 -0
- package/dist/entry/content/lifecycle/nodes/index.js +17 -0
- package/dist/entry/content/lifecycle/nodes/index.js.map +1 -0
- package/dist/entry/content/{core → lifecycle}/nodes/isolated-styles.d.ts +1 -1
- package/dist/entry/content/{core → lifecycle}/nodes/isolated-styles.js +2 -2
- package/dist/entry/content/lifecycle/nodes/isolated-styles.js.map +1 -0
- package/dist/entry/content/resolvers/anchor.d.ts +2 -0
- package/dist/entry/content/{core/resolvers → resolvers}/anchor.js +2 -2
- package/dist/entry/content/resolvers/anchor.js.map +1 -0
- package/dist/entry/content/resolvers/container.d.ts +2 -0
- package/dist/entry/content/{core/resolvers → resolvers}/container.js +2 -2
- package/dist/entry/content/resolvers/container.js.map +1 -0
- package/dist/entry/content/resolvers/definition.d.ts +5 -0
- package/dist/entry/content/resolvers/definition.js +24 -0
- package/dist/entry/content/resolvers/definition.js.map +1 -0
- package/dist/entry/content/{core/resolvers → resolvers}/index.d.ts +1 -1
- package/dist/entry/content/{core/resolvers → resolvers}/index.js +1 -1
- package/dist/entry/content/resolvers/index.js.map +1 -0
- package/dist/entry/content/resolvers/mount.d.ts +2 -0
- package/dist/entry/content/{core/resolvers → resolvers}/mount.js +3 -3
- package/dist/entry/content/resolvers/mount.js.map +1 -0
- package/dist/entry/content/resolvers/target.d.ts +3 -0
- package/dist/entry/content/resolvers/target.js +34 -0
- package/dist/entry/content/resolvers/target.js.map +1 -0
- package/dist/entry/content/resolvers/watch.d.ts +6 -0
- package/dist/entry/content/{core/resolvers → resolvers}/watch.js +14 -10
- package/dist/entry/content/resolvers/watch.js.map +1 -0
- package/dist/entry/relay/Builder.d.ts +8 -8
- package/dist/entry/relay/Builder.js +28 -19
- package/dist/entry/relay/Builder.js.map +1 -1
- package/dist/entry/relay/TransportBuilder.d.ts +3 -2
- package/dist/entry/relay/TransportBuilder.js +3 -3
- package/dist/entry/relay/TransportBuilder.js.map +1 -1
- package/dist/entry/relay/index.d.ts +5 -2
- package/dist/entry/relay/index.js +8 -2
- package/dist/entry/relay/index.js.map +1 -1
- package/dist/entry/relay/resolvers/definition.d.ts +4 -0
- package/dist/entry/relay/resolvers/definition.js +16 -0
- package/dist/entry/relay/resolvers/definition.js.map +1 -0
- package/dist/main/content.d.ts +4 -6
- package/dist/main/content.js +3 -16
- package/dist/main/content.js.map +1 -1
- package/dist/main/entrypoint.js +1 -1
- package/dist/main/entrypoint.js.map +1 -1
- package/dist/main/relay.d.ts +2 -1
- package/dist/main/relay.js.map +1 -1
- package/dist/relay/RelayPermission.js +1 -1
- package/dist/shared/content/isolation.d.ts +1 -1
- package/dist/shared/content/isolation.js +13 -20
- package/dist/shared/content/isolation.js.map +1 -1
- package/dist/types/content/adapters/index.d.ts +2 -0
- package/dist/types/content/adapters/index.js +1 -0
- package/dist/types/content/adapters/index.js.map +1 -0
- package/dist/types/content/adapters/react.d.ts +4 -0
- package/dist/types/content/adapters/react.js +1 -0
- package/dist/types/content/adapters/react.js.map +1 -0
- package/dist/types/content/adapters/vanilla.d.ts +1 -0
- package/dist/types/content/adapters/vanilla.js +1 -0
- package/dist/types/content/adapters/vanilla.js.map +1 -0
- package/dist/types/content/boundary.d.ts +17 -0
- package/dist/types/content/boundary.js +1 -0
- package/dist/types/content/boundary.js.map +1 -0
- package/dist/types/{content.d.ts → content/common.d.ts} +24 -53
- package/dist/types/{content.js → content/common.js} +1 -1
- package/dist/types/content/common.js.map +1 -0
- package/dist/types/content/definition.d.ts +61 -0
- package/dist/types/content/definition.js +1 -0
- package/dist/types/content/definition.js.map +1 -0
- package/dist/types/content/index.d.ts +7 -0
- package/dist/types/content/index.js +2 -0
- package/dist/types/content/index.js.map +1 -0
- package/dist/types/content/prepare.d.ts +9 -0
- package/dist/types/content/prepare.js +1 -0
- package/dist/types/content/prepare.js.map +1 -0
- package/dist/types/content/render.d.ts +6 -0
- package/dist/types/content/render.js +1 -0
- package/dist/types/content/render.js.map +1 -0
- package/dist/types/content/target.d.ts +13 -0
- package/dist/types/content/target.js +1 -0
- package/dist/types/content/target.js.map +1 -0
- package/dist/types/manifest.d.ts +1 -1
- package/dist/types/relay.d.ts +3 -4
- package/dist/types/relay.js.map +1 -1
- package/dist/virtual/modules.d.ts +4 -3
- package/dist/virtual/{entrypoint.d.ts → runtime.d.ts} +3 -0
- package/dist/virtual/runtime.js +9 -0
- package/dist/virtual/runtime.js.map +1 -0
- package/package.json +32 -23
- package/scripts/merge-coverage.mjs +12 -0
- package/scripts/pre-commit.mjs +22 -0
- package/scripts/test-inventory.mjs +38 -0
- package/scripts/test-run.mjs +25 -0
- package/dist/cli/bundler/plugins/build-assets-map/entrypoint-module.d.ts +0 -13
- package/dist/cli/bundler/plugins/build-assets-map/entrypoint-module.js +0 -16
- package/dist/cli/bundler/plugins/build-assets-map/entrypoint-module.js.map +0 -1
- package/dist/cli/bundler/utils/layers.js.map +0 -1
- package/dist/cli/bundler/utils/output.d.ts +0 -6
- package/dist/cli/bundler/utils/output.js.map +0 -1
- package/dist/cli/bundler/utils/styles.d.ts +0 -5
- package/dist/cli/bundler/utils/styles.js.map +0 -1
- package/dist/cli/plugins/output.d.ts +0 -2
- package/dist/cli/plugins/output.js.map +0 -1
- package/dist/entry/content/adapters/react/resolvers/index.d.ts +0 -1
- package/dist/entry/content/adapters/react/resolvers/index.js +0 -2
- package/dist/entry/content/adapters/react/resolvers/index.js.map +0 -1
- package/dist/entry/content/core/Builder.d.ts +0 -26
- package/dist/entry/content/core/Builder.js +0 -128
- package/dist/entry/content/core/Builder.js.map +0 -1
- package/dist/entry/content/core/MountBuilder.d.ts +0 -10
- package/dist/entry/content/core/MountBuilder.js +0 -48
- package/dist/entry/content/core/MountBuilder.js.map +0 -1
- package/dist/entry/content/core/context/Context.js +0 -50
- package/dist/entry/content/core/context/Context.js.map +0 -1
- package/dist/entry/content/core/context/EventEmitter.js.map +0 -1
- package/dist/entry/content/core/context/ManagedContext.d.ts +0 -5
- package/dist/entry/content/core/context/ManagedContext.js.map +0 -1
- package/dist/entry/content/core/context/index.js.map +0 -1
- package/dist/entry/content/core/markers/AbstractMarker.js.map +0 -1
- package/dist/entry/content/core/markers/AttributeMarker.js.map +0 -1
- package/dist/entry/content/core/markers/WeakMarker.js.map +0 -1
- package/dist/entry/content/core/markers/index.js.map +0 -1
- package/dist/entry/content/core/nodes/EventNode.js.map +0 -1
- package/dist/entry/content/core/nodes/FrameNode.js +0 -125
- package/dist/entry/content/core/nodes/FrameNode.js.map +0 -1
- package/dist/entry/content/core/nodes/MarkerNode.js.map +0 -1
- package/dist/entry/content/core/nodes/MountNode.js.map +0 -1
- package/dist/entry/content/core/nodes/Node.js.map +0 -1
- package/dist/entry/content/core/nodes/ShadowNode.d.ts +0 -14
- package/dist/entry/content/core/nodes/ShadowNode.js +0 -67
- package/dist/entry/content/core/nodes/ShadowNode.js.map +0 -1
- package/dist/entry/content/core/nodes/index.js +0 -15
- package/dist/entry/content/core/nodes/index.js.map +0 -1
- package/dist/entry/content/core/nodes/isolated-styles.js.map +0 -1
- package/dist/entry/content/core/resolvers/anchor.d.ts +0 -2
- package/dist/entry/content/core/resolvers/anchor.js.map +0 -1
- package/dist/entry/content/core/resolvers/container.d.ts +0 -2
- package/dist/entry/content/core/resolvers/container.js.map +0 -1
- package/dist/entry/content/core/resolvers/definition.d.ts +0 -3
- package/dist/entry/content/core/resolvers/definition.js +0 -12
- package/dist/entry/content/core/resolvers/definition.js.map +0 -1
- package/dist/entry/content/core/resolvers/index.js.map +0 -1
- package/dist/entry/content/core/resolvers/mount.d.ts +0 -2
- package/dist/entry/content/core/resolvers/mount.js.map +0 -1
- package/dist/entry/content/core/resolvers/render.d.ts +0 -3
- package/dist/entry/content/core/resolvers/render.js +0 -18
- package/dist/entry/content/core/resolvers/render.js.map +0 -1
- package/dist/entry/content/core/resolvers/watch.d.ts +0 -4
- package/dist/entry/content/core/resolvers/watch.js.map +0 -1
- package/dist/entry/content/frame/Builder.d.ts +0 -7
- package/dist/entry/content/frame/Builder.js +0 -14
- package/dist/entry/content/frame/Builder.js.map +0 -1
- package/dist/entry/content/frame/index.d.ts +0 -4
- package/dist/entry/content/frame/index.js +0 -7
- package/dist/entry/content/frame/index.js.map +0 -1
- package/dist/types/content.js.map +0 -1
- package/dist/virtual/entrypoint.js +0 -7
- package/dist/virtual/entrypoint.js.map +0 -1
- /package/dist/entry/content/{core → lifecycle}/context/index.d.ts +0 -0
- /package/dist/entry/content/{core → lifecycle}/context/index.js +0 -0
- /package/dist/entry/content/{core → lifecycle}/markers/index.d.ts +0 -0
- /package/dist/entry/content/{core → lifecycle}/markers/index.js +0 -0
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import Builder from "./Builder.js";
|
|
2
|
+
import type { RelayUnresolvedDefinition } from "../../types/relay.js";
|
|
3
|
+
import type { TransportType } from "../../types/transport.js";
|
|
4
|
+
import type { ContentScriptIsolation } from "../../types/content/index.js";
|
|
2
5
|
export { Builder };
|
|
6
|
+
export { resolveDefinition } from "./resolvers/definition.js";
|
|
3
7
|
export type { RelayUnresolvedDefinition } from "../../types/relay.js";
|
|
4
|
-
|
|
5
|
-
export default _default;
|
|
8
|
+
export default function relay<T extends TransportType, Data = unknown, Isolation extends `${ContentScriptIsolation}` = `${ContentScriptIsolation}`>(definition: RelayUnresolvedDefinition<T, Data, Isolation>, contentBuilder: ConstructorParameters<typeof Builder<T, Data, NoInfer<Isolation>>>[1]): void;
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import Builder from "./Builder.js";
|
|
2
|
-
|
|
2
|
+
import { resolveDefinition } from "./resolvers/definition.js";
|
|
3
|
+
function relay(definition, contentBuilder) {
|
|
4
|
+
new Builder(definition, contentBuilder).build().catch((error) => {
|
|
5
|
+
console.error("Failed to build relay: ", error);
|
|
6
|
+
});
|
|
7
|
+
}
|
|
3
8
|
export {
|
|
4
9
|
Builder,
|
|
5
|
-
|
|
10
|
+
relay as default,
|
|
11
|
+
resolveDefinition
|
|
6
12
|
};
|
|
7
13
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/entry/relay/index.ts"],"sourcesContent":["import Builder from \"./Builder\";\n\nexport {Builder};\nexport type {RelayUnresolvedDefinition} from \"@typing/relay\";\n\nexport default Builder.
|
|
1
|
+
{"version":3,"sources":["../../../src/entry/relay/index.ts"],"sourcesContent":["import Builder from \"./Builder\";\n\nimport type {RelayUnresolvedDefinition} from \"@typing/relay\";\nimport type {TransportType} from \"@typing/transport\";\nimport type {ContentScriptIsolation} from \"@typing/content\";\n\nexport {Builder};\nexport {resolveDefinition} from \"./resolvers/definition\";\nexport type {RelayUnresolvedDefinition} from \"@typing/relay\";\n\nexport default function relay<\n T extends TransportType,\n Data = unknown,\n Isolation extends `${ContentScriptIsolation}` = `${ContentScriptIsolation}`,\n>(\n definition: RelayUnresolvedDefinition<T, Data, Isolation>,\n contentBuilder: ConstructorParameters<typeof Builder<T, Data, NoInfer<Isolation>>>[1]\n): void {\n new Builder(definition, contentBuilder).build().catch(error => {\n console.error(\"Failed to build relay: \", error);\n });\n}\n"],"mappings":"AAAA,OAAO,aAAa;AAOpB,SAAQ,yBAAwB;AAGjB,SAAR,MAKH,YACA,gBACI;AACJ,MAAI,QAAQ,YAAY,cAAc,EAAE,MAAM,EAAE,MAAM,WAAS;AAC3D,YAAQ,MAAM,2BAA2B,KAAK;AAAA,EAClD,CAAC;AACL;","names":[]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { RelayUnresolvedDefinition } from "../../../types/relay.js";
|
|
2
|
+
import type { TransportType } from "../../../types/transport.js";
|
|
3
|
+
/** Resolve Relay exports without executing init; the build supplies the authoritative name. */
|
|
4
|
+
export declare const resolveDefinition: <T extends TransportType = TransportType>(module: object, name: string) => RelayUnresolvedDefinition<T>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { isValidTransportDefinition, isValidTransportInitFunction } from "./../../../entry/transport/resolvers/definition.js";
|
|
2
|
+
const resolveDefinition = (module, name) => {
|
|
3
|
+
const { default: defaultDefinition, ...otherDefinition } = module;
|
|
4
|
+
let definition = otherDefinition;
|
|
5
|
+
if (isValidTransportDefinition(defaultDefinition)) {
|
|
6
|
+
definition = { ...definition, ...defaultDefinition };
|
|
7
|
+
} else if (isValidTransportInitFunction(defaultDefinition)) {
|
|
8
|
+
definition = { ...definition, init: defaultDefinition };
|
|
9
|
+
}
|
|
10
|
+
const { init, main, name: _name, ...options } = definition;
|
|
11
|
+
return { name, init, main, ...options };
|
|
12
|
+
};
|
|
13
|
+
export {
|
|
14
|
+
resolveDefinition
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=definition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/entry/relay/resolvers/definition.ts"],"sourcesContent":["import {isValidTransportDefinition, isValidTransportInitFunction} from \"@entry/transport/resolvers/definition\";\n\nimport type {RelayOptions, RelayUnresolvedDefinition} from \"@typing/relay\";\nimport type {TransportType} from \"@typing/transport\";\n\n/** Resolve Relay exports without executing init; the build supplies the authoritative name. */\nexport const resolveDefinition = <T extends TransportType = TransportType>(\n module: object,\n name: string\n): RelayUnresolvedDefinition<T> => {\n const {default: defaultDefinition, ...otherDefinition} = module as Record<string, unknown>;\n\n let definition = otherDefinition as RelayUnresolvedDefinition<T>;\n\n if (isValidTransportDefinition<RelayOptions, T>(defaultDefinition)) {\n definition = {...definition, ...defaultDefinition};\n } else if (isValidTransportInitFunction<RelayOptions, T>(defaultDefinition)) {\n definition = {...definition, init: defaultDefinition};\n }\n\n const {init, main, name: _name, ...options} = definition;\n\n return {name, init, main, ...options};\n};\n"],"mappings":"AAAA,SAAQ,4BAA4B,oCAAmC;AAMhE,MAAM,oBAAoB,CAC7B,QACA,SAC+B;AAC/B,QAAM,EAAC,SAAS,mBAAmB,GAAG,gBAAe,IAAI;AAEzD,MAAI,aAAa;AAEjB,MAAI,2BAA4C,iBAAiB,GAAG;AAChE,iBAAa,EAAC,GAAG,YAAY,GAAG,kBAAiB;AAAA,EACrD,WAAW,6BAA8C,iBAAiB,GAAG;AACzE,iBAAa,EAAC,GAAG,YAAY,MAAM,kBAAiB;AAAA,EACxD;AAEA,QAAM,EAAC,MAAM,MAAM,MAAM,OAAO,GAAG,QAAO,IAAI;AAE9C,SAAO,EAAC,MAAM,MAAM,MAAM,GAAG,QAAO;AACxC;","names":[]}
|
package/dist/main/content.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export declare const defineContentScript: (options: ContentScriptDefinition) => ContentScriptDefinition;
|
|
6
|
-
export declare const defineContentScriptAppend: (options: ContentScriptAppendDefinition) => ContentScriptDefinition;
|
|
1
|
+
import { ContentScriptAppendDefinition, ContentScriptDefinition, ContentScriptIsolation } from "../types/content/index.js";
|
|
2
|
+
export * from "../types/content/index.js";
|
|
3
|
+
export declare const defineContentScript: <Data = undefined, const Isolation extends `${ContentScriptIsolation}` = "none">(options: ContentScriptDefinition<Data, Isolation>) => ContentScriptDefinition<Data, Isolation>;
|
|
4
|
+
export declare const defineContentScriptAppend: <Data = undefined, const Isolation extends `${ContentScriptIsolation}` = "none">(options: ContentScriptAppendDefinition<Data, Isolation>) => ContentScriptDefinition<Data, Isolation>;
|
package/dist/main/content.js
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
contentScriptAnchorResolver,
|
|
4
|
-
contentScriptAwaitFirstResolver,
|
|
5
|
-
contentScriptMutationObserverResolver,
|
|
6
|
-
contentScriptRenderResolver,
|
|
7
|
-
contentScriptContainerResolver
|
|
8
|
-
} from "./../entry/content/core/resolvers/index.js";
|
|
9
|
-
export * from "./../types/content.js";
|
|
1
|
+
import { createAppendMountHandler } from "./../entry/content/resolvers/mount.js";
|
|
2
|
+
export * from "./../types/content/index.js";
|
|
10
3
|
const defineContentScript = (options) => {
|
|
11
4
|
return options;
|
|
12
5
|
};
|
|
@@ -14,16 +7,10 @@ const defineContentScriptAppend = (options) => {
|
|
|
14
7
|
const { append, ...definition } = options;
|
|
15
8
|
return {
|
|
16
9
|
...definition,
|
|
17
|
-
mount:
|
|
10
|
+
mount: createAppendMountHandler(append)
|
|
18
11
|
};
|
|
19
12
|
};
|
|
20
13
|
export {
|
|
21
|
-
contentScriptAnchorResolver,
|
|
22
|
-
contentScriptAwaitFirstResolver,
|
|
23
|
-
contentScriptContainerResolver,
|
|
24
|
-
contentScriptMountAppendResolver,
|
|
25
|
-
contentScriptMutationObserverResolver,
|
|
26
|
-
contentScriptRenderResolver,
|
|
27
14
|
defineContentScript,
|
|
28
15
|
defineContentScriptAppend
|
|
29
16
|
};
|
package/dist/main/content.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/main/content.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../src/main/content.ts"],"sourcesContent":["import {createAppendMountHandler} from \"@entry/content/resolvers/mount\";\n\nimport {ContentScriptAppendDefinition, ContentScriptDefinition, ContentScriptIsolation} from \"@typing/content\";\n\nexport * from \"@typing/content\";\n\nexport const defineContentScript = <Data = undefined, const Isolation extends `${ContentScriptIsolation}` = \"none\">(\n options: ContentScriptDefinition<Data, Isolation>\n): ContentScriptDefinition<Data, Isolation> => {\n return options;\n};\n\nexport const defineContentScriptAppend = <\n Data = undefined,\n const Isolation extends `${ContentScriptIsolation}` = \"none\",\n>(\n options: ContentScriptAppendDefinition<Data, Isolation>\n): ContentScriptDefinition<Data, Isolation> => {\n const {append, ...definition} = options;\n\n return {\n ...definition,\n mount: createAppendMountHandler(append),\n } as ContentScriptDefinition<Data, Isolation>;\n};\n"],"mappings":"AAAA,SAAQ,gCAA+B;AAIvC,cAAc;AAEP,MAAM,sBAAsB,CAC/B,YAC2C;AAC3C,SAAO;AACX;AAEO,MAAM,4BAA4B,CAIrC,YAC2C;AAC3C,QAAM,EAAC,QAAQ,GAAG,WAAU,IAAI;AAEhC,SAAO;AAAA,IACH,GAAG;AAAA,IACH,OAAO,yBAAyB,MAAM;AAAA,EAC1C;AACJ;","names":[]}
|
package/dist/main/entrypoint.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/main/entrypoint.ts"],"sourcesContent":["import {readAssets, readAssetsMap} from \"#adnbn/
|
|
1
|
+
{"version":3,"sources":["../../src/main/entrypoint.ts"],"sourcesContent":["import {readAssets, readAssetsMap} from \"#adnbn/runtime\";\n\nimport type {EntrypointAssets, EntrypointAssetsMap} from \"@typing/entrypoint\";\n\nexport type {\n EntrypointAssets,\n EntrypointAssetsFiles,\n EntrypointAssetsMap,\n EntrypointAssetsMapEntry,\n} from \"@typing/entrypoint\";\n\nexport const getEntrypointAssetsMap = (): EntrypointAssetsMap => {\n const assets = readAssetsMap();\n\n if (!assets) {\n throw new Error(\"getEntrypointAssetsMap() is available only in the background entrypoint\");\n }\n\n return assets;\n};\n\nexport const getEntrypointAssets = (): EntrypointAssets => {\n const assets = readAssets();\n\n if (!assets) {\n throw new Error(\"Current entrypoint assets are unavailable in this runtime\");\n }\n\n return assets;\n};\n"],"mappings":"AAAA,SAAQ,YAAY,qBAAoB;AAWjC,MAAM,yBAAyB,MAA2B;AAC7D,QAAM,SAAS,cAAc;AAE7B,MAAI,CAAC,QAAQ;AACT,UAAM,IAAI,MAAM,yEAAyE;AAAA,EAC7F;AAEA,SAAO;AACX;AAEO,MAAM,sBAAsB,MAAwB;AACvD,QAAM,SAAS,WAAW;AAE1B,MAAI,CAAC,QAAQ;AACT,UAAM,IAAI,MAAM,2DAA2D;AAAA,EAC/E;AAEA,SAAO;AACX;","names":[]}
|
package/dist/main/relay.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { TransportType } from "../types/transport.js";
|
|
2
|
+
import type { ContentScriptIsolation } from "../types/content/index.js";
|
|
2
3
|
import { RelayDefinition, RelayAllFrames, RelayFrameErrorKind, RelayMethod, type RelayBatchOptions, type RelayBatchProxyTarget, type RelayName, type RelayProxyTarget, type RelayScalarOptions } from "../types/relay.js";
|
|
3
4
|
export { RelayAllFrames, RelayFrameErrorKind, RelayMethod };
|
|
4
5
|
export { RelayDiscoveryError } from "../relay/discovery/RelayDiscovery.js";
|
|
5
6
|
export type { RelayAllFramesOptions, RelayAnyFramesOptions, RelayBatchOptions, RelayBatchProxyTarget, RelayBatchRpcProxy, RelayCallOptions, RelayDocumentOptions, RelayDocumentsOptions, RelayExecutionOptions, RelayEveryFrameOptions, RelayFrameError, RelayFrameOptions, RelayFrameResult, RelayFramesOptions, RelayFramesResult, RelayNonEmptyReadonlyArray, RelayProxyTarget, RelayResultTarget, RelayScalarOptions, RelayTopFrameOptions, RelayDefinition, } from "../types/relay.js";
|
|
6
|
-
export declare const defineRelay: <T extends TransportType>(options: RelayDefinition<T>) => RelayDefinition<T>;
|
|
7
|
+
export declare const defineRelay: <T extends TransportType, Data = undefined, const Isolation extends `${ContentScriptIsolation}` = "none">(options: RelayDefinition<T, Data, Isolation>) => RelayDefinition<T, Data, Isolation>;
|
|
7
8
|
export declare function getRelay<N extends RelayName>(name: N, params: number | RelayScalarOptions): RelayProxyTarget<N>;
|
|
8
9
|
export declare function getRelay<N extends RelayName>(name: N, params: RelayBatchOptions): RelayBatchProxyTarget<N>;
|
package/dist/main/relay.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/main/relay.ts"],"sourcesContent":["import RelayPermission from \"@relay/RelayPermission\";\nimport {ProxyRelay, type ProxyRelayParams} from \"@relay/providers\";\nimport {options as relayOptions} from \"#adnbn/relay\";\n\nimport type {TransportType} from \"@typing/transport\";\nimport {\n RelayDefinition,\n RelayAllFrames,\n RelayFrameErrorKind,\n RelayMethod,\n RelayOptionsMap,\n type RelayBatchOptions,\n type RelayBatchProxyTarget,\n type RelayName,\n type RelayProxyTarget,\n type RelayScalarOptions,\n} from \"@typing/relay\";\n\nexport {RelayAllFrames, RelayFrameErrorKind, RelayMethod};\nexport {RelayDiscoveryError} from \"@relay/discovery/RelayDiscovery\";\nexport type {\n RelayAllFramesOptions,\n RelayAnyFramesOptions,\n RelayBatchOptions,\n RelayBatchProxyTarget,\n RelayBatchRpcProxy,\n RelayCallOptions,\n RelayDocumentOptions,\n RelayDocumentsOptions,\n RelayExecutionOptions,\n RelayEveryFrameOptions,\n RelayFrameError,\n RelayFrameOptions,\n RelayFrameResult,\n RelayFramesOptions,\n RelayFramesResult,\n RelayNonEmptyReadonlyArray,\n RelayProxyTarget,\n RelayResultTarget,\n RelayScalarOptions,\n RelayTopFrameOptions,\n RelayDefinition,\n} from \"@typing/relay\";\n\nexport const defineRelay =
|
|
1
|
+
{"version":3,"sources":["../../src/main/relay.ts"],"sourcesContent":["import RelayPermission from \"@relay/RelayPermission\";\nimport {ProxyRelay, type ProxyRelayParams} from \"@relay/providers\";\nimport {options as relayOptions} from \"#adnbn/relay\";\n\nimport type {TransportType} from \"@typing/transport\";\nimport type {ContentScriptIsolation} from \"@typing/content\";\n\nimport {\n RelayDefinition,\n RelayAllFrames,\n RelayFrameErrorKind,\n RelayMethod,\n RelayOptionsMap,\n type RelayBatchOptions,\n type RelayBatchProxyTarget,\n type RelayName,\n type RelayProxyTarget,\n type RelayScalarOptions,\n} from \"@typing/relay\";\n\nexport {RelayAllFrames, RelayFrameErrorKind, RelayMethod};\nexport {RelayDiscoveryError} from \"@relay/discovery/RelayDiscovery\";\n\nexport type {\n RelayAllFramesOptions,\n RelayAnyFramesOptions,\n RelayBatchOptions,\n RelayBatchProxyTarget,\n RelayBatchRpcProxy,\n RelayCallOptions,\n RelayDocumentOptions,\n RelayDocumentsOptions,\n RelayExecutionOptions,\n RelayEveryFrameOptions,\n RelayFrameError,\n RelayFrameOptions,\n RelayFrameResult,\n RelayFramesOptions,\n RelayFramesResult,\n RelayNonEmptyReadonlyArray,\n RelayProxyTarget,\n RelayResultTarget,\n RelayScalarOptions,\n RelayTopFrameOptions,\n RelayDefinition,\n} from \"@typing/relay\";\n\nexport const defineRelay = <\n T extends TransportType,\n Data = undefined,\n const Isolation extends `${ContentScriptIsolation}` = \"none\",\n>(\n options: RelayDefinition<T, Data, Isolation>\n): RelayDefinition<T, Data, Isolation> => {\n return options;\n};\n\nconst getRelayOptionsMap = (): RelayOptionsMap => {\n const relays: RelayOptionsMap = new Map();\n\n try {\n Object.entries(relayOptions).forEach(([name, options]) => relays.set(name, options));\n } catch (e) {\n console.error(\"Failed getting relays: \", e);\n }\n\n return relays;\n};\n\nexport function getRelay<N extends RelayName>(name: N, params: number | RelayScalarOptions): RelayProxyTarget<N>;\n\nexport function getRelay<N extends RelayName>(name: N, params: RelayBatchOptions): RelayBatchProxyTarget<N>;\n\nexport function getRelay<N extends RelayName>(\n name: N,\n params: ProxyRelayParams\n): RelayProxyTarget<N> | RelayBatchProxyTarget<N> {\n const relays = getRelayOptionsMap();\n const options = relays.get(name);\n\n if (!options) {\n throw new Error(`Failed to get relay \"${name}\"`);\n }\n\n return new ProxyRelay(name, options, params, RelayPermission.getInstance(relays)).get() as\n | RelayProxyTarget<N>\n | RelayBatchProxyTarget<N>;\n}\n"],"mappings":"AAAA,OAAO,qBAAqB;AAC5B,SAAQ,kBAAwC;AAChD,SAAQ,WAAW,oBAAmB;AAKtC;AAAA,EAEI;AAAA,EACA;AAAA,EACA;AAAA,OAOG;AAGP,SAAQ,2BAA0B;AA0B3B,MAAM,cAAc,CAKvB,YACsC;AACtC,SAAO;AACX;AAEA,MAAM,qBAAqB,MAAuB;AAC9C,QAAM,SAA0B,oBAAI,IAAI;AAExC,MAAI;AACA,WAAO,QAAQ,YAAY,EAAE,QAAQ,CAAC,CAAC,MAAM,OAAO,MAAM,OAAO,IAAI,MAAM,OAAO,CAAC;AAAA,EACvF,SAAS,GAAG;AACR,YAAQ,MAAM,2BAA2B,CAAC;AAAA,EAC9C;AAEA,SAAO;AACX;AAMO,SAAS,SACZ,MACA,QAC8C;AAC9C,QAAM,SAAS,mBAAmB;AAClC,QAAM,UAAU,OAAO,IAAI,IAAI;AAE/B,MAAI,CAAC,SAAS;AACV,UAAM,IAAI,MAAM,wBAAwB,IAAI,GAAG;AAAA,EACnD;AAEA,SAAO,IAAI,WAAW,MAAM,SAAS,QAAQ,gBAAgB,YAAY,MAAM,CAAC,EAAE,IAAI;AAG1F;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { containsPermissions, onPermissionsAdded, onPermissionsRemoved, requestPermissions } from "@addon-core/browser";
|
|
2
2
|
import { RelayMethod } from "./../types/relay.js";
|
|
3
|
-
import { ContentScriptDeclarative } from "./../types/content.js";
|
|
3
|
+
import { ContentScriptDeclarative } from "./../types/content/index.js";
|
|
4
4
|
const RelayPermissionGlobalKey = "adnbnRelayPermission";
|
|
5
5
|
class RelayPermission {
|
|
6
6
|
permissions = /* @__PURE__ */ new Map();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ContentScriptIsolationOptions, type ContentScriptIsolationFrameOptions, type ContentScriptFramePageOptions, type ContentScriptFrameSourceOptions } from "../../types/content.js";
|
|
1
|
+
import { type ContentScriptIsolationOptions, type ContentScriptIsolationFrameOptions, type ContentScriptFramePageOptions, type ContentScriptFrameSourceOptions } from "../../types/content/index.js";
|
|
2
2
|
export declare const isContentScriptFrameNavigation: (isolation: unknown) => isolation is ContentScriptIsolationFrameOptions & (ContentScriptFramePageOptions | ContentScriptFrameSourceOptions);
|
|
3
3
|
/** Pure normalization and structural validation, shared by CLI and runtime. */
|
|
4
4
|
export declare const resolveContentScriptIsolation: (value: unknown, hasRender?: boolean) => ContentScriptIsolationOptions;
|
|
@@ -1,34 +1,40 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ContentScriptIsolation,
|
|
3
3
|
ContentScriptShadowMode
|
|
4
|
-
} from "./../../types/content.js";
|
|
4
|
+
} from "./../../types/content/index.js";
|
|
5
5
|
const isContentScriptFrameNavigation = (isolation) => !!isolation && typeof isolation === "object" && "type" in isolation && isolation.type === ContentScriptIsolation.Iframe && ("page" in isolation && isolation.page !== void 0 || "src" in isolation && isolation.src !== void 0);
|
|
6
6
|
const resolveContentScriptIsolation = (value, hasRender = false) => {
|
|
7
7
|
const options = value === void 0 ? { type: ContentScriptIsolation.None } : typeof value === "string" ? { type: value } : value;
|
|
8
8
|
if (!options || typeof options !== "object" || Array.isArray(options)) {
|
|
9
9
|
throw new Error("isolation must be none, shadow, iframe, or an options object with type");
|
|
10
10
|
}
|
|
11
|
-
const { type, mode, page, src
|
|
11
|
+
const { type, mode, page, src } = options;
|
|
12
12
|
if (!Object.values(ContentScriptIsolation).includes(type)) {
|
|
13
13
|
throw new Error(
|
|
14
14
|
"isolation.type must be a statically known ContentScriptIsolation value: none, shadow or iframe"
|
|
15
15
|
);
|
|
16
16
|
}
|
|
17
|
-
const keys = type === ContentScriptIsolation.Shadow ? ["type", "mode"] : type === ContentScriptIsolation.Iframe ? ["type", "page", "src"
|
|
17
|
+
const keys = type === ContentScriptIsolation.Shadow ? ["type", "mode"] : type === ContentScriptIsolation.Iframe ? ["type", "page", "src"] : ["type"];
|
|
18
18
|
for (const key of Object.keys(options)) {
|
|
19
|
-
if (!keys.includes(key))
|
|
19
|
+
if (!keys.includes(key)) {
|
|
20
|
+
throw new Error(`isolation.${key} is not supported for isolation type "${type}"`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if (type === ContentScriptIsolation.None) {
|
|
24
|
+
return { type };
|
|
20
25
|
}
|
|
21
|
-
if (type === ContentScriptIsolation.None) return { type };
|
|
22
26
|
if (type === ContentScriptIsolation.Shadow) {
|
|
23
27
|
if (mode !== void 0 && !Object.values(ContentScriptShadowMode).includes(mode)) {
|
|
24
28
|
throw new Error('isolation.mode must be "open" or "closed"');
|
|
25
29
|
}
|
|
26
30
|
return { type, mode: mode ?? ContentScriptShadowMode.Open };
|
|
27
31
|
}
|
|
28
|
-
if (page !== void 0 && src !== void 0)
|
|
32
|
+
if (page !== void 0 && src !== void 0) {
|
|
29
33
|
throw new Error("isolation.page and isolation.src are mutually exclusive");
|
|
30
|
-
|
|
34
|
+
}
|
|
35
|
+
if (page !== void 0 && (typeof page !== "string" || !page.trim())) {
|
|
31
36
|
throw new Error("isolation.page must be a statically known page alias");
|
|
37
|
+
}
|
|
32
38
|
if (src !== void 0) {
|
|
33
39
|
if (typeof src !== "string" || !/^(https?|chrome-extension|moz-extension):\/\//.test(src)) {
|
|
34
40
|
throw new Error("isolation.src must be an absolute HTTP(S) or extension URL");
|
|
@@ -44,21 +50,8 @@ const resolveContentScriptIsolation = (value, hasRender = false) => {
|
|
|
44
50
|
"isolation.page/isolation.src cannot be combined with render; the embedded page owns its UI and resources"
|
|
45
51
|
);
|
|
46
52
|
}
|
|
47
|
-
for (const [name, size] of [
|
|
48
|
-
["width", width],
|
|
49
|
-
["height", height]
|
|
50
|
-
]) {
|
|
51
|
-
if (size !== void 0 && !(typeof size === "number" && Number.isFinite(size) && size >= 0 || typeof size === "string" && size.trim())) {
|
|
52
|
-
throw new Error(`isolation.${name} must be pixels or a CSS size`);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
if (typeof height === "string" && height.trim().toLowerCase() === "auto") {
|
|
56
|
-
throw new Error('isolation.height: "auto" is not supported yet; specify an explicit height');
|
|
57
|
-
}
|
|
58
53
|
return {
|
|
59
54
|
type,
|
|
60
|
-
width: width ?? "100%",
|
|
61
|
-
height: height ?? 150,
|
|
62
55
|
...page === void 0 ? {} : { page },
|
|
63
56
|
...src === void 0 ? {} : { src }
|
|
64
57
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/shared/content/isolation.ts"],"sourcesContent":["import {\n ContentScriptIsolation,\n ContentScriptShadowMode,\n type ContentScriptIsolationOptions,\n type ContentScriptIsolationFrameOptions,\n type ContentScriptFramePageOptions,\n type ContentScriptFrameSourceOptions,\n} from \"@typing/content\";\n\nexport const isContentScriptFrameNavigation = (\n isolation: unknown\n): isolation is ContentScriptIsolationFrameOptions &\n (ContentScriptFramePageOptions | ContentScriptFrameSourceOptions) =>\n !!isolation &&\n typeof isolation === \"object\" &&\n \"type\" in isolation &&\n isolation.type === ContentScriptIsolation.Iframe &&\n ((\"page\" in isolation && isolation.page !== undefined) || (\"src\" in isolation && isolation.src !== undefined));\n\n/** Pure normalization and structural validation, shared by CLI and runtime. */\nexport const resolveContentScriptIsolation = (value: unknown, hasRender = false): ContentScriptIsolationOptions => {\n const options =\n value === undefined ? {type: ContentScriptIsolation.None} : typeof value === \"string\" ? {type: value} : value;\n if (!options || typeof options !== \"object\" || Array.isArray(options)) {\n throw new Error(\"isolation must be none, shadow, iframe, or an options object with type\");\n }\n const {type, mode, page, src
|
|
1
|
+
{"version":3,"sources":["../../../src/shared/content/isolation.ts"],"sourcesContent":["import {\n ContentScriptIsolation,\n ContentScriptShadowMode,\n type ContentScriptIsolationOptions,\n type ContentScriptIsolationFrameOptions,\n type ContentScriptFramePageOptions,\n type ContentScriptFrameSourceOptions,\n} from \"@typing/content\";\n\nexport const isContentScriptFrameNavigation = (\n isolation: unknown\n): isolation is ContentScriptIsolationFrameOptions &\n (ContentScriptFramePageOptions | ContentScriptFrameSourceOptions) =>\n !!isolation &&\n typeof isolation === \"object\" &&\n \"type\" in isolation &&\n isolation.type === ContentScriptIsolation.Iframe &&\n ((\"page\" in isolation && isolation.page !== undefined) || (\"src\" in isolation && isolation.src !== undefined));\n\n/** Pure normalization and structural validation, shared by CLI and runtime. */\nexport const resolveContentScriptIsolation = (value: unknown, hasRender = false): ContentScriptIsolationOptions => {\n const options =\n value === undefined ? {type: ContentScriptIsolation.None} : typeof value === \"string\" ? {type: value} : value;\n\n if (!options || typeof options !== \"object\" || Array.isArray(options)) {\n throw new Error(\"isolation must be none, shadow, iframe, or an options object with type\");\n }\n\n const {type, mode, page, src} = options as Record<string, unknown>;\n\n if (!Object.values(ContentScriptIsolation).includes(type as ContentScriptIsolation)) {\n throw new Error(\n \"isolation.type must be a statically known ContentScriptIsolation value: none, shadow or iframe\"\n );\n }\n\n const keys =\n type === ContentScriptIsolation.Shadow\n ? [\"type\", \"mode\"]\n : type === ContentScriptIsolation.Iframe\n ? [\"type\", \"page\", \"src\"]\n : [\"type\"];\n\n for (const key of Object.keys(options)) {\n if (!keys.includes(key)) {\n throw new Error(`isolation.${key} is not supported for isolation type \"${type}\"`);\n }\n }\n\n if (type === ContentScriptIsolation.None) {\n return {type};\n }\n\n if (type === ContentScriptIsolation.Shadow) {\n if (mode !== undefined && !Object.values(ContentScriptShadowMode).includes(mode as ContentScriptShadowMode)) {\n throw new Error('isolation.mode must be \"open\" or \"closed\"');\n }\n\n return {type, mode: (mode as ContentScriptShadowMode | undefined) ?? ContentScriptShadowMode.Open};\n }\n\n if (page !== undefined && src !== undefined) {\n throw new Error(\"isolation.page and isolation.src are mutually exclusive\");\n }\n\n if (page !== undefined && (typeof page !== \"string\" || !page.trim())) {\n throw new Error(\"isolation.page must be a statically known page alias\");\n }\n\n if (src !== undefined) {\n if (typeof src !== \"string\" || !/^(https?|chrome-extension|moz-extension):\\/\\//.test(src)) {\n throw new Error(\"isolation.src must be an absolute HTTP(S) or extension URL\");\n }\n\n try {\n new URL(src);\n } catch {\n throw new Error(\"isolation.src must be a valid absolute URL\");\n }\n }\n\n if ((page !== undefined || src !== undefined) && hasRender) {\n throw new Error(\n \"isolation.page/isolation.src cannot be combined with render; the embedded page owns its UI and resources\"\n );\n }\n\n return {\n type,\n ...(page === undefined ? {} : {page}),\n ...(src === undefined ? {} : {src}),\n } as ContentScriptIsolationFrameOptions;\n};\n"],"mappings":"AAAA;AAAA,EACI;AAAA,EACA;AAAA,OAKG;AAEA,MAAM,iCAAiC,CAC1C,cAGA,CAAC,CAAC,aACF,OAAO,cAAc,YACrB,UAAU,aACV,UAAU,SAAS,uBAAuB,WACxC,UAAU,aAAa,UAAU,SAAS,UAAe,SAAS,aAAa,UAAU,QAAQ;AAGhG,MAAM,gCAAgC,CAAC,OAAgB,YAAY,UAAyC;AAC/G,QAAM,UACF,UAAU,SAAY,EAAC,MAAM,uBAAuB,KAAI,IAAI,OAAO,UAAU,WAAW,EAAC,MAAM,MAAK,IAAI;AAE5G,MAAI,CAAC,WAAW,OAAO,YAAY,YAAY,MAAM,QAAQ,OAAO,GAAG;AACnE,UAAM,IAAI,MAAM,wEAAwE;AAAA,EAC5F;AAEA,QAAM,EAAC,MAAM,MAAM,MAAM,IAAG,IAAI;AAEhC,MAAI,CAAC,OAAO,OAAO,sBAAsB,EAAE,SAAS,IAA8B,GAAG;AACjF,UAAM,IAAI;AAAA,MACN;AAAA,IACJ;AAAA,EACJ;AAEA,QAAM,OACF,SAAS,uBAAuB,SAC1B,CAAC,QAAQ,MAAM,IACf,SAAS,uBAAuB,SAC9B,CAAC,QAAQ,QAAQ,KAAK,IACtB,CAAC,MAAM;AAEnB,aAAW,OAAO,OAAO,KAAK,OAAO,GAAG;AACpC,QAAI,CAAC,KAAK,SAAS,GAAG,GAAG;AACrB,YAAM,IAAI,MAAM,aAAa,GAAG,yCAAyC,IAAI,GAAG;AAAA,IACpF;AAAA,EACJ;AAEA,MAAI,SAAS,uBAAuB,MAAM;AACtC,WAAO,EAAC,KAAI;AAAA,EAChB;AAEA,MAAI,SAAS,uBAAuB,QAAQ;AACxC,QAAI,SAAS,UAAa,CAAC,OAAO,OAAO,uBAAuB,EAAE,SAAS,IAA+B,GAAG;AACzG,YAAM,IAAI,MAAM,2CAA2C;AAAA,IAC/D;AAEA,WAAO,EAAC,MAAM,MAAO,QAAgD,wBAAwB,KAAI;AAAA,EACrG;AAEA,MAAI,SAAS,UAAa,QAAQ,QAAW;AACzC,UAAM,IAAI,MAAM,yDAAyD;AAAA,EAC7E;AAEA,MAAI,SAAS,WAAc,OAAO,SAAS,YAAY,CAAC,KAAK,KAAK,IAAI;AAClE,UAAM,IAAI,MAAM,sDAAsD;AAAA,EAC1E;AAEA,MAAI,QAAQ,QAAW;AACnB,QAAI,OAAO,QAAQ,YAAY,CAAC,gDAAgD,KAAK,GAAG,GAAG;AACvF,YAAM,IAAI,MAAM,4DAA4D;AAAA,IAChF;AAEA,QAAI;AACA,UAAI,IAAI,GAAG;AAAA,IACf,QAAQ;AACJ,YAAM,IAAI,MAAM,4CAA4C;AAAA,IAChE;AAAA,EACJ;AAEA,OAAK,SAAS,UAAa,QAAQ,WAAc,WAAW;AACxD,UAAM,IAAI;AAAA,MACN;AAAA,IACJ;AAAA,EACJ;AAEA,SAAO;AAAA,IACH;AAAA,IACA,GAAI,SAAS,SAAY,CAAC,IAAI,EAAC,KAAI;AAAA,IACnC,GAAI,QAAQ,SAAY,CAAC,IAAI,EAAC,IAAG;AAAA,EACrC;AACJ;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { ContentScriptIsolation, ContentScriptProps } from "../common.js";
|
|
3
|
+
export type ContentScriptRenderReactComponent<Data = unknown, Isolation extends `${ContentScriptIsolation}` = `${ContentScriptIsolation}`> = (props: ContentScriptProps<Data, Isolation>) => Exclude<ReactNode, Promise<unknown>>;
|
|
4
|
+
export type ContentScriptReactRenderValue<Data = unknown, Isolation extends `${ContentScriptIsolation}` = `${ContentScriptIsolation}`> = Exclude<ReactNode, Promise<unknown>> | ContentScriptRenderReactComponent<Data, Isolation>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=react.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type ContentScriptVanillaRenderValue = Element | string | number | boolean | null | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=vanilla.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ContentScriptContainerProps, ContentScriptIsolation } from "./common.js";
|
|
2
|
+
export interface ContentScriptBoundaryMap {
|
|
3
|
+
none: undefined;
|
|
4
|
+
shadow: ShadowRoot;
|
|
5
|
+
iframe: HTMLIFrameElement;
|
|
6
|
+
}
|
|
7
|
+
/** The browser node implementing isolation, distinct from the container and render target. */
|
|
8
|
+
export type ContentScriptBoundary<Isolation extends `${ContentScriptIsolation}` = `${ContentScriptIsolation}`> = ContentScriptBoundaryMap[Isolation];
|
|
9
|
+
/** Available when isolation is created, before its target or child document is ready. */
|
|
10
|
+
export interface ContentScriptBoundaryProps<Data = unknown, Isolation extends `${ContentScriptIsolation}` = `${ContentScriptIsolation}`> extends ContentScriptContainerProps<Data> {
|
|
11
|
+
container: Element;
|
|
12
|
+
boundary: Exclude<ContentScriptBoundary<Isolation>, undefined>;
|
|
13
|
+
}
|
|
14
|
+
/** Releases user subscriptions before the boundary is removed. */
|
|
15
|
+
export type ContentScriptBoundaryCleanup = () => void;
|
|
16
|
+
/** Synchronous setup, once per boundary; return cleanup for subscriptions or observers. */
|
|
17
|
+
export type ContentScriptBoundaryHandler<Data = unknown, Isolation extends `${ContentScriptIsolation}` = `${ContentScriptIsolation}`> = (props: ContentScriptBoundaryProps<Data, Isolation>) => void | ContentScriptBoundaryCleanup;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=boundary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import type { ContentScriptPrepareProps } from "./prepare.js";
|
|
2
|
+
import type { ContentScriptBoundary } from "./boundary.js";
|
|
3
|
+
import type { PageAlias } from "../page.js";
|
|
4
|
+
import type { Optional } from "utility-types";
|
|
5
|
+
import type { EntrypointBuilder, EntrypointOptions } from "../entrypoint.js";
|
|
6
|
+
import type { Awaiter, PickNonFunctionProperties } from "../helpers.js";
|
|
6
7
|
export declare const ContentScriptMatches: string[];
|
|
7
8
|
/** Shared property used by the bundler plugin and the content script's style runtime getter. */
|
|
8
9
|
export declare const ContentScriptStylesRuntimeProperty = "__adnbnIsolatedStyles";
|
|
@@ -127,20 +128,15 @@ export interface ContentScriptShadowOptions {
|
|
|
127
128
|
*/
|
|
128
129
|
mode?: ContentScriptShadowMode | `${ContentScriptShadowMode}`;
|
|
129
130
|
}
|
|
130
|
-
export interface
|
|
131
|
-
width?: number | string;
|
|
132
|
-
/** Defaults to 150px. Automatic height is not supported yet. */
|
|
133
|
-
height?: number | string;
|
|
134
|
-
}
|
|
135
|
-
export interface ContentScriptFrameRenderOptions extends ContentScriptFrameOptions {
|
|
131
|
+
export interface ContentScriptFrameRenderOptions {
|
|
136
132
|
page?: never;
|
|
137
133
|
src?: never;
|
|
138
134
|
}
|
|
139
|
-
export interface ContentScriptFramePageOptions
|
|
135
|
+
export interface ContentScriptFramePageOptions {
|
|
140
136
|
page: PageAlias;
|
|
141
137
|
src?: never;
|
|
142
138
|
}
|
|
143
|
-
export interface ContentScriptFrameSourceOptions
|
|
139
|
+
export interface ContentScriptFrameSourceOptions {
|
|
144
140
|
src: string;
|
|
145
141
|
page?: never;
|
|
146
142
|
}
|
|
@@ -150,15 +146,11 @@ export interface ContentScriptIsolationNoneOptions {
|
|
|
150
146
|
mode?: never;
|
|
151
147
|
page?: never;
|
|
152
148
|
src?: never;
|
|
153
|
-
width?: never;
|
|
154
|
-
height?: never;
|
|
155
149
|
}
|
|
156
150
|
export interface ContentScriptIsolationShadowOptions extends ContentScriptShadowOptions {
|
|
157
151
|
type: ContentScriptIsolation.Shadow | "shadow";
|
|
158
152
|
page?: never;
|
|
159
153
|
src?: never;
|
|
160
|
-
width?: never;
|
|
161
|
-
height?: never;
|
|
162
154
|
}
|
|
163
155
|
export type ContentScriptIsolationFrameOptions = ContentScriptFrame & {
|
|
164
156
|
type: ContentScriptIsolation.Iframe | "iframe";
|
|
@@ -176,8 +168,16 @@ export interface ContentScriptMount {
|
|
|
176
168
|
mount(): boolean | undefined | void;
|
|
177
169
|
unmount(): boolean | undefined | void;
|
|
178
170
|
}
|
|
179
|
-
export interface
|
|
180
|
-
|
|
171
|
+
export interface ContentScriptContainerProps<Data = unknown> extends ContentScriptPrepareProps {
|
|
172
|
+
data: Data;
|
|
173
|
+
}
|
|
174
|
+
export interface ContentScriptProps<Data = unknown, Isolation extends `${ContentScriptIsolation}` = `${ContentScriptIsolation}`> extends ContentScriptContainerProps<Data> {
|
|
175
|
+
/** Outer mounted element; the Shadow host or iframe wrapper when isolated. */
|
|
176
|
+
container: Element;
|
|
177
|
+
/** Actual render destination. Use its root/document for portals and DOM operations. */
|
|
178
|
+
target: Element;
|
|
179
|
+
/** ShadowRoot or iframe for the active isolation; undefined without isolation. */
|
|
180
|
+
boundary: ContentScriptBoundary<Isolation>;
|
|
181
181
|
}
|
|
182
182
|
export type ContentScriptAnchor = string | Element | null | undefined;
|
|
183
183
|
export type ContentScriptAnchorGetter = () => Awaiter<ContentScriptAnchor>;
|
|
@@ -200,18 +200,15 @@ export interface ContentScriptMarkerContract {
|
|
|
200
200
|
export type ContentScriptMarkerType = ContentScriptMarker | `${ContentScriptMarker}` | ContentScriptMarkerContract | undefined;
|
|
201
201
|
export type ContentScriptMarkerGetter = (options: ContentScriptOptions) => Awaiter<ContentScriptMarkerType>;
|
|
202
202
|
export type ContentScriptMarkerResolver = (options: ContentScriptOptions) => Awaiter<ContentScriptMarkerContract>;
|
|
203
|
-
export type ContentScriptRenderReactComponent = FC<ContentScriptProps>;
|
|
204
|
-
export type ContentScriptRenderValue = Element | ReactNode | ContentScriptRenderReactComponent;
|
|
205
|
-
export type ContentScriptRenderHandler = (props: ContentScriptProps) => Awaiter<undefined | ContentScriptRenderValue>;
|
|
206
203
|
export type ContentScriptContainerTag = Exclude<keyof HTMLElementTagNameMap, "html" | "body">;
|
|
207
204
|
export type ContentScriptContainerOptions = {
|
|
208
205
|
[Tag in ContentScriptContainerTag]: {
|
|
209
206
|
tagName: Tag;
|
|
210
207
|
} & Exclude<Optional<PickNonFunctionProperties<HTMLElementTagNameMap[Tag]>>, "id">;
|
|
211
208
|
}[ContentScriptContainerTag];
|
|
212
|
-
export type ContentScriptContainerFactory = (props:
|
|
213
|
-
export type ContentScriptContainerCreator = (props:
|
|
214
|
-
export type ContentScriptWatchStrategy = (update: () => void
|
|
209
|
+
export type ContentScriptContainerFactory<Data = unknown> = (props: ContentScriptContainerProps<Data>) => Awaiter<Element | ContentScriptContainerTag | ContentScriptContainerOptions>;
|
|
210
|
+
export type ContentScriptContainerCreator<Data = unknown> = (props: ContentScriptContainerProps<Data>) => Awaiter<Element>;
|
|
211
|
+
export type ContentScriptWatchStrategy = (update: () => Awaiter<void>, context: ContentScriptContext) => () => void;
|
|
215
212
|
export type ContentScriptEventCallback = (event: ContentScriptEvent, node: ContentScriptNode) => void;
|
|
216
213
|
export interface ContentScriptEventEmitter {
|
|
217
214
|
on(callback: ContentScriptEventCallback): void;
|
|
@@ -248,36 +245,10 @@ export interface ContentScriptNode extends ContentScriptMount {
|
|
|
248
245
|
container?: Element;
|
|
249
246
|
/** Element used by the active adapter as the destination for rendered UI. */
|
|
250
247
|
target?: Element;
|
|
248
|
+
/** Present while isolation is mounted, including navigation-only iframes. */
|
|
249
|
+
boundary?: ContentScriptBoundary;
|
|
251
250
|
}
|
|
252
251
|
export type ContentScriptNodeSet = Set<ContentScriptNode>;
|
|
253
|
-
export interface ContentScriptDefinitionBase extends Partial<ContentScriptOptions> {
|
|
254
|
-
marker?: ContentScriptMarkerType | ContentScriptMarkerGetter;
|
|
255
|
-
anchor?: ContentScriptAnchor | ContentScriptAnchorGetter;
|
|
256
|
-
mount?: ContentScriptMountFunction;
|
|
257
|
-
container?: ContentScriptContainerTag | ContentScriptContainerOptions | ContentScriptContainerFactory;
|
|
258
|
-
watch?: true | ContentScriptWatchStrategy;
|
|
259
|
-
main?: ContentScriptMainFunction;
|
|
260
|
-
}
|
|
261
|
-
export type ContentScriptDefinition = ContentScriptDefinitionBase & ({
|
|
262
|
-
isolation?: ContentScriptIsolation | `${ContentScriptIsolation}` | ContentScriptIsolationNoneOptions | ContentScriptIsolationShadowOptions | (ContentScriptIsolationFrameOptions & ContentScriptFrameRenderOptions);
|
|
263
|
-
render?: ContentScriptRenderValue | ContentScriptRenderHandler;
|
|
264
|
-
} | {
|
|
265
|
-
isolation: ContentScriptIsolationFrameOptions & (ContentScriptFramePageOptions | ContentScriptFrameSourceOptions);
|
|
266
|
-
render?: never;
|
|
267
|
-
});
|
|
268
|
-
export interface ContentScriptResolvedDefinition extends Omit<ContentScriptDefinitionBase, "anchor" | "marker" | "mount" | "container" | "watch"> {
|
|
269
|
-
isolation: ContentScriptIsolationOptions;
|
|
270
|
-
marker: ContentScriptMarkerResolver;
|
|
271
|
-
anchor: ContentScriptAnchorGetter;
|
|
272
|
-
mount: ContentScriptMountFunction;
|
|
273
|
-
render?: ContentScriptRenderHandler;
|
|
274
|
-
container: ContentScriptContainerCreator;
|
|
275
|
-
watch: ContentScriptWatchStrategy;
|
|
276
|
-
}
|
|
277
|
-
type ContentScriptAppendVariant<T> = T extends unknown ? Omit<T, "mount"> & {
|
|
278
|
-
append?: ContentScriptAppend;
|
|
279
|
-
} : never;
|
|
280
|
-
export type ContentScriptAppendDefinition = ContentScriptAppendVariant<ContentScriptDefinition>;
|
|
281
252
|
export interface ContentScriptBuilder extends EntrypointBuilder {
|
|
282
253
|
getContext(): ContentScriptContext;
|
|
283
254
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/types/content/common.ts"],"sourcesContent":["import type {ContentScriptPrepareProps} from \"./prepare\";\nimport type {ContentScriptBoundary} from \"./boundary\";\n\nimport type {PageAlias} from \"@typing/page\";\nimport type {Optional} from \"utility-types\";\n\nimport type {EntrypointBuilder, EntrypointOptions} from \"@typing/entrypoint\";\nimport type {Awaiter, PickNonFunctionProperties} from \"@typing/helpers\";\n\nexport const ContentScriptMatches = [\"http://*/*\", \"https://*/*\"];\n\n/** Shared property used by the bundler plugin and the content script's style runtime getter. */\nexport const ContentScriptStylesRuntimeProperty = \"__adnbnIsolatedStyles\";\n\nexport enum ContentScriptWorld {\n Isolated = \"ISOLATED\",\n Main = \"MAIN\",\n}\n\nexport enum ContentScriptDeclarative {\n Required = \"required\",\n Optional = \"optional\",\n}\n\nexport enum ContentScriptIsolation {\n None = \"none\",\n Shadow = \"shadow\",\n Iframe = \"iframe\",\n}\n\nexport enum ContentScriptShadowMode {\n Open = \"open\",\n Closed = \"closed\",\n}\n\n// Append\nexport enum ContentScriptAppend {\n Last = \"last\",\n First = \"first\",\n Replace = \"replace\",\n Before = \"before\",\n After = \"after\",\n}\n\n// Marker\nexport enum ContentScriptMarker {\n /** In-memory marking (no DOM mutations). */\n Weak = \"weak\",\n /** DOM attribute-based marking. */\n Attribute = \"attribute\",\n}\n\nexport enum ContentScriptMarkerValue {\n Mounted = \"1\",\n Unmounted = \"0\",\n}\n\n// Event\nexport enum ContentScriptEvent {\n Mount = \"mount\",\n Unmount = \"unmount\",\n Add = \"add\",\n Remove = \"remove\",\n}\n\ntype RunAt = chrome.extensionTypes.RunAt;\n\nexport interface ContentScriptStylesRuntime {\n /** Resolves initial stylesheet URLs once, before the first root is registered. */\n initialize(resolveUrl: (file: string) => string): void;\n /** Retry restored styles once on load error; future loads keep the default failure behavior. */\n add(root: ShadowRoot | HTMLElement, target: Element | null, retry?: boolean): void;\n delete(root: ShadowRoot | HTMLElement): void;\n load(url: string): Promise<void>;\n}\n\nexport type ContentScriptWorldValue = ContentScriptWorld | `${chrome.scripting.ExecutionWorld}`;\n\nexport interface ContentScriptConfig {\n matches?: string[];\n /**\n * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/\n * @default []\n */\n excludeMatches?: string[];\n /**\n * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/\n * @default []\n */\n includeGlobs?: string[];\n /**\n * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/\n * @default []\n */\n excludeGlobs?: string[];\n /**\n * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/\n * @default false\n */\n allFrames?: boolean;\n /**\n * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/\n * @default \"documentIdle\"\n */\n runAt?: RunAt;\n /**\n * See https://developer.chrome.com/docs/extensions/develop/concepts/content-scripts#isolated_world\n *\n * Dynamic imports keep physical async chunks in ISOLATED. MAIN keeps the same Promise-based\n * execution semantics but includes dynamic dependencies in the initial entrypoint graph.\n * Manifest V2 builds always use ISOLATED. Requesting MAIN emits a build warning and applies\n * ISOLATED grouping and chunk loading rules before generating the manifest.\n */\n world?: ContentScriptWorldValue;\n /**\n * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/\n * @default false\n */\n matchAboutBlank?: boolean;\n /**\n * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/\n * @default false\n */\n matchOriginAsFallback?: boolean;\n /**\n * Whether this content script requires explicit host permission declaration in the extension manifest.\n *\n * Accepted values:\n * - ContentScriptDeclarative.Required — adds the corresponding host patterns to manifest.host_permissions.\n * - ContentScriptDeclarative.Optional — adds the corresponding host patterns to manifest.optional_host_permissions.\n *\n * Backward compatibility:\n * - true ≡ ContentScriptDeclarative.Required\n * - false ≡ undefined (as if the value is not set)\n *\n * @see https://developer.chrome.com/docs/extensions/mv3/declare_permissions/\n *\n * @default undefined\n */\n declarative?: boolean | `${ContentScriptDeclarative}` | ContentScriptDeclarative;\n}\n\nexport type ContentScriptOptions = ContentScriptConfig & EntrypointOptions;\n\nexport interface ContentScriptShadowOptions {\n /**\n * Controls access through the host's shadowRoot property, not CSS isolation or UI visibility.\n * @default ContentScriptShadowMode.Open\n */\n mode?: ContentScriptShadowMode | `${ContentScriptShadowMode}`;\n}\n\nexport interface ContentScriptFrameRenderOptions {\n page?: never;\n src?: never;\n}\n\nexport interface ContentScriptFramePageOptions {\n page: PageAlias;\n src?: never;\n}\n\nexport interface ContentScriptFrameSourceOptions {\n src: string;\n page?: never;\n}\n\nexport type ContentScriptFrame =\n | ContentScriptFrameRenderOptions\n | ContentScriptFramePageOptions\n | ContentScriptFrameSourceOptions;\n\nexport interface ContentScriptIsolationNoneOptions {\n type: ContentScriptIsolation.None | \"none\";\n mode?: never;\n page?: never;\n src?: never;\n}\n\nexport interface ContentScriptIsolationShadowOptions extends ContentScriptShadowOptions {\n type: ContentScriptIsolation.Shadow | \"shadow\";\n page?: never;\n src?: never;\n}\n\nexport type ContentScriptIsolationFrameOptions = ContentScriptFrame & {\n type: ContentScriptIsolation.Iframe | \"iframe\";\n mode?: never;\n};\n\n/** Object form of isolation, also used after resolving shorthand values. */\nexport type ContentScriptIsolationOptions =\n | ContentScriptIsolationNoneOptions\n | ContentScriptIsolationShadowOptions\n | ContentScriptIsolationFrameOptions;\n\nexport type ContentScriptIsolationValue =\n | ContentScriptIsolation\n | `${ContentScriptIsolation}`\n | ContentScriptIsolationOptions;\n\n/** Statically resolved configuration; runtime render values are never retained here. */\nexport type ContentScriptEntrypointOptions = Partial<ContentScriptOptions> & {\n isolation?: ContentScriptIsolationOptions;\n};\n\n// Mount\nexport type ContentScriptMountFunction = (anchor: Element, container: Element) => void | (() => void);\n\nexport interface ContentScriptMount {\n mount(): boolean | undefined | void;\n\n unmount(): boolean | undefined | void;\n}\n\n// Props\nexport interface ContentScriptContainerProps<Data = unknown> extends ContentScriptPrepareProps {\n data: Data;\n}\n\nexport interface ContentScriptProps<\n Data = unknown,\n Isolation extends `${ContentScriptIsolation}` = `${ContentScriptIsolation}`,\n> extends ContentScriptContainerProps<Data> {\n /** Outer mounted element; the Shadow host or iframe wrapper when isolated. */\n container: Element;\n /** Actual render destination. Use its root/document for portals and DOM operations. */\n target: Element;\n /** ShadowRoot or iframe for the active isolation; undefined without isolation. */\n boundary: ContentScriptBoundary<Isolation>;\n}\n\n// Anchor\nexport type ContentScriptAnchor = string | Element | null | undefined;\n\nexport type ContentScriptAnchorGetter = () => Awaiter<ContentScriptAnchor>;\n\nexport interface ContentScriptMarkerContract {\n for(anchor: ContentScriptAnchor): ContentScriptMarkerContract;\n\n /**\n * Returns elements that are not tracked yet (no marker attribute present).\n * MUST NOT mutate marker state.\n */\n unmarked(): Element[];\n\n marked(): Element[];\n\n mark(element: Element, value: ContentScriptMarkerValue): boolean;\n\n unmark(element: Element): boolean;\n\n isMarked(element: Element): boolean;\n\n value(element: Element): ContentScriptMarkerValue | undefined;\n\n mount(element: Element): boolean;\n\n unmount(element: Element): boolean;\n\n reset(): ContentScriptMarkerContract;\n}\n\nexport type ContentScriptMarkerType =\n | ContentScriptMarker\n | `${ContentScriptMarker}`\n | ContentScriptMarkerContract\n | undefined;\n\nexport type ContentScriptMarkerGetter = (options: ContentScriptOptions) => Awaiter<ContentScriptMarkerType>;\n\nexport type ContentScriptMarkerResolver = (options: ContentScriptOptions) => Awaiter<ContentScriptMarkerContract>;\n\n// Container\nexport type ContentScriptContainerTag = Exclude<keyof HTMLElementTagNameMap, \"html\" | \"body\">;\n\nexport type ContentScriptContainerOptions = {\n [Tag in ContentScriptContainerTag]: {\n tagName: Tag;\n } & Exclude<Optional<PickNonFunctionProperties<HTMLElementTagNameMap[Tag]>>, \"id\">;\n}[ContentScriptContainerTag];\n\nexport type ContentScriptContainerFactory<Data = unknown> = (\n props: ContentScriptContainerProps<Data>\n) => Awaiter<Element | ContentScriptContainerTag | ContentScriptContainerOptions>;\n\nexport type ContentScriptContainerCreator<Data = unknown> = (\n props: ContentScriptContainerProps<Data>\n) => Awaiter<Element>;\n\n// Watch\nexport type ContentScriptWatchStrategy = (update: () => Awaiter<void>, context: ContentScriptContext) => () => void;\n\nexport type ContentScriptEventCallback = (event: ContentScriptEvent, node: ContentScriptNode) => void;\n\nexport interface ContentScriptEventEmitter {\n on(callback: ContentScriptEventCallback): void;\n\n off(callback: ContentScriptEventCallback): void;\n\n emit(event: ContentScriptEvent, node: ContentScriptNode): void;\n\n emitMount(node: ContentScriptNode): void;\n\n emitUnmount(node: ContentScriptNode): void;\n\n emitAdd(node: ContentScriptNode): void;\n\n emitRemove(node: ContentScriptNode): void;\n\n removeAllListeners(): void;\n\n listenerCount(): number;\n\n hasListeners(): boolean;\n}\n\n// Context\nexport interface ContentScriptContext extends ContentScriptMount {\n nodes: ReadonlySet<ContentScriptNode>;\n\n /**\n * Registers a callback function that will be invoked when a specific content script context event occurs.\n *\n * @param {ContentScriptEventCallback} callback - The function to be executed when the event is triggered. Receives event-related data as its argument.\n * @return {Function} A function that can be called to unsubscribe the callback from the event.\n */\n watch(callback: ContentScriptEventCallback): () => void;\n\n /**\n * Stops watching for changes or events that were previously being observed.\n * Unsubscribes from all event listeners that were registered through the watch method.\n *\n * @return {void} No return value.\n */\n unwatch(): void;\n}\n\n// Main\nexport type ContentScriptMainFunction = (context: ContentScriptContext, options: ContentScriptOptions) => Awaiter<void>;\n\n// Node\nexport interface ContentScriptNode extends ContentScriptMount {\n anchor: Element;\n container?: Element;\n\n /** Element used by the active adapter as the destination for rendered UI. */\n target?: Element;\n\n /** Present while isolation is mounted, including navigation-only iframes. */\n boundary?: ContentScriptBoundary;\n}\n\nexport type ContentScriptNodeSet = Set<ContentScriptNode>;\n\n// Builder\nexport interface ContentScriptBuilder extends EntrypointBuilder {\n getContext(): ContentScriptContext;\n}\n"],"mappings":"AASO,MAAM,uBAAuB,CAAC,cAAc,aAAa;AAGzD,MAAM,qCAAqC;AAE3C,IAAK,qBAAL,kBAAKA,wBAAL;AACH,EAAAA,oBAAA,cAAW;AACX,EAAAA,oBAAA,UAAO;AAFC,SAAAA;AAAA,GAAA;AAKL,IAAK,2BAAL,kBAAKC,8BAAL;AACH,EAAAA,0BAAA,cAAW;AACX,EAAAA,0BAAA,cAAW;AAFH,SAAAA;AAAA,GAAA;AAKL,IAAK,yBAAL,kBAAKC,4BAAL;AACH,EAAAA,wBAAA,UAAO;AACP,EAAAA,wBAAA,YAAS;AACT,EAAAA,wBAAA,YAAS;AAHD,SAAAA;AAAA,GAAA;AAML,IAAK,0BAAL,kBAAKC,6BAAL;AACH,EAAAA,yBAAA,UAAO;AACP,EAAAA,yBAAA,YAAS;AAFD,SAAAA;AAAA,GAAA;AAML,IAAK,sBAAL,kBAAKC,yBAAL;AACH,EAAAA,qBAAA,UAAO;AACP,EAAAA,qBAAA,WAAQ;AACR,EAAAA,qBAAA,aAAU;AACV,EAAAA,qBAAA,YAAS;AACT,EAAAA,qBAAA,WAAQ;AALA,SAAAA;AAAA,GAAA;AASL,IAAK,sBAAL,kBAAKC,yBAAL;AAEH,EAAAA,qBAAA,UAAO;AAEP,EAAAA,qBAAA,eAAY;AAJJ,SAAAA;AAAA,GAAA;AAOL,IAAK,2BAAL,kBAAKC,8BAAL;AACH,EAAAA,0BAAA,aAAU;AACV,EAAAA,0BAAA,eAAY;AAFJ,SAAAA;AAAA,GAAA;AAML,IAAK,qBAAL,kBAAKC,wBAAL;AACH,EAAAA,oBAAA,WAAQ;AACR,EAAAA,oBAAA,aAAU;AACV,EAAAA,oBAAA,SAAM;AACN,EAAAA,oBAAA,YAAS;AAJD,SAAAA;AAAA,GAAA;","names":["ContentScriptWorld","ContentScriptDeclarative","ContentScriptIsolation","ContentScriptShadowMode","ContentScriptAppend","ContentScriptMarker","ContentScriptMarkerValue","ContentScriptEvent"]}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { ContentScriptPrepareHandler } from "./prepare.js";
|
|
2
|
+
import type { ContentScriptBoundaryHandler } from "./boundary.js";
|
|
3
|
+
import type { ContentScriptAnchor, ContentScriptAnchorGetter, ContentScriptAppend, ContentScriptContainerCreator, ContentScriptContainerFactory, ContentScriptContainerOptions, ContentScriptContainerTag, ContentScriptFramePageOptions, ContentScriptFrameRenderOptions, ContentScriptFrameSourceOptions, ContentScriptIsolation, ContentScriptIsolationFrameOptions, ContentScriptIsolationOptions, ContentScriptIsolationShadowOptions, ContentScriptMainFunction, ContentScriptMarkerGetter, ContentScriptMarkerResolver, ContentScriptMarkerType, ContentScriptMountFunction, ContentScriptOptions, ContentScriptWatchStrategy } from "./common.js";
|
|
4
|
+
import type { ContentScriptRenderHandler, ContentScriptRenderValue } from "./render.js";
|
|
5
|
+
import type { ContentScriptTarget, ContentScriptTargetCreator } from "./target.js";
|
|
6
|
+
export interface ContentScriptDefinitionBase<Data = unknown> extends Partial<ContentScriptOptions> {
|
|
7
|
+
marker?: ContentScriptMarkerType | ContentScriptMarkerGetter;
|
|
8
|
+
anchor?: ContentScriptAnchor | ContentScriptAnchorGetter;
|
|
9
|
+
mount?: ContentScriptMountFunction;
|
|
10
|
+
container?: ContentScriptContainerTag | ContentScriptContainerOptions | ContentScriptContainerFactory<NoInfer<Data>>;
|
|
11
|
+
prepare?: ContentScriptPrepareHandler<Data>;
|
|
12
|
+
watch?: true | ContentScriptWatchStrategy;
|
|
13
|
+
main?: ContentScriptMainFunction;
|
|
14
|
+
}
|
|
15
|
+
export type ContentScriptRenderDefinition<Data = unknown, Isolation extends `${ContentScriptIsolation}` = `${ContentScriptIsolation}`> = {
|
|
16
|
+
isolation?: Isolation | {
|
|
17
|
+
type: Isolation;
|
|
18
|
+
};
|
|
19
|
+
boundary?: ContentScriptBoundaryHandler<NoInfer<Data>, NoInfer<Isolation>>;
|
|
20
|
+
target?: ContentScriptTarget<NoInfer<Data>, NoInfer<Isolation>>;
|
|
21
|
+
render?: ContentScriptRenderValue<NoInfer<Data>, NoInfer<Isolation>> | ContentScriptRenderHandler<NoInfer<Data>, NoInfer<Isolation>>;
|
|
22
|
+
} & ({
|
|
23
|
+
isolation?: NoInfer<Isolation> | Extract<ContentScriptIsolationOptions, {
|
|
24
|
+
type: `${NoInfer<Isolation>}`;
|
|
25
|
+
page?: never;
|
|
26
|
+
src?: never;
|
|
27
|
+
}>;
|
|
28
|
+
boundary?: never;
|
|
29
|
+
target?: never;
|
|
30
|
+
} | {
|
|
31
|
+
isolation: Extract<NoInfer<Isolation>, "shadow"> | Extract<ContentScriptIsolationShadowOptions, {
|
|
32
|
+
type: `${NoInfer<Isolation>}`;
|
|
33
|
+
}>;
|
|
34
|
+
} | {
|
|
35
|
+
isolation: Extract<NoInfer<Isolation>, "iframe"> | Extract<ContentScriptIsolationFrameOptions & ContentScriptFrameRenderOptions, {
|
|
36
|
+
type: `${NoInfer<Isolation>}`;
|
|
37
|
+
}>;
|
|
38
|
+
} | {
|
|
39
|
+
isolation: Extract<ContentScriptIsolationFrameOptions & (ContentScriptFramePageOptions | ContentScriptFrameSourceOptions), {
|
|
40
|
+
type: `${NoInfer<Isolation>}`;
|
|
41
|
+
}>;
|
|
42
|
+
render?: never;
|
|
43
|
+
target?: never;
|
|
44
|
+
}) & ("none" extends `${NoInfer<Isolation>}` ? unknown : {
|
|
45
|
+
isolation: unknown;
|
|
46
|
+
});
|
|
47
|
+
export type ContentScriptDefinition<Data = unknown, Isolation extends `${ContentScriptIsolation}` = `${ContentScriptIsolation}`> = ContentScriptDefinitionBase<Data> & ContentScriptRenderDefinition<Data, Isolation>;
|
|
48
|
+
export interface ContentScriptResolvedDefinition<Data = unknown> extends Omit<ContentScriptDefinitionBase<Data>, "anchor" | "marker" | "mount" | "container" | "watch"> {
|
|
49
|
+
isolation: ContentScriptIsolationOptions;
|
|
50
|
+
boundary?: ContentScriptBoundaryHandler<Data>;
|
|
51
|
+
marker: ContentScriptMarkerResolver;
|
|
52
|
+
anchor: ContentScriptAnchorGetter;
|
|
53
|
+
mount: ContentScriptMountFunction;
|
|
54
|
+
render?: true | ContentScriptRenderHandler<Data>;
|
|
55
|
+
container: ContentScriptContainerCreator<Data>;
|
|
56
|
+
target: ContentScriptTargetCreator<Data>;
|
|
57
|
+
watch: ContentScriptWatchStrategy;
|
|
58
|
+
}
|
|
59
|
+
export type ContentScriptAppendDefinition<Data = unknown, Isolation extends `${ContentScriptIsolation}` = `${ContentScriptIsolation}`> = Omit<ContentScriptDefinitionBase<Data>, "mount"> & ContentScriptRenderDefinition<Data, Isolation> & {
|
|
60
|
+
append?: ContentScriptAppend;
|
|
61
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=definition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|