@fnndsc/brasa 0.31.5 → 0.32.1

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.
Files changed (66) hide show
  1. package/dist/buildinfo.json +1 -1
  2. package/dist/builtins/games/bytes.d.ts +21 -0
  3. package/dist/builtins/games/bytes.js +224 -0
  4. package/dist/builtins/games/bytes.js.map +1 -0
  5. package/dist/builtins/games/chimes.d.ts +64 -0
  6. package/dist/builtins/games/chimes.js +223 -0
  7. package/dist/builtins/games/chimes.js.map +1 -0
  8. package/dist/builtins/games/cowsay.d.ts +36 -0
  9. package/dist/builtins/games/cowsay.js +127 -0
  10. package/dist/builtins/games/cowsay.js.map +1 -0
  11. package/dist/builtins/games/figlet.d.ts +25 -0
  12. package/dist/builtins/games/figlet.js +109 -0
  13. package/dist/builtins/games/figlet.js.map +1 -0
  14. package/dist/builtins/games/lab.d.ts +51 -0
  15. package/dist/builtins/games/lab.js +161 -0
  16. package/dist/builtins/games/lab.js.map +1 -0
  17. package/dist/builtins/games/lolcat.d.ts +26 -0
  18. package/dist/builtins/games/lolcat.js +71 -0
  19. package/dist/builtins/games/lolcat.js.map +1 -0
  20. package/dist/builtins/games/morse.d.ts +18 -0
  21. package/dist/builtins/games/morse.js +46 -0
  22. package/dist/builtins/games/morse.js.map +1 -0
  23. package/dist/builtins/games/numbers.d.ts +55 -0
  24. package/dist/builtins/games/numbers.js +270 -0
  25. package/dist/builtins/games/numbers.js.map +1 -0
  26. package/dist/builtins/games/play.d.ts +53 -0
  27. package/dist/builtins/games/play.js +228 -0
  28. package/dist/builtins/games/play.js.map +1 -0
  29. package/dist/builtins/games/qr.d.ts +40 -0
  30. package/dist/builtins/games/qr.js +336 -0
  31. package/dist/builtins/games/qr.js.map +1 -0
  32. package/dist/builtins/games/shelf.d.ts +27 -0
  33. package/dist/builtins/games/shelf.js +71 -0
  34. package/dist/builtins/games/shelf.js.map +1 -0
  35. package/dist/builtins/games/show.d.ts +38 -0
  36. package/dist/builtins/games/show.js +75 -0
  37. package/dist/builtins/games/show.js.map +1 -0
  38. package/dist/builtins/games/sky.d.ts +69 -0
  39. package/dist/builtins/games/sky.js +190 -0
  40. package/dist/builtins/games/sky.js.map +1 -0
  41. package/dist/builtins/games/stdin.d.ts +34 -0
  42. package/dist/builtins/games/stdin.js +48 -0
  43. package/dist/builtins/games/stdin.js.map +1 -0
  44. package/dist/builtins/games/text.d.ts +46 -0
  45. package/dist/builtins/games/text.js +133 -0
  46. package/dist/builtins/games/text.js.map +1 -0
  47. package/dist/builtins/games/wtf.d.ts +13 -0
  48. package/dist/builtins/games/wtf.data.d.ts +12 -0
  49. package/dist/builtins/games/wtf.data.js +70 -0
  50. package/dist/builtins/games/wtf.data.js.map +1 -0
  51. package/dist/builtins/games/wtf.js +45 -0
  52. package/dist/builtins/games/wtf.js.map +1 -0
  53. package/dist/builtins/help.d.ts +8 -0
  54. package/dist/builtins/help.js +303 -1
  55. package/dist/builtins/help.js.map +1 -1
  56. package/dist/core/dispatch.js +125 -9
  57. package/dist/core/dispatch.js.map +1 -1
  58. package/dist/core/engine.js +1 -0
  59. package/dist/core/engine.js.map +1 -1
  60. package/dist/core/surface.d.ts +14 -0
  61. package/dist/core/surface.js.map +1 -1
  62. package/dist/lib/vfs/providers/static.js +15 -1
  63. package/dist/lib/vfs/providers/static.js.map +1 -1
  64. package/dist/lib/vfs/providers/static_content.js +2 -2
  65. package/dist/lib/vfs/providers/static_content.js.map +1 -1
  66. package/package.json +1 -1
@@ -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 @@
1
+ {"version":3,"file":"shelf.js","sourceRoot":"","sources":["../../../src/builtins/games/shelf.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAY1B,2DAA2D;AAC3D,MAAM,CAAC,MAAM,WAAW,GAAiC;IACvD;QACE,KAAK,EAAE,WAAW;QAClB,IAAI,EAA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s: 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
+ /**
16
+ * The starship `sl` sends across the screen (a typo's punishment, as the
17
+ * train was): the Constitution-class refit, side view, from the Star Trek
18
+ * ASCII Art blog (startrekasciiart.blogspot.com, "Constitution Class -
19
+ * Refit", 2011; artist uncredited there; re-use granted with attribution
20
+ * retained). Nose to the right: it flies left to right.
21
+ */
22
+ export declare const STARSHIP: ReadonlyArray<string>;
23
+ /** The glyphs `cmatrix` rains. */
24
+ export declare const MATRIX_GLYPHS: string;
25
+ /** A still of a show, for a console with no canvas. */
26
+ export declare function still_of(program: ShowProgram, random?: () => number): string[];
27
+ /** `sl`: a starship crosses the screen. */
28
+ export declare function builtin_sl(args: string[]): Promise<CommandEnvelope>;
29
+ /** `cmatrix`: the glyph rain. */
30
+ export declare function builtin_cmatrix(args: string[]): Promise<CommandEnvelope>;
31
+ /** `rain`: rain. */
32
+ export declare function builtin_rain(args: string[]): Promise<CommandEnvelope>;
33
+ /** `asciiquarium`: fish. */
34
+ export declare function builtin_asciiquarium(args: string[]): Promise<CommandEnvelope>;
35
+ /** `tetris`: falling blocks, in ARGUS. */
36
+ export declare function builtin_tetris(args: string[]): Promise<CommandEnvelope>;
37
+ /** `snake`: the snake, in ARGUS. */
38
+ export declare function builtin_snake(args: string[]): Promise<CommandEnvelope>;
@@ -0,0 +1,75 @@
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
+ /**
15
+ * The starship `sl` sends across the screen (a typo's punishment, as the
16
+ * train was): the Constitution-class refit, side view, from the Star Trek
17
+ * ASCII Art blog (startrekasciiart.blogspot.com, "Constitution Class -
18
+ * Refit", 2011; artist uncredited there; re-use granted with attribution
19
+ * retained). Nose to the right: it flies left to right.
20
+ */
21
+ export const STARSHIP = [
22
+ '___________________ _-_ ',
23
+ '\\__(==========/_=_/ ____.---\'---`---.____',
24
+ ' \\_ \\ \\----._________.----/',
25
+ ' \\ \\ / / `-_-\' ',
26
+ ' __,--`.`-\'..\'-_ ',
27
+ ' /____ || ',
28
+ ' `--.____,-\' ',
29
+ ];
30
+ /** The glyphs `cmatrix` rains. */
31
+ export const MATRIX_GLYPHS = 'ハミヒーウシナモニサワツオリアホテマケメエカキムユラセネスタヌヘ0123456789Z:・.=*+-<>¦|';
32
+ /** A still of a show, for a console with no canvas. */
33
+ export function still_of(program, random = Math.random) {
34
+ const pick = (s) => s[Math.floor(random() * s.length)];
35
+ switch (program) {
36
+ case 'sl': return [...STARSHIP];
37
+ case 'cmatrix': return Array.from({ length: 6 }, () => Array.from({ length: 40 }, () => (random() < 0.35 ? pick(MATRIX_GLYPHS) : ' ')).join(''));
38
+ case 'rain': return Array.from({ length: 5 }, (_, row) => Array.from({ length: 40 }, () => (random() < 0.12 ? (row === 4 ? 'o' : '|') : ' ')).join(''));
39
+ case 'aquarium': return [
40
+ ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~',
41
+ ' ><> o ',
42
+ ' <>< o ',
43
+ ' ><> ><> ',
44
+ ' )( )( )( )( )( )( ',
45
+ ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^',
46
+ ];
47
+ case 'tetris': return [
48
+ ' | |', ' | ## |', ' | ## |', ' | |', ' | # # ## |', ' | #### ###|', ' +----------+',
49
+ ];
50
+ case 'snake': return [' . . . . . . . .', ' . @ o o o . . .', ' . . . . o . . .', ' . . * . . . . .'];
51
+ }
52
+ }
53
+ /** What the console says beside a still: where the moving one is. */
54
+ function note_of(program, arcade) {
55
+ return arcade
56
+ ? chalk.gray(`${program} plays in ARGUS: type it there and the GAMES pane opens with the keys live (arrows; Esc gives the keyboard back).`)
57
+ : chalk.gray(`a still; ARGUS draws ${program} moving in its GAMES pane.`);
58
+ }
59
+ function show_run(program, args, arcade) {
60
+ const still = still_of(program);
61
+ return envelope_ok(`${still.join('\n')}\n${note_of(program, arcade)}\n`, { kind: 'games.show', data: { program, args, arcade } });
62
+ }
63
+ /** `sl`: a starship crosses the screen. */
64
+ export async function builtin_sl(args) { return show_run('sl', args, false); }
65
+ /** `cmatrix`: the glyph rain. */
66
+ export async function builtin_cmatrix(args) { return show_run('cmatrix', args, false); }
67
+ /** `rain`: rain. */
68
+ export async function builtin_rain(args) { return show_run('rain', args, false); }
69
+ /** `asciiquarium`: fish. */
70
+ export async function builtin_asciiquarium(args) { return show_run('aquarium', args, false); }
71
+ /** `tetris`: falling blocks, in ARGUS. */
72
+ export async function builtin_tetris(args) { return show_run('tetris', args, true); }
73
+ /** `snake`: the snake, in ARGUS. */
74
+ export async function builtin_snake(args) { return show_run('snake', args, true); }
75
+ //# 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;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,QAAQ,GAA0B;IAC7C,2CAA2C;IAC3C,6CAA6C;IAC7C,8CAA8C;IAC9C,8CAA8C;IAC9C,6CAA6C;IAC7C,2CAA2C;IAC3C,4CAA4C;CAC7C,CAAC;AAEF,kCAAkC;AAClC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,YAAY,CAAC,IAAc,IAA8B,OAAO,QAAQ,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;AACtH,4BAA4B;AAC5B,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,IAAc,IAA8B,OAAO,QAAQ,CAAC,UAAU,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;AAClI,0CAA0C;AAC1C,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,IAAc,IAA8B,OAAO,QAAQ,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;AACzH,oCAAoC;AACpC,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,IAAc,IAA8B,OAAO,QAAQ,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * @file Time and sky from the shelf: `pom`, `stardate`, `ddate`, `sunrise`.
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>;
@@ -0,0 +1,190 @@
1
+ /**
2
+ * @file Time and sky from the shelf: `pom`, `stardate`, `ddate`, `sunrise`.
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 { envelope_ok, envelope_error } from '@fnndsc/cumin';
12
+ import chalk from 'chalk';
13
+ import { WEATHER_DEFAULT_PLACE, place_find } from '../sys/weather.js';
14
+ /* --------------------------------------------------------------- moon */
15
+ /** A reference new moon: 2000-01-06 18:14 UTC, as a Julian day. */
16
+ const NEW_MOON_JD = 2451550.1;
17
+ /** The synodic month, in days. */
18
+ const SYNODIC_DAYS = 29.530588853;
19
+ /** A date as a Julian day. */
20
+ export function julianDay_of(date) {
21
+ return date.getTime() / 86_400_000 + 2440587.5;
22
+ }
23
+ /** Where the moon stands on a date. */
24
+ export function moon_phase(date) {
25
+ const cycles = (julianDay_of(date) - NEW_MOON_JD) / SYNODIC_DAYS;
26
+ const phase = cycles - Math.floor(cycles);
27
+ const illumination = (1 - Math.cos(2 * Math.PI * phase)) / 2;
28
+ const near = (p) => Math.abs(phase - p) < 0.034 || Math.abs(phase - p - 1) < 0.034;
29
+ const name = near(0) ? 'New Moon' : near(0.25) ? 'First Quarter' : near(0.5) ? 'Full Moon' : near(0.75) ? 'Last Quarter'
30
+ : phase < 0.25 ? 'Waxing Crescent' : phase < 0.5 ? 'Waxing Gibbous' : phase < 0.75 ? 'Waning Gibbous' : 'Waning Crescent';
31
+ const toFull = ((0.5 - phase + 1) % 1) * SYNODIC_DAYS;
32
+ const toNew = ((1 - phase) % 1) * SYNODIC_DAYS;
33
+ return { phase, illumination, name, toFull, toNew };
34
+ }
35
+ /** A small moon, lit from the side the phase lights. */
36
+ export function moon_draw(phase) {
37
+ const lit = phase.illumination;
38
+ const waxing = phase.phase < 0.5;
39
+ const rows = [];
40
+ const radius = 4;
41
+ for (let y = -radius; y <= radius; y++) {
42
+ let row = '';
43
+ for (let x = -radius * 2; x <= radius * 2; x++) {
44
+ const dx = x / 2;
45
+ const inside = dx * dx + y * y <= radius * radius + 0.5;
46
+ if (!inside) {
47
+ row += ' ';
48
+ continue;
49
+ }
50
+ const half = Math.sqrt(Math.max(0, radius * radius - y * y));
51
+ // The terminator: a chord moving across the disc as the phase goes.
52
+ const edge = (1 - 2 * lit) * half;
53
+ const bright = waxing ? dx >= edge : dx <= -edge;
54
+ row += bright ? '@' : '.';
55
+ }
56
+ rows.push(row.trimEnd());
57
+ }
58
+ return rows;
59
+ }
60
+ /** `pom [YYYY-MM-DD]` */
61
+ export async function builtin_pom(args) {
62
+ const date = args.length > 0 ? new Date(args.join(' ')) : new Date();
63
+ if (Number.isNaN(date.getTime()))
64
+ return envelope_error('', undefined, `pom: '${args.join(' ')}' is not a date (try pom 2026-12-25)\n`);
65
+ const moon = moon_phase(date);
66
+ const percent = Math.round(moon.illumination * 100);
67
+ const trend = moon.name === 'Full Moon' || moon.name === 'New Moon' ? '' : moon.phase < 0.5 ? ' (waxing)' : ' (waning)';
68
+ const lines = [
69
+ `The Moon is ${chalk.bold(moon.name)}${trend}: ${percent}% of the Full`,
70
+ `${chalk.gray(`next full moon in ${moon.toFull.toFixed(1)} days, next new moon in ${moon.toNew.toFixed(1)} days`)}`,
71
+ ...moon_draw(moon).map((row) => ` ${row}`),
72
+ ];
73
+ return envelope_ok(`${lines.join('\n')}\n`, { kind: 'games.pom', data: { date: date.toISOString(), ...moon } });
74
+ }
75
+ /* ----------------------------------------------------------- stardate */
76
+ /** Days into the year, 1-based, and the year's length. */
77
+ function yearDay_of(date) {
78
+ const start = Date.UTC(date.getUTCFullYear(), 0, 1);
79
+ const next = Date.UTC(date.getUTCFullYear() + 1, 0, 1);
80
+ const elapsed = date.getTime() - start;
81
+ const days = Math.round((next - start) / 86_400_000);
82
+ return { day: Math.floor(elapsed / 86_400_000) + 1, days, fraction: elapsed / (next - start) };
83
+ }
84
+ /** The stardate two ways: the Kelvin films' `YYYY.DDD`, and TNG's thousand-per-year from 2323. */
85
+ export function stardate_of(date) {
86
+ const { day, fraction } = yearDay_of(date);
87
+ const year = date.getUTCFullYear();
88
+ const kelvin = `${year}.${String(day).padStart(3, '0')}`;
89
+ const tng = (year - 2323) * 1000 + fraction * 1000;
90
+ return { kelvin, tng: tng.toFixed(1) };
91
+ }
92
+ /** `stardate` */
93
+ export async function builtin_stardate(args) {
94
+ const date = args.length > 0 ? new Date(args.join(' ')) : new Date();
95
+ if (Number.isNaN(date.getTime()))
96
+ return envelope_error('', undefined, `stardate: '${args.join(' ')}' is not a date\n`);
97
+ const sd = stardate_of(date);
98
+ const lines = [
99
+ `Stardate ${chalk.bold(sd.kelvin)}`,
100
+ chalk.gray(`(Kelvin reckoning: the year and the day of it; by TNG's count it is ${sd.tng} — that era is still ahead of us)`),
101
+ ];
102
+ return envelope_ok(`${lines.join('\n')}\n`, { kind: 'games.stardate', data: { date: date.toISOString(), ...sd } });
103
+ }
104
+ /* -------------------------------------------------------------- ddate */
105
+ const SEASONS = ['Chaos', 'Discord', 'Confusion', 'Bureaucracy', 'The Aftermath'];
106
+ const WEEKDAYS = ['Sweetmorn', 'Boomtime', 'Pungenday', 'Prickle-Prickle', 'Setting Orange'];
107
+ const APOSTLE_DAYS = ['Mungday', 'Mojoday', 'Syaday', 'Zaraday', 'Maladay'];
108
+ const SEASON_DAYS = ['Chaoflux', 'Discoflux', 'Confuflux', 'Bureflux', 'Afflux'];
109
+ export function ddate_of(date) {
110
+ const year = date.getFullYear();
111
+ const yold = year + 1166;
112
+ const start = new Date(year, 0, 1);
113
+ const doy = Math.round((new Date(year, date.getMonth(), date.getDate()).getTime() - start.getTime()) / 86_400_000) + 1;
114
+ const leap = (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
115
+ if (leap && doy === 60)
116
+ return { yold, season: 'Chaos', day: 0, weekday: '', holyday: "St. Tib's Day", tibs: true };
117
+ const adjusted = leap && doy > 60 ? doy - 1 : doy;
118
+ const season = Math.floor((adjusted - 1) / 73);
119
+ const day = ((adjusted - 1) % 73) + 1;
120
+ const weekday = WEEKDAYS[(adjusted - 1) % 5];
121
+ const holyday = day === 5 ? APOSTLE_DAYS[season] : day === 50 ? SEASON_DAYS[season] : null;
122
+ return { yold, season: SEASONS[season], day, weekday, holyday, tibs: false };
123
+ }
124
+ /** 1st, 2nd, 3rd, 4th … 11th, 12th, 13th … 21st. */
125
+ export function ordinal_of(n) {
126
+ const rest = n % 100;
127
+ if (rest >= 11 && rest <= 13)
128
+ return `${n}th`;
129
+ return `${n}${['th', 'st', 'nd', 'rd'][n % 10] ?? 'th'}`;
130
+ }
131
+ /** `ddate [YYYY-MM-DD]` */
132
+ export async function builtin_ddate(args) {
133
+ const date = args.length > 0 ? new Date(args.join(' ')) : new Date();
134
+ if (Number.isNaN(date.getTime()))
135
+ return envelope_error('', undefined, `ddate: '${args.join(' ')}' is not a date\n`);
136
+ const d = ddate_of(date);
137
+ const line = d.tibs
138
+ ? `Today is St. Tib's Day in the YOLD ${d.yold}`
139
+ : `Today is ${d.weekday}, the ${ordinal_of(d.day)} day of ${d.season} in the YOLD ${d.yold}${d.holyday === null ? '' : `\nCelebrate ${d.holyday}!`}`;
140
+ return envelope_ok(`${line}\n`, { kind: 'games.ddate', data: { date: date.toISOString(), ...d } });
141
+ }
142
+ /* ------------------------------------------------------------ sunrise */
143
+ const FORECAST_URL = 'https://api.open-meteo.com/v1/forecast';
144
+ const FETCH_TIMEOUT_MS = 8_000;
145
+ /**
146
+ * Asks Open-Meteo when the sun rises and sets at a place, today and tomorrow.
147
+ *
148
+ * @param fetchFn - The fetch to use.
149
+ * @param place - Where.
150
+ */
151
+ export async function sun_fetch(fetchFn, place) {
152
+ const url = `${FORECAST_URL}?latitude=${place.latitude}&longitude=${place.longitude}&daily=sunrise,sunset,daylight_duration&timezone=auto&forecast_days=2`;
153
+ const response = await fetchFn(url, { signal: AbortSignal.timeout(FETCH_TIMEOUT_MS) });
154
+ if (!response.ok)
155
+ throw new Error(`open-meteo answered ${response.status}`);
156
+ const answer = (await response.json());
157
+ const daily = answer.daily ?? {};
158
+ return (daily.time ?? []).map((date, i) => ({
159
+ date,
160
+ sunrise: daily.sunrise?.[i] ?? '',
161
+ sunset: daily.sunset?.[i] ?? '',
162
+ daylightSeconds: daily.daylight_duration?.[i] ?? 0,
163
+ }));
164
+ }
165
+ /** `HH:MM` out of an ISO local time. */
166
+ const clock_of = (iso) => iso.slice(11, 16) || '?';
167
+ /** `sunrise [place]` */
168
+ export async function builtin_sunrise(args, fetchFn = (url, init) => fetch(url, init)) {
169
+ const name = args.length > 0 ? args.join(' ') : WEATHER_DEFAULT_PLACE;
170
+ try {
171
+ const place = await place_find(fetchFn, name);
172
+ if (place === null)
173
+ return envelope_error('', undefined, `sunrise: no place called '${name}' that open-meteo knows\n`);
174
+ const days = await sun_fetch(fetchFn, place);
175
+ if (days.length === 0)
176
+ return envelope_error('', undefined, `sunrise: open-meteo had no days for ${place.name}\n`);
177
+ const where = [place.name, place.region, place.country].filter((p) => p.length > 0).join(', ');
178
+ const lines = [chalk.bold(where)];
179
+ for (const [i, day] of days.entries()) {
180
+ const hours = Math.floor(day.daylightSeconds / 3600);
181
+ const minutes = Math.round((day.daylightSeconds % 3600) / 60);
182
+ lines.push(`${i === 0 ? 'today ' : 'tomorrow'} ${day.date} sunrise ${chalk.yellow(clock_of(day.sunrise))} sunset ${chalk.yellow(clock_of(day.sunset))} ${chalk.gray(`${hours}h ${String(minutes).padStart(2, '0')}m of daylight`)}`);
183
+ }
184
+ return envelope_ok(`${lines.join('\n')}\n`, { kind: 'games.sunrise', data: { place, days } });
185
+ }
186
+ catch (error) {
187
+ return envelope_error('', undefined, `sunrise: ${error instanceof Error ? error.message : String(error)}\n`);
188
+ }
189
+ }
190
+ //# sourceMappingURL=sky.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sky.js","sourceRoot":"","sources":["../../../src/builtins/games/sky.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAmB,WAAW,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC7E,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAwC,MAAM,mBAAmB,CAAC;AAE5G,0EAA0E;AAE1E,mEAAmE;AACnE,MAAM,WAAW,GAAW,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G,CAAC,MAAM,CAAC,CAAC,KAAK,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,KAAK,MAAM,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;QAC5O,CAAC;QACD,OAAO,WAAW,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;IAChG,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACxB,OAAO,cAAc,CAAC,EAAE,EAAE,SAAS,EAAE,YAAY,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC/G,CAAC;AACH,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @file What a piped builtin reads: the text the segment before it wrote.
3
+ *
4
+ * A pipeline's first segment always ran in the kernel; the rest went to the
5
+ * surface's host shell, so `fortune | cowsay` reached the host's cowsay (or,
6
+ * in a browser, nothing). A segment that names a builtin now runs in the
7
+ * kernel too, and reads what came before it here. The slot is set by the
8
+ * pipe for the length of one segment and taken by the builtin that wants
9
+ * it; a builtin that does not read it leaves it to be cleared, as a shell
10
+ * command that ignores stdin does.
11
+ *
12
+ * @module
13
+ */
14
+ /**
15
+ * Sets what the next builtin may read; the pipe calls this before a segment
16
+ * and clears it after.
17
+ *
18
+ * @param text - The previous segment's output, or null for none.
19
+ */
20
+ export declare function stdin_set(text: string | null): void;
21
+ /**
22
+ * Takes the piped text, once.
23
+ *
24
+ * @returns The text, or null when the builtin was not piped into.
25
+ */
26
+ export declare function stdin_take(): string | null;
27
+ /**
28
+ * The text a toy works on: what was piped in, else its arguments joined,
29
+ * else nothing.
30
+ *
31
+ * @param args - The builtin's arguments.
32
+ * @returns The text, or null when there is none either way.
33
+ */
34
+ export declare function text_input(args: ReadonlyArray<string>): string | null;
@@ -0,0 +1,48 @@
1
+ /**
2
+ * @file What a piped builtin reads: the text the segment before it wrote.
3
+ *
4
+ * A pipeline's first segment always ran in the kernel; the rest went to the
5
+ * surface's host shell, so `fortune | cowsay` reached the host's cowsay (or,
6
+ * in a browser, nothing). A segment that names a builtin now runs in the
7
+ * kernel too, and reads what came before it here. The slot is set by the
8
+ * pipe for the length of one segment and taken by the builtin that wants
9
+ * it; a builtin that does not read it leaves it to be cleared, as a shell
10
+ * command that ignores stdin does.
11
+ *
12
+ * @module
13
+ */
14
+ /** The text piped into the segment now running, or null when nothing was. */
15
+ let piped = null;
16
+ /**
17
+ * Sets what the next builtin may read; the pipe calls this before a segment
18
+ * and clears it after.
19
+ *
20
+ * @param text - The previous segment's output, or null for none.
21
+ */
22
+ export function stdin_set(text) {
23
+ piped = text;
24
+ }
25
+ /**
26
+ * Takes the piped text, once.
27
+ *
28
+ * @returns The text, or null when the builtin was not piped into.
29
+ */
30
+ export function stdin_take() {
31
+ const text = piped;
32
+ piped = null;
33
+ return text;
34
+ }
35
+ /**
36
+ * The text a toy works on: what was piped in, else its arguments joined,
37
+ * else nothing.
38
+ *
39
+ * @param args - The builtin's arguments.
40
+ * @returns The text, or null when there is none either way.
41
+ */
42
+ export function text_input(args) {
43
+ const fromPipe = stdin_take();
44
+ if (fromPipe !== null)
45
+ return fromPipe;
46
+ return args.length > 0 ? args.join(' ') : null;
47
+ }
48
+ //# sourceMappingURL=stdin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stdin.js","sourceRoot":"","sources":["../../../src/builtins/games/stdin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,6EAA6E;AAC7E,IAAI,KAAK,GAAkB,IAAI,CAAC;AAEhC;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,IAAmB;IAC3C,KAAK,GAAG,IAAI,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU;IACxB,MAAM,IAAI,GAAkB,KAAK,CAAC;IAClC,KAAK,GAAG,IAAI,CAAC;IACb,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,IAA2B;IACpD,MAAM,QAAQ,GAAkB,UAAU,EAAE,CAAC;IAC7C,IAAI,QAAQ,KAAK,IAAI;QAAE,OAAO,QAAQ,CAAC;IACvC,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACjD,CAAC"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * @file Text toys from the shelf: `rev`, `tac`, `yes`, `seq`, `shuf`, `rot13`.
3
+ *
4
+ * Each reads what was piped in, else its arguments, and answers in kind:
5
+ * `fortune | rev`, `rot13 hello`, `seq 1 2 9`. `yes` is bounded — a shell
6
+ * that never ends is not a toy — and says how many it printed.
7
+ *
8
+ * @module
9
+ */
10
+ import { CommandEnvelope } from '@fnndsc/cumin';
11
+ /** Lines `yes` prints when not told how many. */
12
+ export declare const YES_DEFAULT: number;
13
+ /** The most lines `yes` prints however it is asked. */
14
+ export declare const YES_MAX: number;
15
+ /** The most numbers `seq` prints. */
16
+ export declare const SEQ_MAX: number;
17
+ /** Reverses each line's characters, keeping the lines. */
18
+ export declare function text_rev(text: string): string;
19
+ /** Reverses the order of the lines. */
20
+ export declare function text_tac(text: string): string;
21
+ /** The ROT13 of a text; letters only, case kept. */
22
+ export declare function text_rot13(text: string): string;
23
+ /**
24
+ * The numbers `seq` prints: `seq LAST`, `seq FIRST LAST`, `seq FIRST STEP LAST`.
25
+ *
26
+ * @returns The numbers, or a refusal.
27
+ */
28
+ export declare function seq_numbers(args: ReadonlyArray<string>): {
29
+ numbers: number[];
30
+ } | {
31
+ refusal: string;
32
+ };
33
+ /** Shuffles lines (Fisher–Yates), with an optional source of chance for tests. */
34
+ export declare function lines_shuffle(lines: string[], random?: () => number): string[];
35
+ /** `rev [text]` */
36
+ export declare function builtin_rev(args: string[]): Promise<CommandEnvelope>;
37
+ /** `tac [text]` */
38
+ export declare function builtin_tac(args: string[]): Promise<CommandEnvelope>;
39
+ /** `yes [word] [-n N]` */
40
+ export declare function builtin_yes(args: string[]): Promise<CommandEnvelope>;
41
+ /** `seq [FIRST [STEP]] LAST` */
42
+ export declare function builtin_seq(args: string[]): Promise<CommandEnvelope>;
43
+ /** `shuf [words...]`: lines piped in, or the words given, in a random order. */
44
+ export declare function builtin_shuf(args: string[]): Promise<CommandEnvelope>;
45
+ /** `rot13 [text]` */
46
+ export declare function builtin_rot13(args: string[]): Promise<CommandEnvelope>;