@deepseek-ai/dsh-client-ui-trajectory 0.2.1-alpha.1 → 0.2.1-alpha.3
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/README.i18n.yaml +6 -6
- package/README.md +5 -3
- package/README.zh.md +5 -3
- package/lib/client.js +82 -1263
- package/lib/types/client/TrajectoryTable.d.ts +6 -3
- package/lib/types/client/TrajectoryView.d.ts +1 -1
- package/lib/types/client/locales.d.ts +1 -1
- package/lib/types/client/trajectory-contract.d.ts +7 -3
- package/lib/types/client/trajectory-record.d.ts +1 -1
- package/locale/en.json +5 -0
- package/locale/zh.json +6 -0
- package/package.json +25 -25
package/lib/client.js
CHANGED
|
@@ -4,33 +4,10 @@ window.__ModuleLoader__.load({
|
|
|
4
4
|
var module = { exports: {} };
|
|
5
5
|
var exports = module.exports;
|
|
6
6
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
7
|
-
//#region \0rolldown/runtime.js
|
|
8
|
-
var __create = Object.create;
|
|
9
|
-
var __defProp = Object.defineProperty;
|
|
10
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
11
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
12
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
13
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
-
var __copyProps = (to, from, except, desc) => {
|
|
15
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
16
|
-
key = keys[i];
|
|
17
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
18
|
-
get: ((k) => from[k]).bind(null, key),
|
|
19
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
return to;
|
|
23
|
-
};
|
|
24
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
25
|
-
value: mod,
|
|
26
|
-
enumerable: true
|
|
27
|
-
}) : target, mod));
|
|
28
|
-
//#endregion
|
|
29
7
|
let _deepseek_ai_dsh_client_store = require("@deepseek-ai/dsh-client-store");
|
|
30
8
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
31
9
|
let react = require("react");
|
|
32
|
-
|
|
33
|
-
let react_dom = require("react-dom");
|
|
10
|
+
let _tanstack_react_virtual = require("@tanstack/react-virtual");
|
|
34
11
|
let _deepseek_ai_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
35
12
|
//#region lib/types/client/duration-store.js
|
|
36
13
|
/**
|
|
@@ -211,9 +188,9 @@ window.__ModuleLoader__.load({
|
|
|
211
188
|
"details.toolCalls": "工具调用",
|
|
212
189
|
"details.subtoolCalls": "子工具调用",
|
|
213
190
|
"details.error": "错误",
|
|
191
|
+
"details.lastAttemptError": "上次尝试错误",
|
|
214
192
|
"details.failure.auth": "API 密钥无效",
|
|
215
193
|
"details.retry": "重试",
|
|
216
|
-
"details.scheduled": "已计划",
|
|
217
194
|
"details.retryDelay": "重试延迟",
|
|
218
195
|
"details.result": "结果",
|
|
219
196
|
"details.compacted": "已压缩",
|
|
@@ -406,9 +383,9 @@ window.__ModuleLoader__.load({
|
|
|
406
383
|
"details.toolCalls": "Tool calls",
|
|
407
384
|
"details.subtoolCalls": "Subtool calls",
|
|
408
385
|
"details.error": "Error",
|
|
386
|
+
"details.lastAttemptError": "Last attempt error",
|
|
409
387
|
"details.failure.auth": "API key is invalid",
|
|
410
388
|
"details.retry": "Retry",
|
|
411
|
-
"details.scheduled": "Scheduled",
|
|
412
389
|
"details.retryDelay": "Retry delay",
|
|
413
390
|
"details.result": "Result",
|
|
414
391
|
"details.compacted": "Compacted",
|
|
@@ -1334,7 +1311,6 @@ window.__ModuleLoader__.load({
|
|
|
1334
1311
|
startSeq,
|
|
1335
1312
|
startTime,
|
|
1336
1313
|
started,
|
|
1337
|
-
sawChunk: false,
|
|
1338
1314
|
blocks: [],
|
|
1339
1315
|
visibleBlocks: 0,
|
|
1340
1316
|
firstVisibleSeq: void 0,
|
|
@@ -1377,7 +1353,6 @@ window.__ModuleLoader__.load({
|
|
|
1377
1353
|
function updateChunk(state, chunk, seq, time) {
|
|
1378
1354
|
if (chunk.type === "usage") return {
|
|
1379
1355
|
...state,
|
|
1380
|
-
sawChunk: true,
|
|
1381
1356
|
usage: addUsage$1(state.usage, chunk.usage)
|
|
1382
1357
|
};
|
|
1383
1358
|
const blocks = [...state.blocks];
|
|
@@ -1432,15 +1407,11 @@ window.__ModuleLoader__.load({
|
|
|
1432
1407
|
previousVisible = blockIsVisible(blocks[chunk.index]);
|
|
1433
1408
|
blocks[chunk.index] = toAssistantBlock(chunk.block);
|
|
1434
1409
|
break;
|
|
1435
|
-
default: return
|
|
1436
|
-
...state,
|
|
1437
|
-
sawChunk: true
|
|
1438
|
-
};
|
|
1410
|
+
default: return state;
|
|
1439
1411
|
}
|
|
1440
1412
|
const visibleBlocks = state.visibleBlocks - Number(previousVisible) + Number(blockIsVisible(blocks[changedIndex]));
|
|
1441
1413
|
return {
|
|
1442
1414
|
...state,
|
|
1443
|
-
sawChunk: true,
|
|
1444
1415
|
blocks,
|
|
1445
1416
|
visibleBlocks,
|
|
1446
1417
|
...visibleBlocks > 0 && state.firstVisibleSeq === void 0 ? {
|
|
@@ -1461,7 +1432,6 @@ window.__ModuleLoader__.load({
|
|
|
1461
1432
|
const blocks = toAssistantBlocks(event.data.message.content);
|
|
1462
1433
|
return {
|
|
1463
1434
|
...settleTiming(state, event),
|
|
1464
|
-
sawChunk: false,
|
|
1465
1435
|
blocks,
|
|
1466
1436
|
visibleBlocks: countVisibleBlocks(blocks),
|
|
1467
1437
|
final: match,
|
|
@@ -1535,7 +1505,7 @@ window.__ModuleLoader__.load({
|
|
|
1535
1505
|
}
|
|
1536
1506
|
function assistantRequest(state, node, boundary) {
|
|
1537
1507
|
if (!state.started) return void 0;
|
|
1538
|
-
const status = node !== void 0
|
|
1508
|
+
const status = node !== void 0 ? node.interrupted === true ? "error" : "complete" : boundary !== void 0 ? "error" : "running";
|
|
1539
1509
|
return {
|
|
1540
1510
|
purpose: "assistant",
|
|
1541
1511
|
startSeq: state.startSeq,
|
|
@@ -1612,10 +1582,14 @@ window.__ModuleLoader__.load({
|
|
|
1612
1582
|
if (state === void 0) return null;
|
|
1613
1583
|
const node = finalNode(state, context);
|
|
1614
1584
|
const boundary = closedBoundary(context);
|
|
1615
|
-
const partial = node === void 0 && boundary === void 0 && state.
|
|
1585
|
+
const partial = node === void 0 && boundary === void 0 && state.blocks.length > 0 ? {
|
|
1616
1586
|
turn: state.turn,
|
|
1617
1587
|
step: state.step,
|
|
1618
|
-
blocks: compactBlocks(state.blocks)
|
|
1588
|
+
blocks: compactBlocks(state.blocks),
|
|
1589
|
+
timing: {
|
|
1590
|
+
stepStartTime: state.started ? state.startTime : null,
|
|
1591
|
+
firstTokenTime: state.firstTokenTime ?? null
|
|
1592
|
+
}
|
|
1619
1593
|
} : null;
|
|
1620
1594
|
const request = assistantRequest(state, node, boundary);
|
|
1621
1595
|
if (node === void 0 && partial === null && request === void 0) return null;
|
|
@@ -2360,6 +2334,7 @@ window.__ModuleLoader__.load({
|
|
|
2360
2334
|
},
|
|
2361
2335
|
callTime: previous === void 0 || "kind" in previous ? null : previous.time,
|
|
2362
2336
|
content: data.content ?? [],
|
|
2337
|
+
meta: data.meta,
|
|
2363
2338
|
isError: data.isError === true,
|
|
2364
2339
|
...data.error === void 0 ? {} : { error: data.error },
|
|
2365
2340
|
subCalls: []
|
|
@@ -2540,1183 +2515,6 @@ window.__ModuleLoader__.load({
|
|
|
2540
2515
|
ctx.uiConversation.events.register(trajectoryToolDefinition);
|
|
2541
2516
|
}
|
|
2542
2517
|
//#endregion
|
|
2543
|
-
//#region ../../../node_modules/.pnpm/@tanstack+virtual-core@3.17.7/node_modules/@tanstack/virtual-core/dist/esm/lazy-measurements.js
|
|
2544
|
-
function createLazyMeasurementsView(count, flat, getItemKey) {
|
|
2545
|
-
const cache = new Array(count);
|
|
2546
|
-
return new Proxy(cache, { get(target, prop, receiver) {
|
|
2547
|
-
if (typeof prop === "string") {
|
|
2548
|
-
const c = prop.charCodeAt(0);
|
|
2549
|
-
if (c >= 48 && c <= 57) {
|
|
2550
|
-
const i = +prop;
|
|
2551
|
-
if (Number.isInteger(i) && i >= 0 && i < count) {
|
|
2552
|
-
let v = target[i];
|
|
2553
|
-
if (!v) {
|
|
2554
|
-
const s = flat[i * 2];
|
|
2555
|
-
v = target[i] = {
|
|
2556
|
-
index: i,
|
|
2557
|
-
key: getItemKey(i),
|
|
2558
|
-
start: s,
|
|
2559
|
-
size: flat[i * 2 + 1],
|
|
2560
|
-
end: s + flat[i * 2 + 1],
|
|
2561
|
-
lane: 0
|
|
2562
|
-
};
|
|
2563
|
-
}
|
|
2564
|
-
return v;
|
|
2565
|
-
}
|
|
2566
|
-
}
|
|
2567
|
-
if (prop === "length") return count;
|
|
2568
|
-
}
|
|
2569
|
-
return Reflect.get(target, prop, receiver);
|
|
2570
|
-
} });
|
|
2571
|
-
}
|
|
2572
|
-
//#endregion
|
|
2573
|
-
//#region ../../../node_modules/.pnpm/@tanstack+virtual-core@3.17.7/node_modules/@tanstack/virtual-core/dist/esm/utils.js
|
|
2574
|
-
function memo$1(getDeps, fn, opts) {
|
|
2575
|
-
let deps = opts.initialDeps ?? [];
|
|
2576
|
-
let result;
|
|
2577
|
-
let isInitial = true;
|
|
2578
|
-
function memoizedFunction() {
|
|
2579
|
-
const newDeps = getDeps();
|
|
2580
|
-
if (!(newDeps.length !== deps.length || newDeps.some((dep, index) => deps[index] !== dep))) return result;
|
|
2581
|
-
deps = newDeps;
|
|
2582
|
-
result = fn(...newDeps);
|
|
2583
|
-
if ((opts == null ? void 0 : opts.onChange) && !(isInitial && opts.skipInitialOnChange)) opts.onChange(result);
|
|
2584
|
-
isInitial = false;
|
|
2585
|
-
return result;
|
|
2586
|
-
}
|
|
2587
|
-
memoizedFunction.updateDeps = (newDeps) => {
|
|
2588
|
-
deps = newDeps;
|
|
2589
|
-
};
|
|
2590
|
-
return memoizedFunction;
|
|
2591
|
-
}
|
|
2592
|
-
function notUndefined(value, msg) {
|
|
2593
|
-
if (value === void 0) throw new Error(`Unexpected undefined${msg ? `: ${msg}` : ""}`);
|
|
2594
|
-
else return value;
|
|
2595
|
-
}
|
|
2596
|
-
const approxEqual = (a, b) => Math.abs(a - b) < 1.01;
|
|
2597
|
-
const debounce = (targetWindow, fn, ms) => {
|
|
2598
|
-
let timeoutId;
|
|
2599
|
-
return function(...args) {
|
|
2600
|
-
targetWindow.clearTimeout(timeoutId);
|
|
2601
|
-
timeoutId = targetWindow.setTimeout(() => fn.apply(this, args), ms);
|
|
2602
|
-
};
|
|
2603
|
-
};
|
|
2604
|
-
//#endregion
|
|
2605
|
-
//#region ../../../node_modules/.pnpm/@tanstack+virtual-core@3.17.7/node_modules/@tanstack/virtual-core/dist/esm/index.js
|
|
2606
|
-
let _isIOSResult;
|
|
2607
|
-
const isIOSWebKit = () => {
|
|
2608
|
-
if (_isIOSResult !== void 0) return _isIOSResult;
|
|
2609
|
-
if (typeof navigator === "undefined") return _isIOSResult = false;
|
|
2610
|
-
if (/iP(hone|od|ad)/.test(navigator.userAgent)) return _isIOSResult = true;
|
|
2611
|
-
const mtp = navigator.maxTouchPoints;
|
|
2612
|
-
return _isIOSResult = navigator.platform === "MacIntel" && mtp !== void 0 && mtp > 0;
|
|
2613
|
-
};
|
|
2614
|
-
const getRect = (element) => {
|
|
2615
|
-
const { offsetWidth, offsetHeight } = element;
|
|
2616
|
-
return {
|
|
2617
|
-
width: offsetWidth,
|
|
2618
|
-
height: offsetHeight
|
|
2619
|
-
};
|
|
2620
|
-
};
|
|
2621
|
-
const defaultKeyExtractor = (index) => index;
|
|
2622
|
-
const defaultRangeExtractor = (range) => {
|
|
2623
|
-
const start = Math.max(range.startIndex - range.overscan, 0);
|
|
2624
|
-
const len = Math.min(range.endIndex + range.overscan, range.count - 1) - start + 1;
|
|
2625
|
-
const arr = new Array(len);
|
|
2626
|
-
for (let i = 0; i < len; i++) arr[i] = start + i;
|
|
2627
|
-
return arr;
|
|
2628
|
-
};
|
|
2629
|
-
const observeElementRect = (instance, cb) => {
|
|
2630
|
-
const element = instance.scrollElement;
|
|
2631
|
-
if (!element) return;
|
|
2632
|
-
const targetWindow = instance.targetWindow;
|
|
2633
|
-
if (!targetWindow) return;
|
|
2634
|
-
const handler = (rect) => {
|
|
2635
|
-
const { width, height } = rect;
|
|
2636
|
-
cb({
|
|
2637
|
-
width: Math.round(width),
|
|
2638
|
-
height: Math.round(height)
|
|
2639
|
-
});
|
|
2640
|
-
};
|
|
2641
|
-
handler(getRect(element));
|
|
2642
|
-
if (!targetWindow.ResizeObserver) return () => {};
|
|
2643
|
-
const observer = new targetWindow.ResizeObserver((entries) => {
|
|
2644
|
-
const run = () => {
|
|
2645
|
-
const entry = entries[0];
|
|
2646
|
-
if (entry == null ? void 0 : entry.borderBoxSize) {
|
|
2647
|
-
const box = entry.borderBoxSize[0];
|
|
2648
|
-
if (box) {
|
|
2649
|
-
handler({
|
|
2650
|
-
width: box.inlineSize,
|
|
2651
|
-
height: box.blockSize
|
|
2652
|
-
});
|
|
2653
|
-
return;
|
|
2654
|
-
}
|
|
2655
|
-
}
|
|
2656
|
-
handler(getRect(element));
|
|
2657
|
-
};
|
|
2658
|
-
instance.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(run) : run();
|
|
2659
|
-
});
|
|
2660
|
-
observer.observe(element, { box: "border-box" });
|
|
2661
|
-
return () => {
|
|
2662
|
-
observer.unobserve(element);
|
|
2663
|
-
};
|
|
2664
|
-
};
|
|
2665
|
-
const addEventListenerOptions = { passive: true };
|
|
2666
|
-
const supportsScrollend = typeof window == "undefined" ? true : "onscrollend" in window;
|
|
2667
|
-
const observeOffset = (instance, cb, readOffset) => {
|
|
2668
|
-
const element = instance.scrollElement;
|
|
2669
|
-
if (!element) return;
|
|
2670
|
-
const targetWindow = instance.targetWindow;
|
|
2671
|
-
if (!targetWindow) return;
|
|
2672
|
-
const registerScrollendEvent = instance.options.useScrollendEvent && supportsScrollend;
|
|
2673
|
-
let offset = 0;
|
|
2674
|
-
const fallback = registerScrollendEvent ? null : debounce(targetWindow, () => cb(offset, false), instance.options.isScrollingResetDelay);
|
|
2675
|
-
const createHandler = (isScrolling) => () => {
|
|
2676
|
-
offset = readOffset(element);
|
|
2677
|
-
fallback?.();
|
|
2678
|
-
cb(offset, isScrolling);
|
|
2679
|
-
};
|
|
2680
|
-
const handler = createHandler(true);
|
|
2681
|
-
const endHandler = createHandler(false);
|
|
2682
|
-
element.addEventListener("scroll", handler, addEventListenerOptions);
|
|
2683
|
-
if (registerScrollendEvent) element.addEventListener("scrollend", endHandler, addEventListenerOptions);
|
|
2684
|
-
return () => {
|
|
2685
|
-
element.removeEventListener("scroll", handler);
|
|
2686
|
-
if (registerScrollendEvent) element.removeEventListener("scrollend", endHandler);
|
|
2687
|
-
};
|
|
2688
|
-
};
|
|
2689
|
-
const observeElementOffset = (instance, cb) => observeOffset(instance, cb, (el) => {
|
|
2690
|
-
const { horizontal, isRtl } = instance.options;
|
|
2691
|
-
return horizontal ? el.scrollLeft * (isRtl && -1 || 1) : el.scrollTop;
|
|
2692
|
-
});
|
|
2693
|
-
const measureElement = (element, entry, instance) => {
|
|
2694
|
-
if (instance.options.useCachedMeasurements) {
|
|
2695
|
-
const index = instance.indexFromElement(element);
|
|
2696
|
-
const key = instance.options.getItemKey(index);
|
|
2697
|
-
return instance.itemSizeCache.get(key) ?? instance.options.estimateSize(index);
|
|
2698
|
-
}
|
|
2699
|
-
if (entry == null ? void 0 : entry.borderBoxSize) {
|
|
2700
|
-
const box = entry.borderBoxSize[0];
|
|
2701
|
-
if (box) return Math.round(box[instance.options.horizontal ? "inlineSize" : "blockSize"]);
|
|
2702
|
-
}
|
|
2703
|
-
if (!entry) {
|
|
2704
|
-
const index = instance.indexFromElement(element);
|
|
2705
|
-
const key = instance.options.getItemKey(index);
|
|
2706
|
-
const cachedSize = instance.itemSizeCache.get(key);
|
|
2707
|
-
if (cachedSize !== void 0) return cachedSize;
|
|
2708
|
-
}
|
|
2709
|
-
return element[instance.options.horizontal ? "offsetWidth" : "offsetHeight"];
|
|
2710
|
-
};
|
|
2711
|
-
const scrollWithAdjustments = (offset, { adjustments = 0, behavior }, instance) => {
|
|
2712
|
-
var _a, _b;
|
|
2713
|
-
(_b = (_a = instance.scrollElement) == null ? void 0 : _a.scrollTo) == null || _b.call(_a, {
|
|
2714
|
-
[instance.options.horizontal ? "left" : "top"]: offset + adjustments,
|
|
2715
|
-
behavior
|
|
2716
|
-
});
|
|
2717
|
-
};
|
|
2718
|
-
const elementScroll = scrollWithAdjustments;
|
|
2719
|
-
var Virtualizer = class {
|
|
2720
|
-
constructor(opts) {
|
|
2721
|
-
this.unsubs = [];
|
|
2722
|
-
this.scrollElement = null;
|
|
2723
|
-
this.targetWindow = null;
|
|
2724
|
-
this.isScrolling = false;
|
|
2725
|
-
this.scrollState = null;
|
|
2726
|
-
this.measurementsCache = [];
|
|
2727
|
-
this._flatMeasurements = null;
|
|
2728
|
-
this.itemSizeCache = /* @__PURE__ */ new Map();
|
|
2729
|
-
this.itemSizeCacheVersion = 0;
|
|
2730
|
-
this.laneAssignments = /* @__PURE__ */ new Map();
|
|
2731
|
-
this.pendingMin = null;
|
|
2732
|
-
this.prevLanes = void 0;
|
|
2733
|
-
this.lanesChangedFlag = false;
|
|
2734
|
-
this.lanesSettling = false;
|
|
2735
|
-
this.pendingScrollAnchor = null;
|
|
2736
|
-
this.scrollRect = null;
|
|
2737
|
-
this.scrollOffset = null;
|
|
2738
|
-
this.scrollDirection = null;
|
|
2739
|
-
this.scrollAdjustments = 0;
|
|
2740
|
-
this._iosDeferredAdjustment = 0;
|
|
2741
|
-
this._iosTouching = false;
|
|
2742
|
-
this._iosJustTouchEnded = false;
|
|
2743
|
-
this._iosTouchEndTimerId = null;
|
|
2744
|
-
this._intendedScrollOffset = null;
|
|
2745
|
-
this.elementsCache = /* @__PURE__ */ new Map();
|
|
2746
|
-
this.now = () => {
|
|
2747
|
-
var _a, _b, _c;
|
|
2748
|
-
return ((_c = (_b = (_a = this.targetWindow) == null ? void 0 : _a.performance) == null ? void 0 : _b.now) == null ? void 0 : _c.call(_b)) ?? Date.now();
|
|
2749
|
-
};
|
|
2750
|
-
this.observer = /* @__PURE__ */ (() => {
|
|
2751
|
-
let _ro = null;
|
|
2752
|
-
const get = () => {
|
|
2753
|
-
if (_ro) return _ro;
|
|
2754
|
-
if (!this.targetWindow || !this.targetWindow.ResizeObserver) return null;
|
|
2755
|
-
return _ro = new this.targetWindow.ResizeObserver((entries) => {
|
|
2756
|
-
entries.forEach((entry) => {
|
|
2757
|
-
const run = () => {
|
|
2758
|
-
const node = entry.target;
|
|
2759
|
-
const index = this.indexFromElement(node);
|
|
2760
|
-
if (!node.isConnected) {
|
|
2761
|
-
this.observer.unobserve(node);
|
|
2762
|
-
for (const [cacheKey, cachedNode] of this.elementsCache) if (cachedNode === node) {
|
|
2763
|
-
this.elementsCache.delete(cacheKey);
|
|
2764
|
-
break;
|
|
2765
|
-
}
|
|
2766
|
-
return;
|
|
2767
|
-
}
|
|
2768
|
-
if (this.shouldMeasureDuringScroll(index)) this.resizeItem(index, this.options.measureElement(node, entry, this));
|
|
2769
|
-
};
|
|
2770
|
-
this.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(run) : run();
|
|
2771
|
-
});
|
|
2772
|
-
});
|
|
2773
|
-
};
|
|
2774
|
-
return {
|
|
2775
|
-
disconnect: () => {
|
|
2776
|
-
var _a;
|
|
2777
|
-
(_a = get()) == null || _a.disconnect();
|
|
2778
|
-
_ro = null;
|
|
2779
|
-
},
|
|
2780
|
-
observe: (target) => {
|
|
2781
|
-
var _a;
|
|
2782
|
-
return (_a = get()) == null ? void 0 : _a.observe(target, { box: "border-box" });
|
|
2783
|
-
},
|
|
2784
|
-
unobserve: (target) => {
|
|
2785
|
-
var _a;
|
|
2786
|
-
return (_a = get()) == null ? void 0 : _a.unobserve(target);
|
|
2787
|
-
}
|
|
2788
|
-
};
|
|
2789
|
-
})();
|
|
2790
|
-
this.range = null;
|
|
2791
|
-
this.setOptions = (opts2) => {
|
|
2792
|
-
var _a, _b;
|
|
2793
|
-
const merged = {
|
|
2794
|
-
debug: false,
|
|
2795
|
-
initialOffset: 0,
|
|
2796
|
-
overscan: 1,
|
|
2797
|
-
paddingStart: 0,
|
|
2798
|
-
paddingEnd: 0,
|
|
2799
|
-
scrollPaddingStart: 0,
|
|
2800
|
-
scrollPaddingEnd: 0,
|
|
2801
|
-
horizontal: false,
|
|
2802
|
-
getItemKey: defaultKeyExtractor,
|
|
2803
|
-
rangeExtractor: defaultRangeExtractor,
|
|
2804
|
-
onChange: () => {},
|
|
2805
|
-
measureElement,
|
|
2806
|
-
initialRect: {
|
|
2807
|
-
width: 0,
|
|
2808
|
-
height: 0
|
|
2809
|
-
},
|
|
2810
|
-
scrollMargin: 0,
|
|
2811
|
-
gap: 0,
|
|
2812
|
-
indexAttribute: "data-index",
|
|
2813
|
-
initialMeasurementsCache: [],
|
|
2814
|
-
lanes: 1,
|
|
2815
|
-
anchorTo: "start",
|
|
2816
|
-
followOnAppend: false,
|
|
2817
|
-
scrollEndThreshold: 1,
|
|
2818
|
-
isScrollingResetDelay: 150,
|
|
2819
|
-
enabled: true,
|
|
2820
|
-
isRtl: false,
|
|
2821
|
-
useScrollendEvent: false,
|
|
2822
|
-
useAnimationFrameWithResizeObserver: false,
|
|
2823
|
-
laneAssignmentMode: "estimate",
|
|
2824
|
-
useCachedMeasurements: false
|
|
2825
|
-
};
|
|
2826
|
-
for (const key in opts2) {
|
|
2827
|
-
const v = opts2[key];
|
|
2828
|
-
if (v !== void 0) merged[key] = v;
|
|
2829
|
-
}
|
|
2830
|
-
const prevOptions = this.options;
|
|
2831
|
-
let anchor = null;
|
|
2832
|
-
let followOnAppend = null;
|
|
2833
|
-
let edgeKeysChanged = false;
|
|
2834
|
-
if (prevOptions !== void 0 && prevOptions.enabled && merged.enabled && merged.anchorTo === "end" && this.scrollElement !== null) {
|
|
2835
|
-
const prevCount = prevOptions.count;
|
|
2836
|
-
const nextCount = merged.count;
|
|
2837
|
-
const measurements = this.getMeasurements();
|
|
2838
|
-
const prevFirstKey = prevCount > 0 ? ((_a = measurements[0]) == null ? void 0 : _a.key) ?? prevOptions.getItemKey(0) : null;
|
|
2839
|
-
const prevLastKey = prevCount > 0 ? ((_b = measurements[prevCount - 1]) == null ? void 0 : _b.key) ?? prevOptions.getItemKey(prevCount - 1) : null;
|
|
2840
|
-
if (nextCount !== prevCount || prevCount > 0 && nextCount > 0 && (merged.getItemKey(0) !== prevFirstKey || merged.getItemKey(nextCount - 1) !== prevLastKey)) {
|
|
2841
|
-
edgeKeysChanged = true;
|
|
2842
|
-
const item = prevCount > 0 ? this.getVirtualItemForOffset(this.getScrollOffset()) ?? measurements[0] : null;
|
|
2843
|
-
if (item) anchor = [item.key, this.getScrollOffset() - item.start];
|
|
2844
|
-
const behavior = merged.followOnAppend === true ? "auto" : merged.followOnAppend || null;
|
|
2845
|
-
if (behavior && nextCount > prevCount && this.isAtEnd(prevOptions.scrollEndThreshold) && (prevCount === 0 || merged.getItemKey(nextCount - 1) !== prevLastKey)) followOnAppend = behavior;
|
|
2846
|
-
}
|
|
2847
|
-
}
|
|
2848
|
-
this.options = merged;
|
|
2849
|
-
if (edgeKeysChanged) {
|
|
2850
|
-
this.pendingMin = 0;
|
|
2851
|
-
this.itemSizeCacheVersion++;
|
|
2852
|
-
}
|
|
2853
|
-
let anchorResolved = false;
|
|
2854
|
-
let anchorDelta = 0;
|
|
2855
|
-
if (anchor && this.scrollOffset !== null) {
|
|
2856
|
-
const [anchorKey, anchorOffset] = anchor;
|
|
2857
|
-
const newMeasurements = this.getMeasurements();
|
|
2858
|
-
const { count, getItemKey } = this.options;
|
|
2859
|
-
let idx = 0;
|
|
2860
|
-
while (idx < count && getItemKey(idx) !== anchorKey) idx++;
|
|
2861
|
-
if (idx < count) {
|
|
2862
|
-
const anchorItem = newMeasurements[idx];
|
|
2863
|
-
if (anchorItem) {
|
|
2864
|
-
const newOffset = Math.max(0, anchorItem.start + anchorOffset);
|
|
2865
|
-
if (newOffset !== this.scrollOffset) {
|
|
2866
|
-
anchorDelta = newOffset - this.scrollOffset;
|
|
2867
|
-
this.scrollOffset = newOffset;
|
|
2868
|
-
anchorResolved = true;
|
|
2869
|
-
}
|
|
2870
|
-
}
|
|
2871
|
-
}
|
|
2872
|
-
}
|
|
2873
|
-
if (anchorResolved || followOnAppend) this.pendingScrollAnchor = [
|
|
2874
|
-
anchorResolved ? anchor[0] : null,
|
|
2875
|
-
anchorResolved ? anchor[1] : 0,
|
|
2876
|
-
followOnAppend,
|
|
2877
|
-
anchorDelta
|
|
2878
|
-
];
|
|
2879
|
-
};
|
|
2880
|
-
this.notify = (sync) => {
|
|
2881
|
-
var _a, _b;
|
|
2882
|
-
(_b = (_a = this.options).onChange) == null || _b.call(_a, this, sync);
|
|
2883
|
-
};
|
|
2884
|
-
this.maybeNotify = memo$1(() => {
|
|
2885
|
-
this.calculateRange();
|
|
2886
|
-
return [
|
|
2887
|
-
this.isScrolling,
|
|
2888
|
-
this.range ? this.range.startIndex : null,
|
|
2889
|
-
this.range ? this.range.endIndex : null
|
|
2890
|
-
];
|
|
2891
|
-
}, (isScrolling) => {
|
|
2892
|
-
this.notify(isScrolling);
|
|
2893
|
-
}, {
|
|
2894
|
-
key: false,
|
|
2895
|
-
debug: () => this.options.debug,
|
|
2896
|
-
initialDeps: [
|
|
2897
|
-
this.isScrolling,
|
|
2898
|
-
this.range ? this.range.startIndex : null,
|
|
2899
|
-
this.range ? this.range.endIndex : null
|
|
2900
|
-
]
|
|
2901
|
-
});
|
|
2902
|
-
this.cleanup = () => {
|
|
2903
|
-
this.unsubs.filter(Boolean).forEach((d) => d());
|
|
2904
|
-
this.unsubs = [];
|
|
2905
|
-
this.observer.disconnect();
|
|
2906
|
-
if (this.rafId != null && this.targetWindow) {
|
|
2907
|
-
this.targetWindow.cancelAnimationFrame(this.rafId);
|
|
2908
|
-
this.rafId = null;
|
|
2909
|
-
}
|
|
2910
|
-
this.scrollState = null;
|
|
2911
|
-
this._iosDeferredAdjustment = 0;
|
|
2912
|
-
this._iosTouching = false;
|
|
2913
|
-
this._iosJustTouchEnded = false;
|
|
2914
|
-
this.scrollElement = null;
|
|
2915
|
-
this.targetWindow = null;
|
|
2916
|
-
};
|
|
2917
|
-
this._didMount = () => {
|
|
2918
|
-
return () => {
|
|
2919
|
-
this.cleanup();
|
|
2920
|
-
};
|
|
2921
|
-
};
|
|
2922
|
-
this._willUpdate = () => {
|
|
2923
|
-
var _a;
|
|
2924
|
-
const scrollElement = this.options.enabled ? this.options.getScrollElement() : null;
|
|
2925
|
-
if (this.scrollElement !== scrollElement) {
|
|
2926
|
-
this.cleanup();
|
|
2927
|
-
if (!scrollElement) {
|
|
2928
|
-
this.maybeNotify();
|
|
2929
|
-
return;
|
|
2930
|
-
}
|
|
2931
|
-
this.scrollElement = scrollElement;
|
|
2932
|
-
if (this.scrollElement && "ownerDocument" in this.scrollElement) this.targetWindow = this.scrollElement.ownerDocument.defaultView;
|
|
2933
|
-
else this.targetWindow = ((_a = this.scrollElement) == null ? void 0 : _a.window) ?? null;
|
|
2934
|
-
this.elementsCache.forEach((cached) => {
|
|
2935
|
-
this.observer.observe(cached);
|
|
2936
|
-
});
|
|
2937
|
-
this.unsubs.push(this.options.observeElementRect(this, (rect) => {
|
|
2938
|
-
this.scrollRect = rect;
|
|
2939
|
-
this.maybeNotify();
|
|
2940
|
-
}));
|
|
2941
|
-
this.unsubs.push(this.options.observeElementOffset(this, (offset, isScrolling) => {
|
|
2942
|
-
if (isScrolling && this._intendedScrollOffset === null && offset === this.scrollOffset) return;
|
|
2943
|
-
if (this._intendedScrollOffset !== null && Math.abs(offset - this._intendedScrollOffset) < 1.5) offset = this._intendedScrollOffset;
|
|
2944
|
-
this._intendedScrollOffset = null;
|
|
2945
|
-
this.scrollAdjustments = 0;
|
|
2946
|
-
const prevOffset = this.getScrollOffset();
|
|
2947
|
-
this.scrollDirection = isScrolling ? prevOffset === offset ? this.scrollDirection : prevOffset < offset ? "forward" : "backward" : null;
|
|
2948
|
-
this.scrollOffset = offset;
|
|
2949
|
-
this.isScrolling = isScrolling;
|
|
2950
|
-
this._flushIosDeferredIfReady();
|
|
2951
|
-
if (this.scrollState) this.scheduleScrollReconcile();
|
|
2952
|
-
this.maybeNotify();
|
|
2953
|
-
}));
|
|
2954
|
-
if ("addEventListener" in this.scrollElement) {
|
|
2955
|
-
const scrollEl = this.scrollElement;
|
|
2956
|
-
const onTouchStart = () => {
|
|
2957
|
-
this._iosTouching = true;
|
|
2958
|
-
this._iosJustTouchEnded = false;
|
|
2959
|
-
if (this._iosTouchEndTimerId !== null && this.targetWindow != null) {
|
|
2960
|
-
this.targetWindow.clearTimeout(this._iosTouchEndTimerId);
|
|
2961
|
-
this._iosTouchEndTimerId = null;
|
|
2962
|
-
}
|
|
2963
|
-
};
|
|
2964
|
-
const onTouchEnd = () => {
|
|
2965
|
-
this._iosTouching = false;
|
|
2966
|
-
if (!isIOSWebKit() || this.targetWindow == null) return;
|
|
2967
|
-
this._iosJustTouchEnded = true;
|
|
2968
|
-
this._iosTouchEndTimerId = this.targetWindow.setTimeout(() => {
|
|
2969
|
-
this._iosJustTouchEnded = false;
|
|
2970
|
-
this._iosTouchEndTimerId = null;
|
|
2971
|
-
this._flushIosDeferredIfReady();
|
|
2972
|
-
}, 150);
|
|
2973
|
-
};
|
|
2974
|
-
scrollEl.addEventListener("touchstart", onTouchStart, addEventListenerOptions);
|
|
2975
|
-
scrollEl.addEventListener("touchend", onTouchEnd, addEventListenerOptions);
|
|
2976
|
-
this.unsubs.push(() => {
|
|
2977
|
-
scrollEl.removeEventListener("touchstart", onTouchStart);
|
|
2978
|
-
scrollEl.removeEventListener("touchend", onTouchEnd);
|
|
2979
|
-
if (this._iosTouchEndTimerId !== null && this.targetWindow != null) {
|
|
2980
|
-
this.targetWindow.clearTimeout(this._iosTouchEndTimerId);
|
|
2981
|
-
this._iosTouchEndTimerId = null;
|
|
2982
|
-
}
|
|
2983
|
-
});
|
|
2984
|
-
}
|
|
2985
|
-
this._scrollToOffset(this.getScrollOffset(), {
|
|
2986
|
-
adjustments: void 0,
|
|
2987
|
-
behavior: void 0
|
|
2988
|
-
});
|
|
2989
|
-
}
|
|
2990
|
-
const anchor = this.pendingScrollAnchor;
|
|
2991
|
-
this.pendingScrollAnchor = null;
|
|
2992
|
-
if (anchor && this.scrollElement && this.options.enabled) {
|
|
2993
|
-
const [key, _offset, followOnAppend, anchorDelta] = anchor;
|
|
2994
|
-
if (key !== null && !followOnAppend) if (isIOSWebKit() && (this.isScrolling || this._iosTouching || this._iosJustTouchEnded)) {
|
|
2995
|
-
if (anchorDelta !== 0) this._iosDeferredAdjustment += anchorDelta;
|
|
2996
|
-
} else this._scrollToOffset(this.getScrollOffset(), {
|
|
2997
|
-
adjustments: void 0,
|
|
2998
|
-
behavior: void 0
|
|
2999
|
-
});
|
|
3000
|
-
if (followOnAppend) this.scrollToEnd({ behavior: followOnAppend });
|
|
3001
|
-
}
|
|
3002
|
-
};
|
|
3003
|
-
this._flushIosDeferredIfReady = () => {
|
|
3004
|
-
if (this._iosDeferredAdjustment === 0) return;
|
|
3005
|
-
if (this.isScrolling) return;
|
|
3006
|
-
if (this._iosTouching) return;
|
|
3007
|
-
if (this._iosJustTouchEnded) return;
|
|
3008
|
-
const cur = this.getScrollOffset();
|
|
3009
|
-
const max = this.getMaxScrollOffset();
|
|
3010
|
-
if (cur < 0 || cur > max) return;
|
|
3011
|
-
if (this._iosDeferredAdjustment < 0 && cur >= max - 1) {
|
|
3012
|
-
this._iosDeferredAdjustment = 0;
|
|
3013
|
-
return;
|
|
3014
|
-
}
|
|
3015
|
-
const delta = this._iosDeferredAdjustment;
|
|
3016
|
-
this._iosDeferredAdjustment = 0;
|
|
3017
|
-
this._scrollToOffset(cur, {
|
|
3018
|
-
adjustments: this.scrollAdjustments += delta,
|
|
3019
|
-
behavior: void 0
|
|
3020
|
-
});
|
|
3021
|
-
};
|
|
3022
|
-
this.rafId = null;
|
|
3023
|
-
this.getSize = () => {
|
|
3024
|
-
if (!this.options.enabled) {
|
|
3025
|
-
this.scrollRect = null;
|
|
3026
|
-
return 0;
|
|
3027
|
-
}
|
|
3028
|
-
this.scrollRect = this.scrollRect ?? this.options.initialRect;
|
|
3029
|
-
return this.scrollRect[this.options.horizontal ? "width" : "height"];
|
|
3030
|
-
};
|
|
3031
|
-
this.getScrollOffset = () => {
|
|
3032
|
-
if (!this.options.enabled) {
|
|
3033
|
-
this.scrollOffset = null;
|
|
3034
|
-
return 0;
|
|
3035
|
-
}
|
|
3036
|
-
this.scrollOffset = this.scrollOffset ?? (typeof this.options.initialOffset === "function" ? this.options.initialOffset() : this.options.initialOffset);
|
|
3037
|
-
return this.scrollOffset;
|
|
3038
|
-
};
|
|
3039
|
-
this.getMeasurementOptions = memo$1(() => [
|
|
3040
|
-
this.options.count,
|
|
3041
|
-
this.options.paddingStart,
|
|
3042
|
-
this.options.scrollMargin,
|
|
3043
|
-
this.options.getItemKey,
|
|
3044
|
-
this.options.enabled,
|
|
3045
|
-
this.options.lanes,
|
|
3046
|
-
this.options.laneAssignmentMode,
|
|
3047
|
-
this.options.gap
|
|
3048
|
-
], (count, paddingStart, scrollMargin, getItemKey, enabled, lanes, laneAssignmentMode, gap) => {
|
|
3049
|
-
if (this.prevLanes !== void 0 && this.prevLanes !== lanes) this.lanesChangedFlag = true;
|
|
3050
|
-
this.prevLanes = lanes;
|
|
3051
|
-
this.pendingMin = null;
|
|
3052
|
-
return {
|
|
3053
|
-
count,
|
|
3054
|
-
paddingStart,
|
|
3055
|
-
scrollMargin,
|
|
3056
|
-
getItemKey,
|
|
3057
|
-
enabled,
|
|
3058
|
-
lanes,
|
|
3059
|
-
laneAssignmentMode,
|
|
3060
|
-
gap
|
|
3061
|
-
};
|
|
3062
|
-
}, { key: false });
|
|
3063
|
-
this.getMeasurements = memo$1(() => [this.getMeasurementOptions(), this.itemSizeCacheVersion], ({ count, paddingStart, scrollMargin, getItemKey, enabled, lanes, laneAssignmentMode, gap }, _itemSizeCacheVersion) => {
|
|
3064
|
-
const itemSizeCache = this.itemSizeCache;
|
|
3065
|
-
if (!enabled) {
|
|
3066
|
-
this.measurementsCache = [];
|
|
3067
|
-
this.itemSizeCache.clear();
|
|
3068
|
-
this.laneAssignments.clear();
|
|
3069
|
-
return [];
|
|
3070
|
-
}
|
|
3071
|
-
if (this.laneAssignments.size > count) {
|
|
3072
|
-
for (const index of this.laneAssignments.keys()) if (index >= count) this.laneAssignments.delete(index);
|
|
3073
|
-
}
|
|
3074
|
-
if (this.lanesChangedFlag) {
|
|
3075
|
-
this.lanesChangedFlag = false;
|
|
3076
|
-
this.lanesSettling = true;
|
|
3077
|
-
this.measurementsCache = [];
|
|
3078
|
-
this.itemSizeCache.clear();
|
|
3079
|
-
this.laneAssignments.clear();
|
|
3080
|
-
this.pendingMin = null;
|
|
3081
|
-
}
|
|
3082
|
-
if (this.measurementsCache.length === 0 && !this.lanesSettling) {
|
|
3083
|
-
this.measurementsCache = this.options.initialMeasurementsCache;
|
|
3084
|
-
this.measurementsCache.forEach((item) => {
|
|
3085
|
-
this.itemSizeCache.set(item.key, item.size);
|
|
3086
|
-
});
|
|
3087
|
-
}
|
|
3088
|
-
const min = this.lanesSettling ? 0 : this.pendingMin ?? 0;
|
|
3089
|
-
this.pendingMin = null;
|
|
3090
|
-
if (this.lanesSettling && this.measurementsCache.length === count) this.lanesSettling = false;
|
|
3091
|
-
if (lanes === 1) {
|
|
3092
|
-
const need = count * 2;
|
|
3093
|
-
let flat = this._flatMeasurements;
|
|
3094
|
-
if (!flat || flat.length < need) {
|
|
3095
|
-
const next = new Float64Array(need);
|
|
3096
|
-
if (flat && min > 0) next.set(flat.subarray(0, min * 2));
|
|
3097
|
-
flat = next;
|
|
3098
|
-
this._flatMeasurements = flat;
|
|
3099
|
-
}
|
|
3100
|
-
let runningStart;
|
|
3101
|
-
if (min === 0) runningStart = paddingStart + scrollMargin;
|
|
3102
|
-
else {
|
|
3103
|
-
const prevIdx = min - 1;
|
|
3104
|
-
runningStart = flat[prevIdx * 2] + flat[prevIdx * 2 + 1] + gap;
|
|
3105
|
-
}
|
|
3106
|
-
for (let i = min; i < count; i++) {
|
|
3107
|
-
const key = getItemKey(i);
|
|
3108
|
-
const measuredSize = itemSizeCache.get(key);
|
|
3109
|
-
const size = typeof measuredSize === "number" ? measuredSize : this.options.estimateSize(i);
|
|
3110
|
-
flat[i * 2] = runningStart;
|
|
3111
|
-
flat[i * 2 + 1] = size;
|
|
3112
|
-
runningStart += size + gap;
|
|
3113
|
-
}
|
|
3114
|
-
const view = createLazyMeasurementsView(count, flat, getItemKey);
|
|
3115
|
-
this.measurementsCache = view;
|
|
3116
|
-
return view;
|
|
3117
|
-
}
|
|
3118
|
-
const measurements = this.measurementsCache.slice(0, min);
|
|
3119
|
-
const laneLastIndex = new Array(lanes).fill(void 0);
|
|
3120
|
-
const laneEnds = new Float64Array(lanes);
|
|
3121
|
-
let filledLanes = 0;
|
|
3122
|
-
for (let m = 0; m < min; m++) {
|
|
3123
|
-
const item = measurements[m];
|
|
3124
|
-
if (item) {
|
|
3125
|
-
if (laneLastIndex[item.lane] === void 0) filledLanes++;
|
|
3126
|
-
laneLastIndex[item.lane] = m;
|
|
3127
|
-
laneEnds[item.lane] = item.end;
|
|
3128
|
-
}
|
|
3129
|
-
}
|
|
3130
|
-
for (let i = min; i < count; i++) {
|
|
3131
|
-
const key = getItemKey(i);
|
|
3132
|
-
const cachedLane = this.laneAssignments.get(i);
|
|
3133
|
-
let lane;
|
|
3134
|
-
let start;
|
|
3135
|
-
const shouldCacheLane = laneAssignmentMode === "estimate" || itemSizeCache.has(key);
|
|
3136
|
-
if (cachedLane !== void 0 && this.options.lanes > 1) {
|
|
3137
|
-
lane = cachedLane;
|
|
3138
|
-
const prevIndex = laneLastIndex[lane];
|
|
3139
|
-
const prevInLane = prevIndex !== void 0 ? measurements[prevIndex] : void 0;
|
|
3140
|
-
start = prevInLane ? prevInLane.end + gap : paddingStart + scrollMargin;
|
|
3141
|
-
} else if (filledLanes === lanes) {
|
|
3142
|
-
let bestLane = 0;
|
|
3143
|
-
let bestEnd = laneEnds[0];
|
|
3144
|
-
let bestIdx = laneLastIndex[0];
|
|
3145
|
-
for (let l = 1; l < lanes; l++) {
|
|
3146
|
-
const e = laneEnds[l];
|
|
3147
|
-
if (e < bestEnd || e === bestEnd && laneLastIndex[l] < bestIdx) {
|
|
3148
|
-
bestLane = l;
|
|
3149
|
-
bestEnd = e;
|
|
3150
|
-
bestIdx = laneLastIndex[l];
|
|
3151
|
-
}
|
|
3152
|
-
}
|
|
3153
|
-
lane = bestLane;
|
|
3154
|
-
start = bestEnd + gap;
|
|
3155
|
-
if (shouldCacheLane) this.laneAssignments.set(i, lane);
|
|
3156
|
-
} else {
|
|
3157
|
-
lane = i % this.options.lanes;
|
|
3158
|
-
start = paddingStart + scrollMargin;
|
|
3159
|
-
if (shouldCacheLane) this.laneAssignments.set(i, lane);
|
|
3160
|
-
}
|
|
3161
|
-
const measuredSize = itemSizeCache.get(key);
|
|
3162
|
-
const size = typeof measuredSize === "number" ? measuredSize : this.options.estimateSize(i);
|
|
3163
|
-
const end = start + size;
|
|
3164
|
-
measurements[i] = {
|
|
3165
|
-
index: i,
|
|
3166
|
-
start,
|
|
3167
|
-
size,
|
|
3168
|
-
end,
|
|
3169
|
-
key,
|
|
3170
|
-
lane
|
|
3171
|
-
};
|
|
3172
|
-
if (laneLastIndex[lane] === void 0) filledLanes++;
|
|
3173
|
-
laneLastIndex[lane] = i;
|
|
3174
|
-
laneEnds[lane] = end;
|
|
3175
|
-
}
|
|
3176
|
-
this.measurementsCache = measurements;
|
|
3177
|
-
return measurements;
|
|
3178
|
-
}, {
|
|
3179
|
-
key: false,
|
|
3180
|
-
debug: () => this.options.debug
|
|
3181
|
-
});
|
|
3182
|
-
this.calculateRange = memo$1(() => [
|
|
3183
|
-
this.getMeasurements(),
|
|
3184
|
-
this.getSize(),
|
|
3185
|
-
this.getScrollOffset(),
|
|
3186
|
-
this.options.lanes
|
|
3187
|
-
], (measurements, outerSize, scrollOffset, lanes) => {
|
|
3188
|
-
if (measurements.length === 0 || outerSize === 0) {
|
|
3189
|
-
this.range = null;
|
|
3190
|
-
return null;
|
|
3191
|
-
}
|
|
3192
|
-
this.range = calculateRangeImpl(measurements, outerSize, scrollOffset, lanes, lanes === 1 && this._flatMeasurements != null ? this._flatMeasurements : null);
|
|
3193
|
-
return this.range;
|
|
3194
|
-
}, {
|
|
3195
|
-
key: false,
|
|
3196
|
-
debug: () => this.options.debug
|
|
3197
|
-
});
|
|
3198
|
-
this.getVirtualIndexes = memo$1(() => {
|
|
3199
|
-
let startIndex = null;
|
|
3200
|
-
let endIndex = null;
|
|
3201
|
-
const range = this.calculateRange();
|
|
3202
|
-
if (range) {
|
|
3203
|
-
startIndex = range.startIndex;
|
|
3204
|
-
endIndex = range.endIndex;
|
|
3205
|
-
}
|
|
3206
|
-
this.maybeNotify.updateDeps([
|
|
3207
|
-
this.isScrolling,
|
|
3208
|
-
startIndex,
|
|
3209
|
-
endIndex
|
|
3210
|
-
]);
|
|
3211
|
-
return [
|
|
3212
|
-
this.options.rangeExtractor,
|
|
3213
|
-
this.options.overscan,
|
|
3214
|
-
this.options.count,
|
|
3215
|
-
startIndex,
|
|
3216
|
-
endIndex
|
|
3217
|
-
];
|
|
3218
|
-
}, (rangeExtractor, overscan, count, startIndex, endIndex) => {
|
|
3219
|
-
return startIndex === null || endIndex === null ? [] : rangeExtractor({
|
|
3220
|
-
startIndex,
|
|
3221
|
-
endIndex,
|
|
3222
|
-
overscan,
|
|
3223
|
-
count
|
|
3224
|
-
});
|
|
3225
|
-
}, {
|
|
3226
|
-
key: false,
|
|
3227
|
-
debug: () => this.options.debug
|
|
3228
|
-
});
|
|
3229
|
-
this.indexFromElement = (node) => {
|
|
3230
|
-
const attributeName = this.options.indexAttribute;
|
|
3231
|
-
const indexStr = node.getAttribute(attributeName);
|
|
3232
|
-
if (!indexStr) {
|
|
3233
|
-
console.warn(`Missing attribute name '${attributeName}={index}' on measured element.`);
|
|
3234
|
-
return -1;
|
|
3235
|
-
}
|
|
3236
|
-
return parseInt(indexStr, 10);
|
|
3237
|
-
};
|
|
3238
|
-
this.shouldMeasureDuringScroll = (index) => {
|
|
3239
|
-
var _a;
|
|
3240
|
-
if (!this.scrollState || this.scrollState.behavior !== "smooth") return true;
|
|
3241
|
-
const scrollIndex = this.scrollState.index ?? ((_a = this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)) == null ? void 0 : _a.index);
|
|
3242
|
-
if (scrollIndex !== void 0 && this.range) {
|
|
3243
|
-
const bufferSize = Math.max(this.options.overscan, Math.ceil((this.range.endIndex - this.range.startIndex) / 2));
|
|
3244
|
-
const minIndex = Math.max(0, scrollIndex - bufferSize);
|
|
3245
|
-
const maxIndex = Math.min(this.options.count - 1, scrollIndex + bufferSize);
|
|
3246
|
-
return index >= minIndex && index <= maxIndex;
|
|
3247
|
-
}
|
|
3248
|
-
return true;
|
|
3249
|
-
};
|
|
3250
|
-
this.measureElement = (node) => {
|
|
3251
|
-
if (!node) {
|
|
3252
|
-
this.elementsCache.forEach((cached, key2) => {
|
|
3253
|
-
if (!cached.isConnected) {
|
|
3254
|
-
this.observer.unobserve(cached);
|
|
3255
|
-
this.elementsCache.delete(key2);
|
|
3256
|
-
}
|
|
3257
|
-
});
|
|
3258
|
-
return;
|
|
3259
|
-
}
|
|
3260
|
-
const index = this.indexFromElement(node);
|
|
3261
|
-
const key = this.options.getItemKey(index);
|
|
3262
|
-
const prevNode = this.elementsCache.get(key);
|
|
3263
|
-
if (prevNode !== node) {
|
|
3264
|
-
if (prevNode) this.observer.unobserve(prevNode);
|
|
3265
|
-
this.observer.observe(node);
|
|
3266
|
-
this.elementsCache.set(key, node);
|
|
3267
|
-
}
|
|
3268
|
-
if ((!this.isScrolling || this.scrollState) && this.shouldMeasureDuringScroll(index)) this.resizeItem(index, this.options.measureElement(node, void 0, this));
|
|
3269
|
-
};
|
|
3270
|
-
this.resizeItem = (index, size) => {
|
|
3271
|
-
var _a, _b;
|
|
3272
|
-
if (index < 0 || index >= this.options.count) return;
|
|
3273
|
-
let cachedSize;
|
|
3274
|
-
let itemStart;
|
|
3275
|
-
let key;
|
|
3276
|
-
const flat = this._flatMeasurements;
|
|
3277
|
-
if (this.options.lanes === 1 && flat !== null) {
|
|
3278
|
-
key = this.options.getItemKey(index);
|
|
3279
|
-
itemStart = flat[index * 2];
|
|
3280
|
-
cachedSize = flat[index * 2 + 1];
|
|
3281
|
-
} else {
|
|
3282
|
-
const item = this.measurementsCache[index];
|
|
3283
|
-
if (!item) return;
|
|
3284
|
-
key = item.key;
|
|
3285
|
-
itemStart = item.start;
|
|
3286
|
-
cachedSize = item.size;
|
|
3287
|
-
}
|
|
3288
|
-
const itemSize = this.itemSizeCache.get(key) ?? cachedSize;
|
|
3289
|
-
const delta = size - itemSize;
|
|
3290
|
-
if (delta !== 0) {
|
|
3291
|
-
const wasAtEnd = this.options.anchorTo === "end" && ((_a = this.scrollState) == null ? void 0 : _a.behavior) !== "smooth" && this.getVirtualDistanceFromEnd() <= this.options.scrollEndThreshold;
|
|
3292
|
-
const prevTotalSize = wasAtEnd ? this.getTotalSize() : 0;
|
|
3293
|
-
const scrollOffsetWithAdj = this.getScrollOffset() + this.scrollAdjustments;
|
|
3294
|
-
const defaultShouldAdjust = !this.itemSizeCache.has(key) ? itemStart < scrollOffsetWithAdj : itemStart + itemSize <= scrollOffsetWithAdj && this.scrollDirection !== "backward";
|
|
3295
|
-
const shouldAdjustScroll = ((_b = this.scrollState) == null ? void 0 : _b.behavior) !== "smooth" && (this.shouldAdjustScrollPositionOnItemSizeChange !== void 0 ? this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[index] ?? {
|
|
3296
|
-
index,
|
|
3297
|
-
key,
|
|
3298
|
-
start: itemStart,
|
|
3299
|
-
size: cachedSize,
|
|
3300
|
-
end: itemStart + cachedSize,
|
|
3301
|
-
lane: 0
|
|
3302
|
-
}, delta, this) : defaultShouldAdjust);
|
|
3303
|
-
if (this.pendingMin === null || index < this.pendingMin) this.pendingMin = index;
|
|
3304
|
-
this.itemSizeCache.set(key, size);
|
|
3305
|
-
this.itemSizeCacheVersion++;
|
|
3306
|
-
let adjustedSync = false;
|
|
3307
|
-
if (wasAtEnd) adjustedSync = this.applyScrollAdjustment(this.getTotalSize() - prevTotalSize);
|
|
3308
|
-
else if (shouldAdjustScroll) adjustedSync = this.applyScrollAdjustment(delta);
|
|
3309
|
-
this.notify(adjustedSync);
|
|
3310
|
-
}
|
|
3311
|
-
};
|
|
3312
|
-
this.getVirtualItems = memo$1(() => [this.getVirtualIndexes(), this.getMeasurements()], (indexes, measurements) => {
|
|
3313
|
-
const virtualItems = [];
|
|
3314
|
-
for (let k = 0, len = indexes.length; k < len; k++) {
|
|
3315
|
-
const measurement = measurements[indexes[k]];
|
|
3316
|
-
virtualItems.push(measurement);
|
|
3317
|
-
}
|
|
3318
|
-
return virtualItems;
|
|
3319
|
-
}, {
|
|
3320
|
-
key: false,
|
|
3321
|
-
debug: () => this.options.debug
|
|
3322
|
-
});
|
|
3323
|
-
this.getVirtualItemForOffset = (offset) => {
|
|
3324
|
-
const measurements = this.getMeasurements();
|
|
3325
|
-
if (measurements.length === 0) return;
|
|
3326
|
-
const flat = this._flatMeasurements;
|
|
3327
|
-
const useFlat = this.options.lanes === 1 && flat != null;
|
|
3328
|
-
return notUndefined(measurements[findNearestBinarySearch(0, measurements.length - 1, useFlat ? (i) => flat[i * 2] : (i) => notUndefined(measurements[i]).start, offset)]);
|
|
3329
|
-
};
|
|
3330
|
-
this.getMaxScrollOffset = () => {
|
|
3331
|
-
if (!this.scrollElement) return 0;
|
|
3332
|
-
if ("scrollHeight" in this.scrollElement) return this.options.horizontal ? this.scrollElement.scrollWidth - this.scrollElement.clientWidth : this.scrollElement.scrollHeight - this.scrollElement.clientHeight;
|
|
3333
|
-
else {
|
|
3334
|
-
const doc = this.scrollElement.document.documentElement;
|
|
3335
|
-
return this.options.horizontal ? doc.scrollWidth - this.scrollElement.innerWidth : doc.scrollHeight - this.scrollElement.innerHeight;
|
|
3336
|
-
}
|
|
3337
|
-
};
|
|
3338
|
-
this.getVirtualDistanceFromEnd = () => {
|
|
3339
|
-
return Math.max(this.getTotalSize() - this.getSize() - this.getScrollOffset(), 0);
|
|
3340
|
-
};
|
|
3341
|
-
this.getDistanceFromEnd = () => {
|
|
3342
|
-
return Math.max(this.getMaxScrollOffset() - this.getScrollOffset(), 0);
|
|
3343
|
-
};
|
|
3344
|
-
this.isAtEnd = (threshold = this.options.scrollEndThreshold) => {
|
|
3345
|
-
return this.getDistanceFromEnd() <= threshold;
|
|
3346
|
-
};
|
|
3347
|
-
this.getOffsetForAlignment = (toOffset, align, itemSize = 0) => {
|
|
3348
|
-
if (!this.scrollElement) return 0;
|
|
3349
|
-
const size = this.getSize();
|
|
3350
|
-
const scrollOffset = this.getScrollOffset();
|
|
3351
|
-
if (align === "auto") align = toOffset >= scrollOffset + size ? "end" : "start";
|
|
3352
|
-
if (align === "center") toOffset += (itemSize - size) / 2;
|
|
3353
|
-
else if (align === "end") toOffset -= size;
|
|
3354
|
-
const maxOffset = this.getMaxScrollOffset();
|
|
3355
|
-
return Math.max(Math.min(maxOffset, toOffset), 0);
|
|
3356
|
-
};
|
|
3357
|
-
this.getOffsetForIndex = (index, align = "auto") => {
|
|
3358
|
-
index = Math.max(0, Math.min(index, this.options.count - 1));
|
|
3359
|
-
const size = this.getSize();
|
|
3360
|
-
const scrollOffset = this.getScrollOffset();
|
|
3361
|
-
const item = this.measurementsCache[index];
|
|
3362
|
-
if (!item) return;
|
|
3363
|
-
if (align === "auto") if (item.end >= scrollOffset + size - this.options.scrollPaddingEnd) align = "end";
|
|
3364
|
-
else if (item.start <= scrollOffset + this.options.scrollPaddingStart) align = "start";
|
|
3365
|
-
else return [scrollOffset, align];
|
|
3366
|
-
if (align === "end" && index === this.options.count - 1) return [this.getMaxScrollOffset(), align];
|
|
3367
|
-
const toOffset = align === "end" ? item.end + this.options.scrollPaddingEnd : item.start - this.options.scrollPaddingStart;
|
|
3368
|
-
return [this.getOffsetForAlignment(toOffset, align, item.size), align];
|
|
3369
|
-
};
|
|
3370
|
-
this.scrollToOffset = (toOffset, { align = "start", behavior = "auto" } = {}) => {
|
|
3371
|
-
this._iosDeferredAdjustment = 0;
|
|
3372
|
-
const offset = this.getOffsetForAlignment(toOffset, align);
|
|
3373
|
-
const now = this.now();
|
|
3374
|
-
this.scrollState = {
|
|
3375
|
-
index: null,
|
|
3376
|
-
align,
|
|
3377
|
-
behavior,
|
|
3378
|
-
startedAt: now,
|
|
3379
|
-
lastTargetOffset: offset,
|
|
3380
|
-
stableFrames: 0
|
|
3381
|
-
};
|
|
3382
|
-
this._scrollToOffset(offset, {
|
|
3383
|
-
adjustments: void 0,
|
|
3384
|
-
behavior
|
|
3385
|
-
});
|
|
3386
|
-
this.scheduleScrollReconcile();
|
|
3387
|
-
};
|
|
3388
|
-
this.scrollToIndex = (index, { align: initialAlign = "auto", behavior = "auto" } = {}) => {
|
|
3389
|
-
this._iosDeferredAdjustment = 0;
|
|
3390
|
-
index = Math.max(0, Math.min(index, this.options.count - 1));
|
|
3391
|
-
const offsetInfo = this.getOffsetForIndex(index, initialAlign);
|
|
3392
|
-
if (!offsetInfo) return;
|
|
3393
|
-
const [offset, align] = offsetInfo;
|
|
3394
|
-
const now = this.now();
|
|
3395
|
-
this.scrollState = {
|
|
3396
|
-
index,
|
|
3397
|
-
align,
|
|
3398
|
-
behavior,
|
|
3399
|
-
startedAt: now,
|
|
3400
|
-
lastTargetOffset: offset,
|
|
3401
|
-
stableFrames: 0
|
|
3402
|
-
};
|
|
3403
|
-
this._scrollToOffset(offset, {
|
|
3404
|
-
adjustments: void 0,
|
|
3405
|
-
behavior
|
|
3406
|
-
});
|
|
3407
|
-
this.scheduleScrollReconcile();
|
|
3408
|
-
};
|
|
3409
|
-
this.scrollBy = (delta, { behavior = "auto" } = {}) => {
|
|
3410
|
-
const offset = this.getScrollOffset() + delta;
|
|
3411
|
-
const now = this.now();
|
|
3412
|
-
this.scrollState = {
|
|
3413
|
-
index: null,
|
|
3414
|
-
align: "start",
|
|
3415
|
-
behavior,
|
|
3416
|
-
startedAt: now,
|
|
3417
|
-
lastTargetOffset: offset,
|
|
3418
|
-
stableFrames: 0
|
|
3419
|
-
};
|
|
3420
|
-
this._scrollToOffset(offset, {
|
|
3421
|
-
adjustments: void 0,
|
|
3422
|
-
behavior
|
|
3423
|
-
});
|
|
3424
|
-
this.scheduleScrollReconcile();
|
|
3425
|
-
};
|
|
3426
|
-
this.scrollToEnd = ({ behavior = "auto" } = {}) => {
|
|
3427
|
-
if (this.options.count > 0) {
|
|
3428
|
-
this.scrollToIndex(this.options.count - 1, {
|
|
3429
|
-
align: "end",
|
|
3430
|
-
behavior
|
|
3431
|
-
});
|
|
3432
|
-
return;
|
|
3433
|
-
}
|
|
3434
|
-
this.scrollToOffset(Math.max(this.getTotalSize() - this.getSize(), 0), { behavior });
|
|
3435
|
-
};
|
|
3436
|
-
this.getTotalSize = () => {
|
|
3437
|
-
var _a;
|
|
3438
|
-
const measurements = this.getMeasurements();
|
|
3439
|
-
let end;
|
|
3440
|
-
if (measurements.length === 0) end = this.options.paddingStart;
|
|
3441
|
-
else if (this.options.lanes === 1) {
|
|
3442
|
-
const lastIdx = measurements.length - 1;
|
|
3443
|
-
const flat = this._flatMeasurements;
|
|
3444
|
-
if (flat != null) end = flat[lastIdx * 2] + flat[lastIdx * 2 + 1];
|
|
3445
|
-
else end = ((_a = measurements[lastIdx]) == null ? void 0 : _a.end) ?? 0;
|
|
3446
|
-
} else {
|
|
3447
|
-
const endByLane = Array(this.options.lanes).fill(null);
|
|
3448
|
-
let endIndex = measurements.length - 1;
|
|
3449
|
-
while (endIndex >= 0 && endByLane.some((val) => val === null)) {
|
|
3450
|
-
const item = measurements[endIndex];
|
|
3451
|
-
if (endByLane[item.lane] === null) endByLane[item.lane] = item.end;
|
|
3452
|
-
endIndex--;
|
|
3453
|
-
}
|
|
3454
|
-
end = Math.max(...endByLane.filter((val) => val !== null));
|
|
3455
|
-
}
|
|
3456
|
-
return Math.max(end - this.options.scrollMargin + this.options.paddingEnd, 0);
|
|
3457
|
-
};
|
|
3458
|
-
this.takeSnapshot = () => {
|
|
3459
|
-
const snapshot = [];
|
|
3460
|
-
if (this.itemSizeCache.size === 0) return snapshot;
|
|
3461
|
-
const m = this.getMeasurements();
|
|
3462
|
-
for (const item of m) if (item && this.itemSizeCache.has(item.key)) snapshot.push({
|
|
3463
|
-
index: item.index,
|
|
3464
|
-
key: item.key,
|
|
3465
|
-
start: item.start,
|
|
3466
|
-
size: item.size,
|
|
3467
|
-
end: item.end,
|
|
3468
|
-
lane: item.lane
|
|
3469
|
-
});
|
|
3470
|
-
return snapshot;
|
|
3471
|
-
};
|
|
3472
|
-
this._scrollToOffset = (offset, { adjustments, behavior }) => {
|
|
3473
|
-
this._intendedScrollOffset = offset + (adjustments ?? 0);
|
|
3474
|
-
this.options.scrollToFn(offset, {
|
|
3475
|
-
behavior,
|
|
3476
|
-
adjustments
|
|
3477
|
-
}, this);
|
|
3478
|
-
};
|
|
3479
|
-
this.measure = () => {
|
|
3480
|
-
this.pendingMin = null;
|
|
3481
|
-
this.itemSizeCache.clear();
|
|
3482
|
-
this.laneAssignments.clear();
|
|
3483
|
-
this.itemSizeCacheVersion++;
|
|
3484
|
-
this.notify(false);
|
|
3485
|
-
};
|
|
3486
|
-
this.setOptions(opts);
|
|
3487
|
-
}
|
|
3488
|
-
applyScrollAdjustment(delta, behavior) {
|
|
3489
|
-
if (delta === 0) return false;
|
|
3490
|
-
if (isIOSWebKit() && (this.isScrolling || this._iosTouching || this._iosJustTouchEnded)) {
|
|
3491
|
-
this._iosDeferredAdjustment += delta;
|
|
3492
|
-
return false;
|
|
3493
|
-
} else {
|
|
3494
|
-
this._scrollToOffset(this.getScrollOffset(), {
|
|
3495
|
-
adjustments: this.scrollAdjustments += delta,
|
|
3496
|
-
behavior
|
|
3497
|
-
});
|
|
3498
|
-
if (this.scrollOffset !== null) {
|
|
3499
|
-
this.scrollOffset += this.scrollAdjustments;
|
|
3500
|
-
if (this.scrollOffset < 0) this.scrollOffset = 0;
|
|
3501
|
-
this.scrollAdjustments = 0;
|
|
3502
|
-
}
|
|
3503
|
-
return true;
|
|
3504
|
-
}
|
|
3505
|
-
}
|
|
3506
|
-
scheduleScrollReconcile() {
|
|
3507
|
-
if (!this.targetWindow) {
|
|
3508
|
-
this.scrollState = null;
|
|
3509
|
-
return;
|
|
3510
|
-
}
|
|
3511
|
-
if (this.rafId != null) return;
|
|
3512
|
-
this.rafId = this.targetWindow.requestAnimationFrame(() => {
|
|
3513
|
-
this.rafId = null;
|
|
3514
|
-
this.reconcileScroll();
|
|
3515
|
-
});
|
|
3516
|
-
}
|
|
3517
|
-
reconcileScroll() {
|
|
3518
|
-
if (!this.scrollState) return;
|
|
3519
|
-
if (!this.scrollElement) return;
|
|
3520
|
-
if (this.now() - this.scrollState.startedAt > 5e3) {
|
|
3521
|
-
this.scrollState = null;
|
|
3522
|
-
return;
|
|
3523
|
-
}
|
|
3524
|
-
const offsetInfo = this.scrollState.index != null ? this.getOffsetForIndex(this.scrollState.index, this.scrollState.align) : void 0;
|
|
3525
|
-
const targetOffset = offsetInfo ? offsetInfo[0] : this.scrollState.lastTargetOffset;
|
|
3526
|
-
const STABLE_FRAMES = 1;
|
|
3527
|
-
const targetChanged = targetOffset !== this.scrollState.lastTargetOffset;
|
|
3528
|
-
if (!targetChanged && approxEqual(targetOffset, this.getScrollOffset())) {
|
|
3529
|
-
this.scrollState.stableFrames++;
|
|
3530
|
-
if (this.scrollState.stableFrames >= STABLE_FRAMES) {
|
|
3531
|
-
if (this.getScrollOffset() !== targetOffset) this._scrollToOffset(targetOffset, {
|
|
3532
|
-
adjustments: void 0,
|
|
3533
|
-
behavior: "auto"
|
|
3534
|
-
});
|
|
3535
|
-
this.scrollState = null;
|
|
3536
|
-
return;
|
|
3537
|
-
}
|
|
3538
|
-
} else {
|
|
3539
|
-
this.scrollState.stableFrames = 0;
|
|
3540
|
-
if (targetChanged) {
|
|
3541
|
-
const viewport = this.getSize() || 600;
|
|
3542
|
-
const distance = Math.abs(targetOffset - this.getScrollOffset());
|
|
3543
|
-
const keepSmooth = this.scrollState.behavior === "smooth" && distance > viewport;
|
|
3544
|
-
this.scrollState.lastTargetOffset = targetOffset;
|
|
3545
|
-
if (!keepSmooth) this.scrollState.behavior = "auto";
|
|
3546
|
-
this._scrollToOffset(targetOffset, {
|
|
3547
|
-
adjustments: void 0,
|
|
3548
|
-
behavior: keepSmooth ? "smooth" : "auto"
|
|
3549
|
-
});
|
|
3550
|
-
}
|
|
3551
|
-
}
|
|
3552
|
-
this.scheduleScrollReconcile();
|
|
3553
|
-
}
|
|
3554
|
-
};
|
|
3555
|
-
const findNearestBinarySearch = (low, high, getCurrentValue, value) => {
|
|
3556
|
-
while (low <= high) {
|
|
3557
|
-
const middle = (low + high) / 2 | 0;
|
|
3558
|
-
const currentValue = getCurrentValue(middle);
|
|
3559
|
-
if (currentValue < value) low = middle + 1;
|
|
3560
|
-
else if (currentValue > value) high = middle - 1;
|
|
3561
|
-
else return middle;
|
|
3562
|
-
}
|
|
3563
|
-
if (low > 0) return low - 1;
|
|
3564
|
-
else return 0;
|
|
3565
|
-
};
|
|
3566
|
-
function findNearestBinarySearchFlat(flat, high, value) {
|
|
3567
|
-
let low = 0;
|
|
3568
|
-
while (low <= high) {
|
|
3569
|
-
const middle = (low + high) / 2 | 0;
|
|
3570
|
-
const currentValue = flat[middle * 2];
|
|
3571
|
-
if (currentValue < value) low = middle + 1;
|
|
3572
|
-
else if (currentValue > value) high = middle - 1;
|
|
3573
|
-
else return middle;
|
|
3574
|
-
}
|
|
3575
|
-
return low > 0 ? low - 1 : 0;
|
|
3576
|
-
}
|
|
3577
|
-
function calculateRangeImpl(measurements, outerSize, scrollOffset, lanes, flat) {
|
|
3578
|
-
const lastIndex = measurements.length - 1;
|
|
3579
|
-
if (measurements.length <= lanes) return {
|
|
3580
|
-
startIndex: 0,
|
|
3581
|
-
endIndex: lastIndex
|
|
3582
|
-
};
|
|
3583
|
-
if (lanes === 1 && flat !== null) {
|
|
3584
|
-
const startIndex2 = findNearestBinarySearchFlat(flat, lastIndex, scrollOffset);
|
|
3585
|
-
let endIndex2 = startIndex2;
|
|
3586
|
-
const limit = scrollOffset + outerSize;
|
|
3587
|
-
while (endIndex2 < lastIndex && flat[endIndex2 * 2] + flat[endIndex2 * 2 + 1] < limit) endIndex2++;
|
|
3588
|
-
return {
|
|
3589
|
-
startIndex: startIndex2,
|
|
3590
|
-
endIndex: endIndex2
|
|
3591
|
-
};
|
|
3592
|
-
}
|
|
3593
|
-
const getStart = (index) => measurements[index].start;
|
|
3594
|
-
let startIndex = findNearestBinarySearch(0, lastIndex, getStart, scrollOffset);
|
|
3595
|
-
let endIndex = startIndex;
|
|
3596
|
-
if (lanes === 1) while (endIndex < lastIndex && measurements[endIndex].end < scrollOffset + outerSize) endIndex++;
|
|
3597
|
-
else if (lanes > 1) {
|
|
3598
|
-
const endPerLane = Array(lanes).fill(0);
|
|
3599
|
-
while (endIndex < lastIndex && endPerLane.some((pos) => pos < scrollOffset + outerSize)) {
|
|
3600
|
-
const item = measurements[endIndex];
|
|
3601
|
-
endPerLane[item.lane] = item.end;
|
|
3602
|
-
endIndex++;
|
|
3603
|
-
}
|
|
3604
|
-
const startPerLane = Array(lanes).fill(scrollOffset + outerSize);
|
|
3605
|
-
while (startIndex >= 0 && startPerLane.some((pos) => pos >= scrollOffset)) {
|
|
3606
|
-
const item = measurements[startIndex];
|
|
3607
|
-
startPerLane[item.lane] = item.start;
|
|
3608
|
-
startIndex--;
|
|
3609
|
-
}
|
|
3610
|
-
startIndex = Math.max(0, startIndex - startIndex % lanes);
|
|
3611
|
-
endIndex = Math.min(lastIndex, endIndex + (lanes - 1 - endIndex % lanes));
|
|
3612
|
-
}
|
|
3613
|
-
return {
|
|
3614
|
-
startIndex,
|
|
3615
|
-
endIndex
|
|
3616
|
-
};
|
|
3617
|
-
}
|
|
3618
|
-
//#endregion
|
|
3619
|
-
//#region ../../../node_modules/.pnpm/@tanstack+react-virtual@3.14.9_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@tanstack/react-virtual/dist/esm/index.js
|
|
3620
|
-
const useIsomorphicLayoutEffect = typeof document !== "undefined" ? react.useLayoutEffect : react.useEffect;
|
|
3621
|
-
function useVirtualizerBase({ useFlushSync = true, directDomUpdates = false, directDomUpdatesMode = "transform", ...options }) {
|
|
3622
|
-
const rerender = react.useReducer((x) => x + 1, 0)[1];
|
|
3623
|
-
const directRef = react.useRef({
|
|
3624
|
-
enabled: directDomUpdates,
|
|
3625
|
-
mode: directDomUpdatesMode,
|
|
3626
|
-
container: null,
|
|
3627
|
-
lastSize: null,
|
|
3628
|
-
lastPositions: /* @__PURE__ */ new WeakMap(),
|
|
3629
|
-
prevRange: null
|
|
3630
|
-
});
|
|
3631
|
-
directRef.current.enabled = directDomUpdates;
|
|
3632
|
-
directRef.current.mode = directDomUpdatesMode;
|
|
3633
|
-
const applyContainerSize = (instance2) => {
|
|
3634
|
-
const state = directRef.current;
|
|
3635
|
-
if (!state.enabled || !state.container) return;
|
|
3636
|
-
const totalSize = instance2.getTotalSize();
|
|
3637
|
-
if (totalSize !== state.lastSize) {
|
|
3638
|
-
state.lastSize = totalSize;
|
|
3639
|
-
const sizeAxis = instance2.options.horizontal ? "width" : "height";
|
|
3640
|
-
state.container.style[sizeAxis] = `${totalSize}px`;
|
|
3641
|
-
}
|
|
3642
|
-
};
|
|
3643
|
-
const applyDirectStyles = (instance2) => {
|
|
3644
|
-
const state = directRef.current;
|
|
3645
|
-
if (!state.enabled || !state.container) return;
|
|
3646
|
-
applyContainerSize(instance2);
|
|
3647
|
-
const horizontal = !!instance2.options.horizontal;
|
|
3648
|
-
const useTransform = state.mode === "transform";
|
|
3649
|
-
const posAxis = horizontal ? "left" : "top";
|
|
3650
|
-
const scrollMargin = instance2.options.scrollMargin;
|
|
3651
|
-
const items = instance2.getVirtualItems();
|
|
3652
|
-
for (const item of items) {
|
|
3653
|
-
const next = item.start - scrollMargin;
|
|
3654
|
-
const el = instance2.elementsCache.get(item.key);
|
|
3655
|
-
if (!el) continue;
|
|
3656
|
-
if (state.lastPositions.get(el) === next) continue;
|
|
3657
|
-
state.lastPositions.set(el, next);
|
|
3658
|
-
if (useTransform) el.style.transform = horizontal ? `translate3d(${next}px, 0, 0)` : `translate3d(0, ${next}px, 0)`;
|
|
3659
|
-
else el.style[posAxis] = `${next}px`;
|
|
3660
|
-
}
|
|
3661
|
-
};
|
|
3662
|
-
const resolvedOptions = {
|
|
3663
|
-
...options,
|
|
3664
|
-
onChange: (instance2, sync) => {
|
|
3665
|
-
var _a;
|
|
3666
|
-
const state = directRef.current;
|
|
3667
|
-
let shouldRerender = true;
|
|
3668
|
-
if (state.enabled) {
|
|
3669
|
-
applyDirectStyles(instance2);
|
|
3670
|
-
const range = instance2.range;
|
|
3671
|
-
const prev = state.prevRange;
|
|
3672
|
-
shouldRerender = !prev || prev.isScrolling !== instance2.isScrolling || prev.startIndex !== (range == null ? void 0 : range.startIndex) || prev.endIndex !== (range == null ? void 0 : range.endIndex);
|
|
3673
|
-
if (shouldRerender) state.prevRange = range ? {
|
|
3674
|
-
startIndex: range.startIndex,
|
|
3675
|
-
endIndex: range.endIndex,
|
|
3676
|
-
isScrolling: instance2.isScrolling
|
|
3677
|
-
} : null;
|
|
3678
|
-
}
|
|
3679
|
-
if (shouldRerender) if (useFlushSync && sync) (0, react_dom.flushSync)(rerender);
|
|
3680
|
-
else rerender();
|
|
3681
|
-
(_a = options.onChange) == null || _a.call(options, instance2, sync);
|
|
3682
|
-
}
|
|
3683
|
-
};
|
|
3684
|
-
const [instance] = react.useState(() => {
|
|
3685
|
-
const v = new Virtualizer(resolvedOptions);
|
|
3686
|
-
return Object.assign(v, { containerRef: (node) => {
|
|
3687
|
-
const state = directRef.current;
|
|
3688
|
-
state.container = node;
|
|
3689
|
-
state.lastSize = null;
|
|
3690
|
-
if (node && state.enabled) {
|
|
3691
|
-
const total = v.getTotalSize();
|
|
3692
|
-
state.lastSize = total;
|
|
3693
|
-
const axis = v.options.horizontal ? "width" : "height";
|
|
3694
|
-
node.style[axis] = `${total}px`;
|
|
3695
|
-
}
|
|
3696
|
-
} });
|
|
3697
|
-
});
|
|
3698
|
-
instance.setOptions(resolvedOptions);
|
|
3699
|
-
useIsomorphicLayoutEffect(() => {
|
|
3700
|
-
return instance._didMount();
|
|
3701
|
-
}, []);
|
|
3702
|
-
useIsomorphicLayoutEffect(() => {
|
|
3703
|
-
applyContainerSize(instance);
|
|
3704
|
-
return instance._willUpdate();
|
|
3705
|
-
});
|
|
3706
|
-
useIsomorphicLayoutEffect(() => {
|
|
3707
|
-
applyDirectStyles(instance);
|
|
3708
|
-
});
|
|
3709
|
-
return instance;
|
|
3710
|
-
}
|
|
3711
|
-
function useVirtualizer(options) {
|
|
3712
|
-
return useVirtualizerBase({
|
|
3713
|
-
observeElementRect,
|
|
3714
|
-
observeElementOffset,
|
|
3715
|
-
scrollToFn: elementScroll,
|
|
3716
|
-
...options
|
|
3717
|
-
});
|
|
3718
|
-
}
|
|
3719
|
-
//#endregion
|
|
3720
2518
|
//#region ../../../node_modules/.pnpm/diff@9.0.0/node_modules/diff/libesm/diff/base.js
|
|
3721
2519
|
var Diff = class {
|
|
3722
2520
|
diff(oldStr, newStr, options = {}) {
|
|
@@ -5056,6 +3854,7 @@ window.__ModuleLoader__.load({
|
|
|
5056
3854
|
function stateOf(record) {
|
|
5057
3855
|
if (record.cell.isError) return "error";
|
|
5058
3856
|
if (record.cell.kind === "compacted" && record.cell.timeSeconds === null) return "running";
|
|
3857
|
+
if (record.cell.assistantMetrics?.completedTime === null) return "running";
|
|
5059
3858
|
if ((record.cell.kind === "tool" || record.cell.kind === "subtool") && record.cell.outputDetail === void 0) return "running";
|
|
5060
3859
|
return "complete";
|
|
5061
3860
|
}
|
|
@@ -5432,7 +4231,7 @@ window.__ModuleLoader__.load({
|
|
|
5432
4231
|
}];
|
|
5433
4232
|
});
|
|
5434
4233
|
}
|
|
5435
|
-
function RecordAttachments({ blocks, preview,
|
|
4234
|
+
function RecordAttachments({ blocks, preview, renderSlot, loadImage, t }) {
|
|
5436
4235
|
const attachments = recordAttachments(blocks, t);
|
|
5437
4236
|
if (attachments.length === 0) return null;
|
|
5438
4237
|
return (0, react_jsx_runtime.jsx)("ul", {
|
|
@@ -5440,13 +4239,14 @@ window.__ModuleLoader__.load({
|
|
|
5440
4239
|
"aria-label": t("attachment.list"),
|
|
5441
4240
|
children: attachments.map(({ block, index, name, metadata }) => (0, react_jsx_runtime.jsxs)("li", {
|
|
5442
4241
|
className: TrajectoryTable_module_css_default.attachmentRow,
|
|
5443
|
-
children: [block.attachment !== void 0 ?
|
|
4242
|
+
children: [block.attachment !== void 0 ? renderSlot("conversation.trajectory.images", {
|
|
5444
4243
|
images: [{
|
|
5445
4244
|
attachment: block.attachment,
|
|
5446
4245
|
label: name
|
|
5447
4246
|
}],
|
|
5448
4247
|
align: "start",
|
|
5449
|
-
thumbnail: true
|
|
4248
|
+
thumbnail: true,
|
|
4249
|
+
loadImage
|
|
5450
4250
|
}) : (0, react_jsx_runtime.jsx)("span", {
|
|
5451
4251
|
className: TrajectoryTable_module_css_default.attachmentIcon,
|
|
5452
4252
|
children: (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.FileTypeIcon, { path: name })
|
|
@@ -5622,7 +4422,7 @@ window.__ModuleLoader__.load({
|
|
|
5622
4422
|
})]
|
|
5623
4423
|
});
|
|
5624
4424
|
}
|
|
5625
|
-
function ToolOutputBlocks({ blocks, error, errorDetail, preview,
|
|
4425
|
+
function ToolOutputBlocks({ blocks, error, errorDetail, preview, renderSlot, loadImage }) {
|
|
5626
4426
|
return (0, react_jsx_runtime.jsxs)("div", {
|
|
5627
4427
|
className: [
|
|
5628
4428
|
TrajectoryTable_module_css_default.resultBlocks,
|
|
@@ -5634,9 +4434,10 @@ window.__ModuleLoader__.load({
|
|
|
5634
4434
|
children: errorDetail
|
|
5635
4435
|
}), blocks.map((block, index) => block.attachment !== void 0 ? (0, react_jsx_runtime.jsx)("div", {
|
|
5636
4436
|
className: TrajectoryTable_module_css_default.messageImages,
|
|
5637
|
-
children:
|
|
4437
|
+
children: renderSlot("conversation.trajectory.images", {
|
|
5638
4438
|
images: [{ attachment: block.attachment }],
|
|
5639
|
-
align: "start"
|
|
4439
|
+
align: "start",
|
|
4440
|
+
loadImage
|
|
5640
4441
|
})
|
|
5641
4442
|
}, index) : block.content !== "" ? (0, react_jsx_runtime.jsx)("pre", {
|
|
5642
4443
|
className: TrajectoryTable_module_css_default.resultBlockText,
|
|
@@ -5644,7 +4445,7 @@ window.__ModuleLoader__.load({
|
|
|
5644
4445
|
}, index) : null)]
|
|
5645
4446
|
});
|
|
5646
4447
|
}
|
|
5647
|
-
function MarkdownRecordContent({ record, rendered, preview = false, thinkingExpanded, onThinkingExpandedChange, onOpenCall,
|
|
4448
|
+
function MarkdownRecordContent({ record, rendered, preview = false, thinkingExpanded, onThinkingExpandedChange, onOpenCall, renderSlot, loadImage, t }) {
|
|
5648
4449
|
if (record.cell.sourceBlocks?.length && record.cell.sourceBlocks.every((block) => block.type === "tool-addition" || block.type === "tool-removal")) return (0, react_jsx_runtime.jsx)("pre", {
|
|
5649
4450
|
className: `${TrajectoryTable_module_css_default.payload} ${TrajectoryTable_module_css_default.toolUpdatePayload}`,
|
|
5650
4451
|
children: record.cell.inputDetail
|
|
@@ -5703,7 +4504,8 @@ window.__ModuleLoader__.load({
|
|
|
5703
4504
|
(0, react_jsx_runtime.jsx)(RecordAttachments, {
|
|
5704
4505
|
blocks: record.cell.sourceBlocks,
|
|
5705
4506
|
preview,
|
|
5706
|
-
|
|
4507
|
+
renderSlot,
|
|
4508
|
+
loadImage,
|
|
5707
4509
|
t
|
|
5708
4510
|
})
|
|
5709
4511
|
]
|
|
@@ -5741,7 +4543,8 @@ window.__ModuleLoader__.load({
|
|
|
5741
4543
|
(0, react_jsx_runtime.jsx)(RecordAttachments, {
|
|
5742
4544
|
blocks: record.cell.sourceBlocks,
|
|
5743
4545
|
preview,
|
|
5744
|
-
|
|
4546
|
+
renderSlot,
|
|
4547
|
+
loadImage,
|
|
5745
4548
|
t
|
|
5746
4549
|
})
|
|
5747
4550
|
] });
|
|
@@ -5790,7 +4593,7 @@ window.__ModuleLoader__.load({
|
|
|
5790
4593
|
})] }), (0, react_jsx_runtime.jsxs)("div", { children: [(0, react_jsx_runtime.jsx)("dt", { children: t("timing.duration") }), (0, react_jsx_runtime.jsx)("dd", { children: formatElapsedSeconds(null, t) })] })]
|
|
5791
4594
|
});
|
|
5792
4595
|
}
|
|
5793
|
-
function RecordPayload({ record, direction, preview = false,
|
|
4596
|
+
function RecordPayload({ record, direction, preview = false, renderSlot, loadImage, stringWrapping, t }) {
|
|
5794
4597
|
const value = direction === "input" ? record.cell.inputDetail : record.cell.outputDetail;
|
|
5795
4598
|
const missing = direction === "input" ? t("record.noPayload") : t("record.noResult");
|
|
5796
4599
|
if (!value) return (0, react_jsx_runtime.jsx)("p", {
|
|
@@ -5814,7 +4617,8 @@ window.__ModuleLoader__.load({
|
|
|
5814
4617
|
error,
|
|
5815
4618
|
errorDetail: error ? value : void 0,
|
|
5816
4619
|
preview,
|
|
5817
|
-
|
|
4620
|
+
renderSlot,
|
|
4621
|
+
loadImage
|
|
5818
4622
|
});
|
|
5819
4623
|
if (direction === "input" && (record.cell.kind === "user" || record.cell.kind === "context") || direction === "output" && record.cell.kind === "message") return (0, react_jsx_runtime.jsx)("div", {
|
|
5820
4624
|
className: [preview ? TrajectoryTable_module_css_default.markdownPreview : TrajectoryTable_module_css_default.markdownPayload, error ? TrajectoryTable_module_css_default.errorPayload : void 0].filter((className) => className !== void 0).join(" "),
|
|
@@ -6105,7 +4909,7 @@ window.__ModuleLoader__.load({
|
|
|
6105
4909
|
* @param props - Grouped trajectory data and whole-ledger fold state.
|
|
6106
4910
|
* @returns The ledger and an optional local record inspector.
|
|
6107
4911
|
*/
|
|
6108
|
-
function TrajectoryTable({ t, stringWrapping,
|
|
4912
|
+
function TrajectoryTable({ t, stringWrapping, renderSlot, loadImage, requestNumbers: sessionRequestNumbers, turns, streamingCells = [], timelineFocusIndexes = null, searchMatchIndexes = null, onSelectedIndexChange, onRecordSelect, recordSelection = null, recordFocus = null, historyLoading = false, olderHistoryLoading = false, historyStartSeq, hasOlderRecords = false, onLoadOlder, onClearSelection, collapsedTurns, onToggleTurn, collapsedAssistants, onToggleAssistant, inspectCallId = null, onInspectApplied }) {
|
|
6109
4913
|
const [selectedRecordId, setSelectedRecordId] = (0, react.useState)(null);
|
|
6110
4914
|
const [selectedRequest, setSelectedRequest] = (0, react.useState)(null);
|
|
6111
4915
|
const [activeTab, setActiveTab] = (0, react.useState)("overview");
|
|
@@ -6171,7 +4975,7 @@ window.__ModuleLoader__.load({
|
|
|
6171
4975
|
const estimateVirtualRowSize = (0, react.useCallback)((index) => virtualRowStructure[index]?.height ?? 30, [virtualRowStructure]);
|
|
6172
4976
|
const getVirtualRowKey = (0, react.useCallback)((index) => virtualRowStructure[index]?.key ?? index, [virtualRowStructure]);
|
|
6173
4977
|
const getTableScrollElement = (0, react.useCallback)(() => tablePaneRef.current, []);
|
|
6174
|
-
const rowVirtualizer = useVirtualizer({
|
|
4978
|
+
const rowVirtualizer = (0, _tanstack_react_virtual.useVirtualizer)({
|
|
6175
4979
|
count: virtualizationEnabled ? virtualRowStructure.length : 0,
|
|
6176
4980
|
enabled: virtualizationEnabled,
|
|
6177
4981
|
estimateSize: estimateVirtualRowSize,
|
|
@@ -6216,7 +5020,7 @@ window.__ModuleLoader__.load({
|
|
|
6216
5020
|
const selectedState = selected === void 0 ? void 0 : stateOf(selected);
|
|
6217
5021
|
const selectedRequestInfo = selectedRequest === null ? void 0 : sessionRequestNumbers?.find((request) => requestIdentity(request) === selectedRequest.identity);
|
|
6218
5022
|
const selectedRequestRecords = (0, react.useMemo)(() => selectedRequestInfo === void 0 ? [] : allRecords.filter((record) => record.turn === selectedRequestInfo.turn && record.group === selectedRequestInfo.group), [allRecords, selectedRequestInfo]).map(currentRecord);
|
|
6219
|
-
const selectedRequestAssistant = selectedRequestRecords.find((record) => record.cell.kind === "message");
|
|
5023
|
+
const selectedRequestAssistant = selectedRequestRecords.find((record) => record.cell.kind === "message" && record.cell.requestOnly !== true);
|
|
6220
5024
|
const selectedRequestAnchor = selectedRequestAssistant ?? selectedRequestRecords[0];
|
|
6221
5025
|
const selectedRequestNumber = selectedRequestInfo?.number;
|
|
6222
5026
|
const selectedRequestState = selectedRequestInfo === void 0 ? void 0 : selectedRequestInfo.status ?? (selectedRequestAssistant?.cell.assistantMetrics?.completedTime === null ? "running" : selectedRequestAssistant === void 0 && selectedRequestRecords.some((record) => stateOf(record) === "running") ? "running" : "complete");
|
|
@@ -6862,18 +5666,14 @@ window.__ModuleLoader__.load({
|
|
|
6862
5666
|
(selectedRequestInfo.model ?? selectedRequestInfo.requestConfig?.model) !== void 0 && (0, react_jsx_runtime.jsxs)("div", { children: [(0, react_jsx_runtime.jsx)("dt", { children: t("details.model") }), (0, react_jsx_runtime.jsx)("dd", { children: selectedRequestInfo.model ?? selectedRequestInfo.requestConfig?.model })] }),
|
|
6863
5667
|
(0, react_jsx_runtime.jsxs)("div", { children: [(0, react_jsx_runtime.jsx)("dt", { children: t("details.toolCalls") }), (0, react_jsx_runtime.jsx)("dd", { children: selectedRequestToolCalls })] }),
|
|
6864
5668
|
selectedRequestSubtoolCalls > 0 && (0, react_jsx_runtime.jsxs)("div", { children: [(0, react_jsx_runtime.jsx)("dt", { children: t("details.subtoolCalls") }), (0, react_jsx_runtime.jsx)("dd", { children: selectedRequestSubtoolCalls })] }),
|
|
6865
|
-
selectedRequestInfo.error !== void 0 && (0, react_jsx_runtime.jsxs)("div", { children: [(0, react_jsx_runtime.jsx)("dt", { children: t("details.error") }), (0, react_jsx_runtime.jsx)("dd", {
|
|
6866
|
-
className: TrajectoryTable_module_css_default.error,
|
|
5669
|
+
selectedRequestInfo.error !== void 0 && (0, react_jsx_runtime.jsxs)("div", { children: [(0, react_jsx_runtime.jsx)("dt", { children: t(selectedRequestState !== "error" && selectedRequestInfo.retry !== void 0 ? "details.lastAttemptError" : "details.error") }), (0, react_jsx_runtime.jsx)("dd", {
|
|
5670
|
+
className: selectedRequestState === "error" ? TrajectoryTable_module_css_default.error : void 0,
|
|
6867
5671
|
children: requestErrorMessage(selectedRequestInfo, t)
|
|
6868
5672
|
})] }),
|
|
6869
|
-
selectedRequestInfo.retry !== void 0 && (0, react_jsx_runtime.jsxs)("div", { children: [(0, react_jsx_runtime.jsx)("dt", { children: t("details.retry") }), (0, react_jsx_runtime.
|
|
6870
|
-
|
|
6871
|
-
|
|
6872
|
-
|
|
6873
|
-
retry: selectedRequestInfo.retry,
|
|
6874
|
-
maximum: selectedRequestInfo.maxRetries
|
|
6875
|
-
})
|
|
6876
|
-
] })] }),
|
|
5673
|
+
selectedRequestInfo.retry !== void 0 && (0, react_jsx_runtime.jsxs)("div", { children: [(0, react_jsx_runtime.jsx)("dt", { children: t("details.retry") }), (0, react_jsx_runtime.jsx)("dd", { children: selectedRequestInfo.maxRetries === void 0 ? selectedRequestInfo.retry : t("request.retryProgress", {
|
|
5674
|
+
retry: selectedRequestInfo.retry,
|
|
5675
|
+
maximum: selectedRequestInfo.maxRetries
|
|
5676
|
+
}) })] }),
|
|
6877
5677
|
selectedRequestInfo.retryDelayMs !== void 0 && (0, react_jsx_runtime.jsxs)("div", { children: [(0, react_jsx_runtime.jsx)("dt", { children: t("details.retryDelay") }), (0, react_jsx_runtime.jsx)("dd", { children: formatDurationMs(selectedRequestInfo.retryDelayMs, t) })] }),
|
|
6878
5678
|
selectedRequestResult !== void 0 && (0, react_jsx_runtime.jsxs)("div", { children: [(0, react_jsx_runtime.jsx)("dt", { children: t("details.result") }), (0, react_jsx_runtime.jsx)("dd", {
|
|
6879
5679
|
className: TrajectoryTable_module_css_default.overviewParentLinks,
|
|
@@ -6982,7 +5782,8 @@ window.__ModuleLoader__.load({
|
|
|
6982
5782
|
"data-summary-scroll-region": "",
|
|
6983
5783
|
children: (0, react_jsx_runtime.jsx)(MarkdownRecordContent, {
|
|
6984
5784
|
record: selected,
|
|
6985
|
-
|
|
5785
|
+
renderSlot,
|
|
5786
|
+
loadImage,
|
|
6986
5787
|
rendered: true,
|
|
6987
5788
|
thinkingExpanded,
|
|
6988
5789
|
onThinkingExpandedChange: setThinkingExpanded,
|
|
@@ -7087,7 +5888,8 @@ window.__ModuleLoader__.load({
|
|
|
7087
5888
|
},
|
|
7088
5889
|
children: (0, react_jsx_runtime.jsx)(MarkdownRecordContent, {
|
|
7089
5890
|
record: selected,
|
|
7090
|
-
|
|
5891
|
+
renderSlot,
|
|
5892
|
+
loadImage,
|
|
7091
5893
|
rendered: true,
|
|
7092
5894
|
preview: true,
|
|
7093
5895
|
thinkingExpanded,
|
|
@@ -7105,7 +5907,8 @@ window.__ModuleLoader__.load({
|
|
|
7105
5907
|
record: selected,
|
|
7106
5908
|
direction: "input",
|
|
7107
5909
|
preview: true,
|
|
7108
|
-
|
|
5910
|
+
renderSlot,
|
|
5911
|
+
loadImage,
|
|
7109
5912
|
stringWrapping,
|
|
7110
5913
|
t
|
|
7111
5914
|
})
|
|
@@ -7119,7 +5922,8 @@ window.__ModuleLoader__.load({
|
|
|
7119
5922
|
record: selected,
|
|
7120
5923
|
direction: "output",
|
|
7121
5924
|
preview: true,
|
|
7122
|
-
|
|
5925
|
+
renderSlot,
|
|
5926
|
+
loadImage,
|
|
7123
5927
|
stringWrapping,
|
|
7124
5928
|
t
|
|
7125
5929
|
})
|
|
@@ -7164,7 +5968,8 @@ window.__ModuleLoader__.load({
|
|
|
7164
5968
|
] }),
|
|
7165
5969
|
!promptSelected && selected !== void 0 && activeTab === "rendered" && (0, react_jsx_runtime.jsx)(MarkdownRecordContent, {
|
|
7166
5970
|
record: selected,
|
|
7167
|
-
|
|
5971
|
+
renderSlot,
|
|
5972
|
+
loadImage,
|
|
7168
5973
|
rendered: true,
|
|
7169
5974
|
thinkingExpanded,
|
|
7170
5975
|
onThinkingExpandedChange: setThinkingExpanded,
|
|
@@ -7173,7 +5978,8 @@ window.__ModuleLoader__.load({
|
|
|
7173
5978
|
}),
|
|
7174
5979
|
!promptSelected && selected !== void 0 && activeTab === "raw" && (0, react_jsx_runtime.jsx)(MarkdownRecordContent, {
|
|
7175
5980
|
record: selected,
|
|
7176
|
-
|
|
5981
|
+
renderSlot,
|
|
5982
|
+
loadImage,
|
|
7177
5983
|
rendered: false,
|
|
7178
5984
|
thinkingExpanded,
|
|
7179
5985
|
onThinkingExpandedChange: setThinkingExpanded,
|
|
@@ -7188,7 +5994,8 @@ window.__ModuleLoader__.load({
|
|
|
7188
5994
|
!promptSelected && selected !== void 0 && activeTab === "input" && (selectedProgram === void 0 ? (0, react_jsx_runtime.jsx)(RecordPayload, {
|
|
7189
5995
|
record: selected,
|
|
7190
5996
|
direction: "input",
|
|
7191
|
-
|
|
5997
|
+
renderSlot,
|
|
5998
|
+
loadImage,
|
|
7192
5999
|
stringWrapping,
|
|
7193
6000
|
t
|
|
7194
6001
|
}) : (0, react_jsx_runtime.jsx)(ProgramInput, {
|
|
@@ -7200,7 +6007,8 @@ window.__ModuleLoader__.load({
|
|
|
7200
6007
|
!promptSelected && selected !== void 0 && activeTab === "output" && (selectedProgram === void 0 ? (0, react_jsx_runtime.jsx)(RecordPayload, {
|
|
7201
6008
|
record: selected,
|
|
7202
6009
|
direction: "output",
|
|
7203
|
-
|
|
6010
|
+
renderSlot,
|
|
6011
|
+
loadImage,
|
|
7204
6012
|
stringWrapping,
|
|
7205
6013
|
t
|
|
7206
6014
|
}) : (0, react_jsx_runtime.jsx)(ProgramOutput, {
|
|
@@ -8322,7 +7130,10 @@ window.__ModuleLoader__.load({
|
|
|
8322
7130
|
turn: partial.turn,
|
|
8323
7131
|
step: partial.step,
|
|
8324
7132
|
blocks: partial.blocks
|
|
8325
|
-
}, index + 1, prevAbsTime, resultByCall, callStartById, callById, t, {
|
|
7133
|
+
}, index + 1, prevAbsTime, resultByCall, callStartById, callById, t, {
|
|
7134
|
+
streaming: true,
|
|
7135
|
+
timing: partial.timing
|
|
7136
|
+
}), t);
|
|
8326
7137
|
if (partial.step > 0) pushStep(partial.turn, partial.step, laidList);
|
|
8327
7138
|
else for (const laid of laidList) pushMessage(partial.turn, laid);
|
|
8328
7139
|
const last = laidList[laidList.length - 1];
|
|
@@ -8485,7 +7296,8 @@ window.__ModuleLoader__.load({
|
|
|
8485
7296
|
let index = startIndex - 1;
|
|
8486
7297
|
const usage = node.usage;
|
|
8487
7298
|
const streaming = opts?.streaming === true;
|
|
8488
|
-
const
|
|
7299
|
+
const timing = opts?.timing ?? node.timing;
|
|
7300
|
+
const recordedStart = finiteTime(timing?.stepStartTime);
|
|
8489
7301
|
const messageDuration = streaming ? null : durationSeconds(node.time, recordedStart ?? prevAbsTime);
|
|
8490
7302
|
const nodeAbs = streaming ? null : finiteTime(node.time);
|
|
8491
7303
|
const messageText = node.blocks.filter((block) => block.kind === "text" && (!streaming || block.text !== "")).map((block) => block.kind === "text" ? block.text : "").join("\n\n");
|
|
@@ -8500,14 +7312,15 @@ window.__ModuleLoader__.load({
|
|
|
8500
7312
|
...messageText !== "" ? { outputDetail: messageText } : {},
|
|
8501
7313
|
...thinkingText !== "" ? { thinkingDetail: thinkingText } : {},
|
|
8502
7314
|
sourceBlocks: node.blocks.map((block) => assistantSourceBlock(block)),
|
|
7315
|
+
...node.interrupted === true ? { isError: true } : {},
|
|
8503
7316
|
timeSeconds: messageDuration,
|
|
8504
7317
|
startedAt: recordedStart
|
|
8505
7318
|
};
|
|
8506
7319
|
attachUsage(message, usage);
|
|
8507
7320
|
message.assistantMetrics = {
|
|
8508
|
-
timingRecorded:
|
|
8509
|
-
stepStartTime:
|
|
8510
|
-
firstTokenTime:
|
|
7321
|
+
timingRecorded: timing !== void 0,
|
|
7322
|
+
stepStartTime: timing?.stepStartTime ?? null,
|
|
7323
|
+
firstTokenTime: timing?.firstTokenTime ?? null,
|
|
8511
7324
|
completedTime: streaming ? null : finiteTime(node.time),
|
|
8512
7325
|
usageProvided: usage !== void 0,
|
|
8513
7326
|
outputTokens: Number.isFinite(usage?.outputTokens) ? usage?.outputTokens ?? null : null
|
|
@@ -8971,10 +7784,6 @@ window.__ModuleLoader__.load({
|
|
|
8971
7784
|
}
|
|
8972
7785
|
function TrajectoryView({ useSession, useTrajectory, useDuration, loadOlder, loadImage, setActualDuration, viewRequest, completeViewRequest, renderSlot, t, jsonStringWrapping }) {
|
|
8973
7786
|
const [collapsedTurns, setCollapsedTurns] = (0, react.useState)(EMPTY_TURN_IDS);
|
|
8974
|
-
const renderImages = (0, react.useCallback)((owner) => renderSlot("conversation.trajectory.images", {
|
|
8975
|
-
...owner,
|
|
8976
|
-
loadImage
|
|
8977
|
-
}), [loadImage, renderSlot]);
|
|
8978
7787
|
const [collapsedAssistants, setCollapsedAssistants] = (0, react.useState)(EMPTY_RECORD_IDS);
|
|
8979
7788
|
const [timelineSelection, setTimelineSelection] = (0, react.useState)(null);
|
|
8980
7789
|
const actualDuration = useDuration((value) => value);
|
|
@@ -9060,18 +7869,21 @@ window.__ModuleLoader__.load({
|
|
|
9060
7869
|
const provider = request?.providerMetadata?.provider ?? node?.providerMetadata?.provider;
|
|
9061
7870
|
const model = request?.providerMetadata?.model ?? node?.providerMetadata?.model;
|
|
9062
7871
|
const requestConfig = request?.requestConfig ?? node?.requestConfig;
|
|
7872
|
+
const startedAt = request?.startedAt;
|
|
7873
|
+
const completedAt = request === void 0 ? node?.time : request.completedAt;
|
|
7874
|
+
const resultSeq = request?.resultSeq ?? node?.seq;
|
|
9063
7875
|
numbered.push({
|
|
9064
7876
|
seq: entry.seq,
|
|
9065
7877
|
turn,
|
|
9066
7878
|
step,
|
|
9067
7879
|
group: t("group.step", { step }),
|
|
9068
7880
|
number: index + 1,
|
|
9069
|
-
|
|
9070
|
-
...
|
|
9071
|
-
...
|
|
7881
|
+
status: request?.status ?? (node?.interrupted === true ? "error" : "complete"),
|
|
7882
|
+
...startedAt === void 0 ? {} : { startedAt },
|
|
7883
|
+
...completedAt === void 0 ? {} : { completedAt },
|
|
9072
7884
|
...request?.error === void 0 ? {} : { error: request.error },
|
|
9073
7885
|
...request?.errorCode === void 0 ? {} : { errorCode: request.errorCode },
|
|
9074
|
-
...
|
|
7886
|
+
...resultSeq === void 0 ? {} : { resultSeq },
|
|
9075
7887
|
...request?.retry === void 0 ? {} : { retry: request.retry },
|
|
9076
7888
|
...request?.maxRetries === void 0 ? {} : { maxRetries: request.maxRetries },
|
|
9077
7889
|
...request?.retryDelayMs === void 0 ? {} : { retryDelayMs: request.retryDelayMs },
|
|
@@ -9096,7 +7908,7 @@ window.__ModuleLoader__.load({
|
|
|
9096
7908
|
completedAt: request.completedAt,
|
|
9097
7909
|
...request.error === void 0 ? {} : { error: request.error },
|
|
9098
7910
|
...request.errorCode === void 0 ? {} : { errorCode: request.errorCode },
|
|
9099
|
-
resultSeq: request.startSeq,
|
|
7911
|
+
...request.status === "running" ? {} : { resultSeq: request.startSeq },
|
|
9100
7912
|
...request.providerMetadata?.provider === void 0 ? {} : { provider: request.providerMetadata.provider },
|
|
9101
7913
|
...request.providerMetadata?.model === void 0 ? {} : { model: request.providerMetadata.model },
|
|
9102
7914
|
...request.requestConfig === void 0 ? {} : { requestConfig: request.requestConfig },
|
|
@@ -9141,14 +7953,20 @@ window.__ModuleLoader__.load({
|
|
|
9141
7953
|
callSchemas,
|
|
9142
7954
|
t
|
|
9143
7955
|
]);
|
|
7956
|
+
const timelinePartialSignature = partialStructureSignature(partial);
|
|
7957
|
+
const partialStartTime = partial?.timing?.stepStartTime;
|
|
7958
|
+
const partialFirstTokenTime = partial?.timing?.firstTokenTime;
|
|
9144
7959
|
const timelinePartial = (0, react.useMemo)(() => partial === null ? null : {
|
|
9145
7960
|
turn: partial.turn,
|
|
9146
7961
|
step: partial.step,
|
|
9147
|
-
blocks: partial.blocks.map((block) => timelineBlock(block))
|
|
7962
|
+
blocks: partial.blocks.map((block) => timelineBlock(block)),
|
|
7963
|
+
...partial.timing === void 0 ? {} : { timing: partial.timing }
|
|
9148
7964
|
}, [
|
|
9149
7965
|
partialStep,
|
|
9150
7966
|
partialTurn,
|
|
9151
|
-
|
|
7967
|
+
timelinePartialSignature,
|
|
7968
|
+
partialStartTime,
|
|
7969
|
+
partialFirstTokenTime
|
|
9152
7970
|
]);
|
|
9153
7971
|
const timelineTurns = (0, react.useMemo)(() => appendTrajectoryPartialLayout(finalized.turns, timelinePartial, finalized.lastIndex, t), [
|
|
9154
7972
|
finalized,
|
|
@@ -9308,7 +8126,8 @@ window.__ModuleLoader__.load({
|
|
|
9308
8126
|
...jsonStringWrapping,
|
|
9309
8127
|
label: t("record.wrapLines")
|
|
9310
8128
|
},
|
|
9311
|
-
|
|
8129
|
+
renderSlot,
|
|
8130
|
+
loadImage,
|
|
9312
8131
|
requestNumbers,
|
|
9313
8132
|
turns: timelineTurns,
|
|
9314
8133
|
streamingCells,
|