webext-schema 5.4.3 → 5.5.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.
@@ -39,7 +39,7 @@ export const createBookmark = async opt => {
39
39
  /**
40
40
  * get bookmark tree node
41
41
  * @param {string|Array} [id] - bookmark ID or array of bookmark IDs
42
- * @returns {Promise.<?Array>} - array of bookmarks.BookmarkTreeNode
42
+ * @returns {Promise.<?Array.<object>>} - array of bookmarks.BookmarkTreeNode
43
43
  */
44
44
  export const getBookmarkTreeNode = async id => {
45
45
  const isGranted = await isPermissionGranted({
@@ -182,7 +182,7 @@ export const updateCommand = async (id, value = '') => {
182
182
  /* contextualIdentities */
183
183
  /**
184
184
  * get all contextual identities
185
- * @returns {Promise.<?Array>} - array of contextualIdentities.ContextualIdentity
185
+ * @returns {Promise.<?Array.<object>>} - array of contextualIdentities.ContextualIdentity
186
186
  */
187
187
  export const getAllContextualIdentities = async () => {
188
188
  const isGranted = await isPermissionGranted({
@@ -219,7 +219,7 @@ export const getContextualId = async cookieStoreId => {
219
219
  /* management */
220
220
  /**
221
221
  * get enabled theme
222
- * @returns {Promise.<?Array>} - array of management.ExtensionInfo
222
+ * @returns {Promise.<?Array.<object>>} - array of management.ExtensionInfo
223
223
  */
224
224
  export const getEnabledTheme = async () => {
225
225
  const isGranted = await isPermissionGranted({
@@ -258,7 +258,7 @@ export const getExtensionInfo = async id => {
258
258
 
259
259
  /**
260
260
  * get external extensions
261
- * @returns {Promise.<?Array|boolean>} - array of management.extensionInfo
261
+ * @returns {Promise.<?Array.<object>>} - array of management.extensionInfo
262
262
  */
263
263
  export const getExternalExtensions = async () => {
264
264
  const isGranted = await isPermissionGranted({
@@ -469,7 +469,7 @@ export const isScriptingAvailable = async () => {
469
469
  /**
470
470
  * execute script to tab
471
471
  * @param {object} opt - options
472
- * @returns {Promise.<?Array|boolean>} - array of InjectionResult object
472
+ * @returns {Promise.<?Array.<object>>} - array of InjectionResult object
473
473
  */
474
474
  export const executeScriptToTab = async (opt = {}) => {
475
475
  const { args, injectImmediately, files, func, target } = opt;
@@ -496,6 +496,32 @@ export const executeScriptToTab = async (opt = {}) => {
496
496
  };
497
497
 
498
498
  /* search */
499
+ /**
500
+ * search in new tab
501
+ * @param {string} text - query string
502
+ * @param {object} opt - create tab options
503
+ * @returns {Promise.<object>} - tabs.Tab
504
+ */
505
+ export const searchInNewTab = async (text, opt) => {
506
+ if (!isString(text)) {
507
+ throw new TypeError(`Expected String but got ${getType(text)}.`);
508
+ }
509
+ const isGranted = await isPermissionGranted({
510
+ permissions: ['search']
511
+ });
512
+ let tab;
513
+ if (isGranted) {
514
+ const { search } = browser;
515
+ const { id: tabId } = await tabs.create(isObjectNotEmpty(opt) ? opt : null);
516
+ await search.query({
517
+ tabId,
518
+ text
519
+ });
520
+ tab = await tabs.get(tabId);
521
+ }
522
+ return tab ?? null;
523
+ };
524
+
499
525
  /**
500
526
  * search with a search engine
501
527
  * @param {string} query - search query
@@ -732,7 +758,7 @@ export const duplicateTab = async (tabId, opt) => {
732
758
  /**
733
759
  * query tabs
734
760
  * @param {object} opt - options
735
- * @returns {Promise.<?Array>} - result
761
+ * @returns {Promise.<Array.<object>>} - array of tabs.Tab
736
762
  */
737
763
  export const queryTabs = async opt => {
738
764
  const res = await tabs.query(opt);
@@ -852,7 +878,7 @@ export const getActiveTabId = async windowId => {
852
878
  /**
853
879
  * get all tabs in window
854
880
  * @param {number} [windowId] - window ID
855
- * @returns {Promise.<?Array>} - array of tabs.Tab
881
+ * @returns {Promise.<Array.<object>>} - array of tabs.Tab
856
882
  */
857
883
  export const getAllTabsInWindow = async windowId => {
858
884
  if (!Number.isInteger(windowId)) {
@@ -868,7 +894,7 @@ export const getAllTabsInWindow = async windowId => {
868
894
  /**
869
895
  * get highlighted tab
870
896
  * @param {number} [windowId] - window ID
871
- * @returns {Promise.<?Array>} - array of tabs.Tab
897
+ * @returns {Promise.<Array.<object>>} - array of tabs.Tab
872
898
  */
873
899
  export const getHighlightedTab = async windowId => {
874
900
  if (!Number.isInteger(windowId)) {
@@ -923,7 +949,7 @@ export const highlightTab = async (index, windowId) => {
923
949
  * move tab
924
950
  * @param {number|Array} tabId - tab ID
925
951
  * @param {object} [opt] - options
926
- * @returns {Promise.<?Array>} - array of tabs.Tab
952
+ * @returns {Promise.<?Array.<object>>} - array of tabs.Tab
927
953
  */
928
954
  export const moveTab = async (tabId, opt) => {
929
955
  if (!(Array.isArray(tabId) || Number.isInteger(tabId))) {
@@ -1083,7 +1109,7 @@ export const createNewWindow = async opt => {
1083
1109
  /**
1084
1110
  * get all windows
1085
1111
  * @param {boolean} populate - populate tabs
1086
- * @returns {Promise.<Array>} - array of windows.Window
1112
+ * @returns {Promise.<Array.<object>>} - array of windows.Window
1087
1113
  */
1088
1114
  export const getAllNormalWindows = async (populate = false) => {
1089
1115
  const arr = await windows.getAll({
@@ -33,7 +33,7 @@ export const cleanDirectory = (cmdOpts = {}) => {
33
33
  * @returns {void}
34
34
  */
35
35
  export const parseCommand = args => {
36
- const reg = /^(?:(?:--)?help|-[h|v]|--version|c(?:lean)?|u(?:pdate)?)$/;
36
+ const reg = /^(?:(?:--)?help|-[hv]|--version|c(?:lean)?|u(?:pdate)?)$/;
37
37
  if (Array.isArray(args) && args.some(arg => reg.test(arg))) {
38
38
  commander.exitOverride();
39
39
  commander.version(process.env.npm_package_version, '-v, --version');
package/modules/schema.js CHANGED
@@ -55,6 +55,7 @@ export class Schema {
55
55
 
56
56
  /**
57
57
  * get target from namespace key
58
+ * @private
58
59
  * @param {string} key - namespace key
59
60
  * @returns {object} - target object
60
61
  */
@@ -81,6 +82,7 @@ export class Schema {
81
82
 
82
83
  /**
83
84
  * assign imported values
85
+ * @private
84
86
  * @returns {void}
85
87
  */
86
88
  _assignImportMap() {
@@ -107,6 +109,7 @@ export class Schema {
107
109
 
108
110
  /**
109
111
  * assign referred values
112
+ * @private
110
113
  * @returns {void}
111
114
  */
112
115
  _assignRefMap() {
@@ -133,6 +136,7 @@ export class Schema {
133
136
 
134
137
  /**
135
138
  * mock events
139
+ * @private
136
140
  * @param {object} target - target object
137
141
  * @param {Array} events - events
138
142
  * @returns {object} - target object
@@ -158,6 +162,7 @@ export class Schema {
158
162
 
159
163
  /**
160
164
  * mock functions
165
+ * @private
161
166
  * @param {object} target - target object
162
167
  * @param {Array} funcs - functions
163
168
  * @returns {object} - target object
@@ -180,6 +185,7 @@ export class Schema {
180
185
 
181
186
  /**
182
187
  * mock properties
188
+ * @private
183
189
  * @param {object} target - target object
184
190
  * @param {object} props - properties
185
191
  * @param {string} namespace - namespace
@@ -220,6 +226,7 @@ export class Schema {
220
226
 
221
227
  /**
222
228
  * mock types
229
+ * @private
223
230
  * @param {object} target - target object
224
231
  * @param {Array} types - types
225
232
  * @param {string} namespace - namespace
@@ -257,6 +264,7 @@ export class Schema {
257
264
 
258
265
  /**
259
266
  * parse schema content
267
+ * @private
260
268
  * @returns {object} - schema
261
269
  */
262
270
  _parseSchemaContent() {
@@ -274,7 +282,7 @@ export class Schema {
274
282
  /**
275
283
  * get schema
276
284
  * @param {string} name - API name or file name
277
- * @returns {Array} - schema
285
+ * @returns {?Array.<object>} - schema
278
286
  */
279
287
  get(name) {
280
288
  if (!isString(name)) {
@@ -304,7 +312,7 @@ export class Schema {
304
312
 
305
313
  /**
306
314
  * list schemas
307
- * @returns {Array} - file list
315
+ * @returns {Array.<string>} - file list
308
316
  */
309
317
  list() {
310
318
  const schemas = this._schema ?? this._parseSchemaContent();
package/modules/update.js CHANGED
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * update.js
3
3
  */
4
+ /* eslint-disable no-await-in-loop */
4
5
 
5
6
  /* api */
6
7
  import path from 'node:path';
@@ -108,46 +109,57 @@ export const getFileList = async baseUrl => {
108
109
  /**
109
110
  * get all schema data
110
111
  * @param {string} baseUrl - base URL
111
- * @returns {Promise.<Array>} - schemas data in array
112
+ * @param {boolean} info - console info
113
+ * @returns {Promise.<Array.<object>>} - schemas data in array
112
114
  */
113
- export const getAllSchemaData = async baseUrl => {
115
+ export const getAllSchemaData = async (baseUrl, info) => {
114
116
  if (!isString(baseUrl)) {
115
117
  throw new TypeError(`Expected String but got ${getType(baseUrl)}.`);
116
118
  }
119
+ const schemas = [];
117
120
  const items = await getFileList(baseUrl);
118
- const func = [];
119
121
  for (const item of items) {
120
- func.push(getSchemaData(item, baseUrl));
122
+ if (info) {
123
+ console.info(`Fetching ${item}`);
124
+ }
125
+ const schema = await getSchemaData(item, baseUrl);
126
+ schemas.push(schema);
121
127
  }
122
- return Promise.all(func);
128
+ return schemas;
123
129
  };
124
130
 
125
131
  /**
126
132
  * get listed schema data
127
133
  * @param {string} baseUrl - base URL
128
134
  * @param {Array} arr - array of schema file names
129
- * @returns {Promise.<Array>} - schema data in array
135
+ * @param {boolean} info - console info
136
+ * @returns {Promise.<Array.<object>>} - schema data in array
130
137
  */
131
- export const getListedSchemaData = async (baseUrl, arr) => {
138
+ export const getListedSchemaData = async (baseUrl, arr, info) => {
132
139
  if (!isString(baseUrl)) {
133
140
  throw new TypeError(`Expected String but got ${getType(baseUrl)}.`);
134
141
  }
135
142
  if (!Array.isArray(arr)) {
136
143
  throw new TypeError(`Expected Array but got ${getType(arr)}.`);
137
144
  }
138
- const func = [];
145
+ const schemas = [];
139
146
  for (const item of arr) {
140
- func.push(getSchemaData(item, baseUrl));
147
+ if (info) {
148
+ console.info(`Fetching ${item}`);
149
+ }
150
+ const schema = await getSchemaData(item, baseUrl);
151
+ schemas.push(schema);
141
152
  }
142
- return Promise.all(func);
153
+ return schemas;
143
154
  };
144
155
 
145
156
  /**
146
157
  * get MailExtensions schema data
147
158
  * @param {string} baseUrl - base URL
148
- * @returns {Promise.<Array>} - results of each handler
159
+ * @param {boolean} info - console info
160
+ * @returns {Promise.<Array.<object>>} - results of each handler
149
161
  */
150
- export const getMailExtSchemaData = async baseUrl => {
162
+ export const getMailExtSchemaData = async (baseUrl, info) => {
151
163
  if (!isString(baseUrl)) {
152
164
  throw new TypeError(`Expected String but got ${getType(baseUrl)}.`);
153
165
  }
@@ -157,19 +169,26 @@ export const getMailExtSchemaData = async baseUrl => {
157
169
  'commands.json',
158
170
  'pkcs11.json'
159
171
  ];
160
- const func = [];
172
+ const schemas = [];
161
173
  for (const item of items) {
162
- !excludeFile.includes(item) && func.push(getSchemaData(item, schemaUrl));
174
+ if (!excludeFile.includes(item)) {
175
+ if (info) {
176
+ console.info(`Fetching ${item}`);
177
+ }
178
+ const schema = await getSchemaData(item, schemaUrl);
179
+ schemas.push(schema);
180
+ }
163
181
  }
164
- return Promise.all(func);
182
+ return schemas;
165
183
  };
166
184
 
167
185
  /**
168
186
  * create unified schema
169
187
  * @param {string} channel - release channel
188
+ * @param {boolean} info - console info
170
189
  * @returns {Promise.<object>} - schema
171
190
  */
172
- export const createUnifiedSchema = async channel => {
191
+ export const createUnifiedSchema = async (channel, info) => {
173
192
  const channelUrl = getChannelUrl(channel);
174
193
  const schema = {};
175
194
  let arr;
@@ -187,14 +206,16 @@ export const createUnifiedSchema = async channel => {
187
206
  const toolkitBaseUrl =
188
207
  `${getChannelUrl('central')}toolkit/components/extensions/schemas/`;
189
208
  arr = await Promise.all([
190
- getListedSchemaData(browserBaseUrl, browserItems),
191
- getListedSchemaData(toolkitBaseUrl, toolkitItems),
192
- getMailExtSchemaData(`${channelUrl}mail/components/extensions/`)
209
+ getListedSchemaData(browserBaseUrl, browserItems, info),
210
+ getListedSchemaData(toolkitBaseUrl, toolkitItems, info),
211
+ getMailExtSchemaData(`${channelUrl}mail/components/extensions/`, info)
193
212
  ]);
194
213
  } else {
195
214
  arr = await Promise.all([
196
- getAllSchemaData(`${channelUrl}browser/components/extensions/schemas/`),
197
- getAllSchemaData(`${channelUrl}toolkit/components/extensions/schemas/`)
215
+ getAllSchemaData(`${channelUrl}browser/components/extensions/schemas/`,
216
+ info),
217
+ getAllSchemaData(`${channelUrl}toolkit/components/extensions/schemas/`,
218
+ info)
198
219
  ]);
199
220
  }
200
221
  for (const items of arr) {
@@ -216,7 +237,7 @@ export const saveSchemaFile = async (channel, info) => {
216
237
  if (!isString(channel)) {
217
238
  throw new TypeError(`Expected String but got ${getType(channel)}.`);
218
239
  }
219
- const schema = await createUnifiedSchema(channel);
240
+ const schema = await createUnifiedSchema(channel, info);
220
241
  const content = `${JSON.stringify(schema, null, INDENT)}\n`;
221
242
  const fileName = channel === 'mail' ? 'mailext' : 'webext';
222
243
  const filePath =
package/package.json CHANGED
@@ -21,20 +21,23 @@
21
21
  },
22
22
  "devDependencies": {
23
23
  "@types/firefox-webext-browser": "^120.0.4",
24
- "@types/node": "^22.7.4",
24
+ "@types/node": "^22.10.1",
25
25
  "@types/sinon": "^17.0.3",
26
26
  "c8": "^10.1.2",
27
- "chai": "^5.1.1",
28
- "eslint": "^8.57.0",
29
- "eslint-config-standard": "^17.1.0",
30
- "eslint-plugin-import": "^2.30.0",
31
- "eslint-plugin-jsdoc": "^50.3.0",
32
- "eslint-plugin-regexp": "^2.6.0",
33
- "eslint-plugin-unicorn": "^55.0.0",
34
- "mocha": "^10.7.3",
35
- "npm-run-all": "^4.1.5",
36
- "typescript": "^5.6.2",
37
- "undici": "^6.19.8"
27
+ "eslint": "^9.15.0",
28
+ "eslint-plugin-import-x": "^4.4.3",
29
+ "eslint-plugin-jsdoc": "^50.6.0",
30
+ "eslint-plugin-regexp": "^2.7.0",
31
+ "eslint-plugin-unicorn": "^56.0.1",
32
+ "globals": "^15.12.0",
33
+ "mocha": "^10.8.2",
34
+ "neostandard": "^0.11.9",
35
+ "npm-run-all2": "^7.0.1",
36
+ "typescript": "^5.7.2",
37
+ "undici": "^7.0.0"
38
+ },
39
+ "overrides": {
40
+ "glob": "^10.4.5"
38
41
  },
39
42
  "scripts": {
40
43
  "build": "npm run tsc && npm run lint && npm run test",
@@ -54,5 +57,5 @@
54
57
  "update-mail": "node index update --channel=mail -i",
55
58
  "update-release": "node index update --channel=release -i"
56
59
  },
57
- "version": "5.4.3"
60
+ "version": "5.5.1"
58
61
  }