@embedpdf/plugin-annotation 3.2.0 → 3.4.0
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/commands.cjs +25 -0
- package/dist/commands.cjs.map +1 -0
- package/dist/commands.d.cts +7 -0
- package/dist/commands.d.ts +7 -0
- package/dist/commands.js +24 -0
- package/dist/commands.js.map +1 -0
- package/dist/contract/host.d.cts +2 -2
- package/dist/contract/host.d.ts +2 -2
- package/dist/{contract-DkxvCGXL.d.cts → contract-BfZ-mTF7.d.cts} +10 -4
- package/dist/contract-BrvLUGi2.js.map +1 -1
- package/dist/{contract-CQfRsCVj.d.ts → contract-DRUUSPzY.d.ts} +10 -4
- package/dist/contract-X3gZNpwu.cjs.map +1 -1
- package/dist/contract.d.cts +1 -1
- package/dist/contract.d.ts +1 -1
- package/dist/{host-contract-BSH_muud.d.cts → host-contract-BrC7hZw_.d.ts} +27 -8
- package/dist/host-contract-C7vx6wTQ.cjs.map +1 -1
- package/dist/host-contract-CDp5skzD.js.map +1 -1
- package/dist/{host-contract-DU3CxFE1.d.ts → host-contract-CjPbxfhS.d.cts} +27 -8
- package/dist/index.cjs +140 -62
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +136 -64
- package/dist/index.js.map +1 -1
- package/package.json +16 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host-contract-C7vx6wTQ.cjs","names":["PublicAnnotationToken"],"sources":["../src/priorities.ts","../src/host-contract.ts"],"sourcesContent":["/**\n * The interaction-hub priorities of the annotation plugin's handlers — the\n * public contract a sibling plugin builds on when it needs to sit above or\n * below one of them for the same gesture. Priority only breaks ties between\n * simultaneously-eligible handlers (the tool's tags decide eligibility).\n *\n * 100 annotation-edit select/move/resize over an existing annotation\n * 95 annotation-place click-to-place an armed payload on empty page space\n * 55 annotation-draw drag-create under a draw tool (below text-select)\n * 50 annotation-marquee empty-space selection, the final fallback\n *\n * Hover runs in the same order, so a handler's hover sees the cursor claims\n * of every handler above it: a create handler shows its tool's ghost only\n * where nothing above it claims the pointer (an annotation, text).\n *\n * A handler that must win a click over an existing annotation while a\n * placing tool is active (a signature mark dropped onto a signature field)\n * registers above {@link ANNOTATION_EDIT_PRIORITY}, not merely above place:\n * the edit handler captures first over any annotation, a widget included.\n */\nexport const ANNOTATION_EDIT_PRIORITY = 100;\nexport const ANNOTATION_PLACE_PRIORITY = 95;\nexport const ANNOTATION_DRAW_PRIORITY = 55;\nexport const ANNOTATION_MARQUEE_PRIORITY = 50;\n","/**\n * @embedpdf/plugin-annotation/contract/host — the host lens: render\n * projections, sync, pointer routing, ghosts, the markup bridge and the\n * extension seams. Same runtime token as the public one, typed wider.\n */\nimport { createHostToken } from '@embedpdf/core';\nimport type { DocumentEvent, EventHook, PredictedOp, Unsubscribe } from '@embedpdf/core';\nimport type {\n ChromeNode,\n Effect,\n Id,\n Model,\n Rect,\n RenderItem,\n SceneNode,\n KindName,\n TextEndAnchor,\n Quad,\n Point,\n ViewEnv,\n} from '@embedpdf/core-annotation';\nimport type { Rotation } from '@embedpdf/core-geometry';\nimport type {\n AnnotationAppearanceImage,\n AnnotationPosition,\n AnnotationRef,\n ChangeOp,\n ImageSource,\n PageMeasurementViewport,\n PageRef,\n PdfMeasure,\n RichTextParagraph,\n SerializedEngineError,\n} from '@embedpdf/engine-core/runtime';\nimport type {\n AnnotationCommitEntry,\n AnnotationCommitResult,\n} from '@embedpdf/plugin-actions/contract/host';\nimport type { AppearancePicture } from '@embedpdf/plugin-render/contract/host';\n\nimport type {\n Annotation,\n AnnotationAnchor,\n AnnotationCapability,\n AnnotationSelectionAnchor,\n ArmedStampInfo,\n ArmedStampPreview,\n Behavior,\n LinkNavItem,\n TextItem,\n ImageGhost,\n} from './contract';\nimport { AnnotationToken as PublicAnnotationToken } from './token';\nimport type { ResolvedTool } from './tools/definitions';\n\nexport * from './contract';\nexport type { AnnotationModel } from './model';\nexport {\n ANNOTATION_DRAW_PRIORITY,\n ANNOTATION_EDIT_PRIORITY,\n ANNOTATION_MARQUEE_PRIORITY,\n ANNOTATION_PLACE_PRIORITY,\n} from './priorities';\n\n/**\n * One annotation's look at rest in one of its states, as the render layer\n * paints it: the engine's picture, or, while the annotation's create is on\n * its way, the one this device made (a placed stamp's preview), which the\n * engine's replaces. `version` is the record's picture version it shows\n * (`RenderItem.pictureVersion`): one drawn at another version shows another look.\n */\nexport interface AnnotationAppearancePicture extends Pick<\n AnnotationAppearanceImage,\n 'ref' | 'mode' | 'state' | 'rect'\n> {\n readonly image: ImageSource;\n readonly version: number;\n}\n\n/**\n * A sibling plugin that lends this plugin records it owns (the form plugin's\n * widgets), so they are selected, moved, resized, restyled and deleted with\n * the annotation tools. This plugin never stores them: it shows them as the\n * lender says, and an edit of one becomes the lender's ops, in the same change\n * as the rest of the edit.\n */\nexport interface AnnotationLender {\n /** Who owns the records, for a refusal that sends you there (`'form'`). */\n readonly owner: string;\n /**\n * Its records as the engine confirmed them and as they show, each list the\n * same object until it changes; `null` while it lends none.\n */\n records(): {\n readonly confirmed: readonly Annotation[];\n readonly shown: readonly Annotation[];\n } | null;\n /**\n * The ops that write a message's effects on its records, all at once:\n * `model` is the model the message left, `before` the one it started from\n * (a record it deleted is there).\n */\n opsOf(effects: readonly Effect[], model: Model, before: Model): readonly ChangeOp[];\n /** What undoing these ops looks like. */\n undoOf(ops: readonly ChangeOp[]): readonly PredictedOp[];\n /** The ops that move these records of one page to `position` in its drawing order. */\n reorderOps(\n page: PageRef,\n refs: readonly AnnotationRef[],\n position: AnnotationPosition,\n ): readonly ChangeOp[];\n /**\n * The ops that copy these records, as the lender copies its own (a form's\n * widgets: a radio button's copy joins its group, any other widget's is a\n * new field), each moved by `offset`, on `page` when one is named; and the\n * copies' refs, in the order of the records given. A record it leaves out\n * has no copy. Resolves once the object numbers the ops take are there.\n */\n copyOps(\n refs: readonly AnnotationRef[],\n placement: {\n readonly page?: PageRef;\n readonly offset?: { readonly x: number; readonly y: number };\n },\n ): Promise<{ readonly ops: readonly ChangeOp[]; readonly copies: readonly AnnotationRef[] }>;\n /** Whether this session may change, delete and copy the record. */\n getAuthority(record: Annotation): {\n readonly update: boolean;\n readonly delete: boolean;\n readonly copy: boolean;\n };\n /** What its records' pictures on a page depend on: a new value means new pictures. */\n getPictureEpoch(page: PageRef): string;\n /** A record's confirmed picture version; kept for one that went, so an undo brings it back with it. */\n getPictureVersion(record: AnnotationRef): number;\n /**\n * The record's look as it shows isn't its confirmed look yet, whatever changed it (a restyle,\n * a resize, one just placed, a change the lender made itself): it draws live, by its\n * {@link painter}, until the engine's picture of it is there.\n */\n isPending(record: AnnotationRef): boolean;\n /**\n * How the lender draws the record live: the record upright in `box` (its box, or where a\n * gesture has it), in page space; `null` for one it doesn't draw. A record with a painter\n * draws live while a gesture reshapes it, as a square does.\n */\n painter(record: Annotation): ((box: Rect) => readonly SceneNode[]) | null;\n /** Its records' pictures on a page, at rest, in every state, each with its record's picture version. */\n renderAppearances(\n page: PageRef,\n scale: number,\n signal?: AbortSignal,\n ): Promise<readonly AppearancePicture[]>;\n}\n\nexport interface RecalibrationReport {\n page: PageRef;\n scale: PdfMeasure;\n /** Page-wide read failure: no complete annotation set was available to recalculate. */\n error?: SerializedEngineError;\n updated: AnnotationRef[];\n skipped: {\n ref: AnnotationRef;\n reason: 'no-authority' | 'locked' | 'foreign-measure' | 'unavailable';\n }[];\n failed: { ref: AnnotationRef; error: SerializedEngineError }[];\n}\n\nexport interface CapturedAnnotationDraft {\n tool: string;\n page: PageRef;\n from: Point;\n to: Point;\n}\n\n/**\n * Ghost render buckets: powers of two from 128 px up to `cap`. The same policy\n * the page renderer uses — one bitmap per size class, never per zoom step.\n */\nexport function previewBucket(devicePixelWidth: number, maxWidth = 4096): number {\n const px = Math.max(128, Math.ceil(devicePixelWidth));\n return Math.min(maxWidth, 2 ** Math.ceil(Math.log2(px)));\n}\n\n/**\n * The host (framework) surface: everything the render layer, the interaction hub,\n * and sibling plugins need, on top of the public {@link AnnotationCapability}.\n * Host-only: sibling plugins and framework adapters import the token from\n * `@embedpdf/plugin-annotation/contract/host`. Never use it from application code.\n */\nexport interface AnnotationHostCapability extends AnnotationCapability {\n // ── measurement seam ──\n setPageViewports(\n page: PageRef,\n viewports: PageMeasurementViewport[] | undefined,\n fallback: PdfMeasure,\n ): void;\n /**\n * Resolves once the document's measurements can be re-measured: the\n * annotations loaded (a failed load retried) and every pending load settled.\n */\n whenRemeasurable(): Promise<void>;\n /**\n * Stage the update of every measurement on `page` to `scale`, at once, so a\n * group (`ctx.changes.group`) takes it into its change. What it staged is\n * `updated`; a refused change refuses all of it. `error` is set, and\n * nothing staged, when the annotations aren't loaded.\n */\n stageRemeasure(page: PageRef, scale: PdfMeasure): RecalibrationReport;\n /** A distance draft was captured (the measurement plugin turns it into a calibration). */\n readonly onDraftCaptured: EventHook<CapturedAnnotationDraft>;\n getDistanceCreationPage(): PageRef | null;\n\n // ── render projections (page space; a view env projects for a rotated / zoomed view) ──\n /**\n * The selection's anchor as a page shows it: its rotation handle where the\n * page's view puts it (screen-sized, so it depends on the zoom), for a menu\n * that stays clear of it. `selection.getAnchor()` is the same without a view.\n */\n getSelectionAnchorIn(view: {\n scale?: number;\n rotation?: Rotation;\n zoom?: number;\n }): AnnotationSelectionAnchor | null;\n /**\n * Where UI attaches to one annotation (its page and the box around what it\n * shows, a drag in progress included), or `null` for one that isn't here.\n * Without a view, an annotation that keeps its size on screen carries\n * `boundsIn` for the view it's shown in.\n */\n getAnnotationAnchor(ref: AnnotationRef, view?: ViewEnv): AnnotationAnchor | null;\n listPageItems(page: PageRef, view?: ViewEnv): RenderItem[];\n /**\n * The text boxes the layer draws as elements: the ones typed in or redrawn\n * live. A saved, idle one shows its engine picture instead.\n */\n listTextItems(page: PageRef, view?: ViewEnv): TextItem[];\n /**\n * One free text's text box in every state, saved and idle included: for a\n * renderer that draws the box itself (`useRichTextEditor`), which no\n * engine picture is drawn under. `null` for one that isn't a free text here.\n */\n getTextItem(ref: AnnotationRef, view?: ViewEnv): TextItem | null;\n listChromeNodes(page: PageRef, scale?: number, rotation?: Rotation, zoom?: number): ChromeNode[];\n listLinkItems(page: PageRef): LinkNavItem[];\n /**\n * What a page's pictures depend on: its baked records at their picture\n * versions, the stamps this session placed, the pictures kept for an undone\n * delete and the lender's widgets. Load the pictures again when it changes,\n * or when the appearance scale (`render.getAppearanceScale`) does.\n */\n getAppearanceEpoch(page: PageRef): string;\n /**\n * Every picture a page's annotations show at rest, in every state, each\n * with its record's picture version: the engine's (through the render\n * plugin; none without it), the lender's, and this session's placed stamps.\n */\n renderAppearances(\n page: PageRef,\n scale: number,\n signal?: AbortSignal,\n ): Promise<AnnotationAppearancePicture[]>;\n\n // ── sync ──\n /**\n * Resolves once the annotations mirror has applied every confirmed change\n * it knows of, including page re-reads that events started.\n */\n whenSynced(): Promise<void>;\n\n // ── text editing (the editor's draft path: shown at once, written after a pause) ──\n getEditingId(): Id | null;\n beginTextEditAt(\n page: PageRef,\n point: Point,\n scale?: number,\n rotation?: Rotation,\n zoom?: number,\n ): boolean;\n draftContents(ref: AnnotationRef, text: string): void;\n /** Returns the paragraphs it keeps: the text typed at the caret takes a style chosen there. */\n draftRichText(\n ref: AnnotationRef,\n doc: { paragraphs: RichTextParagraph[] },\n ): { paragraphs: RichTextParagraph[] };\n setTextSelection(ref: AnnotationRef, range: { start: number; end: number } | null): void;\n /**\n * The CSS family list a face is drawn with in a text box (`id`; `null` for\n * none yet): the font programs the engine draws it in, with the fonts\n * plugin installed.\n */\n getCssFontFamily(\n face: { family: string; weight: number; italic: boolean },\n id: string | null,\n ): string;\n /** The family a CSS family a text box was drawn with stands for, for text the browser drew itself. */\n getFamilyOfCss(cssFamily: string): string | undefined;\n\n // ── pointer routing ──\n getHitKind(\n page: PageRef,\n point: Point,\n scale?: number,\n rotation?: Rotation,\n zoom?: number,\n touch?: boolean,\n ): 'handle' | 'rotate' | 'group-handle' | 'annot' | 'empty';\n claimsTouchAt(\n page: PageRef,\n point: Point,\n scale?: number,\n rotation?: Rotation,\n zoom?: number,\n ): boolean;\n getCursorAt(\n page: PageRef,\n point: Point,\n scale?: number,\n rotation?: Rotation,\n zoom?: number,\n ): string | null;\n hoverAt(\n at: {\n page: PageRef;\n point: Point;\n scale?: number;\n rotation?: Rotation;\n zoom?: number;\n } | null,\n ): void;\n editPointer(\n phase: 'down' | 'move' | 'up',\n page: PageRef,\n point: Point,\n shift: boolean,\n scale?: number,\n rotation?: Rotation,\n zoom?: number,\n touch?: boolean,\n ): void;\n marqueePointer(\n phase: 'down' | 'move' | 'up',\n page: PageRef,\n point: Point,\n shift: boolean,\n scale?: number,\n rotation?: Rotation,\n zoom?: number,\n ): void;\n createPointer(\n tool: string,\n phase: 'down' | 'move' | 'up',\n page: PageRef,\n point: Point,\n finish?: boolean,\n displayRotation?: Rotation,\n ): void;\n finishInkDraft(): void;\n /** Place with the active tool at a click; `displayRotation` and `zoom` are the page's view there. */\n placeAt(page: PageRef, point: Point, displayRotation?: Rotation, zoom?: number): boolean;\n placeArmedStamp(page: PageRef, point: Point, displayRotation?: Rotation): boolean;\n requestStampAt(page: PageRef, point: Point, displayRotation?: Rotation): boolean;\n\n // ── markup bridge (the selection plugin meets the text tools) ──\n /**\n * Turn the text selection into what the tool makes of it (markup, a caret,\n * a replace-text pair) and clear the selection; `false`, and nothing, for a\n * tool that makes nothing of a selection, without create authority, or\n * without a selection.\n */\n applyToolToSelection(toolId: string): boolean;\n createMarkup(subtype: KindName, page: PageRef, quads: Quad[], preset?: string): void;\n createCaret(page: PageRef, anchor: TextEndAnchor): void;\n createReplaceText(page: PageRef, quads: Quad[], anchor: TextEndAnchor, preset?: string): void;\n previewMarkup(subtype: KindName, quadsByPage: Record<number, Quad[]>, preset?: string): void;\n clearMarkupPreview(): void;\n\n // ── ghosts and previews (tools/ghost.ts) ──\n /**\n * Put the tool's ghost at a hover, what a click there would make;\n * `displayRotation` and `zoom` are the page's view there. The handler that\n * would take the click calls it, only where the click would reach it and\n * the user may create; a tool without a ghost clears it.\n */\n hoverGhostAt(\n toolId: string,\n page: PageRef,\n point: Point,\n displayRotation?: Rotation,\n zoom?: number,\n ): void;\n clearGhost(): void;\n /**\n * A sibling plugin's placement gesture with one of this plugin's tools (the\n * form palette's drag-to-place): its press and the pointer now. Once it is a\n * drag, the page paints what releasing places; under that the tool's ghost\n * still shows the click.\n */\n previewPlacement(toolId: string, page: PageRef, from: Point, to: Point): void;\n clearPlacementPreview(): void;\n /** The armed stamp's ghost on a page, for the render layer's `<img>`. */\n getImageGhost(page: PageRef): ImageGhost | null;\n /** The armed stamp: a new object on every arm, null when nothing is armed. */\n getArmedStamp(): ArmedStampInfo | null;\n /** Render the armed stamp's ghost preview for a device pixel width (cached per size bucket). */\n renderArmedStampPreview(devicePixelWidth?: number): Promise<ArmedStampPreview | null>;\n\n // ── extension ──\n /**\n * Show a sibling's records with the annotations and edit them with the same\n * tools (see {@link AnnotationLender}). One lender at a time; returns the\n * release.\n */\n lend(lender: AnnotationLender): Unsubscribe;\n listResolvedTools(): ResolvedTool[];\n getResolvedTool(id: string): ResolvedTool | null;\n getToolSubtype(id: string): KindName;\n registerBehavior(behavior: Behavior): Unsubscribe;\n /** The engaged behavior that owns this annotation now, or `null`. */\n getBehaviorFor(annotation: Annotation): Behavior | null;\n pruneEngagedSelection(): void;\n commitScriptEffects(entries: AnnotationCommitEntry[]): Promise<AnnotationCommitResult>;\n}\n\n/**\n * The annotation capability token, typed to the full\n * {@link AnnotationHostCapability} (the package internals and `/contract/host`\n * use this view). The package root exports the same runtime token narrowed to\n * {@link AnnotationCapability}.\n */\nexport const AnnotationToken = createHostToken<AnnotationHostCapability>(PublicAnnotationToken);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAoBA,MAAa,2BAA2B;AACxC,MAAa,4BAA4B;AACzC,MAAa,2BAA2B;AACxC,MAAa,8BAA8B;;;;;;;;;;;;AC4J3C,SAAgB,cAAc,kBAA0B,WAAW,MAAc;CAE/E,OAAO,KAAK,IAAI,UAAU,KAAK,KAAK,KAAK,KAAK,KADnC,KAAK,IAAI,KAAK,KAAK,KAAK,gBAAgB,CACC,CAAC,CAAC,CAAC;AACzD;;;;;;;AAwPA,MAAa,mBAAA,GAAA,eAAA,gBAAA,CAA4DA,iBAAAA,eAAqB"}
|
|
1
|
+
{"version":3,"file":"host-contract-C7vx6wTQ.cjs","names":["PublicAnnotationToken"],"sources":["../src/priorities.ts","../src/host-contract.ts"],"sourcesContent":["/**\n * The interaction-hub priorities of the annotation plugin's handlers — the\n * public contract a sibling plugin builds on when it needs to sit above or\n * below one of them for the same gesture. Priority only breaks ties between\n * simultaneously-eligible handlers (the tool's tags decide eligibility).\n *\n * 100 annotation-edit select/move/resize over an existing annotation\n * 95 annotation-place click-to-place an armed payload on empty page space\n * 55 annotation-draw drag-create under a draw tool (below text-select)\n * 50 annotation-marquee empty-space selection, the final fallback\n *\n * Hover runs in the same order, so a handler's hover sees the cursor claims\n * of every handler above it: a create handler shows its tool's ghost only\n * where nothing above it claims the pointer (an annotation, text).\n *\n * A handler that must win a click over an existing annotation while a\n * placing tool is active (a signature mark dropped onto a signature field)\n * registers above {@link ANNOTATION_EDIT_PRIORITY}, not merely above place:\n * the edit handler captures first over any annotation, a widget included.\n */\nexport const ANNOTATION_EDIT_PRIORITY = 100;\nexport const ANNOTATION_PLACE_PRIORITY = 95;\nexport const ANNOTATION_DRAW_PRIORITY = 55;\nexport const ANNOTATION_MARQUEE_PRIORITY = 50;\n","/**\n * @embedpdf/plugin-annotation/contract/host — the host lens: render\n * projections, sync, pointer routing, ghosts, the markup bridge and the\n * extension seams. Same runtime token as the public one, typed wider.\n */\nimport { createHostToken } from '@embedpdf/core';\nimport type { DocumentEvent, EventHook, PredictedOp, Unsubscribe } from '@embedpdf/core';\nimport type {\n ChromeNode,\n Effect,\n Id,\n Model,\n RecordAccent,\n Rect,\n RenderItem,\n SceneNode,\n KindName,\n TextEndAnchor,\n Quad,\n Point,\n ViewEnv,\n} from '@embedpdf/core-annotation';\nimport type { Rotation } from '@embedpdf/core-geometry';\nimport type {\n AnnotationAppearanceImage,\n AnnotationPosition,\n AnnotationRef,\n ChangeOp,\n ImageSource,\n PageMeasurementViewport,\n PageRef,\n PdfMeasure,\n RichTextParagraph,\n SerializedEngineError,\n} from '@embedpdf/engine-core/runtime';\nimport type {\n AnnotationCommitEntry,\n AnnotationCommitResult,\n} from '@embedpdf/plugin-actions/contract/host';\nimport type { AppearancePicture } from '@embedpdf/plugin-render/contract/host';\n\nimport type {\n Annotation,\n AnnotationAnchor,\n AnnotationCapability,\n AnnotationSelectionAnchor,\n ArmedStampInfo,\n ArmedStampPreview,\n Behavior,\n LinkNavItem,\n TextItem,\n ImageGhost,\n} from './contract';\nimport { AnnotationToken as PublicAnnotationToken } from './token';\nimport type { ResolvedTool } from './tools/definitions';\n\nexport * from './contract';\nexport type { AnnotationModel } from './model';\nexport {\n ANNOTATION_DRAW_PRIORITY,\n ANNOTATION_EDIT_PRIORITY,\n ANNOTATION_MARQUEE_PRIORITY,\n ANNOTATION_PLACE_PRIORITY,\n} from './priorities';\n\n/**\n * One annotation's look at rest in one of its states, as the render layer\n * paints it: the engine's picture, or, while the annotation's create is on\n * its way, the one this device made (a placed stamp's preview), which the\n * engine's replaces. `version` is the record's picture version it shows\n * (`RenderItem.pictureVersion`): one drawn at another version shows another look.\n */\nexport interface AnnotationAppearancePicture extends Pick<\n AnnotationAppearanceImage,\n 'ref' | 'mode' | 'state' | 'rect'\n> {\n readonly image: ImageSource;\n readonly version: number;\n}\n\n/**\n * A sibling plugin that lends this plugin records it owns (the form plugin's\n * widgets), so they are selected, moved, resized, restyled and deleted with\n * the annotation tools. This plugin never stores them: it shows them as the\n * lender says, and an edit of one becomes the lender's ops, in the same change\n * as the rest of the edit.\n */\nexport interface AnnotationLender {\n /** Who owns the records, for a refusal that sends you there (`'form'`). */\n readonly owner: string;\n /**\n * Its records as the engine confirmed them and as they show, each list the\n * same object until it changes; `null` while it lends none.\n */\n records(): {\n readonly confirmed: readonly Annotation[];\n readonly shown: readonly Annotation[];\n } | null;\n /**\n * The ops that write a message's effects on its records, all at once:\n * `model` is the model the message left, `before` the one it started from\n * (a record it deleted is there).\n */\n opsOf(effects: readonly Effect[], model: Model, before: Model): readonly ChangeOp[];\n /** What undoing these ops looks like. */\n undoOf(ops: readonly ChangeOp[]): readonly PredictedOp[];\n /** The ops that move these records of one page to `position` in its drawing order. */\n reorderOps(\n page: PageRef,\n refs: readonly AnnotationRef[],\n position: AnnotationPosition,\n ): readonly ChangeOp[];\n /**\n * The ops that copy these records, as the lender copies its own (a form's\n * widgets: a radio button's copy joins its group, any other widget's is a\n * new field), each moved by `offset`, on `page` when one is named; and the\n * copies' refs, in the order of the records given. A record it leaves out\n * has no copy. Resolves once the object numbers the ops take are there.\n */\n copyOps(\n refs: readonly AnnotationRef[],\n placement: {\n readonly page?: PageRef;\n readonly offset?: { readonly x: number; readonly y: number };\n },\n ): Promise<{ readonly ops: readonly ChangeOp[]; readonly copies: readonly AnnotationRef[] }>;\n /** Whether this session may change, delete and copy the record. */\n getAuthority(record: Annotation): {\n readonly update: boolean;\n readonly delete: boolean;\n readonly copy: boolean;\n };\n /** What its records' pictures on a page depend on: a new value means new pictures. */\n getPictureEpoch(page: PageRef): string;\n /** A record's confirmed picture version; kept for one that went, so an undo brings it back with it. */\n getPictureVersion(record: AnnotationRef): number;\n /**\n * The record's look as it shows isn't its confirmed look yet, whatever changed it (a restyle,\n * a resize, one just placed, a change the lender made itself): it draws live, by its\n * {@link painter}, until the engine's picture of it is there.\n */\n isPending(record: AnnotationRef): boolean;\n /**\n * How the lender draws the record live: the record upright in `box` (its box, or where a\n * gesture has it), in page space; `null` for one it doesn't draw. A record with a painter\n * draws live while a gesture reshapes it, as a square does.\n */\n painter(record: Annotation): ((box: Rect) => readonly SceneNode[]) | null;\n /**\n * The color a record shows in beside its own look, and how strong (a form field's group's);\n * `null` for a record without one. Read again whenever {@link records} hands out a new object.\n */\n accentOf?(record: Annotation): RecordAccent | null;\n /** Its records' pictures on a page, at rest, in every state, each with its record's picture version. */\n renderAppearances(\n page: PageRef,\n scale: number,\n signal?: AbortSignal,\n ): Promise<readonly AppearancePicture[]>;\n}\n\nexport interface RecalibrationReport {\n page: PageRef;\n scale: PdfMeasure;\n /** Page-wide read failure: no complete annotation set was available to recalculate. */\n error?: SerializedEngineError;\n updated: AnnotationRef[];\n skipped: {\n ref: AnnotationRef;\n reason: 'no-authority' | 'locked' | 'foreign-measure' | 'unavailable';\n }[];\n failed: { ref: AnnotationRef; error: SerializedEngineError }[];\n}\n\nexport interface CapturedAnnotationDraft {\n tool: string;\n page: PageRef;\n from: Point;\n to: Point;\n}\n\n/**\n * Ghost render buckets: powers of two from 128 px up to `cap`. The same policy\n * the page renderer uses — one bitmap per size class, never per zoom step.\n */\nexport function previewBucket(devicePixelWidth: number, maxWidth = 4096): number {\n const px = Math.max(128, Math.ceil(devicePixelWidth));\n return Math.min(maxWidth, 2 ** Math.ceil(Math.log2(px)));\n}\n\n/**\n * The host (framework) surface: everything the render layer, the interaction hub,\n * and sibling plugins need, on top of the public {@link AnnotationCapability}.\n * Host-only: sibling plugins and framework adapters import the token from\n * `@embedpdf/plugin-annotation/contract/host`. Never use it from application code.\n */\nexport interface AnnotationHostCapability extends AnnotationCapability {\n // ── measurement seam ──\n setPageViewports(\n page: PageRef,\n viewports: PageMeasurementViewport[] | undefined,\n fallback: PdfMeasure,\n ): void;\n /**\n * Resolves once the document's measurements can be re-measured: the\n * annotations loaded (a failed load retried) and every pending load settled.\n */\n whenRemeasurable(): Promise<void>;\n /**\n * Stage the update of every measurement on `page` to `scale`, at once, so a\n * group (`ctx.changes.group`) takes it into its change. What it staged is\n * `updated`; a refused change refuses all of it. `error` is set, and\n * nothing staged, when the annotations aren't loaded.\n */\n stageRemeasure(page: PageRef, scale: PdfMeasure): RecalibrationReport;\n /** A distance draft was captured (the measurement plugin turns it into a calibration). */\n readonly onDraftCaptured: EventHook<CapturedAnnotationDraft>;\n getDistanceCreationPage(): PageRef | null;\n /**\n * Whether a shape that is made click by click waits for its next click: a\n * polygon's or polyline's next corner, a callout's knee or box, a distance\n * line's placement. That click is the shape's, also where it lands on an\n * existing annotation.\n */\n hasCreationAwaitingClick(): boolean;\n\n // ── render projections (page space; a view env projects for a rotated / zoomed view) ──\n /**\n * The selection's anchor as a page shows it: its rotation handle where the\n * page's view puts it (screen-sized, so it depends on the zoom), for a menu\n * that stays clear of it. `selection.getAnchor()` is the same without a view.\n */\n getSelectionAnchorIn(view: {\n scale?: number;\n rotation?: Rotation;\n zoom?: number;\n }): AnnotationSelectionAnchor | null;\n /**\n * Where UI attaches to one annotation (its page and the box around what it\n * shows, a drag in progress included), or `null` for one that isn't here.\n * Without a view, an annotation that keeps its size on screen carries\n * `boundsIn` for the view it's shown in.\n */\n getAnnotationAnchor(ref: AnnotationRef, view?: ViewEnv): AnnotationAnchor | null;\n listPageItems(page: PageRef, view?: ViewEnv): RenderItem[];\n /**\n * The text boxes the layer draws as elements: the ones typed in or redrawn\n * live. A saved, idle one shows its engine picture instead.\n */\n listTextItems(page: PageRef, view?: ViewEnv): TextItem[];\n /**\n * One free text's text box in every state, saved and idle included: for a\n * renderer that draws the box itself (`useRichTextEditor`), which no\n * engine picture is drawn under. `null` for one that isn't a free text here.\n */\n getTextItem(ref: AnnotationRef, view?: ViewEnv): TextItem | null;\n listChromeNodes(page: PageRef, scale?: number, rotation?: Rotation, zoom?: number): ChromeNode[];\n listLinkItems(page: PageRef): LinkNavItem[];\n /**\n * What a page's pictures depend on: its baked records at their picture\n * versions, the stamps this session placed, the pictures kept for an undone\n * delete and the lender's widgets. Load the pictures again when it changes,\n * or when the appearance scale (`render.getAppearanceScale`) does.\n */\n getAppearanceEpoch(page: PageRef): string;\n /**\n * Every picture a page's annotations show at rest, in every state, each\n * with its record's picture version: the engine's (through the render\n * plugin; none without it), the lender's, and this session's placed stamps.\n */\n renderAppearances(\n page: PageRef,\n scale: number,\n signal?: AbortSignal,\n ): Promise<AnnotationAppearancePicture[]>;\n\n // ── sync ──\n /**\n * Resolves once the annotations mirror has applied every confirmed change\n * it knows of, including page re-reads that events started.\n */\n whenSynced(): Promise<void>;\n\n // ── text editing (the editor's draft path: shown at once, written after a pause) ──\n getEditingId(): Id | null;\n beginTextEditAt(\n page: PageRef,\n point: Point,\n scale?: number,\n rotation?: Rotation,\n zoom?: number,\n ): boolean;\n draftContents(ref: AnnotationRef, text: string): void;\n /** Returns the paragraphs it keeps: the text typed at the caret takes a style chosen there. */\n draftRichText(\n ref: AnnotationRef,\n doc: { paragraphs: RichTextParagraph[] },\n ): { paragraphs: RichTextParagraph[] };\n setTextSelection(ref: AnnotationRef, range: { start: number; end: number } | null): void;\n /**\n * The CSS family list a face is drawn with in a text box (`id`; `null` for\n * none yet): the font programs the engine draws it in, with the fonts\n * plugin installed.\n */\n getCssFontFamily(\n face: { family: string; weight: number; italic: boolean },\n id: string | null,\n ): string;\n /** The family a CSS family a text box was drawn with stands for, for text the browser drew itself. */\n getFamilyOfCss(cssFamily: string): string | undefined;\n\n // ── pointer routing ──\n getHitKind(\n page: PageRef,\n point: Point,\n scale?: number,\n rotation?: Rotation,\n zoom?: number,\n touch?: boolean,\n ): 'handle' | 'rotate' | 'group-handle' | 'annot' | 'empty';\n claimsTouchAt(\n page: PageRef,\n point: Point,\n scale?: number,\n rotation?: Rotation,\n zoom?: number,\n ): boolean;\n getCursorAt(\n page: PageRef,\n point: Point,\n scale?: number,\n rotation?: Rotation,\n zoom?: number,\n ): string | null;\n hoverAt(\n at: {\n page: PageRef;\n point: Point;\n scale?: number;\n rotation?: Rotation;\n zoom?: number;\n } | null,\n ): void;\n editPointer(\n phase: 'down' | 'move' | 'up',\n page: PageRef,\n point: Point,\n shift: boolean,\n scale?: number,\n rotation?: Rotation,\n zoom?: number,\n touch?: boolean,\n ): void;\n marqueePointer(\n phase: 'down' | 'move' | 'up',\n page: PageRef,\n point: Point,\n shift: boolean,\n scale?: number,\n rotation?: Rotation,\n zoom?: number,\n ): void;\n createPointer(\n tool: string,\n phase: 'down' | 'move' | 'up',\n page: PageRef,\n point: Point,\n finish?: boolean,\n displayRotation?: Rotation,\n ): void;\n /**\n * Make the pen drawing that waits for its next stroke an annotation now,\n * as its tool's `afterCreate` says. A stroke still being drawn is left alone.\n */\n finishInkDraft(): void;\n /** Place with the active tool at a click; `displayRotation` and `zoom` are the page's view there. */\n placeAt(page: PageRef, point: Point, displayRotation?: Rotation, zoom?: number): boolean;\n placeArmedStamp(page: PageRef, point: Point, displayRotation?: Rotation): boolean;\n requestStampAt(page: PageRef, point: Point, displayRotation?: Rotation): boolean;\n\n // ── markup bridge (the selection plugin meets the text tools) ──\n /**\n * Turn the text selection into what the tool makes of it (markup, a caret,\n * a replace-text pair) and clear the selection; `false`, and nothing, for a\n * tool that makes nothing of a selection, without create authority, or\n * without a selection.\n */\n applyToolToSelection(toolId: string): boolean;\n createMarkup(subtype: KindName, page: PageRef, quads: Quad[], preset?: string): void;\n createCaret(page: PageRef, anchor: TextEndAnchor): void;\n createReplaceText(page: PageRef, quads: Quad[], anchor: TextEndAnchor, preset?: string): void;\n previewMarkup(subtype: KindName, quadsByPage: Record<number, Quad[]>, preset?: string): void;\n clearMarkupPreview(): void;\n\n // ── ghosts and previews (tools/ghost.ts) ──\n /**\n * Put the tool's ghost at a hover, what a click there would make;\n * `displayRotation` and `zoom` are the page's view there. The handler that\n * would take the click calls it, only where the click would reach it and\n * the user may create; a tool without a ghost clears it.\n */\n hoverGhostAt(\n toolId: string,\n page: PageRef,\n point: Point,\n displayRotation?: Rotation,\n zoom?: number,\n ): void;\n clearGhost(): void;\n /**\n * A sibling plugin's placement gesture with one of this plugin's tools (the\n * form palette's drag-to-place): its press and the pointer now, and\n * `displayRotation`, the page's view at the press, which an upright tool\n * lays its drag out by. Once it is a drag, the page paints what releasing\n * places; under that the tool's ghost still shows the click.\n */\n previewPlacement(\n toolId: string,\n page: PageRef,\n from: Point,\n to: Point,\n displayRotation?: Rotation,\n ): void;\n clearPlacementPreview(): void;\n /** The armed stamp's ghost on a page, for the render layer's `<img>`. */\n getImageGhost(page: PageRef): ImageGhost | null;\n /** The armed stamp: a new object on every arm, null when nothing is armed. */\n getArmedStamp(): ArmedStampInfo | null;\n /** Render the armed stamp's ghost preview for a device pixel width (cached per size bucket). */\n renderArmedStampPreview(devicePixelWidth?: number): Promise<ArmedStampPreview | null>;\n\n // ── extension ──\n /**\n * Show a sibling's records with the annotations and edit them with the same\n * tools (see {@link AnnotationLender}). One lender at a time; returns the\n * release.\n */\n lend(lender: AnnotationLender): Unsubscribe;\n listResolvedTools(): ResolvedTool[];\n getResolvedTool(id: string): ResolvedTool | null;\n getToolSubtype(id: string): KindName;\n registerBehavior(behavior: Behavior): Unsubscribe;\n /** The engaged behavior that owns this annotation now, or `null`. */\n getBehaviorFor(annotation: Annotation): Behavior | null;\n pruneEngagedSelection(): void;\n commitScriptEffects(entries: AnnotationCommitEntry[]): Promise<AnnotationCommitResult>;\n}\n\n/**\n * The annotation capability token, typed to the full\n * {@link AnnotationHostCapability} (the package internals and `/contract/host`\n * use this view). The package root exports the same runtime token narrowed to\n * {@link AnnotationCapability}.\n */\nexport const AnnotationToken = createHostToken<AnnotationHostCapability>(PublicAnnotationToken);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAoBA,MAAa,2BAA2B;AACxC,MAAa,4BAA4B;AACzC,MAAa,2BAA2B;AACxC,MAAa,8BAA8B;;;;;;;;;;;;ACkK3C,SAAgB,cAAc,kBAA0B,WAAW,MAAc;CAE/E,OAAO,KAAK,IAAI,UAAU,KAAK,KAAK,KAAK,KAAK,KADnC,KAAK,IAAI,KAAK,KAAK,KAAK,gBAAgB,CACC,CAAC,CAAC,CAAC;AACzD;;;;;;;AA0QA,MAAa,mBAAA,GAAA,eAAA,gBAAA,CAA4DA,iBAAAA,eAAqB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host-contract-CDp5skzD.js","names":["PublicAnnotationToken"],"sources":["../src/priorities.ts","../src/host-contract.ts"],"sourcesContent":["/**\n * The interaction-hub priorities of the annotation plugin's handlers — the\n * public contract a sibling plugin builds on when it needs to sit above or\n * below one of them for the same gesture. Priority only breaks ties between\n * simultaneously-eligible handlers (the tool's tags decide eligibility).\n *\n * 100 annotation-edit select/move/resize over an existing annotation\n * 95 annotation-place click-to-place an armed payload on empty page space\n * 55 annotation-draw drag-create under a draw tool (below text-select)\n * 50 annotation-marquee empty-space selection, the final fallback\n *\n * Hover runs in the same order, so a handler's hover sees the cursor claims\n * of every handler above it: a create handler shows its tool's ghost only\n * where nothing above it claims the pointer (an annotation, text).\n *\n * A handler that must win a click over an existing annotation while a\n * placing tool is active (a signature mark dropped onto a signature field)\n * registers above {@link ANNOTATION_EDIT_PRIORITY}, not merely above place:\n * the edit handler captures first over any annotation, a widget included.\n */\nexport const ANNOTATION_EDIT_PRIORITY = 100;\nexport const ANNOTATION_PLACE_PRIORITY = 95;\nexport const ANNOTATION_DRAW_PRIORITY = 55;\nexport const ANNOTATION_MARQUEE_PRIORITY = 50;\n","/**\n * @embedpdf/plugin-annotation/contract/host — the host lens: render\n * projections, sync, pointer routing, ghosts, the markup bridge and the\n * extension seams. Same runtime token as the public one, typed wider.\n */\nimport { createHostToken } from '@embedpdf/core';\nimport type { DocumentEvent, EventHook, PredictedOp, Unsubscribe } from '@embedpdf/core';\nimport type {\n ChromeNode,\n Effect,\n Id,\n Model,\n Rect,\n RenderItem,\n SceneNode,\n KindName,\n TextEndAnchor,\n Quad,\n Point,\n ViewEnv,\n} from '@embedpdf/core-annotation';\nimport type { Rotation } from '@embedpdf/core-geometry';\nimport type {\n AnnotationAppearanceImage,\n AnnotationPosition,\n AnnotationRef,\n ChangeOp,\n ImageSource,\n PageMeasurementViewport,\n PageRef,\n PdfMeasure,\n RichTextParagraph,\n SerializedEngineError,\n} from '@embedpdf/engine-core/runtime';\nimport type {\n AnnotationCommitEntry,\n AnnotationCommitResult,\n} from '@embedpdf/plugin-actions/contract/host';\nimport type { AppearancePicture } from '@embedpdf/plugin-render/contract/host';\n\nimport type {\n Annotation,\n AnnotationAnchor,\n AnnotationCapability,\n AnnotationSelectionAnchor,\n ArmedStampInfo,\n ArmedStampPreview,\n Behavior,\n LinkNavItem,\n TextItem,\n ImageGhost,\n} from './contract';\nimport { AnnotationToken as PublicAnnotationToken } from './token';\nimport type { ResolvedTool } from './tools/definitions';\n\nexport * from './contract';\nexport type { AnnotationModel } from './model';\nexport {\n ANNOTATION_DRAW_PRIORITY,\n ANNOTATION_EDIT_PRIORITY,\n ANNOTATION_MARQUEE_PRIORITY,\n ANNOTATION_PLACE_PRIORITY,\n} from './priorities';\n\n/**\n * One annotation's look at rest in one of its states, as the render layer\n * paints it: the engine's picture, or, while the annotation's create is on\n * its way, the one this device made (a placed stamp's preview), which the\n * engine's replaces. `version` is the record's picture version it shows\n * (`RenderItem.pictureVersion`): one drawn at another version shows another look.\n */\nexport interface AnnotationAppearancePicture extends Pick<\n AnnotationAppearanceImage,\n 'ref' | 'mode' | 'state' | 'rect'\n> {\n readonly image: ImageSource;\n readonly version: number;\n}\n\n/**\n * A sibling plugin that lends this plugin records it owns (the form plugin's\n * widgets), so they are selected, moved, resized, restyled and deleted with\n * the annotation tools. This plugin never stores them: it shows them as the\n * lender says, and an edit of one becomes the lender's ops, in the same change\n * as the rest of the edit.\n */\nexport interface AnnotationLender {\n /** Who owns the records, for a refusal that sends you there (`'form'`). */\n readonly owner: string;\n /**\n * Its records as the engine confirmed them and as they show, each list the\n * same object until it changes; `null` while it lends none.\n */\n records(): {\n readonly confirmed: readonly Annotation[];\n readonly shown: readonly Annotation[];\n } | null;\n /**\n * The ops that write a message's effects on its records, all at once:\n * `model` is the model the message left, `before` the one it started from\n * (a record it deleted is there).\n */\n opsOf(effects: readonly Effect[], model: Model, before: Model): readonly ChangeOp[];\n /** What undoing these ops looks like. */\n undoOf(ops: readonly ChangeOp[]): readonly PredictedOp[];\n /** The ops that move these records of one page to `position` in its drawing order. */\n reorderOps(\n page: PageRef,\n refs: readonly AnnotationRef[],\n position: AnnotationPosition,\n ): readonly ChangeOp[];\n /**\n * The ops that copy these records, as the lender copies its own (a form's\n * widgets: a radio button's copy joins its group, any other widget's is a\n * new field), each moved by `offset`, on `page` when one is named; and the\n * copies' refs, in the order of the records given. A record it leaves out\n * has no copy. Resolves once the object numbers the ops take are there.\n */\n copyOps(\n refs: readonly AnnotationRef[],\n placement: {\n readonly page?: PageRef;\n readonly offset?: { readonly x: number; readonly y: number };\n },\n ): Promise<{ readonly ops: readonly ChangeOp[]; readonly copies: readonly AnnotationRef[] }>;\n /** Whether this session may change, delete and copy the record. */\n getAuthority(record: Annotation): {\n readonly update: boolean;\n readonly delete: boolean;\n readonly copy: boolean;\n };\n /** What its records' pictures on a page depend on: a new value means new pictures. */\n getPictureEpoch(page: PageRef): string;\n /** A record's confirmed picture version; kept for one that went, so an undo brings it back with it. */\n getPictureVersion(record: AnnotationRef): number;\n /**\n * The record's look as it shows isn't its confirmed look yet, whatever changed it (a restyle,\n * a resize, one just placed, a change the lender made itself): it draws live, by its\n * {@link painter}, until the engine's picture of it is there.\n */\n isPending(record: AnnotationRef): boolean;\n /**\n * How the lender draws the record live: the record upright in `box` (its box, or where a\n * gesture has it), in page space; `null` for one it doesn't draw. A record with a painter\n * draws live while a gesture reshapes it, as a square does.\n */\n painter(record: Annotation): ((box: Rect) => readonly SceneNode[]) | null;\n /** Its records' pictures on a page, at rest, in every state, each with its record's picture version. */\n renderAppearances(\n page: PageRef,\n scale: number,\n signal?: AbortSignal,\n ): Promise<readonly AppearancePicture[]>;\n}\n\nexport interface RecalibrationReport {\n page: PageRef;\n scale: PdfMeasure;\n /** Page-wide read failure: no complete annotation set was available to recalculate. */\n error?: SerializedEngineError;\n updated: AnnotationRef[];\n skipped: {\n ref: AnnotationRef;\n reason: 'no-authority' | 'locked' | 'foreign-measure' | 'unavailable';\n }[];\n failed: { ref: AnnotationRef; error: SerializedEngineError }[];\n}\n\nexport interface CapturedAnnotationDraft {\n tool: string;\n page: PageRef;\n from: Point;\n to: Point;\n}\n\n/**\n * Ghost render buckets: powers of two from 128 px up to `cap`. The same policy\n * the page renderer uses — one bitmap per size class, never per zoom step.\n */\nexport function previewBucket(devicePixelWidth: number, maxWidth = 4096): number {\n const px = Math.max(128, Math.ceil(devicePixelWidth));\n return Math.min(maxWidth, 2 ** Math.ceil(Math.log2(px)));\n}\n\n/**\n * The host (framework) surface: everything the render layer, the interaction hub,\n * and sibling plugins need, on top of the public {@link AnnotationCapability}.\n * Host-only: sibling plugins and framework adapters import the token from\n * `@embedpdf/plugin-annotation/contract/host`. Never use it from application code.\n */\nexport interface AnnotationHostCapability extends AnnotationCapability {\n // ── measurement seam ──\n setPageViewports(\n page: PageRef,\n viewports: PageMeasurementViewport[] | undefined,\n fallback: PdfMeasure,\n ): void;\n /**\n * Resolves once the document's measurements can be re-measured: the\n * annotations loaded (a failed load retried) and every pending load settled.\n */\n whenRemeasurable(): Promise<void>;\n /**\n * Stage the update of every measurement on `page` to `scale`, at once, so a\n * group (`ctx.changes.group`) takes it into its change. What it staged is\n * `updated`; a refused change refuses all of it. `error` is set, and\n * nothing staged, when the annotations aren't loaded.\n */\n stageRemeasure(page: PageRef, scale: PdfMeasure): RecalibrationReport;\n /** A distance draft was captured (the measurement plugin turns it into a calibration). */\n readonly onDraftCaptured: EventHook<CapturedAnnotationDraft>;\n getDistanceCreationPage(): PageRef | null;\n\n // ── render projections (page space; a view env projects for a rotated / zoomed view) ──\n /**\n * The selection's anchor as a page shows it: its rotation handle where the\n * page's view puts it (screen-sized, so it depends on the zoom), for a menu\n * that stays clear of it. `selection.getAnchor()` is the same without a view.\n */\n getSelectionAnchorIn(view: {\n scale?: number;\n rotation?: Rotation;\n zoom?: number;\n }): AnnotationSelectionAnchor | null;\n /**\n * Where UI attaches to one annotation (its page and the box around what it\n * shows, a drag in progress included), or `null` for one that isn't here.\n * Without a view, an annotation that keeps its size on screen carries\n * `boundsIn` for the view it's shown in.\n */\n getAnnotationAnchor(ref: AnnotationRef, view?: ViewEnv): AnnotationAnchor | null;\n listPageItems(page: PageRef, view?: ViewEnv): RenderItem[];\n /**\n * The text boxes the layer draws as elements: the ones typed in or redrawn\n * live. A saved, idle one shows its engine picture instead.\n */\n listTextItems(page: PageRef, view?: ViewEnv): TextItem[];\n /**\n * One free text's text box in every state, saved and idle included: for a\n * renderer that draws the box itself (`useRichTextEditor`), which no\n * engine picture is drawn under. `null` for one that isn't a free text here.\n */\n getTextItem(ref: AnnotationRef, view?: ViewEnv): TextItem | null;\n listChromeNodes(page: PageRef, scale?: number, rotation?: Rotation, zoom?: number): ChromeNode[];\n listLinkItems(page: PageRef): LinkNavItem[];\n /**\n * What a page's pictures depend on: its baked records at their picture\n * versions, the stamps this session placed, the pictures kept for an undone\n * delete and the lender's widgets. Load the pictures again when it changes,\n * or when the appearance scale (`render.getAppearanceScale`) does.\n */\n getAppearanceEpoch(page: PageRef): string;\n /**\n * Every picture a page's annotations show at rest, in every state, each\n * with its record's picture version: the engine's (through the render\n * plugin; none without it), the lender's, and this session's placed stamps.\n */\n renderAppearances(\n page: PageRef,\n scale: number,\n signal?: AbortSignal,\n ): Promise<AnnotationAppearancePicture[]>;\n\n // ── sync ──\n /**\n * Resolves once the annotations mirror has applied every confirmed change\n * it knows of, including page re-reads that events started.\n */\n whenSynced(): Promise<void>;\n\n // ── text editing (the editor's draft path: shown at once, written after a pause) ──\n getEditingId(): Id | null;\n beginTextEditAt(\n page: PageRef,\n point: Point,\n scale?: number,\n rotation?: Rotation,\n zoom?: number,\n ): boolean;\n draftContents(ref: AnnotationRef, text: string): void;\n /** Returns the paragraphs it keeps: the text typed at the caret takes a style chosen there. */\n draftRichText(\n ref: AnnotationRef,\n doc: { paragraphs: RichTextParagraph[] },\n ): { paragraphs: RichTextParagraph[] };\n setTextSelection(ref: AnnotationRef, range: { start: number; end: number } | null): void;\n /**\n * The CSS family list a face is drawn with in a text box (`id`; `null` for\n * none yet): the font programs the engine draws it in, with the fonts\n * plugin installed.\n */\n getCssFontFamily(\n face: { family: string; weight: number; italic: boolean },\n id: string | null,\n ): string;\n /** The family a CSS family a text box was drawn with stands for, for text the browser drew itself. */\n getFamilyOfCss(cssFamily: string): string | undefined;\n\n // ── pointer routing ──\n getHitKind(\n page: PageRef,\n point: Point,\n scale?: number,\n rotation?: Rotation,\n zoom?: number,\n touch?: boolean,\n ): 'handle' | 'rotate' | 'group-handle' | 'annot' | 'empty';\n claimsTouchAt(\n page: PageRef,\n point: Point,\n scale?: number,\n rotation?: Rotation,\n zoom?: number,\n ): boolean;\n getCursorAt(\n page: PageRef,\n point: Point,\n scale?: number,\n rotation?: Rotation,\n zoom?: number,\n ): string | null;\n hoverAt(\n at: {\n page: PageRef;\n point: Point;\n scale?: number;\n rotation?: Rotation;\n zoom?: number;\n } | null,\n ): void;\n editPointer(\n phase: 'down' | 'move' | 'up',\n page: PageRef,\n point: Point,\n shift: boolean,\n scale?: number,\n rotation?: Rotation,\n zoom?: number,\n touch?: boolean,\n ): void;\n marqueePointer(\n phase: 'down' | 'move' | 'up',\n page: PageRef,\n point: Point,\n shift: boolean,\n scale?: number,\n rotation?: Rotation,\n zoom?: number,\n ): void;\n createPointer(\n tool: string,\n phase: 'down' | 'move' | 'up',\n page: PageRef,\n point: Point,\n finish?: boolean,\n displayRotation?: Rotation,\n ): void;\n finishInkDraft(): void;\n /** Place with the active tool at a click; `displayRotation` and `zoom` are the page's view there. */\n placeAt(page: PageRef, point: Point, displayRotation?: Rotation, zoom?: number): boolean;\n placeArmedStamp(page: PageRef, point: Point, displayRotation?: Rotation): boolean;\n requestStampAt(page: PageRef, point: Point, displayRotation?: Rotation): boolean;\n\n // ── markup bridge (the selection plugin meets the text tools) ──\n /**\n * Turn the text selection into what the tool makes of it (markup, a caret,\n * a replace-text pair) and clear the selection; `false`, and nothing, for a\n * tool that makes nothing of a selection, without create authority, or\n * without a selection.\n */\n applyToolToSelection(toolId: string): boolean;\n createMarkup(subtype: KindName, page: PageRef, quads: Quad[], preset?: string): void;\n createCaret(page: PageRef, anchor: TextEndAnchor): void;\n createReplaceText(page: PageRef, quads: Quad[], anchor: TextEndAnchor, preset?: string): void;\n previewMarkup(subtype: KindName, quadsByPage: Record<number, Quad[]>, preset?: string): void;\n clearMarkupPreview(): void;\n\n // ── ghosts and previews (tools/ghost.ts) ──\n /**\n * Put the tool's ghost at a hover, what a click there would make;\n * `displayRotation` and `zoom` are the page's view there. The handler that\n * would take the click calls it, only where the click would reach it and\n * the user may create; a tool without a ghost clears it.\n */\n hoverGhostAt(\n toolId: string,\n page: PageRef,\n point: Point,\n displayRotation?: Rotation,\n zoom?: number,\n ): void;\n clearGhost(): void;\n /**\n * A sibling plugin's placement gesture with one of this plugin's tools (the\n * form palette's drag-to-place): its press and the pointer now. Once it is a\n * drag, the page paints what releasing places; under that the tool's ghost\n * still shows the click.\n */\n previewPlacement(toolId: string, page: PageRef, from: Point, to: Point): void;\n clearPlacementPreview(): void;\n /** The armed stamp's ghost on a page, for the render layer's `<img>`. */\n getImageGhost(page: PageRef): ImageGhost | null;\n /** The armed stamp: a new object on every arm, null when nothing is armed. */\n getArmedStamp(): ArmedStampInfo | null;\n /** Render the armed stamp's ghost preview for a device pixel width (cached per size bucket). */\n renderArmedStampPreview(devicePixelWidth?: number): Promise<ArmedStampPreview | null>;\n\n // ── extension ──\n /**\n * Show a sibling's records with the annotations and edit them with the same\n * tools (see {@link AnnotationLender}). One lender at a time; returns the\n * release.\n */\n lend(lender: AnnotationLender): Unsubscribe;\n listResolvedTools(): ResolvedTool[];\n getResolvedTool(id: string): ResolvedTool | null;\n getToolSubtype(id: string): KindName;\n registerBehavior(behavior: Behavior): Unsubscribe;\n /** The engaged behavior that owns this annotation now, or `null`. */\n getBehaviorFor(annotation: Annotation): Behavior | null;\n pruneEngagedSelection(): void;\n commitScriptEffects(entries: AnnotationCommitEntry[]): Promise<AnnotationCommitResult>;\n}\n\n/**\n * The annotation capability token, typed to the full\n * {@link AnnotationHostCapability} (the package internals and `/contract/host`\n * use this view). The package root exports the same runtime token narrowed to\n * {@link AnnotationCapability}.\n */\nexport const AnnotationToken = createHostToken<AnnotationHostCapability>(PublicAnnotationToken);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAoBA,MAAa,2BAA2B;AACxC,MAAa,4BAA4B;AACzC,MAAa,2BAA2B;AACxC,MAAa,8BAA8B;;;;;;;;;;;;AC4J3C,SAAgB,cAAc,kBAA0B,WAAW,MAAc;CAE/E,OAAO,KAAK,IAAI,UAAU,KAAK,KAAK,KAAK,KAAK,KADnC,KAAK,IAAI,KAAK,KAAK,KAAK,gBAAgB,CACC,CAAC,CAAC,CAAC;AACzD;;;;;;;AAwPA,MAAa,kBAAkB,gBAA0CA,iBAAqB"}
|
|
1
|
+
{"version":3,"file":"host-contract-CDp5skzD.js","names":["PublicAnnotationToken"],"sources":["../src/priorities.ts","../src/host-contract.ts"],"sourcesContent":["/**\n * The interaction-hub priorities of the annotation plugin's handlers — the\n * public contract a sibling plugin builds on when it needs to sit above or\n * below one of them for the same gesture. Priority only breaks ties between\n * simultaneously-eligible handlers (the tool's tags decide eligibility).\n *\n * 100 annotation-edit select/move/resize over an existing annotation\n * 95 annotation-place click-to-place an armed payload on empty page space\n * 55 annotation-draw drag-create under a draw tool (below text-select)\n * 50 annotation-marquee empty-space selection, the final fallback\n *\n * Hover runs in the same order, so a handler's hover sees the cursor claims\n * of every handler above it: a create handler shows its tool's ghost only\n * where nothing above it claims the pointer (an annotation, text).\n *\n * A handler that must win a click over an existing annotation while a\n * placing tool is active (a signature mark dropped onto a signature field)\n * registers above {@link ANNOTATION_EDIT_PRIORITY}, not merely above place:\n * the edit handler captures first over any annotation, a widget included.\n */\nexport const ANNOTATION_EDIT_PRIORITY = 100;\nexport const ANNOTATION_PLACE_PRIORITY = 95;\nexport const ANNOTATION_DRAW_PRIORITY = 55;\nexport const ANNOTATION_MARQUEE_PRIORITY = 50;\n","/**\n * @embedpdf/plugin-annotation/contract/host — the host lens: render\n * projections, sync, pointer routing, ghosts, the markup bridge and the\n * extension seams. Same runtime token as the public one, typed wider.\n */\nimport { createHostToken } from '@embedpdf/core';\nimport type { DocumentEvent, EventHook, PredictedOp, Unsubscribe } from '@embedpdf/core';\nimport type {\n ChromeNode,\n Effect,\n Id,\n Model,\n RecordAccent,\n Rect,\n RenderItem,\n SceneNode,\n KindName,\n TextEndAnchor,\n Quad,\n Point,\n ViewEnv,\n} from '@embedpdf/core-annotation';\nimport type { Rotation } from '@embedpdf/core-geometry';\nimport type {\n AnnotationAppearanceImage,\n AnnotationPosition,\n AnnotationRef,\n ChangeOp,\n ImageSource,\n PageMeasurementViewport,\n PageRef,\n PdfMeasure,\n RichTextParagraph,\n SerializedEngineError,\n} from '@embedpdf/engine-core/runtime';\nimport type {\n AnnotationCommitEntry,\n AnnotationCommitResult,\n} from '@embedpdf/plugin-actions/contract/host';\nimport type { AppearancePicture } from '@embedpdf/plugin-render/contract/host';\n\nimport type {\n Annotation,\n AnnotationAnchor,\n AnnotationCapability,\n AnnotationSelectionAnchor,\n ArmedStampInfo,\n ArmedStampPreview,\n Behavior,\n LinkNavItem,\n TextItem,\n ImageGhost,\n} from './contract';\nimport { AnnotationToken as PublicAnnotationToken } from './token';\nimport type { ResolvedTool } from './tools/definitions';\n\nexport * from './contract';\nexport type { AnnotationModel } from './model';\nexport {\n ANNOTATION_DRAW_PRIORITY,\n ANNOTATION_EDIT_PRIORITY,\n ANNOTATION_MARQUEE_PRIORITY,\n ANNOTATION_PLACE_PRIORITY,\n} from './priorities';\n\n/**\n * One annotation's look at rest in one of its states, as the render layer\n * paints it: the engine's picture, or, while the annotation's create is on\n * its way, the one this device made (a placed stamp's preview), which the\n * engine's replaces. `version` is the record's picture version it shows\n * (`RenderItem.pictureVersion`): one drawn at another version shows another look.\n */\nexport interface AnnotationAppearancePicture extends Pick<\n AnnotationAppearanceImage,\n 'ref' | 'mode' | 'state' | 'rect'\n> {\n readonly image: ImageSource;\n readonly version: number;\n}\n\n/**\n * A sibling plugin that lends this plugin records it owns (the form plugin's\n * widgets), so they are selected, moved, resized, restyled and deleted with\n * the annotation tools. This plugin never stores them: it shows them as the\n * lender says, and an edit of one becomes the lender's ops, in the same change\n * as the rest of the edit.\n */\nexport interface AnnotationLender {\n /** Who owns the records, for a refusal that sends you there (`'form'`). */\n readonly owner: string;\n /**\n * Its records as the engine confirmed them and as they show, each list the\n * same object until it changes; `null` while it lends none.\n */\n records(): {\n readonly confirmed: readonly Annotation[];\n readonly shown: readonly Annotation[];\n } | null;\n /**\n * The ops that write a message's effects on its records, all at once:\n * `model` is the model the message left, `before` the one it started from\n * (a record it deleted is there).\n */\n opsOf(effects: readonly Effect[], model: Model, before: Model): readonly ChangeOp[];\n /** What undoing these ops looks like. */\n undoOf(ops: readonly ChangeOp[]): readonly PredictedOp[];\n /** The ops that move these records of one page to `position` in its drawing order. */\n reorderOps(\n page: PageRef,\n refs: readonly AnnotationRef[],\n position: AnnotationPosition,\n ): readonly ChangeOp[];\n /**\n * The ops that copy these records, as the lender copies its own (a form's\n * widgets: a radio button's copy joins its group, any other widget's is a\n * new field), each moved by `offset`, on `page` when one is named; and the\n * copies' refs, in the order of the records given. A record it leaves out\n * has no copy. Resolves once the object numbers the ops take are there.\n */\n copyOps(\n refs: readonly AnnotationRef[],\n placement: {\n readonly page?: PageRef;\n readonly offset?: { readonly x: number; readonly y: number };\n },\n ): Promise<{ readonly ops: readonly ChangeOp[]; readonly copies: readonly AnnotationRef[] }>;\n /** Whether this session may change, delete and copy the record. */\n getAuthority(record: Annotation): {\n readonly update: boolean;\n readonly delete: boolean;\n readonly copy: boolean;\n };\n /** What its records' pictures on a page depend on: a new value means new pictures. */\n getPictureEpoch(page: PageRef): string;\n /** A record's confirmed picture version; kept for one that went, so an undo brings it back with it. */\n getPictureVersion(record: AnnotationRef): number;\n /**\n * The record's look as it shows isn't its confirmed look yet, whatever changed it (a restyle,\n * a resize, one just placed, a change the lender made itself): it draws live, by its\n * {@link painter}, until the engine's picture of it is there.\n */\n isPending(record: AnnotationRef): boolean;\n /**\n * How the lender draws the record live: the record upright in `box` (its box, or where a\n * gesture has it), in page space; `null` for one it doesn't draw. A record with a painter\n * draws live while a gesture reshapes it, as a square does.\n */\n painter(record: Annotation): ((box: Rect) => readonly SceneNode[]) | null;\n /**\n * The color a record shows in beside its own look, and how strong (a form field's group's);\n * `null` for a record without one. Read again whenever {@link records} hands out a new object.\n */\n accentOf?(record: Annotation): RecordAccent | null;\n /** Its records' pictures on a page, at rest, in every state, each with its record's picture version. */\n renderAppearances(\n page: PageRef,\n scale: number,\n signal?: AbortSignal,\n ): Promise<readonly AppearancePicture[]>;\n}\n\nexport interface RecalibrationReport {\n page: PageRef;\n scale: PdfMeasure;\n /** Page-wide read failure: no complete annotation set was available to recalculate. */\n error?: SerializedEngineError;\n updated: AnnotationRef[];\n skipped: {\n ref: AnnotationRef;\n reason: 'no-authority' | 'locked' | 'foreign-measure' | 'unavailable';\n }[];\n failed: { ref: AnnotationRef; error: SerializedEngineError }[];\n}\n\nexport interface CapturedAnnotationDraft {\n tool: string;\n page: PageRef;\n from: Point;\n to: Point;\n}\n\n/**\n * Ghost render buckets: powers of two from 128 px up to `cap`. The same policy\n * the page renderer uses — one bitmap per size class, never per zoom step.\n */\nexport function previewBucket(devicePixelWidth: number, maxWidth = 4096): number {\n const px = Math.max(128, Math.ceil(devicePixelWidth));\n return Math.min(maxWidth, 2 ** Math.ceil(Math.log2(px)));\n}\n\n/**\n * The host (framework) surface: everything the render layer, the interaction hub,\n * and sibling plugins need, on top of the public {@link AnnotationCapability}.\n * Host-only: sibling plugins and framework adapters import the token from\n * `@embedpdf/plugin-annotation/contract/host`. Never use it from application code.\n */\nexport interface AnnotationHostCapability extends AnnotationCapability {\n // ── measurement seam ──\n setPageViewports(\n page: PageRef,\n viewports: PageMeasurementViewport[] | undefined,\n fallback: PdfMeasure,\n ): void;\n /**\n * Resolves once the document's measurements can be re-measured: the\n * annotations loaded (a failed load retried) and every pending load settled.\n */\n whenRemeasurable(): Promise<void>;\n /**\n * Stage the update of every measurement on `page` to `scale`, at once, so a\n * group (`ctx.changes.group`) takes it into its change. What it staged is\n * `updated`; a refused change refuses all of it. `error` is set, and\n * nothing staged, when the annotations aren't loaded.\n */\n stageRemeasure(page: PageRef, scale: PdfMeasure): RecalibrationReport;\n /** A distance draft was captured (the measurement plugin turns it into a calibration). */\n readonly onDraftCaptured: EventHook<CapturedAnnotationDraft>;\n getDistanceCreationPage(): PageRef | null;\n /**\n * Whether a shape that is made click by click waits for its next click: a\n * polygon's or polyline's next corner, a callout's knee or box, a distance\n * line's placement. That click is the shape's, also where it lands on an\n * existing annotation.\n */\n hasCreationAwaitingClick(): boolean;\n\n // ── render projections (page space; a view env projects for a rotated / zoomed view) ──\n /**\n * The selection's anchor as a page shows it: its rotation handle where the\n * page's view puts it (screen-sized, so it depends on the zoom), for a menu\n * that stays clear of it. `selection.getAnchor()` is the same without a view.\n */\n getSelectionAnchorIn(view: {\n scale?: number;\n rotation?: Rotation;\n zoom?: number;\n }): AnnotationSelectionAnchor | null;\n /**\n * Where UI attaches to one annotation (its page and the box around what it\n * shows, a drag in progress included), or `null` for one that isn't here.\n * Without a view, an annotation that keeps its size on screen carries\n * `boundsIn` for the view it's shown in.\n */\n getAnnotationAnchor(ref: AnnotationRef, view?: ViewEnv): AnnotationAnchor | null;\n listPageItems(page: PageRef, view?: ViewEnv): RenderItem[];\n /**\n * The text boxes the layer draws as elements: the ones typed in or redrawn\n * live. A saved, idle one shows its engine picture instead.\n */\n listTextItems(page: PageRef, view?: ViewEnv): TextItem[];\n /**\n * One free text's text box in every state, saved and idle included: for a\n * renderer that draws the box itself (`useRichTextEditor`), which no\n * engine picture is drawn under. `null` for one that isn't a free text here.\n */\n getTextItem(ref: AnnotationRef, view?: ViewEnv): TextItem | null;\n listChromeNodes(page: PageRef, scale?: number, rotation?: Rotation, zoom?: number): ChromeNode[];\n listLinkItems(page: PageRef): LinkNavItem[];\n /**\n * What a page's pictures depend on: its baked records at their picture\n * versions, the stamps this session placed, the pictures kept for an undone\n * delete and the lender's widgets. Load the pictures again when it changes,\n * or when the appearance scale (`render.getAppearanceScale`) does.\n */\n getAppearanceEpoch(page: PageRef): string;\n /**\n * Every picture a page's annotations show at rest, in every state, each\n * with its record's picture version: the engine's (through the render\n * plugin; none without it), the lender's, and this session's placed stamps.\n */\n renderAppearances(\n page: PageRef,\n scale: number,\n signal?: AbortSignal,\n ): Promise<AnnotationAppearancePicture[]>;\n\n // ── sync ──\n /**\n * Resolves once the annotations mirror has applied every confirmed change\n * it knows of, including page re-reads that events started.\n */\n whenSynced(): Promise<void>;\n\n // ── text editing (the editor's draft path: shown at once, written after a pause) ──\n getEditingId(): Id | null;\n beginTextEditAt(\n page: PageRef,\n point: Point,\n scale?: number,\n rotation?: Rotation,\n zoom?: number,\n ): boolean;\n draftContents(ref: AnnotationRef, text: string): void;\n /** Returns the paragraphs it keeps: the text typed at the caret takes a style chosen there. */\n draftRichText(\n ref: AnnotationRef,\n doc: { paragraphs: RichTextParagraph[] },\n ): { paragraphs: RichTextParagraph[] };\n setTextSelection(ref: AnnotationRef, range: { start: number; end: number } | null): void;\n /**\n * The CSS family list a face is drawn with in a text box (`id`; `null` for\n * none yet): the font programs the engine draws it in, with the fonts\n * plugin installed.\n */\n getCssFontFamily(\n face: { family: string; weight: number; italic: boolean },\n id: string | null,\n ): string;\n /** The family a CSS family a text box was drawn with stands for, for text the browser drew itself. */\n getFamilyOfCss(cssFamily: string): string | undefined;\n\n // ── pointer routing ──\n getHitKind(\n page: PageRef,\n point: Point,\n scale?: number,\n rotation?: Rotation,\n zoom?: number,\n touch?: boolean,\n ): 'handle' | 'rotate' | 'group-handle' | 'annot' | 'empty';\n claimsTouchAt(\n page: PageRef,\n point: Point,\n scale?: number,\n rotation?: Rotation,\n zoom?: number,\n ): boolean;\n getCursorAt(\n page: PageRef,\n point: Point,\n scale?: number,\n rotation?: Rotation,\n zoom?: number,\n ): string | null;\n hoverAt(\n at: {\n page: PageRef;\n point: Point;\n scale?: number;\n rotation?: Rotation;\n zoom?: number;\n } | null,\n ): void;\n editPointer(\n phase: 'down' | 'move' | 'up',\n page: PageRef,\n point: Point,\n shift: boolean,\n scale?: number,\n rotation?: Rotation,\n zoom?: number,\n touch?: boolean,\n ): void;\n marqueePointer(\n phase: 'down' | 'move' | 'up',\n page: PageRef,\n point: Point,\n shift: boolean,\n scale?: number,\n rotation?: Rotation,\n zoom?: number,\n ): void;\n createPointer(\n tool: string,\n phase: 'down' | 'move' | 'up',\n page: PageRef,\n point: Point,\n finish?: boolean,\n displayRotation?: Rotation,\n ): void;\n /**\n * Make the pen drawing that waits for its next stroke an annotation now,\n * as its tool's `afterCreate` says. A stroke still being drawn is left alone.\n */\n finishInkDraft(): void;\n /** Place with the active tool at a click; `displayRotation` and `zoom` are the page's view there. */\n placeAt(page: PageRef, point: Point, displayRotation?: Rotation, zoom?: number): boolean;\n placeArmedStamp(page: PageRef, point: Point, displayRotation?: Rotation): boolean;\n requestStampAt(page: PageRef, point: Point, displayRotation?: Rotation): boolean;\n\n // ── markup bridge (the selection plugin meets the text tools) ──\n /**\n * Turn the text selection into what the tool makes of it (markup, a caret,\n * a replace-text pair) and clear the selection; `false`, and nothing, for a\n * tool that makes nothing of a selection, without create authority, or\n * without a selection.\n */\n applyToolToSelection(toolId: string): boolean;\n createMarkup(subtype: KindName, page: PageRef, quads: Quad[], preset?: string): void;\n createCaret(page: PageRef, anchor: TextEndAnchor): void;\n createReplaceText(page: PageRef, quads: Quad[], anchor: TextEndAnchor, preset?: string): void;\n previewMarkup(subtype: KindName, quadsByPage: Record<number, Quad[]>, preset?: string): void;\n clearMarkupPreview(): void;\n\n // ── ghosts and previews (tools/ghost.ts) ──\n /**\n * Put the tool's ghost at a hover, what a click there would make;\n * `displayRotation` and `zoom` are the page's view there. The handler that\n * would take the click calls it, only where the click would reach it and\n * the user may create; a tool without a ghost clears it.\n */\n hoverGhostAt(\n toolId: string,\n page: PageRef,\n point: Point,\n displayRotation?: Rotation,\n zoom?: number,\n ): void;\n clearGhost(): void;\n /**\n * A sibling plugin's placement gesture with one of this plugin's tools (the\n * form palette's drag-to-place): its press and the pointer now, and\n * `displayRotation`, the page's view at the press, which an upright tool\n * lays its drag out by. Once it is a drag, the page paints what releasing\n * places; under that the tool's ghost still shows the click.\n */\n previewPlacement(\n toolId: string,\n page: PageRef,\n from: Point,\n to: Point,\n displayRotation?: Rotation,\n ): void;\n clearPlacementPreview(): void;\n /** The armed stamp's ghost on a page, for the render layer's `<img>`. */\n getImageGhost(page: PageRef): ImageGhost | null;\n /** The armed stamp: a new object on every arm, null when nothing is armed. */\n getArmedStamp(): ArmedStampInfo | null;\n /** Render the armed stamp's ghost preview for a device pixel width (cached per size bucket). */\n renderArmedStampPreview(devicePixelWidth?: number): Promise<ArmedStampPreview | null>;\n\n // ── extension ──\n /**\n * Show a sibling's records with the annotations and edit them with the same\n * tools (see {@link AnnotationLender}). One lender at a time; returns the\n * release.\n */\n lend(lender: AnnotationLender): Unsubscribe;\n listResolvedTools(): ResolvedTool[];\n getResolvedTool(id: string): ResolvedTool | null;\n getToolSubtype(id: string): KindName;\n registerBehavior(behavior: Behavior): Unsubscribe;\n /** The engaged behavior that owns this annotation now, or `null`. */\n getBehaviorFor(annotation: Annotation): Behavior | null;\n pruneEngagedSelection(): void;\n commitScriptEffects(entries: AnnotationCommitEntry[]): Promise<AnnotationCommitResult>;\n}\n\n/**\n * The annotation capability token, typed to the full\n * {@link AnnotationHostCapability} (the package internals and `/contract/host`\n * use this view). The package root exports the same runtime token narrowed to\n * {@link AnnotationCapability}.\n */\nexport const AnnotationToken = createHostToken<AnnotationHostCapability>(PublicAnnotationToken);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAoBA,MAAa,2BAA2B;AACxC,MAAa,4BAA4B;AACzC,MAAa,2BAA2B;AACxC,MAAa,8BAA8B;;;;;;;;;;;;ACkK3C,SAAgB,cAAc,kBAA0B,WAAW,MAAc;CAE/E,OAAO,KAAK,IAAI,UAAU,KAAK,KAAK,KAAK,KAAK,KADnC,KAAK,IAAI,KAAK,KAAK,KAAK,gBAAgB,CACC,CAAC,CAAC,CAAC;AACzD;;;;;;;AA0QA,MAAa,kBAAkB,gBAA0CA,iBAAqB"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { F as AnnotationSelectionAnchor, J as ArmedStampPreview, Jt as EditorSelection, Ot as TextItem, Ut as ResolvedTool, Z as Behavior, i as AnnotationAnchor, mt as ImageGhost, o as AnnotationCapability, q as ArmedStampInfo, r as Annotation$1, vt as LinkNavItem } from "./contract-
|
|
1
|
+
import { F as AnnotationSelectionAnchor, J as ArmedStampPreview, Jt as EditorSelection, Ot as TextItem, Ut as ResolvedTool, Z as Behavior, i as AnnotationAnchor, mt as ImageGhost, o as AnnotationCapability, q as ArmedStampInfo, r as Annotation$1, vt as LinkNavItem } from "./contract-BfZ-mTF7.cjs";
|
|
2
|
+
import { ChromeNode, EditableKinds, Effect, Id, KindName, Model, Point, Quad, RecordAccent, Rect, RenderItem, SceneNode, Session, SnapSettings, TextEndAnchor, ViewEnv } from "@embedpdf/core-annotation";
|
|
2
3
|
import { EventHook, PredictedOp, Unsubscribe } from "@embedpdf/core";
|
|
4
|
+
import { Rotation } from "@embedpdf/core-geometry";
|
|
3
5
|
import { AnnotationAppearanceImage, AnnotationPosition, AnnotationRef, ChangeOp, ImageSource, PageMeasurementViewport, PageRef, PdfMeasure, RichTextParagraph, SerializedEngineError } from "@embedpdf/engine-core/runtime";
|
|
4
|
-
import { ChromeNode, EditableKinds, Effect, Id, KindName, Model, Point, Quad, Rect, RenderItem, SceneNode, Session, SnapSettings, TextEndAnchor, ViewEnv } from "@embedpdf/core-annotation";
|
|
5
6
|
import { AnnotationCommitEntry, AnnotationCommitResult } from "@embedpdf/plugin-actions/contract/host";
|
|
6
7
|
import { AppearancePicture } from "@embedpdf/plugin-render/contract/host";
|
|
7
|
-
import { Rotation } from "@embedpdf/core-geometry";
|
|
8
8
|
//#region src/model.d.ts
|
|
9
9
|
/** Where the active tool's ghost is: the pointer on a page, and how that page shows there. */
|
|
10
10
|
interface GhostPointer {
|
|
@@ -22,6 +22,8 @@ interface ForeignPlacement {
|
|
|
22
22
|
readonly page: PageRef;
|
|
23
23
|
readonly from: Point;
|
|
24
24
|
readonly to: Point;
|
|
25
|
+
/** The page's display rotation at the press (an upright tool lays its drag out as seen). */
|
|
26
|
+
readonly displayRotation?: Rotation;
|
|
25
27
|
}
|
|
26
28
|
interface AnnotationModel {
|
|
27
29
|
/** The core's session: selection, hover, the gesture in progress, tool settings. */
|
|
@@ -159,6 +161,11 @@ interface AnnotationLender {
|
|
|
159
161
|
* draws live while a gesture reshapes it, as a square does.
|
|
160
162
|
*/
|
|
161
163
|
painter(record: Annotation$1): ((box: Rect) => readonly SceneNode[]) | null;
|
|
164
|
+
/**
|
|
165
|
+
* The color a record shows in beside its own look, and how strong (a form field's group's);
|
|
166
|
+
* `null` for a record without one. Read again whenever {@link records} hands out a new object.
|
|
167
|
+
*/
|
|
168
|
+
accentOf?(record: Annotation$1): RecordAccent | null;
|
|
162
169
|
/** Its records' pictures on a page, at rest, in every state, each with its record's picture version. */
|
|
163
170
|
renderAppearances(page: PageRef, scale: number, signal?: AbortSignal): Promise<readonly AppearancePicture[]>;
|
|
164
171
|
}
|
|
@@ -211,6 +218,13 @@ interface AnnotationHostCapability extends AnnotationCapability {
|
|
|
211
218
|
/** A distance draft was captured (the measurement plugin turns it into a calibration). */
|
|
212
219
|
readonly onDraftCaptured: EventHook<CapturedAnnotationDraft>;
|
|
213
220
|
getDistanceCreationPage(): PageRef | null;
|
|
221
|
+
/**
|
|
222
|
+
* Whether a shape that is made click by click waits for its next click: a
|
|
223
|
+
* polygon's or polyline's next corner, a callout's knee or box, a distance
|
|
224
|
+
* line's placement. That click is the shape's, also where it lands on an
|
|
225
|
+
* existing annotation.
|
|
226
|
+
*/
|
|
227
|
+
hasCreationAwaitingClick(): boolean;
|
|
214
228
|
/**
|
|
215
229
|
* The selection's anchor as a page shows it: its rotation handle where the
|
|
216
230
|
* page's view puts it (screen-sized, so it depends on the zoom), for a menu
|
|
@@ -298,6 +312,10 @@ interface AnnotationHostCapability extends AnnotationCapability {
|
|
|
298
312
|
editPointer(phase: 'down' | 'move' | 'up', page: PageRef, point: Point, shift: boolean, scale?: number, rotation?: Rotation, zoom?: number, touch?: boolean): void;
|
|
299
313
|
marqueePointer(phase: 'down' | 'move' | 'up', page: PageRef, point: Point, shift: boolean, scale?: number, rotation?: Rotation, zoom?: number): void;
|
|
300
314
|
createPointer(tool: string, phase: 'down' | 'move' | 'up', page: PageRef, point: Point, finish?: boolean, displayRotation?: Rotation): void;
|
|
315
|
+
/**
|
|
316
|
+
* Make the pen drawing that waits for its next stroke an annotation now,
|
|
317
|
+
* as its tool's `afterCreate` says. A stroke still being drawn is left alone.
|
|
318
|
+
*/
|
|
301
319
|
finishInkDraft(): void;
|
|
302
320
|
/** Place with the active tool at a click; `displayRotation` and `zoom` are the page's view there. */
|
|
303
321
|
placeAt(page: PageRef, point: Point, displayRotation?: Rotation, zoom?: number): boolean;
|
|
@@ -325,11 +343,12 @@ interface AnnotationHostCapability extends AnnotationCapability {
|
|
|
325
343
|
clearGhost(): void;
|
|
326
344
|
/**
|
|
327
345
|
* A sibling plugin's placement gesture with one of this plugin's tools (the
|
|
328
|
-
* form palette's drag-to-place): its press and the pointer now
|
|
329
|
-
*
|
|
330
|
-
*
|
|
346
|
+
* form palette's drag-to-place): its press and the pointer now, and
|
|
347
|
+
* `displayRotation`, the page's view at the press, which an upright tool
|
|
348
|
+
* lays its drag out by. Once it is a drag, the page paints what releasing
|
|
349
|
+
* places; under that the tool's ghost still shows the click.
|
|
331
350
|
*/
|
|
332
|
-
previewPlacement(toolId: string, page: PageRef, from: Point, to: Point): void;
|
|
351
|
+
previewPlacement(toolId: string, page: PageRef, from: Point, to: Point, displayRotation?: Rotation): void;
|
|
333
352
|
clearPlacementPreview(): void;
|
|
334
353
|
/** The armed stamp's ghost on a page, for the render layer's `<img>`. */
|
|
335
354
|
getImageGhost(page: PageRef): ImageGhost | null;
|
|
@@ -361,4 +380,4 @@ interface AnnotationHostCapability extends AnnotationCapability {
|
|
|
361
380
|
declare const AnnotationToken: import("@embedpdf/core").CapabilityToken<AnnotationHostCapability>;
|
|
362
381
|
//#endregion
|
|
363
382
|
export { CapturedAnnotationDraft as a, ANNOTATION_DRAW_PRIORITY as c, ANNOTATION_PLACE_PRIORITY as d, AnnotationModel as f, AnnotationToken as i, ANNOTATION_EDIT_PRIORITY as l, AnnotationHostCapability as n, RecalibrationReport as o, AnnotationLender as r, previewBucket as s, AnnotationAppearancePicture as t, ANNOTATION_MARQUEE_PRIORITY as u };
|
|
364
|
-
//# sourceMappingURL=host-contract-
|
|
383
|
+
//# sourceMappingURL=host-contract-CjPbxfhS.d.cts.map
|