wxt 0.14.2-alpha2 → 0.14.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.
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './external-d6JYvU3i.cjs';
2
- export { q as BackgroundDefinition, h as BackgroundEntrypoint, g as BaseEntrypoint, f as BaseEntrypointOptions, d as BuildStepOutput, w as ConfigEnv, p as ContentScriptBaseDefinition, m as ContentScriptDefinition, C as ContentScriptEntrypoint, n as ContentScriptIsolatedWorldDefinition, o as ContentScriptMainWorldDefinition, j as Entrypoint, k as EntrypointGroup, t as ExcludableEntrypoint, G as GenericEntrypoint, L as Logger, l as OnContentScriptStopped, i as OptionsEntrypoint, c as OutputAsset, b as OutputChunk, O as OutputFile, s as PerBrowserOption, P as PopupEntrypoint, S as ServerInfo, T as TargetBrowser, e as TargetManifestVersion, r as UnlistedScriptDefinition, u as UserManifest, v as UserManifestFn, x as WxtBuilder, y as WxtBuilderServer, a as WxtViteConfig } from './external-d6JYvU3i.cjs';
1
+ import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './external-QOQPHF1G.cjs';
2
+ export { q as BackgroundDefinition, h as BackgroundEntrypoint, g as BaseEntrypoint, f as BaseEntrypointOptions, d as BuildStepOutput, w as ConfigEnv, p as ContentScriptBaseDefinition, m as ContentScriptDefinition, C as ContentScriptEntrypoint, n as ContentScriptIsolatedWorldDefinition, o as ContentScriptMainWorldDefinition, j as Entrypoint, k as EntrypointGroup, t as ExcludableEntrypoint, G as GenericEntrypoint, L as Logger, l as OnContentScriptStopped, i as OptionsEntrypoint, c as OutputAsset, b as OutputChunk, O as OutputFile, s as PerBrowserOption, P as PopupEntrypoint, S as ServerInfo, T as TargetBrowser, e as TargetManifestVersion, r as UnlistedScriptDefinition, u as UserManifest, v as UserManifestFn, x as WxtBuilder, y as WxtBuilderServer, a as WxtViteConfig } from './external-QOQPHF1G.cjs';
3
3
  import 'vite';
4
4
  import 'webextension-polyfill';
5
5
  import 'unimport';
@@ -62,6 +62,6 @@ declare function prepare(config: InlineConfig): Promise<void>;
62
62
  */
63
63
  declare function zip(config?: InlineConfig): Promise<string[]>;
64
64
 
65
- var version = "0.14.2-alpha2";
65
+ var version = "0.14.3";
66
66
 
67
67
  export { BuildOutput, ExtensionRunnerConfig, InlineConfig, UserConfig, WxtDevServer, build, clean, createServer, defineConfig, defineRunnerConfig, initialize, prepare, version, zip };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './external-d6JYvU3i.js';
2
- export { q as BackgroundDefinition, h as BackgroundEntrypoint, g as BaseEntrypoint, f as BaseEntrypointOptions, d as BuildStepOutput, w as ConfigEnv, p as ContentScriptBaseDefinition, m as ContentScriptDefinition, C as ContentScriptEntrypoint, n as ContentScriptIsolatedWorldDefinition, o as ContentScriptMainWorldDefinition, j as Entrypoint, k as EntrypointGroup, t as ExcludableEntrypoint, G as GenericEntrypoint, L as Logger, l as OnContentScriptStopped, i as OptionsEntrypoint, c as OutputAsset, b as OutputChunk, O as OutputFile, s as PerBrowserOption, P as PopupEntrypoint, S as ServerInfo, T as TargetBrowser, e as TargetManifestVersion, r as UnlistedScriptDefinition, u as UserManifest, v as UserManifestFn, x as WxtBuilder, y as WxtBuilderServer, a as WxtViteConfig } from './external-d6JYvU3i.js';
1
+ import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './external-QOQPHF1G.js';
2
+ export { q as BackgroundDefinition, h as BackgroundEntrypoint, g as BaseEntrypoint, f as BaseEntrypointOptions, d as BuildStepOutput, w as ConfigEnv, p as ContentScriptBaseDefinition, m as ContentScriptDefinition, C as ContentScriptEntrypoint, n as ContentScriptIsolatedWorldDefinition, o as ContentScriptMainWorldDefinition, j as Entrypoint, k as EntrypointGroup, t as ExcludableEntrypoint, G as GenericEntrypoint, L as Logger, l as OnContentScriptStopped, i as OptionsEntrypoint, c as OutputAsset, b as OutputChunk, O as OutputFile, s as PerBrowserOption, P as PopupEntrypoint, S as ServerInfo, T as TargetBrowser, e as TargetManifestVersion, r as UnlistedScriptDefinition, u as UserManifest, v as UserManifestFn, x as WxtBuilder, y as WxtBuilderServer, a as WxtViteConfig } from './external-QOQPHF1G.js';
3
3
  import 'vite';
4
4
  import 'webextension-polyfill';
5
5
  import 'unimport';
@@ -62,6 +62,6 @@ declare function prepare(config: InlineConfig): Promise<void>;
62
62
  */
63
63
  declare function zip(config?: InlineConfig): Promise<string[]>;
64
64
 
65
- var version = "0.14.2-alpha2";
65
+ var version = "0.14.3";
66
66
 
67
67
  export { BuildOutput, ExtensionRunnerConfig, InlineConfig, UserConfig, WxtDevServer, build, clean, createServer, defineConfig, defineRunnerConfig, initialize, prepare, version, zip };
package/dist/index.js CHANGED
@@ -15,7 +15,7 @@ import {
15
15
  rebuild,
16
16
  resolvePerBrowserOption,
17
17
  version
18
- } from "./chunk-Y6R4JWTX.js";
18
+ } from "./chunk-E6XT3LOQ.js";
19
19
  import "./chunk-VBXJIVYU.js";
20
20
 
21
21
  // src/core/build.ts
package/dist/storage.js CHANGED
@@ -1,8 +1,9 @@
1
- import {
2
- browser
3
- } from "./chunk-JPUPWTMG.js";
4
1
  import "./chunk-VBXJIVYU.js";
5
2
 
3
+ // src/browser.ts
4
+ import originalBrowser from "webextension-polyfill";
5
+ var browser = originalBrowser;
6
+
6
7
  // src/storage.ts
7
8
  import { dequal } from "dequal/lite";
8
9
  var storage = createStorage();
package/dist/testing.cjs CHANGED
@@ -44,8 +44,8 @@ var import_node_path2 = __toESM(require("path"), 1);
44
44
  // src/core/utils/paths.ts
45
45
  var import_node_path = __toESM(require("path"), 1);
46
46
  var import_normalize_path = __toESM(require("normalize-path"), 1);
47
- function normalizePath(path5) {
48
- return (0, import_normalize_path.default)(path5);
47
+ function normalizePath(path6) {
48
+ return (0, import_normalize_path.default)(path6);
49
49
  }
50
50
  var CSS_EXTENSIONS = ["css", "scss", "sass", "less", "styl", "stylus"];
51
51
  var CSS_EXTENSIONS_PATTERN = `+(${CSS_EXTENSIONS.join("|")})`;
@@ -337,8 +337,7 @@ function getUnimportOptions(config) {
337
337
  debugLog: config.logger.debug,
338
338
  imports: [
339
339
  { name: "defineConfig", from: "wxt" },
340
- { name: "fakeBrowser", from: "wxt/testing" },
341
- { name: "i18n", from: "wxt/i18n" }
340
+ { name: "fakeBrowser", from: "wxt/testing" }
342
341
  ],
343
342
  presets: [
344
343
  { package: "wxt/client" },
@@ -636,20 +635,15 @@ async function writeFileIfDifferent(file, newContents) {
636
635
 
637
636
  // src/core/utils/building/build-entrypoints.ts
638
637
  var import_fs_extra4 = __toESM(require("fs-extra"), 1);
639
- var import_node_path6 = require("path");
640
638
  var import_picocolors = __toESM(require("picocolors"), 1);
641
639
 
642
- // src/i18n/node.ts
643
- var import_promises = require("fs/promises");
644
- var import_json5 = __toESM(require("json5"), 1);
645
- var import_yaml = __toESM(require("yaml"), 1);
646
-
647
640
  // src/core/utils/building/find-entrypoints.ts
648
641
  var import_fs_extra5 = __toESM(require("fs-extra"), 1);
649
642
  var import_minimatch = require("minimatch");
650
643
  var import_linkedom2 = require("linkedom");
651
- var import_json52 = __toESM(require("json5"), 1);
644
+ var import_json5 = __toESM(require("json5"), 1);
652
645
  var import_fast_glob2 = __toESM(require("fast-glob"), 1);
646
+ var import_picocolors2 = __toESM(require("picocolors"), 1);
653
647
  var PATH_GLOB_TO_TYPE_MAP = {
654
648
  "sandbox.html": "sandbox",
655
649
  "sandbox/index.html": "sandbox",
@@ -693,7 +687,7 @@ var PATH_GLOB_TO_TYPE_MAP = {
693
687
  // src/core/utils/building/generate-wxt-dir.ts
694
688
  var import_unimport3 = require("unimport");
695
689
  var import_fs_extra6 = __toESM(require("fs-extra"), 1);
696
- var import_fast_glob3 = __toESM(require("fast-glob"), 1);
690
+ var import_node_path6 = __toESM(require("path"), 1);
697
691
 
698
692
  // src/core/utils/building/get-internal-config.ts
699
693
  var import_c12 = require("c12");
@@ -706,14 +700,14 @@ function createFsCache(wxtDir) {
706
700
  const getPath = (key) => (0, import_path3.resolve)(wxtDir, "cache", encodeURIComponent(key));
707
701
  return {
708
702
  async set(key, value) {
709
- const path5 = getPath(key);
710
- await (0, import_fs_extra7.ensureDir)((0, import_path3.dirname)(path5));
711
- await writeFileIfDifferent(path5, value);
703
+ const path6 = getPath(key);
704
+ await (0, import_fs_extra7.ensureDir)((0, import_path3.dirname)(path6));
705
+ await writeFileIfDifferent(path6, value);
712
706
  },
713
707
  async get(key) {
714
- const path5 = getPath(key);
708
+ const path6 = getPath(key);
715
709
  try {
716
- return await import_fs_extra7.default.readFile(path5, "utf-8");
710
+ return await import_fs_extra7.default.readFile(path6, "utf-8");
717
711
  } catch {
718
712
  return void 0;
719
713
  }
@@ -962,8 +956,8 @@ async function getInternalConfig(inlineConfig, command, server) {
962
956
  srcDir,
963
957
  mergedConfig.entrypointsDir ?? "entrypoints"
964
958
  );
959
+ const filterEntrypoints = !!mergedConfig.filterEntrypoints?.length ? new Set(mergedConfig.filterEntrypoints) : void 0;
965
960
  const publicDir = import_node_path7.default.resolve(srcDir, mergedConfig.publicDir ?? "public");
966
- const localesDir = import_node_path7.default.resolve(srcDir, mergedConfig.localesDir ?? "locales");
967
961
  const typesDir = import_node_path7.default.resolve(wxtDir, "types");
968
962
  const outBaseDir = import_node_path7.default.resolve(root, mergedConfig.outDir ?? ".output");
969
963
  const outDir = import_node_path7.default.resolve(outBaseDir, `${browser}-mv${manifestVersion}`);
@@ -989,6 +983,7 @@ async function getInternalConfig(inlineConfig, command, server) {
989
983
  command,
990
984
  debug,
991
985
  entrypointsDir,
986
+ filterEntrypoints,
992
987
  env,
993
988
  fsCache: createFsCache(wxtDir),
994
989
  imports: mergedConfig.imports ?? {},
@@ -999,7 +994,6 @@ async function getInternalConfig(inlineConfig, command, server) {
999
994
  outBaseDir,
1000
995
  outDir,
1001
996
  publicDir,
1002
- localesDir,
1003
997
  root,
1004
998
  runnerConfig,
1005
999
  srcDir,
@@ -1063,12 +1057,12 @@ function mergeInlineConfig(inlineConfig, userConfig) {
1063
1057
  configFile: inlineConfig.configFile,
1064
1058
  debug: inlineConfig.debug ?? userConfig.debug,
1065
1059
  entrypointsDir: inlineConfig.entrypointsDir ?? userConfig.entrypointsDir,
1060
+ filterEntrypoints: inlineConfig.filterEntrypoints ?? userConfig.filterEntrypoints,
1066
1061
  imports,
1067
1062
  logger: inlineConfig.logger ?? userConfig.logger,
1068
1063
  manifest,
1069
1064
  mode: inlineConfig.mode ?? userConfig.mode,
1070
1065
  publicDir: inlineConfig.publicDir ?? userConfig.publicDir,
1071
- localesDir: inlineConfig.localesDir ?? userConfig.localesDir,
1072
1066
  runner,
1073
1067
  srcDir: inlineConfig.srcDir ?? userConfig.srcDir,
1074
1068
  outDir: inlineConfig.outDir ?? userConfig.outDir,
@@ -1120,33 +1114,33 @@ var import_esbuild = require("esbuild");
1120
1114
  var import_node_url = require("url");
1121
1115
 
1122
1116
  // src/core/utils/building/internal-build.ts
1123
- var import_picocolors4 = __toESM(require("picocolors"), 1);
1117
+ var import_picocolors5 = __toESM(require("picocolors"), 1);
1124
1118
  var import_fs_extra12 = __toESM(require("fs-extra"), 1);
1125
1119
 
1126
1120
  // src/core/utils/log/printFileList.ts
1127
1121
  var import_node_path9 = __toESM(require("path"), 1);
1128
- var import_picocolors2 = __toESM(require("picocolors"), 1);
1122
+ var import_picocolors3 = __toESM(require("picocolors"), 1);
1129
1123
  var import_fs_extra9 = __toESM(require("fs-extra"), 1);
1130
1124
  var import_filesize = require("filesize");
1131
- var DEFAULT_COLOR = import_picocolors2.default.blue;
1125
+ var DEFAULT_COLOR = import_picocolors3.default.blue;
1132
1126
  var CHUNK_COLORS = {
1133
- ".js.map": import_picocolors2.default.gray,
1134
- ".cjs.map": import_picocolors2.default.gray,
1135
- ".mjs.map": import_picocolors2.default.gray,
1136
- ".html": import_picocolors2.default.green,
1137
- ".css": import_picocolors2.default.magenta,
1138
- ".js": import_picocolors2.default.cyan,
1139
- ".cjs": import_picocolors2.default.cyan,
1140
- ".mjs": import_picocolors2.default.cyan,
1141
- ".zip": import_picocolors2.default.yellow
1127
+ ".js.map": import_picocolors3.default.gray,
1128
+ ".cjs.map": import_picocolors3.default.gray,
1129
+ ".mjs.map": import_picocolors3.default.gray,
1130
+ ".html": import_picocolors3.default.green,
1131
+ ".css": import_picocolors3.default.magenta,
1132
+ ".js": import_picocolors3.default.cyan,
1133
+ ".cjs": import_picocolors3.default.cyan,
1134
+ ".mjs": import_picocolors3.default.cyan,
1135
+ ".zip": import_picocolors3.default.yellow
1142
1136
  };
1143
1137
 
1144
1138
  // src/core/utils/log/printHeader.ts
1145
- var import_picocolors3 = __toESM(require("picocolors"), 1);
1139
+ var import_picocolors4 = __toESM(require("picocolors"), 1);
1146
1140
  var import_consola2 = require("consola");
1147
1141
 
1148
1142
  // src/core/utils/building/internal-build.ts
1149
- var import_fast_glob4 = __toESM(require("fast-glob"), 1);
1143
+ var import_fast_glob3 = __toESM(require("fast-glob"), 1);
1150
1144
 
1151
1145
  // src/core/utils/manifest.ts
1152
1146
  var import_fs_extra11 = __toESM(require("fs-extra"), 1);
@@ -1,6 +1,6 @@
1
1
  export { FakeBrowser, fakeBrowser } from '@webext-core/fake-browser';
2
2
  import * as vite from 'vite';
3
- import { I as InlineConfig } from './external-d6JYvU3i.cjs';
3
+ import { I as InlineConfig } from './external-QOQPHF1G.cjs';
4
4
  import 'webextension-polyfill';
5
5
  import 'unimport';
6
6
  import 'consola';
package/dist/testing.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { FakeBrowser, fakeBrowser } from '@webext-core/fake-browser';
2
2
  import * as vite from 'vite';
3
- import { I as InlineConfig } from './external-d6JYvU3i.js';
3
+ import { I as InlineConfig } from './external-QOQPHF1G.js';
4
4
  import 'webextension-polyfill';
5
5
  import 'unimport';
6
6
  import 'consola';
package/dist/testing.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  tsconfigPaths,
6
6
  unimport,
7
7
  webextensionPolyfillMock
8
- } from "./chunk-Y6R4JWTX.js";
8
+ } from "./chunk-E6XT3LOQ.js";
9
9
  import "./chunk-VBXJIVYU.js";
10
10
 
11
11
  // src/testing/fake-browser.ts
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "wxt",
3
3
  "type": "module",
4
- "version": "0.14.2-alpha2",
4
+ "version": "0.14.3",
5
5
  "description": "Next gen framework for developing web extensions",
6
6
  "engines": {
7
7
  "node": ">=18",
@@ -77,16 +77,6 @@
77
77
  "default": "./dist/storage.cjs"
78
78
  }
79
79
  },
80
- "./i18n": {
81
- "import": {
82
- "types": "./dist/i18n.d.ts",
83
- "default": "./dist/i18n.js"
84
- },
85
- "require": {
86
- "types": "./dist/i18n.d.cts",
87
- "default": "./dist/i18n.cjs"
88
- }
89
- },
90
80
  "./vite-builder-env": {
91
81
  "types": "./dist/vite-builder-env.d.ts"
92
82
  }
@@ -124,7 +114,6 @@
124
114
  "vite": "^5.0.0",
125
115
  "web-ext-run": "^0.1.0",
126
116
  "webextension-polyfill": "^0.10.0",
127
- "yaml": "^2.3.4",
128
117
  "zip-dir": "^2.0.0"
129
118
  },
130
119
  "devDependencies": {
@@ -1,7 +0,0 @@
1
- // src/browser.ts
2
- import originalBrowser from "webextension-polyfill";
3
- var browser = originalBrowser;
4
-
5
- export {
6
- browser
7
- };
package/dist/i18n.cjs DELETED
@@ -1,69 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/i18n/index.ts
31
- var i18n_exports = {};
32
- __export(i18n_exports, {
33
- i18n: () => i18n
34
- });
35
- module.exports = __toCommonJS(i18n_exports);
36
-
37
- // src/browser.ts
38
- var import_webextension_polyfill = __toESM(require("webextension-polyfill"), 1);
39
- var browser = import_webextension_polyfill.default;
40
-
41
- // src/i18n/client.ts
42
- function createExtensionI18n() {
43
- const untyped = {
44
- t(key, substitutions) {
45
- return browser.i18n.getMessage(key, substitutions);
46
- },
47
- tp(key, count, substitutions) {
48
- const plural = browser.i18n.getMessage(key, substitutions).split(" | ");
49
- if (plural.length === 1)
50
- return plural[0];
51
- if (plural.length === 2) {
52
- if (count === 1)
53
- return plural[0];
54
- return plural[1];
55
- }
56
- if (count === 0 || count === 1)
57
- return plural[count];
58
- return plural[2];
59
- }
60
- };
61
- return untyped;
62
- }
63
-
64
- // src/i18n/index.ts
65
- var i18n = createExtensionI18n();
66
- // Annotate the CommonJS export names for ESM import in node:
67
- 0 && (module.exports = {
68
- i18n
69
- });
package/dist/i18n.d.cts DELETED
@@ -1,30 +0,0 @@
1
- interface DefaultMessageSchema {
2
- t: {
3
- [key: string]: string[] | undefined;
4
- };
5
- tp: {
6
- [key: string]: string[] | undefined;
7
- };
8
- }
9
- type ExtensionI18n<TMessageSchema> = TMessageSchema extends DefaultMessageSchema ? TypedExtensionI18n<TMessageSchema> : UntypedExtensionI18n;
10
- interface TypedExtensionI18n<TMessageSchema extends DefaultMessageSchema> {
11
- t<TKey extends KeysWithoutSub<TMessageSchema['t']>>(key: TKey): string;
12
- t<TKey extends KeysWithSub<TMessageSchema['t']>>(key: TKey, substitutions: TMessageSchema['t'][TKey]): string;
13
- tp<TKey extends KeysWithoutSub<TMessageSchema['tp']>>(key: TKey, count: number): string;
14
- tp<TKey extends KeysWithSub<TMessageSchema['tp']>>(key: TKey, count: number, substitutions: TMessageSchema['tp'][TKey]): string;
15
- }
16
- interface UntypedExtensionI18n {
17
- t(key: string, substitutions?: string[]): string;
18
- tp(key: string, count: number, substitutions?: string[]): string;
19
- }
20
- type FilterKeys<TObject, TFilterType> = {
21
- [K in keyof TObject]-?: TObject[K] extends TFilterType ? K : never;
22
- }[keyof TObject];
23
- type KeysWithSub<TObject> = FilterKeys<TObject, string[]>;
24
- type KeysWithoutSub<TObject> = FilterKeys<TObject, undefined>;
25
-
26
- interface WxtMessageSchema extends DefaultMessageSchema {
27
- }
28
- declare const i18n: TypedExtensionI18n<WxtMessageSchema>;
29
-
30
- export { type DefaultMessageSchema, type ExtensionI18n, type TypedExtensionI18n, type UntypedExtensionI18n, type WxtMessageSchema, i18n };
package/dist/i18n.d.ts DELETED
@@ -1,30 +0,0 @@
1
- interface DefaultMessageSchema {
2
- t: {
3
- [key: string]: string[] | undefined;
4
- };
5
- tp: {
6
- [key: string]: string[] | undefined;
7
- };
8
- }
9
- type ExtensionI18n<TMessageSchema> = TMessageSchema extends DefaultMessageSchema ? TypedExtensionI18n<TMessageSchema> : UntypedExtensionI18n;
10
- interface TypedExtensionI18n<TMessageSchema extends DefaultMessageSchema> {
11
- t<TKey extends KeysWithoutSub<TMessageSchema['t']>>(key: TKey): string;
12
- t<TKey extends KeysWithSub<TMessageSchema['t']>>(key: TKey, substitutions: TMessageSchema['t'][TKey]): string;
13
- tp<TKey extends KeysWithoutSub<TMessageSchema['tp']>>(key: TKey, count: number): string;
14
- tp<TKey extends KeysWithSub<TMessageSchema['tp']>>(key: TKey, count: number, substitutions: TMessageSchema['tp'][TKey]): string;
15
- }
16
- interface UntypedExtensionI18n {
17
- t(key: string, substitutions?: string[]): string;
18
- tp(key: string, count: number, substitutions?: string[]): string;
19
- }
20
- type FilterKeys<TObject, TFilterType> = {
21
- [K in keyof TObject]-?: TObject[K] extends TFilterType ? K : never;
22
- }[keyof TObject];
23
- type KeysWithSub<TObject> = FilterKeys<TObject, string[]>;
24
- type KeysWithoutSub<TObject> = FilterKeys<TObject, undefined>;
25
-
26
- interface WxtMessageSchema extends DefaultMessageSchema {
27
- }
28
- declare const i18n: TypedExtensionI18n<WxtMessageSchema>;
29
-
30
- export { type DefaultMessageSchema, type ExtensionI18n, type TypedExtensionI18n, type UntypedExtensionI18n, type WxtMessageSchema, i18n };
package/dist/i18n.js DELETED
@@ -1,33 +0,0 @@
1
- import {
2
- browser
3
- } from "./chunk-JPUPWTMG.js";
4
- import "./chunk-VBXJIVYU.js";
5
-
6
- // src/i18n/client.ts
7
- function createExtensionI18n() {
8
- const untyped = {
9
- t(key, substitutions) {
10
- return browser.i18n.getMessage(key, substitutions);
11
- },
12
- tp(key, count, substitutions) {
13
- const plural = browser.i18n.getMessage(key, substitutions).split(" | ");
14
- if (plural.length === 1)
15
- return plural[0];
16
- if (plural.length === 2) {
17
- if (count === 1)
18
- return plural[0];
19
- return plural[1];
20
- }
21
- if (count === 0 || count === 1)
22
- return plural[count];
23
- return plural[2];
24
- }
25
- };
26
- return untyped;
27
- }
28
-
29
- // src/i18n/index.ts
30
- var i18n = createExtensionI18n();
31
- export {
32
- i18n
33
- };