wxt 0.19.29 → 0.20.0-beta2

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 (95) hide show
  1. package/dist/browser.d.ts +30 -0
  2. package/dist/browser.mjs +3 -0
  3. package/dist/builtin-modules/unimport.mjs +29 -10
  4. package/dist/cli/index.mjs +0 -1
  5. package/dist/core/builders/vite/index.mjs +17 -37
  6. package/dist/core/builders/vite/plugins/extensionApiMock.d.ts +1 -6
  7. package/dist/core/builders/vite/plugins/extensionApiMock.mjs +2 -4
  8. package/dist/core/builders/vite/plugins/index.d.ts +0 -1
  9. package/dist/core/builders/vite/plugins/index.mjs +0 -1
  10. package/dist/core/builders/vite/plugins/noopBackground.mjs +1 -1
  11. package/dist/core/define-web-ext-config.d.ts +9 -0
  12. package/dist/core/define-web-ext-config.mjs +10 -0
  13. package/dist/core/generate-wxt-dir.mjs +3 -6
  14. package/dist/core/index.d.ts +1 -1
  15. package/dist/core/index.mjs +1 -1
  16. package/dist/core/resolve-config.mjs +142 -49
  17. package/dist/core/utils/building/index.d.ts +0 -1
  18. package/dist/core/utils/building/index.mjs +0 -1
  19. package/dist/core/utils/building/rebuild.d.ts +2 -2
  20. package/dist/core/utils/content-scripts.d.ts +4 -3
  21. package/dist/core/utils/content-scripts.mjs +2 -0
  22. package/dist/core/utils/manifest.d.ts +4 -8
  23. package/dist/core/utils/manifest.mjs +4 -7
  24. package/dist/core/utils/strings.d.ts +0 -4
  25. package/dist/core/utils/strings.mjs +0 -6
  26. package/dist/core/utils/testing/fake-objects.d.ts +3376 -1013
  27. package/dist/core/utils/testing/fake-objects.mjs +19 -22
  28. package/dist/core/utils/transform.d.ts +1 -1
  29. package/dist/core/utils/types.d.ts +3 -0
  30. package/dist/index.d.ts +5 -0
  31. package/dist/modules.d.ts +1 -1
  32. package/dist/testing/index.d.ts +1 -0
  33. package/dist/testing/wxt-vitest-plugin.mjs +1 -3
  34. package/dist/types.d.ts +42 -76
  35. package/dist/utils/app-config.d.ts +2 -0
  36. package/dist/{client/content-scripts → utils}/content-script-context.d.ts +4 -3
  37. package/dist/{client/content-scripts → utils}/content-script-context.mjs +5 -3
  38. package/dist/utils/content-script-ui/iframe.d.ts +32 -0
  39. package/dist/utils/content-script-ui/iframe.mjs +30 -0
  40. package/dist/utils/content-script-ui/integrated.d.ts +34 -0
  41. package/dist/utils/content-script-ui/integrated.mjs +32 -0
  42. package/dist/utils/content-script-ui/shadow-root.d.ts +76 -0
  43. package/dist/utils/content-script-ui/shadow-root.mjs +73 -0
  44. package/dist/utils/content-script-ui/shared.d.ts +5 -0
  45. package/dist/{client/content-scripts/ui/index.mjs → utils/content-script-ui/shared.mjs} +5 -138
  46. package/dist/{client/content-scripts/ui → utils/content-script-ui}/types.d.ts +1 -96
  47. package/dist/{sandbox → utils}/define-app-config.d.ts +3 -2
  48. package/dist/{sandbox → utils}/define-background.d.ts +1 -0
  49. package/dist/{sandbox → utils}/define-content-script.d.ts +1 -0
  50. package/dist/{sandbox → utils}/define-unlisted-script.d.ts +1 -0
  51. package/dist/{sandbox → utils}/define-wxt-plugin.d.ts +1 -0
  52. package/dist/{sandbox → utils/internal}/dev-server-websocket.mjs +1 -1
  53. package/dist/{client/content-scripts → utils/internal}/location-watcher.d.ts +1 -1
  54. package/dist/utils/match-patterns.d.ts +5 -0
  55. package/dist/utils/match-patterns.mjs +1 -0
  56. package/dist/utils/storage.d.ts +5 -0
  57. package/dist/version.mjs +1 -1
  58. package/dist/virtual/background-entrypoint.mjs +1 -1
  59. package/dist/virtual/content-script-isolated-world-entrypoint.mjs +1 -1
  60. package/package.json +109 -76
  61. package/dist/browser/chrome.d.ts +0 -13
  62. package/dist/browser/chrome.mjs +0 -7
  63. package/dist/browser/index.d.ts +0 -26
  64. package/dist/browser/index.mjs +0 -2
  65. package/dist/client/app-config.d.ts +0 -2
  66. package/dist/client/content-scripts/index.d.ts +0 -2
  67. package/dist/client/content-scripts/index.mjs +0 -2
  68. package/dist/client/content-scripts/ui/index.d.ts +0 -23
  69. package/dist/client/index.d.ts +0 -8
  70. package/dist/client/index.mjs +0 -3
  71. package/dist/core/builders/vite/plugins/resolveExtensionApi.d.ts +0 -10
  72. package/dist/core/builders/vite/plugins/resolveExtensionApi.mjs +0 -15
  73. package/dist/core/define-runner-config.d.ts +0 -2
  74. package/dist/core/define-runner-config.mjs +0 -3
  75. package/dist/core/utils/building/import-entrypoint.d.ts +0 -16
  76. package/dist/core/utils/building/import-entrypoint.mjs +0 -99
  77. package/dist/sandbox/index.d.ts +0 -11
  78. package/dist/sandbox/index.mjs +0 -6
  79. package/dist/storage.d.ts +0 -4
  80. /package/dist/{client → utils}/app-config.mjs +0 -0
  81. /package/dist/{client/content-scripts/ui → utils/content-script-ui}/types.mjs +0 -0
  82. /package/dist/{sandbox → utils}/define-app-config.mjs +0 -0
  83. /package/dist/{sandbox → utils}/define-background.mjs +0 -0
  84. /package/dist/{sandbox → utils}/define-content-script.mjs +0 -0
  85. /package/dist/{sandbox → utils}/define-unlisted-script.mjs +0 -0
  86. /package/dist/{sandbox → utils}/define-wxt-plugin.mjs +0 -0
  87. /package/dist/{client → utils}/inject-script.d.ts +0 -0
  88. /package/dist/{client → utils}/inject-script.mjs +0 -0
  89. /package/dist/{client/content-scripts → utils/internal}/custom-events.d.ts +0 -0
  90. /package/dist/{client/content-scripts → utils/internal}/custom-events.mjs +0 -0
  91. /package/dist/{sandbox → utils/internal}/dev-server-websocket.d.ts +0 -0
  92. /package/dist/{client/content-scripts → utils/internal}/location-watcher.mjs +0 -0
  93. /package/dist/{sandbox/utils → utils/internal}/logger.d.ts +0 -0
  94. /package/dist/{sandbox/utils → utils/internal}/logger.mjs +0 -0
  95. /package/dist/{storage.mjs → utils/storage.mjs} +0 -0
@@ -1,11 +1,12 @@
1
- import type { Manifest, Scripting } from 'wxt/browser';
1
+ import type { Browser } from '@wxt-dev/browser';
2
2
  import { ContentScriptEntrypoint, ResolvedConfig } from '../../types';
3
+ import { ManifestContentScript } from './types';
3
4
  /**
4
5
  * Returns a unique and consistent string hash based on a content scripts options.
5
6
  *
6
7
  * It is able to recognize default values,
7
8
  */
8
9
  export declare function hashContentScriptOptions(options: ContentScriptEntrypoint['options']): string;
9
- export declare function mapWxtOptionsToContentScript(options: ContentScriptEntrypoint['options'], js: string[] | undefined, css: string[] | undefined): Manifest.ContentScript;
10
- export declare function mapWxtOptionsToRegisteredContentScript(options: ContentScriptEntrypoint['options'], js: string[] | undefined, css: string[] | undefined): Omit<Scripting.RegisteredContentScript, 'id'>;
10
+ export declare function mapWxtOptionsToContentScript(options: ContentScriptEntrypoint['options'], js: string[] | undefined, css: string[] | undefined): ManifestContentScript;
11
+ export declare function mapWxtOptionsToRegisteredContentScript(options: ContentScriptEntrypoint['options'], js: string[] | undefined, css: string[] | undefined): Omit<Browser.scripting.RegisteredContentScript, 'id'>;
11
12
  export declare function getContentScriptJs(config: ResolvedConfig, entrypoint: ContentScriptEntrypoint): string[];
@@ -15,6 +15,7 @@ export function hashContentScriptOptions(options) {
15
15
  match_about_blank: false,
16
16
  run_at: "document_idle",
17
17
  all_frames: false,
18
+ // @ts-expect-error: Untyped
18
19
  match_origin_as_fallback: false,
19
20
  world: "ISOLATED",
20
21
  ...simplifiedOptions
@@ -37,6 +38,7 @@ export function mapWxtOptionsToContentScript(options, js, css) {
37
38
  run_at: options.runAt,
38
39
  css,
39
40
  js,
41
+ // @ts-expect-error: Untyped
40
42
  match_origin_as_fallback: options.matchOriginAsFallback,
41
43
  world: options.world
42
44
  };
@@ -1,14 +1,14 @@
1
- import type { Manifest } from 'wxt/browser';
2
1
  import { Entrypoint, BuildOutput, ContentScriptEntrypoint } from '../../types';
2
+ import type { Browser } from '@wxt-dev/browser';
3
3
  /**
4
4
  * Writes the manifest to the output directory and the build output.
5
5
  */
6
- export declare function writeManifest(manifest: Manifest.WebExtensionManifest, output: BuildOutput): Promise<void>;
6
+ export declare function writeManifest(manifest: Browser.runtime.Manifest, output: BuildOutput): Promise<void>;
7
7
  /**
8
8
  * Generates the manifest based on the config and entrypoints.
9
9
  */
10
10
  export declare function generateManifest(allEntrypoints: Entrypoint[], buildOutput: Omit<BuildOutput, 'manifest'>): Promise<{
11
- manifest: Manifest.WebExtensionManifest;
11
+ manifest: Browser.runtime.Manifest;
12
12
  warnings: any[][];
13
13
  }>;
14
14
  /**
@@ -37,8 +37,4 @@ export declare function stripPathFromMatchPattern(pattern: string): string;
37
37
  * generated in this file, and may be defined by the user in their manifest. In both cases, when
38
38
  * targeting MV2, automatically convert their definitions down to the basic MV2 array.
39
39
  */
40
- export declare function convertWebAccessibleResourcesToMv2(manifest: Manifest.WebExtensionManifest): void;
41
- /**
42
- * Make sure all resources are in MV3 format. If not, add a wanring
43
- */
44
- export declare function validateMv3WebAccessibleResources(manifest: Manifest.WebExtensionManifest): void;
40
+ export declare function convertWebAccessibleResourcesToMv2(manifest: Browser.runtime.Manifest): void;
@@ -47,10 +47,7 @@ export async function generateManifest(allEntrypoints, buildOutput) {
47
47
  "`manifest.manifest_version` config was set, but ignored. To change the target manifest version, use the `manifestVersion` option or the `--mv2`/`--mv3` CLI flags.\nSee https://wxt.dev/guide/essentials/target-different-browsers.html#target-a-manifest-version"
48
48
  );
49
49
  }
50
- let manifest = defu(
51
- userManifest,
52
- baseManifest
53
- );
50
+ let manifest = defu(userManifest, baseManifest);
54
51
  if (wxt.config.command === "serve" && wxt.config.dev.reloadCommand) {
55
52
  if (manifest.commands && // If the following limit is exceeded, Chrome will fail to load the extension.
56
53
  // Error: "Too many commands specified for 'commands': The maximum is 4."
@@ -76,7 +73,6 @@ export async function generateManifest(allEntrypoints, buildOutput) {
76
73
  addEntrypoints(manifest, entrypoints, buildOutput);
77
74
  if (wxt.config.command === "serve") addDevModeCsp(manifest);
78
75
  if (wxt.config.command === "serve") addDevModePermissions(manifest);
79
- wxt.config.transformManifest?.(manifest);
80
76
  await wxt.hooks.callHook("build:manifestGenerated", wxt, manifest);
81
77
  if (wxt.config.manifestVersion === 2) {
82
78
  convertWebAccessibleResourcesToMv2(manifest);
@@ -226,6 +222,7 @@ function addEntrypoints(manifest, entrypoints, buildOutput) {
226
222
  const page = getEntrypointBundlePath(options, wxt.config.outDir, ".html");
227
223
  manifest.options_ui = {
228
224
  open_in_tab: options.options.openInTab,
225
+ // @ts-expect-error: Not typed by @wxt-dev/browser, but supported by Firefox
229
226
  browser_style: wxt.config.browser === "firefox" ? options.options.browserStyle : void 0,
230
227
  chrome_style: wxt.config.browser !== "firefox" ? options.options.chromeStyle : void 0,
231
228
  page
@@ -401,7 +398,7 @@ export function getContentScriptCssWebAccessibleResources(contentScripts, conten
401
398
  resources: [cssFile],
402
399
  matches: script.options.matches?.map(
403
400
  (matchPattern) => stripPathFromMatchPattern(matchPattern)
404
- )
401
+ ) ?? []
405
402
  });
406
403
  });
407
404
  return resources;
@@ -461,7 +458,7 @@ function convertCspToMv2(manifest) {
461
458
  return;
462
459
  manifest.content_security_policy = manifest.content_security_policy.extension_pages;
463
460
  }
464
- export function validateMv3WebAccessibleResources(manifest) {
461
+ function validateMv3WebAccessibleResources(manifest) {
465
462
  if (manifest.web_accessible_resources == null) return;
466
463
  const stringResources = manifest.web_accessible_resources.filter(
467
464
  (item) => typeof item === "string"
@@ -12,7 +12,3 @@ export declare function safeFilename(str: string): string;
12
12
  * calls.
13
13
  */
14
14
  export declare function removeImportStatements(text: string): string;
15
- /**
16
- * Removes imports, ensuring that some of WXT's client imports are present, so that entrypoints can be parsed if auto-imports are disabled.
17
- */
18
- export declare function removeProjectImportStatements(text: string): string;
@@ -16,9 +16,3 @@ export function removeImportStatements(text) {
16
16
  ""
17
17
  );
18
18
  }
19
- export function removeProjectImportStatements(text) {
20
- const noImports = removeImportStatements(text);
21
- return `import { defineUnlistedScript, defineContentScript, defineBackground } from 'wxt/sandbox';
22
-
23
- ${noImports}`;
24
- }