@embedpdf/plugin-rotate 1.0.11 → 1.0.13
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/index.cjs +2 -142
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -40
- package/dist/index.js +8 -16
- package/dist/index.js.map +1 -1
- package/dist/lib/index.d.ts +7 -0
- package/dist/lib/manifest.d.ts +4 -0
- package/dist/lib/rotate-plugin.d.ts +13 -0
- package/dist/lib/types.d.ts +20 -0
- package/dist/lib/utils.d.ts +14 -0
- package/dist/preact/adapter.d.ts +4 -0
- package/dist/preact/core.d.ts +1 -0
- package/dist/preact/index.cjs +2 -62
- package/dist/preact/index.cjs.map +1 -1
- package/dist/preact/index.d.ts +1 -25
- package/dist/preact/index.js +6 -9
- package/dist/preact/index.js.map +1 -1
- package/dist/react/adapter.d.ts +2 -0
- package/dist/react/core.d.ts +1 -0
- package/dist/react/index.cjs +2 -62
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.ts +1 -24
- package/dist/react/index.js +6 -9
- package/dist/react/index.js.map +1 -1
- package/dist/shared-preact/components/index.d.ts +1 -0
- package/dist/shared-preact/components/rotate.d.ts +8 -0
- package/dist/shared-preact/hooks/index.d.ts +1 -0
- package/dist/shared-preact/hooks/use-rotate.d.ts +11 -0
- package/dist/shared-preact/index.d.ts +2 -0
- package/dist/shared-react/components/index.d.ts +1 -0
- package/dist/shared-react/components/rotate.d.ts +8 -0
- package/dist/shared-react/hooks/index.d.ts +1 -0
- package/dist/shared-react/hooks/use-rotate.d.ts +11 -0
- package/dist/shared-react/index.d.ts +2 -0
- package/dist/vue/components/index.d.ts +1 -0
- package/dist/vue/components/rotate.vue.d.ts +16 -0
- package/dist/vue/hooks/index.d.ts +1 -0
- package/dist/vue/hooks/use-rotate.d.ts +10 -0
- package/dist/vue/index.cjs +2 -0
- package/dist/vue/index.cjs.map +1 -0
- package/dist/vue/index.d.ts +2 -0
- package/dist/vue/index.js +42 -0
- package/dist/vue/index.js.map +1 -0
- package/package.json +20 -13
- package/dist/index.d.cts +0 -40
- package/dist/preact/index.d.cts +0 -25
- package/dist/react/index.d.cts +0 -24
package/dist/index.cjs
CHANGED
|
@@ -1,142 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/index.ts
|
|
21
|
-
var index_exports = {};
|
|
22
|
-
__export(index_exports, {
|
|
23
|
-
ROTATE_PLUGIN_ID: () => ROTATE_PLUGIN_ID,
|
|
24
|
-
RotatePlugin: () => RotatePlugin,
|
|
25
|
-
RotatePluginPackage: () => RotatePluginPackage,
|
|
26
|
-
manifest: () => manifest
|
|
27
|
-
});
|
|
28
|
-
module.exports = __toCommonJS(index_exports);
|
|
29
|
-
|
|
30
|
-
// src/lib/manifest.ts
|
|
31
|
-
var ROTATE_PLUGIN_ID = "rotate";
|
|
32
|
-
var manifest = {
|
|
33
|
-
id: ROTATE_PLUGIN_ID,
|
|
34
|
-
name: "Rotate Plugin",
|
|
35
|
-
version: "1.0.0",
|
|
36
|
-
provides: ["rotate"],
|
|
37
|
-
requires: ["loader"],
|
|
38
|
-
optional: ["spread"],
|
|
39
|
-
defaultConfig: {
|
|
40
|
-
enabled: true
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
// src/lib/rotate-plugin.ts
|
|
45
|
-
var import_core = require("@embedpdf/core");
|
|
46
|
-
|
|
47
|
-
// src/lib/utils.ts
|
|
48
|
-
function rotationMatrix(rotation, w, h, asString = true) {
|
|
49
|
-
let a = 1, b = 0, c = 0, d = 1, e = 0, f = 0;
|
|
50
|
-
switch (rotation) {
|
|
51
|
-
case 1:
|
|
52
|
-
a = 0;
|
|
53
|
-
b = 1;
|
|
54
|
-
c = -1;
|
|
55
|
-
d = 0;
|
|
56
|
-
e = h;
|
|
57
|
-
break;
|
|
58
|
-
case 2:
|
|
59
|
-
a = -1;
|
|
60
|
-
b = 0;
|
|
61
|
-
c = 0;
|
|
62
|
-
d = -1;
|
|
63
|
-
e = w;
|
|
64
|
-
f = h;
|
|
65
|
-
break;
|
|
66
|
-
case 3:
|
|
67
|
-
a = 0;
|
|
68
|
-
b = -1;
|
|
69
|
-
c = 1;
|
|
70
|
-
d = 0;
|
|
71
|
-
f = w;
|
|
72
|
-
break;
|
|
73
|
-
}
|
|
74
|
-
return asString ? `matrix(${a},${b},${c},${d},${e},${f})` : [a, b, c, d, e, f];
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// src/lib/rotate-plugin.ts
|
|
78
|
-
function getNextRotation(current) {
|
|
79
|
-
return (current + 1) % 4;
|
|
80
|
-
}
|
|
81
|
-
function getPreviousRotation(current) {
|
|
82
|
-
return (current + 3) % 4;
|
|
83
|
-
}
|
|
84
|
-
var RotatePlugin = class extends import_core.BasePlugin {
|
|
85
|
-
constructor(id, registry, cfg) {
|
|
86
|
-
super(id, registry);
|
|
87
|
-
this.rotate$ = (0, import_core.createBehaviorEmitter)();
|
|
88
|
-
this.resetReady();
|
|
89
|
-
const rotation = cfg.defaultRotation ?? this.coreState.core.rotation;
|
|
90
|
-
this.setRotation(rotation);
|
|
91
|
-
this.markReady();
|
|
92
|
-
}
|
|
93
|
-
async initialize(_config) {
|
|
94
|
-
}
|
|
95
|
-
setRotation(rotation) {
|
|
96
|
-
const pages = this.coreState.core.pages;
|
|
97
|
-
if (!pages) {
|
|
98
|
-
throw new Error("Pages not loaded");
|
|
99
|
-
}
|
|
100
|
-
this.dispatchCoreAction((0, import_core.setRotation)(rotation));
|
|
101
|
-
}
|
|
102
|
-
rotateForward() {
|
|
103
|
-
const rotation = getNextRotation(this.coreState.core.rotation);
|
|
104
|
-
this.setRotation(rotation);
|
|
105
|
-
}
|
|
106
|
-
rotateBackward() {
|
|
107
|
-
const rotation = getPreviousRotation(this.coreState.core.rotation);
|
|
108
|
-
this.setRotation(rotation);
|
|
109
|
-
}
|
|
110
|
-
buildCapability() {
|
|
111
|
-
return {
|
|
112
|
-
onRotateChange: this.rotate$.on,
|
|
113
|
-
setRotation: (rotation) => this.setRotation(rotation),
|
|
114
|
-
getRotation: () => this.coreState.core.rotation,
|
|
115
|
-
rotateForward: () => this.rotateForward(),
|
|
116
|
-
rotateBackward: () => this.rotateBackward(),
|
|
117
|
-
getMatrix: ({ w = 0, h = 0, asString = true } = {}) => rotationMatrix(this.coreState.core.rotation, w, h, asString)
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
async destroy() {
|
|
121
|
-
this.rotate$.clear();
|
|
122
|
-
super.destroy();
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
RotatePlugin.id = "rotate";
|
|
126
|
-
|
|
127
|
-
// src/lib/index.ts
|
|
128
|
-
var RotatePluginPackage = {
|
|
129
|
-
manifest,
|
|
130
|
-
create: (registry, _engine, config) => new RotatePlugin(ROTATE_PLUGIN_ID, registry, config),
|
|
131
|
-
reducer: () => {
|
|
132
|
-
},
|
|
133
|
-
initialState: {}
|
|
134
|
-
};
|
|
135
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
136
|
-
0 && (module.exports = {
|
|
137
|
-
ROTATE_PLUGIN_ID,
|
|
138
|
-
RotatePlugin,
|
|
139
|
-
RotatePluginPackage,
|
|
140
|
-
manifest
|
|
141
|
-
});
|
|
142
|
-
//# sourceMappingURL=index.cjs.map
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@embedpdf/core"),e="rotate",o={id:e,name:"Rotate Plugin",version:"1.0.0",provides:["rotate"],requires:["loader"],optional:["spread"],defaultConfig:{enabled:!0}};const a=class extends t.BasePlugin{constructor(e,o,a){super(e,o),this.rotate$=t.createBehaviorEmitter(),this.resetReady();const r=a.defaultRotation??this.coreState.core.rotation;this.setRotation(r),this.markReady()}async initialize(t){}setRotation(e){if(!this.coreState.core.pages)throw new Error("Pages not loaded");this.dispatchCoreAction(t.setRotation(e))}rotateForward(){const t=(this.coreState.core.rotation+1)%4;this.setRotation(t)}rotateBackward(){const t=(this.coreState.core.rotation+3)%4;this.setRotation(t)}buildCapability(){return{onRotateChange:this.rotate$.on,setRotation:t=>this.setRotation(t),getRotation:()=>this.coreState.core.rotation,rotateForward:()=>this.rotateForward(),rotateBackward:()=>this.rotateBackward(),getMatrix:({w:t=0,h:e=0,asString:o=!0}={})=>function(t,e,o,a=!0){let r=1,i=0,s=0,n=1,c=0,d=0;switch(t){case 1:r=0,i=1,s=-1,n=0,c=o;break;case 2:r=-1,i=0,s=0,n=-1,c=e,d=o;break;case 3:r=0,i=-1,s=1,n=0,d=e}return a?`matrix(${r},${i},${s},${n},${c},${d})`:[r,i,s,n,c,d]}(this.coreState.core.rotation,t,e,o)}}async destroy(){this.rotate$.clear(),super.destroy()}};a.id="rotate";let r=a;const i={manifest:o,create:(t,o,a)=>new r(e,t,a),reducer:()=>{},initialState:{}};exports.ROTATE_PLUGIN_ID=e,exports.RotatePlugin=r,exports.RotatePluginPackage=i,exports.manifest=o;
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/lib/manifest.ts","../src/lib/rotate-plugin.ts","../src/lib/utils.ts","../src/lib/index.ts"],"sourcesContent":["import { PluginManifest } from '@embedpdf/core';\nimport { RotatePluginConfig } from './types';\n\nexport const ROTATE_PLUGIN_ID = 'rotate';\n\nexport const manifest: PluginManifest<RotatePluginConfig> = {\n id: ROTATE_PLUGIN_ID,\n name: 'Rotate Plugin',\n version: '1.0.0',\n provides: ['rotate'],\n requires: ['loader'],\n optional: ['spread'],\n defaultConfig: {\n enabled: true,\n },\n};\n","import { BasePlugin, createBehaviorEmitter, PluginRegistry, setRotation } from '@embedpdf/core';\nimport { Rotation } from '@embedpdf/models';\nimport { RotateCapability, RotatePluginConfig } from './types';\nimport { rotationMatrix } from './utils';\n\nfunction getNextRotation(current: Rotation): Rotation {\n return ((current + 1) % 4) as Rotation;\n}\n\nfunction getPreviousRotation(current: Rotation): Rotation {\n return ((current + 3) % 4) as Rotation; // +3 is equivalent to -1 in modulo 4\n}\n\nexport class RotatePlugin extends BasePlugin<RotatePluginConfig, RotateCapability> {\n static readonly id = 'rotate' as const;\n private readonly rotate$ = createBehaviorEmitter<Rotation>();\n\n constructor(id: string, registry: PluginRegistry, cfg: RotatePluginConfig) {\n super(id, registry);\n this.resetReady();\n const rotation = cfg.defaultRotation ?? this.coreState.core.rotation;\n this.setRotation(rotation);\n this.markReady();\n }\n\n async initialize(_config: RotatePluginConfig): Promise<void> {}\n\n private setRotation(rotation: Rotation): void {\n const pages = this.coreState.core.pages;\n if (!pages) {\n throw new Error('Pages not loaded');\n }\n\n this.dispatchCoreAction(setRotation(rotation));\n }\n\n private rotateForward(): void {\n const rotation = getNextRotation(this.coreState.core.rotation);\n this.setRotation(rotation);\n }\n\n private rotateBackward(): void {\n const rotation = getPreviousRotation(this.coreState.core.rotation);\n this.setRotation(rotation);\n }\n\n protected buildCapability(): RotateCapability {\n return {\n onRotateChange: this.rotate$.on,\n setRotation: (rotation) => this.setRotation(rotation),\n getRotation: () => this.coreState.core.rotation,\n rotateForward: () => this.rotateForward(),\n rotateBackward: () => this.rotateBackward(),\n getMatrix: ({ w = 0, h = 0, asString = true } = {}) =>\n rotationMatrix(this.coreState.core.rotation, w, h, asString),\n };\n }\n\n async destroy(): Promise<void> {\n this.rotate$.clear();\n super.destroy();\n }\n}\n","import { Rotation } from '@embedpdf/models';\n\n/**\n * Returns the 6-tuple you can drop straight into\n * `matrix(a,b,c,d,e,f)` or a ready-made CSS string.\n * Rotation is clockwise, origin = top-left (0 0).\n *\n * ── Note on e,f ───────────────────────────────\n * For 0°/180° no translation is needed.\n * For 90°/270° you may want to pass the page\n * height / width so the page stays in positive\n * coordinates. Keep them 0 and handle layout\n * elsewhere if that’s what you do today.\n */\nexport function rotationMatrix(\n rotation: Rotation,\n w: number,\n h: number,\n asString = true,\n): [number, number, number, number, number, number] | string {\n let a = 1,\n b = 0,\n c = 0,\n d = 1,\n e = 0,\n f = 0;\n\n switch (rotation) {\n case 1: // 90°\n a = 0;\n b = 1;\n c = -1;\n d = 0;\n e = h;\n break;\n case 2: // 180°\n a = -1;\n b = 0;\n c = 0;\n d = -1;\n e = w;\n f = h;\n break;\n case 3: // 270°\n a = 0;\n b = -1;\n c = 1;\n d = 0;\n f = w;\n break;\n }\n return asString ? `matrix(${a},${b},${c},${d},${e},${f})` : [a, b, c, d, e, f];\n}\n","import { PluginPackage } from '@embedpdf/core';\nimport { manifest, ROTATE_PLUGIN_ID } from './manifest';\nimport { RotatePluginConfig } from './types';\nimport { RotatePlugin } from './rotate-plugin';\n\nexport const RotatePluginPackage: PluginPackage<RotatePlugin, RotatePluginConfig> = {\n manifest,\n create: (registry, _engine, config) => new RotatePlugin(ROTATE_PLUGIN_ID, registry, config),\n reducer: () => {},\n initialState: {},\n};\n\nexport * from './rotate-plugin';\nexport * from './types';\nexport * from './manifest';\n"],"names":["ROTATE_PLUGIN_ID","manifest","id","name","version","provides","requires","optional","defaultConfig","enabled","_RotatePlugin","BasePlugin","constructor","registry","cfg","super","this","rotate$","createBehaviorEmitter","resetReady","rotation","defaultRotation","coreState","core","setRotation","markReady","initialize","_config","pages","Error","dispatchCoreAction","rotateForward","rotateBackward","buildCapability","onRotateChange","on","getRotation","getMatrix","w","h","asString","a","b","c","d","e","f","rotationMatrix","destroy","clear","RotatePlugin","RotatePluginPackage","create","_engine","config","reducer","initialState"],"mappings":"kHAGaA,EAAmB,SAEnBC,EAA+C,CAC1DC,GAAIF,EACJG,KAAM,gBACNC,QAAS,QACTC,SAAU,CAAC,UACXC,SAAU,CAAC,UACXC,SAAU,CAAC,UACXC,cAAe,CACbC,SAAS,ICAN,MAAMC,EAAN,cAA2BC,EAAAA,WAIhC,WAAAC,CAAYV,EAAYW,EAA0BC,GAChDC,MAAMb,EAAIW,GAHKG,KAAAC,QAAUC,0BAIzBF,KAAKG,aACL,MAAMC,EAAWN,EAAIO,iBAAmBL,KAAKM,UAAUC,KAAKH,SAC5DJ,KAAKQ,YAAYJ,GACjBJ,KAAKS,WAAU,CAGjB,gBAAMC,CAAWC,GAA4C,CAErD,WAAAH,CAAYJ,GAElB,IADcJ,KAAKM,UAAUC,KAAKK,MAE1B,MAAA,IAAIC,MAAM,oBAGbb,KAAAc,mBAAmBN,cAAYJ,GAAS,CAGvC,aAAAW,GACN,MAAMX,GAA2BJ,KAAKM,UAAUC,KAAKH,SA/BpC,GAAK,EAgCtBJ,KAAKQ,YAAYJ,EAAQ,CAGnB,cAAAY,GACN,MAAMZ,GAA+BJ,KAAKM,UAAUC,KAAKH,SAhCxC,GAAK,EAiCtBJ,KAAKQ,YAAYJ,EAAQ,CAGjB,eAAAa,GACD,MAAA,CACLC,eAAgBlB,KAAKC,QAAQkB,GAC7BX,YAAcJ,GAAaJ,KAAKQ,YAAYJ,GAC5CgB,YAAa,IAAMpB,KAAKM,UAAUC,KAAKH,SACvCW,cAAe,IAAMf,KAAKe,gBAC1BC,eAAgB,IAAMhB,KAAKgB,iBAC3BK,UAAW,EAAGC,IAAI,EAAGC,IAAI,EAAGC,YAAW,GAAS,CAAA,ICvC/C,SACLpB,EACAkB,EACAC,EACAC,GAAW,GAEP,IAAAC,EAAI,EACNC,EAAI,EACJC,EAAI,EACJC,EAAI,EACJC,EAAI,EACJC,EAAI,EAEN,OAAQ1B,GACN,KAAK,EACCqB,EAAA,EACAC,EAAA,EACAC,GAAA,EACAC,EAAA,EACAC,EAAAN,EACJ,MACF,KAAK,EACCE,GAAA,EACAC,EAAA,EACAC,EAAA,EACAC,GAAA,EACAC,EAAAP,EACAQ,EAAAP,EACJ,MACF,KAAK,EACCE,EAAA,EACAC,GAAA,EACAC,EAAA,EACAC,EAAA,EACAE,EAAAR,EAGD,OAAAE,EAAW,UAAUC,KAAKC,KAAKC,KAAKC,KAAKC,KAAKC,KAAO,CAACL,EAAGC,EAAGC,EAAGC,EAAGC,EAAGC,EAC9E,CDEQC,CAAe/B,KAAKM,UAAUC,KAAKH,SAAUkB,EAAGC,EAAGC,GACvD,CAGF,aAAMQ,GACJhC,KAAKC,QAAQgC,QACblC,MAAMiC,SAAQ,GA9ChBtC,EAAgBR,GAAK,SADhB,IAAMgD,EAANxC,EERA,MAAMyC,EAAuE,CAClFlD,WACAmD,OAAQ,CAACvC,EAAUwC,EAASC,IAAW,IAAIJ,EAAalD,EAAkBa,EAAUyC,GACpFC,QAAS,OACTC,aAAc,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,40 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { Rotation } from '@embedpdf/models';
|
|
3
|
-
|
|
4
|
-
interface RotatePluginConfig extends BasePluginConfig {
|
|
5
|
-
defaultRotation?: Rotation;
|
|
6
|
-
}
|
|
7
|
-
interface RotateCapability {
|
|
8
|
-
onRotateChange(handler: (rotation: Rotation) => void): void;
|
|
9
|
-
setRotation(rotation: Rotation): void;
|
|
10
|
-
getRotation(): Rotation;
|
|
11
|
-
rotateForward(): void;
|
|
12
|
-
rotateBackward(): void;
|
|
13
|
-
getMatrix(opts?: {
|
|
14
|
-
w?: number;
|
|
15
|
-
h?: number;
|
|
16
|
-
asString?: boolean;
|
|
17
|
-
}): string | [number, number, number, number, number, number];
|
|
18
|
-
}
|
|
19
|
-
interface RotateState {
|
|
20
|
-
rotation: Rotation;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
declare class RotatePlugin extends BasePlugin<RotatePluginConfig, RotateCapability> {
|
|
24
|
-
static readonly id: "rotate";
|
|
25
|
-
private readonly rotate$;
|
|
26
|
-
constructor(id: string, registry: PluginRegistry, cfg: RotatePluginConfig);
|
|
27
|
-
initialize(_config: RotatePluginConfig): Promise<void>;
|
|
28
|
-
private setRotation;
|
|
29
|
-
private rotateForward;
|
|
30
|
-
private rotateBackward;
|
|
31
|
-
protected buildCapability(): RotateCapability;
|
|
32
|
-
destroy(): Promise<void>;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
declare const ROTATE_PLUGIN_ID = "rotate";
|
|
36
|
-
declare const manifest: PluginManifest<RotatePluginConfig>;
|
|
37
|
-
|
|
38
|
-
declare const RotatePluginPackage: PluginPackage<RotatePlugin, RotatePluginConfig>;
|
|
39
|
-
|
|
40
|
-
export { ROTATE_PLUGIN_ID, type RotateCapability, RotatePlugin, type RotatePluginConfig, RotatePluginPackage, type RotateState, manifest };
|
|
1
|
+
export * from './lib';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { BasePlugin, createBehaviorEmitter, setRotation } from "@embedpdf/core";
|
|
2
|
+
const ROTATE_PLUGIN_ID = "rotate";
|
|
3
|
+
const manifest = {
|
|
4
4
|
id: ROTATE_PLUGIN_ID,
|
|
5
5
|
name: "Rotate Plugin",
|
|
6
6
|
version: "1.0.0",
|
|
@@ -11,11 +11,6 @@ var manifest = {
|
|
|
11
11
|
enabled: true
|
|
12
12
|
}
|
|
13
13
|
};
|
|
14
|
-
|
|
15
|
-
// src/lib/rotate-plugin.ts
|
|
16
|
-
import { BasePlugin, createBehaviorEmitter, setRotation } from "@embedpdf/core";
|
|
17
|
-
|
|
18
|
-
// src/lib/utils.ts
|
|
19
14
|
function rotationMatrix(rotation, w, h, asString = true) {
|
|
20
15
|
let a = 1, b = 0, c = 0, d = 1, e = 0, f = 0;
|
|
21
16
|
switch (rotation) {
|
|
@@ -44,15 +39,13 @@ function rotationMatrix(rotation, w, h, asString = true) {
|
|
|
44
39
|
}
|
|
45
40
|
return asString ? `matrix(${a},${b},${c},${d},${e},${f})` : [a, b, c, d, e, f];
|
|
46
41
|
}
|
|
47
|
-
|
|
48
|
-
// src/lib/rotate-plugin.ts
|
|
49
42
|
function getNextRotation(current) {
|
|
50
43
|
return (current + 1) % 4;
|
|
51
44
|
}
|
|
52
45
|
function getPreviousRotation(current) {
|
|
53
46
|
return (current + 3) % 4;
|
|
54
47
|
}
|
|
55
|
-
|
|
48
|
+
const _RotatePlugin = class _RotatePlugin extends BasePlugin {
|
|
56
49
|
constructor(id, registry, cfg) {
|
|
57
50
|
super(id, registry);
|
|
58
51
|
this.rotate$ = createBehaviorEmitter();
|
|
@@ -93,10 +86,9 @@ var RotatePlugin = class extends BasePlugin {
|
|
|
93
86
|
super.destroy();
|
|
94
87
|
}
|
|
95
88
|
};
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
var RotatePluginPackage = {
|
|
89
|
+
_RotatePlugin.id = "rotate";
|
|
90
|
+
let RotatePlugin = _RotatePlugin;
|
|
91
|
+
const RotatePluginPackage = {
|
|
100
92
|
manifest,
|
|
101
93
|
create: (registry, _engine, config) => new RotatePlugin(ROTATE_PLUGIN_ID, registry, config),
|
|
102
94
|
reducer: () => {
|
|
@@ -109,4 +101,4 @@ export {
|
|
|
109
101
|
RotatePluginPackage,
|
|
110
102
|
manifest
|
|
111
103
|
};
|
|
112
|
-
//# sourceMappingURL=index.js.map
|
|
104
|
+
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/manifest.ts","../src/lib/
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/lib/manifest.ts","../src/lib/utils.ts","../src/lib/rotate-plugin.ts","../src/lib/index.ts"],"sourcesContent":["import { PluginManifest } from '@embedpdf/core';\nimport { RotatePluginConfig } from './types';\n\nexport const ROTATE_PLUGIN_ID = 'rotate';\n\nexport const manifest: PluginManifest<RotatePluginConfig> = {\n id: ROTATE_PLUGIN_ID,\n name: 'Rotate Plugin',\n version: '1.0.0',\n provides: ['rotate'],\n requires: ['loader'],\n optional: ['spread'],\n defaultConfig: {\n enabled: true,\n },\n};\n","import { Rotation } from '@embedpdf/models';\n\n/**\n * Returns the 6-tuple you can drop straight into\n * `matrix(a,b,c,d,e,f)` or a ready-made CSS string.\n * Rotation is clockwise, origin = top-left (0 0).\n *\n * ── Note on e,f ───────────────────────────────\n * For 0°/180° no translation is needed.\n * For 90°/270° you may want to pass the page\n * height / width so the page stays in positive\n * coordinates. Keep them 0 and handle layout\n * elsewhere if that’s what you do today.\n */\nexport function rotationMatrix(\n rotation: Rotation,\n w: number,\n h: number,\n asString = true,\n): [number, number, number, number, number, number] | string {\n let a = 1,\n b = 0,\n c = 0,\n d = 1,\n e = 0,\n f = 0;\n\n switch (rotation) {\n case 1: // 90°\n a = 0;\n b = 1;\n c = -1;\n d = 0;\n e = h;\n break;\n case 2: // 180°\n a = -1;\n b = 0;\n c = 0;\n d = -1;\n e = w;\n f = h;\n break;\n case 3: // 270°\n a = 0;\n b = -1;\n c = 1;\n d = 0;\n f = w;\n break;\n }\n return asString ? `matrix(${a},${b},${c},${d},${e},${f})` : [a, b, c, d, e, f];\n}\n","import { BasePlugin, createBehaviorEmitter, PluginRegistry, setRotation } from '@embedpdf/core';\nimport { Rotation } from '@embedpdf/models';\nimport { RotateCapability, RotatePluginConfig } from './types';\nimport { rotationMatrix } from './utils';\n\nfunction getNextRotation(current: Rotation): Rotation {\n return ((current + 1) % 4) as Rotation;\n}\n\nfunction getPreviousRotation(current: Rotation): Rotation {\n return ((current + 3) % 4) as Rotation; // +3 is equivalent to -1 in modulo 4\n}\n\nexport class RotatePlugin extends BasePlugin<RotatePluginConfig, RotateCapability> {\n static readonly id = 'rotate' as const;\n private readonly rotate$ = createBehaviorEmitter<Rotation>();\n\n constructor(id: string, registry: PluginRegistry, cfg: RotatePluginConfig) {\n super(id, registry);\n this.resetReady();\n const rotation = cfg.defaultRotation ?? this.coreState.core.rotation;\n this.setRotation(rotation);\n this.markReady();\n }\n\n async initialize(_config: RotatePluginConfig): Promise<void> {}\n\n private setRotation(rotation: Rotation): void {\n const pages = this.coreState.core.pages;\n if (!pages) {\n throw new Error('Pages not loaded');\n }\n\n this.dispatchCoreAction(setRotation(rotation));\n }\n\n private rotateForward(): void {\n const rotation = getNextRotation(this.coreState.core.rotation);\n this.setRotation(rotation);\n }\n\n private rotateBackward(): void {\n const rotation = getPreviousRotation(this.coreState.core.rotation);\n this.setRotation(rotation);\n }\n\n protected buildCapability(): RotateCapability {\n return {\n onRotateChange: this.rotate$.on,\n setRotation: (rotation) => this.setRotation(rotation),\n getRotation: () => this.coreState.core.rotation,\n rotateForward: () => this.rotateForward(),\n rotateBackward: () => this.rotateBackward(),\n getMatrix: ({ w = 0, h = 0, asString = true } = {}) =>\n rotationMatrix(this.coreState.core.rotation, w, h, asString),\n };\n }\n\n async destroy(): Promise<void> {\n this.rotate$.clear();\n super.destroy();\n }\n}\n","import { PluginPackage } from '@embedpdf/core';\nimport { manifest, ROTATE_PLUGIN_ID } from './manifest';\nimport { RotatePluginConfig } from './types';\nimport { RotatePlugin } from './rotate-plugin';\n\nexport const RotatePluginPackage: PluginPackage<RotatePlugin, RotatePluginConfig> = {\n manifest,\n create: (registry, _engine, config) => new RotatePlugin(ROTATE_PLUGIN_ID, registry, config),\n reducer: () => {},\n initialState: {},\n};\n\nexport * from './rotate-plugin';\nexport * from './types';\nexport * from './manifest';\n"],"names":[],"mappings":";AAGO,MAAM,mBAAmB;AAEzB,MAAM,WAA+C;AAAA,EAC1D,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,SAAS;AAAA,EACT,UAAU,CAAC,QAAQ;AAAA,EACnB,UAAU,CAAC,QAAQ;AAAA,EACnB,UAAU,CAAC,QAAQ;AAAA,EACnB,eAAe;AAAA,IACb,SAAS;AAAA,EAAA;AAEb;ACDO,SAAS,eACd,UACA,GACA,GACA,WAAW,MACgD;AACvD,MAAA,IAAI,GACN,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI;AAEN,UAAQ,UAAU;AAAA,IAChB,KAAK;AACC,UAAA;AACA,UAAA;AACA,UAAA;AACA,UAAA;AACA,UAAA;AACJ;AAAA,IACF,KAAK;AACC,UAAA;AACA,UAAA;AACA,UAAA;AACA,UAAA;AACA,UAAA;AACA,UAAA;AACJ;AAAA,IACF,KAAK;AACC,UAAA;AACA,UAAA;AACA,UAAA;AACA,UAAA;AACA,UAAA;AACJ;AAAA,EAAA;AAEG,SAAA,WAAW,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AAC/E;AC/CA,SAAS,gBAAgB,SAA6B;AACpD,UAAS,UAAU,KAAK;AAC1B;AAEA,SAAS,oBAAoB,SAA6B;AACxD,UAAS,UAAU,KAAK;AAC1B;AAEO,MAAM,gBAAN,MAAM,sBAAqB,WAAiD;AAAA,EAIjF,YAAY,IAAY,UAA0B,KAAyB;AACzE,UAAM,IAAI,QAAQ;AAHpB,SAAiB,UAAU,sBAAgC;AAIzD,SAAK,WAAW;AAChB,UAAM,WAAW,IAAI,mBAAmB,KAAK,UAAU,KAAK;AAC5D,SAAK,YAAY,QAAQ;AACzB,SAAK,UAAU;AAAA,EAAA;AAAA,EAGjB,MAAM,WAAW,SAA4C;AAAA,EAAA;AAAA,EAErD,YAAY,UAA0B;AACtC,UAAA,QAAQ,KAAK,UAAU,KAAK;AAClC,QAAI,CAAC,OAAO;AACJ,YAAA,IAAI,MAAM,kBAAkB;AAAA,IAAA;AAG/B,SAAA,mBAAmB,YAAY,QAAQ,CAAC;AAAA,EAAA;AAAA,EAGvC,gBAAsB;AAC5B,UAAM,WAAW,gBAAgB,KAAK,UAAU,KAAK,QAAQ;AAC7D,SAAK,YAAY,QAAQ;AAAA,EAAA;AAAA,EAGnB,iBAAuB;AAC7B,UAAM,WAAW,oBAAoB,KAAK,UAAU,KAAK,QAAQ;AACjE,SAAK,YAAY,QAAQ;AAAA,EAAA;AAAA,EAGjB,kBAAoC;AACrC,WAAA;AAAA,MACL,gBAAgB,KAAK,QAAQ;AAAA,MAC7B,aAAa,CAAC,aAAa,KAAK,YAAY,QAAQ;AAAA,MACpD,aAAa,MAAM,KAAK,UAAU,KAAK;AAAA,MACvC,eAAe,MAAM,KAAK,cAAc;AAAA,MACxC,gBAAgB,MAAM,KAAK,eAAe;AAAA,MAC1C,WAAW,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,WAAW,KAAA,IAAS,CAAA,MAC9C,eAAe,KAAK,UAAU,KAAK,UAAU,GAAG,GAAG,QAAQ;AAAA,IAC/D;AAAA,EAAA;AAAA,EAGF,MAAM,UAAyB;AAC7B,SAAK,QAAQ,MAAM;AACnB,UAAM,QAAQ;AAAA,EAAA;AAElB;AAhDE,cAAgB,KAAK;AADhB,IAAM,eAAN;ACRA,MAAM,sBAAuE;AAAA,EAClF;AAAA,EACA,QAAQ,CAAC,UAAU,SAAS,WAAW,IAAI,aAAa,kBAAkB,UAAU,MAAM;AAAA,EAC1F,SAAS,MAAM;AAAA,EAAC;AAAA,EAChB,cAAc,CAAA;AAChB;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PluginPackage } from '@embedpdf/core';
|
|
2
|
+
import { RotatePluginConfig } from './types';
|
|
3
|
+
import { RotatePlugin } from './rotate-plugin';
|
|
4
|
+
export declare const RotatePluginPackage: PluginPackage<RotatePlugin, RotatePluginConfig>;
|
|
5
|
+
export * from './rotate-plugin';
|
|
6
|
+
export * from './types';
|
|
7
|
+
export * from './manifest';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BasePlugin, PluginRegistry } from '@embedpdf/core';
|
|
2
|
+
import { RotateCapability, RotatePluginConfig } from './types';
|
|
3
|
+
export declare class RotatePlugin extends BasePlugin<RotatePluginConfig, RotateCapability> {
|
|
4
|
+
static readonly id: "rotate";
|
|
5
|
+
private readonly rotate$;
|
|
6
|
+
constructor(id: string, registry: PluginRegistry, cfg: RotatePluginConfig);
|
|
7
|
+
initialize(_config: RotatePluginConfig): Promise<void>;
|
|
8
|
+
private setRotation;
|
|
9
|
+
private rotateForward;
|
|
10
|
+
private rotateBackward;
|
|
11
|
+
protected buildCapability(): RotateCapability;
|
|
12
|
+
destroy(): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BasePluginConfig } from '@embedpdf/core';
|
|
2
|
+
import { Rotation } from '@embedpdf/models';
|
|
3
|
+
export interface RotatePluginConfig extends BasePluginConfig {
|
|
4
|
+
defaultRotation?: Rotation;
|
|
5
|
+
}
|
|
6
|
+
export interface RotateCapability {
|
|
7
|
+
onRotateChange(handler: (rotation: Rotation) => void): void;
|
|
8
|
+
setRotation(rotation: Rotation): void;
|
|
9
|
+
getRotation(): Rotation;
|
|
10
|
+
rotateForward(): void;
|
|
11
|
+
rotateBackward(): void;
|
|
12
|
+
getMatrix(opts?: {
|
|
13
|
+
w?: number;
|
|
14
|
+
h?: number;
|
|
15
|
+
asString?: boolean;
|
|
16
|
+
}): string | [number, number, number, number, number, number];
|
|
17
|
+
}
|
|
18
|
+
export interface RotateState {
|
|
19
|
+
rotation: Rotation;
|
|
20
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Rotation } from '@embedpdf/models';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the 6-tuple you can drop straight into
|
|
4
|
+
* `matrix(a,b,c,d,e,f)` or a ready-made CSS string.
|
|
5
|
+
* Rotation is clockwise, origin = top-left (0 0).
|
|
6
|
+
*
|
|
7
|
+
* ── Note on e,f ───────────────────────────────
|
|
8
|
+
* For 0°/180° no translation is needed.
|
|
9
|
+
* For 90°/270° you may want to pass the page
|
|
10
|
+
* height / width so the page stays in positive
|
|
11
|
+
* coordinates. Keep them 0 and handle layout
|
|
12
|
+
* elsewhere if that’s what you do today.
|
|
13
|
+
*/
|
|
14
|
+
export declare function rotationMatrix(rotation: Rotation, w: number, h: number, asString?: boolean): [number, number, number, number, number, number] | string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@embedpdf/core/preact';
|
package/dist/preact/index.cjs
CHANGED
|
@@ -1,62 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/preact/index.ts
|
|
21
|
-
var preact_exports = {};
|
|
22
|
-
__export(preact_exports, {
|
|
23
|
-
Rotate: () => Rotate,
|
|
24
|
-
useRotateCapability: () => useRotateCapability,
|
|
25
|
-
useRotatePlugin: () => useRotatePlugin
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(preact_exports);
|
|
28
|
-
|
|
29
|
-
// src/preact/hooks/use-rotate.ts
|
|
30
|
-
var import_preact = require("@embedpdf/core/preact");
|
|
31
|
-
var import_plugin_rotate = require("@embedpdf/plugin-rotate");
|
|
32
|
-
var useRotatePlugin = () => (0, import_preact.usePlugin)(import_plugin_rotate.RotatePlugin.id);
|
|
33
|
-
var useRotateCapability = () => (0, import_preact.useCapability)(import_plugin_rotate.RotatePlugin.id);
|
|
34
|
-
|
|
35
|
-
// src/preact/components/rotate.tsx
|
|
36
|
-
var import_jsx_runtime = require("preact/jsx-runtime");
|
|
37
|
-
function Rotate({ children, pageSize, ...props }) {
|
|
38
|
-
const { provides: rotate } = useRotateCapability();
|
|
39
|
-
const matrix = rotate?.getMatrix({
|
|
40
|
-
w: pageSize.width,
|
|
41
|
-
h: pageSize.height
|
|
42
|
-
}) || "matrix(1, 0, 0, 1, 0, 0)";
|
|
43
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
44
|
-
"div",
|
|
45
|
-
{
|
|
46
|
-
...props,
|
|
47
|
-
style: {
|
|
48
|
-
position: "absolute",
|
|
49
|
-
transformOrigin: "0 0",
|
|
50
|
-
transform: matrix
|
|
51
|
-
},
|
|
52
|
-
children
|
|
53
|
-
}
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
57
|
-
0 && (module.exports = {
|
|
58
|
-
Rotate,
|
|
59
|
-
useRotateCapability,
|
|
60
|
-
useRotatePlugin
|
|
61
|
-
});
|
|
62
|
-
//# sourceMappingURL=index.cjs.map
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core/preact"),t=require("@embedpdf/plugin-rotate"),i=require("preact/jsx-runtime"),r=()=>e.useCapability(t.RotatePlugin.id);exports.Rotate=function({children:e,pageSize:t,...o}){const{provides:a}=r(),n=(null==a?void 0:a.getMatrix({w:t.width,h:t.height}))||"matrix(1, 0, 0, 1, 0, 0)";return i.jsx("div",{...o,style:{position:"absolute",transformOrigin:"0 0",transform:n},children:e})},exports.useRotateCapability=r,exports.useRotatePlugin=()=>e.usePlugin(t.RotatePlugin.id);
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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 { RotatePlugin } from '@embedpdf/plugin-rotate';\n\nexport const useRotatePlugin = () => usePlugin<RotatePlugin>(RotatePlugin.id);\nexport const useRotateCapability = () => useCapability<RotatePlugin>(RotatePlugin.id);\n","import { ReactNode, HTMLAttributes } from '@framework';\nimport { Size } from '@embedpdf/models';\n\nimport { useRotateCapability } from '../hooks';\n\ntype RotateProps = HTMLAttributes<HTMLDivElement> & {\n children: ReactNode;\n pageSize: Size;\n};\n\nexport function Rotate({ children, pageSize, ...props }: RotateProps) {\n const { provides: rotate } = useRotateCapability();\n const matrix =\n (rotate?.getMatrix({\n w: pageSize.width,\n h: pageSize.height,\n }) as string) || '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 }}\n >\n {children}\n </div>\n );\n}\n"],"names":["useRotateCapability","useCapability","RotatePlugin","id","children","pageSize","props","provides","rotate","matrix","getMatrix","w","width","h","height","jsxRuntime","jsx","style","position","transformOrigin","transform","usePlugin"],"mappings":"8LAIaA,EAAsB,IAAMC,gBAA4BC,EAAAA,aAAaC,mBCM3E,UAAgBC,SAAEA,EAAAC,SAAUA,KAAaC,IAC9C,MAAQC,SAAUC,GAAWR,IACvBS,SACHD,WAAQE,UAAU,CACjBC,EAAGN,EAASO,MACZC,EAAGR,EAASS,WACG,2BAGjB,OAAAC,EAAAC,IAAC,MAAA,IACKV,EACJW,MAAO,CACLC,SAAU,WACVC,gBAAiB,MACjBC,UAAWX,GAGZL,YAGP,wDD3B+B,IAAMiB,YAAwBnB,EAAAA,aAAaC"}
|
package/dist/preact/index.d.ts
CHANGED
|
@@ -1,25 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { RotatePlugin } from '@embedpdf/plugin-rotate';
|
|
3
|
-
import { JSX, ComponentChildren } from 'preact';
|
|
4
|
-
import { Size } from '@embedpdf/models';
|
|
5
|
-
|
|
6
|
-
declare const useRotatePlugin: () => {
|
|
7
|
-
plugin: RotatePlugin | null;
|
|
8
|
-
isLoading: boolean;
|
|
9
|
-
ready: Promise<void>;
|
|
10
|
-
};
|
|
11
|
-
declare const useRotateCapability: () => {
|
|
12
|
-
provides: Readonly<_embedpdf_plugin_rotate.RotateCapability> | null;
|
|
13
|
-
isLoading: boolean;
|
|
14
|
-
ready: Promise<void>;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
/** @jsxImportSource preact */
|
|
18
|
-
|
|
19
|
-
type RotateProps = JSX.HTMLAttributes<HTMLDivElement> & {
|
|
20
|
-
children: ComponentChildren;
|
|
21
|
-
pageSize: Size;
|
|
22
|
-
};
|
|
23
|
-
declare function Rotate({ children, pageSize, ...props }: RotateProps): JSX.Element;
|
|
24
|
-
|
|
25
|
-
export { Rotate, useRotateCapability, useRotatePlugin };
|
|
1
|
+
export * from '../shared-preact';
|
package/dist/preact/index.js
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
import { useCapability, usePlugin } from "@embedpdf/core/preact";
|
|
1
|
+
import { usePlugin, useCapability } from "@embedpdf/core/preact";
|
|
3
2
|
import { RotatePlugin } from "@embedpdf/plugin-rotate";
|
|
4
|
-
var useRotatePlugin = () => usePlugin(RotatePlugin.id);
|
|
5
|
-
var useRotateCapability = () => useCapability(RotatePlugin.id);
|
|
6
|
-
|
|
7
|
-
// src/preact/components/rotate.tsx
|
|
8
3
|
import { jsx } from "preact/jsx-runtime";
|
|
4
|
+
const useRotatePlugin = () => usePlugin(RotatePlugin.id);
|
|
5
|
+
const useRotateCapability = () => useCapability(RotatePlugin.id);
|
|
9
6
|
function Rotate({ children, pageSize, ...props }) {
|
|
10
7
|
const { provides: rotate } = useRotateCapability();
|
|
11
|
-
const matrix = rotate
|
|
8
|
+
const matrix = (rotate == null ? void 0 : rotate.getMatrix({
|
|
12
9
|
w: pageSize.width,
|
|
13
10
|
h: pageSize.height
|
|
14
|
-
}) || "matrix(1, 0, 0, 1, 0, 0)";
|
|
11
|
+
})) || "matrix(1, 0, 0, 1, 0, 0)";
|
|
15
12
|
return /* @__PURE__ */ jsx(
|
|
16
13
|
"div",
|
|
17
14
|
{
|
|
@@ -30,4 +27,4 @@ export {
|
|
|
30
27
|
useRotateCapability,
|
|
31
28
|
useRotatePlugin
|
|
32
29
|
};
|
|
33
|
-
//# sourceMappingURL=index.js.map
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
package/dist/preact/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/
|
|
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 { RotatePlugin } from '@embedpdf/plugin-rotate';\n\nexport const useRotatePlugin = () => usePlugin<RotatePlugin>(RotatePlugin.id);\nexport const useRotateCapability = () => useCapability<RotatePlugin>(RotatePlugin.id);\n","import { ReactNode, HTMLAttributes } from '@framework';\nimport { Size } from '@embedpdf/models';\n\nimport { useRotateCapability } from '../hooks';\n\ntype RotateProps = HTMLAttributes<HTMLDivElement> & {\n children: ReactNode;\n pageSize: Size;\n};\n\nexport function Rotate({ children, pageSize, ...props }: RotateProps) {\n const { provides: rotate } = useRotateCapability();\n const matrix =\n (rotate?.getMatrix({\n w: pageSize.width,\n h: pageSize.height,\n }) as string) || '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 }}\n >\n {children}\n </div>\n );\n}\n"],"names":[],"mappings":";;;AAGO,MAAM,kBAAkB,MAAM,UAAwB,aAAa,EAAE;AACrE,MAAM,sBAAsB,MAAM,cAA4B,aAAa,EAAE;ACM7E,SAAS,OAAO,EAAE,UAAU,UAAU,GAAG,SAAsB;AACpE,QAAM,EAAE,UAAU,OAAO,IAAI,oBAAoB;AAC3C,QAAA,UACH,iCAAQ,UAAU;AAAA,IACjB,GAAG,SAAS;AAAA,IACZ,GAAG,SAAS;AAAA,EACb,OAAgB;AAGjB,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACE,GAAG;AAAA,MACJ,OAAO;AAAA,QACL,UAAU;AAAA,QACV,iBAAiB;AAAA,QACjB,WAAW;AAAA,MACb;AAAA,MAEC;AAAA,IAAA;AAAA,EACH;AAEJ;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@embedpdf/core/react';
|
package/dist/react/index.cjs
CHANGED
|
@@ -1,62 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/react/index.ts
|
|
21
|
-
var react_exports = {};
|
|
22
|
-
__export(react_exports, {
|
|
23
|
-
Rotate: () => Rotate,
|
|
24
|
-
useRotateCapability: () => useRotateCapability,
|
|
25
|
-
useRotatePlugin: () => useRotatePlugin
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(react_exports);
|
|
28
|
-
|
|
29
|
-
// src/react/hooks/use-rotate.ts
|
|
30
|
-
var import_react = require("@embedpdf/core/react");
|
|
31
|
-
var import_plugin_rotate = require("@embedpdf/plugin-rotate");
|
|
32
|
-
var useRotatePlugin = () => (0, import_react.usePlugin)(import_plugin_rotate.RotatePlugin.id);
|
|
33
|
-
var useRotateCapability = () => (0, import_react.useCapability)(import_plugin_rotate.RotatePlugin.id);
|
|
34
|
-
|
|
35
|
-
// src/react/components/rotate.tsx
|
|
36
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
37
|
-
function Rotate({ children, pageSize, ...props }) {
|
|
38
|
-
const { provides: rotate } = useRotateCapability();
|
|
39
|
-
const matrix = rotate?.getMatrix({
|
|
40
|
-
w: pageSize.width,
|
|
41
|
-
h: pageSize.height
|
|
42
|
-
}) || "matrix(1, 0, 0, 1, 0, 0)";
|
|
43
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
44
|
-
"div",
|
|
45
|
-
{
|
|
46
|
-
...props,
|
|
47
|
-
style: {
|
|
48
|
-
position: "absolute",
|
|
49
|
-
transformOrigin: "0 0",
|
|
50
|
-
transform: matrix
|
|
51
|
-
},
|
|
52
|
-
children
|
|
53
|
-
}
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
57
|
-
0 && (module.exports = {
|
|
58
|
-
Rotate,
|
|
59
|
-
useRotateCapability,
|
|
60
|
-
useRotatePlugin
|
|
61
|
-
});
|
|
62
|
-
//# sourceMappingURL=index.cjs.map
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core/react"),t=require("@embedpdf/plugin-rotate"),i=require("react/jsx-runtime"),r=()=>e.useCapability(t.RotatePlugin.id);exports.Rotate=function({children:e,pageSize:t,...o}){const{provides:a}=r(),n=(null==a?void 0:a.getMatrix({w:t.width,h:t.height}))||"matrix(1, 0, 0, 1, 0, 0)";return i.jsx("div",{...o,style:{position:"absolute",transformOrigin:"0 0",transform:n},children:e})},exports.useRotateCapability=r,exports.useRotatePlugin=()=>e.usePlugin(t.RotatePlugin.id);
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
package/dist/react/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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 { RotatePlugin } from '@embedpdf/plugin-rotate';\n\nexport const useRotatePlugin = () => usePlugin<RotatePlugin>(RotatePlugin.id);\nexport const useRotateCapability = () => useCapability<RotatePlugin>(RotatePlugin.id);\n","import { ReactNode, HTMLAttributes } from '@framework';\nimport { Size } from '@embedpdf/models';\n\nimport { useRotateCapability } from '../hooks';\n\ntype RotateProps = HTMLAttributes<HTMLDivElement> & {\n children: ReactNode;\n pageSize: Size;\n};\n\nexport function Rotate({ children, pageSize, ...props }: RotateProps) {\n const { provides: rotate } = useRotateCapability();\n const matrix =\n (rotate?.getMatrix({\n w: pageSize.width,\n h: pageSize.height,\n }) as string) || '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 }}\n >\n {children}\n </div>\n );\n}\n"],"names":["useRotateCapability","useCapability","RotatePlugin","id","children","pageSize","props","provides","rotate","matrix","getMatrix","w","width","h","height","jsxRuntime","jsx","style","position","transformOrigin","transform","usePlugin"],"mappings":"4LAIaA,EAAsB,IAAMC,gBAA4BC,EAAAA,aAAaC,mBCM3E,UAAgBC,SAAEA,EAAAC,SAAUA,KAAaC,IAC9C,MAAQC,SAAUC,GAAWR,IACvBS,SACHD,WAAQE,UAAU,CACjBC,EAAGN,EAASO,MACZC,EAAGR,EAASS,WACG,2BAGjB,OAAAC,EAAAC,IAAC,MAAA,IACKV,EACJW,MAAO,CACLC,SAAU,WACVC,gBAAiB,MACjBC,UAAWX,GAGZL,YAGP,wDD3B+B,IAAMiB,YAAwBnB,EAAAA,aAAaC"}
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,24 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { RotatePlugin } from '@embedpdf/plugin-rotate';
|
|
3
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
-
import { ReactNode } from 'react';
|
|
5
|
-
import { Size } from '@embedpdf/models';
|
|
6
|
-
|
|
7
|
-
declare const useRotatePlugin: () => {
|
|
8
|
-
plugin: RotatePlugin | null;
|
|
9
|
-
isLoading: boolean;
|
|
10
|
-
ready: Promise<void>;
|
|
11
|
-
};
|
|
12
|
-
declare const useRotateCapability: () => {
|
|
13
|
-
provides: Readonly<_embedpdf_plugin_rotate.RotateCapability> | null;
|
|
14
|
-
isLoading: boolean;
|
|
15
|
-
ready: Promise<void>;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
type RotateProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
19
|
-
children: ReactNode;
|
|
20
|
-
pageSize: Size;
|
|
21
|
-
};
|
|
22
|
-
declare function Rotate({ children, pageSize, ...props }: RotateProps): react_jsx_runtime.JSX.Element;
|
|
23
|
-
|
|
24
|
-
export { Rotate, useRotateCapability, useRotatePlugin };
|
|
1
|
+
export * from '../shared-react';
|
package/dist/react/index.js
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
import { useCapability, usePlugin } from "@embedpdf/core/react";
|
|
1
|
+
import { usePlugin, useCapability } from "@embedpdf/core/react";
|
|
3
2
|
import { RotatePlugin } from "@embedpdf/plugin-rotate";
|
|
4
|
-
var useRotatePlugin = () => usePlugin(RotatePlugin.id);
|
|
5
|
-
var useRotateCapability = () => useCapability(RotatePlugin.id);
|
|
6
|
-
|
|
7
|
-
// src/react/components/rotate.tsx
|
|
8
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
const useRotatePlugin = () => usePlugin(RotatePlugin.id);
|
|
5
|
+
const useRotateCapability = () => useCapability(RotatePlugin.id);
|
|
9
6
|
function Rotate({ children, pageSize, ...props }) {
|
|
10
7
|
const { provides: rotate } = useRotateCapability();
|
|
11
|
-
const matrix = rotate
|
|
8
|
+
const matrix = (rotate == null ? void 0 : rotate.getMatrix({
|
|
12
9
|
w: pageSize.width,
|
|
13
10
|
h: pageSize.height
|
|
14
|
-
}) || "matrix(1, 0, 0, 1, 0, 0)";
|
|
11
|
+
})) || "matrix(1, 0, 0, 1, 0, 0)";
|
|
15
12
|
return /* @__PURE__ */ jsx(
|
|
16
13
|
"div",
|
|
17
14
|
{
|
|
@@ -30,4 +27,4 @@ export {
|
|
|
30
27
|
useRotateCapability,
|
|
31
28
|
useRotatePlugin
|
|
32
29
|
};
|
|
33
|
-
//# sourceMappingURL=index.js.map
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
package/dist/react/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/
|
|
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 { RotatePlugin } from '@embedpdf/plugin-rotate';\n\nexport const useRotatePlugin = () => usePlugin<RotatePlugin>(RotatePlugin.id);\nexport const useRotateCapability = () => useCapability<RotatePlugin>(RotatePlugin.id);\n","import { ReactNode, HTMLAttributes } from '@framework';\nimport { Size } from '@embedpdf/models';\n\nimport { useRotateCapability } from '../hooks';\n\ntype RotateProps = HTMLAttributes<HTMLDivElement> & {\n children: ReactNode;\n pageSize: Size;\n};\n\nexport function Rotate({ children, pageSize, ...props }: RotateProps) {\n const { provides: rotate } = useRotateCapability();\n const matrix =\n (rotate?.getMatrix({\n w: pageSize.width,\n h: pageSize.height,\n }) as string) || '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 }}\n >\n {children}\n </div>\n );\n}\n"],"names":[],"mappings":";;;AAGO,MAAM,kBAAkB,MAAM,UAAwB,aAAa,EAAE;AACrE,MAAM,sBAAsB,MAAM,cAA4B,aAAa,EAAE;ACM7E,SAAS,OAAO,EAAE,UAAU,UAAU,GAAG,SAAsB;AACpE,QAAM,EAAE,UAAU,OAAO,IAAI,oBAAoB;AAC3C,QAAA,UACH,iCAAQ,UAAU;AAAA,IACjB,GAAG,SAAS;AAAA,IACZ,GAAG,SAAS;AAAA,EACb,OAAgB;AAGjB,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACE,GAAG;AAAA,MACJ,OAAO;AAAA,QACL,UAAU;AAAA,QACV,iBAAiB;AAAA,QACjB,WAAW;AAAA,MACb;AAAA,MAEC;AAAA,IAAA;AAAA,EACH;AAEJ;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './rotate';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ReactNode, HTMLAttributes } from '../../preact/adapter.ts';
|
|
2
|
+
import { Size } from '@embedpdf/models';
|
|
3
|
+
type RotateProps = HTMLAttributes<HTMLDivElement> & {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
pageSize: Size;
|
|
6
|
+
};
|
|
7
|
+
export declare function Rotate({ children, pageSize, ...props }: RotateProps): import("preact").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './use-rotate';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { RotatePlugin } from '../../lib/index.ts';
|
|
2
|
+
export declare const useRotatePlugin: () => {
|
|
3
|
+
plugin: RotatePlugin | null;
|
|
4
|
+
isLoading: boolean;
|
|
5
|
+
ready: Promise<void>;
|
|
6
|
+
};
|
|
7
|
+
export declare const useRotateCapability: () => {
|
|
8
|
+
provides: Readonly<import('../../lib/index.ts').RotateCapability> | null;
|
|
9
|
+
isLoading: boolean;
|
|
10
|
+
ready: Promise<void>;
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './rotate';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ReactNode, HTMLAttributes } from '../../react/adapter.ts';
|
|
2
|
+
import { Size } from '@embedpdf/models';
|
|
3
|
+
type RotateProps = HTMLAttributes<HTMLDivElement> & {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
pageSize: Size;
|
|
6
|
+
};
|
|
7
|
+
export declare function Rotate({ children, pageSize, ...props }: RotateProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './use-rotate';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { RotatePlugin } from '../../lib/index.ts';
|
|
2
|
+
export declare const useRotatePlugin: () => {
|
|
3
|
+
plugin: RotatePlugin | null;
|
|
4
|
+
isLoading: boolean;
|
|
5
|
+
ready: Promise<void>;
|
|
6
|
+
};
|
|
7
|
+
export declare const useRotateCapability: () => {
|
|
8
|
+
provides: Readonly<import('../../lib/index.ts').RotateCapability> | null;
|
|
9
|
+
isLoading: boolean;
|
|
10
|
+
ready: Promise<void>;
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Rotate } from './rotate.vue';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Size } from '@embedpdf/models';
|
|
2
|
+
interface Props {
|
|
3
|
+
pageSize: Size;
|
|
4
|
+
}
|
|
5
|
+
declare var __VLS_1: {};
|
|
6
|
+
type __VLS_Slots = {} & {
|
|
7
|
+
default?: (props: typeof __VLS_1) => any;
|
|
8
|
+
};
|
|
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>;
|
|
11
|
+
export default _default;
|
|
12
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
13
|
+
new (): {
|
|
14
|
+
$slots: S;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './use-rotate';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RotatePlugin } from '../../lib/index.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Hook to get the raw rotate plugin instance.
|
|
4
|
+
*/
|
|
5
|
+
export declare const useRotatePlugin: () => import('@embedpdf/core/vue').PluginState<RotatePlugin>;
|
|
6
|
+
/**
|
|
7
|
+
* Hook to get the rotate plugin's capability API.
|
|
8
|
+
* This provides methods for rotating the document.
|
|
9
|
+
*/
|
|
10
|
+
export declare const useRotateCapability: () => import('@embedpdf/core/vue').CapabilityState<Readonly<import('../../lib/index.ts').RotateCapability>>;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core/vue"),t=require("@embedpdf/plugin-rotate"),o=require("vue"),i=()=>e.useCapability(t.RotatePlugin.id),r=o.defineComponent({__name:"rotate",props:{pageSize:{}},setup(e){const t=e,{provides:r}=i(),a=o.computed((()=>r.value?r.value.getMatrix({w:t.pageSize.width,h:t.pageSize.height,asString:!0}):"matrix(1, 0, 0, 1, 0, 0)"));return(e,t)=>(o.openBlock(),o.createElementBlock("div",{style:o.normalizeStyle({position:"absolute",transformOrigin:"0 0",transform:a.value})},[o.renderSlot(e.$slots,"default")],4))}});exports.Rotate=r,exports.useRotateCapability=i,exports.useRotatePlugin=()=>e.usePlugin(t.RotatePlugin.id);
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/vue/hooks/use-rotate.ts","../../src/vue/components/rotate.vue"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/vue';\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","<script setup lang=\"ts\">\nimport { computed } from 'vue';\nimport type { Size } from '@embedpdf/models';\nimport { useRotateCapability } from '../hooks';\n\ninterface Props {\n pageSize: Size;\n}\n\nconst props = defineProps<Props>();\n\nconst { provides: rotate } = useRotateCapability();\n\nconst transformMatrix = computed(() => {\n // If the capability is not yet available, return an identity matrix.\n if (!rotate.value) {\n return 'matrix(1, 0, 0, 1, 0, 0)';\n }\n\n // Get the CSS transform matrix string from the capability.\n return rotate.value.getMatrix({\n w: props.pageSize.width,\n h: props.pageSize.height,\n asString: true,\n }) as string;\n});\n</script>\n\n<template>\n <div\n :style=\"{\n position: 'absolute',\n transformOrigin: '0 0',\n transform: transformMatrix,\n }\"\n >\n <slot />\n </div>\n</template>\n"],"names":["useRotateCapability","useCapability","RotatePlugin","id","props","__props","provides","rotate","transformMatrix","computed","value","getMatrix","w","pageSize","width","h","height","asString","_createElementBlock","createElementBlock","style","_normalizeStyle","_renderSlot","_ctx","$slots","usePlugin"],"mappings":"4KAYaA,EAAsB,IAAMC,gBAA4BC,EAAAA,aAAaC,sECHlF,MAAMC,EAAQC,GAENC,SAAUC,GAAWP,IAEvBQ,EAAkBC,EAAAA,UAAS,IAE1BF,EAAOG,MAKLH,EAAOG,MAAMC,UAAU,CAC5BC,EAAGR,EAAMS,SAASC,MAClBC,EAAGX,EAAMS,SAASG,OAClBC,UAAU,IAPH,yDAaTC,EAAAC,mBAQM,MAAA,CAPHC,MAAKC,EAAAA,eAAA,qDAA+Eb,EAAeE,UAMpGY,aAAQC,EAAAC,OAAA,0FD9BmB,IAAMC,YAAwBvB,EAAAA,aAAaC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { usePlugin, useCapability } from "@embedpdf/core/vue";
|
|
2
|
+
import { RotatePlugin } from "@embedpdf/plugin-rotate";
|
|
3
|
+
import { defineComponent, computed, createElementBlock, openBlock, normalizeStyle, renderSlot } from "vue";
|
|
4
|
+
const useRotatePlugin = () => usePlugin(RotatePlugin.id);
|
|
5
|
+
const useRotateCapability = () => useCapability(RotatePlugin.id);
|
|
6
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
7
|
+
__name: "rotate",
|
|
8
|
+
props: {
|
|
9
|
+
pageSize: {}
|
|
10
|
+
},
|
|
11
|
+
setup(__props) {
|
|
12
|
+
const props = __props;
|
|
13
|
+
const { provides: rotate } = useRotateCapability();
|
|
14
|
+
const transformMatrix = computed(() => {
|
|
15
|
+
if (!rotate.value) {
|
|
16
|
+
return "matrix(1, 0, 0, 1, 0, 0)";
|
|
17
|
+
}
|
|
18
|
+
return rotate.value.getMatrix({
|
|
19
|
+
w: props.pageSize.width,
|
|
20
|
+
h: props.pageSize.height,
|
|
21
|
+
asString: true
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
return (_ctx, _cache) => {
|
|
25
|
+
return openBlock(), createElementBlock("div", {
|
|
26
|
+
style: normalizeStyle({
|
|
27
|
+
position: "absolute",
|
|
28
|
+
transformOrigin: "0 0",
|
|
29
|
+
transform: transformMatrix.value
|
|
30
|
+
})
|
|
31
|
+
}, [
|
|
32
|
+
renderSlot(_ctx.$slots, "default")
|
|
33
|
+
], 4);
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
export {
|
|
38
|
+
_sfc_main as Rotate,
|
|
39
|
+
useRotateCapability,
|
|
40
|
+
useRotatePlugin
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/vue/hooks/use-rotate.ts","../../src/vue/components/rotate.vue"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/vue';\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","<script setup lang=\"ts\">\nimport { computed } from 'vue';\nimport type { Size } from '@embedpdf/models';\nimport { useRotateCapability } from '../hooks';\n\ninterface Props {\n pageSize: Size;\n}\n\nconst props = defineProps<Props>();\n\nconst { provides: rotate } = useRotateCapability();\n\nconst transformMatrix = computed(() => {\n // If the capability is not yet available, return an identity matrix.\n if (!rotate.value) {\n return 'matrix(1, 0, 0, 1, 0, 0)';\n }\n\n // Get the CSS transform matrix string from the capability.\n return rotate.value.getMatrix({\n w: props.pageSize.width,\n h: props.pageSize.height,\n asString: true,\n }) as string;\n});\n</script>\n\n<template>\n <div\n :style=\"{\n position: 'absolute',\n transformOrigin: '0 0',\n transform: transformMatrix,\n }\"\n >\n <slot />\n </div>\n</template>\n"],"names":["_createElementBlock","_normalizeStyle","_renderSlot"],"mappings":";;;AAMO,MAAM,kBAAkB,MAAM,UAAwB,aAAa,EAAE;AAMrE,MAAM,sBAAsB,MAAM,cAA4B,aAAa,EAAE;;;;;;;ACHpF,UAAM,QAAQ;AAEd,UAAM,EAAE,UAAU,OAAO,IAAI,oBAAoB;AAE3C,UAAA,kBAAkB,SAAS,MAAM;AAEjC,UAAA,CAAC,OAAO,OAAO;AACV,eAAA;AAAA,MAAA;AAIF,aAAA,OAAO,MAAM,UAAU;AAAA,QAC5B,GAAG,MAAM,SAAS;AAAA,QAClB,GAAG,MAAM,SAAS;AAAA,QAClB,UAAU;AAAA,MAAA,CACX;AAAA,IAAA,CACF;;0BAICA,mBAQM,OAAA;AAAA,QAPH,OAAKC,eAAA;AAAA;;qBAA+E,gBAAe;AAAA;;QAMpGC,WAAQ,KAAA,QAAA,SAAA;AAAA;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embedpdf/plugin-rotate",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -20,23 +20,28 @@
|
|
|
20
20
|
"types": "./dist/react/index.d.ts",
|
|
21
21
|
"import": "./dist/react/index.js",
|
|
22
22
|
"require": "./dist/react/index.cjs"
|
|
23
|
+
},
|
|
24
|
+
"./vue": {
|
|
25
|
+
"types": "./dist/vue/index.d.ts",
|
|
26
|
+
"import": "./dist/vue/index.js",
|
|
27
|
+
"require": "./dist/vue/index.cjs"
|
|
23
28
|
}
|
|
24
29
|
},
|
|
25
30
|
"dependencies": {
|
|
26
|
-
"@embedpdf/models": "1.0.
|
|
27
|
-
"@embedpdf/plugin-loader": "1.0.11"
|
|
31
|
+
"@embedpdf/models": "1.0.13"
|
|
28
32
|
},
|
|
29
33
|
"devDependencies": {
|
|
30
34
|
"@types/react": "^18.2.0",
|
|
31
|
-
"tsup": "^8.0.0",
|
|
32
35
|
"typescript": "^5.0.0",
|
|
33
|
-
"@embedpdf/
|
|
36
|
+
"@embedpdf/build": "1.0.0",
|
|
37
|
+
"@embedpdf/core": "1.0.13"
|
|
34
38
|
},
|
|
35
39
|
"peerDependencies": {
|
|
40
|
+
"preact": "^10.26.4",
|
|
36
41
|
"react": ">=16.8.0",
|
|
37
42
|
"react-dom": ">=16.8.0",
|
|
38
|
-
"
|
|
39
|
-
"@embedpdf/core": "1.0.
|
|
43
|
+
"vue": ">=3.2.0",
|
|
44
|
+
"@embedpdf/core": "1.0.13"
|
|
40
45
|
},
|
|
41
46
|
"files": [
|
|
42
47
|
"dist",
|
|
@@ -55,11 +60,13 @@
|
|
|
55
60
|
"access": "public"
|
|
56
61
|
},
|
|
57
62
|
"scripts": {
|
|
58
|
-
"build": "
|
|
59
|
-
"build:
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
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"
|
|
64
71
|
}
|
|
65
72
|
}
|
package/dist/index.d.cts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { BasePluginConfig, BasePlugin, PluginRegistry, PluginManifest, PluginPackage } from '@embedpdf/core';
|
|
2
|
-
import { Rotation } from '@embedpdf/models';
|
|
3
|
-
|
|
4
|
-
interface RotatePluginConfig extends BasePluginConfig {
|
|
5
|
-
defaultRotation?: Rotation;
|
|
6
|
-
}
|
|
7
|
-
interface RotateCapability {
|
|
8
|
-
onRotateChange(handler: (rotation: Rotation) => void): void;
|
|
9
|
-
setRotation(rotation: Rotation): void;
|
|
10
|
-
getRotation(): Rotation;
|
|
11
|
-
rotateForward(): void;
|
|
12
|
-
rotateBackward(): void;
|
|
13
|
-
getMatrix(opts?: {
|
|
14
|
-
w?: number;
|
|
15
|
-
h?: number;
|
|
16
|
-
asString?: boolean;
|
|
17
|
-
}): string | [number, number, number, number, number, number];
|
|
18
|
-
}
|
|
19
|
-
interface RotateState {
|
|
20
|
-
rotation: Rotation;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
declare class RotatePlugin extends BasePlugin<RotatePluginConfig, RotateCapability> {
|
|
24
|
-
static readonly id: "rotate";
|
|
25
|
-
private readonly rotate$;
|
|
26
|
-
constructor(id: string, registry: PluginRegistry, cfg: RotatePluginConfig);
|
|
27
|
-
initialize(_config: RotatePluginConfig): Promise<void>;
|
|
28
|
-
private setRotation;
|
|
29
|
-
private rotateForward;
|
|
30
|
-
private rotateBackward;
|
|
31
|
-
protected buildCapability(): RotateCapability;
|
|
32
|
-
destroy(): Promise<void>;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
declare const ROTATE_PLUGIN_ID = "rotate";
|
|
36
|
-
declare const manifest: PluginManifest<RotatePluginConfig>;
|
|
37
|
-
|
|
38
|
-
declare const RotatePluginPackage: PluginPackage<RotatePlugin, RotatePluginConfig>;
|
|
39
|
-
|
|
40
|
-
export { ROTATE_PLUGIN_ID, type RotateCapability, RotatePlugin, type RotatePluginConfig, RotatePluginPackage, type RotateState, manifest };
|
package/dist/preact/index.d.cts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import * as _embedpdf_plugin_rotate from '@embedpdf/plugin-rotate';
|
|
2
|
-
import { RotatePlugin } from '@embedpdf/plugin-rotate';
|
|
3
|
-
import { JSX, ComponentChildren } from 'preact';
|
|
4
|
-
import { Size } from '@embedpdf/models';
|
|
5
|
-
|
|
6
|
-
declare const useRotatePlugin: () => {
|
|
7
|
-
plugin: RotatePlugin | null;
|
|
8
|
-
isLoading: boolean;
|
|
9
|
-
ready: Promise<void>;
|
|
10
|
-
};
|
|
11
|
-
declare const useRotateCapability: () => {
|
|
12
|
-
provides: Readonly<_embedpdf_plugin_rotate.RotateCapability> | null;
|
|
13
|
-
isLoading: boolean;
|
|
14
|
-
ready: Promise<void>;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
/** @jsxImportSource preact */
|
|
18
|
-
|
|
19
|
-
type RotateProps = JSX.HTMLAttributes<HTMLDivElement> & {
|
|
20
|
-
children: ComponentChildren;
|
|
21
|
-
pageSize: Size;
|
|
22
|
-
};
|
|
23
|
-
declare function Rotate({ children, pageSize, ...props }: RotateProps): JSX.Element;
|
|
24
|
-
|
|
25
|
-
export { Rotate, useRotateCapability, useRotatePlugin };
|
package/dist/react/index.d.cts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import * as _embedpdf_plugin_rotate from '@embedpdf/plugin-rotate';
|
|
2
|
-
import { RotatePlugin } from '@embedpdf/plugin-rotate';
|
|
3
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
-
import { ReactNode } from 'react';
|
|
5
|
-
import { Size } from '@embedpdf/models';
|
|
6
|
-
|
|
7
|
-
declare const useRotatePlugin: () => {
|
|
8
|
-
plugin: RotatePlugin | null;
|
|
9
|
-
isLoading: boolean;
|
|
10
|
-
ready: Promise<void>;
|
|
11
|
-
};
|
|
12
|
-
declare const useRotateCapability: () => {
|
|
13
|
-
provides: Readonly<_embedpdf_plugin_rotate.RotateCapability> | null;
|
|
14
|
-
isLoading: boolean;
|
|
15
|
-
ready: Promise<void>;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
type RotateProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
19
|
-
children: ReactNode;
|
|
20
|
-
pageSize: Size;
|
|
21
|
-
};
|
|
22
|
-
declare function Rotate({ children, pageSize, ...props }: RotateProps): react_jsx_runtime.JSX.Element;
|
|
23
|
-
|
|
24
|
-
export { Rotate, useRotateCapability, useRotatePlugin };
|