@vacantthinker/firefox-addon-framework-easy 2026.618.1242 → 2026.618.1336

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.
@@ -0,0 +1,12 @@
1
+ import { MessageActionBaseOptions } from "./types";
2
+ export type ActHandlerFunc = (rest: any, tabId: number | undefined) => Promise<void>;
3
+ /**
4
+ * Uses <T extends string> so the app can pass its own union type.
5
+ * It defaults to FrameworkBaseAction if no type is passed.
6
+ */
7
+ export declare function bkJsCreateBaseHandlers<T extends string = MessageActionBaseOptions>(): Map<T, ActHandlerFunc>;
8
+ /**
9
+ * Dispatcher also accepts the generic map
10
+ */
11
+ export declare function bkJsRegisterMessageDispatcher<T extends string>(handlersMap: Map<T, ActHandlerFunc>, logTag?: string): void;
12
+ //# sourceMappingURL=backgroundJs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backgroundJs.d.ts","sourceRoot":"","sources":["../src/backgroundJs.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,wBAAwB,EAAC,MAAM,SAAS,CAAC;AAEjD,MAAM,MAAM,cAAc,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAErF;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,MAAM,GAAG,wBAAwB,KAAK,GAAG,CAAC,CAAC,EAAE,cAAc,CAAC,CAuB5G;AAED;;GAEG;AACH,wBAAgB,6BAA6B,CAAC,CAAC,SAAS,MAAM,EAC5D,WAAW,EAAE,GAAG,CAAC,CAAC,EAAE,cAAc,CAAC,EACnC,MAAM,GAAE,MAAyB,QAqBlC"}
@@ -0,0 +1,58 @@
1
+ // --- IN YOUR FRAMEWORK ---
2
+ import { browserTabSendMessageMarcoPolo } from "./browserTab";
3
+ import { tabOpFocus, tabOpReload, tabOpRemove } from "./opTab";
4
+ /**
5
+ * Uses <T extends string> so the app can pass its own union type.
6
+ * It defaults to FrameworkBaseAction if no type is passed.
7
+ */
8
+ export function bkJsCreateBaseHandlers() {
9
+ // We use `any` internally to set the map up without TS complaining,
10
+ // but we return the strictly typed generic Map.
11
+ const map = new Map();
12
+ map.set('actInfo', async (rest) => {
13
+ console.log('actInfo', rest);
14
+ });
15
+ map.set('actMarco', async (_rest, tabId) => {
16
+ if (tabId)
17
+ await browserTabSendMessageMarcoPolo(tabId);
18
+ });
19
+ map.set('actFocusTargetTab', async (rest) => {
20
+ if (rest)
21
+ await tabOpFocus(rest.targetTabId);
22
+ });
23
+ map.set('actReloadTargetTab', async (rest) => {
24
+ if (rest)
25
+ await tabOpReload(rest.targetTabId);
26
+ });
27
+ map.set('actRemoveCurrentTab', async (_rest, tabId) => {
28
+ if (tabId)
29
+ await tabOpRemove(tabId);
30
+ });
31
+ // Cast it to the consumer's type before returning
32
+ return map;
33
+ }
34
+ /**
35
+ * Dispatcher also accepts the generic map
36
+ */
37
+ export function bkJsRegisterMessageDispatcher(handlersMap, logTag = "background.ts ") {
38
+ browser.runtime.onMessage.addListener(async (message, sender) => {
39
+ const { act, ...rest } = message;
40
+ if (!act)
41
+ return;
42
+ const tabId = sender?.tab?.id;
43
+ if (act !== "actMarco") {
44
+ console.info(logTag, act, `tabId=`, tabId);
45
+ }
46
+ else {
47
+ console.log(logTag, act, `tabId=`, tabId);
48
+ }
49
+ // Cast `act` to T so it can be used to query the Map
50
+ const handler = handlersMap.get(act);
51
+ if (handler) {
52
+ await handler(rest, tabId);
53
+ }
54
+ else {
55
+ console.warn(act, " not match!");
56
+ }
57
+ });
58
+ }
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * from './backgroundJs';
1
2
  export * from './BaseNumberKeyORM';
2
3
  export * from './BaseORM';
3
4
  export * from './BaseStringKeyORM';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC;AAC1B,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC;AAC1B,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ export * from './backgroundJs';
1
2
  export * from './BaseNumberKeyORM';
2
3
  export * from './BaseORM';
3
4
  export * from './BaseStringKeyORM';
package/dist/types.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export type MessageActionOptions = "actMarco" | "actRemoveCurrentTab" | "actFocusTargetTab" | "actReloadTargetTab";
1
+ export type MessageActionBaseOptions = 'actInfo' | "actMarco" | "actRemoveCurrentTab" | "actFocusTargetTab" | "actReloadTargetTab";
2
2
  export interface MessagePayloadAct {
3
- act: MessageActionOptions;
3
+ act: MessageActionBaseOptions;
4
4
  }
5
5
  export interface MessagePayloadTargetTab extends MessagePayloadAct {
6
6
  targetTabId: number;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,oBAAoB,GAC5B,UAAU,GACV,qBAAqB,GACrB,mBAAmB,GACnB,oBAAoB,CAAA;AAGxB,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,oBAAoB,CAAA;CAC1B;AAED,MAAM,WAAW,uBAAwB,SAAQ,iBAAiB;IAChE,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,MAAM,4BAA4B,GAAG,uBAAuB,CAAC;AACnE,MAAM,MAAM,6BAA6B,GAAG,uBAAuB,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,wBAAwB,GAChC,SAAS,GACT,UAAU,GACV,qBAAqB,GACrB,mBAAmB,GACnB,oBAAoB,CAAA;AAExB,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,wBAAwB,CAAA;CAC9B;AAED,MAAM,WAAW,uBAAwB,SAAQ,iBAAiB;IAChE,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,MAAM,4BAA4B,GAAG,uBAAuB,CAAC;AACnE,MAAM,MAAM,6BAA6B,GAAG,uBAAuB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vacantthinker/firefox-addon-framework-easy",
3
- "version": "2026.0618.1242",
3
+ "version": "2026.0618.1336",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",