trebol 0.1.0 → 0.1.2
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 +18 -3
- package/dist/cli.js +13790 -11417
- 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/access.d.ts +10 -0
- package/dist/lib/core/access.js +210 -0
- package/dist/lib/core/base.d.ts +4 -0
- package/dist/lib/core/base.js +50 -0
- package/dist/lib/core/bitset.d.ts +9 -0
- package/dist/lib/core/bitset.js +75 -0
- package/dist/lib/core/boot.d.ts +18 -0
- package/dist/lib/core/boot.js +73 -0
- package/dist/lib/core/compare.d.ts +9 -0
- package/dist/lib/core/compare.js +156 -0
- package/dist/lib/core/ctx.d.ts +36 -0
- package/dist/lib/core/ctx.js +251 -0
- package/dist/lib/core/dec.d.ts +28 -0
- package/dist/lib/core/dec.js +158 -0
- package/dist/lib/core/errors.d.ts +15 -0
- package/dist/lib/core/errors.js +44 -0
- package/dist/lib/core/escapes.d.ts +14 -0
- package/dist/lib/core/escapes.js +80 -0
- package/dist/lib/core/eval.d.ts +220 -0
- package/dist/lib/core/eval.js +666 -0
- package/dist/lib/core/func.d.ts +68 -0
- package/dist/lib/core/func.js +129 -0
- package/dist/lib/core/hash.d.ts +5 -0
- package/dist/lib/core/hash.js +155 -0
- package/dist/lib/core/index.d.ts +18 -0
- package/dist/lib/core/index.js +20 -0
- package/dist/lib/core/int64.d.ts +22 -0
- package/dist/lib/core/int64.js +113 -0
- package/dist/lib/core/kinds.d.ts +67 -0
- package/dist/lib/core/kinds.js +134 -0
- package/dist/lib/core/lexer.d.ts +13 -0
- package/dist/lib/core/lexer.js +702 -0
- package/dist/lib/core/mezz.d.ts +1 -0
- package/dist/lib/core/mezz.js +360 -0
- package/dist/lib/core/mold.d.ts +20 -0
- package/dist/lib/core/mold.js +434 -0
- package/dist/lib/core/natives/control.d.ts +1 -0
- package/dist/lib/core/natives/control.js +374 -0
- package/dist/lib/core/natives/csv.d.ts +15 -0
- package/dist/lib/core/natives/csv.js +315 -0
- package/dist/lib/core/natives/data.d.ts +11 -0
- package/dist/lib/core/natives/data.js +367 -0
- package/dist/lib/core/natives/define.d.ts +17 -0
- package/dist/lib/core/natives/define.js +47 -0
- package/dist/lib/core/natives/encode.d.ts +3 -0
- package/dist/lib/core/natives/encode.js +187 -0
- package/dist/lib/core/natives/json.d.ts +5 -0
- package/dist/lib/core/natives/json.js +273 -0
- package/dist/lib/core/natives/math.d.ts +3 -0
- package/dist/lib/core/natives/math.js +500 -0
- package/dist/lib/core/natives/parse.d.ts +1 -0
- package/dist/lib/core/natives/parse.js +600 -0
- package/dist/lib/core/natives/series.d.ts +4 -0
- package/dist/lib/core/natives/series.js +519 -0
- package/dist/lib/core/natives/text.d.ts +1 -0
- package/dist/lib/core/natives/text.js +487 -0
- package/dist/lib/core/natives/xml.d.ts +9 -0
- package/dist/lib/core/natives/xml.js +242 -0
- package/dist/lib/core/series.d.ts +26 -0
- package/dist/lib/core/series.js +73 -0
- package/dist/lib/core/symbols.d.ts +9 -0
- package/dist/lib/core/symbols.js +44 -0
- package/dist/lib/core/values.d.ts +206 -0
- package/dist/lib/core/values.js +223 -0
- package/dist/lib/host/browser.d.ts +4 -0
- package/dist/lib/host/browser.js +4974 -0
- package/dist/lib/host/chart.d.ts +26 -0
- package/dist/lib/host/chart.js +158 -0
- package/dist/lib/host/compress.d.ts +1 -0
- package/dist/lib/host/compress.js +37 -0
- package/dist/lib/host/devlog.d.ts +11 -0
- package/dist/lib/host/devlog.js +13 -0
- package/dist/lib/host/devtools.d.ts +23 -0
- package/dist/lib/host/devtools.js +626 -0
- package/dist/lib/host/draw.d.ts +31 -0
- package/dist/lib/host/draw.js +348 -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 +29 -0
- package/dist/lib/host/icons.d.ts +3 -0
- package/dist/lib/host/icons.js +97 -0
- package/dist/lib/host/index.d.ts +40 -0
- package/dist/lib/host/index.js +192 -0
- package/dist/lib/host/js.d.ts +5 -0
- package/dist/lib/host/js.js +130 -0
- package/dist/lib/host/locale.d.ts +40 -0
- package/dist/lib/host/locale.js +241 -0
- package/dist/lib/host/markdown.d.ts +30 -0
- package/dist/lib/host/markdown.js +161 -0
- package/dist/lib/host/modules.d.ts +14 -0
- package/dist/lib/host/modules.js +300 -0
- package/dist/lib/host/natives.d.ts +6 -0
- package/dist/lib/host/natives.js +98 -0
- package/dist/lib/host/net.d.ts +12 -0
- package/dist/lib/host/net.js +549 -0
- package/dist/lib/host/orbit.d.ts +121 -0
- package/dist/lib/host/orbit.js +374 -0
- package/dist/lib/host/page.d.ts +9 -0
- package/dist/lib/host/page.js +55 -0
- package/dist/lib/host/rows.d.ts +29 -0
- package/dist/lib/host/rows.js +109 -0
- package/dist/lib/host/scheduler.d.ts +51 -0
- package/dist/lib/host/scheduler.js +197 -0
- package/dist/lib/host/theme.d.ts +58 -0
- package/dist/lib/host/theme.js +1667 -0
- package/dist/lib/ui/i18n.trb +117 -0
- package/dist/lib/ui/test.trb +565 -0
- package/dist/lib/ui/ui.trb +1678 -0
- package/dist/trebol.js +1427 -138
- 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 +23 -7
- package/src/core/boot.ts +1 -1
- package/src/core/func.ts +4 -0
- package/src/core/natives/control.ts +1 -1
- package/src/core/natives/series.ts +9 -1
- package/src/core/natives/text.ts +2 -0
- package/src/host/browser.ts +1235 -83
- package/src/host/devlog.ts +16 -0
- package/src/host/devtools.ts +641 -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 +39 -0
- package/src/host/index.ts +5 -3
- package/src/host/js.ts +127 -0
- package/src/host/markdown.ts +9 -0
- package/src/host/modules.ts +41 -2
- package/src/host/net.ts +9 -1
- package/src/host/orbit.ts +432 -0
- package/src/host/rows.ts +30 -0
- package/src/host/scheduler.ts +62 -36
- package/src/host/theme.ts +270 -6
- package/src/ui/i18n.trb +10 -0
- package/src/ui/test.trb +565 -0
- package/src/ui/ui.trb +564 -90
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
// The draw dialect: a block of drawing commands, as in Red, drawn as SVG.
|
|
2
|
+
//
|
|
3
|
+
// canvas 120x120 [fill-pen primary circle 60x60 50 pen text line 30x60 90x60]
|
|
4
|
+
//
|
|
5
|
+
// Coordinates are in the canvas's own space (its extent); the SVG scales to
|
|
6
|
+
// the room it gets. Colors are the theme's roles or Red's color words, which
|
|
7
|
+
// the theme works out for light and dark (`--tb-c-red` and so on), never RGB.
|
|
8
|
+
// This module builds a tree of plain elements and knows nothing of the DOM,
|
|
9
|
+
// so the tests run it in Node; the browser host turns the tree into nodes.
|
|
10
|
+
import { K, I64, spell, text } from "../core/index.js";
|
|
11
|
+
export const svgEl = (tag, attrs = {}, kids = [], txt) => {
|
|
12
|
+
const a = {};
|
|
13
|
+
for (const [k, v] of Object.entries(attrs))
|
|
14
|
+
a[k] = typeof v === 'number' ? round(v) : v;
|
|
15
|
+
return txt === undefined ? { tag, attrs: a, kids } : { tag, attrs: a, kids, text: txt };
|
|
16
|
+
};
|
|
17
|
+
const round = (n) => String(Math.round(n * 100) / 100);
|
|
18
|
+
/** Theme roles a drawing may use as colors. */
|
|
19
|
+
export const DRAW_ROLES = ['primary', 'accent', 'danger', 'success', 'warning', 'muted', 'text', 'border', 'surface', 'bg'];
|
|
20
|
+
/**
|
|
21
|
+
* Red's color words Trebol knows, as OKLCH hue and chroma with a lightness for
|
|
22
|
+
* light and one for dark mode, so each one reads on the background of either.
|
|
23
|
+
* black and white stay what they say in both.
|
|
24
|
+
*/
|
|
25
|
+
export const DRAW_COLORS = {
|
|
26
|
+
red: { h: 27, c: 0.2, light: 0.58, dark: 0.7 },
|
|
27
|
+
maroon: { h: 15, c: 0.13, light: 0.38, dark: 0.58 },
|
|
28
|
+
orange: { h: 55, c: 0.17, light: 0.68, dark: 0.76 },
|
|
29
|
+
brown: { h: 50, c: 0.1, light: 0.45, dark: 0.62 },
|
|
30
|
+
gold: { h: 85, c: 0.15, light: 0.76, dark: 0.8 },
|
|
31
|
+
yellow: { h: 100, c: 0.17, light: 0.86, dark: 0.88 },
|
|
32
|
+
olive: { h: 115, c: 0.12, light: 0.5, dark: 0.68 },
|
|
33
|
+
green: { h: 145, c: 0.17, light: 0.6, dark: 0.74 },
|
|
34
|
+
teal: { h: 185, c: 0.11, light: 0.58, dark: 0.72 },
|
|
35
|
+
aqua: { h: 195, c: 0.12, light: 0.78, dark: 0.82 },
|
|
36
|
+
cyan: { h: 210, c: 0.12, light: 0.72, dark: 0.8 },
|
|
37
|
+
sky: { h: 235, c: 0.1, light: 0.75, dark: 0.8 },
|
|
38
|
+
blue: { h: 260, c: 0.19, light: 0.55, dark: 0.7 },
|
|
39
|
+
navy: { h: 265, c: 0.14, light: 0.32, dark: 0.55 },
|
|
40
|
+
violet: { h: 290, c: 0.15, light: 0.62, dark: 0.75 },
|
|
41
|
+
purple: { h: 305, c: 0.18, light: 0.5, dark: 0.68 },
|
|
42
|
+
magenta: { h: 330, c: 0.24, light: 0.6, dark: 0.72 },
|
|
43
|
+
pink: { h: 350, c: 0.13, light: 0.75, dark: 0.8 },
|
|
44
|
+
silver: { h: 0, c: 0, light: 0.8, dark: 0.75 },
|
|
45
|
+
gray: { h: 0, c: 0, light: 0.6, dark: 0.62 },
|
|
46
|
+
black: { h: 0, c: 0, light: 0.15, dark: 0.15 },
|
|
47
|
+
white: { h: 0, c: 0, light: 1, dark: 1 },
|
|
48
|
+
};
|
|
49
|
+
/** The commands of the dialect, and how each is written. */
|
|
50
|
+
export const DRAW_COMMANDS = {
|
|
51
|
+
pen: 'pen color',
|
|
52
|
+
'fill-pen': 'fill-pen color',
|
|
53
|
+
'line-width': 'line-width number',
|
|
54
|
+
'line-cap': 'line-cap flat | square | round',
|
|
55
|
+
'line-join': 'line-join miter | round | bevel',
|
|
56
|
+
font: 'font [size: number bold italic]',
|
|
57
|
+
line: 'line point point ...',
|
|
58
|
+
box: 'box top-left bottom-right [corner-radius]',
|
|
59
|
+
triangle: 'triangle point point point',
|
|
60
|
+
polygon: 'polygon point point point ...',
|
|
61
|
+
circle: 'circle center radius [radius-y]',
|
|
62
|
+
ellipse: 'ellipse top-left size',
|
|
63
|
+
arc: 'arc center radius begin sweep [closed]',
|
|
64
|
+
curve: 'curve start control end, or curve start control control end',
|
|
65
|
+
text: 'text top-left string',
|
|
66
|
+
translate: 'translate offset',
|
|
67
|
+
rotate: 'rotate angle [center]',
|
|
68
|
+
scale: 'scale x y',
|
|
69
|
+
push: 'push [commands]',
|
|
70
|
+
};
|
|
71
|
+
const START = { pen: 'var(--tb-text)', fill: null, width: 1, cap: 'butt', join: 'miter', size: 15, bold: false, italic: false };
|
|
72
|
+
/** A color word as CSS; null for off, undefined when it is no color. */
|
|
73
|
+
export function drawColor(w) {
|
|
74
|
+
if (w === 'off' || w === 'none' || w === 'transparent')
|
|
75
|
+
return null;
|
|
76
|
+
if (DRAW_ROLES.includes(w))
|
|
77
|
+
return `var(--tb-${w})`;
|
|
78
|
+
if (DRAW_COLORS[w] !== undefined)
|
|
79
|
+
return `var(--tb-c-${w})`;
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
class DrawError extends Error {
|
|
83
|
+
}
|
|
84
|
+
/** The SVG elements of a draw block, and what was wrong with it, if anything. Drawing stops at the first error. */
|
|
85
|
+
export function drawSvg(block) {
|
|
86
|
+
const out = [];
|
|
87
|
+
if (block.t !== K.Block)
|
|
88
|
+
return { kids: out, error: block.t === K.None ? null : 'draw takes a block' };
|
|
89
|
+
try {
|
|
90
|
+
run(block, { ...START }, out);
|
|
91
|
+
return { kids: out, error: null };
|
|
92
|
+
}
|
|
93
|
+
catch (e) {
|
|
94
|
+
if (e instanceof DrawError)
|
|
95
|
+
return { kids: out, error: e.message };
|
|
96
|
+
throw e;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function run(b, st, out) {
|
|
100
|
+
const d = b.s.data;
|
|
101
|
+
let i = b.i;
|
|
102
|
+
let into = out;
|
|
103
|
+
const word = (c) => c !== undefined && (c.t === K.Word || c.t === K.LitWord) ? spell(c.sym).toLowerCase() : null;
|
|
104
|
+
const num = (c) => c === undefined ? null : c.t === K.Integer ? I64.toNumber(c.v) : c.t === K.Decimal ? c.v : null;
|
|
105
|
+
const fail = (cmd) => {
|
|
106
|
+
throw new DrawError(`draw: ${cmd} is written ${DRAW_COMMANDS[cmd]}`);
|
|
107
|
+
};
|
|
108
|
+
const point = (cmd) => {
|
|
109
|
+
const c = d[i];
|
|
110
|
+
if (c === undefined || c.t !== K.Pair)
|
|
111
|
+
return fail(cmd);
|
|
112
|
+
i++;
|
|
113
|
+
return [c.x, c.y];
|
|
114
|
+
};
|
|
115
|
+
const optPoint = () => {
|
|
116
|
+
const c = d[i];
|
|
117
|
+
if (c === undefined || c.t !== K.Pair)
|
|
118
|
+
return null;
|
|
119
|
+
i++;
|
|
120
|
+
return [c.x, c.y];
|
|
121
|
+
};
|
|
122
|
+
const number = (cmd) => {
|
|
123
|
+
const n = num(d[i]);
|
|
124
|
+
if (n === null)
|
|
125
|
+
return fail(cmd);
|
|
126
|
+
i++;
|
|
127
|
+
return n;
|
|
128
|
+
};
|
|
129
|
+
const optNumber = () => {
|
|
130
|
+
const n = num(d[i]);
|
|
131
|
+
if (n !== null)
|
|
132
|
+
i++;
|
|
133
|
+
return n;
|
|
134
|
+
};
|
|
135
|
+
const points = (cmd, least) => {
|
|
136
|
+
const ps = [];
|
|
137
|
+
for (let p = optPoint(); p !== null; p = optPoint())
|
|
138
|
+
ps.push(p);
|
|
139
|
+
if (ps.length < least)
|
|
140
|
+
fail(cmd);
|
|
141
|
+
return ps;
|
|
142
|
+
};
|
|
143
|
+
const paint = (closed) => ({
|
|
144
|
+
fill: closed && st.fill !== null ? st.fill : 'none',
|
|
145
|
+
stroke: st.pen ?? 'none',
|
|
146
|
+
'stroke-width': st.width,
|
|
147
|
+
'stroke-linecap': st.cap,
|
|
148
|
+
'stroke-linejoin': st.join,
|
|
149
|
+
});
|
|
150
|
+
const pts = (ps) => ps.map(([x, y]) => `${round(x)},${round(y)}`).join(' ');
|
|
151
|
+
while (i < d.length) {
|
|
152
|
+
const c = d[i];
|
|
153
|
+
const cmd = word(c);
|
|
154
|
+
if (cmd === null || DRAW_COMMANDS[cmd] === undefined) {
|
|
155
|
+
throw new DrawError(cmd === null ? `draw: a command was expected, not ${kindOf(c)}` : `draw: unknown command ${cmd}`);
|
|
156
|
+
}
|
|
157
|
+
i++;
|
|
158
|
+
switch (cmd) {
|
|
159
|
+
case 'pen':
|
|
160
|
+
case 'fill-pen': {
|
|
161
|
+
const w = word(d[i]);
|
|
162
|
+
const color = w === null ? undefined : drawColor(w);
|
|
163
|
+
if (color === undefined) {
|
|
164
|
+
throw new DrawError(`draw: ${cmd} takes a role (${DRAW_ROLES.join(' ')}), a color (${Object.keys(DRAW_COLORS).join(' ')}) or off`);
|
|
165
|
+
}
|
|
166
|
+
i++;
|
|
167
|
+
if (cmd === 'pen')
|
|
168
|
+
st.pen = color;
|
|
169
|
+
else
|
|
170
|
+
st.fill = color;
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
case 'line-width':
|
|
174
|
+
st.width = Math.max(0, number(cmd));
|
|
175
|
+
break;
|
|
176
|
+
case 'line-cap': {
|
|
177
|
+
const w = word(d[i]);
|
|
178
|
+
if (w !== 'flat' && w !== 'square' && w !== 'round')
|
|
179
|
+
fail(cmd);
|
|
180
|
+
i++;
|
|
181
|
+
st.cap = w === 'flat' ? 'butt' : w;
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
case 'line-join': {
|
|
185
|
+
const w = word(d[i]);
|
|
186
|
+
if (w !== 'miter' && w !== 'round' && w !== 'bevel')
|
|
187
|
+
fail(cmd);
|
|
188
|
+
i++;
|
|
189
|
+
st.join = w;
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
case 'font': {
|
|
193
|
+
const spec = d[i];
|
|
194
|
+
if (spec === undefined || spec.t !== K.Block)
|
|
195
|
+
fail(cmd);
|
|
196
|
+
i++;
|
|
197
|
+
const fd = spec.s.data.slice(spec.i);
|
|
198
|
+
for (let j = 0; j < fd.length; j++) {
|
|
199
|
+
const f = fd[j];
|
|
200
|
+
if (f.t === K.SetWord && spell(f.sym).toLowerCase() === 'size' && num(fd[j + 1]) !== null) {
|
|
201
|
+
st.size = num(fd[++j]);
|
|
202
|
+
}
|
|
203
|
+
else if (word(f) === 'bold')
|
|
204
|
+
st.bold = true;
|
|
205
|
+
else if (word(f) === 'italic')
|
|
206
|
+
st.italic = true;
|
|
207
|
+
else if (word(f) === 'plain')
|
|
208
|
+
st.bold = st.italic = false;
|
|
209
|
+
else
|
|
210
|
+
fail(cmd);
|
|
211
|
+
}
|
|
212
|
+
break;
|
|
213
|
+
}
|
|
214
|
+
case 'line':
|
|
215
|
+
into.push(svgEl('polyline', { points: pts(points(cmd, 2)), ...paint(false) }));
|
|
216
|
+
break;
|
|
217
|
+
case 'triangle': {
|
|
218
|
+
const ps = points(cmd, 3);
|
|
219
|
+
if (ps.length !== 3)
|
|
220
|
+
fail(cmd);
|
|
221
|
+
into.push(svgEl('polygon', { points: pts(ps), ...paint(true) }));
|
|
222
|
+
break;
|
|
223
|
+
}
|
|
224
|
+
case 'polygon':
|
|
225
|
+
into.push(svgEl('polygon', { points: pts(points(cmd, 3)), ...paint(true) }));
|
|
226
|
+
break;
|
|
227
|
+
case 'box': {
|
|
228
|
+
const [x1, y1] = point(cmd);
|
|
229
|
+
const [x2, y2] = point(cmd);
|
|
230
|
+
const r = optNumber();
|
|
231
|
+
const a = {
|
|
232
|
+
x: Math.min(x1, x2), y: Math.min(y1, y2), width: Math.abs(x2 - x1), height: Math.abs(y2 - y1), ...paint(true),
|
|
233
|
+
};
|
|
234
|
+
if (r !== null)
|
|
235
|
+
a['rx'] = r;
|
|
236
|
+
into.push(svgEl('rect', a));
|
|
237
|
+
break;
|
|
238
|
+
}
|
|
239
|
+
case 'circle': {
|
|
240
|
+
const [cx, cy] = point(cmd);
|
|
241
|
+
const r = number(cmd);
|
|
242
|
+
const ry = optNumber();
|
|
243
|
+
into.push(ry === null
|
|
244
|
+
? svgEl('circle', { cx, cy, r, ...paint(true) })
|
|
245
|
+
: svgEl('ellipse', { cx, cy, rx: r, ry, ...paint(true) }));
|
|
246
|
+
break;
|
|
247
|
+
}
|
|
248
|
+
case 'ellipse': {
|
|
249
|
+
const [x, y] = point(cmd);
|
|
250
|
+
const [w, h] = point(cmd);
|
|
251
|
+
into.push(svgEl('ellipse', { cx: x + w / 2, cy: y + h / 2, rx: w / 2, ry: h / 2, ...paint(true) }));
|
|
252
|
+
break;
|
|
253
|
+
}
|
|
254
|
+
case 'arc': {
|
|
255
|
+
const [cx, cy] = point(cmd);
|
|
256
|
+
const [rx, ry] = point(cmd);
|
|
257
|
+
const begin = number(cmd);
|
|
258
|
+
const sweep = number(cmd);
|
|
259
|
+
const closed = word(d[i]) === 'closed';
|
|
260
|
+
if (closed)
|
|
261
|
+
i++;
|
|
262
|
+
into.push(svgEl('path', { d: arcPath(cx, cy, rx, ry, begin, sweep, closed), ...paint(closed) }));
|
|
263
|
+
break;
|
|
264
|
+
}
|
|
265
|
+
case 'curve': {
|
|
266
|
+
const ps = points(cmd, 3);
|
|
267
|
+
if (ps.length > 4)
|
|
268
|
+
fail(cmd);
|
|
269
|
+
const [p0, ...rest] = ps;
|
|
270
|
+
const path = `M${round(p0[0])},${round(p0[1])} ${rest.length === 2 ? 'Q' : 'C'}${pts(rest)}`;
|
|
271
|
+
into.push(svgEl('path', { d: path, ...paint(false) }));
|
|
272
|
+
break;
|
|
273
|
+
}
|
|
274
|
+
case 'text': {
|
|
275
|
+
const [x, y] = point(cmd);
|
|
276
|
+
const s = d[i];
|
|
277
|
+
if (s === undefined || s.t !== K.String)
|
|
278
|
+
fail(cmd);
|
|
279
|
+
i++;
|
|
280
|
+
const a = {
|
|
281
|
+
x, y, 'dominant-baseline': 'hanging', fill: st.pen ?? 'none', 'font-size': st.size, 'font-family': 'var(--tb-font)',
|
|
282
|
+
};
|
|
283
|
+
if (st.bold)
|
|
284
|
+
a['font-weight'] = 'bold';
|
|
285
|
+
if (st.italic)
|
|
286
|
+
a['font-style'] = 'italic';
|
|
287
|
+
into.push(svgEl('text', a, [], text(s)));
|
|
288
|
+
break;
|
|
289
|
+
}
|
|
290
|
+
case 'translate':
|
|
291
|
+
case 'rotate':
|
|
292
|
+
case 'scale': {
|
|
293
|
+
let t;
|
|
294
|
+
if (cmd === 'translate') {
|
|
295
|
+
const [x, y] = point(cmd);
|
|
296
|
+
t = `translate(${round(x)} ${round(y)})`;
|
|
297
|
+
}
|
|
298
|
+
else if (cmd === 'rotate') {
|
|
299
|
+
const a = number(cmd);
|
|
300
|
+
const c = optPoint();
|
|
301
|
+
t = c === null ? `rotate(${round(a)})` : `rotate(${round(a)} ${round(c[0])} ${round(c[1])})`;
|
|
302
|
+
}
|
|
303
|
+
else {
|
|
304
|
+
const x = number(cmd);
|
|
305
|
+
const y = optNumber() ?? x;
|
|
306
|
+
t = `scale(${round(x)} ${round(y)})`;
|
|
307
|
+
}
|
|
308
|
+
// the rest of this block is drawn inside the transform
|
|
309
|
+
const g = svgEl('g', { transform: t });
|
|
310
|
+
into.push(g);
|
|
311
|
+
into = g.kids;
|
|
312
|
+
break;
|
|
313
|
+
}
|
|
314
|
+
case 'push': {
|
|
315
|
+
const inner = d[i];
|
|
316
|
+
if (inner === undefined || inner.t !== K.Block)
|
|
317
|
+
fail(cmd);
|
|
318
|
+
i++;
|
|
319
|
+
const g = svgEl('g');
|
|
320
|
+
into.push(g);
|
|
321
|
+
run(inner, { ...st }, g.kids);
|
|
322
|
+
break;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
/** The SVG path of an arc: angles in degrees, 0 at three o'clock, going clockwise, as in Red. */
|
|
328
|
+
function arcPath(cx, cy, rx, ry, begin, sweep, closed) {
|
|
329
|
+
const at = (deg) => {
|
|
330
|
+
const r = (deg * Math.PI) / 180;
|
|
331
|
+
return [cx + rx * Math.cos(r), cy + ry * Math.sin(r)];
|
|
332
|
+
};
|
|
333
|
+
// a full turn is two halves: one arc cannot start and end at the same point
|
|
334
|
+
if (Math.abs(sweep) >= 360) {
|
|
335
|
+
const [x0, y0] = at(begin);
|
|
336
|
+
const [x1, y1] = at(begin + 180);
|
|
337
|
+
return `M${round(x0)},${round(y0)} A${round(rx)},${round(ry)} 0 1 1 ${round(x1)},${round(y1)} A${round(rx)},${round(ry)} 0 1 1 ${round(x0)},${round(y0)}${closed ? ' Z' : ''}`;
|
|
338
|
+
}
|
|
339
|
+
const [x0, y0] = at(begin);
|
|
340
|
+
const [x1, y1] = at(begin + sweep);
|
|
341
|
+
const large = Math.abs(sweep) > 180 ? 1 : 0;
|
|
342
|
+
const dir = sweep >= 0 ? 1 : 0;
|
|
343
|
+
const arc = `A${round(rx)},${round(ry)} 0 ${large} ${dir} ${round(x1)},${round(y1)}`;
|
|
344
|
+
return closed ? `M${round(cx)},${round(cy)} L${round(x0)},${round(y0)} ${arc} Z` : `M${round(x0)},${round(y0)} ${arc}`;
|
|
345
|
+
}
|
|
346
|
+
function kindOf(c) {
|
|
347
|
+
return c.t === K.String ? 'a string' : c.t === K.Pair ? 'a pair' : c.t === K.Integer || c.t === K.Decimal ? 'a number' : 'that';
|
|
348
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Copyright 2016 The Inter Project Authors (https://github.com/rsms/inter) Inter-Italic[opsz,wght].ttf: Copyright 2016 The Inter Project Authors (https://github.com/rsms/inter)
|
|
2
|
+
|
|
3
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
4
|
+
This license is copied below, and is also available with a FAQ at:
|
|
5
|
+
http://scripts.sil.org/OFL
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
-----------------------------------------------------------
|
|
9
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
10
|
+
-----------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
PREAMBLE
|
|
13
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
14
|
+
development of collaborative font projects, to support the font creation
|
|
15
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
16
|
+
open framework in which fonts may be shared and improved in partnership
|
|
17
|
+
with others.
|
|
18
|
+
|
|
19
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
20
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
21
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
22
|
+
redistributed and/or sold with any software provided that any reserved
|
|
23
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
24
|
+
however, cannot be released under any other type of license. The
|
|
25
|
+
requirement for fonts to remain under this license does not apply
|
|
26
|
+
to any document created using the fonts or their derivatives.
|
|
27
|
+
|
|
28
|
+
DEFINITIONS
|
|
29
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
30
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
31
|
+
include source files, build scripts and documentation.
|
|
32
|
+
|
|
33
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
34
|
+
copyright statement(s).
|
|
35
|
+
|
|
36
|
+
"Original Version" refers to the collection of Font Software components as
|
|
37
|
+
distributed by the Copyright Holder(s).
|
|
38
|
+
|
|
39
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
40
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
41
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
42
|
+
new environment.
|
|
43
|
+
|
|
44
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
45
|
+
writer or other person who contributed to the Font Software.
|
|
46
|
+
|
|
47
|
+
PERMISSION & CONDITIONS
|
|
48
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
49
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
50
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
51
|
+
Software, subject to the following conditions:
|
|
52
|
+
|
|
53
|
+
1) Neither the Font Software nor any of its individual components,
|
|
54
|
+
in Original or Modified Versions, may be sold by itself.
|
|
55
|
+
|
|
56
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
57
|
+
redistributed and/or sold with any software, provided that each copy
|
|
58
|
+
contains the above copyright notice and this license. These can be
|
|
59
|
+
included either as stand-alone text files, human-readable headers or
|
|
60
|
+
in the appropriate machine-readable metadata fields within text or
|
|
61
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
62
|
+
|
|
63
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
64
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
65
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
66
|
+
presented to the users.
|
|
67
|
+
|
|
68
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
69
|
+
Software shall not be used to promote, endorse or advertise any
|
|
70
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
71
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
72
|
+
permission.
|
|
73
|
+
|
|
74
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
75
|
+
must be distributed entirely under this license, and must not be
|
|
76
|
+
distributed under any other license. The requirement for fonts to
|
|
77
|
+
remain under this license does not apply to any document created
|
|
78
|
+
using the Font Software.
|
|
79
|
+
|
|
80
|
+
TERMINATION
|
|
81
|
+
This license becomes null and void if any of the above conditions are
|
|
82
|
+
not met.
|
|
83
|
+
|
|
84
|
+
DISCLAIMER
|
|
85
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
86
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
87
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
88
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
89
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
90
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
91
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
92
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
93
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface FontFile {
|
|
2
|
+
/** File name in fonts/. */
|
|
3
|
+
file: string;
|
|
4
|
+
/** The characters the file has, as CSS unicode-range. */
|
|
5
|
+
range: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const INTER: readonly FontFile[];
|
|
8
|
+
/** The @font-face rules of Inter, each file at the address `src` gives it. */
|
|
9
|
+
export declare function interCss(src: (file: string) => string, faces?: readonly FontFile[]): string;
|
|
10
|
+
/** Whether a code point is in a unicode-range. */
|
|
11
|
+
export declare function inRange(range: string, cp: number): boolean;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// Inter, the font of the default theme, as variable woff2 files in fonts/:
|
|
2
|
+
// one per script, so a browser downloads only those its text needs (the
|
|
3
|
+
// unicode-range of each face). They come from @fontsource-variable/inter
|
|
4
|
+
// 5.3.0, under the SIL Open Font License (fonts/OFL.txt).
|
|
5
|
+
//
|
|
6
|
+
// trebol.js declares them with addresses next to itself; a page made by
|
|
7
|
+
// `trebol build` carries the files inside and declares them in its own
|
|
8
|
+
// <style data-tb-fonts>, which the host then leaves alone.
|
|
9
|
+
// The order of @fontsource: where ranges overlap, the last face declared wins.
|
|
10
|
+
export const INTER = [
|
|
11
|
+
{ file: 'inter-cyrillic-ext.woff2', range: 'U+0460-052F,U+1C80-1C8A,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F' },
|
|
12
|
+
{ file: 'inter-cyrillic.woff2', range: 'U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116' },
|
|
13
|
+
{ file: 'inter-greek-ext.woff2', range: 'U+1F00-1FFF' },
|
|
14
|
+
{ file: 'inter-greek.woff2', range: 'U+0370-0377,U+037A-037F,U+0384-038A,U+038C,U+038E-03A1,U+03A3-03FF' },
|
|
15
|
+
{ file: 'inter-vietnamese.woff2', range: 'U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB' },
|
|
16
|
+
{ file: 'inter-latin-ext.woff2', range: 'U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF' },
|
|
17
|
+
{ file: 'inter-latin.woff2', range: 'U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD' },
|
|
18
|
+
];
|
|
19
|
+
/** The @font-face rules of Inter, each file at the address `src` gives it. */
|
|
20
|
+
export function interCss(src, faces = INTER) {
|
|
21
|
+
return faces.map(f => `@font-face { font-family: Inter; font-style: normal; font-weight: 100 900; font-display: swap; src: url(${src(f.file)}) format("woff2"); unicode-range: ${f.range}; }`).join('\n');
|
|
22
|
+
}
|
|
23
|
+
/** Whether a code point is in a unicode-range. */
|
|
24
|
+
export function inRange(range, cp) {
|
|
25
|
+
return range.split(',').some(r => {
|
|
26
|
+
const [lo, hi] = r.slice(2).split('-').map(h => parseInt(h, 16));
|
|
27
|
+
return cp >= lo && cp <= (hi ?? lo);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// The built-in icons: 24 px outlines drawn with the current text color, so
|
|
2
|
+
// they follow the role of the face that shows them. `icon #search`,
|
|
3
|
+
// `button #plus "New"`, `field #search "Search"`.
|
|
4
|
+
const PATHS = {
|
|
5
|
+
search: 'M11 4a7 7 0 1 0 0 14a7 7 0 1 0 0-14zM16.5 16.5L21 21',
|
|
6
|
+
plus: 'M12 5v14M5 12h14',
|
|
7
|
+
minus: 'M5 12h14',
|
|
8
|
+
close: 'M6 6l12 12M18 6L6 18',
|
|
9
|
+
check: 'M5 12.5l4.5 4.5L19 7',
|
|
10
|
+
'chevron-left': 'M15 6l-6 6 6 6',
|
|
11
|
+
'chevron-right': 'M9 6l6 6-6 6',
|
|
12
|
+
'chevron-up': 'M6 15l6-6 6 6',
|
|
13
|
+
'chevron-down': 'M6 9l6 6 6-6',
|
|
14
|
+
'chevrons-left': 'M11 6l-6 6 6 6M19 6l-6 6 6 6',
|
|
15
|
+
'chevrons-right': 'M5 6l6 6-6 6M13 6l6 6-6 6',
|
|
16
|
+
'arrow-left': 'M19 12H5M11 6l-6 6 6 6',
|
|
17
|
+
'arrow-right': 'M5 12h14M13 6l6 6-6 6',
|
|
18
|
+
'arrow-up': 'M12 19V5M6 11l6-6 6 6',
|
|
19
|
+
'arrow-down': 'M12 5v14M6 13l6 6 6-6',
|
|
20
|
+
edit: 'M4 20h4L19 9l-4-4L4 16v4zM13.5 6.5l4 4',
|
|
21
|
+
trash: 'M4 7h16M9 7V4h6v3M6 7l1 13h10l1-13M10 11v6M14 11v6',
|
|
22
|
+
user: 'M12 4a4 4 0 1 0 0 8a4 4 0 1 0 0-8zM4 21c0-4 3.5-7 8-7s8 3 8 7',
|
|
23
|
+
mail: 'M3 6h18v12H3zM3 7l9 6 9-6',
|
|
24
|
+
phone: 'M5 4h4l2 5-2.5 1.5a11 11 0 0 0 5 5L15 13l5 2v4a1 1 0 0 1-1 1A16 16 0 0 1 4 5a1 1 0 0 1 1-1z',
|
|
25
|
+
info: 'M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18zM12 11v6M12 7.5v.5',
|
|
26
|
+
warning: 'M12 3L2 20h20L12 3zM12 10v4M12 17v.5',
|
|
27
|
+
menu: 'M4 6h16M4 12h16M4 18h16',
|
|
28
|
+
home: 'M3 11l9-7 9 7M5 9.5V20h5v-6h4v6h5V9.5',
|
|
29
|
+
folder: 'M3 6.5A1.5 1.5 0 0 1 4.5 5H9l2 2.5h8.5A1.5 1.5 0 0 1 21 9v9.5a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 3 18.5z',
|
|
30
|
+
door: 'M6 21V4a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v17M3 21h18M14.5 12v.5',
|
|
31
|
+
building: 'M5 21V4h14v17M3 21h18M9 8h.01M15 8h.01M9 12h.01M15 12h.01M10 21v-5h4v5',
|
|
32
|
+
landmark: 'M3 21h18M5 18h14M12 3l9 5H3zM6 8v10M10 8v10M14 8v10M18 8v10',
|
|
33
|
+
shield: 'M12 3l8 3v6c0 5-3.5 8-8 9c-4.5-1-8-4-8-9V6z',
|
|
34
|
+
fireworks: 'M12 22v-9M12 3v3M5 7l2.5 2M19 7l-2.5 2M3.5 13h3M17.5 13h3M8 3.5l1 2.5M16 3.5l-1 2.5',
|
|
35
|
+
coins: 'M9 4a6 6 0 1 0 0 12a6 6 0 1 0 0-12zM15.5 8.3a6 6 0 1 1-7.2 7.2',
|
|
36
|
+
book: 'M4 5a2 2 0 0 1 2-2h14v15H6a2 2 0 0 0-2 2zM4 20a2 2 0 0 0 2 1h14v-3',
|
|
37
|
+
scale: 'M12 4v17M7 21h10M5 7h14M5 7l-3 7a3.5 3.5 0 0 0 6 0zM19 7l-3 7a3.5 3.5 0 0 0 6 0z',
|
|
38
|
+
people: 'M9 5a3.5 3.5 0 1 0 0 7a3.5 3.5 0 1 0 0-7zM2.5 20c0-3.5 3-6 6.5-6s6.5 2.5 6.5 6M16 5.3a3.5 3.5 0 0 1 0 6.4M18 14.5c2 .8 3.5 2.8 3.5 5.5',
|
|
39
|
+
tree: 'M12 3l6 7h-3l4 5H5l4-5H6zM12 15v6',
|
|
40
|
+
truck: 'M2 6h12v11H2zM14 10h4l4 4v3h-8zM6.5 15a2 2 0 1 0 0 4a2 2 0 1 0 0-4zM17.5 15a2 2 0 1 0 0 4a2 2 0 1 0 0-4z',
|
|
41
|
+
box: 'M12 3l8 4.5v9L12 21l-8-4.5v-9zM4 7.5l8 4.5 8-4.5M12 12v9',
|
|
42
|
+
file: 'M6 3h8l4 4v14H6zM14 3v4h4M9 12h6M9 16h6',
|
|
43
|
+
image: 'M4 5h16v14H4zM4 16l5-5 4 4 2-2 5 5M15 8.5a1.5 1.5 0 1 0 0 3a1.5 1.5 0 1 0 0-3z',
|
|
44
|
+
settings: 'M4 7h10M18 7h2M4 17h4M12 17h8M16 5v4M10 15v4',
|
|
45
|
+
filter: 'M4 5h16l-6 8v6l-4-2v-4L4 5z',
|
|
46
|
+
refresh: 'M20 12a8 8 0 1 1-2.3-5.7M20 4v5h-5',
|
|
47
|
+
download: 'M12 4v11M7 10l5 5 5-5M5 20h14',
|
|
48
|
+
upload: 'M12 16V4M7 9l5-5 5 5M5 20h14',
|
|
49
|
+
external: 'M14 4h6v6M20 4l-9 9M18 14v6H4V6h6',
|
|
50
|
+
eye: 'M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12zM12 9a3 3 0 1 0 0 6a3 3 0 1 0 0-6z',
|
|
51
|
+
lock: 'M5 11h14v10H5zM8 11V7a4 4 0 0 1 8 0v4',
|
|
52
|
+
calendar: 'M4 6h16v15H4zM4 10h16M8 3v4M16 3v4',
|
|
53
|
+
star: 'M12 3l2.8 5.8 6.2.9-4.5 4.4 1 6.3L12 17.5l-5.5 2.9 1-6.3L3 9.7l6.2-.9L12 3z',
|
|
54
|
+
heart: 'M12 20s-8-5-8-11a4.5 4.5 0 0 1 8-2.8A4.5 4.5 0 0 1 20 9c0 6-8 11-8 11z',
|
|
55
|
+
type: 'M5 7V4h14v3M12 4v16M9 20h6',
|
|
56
|
+
lines: 'M4 6h16M4 12h16M4 18h10',
|
|
57
|
+
rows: 'M3 5h18v6H3zM3 13h18v6H3z',
|
|
58
|
+
bold: 'M7 5h6a3.5 3.5 0 0 1 0 7H7zM7 12h7a3.5 3.5 0 0 1 0 7H7z',
|
|
59
|
+
italic: 'M10 5h8M6 19h8M14 5l-4 14',
|
|
60
|
+
heading: 'M6 5v14M18 5v14M6 12h12',
|
|
61
|
+
list: 'M9 6h11M9 12h11M9 18h11M4 6h.01M4 12h.01M4 18h.01',
|
|
62
|
+
'list-ordered': 'M10 6h10M10 12h10M10 18h10M4 5l1.5-1v5M4 14.5a1.5 1.5 0 0 1 3 0c0 1.5-3 2-3 4h3',
|
|
63
|
+
link: 'M10 14a4 4 0 0 0 6 0l3-3a4 4 0 0 0-6-6l-1 1M14 10a4 4 0 0 0-6 0l-3 3a4 4 0 0 0 6 6l1-1',
|
|
64
|
+
hash: 'M5 9h14M5 15h14M10 4L8 20M16 4l-2 16',
|
|
65
|
+
banknote: 'M3 7h18v10H3zM12 9.5a2.5 2.5 0 1 0 0 5a2.5 2.5 0 1 0 0-5zM6.5 10v4M17.5 10v4',
|
|
66
|
+
'check-square': 'M4 4h16v16H4zM8 12l3 3 5-6',
|
|
67
|
+
toggle: 'M8 7h8a5 5 0 0 1 0 10H8A5 5 0 0 1 8 7zM16 9.5a2.5 2.5 0 1 0 0 5a2.5 2.5 0 1 0 0-5z',
|
|
68
|
+
radio: 'M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18zM12 9a3 3 0 1 0 0 6a3 3 0 1 0 0-6z',
|
|
69
|
+
dropdown: 'M3 7h18v10H3zM14 11l2 2 2-2',
|
|
70
|
+
panel: 'M4 4h16v16H4zM4 9h16',
|
|
71
|
+
columns: 'M3 5h7v14H3zM14 5h7v14h-7z',
|
|
72
|
+
grid: 'M4 4h7v7H4zM13 4h7v7h-7zM4 13h7v7H4zM13 13h7v7h-7z',
|
|
73
|
+
tabs: 'M3 9h18v11H3zM3 9V5h7v4M10 5h6v4',
|
|
74
|
+
pointer: 'M6 4l13 6-5.5 2L11 18z',
|
|
75
|
+
};
|
|
76
|
+
export const ICONS = Object.keys(PATHS);
|
|
77
|
+
const SVG = 'http://www.w3.org/2000/svg';
|
|
78
|
+
/** An icon element, or null when the name is unknown. Icons are decorative unless labelled. */
|
|
79
|
+
export function iconNode(name, label = null) {
|
|
80
|
+
const d = PATHS[name];
|
|
81
|
+
if (d === undefined)
|
|
82
|
+
return null;
|
|
83
|
+
const svg = document.createElementNS(SVG, 'svg');
|
|
84
|
+
svg.setAttribute('viewBox', '0 0 24 24');
|
|
85
|
+
svg.setAttribute('class', 'tb-icon');
|
|
86
|
+
if (label === null) {
|
|
87
|
+
svg.setAttribute('aria-hidden', 'true');
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
svg.setAttribute('role', 'img');
|
|
91
|
+
svg.setAttribute('aria-label', label);
|
|
92
|
+
}
|
|
93
|
+
const path = document.createElementNS(SVG, 'path');
|
|
94
|
+
path.setAttribute('d', d);
|
|
95
|
+
svg.append(path);
|
|
96
|
+
return svg;
|
|
97
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import './natives.ts';
|
|
2
|
+
import './net.ts';
|
|
3
|
+
import './page.ts';
|
|
4
|
+
import './compress.ts';
|
|
5
|
+
import './locale.ts';
|
|
6
|
+
import { type Loader } from './modules.ts';
|
|
7
|
+
import { type Cell, type ObjectCell, type Runtime } from '../core/index.ts';
|
|
8
|
+
import { type Scheduler } from './scheduler.ts';
|
|
9
|
+
export { output } from './natives.ts';
|
|
10
|
+
export { fileHandle } from './net.ts';
|
|
11
|
+
export { page } from './page.ts';
|
|
12
|
+
export { mapAt, formatLocal, activeLanguage, shown, translate, uiText, editLocal, readLocal, readDate, weekStart, fileSize, LOCAL_KINDS } from './locale.ts';
|
|
13
|
+
export type { Loader } from './modules.ts';
|
|
14
|
+
export * from './scheduler.ts';
|
|
15
|
+
export interface Host {
|
|
16
|
+
readonly rt: Runtime;
|
|
17
|
+
readonly sch: Scheduler;
|
|
18
|
+
}
|
|
19
|
+
/** Rebol-style multi-line report of an error. */
|
|
20
|
+
export declare function report(e: ObjectCell): string;
|
|
21
|
+
export interface HostOptions {
|
|
22
|
+
/** Reports errors of tasks nobody waits for. */
|
|
23
|
+
onError?: (e: ObjectCell) => void;
|
|
24
|
+
/** How `import` finds files; defaults to fetch relative to the page. */
|
|
25
|
+
loader?: Loader;
|
|
26
|
+
}
|
|
27
|
+
export declare function startHost(opts?: HostOptions): Host;
|
|
28
|
+
/** URL of the UI dialect source, next to this file. */
|
|
29
|
+
export declare const UI_SOURCE: string;
|
|
30
|
+
/** URL of the languages module (i18n, tr, translated). */
|
|
31
|
+
export declare const I18N_SOURCE: string;
|
|
32
|
+
/** URL of the words of screen tests (click, type, see...), which `trebol test` loads. */
|
|
33
|
+
export declare const TEST_SOURCE: string;
|
|
34
|
+
/** Loads languages and the UI dialect (view, layout, stylize, theme...) into the user context. */
|
|
35
|
+
export declare function startUi(host: Host): Promise<Cell>;
|
|
36
|
+
/**
|
|
37
|
+
* Loads source into the user context and runs it as a task. Resolves with
|
|
38
|
+
* its value; rejects with the error! if it fails. Load errors throw LoadError.
|
|
39
|
+
*/
|
|
40
|
+
export declare function runSource(host: Host, src: string, file?: string): Promise<Cell>;
|