@vutex/vutex 0.0.13 → 0.0.16

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