@ai-gui/plugin-bigscreen 0.36.3 → 0.37.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-gui/plugin-bigscreen",
3
- "version": "0.36.3",
3
+ "version": "0.37.0",
4
4
  "description": "Animated data walls for AIGUI — counting KPIs, sweeping gauges, growing ranks, self-drawing charts, turning 3D bars and globes, on a grid the model lays out.",
5
5
  "keywords": [
6
6
  "llm",
@@ -55,7 +55,7 @@
55
55
  },
56
56
  "dependencies": {
57
57
  "echarts": "^5.5.1",
58
- "@ai-gui/core": "0.36.3"
58
+ "@ai-gui/core": "0.37.0"
59
59
  },
60
60
  "peerDependencies": {
61
61
  "echarts-gl": "^2.0.9"
@@ -1,499 +0,0 @@
1
- "use strict";
2
- //#region rolldown:runtime
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
- key = keys[i];
12
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
- get: ((k) => from[k]).bind(null, key),
14
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
- });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
20
- value: mod,
21
- enumerable: true
22
- }) : target, mod));
23
-
24
- //#endregion
25
-
26
- //#region src/palette.ts
27
- /**
28
- * Two palettes, one per theme.
29
- *
30
- * The dark one is the data-wall look — deep navy, cyan accent, a little glow; the light one is
31
- * the same screen on a white page. The accent can be overridden per screen, and the series
32
- * colours start from it so a screen reads as one thing rather than a collage.
33
- */
34
- function palette(definition) {
35
- const accent = definition.accent ?? (definition.theme === "dark" ? "#22d3ee" : "#0369a1");
36
- return definition.theme === "dark" ? {
37
- accent,
38
- text: "#e2e8f0",
39
- muted: "#94a3b8",
40
- good: "#34d399",
41
- bad: "#fb7185",
42
- warn: "#fbbf24",
43
- track: "rgba(148,163,184,0.18)",
44
- series: [
45
- accent,
46
- "#a78bfa",
47
- "#34d399",
48
- "#fbbf24",
49
- "#fb7185",
50
- "#60a5fa",
51
- "#f472b6",
52
- "#2dd4bf"
53
- ],
54
- gridLine: "rgba(148,163,184,0.16)"
55
- } : {
56
- accent,
57
- text: "#1e293b",
58
- muted: "#64748b",
59
- good: "#059669",
60
- bad: "#e11d48",
61
- warn: "#d97706",
62
- track: "rgba(100,116,139,0.16)",
63
- series: [
64
- accent,
65
- "#7c3aed",
66
- "#059669",
67
- "#d97706",
68
- "#e11d48",
69
- "#2563eb",
70
- "#db2777",
71
- "#0d9488"
72
- ],
73
- gridLine: "rgba(100,116,139,0.2)"
74
- };
75
- }
76
- /** `#rrggbb` with an alpha, for glows and fills. */
77
- function withAlpha(hex, alpha) {
78
- const h = hex.replace("#", "");
79
- const full = h.length === 3 ? h.split("").map((c) => c + c).join("") : h;
80
- const n = Number.parseInt(full, 16);
81
- return `rgba(${n >> 16 & 255},${n >> 8 & 255},${n & 255},${alpha})`;
82
- }
83
-
84
- //#endregion
85
- //#region src/options.ts
86
- /**
87
- * ECharts options built from panels.
88
- *
89
- * Pure functions of the panel and the palette, so they can be tested without a canvas and so
90
- * the same panel draws the same chart on every screen.
91
- */
92
- const FONT = "ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'PingFang SC', 'Noto Sans CJK SC', sans-serif";
93
- /** Format a number for a label: thousands grouped, up to `decimals` places. */
94
- function formatNumber(value, decimals = 0) {
95
- return value.toLocaleString("en-US", {
96
- minimumFractionDigits: decimals,
97
- maximumFractionDigits: decimals
98
- });
99
- }
100
- /** The colour a gauge shows at `fraction` of its range. */
101
- function gaugeColour(fraction, thresholds, c) {
102
- if (!thresholds) return c.accent;
103
- if (fraction >= thresholds[1]) return c.bad;
104
- if (fraction >= thresholds[0]) return c.warn;
105
- return c.good;
106
- }
107
- function gaugeOption(panel, c, animate) {
108
- const max = panel.max ?? 100;
109
- const fraction = Math.max(0, Math.min(1, panel.value / max));
110
- const colour = gaugeColour(fraction, panel.thresholds, c);
111
- const ring = panel.style === "ring";
112
- return {
113
- animation: animate,
114
- animationDuration: 1400,
115
- animationEasing: "cubicOut",
116
- series: [{
117
- type: "gauge",
118
- startAngle: ring ? 90 : 210,
119
- endAngle: ring ? -270 : -30,
120
- min: 0,
121
- max,
122
- radius: "92%",
123
- center: ["50%", ring ? "50%" : "58%"],
124
- progress: {
125
- show: true,
126
- width: ring ? 14 : 16,
127
- roundCap: true,
128
- itemStyle: {
129
- color: colour,
130
- shadowBlur: 12,
131
- shadowColor: withAlpha(colour, .5)
132
- }
133
- },
134
- pointer: {
135
- show: !ring,
136
- length: "60%",
137
- width: 4,
138
- itemStyle: { color: colour }
139
- },
140
- axisLine: { lineStyle: {
141
- width: ring ? 14 : 16,
142
- color: [[1, c.track]]
143
- } },
144
- axisTick: { show: false },
145
- splitLine: {
146
- show: !ring,
147
- length: 8,
148
- lineStyle: {
149
- color: c.muted,
150
- width: 1
151
- }
152
- },
153
- axisLabel: {
154
- show: !ring,
155
- color: c.muted,
156
- fontSize: 10,
157
- distance: 18,
158
- fontFamily: FONT
159
- },
160
- anchor: {
161
- show: !ring,
162
- size: 10,
163
- itemStyle: { color: colour }
164
- },
165
- title: { show: false },
166
- detail: {
167
- valueAnimation: animate,
168
- offsetCenter: [0, ring ? 0 : "28%"],
169
- fontSize: ring ? 28 : 24,
170
- fontWeight: 700,
171
- fontFamily: FONT,
172
- color: c.text,
173
- formatter: (value) => `${formatNumber(value, Number.isInteger(panel.value) ? 0 : 1)}${panel.unit ?? ""}`
174
- },
175
- data: [{ value: panel.value }]
176
- }]
177
- };
178
- }
179
- /**
180
- * The screen's palette laid over whatever the model wrote.
181
- *
182
- * The model's option wins on anything it sets; this only fills in the colours, the font, the
183
- * transparent background and the entrance animation a screen wants, so a plain `bar` series
184
- * still looks like it belongs.
185
- */
186
- function chartOption(panel, c, animate) {
187
- const axisStyle = {
188
- axisLine: { lineStyle: { color: c.gridLine } },
189
- axisLabel: {
190
- color: c.muted,
191
- fontFamily: FONT
192
- },
193
- splitLine: { lineStyle: { color: c.gridLine } }
194
- };
195
- const withAxisDefaults = (axis) => {
196
- if (Array.isArray(axis)) return axis.map((a) => ({
197
- ...axisStyle,
198
- ...a
199
- }));
200
- if (axis && typeof axis === "object") return {
201
- ...axisStyle,
202
- ...axis
203
- };
204
- return axis;
205
- };
206
- const option = panel.option;
207
- return {
208
- backgroundColor: "transparent",
209
- color: c.series,
210
- textStyle: {
211
- color: c.text,
212
- fontFamily: FONT
213
- },
214
- animation: animate,
215
- animationDuration: 1200,
216
- animationEasing: "cubicOut",
217
- grid: {
218
- left: 40,
219
- right: 16,
220
- top: 28,
221
- bottom: 28,
222
- containLabel: true
223
- },
224
- legend: { textStyle: { color: c.muted } },
225
- tooltip: { trigger: "axis" },
226
- ...option,
227
- ...option.xAxis !== void 0 ? { xAxis: withAxisDefaults(option.xAxis) } : {},
228
- ...option.yAxis !== void 0 ? { yAxis: withAxisDefaults(option.yAxis) } : {}
229
- };
230
- }
231
- function chart3dOption(panel, c, animate) {
232
- const values = panel.data.map((p) => p[2]);
233
- const max = Math.max(...values);
234
- const min = Math.min(...values);
235
- const axis = (categories, name) => ({
236
- type: categories ? "category" : "value",
237
- data: categories,
238
- name: "",
239
- axisLine: { lineStyle: { color: c.gridLine } },
240
- axisLabel: {
241
- color: c.muted,
242
- fontFamily: FONT
243
- },
244
- splitLine: { lineStyle: { color: c.gridLine } },
245
- axisPointer: { show: false },
246
- nameTextStyle: { color: c.muted },
247
- id: name
248
- });
249
- const series = {
250
- type: panel.type,
251
- data: panel.data,
252
- shading: "lambert",
253
- emphasis: { itemStyle: { color: c.text } }
254
- };
255
- if (panel.type === "bar3D") series.bevelSize = .2;
256
- if (panel.type === "scatter3D") series.symbolSize = 9;
257
- if (panel.type === "line3D") series.lineStyle = {
258
- width: 3,
259
- color: c.accent
260
- };
261
- if (panel.type === "surface") series.wireframe = {
262
- show: true,
263
- lineStyle: { color: withAlpha(c.accent, .35) }
264
- };
265
- return {
266
- backgroundColor: "transparent",
267
- textStyle: { fontFamily: FONT },
268
- tooltip: {},
269
- visualMap: {
270
- show: false,
271
- min,
272
- max,
273
- dimension: 2,
274
- inRange: { color: [
275
- withAlpha(c.accent, .55),
276
- c.accent,
277
- c.series[1]
278
- ] }
279
- },
280
- xAxis3D: axis(panel.xAxis, "x"),
281
- yAxis3D: axis(panel.yAxis, "y"),
282
- zAxis3D: {
283
- type: "value",
284
- name: "",
285
- axisLine: { lineStyle: { color: c.gridLine } },
286
- axisLabel: {
287
- color: c.muted,
288
- fontFamily: FONT
289
- },
290
- splitLine: { lineStyle: { color: c.gridLine } }
291
- },
292
- grid3D: {
293
- boxWidth: 100,
294
- boxDepth: 80,
295
- boxHeight: 60,
296
- axisPointer: { show: false },
297
- light: {
298
- main: {
299
- intensity: 1.3,
300
- shadow: false,
301
- alpha: 40,
302
- beta: 30
303
- },
304
- ambient: { intensity: .5 }
305
- },
306
- viewControl: {
307
- autoRotate: animate && panel.rotate !== false,
308
- autoRotateSpeed: 8,
309
- distance: 190,
310
- alpha: 24,
311
- beta: 35,
312
- projection: "perspective"
313
- },
314
- environment: "none"
315
- },
316
- series: [series]
317
- };
318
- }
319
- /**
320
- * A globe without a satellite photograph.
321
- *
322
- * ECharts' globe wants a texture, and the usual one is an image fetched from somewhere — which a
323
- * page must not do on a model's say-so. So the texture is painted here: a deep sphere with a
324
- * graticule, which is what a data wall's globe looks like anyway. Arcs get a moving trail.
325
- */
326
- function globeTexture(c, theme) {
327
- if (typeof document === "undefined") return void 0;
328
- const canvas = document.createElement("canvas");
329
- canvas.width = 1024;
330
- canvas.height = 512;
331
- const ctx = canvas.getContext("2d");
332
- if (!ctx) return void 0;
333
- ctx.fillStyle = theme === "dark" ? "#0b1a33" : "#dbe7f5";
334
- ctx.fillRect(0, 0, canvas.width, canvas.height);
335
- ctx.strokeStyle = withAlpha(c.accent, theme === "dark" ? .28 : .35);
336
- ctx.lineWidth = 1.2;
337
- for (let lng = 0; lng < 360; lng += 15) {
338
- const x = lng / 360 * canvas.width;
339
- ctx.beginPath();
340
- ctx.moveTo(x, 0);
341
- ctx.lineTo(x, canvas.height);
342
- ctx.stroke();
343
- }
344
- for (let lat = 15; lat < 180; lat += 15) {
345
- const y = lat / 180 * canvas.height;
346
- ctx.beginPath();
347
- ctx.moveTo(0, y);
348
- ctx.lineTo(canvas.width, y);
349
- ctx.stroke();
350
- }
351
- ctx.strokeStyle = withAlpha(c.accent, .6);
352
- ctx.lineWidth = 2;
353
- ctx.beginPath();
354
- ctx.moveTo(0, canvas.height / 2);
355
- ctx.lineTo(canvas.width, canvas.height / 2);
356
- ctx.stroke();
357
- return canvas.toDataURL("image/png");
358
- }
359
- function globeOption(panel, c, animate, texture) {
360
- const arcs = (panel.arcs ?? []).map((arc) => ({
361
- coords: [arc.from, arc.to],
362
- name: arc.label
363
- }));
364
- const points = (panel.points ?? []).map((point) => ({
365
- name: point.label,
366
- value: [
367
- point.coord[0],
368
- point.coord[1],
369
- 0,
370
- point.value ?? 1
371
- ]
372
- }));
373
- const maxValue = Math.max(1, ...points.map((p) => p.value[3]));
374
- return {
375
- backgroundColor: "transparent",
376
- globe: {
377
- baseTexture: texture,
378
- shading: "color",
379
- environment: "none",
380
- globeRadius: 78,
381
- atmosphere: {
382
- show: true,
383
- color: c.accent,
384
- glowPower: 5,
385
- innerGlowPower: 2,
386
- offset: 4
387
- },
388
- light: {
389
- ambient: { intensity: 1 },
390
- main: { intensity: .2 }
391
- },
392
- viewControl: {
393
- autoRotate: animate && panel.rotate !== false,
394
- autoRotateSpeed: 3,
395
- distance: 150,
396
- targetCoord: arcs[0]?.coords[0] ?? points[0]?.value.slice(0, 2)
397
- }
398
- },
399
- series: [{
400
- type: "lines3D",
401
- coordinateSystem: "globe",
402
- blendMode: "lighter",
403
- lineStyle: {
404
- width: 2.5,
405
- color: c.series[1],
406
- opacity: .9
407
- },
408
- effect: {
409
- show: animate,
410
- period: 3,
411
- trailWidth: 4,
412
- trailLength: .3,
413
- trailOpacity: 1,
414
- trailColor: "#ffffff"
415
- },
416
- data: arcs
417
- }, {
418
- type: "scatter3D",
419
- coordinateSystem: "globe",
420
- symbolSize: (value) => 6 + 10 * Math.sqrt((value[3] ?? 1) / maxValue),
421
- itemStyle: {
422
- color: c.series[1],
423
- opacity: .9
424
- },
425
- label: {
426
- show: true,
427
- formatter: "{b}",
428
- color: c.text,
429
- fontSize: 11,
430
- fontFamily: FONT,
431
- backgroundColor: "transparent",
432
- distance: 6
433
- },
434
- data: points
435
- }]
436
- };
437
- }
438
-
439
- //#endregion
440
- Object.defineProperty(exports, '__toESM', {
441
- enumerable: true,
442
- get: function () {
443
- return __toESM;
444
- }
445
- });
446
- Object.defineProperty(exports, 'chart3dOption', {
447
- enumerable: true,
448
- get: function () {
449
- return chart3dOption;
450
- }
451
- });
452
- Object.defineProperty(exports, 'chartOption', {
453
- enumerable: true,
454
- get: function () {
455
- return chartOption;
456
- }
457
- });
458
- Object.defineProperty(exports, 'formatNumber', {
459
- enumerable: true,
460
- get: function () {
461
- return formatNumber;
462
- }
463
- });
464
- Object.defineProperty(exports, 'gaugeColour', {
465
- enumerable: true,
466
- get: function () {
467
- return gaugeColour;
468
- }
469
- });
470
- Object.defineProperty(exports, 'gaugeOption', {
471
- enumerable: true,
472
- get: function () {
473
- return gaugeOption;
474
- }
475
- });
476
- Object.defineProperty(exports, 'globeOption', {
477
- enumerable: true,
478
- get: function () {
479
- return globeOption;
480
- }
481
- });
482
- Object.defineProperty(exports, 'globeTexture', {
483
- enumerable: true,
484
- get: function () {
485
- return globeTexture;
486
- }
487
- });
488
- Object.defineProperty(exports, 'palette', {
489
- enumerable: true,
490
- get: function () {
491
- return palette;
492
- }
493
- });
494
- Object.defineProperty(exports, 'withAlpha', {
495
- enumerable: true,
496
- get: function () {
497
- return withAlpha;
498
- }
499
- });