@devicechain/widget-sdk 0.24.0 → 0.25.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/README.md +15 -0
- package/dist/chunks/{chunk-A5BJ2ALW.js → chunk-G6I5HKQM.js} +36 -105
- package/dist/chunks/chunk-G6I5HKQM.js.map +7 -0
- package/dist/chunks/chunk-IG6DBHKZ.js +109 -0
- package/dist/chunks/chunk-IG6DBHKZ.js.map +7 -0
- package/dist/chunks/chunk-PECV5KDV.js +154 -0
- package/dist/chunks/chunk-PECV5KDV.js.map +7 -0
- package/dist/chunks/export-menu-727YDRIA.js +184 -0
- package/dist/chunks/export-menu-727YDRIA.js.map +7 -0
- package/dist/context.d.ts +22 -0
- package/dist/echarts.js +9 -3
- package/dist/echarts.js.map +2 -2
- package/dist/empty-state.d.ts +38 -0
- package/dist/empty-state.js +105 -0
- package/dist/empty-state.js.map +7 -0
- package/dist/export-csv.d.ts +12 -0
- package/dist/export-menu.d.ts +24 -0
- package/dist/frame.d.ts +3 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +103 -166
- package/dist/index.js.map +4 -4
- package/dist/widget-export.d.ts +7 -0
- package/package.json +7 -3
- package/dist/chunks/chunk-A5BJ2ALW.js.map +0 -7
package/README.md
CHANGED
|
@@ -98,6 +98,21 @@ for the built-in widgets.
|
|
|
98
98
|
Trusted widget code runs with the host page's privileges. The declarations in a descriptor
|
|
99
99
|
shape the API; they are not a security boundary.
|
|
100
100
|
|
|
101
|
+
## Offering a download from the frame
|
|
102
|
+
|
|
103
|
+
A widget can let the viewer save the data it shows. Pass `exportRows` to `WidgetFrame`: a function
|
|
104
|
+
that returns a `WidgetExportTable` (a file name without its extension, headings, and rows of
|
|
105
|
+
strings, numbers, booleans or nulls), or a promise of one. The frame then draws a download button
|
|
106
|
+
in its title bar, and **Download CSV** calls your function when the viewer picks it, so the table is
|
|
107
|
+
built on demand from what the widget is showing. The prop is optional and feature-detected: a widget
|
|
108
|
+
that passes none is unchanged, and the frame draws no button when its title bar is hidden.
|
|
109
|
+
|
|
110
|
+
The CSV encoder is the frame's: RFC 4180 quoting, a leading apostrophe on a text cell that begins with
|
|
111
|
+
`=`, `+`, `-`, `@`, tab or carriage return (so a spreadsheet never runs it as a formula), and UTF-8 with
|
|
112
|
+
a byte-order mark so Excel reads units such as `°C`. Put the unit in the heading, write instants as
|
|
113
|
+
ISO 8601 with a zone, and say in the file name what the file covers (the span and the bucket on
|
|
114
|
+
screen). A chart drawn with `<EChart>` also gets **Download image (PNG)** with no code of yours.
|
|
115
|
+
|
|
101
116
|
## Upgrading from 0.21
|
|
102
117
|
|
|
103
118
|
0.22 removes no export. A TypeScript build can notice three changes:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/context.tsx
|
|
2
|
-
import { createContext, useContext } from "react";
|
|
2
|
+
import { createContext, useContext, useEffect, useRef } from "react";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
var WidgetSubjectContext = createContext(void 0);
|
|
5
5
|
function useWidgetSubject() {
|
|
@@ -76,6 +76,17 @@ function WidgetFreshnessProvider({
|
|
|
76
76
|
function useWidgetFreshness() {
|
|
77
77
|
return useContext(WidgetFreshnessContext);
|
|
78
78
|
}
|
|
79
|
+
var NO_DECLARED = { declared: void 0, ask: () => void 0 };
|
|
80
|
+
var WidgetDeclaredMetricsContext = createContext(NO_DECLARED);
|
|
81
|
+
function WidgetDeclaredMetricsProvider({
|
|
82
|
+
value,
|
|
83
|
+
children
|
|
84
|
+
}) {
|
|
85
|
+
return /* @__PURE__ */ jsx(WidgetDeclaredMetricsContext.Provider, { value, children });
|
|
86
|
+
}
|
|
87
|
+
function useWidgetDeclaredMetrics() {
|
|
88
|
+
return useContext(WidgetDeclaredMetricsContext);
|
|
89
|
+
}
|
|
79
90
|
var WidgetFrameStyleContext = createContext(void 0);
|
|
80
91
|
function WidgetFrameStyleProvider({ frame, children }) {
|
|
81
92
|
return /* @__PURE__ */ jsx(WidgetFrameStyleContext.Provider, { value: frame, children });
|
|
@@ -93,6 +104,24 @@ function WidgetTimeRangeProvider({
|
|
|
93
104
|
function useWidgetTimeRange() {
|
|
94
105
|
return useContext(WidgetTimeRangeContext);
|
|
95
106
|
}
|
|
107
|
+
var WidgetImageRegistrarContext = createContext(void 0);
|
|
108
|
+
function WidgetImageRegistrarProvider({
|
|
109
|
+
register,
|
|
110
|
+
children
|
|
111
|
+
}) {
|
|
112
|
+
return /* @__PURE__ */ jsx(WidgetImageRegistrarContext.Provider, { value: register, children });
|
|
113
|
+
}
|
|
114
|
+
function useRegisterWidgetImage(source) {
|
|
115
|
+
const register = useContext(WidgetImageRegistrarContext);
|
|
116
|
+
const latest = useRef(source);
|
|
117
|
+
latest.current = source;
|
|
118
|
+
const offered = source !== void 0;
|
|
119
|
+
useEffect(() => {
|
|
120
|
+
if (!register || !offered) return;
|
|
121
|
+
register((options) => latest.current?.(options));
|
|
122
|
+
return () => register(void 0);
|
|
123
|
+
}, [register, offered]);
|
|
124
|
+
}
|
|
96
125
|
|
|
97
126
|
// src/severity.ts
|
|
98
127
|
import { useMemo, useSyncExternalStore } from "react";
|
|
@@ -180,97 +209,6 @@ function useSeverityColors() {
|
|
|
180
209
|
return scoped ?? page;
|
|
181
210
|
}
|
|
182
211
|
|
|
183
|
-
// src/fit-text.ts
|
|
184
|
-
var FIT_MIN_FONT_PX = 12;
|
|
185
|
-
var FIT_FALLBACK_FONT_PX = 32;
|
|
186
|
-
var FIT_HEIGHT_SHARE = 0.6;
|
|
187
|
-
var FIT_GLYPH_WIDTH = 0.65;
|
|
188
|
-
function charCount(chars) {
|
|
189
|
-
return Math.max(1, Math.ceil(Number.isFinite(chars) ? chars : 1));
|
|
190
|
-
}
|
|
191
|
-
function fitValueFont(size, chars, options = {}) {
|
|
192
|
-
const floor = options.floor ?? FIT_MIN_FONT_PX;
|
|
193
|
-
if (!(size.width > 0) || !(size.height > 0)) return Math.max(floor, FIT_FALLBACK_FONT_PX);
|
|
194
|
-
const byHeight = size.height * FIT_HEIGHT_SHARE;
|
|
195
|
-
const byWidth = size.width / (charCount(chars) * FIT_GLYPH_WIDTH);
|
|
196
|
-
return Math.max(floor, Math.floor(Math.min(byHeight, byWidth)));
|
|
197
|
-
}
|
|
198
|
-
function fitValueFontCss(chars, options = {}) {
|
|
199
|
-
const floor = options.floor ?? FIT_MIN_FONT_PX;
|
|
200
|
-
const perChar = 100 / (charCount(chars) * FIT_GLYPH_WIDTH);
|
|
201
|
-
return `max(${floor}px, min(${FIT_HEIGHT_SHARE * 100}cqh, ${Number(perChar.toFixed(3))}cqw))`;
|
|
202
|
-
}
|
|
203
|
-
function stickyChars(prev, chars, now, holdMs) {
|
|
204
|
-
if (!prev || chars >= prev.value) return { value: chars, since: now };
|
|
205
|
-
if (now - prev.since >= holdMs) return { value: chars, since: now };
|
|
206
|
-
return prev;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
// src/format.ts
|
|
210
|
-
function formatTimestamp(iso, timeZone) {
|
|
211
|
-
if (!iso) return "";
|
|
212
|
-
const date = new Date(iso);
|
|
213
|
-
if (Number.isNaN(date.getTime())) return iso;
|
|
214
|
-
return timeZone ? date.toLocaleTimeString(void 0, { timeZone, timeZoneName: "short" }) : date.toLocaleTimeString();
|
|
215
|
-
}
|
|
216
|
-
function formatDateTime(iso, timeZone) {
|
|
217
|
-
if (!iso) return "";
|
|
218
|
-
const date = new Date(iso);
|
|
219
|
-
if (Number.isNaN(date.getTime())) return iso;
|
|
220
|
-
return timeZone ? date.toLocaleString(void 0, { timeZone, timeZoneName: "short" }) : date.toLocaleString();
|
|
221
|
-
}
|
|
222
|
-
var DEFAULT_FRACTION_DIGITS = 3;
|
|
223
|
-
var DEFAULT_SMALL_SIGNIFICANT = 4;
|
|
224
|
-
function defaultFormat(value) {
|
|
225
|
-
if (!Number.isFinite(value)) return String(value);
|
|
226
|
-
const rounded = Math.abs(value) >= 1 ? Number(value.toFixed(DEFAULT_FRACTION_DIGITS)) : Number(value.toPrecision(DEFAULT_SMALL_SIGNIFICANT));
|
|
227
|
-
return String(rounded);
|
|
228
|
-
}
|
|
229
|
-
function formatValue(value, precision) {
|
|
230
|
-
if (value == null) return "\u2014";
|
|
231
|
-
if (precision == null) return defaultFormat(value);
|
|
232
|
-
const places = Math.min(100, Math.max(0, Math.trunc(precision)));
|
|
233
|
-
return value.toFixed(places);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
// src/thresholds.ts
|
|
237
|
-
function parseThresholds(raw) {
|
|
238
|
-
if (!Array.isArray(raw)) return [];
|
|
239
|
-
const out = [];
|
|
240
|
-
for (const item of raw) {
|
|
241
|
-
if (typeof item !== "object" || item === null) continue;
|
|
242
|
-
const { value, level, label } = item;
|
|
243
|
-
if (typeof value !== "number" || !Number.isFinite(value) || !isSeverityLevel(level)) continue;
|
|
244
|
-
out.push(typeof label === "string" && label !== "" ? { value, level, label } : { value, level });
|
|
245
|
-
}
|
|
246
|
-
return out.map((t, i) => ({ t, i })).sort((a, b) => a.t.value - b.t.value || a.i - b.i).map(({ t }) => t);
|
|
247
|
-
}
|
|
248
|
-
function optThresholds(options, key = "thresholds") {
|
|
249
|
-
return parseThresholds(options?.[key]);
|
|
250
|
-
}
|
|
251
|
-
function bandAt(thresholds, value) {
|
|
252
|
-
if (value == null || !Number.isFinite(value)) return void 0;
|
|
253
|
-
let hit;
|
|
254
|
-
for (const t of thresholds) {
|
|
255
|
-
if (value >= t.value) hit = t;
|
|
256
|
-
else break;
|
|
257
|
-
}
|
|
258
|
-
return hit;
|
|
259
|
-
}
|
|
260
|
-
function thresholdBands(thresholds, min, max) {
|
|
261
|
-
if (!(max > min)) return [];
|
|
262
|
-
const bands = [];
|
|
263
|
-
const push = (from, to, level, label) => {
|
|
264
|
-
const a = Math.max(from, min);
|
|
265
|
-
const b = Math.min(to, max);
|
|
266
|
-
if (b > a) bands.push(label === void 0 ? { from: a, to: b, level } : { from: a, to: b, level, label });
|
|
267
|
-
};
|
|
268
|
-
if (thresholds.length === 0) return [];
|
|
269
|
-
push(-Infinity, thresholds[0].value, void 0);
|
|
270
|
-
thresholds.forEach((t, i) => push(t.value, thresholds[i + 1]?.value ?? Infinity, t.level, t.label));
|
|
271
|
-
return bands;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
212
|
export {
|
|
275
213
|
useWidgetSubject,
|
|
276
214
|
WidgetSubjectProvider,
|
|
@@ -288,10 +226,14 @@ export {
|
|
|
288
226
|
useWidgetCandidates,
|
|
289
227
|
WidgetFreshnessProvider,
|
|
290
228
|
useWidgetFreshness,
|
|
229
|
+
WidgetDeclaredMetricsProvider,
|
|
230
|
+
useWidgetDeclaredMetrics,
|
|
291
231
|
WidgetFrameStyleProvider,
|
|
292
232
|
useWidgetFrameStyle,
|
|
293
233
|
WidgetTimeRangeProvider,
|
|
294
234
|
useWidgetTimeRange,
|
|
235
|
+
WidgetImageRegistrarProvider,
|
|
236
|
+
useRegisterWidgetImage,
|
|
295
237
|
SEVERITY_LEVELS,
|
|
296
238
|
isSeverityLevel,
|
|
297
239
|
ALARM_LEVELS,
|
|
@@ -302,17 +244,6 @@ export {
|
|
|
302
244
|
severityTokenCss,
|
|
303
245
|
severityFallbackColors,
|
|
304
246
|
severityColorsAt,
|
|
305
|
-
useSeverityColors
|
|
306
|
-
FIT_MIN_FONT_PX,
|
|
307
|
-
fitValueFont,
|
|
308
|
-
fitValueFontCss,
|
|
309
|
-
stickyChars,
|
|
310
|
-
formatTimestamp,
|
|
311
|
-
formatDateTime,
|
|
312
|
-
formatValue,
|
|
313
|
-
parseThresholds,
|
|
314
|
-
optThresholds,
|
|
315
|
-
bandAt,
|
|
316
|
-
thresholdBands
|
|
247
|
+
useSeverityColors
|
|
317
248
|
};
|
|
318
|
-
//# sourceMappingURL=chunk-
|
|
249
|
+
//# sourceMappingURL=chunk-G6I5HKQM.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/context.tsx", "../../src/severity.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright The DeviceChain Authors\n// SPDX-License-Identifier: Apache-2.0\n\n// The ambient host context a widget reads: the resolved subject, the display time zone, the\n// theme root, the selection callback and the candidate provider.\n//\n// \uD83D\uDD34 THESE CONTEXTS ARE DEFINED HERE AND NOWHERE ELSE. A React context is identified by the\n// OBJECT createContext returned, so two copies of this module \u2014 one bundled into a widget\n// package, one in the host \u2014 are two unrelated contexts: the host's provider writes to one\n// and the widget reads the other, and the selector silently does nothing. Exactly one\n// definition, in this package, which `@devicechain/widgets` and every third-party widget\n// package depend on as a PEER (never a dependency) so the host's install supplies the\n// single copy.\n\nimport { createContext, useContext, useEffect, useRef, type ReactNode } from 'react';\n\nimport type { ResolvedFrame, SelectionCandidate, SelectionTarget, TimeRangeState } from '@devicechain/dashboards';\n\n// WidgetSubjectContext carries the resolved entity a widget shows (its datasource's\n// bound device/anchor), computed once by the renderer and provided per widget. The\n// frame reads it as a subtitle so every board answers \"which asset is this?\" \u2014 and,\n// because it reads the RESOLVED binding, it updates for free once selection re-points a\n// slot (ADR-039 selection-overlay amendment). Kept as ambient context, not a widget\n// prop, so the pure widget contract (widget, data) stays untouched and no widget needs\n// to know how a subject is resolved.\nconst WidgetSubjectContext = createContext<string | undefined>(undefined);\n\n// useWidgetSubject reads the resolved subject line (the frame's fallback subtitle).\nexport function useWidgetSubject(): string | undefined {\n return useContext(WidgetSubjectContext);\n}\n\nexport function WidgetSubjectProvider({\n label,\n children,\n}: {\n label: string | undefined;\n children: ReactNode;\n}) {\n return <WidgetSubjectContext.Provider value={label}>{children}</WidgetSubjectContext.Provider>;\n}\n\n// WidgetTimeZone is the zone widgets print instants in. Undefined (the default) means the\n// viewer's own zone, which is what every live host wants; a host replaying a recording\n// pins one so the board's times agree with the recording's own clock.\nconst WidgetTimeZoneContext = createContext<string | undefined>(undefined);\n\nexport function WidgetTimeZoneProvider({\n timeZone,\n children,\n}: {\n timeZone: string | undefined;\n children: ReactNode;\n}) {\n return <WidgetTimeZoneContext.Provider value={timeZone}>{children}</WidgetTimeZoneContext.Provider>;\n}\n\nexport function useWidgetTimeZone(): string | undefined {\n return useContext(WidgetTimeZoneContext);\n}\n\n// WidgetThemeRoot is the element chart colors are read from. Undefined (the default) means\n// the document root, which is where a console or dashboard app sets its tokens. A host that\n// scopes its tokens to a container (an embed on a page whose own stylesheet owns the root)\n// provides that container, and charts resolve their colors there instead.\nconst WidgetThemeRootContext = createContext<Element | undefined>(undefined);\n\nexport function WidgetThemeRootProvider({\n root,\n children,\n}: {\n root: Element | undefined;\n children: ReactNode;\n}) {\n return <WidgetThemeRootContext.Provider value={root}>{children}</WidgetThemeRootContext.Provider>;\n}\n\nexport function useWidgetThemeRoot(): Element | undefined {\n return useContext(WidgetThemeRootContext);\n}\n\n// The density scale the board renders at (0.9 compact / 1 comfortable / 1.5 wall), provided by\n// the renderer. Outside a renderer it is 1.\nconst WidgetDensityContext = createContext<number>(1);\n\nexport function WidgetDensityProvider({ scale, children }: { scale: number; children: ReactNode }) {\n return <WidgetDensityContext.Provider value={scale}>{children}</WidgetDensityContext.Provider>;\n}\n\nexport function useWidgetDensityScale(): number {\n return useContext(WidgetDensityContext);\n}\n\n// The size of the widget frame's padded content column in px (quantised), provided by\n// WidgetFrame to everything rendered inside it. {0,0} until measured, and outside a frame.\nexport interface WidgetBodySize {\n width: number;\n height: number;\n}\nconst ZERO_SIZE: WidgetBodySize = { width: 0, height: 0 };\nconst WidgetBodySizeContext = createContext<WidgetBodySize>(ZERO_SIZE);\n\nexport function WidgetBodySizeProvider({ size, children }: { size: WidgetBodySize; children: ReactNode }) {\n return <WidgetBodySizeContext.Provider value={size}>{children}</WidgetBodySizeContext.Provider>;\n}\n\nexport function useWidgetBodySize(): WidgetBodySize {\n return useContext(WidgetBodySizeContext);\n}\n\n// WidgetSelect is a view-interaction callback (ADR-039 selection amendment): a widget\n// drives a slot selection (an alarm-table originator drill, a context-selector pick) by\n// naming its target slot + the entity to bind. Kept DISTINCT from WidgetActions (the\n// write seam) \u2014 selection changes only the view's binding overlay, never the backend.\n// Provided by the renderer from the host; absent (undefined) in edit mode and any host\n// that wires no selection, so a widget feature-detects it before offering a drill.\nexport type WidgetSelect = (target: SelectionTarget) => void;\n\nconst WidgetSelectContext = createContext<WidgetSelect | undefined>(undefined);\n\nexport function WidgetSelectProvider({\n select,\n children,\n}: {\n select: WidgetSelect | undefined;\n children: ReactNode;\n}) {\n return <WidgetSelectContext.Provider value={select}>{children}</WidgetSelectContext.Provider>;\n}\n\n// useWidgetSelect returns the ambient selection callback, or undefined where selection is\n// not wired (edit mode, a read-only embedder). A widget renders its drill affordance only\n// when this is defined.\nexport function useWidgetSelect(): WidgetSelect | undefined {\n return useContext(WidgetSelectContext);\n}\n\n// WidgetCandidates is the ambient companion to WidgetSelect (ADR-039 selection amendment): a\n// context/entity-selector widget asks it for the options a target slot may bind to. The host\n// computes candidates from the definition's scope + resolved bindings (useSlotCandidates), so\n// the widget stays presentational and the pure widget contract stays untouched. Distinct from\n// the hub's data channels \u2014 candidates are a fetch-on-open list, not a live stream. Undefined\n// where not wired (edit/preview, a host that supplies no selection) \u2192 the selector is inert.\nexport type WidgetCandidates = (slot: string) => Promise<SelectionCandidate[]>;\n\nconst WidgetCandidatesContext = createContext<WidgetCandidates | undefined>(undefined);\n\nexport function WidgetCandidatesProvider({\n candidates,\n children,\n}: {\n candidates: WidgetCandidates | undefined;\n children: ReactNode;\n}) {\n return <WidgetCandidatesContext.Provider value={candidates}>{children}</WidgetCandidatesContext.Provider>;\n}\n\n// useWidgetCandidates returns the ambient candidate provider, or undefined where selection is\n// not wired. A selector widget renders its picker only when both this and useWidgetSelect are\n// defined.\nexport function useWidgetCandidates(): WidgetCandidates | undefined {\n return useContext(WidgetCandidatesContext);\n}\n\n// WidgetFreshness is what the host knows about how current a widget's data is: the time of its\n// newest sample (epoch ms) and the age past which that is stale. Provided only for a widget\n// whose descriptor opts in (`freshness: true`); the frame reads it and draws the age readout.\n// Absent, the frame draws nothing, so a widget that does not opt in is unchanged.\n//\n// `staleAfterSeconds` is undefined when no threshold is known, which means the age is shown\n// and nothing is ever styled stale. `at` is undefined while no sample has arrived.\nexport interface WidgetFreshness {\n at: number | undefined;\n staleAfterSeconds: number | undefined;\n}\n\nconst WidgetFreshnessContext = createContext<WidgetFreshness | undefined>(undefined);\n\nexport function WidgetFreshnessProvider({\n freshness,\n children,\n}: {\n freshness: WidgetFreshness | undefined;\n children: ReactNode;\n}) {\n return <WidgetFreshnessContext.Provider value={freshness}>{children}</WidgetFreshnessContext.Provider>;\n}\n\nexport function useWidgetFreshness(): WidgetFreshness | undefined {\n return useContext(WidgetFreshnessContext);\n}\n\n// What the widget's bound device's ACTIVE profile declares, for a widget that has nothing to draw and\n// needs to say whether the device will ever report what it asks for. `declared` is the declared\n// measurement names, `null` when the profile cannot say (none published, no way to look), and\n// `undefined` until it has been asked for and answered. Nothing is read until a widget calls\n// `ask()` -- a board whose widgets all have data costs no lookup. An unknown declaration is read\n// as declared, never as absent.\nexport interface WidgetDeclaredMetrics {\n declared: readonly string[] | null | undefined;\n ask: () => void;\n}\n\nconst NO_DECLARED: WidgetDeclaredMetrics = { declared: undefined, ask: () => undefined };\nconst WidgetDeclaredMetricsContext = createContext<WidgetDeclaredMetrics>(NO_DECLARED);\n\nexport function WidgetDeclaredMetricsProvider({\n value,\n children,\n}: {\n value: WidgetDeclaredMetrics;\n children: ReactNode;\n}) {\n return <WidgetDeclaredMetricsContext.Provider value={value}>{children}</WidgetDeclaredMetricsContext.Provider>;\n}\n\nexport function useWidgetDeclaredMetrics(): WidgetDeclaredMetrics {\n return useContext(WidgetDeclaredMetricsContext);\n}\n\n// The frame a board gives a widget: its canvas default merged with the widget's own override\n// (resolveFrame in @devicechain/dashboards). Absent -- a widget mounted outside a board -- the\n// frame is today's card.\nconst WidgetFrameStyleContext = createContext<ResolvedFrame | undefined>(undefined);\n\nexport function WidgetFrameStyleProvider({ frame, children }: { frame: ResolvedFrame | undefined; children: ReactNode }) {\n return <WidgetFrameStyleContext.Provider value={frame}>{children}</WidgetFrameStyleContext.Provider>;\n}\n\nexport function useWidgetFrameStyle(): ResolvedFrame | undefined {\n return useContext(WidgetFrameStyleContext);\n}\n\n// The board's time range: the span its time-series widgets draw (seconds back from now) and\n// whether the viewer has frozen the board. Provided by the renderer. A widget that draws\n// history reads it to label its axis or to ask its own questions; the built-in time-series chart\n// needs no code of its own, because the host sizes its window from the same value. `pausedAt`\n// is set exactly while `paused`, and is the instant the window ends at while frozen.\n//\n// Undefined outside a board (a widget mounted on its own), which is \"no range is imposed\" -- not\n// a default span. A widget must handle that rather than assume an hour.\nconst WidgetTimeRangeContext = createContext<TimeRangeState | undefined>(undefined);\n\nexport function WidgetTimeRangeProvider({\n range,\n children,\n}: {\n range: TimeRangeState | undefined;\n children: ReactNode;\n}) {\n return <WidgetTimeRangeContext.Provider value={range}>{children}</WidgetTimeRangeContext.Provider>;\n}\n\nexport function useWidgetTimeRange(): TimeRangeState | undefined {\n return useContext(WidgetTimeRangeContext);\n}\n\n// ---- Chart image export --------------------------------------------------------------------\n//\n// A chart widget draws into a canvas the frame cannot reach, and the frame owns the export menu. So\n// the chart wrapper (<EChart>) REGISTERS a way to read its image, and the frame offers \"Download\n// image\" only while one is registered: a widget that draws no chart has nothing to register and is\n// offered no image. The registrar is provided by the frame around its content; outside a frame it is\n// absent and registering does nothing.\n\n/** Reads the chart as a PNG data URL on the given background (a canvas is transparent), or undefined while it has none. */\nexport type WidgetImageSource = (options: { backgroundColor: string }) => string | undefined;\n\nconst WidgetImageRegistrarContext = createContext<((source: WidgetImageSource | undefined) => void) | undefined>(undefined);\n\nexport function WidgetImageRegistrarProvider({\n register,\n children,\n}: {\n register: (source: WidgetImageSource | undefined) => void;\n children: ReactNode;\n}) {\n return <WidgetImageRegistrarContext.Provider value={register}>{children}</WidgetImageRegistrarContext.Provider>;\n}\n\n/**\n * Offers the caller's image to the enclosing frame while `source` is given. It may change every\n * render; passing `undefined` withdraws it (a chart that has not drawn yet has no image to offer).\n */\nexport function useRegisterWidgetImage(source: WidgetImageSource | undefined): void {\n const register = useContext(WidgetImageRegistrarContext);\n const latest = useRef(source);\n latest.current = source;\n const offered = source !== undefined;\n useEffect(() => {\n if (!register || !offered) return;\n register((options) => latest.current?.(options));\n return () => register(undefined);\n }, [register, offered]);\n}\n", "// Copyright The DeviceChain Authors\n// SPDX-License-Identifier: Apache-2.0\n\n// The severity levels a threshold names, and the colours the ABNORMAL ones resolve to. A\n// threshold names a LEVEL, never a colour: an author cannot write `#f00`, so a board stays coherent under a re-themed host,\n// dark mode and (later) a greyscale operator theme where colour means severity and nothing\n// else.\n//\n// \uD83D\uDD11 `normal` HAS NO COLOUR. Colour appears only when something is abnormal (the ISA-101\n// rule): a value in a `normal` band renders exactly as it would with no thresholds at all --\n// the card's ordinary text, the gauge's neutral track and accent needle, no chart fill. So a\n// healthy \"below X\" rule and a healthy \"above X\" rule look the same. `normal` stays in the\n// level vocabulary because it is how a band ENDS (\"low fuel below 15\" is critical from 0,\n// normal from 15); it simply is not one of the coloured levels, and there is no\n// `--sev-normal` token. Each widget's own neutral is different (text, track, accent), which\n// is why the theme does not pretend to own one.\n//\n// \uD83D\uDD11 DEFINED ONCE, HERE. The values below are the single source of the `--sev-*` custom\n// properties. A host that defines `--sev-<level>` as HSL channels (the same convention as\n// every other token) wins; a host that does not still renders the colours below, light or\n// dark, so a threshold never draws as nothing for want of a token. `severityTokenCss()` emits\n// the same values as a stylesheet so a host's token set can be generated from this table\n// instead of re-typed.\n\nimport { useMemo, useSyncExternalStore } from 'react';\n\nimport { useWidgetThemeRoot } from './context';\n\nexport const SEVERITY_LEVELS = ['normal', 'warning', 'minor', 'major', 'critical'] as const;\nexport type SeverityLevel = (typeof SEVERITY_LEVELS)[number];\n\nexport function isSeverityLevel(value: unknown): value is SeverityLevel {\n return typeof value === 'string' && (SEVERITY_LEVELS as readonly string[]).includes(value);\n}\n\n// The levels that carry a colour: every level but `normal`.\nexport const ALARM_LEVELS = ['warning', 'minor', 'major', 'critical'] as const;\nexport type AlarmLevel = (typeof ALARM_LEVELS)[number];\n\nexport function isAlarmLevel(level: SeverityLevel | undefined): level is AlarmLevel {\n return level !== undefined && level !== 'normal';\n}\n\n// The colour a level renders in, or undefined for `normal` (and for no level): the caller then\n// uses its own neutral colour.\nexport function levelColor(colors: Readonly<Record<AlarmLevel, string>>, level: SeverityLevel | undefined): string | undefined {\n return isAlarmLevel(level) ? colors[level] : undefined;\n}\n\n// HSL channels (\"h s% l%\"), the form the host tokens use. The warm-to-cool ramp mirrors the\n// alarm severities (red, orange, amber, sky) so one hue means one severity on a card, a gauge\n// band and an alarm row. The dark column is lighter so each reads as INK against a dark ground.\nexport const SEVERITY_TOKENS: Readonly<Record<AlarmLevel, { light: string; dark: string }>> = {\n warning: { light: '199 89% 44%', dark: '199 89% 62%' },\n minor: { light: '32 95% 40%', dark: '38 92% 56%' },\n major: { light: '25 95% 48%', dark: '25 95% 62%' },\n critical: { light: '0 72% 46%', dark: '0 84% 66%' },\n};\n\n// The custom-property name a host defines for a coloured level.\nexport function severityVar(level: AlarmLevel): string {\n return `--sev-${level}`;\n}\n\n// The tokens as CSS, `:root` light and `.dark` dark -- what a host stylesheet pastes (or a\n// build step writes) so the host and this package cannot disagree about a colour. `hostWins`\n// wraps the selectors in `:where()` (zero specificity) for a stylesheet injected alongside a\n// host's own: any ordinary host rule for the same variable then beats it.\nexport function severityTokenCss(options: { hostWins?: boolean } = {}): string {\n const wrap = (selector: string) => (options.hostWins ? `:where(${selector})` : selector);\n const block = (selector: string, side: 'light' | 'dark') =>\n [\n `${wrap(selector)} {`,\n ...ALARM_LEVELS.map((l) => ` ${severityVar(l)}: ${SEVERITY_TOKENS[l][side]};`),\n '}',\n ].join('\\n');\n return `${block(':root', 'light')}\\n${block('.dark', 'dark')}\\n`;\n}\n\n// --- concrete colours ---------------------------------------------------------------\n//\n// A canvas (and an inline style that must be one value) needs a concrete colour, not\n// `var(--sev-x)`. These resolve the level colours in scope at an element: the host's\n// `--sev-<level>` token when it defines one, else the table above for the light or dark ground.\n// They live HERE, not with the chart theme, so a DOM-only widget (a card colouring its value\n// by threshold) gets them from the SDK root without reaching into the `/echarts` entry; the\n// chart theme reads its severity colours through the same functions.\n\n// A channel triple (\"h s% l%\", space- or comma-separated) as a comma-form hsl() colour, the\n// form every canvas colour parser accepts and severityFill can add an alpha to.\nfunction hslFromChannels(channels: string): string {\n const [h, s, l] = channels.replace(/,/g, ' ').trim().split(/\\s+/);\n return `hsl(${h}, ${s}, ${l})`;\n}\n\nfunction severityColors(dark: boolean, host: (cssVar: string) => string | undefined): Record<AlarmLevel, string> {\n const out = {} as Record<AlarmLevel, string>;\n for (const level of ALARM_LEVELS) {\n out[level] = hslFromChannels(host(severityVar(level)) || SEVERITY_TOKENS[level][dark ? 'dark' : 'light']);\n }\n return out;\n}\n\n// Dark when the element sits under a `.dark` ancestor -- the host convention every token block\n// here uses -- or the document root carries it.\nfunction isDark(el: Element): boolean {\n return el.closest('.dark') !== null || el.ownerDocument.documentElement.classList.contains('dark');\n}\n\n// The light colours with no host involved (jsdom, a host with no tokens yet).\nexport function severityFallbackColors(): Record<AlarmLevel, string> {\n return severityColors(false, () => undefined);\n}\n\n// The colours in scope at `el`. `style` is its computed style when the caller already has it.\nexport function severityColorsAt(el: Element, style: CSSStyleDeclaration = getComputedStyle(el)): Record<AlarmLevel, string> {\n return severityColors(isDark(el), (name) => style.getPropertyValue(name).trim() || undefined);\n}\n\n// One page-wide observer, shared by every caller (the same O(1)-per-toggle shape as the chart\n// theme store): re-resolved when <html> changes class (light/dark) or inline style (tokens).\nlet shared: Record<AlarmLevel, string> | null = null;\nconst listeners = new Set<() => void>();\nlet observer: MutationObserver | null = null;\n\nfunction subscribe(listener: () => void): () => void {\n if (!observer) {\n shared = severityColorsAt(document.documentElement);\n observer = new MutationObserver(() => {\n shared = severityColorsAt(document.documentElement);\n for (const l of listeners) l();\n });\n observer.observe(document.documentElement, { attributes: true, attributeFilter: ['class', 'style'] });\n }\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n if (listeners.size === 0 && observer) {\n observer.disconnect();\n observer = null;\n shared = null;\n }\n };\n}\n\nfunction snapshot(): Record<AlarmLevel, string> {\n shared ??= severityColorsAt(document.documentElement);\n return shared;\n}\n\n// useSeverityColors returns the four concrete severity colours (none for `normal`) and re-renders the caller when\n// the document theme changes. A container-scoped theme (WidgetThemeRoot) is read once there,\n// as the chart theme does.\nexport function useSeverityColors(): Record<AlarmLevel, string> {\n const page = useSyncExternalStore(subscribe, snapshot, snapshot);\n const root = useWidgetThemeRoot();\n const scoped = useMemo(() => (root ? severityColorsAt(root) : null), [root]);\n return scoped ?? page;\n}\n"],
|
|
5
|
+
"mappings": ";AAcA,SAAS,eAAe,YAAY,WAAW,cAA8B;AAyBpE;AAdT,IAAM,uBAAuB,cAAkC,MAAS;AAGjE,SAAS,mBAAuC;AACrD,SAAO,WAAW,oBAAoB;AACxC;AAEO,SAAS,sBAAsB;AAAA,EACpC;AAAA,EACA;AACF,GAGG;AACD,SAAO,oBAAC,qBAAqB,UAArB,EAA8B,OAAO,OAAQ,UAAS;AAChE;AAKA,IAAM,wBAAwB,cAAkC,MAAS;AAElE,SAAS,uBAAuB;AAAA,EACrC;AAAA,EACA;AACF,GAGG;AACD,SAAO,oBAAC,sBAAsB,UAAtB,EAA+B,OAAO,UAAW,UAAS;AACpE;AAEO,SAAS,oBAAwC;AACtD,SAAO,WAAW,qBAAqB;AACzC;AAMA,IAAM,yBAAyB,cAAmC,MAAS;AAEpE,SAAS,wBAAwB;AAAA,EACtC;AAAA,EACA;AACF,GAGG;AACD,SAAO,oBAAC,uBAAuB,UAAvB,EAAgC,OAAO,MAAO,UAAS;AACjE;AAEO,SAAS,qBAA0C;AACxD,SAAO,WAAW,sBAAsB;AAC1C;AAIA,IAAM,uBAAuB,cAAsB,CAAC;AAE7C,SAAS,sBAAsB,EAAE,OAAO,SAAS,GAA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.ts
|
|
6
|
+
var FIT_MIN_FONT_PX = 12;
|
|
7
|
+
var FIT_FALLBACK_FONT_PX = 32;
|
|
8
|
+
var FIT_HEIGHT_SHARE = 0.6;
|
|
9
|
+
var FIT_GLYPH_WIDTH = 0.65;
|
|
10
|
+
function charCount(chars) {
|
|
11
|
+
return Math.max(1, Math.ceil(Number.isFinite(chars) ? chars : 1));
|
|
12
|
+
}
|
|
13
|
+
function fitValueFont(size, chars, options = {}) {
|
|
14
|
+
const floor = options.floor ?? FIT_MIN_FONT_PX;
|
|
15
|
+
if (!(size.width > 0) || !(size.height > 0)) return Math.max(floor, FIT_FALLBACK_FONT_PX);
|
|
16
|
+
const byHeight = size.height * FIT_HEIGHT_SHARE;
|
|
17
|
+
const byWidth = size.width / (charCount(chars) * FIT_GLYPH_WIDTH);
|
|
18
|
+
return Math.max(floor, Math.floor(Math.min(byHeight, byWidth)));
|
|
19
|
+
}
|
|
20
|
+
function fitValueFontCss(chars, options = {}) {
|
|
21
|
+
const floor = options.floor ?? FIT_MIN_FONT_PX;
|
|
22
|
+
const perChar = 100 / (charCount(chars) * FIT_GLYPH_WIDTH);
|
|
23
|
+
return `max(${floor}px, min(${FIT_HEIGHT_SHARE * 100}cqh, ${Number(perChar.toFixed(3))}cqw))`;
|
|
24
|
+
}
|
|
25
|
+
function stickyChars(prev, chars, now, holdMs) {
|
|
26
|
+
if (!prev || chars >= prev.value) return { value: chars, since: now };
|
|
27
|
+
if (now - prev.since >= holdMs) return { value: chars, since: now };
|
|
28
|
+
return prev;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// src/format.ts
|
|
32
|
+
function formatTimestamp(iso, timeZone) {
|
|
33
|
+
if (!iso) return "";
|
|
34
|
+
const date = new Date(iso);
|
|
35
|
+
if (Number.isNaN(date.getTime())) return iso;
|
|
36
|
+
return timeZone ? date.toLocaleTimeString(void 0, { timeZone, timeZoneName: "short" }) : date.toLocaleTimeString();
|
|
37
|
+
}
|
|
38
|
+
function formatDateTime(iso, timeZone) {
|
|
39
|
+
if (!iso) return "";
|
|
40
|
+
const date = new Date(iso);
|
|
41
|
+
if (Number.isNaN(date.getTime())) return iso;
|
|
42
|
+
return timeZone ? date.toLocaleString(void 0, { timeZone, timeZoneName: "short" }) : date.toLocaleString();
|
|
43
|
+
}
|
|
44
|
+
var DEFAULT_FRACTION_DIGITS = 3;
|
|
45
|
+
var DEFAULT_SMALL_SIGNIFICANT = 4;
|
|
46
|
+
function defaultFormat(value) {
|
|
47
|
+
if (!Number.isFinite(value)) return String(value);
|
|
48
|
+
const rounded = Math.abs(value) >= 1 ? Number(value.toFixed(DEFAULT_FRACTION_DIGITS)) : Number(value.toPrecision(DEFAULT_SMALL_SIGNIFICANT));
|
|
49
|
+
return String(rounded);
|
|
50
|
+
}
|
|
51
|
+
function formatValue(value, precision) {
|
|
52
|
+
if (value == null) return "\u2014";
|
|
53
|
+
if (precision == null) return defaultFormat(value);
|
|
54
|
+
const places = Math.min(100, Math.max(0, Math.trunc(precision)));
|
|
55
|
+
return value.toFixed(places);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// src/thresholds.ts
|
|
59
|
+
function parseThresholds(raw) {
|
|
60
|
+
if (!Array.isArray(raw)) return [];
|
|
61
|
+
const out = [];
|
|
62
|
+
for (const item of raw) {
|
|
63
|
+
if (typeof item !== "object" || item === null) continue;
|
|
64
|
+
const { value, level, label } = item;
|
|
65
|
+
if (typeof value !== "number" || !Number.isFinite(value) || !isSeverityLevel(level)) continue;
|
|
66
|
+
out.push(typeof label === "string" && label !== "" ? { value, level, label } : { value, level });
|
|
67
|
+
}
|
|
68
|
+
return out.map((t, i) => ({ t, i })).sort((a, b) => a.t.value - b.t.value || a.i - b.i).map(({ t }) => t);
|
|
69
|
+
}
|
|
70
|
+
function optThresholds(options, key = "thresholds") {
|
|
71
|
+
return parseThresholds(options?.[key]);
|
|
72
|
+
}
|
|
73
|
+
function bandAt(thresholds, value) {
|
|
74
|
+
if (value == null || !Number.isFinite(value)) return void 0;
|
|
75
|
+
let hit;
|
|
76
|
+
for (const t of thresholds) {
|
|
77
|
+
if (value >= t.value) hit = t;
|
|
78
|
+
else break;
|
|
79
|
+
}
|
|
80
|
+
return hit;
|
|
81
|
+
}
|
|
82
|
+
function thresholdBands(thresholds, min, max) {
|
|
83
|
+
if (!(max > min)) return [];
|
|
84
|
+
const bands = [];
|
|
85
|
+
const push = (from, to, level, label) => {
|
|
86
|
+
const a = Math.max(from, min);
|
|
87
|
+
const b = Math.min(to, max);
|
|
88
|
+
if (b > a) bands.push(label === void 0 ? { from: a, to: b, level } : { from: a, to: b, level, label });
|
|
89
|
+
};
|
|
90
|
+
if (thresholds.length === 0) return [];
|
|
91
|
+
push(-Infinity, thresholds[0].value, void 0);
|
|
92
|
+
thresholds.forEach((t, i) => push(t.value, thresholds[i + 1]?.value ?? Infinity, t.level, t.label));
|
|
93
|
+
return bands;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export {
|
|
97
|
+
FIT_MIN_FONT_PX,
|
|
98
|
+
fitValueFont,
|
|
99
|
+
fitValueFontCss,
|
|
100
|
+
stickyChars,
|
|
101
|
+
formatTimestamp,
|
|
102
|
+
formatDateTime,
|
|
103
|
+
formatValue,
|
|
104
|
+
parseThresholds,
|
|
105
|
+
optThresholds,
|
|
106
|
+
bandAt,
|
|
107
|
+
thresholdBands
|
|
108
|
+
};
|
|
109
|
+
//# sourceMappingURL=chunk-IG6DBHKZ.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/fit-text.ts", "../../src/format.ts", "../../src/thresholds.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright The DeviceChain Authors\n// SPDX-License-Identifier: Apache-2.0\n\n// fitValueFont -- the one font-size curve for a big readout (a card's number, a KPI count, a\n// gauge's value). Every widget used to carry its own clamp of the card HEIGHT with a hard cap\n// (44 px, 56 px); that ignored the width, so a long string overflowed a wide-but-short or\n// narrow-but-tall box, and it stopped growing on a wall display. This curve reads both\n// dimensions and the string length.\n//\n// font = min( height * HEIGHT_SHARE , width / (chars * GLYPH_WIDTH) )\n//\n// then floored at MIN_FONT_PX. There is no upper cap: a bigger box gets a bigger number.\n//\n// `size` is the box the text may occupy, so a caller passes its content box (the measured\n// element minus its own padding). HEIGHT_SHARE leaves room for the line's leading and for a\n// secondary line (unit, caption) beneath it. GLYPH_WIDTH is the advance of a digit as a\n// fraction of the font size. Measured: system faces (Segoe UI, Roboto, Arial bold) set a\n// digit at 0.56-0.58 em, but the console's Inter sets them at 0.61-0.62 em on average and\n// 0.67 em at the widest in the 600-700 weights a readout uses. 0.65 covers Inter's digits to\n// within a few percent (which the caller's padding absorbs) without shrinking a system-font\n// number much; a '.' or '-' counted as a full character adds slack.\n\nexport const FIT_MIN_FONT_PX = 12;\n// What to use before the first measure (ElementSize is {0,0} until then) or in a non-DOM test.\nexport const FIT_FALLBACK_FONT_PX = 32;\n\n// The curve's two constants. Exported so the CSS path (fitValueFontCss, `cq` units) and the\n// JS path (fitValueFont, a canvas widget's numeric font) are built from THESE and cannot\n// drift: a number in a card and a number in a gauge of the same size look the same.\nexport const FIT_HEIGHT_SHARE = 0.6;\nexport const FIT_GLYPH_WIDTH = 0.65;\n\nexport interface FitOptions {\n // The smallest font the curve returns, in px. Density scales THIS (a wall display's floor is\n // larger, a compact board's smaller); the curve itself never changes. Default FIT_MIN_FONT_PX.\n floor?: number;\n}\n\nfunction charCount(chars: number): number {\n return Math.max(1, Math.ceil(Number.isFinite(chars) ? chars : 1));\n}\n\nexport function fitValueFont(size: { width: number; height: number }, chars: number, options: FitOptions = {}): number {\n const floor = options.floor ?? FIT_MIN_FONT_PX;\n if (!(size.width > 0) || !(size.height > 0)) return Math.max(floor, FIT_FALLBACK_FONT_PX);\n const byHeight = size.height * FIT_HEIGHT_SHARE;\n const byWidth = size.width / (charCount(chars) * FIT_GLYPH_WIDTH);\n return Math.max(floor, Math.floor(Math.min(byHeight, byWidth)));\n}\n\n// The same curve as a CSS length, for text inside a `container-type: size` box (the widget\n// frame's content column): `cqh`/`cqw` are that box's height and width, so the browser resolves\n// the font on the very first frame -- no {0,0} measure flash -- and re-resolves on every\n// resize with no JS. The box a caller passes to fitValueFont is the SAME box these units\n// measure (the frame's padded content column).\nexport function fitValueFontCss(chars: number, options: FitOptions = {}): string {\n const floor = options.floor ?? FIT_MIN_FONT_PX;\n const perChar = 100 / (charCount(chars) * FIT_GLYPH_WIDTH);\n return `max(${floor}px, min(${FIT_HEIGHT_SHARE * 100}cqh, ${Number(perChar.toFixed(3))}cqw))`;\n}\n\n// A big readout's character count held at the longest recently seen, so a value crossing\n// 9.99 -> 10.01 does not jump the font size by a character's worth (~20 % on a short\n// string). The count grows at once and shrinks only after `holdMs` with nothing longer.\nexport interface StickyChars {\n value: number;\n since: number;\n}\n\nexport function stickyChars(prev: StickyChars | undefined, chars: number, now: number, holdMs: number): StickyChars {\n if (!prev || chars >= prev.value) return { value: chars, since: now };\n if (now - prev.since >= holdMs) return { value: chars, since: now };\n return prev;\n}\n", "// Copyright The DeviceChain Authors\n// SPDX-License-Identifier: Apache-2.0\n\n// Both formatters take an optional IANA `timeZone`. Omitted, they are exactly what they\n// always were: the viewer's own zone and locale defaults, which is right for a live board.\n// A host that plays a RECORDING pins one (the renderer's `timeZone` prop), because the\n// recorded instants are the point and a viewer's zone would shift them across a date line;\n// a pinned zone also prints its short name, so the reading says which clock it is.\n\n// formatTimestamp renders an RFC3339 event time as a locale time string, leaving\n// an unparseable value untouched and an absent one blank.\nexport function formatTimestamp(iso: string | null, timeZone?: string): string {\n if (!iso) return '';\n const date = new Date(iso);\n if (Number.isNaN(date.getTime())) return iso;\n return timeZone ? date.toLocaleTimeString(undefined, { timeZone, timeZoneName: 'short' }) : date.toLocaleTimeString();\n}\n\n// formatDateTime renders an RFC3339 time as a locale date+time string. Unlike\n// formatTimestamp (time-only, right for a live measurement tick) this keeps the date,\n// because an alarm can have been raised days ago and a bare \"09:14:32\" would mislead.\nexport function formatDateTime(iso: string | null, timeZone?: string): string {\n if (!iso) return '';\n const date = new Date(iso);\n if (Number.isNaN(date.getTime())) return iso;\n return timeZone ? date.toLocaleString(undefined, { timeZone, timeZoneName: 'short' }) : date.toLocaleString();\n}\n\n// With no precision configured a value is still not printed at full float width: a sensor's\n// 30.203057033956792 is noise on a card, a gauge or an alarm row. So an unset precision shows\n// at most DEFAULT_FRACTION_DIGITS decimals (trailing zeros dropped), and a value under 1 keeps\n// DEFAULT_SMALL_SIGNIFICANT significant digits instead, so a 0.000123 reading is not rounded\n// to nothing. An author who wants exact decimals sets `precision`.\nexport const DEFAULT_FRACTION_DIGITS = 3;\nexport const DEFAULT_SMALL_SIGNIFICANT = 4;\n\nfunction defaultFormat(value: number): string {\n if (!Number.isFinite(value)) return String(value);\n const rounded =\n Math.abs(value) >= 1 ? Number(value.toFixed(DEFAULT_FRACTION_DIGITS)) : Number(value.toPrecision(DEFAULT_SMALL_SIGNIFICANT));\n return String(rounded);\n}\n\n// formatValue renders a measurement value, applying a fixed precision when given\n// (else the default rounding above) and showing an em dash for a missing value.\n//\n// The precision is clamped to toFixed's domain because it arrives from an opaque stored\n// definition: outside 0..100 toFixed throws a RangeError, which is an exception thrown\n// during render \u2014 it unmounts the widget's whole subtree rather than degrading, and every\n// other bad option value in this package degrades. The console's config panel can author\n// a negative one today, and a hand-edited definition always could.\nexport function formatValue(value: number | null | undefined, precision?: number): string {\n if (value == null) return '\u2014';\n if (precision == null) return defaultFormat(value);\n const places = Math.min(100, Math.max(0, Math.trunc(precision)));\n return value.toFixed(places);\n}\n", "// Copyright The DeviceChain Authors\n// SPDX-License-Identifier: Apache-2.0\n\n// Thresholds: where a measurement crosses from one severity to the next.\n//\n// A threshold STARTS a band: it holds from its `value` up to the next threshold's value (or\n// without end, for the last). Below the lowest threshold there is no band, so a value there\n// reads in the widget's own neutral colour, as does a value in a `normal` band (normal has no\n// colour; see severity.ts), so a healthy value looks the same under either kind of rule.\n// This one rule covers both directions:\n// - \"overheat above 105\" -> [{ value: 105, level: 'critical' }]\n// - \"low fuel below 15\" -> [{ value: 0, level: 'critical' }, { value: 15, level: 'normal' }]\n// A value ON a threshold belongs to the band that threshold starts (>=), never the one below.\n\nimport { isSeverityLevel, type SeverityLevel } from './severity';\n\nexport interface Threshold {\n value: number;\n level: SeverityLevel;\n label?: string;\n}\n\n// A band resolved over a numeric range. `level` is undefined for the neutral stretch below the\n// lowest threshold. `to` is Infinity for the last band.\nexport interface ThresholdBand {\n from: number;\n to: number;\n level: SeverityLevel | undefined;\n label?: string;\n}\n\n// parseThresholds reads the stored option defensively: a hand-edited definition may carry\n// anything, and a threshold that cannot be read must drop out rather than throw during render\n// (or, worse, colour a value by a guess). Only a finite `value` and a known `level` survive --\n// so a free colour in the `level` slot is dropped, and an extra `color` key is never read.\n// The result is sorted ascending by value (stable, so equal values keep their authored order\n// and the later one wins).\nexport function parseThresholds(raw: unknown): Threshold[] {\n if (!Array.isArray(raw)) return [];\n const out: Threshold[] = [];\n for (const item of raw) {\n if (typeof item !== 'object' || item === null) continue;\n const { value, level, label } = item as Record<string, unknown>;\n if (typeof value !== 'number' || !Number.isFinite(value) || !isSeverityLevel(level)) continue;\n out.push(typeof label === 'string' && label !== '' ? { value, level, label } : { value, level });\n }\n return out.map((t, i) => ({ t, i })).sort((a, b) => a.t.value - b.t.value || a.i - b.i).map(({ t }) => t);\n}\n\nexport function optThresholds(options: Record<string, unknown> | undefined, key = 'thresholds'): Threshold[] {\n return parseThresholds(options?.[key]);\n}\n\n// bandAt returns the threshold whose band holds `value`, or undefined below the lowest.\n// `thresholds` must be sorted (parseThresholds does). A null value has no band.\nexport function bandAt(thresholds: readonly Threshold[], value: number | null | undefined): Threshold | undefined {\n if (value == null || !Number.isFinite(value)) return undefined;\n let hit: Threshold | undefined;\n for (const t of thresholds) {\n if (value >= t.value) hit = t;\n else break;\n }\n return hit;\n}\n\n// thresholdBands lays the bands over [min, max]: a neutral lead-in up to the first threshold,\n// then one band per threshold, each clipped to the range. Bands that fall wholly outside the\n// range are dropped, and the band in effect AT `min` is carried in from a threshold below it.\n// The result tiles [min, max] exactly, which is what a gauge arc needs.\nexport function thresholdBands(thresholds: readonly Threshold[], min: number, max: number): ThresholdBand[] {\n if (!(max > min)) return [];\n const bands: ThresholdBand[] = [];\n const push = (from: number, to: number, level: SeverityLevel | undefined, label?: string) => {\n const a = Math.max(from, min);\n const b = Math.min(to, max);\n if (b > a) bands.push(label === undefined ? { from: a, to: b, level } : { from: a, to: b, level, label });\n };\n if (thresholds.length === 0) return [];\n push(-Infinity, thresholds[0].value, undefined);\n thresholds.forEach((t, i) => push(t.value, thresholds[i + 1]?.value ?? Infinity, t.level, t.label));\n return bands;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;AAsBO,IAAM,kBAAkB;AAExB,IAAM,uBAAuB;AAK7B,IAAM,mBAAmB;AACzB,IAAM,kBAAkB;AAQ/B,SAAS,UAAU,OAAuB;AACxC,SAAO,KAAK,IAAI,GAAG,KAAK,KAAK,OAAO,SAAS,KAAK,IAAI,QAAQ,CAAC,CAAC;AAClE;AAEO,SAAS,aAAa,MAAyC,OAAe,UAAsB,CAAC,GAAW;AACrH,QAAM,QAAQ,QAAQ,SAAS;AAC/B,MAAI,EAAE,KAAK,QAAQ,MAAM,EAAE,KAAK,SAAS,GAAI,QAAO,KAAK,IAAI,OAAO,oBAAoB;AACxF,QAAM,WAAW,KAAK,SAAS;AAC/B,QAAM,UAAU,KAAK,SAAS,UAAU,KAAK,IAAI;AACjD,SAAO,KAAK,IAAI,OAAO,KAAK,MAAM,KAAK,IAAI,UAAU,OAAO,CAAC,CAAC;AAChE;AAOO,SAAS,gBAAgB,OAAe,UAAsB,CAAC,GAAW;AAC/E,QAAM,QAAQ,QAAQ,SAAS;AAC/B,QAAM,UAAU,OAAO,UAAU,KAAK,IAAI;AAC1C,SAAO,OAAO,KAAK,WAAW,mBAAmB,GAAG,QAAQ,OAAO,QAAQ,QAAQ,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AAY,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,MAAM,CAAC;AAAA,EAC1G;AACA,MAAI,WAAW,WAAW,EAAG,QAAO,CAAC;AACrC,OAAK,WAAW,WAAW,CAAC,EAAE,OAAO,MAAS;AAC9C,aAAW,QAAQ,CAAC,GAAG,MAAM,KAAK,EAAE,OAAO,WAAW,IAAI,CAAC,GAAG,SAAS,UAAU,EAAE,OAAO,EAAE,KAAK,CAAC;AAClG,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import {
|
|
2
|
+
severityTokenCss
|
|
3
|
+
} from "./chunk-G6I5HKQM.js";
|
|
4
|
+
|
|
5
|
+
// src/widget-options.ts
|
|
6
|
+
function pickSample(latest, name) {
|
|
7
|
+
return name ? latest[name] : Object.values(latest)[0];
|
|
8
|
+
}
|
|
9
|
+
function optString(options, key) {
|
|
10
|
+
const value = options?.[key];
|
|
11
|
+
return typeof value === "string" ? value : void 0;
|
|
12
|
+
}
|
|
13
|
+
function optNumber(options, key) {
|
|
14
|
+
const value = options?.[key];
|
|
15
|
+
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
16
|
+
}
|
|
17
|
+
function optBoolean(options, key) {
|
|
18
|
+
return options?.[key] === true;
|
|
19
|
+
}
|
|
20
|
+
function primaryMeasurementName(widget) {
|
|
21
|
+
const explicit = optString(widget.options, "measurement");
|
|
22
|
+
if (explicit) return explicit;
|
|
23
|
+
const ds = widget.datasource;
|
|
24
|
+
if (ds?.measurements && ds.measurements.length > 0) return ds.measurements[0];
|
|
25
|
+
return void 0;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// src/freshness.ts
|
|
29
|
+
function resolveStaleAfterSeconds(options) {
|
|
30
|
+
const configured = optNumber(options, "staleAfterSeconds");
|
|
31
|
+
return configured !== void 0 && configured > 0 ? configured : void 0;
|
|
32
|
+
}
|
|
33
|
+
function newestSampleTime(latest, names) {
|
|
34
|
+
let newest;
|
|
35
|
+
for (const [name, sample] of Object.entries(latest)) {
|
|
36
|
+
if (names && names.length > 0 && !names.includes(name)) continue;
|
|
37
|
+
if (!sample.occurredTime) continue;
|
|
38
|
+
const at = Date.parse(sample.occurredTime);
|
|
39
|
+
if (Number.isNaN(at)) continue;
|
|
40
|
+
if (newest === void 0 || at > newest) newest = at;
|
|
41
|
+
}
|
|
42
|
+
return newest;
|
|
43
|
+
}
|
|
44
|
+
function ageSeconds(at, now) {
|
|
45
|
+
return Math.max(0, Math.floor((now - at) / 1e3));
|
|
46
|
+
}
|
|
47
|
+
function isStale(age, staleAfter) {
|
|
48
|
+
return staleAfter !== void 0 && age > staleAfter;
|
|
49
|
+
}
|
|
50
|
+
function viewerLocale() {
|
|
51
|
+
if (typeof document !== "undefined" && document.documentElement.lang) return document.documentElement.lang;
|
|
52
|
+
if (typeof navigator !== "undefined" && navigator.language) return navigator.language;
|
|
53
|
+
return void 0;
|
|
54
|
+
}
|
|
55
|
+
var formatters = /* @__PURE__ */ new Map();
|
|
56
|
+
function relativeTimeFormat(locale) {
|
|
57
|
+
const key = locale ?? "";
|
|
58
|
+
let formatter = formatters.get(key);
|
|
59
|
+
if (!formatter) {
|
|
60
|
+
try {
|
|
61
|
+
formatter = new Intl.RelativeTimeFormat(locale, { numeric: "auto", style: "short" });
|
|
62
|
+
} catch {
|
|
63
|
+
formatter = new Intl.RelativeTimeFormat(void 0, { numeric: "auto", style: "short" });
|
|
64
|
+
}
|
|
65
|
+
formatters.set(key, formatter);
|
|
66
|
+
}
|
|
67
|
+
return formatter;
|
|
68
|
+
}
|
|
69
|
+
function formatAge(age, locale = viewerLocale()) {
|
|
70
|
+
const formatter = relativeTimeFormat(locale);
|
|
71
|
+
if (age < 60) return formatter.format(-age, "second");
|
|
72
|
+
if (age < 3600) return formatter.format(-Math.floor(age / 60), "minute");
|
|
73
|
+
if (age < 86400) return formatter.format(-Math.floor(age / 3600), "hour");
|
|
74
|
+
return formatter.format(-Math.floor(age / 86400), "day");
|
|
75
|
+
}
|
|
76
|
+
var FRESHNESS_STRINGS = {
|
|
77
|
+
en: { stale: "stale", ageLabel: "Last sample" },
|
|
78
|
+
es: { stale: "obsoleto", ageLabel: "\xDAltima muestra" }
|
|
79
|
+
};
|
|
80
|
+
function freshnessStrings(locale = viewerLocale()) {
|
|
81
|
+
const base = locale?.toLowerCase().split("-")[0];
|
|
82
|
+
return base === "es" ? FRESHNESS_STRINGS.es : FRESHNESS_STRINGS.en;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// src/theme.ts
|
|
86
|
+
function css(name) {
|
|
87
|
+
return `hsl(var(--${name}))`;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// src/tokens.tsx
|
|
91
|
+
import { DENSITY_SCALE, SPACE_TOKEN_PX } from "@devicechain/dashboards";
|
|
92
|
+
import { jsx } from "react/jsx-runtime";
|
|
93
|
+
var FONT_TOKENS = {
|
|
94
|
+
xs: 11,
|
|
95
|
+
sm: 12,
|
|
96
|
+
md: 13,
|
|
97
|
+
lg: 16,
|
|
98
|
+
xl: 20,
|
|
99
|
+
display: 28
|
|
100
|
+
};
|
|
101
|
+
var SPACE_TOKENS = {
|
|
102
|
+
1: SPACE_TOKEN_PX["space-1"],
|
|
103
|
+
2: SPACE_TOKEN_PX["space-2"],
|
|
104
|
+
3: SPACE_TOKEN_PX["space-3"],
|
|
105
|
+
4: SPACE_TOKEN_PX["space-4"]
|
|
106
|
+
};
|
|
107
|
+
function densityScale(density) {
|
|
108
|
+
return DENSITY_SCALE[density ?? "comfortable"];
|
|
109
|
+
}
|
|
110
|
+
function fontVar(token) {
|
|
111
|
+
return `var(--dc-font-${token}, ${FONT_TOKENS[token]}px)`;
|
|
112
|
+
}
|
|
113
|
+
function spaceVar(token) {
|
|
114
|
+
return `var(--dc-space-${token}, ${SPACE_TOKENS[token]}px)`;
|
|
115
|
+
}
|
|
116
|
+
function tokenPx(token, scale = 1) {
|
|
117
|
+
const [kind, name] = token.split("-");
|
|
118
|
+
const base = kind === "font" ? FONT_TOKENS[name] : SPACE_TOKENS[Number(name)];
|
|
119
|
+
return Math.round(base * scale * 100) / 100;
|
|
120
|
+
}
|
|
121
|
+
function tokenStyle(scale) {
|
|
122
|
+
const vars = { "--dc-scale": String(scale) };
|
|
123
|
+
for (const [name, px] of Object.entries(FONT_TOKENS)) vars[`--dc-font-${name}`] = `calc(${px}px * var(--dc-scale))`;
|
|
124
|
+
for (const [name, px] of Object.entries(SPACE_TOKENS)) vars[`--dc-space-${name}`] = `calc(${px}px * var(--dc-scale))`;
|
|
125
|
+
return vars;
|
|
126
|
+
}
|
|
127
|
+
function WidgetTokenStyles() {
|
|
128
|
+
return /* @__PURE__ */ jsx("style", { "data-dc-tokens": "", children: severityTokenCss({ hostWins: true }) });
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export {
|
|
132
|
+
pickSample,
|
|
133
|
+
optString,
|
|
134
|
+
optNumber,
|
|
135
|
+
optBoolean,
|
|
136
|
+
primaryMeasurementName,
|
|
137
|
+
resolveStaleAfterSeconds,
|
|
138
|
+
newestSampleTime,
|
|
139
|
+
ageSeconds,
|
|
140
|
+
isStale,
|
|
141
|
+
viewerLocale,
|
|
142
|
+
formatAge,
|
|
143
|
+
freshnessStrings,
|
|
144
|
+
css,
|
|
145
|
+
FONT_TOKENS,
|
|
146
|
+
SPACE_TOKENS,
|
|
147
|
+
densityScale,
|
|
148
|
+
fontVar,
|
|
149
|
+
spaceVar,
|
|
150
|
+
tokenPx,
|
|
151
|
+
tokenStyle,
|
|
152
|
+
WidgetTokenStyles
|
|
153
|
+
};
|
|
154
|
+
//# sourceMappingURL=chunk-PECV5KDV.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/widget-options.ts", "../../src/freshness.ts", "../../src/theme.ts", "../../src/tokens.tsx"],
|
|
4
|
+
"sourcesContent": ["// Copyright The DeviceChain Authors\n// SPDX-License-Identifier: Apache-2.0\n\n// Small helpers for reading a widget's opaque `options` bag and picking the measurement a\n// single-value widget should show. They are the SDK's, not the built-ins': a third-party\n// widget reads its own options the same defensive way.\n\nimport type { MeasurementSample, WidgetInstance } from '@devicechain/dashboards';\n\n// pickSample chooses the sample a single-value widget (card, gauge) shows: the\n// named measurement, or the first available when no name is pinned.\nexport function pickSample(\n latest: Record<string, MeasurementSample>,\n name: string | undefined,\n): MeasurementSample | undefined {\n return name ? latest[name] : Object.values(latest)[0];\n}\n\n// --- options helpers ---------------------------------------------------------\n// A widget's `options` is opaque JSON (Record<string, unknown>) owned by the\n// widget; these read a key defensively, returning undefined on the wrong type\n// rather than throwing on a hand-edited definition.\n\ntype Options = Record<string, unknown> | undefined;\n\nexport function optString(options: Options, key: string): string | undefined {\n const value = options?.[key];\n return typeof value === 'string' ? value : undefined;\n}\n\nexport function optNumber(options: Options, key: string): number | undefined {\n const value = options?.[key];\n return typeof value === 'number' && Number.isFinite(value) ? value : undefined;\n}\n\n// A boolean flag option: true only when explicitly stored true (absent/other \u2192 false), so\n// an opt-in feature stays off by default and a hand-edited value can't accidentally enable it.\nexport function optBoolean(options: Options, key: string): boolean {\n return options?.[key] === true;\n}\n\n// primaryMeasurementName is the measurement a single-value widget (card, gauge)\n// displays: an explicit `options.measurement`, else the first measurement its\n// datasource selects, else undefined (fall back to whatever arrives first).\nexport function primaryMeasurementName(widget: WidgetInstance): string | undefined {\n const explicit = optString(widget.options, 'measurement');\n if (explicit) return explicit;\n const ds = widget.datasource;\n if (ds?.measurements && ds.measurements.length > 0) return ds.measurements[0];\n return undefined;\n}\n", "// Copyright The DeviceChain Authors\n// SPDX-License-Identifier: Apache-2.0\n\n// How old a widget's newest sample is, whether that is \"stale\", and how to say so. Pure, so\n// the precedence and the wording are testable without a DOM or a clock.\n\nimport type { MeasurementSample } from '@devicechain/dashboards';\n\nimport { optNumber } from './widget-options';\n\n// resolveStaleAfterSeconds is the age, in seconds, past which a widget's value is called stale,\n// or undefined when no honest threshold is known. Precedence:\n//\n// 1. the widget's own `staleAfterSeconds` option;\n// 2. (no source today) the device profile's expected reporting interval x 3 -- a profile\n// carries no measurement reporting interval at present, only a location-fix interval that\n// is documented as descriptive, so nothing is read here and nothing is invented;\n// 3. otherwise undefined: show the age, never style anything stale.\n//\n// \uD83D\uDD34 There is deliberately NO default. A fleet that reports hourly would be painted stale all\n// day by any number chosen here, and \"stale\" painted on healthy data teaches viewers to ignore\n// the badge. A non-positive value is not a threshold and counts as none.\nexport function resolveStaleAfterSeconds(options: Record<string, unknown> | undefined): number | undefined {\n const configured = optNumber(options, 'staleAfterSeconds');\n return configured !== undefined && configured > 0 ? configured : undefined;\n}\n\n// newestSampleTime is the latest occurredTime (epoch ms) among the named measurements' latest\n// samples, or undefined when none carries a parseable time. `names` empty or omitted means\n// every measurement the widget holds.\nexport function newestSampleTime(\n latest: Record<string, MeasurementSample>,\n names?: readonly string[],\n): number | undefined {\n let newest: number | undefined;\n for (const [name, sample] of Object.entries(latest)) {\n if (names && names.length > 0 && !names.includes(name)) continue;\n if (!sample.occurredTime) continue;\n const at = Date.parse(sample.occurredTime);\n if (Number.isNaN(at)) continue;\n if (newest === undefined || at > newest) newest = at;\n }\n return newest;\n}\n\n// ageSeconds is whole seconds since `at`, never negative: a device clock slightly ahead of the\n// viewer's would otherwise read \"in 3 seconds\".\nexport function ageSeconds(at: number, now: number): number {\n return Math.max(0, Math.floor((now - at) / 1000));\n}\n\n// isStale is true only when a threshold is known and the age has passed it.\nexport function isStale(age: number, staleAfter: number | undefined): boolean {\n return staleAfter !== undefined && age > staleAfter;\n}\n\n// The viewer's language, as the host app set it on <html lang>, else the browser's.\nexport function viewerLocale(): string | undefined {\n if (typeof document !== 'undefined' && document.documentElement.lang) return document.documentElement.lang;\n if (typeof navigator !== 'undefined' && navigator.language) return navigator.language;\n return undefined;\n}\n\n// One formatter per locale tag: every readout on a board re-formats once a second, and\n// building an Intl formatter is far dearer than using one.\nconst formatters = new Map<string, Intl.RelativeTimeFormat>();\n\nfunction relativeTimeFormat(locale: string | undefined): Intl.RelativeTimeFormat {\n const key = locale ?? '';\n let formatter = formatters.get(key);\n if (!formatter) {\n try {\n formatter = new Intl.RelativeTimeFormat(locale, { numeric: 'auto', style: 'short' });\n } catch {\n // An unparseable tag in <html lang> must not take a widget down: the runtime's default.\n formatter = new Intl.RelativeTimeFormat(undefined, { numeric: 'auto', style: 'short' });\n }\n formatters.set(key, formatter);\n }\n return formatter;\n}\n\n// formatAge renders an age as \"12 sec. ago\" / \"hace 12 s\" in the viewer's locale, stepping up\n// to minutes, hours and days. Under a second it reads \"now\".\nexport function formatAge(age: number, locale: string | undefined = viewerLocale()): string {\n const formatter = relativeTimeFormat(locale);\n if (age < 60) return formatter.format(-age, 'second');\n if (age < 3600) return formatter.format(-Math.floor(age / 60), 'minute');\n if (age < 86400) return formatter.format(-Math.floor(age / 3600), 'hour');\n return formatter.format(-Math.floor(age / 86400), 'day');\n}\n\n// The SDK carries no i18n runtime, so the one word it adds to a board ships here, per\n// language, falling back to English. A host that wants another language passes `staleLabel`.\nexport interface FreshnessStrings {\n stale: string;\n ageLabel: string;\n}\n\nexport const FRESHNESS_STRINGS: Record<'en' | 'es', FreshnessStrings> = {\n en: { stale: 'stale', ageLabel: 'Last sample' },\n es: { stale: 'obsoleto', ageLabel: '\u00DAltima muestra' },\n};\n\nexport function freshnessStrings(locale: string | undefined = viewerLocale()): FreshnessStrings {\n const base = locale?.toLowerCase().split('-')[0];\n return base === 'es' ? FRESHNESS_STRINGS.es : FRESHNESS_STRINGS.en;\n}\n", "// Copyright The DeviceChain Authors\n// SPDX-License-Identifier: Apache-2.0\n\n// Theming without Tailwind (widgets are embeddable \u2014 no Tailwind leakage).\n//\n// Widgets style themselves with inline styles that reference the SAME CSS custom\n// properties the console (and any host) defines \u2014 `--card`, `--foreground`,\n// `--border`, `--chart-1..5`, etc. A host that sets those variables themes the\n// widgets for free (light/dark included); a host without Tailwind still works.\n//\n// DOM elements can use `hsl(var(--card))` directly. ECharts renders to a <canvas>,\n// which cannot resolve CSS variables \u2014 so for charts we read the variables off the\n// live computed style and hand ECharts concrete color strings (resolveChartTheme).\n\nimport type { ThemeColorToken } from '@devicechain/dashboards';\n\n// css returns an `hsl(var(--name))` reference for use in an inline style. The host\n// defines the variable as HSL channels (e.g. `--card: 0 0% 100%`), matching the\n// console's token set.\nexport function css(name: ThemeVar): string {\n return `hsl(var(--${name}))`;\n}\n\n// The subset of the console's design tokens widgets rely on. Kept small and\n// semantic so the contract a host must provide is explicit and stable.\n//\n// Colours only: sizes are SizeTokens (see ./tokens). The chart ramp and the severity hues are\n// part of the set, so a widget colours itself from a token rather than a literal; `normal` has\n// NO severity token (it renders in the ordinary foreground, see ./severity).\n//\n// The list itself lives with the dashboard format (THEME_COLOR_TOKENS), because a definition\n// names these too, for a frame's border and background: one list, so a colour a widget can use\n// is exactly a colour a board may name.\nexport type ThemeVar = ThemeColorToken;\n", "// Copyright The DeviceChain Authors\n// SPDX-License-Identifier: Apache-2.0\n\n// Size tokens: the type ramp and spacing steps a widget draws from instead of writing px\n// literals, and the density scale they all multiply by.\n//\n// --dc-scale the board's density scale (0.9 compact / 1 comfortable / 1.5 wall)\n// --dc-font-<xs|sm|md|lg|xl|display> calc(<base px> * var(--dc-scale))\n// --dc-space-<1..4> calc(<base px> * var(--dc-scale))\n//\n// The `dc-` prefix is load-bearing: these are set on a board that lives inside someone else's\n// page, and the bare names collide -- Tailwind v4 keeps font FAMILIES in `--font-*` (a host's\n// `--font-display: \"Inter\"` is its documented example), so `var(--font-display, 28px)` in such\n// a host resolves to a family name and the font size is thrown away.\n//\n// The renderer sets them on its root (tokenStyle), so every widget under it scales with the\n// board's density; `fontVar('md')` is `var(--dc-font-md, 13px)`, which still renders the base\n// size anywhere the tokens are not set (a host that mounts a bare WidgetFrame). Canvas widgets\n// cannot read a CSS variable and take the numeric equivalent from useWidgetScale().px().\n//\n// Colour tokens are the ThemeVar set in ./theme; the severity hues are generated from the\n// table in ./severity (WidgetTokenStyles below injects them), so no colour is typed twice.\n\nimport { DENSITY_SCALE, SPACE_TOKEN_PX, type CanvasDensity } from '@devicechain/dashboards';\nimport type { CSSProperties } from 'react';\n\nimport { severityTokenCss } from './severity';\n\nexport const FONT_TOKENS = {\n xs: 11,\n sm: 12,\n md: 13,\n lg: 16,\n xl: 20,\n display: 28,\n} as const;\nexport type FontToken = keyof typeof FONT_TOKENS;\n\n// The spacing steps a widget draws from, read from the dashboard format's table (which also has\n// `space-0`, for a seamless board's gutter and a frameless widget's padding).\nexport const SPACE_TOKENS = {\n 1: SPACE_TOKEN_PX['space-1'],\n 2: SPACE_TOKEN_PX['space-2'],\n 3: SPACE_TOKEN_PX['space-3'],\n 4: SPACE_TOKEN_PX['space-4'],\n} as const;\nexport type SpaceToken = keyof typeof SPACE_TOKENS;\n\n// 'font-md' | 'space-3' -- the names useWidgetScale().px() accepts.\nexport type SizeToken = `font-${FontToken}` | `space-${SpaceToken}`;\n\nexport function densityScale(density: CanvasDensity | undefined): number {\n return DENSITY_SCALE[density ?? 'comfortable'];\n}\n\nexport function fontVar(token: FontToken): string {\n return `var(--dc-font-${token}, ${FONT_TOKENS[token]}px)`;\n}\n\nexport function spaceVar(token: SpaceToken): string {\n return `var(--dc-space-${token}, ${SPACE_TOKENS[token]}px)`;\n}\n\n// The numeric px of a size token at a scale, for a canvas that cannot read the variable.\nexport function tokenPx(token: SizeToken, scale = 1): number {\n const [kind, name] = token.split('-') as ['font' | 'space', string];\n const base = kind === 'font' ? FONT_TOKENS[name as FontToken] : SPACE_TOKENS[Number(name) as SpaceToken];\n return Math.round(base * scale * 100) / 100;\n}\n\n// The custom properties a board root sets for a density scale.\nexport function tokenStyle(scale: number): CSSProperties {\n const vars: Record<string, string> = { '--dc-scale': String(scale) };\n for (const [name, px] of Object.entries(FONT_TOKENS)) vars[`--dc-font-${name}`] = `calc(${px}px * var(--dc-scale))`;\n for (const [name, px] of Object.entries(SPACE_TOKENS)) vars[`--dc-space-${name}`] = `calc(${px}px * var(--dc-scale))`;\n return vars as CSSProperties;\n}\n\n// The severity hues as a stylesheet at ZERO specificity (`:where`), so a host that defines\n// `--sev-<level>` itself (any ordinary `:root` / `.dark` rule) always wins and a host that\n// does not still gets the colours. They sit on the document root, where useSeverityColors\n// reads them -- nothing is scoped to a board element, so no WidgetThemeRoot registration is\n// needed for them to resolve.\nexport function WidgetTokenStyles() {\n return <style data-dc-tokens=\"\">{severityTokenCss({ hostWins: true })}</style>;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;AAWO,SAAS,WACd,QACA,MAC+B;AAC/B,SAAO,OAAO,OAAO,IAAI,IAAI,OAAO,OAAO,MAAM,EAAE,CAAC;AACtD;AASO,SAAS,UAAU,SAAkB,KAAiC;AAC3E,QAAM,QAAQ,UAAU,GAAG;AAC3B,SAAO,OAAO,UAAU,WAAW,QAAQ;AAC7C;AAEO,SAAS,UAAU,SAAkB,KAAiC;AAC3E,QAAM,QAAQ,UAAU,GAAG;AAC3B,SAAO,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK,IAAI,QAAQ;AACvE;AAIO,SAAS,WAAW,SAAkB,KAAsB;AACjE,SAAO,UAAU,GAAG,MAAM;AAC5B;AAKO,SAAS,uBAAuB,QAA4C;AACjF,QAAM,WAAW,UAAU,OAAO,SAAS,aAAa;AACxD,MAAI,SAAU,QAAO;AACrB,QAAM,KAAK,OAAO;AAClB,MAAI,IAAI,gBAAgB,GAAG,aAAa,SAAS,EAAG,QAAO,GAAG,aAAa,CAAC;AAC5E,SAAO;AACT;;;AC5BO,SAAS,yBAAyB,SAAkE;AACzG,QAAM,aAAa,UAAU,SAAS,mBAAmB;AACzD,SAAO,eAAe,UAAa,aAAa,IAAI,aAAa;AACnE;AAKO,SAAS,iBACd,QACA,OACoB;AACpB,MAAI;AACJ,aAAW,CAAC,MAAM,MAAM,KAAK,OAAO,QAAQ,MAAM,GA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