gm-plugkit 2.0.2014 → 2.0.2016
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/package.json +1 -1
- package/plugkit-wasm-wrapper.js +48 -7
- package/plugkit.version +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gm-plugkit",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2016",
|
|
4
4
|
"description": "Bootstrap and daemon-spawn tool for gm plugkit binary. Downloads the correct platform binary, verifies SHA256, and starts the spool watcher daemon. Includes plugkit-wasm-wrapper for WASM-based spool watching.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
package/plugkit-wasm-wrapper.js
CHANGED
|
@@ -2564,6 +2564,9 @@ function makeHostFunctions(instanceRef) {
|
|
|
2564
2564
|
const __topNM = modeOpts.match(/topN=(\d+)/);
|
|
2565
2565
|
const sampleIntervalUs = __intervalM && parseInt(__intervalM[1], 10) > 0 ? parseInt(__intervalM[1], 10) : 100;
|
|
2566
2566
|
const profileTopNBrowser = __topNM && parseInt(__topNM[1], 10) > 0 ? parseInt(__topNM[1], 10) : 20;
|
|
2567
|
+
const rawUserScript = (screenshotPath || domSelector)
|
|
2568
|
+
? null
|
|
2569
|
+
: (modeMatch ? modeMatch[3] : evalBody);
|
|
2567
2570
|
// Real, pre-existing bug fixed here: this block previously called `page.evaluateOnNewDocument`,
|
|
2568
2571
|
// which is a PUPPETEER method name -- playwriter's `page` object is a real Playwright Page,
|
|
2569
2572
|
// whose equivalent is `page.addInitScript`. evaluateOnNewDocument does not exist on a
|
|
@@ -2772,13 +2775,51 @@ function makeHostFunctions(instanceRef) {
|
|
|
2772
2775
|
// A temp .js file has no such length limit -- this sidesteps the Bun bug class entirely rather
|
|
2773
2776
|
// than working around it script-by-script.
|
|
2774
2777
|
const scriptFile = path.join(os.tmpdir(), `gm-browser-eval-${process.pid}-${execProfileSeq++}.js`);
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2778
|
+
// The playwriter relay's attach+eval hop crashes with a UV_HANDLE_CLOSING native
|
|
2779
|
+
// assertion on Windows. When the session already has a live Chrome CDP endpoint
|
|
2780
|
+
// (chromium launched with --remote-debugging-port, recorded in browser-ports.json),
|
|
2781
|
+
// drive that endpoint directly via the proven wrapper/cdp-eval.js helper instead --
|
|
2782
|
+
// it connects over the DevTools websocket and runs the raw user script through
|
|
2783
|
+
// Runtime.evaluate, never spawning the crashing relay. This is gated strictly on a
|
|
2784
|
+
// live CDP port AND a self-contained raw user script (screenshot=/dom= bodies build
|
|
2785
|
+
// page.screenshot/page.evaluate calls that need the Playwright page object cdp-eval.js
|
|
2786
|
+
// does not provide, so rawUserScript is null for those and the playwriter path runs).
|
|
2787
|
+
let usedCdp = false;
|
|
2788
|
+
if (rawUserScript != null) {
|
|
2789
|
+
let cdpPort = null;
|
|
2790
|
+
let cdpWs = null;
|
|
2791
|
+
try {
|
|
2792
|
+
const ent = readJsonFile(browserPortsFile(cwd), {})[sessionId];
|
|
2793
|
+
if (ent && Number.isFinite(ent.port)) { cdpPort = ent.port; cdpWs = ent.wsEndpoint || null; }
|
|
2794
|
+
} catch (_) {}
|
|
2795
|
+
const cdpLive = cdpPort != null && !!fetchJsonSync(`http://127.0.0.1:${cdpPort}/json/version`, 1000);
|
|
2796
|
+
if (cdpLive) {
|
|
2797
|
+
const cdpEvalScript = path.join(os.tmpdir(), `gm-cdp-eval-${process.pid}-${execProfileSeq++}.js`);
|
|
2798
|
+
try {
|
|
2799
|
+
fs.writeFileSync(cdpEvalScript, rawUserScript, 'utf-8');
|
|
2800
|
+
const cfg = JSON.stringify({ port: cdpPort, wsEndpoint: cdpWs, startUrl, scriptFile: cdpEvalScript, resultFile, timeoutMs });
|
|
2801
|
+
r = spawnSync(process.execPath, [path.join(__dirname, 'wrapper', 'cdp-eval.js'), cfg], {
|
|
2802
|
+
encoding: 'utf-8',
|
|
2803
|
+
timeout: outerTimeoutMs,
|
|
2804
|
+
windowsHide: true,
|
|
2805
|
+
});
|
|
2806
|
+
usedCdp = true;
|
|
2807
|
+
} finally {
|
|
2808
|
+
try { fs.unlinkSync(cdpEvalScript); } catch (_) {}
|
|
2809
|
+
clearInflight(sessionId);
|
|
2810
|
+
stampBrowserLastUse(cwd, sessionId);
|
|
2811
|
+
}
|
|
2812
|
+
}
|
|
2813
|
+
}
|
|
2814
|
+
if (!usedCdp) {
|
|
2815
|
+
try {
|
|
2816
|
+
fs.writeFileSync(scriptFile, evalBody, 'utf-8');
|
|
2817
|
+
r = runBrowserRunner(pw, ['-s', pwSessionId, '--timeout', String(timeoutMs), '-f', scriptFile], outerTimeoutMs, cwd, sessionId);
|
|
2818
|
+
} finally {
|
|
2819
|
+
try { fs.unlinkSync(scriptFile); } catch (_) {}
|
|
2820
|
+
clearInflight(sessionId);
|
|
2821
|
+
stampBrowserLastUse(cwd, sessionId);
|
|
2822
|
+
}
|
|
2782
2823
|
}
|
|
2783
2824
|
const ok = r.status === 0;
|
|
2784
2825
|
if (!ok && r.status === null) {
|
package/plugkit.version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.1.
|
|
1
|
+
0.1.932
|