wxt 0.14.1 → 0.14.2-alpha2
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/chunk-JPUPWTMG.js +7 -0
- package/dist/{chunk-B7XRXAP5.js → chunk-Y6R4JWTX.js} +246 -106
- package/dist/cli.js +263 -121
- package/dist/{external-tVP-84Pg.d.cts → external-d6JYvU3i.d.cts} +6 -0
- package/dist/{external-tVP-84Pg.d.ts → external-d6JYvU3i.d.ts} +6 -0
- package/dist/i18n.cjs +69 -0
- package/dist/i18n.d.cts +30 -0
- package/dist/i18n.d.ts +30 -0
- package/dist/i18n.js +33 -0
- package/dist/index.cjs +302 -160
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -1
- package/dist/storage.js +3 -4
- package/dist/testing.cjs +23 -13
- package/dist/testing.d.cts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +1 -1
- package/package.json +12 -1
|
@@ -122,6 +122,12 @@ interface InlineConfig {
|
|
|
122
122
|
* @default "${config.root}/public"
|
|
123
123
|
*/
|
|
124
124
|
publicDir?: string;
|
|
125
|
+
/**
|
|
126
|
+
* Directory containing localization files used for translation.
|
|
127
|
+
*
|
|
128
|
+
* @default "${config.srcDir}/locales"
|
|
129
|
+
*/
|
|
130
|
+
localesDir?: string;
|
|
125
131
|
/**
|
|
126
132
|
* @default "${config.srcDir}/entrypoints"
|
|
127
133
|
*/
|
|
@@ -122,6 +122,12 @@ interface InlineConfig {
|
|
|
122
122
|
* @default "${config.root}/public"
|
|
123
123
|
*/
|
|
124
124
|
publicDir?: string;
|
|
125
|
+
/**
|
|
126
|
+
* Directory containing localization files used for translation.
|
|
127
|
+
*
|
|
128
|
+
* @default "${config.srcDir}/locales"
|
|
129
|
+
*/
|
|
130
|
+
localesDir?: string;
|
|
125
131
|
/**
|
|
126
132
|
* @default "${config.srcDir}/entrypoints"
|
|
127
133
|
*/
|
package/dist/i18n.cjs
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
};
|