David PHAM-VAN

Fix web builds with Flutter 3.10

@@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
3 ## 5.11.0 3 ## 5.11.0
4 4
5 - Set Flutter 3.10 as the minimum version 5 - Set Flutter 3.10 as the minimum version
  6 +- Fix web builds with Flutter 3.10
6 7
7 ## 5.10.4 8 ## 5.10.4
8 9
@@ -67,6 +67,8 @@ class PrintingPlugin extends PrintingPlatform { @@ -67,6 +67,8 @@ class PrintingPlugin extends PrintingPlatform {
67 if (!_hasPdfJsLib) { 67 if (!_hasPdfJsLib) {
68 dynamic amd; 68 dynamic amd;
69 dynamic define; 69 dynamic define;
  70 + dynamic module;
  71 + dynamic exports;
70 if (js.context['define'] != null) { 72 if (js.context['define'] != null) {
71 // In dev, requireJs is loaded in. Disable it here. 73 // In dev, requireJs is loaded in. Disable it here.
72 define = js.JsObject.fromBrowserObject(js.context['define']); 74 define = js.JsObject.fromBrowserObject(js.context['define']);
@@ -74,6 +76,17 @@ class PrintingPlugin extends PrintingPlatform { @@ -74,6 +76,17 @@ class PrintingPlugin extends PrintingPlatform {
74 define['amd'] = false; 76 define['amd'] = false;
75 } 77 }
76 78
  79 + // Save Webpack values and make typeof module != object
  80 + if (js.context['exports'] != null) {
  81 + exports = js.JsObject.fromBrowserObject(js.context['exports']);
  82 + }
  83 + js.context['exports'] = 0;
  84 +
  85 + if (js.context['module'] != null) {
  86 + module = js.JsObject.fromBrowserObject(js.context['module']);
  87 + }
  88 + js.context['module'] = 0;
  89 +
77 final script = ScriptElement() 90 final script = ScriptElement()
78 ..type = 'text/javascript' 91 ..type = 'text/javascript'
79 ..async = true 92 ..async = true
@@ -89,6 +102,14 @@ class PrintingPlugin extends PrintingPlatform { @@ -89,6 +102,14 @@ class PrintingPlugin extends PrintingPlatform {
89 102
90 js.context['pdfjsLib']['GlobalWorkerOptions']['workerSrc'] = 103 js.context['pdfjsLib']['GlobalWorkerOptions']['workerSrc'] =
91 '$_pdfJsUrlBase/build/pdf.worker.min.js'; 104 '$_pdfJsUrlBase/build/pdf.worker.min.js';
  105 +
  106 + // Restore module and exports
  107 + if (module != null) {
  108 + js.context['module'] = module;
  109 + }
  110 + if (exports != null) {
  111 + js.context['exports'] = exports;
  112 + }
92 } 113 }
93 114
94 _loading.release(); 115 _loading.release();