David PHAM-VAN

Add compatibility with web 1.1.0

@@ -33,7 +33,7 @@ jobs: @@ -33,7 +33,7 @@ jobs:
33 - name: Run readme tests 33 - name: Run readme tests
34 run: make test-readme 34 run: make test-readme
35 - name: Verify that nothing changed 35 - name: Verify that nothing changed
36 - run: test -z "$(git status --porcelain)" 36 + run: test -z "$(git status --porcelain | tee /dev/stderr)"
37 - name: Push to codecov 37 - name: Push to codecov
38 run: bash <(curl -s https://codecov.io/bash) 38 run: bash <(curl -s https://codecov.io/bash)
39 - name: Prepare build 39 - name: Prepare build
@@ -104,7 +104,7 @@ jobs: @@ -104,7 +104,7 @@ jobs:
104 - name: Run readme tests 104 - name: Run readme tests
105 run: make test-readme 105 run: make test-readme
106 - name: Verify that nothing changed 106 - name: Verify that nothing changed
107 - run: test -z "$(git status --porcelain)" 107 + run: test -z "$(git status --porcelain | tee /dev/stderr)"
108 - name: Push to codecov 108 - name: Push to codecov
109 run: bash <(curl -s https://codecov.io/bash) 109 run: bash <(curl -s https://codecov.io/bash)
110 - name: Prepare build 110 - name: Prepare build
@@ -27,7 +27,9 @@ import 'format/stream.dart'; @@ -27,7 +27,9 @@ import 'format/stream.dart';
27 import 'format/string.dart'; 27 import 'format/string.dart';
28 import 'format/xref.dart'; 28 import 'format/xref.dart';
29 import 'graphic_state.dart'; 29 import 'graphic_state.dart';
30 -import 'io/vm.dart' if (dart.library.js) 'io/js.dart'; 30 +import 'io/na.dart'
  31 + if (dart.library.io) 'io/vm.dart'
  32 + if (dart.library.js_interop) 'io/js.dart';
31 import 'obj/catalog.dart'; 33 import 'obj/catalog.dart';
32 import 'obj/encryption.dart'; 34 import 'obj/encryption.dart';
33 import 'obj/font.dart'; 35 import 'obj/font.dart';
  1 +/*
  2 + * Copyright (C) 2017, David PHAM-VAN <dev.nfet.net@gmail.com>
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +
  17 +import '../format/object_base.dart';
  18 +
  19 +/// Zip compression function
  20 +DeflateCallback defaultDeflate = (List<int> a) => a;
  21 +
  22 +/// Computation function
  23 +Future<R> pdfCompute<R>(Future<R> Function() computation) async {
  24 + await null;
  25 + return computation();
  26 +}
@@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
3 ## 5.13.3 3 ## 5.13.3
4 4
5 - Update gfonts [Minh-Danh] 5 - Update gfonts [Minh-Danh]
  6 +- Add compatibility with web 1.1.0
6 7
7 ## 5.13.2 8 ## 5.13.2
8 9
@@ -129,10 +129,10 @@ class PrintingPlugin extends PrintingPlatform { @@ -129,10 +129,10 @@ class PrintingPlugin extends PrintingPlatform {
129 129
130 // Restore module and exports 130 // Restore module and exports
131 if (module != null) { 131 if (module != null) {
132 - web.window['module'] = module; 132 + web.window.module = module;
133 } 133 }
134 if (exports != null) { 134 if (exports != null) {
135 - web.window['exports'] = exports; 135 + web.window.exports = exports;
136 } 136 }
137 } 137 }
138 138
@@ -192,8 +192,8 @@ class PrintingPlugin extends PrintingPlatform { @@ -192,8 +192,8 @@ class PrintingPlugin extends PrintingPlatform {
192 } 192 }
193 193
194 final userAgent = web.window.navigator.userAgent; 194 final userAgent = web.window.navigator.userAgent;
195 - final isChrome = web.window['chrome'] != null;  
196 - final isSafari = web.window['safari'] != null && 195 + final isChrome = web.window['chrome'].isUndefinedOrNull;
  196 + final isSafari = web.window['safari'].isUndefinedOrNull &&
197 !userAgent.contains(RegExp(r'Version/14\.1\.')); 197 !userAgent.contains(RegExp(r'Version/14\.1\.'));
198 final isMobile = userAgent.contains('Mobile'); 198 final isMobile = userAgent.contains('Mobile');
199 final isFirefox = userAgent.contains('Firefox'); 199 final isFirefox = userAgent.contains('Firefox');
@@ -439,3 +439,8 @@ class _WebPdfRaster extends PdfRaster { @@ -439,3 +439,8 @@ class _WebPdfRaster extends PdfRaster {
439 return png; 439 return png;
440 } 440 }
441 } 441 }
  442 +
  443 +extension _WindowModule on web.Window {
  444 + external set module(js.JSObject? value);
  445 + external set exports(js.JSObject? value);
  446 +}
@@ -15,7 +15,7 @@ @@ -15,7 +15,7 @@
15 */ 15 */
16 16
17 import 'dart:async'; 17 import 'dart:async';
18 -import 'dart:io'; 18 +import 'dart:io' show Platform;
19 import 'dart:typed_data'; 19 import 'dart:typed_data';
20 20
21 import 'callback.dart'; 21 import 'callback.dart';