webext-schema 2.0.9 → 2.1.2

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/modules/schema.js CHANGED
@@ -35,6 +35,7 @@ export class Schema {
35
35
  this._importMap = new Map();
36
36
  this._refMap = new Map();
37
37
  this._browser = null;
38
+ this._schema = null;
38
39
  }
39
40
 
40
41
  /* getter / setter */
@@ -272,8 +273,8 @@ export class Schema {
272
273
  encoding: CHAR,
273
274
  flag: 'r'
274
275
  });
275
- const schema = JSON.parse(content);
276
- return schema;
276
+ this._schema = JSON.parse(content);
277
+ return this._schema;
277
278
  }
278
279
 
279
280
  /**
@@ -286,7 +287,7 @@ export class Schema {
286
287
  if (!isString(name)) {
287
288
  throw new TypeError(`Expected String but got ${getType(name)}.`);
288
289
  }
289
- const schemas = this._parseSchemaContent();
290
+ const schemas = this._schema || this._parseSchemaContent();
290
291
  const items = Object.entries(schemas);
291
292
  const label = decamelize(name.replace(/\.json$/, ''));
292
293
  let schema;
@@ -305,7 +306,7 @@ export class Schema {
305
306
  * @returns {object} - schemas
306
307
  */
307
308
  getAll() {
308
- const schemas = this._parseSchemaContent();
309
+ const schemas = this._schema || this._parseSchemaContent();
309
310
  return schemas;
310
311
  }
311
312
 
@@ -315,7 +316,7 @@ export class Schema {
315
316
  * @returns {Array} - file list
316
317
  */
317
318
  list() {
318
- const schemas = this._parseSchemaContent();
319
+ const schemas = this._schema || this._parseSchemaContent();
319
320
  const items = Object.keys(schemas);
320
321
  const arr = [];
321
322
  for (const item of items) {
@@ -330,7 +331,7 @@ export class Schema {
330
331
  * @returns {object} - stubbed browser api
331
332
  */
332
333
  mock() {
333
- const schemas = this._parseSchemaContent();
334
+ const schemas = this._schema || this._parseSchemaContent();
334
335
  const schemaItems = Object.entries(schemas);
335
336
  const aliasKeys = ['action', 'menus'];
336
337
  this._browser = {
package/package.json CHANGED
@@ -14,20 +14,25 @@
14
14
  "scripts": {
15
15
  "lint": "eslint --fix .",
16
16
  "start": "node index",
17
- "test": "c8 --reporter=text mocha test/*.test.js --exit",
17
+ "test": "npm run test:central",
18
+ "test:beta": "c8 mocha --require=test/mocha/setup.js --channel=beta --exit test/*.test.js",
19
+ "test:central": "c8 mocha --require=test/mocha/setup.js --channel=central --exit test/*.test.js",
20
+ "test:esr": "c8 mocha --require=test/mocha/setup.js --channel=esr --exit test/*.test.js",
21
+ "test:release": "c8 mocha --require=test/mocha/setup.js --channel=release --exit test/*.test.js",
22
+ "test_all": "npm-run-all -s test:*",
18
23
  "update": "node index update -i",
19
- "update:beta": "node index update -c beta -i",
20
- "update:central": "node index update -c central -i",
21
- "update:esr": "node index update -c esr -i",
22
- "update:mail": "node index update -c mail -i",
23
- "update:release": "node index update -c release -i"
24
+ "update:beta": "node index update --channel=beta -i",
25
+ "update:central": "node index update --channel=central -i",
26
+ "update:esr": "node index update --channel=esr -i",
27
+ "update:mail": "node index update --channel=mail -i",
28
+ "update:release": "node index update --channel=release -i"
24
29
  },
25
30
  "dependencies": {
26
31
  "camelize": "^1.0.0",
27
32
  "commander": "^9.0.0",
28
33
  "decamelize": "^6.0.0",
29
34
  "json5": "^2.2.0",
30
- "node-fetch": "^3.2.0",
35
+ "node-fetch": "^3.2.2",
31
36
  "sinon": "^13.0.1"
32
37
  },
33
38
  "devDependencies": {
@@ -36,11 +41,12 @@
36
41
  "eslint": "^7.32.0",
37
42
  "eslint-config-standard": "^16.0.3",
38
43
  "eslint-plugin-import": "^2.25.4",
39
- "eslint-plugin-jsdoc": "^37.8.2",
44
+ "eslint-plugin-jsdoc": "^37.9.7",
40
45
  "eslint-plugin-node": "^11.1.0",
41
46
  "eslint-plugin-promise": "^5.2.0",
42
- "mocha": "^9.2.0",
43
- "nock": "^13.2.4"
47
+ "mocha": "^9.2.1",
48
+ "nock": "^13.2.4",
49
+ "npm-run-all": "^4.1.5"
44
50
  },
45
- "version": "2.0.9"
51
+ "version": "2.1.2"
46
52
  }
@@ -15206,7 +15206,8 @@
15206
15206
  "s390x",
15207
15207
  "sparc64",
15208
15208
  "x86-32",
15209
- "x86-64"
15209
+ "x86-64",
15210
+ "noarch"
15210
15211
  ],
15211
15212
  "allowedContexts": [
15212
15213
  "content",
@@ -16028,6 +16029,65 @@
16028
16029
  "description": "Details specifying the target into which to inject the CSS."
16029
16030
  }
16030
16031
  }
16032
+ },
16033
+ {
16034
+ "id": "ContentScriptFilter",
16035
+ "type": "object",
16036
+ "properties": {
16037
+ "ids": {
16038
+ "type": "array",
16039
+ "optional": true,
16040
+ "description": "The IDs of specific scripts to retrieve with <code>getRegisteredContentScripts()</code> or to unregister with <code>unregisterContentScripts()</code>.",
16041
+ "items": {
16042
+ "type": "string"
16043
+ }
16044
+ }
16045
+ }
16046
+ },
16047
+ {
16048
+ "id": "RegisteredContentScript",
16049
+ "type": "object",
16050
+ "properties": {
16051
+ "allFrames": {
16052
+ "type": "boolean",
16053
+ "optional": true,
16054
+ "description": "If specified true, it will inject into all frames, even if the frame is not the top-most frame in the tab. Each frame is checked independently for URL requirements; it will not inject into child frames if the URL requirements are not met. Defaults to false, meaning that only the top frame is matched."
16055
+ },
16056
+ "excludeMatches": {
16057
+ "type": "array",
16058
+ "optional": true,
16059
+ "description": "Excludes pages that this content script would otherwise be injected into.",
16060
+ "items": {
16061
+ "type": "string"
16062
+ }
16063
+ },
16064
+ "id": {
16065
+ "type": "string",
16066
+ "description": "The id of the content script, specified in the API call."
16067
+ },
16068
+ "js": {
16069
+ "type": "array",
16070
+ "optional": true,
16071
+ "description": "The list of JavaScript files to be injected into matching pages. These are injected in the order they appear in this array.",
16072
+ "items": {
16073
+ "$ref": "manifest.ExtensionURL"
16074
+ }
16075
+ },
16076
+ "matches": {
16077
+ "type": "array",
16078
+ "optional": true,
16079
+ "description": "Specifies which pages this content script will be injected into. Must be specified for <code>registerContentScripts()</code>.",
16080
+ "items": {
16081
+ "type": "string"
16082
+ }
16083
+ },
16084
+ "runAt": {
16085
+ "$ref": "extensionTypes.RunAt",
16086
+ "optional": true,
16087
+ "default": "document_idle",
16088
+ "description": "Specifies when JavaScript files are injected into the web page. The preferred and default value is <code>document_idle</code>."
16089
+ }
16090
+ }
16031
16091
  }
16032
16092
  ],
16033
16093
  "functions": [
@@ -16095,6 +16155,76 @@
16095
16155
  "parameters": []
16096
16156
  }
16097
16157
  ]
16158
+ },
16159
+ {
16160
+ "name": "registerContentScripts",
16161
+ "type": "function",
16162
+ "description": "Registers one or more content scripts for this extension.",
16163
+ "async": "callback",
16164
+ "parameters": [
16165
+ {
16166
+ "name": "scripts",
16167
+ "type": "array",
16168
+ "description": "Contains a list of scripts to be registered. If there are errors during script parsing/file validation, or if the IDs specified already exist, then no scripts are registered.",
16169
+ "items": {
16170
+ "$ref": "RegisteredContentScript"
16171
+ }
16172
+ },
16173
+ {
16174
+ "name": "callback",
16175
+ "type": "function",
16176
+ "description": "Invoked upon completion of the registration.",
16177
+ "parameters": []
16178
+ }
16179
+ ]
16180
+ },
16181
+ {
16182
+ "name": "getRegisteredContentScripts",
16183
+ "type": "function",
16184
+ "description": "Returns all dynamically registered content scripts for this extension that match the given filter.",
16185
+ "async": "callback",
16186
+ "parameters": [
16187
+ {
16188
+ "name": "filter",
16189
+ "$ref": "ContentScriptFilter",
16190
+ "optional": true,
16191
+ "description": "An object to filter the extension's dynamically registered scripts."
16192
+ },
16193
+ {
16194
+ "name": "callback",
16195
+ "type": "function",
16196
+ "description": "The resulting array contains the registered content scripts.",
16197
+ "parameters": [
16198
+ {
16199
+ "name": "scripts",
16200
+ "type": "array",
16201
+ "items": {
16202
+ "$ref": "RegisteredContentScript"
16203
+ }
16204
+ }
16205
+ ]
16206
+ }
16207
+ ]
16208
+ },
16209
+ {
16210
+ "name": "unregisterContentScripts",
16211
+ "type": "function",
16212
+ "description": "Unregisters one or more content scripts for this extension.",
16213
+ "async": "callback",
16214
+ "parameters": [
16215
+ {
16216
+ "name": "filter",
16217
+ "$ref": "ContentScriptFilter",
16218
+ "optional": true,
16219
+ "description": "If specified, only unregisters dynamic content scripts which match the filter. Otherwise, all of the extension's dynamic content scripts are unregistered."
16220
+ },
16221
+ {
16222
+ "name": "callback",
16223
+ "type": "function",
16224
+ "description": "Invoked upon completion of the unregistration.",
16225
+ "parameters": []
16226
+ }
16227
+ ]
16098
16228
  }
16099
16229
  ]
16100
16230
  }
@@ -15206,7 +15206,8 @@
15206
15206
  "s390x",
15207
15207
  "sparc64",
15208
15208
  "x86-32",
15209
- "x86-64"
15209
+ "x86-64",
15210
+ "noarch"
15210
15211
  ],
15211
15212
  "allowedContexts": [
15212
15213
  "content",
@@ -16028,6 +16029,65 @@
16028
16029
  "description": "Details specifying the target into which to inject the CSS."
16029
16030
  }
16030
16031
  }
16032
+ },
16033
+ {
16034
+ "id": "ContentScriptFilter",
16035
+ "type": "object",
16036
+ "properties": {
16037
+ "ids": {
16038
+ "type": "array",
16039
+ "optional": true,
16040
+ "description": "The IDs of specific scripts to retrieve with <code>getRegisteredContentScripts()</code> or to unregister with <code>unregisterContentScripts()</code>.",
16041
+ "items": {
16042
+ "type": "string"
16043
+ }
16044
+ }
16045
+ }
16046
+ },
16047
+ {
16048
+ "id": "RegisteredContentScript",
16049
+ "type": "object",
16050
+ "properties": {
16051
+ "allFrames": {
16052
+ "type": "boolean",
16053
+ "optional": true,
16054
+ "description": "If specified true, it will inject into all frames, even if the frame is not the top-most frame in the tab. Each frame is checked independently for URL requirements; it will not inject into child frames if the URL requirements are not met. Defaults to false, meaning that only the top frame is matched."
16055
+ },
16056
+ "excludeMatches": {
16057
+ "type": "array",
16058
+ "optional": true,
16059
+ "description": "Excludes pages that this content script would otherwise be injected into.",
16060
+ "items": {
16061
+ "type": "string"
16062
+ }
16063
+ },
16064
+ "id": {
16065
+ "type": "string",
16066
+ "description": "The id of the content script, specified in the API call."
16067
+ },
16068
+ "js": {
16069
+ "type": "array",
16070
+ "optional": true,
16071
+ "description": "The list of JavaScript files to be injected into matching pages. These are injected in the order they appear in this array.",
16072
+ "items": {
16073
+ "$ref": "manifest.ExtensionURL"
16074
+ }
16075
+ },
16076
+ "matches": {
16077
+ "type": "array",
16078
+ "optional": true,
16079
+ "description": "Specifies which pages this content script will be injected into. Must be specified for <code>registerContentScripts()</code>.",
16080
+ "items": {
16081
+ "type": "string"
16082
+ }
16083
+ },
16084
+ "runAt": {
16085
+ "$ref": "extensionTypes.RunAt",
16086
+ "optional": true,
16087
+ "default": "document_idle",
16088
+ "description": "Specifies when JavaScript files are injected into the web page. The preferred and default value is <code>document_idle</code>."
16089
+ }
16090
+ }
16031
16091
  }
16032
16092
  ],
16033
16093
  "functions": [
@@ -16095,6 +16155,76 @@
16095
16155
  "parameters": []
16096
16156
  }
16097
16157
  ]
16158
+ },
16159
+ {
16160
+ "name": "registerContentScripts",
16161
+ "type": "function",
16162
+ "description": "Registers one or more content scripts for this extension.",
16163
+ "async": "callback",
16164
+ "parameters": [
16165
+ {
16166
+ "name": "scripts",
16167
+ "type": "array",
16168
+ "description": "Contains a list of scripts to be registered. If there are errors during script parsing/file validation, or if the IDs specified already exist, then no scripts are registered.",
16169
+ "items": {
16170
+ "$ref": "RegisteredContentScript"
16171
+ }
16172
+ },
16173
+ {
16174
+ "name": "callback",
16175
+ "type": "function",
16176
+ "description": "Invoked upon completion of the registration.",
16177
+ "parameters": []
16178
+ }
16179
+ ]
16180
+ },
16181
+ {
16182
+ "name": "getRegisteredContentScripts",
16183
+ "type": "function",
16184
+ "description": "Returns all dynamically registered content scripts for this extension that match the given filter.",
16185
+ "async": "callback",
16186
+ "parameters": [
16187
+ {
16188
+ "name": "filter",
16189
+ "$ref": "ContentScriptFilter",
16190
+ "optional": true,
16191
+ "description": "An object to filter the extension's dynamically registered scripts."
16192
+ },
16193
+ {
16194
+ "name": "callback",
16195
+ "type": "function",
16196
+ "description": "The resulting array contains the registered content scripts.",
16197
+ "parameters": [
16198
+ {
16199
+ "name": "scripts",
16200
+ "type": "array",
16201
+ "items": {
16202
+ "$ref": "RegisteredContentScript"
16203
+ }
16204
+ }
16205
+ ]
16206
+ }
16207
+ ]
16208
+ },
16209
+ {
16210
+ "name": "unregisterContentScripts",
16211
+ "type": "function",
16212
+ "description": "Unregisters one or more content scripts for this extension.",
16213
+ "async": "callback",
16214
+ "parameters": [
16215
+ {
16216
+ "name": "filter",
16217
+ "$ref": "ContentScriptFilter",
16218
+ "optional": true,
16219
+ "description": "If specified, only unregisters dynamic content scripts which match the filter. Otherwise, all of the extension's dynamic content scripts are unregistered."
16220
+ },
16221
+ {
16222
+ "name": "callback",
16223
+ "type": "function",
16224
+ "description": "Invoked upon completion of the unregistration.",
16225
+ "parameters": []
16226
+ }
16227
+ ]
16098
16228
  }
16099
16229
  ]
16100
16230
  }
@@ -1583,7 +1583,8 @@
1583
1583
  "s390x",
1584
1584
  "sparc64",
1585
1585
  "x86-32",
1586
- "x86-64"
1586
+ "x86-64",
1587
+ "noarch"
1587
1588
  ],
1588
1589
  "allowedContexts": [
1589
1590
  "content",
@@ -11776,6 +11776,7 @@
11776
11776
  "samplingallthreads",
11777
11777
  "markersallthreads",
11778
11778
  "unregisteredthreads",
11779
+ "processcpu",
11779
11780
  "responsiveness"
11780
11781
  ]
11781
11782
  },
@@ -12895,7 +12896,9 @@
12895
12896
  },
12896
12897
  "persistent": {
12897
12898
  "optional": true,
12898
- "$ref": "PersistentBackgroundProperty"
12899
+ "type": "boolean",
12900
+ "max_manifest_version": 2,
12901
+ "default": true
12899
12902
  }
12900
12903
  },
12901
12904
  "additionalProperties": {
@@ -12913,7 +12916,9 @@
12913
12916
  },
12914
12917
  "persistent": {
12915
12918
  "optional": true,
12916
- "$ref": "PersistentBackgroundProperty"
12919
+ "type": "boolean",
12920
+ "max_manifest_version": 2,
12921
+ "default": true
12917
12922
  }
12918
12923
  },
12919
12924
  "additionalProperties": {
@@ -13536,24 +13541,6 @@
13536
13541
  "id": "UnrecognizedProperty",
13537
13542
  "type": "any",
13538
13543
  "deprecated": "An unexpected property was found in the WebExtension manifest."
13539
- },
13540
- {
13541
- "id": "PersistentBackgroundProperty",
13542
- "choices": [
13543
- {
13544
- "type": "boolean",
13545
- "enum": [
13546
- true
13547
- ]
13548
- },
13549
- {
13550
- "type": "boolean",
13551
- "enum": [
13552
- false
13553
- ],
13554
- "deprecated": "Event pages are not currently supported. This will run as a persistent background page."
13555
- }
13556
- ]
13557
13544
  }
13558
13545
  ]
13559
13546
  }
@@ -15941,7 +15928,7 @@
15941
15928
  "files": {
15942
15929
  "type": "array",
15943
15930
  "optional": true,
15944
- "description": "The path of the JS or CSS files to inject, relative to the extension's root directory. Exactly one of <code>files</code> and <code>func</code> must be specified.",
15931
+ "description": "The path of the JS files to inject, relative to the extension's root directory. Exactly one of <code>files</code> and <code>func</code> must be specified.",
15945
15932
  "minItems": 1,
15946
15933
  "items": {
15947
15934
  "type": "string"
@@ -15964,13 +15951,24 @@
15964
15951
  "description": "Result of a script injection.",
15965
15952
  "properties": {
15966
15953
  "frameId": {
15967
- "type": "number",
15954
+ "type": "integer",
15968
15955
  "description": "The frame ID associated with the injection."
15969
15956
  },
15970
15957
  "result": {
15971
15958
  "type": "any",
15972
15959
  "optional": true,
15973
15960
  "description": "The result of the script execution."
15961
+ },
15962
+ "error": {
15963
+ "type": "object",
15964
+ "optional": true,
15965
+ "description": "When the injection has failed, the error is exposed to the caller with this property.",
15966
+ "properties": {
15967
+ "message": {
15968
+ "type": "string",
15969
+ "description": "A message explaining why the injection has failed."
15970
+ }
15971
+ }
15974
15972
  }
15975
15973
  }
15976
15974
  },
@@ -15986,11 +15984,50 @@
15986
15984
  "type": "number"
15987
15985
  }
15988
15986
  },
15987
+ "allFrames": {
15988
+ "type": "boolean",
15989
+ "optional": true,
15990
+ "description": "Whether the script should inject into all frames within the tab. Defaults to false. This must not be true if <code>frameIds</code> is specified."
15991
+ },
15989
15992
  "tabId": {
15990
15993
  "type": "number",
15991
15994
  "description": "The ID of the tab into which to inject."
15992
15995
  }
15993
15996
  }
15997
+ },
15998
+ {
15999
+ "id": "CSSInjection",
16000
+ "type": "object",
16001
+ "properties": {
16002
+ "css": {
16003
+ "type": "string",
16004
+ "optional": true,
16005
+ "description": "A string containing the CSS to inject. Exactly one of <code>files</code> and <code>css</code> must be specified."
16006
+ },
16007
+ "files": {
16008
+ "type": "array",
16009
+ "optional": true,
16010
+ "description": "The path of the CSS files to inject, relative to the extension's root directory. Exactly one of <code>files</code> and <code>css</code> must be specified.",
16011
+ "minItems": 1,
16012
+ "items": {
16013
+ "type": "string"
16014
+ }
16015
+ },
16016
+ "origin": {
16017
+ "type": "string",
16018
+ "optional": true,
16019
+ "enum": [
16020
+ "USER",
16021
+ "AUTHOR"
16022
+ ],
16023
+ "default": "AUTHOR",
16024
+ "description": "The style origin for the injection. Defaults to <code>'AUTHOR'</code>."
16025
+ },
16026
+ "target": {
16027
+ "$ref": "InjectionTarget",
16028
+ "description": "Details specifying the target into which to inject the CSS."
16029
+ }
16030
+ }
15994
16031
  }
15995
16032
  ],
15996
16033
  "functions": [
@@ -16020,6 +16057,44 @@
16020
16057
  ]
16021
16058
  }
16022
16059
  ]
16060
+ },
16061
+ {
16062
+ "name": "insertCSS",
16063
+ "type": "function",
16064
+ "description": "Inserts a CSS stylesheet into a target context. If multiple frames are specified, unsuccessful injections are ignored.",
16065
+ "async": "callback",
16066
+ "parameters": [
16067
+ {
16068
+ "name": "injection",
16069
+ "$ref": "CSSInjection",
16070
+ "description": "The details of the styles to insert."
16071
+ },
16072
+ {
16073
+ "name": "callback",
16074
+ "type": "function",
16075
+ "description": "Invoked upon completion of the injection.",
16076
+ "parameters": []
16077
+ }
16078
+ ]
16079
+ },
16080
+ {
16081
+ "name": "removeCSS",
16082
+ "type": "function",
16083
+ "description": "Removes a CSS stylesheet that was previously inserted by this extension from a target context.",
16084
+ "async": "callback",
16085
+ "parameters": [
16086
+ {
16087
+ "name": "injection",
16088
+ "$ref": "CSSInjection",
16089
+ "description": "The details of the styles to remove. Note that the <code>css</code>, <code>files</code>, and <code>origin</code> properties must exactly match the stylesheet inserted through <code>insertCSS</code>. Attempting to remove a non-existent stylesheet is a no-op."
16090
+ },
16091
+ {
16092
+ "name": "callback",
16093
+ "type": "function",
16094
+ "description": "Invoked upon completion of the injection.",
16095
+ "parameters": []
16096
+ }
16097
+ ]
16023
16098
  }
16024
16099
  ]
16025
16100
  }
@@ -18009,6 +18084,22 @@
18009
18084
  "default": "document_idle",
18010
18085
  "optional": true,
18011
18086
  "description": "The soonest that the JavaScript will be injected into the tab. Defaults to \"document_idle\"."
18087
+ },
18088
+ "cookieStoreId": {
18089
+ "choices": [
18090
+ {
18091
+ "type": "array",
18092
+ "minItems": 1,
18093
+ "items": {
18094
+ "type": "string"
18095
+ }
18096
+ },
18097
+ {
18098
+ "type": "string"
18099
+ }
18100
+ ],
18101
+ "optional": true,
18102
+ "description": "limit the set of matched tabs to those that belong to the given cookie store id"
18012
18103
  }
18013
18104
  }
18014
18105
  },