@embedpdf/plugin-actions 3.0.0-next.14 → 3.0.0-next.15
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/contract/host.cjs +13 -1
- package/dist/contract/host.cjs.map +1 -1
- package/dist/contract/host.d.cts +3 -7
- package/dist/contract/host.d.ts +3 -7
- package/dist/contract/host.js +10 -3
- package/dist/contract/host.js.map +1 -1
- package/dist/contract-CNKZHb6w.d.ts +547 -0
- package/dist/contract-CwN3NAXU.js +175 -0
- package/dist/contract-CwN3NAXU.js.map +1 -0
- package/dist/contract-DSQysTqU.d.cts +547 -0
- package/dist/contract-_HB_UliT.cjs +210 -0
- package/dist/contract-_HB_UliT.cjs.map +1 -0
- package/dist/contract.cjs +5 -4
- package/dist/contract.d.cts +2 -3
- package/dist/contract.d.ts +2 -3
- package/dist/contract.js +2 -3
- package/dist/host-contract-CRNO2oZN.d.ts +165 -0
- package/dist/host-contract-DJ8TqDr3.d.cts +165 -0
- package/dist/index.cjs +1524 -1076
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -9
- package/dist/index.d.ts +11 -9
- package/dist/index.js +1522 -1076
- package/dist/index.js.map +1 -1
- package/package.json +7 -11
- package/dist/contract-C1K3H4RP.cjs +0 -89
- package/dist/contract-C1K3H4RP.cjs.map +0 -1
- package/dist/contract-COk-w3Fo.d.ts +0 -50
- package/dist/contract-DAem-EST.js +0 -78
- package/dist/contract-DAem-EST.js.map +0 -1
- package/dist/contract-Os5y4NaD.d.cts +0 -50
- package/dist/internal.cjs +0 -3
- package/dist/internal.d.cts +0 -3
- package/dist/internal.d.ts +0 -3
- package/dist/internal.js +0 -2
- package/dist/types-BXJLAKXi.cjs +0 -52
- package/dist/types-BXJLAKXi.cjs.map +0 -1
- package/dist/types-D-DoiESj.d.cts +0 -504
- package/dist/types-D-DoiESj.d.ts +0 -504
- package/dist/types-DgBMy5nE.js +0 -35
- package/dist/types-DgBMy5nE.js.map +0 -1
package/dist/contract/host.cjs
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_contract = require("../contract-_HB_UliT.cjs");
|
|
2
3
|
//#region src/host-contract.ts
|
|
3
|
-
|
|
4
|
+
/**
|
|
5
|
+
* @embedpdf/plugin-actions/contract/host: the host lens, what sibling
|
|
6
|
+
* plugins (stage, annotation, link, form) need to register commit sinks,
|
|
7
|
+
* the submit resolver, script realms and the page-state report. Same
|
|
8
|
+
* runtime token as the public one, typed wider.
|
|
9
|
+
*/
|
|
10
|
+
const ActionsToken = (0, require("@embedpdf/core").createHostToken)(require_contract.ActionsToken);
|
|
4
11
|
//#endregion
|
|
12
|
+
exports.ACTIONS_DEFAULTS = require_contract.ACTIONS_DEFAULTS;
|
|
5
13
|
exports.ActionsToken = ActionsToken;
|
|
14
|
+
exports.createHoverPump = require_contract.createHoverPump;
|
|
15
|
+
exports.eventOf = require_contract.eventOf;
|
|
16
|
+
exports.submitEntriesToUrlEncoded = require_contract.submitEntriesToUrlEncoded;
|
|
17
|
+
exports.triggerOriginOf = require_contract.triggerOriginOf;
|
|
6
18
|
|
|
7
19
|
//# sourceMappingURL=host.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host.cjs","names":["PublicActionsToken"],"sources":["../../src/host-contract.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"host.cjs","names":["PublicActionsToken"],"sources":["../../src/host-contract.ts"],"sourcesContent":["/**\n * @embedpdf/plugin-actions/contract/host: the host lens, what sibling\n * plugins (stage, annotation, link, form) need to register commit sinks,\n * the submit resolver, script realms and the page-state report. Same\n * runtime token as the public one, typed wider.\n */\nimport { createHostToken, type DocumentMeta, type Unsubscribe } from '@embedpdf/core';\nimport type {\n ScriptAnnotEffect,\n ScriptBudget,\n ScriptDiagnostic,\n ScriptExecutionError,\n ScriptTransaction,\n ScriptUiEffect,\n} from '@embedpdf/core-acrojs';\nimport type {\n DocumentHandle,\n FormEffect,\n FormSnapshot,\n PageRef,\n} from '@embedpdf/engine-core/runtime';\n\nimport type {\n ActionContext,\n ActionDiagnostic,\n ActionOrigin,\n ActionsCapability,\n ActionSource,\n ActionSubmitRequest,\n SubmitIntent,\n} from './contract';\nimport { ActionsToken as PublicActionsToken } from './token';\n\nexport * from './contract';\n\n/**\n * The stage's page-truth report, the one door into the lifecycle\n * coordinator. The stage stays authoritative for what page the viewer is on;\n * the coordinator owns when page-lifecycle triggers fire: reports are\n * buffered until the document-open sequence has run and diffed against the\n * last-emitted state, so pre-open motion (a restored view, the open\n * destination's reveal) never emits close and open churn. `cause` feeds the\n * cascade budget: consecutive programmatic rounds are capped, and a\n * user-caused report resets the count.\n */\nexport interface PageStateReport {\n currentPage: PageRef | null;\n visiblePages: readonly PageRef[];\n /** False until layout exists; pre-placement reports are ignored. */\n placed: boolean;\n cause: 'user' | 'programmatic';\n}\n\n// ── owner commit sinks ──\n// Every script and Hide effect is a document mutation committed by the plugin\n// that owns the model, so the engine write and the visible model never\n// diverge. Sinks are invoked from inside the actions and form serialized\n// operations (the script executor calls them while holding the host\n// transaction), so a sink must never enqueue and never acquire the host:\n// either would deadlock.\n\n/** One annotation-effect commit entry. `page` may be absent for bare Hide\n * object-number targets: the sink resolves it from its model (`obj:N` is a\n * cross-page key there), and entries it cannot resolve fail. */\nexport interface AnnotCommitEntry {\n annotObjectNumber: number;\n page?: PageRef;\n patch: ScriptAnnotEffect['patch'];\n}\nexport interface AnnotCommitResult {\n results: Array<{\n annotObjectNumber: number;\n status: 'applied' | 'failed' | 'skipped';\n error?: string;\n }>;\n}\nexport type AnnotCommitSink = (entries: AnnotCommitEntry[]) => Promise<AnnotCommitResult>;\n\n/**\n * What the form plugin's commit did: `applied`, the effects are one change on its way (shown at\n * once; the engine's refusal comes through the change queue); `failed`, none of them is.\n */\nexport interface FormCommitSinkResult {\n status: 'applied' | 'failed';\n /** Why the change couldn't be made, when it couldn't. */\n error?: string;\n}\n/** The form plugin's document commit: a script run's form effects, written as one change. */\nexport type FormCommitSink = (effects: FormEffect[]) => Promise<FormCommitSinkResult>;\n\n/**\n * The form as the user sees it: the form plugin's fields and widgets with this session's pending\n * fills, or `null` before it has read the form. What scripts and dispatch read instead of the\n * engine, so they see a fill before the engine answers it.\n */\nexport type FormReader = () => FormSnapshot | null;\n\n/**\n * Which realm produced a script result. `'document'` = this document's own\n * realm: every effect targets the viewer document. `'detached'` = a realm\n * minted for a document that is not displayed (a stamp asset): it has no\n * document surface, so only alerts reach the adapter — print, page\n * navigation, and submit are suppressed with a diagnostic rather than\n * acting on the wrong document.\n */\nexport type ScriptRealmKind = 'document' | 'detached';\n\n/** What a script transaction surfaced besides document effects. */\nexport interface ScriptSurfaceResult {\n uiEffects: ScriptUiEffect[];\n diagnostics: ScriptDiagnostic[];\n error?: ScriptExecutionError;\n origin: ActionOrigin;\n phase: 'boot' | 'user';\n realm: ScriptRealmKind;\n /** What started the script, when an action did: `onScriptFailed` and diagnostics carry it. */\n source?: ActionSource;\n}\n\n/** A K/V/C/F transaction's result as the form controller reports it: effects\n * carry their own phase (boot effects belong to the first transaction that\n * lazily booted the realm). Structurally the surface half of the form\n * plugin's commit result, typed here so the actions plane never imports the\n * form package. */\nexport interface ScriptCommitSurface {\n uiEffects: Array<ScriptUiEffect & { phase: 'boot' | 'user' }>;\n diagnostics: ScriptDiagnostic[];\n error?: ScriptExecutionError;\n}\n\n// ── script realms ──\n\n/** What a realm is minted for. `doc` is the document the scripts operate on\n * (the viewer document, or a detached asset); `document()` is the metadata\n * scripts observe (`this.documentFileName` …): for a detached stamp that is\n * the target document's, matching Acrobat's dynamic stamps. */\n/** What a script realm reads of the document it runs for. */\nexport type ScriptDocument = Pick<DocumentMeta, 'name' | 'pageCount' | 'pages'>;\n\nexport interface ScriptRealmTarget {\n doc: DocumentHandle;\n document(): ScriptDocument | null;\n /** Name-tree programs, fetched lazily once per realm build. */\n bootSources(): Promise<string[]>;\n}\n\n/** The realm transaction port plus the budget consumers apply as their\n * transaction aggregate: the same shape whether the realm is this document's\n * own (owned by actions) or a detached one (owned by the caller). */\nexport interface ScriptRealmPort {\n /** The body must perform prefetch, runs, sink commits and reconciliation\n * before returning: commits happen inside the transaction. */\n transaction<T>(body: (transaction: ScriptTransaction) => Promise<T>): Promise<T>;\n budget: ScriptBudget;\n}\n\n/** A detached realm: the caller owns its lifetime. */\nexport interface DetachedScriptRealm extends ScriptRealmPort {\n dispose(): void;\n}\n\n/** The form plugin's dataset resolver, registered on the host lens.\n * `diagnose` is the per-entry observability channel: an explicitly listed\n * push-button, signature or unsupported value is diagnosed as\n * `submit-entry-unsupported`, never silently dropped. */\nexport type SubmitResolver = (\n intent: SubmitIntent,\n actionContext: ActionContext,\n diagnose: (diagnostic: ActionDiagnostic) => void,\n) => Promise<ActionSubmitRequest>;\n\n/** The host lens, plugin-to-plugin only: import the token from\n * `@embedpdf/plugin-actions/contract/host`, never from application code. */\nexport interface ActionsHostCapability extends ActionsCapability {\n /** The annotation plugin's commit sink for script and Hide annotation effects. Identity-safe. */\n registerAnnotCommitSink(sink: AnnotCommitSink): Unsubscribe;\n /** The form plugin's commit sink for script and Hide form effects. Identity-safe. */\n registerFormCommitSink(sink: FormCommitSink): Unsubscribe;\n /** The form plugin's form, which scripts and dispatch read; without one they read the engine. Identity-safe. */\n registerFormReader(reader: FormReader): Unsubscribe;\n /**\n * This document's realm, present only when `javascript.enabled` (its\n * presence is the form plugin's \"scripting on\" signal).\n */\n scriptRealm?: ScriptRealmPort;\n /**\n * Mint a realm for a detached document under this document's policy and\n * environment (the same sandbox factory, identity, clock and budget; a\n * fresh sandbox, so isolated globals). Present only when\n * `javascript.enabled`, like `scriptRealm`. The caller owns the returned\n * realm's lifetime and surfaces its results with `realm: 'detached'`.\n */\n createDetachedScriptRealm?(target: ScriptRealmTarget): DetachedScriptRealm;\n /** Surface a script transaction's UI effects, diagnostics and error through\n * the one port (the adapter matrix, the authority print gate, the script\n * events). */\n surfaceScriptResult(result: ScriptSurfaceResult): void;\n /** Surface a K/V/C/F commit result: splits boot-phase and user-phase\n * effects into their own surfaces (diagnostics and the error ride the\n * user phase); the one place that split lives. */\n surfaceScriptCommit(\n commit: ScriptCommitSurface,\n context: { origin: ActionOrigin; realm: ScriptRealmKind; source?: ActionSource },\n ): void;\n /** The stage's page-truth report (see {@link PageStateReport}). */\n reportPageState(report: PageStateReport): void;\n /**\n * The form plugin's dataset resolver: both submit sources (action nodes\n * and script `doc.submitForm()` effects) normalize to a\n * {@link SubmitIntent} and resolve through this one door. Identity-safe;\n * without it every submit blocks with `no-submit-resolver`.\n */\n registerSubmitResolver(resolver: SubmitResolver): Unsubscribe;\n}\n\nexport const ActionsToken = createHostToken<ActionsHostCapability>(PublicActionsToken);\n"],"mappings":";;;;;;;;;AAuNA,MAAa,gBAAA,2BAAA,CAAA,CAAA,gBAAA,CAAsDA,iBAAAA,YAAkB"}
|
package/dist/contract/host.d.cts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
declare const ActionsToken: CapabilityToken<ActionsHostCapability>;
|
|
5
|
-
//#endregion
|
|
6
|
-
export { type ActionExecutor, type ActionExecutorResult, type ActionSubmitRequest, type ActionsHostCapability, ActionsToken, type AnnotCommitEntry, type AnnotCommitResult, type AnnotCommitSink, type DetachedScriptRealm, type FormCommitSink, type PageStateReport, type ScriptCommitSurface, type ScriptRealmKind, type ScriptRealmPort, type ScriptRealmTarget, type ScriptSurfaceResult, type SubmitIntent, type SubmitResolver };
|
|
7
|
-
//# sourceMappingURL=host.d.cts.map
|
|
1
|
+
import { A as DocumentTriggerEvent, B as SubmitIntent, C as ActionUiAdapter, D as ActionsScriptEnvironment, E as ActionsConfig, F as PdfAnnotationEventKind, G as HoverTarget, H as triggerOriginOf, I as PdfFieldEventKind, K as createHoverPump, L as PdfNamedAction, M as PdfActionNode, N as PdfActionTree, O as ActionsScriptIdentity, P as PdfActionType, R as ScriptDiagnosticReportedEvent, S as ActionTriggerResult, T as ActionsCapability, U as submitEntriesToUrlEncoded, V as eventOf, W as HoverPump, _ as ActionSubmitHandler, a as ActionDispatchResult, b as ActionTrigger, c as ActionExecutorResult, d as ActionOrigin, f as ActionPolicy, g as ActionStepResult, h as ActionSource, i as ActionDiagnosticReportedEvent, j as OpenSequenceCompletedEvent, k as ActionsSettings, l as ActionNodeResult, m as ActionPolicyRow, n as ActionContext, o as ActionExecutedEvent, p as ActionPolicyDecision, r as ActionDiagnostic, s as ActionExecutor, t as ACTIONS_DEFAULTS, u as ActionNodeStatus, v as ActionSubmitRequest, w as ActionUiContext, x as ActionTriggerEvent, y as ActionTreeSource, z as ScriptFailedEvent } from "../contract-DSQysTqU.cjs";
|
|
2
|
+
import { _ as SubmitResolver, a as AnnotCommitSink, c as FormCommitSinkResult, d as ScriptCommitSurface, f as ScriptDocument, g as ScriptSurfaceResult, h as ScriptRealmTarget, i as AnnotCommitResult, l as FormReader, m as ScriptRealmPort, n as ActionsToken, o as DetachedScriptRealm, p as ScriptRealmKind, r as AnnotCommitEntry, s as FormCommitSink, t as ActionsHostCapability, u as PageStateReport } from "../host-contract-DJ8TqDr3.cjs";
|
|
3
|
+
export { ACTIONS_DEFAULTS, ActionContext, ActionDiagnostic, ActionDiagnosticReportedEvent, ActionDispatchResult, ActionExecutedEvent, ActionExecutor, ActionExecutorResult, ActionNodeResult, ActionNodeStatus, ActionOrigin, ActionPolicy, ActionPolicyDecision, ActionPolicyRow, ActionSource, ActionStepResult, ActionSubmitHandler, ActionSubmitRequest, ActionTreeSource, ActionTrigger, ActionTriggerEvent, ActionTriggerResult, ActionUiAdapter, ActionUiContext, ActionsCapability, ActionsConfig, ActionsHostCapability, ActionsScriptEnvironment, ActionsScriptIdentity, ActionsSettings, ActionsToken, AnnotCommitEntry, AnnotCommitResult, AnnotCommitSink, DetachedScriptRealm, DocumentTriggerEvent, FormCommitSink, FormCommitSinkResult, FormReader, type HoverPump, type HoverTarget, OpenSequenceCompletedEvent, PageStateReport, type PdfActionNode, type PdfActionTree, type PdfActionType, PdfAnnotationEventKind, PdfFieldEventKind, PdfNamedAction, ScriptCommitSurface, ScriptDiagnosticReportedEvent, ScriptDocument, ScriptFailedEvent, ScriptRealmKind, ScriptRealmPort, ScriptRealmTarget, ScriptSurfaceResult, SubmitIntent, SubmitResolver, createHoverPump, eventOf, submitEntriesToUrlEncoded, triggerOriginOf };
|
package/dist/contract/host.d.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
declare const ActionsToken: CapabilityToken<ActionsHostCapability>;
|
|
5
|
-
//#endregion
|
|
6
|
-
export { type ActionExecutor, type ActionExecutorResult, type ActionSubmitRequest, type ActionsHostCapability, ActionsToken, type AnnotCommitEntry, type AnnotCommitResult, type AnnotCommitSink, type DetachedScriptRealm, type FormCommitSink, type PageStateReport, type ScriptCommitSurface, type ScriptRealmKind, type ScriptRealmPort, type ScriptRealmTarget, type ScriptSurfaceResult, type SubmitIntent, type SubmitResolver };
|
|
7
|
-
//# sourceMappingURL=host.d.ts.map
|
|
1
|
+
import { A as DocumentTriggerEvent, B as SubmitIntent, C as ActionUiAdapter, D as ActionsScriptEnvironment, E as ActionsConfig, F as PdfAnnotationEventKind, G as HoverTarget, H as triggerOriginOf, I as PdfFieldEventKind, K as createHoverPump, L as PdfNamedAction, M as PdfActionNode, N as PdfActionTree, O as ActionsScriptIdentity, P as PdfActionType, R as ScriptDiagnosticReportedEvent, S as ActionTriggerResult, T as ActionsCapability, U as submitEntriesToUrlEncoded, V as eventOf, W as HoverPump, _ as ActionSubmitHandler, a as ActionDispatchResult, b as ActionTrigger, c as ActionExecutorResult, d as ActionOrigin, f as ActionPolicy, g as ActionStepResult, h as ActionSource, i as ActionDiagnosticReportedEvent, j as OpenSequenceCompletedEvent, k as ActionsSettings, l as ActionNodeResult, m as ActionPolicyRow, n as ActionContext, o as ActionExecutedEvent, p as ActionPolicyDecision, r as ActionDiagnostic, s as ActionExecutor, t as ACTIONS_DEFAULTS, u as ActionNodeStatus, v as ActionSubmitRequest, w as ActionUiContext, x as ActionTriggerEvent, y as ActionTreeSource, z as ScriptFailedEvent } from "../contract-CNKZHb6w.js";
|
|
2
|
+
import { _ as SubmitResolver, a as AnnotCommitSink, c as FormCommitSinkResult, d as ScriptCommitSurface, f as ScriptDocument, g as ScriptSurfaceResult, h as ScriptRealmTarget, i as AnnotCommitResult, l as FormReader, m as ScriptRealmPort, n as ActionsToken, o as DetachedScriptRealm, p as ScriptRealmKind, r as AnnotCommitEntry, s as FormCommitSink, t as ActionsHostCapability, u as PageStateReport } from "../host-contract-CRNO2oZN.js";
|
|
3
|
+
export { ACTIONS_DEFAULTS, ActionContext, ActionDiagnostic, ActionDiagnosticReportedEvent, ActionDispatchResult, ActionExecutedEvent, ActionExecutor, ActionExecutorResult, ActionNodeResult, ActionNodeStatus, ActionOrigin, ActionPolicy, ActionPolicyDecision, ActionPolicyRow, ActionSource, ActionStepResult, ActionSubmitHandler, ActionSubmitRequest, ActionTreeSource, ActionTrigger, ActionTriggerEvent, ActionTriggerResult, ActionUiAdapter, ActionUiContext, ActionsCapability, ActionsConfig, ActionsHostCapability, ActionsScriptEnvironment, ActionsScriptIdentity, ActionsSettings, ActionsToken, AnnotCommitEntry, AnnotCommitResult, AnnotCommitSink, DetachedScriptRealm, DocumentTriggerEvent, FormCommitSink, FormCommitSinkResult, FormReader, type HoverPump, type HoverTarget, OpenSequenceCompletedEvent, PageStateReport, type PdfActionNode, type PdfActionTree, type PdfActionType, PdfAnnotationEventKind, PdfFieldEventKind, PdfNamedAction, ScriptCommitSurface, ScriptDiagnosticReportedEvent, ScriptDocument, ScriptFailedEvent, ScriptRealmKind, ScriptRealmPort, ScriptRealmTarget, ScriptSurfaceResult, SubmitIntent, SubmitResolver, createHoverPump, eventOf, submitEntriesToUrlEncoded, triggerOriginOf };
|
package/dist/contract/host.js
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as createHoverPump, i as submitEntriesToUrlEncoded, n as eventOf, o as ActionsToken$1, r as triggerOriginOf, t as ACTIONS_DEFAULTS } from "../contract-CwN3NAXU.js";
|
|
2
|
+
import { createHostToken } from "@embedpdf/core";
|
|
2
3
|
//#region src/host-contract.ts
|
|
3
|
-
|
|
4
|
+
/**
|
|
5
|
+
* @embedpdf/plugin-actions/contract/host: the host lens, what sibling
|
|
6
|
+
* plugins (stage, annotation, link, form) need to register commit sinks,
|
|
7
|
+
* the submit resolver, script realms and the page-state report. Same
|
|
8
|
+
* runtime token as the public one, typed wider.
|
|
9
|
+
*/
|
|
10
|
+
const ActionsToken = createHostToken(ActionsToken$1);
|
|
4
11
|
//#endregion
|
|
5
|
-
export { ActionsToken };
|
|
12
|
+
export { ACTIONS_DEFAULTS, ActionsToken, createHoverPump, eventOf, submitEntriesToUrlEncoded, triggerOriginOf };
|
|
6
13
|
|
|
7
14
|
//# sourceMappingURL=host.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host.js","names":["PublicActionsToken"],"sources":["../../src/host-contract.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"host.js","names":["PublicActionsToken"],"sources":["../../src/host-contract.ts"],"sourcesContent":["/**\n * @embedpdf/plugin-actions/contract/host: the host lens, what sibling\n * plugins (stage, annotation, link, form) need to register commit sinks,\n * the submit resolver, script realms and the page-state report. Same\n * runtime token as the public one, typed wider.\n */\nimport { createHostToken, type DocumentMeta, type Unsubscribe } from '@embedpdf/core';\nimport type {\n ScriptAnnotEffect,\n ScriptBudget,\n ScriptDiagnostic,\n ScriptExecutionError,\n ScriptTransaction,\n ScriptUiEffect,\n} from '@embedpdf/core-acrojs';\nimport type {\n DocumentHandle,\n FormEffect,\n FormSnapshot,\n PageRef,\n} from '@embedpdf/engine-core/runtime';\n\nimport type {\n ActionContext,\n ActionDiagnostic,\n ActionOrigin,\n ActionsCapability,\n ActionSource,\n ActionSubmitRequest,\n SubmitIntent,\n} from './contract';\nimport { ActionsToken as PublicActionsToken } from './token';\n\nexport * from './contract';\n\n/**\n * The stage's page-truth report, the one door into the lifecycle\n * coordinator. The stage stays authoritative for what page the viewer is on;\n * the coordinator owns when page-lifecycle triggers fire: reports are\n * buffered until the document-open sequence has run and diffed against the\n * last-emitted state, so pre-open motion (a restored view, the open\n * destination's reveal) never emits close and open churn. `cause` feeds the\n * cascade budget: consecutive programmatic rounds are capped, and a\n * user-caused report resets the count.\n */\nexport interface PageStateReport {\n currentPage: PageRef | null;\n visiblePages: readonly PageRef[];\n /** False until layout exists; pre-placement reports are ignored. */\n placed: boolean;\n cause: 'user' | 'programmatic';\n}\n\n// ── owner commit sinks ──\n// Every script and Hide effect is a document mutation committed by the plugin\n// that owns the model, so the engine write and the visible model never\n// diverge. Sinks are invoked from inside the actions and form serialized\n// operations (the script executor calls them while holding the host\n// transaction), so a sink must never enqueue and never acquire the host:\n// either would deadlock.\n\n/** One annotation-effect commit entry. `page` may be absent for bare Hide\n * object-number targets: the sink resolves it from its model (`obj:N` is a\n * cross-page key there), and entries it cannot resolve fail. */\nexport interface AnnotCommitEntry {\n annotObjectNumber: number;\n page?: PageRef;\n patch: ScriptAnnotEffect['patch'];\n}\nexport interface AnnotCommitResult {\n results: Array<{\n annotObjectNumber: number;\n status: 'applied' | 'failed' | 'skipped';\n error?: string;\n }>;\n}\nexport type AnnotCommitSink = (entries: AnnotCommitEntry[]) => Promise<AnnotCommitResult>;\n\n/**\n * What the form plugin's commit did: `applied`, the effects are one change on its way (shown at\n * once; the engine's refusal comes through the change queue); `failed`, none of them is.\n */\nexport interface FormCommitSinkResult {\n status: 'applied' | 'failed';\n /** Why the change couldn't be made, when it couldn't. */\n error?: string;\n}\n/** The form plugin's document commit: a script run's form effects, written as one change. */\nexport type FormCommitSink = (effects: FormEffect[]) => Promise<FormCommitSinkResult>;\n\n/**\n * The form as the user sees it: the form plugin's fields and widgets with this session's pending\n * fills, or `null` before it has read the form. What scripts and dispatch read instead of the\n * engine, so they see a fill before the engine answers it.\n */\nexport type FormReader = () => FormSnapshot | null;\n\n/**\n * Which realm produced a script result. `'document'` = this document's own\n * realm: every effect targets the viewer document. `'detached'` = a realm\n * minted for a document that is not displayed (a stamp asset): it has no\n * document surface, so only alerts reach the adapter — print, page\n * navigation, and submit are suppressed with a diagnostic rather than\n * acting on the wrong document.\n */\nexport type ScriptRealmKind = 'document' | 'detached';\n\n/** What a script transaction surfaced besides document effects. */\nexport interface ScriptSurfaceResult {\n uiEffects: ScriptUiEffect[];\n diagnostics: ScriptDiagnostic[];\n error?: ScriptExecutionError;\n origin: ActionOrigin;\n phase: 'boot' | 'user';\n realm: ScriptRealmKind;\n /** What started the script, when an action did: `onScriptFailed` and diagnostics carry it. */\n source?: ActionSource;\n}\n\n/** A K/V/C/F transaction's result as the form controller reports it: effects\n * carry their own phase (boot effects belong to the first transaction that\n * lazily booted the realm). Structurally the surface half of the form\n * plugin's commit result, typed here so the actions plane never imports the\n * form package. */\nexport interface ScriptCommitSurface {\n uiEffects: Array<ScriptUiEffect & { phase: 'boot' | 'user' }>;\n diagnostics: ScriptDiagnostic[];\n error?: ScriptExecutionError;\n}\n\n// ── script realms ──\n\n/** What a realm is minted for. `doc` is the document the scripts operate on\n * (the viewer document, or a detached asset); `document()` is the metadata\n * scripts observe (`this.documentFileName` …): for a detached stamp that is\n * the target document's, matching Acrobat's dynamic stamps. */\n/** What a script realm reads of the document it runs for. */\nexport type ScriptDocument = Pick<DocumentMeta, 'name' | 'pageCount' | 'pages'>;\n\nexport interface ScriptRealmTarget {\n doc: DocumentHandle;\n document(): ScriptDocument | null;\n /** Name-tree programs, fetched lazily once per realm build. */\n bootSources(): Promise<string[]>;\n}\n\n/** The realm transaction port plus the budget consumers apply as their\n * transaction aggregate: the same shape whether the realm is this document's\n * own (owned by actions) or a detached one (owned by the caller). */\nexport interface ScriptRealmPort {\n /** The body must perform prefetch, runs, sink commits and reconciliation\n * before returning: commits happen inside the transaction. */\n transaction<T>(body: (transaction: ScriptTransaction) => Promise<T>): Promise<T>;\n budget: ScriptBudget;\n}\n\n/** A detached realm: the caller owns its lifetime. */\nexport interface DetachedScriptRealm extends ScriptRealmPort {\n dispose(): void;\n}\n\n/** The form plugin's dataset resolver, registered on the host lens.\n * `diagnose` is the per-entry observability channel: an explicitly listed\n * push-button, signature or unsupported value is diagnosed as\n * `submit-entry-unsupported`, never silently dropped. */\nexport type SubmitResolver = (\n intent: SubmitIntent,\n actionContext: ActionContext,\n diagnose: (diagnostic: ActionDiagnostic) => void,\n) => Promise<ActionSubmitRequest>;\n\n/** The host lens, plugin-to-plugin only: import the token from\n * `@embedpdf/plugin-actions/contract/host`, never from application code. */\nexport interface ActionsHostCapability extends ActionsCapability {\n /** The annotation plugin's commit sink for script and Hide annotation effects. Identity-safe. */\n registerAnnotCommitSink(sink: AnnotCommitSink): Unsubscribe;\n /** The form plugin's commit sink for script and Hide form effects. Identity-safe. */\n registerFormCommitSink(sink: FormCommitSink): Unsubscribe;\n /** The form plugin's form, which scripts and dispatch read; without one they read the engine. Identity-safe. */\n registerFormReader(reader: FormReader): Unsubscribe;\n /**\n * This document's realm, present only when `javascript.enabled` (its\n * presence is the form plugin's \"scripting on\" signal).\n */\n scriptRealm?: ScriptRealmPort;\n /**\n * Mint a realm for a detached document under this document's policy and\n * environment (the same sandbox factory, identity, clock and budget; a\n * fresh sandbox, so isolated globals). Present only when\n * `javascript.enabled`, like `scriptRealm`. The caller owns the returned\n * realm's lifetime and surfaces its results with `realm: 'detached'`.\n */\n createDetachedScriptRealm?(target: ScriptRealmTarget): DetachedScriptRealm;\n /** Surface a script transaction's UI effects, diagnostics and error through\n * the one port (the adapter matrix, the authority print gate, the script\n * events). */\n surfaceScriptResult(result: ScriptSurfaceResult): void;\n /** Surface a K/V/C/F commit result: splits boot-phase and user-phase\n * effects into their own surfaces (diagnostics and the error ride the\n * user phase); the one place that split lives. */\n surfaceScriptCommit(\n commit: ScriptCommitSurface,\n context: { origin: ActionOrigin; realm: ScriptRealmKind; source?: ActionSource },\n ): void;\n /** The stage's page-truth report (see {@link PageStateReport}). */\n reportPageState(report: PageStateReport): void;\n /**\n * The form plugin's dataset resolver: both submit sources (action nodes\n * and script `doc.submitForm()` effects) normalize to a\n * {@link SubmitIntent} and resolve through this one door. Identity-safe;\n * without it every submit blocks with `no-submit-resolver`.\n */\n registerSubmitResolver(resolver: SubmitResolver): Unsubscribe;\n}\n\nexport const ActionsToken = createHostToken<ActionsHostCapability>(PublicActionsToken);\n"],"mappings":";;;;;;;;;AAuNA,MAAa,eAAe,gBAAuCA,cAAkB"}
|