@snap-rail/ui 0.0.0-stage → 0.1.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/LICENSE +202 -0
- package/lib/charts.js +142 -0
- package/lib/contract.js +543 -0
- package/lib/fallback.js +400 -0
- package/lib/index.js +3345 -0
- package/lib/pages.js +68 -0
- package/lib/runtime.js +2064 -0
- package/lib/settings.js +1195 -0
- package/lib/skins.js +284 -0
- package/lib/slots.js +267 -0
- package/lib/types/charts.d.ts +62 -0
- package/lib/types/charts.js +41 -0
- package/lib/types/components/button.d.ts +39 -0
- package/lib/types/components/button.js +27 -0
- package/lib/types/components/controls.d.ts +66 -0
- package/lib/types/components/controls.js +66 -0
- package/lib/types/components/dialog.d.ts +58 -0
- package/lib/types/components/dialog.js +46 -0
- package/lib/types/components/feedback.d.ts +46 -0
- package/lib/types/components/feedback.js +20 -0
- package/lib/types/components/form.d.ts +31 -0
- package/lib/types/components/form.js +13 -0
- package/lib/types/components/index.d.ts +15 -0
- package/lib/types/components/index.js +15 -0
- package/lib/types/components/input.d.ts +37 -0
- package/lib/types/components/input.js +15 -0
- package/lib/types/components/layout.d.ts +100 -0
- package/lib/types/components/layout.js +80 -0
- package/lib/types/components/schema-form.d.ts +34 -0
- package/lib/types/components/schema-form.js +61 -0
- package/lib/types/components/surface.d.ts +49 -0
- package/lib/types/components/surface.js +59 -0
- package/lib/types/contract.d.ts +358 -0
- package/lib/types/contract.js +235 -0
- package/lib/types/fallback.d.ts +14 -0
- package/lib/types/fallback.js +50 -0
- package/lib/types/index.d.ts +19 -0
- package/lib/types/index.js +19 -0
- package/lib/types/pages.d.ts +40 -0
- package/lib/types/pages.js +69 -0
- package/lib/types/runtime.d.ts +71 -0
- package/lib/types/runtime.js +177 -0
- package/lib/types/settings-pages/appearance.d.ts +13 -0
- package/lib/types/settings-pages/appearance.js +131 -0
- package/lib/types/settings-pages/index.d.ts +3 -0
- package/lib/types/settings-pages/index.js +3 -0
- package/lib/types/settings-pages/plugins.d.ts +16 -0
- package/lib/types/settings-pages/plugins.js +109 -0
- package/lib/types/settings.d.ts +58 -0
- package/lib/types/settings.js +170 -0
- package/lib/types/skins.d.ts +143 -0
- package/lib/types/skins.js +268 -0
- package/lib/types/slots.d.ts +69 -0
- package/lib/types/slots.js +210 -0
- package/lib/types/utils.d.ts +15 -0
- package/lib/types/utils.js +26 -0
- package/package.json +105 -3
- package/src/styles/base.css +321 -0
- package/src/styles/default.css +734 -0
- package/README.md +0 -3
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The semantic UI contract: component names, region-slot ids, scoped slot
|
|
3
|
+
* contexts, and the author-facing UI profile vocabulary. This module is pure
|
|
4
|
+
* (types, constants, guards) so host and renderer faces can both import it
|
|
5
|
+
* without dragging React or the renderer runtime into the host graph.
|
|
6
|
+
*
|
|
7
|
+
* @module @snap-rail/ui/contract
|
|
8
|
+
*/
|
|
9
|
+
/** The author-declared relationship between a plugin and the skin contract. */
|
|
10
|
+
export const UI_PROFILES = ['native', 'integrated', 'custom'];
|
|
11
|
+
/** The stable region slots every layout may provide. */
|
|
12
|
+
export const UI_SLOT_IDS = {
|
|
13
|
+
/** The one active layout of the operator window. */
|
|
14
|
+
layout: 'shell.layout',
|
|
15
|
+
/** The operator titlebar. */
|
|
16
|
+
titlebar: 'shell.titlebar',
|
|
17
|
+
/** Contributed titlebar actions. */
|
|
18
|
+
titlebarActions: 'shell.titlebar.actions',
|
|
19
|
+
/** Sidebar extension area. */
|
|
20
|
+
sidebar: 'shell.sidebar',
|
|
21
|
+
/** Statusbar extension area. */
|
|
22
|
+
statusbar: 'shell.statusbar',
|
|
23
|
+
/** The global overlay stack (dialogs, confirms). */
|
|
24
|
+
overlay: 'shell.overlay',
|
|
25
|
+
/** The floating ball surface face. */
|
|
26
|
+
ball: 'shell.ball',
|
|
27
|
+
/** The settings trigger. */
|
|
28
|
+
settingsEntry: 'settings.entry',
|
|
29
|
+
/** The settings surface itself. */
|
|
30
|
+
settingsSurface: 'settings.surface',
|
|
31
|
+
};
|
|
32
|
+
/** A named custom slot is owned by a publisher package. */
|
|
33
|
+
export const CUSTOM_SLOT_PATTERN = /^custom:[a-z0-9][a-z0-9-]*\.[a-z0-9][a-z0-9-]*$/;
|
|
34
|
+
/** Check a region-slot id at runtime. */
|
|
35
|
+
export function isValidSlotId(value) {
|
|
36
|
+
return Object.values(UI_SLOT_IDS).includes(value)
|
|
37
|
+
|| CUSTOM_SLOT_PATTERN.test(value);
|
|
38
|
+
}
|
|
39
|
+
/** The occupancy mode of every built-in slot. */
|
|
40
|
+
export const UI_SLOT_MODES = {
|
|
41
|
+
[UI_SLOT_IDS.layout]: 'one',
|
|
42
|
+
[UI_SLOT_IDS.titlebar]: 'one',
|
|
43
|
+
[UI_SLOT_IDS.titlebarActions]: 'many',
|
|
44
|
+
[UI_SLOT_IDS.sidebar]: 'many',
|
|
45
|
+
[UI_SLOT_IDS.statusbar]: 'many',
|
|
46
|
+
[UI_SLOT_IDS.overlay]: 'many',
|
|
47
|
+
[UI_SLOT_IDS.ball]: 'one',
|
|
48
|
+
[UI_SLOT_IDS.settingsEntry]: 'one',
|
|
49
|
+
[UI_SLOT_IDS.settingsSurface]: 'one',
|
|
50
|
+
};
|
|
51
|
+
/** Diagnostic kinds surfaced by the UI registry. */
|
|
52
|
+
export const UI_DIAGNOSTIC_KINDS = [
|
|
53
|
+
'unknown-slot',
|
|
54
|
+
'missing-provider',
|
|
55
|
+
'invalid-context',
|
|
56
|
+
'duplicate-id',
|
|
57
|
+
'render-failed',
|
|
58
|
+
'declared-not-rendered',
|
|
59
|
+
];
|
|
60
|
+
/**
|
|
61
|
+
* The component catalog. It is the shared vocabulary for the gallery, skin
|
|
62
|
+
* coverage checks, and author documentation; adding a component here is a
|
|
63
|
+
* contract change, not an implementation detail.
|
|
64
|
+
*/
|
|
65
|
+
export const UI_COMPONENTS = {
|
|
66
|
+
button: {
|
|
67
|
+
parts: ['button.root', 'button.label', 'button.icon', 'button.spinner'],
|
|
68
|
+
slots: ['label', 'icon'],
|
|
69
|
+
props: ['intent', 'emphasis', 'size', 'loading', 'disabled'],
|
|
70
|
+
},
|
|
71
|
+
'icon-button': {
|
|
72
|
+
parts: ['icon-button.root', 'icon-button.icon'],
|
|
73
|
+
slots: ['icon'],
|
|
74
|
+
props: ['intent', 'emphasis', 'size', 'active', 'disabled'],
|
|
75
|
+
},
|
|
76
|
+
input: {
|
|
77
|
+
parts: ['input.root', 'input.field', 'input.prefix', 'input.suffix', 'input.clear'],
|
|
78
|
+
slots: ['prefix', 'suffix'],
|
|
79
|
+
props: ['size', 'invalid', 'disabled'],
|
|
80
|
+
},
|
|
81
|
+
textarea: {
|
|
82
|
+
parts: ['textarea.root', 'textarea.field'],
|
|
83
|
+
props: ['size', 'invalid', 'disabled'],
|
|
84
|
+
},
|
|
85
|
+
'number-input': {
|
|
86
|
+
parts: ['number-input.root', 'number-input.field', 'number-input.step-up', 'number-input.step-down'],
|
|
87
|
+
props: ['size', 'invalid', 'disabled'],
|
|
88
|
+
},
|
|
89
|
+
select: {
|
|
90
|
+
parts: ['select.root', 'select.trigger', 'select.value', 'select.chevron', 'select.content', 'select.item', 'select.item-indicator', 'select.empty'],
|
|
91
|
+
slots: ['empty'],
|
|
92
|
+
props: ['size', 'invalid', 'disabled', 'presentation'],
|
|
93
|
+
},
|
|
94
|
+
'touch-select': {
|
|
95
|
+
parts: ['touch-select.root', 'touch-select.trigger', 'touch-select.sheet', 'touch-select.option'],
|
|
96
|
+
props: ['invalid', 'disabled'],
|
|
97
|
+
},
|
|
98
|
+
checkbox: {
|
|
99
|
+
parts: ['checkbox.root', 'checkbox.box', 'checkbox.indicator', 'checkbox.label'],
|
|
100
|
+
slots: ['label'],
|
|
101
|
+
props: ['checked', 'invalid', 'disabled'],
|
|
102
|
+
},
|
|
103
|
+
switch: {
|
|
104
|
+
parts: ['switch.root', 'switch.thumb', 'switch.label'],
|
|
105
|
+
slots: ['label'],
|
|
106
|
+
props: ['checked', 'disabled'],
|
|
107
|
+
},
|
|
108
|
+
'radio-group': {
|
|
109
|
+
parts: ['radio-group.root', 'radio-group.item', 'radio-group.indicator', 'radio-group.label'],
|
|
110
|
+
props: ['value', 'disabled'],
|
|
111
|
+
},
|
|
112
|
+
tabs: {
|
|
113
|
+
parts: ['tabs.root', 'tabs.list', 'tabs.trigger', 'tabs.content'],
|
|
114
|
+
slots: ['list', 'content'],
|
|
115
|
+
props: ['value', 'presentation'],
|
|
116
|
+
},
|
|
117
|
+
table: {
|
|
118
|
+
parts: ['table.root', 'table.header', 'table.body', 'table.row', 'table.head', 'table.cell', 'table.empty'],
|
|
119
|
+
slots: ['empty'],
|
|
120
|
+
},
|
|
121
|
+
card: {
|
|
122
|
+
parts: ['card.root', 'card.header', 'card.title', 'card.description', 'card.body', 'card.footer'],
|
|
123
|
+
slots: ['header', 'title', 'description', 'body', 'footer'],
|
|
124
|
+
},
|
|
125
|
+
panel: {
|
|
126
|
+
parts: ['panel.root', 'panel.header', 'panel.title', 'panel.body', 'panel.footer'],
|
|
127
|
+
slots: ['header', 'title', 'body', 'footer'],
|
|
128
|
+
},
|
|
129
|
+
dialog: {
|
|
130
|
+
parts: ['dialog.root', 'dialog.overlay', 'dialog.panel', 'dialog.header', 'dialog.title', 'dialog.description', 'dialog.body', 'dialog.footer', 'dialog.close'],
|
|
131
|
+
slots: ['header', 'title', 'description', 'body', 'footer'],
|
|
132
|
+
props: ['open', 'presentation', 'size'],
|
|
133
|
+
},
|
|
134
|
+
sheet: {
|
|
135
|
+
parts: ['sheet.root', 'sheet.overlay', 'sheet.panel', 'sheet.header', 'sheet.body', 'sheet.footer'],
|
|
136
|
+
slots: ['header', 'body', 'footer'],
|
|
137
|
+
props: ['open', 'presentation'],
|
|
138
|
+
},
|
|
139
|
+
popover: {
|
|
140
|
+
parts: ['popover.root', 'popover.trigger', 'popover.content'],
|
|
141
|
+
slots: ['trigger', 'content'],
|
|
142
|
+
},
|
|
143
|
+
tooltip: {
|
|
144
|
+
parts: ['tooltip.root', 'tooltip.trigger', 'tooltip.content'],
|
|
145
|
+
slots: ['trigger', 'content'],
|
|
146
|
+
},
|
|
147
|
+
menu: {
|
|
148
|
+
parts: ['menu.root', 'menu.trigger', 'menu.content', 'menu.item', 'menu.separator'],
|
|
149
|
+
slots: ['trigger', 'content'],
|
|
150
|
+
},
|
|
151
|
+
toast: {
|
|
152
|
+
parts: ['toast.root', 'toast.title', 'toast.description', 'toast.action', 'toast.close'],
|
|
153
|
+
slots: ['action'],
|
|
154
|
+
},
|
|
155
|
+
progress: {
|
|
156
|
+
parts: ['progress.root', 'progress.track', 'progress.indicator'],
|
|
157
|
+
},
|
|
158
|
+
badge: {
|
|
159
|
+
parts: ['badge.root'],
|
|
160
|
+
},
|
|
161
|
+
led: {
|
|
162
|
+
parts: ['led.root', 'led.halo'],
|
|
163
|
+
props: ['tone'],
|
|
164
|
+
},
|
|
165
|
+
spinner: {
|
|
166
|
+
parts: ['spinner.root'],
|
|
167
|
+
},
|
|
168
|
+
'empty-state': {
|
|
169
|
+
parts: ['empty-state.root', 'empty-state.icon', 'empty-state.title', 'empty-state.description', 'empty-state.action'],
|
|
170
|
+
slots: ['icon', 'title', 'description', 'action'],
|
|
171
|
+
},
|
|
172
|
+
form: {
|
|
173
|
+
parts: ['form.root', 'form.fields', 'form.actions'],
|
|
174
|
+
slots: ['fields', 'actions'],
|
|
175
|
+
},
|
|
176
|
+
field: {
|
|
177
|
+
parts: ['field.root', 'field.label', 'field.control', 'field.help', 'field.error'],
|
|
178
|
+
slots: ['label', 'control', 'help', 'error'],
|
|
179
|
+
props: ['invalid', 'required', 'disabled'],
|
|
180
|
+
},
|
|
181
|
+
'schema-form': {
|
|
182
|
+
parts: ['schema-form.root', 'schema-form.field'],
|
|
183
|
+
slots: ['fields'],
|
|
184
|
+
},
|
|
185
|
+
'app-shell': {
|
|
186
|
+
parts: ['app-shell.root', 'app-shell.header', 'app-shell.sidebar', 'app-shell.main', 'app-shell.footer'],
|
|
187
|
+
slots: ['header', 'sidebar', 'main', 'footer'],
|
|
188
|
+
},
|
|
189
|
+
page: {
|
|
190
|
+
parts: ['page.root', 'page.header', 'page.title', 'page.description', 'page.actions', 'page.body'],
|
|
191
|
+
slots: ['header', 'title', 'description', 'actions', 'body'],
|
|
192
|
+
},
|
|
193
|
+
section: {
|
|
194
|
+
parts: ['section.root', 'section.header', 'section.title', 'section.actions', 'section.body'],
|
|
195
|
+
slots: ['header', 'title', 'actions', 'body'],
|
|
196
|
+
},
|
|
197
|
+
toolbar: {
|
|
198
|
+
parts: ['toolbar.root', 'toolbar.start', 'toolbar.end'],
|
|
199
|
+
slots: ['start', 'end'],
|
|
200
|
+
},
|
|
201
|
+
stack: { parts: ['stack.root'], props: ['gap', 'padding', 'align'] },
|
|
202
|
+
row: { parts: ['row.root'], props: ['gap', 'padding', 'align', 'justify'] },
|
|
203
|
+
grid: { parts: ['grid.root'], props: ['gap', 'columns', 'padding'] },
|
|
204
|
+
split: { parts: ['split.root', 'split.start', 'split.end'], slots: ['start', 'end'] },
|
|
205
|
+
'scroll-area': { parts: ['scroll-area.root', 'scroll-area.viewport', 'scroll-area.scrollbar'] },
|
|
206
|
+
'drag-scroll': { parts: ['drag-scroll.root', 'drag-scroll.viewport'] },
|
|
207
|
+
visualization: {
|
|
208
|
+
parts: ['visualization.root', 'visualization.header', 'visualization.title', 'visualization.actions', 'visualization.body', 'visualization.empty', 'visualization.error', 'visualization.loading'],
|
|
209
|
+
slots: ['header', 'title', 'actions', 'body', 'empty', 'error', 'loading'],
|
|
210
|
+
props: ['state'],
|
|
211
|
+
},
|
|
212
|
+
'chart-frame': {
|
|
213
|
+
parts: ['chart-frame.root', 'chart-frame.header', 'chart-frame.title', 'chart-frame.actions', 'chart-frame.body'],
|
|
214
|
+
slots: ['header', 'title', 'actions', 'body'],
|
|
215
|
+
},
|
|
216
|
+
settings: {
|
|
217
|
+
parts: [
|
|
218
|
+
'settings.root',
|
|
219
|
+
'settings.header',
|
|
220
|
+
'settings.title',
|
|
221
|
+
'settings.body',
|
|
222
|
+
'settings.nav',
|
|
223
|
+
'settings.nav-item',
|
|
224
|
+
'settings.nav-icon',
|
|
225
|
+
'settings.group',
|
|
226
|
+
'settings.group-title',
|
|
227
|
+
'settings.content',
|
|
228
|
+
],
|
|
229
|
+
},
|
|
230
|
+
};
|
|
231
|
+
/** The presentation targets a skin may tune. */
|
|
232
|
+
export const PRESENTATION_TARGETS = ['dialog', 'select', 'tabs', 'toast'];
|
|
233
|
+
/** The presentation variants the core implements. */
|
|
234
|
+
export const PRESENTATION_VARIANTS = ['modal', 'sheet', 'fullscreen', 'popover', 'segmented', 'inline'];
|
|
235
|
+
//# sourceMappingURL=contract.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The built-in fallback layout: a minimal titlebar, a settings seat, window
|
|
3
|
+
* controls, and an empty state pointing at the plugin manager. It is an
|
|
4
|
+
* ordinary low-precedence layout occupant, not a special shell branch; a
|
|
5
|
+
* suite layout with higher precedence replaces it and its disposal brings the
|
|
6
|
+
* fallback back automatically.
|
|
7
|
+
*
|
|
8
|
+
* @module @snap-rail/ui/fallback
|
|
9
|
+
*/
|
|
10
|
+
import { type Plugin } from '@snap-rail/cordis';
|
|
11
|
+
/** The fallback layout occupant. */
|
|
12
|
+
declare const fallbackPlugin: Plugin.Object<void>;
|
|
13
|
+
export default fallbackPlugin;
|
|
14
|
+
//# sourceMappingURL=fallback.d.ts.map
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { AppShell, Button, EmptyState, IconButton } from "./components/index.js";
|
|
3
|
+
import { UI_SLOT_IDS } from "./contract.js";
|
|
4
|
+
import { usePagesVersion } from "./pages.js";
|
|
5
|
+
import { Slot, useUiVersion } from "./slots.js";
|
|
6
|
+
/** A compact glyph for the window controls. */
|
|
7
|
+
function Glyph(props) {
|
|
8
|
+
return _jsx("span", { "aria-hidden": "true", style: { lineHeight: 1 }, children: props.children });
|
|
9
|
+
}
|
|
10
|
+
/** The fallback body. */
|
|
11
|
+
function FallbackShell(props) {
|
|
12
|
+
useUiVersion(props.ctx.ui);
|
|
13
|
+
usePagesVersion(props.ctx);
|
|
14
|
+
const active = props.ctx.pages.active();
|
|
15
|
+
const control = (action) => {
|
|
16
|
+
void props.ctx.client.link.call('window.control', { action }).catch(() => { });
|
|
17
|
+
};
|
|
18
|
+
const header = (_jsxs("div", { className: "snap-fallback-titlebar", style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', minHeight: 48, paddingLeft: 16 }, children: [_jsxs("span", { style: { color: 'var(--snap-color-muted)', fontSize: 'var(--snap-text-sm)' }, children: ["snap-rail", active !== undefined ? ` · ${active.title}` : ''] }), _jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 4 }, children: [_jsx(Slot, { name: UI_SLOT_IDS.settingsEntry, context: {
|
|
19
|
+
presentation: 'icon',
|
|
20
|
+
open: () => props.ctx.settings.open(),
|
|
21
|
+
isOpen: props.ctx.settings.isOpen(),
|
|
22
|
+
} }), _jsx(IconButton, { icon: _jsx(Glyph, { children: "\u2014" }), label: "\u6700\u5C0F\u5316", onClick: () => control('minimize') }), _jsx(IconButton, { icon: _jsx(Glyph, { children: "\u25A1" }), label: "\u6700\u5927\u5316\u5207\u6362", onClick: () => control('toggle-maximize') }), _jsx(IconButton, { icon: _jsx(Glyph, { children: "\u00D7" }), label: "\u5173\u95ED", onClick: () => control('close') })] })] }));
|
|
23
|
+
return (_jsx(AppShell, { header: header, children: active !== undefined
|
|
24
|
+
? active.render()
|
|
25
|
+
: (_jsx("div", { style: { display: 'flex', minHeight: '100%', alignItems: 'center', justifyContent: 'center', padding: 24 }, children: _jsx(EmptyState, { title: "\u5C1A\u672A\u6FC0\u6D3B\u4E1A\u52A1\u5957\u4EF6", description: "\u6253\u5F00\u8BBE\u7F6E\u7684\u300C\u63D2\u4EF6\u7BA1\u7406\u300D\u9875\uFF0C\u5B89\u88C5\u5E76\u542F\u7528\u4E00\u4E2A\u4E1A\u52A1\u5957\u4EF6\uFF1B\u9A71\u52A8\u4E5F\u5728\u540C\u4E00\u5904\u5B89\u88C5\u3002", action: _jsx(Button, { intent: "primary", onClick: () => props.ctx.settings.open('plugins'), children: "\u6253\u5F00\u8BBE\u7F6E" }) }) })) }));
|
|
26
|
+
}
|
|
27
|
+
/** The fallback layout occupant. */
|
|
28
|
+
const fallbackPlugin = {
|
|
29
|
+
name: 'snap-rail fallback layout',
|
|
30
|
+
inject: ['ui', 'settings', 'pages', 'client'],
|
|
31
|
+
apply(ctx) {
|
|
32
|
+
ctx.ui.registerLayout(ctx, {
|
|
33
|
+
id: 'fallback',
|
|
34
|
+
order: 200,
|
|
35
|
+
precedence: 0,
|
|
36
|
+
provides: [
|
|
37
|
+
UI_SLOT_IDS.titlebar,
|
|
38
|
+
UI_SLOT_IDS.titlebarActions,
|
|
39
|
+
UI_SLOT_IDS.sidebar,
|
|
40
|
+
UI_SLOT_IDS.statusbar,
|
|
41
|
+
UI_SLOT_IDS.settingsEntry,
|
|
42
|
+
],
|
|
43
|
+
window: { width: 1280, height: 800, minWidth: 960, minHeight: 600 },
|
|
44
|
+
ball: { size: 128 },
|
|
45
|
+
render: () => _jsx(FallbackShell, { ctx: ctx }),
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
export default fallbackPlugin;
|
|
50
|
+
//# sourceMappingURL=fallback.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The built-in UI substrate's root barrel: semantic contract, region slots,
|
|
3
|
+
* skin registry, and (as they land) components, layout primitives, settings,
|
|
4
|
+
* charts, runtime, and fallback.
|
|
5
|
+
*
|
|
6
|
+
* @module @snap-rail/ui
|
|
7
|
+
*/
|
|
8
|
+
export * from './contract.ts';
|
|
9
|
+
export * from './charts.tsx';
|
|
10
|
+
export * from './components/index.ts';
|
|
11
|
+
export * from './fallback.tsx';
|
|
12
|
+
export * from './pages.tsx';
|
|
13
|
+
export * from './runtime.tsx';
|
|
14
|
+
export * from './settings.tsx';
|
|
15
|
+
export * from './slots.tsx';
|
|
16
|
+
export * from './skins.tsx';
|
|
17
|
+
export { default as slotsPlugin } from './slots.tsx';
|
|
18
|
+
export { default as skinsPlugin } from './skins.tsx';
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The built-in UI substrate's root barrel: semantic contract, region slots,
|
|
3
|
+
* skin registry, and (as they land) components, layout primitives, settings,
|
|
4
|
+
* charts, runtime, and fallback.
|
|
5
|
+
*
|
|
6
|
+
* @module @snap-rail/ui
|
|
7
|
+
*/
|
|
8
|
+
export * from "./contract.js";
|
|
9
|
+
export * from "./charts.js";
|
|
10
|
+
export * from "./components/index.js";
|
|
11
|
+
export * from "./fallback.js";
|
|
12
|
+
export * from "./pages.js";
|
|
13
|
+
export * from "./runtime.js";
|
|
14
|
+
export * from "./settings.js";
|
|
15
|
+
export * from "./slots.js";
|
|
16
|
+
export * from "./skins.js";
|
|
17
|
+
export { default as slotsPlugin } from "./slots.js";
|
|
18
|
+
export { default as skinsPlugin } from "./skins.js";
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The main-page registry: business views contribute a page, a layout renders
|
|
3
|
+
* the active one. This is deliberately separate from settings pages and from
|
|
4
|
+
* the chrome slots; gating/workflows can wrap it later without changing the
|
|
5
|
+
* page authoring surface.
|
|
6
|
+
*
|
|
7
|
+
* @module @snap-rail/ui/pages
|
|
8
|
+
*/
|
|
9
|
+
import { Context, type Plugin } from '@snap-rail/cordis';
|
|
10
|
+
import { type ReactNode } from 'react';
|
|
11
|
+
/** One main page contributed by a plugin. */
|
|
12
|
+
export interface PageDefinition {
|
|
13
|
+
id: string;
|
|
14
|
+
title: string;
|
|
15
|
+
order: number;
|
|
16
|
+
render(): ReactNode;
|
|
17
|
+
}
|
|
18
|
+
/** The page registry exposed as `ctx.pages`. */
|
|
19
|
+
export interface PagesService {
|
|
20
|
+
registerPage(caller: Context, page: PageDefinition): () => void;
|
|
21
|
+
list(): readonly PageDefinition[];
|
|
22
|
+
active(): PageDefinition | undefined;
|
|
23
|
+
setActive(id: string): void;
|
|
24
|
+
subscribe(listener: () => void): () => void;
|
|
25
|
+
version(): number;
|
|
26
|
+
}
|
|
27
|
+
declare module '@snap-rail/cordis' {
|
|
28
|
+
interface Context {
|
|
29
|
+
pages: PagesService;
|
|
30
|
+
}
|
|
31
|
+
interface Events {
|
|
32
|
+
'pages/changed'(): void;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/** Mount the page registry. */
|
|
36
|
+
declare const pagesPlugin: Plugin.Object<void>;
|
|
37
|
+
/** Re-render a layout when the page registry or active page changes. */
|
|
38
|
+
export declare function usePagesVersion(ctx: Context): number;
|
|
39
|
+
export default pagesPlugin;
|
|
40
|
+
//# sourceMappingURL=pages.d.ts.map
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The main-page registry: business views contribute a page, a layout renders
|
|
3
|
+
* the active one. This is deliberately separate from settings pages and from
|
|
4
|
+
* the chrome slots; gating/workflows can wrap it later without changing the
|
|
5
|
+
* page authoring surface.
|
|
6
|
+
*
|
|
7
|
+
* @module @snap-rail/ui/pages
|
|
8
|
+
*/
|
|
9
|
+
import { useSyncExternalStore } from 'react';
|
|
10
|
+
/** Mount the page registry. */
|
|
11
|
+
const pagesPlugin = {
|
|
12
|
+
name: 'snap-rail ui pages',
|
|
13
|
+
apply(ctx) {
|
|
14
|
+
const pages = new Map();
|
|
15
|
+
const listeners = new Set();
|
|
16
|
+
let revision = 0;
|
|
17
|
+
let seq = 0;
|
|
18
|
+
let activeId;
|
|
19
|
+
const ordered = () => [...pages.values()]
|
|
20
|
+
.sort((a, b) => a.page.order - b.page.order || a.seq - b.seq)
|
|
21
|
+
.map(entry => entry.page);
|
|
22
|
+
const notify = () => {
|
|
23
|
+
revision += 1;
|
|
24
|
+
for (const listener of listeners)
|
|
25
|
+
listener();
|
|
26
|
+
ctx.emit('pages/changed');
|
|
27
|
+
};
|
|
28
|
+
const service = {
|
|
29
|
+
registerPage(caller, page) {
|
|
30
|
+
pages.set(page.id, { page, seq: seq++ });
|
|
31
|
+
activeId ??= page.id;
|
|
32
|
+
notify();
|
|
33
|
+
const remove = () => {
|
|
34
|
+
if (!pages.delete(page.id))
|
|
35
|
+
return;
|
|
36
|
+
if (activeId === page.id)
|
|
37
|
+
activeId = ordered()[0]?.id;
|
|
38
|
+
notify();
|
|
39
|
+
};
|
|
40
|
+
caller.effect(() => remove);
|
|
41
|
+
return remove;
|
|
42
|
+
},
|
|
43
|
+
list: ordered,
|
|
44
|
+
active() {
|
|
45
|
+
if (activeId === undefined)
|
|
46
|
+
return undefined;
|
|
47
|
+
return pages.get(activeId)?.page ?? ordered()[0];
|
|
48
|
+
},
|
|
49
|
+
setActive(id) {
|
|
50
|
+
if (!pages.has(id) || activeId === id)
|
|
51
|
+
return;
|
|
52
|
+
activeId = id;
|
|
53
|
+
notify();
|
|
54
|
+
},
|
|
55
|
+
subscribe(listener) {
|
|
56
|
+
listeners.add(listener);
|
|
57
|
+
return () => { listeners.delete(listener); };
|
|
58
|
+
},
|
|
59
|
+
version: () => revision,
|
|
60
|
+
};
|
|
61
|
+
ctx.provide('pages', service);
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
/** Re-render a layout when the page registry or active page changes. */
|
|
65
|
+
export function usePagesVersion(ctx) {
|
|
66
|
+
return useSyncExternalStore(ctx.pages.subscribe, ctx.pages.version, ctx.pages.version);
|
|
67
|
+
}
|
|
68
|
+
export default pagesPlugin;
|
|
69
|
+
//# sourceMappingURL=pages.js.map
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The built-in renderer runtime: it takes over the kernel root, mounts the
|
|
3
|
+
* core services, the skins, the layout/page plugins, and finally the fallback
|
|
4
|
+
* layout. There is no framework row and no framework seed: the substrate is
|
|
5
|
+
* always present, so a fresh install has a usable UI before any plugin is
|
|
6
|
+
* installed.
|
|
7
|
+
*
|
|
8
|
+
* @module @snap-rail/ui/runtime
|
|
9
|
+
*/
|
|
10
|
+
import type { ClientHandle } from '@snap-rail/client-kernel';
|
|
11
|
+
import { type HostLink } from '@snap-rail/connection';
|
|
12
|
+
import { Context, type Plugin } from '@snap-rail/cordis';
|
|
13
|
+
import type { SurfaceId } from '@snap-rail/protocol';
|
|
14
|
+
import { type ReactNode } from 'react';
|
|
15
|
+
import fallbackPlugin from './fallback.tsx';
|
|
16
|
+
import pagesPlugin from './pages.tsx';
|
|
17
|
+
import type { SettingsPageDefinition } from './settings.tsx';
|
|
18
|
+
import settingsPlugin from './settings.tsx';
|
|
19
|
+
import { Slot } from './slots.tsx';
|
|
20
|
+
import slotsPlugin from './slots.tsx';
|
|
21
|
+
import skinsPlugin from './skins.tsx';
|
|
22
|
+
/** The shared services every occupant may consume. */
|
|
23
|
+
export interface ClientServices {
|
|
24
|
+
/** The typed host link shared by every occupant. */
|
|
25
|
+
link: HostLink;
|
|
26
|
+
/** Which window this client tree serves. */
|
|
27
|
+
surface: SurfaceId;
|
|
28
|
+
}
|
|
29
|
+
declare module '@snap-rail/cordis' {
|
|
30
|
+
interface Context {
|
|
31
|
+
client: ClientServices;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/** Provide the client services to builtin page components. */
|
|
35
|
+
export declare function ClientProvider(props: {
|
|
36
|
+
service: ClientServices;
|
|
37
|
+
children: ReactNode;
|
|
38
|
+
}): ReactNode;
|
|
39
|
+
/** Read the client services (host link + surface) from a builtin page. */
|
|
40
|
+
export declare function useClient(): ClientServices;
|
|
41
|
+
/** One occupant seat. */
|
|
42
|
+
export interface OccupantSpec {
|
|
43
|
+
plugin: Plugin;
|
|
44
|
+
config?: unknown;
|
|
45
|
+
}
|
|
46
|
+
/** Options for {@link createClientRuntime}. */
|
|
47
|
+
export interface RuntimeOptions {
|
|
48
|
+
/** Layout/page/feature plugins, already ordered by the boot loader. */
|
|
49
|
+
plugins: readonly (Plugin | OccupantSpec)[];
|
|
50
|
+
/** The window this runtime serves; defaults to `main`. */
|
|
51
|
+
surface?: SurfaceId;
|
|
52
|
+
/** Core settings pages registered by the app (equipment, about, ...). */
|
|
53
|
+
builtinPages?: readonly SettingsPageDefinition[];
|
|
54
|
+
}
|
|
55
|
+
/** The runtime handle. */
|
|
56
|
+
export interface RuntimeHandle {
|
|
57
|
+
ctx: Context;
|
|
58
|
+
dispose(): Promise<void>;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Take over the kernel root and mount the UI substrate.
|
|
62
|
+
*
|
|
63
|
+
* @param handle - the kernel boot result.
|
|
64
|
+
* @param options - see {@link RuntimeOptions}.
|
|
65
|
+
*/
|
|
66
|
+
export declare function createClientRuntime(handle: ClientHandle, options: RuntimeOptions): Promise<RuntimeHandle>;
|
|
67
|
+
/** The built-in fallback layout plugin (exported for tests and custom hosts). */
|
|
68
|
+
export { fallbackPlugin };
|
|
69
|
+
export { pagesPlugin, settingsPlugin, slotsPlugin, skinsPlugin };
|
|
70
|
+
export { Slot };
|
|
71
|
+
//# sourceMappingURL=runtime.d.ts.map
|