@embedpdf/utils 1.0.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 CloudPDF
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
File without changes
package/dist/index.cjs ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"}),exports.getCounterRotation=function(t,e){const{width:i,height:r}=t.size;switch(e%4){case 1:return{matrix:`matrix(0, -1, 1, 0, 0, ${r})`,width:r,height:i};case 2:return{matrix:`matrix(-1, 0, 0, -1, ${i}, ${r})`,width:i,height:r};case 3:return{matrix:`matrix(0, 1, -1, 0, ${i}, 0)`,width:r,height:i};default:return{matrix:"matrix(1, 0, 0, 1, 0, 0)",width:i,height:r}}};
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../src/lib/rotation.ts"],"sourcesContent":["import { Rect, Rotation } from '@embedpdf/models';\n\ninterface CounterTransformResult {\n matrix: string; // CSS matrix(a,b,c,d,e,f)\n width: number; // new width\n height: number; // new height\n}\n\n/**\n * Given an already-placed rect (left/top/width/height in px) and the page rotation,\n * return the counter-rotation matrix + adjusted width/height.\n *\n * transform-origin is expected to be \"0 0\".\n * left/top DO NOT change, apply them as-is.\n */\nexport function getCounterRotation(rect: Rect, rotation: Rotation): CounterTransformResult {\n const { width: w, height: h } = rect.size;\n\n switch (rotation % 4) {\n case 1: // 90° cw → need matrix(0,-1,1,0,0,h) and swap w/h\n return {\n matrix: `matrix(0, -1, 1, 0, 0, ${h})`,\n width: h,\n height: w,\n };\n\n case 2: // 180° → matrix(-1,0,0,-1,w,h), width/height unchanged\n return {\n matrix: `matrix(-1, 0, 0, -1, ${w}, ${h})`,\n width: w,\n height: h,\n };\n\n case 3: // 270° cw → matrix(0,1,-1,0,w,0), swap w/h\n return {\n matrix: `matrix(0, 1, -1, 0, ${w}, 0)`,\n width: h,\n height: w,\n };\n\n default:\n return {\n matrix: `matrix(1, 0, 0, 1, 0, 0)`,\n width: w,\n height: h,\n };\n }\n}\n"],"names":["rect","rotation","width","w","height","h","size","matrix"],"mappings":"2GAegB,SAAmBA,EAAYC,GAC7C,MAAQC,MAAOC,EAAGC,OAAQC,GAAML,EAAKM,KAErC,OAAQL,EAAW,GACjB,KAAK,EACI,MAAA,CACLM,OAAQ,0BAA0BF,KAClCH,MAAOG,EACPD,OAAQD,GAGZ,KAAK,EACI,MAAA,CACLI,OAAQ,wBAAwBJ,MAAME,KACtCH,MAAOC,EACPC,OAAQC,GAGZ,KAAK,EACI,MAAA,CACLE,OAAQ,uBAAuBJ,QAC/BD,MAAOG,EACPD,OAAQD,GAGZ,QACS,MAAA,CACLI,OAAQ,2BACRL,MAAOC,EACPC,OAAQC,GAGhB"}
@@ -0,0 +1 @@
1
+ export * from './lib';
package/dist/index.js ADDED
@@ -0,0 +1,33 @@
1
+ function getCounterRotation(rect, rotation) {
2
+ const { width: w, height: h } = rect.size;
3
+ switch (rotation % 4) {
4
+ case 1:
5
+ return {
6
+ matrix: `matrix(0, -1, 1, 0, 0, ${h})`,
7
+ width: h,
8
+ height: w
9
+ };
10
+ case 2:
11
+ return {
12
+ matrix: `matrix(-1, 0, 0, -1, ${w}, ${h})`,
13
+ width: w,
14
+ height: h
15
+ };
16
+ case 3:
17
+ return {
18
+ matrix: `matrix(0, 1, -1, 0, ${w}, 0)`,
19
+ width: h,
20
+ height: w
21
+ };
22
+ default:
23
+ return {
24
+ matrix: `matrix(1, 0, 0, 1, 0, 0)`,
25
+ width: w,
26
+ height: h
27
+ };
28
+ }
29
+ }
30
+ export {
31
+ getCounterRotation
32
+ };
33
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/lib/rotation.ts"],"sourcesContent":["import { Rect, Rotation } from '@embedpdf/models';\n\ninterface CounterTransformResult {\n matrix: string; // CSS matrix(a,b,c,d,e,f)\n width: number; // new width\n height: number; // new height\n}\n\n/**\n * Given an already-placed rect (left/top/width/height in px) and the page rotation,\n * return the counter-rotation matrix + adjusted width/height.\n *\n * transform-origin is expected to be \"0 0\".\n * left/top DO NOT change, apply them as-is.\n */\nexport function getCounterRotation(rect: Rect, rotation: Rotation): CounterTransformResult {\n const { width: w, height: h } = rect.size;\n\n switch (rotation % 4) {\n case 1: // 90° cw → need matrix(0,-1,1,0,0,h) and swap w/h\n return {\n matrix: `matrix(0, -1, 1, 0, 0, ${h})`,\n width: h,\n height: w,\n };\n\n case 2: // 180° → matrix(-1,0,0,-1,w,h), width/height unchanged\n return {\n matrix: `matrix(-1, 0, 0, -1, ${w}, ${h})`,\n width: w,\n height: h,\n };\n\n case 3: // 270° cw → matrix(0,1,-1,0,w,0), swap w/h\n return {\n matrix: `matrix(0, 1, -1, 0, ${w}, 0)`,\n width: h,\n height: w,\n };\n\n default:\n return {\n matrix: `matrix(1, 0, 0, 1, 0, 0)`,\n width: w,\n height: h,\n };\n }\n}\n"],"names":[],"mappings":"AAegB,SAAA,mBAAmB,MAAY,UAA4C;AACzF,QAAM,EAAE,OAAO,GAAG,QAAQ,EAAA,IAAM,KAAK;AAErC,UAAQ,WAAW,GAAG;AAAA,IACpB,KAAK;AACI,aAAA;AAAA,QACL,QAAQ,0BAA0B,CAAC;AAAA,QACnC,OAAO;AAAA,QACP,QAAQ;AAAA,MACV;AAAA,IAEF,KAAK;AACI,aAAA;AAAA,QACL,QAAQ,wBAAwB,CAAC,KAAK,CAAC;AAAA,QACvC,OAAO;AAAA,QACP,QAAQ;AAAA,MACV;AAAA,IAEF,KAAK;AACI,aAAA;AAAA,QACL,QAAQ,uBAAuB,CAAC;AAAA,QAChC,OAAO;AAAA,QACP,QAAQ;AAAA,MACV;AAAA,IAEF;AACS,aAAA;AAAA,QACL,QAAQ;AAAA,QACR,OAAO;AAAA,QACP,QAAQ;AAAA,MACV;AAAA,EAAA;AAEN;"}
@@ -0,0 +1 @@
1
+ export * from './rotation';
@@ -0,0 +1,15 @@
1
+ import { Rect, Rotation } from '@embedpdf/models';
2
+ interface CounterTransformResult {
3
+ matrix: string;
4
+ width: number;
5
+ height: number;
6
+ }
7
+ /**
8
+ * Given an already-placed rect (left/top/width/height in px) and the page rotation,
9
+ * return the counter-rotation matrix + adjusted width/height.
10
+ *
11
+ * transform-origin is expected to be "0 0".
12
+ * left/top DO NOT change, apply them as-is.
13
+ */
14
+ export declare function getCounterRotation(rect: Rect, rotation: Rotation): CounterTransformResult;
15
+ export {};
@@ -0,0 +1,11 @@
1
+ import { createContext, JSX, Fragment, FunctionComponent } from 'preact';
2
+ export { useEffect, useRef, useState, useCallback, useMemo, useContext } from 'preact/hooks';
3
+ export type { ComponentChildren as ReactNode, JSX } from 'preact';
4
+ export { createContext, Fragment };
5
+ export type CSSProperties = import('preact').JSX.CSSProperties;
6
+ export type HTMLAttributes<T = any> = import('preact').JSX.HTMLAttributes<T extends EventTarget ? T : never>;
7
+ export type MouseEvent<T = Element> = JSX.TargetedMouseEvent<T extends EventTarget ? T : never>;
8
+ export type PointerEvent<T = Element> = JSX.TargetedPointerEvent<T extends EventTarget ? T : never>;
9
+ export type ChangeEvent<T = Element> = JSX.TargetedInputEvent<T extends EventTarget ? T : never>;
10
+ export type TouchEvent<T = Element> = JSX.TargetedTouchEvent<T extends EventTarget ? T : never>;
11
+ export type ComponentType = FunctionComponent;
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("preact/jsx-runtime"),r=require("@embedpdf/utils"),e=require("preact");require("preact/hooks"),exports.CounterRotate=function({children:o,...i}){const{rect:n,rotation:a}=i,{matrix:s,width:p,height:u}=r.getCounterRotation(n,a),g={style:{position:"absolute",left:n.origin.x,top:n.origin.y,transform:s,transformOrigin:"0 0",width:p,height:u,pointerEvents:"none",zIndex:3},onPointerDown:t=>t.stopPropagation(),onTouchStart:t=>t.stopPropagation()};return t.jsx(e.Fragment,{children:o({menuWrapperProps:g,matrix:s,rect:{origin:{x:n.origin.x,y:n.origin.y},size:{width:p,height:u}}})})};
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../../src/shared/components/counter-rotate-container.tsx"],"sourcesContent":["import { Rect, Rotation } from '@embedpdf/models';\nimport { getCounterRotation } from '@embedpdf/utils';\nimport { ReactNode, CSSProperties, PointerEvent, Fragment, TouchEvent } from '@framework';\n\ninterface CounterRotateProps {\n rect: Rect;\n rotation: Rotation;\n}\n\nexport interface MenuWrapperProps {\n style: CSSProperties;\n onPointerDown: (e: PointerEvent<HTMLDivElement>) => void;\n onTouchStart: (e: TouchEvent<HTMLDivElement>) => void;\n}\n\ninterface CounterRotateComponentProps extends CounterRotateProps {\n children: (props: {\n matrix: string;\n rect: Rect;\n menuWrapperProps: MenuWrapperProps;\n }) => ReactNode;\n}\n\nexport function CounterRotate({ children, ...props }: CounterRotateComponentProps) {\n const { rect, rotation } = props;\n const { matrix, width, height } = getCounterRotation(rect, rotation);\n\n const menuWrapperStyle: CSSProperties = {\n position: 'absolute',\n left: rect.origin.x,\n top: rect.origin.y,\n transform: matrix,\n transformOrigin: '0 0',\n width: width,\n height: height,\n pointerEvents: 'none',\n zIndex: 3,\n };\n\n const menuWrapperProps = {\n style: menuWrapperStyle,\n onPointerDown: (e: PointerEvent<HTMLDivElement>) => e.stopPropagation(),\n onTouchStart: (e: TouchEvent<HTMLDivElement>) => e.stopPropagation(),\n };\n\n return (\n <Fragment>\n {children({\n menuWrapperProps,\n matrix,\n rect: {\n origin: { x: rect.origin.x, y: rect.origin.y },\n size: { width: width, height: height },\n },\n })}\n </Fragment>\n );\n}\n"],"names":["children","props","rect","rotation","matrix","width","height","getCounterRotation","menuWrapperProps","style","position","left","origin","x","top","y","transform","transformOrigin","pointerEvents","zIndex","onPointerDown","e","stopPropagation","onTouchStart","Fragment","size"],"mappings":"qNAuBO,UAAuBA,SAAEA,KAAaC,IACrC,MAAAC,KAAEA,EAAMC,SAAAA,GAAaF,GACrBG,OAAEA,QAAQC,EAAOC,OAAAA,GAAWC,EAAAA,mBAAmBL,EAAMC,GAcrDK,EAAmB,CACvBC,MAbsC,CACtCC,SAAU,WACVC,KAAMT,EAAKU,OAAOC,EAClBC,IAAKZ,EAAKU,OAAOG,EACjBC,UAAWZ,EACXa,gBAAiB,MACjBZ,QACAC,SACAY,cAAe,OACfC,OAAQ,GAKRC,cAAgBC,GAAoCA,EAAEC,kBACtDC,aAAeF,GAAkCA,EAAEC,mBAInD,aAACE,EAAAA,UACExB,SAASA,EAAA,CACRQ,mBACAJ,SACAF,KAAM,CACJU,OAAQ,CAAEC,EAAGX,EAAKU,OAAOC,EAAGE,EAAGb,EAAKU,OAAOG,GAC3CU,KAAM,CAAEpB,QAAcC,cAKhC"}
@@ -0,0 +1 @@
1
+ export * from '../shared-preact';
@@ -0,0 +1,36 @@
1
+ import { jsx } from "preact/jsx-runtime";
2
+ import { getCounterRotation } from "@embedpdf/utils";
3
+ import { Fragment } from "preact";
4
+ import "preact/hooks";
5
+ function CounterRotate({ children, ...props }) {
6
+ const { rect, rotation } = props;
7
+ const { matrix, width, height } = getCounterRotation(rect, rotation);
8
+ const menuWrapperStyle = {
9
+ position: "absolute",
10
+ left: rect.origin.x,
11
+ top: rect.origin.y,
12
+ transform: matrix,
13
+ transformOrigin: "0 0",
14
+ width,
15
+ height,
16
+ pointerEvents: "none",
17
+ zIndex: 3
18
+ };
19
+ const menuWrapperProps = {
20
+ style: menuWrapperStyle,
21
+ onPointerDown: (e) => e.stopPropagation(),
22
+ onTouchStart: (e) => e.stopPropagation()
23
+ };
24
+ return /* @__PURE__ */ jsx(Fragment, { children: children({
25
+ menuWrapperProps,
26
+ matrix,
27
+ rect: {
28
+ origin: { x: rect.origin.x, y: rect.origin.y },
29
+ size: { width, height }
30
+ }
31
+ }) });
32
+ }
33
+ export {
34
+ CounterRotate
35
+ };
36
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../src/shared/components/counter-rotate-container.tsx"],"sourcesContent":["import { Rect, Rotation } from '@embedpdf/models';\nimport { getCounterRotation } from '@embedpdf/utils';\nimport { ReactNode, CSSProperties, PointerEvent, Fragment, TouchEvent } from '@framework';\n\ninterface CounterRotateProps {\n rect: Rect;\n rotation: Rotation;\n}\n\nexport interface MenuWrapperProps {\n style: CSSProperties;\n onPointerDown: (e: PointerEvent<HTMLDivElement>) => void;\n onTouchStart: (e: TouchEvent<HTMLDivElement>) => void;\n}\n\ninterface CounterRotateComponentProps extends CounterRotateProps {\n children: (props: {\n matrix: string;\n rect: Rect;\n menuWrapperProps: MenuWrapperProps;\n }) => ReactNode;\n}\n\nexport function CounterRotate({ children, ...props }: CounterRotateComponentProps) {\n const { rect, rotation } = props;\n const { matrix, width, height } = getCounterRotation(rect, rotation);\n\n const menuWrapperStyle: CSSProperties = {\n position: 'absolute',\n left: rect.origin.x,\n top: rect.origin.y,\n transform: matrix,\n transformOrigin: '0 0',\n width: width,\n height: height,\n pointerEvents: 'none',\n zIndex: 3,\n };\n\n const menuWrapperProps = {\n style: menuWrapperStyle,\n onPointerDown: (e: PointerEvent<HTMLDivElement>) => e.stopPropagation(),\n onTouchStart: (e: TouchEvent<HTMLDivElement>) => e.stopPropagation(),\n };\n\n return (\n <Fragment>\n {children({\n menuWrapperProps,\n matrix,\n rect: {\n origin: { x: rect.origin.x, y: rect.origin.y },\n size: { width: width, height: height },\n },\n })}\n </Fragment>\n );\n}\n"],"names":[],"mappings":";;;;AAuBO,SAAS,cAAc,EAAE,UAAU,GAAG,SAAsC;AAC3E,QAAA,EAAE,MAAM,SAAA,IAAa;AAC3B,QAAM,EAAE,QAAQ,OAAO,OAAW,IAAA,mBAAmB,MAAM,QAAQ;AAEnE,QAAM,mBAAkC;AAAA,IACtC,UAAU;AAAA,IACV,MAAM,KAAK,OAAO;AAAA,IAClB,KAAK,KAAK,OAAO;AAAA,IACjB,WAAW;AAAA,IACX,iBAAiB;AAAA,IACjB;AAAA,IACA;AAAA,IACA,eAAe;AAAA,IACf,QAAQ;AAAA,EACV;AAEA,QAAM,mBAAmB;AAAA,IACvB,OAAO;AAAA,IACP,eAAe,CAAC,MAAoC,EAAE,gBAAgB;AAAA,IACtE,cAAc,CAAC,MAAkC,EAAE,gBAAgB;AAAA,EACrE;AAGE,SAAA,oBAAC,YACE,UAAS,SAAA;AAAA,IACR;AAAA,IACA;AAAA,IACA,MAAM;AAAA,MACJ,QAAQ,EAAE,GAAG,KAAK,OAAO,GAAG,GAAG,KAAK,OAAO,EAAE;AAAA,MAC7C,MAAM,EAAE,OAAc,OAAe;AAAA,IAAA;AAAA,EAExC,CAAA,GACH;AAEJ;"}
@@ -0,0 +1,2 @@
1
+ export { Fragment, useEffect, useRef, useState, useCallback, useMemo, JSX, createContext, useContext, } from 'react';
2
+ export type { ReactNode, HTMLAttributes, CSSProperties, MouseEvent, PointerEvent, TouchEvent, ComponentType, } from 'react';
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),r=require("@embedpdf/utils"),e=require("react");exports.CounterRotate=function({children:o,...i}){const{rect:n,rotation:a}=i,{matrix:s,width:g,height:u}=r.getCounterRotation(n,a),p={style:{position:"absolute",left:n.origin.x,top:n.origin.y,transform:s,transformOrigin:"0 0",width:g,height:u,pointerEvents:"none",zIndex:3},onPointerDown:t=>t.stopPropagation(),onTouchStart:t=>t.stopPropagation()};return t.jsx(e.Fragment,{children:o({menuWrapperProps:p,matrix:s,rect:{origin:{x:n.origin.x,y:n.origin.y},size:{width:g,height:u}}})})};
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../../src/shared/components/counter-rotate-container.tsx"],"sourcesContent":["import { Rect, Rotation } from '@embedpdf/models';\nimport { getCounterRotation } from '@embedpdf/utils';\nimport { ReactNode, CSSProperties, PointerEvent, Fragment, TouchEvent } from '@framework';\n\ninterface CounterRotateProps {\n rect: Rect;\n rotation: Rotation;\n}\n\nexport interface MenuWrapperProps {\n style: CSSProperties;\n onPointerDown: (e: PointerEvent<HTMLDivElement>) => void;\n onTouchStart: (e: TouchEvent<HTMLDivElement>) => void;\n}\n\ninterface CounterRotateComponentProps extends CounterRotateProps {\n children: (props: {\n matrix: string;\n rect: Rect;\n menuWrapperProps: MenuWrapperProps;\n }) => ReactNode;\n}\n\nexport function CounterRotate({ children, ...props }: CounterRotateComponentProps) {\n const { rect, rotation } = props;\n const { matrix, width, height } = getCounterRotation(rect, rotation);\n\n const menuWrapperStyle: CSSProperties = {\n position: 'absolute',\n left: rect.origin.x,\n top: rect.origin.y,\n transform: matrix,\n transformOrigin: '0 0',\n width: width,\n height: height,\n pointerEvents: 'none',\n zIndex: 3,\n };\n\n const menuWrapperProps = {\n style: menuWrapperStyle,\n onPointerDown: (e: PointerEvent<HTMLDivElement>) => e.stopPropagation(),\n onTouchStart: (e: TouchEvent<HTMLDivElement>) => e.stopPropagation(),\n };\n\n return (\n <Fragment>\n {children({\n menuWrapperProps,\n matrix,\n rect: {\n origin: { x: rect.origin.x, y: rect.origin.y },\n size: { width: width, height: height },\n },\n })}\n </Fragment>\n );\n}\n"],"names":["children","props","rect","rotation","matrix","width","height","getCounterRotation","menuWrapperProps","style","position","left","origin","x","top","y","transform","transformOrigin","pointerEvents","zIndex","onPointerDown","e","stopPropagation","onTouchStart","Fragment","size"],"mappings":"2LAuBO,UAAuBA,SAAEA,KAAaC,IACrC,MAAAC,KAAEA,EAAMC,SAAAA,GAAaF,GACrBG,OAAEA,QAAQC,EAAOC,OAAAA,GAAWC,EAAAA,mBAAmBL,EAAMC,GAcrDK,EAAmB,CACvBC,MAbsC,CACtCC,SAAU,WACVC,KAAMT,EAAKU,OAAOC,EAClBC,IAAKZ,EAAKU,OAAOG,EACjBC,UAAWZ,EACXa,gBAAiB,MACjBZ,QACAC,SACAY,cAAe,OACfC,OAAQ,GAKRC,cAAgBC,GAAoCA,EAAEC,kBACtDC,aAAeF,GAAkCA,EAAEC,mBAInD,aAACE,EAAAA,UACExB,SAASA,EAAA,CACRQ,mBACAJ,SACAF,KAAM,CACJU,OAAQ,CAAEC,EAAGX,EAAKU,OAAOC,EAAGE,EAAGb,EAAKU,OAAOG,GAC3CU,KAAM,CAAEpB,QAAcC,cAKhC"}
@@ -0,0 +1 @@
1
+ export * from '../shared-react';
@@ -0,0 +1,35 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { getCounterRotation } from "@embedpdf/utils";
3
+ import { Fragment } from "react";
4
+ function CounterRotate({ children, ...props }) {
5
+ const { rect, rotation } = props;
6
+ const { matrix, width, height } = getCounterRotation(rect, rotation);
7
+ const menuWrapperStyle = {
8
+ position: "absolute",
9
+ left: rect.origin.x,
10
+ top: rect.origin.y,
11
+ transform: matrix,
12
+ transformOrigin: "0 0",
13
+ width,
14
+ height,
15
+ pointerEvents: "none",
16
+ zIndex: 3
17
+ };
18
+ const menuWrapperProps = {
19
+ style: menuWrapperStyle,
20
+ onPointerDown: (e) => e.stopPropagation(),
21
+ onTouchStart: (e) => e.stopPropagation()
22
+ };
23
+ return /* @__PURE__ */ jsx(Fragment, { children: children({
24
+ menuWrapperProps,
25
+ matrix,
26
+ rect: {
27
+ origin: { x: rect.origin.x, y: rect.origin.y },
28
+ size: { width, height }
29
+ }
30
+ }) });
31
+ }
32
+ export {
33
+ CounterRotate
34
+ };
35
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../src/shared/components/counter-rotate-container.tsx"],"sourcesContent":["import { Rect, Rotation } from '@embedpdf/models';\nimport { getCounterRotation } from '@embedpdf/utils';\nimport { ReactNode, CSSProperties, PointerEvent, Fragment, TouchEvent } from '@framework';\n\ninterface CounterRotateProps {\n rect: Rect;\n rotation: Rotation;\n}\n\nexport interface MenuWrapperProps {\n style: CSSProperties;\n onPointerDown: (e: PointerEvent<HTMLDivElement>) => void;\n onTouchStart: (e: TouchEvent<HTMLDivElement>) => void;\n}\n\ninterface CounterRotateComponentProps extends CounterRotateProps {\n children: (props: {\n matrix: string;\n rect: Rect;\n menuWrapperProps: MenuWrapperProps;\n }) => ReactNode;\n}\n\nexport function CounterRotate({ children, ...props }: CounterRotateComponentProps) {\n const { rect, rotation } = props;\n const { matrix, width, height } = getCounterRotation(rect, rotation);\n\n const menuWrapperStyle: CSSProperties = {\n position: 'absolute',\n left: rect.origin.x,\n top: rect.origin.y,\n transform: matrix,\n transformOrigin: '0 0',\n width: width,\n height: height,\n pointerEvents: 'none',\n zIndex: 3,\n };\n\n const menuWrapperProps = {\n style: menuWrapperStyle,\n onPointerDown: (e: PointerEvent<HTMLDivElement>) => e.stopPropagation(),\n onTouchStart: (e: TouchEvent<HTMLDivElement>) => e.stopPropagation(),\n };\n\n return (\n <Fragment>\n {children({\n menuWrapperProps,\n matrix,\n rect: {\n origin: { x: rect.origin.x, y: rect.origin.y },\n size: { width: width, height: height },\n },\n })}\n </Fragment>\n );\n}\n"],"names":[],"mappings":";;;AAuBO,SAAS,cAAc,EAAE,UAAU,GAAG,SAAsC;AAC3E,QAAA,EAAE,MAAM,SAAA,IAAa;AAC3B,QAAM,EAAE,QAAQ,OAAO,OAAW,IAAA,mBAAmB,MAAM,QAAQ;AAEnE,QAAM,mBAAkC;AAAA,IACtC,UAAU;AAAA,IACV,MAAM,KAAK,OAAO;AAAA,IAClB,KAAK,KAAK,OAAO;AAAA,IACjB,WAAW;AAAA,IACX,iBAAiB;AAAA,IACjB;AAAA,IACA;AAAA,IACA,eAAe;AAAA,IACf,QAAQ;AAAA,EACV;AAEA,QAAM,mBAAmB;AAAA,IACvB,OAAO;AAAA,IACP,eAAe,CAAC,MAAoC,EAAE,gBAAgB;AAAA,IACtE,cAAc,CAAC,MAAkC,EAAE,gBAAgB;AAAA,EACrE;AAGE,SAAA,oBAAC,YACE,UAAS,SAAA;AAAA,IACR;AAAA,IACA;AAAA,IACA,MAAM;AAAA,MACJ,QAAQ,EAAE,GAAG,KAAK,OAAO,GAAG,GAAG,KAAK,OAAO,EAAE;AAAA,MAC7C,MAAM,EAAE,OAAc,OAAe;AAAA,IAAA;AAAA,EAExC,CAAA,GACH;AAEJ;"}
@@ -0,0 +1,20 @@
1
+ import { Rect, Rotation } from '@embedpdf/models';
2
+ import { ReactNode, CSSProperties, PointerEvent, TouchEvent } from '../../preact/adapter.ts';
3
+ interface CounterRotateProps {
4
+ rect: Rect;
5
+ rotation: Rotation;
6
+ }
7
+ export interface MenuWrapperProps {
8
+ style: CSSProperties;
9
+ onPointerDown: (e: PointerEvent<HTMLDivElement>) => void;
10
+ onTouchStart: (e: TouchEvent<HTMLDivElement>) => void;
11
+ }
12
+ interface CounterRotateComponentProps extends CounterRotateProps {
13
+ children: (props: {
14
+ matrix: string;
15
+ rect: Rect;
16
+ menuWrapperProps: MenuWrapperProps;
17
+ }) => ReactNode;
18
+ }
19
+ export declare function CounterRotate({ children, ...props }: CounterRotateComponentProps): import("preact").JSX.Element;
20
+ export {};
@@ -0,0 +1 @@
1
+ export * from './counter-rotate-container';
@@ -0,0 +1 @@
1
+ export * from './components';
@@ -0,0 +1,20 @@
1
+ import { Rect, Rotation } from '@embedpdf/models';
2
+ import { ReactNode, CSSProperties, PointerEvent, TouchEvent } from '../../react/adapter.ts';
3
+ interface CounterRotateProps {
4
+ rect: Rect;
5
+ rotation: Rotation;
6
+ }
7
+ export interface MenuWrapperProps {
8
+ style: CSSProperties;
9
+ onPointerDown: (e: PointerEvent<HTMLDivElement>) => void;
10
+ onTouchStart: (e: TouchEvent<HTMLDivElement>) => void;
11
+ }
12
+ interface CounterRotateComponentProps extends CounterRotateProps {
13
+ children: (props: {
14
+ matrix: string;
15
+ rect: Rect;
16
+ menuWrapperProps: MenuWrapperProps;
17
+ }) => ReactNode;
18
+ }
19
+ export declare function CounterRotate({ children, ...props }: CounterRotateComponentProps): import("react/jsx-runtime").JSX.Element;
20
+ export {};
@@ -0,0 +1 @@
1
+ export * from './counter-rotate-container';
@@ -0,0 +1 @@
1
+ export * from './components';
@@ -0,0 +1,21 @@
1
+ import { Rect, Rotation } from '@embedpdf/models';
2
+ interface CounterRotateProps {
3
+ rect: Rect;
4
+ rotation: Rotation;
5
+ }
6
+ declare var __VLS_1: {
7
+ menuWrapperProps: any;
8
+ matrix: any;
9
+ rect: any;
10
+ };
11
+ type __VLS_Slots = {} & {
12
+ default?: (props: typeof __VLS_1) => any;
13
+ };
14
+ declare const __VLS_component: import('vue').DefineComponent<CounterRotateProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<CounterRotateProps> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
15
+ declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
16
+ export default _default;
17
+ type __VLS_WithSlots<T, S> = T & {
18
+ new (): {
19
+ $slots: S;
20
+ };
21
+ };
@@ -0,0 +1,2 @@
1
+ export { default as CounterRotate } from './counter-rotate-container.vue';
2
+ export type { MenuWrapperProps } from './types';
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("vue"),e=require("@embedpdf/utils"),o=t.defineComponent({__name:"counter-rotate-container",props:{rect:{},rotation:{}},setup(o){const r=o,{matrix:n,width:i,height:p}=e.getCounterRotation(r.rect,r.rotation),a=t.computed((()=>({style:{position:"absolute",left:`${r.rect.origin.x}px`,top:`${r.rect.origin.y}px`,transform:n,transformOrigin:"0 0",width:`${i}px`,height:`${p}px`,pointerEvents:"none",zIndex:3},onPointerDown:t=>t.stopPropagation(),onTouchStart:t=>t.stopPropagation()}))),s=t.computed((()=>({origin:{x:r.rect.origin.x,y:r.rect.origin.y},size:{width:i,height:p}})));return(e,o)=>t.renderSlot(e.$slots,"default",{menuWrapperProps:a.value,matrix:t.unref(n),rect:s.value})}});exports.CounterRotate=o;
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../../src/vue/components/counter-rotate-container.vue"],"sourcesContent":["<template>\n <slot :menu-wrapper-props=\"menuWrapperProps\" :matrix=\"matrix\" :rect=\"adjustedRect\" />\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, type CSSProperties } from 'vue';\nimport type { Rect, Rotation } from '@embedpdf/models';\nimport { getCounterRotation } from '@embedpdf/utils';\n\ninterface CounterRotateProps {\n rect: Rect;\n rotation: Rotation;\n}\n\nconst props = defineProps<CounterRotateProps>();\n\nconst { matrix, width, height } = getCounterRotation(props.rect, props.rotation);\n\nconst menuWrapperProps = computed(() => ({\n style: {\n position: 'absolute',\n left: `${props.rect.origin.x}px`,\n top: `${props.rect.origin.y}px`,\n transform: matrix,\n transformOrigin: '0 0',\n width: `${width}px`,\n height: `${height}px`,\n pointerEvents: 'none',\n zIndex: 3,\n } as CSSProperties,\n onPointerDown: (e: PointerEvent) => e.stopPropagation(),\n onTouchStart: (e: TouchEvent) => e.stopPropagation(),\n}));\n\nconst adjustedRect = computed(() => ({\n origin: { x: props.rect.origin.x, y: props.rect.origin.y },\n size: { width, height },\n}));\n</script>\n"],"names":["props","__props","matrix","width","height","getCounterRotation","rect","rotation","menuWrapperProps","computed","style","position","left","origin","x","top","y","transform","transformOrigin","pointerEvents","zIndex","onPointerDown","e","stopPropagation","onTouchStart","adjustedRect","size","_renderSlot","_ctx","$slots","value","_unref"],"mappings":"gOAcA,MAAMA,EAAQC,GAERC,OAAEA,EAAQC,MAAAA,EAAAC,OAAOA,GAAWC,EAAmBA,mBAAAL,EAAMM,KAAMN,EAAMO,UAEjEC,EAAmBC,EAAAA,UAAS,KAAO,CACvCC,MAAO,CACLC,SAAU,WACVC,KAAM,GAAGZ,EAAMM,KAAKO,OAAOC,MAC3BC,IAAK,GAAGf,EAAMM,KAAKO,OAAOG,MAC1BC,UAAWf,EACXgB,gBAAiB,MACjBf,MAAO,GAAGA,MACVC,OAAQ,GAAGA,MACXe,cAAe,OACfC,OAAQ,GAEVC,cAAgBC,GAAoBA,EAAEC,kBACtCC,aAAeF,GAAkBA,EAAEC,sBAG/BE,EAAehB,EAAAA,UAAS,KAAO,CACnCI,OAAQ,CAAEC,EAAGd,EAAMM,KAAKO,OAAOC,EAAGE,EAAGhB,EAAMM,KAAKO,OAAOG,GACvDU,KAAM,CAAEvB,QAAOC,2BAnCfuB,aAAqFC,EAAAC,OAAA,UAAA,CAA9ErB,iBAAoBA,EAAgBsB,MAAG5B,OAAQ6B,QAAM7B,GAAGI,KAAMmB,EAAYK"}
@@ -0,0 +1 @@
1
+ export * from './components';
@@ -0,0 +1,43 @@
1
+ import { defineComponent, computed, renderSlot, unref } from "vue";
2
+ import { getCounterRotation } from "@embedpdf/utils";
3
+ const _sfc_main = /* @__PURE__ */ defineComponent({
4
+ __name: "counter-rotate-container",
5
+ props: {
6
+ rect: {},
7
+ rotation: {}
8
+ },
9
+ setup(__props) {
10
+ const props = __props;
11
+ const { matrix, width, height } = getCounterRotation(props.rect, props.rotation);
12
+ const menuWrapperProps = computed(() => ({
13
+ style: {
14
+ position: "absolute",
15
+ left: `${props.rect.origin.x}px`,
16
+ top: `${props.rect.origin.y}px`,
17
+ transform: matrix,
18
+ transformOrigin: "0 0",
19
+ width: `${width}px`,
20
+ height: `${height}px`,
21
+ pointerEvents: "none",
22
+ zIndex: 3
23
+ },
24
+ onPointerDown: (e) => e.stopPropagation(),
25
+ onTouchStart: (e) => e.stopPropagation()
26
+ }));
27
+ const adjustedRect = computed(() => ({
28
+ origin: { x: props.rect.origin.x, y: props.rect.origin.y },
29
+ size: { width, height }
30
+ }));
31
+ return (_ctx, _cache) => {
32
+ return renderSlot(_ctx.$slots, "default", {
33
+ menuWrapperProps: menuWrapperProps.value,
34
+ matrix: unref(matrix),
35
+ rect: adjustedRect.value
36
+ });
37
+ };
38
+ }
39
+ });
40
+ export {
41
+ _sfc_main as CounterRotate
42
+ };
43
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../src/vue/components/counter-rotate-container.vue"],"sourcesContent":["<template>\n <slot :menu-wrapper-props=\"menuWrapperProps\" :matrix=\"matrix\" :rect=\"adjustedRect\" />\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, type CSSProperties } from 'vue';\nimport type { Rect, Rotation } from '@embedpdf/models';\nimport { getCounterRotation } from '@embedpdf/utils';\n\ninterface CounterRotateProps {\n rect: Rect;\n rotation: Rotation;\n}\n\nconst props = defineProps<CounterRotateProps>();\n\nconst { matrix, width, height } = getCounterRotation(props.rect, props.rotation);\n\nconst menuWrapperProps = computed(() => ({\n style: {\n position: 'absolute',\n left: `${props.rect.origin.x}px`,\n top: `${props.rect.origin.y}px`,\n transform: matrix,\n transformOrigin: '0 0',\n width: `${width}px`,\n height: `${height}px`,\n pointerEvents: 'none',\n zIndex: 3,\n } as CSSProperties,\n onPointerDown: (e: PointerEvent) => e.stopPropagation(),\n onTouchStart: (e: TouchEvent) => e.stopPropagation(),\n}));\n\nconst adjustedRect = computed(() => ({\n origin: { x: props.rect.origin.x, y: props.rect.origin.y },\n size: { width, height },\n}));\n</script>\n"],"names":["_renderSlot","_unref"],"mappings":";;;;;;;;;AAcA,UAAM,QAAQ;AAER,UAAA,EAAE,QAAQ,OAAO,WAAW,mBAAmB,MAAM,MAAM,MAAM,QAAQ;AAEzE,UAAA,mBAAmB,SAAS,OAAO;AAAA,MACvC,OAAO;AAAA,QACL,UAAU;AAAA,QACV,MAAM,GAAG,MAAM,KAAK,OAAO,CAAC;AAAA,QAC5B,KAAK,GAAG,MAAM,KAAK,OAAO,CAAC;AAAA,QAC3B,WAAW;AAAA,QACX,iBAAiB;AAAA,QACjB,OAAO,GAAG,KAAK;AAAA,QACf,QAAQ,GAAG,MAAM;AAAA,QACjB,eAAe;AAAA,QACf,QAAQ;AAAA,MACV;AAAA,MACA,eAAe,CAAC,MAAoB,EAAE,gBAAgB;AAAA,MACtD,cAAc,CAAC,MAAkB,EAAE,gBAAgB;AAAA,IAAA,EACnD;AAEI,UAAA,eAAe,SAAS,OAAO;AAAA,MACnC,QAAQ,EAAE,GAAG,MAAM,KAAK,OAAO,GAAG,GAAG,MAAM,KAAK,OAAO,EAAE;AAAA,MACzD,MAAM,EAAE,OAAO,OAAO;AAAA,IAAA,EACtB;;AApCA,aAAAA,WAAqF,KAAA,QAAA,WAAA;AAAA,QAA9E,kBAAoB,iBAAgB;AAAA,QAAG,QAAQC,MAAM,MAAA;AAAA,QAAG,MAAM,aAAY;AAAA,MAAA;;;;"}
package/package.json ADDED
@@ -0,0 +1,72 @@
1
+ {
2
+ "name": "@embedpdf/utils",
3
+ "version": "1.0.20",
4
+ "private": false,
5
+ "description": "Shared utility helpers (geometry, tasks, logging, PDF primitives) that underpin every package in the EmbedPDF ecosystem.",
6
+ "type": "module",
7
+ "main": "./dist/index.cjs",
8
+ "module": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js",
14
+ "require": "./dist/index.cjs"
15
+ },
16
+ "./preact": {
17
+ "types": "./dist/preact/index.d.ts",
18
+ "import": "./dist/preact/index.js",
19
+ "require": "./dist/preact/index.cjs"
20
+ },
21
+ "./react": {
22
+ "types": "./dist/react/index.d.ts",
23
+ "import": "./dist/react/index.js",
24
+ "require": "./dist/react/index.cjs"
25
+ },
26
+ "./vue": {
27
+ "types": "./dist/vue/index.d.ts",
28
+ "import": "./dist/vue/index.js",
29
+ "require": "./dist/vue/index.cjs"
30
+ }
31
+ },
32
+ "files": [
33
+ "dist",
34
+ "README.md"
35
+ ],
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "https://github.com/embedpdf/embed-pdf-viewer",
39
+ "directory": "packages/utils"
40
+ },
41
+ "homepage": "https://www.embedpdf.com/docs",
42
+ "bugs": {
43
+ "url": "https://github.com/embedpdf/embed-pdf-viewer/issues"
44
+ },
45
+ "author": "Bob Singor",
46
+ "license": "MIT",
47
+ "devDependencies": {
48
+ "typescript": "^5.0.0",
49
+ "@types/react": "^18.2.0",
50
+ "@embedpdf/models": "1.0.21",
51
+ "@embedpdf/build": "1.0.0"
52
+ },
53
+ "peerDependencies": {
54
+ "react": ">=16.8.0",
55
+ "react-dom": ">=16.8.0",
56
+ "preact": "^10.26.4",
57
+ "vue": ">=3.2.0"
58
+ },
59
+ "publishConfig": {
60
+ "access": "public"
61
+ },
62
+ "scripts": {
63
+ "build:base": "vite build --mode base",
64
+ "build:react": "vite build --mode react",
65
+ "build:preact": "vite build --mode preact",
66
+ "build:vue": "vite build --mode vue",
67
+ "build": "pnpm run clean && concurrently -c auto -n base,react,preact,vue \"vite build --mode base\" \"vite build --mode react\" \"vite build --mode preact\" \"vite build --mode vue\"",
68
+ "clean": "rimraf dist",
69
+ "lint": "eslint src --color",
70
+ "lint:fix": "eslint src --color --fix"
71
+ }
72
+ }