@deepseek-ai/dsh-experimental-session-inspector 0.2.1-alpha.2 → 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/lib/client.js +4 -1211
- package/package.json +16 -18
package/lib/client.js
CHANGED
|
@@ -4,34 +4,12 @@ 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");
|
|
12
|
+
let react_dom = require("react-dom");
|
|
35
13
|
//#region lib/types/client/locales.js
|
|
36
14
|
/** Session Inspector tab, table controls, and object navigation labels. */
|
|
37
15
|
/** Namespace owned by the Session Inspector plugin. */
|
|
@@ -2133,1191 +2111,6 @@ window.__ModuleLoader__.load({
|
|
|
2133
2111
|
};
|
|
2134
2112
|
}
|
|
2135
2113
|
//#endregion
|
|
2136
|
-
//#region ../../../node_modules/.pnpm/@tanstack+virtual-core@3.17.8/node_modules/@tanstack/virtual-core/dist/esm/lazy-measurements.js
|
|
2137
|
-
function createLazyMeasurementsView(count, flat, getItemKey) {
|
|
2138
|
-
const cache = new Array(count);
|
|
2139
|
-
return new Proxy(cache, { get(target, prop, receiver) {
|
|
2140
|
-
if (typeof prop === "string") {
|
|
2141
|
-
const c = prop.charCodeAt(0);
|
|
2142
|
-
if (c >= 48 && c <= 57) {
|
|
2143
|
-
const i = +prop;
|
|
2144
|
-
if (Number.isInteger(i) && i >= 0 && i < count) {
|
|
2145
|
-
let v = target[i];
|
|
2146
|
-
if (!v) {
|
|
2147
|
-
const s = flat[i * 2];
|
|
2148
|
-
v = target[i] = {
|
|
2149
|
-
index: i,
|
|
2150
|
-
key: getItemKey(i),
|
|
2151
|
-
start: s,
|
|
2152
|
-
size: flat[i * 2 + 1],
|
|
2153
|
-
end: s + flat[i * 2 + 1],
|
|
2154
|
-
lane: 0
|
|
2155
|
-
};
|
|
2156
|
-
}
|
|
2157
|
-
return v;
|
|
2158
|
-
}
|
|
2159
|
-
}
|
|
2160
|
-
if (prop === "length") return count;
|
|
2161
|
-
}
|
|
2162
|
-
return Reflect.get(target, prop, receiver);
|
|
2163
|
-
} });
|
|
2164
|
-
}
|
|
2165
|
-
//#endregion
|
|
2166
|
-
//#region ../../../node_modules/.pnpm/@tanstack+virtual-core@3.17.8/node_modules/@tanstack/virtual-core/dist/esm/utils.js
|
|
2167
|
-
function memo$1(getDeps, fn, opts) {
|
|
2168
|
-
let deps = opts.initialDeps ?? [];
|
|
2169
|
-
let result;
|
|
2170
|
-
let isInitial = true;
|
|
2171
|
-
function memoizedFunction() {
|
|
2172
|
-
const newDeps = getDeps();
|
|
2173
|
-
if (!(newDeps.length !== deps.length || newDeps.some((dep, index) => deps[index] !== dep))) return result;
|
|
2174
|
-
deps = newDeps;
|
|
2175
|
-
result = fn(...newDeps);
|
|
2176
|
-
if ((opts == null ? void 0 : opts.onChange) && !(isInitial && opts.skipInitialOnChange)) opts.onChange(result);
|
|
2177
|
-
isInitial = false;
|
|
2178
|
-
return result;
|
|
2179
|
-
}
|
|
2180
|
-
memoizedFunction.updateDeps = (newDeps) => {
|
|
2181
|
-
deps = newDeps;
|
|
2182
|
-
};
|
|
2183
|
-
return memoizedFunction;
|
|
2184
|
-
}
|
|
2185
|
-
function notUndefined(value, msg) {
|
|
2186
|
-
if (value === void 0) throw new Error(`Unexpected undefined${msg ? `: ${msg}` : ""}`);
|
|
2187
|
-
else return value;
|
|
2188
|
-
}
|
|
2189
|
-
const approxEqual = (a, b) => Math.abs(a - b) < 1.01;
|
|
2190
|
-
const debounce = (targetWindow, fn, ms) => {
|
|
2191
|
-
let timeoutId;
|
|
2192
|
-
return Object.assign(function(...args) {
|
|
2193
|
-
targetWindow.clearTimeout(timeoutId);
|
|
2194
|
-
timeoutId = targetWindow.setTimeout(() => fn.apply(this, args), ms);
|
|
2195
|
-
}, { cancel: () => {
|
|
2196
|
-
targetWindow.clearTimeout(timeoutId);
|
|
2197
|
-
} });
|
|
2198
|
-
};
|
|
2199
|
-
//#endregion
|
|
2200
|
-
//#region ../../../node_modules/.pnpm/@tanstack+virtual-core@3.17.8/node_modules/@tanstack/virtual-core/dist/esm/index.js
|
|
2201
|
-
let _isIOSResult;
|
|
2202
|
-
const isIOSWebKit = () => {
|
|
2203
|
-
if (_isIOSResult !== void 0) return _isIOSResult;
|
|
2204
|
-
if (typeof navigator === "undefined") return _isIOSResult = false;
|
|
2205
|
-
if (/iP(hone|od|ad)/.test(navigator.userAgent)) return _isIOSResult = true;
|
|
2206
|
-
const mtp = navigator.maxTouchPoints;
|
|
2207
|
-
return _isIOSResult = navigator.platform === "MacIntel" && mtp !== void 0 && mtp > 0;
|
|
2208
|
-
};
|
|
2209
|
-
const getRect = (element) => {
|
|
2210
|
-
const { offsetWidth, offsetHeight } = element;
|
|
2211
|
-
return {
|
|
2212
|
-
width: offsetWidth,
|
|
2213
|
-
height: offsetHeight
|
|
2214
|
-
};
|
|
2215
|
-
};
|
|
2216
|
-
const defaultKeyExtractor = (index) => index;
|
|
2217
|
-
const defaultRangeExtractor = (range) => {
|
|
2218
|
-
const start = Math.max(range.startIndex - range.overscan, 0);
|
|
2219
|
-
const len = Math.min(range.endIndex + range.overscan, range.count - 1) - start + 1;
|
|
2220
|
-
const arr = new Array(len);
|
|
2221
|
-
for (let i = 0; i < len; i++) arr[i] = start + i;
|
|
2222
|
-
return arr;
|
|
2223
|
-
};
|
|
2224
|
-
const observeElementRect = (instance, cb) => {
|
|
2225
|
-
const element = instance.scrollElement;
|
|
2226
|
-
if (!element) return;
|
|
2227
|
-
const targetWindow = instance.targetWindow;
|
|
2228
|
-
if (!targetWindow) return;
|
|
2229
|
-
const handler = (rect) => {
|
|
2230
|
-
const { width, height } = rect;
|
|
2231
|
-
cb({
|
|
2232
|
-
width: Math.round(width),
|
|
2233
|
-
height: Math.round(height)
|
|
2234
|
-
});
|
|
2235
|
-
};
|
|
2236
|
-
handler(getRect(element));
|
|
2237
|
-
if (!targetWindow.ResizeObserver) return () => {};
|
|
2238
|
-
const observer = new targetWindow.ResizeObserver((entries) => {
|
|
2239
|
-
const run = () => {
|
|
2240
|
-
const entry = entries[0];
|
|
2241
|
-
if (entry == null ? void 0 : entry.borderBoxSize) {
|
|
2242
|
-
const box = entry.borderBoxSize[0];
|
|
2243
|
-
if (box) {
|
|
2244
|
-
handler({
|
|
2245
|
-
width: box.inlineSize,
|
|
2246
|
-
height: box.blockSize
|
|
2247
|
-
});
|
|
2248
|
-
return;
|
|
2249
|
-
}
|
|
2250
|
-
}
|
|
2251
|
-
handler(getRect(element));
|
|
2252
|
-
};
|
|
2253
|
-
instance.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(run) : run();
|
|
2254
|
-
});
|
|
2255
|
-
observer.observe(element, { box: "border-box" });
|
|
2256
|
-
return () => {
|
|
2257
|
-
observer.unobserve(element);
|
|
2258
|
-
};
|
|
2259
|
-
};
|
|
2260
|
-
const addEventListenerOptions = { passive: true };
|
|
2261
|
-
const supportsScrollend = typeof window == "undefined" ? true : "onscrollend" in window;
|
|
2262
|
-
const observeOffset = (instance, cb, readOffset) => {
|
|
2263
|
-
const element = instance.scrollElement;
|
|
2264
|
-
if (!element) return;
|
|
2265
|
-
const targetWindow = instance.targetWindow;
|
|
2266
|
-
if (!targetWindow) return;
|
|
2267
|
-
const registerScrollendEvent = instance.options.useScrollendEvent && supportsScrollend;
|
|
2268
|
-
let offset = 0;
|
|
2269
|
-
const fallback = registerScrollendEvent ? null : debounce(targetWindow, () => cb(offset, false), instance.options.isScrollingResetDelay);
|
|
2270
|
-
const createHandler = (isScrolling) => () => {
|
|
2271
|
-
offset = readOffset(element);
|
|
2272
|
-
fallback?.();
|
|
2273
|
-
cb(offset, isScrolling);
|
|
2274
|
-
};
|
|
2275
|
-
const handler = createHandler(true);
|
|
2276
|
-
const endHandler = createHandler(false);
|
|
2277
|
-
element.addEventListener("scroll", handler, addEventListenerOptions);
|
|
2278
|
-
if (registerScrollendEvent) element.addEventListener("scrollend", endHandler, addEventListenerOptions);
|
|
2279
|
-
return () => {
|
|
2280
|
-
element.removeEventListener("scroll", handler);
|
|
2281
|
-
if (registerScrollendEvent) element.removeEventListener("scrollend", endHandler);
|
|
2282
|
-
fallback?.cancel();
|
|
2283
|
-
};
|
|
2284
|
-
};
|
|
2285
|
-
const observeElementOffset = (instance, cb) => observeOffset(instance, cb, (el) => {
|
|
2286
|
-
const { horizontal, isRtl } = instance.options;
|
|
2287
|
-
return horizontal ? el.scrollLeft * (isRtl && -1 || 1) : el.scrollTop;
|
|
2288
|
-
});
|
|
2289
|
-
const measureElement = (element, entry, instance) => {
|
|
2290
|
-
if (instance.options.useCachedMeasurements) {
|
|
2291
|
-
const index = instance.indexFromElement(element);
|
|
2292
|
-
const key = instance.options.getItemKey(index);
|
|
2293
|
-
return instance.itemSizeCache.get(key) ?? instance.options.estimateSize(index);
|
|
2294
|
-
}
|
|
2295
|
-
if (entry == null ? void 0 : entry.borderBoxSize) {
|
|
2296
|
-
const box = entry.borderBoxSize[0];
|
|
2297
|
-
if (box) return Math.round(box[instance.options.horizontal ? "inlineSize" : "blockSize"]);
|
|
2298
|
-
}
|
|
2299
|
-
if (!entry) {
|
|
2300
|
-
const index = instance.indexFromElement(element);
|
|
2301
|
-
const key = instance.options.getItemKey(index);
|
|
2302
|
-
const cachedSize = instance.itemSizeCache.get(key);
|
|
2303
|
-
if (cachedSize !== void 0) return cachedSize;
|
|
2304
|
-
}
|
|
2305
|
-
return element[instance.options.horizontal ? "offsetWidth" : "offsetHeight"];
|
|
2306
|
-
};
|
|
2307
|
-
const scrollWithAdjustments = (offset, { adjustments = 0, behavior }, instance) => {
|
|
2308
|
-
var _a, _b;
|
|
2309
|
-
(_b = (_a = instance.scrollElement) == null ? void 0 : _a.scrollTo) == null || _b.call(_a, {
|
|
2310
|
-
[instance.options.horizontal ? "left" : "top"]: offset + adjustments,
|
|
2311
|
-
behavior
|
|
2312
|
-
});
|
|
2313
|
-
};
|
|
2314
|
-
const elementScroll = scrollWithAdjustments;
|
|
2315
|
-
var Virtualizer = class {
|
|
2316
|
-
constructor(opts) {
|
|
2317
|
-
this.unsubs = [];
|
|
2318
|
-
this.scrollElement = null;
|
|
2319
|
-
this.targetWindow = null;
|
|
2320
|
-
this.isScrolling = false;
|
|
2321
|
-
this.scrollState = null;
|
|
2322
|
-
this.measurementsCache = [];
|
|
2323
|
-
this._flatMeasurements = null;
|
|
2324
|
-
this.itemSizeCache = /* @__PURE__ */ new Map();
|
|
2325
|
-
this.itemSizeCacheVersion = 0;
|
|
2326
|
-
this.laneAssignments = /* @__PURE__ */ new Map();
|
|
2327
|
-
this.pendingMin = null;
|
|
2328
|
-
this.prevLanes = void 0;
|
|
2329
|
-
this.lanesChangedFlag = false;
|
|
2330
|
-
this.lanesSettling = false;
|
|
2331
|
-
this.pendingScrollAnchor = null;
|
|
2332
|
-
this.scrollRect = null;
|
|
2333
|
-
this.scrollOffset = null;
|
|
2334
|
-
this.scrollDirection = null;
|
|
2335
|
-
this.scrollAdjustments = 0;
|
|
2336
|
-
this._iosDeferredAdjustment = 0;
|
|
2337
|
-
this._iosTouching = false;
|
|
2338
|
-
this._iosJustTouchEnded = false;
|
|
2339
|
-
this._iosTouchEndTimerId = null;
|
|
2340
|
-
this._intendedScrollOffset = null;
|
|
2341
|
-
this.elementsCache = /* @__PURE__ */ new Map();
|
|
2342
|
-
this.now = () => {
|
|
2343
|
-
var _a, _b, _c;
|
|
2344
|
-
return ((_c = (_b = (_a = this.targetWindow) == null ? void 0 : _a.performance) == null ? void 0 : _b.now) == null ? void 0 : _c.call(_b)) ?? Date.now();
|
|
2345
|
-
};
|
|
2346
|
-
this.observer = /* @__PURE__ */ (() => {
|
|
2347
|
-
let _ro = null;
|
|
2348
|
-
const get = () => {
|
|
2349
|
-
if (_ro) return _ro;
|
|
2350
|
-
if (!this.targetWindow || !this.targetWindow.ResizeObserver) return null;
|
|
2351
|
-
return _ro = new this.targetWindow.ResizeObserver((entries) => {
|
|
2352
|
-
entries.forEach((entry) => {
|
|
2353
|
-
const run = () => {
|
|
2354
|
-
const node = entry.target;
|
|
2355
|
-
const index = this.indexFromElement(node);
|
|
2356
|
-
if (!node.isConnected) {
|
|
2357
|
-
this.observer.unobserve(node);
|
|
2358
|
-
for (const [cacheKey, cachedNode] of this.elementsCache) if (cachedNode === node) {
|
|
2359
|
-
this.elementsCache.delete(cacheKey);
|
|
2360
|
-
break;
|
|
2361
|
-
}
|
|
2362
|
-
return;
|
|
2363
|
-
}
|
|
2364
|
-
if (!this.isIndexInRange(index)) return;
|
|
2365
|
-
if (this.shouldMeasureDuringScroll(index)) this.resizeItem(index, this.options.measureElement(node, entry, this));
|
|
2366
|
-
};
|
|
2367
|
-
this.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(run) : run();
|
|
2368
|
-
});
|
|
2369
|
-
});
|
|
2370
|
-
};
|
|
2371
|
-
return {
|
|
2372
|
-
disconnect: () => {
|
|
2373
|
-
var _a;
|
|
2374
|
-
(_a = get()) == null || _a.disconnect();
|
|
2375
|
-
_ro = null;
|
|
2376
|
-
},
|
|
2377
|
-
observe: (target) => {
|
|
2378
|
-
var _a;
|
|
2379
|
-
return (_a = get()) == null ? void 0 : _a.observe(target, { box: "border-box" });
|
|
2380
|
-
},
|
|
2381
|
-
unobserve: (target) => {
|
|
2382
|
-
var _a;
|
|
2383
|
-
return (_a = get()) == null ? void 0 : _a.unobserve(target);
|
|
2384
|
-
}
|
|
2385
|
-
};
|
|
2386
|
-
})();
|
|
2387
|
-
this.range = null;
|
|
2388
|
-
this.setOptions = (opts2) => {
|
|
2389
|
-
var _a, _b;
|
|
2390
|
-
const merged = {
|
|
2391
|
-
debug: false,
|
|
2392
|
-
initialOffset: 0,
|
|
2393
|
-
overscan: 1,
|
|
2394
|
-
paddingStart: 0,
|
|
2395
|
-
paddingEnd: 0,
|
|
2396
|
-
scrollPaddingStart: 0,
|
|
2397
|
-
scrollPaddingEnd: 0,
|
|
2398
|
-
horizontal: false,
|
|
2399
|
-
getItemKey: defaultKeyExtractor,
|
|
2400
|
-
rangeExtractor: defaultRangeExtractor,
|
|
2401
|
-
onChange: () => {},
|
|
2402
|
-
measureElement,
|
|
2403
|
-
initialRect: {
|
|
2404
|
-
width: 0,
|
|
2405
|
-
height: 0
|
|
2406
|
-
},
|
|
2407
|
-
scrollMargin: 0,
|
|
2408
|
-
gap: 0,
|
|
2409
|
-
indexAttribute: "data-index",
|
|
2410
|
-
initialMeasurementsCache: [],
|
|
2411
|
-
lanes: 1,
|
|
2412
|
-
anchorTo: "start",
|
|
2413
|
-
followOnAppend: false,
|
|
2414
|
-
scrollEndThreshold: 1,
|
|
2415
|
-
isScrollingResetDelay: 150,
|
|
2416
|
-
enabled: true,
|
|
2417
|
-
isRtl: false,
|
|
2418
|
-
useScrollendEvent: false,
|
|
2419
|
-
useAnimationFrameWithResizeObserver: false,
|
|
2420
|
-
laneAssignmentMode: "estimate",
|
|
2421
|
-
useCachedMeasurements: false
|
|
2422
|
-
};
|
|
2423
|
-
for (const key in opts2) {
|
|
2424
|
-
const v = opts2[key];
|
|
2425
|
-
if (v !== void 0) merged[key] = v;
|
|
2426
|
-
}
|
|
2427
|
-
const prevOptions = this.options;
|
|
2428
|
-
let anchor = null;
|
|
2429
|
-
let followOnAppend = null;
|
|
2430
|
-
let edgeKeysChanged = false;
|
|
2431
|
-
if (prevOptions !== void 0 && prevOptions.enabled && merged.enabled && merged.anchorTo === "end" && this.scrollElement !== null) {
|
|
2432
|
-
const prevCount = prevOptions.count;
|
|
2433
|
-
const nextCount = merged.count;
|
|
2434
|
-
const measurements = this.getMeasurements();
|
|
2435
|
-
const prevFirstKey = prevCount > 0 ? ((_a = measurements[0]) == null ? void 0 : _a.key) ?? prevOptions.getItemKey(0) : null;
|
|
2436
|
-
const prevLastKey = prevCount > 0 ? ((_b = measurements[prevCount - 1]) == null ? void 0 : _b.key) ?? prevOptions.getItemKey(prevCount - 1) : null;
|
|
2437
|
-
if (nextCount !== prevCount || prevCount > 0 && nextCount > 0 && (merged.getItemKey(0) !== prevFirstKey || merged.getItemKey(nextCount - 1) !== prevLastKey)) {
|
|
2438
|
-
edgeKeysChanged = true;
|
|
2439
|
-
const item = prevCount > 0 ? this.getVirtualItemForOffset(this.getScrollOffset()) ?? measurements[0] : null;
|
|
2440
|
-
if (item) anchor = [item.key, this.getScrollOffset() - item.start];
|
|
2441
|
-
const behavior = merged.followOnAppend === true ? "auto" : merged.followOnAppend || null;
|
|
2442
|
-
if (behavior && nextCount > prevCount && this.isAtEnd(prevOptions.scrollEndThreshold) && (prevCount === 0 || merged.getItemKey(nextCount - 1) !== prevLastKey)) followOnAppend = behavior;
|
|
2443
|
-
}
|
|
2444
|
-
}
|
|
2445
|
-
this.options = merged;
|
|
2446
|
-
if (edgeKeysChanged) {
|
|
2447
|
-
this.pendingMin = 0;
|
|
2448
|
-
this.itemSizeCacheVersion++;
|
|
2449
|
-
}
|
|
2450
|
-
let anchorResolved = false;
|
|
2451
|
-
let anchorDelta = 0;
|
|
2452
|
-
if (anchor && this.scrollOffset !== null) {
|
|
2453
|
-
const [anchorKey, anchorOffset] = anchor;
|
|
2454
|
-
const newMeasurements = this.getMeasurements();
|
|
2455
|
-
const { count, getItemKey } = this.options;
|
|
2456
|
-
let idx = 0;
|
|
2457
|
-
while (idx < count && getItemKey(idx) !== anchorKey) idx++;
|
|
2458
|
-
if (idx < count) {
|
|
2459
|
-
const anchorItem = newMeasurements[idx];
|
|
2460
|
-
if (anchorItem) {
|
|
2461
|
-
const newOffset = Math.max(0, anchorItem.start + anchorOffset);
|
|
2462
|
-
if (newOffset !== this.scrollOffset) {
|
|
2463
|
-
anchorDelta = newOffset - this.scrollOffset;
|
|
2464
|
-
this.scrollOffset = newOffset;
|
|
2465
|
-
anchorResolved = true;
|
|
2466
|
-
}
|
|
2467
|
-
}
|
|
2468
|
-
}
|
|
2469
|
-
}
|
|
2470
|
-
if (anchorResolved || followOnAppend) this.pendingScrollAnchor = [
|
|
2471
|
-
anchorResolved ? anchor[0] : null,
|
|
2472
|
-
anchorResolved ? anchor[1] : 0,
|
|
2473
|
-
followOnAppend,
|
|
2474
|
-
anchorDelta
|
|
2475
|
-
];
|
|
2476
|
-
};
|
|
2477
|
-
this.notify = (sync) => {
|
|
2478
|
-
var _a, _b;
|
|
2479
|
-
(_b = (_a = this.options).onChange) == null || _b.call(_a, this, sync);
|
|
2480
|
-
};
|
|
2481
|
-
this.maybeNotify = memo$1(() => {
|
|
2482
|
-
this.calculateRange();
|
|
2483
|
-
return [
|
|
2484
|
-
this.isScrolling,
|
|
2485
|
-
this.range ? this.range.startIndex : null,
|
|
2486
|
-
this.range ? this.range.endIndex : null
|
|
2487
|
-
];
|
|
2488
|
-
}, (isScrolling) => {
|
|
2489
|
-
this.notify(isScrolling);
|
|
2490
|
-
}, {
|
|
2491
|
-
key: false,
|
|
2492
|
-
debug: () => this.options.debug,
|
|
2493
|
-
initialDeps: [
|
|
2494
|
-
this.isScrolling,
|
|
2495
|
-
this.range ? this.range.startIndex : null,
|
|
2496
|
-
this.range ? this.range.endIndex : null
|
|
2497
|
-
]
|
|
2498
|
-
});
|
|
2499
|
-
this.cleanup = () => {
|
|
2500
|
-
this.unsubs.filter(Boolean).forEach((d) => d());
|
|
2501
|
-
this.unsubs = [];
|
|
2502
|
-
this.observer.disconnect();
|
|
2503
|
-
if (this.rafId != null && this.targetWindow) {
|
|
2504
|
-
this.targetWindow.cancelAnimationFrame(this.rafId);
|
|
2505
|
-
this.rafId = null;
|
|
2506
|
-
}
|
|
2507
|
-
this.scrollState = null;
|
|
2508
|
-
this.isScrolling = false;
|
|
2509
|
-
this.scrollDirection = null;
|
|
2510
|
-
this._iosDeferredAdjustment = 0;
|
|
2511
|
-
this._iosTouching = false;
|
|
2512
|
-
this._iosJustTouchEnded = false;
|
|
2513
|
-
this.scrollElement = null;
|
|
2514
|
-
this.targetWindow = null;
|
|
2515
|
-
};
|
|
2516
|
-
this._didMount = () => {
|
|
2517
|
-
return () => {
|
|
2518
|
-
this.cleanup();
|
|
2519
|
-
};
|
|
2520
|
-
};
|
|
2521
|
-
this._willUpdate = () => {
|
|
2522
|
-
var _a;
|
|
2523
|
-
const scrollElement = this.options.enabled ? this.options.getScrollElement() : null;
|
|
2524
|
-
if (this.scrollElement !== scrollElement) {
|
|
2525
|
-
this.cleanup();
|
|
2526
|
-
if (!scrollElement) {
|
|
2527
|
-
this.maybeNotify();
|
|
2528
|
-
return;
|
|
2529
|
-
}
|
|
2530
|
-
this.scrollElement = scrollElement;
|
|
2531
|
-
if (this.scrollElement && "ownerDocument" in this.scrollElement) this.targetWindow = this.scrollElement.ownerDocument.defaultView;
|
|
2532
|
-
else this.targetWindow = ((_a = this.scrollElement) == null ? void 0 : _a.window) ?? null;
|
|
2533
|
-
this.elementsCache.forEach((cached) => {
|
|
2534
|
-
this.observer.observe(cached);
|
|
2535
|
-
});
|
|
2536
|
-
this.unsubs.push(this.options.observeElementRect(this, (rect) => {
|
|
2537
|
-
this.scrollRect = rect;
|
|
2538
|
-
this.maybeNotify();
|
|
2539
|
-
}));
|
|
2540
|
-
this.unsubs.push(this.options.observeElementOffset(this, (offset, isScrolling) => {
|
|
2541
|
-
if (isScrolling && this._intendedScrollOffset === null && offset === this.scrollOffset) return;
|
|
2542
|
-
if (this._intendedScrollOffset !== null && Math.abs(offset - this._intendedScrollOffset) < 1.5) offset = this._intendedScrollOffset;
|
|
2543
|
-
this._intendedScrollOffset = null;
|
|
2544
|
-
this.scrollAdjustments = 0;
|
|
2545
|
-
const prevOffset = this.getScrollOffset();
|
|
2546
|
-
this.scrollDirection = isScrolling ? prevOffset === offset ? this.scrollDirection : prevOffset < offset ? "forward" : "backward" : null;
|
|
2547
|
-
this.scrollOffset = offset;
|
|
2548
|
-
this.isScrolling = isScrolling;
|
|
2549
|
-
this._flushIosDeferredIfReady();
|
|
2550
|
-
if (this.scrollState) this.scheduleScrollReconcile();
|
|
2551
|
-
this.maybeNotify();
|
|
2552
|
-
}));
|
|
2553
|
-
if ("addEventListener" in this.scrollElement) {
|
|
2554
|
-
const scrollEl = this.scrollElement;
|
|
2555
|
-
const onTouchStart = () => {
|
|
2556
|
-
this._iosTouching = true;
|
|
2557
|
-
this._iosJustTouchEnded = false;
|
|
2558
|
-
if (this._iosTouchEndTimerId !== null && this.targetWindow != null) {
|
|
2559
|
-
this.targetWindow.clearTimeout(this._iosTouchEndTimerId);
|
|
2560
|
-
this._iosTouchEndTimerId = null;
|
|
2561
|
-
}
|
|
2562
|
-
};
|
|
2563
|
-
const onTouchEnd = () => {
|
|
2564
|
-
this._iosTouching = false;
|
|
2565
|
-
if (!isIOSWebKit() || this.targetWindow == null) return;
|
|
2566
|
-
this._iosJustTouchEnded = true;
|
|
2567
|
-
this._iosTouchEndTimerId = this.targetWindow.setTimeout(() => {
|
|
2568
|
-
this._iosJustTouchEnded = false;
|
|
2569
|
-
this._iosTouchEndTimerId = null;
|
|
2570
|
-
this._flushIosDeferredIfReady();
|
|
2571
|
-
}, 150);
|
|
2572
|
-
};
|
|
2573
|
-
scrollEl.addEventListener("touchstart", onTouchStart, addEventListenerOptions);
|
|
2574
|
-
scrollEl.addEventListener("touchend", onTouchEnd, addEventListenerOptions);
|
|
2575
|
-
this.unsubs.push(() => {
|
|
2576
|
-
scrollEl.removeEventListener("touchstart", onTouchStart);
|
|
2577
|
-
scrollEl.removeEventListener("touchend", onTouchEnd);
|
|
2578
|
-
if (this._iosTouchEndTimerId !== null && this.targetWindow != null) {
|
|
2579
|
-
this.targetWindow.clearTimeout(this._iosTouchEndTimerId);
|
|
2580
|
-
this._iosTouchEndTimerId = null;
|
|
2581
|
-
}
|
|
2582
|
-
});
|
|
2583
|
-
}
|
|
2584
|
-
this._scrollToOffset(this.getScrollOffset(), {
|
|
2585
|
-
adjustments: void 0,
|
|
2586
|
-
behavior: void 0
|
|
2587
|
-
});
|
|
2588
|
-
}
|
|
2589
|
-
const anchor = this.pendingScrollAnchor;
|
|
2590
|
-
this.pendingScrollAnchor = null;
|
|
2591
|
-
if (anchor && this.scrollElement && this.options.enabled) {
|
|
2592
|
-
const [key, _offset, followOnAppend, anchorDelta] = anchor;
|
|
2593
|
-
if (key !== null && !followOnAppend) if (isIOSWebKit() && (this.isScrolling || this._iosTouching || this._iosJustTouchEnded)) {
|
|
2594
|
-
if (anchorDelta !== 0) this._iosDeferredAdjustment += anchorDelta;
|
|
2595
|
-
} else this._scrollToOffset(this.getScrollOffset(), {
|
|
2596
|
-
adjustments: void 0,
|
|
2597
|
-
behavior: void 0
|
|
2598
|
-
});
|
|
2599
|
-
if (followOnAppend) this.scrollToEnd({ behavior: followOnAppend });
|
|
2600
|
-
}
|
|
2601
|
-
};
|
|
2602
|
-
this._flushIosDeferredIfReady = () => {
|
|
2603
|
-
if (this._iosDeferredAdjustment === 0) return;
|
|
2604
|
-
if (this.isScrolling) return;
|
|
2605
|
-
if (this._iosTouching) return;
|
|
2606
|
-
if (this._iosJustTouchEnded) return;
|
|
2607
|
-
const cur = this.getScrollOffset();
|
|
2608
|
-
const max = this.getMaxScrollOffset();
|
|
2609
|
-
if (cur < 0 || cur > max) return;
|
|
2610
|
-
if (this._iosDeferredAdjustment < 0 && cur >= max - 1) {
|
|
2611
|
-
this._iosDeferredAdjustment = 0;
|
|
2612
|
-
return;
|
|
2613
|
-
}
|
|
2614
|
-
const delta = this._iosDeferredAdjustment;
|
|
2615
|
-
this._iosDeferredAdjustment = 0;
|
|
2616
|
-
this._scrollToOffset(cur, {
|
|
2617
|
-
adjustments: this.scrollAdjustments += delta,
|
|
2618
|
-
behavior: void 0
|
|
2619
|
-
});
|
|
2620
|
-
};
|
|
2621
|
-
this.rafId = null;
|
|
2622
|
-
this.getSize = () => {
|
|
2623
|
-
if (!this.options.enabled) {
|
|
2624
|
-
this.scrollRect = null;
|
|
2625
|
-
return 0;
|
|
2626
|
-
}
|
|
2627
|
-
this.scrollRect = this.scrollRect ?? this.options.initialRect;
|
|
2628
|
-
return this.scrollRect[this.options.horizontal ? "width" : "height"];
|
|
2629
|
-
};
|
|
2630
|
-
this.getScrollOffset = () => {
|
|
2631
|
-
if (!this.options.enabled) {
|
|
2632
|
-
this.scrollOffset = null;
|
|
2633
|
-
return 0;
|
|
2634
|
-
}
|
|
2635
|
-
this.scrollOffset = this.scrollOffset ?? (typeof this.options.initialOffset === "function" ? this.options.initialOffset() : this.options.initialOffset);
|
|
2636
|
-
return this.scrollOffset;
|
|
2637
|
-
};
|
|
2638
|
-
this.getMeasurementOptions = memo$1(() => [
|
|
2639
|
-
this.options.count,
|
|
2640
|
-
this.options.paddingStart,
|
|
2641
|
-
this.options.scrollMargin,
|
|
2642
|
-
this.options.getItemKey,
|
|
2643
|
-
this.options.enabled,
|
|
2644
|
-
this.options.lanes,
|
|
2645
|
-
this.options.laneAssignmentMode,
|
|
2646
|
-
this.options.gap
|
|
2647
|
-
], (count, paddingStart, scrollMargin, getItemKey, enabled, lanes, laneAssignmentMode, gap) => {
|
|
2648
|
-
if (this.prevLanes !== void 0 && this.prevLanes !== lanes) this.lanesChangedFlag = true;
|
|
2649
|
-
this.prevLanes = lanes;
|
|
2650
|
-
this.pendingMin = null;
|
|
2651
|
-
return {
|
|
2652
|
-
count,
|
|
2653
|
-
paddingStart,
|
|
2654
|
-
scrollMargin,
|
|
2655
|
-
getItemKey,
|
|
2656
|
-
enabled,
|
|
2657
|
-
lanes,
|
|
2658
|
-
laneAssignmentMode,
|
|
2659
|
-
gap
|
|
2660
|
-
};
|
|
2661
|
-
}, { key: false });
|
|
2662
|
-
this.isIndexInRange = (index) => index >= 0 && index < this.options.count;
|
|
2663
|
-
this.getMeasurements = memo$1(() => [this.getMeasurementOptions(), this.itemSizeCacheVersion], ({ count, paddingStart, scrollMargin, getItemKey, enabled, lanes, laneAssignmentMode, gap }, _itemSizeCacheVersion) => {
|
|
2664
|
-
const itemSizeCache = this.itemSizeCache;
|
|
2665
|
-
if (!enabled) {
|
|
2666
|
-
this.measurementsCache = [];
|
|
2667
|
-
this.itemSizeCache.clear();
|
|
2668
|
-
this.laneAssignments.clear();
|
|
2669
|
-
return [];
|
|
2670
|
-
}
|
|
2671
|
-
if (this.laneAssignments.size > count) {
|
|
2672
|
-
for (const index of this.laneAssignments.keys()) if (index >= count) this.laneAssignments.delete(index);
|
|
2673
|
-
}
|
|
2674
|
-
if (this.lanesChangedFlag) {
|
|
2675
|
-
this.lanesChangedFlag = false;
|
|
2676
|
-
this.lanesSettling = true;
|
|
2677
|
-
this.measurementsCache = [];
|
|
2678
|
-
this.itemSizeCache.clear();
|
|
2679
|
-
this.laneAssignments.clear();
|
|
2680
|
-
this.pendingMin = null;
|
|
2681
|
-
}
|
|
2682
|
-
if (this.measurementsCache.length === 0 && !this.lanesSettling) {
|
|
2683
|
-
this.measurementsCache = this.options.initialMeasurementsCache;
|
|
2684
|
-
this.measurementsCache.forEach((item) => {
|
|
2685
|
-
this.itemSizeCache.set(item.key, item.size);
|
|
2686
|
-
});
|
|
2687
|
-
}
|
|
2688
|
-
const min = this.lanesSettling ? 0 : this.pendingMin ?? 0;
|
|
2689
|
-
this.pendingMin = null;
|
|
2690
|
-
if (this.lanesSettling && this.measurementsCache.length === count) this.lanesSettling = false;
|
|
2691
|
-
if (lanes === 1) {
|
|
2692
|
-
const need = count * 2;
|
|
2693
|
-
let flat = this._flatMeasurements;
|
|
2694
|
-
if (!flat || flat.length < need) {
|
|
2695
|
-
const next = new Float64Array(need);
|
|
2696
|
-
if (flat && min > 0) next.set(flat.subarray(0, min * 2));
|
|
2697
|
-
flat = next;
|
|
2698
|
-
this._flatMeasurements = flat;
|
|
2699
|
-
}
|
|
2700
|
-
let runningStart;
|
|
2701
|
-
if (min === 0) runningStart = paddingStart + scrollMargin;
|
|
2702
|
-
else {
|
|
2703
|
-
const prevIdx = min - 1;
|
|
2704
|
-
runningStart = flat[prevIdx * 2] + flat[prevIdx * 2 + 1] + gap;
|
|
2705
|
-
}
|
|
2706
|
-
for (let i = min; i < count; i++) {
|
|
2707
|
-
const key = getItemKey(i);
|
|
2708
|
-
const measuredSize = itemSizeCache.get(key);
|
|
2709
|
-
const size = typeof measuredSize === "number" ? measuredSize : this.options.estimateSize(i);
|
|
2710
|
-
flat[i * 2] = runningStart;
|
|
2711
|
-
flat[i * 2 + 1] = size;
|
|
2712
|
-
runningStart += size + gap;
|
|
2713
|
-
}
|
|
2714
|
-
const view = createLazyMeasurementsView(count, flat, getItemKey);
|
|
2715
|
-
this.measurementsCache = view;
|
|
2716
|
-
return view;
|
|
2717
|
-
}
|
|
2718
|
-
const measurements = this.measurementsCache.slice(0, min);
|
|
2719
|
-
const laneLastIndex = new Array(lanes).fill(void 0);
|
|
2720
|
-
const laneEnds = new Float64Array(lanes);
|
|
2721
|
-
let filledLanes = 0;
|
|
2722
|
-
for (let m = 0; m < min; m++) {
|
|
2723
|
-
const item = measurements[m];
|
|
2724
|
-
if (item) {
|
|
2725
|
-
if (laneLastIndex[item.lane] === void 0) filledLanes++;
|
|
2726
|
-
laneLastIndex[item.lane] = m;
|
|
2727
|
-
laneEnds[item.lane] = item.end;
|
|
2728
|
-
}
|
|
2729
|
-
}
|
|
2730
|
-
for (let i = min; i < count; i++) {
|
|
2731
|
-
const key = getItemKey(i);
|
|
2732
|
-
const cachedLane = this.laneAssignments.get(i);
|
|
2733
|
-
let lane;
|
|
2734
|
-
let start;
|
|
2735
|
-
const shouldCacheLane = laneAssignmentMode === "estimate" || itemSizeCache.has(key);
|
|
2736
|
-
if (cachedLane !== void 0 && this.options.lanes > 1) {
|
|
2737
|
-
lane = cachedLane;
|
|
2738
|
-
const prevIndex = laneLastIndex[lane];
|
|
2739
|
-
const prevInLane = prevIndex !== void 0 ? measurements[prevIndex] : void 0;
|
|
2740
|
-
start = prevInLane ? prevInLane.end + gap : paddingStart + scrollMargin;
|
|
2741
|
-
} else if (filledLanes === lanes) {
|
|
2742
|
-
let bestLane = 0;
|
|
2743
|
-
let bestEnd = laneEnds[0];
|
|
2744
|
-
let bestIdx = laneLastIndex[0];
|
|
2745
|
-
for (let l = 1; l < lanes; l++) {
|
|
2746
|
-
const e = laneEnds[l];
|
|
2747
|
-
if (e < bestEnd || e === bestEnd && laneLastIndex[l] < bestIdx) {
|
|
2748
|
-
bestLane = l;
|
|
2749
|
-
bestEnd = e;
|
|
2750
|
-
bestIdx = laneLastIndex[l];
|
|
2751
|
-
}
|
|
2752
|
-
}
|
|
2753
|
-
lane = bestLane;
|
|
2754
|
-
start = bestEnd + gap;
|
|
2755
|
-
if (shouldCacheLane) this.laneAssignments.set(i, lane);
|
|
2756
|
-
} else {
|
|
2757
|
-
lane = i % this.options.lanes;
|
|
2758
|
-
start = paddingStart + scrollMargin;
|
|
2759
|
-
if (shouldCacheLane) this.laneAssignments.set(i, lane);
|
|
2760
|
-
}
|
|
2761
|
-
const measuredSize = itemSizeCache.get(key);
|
|
2762
|
-
const size = typeof measuredSize === "number" ? measuredSize : this.options.estimateSize(i);
|
|
2763
|
-
const end = start + size;
|
|
2764
|
-
measurements[i] = {
|
|
2765
|
-
index: i,
|
|
2766
|
-
start,
|
|
2767
|
-
size,
|
|
2768
|
-
end,
|
|
2769
|
-
key,
|
|
2770
|
-
lane
|
|
2771
|
-
};
|
|
2772
|
-
if (laneLastIndex[lane] === void 0) filledLanes++;
|
|
2773
|
-
laneLastIndex[lane] = i;
|
|
2774
|
-
laneEnds[lane] = end;
|
|
2775
|
-
}
|
|
2776
|
-
this.measurementsCache = measurements;
|
|
2777
|
-
return measurements;
|
|
2778
|
-
}, {
|
|
2779
|
-
key: false,
|
|
2780
|
-
debug: () => this.options.debug
|
|
2781
|
-
});
|
|
2782
|
-
this.calculateRange = memo$1(() => [
|
|
2783
|
-
this.getMeasurements(),
|
|
2784
|
-
this.getSize(),
|
|
2785
|
-
this.getScrollOffset(),
|
|
2786
|
-
this.options.lanes
|
|
2787
|
-
], (measurements, outerSize, scrollOffset, lanes) => {
|
|
2788
|
-
if (measurements.length === 0 || outerSize === 0) {
|
|
2789
|
-
this.range = null;
|
|
2790
|
-
return null;
|
|
2791
|
-
}
|
|
2792
|
-
this.range = calculateRangeImpl(measurements, outerSize, scrollOffset, lanes, lanes === 1 && this._flatMeasurements != null ? this._flatMeasurements : null);
|
|
2793
|
-
return this.range;
|
|
2794
|
-
}, {
|
|
2795
|
-
key: false,
|
|
2796
|
-
debug: () => this.options.debug
|
|
2797
|
-
});
|
|
2798
|
-
this.getVirtualIndexes = memo$1(() => {
|
|
2799
|
-
let startIndex = null;
|
|
2800
|
-
let endIndex = null;
|
|
2801
|
-
const range = this.calculateRange();
|
|
2802
|
-
if (range) {
|
|
2803
|
-
startIndex = range.startIndex;
|
|
2804
|
-
endIndex = range.endIndex;
|
|
2805
|
-
}
|
|
2806
|
-
this.maybeNotify.updateDeps([
|
|
2807
|
-
this.isScrolling,
|
|
2808
|
-
startIndex,
|
|
2809
|
-
endIndex
|
|
2810
|
-
]);
|
|
2811
|
-
return [
|
|
2812
|
-
this.options.rangeExtractor,
|
|
2813
|
-
this.options.overscan,
|
|
2814
|
-
this.options.count,
|
|
2815
|
-
startIndex,
|
|
2816
|
-
endIndex
|
|
2817
|
-
];
|
|
2818
|
-
}, (rangeExtractor, overscan, count, startIndex, endIndex) => {
|
|
2819
|
-
return startIndex === null || endIndex === null ? [] : rangeExtractor({
|
|
2820
|
-
startIndex,
|
|
2821
|
-
endIndex,
|
|
2822
|
-
overscan,
|
|
2823
|
-
count
|
|
2824
|
-
});
|
|
2825
|
-
}, {
|
|
2826
|
-
key: false,
|
|
2827
|
-
debug: () => this.options.debug
|
|
2828
|
-
});
|
|
2829
|
-
this.indexFromElement = (node) => {
|
|
2830
|
-
const attributeName = this.options.indexAttribute;
|
|
2831
|
-
const indexStr = node.getAttribute(attributeName);
|
|
2832
|
-
if (!indexStr) {
|
|
2833
|
-
console.warn(`Missing attribute name '${attributeName}={index}' on measured element.`);
|
|
2834
|
-
return -1;
|
|
2835
|
-
}
|
|
2836
|
-
return parseInt(indexStr, 10);
|
|
2837
|
-
};
|
|
2838
|
-
this.shouldMeasureDuringScroll = (index) => {
|
|
2839
|
-
var _a;
|
|
2840
|
-
if (!this.scrollState || this.scrollState.behavior !== "smooth") return true;
|
|
2841
|
-
const scrollIndex = this.scrollState.index ?? ((_a = this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)) == null ? void 0 : _a.index);
|
|
2842
|
-
if (scrollIndex !== void 0 && this.range) {
|
|
2843
|
-
const bufferSize = Math.max(this.options.overscan, Math.ceil((this.range.endIndex - this.range.startIndex) / 2));
|
|
2844
|
-
const minIndex = Math.max(0, scrollIndex - bufferSize);
|
|
2845
|
-
const maxIndex = Math.min(this.options.count - 1, scrollIndex + bufferSize);
|
|
2846
|
-
return index >= minIndex && index <= maxIndex;
|
|
2847
|
-
}
|
|
2848
|
-
return true;
|
|
2849
|
-
};
|
|
2850
|
-
this.measureElement = (node) => {
|
|
2851
|
-
if (!node) {
|
|
2852
|
-
this.elementsCache.forEach((cached, key2) => {
|
|
2853
|
-
if (!cached.isConnected) {
|
|
2854
|
-
this.observer.unobserve(cached);
|
|
2855
|
-
this.elementsCache.delete(key2);
|
|
2856
|
-
}
|
|
2857
|
-
});
|
|
2858
|
-
return;
|
|
2859
|
-
}
|
|
2860
|
-
const index = this.indexFromElement(node);
|
|
2861
|
-
if (!this.isIndexInRange(index)) return;
|
|
2862
|
-
const key = this.options.getItemKey(index);
|
|
2863
|
-
const prevNode = this.elementsCache.get(key);
|
|
2864
|
-
if (prevNode !== node) {
|
|
2865
|
-
if (prevNode) this.observer.unobserve(prevNode);
|
|
2866
|
-
this.observer.observe(node);
|
|
2867
|
-
this.elementsCache.set(key, node);
|
|
2868
|
-
}
|
|
2869
|
-
if ((!this.isScrolling || this.scrollState) && this.shouldMeasureDuringScroll(index)) this.resizeItem(index, this.options.measureElement(node, void 0, this));
|
|
2870
|
-
};
|
|
2871
|
-
this.resizeItem = (index, size) => {
|
|
2872
|
-
var _a, _b;
|
|
2873
|
-
if (!this.isIndexInRange(index)) return;
|
|
2874
|
-
let cachedSize;
|
|
2875
|
-
let itemStart;
|
|
2876
|
-
let key;
|
|
2877
|
-
const flat = this._flatMeasurements;
|
|
2878
|
-
if (this.options.lanes === 1 && flat !== null) {
|
|
2879
|
-
key = this.options.getItemKey(index);
|
|
2880
|
-
itemStart = flat[index * 2];
|
|
2881
|
-
cachedSize = flat[index * 2 + 1];
|
|
2882
|
-
} else {
|
|
2883
|
-
const item = this.measurementsCache[index];
|
|
2884
|
-
if (!item) return;
|
|
2885
|
-
key = item.key;
|
|
2886
|
-
itemStart = item.start;
|
|
2887
|
-
cachedSize = item.size;
|
|
2888
|
-
}
|
|
2889
|
-
const itemSize = this.itemSizeCache.get(key) ?? cachedSize;
|
|
2890
|
-
const delta = size - itemSize;
|
|
2891
|
-
if (delta !== 0) {
|
|
2892
|
-
const wasAtEnd = this.options.anchorTo === "end" && ((_a = this.scrollState) == null ? void 0 : _a.behavior) !== "smooth" && this.getVirtualDistanceFromEnd() <= this.options.scrollEndThreshold;
|
|
2893
|
-
const prevTotalSize = wasAtEnd ? this.getTotalSize() : 0;
|
|
2894
|
-
const scrollOffsetWithAdj = this.getScrollOffset() + this.scrollAdjustments;
|
|
2895
|
-
const defaultShouldAdjust = !this.itemSizeCache.has(key) ? itemStart < scrollOffsetWithAdj : itemStart + itemSize <= scrollOffsetWithAdj && this.scrollDirection !== "backward";
|
|
2896
|
-
const shouldAdjustScroll = ((_b = this.scrollState) == null ? void 0 : _b.behavior) !== "smooth" && (this.shouldAdjustScrollPositionOnItemSizeChange !== void 0 ? this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[index] ?? {
|
|
2897
|
-
index,
|
|
2898
|
-
key,
|
|
2899
|
-
start: itemStart,
|
|
2900
|
-
size: cachedSize,
|
|
2901
|
-
end: itemStart + cachedSize,
|
|
2902
|
-
lane: 0
|
|
2903
|
-
}, delta, this) : defaultShouldAdjust);
|
|
2904
|
-
if (this.pendingMin === null || index < this.pendingMin) this.pendingMin = index;
|
|
2905
|
-
this.itemSizeCache.set(key, size);
|
|
2906
|
-
this.itemSizeCacheVersion++;
|
|
2907
|
-
let adjustedSync = false;
|
|
2908
|
-
if (wasAtEnd) adjustedSync = this.applyScrollAdjustment(this.getTotalSize() - prevTotalSize);
|
|
2909
|
-
else if (shouldAdjustScroll) adjustedSync = this.applyScrollAdjustment(delta);
|
|
2910
|
-
this.notify(adjustedSync);
|
|
2911
|
-
}
|
|
2912
|
-
};
|
|
2913
|
-
this.getVirtualItems = memo$1(() => [this.getVirtualIndexes(), this.getMeasurements()], (indexes, measurements) => {
|
|
2914
|
-
const virtualItems = [];
|
|
2915
|
-
for (let k = 0, len = indexes.length; k < len; k++) {
|
|
2916
|
-
const measurement = measurements[indexes[k]];
|
|
2917
|
-
virtualItems.push(measurement);
|
|
2918
|
-
}
|
|
2919
|
-
return virtualItems;
|
|
2920
|
-
}, {
|
|
2921
|
-
key: false,
|
|
2922
|
-
debug: () => this.options.debug
|
|
2923
|
-
});
|
|
2924
|
-
this.getVirtualItemForOffset = (offset) => {
|
|
2925
|
-
const measurements = this.getMeasurements();
|
|
2926
|
-
if (measurements.length === 0) return;
|
|
2927
|
-
const flat = this._flatMeasurements;
|
|
2928
|
-
const useFlat = this.options.lanes === 1 && flat != null;
|
|
2929
|
-
return notUndefined(measurements[findNearestBinarySearch(0, measurements.length - 1, useFlat ? (i) => flat[i * 2] : (i) => notUndefined(measurements[i]).start, offset)]);
|
|
2930
|
-
};
|
|
2931
|
-
this.getMaxScrollOffset = () => {
|
|
2932
|
-
if (!this.scrollElement) return 0;
|
|
2933
|
-
if ("scrollHeight" in this.scrollElement) return this.options.horizontal ? this.scrollElement.scrollWidth - this.scrollElement.clientWidth : this.scrollElement.scrollHeight - this.scrollElement.clientHeight;
|
|
2934
|
-
else {
|
|
2935
|
-
const doc = this.scrollElement.document.documentElement;
|
|
2936
|
-
return this.options.horizontal ? doc.scrollWidth - this.scrollElement.innerWidth : doc.scrollHeight - this.scrollElement.innerHeight;
|
|
2937
|
-
}
|
|
2938
|
-
};
|
|
2939
|
-
this.getVirtualDistanceFromEnd = () => {
|
|
2940
|
-
return Math.max(this.getTotalSize() - this.getSize() - this.getScrollOffset(), 0);
|
|
2941
|
-
};
|
|
2942
|
-
this.getDistanceFromEnd = () => {
|
|
2943
|
-
return Math.max(this.getMaxScrollOffset() - this.getScrollOffset(), 0);
|
|
2944
|
-
};
|
|
2945
|
-
this.isAtEnd = (threshold = this.options.scrollEndThreshold) => {
|
|
2946
|
-
return this.getDistanceFromEnd() <= threshold;
|
|
2947
|
-
};
|
|
2948
|
-
this.getOffsetForAlignment = (toOffset, align, itemSize = 0) => {
|
|
2949
|
-
if (!this.scrollElement) return 0;
|
|
2950
|
-
const size = this.getSize();
|
|
2951
|
-
const scrollOffset = this.getScrollOffset();
|
|
2952
|
-
if (align === "auto") align = toOffset >= scrollOffset + size ? "end" : "start";
|
|
2953
|
-
if (align === "center") toOffset += (itemSize - size) / 2;
|
|
2954
|
-
else if (align === "end") toOffset -= size;
|
|
2955
|
-
const maxOffset = this.getMaxScrollOffset();
|
|
2956
|
-
return Math.max(Math.min(maxOffset, toOffset), 0);
|
|
2957
|
-
};
|
|
2958
|
-
this.getOffsetForIndex = (index, align = "auto") => {
|
|
2959
|
-
index = Math.max(0, Math.min(index, this.options.count - 1));
|
|
2960
|
-
const size = this.getSize();
|
|
2961
|
-
const scrollOffset = this.getScrollOffset();
|
|
2962
|
-
const item = this.measurementsCache[index];
|
|
2963
|
-
if (!item) return;
|
|
2964
|
-
if (align === "auto") if (item.end >= scrollOffset + size - this.options.scrollPaddingEnd) align = "end";
|
|
2965
|
-
else if (item.start <= scrollOffset + this.options.scrollPaddingStart) align = "start";
|
|
2966
|
-
else return [scrollOffset, align];
|
|
2967
|
-
if (align === "end" && index === this.options.count - 1) return [this.getMaxScrollOffset(), align];
|
|
2968
|
-
const toOffset = align === "end" ? item.end + this.options.scrollPaddingEnd : item.start - this.options.scrollPaddingStart;
|
|
2969
|
-
return [this.getOffsetForAlignment(toOffset, align, item.size), align];
|
|
2970
|
-
};
|
|
2971
|
-
this.scrollToOffset = (toOffset, { align = "start", behavior = "auto" } = {}) => {
|
|
2972
|
-
this._iosDeferredAdjustment = 0;
|
|
2973
|
-
const offset = this.getOffsetForAlignment(toOffset, align);
|
|
2974
|
-
const now = this.now();
|
|
2975
|
-
this.scrollState = {
|
|
2976
|
-
index: null,
|
|
2977
|
-
align,
|
|
2978
|
-
behavior,
|
|
2979
|
-
startedAt: now,
|
|
2980
|
-
lastTargetOffset: offset,
|
|
2981
|
-
stableFrames: 0
|
|
2982
|
-
};
|
|
2983
|
-
this._scrollToOffset(offset, {
|
|
2984
|
-
adjustments: void 0,
|
|
2985
|
-
behavior
|
|
2986
|
-
});
|
|
2987
|
-
this.scheduleScrollReconcile();
|
|
2988
|
-
};
|
|
2989
|
-
this.scrollToIndex = (index, { align: initialAlign = "auto", behavior = "auto" } = {}) => {
|
|
2990
|
-
this._iosDeferredAdjustment = 0;
|
|
2991
|
-
index = Math.max(0, Math.min(index, this.options.count - 1));
|
|
2992
|
-
const offsetInfo = this.getOffsetForIndex(index, initialAlign);
|
|
2993
|
-
if (!offsetInfo) return;
|
|
2994
|
-
const [offset, align] = offsetInfo;
|
|
2995
|
-
const now = this.now();
|
|
2996
|
-
this.scrollState = {
|
|
2997
|
-
index,
|
|
2998
|
-
align,
|
|
2999
|
-
behavior,
|
|
3000
|
-
startedAt: now,
|
|
3001
|
-
lastTargetOffset: offset,
|
|
3002
|
-
stableFrames: 0
|
|
3003
|
-
};
|
|
3004
|
-
this._scrollToOffset(offset, {
|
|
3005
|
-
adjustments: void 0,
|
|
3006
|
-
behavior
|
|
3007
|
-
});
|
|
3008
|
-
this.scheduleScrollReconcile();
|
|
3009
|
-
};
|
|
3010
|
-
this.scrollBy = (delta, { behavior = "auto" } = {}) => {
|
|
3011
|
-
const offset = this.getScrollOffset() + delta;
|
|
3012
|
-
const now = this.now();
|
|
3013
|
-
this.scrollState = {
|
|
3014
|
-
index: null,
|
|
3015
|
-
align: "start",
|
|
3016
|
-
behavior,
|
|
3017
|
-
startedAt: now,
|
|
3018
|
-
lastTargetOffset: offset,
|
|
3019
|
-
stableFrames: 0
|
|
3020
|
-
};
|
|
3021
|
-
this._scrollToOffset(offset, {
|
|
3022
|
-
adjustments: void 0,
|
|
3023
|
-
behavior
|
|
3024
|
-
});
|
|
3025
|
-
this.scheduleScrollReconcile();
|
|
3026
|
-
};
|
|
3027
|
-
this.scrollToEnd = ({ behavior = "auto" } = {}) => {
|
|
3028
|
-
if (this.options.count > 0) {
|
|
3029
|
-
this.scrollToIndex(this.options.count - 1, {
|
|
3030
|
-
align: "end",
|
|
3031
|
-
behavior
|
|
3032
|
-
});
|
|
3033
|
-
return;
|
|
3034
|
-
}
|
|
3035
|
-
this.scrollToOffset(Math.max(this.getTotalSize() - this.getSize(), 0), { behavior });
|
|
3036
|
-
};
|
|
3037
|
-
this.getTotalSize = () => {
|
|
3038
|
-
var _a;
|
|
3039
|
-
const measurements = this.getMeasurements();
|
|
3040
|
-
let end;
|
|
3041
|
-
if (measurements.length === 0) end = this.options.paddingStart;
|
|
3042
|
-
else if (this.options.lanes === 1) {
|
|
3043
|
-
const lastIdx = measurements.length - 1;
|
|
3044
|
-
const flat = this._flatMeasurements;
|
|
3045
|
-
if (flat != null) end = flat[lastIdx * 2] + flat[lastIdx * 2 + 1];
|
|
3046
|
-
else end = ((_a = measurements[lastIdx]) == null ? void 0 : _a.end) ?? 0;
|
|
3047
|
-
} else {
|
|
3048
|
-
const endByLane = Array(this.options.lanes).fill(null);
|
|
3049
|
-
let endIndex = measurements.length - 1;
|
|
3050
|
-
while (endIndex >= 0 && endByLane.some((val) => val === null)) {
|
|
3051
|
-
const item = measurements[endIndex];
|
|
3052
|
-
if (endByLane[item.lane] === null) endByLane[item.lane] = item.end;
|
|
3053
|
-
endIndex--;
|
|
3054
|
-
}
|
|
3055
|
-
end = Math.max(...endByLane.filter((val) => val !== null));
|
|
3056
|
-
}
|
|
3057
|
-
return Math.max(end - this.options.scrollMargin + this.options.paddingEnd, 0);
|
|
3058
|
-
};
|
|
3059
|
-
this.takeSnapshot = () => {
|
|
3060
|
-
const snapshot = [];
|
|
3061
|
-
if (this.itemSizeCache.size === 0) return snapshot;
|
|
3062
|
-
const m = this.getMeasurements();
|
|
3063
|
-
for (const item of m) if (item && this.itemSizeCache.has(item.key)) snapshot.push({
|
|
3064
|
-
index: item.index,
|
|
3065
|
-
key: item.key,
|
|
3066
|
-
start: item.start,
|
|
3067
|
-
size: item.size,
|
|
3068
|
-
end: item.end,
|
|
3069
|
-
lane: item.lane
|
|
3070
|
-
});
|
|
3071
|
-
return snapshot;
|
|
3072
|
-
};
|
|
3073
|
-
this._scrollToOffset = (offset, { adjustments, behavior }) => {
|
|
3074
|
-
this._intendedScrollOffset = offset + (adjustments ?? 0);
|
|
3075
|
-
this.options.scrollToFn(offset, {
|
|
3076
|
-
behavior,
|
|
3077
|
-
adjustments
|
|
3078
|
-
}, this);
|
|
3079
|
-
};
|
|
3080
|
-
this.measure = () => {
|
|
3081
|
-
this.pendingMin = null;
|
|
3082
|
-
this.itemSizeCache.clear();
|
|
3083
|
-
this.laneAssignments.clear();
|
|
3084
|
-
this.itemSizeCacheVersion++;
|
|
3085
|
-
this.notify(false);
|
|
3086
|
-
};
|
|
3087
|
-
this.setOptions(opts);
|
|
3088
|
-
}
|
|
3089
|
-
applyScrollAdjustment(delta, behavior) {
|
|
3090
|
-
if (delta === 0) return false;
|
|
3091
|
-
if (isIOSWebKit() && (this.isScrolling || this._iosTouching || this._iosJustTouchEnded)) {
|
|
3092
|
-
this._iosDeferredAdjustment += delta;
|
|
3093
|
-
return false;
|
|
3094
|
-
} else {
|
|
3095
|
-
this._scrollToOffset(this.getScrollOffset(), {
|
|
3096
|
-
adjustments: this.scrollAdjustments += delta,
|
|
3097
|
-
behavior
|
|
3098
|
-
});
|
|
3099
|
-
if (this.scrollOffset !== null) {
|
|
3100
|
-
this.scrollOffset += this.scrollAdjustments;
|
|
3101
|
-
if (this.scrollOffset < 0) this.scrollOffset = 0;
|
|
3102
|
-
this.scrollAdjustments = 0;
|
|
3103
|
-
}
|
|
3104
|
-
return true;
|
|
3105
|
-
}
|
|
3106
|
-
}
|
|
3107
|
-
scheduleScrollReconcile() {
|
|
3108
|
-
if (!this.targetWindow) {
|
|
3109
|
-
this.scrollState = null;
|
|
3110
|
-
return;
|
|
3111
|
-
}
|
|
3112
|
-
if (this.rafId != null) return;
|
|
3113
|
-
this.rafId = this.targetWindow.requestAnimationFrame(() => {
|
|
3114
|
-
this.rafId = null;
|
|
3115
|
-
this.reconcileScroll();
|
|
3116
|
-
});
|
|
3117
|
-
}
|
|
3118
|
-
reconcileScroll() {
|
|
3119
|
-
if (!this.scrollState) return;
|
|
3120
|
-
if (!this.scrollElement) return;
|
|
3121
|
-
if (this.now() - this.scrollState.startedAt > 5e3) {
|
|
3122
|
-
this.scrollState = null;
|
|
3123
|
-
return;
|
|
3124
|
-
}
|
|
3125
|
-
const offsetInfo = this.scrollState.index != null ? this.getOffsetForIndex(this.scrollState.index, this.scrollState.align) : void 0;
|
|
3126
|
-
const targetOffset = offsetInfo ? offsetInfo[0] : this.scrollState.lastTargetOffset;
|
|
3127
|
-
const STABLE_FRAMES = 1;
|
|
3128
|
-
const targetChanged = targetOffset !== this.scrollState.lastTargetOffset;
|
|
3129
|
-
if (!targetChanged && approxEqual(targetOffset, this.getScrollOffset())) {
|
|
3130
|
-
this.scrollState.stableFrames++;
|
|
3131
|
-
if (this.scrollState.stableFrames >= STABLE_FRAMES) {
|
|
3132
|
-
if (this.getScrollOffset() !== targetOffset) this._scrollToOffset(targetOffset, {
|
|
3133
|
-
adjustments: void 0,
|
|
3134
|
-
behavior: "auto"
|
|
3135
|
-
});
|
|
3136
|
-
this.scrollState = null;
|
|
3137
|
-
return;
|
|
3138
|
-
}
|
|
3139
|
-
} else {
|
|
3140
|
-
this.scrollState.stableFrames = 0;
|
|
3141
|
-
if (targetChanged) {
|
|
3142
|
-
const viewport = this.getSize() || 600;
|
|
3143
|
-
const distance = Math.abs(targetOffset - this.getScrollOffset());
|
|
3144
|
-
const keepSmooth = this.scrollState.behavior === "smooth" && distance > viewport;
|
|
3145
|
-
this.scrollState.lastTargetOffset = targetOffset;
|
|
3146
|
-
if (!keepSmooth) this.scrollState.behavior = "auto";
|
|
3147
|
-
this._scrollToOffset(targetOffset, {
|
|
3148
|
-
adjustments: void 0,
|
|
3149
|
-
behavior: keepSmooth ? "smooth" : "auto"
|
|
3150
|
-
});
|
|
3151
|
-
}
|
|
3152
|
-
}
|
|
3153
|
-
this.scheduleScrollReconcile();
|
|
3154
|
-
}
|
|
3155
|
-
};
|
|
3156
|
-
const findNearestBinarySearch = (low, high, getCurrentValue, value) => {
|
|
3157
|
-
while (low <= high) {
|
|
3158
|
-
const middle = (low + high) / 2 | 0;
|
|
3159
|
-
const currentValue = getCurrentValue(middle);
|
|
3160
|
-
if (currentValue < value) low = middle + 1;
|
|
3161
|
-
else if (currentValue > value) high = middle - 1;
|
|
3162
|
-
else return middle;
|
|
3163
|
-
}
|
|
3164
|
-
if (low > 0) return low - 1;
|
|
3165
|
-
else return 0;
|
|
3166
|
-
};
|
|
3167
|
-
function findNearestBinarySearchFlat(flat, high, value) {
|
|
3168
|
-
let low = 0;
|
|
3169
|
-
while (low <= high) {
|
|
3170
|
-
const middle = (low + high) / 2 | 0;
|
|
3171
|
-
const currentValue = flat[middle * 2];
|
|
3172
|
-
if (currentValue < value) low = middle + 1;
|
|
3173
|
-
else if (currentValue > value) high = middle - 1;
|
|
3174
|
-
else return middle;
|
|
3175
|
-
}
|
|
3176
|
-
return low > 0 ? low - 1 : 0;
|
|
3177
|
-
}
|
|
3178
|
-
function calculateRangeImpl(measurements, outerSize, scrollOffset, lanes, flat) {
|
|
3179
|
-
const lastIndex = measurements.length - 1;
|
|
3180
|
-
if (measurements.length <= lanes) return {
|
|
3181
|
-
startIndex: 0,
|
|
3182
|
-
endIndex: lastIndex
|
|
3183
|
-
};
|
|
3184
|
-
if (lanes === 1 && flat !== null) {
|
|
3185
|
-
const startIndex2 = findNearestBinarySearchFlat(flat, lastIndex, scrollOffset);
|
|
3186
|
-
let endIndex2 = startIndex2;
|
|
3187
|
-
const limit = scrollOffset + outerSize;
|
|
3188
|
-
while (endIndex2 < lastIndex && flat[endIndex2 * 2] + flat[endIndex2 * 2 + 1] < limit) endIndex2++;
|
|
3189
|
-
return {
|
|
3190
|
-
startIndex: startIndex2,
|
|
3191
|
-
endIndex: endIndex2
|
|
3192
|
-
};
|
|
3193
|
-
}
|
|
3194
|
-
const getStart = (index) => measurements[index].start;
|
|
3195
|
-
let startIndex = findNearestBinarySearch(0, lastIndex, getStart, scrollOffset);
|
|
3196
|
-
let endIndex = startIndex;
|
|
3197
|
-
if (lanes === 1) while (endIndex < lastIndex && measurements[endIndex].end < scrollOffset + outerSize) endIndex++;
|
|
3198
|
-
else if (lanes > 1) {
|
|
3199
|
-
const endPerLane = Array(lanes).fill(0);
|
|
3200
|
-
while (endIndex < lastIndex && endPerLane.some((pos) => pos < scrollOffset + outerSize)) {
|
|
3201
|
-
const item = measurements[endIndex];
|
|
3202
|
-
endPerLane[item.lane] = item.end;
|
|
3203
|
-
endIndex++;
|
|
3204
|
-
}
|
|
3205
|
-
const startPerLane = Array(lanes).fill(scrollOffset + outerSize);
|
|
3206
|
-
while (startIndex >= 0 && startPerLane.some((pos) => pos >= scrollOffset)) {
|
|
3207
|
-
const item = measurements[startIndex];
|
|
3208
|
-
startPerLane[item.lane] = item.start;
|
|
3209
|
-
startIndex--;
|
|
3210
|
-
}
|
|
3211
|
-
startIndex = Math.max(0, startIndex - startIndex % lanes);
|
|
3212
|
-
endIndex = Math.min(lastIndex, endIndex + (lanes - 1 - endIndex % lanes));
|
|
3213
|
-
}
|
|
3214
|
-
return {
|
|
3215
|
-
startIndex,
|
|
3216
|
-
endIndex
|
|
3217
|
-
};
|
|
3218
|
-
}
|
|
3219
|
-
//#endregion
|
|
3220
|
-
//#region ../../../node_modules/.pnpm/@tanstack+react-virtual@3.14.10_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@tanstack/react-virtual/dist/esm/index.js
|
|
3221
|
-
const useIsomorphicLayoutEffect = typeof document !== "undefined" ? react.useLayoutEffect : react.useEffect;
|
|
3222
|
-
function useVirtualizerBase({ useFlushSync = true, directDomUpdates = false, directDomUpdatesMode = "transform", ...options }) {
|
|
3223
|
-
const rerender = react.useReducer((x) => x + 1, 0)[1];
|
|
3224
|
-
const directRef = react.useRef({
|
|
3225
|
-
enabled: directDomUpdates,
|
|
3226
|
-
mode: directDomUpdatesMode,
|
|
3227
|
-
container: null,
|
|
3228
|
-
lastSize: null,
|
|
3229
|
-
lastPositions: /* @__PURE__ */ new WeakMap(),
|
|
3230
|
-
prevRange: null
|
|
3231
|
-
});
|
|
3232
|
-
directRef.current.enabled = directDomUpdates;
|
|
3233
|
-
directRef.current.mode = directDomUpdatesMode;
|
|
3234
|
-
const applyContainerSize = (instance2) => {
|
|
3235
|
-
const state = directRef.current;
|
|
3236
|
-
if (!state.enabled || !state.container) return;
|
|
3237
|
-
const totalSize = instance2.getTotalSize();
|
|
3238
|
-
if (totalSize !== state.lastSize) {
|
|
3239
|
-
state.lastSize = totalSize;
|
|
3240
|
-
const sizeAxis = instance2.options.horizontal ? "width" : "height";
|
|
3241
|
-
state.container.style[sizeAxis] = `${totalSize}px`;
|
|
3242
|
-
}
|
|
3243
|
-
};
|
|
3244
|
-
const applyDirectStyles = (instance2) => {
|
|
3245
|
-
const state = directRef.current;
|
|
3246
|
-
if (!state.enabled || !state.container) return;
|
|
3247
|
-
applyContainerSize(instance2);
|
|
3248
|
-
const horizontal = !!instance2.options.horizontal;
|
|
3249
|
-
const useTransform = state.mode === "transform";
|
|
3250
|
-
const posAxis = horizontal ? "left" : "top";
|
|
3251
|
-
const scrollMargin = instance2.options.scrollMargin;
|
|
3252
|
-
const items = instance2.getVirtualItems();
|
|
3253
|
-
for (const item of items) {
|
|
3254
|
-
const next = item.start - scrollMargin;
|
|
3255
|
-
const el = instance2.elementsCache.get(item.key);
|
|
3256
|
-
if (!el) continue;
|
|
3257
|
-
if (state.lastPositions.get(el) === next) continue;
|
|
3258
|
-
state.lastPositions.set(el, next);
|
|
3259
|
-
if (useTransform) el.style.transform = horizontal ? `translate3d(${next}px, 0, 0)` : `translate3d(0, ${next}px, 0)`;
|
|
3260
|
-
else el.style[posAxis] = `${next}px`;
|
|
3261
|
-
}
|
|
3262
|
-
};
|
|
3263
|
-
const resolvedOptions = {
|
|
3264
|
-
...options,
|
|
3265
|
-
onChange: (instance2, sync) => {
|
|
3266
|
-
var _a;
|
|
3267
|
-
const state = directRef.current;
|
|
3268
|
-
let shouldRerender = true;
|
|
3269
|
-
if (state.enabled) {
|
|
3270
|
-
applyDirectStyles(instance2);
|
|
3271
|
-
const range = instance2.range;
|
|
3272
|
-
const prev = state.prevRange;
|
|
3273
|
-
shouldRerender = !prev || prev.isScrolling !== instance2.isScrolling || prev.startIndex !== (range == null ? void 0 : range.startIndex) || prev.endIndex !== (range == null ? void 0 : range.endIndex);
|
|
3274
|
-
if (shouldRerender) state.prevRange = range ? {
|
|
3275
|
-
startIndex: range.startIndex,
|
|
3276
|
-
endIndex: range.endIndex,
|
|
3277
|
-
isScrolling: instance2.isScrolling
|
|
3278
|
-
} : null;
|
|
3279
|
-
}
|
|
3280
|
-
if (shouldRerender) if (useFlushSync && sync) (0, react_dom.flushSync)(rerender);
|
|
3281
|
-
else rerender();
|
|
3282
|
-
(_a = options.onChange) == null || _a.call(options, instance2, sync);
|
|
3283
|
-
}
|
|
3284
|
-
};
|
|
3285
|
-
const [instance] = react.useState(() => {
|
|
3286
|
-
const v = new Virtualizer(resolvedOptions);
|
|
3287
|
-
return Object.assign(v, { containerRef: (node) => {
|
|
3288
|
-
const state = directRef.current;
|
|
3289
|
-
state.container = node;
|
|
3290
|
-
state.lastSize = null;
|
|
3291
|
-
if (node && state.enabled) {
|
|
3292
|
-
const total = v.getTotalSize();
|
|
3293
|
-
state.lastSize = total;
|
|
3294
|
-
const axis = v.options.horizontal ? "width" : "height";
|
|
3295
|
-
node.style[axis] = `${total}px`;
|
|
3296
|
-
}
|
|
3297
|
-
} });
|
|
3298
|
-
});
|
|
3299
|
-
instance.setOptions(resolvedOptions);
|
|
3300
|
-
useIsomorphicLayoutEffect(() => {
|
|
3301
|
-
return instance._didMount();
|
|
3302
|
-
}, []);
|
|
3303
|
-
useIsomorphicLayoutEffect(() => {
|
|
3304
|
-
applyContainerSize(instance);
|
|
3305
|
-
return instance._willUpdate();
|
|
3306
|
-
});
|
|
3307
|
-
useIsomorphicLayoutEffect(() => {
|
|
3308
|
-
applyDirectStyles(instance);
|
|
3309
|
-
});
|
|
3310
|
-
return instance;
|
|
3311
|
-
}
|
|
3312
|
-
function useVirtualizer(options) {
|
|
3313
|
-
return useVirtualizerBase({
|
|
3314
|
-
observeElementRect,
|
|
3315
|
-
observeElementOffset,
|
|
3316
|
-
scrollToFn: elementScroll,
|
|
3317
|
-
...options
|
|
3318
|
-
});
|
|
3319
|
-
}
|
|
3320
|
-
//#endregion
|
|
3321
2114
|
//#region lib/types/client/views/raw-json.js
|
|
3322
2115
|
/** JSON inspection of live objects, including cyclic Location stores. */
|
|
3323
2116
|
var InspectorJsonWriter = class {
|
|
@@ -4432,9 +3225,9 @@ window.__ModuleLoader__.load({
|
|
|
4432
3225
|
startIndex: Math.max(0, Math.floor(offset / 30) - 1),
|
|
4433
3226
|
endIndex: Math.min(range.count - 1, Math.ceil((offset + viewport.current.height) / 30) - 1)
|
|
4434
3227
|
};
|
|
4435
|
-
return [...new Set([...layout.stickyIndexesAtOffset(offset), ...defaultRangeExtractor(visible)])].sort((left, right) => left - right);
|
|
3228
|
+
return [...new Set([...layout.stickyIndexesAtOffset(offset), ...(0, _tanstack_react_virtual.defaultRangeExtractor)(visible)])].sort((left, right) => left - right);
|
|
4436
3229
|
}, [layout, anchoredOffset]);
|
|
4437
|
-
const virtual = useVirtualizer({
|
|
3230
|
+
const virtual = (0, _tanstack_react_virtual.useVirtualizer)({
|
|
4438
3231
|
count: layout.items.length,
|
|
4439
3232
|
getScrollElement: () => scroller.current,
|
|
4440
3233
|
estimateSize: sizeOf,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepseek-ai/dsh-experimental-session-inspector",
|
|
3
3
|
"description": "Experimental virtualized Session log and live Chat group/node inspectors",
|
|
4
|
-
"version": "0.2.1-alpha.
|
|
4
|
+
"version": "0.2.1-alpha.3",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -46,29 +46,27 @@
|
|
|
46
46
|
],
|
|
47
47
|
"license": "MIT",
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"@deepseek-ai/cordis": "~4.0.5-alpha.
|
|
49
|
+
"@deepseek-ai/cordis": "~4.0.5-alpha.2"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@deepseek-ai/dsh-client-test-runtime": "0.2.1-alpha.
|
|
52
|
+
"@deepseek-ai/dsh-client-test-runtime": "0.2.1-alpha.3",
|
|
53
53
|
"@testing-library/react": "^16.3.3",
|
|
54
|
-
"@types/react-dom": "~18.3.0",
|
|
55
54
|
"react-dom": "^18.2.0",
|
|
56
|
-
"@deepseek-ai/dsh-api-session-controller": "0.2.1-alpha.
|
|
57
|
-
"@deepseek-ai/dsh-client-store": "0.2.1-alpha.
|
|
58
|
-
"@deepseek-ai/dsh-client-ui-chat": "0.2.1-alpha.
|
|
59
|
-
"@deepseek-ai/dsh-client-ui-primitives": "0.2.1-alpha.
|
|
60
|
-
"@deepseek-ai/dsh-client-ui-sidebar-right": "0.2.1-alpha.
|
|
61
|
-
"@deepseek-ai/dsh-client-ui-session": "0.2.1-alpha.
|
|
62
|
-
"@deepseek-ai/dsh-session": "0.2.1-alpha.
|
|
63
|
-
"@deepseek-ai/dsh-llm": "0.2.1-alpha.
|
|
55
|
+
"@deepseek-ai/dsh-api-session-controller": "0.2.1-alpha.3",
|
|
56
|
+
"@deepseek-ai/dsh-client-store": "0.2.1-alpha.3",
|
|
57
|
+
"@deepseek-ai/dsh-client-ui-chat": "0.2.1-alpha.3",
|
|
58
|
+
"@deepseek-ai/dsh-client-ui-primitives": "0.2.1-alpha.3",
|
|
59
|
+
"@deepseek-ai/dsh-client-ui-sidebar-right": "0.2.1-alpha.3",
|
|
60
|
+
"@deepseek-ai/dsh-client-ui-session": "0.2.1-alpha.3",
|
|
61
|
+
"@deepseek-ai/dsh-session": "0.2.1-alpha.3",
|
|
62
|
+
"@deepseek-ai/dsh-llm": "0.2.1-alpha.3",
|
|
64
63
|
"@tanstack/react-virtual": "^3.14.10",
|
|
65
|
-
"@types/react": "~18.3.1",
|
|
66
64
|
"react": "^18.2.0",
|
|
67
|
-
"@deepseek-ai/cordis": "~4.0.5-alpha.
|
|
68
|
-
"@deepseek-ai/dsh-client-locale": "0.2.1-alpha.
|
|
69
|
-
"@deepseek-ai/dsh-client-ui-conversation": "0.2.1-alpha.
|
|
70
|
-
"@deepseek-ai/dsh-client-ui-renderer": "0.2.1-alpha.
|
|
71
|
-
"@deepseek-ai/dsh-client-ui-slots": "0.2.1-alpha.
|
|
65
|
+
"@deepseek-ai/cordis": "~4.0.5-alpha.2",
|
|
66
|
+
"@deepseek-ai/dsh-client-locale": "0.2.1-alpha.3",
|
|
67
|
+
"@deepseek-ai/dsh-client-ui-conversation": "0.2.1-alpha.3",
|
|
68
|
+
"@deepseek-ai/dsh-client-ui-renderer": "0.2.1-alpha.3",
|
|
69
|
+
"@deepseek-ai/dsh-client-ui-slots": "0.2.1-alpha.3"
|
|
72
70
|
},
|
|
73
71
|
"scripts": {
|
|
74
72
|
"bundle": "tsdown",
|