adnbn 0.8.0 → 0.9.0
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/LocaleStructureValidator.js +7 -0
- package/dist/cli/builders/locale/LocaleStructureValidator.js.map +1 -1
- package/dist/cli/bundler/plugins/GenerateJsonPlugin.js +3 -7
- package/dist/cli/bundler/plugins/GenerateJsonPlugin.js.map +1 -1
- package/dist/cli/entrypoint/file/injectors/core.js +9 -1
- package/dist/cli/entrypoint/file/injectors/core.js.map +1 -1
- package/dist/cli/entrypoint/parser/ContentParser.d.ts +2 -2
- package/dist/cli/entrypoint/parser/ContentParser.js.map +1 -1
- package/dist/cli/entrypoint/parser/RelayParser.js +2 -1
- package/dist/cli/entrypoint/parser/RelayParser.js.map +1 -1
- package/dist/cli/index.js +2 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/plugins/content/ContentDriver.d.ts +21 -8
- package/dist/cli/plugins/content/ContentDriver.js +24 -2
- package/dist/cli/plugins/content/ContentDriver.js.map +1 -1
- package/dist/cli/plugins/content/ContentManager.d.ts +8 -3
- package/dist/cli/plugins/content/ContentManager.js +41 -6
- package/dist/cli/plugins/content/ContentManager.js.map +1 -1
- package/dist/cli/plugins/content/Relay.d.ts +6 -8
- package/dist/cli/plugins/content/Relay.js +2 -14
- package/dist/cli/plugins/content/Relay.js.map +1 -1
- package/dist/cli/plugins/content/RelayDeclaration.d.ts +0 -1
- package/dist/cli/plugins/content/RelayDeclaration.js +0 -3
- package/dist/cli/plugins/content/RelayDeclaration.js.map +1 -1
- package/dist/cli/plugins/content/RelayDriver.d.ts +10 -0
- package/dist/cli/plugins/content/RelayDriver.js +39 -0
- package/dist/cli/plugins/content/RelayDriver.js.map +1 -0
- package/dist/cli/plugins/content/index.js +1 -10
- package/dist/cli/plugins/content/index.js.map +1 -1
- package/dist/cli/plugins/content/types.d.ts +3 -0
- package/dist/cli/plugins/locale/Locale.js +5 -1
- package/dist/cli/plugins/locale/Locale.js.map +1 -1
- package/dist/cli/plugins/locale/declaration/LocaleDeclaration.js +2 -3
- package/dist/cli/plugins/locale/declaration/LocaleDeclaration.js.map +1 -1
- package/dist/cli/plugins/locale/declaration/locale.d.ts +3 -124
- package/dist/cli/virtual/index.js +2 -2
- package/dist/cli/virtual/virtual.d.ts +52 -147
- package/dist/entry/relay/index.d.ts +2 -1
- package/dist/entry/relay/index.js.map +1 -1
- package/dist/locale/adapters/react/LocaleProvider.js +2 -0
- package/dist/locale/adapters/react/LocaleProvider.js.map +1 -1
- package/dist/locale/adapters/react/context.d.ts +1 -0
- package/dist/locale/adapters/react/context.js +3 -2
- package/dist/locale/adapters/react/context.js.map +1 -1
- package/dist/locale/helpers.js.map +1 -1
- package/dist/locale/providers/AbstractLocale.d.ts +2 -0
- package/dist/locale/providers/AbstractLocale.js +5 -0
- package/dist/locale/providers/AbstractLocale.js.map +1 -1
- package/dist/locale/providers/NativeLocale.d.ts +3 -2
- package/dist/locale/providers/NativeLocale.js +1 -1
- package/dist/locale/providers/NativeLocale.js.map +1 -1
- package/dist/main/relay.d.ts +7 -6
- package/dist/main/relay.js +12 -5
- package/dist/main/relay.js.map +1 -1
- package/dist/message/error.d.ts +6 -0
- package/dist/message/error.js +21 -0
- package/dist/message/error.js.map +1 -1
- package/dist/message/index.d.ts +2 -1
- package/dist/message/index.js +2 -0
- package/dist/message/index.js.map +1 -1
- package/dist/message/providers/Message.d.ts +3 -0
- package/dist/message/providers/Message.js +36 -6
- package/dist/message/providers/Message.js.map +1 -1
- package/dist/offscreen/providers/ProxyOffscreen.d.ts +2 -2
- package/dist/offscreen/providers/ProxyOffscreen.js.map +1 -1
- package/dist/relay/RelayPermission.d.ts +6 -3
- package/dist/relay/RelayPermission.js +28 -12
- package/dist/relay/RelayPermission.js.map +1 -1
- package/dist/relay/adapters/RelayAdapter.d.ts +8 -0
- package/dist/relay/adapters/RelayAdapter.js +16 -0
- package/dist/relay/adapters/RelayAdapter.js.map +1 -0
- package/dist/relay/adapters/RelayMessagingAdapter.d.ts +11 -0
- package/dist/relay/adapters/RelayMessagingAdapter.js +91 -0
- package/dist/relay/adapters/RelayMessagingAdapter.js.map +1 -0
- package/dist/relay/adapters/RelayScriptingAdapter.d.ts +15 -0
- package/dist/relay/adapters/RelayScriptingAdapter.js +170 -0
- package/dist/relay/adapters/RelayScriptingAdapter.js.map +1 -0
- package/dist/relay/discovery/RelayDiscovery.d.ts +10 -0
- package/dist/relay/discovery/RelayDiscovery.js +62 -0
- package/dist/relay/discovery/RelayDiscovery.js.map +1 -0
- package/dist/relay/index.d.ts +1 -4
- package/dist/relay/index.js +1 -3
- package/dist/relay/index.js.map +1 -1
- package/dist/relay/providers/ProxyRelay.d.ts +20 -17
- package/dist/relay/providers/ProxyRelay.js +79 -52
- package/dist/relay/providers/ProxyRelay.js.map +1 -1
- package/dist/relay/providers/RegisterRelay.js +1 -2
- package/dist/relay/providers/RegisterRelay.js.map +1 -1
- package/dist/relay/result.d.ts +12 -0
- package/dist/relay/result.js +88 -0
- package/dist/relay/result.js.map +1 -0
- package/dist/sandbox/index.d.ts +2 -2
- package/dist/sandbox/index.js.map +1 -1
- package/dist/sandbox/providers/ProxySandbox.d.ts +2 -2
- package/dist/sandbox/providers/ProxySandbox.js.map +1 -1
- package/dist/service/providers/ProxyService.d.ts +2 -2
- package/dist/service/providers/ProxyService.js.map +1 -1
- package/dist/transport/ProxyTransport.d.ts +2 -2
- package/dist/transport/ProxyTransport.js.map +1 -1
- package/dist/transport/index.d.ts +3 -2
- package/dist/types/helpers.d.ts +0 -4
- package/dist/types/locale.d.ts +3 -0
- package/dist/types/locale.js +58 -0
- package/dist/types/locale.js.map +1 -1
- package/dist/types/relay.d.ts +130 -3
- package/dist/types/relay.js +16 -0
- package/dist/types/relay.js.map +1 -1
- package/dist/types/rpc.d.ts +4 -0
- package/dist/types/rpc.js +1 -0
- package/dist/types/rpc.js.map +1 -0
- package/dist/types/transport.d.ts +3 -2
- package/package.json +5 -4
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import ContentDriver from "./ContentDriver.js";
|
|
2
|
+
import { ContentScriptDeclarative } from "./../../../types/content.js";
|
|
3
|
+
import { RelayAllFrames, RelayMethod } from "./../../../types/relay.js";
|
|
4
|
+
class RelayDriver_default extends ContentDriver {
|
|
5
|
+
constructor(finder) {
|
|
6
|
+
super(finder);
|
|
7
|
+
}
|
|
8
|
+
transform(relayOptions) {
|
|
9
|
+
const { allFrames, method: _method, name: _name, ...options } = relayOptions;
|
|
10
|
+
return {
|
|
11
|
+
...options,
|
|
12
|
+
...allFrames === void 0 ? {} : { allFrames: allFrames !== false }
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
async calculatePermissions() {
|
|
16
|
+
const permissions = /* @__PURE__ */ new Set();
|
|
17
|
+
const optionalPermissions = /* @__PURE__ */ new Set();
|
|
18
|
+
const relays = Array.from((await this.getOptions()).values());
|
|
19
|
+
if (relays.some(
|
|
20
|
+
(options) => (options.method ?? RelayMethod.Messaging) === RelayMethod.Messaging && options.allFrames === RelayAllFrames.All
|
|
21
|
+
)) {
|
|
22
|
+
permissions.add("webNavigation");
|
|
23
|
+
}
|
|
24
|
+
if (relays.some(
|
|
25
|
+
(options) => options.method === RelayMethod.Scripting && (options.declarative === true || options.declarative === ContentScriptDeclarative.Required)
|
|
26
|
+
)) {
|
|
27
|
+
permissions.add("scripting");
|
|
28
|
+
} else if (relays.some(
|
|
29
|
+
(options) => options.method === RelayMethod.Scripting && options.declarative === ContentScriptDeclarative.Optional
|
|
30
|
+
)) {
|
|
31
|
+
optionalPermissions.add("scripting");
|
|
32
|
+
}
|
|
33
|
+
return [permissions, optionalPermissions];
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export {
|
|
37
|
+
RelayDriver_default as default
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=RelayDriver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/cli/plugins/content/RelayDriver.ts"],"sourcesContent":["import ContentDriver from \"./ContentDriver\";\n\nimport RelayFinder from \"@cli/entrypoint/finder/RelayFinder\";\n\nimport {ContentScriptDeclarative, type ContentScriptEntrypointOptions} from \"@typing/content\";\nimport {RelayAllFrames, type RelayEntrypointOptions, RelayMethod} from \"@typing/relay\";\nimport type {ManifestOptionalPermissions, ManifestPermissions} from \"@typing/manifest\";\n\nexport default class extends ContentDriver<ContentScriptEntrypointOptions, RelayEntrypointOptions> {\n public constructor(finder: RelayFinder) {\n super(finder);\n }\n\n protected transform(relayOptions: RelayEntrypointOptions): ContentScriptEntrypointOptions {\n const {allFrames, method: _method, name: _name, ...options} = relayOptions;\n\n return {\n ...options,\n ...(allFrames === undefined ? {} : {allFrames: allFrames !== false}),\n };\n }\n\n protected async calculatePermissions(): Promise<[ManifestPermissions, ManifestOptionalPermissions]> {\n const permissions: ManifestPermissions = new Set();\n const optionalPermissions: ManifestOptionalPermissions = new Set();\n const relays = Array.from((await this.getOptions()).values());\n\n if (\n relays.some(\n options =>\n (options.method ?? RelayMethod.Messaging) === RelayMethod.Messaging &&\n options.allFrames === RelayAllFrames.All\n )\n ) {\n permissions.add(\"webNavigation\");\n }\n\n if (\n relays.some(\n options =>\n options.method === RelayMethod.Scripting &&\n (options.declarative === true || options.declarative === ContentScriptDeclarative.Required)\n )\n ) {\n permissions.add(\"scripting\");\n } else if (\n relays.some(\n options =>\n options.method === RelayMethod.Scripting &&\n options.declarative === ContentScriptDeclarative.Optional\n )\n ) {\n optionalPermissions.add(\"scripting\");\n }\n\n return [permissions, optionalPermissions];\n }\n}\n"],"mappings":"AAAA,OAAO,mBAAmB;AAI1B,SAAQ,gCAAoE;AAC5E,SAAQ,gBAA6C,mBAAkB;AAGvE,MAAO,4BAAsB,cAAsE;AAAA,EACxF,YAAY,QAAqB;AACpC,UAAM,MAAM;AAAA,EAChB;AAAA,EAEU,UAAU,cAAsE;AACtF,UAAM,EAAC,WAAW,QAAQ,SAAS,MAAM,OAAO,GAAG,QAAO,IAAI;AAE9D,WAAO;AAAA,MACH,GAAG;AAAA,MACH,GAAI,cAAc,SAAY,CAAC,IAAI,EAAC,WAAW,cAAc,MAAK;AAAA,IACtE;AAAA,EACJ;AAAA,EAEA,MAAgB,uBAAoF;AAChG,UAAM,cAAmC,oBAAI,IAAI;AACjD,UAAM,sBAAmD,oBAAI,IAAI;AACjE,UAAM,SAAS,MAAM,MAAM,MAAM,KAAK,WAAW,GAAG,OAAO,CAAC;AAE5D,QACI,OAAO;AAAA,MACH,cACK,QAAQ,UAAU,YAAY,eAAe,YAAY,aAC1D,QAAQ,cAAc,eAAe;AAAA,IAC7C,GACF;AACE,kBAAY,IAAI,eAAe;AAAA,IACnC;AAEA,QACI,OAAO;AAAA,MACH,aACI,QAAQ,WAAW,YAAY,cAC9B,QAAQ,gBAAgB,QAAQ,QAAQ,gBAAgB,yBAAyB;AAAA,IAC1F,GACF;AACE,kBAAY,IAAI,WAAW;AAAA,IAC/B,WACI,OAAO;AAAA,MACH,aACI,QAAQ,WAAW,YAAY,aAC/B,QAAQ,gBAAgB,yBAAyB;AAAA,IACzD,GACF;AACE,0BAAoB,IAAI,WAAW;AAAA,IACvC;AAEA,WAAO,CAAC,aAAa,mBAAmB;AAAA,EAC5C;AACJ;","names":[]}
|
|
@@ -8,8 +8,6 @@ import { definePlugin } from "./../../../main/plugin.js";
|
|
|
8
8
|
import { EntrypointPlugin, onlyViaTopLevelEntry } from "./../../../cli/bundler/index.js";
|
|
9
9
|
import { getResolvePath, getSourcePath } from "./../../../cli/resolvers/path.js";
|
|
10
10
|
import { Command } from "./../../../types/app.js";
|
|
11
|
-
import { RelayMethod } from "./../../../types/relay.js";
|
|
12
|
-
import { ContentScriptDeclarative } from "./../../../types/content.js";
|
|
13
11
|
var content_default = definePlugin(() => {
|
|
14
12
|
let content;
|
|
15
13
|
let relay;
|
|
@@ -83,14 +81,7 @@ var content_default = definePlugin(() => {
|
|
|
83
81
|
});
|
|
84
82
|
},
|
|
85
83
|
manifest: async ({ manifest }) => {
|
|
86
|
-
manifest.setContentScripts(await manager.manifest()).appendHostPermissions(await manager.hostPermissions()).appendOptionalHostPermissions(await manager.optionalHostPermissions());
|
|
87
|
-
if (await relay.exists() && await relay.hasMethod(RelayMethod.Scripting)) {
|
|
88
|
-
if (await relay.hasDeclarative(ContentScriptDeclarative.Required)) {
|
|
89
|
-
manifest.addPermission("scripting");
|
|
90
|
-
} else if (await relay.hasDeclarative(ContentScriptDeclarative.Optional)) {
|
|
91
|
-
manifest.addOptionalPermission("scripting");
|
|
92
|
-
}
|
|
93
|
-
}
|
|
84
|
+
manifest.setContentScripts(await manager.manifest()).appendHostPermissions(await manager.hostPermissions()).appendOptionalHostPermissions(await manager.optionalHostPermissions()).appendPermissions(await manager.permissions()).appendOptionalPermissions(await manager.optionalPermissions());
|
|
94
85
|
}
|
|
95
86
|
};
|
|
96
87
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/cli/plugins/content/index.ts"],"sourcesContent":["import {Configuration as RspackConfig, DefinePlugin, NormalModule} 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\";\nimport {getResolvePath, getSourcePath} from \"@cli/resolvers/path\";\n\nimport {Command} from \"@typing/app\";\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/cli/plugins/content/index.ts"],"sourcesContent":["import {Configuration as RspackConfig, DefinePlugin, NormalModule} 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\";\nimport {getResolvePath, getSourcePath} from \"@cli/resolvers/path\";\n\nimport {Command} from \"@typing/app\";\nimport {RelayOptions} from \"@typing/relay\";\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 const entryTypeFilter = onlyViaTopLevelEntry([\"content\", \"relay\"]);\n\n rspack = {\n plugins: [plugin],\n optimization: {\n splitChunks: {\n cacheGroups: {\n adnbnContent: {\n minChunks: 2,\n name: manager.chunkName(),\n test: (module, context) => {\n const nm = module as NormalModule;\n\n if (!nm.resource) {\n return false;\n }\n\n if (nm.resource.startsWith(getResolvePath(getSourcePath(config)))) {\n return false;\n }\n\n return entryTypeFilter(module, context);\n },\n chunks: (chunk): boolean => {\n return manager.likely(chunk.name);\n },\n enforce: false,\n reuseExistingChunk: true,\n priority: 20,\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 .appendPermissions(await manager.permissions())\n .appendOptionalPermissions(await manager.optionalPermissions());\n },\n };\n});\n"],"mappings":"AAAA,SAAuC,oBAAiC;AACxE,SAAQ,SAAS,mBAAkB;AAEnC,OAAO,oBAAoB;AAC3B,OAAO,aAAa;AACpB,OAAO,WAAW;AAClB,OAAO,sBAAsB;AAE7B,SAAQ,oBAAmB;AAE3B,SAAQ,kBAAkB,4BAA2B;AACrD,SAAQ,gBAAgB,qBAAoB;AAE5C,SAAQ,eAAc;AAGtB,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,cAAM,kBAAkB,qBAAqB,CAAC,WAAW,OAAO,CAAC;AAEjE,iBAAS;AAAA,UACL,SAAS,CAAC,MAAM;AAAA,UAChB,cAAc;AAAA,YACV,aAAa;AAAA,cACT,aAAa;AAAA,gBACT,cAAc;AAAA,kBACV,WAAW;AAAA,kBACX,MAAM,QAAQ,UAAU;AAAA,kBACxB,MAAM,CAAC,QAAQ,YAAY;AACvB,0BAAM,KAAK;AAEX,wBAAI,CAAC,GAAG,UAAU;AACd,6BAAO;AAAA,oBACX;AAEA,wBAAI,GAAG,SAAS,WAAW,eAAe,cAAc,MAAM,CAAC,CAAC,GAAG;AAC/D,6BAAO;AAAA,oBACX;AAEA,2BAAO,gBAAgB,QAAQ,OAAO;AAAA,kBAC1C;AAAA,kBACA,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,EACrE,kBAAkB,MAAM,QAAQ,YAAY,CAAC,EAC7C,0BAA0B,MAAM,QAAQ,oBAAoB,CAAC;AAAA,IACtE;AAAA,EACJ;AACJ,CAAC;","names":[]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ContentScriptEntrypointOptions } from "../../../types/content.js";
|
|
2
2
|
import { EntrypointFile } from "../../../types/entrypoint.js";
|
|
3
|
+
import { ManifestOptionalPermissions, ManifestPermissions } from "../../../types/manifest.js";
|
|
3
4
|
export interface ContentItem<O extends ContentScriptEntrypointOptions> {
|
|
4
5
|
file: EntrypointFile;
|
|
5
6
|
options: O;
|
|
@@ -11,6 +12,8 @@ export interface ContentNameGenerator<O extends ContentScriptEntrypointOptions>
|
|
|
11
12
|
}
|
|
12
13
|
export interface ContentDriver<O extends ContentScriptEntrypointOptions> {
|
|
13
14
|
items(): Promise<ContentItems<O>>;
|
|
15
|
+
permissions(): Promise<ManifestPermissions>;
|
|
16
|
+
optionalPermissions(): Promise<ManifestOptionalPermissions>;
|
|
14
17
|
}
|
|
15
18
|
export interface ContentProvider<O extends ContentScriptEntrypointOptions> {
|
|
16
19
|
virtual(file: EntrypointFile): string;
|
|
@@ -2,10 +2,14 @@ import { getLocaleFilename } from "./../../../locale/utils.js";
|
|
|
2
2
|
import { LocaleFinder } from "./../../../cli/entrypoint/index.js";
|
|
3
3
|
class Locale_default extends LocaleFinder {
|
|
4
4
|
async json() {
|
|
5
|
+
await this.validate();
|
|
5
6
|
const data = {};
|
|
6
7
|
const builders = await this.builders();
|
|
8
|
+
const defaultBuilder = this.getValidator().getDefaultBuilder(builders);
|
|
9
|
+
const defaultMessages = (defaultBuilder == null ? void 0 : defaultBuilder.build()) ?? {};
|
|
7
10
|
for (const builder of builders.values()) {
|
|
8
|
-
|
|
11
|
+
const messages = builder === defaultBuilder ? defaultMessages : builder.build();
|
|
12
|
+
data[getLocaleFilename(builder.lang())] = { ...defaultMessages, ...messages };
|
|
9
13
|
}
|
|
10
14
|
return data;
|
|
11
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/cli/plugins/locale/Locale.ts"],"sourcesContent":["import {getLocaleFilename} from \"@locale/utils\";\n\nimport {LocaleFinder} from \"@cli/entrypoint/index.js\";\nimport {GenerateJsonPluginData} from \"@cli/bundler\";\n\nexport default class extends LocaleFinder {\n public async json(): Promise<GenerateJsonPluginData> {\n const data: GenerateJsonPluginData = {};\n\n const builders = await this.builders();\n\n for (const builder of builders.values()) {\n data[getLocaleFilename(builder.lang())] =
|
|
1
|
+
{"version":3,"sources":["../../../../src/cli/plugins/locale/Locale.ts"],"sourcesContent":["import {getLocaleFilename} from \"@locale/utils\";\n\nimport {LocaleFinder} from \"@cli/entrypoint/index.js\";\nimport {GenerateJsonPluginData} from \"@cli/bundler\";\n\nexport default class extends LocaleFinder {\n public async json(): Promise<GenerateJsonPluginData> {\n await this.validate();\n\n const data: GenerateJsonPluginData = {};\n\n const builders = await this.builders();\n const defaultBuilder = this.getValidator().getDefaultBuilder(builders);\n const defaultMessages = defaultBuilder?.build() ?? {};\n\n for (const builder of builders.values()) {\n // Builders already include this app's layers and browser overrides.\n // Every target plural has been validated; only ordinary gaps remain.\n const messages = builder === defaultBuilder ? defaultMessages : builder.build();\n data[getLocaleFilename(builder.lang())] = {...defaultMessages, ...messages};\n }\n\n return data;\n }\n}\n"],"mappings":"AAAA,SAAQ,yBAAwB;AAEhC,SAAQ,oBAAmB;AAG3B,MAAO,uBAAsB,aAAa;AAAA,EACtC,MAAa,OAAwC;AACjD,UAAM,KAAK,SAAS;AAEpB,UAAM,OAA+B,CAAC;AAEtC,UAAM,WAAW,MAAM,KAAK,SAAS;AACrC,UAAM,iBAAiB,KAAK,aAAa,EAAE,kBAAkB,QAAQ;AACrE,UAAM,mBAAkB,iDAAgB,YAAW,CAAC;AAEpD,eAAW,WAAW,SAAS,OAAO,GAAG;AAGrC,YAAM,WAAW,YAAY,iBAAiB,kBAAkB,QAAQ,MAAM;AAC9E,WAAK,kBAAkB,QAAQ,KAAK,CAAC,CAAC,IAAI,EAAC,GAAG,iBAAiB,GAAG,SAAQ;AAAA,IAC9E;AAEA,WAAO;AAAA,EACX;AACJ;","names":[]}
|
|
@@ -15,9 +15,8 @@ class LocaleDeclaration_default extends FileBuilder {
|
|
|
15
15
|
if (!structure) {
|
|
16
16
|
throw new Error("Locale structure is not set");
|
|
17
17
|
}
|
|
18
|
-
const type =
|
|
19
|
-
|
|
20
|
-
return this.readFile().replace(`interface ${name} {}`, `interface ${name} ${type}`);
|
|
18
|
+
const type = Object.entries(structure).map(([key, value]) => `${JSON.stringify(key)}: ${JSON.stringify(value)};`).join("\n ");
|
|
19
|
+
return this.readFile().replace("__LOCALE_DICTIONARY__", () => type);
|
|
21
20
|
}
|
|
22
21
|
structure(structure) {
|
|
23
22
|
this._structure = structure;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/cli/plugins/locale/declaration/LocaleDeclaration.ts"],"sourcesContent":["import {FileBuilder} from \"@cli/plugins/typescript\";\n\nimport {ReadonlyConfig} from \"@typing/config\";\nimport {LocaleStructure} from \"@typing/locale\";\n\nexport default class extends FileBuilder {\n protected _structure?: LocaleStructure;\n\n public constructor(config: ReadonlyConfig) {\n super(config);\n }\n\n protected filename(): string {\n return \"locale.d.ts\";\n }\n\n protected url(): string {\n return import.meta.url;\n }\n\n protected template(): string {\n const structure = this._structure;\n\n if (!structure) {\n throw new Error(\"Locale structure is not set\");\n }\n\n const type =
|
|
1
|
+
{"version":3,"sources":["../../../../../src/cli/plugins/locale/declaration/LocaleDeclaration.ts"],"sourcesContent":["import {FileBuilder} from \"@cli/plugins/typescript\";\n\nimport {ReadonlyConfig} from \"@typing/config\";\nimport {LocaleStructure} from \"@typing/locale\";\n\nexport default class extends FileBuilder {\n protected _structure?: LocaleStructure;\n\n public constructor(config: ReadonlyConfig) {\n super(config);\n }\n\n protected filename(): string {\n return \"locale.d.ts\";\n }\n\n protected url(): string {\n return import.meta.url;\n }\n\n protected template(): string {\n const structure = this._structure;\n\n if (!structure) {\n throw new Error(\"Locale structure is not set\");\n }\n\n const type = Object.entries(structure)\n .map(([key, value]) => `${JSON.stringify(key)}: ${JSON.stringify(value)};`)\n .join(\"\\n \");\n\n return this.readFile().replace(\"__LOCALE_DICTIONARY__\", () => type);\n }\n\n public structure(structure: LocaleStructure): this {\n this._structure = structure;\n\n return this;\n }\n}\n"],"mappings":"AAAA,SAAQ,mBAAkB;AAK1B,MAAO,kCAAsB,YAAY;AAAA,EAC3B;AAAA,EAEH,YAAY,QAAwB;AACvC,UAAM,MAAM;AAAA,EAChB;AAAA,EAEU,WAAmB;AACzB,WAAO;AAAA,EACX;AAAA,EAEU,MAAc;AACpB,WAAO,YAAY;AAAA,EACvB;AAAA,EAEU,WAAmB;AACzB,UAAM,YAAY,KAAK;AAEvB,QAAI,CAAC,WAAW;AACZ,YAAM,IAAI,MAAM,6BAA6B;AAAA,IACjD;AAEA,UAAM,OAAO,OAAO,QAAQ,SAAS,EAChC,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM,GAAG,KAAK,UAAU,GAAG,CAAC,KAAK,KAAK,UAAU,KAAK,CAAC,GAAG,EACzE,KAAK,YAAY;AAEtB,WAAO,KAAK,SAAS,EAAE,QAAQ,yBAAyB,MAAM,IAAI;AAAA,EACtE;AAAA,EAEO,UAAU,WAAkC;AAC/C,SAAK,aAAa;AAElB,WAAO;AAAA,EACX;AACJ;","names":[]}
|
|
@@ -1,129 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
Language,
|
|
3
|
-
LocaleDir,
|
|
4
|
-
type LocaleNonPluralKeys,
|
|
5
|
-
type LocalePluralKeys,
|
|
6
|
-
type LocaleProvider,
|
|
7
|
-
type LocaleDynamicProvider,
|
|
8
|
-
type LocaleSubstitutionArgs,
|
|
9
|
-
} from ":package/locale";
|
|
1
|
+
import ":package/locale";
|
|
10
2
|
|
|
11
3
|
declare module ":package/locale" {
|
|
12
4
|
// prettier-ignore
|
|
13
|
-
export interface
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Translates a non-plural locale key.
|
|
17
|
-
*
|
|
18
|
-
* Substitutions are type-checked from the generated locale structure:
|
|
19
|
-
* keys without placeholders do not accept substitutions, while keys with
|
|
20
|
-
* placeholders require all declared substitution values.
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* ```ts
|
|
24
|
-
* t("app.name");
|
|
25
|
-
* t("app.greeting", {name: "Alice"});
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
export function t<K extends LocaleNonPluralKeys<GeneratedNativeStructure>>(
|
|
29
|
-
key: K,
|
|
30
|
-
...args: LocaleSubstitutionArgs<GeneratedNativeStructure, K>
|
|
31
|
-
): string;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Translates a plural locale key using the provided count.
|
|
35
|
-
*
|
|
36
|
-
* Substitutions are type-checked from the generated locale structure:
|
|
37
|
-
* keys without placeholders do not accept substitutions, while keys with
|
|
38
|
-
* placeholders require all declared substitution values.
|
|
39
|
-
*
|
|
40
|
-
* @example
|
|
41
|
-
* ```ts
|
|
42
|
-
* choice("cart.items", count, {count});
|
|
43
|
-
* ```
|
|
44
|
-
*/
|
|
45
|
-
export function choice<K extends LocalePluralKeys<GeneratedNativeStructure>>(
|
|
46
|
-
key: K,
|
|
47
|
-
count: number,
|
|
48
|
-
...args: LocaleSubstitutionArgs<GeneratedNativeStructure, K>
|
|
49
|
-
): string;
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Converts a locale key to a browser message reference.
|
|
53
|
-
*
|
|
54
|
-
* This is useful for browser-managed extension fields that expect
|
|
55
|
-
* `__MSG_name__` references instead of already translated text.
|
|
56
|
-
*
|
|
57
|
-
* @example
|
|
58
|
-
* ```ts
|
|
59
|
-
* key("app.name"); // "__MSG_app_name__"
|
|
60
|
-
* ```
|
|
61
|
-
*/
|
|
62
|
-
export function key(value: keyof GeneratedNativeStructure & string): string;
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Resolves a string that may contain a locale marker.
|
|
66
|
-
*
|
|
67
|
-
* When the input contains a locale marker, the marker is extracted and translated.
|
|
68
|
-
* Plain strings are returned unchanged.
|
|
69
|
-
*
|
|
70
|
-
* @example
|
|
71
|
-
* ```ts
|
|
72
|
-
* resolve("@app.name");
|
|
73
|
-
* resolve("Plain title");
|
|
74
|
-
* ```
|
|
75
|
-
*/
|
|
76
|
-
export function resolve(input: string): string;
|
|
77
|
-
|
|
78
|
-
export declare class NativeLocale implements LocaleProvider<GeneratedNativeStructure> {
|
|
79
|
-
lang(): Language;
|
|
80
|
-
|
|
81
|
-
languages(): Set<Language>;
|
|
82
|
-
|
|
83
|
-
keys(): ReadonlySet<keyof GeneratedNativeStructure>;
|
|
84
|
-
|
|
85
|
-
// non-plural keys
|
|
86
|
-
trans<K extends LocaleNonPluralKeys<GeneratedNativeStructure>>(
|
|
87
|
-
key: K,
|
|
88
|
-
...args: LocaleSubstitutionArgs<GeneratedNativeStructure, K>
|
|
89
|
-
): string;
|
|
90
|
-
|
|
91
|
-
// plural keys
|
|
92
|
-
choice<K extends LocalePluralKeys<GeneratedNativeStructure>>(
|
|
93
|
-
key: K,
|
|
94
|
-
count: number,
|
|
95
|
-
...args: LocaleSubstitutionArgs<GeneratedNativeStructure, K>
|
|
96
|
-
): string;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export declare class DynamicLocale extends NativeLocale implements LocaleDynamicProvider<GeneratedNativeStructure> {
|
|
100
|
-
change(lang: Language): Promise<Language>;
|
|
5
|
+
export interface LocaleNativeStructure {
|
|
6
|
+
__LOCALE_DICTIONARY__
|
|
101
7
|
}
|
|
102
8
|
}
|
|
103
|
-
|
|
104
|
-
declare module ":package/locale/react" {
|
|
105
|
-
import type {GeneratedNativeStructure} from ":package/locale";
|
|
106
|
-
|
|
107
|
-
export interface LocaleContract {
|
|
108
|
-
lang: Language;
|
|
109
|
-
|
|
110
|
-
dir: LocaleDir;
|
|
111
|
-
|
|
112
|
-
isRtl: boolean;
|
|
113
|
-
|
|
114
|
-
t<K extends LocaleNonPluralKeys<GeneratedNativeStructure>>(
|
|
115
|
-
key: K,
|
|
116
|
-
...args: LocaleSubstitutionArgs<GeneratedNativeStructure, K>
|
|
117
|
-
): string;
|
|
118
|
-
|
|
119
|
-
choice<K extends LocalePluralKeys<GeneratedNativeStructure>>(
|
|
120
|
-
key: K,
|
|
121
|
-
count: number,
|
|
122
|
-
...args: LocaleSubstitutionArgs<GeneratedNativeStructure, K>
|
|
123
|
-
): string;
|
|
124
|
-
|
|
125
|
-
change(lang: Language): void;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
export function useLocale(): LocaleContract;
|
|
129
|
-
}
|
|
@@ -17,7 +17,7 @@ var offscreen_default = 'import type {OffscreenUnresolvedDefinition} from "adnbn
|
|
|
17
17
|
var offscreen_background_default = 'import {OffscreenBackground} from "adnbn/offscreen";\n\ntry {\n new OffscreenBackground().build();\n} catch (e) {\n console.error("Failed to build offscreen layer on background:", e);\n}\n';
|
|
18
18
|
|
|
19
19
|
// raw-loader:/home/runner/work/addon-bone/addon-bone/src/cli/virtual/relay.ts?raw
|
|
20
|
-
var relay_default = 'import type {
|
|
20
|
+
var relay_default = 'import type {TransportType} from "adnbn/transport";\nimport {isValidTransportDefinition, isValidTransportInitFunction} from "adnbn/entry/transport";\nimport {Builder as RelayBuilder, type RelayUnresolvedDefinition} from "adnbn/entry/relay";\n\nimport {Builder as ContentScriptBuilder} from "virtual:content-framework";\n\nimport * as module from "virtual:relay-entrypoint";\n\ntry {\n const relayName = "virtual:relay-name";\n\n const {default: defaultDefinition, ...otherDefinition} = module;\n\n let definition: RelayUnresolvedDefinition<TransportType> = otherDefinition;\n\n if (isValidTransportDefinition(defaultDefinition)) {\n definition = {...definition, ...defaultDefinition};\n } else if (isValidTransportInitFunction(defaultDefinition)) {\n definition = {...definition, init: defaultDefinition};\n }\n\n const {init, main, name, ...options} = definition;\n const {method, allFrames, ...contentOptions} = options;\n\n new RelayBuilder({\n name: relayName,\n init,\n main,\n ...options,\n })\n .content(\n new ContentScriptBuilder({\n ...contentOptions,\n ...(allFrames === undefined ? {} : {allFrames: allFrames !== false}),\n })\n )\n .build()\n .catch(e => {\n console.error("Failed to build relay: ", e);\n });\n} catch (e) {\n console.error("The relay crashed on startup:", e);\n}\n';
|
|
21
21
|
|
|
22
22
|
// raw-loader:/home/runner/work/addon-bone/addon-bone/src/cli/virtual/sandbox.ts?raw
|
|
23
23
|
var sandbox_default = 'import type {SandboxUnresolvedDefinition} from "adnbn";\nimport type {TransportType} from "adnbn/transport";\nimport {isValidTransportDefinition, isValidTransportInitFunction} from "adnbn/entry/transport";\nimport {Builder as SandboxBuilder} from "adnbn/entry/sandbox";\n\nimport {Builder as ViewBuilder} from "virtual:view-framework";\n\nimport * as module from "virtual:sandbox-entrypoint";\n\ntry {\n const sandboxName = "virtual:sandbox-name";\n\n const {default: defaultDefinition, ...otherDefinition} = module;\n\n let definition: SandboxUnresolvedDefinition<TransportType> = otherDefinition;\n\n if (isValidTransportDefinition(defaultDefinition)) {\n definition = {...definition, ...defaultDefinition};\n } else if (isValidTransportInitFunction(defaultDefinition)) {\n definition = {...definition, init: defaultDefinition};\n }\n\n const {init, main, name, ...options} = definition;\n\n new SandboxBuilder({\n name: sandboxName,\n init,\n main,\n ...options,\n })\n .view(new ViewBuilder(options))\n .build()\n .catch(e => {\n console.error("Failed to build sandbox: ", e);\n });\n} catch (e) {\n console.error("The sandbox crashed on startup:", e);\n}\n';
|
|
@@ -26,7 +26,7 @@ var sandbox_default = 'import type {SandboxUnresolvedDefinition} from "adnbn";\n
|
|
|
26
26
|
var view_default = 'import type {ViewDefinition, ViewOptions} from "adnbn";\nimport {resolve} from "adnbn/locale";\nimport {isViewDefinition, isValidViewDefinitionRenderValue} from "adnbn/entry/view";\n\nimport view from "virtual:view-framework";\n\nimport * as module from "virtual:view-entrypoint";\n\ntry {\n const {default: defaultDefinition, ...otherDefinition} = module;\n\n let definition: ViewDefinition<ViewOptions> = otherDefinition;\n\n if (isViewDefinition(defaultDefinition)) {\n definition = {...definition, ...defaultDefinition};\n } else if (isValidViewDefinitionRenderValue(defaultDefinition)) {\n definition = {...definition, render: defaultDefinition};\n }\n\n const {title, ...options} = definition;\n\n view({title: title ? resolve(title) : undefined, ...options});\n} catch (e) {\n console.error("The view crashed on startup:", e);\n}\n';
|
|
27
27
|
|
|
28
28
|
// src/cli/virtual/index.ts
|
|
29
|
-
import { inferEntrypointFramework } from "
|
|
29
|
+
import { inferEntrypointFramework } from "../entrypoint/index.js";
|
|
30
30
|
|
|
31
31
|
// src/types/app.ts
|
|
32
32
|
var PackageName = "adnbn";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// Only placeholders belong here; real adnbn imports resolve to their source modules via tsconfig.json.
|
|
1
2
|
declare module "*?raw" {
|
|
2
3
|
const content: string;
|
|
3
4
|
export default content;
|
|
@@ -37,16 +38,20 @@ declare module "virtual:content-entrypoint" {
|
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
declare module "virtual:content-framework" {
|
|
40
|
-
|
|
41
|
+
export const Builder:
|
|
42
|
+
| typeof import("../../entry/content/adapters/vanilla/index.js").Builder
|
|
43
|
+
| typeof import("../../entry/content/adapters/react/index.js").Builder;
|
|
41
44
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
export
|
|
45
|
+
const content:
|
|
46
|
+
| typeof import("../../entry/content/adapters/vanilla/index.js").default
|
|
47
|
+
| typeof import("../../entry/content/adapters/react/index.js").default;
|
|
48
|
+
export default content;
|
|
46
49
|
}
|
|
47
50
|
|
|
48
51
|
declare module "virtual:offscreen-entrypoint" {
|
|
49
|
-
type OffscreenDefinition = import("../../types/offscreen.js").OffscreenDefinition<
|
|
52
|
+
type OffscreenDefinition = import("../../types/offscreen.js").OffscreenDefinition<
|
|
53
|
+
import("../../types/transport.js").TransportType
|
|
54
|
+
>;
|
|
50
55
|
|
|
51
56
|
interface ModuleType extends OffscreenDefinition {
|
|
52
57
|
default: OffscreenDefinition | OffscreenDefinition["init"] | undefined;
|
|
@@ -57,14 +62,40 @@ declare module "virtual:offscreen-entrypoint" {
|
|
|
57
62
|
}
|
|
58
63
|
|
|
59
64
|
declare module "virtual:relay-entrypoint" {
|
|
60
|
-
type RelayDefinition = import("../../types/relay.js").RelayDefinition<
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
type RelayDefinition = import("../../types/relay.js").RelayDefinition<import("../../types/transport.js").TransportType>;
|
|
66
|
+
|
|
67
|
+
export const {
|
|
68
|
+
init,
|
|
69
|
+
main,
|
|
70
|
+
name,
|
|
71
|
+
method,
|
|
72
|
+
allFrames,
|
|
73
|
+
matches,
|
|
74
|
+
excludeMatches,
|
|
75
|
+
includeGlobs,
|
|
76
|
+
excludeGlobs,
|
|
77
|
+
runAt,
|
|
78
|
+
world,
|
|
79
|
+
matchAboutBlank,
|
|
80
|
+
matchOriginAsFallback,
|
|
81
|
+
declarative,
|
|
82
|
+
marker,
|
|
83
|
+
anchor,
|
|
84
|
+
mount,
|
|
85
|
+
render,
|
|
86
|
+
container,
|
|
87
|
+
watch,
|
|
88
|
+
includeBrowser,
|
|
89
|
+
excludeBrowser,
|
|
90
|
+
includeApp,
|
|
91
|
+
excludeApp,
|
|
92
|
+
mode,
|
|
93
|
+
manifestVersion,
|
|
94
|
+
debug,
|
|
95
|
+
}: Partial<RelayDefinition>;
|
|
96
|
+
|
|
97
|
+
const definition: RelayDefinition | RelayDefinition["init"] | undefined;
|
|
98
|
+
export default definition;
|
|
68
99
|
}
|
|
69
100
|
|
|
70
101
|
declare module "virtual:sandbox-entrypoint" {
|
|
@@ -78,13 +109,6 @@ declare module "virtual:sandbox-entrypoint" {
|
|
|
78
109
|
export = module;
|
|
79
110
|
}
|
|
80
111
|
|
|
81
|
-
declare module "virtual:relay-framework" {
|
|
82
|
-
type RelayUnresolvedDefinition = import("../../types/relay.js").RelayUnresolvedDefinition<any>;
|
|
83
|
-
|
|
84
|
-
const module: (definition: RelayUnresolvedDefinition) => void;
|
|
85
|
-
export = module;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
112
|
declare module "virtual:view-entrypoint" {
|
|
89
113
|
import {ViewOptions} from "../../types/view.js";
|
|
90
114
|
|
|
@@ -99,14 +123,14 @@ declare module "virtual:view-entrypoint" {
|
|
|
99
123
|
}
|
|
100
124
|
|
|
101
125
|
declare module "virtual:view-framework" {
|
|
102
|
-
|
|
126
|
+
export const Builder:
|
|
127
|
+
| typeof import("../../entry/view/adapters/vanilla/index.js").Builder
|
|
128
|
+
| typeof import("../../entry/view/adapters/react/index.js").Builder;
|
|
103
129
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
const module: (definition: ViewDefinition) => void;
|
|
109
|
-
export = module;
|
|
130
|
+
const view:
|
|
131
|
+
| typeof import("../../entry/view/adapters/vanilla/index.js").default
|
|
132
|
+
| typeof import("../../entry/view/adapters/react/index.js").default;
|
|
133
|
+
export default view;
|
|
110
134
|
}
|
|
111
135
|
|
|
112
136
|
declare module "virtual:transport-entrypoint" {
|
|
@@ -120,125 +144,6 @@ declare module "virtual:transport-entrypoint" {
|
|
|
120
144
|
export = module;
|
|
121
145
|
}
|
|
122
146
|
|
|
123
|
-
declare module "adnbn" {
|
|
124
|
-
export type BackgroundDefinition = import("../../types/background.js").BackgroundDefinition;
|
|
125
|
-
export type CommandUnresolvedDefinition = import("../../types/command.js").CommandUnresolvedDefinition;
|
|
126
|
-
export type ContentScriptDefinition = import("../../types/content.js").ContentScriptDefinition;
|
|
127
|
-
export type ViewOptions = import("../../types/view.js").ViewOptions;
|
|
128
|
-
export type ViewDefinition<T extends ViewOptions = ViewOptions> = import("../../types/view.js").ViewDefinition<T>;
|
|
129
|
-
export type OffscreenUnresolvedDefinition<T extends import("../../types/transport.js").TransportType> =
|
|
130
|
-
import("../../types/offscreen.js").OffscreenUnresolvedDefinition<T>;
|
|
131
|
-
export type RelayUnresolvedDefinition<T extends import("../../types/transport.js").TransportType> =
|
|
132
|
-
import("../../types/relay.js").RelayUnresolvedDefinition<T>;
|
|
133
|
-
export type SandboxUnresolvedDefinition<T extends import("../../types/transport.js").TransportType> =
|
|
134
|
-
import("../../types/sandbox.js").SandboxUnresolvedDefinition<T>;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
declare module "adnbn/transport" {
|
|
138
|
-
export type TransportType = import("../../types/transport.js").TransportType;
|
|
139
|
-
export type TransportOptions = import("../../types/transport.js").TransportOptions;
|
|
140
|
-
export type TransportUnresolvedDefinition<
|
|
141
|
-
O extends import("../../types/transport.js").TransportOptions,
|
|
142
|
-
T extends import("../../types/transport.js").TransportType,
|
|
143
|
-
> = import("../../types/transport.js").TransportUnresolvedDefinition<O, T>;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
declare module "adnbn/locale" {
|
|
147
|
-
export function resolve(value: string): string;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
declare module "adnbn/entry/background" {
|
|
151
|
-
import type {BackgroundDefinition, BackgroundMainHandler} from "../../types/background.js";
|
|
152
|
-
|
|
153
|
-
export function isValidBackgroundDefinition(value: unknown): value is BackgroundDefinition;
|
|
154
|
-
|
|
155
|
-
export function isValidBackgroundMainHandler(value: unknown): value is BackgroundMainHandler;
|
|
156
|
-
|
|
157
|
-
const background: (definition: BackgroundDefinition) => void;
|
|
158
|
-
export default background;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
declare module "adnbn/entry/command" {
|
|
162
|
-
import type {CommandDefinition, CommandExecute, CommandUnresolvedDefinition} from "../../types/command.js";
|
|
163
|
-
|
|
164
|
-
export function isValidCommandDefinition(value: unknown): value is CommandDefinition;
|
|
165
|
-
|
|
166
|
-
export function isValidCommandExecuteFunction(value: unknown): value is CommandExecute;
|
|
167
|
-
|
|
168
|
-
const command: (definition: CommandUnresolvedDefinition) => void;
|
|
169
|
-
export default command;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
declare module "adnbn/entry/content" {
|
|
173
|
-
import type {ContentScriptDefinition, ContentScriptRenderValue} from "../../types/content.js";
|
|
174
|
-
|
|
175
|
-
export function isContentScriptDefinition(value: unknown): value is ContentScriptDefinition;
|
|
176
|
-
|
|
177
|
-
export function isValidContentScriptDefinitionRenderValue(value: unknown): value is ContentScriptRenderValue;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
declare module "adnbn/entry/view" {
|
|
181
|
-
import type {ViewOptions, ViewDefinition, ViewRenderValue} from "../../types/view.js";
|
|
182
|
-
|
|
183
|
-
export function isViewDefinition(value: unknown): value is ViewDefinition<ViewOptions>;
|
|
184
|
-
|
|
185
|
-
export function isValidViewDefinitionRenderValue(value: unknown): value is ViewRenderValue<ViewOptions>;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
declare module "adnbn/entry/transport" {
|
|
189
|
-
export function isValidTransportDefinition(value: unknown): value is any;
|
|
190
|
-
|
|
191
|
-
export function isValidTransportInitFunction(value: unknown): value is (...args: any[]) => any;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
declare module "adnbn/entry/offscreen" {
|
|
195
|
-
import type {OffscreenDefinition, OffscreenUnresolvedDefinition} from "../../types/offscreen.js";
|
|
196
|
-
import type {TransportType} from "../../types/transport.js";
|
|
197
|
-
import type {ViewBuilder} from "../../types/view.js";
|
|
198
|
-
|
|
199
|
-
export class Builder {
|
|
200
|
-
constructor(options: OffscreenDefinition<TransportType> | OffscreenUnresolvedDefinition<TransportType>);
|
|
201
|
-
|
|
202
|
-
view(builder: ViewBuilder): this;
|
|
203
|
-
|
|
204
|
-
build(): Promise<void>;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
declare module "adnbn/entry/relay" {
|
|
209
|
-
import type {RelayDefinition, RelayUnresolvedDefinition} from "../../types/relay.js";
|
|
210
|
-
import type {TransportType} from "../../types/transport.js";
|
|
211
|
-
import type {ContentScriptBuilder} from "../../types/content.js";
|
|
212
|
-
|
|
213
|
-
export class Builder {
|
|
214
|
-
constructor(options: RelayDefinition<TransportType> | RelayUnresolvedDefinition<TransportType>);
|
|
215
|
-
|
|
216
|
-
content(builder: ContentScriptBuilder): this;
|
|
217
|
-
|
|
218
|
-
build(): Promise<void>;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
declare module "adnbn/entry/sandbox" {
|
|
223
|
-
import type {SandboxDefinition, SandboxUnresolvedDefinition} from "../../types/sandbox.js";
|
|
224
|
-
import type {TransportType} from "../../types/transport.js";
|
|
225
|
-
import type {ViewBuilder} from "../../types/view.js";
|
|
226
|
-
|
|
227
|
-
export class Builder {
|
|
228
|
-
constructor(options: SandboxDefinition<TransportType> | SandboxUnresolvedDefinition<TransportType>);
|
|
229
|
-
|
|
230
|
-
view(builder: ViewBuilder): this;
|
|
231
|
-
|
|
232
|
-
build(): Promise<void>;
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
declare module "adnbn/offscreen" {
|
|
237
|
-
export class OffscreenBackground {
|
|
238
|
-
build(): void | Promise<void>;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
|
|
242
147
|
declare module "adnbn/entry/:entry" {
|
|
243
148
|
import type {TransportUnresolvedDefinition, TransportOptions, TransportType} from "../../types/transport.js";
|
|
244
149
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import Builder from "./Builder.js";
|
|
2
2
|
export { Builder };
|
|
3
|
-
|
|
3
|
+
export type { RelayUnresolvedDefinition } from "../../types/relay.js";
|
|
4
|
+
declare const _default: (definition: Partial<import("../../types/relay.js").RelayDefinition<import("../../transport/index.js").TransportType>>) => void;
|
|
4
5
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/entry/relay/index.ts"],"sourcesContent":["import Builder from \"./Builder\";\n\nexport {Builder};\n\nexport default Builder.resolver();\n"],"mappings":"AAAA,OAAO,aAAa;
|
|
1
|
+
{"version":3,"sources":["../../../src/entry/relay/index.ts"],"sourcesContent":["import Builder from \"./Builder\";\n\nexport {Builder};\nexport type {RelayUnresolvedDefinition} from \"@typing/relay\";\n\nexport default Builder.resolver();\n"],"mappings":"AAAA,OAAO,aAAa;AAKpB,IAAO,gBAAQ,QAAQ,SAAS;","names":[]}
|
|
@@ -4,6 +4,7 @@ import { getLocaleDir, isLocaleRtl } from "./../../../locale/utils.js";
|
|
|
4
4
|
import { DynamicLocale } from "./../../../locale/providers/index.js";
|
|
5
5
|
const LocaleProvider = ({ children, storage, container = "html" }) => {
|
|
6
6
|
const locale = useMemo(() => new DynamicLocale(storage), []);
|
|
7
|
+
const langs = useMemo(() => locale.languageNames(), [locale]);
|
|
7
8
|
const [lang, setLang] = useState(locale.lang());
|
|
8
9
|
const t = useCallback((key, ...args) => {
|
|
9
10
|
return locale.trans(key, ...args);
|
|
@@ -42,6 +43,7 @@ const LocaleProvider = ({ children, storage, container = "html" }) => {
|
|
|
42
43
|
choice,
|
|
43
44
|
change,
|
|
44
45
|
lang,
|
|
46
|
+
langs,
|
|
45
47
|
dir: getLocaleDir(lang),
|
|
46
48
|
isRtl: isLocaleRtl(lang)
|
|
47
49
|
}
|
|
@@ -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 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 t: LocaleContract[\"t\"] = useCallback((key, ...args): string => {\n return locale.trans(key, ...args);\n }, []);\n\n const choice: LocaleContract[\"choice\"] = useCallback((key, count, ...args): string => {\n return locale.choice(key, count, ...args);\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 t,\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;
|
|
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 const langs = useMemo(() => locale.languageNames(), [locale]);\n\n const [lang, setLang] = useState<Language>(locale.lang());\n\n const t: LocaleContract[\"t\"] = useCallback((key, ...args): string => {\n return locale.trans(key, ...args);\n }, []);\n\n const choice: LocaleContract[\"choice\"] = useCallback((key, count, ...args): string => {\n return locale.choice(key, count, ...args);\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 t,\n choice,\n change,\n lang,\n langs,\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;AAC3D,QAAM,QAAQ,QAAQ,MAAM,OAAO,cAAc,GAAG,CAAC,MAAM,CAAC;AAE5D,QAAM,CAAC,MAAM,OAAO,IAAI,SAAmB,OAAO,KAAK,CAAC;AAExD,QAAM,IAAyB,YAAY,CAAC,QAAQ,SAAiB;AACjE,WAAO,OAAO,MAAM,KAAK,GAAG,IAAI;AAAA,EACpC,GAAG,CAAC,CAAC;AAEL,QAAM,SAAmC,YAAY,CAAC,KAAK,UAAU,SAAiB;AAClF,WAAO,OAAO,OAAO,KAAK,OAAO,GAAG,IAAI;AAAA,EAC5C,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;AAAA,QACA,KAAK,aAAa,IAAI;AAAA,QACtB,OAAO,YAAY,IAAI;AAAA,MAC3B;AAAA;AAAA,IAEC;AAAA,EACL;AAER;AAEA,IAAO,yBAAQ;","names":["lang"]}
|
|
@@ -2,6 +2,7 @@ import { LocaleDir, Language, LocaleNonPluralKeys, LocaleSubstitutionArgs, Local
|
|
|
2
2
|
import { LocaleNativeStructure } from "../../providers/index.js";
|
|
3
3
|
export interface LocaleContract<S extends object = LocaleNativeStructure> {
|
|
4
4
|
lang: Language;
|
|
5
|
+
langs: ReadonlyMap<Language, string>;
|
|
5
6
|
dir: LocaleDir;
|
|
6
7
|
isRtl: boolean;
|
|
7
8
|
t<K extends LocaleNonPluralKeys<S>>(key: K, ...args: LocaleSubstitutionArgs<S, K>): string;
|