@lofcz/tikz 0.2.2 → 0.2.3
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/NOTICE.md +3 -1
- package/README.md +12 -2
- package/package.json +1 -1
- package/runtime/.build-key +1 -0
- package/runtime/dist/bundles/cm-tfm/chunks/0.br +0 -0
- package/runtime/dist/bundles/cm-tfm/chunks/1.br +0 -0
- package/runtime/dist/bundles/cm-tfm/chunks/2.br +0 -0
- package/runtime/dist/bundles/cm-tfm/chunks/3.br +0 -0
- package/runtime/dist/bundles/cm-tfm/chunks/4.br +0 -0
- package/runtime/dist/bundles/cm-tfm/chunks/5.br +0 -0
- package/runtime/dist/bundles/cm-tfm/chunks/6.br +0 -0
- package/runtime/dist/bundles/cm-tfm/chunks/7.br +0 -0
- package/runtime/dist/bundles/cm-tfm/files.index.json +1 -1
- package/runtime/dist/bundles/cm-type1/chunks/0.br +0 -0
- package/runtime/dist/bundles/cm-type1/chunks/1.br +0 -0
- package/runtime/dist/bundles/cm-type1/chunks/10.br +0 -0
- package/runtime/dist/bundles/cm-type1/chunks/11.br +0 -0
- package/runtime/dist/bundles/cm-type1/chunks/2.br +0 -0
- package/runtime/dist/bundles/cm-type1/chunks/3.br +0 -0
- package/runtime/dist/bundles/cm-type1/chunks/4.br +0 -0
- package/runtime/dist/bundles/cm-type1/chunks/5.br +0 -0
- package/runtime/dist/bundles/cm-type1/chunks/6.br +0 -0
- package/runtime/dist/bundles/cm-type1/chunks/7.br +0 -0
- package/runtime/dist/bundles/cm-type1/chunks/8.br +0 -0
- package/runtime/dist/bundles/cm-type1/chunks/9.br +0 -0
- package/runtime/dist/bundles/cm-type1/files.index.json +1 -1
- package/runtime/dist/bundles/core/chunks/0.br +0 -0
- package/runtime/dist/bundles/core/chunks/1.br +0 -0
- package/runtime/dist/bundles/core/chunks/2.br +0 -0
- package/runtime/dist/bundles/core/chunks/3.br +0 -0
- package/runtime/dist/bundles/core/files.index.json +1 -1
- package/runtime/dist/bundles/filesystem.json +1 -1
- package/runtime/dist/bundles/latex-core/chunks/0.br +0 -0
- package/runtime/dist/bundles/latex-core/chunks/1.br +0 -0
- package/runtime/dist/bundles/latex-core/chunks/10.br +0 -0
- package/runtime/dist/bundles/latex-core/chunks/2.br +0 -0
- package/runtime/dist/bundles/latex-core/chunks/3.br +0 -0
- package/runtime/dist/bundles/latex-core/chunks/4.br +0 -0
- package/runtime/dist/bundles/latex-core/chunks/5.br +0 -0
- package/runtime/dist/bundles/latex-core/chunks/6.br +0 -0
- package/runtime/dist/bundles/latex-core/chunks/7.br +0 -0
- package/runtime/dist/bundles/latex-core/chunks/8.br +0 -0
- package/runtime/dist/bundles/latex-core/chunks/9.br +0 -0
- package/runtime/dist/bundles/latex-core/files.index.json +1 -1
- package/runtime/dist/bundles/latex-extra/chunks/0.br +0 -0
- package/runtime/dist/bundles/latex-extra/chunks/1.br +0 -0
- package/runtime/dist/bundles/latex-extra/chunks/10.br +0 -0
- package/runtime/dist/bundles/latex-extra/chunks/11.br +0 -0
- package/runtime/dist/bundles/latex-extra/chunks/12.br +0 -0
- package/runtime/dist/bundles/latex-extra/chunks/13.br +0 -0
- package/runtime/dist/bundles/latex-extra/chunks/14.br +0 -0
- package/runtime/dist/bundles/latex-extra/chunks/15.br +0 -0
- package/runtime/dist/bundles/latex-extra/chunks/16.br +0 -0
- package/runtime/dist/bundles/latex-extra/chunks/17.br +0 -0
- package/runtime/dist/bundles/latex-extra/chunks/18.br +0 -0
- package/runtime/dist/bundles/latex-extra/chunks/19.br +0 -0
- package/runtime/dist/bundles/latex-extra/chunks/2.br +0 -0
- package/runtime/dist/bundles/latex-extra/chunks/20.br +0 -0
- package/runtime/dist/bundles/latex-extra/chunks/21.br +0 -0
- package/runtime/dist/bundles/latex-extra/chunks/22.br +0 -0
- package/runtime/dist/bundles/latex-extra/chunks/23.br +0 -0
- package/runtime/dist/bundles/latex-extra/chunks/24.br +0 -0
- package/runtime/dist/bundles/latex-extra/chunks/25.br +0 -0
- package/runtime/dist/bundles/latex-extra/chunks/26.br +0 -0
- package/runtime/dist/bundles/latex-extra/chunks/27.br +0 -0
- package/runtime/dist/bundles/latex-extra/chunks/3.br +0 -0
- package/runtime/dist/bundles/latex-extra/chunks/4.br +0 -0
- package/runtime/dist/bundles/latex-extra/chunks/5.br +0 -0
- package/runtime/dist/bundles/latex-extra/chunks/6.br +0 -0
- package/runtime/dist/bundles/latex-extra/chunks/7.br +0 -0
- package/runtime/dist/bundles/latex-extra/chunks/8.br +0 -0
- package/runtime/dist/bundles/latex-extra/chunks/9.br +0 -0
- package/runtime/dist/bundles/latex-extra/files.index.json +1 -1
- package/runtime/dist/bundles/lm-fonts/chunks/0.br +0 -0
- package/runtime/dist/bundles/lm-fonts/chunks/1.br +0 -0
- package/runtime/dist/bundles/lm-fonts/chunks/10.br +0 -0
- package/runtime/dist/bundles/lm-fonts/chunks/11.br +0 -0
- package/runtime/dist/bundles/lm-fonts/chunks/12.br +0 -0
- package/runtime/dist/bundles/lm-fonts/chunks/13.br +0 -0
- package/runtime/dist/bundles/lm-fonts/chunks/14.br +0 -0
- package/runtime/dist/bundles/lm-fonts/chunks/15.br +0 -0
- package/runtime/dist/bundles/lm-fonts/chunks/16.br +0 -0
- package/runtime/dist/bundles/lm-fonts/chunks/17.br +0 -0
- package/runtime/dist/bundles/lm-fonts/chunks/18.br +0 -0
- package/runtime/dist/bundles/lm-fonts/chunks/19.br +0 -0
- package/runtime/dist/bundles/lm-fonts/chunks/2.br +0 -0
- package/runtime/dist/bundles/lm-fonts/chunks/20.br +0 -0
- package/runtime/dist/bundles/lm-fonts/chunks/21.br +0 -0
- package/runtime/dist/bundles/lm-fonts/chunks/22.br +0 -0
- package/runtime/dist/bundles/lm-fonts/chunks/23.br +0 -0
- package/runtime/dist/bundles/lm-fonts/chunks/24.br +0 -0
- package/runtime/dist/bundles/lm-fonts/chunks/25.br +0 -0
- package/runtime/dist/bundles/lm-fonts/chunks/26.br +0 -0
- package/runtime/dist/bundles/lm-fonts/chunks/27.br +0 -0
- package/runtime/dist/bundles/lm-fonts/chunks/28.br +0 -0
- package/runtime/dist/bundles/lm-fonts/chunks/29.br +0 -0
- package/runtime/dist/bundles/lm-fonts/chunks/3.br +0 -0
- package/runtime/dist/bundles/lm-fonts/chunks/4.br +0 -0
- package/runtime/dist/bundles/lm-fonts/chunks/5.br +0 -0
- package/runtime/dist/bundles/lm-fonts/chunks/6.br +0 -0
- package/runtime/dist/bundles/lm-fonts/chunks/7.br +0 -0
- package/runtime/dist/bundles/lm-fonts/chunks/8.br +0 -0
- package/runtime/dist/bundles/lm-fonts/chunks/9.br +0 -0
- package/runtime/dist/bundles/lm-fonts/files.index.json +1 -1
- package/runtime/dist/bundles/luatex/chunks/0.br +0 -0
- package/runtime/dist/bundles/luatex/chunks/1.br +0 -0
- package/runtime/dist/bundles/luatex/files.index.json +1 -1
- package/runtime/dist/bundles/tex-plain/chunks/0.br +0 -0
- package/runtime/dist/bundles/tex-plain/chunks/1.br +0 -0
- package/runtime/dist/bundles/tex-plain/chunks/3.br +0 -0
- package/runtime/dist/bundles/tex-plain/chunks/4.br +0 -0
- package/runtime/dist/bundles/tex-plain/chunks/5.br +0 -0
- package/runtime/dist/bundles/tex-plain/chunks/6.br +0 -0
- package/runtime/dist/bundles/tex-plain/chunks/7.br +0 -0
- package/runtime/dist/bundles/tex-plain/files.index.json +1 -1
- package/runtime/dist/bundles/tikz-snapshot/chunks/1.br +0 -0
- package/runtime/dist/bundles/tikz-snapshot/files.index.json +1 -1
- package/runtime/dist/bundles/tikz-snapshot/manifest.json +1 -1
- package/runtime/dist/core.js +20 -13
- package/runtime/dist/texengine.d.ts +1 -0
- package/runtime/dist/types.d.ts +3 -3
- package/runtime/dist/vfs/lazyfs.d.ts +6 -1
- package/runtime/dist/vfs/lazyfs.js +17 -2
- package/src/browser-worker.js +1 -1
package/runtime/dist/types.d.ts
CHANGED
|
@@ -101,9 +101,9 @@ export interface MetaPostOptions {
|
|
|
101
101
|
/** Defer engine glue and MetaPost WASM until used. MetaPost version fields in creation
|
|
102
102
|
* metadata remain empty in this mode. No cross-request cache is required. */
|
|
103
103
|
lazy?: boolean;
|
|
104
|
-
/** Default for latex()'s snapshot option
|
|
105
|
-
*
|
|
106
|
-
*
|
|
104
|
+
/** Default for latex()'s snapshot option: Node 'auto', browser 'none'. Browser hosts
|
|
105
|
+
* may enable 'auto' when shipping precompiled formats (the @lofcz/tikz browser entry does).
|
|
106
|
+
* Auto uses basic TikZ when available and the full format for explicit plotting packages. */
|
|
107
107
|
snapshot?: 'auto' | 'none';
|
|
108
108
|
}
|
|
109
109
|
export type OutputFormat = 'svg' | 'eps' | 'json' | 'none';
|
|
@@ -12,6 +12,7 @@ export interface EmscriptenFS {
|
|
|
12
12
|
mkdir(path: string, mode?: number): void;
|
|
13
13
|
writeFile(path: string, data: Uint8Array | string, opts?: {
|
|
14
14
|
encoding?: string;
|
|
15
|
+
canOwn?: boolean;
|
|
15
16
|
}): void;
|
|
16
17
|
readFile(path: string, opts?: {
|
|
17
18
|
encoding?: 'binary' | 'utf8';
|
|
@@ -50,7 +51,7 @@ export declare function isUnloadedLazy(FS: EmscriptenFS, path: string): boolean;
|
|
|
50
51
|
/** Force-load a lazy node (no-op for ordinary files). */
|
|
51
52
|
export declare function ensureLoaded(FS: EmscriptenFS, path: string): void;
|
|
52
53
|
/** Write a text or binary file, creating directories as needed. */
|
|
53
|
-
export declare function writeFileDeep(FS: EmscriptenFS, path: string, data: Uint8Array | string): void;
|
|
54
|
+
export declare function writeFileDeep(FS: EmscriptenFS, path: string, data: Uint8Array | string, canOwn?: boolean): void;
|
|
54
55
|
/**
|
|
55
56
|
* Record every file opened for writing from now on (absolute paths, into the
|
|
56
57
|
* returned set). The engine's open syscall reaches the filesystem through
|
|
@@ -60,3 +61,7 @@ export declare function writeFileDeep(FS: EmscriptenFS, path: string, data: Uint
|
|
|
60
61
|
export declare function trackWrites(FS: EmscriptenFS): Set<string>;
|
|
61
62
|
/** Recursively collect regular files under `dir` (used to harvest artifacts). */
|
|
62
63
|
export declare function listFiles(FS: EmscriptenFS, dir: string): string[];
|
|
64
|
+
/** Borrow a completed MEMFS file; never retain a view into a module's WASM heap. */
|
|
65
|
+
export declare function completedFileBytes(FS: EmscriptenFS, path: string, heap?: Uint8Array): Uint8Array;
|
|
66
|
+
/** Auxiliary inputs remain available, but are copied only if the consumer opens them. */
|
|
67
|
+
export declare function writeDeferredFile(FS: EmscriptenFS, path: string, size: number, load: () => Uint8Array): void;
|
|
@@ -82,7 +82,7 @@ export function ensureLoaded(FS, path) {
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
/** Write a text or binary file, creating directories as needed. */
|
|
85
|
-
export function writeFileDeep(FS, path, data) {
|
|
85
|
+
export function writeFileDeep(FS, path, data, canOwn = false) {
|
|
86
86
|
const i = path.lastIndexOf('/');
|
|
87
87
|
if (i > 0)
|
|
88
88
|
mkdirp(FS, path.slice(0, i));
|
|
@@ -92,7 +92,7 @@ export function writeFileDeep(FS, path, data) {
|
|
|
92
92
|
}
|
|
93
93
|
catch { /* ignore */ }
|
|
94
94
|
}
|
|
95
|
-
FS.writeFile(path, data);
|
|
95
|
+
FS.writeFile(path, data, { canOwn });
|
|
96
96
|
}
|
|
97
97
|
/**
|
|
98
98
|
* Record every file opened for writing from now on (absolute paths, into the
|
|
@@ -130,4 +130,19 @@ export function listFiles(FS, dir) {
|
|
|
130
130
|
walk(dir);
|
|
131
131
|
return out;
|
|
132
132
|
}
|
|
133
|
+
/** Borrow a completed MEMFS file; never retain a view into a module's WASM heap. */
|
|
134
|
+
export function completedFileBytes(FS, path, heap) {
|
|
135
|
+
const node = FS.lookupPath(path).node;
|
|
136
|
+
if (heap && node.contents instanceof Uint8Array && node.contents.buffer !== heap.buffer &&
|
|
137
|
+
Number.isSafeInteger(node.usedBytes) && node.usedBytes >= 0 && node.usedBytes <= node.contents.length)
|
|
138
|
+
return node.contents.subarray(0, node.usedBytes);
|
|
139
|
+
return FS.readFile(path, { encoding: 'binary' });
|
|
140
|
+
}
|
|
141
|
+
/** Auxiliary inputs remain available, but are copied only if the consumer opens them. */
|
|
142
|
+
export function writeDeferredFile(FS, path, size, load) {
|
|
143
|
+
mkdirp(FS, path.slice(0, path.lastIndexOf('/')) || '/');
|
|
144
|
+
if (FS.analyzePath(path).exists)
|
|
145
|
+
FS.unlink(path);
|
|
146
|
+
createLazyFile(FS, path, size, () => load().slice());
|
|
147
|
+
}
|
|
133
148
|
//# sourceMappingURL=lazyfs.js.map
|
package/src/browser-worker.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MetaPost } from '../runtime/dist/index.js';
|
|
2
2
|
|
|
3
3
|
try {
|
|
4
|
-
const engine = await MetaPost.create({ worker: false, lazy: true, logLevel: 'silent' });
|
|
4
|
+
const engine = await MetaPost.create({ worker: false, lazy: true, snapshot: 'auto', logLevel: 'silent' });
|
|
5
5
|
self.onmessage = async ({ data: { source: code, maxOutputBytes } }) => {
|
|
6
6
|
try {
|
|
7
7
|
const source = /^\s*\\documentclass\b/m.test(code) ? code : String.raw`\documentclass[tikz,border=6pt]{standalone}
|