idiotikmethods 0.1.0 → 0.1.2
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 +79 -42
- package/package.json +2 -2
package/IdiotikMethods.js
CHANGED
|
@@ -41,8 +41,9 @@
|
|
|
41
41
|
// ── PDF / DOC ──────────────────────────────────────────────
|
|
42
42
|
{
|
|
43
43
|
key: "pdfjs",
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
// 3.11.174 confirmed live on cdnjs — 4.x changed path structure, 404s on cdnjs
|
|
45
|
+
url: "https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.11.174/pdf.min.js",
|
|
46
|
+
fallback: "https://cdn.jsdelivr.net/npm/pdfjs-dist@3.11.174/build/pdf.min.js",
|
|
46
47
|
init: () => _initPdfJs(),
|
|
47
48
|
},
|
|
48
49
|
|
|
@@ -89,7 +90,8 @@
|
|
|
89
90
|
},
|
|
90
91
|
{
|
|
91
92
|
key: "konva",
|
|
92
|
-
|
|
93
|
+
// 9.3.3 not on cdnjs — jsdelivr is the reliable source for konva
|
|
94
|
+
url: "https://cdn.jsdelivr.net/npm/konva@9.3.3/konva.min.js",
|
|
93
95
|
fallback: "https://unpkg.com/konva@9.3.3/konva.min.js",
|
|
94
96
|
init: () => _register("konva", root.Konva),
|
|
95
97
|
},
|
|
@@ -107,8 +109,9 @@
|
|
|
107
109
|
},
|
|
108
110
|
{
|
|
109
111
|
key: "chartjs",
|
|
110
|
-
|
|
111
|
-
|
|
112
|
+
// v4 dropped chart.umd.min.js — correct artifact is chart.umd.js on jsdelivr
|
|
113
|
+
url: "https://cdn.jsdelivr.net/npm/chart.js@4.4.3/dist/chart.umd.js",
|
|
114
|
+
fallback: "https://unpkg.com/chart.js@4.4.3/dist/chart.umd.js",
|
|
112
115
|
init: () => _register("chartjs", root.Chart),
|
|
113
116
|
},
|
|
114
117
|
{
|
|
@@ -347,7 +350,8 @@
|
|
|
347
350
|
},
|
|
348
351
|
{
|
|
349
352
|
key: "planck",
|
|
350
|
-
|
|
353
|
+
// planck was never on cdnjs — jsdelivr is the only CDN that has it
|
|
354
|
+
url: "https://cdn.jsdelivr.net/npm/planck@1.0.0/dist/planck.min.js",
|
|
351
355
|
fallback: "https://unpkg.com/planck@1.0.0/dist/planck.min.js",
|
|
352
356
|
init: () => _register("planck", root.planck),
|
|
353
357
|
},
|
|
@@ -361,8 +365,9 @@
|
|
|
361
365
|
},
|
|
362
366
|
{
|
|
363
367
|
key: "pagejs",
|
|
364
|
-
|
|
365
|
-
|
|
368
|
+
// 1.11.6 not on cdnjs — unpkg primary, jsdelivr fallback
|
|
369
|
+
url: "https://unpkg.com/page@1.11.6/page.js",
|
|
370
|
+
fallback: "https://cdn.jsdelivr.net/npm/page@1.11.6/page.js",
|
|
366
371
|
init: () => _register("pagejs", root.page),
|
|
367
372
|
},
|
|
368
373
|
|
|
@@ -377,7 +382,8 @@
|
|
|
377
382
|
// ── MISC POWER TOOLS ───────────────────────────────────────
|
|
378
383
|
{
|
|
379
384
|
key: "idb",
|
|
380
|
-
|
|
385
|
+
// idb was never on cdnjs — jsdelivr umd build is the right target
|
|
386
|
+
url: "https://cdn.jsdelivr.net/npm/idb@8.0.0/build/umd.js",
|
|
381
387
|
fallback: "https://unpkg.com/idb@8.0.0/build/umd.js",
|
|
382
388
|
init: () => _register("idb", root.idb),
|
|
383
389
|
},
|
|
@@ -389,9 +395,12 @@
|
|
|
389
395
|
},
|
|
390
396
|
{
|
|
391
397
|
key: "fingerprintjs",
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
398
|
+
// fingerprintjs2 is abandoned and unpublished — use v4 (@fingerprintjs/fingerprintjs)
|
|
399
|
+
// v4 is ESM-only so we use the CDN UMD build from jsdelivr
|
|
400
|
+
// API change: FingerprintJS.load().then(fp => fp.get()) instead of new Fingerprint2()
|
|
401
|
+
url: "https://cdn.jsdelivr.net/npm/@fingerprintjs/fingerprintjs@4/dist/fp.umd.min.js",
|
|
402
|
+
fallback: "https://unpkg.com/@fingerprintjs/fingerprintjs@4/dist/fp.umd.min.js",
|
|
403
|
+
init: () => _initFingerprintJS(),
|
|
395
404
|
},
|
|
396
405
|
{
|
|
397
406
|
key: "qrcode",
|
|
@@ -401,8 +410,9 @@
|
|
|
401
410
|
},
|
|
402
411
|
{
|
|
403
412
|
key: "zxing",
|
|
404
|
-
|
|
405
|
-
|
|
413
|
+
// zxing-js was never on cdnjs — unpkg umd build is the right target
|
|
414
|
+
url: "https://unpkg.com/@zxing/library@0.21.3/umd/index.min.js",
|
|
415
|
+
fallback: "https://cdn.jsdelivr.net/npm/@zxing/library@0.21.3/umd/index.min.js",
|
|
406
416
|
init: () => _register("zxing", root.ZXing),
|
|
407
417
|
},
|
|
408
418
|
{
|
|
@@ -450,10 +460,14 @@
|
|
|
450
460
|
const pdfjsLib = root.pdfjsLib || root["pdfjs-dist"] || root.pdfjsLib;
|
|
451
461
|
if (!pdfjsLib) { console.warn("[IdiotikMethods] pdf.js global not found"); return; }
|
|
452
462
|
|
|
453
|
-
// set worker src
|
|
463
|
+
// set worker src — must match the main pdf.js version exactly
|
|
454
464
|
if (pdfjsLib.GlobalWorkerOptions) {
|
|
455
|
-
|
|
456
|
-
|
|
465
|
+
const _workerPrimary = "https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.11.174/pdf.worker.min.js";
|
|
466
|
+
const _workerFallback = "https://cdn.jsdelivr.net/npm/pdfjs-dist@3.11.174/build/pdf.worker.min.js";
|
|
467
|
+
pdfjsLib.GlobalWorkerOptions.workerSrc = _workerPrimary;
|
|
468
|
+
fetch(_workerPrimary, { method: "HEAD" }).catch(() => {
|
|
469
|
+
pdfjsLib.GlobalWorkerOptions.workerSrc = _workerFallback;
|
|
470
|
+
});
|
|
457
471
|
}
|
|
458
472
|
|
|
459
473
|
// spin up a minimal invisible container to get the trusted event pipeline live
|
|
@@ -494,29 +508,37 @@
|
|
|
494
508
|
|
|
495
509
|
function _initHammer() {
|
|
496
510
|
if (!root.Hammer) { console.warn("[IdiotikMethods] Hammer.js not found"); return; }
|
|
497
|
-
|
|
511
|
+
const H = root.Hammer;
|
|
498
512
|
const target = document.createElement("div");
|
|
499
513
|
target.style.cssText = "position:fixed;width:1px;height:1px;top:-9999px;left:-9999px;touch-action:none;pointer-events:all;";
|
|
500
514
|
document.body.appendChild(target);
|
|
501
515
|
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
516
|
+
// avoid the array recognizer form [Hammer.Tap, opts] — when the SW wrapper IIFE
|
|
517
|
+
// patches hammer's source the internal Manager constructor misreads array[0] as
|
|
518
|
+
// the recognizer class reference and throws "a[0] is not a constructor".
|
|
519
|
+
// instantiate each recognizer explicitly instead — same result, no array form.
|
|
520
|
+
let mc;
|
|
521
|
+
try {
|
|
522
|
+
mc = new H.Manager(target);
|
|
523
|
+
mc.add(new H.Tap());
|
|
524
|
+
mc.add(new H.DoubleTap());
|
|
525
|
+
mc.add(new H.Press());
|
|
526
|
+
mc.add(new H.Pan({ direction: H.DIRECTION_ALL }));
|
|
527
|
+
mc.add(new H.Swipe({ direction: H.DIRECTION_ALL }));
|
|
528
|
+
mc.add(new H.Pinch());
|
|
529
|
+
mc.add(new H.Rotate());
|
|
530
|
+
} catch (e) {
|
|
531
|
+
// if Manager itself throws (e.g. stripped build), just register the global
|
|
532
|
+
console.warn("[IdiotikMethods] Hammer.Manager init failed, registering global only:", e.message);
|
|
533
|
+
_register("hammer", H);
|
|
534
|
+
return;
|
|
535
|
+
}
|
|
513
536
|
|
|
514
|
-
// fire noop listeners so the pipeline actually activates
|
|
515
537
|
["tap", "doubletap", "press", "pan", "swipe", "pinch", "rotate"].forEach((ev) => {
|
|
516
538
|
mc.on(ev, () => {});
|
|
517
539
|
});
|
|
518
540
|
|
|
519
|
-
_register("hammer",
|
|
541
|
+
_register("hammer", H);
|
|
520
542
|
_methods.hammerManager = mc;
|
|
521
543
|
if (root.idiotik) {
|
|
522
544
|
root.idiotik.methods = root.idiotik.methods || {};
|
|
@@ -552,6 +574,23 @@
|
|
|
552
574
|
}
|
|
553
575
|
}
|
|
554
576
|
|
|
577
|
+
function _initFingerprintJS() {
|
|
578
|
+
// v4 API — FingerprintJS.load() returns a promise, not a constructor
|
|
579
|
+
// expose both the agent promise and a convenience .get() wrapper
|
|
580
|
+
const FP = root.FingerprintJS;
|
|
581
|
+
if (!FP) { console.warn("[IdiotikMethods] FingerprintJS v4 global not found"); return; }
|
|
582
|
+
const agentPromise = FP.load();
|
|
583
|
+
// convenience wrapper matching common usage patterns
|
|
584
|
+
const fpRef = {
|
|
585
|
+
load: () => agentPromise,
|
|
586
|
+
get: () => agentPromise.then((agent) => agent.get()),
|
|
587
|
+
_agent: agentPromise,
|
|
588
|
+
};
|
|
589
|
+
// kick off a background get so the pipeline is warm
|
|
590
|
+
agentPromise.then((agent) => agent.get()).catch(() => {});
|
|
591
|
+
_register("fingerprintjs", fpRef);
|
|
592
|
+
}
|
|
593
|
+
|
|
555
594
|
// ----------------------------------------------------------------
|
|
556
595
|
// SCRIPT LOADER — load as classic <script> (no type=module)
|
|
557
596
|
// so everything lands on the shared window. with cdnjs/unpkg fallback.
|
|
@@ -662,15 +701,13 @@
|
|
|
662
701
|
}
|
|
663
702
|
|
|
664
703
|
function _resolveSwUrl(type) {
|
|
665
|
-
//
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
}
|
|
673
|
-
return type === "fallback" ? "/sw-fallback.js" : "/sw.js";
|
|
704
|
+
// SW must be same-origin — always resolve relative to the page, not the script src.
|
|
705
|
+
// CDN-hosted scripts (unpkg, cdnjs, jsdelivr) would produce a cross-origin SW url
|
|
706
|
+
// which browsers hard-block with a SecurityError. page-relative is always safe.
|
|
707
|
+
const swFile = type === "fallback" ? "sw-fallback.js" : "sw.js";
|
|
708
|
+
// use the page's current directory (works for both root and subpath deployments)
|
|
709
|
+
const pagePath = window.location.pathname.substring(0, window.location.pathname.lastIndexOf("/") + 1);
|
|
710
|
+
return pagePath + swFile;
|
|
674
711
|
}
|
|
675
712
|
|
|
676
713
|
function _waitForSWActive(reg) {
|
|
@@ -721,7 +758,7 @@
|
|
|
721
758
|
"Papa", "XLSX", "marked", "DOMPurify", "Fuse", "lunr",
|
|
722
759
|
"CryptoJS", "forge", "videojs", "RecordRTC", "Matter", "planck",
|
|
723
760
|
"Navigo", "page", "Comlink", "idb", "localforage",
|
|
724
|
-
"
|
|
761
|
+
"FingerprintJS", "QRCode", "ZXing", "Tesseract", "ml5", "tf",
|
|
725
762
|
];
|
|
726
763
|
|
|
727
764
|
// map from global key → methods key
|
|
@@ -730,7 +767,7 @@
|
|
|
730
767
|
Chart: "chartjs", Tone: "tone", Howl: "howler", WaveSurfer: "wavesurfer",
|
|
731
768
|
io: "socketio", _: "lodash", math: "mathjs", R: "ramda",
|
|
732
769
|
jQuery: "jquery", $: "jquery", Swal: "sweetalert2", Papa: "papaparse",
|
|
733
|
-
ZXing: "zxing",
|
|
770
|
+
ZXing: "zxing", FingerprintJS: "fingerprintjs", tf: "tensorflow",
|
|
734
771
|
};
|
|
735
772
|
|
|
736
773
|
WATCH_KEYS.forEach((key) => {
|