webext-schema 3.0.0 → 3.0.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/modules/browser.js +7 -12
- package/modules/schema.js +12 -15
- package/package.json +1 -1
- package/schemas/mail/mailext.json +72 -0
package/modules/browser.js
CHANGED
|
@@ -74,8 +74,7 @@ export const getCloseTabsByDoubleClickValue = async () => {
|
|
|
74
74
|
});
|
|
75
75
|
let userValue;
|
|
76
76
|
if (isGranted) {
|
|
77
|
-
const { browserSettings } = browser;
|
|
78
|
-
const { closeTabsByDoubleClick } = browserSettings;
|
|
77
|
+
const { browserSettings: { closeTabsByDoubleClick } } = browser;
|
|
79
78
|
userValue = await closeTabsByDoubleClick.get({});
|
|
80
79
|
}
|
|
81
80
|
return userValue || null;
|
|
@@ -92,8 +91,7 @@ export const setContextMenuOnMouseup = async () => {
|
|
|
92
91
|
});
|
|
93
92
|
let res;
|
|
94
93
|
if (isGranted) {
|
|
95
|
-
const { browserSettings } = browser;
|
|
96
|
-
const { contextMenuShowEvent } = browserSettings;
|
|
94
|
+
const { browserSettings: { contextMenuShowEvent } } = browser;
|
|
97
95
|
const { levelOfControl, value } = await contextMenuShowEvent.get({});
|
|
98
96
|
if (value === 'mouseup') {
|
|
99
97
|
res = true;
|
|
@@ -117,8 +115,7 @@ export const clearContextMenuOnMouseup = async () => {
|
|
|
117
115
|
});
|
|
118
116
|
let res;
|
|
119
117
|
if (isGranted) {
|
|
120
|
-
const { browserSettings } = browser;
|
|
121
|
-
const { contextMenuShowEvent } = browserSettings;
|
|
118
|
+
const { browserSettings: { contextMenuShowEvent } } = browser;
|
|
122
119
|
res = await contextMenuShowEvent.clear({});
|
|
123
120
|
}
|
|
124
121
|
return !!res;
|
|
@@ -135,8 +132,7 @@ export const getNewTabPositionValue = async () => {
|
|
|
135
132
|
});
|
|
136
133
|
let res;
|
|
137
134
|
if (isGranted) {
|
|
138
|
-
const { browserSettings } = browser;
|
|
139
|
-
const { newTabPosition } = browserSettings;
|
|
135
|
+
const { browserSettings: { newTabPosition } } = browser;
|
|
140
136
|
res = await newTabPosition.get({});
|
|
141
137
|
}
|
|
142
138
|
return res || null;
|
|
@@ -255,9 +251,8 @@ export const getEnabledTheme = async () => {
|
|
|
255
251
|
try {
|
|
256
252
|
const arr = await management.getAll();
|
|
257
253
|
if (Array.isArray(arr) && arr.length) {
|
|
258
|
-
res =
|
|
259
|
-
info
|
|
260
|
-
);
|
|
254
|
+
res =
|
|
255
|
+
arr.filter(info => info?.type === 'theme' && info?.enabled && info);
|
|
261
256
|
}
|
|
262
257
|
} catch (e) {
|
|
263
258
|
logErr(e);
|
|
@@ -303,7 +298,7 @@ export const getExternalExtensions = async () => {
|
|
|
303
298
|
const arr = await management.getAll();
|
|
304
299
|
if (Array.isArray(arr) && arr.length) {
|
|
305
300
|
res =
|
|
306
|
-
arr.filter(info => info
|
|
301
|
+
arr.filter(info => info?.type === 'extension' && info);
|
|
307
302
|
}
|
|
308
303
|
} catch (e) {
|
|
309
304
|
logErr(e);
|
package/modules/schema.js
CHANGED
|
@@ -94,8 +94,7 @@ export class Schema {
|
|
|
94
94
|
} else if (this._browser[$import]) {
|
|
95
95
|
importValue = this._browser[$import];
|
|
96
96
|
} else {
|
|
97
|
-
importValue =
|
|
98
|
-
this._browser[namespace] && this._browser[namespace][$import];
|
|
97
|
+
importValue = this._browser[namespace]?.[$import];
|
|
99
98
|
}
|
|
100
99
|
Object.assign(target, importValue);
|
|
101
100
|
}
|
|
@@ -122,8 +121,7 @@ export class Schema {
|
|
|
122
121
|
} else if (this._browser[$ref]) {
|
|
123
122
|
refValue = this._browser[$ref];
|
|
124
123
|
} else {
|
|
125
|
-
refValue =
|
|
126
|
-
this._browser[namespace] && this._browser[namespace][$ref];
|
|
124
|
+
refValue = this._browser[namespace]?.[$ref];
|
|
127
125
|
}
|
|
128
126
|
Object.assign(target, refValue);
|
|
129
127
|
}
|
|
@@ -149,7 +147,7 @@ export class Schema {
|
|
|
149
147
|
for (const item of events) {
|
|
150
148
|
const { name, type, unsupported } = item;
|
|
151
149
|
if (!unsupported && name && type === 'function') {
|
|
152
|
-
target[name]
|
|
150
|
+
target[name] ??= {};
|
|
153
151
|
target[name].addListener = this._sandbox.stub();
|
|
154
152
|
target[name].hasListener = this._sandbox.stub();
|
|
155
153
|
target[name].removeListener = this._sandbox.stub();
|
|
@@ -210,7 +208,7 @@ export class Schema {
|
|
|
210
208
|
target[key] = this._sandbox.stub();
|
|
211
209
|
} else if (type === 'object' || $ref ||
|
|
212
210
|
Object.prototype.hasOwnProperty.call(item, 'properties')) {
|
|
213
|
-
target[key]
|
|
211
|
+
target[key] ??= {};
|
|
214
212
|
properties && this._mockProperties(
|
|
215
213
|
target[key], properties, `${namespace}.${key}`
|
|
216
214
|
);
|
|
@@ -247,7 +245,7 @@ export class Schema {
|
|
|
247
245
|
$import &&
|
|
248
246
|
this._importMap.set(`${namespace}.${id}`, { $import, namespace });
|
|
249
247
|
if (type === 'object' || $import || events || functions || properties) {
|
|
250
|
-
target[id]
|
|
248
|
+
target[id] ??= {};
|
|
251
249
|
events && this._mockEvents(target[id], events);
|
|
252
250
|
functions && this._mockFunctions(target[id], functions);
|
|
253
251
|
properties &&
|
|
@@ -287,7 +285,7 @@ export class Schema {
|
|
|
287
285
|
if (!isString(name)) {
|
|
288
286
|
throw new TypeError(`Expected String but got ${getType(name)}.`);
|
|
289
287
|
}
|
|
290
|
-
const schemas = this._schema
|
|
288
|
+
const schemas = this._schema ?? this._parseSchemaContent();
|
|
291
289
|
const items = Object.entries(schemas);
|
|
292
290
|
const label = decamelize(name.replace(/\.json$/, ''));
|
|
293
291
|
let schema;
|
|
@@ -306,7 +304,7 @@ export class Schema {
|
|
|
306
304
|
* @returns {object} - schemas
|
|
307
305
|
*/
|
|
308
306
|
getAll() {
|
|
309
|
-
const schemas = this._schema
|
|
307
|
+
const schemas = this._schema ?? this._parseSchemaContent();
|
|
310
308
|
return schemas;
|
|
311
309
|
}
|
|
312
310
|
|
|
@@ -316,7 +314,7 @@ export class Schema {
|
|
|
316
314
|
* @returns {Array} - file list
|
|
317
315
|
*/
|
|
318
316
|
list() {
|
|
319
|
-
const schemas = this._schema
|
|
317
|
+
const schemas = this._schema ?? this._parseSchemaContent();
|
|
320
318
|
const items = Object.keys(schemas);
|
|
321
319
|
const arr = [];
|
|
322
320
|
for (const item of items) {
|
|
@@ -331,7 +329,7 @@ export class Schema {
|
|
|
331
329
|
* @returns {object} - stubbed browser api
|
|
332
330
|
*/
|
|
333
331
|
mock() {
|
|
334
|
-
const schemas = this._schema
|
|
332
|
+
const schemas = this._schema ?? this._parseSchemaContent();
|
|
335
333
|
const schemaItems = Object.entries(schemas);
|
|
336
334
|
const aliasKeys = ['action', 'menus'];
|
|
337
335
|
this._browser = {
|
|
@@ -354,13 +352,12 @@ export class Schema {
|
|
|
354
352
|
let ns;
|
|
355
353
|
if (namespace.includes('.')) {
|
|
356
354
|
const [itemNamespace, itemSubNamespace] = namespace.split('.');
|
|
357
|
-
this._browser[itemNamespace]
|
|
358
|
-
this._browser[itemNamespace][itemSubNamespace]
|
|
359
|
-
this._browser[itemNamespace][itemSubNamespace] || {};
|
|
355
|
+
this._browser[itemNamespace] ??= {};
|
|
356
|
+
this._browser[itemNamespace][itemSubNamespace] ??= {};
|
|
360
357
|
mapKey.push(itemNamespace, itemSubNamespace);
|
|
361
358
|
ns = this._browser[itemNamespace][itemSubNamespace];
|
|
362
359
|
} else {
|
|
363
|
-
this._browser[namespace]
|
|
360
|
+
this._browser[namespace] ??= {};
|
|
364
361
|
mapKey.push(namespace);
|
|
365
362
|
ns = this._browser[namespace];
|
|
366
363
|
}
|
package/package.json
CHANGED
|
@@ -5571,6 +5571,14 @@
|
|
|
5571
5571
|
"type": "string"
|
|
5572
5572
|
}
|
|
5573
5573
|
}
|
|
5574
|
+
},
|
|
5575
|
+
{
|
|
5576
|
+
"id": "ComposeDictionaries",
|
|
5577
|
+
"type": "object",
|
|
5578
|
+
"additionalProperties": {
|
|
5579
|
+
"type": "boolean"
|
|
5580
|
+
},
|
|
5581
|
+
"description": "Object with language identifiers of all installed dictionaries as keys (for example ``en-US``) and a boolean value, indicating whether that dictionary is enabled for spellchecking or not."
|
|
5574
5582
|
}
|
|
5575
5583
|
],
|
|
5576
5584
|
"events": [
|
|
@@ -5676,6 +5684,21 @@
|
|
|
5676
5684
|
"$ref": "ComposeState"
|
|
5677
5685
|
}
|
|
5678
5686
|
]
|
|
5687
|
+
},
|
|
5688
|
+
{
|
|
5689
|
+
"name": "onActiveDictionariesChanged",
|
|
5690
|
+
"type": "function",
|
|
5691
|
+
"description": "Fired when one or more dictionaries have been activated or deactivated.",
|
|
5692
|
+
"parameters": [
|
|
5693
|
+
{
|
|
5694
|
+
"name": "tab",
|
|
5695
|
+
"$ref": "tabs.Tab"
|
|
5696
|
+
},
|
|
5697
|
+
{
|
|
5698
|
+
"name": "dictionaries",
|
|
5699
|
+
"$ref": "ComposeDictionaries"
|
|
5700
|
+
}
|
|
5701
|
+
]
|
|
5679
5702
|
}
|
|
5680
5703
|
],
|
|
5681
5704
|
"functions": [
|
|
@@ -5835,6 +5858,55 @@
|
|
|
5835
5858
|
}
|
|
5836
5859
|
]
|
|
5837
5860
|
},
|
|
5861
|
+
{
|
|
5862
|
+
"name": "getActiveDictionaries",
|
|
5863
|
+
"type": "function",
|
|
5864
|
+
"async": "callback",
|
|
5865
|
+
"description": "Returns a :ref:`ComposeDictionaries` object, listing all installed dictionaries, including the information whether they are currently enabled or not.",
|
|
5866
|
+
"permissions": [
|
|
5867
|
+
"compose"
|
|
5868
|
+
],
|
|
5869
|
+
"parameters": [
|
|
5870
|
+
{
|
|
5871
|
+
"type": "integer",
|
|
5872
|
+
"name": "tabId",
|
|
5873
|
+
"minimum": 0
|
|
5874
|
+
},
|
|
5875
|
+
{
|
|
5876
|
+
"type": "function",
|
|
5877
|
+
"name": "callback",
|
|
5878
|
+
"optional": true,
|
|
5879
|
+
"parameters": [
|
|
5880
|
+
{
|
|
5881
|
+
"$ref": "ComposeDictionaries"
|
|
5882
|
+
}
|
|
5883
|
+
]
|
|
5884
|
+
}
|
|
5885
|
+
]
|
|
5886
|
+
},
|
|
5887
|
+
{
|
|
5888
|
+
"name": "setActiveDictionaries",
|
|
5889
|
+
"type": "function",
|
|
5890
|
+
"async": true,
|
|
5891
|
+
"description": "Updates the active dictionaries. Throws if the ``activeDictionaries`` array contains unknown or invalid language identifiers.",
|
|
5892
|
+
"permissions": [
|
|
5893
|
+
"compose"
|
|
5894
|
+
],
|
|
5895
|
+
"parameters": [
|
|
5896
|
+
{
|
|
5897
|
+
"type": "integer",
|
|
5898
|
+
"name": "tabId",
|
|
5899
|
+
"minimum": 0
|
|
5900
|
+
},
|
|
5901
|
+
{
|
|
5902
|
+
"type": "array",
|
|
5903
|
+
"items": {
|
|
5904
|
+
"type": "string"
|
|
5905
|
+
},
|
|
5906
|
+
"name": "activeDictionaries"
|
|
5907
|
+
}
|
|
5908
|
+
]
|
|
5909
|
+
},
|
|
5838
5910
|
{
|
|
5839
5911
|
"name": "listAttachments",
|
|
5840
5912
|
"type": "function",
|