@embedpdf/plugin-form 3.0.0-next.9 → 3.0.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.
@@ -0,0 +1,4 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_controller = require("./controller-BwbadmLW.cjs");
3
+ exports.FormScriptingController = require_controller.FormScriptingController;
4
+ exports.createFormScriptingController = require_controller.createFormScriptingController;
@@ -0,0 +1,83 @@
1
+ import { V as FormUiEffect } from "./contract-Djti7ew8.cjs";
2
+ import { DocumentMeta } from "@embedpdf/core";
3
+ import { ScriptBudget, ScriptDiagnostic, ScriptExecutionError, ScriptTransaction } from "@embedpdf/core-acrojs";
4
+ import { FormEffect, FormFieldRef, FormFieldValue, FormSnapshot, PdfActionTree } from "@embedpdf/engine-core/runtime";
5
+ //#region src/scripting/controller.d.ts
6
+ /**
7
+ * The controller never owns a realm. It rides a realm port — this document's
8
+ * own (the actions plugin's per-document host) or a detached one minted by
9
+ * the actions plugin for a document that is not displayed (stamp's
10
+ * asset documents). Either way the owner destroys the realm; `destroy()`
11
+ * here only fences further transactions.
12
+ */
13
+ interface FormScriptingControllerOptions {
14
+ /** What the scripts read of the document: its name, page count and pages. */
15
+ document(): Pick<DocumentMeta, 'name' | 'pageCount' | 'pages'> | null;
16
+ /** The realm's transaction port ({@link ScriptTransaction}): the realm runs one at a time. */
17
+ transaction<T>(body: (txn: ScriptTransaction) => Promise<T>): Promise<T>;
18
+ /** The transaction aggregate (output bytes, wall-clock across passes);
19
+ * the realm owner hands over the same budget its runs enforce. */
20
+ budget?: ScriptBudget;
21
+ }
22
+ /** What the form's scripts made of one write, before anything is written. */
23
+ interface FormScriptResult {
24
+ /**
25
+ * `accepted`: write `effects`. `rejected`: a keystroke or validate script refused the value,
26
+ * so only `bootEffects` are written. `failed`: the transaction broke (a budget, a script that
27
+ * couldn't run), so nothing is.
28
+ */
29
+ readonly status: 'accepted' | 'rejected' | 'failed';
30
+ /** What the scripts changed in the form, in the order to write it (`formEffectOps`). */
31
+ readonly effects: FormEffect[];
32
+ /** What the document's open scripts changed: written even when the value is refused. */
33
+ readonly bootEffects: FormEffect[];
34
+ readonly uiEffects: FormUiEffect[];
35
+ readonly diagnostics: ScriptDiagnostic[];
36
+ readonly error?: ScriptExecutionError;
37
+ }
38
+ /** The scripts one transaction can run, each against the form it is given. */
39
+ interface FormScripts {
40
+ /**
41
+ * A field's new value through its keystroke and validate scripts, then the calculations and
42
+ * the formats. `form` is the form without the value.
43
+ */
44
+ commit(form: FormSnapshot, ref: FormFieldRef, value: FormFieldValue): Promise<FormScriptResult>;
45
+ /** One widget's activation action (`/A`, with `/Next`). Only its scripts run here. */
46
+ activate(form: FormSnapshot, ref: FormFieldRef, action: PdfActionTree<unknown>): Promise<FormScriptResult>;
47
+ /** The document's open scripts (once per realm) and the calculations, without a field change. */
48
+ recalculate(form: FormSnapshot): Promise<FormScriptResult>;
49
+ }
50
+ declare class FormScriptingController {
51
+ private readonly options;
52
+ private disposed;
53
+ private readonly transactionBudget;
54
+ constructor(options: FormScriptingControllerOptions);
55
+ /** The realm belongs to its owner (the actions plugin, or the caller that
56
+ * minted a detached one) — this only fences further transactions. */
57
+ destroy(): void;
58
+ /**
59
+ * One realm transaction: `body` runs its scripts and writes what they changed before the
60
+ * next transaction starts, so that one reads the form with it.
61
+ */
62
+ transaction<T>(body: (scripts: FormScripts) => Promise<T>): Promise<T>;
63
+ /**
64
+ * Load the realm before the first write needs it: the scripts' engine starts, and the
65
+ * document's open scripts run, their effects kept for the first write as without warming.
66
+ * Nothing is written.
67
+ */
68
+ warm(form: FormSnapshot): Promise<void>;
69
+ /** {@link FormScripts.commit} in a transaction of its own. */
70
+ commit(form: FormSnapshot, ref: FormFieldRef, value: FormFieldValue): Promise<FormScriptResult>;
71
+ /** {@link FormScripts.activate} in a transaction of its own. */
72
+ activate(form: FormSnapshot, ref: FormFieldRef, action: PdfActionTree<unknown>): Promise<FormScriptResult>;
73
+ /** {@link FormScripts.recalculate} in a transaction of its own. */
74
+ recalculate(form: FormSnapshot): Promise<FormScriptResult>;
75
+ private run;
76
+ private failed;
77
+ /** The value is refused; the open scripts' effects are still written. */
78
+ private rejected;
79
+ }
80
+ declare function createFormScriptingController(options: FormScriptingControllerOptions): FormScriptingController;
81
+ //#endregion
82
+ export { FormScriptResult, FormScriptingController, FormScriptingControllerOptions, FormScripts, createFormScriptingController };
83
+ //# sourceMappingURL=scripting.d.cts.map
@@ -0,0 +1,83 @@
1
+ import { V as FormUiEffect } from "./contract-6YEsObRl.js";
2
+ import { DocumentMeta } from "@embedpdf/core";
3
+ import { FormEffect, FormFieldRef, FormFieldValue, FormSnapshot, PdfActionTree } from "@embedpdf/engine-core/runtime";
4
+ import { ScriptBudget, ScriptDiagnostic, ScriptExecutionError, ScriptTransaction } from "@embedpdf/core-acrojs";
5
+ //#region src/scripting/controller.d.ts
6
+ /**
7
+ * The controller never owns a realm. It rides a realm port — this document's
8
+ * own (the actions plugin's per-document host) or a detached one minted by
9
+ * the actions plugin for a document that is not displayed (stamp's
10
+ * asset documents). Either way the owner destroys the realm; `destroy()`
11
+ * here only fences further transactions.
12
+ */
13
+ interface FormScriptingControllerOptions {
14
+ /** What the scripts read of the document: its name, page count and pages. */
15
+ document(): Pick<DocumentMeta, 'name' | 'pageCount' | 'pages'> | null;
16
+ /** The realm's transaction port ({@link ScriptTransaction}): the realm runs one at a time. */
17
+ transaction<T>(body: (txn: ScriptTransaction) => Promise<T>): Promise<T>;
18
+ /** The transaction aggregate (output bytes, wall-clock across passes);
19
+ * the realm owner hands over the same budget its runs enforce. */
20
+ budget?: ScriptBudget;
21
+ }
22
+ /** What the form's scripts made of one write, before anything is written. */
23
+ interface FormScriptResult {
24
+ /**
25
+ * `accepted`: write `effects`. `rejected`: a keystroke or validate script refused the value,
26
+ * so only `bootEffects` are written. `failed`: the transaction broke (a budget, a script that
27
+ * couldn't run), so nothing is.
28
+ */
29
+ readonly status: 'accepted' | 'rejected' | 'failed';
30
+ /** What the scripts changed in the form, in the order to write it (`formEffectOps`). */
31
+ readonly effects: FormEffect[];
32
+ /** What the document's open scripts changed: written even when the value is refused. */
33
+ readonly bootEffects: FormEffect[];
34
+ readonly uiEffects: FormUiEffect[];
35
+ readonly diagnostics: ScriptDiagnostic[];
36
+ readonly error?: ScriptExecutionError;
37
+ }
38
+ /** The scripts one transaction can run, each against the form it is given. */
39
+ interface FormScripts {
40
+ /**
41
+ * A field's new value through its keystroke and validate scripts, then the calculations and
42
+ * the formats. `form` is the form without the value.
43
+ */
44
+ commit(form: FormSnapshot, ref: FormFieldRef, value: FormFieldValue): Promise<FormScriptResult>;
45
+ /** One widget's activation action (`/A`, with `/Next`). Only its scripts run here. */
46
+ activate(form: FormSnapshot, ref: FormFieldRef, action: PdfActionTree<unknown>): Promise<FormScriptResult>;
47
+ /** The document's open scripts (once per realm) and the calculations, without a field change. */
48
+ recalculate(form: FormSnapshot): Promise<FormScriptResult>;
49
+ }
50
+ declare class FormScriptingController {
51
+ private readonly options;
52
+ private disposed;
53
+ private readonly transactionBudget;
54
+ constructor(options: FormScriptingControllerOptions);
55
+ /** The realm belongs to its owner (the actions plugin, or the caller that
56
+ * minted a detached one) — this only fences further transactions. */
57
+ destroy(): void;
58
+ /**
59
+ * One realm transaction: `body` runs its scripts and writes what they changed before the
60
+ * next transaction starts, so that one reads the form with it.
61
+ */
62
+ transaction<T>(body: (scripts: FormScripts) => Promise<T>): Promise<T>;
63
+ /**
64
+ * Load the realm before the first write needs it: the scripts' engine starts, and the
65
+ * document's open scripts run, their effects kept for the first write as without warming.
66
+ * Nothing is written.
67
+ */
68
+ warm(form: FormSnapshot): Promise<void>;
69
+ /** {@link FormScripts.commit} in a transaction of its own. */
70
+ commit(form: FormSnapshot, ref: FormFieldRef, value: FormFieldValue): Promise<FormScriptResult>;
71
+ /** {@link FormScripts.activate} in a transaction of its own. */
72
+ activate(form: FormSnapshot, ref: FormFieldRef, action: PdfActionTree<unknown>): Promise<FormScriptResult>;
73
+ /** {@link FormScripts.recalculate} in a transaction of its own. */
74
+ recalculate(form: FormSnapshot): Promise<FormScriptResult>;
75
+ private run;
76
+ private failed;
77
+ /** The value is refused; the open scripts' effects are still written. */
78
+ private rejected;
79
+ }
80
+ declare function createFormScriptingController(options: FormScriptingControllerOptions): FormScriptingController;
81
+ //#endregion
82
+ export { FormScriptResult, FormScriptingController, FormScriptingControllerOptions, FormScripts, createFormScriptingController };
83
+ //# sourceMappingURL=scripting.d.ts.map
@@ -0,0 +1,2 @@
1
+ import { n as createFormScriptingController, t as FormScriptingController } from "./controller-BbC8XWpY.js";
2
+ export { FormScriptingController, createFormScriptingController };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embedpdf/plugin-form",
3
- "version": "3.0.0-next.9",
3
+ "version": "3.0.0",
4
4
  "private": false,
5
5
  "description": "Document-scoped interactive forms: reactive field state over doc.forms, fill-mode controls (FillItem projection), and form-data interchange. Widgets stay annotations; this plugin owns the field plane.",
6
6
  "type": "module",
@@ -12,24 +12,45 @@
12
12
  "import": "./dist/index.js",
13
13
  "require": "./dist/index.cjs"
14
14
  },
15
+ "./contract": {
16
+ "import": "./dist/contract.js",
17
+ "require": "./dist/contract.cjs"
18
+ },
19
+ "./contract/host": {
20
+ "import": "./dist/contract/host.js",
21
+ "require": "./dist/contract/host.cjs"
22
+ },
23
+ "./scripting": {
24
+ "import": "./dist/scripting.js",
25
+ "require": "./dist/scripting.cjs"
26
+ },
15
27
  "./package.json": "./package.json"
16
28
  },
17
29
  "files": [
18
30
  "dist"
19
31
  ],
20
32
  "dependencies": {
21
- "@embedpdf/core-acrojs": "3.0.0-next.9",
22
- "@embedpdf/core-js-sandbox": "3.0.0-next.9",
23
- "@embedpdf/core": "3.0.0-next.9",
24
- "@embedpdf/plugin-interaction": "3.0.0-next.9",
25
- "@embedpdf/plugin-annotation": "3.0.0-next.9",
26
- "@embedpdf/engine-core": "3.0.0-next.9"
33
+ "@embedpdf/core-acrojs": "3.0.0",
34
+ "@embedpdf/core-annotation": "3.0.0",
35
+ "@embedpdf/core-fonts": "3.0.0",
36
+ "@embedpdf/core-geometry": "3.0.0",
37
+ "@embedpdf/core": "3.0.0",
38
+ "@embedpdf/core-form": "3.0.0",
39
+ "@embedpdf/engine-core": "3.0.0",
40
+ "@embedpdf/core-js-sandbox": "3.0.0",
41
+ "@embedpdf/plugin-actions": "3.0.0",
42
+ "@embedpdf/plugin-annotation": "3.0.0",
43
+ "@embedpdf/plugin-fonts": "3.0.0",
44
+ "@embedpdf/plugin-render": "3.0.0",
45
+ "@embedpdf/plugin-stage": "3.0.0",
46
+ "@embedpdf/plugin-interaction": "3.0.0"
27
47
  },
28
48
  "devDependencies": {
29
49
  "typescript": "^5.0.0",
30
50
  "vitest": "^2.1.9",
31
- "@embedpdf/engine": "3.0.0-next.9",
32
- "@embedpdf/tooling-build": "0.0.0"
51
+ "@embedpdf/tooling-build": "0.0.0",
52
+ "@embedpdf/engine": "3.0.0",
53
+ "@embedpdf/plugin-history": "3.0.0"
33
54
  },
34
55
  "license": "Apache-2.0",
35
56
  "sideEffects": false,