@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,51 @@
|
|
|
1
|
+
/** What an extension method sees of its call. */
|
|
2
|
+
export interface CallContext {
|
|
3
|
+
/** Trips when every caller of this (possibly coalesced) call has cancelled. */
|
|
4
|
+
readonly signal: AbortSignal;
|
|
5
|
+
/** Sends a progress event to each caller (`onProgress`). */
|
|
6
|
+
progress(progress: unknown): void;
|
|
7
|
+
}
|
|
8
|
+
/** A method an extension adds (called on the client itself, handle 0). */
|
|
9
|
+
export interface ExtensionMethod {
|
|
10
|
+
/** Runs the method in the worker: its result, or a promise of it; what it throws is the caller's error. */
|
|
11
|
+
run(params: readonly unknown[], context: CallContext): unknown;
|
|
12
|
+
/**
|
|
13
|
+
* One caller's answer from the result, and what to transfer with it. Called once per caller of
|
|
14
|
+
* a coalesced call, so each gets its own transferables (an ImageBitmap each). Omitted, the
|
|
15
|
+
* result is posted as is, its buffers transferred to the last caller and copied to the others.
|
|
16
|
+
*/
|
|
17
|
+
reply?(result: unknown): [unknown, Transferable[]] | Promise<[unknown, Transferable[]]>;
|
|
18
|
+
}
|
|
19
|
+
/** What a package adds to the worker: methods on the client (handle 0). */
|
|
20
|
+
export interface ServerExtension {
|
|
21
|
+
readonly methods: Readonly<Record<string, ExtensionMethod>>;
|
|
22
|
+
/**
|
|
23
|
+
* Work units per save step (default 20,000: a cancel waits at most a few milliseconds). A
|
|
24
|
+
* smaller budget answers a cancel sooner and reports progress more often, at some cost in speed.
|
|
25
|
+
*/
|
|
26
|
+
readonly saveBudget?: number;
|
|
27
|
+
}
|
|
28
|
+
/** What the worker holds and has done: for diagnostics, such as checking that handles are freed. */
|
|
29
|
+
export interface WorkerStats {
|
|
30
|
+
/** Calls that started running (a call cancelled while queued never starts). */
|
|
31
|
+
readonly started: number;
|
|
32
|
+
/** Documents and pages the page side holds a handle to. */
|
|
33
|
+
readonly handles: number;
|
|
34
|
+
/** Calls waiting their turn. */
|
|
35
|
+
readonly queued: number;
|
|
36
|
+
}
|
|
37
|
+
/** Posts an extension event (`client.on("event", …)` on the page side). */
|
|
38
|
+
export declare function emit(name: string, data?: unknown, transfer?: Transferable[]): void;
|
|
39
|
+
/**
|
|
40
|
+
* Lets queued messages (calls, a `cancel`) in, without the 4 ms clamp of nested `setTimeout`s.
|
|
41
|
+
* Exported for extensions whose methods must notice a cancel before committing a change.
|
|
42
|
+
*/
|
|
43
|
+
export declare function yieldToMessages(): Promise<void>;
|
|
44
|
+
/** What this worker holds and has done (see {@link WorkerStats}). */
|
|
45
|
+
export declare function workerStats(): WorkerStats;
|
|
46
|
+
/**
|
|
47
|
+
* Serves the worker client's protocol in this worker, with `ext`'s methods added. Call it once,
|
|
48
|
+
* at the top of the worker's module.
|
|
49
|
+
*/
|
|
50
|
+
export declare function serve(ext?: ServerExtension): void;
|
|
51
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/worker/server.ts"],"names":[],"mappings":"AAsCA,iDAAiD;AACjD,MAAM,WAAW,WAAW;IAC1B,+EAA+E;IAC/E,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,4DAA4D;IAC5D,QAAQ,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAAC;CACnC;AAED,0EAA0E;AAC1E,MAAM,WAAW,eAAe;IAC9B,2GAA2G;IAC3G,GAAG,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC;IAC/D;;;;OAIG;IACH,KAAK,CAAC,CAAC,MAAM,EAAE,OAAO,GAAG,CAAC,OAAO,EAAE,YAAY,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,OAAO,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC;CACzF;AAED,2EAA2E;AAC3E,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC;IAC5D;;;OAGG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,oGAAoG;AACpG,MAAM,WAAW,WAAW;IAC1B,+EAA+E;IAC/E,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,2DAA2D;IAC3D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,gCAAgC;IAChC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAmDD,2EAA2E;AAC3E,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,QAAQ,GAAE,YAAY,EAAO,GAAG,IAAI,CAEtF;AA+BD;;;GAGG;AACH,wBAAgB,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC,CAU/C;AAmXD,qEAAqE;AACrE,wBAAgB,WAAW,IAAI,WAAW,CAEzC;AAED;;;GAGG;AACH,wBAAgB,KAAK,CAAC,GAAG,CAAC,EAAE,eAAe,GAAG,IAAI,CA6BjD"}
|
|
@@ -0,0 +1,493 @@
|
|
|
1
|
+
// The worker side of `@laminapdf/sdk/worker`: `serve()` answers the
|
|
2
|
+
// handshake, calls `init()`, keeps the documents and pages it made in a handle table, and runs one
|
|
3
|
+
// call at a time (the WASM is synchronous). `dist/worker/entry.js` is `serve()` alone; a package
|
|
4
|
+
// that needs more in the same worker (`@laminapdf/viewer`: render methods) passes a ServerExtension
|
|
5
|
+
// and gets the same protocol, queue, cancellation and errors, so there is one RPC, not two.
|
|
6
|
+
//
|
|
7
|
+
// The queue runs the highest `priority` first (FIFO within one), and coalesces calls with the same
|
|
8
|
+
// `key`: a call whose key matches a queued or running one joins it, runs once, and each caller gets
|
|
9
|
+
// its own reply (an extension's `reply` builds one per caller, so transferables aren't shared). A
|
|
10
|
+
// queued call can be cancelled before it starts; a running one sees its AbortSignal trip once all
|
|
11
|
+
// its callers cancelled: `save` and `saveWithReport` run as stepped jobs that yield between steps
|
|
12
|
+
// (ADR 0028), and a range document's fetches take the signal. A cancel that arrives after the
|
|
13
|
+
// answer frees the document the call opened, since the page drops that answer. A WebAssembly trap
|
|
14
|
+
// is reported as a crash and ends the worker.
|
|
15
|
+
import { defined } from "../defined.js";
|
|
16
|
+
import { Document, PageRef } from "../document.js";
|
|
17
|
+
import { isDiagnostic, LaminaPdfError, packageError } from "../errors.js";
|
|
18
|
+
import { init, loadExtract, loadText } from "../index.js";
|
|
19
|
+
import { isTrap } from "../internal/instance.js";
|
|
20
|
+
import { httpRangeSource } from "../source/http.js";
|
|
21
|
+
import { PageText, rawOf } from "../text.js";
|
|
22
|
+
import { HANDSHAKE, isHandleRef, } from "./protocol.js";
|
|
23
|
+
import { DOCUMENT_METHODS, PAGE_METHODS } from "./support.js";
|
|
24
|
+
import { whole } from "./transfer.js";
|
|
25
|
+
/** Work units per save step: small enough that a cancel waits at most a few milliseconds. */
|
|
26
|
+
const SAVE_BUDGET = 20_000;
|
|
27
|
+
/** The budget in use: `serve()`'s `saveBudget`, or the default. */
|
|
28
|
+
let saveBudget = SAVE_BUDGET;
|
|
29
|
+
/** Least time between two progress events of one call, in ms. */
|
|
30
|
+
const PROGRESS_EVERY = 50;
|
|
31
|
+
const scope = globalThis;
|
|
32
|
+
const handles = new Map();
|
|
33
|
+
/** Each document's page handles by page ID: `page(i)` again returns the same handle. */
|
|
34
|
+
const pageHandles = new Map();
|
|
35
|
+
let nextHandle = 1;
|
|
36
|
+
/**
|
|
37
|
+
* Each open document's handle by the ID of the call that made it (`open`, `openUrl`). A cancel
|
|
38
|
+
* for a call already answered means the page dropped that answer, so nobody holds the document.
|
|
39
|
+
*/
|
|
40
|
+
const madeBy = new Map();
|
|
41
|
+
/** Jobs waiting their turn, highest priority first (FIFO within one); the running one. */
|
|
42
|
+
const queue = [];
|
|
43
|
+
let current;
|
|
44
|
+
let running = false;
|
|
45
|
+
/** Jobs actually started (a cancelled call never starts). */
|
|
46
|
+
let started = 0;
|
|
47
|
+
let ready = false;
|
|
48
|
+
let extension = { methods: {} };
|
|
49
|
+
function post(message, transfer = []) {
|
|
50
|
+
scope.postMessage(message, transfer);
|
|
51
|
+
}
|
|
52
|
+
/** Posts an extension event (`client.on("event", …)` on the page side). */
|
|
53
|
+
export function emit(name, data, transfer = []) {
|
|
54
|
+
post({ kind: "event", name, data }, transfer);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The ADR 0026 object for anything thrown. Lamina PDF's own errors pass through, and so does the §1
|
|
58
|
+
* object the WASM modules throw. Any other error that can describe itself (`toDiagnostic()`,
|
|
59
|
+
* as `@laminapdf/render`'s RenderError does) is posted as that object, so a render
|
|
60
|
+
* `data-pending` keeps its `[offset, length]` ranges in `data.ranges` (`LaminaPdfError.ranges`).
|
|
61
|
+
* Anything else is a failure of the worker itself (`worker-failed`, kind internal). Caller
|
|
62
|
+
* mistakes the worker detects (an unknown method) are thrown as `invalid-argument` where they
|
|
63
|
+
* are found.
|
|
64
|
+
*/
|
|
65
|
+
function diagnostic(e) {
|
|
66
|
+
if (e instanceof LaminaPdfError)
|
|
67
|
+
return e.toJSON();
|
|
68
|
+
if (isDiagnostic(e))
|
|
69
|
+
return e;
|
|
70
|
+
const described = fromToDiagnostic(e);
|
|
71
|
+
if (described !== undefined)
|
|
72
|
+
return described;
|
|
73
|
+
return packageError("worker-failed", e instanceof Error ? e.message : String(e)).toJSON();
|
|
74
|
+
}
|
|
75
|
+
/** What `e.toDiagnostic()` returns, when `e` has that method and it returns a §1 object. */
|
|
76
|
+
function fromToDiagnostic(e) {
|
|
77
|
+
const toDiagnostic = e?.toDiagnostic;
|
|
78
|
+
if (typeof toDiagnostic !== "function")
|
|
79
|
+
return undefined;
|
|
80
|
+
const value = toDiagnostic.call(e);
|
|
81
|
+
return isDiagnostic(value) ? value : undefined;
|
|
82
|
+
}
|
|
83
|
+
/** One channel for every yield, and the yields waiting on it (in order). */
|
|
84
|
+
let yieldChannel;
|
|
85
|
+
const yielding = [];
|
|
86
|
+
/**
|
|
87
|
+
* Lets queued messages (calls, a `cancel`) in, without the 4 ms clamp of nested `setTimeout`s.
|
|
88
|
+
* Exported for extensions whose methods must notice a cancel before committing a change.
|
|
89
|
+
*/
|
|
90
|
+
export function yieldToMessages() {
|
|
91
|
+
if (yieldChannel === undefined) {
|
|
92
|
+
yieldChannel = new MessageChannel();
|
|
93
|
+
yieldChannel.port1.onmessage = () => yielding.shift()?.();
|
|
94
|
+
}
|
|
95
|
+
const channel = yieldChannel;
|
|
96
|
+
return new Promise((resolve) => {
|
|
97
|
+
yielding.push(resolve);
|
|
98
|
+
channel.port2.postMessage(null);
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
/** The client methods the worker itself serves; an extension can't reuse their names. */
|
|
102
|
+
const BUILT_IN = new Set(["open", "openUrl", "loadText", "loadExtract"]);
|
|
103
|
+
function register(entry, fields) {
|
|
104
|
+
const handle = nextHandle++;
|
|
105
|
+
handles.set(handle, entry);
|
|
106
|
+
return { $handle: handle, type: entry.type, ...(fields === undefined ? {} : { fields }) };
|
|
107
|
+
}
|
|
108
|
+
function pageRef(page, document) {
|
|
109
|
+
const fields = { id: page.id, index: page.index };
|
|
110
|
+
let pages = pageHandles.get(document);
|
|
111
|
+
if (pages === undefined) {
|
|
112
|
+
pages = new Map();
|
|
113
|
+
pageHandles.set(document, pages);
|
|
114
|
+
}
|
|
115
|
+
const known = pages.get(page.id);
|
|
116
|
+
if (known !== undefined && handles.has(known))
|
|
117
|
+
return { $handle: known, type: "page", fields };
|
|
118
|
+
const ref = register({ type: "page", value: page, document }, fields);
|
|
119
|
+
pages.set(page.id, ref.$handle);
|
|
120
|
+
return ref;
|
|
121
|
+
}
|
|
122
|
+
/** Values to transfer out of `result`, and the result as it should be posted. */
|
|
123
|
+
function outgoing(result) {
|
|
124
|
+
if (result instanceof Uint8Array)
|
|
125
|
+
return [result, whole(result)];
|
|
126
|
+
if (result instanceof PageText) {
|
|
127
|
+
const raw = rawOf(result);
|
|
128
|
+
return [{ $pageText: raw }, [...whole(raw.quads), ...whole(raw.glyphOffsets)]];
|
|
129
|
+
}
|
|
130
|
+
if (typeof result === "object" && result !== null && "bytes" in result && result.bytes instanceof Uint8Array) {
|
|
131
|
+
return [result, whole(result.bytes)];
|
|
132
|
+
}
|
|
133
|
+
return [result, []];
|
|
134
|
+
}
|
|
135
|
+
/** Frees a document handle (and its pages), or a page handle. */
|
|
136
|
+
function release(handle) {
|
|
137
|
+
const entry = handles.get(handle);
|
|
138
|
+
if (entry === undefined)
|
|
139
|
+
return;
|
|
140
|
+
handles.delete(handle);
|
|
141
|
+
if (entry.type === "document") {
|
|
142
|
+
for (const h of pageHandles.get(handle)?.values() ?? [])
|
|
143
|
+
handles.delete(h);
|
|
144
|
+
pageHandles.delete(handle);
|
|
145
|
+
for (const [id, h] of madeBy)
|
|
146
|
+
if (h === handle)
|
|
147
|
+
madeBy.delete(id);
|
|
148
|
+
entry.value.free();
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
async function stepSave(context, doc, method, options) {
|
|
152
|
+
const job = doc.saveJob(options);
|
|
153
|
+
// The first progress event goes out after the first step, so a caller hears at once that a
|
|
154
|
+
// stepped save is under way; later ones at most every PROGRESS_EVERY ms. (Counting from 0 would
|
|
155
|
+
// wait for the worker's own clock, which starts when the worker does.)
|
|
156
|
+
let last = Number.NEGATIVE_INFINITY;
|
|
157
|
+
try {
|
|
158
|
+
for (;;) {
|
|
159
|
+
if (context.signal.aborted)
|
|
160
|
+
job.cancel();
|
|
161
|
+
const step = job.step(saveBudget);
|
|
162
|
+
if (step.state === "done") {
|
|
163
|
+
return method === "save" ? step.bytes : { bytes: step.bytes, report: step.report };
|
|
164
|
+
}
|
|
165
|
+
const now = performance.now();
|
|
166
|
+
if (now - last >= PROGRESS_EVERY) {
|
|
167
|
+
last = now;
|
|
168
|
+
const { state: _, ...progress } = step;
|
|
169
|
+
context.progress(progress);
|
|
170
|
+
}
|
|
171
|
+
await yieldToMessages();
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
finally {
|
|
175
|
+
job.free();
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
/** `openRange`'s own options; the rest of `openUrl`'s go to `httpRangeSource`. */
|
|
179
|
+
const RANGE_KEYS = ["readahead", "maxRounds", "budget"];
|
|
180
|
+
async function clientCall(method, params, context) {
|
|
181
|
+
const { signal } = context;
|
|
182
|
+
switch (method) {
|
|
183
|
+
case "open": {
|
|
184
|
+
const [bytes, options] = params;
|
|
185
|
+
return register({ type: "document", value: Document.open(bytes, options), range: false });
|
|
186
|
+
}
|
|
187
|
+
case "openUrl": {
|
|
188
|
+
const [url, options] = params;
|
|
189
|
+
const { password, strict, limits, ...http } = options ?? {};
|
|
190
|
+
const open = {
|
|
191
|
+
signal,
|
|
192
|
+
...defined({ password, strict, limits, blockSize: http.blockSize }),
|
|
193
|
+
};
|
|
194
|
+
for (const key of RANGE_KEYS) {
|
|
195
|
+
if (http[key] !== undefined)
|
|
196
|
+
open[key] = http[key];
|
|
197
|
+
delete http[key];
|
|
198
|
+
}
|
|
199
|
+
const doc = await Document.openRange(httpRangeSource(url, { ...http, signal }), open);
|
|
200
|
+
return register({ type: "document", value: doc, range: true });
|
|
201
|
+
}
|
|
202
|
+
case "loadText":
|
|
203
|
+
return loadText();
|
|
204
|
+
case "loadExtract":
|
|
205
|
+
return loadExtract();
|
|
206
|
+
default: {
|
|
207
|
+
const own = Object.hasOwn(extension.methods, method) ? extension.methods[method] : undefined;
|
|
208
|
+
if (own === undefined)
|
|
209
|
+
throw packageError("invalid-argument", `the worker client has no method ${method}`);
|
|
210
|
+
return own.run(params, context);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
async function documentCall(context, handle, entry, method, params) {
|
|
215
|
+
const doc = entry.value;
|
|
216
|
+
if (method === "close") {
|
|
217
|
+
release(handle);
|
|
218
|
+
return undefined;
|
|
219
|
+
}
|
|
220
|
+
if (!Object.hasOwn(DOCUMENT_METHODS, method)) {
|
|
221
|
+
throw packageError("invalid-argument", `Document has no remote method ${method}`);
|
|
222
|
+
}
|
|
223
|
+
const run = async () => {
|
|
224
|
+
if (method === "save" || method === "saveWithReport") {
|
|
225
|
+
return stepSave(context, doc, method, params[0]);
|
|
226
|
+
}
|
|
227
|
+
const member = doc[method];
|
|
228
|
+
const value = typeof member === "function" ? member.apply(doc, [...params]) : member;
|
|
229
|
+
if (value instanceof PageRef)
|
|
230
|
+
return pageRef(value, handle);
|
|
231
|
+
return value;
|
|
232
|
+
};
|
|
233
|
+
// A range document fetches what a call needs, then calls again.
|
|
234
|
+
return entry.range ? doc.ensure(run, { signal: context.signal }) : run();
|
|
235
|
+
}
|
|
236
|
+
function pageCall(context, entry, method, params) {
|
|
237
|
+
if (!Object.hasOwn(PAGE_METHODS, method)) {
|
|
238
|
+
throw packageError("invalid-argument", `PageRef has no remote method ${method}`);
|
|
239
|
+
}
|
|
240
|
+
const member = entry.value[method];
|
|
241
|
+
const run = () => typeof member === "function" ? member.apply(entry.value, [...params]) : member;
|
|
242
|
+
const doc = handles.get(entry.document);
|
|
243
|
+
return doc?.type === "document" && doc.range ? doc.value.ensure(run, { signal: context.signal }) : run();
|
|
244
|
+
}
|
|
245
|
+
/** The extension method `request` calls, if it is one (it may build a reply per caller). */
|
|
246
|
+
function extensionMethod(request) {
|
|
247
|
+
return request.handle === 0 && !BUILT_IN.has(request.method) && Object.hasOwn(extension.methods, request.method)
|
|
248
|
+
? extension.methods[request.method]
|
|
249
|
+
: undefined;
|
|
250
|
+
}
|
|
251
|
+
async function execute(job) {
|
|
252
|
+
const { signal } = job.controller;
|
|
253
|
+
const context = {
|
|
254
|
+
signal,
|
|
255
|
+
progress: (progress) => {
|
|
256
|
+
for (const w of job.waiters)
|
|
257
|
+
post({ kind: "progress", id: w.id, progress });
|
|
258
|
+
},
|
|
259
|
+
};
|
|
260
|
+
current = job;
|
|
261
|
+
started++;
|
|
262
|
+
try {
|
|
263
|
+
const result = await run(job.first, context);
|
|
264
|
+
if (signal.aborted) {
|
|
265
|
+
// Nobody will hold a handle the cancelled call made (`openUrl` aborted mid-fetch): free it.
|
|
266
|
+
if (isHandleRef(result))
|
|
267
|
+
release(result.$handle);
|
|
268
|
+
throw packageError("cancelled", "the call was cancelled");
|
|
269
|
+
}
|
|
270
|
+
// The result is in: no caller joins this job any more (a reply can take a while, and a caller
|
|
271
|
+
// that joined now would get none); a same-key call from here on runs again.
|
|
272
|
+
current = undefined;
|
|
273
|
+
// The caller's cancel may still arrive after this answer: cancel() then frees the document.
|
|
274
|
+
const opened = openedFor(job, result);
|
|
275
|
+
if (opened !== undefined)
|
|
276
|
+
madeBy.set(...opened);
|
|
277
|
+
await replyAll(job, result);
|
|
278
|
+
}
|
|
279
|
+
catch (e) {
|
|
280
|
+
if (isTrap(e)) {
|
|
281
|
+
// A trap: the module's state can't be trusted any more. The sync API reports Lamina PDF's
|
|
282
|
+
// own traps as `wasm-trap` or `out-of-memory`; an extension's module (PDFium) throws the
|
|
283
|
+
// RuntimeError itself.
|
|
284
|
+
post({ kind: "crashed", reason: "trap" });
|
|
285
|
+
scope.close();
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
// The page dropped an aborted call's promise already; the answer is only for the record.
|
|
289
|
+
const error = signal.aborted ? packageError("cancelled", "the call was cancelled").toJSON() : diagnostic(e);
|
|
290
|
+
for (const w of job.waiters)
|
|
291
|
+
post({ kind: "result", id: w.id, ok: false, error });
|
|
292
|
+
}
|
|
293
|
+
finally {
|
|
294
|
+
current = undefined;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* `[call ID, document handle]` when `job` is an `open` or `openUrl` that answered one caller
|
|
299
|
+
* alone (one coalesced by a `key` shares its document, so no single cancel may free it).
|
|
300
|
+
*/
|
|
301
|
+
function openedFor(job, result) {
|
|
302
|
+
const { handle, method } = job.first;
|
|
303
|
+
if (handle !== 0 || (method !== "open" && method !== "openUrl") || !isHandleRef(result))
|
|
304
|
+
return undefined;
|
|
305
|
+
const [only, ...others] = job.waiters;
|
|
306
|
+
return only !== undefined && others.length === 0 ? [only.id, result.$handle] : undefined;
|
|
307
|
+
}
|
|
308
|
+
/** Runs the call: a client method, or a method of the document or page its handle names. */
|
|
309
|
+
async function run(request, context) {
|
|
310
|
+
const { handle, method, params } = request;
|
|
311
|
+
if (handle === 0)
|
|
312
|
+
return clientCall(method, params, context);
|
|
313
|
+
const entry = handles.get(handle);
|
|
314
|
+
if (entry === undefined)
|
|
315
|
+
throw packageError("disposed", "the handle was closed or belongs to another worker");
|
|
316
|
+
return entry.type === "document"
|
|
317
|
+
? documentCall(context, handle, entry, method, params)
|
|
318
|
+
: pageCall(context, entry, method, params);
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Answers each caller of the job on its own: a reply that fails (createImageBitmap out of
|
|
322
|
+
* memory) fails only that caller, and those already answered aren't answered twice.
|
|
323
|
+
*/
|
|
324
|
+
async function replyAll(job, result) {
|
|
325
|
+
const own = extensionMethod(job.first);
|
|
326
|
+
const waiters = [...job.waiters];
|
|
327
|
+
for (const [i, w] of waiters.entries()) {
|
|
328
|
+
try {
|
|
329
|
+
const [value, transfer] = await answer(own, result, i === waiters.length - 1);
|
|
330
|
+
post({ kind: "result", id: w.id, ok: true, result: value }, transfer);
|
|
331
|
+
}
|
|
332
|
+
catch (e) {
|
|
333
|
+
post({ kind: "result", id: w.id, ok: false, error: diagnostic(e) });
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
/** One caller's answer and what it transfers: the extension's reply, else the result itself. */
|
|
338
|
+
async function answer(own, result, last) {
|
|
339
|
+
if (own?.reply !== undefined)
|
|
340
|
+
return own.reply(result);
|
|
341
|
+
const [value, transfer] = outgoing(result);
|
|
342
|
+
// One set of buffers: transferred to the last caller, copied to the others.
|
|
343
|
+
return [value, last ? transfer : []];
|
|
344
|
+
}
|
|
345
|
+
async function drain() {
|
|
346
|
+
if (running)
|
|
347
|
+
return;
|
|
348
|
+
running = true;
|
|
349
|
+
try {
|
|
350
|
+
for (;;) {
|
|
351
|
+
// Let every message already sent in first, so the queue sees all waiting calls and
|
|
352
|
+
// cancels before it picks: a synchronous call otherwise finishes inside one message's
|
|
353
|
+
// handler, before the next is even read, and nothing is ever queued to order or drop.
|
|
354
|
+
await yieldToMessages();
|
|
355
|
+
const job = queue.shift();
|
|
356
|
+
if (job === undefined)
|
|
357
|
+
break;
|
|
358
|
+
await execute(job);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
finally {
|
|
362
|
+
running = false;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
/** Puts `job` after every job of its priority or higher. */
|
|
366
|
+
function enqueue(job) {
|
|
367
|
+
const at = queue.findIndex((j) => j.priority < job.priority);
|
|
368
|
+
if (at === -1)
|
|
369
|
+
queue.push(job);
|
|
370
|
+
else
|
|
371
|
+
queue.splice(at, 0, job);
|
|
372
|
+
}
|
|
373
|
+
function call(request) {
|
|
374
|
+
const { key } = request;
|
|
375
|
+
const priority = request.priority ?? 0;
|
|
376
|
+
if (key !== undefined) {
|
|
377
|
+
// Same key, method and handle: a key from one method never answers another's call.
|
|
378
|
+
const same = (j) => j.first.key === key && j.first.method === request.method && j.first.handle === request.handle;
|
|
379
|
+
if (current !== undefined && same(current) && !current.controller.signal.aborted) {
|
|
380
|
+
current.waiters.push(request);
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
const queued = queue.find(same);
|
|
384
|
+
if (queued !== undefined) {
|
|
385
|
+
queued.waiters.push(request);
|
|
386
|
+
if (priority > queued.priority) {
|
|
387
|
+
// The more urgent caller moves the shared job up.
|
|
388
|
+
queue.splice(queue.indexOf(queued), 1);
|
|
389
|
+
queued.priority = priority;
|
|
390
|
+
enqueue(queued);
|
|
391
|
+
}
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
enqueue({ first: request, waiters: [request], priority, controller: new AbortController() });
|
|
396
|
+
if (ready)
|
|
397
|
+
void drain();
|
|
398
|
+
}
|
|
399
|
+
function cancel(id) {
|
|
400
|
+
// Only a call still queued or running can be cancelled. A cancel can also cross its answer: the
|
|
401
|
+
// page aborted after the worker answered, before it read the answer. Such a cancel finds no job,
|
|
402
|
+
// and the page drops that answer, so a document the call made is freed here. (A crossed
|
|
403
|
+
// `page(i)` keeps its page handle, which `page(i)` reuses and closing the document frees.)
|
|
404
|
+
const job = current?.waiters.some((w) => w.id === id)
|
|
405
|
+
? current
|
|
406
|
+
: queue.find((j) => j.waiters.some((w) => w.id === id));
|
|
407
|
+
if (job === undefined) {
|
|
408
|
+
const made = madeBy.get(id);
|
|
409
|
+
if (made !== undefined)
|
|
410
|
+
release(made);
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
job.waiters.splice(job.waiters.findIndex((w) => w.id === id), 1);
|
|
414
|
+
if (job.waiters.length > 0) {
|
|
415
|
+
// The job keeps the priority of its most urgent remaining caller.
|
|
416
|
+
const priority = Math.max(...job.waiters.map((w) => w.priority ?? 0));
|
|
417
|
+
if (job !== current && priority !== job.priority) {
|
|
418
|
+
queue.splice(queue.indexOf(job), 1);
|
|
419
|
+
job.priority = priority;
|
|
420
|
+
enqueue(job);
|
|
421
|
+
}
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
if (job === current) {
|
|
425
|
+
job.controller.abort();
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
queue.splice(queue.indexOf(job), 1);
|
|
429
|
+
post({
|
|
430
|
+
kind: "result",
|
|
431
|
+
id,
|
|
432
|
+
ok: false,
|
|
433
|
+
error: packageError("cancelled", "the call was cancelled before it started").toJSON(),
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
async function hello(message) {
|
|
437
|
+
const { protocol, version } = message.client;
|
|
438
|
+
if (protocol !== HANDSHAKE.protocol || version !== HANDSHAKE.version) {
|
|
439
|
+
// Answer with what this worker is, and do nothing else: the client rejects.
|
|
440
|
+
post({ kind: "welcome", worker: HANDSHAKE });
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
try {
|
|
444
|
+
await init(message.init);
|
|
445
|
+
ready = true;
|
|
446
|
+
post({ kind: "welcome", worker: HANDSHAKE });
|
|
447
|
+
void drain();
|
|
448
|
+
}
|
|
449
|
+
catch (e) {
|
|
450
|
+
post({ kind: "welcome", worker: HANDSHAKE, error: diagnostic(e) });
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
let serving = false;
|
|
454
|
+
/** What this worker holds and has done (see {@link WorkerStats}). */
|
|
455
|
+
export function workerStats() {
|
|
456
|
+
return { started, handles: handles.size, queued: queue.length };
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* Serves the worker client's protocol in this worker, with `ext`'s methods added. Call it once,
|
|
460
|
+
* at the top of the worker's module.
|
|
461
|
+
*/
|
|
462
|
+
export function serve(ext) {
|
|
463
|
+
if (serving)
|
|
464
|
+
throw packageError("invalid-argument", "serve() was already called in this worker");
|
|
465
|
+
if (ext !== undefined) {
|
|
466
|
+
const clash = Object.keys(ext.methods).find((m) => BUILT_IN.has(m));
|
|
467
|
+
if (clash !== undefined)
|
|
468
|
+
throw packageError("invalid-argument", `an extension can't redefine the built-in method ${clash}`);
|
|
469
|
+
extension = ext;
|
|
470
|
+
if (ext.saveBudget !== undefined) {
|
|
471
|
+
if (!(Number.isInteger(ext.saveBudget) && ext.saveBudget > 0))
|
|
472
|
+
throw packageError("invalid-argument", "saveBudget must be a positive whole number of work units");
|
|
473
|
+
saveBudget = ext.saveBudget;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
serving = true;
|
|
477
|
+
scope.addEventListener("message", (event) => {
|
|
478
|
+
const message = event.data;
|
|
479
|
+
switch (message.kind) {
|
|
480
|
+
case "hello":
|
|
481
|
+
void hello(message);
|
|
482
|
+
return;
|
|
483
|
+
case "cancel":
|
|
484
|
+
cancel(message.id);
|
|
485
|
+
return;
|
|
486
|
+
case "call":
|
|
487
|
+
// Calls before the handshake finished wait for it (hello() drains them).
|
|
488
|
+
call(message);
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
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,CAAC,IAAI,EAAE,CAAC;YACrB,KAAK,OAAO;gBACV,KAAK,KAAK,CAAC,OAAO,CAAC,CAAC;gBACpB,OAAO;YACT,KAAK,QAAQ;gBACX,MAAM,CAAE,OAAkB,CAAC,EAAE,CAAC,CAAC;gBAC/B,OAAO;YACT,KAAK,MAAM;gBACT,yEAAyE;gBACzE,IAAI,CAAC,OAAO,CAAC,CAAC;gBACd,OAAO;QACX,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { Document, PageRef } from "../document.js";
|
|
2
|
+
/**
|
|
3
|
+
* Document members with no remote twin:
|
|
4
|
+
* - `transact` takes a callback, which can't cross to a worker: use `apply` with ops;
|
|
5
|
+
* - `saveJob` returns a job the caller steps: the remote `save`/`saveWithReport` are stepped
|
|
6
|
+
* jobs already, cancelled through `signal`;
|
|
7
|
+
* - `ensure` fetches a range document's bytes: the worker does that for every call;
|
|
8
|
+
* - `free` and `Symbol.dispose`: the remote handle's `close()` and `Symbol.asyncDispose`.
|
|
9
|
+
*/
|
|
10
|
+
export type ExcludedDocumentMembers = "transact" | "saveJob" | "ensure" | "free" | typeof Symbol.dispose;
|
|
11
|
+
/**
|
|
12
|
+
* PageRef members with no remote twin: `free` and `Symbol.dispose`, since the worker frees a page
|
|
13
|
+
* with its document.
|
|
14
|
+
*/
|
|
15
|
+
export type ExcludedPageMembers = "free" | typeof Symbol.dispose;
|
|
16
|
+
export type RemotableDocumentMember = Exclude<keyof Document, ExcludedDocumentMembers>;
|
|
17
|
+
export type RemotablePageMember = Exclude<keyof PageRef, ExcludedPageMembers>;
|
|
18
|
+
export declare const DOCUMENT_METHODS: {
|
|
19
|
+
readonly apply: 1;
|
|
20
|
+
readonly applyLog: 1;
|
|
21
|
+
readonly canExtractText: 0;
|
|
22
|
+
readonly extract: 1;
|
|
23
|
+
readonly hasUnsavedChanges: 0;
|
|
24
|
+
readonly info: 0;
|
|
25
|
+
readonly page: 1;
|
|
26
|
+
readonly pageById: 1;
|
|
27
|
+
readonly pageCount: 0;
|
|
28
|
+
readonly pageInfo: 1;
|
|
29
|
+
readonly pages: 0;
|
|
30
|
+
readonly rebase: 1;
|
|
31
|
+
readonly redo: 0;
|
|
32
|
+
readonly save: 1;
|
|
33
|
+
readonly saveWithReport: 1;
|
|
34
|
+
readonly undo: 0;
|
|
35
|
+
readonly warnings: 0;
|
|
36
|
+
};
|
|
37
|
+
export declare const PAGE_METHODS: {
|
|
38
|
+
readonly id: 0;
|
|
39
|
+
readonly index: 0;
|
|
40
|
+
readonly info: 0;
|
|
41
|
+
readonly text: 1;
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=support.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"support.d.ts","sourceRoot":"","sources":["../../src/worker/support.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAExD;;;;;;;GAOG;AACH,MAAM,MAAM,uBAAuB,GAAG,UAAU,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,MAAM,CAAC,OAAO,CAAC;AAEzG;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,OAAO,MAAM,CAAC,OAAO,CAAC;AAEjE,MAAM,MAAM,uBAAuB,GAAG,OAAO,CAAC,MAAM,QAAQ,EAAE,uBAAuB,CAAC,CAAC;AACvF,MAAM,MAAM,mBAAmB,GAAG,OAAO,CAAC,MAAM,OAAO,EAAE,mBAAmB,CAAC,CAAC;AAE9E,eAAO,MAAM,gBAAgB;oBACpB,CAAC;uBACE,CAAC;6BACK,CAAC;sBACR,CAAC;gCACS,CAAC;mBACd,CAAC;mBACD,CAAC;uBACG,CAAC;wBACA,CAAC;uBACF,CAAC;oBACJ,CAAC;qBACA,CAAC;mBACH,CAAC;mBACD,CAAC;6BACS,CAAC;mBACX,CAAC;uBACG,CAAC;CAC+C,CAAC;AAE7D,eAAO,MAAM,YAAY;iBACnB,CAAC;oBACE,CAAC;mBACF,CAAC;mBACD,CAAC;CAC+C,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export const DOCUMENT_METHODS = {
|
|
2
|
+
apply: 1,
|
|
3
|
+
applyLog: 1,
|
|
4
|
+
canExtractText: 0,
|
|
5
|
+
extract: 1,
|
|
6
|
+
hasUnsavedChanges: 0,
|
|
7
|
+
info: 0,
|
|
8
|
+
page: 1,
|
|
9
|
+
pageById: 1,
|
|
10
|
+
pageCount: 0,
|
|
11
|
+
pageInfo: 1,
|
|
12
|
+
pages: 0,
|
|
13
|
+
rebase: 1,
|
|
14
|
+
redo: 0,
|
|
15
|
+
save: 1,
|
|
16
|
+
saveWithReport: 1,
|
|
17
|
+
undo: 0,
|
|
18
|
+
warnings: 0,
|
|
19
|
+
};
|
|
20
|
+
export const PAGE_METHODS = {
|
|
21
|
+
id: 0,
|
|
22
|
+
index: 0,
|
|
23
|
+
info: 0,
|
|
24
|
+
text: 1,
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=support.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"support.js","sourceRoot":"","sources":["../../src/worker/support.ts"],"names":[],"mappings":"AA0BA,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,KAAK,EAAE,CAAC;IACR,QAAQ,EAAE,CAAC;IACX,cAAc,EAAE,CAAC;IACjB,OAAO,EAAE,CAAC;IACV,iBAAiB,EAAE,CAAC;IACpB,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;IACP,QAAQ,EAAE,CAAC;IACX,SAAS,EAAE,CAAC;IACZ,QAAQ,EAAE,CAAC;IACX,KAAK,EAAE,CAAC;IACR,MAAM,EAAE,CAAC;IACT,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;IACP,cAAc,EAAE,CAAC;IACjB,IAAI,EAAE,CAAC;IACP,QAAQ,EAAE,CAAC;CAC+C,CAAC;AAE7D,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,EAAE,EAAE,CAAC;IACL,KAAK,EAAE,CAAC;IACR,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;CAC+C,CAAC"}
|