pi-chrome 0.11.1 → 0.11.2
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"manifest_version": 3,
|
|
3
3
|
"name": "Pi Chrome Connector",
|
|
4
|
-
"version": "0.11.
|
|
4
|
+
"version": "0.11.2",
|
|
5
5
|
"description": "Lets Pi control tabs in Chrome via a local connector at 127.0.0.1.",
|
|
6
6
|
"permissions": ["tabs", "scripting", "storage", "activeTab", "alarms", "webNavigation", "debugger"],
|
|
7
7
|
"host_permissions": ["<all_urls>", "http://127.0.0.1:17318/*"],
|
|
@@ -367,19 +367,20 @@ async function trustedScroll(params) {
|
|
|
367
367
|
const x = resolved.rect ? resolved.rect.left + Math.min(resolved.rect.width, 800) / 2 : resolved.x;
|
|
368
368
|
const y = resolved.rect ? resolved.rect.top + Math.min(resolved.rect.height, 600) / 2 : resolved.y;
|
|
369
369
|
const totalY = params.deltaY || 0, totalX = params.deltaX || 0;
|
|
370
|
-
//
|
|
371
|
-
//
|
|
372
|
-
const MAX_STEP =
|
|
373
|
-
const
|
|
374
|
-
|
|
375
|
-
//
|
|
370
|
+
// Per-event delta cap so IntersectionObserver / scroll-driven animations get gradient samples.
|
|
371
|
+
// A real wheel notch is ~50-120px; we aim for the lower end so visibility transitions are visible.
|
|
372
|
+
const MAX_STEP = 60;
|
|
373
|
+
const peak = Math.max(Math.abs(totalY), Math.abs(totalX));
|
|
374
|
+
// We weight events with mild front-loading. The peak weight = 1.5 / n (vs uniform 1/n), so the
|
|
375
|
+
// first event is ~1.5× average. Choose n so even the peak event stays under MAX_STEP.
|
|
376
|
+
const minN = Math.ceil(peak * 1.5 / MAX_STEP);
|
|
377
|
+
const n = Math.max(6, Math.min(80, params.steps || Math.max(minN, 12)));
|
|
378
|
+
// Front-loaded but smooth weights: w[i] = 1 + 0.5 * (1 - i/(n-1)) so the first event has
|
|
379
|
+
// weight 1.5, the last has 1.0, average ~1.25; redistribution stays predictable.
|
|
376
380
|
const w = [];
|
|
377
381
|
for (let i = 0; i < n; i++) {
|
|
378
382
|
const t = i / Math.max(1, n - 1);
|
|
379
|
-
|
|
380
|
-
const base = Math.sin(Math.min(1, t * 1.4) * Math.PI);
|
|
381
|
-
const decay = Math.pow(1 - t * 0.6, 2);
|
|
382
|
-
w.push(0.2 + base * 0.8 * decay);
|
|
383
|
+
w.push(1 + 0.5 * (1 - t));
|
|
383
384
|
}
|
|
384
385
|
const sumW = w.reduce((a, b) => a + b, 0);
|
|
385
386
|
for (let i = 0; i < n; i++) {
|
|
@@ -387,8 +388,8 @@ async function trustedScroll(params) {
|
|
|
387
388
|
await cdp(tab.id, "Input.dispatchMouseEvent", {
|
|
388
389
|
type: "mouseWheel", x, y, deltaX: dx, deltaY: dy, pointerType: "mouse",
|
|
389
390
|
});
|
|
390
|
-
// Sleep
|
|
391
|
-
await sleep(rng(22,
|
|
391
|
+
// Sleep one+ frame so IntersectionObserver / rAF samples can run between events.
|
|
392
|
+
await sleep(rng(22, 48));
|
|
392
393
|
}
|
|
393
394
|
return { trusted: true, deltaX: totalX, deltaY: totalY, steps: n };
|
|
394
395
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-chrome",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.2",
|
|
4
4
|
"description": "Drive your existing logged-in Chrome from Pi — no re-login, no throwaway profile, watch the agent work in real time (or toggle quiet background mode).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|