@foxycape/core 1.1.5 → 1.1.6
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/dist/kernal/ContentRange.d.ts +1 -0
- package/dist/mediaTypes/pdf/shared/geometry/index.cjs +1 -1
- package/dist/mediaTypes/pdf/shared/geometry/index.mjs +2 -2
- package/dist/mediaTypes/pdf/shared/geometry/selectionToFixedContentRange.cjs +1 -1
- package/dist/mediaTypes/pdf/shared/geometry/selectionToFixedContentRange.d.ts +14 -4
- package/dist/mediaTypes/pdf/shared/geometry/selectionToFixedContentRange.mjs +56 -24
- package/global.d.ts +3 -1
- package/package.json +1 -1
- package/types.d.ts +48 -13
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./textRects.cjs"),t=require("./selectionToFixedContentRange.cjs");exports.collectPageElements=e.collectPageElements,exports.getPageLayoutRef=t.getPageLayoutRef,exports.getPagedSelectionRects=e.getPagedSelectionRects,exports.getSelectionText=e.getSelectionText,exports.mergeClientRects=e.mergeClientRects,exports.mergeClientRectsToLines=e.mergeClientRectsToLines,exports.resolvePageNumberForRect=e.resolvePageNumberForRect,exports.scaleGeometryCoords=t.scaleGeometryCoords,exports.selectionToFixedContentRange=t.selectionToFixedContentRange;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./textRects.cjs"),t=require("./selectionToFixedContentRange.cjs");exports.collectPageElements=e.collectPageElements,exports.getPageLayoutRef=t.getPageLayoutRef,exports.getPagedSelectionRects=e.getPagedSelectionRects,exports.getSelectionText=e.getSelectionText,exports.mergeClientRects=e.mergeClientRects,exports.mergeClientRectsToLines=e.mergeClientRectsToLines,exports.normalizePageRotation=t.normalizePageRotation,exports.resolvePageNumberForRect=e.resolvePageNumberForRect,exports.rotateRectInPage=t.rotateRectInPage,exports.scaleGeometryCoords=t.scaleGeometryCoords,exports.selectionToFixedContentRange=t.selectionToFixedContentRange;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { collectPageElements as e, getPagedSelectionRects as t, getSelectionText as n, mergeClientRects as r, mergeClientRectsToLines as i, resolvePageNumberForRect as a } from "./textRects.mjs";
|
|
2
|
-
import { getPageLayoutRef as o,
|
|
3
|
-
export { e as collectPageElements, o as getPageLayoutRef, t as getPagedSelectionRects, n as getSelectionText, r as mergeClientRects, i as mergeClientRectsToLines, a as resolvePageNumberForRect,
|
|
2
|
+
import { getPageLayoutRef as o, normalizePageRotation as s, rotateRectInPage as c, scaleGeometryCoords as l, selectionToFixedContentRange as u } from "./selectionToFixedContentRange.mjs";
|
|
3
|
+
export { e as collectPageElements, o as getPageLayoutRef, t as getPagedSelectionRects, n as getSelectionText, r as mergeClientRects, i as mergeClientRectsToLines, s as normalizePageRotation, a as resolvePageNumberForRect, c as rotateRectInPage, l as scaleGeometryCoords, u as selectionToFixedContentRange };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./textRects.cjs");var t=e=>{let t=e.getBoundingClientRect(),n=e.clientWidth,r=e.clientHeight;if(!(n<=0||r<=0))return{width:n,height:r,contentLeft:t.left+e.clientLeft,contentTop:t.top+e.clientTop}},
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./textRects.cjs");var t=e=>{let t=(Math.round(e)%360+360)%360;return Math.round(t/90)*90%360},n=(e,n,r,i,a,o,s)=>{switch(t(s)){case 90:return{x:o-n-i,y:e,width:i,height:r};case 180:return{x:a-e-r,y:o-n-i,width:r,height:i};case 270:return{x:n,y:a-e-r,width:i,height:r};default:return{x:e,y:n,width:r,height:i}}},r=e=>{let t=e.getBoundingClientRect(),n=e.clientWidth,r=e.clientHeight;if(!(n<=0||r<=0))return{width:n,height:r,contentLeft:t.left+e.clientLeft,contentTop:t.top+e.clientTop}},i=(n,r)=>{let i=e.getPagedSelectionRects(n);if(i.length===0)return null;let a=[];for(let e of i){let n=r(e.pageNumber);if(!n)continue;let i=e.x-n.contentLeft,o=e.y-n.contentTop,s={pageNumber:e.pageNumber,width:n.width,height:n.height,shape:`rect`,coords:[i,o,e.width,e.height],rotation:t(n.rotation??0)};a.push(s)}return a.length===0?null:{kind:`fixed`,geometries:a}},a=(e,r,i,a=0)=>{let[o=0,s=0,c=0,l=0]=e.coords,u=t(a-(e.rotation??0)),d=n(o,s,c,l,e.width,e.height,u),f=u%180==0?e.width:e.height,p=u%180==0?e.height:e.width,m=f>0?r/f:1,h=p>0?i/p:1;return{x:d.x*m,y:d.y*h,width:d.width*m,height:d.height*h,rotationDelta:u}};exports.getPageLayoutRef=r,exports.normalizePageRotation=t,exports.rotateRectInPage=n,exports.scaleGeometryCoords=a,exports.selectionToFixedContentRange=i;
|
|
@@ -5,13 +5,23 @@ export type PageLayoutRef = {
|
|
|
5
5
|
height: number;
|
|
6
6
|
contentLeft: number;
|
|
7
7
|
contentTop: number;
|
|
8
|
+
rotation?: number;
|
|
8
9
|
};
|
|
9
|
-
export type
|
|
10
|
-
export declare const getPageLayoutRef: (pageEl: HTMLElement) => PageLayoutRef | undefined;
|
|
11
|
-
export declare const selectionToFixedContentRange: (range: Range, resolveLayout: PageLayoutResolver) => FixedContentRange | null;
|
|
12
|
-
export declare const scaleGeometryCoords: (geometry: ContentGeometry, currentWidth: number, currentHeight: number) => {
|
|
10
|
+
export type ScaledGeometryRect = {
|
|
13
11
|
x: number;
|
|
14
12
|
y: number;
|
|
15
13
|
width: number;
|
|
16
14
|
height: number;
|
|
15
|
+
rotationDelta: number;
|
|
17
16
|
};
|
|
17
|
+
export declare const normalizePageRotation: (degrees: number) => number;
|
|
18
|
+
export declare const rotateRectInPage: (x: number, y: number, w: number, h: number, pageWidth: number, pageHeight: number, delta: number) => {
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
width: number;
|
|
22
|
+
height: number;
|
|
23
|
+
};
|
|
24
|
+
export type PageLayoutResolver = (pageNumber: number) => PageLayoutRef | undefined;
|
|
25
|
+
export declare const getPageLayoutRef: (pageEl: HTMLElement) => PageLayoutRef | undefined;
|
|
26
|
+
export declare const selectionToFixedContentRange: (range: Range, resolveLayout: PageLayoutResolver) => FixedContentRange | null;
|
|
27
|
+
export declare const scaleGeometryCoords: (geometry: ContentGeometry, currentWidth: number, currentHeight: number, currentRotation?: number) => ScaledGeometryRect;
|
|
@@ -1,6 +1,36 @@
|
|
|
1
1
|
import { getPagedSelectionRects as e } from "./textRects.mjs";
|
|
2
2
|
//#region mediaTypes/pdf/shared/geometry/selectionToFixedContentRange.ts
|
|
3
3
|
var t = (e) => {
|
|
4
|
+
let t = (Math.round(e) % 360 + 360) % 360;
|
|
5
|
+
return Math.round(t / 90) * 90 % 360;
|
|
6
|
+
}, n = (e, n, r, i, a, o, s) => {
|
|
7
|
+
switch (t(s)) {
|
|
8
|
+
case 90: return {
|
|
9
|
+
x: o - n - i,
|
|
10
|
+
y: e,
|
|
11
|
+
width: i,
|
|
12
|
+
height: r
|
|
13
|
+
};
|
|
14
|
+
case 180: return {
|
|
15
|
+
x: a - e - r,
|
|
16
|
+
y: o - n - i,
|
|
17
|
+
width: r,
|
|
18
|
+
height: i
|
|
19
|
+
};
|
|
20
|
+
case 270: return {
|
|
21
|
+
x: n,
|
|
22
|
+
y: a - e - r,
|
|
23
|
+
width: i,
|
|
24
|
+
height: r
|
|
25
|
+
};
|
|
26
|
+
default: return {
|
|
27
|
+
x: e,
|
|
28
|
+
y: n,
|
|
29
|
+
width: r,
|
|
30
|
+
height: i
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}, r = (e) => {
|
|
4
34
|
let t = e.getBoundingClientRect(), n = e.clientWidth, r = e.clientHeight;
|
|
5
35
|
if (!(n <= 0 || r <= 0)) return {
|
|
6
36
|
width: n,
|
|
@@ -8,39 +38,41 @@ var t = (e) => {
|
|
|
8
38
|
contentLeft: t.left + e.clientLeft,
|
|
9
39
|
contentTop: t.top + e.clientTop
|
|
10
40
|
};
|
|
11
|
-
},
|
|
12
|
-
let
|
|
13
|
-
if (
|
|
14
|
-
let
|
|
15
|
-
for (let e of
|
|
16
|
-
let
|
|
17
|
-
if (!
|
|
18
|
-
let
|
|
19
|
-
i.push({
|
|
41
|
+
}, i = (n, r) => {
|
|
42
|
+
let i = e(n);
|
|
43
|
+
if (i.length === 0) return null;
|
|
44
|
+
let a = [];
|
|
45
|
+
for (let e of i) {
|
|
46
|
+
let n = r(e.pageNumber);
|
|
47
|
+
if (!n) continue;
|
|
48
|
+
let i = e.x - n.contentLeft, o = e.y - n.contentTop, s = {
|
|
20
49
|
pageNumber: e.pageNumber,
|
|
21
|
-
width:
|
|
22
|
-
height:
|
|
50
|
+
width: n.width,
|
|
51
|
+
height: n.height,
|
|
23
52
|
shape: "rect",
|
|
24
53
|
coords: [
|
|
25
|
-
|
|
26
|
-
|
|
54
|
+
i,
|
|
55
|
+
o,
|
|
27
56
|
e.width,
|
|
28
57
|
e.height
|
|
29
|
-
]
|
|
30
|
-
|
|
58
|
+
],
|
|
59
|
+
rotation: t(n.rotation ?? 0)
|
|
60
|
+
};
|
|
61
|
+
a.push(s);
|
|
31
62
|
}
|
|
32
|
-
return
|
|
63
|
+
return a.length === 0 ? null : {
|
|
33
64
|
kind: "fixed",
|
|
34
|
-
geometries:
|
|
65
|
+
geometries: a
|
|
35
66
|
};
|
|
36
|
-
},
|
|
37
|
-
let [
|
|
67
|
+
}, a = (e, r, i, a = 0) => {
|
|
68
|
+
let [o = 0, s = 0, c = 0, l = 0] = e.coords, u = t(a - (e.rotation ?? 0)), d = n(o, s, c, l, e.width, e.height, u), f = u % 180 == 0 ? e.width : e.height, p = u % 180 == 0 ? e.height : e.width, m = f > 0 ? r / f : 1, h = p > 0 ? i / p : 1;
|
|
38
69
|
return {
|
|
39
|
-
x:
|
|
40
|
-
y:
|
|
41
|
-
width:
|
|
42
|
-
height:
|
|
70
|
+
x: d.x * m,
|
|
71
|
+
y: d.y * h,
|
|
72
|
+
width: d.width * m,
|
|
73
|
+
height: d.height * h,
|
|
74
|
+
rotationDelta: u
|
|
43
75
|
};
|
|
44
76
|
};
|
|
45
77
|
//#endregion
|
|
46
|
-
export {
|
|
78
|
+
export { r as getPageLayoutRef, t as normalizePageRotation, n as rotateRectInPage, a as scaleGeometryCoords, i as selectionToFixedContentRange };
|
package/global.d.ts
CHANGED
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -1,13 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
declare module
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
declare module '*.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
declare module '*.
|
|
1
|
+
declare module '*.html' {
|
|
2
|
+
const src: string;
|
|
3
|
+
export default src;
|
|
4
|
+
}
|
|
5
|
+
declare module '*.scss' {
|
|
6
|
+
const src: string;
|
|
7
|
+
export default src;
|
|
8
|
+
}
|
|
9
|
+
declare module '*.css' {
|
|
10
|
+
const src: string;
|
|
11
|
+
export default src;
|
|
12
|
+
}
|
|
13
|
+
declare module '*.png' {
|
|
14
|
+
const src: string;
|
|
15
|
+
export default src;
|
|
16
|
+
}
|
|
17
|
+
declare module '*.js' {
|
|
18
|
+
const src: string;
|
|
19
|
+
export default src;
|
|
20
|
+
}
|
|
21
|
+
declare module '*.html?raw' {
|
|
22
|
+
const src: string;
|
|
23
|
+
export default src;
|
|
24
|
+
}
|
|
25
|
+
declare module '*.js?raw' {
|
|
26
|
+
const src: string;
|
|
27
|
+
export default src;
|
|
28
|
+
}
|
|
29
|
+
declare module '*.mjs?raw' {
|
|
30
|
+
const src: string;
|
|
31
|
+
export default src;
|
|
32
|
+
}
|
|
33
|
+
declare module '*.js?url' {
|
|
34
|
+
const src: string;
|
|
35
|
+
export default src;
|
|
36
|
+
}
|
|
37
|
+
declare module '*.mjs?url' {
|
|
38
|
+
const src: string;
|
|
39
|
+
export default src;
|
|
40
|
+
}
|
|
41
|
+
declare module '*/?url' {
|
|
42
|
+
const src: string;
|
|
43
|
+
export default src;
|
|
44
|
+
}
|
|
45
|
+
declare module '*.css?raw' {
|
|
46
|
+
const src: string;
|
|
47
|
+
export default src;
|
|
48
|
+
}
|