@embedpdf/plugin-tiling 1.3.10 → 1.3.12
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/vue/index.cjs +1 -1
- package/dist/vue/index.cjs.map +1 -1
- package/dist/vue/index.js +22 -3
- package/dist/vue/index.js.map +1 -1
- package/package.json +10 -10
package/dist/vue/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),l=require("@embedpdf/models"),t=require("@embedpdf/core/vue"),n=require("@embedpdf/plugin-tiling"),r=()=>t.useCapability(n.TilingPlugin.id),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),l=require("@embedpdf/models"),t=require("@embedpdf/core/vue"),n=require("@embedpdf/plugin-tiling"),i=()=>t.usePlugin(n.TilingPlugin.id),r=()=>t.useCapability(n.TilingPlugin.id),o=["src"],a=e.defineComponent({__name:"tile-img",props:{pageIndex:{},tile:{},scale:{},dpr:{default:()=>window.devicePixelRatio},style:{type:[Boolean,null,String,Object,Array]}},setup(t){const n=t,{provides:a}=r(),{plugin:u}=i(),c=e.ref(),s=e.ref(0);let p=null,d=null;function g(){p&&(URL.revokeObjectURL(p),p=null)}function m(){d&&!p&&d.abort({code:l.PdfErrorCode.Cancelled,message:"canceled tile render"})}e.watchEffect((e=>{if(!u.value)return;e(u.value.onRefreshPages((e=>{e.includes(n.pageIndex)&&s.value++})))})),e.watch((()=>[n.pageIndex,n.tile.id,s.value,!!a.value]),(function(){if("ready"===n.tile.status&&p)return;if(!a.value)return;m(),g();const t=a.value.renderTile({pageIndex:n.pageIndex,tile:e.toRaw(n.tile),dpr:n.dpr});d=t,t.wait((e=>{p=URL.createObjectURL(e),c.value=p,d=null}),l.ignore)}),{immediate:!0}),e.onBeforeUnmount((()=>{m(),g()}));const f=e.computed((()=>n.scale/n.tile.srcScale));return(l,t)=>c.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:c.value,style:e.normalizeStyle([{position:"absolute",left:l.tile.screenRect.origin.x*f.value+"px",top:l.tile.screenRect.origin.y*f.value+"px",width:l.tile.screenRect.size.width*f.value+"px",height:l.tile.screenRect.size.height*f.value+"px",display:"block"},n.style]),onLoad:g},null,44,o)):e.createCommentVNode("",!0)}}),u=e.defineComponent({__name:"tiling-layer",props:{pageIndex:{},scale:{},style:{type:[Boolean,null,String,Object,Array]}},setup(l){const t=l,n=e.ref([]),{provides:i}=r();let o;return e.onMounted((()=>{i.value&&(o=i.value.onTileRendering((e=>{n.value=e[t.pageIndex]??[]})))})),e.onBeforeUnmount((()=>{null==o||o()})),(l,t)=>(e.openBlock(),e.createElementBlock("div",e.mergeProps({style:l.style},l.$attrs),[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.value,(t=>(e.openBlock(),e.createBlock(a,{key:t.id,pageIndex:l.pageIndex,tile:t,scale:l.scale},null,8,["pageIndex","tile","scale"])))),128))],16))}});exports.TileImg=a,exports.TilingLayer=u,exports.useTilingCapability=r,exports.useTilingPlugin=i,Object.keys(n).forEach((e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>n[e]})}));
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/vue/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/vue/hooks/use-tiling.ts","../../src/vue/components/tile-img.vue","../../src/vue/components/tiling-layer.vue"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/vue';\nimport { TilingPlugin } from '@embedpdf/plugin-tiling';\n\n/** Get the plugin instance itself (e.g. to read config) */\nexport const useTilingPlugin = () => usePlugin<TilingPlugin>(TilingPlugin.id);\n/** Get the *capability* the plugin exposes (renderTile, onTileRendering) */\nexport const useTilingCapability = () => useCapability<TilingPlugin>(TilingPlugin.id);\n","<script setup lang=\"ts\">\nimport { ref, onMounted, onBeforeUnmount, toRaw, computed } from 'vue';\nimport { ignore, PdfErrorCode, PdfErrorReason, Task } from '@embedpdf/models';\nimport type { StyleValue } from 'vue';\n\nimport type { Tile } from '@embedpdf/plugin-tiling';\nimport { useTilingCapability } from '../hooks';\n\ninterface Props {\n pageIndex: number;\n tile: Tile;\n scale: number;\n dpr?: number;\n style?: StyleValue;\n}\n\nconst props = withDefaults(defineProps<Props>(), {\n dpr: () => window.devicePixelRatio,\n});\n\nconst { provides: tilingCapability } = useTilingCapability();\n\nconst url = ref<string>();\nlet blobUrl: string | null = null;\nlet renderTask: Task<Blob, PdfErrorReason> | null = null;\n\n/* -------------------------------------------------- */\n/* Helper functions */\n/* -------------------------------------------------- */\nfunction revoke() {\n if (blobUrl) {\n URL.revokeObjectURL(blobUrl);\n blobUrl = null;\n }\n}\n\nfunction abortCurrentTask() {\n if (renderTask && !blobUrl) {\n renderTask.abort({\n code: PdfErrorCode.Cancelled,\n message: 'canceled tile render',\n });\n }\n}\n\n/* -------------------------------------------------- */\n/* start
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/vue/hooks/use-tiling.ts","../../src/vue/components/tile-img.vue","../../src/vue/components/tiling-layer.vue"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/vue';\nimport { TilingPlugin } from '@embedpdf/plugin-tiling';\n\n/** Get the plugin instance itself (e.g. to read config) */\nexport const useTilingPlugin = () => usePlugin<TilingPlugin>(TilingPlugin.id);\n/** Get the *capability* the plugin exposes (renderTile, onTileRendering) */\nexport const useTilingCapability = () => useCapability<TilingPlugin>(TilingPlugin.id);\n","<script setup lang=\"ts\">\nimport { ref, onMounted, onBeforeUnmount, toRaw, computed, watchEffect, watch } from 'vue';\nimport { ignore, PdfErrorCode, PdfErrorReason, Task } from '@embedpdf/models';\nimport type { StyleValue } from 'vue';\n\nimport type { Tile } from '@embedpdf/plugin-tiling';\nimport { useTilingCapability, useTilingPlugin } from '../hooks';\n\ninterface Props {\n pageIndex: number;\n tile: Tile;\n scale: number;\n dpr?: number;\n style?: StyleValue;\n}\n\nconst props = withDefaults(defineProps<Props>(), {\n dpr: () => window.devicePixelRatio,\n});\n\nconst { provides: tilingCapability } = useTilingCapability();\nconst { plugin: tilingPlugin } = useTilingPlugin();\n\nconst url = ref<string>();\nconst refreshTick = ref(0);\nlet blobUrl: string | null = null;\nlet renderTask: Task<Blob, PdfErrorReason> | null = null;\n\n/* -------------------------------------------------- */\n/* Helper functions */\n/* -------------------------------------------------- */\nfunction revoke() {\n if (blobUrl) {\n URL.revokeObjectURL(blobUrl);\n blobUrl = null;\n }\n}\n\nfunction abortCurrentTask() {\n if (renderTask && !blobUrl) {\n renderTask.abort({\n code: PdfErrorCode.Cancelled,\n message: 'canceled tile render',\n });\n }\n}\n\n/* -------------------------------------------------- */\n/* Watch for external refresh events */\n/* -------------------------------------------------- */\nwatchEffect((onCleanup) => {\n if (!tilingPlugin.value) return;\n const unsubscribe = tilingPlugin.value.onRefreshPages((pages) => {\n if (pages.includes(props.pageIndex)) {\n refreshTick.value++;\n }\n });\n onCleanup(unsubscribe);\n});\n\n/* -------------------------------------------------- */\n/* start render task when dependencies change */\n/* -------------------------------------------------- */\nfunction startRender() {\n if (props.tile.status === 'ready' && blobUrl) return; // already done\n if (!tilingCapability.value) return;\n\n abortCurrentTask();\n revoke();\n\n const task = tilingCapability.value.renderTile({\n pageIndex: props.pageIndex,\n tile: toRaw(props.tile),\n dpr: props.dpr,\n });\n\n renderTask = task;\n task.wait((blob) => {\n blobUrl = URL.createObjectURL(blob);\n url.value = blobUrl;\n renderTask = null; // Task completed\n }, ignore);\n}\n\n// Watch for changes that require a re-render\nwatch(\n () => [props.pageIndex, props.tile.id, refreshTick.value, !!tilingCapability.value],\n startRender,\n { immediate: true },\n);\n\n/* -------------------------------------------------- */\n/* cleanup */\n/* -------------------------------------------------- */\nonBeforeUnmount(() => {\n abortCurrentTask();\n revoke();\n});\n\n/* -------------------------------------------------- */\n/* helpers */\n/* -------------------------------------------------- */\nconst relScale = computed(() => props.scale / props.tile.srcScale);\n</script>\n\n<template>\n <img\n v-if=\"url\"\n :src=\"url\"\n :style=\"[\n {\n position: 'absolute',\n left: tile.screenRect.origin.x * relScale + 'px',\n top: tile.screenRect.origin.y * relScale + 'px',\n width: tile.screenRect.size.width * relScale + 'px',\n height: tile.screenRect.size.height * relScale + 'px',\n display: 'block',\n },\n props.style,\n ]\"\n @load=\"revoke\"\n />\n</template>\n","<script setup lang=\"ts\">\nimport type { Tile } from '@embedpdf/plugin-tiling';\nimport { ref, onMounted, onBeforeUnmount } from 'vue';\nimport type { StyleValue } from 'vue';\n\nimport { useTilingCapability } from '../hooks';\nimport TileImg from './tile-img.vue';\n\ninterface Props {\n pageIndex: number;\n scale: number;\n style?: StyleValue;\n}\n\nconst props = defineProps<Props>();\n\nconst tiles = ref<Tile[]>([]);\nconst { provides: tilingProvides } = useTilingCapability();\n\nlet unsubscribe: (() => void) | undefined;\n\nonMounted(() => {\n if (tilingProvides.value) {\n unsubscribe = tilingProvides.value.onTileRendering((tilesMap) => {\n tiles.value = tilesMap[props.pageIndex] ?? [];\n });\n }\n});\n\nonBeforeUnmount(() => {\n unsubscribe?.();\n});\n</script>\n\n<template>\n <div :style=\"style\" v-bind=\"$attrs\">\n <TileImg\n v-for=\"tile in tiles\"\n :key=\"tile.id\"\n :pageIndex=\"pageIndex\"\n :tile=\"tile\"\n :scale=\"scale\"\n />\n </div>\n</template>\n"],"names":["useTilingPlugin","usePlugin","TilingPlugin","id","useTilingCapability","useCapability","props","__props","provides","tilingCapability","plugin","tilingPlugin","url","ref","refreshTick","blobUrl","renderTask","revoke","URL","revokeObjectURL","abortCurrentTask","abort","code","PdfErrorCode","Cancelled","message","vue$1","watchEffect","onCleanup","value","onRefreshPages","pages","includes","pageIndex","watch","tile","status","task","renderTile","toRaw","dpr","wait","blob","createObjectURL","ignore","immediate","onBeforeUnmount","relScale","computed","scale","srcScale","_createElementBlock","src","style","_normalizeStyle","screenRect","origin","x","y","size","width","height","onLoad","tiles","tilingProvides","unsubscribe","onMounted","onTileRendering","tilesMap","_openBlock","_mergeProps","$attrs","_Fragment","Fragment","_renderList","_createBlock","createBlock","TileImg","key"],"mappings":"0MAIaA,EAAkB,IAAMC,YAAwBC,EAAAA,aAAaC,IAE7DC,EAAsB,IAAMC,gBAA4BH,EAAAA,aAAaC,8LCUlF,MAAMG,EAAQC,GAINC,SAAUC,GAAqBL,KAC/BM,OAAQC,GAAiBX,IAE3BY,EAAMC,EAAAA,MACNC,EAAcD,MAAI,GACxB,IAAIE,EAAyB,KACzBC,EAAgD,KAKpD,SAASC,IACHF,IACFG,IAAIC,gBAAgBJ,GACVA,EAAA,KACZ,CAGF,SAASK,IACHJ,IAAeD,GACjBC,EAAWK,MAAM,CACfC,KAAMC,EAAaA,aAAAC,UACnBC,QAAS,wBAEb,CAMFC,EAAAC,aAAaC,IACP,IAACjB,EAAakB,MAAO,OAMzBD,EALoBjB,EAAakB,MAAMC,gBAAgBC,IACjDA,EAAMC,SAAS1B,EAAM2B,YACXnB,EAAAe,OAAA,IAGK,IA4BvBH,EAAAQ,OACE,IAAM,CAAC5B,EAAM2B,UAAW3B,EAAM6B,KAAKhC,GAAIW,EAAYe,QAASpB,EAAiBoB,SAvB/E,WACE,GAA0B,UAAtBvB,EAAM6B,KAAKC,QAAsBrB,EAAS,OAC1C,IAACN,EAAiBoB,MAAO,OAEZT,IACVH,IAED,MAAAoB,EAAO5B,EAAiBoB,MAAMS,WAAW,CAC7CL,UAAW3B,EAAM2B,UACjBE,KAAMI,EAAAA,MAAMjC,EAAM6B,MAClBK,IAAKlC,EAAMkC,MAGAxB,EAAAqB,EACRA,EAAAI,MAAMC,IACC3B,EAAAG,IAAIyB,gBAAgBD,GAC9B9B,EAAIiB,MAAQd,EACCC,EAAA,IAAA,GACZ4B,SAAM,GAOT,CAAEC,WAAW,IAMfC,EAAAA,iBAAgB,KACG1B,IACVH,GAAA,IAMH,MAAA8B,EAAWC,EAAAA,UAAS,IAAM1C,EAAM2C,MAAQ3C,EAAM6B,KAAKe,wBAK/CtC,EAAGiB,qBADXsB,EAAAA,mBAeE,MAAA,OAbCC,IAAKxC,EAAGiB,MACRwB,MAAKC,EAAAA,eAAA,sBAAwDnB,KAAAA,EAAAA,KAAKoB,WAAWC,OAAOC,EAAIV,EAAQlB,MAAA,KAAsBM,IAAAA,EAAAA,KAAKoB,WAAWC,OAAOE,EAAIX,EAAQlB,MAAA,KAAwBM,MAAAA,EAAAA,KAAKoB,WAAWI,KAAKC,MAAQb,EAAQlB,MAAA,KAAyBM,OAAAA,EAAAA,KAAKoB,WAAWI,KAAKE,OAASd,EAAQlB,MAAA,sBAAkDvB,EAAM+C,QAW7US,OAAM7C,gLC1GX,MAAMX,EAAQC,EAERwD,EAAQlD,EAAYA,IAAA,KAClBL,SAAUwD,GAAmB5D,IAEjC,IAAA6D,SAEJC,EAAAA,WAAU,KACJF,EAAenC,QACjBoC,EAAcD,EAAenC,MAAMsC,iBAAiBC,IAClDL,EAAMlC,MAAQuC,EAAS9D,EAAM2B,YAAc,EAAC,IAC7C,IAILa,EAAAA,iBAAgB,KACA,MAAAmB,GAAAA,GAAA,YAKdI,cAAAlB,qBAQM,MARNmB,EAAAA,WAQM,CARAjB,MAAOA,EAAAA,OAAekB,EAAMA,QAAA,kBAChCpB,EAAAA,mBAMEqB,EAAAC,SAAA,KAAAC,EAAAA,WALeX,EAAKlC,OAAbM,kBADTwC,EAAAC,YAMEC,EAAA,CAJCC,IAAK3C,EAAKhC,GACV8B,UAAWA,EAASA,UACpBE,OACAc,MAAOA,EAAKA"}
|
package/dist/vue/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent, ref,
|
|
1
|
+
import { defineComponent, ref, watchEffect, watch, onBeforeUnmount, computed, createElementBlock, createCommentVNode, openBlock, normalizeStyle, toRaw, onMounted, mergeProps, Fragment, renderList, createBlock } from "vue";
|
|
2
2
|
import { ignore, PdfErrorCode } from "@embedpdf/models";
|
|
3
3
|
import { useCapability, usePlugin } from "@embedpdf/core/vue";
|
|
4
4
|
import { TilingPlugin } from "@embedpdf/plugin-tiling";
|
|
@@ -18,7 +18,9 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
18
18
|
setup(__props) {
|
|
19
19
|
const props = __props;
|
|
20
20
|
const { provides: tilingCapability } = useTilingCapability();
|
|
21
|
+
const { plugin: tilingPlugin } = useTilingPlugin();
|
|
21
22
|
const url = ref();
|
|
23
|
+
const refreshTick = ref(0);
|
|
22
24
|
let blobUrl = null;
|
|
23
25
|
let renderTask = null;
|
|
24
26
|
function revoke() {
|
|
@@ -35,8 +37,20 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
35
37
|
});
|
|
36
38
|
}
|
|
37
39
|
}
|
|
38
|
-
|
|
40
|
+
watchEffect((onCleanup) => {
|
|
41
|
+
if (!tilingPlugin.value) return;
|
|
42
|
+
const unsubscribe = tilingPlugin.value.onRefreshPages((pages) => {
|
|
43
|
+
if (pages.includes(props.pageIndex)) {
|
|
44
|
+
refreshTick.value++;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
onCleanup(unsubscribe);
|
|
48
|
+
});
|
|
49
|
+
function startRender() {
|
|
50
|
+
if (props.tile.status === "ready" && blobUrl) return;
|
|
39
51
|
if (!tilingCapability.value) return;
|
|
52
|
+
abortCurrentTask();
|
|
53
|
+
revoke();
|
|
40
54
|
const task = tilingCapability.value.renderTile({
|
|
41
55
|
pageIndex: props.pageIndex,
|
|
42
56
|
tile: toRaw(props.tile),
|
|
@@ -48,7 +62,12 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
48
62
|
url.value = blobUrl;
|
|
49
63
|
renderTask = null;
|
|
50
64
|
}, ignore);
|
|
51
|
-
}
|
|
65
|
+
}
|
|
66
|
+
watch(
|
|
67
|
+
() => [props.pageIndex, props.tile.id, refreshTick.value, !!tilingCapability.value],
|
|
68
|
+
startRender,
|
|
69
|
+
{ immediate: true }
|
|
70
|
+
);
|
|
52
71
|
onBeforeUnmount(() => {
|
|
53
72
|
abortCurrentTask();
|
|
54
73
|
revoke();
|
package/dist/vue/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/vue/hooks/use-tiling.ts","../../src/vue/components/tile-img.vue","../../src/vue/components/tiling-layer.vue"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/vue';\nimport { TilingPlugin } from '@embedpdf/plugin-tiling';\n\n/** Get the plugin instance itself (e.g. to read config) */\nexport const useTilingPlugin = () => usePlugin<TilingPlugin>(TilingPlugin.id);\n/** Get the *capability* the plugin exposes (renderTile, onTileRendering) */\nexport const useTilingCapability = () => useCapability<TilingPlugin>(TilingPlugin.id);\n","<script setup lang=\"ts\">\nimport { ref, onMounted, onBeforeUnmount, toRaw, computed } from 'vue';\nimport { ignore, PdfErrorCode, PdfErrorReason, Task } from '@embedpdf/models';\nimport type { StyleValue } from 'vue';\n\nimport type { Tile } from '@embedpdf/plugin-tiling';\nimport { useTilingCapability } from '../hooks';\n\ninterface Props {\n pageIndex: number;\n tile: Tile;\n scale: number;\n dpr?: number;\n style?: StyleValue;\n}\n\nconst props = withDefaults(defineProps<Props>(), {\n dpr: () => window.devicePixelRatio,\n});\n\nconst { provides: tilingCapability } = useTilingCapability();\n\nconst url = ref<string>();\nlet blobUrl: string | null = null;\nlet renderTask: Task<Blob, PdfErrorReason> | null = null;\n\n/* -------------------------------------------------- */\n/* Helper functions */\n/* -------------------------------------------------- */\nfunction revoke() {\n if (blobUrl) {\n URL.revokeObjectURL(blobUrl);\n blobUrl = null;\n }\n}\n\nfunction abortCurrentTask() {\n if (renderTask && !blobUrl) {\n renderTask.abort({\n code: PdfErrorCode.Cancelled,\n message: 'canceled tile render',\n });\n }\n}\n\n/* -------------------------------------------------- */\n/* start
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/vue/hooks/use-tiling.ts","../../src/vue/components/tile-img.vue","../../src/vue/components/tiling-layer.vue"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/vue';\nimport { TilingPlugin } from '@embedpdf/plugin-tiling';\n\n/** Get the plugin instance itself (e.g. to read config) */\nexport const useTilingPlugin = () => usePlugin<TilingPlugin>(TilingPlugin.id);\n/** Get the *capability* the plugin exposes (renderTile, onTileRendering) */\nexport const useTilingCapability = () => useCapability<TilingPlugin>(TilingPlugin.id);\n","<script setup lang=\"ts\">\nimport { ref, onMounted, onBeforeUnmount, toRaw, computed, watchEffect, watch } from 'vue';\nimport { ignore, PdfErrorCode, PdfErrorReason, Task } from '@embedpdf/models';\nimport type { StyleValue } from 'vue';\n\nimport type { Tile } from '@embedpdf/plugin-tiling';\nimport { useTilingCapability, useTilingPlugin } from '../hooks';\n\ninterface Props {\n pageIndex: number;\n tile: Tile;\n scale: number;\n dpr?: number;\n style?: StyleValue;\n}\n\nconst props = withDefaults(defineProps<Props>(), {\n dpr: () => window.devicePixelRatio,\n});\n\nconst { provides: tilingCapability } = useTilingCapability();\nconst { plugin: tilingPlugin } = useTilingPlugin();\n\nconst url = ref<string>();\nconst refreshTick = ref(0);\nlet blobUrl: string | null = null;\nlet renderTask: Task<Blob, PdfErrorReason> | null = null;\n\n/* -------------------------------------------------- */\n/* Helper functions */\n/* -------------------------------------------------- */\nfunction revoke() {\n if (blobUrl) {\n URL.revokeObjectURL(blobUrl);\n blobUrl = null;\n }\n}\n\nfunction abortCurrentTask() {\n if (renderTask && !blobUrl) {\n renderTask.abort({\n code: PdfErrorCode.Cancelled,\n message: 'canceled tile render',\n });\n }\n}\n\n/* -------------------------------------------------- */\n/* Watch for external refresh events */\n/* -------------------------------------------------- */\nwatchEffect((onCleanup) => {\n if (!tilingPlugin.value) return;\n const unsubscribe = tilingPlugin.value.onRefreshPages((pages) => {\n if (pages.includes(props.pageIndex)) {\n refreshTick.value++;\n }\n });\n onCleanup(unsubscribe);\n});\n\n/* -------------------------------------------------- */\n/* start render task when dependencies change */\n/* -------------------------------------------------- */\nfunction startRender() {\n if (props.tile.status === 'ready' && blobUrl) return; // already done\n if (!tilingCapability.value) return;\n\n abortCurrentTask();\n revoke();\n\n const task = tilingCapability.value.renderTile({\n pageIndex: props.pageIndex,\n tile: toRaw(props.tile),\n dpr: props.dpr,\n });\n\n renderTask = task;\n task.wait((blob) => {\n blobUrl = URL.createObjectURL(blob);\n url.value = blobUrl;\n renderTask = null; // Task completed\n }, ignore);\n}\n\n// Watch for changes that require a re-render\nwatch(\n () => [props.pageIndex, props.tile.id, refreshTick.value, !!tilingCapability.value],\n startRender,\n { immediate: true },\n);\n\n/* -------------------------------------------------- */\n/* cleanup */\n/* -------------------------------------------------- */\nonBeforeUnmount(() => {\n abortCurrentTask();\n revoke();\n});\n\n/* -------------------------------------------------- */\n/* helpers */\n/* -------------------------------------------------- */\nconst relScale = computed(() => props.scale / props.tile.srcScale);\n</script>\n\n<template>\n <img\n v-if=\"url\"\n :src=\"url\"\n :style=\"[\n {\n position: 'absolute',\n left: tile.screenRect.origin.x * relScale + 'px',\n top: tile.screenRect.origin.y * relScale + 'px',\n width: tile.screenRect.size.width * relScale + 'px',\n height: tile.screenRect.size.height * relScale + 'px',\n display: 'block',\n },\n props.style,\n ]\"\n @load=\"revoke\"\n />\n</template>\n","<script setup lang=\"ts\">\nimport type { Tile } from '@embedpdf/plugin-tiling';\nimport { ref, onMounted, onBeforeUnmount } from 'vue';\nimport type { StyleValue } from 'vue';\n\nimport { useTilingCapability } from '../hooks';\nimport TileImg from './tile-img.vue';\n\ninterface Props {\n pageIndex: number;\n scale: number;\n style?: StyleValue;\n}\n\nconst props = defineProps<Props>();\n\nconst tiles = ref<Tile[]>([]);\nconst { provides: tilingProvides } = useTilingCapability();\n\nlet unsubscribe: (() => void) | undefined;\n\nonMounted(() => {\n if (tilingProvides.value) {\n unsubscribe = tilingProvides.value.onTileRendering((tilesMap) => {\n tiles.value = tilesMap[props.pageIndex] ?? [];\n });\n }\n});\n\nonBeforeUnmount(() => {\n unsubscribe?.();\n});\n</script>\n\n<template>\n <div :style=\"style\" v-bind=\"$attrs\">\n <TileImg\n v-for=\"tile in tiles\"\n :key=\"tile.id\"\n :pageIndex=\"pageIndex\"\n :tile=\"tile\"\n :scale=\"scale\"\n />\n </div>\n</template>\n"],"names":["_createElementBlock","_normalizeStyle","tile","_openBlock","_mergeProps","style","$attrs","_Fragment","_renderList","_createBlock","TileImg","pageIndex","scale"],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embedpdf/plugin-tiling",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.12",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -29,26 +29,26 @@
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@embedpdf/models": "1.3.
|
|
32
|
+
"@embedpdf/models": "1.3.12"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/react": "^18.2.0",
|
|
36
36
|
"typescript": "^5.0.0",
|
|
37
|
+
"@embedpdf/plugin-render": "1.3.12",
|
|
38
|
+
"@embedpdf/plugin-scroll": "1.3.12",
|
|
39
|
+
"@embedpdf/core": "1.3.12",
|
|
37
40
|
"@embedpdf/build": "1.0.1",
|
|
38
|
-
"@embedpdf/
|
|
39
|
-
"@embedpdf/plugin-scroll": "1.3.10",
|
|
40
|
-
"@embedpdf/plugin-render": "1.3.10",
|
|
41
|
-
"@embedpdf/plugin-viewport": "1.3.10"
|
|
41
|
+
"@embedpdf/plugin-viewport": "1.3.12"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"react": ">=16.8.0",
|
|
45
45
|
"react-dom": ">=16.8.0",
|
|
46
46
|
"preact": "^10.26.4",
|
|
47
47
|
"vue": ">=3.2.0",
|
|
48
|
-
"@embedpdf/
|
|
49
|
-
"@embedpdf/plugin-
|
|
50
|
-
"@embedpdf/
|
|
51
|
-
"@embedpdf/plugin-
|
|
48
|
+
"@embedpdf/plugin-scroll": "1.3.12",
|
|
49
|
+
"@embedpdf/plugin-viewport": "1.3.12",
|
|
50
|
+
"@embedpdf/core": "1.3.12",
|
|
51
|
+
"@embedpdf/plugin-render": "1.3.12"
|
|
52
52
|
},
|
|
53
53
|
"files": [
|
|
54
54
|
"dist",
|