@suifei/dsh-market-lens 0.28.0 → 0.28.1
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/client.js +66 -33
- package/index.js +1 -1
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -382,7 +382,7 @@ window.__ModuleLoader__.load({
|
|
|
382
382
|
}
|
|
383
383
|
|
|
384
384
|
// ---------- diagnostic reporting (batched POST /market-lens/diag) ----------
|
|
385
|
-
const CLIENT_REV = '0.28.
|
|
385
|
+
const CLIENT_REV = '0.28.1';
|
|
386
386
|
const diagQueue = [];
|
|
387
387
|
let diagTimer = 0;
|
|
388
388
|
// the host meta tells the real level; until then assume the shipped 'errors' default
|
|
@@ -2284,22 +2284,33 @@ window.__ModuleLoader__.load({
|
|
|
2284
2284
|
txt(nameX, TH + 1, env.L('board.col.instrument'), '#ff6a5e');
|
|
2285
2285
|
if (!two) txt(codeX, TH + 1, env.L('board.col.code'), '#ff6a5e');
|
|
2286
2286
|
pick.forEach((ci, j) => txt(0, TH + 1, env.colLabels[ci], '#ff6a5e', rails[j] - 2));
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2287
|
+
// cell-accurate seamless scroll: the tape repeats enough periods to
|
|
2288
|
+
// cover the band, shifted up by env.scrollCell LED rows; half-rows at
|
|
2289
|
+
// the band edges are cut by the painter via plan.clip
|
|
2290
|
+
const bandH = env.bandH;
|
|
2291
|
+
const period = Math.max(1, pitchC * env.rows.length);
|
|
2292
|
+
const off = env.scrollCell % period;
|
|
2293
|
+
const reps = Math.min(64, Math.ceil((bandH + pitchC) / period));
|
|
2294
|
+
const txtR = (a, b, s, c, r) => { prims.push({ t: 'x', x: X(a), y: X(b), r: r === void 0 ? null : X(r), c, s, g: 'r' }); };
|
|
2295
|
+
const boxR = (a, b, w, h2, c, al) => { prims.push({ t: 'f', x: X(a), y: X(b), w: Math.max(1, X(w)), h: Math.max(1, X(h2)), c, a: al === void 0 ? 1 : al, g: 'r' }); };
|
|
2296
|
+
for (let rep = 0; rep < reps; rep++) {
|
|
2297
|
+
env.rows.forEach((row, i) => {
|
|
2298
|
+
const top = RTOP + rep * period + i * pitchC - off;
|
|
2299
|
+
if (top + pitchC <= RTOP || top >= RTOP + bandH) return;
|
|
2300
|
+
const y = top + Math.floor((pitchC - G) / 2);
|
|
2301
|
+
const color = pctColor(row.pct);
|
|
2302
|
+
const on = i === env.lit;
|
|
2303
|
+
if (on) boxR(MXU, top, tableR - MXU - 8, pitchC - 2, '#0e2c4c');
|
|
2304
|
+
if (on) txtR(MXU, y, '>', '#ffd75e');
|
|
2305
|
+
txtR(nameX, y, row.name, on ? '#ffffff' : color);
|
|
2306
|
+
if (!two) txtR(codeX, y, row.symbol, '#3f618a');
|
|
2307
|
+
pick.forEach((ci, jj) => txtR(0, y, row.cells[ci], ci === 3 || ci === 4 ? (on ? '#ffffff' : color) : on && ci === 5 ? '#ffffff' : row.cellColors[ci], rails[jj] - 2));
|
|
2308
|
+
});
|
|
2309
|
+
}
|
|
2299
2310
|
// twin ranking boards ride wide walls only
|
|
2300
2311
|
if (wide && env.side.length > 0) {
|
|
2301
2312
|
const SXU = u(815);
|
|
2302
|
-
const nSide = Math.max(1, Math.min(6, Math.floor((
|
|
2313
|
+
const nSide = Math.max(1, Math.min(6, Math.floor((bandH - 2 * (G + 5)) / (2 * (G + 2)))));
|
|
2303
2314
|
txt(SXU, TH + 1, env.L('led.gainers'), '#ff6a5e');
|
|
2304
2315
|
env.side.slice(0, nSide).forEach((e, k) => {
|
|
2305
2316
|
const yy = TH + 5 + G + k * (G + 2);
|
|
@@ -2314,7 +2325,7 @@ window.__ModuleLoader__.load({
|
|
|
2314
2325
|
});
|
|
2315
2326
|
}
|
|
2316
2327
|
// lit-row chart strip; hi/lo tick the reserved gutter, top and bottom
|
|
2317
|
-
const cy0 = RTOP +
|
|
2328
|
+
const cy0 = RTOP + bandH; // chart band pinned below the fixed rows band, never moves
|
|
2318
2329
|
if (env.chart !== null) {
|
|
2319
2330
|
const ch = env.chart;
|
|
2320
2331
|
const nCols = Math.max(8, tableR - 120);
|
|
@@ -2345,7 +2356,7 @@ window.__ModuleLoader__.load({
|
|
|
2345
2356
|
const fy = env.hC - FH + 1;
|
|
2346
2357
|
txt(4, fy, env.footL, '#c8a24a');
|
|
2347
2358
|
txt(0, fy, env.footR, '#c8a24a', C - 4);
|
|
2348
|
-
return { w: X(C), h: X(env.hC), prims };
|
|
2359
|
+
return { w: X(C), h: X(env.hC), prims, clip: { y: X(RTOP), h: Math.max(1, X(bandH)) } };
|
|
2349
2360
|
}
|
|
2350
2361
|
|
|
2351
2362
|
function LedBoard({ rows, quotes, seenQuote, meta, onPick, getKline, ledUp, ledDown, tiny, t }) {
|
|
@@ -2367,13 +2378,15 @@ window.__ModuleLoader__.load({
|
|
|
2367
2378
|
const pitchRef = React.useRef(0);
|
|
2368
2379
|
const topRef = React.useRef(0);
|
|
2369
2380
|
const geoRef = React.useRef({ ox: 0, oy: 0, sc: 1 });
|
|
2381
|
+
const offPxRef = React.useRef(0);
|
|
2382
|
+
const bandHPxRef = React.useRef(0);
|
|
2370
2383
|
const idxKRef = React.useRef(null);
|
|
2371
2384
|
const feedsRef = React.useRef(new Map());
|
|
2372
2385
|
const scenePairRef = React.useRef(null);
|
|
2373
2386
|
const pairIdxRef = React.useRef(0);
|
|
2374
2387
|
const sceneSigRef = React.useRef('');
|
|
2375
2388
|
const [size, setSize] = React.useState({ w: 0, h: 0 });
|
|
2376
|
-
const [
|
|
2389
|
+
const [scrollCell, setScrollCell] = React.useState(0);
|
|
2377
2390
|
const [lit, setLit] = React.useState(0);
|
|
2378
2391
|
const [paused, setPaused] = React.useState(false);
|
|
2379
2392
|
const [feedTick, setFeedTick] = React.useState(0);
|
|
@@ -2382,9 +2395,15 @@ window.__ModuleLoader__.load({
|
|
|
2382
2395
|
// watchlist tape; every rotation step advances the tape by exactly one LED
|
|
2383
2396
|
// row and the last row wraps in as the next head; the chart band below
|
|
2384
2397
|
// the rows never moves, and there are no pages and no bulb wipe anymore
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2398
|
+
// seamless cell scroll: the rows band is a fixed window of LED rows
|
|
2399
|
+
// over the whole watchlist tape; every step the head moves exactly one
|
|
2400
|
+
// bulb cell upward, half-rows clip at the band edges, the chart band
|
|
2401
|
+
// below never moves
|
|
2402
|
+
const bandH = HROWS - ROWS_TOP_C - CHART_C - FOOT_HC;
|
|
2403
|
+
const winN = Math.max(2, Math.floor(bandH / ROW_MIN_C));
|
|
2404
|
+
const pitchC0 = rows.length === 0 ? ROW_MIN_C : Math.max(ROW_MIN_C, Math.floor(bandH / Math.min(rows.length, winN)));
|
|
2405
|
+
const tapeCells = pitchC0 * rows.length;
|
|
2406
|
+
const view = rows;
|
|
2388
2407
|
const ticker = (meta?.indexBar ?? []).map((symbol) => quotes.get(symbol) ?? seenQuote(symbol)).filter((q) => q !== void 0);
|
|
2389
2408
|
const tape = ticker.length === 0 ? [] : [...ticker, ...ticker];
|
|
2390
2409
|
const rowsKey = rows.map((row) => row.symbol).join(',');
|
|
@@ -2417,8 +2436,8 @@ window.__ModuleLoader__.load({
|
|
|
2417
2436
|
// report the wall geometry, so live row/col counts and the display
|
|
2418
2437
|
// scale can be read straight out of the diag log
|
|
2419
2438
|
React.useEffect(() => {
|
|
2420
|
-
diag('panel.led.geo', { wall: `${String(WALL_COLS)}x${String(WALL_ROWS)}`, pitch:
|
|
2421
|
-
}, [
|
|
2439
|
+
diag('panel.led.geo', { wall: `${String(WALL_COLS)}x${String(WALL_ROWS)}`, pitch: pitchC0, winRows: Math.min(rows.length, winN), scroll: '1 cell/s', disp: size.w === 0 ? 'pending' : `${String(size.w)}x${String(size.h)} @${(Math.min(size.w / WALL_W_PX, size.h / WALL_H_PX)).toFixed(3)}x` });
|
|
2440
|
+
}, [Math.min(rows.length, winN), size]);
|
|
2422
2441
|
// one canvas pixel per css pixel, no devicePixelRatio games: the
|
|
2423
2442
|
// browser never resamples the wall, so bulbs cannot shimmer or spill
|
|
2424
2443
|
React.useEffect(() => {
|
|
@@ -2456,10 +2475,12 @@ window.__ModuleLoader__.load({
|
|
|
2456
2475
|
}
|
|
2457
2476
|
// the frame budget is the fixed matrix; rows share what the frame
|
|
2458
2477
|
// leaves them, and the footer always sits on the last wall row
|
|
2459
|
-
const pitchC =
|
|
2478
|
+
const pitchC = pitchC0;
|
|
2460
2479
|
const hC = HROWS;
|
|
2461
2480
|
pitchRef.current = pitchC * PITCH;
|
|
2462
2481
|
topRef.current = ROWS_TOP_C * PITCH;
|
|
2482
|
+
offPxRef.current = (tapeCells === 0 ? 0 : scrollCell % tapeCells) * PITCH;
|
|
2483
|
+
bandHPxRef.current = bandH * PITCH;
|
|
2463
2484
|
const fmtv = (v) => (v === null || v === void 0 ? '—' : fmtNum(v));
|
|
2464
2485
|
let upN = 0;
|
|
2465
2486
|
let dnN = 0;
|
|
@@ -2517,7 +2538,7 @@ window.__ModuleLoader__.load({
|
|
|
2517
2538
|
// actually moved: scroll head, lit row, lattice mode, every number
|
|
2518
2539
|
// screen, and the minute the clock prints
|
|
2519
2540
|
const sig = [
|
|
2520
|
-
String(
|
|
2541
|
+
String(scrollCell), String(lit), tiny === true ? "T" : "S",
|
|
2521
2542
|
view.map((r) => {
|
|
2522
2543
|
const q = quotes.get(r.symbol) ?? seenQuote(r.symbol);
|
|
2523
2544
|
return `${String(q?.price)}:${String(q?.changePct)}:${String(q?.high)}:${String(q?.low)}:${String(q?.prevClose)}:${String(q?.amount)}`;
|
|
@@ -2531,7 +2552,7 @@ window.__ModuleLoader__.load({
|
|
|
2531
2552
|
const fullTitle = t('led.master');
|
|
2532
2553
|
const title = COLS >= 200 ? fullTitle : t('led.min');
|
|
2533
2554
|
const plan = ledPlan({
|
|
2534
|
-
P: PITCH, cols: COLS, hC, tiny, pitchC, chartC: CHART_C,
|
|
2555
|
+
P: PITCH, cols: COLS, hC, tiny, pitchC, chartC: CHART_C, scrollCell, bandH,
|
|
2535
2556
|
ledUp, ledDown,
|
|
2536
2557
|
title,
|
|
2537
2558
|
clock: `${String(nowD.getHours()).padStart(2, '0')}:${String(nowD.getMinutes()).padStart(2, '0')}`,
|
|
@@ -2553,7 +2574,16 @@ window.__ModuleLoader__.load({
|
|
|
2553
2574
|
const x = c.getContext('2d', { willReadFrequently: true }); // bake reads pixels on every publish: keep the canvas on the CPU
|
|
2554
2575
|
x.fillStyle = '#000';
|
|
2555
2576
|
x.fillRect(0, 0, c.width, c.height);
|
|
2577
|
+
x.save();
|
|
2578
|
+
let inRows = false;
|
|
2556
2579
|
plan.prims.forEach((p) => {
|
|
2580
|
+
const isR = p.g === 'r';
|
|
2581
|
+
if (isR !== inRows) {
|
|
2582
|
+
x.restore();
|
|
2583
|
+
x.save();
|
|
2584
|
+
inRows = isR;
|
|
2585
|
+
if (isR) { x.beginPath(); x.rect(0, plan.clip.y, c.width, plan.clip.h); x.clip(); }
|
|
2586
|
+
}
|
|
2557
2587
|
if (p.t === 'f') {
|
|
2558
2588
|
x.globalAlpha = p.a;
|
|
2559
2589
|
x.fillStyle = p.c;
|
|
@@ -2563,21 +2593,22 @@ window.__ModuleLoader__.load({
|
|
|
2563
2593
|
ledText(x, p.x, p.y, p.s, p.c, p.r === null ? void 0 : p.r, tiny);
|
|
2564
2594
|
}
|
|
2565
2595
|
});
|
|
2596
|
+
x.restore();
|
|
2566
2597
|
const pair = scenePairRef.current ?? (scenePairRef.current = [document.createElement('canvas'), document.createElement('canvas')]);
|
|
2567
2598
|
const t0 = performance.now();
|
|
2568
2599
|
bakeLamps(c, pair[pairIdxRef.current ^= 1]);
|
|
2569
2600
|
diag("panel.led.bake", { ms: Math.round(performance.now() - t0), cells: WALL_COLS * WALL_ROWS });
|
|
2570
2601
|
// atomic publish: the loop never sees a half-baked screen
|
|
2571
2602
|
sceneRef.current = pair[pairIdxRef.current];
|
|
2572
|
-
}, [size, view.length,
|
|
2573
|
-
// rotation: the
|
|
2603
|
+
}, [size, view.length, scrollCell, lit, feedTick, tiny, quotes]);
|
|
2604
|
+
// rotation: the tape scrolls up exactly one LED cell per second
|
|
2574
2605
|
const rotRef = React.useRef(() => void 0);
|
|
2575
2606
|
rotRef.current = () => {
|
|
2576
2607
|
if (paused === true || rows.length < 2) return;
|
|
2577
|
-
|
|
2608
|
+
setScrollCell((cur) => cur + 1);
|
|
2578
2609
|
};
|
|
2579
2610
|
React.useEffect(() => {
|
|
2580
|
-
const timer = window.setInterval(() => rotRef.current(),
|
|
2611
|
+
const timer = window.setInterval(() => rotRef.current(), 1000);
|
|
2581
2612
|
return () => window.clearInterval(timer);
|
|
2582
2613
|
}, []);
|
|
2583
2614
|
// the living screen: the 800x450 wall lives off-screen at its native
|
|
@@ -2631,9 +2662,11 @@ window.__ModuleLoader__.load({
|
|
|
2631
2662
|
const hit = (event) => {
|
|
2632
2663
|
const rect = canvasRef.current.getBoundingClientRect();
|
|
2633
2664
|
const { ox, oy, sc } = geoRef.current;
|
|
2634
|
-
const wy = (event.clientY - rect.top - oy) / sc;
|
|
2635
|
-
|
|
2636
|
-
|
|
2665
|
+
const wy = (event.clientY - rect.top - oy) / sc;
|
|
2666
|
+
if (wy < topRef.current || wy >= topRef.current + bandHPxRef.current || view.length === 0) return -1;
|
|
2667
|
+
const rel = wy - topRef.current + offPxRef.current;
|
|
2668
|
+
const idx = Math.floor(rel / (pitchRef.current === 0 ? ROW_MIN_C * PITCH : pitchRef.current));
|
|
2669
|
+
return idx % view.length;
|
|
2637
2670
|
};
|
|
2638
2671
|
return h('div', { className: 'ml-led' },
|
|
2639
2672
|
tape.length === 0 ? null : h('div', { className: 'ml-ticker' },
|
|
@@ -2646,7 +2679,7 @@ window.__ModuleLoader__.load({
|
|
|
2646
2679
|
const i = hit(event);
|
|
2647
2680
|
if (i >= 0) {
|
|
2648
2681
|
setPaused(true);
|
|
2649
|
-
setLit(
|
|
2682
|
+
setLit(i);
|
|
2650
2683
|
} else setPaused(false);
|
|
2651
2684
|
},
|
|
2652
2685
|
onMouseLeave: () => setPaused(false),
|
package/index.js
CHANGED