@opentuah/react 0.1.77

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.
@@ -0,0 +1,569 @@
1
+ // @bun
2
+ import {
3
+ __require
4
+ } from "./chunk-eecw9x2f.js";
5
+
6
+ // src/components/index.ts
7
+ import {
8
+ ASCIIFontRenderable,
9
+ BoxRenderable,
10
+ CodeRenderable,
11
+ DiffRenderable,
12
+ InputRenderable,
13
+ LineNumberRenderable,
14
+ MarkdownRenderable,
15
+ ScrollBoxRenderable,
16
+ SelectRenderable,
17
+ TabSelectRenderable,
18
+ TextareaRenderable,
19
+ TextRenderable
20
+ } from "@opentui/core";
21
+
22
+ // src/components/text.ts
23
+ import { TextAttributes, TextNodeRenderable } from "@opentui/core";
24
+ var textNodeKeys = ["span", "b", "strong", "i", "em", "u", "br", "a"];
25
+
26
+ class SpanRenderable extends TextNodeRenderable {
27
+ ctx;
28
+ constructor(ctx, options) {
29
+ super(options);
30
+ this.ctx = ctx;
31
+ }
32
+ }
33
+
34
+ class TextModifierRenderable extends SpanRenderable {
35
+ constructor(options, modifier) {
36
+ super(null, options);
37
+ if (modifier === "b" || modifier === "strong") {
38
+ this.attributes = (this.attributes || 0) | TextAttributes.BOLD;
39
+ } else if (modifier === "i" || modifier === "em") {
40
+ this.attributes = (this.attributes || 0) | TextAttributes.ITALIC;
41
+ } else if (modifier === "u") {
42
+ this.attributes = (this.attributes || 0) | TextAttributes.UNDERLINE;
43
+ }
44
+ }
45
+ }
46
+
47
+ class BoldSpanRenderable extends TextModifierRenderable {
48
+ constructor(_ctx, options) {
49
+ super(options, "b");
50
+ }
51
+ }
52
+
53
+ class ItalicSpanRenderable extends TextModifierRenderable {
54
+ constructor(_ctx, options) {
55
+ super(options, "i");
56
+ }
57
+ }
58
+
59
+ class UnderlineSpanRenderable extends TextModifierRenderable {
60
+ constructor(_ctx, options) {
61
+ super(options, "u");
62
+ }
63
+ }
64
+
65
+ class LineBreakRenderable extends SpanRenderable {
66
+ constructor(_ctx, options) {
67
+ super(null, options);
68
+ this.add();
69
+ }
70
+ add() {
71
+ return super.add(`
72
+ `);
73
+ }
74
+ }
75
+
76
+ class LinkRenderable extends SpanRenderable {
77
+ constructor(_ctx, options) {
78
+ const linkOptions = {
79
+ ...options,
80
+ link: { url: options.href }
81
+ };
82
+ super(null, linkOptions);
83
+ }
84
+ }
85
+
86
+ // src/components/index.ts
87
+ var baseComponents = {
88
+ box: BoxRenderable,
89
+ text: TextRenderable,
90
+ code: CodeRenderable,
91
+ diff: DiffRenderable,
92
+ markdown: MarkdownRenderable,
93
+ input: InputRenderable,
94
+ select: SelectRenderable,
95
+ textarea: TextareaRenderable,
96
+ scrollbox: ScrollBoxRenderable,
97
+ "ascii-font": ASCIIFontRenderable,
98
+ "tab-select": TabSelectRenderable,
99
+ "line-number": LineNumberRenderable,
100
+ span: SpanRenderable,
101
+ br: LineBreakRenderable,
102
+ b: BoldSpanRenderable,
103
+ strong: BoldSpanRenderable,
104
+ i: ItalicSpanRenderable,
105
+ em: ItalicSpanRenderable,
106
+ u: UnderlineSpanRenderable,
107
+ a: LinkRenderable
108
+ };
109
+ var componentCatalogue = { ...baseComponents };
110
+ function extend(objects) {
111
+ Object.assign(componentCatalogue, objects);
112
+ }
113
+ function getComponentCatalogue() {
114
+ return componentCatalogue;
115
+ }
116
+
117
+ // src/components/app.tsx
118
+ import { createContext, useContext } from "react";
119
+ var AppContext = createContext({
120
+ keyHandler: null,
121
+ renderer: null
122
+ });
123
+ var useAppContext = () => {
124
+ return useContext(AppContext);
125
+ };
126
+
127
+ // src/reconciler/renderer.ts
128
+ import { CliRenderEvents, engine } from "@opentui/core";
129
+ import React2 from "react";
130
+
131
+ // src/components/error-boundary.tsx
132
+ import React from "react";
133
+ import { jsxDEV } from "@opentui/react/jsx-dev-runtime";
134
+
135
+ class ErrorBoundary extends React.Component {
136
+ constructor(props) {
137
+ super(props);
138
+ this.state = { hasError: false, error: null };
139
+ }
140
+ static getDerivedStateFromError(error) {
141
+ return { hasError: true, error };
142
+ }
143
+ render() {
144
+ if (this.state.hasError && this.state.error) {
145
+ return /* @__PURE__ */ jsxDEV("box", {
146
+ style: { flexDirection: "column", padding: 2 },
147
+ children: /* @__PURE__ */ jsxDEV("text", {
148
+ fg: "red",
149
+ children: this.state.error.stack || this.state.error.message
150
+ }, undefined, false, undefined, this)
151
+ }, undefined, false, undefined, this);
152
+ }
153
+ return this.props.children;
154
+ }
155
+ }
156
+
157
+ // src/reconciler/reconciler.ts
158
+ import ReactReconciler from "react-reconciler";
159
+ import { ConcurrentRoot } from "react-reconciler/constants";
160
+
161
+ // src/reconciler/host-config.ts
162
+ import { TextNodeRenderable as TextNodeRenderable2 } from "@opentui/core";
163
+ // package.json
164
+ var package_default = {
165
+ name: "@opentuah/react",
166
+ version: "0.1.77",
167
+ description: "React renderer for building terminal user interfaces using OpenTUI core",
168
+ license: "MIT",
169
+ repository: {
170
+ type: "git",
171
+ url: "https://github.com/anomalyco/opentui",
172
+ directory: "packages/react"
173
+ },
174
+ module: "src/index.ts",
175
+ type: "module",
176
+ private: true,
177
+ main: "src/index.ts",
178
+ exports: {
179
+ ".": {
180
+ import: "./src/index.ts",
181
+ types: "./src/index.ts"
182
+ },
183
+ "./test-utils": {
184
+ import: "./src/test-utils.ts",
185
+ types: "./src/test-utils.d.ts"
186
+ },
187
+ "./jsx-runtime": {
188
+ import: "./jsx-runtime.js",
189
+ types: "./jsx-runtime.d.ts"
190
+ },
191
+ "./jsx-dev-runtime": {
192
+ import: "./jsx-dev-runtime.js",
193
+ types: "./jsx-dev-runtime.d.ts"
194
+ }
195
+ },
196
+ scripts: {
197
+ build: "bun run scripts/build.ts",
198
+ "build:dev": "bun run scripts/build.ts --dev",
199
+ publish: "bun run scripts/publish.ts",
200
+ test: "bun test"
201
+ },
202
+ devDependencies: {
203
+ "@types/bun": "latest",
204
+ "@types/node": "^24.0.0",
205
+ "@types/react": "^19.0.0",
206
+ "@types/react-reconciler": "^0.32.0",
207
+ "@types/ws": "^8.18.1",
208
+ react: ">=19.0.0",
209
+ "react-devtools-core": "^7.0.1",
210
+ typescript: "^5",
211
+ ws: "^8.18.0"
212
+ },
213
+ peerDependencies: {
214
+ react: ">=19.0.0",
215
+ "react-devtools-core": "^7.0.1",
216
+ ws: "^8.18.0"
217
+ },
218
+ peerDependenciesMeta: {
219
+ "react-devtools-core": {
220
+ optional: true
221
+ },
222
+ ws: {
223
+ optional: true
224
+ }
225
+ },
226
+ dependencies: {
227
+ "@opentuah/core": "workspace:*",
228
+ "react-reconciler": "^0.32.0"
229
+ }
230
+ };
231
+
232
+ // src/reconciler/host-config.ts
233
+ import { createContext as createContext2 } from "react";
234
+ import { DefaultEventPriority, NoEventPriority } from "react-reconciler/constants";
235
+
236
+ // src/utils/id.ts
237
+ var idCounter = new Map;
238
+ function getNextId(type) {
239
+ if (!idCounter.has(type)) {
240
+ idCounter.set(type, 0);
241
+ }
242
+ const value = idCounter.get(type) + 1;
243
+ idCounter.set(type, value);
244
+ return `${type}-${value}`;
245
+ }
246
+
247
+ // src/utils/index.ts
248
+ import {
249
+ InputRenderable as InputRenderable2,
250
+ InputRenderableEvents,
251
+ isRenderable,
252
+ SelectRenderable as SelectRenderable2,
253
+ SelectRenderableEvents,
254
+ TabSelectRenderable as TabSelectRenderable2,
255
+ TabSelectRenderableEvents
256
+ } from "@opentui/core";
257
+ function initEventListeners(instance, eventName, listener, previousListener) {
258
+ if (previousListener) {
259
+ instance.off(eventName, previousListener);
260
+ }
261
+ if (listener) {
262
+ instance.on(eventName, listener);
263
+ }
264
+ }
265
+ function setStyle(instance, styles, oldStyles) {
266
+ if (oldStyles != null && typeof oldStyles === "object") {
267
+ for (const styleName in oldStyles) {
268
+ if (oldStyles.hasOwnProperty(styleName)) {
269
+ if (styles == null || !styles.hasOwnProperty(styleName)) {
270
+ instance[styleName] = null;
271
+ }
272
+ }
273
+ }
274
+ }
275
+ if (styles != null && typeof styles === "object") {
276
+ for (const styleName in styles) {
277
+ if (styles.hasOwnProperty(styleName)) {
278
+ const value = styles[styleName];
279
+ const oldValue = oldStyles?.[styleName];
280
+ if (value !== oldValue) {
281
+ instance[styleName] = value;
282
+ }
283
+ }
284
+ }
285
+ }
286
+ }
287
+ function setProperty(instance, type, propKey, propValue, oldPropValue) {
288
+ switch (propKey) {
289
+ case "onChange":
290
+ if (instance instanceof InputRenderable2) {
291
+ initEventListeners(instance, InputRenderableEvents.CHANGE, propValue, oldPropValue);
292
+ } else if (instance instanceof SelectRenderable2) {
293
+ initEventListeners(instance, SelectRenderableEvents.SELECTION_CHANGED, propValue, oldPropValue);
294
+ } else if (instance instanceof TabSelectRenderable2) {
295
+ initEventListeners(instance, TabSelectRenderableEvents.SELECTION_CHANGED, propValue, oldPropValue);
296
+ }
297
+ break;
298
+ case "onInput":
299
+ if (instance instanceof InputRenderable2) {
300
+ initEventListeners(instance, InputRenderableEvents.INPUT, propValue, oldPropValue);
301
+ }
302
+ break;
303
+ case "onSubmit":
304
+ if (instance instanceof InputRenderable2) {
305
+ initEventListeners(instance, InputRenderableEvents.ENTER, propValue, oldPropValue);
306
+ }
307
+ break;
308
+ case "onSelect":
309
+ if (instance instanceof SelectRenderable2) {
310
+ initEventListeners(instance, SelectRenderableEvents.ITEM_SELECTED, propValue, oldPropValue);
311
+ } else if (instance instanceof TabSelectRenderable2) {
312
+ initEventListeners(instance, TabSelectRenderableEvents.ITEM_SELECTED, propValue, oldPropValue);
313
+ }
314
+ break;
315
+ case "focused":
316
+ if (isRenderable(instance)) {
317
+ if (!!propValue) {
318
+ instance.focus();
319
+ } else {
320
+ instance.blur();
321
+ }
322
+ }
323
+ break;
324
+ case "style":
325
+ setStyle(instance, propValue, oldPropValue);
326
+ break;
327
+ case "children":
328
+ break;
329
+ default:
330
+ instance[propKey] = propValue;
331
+ }
332
+ }
333
+ function setInitialProperties(instance, type, props) {
334
+ for (const propKey in props) {
335
+ if (!props.hasOwnProperty(propKey)) {
336
+ continue;
337
+ }
338
+ const propValue = props[propKey];
339
+ if (propValue == null) {
340
+ continue;
341
+ }
342
+ setProperty(instance, type, propKey, propValue);
343
+ }
344
+ }
345
+ function updateProperties(instance, type, oldProps, newProps) {
346
+ for (const propKey in oldProps) {
347
+ const oldProp = oldProps[propKey];
348
+ if (oldProps.hasOwnProperty(propKey) && oldProp != null && !newProps.hasOwnProperty(propKey)) {
349
+ setProperty(instance, type, propKey, null, oldProp);
350
+ }
351
+ }
352
+ for (const propKey in newProps) {
353
+ const newProp = newProps[propKey];
354
+ const oldProp = oldProps[propKey];
355
+ if (newProps.hasOwnProperty(propKey) && newProp !== oldProp && (newProp != null || oldProp != null)) {
356
+ setProperty(instance, type, propKey, newProp, oldProp);
357
+ }
358
+ }
359
+ }
360
+
361
+ // src/reconciler/host-config.ts
362
+ var currentUpdatePriority = NoEventPriority;
363
+ var hostConfig = {
364
+ supportsMutation: true,
365
+ supportsPersistence: false,
366
+ supportsHydration: false,
367
+ createInstance(type, props, rootContainerInstance, hostContext) {
368
+ if (textNodeKeys.includes(type) && !hostContext.isInsideText) {
369
+ throw new Error(`Component of type "${type}" must be created inside of a text node`);
370
+ }
371
+ const id = getNextId(type);
372
+ const components = getComponentCatalogue();
373
+ if (!components[type]) {
374
+ throw new Error(`Unknown component type: ${type}`);
375
+ }
376
+ return new components[type](rootContainerInstance.ctx, {
377
+ id,
378
+ ...props
379
+ });
380
+ },
381
+ appendChild(parent, child) {
382
+ parent.add(child);
383
+ },
384
+ removeChild(parent, child) {
385
+ parent.remove(child.id);
386
+ },
387
+ insertBefore(parent, child, beforeChild) {
388
+ parent.insertBefore(child, beforeChild);
389
+ },
390
+ insertInContainerBefore(parent, child, beforeChild) {
391
+ parent.insertBefore(child, beforeChild);
392
+ },
393
+ removeChildFromContainer(parent, child) {
394
+ parent.remove(child.id);
395
+ },
396
+ prepareForCommit(containerInfo) {
397
+ return null;
398
+ },
399
+ resetAfterCommit(containerInfo) {
400
+ containerInfo.requestRender();
401
+ },
402
+ getRootHostContext(rootContainerInstance) {
403
+ return { isInsideText: false };
404
+ },
405
+ getChildHostContext(parentHostContext, type, rootContainerInstance) {
406
+ const isInsideText = ["text", ...textNodeKeys].includes(type);
407
+ return { ...parentHostContext, isInsideText };
408
+ },
409
+ shouldSetTextContent(type, props) {
410
+ return false;
411
+ },
412
+ createTextInstance(text, rootContainerInstance, hostContext) {
413
+ if (!hostContext.isInsideText) {
414
+ throw new Error("Text must be created inside of a text node");
415
+ }
416
+ return TextNodeRenderable2.fromString(text);
417
+ },
418
+ scheduleTimeout: setTimeout,
419
+ cancelTimeout: clearTimeout,
420
+ noTimeout: -1,
421
+ shouldAttemptEagerTransition() {
422
+ return false;
423
+ },
424
+ finalizeInitialChildren(instance, type, props, rootContainerInstance, hostContext) {
425
+ setInitialProperties(instance, type, props);
426
+ return false;
427
+ },
428
+ commitMount(instance, type, props, internalInstanceHandle) {},
429
+ commitUpdate(instance, type, oldProps, newProps, internalInstanceHandle) {
430
+ updateProperties(instance, type, oldProps, newProps);
431
+ instance.requestRender();
432
+ },
433
+ commitTextUpdate(textInstance, oldText, newText) {
434
+ textInstance.children = [newText];
435
+ textInstance.requestRender();
436
+ },
437
+ appendChildToContainer(container, child) {
438
+ container.add(child);
439
+ },
440
+ appendInitialChild(parent, child) {
441
+ parent.add(child);
442
+ },
443
+ hideInstance(instance) {
444
+ instance.visible = false;
445
+ instance.requestRender();
446
+ },
447
+ unhideInstance(instance, props) {
448
+ instance.visible = true;
449
+ instance.requestRender();
450
+ },
451
+ hideTextInstance(textInstance) {
452
+ textInstance.visible = false;
453
+ textInstance.requestRender();
454
+ },
455
+ unhideTextInstance(textInstance, text) {
456
+ textInstance.visible = true;
457
+ textInstance.requestRender();
458
+ },
459
+ clearContainer(container) {
460
+ const children = container.getChildren();
461
+ children.forEach((child) => container.remove(child.id));
462
+ },
463
+ setCurrentUpdatePriority(newPriority) {
464
+ currentUpdatePriority = newPriority;
465
+ },
466
+ getCurrentUpdatePriority: () => currentUpdatePriority,
467
+ resolveUpdatePriority() {
468
+ if (currentUpdatePriority !== NoEventPriority) {
469
+ return currentUpdatePriority;
470
+ }
471
+ return DefaultEventPriority;
472
+ },
473
+ maySuspendCommit() {
474
+ return false;
475
+ },
476
+ NotPendingTransition: null,
477
+ HostTransitionContext: createContext2(null),
478
+ resetFormInstance() {},
479
+ requestPostPaintCallback() {},
480
+ trackSchedulerEvent() {},
481
+ resolveEventType() {
482
+ return null;
483
+ },
484
+ resolveEventTimeStamp() {
485
+ return -1.1;
486
+ },
487
+ preloadInstance() {
488
+ return true;
489
+ },
490
+ startSuspendingCommit() {},
491
+ suspendInstance() {},
492
+ waitForCommitToBeReady() {
493
+ return null;
494
+ },
495
+ detachDeletedInstance(instance) {
496
+ if (!instance.parent) {
497
+ instance.destroyRecursively();
498
+ }
499
+ },
500
+ getPublicInstance(instance) {
501
+ return instance;
502
+ },
503
+ preparePortalMount(containerInfo) {},
504
+ isPrimaryRenderer: true,
505
+ getInstanceFromNode() {
506
+ return null;
507
+ },
508
+ beforeActiveInstanceBlur() {},
509
+ afterActiveInstanceBlur() {},
510
+ prepareScopeUpdate() {},
511
+ getInstanceFromScope() {
512
+ return null;
513
+ },
514
+ rendererPackageName: "@opentui/react",
515
+ rendererVersion: package_default.version
516
+ };
517
+
518
+ // src/reconciler/reconciler.ts
519
+ var reconciler = ReactReconciler(hostConfig);
520
+ if (process.env["DEV"] === "true") {
521
+ try {
522
+ await import("./chunk-pm1hna8x.js");
523
+ } catch (error) {
524
+ if (error.code === "ERR_MODULE_NOT_FOUND") {
525
+ console.warn(`
526
+ The environment variable DEV is set to true, so opentui tried to import \`react-devtools-core\`,
527
+ but this failed as it was not installed. Debugging with React DevTools requires it.
528
+
529
+ To install use this command:
530
+
531
+ $ bun add react-devtools-core@7 -d
532
+ `.trim() + `
533
+ `);
534
+ } else {
535
+ throw error;
536
+ }
537
+ }
538
+ }
539
+ reconciler.injectIntoDevTools();
540
+ function _render(element, root) {
541
+ const container = reconciler.createContainer(root, ConcurrentRoot, null, false, null, "", console.error, console.error, console.error, console.error, null);
542
+ reconciler.updateContainer(element, container, null, () => {});
543
+ return container;
544
+ }
545
+
546
+ // src/reconciler/renderer.ts
547
+ var _r = reconciler;
548
+ var flushSync = _r.flushSyncFromReconciler ?? _r.flushSync;
549
+ var { createPortal } = reconciler;
550
+ function createRoot(renderer) {
551
+ let container = null;
552
+ const cleanup = () => {
553
+ if (container) {
554
+ reconciler.updateContainer(null, container, null, () => {});
555
+ reconciler.flushSyncWork();
556
+ container = null;
557
+ }
558
+ };
559
+ renderer.once(CliRenderEvents.DESTROY, cleanup);
560
+ return {
561
+ render: (node) => {
562
+ engine.attach(renderer);
563
+ container = _render(React2.createElement(AppContext.Provider, { value: { keyHandler: renderer.keyInput, renderer } }, React2.createElement(ErrorBoundary, null, node)), renderer.root);
564
+ },
565
+ unmount: cleanup
566
+ };
567
+ }
568
+
569
+ export { baseComponents, componentCatalogue, extend, getComponentCatalogue, AppContext, useAppContext, flushSync, createPortal, createRoot };
@@ -0,0 +1,4 @@
1
+ // @bun
2
+ var __require = import.meta.require;
3
+
4
+ export { __require };
@@ -0,0 +1,28 @@
1
+ // @bun
2
+ import {
3
+ __require
4
+ } from "./chunk-eecw9x2f.js";
5
+
6
+ // src/reconciler/devtools-polyfill.ts
7
+ var g = globalThis;
8
+ if (typeof g.WebSocket === "undefined") {
9
+ try {
10
+ const ws = await import("ws");
11
+ g.WebSocket = ws.default;
12
+ } catch {}
13
+ }
14
+ g.window ||= globalThis;
15
+ g.self ||= globalThis;
16
+ g.window.__REACT_DEVTOOLS_COMPONENT_FILTERS__ = [
17
+ {
18
+ type: 2,
19
+ value: "ErrorBoundary",
20
+ isEnabled: true,
21
+ isValid: true
22
+ }
23
+ ];
24
+
25
+ // src/reconciler/devtools.ts
26
+ import devtools from "react-devtools-core";
27
+ devtools.initialize();
28
+ devtools.connectToDevTools();
package/index.js ADDED
@@ -0,0 +1,117 @@
1
+ // @bun
2
+ import {
3
+ AppContext,
4
+ baseComponents,
5
+ componentCatalogue,
6
+ createPortal,
7
+ createRoot,
8
+ extend,
9
+ flushSync,
10
+ getComponentCatalogue,
11
+ useAppContext
12
+ } from "./chunk-7627c4s7.js";
13
+ import"./chunk-eecw9x2f.js";
14
+ // src/hooks/use-keyboard.ts
15
+ import { useEffect } from "react";
16
+
17
+ // src/hooks/use-event.ts
18
+ import { useCallback, useLayoutEffect, useRef } from "react";
19
+ function useEffectEvent(handler) {
20
+ const handlerRef = useRef(handler);
21
+ useLayoutEffect(() => {
22
+ handlerRef.current = handler;
23
+ });
24
+ return useCallback((...args) => {
25
+ const fn = handlerRef.current;
26
+ return fn(...args);
27
+ }, []);
28
+ }
29
+
30
+ // src/hooks/use-keyboard.ts
31
+ var useKeyboard = (handler, options = { release: false }) => {
32
+ const { keyHandler } = useAppContext();
33
+ const stableHandler = useEffectEvent(handler);
34
+ useEffect(() => {
35
+ keyHandler?.on("keypress", stableHandler);
36
+ if (options?.release) {
37
+ keyHandler?.on("keyrelease", stableHandler);
38
+ }
39
+ return () => {
40
+ keyHandler?.off("keypress", stableHandler);
41
+ if (options?.release) {
42
+ keyHandler?.off("keyrelease", stableHandler);
43
+ }
44
+ };
45
+ }, [keyHandler, options.release]);
46
+ };
47
+ // src/hooks/use-renderer.ts
48
+ var useRenderer = () => {
49
+ const { renderer } = useAppContext();
50
+ if (!renderer) {
51
+ throw new Error("Renderer not found.");
52
+ }
53
+ return renderer;
54
+ };
55
+ // src/hooks/use-resize.ts
56
+ import { useEffect as useEffect2 } from "react";
57
+ var useOnResize = (callback) => {
58
+ const renderer = useRenderer();
59
+ const stableCallback = useEffectEvent(callback);
60
+ useEffect2(() => {
61
+ renderer.on("resize", stableCallback);
62
+ return () => {
63
+ renderer.off("resize", stableCallback);
64
+ };
65
+ }, [renderer]);
66
+ return renderer;
67
+ };
68
+ // src/hooks/use-terminal-dimensions.ts
69
+ import { useState } from "react";
70
+ var useTerminalDimensions = () => {
71
+ const renderer = useRenderer();
72
+ const [dimensions, setDimensions] = useState({
73
+ width: renderer.width,
74
+ height: renderer.height
75
+ });
76
+ const cb = (width, height) => {
77
+ setDimensions({ width, height });
78
+ };
79
+ useOnResize(cb);
80
+ return dimensions;
81
+ };
82
+ // src/hooks/use-timeline.ts
83
+ import { engine, Timeline } from "@opentui/core";
84
+ import { useEffect as useEffect3 } from "react";
85
+ var useTimeline = (options = {}) => {
86
+ const timeline = new Timeline(options);
87
+ useEffect3(() => {
88
+ if (!options.autoplay) {
89
+ timeline.play();
90
+ }
91
+ engine.register(timeline);
92
+ return () => {
93
+ timeline.pause();
94
+ engine.unregister(timeline);
95
+ };
96
+ }, []);
97
+ return timeline;
98
+ };
99
+ // src/index.ts
100
+ import { createElement } from "react";
101
+ export {
102
+ useTimeline,
103
+ useTerminalDimensions,
104
+ useRenderer,
105
+ useOnResize,
106
+ useKeyboard,
107
+ useAppContext,
108
+ getComponentCatalogue,
109
+ flushSync,
110
+ extend,
111
+ createRoot,
112
+ createPortal,
113
+ createElement,
114
+ componentCatalogue,
115
+ baseComponents,
116
+ AppContext
117
+ };