trebol 0.1.1 → 0.2.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 +12 -1
- package/dist/cli.js +17097 -12238
- package/dist/fonts/OFL.txt +93 -0
- package/dist/fonts/inter-cyrillic-ext.woff2 +0 -0
- package/dist/fonts/inter-cyrillic.woff2 +0 -0
- package/dist/fonts/inter-greek-ext.woff2 +0 -0
- package/dist/fonts/inter-greek.woff2 +0 -0
- package/dist/fonts/inter-latin-ext.woff2 +0 -0
- package/dist/fonts/inter-latin.woff2 +0 -0
- package/dist/fonts/inter-vietnamese.woff2 +0 -0
- package/dist/lib/core/boot.js +12 -8
- package/dist/lib/core/eval.js +2 -2
- package/dist/lib/core/func.d.ts +4 -0
- package/dist/lib/core/machine/checks.d.ts +1 -0
- package/dist/lib/core/machine/checks.js +250 -0
- package/dist/lib/core/machine/events.d.ts +1 -0
- package/dist/lib/core/machine/events.js +365 -0
- package/dist/lib/core/machine/running.d.ts +1 -0
- package/dist/lib/core/machine/running.js +180 -0
- package/dist/lib/core/machine/shared.d.ts +1 -0
- package/dist/lib/core/machine/shared.js +123 -0
- package/dist/lib/core/machine/snapshot.d.ts +1 -0
- package/dist/lib/core/machine/snapshot.js +244 -0
- package/dist/lib/core/machine/spec.d.ts +1 -0
- package/dist/lib/core/machine/spec.js +274 -0
- package/dist/lib/core/machine/words.d.ts +1 -0
- package/dist/lib/core/machine/words.js +98 -0
- package/dist/lib/core/machine.d.ts +1 -0
- package/dist/lib/core/machine.js +17 -0
- package/dist/lib/core/mezz.js +31 -0
- package/dist/lib/core/natives/control.js +2 -2
- package/dist/lib/core/natives/data.js +6 -1
- package/dist/lib/core/natives/series.js +59 -9
- package/dist/lib/core/natives/text.js +3 -1
- package/dist/lib/host/browser/calendar.d.ts +34 -0
- package/dist/lib/host/browser/calendar.js +268 -0
- package/dist/lib/host/browser/count.d.ts +15 -0
- package/dist/lib/host/browser/count.js +48 -0
- package/dist/lib/host/browser/dialogs.d.ts +39 -0
- package/dist/lib/host/browser/dialogs.js +443 -0
- package/dist/lib/host/browser/drag.d.ts +70 -0
- package/dist/lib/host/browser/drag.js +268 -0
- package/dist/lib/host/browser/drawings.d.ts +30 -0
- package/dist/lib/host/browser/drawings.js +176 -0
- package/dist/lib/host/browser/events.d.ts +16 -0
- package/dist/lib/host/browser/events.js +125 -0
- package/dist/lib/host/browser/faces.d.ts +35 -0
- package/dist/lib/host/browser/faces.js +131 -0
- package/dist/lib/host/browser/fields.d.ts +16 -0
- package/dist/lib/host/browser/fields.js +322 -0
- package/dist/lib/host/browser/keys.d.ts +29 -0
- package/dist/lib/host/browser/keys.js +151 -0
- package/dist/lib/host/browser/lookup.d.ts +25 -0
- package/dist/lib/host/browser/lookup.js +275 -0
- package/dist/lib/host/browser/menus.d.ts +20 -0
- package/dist/lib/host/browser/menus.js +149 -0
- package/dist/lib/host/browser/mount.d.ts +92 -0
- package/dist/lib/host/browser/mount.js +448 -0
- package/dist/lib/host/browser/orbits.d.ts +90 -0
- package/dist/lib/host/browser/orbits.js +379 -0
- package/dist/lib/host/browser/page.d.ts +13 -0
- package/dist/lib/host/browser/page.js +35 -0
- package/dist/lib/host/browser/richtext.d.ts +19 -0
- package/dist/lib/host/browser/richtext.js +379 -0
- package/dist/lib/host/browser/row-faces.d.ts +5 -0
- package/dist/lib/host/browser/row-faces.js +74 -0
- package/dist/lib/host/browser/screens.d.ts +37 -0
- package/dist/lib/host/browser/screens.js +140 -0
- package/dist/lib/host/browser/swipe.d.ts +31 -0
- package/dist/lib/host/browser/swipe.js +178 -0
- package/dist/lib/host/browser/sync.d.ts +24 -0
- package/dist/lib/host/browser/sync.js +450 -0
- package/dist/lib/host/browser/tables.d.ts +65 -0
- package/dist/lib/host/browser/tables.js +505 -0
- package/dist/lib/host/browser/times.d.ts +14 -0
- package/dist/lib/host/browser/times.js +114 -0
- package/dist/lib/host/browser/toolbars.d.ts +17 -0
- package/dist/lib/host/browser/toolbars.js +129 -0
- package/dist/lib/host/browser/trees.d.ts +20 -0
- package/dist/lib/host/browser/trees.js +235 -0
- package/dist/lib/host/browser/uploads.d.ts +29 -0
- package/dist/lib/host/browser/uploads.js +370 -0
- package/dist/lib/host/browser/widget.d.ts +13 -0
- package/dist/lib/host/browser/widget.js +105 -0
- package/dist/lib/host/browser.d.ts +25 -0
- package/dist/lib/host/browser.js +129 -3964
- package/dist/lib/host/devlog.d.ts +11 -0
- package/dist/lib/host/devlog.js +13 -0
- package/dist/lib/host/devtools/console.d.ts +9 -0
- package/dist/lib/host/devtools/console.js +104 -0
- package/dist/lib/host/devtools/faces.d.ts +25 -0
- package/dist/lib/host/devtools/faces.js +169 -0
- package/dist/lib/host/devtools/log.d.ts +3 -0
- package/dist/lib/host/devtools/log.js +32 -0
- package/dist/lib/host/devtools/machines.d.ts +34 -0
- package/dist/lib/host/devtools/machines.js +212 -0
- package/dist/lib/host/devtools/read.d.ts +13 -0
- package/dist/lib/host/devtools/read.js +52 -0
- package/dist/lib/host/devtools/state.d.ts +90 -0
- package/dist/lib/host/devtools/state.js +123 -0
- package/dist/lib/host/devtools.d.ts +19 -0
- package/dist/lib/host/devtools.js +238 -0
- package/dist/lib/host/fonts/OFL.txt +93 -0
- package/dist/lib/host/fonts/inter-cyrillic-ext.woff2 +0 -0
- package/dist/lib/host/fonts/inter-cyrillic.woff2 +0 -0
- package/dist/lib/host/fonts/inter-greek-ext.woff2 +0 -0
- package/dist/lib/host/fonts/inter-greek.woff2 +0 -0
- package/dist/lib/host/fonts/inter-latin-ext.woff2 +0 -0
- package/dist/lib/host/fonts/inter-latin.woff2 +0 -0
- package/dist/lib/host/fonts/inter-vietnamese.woff2 +0 -0
- package/dist/lib/host/fonts.d.ts +11 -0
- package/dist/lib/host/fonts.js +30 -0
- package/dist/lib/host/icons.js +4 -0
- package/dist/lib/host/index.d.ts +5 -1
- package/dist/lib/host/index.js +110 -5
- package/dist/lib/host/js.d.ts +5 -0
- package/dist/lib/host/js.js +130 -0
- package/dist/lib/host/locale.d.ts +18 -0
- package/dist/lib/host/locale.js +75 -5
- package/dist/lib/host/markdown.d.ts +6 -0
- package/dist/lib/host/markdown.js +18 -0
- package/dist/lib/host/modules.d.ts +4 -0
- package/dist/lib/host/modules.js +157 -20
- package/dist/lib/host/motion.d.ts +32 -0
- package/dist/lib/host/motion.js +190 -0
- package/dist/lib/host/net.js +14 -3
- package/dist/lib/host/orbit.d.ts +121 -0
- package/dist/lib/host/orbit.js +374 -0
- package/dist/lib/host/palette.d.ts +17 -0
- package/dist/lib/host/palette.js +131 -0
- package/dist/lib/host/rows.d.ts +14 -0
- package/dist/lib/host/rows.js +29 -0
- package/dist/lib/host/scheduler.d.ts +8 -0
- package/dist/lib/host/scheduler.js +64 -36
- package/dist/lib/host/share.d.ts +31 -0
- package/dist/lib/host/share.js +134 -0
- package/dist/lib/host/theme/classic.d.ts +1 -0
- package/dist/lib/host/theme/classic.js +120 -0
- package/dist/lib/host/theme/cupertino.d.ts +1 -0
- package/dist/lib/host/theme/cupertino.js +65 -0
- package/dist/lib/host/theme/data.d.ts +1 -0
- package/dist/lib/host/theme/data.js +109 -0
- package/dist/lib/host/theme/devtools.d.ts +1 -0
- package/dist/lib/host/theme/devtools.js +166 -0
- package/dist/lib/host/theme/dialogs.d.ts +1 -0
- package/dist/lib/host/theme/dialogs.js +63 -0
- package/dist/lib/host/theme/fluent.d.ts +1 -0
- package/dist/lib/host/theme/fluent.js +64 -0
- package/dist/lib/host/theme/forms.d.ts +1 -0
- package/dist/lib/host/theme/forms.js +239 -0
- package/dist/lib/host/theme/fusion.d.ts +1 -0
- package/dist/lib/host/theme/fusion.js +66 -0
- package/dist/lib/host/theme/layout.d.ts +1 -0
- package/dist/lib/host/theme/layout.js +166 -0
- package/dist/lib/host/theme/media.d.ts +1 -0
- package/dist/lib/host/theme/media.js +106 -0
- package/dist/lib/host/theme/navigation.d.ts +1 -0
- package/dist/lib/host/theme/navigation.js +36 -0
- package/dist/lib/host/theme/panes.d.ts +1 -0
- package/dist/lib/host/theme/panes.js +99 -0
- package/dist/lib/host/theme/popups.d.ts +1 -0
- package/dist/lib/host/theme/popups.js +149 -0
- package/dist/lib/host/theme/responsive.d.ts +1 -0
- package/dist/lib/host/theme/responsive.js +103 -0
- package/dist/lib/host/theme/toasts.d.ts +1 -0
- package/dist/lib/host/theme/toasts.js +62 -0
- package/dist/lib/host/theme.js +19 -1179
- package/dist/lib/ui/dialect/events.trb +276 -0
- package/dist/lib/ui/dialect/faces.trb +135 -0
- package/dist/lib/ui/dialect/layout.trb +283 -0
- package/dist/lib/ui/dialect/palette.trb +87 -0
- package/dist/lib/ui/dialect/problems.trb +174 -0
- package/dist/lib/ui/dialect/reactions.trb +198 -0
- package/dist/lib/ui/dialect/rows.trb +208 -0
- package/dist/lib/ui/dialect/screens.trb +293 -0
- package/dist/lib/ui/dialect/steps.trb +203 -0
- package/dist/lib/ui/dialect/validation.trb +137 -0
- package/dist/lib/ui/dialect/view.trb +110 -0
- package/dist/lib/ui/dialect/walking.trb +98 -0
- package/dist/lib/ui/dialect/words.trb +70 -0
- package/dist/lib/ui/i18n.trb +23 -0
- package/dist/lib/ui/test.trb +12 -0
- package/dist/lib/ui/testing/actions.trb +421 -0
- package/dist/lib/ui/testing/faces.trb +148 -0
- package/dist/lib/ui/testing/server.trb +73 -0
- package/dist/lib/ui/ui.trb +25 -1234
- package/dist/trebol.js +4882 -1088
- package/editors/vscode/README.md +15 -0
- package/editors/vscode/language-configuration.json +28 -0
- package/editors/vscode/package.json +42 -0
- package/editors/vscode/syntaxes/trebol.tmLanguage.json +237 -0
- package/package.json +7 -3
- package/src/core/boot.ts +10 -7
- package/src/core/eval.ts +2 -2
- package/src/core/func.ts +4 -0
- package/src/core/machine/checks.ts +251 -0
- package/src/core/machine/events.ts +366 -0
- package/src/core/machine/running.ts +181 -0
- package/src/core/machine/shared.ts +124 -0
- package/src/core/machine/snapshot.ts +245 -0
- package/src/core/machine/spec.ts +275 -0
- package/src/core/machine/words.ts +99 -0
- package/src/core/machine.ts +20 -0
- package/src/core/mezz.ts +31 -0
- package/src/core/natives/control.ts +2 -2
- package/src/core/natives/data.ts +6 -1
- package/src/core/natives/parse.ts +1 -1
- package/src/core/natives/series.ts +55 -11
- package/src/core/natives/text.ts +2 -1
- package/src/host/browser/calendar.ts +264 -0
- package/src/host/browser/count.ts +48 -0
- package/src/host/browser/dialogs.ts +439 -0
- package/src/host/browser/drag.ts +278 -0
- package/src/host/browser/drawings.ts +178 -0
- package/src/host/browser/events.ts +117 -0
- package/src/host/browser/faces.ts +143 -0
- package/src/host/browser/fields.ts +315 -0
- package/src/host/browser/keys.ts +145 -0
- package/src/host/browser/lookup.ts +262 -0
- package/src/host/browser/menus.ts +146 -0
- package/src/host/browser/mount.ts +420 -0
- package/src/host/browser/orbits.ts +418 -0
- package/src/host/browser/page.ts +43 -0
- package/src/host/browser/richtext.ts +346 -0
- package/src/host/browser/row-faces.ts +75 -0
- package/src/host/browser/screens.ts +142 -0
- package/src/host/browser/swipe.ts +168 -0
- package/src/host/browser/sync.ts +354 -0
- package/src/host/browser/tables.ts +461 -0
- package/src/host/browser/times.ts +115 -0
- package/src/host/browser/toolbars.ts +126 -0
- package/src/host/browser/trees.ts +205 -0
- package/src/host/browser/uploads.ts +367 -0
- package/src/host/browser/widget.ts +103 -0
- package/src/host/browser.ts +128 -3747
- package/src/host/devlog.ts +16 -0
- package/src/host/devtools/console.ts +102 -0
- package/src/host/devtools/faces.ts +160 -0
- package/src/host/devtools/log.ts +34 -0
- package/src/host/devtools/machines.ts +208 -0
- package/src/host/devtools/read.ts +58 -0
- package/src/host/devtools/state.ts +148 -0
- package/src/host/devtools.ts +238 -0
- package/src/host/fonts/OFL.txt +93 -0
- package/src/host/fonts/inter-cyrillic-ext.woff2 +0 -0
- package/src/host/fonts/inter-cyrillic.woff2 +0 -0
- package/src/host/fonts/inter-greek-ext.woff2 +0 -0
- package/src/host/fonts/inter-greek.woff2 +0 -0
- package/src/host/fonts/inter-latin-ext.woff2 +0 -0
- package/src/host/fonts/inter-latin.woff2 +0 -0
- package/src/host/fonts/inter-vietnamese.woff2 +0 -0
- package/src/host/fonts.ts +40 -0
- package/src/host/icons.ts +4 -0
- package/src/host/index.ts +110 -5
- package/src/host/js.ts +127 -0
- package/src/host/locale.ts +71 -5
- package/src/host/markdown.ts +18 -0
- package/src/host/modules.ts +150 -22
- package/src/host/motion.ts +204 -0
- package/src/host/net.ts +13 -3
- package/src/host/orbit.ts +432 -0
- package/src/host/palette.ts +139 -0
- package/src/host/rows.ts +30 -0
- package/src/host/scheduler.ts +67 -36
- package/src/host/share.ts +168 -0
- package/src/host/theme/classic.ts +121 -0
- package/src/host/theme/cupertino.ts +66 -0
- package/src/host/theme/data.ts +110 -0
- package/src/host/theme/devtools.ts +167 -0
- package/src/host/theme/dialogs.ts +64 -0
- package/src/host/theme/fluent.ts +65 -0
- package/src/host/theme/forms.ts +240 -0
- package/src/host/theme/fusion.ts +67 -0
- package/src/host/theme/layout.ts +167 -0
- package/src/host/theme/media.ts +107 -0
- package/src/host/theme/navigation.ts +37 -0
- package/src/host/theme/panes.ts +100 -0
- package/src/host/theme/popups.ts +150 -0
- package/src/host/theme/responsive.ts +104 -0
- package/src/host/theme/toasts.ts +63 -0
- package/src/host/theme.ts +19 -1179
- package/src/ui/dialect/events.trb +276 -0
- package/src/ui/dialect/faces.trb +135 -0
- package/src/ui/dialect/layout.trb +283 -0
- package/src/ui/dialect/palette.trb +87 -0
- package/src/ui/dialect/problems.trb +174 -0
- package/src/ui/dialect/reactions.trb +198 -0
- package/src/ui/dialect/rows.trb +208 -0
- package/src/ui/dialect/screens.trb +293 -0
- package/src/ui/dialect/steps.trb +203 -0
- package/src/ui/dialect/validation.trb +137 -0
- package/src/ui/dialect/view.trb +110 -0
- package/src/ui/dialect/walking.trb +98 -0
- package/src/ui/dialect/words.trb +70 -0
- package/src/ui/i18n.trb +23 -0
- package/src/ui/test.trb +12 -0
- package/src/ui/testing/actions.trb +421 -0
- package/src/ui/testing/faces.trb +148 -0
- package/src/ui/testing/server.trb +73 -0
- package/src/ui/ui.trb +25 -1234
|
@@ -35,6 +35,10 @@ export function makeScheduler(rt, onError) {
|
|
|
35
35
|
schedulers.set(rt, sch);
|
|
36
36
|
return sch;
|
|
37
37
|
}
|
|
38
|
+
/** Whether a scheduler runs this runtime: a runtime of the core alone has none. */
|
|
39
|
+
export function hasScheduler(rt) {
|
|
40
|
+
return schedulers.has(rt);
|
|
41
|
+
}
|
|
38
42
|
/** The scheduler running a task's runtime. */
|
|
39
43
|
export function schedulerOf(t) {
|
|
40
44
|
const sch = schedulers.get(t.rt);
|
|
@@ -100,52 +104,76 @@ function finish(sch, ht, state) {
|
|
|
100
104
|
for (const w of ht.watchers.splice(0))
|
|
101
105
|
w(ht);
|
|
102
106
|
}
|
|
107
|
+
/** Runs one slice of a ready task; true if it yielded and has more to do. */
|
|
108
|
+
function slice(sch, ht) {
|
|
109
|
+
const r = run(ht.task, SLICE);
|
|
110
|
+
switch (r.k) {
|
|
111
|
+
case 'done':
|
|
112
|
+
ht.result = r.v;
|
|
113
|
+
finish(sch, ht, 'done');
|
|
114
|
+
break;
|
|
115
|
+
case 'error':
|
|
116
|
+
ht.error = r.e;
|
|
117
|
+
finish(sch, ht, 'failed');
|
|
118
|
+
break;
|
|
119
|
+
case 'yield':
|
|
120
|
+
return true;
|
|
121
|
+
case 'await':
|
|
122
|
+
ht.state = 'waiting';
|
|
123
|
+
r.p.then(v => {
|
|
124
|
+
if (ht.state !== 'waiting')
|
|
125
|
+
return;
|
|
126
|
+
ht.abort = null;
|
|
127
|
+
resume(ht.task, v);
|
|
128
|
+
ht.state = 'ready';
|
|
129
|
+
sch.ready.push(ht);
|
|
130
|
+
schedule(sch);
|
|
131
|
+
}, (e) => {
|
|
132
|
+
if (ht.state !== 'waiting')
|
|
133
|
+
return;
|
|
134
|
+
ht.abort = null;
|
|
135
|
+
resumeError(ht.task, asError(e));
|
|
136
|
+
ht.state = 'ready';
|
|
137
|
+
sch.ready.push(ht);
|
|
138
|
+
schedule(sch);
|
|
139
|
+
});
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
103
144
|
/** Runs ready tasks, one slice each, until none is ready; then yields. */
|
|
104
145
|
function pump(sch) {
|
|
105
146
|
sch.pumping = false;
|
|
106
147
|
const batch = sch.ready.splice(0);
|
|
107
148
|
for (const ht of batch) {
|
|
108
|
-
if (ht.state
|
|
109
|
-
|
|
110
|
-
const r = run(ht.task, SLICE);
|
|
111
|
-
switch (r.k) {
|
|
112
|
-
case 'done':
|
|
113
|
-
ht.result = r.v;
|
|
114
|
-
finish(sch, ht, 'done');
|
|
115
|
-
break;
|
|
116
|
-
case 'error':
|
|
117
|
-
ht.error = r.e;
|
|
118
|
-
finish(sch, ht, 'failed');
|
|
119
|
-
break;
|
|
120
|
-
case 'yield':
|
|
121
|
-
sch.ready.push(ht);
|
|
122
|
-
break;
|
|
123
|
-
case 'await':
|
|
124
|
-
ht.state = 'waiting';
|
|
125
|
-
r.p.then(v => {
|
|
126
|
-
if (ht.state !== 'waiting')
|
|
127
|
-
return;
|
|
128
|
-
ht.abort = null;
|
|
129
|
-
resume(ht.task, v);
|
|
130
|
-
ht.state = 'ready';
|
|
131
|
-
sch.ready.push(ht);
|
|
132
|
-
schedule(sch);
|
|
133
|
-
}, (e) => {
|
|
134
|
-
if (ht.state !== 'waiting')
|
|
135
|
-
return;
|
|
136
|
-
ht.abort = null;
|
|
137
|
-
resumeError(ht.task, asError(e));
|
|
138
|
-
ht.state = 'ready';
|
|
139
|
-
sch.ready.push(ht);
|
|
140
|
-
schedule(sch);
|
|
141
|
-
});
|
|
142
|
-
break;
|
|
143
|
-
}
|
|
149
|
+
if (ht.state === 'ready' && slice(sch, ht))
|
|
150
|
+
sch.ready.push(ht);
|
|
144
151
|
}
|
|
145
152
|
sch.afterPump?.();
|
|
146
153
|
if (sch.ready.length > 0)
|
|
147
154
|
schedule(sch);
|
|
148
155
|
}
|
|
156
|
+
/** Slices a task started with `runNow` may take before it waits its turn like the others. */
|
|
157
|
+
const NOW_SLICES = 10;
|
|
158
|
+
/**
|
|
159
|
+
* Starts a task and runs it at once, before any other, until it ends or waits;
|
|
160
|
+
* a long one goes on in turn with the rest. The browser host runs reactions
|
|
161
|
+
* this way, between a round and the repaint that follows it.
|
|
162
|
+
*/
|
|
163
|
+
export function runNow(sch, s, i = 0) {
|
|
164
|
+
const task = newTask(sch.rt, s, i);
|
|
165
|
+
const ht = { id: nextId++, task, state: 'ready', result: UNSET, error: null, abort: null, watchers: [] };
|
|
166
|
+
sch.byTask.set(task, ht);
|
|
167
|
+
sch.live++;
|
|
168
|
+
let more = true;
|
|
169
|
+
for (let n = 0; more && n < NOW_SLICES; n++)
|
|
170
|
+
more = slice(sch, ht);
|
|
171
|
+
if (more) {
|
|
172
|
+
sch.ready.push(ht);
|
|
173
|
+
schedule(sch);
|
|
174
|
+
}
|
|
175
|
+
return ht;
|
|
176
|
+
}
|
|
149
177
|
/** A rejected promise's reason as a Trebol error!. */
|
|
150
178
|
export function asError(e) {
|
|
151
179
|
if (typeof e === 'object' && e !== null && e.t === K.Error)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type Runtime } from '../core/index.ts';
|
|
2
|
+
/** What travels on the channel: text is a value molded with mold/all. */
|
|
3
|
+
export interface Envelope {
|
|
4
|
+
from: string;
|
|
5
|
+
text: string;
|
|
6
|
+
/** The id of an ask: the one who sent it waits for an envelope that acks it. */
|
|
7
|
+
ask?: string;
|
|
8
|
+
acks?: string[];
|
|
9
|
+
/** A new owner: every tab sends again what it is still waiting for. */
|
|
10
|
+
fresh?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface ChannelLike {
|
|
13
|
+
postMessage(e: Envelope): void;
|
|
14
|
+
onmessage: ((e: {
|
|
15
|
+
data: Envelope;
|
|
16
|
+
}) => void) | null;
|
|
17
|
+
close(): void;
|
|
18
|
+
}
|
|
19
|
+
export interface LocksLike {
|
|
20
|
+
request(name: string, options: {
|
|
21
|
+
ifAvailable: true;
|
|
22
|
+
}, fn: (lock: unknown) => Promise<void> | void): Promise<unknown>;
|
|
23
|
+
request(name: string, fn: (lock: unknown) => Promise<void> | void): Promise<unknown>;
|
|
24
|
+
}
|
|
25
|
+
/** Where a runtime finds channels and locks: the browser's, or a test's. */
|
|
26
|
+
export interface ShareEnv {
|
|
27
|
+
channel(name: string): ChannelLike | null;
|
|
28
|
+
locks(): LocksLike | null;
|
|
29
|
+
}
|
|
30
|
+
/** Gives a runtime its own channels and locks (tests play several tabs in one process). */
|
|
31
|
+
export declare function setShareEnv(rt: Runtime, env: ShareEnv): void;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// Host natives for shared machines: one machine for every tab or window of the
|
|
2
|
+
// same app. One tab owns it (it holds a Web Lock named after it) and runs it;
|
|
3
|
+
// the others keep a copy, which a BroadcastChannel keeps up to date and which
|
|
4
|
+
// sends its events to the owner. The machine engine (src/core/machine.ts)
|
|
5
|
+
// uses these natives only when the host has them.
|
|
6
|
+
import { K, NONE, TRUE, FALSE, string, block, text, throwError } from "../core/index.js";
|
|
7
|
+
import { native, value } from "../core/natives/define.js";
|
|
8
|
+
import { schedulerOf, hasScheduler, spawnHandler, taskResult, makeHandle, handleOf } from "./scheduler.js";
|
|
9
|
+
const browserEnv = {
|
|
10
|
+
channel: name => {
|
|
11
|
+
const B = globalThis.BroadcastChannel;
|
|
12
|
+
if (B === undefined)
|
|
13
|
+
return null;
|
|
14
|
+
const ch = new B(name);
|
|
15
|
+
// in Node a channel would keep the process alive
|
|
16
|
+
ch.unref?.();
|
|
17
|
+
return ch;
|
|
18
|
+
},
|
|
19
|
+
locks: () => globalThis.navigator?.locks ?? null,
|
|
20
|
+
};
|
|
21
|
+
const envs = new WeakMap();
|
|
22
|
+
/** Gives a runtime its own channels and locks (tests play several tabs in one process). */
|
|
23
|
+
export function setShareEnv(rt, env) {
|
|
24
|
+
envs.set(rt, env);
|
|
25
|
+
}
|
|
26
|
+
const envOf = (rt) => envs.get(rt) ?? browserEnv;
|
|
27
|
+
/** A lock held until the page goes. */
|
|
28
|
+
const forever = () => new Promise(() => { });
|
|
29
|
+
const str = (c) => text(c);
|
|
30
|
+
native('share-open', '["Opens the channel of a shared machine; none when the host has none." name [string!] heard [block!]]', (t, f) => {
|
|
31
|
+
// with no locks there is no telling who owns the machine, and with no scheduler (the core
|
|
32
|
+
// alone, as in Node with no host) nothing could hear the other tabs: it stays in this tab
|
|
33
|
+
const env = envOf(t.rt);
|
|
34
|
+
const ch = env.locks() === null || !hasScheduler(t.rt) ? null : env.channel(str(f.args[0]));
|
|
35
|
+
if (ch === null)
|
|
36
|
+
return value(NONE);
|
|
37
|
+
const sch = schedulerOf(t);
|
|
38
|
+
const heard = f.args[1];
|
|
39
|
+
const sh = { me: Math.random().toString(36).slice(2), ch, serial: 0, waiting: new Map() };
|
|
40
|
+
ch.onmessage = async ({ data: env }) => {
|
|
41
|
+
if (env.from === sh.me)
|
|
42
|
+
return;
|
|
43
|
+
try {
|
|
44
|
+
await taskResult(spawnHandler(sch, heard, { message: string(env.text), asked: env.ask === undefined ? NONE : string(env.ask) }));
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
// the scheduler has reported it
|
|
48
|
+
}
|
|
49
|
+
settle(sh, env.acks);
|
|
50
|
+
if (env.fresh)
|
|
51
|
+
for (const [id, w] of sh.waiting)
|
|
52
|
+
ch.postMessage({ from: sh.me, text: w.text, ask: id });
|
|
53
|
+
};
|
|
54
|
+
return value(makeHandle('share', sh));
|
|
55
|
+
});
|
|
56
|
+
function settle(sh, acks) {
|
|
57
|
+
for (const id of acks ?? []) {
|
|
58
|
+
const w = sh.waiting.get(id);
|
|
59
|
+
if (w === undefined)
|
|
60
|
+
continue;
|
|
61
|
+
sh.waiting.delete(id);
|
|
62
|
+
w.done();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const notShared = () => throwError('script', 'bad-share', 'not the channel of a shared machine');
|
|
66
|
+
native('share-post', '["Sends a value to every other tab; acks are asks it answers, also this tab\'s own." channel [handle!] message [string!] acks [block!] fresh [logic!]]', (_t, f) => {
|
|
67
|
+
const sh = handleOf(f.args[0], 'share');
|
|
68
|
+
if (sh === null)
|
|
69
|
+
return notShared();
|
|
70
|
+
const acks = f.args[2].s.data.slice(f.args[2].i).map(str);
|
|
71
|
+
const env = { from: sh.me, text: str(f.args[1]) };
|
|
72
|
+
if (acks.length > 0)
|
|
73
|
+
env.acks = acks;
|
|
74
|
+
if (f.args[3].t === K.Logic && f.args[3].v)
|
|
75
|
+
env.fresh = true;
|
|
76
|
+
sh.ch.postMessage(env);
|
|
77
|
+
settle(sh, acks);
|
|
78
|
+
return value(NONE);
|
|
79
|
+
});
|
|
80
|
+
native('share-ask', '["Sends a value to the owner and waits until an answer acks it." channel [handle!] message [string!]]', (_t, f, v) => {
|
|
81
|
+
// called again with what the wait gave
|
|
82
|
+
if (f.phase === 1)
|
|
83
|
+
return value(v);
|
|
84
|
+
f.phase = 1;
|
|
85
|
+
const sh = handleOf(f.args[0], 'share');
|
|
86
|
+
if (sh === null)
|
|
87
|
+
return notShared();
|
|
88
|
+
const msg = str(f.args[1]);
|
|
89
|
+
const id = `${sh.me}-${++sh.serial}`;
|
|
90
|
+
return {
|
|
91
|
+
k: 'await',
|
|
92
|
+
p: new Promise(resolve => {
|
|
93
|
+
sh.waiting.set(id, { text: msg, done: () => resolve(NONE) });
|
|
94
|
+
sh.ch.postMessage({ from: sh.me, text: msg, ask: id });
|
|
95
|
+
}),
|
|
96
|
+
};
|
|
97
|
+
});
|
|
98
|
+
native('share-asks', '["What this tab asked and is still waiting for, as a block of id and message." channel [handle!]]', (_t, f) => {
|
|
99
|
+
const sh = handleOf(f.args[0], 'share');
|
|
100
|
+
if (sh === null)
|
|
101
|
+
return notShared();
|
|
102
|
+
const out = [];
|
|
103
|
+
for (const [id, w] of sh.waiting)
|
|
104
|
+
out.push(string(id), string(w.text));
|
|
105
|
+
return value(block(out));
|
|
106
|
+
});
|
|
107
|
+
native('share-lock', '["Takes the lock of a shared machine if it is free (true); else gives false and evaluates took when it comes free." name [string!] took [block!]]', (t, f, v) => {
|
|
108
|
+
if (f.phase === 1)
|
|
109
|
+
return value(v);
|
|
110
|
+
f.phase = 1;
|
|
111
|
+
const locks = envOf(t.rt).locks();
|
|
112
|
+
if (locks === null || !hasScheduler(t.rt))
|
|
113
|
+
return value(TRUE);
|
|
114
|
+
const sch = schedulerOf(t);
|
|
115
|
+
const name = str(f.args[0]);
|
|
116
|
+
const took = f.args[1];
|
|
117
|
+
return {
|
|
118
|
+
k: 'await',
|
|
119
|
+
p: new Promise(resolve => {
|
|
120
|
+
void locks.request(name, { ifAvailable: true }, lock => {
|
|
121
|
+
if (lock !== null) {
|
|
122
|
+
resolve(TRUE);
|
|
123
|
+
return forever();
|
|
124
|
+
}
|
|
125
|
+
resolve(FALSE);
|
|
126
|
+
void locks.request(name, () => {
|
|
127
|
+
spawnHandler(sch, took, {});
|
|
128
|
+
return forever();
|
|
129
|
+
});
|
|
130
|
+
return undefined;
|
|
131
|
+
});
|
|
132
|
+
}),
|
|
133
|
+
};
|
|
134
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const CLASSIC: string;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
// What the classic skin changes on top of the component rules.
|
|
2
|
+
export const CLASSIC = String.raw `
|
|
3
|
+
/* classic: controls in relief on a grey window, sunken wells for what is typed, title bars on dialogs */
|
|
4
|
+
:root {
|
|
5
|
+
--tb-raise: inset 1px 1px 0 var(--tb-bevel-hi), inset -1px -1px 0 var(--tb-bevel-lo);
|
|
6
|
+
--tb-sink: inset 1px 1px 0 var(--tb-bevel-lo), inset -1px -1px 0 var(--tb-bevel-hi);
|
|
7
|
+
--tb-drop: 3px 3px 0 color-mix(in oklch, var(--tb-bevel-lo) 60%, transparent);
|
|
8
|
+
--tb-ring: 0 0 0 2px var(--tb-focus);
|
|
9
|
+
--tb-face: linear-gradient(var(--tb-face-hi), var(--tb-face-lo));
|
|
10
|
+
}
|
|
11
|
+
body { font-size: 14px; -webkit-font-smoothing: auto; }
|
|
12
|
+
.tb-title { font-weight: 700; letter-spacing: 0; color: var(--tb-primary); text-shadow: 1px 1px 0 var(--tb-bevel-hi); }
|
|
13
|
+
.tb-heading, .tb-panel > .tb-panel-title, .tb-dialog-title { font-weight: 700; letter-spacing: 0; }
|
|
14
|
+
.tb-label { font-weight: 700; font-size: 13px; }
|
|
15
|
+
.tb-divider { border-top: 1px solid var(--tb-bevel-lo); border-bottom: 1px solid var(--tb-bevel-hi); }
|
|
16
|
+
|
|
17
|
+
.tb-panel { border: 1px solid var(--tb-border-strong); border-radius: var(--tb-radius); box-shadow: var(--tb-raise); padding: var(--tb-space-5); }
|
|
18
|
+
.tb-panel.tb-primary { box-shadow: var(--tb-raise); }
|
|
19
|
+
.tb-panel:focus-visible, .tb-panel.tb-primary:focus-visible { box-shadow: var(--tb-raise), var(--tb-ring); }
|
|
20
|
+
.tb-tile:hover { background: var(--tb-face); border-color: var(--tb-border-strong); box-shadow: var(--tb-raise); }
|
|
21
|
+
|
|
22
|
+
/* buttons: a face lit from the top left; pressed, it sinks */
|
|
23
|
+
.tb-button { font-size: 13px; font-weight: 700; padding: 0 var(--tb-space-4); border: 1px solid var(--tb-border-strong); background: var(--tb-face); box-shadow: var(--tb-raise); transition: none; }
|
|
24
|
+
.tb-button:hover { background: linear-gradient(var(--tb-bevel-hi), var(--tb-face-hi)); border-color: var(--tb-border-strong); }
|
|
25
|
+
.tb-button:active:not(:disabled, [aria-disabled="true"]) { background: linear-gradient(var(--tb-face-lo), var(--tb-face-hi)); box-shadow: var(--tb-sink); }
|
|
26
|
+
.tb-button:focus-visible { box-shadow: var(--tb-raise), var(--tb-ring); }
|
|
27
|
+
.tb-button:disabled, .tb-button[aria-disabled="true"] { box-shadow: var(--tb-raise); }
|
|
28
|
+
.tb-button.tb-primary { --tb-tint: var(--tb-primary); }
|
|
29
|
+
.tb-button.tb-accent { --tb-tint: var(--tb-accent); }
|
|
30
|
+
.tb-button.tb-danger { --tb-tint: var(--tb-danger); }
|
|
31
|
+
.tb-button:is(.tb-primary, .tb-accent, .tb-danger), .tb-button:is(.tb-primary, .tb-accent, .tb-danger):hover, .tb-button.tb-primary[aria-disabled="true"]:hover {
|
|
32
|
+
background: linear-gradient(color-mix(in oklch, var(--tb-tint) 85%, var(--tb-bevel-hi)), var(--tb-tint));
|
|
33
|
+
border-color: color-mix(in oklch, var(--tb-tint) 50%, var(--tb-border-strong));
|
|
34
|
+
box-shadow: inset 1px 1px 0 color-mix(in oklch, var(--tb-bevel-hi) 45%, transparent), inset -1px -1px 0 color-mix(in oklch, var(--tb-bevel-lo) 60%, transparent);
|
|
35
|
+
}
|
|
36
|
+
.tb-button:is(.tb-primary, .tb-accent, .tb-danger):hover:not(:disabled, [aria-disabled="true"]) { filter: brightness(1.08); }
|
|
37
|
+
.tb-button:is(.tb-primary, .tb-accent, .tb-danger):active:not(:disabled, [aria-disabled="true"]) { background: var(--tb-tint); box-shadow: inset 1px 1px 0 color-mix(in oklch, var(--tb-bevel-lo) 60%, transparent); }
|
|
38
|
+
.tb-button:is(.tb-primary, .tb-accent, .tb-danger):focus-visible { box-shadow: var(--tb-raise), var(--tb-ring); }
|
|
39
|
+
.tb-toolbar { background: var(--tb-face); border: 1px solid var(--tb-border-strong); border-radius: var(--tb-radius); box-shadow: var(--tb-raise); }
|
|
40
|
+
.tb-toolbar > .tb-button:not(.tb-primary, .tb-accent, .tb-danger) { box-shadow: none; }
|
|
41
|
+
.tb-toolbar > .tb-button:not(.tb-primary, .tb-accent, .tb-danger):hover { background: var(--tb-face); border-color: var(--tb-border-strong); box-shadow: var(--tb-raise); }
|
|
42
|
+
.tb-toolbar > .tb-button:not(.tb-primary, .tb-accent, .tb-danger):focus-visible { box-shadow: var(--tb-ring); }
|
|
43
|
+
.tb-toolbar > .tb-divider { border-left-color: var(--tb-bevel-lo); border-right: 1px solid var(--tb-bevel-hi); border-bottom: 0; }
|
|
44
|
+
.tb-rich-tool:hover { background: var(--tb-face); box-shadow: var(--tb-raise); color: var(--tb-text); }
|
|
45
|
+
|
|
46
|
+
/* what is typed sits in a sunken well; a choice is a button that drops a list */
|
|
47
|
+
.tb-input { border: 1px solid var(--tb-border-strong); box-shadow: var(--tb-sink); transition: none; }
|
|
48
|
+
.tb-input:focus, .tb-rich-box:focus { border-color: var(--tb-focus); box-shadow: var(--tb-sink), 0 0 0 1px var(--tb-focus); }
|
|
49
|
+
.tb-invalid .tb-input:focus { box-shadow: var(--tb-sink), 0 0 0 1px var(--tb-danger); }
|
|
50
|
+
.tb-input[readonly], .tb-input.tb-rich-box[aria-readonly="true"] { background: var(--tb-bg); border-color: var(--tb-border); box-shadow: none; color: var(--tb-text); }
|
|
51
|
+
select.tb-input {
|
|
52
|
+
font-weight: 700;
|
|
53
|
+
font-size: 13px;
|
|
54
|
+
background-image: linear-gradient(45deg, transparent 50%, var(--tb-text) 50%), linear-gradient(135deg, var(--tb-text) 50%, transparent 50%), var(--tb-face);
|
|
55
|
+
background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%, 0 0;
|
|
56
|
+
background-size: 5px 5px, 5px 5px, 100% 100%;
|
|
57
|
+
box-shadow: var(--tb-raise);
|
|
58
|
+
}
|
|
59
|
+
select.tb-input:focus { box-shadow: var(--tb-raise), var(--tb-ring); }
|
|
60
|
+
.tb-switch input, .tb-switch input:focus-visible { border-radius: var(--tb-radius); box-shadow: var(--tb-sink); }
|
|
61
|
+
.tb-switch input:focus-visible { box-shadow: var(--tb-sink), var(--tb-ring); }
|
|
62
|
+
.tb-switch input::before { border-radius: var(--tb-radius); background: var(--tb-face); box-shadow: var(--tb-raise), 0 0 0 1px var(--tb-border-strong); }
|
|
63
|
+
/* a slider runs in a sunken groove under a raised handle */
|
|
64
|
+
.tb-range::-webkit-slider-runnable-track { border-radius: var(--tb-radius); box-shadow: var(--tb-sink); }
|
|
65
|
+
.tb-range::-moz-range-track { border-radius: var(--tb-radius); box-shadow: var(--tb-sink); }
|
|
66
|
+
.tb-range::-webkit-slider-thumb { width: 12px; border: 0; border-radius: var(--tb-radius); background: var(--tb-face); box-shadow: var(--tb-raise), 0 0 0 1px var(--tb-border-strong); }
|
|
67
|
+
.tb-range::-moz-range-thumb { width: 12px; border: 0; border-radius: var(--tb-radius); background: var(--tb-face); box-shadow: var(--tb-raise), 0 0 0 1px var(--tb-border-strong); }
|
|
68
|
+
.tb-range:focus-visible::-webkit-slider-thumb { box-shadow: var(--tb-raise), 0 0 0 1px var(--tb-border-strong), var(--tb-ring); }
|
|
69
|
+
.tb-range:focus-visible::-moz-range-thumb { box-shadow: var(--tb-raise), 0 0 0 1px var(--tb-border-strong), var(--tb-ring); }
|
|
70
|
+
.tb-upload { box-shadow: var(--tb-sink); }
|
|
71
|
+
.tb-date-button { top: 1px; right: 1px; bottom: 1px; width: calc(var(--tb-control) - 2px); border-left: 1px solid var(--tb-border-strong); border-radius: 0; background: var(--tb-face); box-shadow: var(--tb-raise); color: var(--tb-text); }
|
|
72
|
+
.tb-scroll { background: var(--tb-surface); border-color: var(--tb-border-strong); box-shadow: var(--tb-sink); }
|
|
73
|
+
.tb-scroll:focus-visible { box-shadow: var(--tb-sink), var(--tb-ring); }
|
|
74
|
+
|
|
75
|
+
/* progress: a sunken trough filled with blocks */
|
|
76
|
+
.tb-progress { height: 18px; padding: 2px; border: 1px solid var(--tb-border-strong); border-radius: var(--tb-radius); background: var(--tb-surface); box-shadow: var(--tb-sink); }
|
|
77
|
+
.tb-progress-bar { --tb-bar: var(--tb-primary); border-radius: 0; background: repeating-linear-gradient(90deg, var(--tb-bar) 0 10px, transparent 10px 12px); }
|
|
78
|
+
.tb-success .tb-progress-bar { --tb-bar: var(--tb-success); background: repeating-linear-gradient(90deg, var(--tb-bar) 0 10px, transparent 10px 12px); }
|
|
79
|
+
.tb-warning .tb-progress-bar { --tb-bar: var(--tb-warning); background: repeating-linear-gradient(90deg, var(--tb-bar) 0 10px, transparent 10px 12px); }
|
|
80
|
+
.tb-danger .tb-progress-bar { --tb-bar: var(--tb-danger); background: repeating-linear-gradient(90deg, var(--tb-bar) 0 10px, transparent 10px 12px); }
|
|
81
|
+
.tb-accent .tb-progress-bar { --tb-bar: var(--tb-accent); background: repeating-linear-gradient(90deg, var(--tb-bar) 0 10px, transparent 10px 12px); }
|
|
82
|
+
|
|
83
|
+
/* tables and lists: a sunken frame, buttons for headers, what is chosen in the primary color */
|
|
84
|
+
.tb-table-wrap, .tb-list { border: 1px solid; border-color: var(--tb-bevel-lo) var(--tb-bevel-hi) var(--tb-bevel-hi) var(--tb-bevel-lo); border-radius: var(--tb-radius); box-shadow: none; }
|
|
85
|
+
.tb-table th { color: var(--tb-text); font-weight: 700; padding: var(--tb-space-2) var(--tb-space-3); background: var(--tb-face); border-bottom: 1px solid var(--tb-border-strong); box-shadow: var(--tb-raise); }
|
|
86
|
+
.tb-sort { padding: var(--tb-space-2) var(--tb-space-3); }
|
|
87
|
+
.tb-table tfoot td { background: var(--tb-bg); border-top-color: var(--tb-border-strong); }
|
|
88
|
+
@media (min-width: 641px) {
|
|
89
|
+
.tb-table td { padding: var(--tb-space-2) var(--tb-space-3); border-right: 1px solid var(--tb-border); }
|
|
90
|
+
.tb-table th { border-right: 1px solid var(--tb-border-strong); }
|
|
91
|
+
.tb-table tr > :last-child { border-right: 0; }
|
|
92
|
+
}
|
|
93
|
+
.tb-selectable :is(tbody > tr, .tb-list > li).tb-selected, .tb-tree li.tb-selected > .tb-tree-row { background: var(--tb-primary); color: var(--tb-on-primary); }
|
|
94
|
+
.tb-list > li.tb-selected .tb-list-secondary, .tb-tree li.tb-selected > .tb-tree-row .tb-tree-toggle { color: inherit; }
|
|
95
|
+
.tb-selectable tbody tr.tb-selected:focus-visible, .tb-selectable .tb-list > li.tb-selected:focus-visible { box-shadow: inset 0 0 0 2px var(--tb-focus), inset 0 0 0 3px var(--tb-on-primary); }
|
|
96
|
+
.tb-tree-row { border-radius: 0; }
|
|
97
|
+
|
|
98
|
+
/* tabs: raised tabs on a line; the chosen one is taller and opens onto what it shows */
|
|
99
|
+
.tb-tablist { gap: 2px; padding: 0 var(--tb-space-2); box-shadow: inset 0 -1px 0 var(--tb-border-strong); }
|
|
100
|
+
.tb-tab { font-size: 13px; font-weight: 700; min-height: calc(var(--tb-control) - 4px); margin-top: 4px; border: 1px solid var(--tb-border-strong); border-bottom: 0; border-radius: var(--tb-radius) var(--tb-radius) 0 0; background: var(--tb-face); color: var(--tb-muted); box-shadow: inset 1px 1px 0 var(--tb-bevel-hi); }
|
|
101
|
+
.tb-tab[aria-selected="true"] { margin-top: 0; min-height: var(--tb-control); background: var(--tb-bg); color: var(--tb-text); }
|
|
102
|
+
|
|
103
|
+
/* what floats: raised, with a hard shadow; the item under the pointer or the keys in the primary color */
|
|
104
|
+
.tb-menu, .tb-lookup-list, .tb-calendar { border: 1px solid var(--tb-border-strong); border-radius: var(--tb-radius); box-shadow: var(--tb-raise), var(--tb-drop); animation: none; }
|
|
105
|
+
.tb-menu-item, .tb-lookup-option { border-radius: 0; }
|
|
106
|
+
.tb-menu-item:focus, .tb-lookup-option:hover, .tb-lookup-option[aria-selected="true"] { background: var(--tb-primary); color: var(--tb-on-primary); }
|
|
107
|
+
.tb-menu-item:focus svg { color: inherit; }
|
|
108
|
+
.tb-menu-divider { background: var(--tb-bevel-lo); box-shadow: 0 1px 0 var(--tb-bevel-hi); }
|
|
109
|
+
.tb-calendar-step, .tb-upload-remove { background: var(--tb-face); border: 1px solid var(--tb-border-strong); box-shadow: var(--tb-raise); color: var(--tb-text); }
|
|
110
|
+
.tb-toast { background: var(--tb-raised); color: var(--tb-text); border: 1px solid var(--tb-border-strong); border-radius: var(--tb-radius); box-shadow: var(--tb-raise), var(--tb-drop); font-weight: 700; }
|
|
111
|
+
.tb-drag-ghost { border-color: var(--tb-border-strong); box-shadow: var(--tb-raise), var(--tb-drop); }
|
|
112
|
+
|
|
113
|
+
/* dialogs: a window with a title bar */
|
|
114
|
+
.tb-dialog { border: 1px solid var(--tb-border-strong); border-radius: var(--tb-radius); box-shadow: var(--tb-raise), var(--tb-drop); animation: none; }
|
|
115
|
+
.tb-dialog-head { margin: 3px 3px 0; padding: var(--tb-space-1) var(--tb-space-1) var(--tb-space-1) var(--tb-space-4); background: linear-gradient(90deg, var(--tb-primary), color-mix(in oklch, var(--tb-primary) 60%, var(--tb-bevel-hi))); color: var(--tb-on-primary); }
|
|
116
|
+
.tb-dialog-title { font-size: 14px; }
|
|
117
|
+
.tb-dialog-close, .tb-dialog-close:hover { width: 24px; height: 24px; font-size: 16px; border: 1px solid var(--tb-border-strong); background: var(--tb-face); color: var(--tb-text); box-shadow: var(--tb-raise); }
|
|
118
|
+
.tb-dialog-close:focus-visible { box-shadow: var(--tb-raise), var(--tb-ring); }
|
|
119
|
+
.tb-dialog-body { padding-top: var(--tb-space-5); }
|
|
120
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const CUPERTINO: string;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// What the cupertino skin changes on top of the component rules.
|
|
2
|
+
export const CUPERTINO = String.raw `
|
|
3
|
+
/* cupertino: recalls the Mac: small controls on a light window, labels to the right, segmented tabs, translucent menus */
|
|
4
|
+
body { font-size: 13px; }
|
|
5
|
+
.tb-title { font-size: 26px; font-weight: 700; letter-spacing: -0.01em; }
|
|
6
|
+
.tb-heading { font-size: 17px; font-weight: 700; }
|
|
7
|
+
.tb-panel { border-radius: 10px; border-color: var(--tb-border); box-shadow: none; padding: var(--tb-space-5); }
|
|
8
|
+
.tb-panel > .tb-panel-title { font-size: 13px; font-weight: 700; }
|
|
9
|
+
.tb-label { font-size: 13px; font-weight: 400; }
|
|
10
|
+
:is(.tb-form, .tb-form > .tb-panel, .tb-form > .tb-panel > .tb-panel, .tb-form > .tb-steps > .tb-step-panel) > .tb-field > .tb-label { text-align: right; }
|
|
11
|
+
@container (max-width: 420px) { :is(.tb-form, .tb-form > .tb-panel, .tb-form > .tb-panel > .tb-panel, .tb-form > .tb-steps > .tb-step-panel) > .tb-field > .tb-label { text-align: left; } }
|
|
12
|
+
.tb-button { font-size: 13px; font-weight: 400; padding: 0 var(--tb-space-4); border: 0; border-radius: 6px; background: var(--tb-surface); box-shadow: 0 0 0 1px var(--tb-border), var(--tb-shadow-1); }
|
|
13
|
+
.tb-button:hover { background: var(--tb-surface); }
|
|
14
|
+
.tb-button:active:not(:disabled, [aria-disabled="true"]) { background: var(--tb-border); }
|
|
15
|
+
.tb-button:focus-visible { box-shadow: 0 0 0 1px var(--tb-border), 0 0 0 4px var(--tb-focus-ring); }
|
|
16
|
+
.tb-button.tb-primary, .tb-button.tb-primary:hover, .tb-button.tb-primary[aria-disabled="true"]:hover { background: linear-gradient(color-mix(in oklch, var(--tb-primary) 85%, var(--tb-on-primary)), var(--tb-primary)); box-shadow: var(--tb-shadow-1); }
|
|
17
|
+
.tb-button.tb-primary:active:not(:disabled, [aria-disabled="true"]) { background: var(--tb-primary-hover); }
|
|
18
|
+
.tb-button.tb-primary:focus-visible { box-shadow: 0 0 0 4px var(--tb-focus-ring); }
|
|
19
|
+
.tb-toolbar { background: transparent; border: 0; padding: 0; }
|
|
20
|
+
.tb-toolbar > .tb-button:not(.tb-primary, .tb-accent, .tb-danger) { box-shadow: none; }
|
|
21
|
+
.tb-toolbar > .tb-button:not(.tb-primary, .tb-accent, .tb-danger):hover { background: var(--tb-border); }
|
|
22
|
+
.tb-toolbar > .tb-button:not(.tb-primary, .tb-accent, .tb-danger):focus-visible { box-shadow: 0 0 0 3px var(--tb-focus-ring); }
|
|
23
|
+
.tb-input { border-radius: 5px; border-color: var(--tb-border-strong); }
|
|
24
|
+
/* a choice is a pop-up button: the arrow in a small square of the primary color */
|
|
25
|
+
select.tb-input {
|
|
26
|
+
border: 0;
|
|
27
|
+
border-radius: 6px;
|
|
28
|
+
box-shadow: 0 0 0 1px var(--tb-border), var(--tb-shadow-1);
|
|
29
|
+
background-image: linear-gradient(45deg, transparent 50%, var(--tb-on-primary) 50%), linear-gradient(135deg, var(--tb-on-primary) 50%, transparent 50%), linear-gradient(var(--tb-primary), var(--tb-primary));
|
|
30
|
+
background-position: calc(100% - 15px) 45%, calc(100% - 11px) 45%, calc(100% - 4px) 50%;
|
|
31
|
+
background-size: 4px 4px, 4px 4px, 20px calc(100% - 8px);
|
|
32
|
+
padding-right: 34px;
|
|
33
|
+
}
|
|
34
|
+
select.tb-input:focus { box-shadow: 0 0 0 1px var(--tb-border), 0 0 0 4px var(--tb-focus-ring); }
|
|
35
|
+
.tb-tablist { align-self: center; gap: 0; padding: 2px; border-radius: 7px; background: var(--tb-border); box-shadow: none; }
|
|
36
|
+
.tb-tab { min-height: 24px; padding: 0 var(--tb-space-4); border: 0; border-radius: 5px; font-size: 13px; font-weight: 400; color: var(--tb-text); }
|
|
37
|
+
.tb-tab[aria-selected="true"] { background: var(--tb-segment); color: var(--tb-text); box-shadow: var(--tb-shadow-1); }
|
|
38
|
+
.tb-tab:focus-visible { box-shadow: 0 0 0 3px var(--tb-focus-ring); border-radius: 5px; }
|
|
39
|
+
.tb-table-wrap { border-radius: 8px; box-shadow: none; }
|
|
40
|
+
.tb-table th { background: var(--tb-surface); color: var(--tb-text); font-size: 12px; font-weight: 400; padding: 6px var(--tb-space-3); }
|
|
41
|
+
.tb-sort { padding: 6px var(--tb-space-3); }
|
|
42
|
+
@media (min-width: 641px) {
|
|
43
|
+
.tb-table th:not(:last-child) { box-shadow: inset -1px 0 0 var(--tb-border); }
|
|
44
|
+
.tb-table td { height: auto; padding: 6px var(--tb-space-3); border-bottom: 0; }
|
|
45
|
+
.tb-table tbody tr:nth-child(even) { background: var(--tb-bg); }
|
|
46
|
+
}
|
|
47
|
+
.tb-list { padding: 4px; box-shadow: none; }
|
|
48
|
+
.tb-list > li { border-bottom: 0; border-radius: 6px; }
|
|
49
|
+
.tb-selectable :is(tbody > tr, .tb-list > li).tb-selected, .tb-tree li.tb-selected > .tb-tree-row { background: var(--tb-primary); color: var(--tb-on-primary); }
|
|
50
|
+
.tb-list > li.tb-selected .tb-list-secondary, .tb-tree li.tb-selected > .tb-tree-row .tb-tree-toggle { color: inherit; }
|
|
51
|
+
.tb-tree-row { border-radius: 6px; }
|
|
52
|
+
.tb-menu, .tb-lookup-list { padding: 5px; border-radius: 8px; background: color-mix(in oklch, var(--tb-raised) 82%, transparent); -webkit-backdrop-filter: blur(24px) saturate(1.6); backdrop-filter: blur(24px) saturate(1.6); animation: none; }
|
|
53
|
+
.tb-menu-item { min-height: 24px; border-radius: 5px; font-size: 13px; }
|
|
54
|
+
.tb-menu-item:focus, .tb-lookup-option:hover, .tb-lookup-option[aria-selected="true"] { background: var(--tb-primary); color: var(--tb-on-primary); }
|
|
55
|
+
.tb-menu-item:focus svg { color: inherit; }
|
|
56
|
+
.tb-calendar { border-radius: 10px; }
|
|
57
|
+
/* dialogs: a sheet with its title centred, closed by a red dot on the left */
|
|
58
|
+
.tb-dialog { border: 1px solid var(--tb-border); border-radius: 12px; }
|
|
59
|
+
.tb-dialog-head { position: relative; justify-content: center; padding: var(--tb-space-3) var(--tb-space-6) 0; }
|
|
60
|
+
.tb-dialog-title { font-size: 13px; font-weight: 700; }
|
|
61
|
+
.tb-dialog-close, .tb-dialog-close:hover { position: absolute; left: 12px; top: 12px; width: 14px; height: 14px; border-radius: 50%; background: var(--tb-danger); color: transparent; font-size: 12px; line-height: 14px; }
|
|
62
|
+
.tb-dialog-close:hover { color: var(--tb-on-danger); }
|
|
63
|
+
.tb-toast { border-radius: 10px; background: color-mix(in oklch, var(--tb-text) 80%, transparent); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); }
|
|
64
|
+
.tb-scroll { border-radius: 8px; background: var(--tb-surface); }
|
|
65
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const DATA: string;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// Component rules of the theme: tables, lists and boards.
|
|
2
|
+
// Only token variables appear here, never raw values of color.
|
|
3
|
+
export const DATA = String.raw `
|
|
4
|
+
/* tables: rows become cards on narrow screens */
|
|
5
|
+
.tb-table-wrap, .tb-list-wrap { min-width: 0; }
|
|
6
|
+
.tb-table-wrap {
|
|
7
|
+
overflow-x: auto;
|
|
8
|
+
background: var(--tb-surface);
|
|
9
|
+
border: var(--tb-line) solid var(--tb-border);
|
|
10
|
+
border-radius: var(--tb-radius-lg);
|
|
11
|
+
box-shadow: var(--tb-shadow-1);
|
|
12
|
+
}
|
|
13
|
+
.tb-table { width: 100%; border-collapse: collapse; font-size: 14px; }
|
|
14
|
+
.tb-table th {
|
|
15
|
+
text-align: left;
|
|
16
|
+
font-size: 13px;
|
|
17
|
+
font-weight: 600;
|
|
18
|
+
color: var(--tb-muted);
|
|
19
|
+
white-space: nowrap;
|
|
20
|
+
padding: var(--tb-space-3) var(--tb-space-4);
|
|
21
|
+
background: var(--tb-bg);
|
|
22
|
+
border-bottom: var(--tb-line) solid var(--tb-border);
|
|
23
|
+
}
|
|
24
|
+
.tb-table td { padding: var(--tb-space-3) var(--tb-space-4); border-bottom: var(--tb-line) solid var(--tb-border); height: var(--tb-control); }
|
|
25
|
+
.tb-table tbody tr:last-child td { border-bottom: 0; }
|
|
26
|
+
.tb-table .tb-num { text-align: right; font-variant-numeric: tabular-nums; }
|
|
27
|
+
.tb-table-wrap:has(tbody:empty) thead { display: none; }
|
|
28
|
+
/* the room of the rows a long table does not draw */
|
|
29
|
+
.tb-table .tb-room[hidden] { display: none; }
|
|
30
|
+
.tb-table.tb-fixed { table-layout: fixed; }
|
|
31
|
+
.tb-table .tb-room :is(tr, td) { padding: 0; border: 0; margin: 0; background: none; box-shadow: none; }
|
|
32
|
+
.tb-table th:has(> .tb-sort) { padding: 0; }
|
|
33
|
+
.tb-sort {
|
|
34
|
+
display: flex;
|
|
35
|
+
align-items: center;
|
|
36
|
+
gap: var(--tb-space-1);
|
|
37
|
+
width: 100%;
|
|
38
|
+
padding: var(--tb-space-3) var(--tb-space-4);
|
|
39
|
+
border: 0;
|
|
40
|
+
background: none;
|
|
41
|
+
font: inherit;
|
|
42
|
+
color: inherit;
|
|
43
|
+
text-align: inherit;
|
|
44
|
+
cursor: pointer;
|
|
45
|
+
border-radius: 0;
|
|
46
|
+
}
|
|
47
|
+
.tb-sort:hover, th[aria-sort] > .tb-sort { color: var(--tb-text); }
|
|
48
|
+
.tb-sort:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--tb-focus); }
|
|
49
|
+
.tb-sort svg { width: 14px; height: 14px; flex: none; }
|
|
50
|
+
.tb-sort .tb-sort-idle { opacity: 0; transition: opacity var(--tb-fast) var(--tb-ease); }
|
|
51
|
+
.tb-sort:hover .tb-sort-idle, .tb-sort:focus-visible .tb-sort-idle { opacity: 0.5; }
|
|
52
|
+
.tb-table tfoot[hidden] { display: none !important; }
|
|
53
|
+
.tb-table tfoot td {
|
|
54
|
+
font-weight: 600;
|
|
55
|
+
background: var(--tb-bg);
|
|
56
|
+
border-top: var(--tb-line) solid var(--tb-border);
|
|
57
|
+
border-bottom: 0;
|
|
58
|
+
}
|
|
59
|
+
.tb-selectable tbody:not(.tb-room) tr:not(.tb-group-head, .tb-group-foot), .tb-selectable .tb-list > li:not(.tb-group-head, .tb-group-foot) { cursor: pointer; transition: background var(--tb-fast) var(--tb-ease); }
|
|
60
|
+
.tb-selectable tbody:not(.tb-room) tr:not(.tb-group-head, .tb-group-foot):hover, .tb-selectable .tb-list > li:not(.tb-group-head, .tb-group-foot):hover { background: var(--tb-bg); }
|
|
61
|
+
.tb-selectable tbody tr:focus-visible, .tb-selectable .tb-list > li:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--tb-focus); }
|
|
62
|
+
.tb-table tr.tb-selected, .tb-list > li.tb-selected { background: var(--tb-primary-soft); }
|
|
63
|
+
/* the head and foot of a group in the rows: a title the width of the row, and its subtotals */
|
|
64
|
+
.tb-table .tb-group-head > th { font-size: 14px; color: var(--tb-text); white-space: normal; background: var(--tb-bg); border-top: var(--tb-line) solid var(--tb-border); }
|
|
65
|
+
.tb-table .tb-group-head.tb-level-2 > th { font-weight: 500; background: var(--tb-surface); }
|
|
66
|
+
.tb-table .tb-group-foot > td { font-weight: 600; background: var(--tb-bg); }
|
|
67
|
+
.tb-table .tb-level-2 > :first-child, .tb-list > .tb-level-2 { padding-left: calc(var(--tb-space-4) + var(--tb-space-5)); }
|
|
68
|
+
.tb-list > li.tb-group-head { font-weight: 600; background: var(--tb-bg); }
|
|
69
|
+
.tb-list > li.tb-group-foot { font-weight: 600; }
|
|
70
|
+
.tb-empty { margin: 0; padding: var(--tb-space-6) var(--tb-space-4); text-align: center; color: var(--tb-muted); }
|
|
71
|
+
.tb-empty[hidden] { display: none; }
|
|
72
|
+
|
|
73
|
+
.tb-list {
|
|
74
|
+
list-style: none;
|
|
75
|
+
margin: 0;
|
|
76
|
+
padding: 0;
|
|
77
|
+
background: var(--tb-surface);
|
|
78
|
+
border: var(--tb-line) solid var(--tb-border);
|
|
79
|
+
border-radius: var(--tb-radius-lg);
|
|
80
|
+
box-shadow: var(--tb-shadow-1);
|
|
81
|
+
overflow: hidden;
|
|
82
|
+
}
|
|
83
|
+
.tb-list:empty { display: none; }
|
|
84
|
+
.tb-list > li {
|
|
85
|
+
display: flex;
|
|
86
|
+
align-items: center;
|
|
87
|
+
gap: var(--tb-space-3);
|
|
88
|
+
min-height: var(--tb-control);
|
|
89
|
+
padding: var(--tb-space-3) var(--tb-space-4);
|
|
90
|
+
border-bottom: var(--tb-line) solid var(--tb-border);
|
|
91
|
+
}
|
|
92
|
+
.tb-list > li:last-child { border-bottom: 0; }
|
|
93
|
+
.tb-list-texts { display: flex; flex-direction: column; justify-content: center; gap: 2px; min-width: 0; }
|
|
94
|
+
.tb-list-primary { font-weight: 550; }
|
|
95
|
+
/* the picture of a row, in a column of images or at the start of a list's item */
|
|
96
|
+
.tb-thumb { display: block; flex: none; width: 40px; height: 40px; object-fit: cover; border-radius: var(--tb-radius); background: var(--tb-bg); }
|
|
97
|
+
.tb-thumb.tb-round { border-radius: 50%; }
|
|
98
|
+
.tb-table td.tb-thumb-cell { width: 1%; padding-top: var(--tb-space-1); padding-bottom: var(--tb-space-1); }
|
|
99
|
+
.tb-list-secondary { color: var(--tb-muted); font-size: 13px; }
|
|
100
|
+
.tb-list-secondary:empty { display: none; }
|
|
101
|
+
|
|
102
|
+
/* a board: its lanes side by side, scrolling sideways when they do not fit, and each card on its own */
|
|
103
|
+
.tb-board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(200px, 1fr); gap: var(--tb-space-4); align-items: stretch; overflow-x: auto; padding-bottom: var(--tb-space-2); }
|
|
104
|
+
.tb-board > .tb-panel { background: var(--tb-bg); box-shadow: none; padding: var(--tb-space-4); gap: var(--tb-space-3); min-height: 160px; }
|
|
105
|
+
.tb-board .tb-list { display: flex; flex-direction: column; gap: var(--tb-space-2); background: none; border: 0; box-shadow: none; overflow: visible; }
|
|
106
|
+
.tb-board .tb-list > li, .tb-board .tb-list > li:last-child { background: var(--tb-surface); border: var(--tb-line) solid var(--tb-border); border-radius: var(--tb-radius); box-shadow: var(--tb-shadow-1); }
|
|
107
|
+
.tb-board .tb-empty { display: none; }
|
|
108
|
+
|
|
109
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const DEVTOOLS: string;
|