@embedpdf/plugin-tiling 2.0.0-next.3 → 2.0.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/svelte/index.cjs.map +1 -1
- package/dist/svelte/index.js.map +1 -1
- package/package.json +10 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/svelte/hooks/use-tiling.ts","../../src/svelte/components/TileImg.svelte","../../src/svelte/components/TilingLayer.svelte"],"sourcesContent":["import { TilingPlugin } from '@embedpdf/plugin-tiling';\nimport { useCapability, usePlugin } from '@embedpdf/core/svelte';\n\nexport const useTilingPlugin = () => usePlugin<TilingPlugin>(TilingPlugin.id);\nexport const useTilingCapability = () => useCapability<TilingPlugin>(TilingPlugin.id);\n","<script lang=\"ts\">\n import type { Tile } from '@embedpdf/plugin-tiling';\n import { useTilingCapability } from '../hooks';\n import { ignore, PdfErrorCode } from '@embedpdf/models';\n import { untrack } from 'svelte';\n\n interface TileImgProps {\n documentId: string;\n pageIndex: number;\n tile: Tile;\n dpr: number;\n scale: number;\n }\n\n let { documentId, pageIndex, tile, dpr, scale }: TileImgProps = $props();\n const tilingCapability = useTilingCapability();\n\n // Derived scoped capability for the specific document\n const scope = $derived(tilingCapability.provides?.forDocument(documentId) ?? null);\n\n let url = $state<string>('');\n // urlRef is NOT reactive - similar to React's useRef\n let urlRef: string | null = null;\n\n // Capture these values once per tile change\n const tileId = $derived(tile.id);\n const tileSrcScale = $derived(tile.srcScale);\n const tileScreenRect = $derived(tile.screenRect);\n const relativeScale = $derived(scale / tileSrcScale);\n\n const createPlainTile = (t: Tile): Tile => ({\n ...t,\n pageRect: {\n origin: { x: t.pageRect.origin.x, y: t.pageRect.origin.y },\n size: { width: t.pageRect.size.width, height: t.pageRect.size.height },\n },\n screenRect: {\n origin: { x: t.screenRect.origin.x, y: t.screenRect.origin.y },\n size: { width: t.screenRect.size.width, height: t.screenRect.size.height },\n },\n });\n\n /* kick off render exactly once per tile */\n $effect(() => {\n // Track only tileId and pageIndex as dependencies (like React's [pageIndex, tile.id])\n const _tileId = tileId;\n const _pageIndex = pageIndex;\n\n // Check if we already have a URL for this tile (already rendered)\n if (urlRef) return;\n\n if (!scope) return;\n\n // Clone to avoid reactive proxies that Web Workers cannot clone\n const plainTile = untrack(() => createPlainTile(tile));\n const task = scope.renderTile({\n pageIndex: _pageIndex,\n tile: plainTile,\n dpr,\n });\n task.wait((blob) => {\n const objectUrl = URL.createObjectURL(blob);\n urlRef = objectUrl;\n url = objectUrl;\n }, ignore);\n\n return () => {\n if (urlRef) {\n URL.revokeObjectURL(urlRef);\n urlRef = null;\n } else {\n task.abort({\n code: PdfErrorCode.Cancelled,\n message: 'canceled render task',\n });\n }\n };\n });\n\n const handleImageLoad = () => {\n if (urlRef) {\n URL.revokeObjectURL(urlRef);\n urlRef = null;\n }\n };\n</script>\n\n{#if url}\n <img\n src={url}\n alt=\"\"\n onload={handleImageLoad}\n style:position=\"absolute\"\n style:left={`${tileScreenRect.origin.x * relativeScale}px`}\n style:top={`${tileScreenRect.origin.y * relativeScale}px`}\n style:width={`${tileScreenRect.size.width * relativeScale}px`}\n style:height={`${tileScreenRect.size.height * relativeScale}px`}\n style:display=\"block\"\n />\n{/if}\n","<script lang=\"ts\">\n import type { Tile } from '@embedpdf/plugin-tiling';\n import { useDocumentState } from '@embedpdf/core/svelte';\n import type { HTMLAttributes } from 'svelte/elements';\n import TileImg from './TileImg.svelte';\n import { useTilingCapability } from '../hooks';\n\n type TilingLayoutProps = HTMLAttributes<HTMLDivElement> & {\n documentId: string;\n pageIndex: number;\n scale?: number;\n class?: string;\n };\n\n let {\n documentId,\n pageIndex,\n scale: scaleOverride,\n class: propsClass,\n ...restProps\n }: TilingLayoutProps = $props();\n\n const tilingCapability = useTilingCapability();\n const documentState = useDocumentState(() => documentId);\n\n let tiles = $state<Tile[]>([]);\n\n const actualScale = $derived(\n scaleOverride !== undefined ? scaleOverride : (documentState.current?.scale ?? 1),\n );\n\n $effect(() => {\n if (!tilingCapability.provides) return;\n return tilingCapability.provides.onTileRendering((event) => {\n if (event.documentId === documentId) {\n tiles = event.tiles[pageIndex] ?? [];\n }\n });\n });\n</script>\n\n<div class={propsClass} {...restProps}>\n {#each tiles as tile (tile.id)}\n <TileImg {documentId} {pageIndex} {tile} dpr={window.devicePixelRatio} scale={actualScale} />\n {/each}\n</div>\n"],"names":["useTilingCapability","useCapability","TilingPlugin","id","tilingCapability","scope","_a","provides","forDocument","url","urlRef","tileId","tileSrcScale","srcScale","tileScreenRect","screenRect","relativeScale","
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/svelte/hooks/use-tiling.ts","../../src/svelte/components/TileImg.svelte","../../src/svelte/components/TilingLayer.svelte"],"sourcesContent":["import { TilingPlugin } from '@embedpdf/plugin-tiling';\nimport { useCapability, usePlugin } from '@embedpdf/core/svelte';\n\nexport const useTilingPlugin = () => usePlugin<TilingPlugin>(TilingPlugin.id);\nexport const useTilingCapability = () => useCapability<TilingPlugin>(TilingPlugin.id);\n","<script lang=\"ts\">\n import type { Tile } from '@embedpdf/plugin-tiling';\n import { useTilingCapability } from '../hooks';\n import { ignore, PdfErrorCode } from '@embedpdf/models';\n import { untrack } from 'svelte';\n\n interface TileImgProps {\n documentId: string;\n pageIndex: number;\n tile: Tile;\n dpr: number;\n scale: number;\n }\n\n let { documentId, pageIndex, tile, dpr, scale }: TileImgProps = $props();\n const tilingCapability = useTilingCapability();\n\n // Derived scoped capability for the specific document\n const scope = $derived(tilingCapability.provides?.forDocument(documentId) ?? null);\n\n let url = $state<string>('');\n // urlRef is NOT reactive - similar to React's useRef\n let urlRef: string | null = null;\n\n // Capture these values once per tile change\n const tileId = $derived(tile.id);\n const tileSrcScale = $derived(tile.srcScale);\n const tileScreenRect = $derived(tile.screenRect);\n const relativeScale = $derived(scale / tileSrcScale);\n\n const createPlainTile = (t: Tile): Tile => ({\n ...t,\n pageRect: {\n origin: { x: t.pageRect.origin.x, y: t.pageRect.origin.y },\n size: { width: t.pageRect.size.width, height: t.pageRect.size.height },\n },\n screenRect: {\n origin: { x: t.screenRect.origin.x, y: t.screenRect.origin.y },\n size: { width: t.screenRect.size.width, height: t.screenRect.size.height },\n },\n });\n\n /* kick off render exactly once per tile */\n $effect(() => {\n // Track only tileId and pageIndex as dependencies (like React's [pageIndex, tile.id])\n const _tileId = tileId;\n const _pageIndex = pageIndex;\n\n // Check if we already have a URL for this tile (already rendered)\n if (urlRef) return;\n\n if (!scope) return;\n\n // Clone to avoid reactive proxies that Web Workers cannot clone\n const plainTile = untrack(() => createPlainTile(tile));\n const task = scope.renderTile({\n pageIndex: _pageIndex,\n tile: plainTile,\n dpr,\n });\n task.wait((blob) => {\n const objectUrl = URL.createObjectURL(blob);\n urlRef = objectUrl;\n url = objectUrl;\n }, ignore);\n\n return () => {\n if (urlRef) {\n URL.revokeObjectURL(urlRef);\n urlRef = null;\n } else {\n task.abort({\n code: PdfErrorCode.Cancelled,\n message: 'canceled render task',\n });\n }\n };\n });\n\n const handleImageLoad = () => {\n if (urlRef) {\n URL.revokeObjectURL(urlRef);\n urlRef = null;\n }\n };\n</script>\n\n{#if url}\n <img\n src={url}\n alt=\"\"\n onload={handleImageLoad}\n style:position=\"absolute\"\n style:left={`${tileScreenRect.origin.x * relativeScale}px`}\n style:top={`${tileScreenRect.origin.y * relativeScale}px`}\n style:width={`${tileScreenRect.size.width * relativeScale}px`}\n style:height={`${tileScreenRect.size.height * relativeScale}px`}\n style:display=\"block\"\n />\n{/if}\n","<script lang=\"ts\">\n import type { Tile } from '@embedpdf/plugin-tiling';\n import { useDocumentState } from '@embedpdf/core/svelte';\n import type { HTMLAttributes } from 'svelte/elements';\n import TileImg from './TileImg.svelte';\n import { useTilingCapability } from '../hooks';\n\n type TilingLayoutProps = HTMLAttributes<HTMLDivElement> & {\n documentId: string;\n pageIndex: number;\n scale?: number;\n class?: string;\n };\n\n let {\n documentId,\n pageIndex,\n scale: scaleOverride,\n class: propsClass,\n ...restProps\n }: TilingLayoutProps = $props();\n\n const tilingCapability = useTilingCapability();\n const documentState = useDocumentState(() => documentId);\n\n let tiles = $state<Tile[]>([]);\n\n const actualScale = $derived(\n scaleOverride !== undefined ? scaleOverride : (documentState.current?.scale ?? 1),\n );\n\n $effect(() => {\n if (!tilingCapability.provides) return;\n return tilingCapability.provides.onTileRendering((event) => {\n if (event.documentId === documentId) {\n tiles = event.tiles[pageIndex] ?? [];\n }\n });\n });\n</script>\n\n<div class={propsClass} {...restProps}>\n {#each tiles as tile (tile.id)}\n <TileImg {documentId} {pageIndex} {tile} dpr={window.devicePixelRatio} scale={actualScale} />\n {/each}\n</div>\n"],"names":["useTilingCapability","useCapability","TilingPlugin","id","tilingCapability","scope","_a","provides","forDocument","url","$","state","urlRef","tileId","tileSrcScale","srcScale","tileScreenRect","screenRect","relativeScale","user_effect","_pageIndex","$$props","pageIndex","plainTile","untrack","createPlainTile","t","tile","pageRect","origin","x","y","size","width","height","task","get","renderTile","dpr","wait","blob","objectUrl","URL","createObjectURL","set","ignore","revokeObjectURL","abort","code","PdfErrorCode","Cancelled","message","handleImageLoad","img","root_1","set_attribute","styles","left","top","event","consequent","restProps","rest_props","documentState","useDocumentState","documentId","tiles","proxy","actualScale","derived","scale","current","onTileRendering","div","root","attribute_effect","$$anchor","TileImg","window","devicePixelRatio","usePlugin"],"mappings":"wjBAIaA,EAAsB,IAAMC,gBAA4BC,EAAAA,aAAaC,oECW1E,MAAAC,EAAmBJ,IAGnBK,uBAAiB,OAAA,OAAAC,EAAAF,EAAiBG,eAAjB,EAAAD,EAA2BE,4BAA2B,WAEzEC,EAAMC,EAAAC,MAAe,IAErBC,EAAwB,KAGtB,MAAAC,uBAAuBV,IACvBW,uBAA6BC,UAC7BC,uBAA+BC,YAC/BC,8BAAiCJ,IAevCJ,EAAAS,YAAO,WAEWN,SACVO,EAAUC,EAAAC,aAGZV,EAAM,iBAELP,GAAK,aAGJkB,EAAYC,EAAAA,QAAO,K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AAAzC,EAAA,4EAGP,MAAAjB,EAAmBJ,IACnB+D,EAAgBC,EAAAA,iBAAgB,IAAA3C,EAAA4C,YAElC,IAAAC,EAAQxD,EAAAC,MAAMD,EAAAyD,MAAA,WAEZC,EAAW1D,EAAA2D,QAAA,WAAA,YACG,IADHhD,EAAAiD,MACYjD,EAAAiD,OAAoB,OAAAhE,EAAAyD,EAAcQ,kBAASD,QAAS,IAGjF5D,EAAAS,YAAO,KACA,GAAAf,EAAiBG,SACf,OAAAH,EAAiBG,SAASiE,gBAAiBb,IAC5CA,EAAMM,aAAU5C,EAAA4C,kBAClBC,EAAQP,EAAMO,MAAK7C,EAAAC,YAAA,IAAA,WAM1BmD,EAAGC,IAAHhE,EAAAiE,iBAAAF,yBAA2BZ,YAA3BY,EAAG,GAAA,IAAA/D,EAAA0B,IACK8B,GAASvC,GAAMA,EAAKxB,GAAE,CAAAyE,EAAbjD,KACbkD,EAAOD,EAAA,mGAA2BjD,IAAWW,IAAAwC,OAAOC,0CAAyBX,gBAFjFK,cAAAA,UAFD,wDFpC+B,IAAMO,YAAwB9E,EAAAA,aAAaC"}
|
package/dist/svelte/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/svelte/hooks/use-tiling.ts","../../src/svelte/components/TileImg.svelte","../../src/svelte/components/TilingLayer.svelte"],"sourcesContent":["import { TilingPlugin } from '@embedpdf/plugin-tiling';\nimport { useCapability, usePlugin } from '@embedpdf/core/svelte';\n\nexport const useTilingPlugin = () => usePlugin<TilingPlugin>(TilingPlugin.id);\nexport const useTilingCapability = () => useCapability<TilingPlugin>(TilingPlugin.id);\n","<script lang=\"ts\">\n import type { Tile } from '@embedpdf/plugin-tiling';\n import { useTilingCapability } from '../hooks';\n import { ignore, PdfErrorCode } from '@embedpdf/models';\n import { untrack } from 'svelte';\n\n interface TileImgProps {\n documentId: string;\n pageIndex: number;\n tile: Tile;\n dpr: number;\n scale: number;\n }\n\n let { documentId, pageIndex, tile, dpr, scale }: TileImgProps = $props();\n const tilingCapability = useTilingCapability();\n\n // Derived scoped capability for the specific document\n const scope = $derived(tilingCapability.provides?.forDocument(documentId) ?? null);\n\n let url = $state<string>('');\n // urlRef is NOT reactive - similar to React's useRef\n let urlRef: string | null = null;\n\n // Capture these values once per tile change\n const tileId = $derived(tile.id);\n const tileSrcScale = $derived(tile.srcScale);\n const tileScreenRect = $derived(tile.screenRect);\n const relativeScale = $derived(scale / tileSrcScale);\n\n const createPlainTile = (t: Tile): Tile => ({\n ...t,\n pageRect: {\n origin: { x: t.pageRect.origin.x, y: t.pageRect.origin.y },\n size: { width: t.pageRect.size.width, height: t.pageRect.size.height },\n },\n screenRect: {\n origin: { x: t.screenRect.origin.x, y: t.screenRect.origin.y },\n size: { width: t.screenRect.size.width, height: t.screenRect.size.height },\n },\n });\n\n /* kick off render exactly once per tile */\n $effect(() => {\n // Track only tileId and pageIndex as dependencies (like React's [pageIndex, tile.id])\n const _tileId = tileId;\n const _pageIndex = pageIndex;\n\n // Check if we already have a URL for this tile (already rendered)\n if (urlRef) return;\n\n if (!scope) return;\n\n // Clone to avoid reactive proxies that Web Workers cannot clone\n const plainTile = untrack(() => createPlainTile(tile));\n const task = scope.renderTile({\n pageIndex: _pageIndex,\n tile: plainTile,\n dpr,\n });\n task.wait((blob) => {\n const objectUrl = URL.createObjectURL(blob);\n urlRef = objectUrl;\n url = objectUrl;\n }, ignore);\n\n return () => {\n if (urlRef) {\n URL.revokeObjectURL(urlRef);\n urlRef = null;\n } else {\n task.abort({\n code: PdfErrorCode.Cancelled,\n message: 'canceled render task',\n });\n }\n };\n });\n\n const handleImageLoad = () => {\n if (urlRef) {\n URL.revokeObjectURL(urlRef);\n urlRef = null;\n }\n };\n</script>\n\n{#if url}\n <img\n src={url}\n alt=\"\"\n onload={handleImageLoad}\n style:position=\"absolute\"\n style:left={`${tileScreenRect.origin.x * relativeScale}px`}\n style:top={`${tileScreenRect.origin.y * relativeScale}px`}\n style:width={`${tileScreenRect.size.width * relativeScale}px`}\n style:height={`${tileScreenRect.size.height * relativeScale}px`}\n style:display=\"block\"\n />\n{/if}\n","<script lang=\"ts\">\n import type { Tile } from '@embedpdf/plugin-tiling';\n import { useDocumentState } from '@embedpdf/core/svelte';\n import type { HTMLAttributes } from 'svelte/elements';\n import TileImg from './TileImg.svelte';\n import { useTilingCapability } from '../hooks';\n\n type TilingLayoutProps = HTMLAttributes<HTMLDivElement> & {\n documentId: string;\n pageIndex: number;\n scale?: number;\n class?: string;\n };\n\n let {\n documentId,\n pageIndex,\n scale: scaleOverride,\n class: propsClass,\n ...restProps\n }: TilingLayoutProps = $props();\n\n const tilingCapability = useTilingCapability();\n const documentState = useDocumentState(() => documentId);\n\n let tiles = $state<Tile[]>([]);\n\n const actualScale = $derived(\n scaleOverride !== undefined ? scaleOverride : (documentState.current?.scale ?? 1),\n );\n\n $effect(() => {\n if (!tilingCapability.provides) return;\n return tilingCapability.provides.onTileRendering((event) => {\n if (event.documentId === documentId) {\n tiles = event.tiles[pageIndex] ?? [];\n }\n });\n });\n</script>\n\n<div class={propsClass} {...restProps}>\n {#each tiles as tile (tile.id)}\n <TileImg {documentId} {pageIndex} {tile} dpr={window.devicePixelRatio} scale={actualScale} />\n {/each}\n</div>\n"],"names":[],"mappings":";;;;;;;AAGO,MAAM,kBAAkB,MAAM,UAAwB,aAAa,EAAE;AACrE,MAAM,sBAAsB,MAAM,cAA4B,aAAa,EAAE;;oCCJpF;;AAeQ,QAAA,mBAAmB,oBAAmB;AAGtC,QAAA;;AAAiB,mCAAiB,aAAjB,mBAA2B,oCAA2B;AAAA,GAAI;
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/svelte/hooks/use-tiling.ts","../../src/svelte/components/TileImg.svelte","../../src/svelte/components/TilingLayer.svelte"],"sourcesContent":["import { TilingPlugin } from '@embedpdf/plugin-tiling';\nimport { useCapability, usePlugin } from '@embedpdf/core/svelte';\n\nexport const useTilingPlugin = () => usePlugin<TilingPlugin>(TilingPlugin.id);\nexport const useTilingCapability = () => useCapability<TilingPlugin>(TilingPlugin.id);\n","<script lang=\"ts\">\n import type { Tile } from '@embedpdf/plugin-tiling';\n import { useTilingCapability } from '../hooks';\n import { ignore, PdfErrorCode } from '@embedpdf/models';\n import { untrack } from 'svelte';\n\n interface TileImgProps {\n documentId: string;\n pageIndex: number;\n tile: Tile;\n dpr: number;\n scale: number;\n }\n\n let { documentId, pageIndex, tile, dpr, scale }: TileImgProps = $props();\n const tilingCapability = useTilingCapability();\n\n // Derived scoped capability for the specific document\n const scope = $derived(tilingCapability.provides?.forDocument(documentId) ?? null);\n\n let url = $state<string>('');\n // urlRef is NOT reactive - similar to React's useRef\n let urlRef: string | null = null;\n\n // Capture these values once per tile change\n const tileId = $derived(tile.id);\n const tileSrcScale = $derived(tile.srcScale);\n const tileScreenRect = $derived(tile.screenRect);\n const relativeScale = $derived(scale / tileSrcScale);\n\n const createPlainTile = (t: Tile): Tile => ({\n ...t,\n pageRect: {\n origin: { x: t.pageRect.origin.x, y: t.pageRect.origin.y },\n size: { width: t.pageRect.size.width, height: t.pageRect.size.height },\n },\n screenRect: {\n origin: { x: t.screenRect.origin.x, y: t.screenRect.origin.y },\n size: { width: t.screenRect.size.width, height: t.screenRect.size.height },\n },\n });\n\n /* kick off render exactly once per tile */\n $effect(() => {\n // Track only tileId and pageIndex as dependencies (like React's [pageIndex, tile.id])\n const _tileId = tileId;\n const _pageIndex = pageIndex;\n\n // Check if we already have a URL for this tile (already rendered)\n if (urlRef) return;\n\n if (!scope) return;\n\n // Clone to avoid reactive proxies that Web Workers cannot clone\n const plainTile = untrack(() => createPlainTile(tile));\n const task = scope.renderTile({\n pageIndex: _pageIndex,\n tile: plainTile,\n dpr,\n });\n task.wait((blob) => {\n const objectUrl = URL.createObjectURL(blob);\n urlRef = objectUrl;\n url = objectUrl;\n }, ignore);\n\n return () => {\n if (urlRef) {\n URL.revokeObjectURL(urlRef);\n urlRef = null;\n } else {\n task.abort({\n code: PdfErrorCode.Cancelled,\n message: 'canceled render task',\n });\n }\n };\n });\n\n const handleImageLoad = () => {\n if (urlRef) {\n URL.revokeObjectURL(urlRef);\n urlRef = null;\n }\n };\n</script>\n\n{#if url}\n <img\n src={url}\n alt=\"\"\n onload={handleImageLoad}\n style:position=\"absolute\"\n style:left={`${tileScreenRect.origin.x * relativeScale}px`}\n style:top={`${tileScreenRect.origin.y * relativeScale}px`}\n style:width={`${tileScreenRect.size.width * relativeScale}px`}\n style:height={`${tileScreenRect.size.height * relativeScale}px`}\n style:display=\"block\"\n />\n{/if}\n","<script lang=\"ts\">\n import type { Tile } from '@embedpdf/plugin-tiling';\n import { useDocumentState } from '@embedpdf/core/svelte';\n import type { HTMLAttributes } from 'svelte/elements';\n import TileImg from './TileImg.svelte';\n import { useTilingCapability } from '../hooks';\n\n type TilingLayoutProps = HTMLAttributes<HTMLDivElement> & {\n documentId: string;\n pageIndex: number;\n scale?: number;\n class?: string;\n };\n\n let {\n documentId,\n pageIndex,\n scale: scaleOverride,\n class: propsClass,\n ...restProps\n }: TilingLayoutProps = $props();\n\n const tilingCapability = useTilingCapability();\n const documentState = useDocumentState(() => documentId);\n\n let tiles = $state<Tile[]>([]);\n\n const actualScale = $derived(\n scaleOverride !== undefined ? scaleOverride : (documentState.current?.scale ?? 1),\n );\n\n $effect(() => {\n if (!tilingCapability.provides) return;\n return tilingCapability.provides.onTileRendering((event) => {\n if (event.documentId === documentId) {\n tiles = event.tiles[pageIndex] ?? [];\n }\n });\n });\n</script>\n\n<div class={propsClass} {...restProps}>\n {#each tiles as tile (tile.id)}\n <TileImg {documentId} {pageIndex} {tile} dpr={window.devicePixelRatio} scale={actualScale} />\n {/each}\n</div>\n"],"names":["$$anchor"],"mappings":";;;;;;;AAGO,MAAM,kBAAkB,MAAM,UAAwB,aAAa,EAAE;AACrE,MAAM,sBAAsB,MAAM,cAA4B,aAAa,EAAE;;oCCJpF;;AAeQ,QAAA,mBAAmB,oBAAmB;AAGtC,QAAA;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K,GAAA,CAAI,SAAM,KAAK,IAAE,CAAAA,WAAb,SAAI;AACjB,YAAOA,WAAA;AAAA;;;;;;;qBAA2B,IAAI;AAAA;MAAO,KAAA,OAAO;AAAA;qBAAyB,WAAW;AAAA;;;UAF5F,GAAG;qBAAH,GAAG;;AAFJ;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embedpdf/plugin-tiling",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -35,16 +35,16 @@
|
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@embedpdf/models": "2.0.
|
|
38
|
+
"@embedpdf/models": "2.0.1"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/react": "^18.2.0",
|
|
42
42
|
"typescript": "^5.0.0",
|
|
43
|
-
"@embedpdf/core": "2.0.
|
|
43
|
+
"@embedpdf/core": "2.0.1",
|
|
44
44
|
"@embedpdf/build": "1.1.0",
|
|
45
|
-
"@embedpdf/plugin-render": "2.0.
|
|
46
|
-
"@embedpdf/plugin-
|
|
47
|
-
"@embedpdf/plugin-
|
|
45
|
+
"@embedpdf/plugin-render": "2.0.1",
|
|
46
|
+
"@embedpdf/plugin-scroll": "2.0.1",
|
|
47
|
+
"@embedpdf/plugin-viewport": "2.0.1"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"react": ">=16.8.0",
|
|
@@ -52,10 +52,10 @@
|
|
|
52
52
|
"preact": "^10.26.4",
|
|
53
53
|
"vue": ">=3.2.0",
|
|
54
54
|
"svelte": ">=5 <6",
|
|
55
|
-
"@embedpdf/core": "2.0.
|
|
56
|
-
"@embedpdf/plugin-
|
|
57
|
-
"@embedpdf/plugin-
|
|
58
|
-
"@embedpdf/plugin-viewport": "2.0.
|
|
55
|
+
"@embedpdf/core": "2.0.1",
|
|
56
|
+
"@embedpdf/plugin-render": "2.0.1",
|
|
57
|
+
"@embedpdf/plugin-scroll": "2.0.1",
|
|
58
|
+
"@embedpdf/plugin-viewport": "2.0.1"
|
|
59
59
|
},
|
|
60
60
|
"files": [
|
|
61
61
|
"dist",
|