@embedpdf/core 3.0.0-next.15 → 3.0.0-next.16

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/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { $ as PdfSaveMode, $t as isPluginError, A as Identity, At as MirrorReload, B as OperationOptions, Bt as ChangeQueue, C as DocumentsToken, Ct as SerialQueue, D as EventOrigin, Dt as PageMirrorSpec, E as EngineFactory, Et as PageMirrorChange, F as OpenDocumentOptions, Ft as Cancel, G as PageInsertResult, Gt as SettledChange, H as PageDestination, Ht as HoldOptions, I as OpenDocumentResult, It as HostClock, J as PagePosition, Jt as EventHookSource, K as PageLayout, Kt as StagedChange, L as OpenInput, Lt as PluginClock, M as LockedDocumentInfo, Mt as reload, N as MetadataPatch, Nt as SliceChange, O as FailedDocumentInfo, Ot as Mirror, P as MetadataUpdateResult, Pt as SliceLease, Q as PdfRotation, Qt as PluginErrorInfo, R as OpenOptions, Rt as timerClock, S as DocumentsCapability, St as mergeSettings, T as Engine, Tt as PageMirror, U as PageInfo, Ut as PendingChange, V as PageDeleteResult, Vt as HeldChange, W as PageInsertBlankSpec, Wt as PredictedOp, X as PageRotateResult, Xt as PluginError, Y as PageReorderResult, Yt as createEventHook, Z as PdfDestination, Zt as PluginErrorCode, _ as DocumentOpenFailedEvent, _t as Settings, a as CustomMetadata, an as createLatestLane, at as PluginScope, b as DocumentStatus, bt as SettingsDeclaration, c as DocCapability, ct as ResourceStatus, d as DocumentEvent, dt as Subscribable, en as toPluginError, et as PdfSize, f as DocumentHandle, ft as UnlockOptions, g as DocumentMetadata, gt as NoSettings, h as DocumentMeta, ht as DeepPartial, i as CoreState, in as LatestRun, it as PluginDef, j as InitialDocument, jt as MirrorSpec, k as GlobalState, kt as MirrorChange, l as DocumentActiveChangedEvent, lt as StateCell, m as DocumentLockedEvent, mt as UrlSource, n as BatchResult, nn as LatestCancellation, nt as Permission, o as CustomMetadataPatch, ot as PromiseMemberOf, p as DocumentInfo, pt as Unsubscribe, q as PageObjectNumber, qt as EventHook, r as CapabilityToken, rn as LatestLane, rt as PluginContext, s as CustomMetadataUpdateResult, st as PromiseMembers, t as AnyPlugin, tn as toPluginErrorInfo, tt as PendingMeta, u as DocumentClosedEvent, ut as StateChange, v as DocumentOpenedEvent, vt as SettingsApi, w as DownloadOptions, wt as createSerialQueue, x as DocumentUnsavedChangesChangedEvent, xt as SettingsOf, y as DocumentPagesChangedEvent, yt as SettingsChangedEvent, z as OpenSource, zt as ChangeLabel } from "./types-t-DaU8VK.cjs";
2
- import { AbortablePromise, AnnotationAppearanceImage, AnnotationRef, CONTINUOUS_RENDER_POLICY, CallFacts, CallPriority, DocumentHandle as DocumentHandle$1, EngineRenderPolicy, Identity as Identity$1, PageHandle, PageImageHandle, PageImageObjectUrl, PageImageOptions, PageLayerRights, PageRaster, PageRef, PageRenderLayers, PageRenderOptions, PageRenderTarget, PageRenderViewport, PdfRect, PermissionDenied, WorkingSetPage, annotationKey, decodePageKey, encodePageKey, isLocalEngine, pageRefsEqual, resolvePageLayers, snapAppearanceScale, snapFullPageViewport, snapTileScale, toPageRef } from "@embedpdf/engine-core/runtime";
1
+ import { $ as PdfRotation, $t as StagedChange, A as HostPrinter, At as SerialQueue, B as OpenSource, Bt as SliceChange, C as DocumentsToken, Ct as NoSettings, D as EventOrigin, Dt as SettingsDeclaration, E as EngineFactory, Et as SettingsChangedEvent, F as MetadataUpdateResult, Ft as Mirror, G as PageInsertBlankSpec, Gt as timerClock, H as PageDeleteResult, Ht as Cancel, I as OpenDocumentOptions, It as MirrorChange, J as PageObjectNumber, Jt as HeldChange, K as PageInsertResult, Kt as ChangeLabel, L as OpenDocumentResult, Lt as MirrorReload, M as InitialDocument, Mt as PageMirror, N as LockedDocumentInfo, Nt as PageMirrorChange, O as FailedDocumentInfo, Ot as SettingsOf, P as MetadataPatch, Pt as PageMirrorSpec, Q as PdfDestination, Qt as SettledChange, R as OpenInput, Rt as MirrorSpec, S as DocumentsCapability, St as DeepPartial, T as Engine, Tt as SettingsApi, U as PageDestination, Ut as HostClock, V as OperationOptions, Vt as SliceLease, W as PageInfo, Wt as PluginClock, X as PageReorderResult, Xt as PendingChange, Y as PagePosition, Yt as HoldOptions, Z as PageRotateResult, Zt as PredictedOp, _ as DocumentOpenFailedEvent, _t as StateChange, a as CustomMetadata, an as PluginErrorInfo, at as PluginDef, b as DocumentStatus, bt as Unsubscribe, c as DocCapability, cn as toPluginErrorInfo, ct as PrintOptions, d as DocumentEvent, dn as LatestRun, dt as PrintSheet, en as EventHook, et as PdfSaveMode, f as DocumentHandle, fn as createLatestLane, ft as PromiseMemberOf, g as DocumentMetadata, gt as StateCell, h as DocumentMeta, ht as StagedPrint, i as CoreState, in as PluginErrorCode, it as PluginContext, j as Identity, jt as createSerialQueue, k as GlobalState, kt as mergeSettings, l as DocumentActiveChangedEvent, ln as LatestCancellation, lt as PrintProgress, m as DocumentLockedEvent, mt as ResourceStatus, n as BatchResult, nn as createEventHook, nt as PendingMeta, o as CustomMetadataPatch, on as isPluginError, ot as PluginScope, p as DocumentInfo, pt as PromiseMembers, q as PageLayout, qt as ChangeQueue, r as CapabilityToken, rn as PluginError, rt as Permission, s as CustomMetadataUpdateResult, sn as toPluginError, st as PreparedPrint, t as AnyPlugin, tn as EventHookSource, tt as PdfSize, u as DocumentClosedEvent, un as LatestLane, ut as PrintQuality, v as DocumentOpenedEvent, vt as Subscribable, w as DownloadOptions, wt as Settings, x as DocumentUnsavedChangesChangedEvent, xt as UrlSource, y as DocumentPagesChangedEvent, yt as UnlockOptions, z as OpenOptions, zt as reload } from "./types-CfnZ7go6.cjs";
2
+ import { AbortablePromise, AnnotationAppearanceImage, AnnotationRef, CONTINUOUS_RENDER_POLICY, CallFacts, CallPriority, DocumentHandle as DocumentHandle$1, EngineRenderPolicy, Identity as Identity$1, PageHandle, PageImageHandle, PageImageObjectUrl, PageImageOptions, PageLayerRights, PageRaster, PageRef, PageRenderLayers, PageRenderOptions, PageRenderTarget, PageRenderViewport, PdfRect, PermissionDenied, PrintDpi, WorkingSetPage, annotationKey, decodePageKey, encodePageKey, isLocalEngine, pageRefsEqual, resolvePageLayers, snapAppearanceScale, snapFullPageViewport, snapTileScale, toPageRef } from "@embedpdf/engine-core/runtime";
3
3
  //#region src/viewer-settings.d.ts
4
4
  /** How each page looks before its picture arrives, and around it. */
5
5
  interface ViewerPageSettings {
@@ -121,6 +121,11 @@ declare function createKernel(config: {
121
121
  * timers and no frames.
122
122
  */
123
123
  clock?: HostClock;
124
+ /**
125
+ * The host's print dialog: where `documents.print()` sends the pages. A browser passes
126
+ * `browserPrinter()` from `@embedpdf/web`. Without one, nothing prints (`canPrint()` is false).
127
+ */
128
+ printer?: HostPrinter;
124
129
  }): Kernel;
125
130
  //#endregion
126
131
  //#region src/compose.d.ts
@@ -297,5 +302,5 @@ declare function createHostToken<Host>(token: CapabilityToken<unknown>): Capabil
297
302
  */
298
303
  declare function definePlugin<State = void, Capability = unknown, Settings extends object = NoSettings>(definition: PluginDef<State, Capability, Settings>): PluginDef<State, Capability, Settings>;
299
304
  //#endregion
300
- export { AbortablePromise, type AnnotationAppearanceImage, type AnnotationRef, AnyPlugin, BatchResult, CONTINUOUS_RENDER_POLICY, type CallFacts, type CallPriority, type Cancel, CancelledError, CapabilityToken, type ChangeLabel, type ChangeQueue, CoreState, type CustomMetadata, type CustomMetadataPatch, type CustomMetadataUpdateResult, type DeepPartial, type DocCapability, DocumentActiveChangedEvent, DocumentClosedEvent, type DocumentEvent, type DocumentHandle, DocumentInfo, DocumentLockedEvent, DocumentMeta, type DocumentMetadata, DocumentOpenFailedEvent, DocumentOpenedEvent, DocumentPagesChangedEvent, DocumentStatus, DocumentUnsavedChangesChangedEvent, DocumentsCapability, type DocumentsState, DocumentsToken, DownloadOptions, type Engine, type EngineFactory, type EngineRenderPolicy, EventHook, EventHookSource, type EventOrigin, FailedDocumentInfo, GlobalState, type HeldChange, type HoldOptions, type HostClock, type Identity, InitialDocument, Kernel, KernelStatus, type LatestCancellation, type LatestLane, type LatestRun, LockedDocumentInfo, type MetadataPatch, type MetadataUpdateResult, type Mirror, type MirrorChange, type MirrorReload, type MirrorSpec, type NoSettings, OpenDocumentOptions, OpenDocumentResult, type OpenInput, type OpenOptions, OpenSource, OperationOptions, type PageDeleteResult, type PageDestination, type PageHandle, type PageImageHandle, type PageImageObjectUrl, type PageImageOptions, PageInfo, type PageInsertBlankSpec, type PageInsertResult, type PageLayerRights, type PageLayout, type PageMirror, type PageMirrorChange, type PageMirrorSpec, type PageObjectNumber, type PagePosition, type PageRaster, type PageRef, type PageRenderLayers, type PageRenderOptions, type PageRenderTarget, type PageRenderViewport, type PageReorderResult, type PageRotateResult, type PdfDestination, type PdfRect, type PdfRotation, type PdfSaveMode, type PdfSize, type PendingChange, PendingMeta, Permission, PermissionDenied, type PluginClock, PluginContext, PluginDef, PluginError, PluginErrorCode, PluginErrorInfo, PluginScope, type PredictedOp, PromiseMemberOf, PromiseMembers, ResourceStatus, SerialQueue, type Settings, type SettingsApi, type SettingsChangedEvent, type SettingsDeclaration, type SettingsOf, type SettledChange, type SliceChange, type SliceLease, type StagedChange, StateCell, StateChange, type StateDeclaration, Subscribable, UnlockOptions, Unsubscribe, UrlSource, VIEWER_DEFAULTS, VIEWER_WHOLE_SETTINGS, type ViewerPageSettings, type ViewerSettings, type ViewerSettingsInput, type WorkingSetPage, annotationKey, composeApi, createCapabilityToken, createEventHook, createHostToken, createKernel, createLatestLane, createSerialQueue, decodePageKey, definePlugin, defineState, documentState, documentsState, encodePageKey, guardHandle, isCancelled, isLocalEngine, isPluginError, isReadMember, memo, memoByKey, mergeSettings, pageRefsEqual, reload, resolvePageLayers, returnsPromise, shallowEqual, snapAppearanceScale, snapFullPageViewport, snapTileScale, standInFor, timerClock, toPageRef, toPluginError, toPluginErrorInfo, viewerSettingsOf };
305
+ export { AbortablePromise, type AnnotationAppearanceImage, type AnnotationRef, AnyPlugin, BatchResult, CONTINUOUS_RENDER_POLICY, type CallFacts, type CallPriority, type Cancel, CancelledError, CapabilityToken, type ChangeLabel, type ChangeQueue, CoreState, type CustomMetadata, type CustomMetadataPatch, type CustomMetadataUpdateResult, type DeepPartial, type DocCapability, DocumentActiveChangedEvent, DocumentClosedEvent, type DocumentEvent, type DocumentHandle, DocumentInfo, DocumentLockedEvent, DocumentMeta, type DocumentMetadata, DocumentOpenFailedEvent, DocumentOpenedEvent, DocumentPagesChangedEvent, DocumentStatus, DocumentUnsavedChangesChangedEvent, DocumentsCapability, type DocumentsState, DocumentsToken, DownloadOptions, type Engine, type EngineFactory, type EngineRenderPolicy, EventHook, EventHookSource, type EventOrigin, FailedDocumentInfo, GlobalState, type HeldChange, type HoldOptions, type HostClock, HostPrinter, type Identity, InitialDocument, Kernel, KernelStatus, type LatestCancellation, type LatestLane, type LatestRun, LockedDocumentInfo, type MetadataPatch, type MetadataUpdateResult, type Mirror, type MirrorChange, type MirrorReload, type MirrorSpec, type NoSettings, OpenDocumentOptions, OpenDocumentResult, type OpenInput, type OpenOptions, OpenSource, OperationOptions, type PageDeleteResult, type PageDestination, type PageHandle, type PageImageHandle, type PageImageObjectUrl, type PageImageOptions, PageInfo, type PageInsertBlankSpec, type PageInsertResult, type PageLayerRights, type PageLayout, type PageMirror, type PageMirrorChange, type PageMirrorSpec, type PageObjectNumber, type PagePosition, type PageRaster, type PageRef, type PageRenderLayers, type PageRenderOptions, type PageRenderTarget, type PageRenderViewport, type PageReorderResult, type PageRotateResult, type PdfDestination, type PdfRect, type PdfRotation, type PdfSaveMode, type PdfSize, type PendingChange, PendingMeta, Permission, PermissionDenied, type PluginClock, PluginContext, PluginDef, PluginError, PluginErrorCode, PluginErrorInfo, PluginScope, type PredictedOp, PreparedPrint, type PrintDpi, PrintOptions, PrintProgress, PrintQuality, PrintSheet, PromiseMemberOf, PromiseMembers, ResourceStatus, SerialQueue, type Settings, type SettingsApi, type SettingsChangedEvent, type SettingsDeclaration, type SettingsOf, type SettledChange, type SliceChange, type SliceLease, type StagedChange, StagedPrint, StateCell, StateChange, type StateDeclaration, Subscribable, UnlockOptions, Unsubscribe, UrlSource, VIEWER_DEFAULTS, VIEWER_WHOLE_SETTINGS, type ViewerPageSettings, type ViewerSettings, type ViewerSettingsInput, type WorkingSetPage, annotationKey, composeApi, createCapabilityToken, createEventHook, createHostToken, createKernel, createLatestLane, createSerialQueue, decodePageKey, definePlugin, defineState, documentState, documentsState, encodePageKey, guardHandle, isCancelled, isLocalEngine, isPluginError, isReadMember, memo, memoByKey, mergeSettings, pageRefsEqual, reload, resolvePageLayers, returnsPromise, shallowEqual, snapAppearanceScale, snapFullPageViewport, snapTileScale, standInFor, timerClock, toPageRef, toPluginError, toPluginErrorInfo, viewerSettingsOf };
301
306
  //# sourceMappingURL=index.d.cts.map
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { $ as PdfSaveMode, $t as isPluginError, A as Identity, At as MirrorReload, B as OperationOptions, Bt as ChangeQueue, C as DocumentsToken, Ct as SerialQueue, D as EventOrigin, Dt as PageMirrorSpec, E as EngineFactory, Et as PageMirrorChange, F as OpenDocumentOptions, Ft as Cancel, G as PageInsertResult, Gt as SettledChange, H as PageDestination, Ht as HoldOptions, I as OpenDocumentResult, It as HostClock, J as PagePosition, Jt as EventHookSource, K as PageLayout, Kt as StagedChange, L as OpenInput, Lt as PluginClock, M as LockedDocumentInfo, Mt as reload, N as MetadataPatch, Nt as SliceChange, O as FailedDocumentInfo, Ot as Mirror, P as MetadataUpdateResult, Pt as SliceLease, Q as PdfRotation, Qt as PluginErrorInfo, R as OpenOptions, Rt as timerClock, S as DocumentsCapability, St as mergeSettings, T as Engine, Tt as PageMirror, U as PageInfo, Ut as PendingChange, V as PageDeleteResult, Vt as HeldChange, W as PageInsertBlankSpec, Wt as PredictedOp, X as PageRotateResult, Xt as PluginError, Y as PageReorderResult, Yt as createEventHook, Z as PdfDestination, Zt as PluginErrorCode, _ as DocumentOpenFailedEvent, _t as Settings, a as CustomMetadata, an as createLatestLane, at as PluginScope, b as DocumentStatus, bt as SettingsDeclaration, c as DocCapability, ct as ResourceStatus, d as DocumentEvent, dt as Subscribable, en as toPluginError, et as PdfSize, f as DocumentHandle, ft as UnlockOptions, g as DocumentMetadata, gt as NoSettings, h as DocumentMeta, ht as DeepPartial, i as CoreState, in as LatestRun, it as PluginDef, j as InitialDocument, jt as MirrorSpec, k as GlobalState, kt as MirrorChange, l as DocumentActiveChangedEvent, lt as StateCell, m as DocumentLockedEvent, mt as UrlSource, n as BatchResult, nn as LatestCancellation, nt as Permission, o as CustomMetadataPatch, ot as PromiseMemberOf, p as DocumentInfo, pt as Unsubscribe, q as PageObjectNumber, qt as EventHook, r as CapabilityToken, rn as LatestLane, rt as PluginContext, s as CustomMetadataUpdateResult, st as PromiseMembers, t as AnyPlugin, tn as toPluginErrorInfo, tt as PendingMeta, u as DocumentClosedEvent, ut as StateChange, v as DocumentOpenedEvent, vt as SettingsApi, w as DownloadOptions, wt as createSerialQueue, x as DocumentUnsavedChangesChangedEvent, xt as SettingsOf, y as DocumentPagesChangedEvent, yt as SettingsChangedEvent, z as OpenSource, zt as ChangeLabel } from "./types-t-DaU8VK.js";
2
- import { AbortablePromise, AnnotationAppearanceImage, AnnotationRef, CONTINUOUS_RENDER_POLICY, CallFacts, CallPriority, DocumentHandle as DocumentHandle$1, EngineRenderPolicy, Identity as Identity$1, PageHandle, PageImageHandle, PageImageObjectUrl, PageImageOptions, PageLayerRights, PageRaster, PageRef, PageRenderLayers, PageRenderOptions, PageRenderTarget, PageRenderViewport, PdfRect, PermissionDenied, WorkingSetPage, annotationKey, decodePageKey, encodePageKey, isLocalEngine, pageRefsEqual, resolvePageLayers, snapAppearanceScale, snapFullPageViewport, snapTileScale, toPageRef } from "@embedpdf/engine-core/runtime";
1
+ import { $ as PdfRotation, $t as StagedChange, A as HostPrinter, At as SerialQueue, B as OpenSource, Bt as SliceChange, C as DocumentsToken, Ct as NoSettings, D as EventOrigin, Dt as SettingsDeclaration, E as EngineFactory, Et as SettingsChangedEvent, F as MetadataUpdateResult, Ft as Mirror, G as PageInsertBlankSpec, Gt as timerClock, H as PageDeleteResult, Ht as Cancel, I as OpenDocumentOptions, It as MirrorChange, J as PageObjectNumber, Jt as HeldChange, K as PageInsertResult, Kt as ChangeLabel, L as OpenDocumentResult, Lt as MirrorReload, M as InitialDocument, Mt as PageMirror, N as LockedDocumentInfo, Nt as PageMirrorChange, O as FailedDocumentInfo, Ot as SettingsOf, P as MetadataPatch, Pt as PageMirrorSpec, Q as PdfDestination, Qt as SettledChange, R as OpenInput, Rt as MirrorSpec, S as DocumentsCapability, St as DeepPartial, T as Engine, Tt as SettingsApi, U as PageDestination, Ut as HostClock, V as OperationOptions, Vt as SliceLease, W as PageInfo, Wt as PluginClock, X as PageReorderResult, Xt as PendingChange, Y as PagePosition, Yt as HoldOptions, Z as PageRotateResult, Zt as PredictedOp, _ as DocumentOpenFailedEvent, _t as StateChange, a as CustomMetadata, an as PluginErrorInfo, at as PluginDef, b as DocumentStatus, bt as Unsubscribe, c as DocCapability, cn as toPluginErrorInfo, ct as PrintOptions, d as DocumentEvent, dn as LatestRun, dt as PrintSheet, en as EventHook, et as PdfSaveMode, f as DocumentHandle, fn as createLatestLane, ft as PromiseMemberOf, g as DocumentMetadata, gt as StateCell, h as DocumentMeta, ht as StagedPrint, i as CoreState, in as PluginErrorCode, it as PluginContext, j as Identity, jt as createSerialQueue, k as GlobalState, kt as mergeSettings, l as DocumentActiveChangedEvent, ln as LatestCancellation, lt as PrintProgress, m as DocumentLockedEvent, mt as ResourceStatus, n as BatchResult, nn as createEventHook, nt as PendingMeta, o as CustomMetadataPatch, on as isPluginError, ot as PluginScope, p as DocumentInfo, pt as PromiseMembers, q as PageLayout, qt as ChangeQueue, r as CapabilityToken, rn as PluginError, rt as Permission, s as CustomMetadataUpdateResult, sn as toPluginError, st as PreparedPrint, t as AnyPlugin, tn as EventHookSource, tt as PdfSize, u as DocumentClosedEvent, un as LatestLane, ut as PrintQuality, v as DocumentOpenedEvent, vt as Subscribable, w as DownloadOptions, wt as Settings, x as DocumentUnsavedChangesChangedEvent, xt as UrlSource, y as DocumentPagesChangedEvent, yt as UnlockOptions, z as OpenOptions, zt as reload } from "./types-CfnZ7go6.js";
2
+ import { AbortablePromise, AnnotationAppearanceImage, AnnotationRef, CONTINUOUS_RENDER_POLICY, CallFacts, CallPriority, DocumentHandle as DocumentHandle$1, EngineRenderPolicy, Identity as Identity$1, PageHandle, PageImageHandle, PageImageObjectUrl, PageImageOptions, PageLayerRights, PageRaster, PageRef, PageRenderLayers, PageRenderOptions, PageRenderTarget, PageRenderViewport, PdfRect, PermissionDenied, PrintDpi, WorkingSetPage, annotationKey, decodePageKey, encodePageKey, isLocalEngine, pageRefsEqual, resolvePageLayers, snapAppearanceScale, snapFullPageViewport, snapTileScale, toPageRef } from "@embedpdf/engine-core/runtime";
3
3
  //#region src/viewer-settings.d.ts
4
4
  /** How each page looks before its picture arrives, and around it. */
5
5
  interface ViewerPageSettings {
@@ -121,6 +121,11 @@ declare function createKernel(config: {
121
121
  * timers and no frames.
122
122
  */
123
123
  clock?: HostClock;
124
+ /**
125
+ * The host's print dialog: where `documents.print()` sends the pages. A browser passes
126
+ * `browserPrinter()` from `@embedpdf/web`. Without one, nothing prints (`canPrint()` is false).
127
+ */
128
+ printer?: HostPrinter;
124
129
  }): Kernel;
125
130
  //#endregion
126
131
  //#region src/compose.d.ts
@@ -297,5 +302,5 @@ declare function createHostToken<Host>(token: CapabilityToken<unknown>): Capabil
297
302
  */
298
303
  declare function definePlugin<State = void, Capability = unknown, Settings extends object = NoSettings>(definition: PluginDef<State, Capability, Settings>): PluginDef<State, Capability, Settings>;
299
304
  //#endregion
300
- export { AbortablePromise, type AnnotationAppearanceImage, type AnnotationRef, AnyPlugin, BatchResult, CONTINUOUS_RENDER_POLICY, type CallFacts, type CallPriority, type Cancel, CancelledError, CapabilityToken, type ChangeLabel, type ChangeQueue, CoreState, type CustomMetadata, type CustomMetadataPatch, type CustomMetadataUpdateResult, type DeepPartial, type DocCapability, DocumentActiveChangedEvent, DocumentClosedEvent, type DocumentEvent, type DocumentHandle, DocumentInfo, DocumentLockedEvent, DocumentMeta, type DocumentMetadata, DocumentOpenFailedEvent, DocumentOpenedEvent, DocumentPagesChangedEvent, DocumentStatus, DocumentUnsavedChangesChangedEvent, DocumentsCapability, type DocumentsState, DocumentsToken, DownloadOptions, type Engine, type EngineFactory, type EngineRenderPolicy, EventHook, EventHookSource, type EventOrigin, FailedDocumentInfo, GlobalState, type HeldChange, type HoldOptions, type HostClock, type Identity, InitialDocument, Kernel, KernelStatus, type LatestCancellation, type LatestLane, type LatestRun, LockedDocumentInfo, type MetadataPatch, type MetadataUpdateResult, type Mirror, type MirrorChange, type MirrorReload, type MirrorSpec, type NoSettings, OpenDocumentOptions, OpenDocumentResult, type OpenInput, type OpenOptions, OpenSource, OperationOptions, type PageDeleteResult, type PageDestination, type PageHandle, type PageImageHandle, type PageImageObjectUrl, type PageImageOptions, PageInfo, type PageInsertBlankSpec, type PageInsertResult, type PageLayerRights, type PageLayout, type PageMirror, type PageMirrorChange, type PageMirrorSpec, type PageObjectNumber, type PagePosition, type PageRaster, type PageRef, type PageRenderLayers, type PageRenderOptions, type PageRenderTarget, type PageRenderViewport, type PageReorderResult, type PageRotateResult, type PdfDestination, type PdfRect, type PdfRotation, type PdfSaveMode, type PdfSize, type PendingChange, PendingMeta, Permission, PermissionDenied, type PluginClock, PluginContext, PluginDef, PluginError, PluginErrorCode, PluginErrorInfo, PluginScope, type PredictedOp, PromiseMemberOf, PromiseMembers, ResourceStatus, SerialQueue, type Settings, type SettingsApi, type SettingsChangedEvent, type SettingsDeclaration, type SettingsOf, type SettledChange, type SliceChange, type SliceLease, type StagedChange, StateCell, StateChange, type StateDeclaration, Subscribable, UnlockOptions, Unsubscribe, UrlSource, VIEWER_DEFAULTS, VIEWER_WHOLE_SETTINGS, type ViewerPageSettings, type ViewerSettings, type ViewerSettingsInput, type WorkingSetPage, annotationKey, composeApi, createCapabilityToken, createEventHook, createHostToken, createKernel, createLatestLane, createSerialQueue, decodePageKey, definePlugin, defineState, documentState, documentsState, encodePageKey, guardHandle, isCancelled, isLocalEngine, isPluginError, isReadMember, memo, memoByKey, mergeSettings, pageRefsEqual, reload, resolvePageLayers, returnsPromise, shallowEqual, snapAppearanceScale, snapFullPageViewport, snapTileScale, standInFor, timerClock, toPageRef, toPluginError, toPluginErrorInfo, viewerSettingsOf };
305
+ export { AbortablePromise, type AnnotationAppearanceImage, type AnnotationRef, AnyPlugin, BatchResult, CONTINUOUS_RENDER_POLICY, type CallFacts, type CallPriority, type Cancel, CancelledError, CapabilityToken, type ChangeLabel, type ChangeQueue, CoreState, type CustomMetadata, type CustomMetadataPatch, type CustomMetadataUpdateResult, type DeepPartial, type DocCapability, DocumentActiveChangedEvent, DocumentClosedEvent, type DocumentEvent, type DocumentHandle, DocumentInfo, DocumentLockedEvent, DocumentMeta, type DocumentMetadata, DocumentOpenFailedEvent, DocumentOpenedEvent, DocumentPagesChangedEvent, DocumentStatus, DocumentUnsavedChangesChangedEvent, DocumentsCapability, type DocumentsState, DocumentsToken, DownloadOptions, type Engine, type EngineFactory, type EngineRenderPolicy, EventHook, EventHookSource, type EventOrigin, FailedDocumentInfo, GlobalState, type HeldChange, type HoldOptions, type HostClock, HostPrinter, type Identity, InitialDocument, Kernel, KernelStatus, type LatestCancellation, type LatestLane, type LatestRun, LockedDocumentInfo, type MetadataPatch, type MetadataUpdateResult, type Mirror, type MirrorChange, type MirrorReload, type MirrorSpec, type NoSettings, OpenDocumentOptions, OpenDocumentResult, type OpenInput, type OpenOptions, OpenSource, OperationOptions, type PageDeleteResult, type PageDestination, type PageHandle, type PageImageHandle, type PageImageObjectUrl, type PageImageOptions, PageInfo, type PageInsertBlankSpec, type PageInsertResult, type PageLayerRights, type PageLayout, type PageMirror, type PageMirrorChange, type PageMirrorSpec, type PageObjectNumber, type PagePosition, type PageRaster, type PageRef, type PageRenderLayers, type PageRenderOptions, type PageRenderTarget, type PageRenderViewport, type PageReorderResult, type PageRotateResult, type PdfDestination, type PdfRect, type PdfRotation, type PdfSaveMode, type PdfSize, type PendingChange, PendingMeta, Permission, PermissionDenied, type PluginClock, PluginContext, PluginDef, PluginError, PluginErrorCode, PluginErrorInfo, PluginScope, type PredictedOp, PreparedPrint, type PrintDpi, PrintOptions, PrintProgress, PrintQuality, PrintSheet, PromiseMemberOf, PromiseMembers, ResourceStatus, SerialQueue, type Settings, type SettingsApi, type SettingsChangedEvent, type SettingsDeclaration, type SettingsOf, type SettledChange, type SliceChange, type SliceLease, type StagedChange, StagedPrint, StateCell, StateChange, type StateDeclaration, Subscribable, UnlockOptions, Unsubscribe, UrlSource, VIEWER_DEFAULTS, VIEWER_WHOLE_SETTINGS, type ViewerPageSettings, type ViewerSettings, type ViewerSettingsInput, type WorkingSetPage, annotationKey, composeApi, createCapabilityToken, createEventHook, createHostToken, createKernel, createLatestLane, createSerialQueue, decodePageKey, definePlugin, defineState, documentState, documentsState, encodePageKey, guardHandle, isCancelled, isLocalEngine, isPluginError, isReadMember, memo, memoByKey, mergeSettings, pageRefsEqual, reload, resolvePageLayers, returnsPromise, shallowEqual, snapAppearanceScale, snapFullPageViewport, snapTileScale, standInFor, timerClock, toPageRef, toPluginError, toPluginErrorInfo, viewerSettingsOf };
301
306
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { A as createScope, C as createDocumentChanges, D as toPluginError, E as isPluginError, M as createBurstGate, N as DocumentsToken, O as toPluginErrorInfo, S as timerClock, T as PluginError, _ as reload, a as markConnected, b as createStore, d as findPage, i as createPluginContext, j as isCancelled, k as CancelledError, l as permissionDenied, m as createSerialQueue, n as mergeSettings, o as readWrapped, p as cancellable, r as settle, s as sliceKey, t as createSettingsStore, u as sessionAllows, v as createLatestLane, w as createEventHook, y as guardHandle } from "./settings-CMWFRjmQ.js";
1
+ import { A as createScope, C as createDocumentChanges, D as toPluginError, E as isPluginError, M as createBurstGate, N as DocumentsToken, O as toPluginErrorInfo, S as timerClock, T as PluginError, _ as reload, a as markConnected, b as createStore, d as findPage, i as createPluginContext, j as isCancelled, k as CancelledError, l as permissionDenied, m as createSerialQueue, n as mergeSettings, o as runWrapped, p as cancellable, r as settle, s as sliceKey, t as createSettingsStore, u as sessionAllows, v as createLatestLane, w as createEventHook, y as guardHandle } from "./settings-CHdHuZ3k.js";
2
2
  import { AbortablePromise, CONTINUOUS_RENDER_POLICY, CONTINUOUS_RENDER_POLICY as CONTINUOUS_RENDER_POLICY$1, PermissionDenied, annotationKey, decodePageKey, encodePageKey, isLocalDocument, isLocalEngine, pageRefsEqual, pageRefsEqual as pageRefsEqual$1, resolvePageLayers, snapAppearanceScale, snapFullPageViewport, snapTileScale, toPageRef } from "@embedpdf/engine-core/runtime";
3
3
  //#region src/order.ts
4
4
  /**
@@ -96,7 +96,8 @@ function layoutFromEvent(event) {
96
96
  case "pages.reordered":
97
97
  case "pages.rotated":
98
98
  case "pages.deleted":
99
- case "pages.inserted": return event.layout;
99
+ case "pages.inserted":
100
+ case "pages.restored": return event.layout;
100
101
  default: return null;
101
102
  }
102
103
  }
@@ -146,6 +147,16 @@ async function fetchUrlSource(source, signal) {
146
147
  }
147
148
  const isUrlSource = (source) => source.kind === "url";
148
149
  const noLayer = () => new PluginError("unsupported", "documents", "only the local engine gives a layer to download");
150
+ /** How a print comes out at each tier, one object each, so readers can compare them with `Object.is`. */
151
+ const PRINT_STANDARD = Object.freeze({
152
+ kind: "images",
153
+ dpi: 150
154
+ });
155
+ const PRINT_HIGH = Object.freeze({
156
+ kind: "images",
157
+ dpi: 300
158
+ });
159
+ const PRINT_PDF = Object.freeze({ kind: "pdf" });
149
160
  /**
150
161
  * The documents capability as seen from inside one document's scope: every call whose document
151
162
  * is optional uses that document instead of the active one. The rest is the registry itself.
@@ -156,6 +167,9 @@ const documentsInScope = (documents, documentId) => ({
156
167
  download: (id = documentId, options) => documents.download(id, options),
157
168
  downloadLayer: (id = documentId, options) => documents.downloadLayer(id, options),
158
169
  canDownload: (id = documentId) => documents.canDownload(id),
170
+ preparePrint: (id = documentId, options) => documents.preparePrint(id, options),
171
+ print: (id = documentId, options) => documents.print(id, options),
172
+ getPrintQuality: (id = documentId) => documents.getPrintQuality(id),
159
173
  canPrint: (id = documentId) => documents.canPrint(id),
160
174
  listPages: (id = documentId) => documents.listPages(id),
161
175
  getPage: (page, id = documentId) => documents.getPage(page, id),
@@ -293,12 +307,14 @@ function createKernel(config) {
293
307
  leases: /* @__PURE__ */ new Map(),
294
308
  settleFlushes: /* @__PURE__ */ new Set(),
295
309
  downloadWraps: [],
310
+ printWraps: [],
296
311
  changes: createDocumentChanges({
297
312
  handle: () => session.handle,
298
313
  notify: () => store.notify(),
299
314
  report
300
315
  }),
301
316
  changeCount: 0,
317
+ changesSeen: 0,
302
318
  close: () => closeSession(session)
303
319
  };
304
320
  session.settleFlushes.add(() => session.changes.settle());
@@ -517,13 +533,202 @@ function createKernel(config) {
517
533
  readAt = session.changeCount;
518
534
  return cancellable("documents", signal, read(handle));
519
535
  };
520
- const bytes = await readWrapped(session.downloadWraps, readFile);
536
+ const bytes = await runWrapped(session.downloadWraps, readFile);
521
537
  if (readAt === session.changeCount) setUnsavedChanges(session, false);
522
538
  return bytes;
523
539
  } catch (error) {
524
540
  throw toPluginError("documents", error);
525
541
  }
526
542
  }
543
+ const printer = config.printer ?? null;
544
+ const canPrintOn = (documentId) => printer !== null && allowsOn(documentId, "doc.print");
545
+ /**
546
+ * How a print comes out: the PDF copy with `doc.print.high`, a right to keep the copy (every
547
+ * print dialog can save it as a file) and a printer that prints a PDF; else pictures, at the
548
+ * resolution `doc.print.high` or `doc.print` allows.
549
+ */
550
+ const printQualityOf = (documentId) => {
551
+ if (!canPrintOn(documentId)) return null;
552
+ if (!allowsOn(documentId, "doc.print.high")) return PRINT_STANDARD;
553
+ return (allowsOn(documentId, "doc.download") || allowsOn(documentId, "doc.download.flattened")) && printer?.stagePdf ? PRINT_PDF : PRINT_HIGH;
554
+ };
555
+ /** The pages a print asks for, in its order: every page when it names none. */
556
+ function printPagesOf(session, pages) {
557
+ const all = metaOf(session.id)?.pages ?? EMPTY_PAGES;
558
+ if (pages === void 0) return all;
559
+ if (pages.length === 0) throw new PluginError("invalid-input", "documents", "a print needs at least one page");
560
+ const found = pages.map((ref) => {
561
+ const page = findPage(all, ref);
562
+ if (!page) throw new PluginError("not-found", "documents", `page ${ref.objectNumber} is not in this document`);
563
+ return page;
564
+ });
565
+ if (new Set(found).size !== found.length) throw new PluginError("invalid-input", "documents", "a print names a page twice");
566
+ return found;
567
+ }
568
+ /**
569
+ * What prints beside the page content: the annotations as the options ask, by default when
570
+ * the user may read them; the form fields whenever the user may read the form.
571
+ */
572
+ const printLayersOf = (documentId, options) => ({
573
+ includeAnnotations: options.includeAnnotations ?? allowsOn(documentId, "doc.annotate.read"),
574
+ includeFormFields: allowsOn(documentId, "doc.forms.read")
575
+ });
576
+ /**
577
+ * Make the pages as they print and hand them to the printer, once the document settled: the
578
+ * PDF copy, or a picture of each page. The pages are looked up again each time, so one deleted
579
+ * meanwhile refuses `not-found`. Returns the staged print, how it came out, and the change it
580
+ * saw last, so a print can tell it went stale.
581
+ */
582
+ async function stagePrint(session, activePrinter, quality, options) {
583
+ const { signal } = options;
584
+ await settle(session.settleFlushes, [signal, session.signal], report);
585
+ const handle = documentHandle(session.id);
586
+ if (!handle) throw new PluginError("not-ready", "documents", "no open document to print");
587
+ const changesSeen = session.changesSeen;
588
+ const job = {
589
+ handle,
590
+ pages: printPagesOf(session, options.pages),
591
+ layers: printLayersOf(session.id, options),
592
+ name: session.name ?? "document",
593
+ options
594
+ };
595
+ options.onProgress?.({
596
+ pagesRendered: 0,
597
+ pageCount: job.pages.length
598
+ });
599
+ if (quality.kind === "images") return {
600
+ staged: await stagePictures(job, activePrinter, quality.dpi),
601
+ quality,
602
+ changesSeen
603
+ };
604
+ try {
605
+ return {
606
+ staged: await stagePdfCopy(job, activePrinter),
607
+ quality,
608
+ changesSeen
609
+ };
610
+ } catch (error) {
611
+ if (signal?.aborted) throw error;
612
+ return {
613
+ staged: await stagePictures(job, activePrinter, PRINT_HIGH.dpi),
614
+ quality: PRINT_HIGH,
615
+ changesSeen
616
+ };
617
+ }
618
+ }
619
+ /** The PDF copy of the pages as they print, staged with the printer. */
620
+ async function stagePdfCopy(job, activePrinter) {
621
+ const { handle, pages, layers, name, options } = job;
622
+ const { signal } = options;
623
+ if (!activePrinter.stagePdf) throw new PluginError("unsupported", "documents", "this printer prints no PDF");
624
+ const pdf = await cancellable("documents", signal, handle.pages.extract(pages.map((page) => page.ref), {
625
+ flatten: { usage: "print" },
626
+ ...layers
627
+ }));
628
+ const staged = await activePrinter.stagePdf(pdf, {
629
+ name,
630
+ ...signal ? { signal } : {}
631
+ });
632
+ options.onProgress?.({
633
+ pagesRendered: pages.length,
634
+ pageCount: pages.length
635
+ });
636
+ return staged;
637
+ }
638
+ /** A picture of each page, drawn by the print rules at `dpi`, staged with the printer. */
639
+ async function stagePictures(job, activePrinter, dpi) {
640
+ const { handle, pages, layers, name, options } = job;
641
+ const { signal } = options;
642
+ const sheets = [];
643
+ for (const page of pages) {
644
+ const blob = await cancellable("documents", signal, (await cancellable("documents", signal, handle.page(page.ref).render.image({
645
+ usage: "print",
646
+ viewport: {
647
+ kind: "dpi",
648
+ dpi
649
+ },
650
+ format: "png",
651
+ ...layers
652
+ }))).blob());
653
+ sheets.push({
654
+ image: blob,
655
+ widthPt: page.size.width,
656
+ heightPt: page.size.height
657
+ });
658
+ options.onProgress?.({
659
+ pagesRendered: sheets.length,
660
+ pageCount: pages.length
661
+ });
662
+ }
663
+ return activePrinter.stage(sheets, {
664
+ name,
665
+ ...signal ? { signal } : {}
666
+ });
667
+ }
668
+ /**
669
+ * Get a print ready. Refused before anything runs without `doc.print` or a printer, or for
670
+ * pages the document doesn't have. Its `print()` runs inside every `aroundPrint` wrap (the
671
+ * document's own print actions), and prepares again first when the document changed since:
672
+ * a will-print action that fills in a date is on the paper. When the printer turns the PDF
673
+ * copy down, preparing or printing, the same pages print as pictures, and `quality` says so.
674
+ */
675
+ async function preparePrint(documentId, options = {}) {
676
+ const session = readySession(documentId, "preparePrint");
677
+ if (!allowsOn(session.id, "doc.print")) throw permissionDenied("documents", "doc.print", "documents.preparePrint");
678
+ const quality = printQualityOf(session.id);
679
+ if (!printer || !quality) throw new PluginError("unsupported", "documents", "no printer: pass one to createKernel({ printer }), such as browserPrinter() from @embedpdf/web");
680
+ const pageCount = printPagesOf(session, options.pages).length;
681
+ try {
682
+ let { staged, changesSeen, quality: printed } = await stagePrint(session, printer, quality, options);
683
+ let disposed = false;
684
+ const dispose = () => {
685
+ if (disposed) return;
686
+ disposed = true;
687
+ staged.dispose();
688
+ };
689
+ session.scope.defer(dispose);
690
+ /** Stage the print again, as `as`, in place of what was staged. */
691
+ const restage = async (as, signal) => {
692
+ const fresh = await stagePrint(session, printer, as, {
693
+ ...options.pages ? { pages: options.pages } : {},
694
+ ...options.includeAnnotations !== void 0 ? { includeAnnotations: options.includeAnnotations } : {},
695
+ ...signal ? { signal } : {}
696
+ });
697
+ staged.dispose();
698
+ ({staged, changesSeen, quality: printed} = fresh);
699
+ };
700
+ return {
701
+ get quality() {
702
+ return printed;
703
+ },
704
+ pageCount,
705
+ needsTap: printer.needsTap === true,
706
+ async print(printOptions) {
707
+ if (disposed) throw new PluginError("invalid-input", "documents", "this print was disposed");
708
+ const signal = printOptions?.signal;
709
+ const run = async () => {
710
+ if (session.changesSeen !== changesSeen) await restage(quality, signal);
711
+ if (signal?.aborted) throw new PluginError("operation-cancelled", "documents", "print cancelled", { cause: signal.reason });
712
+ try {
713
+ await staged.print();
714
+ } catch (error) {
715
+ if (printed.kind !== "pdf") throw error;
716
+ await restage(PRINT_HIGH, signal);
717
+ await staged.print();
718
+ }
719
+ };
720
+ try {
721
+ await runWrapped(session.printWraps, run);
722
+ } catch (error) {
723
+ throw toPluginError("documents", error);
724
+ }
725
+ },
726
+ dispose
727
+ };
728
+ } catch (error) {
729
+ throw toPluginError("documents", error);
730
+ }
731
+ }
527
732
  /** Whether the plugin's `create()` is running for this document: it has no capability yet. */
528
733
  const isBuilding = (plugin, session) => session.building.has(plugin) && !session.capabilities.has(plugin);
529
734
  function buildDocumentCapability(plugin, session) {
@@ -665,9 +870,12 @@ function createKernel(config) {
665
870
  session.scope.defer(bursts.close);
666
871
  const unsubscribeEvents = session.handle.events.subscribe((event) => {
667
872
  bursts.first(event);
668
- if (tracksChanges && changesDocument(event)) {
669
- session.changeCount += 1;
670
- setUnsavedChanges(session, true);
873
+ if (changesDocument(event)) {
874
+ session.changesSeen += 1;
875
+ if (tracksChanges) {
876
+ session.changeCount += 1;
877
+ setUnsavedChanges(session, true);
878
+ }
671
879
  }
672
880
  const layout = layoutFromEvent(event);
673
881
  if (!layout) return;
@@ -954,8 +1162,18 @@ function createKernel(config) {
954
1162
  },
955
1163
  download: (id, options) => downloadFile(id, options?.signal, "download", (handle) => handle.download(options?.mode !== void 0 ? { mode: options.mode } : void 0)),
956
1164
  downloadLayer: (id, options) => downloadFile(id, options?.signal, "downloadLayer", (handle) => isLocalDocument(handle) ? handle.downloadLayer() : Promise.reject(noLayer()), (handle) => isLocalDocument(handle) ? null : noLayer()),
1165
+ preparePrint: (id, options) => preparePrint(id, options),
1166
+ async print(id, options = {}) {
1167
+ const prepared = await preparePrint(id, options);
1168
+ try {
1169
+ await prepared.print(options.signal ? { signal: options.signal } : void 0);
1170
+ } finally {
1171
+ prepared.dispose();
1172
+ }
1173
+ },
1174
+ getPrintQuality: (id) => printQualityOf(id),
957
1175
  canDownload: (id) => allowsOn(id, "doc.download"),
958
- canPrint: (id) => allowsOn(id, "doc.print"),
1176
+ canPrint: (id) => canPrintOn(id),
959
1177
  listPages: (id) => metaOf(id)?.pages ?? EMPTY_PAGES,
960
1178
  getPage: (page, id) => findPage(metaOf(id)?.pages ?? EMPTY_PAGES, page),
961
1179
  getPageIndex: (ref, id) => metaOf(id)?.pages.findIndex((pageInfo) => pageRefsEqual$1(pageInfo.ref, ref)) ?? -1,