@embedpdf/plugin-page-edit 3.0.0-next.14 → 3.0.0-next.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,25 @@
1
+ //#region src/token.ts
2
+ /** The package token, created once here and re-exported by `contract.ts`. */
3
+ const PageEditToken = (0, require("@embedpdf/core").createCapabilityToken)("page-edit", {
4
+ hint: `add pageEditPlugin() from '@embedpdf/plugin-page-edit' to your plugins list`,
5
+ promises: {
6
+ rotateBy: true,
7
+ setRotation: true,
8
+ reorder: true,
9
+ delete: true,
10
+ insertBlank: true,
11
+ insertFromBytes: true,
12
+ insertFromDocument: true,
13
+ duplicate: true,
14
+ extract: true
15
+ }
16
+ });
17
+ //#endregion
18
+ Object.defineProperty(exports, "PageEditToken", {
19
+ enumerable: true,
20
+ get: function() {
21
+ return PageEditToken;
22
+ }
23
+ });
24
+
25
+ //# sourceMappingURL=contract-B4DeVaKv.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract-B4DeVaKv.cjs","names":[],"sources":["../src/token.ts"],"sourcesContent":["/** The package token, created once here and re-exported by `contract.ts`. */\nimport { createCapabilityToken } from '@embedpdf/core';\n\nimport type { PageEditCapability } from './contract';\n\nexport const PageEditToken = createCapabilityToken<PageEditCapability>('page-edit', {\n hint: `add pageEditPlugin() from '@embedpdf/plugin-page-edit' to your plugins list`,\n // Without a document, an adapter's stand-in rejects these with `not-ready`, as the\n // capability would; the type asks for every member that returns a promise.\n promises: {\n rotateBy: true,\n setRotation: true,\n reorder: true,\n delete: true,\n insertBlank: true,\n insertFromBytes: true,\n insertFromDocument: true,\n duplicate: true,\n extract: true,\n },\n});\n"],"mappings":";;AAKA,MAAa,iBAAA,2BAAA,CAAA,CAAA,sBAAA,CAA0D,aAAa;CAClF,MAAM;CAGN,UAAU;EACR,UAAU;EACV,aAAa;EACb,SAAS;EACT,QAAQ;EACR,aAAa;EACb,iBAAiB;EACjB,oBAAoB;EACpB,WAAW;EACX,SAAS;CACX;AACF,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { createCapabilityToken } from "@embedpdf/core";
2
+ //#region src/token.ts
3
+ /** The package token, created once here and re-exported by `contract.ts`. */
4
+ const PageEditToken = createCapabilityToken("page-edit", {
5
+ hint: `add pageEditPlugin() from '@embedpdf/plugin-page-edit' to your plugins list`,
6
+ promises: {
7
+ rotateBy: true,
8
+ setRotation: true,
9
+ reorder: true,
10
+ delete: true,
11
+ insertBlank: true,
12
+ insertFromBytes: true,
13
+ insertFromDocument: true,
14
+ duplicate: true,
15
+ extract: true
16
+ }
17
+ });
18
+ //#endregion
19
+ export { PageEditToken as t };
20
+
21
+ //# sourceMappingURL=contract-CYWYR5Pd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract-CYWYR5Pd.js","names":[],"sources":["../src/token.ts"],"sourcesContent":["/** The package token, created once here and re-exported by `contract.ts`. */\nimport { createCapabilityToken } from '@embedpdf/core';\n\nimport type { PageEditCapability } from './contract';\n\nexport const PageEditToken = createCapabilityToken<PageEditCapability>('page-edit', {\n hint: `add pageEditPlugin() from '@embedpdf/plugin-page-edit' to your plugins list`,\n // Without a document, an adapter's stand-in rejects these with `not-ready`, as the\n // capability would; the type asks for every member that returns a promise.\n promises: {\n rotateBy: true,\n setRotation: true,\n reorder: true,\n delete: true,\n insertBlank: true,\n insertFromBytes: true,\n insertFromDocument: true,\n duplicate: true,\n extract: true,\n },\n});\n"],"mappings":";;;AAKA,MAAa,gBAAgB,sBAA0C,aAAa;CAClF,MAAM;CAGN,UAAU;EACR,UAAU;EACV,aAAa;EACb,SAAS;EACT,QAAQ;EACR,aAAa;EACb,iBAAiB;EACjB,oBAAoB;EACpB,WAAW;EACX,SAAS;CACX;AACF,CAAC"}
@@ -0,0 +1,91 @@
1
+ import { OperationOptions, PagePosition, PagePosition as PagePosition$1, PageRef, PdfRotation, PdfRotation as PdfRotation$1, PdfSize, PdfSize as PdfSize$1 } from "@embedpdf/core";
2
+ //#region src/token.d.ts
3
+ declare const PageEditToken: import("@embedpdf/core").CapabilityToken<PageEditCapability>;
4
+ //#endregion
5
+ //#region src/contract.d.ts
6
+ /** What an insert resolves: the new pages, in the order they were inserted. */
7
+ interface PageEditInsertResult {
8
+ readonly pages: readonly PageRef[];
9
+ }
10
+ /** Options of `insertBlank()`. */
11
+ interface PageInsertBlankOptions extends OperationOptions {
12
+ /** Where the new pages go. Default `'end'`. */
13
+ readonly position?: PagePosition;
14
+ /** The page size, in points. Default: the size of the page the new pages go next to. */
15
+ readonly size?: PdfSize;
16
+ /** How many blank pages. Default 1. */
17
+ readonly count?: number;
18
+ }
19
+ /** Options of `insertFromBytes()`. */
20
+ interface PageInsertFromBytesOptions extends OperationOptions {
21
+ /** Only the source PDF's pages at these indexes, in this order. Default: every page. */
22
+ readonly pageIndexes?: readonly number[];
23
+ /** Where the new pages go. Default `'end'`. */
24
+ readonly position?: PagePosition;
25
+ }
26
+ /** Options of the verbs that copy pages in: `insertFromDocument()` and `duplicate()`. */
27
+ interface PagePositionOptions extends OperationOptions {
28
+ readonly position?: PagePosition;
29
+ }
30
+ /**
31
+ * Every edit is one change: one step of the history, so undo brings the
32
+ * pages back as they were, a deleted page with its annotations under its old
33
+ * ref. It shows once the engine answers. Edits apply in the order they were
34
+ * called, except that the verbs that copy pages first (`duplicate()`,
35
+ * `insertFromDocument()`, `insertFromBytes()` with `pageIndexes`) take their
36
+ * place once the copy is made.
37
+ *
38
+ * Every verb rejects `permission-denied` (with `error.permission`) when the
39
+ * session may not do it, `not-found` for a page the document doesn't have and
40
+ * `invalid-input` for no pages; a refusal changes nothing. An edit the engine
41
+ * refuses rejects with the engine's reason. When the `signal` fires the verb
42
+ * rejects `operation-cancelled`: before its change is made nothing changes,
43
+ * after it the change still applies.
44
+ */
45
+ interface PageEditCapability {
46
+ /** Whether rotating, reordering, deleting and inserting pages is allowed (`doc.pages.assemble`). */
47
+ canEdit(): boolean;
48
+ /**
49
+ * Whether copying pages out is allowed (`doc.download`): `extract()`,
50
+ * `duplicate()` and `insertFromDocument()` need it.
51
+ */
52
+ canExtract(): boolean;
53
+ /** The selected pages, in the order they were selected; pages the document no longer has drop out. */
54
+ getSelected(): readonly PageRef[];
55
+ /** Make these pages the selection; `[]` clears it. Pages the document doesn't have are left out. */
56
+ select(pages: readonly (PageRef | number)[]): void;
57
+ /**
58
+ * Turn each page by a quarter or half turn from its rotation, the one it
59
+ * has once the edits on their way apply: two quick quarter turns are a
60
+ * half turn.
61
+ */
62
+ rotateBy(pages: readonly (PageRef | number)[], delta: 90 | -90 | 180, options?: OperationOptions): Promise<void>;
63
+ /** Give every page the same rotation. */
64
+ setRotation(pages: readonly (PageRef | number)[], rotation: PdfRotation, options?: OperationOptions): Promise<void>;
65
+ /** Move pages to `position`; several pages keep their order and land together. */
66
+ reorder(pages: readonly (PageRef | number)[], position: PagePosition, options?: OperationOptions): Promise<void>;
67
+ /** Delete pages. Deleting every page is refused (`invalid-input`): a document keeps one. */
68
+ delete(pages: readonly (PageRef | number)[], options?: OperationOptions): Promise<void>;
69
+ /** Insert blank pages, one unless `count` says more. */
70
+ insertBlank(options?: PageInsertBlankOptions): Promise<PageEditInsertResult>;
71
+ /** Insert the pages of another PDF, or only the ones at `pageIndexes`. */
72
+ insertFromBytes(bytes: Uint8Array | ArrayBuffer, options?: PageInsertFromBytesOptions): Promise<PageEditInsertResult>;
73
+ /**
74
+ * Insert copies of pages from another document open in the viewer. Needs
75
+ * `doc.download` on that document and `doc.pages.assemble` on this one.
76
+ */
77
+ insertFromDocument(documentId: string, pages: readonly (PageRef | number)[], options?: PagePositionOptions): Promise<PageEditInsertResult>;
78
+ /**
79
+ * Copy pages as they show, with the edits on their way, right after the
80
+ * last of them unless `position` says otherwise.
81
+ */
82
+ duplicate(pages: readonly (PageRef | number)[], options?: PagePositionOptions): Promise<PageEditInsertResult>;
83
+ /**
84
+ * Copy pages into a new PDF, as they show with the edits on their way, and
85
+ * resolve its bytes. This document doesn't change.
86
+ */
87
+ extract(pages: readonly (PageRef | number)[], options?: OperationOptions): Promise<Uint8Array>;
88
+ }
89
+ //#endregion
90
+ export { PagePosition$1 as a, PdfSize$1 as c, PageInsertFromBytesOptions as i, PageEditToken as l, PageEditInsertResult as n, PagePositionOptions as o, PageInsertBlankOptions as r, PdfRotation$1 as s, PageEditCapability as t };
91
+ //# sourceMappingURL=contract-IN8rk5LG.d.cts.map
@@ -0,0 +1,91 @@
1
+ import { OperationOptions, PagePosition, PagePosition as PagePosition$1, PageRef, PdfRotation, PdfRotation as PdfRotation$1, PdfSize, PdfSize as PdfSize$1 } from "@embedpdf/core";
2
+ //#region src/token.d.ts
3
+ declare const PageEditToken: import("@embedpdf/core").CapabilityToken<PageEditCapability>;
4
+ //#endregion
5
+ //#region src/contract.d.ts
6
+ /** What an insert resolves: the new pages, in the order they were inserted. */
7
+ interface PageEditInsertResult {
8
+ readonly pages: readonly PageRef[];
9
+ }
10
+ /** Options of `insertBlank()`. */
11
+ interface PageInsertBlankOptions extends OperationOptions {
12
+ /** Where the new pages go. Default `'end'`. */
13
+ readonly position?: PagePosition;
14
+ /** The page size, in points. Default: the size of the page the new pages go next to. */
15
+ readonly size?: PdfSize;
16
+ /** How many blank pages. Default 1. */
17
+ readonly count?: number;
18
+ }
19
+ /** Options of `insertFromBytes()`. */
20
+ interface PageInsertFromBytesOptions extends OperationOptions {
21
+ /** Only the source PDF's pages at these indexes, in this order. Default: every page. */
22
+ readonly pageIndexes?: readonly number[];
23
+ /** Where the new pages go. Default `'end'`. */
24
+ readonly position?: PagePosition;
25
+ }
26
+ /** Options of the verbs that copy pages in: `insertFromDocument()` and `duplicate()`. */
27
+ interface PagePositionOptions extends OperationOptions {
28
+ readonly position?: PagePosition;
29
+ }
30
+ /**
31
+ * Every edit is one change: one step of the history, so undo brings the
32
+ * pages back as they were, a deleted page with its annotations under its old
33
+ * ref. It shows once the engine answers. Edits apply in the order they were
34
+ * called, except that the verbs that copy pages first (`duplicate()`,
35
+ * `insertFromDocument()`, `insertFromBytes()` with `pageIndexes`) take their
36
+ * place once the copy is made.
37
+ *
38
+ * Every verb rejects `permission-denied` (with `error.permission`) when the
39
+ * session may not do it, `not-found` for a page the document doesn't have and
40
+ * `invalid-input` for no pages; a refusal changes nothing. An edit the engine
41
+ * refuses rejects with the engine's reason. When the `signal` fires the verb
42
+ * rejects `operation-cancelled`: before its change is made nothing changes,
43
+ * after it the change still applies.
44
+ */
45
+ interface PageEditCapability {
46
+ /** Whether rotating, reordering, deleting and inserting pages is allowed (`doc.pages.assemble`). */
47
+ canEdit(): boolean;
48
+ /**
49
+ * Whether copying pages out is allowed (`doc.download`): `extract()`,
50
+ * `duplicate()` and `insertFromDocument()` need it.
51
+ */
52
+ canExtract(): boolean;
53
+ /** The selected pages, in the order they were selected; pages the document no longer has drop out. */
54
+ getSelected(): readonly PageRef[];
55
+ /** Make these pages the selection; `[]` clears it. Pages the document doesn't have are left out. */
56
+ select(pages: readonly (PageRef | number)[]): void;
57
+ /**
58
+ * Turn each page by a quarter or half turn from its rotation, the one it
59
+ * has once the edits on their way apply: two quick quarter turns are a
60
+ * half turn.
61
+ */
62
+ rotateBy(pages: readonly (PageRef | number)[], delta: 90 | -90 | 180, options?: OperationOptions): Promise<void>;
63
+ /** Give every page the same rotation. */
64
+ setRotation(pages: readonly (PageRef | number)[], rotation: PdfRotation, options?: OperationOptions): Promise<void>;
65
+ /** Move pages to `position`; several pages keep their order and land together. */
66
+ reorder(pages: readonly (PageRef | number)[], position: PagePosition, options?: OperationOptions): Promise<void>;
67
+ /** Delete pages. Deleting every page is refused (`invalid-input`): a document keeps one. */
68
+ delete(pages: readonly (PageRef | number)[], options?: OperationOptions): Promise<void>;
69
+ /** Insert blank pages, one unless `count` says more. */
70
+ insertBlank(options?: PageInsertBlankOptions): Promise<PageEditInsertResult>;
71
+ /** Insert the pages of another PDF, or only the ones at `pageIndexes`. */
72
+ insertFromBytes(bytes: Uint8Array | ArrayBuffer, options?: PageInsertFromBytesOptions): Promise<PageEditInsertResult>;
73
+ /**
74
+ * Insert copies of pages from another document open in the viewer. Needs
75
+ * `doc.download` on that document and `doc.pages.assemble` on this one.
76
+ */
77
+ insertFromDocument(documentId: string, pages: readonly (PageRef | number)[], options?: PagePositionOptions): Promise<PageEditInsertResult>;
78
+ /**
79
+ * Copy pages as they show, with the edits on their way, right after the
80
+ * last of them unless `position` says otherwise.
81
+ */
82
+ duplicate(pages: readonly (PageRef | number)[], options?: PagePositionOptions): Promise<PageEditInsertResult>;
83
+ /**
84
+ * Copy pages into a new PDF, as they show with the edits on their way, and
85
+ * resolve its bytes. This document doesn't change.
86
+ */
87
+ extract(pages: readonly (PageRef | number)[], options?: OperationOptions): Promise<Uint8Array>;
88
+ }
89
+ //#endregion
90
+ export { PagePosition$1 as a, PdfSize$1 as c, PageInsertFromBytesOptions as i, PageEditToken as l, PageEditInsertResult as n, PagePositionOptions as o, PageInsertBlankOptions as r, PdfRotation$1 as s, PageEditCapability as t };
91
+ //# sourceMappingURL=contract-IN8rk5LG.d.ts.map
package/dist/contract.cjs CHANGED
@@ -1,3 +1,3 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_contract = require("./contract-UeGRCn-t.cjs");
2
+ const require_contract = require("./contract-B4DeVaKv.cjs");
3
3
  exports.PageEditToken = require_contract.PageEditToken;
@@ -1,2 +1,2 @@
1
- import { n as PageEditToken, t as PageEditCapability } from "./contract-BnXi11KD.cjs";
2
- export { type PageEditCapability, PageEditToken };
1
+ import { a as PagePosition, c as PdfSize, i as PageInsertFromBytesOptions, l as PageEditToken, n as PageEditInsertResult, o as PagePositionOptions, r as PageInsertBlankOptions, s as PdfRotation, t as PageEditCapability } from "./contract-IN8rk5LG.cjs";
2
+ export { PageEditCapability, PageEditInsertResult, PageEditToken, PageInsertBlankOptions, PageInsertFromBytesOptions, type PagePosition, PagePositionOptions, type PdfRotation, type PdfSize };
@@ -1,2 +1,2 @@
1
- import { n as PageEditToken, t as PageEditCapability } from "./contract-BnXi11KD.js";
2
- export { type PageEditCapability, PageEditToken };
1
+ import { a as PagePosition, c as PdfSize, i as PageInsertFromBytesOptions, l as PageEditToken, n as PageEditInsertResult, o as PagePositionOptions, r as PageInsertBlankOptions, s as PdfRotation, t as PageEditCapability } from "./contract-IN8rk5LG.js";
2
+ export { PageEditCapability, PageEditInsertResult, PageEditToken, PageInsertBlankOptions, PageInsertFromBytesOptions, type PagePosition, PagePositionOptions, type PdfRotation, type PdfSize };
package/dist/contract.js CHANGED
@@ -1,2 +1,2 @@
1
- import { t as PageEditToken } from "./contract-BsNelyd8.js";
1
+ import { t as PageEditToken } from "./contract-CYWYR5Pd.js";
2
2
  export { PageEditToken };