@siglum/engine 0.1.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.
@@ -0,0 +1,124 @@
1
+ /**
2
+ * Get metadata for a cached CTAN package.
3
+ * @param {string} packageName - Package name
4
+ * @returns {Promise<Object|null>} Package metadata or null
5
+ */
6
+ export function getPackageMeta(packageName: string): Promise<any | null>;
7
+ /**
8
+ * Save metadata for a CTAN package.
9
+ * @param {string} packageName - Package name
10
+ * @param {Object} meta - Package metadata
11
+ * @returns {Promise<boolean>} True if saved successfully
12
+ */
13
+ export function savePackageMeta(packageName: string, meta: any): Promise<boolean>;
14
+ /**
15
+ * List all cached CTAN packages and their metadata.
16
+ * @returns {Promise<Object[]>} Array of package metadata objects
17
+ */
18
+ export function listAllCachedPackages(): Promise<any[]>;
19
+ /**
20
+ * Ensure the /texlive filesystem is mounted for CTAN package storage.
21
+ * @returns {Promise<boolean>} True if mounted successfully
22
+ */
23
+ export function ensureTexliveMounted(): Promise<boolean>;
24
+ /**
25
+ * Get a bundle from the cache.
26
+ * @param {string} bundleName - Bundle name
27
+ * @returns {Promise<ArrayBuffer|null>} Bundle data or null if not cached
28
+ */
29
+ export function getBundleFromCache(bundleName: string): Promise<ArrayBuffer | null>;
30
+ /**
31
+ * Save a bundle to the cache.
32
+ * @param {string} bundleName - Bundle name
33
+ * @param {ArrayBuffer|SharedArrayBuffer} data - Bundle data
34
+ * @returns {Promise<boolean>} True if saved successfully
35
+ */
36
+ export function saveBundleToCache(bundleName: string, data: ArrayBuffer | SharedArrayBuffer): Promise<boolean>;
37
+ /**
38
+ * Get a manifest from the cache.
39
+ * @param {string} name - Manifest name (without .json extension)
40
+ * @returns {Promise<Object|null>} Parsed manifest or null
41
+ */
42
+ export function getManifestFromCache(name: string): Promise<any | null>;
43
+ /**
44
+ * Save a manifest to the cache.
45
+ * @param {string} name - Manifest name (without .json extension)
46
+ * @param {Object} data - Manifest data
47
+ * @returns {Promise<boolean>} True if saved successfully
48
+ */
49
+ export function saveManifestToCache(name: string, data: any): Promise<boolean>;
50
+ /**
51
+ * Get the cached manifest version number.
52
+ * @returns {Promise<number>} Version number (0 if not set)
53
+ */
54
+ export function getManifestVersion(): Promise<number>;
55
+ /**
56
+ * Save the manifest version number.
57
+ * @param {number} version - Version number
58
+ * @returns {Promise<boolean>} True if saved successfully
59
+ */
60
+ export function saveManifestVersion(version: number): Promise<boolean>;
61
+ /**
62
+ * Get cached aux files for a preamble hash.
63
+ * @param {string} preambleHash - Hash of the document preamble
64
+ * @returns {Promise<{hash: string, files: Object, timestamp: number}|null>} Cached entry or null
65
+ */
66
+ export function getAuxCache(preambleHash: string): Promise<{
67
+ hash: string;
68
+ files: any;
69
+ timestamp: number;
70
+ } | null>;
71
+ /**
72
+ * Save aux files for a preamble hash.
73
+ * @param {string} preambleHash - Hash of the document preamble
74
+ * @param {Object} auxFiles - Aux files to cache
75
+ * @returns {Promise<void>}
76
+ */
77
+ export function saveAuxCache(preambleHash: string, auxFiles: any): Promise<void>;
78
+ /**
79
+ * Get a cached compiled PDF.
80
+ * @param {string} docHash - Document content hash
81
+ * @param {string} engine - Engine used ('pdflatex', 'xelatex', 'lualatex')
82
+ * @returns {Promise<Uint8Array|null>} PDF data or null if not cached
83
+ */
84
+ export function getCachedPdf(docHash: string, engine: string): Promise<Uint8Array | null>;
85
+ /**
86
+ * Save a compiled PDF to the cache.
87
+ * @param {string} docHash - Document content hash
88
+ * @param {string} engine - Engine used ('pdflatex', 'xelatex', 'lualatex')
89
+ * @param {Uint8Array} pdfData - PDF data
90
+ * @returns {Promise<void>}
91
+ */
92
+ export function saveCachedPdf(docHash: string, engine: string, pdfData: Uint8Array): Promise<void>;
93
+ /**
94
+ * Get the path for a format file.
95
+ * @param {string} fmtKey - Format key
96
+ * @returns {string} Path to format file
97
+ */
98
+ export function getFmtPath(fmtKey: string): string;
99
+ /**
100
+ * Clear all cached CTAN package metadata.
101
+ * @returns {Promise<boolean>} True if cleared successfully
102
+ */
103
+ export function clearCTANCache(): Promise<boolean>;
104
+ /**
105
+ * Get cached WASM bytes and compile to WebAssembly.Module.
106
+ * @returns {Promise<WebAssembly.Module|null>} Compiled module or null
107
+ */
108
+ export function getCompiledWasmModule(): Promise<WebAssembly.Module | null>;
109
+ /**
110
+ * Save WASM bytes to IndexedDB for future compilation.
111
+ * @param {Uint8Array} bytes - WASM bytes
112
+ * @returns {Promise<boolean>} True if saved successfully
113
+ */
114
+ export function saveWasmBytes(bytes: Uint8Array): Promise<boolean>;
115
+ /**
116
+ * Save WASM memory snapshot for instant restore on next load.
117
+ * @param {WebAssembly.Memory|Uint8Array} memoryOrSnapshot - Memory object or snapshot bytes
118
+ * @param {Object} [metadata] - Optional metadata to save with snapshot
119
+ * @returns {Promise<boolean>} True if saved successfully
120
+ */
121
+ export function saveWasmMemorySnapshot(memoryOrSnapshot: WebAssembly.Memory | Uint8Array, metadata?: any): Promise<boolean>;
122
+ export { hashDocument } from "./hash.js";
123
+ export const CTAN_CACHE_VERSION: 9;
124
+ export const MANIFEST_CACHE_VERSION: 5;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Create a batched logger that collects messages and flushes them once per animation frame.
3
+ * This prevents DOM thrashing when the compiler emits many log messages rapidly.
4
+ *
5
+ * @param {function(string[]): void} onFlush - Called with array of messages to display
6
+ * @returns {function(string): void} - Logger function to pass to SiglumCompiler's onLog option
7
+ *
8
+ * @example
9
+ * const compiler = new SiglumCompiler({
10
+ * onLog: createBatchedLogger((messages) => {
11
+ * statusDiv.textContent += messages.join('\n') + '\n';
12
+ * statusDiv.scrollTop = statusDiv.scrollHeight;
13
+ * }),
14
+ * });
15
+ */
16
+ export function createBatchedLogger(onFlush: (arg0: string[]) => void): (arg0: string) => void;