@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,113 @@
|
|
|
1
|
+
// The base of every handle that owns memory in a WebAssembly instance: `free()` and
|
|
2
|
+
// `Symbol.dispose` (the same thing; a second call does nothing), `disposed` for any call after it,
|
|
3
|
+
// `instance-reset` for a handle whose instance was replaced, and a parent that frees it too (a
|
|
4
|
+
// page with its document or builder). A handle the garbage collector reclaims is still freed, by
|
|
5
|
+
// wasm-bindgen's own finalizer; `onLeak` reports those.
|
|
6
|
+
import { packageError } from "../errors.js";
|
|
7
|
+
/**
|
|
8
|
+
* `Symbol.dispose`, or, where a runtime lacks it (Safari), `Symbol.for("Symbol.dispose")`: the key
|
|
9
|
+
* the `using` helpers of esbuild and Babel fall back to.
|
|
10
|
+
*/
|
|
11
|
+
const DISPOSE = typeof Symbol.dispose === "symbol" ? Symbol.dispose : Symbol.for("Symbol.dispose");
|
|
12
|
+
let leakHook;
|
|
13
|
+
const leaks = typeof FinalizationRegistry === "function"
|
|
14
|
+
? new FinalizationRegistry((handle) => leakHook?.({ handle }))
|
|
15
|
+
: undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Reports every document, builder and image created from now on that the garbage collector
|
|
18
|
+
* reclaims without a `free()` or `using`: a debugging aid for code that should free what it
|
|
19
|
+
* makes. Reclaimed handles are freed anyway, only later. `onLeak()` turns the reports off.
|
|
20
|
+
*
|
|
21
|
+
* @param hook - called once per leaked handle, some time after the collection.
|
|
22
|
+
*/
|
|
23
|
+
export function onLeak(hook) {
|
|
24
|
+
leakHook = hook;
|
|
25
|
+
}
|
|
26
|
+
/** Watches `handle` for a leak while a hook is set; {@link forget} once it is freed. */
|
|
27
|
+
export function watch(handle, name) {
|
|
28
|
+
if (leakHook !== undefined)
|
|
29
|
+
leaks?.register(handle, name, handle);
|
|
30
|
+
}
|
|
31
|
+
/** Stops watching `handle`. */
|
|
32
|
+
export function forget(handle) {
|
|
33
|
+
leaks?.unregister(handle);
|
|
34
|
+
}
|
|
35
|
+
/** A handle on memory in one WebAssembly instance. */
|
|
36
|
+
export class Handle {
|
|
37
|
+
/** The class, for messages (minifiers rename classes). */
|
|
38
|
+
#name;
|
|
39
|
+
#instance;
|
|
40
|
+
#generation;
|
|
41
|
+
#parent;
|
|
42
|
+
#freed = false;
|
|
43
|
+
/**
|
|
44
|
+
* @param name - the class, as messages name it.
|
|
45
|
+
* @param instance - the instance the handle's memory lives in.
|
|
46
|
+
* @param parent - the handle it is freed with, if any.
|
|
47
|
+
*/
|
|
48
|
+
constructor(name, instance, parent) {
|
|
49
|
+
this.#name = name;
|
|
50
|
+
this.#instance = instance;
|
|
51
|
+
this.#generation = instance.generation;
|
|
52
|
+
this.#parent = parent;
|
|
53
|
+
}
|
|
54
|
+
/** The instance this handle lives in (for the handles it makes). */
|
|
55
|
+
get instance() {
|
|
56
|
+
return this.#instance;
|
|
57
|
+
}
|
|
58
|
+
/** Whether the handle's raw objects can be freed: its instance is current and hasn't trapped. */
|
|
59
|
+
get owned() {
|
|
60
|
+
return this.#instance.owns(this.#generation);
|
|
61
|
+
}
|
|
62
|
+
/** Whether `free()` ran on this handle or its parent. */
|
|
63
|
+
get isFreed() {
|
|
64
|
+
return this.#freed || this.#parent?.isFreed === true;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* @throws {@link LaminaPdfError} `disposed` after `free()` (here or on the parent);
|
|
68
|
+
* `instance-reset` when the instance was replaced (a trapped one is replaced first).
|
|
69
|
+
*/
|
|
70
|
+
assertLive() {
|
|
71
|
+
if (this.isFreed) {
|
|
72
|
+
throw packageError("disposed", `the ${this.#name} was used after free() or its using block`);
|
|
73
|
+
}
|
|
74
|
+
this.#instance.check(this.#generation, this.#name);
|
|
75
|
+
}
|
|
76
|
+
/** Runs `f` (calls into the glue) on this live handle; see {@link Instance.call}. */
|
|
77
|
+
call(f) {
|
|
78
|
+
this.assertLive();
|
|
79
|
+
return this.#instance.call(f);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Frees the handle's memory now; without it, the garbage collector frees it later. A second
|
|
83
|
+
* call does nothing, and any other call afterwards throws `disposed`. Prefer `using`, which
|
|
84
|
+
* calls this at the end of the block.
|
|
85
|
+
*/
|
|
86
|
+
free() {
|
|
87
|
+
if (this.#freed)
|
|
88
|
+
return;
|
|
89
|
+
this.#freed = true;
|
|
90
|
+
forget(this);
|
|
91
|
+
// A replaced instance's memory is gone already, and its objects must not reach the new one.
|
|
92
|
+
if (this.owned)
|
|
93
|
+
this.release();
|
|
94
|
+
}
|
|
95
|
+
/** Frees the handle at the end of a `using` block (an alias of `free()`). */
|
|
96
|
+
[Symbol.dispose]() {
|
|
97
|
+
this.free();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/** Gives `target`'s prototype the dispose method under {@link DISPOSE} where it isn't `Symbol.dispose`. */
|
|
101
|
+
export function disposable(target) {
|
|
102
|
+
if (DISPOSE === Symbol.dispose)
|
|
103
|
+
return;
|
|
104
|
+
Object.defineProperty(target.prototype, DISPOSE, {
|
|
105
|
+
value() {
|
|
106
|
+
this.free();
|
|
107
|
+
},
|
|
108
|
+
configurable: true,
|
|
109
|
+
writable: true,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
disposable(Handle);
|
|
113
|
+
//# sourceMappingURL=handle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handle.js","sourceRoot":"","sources":["../../src/internal/handle.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,mGAAmG;AACnG,+FAA+F;AAC/F,iGAAiG;AACjG,wDAAwD;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAG5C;;;GAGG;AACH,MAAM,OAAO,GAAW,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;AAQ3G,IAAI,QAA4C,CAAC;AACjD,MAAM,KAAK,GACT,OAAO,oBAAoB,KAAK,UAAU;IACxC,CAAC,CAAC,IAAI,oBAAoB,CAAS,CAAC,MAAM,EAAE,EAAE,CAAC,QAAQ,EAAE,CAAC,EAAE,MAAM,EAAE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E,CAAC;YACjB,MAAM,YAAY,CAAC,UAAU,EAAE,OAAO,IAAI,CAAC,KAAK,2CAA2C,CAAC,CAAC;QAC/F,CAAC;QACD,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IACrD,CAAC;IAED,qFAAqF;IAC3E,IAAI,CAAI,CAAiB;QACjC,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAChC,CAAC;IAKD;;;;OAIG;IACH,IAAI;QACF,IAAI,IAAI,CAAC,MAAM;YAAE,OAAO;QACxB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,MAAM,CAAC,IAAI,CAAC,CAAC;QACb,4FAA4F;QAC5F,IAAI,IAAI,CAAC,KAAK;YAAE,IAAI,CAAC,OAAO,EAAE,CAAC;IACjC,CAAC;IAED,6EAA6E;IAC7E,CAAC,MAAM,CAAC,OAAO,CAAC;QACd,IAAI,CAAC,IAAI,EAAE,CAAC;IACd,CAAC;CACF;AAED,2GAA2G;AAC3G,MAAM,UAAU,UAAU,CAAC,MAAgD;IACzE,IAAI,OAAO,KAAK,MAAM,CAAC,OAAO;QAAE,OAAO;IACvC,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,EAAE;QAC/C,KAAK;YACH,IAAI,CAAC,IAAI,EAAE,CAAC;QACd,CAAC;QACD,YAAY,EAAE,IAAI;QAClB,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC;AACL,CAAC;AAED,UAAU,CAAC,MAAM,CAAC,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether `e` is a trap: as {@link Instance.call} reports one (`wasm-trap`, `out-of-memory`), or
|
|
3
|
+
* raw from a module the package doesn't guard (an extension's PDFium).
|
|
4
|
+
*/
|
|
5
|
+
export declare function isTrap(e: unknown): boolean;
|
|
6
|
+
/** The modules of `@laminapdf/wasm` that `@laminapdf/sdk` loads. */
|
|
7
|
+
export type ModuleName = "base" | "text" | "extract";
|
|
8
|
+
/** The exports every wasm-bindgen module has. */
|
|
9
|
+
interface Exports {
|
|
10
|
+
readonly memory: WebAssembly.Memory;
|
|
11
|
+
}
|
|
12
|
+
/** What `@laminapdf/sdk` needs from a module's glue besides its classes. */
|
|
13
|
+
export interface Glue {
|
|
14
|
+
/** Replaces the instance with a fresh one of the same compiled module. */
|
|
15
|
+
__wbg_reset_state(): void;
|
|
16
|
+
/** Whether an allocation failed in the current instance. */
|
|
17
|
+
allocationFailed(): boolean;
|
|
18
|
+
/** Once the module is loaded: the current instance's exports. */
|
|
19
|
+
initSync(module: never): Exports;
|
|
20
|
+
}
|
|
21
|
+
/** One loaded module: its glue, and which of its instances is current. */
|
|
22
|
+
export declare class Instance<G extends Glue = Glue> {
|
|
23
|
+
#private;
|
|
24
|
+
readonly name: ModuleName;
|
|
25
|
+
readonly glue: G;
|
|
26
|
+
constructor(name: ModuleName, glue: G, exports: Exports);
|
|
27
|
+
/** Which instance is current; a handle keeps the one it was made in. */
|
|
28
|
+
get generation(): number;
|
|
29
|
+
/** The size of the current instance's memory, in bytes. */
|
|
30
|
+
get memoryBytes(): number;
|
|
31
|
+
/**
|
|
32
|
+
* Whether objects made in `generation` can still be freed: it is current, and hasn't trapped
|
|
33
|
+
* (a trapped instance is about to be replaced, and freeing into it could trap again).
|
|
34
|
+
*/
|
|
35
|
+
owns(generation: number): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Throws `instance-reset` unless objects made in `generation` belong to the current instance,
|
|
38
|
+
* after replacing an instance that trapped (so a trap's survivors never reach the fresh one).
|
|
39
|
+
*
|
|
40
|
+
* @param name - what holds the objects, for the message.
|
|
41
|
+
*/
|
|
42
|
+
check(generation: number, name: string): void;
|
|
43
|
+
/** The glue, after replacing an instance that trapped. */
|
|
44
|
+
live(): G;
|
|
45
|
+
/** Replaces the instance with a fresh one: memory back to its initial size, every handle gone. */
|
|
46
|
+
replace(): void;
|
|
47
|
+
/**
|
|
48
|
+
* Runs one call into the glue, after replacing an instance that trapped.
|
|
49
|
+
*
|
|
50
|
+
* @throws {@link LaminaPdfError} for the §1 object the module throws; `wasm-trap` or
|
|
51
|
+
* `out-of-memory` when it traps or overflows the stack (the next call gets a fresh instance).
|
|
52
|
+
*/
|
|
53
|
+
call<T>(f: (glue: G) => T): T;
|
|
54
|
+
}
|
|
55
|
+
export {};
|
|
56
|
+
//# sourceMappingURL=instance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instance.d.ts","sourceRoot":"","sources":["../../src/internal/instance.ts"],"names":[],"mappings":"AAsBA;;;GAGG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAE1C;AAED,oEAAoE;AACpE,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AAErD,iDAAiD;AACjD,UAAU,OAAO;IACf,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC;CACrC;AAED,4EAA4E;AAC5E,MAAM,WAAW,IAAI;IACnB,0EAA0E;IAC1E,iBAAiB,IAAI,IAAI,CAAC;IAC1B,4DAA4D;IAC5D,gBAAgB,IAAI,OAAO,CAAC;IAC5B,iEAAiE;IACjE,QAAQ,CAAC,MAAM,EAAE,KAAK,GAAG,OAAO,CAAC;CAClC;AAED,0EAA0E;AAC1E,qBAAa,QAAQ,CAAC,CAAC,SAAS,IAAI,GAAG,IAAI;;IACzC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IAMjB,YAAY,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,OAAO,EAItD;IAED,wEAAwE;IACxE,IAAI,UAAU,IAAI,MAAM,CAEvB;IAED,2DAA2D;IAC3D,IAAI,WAAW,IAAI,MAAM,CAExB;IAED;;;OAGG;IACH,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAEhC;IAED;;;;;OAKG;IACH,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAQ5C;IAED,0DAA0D;IAC1D,IAAI,IAAI,CAAC,CAGR;IAED,kGAAkG;IAClG,OAAO,IAAI,IAAI,CAMd;IAED;;;;;OAKG;IACH,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAO5B;CA2BF"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// The WebAssembly instances behind every handle. A trap (a bug, or growth past the memory maximum
|
|
2
|
+
// set when the modules are built) can leave an instance's memory half-written, so the call that
|
|
3
|
+
// trapped throws `wasm-trap` or `out-of-memory`, and the next call first replaces the instance with
|
|
4
|
+
// a fresh one of the same compiled module (wasm-bindgen's `__wbg_reset_state`); `reset()` replaces
|
|
5
|
+
// every one. Each replacement starts a new generation: a handle made in an older one throws
|
|
6
|
+
// `instance-reset` rather than reach into the new instance's memory.
|
|
7
|
+
import { isDiagnostic, isLaminaPdfError, LaminaPdfError, packageError } from "../errors.js";
|
|
8
|
+
/**
|
|
9
|
+
* Whether `e` stopped WebAssembly code mid-call: a trap (`RuntimeError`), or the engine's stack
|
|
10
|
+
* overflowing inside it (V8 and JavaScriptCore throw a `RangeError`, Firefox an `InternalError`).
|
|
11
|
+
* Either leaves the instance's memory half-written.
|
|
12
|
+
*/
|
|
13
|
+
function stoppedMidCall(e) {
|
|
14
|
+
if (e instanceof WebAssembly.RuntimeError)
|
|
15
|
+
return true;
|
|
16
|
+
if (!(e instanceof Error))
|
|
17
|
+
return false;
|
|
18
|
+
return ((e instanceof RangeError && /call stack/i.test(e.message)) ||
|
|
19
|
+
(e.name === "InternalError" && /recursion/i.test(e.message)));
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Whether `e` is a trap: as {@link Instance.call} reports one (`wasm-trap`, `out-of-memory`), or
|
|
23
|
+
* raw from a module the package doesn't guard (an extension's PDFium).
|
|
24
|
+
*/
|
|
25
|
+
export function isTrap(e) {
|
|
26
|
+
return stoppedMidCall(e) || isLaminaPdfError(e, "wasm-trap") || isLaminaPdfError(e, "out-of-memory");
|
|
27
|
+
}
|
|
28
|
+
/** One loaded module: its glue, and which of its instances is current. */
|
|
29
|
+
export class Instance {
|
|
30
|
+
name;
|
|
31
|
+
glue;
|
|
32
|
+
#memory;
|
|
33
|
+
#generation = 0;
|
|
34
|
+
/** Set by a trap: the next call replaces the instance first. */
|
|
35
|
+
#poisoned = false;
|
|
36
|
+
constructor(name, glue, exports) {
|
|
37
|
+
this.name = name;
|
|
38
|
+
this.glue = glue;
|
|
39
|
+
this.#memory = exports.memory;
|
|
40
|
+
}
|
|
41
|
+
/** Which instance is current; a handle keeps the one it was made in. */
|
|
42
|
+
get generation() {
|
|
43
|
+
return this.#generation;
|
|
44
|
+
}
|
|
45
|
+
/** The size of the current instance's memory, in bytes. */
|
|
46
|
+
get memoryBytes() {
|
|
47
|
+
return this.#memory.buffer.byteLength;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Whether objects made in `generation` can still be freed: it is current, and hasn't trapped
|
|
51
|
+
* (a trapped instance is about to be replaced, and freeing into it could trap again).
|
|
52
|
+
*/
|
|
53
|
+
owns(generation) {
|
|
54
|
+
return generation === this.#generation && !this.#poisoned;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Throws `instance-reset` unless objects made in `generation` belong to the current instance,
|
|
58
|
+
* after replacing an instance that trapped (so a trap's survivors never reach the fresh one).
|
|
59
|
+
*
|
|
60
|
+
* @param name - what holds the objects, for the message.
|
|
61
|
+
*/
|
|
62
|
+
check(generation, name) {
|
|
63
|
+
this.live();
|
|
64
|
+
if (generation !== this.#generation) {
|
|
65
|
+
throw packageError("instance-reset", `the ${name} belongs to a WebAssembly instance that reset() or a trap replaced`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/** The glue, after replacing an instance that trapped. */
|
|
69
|
+
live() {
|
|
70
|
+
if (this.#poisoned)
|
|
71
|
+
this.replace();
|
|
72
|
+
return this.glue;
|
|
73
|
+
}
|
|
74
|
+
/** Replaces the instance with a fresh one: memory back to its initial size, every handle gone. */
|
|
75
|
+
replace() {
|
|
76
|
+
this.glue.__wbg_reset_state();
|
|
77
|
+
// The glue's `initSync` returns early with the current exports once the module is loaded.
|
|
78
|
+
this.#memory = this.glue.initSync(undefined).memory;
|
|
79
|
+
this.#generation++;
|
|
80
|
+
this.#poisoned = false;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Runs one call into the glue, after replacing an instance that trapped.
|
|
84
|
+
*
|
|
85
|
+
* @throws {@link LaminaPdfError} for the §1 object the module throws; `wasm-trap` or
|
|
86
|
+
* `out-of-memory` when it traps or overflows the stack (the next call gets a fresh instance).
|
|
87
|
+
*/
|
|
88
|
+
call(f) {
|
|
89
|
+
const glue = this.live();
|
|
90
|
+
try {
|
|
91
|
+
return f(glue);
|
|
92
|
+
}
|
|
93
|
+
catch (e) {
|
|
94
|
+
throw this.#wrap(e);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
#wrap(e) {
|
|
98
|
+
if (isDiagnostic(e))
|
|
99
|
+
return new LaminaPdfError(e);
|
|
100
|
+
if (!stoppedMidCall(e))
|
|
101
|
+
return e;
|
|
102
|
+
this.#poisoned = true;
|
|
103
|
+
const module = this.name;
|
|
104
|
+
if (this.#allocationFailed()) {
|
|
105
|
+
return packageError("out-of-memory", `the ${module} module ran out of memory; the next call starts afresh`, {
|
|
106
|
+
data: { module, memoryBytes: this.memoryBytes },
|
|
107
|
+
cause: e,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
return packageError("wasm-trap", `the ${module} module trapped; the next call starts afresh`, {
|
|
111
|
+
data: { module },
|
|
112
|
+
cause: e,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
/** Whether the trapped instance ran out of memory. Reading its flag is safe: a trap leaves memory as it was. */
|
|
116
|
+
#allocationFailed() {
|
|
117
|
+
try {
|
|
118
|
+
return this.glue.allocationFailed();
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=instance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instance.js","sourceRoot":"","sources":["../../src/internal/instance.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,gGAAgG;AAChG,oGAAoG;AACpG,mGAAmG;AACnG,4FAA4F;AAC5F,qEAAqE;AACrE,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5F;;;;GAIG;AACH,SAAS,cAAc,CAAC,CAAU;IAChC,IAAI,CAAC,YAAY,WAAW,CAAC,YAAY;QAAE,OAAO,IAAI,CAAC;IACvD,IAAI,CAAC,CAAC,CAAC,YAAY,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACxC,OAAO,CACL,CAAC,CAAC,YAAY,UAAU,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QAC1D,CAAC,CAAC,CAAC,IAAI,KAAK,eAAe,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAC7D,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,MAAM,CAAC,CAAU;IAC/B,OAAO,cAAc,CAAC,CAAC,CAAC,IAAI,gBAAgB,CAAC,CAAC,EAAE,WAAW,CAAC,IAAI,gBAAgB,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC;AACvG,CAAC;AAoBD,0EAA0E;AAC1E,MAAM,OAA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.d.ts","sourceRoot":"","sources":["../../src/loader/fetch.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC,eAAO,MAAM,MAAM,EAAE,MAAwB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../src/loader/fetch.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,MAAM,GAAW,GAAG,EAAE,CAAC,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/loader/node.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC,eAAO,MAAM,MAAM,EAAE,MASlB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// The `node` condition (Node, Bun): the `.wasm` file of @laminapdf/wasm, read as bytes (Node's
|
|
2
|
+
// fetch can't read file: URLs). The one file in src/ allowed a Node API (biome.json override).
|
|
3
|
+
import { readFile } from "node:fs/promises";
|
|
4
|
+
export const locate = (module) => readFile(new URL(module === "base"
|
|
5
|
+
? import.meta.resolve("@laminapdf/wasm/lamina_pdf_base.wasm")
|
|
6
|
+
: module === "text"
|
|
7
|
+
? import.meta.resolve("@laminapdf/wasm/lamina_pdf_text.wasm")
|
|
8
|
+
: import.meta.resolve("@laminapdf/wasm/lamina_pdf_extract.wasm")));
|
|
9
|
+
//# sourceMappingURL=node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/loader/node.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,+FAA+F;AAC/F,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C,MAAM,CAAC,MAAM,MAAM,GAAW,CAAC,MAAM,EAAE,EAAE,CACvC,QAAQ,CACN,IAAI,GAAG,CACL,MAAM,KAAK,MAAM;IACf,CAAC,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,sCAAsC,CAAC;IAC7D,CAAC,CAAC,MAAM,KAAK,MAAM;QACjB,CAAC,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,sCAAsC,CAAC;QAC7D,CAAC,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,yCAAyC,CAAC,CACrE,CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workerd.d.ts","sourceRoot":"","sources":["../../src/loader/workerd.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAIzC,eAAO,MAAM,MAAM,EAAE,MAQpB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// The `workerd` condition (Cloudflare Workers): Workers can't compile WebAssembly at run time,
|
|
2
|
+
// so the modules are imported statically; wrangler turns a `.wasm` import into a
|
|
3
|
+
// `WebAssembly.Module` (ADR 0016 §2). Both modules are part of the Worker's bundle.
|
|
4
|
+
import base from "@laminapdf/wasm/lamina_pdf_base.wasm";
|
|
5
|
+
import text from "@laminapdf/wasm/lamina_pdf_text.wasm";
|
|
6
|
+
import { packageError } from "../errors.js";
|
|
7
|
+
// The extract module isn't imported here: a static import would put it in every Worker's bundle
|
|
8
|
+
// (about 526 KB gzip) whether or not it extracts text. A Worker that does passes it itself.
|
|
9
|
+
export const locate = (module) => {
|
|
10
|
+
if (module === "extract") {
|
|
11
|
+
throw packageError("extract-module-not-loaded", 'in workerd, pass the extract module: import extract from "@laminapdf/wasm/lamina_pdf_extract.wasm"; await loadExtract(extract)');
|
|
12
|
+
}
|
|
13
|
+
return module === "base" ? base : text;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=workerd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workerd.js","sourceRoot":"","sources":["../../src/loader/workerd.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,iFAAiF;AACjF,oFAAoF;AACpF,OAAO,IAAI,MAAM,sCAAsC,CAAC;AACxD,OAAO,IAAI,MAAM,sCAAsC,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAG5C,gGAAgG;AAChG,4FAA4F;AAC5F,MAAM,CAAC,MAAM,MAAM,GAAW,CAAC,MAAM,EAAE,EAAE;IACvC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,MAAM,YAAY,CAChB,2BAA2B,EAC3B,gIAAgI,CACjI,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;AACzC,CAAC,CAAC"}
|
package/dist/matrix.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** A transformation matrix `[a, b, c, d, e, f]` (ISO 32000-2 §8.3.4), in page space. */
|
|
2
|
+
export type Transform = readonly [a: number, b: number, c: number, d: number, e: number, f: number];
|
|
3
|
+
/** Building transformation matrices. */
|
|
4
|
+
export declare const Matrix: {
|
|
5
|
+
/** The identity. */
|
|
6
|
+
readonly identity: Transform;
|
|
7
|
+
/** A translation by (x, y) points. */
|
|
8
|
+
readonly translate: (x: number, y: number) => Transform;
|
|
9
|
+
/** A scaling by `sx` horizontally and `sy` vertically. */
|
|
10
|
+
readonly scale: (sx: number, sy: number) => Transform;
|
|
11
|
+
/** A rotation by `degrees` about the origin, clockwise as displayed. */
|
|
12
|
+
readonly rotate: (degrees: number) => Transform;
|
|
13
|
+
/** `outer` applied after `inner`: maps p to outer(inner(p)). */
|
|
14
|
+
readonly after: (outer: Transform, inner: Transform) => Transform;
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=matrix.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"matrix.d.ts","sourceRoot":"","sources":["../src/matrix.ts"],"names":[],"mappings":"AAGA,wFAAwF;AACxF,MAAM,MAAM,SAAS,GAAG,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;AAEpG,wCAAwC;AACxC,eAAO,MAAM,MAAM;IACjB,oBAAoB;aACpB,QAAQ,EAAwB,SAAS;IACzC,sCAAsC;aACtC,SAAS,MAAI,MAAM,KAAK,MAAM,KAAG,SAAS;IAG1C,0DAA0D;aAC1D,KAAK,OAAK,MAAM,MAAM,MAAM,KAAG,SAAS;IAGxC,wEAAwE;aACxE,MAAM,YAAU,MAAM,KAAG,SAAS;IAMlC,gEAAgE;aAChE,KAAK,UAAQ,SAAS,SAAS,SAAS,KAAG,SAAS;CAY5C,CAAC"}
|
package/dist/matrix.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// Transformation matrices `[a b c d e f]` in page space, computed as the Rust `Matrix` does so
|
|
2
|
+
// that the same drawing gives the same bytes.
|
|
3
|
+
/** Building transformation matrices. */
|
|
4
|
+
export const Matrix = {
|
|
5
|
+
/** The identity. */
|
|
6
|
+
identity: [1, 0, 0, 1, 0, 0],
|
|
7
|
+
/** A translation by (x, y) points. */
|
|
8
|
+
translate(x, y) {
|
|
9
|
+
return [1, 0, 0, 1, x, y];
|
|
10
|
+
},
|
|
11
|
+
/** A scaling by `sx` horizontally and `sy` vertically. */
|
|
12
|
+
scale(sx, sy) {
|
|
13
|
+
return [sx, 0, 0, sy, 0, 0];
|
|
14
|
+
},
|
|
15
|
+
/** A rotation by `degrees` about the origin, clockwise as displayed. */
|
|
16
|
+
rotate(degrees) {
|
|
17
|
+
const radians = degrees * (Math.PI / 180);
|
|
18
|
+
const s = Math.sin(radians);
|
|
19
|
+
const c = Math.cos(radians);
|
|
20
|
+
return [c, s, -s, c, 0, 0];
|
|
21
|
+
},
|
|
22
|
+
/** `outer` applied after `inner`: maps p to outer(inner(p)). */
|
|
23
|
+
after(outer, inner) {
|
|
24
|
+
const [a, b, c, d, e, f] = outer;
|
|
25
|
+
const [ia, ib, ic, id, ie, iff] = inner;
|
|
26
|
+
return [
|
|
27
|
+
a * ia + c * ib,
|
|
28
|
+
b * ia + d * ib,
|
|
29
|
+
a * ic + c * id,
|
|
30
|
+
b * ic + d * id,
|
|
31
|
+
a * ie + c * iff + e,
|
|
32
|
+
b * ie + d * iff + f,
|
|
33
|
+
];
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=matrix.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"matrix.js","sourceRoot":"","sources":["../src/matrix.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,8CAA8C;AAK9C,wCAAwC;AACxC,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,oBAAoB;IACpB,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAc;IACzC,sCAAsC;IACtC,SAAS,CAAC,CAAS,EAAE,CAAS;QAC5B,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAC5B,CAAC;IACD,0DAA0D;IAC1D,KAAK,CAAC,EAAU,EAAE,EAAU;QAC1B,OAAO,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAC9B,CAAC;IACD,wEAAwE;IACxE,MAAM,CAAC,OAAe;QACpB,MAAM,OAAO,GAAG,OAAO,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC;QAC1C,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC5B,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC5B,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAC7B,CAAC;IACD,gEAAgE;IAChE,KAAK,CAAC,KAAgB,EAAE,KAAgB;QACtC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC;QACjC,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC;QACxC,OAAO;YACL,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE;YACf,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE;YACf,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE;YACf,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE;YACf,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC;YACpB,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC;SACrB,CAAC;IACJ,CAAC;CACO,CAAC"}
|
package/dist/path.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Point, Rect } from "./types.js";
|
|
2
|
+
/** Builds a path in page space; every method returns the builder, so calls chain. */
|
|
3
|
+
export interface PathBuilder {
|
|
4
|
+
/** Starts a subpath at (x, y). */
|
|
5
|
+
moveTo(x: number, y: number): PathBuilder;
|
|
6
|
+
/** A straight line to (x, y). */
|
|
7
|
+
lineTo(x: number, y: number): PathBuilder;
|
|
8
|
+
/** A cubic Bézier curve through two control points to (x, y). */
|
|
9
|
+
cubicTo(x1: number, y1: number, x2: number, y2: number, x: number, y: number): PathBuilder;
|
|
10
|
+
/** A quadratic Bézier curve through one control point to (x, y). */
|
|
11
|
+
quadTo(x1: number, y1: number, x: number, y: number): PathBuilder;
|
|
12
|
+
/** Closes the subpath. */
|
|
13
|
+
close(): PathBuilder;
|
|
14
|
+
/** A rectangle: left, top, width, height. */
|
|
15
|
+
rect(rect: Rect): PathBuilder;
|
|
16
|
+
/** The ellipse inscribed in a rectangle. */
|
|
17
|
+
ellipse(rect: Rect): PathBuilder;
|
|
18
|
+
/** A circle around `center`. */
|
|
19
|
+
circle(center: Point, radius: number): PathBuilder;
|
|
20
|
+
}
|
|
21
|
+
/** @internal Collects a path's verbs and numbers. */
|
|
22
|
+
export declare class PathEncoder implements PathBuilder {
|
|
23
|
+
#private;
|
|
24
|
+
moveTo(x: number, y: number): this;
|
|
25
|
+
lineTo(x: number, y: number): this;
|
|
26
|
+
cubicTo(x1: number, y1: number, x2: number, y2: number, x: number, y: number): this;
|
|
27
|
+
quadTo(x1: number, y1: number, x: number, y: number): this;
|
|
28
|
+
close(): this;
|
|
29
|
+
rect(rect: Rect): this;
|
|
30
|
+
ellipse(rect: Rect): this;
|
|
31
|
+
circle(center: Point, radius: number): this;
|
|
32
|
+
finish(): Float64Array;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=path.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../src/path.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAE9C,qFAAqF;AACrF,MAAM,WAAW,WAAW;IAC1B,kCAAkC;IAClC,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;IAC1C,iCAAiC;IACjC,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;IAC1C,iEAAiE;IACjE,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,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,IAAI,YAAY,CAErB;CACF"}
|
package/dist/path.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/** The verbs of the flat encoding. */
|
|
2
|
+
const MOVE = 0;
|
|
3
|
+
const LINE = 1;
|
|
4
|
+
const CUBIC = 2;
|
|
5
|
+
const QUAD = 3;
|
|
6
|
+
const CLOSE = 4;
|
|
7
|
+
const RECT = 5;
|
|
8
|
+
const ELLIPSE = 6;
|
|
9
|
+
const CIRCLE = 7;
|
|
10
|
+
/** @internal Collects a path's verbs and numbers. */
|
|
11
|
+
export class PathEncoder {
|
|
12
|
+
#data = [];
|
|
13
|
+
moveTo(x, y) {
|
|
14
|
+
this.#data.push(MOVE, x, y);
|
|
15
|
+
return this;
|
|
16
|
+
}
|
|
17
|
+
lineTo(x, y) {
|
|
18
|
+
this.#data.push(LINE, x, y);
|
|
19
|
+
return this;
|
|
20
|
+
}
|
|
21
|
+
cubicTo(x1, y1, x2, y2, x, y) {
|
|
22
|
+
this.#data.push(CUBIC, x1, y1, x2, y2, x, y);
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
25
|
+
quadTo(x1, y1, x, y) {
|
|
26
|
+
this.#data.push(QUAD, x1, y1, x, y);
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
close() {
|
|
30
|
+
this.#data.push(CLOSE);
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
rect(rect) {
|
|
34
|
+
this.#data.push(RECT, ...rect);
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
ellipse(rect) {
|
|
38
|
+
this.#data.push(ELLIPSE, ...rect);
|
|
39
|
+
return this;
|
|
40
|
+
}
|
|
41
|
+
circle(center, radius) {
|
|
42
|
+
this.#data.push(CIRCLE, center[0], center[1], radius);
|
|
43
|
+
return this;
|
|
44
|
+
}
|
|
45
|
+
finish() {
|
|
46
|
+
return new Float64Array(this.#data);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//# sourceMapping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AO,IAAI,CAAC;IACd,CAAC;IAED,KAAK;QACH,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CAAC,IAAU;QACb,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC;QAC/B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,CAAC,IAAU;QAChB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;QAClC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,CAAC,MAAa,EAAE,MAAc;QAClC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;QACtD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;CACF"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type RangeSource } from "./range.js";
|
|
2
|
+
/** Options for {@link httpRangeSource}. */
|
|
3
|
+
export interface HttpRangeOptions {
|
|
4
|
+
/** Extra request headers (authorisation, …). `Range` and `If-Range` are Lamina PDF's. */
|
|
5
|
+
readonly headers?: Readonly<Record<string, string>>;
|
|
6
|
+
/** `fetch`'s credentials mode. */
|
|
7
|
+
readonly credentials?: RequestCredentials;
|
|
8
|
+
/** Aborts the probe; reads take their own signal. */
|
|
9
|
+
readonly signal?: AbortSignal;
|
|
10
|
+
/** Fetches are aligned to blocks of this many bytes (default 16 384: each object a reader
|
|
11
|
+
* checks costs one block, so larger blocks fetch more of the file). */
|
|
12
|
+
readonly blockSize?: number;
|
|
13
|
+
/** The first request asks for this many bytes at the end of the file (default 65 536). */
|
|
14
|
+
readonly tail?: number;
|
|
15
|
+
/** The `fetch` to use (default: the global one). */
|
|
16
|
+
readonly fetch?: typeof fetch;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A {@link RangeSource} over a URL, for `Document.openRange`. The first request asks for the
|
|
20
|
+
* last `tail` bytes, which gives the size and the part of the file a reader needs first (the
|
|
21
|
+
* xref is at the end). Every later request sends `If-Range` with the first strong `ETag` (else
|
|
22
|
+
* its `Last-Modified`); a response whose `ETag`, `Last-Modified` or total size differs fails
|
|
23
|
+
* with `source-changed`. A server that ignores
|
|
24
|
+
* `Range` (it answers `200`) is read with that one full download.
|
|
25
|
+
*
|
|
26
|
+
* The server must allow `Range` (across origins: `Access-Control-Allow-Headers: Range` and
|
|
27
|
+
* `Access-Control-Expose-Headers: Content-Range, Content-Length, ETag`) and must not compress
|
|
28
|
+
* the response.
|
|
29
|
+
*
|
|
30
|
+
* @param url - the file.
|
|
31
|
+
* @param options - headers, credentials, signal, block size.
|
|
32
|
+
* @returns the source, once the first request has answered.
|
|
33
|
+
* @throws {@link LaminaPdfError} `fetch-failed` (with `data.status`), `source-changed`.
|
|
34
|
+
*/
|
|
35
|
+
export declare function httpRangeSource(url: string | URL, options?: HttpRangeOptions): Promise<RangeSource>;
|
|
36
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/source/http.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,WAAW,EAAS,MAAM,YAAY,CAAC;AAErD,2CAA2C;AAC3C,MAAM,WAAW,gBAAgB;IAC/B,yFAAyF;IACzF,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACpD,kCAAkC;IAClC,QAAQ,CAAC,WAAW,CAAC,EAAE,kBAAkB,CAAC;IAC1C,qDAAqD;IACrD,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B;2EACuE;IACvE,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,0FAA0F;IAC1F,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,oDAAoD;IACpD,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CAC/B;AAqBD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,EAAE,OAAO,GAAE,gBAAqB,GAAG,OAAO,CAAC,WAAW,CAAC,CA0B7G"}
|