@embedpdf/plugin-rotate 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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/dist/index.cjs ADDED
@@ -0,0 +1,142 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
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
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/lib/manifest.ts","../src/lib/rotate-plugin.ts","../src/lib/utils.ts","../src/lib/index.ts"],"sourcesContent":["export * from './lib';\n","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"],"mappings":"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","names":[]}
@@ -0,0 +1,40 @@
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 };
@@ -0,0 +1,40 @@
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/index.js ADDED
@@ -0,0 +1,112 @@
1
+ // src/lib/manifest.ts
2
+ var ROTATE_PLUGIN_ID = "rotate";
3
+ var manifest = {
4
+ id: ROTATE_PLUGIN_ID,
5
+ name: "Rotate Plugin",
6
+ version: "1.0.0",
7
+ provides: ["rotate"],
8
+ requires: ["loader"],
9
+ optional: ["spread"],
10
+ defaultConfig: {
11
+ enabled: true
12
+ }
13
+ };
14
+
15
+ // src/lib/rotate-plugin.ts
16
+ import { BasePlugin, createBehaviorEmitter, setRotation } from "@embedpdf/core";
17
+
18
+ // src/lib/utils.ts
19
+ function rotationMatrix(rotation, w, h, asString = true) {
20
+ let a = 1, b = 0, c = 0, d = 1, e = 0, f = 0;
21
+ switch (rotation) {
22
+ case 1:
23
+ a = 0;
24
+ b = 1;
25
+ c = -1;
26
+ d = 0;
27
+ e = h;
28
+ break;
29
+ case 2:
30
+ a = -1;
31
+ b = 0;
32
+ c = 0;
33
+ d = -1;
34
+ e = w;
35
+ f = h;
36
+ break;
37
+ case 3:
38
+ a = 0;
39
+ b = -1;
40
+ c = 1;
41
+ d = 0;
42
+ f = w;
43
+ break;
44
+ }
45
+ return asString ? `matrix(${a},${b},${c},${d},${e},${f})` : [a, b, c, d, e, f];
46
+ }
47
+
48
+ // src/lib/rotate-plugin.ts
49
+ function getNextRotation(current) {
50
+ return (current + 1) % 4;
51
+ }
52
+ function getPreviousRotation(current) {
53
+ return (current + 3) % 4;
54
+ }
55
+ var RotatePlugin = class extends BasePlugin {
56
+ constructor(id, registry, cfg) {
57
+ super(id, registry);
58
+ this.rotate$ = createBehaviorEmitter();
59
+ this.resetReady();
60
+ const rotation = cfg.defaultRotation ?? this.coreState.core.rotation;
61
+ this.setRotation(rotation);
62
+ this.markReady();
63
+ }
64
+ async initialize(_config) {
65
+ }
66
+ setRotation(rotation) {
67
+ const pages = this.coreState.core.pages;
68
+ if (!pages) {
69
+ throw new Error("Pages not loaded");
70
+ }
71
+ this.dispatchCoreAction(setRotation(rotation));
72
+ }
73
+ rotateForward() {
74
+ const rotation = getNextRotation(this.coreState.core.rotation);
75
+ this.setRotation(rotation);
76
+ }
77
+ rotateBackward() {
78
+ const rotation = getPreviousRotation(this.coreState.core.rotation);
79
+ this.setRotation(rotation);
80
+ }
81
+ buildCapability() {
82
+ return {
83
+ onRotateChange: this.rotate$.on,
84
+ setRotation: (rotation) => this.setRotation(rotation),
85
+ getRotation: () => this.coreState.core.rotation,
86
+ rotateForward: () => this.rotateForward(),
87
+ rotateBackward: () => this.rotateBackward(),
88
+ getMatrix: ({ w = 0, h = 0, asString = true } = {}) => rotationMatrix(this.coreState.core.rotation, w, h, asString)
89
+ };
90
+ }
91
+ async destroy() {
92
+ this.rotate$.clear();
93
+ super.destroy();
94
+ }
95
+ };
96
+ RotatePlugin.id = "rotate";
97
+
98
+ // src/lib/index.ts
99
+ var RotatePluginPackage = {
100
+ manifest,
101
+ create: (registry, _engine, config) => new RotatePlugin(ROTATE_PLUGIN_ID, registry, config),
102
+ reducer: () => {
103
+ },
104
+ initialState: {}
105
+ };
106
+ export {
107
+ ROTATE_PLUGIN_ID,
108
+ RotatePlugin,
109
+ RotatePluginPackage,
110
+ manifest
111
+ };
112
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"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"],"mappings":";AAGO,IAAM,mBAAmB;AAEzB,IAAM,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,EACX;AACF;;;ACfA,SAAS,YAAY,uBAAuC,mBAAmB;;;ACcxE,SAAS,eACd,UACA,GACA,GACA,WAAW,MACgD;AAC3D,MAAI,IAAI,GACN,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI;AAEN,UAAQ,UAAU;AAAA,IAChB,KAAK;AACH,UAAI;AACJ,UAAI;AACJ,UAAI;AACJ,UAAI;AACJ,UAAI;AACJ;AAAA,IACF,KAAK;AACH,UAAI;AACJ,UAAI;AACJ,UAAI;AACJ,UAAI;AACJ,UAAI;AACJ,UAAI;AACJ;AAAA,IACF,KAAK;AACH,UAAI;AACJ,UAAI;AACJ,UAAI;AACJ,UAAI;AACJ,UAAI;AACJ;AAAA,EACJ;AACA,SAAO,WAAW,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AAC/E;;;AD/CA,SAAS,gBAAgB,SAA6B;AACpD,UAAS,UAAU,KAAK;AAC1B;AAEA,SAAS,oBAAoB,SAA6B;AACxD,UAAS,UAAU,KAAK;AAC1B;AAEO,IAAM,eAAN,cAA2B,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,EACjB;AAAA,EAEA,MAAM,WAAW,SAA4C;AAAA,EAAC;AAAA,EAEtD,YAAY,UAA0B;AAC5C,UAAM,QAAQ,KAAK,UAAU,KAAK;AAClC,QAAI,CAAC,OAAO;AACV,YAAM,IAAI,MAAM,kBAAkB;AAAA,IACpC;AAEA,SAAK,mBAAmB,YAAY,QAAQ,CAAC;AAAA,EAC/C;AAAA,EAEQ,gBAAsB;AAC5B,UAAM,WAAW,gBAAgB,KAAK,UAAU,KAAK,QAAQ;AAC7D,SAAK,YAAY,QAAQ;AAAA,EAC3B;AAAA,EAEQ,iBAAuB;AAC7B,UAAM,WAAW,oBAAoB,KAAK,UAAU,KAAK,QAAQ;AACjE,SAAK,YAAY,QAAQ;AAAA,EAC3B;AAAA,EAEU,kBAAoC;AAC5C,WAAO;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,KAAK,IAAI,CAAC,MAC/C,eAAe,KAAK,UAAU,KAAK,UAAU,GAAG,GAAG,QAAQ;AAAA,IAC/D;AAAA,EACF;AAAA,EAEA,MAAM,UAAyB;AAC7B,SAAK,QAAQ,MAAM;AACnB,UAAM,QAAQ;AAAA,EAChB;AACF;AAjDa,aACK,KAAK;;;AEThB,IAAM,sBAAuE;AAAA,EAClF;AAAA,EACA,QAAQ,CAAC,UAAU,SAAS,WAAW,IAAI,aAAa,kBAAkB,UAAU,MAAM;AAAA,EAC1F,SAAS,MAAM;AAAA,EAAC;AAAA,EAChB,cAAc,CAAC;AACjB;","names":[]}
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
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
+ useRotate: () => useRotate,
25
+ useRotateCapability: () => useRotateCapability
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 useRotate = () => (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
+ useRotate,
60
+ useRotateCapability
61
+ });
62
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/preact/index.ts","../../src/preact/hooks/use-rotate.ts","../../src/preact/components/rotate.tsx"],"sourcesContent":["export * from './hooks';\nexport * from './components';\n","import { useCapability, usePlugin } from '@embedpdf/core/preact';\nimport { RotatePlugin } from '@embedpdf/plugin-rotate';\n\nexport const useRotate = () => usePlugin<RotatePlugin>(RotatePlugin.id);\nexport const useRotateCapability = () => useCapability<RotatePlugin>(RotatePlugin.id);\n","/** @jsxImportSource preact */\nimport { ComponentChildren, JSX } from 'preact';\nimport { Size } from '@embedpdf/models';\n\nimport { useRotateCapability } from '../hooks';\n\ntype RotateProps = JSX.HTMLAttributes<HTMLDivElement> & {\n children: ComponentChildren;\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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,oBAAyC;AACzC,2BAA6B;AAEtB,IAAM,YAAY,UAAM,yBAAwB,kCAAa,EAAE;AAC/D,IAAM,sBAAsB,UAAM,6BAA4B,kCAAa,EAAE;;;ACgBhF;AATG,SAAS,OAAO,EAAE,UAAU,UAAU,GAAG,MAAM,GAAgB;AACpE,QAAM,EAAE,UAAU,OAAO,IAAI,oBAAoB;AACjD,QAAM,SACH,QAAQ,UAAU;AAAA,IACjB,GAAG,SAAS;AAAA,IACZ,GAAG,SAAS;AAAA,EACd,CAAC,KAAgB;AAEnB,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,OAAO;AAAA,QACL,UAAU;AAAA,QACV,iBAAiB;AAAA,QACjB,WAAW;AAAA,MACb;AAAA,MAEC;AAAA;AAAA,EACH;AAEJ;","names":[]}
@@ -0,0 +1,25 @@
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 useRotate: () => {
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, useRotate, useRotateCapability };
@@ -0,0 +1,25 @@
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 useRotate: () => {
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, useRotate, useRotateCapability };
@@ -0,0 +1,33 @@
1
+ // src/preact/hooks/use-rotate.ts
2
+ import { useCapability, usePlugin } from "@embedpdf/core/preact";
3
+ import { RotatePlugin } from "@embedpdf/plugin-rotate";
4
+ var useRotate = () => usePlugin(RotatePlugin.id);
5
+ var useRotateCapability = () => useCapability(RotatePlugin.id);
6
+
7
+ // src/preact/components/rotate.tsx
8
+ import { jsx } from "preact/jsx-runtime";
9
+ function Rotate({ children, pageSize, ...props }) {
10
+ const { provides: rotate } = useRotateCapability();
11
+ const matrix = rotate?.getMatrix({
12
+ w: pageSize.width,
13
+ h: pageSize.height
14
+ }) || "matrix(1, 0, 0, 1, 0, 0)";
15
+ return /* @__PURE__ */ jsx(
16
+ "div",
17
+ {
18
+ ...props,
19
+ style: {
20
+ position: "absolute",
21
+ transformOrigin: "0 0",
22
+ transform: matrix
23
+ },
24
+ children
25
+ }
26
+ );
27
+ }
28
+ export {
29
+ Rotate,
30
+ useRotate,
31
+ useRotateCapability
32
+ };
33
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/preact/hooks/use-rotate.ts","../../src/preact/components/rotate.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/preact';\nimport { RotatePlugin } from '@embedpdf/plugin-rotate';\n\nexport const useRotate = () => usePlugin<RotatePlugin>(RotatePlugin.id);\nexport const useRotateCapability = () => useCapability<RotatePlugin>(RotatePlugin.id);\n","/** @jsxImportSource preact */\nimport { ComponentChildren, JSX } from 'preact';\nimport { Size } from '@embedpdf/models';\n\nimport { useRotateCapability } from '../hooks';\n\ntype RotateProps = JSX.HTMLAttributes<HTMLDivElement> & {\n children: ComponentChildren;\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"],"mappings":";AAAA,SAAS,eAAe,iBAAiB;AACzC,SAAS,oBAAoB;AAEtB,IAAM,YAAY,MAAM,UAAwB,aAAa,EAAE;AAC/D,IAAM,sBAAsB,MAAM,cAA4B,aAAa,EAAE;;;ACgBhF;AATG,SAAS,OAAO,EAAE,UAAU,UAAU,GAAG,MAAM,GAAgB;AACpE,QAAM,EAAE,UAAU,OAAO,IAAI,oBAAoB;AACjD,QAAM,SACH,QAAQ,UAAU;AAAA,IACjB,GAAG,SAAS;AAAA,IACZ,GAAG,SAAS;AAAA,EACd,CAAC,KAAgB;AAEnB,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,OAAO;AAAA,QACL,UAAU;AAAA,QACV,iBAAiB;AAAA,QACjB,WAAW;AAAA,MACb;AAAA,MAEC;AAAA;AAAA,EACH;AAEJ;","names":[]}
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
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
+ useRotate: () => useRotate,
25
+ useRotateCapability: () => useRotateCapability
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 useRotate = () => (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
+ useRotate,
60
+ useRotateCapability
61
+ });
62
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/react/index.ts","../../src/react/hooks/use-rotate.ts","../../src/react/components/rotate.tsx"],"sourcesContent":["export * from './hooks';\nexport * from './components';\n","import { useCapability, usePlugin } from '@embedpdf/core/react';\nimport { RotatePlugin } from '@embedpdf/plugin-rotate';\n\nexport const useRotate = () => usePlugin<RotatePlugin>(RotatePlugin.id);\nexport const useRotateCapability = () => useCapability<RotatePlugin>(RotatePlugin.id);\n","import { ReactNode } from 'react';\nimport { Size } from '@embedpdf/models';\n\nimport { useRotateCapability } from '../hooks';\n\ntype RotateProps = React.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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAyC;AACzC,2BAA6B;AAEtB,IAAM,YAAY,UAAM,wBAAwB,kCAAa,EAAE;AAC/D,IAAM,sBAAsB,UAAM,4BAA4B,kCAAa,EAAE;;;ACehF;AATG,SAAS,OAAO,EAAE,UAAU,UAAU,GAAG,MAAM,GAAgB;AACpE,QAAM,EAAE,UAAU,OAAO,IAAI,oBAAoB;AACjD,QAAM,SACH,QAAQ,UAAU;AAAA,IACjB,GAAG,SAAS;AAAA,IACZ,GAAG,SAAS;AAAA,EACd,CAAC,KAAgB;AAEnB,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,OAAO;AAAA,QACL,UAAU;AAAA,QACV,iBAAiB;AAAA,QACjB,WAAW;AAAA,MACb;AAAA,MAEC;AAAA;AAAA,EACH;AAEJ;","names":[]}
@@ -0,0 +1,24 @@
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 useRotate: () => {
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, useRotate, useRotateCapability };
@@ -0,0 +1,24 @@
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 useRotate: () => {
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, useRotate, useRotateCapability };
@@ -0,0 +1,33 @@
1
+ // src/react/hooks/use-rotate.ts
2
+ import { useCapability, usePlugin } from "@embedpdf/core/react";
3
+ import { RotatePlugin } from "@embedpdf/plugin-rotate";
4
+ var useRotate = () => usePlugin(RotatePlugin.id);
5
+ var useRotateCapability = () => useCapability(RotatePlugin.id);
6
+
7
+ // src/react/components/rotate.tsx
8
+ import { jsx } from "react/jsx-runtime";
9
+ function Rotate({ children, pageSize, ...props }) {
10
+ const { provides: rotate } = useRotateCapability();
11
+ const matrix = rotate?.getMatrix({
12
+ w: pageSize.width,
13
+ h: pageSize.height
14
+ }) || "matrix(1, 0, 0, 1, 0, 0)";
15
+ return /* @__PURE__ */ jsx(
16
+ "div",
17
+ {
18
+ ...props,
19
+ style: {
20
+ position: "absolute",
21
+ transformOrigin: "0 0",
22
+ transform: matrix
23
+ },
24
+ children
25
+ }
26
+ );
27
+ }
28
+ export {
29
+ Rotate,
30
+ useRotate,
31
+ useRotateCapability
32
+ };
33
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/react/hooks/use-rotate.ts","../../src/react/components/rotate.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/react';\nimport { RotatePlugin } from '@embedpdf/plugin-rotate';\n\nexport const useRotate = () => usePlugin<RotatePlugin>(RotatePlugin.id);\nexport const useRotateCapability = () => useCapability<RotatePlugin>(RotatePlugin.id);\n","import { ReactNode } from 'react';\nimport { Size } from '@embedpdf/models';\n\nimport { useRotateCapability } from '../hooks';\n\ntype RotateProps = React.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"],"mappings":";AAAA,SAAS,eAAe,iBAAiB;AACzC,SAAS,oBAAoB;AAEtB,IAAM,YAAY,MAAM,UAAwB,aAAa,EAAE;AAC/D,IAAM,sBAAsB,MAAM,cAA4B,aAAa,EAAE;;;ACehF;AATG,SAAS,OAAO,EAAE,UAAU,UAAU,GAAG,MAAM,GAAgB;AACpE,QAAM,EAAE,UAAU,OAAO,IAAI,oBAAoB;AACjD,QAAM,SACH,QAAQ,UAAU;AAAA,IACjB,GAAG,SAAS;AAAA,IACZ,GAAG,SAAS;AAAA,EACd,CAAC,KAAgB;AAEnB,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,OAAO;AAAA,QACL,UAAU;AAAA,QACV,iBAAiB;AAAA,QACjB,WAAW;AAAA,MACb;AAAA,MAEC;AAAA;AAAA,EACH;AAEJ;","names":[]}
package/package.json ADDED
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "@embedpdf/plugin-rotate",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "main": "./dist/index.cjs",
6
+ "module": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "require": "./dist/index.cjs"
13
+ },
14
+ "./preact": {
15
+ "types": "./dist/preact/index.d.ts",
16
+ "import": "./dist/preact/index.js",
17
+ "require": "./dist/preact/index.cjs"
18
+ },
19
+ "./react": {
20
+ "types": "./dist/react/index.d.ts",
21
+ "import": "./dist/react/index.js",
22
+ "require": "./dist/react/index.cjs"
23
+ }
24
+ },
25
+ "dependencies": {
26
+ "@embedpdf/models": "1.0.0",
27
+ "@embedpdf/plugin-loader": "1.0.0"
28
+ },
29
+ "devDependencies": {
30
+ "@types/react": "^18.2.0",
31
+ "tsup": "^8.0.0",
32
+ "typescript": "^5.0.0",
33
+ "@embedpdf/plugin-spread": "1.0.0"
34
+ },
35
+ "peerDependencies": {
36
+ "react": ">=16.8.0",
37
+ "react-dom": ">=16.8.0",
38
+ "preact": "^10.26.4",
39
+ "@embedpdf/core": "1.0.0"
40
+ },
41
+ "files": [
42
+ "dist",
43
+ "README.md"
44
+ ],
45
+ "repository": {
46
+ "type": "git",
47
+ "url": "https://github.com/embedpdf/embed-pdf-viewer",
48
+ "directory": "packages/plugin-rotate"
49
+ },
50
+ "homepage": "https://www.embedpdf.com/docs",
51
+ "bugs": {
52
+ "url": "https://github.com/embedpdf/embed-pdf-viewer/issues"
53
+ },
54
+ "publishConfig": {
55
+ "access": "public"
56
+ },
57
+ "scripts": {
58
+ "build": "PROJECT_CWD=$(pwd) pnpm -w p:build",
59
+ "build:watch": "PROJECT_CWD=$(pwd) pnpm -w p:build:watch",
60
+ "clean": "PROJECT_CWD=$(pwd) pnpm -w p:clean",
61
+ "lint": "PROJECT_CWD=$(pwd) pnpm -w p:lint",
62
+ "lint:fix": "PROJECT_CWD=$(pwd) pnpm -w p:lint:fix",
63
+ "typecheck": "PROJECT_CWD=$(pwd) pnpm -w p:typecheck"
64
+ }
65
+ }