opencode-next 1.0.1 → 1.0.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.
- package/lib/client.js +9 -2
- package/lib/ui.js +58 -0
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -22,8 +22,15 @@ export function canonicalSessionId(signal = '') {
|
|
|
22
22
|
if (typeof signal === 'string' && CANONICAL_SESSION_PATTERN.test(signal)) {
|
|
23
23
|
return signal;
|
|
24
24
|
}
|
|
25
|
-
const
|
|
26
|
-
|
|
25
|
+
const hasSignal = signal !== undefined && signal !== null && String(signal) !== '';
|
|
26
|
+
const seed = hasSignal ? String(signal) : `${Date.now()}:${Math.random()}`;
|
|
27
|
+
const sum = crypto.createHash("sha256").update("ses\0" + seed).digest();
|
|
28
|
+
// Deterministic epoch-bounded timestamp when a session signal is given, so the same session
|
|
29
|
+
// never drifts across 1ms clock boundaries between turns or tests.
|
|
30
|
+
const tsMs = hasSignal
|
|
31
|
+
? 1700000000000 + (sum.readUInt32BE(0) % 100000000000)
|
|
32
|
+
: Date.now();
|
|
33
|
+
return `ses_${invertedTimestampHex(tsMs)}${base62Fixed(BigInt("0x" + sum.subarray(6, 16).toString("hex")), 14)}`;
|
|
27
34
|
}
|
|
28
35
|
|
|
29
36
|
export function randomId(prefix = 'req', length = 16) {
|
package/lib/ui.js
CHANGED
|
@@ -4567,6 +4567,64 @@ window.__ModuleLoader__.load({
|
|
|
4567
4567
|
這樣無論宿主語言是什麼,那一行都是可預期的。 */
|
|
4568
4568
|
const navLabel = 'OpenCode-Next';
|
|
4569
4569
|
|
|
4570
|
+
// 設定左側導覽列圖示裝飾器:把 DSH 預設的齒輪圖示換成 OpenCode-Next 專屬標誌。
|
|
4571
|
+
const NAV_ICON_SVG =
|
|
4572
|
+
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="76 76 360 360" width="16" height="16" fill="none" data-ocn-nav="1" style="flex:none;vertical-align:middle;">' +
|
|
4573
|
+
'<defs>' +
|
|
4574
|
+
'<linearGradient id="ocn-nav-gRing" gradientUnits="userSpaceOnUse" x1="0" y1="158" x2="0" y2="354">' +
|
|
4575
|
+
'<stop offset="0" stop-color="#A8B5C8"/>' +
|
|
4576
|
+
'<stop offset="1" stop-color="#5B6B82"/>' +
|
|
4577
|
+
'</linearGradient>' +
|
|
4578
|
+
'<linearGradient id="ocn-nav-gChev" x1="0" y1="0" x2="1" y2="1">' +
|
|
4579
|
+
'<stop offset="0" stop-color="#06B6D4"/>' +
|
|
4580
|
+
'<stop offset="1" stop-color="#2563EB"/>' +
|
|
4581
|
+
'</linearGradient>' +
|
|
4582
|
+
'<mask id="ocn-nav-cut" maskUnits="userSpaceOnUse" x="0" y="0" width="512" height="512">' +
|
|
4583
|
+
'<rect width="512" height="512" fill="#fff"/>' +
|
|
4584
|
+
'<path d="M377.15 200.85 A78 78 0 1 0 377.15 311.15" fill="none" stroke="#000" stroke-width="64" stroke-linecap="round"/>' +
|
|
4585
|
+
'</mask>' +
|
|
4586
|
+
'</defs>' +
|
|
4587
|
+
'<g transform="translate(256 256) scale(1.12) translate(-256 -256)">' +
|
|
4588
|
+
'<g transform="translate(11 0)">' +
|
|
4589
|
+
'<circle cx="190" cy="256" r="78" fill="none" stroke="url(#ocn-nav-gRing)" stroke-width="40" mask="url(#ocn-nav-cut)"/>' +
|
|
4590
|
+
'<path d="M377.15 200.85 A78 78 0 1 0 377.15 311.15" fill="none" stroke="url(#ocn-nav-gRing)" stroke-width="40" stroke-linecap="round"/>' +
|
|
4591
|
+
'<path d="M334 234 L356 256 L334 278" fill="none" stroke="url(#ocn-nav-gChev)" stroke-width="16" stroke-linecap="round" stroke-linejoin="round"/>' +
|
|
4592
|
+
'</g>' +
|
|
4593
|
+
'</g>' +
|
|
4594
|
+
'</svg>';
|
|
4595
|
+
|
|
4596
|
+
function patchNavIcon() {
|
|
4597
|
+
if (typeof document === 'undefined' || typeof document.querySelector !== 'function') return;
|
|
4598
|
+
if (!document.querySelector('[role="dialog"]')) return;
|
|
4599
|
+
for (const span of document.querySelectorAll('span')) {
|
|
4600
|
+
if (span.textContent && span.textContent.trim() === navLabel) {
|
|
4601
|
+
const btn = span.closest('button');
|
|
4602
|
+
if (btn) {
|
|
4603
|
+
const svg = btn.querySelector('svg');
|
|
4604
|
+
if (svg && svg.dataset.ocnNav !== '1') {
|
|
4605
|
+
svg.outerHTML = NAV_ICON_SVG;
|
|
4606
|
+
}
|
|
4607
|
+
}
|
|
4608
|
+
}
|
|
4609
|
+
}
|
|
4610
|
+
}
|
|
4611
|
+
|
|
4612
|
+
if (typeof window !== 'undefined' && typeof window.setInterval === 'function') {
|
|
4613
|
+
const timer = window.setInterval(patchNavIcon, 400);
|
|
4614
|
+
const onClick = () => queueMicrotask(patchNavIcon);
|
|
4615
|
+
if (typeof document !== 'undefined' && typeof document.addEventListener === 'function') {
|
|
4616
|
+
document.addEventListener('click', onClick, true);
|
|
4617
|
+
}
|
|
4618
|
+
if (typeof ctx.effect === 'function') {
|
|
4619
|
+
ctx.effect(() => () => {
|
|
4620
|
+
window.clearInterval?.(timer);
|
|
4621
|
+
if (typeof document !== 'undefined' && typeof document.removeEventListener === 'function') {
|
|
4622
|
+
document.removeEventListener('click', onClick, true);
|
|
4623
|
+
}
|
|
4624
|
+
}, 'opencode-next: nav icon timer');
|
|
4625
|
+
}
|
|
4626
|
+
}
|
|
4627
|
+
|
|
4570
4628
|
ctx.slots.inject('settings.section', () =>
|
|
4571
4629
|
ctx.slots.register(
|
|
4572
4630
|
{
|