@fnndsc/brasa 0.31.4 → 0.32.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/dist/buildinfo.json +1 -1
- package/dist/builtins/fs/pull.js +16 -0
- package/dist/builtins/fs/pull.js.map +1 -1
- package/dist/builtins/games/bytes.d.ts +21 -0
- package/dist/builtins/games/bytes.js +224 -0
- package/dist/builtins/games/bytes.js.map +1 -0
- package/dist/builtins/games/chimes.d.ts +64 -0
- package/dist/builtins/games/chimes.js +223 -0
- package/dist/builtins/games/chimes.js.map +1 -0
- package/dist/builtins/games/cowsay.d.ts +36 -0
- package/dist/builtins/games/cowsay.js +127 -0
- package/dist/builtins/games/cowsay.js.map +1 -0
- package/dist/builtins/games/figlet.d.ts +25 -0
- package/dist/builtins/games/figlet.js +109 -0
- package/dist/builtins/games/figlet.js.map +1 -0
- package/dist/builtins/games/lab.d.ts +51 -0
- package/dist/builtins/games/lab.js +161 -0
- package/dist/builtins/games/lab.js.map +1 -0
- package/dist/builtins/games/lolcat.d.ts +26 -0
- package/dist/builtins/games/lolcat.js +71 -0
- package/dist/builtins/games/lolcat.js.map +1 -0
- package/dist/builtins/games/morse.d.ts +18 -0
- package/dist/builtins/games/morse.js +46 -0
- package/dist/builtins/games/morse.js.map +1 -0
- package/dist/builtins/games/numbers.d.ts +55 -0
- package/dist/builtins/games/numbers.js +270 -0
- package/dist/builtins/games/numbers.js.map +1 -0
- package/dist/builtins/games/play.d.ts +53 -0
- package/dist/builtins/games/play.js +228 -0
- package/dist/builtins/games/play.js.map +1 -0
- package/dist/builtins/games/qr.d.ts +40 -0
- package/dist/builtins/games/qr.js +336 -0
- package/dist/builtins/games/qr.js.map +1 -0
- package/dist/builtins/games/shelf.d.ts +27 -0
- package/dist/builtins/games/shelf.js +71 -0
- package/dist/builtins/games/shelf.js.map +1 -0
- package/dist/builtins/games/show.d.ts +32 -0
- package/dist/builtins/games/show.js +68 -0
- package/dist/builtins/games/show.js.map +1 -0
- package/dist/builtins/games/sky.d.ts +69 -0
- package/dist/builtins/games/sky.js +190 -0
- package/dist/builtins/games/sky.js.map +1 -0
- package/dist/builtins/games/stdin.d.ts +34 -0
- package/dist/builtins/games/stdin.js +48 -0
- package/dist/builtins/games/stdin.js.map +1 -0
- package/dist/builtins/games/text.d.ts +46 -0
- package/dist/builtins/games/text.js +133 -0
- package/dist/builtins/games/text.js.map +1 -0
- package/dist/builtins/games/wtf.d.ts +13 -0
- package/dist/builtins/games/wtf.data.d.ts +12 -0
- package/dist/builtins/games/wtf.data.js +70 -0
- package/dist/builtins/games/wtf.data.js.map +1 -0
- package/dist/builtins/games/wtf.js +45 -0
- package/dist/builtins/games/wtf.js.map +1 -0
- package/dist/builtins/help.d.ts +8 -0
- package/dist/builtins/help.js +296 -0
- package/dist/builtins/help.js.map +1 -1
- package/dist/core/dispatch.js +125 -9
- package/dist/core/dispatch.js.map +1 -1
- package/dist/core/engine.js +1 -0
- package/dist/core/engine.js.map +1 -1
- package/dist/core/surface.d.ts +14 -0
- package/dist/core/surface.js.map +1 -1
- package/dist/lib/vfs/providers/static.js +15 -1
- package/dist/lib/vfs/providers/static.js.map +1 -1
- package/dist/lib/vfs/providers/static_content.js +2 -2
- package/dist/lib/vfs/providers/static_content.js.map +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file `qr`: a QR code in the console, for a phone to read off the screen.
|
|
3
|
+
*
|
|
4
|
+
* A small encoder of its own — byte mode, error correction level L,
|
|
5
|
+
* versions 1 to 10 (up to 271 bytes) — drawn in half-block characters so a
|
|
6
|
+
* code is half as tall as it is wide, with the light modules bright: on a
|
|
7
|
+
* dark console that is what a camera reads. No library: the whole of it
|
|
8
|
+
* is below, and a surface may draw the matrix in the model its own way.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
import { envelope_ok, envelope_error } from '@fnndsc/cumin';
|
|
13
|
+
import { text_input } from './stdin.js';
|
|
14
|
+
/** Data codewords per version at level L (1..10). */
|
|
15
|
+
const DATA_CODEWORDS = [0, 19, 34, 55, 80, 108, 136, 156, 194, 232, 274];
|
|
16
|
+
/** Error-correction codewords per block, and the block counts, per version at level L. */
|
|
17
|
+
const EC_PER_BLOCK = [0, 7, 10, 15, 20, 26, 18, 20, 24, 30, 18];
|
|
18
|
+
const BLOCKS = [0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4];
|
|
19
|
+
/** Alignment pattern centres per version. */
|
|
20
|
+
const ALIGNMENT = [[], [], [6, 18], [6, 22], [6, 26], [6, 30], [6, 34], [6, 22, 38], [6, 24, 42], [6, 26, 46], [6, 28, 50]];
|
|
21
|
+
/** Version information bits for versions 7..10. */
|
|
22
|
+
const VERSION_BITS = { 7: 0x07c94, 8: 0x085bc, 9: 0x09a99, 10: 0x0a4d3 };
|
|
23
|
+
/** Format information bits for level L, by mask. */
|
|
24
|
+
const FORMAT_BITS = [0x77c4, 0x72f3, 0x7daa, 0x789d, 0x662f, 0x6318, 0x6c41, 0x6976];
|
|
25
|
+
/** The most bytes the biggest version here carries. */
|
|
26
|
+
export const QR_MAX_BYTES = 271;
|
|
27
|
+
/* -------------------------------------------------- Galois field */
|
|
28
|
+
const EXP = new Array(512).fill(0);
|
|
29
|
+
const LOG = new Array(256).fill(0);
|
|
30
|
+
(() => {
|
|
31
|
+
let x = 1;
|
|
32
|
+
for (let i = 0; i < 255; i++) {
|
|
33
|
+
EXP[i] = x;
|
|
34
|
+
LOG[x] = i;
|
|
35
|
+
x <<= 1;
|
|
36
|
+
if (x & 0x100)
|
|
37
|
+
x ^= 0x11d;
|
|
38
|
+
}
|
|
39
|
+
for (let i = 255; i < 512; i++)
|
|
40
|
+
EXP[i] = EXP[i - 255];
|
|
41
|
+
})();
|
|
42
|
+
const gf_mul = (a, b) => (a === 0 || b === 0 ? 0 : EXP[(LOG[a] + LOG[b]) % 255]);
|
|
43
|
+
/** The Reed–Solomon remainder of `data` for `ec` check codewords. */
|
|
44
|
+
export function rs_remainder(data, ec) {
|
|
45
|
+
let gen = [1];
|
|
46
|
+
for (let i = 0; i < ec; i++) {
|
|
47
|
+
const next = new Array(gen.length + 1).fill(0);
|
|
48
|
+
for (let j = 0; j < gen.length; j++) {
|
|
49
|
+
next[j] ^= gen[j];
|
|
50
|
+
next[j + 1] ^= gf_mul(gen[j], EXP[i]);
|
|
51
|
+
}
|
|
52
|
+
gen = next;
|
|
53
|
+
}
|
|
54
|
+
const rem = new Array(ec).fill(0);
|
|
55
|
+
for (const byte of data) {
|
|
56
|
+
const factor = byte ^ rem.shift();
|
|
57
|
+
rem.push(0);
|
|
58
|
+
for (let j = 0; j < ec; j++)
|
|
59
|
+
rem[j] ^= gf_mul(gen[j + 1], factor);
|
|
60
|
+
}
|
|
61
|
+
return rem;
|
|
62
|
+
}
|
|
63
|
+
function matrix_make(size) {
|
|
64
|
+
return { size, dark: Array.from({ length: size }, () => new Array(size).fill(false)), fixed: Array.from({ length: size }, () => new Array(size).fill(false)) };
|
|
65
|
+
}
|
|
66
|
+
function module_set(m, r, c, dark) {
|
|
67
|
+
m.dark[r][c] = dark;
|
|
68
|
+
m.fixed[r][c] = true;
|
|
69
|
+
}
|
|
70
|
+
function finder_draw(m, r0, c0) {
|
|
71
|
+
for (let r = -1; r <= 7; r++) {
|
|
72
|
+
for (let c = -1; c <= 7; c++) {
|
|
73
|
+
const rr = r0 + r;
|
|
74
|
+
const cc = c0 + c;
|
|
75
|
+
if (rr < 0 || cc < 0 || rr >= m.size || cc >= m.size)
|
|
76
|
+
continue;
|
|
77
|
+
const ring = Math.max(Math.abs(r - 3), Math.abs(c - 3));
|
|
78
|
+
module_set(m, rr, cc, ring !== 2 && ring !== 4);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function functions_draw(m, version) {
|
|
83
|
+
finder_draw(m, 0, 0);
|
|
84
|
+
finder_draw(m, 0, m.size - 7);
|
|
85
|
+
finder_draw(m, m.size - 7, 0);
|
|
86
|
+
for (let i = 8; i < m.size - 8; i++) {
|
|
87
|
+
module_set(m, 6, i, i % 2 === 0);
|
|
88
|
+
module_set(m, i, 6, i % 2 === 0);
|
|
89
|
+
}
|
|
90
|
+
const centres = ALIGNMENT[version] ?? [];
|
|
91
|
+
const outer = centres[centres.length - 1] ?? -1;
|
|
92
|
+
for (const r of centres) {
|
|
93
|
+
for (const c of centres) {
|
|
94
|
+
// The three that would sit on a finder (the first and the outermost
|
|
95
|
+
// centres, paired) are left out; one on the timing pattern is drawn
|
|
96
|
+
// over it, as the standard has it.
|
|
97
|
+
if ((r === 6 && c === 6) || (r === 6 && c === outer) || (r === outer && c === 6))
|
|
98
|
+
continue;
|
|
99
|
+
for (let dr = -2; dr <= 2; dr++)
|
|
100
|
+
for (let dc = -2; dc <= 2; dc++)
|
|
101
|
+
module_set(m, r + dr, c + dc, Math.max(Math.abs(dr), Math.abs(dc)) !== 1);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
// The format areas are reserved now and written after the mask is chosen.
|
|
105
|
+
for (let i = 0; i < 9; i++) {
|
|
106
|
+
if (i !== 6) {
|
|
107
|
+
module_set(m, 8, i, false);
|
|
108
|
+
module_set(m, i, 8, false);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
for (let i = 0; i < 8; i++) {
|
|
112
|
+
module_set(m, 8, m.size - 1 - i, false);
|
|
113
|
+
module_set(m, m.size - 1 - i, 8, false);
|
|
114
|
+
}
|
|
115
|
+
module_set(m, m.size - 8, 8, true);
|
|
116
|
+
if (version >= 7) {
|
|
117
|
+
const bits = VERSION_BITS[version];
|
|
118
|
+
for (let i = 0; i < 18; i++) {
|
|
119
|
+
const dark = ((bits >> i) & 1) === 1;
|
|
120
|
+
module_set(m, Math.floor(i / 3), m.size - 11 + (i % 3), dark);
|
|
121
|
+
module_set(m, m.size - 11 + (i % 3), Math.floor(i / 3), dark);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
function format_draw(m, mask) {
|
|
126
|
+
const bits = FORMAT_BITS[mask];
|
|
127
|
+
const bit = (i) => ((bits >> i) & 1) === 1;
|
|
128
|
+
// First copy: down column 8 beside the top-left finder, then along row 8.
|
|
129
|
+
for (let i = 0; i <= 5; i++)
|
|
130
|
+
module_set(m, i, 8, bit(i));
|
|
131
|
+
module_set(m, 7, 8, bit(6));
|
|
132
|
+
module_set(m, 8, 8, bit(7));
|
|
133
|
+
module_set(m, 8, 7, bit(8));
|
|
134
|
+
for (let i = 9; i < 15; i++)
|
|
135
|
+
module_set(m, 8, 14 - i, bit(i));
|
|
136
|
+
// Second copy: along row 8 under the top-right finder, down column 8 beside the bottom-left.
|
|
137
|
+
for (let i = 0; i < 8; i++)
|
|
138
|
+
module_set(m, 8, m.size - 1 - i, bit(i));
|
|
139
|
+
for (let i = 8; i < 15; i++)
|
|
140
|
+
module_set(m, m.size - 15 + i, 8, bit(i));
|
|
141
|
+
}
|
|
142
|
+
function mask_bit(mask, r, c) {
|
|
143
|
+
switch (mask) {
|
|
144
|
+
case 0: return (r + c) % 2 === 0;
|
|
145
|
+
case 1: return r % 2 === 0;
|
|
146
|
+
case 2: return c % 3 === 0;
|
|
147
|
+
case 3: return (r + c) % 3 === 0;
|
|
148
|
+
case 4: return (Math.floor(r / 2) + Math.floor(c / 3)) % 2 === 0;
|
|
149
|
+
case 5: return ((r * c) % 2) + ((r * c) % 3) === 0;
|
|
150
|
+
case 6: return (((r * c) % 2) + ((r * c) % 3)) % 2 === 0;
|
|
151
|
+
default: return (((r + c) % 2) + ((r * c) % 3)) % 2 === 0;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
function data_place(m, codewords, mask) {
|
|
155
|
+
let bitIndex = 0;
|
|
156
|
+
const total = codewords.length * 8;
|
|
157
|
+
let upward = true;
|
|
158
|
+
for (let right = m.size - 1; right >= 1; right -= 2) {
|
|
159
|
+
if (right === 6)
|
|
160
|
+
right = 5;
|
|
161
|
+
for (let step = 0; step < m.size; step++) {
|
|
162
|
+
const r = upward ? m.size - 1 - step : step;
|
|
163
|
+
for (const c of [right, right - 1]) {
|
|
164
|
+
if (m.fixed[r][c])
|
|
165
|
+
continue;
|
|
166
|
+
let dark = false;
|
|
167
|
+
if (bitIndex < total) {
|
|
168
|
+
dark = (codewords[bitIndex >> 3] >> (7 - (bitIndex & 7)) & 1) === 1;
|
|
169
|
+
bitIndex++;
|
|
170
|
+
}
|
|
171
|
+
if (mask_bit(mask, r, c))
|
|
172
|
+
dark = !dark;
|
|
173
|
+
m.dark[r][c] = dark;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
upward = !upward;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
/** The penalty of a drawn matrix, by the four rules; lower is better. */
|
|
180
|
+
export function penalty_of(dark) {
|
|
181
|
+
const n = dark.length;
|
|
182
|
+
let score = 0;
|
|
183
|
+
const run = (line) => {
|
|
184
|
+
let count = 1;
|
|
185
|
+
for (let i = 1; i <= n; i++) {
|
|
186
|
+
if (i < n && line[i] === line[i - 1]) {
|
|
187
|
+
count++;
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
if (count >= 5)
|
|
191
|
+
score += 3 + (count - 5);
|
|
192
|
+
count = 1;
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
for (let i = 0; i < n; i++) {
|
|
196
|
+
run(dark[i]);
|
|
197
|
+
run(dark.map((row) => row[i]));
|
|
198
|
+
}
|
|
199
|
+
for (let r = 0; r < n - 1; r++)
|
|
200
|
+
for (let c = 0; c < n - 1; c++) {
|
|
201
|
+
const v = dark[r][c];
|
|
202
|
+
if (v === dark[r][c + 1] && v === dark[r + 1][c] && v === dark[r + 1][c + 1])
|
|
203
|
+
score += 3;
|
|
204
|
+
}
|
|
205
|
+
const pattern = [true, false, true, true, true, false, true, false, false, false, false];
|
|
206
|
+
const matches = (line, start, p) => p.every((v, i) => line[start + i] === v);
|
|
207
|
+
const reversed = [...pattern].reverse();
|
|
208
|
+
for (let i = 0; i < n; i++) {
|
|
209
|
+
const row = dark[i];
|
|
210
|
+
const col = dark.map((r) => r[i]);
|
|
211
|
+
for (let s = 0; s + 11 <= n; s++) {
|
|
212
|
+
if (matches(row, s, pattern) || matches(row, s, reversed))
|
|
213
|
+
score += 40;
|
|
214
|
+
if (matches(col, s, pattern) || matches(col, s, reversed))
|
|
215
|
+
score += 40;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
let darkCount = 0;
|
|
219
|
+
for (const row of dark)
|
|
220
|
+
for (const v of row)
|
|
221
|
+
if (v)
|
|
222
|
+
darkCount++;
|
|
223
|
+
const percent = (darkCount * 100) / (n * n);
|
|
224
|
+
score += Math.floor(Math.abs(percent - 50) / 5) * 10;
|
|
225
|
+
return score;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Encodes bytes as a QR matrix.
|
|
229
|
+
*
|
|
230
|
+
* @param text - The text (UTF-8).
|
|
231
|
+
* @param maskForced - A mask to use instead of the least-penalty one (a test's seam).
|
|
232
|
+
* @returns The dark/light matrix, its version and the mask chosen; null when too long.
|
|
233
|
+
*/
|
|
234
|
+
export function qr_encode(text, maskForced) {
|
|
235
|
+
const bytes = Buffer.from(text, 'utf-8');
|
|
236
|
+
let version = 0;
|
|
237
|
+
for (let v = 1; v <= 10; v++) {
|
|
238
|
+
const capacity = DATA_CODEWORDS[v] - (v >= 10 ? 3 : 2);
|
|
239
|
+
if (bytes.length <= capacity) {
|
|
240
|
+
version = v;
|
|
241
|
+
break;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
if (version === 0)
|
|
245
|
+
return null;
|
|
246
|
+
const dataCount = DATA_CODEWORDS[version];
|
|
247
|
+
// The bit stream: mode 0100, the count (8 bits below version 10, 16 at it), the bytes, a terminator, padding.
|
|
248
|
+
const bits = [];
|
|
249
|
+
const push = (value, width) => { for (let i = width - 1; i >= 0; i--)
|
|
250
|
+
bits.push((value >> i) & 1); };
|
|
251
|
+
push(0b0100, 4);
|
|
252
|
+
push(bytes.length, version >= 10 ? 16 : 8);
|
|
253
|
+
for (const b of bytes)
|
|
254
|
+
push(b, 8);
|
|
255
|
+
push(0, Math.min(4, dataCount * 8 - bits.length));
|
|
256
|
+
while (bits.length % 8 !== 0)
|
|
257
|
+
bits.push(0);
|
|
258
|
+
const data = [];
|
|
259
|
+
for (let i = 0; i < bits.length; i += 8)
|
|
260
|
+
data.push(bits.slice(i, i + 8).reduce((a, b) => (a << 1) | b, 0));
|
|
261
|
+
for (let pad = 0; data.length < dataCount; pad++)
|
|
262
|
+
data.push(pad % 2 === 0 ? 0xec : 0x11);
|
|
263
|
+
// Blocks: the short ones first, then the long; interleaved for the stream.
|
|
264
|
+
const blocks = BLOCKS[version];
|
|
265
|
+
const ec = EC_PER_BLOCK[version];
|
|
266
|
+
const shortLength = Math.floor(dataCount / blocks);
|
|
267
|
+
const longBlocks = dataCount % blocks;
|
|
268
|
+
const dataBlocks = [];
|
|
269
|
+
const ecBlocks = [];
|
|
270
|
+
let at = 0;
|
|
271
|
+
for (let b = 0; b < blocks; b++) {
|
|
272
|
+
const length = shortLength + (b >= blocks - longBlocks ? 1 : 0);
|
|
273
|
+
const block = data.slice(at, at + length);
|
|
274
|
+
at += length;
|
|
275
|
+
dataBlocks.push(block);
|
|
276
|
+
ecBlocks.push(rs_remainder(block, ec));
|
|
277
|
+
}
|
|
278
|
+
const codewords = [];
|
|
279
|
+
for (let i = 0; i <= shortLength; i++)
|
|
280
|
+
for (const block of dataBlocks)
|
|
281
|
+
if (i < block.length)
|
|
282
|
+
codewords.push(block[i]);
|
|
283
|
+
for (let i = 0; i < ec; i++)
|
|
284
|
+
for (const block of ecBlocks)
|
|
285
|
+
codewords.push(block[i]);
|
|
286
|
+
// Every mask drawn; the one with the least penalty stands.
|
|
287
|
+
const size = 17 + version * 4;
|
|
288
|
+
let best = null;
|
|
289
|
+
for (let mask = 0; mask < 8; mask++) {
|
|
290
|
+
if (maskForced !== undefined && mask !== maskForced)
|
|
291
|
+
continue;
|
|
292
|
+
const m = matrix_make(size);
|
|
293
|
+
functions_draw(m, version);
|
|
294
|
+
data_place(m, codewords, mask);
|
|
295
|
+
format_draw(m, mask);
|
|
296
|
+
const penalty = penalty_of(m.dark);
|
|
297
|
+
if (best === null || penalty < best.penalty)
|
|
298
|
+
best = { dark: m.dark, mask, penalty };
|
|
299
|
+
}
|
|
300
|
+
return { size, dark: best.dark, version, mask: best.mask };
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Draws a matrix in half blocks, light modules bright, a quiet zone round it.
|
|
304
|
+
*
|
|
305
|
+
* @param dark - The matrix.
|
|
306
|
+
* @returns The lines.
|
|
307
|
+
*/
|
|
308
|
+
export function qr_render(dark) {
|
|
309
|
+
const n = dark.length;
|
|
310
|
+
const quiet = 2;
|
|
311
|
+
const light = (r, c) => r < 0 || c < 0 || r >= n || c >= n ? true : !dark[r][c];
|
|
312
|
+
const lines = [];
|
|
313
|
+
for (let r = -quiet; r < n + quiet; r += 2) {
|
|
314
|
+
let line = '';
|
|
315
|
+
for (let c = -quiet; c < n + quiet; c++) {
|
|
316
|
+
const top = light(r, c);
|
|
317
|
+
const bottom = light(r + 1, c);
|
|
318
|
+
line += top && bottom ? '█' : top ? '▀' : bottom ? '▄' : ' ';
|
|
319
|
+
}
|
|
320
|
+
lines.push(line);
|
|
321
|
+
}
|
|
322
|
+
return lines;
|
|
323
|
+
}
|
|
324
|
+
/** `qr <text>` */
|
|
325
|
+
export async function builtin_qr(args) {
|
|
326
|
+
const text = text_input(args);
|
|
327
|
+
if (text === null)
|
|
328
|
+
return envelope_error('', undefined, 'qr: usage: qr <text or URL> (up to 271 bytes)\n');
|
|
329
|
+
const said = text.replace(/\n$/, '');
|
|
330
|
+
const code = qr_encode(said);
|
|
331
|
+
if (code === null)
|
|
332
|
+
return envelope_error('', undefined, `qr: too long for the codes drawn here (${Buffer.byteLength(said, 'utf-8')} bytes; at most ${QR_MAX_BYTES})\n`);
|
|
333
|
+
const rows = code.dark.map((row) => row.map((d) => (d ? '1' : '0')).join(''));
|
|
334
|
+
return envelope_ok(`${qr_render(code.dark).join('\n')}\n`, { kind: 'games.qr', data: { text: said, version: code.version, size: code.size, rows } });
|
|
335
|
+
}
|
|
336
|
+
//# sourceMappingURL=qr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qr.js","sourceRoot":"","sources":["../../../src/builtins/games/qr.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAmB,WAAW,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,qDAAqD;AACrD,MAAM,cAAc,GAA0B,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AAChG,0FAA0F;AAC1F,MAAM,YAAY,GAA0B,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;AACvF,MAAM,MAAM,GAA0B,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACxE,6CAA6C;AAC7C,MAAM,SAAS,GAAyC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,EA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CAAU,EAAU,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IAC5H,OAAO,WAAW,CAAC,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;AACvJ,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** One category on the shelf. */
|
|
2
|
+
export interface GamesCategory {
|
|
3
|
+
/** The heading, as the page prints it. */
|
|
4
|
+
title: string;
|
|
5
|
+
/** What the category holds, in a line. */
|
|
6
|
+
note: string;
|
|
7
|
+
/** The commands, in the order the page lists them. */
|
|
8
|
+
commands: ReadonlyArray<string>;
|
|
9
|
+
}
|
|
10
|
+
/** The shelf, in reading order. A command appears once. */
|
|
11
|
+
export declare const GAMES_SHELF: ReadonlyArray<GamesCategory>;
|
|
12
|
+
/** A command's one-line summary, when it has a help entry. */
|
|
13
|
+
export type SummaryLookup = (command: string) => string | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* The commands on the shelf that exist: those with a help entry.
|
|
16
|
+
*
|
|
17
|
+
* @param summary_of - The help lookup.
|
|
18
|
+
* @returns The names, shelf order.
|
|
19
|
+
*/
|
|
20
|
+
export declare function gamesShelf_names(summary_of: SummaryLookup): string[];
|
|
21
|
+
/**
|
|
22
|
+
* Renders `help games`: the shelf by category, in the style of bare `help`.
|
|
23
|
+
*
|
|
24
|
+
* @param summary_of - The help lookup; a command without one is left off.
|
|
25
|
+
* @returns The page.
|
|
26
|
+
*/
|
|
27
|
+
export declare function gamesShelf_render(summary_of: SummaryLookup): string;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The games shelf: `/usr/games`, as BSD shipped it.
|
|
3
|
+
*
|
|
4
|
+
* BSD kept its small pleasures apart from its tools — `fortune`, `pom`,
|
|
5
|
+
* `wtf`, `worms` — in `/usr/games`, with their own manual section. chell
|
|
6
|
+
* keeps the same shelf: `help games` lists it in categories, `ls /usr/games`
|
|
7
|
+
* walks it, and each command's help is the one declaration it has (in
|
|
8
|
+
* `help.ts`, where every command's is). The shelf names the commands and
|
|
9
|
+
* their categories only; a name here with no help entry is not listed, so
|
|
10
|
+
* the page never promises a command that has not landed.
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
import chalk from 'chalk';
|
|
15
|
+
/** The shelf, in reading order. A command appears once. */
|
|
16
|
+
export const GAMES_SHELF = [
|
|
17
|
+
{
|
|
18
|
+
title: 'Text toys',
|
|
19
|
+
note: 'pipe fodder: fortune | cowsay, and friends',
|
|
20
|
+
commands: ['fortune', 'cowsay', 'cowthink', 'figlet', 'banner', 'lolcat', 'rev', 'tac', 'yes', 'seq', 'factor', 'primes', 'shuf', 'roll', 'rot13', 'morse', 'calc', 'units'],
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
title: 'Time and sky',
|
|
24
|
+
note: 'the calendar, the weather, the moon and the stardate',
|
|
25
|
+
commands: ['cal', 'date', 'weather', 'stardate', 'pom', 'sunrise', 'ddate', 'leave', 'timer', 'stopwatch'],
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
title: "The lab's own",
|
|
29
|
+
note: 'small tools that happen to be fun',
|
|
30
|
+
commands: ['motd', 'wtf', 'chrisfetch', 'who', 'uptime', 'ping', 'qr', 'file', 'xxd', 'strings', 'sha256sum', 'md5sum', 'say'],
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
title: 'Showpieces and games',
|
|
34
|
+
note: 'drawn in ARGUS; the console gets the text',
|
|
35
|
+
commands: ['sl', 'cmatrix', 'asciiquarium', 'rain', 'tetris', '2048', 'snake', 'quiz', 'hangman'],
|
|
36
|
+
},
|
|
37
|
+
];
|
|
38
|
+
/**
|
|
39
|
+
* The commands on the shelf that exist: those with a help entry.
|
|
40
|
+
*
|
|
41
|
+
* @param summary_of - The help lookup.
|
|
42
|
+
* @returns The names, shelf order.
|
|
43
|
+
*/
|
|
44
|
+
export function gamesShelf_names(summary_of) {
|
|
45
|
+
return GAMES_SHELF.flatMap((category) => category.commands.filter((command) => summary_of(command) !== undefined));
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Renders `help games`: the shelf by category, in the style of bare `help`.
|
|
49
|
+
*
|
|
50
|
+
* @param summary_of - The help lookup; a command without one is left off.
|
|
51
|
+
* @returns The page.
|
|
52
|
+
*/
|
|
53
|
+
export function gamesShelf_render(summary_of) {
|
|
54
|
+
let out = '\n';
|
|
55
|
+
out += `${chalk.bold.cyan('/usr/games — the shelf')}\n`;
|
|
56
|
+
out += `${chalk.gray('─'.repeat(60))}\n`;
|
|
57
|
+
out += `${chalk.gray('Small pleasures, kept apart from the tools as BSD kept them. Every one is built in: no host binary, same words in chell and ARGUS.')}\n\n`;
|
|
58
|
+
for (const category of GAMES_SHELF) {
|
|
59
|
+
const present = category.commands.filter((command) => summary_of(command) !== undefined);
|
|
60
|
+
if (present.length === 0)
|
|
61
|
+
continue;
|
|
62
|
+
out += `${chalk.bold.yellow(category.title)} ${chalk.gray(category.note)}\n`;
|
|
63
|
+
for (const command of present) {
|
|
64
|
+
out += ` ${chalk.cyan(command.padEnd(20))} ${chalk.gray(summary_of(command) ?? '')}\n`;
|
|
65
|
+
}
|
|
66
|
+
out += '\n';
|
|
67
|
+
}
|
|
68
|
+
out += `${chalk.gray('Type "help <command>" for one of them; "ls /usr/games" walks the shelf.')}\n\n`;
|
|
69
|
+
return out;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=shelf.js.map
|
|
@@ -0,0 +1 @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;IACD,GAAG,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,yEAAyE,CAAC,MAAM,CAAC;IACtG,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The showpieces — `sl`, `cmatrix`, `rain`, `asciiquarium` — and the
|
|
3
|
+
* arcade: `tetris`, `snake`.
|
|
4
|
+
*
|
|
5
|
+
* Each is a program a surface with a canvas runs: ARGUS opens its GAMES
|
|
6
|
+
* pane on the `games.show` model and draws. The console gets the text: a
|
|
7
|
+
* still of the show, or the words that there is nothing to play here and
|
|
8
|
+
* where there is.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
import { CommandEnvelope } from '@fnndsc/cumin';
|
|
13
|
+
/** The programs a GAMES pane can run. */
|
|
14
|
+
export type ShowProgram = 'sl' | 'cmatrix' | 'rain' | 'aquarium' | 'tetris' | 'snake';
|
|
15
|
+
/** The starship `sl` sends across the screen (a typo's punishment, as the train was). */
|
|
16
|
+
export declare const STARSHIP: ReadonlyArray<string>;
|
|
17
|
+
/** The glyphs `cmatrix` rains. */
|
|
18
|
+
export declare const MATRIX_GLYPHS: string;
|
|
19
|
+
/** A still of a show, for a console with no canvas. */
|
|
20
|
+
export declare function still_of(program: ShowProgram, random?: () => number): string[];
|
|
21
|
+
/** `sl`: a starship crosses the screen. */
|
|
22
|
+
export declare function builtin_sl(args: string[]): Promise<CommandEnvelope>;
|
|
23
|
+
/** `cmatrix`: the glyph rain. */
|
|
24
|
+
export declare function builtin_cmatrix(args: string[]): Promise<CommandEnvelope>;
|
|
25
|
+
/** `rain`: rain. */
|
|
26
|
+
export declare function builtin_rain(args: string[]): Promise<CommandEnvelope>;
|
|
27
|
+
/** `asciiquarium`: fish. */
|
|
28
|
+
export declare function builtin_asciiquarium(args: string[]): Promise<CommandEnvelope>;
|
|
29
|
+
/** `tetris`: falling blocks, in ARGUS. */
|
|
30
|
+
export declare function builtin_tetris(args: string[]): Promise<CommandEnvelope>;
|
|
31
|
+
/** `snake`: the snake, in ARGUS. */
|
|
32
|
+
export declare function builtin_snake(args: string[]): Promise<CommandEnvelope>;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The showpieces — `sl`, `cmatrix`, `rain`, `asciiquarium` — and the
|
|
3
|
+
* arcade: `tetris`, `snake`.
|
|
4
|
+
*
|
|
5
|
+
* Each is a program a surface with a canvas runs: ARGUS opens its GAMES
|
|
6
|
+
* pane on the `games.show` model and draws. The console gets the text: a
|
|
7
|
+
* still of the show, or the words that there is nothing to play here and
|
|
8
|
+
* where there is.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
import { envelope_ok } from '@fnndsc/cumin';
|
|
13
|
+
import chalk from 'chalk';
|
|
14
|
+
/** The starship `sl` sends across the screen (a typo's punishment, as the train was). */
|
|
15
|
+
export const STARSHIP = [
|
|
16
|
+
' __ ',
|
|
17
|
+
' _______/ \\______ ',
|
|
18
|
+
' ____/ [] [] [] [] [] \\____ ',
|
|
19
|
+
' <____ ARGUS ================>> ',
|
|
20
|
+
' \\_______ ______/ ',
|
|
21
|
+
' \\/ ',
|
|
22
|
+
];
|
|
23
|
+
/** The glyphs `cmatrix` rains. */
|
|
24
|
+
export const MATRIX_GLYPHS = 'ハミヒーウシナモニサワツオリアホテマケメエカキムユラセネスタヌヘ0123456789Z:・.=*+-<>¦|';
|
|
25
|
+
/** A still of a show, for a console with no canvas. */
|
|
26
|
+
export function still_of(program, random = Math.random) {
|
|
27
|
+
const pick = (s) => s[Math.floor(random() * s.length)];
|
|
28
|
+
switch (program) {
|
|
29
|
+
case 'sl': return [...STARSHIP];
|
|
30
|
+
case 'cmatrix': return Array.from({ length: 6 }, () => Array.from({ length: 40 }, () => (random() < 0.35 ? pick(MATRIX_GLYPHS) : ' ')).join(''));
|
|
31
|
+
case 'rain': return Array.from({ length: 5 }, (_, row) => Array.from({ length: 40 }, () => (random() < 0.12 ? (row === 4 ? 'o' : '|') : ' ')).join(''));
|
|
32
|
+
case 'aquarium': return [
|
|
33
|
+
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~',
|
|
34
|
+
' ><> o ',
|
|
35
|
+
' <>< o ',
|
|
36
|
+
' ><> ><> ',
|
|
37
|
+
' )( )( )( )( )( )( ',
|
|
38
|
+
' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^',
|
|
39
|
+
];
|
|
40
|
+
case 'tetris': return [
|
|
41
|
+
' | |', ' | ## |', ' | ## |', ' | |', ' | # # ## |', ' | #### ###|', ' +----------+',
|
|
42
|
+
];
|
|
43
|
+
case 'snake': return [' . . . . . . . .', ' . @ o o o . . .', ' . . . . o . . .', ' . . * . . . . .'];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/** What the console says beside a still: where the moving one is. */
|
|
47
|
+
function note_of(program, arcade) {
|
|
48
|
+
return arcade
|
|
49
|
+
? chalk.gray(`${program} plays in ARGUS: type it there and the GAMES pane opens with the keys live (arrows; Esc gives the keyboard back).`)
|
|
50
|
+
: chalk.gray(`a still; ARGUS draws ${program} moving in its GAMES pane.`);
|
|
51
|
+
}
|
|
52
|
+
function show_run(program, args, arcade) {
|
|
53
|
+
const still = still_of(program);
|
|
54
|
+
return envelope_ok(`${still.join('\n')}\n${note_of(program, arcade)}\n`, { kind: 'games.show', data: { program, args, arcade } });
|
|
55
|
+
}
|
|
56
|
+
/** `sl`: a starship crosses the screen. */
|
|
57
|
+
export async function builtin_sl(args) { return show_run('sl', args, false); }
|
|
58
|
+
/** `cmatrix`: the glyph rain. */
|
|
59
|
+
export async function builtin_cmatrix(args) { return show_run('cmatrix', args, false); }
|
|
60
|
+
/** `rain`: rain. */
|
|
61
|
+
export async function builtin_rain(args) { return show_run('rain', args, false); }
|
|
62
|
+
/** `asciiquarium`: fish. */
|
|
63
|
+
export async function builtin_asciiquarium(args) { return show_run('aquarium', args, false); }
|
|
64
|
+
/** `tetris`: falling blocks, in ARGUS. */
|
|
65
|
+
export async function builtin_tetris(args) { return show_run('tetris', args, true); }
|
|
66
|
+
/** `snake`: the snake, in ARGUS. */
|
|
67
|
+
export async function builtin_snake(args) { return show_run('snake', args, true); }
|
|
68
|
+
//# sourceMappingURL=show.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"show.js","sourceRoot":"","sources":["../../../src/builtins/games/show.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAmB,WAAW,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,yFAAyF;AACzF,MAAM,CAAC,MAAM,QAAQ,GAA0B;IAC7C,sCAAsC;IACtC,uCAAuC;IACvC,uCAAuC;IACvC,sCAAsC;IACtC,uCAAuC;IACvC,uCAAuC;CACxC,CAAC;AAEF,kCAAkC;AAClC,MAAM,CAAC,MAAM,aAAa,GAAW,wDAAwD,CAAC;AAE9F,uDAAuD;AACvD,MAAM,UAAU,QAAQ,CAAC,OAAoB,EAAE,SAAuB,IAAI,CAAC,MAAM;IAC/E,MAAM,IAAI,GAAG,CAAC,CAAS,EAAU,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,CAAW,CAAC;IACjF,QAAQ,OAAO,EAAE,CAAC;QAChB,KAAK,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,QAAQ,CAAC,CAAC;QAChC,KAAK,SAAS,CAAC,CAAC,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,GAAW,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,GAAW,EAAE,CAAC,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,C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`.
|
|
3
|
+
*
|
|
4
|
+
* `pom` is BSD's phase of the moon; `stardate` reckons the day two ways;
|
|
5
|
+
* `ddate` is the Discordian calendar, holy days included; `sunrise` asks
|
|
6
|
+
* Open-Meteo (the service `weather` already uses, no key) when the sun
|
|
7
|
+
* rises and sets at a place.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
import { CommandEnvelope } from '@fnndsc/cumin';
|
|
12
|
+
import { type WeatherFetch, type WeatherPlace } from '../sys/weather.js';
|
|
13
|
+
/** A date as a Julian day. */
|
|
14
|
+
export declare function julianDay_of(date: Date): number;
|
|
15
|
+
/** The moon's state on a date. */
|
|
16
|
+
export interface MoonPhase {
|
|
17
|
+
/** 0 at new, 0.5 at full, in [0, 1). */
|
|
18
|
+
phase: number;
|
|
19
|
+
/** The lit fraction, 0..1. */
|
|
20
|
+
illumination: number;
|
|
21
|
+
/** The phase's name. */
|
|
22
|
+
name: string;
|
|
23
|
+
/** Days to the next full moon and the next new moon. */
|
|
24
|
+
toFull: number;
|
|
25
|
+
toNew: number;
|
|
26
|
+
}
|
|
27
|
+
/** Where the moon stands on a date. */
|
|
28
|
+
export declare function moon_phase(date: Date): MoonPhase;
|
|
29
|
+
/** A small moon, lit from the side the phase lights. */
|
|
30
|
+
export declare function moon_draw(phase: MoonPhase): string[];
|
|
31
|
+
/** `pom [YYYY-MM-DD]` */
|
|
32
|
+
export declare function builtin_pom(args: string[]): Promise<CommandEnvelope>;
|
|
33
|
+
/** The stardate two ways: the Kelvin films' `YYYY.DDD`, and TNG's thousand-per-year from 2323. */
|
|
34
|
+
export declare function stardate_of(date: Date): {
|
|
35
|
+
kelvin: string;
|
|
36
|
+
tng: string;
|
|
37
|
+
};
|
|
38
|
+
/** `stardate` */
|
|
39
|
+
export declare function builtin_stardate(args: string[]): Promise<CommandEnvelope>;
|
|
40
|
+
/** The Discordian date of a Gregorian one. */
|
|
41
|
+
export interface DiscordianDate {
|
|
42
|
+
yold: number;
|
|
43
|
+
season: string;
|
|
44
|
+
day: number;
|
|
45
|
+
weekday: string;
|
|
46
|
+
holyday: string | null;
|
|
47
|
+
tibs: boolean;
|
|
48
|
+
}
|
|
49
|
+
export declare function ddate_of(date: Date): DiscordianDate;
|
|
50
|
+
/** 1st, 2nd, 3rd, 4th … 11th, 12th, 13th … 21st. */
|
|
51
|
+
export declare function ordinal_of(n: number): string;
|
|
52
|
+
/** `ddate [YYYY-MM-DD]` */
|
|
53
|
+
export declare function builtin_ddate(args: string[]): Promise<CommandEnvelope>;
|
|
54
|
+
/** What Open-Meteo says of one day's sun. */
|
|
55
|
+
export interface SunDay {
|
|
56
|
+
date: string;
|
|
57
|
+
sunrise: string;
|
|
58
|
+
sunset: string;
|
|
59
|
+
daylightSeconds: number;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Asks Open-Meteo when the sun rises and sets at a place, today and tomorrow.
|
|
63
|
+
*
|
|
64
|
+
* @param fetchFn - The fetch to use.
|
|
65
|
+
* @param place - Where.
|
|
66
|
+
*/
|
|
67
|
+
export declare function sun_fetch(fetchFn: WeatherFetch, place: WeatherPlace): Promise<SunDay[]>;
|
|
68
|
+
/** `sunrise [place]` */
|
|
69
|
+
export declare function builtin_sunrise(args: string[], fetchFn?: WeatherFetch): Promise<CommandEnvelope>;
|