adnbn 0.5.2 → 0.5.4
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/cli/builders/locale/LocaleBuilder.js +1 -4
- package/dist/cli/builders/locale/LocaleBuilder.js.map +1 -1
- package/dist/cli/plugins/content/index.js.map +1 -1
- package/dist/cli/plugins/content/utils.js +9 -1
- package/dist/cli/plugins/content/utils.js.map +1 -1
- package/dist/cli/plugins/optimization.js +14 -4
- package/dist/cli/plugins/optimization.js.map +1 -1
- package/dist/cli/plugins/output.js +1 -0
- package/dist/cli/plugins/output.js.map +1 -1
- package/dist/cli/plugins/style.js +3 -3
- package/dist/cli/plugins/style.js.map +1 -1
- package/dist/entry/content/core/AbstractMarker.js +1 -3
- package/dist/entry/content/core/AbstractMarker.js.map +1 -1
- package/dist/locale/adapters/react/LocaleProvider.d.ts +2 -1
- package/dist/locale/adapters/react/LocaleProvider.js +15 -6
- package/dist/locale/adapters/react/LocaleProvider.js.map +1 -1
- package/dist/locale/providers/NativeLocale.d.ts +2 -0
- package/dist/locale/providers/NativeLocale.js +21 -18
- package/dist/locale/providers/NativeLocale.js.map +1 -1
- package/dist/locale/utils.d.ts +2 -1
- package/dist/locale/utils.js +13 -1
- package/dist/locale/utils.js.map +1 -1
- package/dist/message/providers/AbstractMessage.js.map +1 -1
- package/dist/types/offscreen.js.map +1 -1
- package/dist/types/relay.js.map +1 -1
- package/package.json +17 -12
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
LocaleNestedKeysSeparator,
|
|
7
7
|
LocaleValuesSeparator
|
|
8
8
|
} from "./../../../types/locale.js";
|
|
9
|
-
import { Browser } from "./../../../types/browser.js";
|
|
10
9
|
class LocaleBuilder {
|
|
11
10
|
constructor(browser, language) {
|
|
12
11
|
this.browser = browser;
|
|
@@ -25,9 +24,7 @@ class LocaleBuilder {
|
|
|
25
24
|
items.set(key, value);
|
|
26
25
|
}
|
|
27
26
|
}
|
|
28
|
-
|
|
29
|
-
items.set(LocaleCustomKeyForLanguage, this.language);
|
|
30
|
-
}
|
|
27
|
+
items.set(LocaleCustomKeyForLanguage, this.language);
|
|
31
28
|
return this.items = items;
|
|
32
29
|
}
|
|
33
30
|
keys() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/cli/builders/locale/LocaleBuilder.ts"],"sourcesContent":["import _ from \"lodash\";\n\nimport {convertLocaleKey} from \"@locale/utils\";\n\nimport {LocaleError} from \"./LocaleValidator\";\n\nimport {\n Language,\n LocaleBuilder as LocaleBuilderContract,\n LocaleCustomKeyForLanguage,\n LocaleData,\n LocaleItems,\n LocaleKeys,\n LocaleMessages,\n LocaleNestedKeysSeparator,\n LocaleStructure,\n LocaleValidator,\n LocaleValuesSeparator,\n} from \"@typing/locale\";\nimport {Browser} from \"@typing/browser\";\n\nexport default class LocaleBuilder implements LocaleBuilderContract {\n protected data: LocaleData[] = [];\n protected items?: LocaleItems;\n\n protected validator?: LocaleValidator;\n\n constructor(\n protected readonly browser: Browser,\n protected readonly language: Language\n ) {}\n\n public get(): LocaleItems {\n if (this.items) {\n return this.items;\n }\n\n const items: LocaleItems = new Map();\n\n for (const data of this.data) {\n for (const [key, value] of this.convert(data).entries()) {\n items.set(key, value);\n }\n }\n\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/cli/builders/locale/LocaleBuilder.ts"],"sourcesContent":["import _ from \"lodash\";\n\nimport {convertLocaleKey} from \"@locale/utils\";\n\nimport {LocaleError} from \"./LocaleValidator\";\n\nimport {\n Language,\n LocaleBuilder as LocaleBuilderContract,\n LocaleCustomKeyForLanguage,\n LocaleData,\n LocaleItems,\n LocaleKeys,\n LocaleMessages,\n LocaleNestedKeysSeparator,\n LocaleStructure,\n LocaleValidator,\n LocaleValuesSeparator,\n} from \"@typing/locale\";\nimport {Browser} from \"@typing/browser\";\n\nexport default class LocaleBuilder implements LocaleBuilderContract {\n protected data: LocaleData[] = [];\n protected items?: LocaleItems;\n\n protected validator?: LocaleValidator;\n\n constructor(\n protected readonly browser: Browser,\n protected readonly language: Language\n ) {}\n\n public get(): LocaleItems {\n if (this.items) {\n return this.items;\n }\n\n const items: LocaleItems = new Map();\n\n for (const data of this.data) {\n for (const [key, value] of this.convert(data).entries()) {\n items.set(key, value);\n }\n }\n\n /**\n We inject a locale marker into each `messages.json`.\n Chrome provides no API to query the effective i18n locale:\n browser UI language may differ from the translation actually used\n (Chrome silently falls back to default_locale).\n Reading this marker via chrome.i18n.getMessage() is the only reliable way\n to detect the language currently displayed in the extension UI.\n */\n items.set(LocaleCustomKeyForLanguage, this.language);\n\n return (this.items = items);\n }\n\n public keys(): LocaleKeys {\n return new Set(this.get().keys());\n }\n\n public build(): LocaleMessages {\n return this.validate()\n .get()\n .entries()\n .reduce(\n (locale, [key, value]) => ({\n ...locale,\n [convertLocaleKey(key)]: {message: value},\n }),\n {}\n );\n }\n\n public structure(): LocaleStructure {\n const substitutions = (value: string): string[] => {\n const pattern = /{{([^{}]+)}}/g;\n const substitutions: string[] = [];\n\n let match: RegExpExecArray | null;\n\n while ((match = pattern.exec(value)) !== null) {\n substitutions.push(match[1].trim());\n }\n\n return substitutions;\n };\n\n return this.get()\n .entries()\n .reduce(\n (structure, [key, value]) => ({\n ...structure,\n [key]: {\n plural: value.includes(LocaleValuesSeparator),\n substitutions: substitutions(value),\n },\n }),\n {} as LocaleStructure\n );\n }\n\n public merge(data: LocaleData): this {\n this.data.push(data);\n this.items = undefined;\n\n return this;\n }\n\n public lang(): Language {\n return this.language;\n }\n\n public isValid(): boolean {\n try {\n this.validate();\n return true;\n } catch {\n return false;\n }\n }\n\n public validate(): this {\n if (!this.validator) {\n throw new LocaleError(this.browser, this.language, \"Validator is not set\");\n }\n\n this.validator.validate(this);\n\n return this;\n }\n\n public setValidator(validator: LocaleValidator): this {\n this.validator = validator;\n\n return this;\n }\n\n protected convert(data: LocaleData, prefix?: string): LocaleItems {\n const items: LocaleItems = new Map();\n\n for (const [key, value] of Object.entries(data)) {\n const resolvedKey = prefix ? [prefix, key].join(LocaleNestedKeysSeparator) : key;\n\n if (_.isString(value) || _.isNumber(value)) {\n items.set(resolvedKey, value.toString());\n } else if (_.isArray(value)) {\n items.set(\n resolvedKey,\n _.filter(value, v => _.isString(v) || _.isNumber(v)).join(LocaleValuesSeparator)\n );\n } else if (_.isPlainObject(value)) {\n for (const [k, v] of this.convert(value, resolvedKey).entries()) {\n items.set(k, v);\n }\n }\n }\n\n return items;\n }\n}\n"],"mappings":"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","names":["substitutions"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/cli/plugins/content/index.ts"],"sourcesContent":["import {Configuration as RspackConfig, DefinePlugin} from \"@rspack/core\";\nimport {merge as mergeConfig} from \"webpack-merge\";\n\nimport ContentManager from \"./ContentManager\";\nimport Content from \"./Content\";\nimport Relay from \"./Relay\";\nimport RelayDeclaration from \"./RelayDeclaration\";\n\nimport {definePlugin} from \"@main/plugin\";\n\nimport {EntrypointPlugin, onlyViaTopLevelEntry} from \"@cli/bundler\";\n\nimport {Command} from \"@typing/app\";\nimport {RelayMethod, RelayOptions} from \"@typing/relay\";\nimport {ContentScriptDeclarative} from \"@typing/content\";\n\nexport default definePlugin(() => {\n let content: Content;\n let relay: Relay;\n let manager: ContentManager;\n let relayDeclaration: RelayDeclaration;\n\n return {\n name: \"adnbn:content\",\n startup: async ({config}) => {\n content = new Content(config);\n relay = new Relay(config);\n\n manager = new ContentManager(config).provider(content).provider(relay);\n\n relayDeclaration = new RelayDeclaration(config);\n },\n content: () => content.files(),\n relay: () => relay.files(),\n bundler: async ({config}) => {\n relayDeclaration.dictionary(await relay.dictionary()).build();\n\n let rspack: RspackConfig = {};\n let options: Record<string, RelayOptions> = {};\n\n if (await manager.empty()) {\n if (config.debug) {\n console.warn(\"Content script or relay entries not found\");\n }\n } else {\n options = await relay.getOptionsMap();\n\n // prettier-ignore\n const plugin = EntrypointPlugin.from(await manager.entries())\n .virtual(file => manager.virtual(file));\n\n if (config.command === Command.Watch) {\n plugin.watch(async () => {\n manager.clear();\n\n relayDeclaration.dictionary(await relay.dictionary()).build();\n\n return manager.entries();\n });\n }\n\n rspack = {\n plugins: [plugin],\n optimization: {\n splitChunks: {\n cacheGroups: {\n frameworkContent: {\n minChunks: 2,\n name: manager.chunkName(),\n test: onlyViaTopLevelEntry([\"content\", \"relay\"]),\n chunks: (chunk): boolean => {\n return manager.likely(chunk.name);\n },\n enforce: false,\n reuseExistingChunk: true,\n priority: 10,\n },\n },\n },\n },\n };\n }\n\n return mergeConfig(rspack, {\n plugins: [\n new DefinePlugin({\n __ADNBN_RELAY_OPTIONS__: JSON.stringify(options),\n }),\n ],\n });\n },\n manifest: async ({manifest}) => {\n // prettier-ignore\n manifest\n .setContentScripts(await manager.manifest())\n .appendHostPermissions(await manager.hostPermissions())\n .appendOptionalHostPermissions(await manager.optionalHostPermissions());\n\n if ((await relay.exists()) && (await relay.hasMethod(RelayMethod.Scripting))) {\n if (await relay.hasDeclarative(ContentScriptDeclarative.Required)) {\n manifest.addPermission(\"scripting\");\n } else if (await relay.hasDeclarative(ContentScriptDeclarative.Optional)) {\n manifest.addOptionalPermission(\"scripting\");\n }\n }\n },\n };\n});\n"],"mappings":"AAAA,SAAuC,oBAAmB;AAC1D,SAAQ,SAAS,mBAAkB;AAEnC,OAAO,oBAAoB;AAC3B,OAAO,aAAa;AACpB,OAAO,WAAW;AAClB,OAAO,sBAAsB;AAE7B,SAAQ,oBAAmB;AAE3B,SAAQ,kBAAkB,4BAA2B;AAErD,SAAQ,eAAc;AACtB,SAAQ,mBAAgC;AACxC,SAAQ,gCAA+B;AAEvC,IAAO,kBAAQ,aAAa,MAAM;AAC9B,MAAI;AACJ,MAAI;AACJ,MAAI;AACJ,MAAI;AAEJ,SAAO;AAAA,IACH,MAAM;AAAA,IACN,SAAS,OAAO,EAAC,OAAM,MAAM;AACzB,gBAAU,IAAI,QAAQ,MAAM;AAC5B,cAAQ,IAAI,MAAM,MAAM;
|
|
1
|
+
{"version":3,"sources":["../../../../src/cli/plugins/content/index.ts"],"sourcesContent":["import {Configuration as RspackConfig, DefinePlugin} from \"@rspack/core\";\nimport {merge as mergeConfig} from \"webpack-merge\";\n\nimport ContentManager from \"./ContentManager\";\nimport Content from \"./Content\";\nimport Relay from \"./Relay\";\nimport RelayDeclaration from \"./RelayDeclaration\";\n\nimport {definePlugin} from \"@main/plugin\";\n\nimport {EntrypointPlugin, onlyViaTopLevelEntry} from \"@cli/bundler\";\n\nimport {Command} from \"@typing/app\";\nimport {RelayMethod, RelayOptions} from \"@typing/relay\";\nimport {ContentScriptDeclarative} from \"@typing/content\";\n\nexport default definePlugin(() => {\n let content: Content;\n let relay: Relay;\n let manager: ContentManager;\n let relayDeclaration: RelayDeclaration;\n\n return {\n name: \"adnbn:content\",\n startup: async ({config}) => {\n content = new Content(config);\n relay = new Relay(config);\n\n // prettier-ignore\n manager = new ContentManager(config)\n .provider(content)\n .provider(relay);\n\n relayDeclaration = new RelayDeclaration(config);\n },\n content: () => content.files(),\n relay: () => relay.files(),\n bundler: async ({config}) => {\n relayDeclaration.dictionary(await relay.dictionary()).build();\n\n let rspack: RspackConfig = {};\n let options: Record<string, RelayOptions> = {};\n\n if (await manager.empty()) {\n if (config.debug) {\n console.warn(\"Content script or relay entries not found\");\n }\n } else {\n options = await relay.getOptionsMap();\n\n // prettier-ignore\n const plugin = EntrypointPlugin.from(await manager.entries())\n .virtual(file => manager.virtual(file));\n\n if (config.command === Command.Watch) {\n plugin.watch(async () => {\n manager.clear();\n\n relayDeclaration.dictionary(await relay.dictionary()).build();\n\n return manager.entries();\n });\n }\n\n rspack = {\n plugins: [plugin],\n optimization: {\n splitChunks: {\n cacheGroups: {\n frameworkContent: {\n minChunks: 2,\n name: manager.chunkName(),\n test: onlyViaTopLevelEntry([\"content\", \"relay\"]),\n chunks: (chunk): boolean => {\n return manager.likely(chunk.name);\n },\n enforce: false,\n reuseExistingChunk: true,\n priority: 10,\n },\n },\n },\n },\n };\n }\n\n return mergeConfig(rspack, {\n plugins: [\n new DefinePlugin({\n __ADNBN_RELAY_OPTIONS__: JSON.stringify(options),\n }),\n ],\n });\n },\n manifest: async ({manifest}) => {\n // prettier-ignore\n manifest\n .setContentScripts(await manager.manifest())\n .appendHostPermissions(await manager.hostPermissions())\n .appendOptionalHostPermissions(await manager.optionalHostPermissions());\n\n if ((await relay.exists()) && (await relay.hasMethod(RelayMethod.Scripting))) {\n if (await relay.hasDeclarative(ContentScriptDeclarative.Required)) {\n manifest.addPermission(\"scripting\");\n } else if (await relay.hasDeclarative(ContentScriptDeclarative.Optional)) {\n manifest.addOptionalPermission(\"scripting\");\n }\n }\n },\n };\n});\n"],"mappings":"AAAA,SAAuC,oBAAmB;AAC1D,SAAQ,SAAS,mBAAkB;AAEnC,OAAO,oBAAoB;AAC3B,OAAO,aAAa;AACpB,OAAO,WAAW;AAClB,OAAO,sBAAsB;AAE7B,SAAQ,oBAAmB;AAE3B,SAAQ,kBAAkB,4BAA2B;AAErD,SAAQ,eAAc;AACtB,SAAQ,mBAAgC;AACxC,SAAQ,gCAA+B;AAEvC,IAAO,kBAAQ,aAAa,MAAM;AAC9B,MAAI;AACJ,MAAI;AACJ,MAAI;AACJ,MAAI;AAEJ,SAAO;AAAA,IACH,MAAM;AAAA,IACN,SAAS,OAAO,EAAC,OAAM,MAAM;AACzB,gBAAU,IAAI,QAAQ,MAAM;AAC5B,cAAQ,IAAI,MAAM,MAAM;AAGxB,gBAAU,IAAI,eAAe,MAAM,EAC9B,SAAS,OAAO,EAChB,SAAS,KAAK;AAEnB,yBAAmB,IAAI,iBAAiB,MAAM;AAAA,IAClD;AAAA,IACA,SAAS,MAAM,QAAQ,MAAM;AAAA,IAC7B,OAAO,MAAM,MAAM,MAAM;AAAA,IACzB,SAAS,OAAO,EAAC,OAAM,MAAM;AACzB,uBAAiB,WAAW,MAAM,MAAM,WAAW,CAAC,EAAE,MAAM;AAE5D,UAAI,SAAuB,CAAC;AAC5B,UAAI,UAAwC,CAAC;AAE7C,UAAI,MAAM,QAAQ,MAAM,GAAG;AACvB,YAAI,OAAO,OAAO;AACd,kBAAQ,KAAK,2CAA2C;AAAA,QAC5D;AAAA,MACJ,OAAO;AACH,kBAAU,MAAM,MAAM,cAAc;AAGpC,cAAM,SAAS,iBAAiB,KAAK,MAAM,QAAQ,QAAQ,CAAC,EACvD,QAAQ,UAAQ,QAAQ,QAAQ,IAAI,CAAC;AAE1C,YAAI,OAAO,YAAY,QAAQ,OAAO;AAClC,iBAAO,MAAM,YAAY;AACrB,oBAAQ,MAAM;AAEd,6BAAiB,WAAW,MAAM,MAAM,WAAW,CAAC,EAAE,MAAM;AAE5D,mBAAO,QAAQ,QAAQ;AAAA,UAC3B,CAAC;AAAA,QACL;AAEA,iBAAS;AAAA,UACL,SAAS,CAAC,MAAM;AAAA,UAChB,cAAc;AAAA,YACV,aAAa;AAAA,cACT,aAAa;AAAA,gBACT,kBAAkB;AAAA,kBACd,WAAW;AAAA,kBACX,MAAM,QAAQ,UAAU;AAAA,kBACxB,MAAM,qBAAqB,CAAC,WAAW,OAAO,CAAC;AAAA,kBAC/C,QAAQ,CAAC,UAAmB;AACxB,2BAAO,QAAQ,OAAO,MAAM,IAAI;AAAA,kBACpC;AAAA,kBACA,SAAS;AAAA,kBACT,oBAAoB;AAAA,kBACpB,UAAU;AAAA,gBACd;AAAA,cACJ;AAAA,YACJ;AAAA,UACJ;AAAA,QACJ;AAAA,MACJ;AAEA,aAAO,YAAY,QAAQ;AAAA,QACvB,SAAS;AAAA,UACL,IAAI,aAAa;AAAA,YACb,yBAAyB,KAAK,UAAU,OAAO;AAAA,UACnD,CAAC;AAAA,QACL;AAAA,MACJ,CAAC;AAAA,IACL;AAAA,IACA,UAAU,OAAO,EAAC,SAAQ,MAAM;AAE5B,eACK,kBAAkB,MAAM,QAAQ,SAAS,CAAC,EAC1C,sBAAsB,MAAM,QAAQ,gBAAgB,CAAC,EACrD,8BAA8B,MAAM,QAAQ,wBAAwB,CAAC;AAE1E,UAAK,MAAM,MAAM,OAAO,KAAO,MAAM,MAAM,UAAU,YAAY,SAAS,GAAI;AAC1E,YAAI,MAAM,MAAM,eAAe,yBAAyB,QAAQ,GAAG;AAC/D,mBAAS,cAAc,WAAW;AAAA,QACtC,WAAW,MAAM,MAAM,eAAe,yBAAyB,QAAQ,GAAG;AACtE,mBAAS,sBAAsB,WAAW;AAAA,QAC9C;AAAA,MACJ;AAAA,IACJ;AAAA,EACJ;AACJ,CAAC;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _ from "lodash";
|
|
2
2
|
const getContentScriptConfigFromOptions = (options) => {
|
|
3
|
-
|
|
3
|
+
const config = _.pick(options, [
|
|
4
4
|
"matches",
|
|
5
5
|
"excludeMatches",
|
|
6
6
|
"includeGlobs",
|
|
@@ -11,6 +11,14 @@ const getContentScriptConfigFromOptions = (options) => {
|
|
|
11
11
|
"matchAboutBlank",
|
|
12
12
|
"matchOriginAsFallback"
|
|
13
13
|
]);
|
|
14
|
+
const sort = (arr) => arr == null ? void 0 : arr.toSorted((a, b) => a.localeCompare(b));
|
|
15
|
+
return {
|
|
16
|
+
...config,
|
|
17
|
+
matches: sort(config.matches),
|
|
18
|
+
excludeMatches: sort(config.excludeMatches),
|
|
19
|
+
includeGlobs: sort(config.includeGlobs),
|
|
20
|
+
excludeGlobs: sort(config.excludeGlobs)
|
|
21
|
+
};
|
|
14
22
|
};
|
|
15
23
|
export {
|
|
16
24
|
getContentScriptConfigFromOptions
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/cli/plugins/content/utils.ts"],"sourcesContent":["import _ from \"lodash\";\n\nimport {ContentScriptConfig, ContentScriptEntrypointOptions} from \"@typing/content\";\n\nexport const getContentScriptConfigFromOptions = (options: ContentScriptEntrypointOptions): ContentScriptConfig => {\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/cli/plugins/content/utils.ts"],"sourcesContent":["import _ from \"lodash\";\n\nimport {ContentScriptConfig, ContentScriptEntrypointOptions} from \"@typing/content\";\n\nexport const getContentScriptConfigFromOptions = (options: ContentScriptEntrypointOptions): ContentScriptConfig => {\n const config = _.pick(options, [\n \"matches\",\n \"excludeMatches\",\n \"includeGlobs\",\n \"excludeGlobs\",\n \"allFrames\",\n \"runAt\",\n \"world\",\n \"matchAboutBlank\",\n \"matchOriginAsFallback\",\n ]) as ContentScriptConfig;\n\n const sort = (arr?: string[]) => arr?.toSorted((a, b) => a.localeCompare(b));\n\n return {\n ...config,\n matches: sort(config.matches),\n excludeMatches: sort(config.excludeMatches),\n includeGlobs: sort(config.includeGlobs),\n excludeGlobs: sort(config.excludeGlobs),\n };\n};\n"],"mappings":"AAAA,OAAO,OAAO;AAIP,MAAM,oCAAoC,CAAC,YAAiE;AAC/G,QAAM,SAAS,EAAE,KAAK,SAAS;AAAA,IAC3B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACJ,CAAC;AAED,QAAM,OAAO,CAAC,QAAmB,2BAAK,SAAS,CAAC,GAAG,MAAM,EAAE,cAAc,CAAC;AAE1E,SAAO;AAAA,IACH,GAAG;AAAA,IACH,SAAS,KAAK,OAAO,OAAO;AAAA,IAC5B,gBAAgB,KAAK,OAAO,cAAc;AAAA,IAC1C,cAAc,KAAK,OAAO,YAAY;AAAA,IACtC,cAAc,KAAK,OAAO,YAAY;AAAA,EAC1C;AACJ;","names":[]}
|
|
@@ -1,19 +1,28 @@
|
|
|
1
1
|
import _ from "lodash";
|
|
2
|
+
import { merge as mergeConfig } from "webpack-merge";
|
|
2
3
|
import { definePlugin } from "./../../main/plugin.js";
|
|
3
4
|
import { getResolvePath, getSourcePath } from "./../../cli/resolvers/path.js";
|
|
4
5
|
var optimization_default = definePlugin(() => {
|
|
5
6
|
return {
|
|
6
7
|
name: "adnbn:optimization",
|
|
7
8
|
bundler: ({ config }) => {
|
|
9
|
+
const rspack = {
|
|
10
|
+
optimization: {
|
|
11
|
+
moduleIds: "deterministic",
|
|
12
|
+
chunkIds: "deterministic",
|
|
13
|
+
mangleExports: "deterministic"
|
|
14
|
+
}
|
|
15
|
+
};
|
|
8
16
|
if (!config.commonChunks) {
|
|
9
|
-
return
|
|
17
|
+
return rspack;
|
|
10
18
|
}
|
|
11
|
-
return {
|
|
19
|
+
return mergeConfig(rspack, {
|
|
12
20
|
optimization: {
|
|
13
21
|
usedExports: true,
|
|
14
22
|
providedExports: true,
|
|
15
23
|
splitChunks: {
|
|
16
|
-
|
|
24
|
+
chunks: "all",
|
|
25
|
+
minSize: 2e4,
|
|
17
26
|
cacheGroups: {
|
|
18
27
|
default: false,
|
|
19
28
|
defaultVendors: false,
|
|
@@ -32,13 +41,14 @@ var optimization_default = definePlugin(() => {
|
|
|
32
41
|
return `${entryNames.join("-")}.${cacheGroupKey}`;
|
|
33
42
|
},
|
|
34
43
|
minChunks: 2,
|
|
44
|
+
enforce: true,
|
|
35
45
|
priority: -10,
|
|
36
46
|
reuseExistingChunk: true
|
|
37
47
|
}
|
|
38
48
|
}
|
|
39
49
|
}
|
|
40
50
|
}
|
|
41
|
-
};
|
|
51
|
+
});
|
|
42
52
|
}
|
|
43
53
|
};
|
|
44
54
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/cli/plugins/optimization.ts"],"sourcesContent":["import _ from \"lodash\";\nimport {Configuration as RspackConfig, NormalModule} from \"@rspack/core\";\n\nimport {definePlugin} from \"@main/plugin\";\n\nimport {getResolvePath, getSourcePath} from \"@cli/resolvers/path\";\n\nexport default definePlugin(() => {\n return {\n name: \"adnbn:optimization\",\n bundler: ({config}) => {\n if (!config.commonChunks) {\n return
|
|
1
|
+
{"version":3,"sources":["../../../src/cli/plugins/optimization.ts"],"sourcesContent":["import _ from \"lodash\";\nimport {Configuration as RspackConfig, NormalModule} from \"@rspack/core\";\nimport {merge as mergeConfig} from \"webpack-merge\";\n\nimport {definePlugin} from \"@main/plugin\";\n\nimport {getResolvePath, getSourcePath} from \"@cli/resolvers/path\";\n\nexport default definePlugin(() => {\n return {\n name: \"adnbn:optimization\",\n bundler: ({config}) => {\n const rspack: RspackConfig = {\n optimization: {\n moduleIds: \"deterministic\",\n chunkIds: \"deterministic\",\n mangleExports: \"deterministic\",\n },\n };\n\n if (!config.commonChunks) {\n return rspack;\n }\n\n return mergeConfig(rspack, {\n optimization: {\n usedExports: true,\n providedExports: true,\n splitChunks: {\n chunks: \"all\",\n minSize: 20000,\n cacheGroups: {\n default: false,\n defaultVendors: false,\n common: {\n test: module => {\n const {resource} = module as NormalModule;\n\n if (!resource) {\n return false;\n }\n\n return resource.startsWith(getResolvePath(getSourcePath(config)));\n },\n name: (module, chunks, cacheGroupKey) => {\n const entryNames = Array.from(\n new Set(chunks.map(({name}) => name).filter(name => _.isString(name)))\n ).sort();\n\n return `${entryNames.join(\"-\")}.${cacheGroupKey}`;\n },\n minChunks: 2,\n enforce: true,\n priority: -10,\n reuseExistingChunk: true,\n },\n },\n },\n },\n });\n },\n };\n});\n"],"mappings":"AAAA,OAAO,OAAO;AAEd,SAAQ,SAAS,mBAAkB;AAEnC,SAAQ,oBAAmB;AAE3B,SAAQ,gBAAgB,qBAAoB;AAE5C,IAAO,uBAAQ,aAAa,MAAM;AAC9B,SAAO;AAAA,IACH,MAAM;AAAA,IACN,SAAS,CAAC,EAAC,OAAM,MAAM;AACnB,YAAM,SAAuB;AAAA,QACzB,cAAc;AAAA,UACV,WAAW;AAAA,UACX,UAAU;AAAA,UACV,eAAe;AAAA,QACnB;AAAA,MACJ;AAEA,UAAI,CAAC,OAAO,cAAc;AACtB,eAAO;AAAA,MACX;AAEA,aAAO,YAAY,QAAQ;AAAA,QACvB,cAAc;AAAA,UACV,aAAa;AAAA,UACb,iBAAiB;AAAA,UACjB,aAAa;AAAA,YACT,QAAQ;AAAA,YACR,SAAS;AAAA,YACT,aAAa;AAAA,cACT,SAAS;AAAA,cACT,gBAAgB;AAAA,cAChB,QAAQ;AAAA,gBACJ,MAAM,YAAU;AACZ,wBAAM,EAAC,SAAQ,IAAI;AAEnB,sBAAI,CAAC,UAAU;AACX,2BAAO;AAAA,kBACX;AAEA,yBAAO,SAAS,WAAW,eAAe,cAAc,MAAM,CAAC,CAAC;AAAA,gBACpE;AAAA,gBACA,MAAM,CAAC,QAAQ,QAAQ,kBAAkB;AACrC,wBAAM,aAAa,MAAM;AAAA,oBACrB,IAAI,IAAI,OAAO,IAAI,CAAC,EAAC,KAAI,MAAM,IAAI,EAAE,OAAO,UAAQ,EAAE,SAAS,IAAI,CAAC,CAAC;AAAA,kBACzE,EAAE,KAAK;AAEP,yBAAO,GAAG,WAAW,KAAK,GAAG,CAAC,IAAI,aAAa;AAAA,gBACnD;AAAA,gBACA,WAAW;AAAA,gBACX,SAAS;AAAA,gBACT,UAAU;AAAA,gBACV,oBAAoB;AAAA,cACxB;AAAA,YACJ;AAAA,UACJ;AAAA,QACJ;AAAA,MACJ,CAAC;AAAA,IACL;AAAA,EACJ;AACJ,CAAC;","names":[]}
|
|
@@ -16,6 +16,7 @@ var output_default = definePlugin(() => {
|
|
|
16
16
|
path: getResolvePath(getOutputPath(config)),
|
|
17
17
|
filename,
|
|
18
18
|
chunkFilename: filename,
|
|
19
|
+
hashSalt: kebabApp,
|
|
19
20
|
hotUpdateGlobal: camelApp + "HotUpdate",
|
|
20
21
|
chunkLoadingGlobal: camelApp + "ChunkLoading",
|
|
21
22
|
uniqueName: kebabApp,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/cli/plugins/output.ts"],"sourcesContent":["import _ from \"lodash\";\nimport {Configuration as RspackConfig} from \"@rspack/core\";\n\nimport {definePlugin} from \"@main/plugin\";\n\nimport {appFilenameResolver} from \"@cli/bundler\";\nimport {getOutputPath, getResolvePath} from \"@cli/resolvers/path\";\n\nimport {Command} from \"@typing/app\";\n\nexport default definePlugin(() => {\n return {\n name: \"adnbn:output\",\n bundler: ({config}) => {\n const {app, jsDir, jsFilename} = config;\n\n const kebabApp = _.kebabCase(app);\n const camelApp = _.camelCase(app);\n\n const filename = appFilenameResolver(app, jsFilename, jsDir);\n\n return {\n output: {\n path: getResolvePath(getOutputPath(config)),\n filename,\n chunkFilename: filename,\n hotUpdateGlobal: camelApp + \"HotUpdate\",\n chunkLoadingGlobal: camelApp + \"ChunkLoading\",\n uniqueName: kebabApp,\n clean: config.command === Command.Build,\n },\n } satisfies RspackConfig;\n },\n };\n});\n"],"mappings":"AAAA,OAAO,OAAO;AAGd,SAAQ,oBAAmB;AAE3B,SAAQ,2BAA0B;AAClC,SAAQ,eAAe,sBAAqB;AAE5C,SAAQ,eAAc;AAEtB,IAAO,iBAAQ,aAAa,MAAM;AAC9B,SAAO;AAAA,IACH,MAAM;AAAA,IACN,SAAS,CAAC,EAAC,OAAM,MAAM;AACnB,YAAM,EAAC,KAAK,OAAO,WAAU,IAAI;AAEjC,YAAM,WAAW,EAAE,UAAU,GAAG;AAChC,YAAM,WAAW,EAAE,UAAU,GAAG;AAEhC,YAAM,WAAW,oBAAoB,KAAK,YAAY,KAAK;AAE3D,aAAO;AAAA,QACH,QAAQ;AAAA,UACJ,MAAM,eAAe,cAAc,MAAM,CAAC;AAAA,UAC1C;AAAA,UACA,eAAe;AAAA,UACf,iBAAiB,WAAW;AAAA,UAC5B,oBAAoB,WAAW;AAAA,UAC/B,YAAY;AAAA,UACZ,OAAO,OAAO,YAAY,QAAQ;AAAA,QACtC;AAAA,MACJ;AAAA,IACJ;AAAA,EACJ;AACJ,CAAC;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/cli/plugins/output.ts"],"sourcesContent":["import _ from \"lodash\";\nimport {Configuration as RspackConfig} from \"@rspack/core\";\n\nimport {definePlugin} from \"@main/plugin\";\n\nimport {appFilenameResolver} from \"@cli/bundler\";\nimport {getOutputPath, getResolvePath} from \"@cli/resolvers/path\";\n\nimport {Command} from \"@typing/app\";\n\nexport default definePlugin(() => {\n return {\n name: \"adnbn:output\",\n bundler: ({config}) => {\n const {app, jsDir, jsFilename} = config;\n\n const kebabApp = _.kebabCase(app);\n const camelApp = _.camelCase(app);\n\n const filename = appFilenameResolver(app, jsFilename, jsDir);\n\n return {\n output: {\n path: getResolvePath(getOutputPath(config)),\n filename,\n chunkFilename: filename,\n hashSalt: kebabApp,\n hotUpdateGlobal: camelApp + \"HotUpdate\",\n chunkLoadingGlobal: camelApp + \"ChunkLoading\",\n uniqueName: kebabApp,\n clean: config.command === Command.Build,\n },\n } satisfies RspackConfig;\n },\n };\n});\n"],"mappings":"AAAA,OAAO,OAAO;AAGd,SAAQ,oBAAmB;AAE3B,SAAQ,2BAA0B;AAClC,SAAQ,eAAe,sBAAqB;AAE5C,SAAQ,eAAc;AAEtB,IAAO,iBAAQ,aAAa,MAAM;AAC9B,SAAO;AAAA,IACH,MAAM;AAAA,IACN,SAAS,CAAC,EAAC,OAAM,MAAM;AACnB,YAAM,EAAC,KAAK,OAAO,WAAU,IAAI;AAEjC,YAAM,WAAW,EAAE,UAAU,GAAG;AAChC,YAAM,WAAW,EAAE,UAAU,GAAG;AAEhC,YAAM,WAAW,oBAAoB,KAAK,YAAY,KAAK;AAE3D,aAAO;AAAA,QACH,QAAQ;AAAA,UACJ,MAAM,eAAe,cAAc,MAAM,CAAC;AAAA,UAC1C;AAAA,UACA,eAAe;AAAA,UACf,UAAU;AAAA,UACV,iBAAiB,WAAW;AAAA,UAC5B,oBAAoB,WAAW;AAAA,UAC/B,YAAY;AAAA,UACZ,OAAO,OAAO,YAAY,QAAQ;AAAA,QACtC;AAAA,MACJ;AAAA,IACJ;AAAA,EACJ;AACJ,CAAC;","names":[]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _ from "lodash";
|
|
2
2
|
import path from "path";
|
|
3
3
|
import fs from "fs";
|
|
4
|
-
import { createHash } from "crypto";
|
|
5
4
|
import { CssExtractRspackPlugin } from "@rspack/core";
|
|
6
5
|
import { definePlugin } from "./../../main/plugin.js";
|
|
7
6
|
import { appFilenameResolver } from "./../../cli/bundler/index.js";
|
|
@@ -39,6 +38,7 @@ var style_default = definePlugin(() => {
|
|
|
39
38
|
bundler: ({ config }) => {
|
|
40
39
|
const { app, cssDir, cssFilename, cssIdentName, mergeStyles } = config;
|
|
41
40
|
const filename = appFilenameResolver(app, cssFilename, cssDir);
|
|
41
|
+
const kebabApp = _.kebabCase(app);
|
|
42
42
|
const createSassRuleSet = (rule) => {
|
|
43
43
|
const rules = [CssExtractRspackPlugin.loader, rule, "sass-loader"];
|
|
44
44
|
if (mergeStyles) {
|
|
@@ -85,8 +85,8 @@ var style_default = definePlugin(() => {
|
|
|
85
85
|
modules: {
|
|
86
86
|
exportLocalsConvention: "as-is",
|
|
87
87
|
namedExport: false,
|
|
88
|
-
localIdentName: cssIdentName.replaceAll("[app]",
|
|
89
|
-
localIdentHashSalt:
|
|
88
|
+
localIdentName: cssIdentName.replaceAll("[app]", kebabApp),
|
|
89
|
+
localIdentHashSalt: kebabApp
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/cli/plugins/style.ts"],"sourcesContent":["import _ from \"lodash\";\nimport path from \"path\";\nimport fs from \"fs\";\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/cli/plugins/style.ts"],"sourcesContent":["import _ from \"lodash\";\nimport path from \"path\";\nimport fs from \"fs\";\nimport {Configuration as RspackConfig, CssExtractRspackPlugin, RuleSetUse, RuleSetUseItem} from \"@rspack/core\";\n\nimport {definePlugin} from \"@main/plugin\";\n\nimport {appFilenameResolver} from \"@cli/bundler\";\n\nimport {getAppSourcePath, getResolvePath, getSharedPath} from \"@cli/resolvers/path\";\n\nimport {ReadonlyConfig} from \"@typing/config\";\nimport {toPosix} from \"@cli/utils/path\";\n\n// prettier-ignore\nconst styleMergerLoader =\n (config: ReadonlyConfig) =>\n (sharedStyle: string, sharedPath: string): string | void => {\n const sharedDir = getResolvePath(getSharedPath(config));\n\n if (sharedPath.startsWith(sharedDir)) {\n const relativePath = path.relative(sharedDir, sharedPath);\n\n const appDir = getResolvePath(getAppSourcePath(config));\n const appPath = getResolvePath(path.join(appDir, relativePath));\n\n if (fs.existsSync(appPath)) {\n try {\n let appStyle = fs.readFileSync(appPath, \"utf8\");\n\n appStyle = appStyle.replace(/url\\((['\"]?)(.*?)\\1\\)/g, (match, quote, filePath) => {\n if (\n filePath.startsWith(\"/\") ||\n filePath.startsWith(\"http\") ||\n filePath.startsWith(\"data:\")\n ) {\n return match;\n }\n\n const cssDir = path.dirname(appPath);\n const assetAbs = path.resolve(cssDir, filePath);\n\n const sharedFileDir = path.dirname(sharedPath);\n\n const relativeToSharedFile = path.relative(sharedFileDir, assetAbs);\n\n return `url(\"${toPosix(relativeToSharedFile)}\")`;\n });\n\n return sharedStyle + \"\\n\" + appStyle;\n } catch (error) {\n console.error(error);\n }\n }\n }\n };\n\nexport default definePlugin(() => {\n return {\n name: \"adnbn:styles\",\n bundler: ({config}) => {\n const {app, cssDir, cssFilename, cssIdentName, mergeStyles} = config;\n\n const filename = appFilenameResolver(app, cssFilename, cssDir);\n const kebabApp = _.kebabCase(app);\n\n const createSassRuleSet = (rule: RuleSetUseItem): RuleSetUse => {\n const rules: RuleSetUse = [CssExtractRspackPlugin.loader, rule, \"sass-loader\"];\n\n if (mergeStyles) {\n rules.push({\n loader: \"source-modifier-loader\",\n options: {\n modify: styleMergerLoader(config),\n },\n });\n }\n\n return rules;\n };\n\n return {\n resolve: {\n extensions: [\".css\", \".scss\"],\n },\n plugins: [\n new CssExtractRspackPlugin({\n filename,\n chunkFilename: filename,\n }),\n ],\n module: {\n rules: [\n {\n test: /\\.(scss|css)$/,\n type: \"javascript/auto\",\n oneOf: [\n {\n resourceQuery: /asis/,\n use: createSassRuleSet({\n loader: \"css-loader\",\n options: {\n esModule: true,\n modules: false,\n },\n }),\n },\n {\n use: createSassRuleSet({\n loader: \"css-loader\",\n options: {\n esModule: true,\n modules: {\n exportLocalsConvention: \"as-is\",\n namedExport: false,\n localIdentName: cssIdentName.replaceAll(\"[app]\", kebabApp),\n localIdentHashSalt: kebabApp,\n },\n },\n }),\n },\n ],\n },\n ],\n },\n } satisfies RspackConfig;\n },\n };\n});\n"],"mappings":"AAAA,OAAO,OAAO;AACd,OAAO,UAAU;AACjB,OAAO,QAAQ;AACf,SAAuC,8BAAyD;AAEhG,SAAQ,oBAAmB;AAE3B,SAAQ,2BAA0B;AAElC,SAAQ,kBAAkB,gBAAgB,qBAAoB;AAG9D,SAAQ,eAAc;AAGtB,MAAM,oBACF,CAAC,WACG,CAAC,aAAqB,eAAsC;AACxD,QAAM,YAAY,eAAe,cAAc,MAAM,CAAC;AAEtD,MAAI,WAAW,WAAW,SAAS,GAAG;AAClC,UAAM,eAAe,KAAK,SAAS,WAAW,UAAU;AAExD,UAAM,SAAS,eAAe,iBAAiB,MAAM,CAAC;AACtD,UAAM,UAAU,eAAe,KAAK,KAAK,QAAQ,YAAY,CAAC;AAE9D,QAAI,GAAG,WAAW,OAAO,GAAG;AACxB,UAAI;AACA,YAAI,WAAW,GAAG,aAAa,SAAS,MAAM;AAE9C,mBAAW,SAAS,QAAQ,0BAA0B,CAAC,OAAO,OAAO,aAAa;AAC9E,cACI,SAAS,WAAW,GAAG,KACvB,SAAS,WAAW,MAAM,KAC1B,SAAS,WAAW,OAAO,GAC7B;AACE,mBAAO;AAAA,UACX;AAEA,gBAAM,SAAS,KAAK,QAAQ,OAAO;AACnC,gBAAM,WAAW,KAAK,QAAQ,QAAQ,QAAQ;AAE9C,gBAAM,gBAAgB,KAAK,QAAQ,UAAU;AAE7C,gBAAM,uBAAuB,KAAK,SAAS,eAAe,QAAQ;AAElE,iBAAO,QAAQ,QAAQ,oBAAoB,CAAC;AAAA,QAChD,CAAC;AAED,eAAO,cAAc,OAAO;AAAA,MAChC,SAAS,OAAO;AACZ,gBAAQ,MAAM,KAAK;AAAA,MACvB;AAAA,IACJ;AAAA,EACJ;AACJ;AAER,IAAO,gBAAQ,aAAa,MAAM;AAC9B,SAAO;AAAA,IACH,MAAM;AAAA,IACN,SAAS,CAAC,EAAC,OAAM,MAAM;AACnB,YAAM,EAAC,KAAK,QAAQ,aAAa,cAAc,YAAW,IAAI;AAE9D,YAAM,WAAW,oBAAoB,KAAK,aAAa,MAAM;AAC7D,YAAM,WAAW,EAAE,UAAU,GAAG;AAEhC,YAAM,oBAAoB,CAAC,SAAqC;AAC5D,cAAM,QAAoB,CAAC,uBAAuB,QAAQ,MAAM,aAAa;AAE7E,YAAI,aAAa;AACb,gBAAM,KAAK;AAAA,YACP,QAAQ;AAAA,YACR,SAAS;AAAA,cACL,QAAQ,kBAAkB,MAAM;AAAA,YACpC;AAAA,UACJ,CAAC;AAAA,QACL;AAEA,eAAO;AAAA,MACX;AAEA,aAAO;AAAA,QACH,SAAS;AAAA,UACL,YAAY,CAAC,QAAQ,OAAO;AAAA,QAChC;AAAA,QACA,SAAS;AAAA,UACL,IAAI,uBAAuB;AAAA,YACvB;AAAA,YACA,eAAe;AAAA,UACnB,CAAC;AAAA,QACL;AAAA,QACA,QAAQ;AAAA,UACJ,OAAO;AAAA,YACH;AAAA,cACI,MAAM;AAAA,cACN,MAAM;AAAA,cACN,OAAO;AAAA,gBACH;AAAA,kBACI,eAAe;AAAA,kBACf,KAAK,kBAAkB;AAAA,oBACnB,QAAQ;AAAA,oBACR,SAAS;AAAA,sBACL,UAAU;AAAA,sBACV,SAAS;AAAA,oBACb;AAAA,kBACJ,CAAC;AAAA,gBACL;AAAA,gBACA;AAAA,kBACI,KAAK,kBAAkB;AAAA,oBACnB,QAAQ;AAAA,oBACR,SAAS;AAAA,sBACL,UAAU;AAAA,sBACV,SAAS;AAAA,wBACL,wBAAwB;AAAA,wBACxB,aAAa;AAAA,wBACb,gBAAgB,aAAa,WAAW,SAAS,QAAQ;AAAA,wBACzD,oBAAoB;AAAA,sBACxB;AAAA,oBACJ;AAAA,kBACJ,CAAC;AAAA,gBACL;AAAA,cACJ;AAAA,YACJ;AAAA,UACJ;AAAA,QACJ;AAAA,MACJ;AAAA,IACJ;AAAA,EACJ;AACJ,CAAC;","names":[]}
|
|
@@ -44,9 +44,7 @@ class AbstractMarker_default {
|
|
|
44
44
|
}
|
|
45
45
|
return this.querySelector(anchor, marked);
|
|
46
46
|
} catch (e) {
|
|
47
|
-
console.error(
|
|
48
|
-
|
|
49
|
-
`, e);
|
|
47
|
+
console.error("Invalid anchor format. Expected a valid string (CSS selector/XPath)", e);
|
|
50
48
|
return [];
|
|
51
49
|
}
|
|
52
50
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/entry/content/core/AbstractMarker.ts"],"sourcesContent":["import {ContentScriptAnchor, ContentScriptMarkerContract, ContentScriptMarkerValue} from \"@typing/content\";\n\nexport default abstract class implements ContentScriptMarkerContract {\n public abstract mark(element: Element, value: ContentScriptMarkerValue): boolean;\n\n public abstract unmark(element: Element): boolean;\n\n public abstract isMarked(element: Element): boolean;\n\n public abstract value(element: Element): ContentScriptMarkerValue | undefined;\n\n protected constructor(protected anchor: ContentScriptAnchor) {}\n\n public for(anchor: ContentScriptAnchor): ContentScriptMarkerContract {\n this.anchor = anchor;\n\n return this;\n }\n\n public unmarked(): Element[] {\n return this.query(false);\n }\n\n public marked(): Element[] {\n return this.query(true);\n }\n\n public mount(element: Element): boolean {\n return this.mark(element, ContentScriptMarkerValue.Mounted);\n }\n\n public unmount(element: Element): boolean {\n return this.mark(element, ContentScriptMarkerValue.Unmounted);\n }\n\n public reset(): ContentScriptMarkerContract {\n for (const element of this.marked()) {\n this.unmark(element);\n }\n\n return this;\n }\n\n protected query(marked: boolean): Element[] {\n const anchor = this.anchor;\n\n if (anchor instanceof Element) {\n const isMarked = this.isMarked(anchor);\n\n if ((isMarked && marked) || (!isMarked && !marked)) {\n return [anchor];\n }\n } else if (typeof anchor === \"string\") {\n return this.queryAnchor(anchor, marked);\n }\n\n return [];\n }\n\n protected queryAnchor(anchor: string, marked: boolean = false): Element[] {\n try {\n if (anchor.startsWith(\"/\")) {\n return this.queryXpath(anchor, marked);\n }\n\n return this.querySelector(anchor, marked);\n } catch (e) {\n console.error(
|
|
1
|
+
{"version":3,"sources":["../../../../src/entry/content/core/AbstractMarker.ts"],"sourcesContent":["import {ContentScriptAnchor, ContentScriptMarkerContract, ContentScriptMarkerValue} from \"@typing/content\";\n\nexport default abstract class implements ContentScriptMarkerContract {\n public abstract mark(element: Element, value: ContentScriptMarkerValue): boolean;\n\n public abstract unmark(element: Element): boolean;\n\n public abstract isMarked(element: Element): boolean;\n\n public abstract value(element: Element): ContentScriptMarkerValue | undefined;\n\n protected constructor(protected anchor: ContentScriptAnchor) {}\n\n public for(anchor: ContentScriptAnchor): ContentScriptMarkerContract {\n this.anchor = anchor;\n\n return this;\n }\n\n public unmarked(): Element[] {\n return this.query(false);\n }\n\n public marked(): Element[] {\n return this.query(true);\n }\n\n public mount(element: Element): boolean {\n return this.mark(element, ContentScriptMarkerValue.Mounted);\n }\n\n public unmount(element: Element): boolean {\n return this.mark(element, ContentScriptMarkerValue.Unmounted);\n }\n\n public reset(): ContentScriptMarkerContract {\n for (const element of this.marked()) {\n this.unmark(element);\n }\n\n return this;\n }\n\n protected query(marked: boolean): Element[] {\n const anchor = this.anchor;\n\n if (anchor instanceof Element) {\n const isMarked = this.isMarked(anchor);\n\n if ((isMarked && marked) || (!isMarked && !marked)) {\n return [anchor];\n }\n } else if (typeof anchor === \"string\") {\n return this.queryAnchor(anchor, marked);\n }\n\n return [];\n }\n\n protected queryAnchor(anchor: string, marked: boolean = false): Element[] {\n try {\n if (anchor.startsWith(\"/\")) {\n return this.queryXpath(anchor, marked);\n }\n\n return this.querySelector(anchor, marked);\n } catch (e) {\n console.error(\"Invalid anchor format. Expected a valid string (CSS selector/XPath)\", e);\n\n return [];\n }\n }\n\n protected querySelector(selector: string, _marked: boolean = false): Element[] {\n return Array.from(document.querySelectorAll(selector));\n }\n\n protected queryXpath(xpath: string, _marked: boolean = false): Element[] {\n const elements: Element[] = [];\n\n const result = document.evaluate(xpath, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);\n\n for (let i = 0; i < result.snapshotLength; i++) {\n elements.push(result.snapshotItem(i) as Element);\n }\n\n return elements;\n }\n\n protected isValidValue(value: any): value is ContentScriptMarkerValue {\n return [ContentScriptMarkerValue.Unmounted, ContentScriptMarkerValue.Mounted].includes(value);\n }\n}\n"],"mappings":"AAAA,SAA0D,gCAA+B;AAEzF,MAAO,uBAA8D;AAAA,EASvD,YAAsB,QAA6B;AAA7B;AAAA,EAA8B;AAAA,EAEvD,IAAI,QAA0D;AACjE,SAAK,SAAS;AAEd,WAAO;AAAA,EACX;AAAA,EAEO,WAAsB;AACzB,WAAO,KAAK,MAAM,KAAK;AAAA,EAC3B;AAAA,EAEO,SAAoB;AACvB,WAAO,KAAK,MAAM,IAAI;AAAA,EAC1B;AAAA,EAEO,MAAM,SAA2B;AACpC,WAAO,KAAK,KAAK,SAAS,yBAAyB,OAAO;AAAA,EAC9D;AAAA,EAEO,QAAQ,SAA2B;AACtC,WAAO,KAAK,KAAK,SAAS,yBAAyB,SAAS;AAAA,EAChE;AAAA,EAEO,QAAqC;AACxC,eAAW,WAAW,KAAK,OAAO,GAAG;AACjC,WAAK,OAAO,OAAO;AAAA,IACvB;AAEA,WAAO;AAAA,EACX;AAAA,EAEU,MAAM,QAA4B;AACxC,UAAM,SAAS,KAAK;AAEpB,QAAI,kBAAkB,SAAS;AAC3B,YAAM,WAAW,KAAK,SAAS,MAAM;AAErC,UAAK,YAAY,UAAY,CAAC,YAAY,CAAC,QAAS;AAChD,eAAO,CAAC,MAAM;AAAA,MAClB;AAAA,IACJ,WAAW,OAAO,WAAW,UAAU;AACnC,aAAO,KAAK,YAAY,QAAQ,MAAM;AAAA,IAC1C;AAEA,WAAO,CAAC;AAAA,EACZ;AAAA,EAEU,YAAY,QAAgB,SAAkB,OAAkB;AACtE,QAAI;AACA,UAAI,OAAO,WAAW,GAAG,GAAG;AACxB,eAAO,KAAK,WAAW,QAAQ,MAAM;AAAA,MACzC;AAEA,aAAO,KAAK,cAAc,QAAQ,MAAM;AAAA,IAC5C,SAAS,GAAG;AACR,cAAQ,MAAM,uEAAuE,CAAC;AAEtF,aAAO,CAAC;AAAA,IACZ;AAAA,EACJ;AAAA,EAEU,cAAc,UAAkB,UAAmB,OAAkB;AAC3E,WAAO,MAAM,KAAK,SAAS,iBAAiB,QAAQ,CAAC;AAAA,EACzD;AAAA,EAEU,WAAW,OAAe,UAAmB,OAAkB;AACrE,UAAM,WAAsB,CAAC;AAE7B,UAAM,SAAS,SAAS,SAAS,OAAO,UAAU,MAAM,YAAY,4BAA4B,IAAI;AAEpG,aAAS,IAAI,GAAG,IAAI,OAAO,gBAAgB,KAAK;AAC5C,eAAS,KAAK,OAAO,aAAa,CAAC,CAAY;AAAA,IACnD;AAEA,WAAO;AAAA,EACX;AAAA,EAEU,aAAa,OAA+C;AAClE,WAAO,CAAC,yBAAyB,WAAW,yBAAyB,OAAO,EAAE,SAAS,KAAK;AAAA,EAChG;AACJ;","names":[]}
|
|
@@ -2,7 +2,8 @@ import React__default, { PropsWithChildren } from 'react';
|
|
|
2
2
|
|
|
3
3
|
interface LocaleProviderProps {
|
|
4
4
|
storage?: string | false;
|
|
5
|
+
container?: string | Element | false;
|
|
5
6
|
}
|
|
6
|
-
declare const LocaleProvider: ({ children, storage }: PropsWithChildren<LocaleProviderProps>) => React__default.JSX.Element;
|
|
7
|
+
declare const LocaleProvider: ({ children, storage, container }: PropsWithChildren<LocaleProviderProps>) => React__default.JSX.Element;
|
|
7
8
|
|
|
8
9
|
export { type LocaleProviderProps, LocaleProvider as default };
|
|
@@ -2,7 +2,7 @@ import React, { useCallback, useEffect, useMemo, useState } from "react";
|
|
|
2
2
|
import { LocaleContext } from "./context.js";
|
|
3
3
|
import { getLocaleDir, isLocaleRtl } from "./../../../locale/utils.js";
|
|
4
4
|
import { DynamicLocale } from "./../../../locale/providers/index.js";
|
|
5
|
-
const LocaleProvider = ({ children, storage }) => {
|
|
5
|
+
const LocaleProvider = ({ children, storage, container = "html" }) => {
|
|
6
6
|
const locale = useMemo(() => new DynamicLocale(storage), []);
|
|
7
7
|
const [lang, setLang] = useState(locale.lang());
|
|
8
8
|
const _ = useCallback((key, substitutions) => {
|
|
@@ -12,13 +12,22 @@ const LocaleProvider = ({ children, storage }) => {
|
|
|
12
12
|
return locale.choice(key, count, substitutions);
|
|
13
13
|
}, []);
|
|
14
14
|
const change = useCallback((lang2) => {
|
|
15
|
-
locale.change(lang2).catch((err) => console.error(`Cannot find locale file for "${lang2}" language`, err));
|
|
15
|
+
locale.change(lang2).catch((err) => console.error(`[LocaleProvider] Cannot find locale file for "${lang2}" language`, err));
|
|
16
16
|
}, []);
|
|
17
17
|
useEffect(() => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
if (container === false) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const element = typeof container === "string" ? document.querySelector(container) : container;
|
|
22
|
+
if (element) {
|
|
23
|
+
element.setAttribute("lang", lang);
|
|
24
|
+
element.setAttribute("dir", getLocaleDir(lang));
|
|
25
|
+
return () => {
|
|
26
|
+
element.removeAttribute("lang");
|
|
27
|
+
element.removeAttribute("dir");
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}, [lang, container]);
|
|
22
31
|
useEffect(() => {
|
|
23
32
|
locale.sync().then((lang2) => setLang(lang2));
|
|
24
33
|
}, []);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/locale/adapters/react/LocaleProvider.tsx"],"sourcesContent":["import React, {PropsWithChildren, useCallback, useEffect, useMemo, useState} from \"react\";\n\nimport {LocaleContext, LocaleContract} from \"./context\";\n\nimport {getLocaleDir, isLocaleRtl} from \"@locale/utils\";\n\nimport {DynamicLocale} from \"@locale/providers\";\n\nimport {Language} from \"@typing/locale\";\n\nexport interface LocaleProviderProps {\n storage?: string | false;\n}\n\nconst LocaleProvider = ({children, storage}: PropsWithChildren<LocaleProviderProps>) => {\n const locale = useMemo(() => new DynamicLocale(storage), []);\n\n const [lang, setLang] = useState<Language>(locale.lang());\n\n const _: LocaleContract[\"_\"] = useCallback((key, substitutions): string => {\n return locale.trans(key, substitutions);\n }, []);\n\n const choice: LocaleContract[\"choice\"] = useCallback((key, count, substitutions): string => {\n return locale.choice(key, count, substitutions);\n }, []);\n\n const change: LocaleContract[\"change\"] = useCallback((lang): void => {\n locale.change(lang).catch(err => console.error(`Cannot find locale file for \"${lang}\" language`, err));\n }, []);\n\n useEffect(() => {\n const
|
|
1
|
+
{"version":3,"sources":["../../../../src/locale/adapters/react/LocaleProvider.tsx"],"sourcesContent":["import React, {PropsWithChildren, useCallback, useEffect, useMemo, useState} from \"react\";\n\nimport {LocaleContext, LocaleContract} from \"./context\";\n\nimport {getLocaleDir, isLocaleRtl} from \"@locale/utils\";\n\nimport {DynamicLocale} from \"@locale/providers\";\n\nimport {Language} from \"@typing/locale\";\n\nexport interface LocaleProviderProps {\n storage?: string | false;\n container?: string | Element | false;\n}\n\nconst LocaleProvider = ({children, storage, container = \"html\"}: PropsWithChildren<LocaleProviderProps>) => {\n const locale = useMemo(() => new DynamicLocale(storage), []);\n\n const [lang, setLang] = useState<Language>(locale.lang());\n\n const _: LocaleContract[\"_\"] = useCallback((key, substitutions): string => {\n return locale.trans(key, substitutions);\n }, []);\n\n const choice: LocaleContract[\"choice\"] = useCallback((key, count, substitutions): string => {\n return locale.choice(key, count, substitutions);\n }, []);\n\n const change: LocaleContract[\"change\"] = useCallback((lang): void => {\n locale\n .change(lang)\n .catch(err => console.error(`[LocaleProvider] Cannot find locale file for \"${lang}\" language`, err));\n }, []);\n\n useEffect(() => {\n if (container === false) {\n return;\n }\n\n const element = typeof container === \"string\" ? document.querySelector(container) : container;\n\n if (element) {\n element.setAttribute(\"lang\", lang);\n element.setAttribute(\"dir\", getLocaleDir(lang));\n\n return () => {\n element.removeAttribute(\"lang\");\n element.removeAttribute(\"dir\");\n };\n }\n }, [lang, container]);\n\n useEffect(() => {\n locale.sync().then(lang => setLang(lang));\n }, []);\n\n useEffect(() => {\n return locale.watch(lang => setLang(lang));\n }, []);\n\n return (\n <LocaleContext.Provider\n value={{\n _,\n choice,\n change,\n lang,\n dir: getLocaleDir(lang),\n isRtl: isLocaleRtl(lang),\n }}\n >\n {children}\n </LocaleContext.Provider>\n );\n};\n\nexport default LocaleProvider;\n"],"mappings":"AAAA,OAAO,SAA2B,aAAa,WAAW,SAAS,gBAAe;AAElF,SAAQ,qBAAoC;AAE5C,SAAQ,cAAc,mBAAkB;AAExC,SAAQ,qBAAoB;AAS5B,MAAM,iBAAiB,CAAC,EAAC,UAAU,SAAS,YAAY,OAAM,MAA8C;AACxG,QAAM,SAAS,QAAQ,MAAM,IAAI,cAAc,OAAO,GAAG,CAAC,CAAC;AAE3D,QAAM,CAAC,MAAM,OAAO,IAAI,SAAmB,OAAO,KAAK,CAAC;AAExD,QAAM,IAAyB,YAAY,CAAC,KAAK,kBAA0B;AACvE,WAAO,OAAO,MAAM,KAAK,aAAa;AAAA,EAC1C,GAAG,CAAC,CAAC;AAEL,QAAM,SAAmC,YAAY,CAAC,KAAK,OAAO,kBAA0B;AACxF,WAAO,OAAO,OAAO,KAAK,OAAO,aAAa;AAAA,EAClD,GAAG,CAAC,CAAC;AAEL,QAAM,SAAmC,YAAY,CAACA,UAAe;AACjE,WACK,OAAOA,KAAI,EACX,MAAM,SAAO,QAAQ,MAAM,iDAAiDA,KAAI,cAAc,GAAG,CAAC;AAAA,EAC3G,GAAG,CAAC,CAAC;AAEL,YAAU,MAAM;AACZ,QAAI,cAAc,OAAO;AACrB;AAAA,IACJ;AAEA,UAAM,UAAU,OAAO,cAAc,WAAW,SAAS,cAAc,SAAS,IAAI;AAEpF,QAAI,SAAS;AACT,cAAQ,aAAa,QAAQ,IAAI;AACjC,cAAQ,aAAa,OAAO,aAAa,IAAI,CAAC;AAE9C,aAAO,MAAM;AACT,gBAAQ,gBAAgB,MAAM;AAC9B,gBAAQ,gBAAgB,KAAK;AAAA,MACjC;AAAA,IACJ;AAAA,EACJ,GAAG,CAAC,MAAM,SAAS,CAAC;AAEpB,YAAU,MAAM;AACZ,WAAO,KAAK,EAAE,KAAK,CAAAA,UAAQ,QAAQA,KAAI,CAAC;AAAA,EAC5C,GAAG,CAAC,CAAC;AAEL,YAAU,MAAM;AACZ,WAAO,OAAO,MAAM,CAAAA,UAAQ,QAAQA,KAAI,CAAC;AAAA,EAC7C,GAAG,CAAC,CAAC;AAEL,SACI;AAAA,IAAC,cAAc;AAAA,IAAd;AAAA,MACG,OAAO;AAAA,QACH;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,KAAK,aAAa,IAAI;AAAA,QACtB,OAAO,YAAY,IAAI;AAAA,MAC3B;AAAA;AAAA,IAEC;AAAA,EACL;AAER;AAEA,IAAO,yBAAQ;","names":["lang"]}
|
|
@@ -6,6 +6,8 @@ interface LocaleNativeStructure extends LocaleStructure {
|
|
|
6
6
|
declare class NativeLocale extends export_default<LocaleNativeStructure> {
|
|
7
7
|
private static instance?;
|
|
8
8
|
static getInstance<S extends LocaleStructure = LocaleNativeStructure>(): LocaleProvider<S>;
|
|
9
|
+
private readonly language?;
|
|
10
|
+
constructor();
|
|
9
11
|
lang(): Language;
|
|
10
12
|
keys(): Set<keyof LocaleNativeStructure>;
|
|
11
13
|
languages(): Set<Language>;
|
|
@@ -1,33 +1,36 @@
|
|
|
1
|
-
import { getI18nMessage
|
|
1
|
+
import { getI18nMessage } from "@addon-core/browser";
|
|
2
2
|
import AbstractLocale from "./AbstractLocale.js";
|
|
3
|
-
import { convertLocaleKey } from "./../../locale/utils.js";
|
|
4
|
-
import {
|
|
5
|
-
import { LanguageCodes, LocaleCustomKeyForLanguage } from "./../../types/locale.js";
|
|
6
|
-
import { Browser } from "./../../types/browser.js";
|
|
3
|
+
import { convertLocaleKey, resolveLanguage } from "./../../locale/utils.js";
|
|
4
|
+
import { LocaleCustomKeyForLanguage } from "./../../types/locale.js";
|
|
7
5
|
class NativeLocale extends AbstractLocale {
|
|
8
6
|
static instance;
|
|
9
7
|
static getInstance() {
|
|
10
8
|
return NativeLocale.instance ?? (NativeLocale.instance = new NativeLocale());
|
|
11
9
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
10
|
+
language;
|
|
11
|
+
constructor() {
|
|
12
|
+
super();
|
|
13
|
+
const markerLang = getI18nMessage(LocaleCustomKeyForLanguage);
|
|
14
|
+
const resolvedLang = resolveLanguage(markerLang);
|
|
15
|
+
if (!resolvedLang) {
|
|
16
|
+
console.warn(`[NativeLocale] Unsupported language detected: "${markerLang}".`);
|
|
17
|
+
}
|
|
18
|
+
if (markerLang && resolvedLang && markerLang !== resolvedLang) {
|
|
19
|
+
console.info(`[NativeLocale] Language normalized: using "${resolvedLang}" instead of "${markerLang}".`);
|
|
19
20
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
this.language = resolvedLang;
|
|
22
|
+
}
|
|
23
|
+
lang() {
|
|
24
|
+
if (!this.language) {
|
|
25
|
+
throw new Error("[NativeLocale] Language is not defined. Failed to determine a supported locale.");
|
|
23
26
|
}
|
|
24
|
-
return
|
|
27
|
+
return this.language;
|
|
25
28
|
}
|
|
26
29
|
keys() {
|
|
27
30
|
try {
|
|
28
31
|
return new Set(__ADNBN_LOCALE_KEYS__);
|
|
29
32
|
} catch (e) {
|
|
30
|
-
console.error("
|
|
33
|
+
console.error("[NativeLocale] Failed to access locale keys. Ensure the bundler plugin is active.", e);
|
|
31
34
|
return /* @__PURE__ */ new Set();
|
|
32
35
|
}
|
|
33
36
|
}
|
|
@@ -35,7 +38,7 @@ class NativeLocale extends AbstractLocale {
|
|
|
35
38
|
try {
|
|
36
39
|
return new Set(__ADNBN_DEFINED_LOCALES__);
|
|
37
40
|
} catch (e) {
|
|
38
|
-
console.error("
|
|
41
|
+
console.error("[NativeLocale] Failed to access defined locales. Check virtual variables configuration.", e);
|
|
39
42
|
return /* @__PURE__ */ new Set();
|
|
40
43
|
}
|
|
41
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/locale/providers/NativeLocale.ts"],"sourcesContent":["import {getI18nMessage
|
|
1
|
+
{"version":3,"sources":["../../../src/locale/providers/NativeLocale.ts"],"sourcesContent":["import {getI18nMessage} from \"@addon-core/browser\";\n\nimport AbstractLocale from \"./AbstractLocale\";\n\nimport {convertLocaleKey, resolveLanguage} from \"@locale/utils\";\n\nimport {Language, LocaleCustomKeyForLanguage, LocaleProvider, LocaleStructure} from \"@typing/locale\";\n\nexport interface LocaleNativeStructure extends LocaleStructure {}\n\nexport default class NativeLocale extends AbstractLocale<LocaleNativeStructure> {\n private static instance?: LocaleProvider<LocaleNativeStructure>;\n\n public static getInstance<S extends LocaleStructure = LocaleNativeStructure>(): LocaleProvider<S> {\n return (NativeLocale.instance ??= new NativeLocale());\n }\n\n private readonly language?: Language;\n\n constructor() {\n super();\n\n /**\n Locale detection note:\n Chrome does NOT expose an API to get the effective translation locale.\n getUILanguage() returns browser UI language (e.g., es-MX),\n even if extension translations fall back to default_locale (e.g., en).\n To detect the actual language used by i18n, we read a locale marker\n from messages.json via chrome.i18n.getMessage().\n */\n const markerLang = getI18nMessage(LocaleCustomKeyForLanguage);\n const resolvedLang = resolveLanguage(markerLang);\n\n if (!resolvedLang) {\n console.warn(`[NativeLocale] Unsupported language detected: \"${markerLang}\".`);\n }\n\n if (markerLang && resolvedLang && markerLang !== resolvedLang) {\n console.info(`[NativeLocale] Language normalized: using \"${resolvedLang}\" instead of \"${markerLang}\".`);\n }\n\n this.language = resolvedLang;\n }\n\n public lang(): Language {\n if (!this.language) {\n throw new Error(\"[NativeLocale] Language is not defined. Failed to determine a supported locale.\");\n }\n\n return this.language;\n }\n\n public keys(): Set<keyof LocaleNativeStructure> {\n try {\n // @ts-expect-error: __ADNBN_LOCALE_KEYS__ is a virtual variable generated by the bundler `src/cli/plugins/locale/index.ts`\n return new Set<string>(__ADNBN_LOCALE_KEYS__);\n } catch (e) {\n console.error(\"[NativeLocale] Failed to access locale keys. Ensure the bundler plugin is active.\", e);\n\n return new Set<string>();\n }\n }\n\n public languages(): Set<Language> {\n try {\n // @ts-expect-error: __ADNBN_DEFINED_LOCALES__ is a virtual variable generated by the bundler `src/cli/plugins/locale/index.ts`\n return new Set<Language>(__ADNBN_DEFINED_LOCALES__);\n } catch (e) {\n console.error(\"[NativeLocale] Failed to access defined locales. Check virtual variables configuration.\", e);\n\n return new Set<Language>();\n }\n }\n\n protected value(key: Extract<keyof LocaleNativeStructure, string>): string | undefined {\n const value = getI18nMessage(convertLocaleKey(key));\n\n if (!value || value.length === 0) {\n return undefined;\n }\n\n return value;\n }\n}\n"],"mappings":"AAAA,SAAQ,sBAAqB;AAE7B,OAAO,oBAAoB;AAE3B,SAAQ,kBAAkB,uBAAsB;AAEhD,SAAkB,kCAAkE;AAIpF,MAAO,qBAAmC,eAAsC;AAAA,EAC5E,OAAe;AAAA,EAEf,OAAc,cAAoF;AAC9F,WAAQ,aAAa,aAAb,aAAa,WAAa,IAAI,aAAa;AAAA,EACvD;AAAA,EAEiB;AAAA,EAEjB,cAAc;AACV,UAAM;AAUN,UAAM,aAAa,eAAe,0BAA0B;AAC5D,UAAM,eAAe,gBAAgB,UAAU;AAE/C,QAAI,CAAC,cAAc;AACf,cAAQ,KAAK,kDAAkD,UAAU,IAAI;AAAA,IACjF;AAEA,QAAI,cAAc,gBAAgB,eAAe,cAAc;AAC3D,cAAQ,KAAK,8CAA8C,YAAY,iBAAiB,UAAU,IAAI;AAAA,IAC1G;AAEA,SAAK,WAAW;AAAA,EACpB;AAAA,EAEO,OAAiB;AACpB,QAAI,CAAC,KAAK,UAAU;AAChB,YAAM,IAAI,MAAM,iFAAiF;AAAA,IACrG;AAEA,WAAO,KAAK;AAAA,EAChB;AAAA,EAEO,OAAyC;AAC5C,QAAI;AAEA,aAAO,IAAI,IAAY,qBAAqB;AAAA,IAChD,SAAS,GAAG;AACR,cAAQ,MAAM,qFAAqF,CAAC;AAEpG,aAAO,oBAAI,IAAY;AAAA,IAC3B;AAAA,EACJ;AAAA,EAEO,YAA2B;AAC9B,QAAI;AAEA,aAAO,IAAI,IAAc,yBAAyB;AAAA,IACtD,SAAS,GAAG;AACR,cAAQ,MAAM,2FAA2F,CAAC;AAE1G,aAAO,oBAAI,IAAc;AAAA,IAC7B;AAAA,EACJ;AAAA,EAEU,MAAM,KAAuE;AACnF,UAAM,QAAQ,eAAe,iBAAiB,GAAG,CAAC;AAElD,QAAI,CAAC,SAAS,MAAM,WAAW,GAAG;AAC9B,aAAO;AAAA,IACX;AAEA,WAAO;AAAA,EACX;AACJ;","names":[]}
|
package/dist/locale/utils.d.ts
CHANGED
|
@@ -9,5 +9,6 @@ declare const modifyLocaleMessageKey: (key?: string) => string | undefined;
|
|
|
9
9
|
declare const isLocaleRtl: (lang: Language) => boolean;
|
|
10
10
|
declare const getLocaleDir: (lang: Language) => LocaleDir;
|
|
11
11
|
declare const flattenLocaleMessages: (messages: LocaleMessages) => Record<string, string>;
|
|
12
|
+
declare const resolveLanguage: (language?: string) => Language | undefined;
|
|
12
13
|
|
|
13
|
-
export { convertLocaleKey, convertLocaleMessageKey, extractLocaleKey, flattenLocaleMessages, getLocaleDir, getLocaleFilename, isLocaleKey, isLocaleRtl, modifyLocaleMessageKey };
|
|
14
|
+
export { convertLocaleKey, convertLocaleMessageKey, extractLocaleKey, flattenLocaleMessages, getLocaleDir, getLocaleFilename, isLocaleKey, isLocaleRtl, modifyLocaleMessageKey, resolveLanguage };
|
package/dist/locale/utils.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
LanguageCodes,
|
|
2
3
|
LocaleDir,
|
|
3
4
|
LocaleKeyMarker,
|
|
4
5
|
LocaleKeysSeparator,
|
|
@@ -41,6 +42,16 @@ const getLocaleDir = (lang) => {
|
|
|
41
42
|
const flattenLocaleMessages = (messages) => {
|
|
42
43
|
return Object.fromEntries(Object.entries(messages).map(([key, value]) => [key, value.message]));
|
|
43
44
|
};
|
|
45
|
+
const resolveLanguage = (language) => {
|
|
46
|
+
if (!language) {
|
|
47
|
+
return void 0;
|
|
48
|
+
}
|
|
49
|
+
if (LanguageCodes.has(language)) {
|
|
50
|
+
return language;
|
|
51
|
+
}
|
|
52
|
+
const shortLang = language.slice(0, 2);
|
|
53
|
+
return LanguageCodes.has(shortLang) ? shortLang : void 0;
|
|
54
|
+
};
|
|
44
55
|
export {
|
|
45
56
|
convertLocaleKey,
|
|
46
57
|
convertLocaleMessageKey,
|
|
@@ -50,6 +61,7 @@ export {
|
|
|
50
61
|
getLocaleFilename,
|
|
51
62
|
isLocaleKey,
|
|
52
63
|
isLocaleRtl,
|
|
53
|
-
modifyLocaleMessageKey
|
|
64
|
+
modifyLocaleMessageKey,
|
|
65
|
+
resolveLanguage
|
|
54
66
|
};
|
|
55
67
|
//# sourceMappingURL=utils.js.map
|
package/dist/locale/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/locale/utils.ts"],"sourcesContent":["import {\n Language,\n LocaleDir,\n LocaleKeyMarker,\n LocaleKeysSeparator,\n LocaleMessages,\n LocaleNestedKeysSeparator,\n RtlLanguages,\n} from \"@typing/locale\";\n\nexport const getLocaleFilename = (lang: Language): string => {\n return `_locales/${lang}/messages.json`;\n};\n\nexport const convertLocaleKey = (key: string): string => {\n return key.replaceAll(LocaleNestedKeysSeparator, LocaleKeysSeparator);\n};\n\nexport const convertLocaleMessageKey = (key: string): string => {\n return `__MSG_${convertLocaleKey(key)}__`;\n};\n\nexport const extractLocaleKey = (key?: string): string | undefined => {\n if (isLocaleKey(key)) {\n return key.substring(1);\n }\n};\n\nexport const isLocaleKey = (key?: string): key is string => {\n return key?.startsWith(LocaleKeyMarker) ?? false;\n};\n\nexport const modifyLocaleMessageKey = (key?: string): string | undefined => {\n if (typeof key !== \"string\") {\n return undefined;\n }\n\n const localeKey = extractLocaleKey(key);\n\n if (localeKey) {\n return convertLocaleMessageKey(localeKey);\n }\n\n return key;\n};\n\nexport const isLocaleRtl = (lang: Language): boolean => {\n return RtlLanguages.has(lang);\n};\n\nexport const getLocaleDir = (lang: Language): LocaleDir => {\n return isLocaleRtl(lang) ? LocaleDir.RightToLeft : LocaleDir.LeftToRight;\n};\n\nexport const flattenLocaleMessages = (messages: LocaleMessages): Record<string, string> => {\n return Object.fromEntries(Object.entries(messages).map(([key, value]) => [key, value.message]));\n};\n"],"mappings":"AAAA;AAAA,EAEI;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,OACG;AAEA,MAAM,oBAAoB,CAAC,SAA2B;AACzD,SAAO,YAAY,IAAI;AAC3B;AAEO,MAAM,mBAAmB,CAAC,QAAwB;AACrD,SAAO,IAAI,WAAW,2BAA2B,mBAAmB;AACxE;AAEO,MAAM,0BAA0B,CAAC,QAAwB;AAC5D,SAAO,SAAS,iBAAiB,GAAG,CAAC;AACzC;AAEO,MAAM,mBAAmB,CAAC,QAAqC;AAClE,MAAI,YAAY,GAAG,GAAG;AAClB,WAAO,IAAI,UAAU,CAAC;AAAA,EAC1B;AACJ;AAEO,MAAM,cAAc,CAAC,QAAgC;AACxD,UAAO,2BAAK,WAAW,qBAAoB;AAC/C;AAEO,MAAM,yBAAyB,CAAC,QAAqC;AACxE,MAAI,OAAO,QAAQ,UAAU;AACzB,WAAO;AAAA,EACX;AAEA,QAAM,YAAY,iBAAiB,GAAG;AAEtC,MAAI,WAAW;AACX,WAAO,wBAAwB,SAAS;AAAA,EAC5C;AAEA,SAAO;AACX;AAEO,MAAM,cAAc,CAAC,SAA4B;AACpD,SAAO,aAAa,IAAI,IAAI;AAChC;AAEO,MAAM,eAAe,CAAC,SAA8B;AACvD,SAAO,YAAY,IAAI,IAAI,UAAU,cAAc,UAAU;AACjE;AAEO,MAAM,wBAAwB,CAAC,aAAqD;AACvF,SAAO,OAAO,YAAY,OAAO,QAAQ,QAAQ,EAAE,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM,CAAC,KAAK,MAAM,OAAO,CAAC,CAAC;AAClG;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/locale/utils.ts"],"sourcesContent":["import {\n Language,\n LanguageCodes,\n LocaleDir,\n LocaleKeyMarker,\n LocaleKeysSeparator,\n LocaleMessages,\n LocaleNestedKeysSeparator,\n RtlLanguages,\n} from \"@typing/locale\";\n\nexport const getLocaleFilename = (lang: Language): string => {\n return `_locales/${lang}/messages.json`;\n};\n\nexport const convertLocaleKey = (key: string): string => {\n return key.replaceAll(LocaleNestedKeysSeparator, LocaleKeysSeparator);\n};\n\nexport const convertLocaleMessageKey = (key: string): string => {\n return `__MSG_${convertLocaleKey(key)}__`;\n};\n\nexport const extractLocaleKey = (key?: string): string | undefined => {\n if (isLocaleKey(key)) {\n return key.substring(1);\n }\n};\n\nexport const isLocaleKey = (key?: string): key is string => {\n return key?.startsWith(LocaleKeyMarker) ?? false;\n};\n\nexport const modifyLocaleMessageKey = (key?: string): string | undefined => {\n if (typeof key !== \"string\") {\n return undefined;\n }\n\n const localeKey = extractLocaleKey(key);\n\n if (localeKey) {\n return convertLocaleMessageKey(localeKey);\n }\n\n return key;\n};\n\nexport const isLocaleRtl = (lang: Language): boolean => {\n return RtlLanguages.has(lang);\n};\n\nexport const getLocaleDir = (lang: Language): LocaleDir => {\n return isLocaleRtl(lang) ? LocaleDir.RightToLeft : LocaleDir.LeftToRight;\n};\n\nexport const flattenLocaleMessages = (messages: LocaleMessages): Record<string, string> => {\n return Object.fromEntries(Object.entries(messages).map(([key, value]) => [key, value.message]));\n};\n\nexport const resolveLanguage = (language?: string): Language | undefined => {\n if (!language) {\n return undefined;\n }\n\n if (LanguageCodes.has(language as Language)) {\n return language as Language;\n }\n\n const shortLang = language.slice(0, 2) as Language;\n\n return LanguageCodes.has(shortLang) ? shortLang : undefined;\n};\n"],"mappings":"AAAA;AAAA,EAEI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,OACG;AAEA,MAAM,oBAAoB,CAAC,SAA2B;AACzD,SAAO,YAAY,IAAI;AAC3B;AAEO,MAAM,mBAAmB,CAAC,QAAwB;AACrD,SAAO,IAAI,WAAW,2BAA2B,mBAAmB;AACxE;AAEO,MAAM,0BAA0B,CAAC,QAAwB;AAC5D,SAAO,SAAS,iBAAiB,GAAG,CAAC;AACzC;AAEO,MAAM,mBAAmB,CAAC,QAAqC;AAClE,MAAI,YAAY,GAAG,GAAG;AAClB,WAAO,IAAI,UAAU,CAAC;AAAA,EAC1B;AACJ;AAEO,MAAM,cAAc,CAAC,QAAgC;AACxD,UAAO,2BAAK,WAAW,qBAAoB;AAC/C;AAEO,MAAM,yBAAyB,CAAC,QAAqC;AACxE,MAAI,OAAO,QAAQ,UAAU;AACzB,WAAO;AAAA,EACX;AAEA,QAAM,YAAY,iBAAiB,GAAG;AAEtC,MAAI,WAAW;AACX,WAAO,wBAAwB,SAAS;AAAA,EAC5C;AAEA,SAAO;AACX;AAEO,MAAM,cAAc,CAAC,SAA4B;AACpD,SAAO,aAAa,IAAI,IAAI;AAChC;AAEO,MAAM,eAAe,CAAC,SAA8B;AACvD,SAAO,YAAY,IAAI,IAAI,UAAU,cAAc,UAAU;AACjE;AAEO,MAAM,wBAAwB,CAAC,aAAqD;AACvF,SAAO,OAAO,YAAY,OAAO,QAAQ,QAAQ,EAAE,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM,CAAC,KAAK,MAAM,OAAO,CAAC,CAAC;AAClG;AAEO,MAAM,kBAAkB,CAAC,aAA4C;AACxE,MAAI,CAAC,UAAU;AACX,WAAO;AAAA,EACX;AAEA,MAAI,cAAc,IAAI,QAAoB,GAAG;AACzC,WAAO;AAAA,EACX;AAEA,QAAM,YAAY,SAAS,MAAM,GAAG,CAAC;AAErC,SAAO,cAAc,IAAI,SAAS,IAAI,YAAY;AACtD;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/message/providers/AbstractMessage.ts"],"sourcesContent":["import {nanoid} from \"nanoid\";\nimport {\n MessageBody,\n MessageData,\n MessageDictionary,\n MessageGeneralHandler,\n MessageMapHandler,\n MessageProvider,\n MessageResponse,\n MessageTargetHandler,\n MessageType,\n} from \"@typing/message\";\n\nexport default abstract class AbstractMessage<T extends MessageDictionary, TOptions
|
|
1
|
+
{"version":3,"sources":["../../../src/message/providers/AbstractMessage.ts"],"sourcesContent":["import {nanoid} from \"nanoid\";\nimport {\n MessageBody,\n MessageData,\n MessageDictionary,\n MessageGeneralHandler,\n MessageMapHandler,\n MessageProvider,\n MessageResponse,\n MessageTargetHandler,\n MessageType,\n} from \"@typing/message\";\n\nexport default abstract class AbstractMessage<T extends MessageDictionary, TOptions> implements MessageProvider<\n T,\n TOptions\n> {\n public abstract send<K extends MessageType<T>>(\n type: K,\n data: MessageData<T, K>,\n options?: TOptions\n ): Promise<MessageResponse<T, K>>;\n\n public abstract watch<K extends MessageType<T>>(type: K, handler: MessageTargetHandler<T, K>): () => void;\n\n public abstract watch(map: MessageMapHandler<T>): () => void;\n\n public abstract watch<K extends MessageType<T>>(general: MessageGeneralHandler<T, K>): () => void;\n\n protected buildMessage<K extends MessageType<T>>(type: K, data: MessageData<T, K>): MessageBody<T, K> {\n return {\n id: nanoid(),\n type,\n data,\n timestamp: Date.now(),\n };\n }\n}\n"],"mappings":"AAAA,SAAQ,cAAa;AAarB,MAAO,gBAGL;AAAA,EAaY,aAAuC,MAAS,MAA4C;AAClG,WAAO;AAAA,MACH,IAAI,OAAO;AAAA,MACX;AAAA,MACA;AAAA,MACA,WAAW,KAAK,IAAI;AAAA,IACxB;AAAA,EACJ;AACJ;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/offscreen.ts"],"sourcesContent":["import {TransportConfig, TransportDefinition, TransportType} from \"@typing/transport\";\nimport {ViewOptions} from \"@typing/view\";\nimport {Awaiter} from \"@typing/helpers\";\n\nexport const OffscreenGlobalKey = \"adnbnOffscreen\";\nexport const OffscreenGlobalAccess = \"adnbnOffscreenAccess\";\n\nexport enum OffscreenReason {\n /** A reason used for testing purposes only. */\n Testing = \"TESTING\",\n /** The offscreen document is responsible for playing audio. */\n AudioPlayback = \"AUDIO_PLAYBACK\",\n /** The offscreen document needs to embed and script an iframe in order to modify the iframe's content. */\n IframeScripting = \"IFRAME_SCRIPTING\",\n /** The offscreen document needs to embed an iframe and scrape its DOM to extract information. */\n DOMScraping = \"DOM_SCRAPING\",\n /** The offscreen document needs to interact with Blob objects (including URL.createObjectURL()). */\n Blobs = \"BLOBS\",\n /** The offscreen document needs to use the DOMParser API. */\n DOMParser = \"DOM_PARSER\",\n /** The offscreen document needs to interact with media streams from user media (e.g. getUserMedia()). */\n UserMedia = \"USER_MEDIA\",\n /** The offscreen document needs to interact with media streams from display media (e.g. getDisplayMedia()). */\n DisplayMedia = \"DISPLAY_MEDIA\",\n /** The offscreen document needs to use WebRTC APIs. */\n WebRTC = \"WEB_RTC\",\n /** The offscreen document needs to interact with the clipboard APIs(e.g. Navigator.clipboard). */\n Clipboard = \"CLIPBOARD\",\n /** Specifies that the offscreen document needs access to localStorage. */\n LocalStorage = \"LOCAL_STORAGE\",\n /** Specifies that the offscreen document needs to spawn workers. */\n Workers = \"WORKERS\",\n /** Specifies that the offscreen document needs to use navigator.getBattery. */\n BatteryStatus = \"BATTERY_STATUS\",\n /** Specifies that the offscreen document needs to use window.matchMedia. */\n MatchMedia = \"MATCH_MEDIA\",\n /** Specifies that the offscreen document needs to use navigator.geolocation. */\n Geolocation = \"GEOLOCATION\",\n}\n\nexport interface OffscreenConfig extends TransportConfig {\n reasons?: `${OffscreenReason}` | `${OffscreenReason}`[] | OffscreenReason | OffscreenReason[];\n justification?: string;\n}\n\nexport type OffscreenOptions = OffscreenConfig & ViewOptions;\n\nexport type OffscreenEntrypointOptions = Partial<OffscreenOptions>;\n\nexport type OffscreenMainHandler<T extends TransportType> = (\n offscreen: T,\n options: OffscreenEntrypointOptions\n) => Awaiter<void>;\n\nexport interface OffscreenDefinition<T extends TransportType>\n extends TransportDefinition<OffscreenOptions, T
|
|
1
|
+
{"version":3,"sources":["../../src/types/offscreen.ts"],"sourcesContent":["import {TransportConfig, TransportDefinition, TransportType} from \"@typing/transport\";\nimport {ViewOptions} from \"@typing/view\";\nimport {Awaiter} from \"@typing/helpers\";\n\nexport const OffscreenGlobalKey = \"adnbnOffscreen\";\nexport const OffscreenGlobalAccess = \"adnbnOffscreenAccess\";\n\nexport enum OffscreenReason {\n /** A reason used for testing purposes only. */\n Testing = \"TESTING\",\n /** The offscreen document is responsible for playing audio. */\n AudioPlayback = \"AUDIO_PLAYBACK\",\n /** The offscreen document needs to embed and script an iframe in order to modify the iframe's content. */\n IframeScripting = \"IFRAME_SCRIPTING\",\n /** The offscreen document needs to embed an iframe and scrape its DOM to extract information. */\n DOMScraping = \"DOM_SCRAPING\",\n /** The offscreen document needs to interact with Blob objects (including URL.createObjectURL()). */\n Blobs = \"BLOBS\",\n /** The offscreen document needs to use the DOMParser API. */\n DOMParser = \"DOM_PARSER\",\n /** The offscreen document needs to interact with media streams from user media (e.g. getUserMedia()). */\n UserMedia = \"USER_MEDIA\",\n /** The offscreen document needs to interact with media streams from display media (e.g. getDisplayMedia()). */\n DisplayMedia = \"DISPLAY_MEDIA\",\n /** The offscreen document needs to use WebRTC APIs. */\n WebRTC = \"WEB_RTC\",\n /** The offscreen document needs to interact with the clipboard APIs(e.g. Navigator.clipboard). */\n Clipboard = \"CLIPBOARD\",\n /** Specifies that the offscreen document needs access to localStorage. */\n LocalStorage = \"LOCAL_STORAGE\",\n /** Specifies that the offscreen document needs to spawn workers. */\n Workers = \"WORKERS\",\n /** Specifies that the offscreen document needs to use navigator.getBattery. */\n BatteryStatus = \"BATTERY_STATUS\",\n /** Specifies that the offscreen document needs to use window.matchMedia. */\n MatchMedia = \"MATCH_MEDIA\",\n /** Specifies that the offscreen document needs to use navigator.geolocation. */\n Geolocation = \"GEOLOCATION\",\n}\n\nexport interface OffscreenConfig extends TransportConfig {\n reasons?: `${OffscreenReason}` | `${OffscreenReason}`[] | OffscreenReason | OffscreenReason[];\n justification?: string;\n}\n\nexport type OffscreenOptions = OffscreenConfig & ViewOptions;\n\nexport type OffscreenEntrypointOptions = Partial<OffscreenOptions>;\n\nexport type OffscreenMainHandler<T extends TransportType> = (\n offscreen: T,\n options: OffscreenEntrypointOptions\n) => Awaiter<void>;\n\nexport interface OffscreenDefinition<T extends TransportType>\n extends TransportDefinition<OffscreenOptions, T>, OffscreenEntrypointOptions {\n main?: OffscreenMainHandler<T>;\n}\n\nexport type OffscreenUnresolvedDefinition<T extends TransportType> = Partial<OffscreenDefinition<T>>;\n"],"mappings":"AAIO,MAAM,qBAAqB;AAC3B,MAAM,wBAAwB;AAE9B,IAAK,kBAAL,kBAAKA,qBAAL;AAEH,EAAAA,iBAAA,aAAU;AAEV,EAAAA,iBAAA,mBAAgB;AAEhB,EAAAA,iBAAA,qBAAkB;AAElB,EAAAA,iBAAA,iBAAc;AAEd,EAAAA,iBAAA,WAAQ;AAER,EAAAA,iBAAA,eAAY;AAEZ,EAAAA,iBAAA,eAAY;AAEZ,EAAAA,iBAAA,kBAAe;AAEf,EAAAA,iBAAA,YAAS;AAET,EAAAA,iBAAA,eAAY;AAEZ,EAAAA,iBAAA,kBAAe;AAEf,EAAAA,iBAAA,aAAU;AAEV,EAAAA,iBAAA,mBAAgB;AAEhB,EAAAA,iBAAA,gBAAa;AAEb,EAAAA,iBAAA,iBAAc;AA9BN,SAAAA;AAAA,GAAA;","names":["OffscreenReason"]}
|
package/dist/types/relay.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/relay.ts"],"sourcesContent":["import {EntrypointOptions} from \"@typing/entrypoint\";\nimport {ContentScriptConfig, ContentScriptContext, ContentScriptDefinition} from \"@typing/content\";\nimport {TransportConfig, TransportDefinition, TransportType} from \"@typing/transport\";\nimport {Awaiter} from \"@typing/helpers\";\n\nexport const RelayGlobalKey = \"adnbnRelay\";\n\nexport enum RelayMethod {\n Scripting = \"scripting\",\n Messaging = \"messaging\",\n}\n\nexport interface RelayConfig extends TransportConfig, ContentScriptConfig {\n method?: RelayMethod;\n}\n\nexport type RelayOptions = RelayConfig & EntrypointOptions;\n\nexport type RelayOptionsMap = Map<string, RelayOptions>;\n\nexport type RelayEntrypointOptions = Partial<RelayOptions>;\n\nexport type RelayMainHandler<T extends TransportType> = (\n relay: T,\n context: ContentScriptContext,\n options: RelayEntrypointOptions\n) => Awaiter<void>;\n\nexport interface RelayDefinition<T extends TransportType>\n extends
|
|
1
|
+
{"version":3,"sources":["../../src/types/relay.ts"],"sourcesContent":["import {EntrypointOptions} from \"@typing/entrypoint\";\nimport {ContentScriptConfig, ContentScriptContext, ContentScriptDefinition} from \"@typing/content\";\nimport {TransportConfig, TransportDefinition, TransportType} from \"@typing/transport\";\nimport {Awaiter} from \"@typing/helpers\";\n\nexport const RelayGlobalKey = \"adnbnRelay\";\n\nexport enum RelayMethod {\n Scripting = \"scripting\",\n Messaging = \"messaging\",\n}\n\nexport interface RelayConfig extends TransportConfig, ContentScriptConfig {\n method?: RelayMethod;\n}\n\nexport type RelayOptions = RelayConfig & EntrypointOptions;\n\nexport type RelayOptionsMap = Map<string, RelayOptions>;\n\nexport type RelayEntrypointOptions = Partial<RelayOptions>;\n\nexport type RelayMainHandler<T extends TransportType> = (\n relay: T,\n context: ContentScriptContext,\n options: RelayEntrypointOptions\n) => Awaiter<void>;\n\nexport interface RelayDefinition<T extends TransportType>\n extends\n Omit<TransportDefinition<RelayOptions, T>, \"main\">,\n Omit<ContentScriptDefinition, \"main\">,\n RelayEntrypointOptions {\n main?: RelayMainHandler<T>;\n}\n\nexport type RelayUnresolvedDefinition<T extends TransportType> = Partial<RelayDefinition<T>>;\n"],"mappings":"AAKO,MAAM,iBAAiB;AAEvB,IAAK,cAAL,kBAAKA,iBAAL;AACH,EAAAA,aAAA,eAAY;AACZ,EAAAA,aAAA,eAAY;AAFJ,SAAAA;AAAA,GAAA;","names":["RelayMethod"]}
|
package/package.json
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "adnbn",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.5.
|
|
4
|
+
"version": "0.5.4",
|
|
5
5
|
"description": "Addon Bone - Cross-browser web extension framework with shared code base",
|
|
6
6
|
"homepage": "https://addonbone.com",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
|
-
"url": "https://github.com/addon-stack/addon-bone"
|
|
10
|
+
"url": "git+https://github.com/addon-stack/addon-bone.git"
|
|
11
|
+
},
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public",
|
|
14
|
+
"provenance": true
|
|
11
15
|
},
|
|
12
16
|
"bugs": {
|
|
13
17
|
"url": "https://github.com/addon-stack/addon-bone/issues"
|
|
@@ -121,12 +125,12 @@
|
|
|
121
125
|
"@addon-core/browser": "^0.2.1",
|
|
122
126
|
"@addon-core/inject-script": "^0.3.1",
|
|
123
127
|
"@addon-core/storage": "^0.4.0",
|
|
124
|
-
"@rsdoctor/rspack-plugin": "
|
|
125
|
-
"@rspack/cli": "^1.
|
|
126
|
-
"@rspack/core": "^1.
|
|
128
|
+
"@rsdoctor/rspack-plugin": "^1.3.11",
|
|
129
|
+
"@rspack/cli": "^1.6.7",
|
|
130
|
+
"@rspack/core": "^1.6.7",
|
|
127
131
|
"@svgr/webpack": "^8.1.0",
|
|
128
132
|
"await-lock": "^3.0.0",
|
|
129
|
-
"c12": "^3.
|
|
133
|
+
"c12": "^3.3.2",
|
|
130
134
|
"cac": "^6.7.14",
|
|
131
135
|
"consola": "^3.4.2",
|
|
132
136
|
"css-loader": "^7.1.2",
|
|
@@ -134,13 +138,13 @@
|
|
|
134
138
|
"file-loader": "^6.2.0",
|
|
135
139
|
"get-value": "^4.0.1",
|
|
136
140
|
"html-rspack-tags-plugin": "^0.0.3",
|
|
137
|
-
"js-yaml": "^4.1.
|
|
141
|
+
"js-yaml": "^4.1.1",
|
|
138
142
|
"json-stringify-deterministic": "^1.0.12",
|
|
139
143
|
"lodash": "^4.17.21",
|
|
140
144
|
"mini-css-extract-plugin": "^2.9.2",
|
|
141
145
|
"nanoid": "^5.1.4",
|
|
142
146
|
"pluralize": "^8.0.0",
|
|
143
|
-
"rspack-plugin-virtual-module": "^0.1
|
|
147
|
+
"rspack-plugin-virtual-module": "^1.0.1",
|
|
144
148
|
"sass": "^1.83.4",
|
|
145
149
|
"sass-loader": "^16.0.4",
|
|
146
150
|
"semver": "^7.7.3",
|
|
@@ -155,7 +159,7 @@
|
|
|
155
159
|
"@commitlint/cli": "^20.1.0",
|
|
156
160
|
"@commitlint/config-conventional": "^20.0.0",
|
|
157
161
|
"@microsoft/api-extractor": "^7.53.1",
|
|
158
|
-
"@release-it/conventional-changelog": "^10.0.
|
|
162
|
+
"@release-it/conventional-changelog": "^10.0.4",
|
|
159
163
|
"@swc/core": "^1.11.7",
|
|
160
164
|
"@swc/jest": "^0.2.36",
|
|
161
165
|
"@testing-library/jest-dom": "^6.6.3",
|
|
@@ -176,12 +180,12 @@
|
|
|
176
180
|
"fs-extra": "^11.3.0",
|
|
177
181
|
"globby": "^14.1.0",
|
|
178
182
|
"husky": "^9.1.7",
|
|
179
|
-
"jest": "^30.
|
|
183
|
+
"jest": "^30.2.0",
|
|
180
184
|
"jest-environment-jsdom": "^30.0.0",
|
|
181
185
|
"jest-webextension-mock": "^4.0.0",
|
|
182
186
|
"prettier": "^3.6.2",
|
|
183
|
-
"release-it": "^19.
|
|
184
|
-
"ts-node": "^
|
|
187
|
+
"release-it": "^19.2.3",
|
|
188
|
+
"ts-node": "^1.7.1",
|
|
185
189
|
"tsup": "^8.5.0",
|
|
186
190
|
"tsx": "^4.19.2",
|
|
187
191
|
"uglify-js": "^3.19.3",
|
|
@@ -206,6 +210,7 @@
|
|
|
206
210
|
}
|
|
207
211
|
},
|
|
208
212
|
"overrides": {
|
|
213
|
+
"jsdom": "27.4.0",
|
|
209
214
|
"html-rspack-tags-plugin": {
|
|
210
215
|
"glob": "^10.4.1"
|
|
211
216
|
},
|