@opentui/react 0.1.74 → 0.1.75
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 +1 -1
- package/{src/reconciler/renderer.js → chunk-j5j59zk3.js} +120 -115
- package/index.js +11 -566
- package/jsx-namespace.d.ts +2 -0
- package/package.json +6 -6
- package/src/components/index.d.ts +2 -1
- package/src/test-utils.d.ts +1 -0
- package/src/types/components.d.ts +3 -2
- package/test-utils.js +39 -0
- package/src/reconciler/chunk-e11q5a3p.js +0 -20
- package/src/reconciler/chunk-fcedq94e.js +0 -29
- package/src/test-utils/chunk-e11q5a3p.js +0 -20
- package/src/test-utils/chunk-fcedq94e.js +0 -29
- package/src/test-utils/test-utils.js +0 -598
|
@@ -1,598 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import {
|
|
3
|
-
__require,
|
|
4
|
-
__toESM
|
|
5
|
-
} from "./chunk-e11q5a3p.js";
|
|
6
|
-
|
|
7
|
-
// src/test-utils.ts
|
|
8
|
-
import { createTestRenderer } from "@opentui/core/testing";
|
|
9
|
-
import { act } from "react";
|
|
10
|
-
|
|
11
|
-
// src/reconciler/renderer.ts
|
|
12
|
-
import { CliRenderEvents, engine } from "@opentui/core";
|
|
13
|
-
import React2 from "react";
|
|
14
|
-
|
|
15
|
-
// src/components/app.tsx
|
|
16
|
-
import { createContext, useContext } from "react";
|
|
17
|
-
var AppContext = createContext({
|
|
18
|
-
keyHandler: null,
|
|
19
|
-
renderer: null
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
// src/components/error-boundary.tsx
|
|
23
|
-
import React from "react";
|
|
24
|
-
|
|
25
|
-
// jsx-dev-runtime.js
|
|
26
|
-
import { Fragment, jsxDEV } from "react/jsx-dev-runtime";
|
|
27
|
-
|
|
28
|
-
// src/components/error-boundary.tsx
|
|
29
|
-
class ErrorBoundary extends React.Component {
|
|
30
|
-
constructor(props) {
|
|
31
|
-
super(props);
|
|
32
|
-
this.state = { hasError: false, error: null };
|
|
33
|
-
}
|
|
34
|
-
static getDerivedStateFromError(error) {
|
|
35
|
-
return { hasError: true, error };
|
|
36
|
-
}
|
|
37
|
-
render() {
|
|
38
|
-
if (this.state.hasError && this.state.error) {
|
|
39
|
-
return /* @__PURE__ */ jsxDEV("box", {
|
|
40
|
-
style: { flexDirection: "column", padding: 2 },
|
|
41
|
-
children: /* @__PURE__ */ jsxDEV("text", {
|
|
42
|
-
fg: "red",
|
|
43
|
-
children: this.state.error.stack || this.state.error.message
|
|
44
|
-
}, undefined, false, undefined, this)
|
|
45
|
-
}, undefined, false, undefined, this);
|
|
46
|
-
}
|
|
47
|
-
return this.props.children;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// src/reconciler/reconciler.ts
|
|
52
|
-
import ReactReconciler from "react-reconciler";
|
|
53
|
-
import { ConcurrentRoot } from "react-reconciler/constants";
|
|
54
|
-
|
|
55
|
-
// src/reconciler/host-config.ts
|
|
56
|
-
import { TextNodeRenderable as TextNodeRenderable2 } from "@opentui/core";
|
|
57
|
-
// package.json
|
|
58
|
-
var package_default = {
|
|
59
|
-
name: "@opentui/react",
|
|
60
|
-
version: "0.1.74",
|
|
61
|
-
description: "React renderer for building terminal user interfaces using OpenTUI core",
|
|
62
|
-
license: "MIT",
|
|
63
|
-
repository: {
|
|
64
|
-
type: "git",
|
|
65
|
-
url: "https://github.com/anomalyco/opentui",
|
|
66
|
-
directory: "packages/react"
|
|
67
|
-
},
|
|
68
|
-
module: "src/index.ts",
|
|
69
|
-
type: "module",
|
|
70
|
-
private: true,
|
|
71
|
-
main: "src/index.ts",
|
|
72
|
-
exports: {
|
|
73
|
-
".": {
|
|
74
|
-
import: "./src/index.ts",
|
|
75
|
-
types: "./src/index.ts"
|
|
76
|
-
},
|
|
77
|
-
"./test-utils": {
|
|
78
|
-
import: "./src/test-utils.ts",
|
|
79
|
-
types: "./src/test-utils.d.ts"
|
|
80
|
-
},
|
|
81
|
-
"./jsx-runtime": {
|
|
82
|
-
import: "./jsx-runtime.js",
|
|
83
|
-
types: "./jsx-runtime.d.ts"
|
|
84
|
-
},
|
|
85
|
-
"./jsx-dev-runtime": {
|
|
86
|
-
import: "./jsx-dev-runtime.js",
|
|
87
|
-
types: "./jsx-dev-runtime.d.ts"
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
scripts: {
|
|
91
|
-
build: "bun run scripts/build.ts",
|
|
92
|
-
"build:dev": "bun run scripts/build.ts --dev",
|
|
93
|
-
publish: "bun run scripts/publish.ts",
|
|
94
|
-
test: "bun test"
|
|
95
|
-
},
|
|
96
|
-
devDependencies: {
|
|
97
|
-
"@types/bun": "latest",
|
|
98
|
-
"@types/node": "^24.0.0",
|
|
99
|
-
"@types/react": "^19.0.0",
|
|
100
|
-
"@types/react-reconciler": "^0.32.0",
|
|
101
|
-
"@types/ws": "^8.18.1",
|
|
102
|
-
react: ">=19.0.0",
|
|
103
|
-
"react-devtools-core": "^7.0.1",
|
|
104
|
-
typescript: "^5",
|
|
105
|
-
ws: "^8.18.0"
|
|
106
|
-
},
|
|
107
|
-
peerDependencies: {
|
|
108
|
-
react: ">=19.0.0",
|
|
109
|
-
"react-devtools-core": "^7.0.1",
|
|
110
|
-
ws: "^8.18.0"
|
|
111
|
-
},
|
|
112
|
-
peerDependenciesMeta: {
|
|
113
|
-
"react-devtools-core": {
|
|
114
|
-
optional: true
|
|
115
|
-
},
|
|
116
|
-
ws: {
|
|
117
|
-
optional: true
|
|
118
|
-
}
|
|
119
|
-
},
|
|
120
|
-
dependencies: {
|
|
121
|
-
"@opentui/core": "workspace:*",
|
|
122
|
-
"react-reconciler": "^0.32.0"
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
// src/reconciler/host-config.ts
|
|
127
|
-
import { createContext as createContext2 } from "react";
|
|
128
|
-
import { DefaultEventPriority, NoEventPriority } from "react-reconciler/constants";
|
|
129
|
-
|
|
130
|
-
// src/components/index.ts
|
|
131
|
-
import {
|
|
132
|
-
ASCIIFontRenderable,
|
|
133
|
-
BoxRenderable,
|
|
134
|
-
CodeRenderable,
|
|
135
|
-
DiffRenderable,
|
|
136
|
-
InputRenderable,
|
|
137
|
-
LineNumberRenderable,
|
|
138
|
-
ScrollBoxRenderable,
|
|
139
|
-
SelectRenderable,
|
|
140
|
-
TabSelectRenderable,
|
|
141
|
-
TextareaRenderable,
|
|
142
|
-
TextRenderable
|
|
143
|
-
} from "@opentui/core";
|
|
144
|
-
|
|
145
|
-
// src/components/text.ts
|
|
146
|
-
import { TextAttributes, TextNodeRenderable } from "@opentui/core";
|
|
147
|
-
var textNodeKeys = ["span", "b", "strong", "i", "em", "u", "br", "a"];
|
|
148
|
-
|
|
149
|
-
class SpanRenderable extends TextNodeRenderable {
|
|
150
|
-
ctx;
|
|
151
|
-
constructor(ctx, options) {
|
|
152
|
-
super(options);
|
|
153
|
-
this.ctx = ctx;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
class TextModifierRenderable extends SpanRenderable {
|
|
158
|
-
constructor(options, modifier) {
|
|
159
|
-
super(null, options);
|
|
160
|
-
if (modifier === "b" || modifier === "strong") {
|
|
161
|
-
this.attributes = (this.attributes || 0) | TextAttributes.BOLD;
|
|
162
|
-
} else if (modifier === "i" || modifier === "em") {
|
|
163
|
-
this.attributes = (this.attributes || 0) | TextAttributes.ITALIC;
|
|
164
|
-
} else if (modifier === "u") {
|
|
165
|
-
this.attributes = (this.attributes || 0) | TextAttributes.UNDERLINE;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
class BoldSpanRenderable extends TextModifierRenderable {
|
|
171
|
-
constructor(_ctx, options) {
|
|
172
|
-
super(options, "b");
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
class ItalicSpanRenderable extends TextModifierRenderable {
|
|
177
|
-
constructor(_ctx, options) {
|
|
178
|
-
super(options, "i");
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
class UnderlineSpanRenderable extends TextModifierRenderable {
|
|
183
|
-
constructor(_ctx, options) {
|
|
184
|
-
super(options, "u");
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
class LineBreakRenderable extends SpanRenderable {
|
|
189
|
-
constructor(_ctx, options) {
|
|
190
|
-
super(null, options);
|
|
191
|
-
this.add();
|
|
192
|
-
}
|
|
193
|
-
add() {
|
|
194
|
-
return super.add(`
|
|
195
|
-
`);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
class LinkRenderable extends SpanRenderable {
|
|
200
|
-
constructor(_ctx, options) {
|
|
201
|
-
const linkOptions = {
|
|
202
|
-
...options,
|
|
203
|
-
link: { url: options.href }
|
|
204
|
-
};
|
|
205
|
-
super(null, linkOptions);
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
// src/components/index.ts
|
|
210
|
-
var baseComponents = {
|
|
211
|
-
box: BoxRenderable,
|
|
212
|
-
text: TextRenderable,
|
|
213
|
-
code: CodeRenderable,
|
|
214
|
-
diff: DiffRenderable,
|
|
215
|
-
input: InputRenderable,
|
|
216
|
-
select: SelectRenderable,
|
|
217
|
-
textarea: TextareaRenderable,
|
|
218
|
-
scrollbox: ScrollBoxRenderable,
|
|
219
|
-
"ascii-font": ASCIIFontRenderable,
|
|
220
|
-
"tab-select": TabSelectRenderable,
|
|
221
|
-
"line-number": LineNumberRenderable,
|
|
222
|
-
span: SpanRenderable,
|
|
223
|
-
br: LineBreakRenderable,
|
|
224
|
-
b: BoldSpanRenderable,
|
|
225
|
-
strong: BoldSpanRenderable,
|
|
226
|
-
i: ItalicSpanRenderable,
|
|
227
|
-
em: ItalicSpanRenderable,
|
|
228
|
-
u: UnderlineSpanRenderable,
|
|
229
|
-
a: LinkRenderable
|
|
230
|
-
};
|
|
231
|
-
var componentCatalogue = { ...baseComponents };
|
|
232
|
-
function getComponentCatalogue() {
|
|
233
|
-
return componentCatalogue;
|
|
234
|
-
}
|
|
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-fcedq94e.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
|
-
function createRoot(renderer) {
|
|
550
|
-
let container = null;
|
|
551
|
-
const cleanup = () => {
|
|
552
|
-
if (container) {
|
|
553
|
-
reconciler.updateContainer(null, container, null, () => {});
|
|
554
|
-
reconciler.flushSyncWork();
|
|
555
|
-
container = null;
|
|
556
|
-
}
|
|
557
|
-
};
|
|
558
|
-
renderer.once(CliRenderEvents.DESTROY, cleanup);
|
|
559
|
-
return {
|
|
560
|
-
render: (node) => {
|
|
561
|
-
engine.attach(renderer);
|
|
562
|
-
container = _render(React2.createElement(AppContext.Provider, { value: { keyHandler: renderer.keyInput, renderer } }, React2.createElement(ErrorBoundary, null, node)), renderer.root);
|
|
563
|
-
},
|
|
564
|
-
unmount: cleanup
|
|
565
|
-
};
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
// src/test-utils.ts
|
|
569
|
-
function setIsReactActEnvironment(isReactActEnvironment) {
|
|
570
|
-
globalThis.IS_REACT_ACT_ENVIRONMENT = isReactActEnvironment;
|
|
571
|
-
}
|
|
572
|
-
async function testRender(node, testRendererOptions) {
|
|
573
|
-
let root = null;
|
|
574
|
-
setIsReactActEnvironment(true);
|
|
575
|
-
const testSetup = await createTestRenderer({
|
|
576
|
-
...testRendererOptions,
|
|
577
|
-
onDestroy() {
|
|
578
|
-
act(() => {
|
|
579
|
-
if (root) {
|
|
580
|
-
root.unmount();
|
|
581
|
-
root = null;
|
|
582
|
-
}
|
|
583
|
-
});
|
|
584
|
-
testRendererOptions.onDestroy?.();
|
|
585
|
-
setIsReactActEnvironment(false);
|
|
586
|
-
}
|
|
587
|
-
});
|
|
588
|
-
root = createRoot(testSetup.renderer);
|
|
589
|
-
act(() => {
|
|
590
|
-
if (root) {
|
|
591
|
-
root.render(node);
|
|
592
|
-
}
|
|
593
|
-
});
|
|
594
|
-
return testSetup;
|
|
595
|
-
}
|
|
596
|
-
export {
|
|
597
|
-
testRender
|
|
598
|
-
};
|