@embedpdf/plugin-render 1.0.8 → 1.0.10
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/preact/index.ts","../../src/preact/hooks/use-render.ts","../../src/preact/components/render-layer.tsx"],"sourcesContent":["export * from './hooks';\nexport * from './components';\n","import { useCapability, usePlugin } from '@embedpdf/core/preact';\nimport { RenderPlugin } from '@embedpdf/plugin-render';\n\nexport const useRenderPlugin = () => usePlugin<RenderPlugin>(RenderPlugin.id);\nexport const useRenderCapability = () => useCapability<RenderPlugin>(RenderPlugin.id);\n","/** @jsxImportSource preact */\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/preact/index.ts","../../src/preact/hooks/use-render.ts","../../src/preact/components/render-layer.tsx"],"sourcesContent":["export * from './hooks';\nexport * from './components';\n","import { useCapability, usePlugin } from '@embedpdf/core/preact';\nimport { RenderPlugin } from '@embedpdf/plugin-render';\n\nexport const useRenderPlugin = () => usePlugin<RenderPlugin>(RenderPlugin.id);\nexport const useRenderCapability = () => useCapability<RenderPlugin>(RenderPlugin.id);\n","/** @jsxImportSource preact */\nimport { Fragment, JSX } from 'preact';\nimport { useEffect, useRef, useState } from 'preact/hooks';\nimport { ignore, PdfErrorCode } from '@embedpdf/models';\n\nimport { useRenderCapability } from '../hooks/use-render';\n\ntype RenderLayoutProps = Omit<JSX.HTMLAttributes<HTMLImageElement>, 'style'> & {\n pageIndex: number;\n scaleFactor?: number;\n dpr?: number;\n style?: JSX.CSSProperties;\n};\n\nexport function RenderLayer({\n pageIndex,\n scaleFactor = 1,\n dpr = 1,\n style,\n ...props\n}: RenderLayoutProps) {\n const { provides: renderProvides } = useRenderCapability();\n const [imageUrl, setImageUrl] = useState<string | null>(null);\n const urlRef = useRef<string | null>(null);\n\n useEffect(() => {\n if (renderProvides) {\n const task = renderProvides.renderPage({ pageIndex, scaleFactor, dpr });\n task.wait((blob) => {\n const url = URL.createObjectURL(blob);\n setImageUrl(url);\n urlRef.current = url;\n }, ignore);\n\n return () => {\n if (urlRef.current) {\n URL.revokeObjectURL(urlRef.current);\n urlRef.current = null;\n } else {\n task.abort({\n code: PdfErrorCode.Cancelled,\n message: 'canceled render task',\n });\n }\n };\n }\n }, [pageIndex, scaleFactor, dpr, renderProvides]);\n\n const handleImageLoad = () => {\n if (urlRef.current) {\n URL.revokeObjectURL(urlRef.current);\n urlRef.current = null;\n }\n };\n\n return (\n <Fragment>\n {imageUrl && (\n <img\n src={imageUrl}\n onLoad={handleImageLoad}\n {...props}\n style={{\n width: '100%',\n height: '100%',\n ...(style || {}),\n }}\n />\n )}\n </Fragment>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,oBAAyC;AACzC,2BAA6B;AAEtB,IAAM,kBAAkB,UAAM,yBAAwB,kCAAa,EAAE;AACrE,IAAM,sBAAsB,UAAM,6BAA4B,kCAAa,EAAE;;;ACHpF,IAAAA,iBAA8B;AAC9B,mBAA4C;AAC5C,oBAAqC;AAuD7B;AA5CD,SAAS,YAAY;AAAA,EAC1B;AAAA,EACA,cAAc;AAAA,EACd,MAAM;AAAA,EACN;AAAA,EACA,GAAG;AACL,GAAsB;AACpB,QAAM,EAAE,UAAU,eAAe,IAAI,oBAAoB;AACzD,QAAM,CAAC,UAAU,WAAW,QAAI,uBAAwB,IAAI;AAC5D,QAAM,aAAS,qBAAsB,IAAI;AAEzC,8BAAU,MAAM;AACd,QAAI,gBAAgB;AAClB,YAAM,OAAO,eAAe,WAAW,EAAE,WAAW,aAAa,IAAI,CAAC;AACtE,WAAK,KAAK,CAAC,SAAS;AAClB,cAAM,MAAM,IAAI,gBAAgB,IAAI;AACpC,oBAAY,GAAG;AACf,eAAO,UAAU;AAAA,MACnB,GAAG,oBAAM;AAET,aAAO,MAAM;AACX,YAAI,OAAO,SAAS;AAClB,cAAI,gBAAgB,OAAO,OAAO;AAClC,iBAAO,UAAU;AAAA,QACnB,OAAO;AACL,eAAK,MAAM;AAAA,YACT,MAAM,2BAAa;AAAA,YACnB,SAAS;AAAA,UACX,CAAC;AAAA,QACH;AAAA,MACF;AAAA,IACF;AAAA,EACF,GAAG,CAAC,WAAW,aAAa,KAAK,cAAc,CAAC;AAEhD,QAAM,kBAAkB,MAAM;AAC5B,QAAI,OAAO,SAAS;AAClB,UAAI,gBAAgB,OAAO,OAAO;AAClC,aAAO,UAAU;AAAA,IACnB;AAAA,EACF;AAEA,SACE,4CAAC,2BACE,sBACC;AAAA,IAAC;AAAA;AAAA,MACC,KAAK;AAAA,MACL,QAAQ;AAAA,MACP,GAAG;AAAA,MACJ,OAAO;AAAA,QACL,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,GAAI,SAAS,CAAC;AAAA,MAChB;AAAA;AAAA,EACF,GAEJ;AAEJ;","names":["import_preact"]}
|
package/dist/preact/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/preact/hooks/use-render.ts","../../src/preact/components/render-layer.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/preact';\nimport { RenderPlugin } from '@embedpdf/plugin-render';\n\nexport const useRenderPlugin = () => usePlugin<RenderPlugin>(RenderPlugin.id);\nexport const useRenderCapability = () => useCapability<RenderPlugin>(RenderPlugin.id);\n","/** @jsxImportSource preact */\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/preact/hooks/use-render.ts","../../src/preact/components/render-layer.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/preact';\nimport { RenderPlugin } from '@embedpdf/plugin-render';\n\nexport const useRenderPlugin = () => usePlugin<RenderPlugin>(RenderPlugin.id);\nexport const useRenderCapability = () => useCapability<RenderPlugin>(RenderPlugin.id);\n","/** @jsxImportSource preact */\nimport { Fragment, JSX } from 'preact';\nimport { useEffect, useRef, useState } from 'preact/hooks';\nimport { ignore, PdfErrorCode } from '@embedpdf/models';\n\nimport { useRenderCapability } from '../hooks/use-render';\n\ntype RenderLayoutProps = Omit<JSX.HTMLAttributes<HTMLImageElement>, 'style'> & {\n pageIndex: number;\n scaleFactor?: number;\n dpr?: number;\n style?: JSX.CSSProperties;\n};\n\nexport function RenderLayer({\n pageIndex,\n scaleFactor = 1,\n dpr = 1,\n style,\n ...props\n}: RenderLayoutProps) {\n const { provides: renderProvides } = useRenderCapability();\n const [imageUrl, setImageUrl] = useState<string | null>(null);\n const urlRef = useRef<string | null>(null);\n\n useEffect(() => {\n if (renderProvides) {\n const task = renderProvides.renderPage({ pageIndex, scaleFactor, dpr });\n task.wait((blob) => {\n const url = URL.createObjectURL(blob);\n setImageUrl(url);\n urlRef.current = url;\n }, ignore);\n\n return () => {\n if (urlRef.current) {\n URL.revokeObjectURL(urlRef.current);\n urlRef.current = null;\n } else {\n task.abort({\n code: PdfErrorCode.Cancelled,\n message: 'canceled render task',\n });\n }\n };\n }\n }, [pageIndex, scaleFactor, dpr, renderProvides]);\n\n const handleImageLoad = () => {\n if (urlRef.current) {\n URL.revokeObjectURL(urlRef.current);\n urlRef.current = null;\n }\n };\n\n return (\n <Fragment>\n {imageUrl && (\n <img\n src={imageUrl}\n onLoad={handleImageLoad}\n {...props}\n style={{\n width: '100%',\n height: '100%',\n ...(style || {}),\n }}\n />\n )}\n </Fragment>\n );\n}\n"],"mappings":";AAAA,SAAS,eAAe,iBAAiB;AACzC,SAAS,oBAAoB;AAEtB,IAAM,kBAAkB,MAAM,UAAwB,aAAa,EAAE;AACrE,IAAM,sBAAsB,MAAM,cAA4B,aAAa,EAAE;;;ACHpF,SAAS,gBAAqB;AAC9B,SAAS,WAAW,QAAQ,gBAAgB;AAC5C,SAAS,QAAQ,oBAAoB;AAuD7B;AA5CD,SAAS,YAAY;AAAA,EAC1B;AAAA,EACA,cAAc;AAAA,EACd,MAAM;AAAA,EACN;AAAA,EACA,GAAG;AACL,GAAsB;AACpB,QAAM,EAAE,UAAU,eAAe,IAAI,oBAAoB;AACzD,QAAM,CAAC,UAAU,WAAW,IAAI,SAAwB,IAAI;AAC5D,QAAM,SAAS,OAAsB,IAAI;AAEzC,YAAU,MAAM;AACd,QAAI,gBAAgB;AAClB,YAAM,OAAO,eAAe,WAAW,EAAE,WAAW,aAAa,IAAI,CAAC;AACtE,WAAK,KAAK,CAAC,SAAS;AAClB,cAAM,MAAM,IAAI,gBAAgB,IAAI;AACpC,oBAAY,GAAG;AACf,eAAO,UAAU;AAAA,MACnB,GAAG,MAAM;AAET,aAAO,MAAM;AACX,YAAI,OAAO,SAAS;AAClB,cAAI,gBAAgB,OAAO,OAAO;AAClC,iBAAO,UAAU;AAAA,QACnB,OAAO;AACL,eAAK,MAAM;AAAA,YACT,MAAM,aAAa;AAAA,YACnB,SAAS;AAAA,UACX,CAAC;AAAA,QACH;AAAA,MACF;AAAA,IACF;AAAA,EACF,GAAG,CAAC,WAAW,aAAa,KAAK,cAAc,CAAC;AAEhD,QAAM,kBAAkB,MAAM;AAC5B,QAAI,OAAO,SAAS;AAClB,UAAI,gBAAgB,OAAO,OAAO;AAClC,aAAO,UAAU;AAAA,IACnB;AAAA,EACF;AAEA,SACE,oBAAC,YACE,sBACC;AAAA,IAAC;AAAA;AAAA,MACC,KAAK;AAAA,MACL,QAAQ;AAAA,MACP,GAAG;AAAA,MACJ,OAAO;AAAA,QACL,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,GAAI,SAAS,CAAC;AAAA,MAChB;AAAA;AAAA,EACF,GAEJ;AAEJ;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embedpdf/plugin-render",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -23,21 +23,21 @@
|
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@embedpdf/models": "1.0.
|
|
26
|
+
"@embedpdf/models": "1.0.10"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/react": "^18.2.0",
|
|
30
30
|
"tsup": "^8.0.0",
|
|
31
31
|
"typescript": "^5.0.0",
|
|
32
|
-
"@embedpdf/core": "1.0.
|
|
33
|
-
"@embedpdf/plugin-loader": "1.0.
|
|
32
|
+
"@embedpdf/core": "1.0.10",
|
|
33
|
+
"@embedpdf/plugin-loader": "1.0.10"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"react": ">=16.8.0",
|
|
37
37
|
"react-dom": ">=16.8.0",
|
|
38
38
|
"preact": "^10.26.4",
|
|
39
|
-
"@embedpdf/core": "1.0.
|
|
40
|
-
"@embedpdf/plugin-loader": "1.0.
|
|
39
|
+
"@embedpdf/core": "1.0.10",
|
|
40
|
+
"@embedpdf/plugin-loader": "1.0.10"
|
|
41
41
|
},
|
|
42
42
|
"files": [
|
|
43
43
|
"dist",
|