@embedpdf/react 3.0.0-next.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.
Files changed (141) hide show
  1. package/LICENSE +192 -0
  2. package/dist/AnnotationListSnapshot-W0RCsyDE-dWna4TTJ.d.cts +2593 -0
  3. package/dist/AnnotationListSnapshot-W0RCsyDE-dWna4TTJ.d.ts +2593 -0
  4. package/dist/annotation-B6jwfTCh.d.cts +173 -0
  5. package/dist/annotation-Ct6dFtzJ.cjs +913 -0
  6. package/dist/annotation-Ct6dFtzJ.cjs.map +1 -0
  7. package/dist/annotation-DjGWJljY.js +829 -0
  8. package/dist/annotation-DjGWJljY.js.map +1 -0
  9. package/dist/annotation-menu.cjs +115 -0
  10. package/dist/annotation-menu.cjs.map +1 -0
  11. package/dist/annotation-menu.d.cts +7 -0
  12. package/dist/annotation-menu.d.ts +7 -0
  13. package/dist/annotation-menu.js +99 -0
  14. package/dist/annotation-menu.js.map +1 -0
  15. package/dist/annotation-nUMefyjw.d.ts +173 -0
  16. package/dist/annotation.cjs +25 -0
  17. package/dist/annotation.d.cts +3 -0
  18. package/dist/annotation.d.ts +3 -0
  19. package/dist/annotation.js +4 -0
  20. package/dist/commands.cjs +59 -0
  21. package/dist/commands.cjs.map +1 -0
  22. package/dist/commands.d.cts +20 -0
  23. package/dist/commands.d.ts +20 -0
  24. package/dist/commands.js +47 -0
  25. package/dist/commands.js.map +1 -0
  26. package/dist/form.cjs +560 -0
  27. package/dist/form.cjs.map +1 -0
  28. package/dist/form.d.cts +52 -0
  29. package/dist/form.d.ts +52 -0
  30. package/dist/form.js +545 -0
  31. package/dist/form.js.map +1 -0
  32. package/dist/i18n.cjs +52 -0
  33. package/dist/i18n.cjs.map +1 -0
  34. package/dist/i18n.d.cts +30 -0
  35. package/dist/i18n.d.ts +30 -0
  36. package/dist/i18n.js +42 -0
  37. package/dist/i18n.js.map +1 -0
  38. package/dist/index.cjs +240 -0
  39. package/dist/index.d.cts +37 -0
  40. package/dist/index.d.ts +37 -0
  41. package/dist/index.js +37 -0
  42. package/dist/interaction.cjs +152 -0
  43. package/dist/interaction.cjs.map +1 -0
  44. package/dist/interaction.d.cts +46 -0
  45. package/dist/interaction.d.ts +46 -0
  46. package/dist/interaction.js +139 -0
  47. package/dist/interaction.js.map +1 -0
  48. package/dist/link.cjs +108 -0
  49. package/dist/link.cjs.map +1 -0
  50. package/dist/link.d.cts +16 -0
  51. package/dist/link.d.ts +16 -0
  52. package/dist/link.js +98 -0
  53. package/dist/link.js.map +1 -0
  54. package/dist/metadata.cjs +25 -0
  55. package/dist/metadata.cjs.map +1 -0
  56. package/dist/metadata.d.cts +11 -0
  57. package/dist/metadata.d.ts +11 -0
  58. package/dist/metadata.js +16 -0
  59. package/dist/metadata.js.map +1 -0
  60. package/dist/page-edit.cjs +20 -0
  61. package/dist/page-edit.cjs.map +1 -0
  62. package/dist/page-edit.d.cts +7 -0
  63. package/dist/page-edit.d.ts +7 -0
  64. package/dist/page-edit.js +11 -0
  65. package/dist/page-edit.js.map +1 -0
  66. package/dist/page-view.cjs +107 -0
  67. package/dist/page-view.cjs.map +1 -0
  68. package/dist/page-view.d.cts +23 -0
  69. package/dist/page-view.d.ts +23 -0
  70. package/dist/page-view.js +95 -0
  71. package/dist/page-view.js.map +1 -0
  72. package/dist/redaction.cjs +35 -0
  73. package/dist/redaction.cjs.map +1 -0
  74. package/dist/redaction.d.cts +14 -0
  75. package/dist/redaction.d.ts +14 -0
  76. package/dist/redaction.js +25 -0
  77. package/dist/redaction.js.map +1 -0
  78. package/dist/render.cjs +142 -0
  79. package/dist/render.cjs.map +1 -0
  80. package/dist/render.d.cts +32 -0
  81. package/dist/render.d.ts +32 -0
  82. package/dist/render.js +131 -0
  83. package/dist/render.js.map +1 -0
  84. package/dist/rolldown-runtime-DDXJien1.cjs +50 -0
  85. package/dist/runtime-CMxIuF2O.d.cts +195 -0
  86. package/dist/runtime-DV98q7I0.d.ts +195 -0
  87. package/dist/runtime.cjs +314 -0
  88. package/dist/runtime.cjs.map +1 -0
  89. package/dist/runtime.d.cts +3 -0
  90. package/dist/runtime.d.ts +3 -0
  91. package/dist/runtime.js +287 -0
  92. package/dist/runtime.js.map +1 -0
  93. package/dist/scrollbar.cjs +241 -0
  94. package/dist/scrollbar.cjs.map +1 -0
  95. package/dist/scrollbar.d.cts +42 -0
  96. package/dist/scrollbar.d.ts +42 -0
  97. package/dist/scrollbar.js +213 -0
  98. package/dist/scrollbar.js.map +1 -0
  99. package/dist/search.cjs +70 -0
  100. package/dist/search.cjs.map +1 -0
  101. package/dist/search.d.cts +35 -0
  102. package/dist/search.d.ts +35 -0
  103. package/dist/search.js +58 -0
  104. package/dist/search.js.map +1 -0
  105. package/dist/selection.cjs +60 -0
  106. package/dist/selection.cjs.map +1 -0
  107. package/dist/selection.d.cts +12 -0
  108. package/dist/selection.d.ts +12 -0
  109. package/dist/selection.js +49 -0
  110. package/dist/selection.js.map +1 -0
  111. package/dist/shell.cjs +57 -0
  112. package/dist/shell.cjs.map +1 -0
  113. package/dist/shell.d.cts +27 -0
  114. package/dist/shell.d.ts +27 -0
  115. package/dist/shell.js +46 -0
  116. package/dist/shell.js.map +1 -0
  117. package/dist/stage.cjs +343 -0
  118. package/dist/stage.cjs.map +1 -0
  119. package/dist/stage.d.cts +104 -0
  120. package/dist/stage.d.ts +104 -0
  121. package/dist/stage.js +327 -0
  122. package/dist/stage.js.map +1 -0
  123. package/dist/stamp.cjs +76 -0
  124. package/dist/stamp.cjs.map +1 -0
  125. package/dist/stamp.d.cts +28 -0
  126. package/dist/stamp.d.ts +28 -0
  127. package/dist/stamp.js +63 -0
  128. package/dist/stamp.js.map +1 -0
  129. package/dist/toolbar.cjs +515 -0
  130. package/dist/toolbar.cjs.map +1 -0
  131. package/dist/toolbar.d.cts +100 -0
  132. package/dist/toolbar.d.ts +100 -0
  133. package/dist/toolbar.js +505 -0
  134. package/dist/toolbar.js.map +1 -0
  135. package/dist/views.cjs +35 -0
  136. package/dist/views.cjs.map +1 -0
  137. package/dist/views.d.cts +21 -0
  138. package/dist/views.d.ts +21 -0
  139. package/dist/views.js +26 -0
  140. package/dist/views.js.map +1 -0
  141. package/package.json +158 -0
package/dist/link.js ADDED
@@ -0,0 +1,98 @@
1
+ import { shallowArray, useCapability, usePage, useSelector } from "./runtime.js";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { useEffect } from "react";
5
+ import { sanitizeExternalUri } from "@embedpdf/web";
6
+ import { LinkToken } from "@embedpdf/plugin-link";
7
+ export * from "@embedpdf/plugin-link";
8
+ //#region src/link.tsx
9
+ /** Content rect → view px (the page wrapper's own space) — the same idiom as
10
+ * the annotation and form layers: never re-derive `x * scale`. */
11
+ function boxOf(item, page) {
12
+ const tl = page.transform.pageToContent({
13
+ x: item.rect.x,
14
+ y: item.rect.y
15
+ });
16
+ const br = page.transform.pageToContent({
17
+ x: item.rect.x + item.rect.width,
18
+ y: item.rect.y + item.rect.height
19
+ });
20
+ return {
21
+ left: tl.x,
22
+ top: tl.y,
23
+ width: br.x - tl.x,
24
+ height: br.y - tl.y
25
+ };
26
+ }
27
+ /** A human label for the hover tooltip. Apps with i18n render their own via
28
+ * `renderLink`; this is the sensible default. */
29
+ function labelOf(item) {
30
+ switch (item.target.kind) {
31
+ case "uri": return item.target.uri;
32
+ case "goto": return "Go to destination";
33
+ case "named": return item.target.name;
34
+ default: return "Link";
35
+ }
36
+ }
37
+ function LinkLayer({ renderLink } = {}) {
38
+ const page = usePage();
39
+ const link = useCapability(LinkToken);
40
+ const items = useSelector(LinkToken, (c) => c.linksOn(page.pon), shallowArray);
41
+ const engaged = useSelector(LinkToken, (c) => c.engaged());
42
+ useEffect(() => {
43
+ link.ensurePage(page.pon);
44
+ }, [link, page.pon]);
45
+ if (!engaged || !items.length) return null;
46
+ return /* @__PURE__ */ jsx("div", {
47
+ style: {
48
+ position: "absolute",
49
+ inset: 0,
50
+ pointerEvents: "none"
51
+ },
52
+ children: items.map((item) => {
53
+ const box = boxOf(item, page);
54
+ const native = /* @__PURE__ */ jsx("a", {
55
+ href: (item.target.kind === "uri" ? sanitizeExternalUri(item.target.uri) : null) ?? void 0,
56
+ target: "_blank",
57
+ rel: "noopener noreferrer",
58
+ role: "link",
59
+ tabIndex: 0,
60
+ title: labelOf(item),
61
+ "aria-label": labelOf(item),
62
+ onClick: (e) => {
63
+ if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;
64
+ e.preventDefault();
65
+ link.activate(item.target);
66
+ },
67
+ onKeyDown: (e) => {
68
+ if (e.key === "Enter" || e.key === " ") {
69
+ e.preventDefault();
70
+ link.activate(item.target);
71
+ }
72
+ },
73
+ onPointerDown: (e) => e.stopPropagation(),
74
+ style: {
75
+ position: "absolute",
76
+ left: box.left,
77
+ top: box.top,
78
+ width: box.width,
79
+ height: box.height,
80
+ cursor: "pointer",
81
+ pointerEvents: "auto"
82
+ }
83
+ });
84
+ const out = renderLink?.({
85
+ item,
86
+ nativeComponent: native
87
+ }) ?? native;
88
+ return /* @__PURE__ */ jsx(React.Fragment, { children: out }, item.id);
89
+ })
90
+ });
91
+ }
92
+ function useLink() {
93
+ return useCapability(LinkToken);
94
+ }
95
+ //#endregion
96
+ export { LinkLayer, useLink };
97
+
98
+ //# sourceMappingURL=link.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"link.js","names":[],"sources":["../src/link.tsx"],"sourcesContent":["/**\n * The React view of @embedpdf/plugin-link — the navigation plane's paint.\n *\n * One absolutely-positioned <a> per clickable link area, real anchors on\n * purpose: URIs get an `href` (middle-click, copy-link, status-bar preview\n * and keyboard focus for free), internal destinations activate through the\n * plugin (stage reveal). The layer stands down entirely while the active\n * tool doesn't enable `link-nav` — the annotation plane owns links then\n * (select / move / resize / retarget through the selection editor).\n */\n\n// One-line-per-feature: registration travels with the UI.\nexport * from '@embedpdf/plugin-link';\nimport * as React from 'react';\nimport { useEffect } from 'react';\nimport { LinkToken, type LinkNavItem } from '@embedpdf/plugin-link';\nimport { sanitizeExternalUri } from '@embedpdf/web';\n\nimport { shallowArray, useCapability, usePage, useSelector } from './runtime';\nimport type { PageContextValue } from './runtime';\n\n/** Content rect → view px (the page wrapper's own space) — the same idiom as\n * the annotation and form layers: never re-derive `x * scale`. */\nfunction boxOf(item: LinkNavItem, page: PageContextValue) {\n const tl = page.transform.pageToContent({ x: item.rect.x, y: item.rect.y });\n const br = page.transform.pageToContent({\n x: item.rect.x + item.rect.width,\n y: item.rect.y + item.rect.height,\n });\n return { left: tl.x, top: tl.y, width: br.x - tl.x, height: br.y - tl.y };\n}\n\n/** A human label for the hover tooltip. Apps with i18n render their own via\n * `renderLink`; this is the sensible default. */\nfunction labelOf(item: LinkNavItem): string {\n switch (item.target.kind) {\n case 'uri':\n return item.target.uri;\n case 'goto':\n return 'Go to destination';\n case 'named':\n return item.target.name;\n default:\n return 'Link';\n }\n}\n\nexport interface LinkLayerProps {\n /** Wrap or replace a link's native anchor (badging, custom tooltips). */\n renderLink?: (args: {\n item: LinkNavItem;\n nativeComponent: React.ReactNode;\n }) => React.ReactNode | undefined;\n}\n\nexport function LinkLayer({ renderLink }: LinkLayerProps = {}) {\n const page = usePage();\n const link = useCapability(LinkToken);\n const items = useSelector(LinkToken, (c) => c.linksOn(page.pon), shallowArray);\n const engaged = useSelector(LinkToken, (c) => c.engaged());\n\n useEffect(() => {\n link.ensurePage(page.pon);\n }, [link, page.pon]);\n\n // An authoring tool is active → the annotation plane owns links (they're\n // plain editable rects there); no nav anchors, no swallowed pointer events.\n if (!engaged || !items.length) return null;\n\n return (\n <div style={{ position: 'absolute', inset: 0, pointerEvents: 'none' }}>\n {items.map((item) => {\n const box = boxOf(item, page);\n // Real href ONLY for sanitized external URIs; blocked schemes and\n // internal targets activate through the plugin instead.\n const href = item.target.kind === 'uri' ? sanitizeExternalUri(item.target.uri) : null;\n const native = (\n <a\n href={href ?? undefined}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n role=\"link\"\n tabIndex={0}\n title={labelOf(item)}\n aria-label={labelOf(item)}\n onClick={(e) => {\n // Plain left-click activates through the plugin (stage reveal /\n // policy / analytics). Modified clicks and middle-clicks on a\n // real href keep their native browser behaviour.\n if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;\n e.preventDefault();\n link.activate(item.target);\n }}\n onKeyDown={(e) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n link.activate(item.target);\n }\n }}\n // Keep the hub out of it: a down inside the anchor must not reach\n // the Stage's native listener (same isolation idiom as FreeText).\n onPointerDown={(e) => e.stopPropagation()}\n style={{\n position: 'absolute',\n left: box.left,\n top: box.top,\n width: box.width,\n height: box.height,\n cursor: 'pointer',\n pointerEvents: 'auto',\n }}\n />\n );\n const out = renderLink?.({ item, nativeComponent: native }) ?? native;\n return <React.Fragment key={item.id}>{out}</React.Fragment>;\n })}\n </div>\n );\n}\n\nexport function useLink() {\n return useCapability(LinkToken);\n}\n"],"mappings":";;;;;;;;;;AAuBA,SAAS,MAAM,MAAmB,MAAwB;CACxD,MAAM,KAAK,KAAK,UAAU,cAAc;EAAE,GAAG,KAAK,KAAK;EAAG,GAAG,KAAK,KAAK;CAAE,CAAC;CAC1E,MAAM,KAAK,KAAK,UAAU,cAAc;EACtC,GAAG,KAAK,KAAK,IAAI,KAAK,KAAK;EAC3B,GAAG,KAAK,KAAK,IAAI,KAAK,KAAK;CAC7B,CAAC;CACD,OAAO;EAAE,MAAM,GAAG;EAAG,KAAK,GAAG;EAAG,OAAO,GAAG,IAAI,GAAG;EAAG,QAAQ,GAAG,IAAI,GAAG;CAAE;AAC1E;;;AAIA,SAAS,QAAQ,MAA2B;CAC1C,QAAQ,KAAK,OAAO,MAApB;EACE,KAAK,OACH,OAAO,KAAK,OAAO;EACrB,KAAK,QACH,OAAO;EACT,KAAK,SACH,OAAO,KAAK,OAAO;EACrB,SACE,OAAO;CACX;AACF;AAUA,SAAgB,UAAU,EAAE,eAA+B,CAAC,GAAG;CAC7D,MAAM,OAAO,QAAQ;CACrB,MAAM,OAAO,cAAc,SAAS;CACpC,MAAM,QAAQ,YAAY,YAAY,MAAM,EAAE,QAAQ,KAAK,GAAG,GAAG,YAAY;CAC7E,MAAM,UAAU,YAAY,YAAY,MAAM,EAAE,QAAQ,CAAC;CAEzD,gBAAgB;EACd,KAAK,WAAW,KAAK,GAAG;CAC1B,GAAG,CAAC,MAAM,KAAK,GAAG,CAAC;CAInB,IAAI,CAAC,WAAW,CAAC,MAAM,QAAQ,OAAO;CAEtC,OACE,oBAAC,OAAD;EAAK,OAAO;GAAE,UAAU;GAAY,OAAO;GAAG,eAAe;EAAO;EACjE,UAAA,MAAM,KAAK,SAAS;GACnB,MAAM,MAAM,MAAM,MAAM,IAAI;GAI5B,MAAM,SACJ,oBAAC,KAAD;IACE,OAHS,KAAK,OAAO,SAAS,QAAQ,oBAAoB,KAAK,OAAO,GAAG,IAAI,SAG/D,KAAA;IACd,QAAO;IACP,KAAI;IACJ,MAAK;IACL,UAAU;IACV,OAAO,QAAQ,IAAI;IACnB,cAAY,QAAQ,IAAI;IACxB,UAAU,MAAM;KAId,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ;KACtD,EAAE,eAAe;KACjB,KAAK,SAAS,KAAK,MAAM;IAC3B;IACA,YAAY,MAAM;KAChB,IAAI,EAAE,QAAQ,WAAW,EAAE,QAAQ,KAAK;MACtC,EAAE,eAAe;MACjB,KAAK,SAAS,KAAK,MAAM;KAC3B;IACF;IAGA,gBAAgB,MAAM,EAAE,gBAAgB;IACxC,OAAO;KACL,UAAU;KACV,MAAM,IAAI;KACV,KAAK,IAAI;KACT,OAAO,IAAI;KACX,QAAQ,IAAI;KACZ,QAAQ;KACR,eAAe;IACjB;GACD,CAAA;GAEH,MAAM,MAAM,aAAa;IAAE;IAAM,iBAAiB;GAAO,CAAC,KAAK;GAC/D,OAAO,oBAAC,MAAM,UAAP,EAAA,UAA+B,IAAoB,GAA9B,KAAK,EAAyB;EAC5D,CAAC;CACE,CAAA;AAET;AAEA,SAAgB,UAAU;CACxB,OAAO,cAAc,SAAS;AAChC"}
@@ -0,0 +1,25 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ require("./rolldown-runtime-DDXJien1.cjs");
3
+ const require_runtime = require("./runtime.cjs");
4
+ let _embedpdf_plugin_metadata = require("@embedpdf/plugin-metadata");
5
+ //#region src/metadata.ts
6
+ function useMetadata() {
7
+ const cap = require_runtime.useCapability(_embedpdf_plugin_metadata.MetadataToken);
8
+ return {
9
+ metadata: require_runtime.useSelector(_embedpdf_plugin_metadata.MetadataToken, (c) => c.current()),
10
+ update: cap.update,
11
+ canEdit: cap.canEdit
12
+ };
13
+ }
14
+ //#endregion
15
+ exports.useMetadata = useMetadata;
16
+ Object.keys(_embedpdf_plugin_metadata).forEach(function(k) {
17
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
18
+ enumerable: true,
19
+ get: function() {
20
+ return _embedpdf_plugin_metadata[k];
21
+ }
22
+ });
23
+ });
24
+
25
+ //# sourceMappingURL=metadata.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metadata.cjs","names":["useCapability","MetadataToken","useSelector"],"sources":["../src/metadata.ts"],"sourcesContent":["import { MetadataToken } from '@embedpdf/plugin-metadata';\nimport type { DocumentMetadata, MetadataPatch } from '@embedpdf/core';\nimport { useCapability, useSelector } from './runtime';\n\n/**\n * The document's metadata, bound to the surrounding `DocumentScope`. Reactive:\n * `metadata` updates from your own edits AND from remote (SSE) edits — the\n * plugin keeps it live off the document event stream.\n *\n * const { metadata, update } = useMetadata();\n * await update({ title: 'New title' }); // three-state patch; writes to the layer\n */\n\n// One-line-per-feature: registration travels with the UI.\nexport * from '@embedpdf/plugin-metadata';\nexport function useMetadata(): {\n metadata: DocumentMetadata | null;\n update: (patch: MetadataPatch) => Promise<void>;\n canEdit: () => boolean;\n} {\n const cap = useCapability(MetadataToken);\n const metadata = useSelector(MetadataToken, (c) => c.current());\n return { metadata, update: cap.update, canEdit: cap.canEdit };\n}\n"],"mappings":";;;;;AAeA,SAAgB,cAId;CACA,MAAM,MAAMA,gBAAAA,cAAcC,0BAAAA,aAAa;CAEvC,OAAO;EAAE,UADQC,gBAAAA,YAAYD,0BAAAA,gBAAgB,MAAM,EAAE,QAAQ,CAC7C;EAAG,QAAQ,IAAI;EAAQ,SAAS,IAAI;CAAQ;AAC9D"}
@@ -0,0 +1,11 @@
1
+ import { DocumentMetadata, MetadataPatch } from "@embedpdf/core";
2
+ export * from "@embedpdf/plugin-metadata";
3
+ //#region src/metadata.d.ts
4
+ declare function useMetadata(): {
5
+ metadata: DocumentMetadata | null;
6
+ update: (patch: MetadataPatch) => Promise<void>;
7
+ canEdit: () => boolean;
8
+ };
9
+ //#endregion
10
+ export { useMetadata };
11
+ //# sourceMappingURL=metadata.d.cts.map
@@ -0,0 +1,11 @@
1
+ import { DocumentMetadata, MetadataPatch } from "@embedpdf/core";
2
+ export * from "@embedpdf/plugin-metadata";
3
+ //#region src/metadata.d.ts
4
+ declare function useMetadata(): {
5
+ metadata: DocumentMetadata | null;
6
+ update: (patch: MetadataPatch) => Promise<void>;
7
+ canEdit: () => boolean;
8
+ };
9
+ //#endregion
10
+ export { useMetadata };
11
+ //# sourceMappingURL=metadata.d.ts.map
@@ -0,0 +1,16 @@
1
+ import { useCapability, useSelector } from "./runtime.js";
2
+ import { MetadataToken } from "@embedpdf/plugin-metadata";
3
+ export * from "@embedpdf/plugin-metadata";
4
+ //#region src/metadata.ts
5
+ function useMetadata() {
6
+ const cap = useCapability(MetadataToken);
7
+ return {
8
+ metadata: useSelector(MetadataToken, (c) => c.current()),
9
+ update: cap.update,
10
+ canEdit: cap.canEdit
11
+ };
12
+ }
13
+ //#endregion
14
+ export { useMetadata };
15
+
16
+ //# sourceMappingURL=metadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metadata.js","names":[],"sources":["../src/metadata.ts"],"sourcesContent":["import { MetadataToken } from '@embedpdf/plugin-metadata';\nimport type { DocumentMetadata, MetadataPatch } from '@embedpdf/core';\nimport { useCapability, useSelector } from './runtime';\n\n/**\n * The document's metadata, bound to the surrounding `DocumentScope`. Reactive:\n * `metadata` updates from your own edits AND from remote (SSE) edits — the\n * plugin keeps it live off the document event stream.\n *\n * const { metadata, update } = useMetadata();\n * await update({ title: 'New title' }); // three-state patch; writes to the layer\n */\n\n// One-line-per-feature: registration travels with the UI.\nexport * from '@embedpdf/plugin-metadata';\nexport function useMetadata(): {\n metadata: DocumentMetadata | null;\n update: (patch: MetadataPatch) => Promise<void>;\n canEdit: () => boolean;\n} {\n const cap = useCapability(MetadataToken);\n const metadata = useSelector(MetadataToken, (c) => c.current());\n return { metadata, update: cap.update, canEdit: cap.canEdit };\n}\n"],"mappings":";;;;AAeA,SAAgB,cAId;CACA,MAAM,MAAM,cAAc,aAAa;CAEvC,OAAO;EAAE,UADQ,YAAY,gBAAgB,MAAM,EAAE,QAAQ,CAC7C;EAAG,QAAQ,IAAI;EAAQ,SAAS,IAAI;CAAQ;AAC9D"}
@@ -0,0 +1,20 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ require("./rolldown-runtime-DDXJien1.cjs");
3
+ const require_runtime = require("./runtime.cjs");
4
+ let _embedpdf_plugin_page_edit = require("@embedpdf/plugin-page-edit");
5
+ //#region src/page-edit.ts
6
+ function usePageEditor() {
7
+ return require_runtime.useCapability(_embedpdf_plugin_page_edit.PageEditToken);
8
+ }
9
+ //#endregion
10
+ exports.usePageEditor = usePageEditor;
11
+ Object.keys(_embedpdf_plugin_page_edit).forEach(function(k) {
12
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
13
+ enumerable: true,
14
+ get: function() {
15
+ return _embedpdf_plugin_page_edit[k];
16
+ }
17
+ });
18
+ });
19
+
20
+ //# sourceMappingURL=page-edit.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page-edit.cjs","names":["useCapability","PageEditToken"],"sources":["../src/page-edit.ts"],"sourcesContent":["import { PageEditToken, type PageEditCapability } from '@embedpdf/plugin-page-edit';\nimport { useCapability } from './runtime';\n\n/**\n * The page-edit capability, bound to the surrounding `DocumentScope`.\n *\n * Thin idiomatic wrapper over `PageEditToken` — the relative→absolute rotation\n * and PON addressing live in the plugin, so this hook (and its Vue/Svelte/\n * Angular siblings) is pure binding sugar with no logic to drift.\n *\n * const editor = usePageEditor();\n * editor.rotateBy(page.pon, 90);\n * if (editor.canEdit()) { … }\n */\n\n// One-line-per-feature: registration travels with the UI.\nexport * from '@embedpdf/plugin-page-edit';\nexport function usePageEditor(): PageEditCapability {\n return useCapability(PageEditToken);\n}\n"],"mappings":";;;;;AAiBA,SAAgB,gBAAoC;CAClD,OAAOA,gBAAAA,cAAcC,2BAAAA,aAAa;AACpC"}
@@ -0,0 +1,7 @@
1
+ import { PageEditCapability } from "@embedpdf/plugin-page-edit";
2
+ export * from "@embedpdf/plugin-page-edit";
3
+ //#region src/page-edit.d.ts
4
+ declare function usePageEditor(): PageEditCapability;
5
+ //#endregion
6
+ export { usePageEditor };
7
+ //# sourceMappingURL=page-edit.d.cts.map
@@ -0,0 +1,7 @@
1
+ import { PageEditCapability } from "@embedpdf/plugin-page-edit";
2
+ export * from "@embedpdf/plugin-page-edit";
3
+ //#region src/page-edit.d.ts
4
+ declare function usePageEditor(): PageEditCapability;
5
+ //#endregion
6
+ export { usePageEditor };
7
+ //# sourceMappingURL=page-edit.d.ts.map
@@ -0,0 +1,11 @@
1
+ import { useCapability } from "./runtime.js";
2
+ import { PageEditToken } from "@embedpdf/plugin-page-edit";
3
+ export * from "@embedpdf/plugin-page-edit";
4
+ //#region src/page-edit.ts
5
+ function usePageEditor() {
6
+ return useCapability(PageEditToken);
7
+ }
8
+ //#endregion
9
+ export { usePageEditor };
10
+
11
+ //# sourceMappingURL=page-edit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page-edit.js","names":[],"sources":["../src/page-edit.ts"],"sourcesContent":["import { PageEditToken, type PageEditCapability } from '@embedpdf/plugin-page-edit';\nimport { useCapability } from './runtime';\n\n/**\n * The page-edit capability, bound to the surrounding `DocumentScope`.\n *\n * Thin idiomatic wrapper over `PageEditToken` — the relative→absolute rotation\n * and PON addressing live in the plugin, so this hook (and its Vue/Svelte/\n * Angular siblings) is pure binding sugar with no logic to drift.\n *\n * const editor = usePageEditor();\n * editor.rotateBy(page.pon, 90);\n * if (editor.canEdit()) { … }\n */\n\n// One-line-per-feature: registration travels with the UI.\nexport * from '@embedpdf/plugin-page-edit';\nexport function usePageEditor(): PageEditCapability {\n return useCapability(PageEditToken);\n}\n"],"mappings":";;;;AAiBA,SAAgB,gBAAoC;CAClD,OAAO,cAAc,aAAa;AACpC"}
@@ -0,0 +1,107 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_rolldown_runtime = require("./rolldown-runtime-DDXJien1.cjs");
3
+ const require_runtime = require("./runtime.cjs");
4
+ let react_jsx_runtime = require("react/jsx-runtime");
5
+ let react = require("react");
6
+ react = require_rolldown_runtime.__toESM(react, 1);
7
+ let _embedpdf_core_geometry = require("@embedpdf/core-geometry");
8
+ //#region src/page-view.tsx
9
+ /**
10
+ * <PageView> — a single page surface with NO Stage.
11
+ *
12
+ * Same layers + rotation + chrome frame as a `<Stage>` page, but no
13
+ * camera/scroll/zoom and, crucially, NO dependency on `@embedpdf/plugin-stage`.
14
+ * It builds its own `PageTransform` from a target content width and shares the
15
+ * exact `PageContext` seam, so every layer (RenderLayer, AnnotationLayer,
16
+ * PageAnnotationMenu, …) works here identically.
17
+ */
18
+ /** A single page surface with NO Stage — same layers + rotation + chrome frame,
19
+ * no camera/scroll/zoom. */
20
+ function PageView({ page, documentId, width = 240, pageFrame = _embedpdf_core_geometry.NO_FRAME, children, pageChrome, style }) {
21
+ const kernel = require_runtime.useKernel();
22
+ const active = require_runtime.useActiveDocumentId();
23
+ const ref = (0, react.useRef)(null);
24
+ const docId = documentId ?? active;
25
+ const meta = docId ? kernel.getState().core.documents[docId] : void 0;
26
+ const base = meta?.pages[page];
27
+ const pon = base?.pageObjectNumber ?? page + 1;
28
+ const rotation = base?.rotation ?? 0;
29
+ const dpr = typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1;
30
+ const transform = (0, react.useMemo)(() => (0, _embedpdf_core_geometry.pageTransform)({
31
+ pageSize: base ? {
32
+ width: base.size.width,
33
+ height: base.size.height
34
+ } : {
35
+ width: 1,
36
+ height: 1
37
+ },
38
+ rotation,
39
+ scale: base ? width / base.size.width : 1,
40
+ baseScale: 96 / 72 * (base?.userUnit ?? 1),
41
+ dpr
42
+ }), [
43
+ base?.size.width,
44
+ base?.size.height,
45
+ base?.userUnit,
46
+ rotation,
47
+ width,
48
+ dpr
49
+ ]);
50
+ const ctx = (0, react.useMemo)(() => require_runtime.makePageContext(docId ?? "", pon, page, pageFrame, transform, () => ref.current.getBoundingClientRect()), [
51
+ docId,
52
+ pon,
53
+ page,
54
+ pageFrame,
55
+ transform
56
+ ]);
57
+ if (!docId || !meta || !base) return null;
58
+ const t = transform;
59
+ const outerW = t.viewWidth + pageFrame.left + pageFrame.right;
60
+ const outerH = t.viewHeight + pageFrame.top + pageFrame.bottom;
61
+ const contentLeft = pageFrame.left + (t.viewWidth - t.contentWidth) / 2;
62
+ const contentTop = pageFrame.top + (t.viewHeight - t.contentHeight) / 2;
63
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_runtime.DocumentScope, {
64
+ id: docId,
65
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
66
+ style: {
67
+ position: "relative",
68
+ width: outerW,
69
+ height: outerH,
70
+ ...style
71
+ },
72
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_runtime.PageProvider, {
73
+ value: ctx,
74
+ children: [
75
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { style: {
76
+ position: "absolute",
77
+ left: pageFrame.left,
78
+ top: pageFrame.top,
79
+ width: t.viewWidth,
80
+ height: t.viewHeight,
81
+ boxShadow: "0 6px 18px rgba(0,0,0,.18)"
82
+ } }),
83
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
84
+ ref,
85
+ style: {
86
+ position: "absolute",
87
+ left: contentLeft,
88
+ top: contentTop,
89
+ width: t.contentWidth,
90
+ height: t.contentHeight,
91
+ background: "#fff",
92
+ transform: rotation ? `rotate(${rotation}deg)` : void 0,
93
+ userSelect: "none",
94
+ WebkitUserSelect: "none"
95
+ },
96
+ children
97
+ }),
98
+ pageChrome
99
+ ]
100
+ })
101
+ })
102
+ });
103
+ }
104
+ //#endregion
105
+ exports.PageView = PageView;
106
+
107
+ //# sourceMappingURL=page-view.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page-view.cjs","names":["NO_FRAME","useKernel","useActiveDocumentId","makePageContext","DocumentScope","PageProvider"],"sources":["../src/page-view.tsx"],"sourcesContent":["/**\n * <PageView> — a single page surface with NO Stage.\n *\n * Same layers + rotation + chrome frame as a `<Stage>` page, but no\n * camera/scroll/zoom and, crucially, NO dependency on `@embedpdf/plugin-stage`.\n * It builds its own `PageTransform` from a target content width and shares the\n * exact `PageContext` seam, so every layer (RenderLayer, AnnotationLayer,\n * PageAnnotationMenu, …) works here identically.\n */\nimport * as React from 'react';\nimport { useMemo, useRef } from 'react';\nimport { NO_FRAME, pageTransform, type PageFrame } from '@embedpdf/core-geometry';\nimport {\n DocumentScope,\n makePageContext,\n PageProvider,\n useActiveDocumentId,\n useKernel,\n} from './runtime';\n\nexport interface PageViewProps {\n page: number;\n /** Which document to show. Defaults to the active document. */\n documentId?: string;\n /** Target width for the page CONTENT; the display box is the rotated footprint. */\n width?: number;\n /** Reserved chrome bands around the page (screen px) — same model as `<Stage>`. */\n pageFrame?: PageFrame;\n /** Page-space content (rotates with the page). */\n children: React.ReactNode;\n /** Box-space chrome (label, border, …) — never rotated. Mirrors `<Stage pageChrome>`. */\n pageChrome?: React.ReactNode;\n style?: React.CSSProperties;\n}\n\n/** A single page surface with NO Stage — same layers + rotation + chrome frame,\n * no camera/scroll/zoom. */\nexport function PageView({\n page,\n documentId,\n width = 240,\n pageFrame = NO_FRAME,\n children,\n pageChrome,\n style,\n}: PageViewProps) {\n const kernel = useKernel();\n const active = useActiveDocumentId();\n const ref = useRef<HTMLDivElement>(null);\n const docId = documentId ?? active;\n const meta = docId ? kernel.getState().core.documents[docId] : undefined;\n const base = meta?.pages[page];\n const pon = base?.pageObjectNumber ?? page + 1;\n const rotation = base?.rotation ?? 0;\n const dpr = typeof window !== 'undefined' ? window.devicePixelRatio || 1 : 1;\n // Standalone (no Stage/camera): build the page's transform from the target\n // content `width` directly. `scale` is view px per point = width / pageWidthPts.\n const transform = useMemo(\n () =>\n pageTransform({\n pageSize: base\n ? { width: base.size.width, height: base.size.height }\n : { width: 1, height: 1 },\n rotation,\n scale: base ? width / base.size.width : 1,\n // Physical 100% on the web: 1pt = 96/72 CSS px, times the page's\n // /UserUnit — so `transform.zoom` is meaningful even without a Stage\n // (a thumbnail-sized PageView reads as zoomed out, as it should).\n baseScale: (96 / 72) * (base?.userUnit ?? 1),\n dpr,\n }),\n [base?.size.width, base?.size.height, base?.userUnit, rotation, width, dpr],\n );\n const ctx = useMemo(\n () =>\n makePageContext(docId ?? '', pon, page, pageFrame, transform, () =>\n ref.current!.getBoundingClientRect(),\n ),\n [docId, pon, page, pageFrame, transform],\n );\n if (!docId || !meta || !base) return null;\n const t = transform;\n const outerW = t.viewWidth + pageFrame.left + pageFrame.right;\n const outerH = t.viewHeight + pageFrame.top + pageFrame.bottom;\n const contentLeft = pageFrame.left + (t.viewWidth - t.contentWidth) / 2;\n const contentTop = pageFrame.top + (t.viewHeight - t.contentHeight) / 2;\n return (\n <DocumentScope id={docId}>\n <div style={{ position: 'relative', width: outerW, height: outerH, ...style }}>\n <PageProvider value={ctx}>\n {/* drop shadow ONLY — transparent, axis-aligned, can't leak behind the bitmap */}\n <div\n style={{\n position: 'absolute',\n left: pageFrame.left,\n top: pageFrame.top,\n width: t.viewWidth,\n height: t.viewHeight,\n boxShadow: '0 6px 18px rgba(0,0,0,.18)',\n }}\n />\n {/* white backing + content as ONE box; rotation 0 carries no transform */}\n <div\n ref={ref}\n style={{\n position: 'absolute',\n left: contentLeft,\n top: contentTop,\n width: t.contentWidth,\n height: t.contentHeight,\n background: '#fff',\n transform: rotation ? `rotate(${rotation}deg)` : undefined,\n userSelect: 'none',\n WebkitUserSelect: 'none',\n }}\n >\n {children}\n </div>\n {pageChrome}\n </PageProvider>\n </div>\n </DocumentScope>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqCA,SAAgB,SAAS,EACvB,MACA,YACA,QAAQ,KACR,YAAYA,wBAAAA,UACZ,UACA,YACA,SACgB;CAChB,MAAM,SAASC,gBAAAA,UAAU;CACzB,MAAM,SAASC,gBAAAA,oBAAoB;CACnC,MAAM,OAAA,GAAA,MAAA,OAAA,CAA6B,IAAI;CACvC,MAAM,QAAQ,cAAc;CAC5B,MAAM,OAAO,QAAQ,OAAO,SAAS,CAAC,CAAC,KAAK,UAAU,SAAS,KAAA;CAC/D,MAAM,OAAO,MAAM,MAAM;CACzB,MAAM,MAAM,MAAM,oBAAoB,OAAO;CAC7C,MAAM,WAAW,MAAM,YAAY;CACnC,MAAM,MAAM,OAAO,WAAW,cAAc,OAAO,oBAAoB,IAAI;CAG3E,MAAM,aAAA,GAAA,MAAA,QAAA,QAAA,GAAA,wBAAA,cAAA,CAEY;EACZ,UAAU,OACN;GAAE,OAAO,KAAK,KAAK;GAAO,QAAQ,KAAK,KAAK;EAAO,IACnD;GAAE,OAAO;GAAG,QAAQ;EAAE;EAC1B;EACA,OAAO,OAAO,QAAQ,KAAK,KAAK,QAAQ;EAIxC,WAAY,KAAK,MAAO,MAAM,YAAY;EAC1C;CACF,CAAC,GACH;EAAC,MAAM,KAAK;EAAO,MAAM,KAAK;EAAQ,MAAM;EAAU;EAAU;EAAO;CAAG,CAC5E;CACA,MAAM,OAAA,GAAA,MAAA,QAAA,OAEFC,gBAAAA,gBAAgB,SAAS,IAAI,KAAK,MAAM,WAAW,iBACjD,IAAI,QAAS,sBAAsB,CACrC,GACF;EAAC;EAAO;EAAK;EAAM;EAAW;CAAS,CACzC;CACA,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,OAAO;CACrC,MAAM,IAAI;CACV,MAAM,SAAS,EAAE,YAAY,UAAU,OAAO,UAAU;CACxD,MAAM,SAAS,EAAE,aAAa,UAAU,MAAM,UAAU;CACxD,MAAM,cAAc,UAAU,QAAQ,EAAE,YAAY,EAAE,gBAAgB;CACtE,MAAM,aAAa,UAAU,OAAO,EAAE,aAAa,EAAE,iBAAiB;CACtE,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,gBAAAA,eAAD;EAAe,IAAI;EACjB,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;GAAK,OAAO;IAAE,UAAU;IAAY,OAAO;IAAQ,QAAQ;IAAQ,GAAG;GAAM;GAC1E,UAAA,iBAAA,GAAA,kBAAA,KAAA,CAACC,gBAAAA,cAAD;IAAc,OAAO;IAArB,UAAA;KAEE,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD,EACE,OAAO;MACL,UAAU;MACV,MAAM,UAAU;MAChB,KAAK,UAAU;MACf,OAAO,EAAE;MACT,QAAQ,EAAE;MACV,WAAW;KACb,EACD,CAAA;KAED,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;MACO;MACL,OAAO;OACL,UAAU;OACV,MAAM;OACN,KAAK;OACL,OAAO,EAAE;OACT,QAAQ,EAAE;OACV,YAAY;OACZ,WAAW,WAAW,UAAU,SAAS,QAAQ,KAAA;OACjD,YAAY;OACZ,kBAAkB;MACpB;MAEC;KACE,CAAA;KACJ;IACW;;EACX,CAAA;CACQ,CAAA;AAEnB"}
@@ -0,0 +1,23 @@
1
+ import * as React from "react";
2
+ import { PageFrame } from "@embedpdf/core-geometry";
3
+ //#region src/page-view.d.ts
4
+ interface PageViewProps {
5
+ page: number;
6
+ /** Which document to show. Defaults to the active document. */
7
+ documentId?: string;
8
+ /** Target width for the page CONTENT; the display box is the rotated footprint. */
9
+ width?: number;
10
+ /** Reserved chrome bands around the page (screen px) — same model as `<Stage>`. */
11
+ pageFrame?: PageFrame;
12
+ /** Page-space content (rotates with the page). */
13
+ children: React.ReactNode;
14
+ /** Box-space chrome (label, border, …) — never rotated. Mirrors `<Stage pageChrome>`. */
15
+ pageChrome?: React.ReactNode;
16
+ style?: React.CSSProperties;
17
+ }
18
+ /** A single page surface with NO Stage — same layers + rotation + chrome frame,
19
+ * no camera/scroll/zoom. */
20
+ declare function PageView({ page, documentId, width, pageFrame, children, pageChrome, style }: PageViewProps): import("react/jsx-runtime").JSX.Element | null;
21
+ //#endregion
22
+ export { PageView, PageViewProps };
23
+ //# sourceMappingURL=page-view.d.cts.map
@@ -0,0 +1,23 @@
1
+ import * as React from "react";
2
+ import { PageFrame } from "@embedpdf/core-geometry";
3
+ //#region src/page-view.d.ts
4
+ interface PageViewProps {
5
+ page: number;
6
+ /** Which document to show. Defaults to the active document. */
7
+ documentId?: string;
8
+ /** Target width for the page CONTENT; the display box is the rotated footprint. */
9
+ width?: number;
10
+ /** Reserved chrome bands around the page (screen px) — same model as `<Stage>`. */
11
+ pageFrame?: PageFrame;
12
+ /** Page-space content (rotates with the page). */
13
+ children: React.ReactNode;
14
+ /** Box-space chrome (label, border, …) — never rotated. Mirrors `<Stage pageChrome>`. */
15
+ pageChrome?: React.ReactNode;
16
+ style?: React.CSSProperties;
17
+ }
18
+ /** A single page surface with NO Stage — same layers + rotation + chrome frame,
19
+ * no camera/scroll/zoom. */
20
+ declare function PageView({ page, documentId, width, pageFrame, children, pageChrome, style }: PageViewProps): import("react/jsx-runtime").JSX.Element | null;
21
+ //#endregion
22
+ export { PageView, PageViewProps };
23
+ //# sourceMappingURL=page-view.d.ts.map
@@ -0,0 +1,95 @@
1
+ import { DocumentScope, PageProvider, makePageContext, useActiveDocumentId, useKernel } from "./runtime.js";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { useMemo, useRef } from "react";
4
+ import { NO_FRAME, pageTransform } from "@embedpdf/core-geometry";
5
+ //#region src/page-view.tsx
6
+ /** A single page surface with NO Stage — same layers + rotation + chrome frame,
7
+ * no camera/scroll/zoom. */
8
+ function PageView({ page, documentId, width = 240, pageFrame = NO_FRAME, children, pageChrome, style }) {
9
+ const kernel = useKernel();
10
+ const active = useActiveDocumentId();
11
+ const ref = useRef(null);
12
+ const docId = documentId ?? active;
13
+ const meta = docId ? kernel.getState().core.documents[docId] : void 0;
14
+ const base = meta?.pages[page];
15
+ const pon = base?.pageObjectNumber ?? page + 1;
16
+ const rotation = base?.rotation ?? 0;
17
+ const dpr = typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1;
18
+ const transform = useMemo(() => pageTransform({
19
+ pageSize: base ? {
20
+ width: base.size.width,
21
+ height: base.size.height
22
+ } : {
23
+ width: 1,
24
+ height: 1
25
+ },
26
+ rotation,
27
+ scale: base ? width / base.size.width : 1,
28
+ baseScale: 96 / 72 * (base?.userUnit ?? 1),
29
+ dpr
30
+ }), [
31
+ base?.size.width,
32
+ base?.size.height,
33
+ base?.userUnit,
34
+ rotation,
35
+ width,
36
+ dpr
37
+ ]);
38
+ const ctx = useMemo(() => makePageContext(docId ?? "", pon, page, pageFrame, transform, () => ref.current.getBoundingClientRect()), [
39
+ docId,
40
+ pon,
41
+ page,
42
+ pageFrame,
43
+ transform
44
+ ]);
45
+ if (!docId || !meta || !base) return null;
46
+ const t = transform;
47
+ const outerW = t.viewWidth + pageFrame.left + pageFrame.right;
48
+ const outerH = t.viewHeight + pageFrame.top + pageFrame.bottom;
49
+ const contentLeft = pageFrame.left + (t.viewWidth - t.contentWidth) / 2;
50
+ const contentTop = pageFrame.top + (t.viewHeight - t.contentHeight) / 2;
51
+ return /* @__PURE__ */ jsx(DocumentScope, {
52
+ id: docId,
53
+ children: /* @__PURE__ */ jsx("div", {
54
+ style: {
55
+ position: "relative",
56
+ width: outerW,
57
+ height: outerH,
58
+ ...style
59
+ },
60
+ children: /* @__PURE__ */ jsxs(PageProvider, {
61
+ value: ctx,
62
+ children: [
63
+ /* @__PURE__ */ jsx("div", { style: {
64
+ position: "absolute",
65
+ left: pageFrame.left,
66
+ top: pageFrame.top,
67
+ width: t.viewWidth,
68
+ height: t.viewHeight,
69
+ boxShadow: "0 6px 18px rgba(0,0,0,.18)"
70
+ } }),
71
+ /* @__PURE__ */ jsx("div", {
72
+ ref,
73
+ style: {
74
+ position: "absolute",
75
+ left: contentLeft,
76
+ top: contentTop,
77
+ width: t.contentWidth,
78
+ height: t.contentHeight,
79
+ background: "#fff",
80
+ transform: rotation ? `rotate(${rotation}deg)` : void 0,
81
+ userSelect: "none",
82
+ WebkitUserSelect: "none"
83
+ },
84
+ children
85
+ }),
86
+ pageChrome
87
+ ]
88
+ })
89
+ })
90
+ });
91
+ }
92
+ //#endregion
93
+ export { PageView };
94
+
95
+ //# sourceMappingURL=page-view.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page-view.js","names":[],"sources":["../src/page-view.tsx"],"sourcesContent":["/**\n * <PageView> — a single page surface with NO Stage.\n *\n * Same layers + rotation + chrome frame as a `<Stage>` page, but no\n * camera/scroll/zoom and, crucially, NO dependency on `@embedpdf/plugin-stage`.\n * It builds its own `PageTransform` from a target content width and shares the\n * exact `PageContext` seam, so every layer (RenderLayer, AnnotationLayer,\n * PageAnnotationMenu, …) works here identically.\n */\nimport * as React from 'react';\nimport { useMemo, useRef } from 'react';\nimport { NO_FRAME, pageTransform, type PageFrame } from '@embedpdf/core-geometry';\nimport {\n DocumentScope,\n makePageContext,\n PageProvider,\n useActiveDocumentId,\n useKernel,\n} from './runtime';\n\nexport interface PageViewProps {\n page: number;\n /** Which document to show. Defaults to the active document. */\n documentId?: string;\n /** Target width for the page CONTENT; the display box is the rotated footprint. */\n width?: number;\n /** Reserved chrome bands around the page (screen px) — same model as `<Stage>`. */\n pageFrame?: PageFrame;\n /** Page-space content (rotates with the page). */\n children: React.ReactNode;\n /** Box-space chrome (label, border, …) — never rotated. Mirrors `<Stage pageChrome>`. */\n pageChrome?: React.ReactNode;\n style?: React.CSSProperties;\n}\n\n/** A single page surface with NO Stage — same layers + rotation + chrome frame,\n * no camera/scroll/zoom. */\nexport function PageView({\n page,\n documentId,\n width = 240,\n pageFrame = NO_FRAME,\n children,\n pageChrome,\n style,\n}: PageViewProps) {\n const kernel = useKernel();\n const active = useActiveDocumentId();\n const ref = useRef<HTMLDivElement>(null);\n const docId = documentId ?? active;\n const meta = docId ? kernel.getState().core.documents[docId] : undefined;\n const base = meta?.pages[page];\n const pon = base?.pageObjectNumber ?? page + 1;\n const rotation = base?.rotation ?? 0;\n const dpr = typeof window !== 'undefined' ? window.devicePixelRatio || 1 : 1;\n // Standalone (no Stage/camera): build the page's transform from the target\n // content `width` directly. `scale` is view px per point = width / pageWidthPts.\n const transform = useMemo(\n () =>\n pageTransform({\n pageSize: base\n ? { width: base.size.width, height: base.size.height }\n : { width: 1, height: 1 },\n rotation,\n scale: base ? width / base.size.width : 1,\n // Physical 100% on the web: 1pt = 96/72 CSS px, times the page's\n // /UserUnit — so `transform.zoom` is meaningful even without a Stage\n // (a thumbnail-sized PageView reads as zoomed out, as it should).\n baseScale: (96 / 72) * (base?.userUnit ?? 1),\n dpr,\n }),\n [base?.size.width, base?.size.height, base?.userUnit, rotation, width, dpr],\n );\n const ctx = useMemo(\n () =>\n makePageContext(docId ?? '', pon, page, pageFrame, transform, () =>\n ref.current!.getBoundingClientRect(),\n ),\n [docId, pon, page, pageFrame, transform],\n );\n if (!docId || !meta || !base) return null;\n const t = transform;\n const outerW = t.viewWidth + pageFrame.left + pageFrame.right;\n const outerH = t.viewHeight + pageFrame.top + pageFrame.bottom;\n const contentLeft = pageFrame.left + (t.viewWidth - t.contentWidth) / 2;\n const contentTop = pageFrame.top + (t.viewHeight - t.contentHeight) / 2;\n return (\n <DocumentScope id={docId}>\n <div style={{ position: 'relative', width: outerW, height: outerH, ...style }}>\n <PageProvider value={ctx}>\n {/* drop shadow ONLY — transparent, axis-aligned, can't leak behind the bitmap */}\n <div\n style={{\n position: 'absolute',\n left: pageFrame.left,\n top: pageFrame.top,\n width: t.viewWidth,\n height: t.viewHeight,\n boxShadow: '0 6px 18px rgba(0,0,0,.18)',\n }}\n />\n {/* white backing + content as ONE box; rotation 0 carries no transform */}\n <div\n ref={ref}\n style={{\n position: 'absolute',\n left: contentLeft,\n top: contentTop,\n width: t.contentWidth,\n height: t.contentHeight,\n background: '#fff',\n transform: rotation ? `rotate(${rotation}deg)` : undefined,\n userSelect: 'none',\n WebkitUserSelect: 'none',\n }}\n >\n {children}\n </div>\n {pageChrome}\n </PageProvider>\n </div>\n </DocumentScope>\n );\n}\n"],"mappings":";;;;;;;AAqCA,SAAgB,SAAS,EACvB,MACA,YACA,QAAQ,KACR,YAAY,UACZ,UACA,YACA,SACgB;CAChB,MAAM,SAAS,UAAU;CACzB,MAAM,SAAS,oBAAoB;CACnC,MAAM,MAAM,OAAuB,IAAI;CACvC,MAAM,QAAQ,cAAc;CAC5B,MAAM,OAAO,QAAQ,OAAO,SAAS,CAAC,CAAC,KAAK,UAAU,SAAS,KAAA;CAC/D,MAAM,OAAO,MAAM,MAAM;CACzB,MAAM,MAAM,MAAM,oBAAoB,OAAO;CAC7C,MAAM,WAAW,MAAM,YAAY;CACnC,MAAM,MAAM,OAAO,WAAW,cAAc,OAAO,oBAAoB,IAAI;CAG3E,MAAM,YAAY,cAEd,cAAc;EACZ,UAAU,OACN;GAAE,OAAO,KAAK,KAAK;GAAO,QAAQ,KAAK,KAAK;EAAO,IACnD;GAAE,OAAO;GAAG,QAAQ;EAAE;EAC1B;EACA,OAAO,OAAO,QAAQ,KAAK,KAAK,QAAQ;EAIxC,WAAY,KAAK,MAAO,MAAM,YAAY;EAC1C;CACF,CAAC,GACH;EAAC,MAAM,KAAK;EAAO,MAAM,KAAK;EAAQ,MAAM;EAAU;EAAU;EAAO;CAAG,CAC5E;CACA,MAAM,MAAM,cAER,gBAAgB,SAAS,IAAI,KAAK,MAAM,WAAW,iBACjD,IAAI,QAAS,sBAAsB,CACrC,GACF;EAAC;EAAO;EAAK;EAAM;EAAW;CAAS,CACzC;CACA,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,OAAO;CACrC,MAAM,IAAI;CACV,MAAM,SAAS,EAAE,YAAY,UAAU,OAAO,UAAU;CACxD,MAAM,SAAS,EAAE,aAAa,UAAU,MAAM,UAAU;CACxD,MAAM,cAAc,UAAU,QAAQ,EAAE,YAAY,EAAE,gBAAgB;CACtE,MAAM,aAAa,UAAU,OAAO,EAAE,aAAa,EAAE,iBAAiB;CACtE,OACE,oBAAC,eAAD;EAAe,IAAI;EACjB,UAAA,oBAAC,OAAD;GAAK,OAAO;IAAE,UAAU;IAAY,OAAO;IAAQ,QAAQ;IAAQ,GAAG;GAAM;GAC1E,UAAA,qBAAC,cAAD;IAAc,OAAO;IAArB,UAAA;KAEE,oBAAC,OAAD,EACE,OAAO;MACL,UAAU;MACV,MAAM,UAAU;MAChB,KAAK,UAAU;MACf,OAAO,EAAE;MACT,QAAQ,EAAE;MACV,WAAW;KACb,EACD,CAAA;KAED,oBAAC,OAAD;MACO;MACL,OAAO;OACL,UAAU;OACV,MAAM;OACN,KAAK;OACL,OAAO,EAAE;OACT,QAAQ,EAAE;OACV,YAAY;OACZ,WAAW,WAAW,UAAU,SAAS,QAAQ,KAAA;OACjD,YAAY;OACZ,kBAAkB;MACpB;MAEC;KACE,CAAA;KACJ;IACW;;EACX,CAAA;CACQ,CAAA;AAEnB"}
@@ -0,0 +1,35 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ require("./rolldown-runtime-DDXJien1.cjs");
3
+ const require_runtime = require("./runtime.cjs");
4
+ let _embedpdf_plugin_redaction = require("@embedpdf/plugin-redaction");
5
+ //#region src/redaction.tsx
6
+ function useRedaction() {
7
+ const cap = require_runtime.useCapability(_embedpdf_plugin_redaction.RedactionToken);
8
+ const applying = require_runtime.useSelector(_embedpdf_plugin_redaction.RedactionToken, (c) => c.isApplying());
9
+ const lastApplyResult = require_runtime.useSelector(_embedpdf_plugin_redaction.RedactionToken, (c) => c.lastResult());
10
+ return {
11
+ ...cap,
12
+ applying,
13
+ lastApplyResult
14
+ };
15
+ }
16
+ /** The pending marks, reactive against the annotation plane. Note the view
17
+ * covers LOADED pages — call `preparePending()` (e.g. on panel open) to load
18
+ * the whole document. */
19
+ function usePendingRedactions() {
20
+ return require_runtime.useSelector(_embedpdf_plugin_redaction.RedactionToken, (c) => c.getPending(), pendingEqual);
21
+ }
22
+ const pendingEqual = (a, b) => a.length === b.length && a.every((item, i) => item.id === b[i].id && item.overlayText === b[i].overlayText);
23
+ //#endregion
24
+ exports.usePendingRedactions = usePendingRedactions;
25
+ exports.useRedaction = useRedaction;
26
+ Object.keys(_embedpdf_plugin_redaction).forEach(function(k) {
27
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
28
+ enumerable: true,
29
+ get: function() {
30
+ return _embedpdf_plugin_redaction[k];
31
+ }
32
+ });
33
+ });
34
+
35
+ //# sourceMappingURL=redaction.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redaction.cjs","names":["useCapability","RedactionToken","useSelector"],"sources":["../src/redaction.tsx"],"sourcesContent":["import { RedactionToken } from '@embedpdf/plugin-redaction';\nimport type {\n RedactionApplyResult,\n RedactionCapability,\n RedactionPendingItem,\n} from '@embedpdf/plugin-redaction';\nimport { useCapability, useSelector } from './runtime';\n\n/**\n * Redaction for the surrounding `DocumentScope`: the pending-marks view plus\n * the destructive apply. Marking rides the annotation plane (the composed\n * `redact` tool); `useRedaction` surfaces the workflow around it.\n *\n * const redaction = useRedaction();\n * redaction.toggleRedact();\n * await redaction.applyAll(); // irreversible — confirm first\n */\n\n// One-line-per-feature: registration travels with the UI.\nexport * from '@embedpdf/plugin-redaction';\n\nexport function useRedaction(): RedactionCapability & {\n applying: boolean;\n lastApplyResult: RedactionApplyResult | null;\n} {\n const cap = useCapability(RedactionToken);\n const applying = useSelector(RedactionToken, (c) => c.isApplying());\n const lastApplyResult = useSelector(RedactionToken, (c) => c.lastResult());\n return { ...cap, applying, lastApplyResult };\n}\n\n/** The pending marks, reactive against the annotation plane. Note the view\n * covers LOADED pages — call `preparePending()` (e.g. on panel open) to load\n * the whole document. */\nexport function usePendingRedactions(): RedactionPendingItem[] {\n return useSelector(RedactionToken, (c) => c.getPending(), pendingEqual);\n}\n\nconst pendingEqual = (a: RedactionPendingItem[], b: RedactionPendingItem[]): boolean =>\n a.length === b.length &&\n a.every((item, i) => item.id === b[i]!.id && item.overlayText === b[i]!.overlayText);\n"],"mappings":";;;;;AAqBA,SAAgB,eAGd;CACA,MAAM,MAAMA,gBAAAA,cAAcC,2BAAAA,cAAc;CACxC,MAAM,WAAWC,gBAAAA,YAAYD,2BAAAA,iBAAiB,MAAM,EAAE,WAAW,CAAC;CAClE,MAAM,kBAAkBC,gBAAAA,YAAYD,2BAAAA,iBAAiB,MAAM,EAAE,WAAW,CAAC;CACzE,OAAO;EAAE,GAAG;EAAK;EAAU;CAAgB;AAC7C;;;;AAKA,SAAgB,uBAA+C;CAC7D,OAAOC,gBAAAA,YAAYD,2BAAAA,iBAAiB,MAAM,EAAE,WAAW,GAAG,YAAY;AACxE;AAEA,MAAM,gBAAgB,GAA2B,MAC/C,EAAE,WAAW,EAAE,UACf,EAAE,OAAO,MAAM,MAAM,KAAK,OAAO,EAAE,EAAE,CAAE,MAAM,KAAK,gBAAgB,EAAE,EAAE,CAAE,WAAW"}
@@ -0,0 +1,14 @@
1
+ import { RedactionApplyResult, RedactionCapability, RedactionPendingItem } from "@embedpdf/plugin-redaction";
2
+ export * from "@embedpdf/plugin-redaction";
3
+ //#region src/redaction.d.ts
4
+ declare function useRedaction(): RedactionCapability & {
5
+ applying: boolean;
6
+ lastApplyResult: RedactionApplyResult | null;
7
+ };
8
+ /** The pending marks, reactive against the annotation plane. Note the view
9
+ * covers LOADED pages — call `preparePending()` (e.g. on panel open) to load
10
+ * the whole document. */
11
+ declare function usePendingRedactions(): RedactionPendingItem[];
12
+ //#endregion
13
+ export { usePendingRedactions, useRedaction };
14
+ //# sourceMappingURL=redaction.d.cts.map
@@ -0,0 +1,14 @@
1
+ import { RedactionApplyResult, RedactionCapability, RedactionPendingItem } from "@embedpdf/plugin-redaction";
2
+ export * from "@embedpdf/plugin-redaction";
3
+ //#region src/redaction.d.ts
4
+ declare function useRedaction(): RedactionCapability & {
5
+ applying: boolean;
6
+ lastApplyResult: RedactionApplyResult | null;
7
+ };
8
+ /** The pending marks, reactive against the annotation plane. Note the view
9
+ * covers LOADED pages — call `preparePending()` (e.g. on panel open) to load
10
+ * the whole document. */
11
+ declare function usePendingRedactions(): RedactionPendingItem[];
12
+ //#endregion
13
+ export { usePendingRedactions, useRedaction };
14
+ //# sourceMappingURL=redaction.d.ts.map
@@ -0,0 +1,25 @@
1
+ import { useCapability, useSelector } from "./runtime.js";
2
+ import { RedactionToken } from "@embedpdf/plugin-redaction";
3
+ export * from "@embedpdf/plugin-redaction";
4
+ //#region src/redaction.tsx
5
+ function useRedaction() {
6
+ const cap = useCapability(RedactionToken);
7
+ const applying = useSelector(RedactionToken, (c) => c.isApplying());
8
+ const lastApplyResult = useSelector(RedactionToken, (c) => c.lastResult());
9
+ return {
10
+ ...cap,
11
+ applying,
12
+ lastApplyResult
13
+ };
14
+ }
15
+ /** The pending marks, reactive against the annotation plane. Note the view
16
+ * covers LOADED pages — call `preparePending()` (e.g. on panel open) to load
17
+ * the whole document. */
18
+ function usePendingRedactions() {
19
+ return useSelector(RedactionToken, (c) => c.getPending(), pendingEqual);
20
+ }
21
+ const pendingEqual = (a, b) => a.length === b.length && a.every((item, i) => item.id === b[i].id && item.overlayText === b[i].overlayText);
22
+ //#endregion
23
+ export { usePendingRedactions, useRedaction };
24
+
25
+ //# sourceMappingURL=redaction.js.map