webext-schema 5.2.10 → 5.3.1

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/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  [![build](https://github.com/asamuzaK/webext-schema/workflows/build/badge.svg)](https://github.com/asamuzaK/webext-schema/actions?query=workflow%3Abuild)
2
- [![CodeQL](https://github.com/asamuzaK/webext-schema/workflows/CodeQL/badge.svg)](https://github.com/asamuzaK/webext-schema/actions?query=workflow%3ACodeQL)
2
+ [![CodeQL](https://github.com/asamuzaK/webext-schema/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/asamuzaK/webext-schema/actions/workflows/github-code-scanning/codeql)
3
3
  [![npm](https://img.shields.io/npm/v/webext-schema)](https://www.npmjs.com/package/webext-schema)
4
4
 
5
5
  # webext-schema
@@ -989,6 +989,44 @@ export const warmupTab = async tabId => {
989
989
  }
990
990
  };
991
991
 
992
+ /**
993
+ * capture visible tab
994
+ * @param {number} windowId - window ID
995
+ * @param {object} opt - options
996
+ * @returns {Promise.<?string>} - data URL
997
+ */
998
+ export const captureVisibleTab = async (windowId, opt) => {
999
+ const info = await runtime.getBrowserInfo();
1000
+ let isGranted;
1001
+ if (info.vender === 'Mozilla') {
1002
+ const browserVersion = parseFloat(info.version);
1003
+ isGranted = (browserVersion >= 126 && await isPermissionGranted({
1004
+ permissions: ['activeTab']
1005
+ })) || await isPermissionGranted({
1006
+ origins: ['<all_urls>']
1007
+ });
1008
+ } else {
1009
+ isGranted = await isPermissionGranted({
1010
+ permissions: ['activeTab']
1011
+ }) || await isPermissionGranted({
1012
+ origins: ['<all_urls>']
1013
+ });
1014
+ }
1015
+ let url;
1016
+ if (isGranted) {
1017
+ if (!Number.isInteger(windowId)) {
1018
+ windowId = windows.WINDOW_ID_CURRENT;
1019
+ }
1020
+ if (!opt) {
1021
+ opt = {
1022
+ format: 'png'
1023
+ };
1024
+ }
1025
+ url = await tabs.captureVisibleTab(windowId, opt);
1026
+ }
1027
+ return url ?? null;
1028
+ };
1029
+
992
1030
  /**
993
1031
  * is tab
994
1032
  * @param {*} tabId - tab ID
package/package.json CHANGED
@@ -17,24 +17,24 @@
17
17
  "commander": "^12.0.0",
18
18
  "decamelize": "^6.0.0",
19
19
  "json5": "^2.2.3",
20
- "sinon": "^17.0.1"
20
+ "sinon": "^17.0.2"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@types/firefox-webext-browser": "^120.0.3",
24
- "@types/node": "^20.11.30",
24
+ "@types/node": "^20.12.11",
25
25
  "@types/sinon": "^17.0.3",
26
26
  "c8": "^9.1.0",
27
- "chai": "^5.1.0",
27
+ "chai": "^5.1.1",
28
28
  "eslint": "^8.57.0",
29
29
  "eslint-config-standard": "^17.1.0",
30
30
  "eslint-plugin-import": "^2.29.1",
31
- "eslint-plugin-jsdoc": "^48.2.1",
32
- "eslint-plugin-regexp": "^2.3.0",
33
- "eslint-plugin-unicorn": "^51.0.1",
34
- "mocha": "^10.3.0",
31
+ "eslint-plugin-jsdoc": "^48.2.4",
32
+ "eslint-plugin-regexp": "^2.5.0",
33
+ "eslint-plugin-unicorn": "^53.0.0",
34
+ "mocha": "^10.4.0",
35
35
  "npm-run-all": "^4.1.5",
36
- "typescript": "^5.4.2",
37
- "undici": "^6.9.0"
36
+ "typescript": "^5.4.5",
37
+ "undici": "^6.16.1"
38
38
  },
39
39
  "scripts": {
40
40
  "build": "npm run tsc && npm run lint && npm run test",
@@ -54,5 +54,5 @@
54
54
  "update-mail": "node index update --channel=mail -i",
55
55
  "update-release": "node index update --channel=release -i"
56
56
  },
57
- "version": "5.2.10"
57
+ "version": "5.3.1"
58
58
  }
@@ -915,6 +915,12 @@
915
915
  {
916
916
  "name": "command",
917
917
  "type": "string"
918
+ },
919
+ {
920
+ "name": "tab",
921
+ "$ref": "tags.Tab",
922
+ "optional": true,
923
+ "description": "Details of the $(ref:tabs.Tab) where the command was activated."
918
924
  }
919
925
  ]
920
926
  },
@@ -5613,9 +5619,10 @@
5613
5619
  {
5614
5620
  "name": "captureVisibleTab",
5615
5621
  "type": "function",
5616
- "description": "Captures an area of the currently active tab in the specified window. You must have $(topic:declare_permissions)[&lt;all_urls&gt;] permission to use this method.",
5622
+ "description": "Captures an area of the currently active tab in the specified window. You must have &lt;all_urls&gt; or activeTab permission to use this method.",
5617
5623
  "permissions": [
5618
- "<all_urls>"
5624
+ "<all_urls>",
5625
+ "activeTab"
5619
5626
  ],
5620
5627
  "async": "callback",
5621
5628
  "parameters": [
@@ -13476,6 +13483,11 @@
13476
13483
  ],
13477
13484
  "optional": true
13478
13485
  },
13486
+ "options_page": {
13487
+ "$ref": "ExtensionURL",
13488
+ "optional": true,
13489
+ "description": "Alias property for options_ui.page, ignored when options_ui.page is set. When using this property the options page is always opened in a new tab."
13490
+ },
13479
13491
  "options_ui": {
13480
13492
  "type": "object",
13481
13493
  "optional": true,
@@ -19710,6 +19722,7 @@
19710
19722
  "type": "string",
19711
19723
  "enum": [
19712
19724
  "webRequest",
19725
+ "webRequestAuthProvider",
19713
19726
  "webRequestBlocking",
19714
19727
  "webRequestFilterResponse",
19715
19728
  "webRequestFilterResponse.serviceWorkerScript"
@@ -19800,7 +19813,7 @@
19800
19813
  "blocking",
19801
19814
  "asyncBlocking"
19802
19815
  ],
19803
- "postprocess": "webRequestBlockingPermissionRequired"
19816
+ "postprocess": "webRequestBlockingOrAuthProviderPermissionRequired"
19804
19817
  },
19805
19818
  {
19806
19819
  "id": "OnResponseStartedOptions",
@@ -915,6 +915,12 @@
915
915
  {
916
916
  "name": "command",
917
917
  "type": "string"
918
+ },
919
+ {
920
+ "name": "tab",
921
+ "$ref": "tags.Tab",
922
+ "optional": true,
923
+ "description": "Details of the $(ref:tabs.Tab) where the command was activated."
918
924
  }
919
925
  ]
920
926
  },
@@ -5613,9 +5619,10 @@
5613
5619
  {
5614
5620
  "name": "captureVisibleTab",
5615
5621
  "type": "function",
5616
- "description": "Captures an area of the currently active tab in the specified window. You must have $(topic:declare_permissions)[&lt;all_urls&gt;] permission to use this method.",
5622
+ "description": "Captures an area of the currently active tab in the specified window. You must have &lt;all_urls&gt; or activeTab permission to use this method.",
5617
5623
  "permissions": [
5618
- "<all_urls>"
5624
+ "<all_urls>",
5625
+ "activeTab"
5619
5626
  ],
5620
5627
  "async": "callback",
5621
5628
  "parameters": [
@@ -9974,6 +9981,20 @@
9974
9981
  }
9975
9982
  }
9976
9983
  }
9984
+ },
9985
+ {
9986
+ "id": "GetRulesFilter",
9987
+ "type": "object",
9988
+ "properties": {
9989
+ "ruleIds": {
9990
+ "type": "array",
9991
+ "optional": true,
9992
+ "description": "If specified, only rules with matching IDs are included.",
9993
+ "items": {
9994
+ "type": "integer"
9995
+ }
9996
+ }
9997
+ }
9977
9998
  }
9978
9999
  ],
9979
10000
  "functions": [
@@ -10129,6 +10150,12 @@
10129
10150
  "description": "Returns the current set of dynamic rules for the extension.",
10130
10151
  "async": "callback",
10131
10152
  "parameters": [
10153
+ {
10154
+ "name": "filter",
10155
+ "$ref": "GetRulesFilter",
10156
+ "optional": true,
10157
+ "description": "An object to filter the set of dynamic rules for the extension."
10158
+ },
10132
10159
  {
10133
10160
  "name": "callback",
10134
10161
  "type": "function",
@@ -10150,6 +10177,12 @@
10150
10177
  "description": "Returns the current set of session scoped rules for the extension.",
10151
10178
  "async": "callback",
10152
10179
  "parameters": [
10180
+ {
10181
+ "name": "filter",
10182
+ "$ref": "GetRulesFilter",
10183
+ "optional": true,
10184
+ "description": "An object to filter the set of session scoped rules for the extension."
10185
+ },
10153
10186
  {
10154
10187
  "name": "callback",
10155
10188
  "type": "function",
@@ -12305,7 +12338,8 @@
12305
12338
  "power",
12306
12339
  "responsiveness",
12307
12340
  "cpufreq",
12308
- "bandwidth"
12341
+ "bandwidth",
12342
+ "memory"
12309
12343
  ]
12310
12344
  },
12311
12345
  {
@@ -12962,12 +12996,13 @@
12962
12996
  },
12963
12997
  {
12964
12998
  "id": "ExtensionInstallType",
12965
- "description": "How the extension was installed. One of<br><var>development</var>: The extension was loaded unpacked in developer mode,<br><var>normal</var>: The extension was installed normally via an .xpi file,<br><var>sideload</var>: The extension was installed by other software on the machine,<br><var>other</var>: The extension was installed by other means.",
12999
+ "description": "How the extension was installed. One of<br><var>development</var>: The extension was loaded unpacked in developer mode,<br><var>normal</var>: The extension was installed normally via an .xpi file,<br><var>sideload</var>: The extension was installed by other software on the machine,<br><var>admin</var>: The extension was installed by policy,<br><var>other</var>: The extension was installed by other means.",
12966
13000
  "type": "string",
12967
13001
  "enum": [
12968
13002
  "development",
12969
13003
  "normal",
12970
13004
  "sideload",
13005
+ "admin",
12971
13006
  "other"
12972
13007
  ]
12973
13008
  },
@@ -13410,10 +13445,13 @@
13410
13445
  },
13411
13446
  "incognito": {
13412
13447
  "type": "string",
13448
+ "description": "The 'split' value is not supported.",
13413
13449
  "enum": [
13414
13450
  "not_allowed",
13415
- "spanning"
13451
+ "spanning",
13452
+ "split"
13416
13453
  ],
13454
+ "postprocess": "incognitoSplitUnsupportedAndFallback",
13417
13455
  "default": "spanning",
13418
13456
  "optional": true
13419
13457
  },
@@ -13476,6 +13514,11 @@
13476
13514
  ],
13477
13515
  "optional": true
13478
13516
  },
13517
+ "options_page": {
13518
+ "$ref": "ExtensionURL",
13519
+ "optional": true,
13520
+ "description": "Alias property for options_ui.page, ignored when options_ui.page is set. When using this property the options page is always opened in a new tab."
13521
+ },
13479
13522
  "options_ui": {
13480
13523
  "type": "object",
13481
13524
  "optional": true,
@@ -15713,6 +15756,132 @@
15713
15756
  ],
15714
15757
  "description": "Use the <code>browser.runtime</code> API to retrieve the background page, return details about the manifest, and listen for and respond to events in the app or extension lifecycle. You can also use this API to convert the relative path of URLs to fully-qualified URLs.",
15715
15758
  "types": [
15759
+ {
15760
+ "id": "ContextFilter",
15761
+ "min_manifest_version": 3,
15762
+ "type": "object",
15763
+ "description": "A filter to match against existing extension context. Matching contexts must match all specified filters.",
15764
+ "properties": {
15765
+ "contextIds": {
15766
+ "optional": true,
15767
+ "type": "array",
15768
+ "items": {
15769
+ "type": "string"
15770
+ }
15771
+ },
15772
+ "contextTypes": {
15773
+ "optional": true,
15774
+ "type": "array",
15775
+ "items": {
15776
+ "$ref": "ContextType"
15777
+ }
15778
+ },
15779
+ "documentIds": {
15780
+ "optional": true,
15781
+ "type": "array",
15782
+ "items": {
15783
+ "type": "string"
15784
+ }
15785
+ },
15786
+ "documentOrigins": {
15787
+ "optional": true,
15788
+ "type": "array",
15789
+ "items": {
15790
+ "type": "string"
15791
+ }
15792
+ },
15793
+ "documentUrls": {
15794
+ "optional": true,
15795
+ "type": "array",
15796
+ "items": {
15797
+ "type": "string"
15798
+ }
15799
+ },
15800
+ "frameIds": {
15801
+ "optional": true,
15802
+ "type": "array",
15803
+ "items": {
15804
+ "type": "integer"
15805
+ }
15806
+ },
15807
+ "tabIds": {
15808
+ "optional": true,
15809
+ "type": "array",
15810
+ "items": {
15811
+ "type": "integer"
15812
+ }
15813
+ },
15814
+ "windowIds": {
15815
+ "optional": true,
15816
+ "type": "array",
15817
+ "items": {
15818
+ "type": "integer"
15819
+ }
15820
+ },
15821
+ "incognito": {
15822
+ "optional": true,
15823
+ "type": "boolean"
15824
+ }
15825
+ }
15826
+ },
15827
+ {
15828
+ "id": "ContextType",
15829
+ "type": "string",
15830
+ "enum": [
15831
+ "BACKGROUND",
15832
+ "POPUP",
15833
+ "SIDE_PANEL",
15834
+ "TAB"
15835
+ ],
15836
+ "description": "The type of extension view."
15837
+ },
15838
+ {
15839
+ "id": "ExtensionContext",
15840
+ "type": "object",
15841
+ "description": "A context hosting extension content",
15842
+ "properties": {
15843
+ "contextId": {
15844
+ "type": "string",
15845
+ "description": "An unique identifier associated to this context"
15846
+ },
15847
+ "contextType": {
15848
+ "$ref": "ContextType",
15849
+ "description": "The type of the context"
15850
+ },
15851
+ "documentId": {
15852
+ "type": "string",
15853
+ "unsupported": true,
15854
+ "optional": true,
15855
+ "description": "An UUID for the document associated with this context, or undefined if it is not hosted in a document"
15856
+ },
15857
+ "documentOrigin": {
15858
+ "type": "string",
15859
+ "optional": true,
15860
+ "description": "The origin of the document associated with this context, or undefined if it is not hosted in a document"
15861
+ },
15862
+ "documentUrl": {
15863
+ "type": "string",
15864
+ "optional": true,
15865
+ "description": "The URL of the document associated with this context, or undefined if it is not hosted in a document"
15866
+ },
15867
+ "incognito": {
15868
+ "type": "boolean",
15869
+ "description": "Whether the context is associated with an private browsing context."
15870
+ },
15871
+ "frameId": {
15872
+ "type": "integer",
15873
+ "description": "The frame ID for this context, or -1 if it is not hosted in a frame."
15874
+ },
15875
+ "tabId": {
15876
+ "type": "integer",
15877
+ "description": "The tab ID for this context, or -1 if it is not hosted in a tab."
15878
+ },
15879
+ "windowId": {
15880
+ "type": "integer",
15881
+ "description": "The window ID for this context, or -1 if it is not hosted in a window."
15882
+ }
15883
+ }
15884
+ },
15716
15885
  {
15717
15886
  "id": "Port",
15718
15887
  "type": "object",
@@ -15982,6 +16151,33 @@
15982
16151
  }
15983
16152
  ]
15984
16153
  },
16154
+ {
16155
+ "name": "getContexts",
16156
+ "type": "function",
16157
+ "description": "Fetches information about active contexts associated with this extension",
16158
+ "async": "callback",
16159
+ "parameters": [
16160
+ {
16161
+ "name": "filter",
16162
+ "$ref": "ContextFilter",
16163
+ "description": "A filter to find matching context."
16164
+ },
16165
+ {
16166
+ "type": "function",
16167
+ "name": "callback",
16168
+ "parameters": [
16169
+ {
16170
+ "name": "contexts",
16171
+ "type": "array",
16172
+ "items": {
16173
+ "$ref": "ExtensionContext"
16174
+ },
16175
+ "description": "The matching contexts, if any."
16176
+ }
16177
+ ]
16178
+ }
16179
+ ]
16180
+ },
15985
16181
  {
15986
16182
  "name": "openOptionsPage",
15987
16183
  "type": "function",
@@ -19710,6 +19906,7 @@
19710
19906
  "type": "string",
19711
19907
  "enum": [
19712
19908
  "webRequest",
19909
+ "webRequestAuthProvider",
19713
19910
  "webRequestBlocking",
19714
19911
  "webRequestFilterResponse",
19715
19912
  "webRequestFilterResponse.serviceWorkerScript"
@@ -19800,7 +19997,7 @@
19800
19997
  "blocking",
19801
19998
  "asyncBlocking"
19802
19999
  ],
19803
- "postprocess": "webRequestBlockingPermissionRequired"
20000
+ "postprocess": "webRequestBlockingOrAuthProviderPermissionRequired"
19804
20001
  },
19805
20002
  {
19806
20003
  "id": "OnResponseStartedOptions",