@twintag/twintag-core 0.2.258 → 0.2.261
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/cjs/twintag-offline-support.cjs.entry.js +1 -1
- package/dist/cjs/twintag-pdf-viewer.cjs.entry.js +10 -23
- package/dist/collection/components/twintag-pdf-viewer/twintag-pdf-viewer.js +10 -23
- package/dist/collection/version.js +1 -1
- package/dist/components/twintag-offline-support.js +1 -1
- package/dist/components/twintag-pdf-viewer2.js +10 -23
- package/dist/esm/twintag-offline-support.entry.js +1 -1
- package/dist/esm/twintag-pdf-viewer.entry.js +10 -23
- package/dist/stencil-web-components/p-d03ce5dc.entry.js +1 -0
- package/dist/stencil-web-components/{p-53b62758.entry.js → p-ee86c730.entry.js} +1 -1
- package/dist/stencil-web-components/stencil-web-components.esm.js +1 -1
- package/dist/types/components/twintag-pdf-viewer/twintag-pdf-viewer.d.ts +1 -1
- package/dist/types/drone/src/libs/stencil-web-components/.stencil/libs/twintag-sdk/src/lib/version.d.ts +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
- package/twintag-sdk/src/lib/version.js +1 -1
- package/dist/stencil-web-components/p-618703ff.entry.js +0 -1
|
@@ -263,9 +263,7 @@ const TwintagPdfViewer = class {
|
|
|
263
263
|
return null;
|
|
264
264
|
const response = await fetch(url);
|
|
265
265
|
const blob = await response.blob();
|
|
266
|
-
const file_name = this.fileName
|
|
267
|
-
? this.fileName
|
|
268
|
-
: Math.random().toString(36).substring(6) + '_name.pdf';
|
|
266
|
+
const file_name = this.fileName ? this.fileName : Math.random().toString(36).substring(6) + '_name.pdf';
|
|
269
267
|
const file_object = new File([blob], file_name, {
|
|
270
268
|
type: 'application/pdf',
|
|
271
269
|
});
|
|
@@ -289,7 +287,7 @@ const TwintagPdfViewer = class {
|
|
|
289
287
|
this.handleFile(this.src, this.fileURL);
|
|
290
288
|
}
|
|
291
289
|
componentWillRender() {
|
|
292
|
-
worker.onmessage =
|
|
290
|
+
worker.onmessage = e => {
|
|
293
291
|
const { data } = e;
|
|
294
292
|
if (data.type) {
|
|
295
293
|
if (data.type === 'file_converted') {
|
|
@@ -305,11 +303,10 @@ const TwintagPdfViewer = class {
|
|
|
305
303
|
}
|
|
306
304
|
};
|
|
307
305
|
}
|
|
308
|
-
|
|
309
|
-
this.observer = new IntersectionObserver(
|
|
310
|
-
entries.forEach(
|
|
311
|
-
if (entry.isIntersecting &&
|
|
312
|
-
entry.target.classList.contains('twintag-pdf-observed-page')) {
|
|
306
|
+
componentDidRender() {
|
|
307
|
+
this.observer = new IntersectionObserver(entries => {
|
|
308
|
+
entries.forEach(entry => {
|
|
309
|
+
if (entry.isIntersecting && entry.target.classList.contains('twintag-pdf-observed-page')) {
|
|
313
310
|
const { idxLastRendered, pageCount } = pdfStore.state.docs.get(this.fileURL);
|
|
314
311
|
if (idxLastRendered < pageCount) {
|
|
315
312
|
worker.postMessage({
|
|
@@ -326,24 +323,14 @@ const TwintagPdfViewer = class {
|
|
|
326
323
|
return (index.h("div", null, index.h("svg", { color: "#ccc", width: "100%", height: "391", viewBox: "0 0 400 391", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, index.h("path", { d: "M82.4286 16H19.5714C17.599 16 16 19.0726 16 22.8627V79.1373C16 82.9274 17.599 86 19.5714 86H82.4286C84.401 86 86 82.9274 86 79.1373V22.8627C86 19.0726 84.401 16 82.4286 16Z", fill: "currentColor" }), index.h("path", { d: "M380.522 16H275.478C273.557 16 272 18.7982 272 22.25V24.75C272 28.2018 273.557 31 275.478 31H380.522C382.443 31 384 28.2018 384 24.75V22.25C384 18.7982 382.443 16 380.522 16Z", fill: "currentColor" }), index.h("path", { d: "M379.429 47H228.571C226.047 47 224 48.7909 224 51C224 53.2091 226.047 55 228.571 55H379.429C381.953 55 384 53.2091 384 51C384 48.7909 381.953 47 379.429 47Z", fill: "currentColor" }), index.h("path", { d: "M379.918 59H228.082C225.827 59 224 60.567 224 62.5C224 64.433 225.827 66 228.082 66H379.918C382.173 66 384 64.433 384 62.5C384 60.567 382.173 59 379.918 59Z", fill: "currentColor" }), index.h("path", { d: "M379.429 70H228.571C226.047 70 224 71.567 224 73.5C224 75.433 226.047 77 228.571 77H379.429C381.953 77 384 75.433 384 73.5C384 71.567 381.953 70 379.429 70Z", fill: "currentColor" }), index.h("path", { d: "M209 102H21C18.2386 102 16 104.612 16 107.833V110.167C16 113.388 18.2386 116 21 116H209C211.761 116 214 113.388 214 110.167V107.833C214 104.612 211.761 102 209 102Z", fill: "currentColor" }), index.h("path", { d: "M240.043 132H20.9567C18.2192 132 16 133.567 16 135.5C16 137.433 18.2192 139 20.9567 139H240.043C242.781 139 245 137.433 245 135.5C245 133.567 242.781 132 240.043 132Z", fill: "currentColor" }), index.h("path", { d: "M239.158 143H21.8418C18.6155 143 16 144.567 16 146.5C16 148.433 18.6155 150 21.8418 150H239.158C242.385 150 245 148.433 245 146.5C245 144.567 242.385 143 239.158 143Z", fill: "currentColor" }), index.h("path", { d: "M238.457 154H22.5429C18.9293 154 16 155.567 16 157.5C16 159.433 18.9293 161 22.5429 161H238.457C242.071 161 245 159.433 245 157.5C245 155.567 242.071 154 238.457 154Z", fill: "currentColor" }), index.h("path", { d: "M238.457 165H22.5429C18.9293 165 16 166.791 16 169C16 171.209 18.9293 173 22.5429 173H238.457C242.071 173 245 171.209 245 169C245 166.791 242.071 165 238.457 165Z", fill: "currentColor" }), index.h("path", { d: "M191 189H21C18.2386 189 16 190.343 16 192C16 193.657 18.2386 195 21 195H191C193.761 195 196 193.657 196 192C196 190.343 193.761 189 191 189Z", fill: "currentColor" }), index.h("path", { d: "M166 211H21C18.2386 211 16 213.736 16 217.111V226.889C16 230.264 18.2386 233 21 233H166C168.761 233 171 230.264 171 226.889V217.111C171 213.736 168.761 211 166 211Z", fill: "currentColor" }), index.h("path", { d: "M97 249H21C18.2386 249 16 250.119 16 251.5C16 252.881 18.2386 254 21 254H97C99.7614 254 102 252.881 102 251.5C102 250.119 99.7614 249 97 249Z", fill: "currentColor" }), index.h("path", { d: "M144 258H21C18.2386 258 16 259.343 16 261C16 262.657 18.2386 264 21 264H144C146.761 264 149 262.657 149 261C149 259.343 146.761 258 144 258Z", fill: "currentColor" }), index.h("path", { d: "M379 211.5H339C336.239 211.5 334 214.236 334 217.611V227.389C334 230.764 336.239 233.5 339 233.5H379C381.761 233.5 384 230.764 384 227.389V217.611C384 214.236 381.761 211.5 379 211.5Z", fill: "currentColor" }), index.h("path", { d: "M379 241.5H304C301.239 241.5 299 244.236 299 247.611V257.389C299 260.764 301.239 263.5 304 263.5H379C381.761 263.5 384 260.764 384 257.389V247.611C384 244.236 381.761 241.5 379 241.5Z", fill: "currentColor" }), index.h("path", { d: "M204 280H21C18.2386 280 16 282.718 16 286.071V290.929C16 294.282 18.2386 297 21 297H204C206.761 297 209 294.282 209 290.929V286.071C209 282.718 206.761 280 204 280Z", fill: "currentColor" }), index.h("path", { d: "M242 313H21C18.2386 313 16 314.567 16 316.5C16 318.433 18.2386 320 21 320H242C244.761 320 247 318.433 247 316.5C247 314.567 244.761 313 242 313Z", fill: "currentColor" }), index.h("path", { d: "M239.158 324H21.8418C18.6155 324 16 325.567 16 327.5C16 329.433 18.6155 331 21.8418 331H239.158C242.385 331 245 329.433 245 327.5C245 325.567 242.385 324 239.158 324Z", fill: "currentColor" }), index.h("path", { d: "M238.457 335H22.5429C18.9293 335 16 336.567 16 338.5C16 340.433 18.9293 342 22.5429 342H238.457C242.071 342 245 340.433 245 338.5C245 336.567 242.071 335 238.457 335Z", fill: "currentColor" }), index.h("path", { d: "M238.457 346H22.5429C18.9293 346 16 347.567 16 349.5C16 351.433 18.9293 353 22.5429 353H238.457C242.071 353 245 351.433 245 349.5C245 347.567 242.071 346 238.457 346Z", fill: "currentColor" }), index.h("path", { d: "M191 369H21C18.2386 369 16 370.343 16 372C16 373.657 18.2386 375 21 375H191C193.761 375 196 373.657 196 372C196 370.343 193.761 369 191 369Z", fill: "currentColor" }), index.h("path", { d: "M330 333H299C296.239 333 294 333.895 294 335C294 336.105 296.239 337 299 337H330C332.761 337 335 336.105 335 335C335 333.895 332.761 333 330 333Z", fill: "currentColor" }), index.h("path", { d: "M379 333H348C345.239 333 343 333.895 343 335C343 336.105 345.239 337 348 337H379C381.761 337 384 336.105 384 335C384 333.895 381.761 333 379 333Z", fill: "currentColor" }), index.h("path", { d: "M379 353H275C272.239 353 270 355.736 270 359.111V368.889C270 372.264 272.239 375 275 375H379C381.761 375 384 372.264 384 368.889V359.111C384 355.736 381.761 353 379 353Z", fill: "currentColor" }))));
|
|
327
324
|
}
|
|
328
325
|
render() {
|
|
329
|
-
return (index.h("div", { class: "twintag-pdf-viewer" }, pdfStore.state.docs.get(this.fileURL) ? (index.h("div", { class: "twintag-pdf-container" }, index.h("div", null), index.h("div", { class: "twintag-pdf-view" }, pdfStore.state.docs.get(this.fileURL).pages &&
|
|
330
|
-
pdfStore.state.docs.get(this.fileURL).pages.
|
|
331
|
-
|
|
332
|
-
.get(this.fileURL)
|
|
333
|
-
.pages.map((page, key) => (index.h("img", { key: key, src: page, alt: `Page ${key + 1}`, class: key ===
|
|
334
|
-
pdfStore.state.docs.get(this.fileURL)
|
|
335
|
-
.idxLastRendered -
|
|
336
|
-
1
|
|
337
|
-
? 'twintag-pdf-observed-page'
|
|
338
|
-
: '', style: { width: '100%' }, ref: (el) => {
|
|
339
|
-
if (el) {
|
|
326
|
+
return (index.h("div", { class: "twintag-pdf-viewer" }, pdfStore.state.docs.get(this.fileURL) ? (index.h("div", { class: "twintag-pdf-container" }, index.h("div", null), index.h("div", { class: "twintag-pdf-view" }, pdfStore.state.docs.get(this.fileURL).pages && pdfStore.state.docs.get(this.fileURL).pages.length > 0
|
|
327
|
+
? pdfStore.state.docs.get(this.fileURL).pages.map((page, key) => (index.h("img", { key: key, src: page, alt: `Page ${key + 1}`, class: key === pdfStore.state.docs.get(this.fileURL).idxLastRendered - 1 ? 'twintag-pdf-observed-page' : '', style: { width: '100%' }, ref: el => {
|
|
328
|
+
if (el && this.observer) {
|
|
340
329
|
this.observer.observe(el);
|
|
341
330
|
}
|
|
342
331
|
return el;
|
|
343
332
|
} })))
|
|
344
|
-
: null), pdfStore.state.docs.get(this.fileURL).pages &&
|
|
345
|
-
pdfStore.state.docs.get(this.fileURL).pages.length <
|
|
346
|
-
pdfStore.state.docs.get(this.fileURL).pageCount
|
|
333
|
+
: null), pdfStore.state.docs.get(this.fileURL).pages && pdfStore.state.docs.get(this.fileURL).pages.length < pdfStore.state.docs.get(this.fileURL).pageCount
|
|
347
334
|
? this.getPlaceholder()
|
|
348
335
|
: null)) : (this.getPlaceholder())));
|
|
349
336
|
}
|
|
@@ -16,9 +16,7 @@ export class TwintagPdfViewer {
|
|
|
16
16
|
return null;
|
|
17
17
|
const response = await fetch(url);
|
|
18
18
|
const blob = await response.blob();
|
|
19
|
-
const file_name = this.fileName
|
|
20
|
-
? this.fileName
|
|
21
|
-
: Math.random().toString(36).substring(6) + '_name.pdf';
|
|
19
|
+
const file_name = this.fileName ? this.fileName : Math.random().toString(36).substring(6) + '_name.pdf';
|
|
22
20
|
const file_object = new File([blob], file_name, {
|
|
23
21
|
type: 'application/pdf',
|
|
24
22
|
});
|
|
@@ -42,7 +40,7 @@ export class TwintagPdfViewer {
|
|
|
42
40
|
this.handleFile(this.src, this.fileURL);
|
|
43
41
|
}
|
|
44
42
|
componentWillRender() {
|
|
45
|
-
worker.onmessage =
|
|
43
|
+
worker.onmessage = e => {
|
|
46
44
|
const { data } = e;
|
|
47
45
|
if (data.type) {
|
|
48
46
|
if (data.type === 'file_converted') {
|
|
@@ -58,11 +56,10 @@ export class TwintagPdfViewer {
|
|
|
58
56
|
}
|
|
59
57
|
};
|
|
60
58
|
}
|
|
61
|
-
|
|
62
|
-
this.observer = new IntersectionObserver(
|
|
63
|
-
entries.forEach(
|
|
64
|
-
if (entry.isIntersecting &&
|
|
65
|
-
entry.target.classList.contains('twintag-pdf-observed-page')) {
|
|
59
|
+
componentDidRender() {
|
|
60
|
+
this.observer = new IntersectionObserver(entries => {
|
|
61
|
+
entries.forEach(entry => {
|
|
62
|
+
if (entry.isIntersecting && entry.target.classList.contains('twintag-pdf-observed-page')) {
|
|
66
63
|
const { idxLastRendered, pageCount } = pdfStore.state.docs.get(this.fileURL);
|
|
67
64
|
if (idxLastRendered < pageCount) {
|
|
68
65
|
worker.postMessage({
|
|
@@ -79,24 +76,14 @@ export class TwintagPdfViewer {
|
|
|
79
76
|
return (h("div", null, h("svg", { color: "#ccc", width: "100%", height: "391", viewBox: "0 0 400 391", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, h("path", { d: "M82.4286 16H19.5714C17.599 16 16 19.0726 16 22.8627V79.1373C16 82.9274 17.599 86 19.5714 86H82.4286C84.401 86 86 82.9274 86 79.1373V22.8627C86 19.0726 84.401 16 82.4286 16Z", fill: "currentColor" }), h("path", { d: "M380.522 16H275.478C273.557 16 272 18.7982 272 22.25V24.75C272 28.2018 273.557 31 275.478 31H380.522C382.443 31 384 28.2018 384 24.75V22.25C384 18.7982 382.443 16 380.522 16Z", fill: "currentColor" }), h("path", { d: "M379.429 47H228.571C226.047 47 224 48.7909 224 51C224 53.2091 226.047 55 228.571 55H379.429C381.953 55 384 53.2091 384 51C384 48.7909 381.953 47 379.429 47Z", fill: "currentColor" }), h("path", { d: "M379.918 59H228.082C225.827 59 224 60.567 224 62.5C224 64.433 225.827 66 228.082 66H379.918C382.173 66 384 64.433 384 62.5C384 60.567 382.173 59 379.918 59Z", fill: "currentColor" }), h("path", { d: "M379.429 70H228.571C226.047 70 224 71.567 224 73.5C224 75.433 226.047 77 228.571 77H379.429C381.953 77 384 75.433 384 73.5C384 71.567 381.953 70 379.429 70Z", fill: "currentColor" }), h("path", { d: "M209 102H21C18.2386 102 16 104.612 16 107.833V110.167C16 113.388 18.2386 116 21 116H209C211.761 116 214 113.388 214 110.167V107.833C214 104.612 211.761 102 209 102Z", fill: "currentColor" }), h("path", { d: "M240.043 132H20.9567C18.2192 132 16 133.567 16 135.5C16 137.433 18.2192 139 20.9567 139H240.043C242.781 139 245 137.433 245 135.5C245 133.567 242.781 132 240.043 132Z", fill: "currentColor" }), h("path", { d: "M239.158 143H21.8418C18.6155 143 16 144.567 16 146.5C16 148.433 18.6155 150 21.8418 150H239.158C242.385 150 245 148.433 245 146.5C245 144.567 242.385 143 239.158 143Z", fill: "currentColor" }), h("path", { d: "M238.457 154H22.5429C18.9293 154 16 155.567 16 157.5C16 159.433 18.9293 161 22.5429 161H238.457C242.071 161 245 159.433 245 157.5C245 155.567 242.071 154 238.457 154Z", fill: "currentColor" }), h("path", { d: "M238.457 165H22.5429C18.9293 165 16 166.791 16 169C16 171.209 18.9293 173 22.5429 173H238.457C242.071 173 245 171.209 245 169C245 166.791 242.071 165 238.457 165Z", fill: "currentColor" }), h("path", { d: "M191 189H21C18.2386 189 16 190.343 16 192C16 193.657 18.2386 195 21 195H191C193.761 195 196 193.657 196 192C196 190.343 193.761 189 191 189Z", fill: "currentColor" }), h("path", { d: "M166 211H21C18.2386 211 16 213.736 16 217.111V226.889C16 230.264 18.2386 233 21 233H166C168.761 233 171 230.264 171 226.889V217.111C171 213.736 168.761 211 166 211Z", fill: "currentColor" }), h("path", { d: "M97 249H21C18.2386 249 16 250.119 16 251.5C16 252.881 18.2386 254 21 254H97C99.7614 254 102 252.881 102 251.5C102 250.119 99.7614 249 97 249Z", fill: "currentColor" }), h("path", { d: "M144 258H21C18.2386 258 16 259.343 16 261C16 262.657 18.2386 264 21 264H144C146.761 264 149 262.657 149 261C149 259.343 146.761 258 144 258Z", fill: "currentColor" }), h("path", { d: "M379 211.5H339C336.239 211.5 334 214.236 334 217.611V227.389C334 230.764 336.239 233.5 339 233.5H379C381.761 233.5 384 230.764 384 227.389V217.611C384 214.236 381.761 211.5 379 211.5Z", fill: "currentColor" }), h("path", { d: "M379 241.5H304C301.239 241.5 299 244.236 299 247.611V257.389C299 260.764 301.239 263.5 304 263.5H379C381.761 263.5 384 260.764 384 257.389V247.611C384 244.236 381.761 241.5 379 241.5Z", fill: "currentColor" }), h("path", { d: "M204 280H21C18.2386 280 16 282.718 16 286.071V290.929C16 294.282 18.2386 297 21 297H204C206.761 297 209 294.282 209 290.929V286.071C209 282.718 206.761 280 204 280Z", fill: "currentColor" }), h("path", { d: "M242 313H21C18.2386 313 16 314.567 16 316.5C16 318.433 18.2386 320 21 320H242C244.761 320 247 318.433 247 316.5C247 314.567 244.761 313 242 313Z", fill: "currentColor" }), h("path", { d: "M239.158 324H21.8418C18.6155 324 16 325.567 16 327.5C16 329.433 18.6155 331 21.8418 331H239.158C242.385 331 245 329.433 245 327.5C245 325.567 242.385 324 239.158 324Z", fill: "currentColor" }), h("path", { d: "M238.457 335H22.5429C18.9293 335 16 336.567 16 338.5C16 340.433 18.9293 342 22.5429 342H238.457C242.071 342 245 340.433 245 338.5C245 336.567 242.071 335 238.457 335Z", fill: "currentColor" }), h("path", { d: "M238.457 346H22.5429C18.9293 346 16 347.567 16 349.5C16 351.433 18.9293 353 22.5429 353H238.457C242.071 353 245 351.433 245 349.5C245 347.567 242.071 346 238.457 346Z", fill: "currentColor" }), h("path", { d: "M191 369H21C18.2386 369 16 370.343 16 372C16 373.657 18.2386 375 21 375H191C193.761 375 196 373.657 196 372C196 370.343 193.761 369 191 369Z", fill: "currentColor" }), h("path", { d: "M330 333H299C296.239 333 294 333.895 294 335C294 336.105 296.239 337 299 337H330C332.761 337 335 336.105 335 335C335 333.895 332.761 333 330 333Z", fill: "currentColor" }), h("path", { d: "M379 333H348C345.239 333 343 333.895 343 335C343 336.105 345.239 337 348 337H379C381.761 337 384 336.105 384 335C384 333.895 381.761 333 379 333Z", fill: "currentColor" }), h("path", { d: "M379 353H275C272.239 353 270 355.736 270 359.111V368.889C270 372.264 272.239 375 275 375H379C381.761 375 384 372.264 384 368.889V359.111C384 355.736 381.761 353 379 353Z", fill: "currentColor" }))));
|
|
80
77
|
}
|
|
81
78
|
render() {
|
|
82
|
-
return (h("div", { class: "twintag-pdf-viewer" }, pdfStore.state.docs.get(this.fileURL) ? (h("div", { class: "twintag-pdf-container" }, h("div", null), h("div", { class: "twintag-pdf-view" }, pdfStore.state.docs.get(this.fileURL).pages &&
|
|
83
|
-
pdfStore.state.docs.get(this.fileURL).pages.
|
|
84
|
-
|
|
85
|
-
.get(this.fileURL)
|
|
86
|
-
.pages.map((page, key) => (h("img", { key: key, src: page, alt: `Page ${key + 1}`, class: key ===
|
|
87
|
-
pdfStore.state.docs.get(this.fileURL)
|
|
88
|
-
.idxLastRendered -
|
|
89
|
-
1
|
|
90
|
-
? 'twintag-pdf-observed-page'
|
|
91
|
-
: '', style: { width: '100%' }, ref: (el) => {
|
|
92
|
-
if (el) {
|
|
79
|
+
return (h("div", { class: "twintag-pdf-viewer" }, pdfStore.state.docs.get(this.fileURL) ? (h("div", { class: "twintag-pdf-container" }, h("div", null), h("div", { class: "twintag-pdf-view" }, pdfStore.state.docs.get(this.fileURL).pages && pdfStore.state.docs.get(this.fileURL).pages.length > 0
|
|
80
|
+
? pdfStore.state.docs.get(this.fileURL).pages.map((page, key) => (h("img", { key: key, src: page, alt: `Page ${key + 1}`, class: key === pdfStore.state.docs.get(this.fileURL).idxLastRendered - 1 ? 'twintag-pdf-observed-page' : '', style: { width: '100%' }, ref: el => {
|
|
81
|
+
if (el && this.observer) {
|
|
93
82
|
this.observer.observe(el);
|
|
94
83
|
}
|
|
95
84
|
return el;
|
|
96
85
|
} })))
|
|
97
|
-
: null), pdfStore.state.docs.get(this.fileURL).pages &&
|
|
98
|
-
pdfStore.state.docs.get(this.fileURL).pages.length <
|
|
99
|
-
pdfStore.state.docs.get(this.fileURL).pageCount
|
|
86
|
+
: null), pdfStore.state.docs.get(this.fileURL).pages && pdfStore.state.docs.get(this.fileURL).pages.length < pdfStore.state.docs.get(this.fileURL).pageCount
|
|
100
87
|
? this.getPlaceholder()
|
|
101
88
|
: null)) : (this.getPlaceholder())));
|
|
102
89
|
}
|
|
@@ -260,9 +260,7 @@ const TwintagPdfViewer = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
|
|
|
260
260
|
return null;
|
|
261
261
|
const response = await fetch(url);
|
|
262
262
|
const blob = await response.blob();
|
|
263
|
-
const file_name = this.fileName
|
|
264
|
-
? this.fileName
|
|
265
|
-
: Math.random().toString(36).substring(6) + '_name.pdf';
|
|
263
|
+
const file_name = this.fileName ? this.fileName : Math.random().toString(36).substring(6) + '_name.pdf';
|
|
266
264
|
const file_object = new File([blob], file_name, {
|
|
267
265
|
type: 'application/pdf',
|
|
268
266
|
});
|
|
@@ -286,7 +284,7 @@ const TwintagPdfViewer = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
|
|
|
286
284
|
this.handleFile(this.src, this.fileURL);
|
|
287
285
|
}
|
|
288
286
|
componentWillRender() {
|
|
289
|
-
worker.onmessage =
|
|
287
|
+
worker.onmessage = e => {
|
|
290
288
|
const { data } = e;
|
|
291
289
|
if (data.type) {
|
|
292
290
|
if (data.type === 'file_converted') {
|
|
@@ -302,11 +300,10 @@ const TwintagPdfViewer = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
|
|
|
302
300
|
}
|
|
303
301
|
};
|
|
304
302
|
}
|
|
305
|
-
|
|
306
|
-
this.observer = new IntersectionObserver(
|
|
307
|
-
entries.forEach(
|
|
308
|
-
if (entry.isIntersecting &&
|
|
309
|
-
entry.target.classList.contains('twintag-pdf-observed-page')) {
|
|
303
|
+
componentDidRender() {
|
|
304
|
+
this.observer = new IntersectionObserver(entries => {
|
|
305
|
+
entries.forEach(entry => {
|
|
306
|
+
if (entry.isIntersecting && entry.target.classList.contains('twintag-pdf-observed-page')) {
|
|
310
307
|
const { idxLastRendered, pageCount } = pdfStore.state.docs.get(this.fileURL);
|
|
311
308
|
if (idxLastRendered < pageCount) {
|
|
312
309
|
worker.postMessage({
|
|
@@ -323,24 +320,14 @@ const TwintagPdfViewer = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
|
|
|
323
320
|
return (h("div", null, h("svg", { color: "#ccc", width: "100%", height: "391", viewBox: "0 0 400 391", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, h("path", { d: "M82.4286 16H19.5714C17.599 16 16 19.0726 16 22.8627V79.1373C16 82.9274 17.599 86 19.5714 86H82.4286C84.401 86 86 82.9274 86 79.1373V22.8627C86 19.0726 84.401 16 82.4286 16Z", fill: "currentColor" }), h("path", { d: "M380.522 16H275.478C273.557 16 272 18.7982 272 22.25V24.75C272 28.2018 273.557 31 275.478 31H380.522C382.443 31 384 28.2018 384 24.75V22.25C384 18.7982 382.443 16 380.522 16Z", fill: "currentColor" }), h("path", { d: "M379.429 47H228.571C226.047 47 224 48.7909 224 51C224 53.2091 226.047 55 228.571 55H379.429C381.953 55 384 53.2091 384 51C384 48.7909 381.953 47 379.429 47Z", fill: "currentColor" }), h("path", { d: "M379.918 59H228.082C225.827 59 224 60.567 224 62.5C224 64.433 225.827 66 228.082 66H379.918C382.173 66 384 64.433 384 62.5C384 60.567 382.173 59 379.918 59Z", fill: "currentColor" }), h("path", { d: "M379.429 70H228.571C226.047 70 224 71.567 224 73.5C224 75.433 226.047 77 228.571 77H379.429C381.953 77 384 75.433 384 73.5C384 71.567 381.953 70 379.429 70Z", fill: "currentColor" }), h("path", { d: "M209 102H21C18.2386 102 16 104.612 16 107.833V110.167C16 113.388 18.2386 116 21 116H209C211.761 116 214 113.388 214 110.167V107.833C214 104.612 211.761 102 209 102Z", fill: "currentColor" }), h("path", { d: "M240.043 132H20.9567C18.2192 132 16 133.567 16 135.5C16 137.433 18.2192 139 20.9567 139H240.043C242.781 139 245 137.433 245 135.5C245 133.567 242.781 132 240.043 132Z", fill: "currentColor" }), h("path", { d: "M239.158 143H21.8418C18.6155 143 16 144.567 16 146.5C16 148.433 18.6155 150 21.8418 150H239.158C242.385 150 245 148.433 245 146.5C245 144.567 242.385 143 239.158 143Z", fill: "currentColor" }), h("path", { d: "M238.457 154H22.5429C18.9293 154 16 155.567 16 157.5C16 159.433 18.9293 161 22.5429 161H238.457C242.071 161 245 159.433 245 157.5C245 155.567 242.071 154 238.457 154Z", fill: "currentColor" }), h("path", { d: "M238.457 165H22.5429C18.9293 165 16 166.791 16 169C16 171.209 18.9293 173 22.5429 173H238.457C242.071 173 245 171.209 245 169C245 166.791 242.071 165 238.457 165Z", fill: "currentColor" }), h("path", { d: "M191 189H21C18.2386 189 16 190.343 16 192C16 193.657 18.2386 195 21 195H191C193.761 195 196 193.657 196 192C196 190.343 193.761 189 191 189Z", fill: "currentColor" }), h("path", { d: "M166 211H21C18.2386 211 16 213.736 16 217.111V226.889C16 230.264 18.2386 233 21 233H166C168.761 233 171 230.264 171 226.889V217.111C171 213.736 168.761 211 166 211Z", fill: "currentColor" }), h("path", { d: "M97 249H21C18.2386 249 16 250.119 16 251.5C16 252.881 18.2386 254 21 254H97C99.7614 254 102 252.881 102 251.5C102 250.119 99.7614 249 97 249Z", fill: "currentColor" }), h("path", { d: "M144 258H21C18.2386 258 16 259.343 16 261C16 262.657 18.2386 264 21 264H144C146.761 264 149 262.657 149 261C149 259.343 146.761 258 144 258Z", fill: "currentColor" }), h("path", { d: "M379 211.5H339C336.239 211.5 334 214.236 334 217.611V227.389C334 230.764 336.239 233.5 339 233.5H379C381.761 233.5 384 230.764 384 227.389V217.611C384 214.236 381.761 211.5 379 211.5Z", fill: "currentColor" }), h("path", { d: "M379 241.5H304C301.239 241.5 299 244.236 299 247.611V257.389C299 260.764 301.239 263.5 304 263.5H379C381.761 263.5 384 260.764 384 257.389V247.611C384 244.236 381.761 241.5 379 241.5Z", fill: "currentColor" }), h("path", { d: "M204 280H21C18.2386 280 16 282.718 16 286.071V290.929C16 294.282 18.2386 297 21 297H204C206.761 297 209 294.282 209 290.929V286.071C209 282.718 206.761 280 204 280Z", fill: "currentColor" }), h("path", { d: "M242 313H21C18.2386 313 16 314.567 16 316.5C16 318.433 18.2386 320 21 320H242C244.761 320 247 318.433 247 316.5C247 314.567 244.761 313 242 313Z", fill: "currentColor" }), h("path", { d: "M239.158 324H21.8418C18.6155 324 16 325.567 16 327.5C16 329.433 18.6155 331 21.8418 331H239.158C242.385 331 245 329.433 245 327.5C245 325.567 242.385 324 239.158 324Z", fill: "currentColor" }), h("path", { d: "M238.457 335H22.5429C18.9293 335 16 336.567 16 338.5C16 340.433 18.9293 342 22.5429 342H238.457C242.071 342 245 340.433 245 338.5C245 336.567 242.071 335 238.457 335Z", fill: "currentColor" }), h("path", { d: "M238.457 346H22.5429C18.9293 346 16 347.567 16 349.5C16 351.433 18.9293 353 22.5429 353H238.457C242.071 353 245 351.433 245 349.5C245 347.567 242.071 346 238.457 346Z", fill: "currentColor" }), h("path", { d: "M191 369H21C18.2386 369 16 370.343 16 372C16 373.657 18.2386 375 21 375H191C193.761 375 196 373.657 196 372C196 370.343 193.761 369 191 369Z", fill: "currentColor" }), h("path", { d: "M330 333H299C296.239 333 294 333.895 294 335C294 336.105 296.239 337 299 337H330C332.761 337 335 336.105 335 335C335 333.895 332.761 333 330 333Z", fill: "currentColor" }), h("path", { d: "M379 333H348C345.239 333 343 333.895 343 335C343 336.105 345.239 337 348 337H379C381.761 337 384 336.105 384 335C384 333.895 381.761 333 379 333Z", fill: "currentColor" }), h("path", { d: "M379 353H275C272.239 353 270 355.736 270 359.111V368.889C270 372.264 272.239 375 275 375H379C381.761 375 384 372.264 384 368.889V359.111C384 355.736 381.761 353 379 353Z", fill: "currentColor" }))));
|
|
324
321
|
}
|
|
325
322
|
render() {
|
|
326
|
-
return (h("div", { class: "twintag-pdf-viewer" }, pdfStore.state.docs.get(this.fileURL) ? (h("div", { class: "twintag-pdf-container" }, h("div", null), h("div", { class: "twintag-pdf-view" }, pdfStore.state.docs.get(this.fileURL).pages &&
|
|
327
|
-
pdfStore.state.docs.get(this.fileURL).pages.
|
|
328
|
-
|
|
329
|
-
.get(this.fileURL)
|
|
330
|
-
.pages.map((page, key) => (h("img", { key: key, src: page, alt: `Page ${key + 1}`, class: key ===
|
|
331
|
-
pdfStore.state.docs.get(this.fileURL)
|
|
332
|
-
.idxLastRendered -
|
|
333
|
-
1
|
|
334
|
-
? 'twintag-pdf-observed-page'
|
|
335
|
-
: '', style: { width: '100%' }, ref: (el) => {
|
|
336
|
-
if (el) {
|
|
323
|
+
return (h("div", { class: "twintag-pdf-viewer" }, pdfStore.state.docs.get(this.fileURL) ? (h("div", { class: "twintag-pdf-container" }, h("div", null), h("div", { class: "twintag-pdf-view" }, pdfStore.state.docs.get(this.fileURL).pages && pdfStore.state.docs.get(this.fileURL).pages.length > 0
|
|
324
|
+
? pdfStore.state.docs.get(this.fileURL).pages.map((page, key) => (h("img", { key: key, src: page, alt: `Page ${key + 1}`, class: key === pdfStore.state.docs.get(this.fileURL).idxLastRendered - 1 ? 'twintag-pdf-observed-page' : '', style: { width: '100%' }, ref: el => {
|
|
325
|
+
if (el && this.observer) {
|
|
337
326
|
this.observer.observe(el);
|
|
338
327
|
}
|
|
339
328
|
return el;
|
|
340
329
|
} })))
|
|
341
|
-
: null), pdfStore.state.docs.get(this.fileURL).pages &&
|
|
342
|
-
pdfStore.state.docs.get(this.fileURL).pages.length <
|
|
343
|
-
pdfStore.state.docs.get(this.fileURL).pageCount
|
|
330
|
+
: null), pdfStore.state.docs.get(this.fileURL).pages && pdfStore.state.docs.get(this.fileURL).pages.length < pdfStore.state.docs.get(this.fileURL).pageCount
|
|
344
331
|
? this.getPlaceholder()
|
|
345
332
|
: null)) : (this.getPlaceholder())));
|
|
346
333
|
}
|
|
@@ -259,9 +259,7 @@ const TwintagPdfViewer = class {
|
|
|
259
259
|
return null;
|
|
260
260
|
const response = await fetch(url);
|
|
261
261
|
const blob = await response.blob();
|
|
262
|
-
const file_name = this.fileName
|
|
263
|
-
? this.fileName
|
|
264
|
-
: Math.random().toString(36).substring(6) + '_name.pdf';
|
|
262
|
+
const file_name = this.fileName ? this.fileName : Math.random().toString(36).substring(6) + '_name.pdf';
|
|
265
263
|
const file_object = new File([blob], file_name, {
|
|
266
264
|
type: 'application/pdf',
|
|
267
265
|
});
|
|
@@ -285,7 +283,7 @@ const TwintagPdfViewer = class {
|
|
|
285
283
|
this.handleFile(this.src, this.fileURL);
|
|
286
284
|
}
|
|
287
285
|
componentWillRender() {
|
|
288
|
-
worker.onmessage =
|
|
286
|
+
worker.onmessage = e => {
|
|
289
287
|
const { data } = e;
|
|
290
288
|
if (data.type) {
|
|
291
289
|
if (data.type === 'file_converted') {
|
|
@@ -301,11 +299,10 @@ const TwintagPdfViewer = class {
|
|
|
301
299
|
}
|
|
302
300
|
};
|
|
303
301
|
}
|
|
304
|
-
|
|
305
|
-
this.observer = new IntersectionObserver(
|
|
306
|
-
entries.forEach(
|
|
307
|
-
if (entry.isIntersecting &&
|
|
308
|
-
entry.target.classList.contains('twintag-pdf-observed-page')) {
|
|
302
|
+
componentDidRender() {
|
|
303
|
+
this.observer = new IntersectionObserver(entries => {
|
|
304
|
+
entries.forEach(entry => {
|
|
305
|
+
if (entry.isIntersecting && entry.target.classList.contains('twintag-pdf-observed-page')) {
|
|
309
306
|
const { idxLastRendered, pageCount } = pdfStore.state.docs.get(this.fileURL);
|
|
310
307
|
if (idxLastRendered < pageCount) {
|
|
311
308
|
worker.postMessage({
|
|
@@ -322,24 +319,14 @@ const TwintagPdfViewer = class {
|
|
|
322
319
|
return (h("div", null, h("svg", { color: "#ccc", width: "100%", height: "391", viewBox: "0 0 400 391", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, h("path", { d: "M82.4286 16H19.5714C17.599 16 16 19.0726 16 22.8627V79.1373C16 82.9274 17.599 86 19.5714 86H82.4286C84.401 86 86 82.9274 86 79.1373V22.8627C86 19.0726 84.401 16 82.4286 16Z", fill: "currentColor" }), h("path", { d: "M380.522 16H275.478C273.557 16 272 18.7982 272 22.25V24.75C272 28.2018 273.557 31 275.478 31H380.522C382.443 31 384 28.2018 384 24.75V22.25C384 18.7982 382.443 16 380.522 16Z", fill: "currentColor" }), h("path", { d: "M379.429 47H228.571C226.047 47 224 48.7909 224 51C224 53.2091 226.047 55 228.571 55H379.429C381.953 55 384 53.2091 384 51C384 48.7909 381.953 47 379.429 47Z", fill: "currentColor" }), h("path", { d: "M379.918 59H228.082C225.827 59 224 60.567 224 62.5C224 64.433 225.827 66 228.082 66H379.918C382.173 66 384 64.433 384 62.5C384 60.567 382.173 59 379.918 59Z", fill: "currentColor" }), h("path", { d: "M379.429 70H228.571C226.047 70 224 71.567 224 73.5C224 75.433 226.047 77 228.571 77H379.429C381.953 77 384 75.433 384 73.5C384 71.567 381.953 70 379.429 70Z", fill: "currentColor" }), h("path", { d: "M209 102H21C18.2386 102 16 104.612 16 107.833V110.167C16 113.388 18.2386 116 21 116H209C211.761 116 214 113.388 214 110.167V107.833C214 104.612 211.761 102 209 102Z", fill: "currentColor" }), h("path", { d: "M240.043 132H20.9567C18.2192 132 16 133.567 16 135.5C16 137.433 18.2192 139 20.9567 139H240.043C242.781 139 245 137.433 245 135.5C245 133.567 242.781 132 240.043 132Z", fill: "currentColor" }), h("path", { d: "M239.158 143H21.8418C18.6155 143 16 144.567 16 146.5C16 148.433 18.6155 150 21.8418 150H239.158C242.385 150 245 148.433 245 146.5C245 144.567 242.385 143 239.158 143Z", fill: "currentColor" }), h("path", { d: "M238.457 154H22.5429C18.9293 154 16 155.567 16 157.5C16 159.433 18.9293 161 22.5429 161H238.457C242.071 161 245 159.433 245 157.5C245 155.567 242.071 154 238.457 154Z", fill: "currentColor" }), h("path", { d: "M238.457 165H22.5429C18.9293 165 16 166.791 16 169C16 171.209 18.9293 173 22.5429 173H238.457C242.071 173 245 171.209 245 169C245 166.791 242.071 165 238.457 165Z", fill: "currentColor" }), h("path", { d: "M191 189H21C18.2386 189 16 190.343 16 192C16 193.657 18.2386 195 21 195H191C193.761 195 196 193.657 196 192C196 190.343 193.761 189 191 189Z", fill: "currentColor" }), h("path", { d: "M166 211H21C18.2386 211 16 213.736 16 217.111V226.889C16 230.264 18.2386 233 21 233H166C168.761 233 171 230.264 171 226.889V217.111C171 213.736 168.761 211 166 211Z", fill: "currentColor" }), h("path", { d: "M97 249H21C18.2386 249 16 250.119 16 251.5C16 252.881 18.2386 254 21 254H97C99.7614 254 102 252.881 102 251.5C102 250.119 99.7614 249 97 249Z", fill: "currentColor" }), h("path", { d: "M144 258H21C18.2386 258 16 259.343 16 261C16 262.657 18.2386 264 21 264H144C146.761 264 149 262.657 149 261C149 259.343 146.761 258 144 258Z", fill: "currentColor" }), h("path", { d: "M379 211.5H339C336.239 211.5 334 214.236 334 217.611V227.389C334 230.764 336.239 233.5 339 233.5H379C381.761 233.5 384 230.764 384 227.389V217.611C384 214.236 381.761 211.5 379 211.5Z", fill: "currentColor" }), h("path", { d: "M379 241.5H304C301.239 241.5 299 244.236 299 247.611V257.389C299 260.764 301.239 263.5 304 263.5H379C381.761 263.5 384 260.764 384 257.389V247.611C384 244.236 381.761 241.5 379 241.5Z", fill: "currentColor" }), h("path", { d: "M204 280H21C18.2386 280 16 282.718 16 286.071V290.929C16 294.282 18.2386 297 21 297H204C206.761 297 209 294.282 209 290.929V286.071C209 282.718 206.761 280 204 280Z", fill: "currentColor" }), h("path", { d: "M242 313H21C18.2386 313 16 314.567 16 316.5C16 318.433 18.2386 320 21 320H242C244.761 320 247 318.433 247 316.5C247 314.567 244.761 313 242 313Z", fill: "currentColor" }), h("path", { d: "M239.158 324H21.8418C18.6155 324 16 325.567 16 327.5C16 329.433 18.6155 331 21.8418 331H239.158C242.385 331 245 329.433 245 327.5C245 325.567 242.385 324 239.158 324Z", fill: "currentColor" }), h("path", { d: "M238.457 335H22.5429C18.9293 335 16 336.567 16 338.5C16 340.433 18.9293 342 22.5429 342H238.457C242.071 342 245 340.433 245 338.5C245 336.567 242.071 335 238.457 335Z", fill: "currentColor" }), h("path", { d: "M238.457 346H22.5429C18.9293 346 16 347.567 16 349.5C16 351.433 18.9293 353 22.5429 353H238.457C242.071 353 245 351.433 245 349.5C245 347.567 242.071 346 238.457 346Z", fill: "currentColor" }), h("path", { d: "M191 369H21C18.2386 369 16 370.343 16 372C16 373.657 18.2386 375 21 375H191C193.761 375 196 373.657 196 372C196 370.343 193.761 369 191 369Z", fill: "currentColor" }), h("path", { d: "M330 333H299C296.239 333 294 333.895 294 335C294 336.105 296.239 337 299 337H330C332.761 337 335 336.105 335 335C335 333.895 332.761 333 330 333Z", fill: "currentColor" }), h("path", { d: "M379 333H348C345.239 333 343 333.895 343 335C343 336.105 345.239 337 348 337H379C381.761 337 384 336.105 384 335C384 333.895 381.761 333 379 333Z", fill: "currentColor" }), h("path", { d: "M379 353H275C272.239 353 270 355.736 270 359.111V368.889C270 372.264 272.239 375 275 375H379C381.761 375 384 372.264 384 368.889V359.111C384 355.736 381.761 353 379 353Z", fill: "currentColor" }))));
|
|
323
320
|
}
|
|
324
321
|
render() {
|
|
325
|
-
return (h("div", { class: "twintag-pdf-viewer" }, pdfStore.state.docs.get(this.fileURL) ? (h("div", { class: "twintag-pdf-container" }, h("div", null), h("div", { class: "twintag-pdf-view" }, pdfStore.state.docs.get(this.fileURL).pages &&
|
|
326
|
-
pdfStore.state.docs.get(this.fileURL).pages.
|
|
327
|
-
|
|
328
|
-
.get(this.fileURL)
|
|
329
|
-
.pages.map((page, key) => (h("img", { key: key, src: page, alt: `Page ${key + 1}`, class: key ===
|
|
330
|
-
pdfStore.state.docs.get(this.fileURL)
|
|
331
|
-
.idxLastRendered -
|
|
332
|
-
1
|
|
333
|
-
? 'twintag-pdf-observed-page'
|
|
334
|
-
: '', style: { width: '100%' }, ref: (el) => {
|
|
335
|
-
if (el) {
|
|
322
|
+
return (h("div", { class: "twintag-pdf-viewer" }, pdfStore.state.docs.get(this.fileURL) ? (h("div", { class: "twintag-pdf-container" }, h("div", null), h("div", { class: "twintag-pdf-view" }, pdfStore.state.docs.get(this.fileURL).pages && pdfStore.state.docs.get(this.fileURL).pages.length > 0
|
|
323
|
+
? pdfStore.state.docs.get(this.fileURL).pages.map((page, key) => (h("img", { key: key, src: page, alt: `Page ${key + 1}`, class: key === pdfStore.state.docs.get(this.fileURL).idxLastRendered - 1 ? 'twintag-pdf-observed-page' : '', style: { width: '100%' }, ref: el => {
|
|
324
|
+
if (el && this.observer) {
|
|
336
325
|
this.observer.observe(el);
|
|
337
326
|
}
|
|
338
327
|
return el;
|
|
339
328
|
} })))
|
|
340
|
-
: null), pdfStore.state.docs.get(this.fileURL).pages &&
|
|
341
|
-
pdfStore.state.docs.get(this.fileURL).pages.length <
|
|
342
|
-
pdfStore.state.docs.get(this.fileURL).pageCount
|
|
329
|
+
: null), pdfStore.state.docs.get(this.fileURL).pages && pdfStore.state.docs.get(this.fileURL).pages.length < pdfStore.state.docs.get(this.fileURL).pageCount
|
|
343
330
|
? this.getPlaceholder()
|
|
344
331
|
: null)) : (this.getPlaceholder())));
|
|
345
332
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as t,d as e,f as r,r as n,h as o}from"./p-cb286d41.js";const l=new Map,i=new Map,C=(e,r,n)=>{const o=new Worker(e,{name:r});return o.addEventListener("message",(({data:e})=>{if(e){const r=e[0],o=e[1],C=e[2];if(r===n){const r=e[3],[n,s,c]=l.get(o);if(l.delete(o),r){const e=r.isError?Object.assign(new Error(r.value.message),r.value):r.value;t(e),s(e)}else c&&c.forEach((t=>i.delete(t))),n(C)}else if(r===n+".cb")try{i.get(o)(...C)}catch(e){t(e)}}})),o},s=C(new URL("p-451433c3.js",import.meta.url).href,"pdf-viewer.worker","stencil.pdf-viewer.worker"),c=t=>!("isConnected"in t)||t.isConnected,a=(()=>{let t;return(...e)=>{t&&clearTimeout(t),t=setTimeout((()=>{t=0,(t=>{for(let e of t.keys())t.set(e,t.get(e).filter(c))})(...e)}),2e3)}})(),d=t=>"function"==typeof t?t():t,p=(()=>{const t=((t,e=((t,e)=>t!==e))=>{const r=d(t);let n=new Map(Object.entries(null!=r?r:{}));const o={dispose:[],get:[],set:[],reset:[]},l=()=>{var e;n=new Map(Object.entries(null!==(e=d(t))&&void 0!==e?e:{})),o.reset.forEach((t=>t()))},i=t=>(o.get.forEach((e=>e(t))),n.get(t)),C=(t,r)=>{const l=n.get(t);e(r,l,t)&&(n.set(t,r),o.set.forEach((e=>e(t,r,l))))},s="undefined"==typeof Proxy?{}:new Proxy(r,{get:(t,e)=>i(e),ownKeys:()=>Array.from(n.keys()),getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0}),has:(t,e)=>n.has(e),set:(t,e,r)=>(C(e,r),!0)}),c=(t,e)=>(o[t].push(e),()=>{((t,e)=>{const r=t.indexOf(e);r>=0&&(t[r]=t[t.length-1],t.length--)})(o[t],e)});return{state:s,get:i,set:C,on:c,onChange:(e,r)=>{const n=c("set",((t,n)=>{t===e&&r(n)})),o=c("reset",(()=>r(d(t)[e])));return()=>{n(),o()}},use:(...t)=>{const e=t.reduce(((t,e)=>(e.set&&t.push(c("set",e.set)),e.get&&t.push(c("get",e.get)),e.reset&&t.push(c("reset",e.reset)),e.dispose&&t.push(c("dispose",e.dispose)),t)),[]);return()=>e.forEach((t=>t()))},dispose:()=>{o.dispose.forEach((t=>t())),l()},reset:l,forceUpdate:t=>{const e=n.get(t);o.set.forEach((r=>r(t,e,e)))}}})({docs:new Map},void 0);return t.use((()=>{if("function"!=typeof e)return{};const t=new Map;return{dispose:()=>t.clear(),get:r=>{const n=e();n&&((t,e,r)=>{const n=t.get(e);n?n.includes(r)||n.push(r):t.set(e,[r])})(t,r,n)},set:e=>{const n=t.get(e);n&&t.set(e,n.filter(r)),a(t)},reset:()=>{t.forEach((t=>t.forEach(r))),a(t)}}})()),t})(),h=class{constructor(t){n(this,t),this.src="",this.fileName=void 0,this.file=null,this.fileURL=""}async urlToFile(t){if(!t)return null;const e=await fetch(t),r=await e.blob(),n=this.fileName?this.fileName:Math.random().toString(36).substring(6)+"_name.pdf";return new File([r],n,{type:"application/pdf"})}async handleFile(t,e){if(t!==e){const e=await this.urlToFile(t);this.file=e,this.fileURL=t,function(t){return t&&"application/pdf"===t.type}(e)&&!p.state.docs.has(t)&&s.postMessage({type:"convert_file",url:t,file:e})}}connectedCallback(){this.handleFile(this.src,this.fileURL)}componentWillRender(){s.onmessage=t=>{const{data:e}=t;if(e.type){if("file_converted"===e.type){const t=new Map(p.state.docs).set(e.url,Object.assign(Object.assign({},p.state.docs.get(e.url)),{pages:e.pages,pageCount:e.pageCount,idxLastRendered:e.idxLastRendered}));p.state.docs=t}if("page_converted"===e.type){const t=[...p.state.docs.get(e.url).pages];t[e.idxLastRendered-1]=e.page;const r=new Map(p.state.docs).set(e.url,Object.assign(Object.assign({},p.state.docs.get(e.url)),{pages:t,idxLastRendered:e.idxLastRendered}));p.state.docs=r}}}}componentDidRender(){this.observer=new IntersectionObserver((t=>{t.forEach((t=>{if(t.isIntersecting&&t.target.classList.contains("twintag-pdf-observed-page")){const{idxLastRendered:t,pageCount:e}=p.state.docs.get(this.fileURL);t<e&&s.postMessage({type:"convert_idx_to_page",url:this.fileURL,idxLastRendered:t})}}))}))}getPlaceholder(){return o("div",null,o("svg",{color:"#ccc",width:"100%",height:"391",viewBox:"0 0 400 391",fill:"none",xmlns:"http://www.w3.org/2000/svg"},o("path",{d:"M82.4286 16H19.5714C17.599 16 16 19.0726 16 22.8627V79.1373C16 82.9274 17.599 86 19.5714 86H82.4286C84.401 86 86 82.9274 86 79.1373V22.8627C86 19.0726 84.401 16 82.4286 16Z",fill:"currentColor"}),o("path",{d:"M380.522 16H275.478C273.557 16 272 18.7982 272 22.25V24.75C272 28.2018 273.557 31 275.478 31H380.522C382.443 31 384 28.2018 384 24.75V22.25C384 18.7982 382.443 16 380.522 16Z",fill:"currentColor"}),o("path",{d:"M379.429 47H228.571C226.047 47 224 48.7909 224 51C224 53.2091 226.047 55 228.571 55H379.429C381.953 55 384 53.2091 384 51C384 48.7909 381.953 47 379.429 47Z",fill:"currentColor"}),o("path",{d:"M379.918 59H228.082C225.827 59 224 60.567 224 62.5C224 64.433 225.827 66 228.082 66H379.918C382.173 66 384 64.433 384 62.5C384 60.567 382.173 59 379.918 59Z",fill:"currentColor"}),o("path",{d:"M379.429 70H228.571C226.047 70 224 71.567 224 73.5C224 75.433 226.047 77 228.571 77H379.429C381.953 77 384 75.433 384 73.5C384 71.567 381.953 70 379.429 70Z",fill:"currentColor"}),o("path",{d:"M209 102H21C18.2386 102 16 104.612 16 107.833V110.167C16 113.388 18.2386 116 21 116H209C211.761 116 214 113.388 214 110.167V107.833C214 104.612 211.761 102 209 102Z",fill:"currentColor"}),o("path",{d:"M240.043 132H20.9567C18.2192 132 16 133.567 16 135.5C16 137.433 18.2192 139 20.9567 139H240.043C242.781 139 245 137.433 245 135.5C245 133.567 242.781 132 240.043 132Z",fill:"currentColor"}),o("path",{d:"M239.158 143H21.8418C18.6155 143 16 144.567 16 146.5C16 148.433 18.6155 150 21.8418 150H239.158C242.385 150 245 148.433 245 146.5C245 144.567 242.385 143 239.158 143Z",fill:"currentColor"}),o("path",{d:"M238.457 154H22.5429C18.9293 154 16 155.567 16 157.5C16 159.433 18.9293 161 22.5429 161H238.457C242.071 161 245 159.433 245 157.5C245 155.567 242.071 154 238.457 154Z",fill:"currentColor"}),o("path",{d:"M238.457 165H22.5429C18.9293 165 16 166.791 16 169C16 171.209 18.9293 173 22.5429 173H238.457C242.071 173 245 171.209 245 169C245 166.791 242.071 165 238.457 165Z",fill:"currentColor"}),o("path",{d:"M191 189H21C18.2386 189 16 190.343 16 192C16 193.657 18.2386 195 21 195H191C193.761 195 196 193.657 196 192C196 190.343 193.761 189 191 189Z",fill:"currentColor"}),o("path",{d:"M166 211H21C18.2386 211 16 213.736 16 217.111V226.889C16 230.264 18.2386 233 21 233H166C168.761 233 171 230.264 171 226.889V217.111C171 213.736 168.761 211 166 211Z",fill:"currentColor"}),o("path",{d:"M97 249H21C18.2386 249 16 250.119 16 251.5C16 252.881 18.2386 254 21 254H97C99.7614 254 102 252.881 102 251.5C102 250.119 99.7614 249 97 249Z",fill:"currentColor"}),o("path",{d:"M144 258H21C18.2386 258 16 259.343 16 261C16 262.657 18.2386 264 21 264H144C146.761 264 149 262.657 149 261C149 259.343 146.761 258 144 258Z",fill:"currentColor"}),o("path",{d:"M379 211.5H339C336.239 211.5 334 214.236 334 217.611V227.389C334 230.764 336.239 233.5 339 233.5H379C381.761 233.5 384 230.764 384 227.389V217.611C384 214.236 381.761 211.5 379 211.5Z",fill:"currentColor"}),o("path",{d:"M379 241.5H304C301.239 241.5 299 244.236 299 247.611V257.389C299 260.764 301.239 263.5 304 263.5H379C381.761 263.5 384 260.764 384 257.389V247.611C384 244.236 381.761 241.5 379 241.5Z",fill:"currentColor"}),o("path",{d:"M204 280H21C18.2386 280 16 282.718 16 286.071V290.929C16 294.282 18.2386 297 21 297H204C206.761 297 209 294.282 209 290.929V286.071C209 282.718 206.761 280 204 280Z",fill:"currentColor"}),o("path",{d:"M242 313H21C18.2386 313 16 314.567 16 316.5C16 318.433 18.2386 320 21 320H242C244.761 320 247 318.433 247 316.5C247 314.567 244.761 313 242 313Z",fill:"currentColor"}),o("path",{d:"M239.158 324H21.8418C18.6155 324 16 325.567 16 327.5C16 329.433 18.6155 331 21.8418 331H239.158C242.385 331 245 329.433 245 327.5C245 325.567 242.385 324 239.158 324Z",fill:"currentColor"}),o("path",{d:"M238.457 335H22.5429C18.9293 335 16 336.567 16 338.5C16 340.433 18.9293 342 22.5429 342H238.457C242.071 342 245 340.433 245 338.5C245 336.567 242.071 335 238.457 335Z",fill:"currentColor"}),o("path",{d:"M238.457 346H22.5429C18.9293 346 16 347.567 16 349.5C16 351.433 18.9293 353 22.5429 353H238.457C242.071 353 245 351.433 245 349.5C245 347.567 242.071 346 238.457 346Z",fill:"currentColor"}),o("path",{d:"M191 369H21C18.2386 369 16 370.343 16 372C16 373.657 18.2386 375 21 375H191C193.761 375 196 373.657 196 372C196 370.343 193.761 369 191 369Z",fill:"currentColor"}),o("path",{d:"M330 333H299C296.239 333 294 333.895 294 335C294 336.105 296.239 337 299 337H330C332.761 337 335 336.105 335 335C335 333.895 332.761 333 330 333Z",fill:"currentColor"}),o("path",{d:"M379 333H348C345.239 333 343 333.895 343 335C343 336.105 345.239 337 348 337H379C381.761 337 384 336.105 384 335C384 333.895 381.761 333 379 333Z",fill:"currentColor"}),o("path",{d:"M379 353H275C272.239 353 270 355.736 270 359.111V368.889C270 372.264 272.239 375 275 375H379C381.761 375 384 372.264 384 368.889V359.111C384 355.736 381.761 353 379 353Z",fill:"currentColor"})))}render(){return o("div",{class:"twintag-pdf-viewer"},p.state.docs.get(this.fileURL)?o("div",{class:"twintag-pdf-container"},o("div",null),o("div",{class:"twintag-pdf-view"},p.state.docs.get(this.fileURL).pages&&p.state.docs.get(this.fileURL).pages.length>0?p.state.docs.get(this.fileURL).pages.map(((t,e)=>o("img",{key:e,src:t,alt:`Page ${e+1}`,class:e===p.state.docs.get(this.fileURL).idxLastRendered-1?"twintag-pdf-observed-page":"",style:{width:"100%"},ref:t=>(t&&this.observer&&this.observer.observe(t),t)}))):null),p.state.docs.get(this.fileURL).pages&&p.state.docs.get(this.fileURL).pages.length<p.state.docs.get(this.fileURL).pageCount?this.getPlaceholder():null):this.getPlaceholder())}static get watchers(){return{src:["handleFile"]}}};export{h as twintag_pdf_viewer}
|