@phi-code-admin/browser 1.0.0 → 1.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/dist/index.js +39 -5
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -92,24 +92,58 @@ export async function ensureServer() {
|
|
|
92
92
|
stdio: ["ignore", "pipe", "pipe"],
|
|
93
93
|
detached: false,
|
|
94
94
|
});
|
|
95
|
-
// Surface
|
|
95
|
+
// Surface child stderr so the user can see crash reasons. Once the
|
|
96
|
+
// server has become healthy we go quiet again unless
|
|
97
|
+
// PHI_BROWSER_VERBOSE=1 is set. Boot-time crashes ALWAYS print —
|
|
98
|
+
// otherwise a silent E22-style "failed to become healthy" exception
|
|
99
|
+
// is unsurmountable from the consumer side.
|
|
100
|
+
const stderrTail = [];
|
|
101
|
+
let healthy = false;
|
|
96
102
|
child.stderr?.on("data", (chunk) => {
|
|
97
|
-
|
|
98
|
-
|
|
103
|
+
const text = chunk.toString();
|
|
104
|
+
if (!healthy || process.env.PHI_BROWSER_VERBOSE) {
|
|
105
|
+
process.stderr.write(`[camofox] ${text}`);
|
|
99
106
|
}
|
|
107
|
+
stderrTail.push(text);
|
|
108
|
+
while (stderrTail.length > 200)
|
|
109
|
+
stderrTail.shift();
|
|
100
110
|
});
|
|
101
111
|
child.on("exit", (code) => {
|
|
102
112
|
serverProcess = null;
|
|
103
113
|
serverPort = null;
|
|
104
114
|
bootPromise = null;
|
|
105
|
-
if (process.env.PHI_BROWSER_VERBOSE) {
|
|
115
|
+
if (!healthy || process.env.PHI_BROWSER_VERBOSE) {
|
|
106
116
|
process.stderr.write(`[camofox] server exited with code ${code}\n`);
|
|
107
117
|
}
|
|
108
118
|
});
|
|
119
|
+
// Expose stderr tail through a wrapper that promotes the listener
|
|
120
|
+
// flip — needed below when waitForHealth resolves.
|
|
121
|
+
child.__markHealthy = () => {
|
|
122
|
+
healthy = true;
|
|
123
|
+
};
|
|
124
|
+
child.__stderrTail = stderrTail;
|
|
109
125
|
serverProcess = child;
|
|
110
126
|
serverPort = port;
|
|
111
127
|
const baseUrl = `http://127.0.0.1:${port}`;
|
|
112
|
-
|
|
128
|
+
try {
|
|
129
|
+
await waitForHealth(baseUrl);
|
|
130
|
+
child.__markHealthy?.();
|
|
131
|
+
}
|
|
132
|
+
catch (err) {
|
|
133
|
+
// Augment the health-check error with whatever the child wrote to
|
|
134
|
+
// stderr so the consumer has at least one breadcrumb to follow.
|
|
135
|
+
const tail = (child.__stderrTail ?? [])
|
|
136
|
+
.join("")
|
|
137
|
+
.split(/\r?\n/)
|
|
138
|
+
.filter(Boolean)
|
|
139
|
+
.slice(-20)
|
|
140
|
+
.join("\n");
|
|
141
|
+
const original = err instanceof Error ? err.message : String(err);
|
|
142
|
+
const augmented = new Error(tail
|
|
143
|
+
? `${original}\nLast stderr lines from camofox-browser child:\n${tail}`
|
|
144
|
+
: `${original}\n(no stderr captured — set PHI_BROWSER_VERBOSE=1 for more)`);
|
|
145
|
+
throw augmented;
|
|
146
|
+
}
|
|
113
147
|
return { baseUrl };
|
|
114
148
|
})();
|
|
115
149
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phi-code-admin/browser",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Phi-code browser automation API: lazy-start the bundled Camoufox + camofox-browser server and expose 10 high-level tools (navigate, extract, screenshot, click, type, scroll, snapshot, search, close_tab, list_tabs) as plain ES module functions. Zero external dependencies at runtime.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"clean": "rimraf dist"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@phi-code-admin/camofox-browser": "1.0.
|
|
41
|
+
"@phi-code-admin/camofox-browser": "1.0.1",
|
|
42
42
|
"@phi-code-admin/camoufox-js": "1.0.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|