@embedpdf/plugin-rotate 1.3.16 → 1.4.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.
@@ -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,3 @@
1
+ export * from './hooks';
2
+ export * from './components';
3
+ export * from '../index.ts';
@@ -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 rotation: Rotation;
25
+ provides: Readonly<import('../../lib/index.ts').RotateCapability> | null;
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{plugin:r}=n(),o=i.derived((()=>r?r.getMatrixAsString({w:t.pageSize.width,h:t.pageSize.height}):"matrix(1, 0, 0, 1, 0, 0)"));var s=a();let l;var u=i.child(s);i.snippet(u,(()=>t.children??i.noop)),i.reset(s),i.template_effect((e=>l=i.set_style(s,"",l,e)),[()=>({position:"absolute","transform-origin":"0 0",transform:i.get(o)})]),i.append(e,s),i.pop()},exports.useRotate=()=>{const{provides:e}=s();let t=i.state(0);return i.user_effect((()=>{if(!e)return;return e.onRotateChange((e=>{i.set(t,e,!0)}))})),{get rotation(){return i.get(t)},provides:e}},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 { provides } = useRotateCapability();\n let rotation = $state<Rotation>(0);\n\n $effect(() => {\n if (!provides) return;\n\n const unsubscribe = provides.onRotateChange((newRotation) => {\n rotation = newRotation;\n });\n\n return unsubscribe;\n });\n\n return {\n get rotation() {\n return rotation;\n },\n provides,\n };\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 { plugin: rotate } = useRotatePlugin();\n\n const transformMatrix = $derived(\n rotate\n ? rotate.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","plugin","rotate","transformMatrix","getMatrixAsString","w","width","h","$$props","pageSize","height","provides","rotation","$","user_effect","onRotateChange","newRotation","$__namespace","set"],"mappings":"sgBAOaA,EAAwB,IAAAC,YAAwBC,EAAAA,aAAaC,IAM7DC,EAA4B,IAAAC,gBAA4BH,EAAAA,aAAaC,wFCDxEG,OAAQC,GAAWP,IAErBQ,iBACJD,EACIA,EAAOE,kBACL,CAAAC,aAAYC,MACZC,EAACC,EAAAC,SAAWC,SAEd,kOAIqEP,4BAF7E,yBDHU,MAAAQ,SAAAA,GAAaZ,IACjB,IAAAa,UAA4B,UAEhCC,EAAAC,sBACOH,EAAU,OAMR,OAJaA,EAASI,gBAAgBC,IAChCC,EAAAC,IAAAN,EAAAI,GAAA,EAAA,GAGN,KAIH,YAAAJ,gBACKA,EACT,EACAD"}
@@ -0,0 +1,3 @@
1
+ export * from './hooks';
2
+ export * from './components';
3
+ export * from '../lib/index.ts';
@@ -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 { provides } = useRotateCapability();
10
+ let rotation = $.state(0);
11
+ $.user_effect(() => {
12
+ if (!provides) return;
13
+ const unsubscribe = provides.onRotateChange((newRotation) => {
14
+ $.set(rotation, newRotation, true);
15
+ });
16
+ return unsubscribe;
17
+ });
18
+ return {
19
+ get rotation() {
20
+ return $.get(rotation);
21
+ },
22
+ provides
23
+ };
24
+ };
25
+ var root = $.from_html(`<div><!></div>`);
26
+ function Rotate($$anchor, $$props) {
27
+ $.push($$props, true);
28
+ const { plugin: rotate } = useRotatePlugin();
29
+ const transformMatrix = $.derived(() => rotate ? rotate.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 { provides } = useRotateCapability();\n let rotation = $state<Rotation>(0);\n\n $effect(() => {\n if (!provides) return;\n\n const unsubscribe = provides.onRotateChange((newRotation) => {\n rotation = newRotation;\n });\n\n return unsubscribe;\n });\n\n return {\n get rotation() {\n return rotation;\n },\n provides,\n };\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 { plugin: rotate } = useRotatePlugin();\n\n const transformMatrix = $derived(\n rotate\n ? rotate.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;AACrB,QAAA,EAAA,aAAa,oBAAoB;AACrC,MAAA,mBAA4B,CAAC;AAEjC,IAAA,kBAAc;SACP,SAAU;AAET,UAAA,cAAc,SAAS,eAAgB,CAAA,gBAAgB;AAChD,QAAA,IAAA,UAAA,aAAA,IAAA;AAAA,KACZ;WAEM;AAAA,GACR;;IAGK,IAAA,WAAW;mBACN,QAAA;AAAA,IACT;AAAA,IACA;AAAA;AAEJ;;mCCtCA;;UAYU,QAAQ,OAAM,IAAK,gBAAe;AAEpC,QAAA,kCACJ,SACI,OAAO,kBACL,EAAA,oBAAY,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.16",
3
+ "version": "1.4.0",
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.3.16"
37
+ "@embedpdf/models": "1.4.0"
33
38
  },
34
39
  "devDependencies": {
35
40
  "@types/react": "^18.2.0",
36
41
  "typescript": "^5.0.0",
37
- "@embedpdf/build": "1.0.1",
38
- "@embedpdf/core": "1.3.16"
42
+ "@embedpdf/build": "1.1.0",
43
+ "@embedpdf/core": "1.4.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
- "@embedpdf/core": "1.3.16"
50
+ "svelte": ">=5 <6",
51
+ "@embedpdf/core": "1.4.0"
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": "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\"",
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"