@vutex/vutex 0.0.14 → 0.0.17
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/licenses/NotoSansMono.OFL.md +93 -0
- package/licenses/NotoSerifSC.OFL.md +94 -0
- package/licenses/Tinos.OFL.md +93 -0
- package/locales/en-US/cli.json +5 -4
- package/package.json +8 -7
- package/readme.md +29 -3
- package/src/cli/commands/package.ts +41 -12
- package/src/cli/commands/render.ts +5 -1
- package/src/index.ts +3 -0
- package/src/node/load.ts +18 -22
- package/src/packages/builtin.ts +129 -0
- package/src/packages/lockfile.ts +33 -1
- package/src/packages/manager.ts +1125 -64
- package/src/packages/manifest.ts +45 -0
- package/src/packages/math_font.ts +63 -0
- package/src/packages/registry.ts +405 -0
- package/src/packages/template.ts +352 -0
- package/src/runtime.ts +387 -37
- package/src/types.ts +173 -15
package/src/types.ts
CHANGED
|
@@ -6,14 +6,34 @@ export type CreateVuTeXOptions = {
|
|
|
6
6
|
projectRoot?: string;
|
|
7
7
|
host?: VuTeXHost;
|
|
8
8
|
backend?: VuTeXBackend;
|
|
9
|
+
/**
|
|
10
|
+
* Fallback theme, math face and input format when neither the render call
|
|
11
|
+
* nor the manifest picks one. Distributions such as `@vutex/latex` set
|
|
12
|
+
* these so a preset never has to write into the user's project.
|
|
13
|
+
*/
|
|
14
|
+
defaults?: {
|
|
15
|
+
theme?: string;
|
|
16
|
+
mathFont?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Input format used when the render call and the manifest stay silent.
|
|
19
|
+
* An input distribution such as `@vutex/typst` sets this so files with
|
|
20
|
+
* no recognised extension still reach the right adapter.
|
|
21
|
+
*/
|
|
22
|
+
input?: string;
|
|
23
|
+
};
|
|
9
24
|
};
|
|
10
25
|
|
|
11
26
|
export type DocumentOutputFormat = "svg" | "html" | "snapshot" | "pdf";
|
|
12
27
|
|
|
28
|
+
export type DocumentTheme = "baseline" | "traditional";
|
|
29
|
+
|
|
13
30
|
export type RenderDocumentOptions = {
|
|
14
31
|
output?: DocumentOutputFormat | string;
|
|
15
32
|
profile?: string;
|
|
16
33
|
input?: string;
|
|
34
|
+
theme?: DocumentTheme | string;
|
|
35
|
+
baseDir?: string;
|
|
36
|
+
resources?: Record<string, string>;
|
|
17
37
|
};
|
|
18
38
|
|
|
19
39
|
export type InspectDocumentOptions = {
|
|
@@ -57,13 +77,13 @@ export type VuTeXDiagnostic = {
|
|
|
57
77
|
};
|
|
58
78
|
|
|
59
79
|
export type RenderDocumentResult = {
|
|
60
|
-
exitCode: number;
|
|
61
80
|
outputFormat: string;
|
|
62
81
|
svg?: string;
|
|
63
82
|
html?: string;
|
|
64
83
|
pdf?: Uint8Array;
|
|
65
84
|
reportJson: string;
|
|
66
85
|
diagnostics: VuTeXDiagnostic[];
|
|
86
|
+
packages?: ActivatedPackage[];
|
|
67
87
|
};
|
|
68
88
|
|
|
69
89
|
export type InspectDocumentResult = {
|
|
@@ -73,41 +93,179 @@ export type InspectDocumentResult = {
|
|
|
73
93
|
diagnostics: VuTeXDiagnostic[];
|
|
74
94
|
};
|
|
75
95
|
|
|
96
|
+
export type PackageSlot =
|
|
97
|
+
| "font"
|
|
98
|
+
| "math-font"
|
|
99
|
+
| "template"
|
|
100
|
+
| "theme"
|
|
101
|
+
| "profile"
|
|
102
|
+
| "macros"
|
|
103
|
+
| "resources"
|
|
104
|
+
| "fixture";
|
|
105
|
+
|
|
76
106
|
export type PackageInstallOptions = {
|
|
77
107
|
name?: string;
|
|
78
108
|
version?: string;
|
|
109
|
+
slot?: string;
|
|
79
110
|
};
|
|
80
111
|
|
|
81
112
|
export type PackageRecord = {
|
|
113
|
+
slot: string;
|
|
82
114
|
name: string;
|
|
83
115
|
version: string;
|
|
84
116
|
source: string;
|
|
117
|
+
artifactHash?: string;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export type ActivatedPackage = {
|
|
121
|
+
slot: string;
|
|
122
|
+
name: string;
|
|
123
|
+
version: string;
|
|
124
|
+
source: string;
|
|
125
|
+
artifactHash?: string;
|
|
126
|
+
/** Directory holding the package resources, absent for byte-less presets. */
|
|
127
|
+
path?: string;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
/** Colour tokens a template may override, each written as `#RRGGBB`. */
|
|
131
|
+
export type TemplateColorToken =
|
|
132
|
+
| "ink"
|
|
133
|
+
| "inkSecondary"
|
|
134
|
+
| "inkMuted"
|
|
135
|
+
| "inkFaint"
|
|
136
|
+
| "accent"
|
|
137
|
+
| "ruleStrong"
|
|
138
|
+
| "rule"
|
|
139
|
+
| "ruleFaint"
|
|
140
|
+
| "tint"
|
|
141
|
+
| "header"
|
|
142
|
+
| "folio"
|
|
143
|
+
| "headingRule";
|
|
144
|
+
|
|
145
|
+
/** Chrome a template switches on when a heading of one level starts. */
|
|
146
|
+
export type TemplateSectionChrome = {
|
|
147
|
+
/** Heading level, H1 to H4. */
|
|
148
|
+
level: number;
|
|
149
|
+
/** Header source: `title`, `none`, or literal text. */
|
|
150
|
+
header?: string;
|
|
151
|
+
/** Whether pages in this section carry a folio. */
|
|
152
|
+
folio?: boolean;
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
/** Page geometry a template package contributes to the native layout pass. */
|
|
156
|
+
export type TemplateGeometry = {
|
|
157
|
+
pageWidth: number;
|
|
158
|
+
pageHeight: number;
|
|
159
|
+
marginTop?: number;
|
|
160
|
+
marginRight?: number;
|
|
161
|
+
marginBottom?: number;
|
|
162
|
+
marginLeft?: number;
|
|
163
|
+
/** Running header source: `title`, `none`, or literal text. */
|
|
164
|
+
chromeHeader?: string;
|
|
165
|
+
/** Whether pages carry a folio. */
|
|
166
|
+
chromeFolio?: boolean;
|
|
167
|
+
/** 1-based page index where the running header and folio start. */
|
|
168
|
+
chromeStartPage?: number;
|
|
169
|
+
/** Horizontal alignment of the running header. */
|
|
170
|
+
headerAlign?: "left" | "center" | "right";
|
|
171
|
+
/** Per-level chrome overrides, H1 to H4. */
|
|
172
|
+
chromeSections?: TemplateSectionChrome[];
|
|
173
|
+
/** Heading levels that start a new page, H1 to H4. */
|
|
174
|
+
pageBreakBefore?: number[];
|
|
175
|
+
/** Body text size in points. */
|
|
176
|
+
bodySize?: number;
|
|
177
|
+
/** Line box as a multiple of the body size. */
|
|
178
|
+
lineHeight?: number;
|
|
179
|
+
/** Heading size as a multiple of the body size, H1 to H4. */
|
|
180
|
+
headingScales?: number[];
|
|
181
|
+
/** Space after a paragraph, in points. */
|
|
182
|
+
paragraphGap?: number;
|
|
183
|
+
/** First-line paragraph indent, in points. */
|
|
184
|
+
paragraphIndent?: number;
|
|
185
|
+
/** Colour token overrides. */
|
|
186
|
+
colors?: Partial<Record<TemplateColorToken, string>>;
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
export type PackageCheck = {
|
|
190
|
+
id: string;
|
|
191
|
+
ok: boolean;
|
|
192
|
+
message: string;
|
|
193
|
+
code?: string;
|
|
85
194
|
};
|
|
86
195
|
|
|
87
196
|
export type PackageDoctorReport = {
|
|
88
197
|
ok: boolean;
|
|
89
|
-
checks:
|
|
198
|
+
checks: PackageCheck[];
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Lowered document handle returned by `lowerDocument`.
|
|
203
|
+
*
|
|
204
|
+
* The handle carries the diagram and footnote resolution between the lowering
|
|
205
|
+
* and layout primitives. It is a scene value, not a file or process handle.
|
|
206
|
+
*/
|
|
207
|
+
export type LoweredDocumentHandle = {
|
|
208
|
+
graphJson: () => string;
|
|
209
|
+
diagnosticsJson: () => string;
|
|
210
|
+
footnotesJson: () => string;
|
|
90
211
|
};
|
|
91
212
|
|
|
213
|
+
/**
|
|
214
|
+
* Paginated display scene returned by `buildDisplay`.
|
|
215
|
+
*
|
|
216
|
+
* Each method is one emission primitive. The SVG and HTML methods embed the
|
|
217
|
+
* bundled fonts themselves, so callers never assemble a font list.
|
|
218
|
+
*/
|
|
219
|
+
export type DisplaySceneHandle = {
|
|
220
|
+
pageCount: () => number;
|
|
221
|
+
itemCount: () => number;
|
|
222
|
+
themeId: () => string;
|
|
223
|
+
mathFontId: () => string | undefined;
|
|
224
|
+
diagnosticsJson: () => string;
|
|
225
|
+
svg: () => string;
|
|
226
|
+
snapshotHtml: () => string;
|
|
227
|
+
pdf: (resourcesJson?: string) => { pdf: Uint8Array; diagnosticsJson: string };
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
/** Semantic reflow scene returned by `buildFlow`. */
|
|
231
|
+
export type FlowSceneHandle = {
|
|
232
|
+
html: () => string;
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Native primitive surface.
|
|
237
|
+
*
|
|
238
|
+
* Exactly these calls exist on the library side. Reading input files, writing
|
|
239
|
+
* output files, deciding exit codes, and printing belong to the CLI package.
|
|
240
|
+
*/
|
|
92
241
|
export type VuTeXBindings = {
|
|
93
242
|
vutexVersion: () => string;
|
|
94
243
|
measureFormula: (source: string, optionsJson?: string) => string;
|
|
95
244
|
renderFormulaSvg: (source: string, optionsJson?: string) => string;
|
|
96
245
|
renderFormulaMathml: (source: string, optionsJson?: string) => string;
|
|
97
246
|
renderFormula: (source: string, optionsJson?: string) => string;
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
247
|
+
parseDocument: (label: string, format: string, bytes: Uint8Array) => string;
|
|
248
|
+
lowerDocument: (graphJson: string, label: string) => LoweredDocumentHandle;
|
|
249
|
+
buildDisplay: (
|
|
250
|
+
lowered: LoweredDocumentHandle,
|
|
251
|
+
theme?: string,
|
|
252
|
+
mathFont?: string,
|
|
253
|
+
template?: TemplateGeometry,
|
|
254
|
+
) => DisplaySceneHandle;
|
|
255
|
+
buildFlow: (graphJson: string, theme?: string) => FlowSceneHandle;
|
|
256
|
+
installMathFontFace: (name: string, artifactHash: string, bytes: Uint8Array, texParameters?: string) => void;
|
|
257
|
+
mathFontTexParameterFamilies: () => string[];
|
|
258
|
+
embedSvgFonts: (svg: string, theme?: string) => string;
|
|
259
|
+
subsetFace: (family: string, script: string, style: string, chars: string) => Uint8Array | null;
|
|
260
|
+
summarizeDocument: (graphJson: string) => string;
|
|
261
|
+
assembleReport: (
|
|
262
|
+
operation: string,
|
|
263
|
+
inputsJson: string,
|
|
264
|
+
diagnosticsJson: string,
|
|
265
|
+
outputJson?: string,
|
|
266
|
+
extraJson?: string,
|
|
267
|
+
) => string;
|
|
268
|
+
themeFacts: (theme?: string) => string;
|
|
111
269
|
};
|
|
112
270
|
|
|
113
271
|
export type VuTeXRuntime = {
|