@simonklee/opentui-tex 0.2.0 → 0.3.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 +8 -3
- package/dist/chunk-k9sn9j1p.js +119 -0
- package/dist/chunk-pgj24z8a.js +1434 -0
- package/dist/chunk-v0bahtg2.js +4 -0
- package/dist/index.js +5 -1373
- package/dist/math-graphemes.d.ts +1 -0
- package/dist/math-types.d.ts +1 -1
- package/dist/native.js +5 -4
- package/dist/react.js +8 -1488
- package/dist/solid.js +8 -1488
- package/dist/tex-renderable.d.ts +3 -1
- package/docs/native.md +14 -0
- package/docs/releasing.md +51 -11
- package/package.json +17 -12
package/README.md
CHANGED
|
@@ -96,9 +96,14 @@ Options beyond `BoxOptions`:
|
|
|
96
96
|
- `imageOptions`: options for the installed `ImageRenderable`.
|
|
97
97
|
- `onError`: receives backend errors.
|
|
98
98
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
Automatic width and height include borders and padding. Explicit dimensions
|
|
100
|
+
set the outer box size. Unicode output clips to the available cells without
|
|
101
|
+
wrapping mathematical rows.
|
|
102
|
+
|
|
103
|
+
When you assign `formula.formula`, `TexRenderable` installs synchronous Unicode
|
|
104
|
+
output. With the built-in Unicode backend, this is the final result. Other
|
|
105
|
+
backends run next; a native result replaces the preview with an image in the
|
|
106
|
+
same `TexRenderable`.
|
|
102
107
|
|
|
103
108
|
`formula.whenReady()` tracks replacement requests. It resolves after
|
|
104
109
|
`TexRenderable` installs the latest result. `formula.ready` exposes the
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TexRenderable
|
|
3
|
+
} from "./chunk-pgj24z8a.js";
|
|
4
|
+
|
|
5
|
+
// src/binding-tex-renderable.ts
|
|
6
|
+
var UNCONFIGURED_BACKEND = {
|
|
7
|
+
async render() {
|
|
8
|
+
throw new Error("TexRenderable requires a backend");
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
class BindingTexRenderable extends TexRenderable {
|
|
13
|
+
bindingFormula;
|
|
14
|
+
bindingStreaming;
|
|
15
|
+
bindingDisplay;
|
|
16
|
+
bindingForeground;
|
|
17
|
+
bindingBackground;
|
|
18
|
+
updateQueued = false;
|
|
19
|
+
constructor(context, options) {
|
|
20
|
+
const initial = options;
|
|
21
|
+
const foreground = initial.foreground ?? "";
|
|
22
|
+
const background = initial.background ?? "";
|
|
23
|
+
super(context, {
|
|
24
|
+
...options,
|
|
25
|
+
formula: initial.formula ?? "",
|
|
26
|
+
foreground,
|
|
27
|
+
background,
|
|
28
|
+
backend: initial.backend ?? UNCONFIGURED_BACKEND,
|
|
29
|
+
streaming: initial.streaming === true,
|
|
30
|
+
display: initial.display === true,
|
|
31
|
+
width: initial.width ?? undefined,
|
|
32
|
+
height: initial.height ?? undefined
|
|
33
|
+
});
|
|
34
|
+
this.bindingFormula = initial.formula ?? "";
|
|
35
|
+
this.bindingStreaming = initial.streaming === true;
|
|
36
|
+
this.bindingDisplay = initial.display === true;
|
|
37
|
+
this.bindingForeground = foreground;
|
|
38
|
+
this.bindingBackground = background;
|
|
39
|
+
}
|
|
40
|
+
get formula() {
|
|
41
|
+
return this.bindingFormula;
|
|
42
|
+
}
|
|
43
|
+
set formula(value) {
|
|
44
|
+
const formula = typeof value === "string" ? value : "";
|
|
45
|
+
if (formula === this.formula)
|
|
46
|
+
return;
|
|
47
|
+
this.bindingFormula = formula;
|
|
48
|
+
this.queueUpdate();
|
|
49
|
+
}
|
|
50
|
+
get streaming() {
|
|
51
|
+
return this.bindingStreaming;
|
|
52
|
+
}
|
|
53
|
+
set streaming(value) {
|
|
54
|
+
const streaming = value === true;
|
|
55
|
+
if (streaming === this.streaming)
|
|
56
|
+
return;
|
|
57
|
+
this.bindingStreaming = streaming;
|
|
58
|
+
this.queueUpdate();
|
|
59
|
+
}
|
|
60
|
+
get display() {
|
|
61
|
+
return this.bindingDisplay;
|
|
62
|
+
}
|
|
63
|
+
set display(value) {
|
|
64
|
+
const display = value === true;
|
|
65
|
+
if (display === this.display)
|
|
66
|
+
return;
|
|
67
|
+
this.bindingDisplay = display;
|
|
68
|
+
this.queueUpdate();
|
|
69
|
+
}
|
|
70
|
+
get foreground() {
|
|
71
|
+
return this.bindingForeground;
|
|
72
|
+
}
|
|
73
|
+
set foreground(value) {
|
|
74
|
+
const foreground = typeof value === "string" ? value : "";
|
|
75
|
+
if (foreground === this.bindingForeground)
|
|
76
|
+
return;
|
|
77
|
+
this.bindingForeground = foreground;
|
|
78
|
+
this.queueUpdate();
|
|
79
|
+
}
|
|
80
|
+
get background() {
|
|
81
|
+
return this.bindingBackground;
|
|
82
|
+
}
|
|
83
|
+
set background(value) {
|
|
84
|
+
const background = typeof value === "string" ? value : "";
|
|
85
|
+
if (background === this.bindingBackground)
|
|
86
|
+
return;
|
|
87
|
+
this.bindingBackground = background;
|
|
88
|
+
this.queueUpdate();
|
|
89
|
+
}
|
|
90
|
+
setColors(foreground, background) {
|
|
91
|
+
this.bindingForeground = foreground;
|
|
92
|
+
this.bindingBackground = background;
|
|
93
|
+
super.setColors(foreground, background);
|
|
94
|
+
}
|
|
95
|
+
queueUpdate() {
|
|
96
|
+
if (this.updateQueued)
|
|
97
|
+
return;
|
|
98
|
+
this.updateQueued = true;
|
|
99
|
+
let queued;
|
|
100
|
+
queued = Promise.resolve().then(() => {
|
|
101
|
+
this.flushUpdate();
|
|
102
|
+
if (this.ready !== queued)
|
|
103
|
+
return this.ready;
|
|
104
|
+
});
|
|
105
|
+
this.ready = queued;
|
|
106
|
+
}
|
|
107
|
+
flushUpdate() {
|
|
108
|
+
this.updateQueued = false;
|
|
109
|
+
if (this.isDestroyed)
|
|
110
|
+
return;
|
|
111
|
+
if (this.bindingStreaming && !super.streaming)
|
|
112
|
+
super.streaming = true;
|
|
113
|
+
this.setSnapshot(this.bindingFormula, this.bindingForeground, this.bindingBackground, this.bindingDisplay);
|
|
114
|
+
if (!this.bindingStreaming && super.streaming)
|
|
115
|
+
super.streaming = false;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export { BindingTexRenderable };
|