@pxlarified/browser 1.9.8 → 2.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/README.md +1 -1
- package/dist/extensions/firefox/openbrowser-dev.xpi +0 -0
- package/dist/extensions/firefox/openbrowser.xpi +0 -0
- package/dist/extensions/firefox/signed/8cfe45915b2d499ab5d0-2.0.1.xpi +0 -0
- package/extensions/manifest.json +1 -1
- package/package.json +7 -2
- package/src/browsers/firefox-family.js +54 -2
- package/src/browsers/zen.js +7 -0
- package/dist/extensions/firefox/signed/8cfe45915b2d499ab5d0-1.9.5.xpi +0 -0
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
<p align="center">
|
|
10
10
|
<img alt="Node.js" src="https://img.shields.io/badge/Node.js-%3E%3D20-339933?style=flat-square&logo=node.js&logoColor=white">
|
|
11
|
-
<img alt="Version" src="https://img.shields.io/badge/version-
|
|
11
|
+
<img alt="Version" src="https://img.shields.io/badge/version-2.0.1-blue?style=flat-square">
|
|
12
12
|
<img alt="Browser" src="https://img.shields.io/badge/browser-Zen-7F52FF?style=flat-square">
|
|
13
13
|
<img alt="Firefox Extension" src="https://img.shields.io/badge/Firefox-WebExtension-FF7139?style=flat-square&logo=firefoxbrowser&logoColor=white">
|
|
14
14
|
</p>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/extensions/manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pxlarified/browser",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "Minimal local browser-control CLI for OpenBrowser.",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/mizius-studios/OpenBrowser"
|
|
8
|
+
},
|
|
5
9
|
"type": "module",
|
|
6
10
|
"bin": {
|
|
7
|
-
"OpenBrowser": "
|
|
11
|
+
"OpenBrowser": "bin/OpenBrowser.js"
|
|
8
12
|
},
|
|
9
13
|
"scripts": {
|
|
10
14
|
"sync:version": "node scripts/sync-version.js",
|
|
11
15
|
"build": "node scripts/build.js firefox",
|
|
12
16
|
"build:firefox": "node scripts/build.js firefox",
|
|
17
|
+
"test": "node --test coverage/*.test.js",
|
|
13
18
|
"release:firefox": "node scripts/sign-firefox.js",
|
|
14
19
|
"prepack": "npm run build"
|
|
15
20
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import os from "node:os";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import { spawn } from "node:child_process";
|
|
4
|
+
import { execFileSync, spawn } from "node:child_process";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
import { EXTENSION_ID, FIREFOX_DEV_ARTIFACT, FIREFOX_SIGNED_ARTIFACT, NATIVE_HOST_NAME } from "../constants.js";
|
|
7
7
|
import { openBrowserHome, packageRoot } from "../util/paths.js";
|
|
@@ -13,6 +13,7 @@ export class FirefoxFamilyAdapter {
|
|
|
13
13
|
this.profileRoots = options.profileRoots;
|
|
14
14
|
this.launchCommands = options.launchCommands;
|
|
15
15
|
this.nativeManifestRoots = options.nativeManifestRoots;
|
|
16
|
+
this.processNames = options.processNames || [];
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
artifactPath() {
|
|
@@ -28,6 +29,11 @@ export class FirefoxFamilyAdapter {
|
|
|
28
29
|
throw new Error(`Missing Firefox extension artifact: ${artifact}. Run npm run build:firefox first.`);
|
|
29
30
|
}
|
|
30
31
|
|
|
32
|
+
const runningProcess = findRunningProcess(this.processNames);
|
|
33
|
+
if (runningProcess) {
|
|
34
|
+
throw new Error(`${this.displayName} must be closed before installing or updating the OpenBrowser extension. Close ${this.displayName} and run install again.`);
|
|
35
|
+
}
|
|
36
|
+
|
|
31
37
|
const nativeHost = installNativeHost(this.name);
|
|
32
38
|
const manifests = installNativeMessagingManifests(this.nativeManifestRoots, nativeHost);
|
|
33
39
|
const profiles = this.findProfiles();
|
|
@@ -52,7 +58,7 @@ export class FirefoxFamilyAdapter {
|
|
|
52
58
|
installedExtensions,
|
|
53
59
|
nativeHost,
|
|
54
60
|
nativeManifests: manifests,
|
|
55
|
-
note: "Extension install/update is staged in the profile.
|
|
61
|
+
note: "Extension install/update is staged in the profile. Start the browser to load it.",
|
|
56
62
|
};
|
|
57
63
|
}
|
|
58
64
|
|
|
@@ -86,6 +92,52 @@ export class FirefoxFamilyAdapter {
|
|
|
86
92
|
}
|
|
87
93
|
}
|
|
88
94
|
|
|
95
|
+
function findRunningProcess(processNames) {
|
|
96
|
+
if (processNames.length === 0) return null;
|
|
97
|
+
|
|
98
|
+
if (process.platform === "win32") return findRunningWindowsProcess(processNames);
|
|
99
|
+
return findRunningUnixProcess(processNames);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function findRunningUnixProcess(processNames) {
|
|
103
|
+
for (const processName of processNames) {
|
|
104
|
+
try {
|
|
105
|
+
execFileSync("pgrep", ["-x", processName], { stdio: "ignore" });
|
|
106
|
+
return processName;
|
|
107
|
+
} catch {
|
|
108
|
+
// Process is not running, or pgrep is unavailable. Try the next known name.
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function findRunningWindowsProcess(processNames) {
|
|
115
|
+
let output;
|
|
116
|
+
try {
|
|
117
|
+
output = execFileSync("tasklist", ["/fo", "csv", "/nh"], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] });
|
|
118
|
+
} catch {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const runningNames = new Set(output
|
|
123
|
+
.split(/\r?\n/)
|
|
124
|
+
.map((line) => parseTasklistImageName(line))
|
|
125
|
+
.filter(Boolean)
|
|
126
|
+
.map((name) => name.toLowerCase()));
|
|
127
|
+
|
|
128
|
+
for (const processName of processNames) {
|
|
129
|
+
const executable = processName.toLowerCase().endsWith(".exe") ? processName.toLowerCase() : `${processName.toLowerCase()}.exe`;
|
|
130
|
+
if (runningNames.has(executable)) return processName;
|
|
131
|
+
}
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function parseTasklistImageName(line) {
|
|
136
|
+
const match = line.match(/^"((?:[^"]|"")*)"/);
|
|
137
|
+
if (!match) return null;
|
|
138
|
+
return match[1].replace(/""/g, "\"");
|
|
139
|
+
}
|
|
140
|
+
|
|
89
141
|
function installNativeHost(browser) {
|
|
90
142
|
const source = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../native-host.cjs");
|
|
91
143
|
const dir = path.join(openBrowserHome(), "native-host");
|
package/src/browsers/zen.js
CHANGED
|
@@ -36,6 +36,12 @@ function platformNativeManifestRoots() {
|
|
|
36
36
|
return ["~/.mozilla", "~/.zen", "~/.zen-browser"];
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
function platformProcessNames() {
|
|
40
|
+
if (process.platform === "darwin") return ["Zen Browser", "Zen", "zen"];
|
|
41
|
+
if (process.platform === "win32") return ["zen", "zen-browser"];
|
|
42
|
+
return ["zen", "zen-bin", "zen-browser"];
|
|
43
|
+
}
|
|
44
|
+
|
|
39
45
|
function platformLaunchCommands() {
|
|
40
46
|
if (process.platform === "darwin") {
|
|
41
47
|
return [
|
|
@@ -65,6 +71,7 @@ export class ZenBrowserAdapter extends FirefoxFamilyAdapter {
|
|
|
65
71
|
profileRoots: platformProfileRoots(),
|
|
66
72
|
nativeManifestRoots: platformNativeManifestRoots(),
|
|
67
73
|
launchCommands: platformLaunchCommands(),
|
|
74
|
+
processNames: platformProcessNames(),
|
|
68
75
|
});
|
|
69
76
|
}
|
|
70
77
|
}
|
|
Binary file
|