@nativescript/canvas-polyfill 2.0.0-alpha.5 → 2.0.0-alpha.50

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.
Files changed (54) hide show
  1. package/DOM/Document.d.ts +3 -2
  2. package/DOM/Element.d.ts +3 -3
  3. package/DOM/Element.js +14 -10
  4. package/DOM/Element.js.map +1 -1
  5. package/DOM/HTMLCanvasElement.d.ts +3 -0
  6. package/DOM/HTMLCanvasElement.js +5 -0
  7. package/DOM/HTMLCanvasElement.js.map +1 -1
  8. package/DOM/HTMLImageElement.js +9 -17
  9. package/DOM/HTMLImageElement.js.map +1 -1
  10. package/DOM/HTMLVideoElement.js +10 -20
  11. package/DOM/HTMLVideoElement.js.map +1 -1
  12. package/DOM/Node.d.ts +2 -0
  13. package/DOM/Node.js +15 -0
  14. package/DOM/Node.js.map +1 -1
  15. package/DOM/XMLDocument.d.ts +4 -0
  16. package/DOM/XMLDocument.js +18 -0
  17. package/DOM/XMLDocument.js.map +1 -1
  18. package/LICENSE +201 -0
  19. package/MutationObserver.d.ts +10 -0
  20. package/MutationObserver.js +22 -0
  21. package/MutationObserver.js.map +1 -0
  22. package/URL.android.d.ts +16 -14
  23. package/URL.android.js +293 -42
  24. package/URL.android.js.map +1 -1
  25. package/URL.ios.d.ts +19 -5
  26. package/URL.ios.js +536 -96
  27. package/URL.ios.js.map +1 -1
  28. package/async/file/file.android.js +2 -3
  29. package/async/file/file.android.js.map +1 -1
  30. package/async/file/file.ios.js +26 -39
  31. package/async/file/file.ios.js.map +1 -1
  32. package/async/http/http.android.js +6 -1
  33. package/async/http/http.android.js.map +1 -1
  34. package/async/http/http.ios.js +9 -4
  35. package/async/http/http.ios.js.map +1 -1
  36. package/async/xhr/TNSXMLHttpRequest.js +175 -41
  37. package/async/xhr/TNSXMLHttpRequest.js.map +1 -1
  38. package/index.d.ts +1 -0
  39. package/index.js +8 -0
  40. package/index.js.map +1 -1
  41. package/localStorage.d.ts +2 -0
  42. package/localStorage.js +150 -0
  43. package/localStorage.js.map +1 -0
  44. package/package.json +5 -5
  45. package/performance.js +11 -11
  46. package/performance.js.map +1 -1
  47. package/platforms/android/async-release.aar +0 -0
  48. package/platforms/android/canvas_polyfill.aar +0 -0
  49. package/platforms/android/java/org/nativescript/canvas/polyfill/Utils.java +33 -7
  50. package/resize.js +15 -10
  51. package/resize.js.map +1 -1
  52. package/url-search.d.ts +0 -0
  53. package/url-search.js +343 -0
  54. package/url-search.js.map +1 -0
@@ -0,0 +1,150 @@
1
+ import { File, knownFolders } from '@nativescript/core';
2
+ let file;
3
+ let localStorageTimeout = null;
4
+ const internalSaveData = function (storage) {
5
+ try {
6
+ file.writeText(JSON.stringify(storage._localStorageData));
7
+ }
8
+ catch (err) {
9
+ // This should never happen on normal data, but if they tried to put non JS stuff it won't serialize
10
+ console.log('localStorage: unable to write storage, error: ', err);
11
+ }
12
+ };
13
+ const saveData = function (storage) {
14
+ if (localStorageTimeout !== null) {
15
+ clearTimeout(localStorageTimeout);
16
+ }
17
+ localStorageTimeout = setTimeout(() => {
18
+ internalSaveData(storage);
19
+ }, 250);
20
+ };
21
+ class Storage {
22
+ constructor() {
23
+ this._localStorageData = {};
24
+ }
25
+ getItem(name) {
26
+ if (this._localStorageData.hasOwnProperty(name)) {
27
+ return this._localStorageData[name];
28
+ }
29
+ return null;
30
+ }
31
+ key(id) {
32
+ const keys = Object.keys(this._localStorageData);
33
+ if (id >= keys.length) {
34
+ return null;
35
+ }
36
+ return keys[id];
37
+ }
38
+ setItemObject(name, value) {
39
+ this._localStorageData[name] = value;
40
+ saveData(this);
41
+ }
42
+ // Revamp this to be "String" only
43
+ // https://github.com/NathanaelA/nativescript-localstorage/issues/17
44
+ setItem(name, value) {
45
+ if (value == null) {
46
+ if (value === null) {
47
+ this._localStorageData[name] = 'null';
48
+ }
49
+ else {
50
+ this._localStorageData[name] = 'undefined';
51
+ }
52
+ }
53
+ else {
54
+ this._localStorageData[name] = value.toString();
55
+ }
56
+ saveData(this);
57
+ }
58
+ removeItem(name) {
59
+ if (this._localStorageData[name]) {
60
+ delete this._localStorageData[name];
61
+ saveData(this);
62
+ }
63
+ }
64
+ clear() {
65
+ this._localStorageData = {};
66
+ saveData(this);
67
+ }
68
+ get length() {
69
+ return Object.keys(this._localStorageData).length;
70
+ }
71
+ }
72
+ class SessionStorage {
73
+ constructor() {
74
+ this._storage = new Map();
75
+ }
76
+ getItem(name) {
77
+ return this._storage.get(name) ?? null;
78
+ }
79
+ key(id) {
80
+ const keys = Array.from(this._storage.keys());
81
+ if (id >= keys.length) {
82
+ return null;
83
+ }
84
+ return keys[id];
85
+ }
86
+ setItemObject(name, value) {
87
+ this._storage.set(name, value);
88
+ }
89
+ setItem(name, value) {
90
+ if (value == null) {
91
+ if (value === null) {
92
+ this._storage.set(name, 'null');
93
+ }
94
+ else {
95
+ this._storage.set(name, 'undefined');
96
+ }
97
+ }
98
+ else {
99
+ this._storage.set(name, value.toString());
100
+ }
101
+ }
102
+ removeItem(name) {
103
+ this._storage.delete(name);
104
+ }
105
+ clear() {
106
+ this._storage.clear();
107
+ }
108
+ get length() {
109
+ return this._storage.size;
110
+ }
111
+ }
112
+ if (!global.Storage) {
113
+ global.Storage = Storage;
114
+ }
115
+ if (!global.localStorage || module.hot) {
116
+ const path = knownFolders.documents().path + '/localStorage.db';
117
+ file = File.fromPath(path);
118
+ localStorageTimeout = null;
119
+ const loadData = function (storage) {
120
+ if (!File.exists(path)) {
121
+ return;
122
+ }
123
+ let data;
124
+ if (file.size === 0) {
125
+ return;
126
+ }
127
+ try {
128
+ let textData = file.readTextSync();
129
+ data = JSON.parse(textData);
130
+ storage._localStorageData = data;
131
+ }
132
+ catch (err) {
133
+ console.log('localStorage: error reading storage, Error: ', err);
134
+ }
135
+ };
136
+ const storage = new Storage();
137
+ loadData(storage);
138
+ global.localStorage = storage;
139
+ }
140
+ if (!global.sessionStorage) {
141
+ global.sessionStorage = new SessionStorage();
142
+ }
143
+ export default global.localStorage;
144
+ if (module.hot) {
145
+ module.hot.accept();
146
+ module.hot.dispose(() => {
147
+ global.localStorage = undefined;
148
+ });
149
+ }
150
+ //# sourceMappingURL=localStorage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localStorage.js","sourceRoot":"","sources":["../../../packages/canvas-polyfill/localStorage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAExD,IAAI,IAAU,CAAC;AACf,IAAI,mBAAmB,GAAG,IAAI,CAAC;AAE/B,MAAM,gBAAgB,GAAG,UAAU,OAAgB;IAClD,IAAI;QACH,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC;KAC1D;IAAC,OAAO,GAAG,EAAE;QACb,oGAAoG;QACpG,OAAO,CAAC,GAAG,CAAC,gDAAgD,EAAE,GAAG,CAAC,CAAC;KACnE;AACF,CAAC,CAAC;AAEF,MAAM,QAAQ,GAAG,UAAU,OAAgB;IAC1C,IAAI,mBAAmB,KAAK,IAAI,EAAE;QACjC,YAAY,CAAC,mBAAmB,CAAC,CAAC;KAClC;IACD,mBAAmB,GAAG,UAAU,CAAC,GAAG,EAAE;QACrC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC,EAAE,GAAG,CAAC,CAAC;AACT,CAAC,CAAC;AAEF,MAAM,OAAO;IAAb;QACC,sBAAiB,GAAG,EAAE,CAAC;IAgDxB,CAAC;IA/CA,OAAO,CAAC,IAAI;QACX,IAAI,IAAI,CAAC,iBAAiB,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE;YAChD,OAAO,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;SACpC;QACD,OAAO,IAAI,CAAC;IACb,CAAC;IACD,GAAG,CAAC,EAAE;QACL,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,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ript/canvas-polyfill",
3
- "version": "2.0.0-alpha.5",
3
+ "version": "2.0.0-alpha.50",
4
4
  "description": "Polyfill for making NativeScript compatible with web libs like pixi.js, three.js, phaser.js, babylon.js, etc....",
5
5
  "main": "index",
6
6
  "typings": "index.d.ts",
@@ -33,10 +33,10 @@
33
33
  "readmeFilename": "README.md",
34
34
  "bootstrapper": "@nativescript/plugin-seed",
35
35
  "dependencies": {
36
+ "@nativescript/canvas": "alpha",
37
+ "@nativescript/canvas-media": "alpha",
38
+ "query-selector": "2.0.0",
36
39
  "xmldom": "~0.6.0"
37
40
  },
38
- "peerDependencies": {
39
- "@nativescript/canvas": "2.0.0-alpha.5",
40
- "@nativescript/canvas-media": "2.0.0-alpha.5"
41
- }
41
+ "types": "./index.d.ts"
42
42
  }
package/performance.js CHANGED
@@ -26,9 +26,9 @@ if (!global.performance || !global.performance.now) {
26
26
  },
27
27
  now() {
28
28
  if (global.isIOS) {
29
- return CACurrentMediaTime() * 1000;
29
+ return performance.now();
30
30
  }
31
- return java.lang.System.nanoTime() / 1000000;
31
+ return __time();
32
32
  },
33
33
  toJSON() {
34
34
  return {
@@ -47,33 +47,33 @@ if (!global.performance || !global.performance.now) {
47
47
  usedJSHeapSize: -1,
48
48
  },
49
49
  measure() {
50
- console.warn("window.performance.measure is not implemented");
50
+ console.warn('window.performance.measure is not implemented');
51
51
  },
52
52
  mark() {
53
- console.warn("window.performance.mark is not implemented");
53
+ console.warn('window.performance.mark is not implemented');
54
54
  },
55
55
  clearMeasures() {
56
- console.warn("window.performance.clearMeasures is not implemented");
56
+ console.warn('window.performance.clearMeasures is not implemented');
57
57
  },
58
58
  clearMarks() {
59
- console.warn("window.performance.clearMarks is not implemented");
59
+ console.warn('window.performance.clearMarks is not implemented');
60
60
  },
61
61
  clearResourceTimings() {
62
- console.warn("window.performance.clearResourceTimings is not implemented");
62
+ console.warn('window.performance.clearResourceTimings is not implemented');
63
63
  },
64
64
  setResourceTimingBufferSize() {
65
- console.warn("window.performance.setResourceTimingBufferSize is not implemented");
65
+ console.warn('window.performance.setResourceTimingBufferSize is not implemented');
66
66
  },
67
67
  getEntriesByType() {
68
- console.warn("window.performance.getEntriesByType is not implemented");
68
+ console.warn('window.performance.getEntriesByType is not implemented');
69
69
  return [];
70
70
  },
71
71
  getEntriesByName() {
72
- console.warn("window.performance.getEntriesByName is not implemented");
72
+ console.warn('window.performance.getEntriesByName is not implemented');
73
73
  return [];
74
74
  },
75
75
  getEntries() {
76
- console.warn("window.performance.getEntries is not implemented");
76
+ console.warn('window.performance.getEntries is not implemented');
77
77
  },
78
78
  };
79
79
  }
@@ -1 +1 @@
1
- {"version":3,"file":"performance.js","sourceRoot":"","sources":["../../../packages/canvas-polyfill/performance.ts"],"names":[],"mappings":"AAAA,IAAI,CAAE,MAAc,CAAC,WAAW,IAAI,CAAE,MAAc,CAAC,WAAW,CAAC,GAAG,EAAE;IACjE,MAAc,CAAC,WAAW,GAAG;QAC1B,UAAU,EAAE,CAAC,CAAC;QACd,MAAM,EAAE;YACJ,UAAU,EAAE,CAAC,CAAC;YACd,YAAY,EAAE,CAAC,CAAC;YAChB,WAAW,EAAE,CAAC,CAAC;YACf,wBAAwB,EAAE,CAAC,CAAC;YAC5B,0BAA0B,EAAE,CAAC,CAAC;YAC9B,cAAc,EAAE,CAAC,CAAC;YAClB,UAAU,EAAE,CAAC,CAAC;YACd,eAAe,EAAE,CAAC,CAAC;YACnB,iBAAiB,EAAE,CAAC,CAAC;YACrB,UAAU,EAAE,CAAC,CAAC;YACd,YAAY,EAAE,CAAC,CAAC;YAChB,cAAc,EAAE,CAAC,CAAC;YAClB,eAAe,EAAE,CAAC,CAAC;YACnB,WAAW,EAAE,CAAC,CAAC;YACf,aAAa,EAAE,CAAC,CAAC;YACjB,YAAY,EAAE,CAAC,CAAC;YAChB,WAAW,EAAE,CAAC,CAAC;YACf,aAAa,EAAE,CAAC,CAAC;YACjB,qBAAqB,EAAE,CAAC,CAAC;YACzB,cAAc,EAAE,CAAC,CA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O,CAAC,IAAI,CAAC,kDAAkD,CAAC,CAAC;QACrE,CAAC;KACJ,CAAC;CACL"}
1
+ {"version":3,"file":"performance.js","sourceRoot":"","sources":["../../../packages/canvas-polyfill/performance.ts"],"names":[],"mappings":"AAAA,IAAI,CAAE,MAAc,CAAC,WAAW,IAAI,CAAE,MAAc,CAAC,WAAW,CAAC,GAAG,EAAE;IACpE,MAAc,CAAC,WAAW,GAAG;QAC7B,UAAU,EAAE,CAAC,CAAC;QACd,MAAM,EAAE;YACP,UAAU,EAAE,CAAC,CAAC;YACd,YAAY,EAAE,CAAC,CAAC;YAChB,WAAW,EAAE,CAAC,CAAC;YACf,wBAAwB,EAAE,CAAC,CAAC;YAC5B,0BAA0B,EAAE,CAAC,CAAC;YAC9B,cAAc,EAAE,CAAC,CAAC;YAClB,UAAU,EAAE,CAAC,CAAC;YACd,eAAe,EAAE,CAAC,CAAC;YACnB,iBAAiB,EAAE,CAAC,CAAC;YACrB,UAAU,EAAE,CAAC,CAAC;YACd,YAAY,EAAE,CAAC,CAAC;YAChB,cAAc,EAAE,CAAC,CAAC;YAClB,eAAe,EAAE,CAAC,CAAC;YACnB,WAAW,EAAE,CAAC,CAAC;YACf,aAAa,EAAE,CAAC,CAAC;YACjB,YAAY,EAAE,CAAC,CAAC;YAChB,WAAW,EAAE,CAAC,CAAC;YACf,aAAa,EAAE,CAAC,CAAC;YACjB,qBAAqB,EAAE,CAAC,CAAC;YACzB,cAAc,EAAE,CAAC,CAAC;YAClB,gBAAgB,EAAE,CAAC,CAAC;SACpB;QACD,GAAG;YACF,IAAI,MAAM,CAAC,KAAK,EAAE;gBACjB,OAAO,WAAW,CAAC,GAAG,EAAE,CAAC;aACzB;YAED,OAAO,MAAM,EAAE,CAAC;QACjB,CAAC;QACD,MAAM;YACL,OAAO;gBACN,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,UAAU,EAAE,IAAI,CAAC,UAAU;gBAC3B,UAAU,EAAE,IAAI,CAAC,UAAU;aAC3B,CAAC;QACH,CAAC;QACD,UAAU,EAAE;YACX,aAAa,EAAE,CAAC,CAAC;YACjB,IAAI,EAAE,CAAC,CAAC;SACR;QACD,MAAM,EAAE;YACP,eAAe,EAAE,CAAC,CAAC;YACnB,eAAe,EAAE,CAAC,CAAC;YACnB,cAAc,EAAE,CAAC,CAAC;SAClB;QACD,OAAO;YACN,OAAO,CAAC,IAAI,CAAC,+CAA+C,CAAC,CAAC;QAC/D,CAAC;QACD,IAAI;YACH,OAAO,CAAC,IAAI,CAAC,4CAA4C,CAAC,CAAC;QAC5D,CAAC;QACD,aAAa;YACZ,OAAO,CAAC,IAAI,CAAC,qDAAqD,CAAC,CAAC;QACrE,CAAC;QACD,UAAU;YACT,OAAO,CAAC,IAAI,CAAC,kDAAkD,CAAC,CAAC;QAClE,CAAC;QACD,oBAAoB;YACnB,OAAO,CAAC,IAAI,CAAC,4DAA4D,CAAC,CAAC;QAC5E,CAAC;QACD,2BAA2B;YAC1B,OAAO,CAAC,IAAI,CAAC,mEAAmE,CAAC,CAAC;QACnF,CAAC;QACD,gBAAgB;YACf,OAAO,CAAC,IAAI,CAAC,wDAAwD,CAAC,CAAC;YACvE,OAAO,EAAE,CAAC;QACX,CAAC;QACD,gBAAgB;YACf,OAAO,CAAC,IAAI,CAAC,wDAAwD,CAAC,CAAC;YACvE,OAAO,EAAE,CAAC;QACX,CAAC;QACD,UAAU;YACT,OAAO,CAAC,IAAI,CAAC,kDAAkD,CAAC,CAAC;QAClE,CAAC;KACD,CAAC;CACF"}
Binary file
@@ -29,25 +29,38 @@ public class Utils {
29
29
  buffer.position(position);
30
30
  }
31
31
 
32
-
33
- public static String createObjectURL(Context context, ByteBuffer buffer, int position, String mime) throws IOException {
32
+ public static String createObjectURL(Context context, ByteBuffer buffer, int position, String mime, String extension) throws IOException {
34
33
  String id = UUID.randomUUID().toString();
34
+ createObjectURLWithURL(context, BLOB_PATH + id, buffer, position, mime, extension);
35
+ return BLOB_PATH + id;
36
+ }
37
+
38
+ public static void createObjectURLWithURL(Context context, String url, ByteBuffer buffer, int position, String mime, String extension) throws IOException {
39
+ String id = url.replace(BLOB_PATH, "");
35
40
  File blob_root = new File(context.getFilesDir(), BLOB_DIR);
36
41
  if (!blob_root.exists()) {
37
42
  blob_root.mkdirs();
38
43
  }
39
44
 
40
- // todo get type from magic bytes
41
- String ext = MimeTypeMap.getSingleton().getExtensionFromMimeType(mime);
42
45
  String fileName = id;
43
- if (ext != null) {
44
- fileName = id + "." + ext;
46
+ if (extension != null) {
47
+ fileName = id + "." + extension;
48
+ } else {
49
+ // todo get type from magic bytes
50
+ String ext = MimeTypeMap.getSingleton().getExtensionFromMimeType(mime);
51
+ if (ext != null) {
52
+ fileName = id + "." + ext;
53
+ }
45
54
  }
46
55
 
47
56
  org.nativescript.canvas.polyfill.Utils.writeBytes(buffer, position, new File(blob_root, fileName).getAbsolutePath());
48
57
 
49
58
  putItem(context, id, fileName);
50
- return BLOB_PATH + id;
59
+ }
60
+
61
+ public static String getItemOrCreateAndReturn(Context context, String url, ByteBuffer buffer, int position, String mime, String extension) throws IOException {
62
+ createObjectURLWithURL(context, url, buffer, position, mime, extension);
63
+ return getPath(context, url);
51
64
  }
52
65
 
53
66
  public static void revokeObjectURL(Context context, String url) {
@@ -73,6 +86,7 @@ public class Utils {
73
86
  return "";
74
87
  }
75
88
 
89
+
76
90
  public static void putItem(Context context, String key, String value) {
77
91
  SharedPreferences sharedPreferences = context.getSharedPreferences(BLOB_KEYS, Context.MODE_PRIVATE);
78
92
  sharedPreferences.edit().putString(key, value).commit();
@@ -92,6 +106,18 @@ public class Utils {
92
106
 
93
107
  public static void deleteItem(Context context, String key) {
94
108
  if (key != null) {
109
+ File blob_root = new File(context.getFilesDir(), BLOB_DIR);
110
+ SharedPreferences sharedPreferences = context.getSharedPreferences(BLOB_KEYS, Context.MODE_PRIVATE);
111
+
112
+ String fileName = sharedPreferences.getString(key, null);
113
+
114
+ if (fileName != null) {
115
+ File file = new File(blob_root, fileName);
116
+ try {
117
+ file.delete();
118
+ } catch (Exception ignored) {
119
+ }
120
+ }
95
121
  putItem(context, key, null);
96
122
  }
97
123
  }
package/resize.js CHANGED
@@ -4,21 +4,26 @@ import { Application } from '@nativescript/core';
4
4
  Window Resize Stub
5
5
  */
6
6
  const scale = Screen.mainScreen.scale;
7
- const width = Screen.mainScreen.widthPixels;
8
- const height = Screen.mainScreen.heightPixels;
9
- global.window.devicePixelRatio = global.devicePixelRatio = 1;
10
- global.window.innerWidth = global.innerWidth = width;
11
- global.window.clientWidth = global.clientWidth = width;
12
- global.window.innerHeight = global.innerHeight = height;
13
- global.window.clientHeight = global.clientHeight = height;
7
+ // const screenWidth = Screen.mainScreen.widthPixels;
8
+ // const screenHeight = Screen.mainScreen.heightPixels;
9
+ const screenWidth = Screen.mainScreen.widthDIPs;
10
+ const screenHeight = Screen.mainScreen.heightDIPs;
11
+ global.window.devicePixelRatio = global.devicePixelRatio = scale; //1;
12
+ global.window.innerWidth = global.innerWidth = screenWidth;
13
+ global.window.clientWidth = global.clientWidth = screenWidth;
14
+ global.window.innerHeight = global.innerHeight = screenHeight;
15
+ global.window.clientHeight = global.clientHeight = screenHeight;
14
16
  global.window.screen = global.screen = global.screen || {};
15
17
  global.window.screen.orientation = global.screen.orientation = global.screen.orientation || global.clientWidth < global.clientHeight ? 0 : 90;
16
18
  if (!global.__TNS_BROWSER_POLYFILL_RESIZE) {
17
19
  global.__TNS_BROWSER_POLYFILL_RESIZE = true;
18
20
  Application.on(Application.orientationChangedEvent, (args) => {
19
- const width = Screen.mainScreen.widthPixels;
20
- const height = Screen.mainScreen.heightDIPs;
21
- global.window.devicePixelRatio = global.devicePixelRatio = 1;
21
+ // const width = Screen.mainScreen.widthPixels;
22
+ // const height = Screen.mainScreen.heightPixels;
23
+ const portrait = args.newValue === 'portrait';
24
+ const width = portrait ? screenWidth : screenHeight;
25
+ const height = portrait ? screenHeight : screenWidth;
26
+ global.window.devicePixelRatio = global.devicePixelRatio = scale; //1;
22
27
  global.window.innerWidth = global.innerWidth = width;
23
28
  global.window.clientWidth = global.clientWidth = width;
24
29
  global.window.innerHeight = global.innerHeight = height;
package/resize.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"resize.js","sourceRoot":"","sources":["../../../packages/canvas-polyfill/resize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAC,WAAW,EAAC,MAAM,oBAAoB,CAAC;AAC/C;;EAEE;AAEF,MAAM,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC;AACtC,MAAM,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC;AAC5C,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC;AAC7C,MAAc,CAAC,MAAM,CAAC,gBAAgB,GAAI,MAAc,CAAC,gBAAgB,GAAG,CAAC,CAAC;AAC9E,MAAc,CAAC,MAAM,CAAC,UAAU,GAAI,MAAc,CAAC,UAAU,GAAG,KAAK,CAAC;AACtE,MAAc,CAAC,MAAM,CAAC,WAAW,GAAI,MAAc,CAAC,WAAW,GAAG,KAAK,CAAC;AACxE,MAAc,CAAC,MAAM,CAAC,WAAW,GAAI,MAAc,CAAC,WAAW,GAAG,MAAM,CAAC;AACzE,MAAc,CAAC,MAAM,CAAC,YAAY,GAAI,MAAc,CAAC,YAAY,GAAG,MAAM,CAAC;AAC3E,MAAc,CAAC,MAAM,CAAC,MAAM,GAAI,MAAc,CAAC,MAAM,GAAI,MAAc,CAAC,MAAM,IAAI,EAAE,CAAC;AACrF,MAAc,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,GAAI,MAAc,CAAC,MAAM,CAAC,WAAW,GAAI,MAAc,CAAC,MAAM,CAAC,WAAW,IAAK,MAAc,CAAC,WAAW,GAAI,MAAc,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAC3L,IAAI,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