extension 3.1.0-next.7 → 3.1.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/README.md +1 -1
- package/dist/check-updates.d.ts +1 -1
- package/dist/cli-package-json.d.ts +1 -0
- package/dist/cli.js +43 -15
- package/package.json +3 -3
- package/types/extension-develop-shim.d.ts +18 -0
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
|
|
20
20
|
- [Create a new extension](#create-a-new-extension) — How to create a new extension.
|
|
21
21
|
- [Watch demo](#watch-demo) — See how creating a new extension works.
|
|
22
|
-
- [Start from an example](https://github.com/extension-js/
|
|
22
|
+
- [Start from an example](https://github.com/extension-js/examples) — Start from a working baseline.
|
|
23
23
|
- [I have an extension](#i-have-an-extension) — Use only specific parts of Extension.js.
|
|
24
24
|
|
|
25
25
|
Create cross-browser extensions without manual build configuration.<br />Use Extension.js to develop, build, and preview across browsers with a unified workflow.
|
package/dist/check-updates.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function checkUpdates(
|
|
1
|
+
export default function checkUpdates(): Promise<string | null>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getCliPackageJson(): Record<string, any>;
|
package/dist/cli.js
CHANGED
|
@@ -23,7 +23,6 @@ var __webpack_require__ = {};
|
|
|
23
23
|
})();
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
const external_commander_namespaceObject = require("commander");
|
|
26
|
-
var package_namespaceObject = JSON.parse('{"license":"MIT","repository":{"type":"git","url":"git+https://github.com/extension-js/extension.js.git","directory":"programs/cli"},"engines":{"node":">=18"},"exports":{".":{"types":"./dist/cli.d.ts","import":"./dist/cli.js","require":"./dist/cli.js"}},"main":"./dist/cli.js","types":"./dist/cli.d.ts","typesVersions":{"*":{"types":["./types/index.d.ts"],"types/*":["./types/*"]}},"files":["dist","types"],"bin":{"extension":"./dist/cli.js"},"name":"extension","version":"3.1.0-next.7","description":"Create cross-browser extensions with no build configuration.","homepage":"https://extension.js.org/","bugs":{"url":"https://github.com/extension-js/extension.js/issues"},"author":{"name":"Cezar Augusto","email":"boss@cezaraugusto.net","url":"https://cezaraugusto.com"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org"},"scripts":{"prepublishOnly":"pnpm run compile","compile":"rslib build","watch":"rslib build --watch","test":"vitest run"},"keywords":["zero-config","build","develop","browser","extension","chrome extension","edge extension","firefox extension","safari extension","web","react","typescript","webextension","browser-extension","chrome-extension","firefox-addon","edge-extension","safari-web-extension","manifest-v3","mv3","cross-browser","content-script","background-script","devtools","create-extension","scaffold","starter-template","boilerplate","cli"],"dependencies":{"extension-create":"^3.1.0-next.7","extension-develop":"^3.1.0-next.7","commander":"^14.0.2","pintor":"0.3.0","semver":"^7.7.3","update-check":"^1.5.4"},"devDependencies":{"@rslib/core":"^0.19.2","@types/chrome":"^0.1.33","@types/node":"^25.0.9","@types/react":"^19.2.8","@types/react-dom":"^19.2.3","@types/webextension-polyfill":"0.12.4","@types/mock-fs":"^4.13.4","@types/semver":"^7.7.1","mock-fs":"^5.5.0","webextension-polyfill":"^0.12.0","tsconfig":"*","typescript":"5.9.3","vitest":"^4.0.17"}}');
|
|
27
26
|
const external_update_check_namespaceObject = require("update-check");
|
|
28
27
|
var external_update_check_default = /*#__PURE__*/ __webpack_require__.n(external_update_check_namespaceObject);
|
|
29
28
|
const external_pintor_namespaceObject = require("pintor");
|
|
@@ -156,7 +155,7 @@ ${external_pintor_default().underline('Path Resolution (important)')}
|
|
|
156
155
|
|
|
157
156
|
|
|
158
157
|
AI Assistants
|
|
159
|
-
- For AI-oriented guidance and
|
|
158
|
+
- For AI-oriented guidance and deeper tips, run ${code('extension --ai-help')}
|
|
160
159
|
|
|
161
160
|
Report issues
|
|
162
161
|
- ${external_pintor_default().underline('https://github.com/cezaraugusto/extension/issues/new')}`;
|
|
@@ -271,7 +270,7 @@ Source Inspection & Real-Time Monitoring
|
|
|
271
270
|
- Watch mode is enabled by default when ${code('--source')} is present
|
|
272
271
|
- Automatically enables Chrome remote debugging (port 9222) when source inspection is active
|
|
273
272
|
- Extracts Shadow DOM content from ${code('#extension-root')} or ${code('[data-extension-root=\"true\"]')} elements
|
|
274
|
-
-
|
|
273
|
+
- Useful for debugging content script behavior and style injection
|
|
275
274
|
- Example: ${code('extension dev --source=' + arg('https://example.com'))}
|
|
276
275
|
|
|
277
276
|
Non-Destructive Testing in CI
|
|
@@ -300,18 +299,39 @@ Cross-Browser Compatibility
|
|
|
300
299
|
- Supports Chrome, Edge, Firefox with single codebase`;
|
|
301
300
|
}
|
|
302
301
|
const external_semver_namespaceObject = require("semver");
|
|
302
|
+
const external_node_fs_namespaceObject = require("node:fs");
|
|
303
|
+
var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
|
|
304
|
+
const external_node_path_namespaceObject = require("node:path");
|
|
305
|
+
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
306
|
+
let cachedPackageJson = null;
|
|
307
|
+
function getCliPackageJson() {
|
|
308
|
+
if (cachedPackageJson) return cachedPackageJson;
|
|
309
|
+
const candidates = [
|
|
310
|
+
external_node_path_default().resolve(__dirname, 'package.json'),
|
|
311
|
+
external_node_path_default().resolve(__dirname, '..', 'package.json')
|
|
312
|
+
];
|
|
313
|
+
for (const candidate of candidates)if (external_node_fs_default().existsSync(candidate)) {
|
|
314
|
+
const content = external_node_fs_default().readFileSync(candidate, 'utf8');
|
|
315
|
+
const parsed = JSON.parse(content);
|
|
316
|
+
cachedPackageJson = parsed;
|
|
317
|
+
return parsed;
|
|
318
|
+
}
|
|
319
|
+
throw new Error('Extension.js CLI package.json not found.');
|
|
320
|
+
}
|
|
303
321
|
function isStableVersion(version) {
|
|
304
322
|
const v = external_semver_namespaceObject.parse(version);
|
|
305
323
|
return Boolean(v && 0 === v.prerelease.length);
|
|
306
324
|
}
|
|
307
|
-
async function check_updates_checkUpdates(
|
|
325
|
+
async function check_updates_checkUpdates() {
|
|
326
|
+
const packageJson = getCliPackageJson();
|
|
308
327
|
let update = null;
|
|
309
328
|
try {
|
|
310
329
|
update = await external_update_check_default()(packageJson);
|
|
311
330
|
} catch (err) {
|
|
312
331
|
if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.error(updateFailed(err));
|
|
313
332
|
}
|
|
314
|
-
if (update && isStableVersion(update.latest))
|
|
333
|
+
if (update && isStableVersion(update.latest)) return checkUpdates(packageJson, update);
|
|
334
|
+
return null;
|
|
315
335
|
}
|
|
316
336
|
const external_fs_namespaceObject = require("fs");
|
|
317
337
|
var external_fs_default = /*#__PURE__*/ __webpack_require__.n(external_fs_namespaceObject);
|
|
@@ -319,10 +339,6 @@ const external_path_namespaceObject = require("path");
|
|
|
319
339
|
var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
|
|
320
340
|
const external_node_os_namespaceObject = require("node:os");
|
|
321
341
|
var external_node_os_default = /*#__PURE__*/ __webpack_require__.n(external_node_os_namespaceObject);
|
|
322
|
-
const external_node_fs_namespaceObject = require("node:fs");
|
|
323
|
-
var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
|
|
324
|
-
const external_node_path_namespaceObject = require("node:path");
|
|
325
|
-
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
326
342
|
const external_node_crypto_namespaceObject = require("node:crypto");
|
|
327
343
|
var external_node_crypto_default = /*#__PURE__*/ __webpack_require__.n(external_node_crypto_namespaceObject);
|
|
328
344
|
function _define_property(obj, key, value) {
|
|
@@ -450,7 +466,7 @@ class Telemetry {
|
|
|
450
466
|
this.track('cli_telemetry_consent', {
|
|
451
467
|
value: 'implicit_opt_in'
|
|
452
468
|
});
|
|
453
|
-
console.log(`${external_pintor_default().gray('►►►
|
|
469
|
+
console.log(`${external_pintor_default().gray('►►►')} Telemetry is enabled for Extension.js. To opt out, run with --no-telemetry. Learn more in TELEMETRY.md.`);
|
|
454
470
|
}
|
|
455
471
|
}
|
|
456
472
|
}
|
|
@@ -513,7 +529,7 @@ function findManifestJson(projectRoot) {
|
|
|
513
529
|
}
|
|
514
530
|
const telemetry_cli_telemetry = new Telemetry({
|
|
515
531
|
app: 'extension',
|
|
516
|
-
version:
|
|
532
|
+
version: getCliPackageJson().version,
|
|
517
533
|
disabled: telemetryDisabled
|
|
518
534
|
});
|
|
519
535
|
if (!telemetryDisabled) {
|
|
@@ -593,7 +609,7 @@ function validateVendorsOrExit(vendorsList, onInvalid) {
|
|
|
593
609
|
}
|
|
594
610
|
}
|
|
595
611
|
function registerCreateCommand(program, telemetry) {
|
|
596
|
-
program.command('create').arguments('<project-name|project-path>').usage('create <project-name|project-path> [options]').description(commandDescriptions.create).option('-t, --template <template-name>', 'specify a template for the created project').option('--install [boolean]', 'whether or not to install the dependencies after creating the project (
|
|
612
|
+
program.command('create').arguments('<project-name|project-path>').usage('create <project-name|project-path> [options]').description(commandDescriptions.create).option('-t, --template <template-name>', 'specify a template for the created project').option('--install [boolean]', 'whether or not to install the dependencies after creating the project (enabled by default)', parseOptionalBoolean, true).action(async function(pathOrRemoteUrl, { template, install }) {
|
|
597
613
|
const startedAt = Date.now();
|
|
598
614
|
telemetry.track('cli_command_start', {
|
|
599
615
|
command: 'create',
|
|
@@ -602,10 +618,16 @@ function registerCreateCommand(program, telemetry) {
|
|
|
602
618
|
});
|
|
603
619
|
try {
|
|
604
620
|
const { extensionCreate } = await import("extension-create");
|
|
621
|
+
const { ensureDependencies } = await import("extension-develop");
|
|
622
|
+
const projectPath = external_path_namespaceObject.isAbsolute(pathOrRemoteUrl) ? pathOrRemoteUrl : external_path_namespaceObject.join(process.cwd(), pathOrRemoteUrl);
|
|
605
623
|
await extensionCreate(pathOrRemoteUrl, {
|
|
606
624
|
template,
|
|
607
625
|
install,
|
|
608
|
-
cliVersion:
|
|
626
|
+
cliVersion: getCliPackageJson().version
|
|
627
|
+
});
|
|
628
|
+
if (install) await ensureDependencies(projectPath, {
|
|
629
|
+
skipProjectInstall: true,
|
|
630
|
+
showRunAgainMessage: false
|
|
609
631
|
});
|
|
610
632
|
telemetry.track('cli_command_finish', {
|
|
611
633
|
command: 'create',
|
|
@@ -882,9 +904,15 @@ function registerBuildCommand(program, telemetry) {
|
|
|
882
904
|
});
|
|
883
905
|
});
|
|
884
906
|
}
|
|
885
|
-
|
|
907
|
+
const cliPackageJson = getCliPackageJson();
|
|
908
|
+
process.env.EXTENSION_CLI_VERSION = cliPackageJson.version;
|
|
909
|
+
check_updates_checkUpdates().then((updateMessage)=>{
|
|
910
|
+
if (!updateMessage) return;
|
|
911
|
+
if ('true' === process.env.EXTENSION_CLI_BANNER_PRINTED) return void console.log(updateMessage);
|
|
912
|
+
process.env.EXTENSION_CLI_UPDATE_MESSAGE = updateMessage;
|
|
913
|
+
});
|
|
886
914
|
const extensionJs = external_commander_namespaceObject.program;
|
|
887
|
-
extensionJs.name(
|
|
915
|
+
extensionJs.name(cliPackageJson.name).description(cliPackageJson.description).version(cliPackageJson.version).option('--no-telemetry', 'disable anonymous telemetry for this run').option('--ai-help', 'show AI-assistant oriented help and tips').addHelpText('after', programUserHelp()).showHelpAfterError(true).showSuggestionAfterError(true);
|
|
888
916
|
registerCreateCommand(extensionJs, telemetry_cli_telemetry);
|
|
889
917
|
registerDevCommand(extensionJs, telemetry_cli_telemetry);
|
|
890
918
|
registerStartCommand(extensionJs, telemetry_cli_telemetry);
|
package/package.json
CHANGED
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"extension": "./dist/cli.js"
|
|
36
36
|
},
|
|
37
37
|
"name": "extension",
|
|
38
|
-
"version": "3.1.
|
|
38
|
+
"version": "3.1.1",
|
|
39
39
|
"description": "Create cross-browser extensions with no build configuration.",
|
|
40
40
|
"homepage": "https://extension.js.org/",
|
|
41
41
|
"bugs": {
|
|
@@ -88,8 +88,8 @@
|
|
|
88
88
|
"cli"
|
|
89
89
|
],
|
|
90
90
|
"dependencies": {
|
|
91
|
-
"extension-create": "^3.1.
|
|
92
|
-
"extension-develop": "^3.1.
|
|
91
|
+
"extension-create": "^3.1.1",
|
|
92
|
+
"extension-develop": "^3.1.1",
|
|
93
93
|
"commander": "^14.0.2",
|
|
94
94
|
"pintor": "0.3.0",
|
|
95
95
|
"semver": "^7.7.3",
|
|
@@ -82,4 +82,22 @@ declare module 'extension-develop' {
|
|
|
82
82
|
pathOrRemoteUrl: string,
|
|
83
83
|
options: PreviewOptions
|
|
84
84
|
): Promise<any>
|
|
85
|
+
|
|
86
|
+
export function ensureDependencies(
|
|
87
|
+
projectPath?: string,
|
|
88
|
+
opts?: {
|
|
89
|
+
skipProjectInstall?: boolean
|
|
90
|
+
exitOnInstall?: boolean
|
|
91
|
+
showRunAgainMessage?: boolean
|
|
92
|
+
}
|
|
93
|
+
): Promise<{
|
|
94
|
+
installed: boolean
|
|
95
|
+
installedBuild: boolean
|
|
96
|
+
installedUser: boolean
|
|
97
|
+
}>
|
|
98
|
+
|
|
99
|
+
export function preflightOptionalDependenciesForProject(
|
|
100
|
+
pathOrRemoteUrl: string,
|
|
101
|
+
mode?: ExtensionMode
|
|
102
|
+
): Promise<void>
|
|
85
103
|
}
|