@junejs/pdf-typst-wasm 0.2.1 → 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/dist/{assets-0jc0W7Pm.d.ts → assets-B66CxsG8.d.ts} +0 -8
- package/dist/{assets-rrgfvCKs.js → assets-Bz9CTYyD.js} +4 -8
- package/dist/node.d.ts +1 -3
- package/dist/node.js +2 -3
- package/dist/typst.wasm.ref.json +2 -2
- package/dist/unbundled.d.ts +1 -3
- package/dist/unbundled.js +2 -3
- package/dist/workerd.d.ts +1 -3
- package/dist/workerd.js +2 -3
- package/package.json +4 -4
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { PdfRenderer } from "@junejs/pdf";
|
|
2
|
-
//#region src/engine.d.ts
|
|
3
2
|
type FontScope = "persistent" | "document";
|
|
4
3
|
type TypstOutput = {
|
|
5
4
|
pdf: Uint8Array;
|
|
@@ -16,8 +15,6 @@ declare class TypstCompileError extends Error {
|
|
|
16
15
|
}
|
|
17
16
|
type WasmSource = WebAssembly.Module | BufferSource;
|
|
18
17
|
declare function createEngine(wasm: WasmSource): Promise<TypstEngine>;
|
|
19
|
-
//#endregion
|
|
20
|
-
//#region src/fonts.d.ts
|
|
21
18
|
type FontEgress = {
|
|
22
19
|
host: string;
|
|
23
20
|
sends: "nothing" | "document-characters";
|
|
@@ -44,8 +41,6 @@ declare function googleFontSubsets(opts: {
|
|
|
44
41
|
families: GoogleFont[];
|
|
45
42
|
fetch?: typeof fetch;
|
|
46
43
|
}): FontProvider;
|
|
47
|
-
//#endregion
|
|
48
|
-
//#region src/renderer.d.ts
|
|
49
44
|
type TypstWasmRendererOptions = {
|
|
50
45
|
wasm?: WasmSource | (() => Promise<WasmSource>);
|
|
51
46
|
fonts?: FontProvider[];
|
|
@@ -55,8 +50,6 @@ type TypstWasmRendererOptions = {
|
|
|
55
50
|
interface TypstWasmRenderer extends PdfRenderer {
|
|
56
51
|
readonly egress: readonly FontEgress[];
|
|
57
52
|
}
|
|
58
|
-
//#endregion
|
|
59
|
-
//#region src/assets.d.ts
|
|
60
53
|
type AssetRef = {
|
|
61
54
|
name: string;
|
|
62
55
|
sha256: string;
|
|
@@ -65,5 +58,4 @@ type AssetRef = {
|
|
|
65
58
|
};
|
|
66
59
|
type AssetLoader = (ref: AssetRef) => Promise<Uint8Array | ArrayBuffer>;
|
|
67
60
|
declare function loadVerified(ref: AssetRef, load: AssetLoader): Promise<Uint8Array>;
|
|
68
|
-
//#endregion
|
|
69
61
|
export { WasmSource as _, TypstWasmRendererOptions as a, FontProvider as c, googleFontSubsets as d, localFonts as f, TypstOutput as g, TypstEngine as h, TypstWasmRenderer as i, FontSource as l, TypstCompileError as m, AssetRef as n, DocumentFonts as o, FontScope as p, loadVerified as r, FontEgress as s, AssetLoader as t, GoogleFont as u, createEngine as v };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PdfRenderError, typstSource } from "@junejs/pdf";
|
|
2
|
-
|
|
2
|
+
// src/engine.ts
|
|
3
3
|
var TypstCompileError = class extends Error {
|
|
4
4
|
constructor(message) {
|
|
5
5
|
super(message);
|
|
@@ -40,8 +40,7 @@ async function createEngine(wasm) {
|
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
|
-
|
|
44
|
-
//#region src/renderer.ts
|
|
43
|
+
// src/renderer.ts
|
|
45
44
|
const MISSING_SHOWN = 10;
|
|
46
45
|
function createTypstWasmRenderer(defaultWasm, opts = {}, engineEgress = []) {
|
|
47
46
|
const providers = [...opts.fonts ?? []];
|
|
@@ -110,8 +109,7 @@ async function fontsFor(doc, providers) {
|
|
|
110
109
|
function missingGlyphsMessage(missing, failed) {
|
|
111
110
|
return `no font available to the PDF renderer covers ${missing.slice(0, MISSING_SHOWN).join(" ")}${missing.length > MISSING_SHOWN ? ` (and ${missing.length - MISSING_SHOWN} more)` : ""}, so they would be missing from the document. ` + (failed.length ? `${failed.join("; ")}. ` : "") + "Remove them from the Markdown if they are decorative (emoji, symbols); otherwise tell the user the PDF can't include them until the app adds a font that covers them to typstWasmRenderer's `fonts` (localFonts or googleFontSubsets).";
|
|
112
111
|
}
|
|
113
|
-
|
|
114
|
-
//#region src/fonts.ts
|
|
112
|
+
// src/fonts.ts
|
|
115
113
|
function localFonts(input, opts = {}) {
|
|
116
114
|
const sources = [...input];
|
|
117
115
|
const fetcher = opts.fetch ?? fetch;
|
|
@@ -182,8 +180,7 @@ function googleSubset(cache, family, weight, text, fetcher) {
|
|
|
182
180
|
if (cache.size > SUBSET_CACHE_MAX) cache.delete(cache.keys().next().value);
|
|
183
181
|
return load;
|
|
184
182
|
}
|
|
185
|
-
|
|
186
|
-
//#region src/assets.ts
|
|
183
|
+
// src/assets.ts
|
|
187
184
|
async function loadVerified(ref, load) {
|
|
188
185
|
const got = await load(ref);
|
|
189
186
|
const bytes = got instanceof Uint8Array ? got.buffer instanceof SharedArrayBuffer ? got.slice() : got : new Uint8Array(got);
|
|
@@ -193,5 +190,4 @@ async function loadVerified(ref, load) {
|
|
|
193
190
|
if (hex !== ref.sha256) throw new Error(`${ref.name}: the loader returned bytes with sha256 ${hex}, expected ${ref.sha256}`);
|
|
194
191
|
return bytes;
|
|
195
192
|
}
|
|
196
|
-
//#endregion
|
|
197
193
|
export { TypstCompileError as a, createTypstWasmRenderer as i, googleFontSubsets as n, createEngine as o, localFonts as r, loadVerified as t };
|
package/dist/node.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { _ as WasmSource, a as TypstWasmRendererOptions, c as FontProvider, d as googleFontSubsets, f as localFonts, g as TypstOutput, h as TypstEngine, i as TypstWasmRenderer, l as FontSource, m as TypstCompileError, n as AssetRef, o as DocumentFonts, p as FontScope, r as loadVerified, s as FontEgress, t as AssetLoader, u as GoogleFont, v as createEngine } from "./assets-
|
|
2
|
-
//#region src/node.d.ts
|
|
1
|
+
import { _ as WasmSource, a as TypstWasmRendererOptions, c as FontProvider, d as googleFontSubsets, f as localFonts, g as TypstOutput, h as TypstEngine, i as TypstWasmRenderer, l as FontSource, m as TypstCompileError, n as AssetRef, o as DocumentFonts, p as FontScope, r as loadVerified, s as FontEgress, t as AssetLoader, u as GoogleFont, v as createEngine } from "./assets-B66CxsG8.js";
|
|
3
2
|
export declare const WASM_URL: URL;
|
|
4
3
|
export declare function typstWasmRenderer(opts?: TypstWasmRendererOptions): TypstWasmRenderer;
|
|
5
|
-
//#endregion
|
|
6
4
|
export { type AssetLoader, type AssetRef, type DocumentFonts, type FontEgress, type FontProvider, type FontScope, type FontSource, type GoogleFont, TypstCompileError, type TypstEngine, type TypstOutput, type TypstWasmRenderer, type TypstWasmRendererOptions, type WasmSource, createEngine, googleFontSubsets, loadVerified, localFonts };
|
package/dist/node.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as TypstCompileError, i as createTypstWasmRenderer, n as googleFontSubsets, o as createEngine, r as localFonts, t as loadVerified } from "./assets-
|
|
2
|
-
|
|
1
|
+
import { a as TypstCompileError, i as createTypstWasmRenderer, n as googleFontSubsets, o as createEngine, r as localFonts, t as loadVerified } from "./assets-Bz9CTYyD.js";
|
|
2
|
+
// src/node.ts
|
|
3
3
|
const WASM_URL = new URL("../dist/typst.wasm", import.meta.url);
|
|
4
4
|
let compiled;
|
|
5
5
|
async function loadWasm() {
|
|
@@ -20,5 +20,4 @@ async function loadWasm() {
|
|
|
20
20
|
function typstWasmRenderer(opts = {}) {
|
|
21
21
|
return createTypstWasmRenderer(loadWasm, opts);
|
|
22
22
|
}
|
|
23
|
-
//#endregion
|
|
24
23
|
export { TypstCompileError, WASM_URL, createEngine, googleFontSubsets, loadVerified, localFonts, typstWasmRenderer };
|
package/dist/typst.wasm.ref.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"sha256": "65482a22d5c7fa257bce3f0bf9531548f1f553427d29b783ff84b346f678517f",
|
|
4
4
|
"size": 30456380,
|
|
5
5
|
"urls": [
|
|
6
|
-
"https://cdn.jsdelivr.net/npm/@junejs/pdf-typst-wasm@0.2.
|
|
7
|
-
"https://unpkg.com/@junejs/pdf-typst-wasm@0.2.
|
|
6
|
+
"https://cdn.jsdelivr.net/npm/@junejs/pdf-typst-wasm@0.2.3/dist/typst.wasm",
|
|
7
|
+
"https://unpkg.com/@junejs/pdf-typst-wasm@0.2.3/dist/typst.wasm"
|
|
8
8
|
]
|
|
9
9
|
}
|
package/dist/unbundled.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { _ as WasmSource, a as TypstWasmRendererOptions, c as FontProvider, d as googleFontSubsets, f as localFonts, g as TypstOutput, h as TypstEngine, i as TypstWasmRenderer, l as FontSource, m as TypstCompileError, n as AssetRef, o as DocumentFonts, p as FontScope, r as loadVerified, s as FontEgress, t as AssetLoader, u as GoogleFont, v as createEngine } from "./assets-
|
|
2
|
-
//#region src/unbundled.d.ts
|
|
1
|
+
import { _ as WasmSource, a as TypstWasmRendererOptions, c as FontProvider, d as googleFontSubsets, f as localFonts, g as TypstOutput, h as TypstEngine, i as TypstWasmRenderer, l as FontSource, m as TypstCompileError, n as AssetRef, o as DocumentFonts, p as FontScope, r as loadVerified, s as FontEgress, t as AssetLoader, u as GoogleFont, v as createEngine } from "./assets-B66CxsG8.js";
|
|
3
2
|
export declare function engineUrls(version: string): string[];
|
|
4
3
|
export declare function typstWasmAsset(): Promise<AssetRef>;
|
|
5
4
|
export type UnbundledRendererOptions = Omit<TypstWasmRendererOptions, "wasm"> & {
|
|
@@ -7,5 +6,4 @@ export type UnbundledRendererOptions = Omit<TypstWasmRendererOptions, "wasm"> &
|
|
|
7
6
|
engineEgress?: FontEgress[];
|
|
8
7
|
};
|
|
9
8
|
export declare function typstWasmRenderer(opts: UnbundledRendererOptions): TypstWasmRenderer;
|
|
10
|
-
//#endregion
|
|
11
9
|
export { type AssetLoader, type AssetRef, type DocumentFonts, type FontEgress, type FontProvider, type FontScope, type FontSource, type GoogleFont, TypstCompileError, type TypstEngine, type TypstOutput, type TypstWasmRenderer, type WasmSource, createEngine, googleFontSubsets, loadVerified, localFonts };
|
package/dist/unbundled.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as TypstCompileError, i as createTypstWasmRenderer, n as googleFontSubsets, o as createEngine, r as localFonts, t as loadVerified } from "./assets-
|
|
2
|
-
|
|
1
|
+
import { a as TypstCompileError, i as createTypstWasmRenderer, n as googleFontSubsets, o as createEngine, r as localFonts, t as loadVerified } from "./assets-Bz9CTYyD.js";
|
|
2
|
+
// src/unbundled.ts
|
|
3
3
|
function engineUrls(version) {
|
|
4
4
|
return [`https://cdn.jsdelivr.net/npm/@junejs/pdf-typst-wasm@${version}/dist/typst.wasm`, `https://unpkg.com/@junejs/pdf-typst-wasm@${version}/dist/typst.wasm`];
|
|
5
5
|
}
|
|
@@ -18,5 +18,4 @@ function typstWasmRenderer(opts) {
|
|
|
18
18
|
const { load, engineEgress, ...rest } = opts;
|
|
19
19
|
return createTypstWasmRenderer(async () => loadVerified(await typstWasmAsset(), load), rest, engineEgress ?? ENGINE_HOSTS);
|
|
20
20
|
}
|
|
21
|
-
//#endregion
|
|
22
21
|
export { TypstCompileError, createEngine, engineUrls, googleFontSubsets, loadVerified, localFonts, typstWasmAsset, typstWasmRenderer };
|
package/dist/workerd.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { _ as WasmSource, a as TypstWasmRendererOptions, c as FontProvider, d as googleFontSubsets, f as localFonts, g as TypstOutput, h as TypstEngine, i as TypstWasmRenderer, l as FontSource, m as TypstCompileError, n as AssetRef, o as DocumentFonts, p as FontScope, r as loadVerified, s as FontEgress, t as AssetLoader, u as GoogleFont, v as createEngine } from "./assets-
|
|
2
|
-
//#region src/workerd.d.ts
|
|
1
|
+
import { _ as WasmSource, a as TypstWasmRendererOptions, c as FontProvider, d as googleFontSubsets, f as localFonts, g as TypstOutput, h as TypstEngine, i as TypstWasmRenderer, l as FontSource, m as TypstCompileError, n as AssetRef, o as DocumentFonts, p as FontScope, r as loadVerified, s as FontEgress, t as AssetLoader, u as GoogleFont, v as createEngine } from "./assets-B66CxsG8.js";
|
|
3
2
|
export declare function typstWasmRenderer(opts?: TypstWasmRendererOptions): TypstWasmRenderer;
|
|
4
|
-
//#endregion
|
|
5
3
|
export { type AssetLoader, type AssetRef, type DocumentFonts, type FontEgress, type FontProvider, type FontScope, type FontSource, type GoogleFont, TypstCompileError, type TypstEngine, type TypstOutput, type TypstWasmRenderer, type TypstWasmRendererOptions, type WasmSource, createEngine, googleFontSubsets, loadVerified, localFonts };
|
package/dist/workerd.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { a as TypstCompileError, i as createTypstWasmRenderer, n as googleFontSubsets, o as createEngine, r as localFonts, t as loadVerified } from "./assets-
|
|
1
|
+
import { a as TypstCompileError, i as createTypstWasmRenderer, n as googleFontSubsets, o as createEngine, r as localFonts, t as loadVerified } from "./assets-Bz9CTYyD.js";
|
|
2
2
|
import wasm from "../dist/typst.wasm";
|
|
3
|
-
|
|
3
|
+
// src/workerd.ts
|
|
4
4
|
function typstWasmRenderer(opts = {}) {
|
|
5
5
|
return createTypstWasmRenderer(async () => wasm, opts);
|
|
6
6
|
}
|
|
7
|
-
//#endregion
|
|
8
7
|
export { TypstCompileError, createEngine, googleFontSubsets, loadVerified, localFonts, typstWasmRenderer };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@junejs/pdf-typst-wasm",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "June — a PdfRenderer on a Typst to PDF engine compiled to WebAssembly: no browser, no native binary, and it runs on Cloudflare Workers.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
"test": "bun test"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@junejs/pdf": "^0.2.
|
|
46
|
+
"@junejs/pdf": "^0.2.3"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@junejs/core": "^0.2.
|
|
50
|
-
"@junejs/server": "^0.2.
|
|
49
|
+
"@junejs/core": "^0.2.3",
|
|
50
|
+
"@junejs/server": "^0.2.3"
|
|
51
51
|
},
|
|
52
52
|
"keywords": [
|
|
53
53
|
"june",
|