webext-schema
Advanced tools
Comparing version 5.4.3 to 5.5.0
@@ -42,3 +42,3 @@ /** | ||
* @param {string|Array} [id] - bookmark ID or array of bookmark IDs | ||
* @returns {Promise.<?Array>} - array of bookmarks.BookmarkTreeNode | ||
* @returns {Promise.<?Array.<object>>} - array of bookmarks.BookmarkTreeNode | ||
*/ | ||
@@ -186,3 +186,3 @@ export const getBookmarkTreeNode = async id => { | ||
* get all contextual identities | ||
* @returns {Promise.<?Array>} - array of contextualIdentities.ContextualIdentity | ||
* @returns {Promise.<?Array.<object>>} - array of contextualIdentities.ContextualIdentity | ||
*/ | ||
@@ -224,3 +224,3 @@ export const getAllContextualIdentities = async () => { | ||
* get enabled theme | ||
* @returns {Promise.<?Array>} - array of management.ExtensionInfo | ||
* @returns {Promise.<?Array.<object>>} - array of management.ExtensionInfo | ||
*/ | ||
@@ -264,3 +264,3 @@ export const getEnabledTheme = async () => { | ||
* get external extensions | ||
* @returns {Promise.<?Array|boolean>} - array of management.extensionInfo | ||
* @returns {Promise.<?Array.<object>>} - array of management.extensionInfo | ||
*/ | ||
@@ -476,3 +476,3 @@ export const getExternalExtensions = async () => { | ||
* @param {object} opt - options | ||
* @returns {Promise.<?Array|boolean>} - array of InjectionResult object | ||
* @returns {Promise.<?Array.<object>>} - array of InjectionResult object | ||
*/ | ||
@@ -505,2 +505,28 @@ export const executeScriptToTab = async (opt = {}) => { | ||
/** | ||
* search in new tab | ||
* @param {string} text - query string | ||
* @param {object} opt - create tab options | ||
* @returns {Promise.<object>} - tabs.Tab | ||
*/ | ||
export const searchInNewTab = async (text, opt) => { | ||
if (!isString(text)) { | ||
throw new TypeError(`Expected String but got ${getType(text)}.`); | ||
} | ||
const isGranted = await isPermissionGranted({ | ||
permissions: ['search'] | ||
}); | ||
let tab; | ||
if (isGranted) { | ||
const { search } = browser; | ||
const { id: tabId } = await tabs.create(isObjectNotEmpty(opt) ? opt : null); | ||
await search.query({ | ||
tabId, | ||
text | ||
}); | ||
tab = await tabs.get(tabId); | ||
} | ||
return tab ?? null; | ||
}; | ||
/** | ||
* search with a search engine | ||
@@ -741,3 +767,3 @@ * @param {string} query - search query | ||
* @param {object} opt - options | ||
* @returns {Promise.<?Array>} - result | ||
* @returns {Promise.<Array.<object>>} - array of tabs.Tab | ||
*/ | ||
@@ -862,3 +888,3 @@ export const queryTabs = async opt => { | ||
* @param {number} [windowId] - window ID | ||
* @returns {Promise.<?Array>} - array of tabs.Tab | ||
* @returns {Promise.<Array.<object>>} - array of tabs.Tab | ||
*/ | ||
@@ -879,3 +905,3 @@ export const getAllTabsInWindow = async windowId => { | ||
* @param {number} [windowId] - window ID | ||
* @returns {Promise.<?Array>} - array of tabs.Tab | ||
* @returns {Promise.<Array.<object>>} - array of tabs.Tab | ||
*/ | ||
@@ -935,3 +961,3 @@ export const getHighlightedTab = async windowId => { | ||
* @param {object} [opt] - options | ||
* @returns {Promise.<?Array>} - array of tabs.Tab | ||
* @returns {Promise.<?Array.<object>>} - array of tabs.Tab | ||
*/ | ||
@@ -1096,3 +1122,3 @@ export const moveTab = async (tabId, opt) => { | ||
* @param {boolean} populate - populate tabs | ||
* @returns {Promise.<Array>} - array of windows.Window | ||
* @returns {Promise.<Array.<object>>} - array of windows.Window | ||
*/ | ||
@@ -1099,0 +1125,0 @@ export const getAllNormalWindows = async (populate = false) => { |
@@ -58,2 +58,3 @@ /** | ||
* get target from namespace key | ||
* @private | ||
* @param {string} key - namespace key | ||
@@ -85,2 +86,3 @@ * @returns {object} - target object | ||
* assign imported values | ||
* @private | ||
* @returns {void} | ||
@@ -112,2 +114,3 @@ */ | ||
* assign referred values | ||
* @private | ||
* @returns {void} | ||
@@ -139,2 +142,3 @@ */ | ||
* mock events | ||
* @private | ||
* @param {object} target - target object | ||
@@ -165,2 +169,3 @@ * @param {Array} events - events | ||
* mock functions | ||
* @private | ||
* @param {object} target - target object | ||
@@ -188,2 +193,3 @@ * @param {Array} funcs - functions | ||
* mock properties | ||
* @private | ||
* @param {object} target - target object | ||
@@ -229,2 +235,3 @@ * @param {object} props - properties | ||
* mock types | ||
* @private | ||
* @param {object} target - target object | ||
@@ -267,2 +274,3 @@ * @param {Array} types - types | ||
* parse schema content | ||
* @private | ||
* @returns {object} - schema | ||
@@ -285,3 +293,3 @@ */ | ||
* @param {string} name - API name or file name | ||
* @returns {Array} - schema | ||
* @returns {?Array.<object>} - schema | ||
*/ | ||
@@ -316,3 +324,3 @@ get(name) { | ||
* list schemas | ||
* @returns {Array} - file list | ||
* @returns {Array.<string>} - file list | ||
*/ | ||
@@ -319,0 +327,0 @@ list() { |
/** | ||
* update.js | ||
*/ | ||
/* eslint-disable no-await-in-loop */ | ||
@@ -111,14 +112,19 @@ /* api */ | ||
* @param {string} baseUrl - base URL | ||
* @returns {Promise.<Array>} - schemas data in array | ||
* @param {boolean} info - console info | ||
* @returns {Promise.<Array.<object>>} - schemas data in array | ||
*/ | ||
export const getAllSchemaData = async baseUrl => { | ||
export const getAllSchemaData = async (baseUrl, info) => { | ||
if (!isString(baseUrl)) { | ||
throw new TypeError(`Expected String but got ${getType(baseUrl)}.`); | ||
} | ||
const schemas = []; | ||
const items = await getFileList(baseUrl); | ||
const func = []; | ||
for (const item of items) { | ||
func.push(getSchemaData(item, baseUrl)); | ||
if (info) { | ||
console.info(`Fetching ${item}`); | ||
} | ||
const schema = await getSchemaData(item, baseUrl); | ||
schemas.push(schema); | ||
} | ||
return Promise.all(func); | ||
return schemas; | ||
}; | ||
@@ -130,5 +136,6 @@ | ||
* @param {Array} arr - array of schema file names | ||
* @returns {Promise.<Array>} - schema data in array | ||
* @param {boolean} info - console info | ||
* @returns {Promise.<Array.<object>>} - schema data in array | ||
*/ | ||
export const getListedSchemaData = async (baseUrl, arr) => { | ||
export const getListedSchemaData = async (baseUrl, arr, info) => { | ||
if (!isString(baseUrl)) { | ||
@@ -140,7 +147,11 @@ throw new TypeError(`Expected String but got ${getType(baseUrl)}.`); | ||
} | ||
const func = []; | ||
const schemas = []; | ||
for (const item of arr) { | ||
func.push(getSchemaData(item, baseUrl)); | ||
if (info) { | ||
console.info(`Fetching ${item}`); | ||
} | ||
const schema = await getSchemaData(item, baseUrl); | ||
schemas.push(schema); | ||
} | ||
return Promise.all(func); | ||
return schemas; | ||
}; | ||
@@ -151,5 +162,6 @@ | ||
* @param {string} baseUrl - base URL | ||
* @returns {Promise.<Array>} - results of each handler | ||
* @param {boolean} info - console info | ||
* @returns {Promise.<Array.<object>>} - results of each handler | ||
*/ | ||
export const getMailExtSchemaData = async baseUrl => { | ||
export const getMailExtSchemaData = async (baseUrl, info) => { | ||
if (!isString(baseUrl)) { | ||
@@ -164,7 +176,13 @@ throw new TypeError(`Expected String but got ${getType(baseUrl)}.`); | ||
]; | ||
const func = []; | ||
const schemas = []; | ||
for (const item of items) { | ||
!excludeFile.includes(item) && func.push(getSchemaData(item, schemaUrl)); | ||
if (!excludeFile.includes(item)) { | ||
if (info) { | ||
console.info(`Fetching ${item}`); | ||
} | ||
const schema = await getSchemaData(item, schemaUrl); | ||
schemas.push(schema); | ||
} | ||
} | ||
return Promise.all(func); | ||
return schemas; | ||
}; | ||
@@ -175,5 +193,6 @@ | ||
* @param {string} channel - release channel | ||
* @param {boolean} info - console info | ||
* @returns {Promise.<object>} - schema | ||
*/ | ||
export const createUnifiedSchema = async channel => { | ||
export const createUnifiedSchema = async (channel, info) => { | ||
const channelUrl = getChannelUrl(channel); | ||
@@ -196,10 +215,12 @@ const schema = {}; | ||
arr = await Promise.all([ | ||
getListedSchemaData(browserBaseUrl, browserItems), | ||
getListedSchemaData(toolkitBaseUrl, toolkitItems), | ||
getMailExtSchemaData(`${channelUrl}mail/components/extensions/`) | ||
getListedSchemaData(browserBaseUrl, browserItems, info), | ||
getListedSchemaData(toolkitBaseUrl, toolkitItems, info), | ||
getMailExtSchemaData(`${channelUrl}mail/components/extensions/`, info) | ||
]); | ||
} else { | ||
arr = await Promise.all([ | ||
getAllSchemaData(`${channelUrl}browser/components/extensions/schemas/`), | ||
getAllSchemaData(`${channelUrl}toolkit/components/extensions/schemas/`) | ||
getAllSchemaData(`${channelUrl}browser/components/extensions/schemas/`, | ||
info), | ||
getAllSchemaData(`${channelUrl}toolkit/components/extensions/schemas/`, | ||
info) | ||
]); | ||
@@ -226,3 +247,3 @@ } | ||
} | ||
const schema = await createUnifiedSchema(channel); | ||
const schema = await createUnifiedSchema(channel, info); | ||
const content = `${JSON.stringify(schema, null, INDENT)}\n`; | ||
@@ -229,0 +250,0 @@ const fileName = channel === 'mail' ? 'mailext' : 'webext'; |
@@ -24,16 +24,17 @@ { | ||
"@types/firefox-webext-browser": "^120.0.4", | ||
"@types/node": "^22.7.4", | ||
"@types/node": "^22.8.2", | ||
"@types/sinon": "^17.0.3", | ||
"c8": "^10.1.2", | ||
"chai": "^5.1.1", | ||
"eslint": "^8.57.0", | ||
"eslint-config-standard": "^17.1.0", | ||
"eslint-plugin-import": "^2.30.0", | ||
"eslint-plugin-jsdoc": "^50.3.0", | ||
"chai": "^5.1.2", | ||
"eslint": "^9.13.0", | ||
"eslint-plugin-import-x": "^4.3.1", | ||
"eslint-plugin-jsdoc": "^50.4.3", | ||
"eslint-plugin-regexp": "^2.6.0", | ||
"eslint-plugin-unicorn": "^55.0.0", | ||
"eslint-plugin-unicorn": "^56.0.0", | ||
"globals": "^15.11.0", | ||
"mocha": "^10.7.3", | ||
"npm-run-all": "^4.1.5", | ||
"typescript": "^5.6.2", | ||
"undici": "^6.19.8" | ||
"neostandard": "^0.11.7", | ||
"npm-run-all2": "^7.0.1", | ||
"typescript": "^5.6.3", | ||
"undici": "^6.20.1" | ||
}, | ||
@@ -58,3 +59,3 @@ "scripts": { | ||
}, | ||
"version": "5.4.3" | ||
"version": "5.5.0" | ||
} |
@@ -15,3 +15,6 @@ { | ||
}, | ||
"include": ["index.js", "modules/browser.js"] | ||
"include": [ | ||
"index.js", | ||
"modules/browser.js" | ||
] | ||
} |
export function isPermissionGranted(perm: object): Promise<boolean>; | ||
export function createBookmark(opt: object): Promise<object>; | ||
export function getBookmarkTreeNode(id?: string | any[]): Promise<any[] | null>; | ||
export function getBookmarkTreeNode(id?: string | any[]): Promise<Array<object> | null>; | ||
export function getCloseTabsByDoubleClickValue(): Promise<object>; | ||
@@ -10,7 +10,7 @@ export function setContextMenuOnMouseup(): Promise<boolean>; | ||
export function updateCommand(id: string, value?: string): Promise<void | null>; | ||
export function getAllContextualIdentities(): Promise<any[] | null>; | ||
export function getAllContextualIdentities(): Promise<Array<object> | null>; | ||
export function getContextualId(cookieStoreId: string): Promise<object>; | ||
export function getEnabledTheme(): Promise<any[] | null>; | ||
export function getEnabledTheme(): Promise<Array<object> | null>; | ||
export function getExtensionInfo(id: string): Promise<object>; | ||
export function getExternalExtensions(): Promise<(any[] | boolean) | null>; | ||
export function getExternalExtensions(): Promise<Array<object> | null>; | ||
export function clearNotification(id: string): Promise<boolean | null>; | ||
@@ -26,3 +26,4 @@ export function createNotification(id: string, opt: object): Promise<string | null>; | ||
export function isScriptingAvailable(): Promise<boolean>; | ||
export function executeScriptToTab(opt?: object): Promise<(any[] | boolean) | null>; | ||
export function executeScriptToTab(opt?: object): Promise<Array<object> | null>; | ||
export function searchInNewTab(text: string, opt: object): Promise<object>; | ||
export function searchWithSearchEngine(query: string, opt?: object): Promise<void>; | ||
@@ -40,3 +41,3 @@ export function getRecentlyClosedTab(windowId?: number): Promise<object>; | ||
export function duplicateTab(tabId: number, opt: object): Promise<object>; | ||
export function queryTabs(opt: object): Promise<any[] | null>; | ||
export function queryTabs(opt: object): Promise<Array<object>>; | ||
export function execScriptToTab(tabId: number | object, opt?: object): Promise<(any[] | boolean) | null>; | ||
@@ -47,7 +48,7 @@ export function execScriptToTabs(opt?: object): Promise<any[]>; | ||
export function getActiveTabId(windowId?: number): Promise<number | null>; | ||
export function getAllTabsInWindow(windowId?: number): Promise<any[] | null>; | ||
export function getHighlightedTab(windowId?: number): Promise<any[] | null>; | ||
export function getAllTabsInWindow(windowId?: number): Promise<Array<object>>; | ||
export function getHighlightedTab(windowId?: number): Promise<Array<object>>; | ||
export function getTab(tabId: number): Promise<object>; | ||
export function highlightTab(index: number | any[], windowId?: number): Promise<object>; | ||
export function moveTab(tabId: number | any[], opt?: object): Promise<any[] | null>; | ||
export function moveTab(tabId: number | any[], opt?: object): Promise<Array<object> | null>; | ||
export function reloadTab(tabId: number, opt: object): Promise<void>; | ||
@@ -61,5 +62,5 @@ export function removeTab(arg: number | any[]): Promise<void>; | ||
export function createNewWindow(opt: object): Promise<object>; | ||
export function getAllNormalWindows(populate?: boolean): Promise<any[]>; | ||
export function getAllNormalWindows(populate?: boolean): Promise<Array<object>>; | ||
export function getCurrentWindow(opt: object): Promise<object>; | ||
export function getWindow(windowId: number, opt: object): Promise<object>; | ||
export function checkIncognitoWindowExists(): Promise<boolean>; |
@@ -12,13 +12,13 @@ export class Schema { | ||
get channel(): any; | ||
_getTargetFromNamespace(key: string): object; | ||
_assignImportMap(): void; | ||
_assignRefMap(): void; | ||
_mockEvents(target: object, events: any[]): object; | ||
_mockFunctions(target: object, funcs: any[]): object; | ||
_mockProperties(target: object, props: object, namespace: string): object; | ||
_mockTypes(target: object, types: any[], namespace: string): object; | ||
_parseSchemaContent(): object; | ||
get(name: string): any[]; | ||
private _getTargetFromNamespace; | ||
private _assignImportMap; | ||
private _assignRefMap; | ||
private _mockEvents; | ||
private _mockFunctions; | ||
private _mockProperties; | ||
private _mockTypes; | ||
private _parseSchemaContent; | ||
get(name: string): Array<object> | null; | ||
getAll(): object; | ||
list(): any[]; | ||
list(): Array<string>; | ||
mock(): object; | ||
@@ -25,0 +25,0 @@ #private; |
@@ -6,7 +6,7 @@ export const ESR_VER: 128; | ||
export function getFileList(baseUrl: string): Promise<Array<string>>; | ||
export function getAllSchemaData(baseUrl: string): Promise<any[]>; | ||
export function getListedSchemaData(baseUrl: string, arr: any[]): Promise<any[]>; | ||
export function getMailExtSchemaData(baseUrl: string): Promise<any[]>; | ||
export function createUnifiedSchema(channel: string): Promise<object>; | ||
export function getAllSchemaData(baseUrl: string, info: boolean): Promise<Array<object>>; | ||
export function getListedSchemaData(baseUrl: string, arr: any[], info: boolean): Promise<Array<object>>; | ||
export function getMailExtSchemaData(baseUrl: string, info: boolean): Promise<Array<object>>; | ||
export function createUnifiedSchema(channel: string, info: boolean): Promise<object>; | ||
export function saveSchemaFile(channel: string, info: boolean): Promise<string>; | ||
export function updateSchemas(cmdOpts?: object): Promise<void>; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3782127
105432
16