@laminapdf/sdk 0.2.0-alpha.2 → 0.2.0-alpha.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/README.md +42 -7
- package/dist/api.d.ts +5 -2
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +3 -2
- package/dist/api.js.map +1 -1
- package/dist/builder.d.ts +35 -19
- package/dist/builder.d.ts.map +1 -1
- package/dist/builder.js +114 -80
- package/dist/builder.js.map +1 -1
- package/dist/document.d.ts +47 -21
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +112 -67
- package/dist/document.js.map +1 -1
- package/dist/errors.d.ts +5 -5
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +10 -16
- package/dist/errors.js.map +1 -1
- package/dist/extract.d.ts +57 -0
- package/dist/extract.d.ts.map +1 -0
- package/dist/extract.js +5 -0
- package/dist/extract.js.map +1 -0
- package/dist/font.d.ts +13 -6
- package/dist/font.d.ts.map +1 -1
- package/dist/font.js +50 -20
- package/dist/font.js.map +1 -1
- package/dist/generated/codes.d.ts +18 -6
- package/dist/generated/codes.d.ts.map +1 -1
- package/dist/generated/codes.js +59 -4
- package/dist/generated/codes.js.map +1 -1
- package/dist/generated/explain.d.ts.map +1 -1
- package/dist/generated/explain.js +27 -10
- package/dist/generated/explain.js.map +1 -1
- package/dist/generated/extract.d.ts +235 -0
- package/dist/generated/extract.d.ts.map +1 -0
- package/dist/generated/extract.js +4 -0
- package/dist/generated/extract.js.map +1 -0
- package/dist/init.d.ts +13 -5
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +23 -11
- package/dist/init.js.map +1 -1
- package/dist/internal/handle.d.ts +58 -0
- package/dist/internal/handle.d.ts.map +1 -0
- package/dist/internal/handle.js +113 -0
- package/dist/internal/handle.js.map +1 -0
- package/dist/internal/instance.d.ts +56 -0
- package/dist/internal/instance.d.ts.map +1 -0
- package/dist/internal/instance.js +125 -0
- package/dist/internal/instance.js.map +1 -0
- package/dist/source/http.js +1 -1
- package/dist/source/http.js.map +1 -1
- package/dist/source/range.d.ts +6 -1
- package/dist/source/range.d.ts.map +1 -1
- package/dist/source/range.js +10 -6
- package/dist/source/range.js.map +1 -1
- package/dist/text.d.ts +3 -3
- package/dist/text.d.ts.map +1 -1
- package/dist/text.js +3 -3
- package/dist/text.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +2 -2
- package/dist/version.js.map +1 -1
- package/dist/worker/client.d.ts +3 -2
- package/dist/worker/client.d.ts.map +1 -1
- package/dist/worker/client.js +6 -4
- package/dist/worker/client.js.map +1 -1
- package/dist/worker/entry.js +1 -1
- package/dist/worker/entry.js.map +1 -1
- package/dist/worker/server.d.ts.map +1 -1
- package/dist/worker/server.js +42 -9
- package/dist/worker/server.js.map +1 -1
- package/dist/worker/support.d.ts +6 -2
- package/dist/worker/support.d.ts.map +1 -1
- package/dist/worker/support.js +1 -0
- package/dist/worker/support.js.map +1 -1
- package/dist/worker/types.d.ts +8 -1
- package/dist/worker/types.d.ts.map +1 -1
- package/docs/AGENTS.md +14 -0
- package/docs/api/README.md +147 -0
- package/docs/api/classes/Builder.md +467 -0
- package/docs/api/classes/Document.md +742 -0
- package/docs/api/classes/Font.md +74 -0
- package/docs/api/classes/Image.md +140 -0
- package/docs/api/classes/LaminaPdfError.md +189 -0
- package/docs/api/classes/Page.md +178 -0
- package/docs/api/classes/PageRef.md +253 -0
- package/docs/api/classes/PageText.md +129 -0
- package/docs/api/classes/PageTextRun.md +167 -0
- package/docs/api/classes/PendingPath.md +97 -0
- package/docs/api/classes/SaveJob.md +205 -0
- package/docs/api/classes/Surface.md +326 -0
- package/docs/api/classes/Transaction.md +111 -0
- package/docs/api/functions/callbackSource.md +33 -0
- package/docs/api/functions/httpRangeSource.md +48 -0
- package/docs/api/functions/init.md +36 -0
- package/docs/api/functions/isExtractLoaded.md +21 -0
- package/docs/api/functions/isInitialized.md +19 -0
- package/docs/api/functions/isLaminaPdfError.md +41 -0
- package/docs/api/functions/isTextLoaded.md +19 -0
- package/docs/api/functions/loadExtract.md +28 -0
- package/docs/api/functions/loadText.md +28 -0
- package/docs/api/functions/onLeak.md +29 -0
- package/docs/api/functions/reset.md +22 -0
- package/docs/api/functions/wasmMemory.md +22 -0
- package/docs/api/interfaces/BuilderOptions.md +108 -0
- package/docs/api/interfaces/ByteRange.md +29 -0
- package/docs/api/interfaces/ChunkOptions.md +37 -0
- package/docs/api/interfaces/Diagnostic.md +67 -0
- package/docs/api/interfaces/ExtractOptions.md +92 -0
- package/docs/api/interfaces/ExtractResult.md +37 -0
- package/docs/api/interfaces/FontInfo.md +37 -0
- package/docs/api/interfaces/HttpRangeOptions.md +78 -0
- package/docs/api/interfaces/InitOptions.md +40 -0
- package/docs/api/interfaces/Leak.md +21 -0
- package/docs/api/interfaces/Location.md +53 -0
- package/docs/api/interfaces/OpLog.md +25 -0
- package/docs/api/interfaces/OpenOptions.md +37 -0
- package/docs/api/interfaces/PageTextOptions.md +21 -0
- package/docs/api/interfaces/PathBuilder.md +195 -0
- package/docs/api/interfaces/QuadPoint.md +25 -0
- package/docs/api/interfaces/RangeOptions.md +54 -0
- package/docs/api/interfaces/RangeSource.md +59 -0
- package/docs/api/interfaces/StrokeStyle.md +61 -0
- package/docs/api/interfaces/TagSpec.md +69 -0
- package/docs/api/interfaces/TextBoxOptions.md +93 -0
- package/docs/api/interfaces/TextGlyph.md +29 -0
- package/docs/api/interfaces/TextOptions.md +101 -0
- package/docs/api/interfaces/WasmMemory.md +37 -0
- package/docs/api/type-aliases/AfRelationship.md +15 -0
- package/docs/api/type-aliases/Align.md +15 -0
- package/docs/api/type-aliases/ArtifactKind.md +15 -0
- package/docs/api/type-aliases/AttachmentOptions.md +15 -0
- package/docs/api/type-aliases/BlendMode.md +15 -0
- package/docs/api/type-aliases/BoxRect.md +15 -0
- package/docs/api/type-aliases/BuildOptions.md +15 -0
- package/docs/api/type-aliases/Cell.md +71 -0
- package/docs/api/type-aliases/Chunk.md +79 -0
- package/docs/api/type-aliases/Color.md +16 -0
- package/docs/api/type-aliases/Coordinates.md +55 -0
- package/docs/api/type-aliases/Direction.md +15 -0
- package/docs/api/type-aliases/DocumentInfo.md +15 -0
- package/docs/api/type-aliases/DropReason.md +15 -0
- package/docs/api/type-aliases/Dropped.md +59 -0
- package/docs/api/type-aliases/Edited.md +15 -0
- package/docs/api/type-aliases/ErrorCode.md +15 -0
- package/docs/api/type-aliases/ErrorKind.md +15 -0
- package/docs/api/type-aliases/ExtractFormat.md +15 -0
- package/docs/api/type-aliases/ExtractedBlock.md +82 -0
- package/docs/api/type-aliases/ExtractedPage.md +65 -0
- package/docs/api/type-aliases/ExtractedSource.md +48 -0
- package/docs/api/type-aliases/Extraction.md +22 -0
- package/docs/api/type-aliases/FillRule.md +15 -0
- package/docs/api/type-aliases/Fit.md +15 -0
- package/docs/api/type-aliases/Flags.md +15 -0
- package/docs/api/type-aliases/Generator.md +41 -0
- package/docs/api/type-aliases/GlyphQuad.md +15 -0
- package/docs/api/type-aliases/InfoPatch.md +15 -0
- package/docs/api/type-aliases/LaminaPdfWarning.md +16 -0
- package/docs/api/type-aliases/LimitName.md +15 -0
- package/docs/api/type-aliases/Limits.md +15 -0
- package/docs/api/type-aliases/LineBox.md +15 -0
- package/docs/api/type-aliases/LineCap.md +15 -0
- package/docs/api/type-aliases/LineJoin.md +15 -0
- package/docs/api/type-aliases/LinkTarget.md +15 -0
- package/docs/api/type-aliases/Metadata.md +15 -0
- package/docs/api/type-aliases/Op.md +15 -0
- package/docs/api/type-aliases/OutlineEntry.md +15 -0
- package/docs/api/type-aliases/Overflow.md +15 -0
- package/docs/api/type-aliases/PageInfo.md +15 -0
- package/docs/api/type-aliases/PageLabel.md +15 -0
- package/docs/api/type-aliases/PageSizeName.md +15 -0
- package/docs/api/type-aliases/Point.md +15 -0
- package/docs/api/type-aliases/Profile.md +15 -0
- package/docs/api/type-aliases/Progress.md +15 -0
- package/docs/api/type-aliases/ReadingOrder.md +15 -0
- package/docs/api/type-aliases/Rect.md +15 -0
- package/docs/api/type-aliases/Region.md +31 -0
- package/docs/api/type-aliases/RenderMode.md +15 -0
- package/docs/api/type-aliases/Rotation.md +15 -0
- package/docs/api/type-aliases/SaveOptions.md +15 -0
- package/docs/api/type-aliases/SaveReport.md +15 -0
- package/docs/api/type-aliases/Span.md +63 -0
- package/docs/api/type-aliases/SplitOn.md +15 -0
- package/docs/api/type-aliases/Standard14.md +15 -0
- package/docs/api/type-aliases/StructRef.md +41 -0
- package/docs/api/type-aliases/StructSource.md +17 -0
- package/docs/api/type-aliases/TableDetector.md +15 -0
- package/docs/api/type-aliases/TableMode.md +15 -0
- package/docs/api/type-aliases/TableScope.md +15 -0
- package/docs/api/type-aliases/Tag.md +15 -0
- package/docs/api/type-aliases/TagName.md +15 -0
- package/docs/api/type-aliases/TextLayout.md +15 -0
- package/docs/api/type-aliases/TextRange.md +33 -0
- package/docs/api/type-aliases/TextRunInfo.md +15 -0
- package/docs/api/type-aliases/Transform.md +15 -0
- package/docs/api/type-aliases/UndoOutcome.md +15 -0
- package/docs/api/type-aliases/ViewerPreferences.md +15 -0
- package/docs/api/type-aliases/WarningCode.md +15 -0
- package/docs/api/type-aliases/WasmSource.md +16 -0
- package/docs/api/variables/Matrix.md +99 -0
- package/docs/api/variables/PAGE_SIZES.md +15 -0
- package/docs/api/variables/TAG_NAMES.md +15 -0
- package/docs/errors/README.md +156 -0
- package/docs/errors/aes-padding-invalid.md +34 -0
- package/docs/errors/already-initialized.md +34 -0
- package/docs/errors/binary-output-to-terminal.md +35 -0
- package/docs/errors/builder-finished.md +35 -0
- package/docs/errors/cancelled.md +35 -0
- package/docs/errors/cmap-invalid.md +42 -0
- package/docs/errors/collection-index.md +33 -0
- package/docs/errors/color-components.md +33 -0
- package/docs/errors/content-bad-operands.md +36 -0
- package/docs/errors/content-path-unpainted.md +36 -0
- package/docs/errors/content-resource-missing.md +37 -0
- package/docs/errors/content-syntax.md +36 -0
- package/docs/errors/content-unbalanced-bt.md +36 -0
- package/docs/errors/content-unbalanced-marked.md +36 -0
- package/docs/errors/content-unbalanced-q.md +36 -0
- package/docs/errors/content-unknown-operator.md +37 -0
- package/docs/errors/data-pending.md +34 -0
- package/docs/errors/decompress.md +34 -0
- package/docs/errors/device-color-without-output-intent.md +33 -0
- package/docs/errors/direct-page.md +34 -0
- package/docs/errors/disposed.md +34 -0
- package/docs/errors/document-changed.md +34 -0
- package/docs/errors/embedded-file-forbidden.md +35 -0
- package/docs/errors/embedded-file-without-mime-type.md +36 -0
- package/docs/errors/encoding-full.md +34 -0
- package/docs/errors/encrypted-base.md +33 -0
- package/docs/errors/extract-limit-blocks.md +35 -0
- package/docs/errors/extract-module-not-loaded.md +37 -0
- package/docs/errors/extract-reading-order-ambiguous.md +32 -0
- package/docs/errors/extract-struct-tree-ignored.md +32 -0
- package/docs/errors/extract-table-ambiguous.md +32 -0
- package/docs/errors/extract-table-limit.md +35 -0
- package/docs/errors/extract-untagged-content.md +32 -0
- package/docs/errors/fetch-failed.md +34 -0
- package/docs/errors/flate-truncated.md +34 -0
- package/docs/errors/font-invalid.md +36 -0
- package/docs/errors/font-mismatch.md +34 -0
- package/docs/errors/font-not-embeddable.md +34 -0
- package/docs/errors/font-not-embedded.md +35 -0
- package/docs/errors/font-not-shapable.md +33 -0
- package/docs/errors/glyph-out-of-range.md +34 -0
- package/docs/errors/glyph-without-unicode.md +35 -0
- package/docs/errors/heading-level-skipped.md +36 -0
- package/docs/errors/image-data-length.md +33 -0
- package/docs/errors/image-too-large.md +32 -0
- package/docs/errors/inline-image-unterminated.md +36 -0
- package/docs/errors/input-unreadable.md +37 -0
- package/docs/errors/instance-reset.md +34 -0
- package/docs/errors/invalid-argument.md +33 -0
- package/docs/errors/invalid-axis-value.md +32 -0
- package/docs/errors/invalid-box.md +34 -0
- package/docs/errors/invalid-color.md +32 -0
- package/docs/errors/invalid-command-line.md +44 -0
- package/docs/errors/invalid-date.md +34 -0
- package/docs/errors/invalid-entry.md +34 -0
- package/docs/errors/invalid-feature.md +32 -0
- package/docs/errors/invalid-font.md +32 -0
- package/docs/errors/invalid-geometry.md +32 -0
- package/docs/errors/invalid-icc-profile.md +32 -0
- package/docs/errors/invalid-image.md +33 -0
- package/docs/errors/invalid-op-log.md +33 -0
- package/docs/errors/invalid-page-label.md +34 -0
- package/docs/errors/invalid-page-labels.md +32 -0
- package/docs/errors/invalid-page-range.md +37 -0
- package/docs/errors/invalid-rotate.md +34 -0
- package/docs/errors/invalid-structure-nesting.md +38 -0
- package/docs/errors/invalid-structure.md +34 -0
- package/docs/errors/invalid-text-range.md +33 -0
- package/docs/errors/job-finished.md +34 -0
- package/docs/errors/limit-exceeded.md +38 -0
- package/docs/errors/link-without-contents.md +33 -0
- package/docs/errors/link-without-structure.md +37 -0
- package/docs/errors/missing-alt-text.md +33 -0
- package/docs/errors/missing-glyph.md +33 -0
- package/docs/errors/missing-header.md +37 -0
- package/docs/errors/missing-lang.md +32 -0
- package/docs/errors/missing-root.md +34 -0
- package/docs/errors/missing-title.md +32 -0
- package/docs/errors/name-tree-node-skipped.md +34 -0
- package/docs/errors/nested-transaction.md +34 -0
- package/docs/errors/no-pending-save.md +32 -0
- package/docs/errors/no-transaction.md +33 -0
- package/docs/errors/not-initialized.md +35 -0
- package/docs/errors/not-pdf.md +33 -0
- package/docs/errors/not-rebased.md +35 -0
- package/docs/errors/object-number-out-of-range.md +38 -0
- package/docs/errors/objstm-index-mismatch.md +36 -0
- package/docs/errors/out-of-memory.md +38 -0
- package/docs/errors/outline-cycle.md +34 -0
- package/docs/errors/outline-item-skipped.md +34 -0
- package/docs/errors/output-unwritable.md +37 -0
- package/docs/errors/overwrite-refused.md +36 -0
- package/docs/errors/page-count-mismatch.md +34 -0
- package/docs/errors/page-index-out-of-range.md +34 -0
- package/docs/errors/page-tree-node-skipped.md +35 -0
- package/docs/errors/password-required.md +36 -0
- package/docs/errors/path-outside-roots.md +32 -0
- package/docs/errors/perms-mismatch.md +34 -0
- package/docs/errors/profile-version-conflict.md +35 -0
- package/docs/errors/reference-cycle.md +35 -0
- package/docs/errors/render-backend-unavailable.md +32 -0
- package/docs/errors/render-failed.md +33 -0
- package/docs/errors/render-too-large.md +36 -0
- package/docs/errors/repaired-base.md +34 -0
- package/docs/errors/requires-rewrite.md +38 -0
- package/docs/errors/saved-not-rebased.md +34 -0
- package/docs/errors/sink-not-empty.md +33 -0
- package/docs/errors/sink.md +31 -0
- package/docs/errors/source-budget-exceeded.md +34 -0
- package/docs/errors/source-changed.md +33 -0
- package/docs/errors/source.md +30 -0
- package/docs/errors/stale-generation.md +34 -0
- package/docs/errors/stream-length-recovered.md +37 -0
- package/docs/errors/strict.md +34 -0
- package/docs/errors/subset-failed.md +31 -0
- package/docs/errors/syntax.md +34 -0
- package/docs/errors/text-module-not-loaded.md +36 -0
- package/docs/errors/text-overflow.md +34 -0
- package/docs/errors/tounicode-conflict.md +32 -0
- package/docs/errors/type.md +34 -0
- package/docs/errors/unexpected-eof.md +34 -0
- package/docs/errors/unknown-axis.md +33 -0
- package/docs/errors/unknown-code.md +36 -0
- package/docs/errors/unknown-destination.md +33 -0
- package/docs/errors/unknown-font.md +33 -0
- package/docs/errors/unknown-option.md +33 -0
- package/docs/errors/unknown-page.md +34 -0
- package/docs/errors/unmapped-glyph.md +36 -0
- package/docs/errors/unnumbered-heading-misused.md +34 -0
- package/docs/errors/unset-object.md +30 -0
- package/docs/errors/unsupported-filter.md +34 -0
- package/docs/errors/unsupported-image.md +33 -0
- package/docs/errors/unsupported-layout-option.md +33 -0
- package/docs/errors/unsupported-security-handler.md +34 -0
- package/docs/errors/unsupported-version.md +32 -0
- package/docs/errors/untagged-content.md +35 -0
- package/docs/errors/warnings-truncated.md +35 -0
- package/docs/errors/wasm-trap.md +37 -0
- package/docs/errors/whole-font-rebuilt.md +30 -0
- package/docs/errors/worker-crashed.md +33 -0
- package/docs/errors/worker-failed.md +32 -0
- package/docs/errors/worker-version-mismatch.md +34 -0
- package/docs/errors/would-invalidate-signatures.md +38 -0
- package/docs/errors/wrong-document.md +33 -0
- package/docs/errors/wrong-password.md +34 -0
- package/docs/errors/xobject-cycle.md +36 -0
- package/docs/errors/xref-repaired.md +36 -0
- package/docs/errors/xrefstm-ignored.md +34 -0
- package/docs/llms.txt +88 -0
- package/docs/pages/concepts/dependencies.md +44 -0
- package/docs/pages/concepts/errors-and-warnings.md +64 -0
- package/docs/pages/concepts/how-lamina-thinks.md +86 -0
- package/docs/pages/concepts/pages-and-coordinates.md +67 -0
- package/docs/pages/guides/accessible-pdfs.md +260 -0
- package/docs/pages/guides/archival-pdfs.md +429 -0
- package/docs/pages/guides/edit-a-pdf.md +137 -0
- package/docs/pages/guides/fonts-and-text.md +202 -0
- package/docs/pages/guides/images-and-vectors.md +219 -0
- package/docs/pages/guides/keep-the-page-responsive.md +81 -0
- package/docs/pages/guides/links-outlines-and-metadata.md +222 -0
- package/docs/pages/guides/password-protected-files.md +70 -0
- package/docs/pages/guides/save-a-pdf.md +144 -0
- package/docs/pages/guides/untrusted-files.md +80 -0
- package/docs/pages/index.md +33 -0
- package/docs/pages/install.md +75 -0
- package/docs/pages/quick-start/browser.md +67 -0
- package/docs/pages/quick-start/bun.md +60 -0
- package/docs/pages/quick-start/deno.md +58 -0
- package/docs/pages/quick-start/node.md +61 -0
- package/docs/pages/quick-start/rust.md +58 -0
- package/docs/pages/quick-start/workers.md +139 -0
- package/docs/pages/recipes/cloudflare-worker.md +115 -0
- package/docs/pages/recipes/extract-markdown.md +114 -0
- package/docs/pages/recipes/generate-then-edit.md +135 -0
- package/docs/pages/recipes/hello.md +94 -0
- package/docs/pages/recipes/images-and-vectors.md +209 -0
- package/docs/pages/recipes/invoice.md +226 -0
- package/docs/pages/recipes/links-and-outlines.md +215 -0
- package/docs/pages/recipes/multilingual.md +189 -0
- package/docs/pages/recipes/open-untrusted.md +65 -0
- package/docs/pages/recipes/pdf-a-archive.md +205 -0
- package/docs/pages/recipes/pdf-a3-invoice-with-xml.md +222 -0
- package/docs/pages/recipes/pdf-ua-report.md +237 -0
- package/docs/pages/recipes/report.md +125 -0
- package/docs/pages/recipes/web-worker-client.md +64 -0
- package/docs/pages/recipes.md +47 -0
- package/docs/pages/reference/changelog.md +86 -0
- package/docs/pages/reference/codes.md +14 -0
- package/docs/pages/reference/glossary.md +108 -0
- package/docs/pages/reference/rust.md +36 -0
- package/docs/pages/reference/stability.md +59 -0
- package/docs/pages/start/coding-agents.md +45 -0
- package/docs/pages/start/first-pdf.md +77 -0
- package/docs/pages/troubleshooting.md +74 -0
- package/docs/renames.json +86 -0
- package/docs/schemas/error.schema.json +305 -0
- package/docs/schemas/renames.schema.json +29 -0
- package/package.json +5 -3
- package/schemas/error.schema.json +19 -2
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ const doc = Document.open(bytes);
|
|
|
10
10
|
console.log(doc.pageCount);
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
The package is ESM only. It
|
|
13
|
+
The package is ESM only. It's on npm as an alpha release: `npm install @laminapdf/sdk@alpha`.
|
|
14
14
|
|
|
15
15
|
## Quick start
|
|
16
16
|
|
|
@@ -40,8 +40,8 @@ Coordinates are in page space: points from the top-left of the displayed page, w
|
|
|
40
40
|
| Module | gzip | What it can do |
|
|
41
41
|
| --- | ---: | --- |
|
|
42
42
|
| base (`init()`) | ≈ 373 KB | Open (passwords, limits, strict mode), read pages and Info, warnings, edit with ops (transactions, undo/redo), save (auto, incremental, full rewrite; save jobs); build vector and image pages with links, outline, page labels, metadata |
|
|
43
|
-
| extract (`init({ extract: true })` or `loadExtract()`) | ≈
|
|
44
|
-
| text (`init({ text: true })` or `loadText()`) | ≈ 1,
|
|
43
|
+
| extract (`init({ extract: true })` or `loadExtract()`) | ≈ 589 KB | Everything in base, plus text extraction (`page.text()`, `doc.extract()`) |
|
|
44
|
+
| text (`init({ text: true })` or `loadText()`) | ≈ 1,075 KB | Everything in base, plus fonts (`Font.fromBytes`, the standard 14), shaped text runs and text boxes, and text extraction |
|
|
45
45
|
|
|
46
46
|
A page that never draws text never downloads the text module. A `Builder` is built in the text module when it is loaded at the time the builder is created (or with `new Builder({ text: true })`); drawing text on a base-module builder throws `text-module-not-loaded`.
|
|
47
47
|
|
|
@@ -132,6 +132,27 @@ const text = doc.page(0).text({ skipInvisible: true });
|
|
|
132
132
|
console.log(text.text());
|
|
133
133
|
```
|
|
134
134
|
|
|
135
|
+
### For an LLM or a search index: `doc.extract()`
|
|
136
|
+
|
|
137
|
+
`doc.extract({ format })` reads the whole document in reading order, tables included, and leaves out text a reader can't see. It needs the extract or text module, like `page.text()`, and returns one of four outputs:
|
|
138
|
+
|
|
139
|
+
- `"markdown"`: a string, with pipe tables and, with `pageMarkers: true`, a `<!-- page N -->` comment before each page.
|
|
140
|
+
- `"text"`: a string of plain text.
|
|
141
|
+
- `"json"`: an `Extraction`, the `laminapdf.extract/1` document: every block with its page and box in points from the top-left corner, the text left out and why, and the file's warnings. With `chunk`, it carries the chunks too.
|
|
142
|
+
- `"chunks"`: `Chunk`s of whole blocks up to `chunk.maxTokens` (512 by default), each with its blocks, pages, boxes and place in the Markdown.
|
|
143
|
+
|
|
144
|
+
The JSON holds what Rust's `extract_json` writes for the same options.
|
|
145
|
+
|
|
146
|
+
Five more options tune the extraction: `pages`, `readingOrder`, `tables` (`"lattice-and-stream"` also finds tables without lines), `drop` and `dehyphenate`. An unknown option throws `unknown-option` with the name you probably meant.
|
|
147
|
+
|
|
148
|
+
```ts
|
|
149
|
+
await init({ extract: true });
|
|
150
|
+
const doc = Document.open(bytes);
|
|
151
|
+
const chunks = doc.extract({ format: "chunks", chunk: { maxTokens: 400 } });
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
`doc.extract()` runs to the end in one call. In a Web Worker (`@laminapdf/sdk/worker`) the main thread stays free, but aborting the call's `signal` only rejects the promise: the Web Worker finishes the extraction first.
|
|
155
|
+
|
|
135
156
|
## Remote and large files
|
|
136
157
|
|
|
137
158
|
`Document.openRange(source, options)` opens a file whose bytes are fetched range by range, so a remote PDF opens without downloading it whole. Only what the open needs is fetched: the end of the file (the xref), the catalog, the page tree. The document stays synchronous; a call that needs bytes not fetched yet throws `data-pending` with `e.ranges`, and `await doc.ensure(() => …)` fetches them and calls again.
|
|
@@ -173,7 +194,7 @@ const updated = await doc.save({ mode: "incremental" }, { signal, onProgress: (p
|
|
|
173
194
|
- `Builder`: its callbacks (`path`, `tag`) can't cross either. Build on the main thread or in your own Web Worker.
|
|
174
195
|
|
|
175
196
|
- **Remote files:** `client.openUrl(url, options)` opens a file by range requests in the Web Worker; every call fetches what it needs first. Its options are `httpRangeSource`'s, without a custom `fetch` (a function can't be sent to the Web Worker), and `openRange`'s (`budget`, `readahead`, `maxRounds`). Aborting the call's `signal` also cancels the fetches in flight.
|
|
176
|
-
- **Cancellation:** pass `signal` to any call. An aborted call rejects at once with `LaminaPdfError` `cancelled`, whose `cause` is the signal's reason, and a late answer is dropped.
|
|
197
|
+
- **Cancellation:** pass `signal` to any call. An aborted call rejects at once with `LaminaPdfError` `cancelled`, whose `cause` is the signal's reason, and a late answer is dropped. If an aborted `open` or `openUrl` opened its document anyway, the Web Worker frees it.
|
|
177
198
|
- **Not started yet:** the call never runs.
|
|
178
199
|
- **`save` / `saveWithReport`:** they run as stepped jobs and stop at the next step. The document stays usable.
|
|
179
200
|
- **Every other call:** one synchronous call in the Web Worker, so it can't be stopped midway (`open` included). `client.terminate()` is the hard stop.
|
|
@@ -196,13 +217,27 @@ const updated = await doc.save({ mode: "incremental" }, { signal, onProgress: (p
|
|
|
196
217
|
|
|
197
218
|
## Memory
|
|
198
219
|
|
|
199
|
-
Documents, builders, pages and images live in WebAssembly memory.
|
|
220
|
+
Documents, builders, pages, save jobs and images live in WebAssembly memory. Free each one when you're done: `using doc = Document.open(…)` frees it at the end of the block, and `doc.free()` frees it at once. A second `free()` does nothing, and any other call afterwards throws `disposed`. A page or save job is freed with its document, a builder's page with its builder, and `page.finish()` and `builder.finish()` free their WebAssembly memory. The garbage collector frees whatever you forget, only later. To find what you forget, `onLeak((leak) => console.warn(leak.handle))` reports each document, builder or image the collector reclaims without a `free()`.
|
|
221
|
+
|
|
222
|
+
WebAssembly memory grows as Lamina PDF needs it and never shrinks. Three bounds keep it in check:
|
|
223
|
+
|
|
224
|
+
- **Limits:** the open limits (`limits` in `Document.open`'s options) stop most hostile files before they use much memory.
|
|
225
|
+
- **A ceiling:** each module may grow to 2 GiB. Past that, the call throws `out-of-memory`.
|
|
226
|
+
- **`reset()`:** replaces every loaded module's instance with a fresh one, so memory returns to its size after `init()`. Every document, page, builder and save job made before throws `instance-reset`, so call it while none is in use, such as between jobs on a server. Images and fonts keep working.
|
|
227
|
+
|
|
228
|
+
When Lamina PDF hits a bug, the module traps and the call throws `wasm-trap`. After a trap or `out-of-memory`, the next call runs in a fresh instance, and the old instance's handles throw `instance-reset`: open the document again from its bytes. In a Web Worker from `@laminapdf/sdk/worker`, a trap ends the Web Worker instead, and `client.restart()` starts a new one. `wasmMemory()` reports each module's memory size.
|
|
229
|
+
|
|
230
|
+
**`using` in Safari:** according to MDN's compatibility data (November 2026), Safari has `Symbol.dispose` only in its Technology Preview. When esbuild or Babel compile `using`, they fall back to `Symbol.for("Symbol.dispose")`, and every Lamina PDF handle answers to that key too. TypeScript's compiled `using` needs the symbol itself, so add `Symbol.dispose ??= Symbol.for("Symbol.dispose")` to your app. In that form it matches Lamina PDF's key whichever runs first. Without it, call `free()` in a `finally` block.
|
|
200
231
|
|
|
201
232
|
## Examples
|
|
202
233
|
|
|
203
|
-
The [
|
|
234
|
+
The [recipes](https://docs.laminapdf.com/recipes/) show each example with what it makes and what to change: `hello`, `invoice`, `multilingual`, `images-and-vectors`, `links-and-outlines` and `generate-then-edit`, plus `report`, 100 pages with two embedded fonts. Each produces the same bytes as its Rust twin.
|
|
235
|
+
|
|
236
|
+
A Cloudflare Worker example generates a PDF per request: `/?name=Ada` returns a letter in Helvetica, and `/embedded?name=Ada` the same letter in a font bundled with the Cloudflare Worker. A name the font can't draw gets a 400 with the error as JSON. The [Cloudflare Workers quick start](https://docs.laminapdf.com/quick-start/workers/) shows it and how to run it.
|
|
237
|
+
|
|
238
|
+
## Docs for coding agents
|
|
204
239
|
|
|
205
|
-
|
|
240
|
+
The package carries these docs as Markdown in `docs/`, for the version you installed: `docs/llms.txt` lists every page, `docs/api/` holds the API reference, `docs/errors/` explains each error code and `docs/renames.json` says what renamed items are called now. Paste `docs/AGENTS.md` into your project's `AGENTS.md` or `CLAUDE.md` to point your coding agent at them. The [coding agents page](https://docs.laminapdf.com/start/coding-agents/) has the details.
|
|
206
241
|
|
|
207
242
|
## Working on this package
|
|
208
243
|
|
package/dist/api.d.ts
CHANGED
|
@@ -3,11 +3,14 @@ export { Builder, PAGE_SIZES, Page, PendingPath, Surface, TAG_NAMES } from "./bu
|
|
|
3
3
|
export { Document, PageRef, SaveJob } from "./document.js";
|
|
4
4
|
export type { Diagnostic, ErrorKind, LaminaPdfWarning, Location } from "./errors.js";
|
|
5
5
|
export { isLaminaPdfError, LaminaPdfError } from "./errors.js";
|
|
6
|
+
export type { Cell, Chunk, ChunkOptions, Coordinates, Dropped, DropReason, ExtractedBlock, ExtractedPage, ExtractedSource, ExtractFormat, Extraction, ExtractOptions, ExtractResult, Flags, Generator, ReadingOrder, Region, Span, SplitOn, StructRef, StructSource, TableDetector, TableMode, TextRange, } from "./extract.js";
|
|
6
7
|
export type { FontInfo, Standard14 } from "./font.js";
|
|
7
8
|
export { Font, Image } from "./font.js";
|
|
8
9
|
export type { ErrorCode, LimitName, WarningCode } from "./generated/codes.js";
|
|
9
10
|
export type { InitOptions, WasmMemory, WasmSource } from "./init.js";
|
|
10
|
-
export { isExtractLoaded, isInitialized, isTextLoaded, wasmMemory } from "./init.js";
|
|
11
|
+
export { isExtractLoaded, isInitialized, isTextLoaded, reset, wasmMemory } from "./init.js";
|
|
12
|
+
export type { Leak } from "./internal/handle.js";
|
|
13
|
+
export { onLeak } from "./internal/handle.js";
|
|
11
14
|
export type { Transform } from "./matrix.js";
|
|
12
15
|
export { Matrix } from "./matrix.js";
|
|
13
16
|
export type { PathBuilder } from "./path.js";
|
|
@@ -16,7 +19,7 @@ export { httpRangeSource } from "./source/http.js";
|
|
|
16
19
|
export type { ByteRange, RangeOptions, RangeSource } from "./source/range.js";
|
|
17
20
|
export { callbackSource } from "./source/range.js";
|
|
18
21
|
export type { GlyphQuad, QuadPoint, TextGlyph, TextOptions as PageTextOptions } from "./text.js";
|
|
19
|
-
export { PageText,
|
|
22
|
+
export { PageText, PageTextRun } from "./text.js";
|
|
20
23
|
export type { InfoPatch, Rotation } from "./transaction.js";
|
|
21
24
|
export { Transaction } from "./transaction.js";
|
|
22
25
|
export type { AfRelationship, Align, AttachmentOptions, BoxRect, BuildOptions, Color, Direction, DocumentInfo, Edited, Fit, Limits, LineBox, LinkTarget, Metadata, Op, OpenOptions, OpLog, OutlineEntry, Overflow, PageInfo, PageLabel, Point, Profile, Progress, Rect, RenderMode, SaveOptions, SaveReport, TextLayout, TextRunInfo, UndoOutcome, ViewerPreferences, } from "./types.js";
|
package/dist/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAEA,YAAY,EACV,YAAY,EACZ,SAAS,EACT,cAAc,EACd,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,UAAU,EACV,GAAG,EACH,OAAO,EACP,OAAO,EACP,cAAc,EACd,WAAW,GACZ,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC1F,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC3D,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,aAAa,C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Ac,EACd,KAAK,EACL,iBAAiB,EACjB,OAAO,EACP,YAAY,EACZ,KAAK,EACL,SAAS,EACT,YAAY,EACZ,MAAM,EACN,GAAG,EACH,MAAM,EACN,OAAO,EACP,UAAU,EACV,QAAQ,EACR,EAAE,EACF,WAAW,EACX,KAAK,EACL,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,KAAK,EACL,OAAO,EACP,QAAQ,EACR,IAAI,EACJ,UAAU,EACV,WAAW,EACX,UAAU,EACV,UAAU,EACV,WAAW,EACX,WAAW,EACX,iBAAiB,GAClB,MAAM,YAAY,CAAC"}
|
package/dist/api.js
CHANGED
|
@@ -2,10 +2,11 @@ export { Builder, PAGE_SIZES, Page, PendingPath, Surface, TAG_NAMES } from "./bu
|
|
|
2
2
|
export { Document, PageRef, SaveJob } from "./document.js";
|
|
3
3
|
export { isLaminaPdfError, LaminaPdfError } from "./errors.js";
|
|
4
4
|
export { Font, Image } from "./font.js";
|
|
5
|
-
export { isExtractLoaded, isInitialized, isTextLoaded, wasmMemory } from "./init.js";
|
|
5
|
+
export { isExtractLoaded, isInitialized, isTextLoaded, reset, wasmMemory } from "./init.js";
|
|
6
|
+
export { onLeak } from "./internal/handle.js";
|
|
6
7
|
export { Matrix } from "./matrix.js";
|
|
7
8
|
export { httpRangeSource } from "./source/http.js";
|
|
8
9
|
export { callbackSource } from "./source/range.js";
|
|
9
|
-
export { PageText,
|
|
10
|
+
export { PageText, PageTextRun } from "./text.js";
|
|
10
11
|
export { Transaction } from "./transaction.js";
|
|
11
12
|
//# sourceMappingURL=api.js.map
|
package/dist/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC1F,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAE3D,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC1F,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAE3D,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AA4B/D,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAGxC,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,YAAY,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5F,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAElD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/builder.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import type { WasmImage } from "@laminapdf/wasm/base";
|
|
1
2
|
import type { WasmPageBuilder as TextPageBuilder, WasmFont } from "@laminapdf/wasm/text";
|
|
2
3
|
import { Document } from "./document.js";
|
|
3
4
|
import type { Font, FontInfo, Image } from "./font.js";
|
|
4
5
|
import { type ArtifactKind, type BlendMode, type FillRule, type LineCap, type LineJoin, type TableScope, type TagName } from "./generated/builder-enums.js";
|
|
5
|
-
import { type BaseGlue
|
|
6
|
+
import { type BaseGlue } from "./init.js";
|
|
7
|
+
import { Handle } from "./internal/handle.js";
|
|
8
|
+
import type { Instance } from "./internal/instance.js";
|
|
6
9
|
import type { Transform } from "./matrix.js";
|
|
7
10
|
import { type PathBuilder } from "./path.js";
|
|
8
11
|
import type { Align, AttachmentOptions, BuildOptions, Color, Direction, Fit, LinkTarget, Metadata, OutlineEntry, Overflow, PageLabel, Point, Rect, RenderMode, TextLayout, TextRunInfo, ViewerPreferences } from "./types.js";
|
|
@@ -105,12 +108,22 @@ export interface TextBoxOptions {
|
|
|
105
108
|
/** The structure element the box is (as drawing it inside {@link Surface.tag}). */
|
|
106
109
|
readonly tag?: Tag;
|
|
107
110
|
}
|
|
108
|
-
/**
|
|
109
|
-
|
|
111
|
+
/**
|
|
112
|
+
* The raw page of a {@link Page}, a handle freed with its builder: `builder-finished` once the page
|
|
113
|
+
* or its builder finishes, `disposed` once either is freed.
|
|
114
|
+
*/
|
|
115
|
+
declare class LivePage extends Handle<BaseGlue> {
|
|
110
116
|
#private;
|
|
111
|
-
constructor(raw: TextPageBuilder,
|
|
112
|
-
|
|
113
|
-
|
|
117
|
+
constructor(raw: TextPageBuilder, builder: Builder, instance: Instance<BaseGlue>, onClose: (page: LivePage) => void);
|
|
118
|
+
/**
|
|
119
|
+
* Runs `f`, calls into the glue, on this page's raw side.
|
|
120
|
+
*
|
|
121
|
+
* @throws {@link LaminaPdfError} `disposed`, `instance-reset`, `builder-finished`; what `f` throws.
|
|
122
|
+
*/
|
|
123
|
+
run<T>(f: (page: TextPageBuilder) => T): T;
|
|
124
|
+
/** Frees the raw page and keeps the handle: later calls throw `builder-finished`. */
|
|
125
|
+
close(): void;
|
|
126
|
+
protected release(): void;
|
|
114
127
|
}
|
|
115
128
|
/** A path waiting to be painted: fill it, stroke it, both, or clip to it. */
|
|
116
129
|
export declare class PendingPath {
|
|
@@ -202,7 +215,10 @@ export declare class Surface {
|
|
|
202
215
|
*/
|
|
203
216
|
textBox(text: string, options: TextBoxOptions): TextLayout;
|
|
204
217
|
}
|
|
205
|
-
/**
|
|
218
|
+
/**
|
|
219
|
+
* A page being drawn: its boxes and rotation, its {@link Surface}, then {@link Page.finish}. Freed
|
|
220
|
+
* with its builder; `using` or {@link Page.free} drops it without writing it.
|
|
221
|
+
*/
|
|
206
222
|
export declare class Page {
|
|
207
223
|
#private;
|
|
208
224
|
/** @internal */
|
|
@@ -229,13 +245,19 @@ export declare class Page {
|
|
|
229
245
|
* @throws {@link LaminaPdfError} `invalid-geometry`, `builder-finished`.
|
|
230
246
|
*/
|
|
231
247
|
finish(): string;
|
|
232
|
-
/**
|
|
248
|
+
/**
|
|
249
|
+
* Drops the page without writing it and frees its WASM side; a second call does nothing, and
|
|
250
|
+
* any other call afterwards throws `disposed`.
|
|
251
|
+
*/
|
|
233
252
|
free(): void;
|
|
253
|
+
/** Drops the page at the end of a `using` block (an alias of `free()`). */
|
|
254
|
+
[Symbol.dispose](): void;
|
|
234
255
|
}
|
|
235
256
|
/**
|
|
236
257
|
* Builds a new document: pages, navigation and metadata; {@link Builder.finish} returns a
|
|
237
258
|
* {@link Document} to save. Created in the text module when it is loaded (or `text: true`),
|
|
238
|
-
* else in the reading module (text, extract, then base; vector and image pages only).
|
|
259
|
+
* else in the reading module (text, extract, then base; vector and image pages only). `finish()`
|
|
260
|
+
* frees its WebAssembly memory; to drop it unfinished, use `using` or {@link Builder.free}.
|
|
239
261
|
*
|
|
240
262
|
* @example
|
|
241
263
|
* ```ts
|
|
@@ -247,16 +269,16 @@ export declare class Page {
|
|
|
247
269
|
* const bytes = b.finish().save();
|
|
248
270
|
* ```
|
|
249
271
|
*/
|
|
250
|
-
export declare class Builder {
|
|
272
|
+
export declare class Builder extends Handle<BaseGlue> {
|
|
251
273
|
#private;
|
|
252
|
-
/** @internal The module the document is built in. */
|
|
253
|
-
readonly glue: BaseGlue | TextGlue;
|
|
254
274
|
/**
|
|
255
275
|
* @param options - version, file ID, producer, creation date, compression, tagging,
|
|
256
276
|
* conformance `profiles`; `text`.
|
|
257
277
|
* @throws {@link LaminaPdfError} `not-initialized`, `text-module-not-loaded`; `unknown-option`.
|
|
258
278
|
*/
|
|
259
279
|
constructor(options?: BuilderOptions);
|
|
280
|
+
/** @internal `image` in this builder's instance. */
|
|
281
|
+
wasmImage(image: Image): WasmImage;
|
|
260
282
|
/** As `new Builder(options)`. */
|
|
261
283
|
static create(options?: BuilderOptions): Builder;
|
|
262
284
|
/** Whether this builder draws in the text module (fonts and text). */
|
|
@@ -308,12 +330,6 @@ export declare class Builder {
|
|
|
308
330
|
* code (the error reference lists them, from `profile-version-conflict` on).
|
|
309
331
|
*/
|
|
310
332
|
finish(): Document;
|
|
311
|
-
|
|
312
|
-
* Frees the builder's WASM memory now (`finish` does this itself); the builder takes no more
|
|
313
|
-
* calls afterwards. Unfinished pages are freed with {@link Page.free}.
|
|
314
|
-
*/
|
|
315
|
-
free(): void;
|
|
316
|
-
/** Frees the builder at the end of a `using` block. */
|
|
317
|
-
[Symbol.dispose](): void;
|
|
333
|
+
protected release(): void;
|
|
318
334
|
}
|
|
319
335
|
//# sourceMappingURL=builder.d.ts.map
|
package/dist/builder.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAA8B,eAAe,IAAI,eAAe,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAErH,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,OAAO,EACZ,KAAK,QAAQ,EAGb,KAAK,UAAU,EACf,KAAK,OAAO,EACb,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE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