@laminapdf/sdk 0.0.0-stage → 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 +243 -2
- package/dist/api.d.ts +26 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +12 -0
- package/dist/api.js.map +1 -0
- package/dist/builder.d.ts +335 -0
- package/dist/builder.d.ts.map +1 -0
- package/dist/builder.js +574 -0
- package/dist/builder.js.map +1 -0
- package/dist/defined.d.ts +5 -0
- package/dist/defined.d.ts.map +1 -0
- package/dist/defined.js +7 -0
- package/dist/defined.js.map +1 -0
- package/dist/document.d.ts +267 -0
- package/dist/document.d.ts.map +1 -0
- package/dist/document.js +472 -0
- package/dist/document.js.map +1 -0
- package/dist/entry/node.d.ts +30 -0
- package/dist/entry/node.d.ts.map +1 -0
- package/dist/entry/node.js +37 -0
- package/dist/entry/node.js.map +1 -0
- package/dist/entry/workerd.d.ts +30 -0
- package/dist/entry/workerd.d.ts.map +1 -0
- package/dist/entry/workerd.js +37 -0
- package/dist/entry/workerd.js.map +1 -0
- package/dist/errors.d.ts +102 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +131 -0
- package/dist/errors.js.map +1 -0
- package/dist/explain.d.ts +20 -0
- package/dist/explain.d.ts.map +1 -0
- package/dist/explain.js +14 -0
- package/dist/explain.js.map +1 -0
- 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 +73 -0
- package/dist/font.d.ts.map +1 -0
- package/dist/font.js +133 -0
- package/dist/font.js.map +1 -0
- package/dist/generated/builder-enums.d.ts +29 -0
- package/dist/generated/builder-enums.d.ts.map +1 -0
- package/dist/generated/builder-enums.js +80 -0
- package/dist/generated/builder-enums.js.map +1 -0
- package/dist/generated/codes.d.ts +109 -0
- package/dist/generated/codes.d.ts.map +1 -0
- package/dist/generated/codes.js +508 -0
- package/dist/generated/codes.js.map +1 -0
- package/dist/generated/explain.d.ts +6 -0
- package/dist/generated/explain.d.ts.map +1 -0
- package/dist/generated/explain.js +155 -0
- package/dist/generated/explain.js.map +1 -0
- 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/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/dist/init.d.ts +88 -0
- package/dist/init.d.ts.map +1 -0
- package/dist/init.js +139 -0
- package/dist/init.js.map +1 -0
- 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/loader/fetch.d.ts +3 -0
- package/dist/loader/fetch.d.ts.map +1 -0
- package/dist/loader/fetch.js +2 -0
- package/dist/loader/fetch.js.map +1 -0
- package/dist/loader/node.d.ts +3 -0
- package/dist/loader/node.d.ts.map +1 -0
- package/dist/loader/node.js +9 -0
- package/dist/loader/node.js.map +1 -0
- package/dist/loader/workerd.d.ts +3 -0
- package/dist/loader/workerd.d.ts.map +1 -0
- package/dist/loader/workerd.js +15 -0
- package/dist/loader/workerd.js.map +1 -0
- package/dist/matrix.d.ts +16 -0
- package/dist/matrix.d.ts.map +1 -0
- package/dist/matrix.js +36 -0
- package/dist/matrix.js.map +1 -0
- package/dist/path.d.ts +34 -0
- package/dist/path.d.ts.map +1 -0
- package/dist/path.js +49 -0
- package/dist/path.js.map +1 -0
- package/dist/source/http.d.ts +36 -0
- package/dist/source/http.d.ts.map +1 -0
- package/dist/source/http.js +211 -0
- package/dist/source/http.js.map +1 -0
- package/dist/source/range.d.ts +75 -0
- package/dist/source/range.d.ts.map +1 -0
- package/dist/source/range.js +100 -0
- package/dist/source/range.js.map +1 -0
- package/dist/text.d.ts +90 -0
- package/dist/text.d.ts.map +1 -0
- package/dist/text.js +127 -0
- package/dist/text.js.map +1 -0
- package/dist/transaction.d.ts +36 -0
- package/dist/transaction.d.ts.map +1 -0
- package/dist/transaction.js +47 -0
- package/dist/transaction.js.map +1 -0
- package/dist/types.d.ts +79 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +6 -0
- package/dist/version.js.map +1 -0
- package/dist/worker/client.d.ts +88 -0
- package/dist/worker/client.d.ts.map +1 -0
- package/dist/worker/client.js +407 -0
- package/dist/worker/client.js.map +1 -0
- package/dist/worker/emitter.d.ts +12 -0
- package/dist/worker/emitter.d.ts.map +1 -0
- package/dist/worker/emitter.js +34 -0
- package/dist/worker/emitter.js.map +1 -0
- package/dist/worker/entry.d.ts +2 -0
- package/dist/worker/entry.d.ts.map +1 -0
- package/dist/worker/entry.js +4 -0
- package/dist/worker/entry.js.map +1 -0
- package/dist/worker/index.d.ts +7 -0
- package/dist/worker/index.d.ts.map +1 -0
- package/dist/worker/index.js +4 -0
- package/dist/worker/index.js.map +1 -0
- package/dist/worker/protocol.d.ts +82 -0
- package/dist/worker/protocol.d.ts.map +1 -0
- package/dist/worker/protocol.js +11 -0
- package/dist/worker/protocol.js.map +1 -0
- package/dist/worker/server.d.ts +51 -0
- package/dist/worker/server.d.ts.map +1 -0
- package/dist/worker/server.js +493 -0
- package/dist/worker/server.js.map +1 -0
- package/dist/worker/support.d.ts +43 -0
- package/dist/worker/support.d.ts.map +1 -0
- package/dist/worker/support.js +26 -0
- package/dist/worker/support.js.map +1 -0
- package/dist/worker/transfer.d.ts +3 -0
- package/dist/worker/transfer.d.ts.map +1 -0
- package/dist/worker/transfer.js +13 -0
- package/dist/worker/transfer.js.map +1 -0
- package/dist/worker/types.d.ts +50 -0
- package/dist/worker/types.d.ts.map +1 -0
- package/dist/worker/types.js +2 -0
- package/dist/worker/types.js.map +1 -0
- 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 +93 -3
- package/schemas/error.schema.json +305 -0
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
/** One cell of a table block. */
|
|
2
|
+
export type Cell = {
|
|
3
|
+
/** Its box in page space. */
|
|
4
|
+
bbox: [number, number, number, number];
|
|
5
|
+
/** The first column it covers, 0 at the left. */
|
|
6
|
+
col: number;
|
|
7
|
+
/** How many columns it covers. */
|
|
8
|
+
colSpan: number;
|
|
9
|
+
/** Whether it is in a header row. */
|
|
10
|
+
header: boolean;
|
|
11
|
+
/** The first row it covers, 0 at the top. */
|
|
12
|
+
row: number;
|
|
13
|
+
/** How many rows it covers. */
|
|
14
|
+
rowSpan: number;
|
|
15
|
+
/** Its visible text, lines joined by a space. */
|
|
16
|
+
text: string;
|
|
17
|
+
};
|
|
18
|
+
/** One chunk. */
|
|
19
|
+
export type Chunk = {
|
|
20
|
+
/** The blocks it holds, in order. */
|
|
21
|
+
blockIds: string[];
|
|
22
|
+
/** The headings above its first block, outermost first. */
|
|
23
|
+
headingPath: string[];
|
|
24
|
+
/** `c<n>`, from 0, in order. */
|
|
25
|
+
id: string;
|
|
26
|
+
/** The pages its blocks are on, ascending. */
|
|
27
|
+
pages: number[];
|
|
28
|
+
/** Its area on each of those pages. */
|
|
29
|
+
regions: Region[];
|
|
30
|
+
/** The Markdown from the first block's start to the last block's end. */
|
|
31
|
+
text: string;
|
|
32
|
+
/** Where `text` sits in the Markdown. */
|
|
33
|
+
textRange: TextRange;
|
|
34
|
+
/** [`tokens_approx`] of `text`. */
|
|
35
|
+
tokensApprox: number;
|
|
36
|
+
};
|
|
37
|
+
/** ADR 0027 §4's `coordinates` block: top-left points of the displayed box. */
|
|
38
|
+
export type Coordinates = {
|
|
39
|
+
/** `"CropBox"`, or `"default"` when the page had no usable box and US Letter was used. */
|
|
40
|
+
box: string;
|
|
41
|
+
/** Always `"top-left"`. */
|
|
42
|
+
origin: string;
|
|
43
|
+
/** The `/Rotate` applied, in degrees clockwise. */
|
|
44
|
+
rotate: number;
|
|
45
|
+
/** Always `"pt"`. */
|
|
46
|
+
unit: string;
|
|
47
|
+
/** The `/UserUnit` applied. */
|
|
48
|
+
userUnit: number;
|
|
49
|
+
};
|
|
50
|
+
/** Why text was left out. */
|
|
51
|
+
export type DropReason = "invisible" | "off-page" | "tiny" | "clipped" | "low-contrast" | "artifact" | "running-header" | "running-footer" | "page-number";
|
|
52
|
+
/**
|
|
53
|
+
* Text left out of the output ([ADR 0030] §4). It records a count, never the text, so a log of
|
|
54
|
+
* the output can't leak what was hidden.
|
|
55
|
+
*
|
|
56
|
+
* [ADR 0030]: https://github.com/laudebugs/laminapdf/blob/main/docs/decisions/0030-extraction-output-and-model-plugins.md
|
|
57
|
+
*/
|
|
58
|
+
export type Dropped = {
|
|
59
|
+
/** Where it was, in page space. */
|
|
60
|
+
bbox: [number, number, number, number];
|
|
61
|
+
/** How many characters were left out. */
|
|
62
|
+
chars: number;
|
|
63
|
+
/** The page index. */
|
|
64
|
+
page: number;
|
|
65
|
+
/** Why it was left out (the first reason when there are several). */
|
|
66
|
+
reason: DropReason;
|
|
67
|
+
/**
|
|
68
|
+
* The run itself, only when [`DropOptions::keep_spans`](crate::DropOptions::keep_spans)
|
|
69
|
+
* asked for it.
|
|
70
|
+
*/
|
|
71
|
+
spans?: Span[];
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* One extracted page ([ADR 0027] §4).
|
|
75
|
+
*
|
|
76
|
+
* [ADR 0027]: https://github.com/laudebugs/laminapdf/blob/main/docs/decisions/0027-coordinates-units-and-page-indexing.md
|
|
77
|
+
*/
|
|
78
|
+
export type ExtractedPage = {
|
|
79
|
+
/** The frame the boxes are in. */
|
|
80
|
+
coordinates: Coordinates;
|
|
81
|
+
/** The displayed height in points. */
|
|
82
|
+
height: number;
|
|
83
|
+
/** 0-based. */
|
|
84
|
+
index: number;
|
|
85
|
+
/** The page label (`/PageLabels`), when there is one. */
|
|
86
|
+
label?: string | null;
|
|
87
|
+
/** 1-based, as people count. */
|
|
88
|
+
number: number;
|
|
89
|
+
/** The displayed width in points (after `/Rotate` and `/UserUnit`). */
|
|
90
|
+
width: number;
|
|
91
|
+
};
|
|
92
|
+
/** The input, as ADR 0030 §1's `source` describes it. */
|
|
93
|
+
export type ExtractedSource = {
|
|
94
|
+
/** The document's page count. */
|
|
95
|
+
pageCount: number;
|
|
96
|
+
/**
|
|
97
|
+
* The input's SHA-256 in hex: filled by the caller that holds the bytes (the façade), since
|
|
98
|
+
* a windowed source can't be hashed without reading it whole.
|
|
99
|
+
*/
|
|
100
|
+
sha256?: string | null;
|
|
101
|
+
/** Where the reading order came from. */
|
|
102
|
+
structSource: StructSource;
|
|
103
|
+
/** Whether the catalog's `/MarkInfo` says `/Marked true`. */
|
|
104
|
+
tagged: boolean;
|
|
105
|
+
};
|
|
106
|
+
/** Why a run would be hidden from a reader; empty for visible text. */
|
|
107
|
+
export type Flags = DropReason[];
|
|
108
|
+
/** Who made the extraction (ADR 0030 §1's `generator`). */
|
|
109
|
+
export type Generator = {
|
|
110
|
+
/** `"rules"`, or `"rules+models"` once model plug-ins exist. */
|
|
111
|
+
mode: string;
|
|
112
|
+
models: unknown[];
|
|
113
|
+
name: string;
|
|
114
|
+
version: string;
|
|
115
|
+
};
|
|
116
|
+
/** A block and where its text sits in the Markdown. */
|
|
117
|
+
export type JsonBlock = {
|
|
118
|
+
/** The block's box in page space. */
|
|
119
|
+
bbox: [number, number, number, number];
|
|
120
|
+
/**
|
|
121
|
+
* The box divided by the page's width and height, clamped to [0, 1]; `None` when the
|
|
122
|
+
* block lies wholly outside the page.
|
|
123
|
+
*/
|
|
124
|
+
bboxNorm?: [number, number, number, number] | null;
|
|
125
|
+
/** A table's cells, row by row; empty for every other block. */
|
|
126
|
+
cells?: Cell[];
|
|
127
|
+
/** In [0, 1]: 1 for structure from the tree, lower for structure inferred from layout. */
|
|
128
|
+
confidence: number;
|
|
129
|
+
/** `p<page index>-b<position in the page's reading order>`. */
|
|
130
|
+
id: string;
|
|
131
|
+
/** The page index. */
|
|
132
|
+
page: number;
|
|
133
|
+
/** The runs of text, in reading order. */
|
|
134
|
+
spans: Span[];
|
|
135
|
+
/** The structure types from the root down to the block; empty when untagged. */
|
|
136
|
+
structPath: string[];
|
|
137
|
+
/** The structure element the block comes from, when it comes from one. */
|
|
138
|
+
structRef?: StructRef | null;
|
|
139
|
+
/** The visible text, lines joined by a space after the text fixes (ADR 0030 §5). */
|
|
140
|
+
text: string;
|
|
141
|
+
textRange: TextRange;
|
|
142
|
+
} & ({
|
|
143
|
+
/** 1–6. */
|
|
144
|
+
level: number;
|
|
145
|
+
type: "heading";
|
|
146
|
+
} | {
|
|
147
|
+
type: "paragraph";
|
|
148
|
+
} | {
|
|
149
|
+
/** 0 for the outermost list. */
|
|
150
|
+
depth: number;
|
|
151
|
+
/** The bullet or number that starts it. */
|
|
152
|
+
marker: string;
|
|
153
|
+
type: "list-item";
|
|
154
|
+
} | {
|
|
155
|
+
type: "caption";
|
|
156
|
+
} | {
|
|
157
|
+
type: "footnote";
|
|
158
|
+
} | {
|
|
159
|
+
type: "other";
|
|
160
|
+
} | {
|
|
161
|
+
/** The grid's columns. */
|
|
162
|
+
cols: number;
|
|
163
|
+
/** What found it. */
|
|
164
|
+
detector: TableDetector;
|
|
165
|
+
/** The grid's rows. */
|
|
166
|
+
rows: number;
|
|
167
|
+
type: "table";
|
|
168
|
+
});
|
|
169
|
+
/** A chunk's area on one page. */
|
|
170
|
+
export type Region = {
|
|
171
|
+
/** The union of the chunk's blocks' boxes on that page, in page space. */
|
|
172
|
+
bbox: [number, number, number, number];
|
|
173
|
+
/** The page index. */
|
|
174
|
+
page: number;
|
|
175
|
+
};
|
|
176
|
+
/** One run of text in a block or a dropped entry. */
|
|
177
|
+
export type Span = {
|
|
178
|
+
/** The baseline's y in page space (ADR 0027 §5). */
|
|
179
|
+
baseline: number;
|
|
180
|
+
/** Its box in page space. */
|
|
181
|
+
bbox: [number, number, number, number];
|
|
182
|
+
/** Why the run would be hidden; empty for visible text. */
|
|
183
|
+
flags: Flags;
|
|
184
|
+
/** The font's `/BaseFont`. */
|
|
185
|
+
font: string;
|
|
186
|
+
/** The glyph size in points. */
|
|
187
|
+
size: number;
|
|
188
|
+
/** The run's text. */
|
|
189
|
+
text: string;
|
|
190
|
+
};
|
|
191
|
+
/**
|
|
192
|
+
* A structure element ([ADR 0030] §1's `structRef`).
|
|
193
|
+
*
|
|
194
|
+
* [ADR 0030]: https://github.com/laudebugs/laminapdf/blob/main/docs/decisions/0030-extraction-output-and-model-plugins.md
|
|
195
|
+
*/
|
|
196
|
+
export type StructRef = {
|
|
197
|
+
/** Its generation. */
|
|
198
|
+
gen: number;
|
|
199
|
+
/** The marked-content identifiers it covers on the page. */
|
|
200
|
+
mcids: number[];
|
|
201
|
+
/** The element's object number. */
|
|
202
|
+
obj: number;
|
|
203
|
+
};
|
|
204
|
+
/**
|
|
205
|
+
* Where the reading order came from ([ADR 0030] §2).
|
|
206
|
+
*
|
|
207
|
+
* [ADR 0030]: https://github.com/laudebugs/laminapdf/blob/main/docs/decisions/0030-extraction-output-and-model-plugins.md
|
|
208
|
+
*/
|
|
209
|
+
export type StructSource = "tagged" | "xycut" | "content";
|
|
210
|
+
/** What found a table. */
|
|
211
|
+
export type TableDetector = "lattice" | "stream" | "tagged";
|
|
212
|
+
/**
|
|
213
|
+
* Where a piece of text sits in a rendering, in Unicode scalar values (`char`s), `start`
|
|
214
|
+
* inclusive and `end` exclusive. Code points, not bytes or UTF-16 units, so Python slices a
|
|
215
|
+
* rendering with them as they are; [`Rendered::slice`] does it in Rust.
|
|
216
|
+
*/
|
|
217
|
+
export type TextRange = {
|
|
218
|
+
/** One past the last character. */
|
|
219
|
+
end: number;
|
|
220
|
+
/** The first character. */
|
|
221
|
+
start: number;
|
|
222
|
+
};
|
|
223
|
+
/** The whole document. */
|
|
224
|
+
export type Extraction = {
|
|
225
|
+
blocks: JsonBlock[];
|
|
226
|
+
chunks?: Chunk[] | null;
|
|
227
|
+
dropped: Dropped[];
|
|
228
|
+
generator: Generator;
|
|
229
|
+
pages: ExtractedPage[];
|
|
230
|
+
/** Always `"laminapdf.extract/1"`. */
|
|
231
|
+
schema: string;
|
|
232
|
+
source: ExtractedSource;
|
|
233
|
+
warnings: unknown[];
|
|
234
|
+
};
|
|
235
|
+
//# sourceMappingURL=extract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract.d.ts","sourceRoot":"","sources":["../../src/generated/extract.ts"],"names":[],"mappings":"AAGA,iCAAiC;AACjC,MAAM,MAAM,IAAI,GAAG;IACjB,6BAA6B;IAC7B,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,iDAAiD;IACjD,GAAG,EAAE,MAAM,CAAC;IACZ,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,qCAAqC;IACrC,MAAM,EAAE,OAAO,CAAC;IAChB,6CAA6C;IAC7C,GAAG,EAAE,MAAM,CAAC;IACZ,+BAA+B;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,iDAAiD;IACjD,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,iBAAiB;AACjB,MAAM,MAAM,KAAK,GAAG;IAClB,qCAAqC;IACrC,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,2DAA2D;IAC3D,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,gCAAgC;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,8CAA8C;IAC9C,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,uCAAuC;IACvC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,yEAAyE;IACzE,IAAI,EAAE,MAAM,CAAC;IACb,yCAAyC;IACzC,SAAS,EAAE,SAAS,CAAC;IACrB,mCAAmC;IACnC,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,+EAA+E;AAC/E,MAAM,MAAM,WAAW,GAAG;IACxB,0FAA0F;IAC1F,GAAG,EAAE,MAAM,CAAC;IACZ,2BAA2B;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,mDAAmD;IACnD,MAAM,EAAE,MAAM,CAAC;IACf,qBAAqB;IACrB,IAAI,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A2B;IAC3B,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,0BAA0B;AAC1B,MAAM,MAAM,UAAU,GAAG;IACvB,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,MAAM,CAAC,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;IACxB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,SAAS,EAAE,SAAS,CAAC;IACrB,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB,sCAAsC;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,eAAe,CAAC;IACxB,QAAQ,EAAE,OAAO,EAAE,CAAC;CACrB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract.js","sourceRoot":"","sources":["../../src/generated/extract.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,6DAA6D"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { InitOptions, WasmSource } from "./init.js";
|
|
2
|
+
/**
|
|
3
|
+
* Loads the base WebAssembly module (fetched next to the package); with `{ text: true }`, the text
|
|
4
|
+
* module too. Idempotent: later calls return at once (or load the text module). Everything else
|
|
5
|
+
* in the package is synchronous and needs this promise to have resolved.
|
|
6
|
+
*
|
|
7
|
+
* @param input - where the base module comes from (a URL, `Response`, bytes or
|
|
8
|
+
* `WebAssembly.Module`), or options; omitted, the file next to the package.
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* await init(); // or: await init({ text: true })
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare function init(input?: WasmSource | InitOptions): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Loads the text module (fonts, shaping and text layout; about 940 KB gzipped). Builders
|
|
17
|
+
* created afterwards can draw text. Idempotent.
|
|
18
|
+
*
|
|
19
|
+
* @param source - where it comes from; omitted, the file next to the package.
|
|
20
|
+
*/
|
|
21
|
+
export declare function loadText(source?: WasmSource): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Loads the extract module (reading plus text extraction). Documents opened afterwards can
|
|
24
|
+
* extract text with `page.text()`. Idempotent; not needed when the text module is loaded.
|
|
25
|
+
*
|
|
26
|
+
* @param source - where it comes from; omitted, the file next to the package.
|
|
27
|
+
*/
|
|
28
|
+
export declare function loadExtract(source?: WasmSource): Promise<void>;
|
|
29
|
+
export * from "./api.js";
|
|
30
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAIzD;;;;;;;;;;;GAWG;AACH,wBAAgB,IAAI,CAAC,KAAK,CAAC,EAAE,UAAU,GAAG,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAEpE;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAE3D;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAE9D;AAED,cAAc,UAAU,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { initWith, loadExtractWith, loadTextWith } from "./init.js";
|
|
2
|
+
import { locate } from "./loader/fetch.js";
|
|
3
|
+
/**
|
|
4
|
+
* Loads the base WebAssembly module (fetched next to the package); with `{ text: true }`, the text
|
|
5
|
+
* module too. Idempotent: later calls return at once (or load the text module). Everything else
|
|
6
|
+
* in the package is synchronous and needs this promise to have resolved.
|
|
7
|
+
*
|
|
8
|
+
* @param input - where the base module comes from (a URL, `Response`, bytes or
|
|
9
|
+
* `WebAssembly.Module`), or options; omitted, the file next to the package.
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* await init(); // or: await init({ text: true })
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export function init(input) {
|
|
16
|
+
return initWith(locate, input);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Loads the text module (fonts, shaping and text layout; about 940 KB gzipped). Builders
|
|
20
|
+
* created afterwards can draw text. Idempotent.
|
|
21
|
+
*
|
|
22
|
+
* @param source - where it comes from; omitted, the file next to the package.
|
|
23
|
+
*/
|
|
24
|
+
export function loadText(source) {
|
|
25
|
+
return loadTextWith(locate, source);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Loads the extract module (reading plus text extraction). Documents opened afterwards can
|
|
29
|
+
* extract text with `page.text()`. Idempotent; not needed when the text module is loaded.
|
|
30
|
+
*
|
|
31
|
+
* @param source - where it comes from; omitted, the file next to the package.
|
|
32
|
+
*/
|
|
33
|
+
export function loadExtract(source) {
|
|
34
|
+
return loadExtractWith(locate, source);
|
|
35
|
+
}
|
|
36
|
+
export * from "./api.js";
|
|
37
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,IAAI,CAAC,KAAgC;IACnD,OAAO,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AACjC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAC,MAAmB;IAC1C,OAAO,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AACtC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,MAAmB;IAC7C,OAAO,eAAe,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AACzC,CAAC;AAED,cAAc,UAAU,CAAC"}
|
package/dist/init.d.ts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import * as baseGlue from "@laminapdf/wasm/base";
|
|
2
|
+
import { Instance } from "./internal/instance.js";
|
|
3
|
+
/** The base module's wasm-bindgen glue. */
|
|
4
|
+
export type BaseGlue = typeof baseGlue;
|
|
5
|
+
/** The text module's wasm-bindgen glue (a superset of the base module's API). */
|
|
6
|
+
export type TextGlue = typeof import("@laminapdf/wasm/text");
|
|
7
|
+
/**
|
|
8
|
+
* Where a module comes from: a URL (or URL string) to fetch, a `Response` (or a promise of one),
|
|
9
|
+
* the bytes, or a compiled `WebAssembly.Module` (Cloudflare Workers import one).
|
|
10
|
+
*/
|
|
11
|
+
export type WasmSource = URL | string | Response | PromiseLike<Response> | ArrayBuffer | ArrayBufferView | WebAssembly.Module;
|
|
12
|
+
/** Options for {@link init}. */
|
|
13
|
+
export interface InitOptions {
|
|
14
|
+
/** The base module (default: the `lamina_pdf_base.wasm` next to the package, per export condition). */
|
|
15
|
+
readonly module?: WasmSource;
|
|
16
|
+
/**
|
|
17
|
+
* Also load the text module (fonts and text): `true` for the default file, or where it comes
|
|
18
|
+
* from. Without it, only builders created after a later {@link loadText} can draw text.
|
|
19
|
+
*/
|
|
20
|
+
readonly text?: boolean | WasmSource;
|
|
21
|
+
/**
|
|
22
|
+
* Also load the extract module (reading plus text extraction, about half the text module's
|
|
23
|
+
* size): `true` for the default file, or where it comes from. Documents opened afterwards can
|
|
24
|
+
* extract text ({@link PageRef.text}). Not needed when the text module is loaded.
|
|
25
|
+
*/
|
|
26
|
+
readonly extract?: boolean | WasmSource;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* How an export condition finds a module's default file; `undefined` lets the wasm-bindgen glue
|
|
30
|
+
* fetch the `.wasm` next to itself.
|
|
31
|
+
*/
|
|
32
|
+
export type Locate = (module: "base" | "text" | "extract") => WasmSource | undefined | Promise<WasmSource | undefined>;
|
|
33
|
+
/** Loads the text module (once; a failed load can be retried). */
|
|
34
|
+
export declare function loadTextWith(locate: Locate, source?: WasmSource): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Loads the extract module (once; a failed load can be retried). Not when the text module is
|
|
37
|
+
* loaded or loading: it extracts too, and documents open in it first, so the extract module
|
|
38
|
+
* would never be used.
|
|
39
|
+
*/
|
|
40
|
+
export declare function loadExtractWith(locate: Locate, source?: WasmSource): Promise<void>;
|
|
41
|
+
/** `init` for an export condition's `locate`. */
|
|
42
|
+
export declare function initWith(locate: Locate, input?: WasmSource | InitOptions): Promise<void>;
|
|
43
|
+
/** The base module. @throws {@link LaminaPdfError} `not-initialized` before `init()`. */
|
|
44
|
+
export declare function baseModule(): Instance<BaseGlue>;
|
|
45
|
+
/**
|
|
46
|
+
* The module documents are opened in: the text module when loaded, else the extract module, else
|
|
47
|
+
* the base one (each a superset of the base module's reading API; the first two extract text).
|
|
48
|
+
* @throws {@link LaminaPdfError} `not-initialized` before `init()`.
|
|
49
|
+
*/
|
|
50
|
+
export declare function readingModule(): Instance<BaseGlue>;
|
|
51
|
+
/**
|
|
52
|
+
* Whether documents opened or built from now on can extract text: the extract or the text module
|
|
53
|
+
* is loaded. A document opened earlier stays in the module it was opened in; ask it with
|
|
54
|
+
* {@link Document.canExtractText}.
|
|
55
|
+
*/
|
|
56
|
+
export declare function isExtractLoaded(): boolean;
|
|
57
|
+
/** Whether `doc` lives in a module that extracts text (the extract or the text module). */
|
|
58
|
+
export declare function extractsText(doc: object): boolean;
|
|
59
|
+
/** The text module, when loaded. */
|
|
60
|
+
export declare function textModule(): Instance<TextGlue> | undefined;
|
|
61
|
+
/** Whether `init()` has finished. */
|
|
62
|
+
export declare function isInitialized(): boolean;
|
|
63
|
+
/** Whether the text module is loaded (builders created now can draw text). */
|
|
64
|
+
export declare function isTextLoaded(): boolean;
|
|
65
|
+
/** The size of each loaded module's linear memory, in bytes. */
|
|
66
|
+
export interface WasmMemory {
|
|
67
|
+
/** The base module's (absent before `init()`). */
|
|
68
|
+
readonly base?: number;
|
|
69
|
+
/** The text module's (absent until it is loaded). */
|
|
70
|
+
readonly text?: number;
|
|
71
|
+
/** The extract module's (absent until it is loaded). */
|
|
72
|
+
readonly extract?: number;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The size of each loaded module's WebAssembly memory. Memory grows and never shrinks; freed
|
|
76
|
+
* documents and builders leave room that later ones reuse.
|
|
77
|
+
*
|
|
78
|
+
* @returns the byte length of each loaded module's memory.
|
|
79
|
+
*/
|
|
80
|
+
export declare function wasmMemory(): WasmMemory;
|
|
81
|
+
/**
|
|
82
|
+
* Replaces each loaded module's instance with a fresh one, so its memory returns to the size it
|
|
83
|
+
* had after `init()`: WebAssembly memory grows and never shrinks, and this gives it back. Every
|
|
84
|
+
* document, page, builder and save job made before throws `instance-reset` afterwards, so call it
|
|
85
|
+
* while none is in use, such as between jobs on a server. Images and fonts keep working.
|
|
86
|
+
*/
|
|
87
|
+
export declare function reset(): void;
|
|
88
|
+
//# sourceMappingURL=init.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,QAAQ,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAElD,2CAA2C;AAC3C,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC;AACvC,iFAAiF;AACjF,MAAM,MAAM,QAAQ,GAAG,cAAc,sBAAsB,CAAC,CAAC;AAI7D;;;GAGG;AACH,MAAM,MAAM,UAAU,GAClB,GAAG,GACH,MAAM,GACN,QAAQ,GACR,WAAW,CAAC,QAAQ,CAAC,GACrB,WAAW,GACX,eAAe,GACf,WAAW,CAAC,MAAM,CAAC;AAEvB,gCAAgC;AAChC,MAAM,WAAW,WAAW;IAC1B,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,CAEtC;AAED,gEAAgE;AAChE,MAAM,WAAW,UAAU;IACzB,kDAAkD;IAClD,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,qDAAqD;IACrD,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,wDAAwD;IACxD,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,IAAI,UAAU,CAMvC;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,IAAI,IAAI,CAE5B"}
|
package/dist/init.js
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
// Loading the WebAssembly modules (ADR 0016 §2, §3): `init()` compiles and instantiates the base
|
|
2
|
+
// module once; the text module is loaded by `init({ text: true })` or `loadText()`, the extract
|
|
3
|
+
// module (base + text extraction) by `init({ extract: true })` or `loadExtract()`. After
|
|
4
|
+
// that, every call is synchronous. `reset()` replaces each loaded module's instance
|
|
5
|
+
// (internal/instance.ts). Each export condition supplies its own `Locate` (src/loader/), so
|
|
6
|
+
// this file has no environment detection and no runtime-specific API.
|
|
7
|
+
import * as baseGlue from "@laminapdf/wasm/base";
|
|
8
|
+
import { packageError } from "./errors.js";
|
|
9
|
+
import { Instance } from "./internal/instance.js";
|
|
10
|
+
const base = {};
|
|
11
|
+
const text = {};
|
|
12
|
+
const extract = {};
|
|
13
|
+
function isOptions(input) {
|
|
14
|
+
if (typeof input !== "object" || input === null || "then" in input)
|
|
15
|
+
return false;
|
|
16
|
+
const proto = Object.getPrototypeOf(input);
|
|
17
|
+
return proto === Object.prototype || proto === null;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Loads `slot`'s module once with `glue` (a failed load can be retried). A later call naming a
|
|
21
|
+
* different source than the first throws `already-initialized` instead of being ignored.
|
|
22
|
+
*/
|
|
23
|
+
function load(slot, name, glue, locate, source) {
|
|
24
|
+
if (slot.pending !== undefined) {
|
|
25
|
+
if (source !== undefined && source !== slot.requested) {
|
|
26
|
+
return Promise.reject(packageError("already-initialized", `the ${name} module is already loaded or loading from another source; the new source is ignored`));
|
|
27
|
+
}
|
|
28
|
+
return slot.pending;
|
|
29
|
+
}
|
|
30
|
+
slot.requested = source;
|
|
31
|
+
slot.pending = (async () => {
|
|
32
|
+
const g = await glue();
|
|
33
|
+
const from = source ?? (await locate(name));
|
|
34
|
+
const exports = (await g.default(from === undefined ? undefined : { module_or_path: from }));
|
|
35
|
+
slot.loaded = new Instance(name, g, exports);
|
|
36
|
+
})().catch((e) => {
|
|
37
|
+
slot.pending = undefined;
|
|
38
|
+
slot.requested = undefined;
|
|
39
|
+
throw e;
|
|
40
|
+
});
|
|
41
|
+
return slot.pending;
|
|
42
|
+
}
|
|
43
|
+
/** Loads the text module (once; a failed load can be retried). */
|
|
44
|
+
export function loadTextWith(locate, source) {
|
|
45
|
+
return load(text, "text", () => import("@laminapdf/wasm/text"), locate, source);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Loads the extract module (once; a failed load can be retried). Not when the text module is
|
|
49
|
+
* loaded or loading: it extracts too, and documents open in it first, so the extract module
|
|
50
|
+
* would never be used.
|
|
51
|
+
*/
|
|
52
|
+
export function loadExtractWith(locate, source) {
|
|
53
|
+
const loadIt = () => load(extract, "extract", () => import("@laminapdf/wasm/extract"), locate, source);
|
|
54
|
+
// A source given is honoured as for any module; without one, a text module loaded or loading
|
|
55
|
+
// makes the extract module unnecessary, unless that load fails.
|
|
56
|
+
if (source !== undefined || text.pending === undefined)
|
|
57
|
+
return loadIt();
|
|
58
|
+
return text.pending.catch(loadIt);
|
|
59
|
+
}
|
|
60
|
+
/** `init` for an export condition's `locate`. */
|
|
61
|
+
export async function initWith(locate, input) {
|
|
62
|
+
const options = input === undefined ? {} : isOptions(input) ? input : { module: input };
|
|
63
|
+
const loads = [load(base, "base", async () => baseGlue, locate, options.module)];
|
|
64
|
+
if (options.text !== undefined && options.text !== false) {
|
|
65
|
+
loads.push(loadTextWith(locate, options.text === true ? undefined : options.text));
|
|
66
|
+
}
|
|
67
|
+
// The text module extracts too: with it, the extract module would never be used.
|
|
68
|
+
if (options.extract !== undefined &&
|
|
69
|
+
options.extract !== false &&
|
|
70
|
+
(options.text === undefined || options.text === false)) {
|
|
71
|
+
loads.push(loadExtractWith(locate, options.extract === true ? undefined : options.extract));
|
|
72
|
+
}
|
|
73
|
+
await Promise.all(loads);
|
|
74
|
+
}
|
|
75
|
+
/** The base module. @throws {@link LaminaPdfError} `not-initialized` before `init()`. */
|
|
76
|
+
export function baseModule() {
|
|
77
|
+
if (base.loaded === undefined) {
|
|
78
|
+
throw packageError("not-initialized", "init() has not finished loading the WebAssembly module");
|
|
79
|
+
}
|
|
80
|
+
return base.loaded;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* The module documents are opened in: the text module when loaded, else the extract module, else
|
|
84
|
+
* the base one (each a superset of the base module's reading API; the first two extract text).
|
|
85
|
+
* @throws {@link LaminaPdfError} `not-initialized` before `init()`.
|
|
86
|
+
*/
|
|
87
|
+
export function readingModule() {
|
|
88
|
+
const base = baseModule();
|
|
89
|
+
return (text.loaded ?? extract.loaded ?? base);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Whether documents opened or built from now on can extract text: the extract or the text module
|
|
93
|
+
* is loaded. A document opened earlier stays in the module it was opened in; ask it with
|
|
94
|
+
* {@link Document.canExtractText}.
|
|
95
|
+
*/
|
|
96
|
+
export function isExtractLoaded() {
|
|
97
|
+
return extract.loaded !== undefined || text.loaded !== undefined;
|
|
98
|
+
}
|
|
99
|
+
/** Whether `doc` lives in a module that extracts text (the extract or the text module). */
|
|
100
|
+
export function extractsText(doc) {
|
|
101
|
+
return ((text.loaded !== undefined && doc instanceof text.loaded.glue.WasmDocument) ||
|
|
102
|
+
(extract.loaded !== undefined && doc instanceof extract.loaded.glue.WasmDocument));
|
|
103
|
+
}
|
|
104
|
+
/** The text module, when loaded. */
|
|
105
|
+
export function textModule() {
|
|
106
|
+
return text.loaded;
|
|
107
|
+
}
|
|
108
|
+
/** Whether `init()` has finished. */
|
|
109
|
+
export function isInitialized() {
|
|
110
|
+
return base.loaded !== undefined;
|
|
111
|
+
}
|
|
112
|
+
/** Whether the text module is loaded (builders created now can draw text). */
|
|
113
|
+
export function isTextLoaded() {
|
|
114
|
+
return text.loaded !== undefined;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* The size of each loaded module's WebAssembly memory. Memory grows and never shrinks; freed
|
|
118
|
+
* documents and builders leave room that later ones reuse.
|
|
119
|
+
*
|
|
120
|
+
* @returns the byte length of each loaded module's memory.
|
|
121
|
+
*/
|
|
122
|
+
export function wasmMemory() {
|
|
123
|
+
return {
|
|
124
|
+
...(base.loaded === undefined ? {} : { base: base.loaded.memoryBytes }),
|
|
125
|
+
...(text.loaded === undefined ? {} : { text: text.loaded.memoryBytes }),
|
|
126
|
+
...(extract.loaded === undefined ? {} : { extract: extract.loaded.memoryBytes }),
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Replaces each loaded module's instance with a fresh one, so its memory returns to the size it
|
|
131
|
+
* had after `init()`: WebAssembly memory grows and never shrinks, and this gives it back. Every
|
|
132
|
+
* document, page, builder and save job made before throws `instance-reset` afterwards, so call it
|
|
133
|
+
* while none is in use, such as between jobs on a server. Images and fonts keep working.
|
|
134
|
+
*/
|
|
135
|
+
export function reset() {
|
|
136
|
+
for (const slot of [base, text, extract])
|
|
137
|
+
slot.loaded?.replace();
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=init.js.map
|
package/dist/init.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAAA,iGAAiG;AACjG,gGAAgG;AAChG,yFAAyF;AACzF,oFAAoF;AACpF,4FAA4F;AAC5F,sEAAsE;AACtE,OAAO,KAAK,QAAQ,MA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AC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;KACjF,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,KAAK;IACnB,KAAK,MAAM,IAAI,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC;QAAE,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC;AACnE,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { Glue, Instance } from "./instance.js";
|
|
2
|
+
/** A handle the garbage collector reclaimed without a `free()`. */
|
|
3
|
+
export interface Leak {
|
|
4
|
+
/** The handle's class: `Document`, `Builder` or `Image`. */
|
|
5
|
+
readonly handle: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Reports every document, builder and image created from now on that the garbage collector
|
|
9
|
+
* reclaims without a `free()` or `using`: a debugging aid for code that should free what it
|
|
10
|
+
* makes. Reclaimed handles are freed anyway, only later. `onLeak()` turns the reports off.
|
|
11
|
+
*
|
|
12
|
+
* @param hook - called once per leaked handle, some time after the collection.
|
|
13
|
+
*/
|
|
14
|
+
export declare function onLeak(hook?: (leak: Leak) => void): void;
|
|
15
|
+
/** Watches `handle` for a leak while a hook is set; {@link forget} once it is freed. */
|
|
16
|
+
export declare function watch(handle: object, name: string): void;
|
|
17
|
+
/** Stops watching `handle`. */
|
|
18
|
+
export declare function forget(handle: object): void;
|
|
19
|
+
/** A handle on memory in one WebAssembly instance. */
|
|
20
|
+
export declare abstract class Handle<G extends Glue = Glue> {
|
|
21
|
+
#private;
|
|
22
|
+
/**
|
|
23
|
+
* @param name - the class, as messages name it.
|
|
24
|
+
* @param instance - the instance the handle's memory lives in.
|
|
25
|
+
* @param parent - the handle it is freed with, if any.
|
|
26
|
+
*/
|
|
27
|
+
protected constructor(name: string, instance: Instance<G>, parent?: Handle);
|
|
28
|
+
/** The instance this handle lives in (for the handles it makes). */
|
|
29
|
+
protected get instance(): Instance<G>;
|
|
30
|
+
/** Whether the handle's raw objects can be freed: its instance is current and hasn't trapped. */
|
|
31
|
+
protected get owned(): boolean;
|
|
32
|
+
/** Whether `free()` ran on this handle or its parent. */
|
|
33
|
+
protected get isFreed(): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* @throws {@link LaminaPdfError} `disposed` after `free()` (here or on the parent);
|
|
36
|
+
* `instance-reset` when the instance was replaced (a trapped one is replaced first).
|
|
37
|
+
*/
|
|
38
|
+
protected assertLive(): void;
|
|
39
|
+
/** Runs `f` (calls into the glue) on this live handle; see {@link Instance.call}. */
|
|
40
|
+
protected call<T>(f: (glue: G) => T): T;
|
|
41
|
+
/** Frees the WebAssembly side; called at most once, and only while {@link owned}. */
|
|
42
|
+
protected abstract release(): void;
|
|
43
|
+
/**
|
|
44
|
+
* Frees the handle's memory now; without it, the garbage collector frees it later. A second
|
|
45
|
+
* call does nothing, and any other call afterwards throws `disposed`. Prefer `using`, which
|
|
46
|
+
* calls this at the end of the block.
|
|
47
|
+
*/
|
|
48
|
+
free(): void;
|
|
49
|
+
/** Frees the handle at the end of a `using` block (an alias of `free()`). */
|
|
50
|
+
[Symbol.dispose](): void;
|
|
51
|
+
}
|
|
52
|
+
/** Gives `target`'s prototype the dispose method under {@link DISPOSE} where it isn't `Symbol.dispose`. */
|
|
53
|
+
export declare function disposable(target: {
|
|
54
|
+
readonly prototype: {
|
|
55
|
+
free(): void;
|
|
56
|
+
};
|
|
57
|
+
}): void;
|
|
58
|
+
//# sourceMappingURL=handle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handle.d.ts","sourceRoot":"","sources":["../../src/internal/handle.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAQpD,mEAAmE;AACnE,MAAM,WAAW,IAAI;IACnB,4DAA4D;IAC5D,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAQD;;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