@flyingrobots/bijou-tui 1.8.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +64 -21
- package/dist/animate.d.ts +0 -2
- package/dist/animate.d.ts.map +1 -1
- package/dist/animate.js +17 -26
- package/dist/animate.js.map +1 -1
- package/dist/app-frame-actions.d.ts +37 -0
- package/dist/app-frame-actions.d.ts.map +1 -0
- package/dist/app-frame-actions.js +313 -0
- package/dist/app-frame-actions.js.map +1 -0
- package/dist/app-frame-palette.d.ts +16 -0
- package/dist/app-frame-palette.d.ts.map +1 -0
- package/dist/app-frame-palette.js +158 -0
- package/dist/app-frame-palette.js.map +1 -0
- package/dist/app-frame-render.d.ts +39 -0
- package/dist/app-frame-render.d.ts.map +1 -0
- package/dist/app-frame-render.js +319 -0
- package/dist/app-frame-render.js.map +1 -0
- package/dist/app-frame-types.d.ts +135 -0
- package/dist/app-frame-types.d.ts.map +1 -0
- package/dist/app-frame-types.js +72 -0
- package/dist/app-frame-types.js.map +1 -0
- package/dist/app-frame-utils.d.ts +37 -0
- package/dist/app-frame-utils.d.ts.map +1 -0
- package/dist/app-frame-utils.js +141 -0
- package/dist/app-frame-utils.js.map +1 -0
- package/dist/app-frame.d.ts +13 -8
- package/dist/app-frame.d.ts.map +1 -1
- package/dist/app-frame.js +80 -906
- package/dist/app-frame.js.map +1 -1
- package/dist/canvas.d.ts +37 -25
- package/dist/canvas.d.ts.map +1 -1
- package/dist/canvas.js +116 -30
- package/dist/canvas.js.map +1 -1
- package/dist/commands.js +2 -2
- package/dist/commands.js.map +1 -1
- package/dist/css/install.d.ts +4 -0
- package/dist/css/install.d.ts.map +1 -0
- package/dist/css/install.js +24 -0
- package/dist/css/install.js.map +1 -0
- package/dist/css/parser.d.ts +14 -0
- package/dist/css/parser.d.ts.map +1 -0
- package/dist/css/parser.js +92 -0
- package/dist/css/parser.js.map +1 -0
- package/dist/css/resolver.d.ts +36 -0
- package/dist/css/resolver.d.ts.map +1 -0
- package/dist/css/resolver.js +130 -0
- package/dist/css/resolver.js.map +1 -0
- package/dist/css/text-style.d.ts +17 -0
- package/dist/css/text-style.d.ts.map +1 -0
- package/dist/css/text-style.js +59 -0
- package/dist/css/text-style.js.map +1 -0
- package/dist/css/types.d.ts +27 -0
- package/dist/css/types.d.ts.map +1 -0
- package/dist/css/types.js +5 -0
- package/dist/css/types.js.map +1 -0
- package/dist/driver.d.ts +10 -2
- package/dist/driver.d.ts.map +1 -1
- package/dist/driver.js +25 -2
- package/dist/driver.js.map +1 -1
- package/dist/eventbus.d.ts +42 -3
- package/dist/eventbus.d.ts.map +1 -1
- package/dist/eventbus.js +108 -7
- package/dist/eventbus.js.map +1 -1
- package/dist/focus-area.d.ts +4 -0
- package/dist/focus-area.d.ts.map +1 -1
- package/dist/focus-area.js +11 -1
- package/dist/focus-area.js.map +1 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -1
- package/dist/index.js.map +1 -1
- package/dist/layout-v3.d.ts +10 -0
- package/dist/layout-v3.d.ts.map +1 -0
- package/dist/layout-v3.js +35 -0
- package/dist/layout-v3.js.map +1 -0
- package/dist/motion/motion.d.ts +14 -0
- package/dist/motion/motion.d.ts.map +1 -0
- package/dist/motion/motion.js +31 -0
- package/dist/motion/motion.js.map +1 -0
- package/dist/motion/reconciler.d.ts +15 -0
- package/dist/motion/reconciler.d.ts.map +1 -0
- package/dist/motion/reconciler.js +109 -0
- package/dist/motion/reconciler.js.map +1 -0
- package/dist/motion/types.d.ts +52 -0
- package/dist/motion/types.d.ts.map +1 -0
- package/dist/motion/types.js +2 -0
- package/dist/motion/types.js.map +1 -0
- package/dist/pipeline/middleware/css.d.ts +20 -0
- package/dist/pipeline/middleware/css.d.ts.map +1 -0
- package/dist/pipeline/middleware/css.js +41 -0
- package/dist/pipeline/middleware/css.js.map +1 -0
- package/dist/pipeline/middleware/grayscale.d.ts +9 -0
- package/dist/pipeline/middleware/grayscale.d.ts.map +1 -0
- package/dist/pipeline/middleware/grayscale.js +39 -0
- package/dist/pipeline/middleware/grayscale.js.map +1 -0
- package/dist/pipeline/middleware/motion.d.ts +6 -0
- package/dist/pipeline/middleware/motion.d.ts.map +1 -0
- package/dist/pipeline/middleware/motion.js +19 -0
- package/dist/pipeline/middleware/motion.js.map +1 -0
- package/dist/pipeline/middleware/paint.d.ts +6 -0
- package/dist/pipeline/middleware/paint.d.ts.map +1 -0
- package/dist/pipeline/middleware/paint.js +21 -0
- package/dist/pipeline/middleware/paint.js.map +1 -0
- package/dist/pipeline/pipeline.d.ts +56 -0
- package/dist/pipeline/pipeline.d.ts.map +1 -0
- package/dist/pipeline/pipeline.js +45 -0
- package/dist/pipeline/pipeline.js.map +1 -0
- package/dist/runtime.d.ts +1 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +153 -8
- package/dist/runtime.js.map +1 -1
- package/dist/screen.d.ts +12 -1
- package/dist/screen.d.ts.map +1 -1
- package/dist/screen.js +14 -1
- package/dist/screen.js.map +1 -1
- package/dist/subapp/mount.d.ts +67 -0
- package/dist/subapp/mount.d.ts.map +1 -0
- package/dist/subapp/mount.js +60 -0
- package/dist/subapp/mount.js.map +1 -0
- package/dist/transition-shaders.d.ts +101 -3
- package/dist/transition-shaders.d.ts.map +1 -1
- package/dist/transition-shaders.js +281 -6
- package/dist/transition-shaders.js.map +1 -1
- package/dist/types.d.ts +45 -8
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +9 -0
- package/dist/types.js.map +1 -1
- package/dist/view-output.d.ts +15 -0
- package/dist/view-output.d.ts.map +1 -0
- package/dist/view-output.js +53 -0
- package/dist/view-output.js.map +1 -0
- package/package.json +3 -3
package/dist/runtime.js
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import { getDefaultContext } from '@flyingrobots/bijou';
|
|
2
|
-
import { isKeyMsg } from './types.js';
|
|
3
|
-
import { enterScreen, exitScreen,
|
|
1
|
+
import { getDefaultContext, createSurface, surfaceToString } from '@flyingrobots/bijou';
|
|
2
|
+
import { isKeyMsg, isPulseMsg, isResizeMsg } from './types.js';
|
|
3
|
+
import { clearAndHome, enterScreen, exitScreen, renderSurfaceFrame } from './screen.js';
|
|
4
4
|
import { createEventBus } from './eventbus.js';
|
|
5
|
+
import { createPipeline } from './pipeline/pipeline.js';
|
|
6
|
+
import { bcssMiddleware } from './pipeline/middleware/css.js';
|
|
7
|
+
import { motionMiddleware } from './pipeline/middleware/motion.js';
|
|
8
|
+
import { paintMiddleware } from './pipeline/middleware/paint.js';
|
|
9
|
+
import { installBCSSResolver } from './css/install.js';
|
|
10
|
+
import { normalizeViewOutput, wrapViewOutputAsLayoutRoot } from './view-output.js';
|
|
5
11
|
/**
|
|
6
12
|
* Disable mouse reporting sequences that terminals may send.
|
|
7
13
|
* Some terminals auto-enable mouse tracking in alt screen mode.
|
|
8
14
|
*/
|
|
9
|
-
const DISABLE_MOUSE = '\x1b[?1000l\x1b[?1002l\x1b[?
|
|
15
|
+
const DISABLE_MOUSE = '\x1b[?1000l\x1b[?1002l\x1b[?1006l';
|
|
10
16
|
/**
|
|
11
17
|
* Enable SGR mouse reporting.
|
|
12
18
|
* 1000 = basic press/release, 1002 = button-event tracking (drag),
|
|
@@ -31,13 +37,27 @@ const ENABLE_MOUSE = '\x1b[?1000h\x1b[?1002h\x1b[?1006h';
|
|
|
31
37
|
*/
|
|
32
38
|
export async function run(app, options) {
|
|
33
39
|
const ctx = options?.ctx ?? getDefaultContext();
|
|
40
|
+
installRuntimeOverlay(ctx);
|
|
34
41
|
const useAltScreen = options?.altScreen ?? true;
|
|
35
42
|
const useHideCursor = options?.hideCursor ?? true;
|
|
36
43
|
const useMouse = options?.mouse ?? false;
|
|
44
|
+
installBCSSResolver(ctx, options?.css);
|
|
37
45
|
const [initModel, initCmds] = app.init();
|
|
38
46
|
// Non-interactive: render once and return
|
|
39
47
|
if (ctx.mode !== 'interactive') {
|
|
40
|
-
|
|
48
|
+
const viewOutput = app.view(initModel);
|
|
49
|
+
let output;
|
|
50
|
+
if (typeof viewOutput === 'string') {
|
|
51
|
+
output = viewOutput;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
const normalized = normalizeViewOutput(viewOutput, {
|
|
55
|
+
width: sanitizeDimension(ctx.runtime.columns),
|
|
56
|
+
height: sanitizeDimension(ctx.runtime.rows),
|
|
57
|
+
});
|
|
58
|
+
output = surfaceToString(normalized.surface, ctx.style);
|
|
59
|
+
}
|
|
60
|
+
ctx.io.write(output);
|
|
41
61
|
return;
|
|
42
62
|
}
|
|
43
63
|
// Interactive mode
|
|
@@ -45,6 +65,10 @@ export async function run(app, options) {
|
|
|
45
65
|
let running = true;
|
|
46
66
|
let lastCtrlC = 0;
|
|
47
67
|
let resolveQuit = null;
|
|
68
|
+
let currentDt = 0.016; // Default to 60fps for first frame
|
|
69
|
+
let fatalError = null;
|
|
70
|
+
// Double Buffering: track what is currently on screen
|
|
71
|
+
let currentSurface = createSurface(sanitizeDimension(ctx.runtime.columns), sanitizeDimension(ctx.runtime.rows));
|
|
48
72
|
const bus = createEventBus({
|
|
49
73
|
onCommandRejected(error) {
|
|
50
74
|
const message = error instanceof Error
|
|
@@ -53,8 +77,46 @@ export async function run(app, options) {
|
|
|
53
77
|
writeErrorLine(ctx.io, `[EventBus] Command rejected: ${message}\n`);
|
|
54
78
|
},
|
|
55
79
|
});
|
|
80
|
+
// Setup Programmable Rendering Pipeline
|
|
81
|
+
const pipeline = createPipeline();
|
|
82
|
+
// 1. Layout Logic Stage
|
|
83
|
+
pipeline.use('Layout', (state, next) => {
|
|
84
|
+
const viewOutput = app.view(state.model);
|
|
85
|
+
state.layoutRoot = wrapViewOutputAsLayoutRoot(viewOutput, {
|
|
86
|
+
width: sanitizeDimension(ctx.runtime.columns),
|
|
87
|
+
height: sanitizeDimension(ctx.runtime.rows),
|
|
88
|
+
});
|
|
89
|
+
next();
|
|
90
|
+
});
|
|
91
|
+
// 2. Motion Interpolation Stage
|
|
92
|
+
pipeline.use('Layout', motionMiddleware());
|
|
93
|
+
if (options?.css) {
|
|
94
|
+
pipeline.use('Layout', bcssMiddleware(options.css));
|
|
95
|
+
}
|
|
96
|
+
// 3. Paint Stage
|
|
97
|
+
pipeline.use('Paint', paintMiddleware());
|
|
98
|
+
// Add default Diff stage (double-buffering)
|
|
99
|
+
pipeline.use('Diff', (state, next) => {
|
|
100
|
+
renderSurfaceFrame(state.ctx.io, state.currentSurface, state.targetSurface, state.ctx.style);
|
|
101
|
+
next();
|
|
102
|
+
});
|
|
103
|
+
// Add default Output stage (sync current surface)
|
|
104
|
+
pipeline.use('Output', (state, next) => {
|
|
105
|
+
currentSurface = state.targetSurface.clone();
|
|
106
|
+
next();
|
|
107
|
+
});
|
|
108
|
+
options?.configurePipeline?.(pipeline);
|
|
109
|
+
// Register user middleware
|
|
110
|
+
if (options?.middlewares) {
|
|
111
|
+
for (const mw of options.middlewares) {
|
|
112
|
+
bus.use(mw);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
56
115
|
/** Tear down the run loop and signal the quit promise. */
|
|
57
|
-
function shutdown() {
|
|
116
|
+
function shutdown(error) {
|
|
117
|
+
if (error !== undefined && fatalError === null) {
|
|
118
|
+
fatalError = error;
|
|
119
|
+
}
|
|
58
120
|
if (!running)
|
|
59
121
|
return;
|
|
60
122
|
running = false;
|
|
@@ -72,11 +134,34 @@ export async function run(app, options) {
|
|
|
72
134
|
ctx.io.write(DISABLE_MOUSE);
|
|
73
135
|
}
|
|
74
136
|
// Render helper
|
|
137
|
+
let renderRequested = false;
|
|
75
138
|
/** Render the current model's view to the terminal. */
|
|
76
139
|
function render() {
|
|
77
|
-
if (!running)
|
|
140
|
+
if (!running || renderRequested)
|
|
78
141
|
return;
|
|
79
|
-
|
|
142
|
+
renderRequested = true;
|
|
143
|
+
setTimeout(() => {
|
|
144
|
+
try {
|
|
145
|
+
const targetSurface = createSurface(sanitizeDimension(ctx.runtime.columns), sanitizeDimension(ctx.runtime.rows));
|
|
146
|
+
const renderState = {
|
|
147
|
+
model,
|
|
148
|
+
ctx,
|
|
149
|
+
dt: currentDt,
|
|
150
|
+
currentSurface,
|
|
151
|
+
targetSurface,
|
|
152
|
+
layoutMap: new Map(),
|
|
153
|
+
data: {},
|
|
154
|
+
};
|
|
155
|
+
pipeline.execute(renderState);
|
|
156
|
+
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
writeErrorLine(ctx.io, `[Runtime Error] ${error instanceof Error ? (error.stack ?? error.message) : String(error)}\n`);
|
|
159
|
+
shutdown(error);
|
|
160
|
+
}
|
|
161
|
+
finally {
|
|
162
|
+
renderRequested = false;
|
|
163
|
+
}
|
|
164
|
+
}, 0);
|
|
80
165
|
}
|
|
81
166
|
// Execute commands through the bus
|
|
82
167
|
/** Submit TEA commands to the event bus for async execution. */
|
|
@@ -89,10 +174,22 @@ export async function run(app, options) {
|
|
|
89
174
|
bus.connectIO(ctx.io, { mouse: useMouse });
|
|
90
175
|
// Handle quit signals from commands
|
|
91
176
|
bus.onQuit(shutdown);
|
|
177
|
+
// Start heartbeat for animations
|
|
178
|
+
bus.startPulse(ctx.runtime.refreshRate);
|
|
92
179
|
// Single subscription drives the entire update cycle
|
|
93
180
|
bus.on((msg) => {
|
|
94
181
|
if (!running)
|
|
95
182
|
return;
|
|
183
|
+
// Track time delta from pulse
|
|
184
|
+
if (isPulseMsg(msg)) {
|
|
185
|
+
currentDt = msg.dt;
|
|
186
|
+
}
|
|
187
|
+
if (isResizeMsg(msg)) {
|
|
188
|
+
ctx.runtime.columns = sanitizeDimension(msg.columns);
|
|
189
|
+
ctx.runtime.rows = sanitizeDimension(msg.rows);
|
|
190
|
+
currentSurface = createSurface(ctx.runtime.columns, ctx.runtime.rows);
|
|
191
|
+
clearAndHome(ctx.io);
|
|
192
|
+
}
|
|
96
193
|
// Double Ctrl+C force-quit
|
|
97
194
|
if (isKeyMsg(msg) && msg.key === 'c' && msg.ctrl) {
|
|
98
195
|
const now = Date.now();
|
|
@@ -116,6 +213,9 @@ export async function run(app, options) {
|
|
|
116
213
|
};
|
|
117
214
|
const [resizedModel, resizeCmds] = app.update(initialResize, model);
|
|
118
215
|
model = resizedModel;
|
|
216
|
+
// After a potential resize in update, ensure currentSurface matches size
|
|
217
|
+
// to avoid diffing mismatched grids.
|
|
218
|
+
currentSurface = createSurface(sanitizeDimension(ctx.runtime.columns), sanitizeDimension(ctx.runtime.rows));
|
|
119
219
|
// Initial render + startup commands
|
|
120
220
|
render();
|
|
121
221
|
executeCommands(initCmds);
|
|
@@ -126,7 +226,14 @@ export async function run(app, options) {
|
|
|
126
226
|
if (!running)
|
|
127
227
|
resolve();
|
|
128
228
|
});
|
|
229
|
+
// Ensure any pending render is flushed before exiting
|
|
230
|
+
if (renderRequested) {
|
|
231
|
+
await new Promise((resolve) => {
|
|
232
|
+
setTimeout(resolve, 0);
|
|
233
|
+
});
|
|
234
|
+
}
|
|
129
235
|
// Cleanup — bus disposes all I/O connections
|
|
236
|
+
bus.stopPulse();
|
|
130
237
|
bus.dispose();
|
|
131
238
|
if (useMouse) {
|
|
132
239
|
ctx.io.write(DISABLE_MOUSE);
|
|
@@ -134,6 +241,9 @@ export async function run(app, options) {
|
|
|
134
241
|
if (useAltScreen || useHideCursor) {
|
|
135
242
|
exitScreen(ctx.io);
|
|
136
243
|
}
|
|
244
|
+
if (fatalError != null) {
|
|
245
|
+
throw fatalError instanceof Error ? fatalError : new Error(String(fatalError));
|
|
246
|
+
}
|
|
137
247
|
}
|
|
138
248
|
/** Clamp a terminal dimension to a non-negative integer. */
|
|
139
249
|
function sanitizeDimension(value) {
|
|
@@ -141,6 +251,41 @@ function sanitizeDimension(value) {
|
|
|
141
251
|
return 0;
|
|
142
252
|
return Math.max(0, Math.floor(value));
|
|
143
253
|
}
|
|
254
|
+
function installRuntimeOverlay(ctx) {
|
|
255
|
+
const baseRuntime = ctx.runtime;
|
|
256
|
+
const state = {
|
|
257
|
+
columns: sanitizeDimension(baseRuntime.columns),
|
|
258
|
+
rows: sanitizeDimension(baseRuntime.rows),
|
|
259
|
+
};
|
|
260
|
+
const runtime = {
|
|
261
|
+
env(key) {
|
|
262
|
+
return baseRuntime.env(key);
|
|
263
|
+
},
|
|
264
|
+
get stdoutIsTTY() {
|
|
265
|
+
return baseRuntime.stdoutIsTTY;
|
|
266
|
+
},
|
|
267
|
+
get stdinIsTTY() {
|
|
268
|
+
return baseRuntime.stdinIsTTY;
|
|
269
|
+
},
|
|
270
|
+
get columns() {
|
|
271
|
+
return state.columns;
|
|
272
|
+
},
|
|
273
|
+
set columns(value) {
|
|
274
|
+
state.columns = sanitizeDimension(value);
|
|
275
|
+
},
|
|
276
|
+
get rows() {
|
|
277
|
+
return state.rows;
|
|
278
|
+
},
|
|
279
|
+
set rows(value) {
|
|
280
|
+
state.rows = sanitizeDimension(value);
|
|
281
|
+
},
|
|
282
|
+
get refreshRate() {
|
|
283
|
+
return baseRuntime.refreshRate;
|
|
284
|
+
},
|
|
285
|
+
};
|
|
286
|
+
ctx.runtime = runtime;
|
|
287
|
+
return runtime;
|
|
288
|
+
}
|
|
144
289
|
/** Write an error message to stderr if available, otherwise stdout. */
|
|
145
290
|
function writeErrorLine(io, data) {
|
|
146
291
|
if (io.writeError != null) {
|
package/dist/runtime.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGxF,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAA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AAc,CAAC,EAAa,EAAE,IAAY;IACjD,IAAI,EAAE,CAAC,UAAU,IAAI,IAAI,EAAE,CAAC;QAC1B,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACpB,OAAO;IACT,CAAC;IACD,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AACjB,CAAC"}
|
package/dist/screen.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @module screen
|
|
8
8
|
*/
|
|
9
|
-
import { HIDE_CURSOR, SHOW_CURSOR, type IOPort } from '@flyingrobots/bijou';
|
|
9
|
+
import { HIDE_CURSOR, SHOW_CURSOR, type IOPort, type Surface, type StylePort } from '@flyingrobots/bijou';
|
|
10
10
|
/** ANSI escape: enter alternate screen buffer (DEC Private Mode 1049). */
|
|
11
11
|
export declare const ENTER_ALT_SCREEN = "\u001B[?1049h";
|
|
12
12
|
/** ANSI escape: exit alternate screen buffer (DEC Private Mode 1049). */
|
|
@@ -76,8 +76,19 @@ export declare function exitScreen(io: IOPort): void;
|
|
|
76
76
|
* @param io - The I/O port to write escape sequences to.
|
|
77
77
|
*/
|
|
78
78
|
export declare function clearAndHome(io: IOPort): void;
|
|
79
|
+
/**
|
|
80
|
+
* Optimized double-buffered render: diff two surfaces and write the minimal
|
|
81
|
+
* set of CUP/SGR escape codes to the terminal.
|
|
82
|
+
*
|
|
83
|
+
* @param io - The I/O port to write the composed frame to.
|
|
84
|
+
* @param current - The surface currently on screen.
|
|
85
|
+
* @param target - The new surface to render.
|
|
86
|
+
* @param style - Style port for color resolution.
|
|
87
|
+
*/
|
|
88
|
+
export declare function renderSurfaceFrame(io: IOPort, current: Surface, target: Surface, style: StylePort): void;
|
|
79
89
|
/**
|
|
80
90
|
* Flicker-free render: move cursor home, write content line-by-line,
|
|
91
|
+
...
|
|
81
92
|
* clearing from the end of each line to the terminal edge.
|
|
82
93
|
*
|
|
83
94
|
* Disabling wrap in enterScreen() ensures the terminal won't scroll
|
package/dist/screen.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"screen.d.ts","sourceRoot":"","sources":["../src/screen.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,WAAW,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"screen.d.ts","sourceRoot":"","sources":["../src/screen.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,WAAW,EAAE,WAAW,EAAc,KAAK,MAAM,EAAE,KAAK,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEtH,0EAA0E;AAC1E,eAAO,MAAM,gBAAgB,kBAAgB,CAAC;AAC9C,yEAAyE;AACzE,eAAO,MAAM,eAAe,kBAAgB,CAAC;AAE7C,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC;AACpC,+DAA+D;AAC/D,eAAO,MAAM,YAAY,eAAa,CAAC;AACvC,8DAA8D;AAC9D,eAAO,MAAM,WAAW,eAAa,CAAC;AACtC,+CAA+C;AAC/C,eAAO,MAAM,YAAY,cAAY,CAAC;AACtC,8DAA8D;AAC9D,eAAO,MAAM,YAAY,aAAW,CAAC;AACrC,oEAAoE;AACpE,eAAO,MAAM,iBAAiB,aAAW,CAAC;AAC1C,yDAAyD;AACzD,eAAO,MAAM,IAAI,aAAW,CAAC;AAC7B,qDAAqD;AACrD,eAAO,MAAM,UAAU,cAAY,CAAC;AAIpC,oDAAoD;AACpD,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,WAAW,GAAG,KAAK,CAAC;AAExD,qDAAqD;AACrD,eAAO,MAAM,YAAY,eAAa,CAAC;AACvC,yDAAyD;AACzD,eAAO,MAAM,gBAAgB,eAAa,CAAC;AAC3C,mDAAmD;AACnD,eAAO,MAAM,UAAU,eAAa,CAAC;AACrC,wFAAwF;AACxF,eAAO,MAAM,YAAY,eAAa,CAAC;AASvC;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAGlG;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAEjD;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAE5C;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAE3C;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAE7C;AACD;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,OAAO,EACf,KAAK,EAAE,SAAS,GACf,IAAI,CAEN;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAI7D"}
|
package/dist/screen.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @module screen
|
|
8
8
|
*/
|
|
9
|
-
import { HIDE_CURSOR, SHOW_CURSOR } from '@flyingrobots/bijou';
|
|
9
|
+
import { HIDE_CURSOR, SHOW_CURSOR, renderDiff } from '@flyingrobots/bijou';
|
|
10
10
|
/** ANSI escape: enter alternate screen buffer (DEC Private Mode 1049). */
|
|
11
11
|
export const ENTER_ALT_SCREEN = '\x1b[?1049h';
|
|
12
12
|
/** ANSI escape: exit alternate screen buffer (DEC Private Mode 1049). */
|
|
@@ -89,8 +89,21 @@ export function exitScreen(io) {
|
|
|
89
89
|
export function clearAndHome(io) {
|
|
90
90
|
io.write(CLEAR_SCREEN + HOME);
|
|
91
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* Optimized double-buffered render: diff two surfaces and write the minimal
|
|
94
|
+
* set of CUP/SGR escape codes to the terminal.
|
|
95
|
+
*
|
|
96
|
+
* @param io - The I/O port to write the composed frame to.
|
|
97
|
+
* @param current - The surface currently on screen.
|
|
98
|
+
* @param target - The new surface to render.
|
|
99
|
+
* @param style - Style port for color resolution.
|
|
100
|
+
*/
|
|
101
|
+
export function renderSurfaceFrame(io, current, target, style) {
|
|
102
|
+
renderDiff(current, target, io, style);
|
|
103
|
+
}
|
|
92
104
|
/**
|
|
93
105
|
* Flicker-free render: move cursor home, write content line-by-line,
|
|
106
|
+
...
|
|
94
107
|
* clearing from the end of each line to the terminal edge.
|
|
95
108
|
*
|
|
96
109
|
* Disabling wrap in enterScreen() ensures the terminal won't scroll
|
package/dist/screen.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"screen.js","sourceRoot":"","sources":["../src/screen.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,WAAW,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"screen.js","sourceRoot":"","sources":["../src/screen.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAA6C,MAAM,qBAAqB,CAAC;AAEtH,0EAA0E;AAC1E,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAa,CAAC;AAC9C,yEAAyE;AACzE,MAAM,CAAC,MAAM,eAAe,GAAG,aAAa,CAAC;AAE7C,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC;AACpC,+DAA+D;AAC/D,MAAM,CAAC,MAAM,YAAY,GAAG,UAAU,CAAC;AACvC,8DAA8D;AAC9D,MAAM,CAAC,MAAM,WAAW,GAAG,UAAU,CAAC;AACtC,+CAA+C;AAC/C,MAAM,CAAC,MAAM,YAAY,GAAG,SAAS,CAAC;AACtC,8DAA8D;AAC9D,MAAM,CAAC,MAAM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U;IACnC,EAAE,CAAC,KAAK,CAAC,WAAW,GAAG,WAAW,GAAG,eAAe,CAAC,CAAC;AACxD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,EAAU;IACrC,EAAE,CAAC,KAAK,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;AAChC,CAAC;AACD;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CAChC,EAAU,EACV,OAAgB,EAChB,MAAe,EACf,KAAgB;IAEhB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC;AACzC,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,WAAW,CAAC,EAAU,EAAE,OAAe;IACrD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAClC,MAAM,KAAK,GAAG,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,iBAAiB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC;IAC7F,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { App, Cmd } from '../types.js';
|
|
2
|
+
import type { ViewOutput } from '../view-output.js';
|
|
3
|
+
/**
|
|
4
|
+
* Options for mounting a sub-app.
|
|
5
|
+
*
|
|
6
|
+
* @template SubModel - The sub-app's model type.
|
|
7
|
+
* @template SubMsg - The sub-app's message type.
|
|
8
|
+
* @template ParentMsg - The parent app's message type.
|
|
9
|
+
*/
|
|
10
|
+
export interface MountOptions<SubModel, SubMsg, ParentMsg> {
|
|
11
|
+
/** The current state of the sub-app. */
|
|
12
|
+
model: SubModel;
|
|
13
|
+
/** Function to map a sub-app message into a parent message. */
|
|
14
|
+
onMsg: (msg: SubMsg) => ParentMsg;
|
|
15
|
+
/**
|
|
16
|
+
* Optional function to intercept and handle `Cmd`s emitted by the sub-app.
|
|
17
|
+
* If not provided, commands are automatically mapped using `onMsg`.
|
|
18
|
+
*/
|
|
19
|
+
mapCmd?: (cmd: Cmd<SubMsg>) => Cmd<ParentMsg>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A mounted sub-app instance ready to be rendered.
|
|
23
|
+
*
|
|
24
|
+
* This is typically returned by the parent's `view` function
|
|
25
|
+
* and blitted onto the parent's surface.
|
|
26
|
+
*/
|
|
27
|
+
export interface MountedApp<SubMsg> {
|
|
28
|
+
/** The rendered surface or layout tree of the sub-app. */
|
|
29
|
+
surfaceOrNode: ViewOutput;
|
|
30
|
+
/**
|
|
31
|
+
* Any TEA commands the sub-app needs to execute.
|
|
32
|
+
* These should be dispatched by the parent during its update cycle.
|
|
33
|
+
*/
|
|
34
|
+
cmds: Cmd<SubMsg>[];
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Mount a sub-app, returning its rendered surface and any pending commands.
|
|
38
|
+
*
|
|
39
|
+
* @template SubModel - The sub-app's model type.
|
|
40
|
+
* @template SubMsg - The sub-app's message type.
|
|
41
|
+
* @template ParentMsg - The parent app's message type.
|
|
42
|
+
*
|
|
43
|
+
* @param app - The TEA application to mount.
|
|
44
|
+
* @param options - Configuration for the mounted instance.
|
|
45
|
+
* @returns A tuple of `[Surface | LayoutNode, mapped Cmds]`.
|
|
46
|
+
*/
|
|
47
|
+
export declare function mount<SubModel, SubMsg, ParentMsg>(app: App<SubModel, SubMsg>, options: MountOptions<SubModel, SubMsg, ParentMsg>): [ViewOutput, Cmd<ParentMsg>[]];
|
|
48
|
+
export interface SubAppOptions<SubMsg, ParentMsg> {
|
|
49
|
+
/** Function to map a sub-app message into a parent message. */
|
|
50
|
+
onMsg: (msg: SubMsg) => ParentMsg;
|
|
51
|
+
/**
|
|
52
|
+
* Optional function to intercept and handle `Cmd`s emitted by the sub-app.
|
|
53
|
+
* If not provided, commands are automatically mapped using `onMsg`.
|
|
54
|
+
*/
|
|
55
|
+
mapCmd?: (cmd: Cmd<SubMsg>) => Cmd<ParentMsg>;
|
|
56
|
+
}
|
|
57
|
+
export declare function initSubApp<SubModel, SubMsg, ParentMsg>(app: App<SubModel, SubMsg>, options: SubAppOptions<SubMsg, ParentMsg>): [SubModel, Cmd<ParentMsg>[]];
|
|
58
|
+
export declare function updateSubApp<SubModel, SubMsg, ParentMsg>(app: App<SubModel, SubMsg>, msg: SubMsg, model: SubModel, options: SubAppOptions<SubMsg, ParentMsg>): [SubModel, Cmd<ParentMsg>[]];
|
|
59
|
+
/**
|
|
60
|
+
* Helper to map an array of sub-app commands into parent commands.
|
|
61
|
+
*
|
|
62
|
+
* @param cmds - The sub-app commands to map.
|
|
63
|
+
* @param mapper - The message mapping function.
|
|
64
|
+
* @returns An array of commands that emit parent messages.
|
|
65
|
+
*/
|
|
66
|
+
export declare function mapCmds<SubMsg, ParentMsg>(cmds: Cmd<SubMsg>[], mapper: (msg: SubMsg) => ParentMsg): Cmd<ParentMsg>[];
|
|
67
|
+
//# sourceMappingURL=mount.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mount.d.ts","sourceRoot":"","sources":["../../src/subapp/mount.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,GAAG,EAAc,MAAM,aAAa,CAAC;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;;;;;GAMG;AACH,MAAM,WAAW,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS;IACvD,wCAAwC;IACxC,KAAK,EAAE,QAAQ,CAAC;IAChB,+DAA+D;IAC/D,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,SAAS,CAAC;IAClC;;;OAGG;IACH,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,SAAS,CAAC,CAAC;CAC/C;AAED;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OAAO,CAAC,MAAM,EAAE,SAAS,EACvC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,EACnB,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,SAAS,GACjC,GAAG,CAAC,SAAS,CAAC,EAAE,CAElB"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mount a sub-app, returning its rendered surface and any pending commands.
|
|
3
|
+
*
|
|
4
|
+
* @template SubModel - The sub-app's model type.
|
|
5
|
+
* @template SubMsg - The sub-app's message type.
|
|
6
|
+
* @template ParentMsg - The parent app's message type.
|
|
7
|
+
*
|
|
8
|
+
* @param app - The TEA application to mount.
|
|
9
|
+
* @param options - Configuration for the mounted instance.
|
|
10
|
+
* @returns A tuple of `[Surface | LayoutNode, mapped Cmds]`.
|
|
11
|
+
*/
|
|
12
|
+
export function mount(app, options) {
|
|
13
|
+
const { model } = options;
|
|
14
|
+
const surfaceOrNode = app.view(model);
|
|
15
|
+
return [surfaceOrNode, []];
|
|
16
|
+
}
|
|
17
|
+
export function initSubApp(app, options) {
|
|
18
|
+
const [model, cmds] = app.init();
|
|
19
|
+
return [model, mapSubAppCmds(cmds, options)];
|
|
20
|
+
}
|
|
21
|
+
export function updateSubApp(app, msg, model, options) {
|
|
22
|
+
const [nextModel, cmds] = app.update(msg, model);
|
|
23
|
+
return [nextModel, mapSubAppCmds(cmds, options)];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Helper to map an array of sub-app commands into parent commands.
|
|
27
|
+
*
|
|
28
|
+
* @param cmds - The sub-app commands to map.
|
|
29
|
+
* @param mapper - The message mapping function.
|
|
30
|
+
* @returns An array of commands that emit parent messages.
|
|
31
|
+
*/
|
|
32
|
+
export function mapCmds(cmds, mapper) {
|
|
33
|
+
return cmds.map((cmd) => mapSingleCmd(cmd, mapper));
|
|
34
|
+
}
|
|
35
|
+
function mapSubAppCmds(cmds, options) {
|
|
36
|
+
if (options.mapCmd != null) {
|
|
37
|
+
return cmds.map((cmd) => options.mapCmd(cmd));
|
|
38
|
+
}
|
|
39
|
+
return mapCmds(cmds, options.onMsg);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Map a single sub-app command to a parent command.
|
|
43
|
+
*/
|
|
44
|
+
function mapSingleCmd(cmd, mapper) {
|
|
45
|
+
return async (emit, caps) => {
|
|
46
|
+
// We intercept the sub-app's `emit` call to wrap its messages
|
|
47
|
+
const mappedEmit = (subMsg) => {
|
|
48
|
+
emit(mapper(subMsg));
|
|
49
|
+
};
|
|
50
|
+
const result = await cmd(mappedEmit, caps);
|
|
51
|
+
// If the command resolves to a final message, map it.
|
|
52
|
+
// Quit signals are passed through unaltered.
|
|
53
|
+
if (result === undefined)
|
|
54
|
+
return undefined;
|
|
55
|
+
if (typeof result === 'symbol')
|
|
56
|
+
return result; // QUIT
|
|
57
|
+
return mapper(result);
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=mount.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mount.js","sourceRoot":"","sources":["../../src/subapp/mount.ts"],"names":[],"mappings":"AAsCA;;;;;;;;;;GAUG;AACH,MAAM,UAAU,KAAK,CACnB,GAA0B,EAC1B,OAAkD;IAElD,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IAE1B,MAAM,aAAa,GAAG,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAEtC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;AAC7B,CAAC;AAYD,MAAM,UAAU,UAAU,CACxB,GAA0B,EAC1B,OAAyC;IAEzC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;IACjC,OAAO,CAAC,KAAK,EAAE,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;AAC/C,CAAC;AAED,MAAM,UAAU,YAAY,CAC1B,GA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C,MAAgB,CAAC,CAAC;IAClC,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Transition shader system — composable pure functions for page transitions.
|
|
3
3
|
*
|
|
4
|
-
* Each shader receives cell metadata (position, dimensions, progress, random
|
|
5
|
-
* and returns whether to show the next page or optionally
|
|
4
|
+
* Each shader receives cell metadata (position, dimensions, progress, random,
|
|
5
|
+
* frame counter) and returns whether to show the next page or optionally
|
|
6
|
+
* override the character.
|
|
7
|
+
*
|
|
8
|
+
* ## Shader types
|
|
9
|
+
*
|
|
10
|
+
* - **Instances** (`wipeShader`, `dissolveShader`, …) — zero-config, ready to use.
|
|
11
|
+
* - **Factories** (`wipe()`, `radial()`, `blinds()`, …) — parameterized, return a shader.
|
|
12
|
+
* - **Combinators** (`reverse()`, `chain()`, `overlay()`) — transform or compose shaders.
|
|
6
13
|
*/
|
|
7
14
|
import type { BijouContext } from '@flyingrobots/bijou';
|
|
8
15
|
/** Input provided to a transition shader for each cell. */
|
|
@@ -12,18 +19,35 @@ export interface TransitionCell {
|
|
|
12
19
|
readonly width: number;
|
|
13
20
|
readonly height: number;
|
|
14
21
|
readonly progress: number;
|
|
22
|
+
/** Stable pseudo-random [0, 1] based on coordinates — constant across frames. */
|
|
15
23
|
readonly rand: number;
|
|
24
|
+
/** Monotonic frame counter for temporal effects (glitch, static, etc.). */
|
|
25
|
+
readonly frame: number;
|
|
16
26
|
readonly ctx: BijouContext;
|
|
17
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Semantic role of a character override.
|
|
30
|
+
*
|
|
31
|
+
* - `'decoration'` — ambient visual noise (glitch blocks, static, scramble).
|
|
32
|
+
* Survives progress remapping in combinators like `reverse()` and `chain()`.
|
|
33
|
+
* - `'marker'` — positional indicator tied to the shader's progress direction
|
|
34
|
+
* (e.g., typewriter cursor). Dropped by combinators that remap progress,
|
|
35
|
+
* since the marker's position becomes meaningless in the new space.
|
|
36
|
+
*/
|
|
37
|
+
export type CharRole = 'decoration' | 'marker';
|
|
18
38
|
/** Output from a transition shader for a single cell. */
|
|
19
39
|
export interface TransitionResult {
|
|
20
40
|
readonly showNext: boolean;
|
|
21
41
|
readonly char?: string;
|
|
42
|
+
/** Semantic role of the char override. Defaults to `'decoration'` if omitted. */
|
|
43
|
+
readonly charRole?: CharRole;
|
|
22
44
|
}
|
|
23
45
|
/** A pure function that determines how each cell transitions between pages. */
|
|
24
46
|
export type TransitionShaderFn = (cell: TransitionCell) => TransitionResult;
|
|
47
|
+
/** Direction for axis-aligned wipes and blinds. */
|
|
48
|
+
export type WipeDirection = 'left' | 'right' | 'up' | 'down';
|
|
25
49
|
/** Built-in transition names. */
|
|
26
|
-
export type BuiltinTransition = 'none' | 'wipe' | 'dissolve' | 'grid' | 'fade' | 'melt' | 'matrix' | 'scramble';
|
|
50
|
+
export type BuiltinTransition = 'none' | 'wipe' | 'dissolve' | 'grid' | 'fade' | 'melt' | 'matrix' | 'scramble' | 'radial' | 'diamond' | 'spiral' | 'blinds' | 'curtain' | 'pixelate' | 'typewriter' | 'glitch' | 'static';
|
|
27
51
|
/** Left-to-right wipe. */
|
|
28
52
|
export declare const wipeShader: TransitionShaderFn;
|
|
29
53
|
/** Random pixel dissolve. */
|
|
@@ -38,6 +62,80 @@ export declare const meltShader: TransitionShaderFn;
|
|
|
38
62
|
export declare const matrixShader: TransitionShaderFn;
|
|
39
63
|
/** Scramble noise that resolves at midpoint. */
|
|
40
64
|
export declare const scrambleShader: TransitionShaderFn;
|
|
65
|
+
/** Directional wipe factory. Default: left-to-right. */
|
|
66
|
+
export declare function wipe(direction?: WipeDirection): TransitionShaderFn;
|
|
67
|
+
/** Circle expanding from an origin point. Default: center. */
|
|
68
|
+
export declare function radial(originX?: number, originY?: number): TransitionShaderFn;
|
|
69
|
+
/** Diamond/rhombus shape expanding from center. */
|
|
70
|
+
export declare function diamond(originX?: number, originY?: number): TransitionShaderFn;
|
|
71
|
+
/** Angular sweep that spirals outward from center. */
|
|
72
|
+
export declare function spiral(turns?: number, originX?: number, originY?: number): TransitionShaderFn;
|
|
73
|
+
/** Venetian blinds (horizontal or vertical bands). */
|
|
74
|
+
export declare function blinds(count?: number, direction?: 'horizontal' | 'vertical'): TransitionShaderFn;
|
|
75
|
+
/** Two halves sliding apart from center (vertical split). */
|
|
76
|
+
export declare function curtain(direction?: 'horizontal' | 'vertical'): TransitionShaderFn;
|
|
77
|
+
/** Progressively shrinking block pixelation that resolves to the next page. */
|
|
78
|
+
export declare function pixelate(maxBlockSize?: number): TransitionShaderFn;
|
|
79
|
+
/**
|
|
80
|
+
* Left-to-right, top-to-bottom typewriter reveal.
|
|
81
|
+
* Shows a cursor character at the leading edge.
|
|
82
|
+
*/
|
|
83
|
+
export declare function typewriter(cursor?: string): TransitionShaderFn;
|
|
84
|
+
/**
|
|
85
|
+
* Horizontal glitch displacement with RGB-split-style character noise.
|
|
86
|
+
* Uses the frame counter for temporal variation.
|
|
87
|
+
*/
|
|
88
|
+
export declare function glitch(intensity?: number): TransitionShaderFn;
|
|
89
|
+
/**
|
|
90
|
+
* TV static noise that clears to reveal the next page.
|
|
91
|
+
* Uses the frame counter for flickering.
|
|
92
|
+
*/
|
|
93
|
+
export declare function tvStatic(density?: number): TransitionShaderFn;
|
|
94
|
+
/** Circle expanding from center. */
|
|
95
|
+
export declare const radialShader: TransitionShaderFn;
|
|
96
|
+
/** Diamond expanding from center. */
|
|
97
|
+
export declare const diamondShader: TransitionShaderFn;
|
|
98
|
+
/** Spiral sweep from center. */
|
|
99
|
+
export declare const spiralShader: TransitionShaderFn;
|
|
100
|
+
/** 8-band horizontal blinds. */
|
|
101
|
+
export declare const blindsShader: TransitionShaderFn;
|
|
102
|
+
/** Vertical curtain split from center. */
|
|
103
|
+
export declare const curtainShader: TransitionShaderFn;
|
|
104
|
+
/** Block pixelation with 16px max block size. */
|
|
105
|
+
export declare const pixelateShader: TransitionShaderFn;
|
|
106
|
+
/** Typewriter reveal with ▌ cursor. */
|
|
107
|
+
export declare const typewriterShader: TransitionShaderFn;
|
|
108
|
+
/** Horizontal glitch at 50% intensity. */
|
|
109
|
+
export declare const glitchShader: TransitionShaderFn;
|
|
110
|
+
/** TV static noise at 70% density. */
|
|
111
|
+
export declare const staticShader: TransitionShaderFn;
|
|
112
|
+
/**
|
|
113
|
+
* Reverse a shader's spatial reveal order.
|
|
114
|
+
*
|
|
115
|
+
* Cells that would be revealed last are revealed first, and vice versa.
|
|
116
|
+
* At progress=0 nothing is revealed; at progress=1 everything is revealed.
|
|
117
|
+
*/
|
|
118
|
+
export declare function reverse(shader: TransitionShaderFn): TransitionShaderFn;
|
|
119
|
+
/**
|
|
120
|
+
* Chain two shaders sequentially: `a` runs during progress [0, 0.5],
|
|
121
|
+
* `b` runs during (0.5, 1]. Each sub-shader receives a normalized 0→1
|
|
122
|
+
* progress for its half.
|
|
123
|
+
*
|
|
124
|
+
* **Note:** There is a hard cut at the midpoint — shader `a` completes
|
|
125
|
+
* (all cells revealed) then shader `b` starts from scratch (no cells
|
|
126
|
+
* revealed). This is intentional for effects like "dissolve out → wipe in"
|
|
127
|
+
* but will flash if both shaders reveal in the same direction.
|
|
128
|
+
*/
|
|
129
|
+
export declare function chain(a: TransitionShaderFn, b: TransitionShaderFn): TransitionShaderFn;
|
|
130
|
+
/**
|
|
131
|
+
* Overlay two shaders: `top` shader's char override wins when present,
|
|
132
|
+
* otherwise falls through to `base` shader's result.
|
|
133
|
+
*
|
|
134
|
+
* `showNext` uses OR semantics — the composite reveals a cell if *either*
|
|
135
|
+
* shader reveals it. This means the composite always reveals at least as
|
|
136
|
+
* much as either shader alone.
|
|
137
|
+
*/
|
|
138
|
+
export declare function overlay(base: TransitionShaderFn, top: TransitionShaderFn): TransitionShaderFn;
|
|
41
139
|
/** Registry mapping built-in transition names to shader functions. `none` maps to `undefined`. */
|
|
42
140
|
export declare const TRANSITION_SHADERS: Record<BuiltinTransition, TransitionShaderFn | undefined>;
|
|
43
141
|
//# sourceMappingURL=transition-shaders.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transition-shaders.d.ts","sourceRoot":"","sources":["../src/transition-shaders.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"transition-shaders.d.ts","sourceRoot":"","sources":["../src/transition-shaders.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAMxD,2DAA2D;AAC3D,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,iFAAiF;IACjF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,2EAA2E;IAC3E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,YAAY,CAAC;CAC5B;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,QAAQ,GAAG,YAAY,GAAG,QAAQ,CAAC;AAE/C,yDAAyD;AACzD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,iFAAiF;IACjF,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC;CAC9B;AAED,+EAA+E;AAC/E,MAAM,MAAM,kBAAkB,GAAG,CAAC,IAAI,EAAE,cAAc,KAAK,gBAAgB,CAAC;AAE5E,mDAAmD;AACnD,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,MAAM,CAAC;AAE7D,iCAAiC;AACjC,MAAM,MAAM,i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