idiotikmethods 0.1.0 → 0.1.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/IdiotikMethods.js +17 -13
- package/package.json +2 -2
package/IdiotikMethods.js
CHANGED
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
{
|
|
43
43
|
key: "pdfjs",
|
|
44
44
|
url: "https://cdnjs.cloudflare.com/ajax/libs/pdf.js/4.2.67/pdf.min.js",
|
|
45
|
-
fallback: "https://
|
|
45
|
+
fallback: "https://cdn.jsdelivr.net/npm/pdfjs-dist@4.2.67/legacy/build/pdf.min.js",
|
|
46
46
|
init: () => _initPdfJs(),
|
|
47
47
|
},
|
|
48
48
|
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
{
|
|
109
109
|
key: "chartjs",
|
|
110
110
|
url: "https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.4.3/chart.umd.min.js",
|
|
111
|
-
fallback: "https://
|
|
111
|
+
fallback: "https://cdn.jsdelivr.net/npm/chart.js@4.4.3/dist/chart.umd.min.js",
|
|
112
112
|
init: () => _register("chartjs", root.Chart),
|
|
113
113
|
},
|
|
114
114
|
{
|
|
@@ -452,8 +452,14 @@
|
|
|
452
452
|
|
|
453
453
|
// set worker src (use CDN worker)
|
|
454
454
|
if (pdfjsLib.GlobalWorkerOptions) {
|
|
455
|
-
|
|
456
|
-
|
|
455
|
+
// primary worker — cdnjs; fallback — jsDelivr legacy build
|
|
456
|
+
const _workerPrimary = "https://cdnjs.cloudflare.com/ajax/libs/pdf.js/4.2.67/pdf.worker.min.js";
|
|
457
|
+
const _workerFallback = "https://cdn.jsdelivr.net/npm/pdfjs-dist@4.2.67/legacy/build/pdf.worker.min.js";
|
|
458
|
+
pdfjsLib.GlobalWorkerOptions.workerSrc = _workerPrimary;
|
|
459
|
+
// if the worker 404s, swap to fallback so pdf rendering doesn't die silently
|
|
460
|
+
fetch(_workerPrimary, { method: "HEAD" }).catch(() => {
|
|
461
|
+
pdfjsLib.GlobalWorkerOptions.workerSrc = _workerFallback;
|
|
462
|
+
});
|
|
457
463
|
}
|
|
458
464
|
|
|
459
465
|
// spin up a minimal invisible container to get the trusted event pipeline live
|
|
@@ -662,15 +668,13 @@
|
|
|
662
668
|
}
|
|
663
669
|
|
|
664
670
|
function _resolveSwUrl(type) {
|
|
665
|
-
//
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
}
|
|
673
|
-
return type === "fallback" ? "/sw-fallback.js" : "/sw.js";
|
|
671
|
+
// SW must be same-origin — always resolve relative to the page, not the script src.
|
|
672
|
+
// CDN-hosted scripts (unpkg, cdnjs, jsdelivr) would produce a cross-origin SW url
|
|
673
|
+
// which browsers hard-block with a SecurityError. page-relative is always safe.
|
|
674
|
+
const swFile = type === "fallback" ? "sw-fallback.js" : "sw.js";
|
|
675
|
+
// use the page's current directory (works for both root and subpath deployments)
|
|
676
|
+
const pagePath = window.location.pathname.substring(0, window.location.pathname.lastIndexOf("/") + 1);
|
|
677
|
+
return pagePath + swFile;
|
|
674
678
|
}
|
|
675
679
|
|
|
676
680
|
function _waitForSWActive(reg) {
|