adnbn 0.2.1 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/dist/{AbstractBuilder-CKgY_Bta.d.ts → AbstractBuilder-BN4TmNJG.d.ts} +3 -3
  2. package/dist/{AbstractBuilder-Ce5zNRXr.d.mts → AbstractBuilder-C81kWZzQ.d.mts} +3 -3
  3. package/dist/{BaseTransport-C7uEgfUu.d.mts → BaseTransport-DNZ28gFF.d.mts} +1 -1
  4. package/dist/{BaseTransport-BdFTZfP0.d.ts → BaseTransport-Ecy2Kzti.d.ts} +1 -1
  5. package/dist/{Builder-FwJAxWos.d.ts → Builder-BOLvGGqp.d.ts} +2 -2
  6. package/dist/{Builder-rW3fzusy.d.mts → Builder-BP8SDHO1.d.mts} +2 -2
  7. package/dist/{Builder-7pbnGvHK.d.ts → Builder-Bc8US0PY.d.ts} +1 -1
  8. package/dist/{Builder-CCyBD4hF.d.mts → Builder-Df1LUO_f.d.mts} +1 -1
  9. package/dist/{Message-1cYgMdsu.d.mts → Message-Bnritk3D.d.mts} +1 -1
  10. package/dist/{Message-DAhczRx9.d.ts → Message-DFDaS7mV.d.ts} +1 -1
  11. package/dist/{MountBuilder-DjnAmTI0.d.ts → MountBuilder-BTltgVF2.d.mts} +26 -7
  12. package/dist/{MountBuilder-CjvMOcmn.d.mts → MountBuilder-C9Q-7PeI.d.ts} +26 -7
  13. package/dist/{ProxyRelay-Ce-szh9p.d.ts → ProxyRelay-DDOSZE3h.d.ts} +3 -3
  14. package/dist/{ProxyRelay-BOBEhRET.d.mts → ProxyRelay-Uel0ATcx.d.mts} +3 -3
  15. package/dist/{ProxyTransport-BTVUbDxE.d.mts → ProxyTransport-35rU8xqa.d.mts} +3 -3
  16. package/dist/{ProxyTransport-BW63K6SU.d.ts → ProxyTransport-D4jv5SFh.d.ts} +3 -3
  17. package/dist/{RegisterOffscreen-BukckdvS.d.mts → RegisterOffscreen-DT0gN5xN.d.mts} +2 -2
  18. package/dist/{RegisterOffscreen-DmlpLqjW.d.ts → RegisterOffscreen-df3W5HqA.d.ts} +2 -2
  19. package/dist/{RegisterRelay-MEVSR1sP.d.mts → RegisterRelay-DCVZ2_NI.d.mts} +2 -2
  20. package/dist/{RegisterRelay-BaIET78I.d.ts → RegisterRelay-PFT2ac4v.d.ts} +2 -2
  21. package/dist/{TransportMessage-Bk0wg4rF.d.mts → TransportMessage-CIKrv3DG.d.mts} +8 -4
  22. package/dist/{TransportMessage-BqMzXWZR.d.ts → TransportMessage-CsObvTPq.d.ts} +8 -4
  23. package/dist/{background-Zjiqg60g.d.ts → background-CpVjDFHQ.d.ts} +1 -1
  24. package/dist/{background-CyGGjmBx.d.mts → background-cxLBji1Q.d.mts} +1 -1
  25. package/dist/cli/index.cjs +46 -15
  26. package/dist/cli/index.cjs.map +1 -1
  27. package/dist/{command-BFsdm7Bx.d.mts → command-S2dcqx6Q.d.mts} +4 -3
  28. package/dist/{command-3i_5d__K.d.ts → command-TJ2JUrVd.d.ts} +4 -3
  29. package/dist/{content-sdYF4W-A.d.ts → content-B0znLIjr.d.ts} +37 -4
  30. package/dist/{content-BYoXVO6V.d.mts → content-DrrPH4ri.d.mts} +37 -4
  31. package/dist/entry/background/index.d.mts +2 -2
  32. package/dist/entry/background/index.d.ts +2 -2
  33. package/dist/entry/command/index.d.mts +3 -3
  34. package/dist/entry/command/index.d.ts +3 -3
  35. package/dist/entry/content/index.d.mts +2 -2
  36. package/dist/entry/content/index.d.ts +2 -2
  37. package/dist/entry/content/react/index.cjs +104 -18
  38. package/dist/entry/content/react/index.cjs.map +1 -1
  39. package/dist/entry/content/react/index.d.mts +4 -4
  40. package/dist/entry/content/react/index.d.ts +4 -4
  41. package/dist/entry/content/react/index.js +104 -18
  42. package/dist/entry/content/react/index.js.map +1 -1
  43. package/dist/entry/content/vanilla/index.cjs +108 -18
  44. package/dist/entry/content/vanilla/index.cjs.map +1 -1
  45. package/dist/entry/content/vanilla/index.d.mts +4 -4
  46. package/dist/entry/content/vanilla/index.d.ts +4 -4
  47. package/dist/entry/content/vanilla/index.js +108 -18
  48. package/dist/entry/content/vanilla/index.js.map +1 -1
  49. package/dist/entry/offscreen/index.cjs +27 -4
  50. package/dist/entry/offscreen/index.cjs.map +1 -1
  51. package/dist/entry/offscreen/index.d.mts +11 -9
  52. package/dist/entry/offscreen/index.d.ts +11 -9
  53. package/dist/entry/offscreen/index.js +27 -4
  54. package/dist/entry/offscreen/index.js.map +1 -1
  55. package/dist/entry/relay/index.d.mts +9 -8
  56. package/dist/entry/relay/index.d.ts +9 -8
  57. package/dist/entry/service/index.cjs +31 -10
  58. package/dist/entry/service/index.cjs.map +1 -1
  59. package/dist/entry/service/index.d.mts +5 -4
  60. package/dist/entry/service/index.d.ts +5 -4
  61. package/dist/entry/service/index.js +31 -10
  62. package/dist/entry/service/index.js.map +1 -1
  63. package/dist/entry/transport/index.d.mts +8 -7
  64. package/dist/entry/transport/index.d.ts +8 -7
  65. package/dist/entry/view/index.d.mts +2 -2
  66. package/dist/entry/view/index.d.ts +2 -2
  67. package/dist/entry/view/react/index.d.mts +4 -4
  68. package/dist/entry/view/react/index.d.ts +4 -4
  69. package/dist/entry/view/vanilla/index.d.mts +4 -4
  70. package/dist/entry/view/vanilla/index.d.ts +4 -4
  71. package/dist/{helpers-DnV3N7fU.d.mts → helpers-YDFORuZz.d.mts} +2 -2
  72. package/dist/{helpers-DnV3N7fU.d.ts → helpers-YDFORuZz.d.ts} +2 -2
  73. package/dist/index.cjs +11 -1
  74. package/dist/index.cjs.map +1 -1
  75. package/dist/index.d.mts +63 -22
  76. package/dist/index.d.ts +63 -22
  77. package/dist/index.js +11 -2
  78. package/dist/index.js.map +1 -1
  79. package/dist/message/index.cjs.map +1 -1
  80. package/dist/message/index.d.mts +4 -3
  81. package/dist/message/index.d.ts +4 -3
  82. package/dist/message/index.js.map +1 -1
  83. package/dist/message/react/index.cjs.map +1 -1
  84. package/dist/message/react/index.d.mts +1 -1
  85. package/dist/message/react/index.d.ts +1 -1
  86. package/dist/message/react/index.js.map +1 -1
  87. package/dist/{message-55r-wFjc.d.mts → message-jsmkeGHC.d.mts} +5 -1
  88. package/dist/{message-55r-wFjc.d.ts → message-jsmkeGHC.d.ts} +5 -1
  89. package/dist/offscreen/index.cjs +30 -5
  90. package/dist/offscreen/index.cjs.map +1 -1
  91. package/dist/offscreen/index.d.mts +10 -9
  92. package/dist/offscreen/index.d.ts +10 -9
  93. package/dist/offscreen/index.js +30 -5
  94. package/dist/offscreen/index.js.map +1 -1
  95. package/dist/{offscreen-B9GiglgN.d.mts → offscreen-2EP-rRfx.d.mts} +3 -3
  96. package/dist/{offscreen-BG5Abe8V.d.ts → offscreen-aHdkogKj.d.ts} +3 -3
  97. package/dist/relay/index.d.mts +8 -7
  98. package/dist/relay/index.d.ts +8 -7
  99. package/dist/{relay-DymeeDe7.d.ts → relay-DT46Ltms.d.ts} +3 -3
  100. package/dist/{relay-BYeTCwKO.d.mts → relay-vaJ5R2iC.d.mts} +3 -3
  101. package/dist/service/index.cjs +27 -4
  102. package/dist/service/index.cjs.map +1 -1
  103. package/dist/service/index.d.mts +8 -6
  104. package/dist/service/index.d.ts +8 -6
  105. package/dist/service/index.js +27 -4
  106. package/dist/service/index.js.map +1 -1
  107. package/dist/{service-BhJhIk-O.d.ts → service-6FdoYGNC.d.ts} +3 -3
  108. package/dist/{service-DsivypLQ.d.mts → service-C9HbDQPE.d.mts} +3 -3
  109. package/dist/{transport-B_uYwoGi.d.mts → transport-BrbirhXv.d.mts} +3 -2
  110. package/dist/{transport-BPmSUoEU.d.ts → transport-Co9Oxp0-.d.ts} +3 -2
  111. package/dist/{view-QDP2Maev.d.mts → view-Bs26Jcvi.d.mts} +1 -1
  112. package/dist/{view-D4dquvKl.d.ts → view-u9w7nMgw.d.ts} +1 -1
  113. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/entry/core/Builder.ts","../../../../src/entry/content/core/resolvers/mount.ts","../../../../src/entry/content/core/resolvers/anchor.ts","../../../../src/entry/content/core/resolvers/render.ts","../../../../src/entry/content/core/resolvers/container.ts","../../../../src/entry/content/core/resolvers/watch.ts","../../../../src/entry/content/core/Context.ts","../../../../src/entry/content/core/ManagedContext.ts","../../../../src/entry/content/core/Builder.ts","../../../../src/entry/content/core/Node.ts","../../../../src/entry/content/core/MountNode.ts","../../../../src/entry/content/core/MountBuilder.ts","../../../../src/entry/content/react/Node.ts","../../../../src/entry/content/react/resolvers/render.ts","../../../../src/entry/content/react/Builder.ts","../../../../src/entry/content/react/index.ts"],"names":["Builder_default","Node_default","isValidElement"],"mappings":";;;;;;;;AAEA,IAAO,kBAAP,MAA2D;AAAA,EAKvD,OAAc,QAAwE,GAAA;AAClF,IAAA,OAAO,CAAC,UAAwD,KAAA;AAC5D,MAAA,IAAI,KAAK,UAAU,CAAA,CAAE,KAAM,EAAA,CAAE,MAAM,CAAK,CAAA,KAAA;AACpC,QAAQ,OAAA,CAAA,KAAA,CAAM,+BAA+B,CAAC,CAAA;AAAA,OACjD,CAAA;AAAA,KACL;AAAA;AAER,CAAA;;;ACXO,IAAM,gCACT,GAAA,CAAC,MACG,KAAA,CAAC,QAAiB,SAA6B,KAAA;AALvD,EAAA,IAAA,EAAA,EAAA,EAAA;AAMY,EAAA,QAAQ,MAAQ;AAAA,IACZ,KAAA,MAAA;AACI,MAAA,MAAA,CAAO,OAAO,SAAS,CAAA;AACvB,MAAA;AAAA,IACJ;AAAA,IACA,KAAK,MAAA;AAAA,IACL,KAAA,OAAA;AACI,MAAA,MAAA,CAAO,QAAQ,SAAS,CAAA;AACxB,MAAA;AAAA,IACJ,KAAA,SAAA;AACI,MAAA,MAAA,CAAO,YAAY,SAAS,CAAA;AAC5B,MAAA;AAAA,IACJ,KAAA,OAAA;AACI,MAAA,CAAA,EAAA,GAAA,MAAA,CAAO,aAAP,KAAA,IAAA,GAAA,MAAA,GAAA,EAAA,CAAsB,YAAa,CAAA,SAA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,cAAc,CAAG,EAAA;AAChC,IAAO,OAAA,cAAA;AAAA;AAEf,CAAA;;;ACEGD,IAAAA,gBAAAA,GAAP,cAA6B,oBAAa,CAAA;AAAA,EACtC,YAAY,UAAqC,EAAA;AAC7C,IAAA,KAAA,CAAM,UAAU,CAAA;AAAA;AACpB,EAEU,cAAc,MAA2E,EAAA;AAC/F,IAAA,IAAI,WAAW,MAAW,EAAA;AACtB,MAAA;AAAA;AAGJ,IAAA,OAAO,iCAAiC,MAAM,CAAA;AAAA;AAClD,EAEA,MAAgB,WAAW,MAA6C,EAAA;AACpE,IAAA,IAAI,KAAQ,GAAA,MAAM,IAAK,CAAA,QAAA,CAAS,MAAM,CAAA;AAEtC,IAAI,IAAA,CAACE,cAAe,CAAA,KAAK,CAAG,EAAA;AACxB,MAAQ,KAAA,GAAA,MAAA;AAER,MAAA,OAAA,CAAQ,KAAK,yDAAyD,CAAA;AAAA;AAG1E,IAAA,OAAO,IAAID,aAAU,CAAA,MAAM,MAAM,UAAW,CAAA,MAAM,GAAG,KAAK,CAAA;AAAA;AAElE;;;AClCO,IAAA,aAAA,GAAQD,iBAAQ,QAAS","file":"index.js","sourcesContent":["import {EntrypointBuilder, EntrypointConstructorParameter} from \"@typing/entrypoint\";\n\nexport default abstract class implements EntrypointBuilder {\n public abstract build(): Promise<void>;\n\n public abstract destroy(): Promise<void>;\n\n public static resolver<T extends new (definition: any) => EntrypointBuilder>(this: T) {\n return (definition: EntrypointConstructorParameter<T>): void => {\n new this(definition).build().catch(e => {\n console.error(\"Failed to build entrypoint:\", e);\n });\n };\n }\n}\n","import {ContentScriptAppend, ContentScriptMountFunction} from \"@typing/content\";\n\n// prettier-ignore\nexport const contentScriptMountAppendResolver =\n (append?: ContentScriptAppend): ContentScriptMountFunction =>\n (anchor: Element, container: Element): void => {\n switch (append) {\n case ContentScriptAppend.Last:\n anchor.append(container);\n break;\n default:\n case undefined:\n case ContentScriptAppend.First:\n anchor.prepend(container);\n break;\n case ContentScriptAppend.Replace:\n anchor.replaceWith(container);\n break;\n case ContentScriptAppend.After:\n anchor.parentElement?.insertBefore(container, anchor.nextElementSibling);\n break;\n case ContentScriptAppend.Before:\n anchor.parentElement?.insertBefore(container, anchor);\n break;\n }\n };\n","import {customAlphabet} from \"nanoid\";\n\nimport {ContentScriptAnchor, ContentScriptAnchorGetter, ContentScriptAnchorResolver} from \"@typing/content\";\n\nconst generateId = customAlphabet(\"abcdefghijklmnopqrstuvwxyz\", 7);\n\nexport const contentScriptAnchorAttribute = `data-${generateId()}`;\n\n// prettier-ignore\nexport const contentScriptAnchorResolver =\n (anchor?: ContentScriptAnchor | ContentScriptAnchorGetter): ContentScriptAnchorResolver =>\n async (): Promise<Element[]> => {\n const attr = contentScriptAnchorAttribute;\n\n let resolved = typeof anchor === \"function\" ? anchor() : anchor;\n\n if (resolved instanceof Promise) {\n resolved = await resolved;\n }\n\n if (resolved === undefined || resolved === null) {\n resolved = document.body;\n }\n\n const elements: Element[] = [];\n\n if (resolved instanceof Element) {\n if (!resolved.hasAttribute(attr)) {\n elements.push(resolved);\n }\n } else if (typeof resolved === \"string\") {\n if (resolved.startsWith(\"/\")) {\n const notRegex = /not\\(\\s*[^)]+\\s*\\)/;\n const condition = `not(@${attr})`;\n\n if (notRegex.test(resolved)) {\n resolved = `(${resolved})[${condition}]`;\n }\n\n const result = document.evaluate(\n resolved,\n document,\n null,\n XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,\n null\n );\n\n for (let i = 0; i < result.snapshotLength; i++) {\n elements.push(result.snapshotItem(i) as Element);\n }\n } else {\n resolved += `:not([${attr}])`;\n\n elements.push(...Array.from(document.querySelectorAll(resolved)));\n }\n }\n\n return elements;\n };\n","import {ContentScriptRenderHandler, ContentScriptRenderValue} from \"@typing/content\";\n\nexport const isValidContentScriptRenderValue = (value: unknown): value is string | number | Element => {\n return (typeof value === \"string\" && value.length > 0) || typeof value === \"number\" || value instanceof Element;\n};\n\n// prettier-ignore\nexport const contentScriptRenderResolver =\n (render?: ContentScriptRenderValue | ContentScriptRenderHandler): ContentScriptRenderHandler =>\n async (props): Promise<undefined | ContentScriptRenderValue> => {\n let resolvedRender = typeof render === \"function\" ? render(props) : render;\n\n if (resolvedRender instanceof Promise) {\n resolvedRender = await resolvedRender;\n }\n\n if (resolvedRender !== true && !isValidContentScriptRenderValue(resolvedRender)) {\n return;\n }\n\n return resolvedRender;\n };\n","import {\n ContentScriptContainerCreator,\n ContentScriptContainerFactory,\n ContentScriptContainerOptions,\n ContentScriptContainerTag,\n ContentScriptProps,\n} from \"@typing/content\";\n\nexport const contentScriptContainerResolver =\n (\n container?: ContentScriptContainerTag | ContentScriptContainerOptions | ContentScriptContainerFactory\n ): ContentScriptContainerCreator =>\n async (props: ContentScriptProps): Promise<Element> => {\n let resolvedContainer = typeof container === \"function\" ? container(props) : container;\n\n if (resolvedContainer instanceof Promise) {\n resolvedContainer = await resolvedContainer;\n }\n\n if (resolvedContainer === undefined || typeof resolvedContainer === \"string\") {\n resolvedContainer = document.createElement(resolvedContainer || \"div\");\n } else if (typeof resolvedContainer === \"object\" && resolvedContainer.constructor === Object) {\n const {tagName = \"div\", ...options} = resolvedContainer as ContentScriptContainerOptions;\n\n resolvedContainer = document.createElement(tagName);\n\n Object.assign(resolvedContainer, options);\n }\n\n if (!(resolvedContainer instanceof Element)) {\n throw new Error(\"The content script container must be a valid element\");\n }\n\n return resolvedContainer;\n };\n","import debounce from \"debounce\";\n\nimport {ContentScriptWatchStrategy} from \"@typing/content\";\n\n// prettier-ignore\nexport const contentScriptMutationObserverResolver =\n (options?: MutationObserverInit): ContentScriptWatchStrategy =>\n update => {\n if (!options) {\n options = {};\n }\n\n const handle = debounce(update, 200);\n\n const observer = new MutationObserver(handle);\n\n observer.observe(document.body, {\n childList: true,\n subtree: true,\n attributes: true,\n characterData: true,\n ...options,\n });\n\n return () => {\n handle.clear();\n observer.disconnect();\n };\n };\n\n// prettier-ignore\nexport const contentScriptAwaitFirstResolver =\n (options?: MutationObserverInit): ContentScriptWatchStrategy =>\n (update, context) => {\n const resolver = contentScriptMutationObserverResolver({\n attributes: false,\n characterData: false,\n ...options,\n });\n\n let unwatch: { (): void } | undefined;\n\n const clear = () => {\n unwatch && unwatch();\n unwatch = undefined;\n };\n\n if (context.nodes.size === 0) {\n unwatch = resolver(() => {\n update();\n\n if (context.nodes.size > 0) {\n clear();\n }\n }, context);\n }\n\n return () => {\n clear();\n };\n };\n\n// prettier-ignore\nexport const contentScriptLocationResolver =\n (strategy: ContentScriptWatchStrategy): ContentScriptWatchStrategy =>\n (update, context) => {\n let currentUrl = location.href;\n\n const interval = setInterval(() => {\n if (currentUrl !== location.href) {\n currentUrl = location.href;\n\n context.mount();\n }\n }, 300);\n\n const unwatch = strategy(update, context);\n\n return () => {\n clearInterval(interval);\n unwatch();\n };\n };\n","import {ContentScriptContext, ContentScriptNode, ContentScriptNodeSet} from \"@typing/content\";\n\nexport default class implements ContentScriptContext {\n protected readonly collection: ContentScriptNodeSet = new Set();\n\n public get nodes(): ReadonlySet<ContentScriptNode> {\n return this.collection;\n }\n\n public mount(): void {\n for (const node of this.collection) {\n if (!node.anchor.isConnected) {\n node.unmount();\n\n this.collection.delete(node);\n\n continue;\n }\n\n node.mount();\n }\n }\n\n public unmount(): void {\n for (const node of this.collection) {\n node.unmount();\n\n if (!node.anchor.isConnected) {\n this.collection.delete(node);\n }\n }\n }\n}\n","import Context from \"./Context\";\n\nimport {ContentScriptNode} from \"@typing/content\";\n\nexport default class extends Context {\n public add(node: ContentScriptNode): this {\n this.collection.add(node);\n\n return this;\n }\n}\n","import Builder from \"@entry/core/Builder\";\n\nimport {contentScriptMountAppendResolver} from \"./resolvers/mount\";\nimport {contentScriptAnchorResolver} from \"./resolvers/anchor\";\nimport {contentScriptRenderResolver} from \"./resolvers/render\";\nimport {contentScriptContainerResolver} from \"./resolvers/container\";\nimport {\n contentScriptAwaitFirstResolver,\n contentScriptLocationResolver,\n contentScriptMutationObserverResolver,\n} from \"./resolvers/watch\";\n\nimport ManagedContext from \"./ManagedContext\";\n\nimport {\n ContentScriptAnchor,\n ContentScriptAnchorGetter,\n ContentScriptAnchorResolver,\n ContentScriptBuilder,\n ContentScriptContainerCreator,\n ContentScriptContainerFactory,\n ContentScriptContainerOptions,\n ContentScriptContainerTag,\n ContentScriptContext,\n ContentScriptDefinition,\n ContentScriptMountFunction,\n ContentScriptNode,\n ContentScriptRenderHandler,\n ContentScriptRenderValue,\n ContentScriptResolvedDefinition,\n ContentScriptWatchStrategy,\n} from \"@typing/content\";\n\nimport {Awaiter} from \"@typing/helpers\";\n\nexport default abstract class extends Builder implements ContentScriptBuilder {\n protected readonly definition: ContentScriptResolvedDefinition;\n\n protected context = new ManagedContext();\n\n protected unwatch?: () => void;\n\n private isProcessing: boolean = false;\n\n protected abstract createNode(anchor: Element): Promise<ContentScriptNode>;\n\n protected abstract cleanupNode(anchor: Element): Awaiter<void>;\n\n protected constructor(definition: ContentScriptDefinition) {\n super();\n\n this.definition = {\n ...definition,\n anchor: this.resolveAnchor(definition.anchor),\n mount: this.resolveMount(definition.mount),\n container: this.resolveContainer(definition.container),\n render: this.resolveRender(definition.render),\n watch: this.resolveWatch(definition.watch),\n };\n }\n\n protected resolveAnchor(anchor?: ContentScriptAnchor | ContentScriptAnchorGetter): ContentScriptAnchorResolver {\n return contentScriptAnchorResolver(anchor);\n }\n\n protected resolveMount(mount?: ContentScriptMountFunction): ContentScriptMountFunction {\n return mount || contentScriptMountAppendResolver();\n }\n\n protected resolveContainer(\n container?: ContentScriptContainerTag | ContentScriptContainerOptions | ContentScriptContainerFactory\n ): ContentScriptContainerCreator {\n return contentScriptContainerResolver(container);\n }\n\n protected resolveRender(\n render?: ContentScriptRenderValue | ContentScriptRenderHandler\n ): ContentScriptRenderHandler | undefined {\n if (render === undefined) {\n return;\n }\n\n return contentScriptRenderResolver(render);\n }\n\n protected resolveWatch(watch?: true | ContentScriptWatchStrategy): ContentScriptWatchStrategy {\n if (watch === undefined) {\n watch = contentScriptAwaitFirstResolver();\n } else if (watch === true) {\n watch = contentScriptMutationObserverResolver();\n }\n\n return contentScriptLocationResolver(watch);\n }\n\n public getContext(): ContentScriptContext {\n return this.context;\n }\n\n public async build(): Promise<void> {\n await this.destroy();\n\n const {render, main, anchor, container, watch, mount, ...options} = this.definition;\n\n if (render !== undefined) {\n await this.processing();\n\n this.unwatch = watch(() => {\n this.processing().catch(e => {\n console.error(\"Content script processing on watch error\", e);\n });\n }, this.context);\n }\n\n await main?.(this.context, options);\n }\n\n public async destroy(): Promise<void> {\n this.unwatch?.();\n this.unwatch = undefined;\n }\n\n protected async processing(): Promise<void> {\n if (this.isProcessing) {\n return;\n }\n\n this.isProcessing = true;\n\n const anchors = await this.definition.anchor();\n\n await Promise.allSettled(anchors.map(this.processAnchor.bind(this)));\n\n this.isProcessing = false;\n }\n\n protected async processAnchor(anchor: Element): Promise<void> {\n const node = await this.createNode(anchor);\n\n this.context.add(node);\n\n await this.cleanupNode(anchor);\n\n node.mount();\n }\n}\n","import {contentScriptAnchorAttribute} from \"./resolvers/anchor\";\n\nimport {ContentScriptNode} from \"@typing/content\";\n\nenum NodeMark {\n Mounded = \"1\",\n Unmounted = \"0\",\n}\n\nexport default class implements ContentScriptNode {\n private readonly _container?: Element;\n\n private readonly attr = contentScriptAnchorAttribute;\n\n constructor(\n public readonly anchor: Element,\n public container?: Element\n ) {\n if (this.container) {\n this._container = this.container.cloneNode(false) as Element;\n }\n }\n\n public mount(): void {\n this.mark();\n\n if (!this.container && this._container) {\n this.container = this._container.cloneNode(false) as Element;\n }\n }\n\n public unmount(): void {\n this.unmark();\n\n if (this.container) {\n this.container.remove();\n this.container = undefined;\n }\n }\n\n protected mark(): this {\n let id = this.anchor.getAttribute(this.attr);\n\n if (typeof id !== \"string\" || id.length === 0 || id === NodeMark.Unmounted) {\n this.anchor.setAttribute(this.attr, NodeMark.Mounded);\n }\n\n return this;\n }\n\n protected unmark(): void {\n this.anchor.setAttribute(this.attr, NodeMark.Unmounted);\n }\n}\n","import {ContentScriptMountFunction, ContentScriptNode} from \"@typing/content\";\n\nexport default class implements ContentScriptNode {\n private unmounting?: () => void;\n\n constructor(\n protected node: ContentScriptNode,\n protected mounter?: ContentScriptMountFunction\n ) {}\n\n public get anchor(): Element {\n return this.node.anchor;\n }\n\n public get container(): Element | undefined {\n return this.node.container;\n }\n\n public mount(): void {\n this.node.mount();\n\n if (!this.container || this.container.isConnected) {\n return;\n }\n\n const unmounting = this.mounter?.(this.anchor, this.container);\n\n if (unmounting) {\n this.unmounting = unmounting;\n }\n }\n\n public unmount(): void {\n this.unmounting?.();\n this.unmounting = undefined;\n\n this.node.unmount();\n }\n}\n","import Builder from \"./Builder\";\nimport Node from \"./Node\";\nimport MountNode from \"./MountNode\";\n\nimport {ContentScriptNode, ContentScriptProps, ContentScriptRenderValue} from \"@typing/content\";\n\nexport default abstract class extends Builder {\n private values = new Map<Element, null | ContentScriptRenderValue>();\n\n protected getProps(anchor: Element): ContentScriptProps {\n const {anchor: _, mount, watch, render, container, main, ...options} = this.definition;\n\n return {...options, anchor};\n }\n\n protected async getValue(anchor: Element): Promise<undefined | ContentScriptRenderValue> {\n if (!this.values.has(anchor)) {\n const value = await this.renderValue(anchor);\n\n this.values.set(anchor, value === undefined ? undefined : value);\n }\n\n return this.values.get(anchor);\n }\n\n protected async renderValue(anchor: Element): Promise<undefined | ContentScriptRenderValue> {\n const {render} = this.definition;\n\n if (render === undefined) {\n return;\n }\n\n return render(this.getProps(anchor));\n }\n\n protected async createNode(anchor: Element): Promise<ContentScriptNode> {\n let container: Element | undefined;\n\n if (await this.getValue(anchor)) {\n container = (await this.definition.container(this.getProps(anchor))) as Element | undefined;\n }\n\n return new MountNode(new Node(anchor, container), this.definition.mount);\n }\n\n protected cleanupNode(anchor: Element): void {\n this.values.delete(anchor);\n }\n}\n","import {ReactNode as ReactComponent} from \"react\";\nimport {createRoot, Root} from \"react-dom/client\";\n\nimport {ContentScriptNode} from \"@typing/content\";\n\nexport default class implements ContentScriptNode {\n protected root?: Root;\n\n constructor(\n protected readonly node: ContentScriptNode,\n protected readonly component?: ReactComponent\n ) {}\n\n public get anchor(): Element {\n return this.node.anchor;\n }\n\n public get container(): Element | undefined {\n return this.node.container;\n }\n\n public mount(): void {\n this.node.mount();\n\n if (!this.container || this.root) {\n return;\n }\n\n if (!this.component) {\n console.warn(\"Content script react component is empty\");\n\n return;\n }\n\n this.root = createRoot(this.container);\n\n this.root.render(this.component);\n }\n\n public unmount(): void {\n this.root?.unmount();\n this.root = undefined;\n\n this.node.unmount();\n }\n}\n","import {createElement, isValidElement} from \"react\";\n\nimport {ContentScriptRenderHandler, ContentScriptRenderValue} from \"@typing/content\";\n\nexport const contentScriptReactRenderResolver =\n (render?: ContentScriptRenderValue): ContentScriptRenderHandler =>\n async (props): Promise<undefined | ContentScriptRenderValue> => {\n let resolvedRender = typeof render === \"function\" ? createElement(render, props) : render;\n\n if (isValidElement(resolvedRender)) {\n return resolvedRender;\n }\n };\n","import {isValidElement} from \"react\";\n\nimport MountBuilder from \"../core/MountBuilder\";\nimport ReactNode from \"./Node\";\n\nimport {contentScriptReactRenderResolver} from \"./resolvers/render\";\n\nimport {\n ContentScriptDefinition,\n ContentScriptNode,\n ContentScriptRenderHandler,\n ContentScriptRenderValue,\n} from \"@typing/content\";\n\nexport default class extends MountBuilder {\n constructor(definition: ContentScriptDefinition) {\n super(definition);\n }\n\n protected resolveRender(render?: ContentScriptRenderValue): ContentScriptRenderHandler | undefined {\n if (render === undefined) {\n return;\n }\n\n return contentScriptReactRenderResolver(render);\n }\n\n protected async createNode(anchor: Element): Promise<ContentScriptNode> {\n let value = await this.getValue(anchor);\n\n if (!isValidElement(value)) {\n value = undefined;\n\n console.warn(\"Content script react value is not a valid React element\");\n }\n\n return new ReactNode(await super.createNode(anchor), value);\n }\n}\n","import Builder from \"./Builder\";\n\nexport {Builder};\n\nexport default Builder.resolver();\n"]}
1
+ {"version":3,"sources":["../../../../src/entry/core/Builder.ts","../../../../src/entry/content/core/resolvers/mount.ts","../../../../src/entry/content/core/resolvers/anchor.ts","../../../../src/entry/content/core/resolvers/render.ts","../../../../src/entry/content/core/resolvers/container.ts","../../../../src/entry/content/core/resolvers/watch.ts","../../../../src/entry/content/core/Context.ts","../../../../src/entry/content/core/ManagedContext.ts","../../../../src/entry/content/core/EventEmitter.ts","../../../../src/entry/content/core/Builder.ts","../../../../src/entry/content/core/Node.ts","../../../../src/entry/content/core/MountNode.ts","../../../../src/entry/content/core/MountBuilder.ts","../../../../src/entry/content/core/EventNode.ts","../../../../src/entry/content/react/Node.ts","../../../../src/entry/content/react/resolvers/render.ts","../../../../src/entry/content/react/Builder.ts","../../../../src/entry/content/react/index.ts"],"names":["Builder_default","Node_default","isValidElement"],"mappings":";;;;;;;;AAEA,IAAO,kBAAP,MAA2D;AAAA,EAKvD,OAAc,QAAwE,GAAA;AAClF,IAAA,OAAO,CAAC,UAAwD,KAAA;AAC5D,MAAA,IAAI,KAAK,UAAU,CAAA,CAAE,KAAM,EAAA,CAAE,MAAM,CAAK,CAAA,KAAA;AACpC,QAAQ,OAAA,CAAA,KAAA,CAAM,+BAA+B,CAAC,CAAA;AAAA,OACjD,CAAA;AAAA,KACL;AAAA;AAER,CAAA;;;ACXO,IAAM,gCACT,GAAA,CAAC,MACG,KAAA,CAAC,QAAiB,SAA6B,KAAA;AALvD,EAAA,IAAA,EAAA,EAAA,EAAA;AAMY,EAAA,QAAQ,MAAQ;AAAA,IACZ,KAAA,MAAA;AACI,MAAA,MAAA,CAAO,OAAO,SAAS,CAAA;AACvB,MAAA;AAAA,IACJ;AAAA,IACA,KAAK,MAAA;AAAA,IACL,KAAA,OAAA;AACI,MAAA,MAAA,CAAO,QAAQ,SAAS,CAAA;AACxB,MAAA;AAAA,IACJ,KAAA,SAAA;AACI,MAAA,MAAA,CAAO,YAAY,SAAS,CAAA;AAC5B,MAAA;AAAA,IACJ,KAAA,OAAA;AACI,MAAA,CAAA,EAAA,GAAA,MAAA,CAAO,aAAP,KAAA,I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BAAiB,OAAO,MAAA,KAAW,aAAa,aAAc,CAAA,MAAA,EAAQ,KAAK,CAAI,GAAA,MAAA;AAEnF,EAAI,IAAA,cAAA,CAAe,cAAc,CAAG,EAAA;AAChC,IAAO,OAAA,cAAA;AAAA;AAEf,CAAA;;;ACGGD,IAAAA,gBAAAA,GAAP,cAA6B,oBAAa,CAAA;AAAA,EACtC,YAAY,UAAqC,EAAA;AAC7C,IAAA,KAAA,CAAM,UAAU,CAAA;AAAA;AACpB,EAEU,cAAc,MAA2E,EAAA;AAC/F,IAAA,IAAI,WAAW,MAAW,EAAA;AACtB,MAAA;AAAA;AAGJ,IAAA,OAAO,iCAAiC,MAAM,CAAA;AAAA;AAClD,EAEA,MAAgB,WAAW,MAA6C,EAAA;AACpE,IAAA,IAAI,KAAQ,GAAA,MAAM,IAAK,CAAA,QAAA,CAAS,MAAM,CAAA;AAEtC,IAAI,IAAA,CAACE,cAAe,CAAA,KAAK,CAAG,EAAA;AACxB,MAAQ,KAAA,GAAA,MAAA;AAER,MAAA,OAAA,CAAQ,KAAK,yDAAyD,CAAA;AAAA;AAG1E,IAAA,OAAO,IAAI,iBAAA,CAAU,IAAID,aAAAA,CAAU,MAAM,KAAA,CAAM,UAAW,CAAA,MAAM,CAAG,EAAA,KAAK,CAAG,EAAA,IAAA,CAAK,OAAO,CAAA;AAAA;AAE/F;;;ACnCO,IAAA,aAAA,GAAQD,iBAAQ,QAAS","file":"index.js","sourcesContent":["import {EntrypointBuilder, EntrypointConstructorParameter} from \"@typing/entrypoint\";\n\nexport default abstract class implements EntrypointBuilder {\n public abstract build(): Promise<void>;\n\n public abstract destroy(): Promise<void>;\n\n public static resolver<T extends new (definition: any) => EntrypointBuilder>(this: T) {\n return (definition: EntrypointConstructorParameter<T>): void => {\n new this(definition).build().catch(e => {\n console.error(\"Failed to build entrypoint:\", e);\n });\n };\n }\n}\n","import {ContentScriptAppend, ContentScriptMountFunction} from \"@typing/content\";\n\n// prettier-ignore\nexport const contentScriptMountAppendResolver =\n (append?: ContentScriptAppend): ContentScriptMountFunction =>\n (anchor: Element, container: Element): void => {\n switch (append) {\n case ContentScriptAppend.Last:\n anchor.append(container);\n break;\n default:\n case undefined:\n case ContentScriptAppend.First:\n anchor.prepend(container);\n break;\n case ContentScriptAppend.Replace:\n anchor.replaceWith(container);\n break;\n case ContentScriptAppend.After:\n anchor.parentElement?.insertBefore(container, anchor.nextElementSibling);\n break;\n case ContentScriptAppend.Before:\n anchor.parentElement?.insertBefore(container, anchor);\n break;\n }\n };\n","import {customAlphabet} from \"nanoid\";\n\nimport {ContentScriptAnchor, ContentScriptAnchorGetter, ContentScriptAnchorResolver} from \"@typing/content\";\n\nconst generateId = customAlphabet(\"abcdefghijklmnopqrstuvwxyz\", 7);\n\nexport const contentScriptAnchorAttribute = `data-${generateId()}`;\n\n// prettier-ignore\nexport const contentScriptAnchorResolver =\n (anchor?: ContentScriptAnchor | ContentScriptAnchorGetter): ContentScriptAnchorResolver =>\n async (): Promise<Element[]> => {\n const attr = contentScriptAnchorAttribute;\n\n let resolved = typeof anchor === \"function\" ? anchor() : anchor;\n\n if (resolved instanceof Promise) {\n resolved = await resolved;\n }\n\n if (resolved === undefined || resolved === null) {\n resolved = document.body;\n }\n\n const elements: Element[] = [];\n\n if (resolved instanceof Element) {\n if (!resolved.hasAttribute(attr)) {\n elements.push(resolved);\n }\n } else if (typeof resolved === \"string\") {\n if (resolved.startsWith(\"/\")) {\n resolved = `(${resolved})[not(@${attr})]`;\n\n const result = document.evaluate(\n resolved,\n document,\n null,\n XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,\n null\n );\n\n for (let i = 0; i < result.snapshotLength; i++) {\n elements.push(result.snapshotItem(i) as Element);\n }\n } else {\n resolved += `:not([${attr}])`;\n\n elements.push(...Array.from(document.querySelectorAll(resolved)));\n }\n }\n\n return elements;\n };\n","import {ContentScriptRenderHandler, ContentScriptRenderValue} from \"@typing/content\";\n\nexport const isValidContentScriptRenderValue = (value: unknown): value is string | number | Element => {\n return (typeof value === \"string\" && value.length > 0) || typeof value === \"number\" || value instanceof Element;\n};\n\n// prettier-ignore\nexport const contentScriptRenderResolver =\n (render?: ContentScriptRenderValue | ContentScriptRenderHandler): ContentScriptRenderHandler =>\n async (props): Promise<undefined | ContentScriptRenderValue> => {\n let resolvedRender = typeof render === \"function\" ? render(props) : render;\n\n if (resolvedRender instanceof Promise) {\n resolvedRender = await resolvedRender;\n }\n\n if (resolvedRender !== true && !isValidContentScriptRenderValue(resolvedRender)) {\n return;\n }\n\n return resolvedRender;\n };\n","import {\n ContentScriptContainerCreator,\n ContentScriptContainerFactory,\n ContentScriptContainerOptions,\n ContentScriptContainerTag,\n ContentScriptProps,\n} from \"@typing/content\";\n\n// prettier-ignore\nexport const contentScriptContainerResolver = (\n container?:\n ContentScriptContainerTag |\n ContentScriptContainerOptions |\n ContentScriptContainerFactory\n): ContentScriptContainerCreator =>\n async (props: ContentScriptProps): Promise<Element> => {\n let resolvedContainer = typeof container === \"function\" ? container(props) : container;\n\n if (resolvedContainer instanceof Promise) {\n resolvedContainer = await resolvedContainer;\n }\n\n if (resolvedContainer === undefined || typeof resolvedContainer === \"string\") {\n resolvedContainer = document.createElement(resolvedContainer || \"div\");\n } else if (typeof resolvedContainer === \"object\" && resolvedContainer.constructor === Object) {\n const {tagName = \"div\", ...options} = resolvedContainer as ContentScriptContainerOptions;\n\n resolvedContainer = document.createElement(tagName);\n\n Object.assign(resolvedContainer, options);\n }\n\n if (!(resolvedContainer instanceof Element)) {\n throw new Error(\"The content script container must be a valid element\");\n }\n\n return resolvedContainer;\n };\n","import debounce from \"debounce\";\n\nimport {ContentScriptWatchStrategy} from \"@typing/content\";\n\n// prettier-ignore\nexport const contentScriptMutationObserverResolver =\n (options?: MutationObserverInit): ContentScriptWatchStrategy =>\n update => {\n if (!options) {\n options = {};\n }\n\n const handle = debounce(update, 200);\n\n const observer = new MutationObserver(handle);\n\n observer.observe(document.body, {\n childList: true,\n subtree: true,\n attributes: true,\n characterData: true,\n ...options,\n });\n\n return () => {\n handle.clear();\n observer.disconnect();\n };\n };\n\n// prettier-ignore\nexport const contentScriptAwaitFirstResolver =\n (options?: MutationObserverInit): ContentScriptWatchStrategy =>\n (update, context) => {\n const resolver = contentScriptMutationObserverResolver({\n attributes: false,\n characterData: false,\n ...options,\n });\n\n let unwatch: { (): void } | undefined;\n\n const clear = () => {\n unwatch && unwatch();\n unwatch = undefined;\n };\n\n if (context.nodes.size === 0) {\n unwatch = resolver(() => {\n update();\n\n if (context.nodes.size > 0) {\n clear();\n }\n }, context);\n }\n\n return () => {\n clear();\n };\n };\n\n// prettier-ignore\nexport const contentScriptLocationResolver =\n (strategy: ContentScriptWatchStrategy): ContentScriptWatchStrategy =>\n (update, context) => {\n let currentUrl = location.href;\n\n const interval = setInterval(() => {\n if (currentUrl !== location.href) {\n currentUrl = location.href;\n\n context.mount();\n }\n }, 300);\n\n const unwatch = strategy(update, context);\n\n return () => {\n clearInterval(interval);\n unwatch();\n };\n };\n","import {\n ContentScriptContext,\n ContentScriptEventCallback,\n ContentScriptEventEmitter,\n ContentScriptNode,\n ContentScriptNodeSet,\n} from \"@typing/content\";\n\nexport default class implements ContentScriptContext {\n protected readonly collection: ContentScriptNodeSet = new Set();\n\n constructor(protected readonly emitter: ContentScriptEventEmitter) {}\n\n public get nodes(): ReadonlySet<ContentScriptNode> {\n return this.collection;\n }\n\n public mount(): void {\n for (const node of this.collection) {\n if (!node.anchor.isConnected) {\n node.unmount();\n\n this.collection.delete(node);\n\n this.emitter.emitRemove(node);\n\n continue;\n }\n\n node.mount();\n }\n }\n\n public unmount(): void {\n for (const node of this.collection) {\n node.unmount();\n\n if (!node.anchor.isConnected) {\n this.collection.delete(node);\n\n this.emitter.emitRemove(node);\n }\n }\n }\n\n public watch(callback: ContentScriptEventCallback): () => void {\n this.emitter.on(callback);\n\n return () => {\n this.emitter.off(callback);\n };\n }\n\n public unwatch(): void {\n this.emitter.removeAllListeners();\n }\n}\n","import Context from \"./Context\";\n\nimport {ContentScriptNode} from \"@typing/content\";\n\nexport default class extends Context {\n public add(node: ContentScriptNode): this {\n this.collection.add(node);\n\n this.emitter.emitAdd(node);\n\n return this;\n }\n}\n","import {\n ContentScriptEvent,\n ContentScriptEventCallback,\n ContentScriptEventEmitter,\n ContentScriptNode,\n} from \"@typing/content\";\n\nexport default class implements ContentScriptEventEmitter {\n private readonly listeners: Set<ContentScriptEventCallback> = new Set();\n\n public emit(event: ContentScriptEvent, node: ContentScriptNode): void {\n for (const listener of this.listeners) {\n listener(event, node);\n }\n }\n\n public emitAdd(node: ContentScriptNode): void {\n this.emit(ContentScriptEvent.Add, node);\n }\n\n public emitMount(node: ContentScriptNode): void {\n this.emit(ContentScriptEvent.Mount, node);\n }\n\n public emitRemove(node: ContentScriptNode): void {\n this.emit(ContentScriptEvent.Remove, node);\n }\n\n public emitUnmount(node: ContentScriptNode): void {\n this.emit(ContentScriptEvent.Unmount, node);\n }\n\n public hasListeners(): boolean {\n return this.listenerCount() > 0;\n }\n\n public listenerCount(): number {\n return this.listeners.size;\n }\n\n public off(callback: ContentScriptEventCallback): void {\n this.listeners.delete(callback);\n }\n\n public on(callback: ContentScriptEventCallback): void {\n this.listeners.add(callback);\n }\n\n public removeAllListeners(): void {\n this.listeners.clear();\n }\n}\n","import Builder from \"@entry/core/Builder\";\n\nimport {contentScriptMountAppendResolver} from \"./resolvers/mount\";\nimport {contentScriptAnchorResolver} from \"./resolvers/anchor\";\nimport {contentScriptRenderResolver} from \"./resolvers/render\";\nimport {contentScriptContainerResolver} from \"./resolvers/container\";\nimport {\n contentScriptAwaitFirstResolver,\n contentScriptLocationResolver,\n contentScriptMutationObserverResolver,\n} from \"./resolvers/watch\";\n\nimport ManagedContext from \"./ManagedContext\";\nimport EventEmitter from \"./EventEmitter\";\n\nimport {\n ContentScriptAnchor,\n ContentScriptAnchorGetter,\n ContentScriptAnchorResolver,\n ContentScriptBuilder,\n ContentScriptContainerCreator,\n ContentScriptContainerFactory,\n ContentScriptContainerOptions,\n ContentScriptContainerTag,\n ContentScriptContext,\n ContentScriptDefinition,\n ContentScriptMountFunction,\n ContentScriptNode,\n ContentScriptRenderHandler,\n ContentScriptRenderValue,\n ContentScriptResolvedDefinition,\n ContentScriptWatchStrategy,\n} from \"@typing/content\";\n\nimport {Awaiter} from \"@typing/helpers\";\n\nexport default abstract class extends Builder implements ContentScriptBuilder {\n protected readonly definition: ContentScriptResolvedDefinition;\n\n protected readonly emitter = new EventEmitter();\n\n protected readonly context = new ManagedContext(this.emitter);\n\n protected unwatch?: () => void;\n\n private isProcessing: boolean = false;\n\n protected abstract createNode(anchor: Element): Promise<ContentScriptNode>;\n\n protected abstract cleanupNode(anchor: Element): Awaiter<void>;\n\n protected constructor(definition: ContentScriptDefinition) {\n super();\n\n this.definition = {\n ...definition,\n anchor: this.resolveAnchor(definition.anchor),\n mount: this.resolveMount(definition.mount),\n container: this.resolveContainer(definition.container),\n render: this.resolveRender(definition.render),\n watch: this.resolveWatch(definition.watch),\n };\n }\n\n protected resolveAnchor(anchor?: ContentScriptAnchor | ContentScriptAnchorGetter): ContentScriptAnchorResolver {\n return contentScriptAnchorResolver(anchor);\n }\n\n protected resolveMount(mount?: ContentScriptMountFunction): ContentScriptMountFunction {\n return mount || contentScriptMountAppendResolver();\n }\n\n protected resolveContainer(\n container?: ContentScriptContainerTag | ContentScriptContainerOptions | ContentScriptContainerFactory\n ): ContentScriptContainerCreator {\n return contentScriptContainerResolver(container);\n }\n\n protected resolveRender(\n render?: ContentScriptRenderValue | ContentScriptRenderHandler\n ): ContentScriptRenderHandler | undefined {\n if (render === undefined) {\n return;\n }\n\n return contentScriptRenderResolver(render);\n }\n\n protected resolveWatch(watch?: true | ContentScriptWatchStrategy): ContentScriptWatchStrategy {\n if (watch === undefined) {\n watch = contentScriptAwaitFirstResolver();\n } else if (watch === true) {\n watch = contentScriptMutationObserverResolver();\n }\n\n return contentScriptLocationResolver(watch);\n }\n\n public getContext(): ContentScriptContext {\n return this.context;\n }\n\n public async build(): Promise<void> {\n await this.destroy();\n\n const {render, main, anchor, container, watch, mount, ...options} = this.definition;\n\n await main?.(this.context, options);\n\n if (render !== undefined) {\n await this.processing();\n\n this.unwatch = watch(() => {\n this.processing().catch(e => {\n console.error(\"Content script processing on watch error\", e);\n });\n }, this.context);\n }\n }\n\n public async destroy(): Promise<void> {\n this.unwatch?.();\n this.unwatch = undefined;\n }\n\n protected async processing(): Promise<void> {\n if (this.isProcessing) {\n return;\n }\n\n this.isProcessing = true;\n\n const anchors = await this.definition.anchor();\n\n await Promise.allSettled(anchors.map(this.processAnchor.bind(this)));\n\n this.isProcessing = false;\n }\n\n protected async processAnchor(anchor: Element): Promise<void> {\n const node = await this.createNode(anchor);\n\n this.context.add(node);\n\n await this.cleanupNode(anchor);\n\n node.mount();\n }\n}\n","import {contentScriptAnchorAttribute} from \"./resolvers/anchor\";\n\nimport {ContentScriptNode} from \"@typing/content\";\n\nenum NodeMark {\n Mounded = \"1\",\n Unmounted = \"0\",\n}\n\nexport default class implements ContentScriptNode {\n private readonly _container?: Element;\n\n private readonly attr = contentScriptAnchorAttribute;\n\n constructor(\n public readonly anchor: Element,\n public container?: Element\n ) {\n if (this.container) {\n this._container = this.container.cloneNode(false) as Element;\n }\n }\n\n public mount(): boolean {\n this.mark();\n\n if (!this.container && this._container) {\n this.container = this._container.cloneNode(false) as Element;\n\n return true;\n }\n\n return false;\n }\n\n public unmount(): boolean {\n this.unmark();\n\n if (this.container) {\n this.container.remove();\n this.container = undefined;\n\n return true;\n }\n\n return false;\n }\n\n protected mark(): this {\n let id = this.anchor.getAttribute(this.attr);\n\n if (typeof id !== \"string\" || id.length === 0 || id === NodeMark.Unmounted) {\n this.anchor.setAttribute(this.attr, NodeMark.Mounded);\n }\n\n return this;\n }\n\n protected unmark(): void {\n this.anchor.setAttribute(this.attr, NodeMark.Unmounted);\n }\n}\n","import {ContentScriptMountFunction, ContentScriptNode} from \"@typing/content\";\n\nexport default class implements ContentScriptNode {\n private unmounting?: () => void;\n\n constructor(\n protected node: ContentScriptNode,\n protected mounter?: ContentScriptMountFunction\n ) {}\n\n public get anchor(): Element {\n return this.node.anchor;\n }\n\n public get container(): Element | undefined {\n return this.node.container;\n }\n\n public mount(): boolean {\n this.node.mount();\n\n if (!this.container || this.container.isConnected) {\n return false;\n }\n\n if (this.mounter) {\n const unmounting = this.mounter(this.anchor, this.container);\n\n if (unmounting) {\n this.unmounting = unmounting;\n }\n\n return true;\n }\n\n return false;\n }\n\n public unmount(): boolean {\n this.unmounting?.();\n this.unmounting = undefined;\n\n return !!this.node.unmount();\n }\n}\n","import Builder from \"./Builder\";\nimport Node from \"./Node\";\nimport MountNode from \"./MountNode\";\n\nimport {ContentScriptNode, ContentScriptProps, ContentScriptRenderValue} from \"@typing/content\";\n\nexport default abstract class extends Builder {\n private values = new Map<Element, null | ContentScriptRenderValue>();\n\n protected getProps(anchor: Element): ContentScriptProps {\n const {anchor: _, mount, watch, render, container, main, ...options} = this.definition;\n\n return {...options, anchor};\n }\n\n protected async getValue(anchor: Element): Promise<undefined | ContentScriptRenderValue> {\n if (!this.values.has(anchor)) {\n const value = await this.renderValue(anchor);\n\n this.values.set(anchor, value === undefined ? undefined : value);\n }\n\n return this.values.get(anchor);\n }\n\n protected async renderValue(anchor: Element): Promise<undefined | ContentScriptRenderValue> {\n const {render} = this.definition;\n\n if (render === undefined) {\n return;\n }\n\n return render(this.getProps(anchor));\n }\n\n protected async createNode(anchor: Element): Promise<ContentScriptNode> {\n let container: Element | undefined;\n\n const value = await this.getValue(anchor);\n\n if (typeof value !== \"boolean\" && value !== undefined) {\n container = (await this.definition.container(this.getProps(anchor))) as Element | undefined;\n }\n\n return new MountNode(new Node(anchor, container), this.definition.mount);\n }\n\n protected cleanupNode(anchor: Element): void {\n this.values.delete(anchor);\n }\n}\n","import {ContentScriptEventEmitter, ContentScriptNode} from \"@typing/content\";\n\nexport default class implements ContentScriptNode {\n constructor(\n protected readonly node: ContentScriptNode,\n protected readonly emitter: ContentScriptEventEmitter\n ) {}\n\n public get anchor(): Element {\n return this.node.anchor;\n }\n\n public get container(): Element | undefined {\n return this.node.container;\n }\n\n public mount(): boolean {\n const result = this.node.mount();\n\n if (result === true) {\n this.emitter.emitMount(this.node);\n }\n\n return !!result;\n }\n\n public unmount(): boolean {\n const result = this.node.unmount();\n\n if (result === true) {\n this.emitter.emitUnmount(this.node);\n }\n\n return !!result;\n }\n}\n","import {ReactNode as ReactComponent} from \"react\";\nimport {createRoot, Root} from \"react-dom/client\";\n\nimport {ContentScriptNode} from \"@typing/content\";\n\nexport default class implements ContentScriptNode {\n protected root?: Root;\n\n constructor(\n protected readonly node: ContentScriptNode,\n protected readonly component?: ReactComponent\n ) {}\n\n public get anchor(): Element {\n return this.node.anchor;\n }\n\n public get container(): Element | undefined {\n return this.node.container;\n }\n\n public mount(): boolean {\n this.node.mount();\n\n if (!this.container || this.root) {\n return false;\n }\n\n if (!this.component) {\n console.warn(\"Content script react component is empty\");\n\n return false;\n }\n\n this.root = createRoot(this.container);\n\n this.root.render(this.component);\n\n return true;\n }\n\n public unmount(): boolean {\n this.root?.unmount();\n this.root = undefined;\n\n return !!this.node.unmount();\n }\n}\n","import {createElement, isValidElement} from \"react\";\n\nimport {ContentScriptRenderHandler, ContentScriptRenderValue} from \"@typing/content\";\n\nexport const contentScriptReactRenderResolver =\n (render?: ContentScriptRenderValue): ContentScriptRenderHandler =>\n async (props): Promise<undefined | ContentScriptRenderValue> => {\n let resolvedRender = typeof render === \"function\" ? createElement(render, props) : render;\n\n if (isValidElement(resolvedRender)) {\n return resolvedRender;\n }\n };\n","import {isValidElement} from \"react\";\n\nimport MountBuilder from \"../core/MountBuilder\";\nimport EventNode from \"../core/EventNode\";\nimport ReactNode from \"./Node\";\n\nimport {contentScriptReactRenderResolver} from \"./resolvers/render\";\n\nimport {\n ContentScriptDefinition,\n ContentScriptNode,\n ContentScriptRenderHandler,\n ContentScriptRenderValue,\n} from \"@typing/content\";\n\nexport default class extends MountBuilder {\n constructor(definition: ContentScriptDefinition) {\n super(definition);\n }\n\n protected resolveRender(render?: ContentScriptRenderValue): ContentScriptRenderHandler | undefined {\n if (render === undefined) {\n return;\n }\n\n return contentScriptReactRenderResolver(render);\n }\n\n protected async createNode(anchor: Element): Promise<ContentScriptNode> {\n let value = await this.getValue(anchor);\n\n if (!isValidElement(value)) {\n value = undefined;\n\n console.warn(\"Content script react value is not a valid React element\");\n }\n\n return new EventNode(new ReactNode(await super.createNode(anchor), value), this.emitter);\n }\n}\n","import Builder from \"./Builder\";\n\nexport {Builder};\n\nexport default Builder.resolver();\n"]}
@@ -76,11 +76,7 @@ var contentScriptAnchorResolver = (anchor) => async () => {
76
76
  }
77
77
  } else if (typeof resolved === "string") {
78
78
  if (resolved.startsWith("/")) {
79
- const notRegex = /not\(\s*[^)]+\s*\)/;
80
- const condition = `not(@${attr})`;
81
- if (notRegex.test(resolved)) {
82
- resolved = `(${resolved})[${condition}]`;
83
- }
79
+ resolved = `(${resolved})[not(@${attr})]`;
84
80
  const result = document.evaluate(
85
81
  resolved,
86
82
  document,
@@ -175,6 +171,9 @@ var contentScriptLocationResolver = (strategy) => (update, context) => {
175
171
 
176
172
  // src/entry/content/core/Context.ts
177
173
  var Context_default = class {
174
+ constructor(emitter) {
175
+ this.emitter = emitter;
176
+ }
178
177
  collection = /* @__PURE__ */ new Set();
179
178
  get nodes() {
180
179
  return this.collection;
@@ -184,6 +183,7 @@ var Context_default = class {
184
183
  if (!node.anchor.isConnected) {
185
184
  node.unmount();
186
185
  this.collection.delete(node);
186
+ this.emitter.emitRemove(node);
187
187
  continue;
188
188
  }
189
189
  node.mount();
@@ -194,23 +194,72 @@ var Context_default = class {
194
194
  node.unmount();
195
195
  if (!node.anchor.isConnected) {
196
196
  this.collection.delete(node);
197
+ this.emitter.emitRemove(node);
197
198
  }
198
199
  }
199
200
  }
201
+ watch(callback) {
202
+ this.emitter.on(callback);
203
+ return () => {
204
+ this.emitter.off(callback);
205
+ };
206
+ }
207
+ unwatch() {
208
+ this.emitter.removeAllListeners();
209
+ }
200
210
  };
201
211
 
202
212
  // src/entry/content/core/ManagedContext.ts
203
213
  var ManagedContext_default = class extends Context_default {
204
214
  add(node) {
205
215
  this.collection.add(node);
216
+ this.emitter.emitAdd(node);
206
217
  return this;
207
218
  }
208
219
  };
209
220
 
221
+ // src/entry/content/core/EventEmitter.ts
222
+ var EventEmitter_default = class {
223
+ listeners = /* @__PURE__ */ new Set();
224
+ emit(event, node) {
225
+ for (const listener of this.listeners) {
226
+ listener(event, node);
227
+ }
228
+ }
229
+ emitAdd(node) {
230
+ this.emit("add" /* Add */, node);
231
+ }
232
+ emitMount(node) {
233
+ this.emit("mount" /* Mount */, node);
234
+ }
235
+ emitRemove(node) {
236
+ this.emit("remove" /* Remove */, node);
237
+ }
238
+ emitUnmount(node) {
239
+ this.emit("unmount" /* Unmount */, node);
240
+ }
241
+ hasListeners() {
242
+ return this.listenerCount() > 0;
243
+ }
244
+ listenerCount() {
245
+ return this.listeners.size;
246
+ }
247
+ off(callback) {
248
+ this.listeners.delete(callback);
249
+ }
250
+ on(callback) {
251
+ this.listeners.add(callback);
252
+ }
253
+ removeAllListeners() {
254
+ this.listeners.clear();
255
+ }
256
+ };
257
+
210
258
  // src/entry/content/core/Builder.ts
211
259
  var Builder_default2 = class extends Builder_default {
212
260
  definition;
213
- context = new ManagedContext_default();
261
+ emitter = new EventEmitter_default();
262
+ context = new ManagedContext_default(this.emitter);
214
263
  unwatch;
215
264
  isProcessing = false;
216
265
  constructor(definition) {
@@ -253,6 +302,7 @@ var Builder_default2 = class extends Builder_default {
253
302
  async build() {
254
303
  await this.destroy();
255
304
  const { render, main, anchor, container, watch, mount, ...options } = this.definition;
305
+ await (main == null ? void 0 : main(this.context, options));
256
306
  if (render !== void 0) {
257
307
  await this.processing();
258
308
  this.unwatch = watch(() => {
@@ -261,7 +311,6 @@ var Builder_default2 = class extends Builder_default {
261
311
  });
262
312
  }, this.context);
263
313
  }
264
- await (main == null ? void 0 : main(this.context, options));
265
314
  }
266
315
  async destroy() {
267
316
  var _a;
@@ -300,14 +349,18 @@ var Node_default = class {
300
349
  this.mark();
301
350
  if (!this.container && this._container) {
302
351
  this.container = this._container.cloneNode(false);
352
+ return true;
303
353
  }
354
+ return false;
304
355
  }
305
356
  unmount() {
306
357
  this.unmark();
307
358
  if (this.container) {
308
359
  this.container.remove();
309
360
  this.container = void 0;
361
+ return true;
310
362
  }
363
+ return false;
311
364
  }
312
365
  mark() {
313
366
  let id = this.anchor.getAttribute(this.attr);
@@ -335,21 +388,24 @@ var MountNode_default = class {
335
388
  return this.node.container;
336
389
  }
337
390
  mount() {
338
- var _a;
339
391
  this.node.mount();
340
392
  if (!this.container || this.container.isConnected) {
341
- return;
393
+ return false;
342
394
  }
343
- const unmounting = (_a = this.mounter) == null ? void 0 : _a.call(this, this.anchor, this.container);
344
- if (unmounting) {
345
- this.unmounting = unmounting;
395
+ if (this.mounter) {
396
+ const unmounting = this.mounter(this.anchor, this.container);
397
+ if (unmounting) {
398
+ this.unmounting = unmounting;
399
+ }
400
+ return true;
346
401
  }
402
+ return false;
347
403
  }
348
404
  unmount() {
349
405
  var _a;
350
406
  (_a = this.unmounting) == null ? void 0 : _a.call(this);
351
407
  this.unmounting = void 0;
352
- this.node.unmount();
408
+ return !!this.node.unmount();
353
409
  }
354
410
  };
355
411
 
@@ -376,7 +432,8 @@ var MountBuilder_default = class extends Builder_default2 {
376
432
  }
377
433
  async createNode(anchor) {
378
434
  let container;
379
- if (await this.getValue(anchor)) {
435
+ const value = await this.getValue(anchor);
436
+ if (typeof value !== "boolean" && value !== void 0) {
380
437
  container = await this.definition.container(this.getProps(anchor));
381
438
  }
382
439
  return new MountNode_default(new Node_default(anchor, container), this.definition.mount);
@@ -386,6 +443,34 @@ var MountBuilder_default = class extends Builder_default2 {
386
443
  }
387
444
  };
388
445
 
446
+ // src/entry/content/core/EventNode.ts
447
+ var EventNode_default = class {
448
+ constructor(node, emitter) {
449
+ this.node = node;
450
+ this.emitter = emitter;
451
+ }
452
+ get anchor() {
453
+ return this.node.anchor;
454
+ }
455
+ get container() {
456
+ return this.node.container;
457
+ }
458
+ mount() {
459
+ const result = this.node.mount();
460
+ if (result === true) {
461
+ this.emitter.emitMount(this.node);
462
+ }
463
+ return !!result;
464
+ }
465
+ unmount() {
466
+ const result = this.node.unmount();
467
+ if (result === true) {
468
+ this.emitter.emitUnmount(this.node);
469
+ }
470
+ return !!result;
471
+ }
472
+ };
473
+
389
474
  // src/entry/content/vanilla/Node.ts
390
475
  var Node_default2 = class {
391
476
  constructor(node, value) {
@@ -402,20 +487,25 @@ var Node_default2 = class {
402
487
  mount() {
403
488
  this.node.mount();
404
489
  if (!this.container || this.mounted) {
405
- return;
490
+ return false;
406
491
  }
492
+ let result = true;
407
493
  if (this.value instanceof Element) {
408
494
  this.container.appendChild(this.value);
409
495
  } else if (typeof this.value === "string" || typeof this.value === "number") {
410
496
  this.container.textContent = String(this.value);
411
- } else if (this.value === null || this.value === void 0) {
497
+ } else if (this.value === null || this.value === void 0 || this.value === false) {
498
+ result = false;
412
499
  console.warn("Content script vanilla value is empty");
500
+ } else if (this.value === true) {
501
+ result = false;
413
502
  }
414
503
  this.mounted = true;
504
+ return result;
415
505
  }
416
506
  unmount() {
417
- this.node.unmount();
418
507
  this.mounted = false;
508
+ return !!this.node.unmount();
419
509
  }
420
510
  };
421
511
 
@@ -430,7 +520,7 @@ var Builder_default3 = class extends MountBuilder_default {
430
520
  value = void 0;
431
521
  console.warn("Content script vanilla value is not a valid render value");
432
522
  }
433
- return new Node_default2(await super.createNode(anchor), value);
523
+ return new EventNode_default(new Node_default2(await super.createNode(anchor), value), this.emitter);
434
524
  }
435
525
  };
436
526
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/entry/content/core/resolvers/render.ts","../../../../src/entry/core/Builder.ts","../../../../src/entry/content/core/resolvers/mount.ts","../../../../src/entry/content/core/resolvers/anchor.ts","../../../../src/entry/content/core/resolvers/container.ts","../../../../src/entry/content/core/resolvers/watch.ts","../../../../src/entry/content/core/Context.ts","../../../../src/entry/content/core/ManagedContext.ts","../../../../src/entry/content/core/Builder.ts","../../../../src/entry/content/core/Node.ts","../../../../src/entry/content/core/MountNode.ts","../../../../src/entry/content/core/MountBuilder.ts","../../../../src/entry/content/vanilla/Node.ts","../../../../src/entry/content/vanilla/Builder.ts","../../../../src/entry/content/vanilla/index.ts"],"names":["customAlphabet","debounce","Builder_default","Node_default"],"mappings":";;;;;;;;;;;;AAEO,IAAM,+BAAA,GAAkC,CAAC,KAAuD,KAAA;AACnG,EAAQ,OAAA,OAAO,UAAU,QAAY,IAAA,KAAA,CAAM,SAAS,CAAM,IAAA,OAAO,KAAU,KAAA,QAAA,IAAY,KAAiB,YAAA,OAAA;AAC5G,CAAA;AAGO,IAAM,2BACT,GAAA,CAAC,MACG,KAAA,OAAO,KAAyD,KAAA;AAC5D,EAAA,IAAI,iBAAiB,OAAO,MAAA,KAAW,UAAa,GAAA,MAAA,CAAO,KAAK,CAAI,GAAA,MAAA;AAEpE,EAAA,IAAI,0BAA0B,OAAS,EAAA;AACnC,IAAA,cAAA,GAAiB,MAAM,cAAA;AAAA;AAG3B,EAAA,IAAI,cAAmB,KAAA,IAAA,IAAQ,CAAC,+BAAA,CAAgC,cAAc,CAAG,EAAA;AAC7E,IAAA;AAAA;AAGJ,EAAO,OAAA,cAAA;AACX,CAAA;;;ACnBR,IAAO,kBAAP,MAA2D;AAAA,EAKvD,OAAc,QAAwE,GAAA;AAClF,IAAA,OAAO,CAAC,UAAwD,KAAA;AAC5D,MAAA,IAAI,KAAK,UAAU,CAAA,CAAE,KAAM,EAAA,CAAE,MAAM,CAAK,CAAA,KAAA;AACpC,QAAQ,OAAA,CAAA,KAAA,CAAM,+BAA+B,CAAC,CAAA;AAAA,OACjD,CAAA;AAAA,KACL;AAAA;AAER,CAAA;;;ACXO,IAAM,gCACT,GAAA,CAAC,MACG,KAAA,CAAC,QAAiB,SAA6B,KAAA;AALvD,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I,KAAQ,GAAA,MAAM,IAAK,CAAA,QAAA,CAAS,MAAM,CAAA;AAEtC,IAAA,IAAI,KAAU,KAAA,IAAA,IAAQ,CAAC,+BAAA,CAAgC,KAAK,CAAG,EAAA;AAC3D,MAAQ,KAAA,GAAA,MAAA;AAER,MAAA,OAAA,CAAQ,KAAK,0DAA0D,CAAA;AAAA;AAG3E,IAAA,OAAO,IAAIC,aAAY,CAAA,MAAM,MAAM,UAAW,CAAA,MAAM,GAAG,KAAK,CAAA;AAAA;AAEpE;;;ACnBO,IAAA,eAAA,GAAQD,iBAAQ,QAAS","file":"index.cjs","sourcesContent":["import {ContentScriptRenderHandler, ContentScriptRenderValue} from \"@typing/content\";\n\nexport const isValidContentScriptRenderValue = (value: unknown): value is string | number | Element => {\n return (typeof value === \"string\" && value.length > 0) || typeof value === \"number\" || value instanceof Element;\n};\n\n// prettier-ignore\nexport const contentScriptRenderResolver =\n (render?: ContentScriptRenderValue | ContentScriptRenderHandler): ContentScriptRenderHandler =>\n async (props): Promise<undefined | ContentScriptRenderValue> => {\n let resolvedRender = typeof render === \"function\" ? render(props) : render;\n\n if (resolvedRender instanceof Promise) {\n resolvedRender = await resolvedRender;\n }\n\n if (resolvedRender !== true && !isValidContentScriptRenderValue(resolvedRender)) {\n return;\n }\n\n return resolvedRender;\n };\n","import {EntrypointBuilder, EntrypointConstructorParameter} from \"@typing/entrypoint\";\n\nexport default abstract class implements EntrypointBuilder {\n public abstract build(): Promise<void>;\n\n public abstract destroy(): Promise<void>;\n\n public static resolver<T extends new (definition: any) => EntrypointBuilder>(this: T) {\n return (definition: EntrypointConstructorParameter<T>): void => {\n new this(definition).build().catch(e => {\n console.error(\"Failed to build entrypoint:\", e);\n });\n };\n }\n}\n","import {ContentScriptAppend, ContentScriptMountFunction} from \"@typing/content\";\n\n// prettier-ignore\nexport const contentScriptMountAppendResolver =\n (append?: ContentScriptAppend): ContentScriptMountFunction =>\n (anchor: Element, container: Element): void => {\n switch (append) {\n case ContentScriptAppend.Last:\n anchor.append(container);\n break;\n default:\n case undefined:\n case ContentScriptAppend.First:\n anchor.prepend(container);\n break;\n case ContentScriptAppend.Replace:\n anchor.replaceWith(container);\n break;\n case ContentScriptAppend.After:\n anchor.parentElement?.insertBefore(container, anchor.nextElementSibling);\n break;\n case ContentScriptAppend.Before:\n anchor.parentElement?.insertBefore(container, anchor);\n break;\n }\n };\n","import {customAlphabet} from \"nanoid\";\n\nimport {ContentScriptAnchor, ContentScriptAnchorGetter, ContentScriptAnchorResolver} from \"@typing/content\";\n\nconst generateId = customAlphabet(\"abcdefghijklmnopqrstuvwxyz\", 7);\n\nexport const contentScriptAnchorAttribute = `data-${generateId()}`;\n\n// prettier-ignore\nexport const contentScriptAnchorResolver =\n (anchor?: ContentScriptAnchor | ContentScriptAnchorGetter): ContentScriptAnchorResolver =>\n async (): Promise<Element[]> => {\n const attr = contentScriptAnchorAttribute;\n\n let resolved = typeof anchor === \"function\" ? anchor() : anchor;\n\n if (resolved instanceof Promise) {\n resolved = await resolved;\n }\n\n if (resolved === undefined || resolved === null) {\n resolved = document.body;\n }\n\n const elements: Element[] = [];\n\n if (resolved instanceof Element) {\n if (!resolved.hasAttribute(attr)) {\n elements.push(resolved);\n }\n } else if (typeof resolved === \"string\") {\n if (resolved.startsWith(\"/\")) {\n const notRegex = /not\\(\\s*[^)]+\\s*\\)/;\n const condition = `not(@${attr})`;\n\n if (notRegex.test(resolved)) {\n resolved = `(${resolved})[${condition}]`;\n }\n\n const result = document.evaluate(\n resolved,\n document,\n null,\n XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,\n null\n );\n\n for (let i = 0; i < result.snapshotLength; i++) {\n elements.push(result.snapshotItem(i) as Element);\n }\n } else {\n resolved += `:not([${attr}])`;\n\n elements.push(...Array.from(document.querySelectorAll(resolved)));\n }\n }\n\n return elements;\n };\n","import {\n ContentScriptContainerCreator,\n ContentScriptContainerFactory,\n ContentScriptContainerOptions,\n ContentScriptContainerTag,\n ContentScriptProps,\n} from \"@typing/content\";\n\nexport const contentScriptContainerResolver =\n (\n container?: ContentScriptContainerTag | ContentScriptContainerOptions | ContentScriptContainerFactory\n ): ContentScriptContainerCreator =>\n async (props: ContentScriptProps): Promise<Element> => {\n let resolvedContainer = typeof container === \"function\" ? container(props) : container;\n\n if (resolvedContainer instanceof Promise) {\n resolvedContainer = await resolvedContainer;\n }\n\n if (resolvedContainer === undefined || typeof resolvedContainer === \"string\") {\n resolvedContainer = document.createElement(resolvedContainer || \"div\");\n } else if (typeof resolvedContainer === \"object\" && resolvedContainer.constructor === Object) {\n const {tagName = \"div\", ...options} = resolvedContainer as ContentScriptContainerOptions;\n\n resolvedContainer = document.createElement(tagName);\n\n Object.assign(resolvedContainer, options);\n }\n\n if (!(resolvedContainer instanceof Element)) {\n throw new Error(\"The content script container must be a valid element\");\n }\n\n return resolvedContainer;\n };\n","import debounce from \"debounce\";\n\nimport {ContentScriptWatchStrategy} from \"@typing/content\";\n\n// prettier-ignore\nexport const contentScriptMutationObserverResolver =\n (options?: MutationObserverInit): ContentScriptWatchStrategy =>\n update => {\n if (!options) {\n options = {};\n }\n\n const handle = debounce(update, 200);\n\n const observer = new MutationObserver(handle);\n\n observer.observe(document.body, {\n childList: true,\n subtree: true,\n attributes: true,\n characterData: true,\n ...options,\n });\n\n return () => {\n handle.clear();\n observer.disconnect();\n };\n };\n\n// prettier-ignore\nexport const contentScriptAwaitFirstResolver =\n (options?: MutationObserverInit): ContentScriptWatchStrategy =>\n (update, context) => {\n const resolver = contentScriptMutationObserverResolver({\n attributes: false,\n characterData: false,\n ...options,\n });\n\n let unwatch: { (): void } | undefined;\n\n const clear = () => {\n unwatch && unwatch();\n unwatch = undefined;\n };\n\n if (context.nodes.size === 0) {\n unwatch = resolver(() => {\n update();\n\n if (context.nodes.size > 0) {\n clear();\n }\n }, context);\n }\n\n return () => {\n clear();\n };\n };\n\n// prettier-ignore\nexport const contentScriptLocationResolver =\n (strategy: ContentScriptWatchStrategy): ContentScriptWatchStrategy =>\n (update, context) => {\n let currentUrl = location.href;\n\n const interval = setInterval(() => {\n if (currentUrl !== location.href) {\n currentUrl = location.href;\n\n context.mount();\n }\n }, 300);\n\n const unwatch = strategy(update, context);\n\n return () => {\n clearInterval(interval);\n unwatch();\n };\n };\n","import {ContentScriptContext, ContentScriptNode, ContentScriptNodeSet} from \"@typing/content\";\n\nexport default class implements ContentScriptContext {\n protected readonly collection: ContentScriptNodeSet = new Set();\n\n public get nodes(): ReadonlySet<ContentScriptNode> {\n return this.collection;\n }\n\n public mount(): void {\n for (const node of this.collection) {\n if (!node.anchor.isConnected) {\n node.unmount();\n\n this.collection.delete(node);\n\n continue;\n }\n\n node.mount();\n }\n }\n\n public unmount(): void {\n for (const node of this.collection) {\n node.unmount();\n\n if (!node.anchor.isConnected) {\n this.collection.delete(node);\n }\n }\n }\n}\n","import Context from \"./Context\";\n\nimport {ContentScriptNode} from \"@typing/content\";\n\nexport default class extends Context {\n public add(node: ContentScriptNode): this {\n this.collection.add(node);\n\n return this;\n }\n}\n","import Builder from \"@entry/core/Builder\";\n\nimport {contentScriptMountAppendResolver} from \"./resolvers/mount\";\nimport {contentScriptAnchorResolver} from \"./resolvers/anchor\";\nimport {contentScriptRenderResolver} from \"./resolvers/render\";\nimport {contentScriptContainerResolver} from \"./resolvers/container\";\nimport {\n contentScriptAwaitFirstResolver,\n contentScriptLocationResolver,\n contentScriptMutationObserverResolver,\n} from \"./resolvers/watch\";\n\nimport ManagedContext from \"./ManagedContext\";\n\nimport {\n ContentScriptAnchor,\n ContentScriptAnchorGetter,\n ContentScriptAnchorResolver,\n ContentScriptBuilder,\n ContentScriptContainerCreator,\n ContentScriptContainerFactory,\n ContentScriptContainerOptions,\n ContentScriptContainerTag,\n ContentScriptContext,\n ContentScriptDefinition,\n ContentScriptMountFunction,\n ContentScriptNode,\n ContentScriptRenderHandler,\n ContentScriptRenderValue,\n ContentScriptResolvedDefinition,\n ContentScriptWatchStrategy,\n} from \"@typing/content\";\n\nimport {Awaiter} from \"@typing/helpers\";\n\nexport default abstract class extends Builder implements ContentScriptBuilder {\n protected readonly definition: ContentScriptResolvedDefinition;\n\n protected context = new ManagedContext();\n\n protected unwatch?: () => void;\n\n private isProcessing: boolean = false;\n\n protected abstract createNode(anchor: Element): Promise<ContentScriptNode>;\n\n protected abstract cleanupNode(anchor: Element): Awaiter<void>;\n\n protected constructor(definition: ContentScriptDefinition) {\n super();\n\n this.definition = {\n ...definition,\n anchor: this.resolveAnchor(definition.anchor),\n mount: this.resolveMount(definition.mount),\n container: this.resolveContainer(definition.container),\n render: this.resolveRender(definition.render),\n watch: this.resolveWatch(definition.watch),\n };\n }\n\n protected resolveAnchor(anchor?: ContentScriptAnchor | ContentScriptAnchorGetter): ContentScriptAnchorResolver {\n return contentScriptAnchorResolver(anchor);\n }\n\n protected resolveMount(mount?: ContentScriptMountFunction): ContentScriptMountFunction {\n return mount || contentScriptMountAppendResolver();\n }\n\n protected resolveContainer(\n container?: ContentScriptContainerTag | ContentScriptContainerOptions | ContentScriptContainerFactory\n ): ContentScriptContainerCreator {\n return contentScriptContainerResolver(container);\n }\n\n protected resolveRender(\n render?: ContentScriptRenderValue | ContentScriptRenderHandler\n ): ContentScriptRenderHandler | undefined {\n if (render === undefined) {\n return;\n }\n\n return contentScriptRenderResolver(render);\n }\n\n protected resolveWatch(watch?: true | ContentScriptWatchStrategy): ContentScriptWatchStrategy {\n if (watch === undefined) {\n watch = contentScriptAwaitFirstResolver();\n } else if (watch === true) {\n watch = contentScriptMutationObserverResolver();\n }\n\n return contentScriptLocationResolver(watch);\n }\n\n public getContext(): ContentScriptContext {\n return this.context;\n }\n\n public async build(): Promise<void> {\n await this.destroy();\n\n const {render, main, anchor, container, watch, mount, ...options} = this.definition;\n\n if (render !== undefined) {\n await this.processing();\n\n this.unwatch = watch(() => {\n this.processing().catch(e => {\n console.error(\"Content script processing on watch error\", e);\n });\n }, this.context);\n }\n\n await main?.(this.context, options);\n }\n\n public async destroy(): Promise<void> {\n this.unwatch?.();\n this.unwatch = undefined;\n }\n\n protected async processing(): Promise<void> {\n if (this.isProcessing) {\n return;\n }\n\n this.isProcessing = true;\n\n const anchors = await this.definition.anchor();\n\n await Promise.allSettled(anchors.map(this.processAnchor.bind(this)));\n\n this.isProcessing = false;\n }\n\n protected async processAnchor(anchor: Element): Promise<void> {\n const node = await this.createNode(anchor);\n\n this.context.add(node);\n\n await this.cleanupNode(anchor);\n\n node.mount();\n }\n}\n","import {contentScriptAnchorAttribute} from \"./resolvers/anchor\";\n\nimport {ContentScriptNode} from \"@typing/content\";\n\nenum NodeMark {\n Mounded = \"1\",\n Unmounted = \"0\",\n}\n\nexport default class implements ContentScriptNode {\n private readonly _container?: Element;\n\n private readonly attr = contentScriptAnchorAttribute;\n\n constructor(\n public readonly anchor: Element,\n public container?: Element\n ) {\n if (this.container) {\n this._container = this.container.cloneNode(false) as Element;\n }\n }\n\n public mount(): void {\n this.mark();\n\n if (!this.container && this._container) {\n this.container = this._container.cloneNode(false) as Element;\n }\n }\n\n public unmount(): void {\n this.unmark();\n\n if (this.container) {\n this.container.remove();\n this.container = undefined;\n }\n }\n\n protected mark(): this {\n let id = this.anchor.getAttribute(this.attr);\n\n if (typeof id !== \"string\" || id.length === 0 || id === NodeMark.Unmounted) {\n this.anchor.setAttribute(this.attr, NodeMark.Mounded);\n }\n\n return this;\n }\n\n protected unmark(): void {\n this.anchor.setAttribute(this.attr, NodeMark.Unmounted);\n }\n}\n","import {ContentScriptMountFunction, ContentScriptNode} from \"@typing/content\";\n\nexport default class implements ContentScriptNode {\n private unmounting?: () => void;\n\n constructor(\n protected node: ContentScriptNode,\n protected mounter?: ContentScriptMountFunction\n ) {}\n\n public get anchor(): Element {\n return this.node.anchor;\n }\n\n public get container(): Element | undefined {\n return this.node.container;\n }\n\n public mount(): void {\n this.node.mount();\n\n if (!this.container || this.container.isConnected) {\n return;\n }\n\n const unmounting = this.mounter?.(this.anchor, this.container);\n\n if (unmounting) {\n this.unmounting = unmounting;\n }\n }\n\n public unmount(): void {\n this.unmounting?.();\n this.unmounting = undefined;\n\n this.node.unmount();\n }\n}\n","import Builder from \"./Builder\";\nimport Node from \"./Node\";\nimport MountNode from \"./MountNode\";\n\nimport {ContentScriptNode, ContentScriptProps, ContentScriptRenderValue} from \"@typing/content\";\n\nexport default abstract class extends Builder {\n private values = new Map<Element, null | ContentScriptRenderValue>();\n\n protected getProps(anchor: Element): ContentScriptProps {\n const {anchor: _, mount, watch, render, container, main, ...options} = this.definition;\n\n return {...options, anchor};\n }\n\n protected async getValue(anchor: Element): Promise<undefined | ContentScriptRenderValue> {\n if (!this.values.has(anchor)) {\n const value = await this.renderValue(anchor);\n\n this.values.set(anchor, value === undefined ? undefined : value);\n }\n\n return this.values.get(anchor);\n }\n\n protected async renderValue(anchor: Element): Promise<undefined | ContentScriptRenderValue> {\n const {render} = this.definition;\n\n if (render === undefined) {\n return;\n }\n\n return render(this.getProps(anchor));\n }\n\n protected async createNode(anchor: Element): Promise<ContentScriptNode> {\n let container: Element | undefined;\n\n if (await this.getValue(anchor)) {\n container = (await this.definition.container(this.getProps(anchor))) as Element | undefined;\n }\n\n return new MountNode(new Node(anchor, container), this.definition.mount);\n }\n\n protected cleanupNode(anchor: Element): void {\n this.values.delete(anchor);\n }\n}\n","import {ContentScriptNode} from \"@typing/content\";\n\nexport default class implements ContentScriptNode {\n private mounted: boolean = false;\n\n constructor(\n protected readonly node: ContentScriptNode,\n protected readonly value?: null | boolean | string | number | Element\n ) {}\n\n public get anchor(): Element {\n return this.node.anchor;\n }\n\n public get container(): Element | undefined {\n return this.node.container;\n }\n\n public mount(): void {\n this.node.mount();\n\n if (!this.container || this.mounted) {\n return;\n }\n\n if (this.value instanceof Element) {\n this.container.appendChild(this.value);\n } else if (typeof this.value === \"string\" || typeof this.value === \"number\") {\n this.container.textContent = String(this.value);\n } else if (this.value === null || this.value === undefined) {\n console.warn(\"Content script vanilla value is empty\");\n }\n\n this.mounted = true;\n }\n\n public unmount(): void {\n this.node.unmount();\n\n this.mounted = false;\n }\n}\n","import {isValidContentScriptRenderValue} from \"../core/resolvers/render\";\n\nimport MountBuilder from \"../core/MountBuilder\";\nimport VanillaNode from \"./Node\";\n\nimport {ContentScriptDefinition, ContentScriptNode} from \"@typing/content\";\n\nexport default class extends MountBuilder {\n public constructor(definition: ContentScriptDefinition) {\n super(definition);\n }\n\n protected async createNode(anchor: Element): Promise<ContentScriptNode> {\n let value = await this.getValue(anchor);\n\n if (value !== true && !isValidContentScriptRenderValue(value)) {\n value = undefined;\n\n console.warn(\"Content script vanilla value is not a valid render value\");\n }\n\n return new VanillaNode(await super.createNode(anchor), value);\n }\n}\n","import Builder from \"./Builder\";\n\nexport {Builder};\n\nexport default Builder.resolver();\n"]}
1
+ {"version":3,"sources":["../../../../src/entry/content/core/resolvers/render.ts","../../../../src/entry/core/Builder.ts","../../../../src/entry/content/core/resolvers/mount.ts","../../../../src/entry/content/core/resolvers/anchor.ts","../../../../src/entry/content/core/resolvers/container.ts","../../../../src/entry/content/core/resolvers/watch.ts","../../../../src/entry/content/core/Context.ts","../../../../src/entry/content/core/ManagedContext.ts","../../../../src/entry/content/core/EventEmitter.ts","../../../../src/entry/content/core/Builder.ts","../../../../src/entry/content/core/Node.ts","../../../../src/entry/content/core/MountNode.ts","../../../../src/entry/content/core/MountBuilder.ts","../../../../src/entry/content/core/EventNode.ts","../../../../src/entry/content/vanilla/Node.ts","../../../../src/entry/content/vanilla/Builder.ts","../../../../src/entry/content/vanilla/index.ts"],"names":["customAlphabet","debounce","Builder_default","Node_default"],"mappings":";;;;;;;;;;;;AAEO,IAAM,+BAAA,GAAkC,CAAC,KAAuD,KAAA;AACnG,EAAQ,OAAA,OAAO,UAAU,QAAY,IAAA,KAAA,CAAM,SAAS,CAAM,IAAA,OAAO,KAAU,KAAA,QAAA,IAAY,KAAiB,YAAA,OAAA;AAC5G,CAAA;AAGO,IAAM,2BACT,GAAA,CAAC,MACG,KAAA,OAAO,KAAyD,KAAA;AAC5D,EAAA,IA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,CAAG,EAAA,KAAK,CAAG,EAAA,IAAA,CAAK,OAAO,CAAA;AAAA;AAEjG;;;ACpBO,IAAA,eAAA,GAAQD,iBAAQ,QAAS","file":"index.cjs","sourcesContent":["import {ContentScriptRenderHandler, ContentScriptRenderValue} from \"@typing/content\";\n\nexport const isValidContentScriptRenderValue = (value: unknown): value is string | number | Element => {\n return (typeof value === \"string\" && value.length > 0) || typeof value === \"number\" || value instanceof Element;\n};\n\n// prettier-ignore\nexport const contentScriptRenderResolver =\n (render?: ContentScriptRenderValue | ContentScriptRenderHandler): ContentScriptRenderHandler =>\n async (props): Promise<undefined | ContentScriptRenderValue> => {\n let resolvedRender = typeof render === \"function\" ? render(props) : render;\n\n if (resolvedRender instanceof Promise) {\n resolvedRender = await resolvedRender;\n }\n\n if (resolvedRender !== true && !isValidContentScriptRenderValue(resolvedRender)) {\n return;\n }\n\n return resolvedRender;\n };\n","import {EntrypointBuilder, EntrypointConstructorParameter} from \"@typing/entrypoint\";\n\nexport default abstract class implements EntrypointBuilder {\n public abstract build(): Promise<void>;\n\n public abstract destroy(): Promise<void>;\n\n public static resolver<T extends new (definition: any) => EntrypointBuilder>(this: T) {\n return (definition: EntrypointConstructorParameter<T>): void => {\n new this(definition).build().catch(e => {\n console.error(\"Failed to build entrypoint:\", e);\n });\n };\n }\n}\n","import {ContentScriptAppend, ContentScriptMountFunction} from \"@typing/content\";\n\n// prettier-ignore\nexport const contentScriptMountAppendResolver =\n (append?: ContentScriptAppend): ContentScriptMountFunction =>\n (anchor: Element, container: Element): void => {\n switch (append) {\n case ContentScriptAppend.Last:\n anchor.append(container);\n break;\n default:\n case undefined:\n case ContentScriptAppend.First:\n anchor.prepend(container);\n break;\n case ContentScriptAppend.Replace:\n anchor.replaceWith(container);\n break;\n case ContentScriptAppend.After:\n anchor.parentElement?.insertBefore(container, anchor.nextElementSibling);\n break;\n case ContentScriptAppend.Before:\n anchor.parentElement?.insertBefore(container, anchor);\n break;\n }\n };\n","import {customAlphabet} from \"nanoid\";\n\nimport {ContentScriptAnchor, ContentScriptAnchorGetter, ContentScriptAnchorResolver} from \"@typing/content\";\n\nconst generateId = customAlphabet(\"abcdefghijklmnopqrstuvwxyz\", 7);\n\nexport const contentScriptAnchorAttribute = `data-${generateId()}`;\n\n// prettier-ignore\nexport const contentScriptAnchorResolver =\n (anchor?: ContentScriptAnchor | ContentScriptAnchorGetter): ContentScriptAnchorResolver =>\n async (): Promise<Element[]> => {\n const attr = contentScriptAnchorAttribute;\n\n let resolved = typeof anchor === \"function\" ? anchor() : anchor;\n\n if (resolved instanceof Promise) {\n resolved = await resolved;\n }\n\n if (resolved === undefined || resolved === null) {\n resolved = document.body;\n }\n\n const elements: Element[] = [];\n\n if (resolved instanceof Element) {\n if (!resolved.hasAttribute(attr)) {\n elements.push(resolved);\n }\n } else if (typeof resolved === \"string\") {\n if (resolved.startsWith(\"/\")) {\n resolved = `(${resolved})[not(@${attr})]`;\n\n const result = document.evaluate(\n resolved,\n document,\n null,\n XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,\n null\n );\n\n for (let i = 0; i < result.snapshotLength; i++) {\n elements.push(result.snapshotItem(i) as Element);\n }\n } else {\n resolved += `:not([${attr}])`;\n\n elements.push(...Array.from(document.querySelectorAll(resolved)));\n }\n }\n\n return elements;\n };\n","import {\n ContentScriptContainerCreator,\n ContentScriptContainerFactory,\n ContentScriptContainerOptions,\n ContentScriptContainerTag,\n ContentScriptProps,\n} from \"@typing/content\";\n\n// prettier-ignore\nexport const contentScriptContainerResolver = (\n container?:\n ContentScriptContainerTag |\n ContentScriptContainerOptions |\n ContentScriptContainerFactory\n): ContentScriptContainerCreator =>\n async (props: ContentScriptProps): Promise<Element> => {\n let resolvedContainer = typeof container === \"function\" ? container(props) : container;\n\n if (resolvedContainer instanceof Promise) {\n resolvedContainer = await resolvedContainer;\n }\n\n if (resolvedContainer === undefined || typeof resolvedContainer === \"string\") {\n resolvedContainer = document.createElement(resolvedContainer || \"div\");\n } else if (typeof resolvedContainer === \"object\" && resolvedContainer.constructor === Object) {\n const {tagName = \"div\", ...options} = resolvedContainer as ContentScriptContainerOptions;\n\n resolvedContainer = document.createElement(tagName);\n\n Object.assign(resolvedContainer, options);\n }\n\n if (!(resolvedContainer instanceof Element)) {\n throw new Error(\"The content script container must be a valid element\");\n }\n\n return resolvedContainer;\n };\n","import debounce from \"debounce\";\n\nimport {ContentScriptWatchStrategy} from \"@typing/content\";\n\n// prettier-ignore\nexport const contentScriptMutationObserverResolver =\n (options?: MutationObserverInit): ContentScriptWatchStrategy =>\n update => {\n if (!options) {\n options = {};\n }\n\n const handle = debounce(update, 200);\n\n const observer = new MutationObserver(handle);\n\n observer.observe(document.body, {\n childList: true,\n subtree: true,\n attributes: true,\n characterData: true,\n ...options,\n });\n\n return () => {\n handle.clear();\n observer.disconnect();\n };\n };\n\n// prettier-ignore\nexport const contentScriptAwaitFirstResolver =\n (options?: MutationObserverInit): ContentScriptWatchStrategy =>\n (update, context) => {\n const resolver = contentScriptMutationObserverResolver({\n attributes: false,\n characterData: false,\n ...options,\n });\n\n let unwatch: { (): void } | undefined;\n\n const clear = () => {\n unwatch && unwatch();\n unwatch = undefined;\n };\n\n if (context.nodes.size === 0) {\n unwatch = resolver(() => {\n update();\n\n if (context.nodes.size > 0) {\n clear();\n }\n }, context);\n }\n\n return () => {\n clear();\n };\n };\n\n// prettier-ignore\nexport const contentScriptLocationResolver =\n (strategy: ContentScriptWatchStrategy): ContentScriptWatchStrategy =>\n (update, context) => {\n let currentUrl = location.href;\n\n const interval = setInterval(() => {\n if (currentUrl !== location.href) {\n currentUrl = location.href;\n\n context.mount();\n }\n }, 300);\n\n const unwatch = strategy(update, context);\n\n return () => {\n clearInterval(interval);\n unwatch();\n };\n };\n","import {\n ContentScriptContext,\n ContentScriptEventCallback,\n ContentScriptEventEmitter,\n ContentScriptNode,\n ContentScriptNodeSet,\n} from \"@typing/content\";\n\nexport default class implements ContentScriptContext {\n protected readonly collection: ContentScriptNodeSet = new Set();\n\n constructor(protected readonly emitter: ContentScriptEventEmitter) {}\n\n public get nodes(): ReadonlySet<ContentScriptNode> {\n return this.collection;\n }\n\n public mount(): void {\n for (const node of this.collection) {\n if (!node.anchor.isConnected) {\n node.unmount();\n\n this.collection.delete(node);\n\n this.emitter.emitRemove(node);\n\n continue;\n }\n\n node.mount();\n }\n }\n\n public unmount(): void {\n for (const node of this.collection) {\n node.unmount();\n\n if (!node.anchor.isConnected) {\n this.collection.delete(node);\n\n this.emitter.emitRemove(node);\n }\n }\n }\n\n public watch(callback: ContentScriptEventCallback): () => void {\n this.emitter.on(callback);\n\n return () => {\n this.emitter.off(callback);\n };\n }\n\n public unwatch(): void {\n this.emitter.removeAllListeners();\n }\n}\n","import Context from \"./Context\";\n\nimport {ContentScriptNode} from \"@typing/content\";\n\nexport default class extends Context {\n public add(node: ContentScriptNode): this {\n this.collection.add(node);\n\n this.emitter.emitAdd(node);\n\n return this;\n }\n}\n","import {\n ContentScriptEvent,\n ContentScriptEventCallback,\n ContentScriptEventEmitter,\n ContentScriptNode,\n} from \"@typing/content\";\n\nexport default class implements ContentScriptEventEmitter {\n private readonly listeners: Set<ContentScriptEventCallback> = new Set();\n\n public emit(event: ContentScriptEvent, node: ContentScriptNode): void {\n for (const listener of this.listeners) {\n listener(event, node);\n }\n }\n\n public emitAdd(node: ContentScriptNode): void {\n this.emit(ContentScriptEvent.Add, node);\n }\n\n public emitMount(node: ContentScriptNode): void {\n this.emit(ContentScriptEvent.Mount, node);\n }\n\n public emitRemove(node: ContentScriptNode): void {\n this.emit(ContentScriptEvent.Remove, node);\n }\n\n public emitUnmount(node: ContentScriptNode): void {\n this.emit(ContentScriptEvent.Unmount, node);\n }\n\n public hasListeners(): boolean {\n return this.listenerCount() > 0;\n }\n\n public listenerCount(): number {\n return this.listeners.size;\n }\n\n public off(callback: ContentScriptEventCallback): void {\n this.listeners.delete(callback);\n }\n\n public on(callback: ContentScriptEventCallback): void {\n this.listeners.add(callback);\n }\n\n public removeAllListeners(): void {\n this.listeners.clear();\n }\n}\n","import Builder from \"@entry/core/Builder\";\n\nimport {contentScriptMountAppendResolver} from \"./resolvers/mount\";\nimport {contentScriptAnchorResolver} from \"./resolvers/anchor\";\nimport {contentScriptRenderResolver} from \"./resolvers/render\";\nimport {contentScriptContainerResolver} from \"./resolvers/container\";\nimport {\n contentScriptAwaitFirstResolver,\n contentScriptLocationResolver,\n contentScriptMutationObserverResolver,\n} from \"./resolvers/watch\";\n\nimport ManagedContext from \"./ManagedContext\";\nimport EventEmitter from \"./EventEmitter\";\n\nimport {\n ContentScriptAnchor,\n ContentScriptAnchorGetter,\n ContentScriptAnchorResolver,\n ContentScriptBuilder,\n ContentScriptContainerCreator,\n ContentScriptContainerFactory,\n ContentScriptContainerOptions,\n ContentScriptContainerTag,\n ContentScriptContext,\n ContentScriptDefinition,\n ContentScriptMountFunction,\n ContentScriptNode,\n ContentScriptRenderHandler,\n ContentScriptRenderValue,\n ContentScriptResolvedDefinition,\n ContentScriptWatchStrategy,\n} from \"@typing/content\";\n\nimport {Awaiter} from \"@typing/helpers\";\n\nexport default abstract class extends Builder implements ContentScriptBuilder {\n protected readonly definition: ContentScriptResolvedDefinition;\n\n protected readonly emitter = new EventEmitter();\n\n protected readonly context = new ManagedContext(this.emitter);\n\n protected unwatch?: () => void;\n\n private isProcessing: boolean = false;\n\n protected abstract createNode(anchor: Element): Promise<ContentScriptNode>;\n\n protected abstract cleanupNode(anchor: Element): Awaiter<void>;\n\n protected constructor(definition: ContentScriptDefinition) {\n super();\n\n this.definition = {\n ...definition,\n anchor: this.resolveAnchor(definition.anchor),\n mount: this.resolveMount(definition.mount),\n container: this.resolveContainer(definition.container),\n render: this.resolveRender(definition.render),\n watch: this.resolveWatch(definition.watch),\n };\n }\n\n protected resolveAnchor(anchor?: ContentScriptAnchor | ContentScriptAnchorGetter): ContentScriptAnchorResolver {\n return contentScriptAnchorResolver(anchor);\n }\n\n protected resolveMount(mount?: ContentScriptMountFunction): ContentScriptMountFunction {\n return mount || contentScriptMountAppendResolver();\n }\n\n protected resolveContainer(\n container?: ContentScriptContainerTag | ContentScriptContainerOptions | ContentScriptContainerFactory\n ): ContentScriptContainerCreator {\n return contentScriptContainerResolver(container);\n }\n\n protected resolveRender(\n render?: ContentScriptRenderValue | ContentScriptRenderHandler\n ): ContentScriptRenderHandler | undefined {\n if (render === undefined) {\n return;\n }\n\n return contentScriptRenderResolver(render);\n }\n\n protected resolveWatch(watch?: true | ContentScriptWatchStrategy): ContentScriptWatchStrategy {\n if (watch === undefined) {\n watch = contentScriptAwaitFirstResolver();\n } else if (watch === true) {\n watch = contentScriptMutationObserverResolver();\n }\n\n return contentScriptLocationResolver(watch);\n }\n\n public getContext(): ContentScriptContext {\n return this.context;\n }\n\n public async build(): Promise<void> {\n await this.destroy();\n\n const {render, main, anchor, container, watch, mount, ...options} = this.definition;\n\n await main?.(this.context, options);\n\n if (render !== undefined) {\n await this.processing();\n\n this.unwatch = watch(() => {\n this.processing().catch(e => {\n console.error(\"Content script processing on watch error\", e);\n });\n }, this.context);\n }\n }\n\n public async destroy(): Promise<void> {\n this.unwatch?.();\n this.unwatch = undefined;\n }\n\n protected async processing(): Promise<void> {\n if (this.isProcessing) {\n return;\n }\n\n this.isProcessing = true;\n\n const anchors = await this.definition.anchor();\n\n await Promise.allSettled(anchors.map(this.processAnchor.bind(this)));\n\n this.isProcessing = false;\n }\n\n protected async processAnchor(anchor: Element): Promise<void> {\n const node = await this.createNode(anchor);\n\n this.context.add(node);\n\n await this.cleanupNode(anchor);\n\n node.mount();\n }\n}\n","import {contentScriptAnchorAttribute} from \"./resolvers/anchor\";\n\nimport {ContentScriptNode} from \"@typing/content\";\n\nenum NodeMark {\n Mounded = \"1\",\n Unmounted = \"0\",\n}\n\nexport default class implements ContentScriptNode {\n private readonly _container?: Element;\n\n private readonly attr = contentScriptAnchorAttribute;\n\n constructor(\n public readonly anchor: Element,\n public container?: Element\n ) {\n if (this.container) {\n this._container = this.container.cloneNode(false) as Element;\n }\n }\n\n public mount(): boolean {\n this.mark();\n\n if (!this.container && this._container) {\n this.container = this._container.cloneNode(false) as Element;\n\n return true;\n }\n\n return false;\n }\n\n public unmount(): boolean {\n this.unmark();\n\n if (this.container) {\n this.container.remove();\n this.container = undefined;\n\n return true;\n }\n\n return false;\n }\n\n protected mark(): this {\n let id = this.anchor.getAttribute(this.attr);\n\n if (typeof id !== \"string\" || id.length === 0 || id === NodeMark.Unmounted) {\n this.anchor.setAttribute(this.attr, NodeMark.Mounded);\n }\n\n return this;\n }\n\n protected unmark(): void {\n this.anchor.setAttribute(this.attr, NodeMark.Unmounted);\n }\n}\n","import {ContentScriptMountFunction, ContentScriptNode} from \"@typing/content\";\n\nexport default class implements ContentScriptNode {\n private unmounting?: () => void;\n\n constructor(\n protected node: ContentScriptNode,\n protected mounter?: ContentScriptMountFunction\n ) {}\n\n public get anchor(): Element {\n return this.node.anchor;\n }\n\n public get container(): Element | undefined {\n return this.node.container;\n }\n\n public mount(): boolean {\n this.node.mount();\n\n if (!this.container || this.container.isConnected) {\n return false;\n }\n\n if (this.mounter) {\n const unmounting = this.mounter(this.anchor, this.container);\n\n if (unmounting) {\n this.unmounting = unmounting;\n }\n\n return true;\n }\n\n return false;\n }\n\n public unmount(): boolean {\n this.unmounting?.();\n this.unmounting = undefined;\n\n return !!this.node.unmount();\n }\n}\n","import Builder from \"./Builder\";\nimport Node from \"./Node\";\nimport MountNode from \"./MountNode\";\n\nimport {ContentScriptNode, ContentScriptProps, ContentScriptRenderValue} from \"@typing/content\";\n\nexport default abstract class extends Builder {\n private values = new Map<Element, null | ContentScriptRenderValue>();\n\n protected getProps(anchor: Element): ContentScriptProps {\n const {anchor: _, mount, watch, render, container, main, ...options} = this.definition;\n\n return {...options, anchor};\n }\n\n protected async getValue(anchor: Element): Promise<undefined | ContentScriptRenderValue> {\n if (!this.values.has(anchor)) {\n const value = await this.renderValue(anchor);\n\n this.values.set(anchor, value === undefined ? undefined : value);\n }\n\n return this.values.get(anchor);\n }\n\n protected async renderValue(anchor: Element): Promise<undefined | ContentScriptRenderValue> {\n const {render} = this.definition;\n\n if (render === undefined) {\n return;\n }\n\n return render(this.getProps(anchor));\n }\n\n protected async createNode(anchor: Element): Promise<ContentScriptNode> {\n let container: Element | undefined;\n\n const value = await this.getValue(anchor);\n\n if (typeof value !== \"boolean\" && value !== undefined) {\n container = (await this.definition.container(this.getProps(anchor))) as Element | undefined;\n }\n\n return new MountNode(new Node(anchor, container), this.definition.mount);\n }\n\n protected cleanupNode(anchor: Element): void {\n this.values.delete(anchor);\n }\n}\n","import {ContentScriptEventEmitter, ContentScriptNode} from \"@typing/content\";\n\nexport default class implements ContentScriptNode {\n constructor(\n protected readonly node: ContentScriptNode,\n protected readonly emitter: ContentScriptEventEmitter\n ) {}\n\n public get anchor(): Element {\n return this.node.anchor;\n }\n\n public get container(): Element | undefined {\n return this.node.container;\n }\n\n public mount(): boolean {\n const result = this.node.mount();\n\n if (result === true) {\n this.emitter.emitMount(this.node);\n }\n\n return !!result;\n }\n\n public unmount(): boolean {\n const result = this.node.unmount();\n\n if (result === true) {\n this.emitter.emitUnmount(this.node);\n }\n\n return !!result;\n }\n}\n","import {ContentScriptNode} from \"@typing/content\";\n\nexport default class implements ContentScriptNode {\n private mounted: boolean = false;\n\n constructor(\n protected readonly node: ContentScriptNode,\n protected readonly value?: null | boolean | string | number | Element\n ) {}\n\n public get anchor(): Element {\n return this.node.anchor;\n }\n\n public get container(): Element | undefined {\n return this.node.container;\n }\n\n public mount(): boolean {\n this.node.mount();\n\n if (!this.container || this.mounted) {\n return false;\n }\n\n let result: boolean = true;\n\n if (this.value instanceof Element) {\n this.container.appendChild(this.value);\n } else if (typeof this.value === \"string\" || typeof this.value === \"number\") {\n this.container.textContent = String(this.value);\n } else if (this.value === null || this.value === undefined || this.value === false) {\n result = false;\n\n console.warn(\"Content script vanilla value is empty\");\n } else if (this.value === true) {\n result = false;\n }\n\n this.mounted = true;\n\n return result;\n }\n\n public unmount(): boolean {\n this.mounted = false;\n\n return !!this.node.unmount();\n }\n}\n","import {isValidContentScriptRenderValue} from \"../core/resolvers/render\";\n\nimport MountBuilder from \"../core/MountBuilder\";\nimport EventNode from \"../core/EventNode\";\nimport VanillaNode from \"./Node\";\n\nimport {ContentScriptDefinition, ContentScriptNode} from \"@typing/content\";\n\nexport default class extends MountBuilder {\n public constructor(definition: ContentScriptDefinition) {\n super(definition);\n }\n\n protected async createNode(anchor: Element): Promise<ContentScriptNode> {\n let value = await this.getValue(anchor);\n\n if (value !== true && !isValidContentScriptRenderValue(value)) {\n value = undefined;\n\n console.warn(\"Content script vanilla value is not a valid render value\");\n }\n\n return new EventNode(new VanillaNode(await super.createNode(anchor), value), this.emitter);\n }\n}\n","import Builder from \"./Builder\";\n\nexport {Builder};\n\nexport default Builder.resolver();\n"]}
@@ -1,9 +1,9 @@
1
- import { a as ContentScriptDefinition, c as ContentScriptNode } from '../../../content-BYoXVO6V.mjs';
2
- import { e as export_default$1 } from '../../../MountBuilder-CjvMOcmn.mjs';
1
+ import { a as ContentScriptDefinition, c as ContentScriptNode } from '../../../content-DrrPH4ri.mjs';
2
+ import { e as export_default$1 } from '../../../MountBuilder-BTltgVF2.mjs';
3
3
  import 'react';
4
4
  import 'utility-types';
5
- import '../../../helpers-DnV3N7fU.mjs';
6
- import '../../../Builder-CCyBD4hF.mjs';
5
+ import '../../../helpers-YDFORuZz.mjs';
6
+ import '../../../Builder-Df1LUO_f.mjs';
7
7
 
8
8
  declare class export_default extends export_default$1 {
9
9
  constructor(definition: ContentScriptDefinition);