@embedpdf/plugin-rotate 1.3.16 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/shared/components/index.d.ts +1 -0
- package/dist/shared/components/rotate.d.ts +9 -0
- package/dist/shared/hooks/index.d.ts +1 -0
- package/dist/shared/hooks/use-rotate.d.ts +16 -0
- package/dist/shared/index.d.ts +3 -0
- package/dist/svelte/components/Rotate.svelte.d.ts +9 -0
- package/dist/svelte/components/index.d.ts +1 -0
- package/dist/svelte/hooks/index.d.ts +1 -0
- package/dist/svelte/hooks/use-rotate.svelte.d.ts +26 -0
- package/dist/svelte/index.cjs +2 -0
- package/dist/svelte/index.cjs.map +1 -0
- package/dist/svelte/index.d.ts +3 -0
- package/dist/svelte/index.js +51 -0
- package/dist/svelte/index.js.map +1 -0
- package/package.json +13 -6
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './rotate';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ReactNode, HTMLAttributes, CSSProperties } from '../../react/adapter.ts';
|
|
2
|
+
import { Size } from '@embedpdf/models';
|
|
3
|
+
type RotateProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
pageSize: Size;
|
|
6
|
+
style?: CSSProperties;
|
|
7
|
+
};
|
|
8
|
+
export declare function Rotate({ children, pageSize, style, ...props }: RotateProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './use-rotate';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Rotation } from '@embedpdf/models';
|
|
2
|
+
import { RotatePlugin } from '../../index.ts';
|
|
3
|
+
export declare const useRotatePlugin: () => {
|
|
4
|
+
plugin: RotatePlugin | null;
|
|
5
|
+
isLoading: boolean;
|
|
6
|
+
ready: Promise<void>;
|
|
7
|
+
};
|
|
8
|
+
export declare const useRotateCapability: () => {
|
|
9
|
+
provides: Readonly<import('../../index.ts').RotateCapability> | null;
|
|
10
|
+
isLoading: boolean;
|
|
11
|
+
ready: Promise<void>;
|
|
12
|
+
};
|
|
13
|
+
export declare const useRotate: () => {
|
|
14
|
+
rotation: Rotation;
|
|
15
|
+
provides: Readonly<import('../../index.ts').RotateCapability> | null;
|
|
16
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Size } from '@embedpdf/models';
|
|
2
|
+
import { Snippet } from 'svelte';
|
|
3
|
+
interface RotateProps {
|
|
4
|
+
pageSize: Size;
|
|
5
|
+
children?: Snippet;
|
|
6
|
+
}
|
|
7
|
+
declare const Rotate: import('svelte', { with: { "resolution-mode": "import" } }).Component<RotateProps, {}, "">;
|
|
8
|
+
type Rotate = ReturnType<typeof Rotate>;
|
|
9
|
+
export default Rotate;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Rotate } from './Rotate.svelte';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './use-rotate.svelte';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Rotation } from '@embedpdf/models';
|
|
2
|
+
import { RotatePlugin } from '../../lib/index.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Hook to get the raw rotate plugin instance.
|
|
5
|
+
*/
|
|
6
|
+
export declare const useRotatePlugin: () => {
|
|
7
|
+
plugin: RotatePlugin | null;
|
|
8
|
+
isLoading: boolean;
|
|
9
|
+
ready: Promise<void>;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Hook to get the rotate plugin's capability API.
|
|
13
|
+
* This provides methods for rotating the document.
|
|
14
|
+
*/
|
|
15
|
+
export declare const useRotateCapability: () => {
|
|
16
|
+
provides: Readonly<import('../../lib/index.ts').RotateCapability> | null;
|
|
17
|
+
isLoading: boolean;
|
|
18
|
+
ready: Promise<void>;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Hook that provides reactive rotation state and methods.
|
|
22
|
+
*/
|
|
23
|
+
export declare const useRotate: () => {
|
|
24
|
+
readonly provides: Readonly<import('../../lib/index.ts').RotateCapability> | null;
|
|
25
|
+
rotation: Rotation;
|
|
26
|
+
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("svelte/internal/client"),t=require("@embedpdf/core/svelte"),r=require("@embedpdf/plugin-rotate");function o(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const r in e)if("default"!==r){const o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,o.get?o:{enumerable:!0,get:()=>e[r]})}return t.default=e,Object.freeze(t)}require("svelte/internal/disclose-version");const i=o(e),n=()=>t.usePlugin(r.RotatePlugin.id),s=()=>t.useCapability(r.RotatePlugin.id);var a=i.from_html("<div><!></div>");exports.Rotate=function(e,t){i.push(t,!0);const r=n(),o=i.derived((()=>r.plugin?r.plugin.getMatrixAsString({w:t.pageSize.width,h:t.pageSize.height}):"matrix(1, 0, 0, 1, 0, 0)"));var s=a();let p;var l=i.child(s);i.snippet(l,(()=>t.children??i.noop)),i.reset(s),i.template_effect((e=>p=i.set_style(s,"",p,e)),[()=>({position:"absolute","transform-origin":"0 0",transform:i.get(o)})]),i.append(e,s),i.pop()},exports.useRotate=()=>{const e=s(),t=i.proxy({get provides(){return e.provides},rotation:0});return i.user_effect((()=>{if(!e.provides)return;return e.provides.onRotateChange((e=>{t.rotation=e}))})),t},exports.useRotateCapability=s,exports.useRotatePlugin=n,Object.keys(r).forEach((e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>r[e]})}));
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/svelte/hooks/use-rotate.svelte.ts","../../src/svelte/components/Rotate.svelte"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/svelte';\nimport { Rotation } from '@embedpdf/models';\nimport { RotatePlugin } from '@embedpdf/plugin-rotate';\n\n/**\n * Hook to get the raw rotate plugin instance.\n */\nexport const useRotatePlugin = () => usePlugin<RotatePlugin>(RotatePlugin.id);\n\n/**\n * Hook to get the rotate plugin's capability API.\n * This provides methods for rotating the document.\n */\nexport const useRotateCapability = () => useCapability<RotatePlugin>(RotatePlugin.id);\n\n/**\n * Hook that provides reactive rotation state and methods.\n */\nexport const useRotate = () => {\n const capability = useRotateCapability();\n\n const state = $state({\n get provides() {\n return capability.provides;\n },\n rotation: 0 as Rotation,\n });\n\n $effect(() => {\n if (!capability.provides) return;\n\n const unsubscribe = capability.provides.onRotateChange((newRotation) => {\n state.rotation = newRotation;\n });\n\n return unsubscribe;\n });\n\n return state;\n};\n","<script lang=\"ts\">\n import type { Size } from '@embedpdf/models';\n import type { Snippet } from 'svelte';\n import { useRotatePlugin } from '../hooks';\n\n interface RotateProps {\n pageSize: Size;\n children?: Snippet;\n }\n\n let { pageSize, children }: RotateProps = $props();\n\n const rotatePlugin = useRotatePlugin();\n\n const transformMatrix = $derived(\n rotatePlugin.plugin\n ? rotatePlugin.plugin.getMatrixAsString({\n w: pageSize.width,\n h: pageSize.height,\n })\n : 'matrix(1, 0, 0, 1, 0, 0)',\n );\n</script>\n\n<div style:position=\"absolute\" style:transform-origin=\"0 0\" style:transform={transformMatrix}>\n {@render children?.()}\n</div>\n"],"names":["useRotatePlugin","usePlugin","RotatePlugin","id","useRotateCapability","useCapability","rotatePlugin","transformMatrix","$","derived","plugin","getMatrixAsString","w","$$props","pageSize","width","h","height","capability","state","provides","rotation","user_effect","onRotateChange","newRotation"],"mappings":"sgBAOaA,EAAwB,IAAAC,YAAwBC,EAAAA,aAAaC,IAM7DC,EAA4B,IAAAC,gBAA4BH,EAAAA,aAAaC,kFCD1E,MAAAG,EAAeN,IAEfO,EAAeC,EAAAC,SAAA,IACnBH,EAAaI,OACTJ,EAAaI,OAAOC,kBAAiB,CACnCC,EAACC,EAAAC,SAAWC,MACZC,EAACH,EAAAC,SAAWG,SAEd,kOAIqEV,4BAF7E,yBDHQ,MAAAW,EAAad,IAEbe,WACA,YAAAC,GACK,OAAAF,EAAWE,QACpB,EACAC,SAAU,IAaL,OAVPb,EAAAc,kBACO,IAAAJ,EAAWE,SAAU,OAMnB,OAJaF,EAAWE,SAASG,gBAAgBC,IACtDL,EAAME,SAAWG,CAAA,GAGZ,IAGFL,CAAA"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as $ from "svelte/internal/client";
|
|
2
|
+
import { usePlugin, useCapability } from "@embedpdf/core/svelte";
|
|
3
|
+
import { RotatePlugin } from "@embedpdf/plugin-rotate";
|
|
4
|
+
export * from "@embedpdf/plugin-rotate";
|
|
5
|
+
import "svelte/internal/disclose-version";
|
|
6
|
+
const useRotatePlugin = () => usePlugin(RotatePlugin.id);
|
|
7
|
+
const useRotateCapability = () => useCapability(RotatePlugin.id);
|
|
8
|
+
const useRotate = () => {
|
|
9
|
+
const capability = useRotateCapability();
|
|
10
|
+
const state = $.proxy({
|
|
11
|
+
get provides() {
|
|
12
|
+
return capability.provides;
|
|
13
|
+
},
|
|
14
|
+
rotation: 0
|
|
15
|
+
});
|
|
16
|
+
$.user_effect(() => {
|
|
17
|
+
if (!capability.provides) return;
|
|
18
|
+
const unsubscribe = capability.provides.onRotateChange((newRotation) => {
|
|
19
|
+
state.rotation = newRotation;
|
|
20
|
+
});
|
|
21
|
+
return unsubscribe;
|
|
22
|
+
});
|
|
23
|
+
return state;
|
|
24
|
+
};
|
|
25
|
+
var root = $.from_html(`<div><!></div>`);
|
|
26
|
+
function Rotate($$anchor, $$props) {
|
|
27
|
+
$.push($$props, true);
|
|
28
|
+
const rotatePlugin = useRotatePlugin();
|
|
29
|
+
const transformMatrix = $.derived(() => rotatePlugin.plugin ? rotatePlugin.plugin.getMatrixAsString({ w: $$props.pageSize.width, h: $$props.pageSize.height }) : "matrix(1, 0, 0, 1, 0, 0)");
|
|
30
|
+
var div = root();
|
|
31
|
+
let styles;
|
|
32
|
+
var node = $.child(div);
|
|
33
|
+
$.snippet(node, () => $$props.children ?? $.noop);
|
|
34
|
+
$.reset(div);
|
|
35
|
+
$.template_effect(($0) => styles = $.set_style(div, "", styles, $0), [
|
|
36
|
+
() => ({
|
|
37
|
+
position: "absolute",
|
|
38
|
+
"transform-origin": "0 0",
|
|
39
|
+
transform: $.get(transformMatrix)
|
|
40
|
+
})
|
|
41
|
+
]);
|
|
42
|
+
$.append($$anchor, div);
|
|
43
|
+
$.pop();
|
|
44
|
+
}
|
|
45
|
+
export {
|
|
46
|
+
Rotate,
|
|
47
|
+
useRotate,
|
|
48
|
+
useRotateCapability,
|
|
49
|
+
useRotatePlugin
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/svelte/hooks/use-rotate.svelte.ts","../../src/svelte/components/Rotate.svelte"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/svelte';\nimport { Rotation } from '@embedpdf/models';\nimport { RotatePlugin } from '@embedpdf/plugin-rotate';\n\n/**\n * Hook to get the raw rotate plugin instance.\n */\nexport const useRotatePlugin = () => usePlugin<RotatePlugin>(RotatePlugin.id);\n\n/**\n * Hook to get the rotate plugin's capability API.\n * This provides methods for rotating the document.\n */\nexport const useRotateCapability = () => useCapability<RotatePlugin>(RotatePlugin.id);\n\n/**\n * Hook that provides reactive rotation state and methods.\n */\nexport const useRotate = () => {\n const capability = useRotateCapability();\n\n const state = $state({\n get provides() {\n return capability.provides;\n },\n rotation: 0 as Rotation,\n });\n\n $effect(() => {\n if (!capability.provides) return;\n\n const unsubscribe = capability.provides.onRotateChange((newRotation) => {\n state.rotation = newRotation;\n });\n\n return unsubscribe;\n });\n\n return state;\n};\n","<script lang=\"ts\">\n import type { Size } from '@embedpdf/models';\n import type { Snippet } from 'svelte';\n import { useRotatePlugin } from '../hooks';\n\n interface RotateProps {\n pageSize: Size;\n children?: Snippet;\n }\n\n let { pageSize, children }: RotateProps = $props();\n\n const rotatePlugin = useRotatePlugin();\n\n const transformMatrix = $derived(\n rotatePlugin.plugin\n ? rotatePlugin.plugin.getMatrixAsString({\n w: pageSize.width,\n h: pageSize.height,\n })\n : 'matrix(1, 0, 0, 1, 0, 0)',\n );\n</script>\n\n<div style:position=\"absolute\" style:transform-origin=\"0 0\" style:transform={transformMatrix}>\n {@render children?.()}\n</div>\n"],"names":[],"mappings":";;;;;AAOa,MAAA,kBAAwB,MAAA,UAAwB,aAAa,EAAE;AAM/D,MAAA,sBAA4B,MAAA,cAA4B,aAAa,EAAE;AAKvE,MAAA,kBAAkB;AACvB,QAAA,aAAa,oBAAoB;QAEjC;IACA,IAAA,WAAW;AACN,aAAA,WAAW;AAAA,IACpB;AAAA,IACA,UAAU;AAAA;AAGZ,IAAA,kBAAc;AACP,QAAA,CAAA,WAAW,SAAU;UAEpB,cAAc,WAAW,SAAS,eAAA,CAAgB,gBAAgB;AACtE,YAAM,WAAW;AAAA,KAClB;WAEM;AAAA,GACR;SAEM;AACT;;mCCvCA;;AAYQ,QAAA,eAAe,gBAAe;QAE9B,kBAAe,EAAA,QAAA,MACnB,aAAa,SACT,aAAa,OAAO,kBAAiB,EACnC,GAAC,QAAA,SAAW,OACZ,GAAC,QAAA,SAAW,OAAM,CAAA,IAEpB,0BAA0B;;;;;;;;;;uBAI2C,eAAe;AAAA;;;;AAF5F;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embedpdf/plugin-rotate",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -26,23 +26,29 @@
|
|
|
26
26
|
"types": "./dist/vue/index.d.ts",
|
|
27
27
|
"import": "./dist/vue/index.js",
|
|
28
28
|
"require": "./dist/vue/index.cjs"
|
|
29
|
+
},
|
|
30
|
+
"./svelte": {
|
|
31
|
+
"types": "./dist/svelte/index.d.ts",
|
|
32
|
+
"import": "./dist/svelte/index.js",
|
|
33
|
+
"require": "./dist/svelte/index.cjs"
|
|
29
34
|
}
|
|
30
35
|
},
|
|
31
36
|
"dependencies": {
|
|
32
|
-
"@embedpdf/models": "1.
|
|
37
|
+
"@embedpdf/models": "1.4.1"
|
|
33
38
|
},
|
|
34
39
|
"devDependencies": {
|
|
35
40
|
"@types/react": "^18.2.0",
|
|
36
41
|
"typescript": "^5.0.0",
|
|
37
|
-
"@embedpdf/
|
|
38
|
-
"@embedpdf/
|
|
42
|
+
"@embedpdf/core": "1.4.1",
|
|
43
|
+
"@embedpdf/build": "1.1.0"
|
|
39
44
|
},
|
|
40
45
|
"peerDependencies": {
|
|
41
46
|
"preact": "^10.26.4",
|
|
42
47
|
"react": ">=16.8.0",
|
|
43
48
|
"react-dom": ">=16.8.0",
|
|
44
49
|
"vue": ">=3.2.0",
|
|
45
|
-
"
|
|
50
|
+
"svelte": ">=5 <6",
|
|
51
|
+
"@embedpdf/core": "1.4.1"
|
|
46
52
|
},
|
|
47
53
|
"files": [
|
|
48
54
|
"dist",
|
|
@@ -65,7 +71,8 @@
|
|
|
65
71
|
"build:react": "vite build --mode react",
|
|
66
72
|
"build:preact": "vite build --mode preact",
|
|
67
73
|
"build:vue": "vite build --mode vue",
|
|
68
|
-
"build": "
|
|
74
|
+
"build:svelte": "vite build --mode svelte",
|
|
75
|
+
"build": "pnpm run clean && concurrently -c auto -n base,react,preact,vue,svelte \"vite build --mode base\" \"vite build --mode react\" \"vite build --mode preact\" \"vite build --mode vue\" \"vite build --mode svelte\"",
|
|
69
76
|
"clean": "rimraf dist",
|
|
70
77
|
"lint": "eslint src --color",
|
|
71
78
|
"lint:fix": "eslint src --color --fix"
|