@opentui/react 0.1.74 → 0.1.76

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 CHANGED
@@ -985,7 +985,7 @@ bun add --dev react-devtools-core@7
985
985
  2. Start the standalone React DevTools:
986
986
 
987
987
  ```bash
988
- npx npx react-devtools@7
988
+ npx react-devtools@7
989
989
  ```
990
990
 
991
991
  3. Run your app with the `DEV` environment variable:
@@ -0,0 +1,4 @@
1
+ // @bun
2
+ var __require = import.meta.require;
3
+
4
+ export { __require };
@@ -1,12 +1,118 @@
1
1
  // @bun
2
2
  import {
3
- __require,
4
- __toESM
5
- } from "./chunk-e11q5a3p.js";
3
+ __require
4
+ } from "./chunk-eecw9x2f.js";
6
5
 
7
- // src/reconciler/renderer.ts
8
- import { CliRenderEvents, engine } from "@opentui/core";
9
- import React2 from "react";
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
+ }
10
116
 
11
117
  // src/components/app.tsx
12
118
  import { createContext, useContext } from "react";
@@ -14,6 +120,13 @@ var AppContext = createContext({
14
120
  keyHandler: null,
15
121
  renderer: null
16
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";
17
130
 
18
131
  // src/components/error-boundary.tsx
19
132
  import React from "react";
@@ -53,7 +166,7 @@ import { TextNodeRenderable as TextNodeRenderable2 } from "@opentui/core";
53
166
  // package.json
54
167
  var package_default = {
55
168
  name: "@opentui/react",
56
- version: "0.1.74",
169
+ version: "0.1.76",
57
170
  description: "React renderer for building terminal user interfaces using OpenTUI core",
58
171
  license: "MIT",
59
172
  repository: {
@@ -123,112 +236,6 @@ var package_default = {
123
236
  import { createContext as createContext2 } from "react";
124
237
  import { DefaultEventPriority, NoEventPriority } from "react-reconciler/constants";
125
238
 
126
- // src/components/index.ts
127
- import {
128
- ASCIIFontRenderable,
129
- BoxRenderable,
130
- CodeRenderable,
131
- DiffRenderable,
132
- InputRenderable,
133
- LineNumberRenderable,
134
- ScrollBoxRenderable,
135
- SelectRenderable,
136
- TabSelectRenderable,
137
- TextareaRenderable,
138
- TextRenderable
139
- } from "@opentui/core";
140
-
141
- // src/components/text.ts
142
- import { TextAttributes, TextNodeRenderable } from "@opentui/core";
143
- var textNodeKeys = ["span", "b", "strong", "i", "em", "u", "br", "a"];
144
-
145
- class SpanRenderable extends TextNodeRenderable {
146
- ctx;
147
- constructor(ctx, options) {
148
- super(options);
149
- this.ctx = ctx;
150
- }
151
- }
152
-
153
- class TextModifierRenderable extends SpanRenderable {
154
- constructor(options, modifier) {
155
- super(null, options);
156
- if (modifier === "b" || modifier === "strong") {
157
- this.attributes = (this.attributes || 0) | TextAttributes.BOLD;
158
- } else if (modifier === "i" || modifier === "em") {
159
- this.attributes = (this.attributes || 0) | TextAttributes.ITALIC;
160
- } else if (modifier === "u") {
161
- this.attributes = (this.attributes || 0) | TextAttributes.UNDERLINE;
162
- }
163
- }
164
- }
165
-
166
- class BoldSpanRenderable extends TextModifierRenderable {
167
- constructor(_ctx, options) {
168
- super(options, "b");
169
- }
170
- }
171
-
172
- class ItalicSpanRenderable extends TextModifierRenderable {
173
- constructor(_ctx, options) {
174
- super(options, "i");
175
- }
176
- }
177
-
178
- class UnderlineSpanRenderable extends TextModifierRenderable {
179
- constructor(_ctx, options) {
180
- super(options, "u");
181
- }
182
- }
183
-
184
- class LineBreakRenderable extends SpanRenderable {
185
- constructor(_ctx, options) {
186
- super(null, options);
187
- this.add();
188
- }
189
- add() {
190
- return super.add(`
191
- `);
192
- }
193
- }
194
-
195
- class LinkRenderable extends SpanRenderable {
196
- constructor(_ctx, options) {
197
- const linkOptions = {
198
- ...options,
199
- link: { url: options.href }
200
- };
201
- super(null, linkOptions);
202
- }
203
- }
204
-
205
- // src/components/index.ts
206
- var baseComponents = {
207
- box: BoxRenderable,
208
- text: TextRenderable,
209
- code: CodeRenderable,
210
- diff: DiffRenderable,
211
- input: InputRenderable,
212
- select: SelectRenderable,
213
- textarea: TextareaRenderable,
214
- scrollbox: ScrollBoxRenderable,
215
- "ascii-font": ASCIIFontRenderable,
216
- "tab-select": TabSelectRenderable,
217
- "line-number": LineNumberRenderable,
218
- span: SpanRenderable,
219
- br: LineBreakRenderable,
220
- b: BoldSpanRenderable,
221
- strong: BoldSpanRenderable,
222
- i: ItalicSpanRenderable,
223
- em: ItalicSpanRenderable,
224
- u: UnderlineSpanRenderable,
225
- a: LinkRenderable
226
- };
227
- var componentCatalogue = { ...baseComponents };
228
- function getComponentCatalogue() {
229
- return componentCatalogue;
230
- }
231
-
232
239
  // src/utils/id.ts
233
240
  var idCounter = new Map;
234
241
  function getNextId(type) {
@@ -515,7 +522,7 @@ var hostConfig = {
515
522
  var reconciler = ReactReconciler(hostConfig);
516
523
  if (process.env["DEV"] === "true") {
517
524
  try {
518
- await import("./chunk-fcedq94e.js");
525
+ await import("./chunk-pm1hna8x.js");
519
526
  } catch (error) {
520
527
  if (error.code === "ERR_MODULE_NOT_FOUND") {
521
528
  console.warn(`
@@ -561,8 +568,5 @@ function createRoot(renderer) {
561
568
  unmount: cleanup
562
569
  };
563
570
  }
564
- export {
565
- flushSync,
566
- createRoot,
567
- createPortal
568
- };
571
+
572
+ export { baseComponents, componentCatalogue, extend, getComponentCatalogue, AppContext, useAppContext, flushSync, createPortal, createRoot };
@@ -1,8 +1,7 @@
1
1
  // @bun
2
2
  import {
3
- __require,
4
- __toESM
5
- } from "./chunk-e11q5a3p.js";
3
+ __require
4
+ } from "./chunk-eecw9x2f.js";
6
5
 
7
6
  // src/reconciler/devtools-polyfill.ts
8
7
  var g = globalThis;