heybash-xdpool 1.0.4 → 1.0.5
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/CHANGELOG.md +5 -0
- package/lib/client.js +47 -62
- package/package.json +2 -1
- package/tools/sync-npmmirror.mjs +16 -3
package/CHANGELOG.md
CHANGED
package/lib/client.js
CHANGED
|
@@ -6,6 +6,7 @@ window.__ModuleLoader__.load({
|
|
|
6
6
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
7
7
|
let react = require("react");
|
|
8
8
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
|
+
let react_dom = require("react-dom");
|
|
9
10
|
// src/client/sidebar-row.ts
|
|
10
11
|
/**
|
|
11
12
|
* The `sidebarRow` switch, read and written from one place.
|
|
@@ -1797,8 +1798,8 @@ window.__ModuleLoader__.load({
|
|
|
1797
1798
|
.dsm-xdpool-dot:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#5686fe);outline-offset:3px}
|
|
1798
1799
|
/* Measured coordinates, not flow: the composer sits at the bottom of the viewport, so a
|
|
1799
1800
|
panel laid out downward would be clipped. */
|
|
1800
|
-
.dsm-xdpool-dotpanel{position:fixed;z-index:80;width:max-content;min-width:172px;max-width:min(280px,calc(100vw -
|
|
1801
|
-
@keyframes dsm-xdpool-dotpanel-in{from{opacity:0
|
|
1801
|
+
.dsm-xdpool-dotpanel{position:fixed;z-index:80;box-sizing:border-box;width:max-content;min-width:min(172px,calc(100vw - 16px));max-width:min(280px,calc(100vw - 16px));max-height:calc(100vh - 16px);overflow-y:auto;display:flex;flex-direction:column;gap:7px;padding:10px 12px 11px;border-radius:14px;border:1px solid color-mix(in srgb, var(--dsw-alias-border-l2,#ffffff1f) 92%, transparent);background:var(--dsw-alias-bg-layer-2,#1c1e22);box-shadow:0 18px 48px rgb(0 0 0 / 44%),0 3px 10px rgb(0 0 0 / 24%),inset 0 1px 0 rgb(255 255 255 / 7%);animation:dsm-xdpool-dotpanel-in .16s cubic-bezier(.16,1,.3,1)}
|
|
1802
|
+
@keyframes dsm-xdpool-dotpanel-in{from{opacity:0}to{opacity:1}}
|
|
1802
1803
|
.dsm-xdpool-dotpanel-head{display:flex;align-items:center;gap:8px;min-width:0}
|
|
1803
1804
|
.dsm-xdpool-dotpanel-channel{font-size:12.5px;font-weight:600;letter-spacing:.01em;color:var(--dsw-alias-label-primary,#e8eaf0);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}
|
|
1804
1805
|
.dsm-xdpool-dotpanel-chip{margin-left:auto;padding:1px 8px;border-radius:999px;font-size:10px;line-height:16px;font-weight:500}
|
|
@@ -13294,7 +13295,7 @@ window.__ModuleLoader__.load({
|
|
|
13294
13295
|
}
|
|
13295
13296
|
// src/version.ts
|
|
13296
13297
|
/** Version embedded in the browser bundle at build time from the package manifest. */
|
|
13297
|
-
const POOL_VERSION = "1.0.
|
|
13298
|
+
const POOL_VERSION = "1.0.5";
|
|
13298
13299
|
// src/client/PoolCard.tsx
|
|
13299
13300
|
/**
|
|
13300
13301
|
* Heybash card contributed to DSH Plugin configuration.
|
|
@@ -15821,6 +15822,19 @@ window.__ModuleLoader__.load({
|
|
|
15821
15822
|
*
|
|
15822
15823
|
* @module dsh-xdpool/client/credit-strip
|
|
15823
15824
|
*/
|
|
15825
|
+
// src/client/credit-position.ts
|
|
15826
|
+
/** Position a measured panel above its trigger, flipping and clamping at viewport edges. */
|
|
15827
|
+
function creditPanelPosition(anchor, panel, viewport) {
|
|
15828
|
+
const margin = 8;
|
|
15829
|
+
const left = Math.min(Math.max(margin, anchor.left + anchor.width / 2 - panel.width / 2), Math.max(margin, viewport.width - panel.width - margin));
|
|
15830
|
+
const above = anchor.top - panel.height - margin;
|
|
15831
|
+
const below = anchor.bottom + margin;
|
|
15832
|
+
const preferAbove = above >= margin || anchor.top >= viewport.height - anchor.bottom;
|
|
15833
|
+
return {
|
|
15834
|
+
top: Math.min(Math.max(margin, preferAbove ? above : below), Math.max(margin, viewport.height - panel.height - margin)),
|
|
15835
|
+
left
|
|
15836
|
+
};
|
|
15837
|
+
}
|
|
15824
15838
|
// src/client/nav-icon.ts
|
|
15825
15839
|
/**
|
|
15826
15840
|
* Nav glyph for the Heybash settings page.
|
|
@@ -15913,10 +15927,8 @@ window.__ModuleLoader__.load({
|
|
|
15913
15927
|
*
|
|
15914
15928
|
* POSITIONING AND DISMISSAL ARE DONE HERE
|
|
15915
15929
|
*
|
|
15916
|
-
* The
|
|
15917
|
-
*
|
|
15918
|
-
* Escape. That is the same contract the host's meters use, implemented locally rather
|
|
15919
|
-
* than depending on a module this bundle cannot import.
|
|
15930
|
+
* The panel is portaled to the document body so transformed or clipping composer
|
|
15931
|
+
* ancestors cannot change the coordinate system of its fixed position.
|
|
15920
15932
|
*
|
|
15921
15933
|
* @module dsh-xdpool/client/CreditDot
|
|
15922
15934
|
*/
|
|
@@ -16154,69 +16166,42 @@ window.__ModuleLoader__.load({
|
|
|
16154
16166
|
observer.disconnect();
|
|
16155
16167
|
};
|
|
16156
16168
|
}, []);
|
|
16157
|
-
/**
|
|
16158
|
-
* Place the panel above the dot.
|
|
16159
|
-
*
|
|
16160
|
-
* Measured rather than CSS-anchored because the composer row can be at the bottom of
|
|
16161
|
-
* the viewport, and a panel that opens downward would be clipped by it. `side: top`
|
|
16162
|
-
* with a viewport clamp is the same rule the host's own meters follow.
|
|
16163
|
-
*/
|
|
16169
|
+
/** Keep body-relative panel and viewport-relative anchor in the same coordinate space. */
|
|
16164
16170
|
(0, react.useLayoutEffect)(() => {
|
|
16165
16171
|
if (!open) {
|
|
16166
16172
|
setPos(void 0);
|
|
16167
16173
|
return;
|
|
16168
16174
|
}
|
|
16169
16175
|
const anchor = anchorRef.current;
|
|
16170
|
-
if (anchor === null) return;
|
|
16171
|
-
const box = anchor.getBoundingClientRect();
|
|
16172
|
-
/**
|
|
16173
|
-
* The panel sizes to its content (`width: max-content`), so its width can only be
|
|
16174
|
-
* read AFTER it has rendered. A hard-coded number here was what made a short line of
|
|
16175
|
-
* text sit in a 300px box: the width came from this layout maths rather than from
|
|
16176
|
-
* what the text needed. Measuring the element keeps the two in step.
|
|
16177
|
-
*
|
|
16178
|
-
* Falling back to 200 when the ref is not attached yet (first frame) is safe: the
|
|
16179
|
-
* effect re-runs on `open`, and the panel is `visibility: hidden` until `pos` exists.
|
|
16180
|
-
*/
|
|
16181
|
-
const width = panelRef.current?.offsetWidth ?? 200;
|
|
16182
|
-
const margin = 8;
|
|
16183
|
-
const left = Math.min(Math.max(margin, box.left + box.width / 2 - width / 2), Math.max(margin, window.innerWidth - width - margin));
|
|
16184
|
-
const panelHeight = panelRef.current?.offsetHeight ?? 240;
|
|
16185
|
-
const above = box.top - panelHeight - 8;
|
|
16186
|
-
const top = above >= margin ? above : box.bottom + 8;
|
|
16187
|
-
setPos({
|
|
16188
|
-
top,
|
|
16189
|
-
left
|
|
16190
|
-
});
|
|
16191
|
-
}, [open]);
|
|
16192
|
-
/**
|
|
16193
|
-
* Re-measure once the panel has painted.
|
|
16194
|
-
*
|
|
16195
|
-
* `width: max-content` means the first pass measures a zero-width element: the panel is
|
|
16196
|
-
* attached but `pos` is still undefined, so it is laid out at its min-width. Re-running
|
|
16197
|
-
* after the content exists is what makes the width follow the text rather than the
|
|
16198
|
-
* placeholder. Keyed on the model and the channel so a longer name (a real possibility
|
|
16199
|
-
* with a `· 14,031` suffix) triggers a fresh measurement.
|
|
16200
|
-
*/
|
|
16201
|
-
(0, react.useLayoutEffect)(() => {
|
|
16202
|
-
if (!open) return;
|
|
16203
|
-
const anchor = anchorRef.current;
|
|
16204
16176
|
const panel = panelRef.current;
|
|
16205
16177
|
if (anchor === null || panel === null) return;
|
|
16206
|
-
|
|
16207
|
-
const
|
|
16208
|
-
|
|
16209
|
-
|
|
16210
|
-
|
|
16211
|
-
|
|
16212
|
-
|
|
16213
|
-
|
|
16214
|
-
if (current.top === top && current.left === left) return current;
|
|
16215
|
-
return {
|
|
16178
|
+
let frame;
|
|
16179
|
+
const update = () => {
|
|
16180
|
+
frame = void 0;
|
|
16181
|
+
const { left, top } = creditPanelPosition(anchor.getBoundingClientRect(), panel.getBoundingClientRect(), {
|
|
16182
|
+
width: window.innerWidth,
|
|
16183
|
+
height: window.innerHeight
|
|
16184
|
+
});
|
|
16185
|
+
setPos((current) => current?.top === top && current.left === left ? current : {
|
|
16216
16186
|
top,
|
|
16217
16187
|
left
|
|
16218
|
-
};
|
|
16219
|
-
}
|
|
16188
|
+
});
|
|
16189
|
+
};
|
|
16190
|
+
const schedule = () => {
|
|
16191
|
+
if (frame === void 0) frame = window.requestAnimationFrame(update);
|
|
16192
|
+
};
|
|
16193
|
+
update();
|
|
16194
|
+
const observer = typeof ResizeObserver === "undefined" ? void 0 : new ResizeObserver(schedule);
|
|
16195
|
+
observer?.observe(anchor);
|
|
16196
|
+
observer?.observe(panel);
|
|
16197
|
+
window.addEventListener("resize", schedule);
|
|
16198
|
+
window.addEventListener("scroll", schedule, true);
|
|
16199
|
+
return () => {
|
|
16200
|
+
observer?.disconnect();
|
|
16201
|
+
window.removeEventListener("resize", schedule);
|
|
16202
|
+
window.removeEventListener("scroll", schedule, true);
|
|
16203
|
+
if (frame !== void 0) window.cancelAnimationFrame(frame);
|
|
16204
|
+
};
|
|
16220
16205
|
}, [
|
|
16221
16206
|
open,
|
|
16222
16207
|
snapshot?.model,
|
|
@@ -16290,7 +16275,7 @@ window.__ModuleLoader__.load({
|
|
|
16290
16275
|
"aria-hidden": "true"
|
|
16291
16276
|
})
|
|
16292
16277
|
}),
|
|
16293
|
-
!open ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
16278
|
+
!open || typeof document === "undefined" ? null : (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
16294
16279
|
ref: panelRef,
|
|
16295
16280
|
className: "dsm-xdpool-dotpanel",
|
|
16296
16281
|
role: "dialog",
|
|
@@ -16358,7 +16343,7 @@ window.__ModuleLoader__.load({
|
|
|
16358
16343
|
})
|
|
16359
16344
|
}) : null
|
|
16360
16345
|
] })]
|
|
16361
|
-
})
|
|
16346
|
+
}), document.body)
|
|
16362
16347
|
]
|
|
16363
16348
|
});
|
|
16364
16349
|
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "heybash-xdpool",
|
|
3
3
|
"displayName": "Heybash",
|
|
4
4
|
"description": "Heybash model pool for DeepSeek Harness: account rotation, provider aggregation, routing chains, usage insights and a local OpenAI-compatible gateway.",
|
|
5
|
-
"version": "1.0.
|
|
5
|
+
"version": "1.0.5",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "Heybash",
|
|
8
8
|
"contributors": [
|
|
@@ -101,6 +101,7 @@
|
|
|
101
101
|
"@types/react": "~18.3.31",
|
|
102
102
|
"@types/react-dom": "~18.3.0",
|
|
103
103
|
"react": "^18.2.0",
|
|
104
|
+
"react-dom": "^18.3.1",
|
|
104
105
|
"tsdown": "^0.23.0",
|
|
105
106
|
"typescript": "^7.0.2",
|
|
106
107
|
"vite": "8.3.0",
|
package/tools/sync-npmmirror.mjs
CHANGED
|
@@ -41,11 +41,15 @@ async function retry(label, action, { attempts, intervalMs, sleep, log }) {
|
|
|
41
41
|
*/
|
|
42
42
|
export async function syncMirror({
|
|
43
43
|
version, fetchImpl = fetch, sleep = delay, log = console.log,
|
|
44
|
-
attempts = 24, intervalMs = 10_000, syncAttempts = 3,
|
|
44
|
+
attempts = 24, officialAttempts = attempts * 2, intervalMs = 10_000, syncAttempts = 3,
|
|
45
45
|
} = {}) {
|
|
46
46
|
if (version !== undefined && !VERSION.test(version)) throw new Error('Invalid target version')
|
|
47
47
|
const options = { attempts, intervalMs, sleep, log }
|
|
48
|
-
|
|
48
|
+
// Match npm/pnpm's metadata representation. The mirror can cache its
|
|
49
|
+
// generic */* representation separately from the package-manager response.
|
|
50
|
+
const read = async (url) => (await request(fetchImpl, url, {
|
|
51
|
+
headers: { accept: 'application/json' },
|
|
52
|
+
})).json()
|
|
49
53
|
const official = await retry('Waiting for npm', async () => {
|
|
50
54
|
const data = await read(NPM)
|
|
51
55
|
const target = version ?? data['dist-tags']?.latest
|
|
@@ -53,7 +57,7 @@ export async function syncMirror({
|
|
|
53
57
|
const checksum = data.versions?.[target]?.dist?.shasum
|
|
54
58
|
if (typeof checksum !== 'string' || !/^[a-f0-9]{40}$/u.test(checksum)) throw new Error(`npm ${target} is not yet available with a checksum`)
|
|
55
59
|
return { target, checksum, latest: data['dist-tags']?.latest }
|
|
56
|
-
}, options)
|
|
60
|
+
}, { ...options, attempts: officialAttempts })
|
|
57
61
|
log(`npm target ${official.target}; latest ${official.latest}`)
|
|
58
62
|
|
|
59
63
|
const verify = async (download = false) => {
|
|
@@ -109,6 +113,15 @@ export async function syncMirror({
|
|
|
109
113
|
} catch (error) {
|
|
110
114
|
lastError = error
|
|
111
115
|
log(`Mirror synchronization attempt ${attempt + 1}/${syncAttempts} failed: ${error instanceof Error ? error.message : String(error)}`)
|
|
116
|
+
// A sync task can fail or time out after another worker already updated
|
|
117
|
+
// the mirror. Verify the artifact before submitting a redundant task.
|
|
118
|
+
try {
|
|
119
|
+
const target = await verify(true)
|
|
120
|
+
log(`Mirror serves ${target} with the correct checksum`)
|
|
121
|
+
return { version: target, synced: true }
|
|
122
|
+
} catch {
|
|
123
|
+
// Still unavailable: proceed with the bounded retry below.
|
|
124
|
+
}
|
|
112
125
|
if (attempt + 1 < syncAttempts) await sleep(intervalMs)
|
|
113
126
|
}
|
|
114
127
|
}
|