@embedpdf/plugin-rotate 1.5.0 → 2.0.0-next.1

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.
@@ -1,28 +1,50 @@
1
- import { usePlugin, useCapability } from "@embedpdf/core/preact";
2
- import { RotatePlugin } from "@embedpdf/plugin-rotate";
1
+ import { usePlugin, useCapability, useDocumentState } from "@embedpdf/core/preact";
2
+ import { RotatePlugin, initialDocumentState } from "@embedpdf/plugin-rotate";
3
3
  export * from "@embedpdf/plugin-rotate";
4
4
  import "preact";
5
5
  import { useState, useEffect } from "preact/hooks";
6
6
  import { jsx } from "preact/jsx-runtime";
7
7
  const useRotatePlugin = () => usePlugin(RotatePlugin.id);
8
8
  const useRotateCapability = () => useCapability(RotatePlugin.id);
9
- const useRotate = () => {
9
+ const useRotate = (documentId) => {
10
10
  const { provides } = useRotateCapability();
11
- const [rotation, setRotation] = useState(0);
11
+ const [rotation, setRotation] = useState(initialDocumentState.rotation);
12
12
  useEffect(() => {
13
- return provides == null ? void 0 : provides.onRotateChange((rotation2) => setRotation(rotation2));
14
- }, [provides]);
13
+ if (!provides) return;
14
+ const scope = provides.forDocument(documentId);
15
+ setRotation(scope.getRotation());
16
+ return scope.onRotateChange((newRotation) => {
17
+ setRotation(newRotation);
18
+ });
19
+ }, [provides, documentId]);
15
20
  return {
16
21
  rotation,
17
- provides
22
+ provides: (provides == null ? void 0 : provides.forDocument(documentId)) ?? null
18
23
  };
19
24
  };
20
- function Rotate({ children, pageSize, style, ...props }) {
21
- const { plugin: rotate } = useRotatePlugin();
22
- const matrix = (rotate == null ? void 0 : rotate.getMatrixAsString({
23
- w: pageSize.width,
24
- h: pageSize.height
25
- })) || "matrix(1, 0, 0, 1, 0, 0)";
25
+ function Rotate({
26
+ children,
27
+ documentId,
28
+ pageIndex,
29
+ rotation: rotationOverride,
30
+ scale: scaleOverride,
31
+ style,
32
+ ...props
33
+ }) {
34
+ var _a, _b, _c, _d;
35
+ const { plugin: rotatePlugin } = useRotatePlugin();
36
+ const documentState = useDocumentState(documentId);
37
+ const page = (_b = (_a = documentState == null ? void 0 : documentState.document) == null ? void 0 : _a.pages) == null ? void 0 : _b[pageIndex];
38
+ const width = ((_c = page == null ? void 0 : page.size) == null ? void 0 : _c.width) ?? 0;
39
+ const height = ((_d = page == null ? void 0 : page.size) == null ? void 0 : _d.height) ?? 0;
40
+ const rotation = rotationOverride ?? (documentState == null ? void 0 : documentState.rotation) ?? 0;
41
+ const scale = scaleOverride ?? (documentState == null ? void 0 : documentState.scale) ?? 1;
42
+ const matrix = (rotatePlugin == null ? void 0 : rotatePlugin.getMatrixAsString({
43
+ width: width * scale,
44
+ height: height * scale,
45
+ rotation
46
+ })) ?? "matrix(1, 0, 0, 1, 0, 0)";
47
+ if (!page) return null;
26
48
  return /* @__PURE__ */ jsx(
27
49
  "div",
28
50
  {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/shared/hooks/use-rotate.ts","../../src/shared/components/rotate.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport { Rotation } from '@embedpdf/models';\nimport { RotatePlugin } from '@embedpdf/plugin-rotate';\nimport { useEffect, useState } from '@framework';\n\nexport const useRotatePlugin = () => usePlugin<RotatePlugin>(RotatePlugin.id);\nexport const useRotateCapability = () => useCapability<RotatePlugin>(RotatePlugin.id);\n\nexport const useRotate = () => {\n const { provides } = useRotateCapability();\n const [rotation, setRotation] = useState<Rotation>(0);\n\n useEffect(() => {\n return provides?.onRotateChange((rotation) => setRotation(rotation));\n }, [provides]);\n\n return {\n rotation,\n provides,\n };\n};\n","import { ReactNode, HTMLAttributes, CSSProperties } from '@framework';\nimport { Size } from '@embedpdf/models';\n\nimport { useRotatePlugin } from '../hooks';\n\ntype RotateProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {\n children: ReactNode;\n pageSize: Size;\n style?: CSSProperties;\n};\n\nexport function Rotate({ children, pageSize, style, ...props }: RotateProps) {\n const { plugin: rotate } = useRotatePlugin();\n const matrix =\n rotate?.getMatrixAsString({\n w: pageSize.width,\n h: pageSize.height,\n }) || 'matrix(1, 0, 0, 1, 0, 0)';\n\n return (\n <div\n {...props}\n style={{\n position: 'absolute',\n transformOrigin: '0 0',\n transform: matrix,\n ...style,\n }}\n >\n {children}\n </div>\n );\n}\n"],"names":["rotation"],"mappings":";;;;;;AAKO,MAAM,kBAAkB,MAAM,UAAwB,aAAa,EAAE;AACrE,MAAM,sBAAsB,MAAM,cAA4B,aAAa,EAAE;AAE7E,MAAM,YAAY,MAAM;AACvB,QAAA,EAAE,SAAS,IAAI,oBAAoB;AACzC,QAAM,CAAC,UAAU,WAAW,IAAI,SAAmB,CAAC;AAEpD,YAAU,MAAM;AACd,WAAO,qCAAU,eAAe,CAACA,cAAa,YAAYA,SAAQ;AAAA,EAAC,GAClE,CAAC,QAAQ,CAAC;AAEN,SAAA;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;ACTO,SAAS,OAAO,EAAE,UAAU,UAAU,OAAO,GAAG,SAAsB;AAC3E,QAAM,EAAE,QAAQ,OAAO,IAAI,gBAAgB;AACrC,QAAA,UACJ,iCAAQ,kBAAkB;AAAA,IACxB,GAAG,SAAS;AAAA,IACZ,GAAG,SAAS;AAAA,EACb,OAAK;AAGN,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACE,GAAG;AAAA,MACJ,OAAO;AAAA,QACL,UAAU;AAAA,QACV,iBAAiB;AAAA,QACjB,WAAW;AAAA,QACX,GAAG;AAAA,MACL;AAAA,MAEC;AAAA,IAAA;AAAA,EACH;AAEJ;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/shared/hooks/use-rotate.ts","../../src/shared/components/rotate.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport { Rotation } from '@embedpdf/models';\nimport { initialDocumentState, RotatePlugin } from '@embedpdf/plugin-rotate';\nimport { useEffect, useState } from '@framework';\n\nexport const useRotatePlugin = () => usePlugin<RotatePlugin>(RotatePlugin.id);\nexport const useRotateCapability = () => useCapability<RotatePlugin>(RotatePlugin.id);\n\n/**\n * Hook for rotation state for a specific document\n * @param documentId Document ID\n */\nexport const useRotate = (documentId: string) => {\n const { provides } = useRotateCapability();\n const [rotation, setRotation] = useState<Rotation>(initialDocumentState.rotation);\n\n useEffect(() => {\n if (!provides) return;\n\n const scope = provides.forDocument(documentId);\n\n // Get initial state\n setRotation(scope.getRotation());\n\n // Subscribe to rotation changes\n return scope.onRotateChange((newRotation) => {\n setRotation(newRotation);\n });\n }, [provides, documentId]);\n\n return {\n rotation,\n provides: provides?.forDocument(documentId) ?? null,\n };\n};\n","import { ReactNode, HTMLAttributes, CSSProperties } from '@framework';\nimport { useDocumentState } from '@embedpdf/core/@framework';\nimport { Rotation } from '@embedpdf/models';\n\nimport { useRotatePlugin } from '../hooks';\n\ntype RotateProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {\n children: ReactNode;\n documentId: string;\n pageIndex: number;\n rotation?: Rotation;\n scale?: number;\n style?: CSSProperties;\n};\n\nexport function Rotate({\n children,\n documentId,\n pageIndex,\n rotation: rotationOverride,\n scale: scaleOverride,\n style,\n ...props\n}: RotateProps) {\n const { plugin: rotatePlugin } = useRotatePlugin();\n const documentState = useDocumentState(documentId);\n\n const page = documentState?.document?.pages?.[pageIndex];\n const width = page?.size?.width ?? 0;\n const height = page?.size?.height ?? 0;\n const rotation = rotationOverride ?? documentState?.rotation ?? 0;\n const scale = scaleOverride ?? documentState?.scale ?? 1;\n\n const matrix =\n rotatePlugin?.getMatrixAsString({\n width: width * scale,\n height: height * scale,\n rotation: rotation,\n }) ?? 'matrix(1, 0, 0, 1, 0, 0)';\n\n if (!page) return null;\n\n return (\n <div\n {...props}\n style={{\n position: 'absolute',\n transformOrigin: '0 0',\n transform: matrix,\n ...style,\n }}\n >\n {children}\n </div>\n );\n}\n"],"names":[],"mappings":";;;;;;AAKO,MAAM,kBAAkB,MAAM,UAAwB,aAAa,EAAE;AACrE,MAAM,sBAAsB,MAAM,cAA4B,aAAa,EAAE;AAM7E,MAAM,YAAY,CAAC,eAAuB;AAC/C,QAAM,EAAE,SAAA,IAAa,oBAAA;AACrB,QAAM,CAAC,UAAU,WAAW,IAAI,SAAmB,qBAAqB,QAAQ;AAEhF,YAAU,MAAM;AACd,QAAI,CAAC,SAAU;AAEf,UAAM,QAAQ,SAAS,YAAY,UAAU;AAG7C,gBAAY,MAAM,aAAa;AAG/B,WAAO,MAAM,eAAe,CAAC,gBAAgB;AAC3C,kBAAY,WAAW;AAAA,IACzB,CAAC;AAAA,EACH,GAAG,CAAC,UAAU,UAAU,CAAC;AAEzB,SAAO;AAAA,IACL;AAAA,IACA,WAAU,qCAAU,YAAY,gBAAe;AAAA,EAAA;AAEnD;ACnBO,SAAS,OAAO;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV,OAAO;AAAA,EACP;AAAA,EACA,GAAG;AACL,GAAgB;;AACd,QAAM,EAAE,QAAQ,aAAA,IAAiB,gBAAA;AACjC,QAAM,gBAAgB,iBAAiB,UAAU;AAEjD,QAAM,QAAO,0DAAe,aAAf,mBAAyB,UAAzB,mBAAiC;AAC9C,QAAM,UAAQ,kCAAM,SAAN,mBAAY,UAAS;AACnC,QAAM,WAAS,kCAAM,SAAN,mBAAY,WAAU;AACrC,QAAM,WAAW,qBAAoB,+CAAe,aAAY;AAChE,QAAM,QAAQ,kBAAiB,+CAAe,UAAS;AAEvD,QAAM,UACJ,6CAAc,kBAAkB;AAAA,IAC9B,OAAO,QAAQ;AAAA,IACf,QAAQ,SAAS;AAAA,IACjB;AAAA,EAAA,OACI;AAER,MAAI,CAAC,KAAM,QAAO;AAElB,SACE;AAAA,IAAC;AAAA,IAAA;AAAA,MACE,GAAG;AAAA,MACJ,OAAO;AAAA,QACL,UAAU;AAAA,QACV,iBAAiB;AAAA,QACjB,WAAW;AAAA,QACX,GAAG;AAAA,MAAA;AAAA,MAGJ;AAAA,IAAA;AAAA,EAAA;AAGP;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core/react"),t=require("@embedpdf/plugin-rotate"),r=require("react"),o=require("react/jsx-runtime"),i=()=>e.usePlugin(t.RotatePlugin.id),s=()=>e.useCapability(t.RotatePlugin.id);exports.Rotate=function({children:e,pageSize:t,style:r,...s}){const{plugin:a}=i(),n=(null==a?void 0:a.getMatrixAsString({w:t.width,h:t.height}))||"matrix(1, 0, 0, 1, 0, 0)";return o.jsx("div",{...s,style:{position:"absolute",transformOrigin:"0 0",transform:n,...r},children:e})},exports.useRotate=()=>{const{provides:e}=s(),[t,o]=r.useState(0);return r.useEffect((()=>null==e?void 0:e.onRotateChange((e=>o(e)))),[e]),{rotation:t,provides:e}},exports.useRotateCapability=s,exports.useRotatePlugin=i,Object.keys(t).forEach((e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>t[e]})}));
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core/react"),t=require("@embedpdf/plugin-rotate"),o=require("react"),i=require("react/jsx-runtime"),r=()=>e.usePlugin(t.RotatePlugin.id),n=()=>e.useCapability(t.RotatePlugin.id);exports.Rotate=function({children:t,documentId:o,pageIndex:n,rotation:l,scale:u,style:a,...s}){var d,c,p,g;const{plugin:v}=r(),f=e.useDocumentState(o),m=null==(c=null==(d=null==f?void 0:f.document)?void 0:d.pages)?void 0:c[n],x=(null==(p=null==m?void 0:m.size)?void 0:p.width)??0,b=(null==(g=null==m?void 0:m.size)?void 0:g.height)??0,h=l??(null==f?void 0:f.rotation)??0,y=u??(null==f?void 0:f.scale)??1,R=(null==v?void 0:v.getMatrixAsString({width:x*y,height:b*y,rotation:h}))??"matrix(1, 0, 0, 1, 0, 0)";return m?i.jsx("div",{...s,style:{position:"absolute",transformOrigin:"0 0",transform:R,...a},children:t}):null},exports.useRotate=e=>{const{provides:i}=n(),[r,l]=o.useState(t.initialDocumentState.rotation);return o.useEffect(()=>{if(!i)return;const t=i.forDocument(e);return l(t.getRotation()),t.onRotateChange(e=>{l(e)})},[i,e]),{rotation:r,provides:(null==i?void 0:i.forDocument(e))??null}},exports.useRotateCapability=n,exports.useRotatePlugin=r,Object.keys(t).forEach(e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>t[e]})});
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../src/shared/hooks/use-rotate.ts","../../src/shared/components/rotate.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport { Rotation } from '@embedpdf/models';\nimport { RotatePlugin } from '@embedpdf/plugin-rotate';\nimport { useEffect, useState } from '@framework';\n\nexport const useRotatePlugin = () => usePlugin<RotatePlugin>(RotatePlugin.id);\nexport const useRotateCapability = () => useCapability<RotatePlugin>(RotatePlugin.id);\n\nexport const useRotate = () => {\n const { provides } = useRotateCapability();\n const [rotation, setRotation] = useState<Rotation>(0);\n\n useEffect(() => {\n return provides?.onRotateChange((rotation) => setRotation(rotation));\n }, [provides]);\n\n return {\n rotation,\n provides,\n };\n};\n","import { ReactNode, HTMLAttributes, CSSProperties } from '@framework';\nimport { Size } from '@embedpdf/models';\n\nimport { useRotatePlugin } from '../hooks';\n\ntype RotateProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {\n children: ReactNode;\n pageSize: Size;\n style?: CSSProperties;\n};\n\nexport function Rotate({ children, pageSize, style, ...props }: RotateProps) {\n const { plugin: rotate } = useRotatePlugin();\n const matrix =\n rotate?.getMatrixAsString({\n w: pageSize.width,\n h: pageSize.height,\n }) || 'matrix(1, 0, 0, 1, 0, 0)';\n\n return (\n <div\n {...props}\n style={{\n position: 'absolute',\n transformOrigin: '0 0',\n transform: matrix,\n ...style,\n }}\n >\n {children}\n </div>\n );\n}\n"],"names":["useRotatePlugin","usePlugin","RotatePlugin","id","useRotateCapability","useCapability","children","pageSize","style","props","plugin","rotate","matrix","getMatrixAsString","w","width","h","height","jsxRuntime","jsx","position","transformOrigin","transform","provides","rotation","setRotation","useState","useEffect","onRotateChange"],"mappings":"+MAKaA,EAAkB,IAAMC,YAAwBC,EAAAA,aAAaC,IAC7DC,EAAsB,IAAMC,gBAA4BH,EAAAA,aAAaC,mBCK3E,UAAgBG,SAAEA,EAAAC,SAAUA,QAAUC,KAAUC,IACrD,MAAQC,OAAQC,GAAWX,IACrBY,SACJD,WAAQE,kBAAkB,CACxBC,EAAGP,EAASQ,MACZC,EAAGT,EAASU,WACR,2BAGN,OAAAC,EAAAC,IAAC,MAAA,IACKV,EACJD,MAAO,CACLY,SAAU,WACVC,gBAAiB,MACjBC,UAAWV,KACRJ,GAGJF,YAGP,oBDxByB,KACjB,MAAAiB,SAAEA,GAAanB,KACdoB,EAAUC,GAAeC,EAAAA,SAAmB,GAM5C,OAJPC,EAAAA,WAAU,IACS,MAAVJ,OAAU,EAAAA,EAAAK,gBAAgBJ,GAAaC,EAAYD,MACzD,CAACD,IAEG,CACLC,WACAD,WACF"}
1
+ {"version":3,"file":"index.cjs","sources":["../../src/shared/hooks/use-rotate.ts","../../src/shared/components/rotate.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport { Rotation } from '@embedpdf/models';\nimport { initialDocumentState, RotatePlugin } from '@embedpdf/plugin-rotate';\nimport { useEffect, useState } from '@framework';\n\nexport const useRotatePlugin = () => usePlugin<RotatePlugin>(RotatePlugin.id);\nexport const useRotateCapability = () => useCapability<RotatePlugin>(RotatePlugin.id);\n\n/**\n * Hook for rotation state for a specific document\n * @param documentId Document ID\n */\nexport const useRotate = (documentId: string) => {\n const { provides } = useRotateCapability();\n const [rotation, setRotation] = useState<Rotation>(initialDocumentState.rotation);\n\n useEffect(() => {\n if (!provides) return;\n\n const scope = provides.forDocument(documentId);\n\n // Get initial state\n setRotation(scope.getRotation());\n\n // Subscribe to rotation changes\n return scope.onRotateChange((newRotation) => {\n setRotation(newRotation);\n });\n }, [provides, documentId]);\n\n return {\n rotation,\n provides: provides?.forDocument(documentId) ?? null,\n };\n};\n","import { ReactNode, HTMLAttributes, CSSProperties } from '@framework';\nimport { useDocumentState } from '@embedpdf/core/@framework';\nimport { Rotation } from '@embedpdf/models';\n\nimport { useRotatePlugin } from '../hooks';\n\ntype RotateProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {\n children: ReactNode;\n documentId: string;\n pageIndex: number;\n rotation?: Rotation;\n scale?: number;\n style?: CSSProperties;\n};\n\nexport function Rotate({\n children,\n documentId,\n pageIndex,\n rotation: rotationOverride,\n scale: scaleOverride,\n style,\n ...props\n}: RotateProps) {\n const { plugin: rotatePlugin } = useRotatePlugin();\n const documentState = useDocumentState(documentId);\n\n const page = documentState?.document?.pages?.[pageIndex];\n const width = page?.size?.width ?? 0;\n const height = page?.size?.height ?? 0;\n const rotation = rotationOverride ?? documentState?.rotation ?? 0;\n const scale = scaleOverride ?? documentState?.scale ?? 1;\n\n const matrix =\n rotatePlugin?.getMatrixAsString({\n width: width * scale,\n height: height * scale,\n rotation: rotation,\n }) ?? 'matrix(1, 0, 0, 1, 0, 0)';\n\n if (!page) return null;\n\n return (\n <div\n {...props}\n style={{\n position: 'absolute',\n transformOrigin: '0 0',\n transform: matrix,\n ...style,\n }}\n >\n {children}\n </div>\n );\n}\n"],"names":["useRotatePlugin","usePlugin","RotatePlugin","id","useRotateCapability","useCapability","children","documentId","pageIndex","rotation","rotationOverride","scale","scaleOverride","style","props","plugin","rotatePlugin","documentState","useDocumentState","page","_b","_a","document","pages","width","_c","size","height","_d","matrix","getMatrixAsString","jsx","position","transformOrigin","transform","provides","setRotation","useState","initialDocumentState","useEffect","scope","forDocument","getRotation","onRotateChange","newRotation"],"mappings":"+MAKaA,EAAkB,IAAMC,YAAwBC,EAAAA,aAAaC,IAC7DC,EAAsB,IAAMC,gBAA4BH,EAAAA,aAAaC,mBCS3E,UAAgBG,SACrBA,EAAAC,WACAA,EAAAC,UACAA,EACAC,SAAUC,EACVC,MAAOC,EAAAC,MACPA,KACGC,gBAEH,MAAQC,OAAQC,GAAiBhB,IAC3BiB,EAAgBC,EAAAA,iBAAiBX,GAEjCY,EAAO,OAAAC,EAAA,OAAAC,EAAA,MAAAJ,OAAA,EAAAA,EAAeK,eAAf,EAAAD,EAAyBE,YAAzB,EAAAH,EAAiCZ,GACxCgB,GAAQ,OAAAC,EAAA,MAAAN,OAAA,EAAAA,EAAMO,WAAN,EAAAD,EAAYD,QAAS,EAC7BG,GAAS,OAAAC,EAAA,MAAAT,OAAA,EAAAA,EAAMO,WAAN,EAAAE,EAAYD,SAAU,EAC/BlB,EAAWC,IAAoB,MAAAO,OAAA,EAAAA,EAAeR,WAAY,EAC1DE,EAAQC,IAAiB,MAAAK,OAAA,EAAAA,EAAeN,QAAS,EAEjDkB,SACJb,WAAcc,kBAAkB,CAC9BN,MAAOA,EAAQb,EACfgB,OAAQA,EAAShB,EACjBF,eACI,2BAER,OAAKU,EAGHY,EAAAA,IAAC,MAAA,IACKjB,EACJD,MAAO,CACLmB,SAAU,WACVC,gBAAiB,MACjBC,UAAWL,KACRhB,GAGJP,aAZa,IAepB,oBD3C0BC,IACxB,MAAM4B,SAAEA,GAAa/B,KACdK,EAAU2B,GAAeC,EAAAA,SAAmBC,EAAAA,qBAAqB7B,UAgBxE,OAdA8B,EAAAA,UAAU,KACR,IAAKJ,EAAU,OAEf,MAAMK,EAAQL,EAASM,YAAYlC,GAMnC,OAHA6B,EAAYI,EAAME,eAGXF,EAAMG,eAAgBC,IAC3BR,EAAYQ,MAEb,CAACT,EAAU5B,IAEP,CACLE,WACA0B,UAAU,MAAAA,OAAA,EAAAA,EAAUM,YAAYlC,KAAe"}
@@ -1,27 +1,49 @@
1
- import { usePlugin, useCapability } from "@embedpdf/core/react";
2
- import { RotatePlugin } from "@embedpdf/plugin-rotate";
1
+ import { usePlugin, useCapability, useDocumentState } from "@embedpdf/core/react";
2
+ import { RotatePlugin, initialDocumentState } from "@embedpdf/plugin-rotate";
3
3
  export * from "@embedpdf/plugin-rotate";
4
4
  import { useState, useEffect } from "react";
5
5
  import { jsx } from "react/jsx-runtime";
6
6
  const useRotatePlugin = () => usePlugin(RotatePlugin.id);
7
7
  const useRotateCapability = () => useCapability(RotatePlugin.id);
8
- const useRotate = () => {
8
+ const useRotate = (documentId) => {
9
9
  const { provides } = useRotateCapability();
10
- const [rotation, setRotation] = useState(0);
10
+ const [rotation, setRotation] = useState(initialDocumentState.rotation);
11
11
  useEffect(() => {
12
- return provides == null ? void 0 : provides.onRotateChange((rotation2) => setRotation(rotation2));
13
- }, [provides]);
12
+ if (!provides) return;
13
+ const scope = provides.forDocument(documentId);
14
+ setRotation(scope.getRotation());
15
+ return scope.onRotateChange((newRotation) => {
16
+ setRotation(newRotation);
17
+ });
18
+ }, [provides, documentId]);
14
19
  return {
15
20
  rotation,
16
- provides
21
+ provides: (provides == null ? void 0 : provides.forDocument(documentId)) ?? null
17
22
  };
18
23
  };
19
- function Rotate({ children, pageSize, style, ...props }) {
20
- const { plugin: rotate } = useRotatePlugin();
21
- const matrix = (rotate == null ? void 0 : rotate.getMatrixAsString({
22
- w: pageSize.width,
23
- h: pageSize.height
24
- })) || "matrix(1, 0, 0, 1, 0, 0)";
24
+ function Rotate({
25
+ children,
26
+ documentId,
27
+ pageIndex,
28
+ rotation: rotationOverride,
29
+ scale: scaleOverride,
30
+ style,
31
+ ...props
32
+ }) {
33
+ var _a, _b, _c, _d;
34
+ const { plugin: rotatePlugin } = useRotatePlugin();
35
+ const documentState = useDocumentState(documentId);
36
+ const page = (_b = (_a = documentState == null ? void 0 : documentState.document) == null ? void 0 : _a.pages) == null ? void 0 : _b[pageIndex];
37
+ const width = ((_c = page == null ? void 0 : page.size) == null ? void 0 : _c.width) ?? 0;
38
+ const height = ((_d = page == null ? void 0 : page.size) == null ? void 0 : _d.height) ?? 0;
39
+ const rotation = rotationOverride ?? (documentState == null ? void 0 : documentState.rotation) ?? 0;
40
+ const scale = scaleOverride ?? (documentState == null ? void 0 : documentState.scale) ?? 1;
41
+ const matrix = (rotatePlugin == null ? void 0 : rotatePlugin.getMatrixAsString({
42
+ width: width * scale,
43
+ height: height * scale,
44
+ rotation
45
+ })) ?? "matrix(1, 0, 0, 1, 0, 0)";
46
+ if (!page) return null;
25
47
  return /* @__PURE__ */ jsx(
26
48
  "div",
27
49
  {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/shared/hooks/use-rotate.ts","../../src/shared/components/rotate.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport { Rotation } from '@embedpdf/models';\nimport { RotatePlugin } from '@embedpdf/plugin-rotate';\nimport { useEffect, useState } from '@framework';\n\nexport const useRotatePlugin = () => usePlugin<RotatePlugin>(RotatePlugin.id);\nexport const useRotateCapability = () => useCapability<RotatePlugin>(RotatePlugin.id);\n\nexport const useRotate = () => {\n const { provides } = useRotateCapability();\n const [rotation, setRotation] = useState<Rotation>(0);\n\n useEffect(() => {\n return provides?.onRotateChange((rotation) => setRotation(rotation));\n }, [provides]);\n\n return {\n rotation,\n provides,\n };\n};\n","import { ReactNode, HTMLAttributes, CSSProperties } from '@framework';\nimport { Size } from '@embedpdf/models';\n\nimport { useRotatePlugin } from '../hooks';\n\ntype RotateProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {\n children: ReactNode;\n pageSize: Size;\n style?: CSSProperties;\n};\n\nexport function Rotate({ children, pageSize, style, ...props }: RotateProps) {\n const { plugin: rotate } = useRotatePlugin();\n const matrix =\n rotate?.getMatrixAsString({\n w: pageSize.width,\n h: pageSize.height,\n }) || 'matrix(1, 0, 0, 1, 0, 0)';\n\n return (\n <div\n {...props}\n style={{\n position: 'absolute',\n transformOrigin: '0 0',\n transform: matrix,\n ...style,\n }}\n >\n {children}\n </div>\n );\n}\n"],"names":["rotation"],"mappings":";;;;;AAKO,MAAM,kBAAkB,MAAM,UAAwB,aAAa,EAAE;AACrE,MAAM,sBAAsB,MAAM,cAA4B,aAAa,EAAE;AAE7E,MAAM,YAAY,MAAM;AACvB,QAAA,EAAE,SAAS,IAAI,oBAAoB;AACzC,QAAM,CAAC,UAAU,WAAW,IAAI,SAAmB,CAAC;AAEpD,YAAU,MAAM;AACd,WAAO,qCAAU,eAAe,CAACA,cAAa,YAAYA,SAAQ;AAAA,EAAC,GAClE,CAAC,QAAQ,CAAC;AAEN,SAAA;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;ACTO,SAAS,OAAO,EAAE,UAAU,UAAU,OAAO,GAAG,SAAsB;AAC3E,QAAM,EAAE,QAAQ,OAAO,IAAI,gBAAgB;AACrC,QAAA,UACJ,iCAAQ,kBAAkB;AAAA,IACxB,GAAG,SAAS;AAAA,IACZ,GAAG,SAAS;AAAA,EACb,OAAK;AAGN,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACE,GAAG;AAAA,MACJ,OAAO;AAAA,QACL,UAAU;AAAA,QACV,iBAAiB;AAAA,QACjB,WAAW;AAAA,QACX,GAAG;AAAA,MACL;AAAA,MAEC;AAAA,IAAA;AAAA,EACH;AAEJ;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/shared/hooks/use-rotate.ts","../../src/shared/components/rotate.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport { Rotation } from '@embedpdf/models';\nimport { initialDocumentState, RotatePlugin } from '@embedpdf/plugin-rotate';\nimport { useEffect, useState } from '@framework';\n\nexport const useRotatePlugin = () => usePlugin<RotatePlugin>(RotatePlugin.id);\nexport const useRotateCapability = () => useCapability<RotatePlugin>(RotatePlugin.id);\n\n/**\n * Hook for rotation state for a specific document\n * @param documentId Document ID\n */\nexport const useRotate = (documentId: string) => {\n const { provides } = useRotateCapability();\n const [rotation, setRotation] = useState<Rotation>(initialDocumentState.rotation);\n\n useEffect(() => {\n if (!provides) return;\n\n const scope = provides.forDocument(documentId);\n\n // Get initial state\n setRotation(scope.getRotation());\n\n // Subscribe to rotation changes\n return scope.onRotateChange((newRotation) => {\n setRotation(newRotation);\n });\n }, [provides, documentId]);\n\n return {\n rotation,\n provides: provides?.forDocument(documentId) ?? null,\n };\n};\n","import { ReactNode, HTMLAttributes, CSSProperties } from '@framework';\nimport { useDocumentState } from '@embedpdf/core/@framework';\nimport { Rotation } from '@embedpdf/models';\n\nimport { useRotatePlugin } from '../hooks';\n\ntype RotateProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {\n children: ReactNode;\n documentId: string;\n pageIndex: number;\n rotation?: Rotation;\n scale?: number;\n style?: CSSProperties;\n};\n\nexport function Rotate({\n children,\n documentId,\n pageIndex,\n rotation: rotationOverride,\n scale: scaleOverride,\n style,\n ...props\n}: RotateProps) {\n const { plugin: rotatePlugin } = useRotatePlugin();\n const documentState = useDocumentState(documentId);\n\n const page = documentState?.document?.pages?.[pageIndex];\n const width = page?.size?.width ?? 0;\n const height = page?.size?.height ?? 0;\n const rotation = rotationOverride ?? documentState?.rotation ?? 0;\n const scale = scaleOverride ?? documentState?.scale ?? 1;\n\n const matrix =\n rotatePlugin?.getMatrixAsString({\n width: width * scale,\n height: height * scale,\n rotation: rotation,\n }) ?? 'matrix(1, 0, 0, 1, 0, 0)';\n\n if (!page) return null;\n\n return (\n <div\n {...props}\n style={{\n position: 'absolute',\n transformOrigin: '0 0',\n transform: matrix,\n ...style,\n }}\n >\n {children}\n </div>\n );\n}\n"],"names":[],"mappings":";;;;;AAKO,MAAM,kBAAkB,MAAM,UAAwB,aAAa,EAAE;AACrE,MAAM,sBAAsB,MAAM,cAA4B,aAAa,EAAE;AAM7E,MAAM,YAAY,CAAC,eAAuB;AAC/C,QAAM,EAAE,SAAA,IAAa,oBAAA;AACrB,QAAM,CAAC,UAAU,WAAW,IAAI,SAAmB,qBAAqB,QAAQ;AAEhF,YAAU,MAAM;AACd,QAAI,CAAC,SAAU;AAEf,UAAM,QAAQ,SAAS,YAAY,UAAU;AAG7C,gBAAY,MAAM,aAAa;AAG/B,WAAO,MAAM,eAAe,CAAC,gBAAgB;AAC3C,kBAAY,WAAW;AAAA,IACzB,CAAC;AAAA,EACH,GAAG,CAAC,UAAU,UAAU,CAAC;AAEzB,SAAO;AAAA,IACL;AAAA,IACA,WAAU,qCAAU,YAAY,gBAAe;AAAA,EAAA;AAEnD;ACnBO,SAAS,OAAO;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV,OAAO;AAAA,EACP;AAAA,EACA,GAAG;AACL,GAAgB;;AACd,QAAM,EAAE,QAAQ,aAAA,IAAiB,gBAAA;AACjC,QAAM,gBAAgB,iBAAiB,UAAU;AAEjD,QAAM,QAAO,0DAAe,aAAf,mBAAyB,UAAzB,mBAAiC;AAC9C,QAAM,UAAQ,kCAAM,SAAN,mBAAY,UAAS;AACnC,QAAM,WAAS,kCAAM,SAAN,mBAAY,WAAU;AACrC,QAAM,WAAW,qBAAoB,+CAAe,aAAY;AAChE,QAAM,QAAQ,kBAAiB,+CAAe,UAAS;AAEvD,QAAM,UACJ,6CAAc,kBAAkB;AAAA,IAC9B,OAAO,QAAQ;AAAA,IACf,QAAQ,SAAS;AAAA,IACjB;AAAA,EAAA,OACI;AAER,MAAI,CAAC,KAAM,QAAO;AAElB,SACE;AAAA,IAAC;AAAA,IAAA;AAAA,MACE,GAAG;AAAA,MACJ,OAAO;AAAA,QACL,UAAU;AAAA,QACV,iBAAiB;AAAA,QACjB,WAAW;AAAA,QACX,GAAG;AAAA,MAAA;AAAA,MAGJ;AAAA,IAAA;AAAA,EAAA;AAGP;"}
@@ -1,9 +1,12 @@
1
1
  import { ReactNode, HTMLAttributes, CSSProperties } from '../../react/adapter.ts';
2
- import { Size } from '@embedpdf/models';
2
+ import { Rotation } from '@embedpdf/models';
3
3
  type RotateProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
4
4
  children: ReactNode;
5
- pageSize: Size;
5
+ documentId: string;
6
+ pageIndex: number;
7
+ rotation?: Rotation;
8
+ scale?: number;
6
9
  style?: CSSProperties;
7
10
  };
8
- export declare function Rotate({ children, pageSize, style, ...props }: RotateProps): import("react/jsx-runtime").JSX.Element;
11
+ export declare function Rotate({ children, documentId, pageIndex, rotation: rotationOverride, scale: scaleOverride, style, ...props }: RotateProps): import("react/jsx-runtime").JSX.Element | null;
9
12
  export {};
@@ -10,7 +10,11 @@ export declare const useRotateCapability: () => {
10
10
  isLoading: boolean;
11
11
  ready: Promise<void>;
12
12
  };
13
- export declare const useRotate: () => {
13
+ /**
14
+ * Hook for rotation state for a specific document
15
+ * @param documentId Document ID
16
+ */
17
+ export declare const useRotate: (documentId: string) => {
14
18
  rotation: Rotation;
15
- provides: Readonly<import('../../index.ts').RotateCapability> | null;
19
+ provides: import('../../index.ts').RotateScope | null;
16
20
  };
@@ -1,9 +1,12 @@
1
1
  import { ReactNode, HTMLAttributes, CSSProperties } from '../../preact/adapter.ts';
2
- import { Size } from '@embedpdf/models';
2
+ import { Rotation } from '@embedpdf/models';
3
3
  type RotateProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
4
4
  children: ReactNode;
5
- pageSize: Size;
5
+ documentId: string;
6
+ pageIndex: number;
7
+ rotation?: Rotation;
8
+ scale?: number;
6
9
  style?: CSSProperties;
7
10
  };
8
- export declare function Rotate({ children, pageSize, style, ...props }: RotateProps): import("preact").JSX.Element;
11
+ export declare function Rotate({ children, documentId, pageIndex, rotation: rotationOverride, scale: scaleOverride, style, ...props }: RotateProps): import("preact").JSX.Element | null;
9
12
  export {};
@@ -10,7 +10,11 @@ export declare const useRotateCapability: () => {
10
10
  isLoading: boolean;
11
11
  ready: Promise<void>;
12
12
  };
13
- export declare const useRotate: () => {
13
+ /**
14
+ * Hook for rotation state for a specific document
15
+ * @param documentId Document ID
16
+ */
17
+ export declare const useRotate: (documentId: string) => {
14
18
  rotation: Rotation;
15
- provides: Readonly<import('../../lib/index.ts').RotateCapability> | null;
19
+ provides: import('../../lib/index.ts').RotateScope | null;
16
20
  };
@@ -1,9 +1,12 @@
1
1
  import { ReactNode, HTMLAttributes, CSSProperties } from '../../react/adapter.ts';
2
- import { Size } from '@embedpdf/models';
2
+ import { Rotation } from '@embedpdf/models';
3
3
  type RotateProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
4
4
  children: ReactNode;
5
- pageSize: Size;
5
+ documentId: string;
6
+ pageIndex: number;
7
+ rotation?: Rotation;
8
+ scale?: number;
6
9
  style?: CSSProperties;
7
10
  };
8
- export declare function Rotate({ children, pageSize, style, ...props }: RotateProps): import("react/jsx-runtime").JSX.Element;
11
+ export declare function Rotate({ children, documentId, pageIndex, rotation: rotationOverride, scale: scaleOverride, style, ...props }: RotateProps): import("react/jsx-runtime").JSX.Element | null;
9
12
  export {};
@@ -10,7 +10,11 @@ export declare const useRotateCapability: () => {
10
10
  isLoading: boolean;
11
11
  ready: Promise<void>;
12
12
  };
13
- export declare const useRotate: () => {
13
+ /**
14
+ * Hook for rotation state for a specific document
15
+ * @param documentId Document ID
16
+ */
17
+ export declare const useRotate: (documentId: string) => {
14
18
  rotation: Rotation;
15
- provides: Readonly<import('../../lib/index.ts').RotateCapability> | null;
19
+ provides: import('../../lib/index.ts').RotateScope | null;
16
20
  };
@@ -1,9 +1,15 @@
1
- import { Size } from '@embedpdf/models';
1
+ import { Rotation } from '@embedpdf/models';
2
2
  import { Snippet } from 'svelte';
3
- interface RotateProps {
4
- pageSize: Size;
3
+ import { HTMLAttributes } from 'svelte/elements';
4
+ type RotateProps = HTMLAttributes<HTMLDivElement> & {
5
+ documentId: string;
6
+ pageIndex: number;
7
+ rotation?: Rotation;
8
+ scale?: number;
5
9
  children?: Snippet;
6
- }
10
+ class?: string;
11
+ style?: string;
12
+ };
7
13
  declare const Rotate: import('svelte', { with: { "resolution-mode": "import" } }).Component<RotateProps, {}, "">;
8
14
  type Rotate = ReturnType<typeof Rotate>;
9
15
  export default Rotate;
@@ -1,5 +1,5 @@
1
1
  import { Rotation } from '@embedpdf/models';
2
- import { RotatePlugin } from '../../lib/index.ts';
2
+ import { RotatePlugin, RotateScope } from '../../lib/index.ts';
3
3
  /**
4
4
  * Hook to get the raw rotate plugin instance.
5
5
  */
@@ -17,10 +17,13 @@ export declare const useRotateCapability: () => {
17
17
  isLoading: boolean;
18
18
  ready: Promise<void>;
19
19
  };
20
+ interface UseRotateReturn {
21
+ provides: RotateScope | null;
22
+ rotation: Rotation;
23
+ }
20
24
  /**
21
- * Hook that provides reactive rotation state and methods.
25
+ * Hook that provides reactive rotation state and methods for a specific document.
26
+ * @param getDocumentId Function that returns the document ID
22
27
  */
23
- export declare const useRotate: () => {
24
- readonly provides: Readonly<import('../../lib/index.ts').RotateCapability> | null;
25
- rotation: Rotation;
26
- };
28
+ export declare const useRotate: (getDocumentId: () => string | null) => UseRotateReturn;
29
+ export {};
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("svelte/internal/client"),t=require("@embedpdf/core/svelte"),r=require("@embedpdf/plugin-rotate");function o(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const r in e)if("default"!==r){const o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,o.get?o:{enumerable:!0,get:()=>e[r]})}return t.default=e,Object.freeze(t)}require("svelte/internal/disclose-version");const i=o(e),n=()=>t.usePlugin(r.RotatePlugin.id),s=()=>t.useCapability(r.RotatePlugin.id);var a=i.from_html("<div><!></div>");exports.Rotate=function(e,t){i.push(t,!0);const r=n(),o=i.derived((()=>r.plugin?r.plugin.getMatrixAsString({w:t.pageSize.width,h:t.pageSize.height}):"matrix(1, 0, 0, 1, 0, 0)"));var s=a();let p;var l=i.child(s);i.snippet(l,(()=>t.children??i.noop)),i.reset(s),i.template_effect((e=>p=i.set_style(s,"",p,e)),[()=>({position:"absolute","transform-origin":"0 0",transform:i.get(o)})]),i.append(e,s),i.pop()},exports.useRotate=()=>{const e=s(),t=i.proxy({get provides(){return e.provides},rotation:0});return i.user_effect((()=>{if(!e.provides)return;return e.provides.onRotateChange((e=>{t.rotation=e}))})),t},exports.useRotateCapability=s,exports.useRotatePlugin=n,Object.keys(r).forEach((e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>r[e]})}));
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("svelte/internal/client"),t=require("@embedpdf/core/svelte"),r=require("@embedpdf/plugin-rotate");function o(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const r in e)if("default"!==r){const o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,o.get?o:{enumerable:!0,get:()=>e[r]})}return t.default=e,Object.freeze(t)}require("svelte/internal/disclose-version");const n=o(e),i=()=>t.usePlugin(r.RotatePlugin.id),l=()=>t.useCapability(r.RotatePlugin.id);var s=n.from_html("<div><!></div>");exports.Rotate=function(e,r){n.push(r,!0);let o=n.rest_props(r,["$$slots","$$events","$$legacy","documentId","pageIndex","rotation","scale","children","class","style"]);const l=i(),a=t.useDocumentState(()=>r.documentId),u=n.derived(()=>{var e,t,o;return null==(o=null==(t=null==(e=a.current)?void 0:e.document)?void 0:t.pages)?void 0:o[r.pageIndex]}),d=n.derived(()=>{var e,t;return(null==(t=null==(e=n.get(u))?void 0:e.size)?void 0:t.width)??0}),c=n.derived(()=>{var e,t;return(null==(t=null==(e=n.get(u))?void 0:e.size)?void 0:t.height)??0}),p=n.derived(()=>{var e;return void 0!==r.rotation?r.rotation:(null==(e=a.current)?void 0:e.rotation)??0}),g=n.derived(()=>{var e;return void 0!==r.scale?r.scale:(null==(e=a.current)?void 0:e.scale)??1}),v=n.derived(()=>l.plugin?l.plugin.getMatrixAsString({width:n.get(d)*n.get(g),height:n.get(c)*n.get(g),rotation:n.get(p)}):"matrix(1, 0, 0, 1, 0, 0)");var f=n.comment(),m=n.first_child(f),b=e=>{var t=s();n.attribute_effect(t,()=>({class:r.class,style:r.style,...o,[n.STYLE]:{position:"absolute","transform-origin":"0 0",transform:n.get(v)}}));var i=n.child(t);n.snippet(i,()=>r.children??n.noop),n.reset(t),n.append(e,t)};n.if(m,e=>{n.get(u)&&e(b)}),n.append(e,f),n.pop()},exports.useRotate=e=>{const t=l();let o=n.state(n.proxy(r.initialDocumentState.rotation));const i=n.derived(e),s=n.derived(()=>t.provides&&n.get(i)?t.provides.forDocument(n.get(i)):null);return n.user_effect(()=>{const e=t.provides,l=n.get(i);if(!e||!l)return void n.set(o,r.initialDocumentState.rotation,!0);const s=e.forDocument(l);return n.set(o,s.getRotation(),!0),s.onRotateChange(e=>{n.set(o,e,!0)})}),{get provides(){return n.get(s)},get rotation(){return n.get(o)}}},exports.useRotateCapability=l,exports.useRotatePlugin=i,Object.keys(r).forEach(e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>r[e]})});
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../src/svelte/hooks/use-rotate.svelte.ts","../../src/svelte/components/Rotate.svelte"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/svelte';\nimport { Rotation } from '@embedpdf/models';\nimport { RotatePlugin } from '@embedpdf/plugin-rotate';\n\n/**\n * Hook to get the raw rotate plugin instance.\n */\nexport const useRotatePlugin = () => usePlugin<RotatePlugin>(RotatePlugin.id);\n\n/**\n * Hook to get the rotate plugin's capability API.\n * This provides methods for rotating the document.\n */\nexport const useRotateCapability = () => useCapability<RotatePlugin>(RotatePlugin.id);\n\n/**\n * Hook that provides reactive rotation state and methods.\n */\nexport const useRotate = () => {\n const capability = useRotateCapability();\n\n const state = $state({\n get provides() {\n return capability.provides;\n },\n rotation: 0 as Rotation,\n });\n\n $effect(() => {\n if (!capability.provides) return;\n\n const unsubscribe = capability.provides.onRotateChange((newRotation) => {\n state.rotation = newRotation;\n });\n\n return unsubscribe;\n });\n\n return state;\n};\n","<script lang=\"ts\">\n import type { Size } from '@embedpdf/models';\n import type { Snippet } from 'svelte';\n import { useRotatePlugin } from '../hooks';\n\n interface RotateProps {\n pageSize: Size;\n children?: Snippet;\n }\n\n let { pageSize, children }: RotateProps = $props();\n\n const rotatePlugin = useRotatePlugin();\n\n const transformMatrix = $derived(\n rotatePlugin.plugin\n ? rotatePlugin.plugin.getMatrixAsString({\n w: pageSize.width,\n h: pageSize.height,\n })\n : 'matrix(1, 0, 0, 1, 0, 0)',\n );\n</script>\n\n<div style:position=\"absolute\" style:transform-origin=\"0 0\" style:transform={transformMatrix}>\n {@render children?.()}\n</div>\n"],"names":["useRotatePlugin","usePlugin","RotatePlugin","id","useRotateCapability","useCapability","rotatePlugin","transformMatrix","$","derived","plugin","getMatrixAsString","w","$$props","pageSize","width","h","height","capability","state","provides","rotation","user_effect","onRotateChange","newRotation"],"mappings":"sgBAOaA,EAAwB,IAAAC,YAAwBC,EAAAA,aAAaC,IAM7DC,EAA4B,IAAAC,gBAA4BH,EAAAA,aAAaC,kFCD1E,MAAAG,EAAeN,IAEfO,EAAeC,EAAAC,SAAA,IACnBH,EAAaI,OACTJ,EAAaI,OAAOC,kBAAiB,CACnCC,EAACC,EAAAC,SAAWC,MACZC,EAACH,EAAAC,SAAWG,SAEd,kOAIqEV,4BAF7E,yBDHQ,MAAAW,EAAad,IAEbe,WACA,YAAAC,GACK,OAAAF,EAAWE,QACpB,EACAC,SAAU,IAaL,OAVPb,EAAAc,kBACO,IAAAJ,EAAWE,SAAU,OAMnB,OAJaF,EAAWE,SAASG,gBAAgBC,IACtDL,EAAME,SAAWG,CAAA,GAGZ,IAGFL,CAAA"}
1
+ {"version":3,"file":"index.cjs","sources":["../../src/svelte/hooks/use-rotate.svelte.ts","../../src/svelte/components/Rotate.svelte"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/svelte';\nimport { Rotation } from '@embedpdf/models';\nimport { RotatePlugin, initialDocumentState, RotateScope } from '@embedpdf/plugin-rotate';\n\n/**\n * Hook to get the raw rotate plugin instance.\n */\nexport const useRotatePlugin = () => usePlugin<RotatePlugin>(RotatePlugin.id);\n\n/**\n * Hook to get the rotate plugin's capability API.\n * This provides methods for rotating the document.\n */\nexport const useRotateCapability = () => useCapability<RotatePlugin>(RotatePlugin.id);\n\n// Define the return type explicitly to maintain type safety\ninterface UseRotateReturn {\n provides: RotateScope | null;\n rotation: Rotation;\n}\n\n/**\n * Hook that provides reactive rotation state and methods for a specific document.\n * @param getDocumentId Function that returns the document ID\n */\nexport const useRotate = (getDocumentId: () => string | null): UseRotateReturn => {\n const capability = useRotateCapability();\n\n let rotation = $state<Rotation>(initialDocumentState.rotation);\n\n // Reactive documentId\n const documentId = $derived(getDocumentId());\n\n // Scoped capability for current docId\n const scopedProvides = $derived(\n capability.provides && documentId ? capability.provides.forDocument(documentId) : null,\n );\n\n $effect(() => {\n const provides = capability.provides;\n const docId = documentId;\n\n if (!provides || !docId) {\n rotation = initialDocumentState.rotation;\n return;\n }\n\n const scope = provides.forDocument(docId);\n\n // Get initial state\n rotation = scope.getRotation();\n\n // Subscribe to rotation changes for this document\n return scope.onRotateChange((newRotation) => {\n rotation = newRotation;\n });\n });\n\n return {\n get provides() {\n return scopedProvides;\n },\n get rotation() {\n return rotation;\n },\n };\n};\n","<script lang=\"ts\">\n import type { Rotation } from '@embedpdf/models';\n import type { Snippet } from 'svelte';\n import type { HTMLAttributes } from 'svelte/elements';\n import { useDocumentState } from '@embedpdf/core/svelte';\n import { useRotatePlugin } from '../hooks';\n\n type RotateProps = HTMLAttributes<HTMLDivElement> & {\n documentId: string;\n pageIndex: number;\n rotation?: Rotation;\n scale?: number;\n children?: Snippet;\n class?: string;\n style?: string;\n };\n\n let {\n documentId,\n pageIndex,\n rotation: rotationOverride,\n scale: scaleOverride,\n children,\n class: propsClass,\n style: propsStyle,\n ...restProps\n }: RotateProps = $props();\n\n const rotatePlugin = useRotatePlugin();\n const documentState = useDocumentState(() => documentId);\n\n const page = $derived(documentState.current?.document?.pages?.[pageIndex]);\n const width = $derived(page?.size?.width ?? 0);\n const height = $derived(page?.size?.height ?? 0);\n\n const rotation = $derived(\n rotationOverride !== undefined ? rotationOverride : (documentState.current?.rotation ?? 0),\n );\n\n const scale = $derived(\n scaleOverride !== undefined ? scaleOverride : (documentState.current?.scale ?? 1),\n );\n\n const matrix = $derived(\n rotatePlugin.plugin\n ? rotatePlugin.plugin.getMatrixAsString({\n width: width * scale,\n height: height * scale,\n rotation: rotation,\n })\n : 'matrix(1, 0, 0, 1, 0, 0)',\n );\n</script>\n\n{#if page}\n <div\n class={propsClass}\n style:position=\"absolute\"\n style:transform-origin=\"0 0\"\n style:transform={matrix}\n style={propsStyle}\n {...restProps}\n >\n {@render children?.()}\n </div>\n{/if}\n"],"names":["useRotatePlugin","usePlugin","RotatePlugin","id","useRotateCapability","useCapability","restProps","$","rest_props","$$props","rotatePlugin","documentState","useDocumentState","documentId","page","_c","_b","_a","current","document","pages","pageIndex","width","size","height","rotation","scale","derived","matrix","plugin","getMatrixAsString","get","consequent","getDocumentId","capability","state","proxy","initialDocumentState","scopedProvides","provides","forDocument","user_effect","docId","scope","getRotation","onRotateChange","newRotation","set"],"mappings":"sgBAOaA,EAAA,IAAwBC,YAAwBC,EAAAA,aAAaC,IAM7DC,EAAA,IAA4BC,gBAA4BH,EAAAA,aAAaC,sFCY3EG,EAAQC,EAAAC,WAAAC,EAAA,0GAGP,MAAAC,EAAeV,IACfW,EAAgBC,EAAAA,iBAAgB,IAAAH,EAAAI,YAEhCC,2BAAgB,OAAA,OAAAC,EAAA,OAAAC,EAAA,OAAAC,EAAAN,EAAcO,cAAd,EAAAD,EAAuBE,eAAvB,EAAAH,EAAiCI,gBAAKX,EAAAY,aACtDC,wDAAiBR,aAAMS,eAAMD,QAAS,IACtCE,wDAAkBV,aAAMS,eAAMC,SAAU,IAExCC,mCACiB,2BAAgC,OAAAR,EAAAN,EAAcO,kBAASO,WAAY,IAGpFC,EAAKnB,EAAAoB,QAAA,WAAA,YACS,IADTlB,EAAAiB,MACkBjB,EAAAiB,OAAoB,OAAAT,EAAAN,EAAcO,kBAASQ,QAAS,IAG3EE,EAAMrB,EAAAoB,QAAA,IACVjB,EAAamB,OACTnB,EAAamB,OAAOC,kBAAiB,CACnCR,MAAKf,EAAAwB,IAAET,GAAKf,EAAAwB,IAAGL,GACfF,OAAMjB,EAAAwB,IAAEP,GAAMjB,EAAAwB,IAAGL,GACjBD,eAAUA,KAEZ,2IAWAnB,0EAFasB,uGALhBd,MAAIkB,0BAFT,oBD3B0BC,IAClB,MAAAC,EAAa9B,QAEfqB,EAAAlB,EAAA4B,MAAA5B,EAAA6B,MAA4BC,EAAAA,qBAAqBZ,WAG/C,MAAAZ,YAAsBoB,GAGtBK,EAAA/B,EAAAoB,QAAA,IACJO,EAAWK,gBAAY1B,GAAaqB,EAAWK,SAASC,kBAAY3B,IAAc,aAGpFN,EAAAkC,uBACQF,EAAWL,EAAWK,SACtBG,QAAQ7B,OAET0B,IAAaG,oBAChBjB,EAAWY,EAAAA,qBAAqBZ,UAAA,GAI5B,MAAAkB,EAAQJ,EAASC,YAAYE,GAM5B,aAHPjB,EAAWkB,EAAMC,eAAA,GAGVD,EAAME,eAAgBC,IAC3BvC,EAAAwC,IAAAtB,EAAWqB,GAAA,QAKT,YAAAP,gBACKD,EACT,EACI,YAAAb,gBACKA,EACT"}
@@ -1,45 +1,104 @@
1
1
  import * as $ from "svelte/internal/client";
2
- import { usePlugin, useCapability } from "@embedpdf/core/svelte";
3
- import { RotatePlugin } from "@embedpdf/plugin-rotate";
2
+ import { usePlugin, useCapability, useDocumentState } from "@embedpdf/core/svelte";
3
+ import { RotatePlugin, initialDocumentState } from "@embedpdf/plugin-rotate";
4
4
  export * from "@embedpdf/plugin-rotate";
5
5
  import "svelte/internal/disclose-version";
6
6
  const useRotatePlugin = () => usePlugin(RotatePlugin.id);
7
7
  const useRotateCapability = () => useCapability(RotatePlugin.id);
8
- const useRotate = () => {
8
+ const useRotate = (getDocumentId) => {
9
9
  const capability = useRotateCapability();
10
- const state = $.proxy({
11
- get provides() {
12
- return capability.provides;
13
- },
14
- rotation: 0
15
- });
10
+ let rotation = $.state($.proxy(initialDocumentState.rotation));
11
+ const documentId = $.derived(getDocumentId);
12
+ const scopedProvides = $.derived(() => capability.provides && $.get(documentId) ? capability.provides.forDocument($.get(documentId)) : null);
16
13
  $.user_effect(() => {
17
- if (!capability.provides) return;
18
- const unsubscribe = capability.provides.onRotateChange((newRotation) => {
19
- state.rotation = newRotation;
14
+ const provides = capability.provides;
15
+ const docId = $.get(documentId);
16
+ if (!provides || !docId) {
17
+ $.set(rotation, initialDocumentState.rotation, true);
18
+ return;
19
+ }
20
+ const scope = provides.forDocument(docId);
21
+ $.set(rotation, scope.getRotation(), true);
22
+ return scope.onRotateChange((newRotation) => {
23
+ $.set(rotation, newRotation, true);
20
24
  });
21
- return unsubscribe;
22
25
  });
23
- return state;
26
+ return {
27
+ get provides() {
28
+ return $.get(scopedProvides);
29
+ },
30
+ get rotation() {
31
+ return $.get(rotation);
32
+ }
33
+ };
24
34
  };
25
- var root = $.from_html(`<div><!></div>`);
35
+ var root_1 = $.from_html(`<div><!></div>`);
26
36
  function Rotate($$anchor, $$props) {
27
37
  $.push($$props, true);
28
- const rotatePlugin = useRotatePlugin();
29
- const transformMatrix = $.derived(() => rotatePlugin.plugin ? rotatePlugin.plugin.getMatrixAsString({ w: $$props.pageSize.width, h: $$props.pageSize.height }) : "matrix(1, 0, 0, 1, 0, 0)");
30
- var div = root();
31
- let styles;
32
- var node = $.child(div);
33
- $.snippet(node, () => $$props.children ?? $.noop);
34
- $.reset(div);
35
- $.template_effect(($0) => styles = $.set_style(div, "", styles, $0), [
36
- () => ({
37
- position: "absolute",
38
- "transform-origin": "0 0",
39
- transform: $.get(transformMatrix)
40
- })
38
+ let restProps = $.rest_props($$props, [
39
+ "$$slots",
40
+ "$$events",
41
+ "$$legacy",
42
+ "documentId",
43
+ "pageIndex",
44
+ "rotation",
45
+ "scale",
46
+ "children",
47
+ "class",
48
+ "style"
41
49
  ]);
42
- $.append($$anchor, div);
50
+ const rotatePlugin = useRotatePlugin();
51
+ const documentState = useDocumentState(() => $$props.documentId);
52
+ const page = $.derived(() => {
53
+ var _a, _b, _c;
54
+ return (_c = (_b = (_a = documentState.current) == null ? void 0 : _a.document) == null ? void 0 : _b.pages) == null ? void 0 : _c[$$props.pageIndex];
55
+ });
56
+ const width = $.derived(() => {
57
+ var _a, _b;
58
+ return ((_b = (_a = $.get(page)) == null ? void 0 : _a.size) == null ? void 0 : _b.width) ?? 0;
59
+ });
60
+ const height = $.derived(() => {
61
+ var _a, _b;
62
+ return ((_b = (_a = $.get(page)) == null ? void 0 : _a.size) == null ? void 0 : _b.height) ?? 0;
63
+ });
64
+ const rotation = $.derived(() => {
65
+ var _a;
66
+ return $$props.rotation !== void 0 ? $$props.rotation : ((_a = documentState.current) == null ? void 0 : _a.rotation) ?? 0;
67
+ });
68
+ const scale = $.derived(() => {
69
+ var _a;
70
+ return $$props.scale !== void 0 ? $$props.scale : ((_a = documentState.current) == null ? void 0 : _a.scale) ?? 1;
71
+ });
72
+ const matrix = $.derived(() => rotatePlugin.plugin ? rotatePlugin.plugin.getMatrixAsString({
73
+ width: $.get(width) * $.get(scale),
74
+ height: $.get(height) * $.get(scale),
75
+ rotation: $.get(rotation)
76
+ }) : "matrix(1, 0, 0, 1, 0, 0)");
77
+ var fragment = $.comment();
78
+ var node = $.first_child(fragment);
79
+ {
80
+ var consequent = ($$anchor2) => {
81
+ var div = root_1();
82
+ $.attribute_effect(div, () => ({
83
+ class: $$props.class,
84
+ style: $$props.style,
85
+ ...restProps,
86
+ [$.STYLE]: {
87
+ position: "absolute",
88
+ "transform-origin": "0 0",
89
+ transform: $.get(matrix)
90
+ }
91
+ }));
92
+ var node_1 = $.child(div);
93
+ $.snippet(node_1, () => $$props.children ?? $.noop);
94
+ $.reset(div);
95
+ $.append($$anchor2, div);
96
+ };
97
+ $.if(node, ($$render) => {
98
+ if ($.get(page)) $$render(consequent);
99
+ });
100
+ }
101
+ $.append($$anchor, fragment);
43
102
  $.pop();
44
103
  }
45
104
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/svelte/hooks/use-rotate.svelte.ts","../../src/svelte/components/Rotate.svelte"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/svelte';\nimport { Rotation } from '@embedpdf/models';\nimport { RotatePlugin } from '@embedpdf/plugin-rotate';\n\n/**\n * Hook to get the raw rotate plugin instance.\n */\nexport const useRotatePlugin = () => usePlugin<RotatePlugin>(RotatePlugin.id);\n\n/**\n * Hook to get the rotate plugin's capability API.\n * This provides methods for rotating the document.\n */\nexport const useRotateCapability = () => useCapability<RotatePlugin>(RotatePlugin.id);\n\n/**\n * Hook that provides reactive rotation state and methods.\n */\nexport const useRotate = () => {\n const capability = useRotateCapability();\n\n const state = $state({\n get provides() {\n return capability.provides;\n },\n rotation: 0 as Rotation,\n });\n\n $effect(() => {\n if (!capability.provides) return;\n\n const unsubscribe = capability.provides.onRotateChange((newRotation) => {\n state.rotation = newRotation;\n });\n\n return unsubscribe;\n });\n\n return state;\n};\n","<script lang=\"ts\">\n import type { Size } from '@embedpdf/models';\n import type { Snippet } from 'svelte';\n import { useRotatePlugin } from '../hooks';\n\n interface RotateProps {\n pageSize: Size;\n children?: Snippet;\n }\n\n let { pageSize, children }: RotateProps = $props();\n\n const rotatePlugin = useRotatePlugin();\n\n const transformMatrix = $derived(\n rotatePlugin.plugin\n ? rotatePlugin.plugin.getMatrixAsString({\n w: pageSize.width,\n h: pageSize.height,\n })\n : 'matrix(1, 0, 0, 1, 0, 0)',\n );\n</script>\n\n<div style:position=\"absolute\" style:transform-origin=\"0 0\" style:transform={transformMatrix}>\n {@render children?.()}\n</div>\n"],"names":[],"mappings":";;;;;AAOa,MAAA,kBAAwB,MAAA,UAAwB,aAAa,EAAE;AAM/D,MAAA,sBAA4B,MAAA,cAA4B,aAAa,EAAE;AAKvE,MAAA,kBAAkB;AACvB,QAAA,aAAa,oBAAoB;QAEjC;IACA,IAAA,WAAW;AACN,aAAA,WAAW;AAAA,IACpB;AAAA,IACA,UAAU;AAAA;AAGZ,IAAA,kBAAc;AACP,QAAA,CAAA,WAAW,SAAU;UAEpB,cAAc,WAAW,SAAS,eAAA,CAAgB,gBAAgB;AACtE,YAAM,WAAW;AAAA,KAClB;WAEM;AAAA,GACR;SAEM;AACT;;mCCvCA;;AAYQ,QAAA,eAAe,gBAAe;QAE9B,kBAAe,EAAA,QAAA,MACnB,aAAa,SACT,aAAa,OAAO,kBAAiB,EACnC,GAAC,QAAA,SAAW,OACZ,GAAC,QAAA,SAAW,OAAM,CAAA,IAEpB,0BAA0B;;;;;;;;;;uBAI2C,eAAe;AAAA;;;;AAF5F;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/svelte/hooks/use-rotate.svelte.ts","../../src/svelte/components/Rotate.svelte"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/svelte';\nimport { Rotation } from '@embedpdf/models';\nimport { RotatePlugin, initialDocumentState, RotateScope } from '@embedpdf/plugin-rotate';\n\n/**\n * Hook to get the raw rotate plugin instance.\n */\nexport const useRotatePlugin = () => usePlugin<RotatePlugin>(RotatePlugin.id);\n\n/**\n * Hook to get the rotate plugin's capability API.\n * This provides methods for rotating the document.\n */\nexport const useRotateCapability = () => useCapability<RotatePlugin>(RotatePlugin.id);\n\n// Define the return type explicitly to maintain type safety\ninterface UseRotateReturn {\n provides: RotateScope | null;\n rotation: Rotation;\n}\n\n/**\n * Hook that provides reactive rotation state and methods for a specific document.\n * @param getDocumentId Function that returns the document ID\n */\nexport const useRotate = (getDocumentId: () => string | null): UseRotateReturn => {\n const capability = useRotateCapability();\n\n let rotation = $state<Rotation>(initialDocumentState.rotation);\n\n // Reactive documentId\n const documentId = $derived(getDocumentId());\n\n // Scoped capability for current docId\n const scopedProvides = $derived(\n capability.provides && documentId ? capability.provides.forDocument(documentId) : null,\n );\n\n $effect(() => {\n const provides = capability.provides;\n const docId = documentId;\n\n if (!provides || !docId) {\n rotation = initialDocumentState.rotation;\n return;\n }\n\n const scope = provides.forDocument(docId);\n\n // Get initial state\n rotation = scope.getRotation();\n\n // Subscribe to rotation changes for this document\n return scope.onRotateChange((newRotation) => {\n rotation = newRotation;\n });\n });\n\n return {\n get provides() {\n return scopedProvides;\n },\n get rotation() {\n return rotation;\n },\n };\n};\n","<script lang=\"ts\">\n import type { Rotation } from '@embedpdf/models';\n import type { Snippet } from 'svelte';\n import type { HTMLAttributes } from 'svelte/elements';\n import { useDocumentState } from '@embedpdf/core/svelte';\n import { useRotatePlugin } from '../hooks';\n\n type RotateProps = HTMLAttributes<HTMLDivElement> & {\n documentId: string;\n pageIndex: number;\n rotation?: Rotation;\n scale?: number;\n children?: Snippet;\n class?: string;\n style?: string;\n };\n\n let {\n documentId,\n pageIndex,\n rotation: rotationOverride,\n scale: scaleOverride,\n children,\n class: propsClass,\n style: propsStyle,\n ...restProps\n }: RotateProps = $props();\n\n const rotatePlugin = useRotatePlugin();\n const documentState = useDocumentState(() => documentId);\n\n const page = $derived(documentState.current?.document?.pages?.[pageIndex]);\n const width = $derived(page?.size?.width ?? 0);\n const height = $derived(page?.size?.height ?? 0);\n\n const rotation = $derived(\n rotationOverride !== undefined ? rotationOverride : (documentState.current?.rotation ?? 0),\n );\n\n const scale = $derived(\n scaleOverride !== undefined ? scaleOverride : (documentState.current?.scale ?? 1),\n );\n\n const matrix = $derived(\n rotatePlugin.plugin\n ? rotatePlugin.plugin.getMatrixAsString({\n width: width * scale,\n height: height * scale,\n rotation: rotation,\n })\n : 'matrix(1, 0, 0, 1, 0, 0)',\n );\n</script>\n\n{#if page}\n <div\n class={propsClass}\n style:position=\"absolute\"\n style:transform-origin=\"0 0\"\n style:transform={matrix}\n style={propsStyle}\n {...restProps}\n >\n {@render children?.()}\n </div>\n{/if}\n"],"names":[],"mappings":";;;;;AAOa,MAAA,kBAAA,MAAwB,UAAwB,aAAa,EAAE;AAM/D,MAAA,sBAAA,MAA4B,cAA4B,aAAa,EAAE;MAYvE,YAAA,CAAa,kBAAwD;AAC1E,QAAA,aAAa,oBAAA;MAEf,WAAA,EAAA,MAAA,EAAA,MAA4B,qBAAqB,QAAQ,CAAA;AAGvD,QAAA,uBAAsB,aAAA;AAGtB,QAAA,iBAAA,EAAA,QAAA,MACJ,WAAW,kBAAY,UAAA,IAAa,WAAW,SAAS,kBAAY,UAAU,CAAA,IAAI,IAAA;AAGpF,IAAA,kBAAc;UACN,WAAW,WAAW;AACtB,UAAA,cAAQ,UAAA;SAET,YAAA,CAAa,OAAO;YACvB,UAAW,qBAAqB,UAAA,IAAA;;IAElC;AAEM,UAAA,QAAQ,SAAS,YAAY,KAAK;UAGxC,UAAW,MAAM,YAAA,GAAA,IAAA;AAGV,WAAA,MAAM,eAAA,CAAgB,gBAAgB;AAC3C,QAAA,IAAA,UAAW,aAAA,IAAA;AAAA,IACb,CAAC;AAAA,EACH,CAAC;;IAGK,IAAA,WAAW;mBACN,cAAA;AAAA,IACT;AAAA,IACI,IAAA,WAAW;mBACN,QAAA;AAAA,IACT;AAAA;AAEJ;;mCClEA;;MAyBO,YAAQ,EAAA,WAAA,SAAA;AAAA;;;;;;;;;;;AAGP,QAAA,eAAe,gBAAe;AAC9B,QAAA,gBAAgB,iBAAgB,MAAA,QAAA,UAAA;AAEhC,QAAA;;AAAgB,2CAAc,YAAd,mBAAuB,aAAvB,mBAAiC,UAAjC,mBAAsC,QAAA;AAAA,GAAA;AACtD,QAAA;;8BAAiB,IAAI,yBAAE,4BAAM,UAAS;AAAA,GAAC;AACvC,QAAA;;8BAAkB,IAAI,yBAAE,4BAAM,WAAU;AAAA,GAAC;AAEzC,QAAA;;gCACiB,8BAAgC,mBAAc,YAAd,mBAAuB,aAAY;AAAA,GAAC;QAGrF,QAAK,EAAA,QAAA,MAAA;;AAAA,mBAAA,UACS,SAAS,QAAA,UAAoB,mBAAc,YAAd,mBAAuB,UAAS;AAAA,GAAC;QAG5E,SAAM,EAAA,QAAA,MACV,aAAa,SACT,aAAa,OAAO,kBAAiB;AAAA,IACnC,OAAK,EAAA,IAAE,KAAK,IAAA,EAAA,IAAG,KAAK;AAAA,IACpB,QAAM,EAAA,IAAE,MAAM,IAAA,EAAA,IAAG,KAAK;AAAA,IACtB,gBAAU,QAAQ;AAAA,OAEpB,0BAA0B;;;;;;;;;WAW1B;AAAA;;;2BAFa,MAAM;AAAA;;;;;;;;gBALtB,IAAI,EAAA,UAAA,UAAA;AAAA;;;;AAFT;"}
@@ -1,13 +1,17 @@
1
- import { Size } from '@embedpdf/models';
2
- interface Props {
3
- pageSize: Size;
1
+ import { Rotation } from '@embedpdf/models';
2
+ interface RotateProps {
3
+ documentId: string;
4
+ pageIndex: number;
5
+ rotation?: Rotation;
6
+ scale?: number;
4
7
  }
5
8
  declare var __VLS_1: {};
6
9
  type __VLS_Slots = {} & {
7
10
  default?: (props: typeof __VLS_1) => any;
8
11
  };
9
- declare const __VLS_component: import('vue').DefineComponent<Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
10
- declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
12
+ declare const __VLS_base: import('vue').DefineComponent<RotateProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<RotateProps> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
13
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
14
+ declare const _default: typeof __VLS_export;
11
15
  export default _default;
12
16
  type __VLS_WithSlots<T, S> = T & {
13
17
  new (): {
@@ -1,3 +1,4 @@
1
+ import { MaybeRefOrGetter } from 'vue';
1
2
  import { RotatePlugin } from '../../lib/index.ts';
2
3
  import { Rotation } from '@embedpdf/models';
3
4
  /**
@@ -10,9 +11,10 @@ export declare const useRotatePlugin: () => import('@embedpdf/core/vue').PluginS
10
11
  */
11
12
  export declare const useRotateCapability: () => import('@embedpdf/core/vue').CapabilityState<Readonly<import('../../lib/index.ts').RotateCapability>>;
12
13
  /**
13
- * Hook that provides reactive rotation state and methods.
14
+ * Hook that provides reactive rotation state and methods for a specific document.
15
+ * @param documentId Document ID (can be ref, computed, getter, or plain value)
14
16
  */
15
- export declare const useRotate: () => {
16
- rotation: import('vue').Ref<Rotation, Rotation>;
17
- provides: import('vue').Ref<Readonly<import('../../lib/index.ts').RotateCapability> | null, Readonly<import('../../lib/index.ts').RotateCapability> | null>;
17
+ export declare const useRotate: (documentId: MaybeRefOrGetter<string>) => {
18
+ rotation: Readonly<import('vue').Ref<Rotation, Rotation>>;
19
+ provides: import('vue').ComputedRef<import('../../lib/index.ts').RotateScope | null>;
18
20
  };