@simonklee/opentui-tex 0.2.0 → 0.3.1
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 +93 -47
- package/dist/backend.d.ts +6 -0
- package/dist/chunk-gbwc618x.js +1797 -0
- package/dist/chunk-qz8qag2e.js +119 -0
- package/dist/chunk-v0bahtg2.js +4 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -1373
- package/dist/math-graphemes.d.ts +1 -0
- package/dist/math-layout.d.ts +5 -1
- package/dist/math-parser.d.ts +5 -2
- package/dist/math-types.d.ts +26 -2
- package/dist/native.js +5 -4
- package/dist/react.js +8 -1488
- package/dist/solid.js +8 -1488
- package/dist/tex-renderable.d.ts +5 -1
- package/docs/native.md +14 -0
- package/docs/releasing.md +51 -11
- package/package.json +17 -12
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TexRenderable
|
|
3
|
+
} from "./chunk-gbwc618x.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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { TexBackend, TexRenderOutput, TexRenderRequest, } from "./backend.js";
|
|
1
|
+
export type { TexBackend, TexRenderOutput, TexRenderRequest, TexTextSpan, } from "./backend.js";
|
|
2
2
|
export { measureTex, TexRenderable } from "./tex-renderable.js";
|
|
3
3
|
export type { TexDimensions, TexFallback, TexRenderableOptions } from "./tex-renderable.js";
|
|
4
4
|
export { UnicodeTexBackend } from "./unicode-tex-backend.js";
|