webext-schema 3.0.1 → 4.0.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.
@@ -346,8 +346,9 @@ export const createNotification = async (id, opt) => {
346
346
  let func;
347
347
  if (isGranted) {
348
348
  const { notifications } = browser;
349
- !notifications.onClosed.hasListener(clearNotification) &&
349
+ if (!notifications.onClosed.hasListener(clearNotification)) {
350
350
  notifications.onClosed.addListener(clearNotification);
351
+ }
351
352
  func = notifications.create(id, opt);
352
353
  }
353
354
  return func || null;
@@ -424,21 +425,29 @@ export const getOs = async () => {
424
425
  /**
425
426
  * make a connection
426
427
  *
427
- * @param {string} [extId] - extension ID
428
- * @param {object} [info] - info
428
+ * @param {number|string} [id] - tab ID / extension ID / host name
429
+ * @param {object|boolean} [info] - connection info / connect to native app
429
430
  * @returns {object} - runtime.Port
430
431
  */
431
- export const makeConnection = async (extId, info) => {
432
+ export const makeConnection = async (id, info) => {
432
433
  let port;
433
- if (isString(extId)) {
434
+ if (Number.isInteger(id)) {
434
435
  if (isObjectNotEmpty(info)) {
435
- port = await runtime.connect(extId, info);
436
+ port = await tabs.connect(id, info);
437
+ } else {
438
+ port = await tabs.connect(id);
439
+ }
440
+ } else if (isString(id)) {
441
+ if (info && getType(info) === 'Boolean') {
442
+ port = await runtime.connectNative(id);
443
+ } else if (isObjectNotEmpty(info)) {
444
+ port = await runtime.connect(id, info);
436
445
  } else {
437
- port = await runtime.connect(extId);
446
+ port = await runtime.connect(id);
438
447
  }
439
- } else if (isObjectNotEmpty(extId)) {
440
- port = await runtime.connect(extId);
441
- } else if (!extId && isObjectNotEmpty(info)) {
448
+ } else if (isObjectNotEmpty(id)) {
449
+ port = await runtime.connect(id);
450
+ } else if (!id && isObjectNotEmpty(info)) {
442
451
  port = await runtime.connect(info);
443
452
  } else {
444
453
  port = await runtime.connect();
@@ -449,7 +458,7 @@ export const makeConnection = async (extId, info) => {
449
458
  /**
450
459
  * send message
451
460
  *
452
- * @param {number|string} id - tabId or extension ID
461
+ * @param {number|string} id - tab ID / extension ID
453
462
  * @param {*} msg - message
454
463
  * @param {object} opt - options
455
464
  * @returns {?Function} - tabs.sendMessage() | runtime.sendMessage()
@@ -728,17 +737,12 @@ export const queryTabs = async opt => {
728
737
  export const execScriptToTab = async (tabId, opt = {}) => {
729
738
  let res;
730
739
  try {
731
- const isGranted = await isPermissionGranted({
732
- permissions: ['activeTab']
733
- });
734
740
  if (Number.isInteger(tabId)) {
735
741
  res = await tabs.executeScript(tabId, opt);
736
- } else if (isGranted) {
737
- if (isObjectNotEmpty(tabId)) {
738
- res = await tabs.executeScript(tabId);
739
- } else {
740
- res = await tabs.executeScript(opt);
741
- }
742
+ } else if (isObjectNotEmpty(tabId)) {
743
+ res = await tabs.executeScript(tabId);
744
+ } else if (isObjectNotEmpty(opt)) {
745
+ res = await tabs.executeScript(opt);
742
746
  } else {
743
747
  res = null;
744
748
  }
@@ -978,7 +982,9 @@ export const warmupTab = async tabId => {
978
982
  if (!Number.isInteger(tabId)) {
979
983
  throw new TypeError(`Expected Number but got ${getType(tabId)}.`);
980
984
  }
981
- typeof tabs.warmup === 'function' && await tabs.warmup(tabId);
985
+ if (typeof tabs.warmup === 'function') {
986
+ await tabs.warmup(tabId);
987
+ }
982
988
  };
983
989
 
984
990
  /**
@@ -1080,7 +1086,7 @@ export const getWindow = async (windowId, opt) => {
1080
1086
  export const checkIncognitoWindowExists = async () => {
1081
1087
  const arr = await getAllNormalWindows();
1082
1088
  let bool;
1083
- if (arr && arr.length) {
1089
+ if (arr?.length) {
1084
1090
  for (const win of arr) {
1085
1091
  bool = win.incognito;
1086
1092
  if (bool) {
package/modules/common.js CHANGED
@@ -66,7 +66,7 @@ export const getType = o =>
66
66
  */
67
67
  export const isObjectNotEmpty = o => {
68
68
  const items = /Object/i.test(getType(o)) && Object.keys(o);
69
- return !!(items && items.length);
69
+ return !!(items?.length);
70
70
  };
71
71
 
72
72
  /**
package/modules/update.js CHANGED
@@ -15,7 +15,7 @@ import process from 'process';
15
15
  /* constants */
16
16
  const DIR_CWD = process.cwd();
17
17
  const PERM_FILE = 0o644;
18
- export const ESR_VER = 91;
18
+ export const ESR_VER = 102;
19
19
 
20
20
  /**
21
21
  * fetch text
@@ -168,9 +168,7 @@ export const getMailExtSchemaData = async baseUrl => {
168
168
  ];
169
169
  const func = [];
170
170
  for (const item of items) {
171
- if (!excludeFile.includes(item)) {
172
- func.push(getSchemaData(item, schemaUrl));
173
- }
171
+ !excludeFile.includes(item) && func.push(getSchemaData(item, schemaUrl));
174
172
  }
175
173
  return Promise.all(func);
176
174
  };
package/package.json CHANGED
@@ -29,24 +29,24 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "camelize": "^1.0.0",
32
- "commander": "^9.2.0",
32
+ "commander": "^9.3.0",
33
33
  "decamelize": "^6.0.0",
34
34
  "json5": "^2.2.1",
35
- "node-fetch": "^3.2.4",
35
+ "node-fetch": "^3.2.5",
36
36
  "sinon": "^14.0.0"
37
37
  },
38
38
  "devDependencies": {
39
- "c8": "^7.11.2",
39
+ "c8": "^7.11.3",
40
40
  "chai": "^4.3.6",
41
- "eslint": "^8.15.0",
41
+ "eslint": "^8.17.0",
42
42
  "eslint-config-standard": "^17.0.0",
43
43
  "eslint-plugin-import": "^2.26.0",
44
- "eslint-plugin-jsdoc": "^39.2.9",
44
+ "eslint-plugin-jsdoc": "^39.3.2",
45
45
  "eslint-plugin-node": "^11.1.0",
46
46
  "eslint-plugin-promise": "^6.0.0",
47
47
  "mocha": "^10.0.0",
48
- "nock": "^13.2.4",
48
+ "nock": "^13.2.6",
49
49
  "npm-run-all": "^4.1.5"
50
50
  },
51
- "version": "3.0.1"
51
+ "version": "4.0.0"
52
52
  }
@@ -3066,7 +3066,7 @@
3066
3066
  "namespace": "manifest",
3067
3067
  "types": [
3068
3068
  {
3069
- "$extend": "PermissionNoPrompt",
3069
+ "$extend": "PermissionPrivileged",
3070
3070
  "choices": [
3071
3071
  {
3072
3072
  "type": "string",
@@ -6430,7 +6430,7 @@
6430
6430
  "namespace": "manifest",
6431
6431
  "types": [
6432
6432
  {
6433
- "$extend": "PermissionNoPrompt",
6433
+ "$extend": "PermissionPrivileged",
6434
6434
  "choices": [
6435
6435
  {
6436
6436
  "type": "string",
@@ -7275,7 +7275,7 @@
7275
7275
  "namespace": "manifest",
7276
7276
  "types": [
7277
7277
  {
7278
- "$extend": "PermissionNoPrompt",
7278
+ "$extend": "PermissionPrivileged",
7279
7279
  "choices": [
7280
7280
  {
7281
7281
  "type": "string",
@@ -10910,7 +10910,8 @@
10910
10910
  "additionalProperties": {
10911
10911
  "$ref": "experiments.ExperimentAPI"
10912
10912
  },
10913
- "optional": true
10913
+ "optional": true,
10914
+ "privileged": true
10914
10915
  }
10915
10916
  }
10916
10917
  }
@@ -11761,7 +11762,8 @@
11761
11762
  "items": {
11762
11763
  "type": "string"
11763
11764
  },
11764
- "optional": true
11765
+ "optional": true,
11766
+ "privileged": true
11765
11767
  }
11766
11768
  }
11767
11769
  }
@@ -13089,17 +13091,30 @@
13089
13091
  }
13090
13092
  ]
13091
13093
  },
13094
+ {
13095
+ "id": "PermissionPrivileged",
13096
+ "choices": [
13097
+ {
13098
+ "type": "string",
13099
+ "enum": [
13100
+ "mozillaAddons"
13101
+ ]
13102
+ }
13103
+ ]
13104
+ },
13092
13105
  {
13093
13106
  "id": "PermissionNoPrompt",
13094
13107
  "choices": [
13095
13108
  {
13096
- "$ref": "OptionalPermission"
13109
+ "$ref": "OptionalPermissionNoPrompt"
13110
+ },
13111
+ {
13112
+ "$ref": "PermissionPrivileged"
13097
13113
  },
13098
13114
  {
13099
13115
  "type": "string",
13100
13116
  "enum": [
13101
13117
  "alarms",
13102
- "mozillaAddons",
13103
13118
  "storage",
13104
13119
  "unlimitedStorage"
13105
13120
  ]
@@ -13443,7 +13458,7 @@
13443
13458
  "namespace": "manifest",
13444
13459
  "types": [
13445
13460
  {
13446
- "$extend": "PermissionNoPrompt",
13461
+ "$extend": "PermissionPrivileged",
13447
13462
  "choices": [
13448
13463
  {
13449
13464
  "type": "string",
@@ -14865,7 +14880,8 @@
14865
14880
  "type": "boolean",
14866
14881
  "optional": true,
14867
14882
  "default": false,
14868
- "description": "Whether to create all cookies as nonPersistent (i.e., session) cookies."
14883
+ "description": "Whether to create all cookies as nonPersistent (i.e., session) cookies.",
14884
+ "deprecated": "This property has no effect anymore and its value is always <code>false<code>."
14869
14885
  }
14870
14886
  }
14871
14887
  }
@@ -15720,8 +15736,7 @@
15720
15736
  "type": "string",
15721
15737
  "enum": [
15722
15738
  "scripting"
15723
- ],
15724
- "min_manifest_version": 3
15739
+ ]
15725
15740
  }
15726
15741
  ]
15727
15742
  }
@@ -15733,7 +15748,6 @@
15733
15748
  "permissions": [
15734
15749
  "scripting"
15735
15750
  ],
15736
- "min_manifest_version": 3,
15737
15751
  "types": [
15738
15752
  {
15739
15753
  "id": "ScriptInjection",
@@ -16635,7 +16649,7 @@
16635
16649
  }
16636
16650
  },
16637
16651
  {
16638
- "$extend": "PermissionNoPrompt",
16652
+ "$extend": "PermissionPrivileged",
16639
16653
  "choices": [
16640
16654
  {
16641
16655
  "type": "string",
@@ -3066,7 +3066,7 @@
3066
3066
  "namespace": "manifest",
3067
3067
  "types": [
3068
3068
  {
3069
- "$extend": "PermissionNoPrompt",
3069
+ "$extend": "PermissionPrivileged",
3070
3070
  "choices": [
3071
3071
  {
3072
3072
  "type": "string",
@@ -6430,7 +6430,7 @@
6430
6430
  "namespace": "manifest",
6431
6431
  "types": [
6432
6432
  {
6433
- "$extend": "PermissionNoPrompt",
6433
+ "$extend": "PermissionPrivileged",
6434
6434
  "choices": [
6435
6435
  {
6436
6436
  "type": "string",
@@ -7275,7 +7275,7 @@
7275
7275
  "namespace": "manifest",
7276
7276
  "types": [
7277
7277
  {
7278
- "$extend": "PermissionNoPrompt",
7278
+ "$extend": "PermissionPrivileged",
7279
7279
  "choices": [
7280
7280
  {
7281
7281
  "type": "string",
@@ -10910,7 +10910,8 @@
10910
10910
  "additionalProperties": {
10911
10911
  "$ref": "experiments.ExperimentAPI"
10912
10912
  },
10913
- "optional": true
10913
+ "optional": true,
10914
+ "privileged": true
10914
10915
  }
10915
10916
  }
10916
10917
  }
@@ -11761,7 +11762,8 @@
11761
11762
  "items": {
11762
11763
  "type": "string"
11763
11764
  },
11764
- "optional": true
11765
+ "optional": true,
11766
+ "privileged": true
11765
11767
  }
11766
11768
  }
11767
11769
  }
@@ -13089,17 +13091,30 @@
13089
13091
  }
13090
13092
  ]
13091
13093
  },
13094
+ {
13095
+ "id": "PermissionPrivileged",
13096
+ "choices": [
13097
+ {
13098
+ "type": "string",
13099
+ "enum": [
13100
+ "mozillaAddons"
13101
+ ]
13102
+ }
13103
+ ]
13104
+ },
13092
13105
  {
13093
13106
  "id": "PermissionNoPrompt",
13094
13107
  "choices": [
13095
13108
  {
13096
- "$ref": "OptionalPermission"
13109
+ "$ref": "OptionalPermissionNoPrompt"
13110
+ },
13111
+ {
13112
+ "$ref": "PermissionPrivileged"
13097
13113
  },
13098
13114
  {
13099
13115
  "type": "string",
13100
13116
  "enum": [
13101
13117
  "alarms",
13102
- "mozillaAddons",
13103
13118
  "storage",
13104
13119
  "unlimitedStorage"
13105
13120
  ]
@@ -13443,7 +13458,7 @@
13443
13458
  "namespace": "manifest",
13444
13459
  "types": [
13445
13460
  {
13446
- "$extend": "PermissionNoPrompt",
13461
+ "$extend": "PermissionPrivileged",
13447
13462
  "choices": [
13448
13463
  {
13449
13464
  "type": "string",
@@ -16634,7 +16649,7 @@
16634
16649
  }
16635
16650
  },
16636
16651
  {
16637
- "$extend": "PermissionNoPrompt",
16652
+ "$extend": "PermissionPrivileged",
16638
16653
  "choices": [
16639
16654
  {
16640
16655
  "type": "string",