wxt 0.20.18 → 0.20.20

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 (141) hide show
  1. package/bin/wxt-publish-extension.mjs +4 -3
  2. package/dist/browser.d.mts +7 -6
  3. package/dist/browser.mjs +6 -5
  4. package/dist/builtin-modules/index.mjs +1 -3
  5. package/dist/builtin-modules/unimport.mjs +1 -3
  6. package/dist/cli/cli-utils.mjs +5 -6
  7. package/dist/cli/commands.mjs +1 -3
  8. package/dist/cli/index.mjs +1 -3
  9. package/dist/core/build.d.mts +9 -8
  10. package/dist/core/build.mjs +10 -11
  11. package/dist/core/builders/vite/index.mjs +27 -25
  12. package/dist/core/builders/vite/plugins/bundleAnalysis.mjs +1 -3
  13. package/dist/core/builders/vite/plugins/cssEntrypoints.mjs +6 -6
  14. package/dist/core/builders/vite/plugins/defineImportMeta.mjs +3 -4
  15. package/dist/core/builders/vite/plugins/devHtmlPrerender.mjs +33 -25
  16. package/dist/core/builders/vite/plugins/devServerGlobals.mjs +3 -3
  17. package/dist/core/builders/vite/plugins/download.mjs +15 -11
  18. package/dist/core/builders/vite/plugins/entrypointGroupGlobals.mjs +2 -6
  19. package/dist/core/builders/vite/plugins/extensionApiMock.mjs +13 -8
  20. package/dist/core/builders/vite/plugins/globals.mjs +1 -3
  21. package/dist/core/builders/vite/plugins/iifeAnonymous.mjs +1 -2
  22. package/dist/core/builders/vite/plugins/iifeFooter.mjs +14 -7
  23. package/dist/core/builders/vite/plugins/index.mjs +18 -19
  24. package/dist/core/builders/vite/plugins/noopBackground.mjs +14 -9
  25. package/dist/core/builders/vite/plugins/removeEntrypointMainFunction.mjs +10 -12
  26. package/dist/core/builders/vite/plugins/resolveAppConfig.mjs +14 -10
  27. package/dist/core/builders/vite/plugins/resolveVirtualModules.mjs +15 -13
  28. package/dist/core/builders/vite/plugins/tsconfigPaths.mjs +1 -2
  29. package/dist/core/builders/vite/plugins/wxtPluginLoader.mjs +22 -17
  30. package/dist/core/clean.d.mts +7 -7
  31. package/dist/core/clean.mjs +6 -7
  32. package/dist/core/create-server.d.mts +6 -5
  33. package/dist/core/create-server.mjs +12 -11
  34. package/dist/core/define-config.mjs +1 -2
  35. package/dist/core/define-web-ext-config.d.mts +3 -4
  36. package/dist/core/define-web-ext-config.mjs +4 -7
  37. package/dist/core/generate-wxt-dir.mjs +8 -9
  38. package/dist/core/index.mjs +10 -11
  39. package/dist/core/initialize.mjs +10 -11
  40. package/dist/core/keyboard-shortcuts.mjs +2 -6
  41. package/dist/core/package-managers/bun.mjs +1 -3
  42. package/dist/core/package-managers/deno.mjs +1 -2
  43. package/dist/core/package-managers/index.mjs +1 -3
  44. package/dist/core/package-managers/npm.mjs +3 -5
  45. package/dist/core/package-managers/pnpm.mjs +1 -3
  46. package/dist/core/package-managers/yarn.mjs +1 -3
  47. package/dist/core/prepare.mjs +1 -3
  48. package/dist/core/resolve-config.mjs +20 -23
  49. package/dist/core/runners/index.mjs +1 -3
  50. package/dist/core/runners/manual.mjs +2 -6
  51. package/dist/core/runners/safari.mjs +3 -4
  52. package/dist/core/runners/web-ext.mjs +2 -6
  53. package/dist/core/runners/wsl.mjs +3 -4
  54. package/dist/core/utils/arrays.mjs +4 -11
  55. package/dist/core/utils/building/build-entrypoints.mjs +8 -9
  56. package/dist/core/utils/building/detect-dev-changes.mjs +21 -13
  57. package/dist/core/utils/building/find-entrypoints.mjs +16 -11
  58. package/dist/core/utils/building/group-entrypoints.mjs +3 -4
  59. package/dist/core/utils/building/index.mjs +7 -8
  60. package/dist/core/utils/building/internal-build.mjs +13 -13
  61. package/dist/core/utils/building/rebuild.mjs +10 -10
  62. package/dist/core/utils/cache.mjs +6 -8
  63. package/dist/core/utils/constants.mjs +3 -4
  64. package/dist/core/utils/content-scripts.mjs +3 -4
  65. package/dist/core/utils/content-security-policy.mjs +2 -5
  66. package/dist/core/utils/entrypoints.mjs +6 -10
  67. package/dist/core/utils/env.mjs +2 -6
  68. package/dist/core/utils/environments/browser-environment.mjs +1 -3
  69. package/dist/core/utils/environments/environment.mjs +1 -2
  70. package/dist/core/utils/environments/extension-environment.mjs +1 -3
  71. package/dist/core/utils/environments/index.mjs +3 -4
  72. package/dist/core/utils/eslint.mjs +1 -2
  73. package/dist/core/utils/fs.mjs +23 -14
  74. package/dist/core/utils/globals.mjs +1 -2
  75. package/dist/core/utils/i18n.mjs +1 -2
  76. package/dist/core/utils/index.mjs +2 -3
  77. package/dist/core/utils/log/index.mjs +5 -6
  78. package/dist/core/utils/log/printBuildSummary.mjs +1 -3
  79. package/dist/core/utils/log/printFileList.mjs +3 -5
  80. package/dist/core/utils/log/printHeader.mjs +1 -3
  81. package/dist/core/utils/log/printTable.mjs +1 -2
  82. package/dist/core/utils/manifest.mjs +23 -31
  83. package/dist/core/utils/minimatch-multiple.mjs +5 -7
  84. package/dist/core/utils/network.mjs +3 -5
  85. package/dist/core/utils/number.mjs +1 -2
  86. package/dist/core/utils/package.mjs +3 -5
  87. package/dist/core/utils/paths.d.mts +2 -2
  88. package/dist/core/utils/paths.mjs +7 -9
  89. package/dist/core/utils/strings.mjs +4 -7
  90. package/dist/core/utils/syntax-errors.mjs +1 -3
  91. package/dist/core/utils/time.mjs +2 -5
  92. package/dist/core/utils/transform.mjs +8 -6
  93. package/dist/core/utils/validation.mjs +1 -2
  94. package/dist/core/utils/virtual-modules.mjs +9 -15
  95. package/dist/core/utils/wsl.mjs +2 -6
  96. package/dist/core/wxt.mjs +7 -9
  97. package/dist/core/zip.d.mts +1 -0
  98. package/dist/core/zip.mjs +11 -10
  99. package/dist/index.d.mts +0 -1
  100. package/dist/index.mjs +1 -2
  101. package/dist/modules.d.mts +64 -61
  102. package/dist/modules.mjs +70 -66
  103. package/dist/testing/fake-browser.mjs +1 -2
  104. package/dist/testing/index.mjs +1 -2
  105. package/dist/testing/wxt-vitest-plugin.d.mts +4 -2
  106. package/dist/testing/wxt-vitest-plugin.mjs +5 -5
  107. package/dist/types.d.mts +455 -435
  108. package/dist/utils/app-config.mjs +1 -3
  109. package/dist/utils/content-script-context.d.mts +49 -39
  110. package/dist/utils/content-script-context.mjs +36 -31
  111. package/dist/utils/content-script-ui/iframe.d.mts +12 -13
  112. package/dist/utils/content-script-ui/iframe.mjs +1 -3
  113. package/dist/utils/content-script-ui/integrated.d.mts +8 -7
  114. package/dist/utils/content-script-ui/integrated.mjs +1 -3
  115. package/dist/utils/content-script-ui/shadow-root.d.mts +37 -25
  116. package/dist/utils/content-script-ui/shadow-root.mjs +4 -7
  117. package/dist/utils/content-script-ui/shared.mjs +1 -3
  118. package/dist/utils/content-script-ui/types.d.mts +29 -34
  119. package/dist/utils/content-script-ui/types.mjs +1 -1
  120. package/dist/utils/define-app-config.d.mts +4 -3
  121. package/dist/utils/define-app-config.mjs +5 -5
  122. package/dist/utils/define-background.mjs +1 -2
  123. package/dist/utils/define-content-script.mjs +1 -2
  124. package/dist/utils/define-unlisted-script.mjs +1 -2
  125. package/dist/utils/define-wxt-plugin.mjs +1 -2
  126. package/dist/utils/inject-script.mjs +1 -3
  127. package/dist/utils/internal/custom-events.mjs +3 -4
  128. package/dist/utils/internal/location-watcher.mjs +4 -6
  129. package/dist/utils/internal/logger.mjs +2 -5
  130. package/dist/utils/match-patterns.mjs +2 -3
  131. package/dist/utils/split-shadow-root-css.d.mts +6 -2
  132. package/dist/utils/split-shadow-root-css.mjs +7 -4
  133. package/dist/utils/storage.mjs +2 -3
  134. package/dist/version.mjs +2 -3
  135. package/dist/virtual/background-entrypoint.mjs +4 -16
  136. package/dist/virtual/content-script-isolated-world-entrypoint.mjs +2 -7
  137. package/dist/virtual/content-script-main-world-entrypoint.mjs +2 -7
  138. package/dist/virtual/mock-browser.mjs +1 -3
  139. package/dist/virtual/reload-html.mjs +3 -10
  140. package/dist/virtual/unlisted-script-entrypoint.mjs +2 -7
  141. package/package.json +17 -19
@@ -1,5 +1,4 @@
1
1
  import appConfig from "virtual:app-config";
2
-
3
2
  //#region src/utils/app-config.ts
4
3
  /** @module wxt/utils/app-config */
5
4
  /**
@@ -18,6 +17,5 @@ function getAppConfig() {
18
17
  function useAppConfig() {
19
18
  return getAppConfig();
20
19
  }
21
-
22
20
  //#endregion
23
- export { getAppConfig, useAppConfig };
21
+ export { getAppConfig, useAppConfig };
@@ -3,20 +3,22 @@ import { ContentScriptDefinition } from "../types.mjs";
3
3
 
4
4
  //#region src/utils/content-script-context.d.ts
5
5
  /**
6
- * Implements [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).
6
+ * Implements
7
+ * [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).
7
8
  * Used to detect and stop content script code when the script is invalidated.
8
9
  *
9
- * It also provides several utilities like `ctx.setTimeout` and `ctx.setInterval` that should be used in
10
- * content scripts instead of `window.setTimeout` or `window.setInterval`.
10
+ * It also provides several utilities like `ctx.setTimeout` and
11
+ * `ctx.setInterval` that should be used in content scripts instead of
12
+ * `window.setTimeout` or `window.setInterval`.
11
13
  *
12
14
  * To create context for testing, you can use the class's constructor:
13
15
  *
14
16
  * ```ts
15
17
  * import { ContentScriptContext } from 'wxt/utils/content-scripts-context';
16
18
  *
17
- * test("storage listener should be removed when context is invalidated", () => {
19
+ * test('storage listener should be removed when context is invalidated', () => {
18
20
  * const ctx = new ContentScriptContext('test');
19
- * const item = storage.defineItem("local:count", { defaultValue: 0 });
21
+ * const item = storage.defineItem('local:count', { defaultValue: 0 });
20
22
  * const watcher = vi.fn();
21
23
  *
22
24
  * const unwatch = item.watch(watcher);
@@ -45,75 +47,83 @@ declare class ContentScriptContext implements AbortController {
45
47
  get isInvalid(): boolean;
46
48
  get isValid(): boolean;
47
49
  /**
48
- * Add a listener that is called when the content script's context is invalidated.
49
- *
50
- * @returns A function to remove the listener.
50
+ * Add a listener that is called when the content script's context is
51
+ * invalidated.
51
52
  *
52
53
  * @example
53
- * browser.runtime.onMessage.addListener(cb);
54
- * const removeInvalidatedListener = ctx.onInvalidated(() => {
55
- * browser.runtime.onMessage.removeListener(cb);
56
- * })
57
- * // ...
58
- * removeInvalidatedListener();
54
+ * browser.runtime.onMessage.addListener(cb);
55
+ * const removeInvalidatedListener = ctx.onInvalidated(() => {
56
+ * browser.runtime.onMessage.removeListener(cb);
57
+ * });
58
+ * // ...
59
+ * removeInvalidatedListener();
60
+ *
61
+ * @returns A function to remove the listener.
59
62
  */
60
63
  onInvalidated(cb: () => void): () => void;
61
64
  /**
62
- * Return a promise that never resolves. Useful if you have an async function that shouldn't run
63
- * after the context is expired.
65
+ * Return a promise that never resolves. Useful if you have an async function
66
+ * that shouldn't run after the context is expired.
64
67
  *
65
68
  * @example
66
- * const getValueFromStorage = async () => {
67
- * if (ctx.isInvalid) return ctx.block();
69
+ * const getValueFromStorage = async () => {
70
+ * if (ctx.isInvalid) return ctx.block();
68
71
  *
69
- * // ...
70
- * }
72
+ * // ...
73
+ * };
71
74
  */
72
75
  block<T>(): Promise<T>;
73
76
  /**
74
- * Wrapper around `window.setInterval` that automatically clears the interval when invalidated.
77
+ * Wrapper around `window.setInterval` that automatically clears the interval
78
+ * when invalidated.
75
79
  *
76
80
  * Intervals can be cleared by calling the normal `clearInterval` function.
77
81
  */
78
82
  setInterval(handler: () => void, timeout?: number): number;
79
83
  /**
80
- * Wrapper around `window.setTimeout` that automatically clears the interval when invalidated.
84
+ * Wrapper around `window.setTimeout` that automatically clears the interval
85
+ * when invalidated.
81
86
  *
82
87
  * Timeouts can be cleared by calling the normal `setTimeout` function.
83
88
  */
84
89
  setTimeout(handler: () => void, timeout?: number): number;
85
90
  /**
86
- * Wrapper around `window.requestAnimationFrame` that automatically cancels the request when
87
- * invalidated.
91
+ * Wrapper around `window.requestAnimationFrame` that automatically cancels
92
+ * the request when invalidated.
88
93
  *
89
- * Callbacks can be canceled by calling the normal `cancelAnimationFrame` function.
94
+ * Callbacks can be canceled by calling the normal `cancelAnimationFrame`
95
+ * function.
90
96
  */
91
97
  requestAnimationFrame(callback: FrameRequestCallback): number;
92
98
  /**
93
- * Wrapper around `window.requestIdleCallback` that automatically cancels the request when
94
- * invalidated.
99
+ * Wrapper around `window.requestIdleCallback` that automatically cancels the
100
+ * request when invalidated.
95
101
  *
96
- * Callbacks can be canceled by calling the normal `cancelIdleCallback` function.
102
+ * Callbacks can be canceled by calling the normal `cancelIdleCallback`
103
+ * function.
97
104
  */
98
105
  requestIdleCallback(callback: IdleRequestCallback, options?: IdleRequestOptions): number;
99
106
  /**
100
- * Call `target.addEventListener` and remove the event listener when the context is invalidated.
107
+ * Call `target.addEventListener` and remove the event listener when the
108
+ * context is invalidated.
101
109
  *
102
- * Listeners can be canceled by calling the normal `removeEventListener` function.
110
+ * Listeners can be canceled by calling the normal `removeEventListener`
111
+ * function.
103
112
  *
104
113
  * Includes additional events useful for content scripts:
105
114
  *
106
- * - `"wxt:locationchange"` - Triggered when HTML5 history mode is used to change URL. Content
107
- * scripts are not reloaded when navigating this way, so this can be used to reset the content
108
- * script state on URL change, or run custom code.
115
+ * - `"wxt:locationchange"` - Triggered when HTML5 history mode is used to
116
+ * change URL. Content scripts are not reloaded when navigating this way, so
117
+ * this can be used to reset the content script state on URL change, or run
118
+ * custom code.
109
119
  *
110
120
  * @example
111
- * ctx.addEventListener(document, "visibilitychange", () => {
112
- * // ...
113
- * });
114
- * ctx.addEventListener(window, "wxt:locationchange", () => {
115
- * // ...
116
- * });
121
+ * ctx.addEventListener(document, 'visibilitychange', () => {
122
+ * // ...
123
+ * });
124
+ * ctx.addEventListener(window, 'wxt:locationchange', () => {
125
+ * // ...
126
+ * });
117
127
  */
118
128
  addEventListener<TType extends keyof WxtWindowEventMap>(target: Window, type: TType, handler: (event: WxtWindowEventMap[TType]) => void, options?: AddEventListenerOptions): void;
119
129
  addEventListener<TType extends keyof DocumentEventMap>(target: Document, type: TType, handler: (event: DocumentEventMap[TType]) => void, options?: AddEventListenerOptions): void;
@@ -2,23 +2,24 @@ import { logger } from "./internal/logger.mjs";
2
2
  import { getUniqueEventName } from "./internal/custom-events.mjs";
3
3
  import { createLocationWatcher } from "./internal/location-watcher.mjs";
4
4
  import { browser } from "wxt/browser";
5
-
6
5
  //#region src/utils/content-script-context.ts
7
6
  /**
8
- * Implements [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).
7
+ * Implements
8
+ * [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).
9
9
  * Used to detect and stop content script code when the script is invalidated.
10
10
  *
11
- * It also provides several utilities like `ctx.setTimeout` and `ctx.setInterval` that should be used in
12
- * content scripts instead of `window.setTimeout` or `window.setInterval`.
11
+ * It also provides several utilities like `ctx.setTimeout` and
12
+ * `ctx.setInterval` that should be used in content scripts instead of
13
+ * `window.setTimeout` or `window.setInterval`.
13
14
  *
14
15
  * To create context for testing, you can use the class's constructor:
15
16
  *
16
17
  * ```ts
17
18
  * import { ContentScriptContext } from 'wxt/utils/content-scripts-context';
18
19
  *
19
- * test("storage listener should be removed when context is invalidated", () => {
20
+ * test('storage listener should be removed when context is invalidated', () => {
20
21
  * const ctx = new ContentScriptContext('test');
21
- * const item = storage.defineItem("local:count", { defaultValue: 0 });
22
+ * const item = storage.defineItem('local:count', { defaultValue: 0 });
22
23
  * const watcher = vi.fn();
23
24
  *
24
25
  * const unwatch = item.watch(watcher);
@@ -61,38 +62,40 @@ var ContentScriptContext = class ContentScriptContext {
61
62
  return !this.isInvalid;
62
63
  }
63
64
  /**
64
- * Add a listener that is called when the content script's context is invalidated.
65
- *
66
- * @returns A function to remove the listener.
65
+ * Add a listener that is called when the content script's context is
66
+ * invalidated.
67
67
  *
68
68
  * @example
69
- * browser.runtime.onMessage.addListener(cb);
70
- * const removeInvalidatedListener = ctx.onInvalidated(() => {
71
- * browser.runtime.onMessage.removeListener(cb);
72
- * })
73
- * // ...
74
- * removeInvalidatedListener();
69
+ * browser.runtime.onMessage.addListener(cb);
70
+ * const removeInvalidatedListener = ctx.onInvalidated(() => {
71
+ * browser.runtime.onMessage.removeListener(cb);
72
+ * });
73
+ * // ...
74
+ * removeInvalidatedListener();
75
+ *
76
+ * @returns A function to remove the listener.
75
77
  */
76
78
  onInvalidated(cb) {
77
79
  this.signal.addEventListener("abort", cb);
78
80
  return () => this.signal.removeEventListener("abort", cb);
79
81
  }
80
82
  /**
81
- * Return a promise that never resolves. Useful if you have an async function that shouldn't run
82
- * after the context is expired.
83
+ * Return a promise that never resolves. Useful if you have an async function
84
+ * that shouldn't run after the context is expired.
83
85
  *
84
86
  * @example
85
- * const getValueFromStorage = async () => {
86
- * if (ctx.isInvalid) return ctx.block();
87
+ * const getValueFromStorage = async () => {
88
+ * if (ctx.isInvalid) return ctx.block();
87
89
  *
88
- * // ...
89
- * }
90
+ * // ...
91
+ * };
90
92
  */
91
93
  block() {
92
94
  return new Promise(() => {});
93
95
  }
94
96
  /**
95
- * Wrapper around `window.setInterval` that automatically clears the interval when invalidated.
97
+ * Wrapper around `window.setInterval` that automatically clears the interval
98
+ * when invalidated.
96
99
  *
97
100
  * Intervals can be cleared by calling the normal `clearInterval` function.
98
101
  */
@@ -104,7 +107,8 @@ var ContentScriptContext = class ContentScriptContext {
104
107
  return id;
105
108
  }
106
109
  /**
107
- * Wrapper around `window.setTimeout` that automatically clears the interval when invalidated.
110
+ * Wrapper around `window.setTimeout` that automatically clears the interval
111
+ * when invalidated.
108
112
  *
109
113
  * Timeouts can be cleared by calling the normal `setTimeout` function.
110
114
  */
@@ -116,10 +120,11 @@ var ContentScriptContext = class ContentScriptContext {
116
120
  return id;
117
121
  }
118
122
  /**
119
- * Wrapper around `window.requestAnimationFrame` that automatically cancels the request when
120
- * invalidated.
123
+ * Wrapper around `window.requestAnimationFrame` that automatically cancels
124
+ * the request when invalidated.
121
125
  *
122
- * Callbacks can be canceled by calling the normal `cancelAnimationFrame` function.
126
+ * Callbacks can be canceled by calling the normal `cancelAnimationFrame`
127
+ * function.
123
128
  */
124
129
  requestAnimationFrame(callback) {
125
130
  const id = requestAnimationFrame((...args) => {
@@ -129,10 +134,11 @@ var ContentScriptContext = class ContentScriptContext {
129
134
  return id;
130
135
  }
131
136
  /**
132
- * Wrapper around `window.requestIdleCallback` that automatically cancels the request when
133
- * invalidated.
137
+ * Wrapper around `window.requestIdleCallback` that automatically cancels the
138
+ * request when invalidated.
134
139
  *
135
- * Callbacks can be canceled by calling the normal `cancelIdleCallback` function.
140
+ * Callbacks can be canceled by calling the normal `cancelIdleCallback`
141
+ * function.
136
142
  */
137
143
  requestIdleCallback(callback, options) {
138
144
  const id = requestIdleCallback((...args) => {
@@ -183,6 +189,5 @@ var ContentScriptContext = class ContentScriptContext {
183
189
  this.onInvalidated(() => document.removeEventListener(ContentScriptContext.SCRIPT_STARTED_MESSAGE_TYPE, cb));
184
190
  }
185
191
  };
186
-
187
192
  //#endregion
188
- export { ContentScriptContext };
193
+ export { ContentScriptContext };
@@ -10,31 +10,30 @@ import * as wxt_browser0 from "wxt/browser";
10
10
  */
11
11
  declare function createIframeUi<TMounted>(ctx: ContentScriptContext, options: IframeContentScriptUiOptions<TMounted>): IframeContentScriptUi<TMounted>;
12
12
  interface IframeContentScriptUi<TMounted> extends ContentScriptUi<TMounted> {
13
- /**
14
- * The iframe added to the DOM.
15
- */
13
+ /** The iframe added to the DOM. */
16
14
  iframe: HTMLIFrameElement;
17
- /**
18
- * A wrapper div that assists in positioning.
19
- */
15
+ /** A wrapper div that assists in positioning. */
20
16
  wrapper: HTMLDivElement;
21
17
  }
22
18
  type IframeContentScriptUiOptions<TMounted> = ContentScriptUiOptions<TMounted> & {
23
19
  /**
24
- * The path to the HTML page that will be shown in the iframe. This string is passed into
25
- * `browser.runtime.getURL`.
20
+ * The path to the HTML page that will be shown in the iframe. This string
21
+ * is passed into `browser.runtime.getURL`.
26
22
  */
27
23
  page: wxt_browser0.HtmlPublicPath;
28
24
  /**
29
- * Callback executed when mounting the UI. Use this function to customize the iframe or wrapper
30
- * element's appearance. It is called every time `ui.mount()` is called.
25
+ * Callback executed when mounting the UI. Use this function to customize
26
+ * the iframe or wrapper element's appearance. It is called every time
27
+ * `ui.mount()` is called.
31
28
  *
32
- * Optionally return a value that can be accessed at `ui.mounted` or in the `onRemove` callback.
29
+ * Optionally return a value that can be accessed at `ui.mounted` or in the
30
+ * `onRemove` callback.
33
31
  */
34
32
  onMount?: (wrapper: HTMLElement, iframe: HTMLIFrameElement) => TMounted;
35
33
  /**
36
- * Callback executed before mounting the UI. Use this function to customize the iframe or wrapper
37
- * elements before they are injected into the DOM. It is called every time `ui.mount()` is called.
34
+ * Callback executed before mounting the UI. Use this function to customize
35
+ * the iframe or wrapper elements before they are injected into the DOM. It
36
+ * is called every time `ui.mount()` is called.
38
37
  */
39
38
  onBeforeMount?: (wrapper: HTMLElement, iframe: HTMLIFrameElement) => void;
40
39
  };
@@ -1,6 +1,5 @@
1
1
  import { applyPosition, createMountFunctions, mountUi } from "./shared.mjs";
2
2
  import { browser } from "wxt/browser";
3
-
4
3
  //#region src/utils/content-script-ui/iframe.ts
5
4
  /** @module wxt/utils/content-script-ui/iframe */
6
5
  /**
@@ -39,6 +38,5 @@ function createIframeUi(ctx, options) {
39
38
  ...mountFunctions
40
39
  };
41
40
  }
42
-
43
41
  //#endregion
44
- export { createIframeUi };
42
+ export { createIframeUi };
@@ -10,26 +10,27 @@ import { ContentScriptUi, ContentScriptUiOptions } from "./types.mjs";
10
10
  declare function createIntegratedUi<TMounted>(ctx: ContentScriptContext, options: IntegratedContentScriptUiOptions<TMounted>): IntegratedContentScriptUi<TMounted>;
11
11
  /**
12
12
  * Shared types for the different `wxt/utils/content-script-ui/*` modules.
13
+ *
13
14
  * @module wxt/utils/content-script-ui/types
14
15
  */
15
16
  interface IntegratedContentScriptUi<TMounted> extends ContentScriptUi<TMounted> {
16
- /**
17
- * A wrapper div that assists in positioning.
18
- */
17
+ /** A wrapper div that assists in positioning. */
19
18
  wrapper: HTMLElement;
20
19
  }
21
20
  type IntegratedContentScriptUiOptions<TMounted> = ContentScriptUiOptions<TMounted> & {
22
21
  /**
23
22
  * Tag used to create the wrapper element.
24
23
  *
25
- * @default "div"
24
+ * @default 'div'
26
25
  */
27
26
  tag?: string;
28
27
  /**
29
- * Callback executed when mounting the UI. This function should create and append the UI to the
30
- * `wrapper` element. It is called every time `ui.mount()` is called.
28
+ * Callback executed when mounting the UI. This function should create and
29
+ * append the UI to the `wrapper` element. It is called every time
30
+ * `ui.mount()` is called.
31
31
  *
32
- * Optionally return a value that can be accessed at `ui.mounted` or in the `onRemove` callback.
32
+ * Optionally return a value that can be accessed at `ui.mounted` or in the
33
+ * `onRemove` callback.
33
34
  */
34
35
  onMount: (wrapper: HTMLElement) => TMounted;
35
36
  };
@@ -1,5 +1,4 @@
1
1
  import { applyPosition, createMountFunctions, mountUi } from "./shared.mjs";
2
-
3
2
  //#region src/utils/content-script-ui/integrated.ts
4
3
  /**
5
4
  * Create a content script UI without any isolation.
@@ -33,6 +32,5 @@ function createIntegratedUi(ctx, options) {
33
32
  ...mountFunctions
34
33
  };
35
34
  }
36
-
37
35
  //#endregion
38
- export { createIntegratedUi };
36
+ export { createIntegratedUi };
@@ -3,7 +3,8 @@ import { ContentScriptUi, ContentScriptUiOptions } from "./types.mjs";
3
3
 
4
4
  //#region src/utils/content-script-ui/shadow-root.d.ts
5
5
  /**
6
- * Create a content script UI inside a [`ShadowRoot`](https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot).
6
+ * Create a content script UI inside a
7
+ * [`ShadowRoot`](https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot).
7
8
  *
8
9
  * > This function is async because it has to load the CSS via a network call.
9
10
  *
@@ -12,67 +13,78 @@ import { ContentScriptUi, ContentScriptUiOptions } from "./types.mjs";
12
13
  declare function createShadowRootUi<TMounted>(ctx: ContentScriptContext, options: ShadowRootContentScriptUiOptions<TMounted>): Promise<ShadowRootContentScriptUi<TMounted>>;
13
14
  interface ShadowRootContentScriptUi<TMounted> extends ContentScriptUi<TMounted> {
14
15
  /**
15
- * The `HTMLElement` hosting the shadow root used to isolate the UI's styles. This is the element
16
- * that get's added to the DOM. This element's style is not isolated from the webpage.
16
+ * The `HTMLElement` hosting the shadow root used to isolate the UI's styles.
17
+ * This is the element that get's added to the DOM. This element's style is
18
+ * not isolated from the webpage.
17
19
  */
18
20
  shadowHost: HTMLElement;
19
21
  /**
20
- * The container element inside the `ShadowRoot` whose styles are isolated. The UI is mounted
21
- * inside this `HTMLElement`.
22
+ * The container element inside the `ShadowRoot` whose styles are isolated.
23
+ * The UI is mounted inside this `HTMLElement`.
22
24
  */
23
25
  uiContainer: HTMLElement;
24
- /**
25
- * The shadow root performing the isolation.
26
- */
26
+ /** The shadow root performing the isolation. */
27
27
  shadow: ShadowRoot;
28
28
  }
29
29
  type ShadowRootContentScriptUiOptions<TMounted> = ContentScriptUiOptions<TMounted> & {
30
30
  /**
31
- * The name of the custom component used to host the ShadowRoot. Must be kebab-case.
31
+ * The name of the custom component used to host the ShadowRoot. Must be
32
+ * kebab-case.
32
33
  */
33
34
  name: string;
34
35
  /**
35
- * Custom CSS text to apply to the UI. If your content script imports/generates CSS and you've
36
- * set `cssInjectionMode: "ui"`, the imported CSS will be included automatically. You do not need
37
- * to pass those styles in here. This is for any additional styles not in the imported CSS.
36
+ * Custom CSS text to apply to the UI. If your content script
37
+ * imports/generates CSS and you've set `cssInjectionMode: "ui"`, the
38
+ * imported CSS will be included automatically. You do not need to pass
39
+ * those styles in here. This is for any additional styles not in the
40
+ * imported CSS.
38
41
  */
39
42
  css?: string;
40
43
  /**
41
44
  * ShadowRoot's mode.
42
45
  *
46
+ * @default 'open'
43
47
  * @see https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot/mode
44
- * @default "open"
45
48
  */
46
49
  mode?: 'open' | 'closed';
47
50
  /**
48
- * When enabled, `event.stopPropagation` will be called on events trying to bubble out of the
49
- * shadow root.
51
+ * When enabled, `event.stopPropagation` will be called on events trying to
52
+ * bubble out of the shadow root.
50
53
  *
51
54
  * - Set to `true` to stop the propagation of a default set of events,
52
55
  * `["keyup", "keydown", "keypress"]`
53
- * - Set to an array of event names to stop the propagation of a custom list of events
56
+ * - Set to an array of event names to stop the propagation of a custom list
57
+ * of events
54
58
  */
55
59
  isolateEvents?: boolean | string[];
56
60
  /**
57
61
  * By default, WXT adds `all: initial` to the shadow root before the rest of
58
- * your CSS. This resets any inheritable CSS styles that
59
- * [normally pierce the Shadow DOM](https://open-wc.org/guides/knowledge/styling/styles-piercing-shadow-dom/).
62
+ * your CSS. This resets any inheritable CSS styles that [normally pierce
63
+ * the Shadow
64
+ * DOM](https://open-wc.org/guides/knowledge/styling/styles-piercing-shadow-dom/).
60
65
  *
61
66
  * WXT resets everything but:
62
- * - **`rem` Units**: they continue to scale based off the webpage's HTML `font-size`.
63
- * - **CSS Variables/Custom Properties**: CSS variables defined outside the shadow root can be accessed inside it.
64
- * - **`@font-face` Definitions**: Fonts defined outside the shadow root can be used inside it.
65
67
  *
66
- * To disable this behavior and inherit styles from the webpage, set `inheritStyles: true`.
68
+ * - **`rem` Units**: they continue to scale based off the webpage's HTML
69
+ * `font-size`.
70
+ * - **CSS Variables/Custom Properties**: CSS variables defined outside the
71
+ * shadow root can be accessed inside it.
72
+ * - **`@font-face` Definitions**: Fonts defined outside the shadow root can
73
+ * be used inside it.
74
+ *
75
+ * To disable this behavior and inherit styles from the webpage, set
76
+ * `inheritStyles: true`.
67
77
  *
68
78
  * @default false
69
79
  */
70
80
  inheritStyles?: boolean;
71
81
  /**
72
- * Callback executed when mounting the UI. This function should create and append the UI to the
73
- * `uiContainer` element. It is called every time `ui.mount()` is called.
82
+ * Callback executed when mounting the UI. This function should create and
83
+ * append the UI to the `uiContainer` element. It is called every time
84
+ * `ui.mount()` is called.
74
85
  *
75
- * Optionally return a value that can be accessed at `ui.mounted` or in the `onRemove` callback.
86
+ * Optionally return a value that can be accessed at `ui.mounted` or in the
87
+ * `onRemove` callback.
76
88
  */
77
89
  onMount: (uiContainer: HTMLElement, shadow: ShadowRoot, shadowHost: HTMLElement) => TMounted;
78
90
  };
@@ -3,11 +3,11 @@ import { applyPosition, createMountFunctions, mountUi } from "./shared.mjs";
3
3
  import { splitShadowRootCss } from "../split-shadow-root-css.mjs";
4
4
  import { browser } from "wxt/browser";
5
5
  import { createIsolatedElement } from "@webext-core/isolated-element";
6
-
7
6
  //#region src/utils/content-script-ui/shadow-root.ts
8
7
  /** @module wxt/utils/content-script-ui/shadow-root */
9
8
  /**
10
- * Create a content script UI inside a [`ShadowRoot`](https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot).
9
+ * Create a content script UI inside a
10
+ * [`ShadowRoot`](https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot).
11
11
  *
12
12
  * > This function is async because it has to load the CSS via a network call.
13
13
  *
@@ -63,9 +63,7 @@ async function createShadowRootUi(ctx, options) {
63
63
  }
64
64
  };
65
65
  }
66
- /**
67
- * Load the CSS for the current entrypoint.
68
- */
66
+ /** Load the CSS for the current entrypoint. */
69
67
  async function loadCss() {
70
68
  const url = browser.runtime.getURL(`/content-scripts/${import.meta.env.ENTRYPOINT}.css`);
71
69
  try {
@@ -75,6 +73,5 @@ async function loadCss() {
75
73
  return "";
76
74
  }
77
75
  }
78
-
79
76
  //#endregion
80
- export { createShadowRootUi };
77
+ export { createShadowRootUi };
@@ -1,7 +1,6 @@
1
1
  import { logger } from "../internal/logger.mjs";
2
2
  import { waitElement } from "@1natsu/wait-element";
3
3
  import { isExist, isNotExist } from "@1natsu/wait-element/detectors";
4
-
5
4
  //#region src/utils/content-script-ui/shared.ts
6
5
  function applyPosition(root, positionedElement, options) {
7
6
  if (options.position === "inline") return;
@@ -117,6 +116,5 @@ function autoMountUi(uiCallbacks, options) {
117
116
  observeElement(resolvedAnchor);
118
117
  return { stopAutoMount: _stopAutoMount };
119
118
  }
120
-
121
119
  //#endregion
122
- export { applyPosition, createMountFunctions, mountUi };
120
+ export { applyPosition, createMountFunctions, mountUi };