velo-plot 1.19.0 → 2.20.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/dist/{ChartCore-DQ691eXH.js → ChartCore-ivzLqxVb.js} +1376 -1153
- package/dist/ChartCore-ivzLqxVb.js.map +1 -0
- package/dist/SciPlot-CEU4ApgD.js +463 -0
- package/dist/SciPlot-CEU4ApgD.js.map +1 -0
- package/dist/axisFormat-CzumxpCL.js +200 -0
- package/dist/axisFormat-CzumxpCL.js.map +1 -0
- package/dist/core/InteractionManager.d.ts +1 -0
- package/dist/core/OverlayRenderer.d.ts +11 -0
- package/dist/core/chart/ChartAxisManager.d.ts +2 -0
- package/dist/core/chart/ChartCore.d.ts +20 -0
- package/dist/core/chart/ChartPluginBridge.d.ts +1 -0
- package/dist/core/chart/ChartRenderLoop.d.ts +7 -0
- package/dist/core/chart/ChartRenderer.d.ts +5 -0
- package/dist/core/chart/ChartStateManager.d.ts +2 -0
- package/dist/core/chart/positionLines.d.ts +12 -0
- package/dist/core/chart/types.d.ts +7 -0
- package/dist/core/format/axisFormat.d.ts +2 -1
- package/dist/core/indicator/addIndicator.d.ts +1 -1
- package/dist/core/indicator/indicatorPresets.d.ts +10 -2
- package/dist/core/sync/index.d.ts +0 -1
- package/dist/core/time/TimeScale.d.ts +2 -2
- package/dist/core/time/applyTimeScale.d.ts +10 -0
- package/dist/createStackedChart-DxNW0VkF.js +705 -0
- package/dist/createStackedChart-DxNW0VkF.js.map +1 -0
- package/dist/{index-D7dTq6VB.js → index-BBpJwOct.js} +17 -19
- package/dist/index-BBpJwOct.js.map +1 -0
- package/dist/{index-CUGS98p4.js → index-CaXWSOTk.js} +3 -6
- package/dist/index-CaXWSOTk.js.map +1 -0
- package/dist/{index-DjeWClO9.js → index-qunX30Xu.js} +2 -2
- package/dist/{index-DjeWClO9.js.map → index-qunX30Xu.js.map} +1 -1
- package/dist/{index.core-BtGFYMOu.js → index.core-COREBDNq.js} +25 -24
- package/dist/{index.core-BtGFYMOu.js.map → index.core-COREBDNq.js.map} +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/mockDatafeed-927foCM4.js +511 -0
- package/dist/mockDatafeed-927foCM4.js.map +1 -0
- package/dist/plugins/analysis/contours.d.ts +31 -0
- package/dist/plugins/analysis.js +494 -407
- package/dist/plugins/analysis.js.map +1 -1
- package/dist/plugins/broken-axis.js +170 -181
- package/dist/plugins/broken-axis.js.map +1 -1
- package/dist/plugins/drawing-tools/index.d.ts +14 -1
- package/dist/plugins/drawing-tools/measure.d.ts +21 -0
- package/dist/plugins/drawing-tools/snapToCandle.d.ts +21 -0
- package/dist/plugins/forecasting/algorithms.d.ts +7 -2
- package/dist/plugins/forecasting/types.d.ts +13 -3
- package/dist/plugins/forecasting.js +355 -175
- package/dist/plugins/forecasting.js.map +1 -1
- package/dist/plugins/latex/symbols.d.ts +50 -0
- package/dist/plugins/latex/types.d.ts +13 -1
- package/dist/plugins/latex.js +351 -331
- package/dist/plugins/latex.js.map +1 -1
- package/dist/plugins/ml-integration/native-algorithms.d.ts +24 -4
- package/dist/plugins/ml-integration/types.d.ts +19 -0
- package/dist/plugins/ml-integration.js +191 -140
- package/dist/plugins/ml-integration.js.map +1 -1
- package/dist/plugins/pattern-recognition/types.d.ts +28 -1
- package/dist/plugins/pattern-recognition.js +416 -343
- package/dist/plugins/pattern-recognition.js.map +1 -1
- package/dist/plugins/snapshot.js +36 -36
- package/dist/plugins/snapshot.js.map +1 -1
- package/dist/plugins/sync.js +1 -1
- package/dist/plugins/tools.js +1 -1
- package/dist/plugins/virtualization.js +1 -1
- package/dist/react.js +5 -5
- package/dist/symbols-DT0eLlpW.js +568 -0
- package/dist/symbols-DT0eLlpW.js.map +1 -0
- package/dist/trading/datafeed.d.ts +48 -0
- package/dist/trading/index.d.ts +29 -0
- package/dist/trading/mockDatafeed.d.ts +9 -0
- package/dist/trading/ohlcvGenerator.d.ts +25 -0
- package/dist/trading.d.ts +1 -0
- package/dist/trading.js +95 -0
- package/dist/trading.js.map +1 -0
- package/dist/types.d.ts +1 -1
- package/dist/velo-plot.full.js +835 -1054
- package/dist/velo-plot.full.js.map +1 -1
- package/dist/velo-plot.js +13 -13
- package/dist/workers/indicatorsAsync.d.ts +24 -0
- package/package.json +13 -1
- package/dist/ChartCore-DQ691eXH.js.map +0 -1
- package/dist/axisFormat-B7o_uIEA.js +0 -127
- package/dist/axisFormat-B7o_uIEA.js.map +0 -1
- package/dist/createStackedChart-BPooTQ9z.js +0 -1164
- package/dist/createStackedChart-BPooTQ9z.js.map +0 -1
- package/dist/index-CUGS98p4.js.map +0 -1
- package/dist/index-D7dTq6VB.js.map +0 -1
package/dist/plugins/latex.js
CHANGED
|
@@ -1,431 +1,450 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
theta: "θ",
|
|
10
|
-
iota: "ι",
|
|
11
|
-
kappa: "κ",
|
|
12
|
-
lambda: "λ",
|
|
13
|
-
mu: "μ",
|
|
14
|
-
nu: "ν",
|
|
15
|
-
xi: "ξ",
|
|
16
|
-
omicron: "ο",
|
|
17
|
-
pi: "π",
|
|
18
|
-
rho: "ρ",
|
|
19
|
-
sigma: "σ",
|
|
20
|
-
tau: "τ",
|
|
21
|
-
upsilon: "υ",
|
|
22
|
-
phi: "φ",
|
|
23
|
-
chi: "χ",
|
|
24
|
-
psi: "ψ",
|
|
25
|
-
omega: "ω"
|
|
26
|
-
}, x = {
|
|
27
|
-
Alpha: "Α",
|
|
28
|
-
Beta: "Β",
|
|
29
|
-
Gamma: "Γ",
|
|
30
|
-
Delta: "Δ",
|
|
31
|
-
Epsilon: "Ε",
|
|
32
|
-
Zeta: "Ζ",
|
|
33
|
-
Eta: "Η",
|
|
34
|
-
Theta: "Θ",
|
|
35
|
-
Iota: "Ι",
|
|
36
|
-
Kappa: "Κ",
|
|
37
|
-
Lambda: "Λ",
|
|
38
|
-
Mu: "Μ",
|
|
39
|
-
Nu: "Ν",
|
|
40
|
-
Xi: "Ξ",
|
|
41
|
-
Omicron: "Ο",
|
|
42
|
-
Pi: "Π",
|
|
43
|
-
Rho: "Ρ",
|
|
44
|
-
Sigma: "Σ",
|
|
45
|
-
Tau: "Τ",
|
|
46
|
-
Upsilon: "Υ",
|
|
47
|
-
Phi: "Φ",
|
|
48
|
-
Chi: "Χ",
|
|
49
|
-
Psi: "Ψ",
|
|
50
|
-
Omega: "Ω"
|
|
1
|
+
import { F as W, C as E, B as H, i as _, g as D } from "../symbols-DT0eLlpW.js";
|
|
2
|
+
const $ = {
|
|
3
|
+
matrix: ["", ""],
|
|
4
|
+
pmatrix: ["(", ")"],
|
|
5
|
+
bmatrix: ["[", "]"],
|
|
6
|
+
Bmatrix: ["{", "}"],
|
|
7
|
+
vmatrix: ["|", "|"],
|
|
8
|
+
Vmatrix: ["‖", "‖"]
|
|
51
9
|
}, F = {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
oint: "∮",
|
|
56
|
-
partial: "∂",
|
|
57
|
-
nabla: "∇",
|
|
58
|
-
infty: "∞",
|
|
59
|
-
hbar: "ℏ",
|
|
60
|
-
pm: "±",
|
|
61
|
-
mp: "∓",
|
|
62
|
-
times: "×",
|
|
63
|
-
div: "÷",
|
|
64
|
-
cdot: "·",
|
|
65
|
-
ast: "∗",
|
|
66
|
-
star: "⋆",
|
|
67
|
-
circ: "∘",
|
|
68
|
-
bullet: "•",
|
|
69
|
-
cap: "∩",
|
|
70
|
-
cup: "∪",
|
|
71
|
-
vee: "∨",
|
|
72
|
-
wedge: "∧",
|
|
73
|
-
oplus: "⊕",
|
|
74
|
-
otimes: "⊗",
|
|
75
|
-
equiv: "≡",
|
|
76
|
-
cong: "≅",
|
|
77
|
-
approx: "≈",
|
|
78
|
-
propto: "∝",
|
|
79
|
-
neq: "≠",
|
|
80
|
-
leq: "≤",
|
|
81
|
-
geq: "≥",
|
|
82
|
-
ll: "≪",
|
|
83
|
-
gg: "≫",
|
|
84
|
-
subset: "⊂",
|
|
85
|
-
supset: "⊃",
|
|
86
|
-
subseteq: "⊆",
|
|
87
|
-
supseteq: "⊇",
|
|
88
|
-
in: "∈",
|
|
89
|
-
notin: "∉",
|
|
90
|
-
ni: "∋",
|
|
91
|
-
forall: "∀",
|
|
92
|
-
exists: "∃",
|
|
93
|
-
emptyset: "∅",
|
|
94
|
-
neg: "¬",
|
|
95
|
-
angle: "∠",
|
|
96
|
-
perp: "⊥",
|
|
97
|
-
parallel: "∥",
|
|
98
|
-
rightarrow: "→",
|
|
99
|
-
leftarrow: "←",
|
|
100
|
-
leftrightarrow: "↔",
|
|
101
|
-
Rightarrow: "⇒",
|
|
102
|
-
Leftarrow: "⇐",
|
|
103
|
-
Leftrightarrow: "⇔",
|
|
104
|
-
mapsto: "↦",
|
|
105
|
-
to: "→",
|
|
106
|
-
langle: "⟨",
|
|
107
|
-
rangle: "⟩",
|
|
108
|
-
rightleftharpoons: "⇌",
|
|
109
|
-
log: "log",
|
|
110
|
-
ln: "ln",
|
|
111
|
-
sin: "sin",
|
|
112
|
-
cos: "cos",
|
|
113
|
-
tan: "tan"
|
|
114
|
-
}, E = {
|
|
115
|
-
...L,
|
|
116
|
-
...x,
|
|
117
|
-
...F
|
|
10
|
+
mathbb: H,
|
|
11
|
+
mathcal: E,
|
|
12
|
+
mathfrak: W
|
|
118
13
|
};
|
|
119
|
-
function
|
|
120
|
-
|
|
14
|
+
function P(s) {
|
|
15
|
+
const t = N(s);
|
|
16
|
+
return M(t);
|
|
121
17
|
}
|
|
122
|
-
function
|
|
123
|
-
|
|
18
|
+
function v(s) {
|
|
19
|
+
let t = "";
|
|
20
|
+
for (const e of s)
|
|
21
|
+
e.type === "text" || e.type === "textgroup" || e.type === "symbol" ? t += e.content || "" : e.children && (t += v(e.children));
|
|
22
|
+
return t;
|
|
124
23
|
}
|
|
125
|
-
function
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
for (const t of n)
|
|
132
|
-
t.type === "text" || t.type === "textgroup" || t.type === "symbol" ? e += t.content || "" : t.children && (e += M(t.children));
|
|
133
|
-
return e;
|
|
134
|
-
}
|
|
135
|
-
function D(n) {
|
|
136
|
-
const e = [];
|
|
137
|
-
let t = 0;
|
|
138
|
-
for (; t < n.length; ) {
|
|
139
|
-
const s = n[t];
|
|
140
|
-
if (s === "\\") {
|
|
24
|
+
function N(s) {
|
|
25
|
+
const t = [];
|
|
26
|
+
let e = 0;
|
|
27
|
+
for (; e < s.length; ) {
|
|
28
|
+
const n = s[e];
|
|
29
|
+
if (n === "\\") {
|
|
141
30
|
let i = "";
|
|
142
|
-
for (
|
|
143
|
-
i +=
|
|
144
|
-
i ?
|
|
145
|
-
} else if (
|
|
146
|
-
|
|
147
|
-
else if (/\s/.test(
|
|
148
|
-
for (
|
|
149
|
-
|
|
31
|
+
for (e++; e < s.length && /[a-zA-Z]/.test(s[e]); )
|
|
32
|
+
i += s[e], e++;
|
|
33
|
+
i ? t.push("\\" + i) : e < s.length && (t.push("\\" + s[e]), e++);
|
|
34
|
+
} else if (n === "{" || n === "}" || n === "^" || n === "_")
|
|
35
|
+
t.push(n), e++;
|
|
36
|
+
else if (/\s/.test(n))
|
|
37
|
+
for (t.push(" "), e++; e < s.length && /\s/.test(s[e]); )
|
|
38
|
+
e++;
|
|
150
39
|
else
|
|
151
|
-
|
|
40
|
+
t.push(n), e++;
|
|
152
41
|
}
|
|
153
|
-
return
|
|
42
|
+
return t;
|
|
154
43
|
}
|
|
155
|
-
function
|
|
156
|
-
const
|
|
157
|
-
let
|
|
158
|
-
for (;
|
|
159
|
-
const
|
|
160
|
-
if (
|
|
161
|
-
|
|
162
|
-
const i =
|
|
163
|
-
|
|
44
|
+
function M(s) {
|
|
45
|
+
const t = [];
|
|
46
|
+
let e = 0;
|
|
47
|
+
for (; e < s.length; ) {
|
|
48
|
+
const n = s[e];
|
|
49
|
+
if (n === "^") {
|
|
50
|
+
e++;
|
|
51
|
+
const i = w(s, e);
|
|
52
|
+
t.push({
|
|
164
53
|
type: "superscript",
|
|
165
54
|
children: i.nodes
|
|
166
|
-
}),
|
|
167
|
-
} else if (
|
|
168
|
-
|
|
169
|
-
const i =
|
|
170
|
-
|
|
55
|
+
}), e = i.nextIndex;
|
|
56
|
+
} else if (n === "_") {
|
|
57
|
+
e++;
|
|
58
|
+
const i = w(s, e);
|
|
59
|
+
t.push({
|
|
171
60
|
type: "subscript",
|
|
172
61
|
children: i.nodes
|
|
173
|
-
}),
|
|
174
|
-
} else if (
|
|
175
|
-
const i =
|
|
62
|
+
}), e = i.nextIndex;
|
|
63
|
+
} else if (n.startsWith("\\")) {
|
|
64
|
+
const i = n.substring(1);
|
|
176
65
|
if (i === "frac") {
|
|
177
|
-
|
|
178
|
-
const o =
|
|
179
|
-
|
|
180
|
-
const
|
|
181
|
-
|
|
66
|
+
e++;
|
|
67
|
+
const o = w(s, e);
|
|
68
|
+
e = o.nextIndex;
|
|
69
|
+
const l = w(s, e);
|
|
70
|
+
e = l.nextIndex, t.push({
|
|
182
71
|
type: "fraction",
|
|
183
72
|
numerator: o.nodes,
|
|
184
|
-
denominator:
|
|
73
|
+
denominator: l.nodes
|
|
185
74
|
});
|
|
186
75
|
} else if (i === "sqrt") {
|
|
187
|
-
|
|
188
|
-
const o =
|
|
189
|
-
|
|
76
|
+
e++;
|
|
77
|
+
const o = w(s, e);
|
|
78
|
+
t.push({
|
|
190
79
|
type: "sqrt",
|
|
191
80
|
children: o.nodes
|
|
192
|
-
}),
|
|
193
|
-
} else if (i === "text") {
|
|
194
|
-
|
|
195
|
-
const o =
|
|
196
|
-
|
|
81
|
+
}), e = o.nextIndex;
|
|
82
|
+
} else if (i === "text" || i === "mathrm" || i === "mathbf" || i === "mathit" || i === "operatorname") {
|
|
83
|
+
e++;
|
|
84
|
+
const o = w(s, e), l = v(o.nodes);
|
|
85
|
+
t.push({
|
|
197
86
|
type: "textgroup",
|
|
198
|
-
content:
|
|
199
|
-
}),
|
|
200
|
-
} else
|
|
87
|
+
content: l
|
|
88
|
+
}), e = o.nextIndex;
|
|
89
|
+
} else if (i in F) {
|
|
90
|
+
e++;
|
|
91
|
+
const o = w(s, e);
|
|
92
|
+
e = o.nextIndex;
|
|
93
|
+
const l = F[i], r = v(o.nodes);
|
|
94
|
+
let c = "";
|
|
95
|
+
for (const f of r) c += l[f] ?? f;
|
|
96
|
+
t.push({ type: "text", content: c });
|
|
97
|
+
} else i === "begin" ? e = Y(s, e, t) : _(i) ? (t.push({
|
|
201
98
|
type: "symbol",
|
|
202
|
-
content:
|
|
203
|
-
}),
|
|
99
|
+
content: D(i)
|
|
100
|
+
}), e++) : i === "times" || i === "cdot" || i === "pm" || i === "mp" ? (t.push({
|
|
204
101
|
type: "symbol",
|
|
205
|
-
content:
|
|
206
|
-
}),
|
|
102
|
+
content: D(i)
|
|
103
|
+
}), e++) : (t.push({
|
|
207
104
|
type: "text",
|
|
208
|
-
content:
|
|
209
|
-
}),
|
|
210
|
-
} else if (
|
|
211
|
-
const i =
|
|
212
|
-
|
|
105
|
+
content: n
|
|
106
|
+
}), e++);
|
|
107
|
+
} else if (n === "{") {
|
|
108
|
+
const i = w(s, e);
|
|
109
|
+
t.push({
|
|
213
110
|
type: "group",
|
|
214
111
|
children: i.nodes
|
|
215
|
-
}),
|
|
112
|
+
}), e = i.nextIndex;
|
|
216
113
|
} else
|
|
217
|
-
|
|
114
|
+
t.push({
|
|
218
115
|
type: "text",
|
|
219
|
-
content:
|
|
220
|
-
}),
|
|
116
|
+
content: n
|
|
117
|
+
}), e++;
|
|
118
|
+
}
|
|
119
|
+
return t;
|
|
120
|
+
}
|
|
121
|
+
function Y(s, t, e) {
|
|
122
|
+
let n = t + 1, i = "";
|
|
123
|
+
if (s[n] === "{") {
|
|
124
|
+
for (n++; n < s.length && s[n] !== "}"; )
|
|
125
|
+
i += s[n], n++;
|
|
126
|
+
s[n] === "}" && n++;
|
|
127
|
+
}
|
|
128
|
+
const o = [];
|
|
129
|
+
let l = 1;
|
|
130
|
+
for (; n < s.length && l > 0; ) {
|
|
131
|
+
const a = s[n];
|
|
132
|
+
if (a === "\\begin")
|
|
133
|
+
l++, o.push(a), n++;
|
|
134
|
+
else if (a === "\\end")
|
|
135
|
+
if (l--, l === 0) {
|
|
136
|
+
if (n++, s[n] === "{") {
|
|
137
|
+
for (n++; n < s.length && s[n] !== "}"; ) n++;
|
|
138
|
+
s[n] === "}" && n++;
|
|
139
|
+
}
|
|
140
|
+
} else
|
|
141
|
+
o.push(a), n++;
|
|
142
|
+
else
|
|
143
|
+
o.push(a), n++;
|
|
221
144
|
}
|
|
222
|
-
|
|
145
|
+
const r = [];
|
|
146
|
+
let c = [], f = [];
|
|
147
|
+
const p = () => {
|
|
148
|
+
c.push(M(f)), f = [];
|
|
149
|
+
}, b = () => {
|
|
150
|
+
p(), r.push(c), c = [];
|
|
151
|
+
};
|
|
152
|
+
for (const a of o)
|
|
153
|
+
a === "&" ? p() : a === "\\\\" ? b() : f.push(a);
|
|
154
|
+
(f.length > 0 || c.length > 0) && b();
|
|
155
|
+
const m = $[i] ?? ["", ""];
|
|
156
|
+
return e.push({ type: "matrix", rows: r, delimiters: m }), n;
|
|
223
157
|
}
|
|
224
|
-
function
|
|
225
|
-
if (
|
|
158
|
+
function w(s, t) {
|
|
159
|
+
if (s[t] !== "{")
|
|
226
160
|
return {
|
|
227
161
|
nodes: [
|
|
228
162
|
{
|
|
229
163
|
type: "text",
|
|
230
|
-
content:
|
|
164
|
+
content: s[t] || ""
|
|
231
165
|
}
|
|
232
166
|
],
|
|
233
|
-
nextIndex:
|
|
167
|
+
nextIndex: t + 1
|
|
234
168
|
};
|
|
235
|
-
let
|
|
236
|
-
const
|
|
169
|
+
let e = t + 1;
|
|
170
|
+
const n = [];
|
|
237
171
|
let i = 1;
|
|
238
|
-
for (;
|
|
239
|
-
const o =
|
|
240
|
-
o === "{" ? (i++,
|
|
172
|
+
for (; e < s.length && i > 0; ) {
|
|
173
|
+
const o = s[e];
|
|
174
|
+
o === "{" ? (i++, n.push(o)) : o === "}" ? (i--, i > 0 && n.push(o)) : n.push(o), e++;
|
|
241
175
|
}
|
|
242
176
|
return {
|
|
243
|
-
nodes:
|
|
244
|
-
nextIndex:
|
|
177
|
+
nodes: M(n),
|
|
178
|
+
nextIndex: e
|
|
245
179
|
};
|
|
246
180
|
}
|
|
247
|
-
function
|
|
248
|
-
let
|
|
249
|
-
for (let o = 0; o <
|
|
250
|
-
const
|
|
251
|
-
if (
|
|
252
|
-
const
|
|
253
|
-
|
|
181
|
+
function T(s, t) {
|
|
182
|
+
let e = t.x, n = 0, i = 0;
|
|
183
|
+
for (let o = 0; o < s.length; o++) {
|
|
184
|
+
const l = s[o], r = l.type === "subscript", c = l.type === "superscript", f = s[o + 1], p = (f == null ? void 0 : f.type) === "subscript", b = (f == null ? void 0 : f.type) === "superscript";
|
|
185
|
+
if (r && b || c && p) {
|
|
186
|
+
const m = C(l, { ...t, x: e }), a = C(f, { ...t, x: e }), u = Math.max(m.width, a.width);
|
|
187
|
+
e += u + t.fontSize * 0.15, n = Math.max(n, m.baseline, a.baseline), i = Math.max(i, m.height - m.baseline, a.height - a.baseline), o++;
|
|
254
188
|
} else {
|
|
255
|
-
const
|
|
256
|
-
|
|
189
|
+
const m = C(l, { ...t, x: e });
|
|
190
|
+
e += m.width, (r || c) && (e += t.fontSize * 0.12), n = Math.max(n, m.baseline), i = Math.max(i, m.height - m.baseline);
|
|
257
191
|
}
|
|
258
192
|
}
|
|
259
193
|
return {
|
|
260
|
-
width:
|
|
261
|
-
height:
|
|
262
|
-
baseline:
|
|
194
|
+
width: e - t.x,
|
|
195
|
+
height: n + i,
|
|
196
|
+
baseline: n
|
|
263
197
|
};
|
|
264
198
|
}
|
|
265
|
-
function
|
|
266
|
-
switch (
|
|
199
|
+
function C(s, t) {
|
|
200
|
+
switch (s.type) {
|
|
267
201
|
case "text":
|
|
268
|
-
return
|
|
202
|
+
return R(s.content || "", t);
|
|
269
203
|
case "textgroup":
|
|
270
|
-
return
|
|
204
|
+
return R(s.content || "", t);
|
|
271
205
|
case "symbol":
|
|
272
|
-
return
|
|
206
|
+
return x(s.content || "", t);
|
|
273
207
|
case "superscript":
|
|
274
|
-
return
|
|
208
|
+
return K(s.children || [], t);
|
|
275
209
|
case "subscript":
|
|
276
|
-
return
|
|
210
|
+
return O(s.children || [], t);
|
|
277
211
|
case "fraction":
|
|
278
|
-
return
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
212
|
+
return G(
|
|
213
|
+
s.numerator || [],
|
|
214
|
+
s.denominator || [],
|
|
215
|
+
t
|
|
282
216
|
);
|
|
283
217
|
case "sqrt":
|
|
284
|
-
return
|
|
218
|
+
return J(s.children || [], t);
|
|
285
219
|
case "group":
|
|
286
|
-
return
|
|
220
|
+
return T(s.children || [], t);
|
|
221
|
+
case "matrix":
|
|
222
|
+
return k(s.rows || [], s.delimiters || ["", ""], t);
|
|
287
223
|
default:
|
|
288
224
|
return { width: 0, height: 0, baseline: 0 };
|
|
289
225
|
}
|
|
290
226
|
}
|
|
291
|
-
function
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
const
|
|
227
|
+
function k(s, t, e) {
|
|
228
|
+
const n = s.length, i = s.reduce((h, d) => Math.max(h, d.length), 0);
|
|
229
|
+
if (n === 0 || i === 0)
|
|
230
|
+
return { width: 0, height: 0, baseline: 0 };
|
|
231
|
+
const o = e.fontSize * 0.35, l = e.fontSize * 0.25, r = e.fontSize * 0.35, c = s.map((h) => h.map((d) => A(d, e))), f = new Array(i).fill(0), p = new Array(n).fill(0), b = new Array(n).fill(0);
|
|
232
|
+
for (let h = 0; h < n; h++)
|
|
233
|
+
for (let d = 0; d < s[h].length; d++) {
|
|
234
|
+
const g = c[h][d];
|
|
235
|
+
f[d] = Math.max(f[d], g.width), p[h] = Math.max(p[h], g.baseline), b[h] = Math.max(b[h], g.height - g.baseline);
|
|
236
|
+
}
|
|
237
|
+
const m = p.map((h, d) => h + b[d]), a = m.reduce((h, d) => h + d, 0) + l * 2 * n, z = f.reduce((h, d) => h + d, 0) + o * 2 * i + r * 2, y = e.y - a / 2;
|
|
238
|
+
X(e, t[0], e.x, y, a, r, "left"), X(e, t[1], e.x + z - r, y, a, r, "right");
|
|
239
|
+
let S = y + l;
|
|
240
|
+
for (let h = 0; h < n; h++) {
|
|
241
|
+
let d = e.x + r + o;
|
|
242
|
+
for (let g = 0; g < i; g++) {
|
|
243
|
+
const I = s[h][g];
|
|
244
|
+
if (I) {
|
|
245
|
+
const q = c[h][g], B = d + (f[g] - q.width) / 2, L = S + p[h];
|
|
246
|
+
T(I, { ...e, x: B, y: L });
|
|
247
|
+
}
|
|
248
|
+
d += f[g] + o * 2;
|
|
249
|
+
}
|
|
250
|
+
S += m[h] + l * 2;
|
|
251
|
+
}
|
|
252
|
+
return { width: z, height: a, baseline: a / 2 };
|
|
253
|
+
}
|
|
254
|
+
function X(s, t, e, n, i, o, l) {
|
|
255
|
+
if (!t) return;
|
|
256
|
+
const r = s.ctx;
|
|
257
|
+
r.save(), r.strokeStyle = s.color, r.lineWidth = Math.max(1, s.fontSize * 0.05), r.lineCap = "round", r.lineJoin = "round";
|
|
258
|
+
const c = n + i, f = o * 0.7, p = (u) => {
|
|
259
|
+
r.beginPath(), u ? (r.moveTo(e + o, n), r.quadraticCurveTo(e, (n + c) / 2, e + o, c)) : (r.moveTo(e, n), r.quadraticCurveTo(e + o, (n + c) / 2, e, c)), r.stroke();
|
|
260
|
+
}, b = (u) => {
|
|
261
|
+
r.beginPath(), u ? (r.moveTo(e + f, n), r.lineTo(e, n), r.lineTo(e, c), r.lineTo(e + f, c)) : (r.moveTo(e + o - f, n), r.lineTo(e + o, n), r.lineTo(e + o, c), r.lineTo(e + o - f, c)), r.stroke();
|
|
262
|
+
}, m = (u) => {
|
|
263
|
+
r.beginPath(), r.moveTo(e + u, n), r.lineTo(e + u, c), r.stroke();
|
|
264
|
+
}, a = (u) => {
|
|
265
|
+
const z = (n + c) / 2, y = u ? e + o : e, S = u ? e : e + o;
|
|
266
|
+
r.beginPath(), r.moveTo(y, n), r.quadraticCurveTo(S, n + i * 0.25, (y + S) / 2, n + i * 0.4), r.quadraticCurveTo(S, z - 1, S, z), r.quadraticCurveTo(S, z + 1, (y + S) / 2, c - i * 0.4), r.quadraticCurveTo(S, c - i * 0.25, y, c), r.stroke();
|
|
267
|
+
};
|
|
268
|
+
switch (t) {
|
|
269
|
+
case "(":
|
|
270
|
+
p(!0);
|
|
271
|
+
break;
|
|
272
|
+
case ")":
|
|
273
|
+
p(!1);
|
|
274
|
+
break;
|
|
275
|
+
case "[":
|
|
276
|
+
b(!0);
|
|
277
|
+
break;
|
|
278
|
+
case "]":
|
|
279
|
+
b(!1);
|
|
280
|
+
break;
|
|
281
|
+
case "{":
|
|
282
|
+
a(!0);
|
|
283
|
+
break;
|
|
284
|
+
case "}":
|
|
285
|
+
a(!1);
|
|
286
|
+
break;
|
|
287
|
+
case "|":
|
|
288
|
+
m(o * 0.5);
|
|
289
|
+
break;
|
|
290
|
+
case "‖":
|
|
291
|
+
m(o * 0.3), m(o * 0.7);
|
|
292
|
+
break;
|
|
293
|
+
}
|
|
294
|
+
r.restore();
|
|
295
|
+
}
|
|
296
|
+
function R(s, t) {
|
|
297
|
+
t.ctx.save(), t.ctx.font = `${t.fontSize}px ${t.fontFamily}`, t.ctx.fillStyle = t.color, t.ctx.textAlign = "left", t.ctx.textBaseline = "alphabetic";
|
|
298
|
+
const e = t.ctx.measureText(s);
|
|
299
|
+
t.ctx.fillText(s, t.x, t.y), t.ctx.restore();
|
|
300
|
+
const n = t.fontSize, i = n * 0.75;
|
|
296
301
|
return {
|
|
297
|
-
width:
|
|
298
|
-
height:
|
|
302
|
+
width: e.width,
|
|
303
|
+
height: n,
|
|
299
304
|
baseline: i
|
|
300
305
|
};
|
|
301
306
|
}
|
|
302
|
-
function
|
|
303
|
-
|
|
304
|
-
const
|
|
305
|
-
|
|
306
|
-
const
|
|
307
|
+
function x(s, t) {
|
|
308
|
+
t.ctx.save(), t.ctx.font = `${t.fontSize * 1.1}px ${t.fontFamily}`, t.ctx.fillStyle = t.color, t.ctx.textAlign = "left", t.ctx.textBaseline = "alphabetic";
|
|
309
|
+
const e = t.ctx.measureText(s);
|
|
310
|
+
t.ctx.fillText(s, t.x, t.y), t.ctx.restore();
|
|
311
|
+
const n = t.fontSize * 1.1, i = n * 0.75;
|
|
307
312
|
return {
|
|
308
|
-
width:
|
|
309
|
-
height:
|
|
313
|
+
width: e.width,
|
|
314
|
+
height: n,
|
|
310
315
|
baseline: i
|
|
311
316
|
};
|
|
312
317
|
}
|
|
313
|
-
function
|
|
314
|
-
const
|
|
315
|
-
...
|
|
316
|
-
fontSize:
|
|
317
|
-
y:
|
|
318
|
-
}), o = i.baseline,
|
|
318
|
+
function K(s, t) {
|
|
319
|
+
const e = t.fontSize * 0.7, n = -t.fontSize * 0.4, i = T(s, {
|
|
320
|
+
...t,
|
|
321
|
+
fontSize: e,
|
|
322
|
+
y: t.y + n
|
|
323
|
+
}), o = i.baseline, l = i.height - i.baseline;
|
|
319
324
|
return {
|
|
320
325
|
width: i.width,
|
|
321
|
-
height: o -
|
|
322
|
-
baseline: o -
|
|
326
|
+
height: o - n + (l + n),
|
|
327
|
+
baseline: o - n
|
|
323
328
|
};
|
|
324
329
|
}
|
|
325
|
-
function
|
|
326
|
-
const
|
|
327
|
-
...
|
|
328
|
-
fontSize:
|
|
329
|
-
y:
|
|
330
|
-
}), o = i.baseline,
|
|
330
|
+
function O(s, t) {
|
|
331
|
+
const e = t.fontSize * 0.7, n = t.fontSize * 0.3, i = T(s, {
|
|
332
|
+
...t,
|
|
333
|
+
fontSize: e,
|
|
334
|
+
y: t.y + n
|
|
335
|
+
}), o = i.baseline, l = i.height - i.baseline;
|
|
331
336
|
return {
|
|
332
337
|
width: i.width,
|
|
333
|
-
height: o -
|
|
334
|
-
baseline: o -
|
|
338
|
+
height: o - n + (l + n),
|
|
339
|
+
baseline: o - n
|
|
335
340
|
};
|
|
336
341
|
}
|
|
337
|
-
function
|
|
338
|
-
const
|
|
339
|
-
...
|
|
340
|
-
fontSize:
|
|
341
|
-
}),
|
|
342
|
-
...
|
|
343
|
-
fontSize:
|
|
344
|
-
}),
|
|
345
|
-
|
|
346
|
-
...
|
|
347
|
-
x:
|
|
348
|
-
y:
|
|
349
|
-
fontSize:
|
|
350
|
-
}),
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
342
|
+
function G(s, t, e) {
|
|
343
|
+
const n = e.fontSize * 0.85, i = Math.max(1, e.fontSize * 0.05), o = e.fontSize * 0.1, l = A(s, {
|
|
344
|
+
...e,
|
|
345
|
+
fontSize: n
|
|
346
|
+
}), r = A(t, {
|
|
347
|
+
...e,
|
|
348
|
+
fontSize: n
|
|
349
|
+
}), c = Math.max(l.width, r.width), f = l.height + r.height + o * 2 + i, p = e.x + (c - l.width) / 2, b = e.y - o - i / 2;
|
|
350
|
+
T(s, {
|
|
351
|
+
...e,
|
|
352
|
+
x: p,
|
|
353
|
+
y: b,
|
|
354
|
+
fontSize: n
|
|
355
|
+
}), e.ctx.fillStyle = e.color, e.ctx.fillRect(
|
|
356
|
+
e.x,
|
|
357
|
+
e.y - i / 2,
|
|
358
|
+
c,
|
|
354
359
|
i
|
|
355
360
|
);
|
|
356
|
-
const
|
|
357
|
-
return
|
|
358
|
-
...
|
|
359
|
-
x:
|
|
360
|
-
y:
|
|
361
|
-
fontSize:
|
|
361
|
+
const m = e.x + (c - r.width) / 2, a = e.y + r.baseline + o + i / 2;
|
|
362
|
+
return T(t, {
|
|
363
|
+
...e,
|
|
364
|
+
x: m,
|
|
365
|
+
y: a,
|
|
366
|
+
fontSize: n
|
|
362
367
|
}), {
|
|
363
|
-
width:
|
|
364
|
-
height:
|
|
365
|
-
baseline:
|
|
368
|
+
width: c,
|
|
369
|
+
height: f,
|
|
370
|
+
baseline: f / 2
|
|
366
371
|
};
|
|
367
372
|
}
|
|
368
|
-
function
|
|
369
|
-
const
|
|
370
|
-
...
|
|
371
|
-
x:
|
|
372
|
-
}),
|
|
373
|
-
return
|
|
374
|
-
width:
|
|
373
|
+
function J(s, t) {
|
|
374
|
+
const e = T(s, {
|
|
375
|
+
...t,
|
|
376
|
+
x: t.x + t.fontSize * 0.4
|
|
377
|
+
}), n = e.width + t.fontSize * 0.5, i = e.height * 1.1;
|
|
378
|
+
return t.ctx.save(), t.ctx.strokeStyle = t.color, t.ctx.lineWidth = Math.max(1, t.fontSize * 0.05), t.ctx.lineCap = "round", t.ctx.lineJoin = "miter", t.ctx.beginPath(), t.ctx.moveTo(t.x, t.y - i * 0.3), t.ctx.lineTo(t.x + t.fontSize * 0.15, t.y), t.ctx.lineTo(t.x + t.fontSize * 0.3, t.y - i * 0.9), t.ctx.lineTo(t.x + n, t.y - i * 0.9), t.ctx.stroke(), t.ctx.restore(), {
|
|
379
|
+
width: n,
|
|
375
380
|
height: i,
|
|
376
|
-
baseline:
|
|
381
|
+
baseline: e.baseline
|
|
377
382
|
};
|
|
378
383
|
}
|
|
379
|
-
function
|
|
380
|
-
const
|
|
381
|
-
return
|
|
384
|
+
function A(s, t) {
|
|
385
|
+
const n = document.createElement("canvas").getContext("2d");
|
|
386
|
+
return n ? T(s, { ...t, ctx: n, x: 0, y: 0 }) : { width: 0, height: 0, baseline: 0 };
|
|
382
387
|
}
|
|
383
|
-
function
|
|
384
|
-
const
|
|
388
|
+
function V(s = {}) {
|
|
389
|
+
const e = { ...{
|
|
385
390
|
fontSize: 14,
|
|
386
391
|
fontFamily: "serif",
|
|
387
392
|
color: "#000000",
|
|
388
393
|
enableCache: !0,
|
|
389
394
|
customSymbols: {}
|
|
390
|
-
}, ...
|
|
391
|
-
function
|
|
392
|
-
|
|
395
|
+
}, ...s }, n = 1e3;
|
|
396
|
+
function i(a) {
|
|
397
|
+
if (a.size > n) {
|
|
398
|
+
const u = a.keys().next().value;
|
|
399
|
+
u !== void 0 && a.delete(u);
|
|
400
|
+
}
|
|
393
401
|
}
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
let c = s.get(a);
|
|
398
|
-
return c || (c = T(a), s.set(a, c)), c;
|
|
402
|
+
const o = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map();
|
|
403
|
+
function r() {
|
|
404
|
+
o.clear(), l.clear();
|
|
399
405
|
}
|
|
400
|
-
function
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
406
|
+
function c(a) {
|
|
407
|
+
if (!e.enableCache)
|
|
408
|
+
return P(a);
|
|
409
|
+
let u = o.get(a);
|
|
410
|
+
return u || (u = P(a), o.set(a, u), i(o)), u;
|
|
411
|
+
}
|
|
412
|
+
function f(a, u, z, y, S = {}) {
|
|
413
|
+
const h = { ...e, ...S }, d = c(a);
|
|
414
|
+
return T(d, {
|
|
415
|
+
ctx: u,
|
|
416
|
+
x: z,
|
|
417
|
+
y,
|
|
418
|
+
fontSize: h.fontSize,
|
|
419
|
+
fontFamily: h.fontFamily,
|
|
420
|
+
color: h.color,
|
|
409
421
|
scale: 1
|
|
410
422
|
});
|
|
411
423
|
}
|
|
412
|
-
function p(a,
|
|
413
|
-
const
|
|
414
|
-
if (
|
|
415
|
-
return
|
|
416
|
-
const
|
|
417
|
-
if (!
|
|
424
|
+
function p(a, u = {}) {
|
|
425
|
+
const z = `${a}:${u.fontSize || e.fontSize}`;
|
|
426
|
+
if (e.enableCache && l.has(z))
|
|
427
|
+
return l.get(z);
|
|
428
|
+
const y = { ...e, ...u }, S = c(a), d = document.createElement("canvas").getContext("2d");
|
|
429
|
+
if (!d)
|
|
418
430
|
return { width: 0, height: 0, baseline: 0 };
|
|
419
|
-
const
|
|
420
|
-
ctx:
|
|
431
|
+
const g = T(S, {
|
|
432
|
+
ctx: d,
|
|
421
433
|
x: 0,
|
|
422
434
|
y: 0,
|
|
423
|
-
fontSize:
|
|
424
|
-
fontFamily:
|
|
425
|
-
color:
|
|
435
|
+
fontSize: y.fontSize,
|
|
436
|
+
fontFamily: y.fontFamily,
|
|
437
|
+
color: y.color,
|
|
426
438
|
scale: 1
|
|
427
439
|
});
|
|
428
|
-
return
|
|
440
|
+
return e.enableCache && (l.set(z, g), i(l)), g;
|
|
441
|
+
}
|
|
442
|
+
function b() {
|
|
443
|
+
return {
|
|
444
|
+
parseCache: o.size,
|
|
445
|
+
measureCache: l.size,
|
|
446
|
+
maxEntries: n
|
|
447
|
+
};
|
|
429
448
|
}
|
|
430
449
|
return {
|
|
431
450
|
manifest: {
|
|
@@ -439,16 +458,17 @@ function _(n = {}) {
|
|
|
439
458
|
a.log.info("LaTeX plugin initialized");
|
|
440
459
|
},
|
|
441
460
|
onDestroy(a) {
|
|
442
|
-
|
|
461
|
+
r(), a.log.info("LaTeX plugin destroyed");
|
|
443
462
|
},
|
|
444
463
|
api: {
|
|
445
464
|
render: f,
|
|
446
465
|
measure: p,
|
|
447
|
-
clearCache:
|
|
466
|
+
clearCache: r,
|
|
467
|
+
getCacheStats: b
|
|
448
468
|
}
|
|
449
469
|
};
|
|
450
470
|
}
|
|
451
471
|
export {
|
|
452
|
-
|
|
472
|
+
V as PluginLaTeX
|
|
453
473
|
};
|
|
454
474
|
//# sourceMappingURL=latex.js.map
|