@devicechain/widget-sdk 0.0.0-bootstrap.0 → 0.0.0-stage

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 CHANGED
@@ -1,84 +1,3 @@
1
- <!--
2
- Copyright The DeviceChain Authors
3
- SPDX-License-Identifier: Apache-2.0
4
- -->
1
+ # Temporary Holding Version
5
2
 
6
- # @devicechain/widget-sdk
7
-
8
- The typed contract for writing a DeviceChain dashboard widget as a React component, and the
9
- sealed registry that makes it available to a host application. The built-in widgets are
10
- declared through exactly this interface.
11
-
12
- ```bash
13
- npm install @devicechain/widget-sdk @devicechain/dashboards react
14
- ```
15
-
16
- `@devicechain/dashboards` and `react` are **peer dependencies**: the SDK defines the React
17
- contexts a widget reads (selection, candidate lookup, time zone, theme root), and a context is
18
- identified by the object that created it, so every widget package and the host must resolve
19
- the same single copy of this package. Declare it as a peer in your own widget package too,
20
- never as a dependency.
21
-
22
- ## What is in the box
23
-
24
- The root entry is chart-free and map-free: the card frame (`WidgetFrame`), theme-variable
25
- references (`css`), formatters, the change-flash cue, option readers (`optString`,
26
- `optNumber`, ...) and the React hooks that bind a hub channel to widget state. A widget
27
- that only draws DOM imports from here and pulls in neither Apache ECharts nor MapLibre nor
28
- the built-in widgets.
29
-
30
- Chart helpers live on a separate entry, `@devicechain/widget-sdk/echarts`: the `EChart`
31
- wrapper, `buildLineOption` / `buildGaugeOption` and the chart colour theme. `echarts` is an
32
- **optional peer dependency**, needed only by a widget that imports that entry.
33
-
34
- ## Declare a widget
35
-
36
- ```tsx
37
- import { defineWidget } from '@devicechain/widget-sdk';
38
-
39
- export const tankLevelWidget = defineWidget({
40
- descriptor: {
41
- id: 'acme/tank-level',
42
- version: '1.0.0',
43
- sdkApiVersion: 1,
44
- optionsVersion: 1,
45
- display: { title: 'Tank level', category: 'Telemetry' },
46
- channel: 'measurement',
47
- datasource: { mode: 'required', selectors: ['device', 'slot'] },
48
- binding: { window: { option: 'window', min: 1 } },
49
- options: {
50
- unit: { kind: 'string', doc: 'Unit shown beside the level.' },
51
- window: { kind: 'number', integer: true, min: 1, doc: 'Samples retained.' },
52
- },
53
- defaults: { unit: '%' },
54
- interactions: {},
55
- },
56
- implementation: {
57
- kind: 'trusted-react',
58
- // `data` is typed from the channel: a measurement widget receives measurement data.
59
- component: ({ data }) => <span>{Object.values(data.latest)[0]?.value}</span>,
60
- },
61
- });
62
- ```
63
-
64
- The descriptor is plain JSON-serializable data: no component, callback or URL. A descriptor
65
- that disagrees with its channel, or whose defaults or bindings disagree with its option
66
- schema, fails type checking, and `createWidgetRegistry` checks the same rules again at
67
- runtime.
68
-
69
- ## Register it
70
-
71
- ```ts
72
- import { createWidgetRegistry } from '@devicechain/widget-sdk';
73
-
74
- const registry = createWidgetRegistry([tankLevelWidget]);
75
- ```
76
-
77
- A registry is validated and sealed when it is created: duplicate ids, malformed descriptors,
78
- an unsupported `sdkApiVersion` and invalid bindings or defaults are all reported together in
79
- one `WidgetRegistryError`. There is no global registration; two registries on one page are
80
- independent. Extension ids are namespaced (`scope/name`); the un-namespaced ids are reserved
81
- for the built-in widgets.
82
-
83
- Trusted widget code runs with the host page's privileges. The declarations in a descriptor
84
- shape the API; they are not a security boundary.
3
+ This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
package/package.json CHANGED
@@ -1,76 +1,6 @@
1
1
  {
2
2
  "name": "@devicechain/widget-sdk",
3
- "version": "0.0.0-bootstrap.0",
4
- "description": "The DeviceChain widget SDK: the typed contract for writing a dashboard widget as a React component, and the sealed registry that makes it available to a host. Declare a widget once (portable descriptor plus trusted component) and register it beside the built-ins.",
5
- "keywords": [
6
- "devicechain",
7
- "iot",
8
- "dashboard",
9
- "widget",
10
- "sdk",
11
- "registry",
12
- "react",
13
- "echarts"
14
- ],
15
- "license": "Apache-2.0",
16
- "homepage": "https://devicechain.io",
17
- "repository": {
18
- "type": "git",
19
- "url": "git+https://github.com/devicechain-io/devicechain.git",
20
- "directory": "frontend/packages/widget-sdk"
21
- },
22
- "bugs": {
23
- "url": "https://github.com/devicechain-io/devicechain/issues"
24
- },
25
- "type": "module",
26
- "main": "./dist/index.js",
27
- "types": "./dist/index.d.ts",
28
- "exports": {
29
- ".": {
30
- "types": "./dist/index.d.ts",
31
- "import": "./dist/index.js"
32
- },
33
- "./echarts": {
34
- "types": "./dist/echarts.d.ts",
35
- "import": "./dist/echarts.js"
36
- },
37
- "./package.json": "./package.json"
38
- },
39
- "files": [
40
- "dist",
41
- "README.md",
42
- "LICENSE"
43
- ],
44
- "publishConfig": {
45
- "access": "public"
46
- },
47
- "scripts": {
48
- "build": "node ../../scripts/build-package.mjs",
49
- "typecheck": "tsc --noEmit",
50
- "pretest": "node ../../scripts/build-packages.mjs",
51
- "test": "vitest run"
52
- },
53
- "peerDependencies": {
54
- "@devicechain/dashboards": "0.0.0-bootstrap.0",
55
- "echarts": "^6.0.0",
56
- "react": "^19.3.0"
57
- },
58
- "devDependencies": {
59
- "@devicechain/dashboards": "0.0.0-bootstrap.0",
60
- "@testing-library/react": "^16.3.3",
61
- "@types/node": "^26.6.4",
62
- "@types/react": "^19.3.0",
63
- "echarts": "^6.0.0",
64
- "esbuild": "^0.28.2",
65
- "jsdom": "^30.1.1",
66
- "react": "^19.3.0",
67
- "react-dom": "^19.3.0",
68
- "typescript": "~7.0.2",
69
- "vitest": "^5.0.3"
70
- },
71
- "peerDependenciesMeta": {
72
- "echarts": {
73
- "optional": true
74
- }
75
- }
76
- }
3
+ "version": "0.0.0-stage",
4
+ "stub": true,
5
+ "description": "Temporary package placeholder for staged publishing"
6
+ }
package/LICENSE DELETED
@@ -1,201 +0,0 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS
177
-
178
- APPENDIX: How to apply the Apache License to your work.
179
-
180
- To apply the Apache License to your work, attach the following
181
- boilerplate notice, with the fields enclosed by brackets "[]"
182
- replaced with your own identifying information. (Don't include
183
- the brackets!) The text should be enclosed in the appropriate
184
- comment syntax for the file format. We also recommend that a
185
- file or class name and description of purpose be included on the
186
- same "printed page" as the copyright notice for easier
187
- identification within third-party archives.
188
-
189
- Copyright The DeviceChain Authors
190
-
191
- Licensed under the Apache License, Version 2.0 (the "License");
192
- you may not use this file except in compliance with the License.
193
- You may obtain a copy of the License at
194
-
195
- http://www.apache.org/licenses/LICENSE-2.0
196
-
197
- Unless required by applicable law or agreed to in writing, software
198
- distributed under the License is distributed on an "AS IS" BASIS,
199
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
- See the License for the specific language governing permissions and
201
- limitations under the License.
@@ -1,14 +0,0 @@
1
- import type { MeasurementSample } from '@devicechain/dashboards';
2
- import type { ElementSize } from '../hooks';
3
- import type { ChartTheme } from './chart-theme';
4
- import type { EChartOption } from './echart';
5
- export interface LineChartOptions {
6
- measurements?: string[];
7
- }
8
- export declare function buildLineOption(samples: MeasurementSample[], theme: ChartTheme, options?: LineChartOptions, size?: ElementSize): EChartOption;
9
- export interface GaugeChartOptions {
10
- min?: number;
11
- max?: number;
12
- unit?: string;
13
- }
14
- export declare function buildGaugeOption(value: number | null, theme: ChartTheme, options?: GaugeChartOptions, size?: ElementSize): EChartOption;
@@ -1,8 +0,0 @@
1
- export interface ChartTheme {
2
- foreground: string;
3
- mutedForeground: string;
4
- border: string;
5
- series: string[];
6
- }
7
- export declare function resolveChartTheme(el: Element): ChartTheme;
8
- export declare function useChartTheme(): ChartTheme;
@@ -1,8 +0,0 @@
1
- import * as echarts from 'echarts/core';
2
- export type EChartOption = echarts.EChartsCoreOption;
3
- export interface EChartProps {
4
- option: EChartOption;
5
- className?: string;
6
- style?: React.CSSProperties;
7
- }
8
- export declare function EChart({ option, className, style }: EChartProps): import("react").JSX.Element;
@@ -1,67 +0,0 @@
1
- // src/context.tsx
2
- import { createContext, useContext } from "react";
3
- import { jsx } from "react/jsx-runtime";
4
- var WidgetSubjectContext = createContext(void 0);
5
- function useWidgetSubject() {
6
- return useContext(WidgetSubjectContext);
7
- }
8
- function WidgetSubjectProvider({
9
- label,
10
- children
11
- }) {
12
- return /* @__PURE__ */ jsx(WidgetSubjectContext.Provider, { value: label, children });
13
- }
14
- var WidgetTimeZoneContext = createContext(void 0);
15
- function WidgetTimeZoneProvider({
16
- timeZone,
17
- children
18
- }) {
19
- return /* @__PURE__ */ jsx(WidgetTimeZoneContext.Provider, { value: timeZone, children });
20
- }
21
- function useWidgetTimeZone() {
22
- return useContext(WidgetTimeZoneContext);
23
- }
24
- var WidgetThemeRootContext = createContext(void 0);
25
- function WidgetThemeRootProvider({
26
- root,
27
- children
28
- }) {
29
- return /* @__PURE__ */ jsx(WidgetThemeRootContext.Provider, { value: root, children });
30
- }
31
- function useWidgetThemeRoot() {
32
- return useContext(WidgetThemeRootContext);
33
- }
34
- var WidgetSelectContext = createContext(void 0);
35
- function WidgetSelectProvider({
36
- select,
37
- children
38
- }) {
39
- return /* @__PURE__ */ jsx(WidgetSelectContext.Provider, { value: select, children });
40
- }
41
- function useWidgetSelect() {
42
- return useContext(WidgetSelectContext);
43
- }
44
- var WidgetCandidatesContext = createContext(void 0);
45
- function WidgetCandidatesProvider({
46
- candidates,
47
- children
48
- }) {
49
- return /* @__PURE__ */ jsx(WidgetCandidatesContext.Provider, { value: candidates, children });
50
- }
51
- function useWidgetCandidates() {
52
- return useContext(WidgetCandidatesContext);
53
- }
54
-
55
- export {
56
- useWidgetSubject,
57
- WidgetSubjectProvider,
58
- WidgetTimeZoneProvider,
59
- useWidgetTimeZone,
60
- WidgetThemeRootProvider,
61
- useWidgetThemeRoot,
62
- WidgetSelectProvider,
63
- useWidgetSelect,
64
- WidgetCandidatesProvider,
65
- useWidgetCandidates
66
- };
67
- //# sourceMappingURL=chunk-CC2V7LVI.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/context.tsx"],
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, type ReactNode } from 'react';\n\nimport type { SelectionCandidate, SelectionTarget } 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// 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"],
5
- "mappings": ";AAcA,SAAS,eAAe,kBAAkC;AAyBjD;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;AAUA,IAAM,sBAAsB,cAAwC,MAAS;AAEtE,SAAS,qBAAqB;AAAA,EACnC;AAAA,EACA;AACF,GAGG;AACD,SAAO,oBAAC,oBAAoB,UAApB,EAA6B,OAAO,QAAS,UAAS;AAChE;AAKO,SAAS,kBAA4C;AAC1D,SAAO,WAAW,mBAAmB;AACvC;AAUA,IAAM,0BAA0B,cAA4C,MAAS;AAE9E,SAAS,yBAAyB;AAAA,EACvC;AAAA,EACA;AACF,GAGG;AACD,SAAO,oBAAC,wBAAwB,UAAxB,EAAiC,OAAO,YAAa,UAAS;AACxE;AAKO,SAAS,sBAAoD;AAClE,SAAO,WAAW,uBAAuB;AAC3C;",
6
- "names": []
7
- }
package/dist/context.d.ts DELETED
@@ -1,29 +0,0 @@
1
- import { type ReactNode } from 'react';
2
- import type { SelectionCandidate, SelectionTarget } from '@devicechain/dashboards';
3
- export declare function useWidgetSubject(): string | undefined;
4
- export declare function WidgetSubjectProvider({ label, children, }: {
5
- label: string | undefined;
6
- children: ReactNode;
7
- }): import("react").JSX.Element;
8
- export declare function WidgetTimeZoneProvider({ timeZone, children, }: {
9
- timeZone: string | undefined;
10
- children: ReactNode;
11
- }): import("react").JSX.Element;
12
- export declare function useWidgetTimeZone(): string | undefined;
13
- export declare function WidgetThemeRootProvider({ root, children, }: {
14
- root: Element | undefined;
15
- children: ReactNode;
16
- }): import("react").JSX.Element;
17
- export declare function useWidgetThemeRoot(): Element | undefined;
18
- export type WidgetSelect = (target: SelectionTarget) => void;
19
- export declare function WidgetSelectProvider({ select, children, }: {
20
- select: WidgetSelect | undefined;
21
- children: ReactNode;
22
- }): import("react").JSX.Element;
23
- export declare function useWidgetSelect(): WidgetSelect | undefined;
24
- export type WidgetCandidates = (slot: string) => Promise<SelectionCandidate[]>;
25
- export declare function WidgetCandidatesProvider({ candidates, children, }: {
26
- candidates: WidgetCandidates | undefined;
27
- children: ReactNode;
28
- }): import("react").JSX.Element;
29
- export declare function useWidgetCandidates(): WidgetCandidates | undefined;
@@ -1,22 +0,0 @@
1
- import type { ChannelSnapshot, OptionsOf, WidgetChannel, WidgetDescriptor, WidgetOptionSpecs } from '@devicechain/dashboards';
2
- import type { ComponentType } from 'react';
3
- import type { WidgetEditorProps, WidgetProps } from './widget';
4
- export interface WidgetImplementation<C extends WidgetChannel, S extends WidgetOptionSpecs> {
5
- kind: 'trusted-react';
6
- component: ComponentType<WidgetProps<ChannelSnapshot<C>>>;
7
- editor?: ComponentType<WidgetEditorProps<OptionsOf<S>>>;
8
- }
9
- export interface WidgetDefinition<C extends WidgetChannel = WidgetChannel, S extends WidgetOptionSpecs = WidgetOptionSpecs> {
10
- descriptor: WidgetDescriptor<C, S>;
11
- implementation: WidgetImplementation<C, S>;
12
- }
13
- export type ErasedComponent = ComponentType<any>;
14
- export interface ErasedWidgetDefinition {
15
- descriptor: WidgetDescriptor;
16
- implementation: {
17
- kind: 'trusted-react';
18
- component: ErasedComponent;
19
- editor?: ErasedComponent;
20
- };
21
- }
22
- export declare function defineWidget<const C extends WidgetChannel, const S extends WidgetOptionSpecs>(definition: WidgetDefinition<C, S>): WidgetDefinition<C, S>;
package/dist/echarts.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export { EChart, type EChartOption, type EChartProps } from './chart/echart';
2
- export { buildGaugeOption, buildLineOption, type GaugeChartOptions, type LineChartOptions, } from './chart/chart-options';
3
- export { resolveChartTheme, useChartTheme, type ChartTheme } from './chart/chart-theme';