@vacantthinker/firefox-addon-framework-easy 2026.608.1034 → 2026.609.557

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vacantthinker/firefox-addon-framework-easy",
3
- "version": "2026.0608.1034",
3
+ "version": "2026.0609.0557",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "publishConfig": {
@@ -1,4 +1,4 @@
1
- import {tabOpRemove} from './opTab.js';
1
+ import {tabOpFocus, tabOpRemove} from './opTab.js';
2
2
  import {serviceDownloadByDownlink} from './serviceCommon.js';
3
3
  import {browserTabSendMessage} from './browserTab.js';
4
4
  import {browserNotificationCreate} from './browserNotification.js';
@@ -12,10 +12,12 @@ import {browserNotificationCreate} from './browserNotification.js';
12
12
  * |'actRequestTabIdTabUrl'
13
13
  * |'actNotification'
14
14
  * |'actRemoveTab'
15
+ * |'actFocusTab'
15
16
  * |'actDownloadFile'
16
17
  * |'actSendMessageToTab'
17
18
  * }
18
19
  * @param message
20
+ * @param message.tabId{number}
19
21
  * @param sendResponse
20
22
  */
21
23
  export function browserRuntimeOnMessageCommon(act, message, sendResponse) {
@@ -35,6 +37,9 @@ export function browserRuntimeOnMessageCommon(act, message, sendResponse) {
35
37
  case 'actRemoveTab':
36
38
  tabOpRemove(message.tabId);
37
39
  break;
40
+ case 'actFocusTab':
41
+ tabOpFocus(message.tabId);
42
+ break;
38
43
  case 'actDownloadFile':
39
44
  serviceDownloadByDownlink(message);
40
45
  break;
package/src/browserTab.js CHANGED
@@ -21,23 +21,29 @@ export function browserTabWaitReloadThenSendMessageToContentJs(message) {
21
21
 
22
22
  /**
23
23
  * must has, url
24
- * @param message{{
25
- * tabId:number,
26
- * title:string,
27
- * url:string,
28
- * focusNewTab:boolean,
29
- * }}
24
+ * @param message
25
+ * @param message.tabId{number}
26
+ * @param message.url{string}
27
+ * @param message.options.focusNewTab{boolean}
30
28
  * @returns {Promise<void>}
31
29
  */
32
30
  export async function browserTabCreateToDownload(message) {
33
- let {title, url} = message;
34
- await browserNotificationCreate(`new tab! ${title || url}`);
35
-
36
- let {focusNewTab} = message;
37
31
  let properties = {
38
- url, tabId: message.tabId,
39
- active: focusNewTab || false,
32
+ url: message.url,
40
33
  };
34
+ if (message.tabId) {
35
+ let tabId = message.tabId;
36
+ try {
37
+ await tabOpGet(tabId);
38
+ Object.assign(properties, {tabId});
39
+ } catch (e) {
40
+ delete message.tabId;
41
+ }
42
+ }
43
+ if (message.options) {
44
+ let focusNewTab = message.options.focusNewTab;
45
+ Object.assign(properties, {active: focusNewTab});
46
+ }
41
47
 
42
48
  let {tabId} = await tabOpCreateNear(properties);
43
49
  browser.tabs.onUpdated.addListener(
@@ -53,12 +59,10 @@ export async function browserTabCreateToDownload(message) {
53
59
 
54
60
  /**
55
61
  * must has, tabId, url
56
- * @param message{{
57
- * tabId:number,
58
- * title:string,
59
- * url:string,
60
- * focusNewTab:boolean,
61
- * }}
62
+ * @param message
63
+ * @param message.tabId{number}
64
+ * @param message.url{string}
65
+ * @param message.options.focusNewTab{boolean}
62
66
  * @returns {Promise<void>}
63
67
  */
64
68
  export async function browserTabCreateNearSendMessageToContentJs(message) {
@@ -74,8 +78,9 @@ export async function browserTabCreateNearSendMessageToContentJs(message) {
74
78
  delete message.tabId;
75
79
  }
76
80
  }
77
- if (message.focusNewTab) {
78
- Object.assign(properties, {active: message.focusNewTab});
81
+ if (message.options) {
82
+ let focusNewTab = message.options.focusNewTab;
83
+ Object.assign(properties, {active: focusNewTab});
79
84
  }
80
85
 
81
86
  let {tabId} = await tabOpCreateNear(properties);
@@ -1,13 +1,8 @@
1
1
  import {stoOpGet, stoOpSet} from './opStorage.js';
2
2
 
3
- /**
4
- *
5
- * @param userSettings{Object}
6
- * @returns {Promise<void>}
7
- */
8
3
  export async function serviceInitUserSettings(userSettings) {
9
- const initPromises = Object.entries(userSettings).
10
- map(async ([key, setting]) => {
4
+ const initPromises = Object.entries(userSettings)
5
+ .map(async ([key, setting]) => {
11
6
  const oldValue = await stoOpGet(key);
12
7
 
13
8
  // FIX: Check strictly for null or undefined.