@embedpdf/plugin-rotate 1.4.0 → 1.5.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.
@@ -21,6 +21,6 @@ export declare const useRotateCapability: () => {
21
21
  * Hook that provides reactive rotation state and methods.
22
22
  */
23
23
  export declare const useRotate: () => {
24
- readonly rotation: Rotation;
25
- provides: Readonly<import('../../lib/index.ts').RotateCapability> | null;
24
+ readonly provides: Readonly<import('../../lib/index.ts').RotateCapability> | null;
25
+ rotation: Rotation;
26
26
  };
@@ -1,2 +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]})}));
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
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +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"}
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"}
@@ -6,27 +6,27 @@ import "svelte/internal/disclose-version";
6
6
  const useRotatePlugin = () => usePlugin(RotatePlugin.id);
7
7
  const useRotateCapability = () => useCapability(RotatePlugin.id);
8
8
  const useRotate = () => {
9
- const { provides } = useRotateCapability();
10
- let rotation = $.state(0);
9
+ const capability = useRotateCapability();
10
+ const state = $.proxy({
11
+ get provides() {
12
+ return capability.provides;
13
+ },
14
+ rotation: 0
15
+ });
11
16
  $.user_effect(() => {
12
- if (!provides) return;
13
- const unsubscribe = provides.onRotateChange((newRotation) => {
14
- $.set(rotation, newRotation, true);
17
+ if (!capability.provides) return;
18
+ const unsubscribe = capability.provides.onRotateChange((newRotation) => {
19
+ state.rotation = newRotation;
15
20
  });
16
21
  return unsubscribe;
17
22
  });
18
- return {
19
- get rotation() {
20
- return $.get(rotation);
21
- },
22
- provides
23
- };
23
+ return state;
24
24
  };
25
25
  var root = $.from_html(`<div><!></div>`);
26
26
  function Rotate($$anchor, $$props) {
27
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)");
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
30
  var div = root();
31
31
  let styles;
32
32
  var node = $.child(div);
@@ -1 +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;"}
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.4.0",
3
+ "version": "1.5.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.cjs",
@@ -34,13 +34,13 @@
34
34
  }
35
35
  },
36
36
  "dependencies": {
37
- "@embedpdf/models": "1.4.0"
37
+ "@embedpdf/models": "1.5.0"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/react": "^18.2.0",
41
41
  "typescript": "^5.0.0",
42
42
  "@embedpdf/build": "1.1.0",
43
- "@embedpdf/core": "1.4.0"
43
+ "@embedpdf/core": "1.5.0"
44
44
  },
45
45
  "peerDependencies": {
46
46
  "preact": "^10.26.4",
@@ -48,7 +48,7 @@
48
48
  "react-dom": ">=16.8.0",
49
49
  "vue": ">=3.2.0",
50
50
  "svelte": ">=5 <6",
51
- "@embedpdf/core": "1.4.0"
51
+ "@embedpdf/core": "1.5.0"
52
52
  },
53
53
  "files": [
54
54
  "dist",