@zilijonas/foliark 0.1.3 → 0.1.5
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/README.md +2 -2
- package/SUPPORT_MATRIX.md +1 -1
- package/dist/document.js +4 -3
- package/dist/generated/EditPreview.d.ts +6 -0
- package/dist/generated/ParagraphInfo.d.ts +20 -0
- package/dist/generated/ParagraphSegment.d.ts +20 -0
- package/dist/generated/ParagraphSegment.js +1 -0
- package/dist/generated/StyleSpan.d.ts +8 -0
- package/dist/generated/StyleSpan.js +2 -0
- package/dist/generated/TextLook.d.ts +15 -0
- package/dist/generated/TextLook.js +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/worker-core.js +4 -4
- package/package.json +1 -1
- package/wasm/foliark_wasm.js +4 -0
- package/wasm/foliark_wasm_bg.wasm +0 -0
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<p align="center"><b>A PDF engine in Rust and WebAssembly for the browser. Extract, search, render, edit, redact and sanitize PDFs on the user's device. The document never leaves it.</b></p>
|
|
6
6
|
|
|
7
7
|
```sh
|
|
8
|
-
npm install @zilijonas/foliark@0.1.
|
|
8
|
+
npm install @zilijonas/foliark@0.1.5 --save-exact
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
ESM only, no runtime dependencies, typed. Runs in a worker, fetches only its own `.wasm` and worker script, and refuses what it cannot do safely with a typed `FoliarkError` instead of degrading quietly.
|
|
@@ -126,6 +126,6 @@ Chromium on desktop (macOS arm64) is supported and has budgets. WebKit is suppor
|
|
|
126
126
|
|
|
127
127
|
[AGPL-3.0-only](https://github.com/zilijonas/foliark/blob/main/LICENSE), the same licence family as the AGPL option PyMuPDF is offered under. If the AGPL does not fit your use, separate commercial licensing is available: see `COMMERCIAL-LICENSING.md` in the package. This is not legal advice. Details are in `LICENSING.md`.
|
|
128
128
|
|
|
129
|
-
Foliark is free software, so the complete corresponding source of version 0.1.
|
|
129
|
+
Foliark is free software, so the complete corresponding source of version 0.1.5 (Rust engine, vendored hayro fork and patches, build scripts) is tag `v0.1.5` of https://github.com/zilijonas/foliark. Build steps are in `docs/development.md` there (`scripts/build-wasm.sh`, `pnpm build:sdk`, `tests/package-consumers/pack.sh`). The package contains `dist/`, `wasm/` (5.8 MB raw, 2.2 MB gzip), `cmaps/`, `LICENSE`, `LICENSING.md`, `COMMERCIAL-LICENSING.md`, `LICENSE_FOXIT`, `NOTICE`, `THIRD_PARTY_NOTICES.md` and `SUPPORT_MATRIX.md`.
|
|
130
130
|
|
|
131
131
|
PyMuPDF and MuPDF are products of Artifex Software, Inc. Foliark is independent of them and not affiliated with Artifex.
|
package/SUPPORT_MATRIX.md
CHANGED
|
@@ -35,7 +35,7 @@ Host requirements, each tested in the browser specs: static files only, `applica
|
|
|
35
35
|
| Search, hit test, select | supported on the multi-column Unicode fixture (diacritic folding, column drag stays on its line) | `hddn-adapter.md` (NEW-67) | `INVALID_ARGUMENT` | regex and hyphenation-aware search are absent by design (spec 16); not wired into HDDN's UI |
|
|
36
36
|
| Render | supported with warnings | `native-roundtrip.md` (0 channel values off by more than 2/255 between input and output renders); reduced vs exact decode max diff 1 (`docs/performance/comparison.md`) | warnings `FONT_SUBSTITUTED`, `IMAGE_DECODE_FAILED`, `ANNOTATION_APPEARANCE_MISSING`, `CMAP_MISSING` (page is `complete:false`); `LIMIT_EXCEEDED` over `maxRenderPixels` | pixel accuracy against a second renderer on real documents (PyMuPDF differs by mean 0.02 to 3.1 levels on the scan fixtures) |
|
|
37
37
|
| Predefined CMaps (legacy CJK encodings) | supported (pack in the package) | `cmaps/` 63 Adobe files; fixture `generated/cjk-predefined-cmaps.pdf`: extract equals PyMuPDF, render has no `CMAP_MISSING`, redaction + native export judged by `objects.py`/PyMuPDF (`crates/foliark-engine/tests/cmaps.rs`), packed-package browser specs in 3 engines (`tests/browser/cmaps.spec.ts`) | `ASSET_LOAD_FAILED` at `open` for a missing or corrupt pack file; `CMAP_MISSING` for a name outside the predefined set; the pack must be served or copied by the caller (`docs/deployment.md`) | text redaction/edit on mixed-length encodings (RKSJ, EUC, UTF16): `FONT_UNSUPPORTED`; CJK glyphs of a non-embedded font are drawn missing |
|
|
38
|
-
| Paragraph edit | supported for horizontal, unrotated, left-to-right text in a registered or reusable font | `docs/adr/0003`, `0004`, `0005`, `0011`, `0012`; acceptance scenario E over 80 cases; HDDN adapter NEW-68 | `EDIT_NO_FONT`, `EDIT_NO_FIT`, `EDIT_NO_STYLE`, `EDIT_UNSUPPORTED_SCRIPT` (non-BMP, RTL), `EDIT_ROTATED_TEXT`, `FONT_UNSUPPORTED`, `STALE_REVISION` | CFF/Type1 embedded faces, RTL, CJK, vertical, auto-fit (spec 16) |
|
|
38
|
+
| Paragraph edit | supported for horizontal, unrotated, left-to-right text in a registered or reusable font | `docs/adr/0003`, `0004`, `0005`, `0011`, `0012`, `0013`; acceptance scenario E over 80 cases; HDDN adapter NEW-68 | `EDIT_NO_FONT`, `EDIT_NO_FIT`, `EDIT_NO_STYLE`, `EDIT_UNSUPPORTED_SCRIPT` (non-BMP, RTL), `EDIT_ROTATED_TEXT`, `FONT_UNSUPPORTED`, `STALE_REVISION` | CFF/Type1 embedded faces, RTL, CJK, vertical, auto-fit (spec 16) |
|
|
39
39
|
| Native export (sanitized rewrite) | supported | `strict-native.md`: 39 fixtures, 31 supported + 8 refused, 0 skipped, independent oracles, negative controls caught; acceptance 80 cases x 6 scenarios | `FORM_APPEARANCE_MISSING`, `XFA_UNSUPPORTED`, `OPTIONAL_CONTENT_UNSUPPORTED`, `SIGNED_INPUT` (policy `refuse`), `REDACT_*`, `STALE_PLAN`, `PLAN_CONSUMED` | what sections 3 and 4 list |
|
|
40
40
|
| Raster export (image-only, redactions burned in) | supported; needs `policy.raster.acknowledgeLosses` | acceptance: 143 SAFE + 17 refused raster results; `comparison.md` (30 pages, 10 regions, 0 words in the regions) | `CONSENT_REQUIRED`, `RENDER_INCOMPLETE {pages}` (3 acceptance cases, annotation-comment pinned by NEW-56) | encrypted raster fidelity; edge pixels touching a region are checked with a 0.26 pt inset |
|
|
41
41
|
| Cancellation | supported before an operation starts; results of aborted operations are atomic | acceptance: 27 attempts, finals byte-equal to a clean run | `CANCELLED` | abort while an operation runs through the packed SDK (only 3 pre-aborted attempts ended `CANCELLED`) |
|
package/dist/document.js
CHANGED
|
@@ -76,9 +76,10 @@ export function makeHandle(link, id, info) {
|
|
|
76
76
|
},
|
|
77
77
|
async prepareParagraph(p, rects, o) {
|
|
78
78
|
const r = await call("prepareParagraph", { page: page(p), rects, font: o?.font, editorFace: o?.editorFace });
|
|
79
|
-
// The
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
// The faces cross the worker boundary as transferred ArrayBuffers.
|
|
80
|
+
for (const x of [r, ...r.segments, ...r.looks])
|
|
81
|
+
if (x.editorFace)
|
|
82
|
+
x.editorFace.bytes = new Uint8Array(x.editorFace.bytes);
|
|
82
83
|
return r;
|
|
83
84
|
},
|
|
84
85
|
async layoutEdit(p, rects, text, o) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { LayoutRun } from "./LayoutRun";
|
|
2
2
|
import type { PreviewGlyph } from "./PreviewGlyph";
|
|
3
3
|
import type { PreviewLine } from "./PreviewLine";
|
|
4
|
+
import type { StyleSpan } from "./StyleSpan";
|
|
4
5
|
/**
|
|
5
6
|
* ADR 0004: the layout `applyChanges` would commit for one text edit, without committing.
|
|
6
7
|
*/
|
|
@@ -28,6 +29,11 @@ export type EditPreview = {
|
|
|
28
29
|
* Equals `ChangeResult.layouts[].fingerprint` for the same inputs.
|
|
29
30
|
*/
|
|
30
31
|
fingerprint: string;
|
|
32
|
+
/**
|
|
33
|
+
* Style runs of the whole normalized text sent (ADR 0013): UTF-16 ranges that tile it, each
|
|
34
|
+
* indexing the `looks` `prepareParagraph` returns for the same rects.
|
|
35
|
+
*/
|
|
36
|
+
styles: Array<StyleSpan>;
|
|
31
37
|
/**
|
|
32
38
|
* Only when asked for.
|
|
33
39
|
*/
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { EditorFace } from "./EditorFace";
|
|
2
2
|
import type { FontResolution } from "./FontResolution";
|
|
3
|
+
import type { ParagraphSegment } from "./ParagraphSegment";
|
|
3
4
|
import type { Rect } from "./Rect";
|
|
5
|
+
import type { StyleSpan } from "./StyleSpan";
|
|
6
|
+
import type { TextLook } from "./TextLook";
|
|
4
7
|
export type ParagraphInfo = {
|
|
5
8
|
docId: string;
|
|
6
9
|
revision: number;
|
|
@@ -23,4 +26,21 @@ export type ParagraphInfo = {
|
|
|
23
26
|
originalText: string | null;
|
|
24
27
|
font: FontResolution;
|
|
25
28
|
editorFace?: EditorFace | null;
|
|
29
|
+
/**
|
|
30
|
+
* ADR 0012's style segments, top to bottom; empty when `originalText` is null. Their ranges
|
|
31
|
+
* tile `originalText` exactly (a segment's hard-break LF ends it), so slicing the text at
|
|
32
|
+
* them and joining the slices gives it back. Each describes the page's own font, never the
|
|
33
|
+
* caller's.
|
|
34
|
+
*/
|
|
35
|
+
segments: Array<ParagraphSegment>;
|
|
36
|
+
/**
|
|
37
|
+
* The page styles the selection is drawn in (ADR 0013), each with the page's own font
|
|
38
|
+
* (never the caller's). `runs` and `EditPreview.styles` index them.
|
|
39
|
+
*/
|
|
40
|
+
looks: Array<TextLook>;
|
|
41
|
+
/**
|
|
42
|
+
* Style runs of `originalText`: UTF-16 ranges that tile it, each drawn in one look. Empty
|
|
43
|
+
* when `originalText` is null.
|
|
44
|
+
*/
|
|
45
|
+
runs: Array<StyleSpan>;
|
|
26
46
|
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { EditorFace } from "./EditorFace";
|
|
2
|
+
import type { FontResolution } from "./FontResolution";
|
|
3
|
+
/**
|
|
4
|
+
* One style segment of a paragraph: consecutive hard lines drawn in one look (ADR 0012).
|
|
5
|
+
*/
|
|
6
|
+
export type ParagraphSegment = {
|
|
7
|
+
/**
|
|
8
|
+
* UTF-16 offsets into `ParagraphInfo.originalText`, `start` inclusive.
|
|
9
|
+
*/
|
|
10
|
+
start: number;
|
|
11
|
+
end: number;
|
|
12
|
+
fontSize: number;
|
|
13
|
+
color: [number, number, number];
|
|
14
|
+
bold: boolean;
|
|
15
|
+
italic: boolean;
|
|
16
|
+
serif: boolean;
|
|
17
|
+
mono: boolean;
|
|
18
|
+
font: FontResolution;
|
|
19
|
+
editorFace?: EditorFace | null;
|
|
20
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { EditorFace } from "./EditorFace";
|
|
2
|
+
import type { FontResolution } from "./FontResolution";
|
|
3
|
+
/**
|
|
4
|
+
* One page style of a paragraph (ADR 0013), as `ParagraphSegment` describes a segment's.
|
|
5
|
+
*/
|
|
6
|
+
export type TextLook = {
|
|
7
|
+
fontSize: number;
|
|
8
|
+
color: [number, number, number];
|
|
9
|
+
bold: boolean;
|
|
10
|
+
italic: boolean;
|
|
11
|
+
serif: boolean;
|
|
12
|
+
mono: boolean;
|
|
13
|
+
font: FontResolution;
|
|
14
|
+
editorFace?: EditorFace | null;
|
|
15
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -31,6 +31,9 @@ export type { Limits } from "./generated/Limits.js";
|
|
|
31
31
|
export type { Matrix } from "./generated/Matrix.js";
|
|
32
32
|
export type { PageGeometry } from "./generated/PageGeometry.js";
|
|
33
33
|
export type { ParagraphInfo } from "./generated/ParagraphInfo.js";
|
|
34
|
+
export type { ParagraphSegment } from "./generated/ParagraphSegment.js";
|
|
35
|
+
export type { StyleSpan } from "./generated/StyleSpan.js";
|
|
36
|
+
export type { TextLook } from "./generated/TextLook.js";
|
|
34
37
|
export type { Point } from "./generated/Point.js";
|
|
35
38
|
export type { Quad } from "./generated/Quad.js";
|
|
36
39
|
export type { Rect } from "./generated/Rect.js";
|
package/dist/worker-core.js
CHANGED
|
@@ -152,10 +152,10 @@ export function createWorkerCore(host, stepBudget = STEP_BUDGET) {
|
|
|
152
152
|
return { result: e.registerFonts(a.fonts.map((f) => ({ ...f, bytes: new Uint8Array(f.bytes) }))) };
|
|
153
153
|
case "prepareParagraph": {
|
|
154
154
|
const r = e.prepareParagraph(d, a.page, a.rects, a.font, a.editorFace);
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
return { result: r, transfer:
|
|
155
|
+
const faces = [r, ...r.segments, ...r.looks].flatMap((x) => (x.editorFace ? [x.editorFace] : []));
|
|
156
|
+
for (const face of faces)
|
|
157
|
+
face.bytes = ownBuffer(face.bytes);
|
|
158
|
+
return { result: r, transfer: faces.map((face) => face.bytes) };
|
|
159
159
|
}
|
|
160
160
|
case "layoutEdit":
|
|
161
161
|
return { result: e.layoutEdit(d, a.page, a.rects, a.text, a.font, a.glyphs) };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zilijonas/foliark",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Rust/WebAssembly PDF SDK for the browser: extract text, render, edit, redact and sanitize PDFs offline. A PyMuPDF alternative. AGPL-3.0.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "AGPL-3.0-only",
|
package/wasm/foliark_wasm.js
CHANGED
|
@@ -604,6 +604,10 @@ function __wbg_get_imports() {
|
|
|
604
604
|
const ret = getObject(arg0)[arg1 >>> 0];
|
|
605
605
|
return addHeapObject(ret);
|
|
606
606
|
},
|
|
607
|
+
__wbg_get_806853698d9fc227: function() { return handleError(function (arg0, arg1) {
|
|
608
|
+
const ret = Reflect.get(getObject(arg0), arg1 >>> 0);
|
|
609
|
+
return addHeapObject(ret);
|
|
610
|
+
}, arguments); },
|
|
607
611
|
__wbg_get_unchecked_288889d017702237: function(arg0, arg1) {
|
|
608
612
|
const ret = getObject(arg0)[arg1 >>> 0];
|
|
609
613
|
return addHeapObject(ret);
|
|
Binary file
|