File tree Expand file tree Collapse file tree 1 file changed +46
-3
lines changed Expand file tree Collapse file tree 1 file changed +46
-3
lines changed Original file line number Diff line number Diff line change @@ -363,6 +363,39 @@ const reduce = ImageBlobReduce({
363
363
364
364
let user ;
365
365
let broadcastChannel ;
366
+ const clientSupportsES2022 = ( ( ) => {
367
+ try {
368
+ // Check Object.hasOwn (introduced in ES2022)
369
+ // @ts -ignore
370
+ if ( typeof Object . hasOwn !== 'function' ) {
371
+ return false ;
372
+ }
373
+
374
+ // Check Array.prototype.at
375
+ if ( ! Array . prototype . at ) {
376
+ return false ;
377
+ }
378
+
379
+ // Check private fields
380
+ class TestPrivateFields {
381
+ #privateField: boolean ;
382
+ constructor ( ) {
383
+ this . #privateField = true ;
384
+ }
385
+ hasPrivateField ( ) {
386
+ return this . #privateField;
387
+ }
388
+ }
389
+ const instance = new TestPrivateFields ( ) ;
390
+ if ( ! instance . hasPrivateField ( ) ) {
391
+ return false ;
392
+ }
393
+
394
+ return true ;
395
+ } catch ( e ) {
396
+ return false ; // Any failure indicates lack of support
397
+ }
398
+ } ) ( ) ;
366
399
367
400
let forceRefreshCallback : ( ) => { } ;
368
401
@@ -671,9 +704,19 @@ const applicationContext = {
671
704
} ,
672
705
} ) ,
673
706
getPdfJs : async ( ) => {
674
- const pdfjsLib = ( await import ( 'pdfjs-dist' ) ) . default ;
675
- const pdfjsWorker = ( await import ( 'pdfjs-dist/build/pdf.worker.entry' ) )
676
- . default ;
707
+ const pdfjsLib = (
708
+ await import (
709
+ clientSupportsES2022 ? 'pdfjs-dist' : 'pdfjs-dist/legacy/build/pdf'
710
+ )
711
+ ) . default ;
712
+ const pdfjsWorker = (
713
+ await import (
714
+ clientSupportsES2022
715
+ ? 'pdfjs-dist/build/pdf.worker.entry'
716
+ : 'pdfjs-dist/legacy/build/pdf.worker.entry'
717
+ )
718
+ ) . default ;
719
+
677
720
pdfjsLib . GlobalWorkerOptions . workerSrc = pdfjsWorker ;
678
721
return pdfjsLib ;
679
722
} ,
You can’t perform that action at this time.
0 commit comments