@popoverinstall/cli 0.5.0 → 0.6.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.
- package/CHANGELOG.md +48 -0
- package/README.md +8 -5
- package/dist/aardvark.d.ts +30 -0
- package/dist/aardvark.d.ts.map +1 -0
- package/dist/aardvark.js +97 -0
- package/dist/aardvark.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -1
- package/dist/login.d.ts +8 -1
- package/dist/login.d.ts.map +1 -1
- package/dist/login.js +51 -23
- package/dist/login.js.map +1 -1
- package/dist/next-steps.d.ts +18 -0
- package/dist/next-steps.d.ts.map +1 -0
- package/dist/next-steps.js +81 -0
- package/dist/next-steps.js.map +1 -0
- package/dist/scene.d.ts +43 -0
- package/dist/scene.d.ts.map +1 -0
- package/dist/scene.js +276 -0
- package/dist/scene.js.map +1 -0
- package/dist/snapshot.d.ts +2 -0
- package/dist/snapshot.d.ts.map +1 -0
- package/dist/snapshot.js +828 -0
- package/dist/snapshot.js.map +1 -0
- package/dist/terminal.d.ts +58 -0
- package/dist/terminal.d.ts.map +1 -0
- package/dist/terminal.js +139 -0
- package/dist/terminal.js.map +1 -0
- package/dist/theme.d.ts +123 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +257 -0
- package/dist/theme.js.map +1 -0
- package/dist/welcome.d.ts +24 -0
- package/dist/welcome.d.ts.map +1 -0
- package/dist/welcome.js +159 -0
- package/dist/welcome.js.map +1 -0
- package/package.json +3 -3
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/README.md +11 -1
- package/plugin/commands/fork.md +118 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"next-steps.js","sourceRoot":"","sources":["../src/next-steps.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,IA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,KAAK,CAAC,GAAG,CAAC,0BAA0B,CAAC,EAAE,CAAC,CAAC;IAEpF,KAAK,EAAE,CAAC;IACR,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC,CAAC;IAC3C,KAAK,MAAM,OAAO,IAAI,YAAY,EAAE,CAAC;QACnC;;;;;;WAMG;QACH,MAAM,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,OAAO,GAAG,EAAE,IAAI,GAAG,CAAC,CAAC,CAAC;QACxD,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC;QAC/B,2FAA2F;QAC3F,iEAAiE;QACjE,KAAK,MAAM,IAAI,IAAI,IAAI;YAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC;IACxD,CAAC;IAED,KAAK,EAAE,CAAC;IACR,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,6CAA6C,CAAC,CAAC,CAAC;IAC/D,KAAK,EAAE,CAAC;IACR,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC;IACpC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAClB,CAAC;AAED,6CAA6C;AAC7C,SAAS,MAAM,CAAC,IAAY;IAC1B,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;AAC5E,CAAC"}
|
package/dist/scene.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The welcome scene: the aardvark standing in some grass, under a sky.
|
|
3
|
+
*
|
|
4
|
+
* Same half-block bitmap trick as the aardvark itself — two stacked pixels per terminal cell
|
|
5
|
+
* via U+2580, foreground painting the top pixel and background the bottom — but over one
|
|
6
|
+
* shared canvas with a palette, so the moon, the clouds and the grass can each have their own
|
|
7
|
+
* colour while still sharing cells with whatever they overlap.
|
|
8
|
+
*
|
|
9
|
+
* The sky follows the clock: a crescent moon and stars at night, a sun during the day. Beyond
|
|
10
|
+
* being a nice touch, it means the scene someone sees at 2am is not pretending it is midday.
|
|
11
|
+
*
|
|
12
|
+
* Stars are the one exception to the bitmap: they are `*` glyphs rather than blocks, because a
|
|
13
|
+
* star drawn as a half-block is a rectangle. Any cell containing one is rendered as the glyph
|
|
14
|
+
* instead of as pixels.
|
|
15
|
+
*/
|
|
16
|
+
/** Total columns the scene needs, trunk and indent included. */
|
|
17
|
+
export declare const SCENE_COLUMNS: number;
|
|
18
|
+
export interface SceneOptions {
|
|
19
|
+
/** Columns available. A scene wider than the window is worse than no scene. */
|
|
20
|
+
columns?: number;
|
|
21
|
+
/** Overridden by the tests and by `--night` / `--day`; otherwise read off the clock. */
|
|
22
|
+
night?: boolean;
|
|
23
|
+
indent?: number;
|
|
24
|
+
/**
|
|
25
|
+
* Whether half blocks are safe to emit. Defaults to what the terminal announced.
|
|
26
|
+
*
|
|
27
|
+
* An override for the same reason `night` is one: the ambient value is environmental, and a
|
|
28
|
+
* test that reads it asserts against whatever terminal happens to run it — passing on a
|
|
29
|
+
* developer's Windows Terminal and failing on a bare CI runner, where no
|
|
30
|
+
* `WT_SESSION`/`TERM_PROGRAM` means ASCII and the scene is empty by design.
|
|
31
|
+
*/
|
|
32
|
+
unicode?: boolean;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The scene as terminal rows, each prefixed with the trunk so it hangs off the same vertical
|
|
36
|
+
* line as the rest of the flow.
|
|
37
|
+
*
|
|
38
|
+
* Returns an empty array when the terminal has not told us it speaks UTF-8 — half blocks come
|
|
39
|
+
* out as replacement characters there — and null when the window is too narrow, which is the
|
|
40
|
+
* caller's cue to fall back to the aardvark on its own.
|
|
41
|
+
*/
|
|
42
|
+
export declare function sceneLines(opts?: SceneOptions): string[] | null;
|
|
43
|
+
//# sourceMappingURL=scene.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scene.d.ts","sourceRoot":"","sources":["../src/scene.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AASH,gEAAgE;AAChE,eAAO,MAAM,aAAa,QAAY,CAAC;AAsPvC,MAAM,WAAW,YAAY;IAC3B,+EAA+E;IAC/E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,wFAAwF;IACxF,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,IAAI,GAAE,YAAiB,GAAG,MAAM,EAAE,GAAG,IAAI,CAqBnE"}
|
package/dist/scene.js
ADDED
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The welcome scene: the aardvark standing in some grass, under a sky.
|
|
3
|
+
*
|
|
4
|
+
* Same half-block bitmap trick as the aardvark itself — two stacked pixels per terminal cell
|
|
5
|
+
* via U+2580, foreground painting the top pixel and background the bottom — but over one
|
|
6
|
+
* shared canvas with a palette, so the moon, the clouds and the grass can each have their own
|
|
7
|
+
* colour while still sharing cells with whatever they overlap.
|
|
8
|
+
*
|
|
9
|
+
* The sky follows the clock: a crescent moon and stars at night, a sun during the day. Beyond
|
|
10
|
+
* being a nice touch, it means the scene someone sees at 2am is not pretending it is midday.
|
|
11
|
+
*
|
|
12
|
+
* Stars are the one exception to the bitmap: they are `*` glyphs rather than blocks, because a
|
|
13
|
+
* star drawn as a half-block is a rectangle. Any cell containing one is rendered as the glyph
|
|
14
|
+
* instead of as pixels.
|
|
15
|
+
*/
|
|
16
|
+
import { AARDVARK_SPRITE } from "./aardvark.js";
|
|
17
|
+
import { AMBER_INK, AMBER_WASH, colorEnabled, glyph, style, unicodeEnabled } from "./theme.js";
|
|
18
|
+
const WIDTH = 64;
|
|
19
|
+
/** Two pixel rows per terminal row, so this must stay even. */
|
|
20
|
+
const HEIGHT = 20;
|
|
21
|
+
/** Total columns the scene needs, trunk and indent included. */
|
|
22
|
+
export const SCENE_COLUMNS = WIDTH + 3;
|
|
23
|
+
// ------------------------------------------------------------------ sky art
|
|
24
|
+
/**
|
|
25
|
+
* The moon, at cell resolution and in two tones.
|
|
26
|
+
*
|
|
27
|
+
* Coverage per cell is supersampled against a crescent — a disc of radius 7 with a radius-5 disc
|
|
28
|
+
* bitten out of it, offset 2.5 — then quantised: mostly covered becomes a solid block, partly
|
|
29
|
+
* covered becomes stipple. That is what produces the soft two-tone edge and the detached tips at
|
|
30
|
+
* the horns, rather than them being drawn in.
|
|
31
|
+
*
|
|
32
|
+
* Cell resolution rather than pixels because a cell is roughly twice as tall as it is wide, so a
|
|
33
|
+
* round moon needs twice as many columns as rows — 14 by 7 — and because the stipple is a
|
|
34
|
+
* character, which cannot be half a cell tall.
|
|
35
|
+
*
|
|
36
|
+
* Mirrored from the reference so it opens back towards the aardvark.
|
|
37
|
+
*/
|
|
38
|
+
// prettier-ignore
|
|
39
|
+
const MOON = [
|
|
40
|
+
"...dMMMMMMd...",
|
|
41
|
+
"..d...ddMMMMM.",
|
|
42
|
+
".........MMMMM",
|
|
43
|
+
".........dMMMM",
|
|
44
|
+
".........MMMMM",
|
|
45
|
+
"..d...ddMMMMM.",
|
|
46
|
+
"...dMMMMMMd...",
|
|
47
|
+
];
|
|
48
|
+
/**
|
|
49
|
+
* Disc and eight rays, on the moon's footprint so the sky does not reflow at dawn.
|
|
50
|
+
*
|
|
51
|
+
* Drawn by hand. Generating the rays as an arc cut into spokes produced confetti — at this
|
|
52
|
+
* size every ray has to be placed, not derived.
|
|
53
|
+
*/
|
|
54
|
+
// prettier-ignore
|
|
55
|
+
const SUN = [
|
|
56
|
+
"......ss......",
|
|
57
|
+
"......ss......",
|
|
58
|
+
"..s........s..",
|
|
59
|
+
".....ssss.....",
|
|
60
|
+
"....ssssss....",
|
|
61
|
+
"...ssssssss...",
|
|
62
|
+
"ss.ssssssss.ss",
|
|
63
|
+
"ss.ssssssss.ss",
|
|
64
|
+
"...ssssssss...",
|
|
65
|
+
"....ssssss....",
|
|
66
|
+
".....ssss.....",
|
|
67
|
+
"..s........s..",
|
|
68
|
+
"......ss......",
|
|
69
|
+
"......ss......",
|
|
70
|
+
];
|
|
71
|
+
/*
|
|
72
|
+
* Clouds are stippled rather than solid, and drawn at cell resolution rather than in pixels.
|
|
73
|
+
*
|
|
74
|
+
* A cloud is the one thing here made of a character instead of blocks: U+2591 LIGHT SHADE, whose
|
|
75
|
+
* dot grid is the texture in the reference. That means a cloud cannot be half a cell tall, so its
|
|
76
|
+
* art is one row per terminal row and `stampCells` writes it to both pixel rows of each — which
|
|
77
|
+
* is also why the silhouettes are stepped mesas rather than curves. It is the shape the medium
|
|
78
|
+
* wants.
|
|
79
|
+
*/
|
|
80
|
+
// prettier-ignore
|
|
81
|
+
const CLOUD_BIG = [
|
|
82
|
+
"......cccc....",
|
|
83
|
+
"..ccc.ccccccc.",
|
|
84
|
+
"cccccccccccccc",
|
|
85
|
+
];
|
|
86
|
+
// prettier-ignore
|
|
87
|
+
const CLOUD_SMALL = [
|
|
88
|
+
"...cccc...",
|
|
89
|
+
"cccccccccc",
|
|
90
|
+
];
|
|
91
|
+
/**
|
|
92
|
+
* Where the stars go. Placed by hand to sit in the gaps rather than on top of anything, and all
|
|
93
|
+
* above the skyline — a star down at grass height reads as a dropped asterisk.
|
|
94
|
+
*/
|
|
95
|
+
const STARS = [
|
|
96
|
+
[36, 0],
|
|
97
|
+
[42, 1],
|
|
98
|
+
[47, 0],
|
|
99
|
+
[49, 5],
|
|
100
|
+
[63, 6],
|
|
101
|
+
[35, 7],
|
|
102
|
+
[41, 8],
|
|
103
|
+
[48, 9],
|
|
104
|
+
];
|
|
105
|
+
/**
|
|
106
|
+
* Strand heights in pixels, cycled across the ground.
|
|
107
|
+
*
|
|
108
|
+
* Paired with uneven gaps below. Heights alone are not enough — strands on a fixed 2px pitch
|
|
109
|
+
* read as a picket fence however much their tops vary.
|
|
110
|
+
*/
|
|
111
|
+
const GRASS_HEIGHTS = [3, 5, 2, 4, 3, 2, 5, 3, 4, 2, 3, 5, 2, 4, 3, 2, 4, 3, 5, 2];
|
|
112
|
+
/** Columns to skip before the next strand. */
|
|
113
|
+
const GRASS_GAPS = [2, 3, 2, 2, 3, 2, 4, 2];
|
|
114
|
+
/** Grass starts clear of the aardvark's hind legs and runs to the edge. */
|
|
115
|
+
const GRASS_FROM = 35;
|
|
116
|
+
// ------------------------------------------------------------------ palette
|
|
117
|
+
const RESET = "\x1b[0m";
|
|
118
|
+
/** Moonlight: the solid blocks and the stippled edge share it. */
|
|
119
|
+
const MOONLIGHT = "\x1b[37m";
|
|
120
|
+
/** Foreground codes per palette key. The aardvark keeps the terminal's own dark red. */
|
|
121
|
+
const INK = {
|
|
122
|
+
"1": "\x1b[31m", // aardvark body
|
|
123
|
+
"4": "\x1b[97m", // its eye
|
|
124
|
+
s: AMBER_INK, // the sun, in the same amber as the rest of the flow
|
|
125
|
+
c: "\x1b[90m", // cloud
|
|
126
|
+
g: "\x1b[32m", // grass
|
|
127
|
+
};
|
|
128
|
+
/** Background codes, for the lower pixel of a cell. */
|
|
129
|
+
const WASH = {
|
|
130
|
+
"1": "\x1b[41m",
|
|
131
|
+
"4": "\x1b[107m",
|
|
132
|
+
s: AMBER_WASH,
|
|
133
|
+
c: "\x1b[100m",
|
|
134
|
+
g: "\x1b[42m",
|
|
135
|
+
};
|
|
136
|
+
const UPPER = "▀";
|
|
137
|
+
const LOWER = "▄";
|
|
138
|
+
const FULL = "█";
|
|
139
|
+
const STAR = "*";
|
|
140
|
+
/** U+2591 LIGHT SHADE. Its dot grid is the cloud texture from the reference. */
|
|
141
|
+
const SHADE = "░";
|
|
142
|
+
// ------------------------------------------------------------------ compose
|
|
143
|
+
function stamp(canvas, art, ox, oy) {
|
|
144
|
+
art.forEach((row, y) => [...row].forEach((ch, x) => {
|
|
145
|
+
if (ch === ".")
|
|
146
|
+
return;
|
|
147
|
+
const cy = oy + y;
|
|
148
|
+
const cx = ox + x;
|
|
149
|
+
if (cy < 0 || cy >= HEIGHT || cx < 0 || cx >= WIDTH)
|
|
150
|
+
return;
|
|
151
|
+
canvas[cy][cx] = ch;
|
|
152
|
+
}));
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Stamp art whose rows are terminal rows rather than pixel rows, by writing each to both pixels
|
|
156
|
+
* of its cell. For anything drawn as a character, where half a cell is not a thing.
|
|
157
|
+
*/
|
|
158
|
+
function stampCells(canvas, art, ox, oy) {
|
|
159
|
+
art.forEach((row, y) => {
|
|
160
|
+
[...row].forEach((ch, x) => {
|
|
161
|
+
if (ch === ".")
|
|
162
|
+
return;
|
|
163
|
+
const cx = ox + x;
|
|
164
|
+
if (cx < 0 || cx >= WIDTH)
|
|
165
|
+
return;
|
|
166
|
+
for (const cy of [oy + y * 2, oy + y * 2 + 1]) {
|
|
167
|
+
if (cy >= 0 && cy < HEIGHT)
|
|
168
|
+
canvas[cy][cx] = ch;
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Build the canvas. Back to front, so the aardvark and the grass sit over the sky rather than
|
|
175
|
+
* being punched through by it.
|
|
176
|
+
*/
|
|
177
|
+
function compose(night) {
|
|
178
|
+
const canvas = Array.from({ length: HEIGHT }, () => Array(WIDTH).fill("."));
|
|
179
|
+
// Top right corner. Both are 14 wide, so the sun's disc and the moon's limb land in the same
|
|
180
|
+
// place — the sky does not shift at dawn.
|
|
181
|
+
if (night)
|
|
182
|
+
stampCells(canvas, MOON, WIDTH - 14, 0);
|
|
183
|
+
else
|
|
184
|
+
stamp(canvas, SUN, WIDTH - 14, 0);
|
|
185
|
+
// Cell rows 1-3 and 5-6, kept clear of the moon so neither sits on the other.
|
|
186
|
+
stampCells(canvas, CLOUD_BIG, 34, 2);
|
|
187
|
+
stampCells(canvas, CLOUD_SMALL, 38, 10);
|
|
188
|
+
// Stars only at night, and only where nothing else already is.
|
|
189
|
+
if (night) {
|
|
190
|
+
for (const [x, y] of STARS) {
|
|
191
|
+
if (canvas[y]?.[x] === ".")
|
|
192
|
+
canvas[y][x] = "*";
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
/*
|
|
196
|
+
* A continuous ground line with strands rising out of it. Strands alone, however uneven, read
|
|
197
|
+
* as a picket fence — it is the unbroken base that turns them into grass growing on something.
|
|
198
|
+
* The line sits on the aardvark's own footing: the sprite's legs end on this row too.
|
|
199
|
+
*/
|
|
200
|
+
for (let x = GRASS_FROM; x < WIDTH; x += 1)
|
|
201
|
+
canvas[HEIGHT - 1][x] = "g";
|
|
202
|
+
for (let x = GRASS_FROM, i = 0; x < WIDTH; i += 1) {
|
|
203
|
+
const height = GRASS_HEIGHTS[i % GRASS_HEIGHTS.length];
|
|
204
|
+
for (let y = HEIGHT - height; y < HEIGHT; y += 1)
|
|
205
|
+
canvas[y][x] = "g";
|
|
206
|
+
x += GRASS_GAPS[i % GRASS_GAPS.length];
|
|
207
|
+
}
|
|
208
|
+
stamp(canvas, AARDVARK_SPRITE, 0, 0);
|
|
209
|
+
return canvas;
|
|
210
|
+
}
|
|
211
|
+
/** The sun is up between six in the morning and six at night. Close enough for a sky. */
|
|
212
|
+
function isNight(at = new Date()) {
|
|
213
|
+
const hour = at.getHours();
|
|
214
|
+
return hour < 6 || hour >= 18;
|
|
215
|
+
}
|
|
216
|
+
// ------------------------------------------------------------------ render
|
|
217
|
+
function paint(top, bottom) {
|
|
218
|
+
if (top === "*" || bottom === "*") {
|
|
219
|
+
// A star is a glyph, not a pixel pair. Rendered dim so it reads as distant.
|
|
220
|
+
return colorEnabled ? `${INK.c}${STAR}${RESET}` : STAR;
|
|
221
|
+
}
|
|
222
|
+
/*
|
|
223
|
+
* Everything drawn as a character rather than as a pixel pair is resolved first: clouds and the
|
|
224
|
+
* moon's stipple. All are stamped at cell resolution, so there is never half of one to draw.
|
|
225
|
+
*/
|
|
226
|
+
if (top === "c" || bottom === "c") {
|
|
227
|
+
return colorEnabled ? `${INK.c}${SHADE}${RESET}` : SHADE;
|
|
228
|
+
}
|
|
229
|
+
if (top === "M" || bottom === "M") {
|
|
230
|
+
return colorEnabled ? `${MOONLIGHT}${FULL}${RESET}` : FULL;
|
|
231
|
+
}
|
|
232
|
+
if (top === "d" || bottom === "d") {
|
|
233
|
+
// The stipple reads dimmer than the solid on its own — a quarter of the cell is lit — so it
|
|
234
|
+
// needs no separate colour to sit behind the edge.
|
|
235
|
+
return colorEnabled ? `${MOONLIGHT}${SHADE}${RESET}` : SHADE;
|
|
236
|
+
}
|
|
237
|
+
if (top === "." && bottom === ".")
|
|
238
|
+
return " ";
|
|
239
|
+
if (!colorEnabled) {
|
|
240
|
+
// Nothing to tell the layers apart with, so fall back to shape alone.
|
|
241
|
+
return top === "." ? LOWER : bottom === "." ? UPPER : FULL;
|
|
242
|
+
}
|
|
243
|
+
if (bottom === ".")
|
|
244
|
+
return `${INK[top] ?? ""}${UPPER}${RESET}`;
|
|
245
|
+
if (top === ".")
|
|
246
|
+
return `${INK[bottom] ?? ""}${LOWER}${RESET}`;
|
|
247
|
+
return `${INK[top] ?? ""}${WASH[bottom] ?? ""}${UPPER}${RESET}`;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* The scene as terminal rows, each prefixed with the trunk so it hangs off the same vertical
|
|
251
|
+
* line as the rest of the flow.
|
|
252
|
+
*
|
|
253
|
+
* Returns an empty array when the terminal has not told us it speaks UTF-8 — half blocks come
|
|
254
|
+
* out as replacement characters there — and null when the window is too narrow, which is the
|
|
255
|
+
* caller's cue to fall back to the aardvark on its own.
|
|
256
|
+
*/
|
|
257
|
+
export function sceneLines(opts = {}) {
|
|
258
|
+
if (!(opts.unicode ?? unicodeEnabled))
|
|
259
|
+
return [];
|
|
260
|
+
const columns = opts.columns ?? process.stdout.columns ?? 80;
|
|
261
|
+
if (columns < SCENE_COLUMNS)
|
|
262
|
+
return null;
|
|
263
|
+
const indent = opts.indent ?? 2;
|
|
264
|
+
const canvas = compose(opts.night ?? isNight());
|
|
265
|
+
const rows = [];
|
|
266
|
+
for (let y = 0; y < HEIGHT; y += 2) {
|
|
267
|
+
const top = canvas[y];
|
|
268
|
+
const bottom = canvas[y + 1];
|
|
269
|
+
let out = "";
|
|
270
|
+
for (let x = 0; x < WIDTH; x += 1)
|
|
271
|
+
out += paint(top[x], bottom[x]);
|
|
272
|
+
rows.push(`${style.dim(glyph.trunk)}${" ".repeat(indent)}${out.replace(/\s+$/, "")}`);
|
|
273
|
+
}
|
|
274
|
+
return rows;
|
|
275
|
+
}
|
|
276
|
+
//# sourceMappingURL=scene.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scene.js","sourceRoot":"","sources":["../src/scene.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE/F,MAAM,KAAK,GAAG,EAAE,CAAC;AACjB,+DAA+D;AAC/D,MAAM,MAAM,GAAG,EAAE,CAAC;AAElB,gEAAgE;AAChE,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,GAAG,CAAC,CAAC;AAEvC,6EAA6E;AAE7E;;;;;;;;;;;;;GAaG;AACH,kBAAkB;AAClB,MAAM,IAAI,GAAG;IACX,gBAAgB;IAChB,gBAAgB;IAChB,gBAAgB;IAChB,gBAAgB;IAChB,gBAAgB;IAChB,gBAAgB;IAChB,gBAAgB;CACjB,CAAC;AAEF;;;;;GAKG;AACH,kBAAkB;AAClB,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