Registry / storage / webextensions-schema

webextensions-schema

JSON →
library0.5.1jsnpmunverified

Programmatically consume the WebExtensions Schema JSON files from Mozilla. Version 0.5.1, updated infrequently (last release February 2024). Ships TypeScript types. Defaults to latest stable schema, but can specify any tag from mozilla-unified. Schemas are cached locally. Differentiates from passive schema downloads by providing a simple programmatic API with namespace filtering.

npm install webextensions-schema
INSTALL
IMPORT
SIG · WEBEXTENSIONS-SCHE
W
webextensions-schema
storagejavascriptv0.5.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (webExtensionsSchema)
import webExtensionsSchema from 'webextensions-schema';
import * as webextensionsSchema from 'webextensions-schema';
The package has a default export (function).
webExtensionsSchema (with options)
const schema = await webExtensionsSchema({ tag: 'FIREFOX_126_0b9_RELEASE' });
const schema = webExtensionsSchema({ tag: 'FIREFOX_126_0b9_RELEASE' });
The function is async and must be awaited.
Raw and Namespace methods
import webExtensionsSchema from 'webextensions-schema'; const schema = await webExtensionsSchema(); const raw = schema.raw(); const namespaces = schema.namespaces();
Methods are synchronous after the initial async call.

Basic usage: install, import default function, call with options, use raw/namespaces/tag methods.

import webExtensionsSchema from 'webextensions-schema'; (async () => { const schema = await webExtensionsSchema(); console.log('Tag:', schema.tag()); console.log('Namespaces:', Object.keys(schema.namespaces())); // Access a specific namespace const tabs = schema.namespaces()['tabs']; if (tabs) { console.log('Tabs namespace functions:', tabs[0]?.functions?.length ?? 0); } })();
Debug
Known issues
gotchaDefault options fetch latest stable tag from Mozilla, which requires network access.
fix
If offline, provide a specific 'tag' option from the local .schemas directory.
affects: >=0.1.0
gotchaTag names must exactly match mozilla-unified tags (e.g., 'FIREFOX_126_0b9_RELEASE'), not 'FIREFOX_126'.
fix
Use the full tag string as seen on https://hg.mozilla.org/mozilla-unified/tags.
affects: >=0.1.0
gotchaThe returned schema object methods (raw, namespaces, tag) are synchronous, but the initial webExtensionsSchema() call is async.
fix
Always await the webExtensionsSchema() call before accessing methods.
affects: >=0.1.0
gotchaThe .schemas directory is gitignored except for shipped files. Downloaded schemas persist locally, but may conflict if multiple projects share the same node_modules.
fix
Use a unique tag or clear the .schemas directory if issues arise.
affects: >=0.1.0
deprecatedNo breaking changes announced, but the package may become stale if Mozilla changes schema format.
fix
Monitor the GitHub repo for updates; consider caching schema files in CI.
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: webExtensionsSchema is not a function
Using named import instead of default import.
fix
Use: import webExtensionsSchema from 'webextensions-schema';
Error: Could not fetch tag 'tip'. 'tip' is not allowed.
The tag 'tip' is explicitly forbidden as per documentation.
fix
Use a specific tag like 'FIREFOX_126_0b9_RELEASE' or omit options for latest stable.
Error: ENOENT: no such file or directory, open '.../.schemas/tabs.json'
The requested tag's schemas are not cached offline and network fetch failed.
fix
Ensure network access or use a tag that ships with the package (check .schemas directory).
Accessing schema.raw() before awaiting webExtensionsSchema() returns undefined.
webExtensionsSchema is async, but raw() is called synchronously.
fix
Ensure to await the async call: const schema = await webExtensionsSchema();
Upgrade
Version history
0.5.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
39 hits · last 30 days
node
34
Resources
webextensions-schema — npm install webextensions-schema · libregistry