Skip to content

Commit 9203636

Browse files
committed
chore: format
1 parent a2e6bd8 commit 9203636

File tree

2 files changed

+50
-101
lines changed

2 files changed

+50
-101
lines changed

packages/canvas-polyfill/URL.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import {knownFolders, File as NSFile, isIOS, path} from '@nativescript/core';
2-
import {FileManager} from './async/async'
1+
import { knownFolders, File as NSFile, isIOS, path } from '@nativescript/core';
32

43
export class URL {
54
public static createObjectURL(object: any): string {
@@ -10,9 +9,7 @@ export class URL {
109
NSFile.fromPath(filePath).writeSync(NSData.dataWithData(buf));
1110
} else {
1211
try {
13-
const fos = new java.io.FileOutputStream(
14-
new java.io.File(filePath)
15-
);
12+
const fos = new java.io.FileOutputStream(new java.io.File(filePath));
1613
fos.write(Array.from(buf) as any);
1714
fos.flush();
1815
fos.close();
@@ -25,11 +22,11 @@ export class URL {
2522
return null;
2623
}
2724

28-
public static revokeObjectURL(url: string){
29-
if(typeof url === 'string'){
30-
if(NSFile.exists(url)){
25+
public static revokeObjectURL(url: string) {
26+
if (typeof url === 'string') {
27+
if (NSFile.exists(url)) {
3128
const file = NSFile.fromPath(url);
32-
file.removeSync()
29+
file.removeSync();
3330
}
3431
}
3532
}
@@ -38,6 +35,6 @@ export class URL {
3835
if (isIOS) {
3936
return NSUUID.UUID().UUIDString;
4037
}
41-
return java.util.UUID.randomUUID().toString()
38+
return java.util.UUID.randomUUID().toString();
4239
}
4340
}

packages/canvas-polyfill/window.ts

Lines changed: 43 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,40 @@
1-
import {Document} from "./DOM/Document";
2-
import "./performance";
3-
import {HTMLImageElement} from "./DOM/HTMLImageElement";
4-
import {HTMLCanvasElement} from "./DOM/HTMLCanvasElement";
5-
import {HTMLVideoElement} from "./DOM/HTMLVideoElement";
6-
import {XMLDocument} from './DOM/XMLDocument';
7-
import {Device, fromObject, Application, View} from "@nativescript/core";
8-
import {
9-
CanvasRenderingContext2D,
10-
WebGLRenderingContext,
11-
WebGL2RenderingContext
12-
} from "@nativescript/canvas";
1+
import { Document } from './DOM/Document';
2+
import './performance';
3+
import { HTMLImageElement } from './DOM/HTMLImageElement';
4+
import { HTMLCanvasElement } from './DOM/HTMLCanvasElement';
135
import { HTMLVideoElement } from './DOM/HTMLVideoElement';
146
import { XMLDocument } from './DOM/XMLDocument';
157
import { Device, fromObject, View } from '@nativescript/core';
168
import { CanvasRenderingContext2D, WebGLRenderingContext, WebGL2RenderingContext } from '@nativescript/canvas';
179

18-
(global as any).WEBGL_RENDERER = "true";
10+
(global as any).CANVAS_RENDERER = 'true';
11+
(global as any).WEBGL_RENDERER = 'true';
1912
(global as any).window = (global as any).window || {
2013
console: console,
21-
WEBGL_RENDERER: "true",
22-
CANVAS_RENDERER: "true"
14+
WEBGL_RENDERER: 'true',
15+
CANVAS_RENDERER: 'true',
2316
};
24-
(global as any).window.self = (global as any).self =
25-
(global as any).self || window;
26-
(global as any).window.HTMLImageElement = (global as any).HTMLImageElement =
27-
(global as any).HTMLImageElement || HTMLImageElement;
28-
(global as any).window.Image = (global as any).Image =
29-
(global as any).Image || HTMLImageElement;
30-
(global as any).window.ImageBitmap = (global as any).ImageBitmap =
31-
(global as any).ImageBitmap || HTMLImageElement;
32-
(global as any).window.HTMLVideoElement = (global as any).HTMLVideoElement =
33-
(global as any).HTMLVideoElement || HTMLVideoElement;
34-
(global as any).window.Video = (global as any).Video =
35-
(global as any).Video || HTMLVideoElement;
36-
(global as any).window.HTMLCanvasElement = (global as any).HTMLCanvasElement =
37-
(global as any).HTMLCanvasElement || HTMLCanvasElement;
38-
(global as any).window.Canvas = (global as any).Canvas =
39-
(global as any).Canvas || HTMLCanvasElement;
40-
(global as any).window.CanvasRenderingContext2D = (global as any).CanvasRenderingContext2D =
41-
(global as any).CanvasRenderingContext2D || CanvasRenderingContext2D;
42-
(global as any).window.WebGLRenderingContext = (global as any).WebGLRenderingContext =
43-
(global as any).WebGLRenderingContext || WebGLRenderingContext;
44-
(global as any).window.WebGL2RenderingContext = (global as any).WebGL2RenderingContext =
45-
(global as any).WebGL2RenderingContext || WebGL2RenderingContext;
17+
(global as any).window.self = (global as any).self = (global as any).self || window;
18+
(global as any).window.HTMLImageElement = (global as any).HTMLImageElement = (global as any).HTMLImageElement || HTMLImageElement;
19+
(global as any).window.Image = (global as any).Image = (global as any).Image || HTMLImageElement;
20+
(global as any).window.ImageBitmap = (global as any).ImageBitmap = (global as any).ImageBitmap || HTMLImageElement;
21+
(global as any).window.HTMLVideoElement = (global as any).HTMLVideoElement = (global as any).HTMLVideoElement || HTMLVideoElement;
22+
(global as any).window.Video = (global as any).Video = (global as any).Video || HTMLVideoElement;
23+
(global as any).window.HTMLCanvasElement = (global as any).HTMLCanvasElement = (global as any).HTMLCanvasElement || HTMLCanvasElement;
24+
(global as any).window.Canvas = (global as any).Canvas = (global as any).Canvas || HTMLCanvasElement;
25+
(global as any).window.CanvasRenderingContext2D = (global as any).CanvasRenderingContext2D = (global as any).CanvasRenderingContext2D || CanvasRenderingContext2D;
26+
(global as any).window.WebGLRenderingContext = (global as any).WebGLRenderingContext = (global as any).WebGLRenderingContext || WebGLRenderingContext;
27+
(global as any).window.WebGL2RenderingContext = (global as any).WebGL2RenderingContext = (global as any).WebGL2RenderingContext || WebGL2RenderingContext;
4628

4729
function checkEmitter() {
48-
if (
49-
!(global as any).emitter ||
50-
!(
51-
(global as any).emitter.on ||
52-
(global as any).emitter.addEventListener ||
53-
(global as any).emitter.addListener
54-
)
55-
) {
56-
(global as any).window.emitter = (global as any).emitter = fromObject(
57-
{}
58-
);
30+
if (!(global as any).emitter || !((global as any).emitter.on || (global as any).emitter.addEventListener || (global as any).emitter.addListener)) {
31+
(global as any).window.emitter = (global as any).emitter = fromObject({});
5932
}
6033
}
6134

62-
(global as any).window.scrollTo = (global as any).scrollTo =
63-
(global as any).scrollTo || (() => ({}));
35+
(global as any).window.scrollTo = (global as any).scrollTo = (global as any).scrollTo || (() => ({}));
6436

65-
(global as any).window.addEventListener = (global as any).addEventListener = (
66-
eventName,
67-
listener
68-
) => {
37+
(global as any).window.addEventListener = (global as any).addEventListener = (eventName, listener) => {
6938
checkEmitter();
7039
const addListener = () => {
7140
if ((global as any).emitter.on) {
@@ -79,19 +48,16 @@ function checkEmitter() {
7948

8049
addListener();
8150

82-
if (eventName.toLowerCase() === "load") {
51+
if (eventName.toLowerCase() === 'load') {
8352
if ((global as any).emitter && (global as any).emitter.emit) {
8453
setTimeout(() => {
85-
(global as any).emitter.emit("load");
54+
(global as any).emitter.emit('load');
8655
}, 1);
8756
}
8857
}
8958
};
9059

91-
(global as any).window.removeEventListener = (global as any).removeEventListener = (
92-
eventName,
93-
listener
94-
) => {
60+
(global as any).window.removeEventListener = (global as any).removeEventListener = (eventName, listener) => {
9561
checkEmitter();
9662
if ((global as any).emitter.off) {
9763
(global as any).emitter.off(eventName, listener);
@@ -106,43 +72,30 @@ function checkEmitter() {
10672

10773
(global as any).window.XMLDocument = (global as any).XMLDocument = XMLDocument;
10874

109-
const agent = "chrome";
110-
(global as any).window.navigator = (global as any).navigator =
111-
(global as any).navigator || {};
112-
(global as any).window.userAgent = (global as any).userAgent =
113-
(global as any).userAgent || agent;
114-
(global as any).window.navigator.userAgent = (global as any).navigator.userAgent =
115-
(global as any).navigator.userAgent || agent;
116-
(global as any).window.navigator.product = (global as any).navigator.product =
117-
"NativeScript";
118-
(global as any).window.navigator.platform = (global as any).navigator.platform =
119-
(global as any).navigator.platform || [];
120-
(global as any).window.navigator.appVersion = (global as any).navigator.appVersion =
121-
(global as any).navigator.appVersion || Device.osVersion;
122-
(global as any).window.navigator.maxTouchPoints = (global as any).navigator.maxTouchPoints =
123-
(global as any).navigator.maxTouchPoints || 5;
124-
(global as any).window.navigator.standalone = (global as any).navigator.standalone =
125-
(global as any).navigator.standalone === null
126-
? true
127-
: (global as any).navigator.standalone;
75+
const agent = 'chrome';
76+
(global as any).window.navigator = (global as any).navigator = (global as any).navigator || {};
77+
(global as any).window.userAgent = (global as any).userAgent = (global as any).userAgent || agent;
78+
(global as any).window.navigator.userAgent = (global as any).navigator.userAgent = (global as any).navigator.userAgent || agent;
79+
(global as any).window.navigator.product = (global as any).navigator.product = 'NativeScript';
80+
(global as any).window.navigator.platform = (global as any).navigator.platform = (global as any).navigator.platform || [];
81+
(global as any).window.navigator.appVersion = (global as any).navigator.appVersion = (global as any).navigator.appVersion || Device.osVersion;
82+
(global as any).window.navigator.maxTouchPoints = (global as any).navigator.maxTouchPoints = (global as any).navigator.maxTouchPoints || 5;
83+
(global as any).window.navigator.standalone = (global as any).navigator.standalone = (global as any).navigator.standalone === null ? true : (global as any).navigator.standalone;
12884

129-
(global as any).window["chrome"] = (global as any)["chrome"] = (global as any)[
130-
"chrome"
131-
] || {
85+
(global as any).window['chrome'] = (global as any)['chrome'] = (global as any)['chrome'] || {
13286
extension: {},
13387
};
13488
/// https://www.w3schools.com/js/js_window_location.asp
135-
(global as any).window.location = (global as any).location = (global as any)
136-
.location || {
137-
href: "", // window.location.href returns the href (URL) of the current page
138-
hostname: "", // window.location.hostname returns the domain name of the web host
139-
pathname: "", // window.location.pathname returns the path and filename of the current page
140-
protocol: "https", // window.location.protocol returns the web protocol used (http: or https:)
89+
(global as any).window.location = (global as any).location = (global as any).location || {
90+
href: '', // window.location.href returns the href (URL) of the current page
91+
hostname: '', // window.location.hostname returns the domain name of the web host
92+
pathname: '', // window.location.pathname returns the path and filename of the current page
93+
protocol: 'https', // window.location.protocol returns the web protocol used (http: or https:)
14194
assign: null, // window.location.assign loads a new document
14295
};
14396

14497
if ((global as any).document) {
145-
(global as any).document.readyState = "complete";
98+
(global as any).document.readyState = 'complete';
14699
}
147100

148101
(global as any).window.setTimeout = setTimeout;
@@ -154,7 +107,7 @@ if ((global as any).document) {
154107
obj.getPropertyValue = function (prop) {
155108
if (element instanceof View) {
156109
let val = element.style.get(prop);
157-
if ((val !== undefined) && typeof val.value && typeof val.unit) {
110+
if (val !== undefined && typeof val.value && typeof val.unit) {
158111
if (typeof val.value && typeof val.unit) {
159112
return `${val.value}${val.unit}`;
160113
}
@@ -165,4 +118,3 @@ if ((global as any).document) {
165118
};
166119
return obj;
167120
};
168-

0 commit comments

Comments
 (0)