Skip to content

Commit c8d9a63

Browse files
committed
implement CrossAndroid support
1 parent e2f2dd3 commit c8d9a63

File tree

16 files changed

+618
-32
lines changed

16 files changed

+618
-32
lines changed

.eslintrc.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ rules:
1212
- ignores:
1313
- modules
1414
- dynamicImport
15+
node/no-unsupported-features/es-builtins:
16+
- error
17+
- ignores:
18+
- globalThis
1519

1620
node/no-unpublished-import: off
1721
node/no-unpublished-require: off

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/common/vendor-libs/jszip.js linguist-vendored
22
/common/vendor-libs/patch-steps-lib/**/* linguist-vendored
33
/common/vendor-libs/semver.js linguist-vendored
4+
/common/vendor-libs/whatwg-fetch.js linguist-vendored

common/src/utils.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,20 @@ export { MaybePromise };
88

99
export enum PlatformType {
1010
DESKTOP = 'DESKTOP',
11+
ANDROID = 'ANDROID',
1112
BROWSER = 'BROWSER',
1213
}
1314

14-
export const PLATFORM_TYPE =
15-
typeof nw !== 'undefined' ? PlatformType.DESKTOP : PlatformType.BROWSER;
15+
export const PLATFORM_TYPE: PlatformType = (() => {
16+
if (typeof nw !== 'undefined') {
17+
return PlatformType.DESKTOP;
18+
}
19+
let params = new URLSearchParams(window.location.search);
20+
if (params.has('crossandroid')) {
21+
return PlatformType.ANDROID;
22+
}
23+
return PlatformType.BROWSER;
24+
})();
1625

1726
export function showDevTools(window: nw.Window = nw.Window.get()): Promise<void> {
1827
return new Promise((resolve) =>
@@ -80,6 +89,8 @@ export function cwdFilePathToURL(path: string, base: string = document.baseURI):
8089
let url = new URL(base);
8190
// Implicitly percent-encodes and doesn't trim path on the ends.
8291
url.pathname = path;
92+
url.search = '';
93+
url.hash = '';
8394
return url;
8495
}
8596

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export declare var DOMException: typeof globalThis.DOMException;
2+
export declare var Headers: typeof globalThis.Headers;
3+
export declare var Request: typeof globalThis.Request;
4+
export declare var Response: typeof globalThis.Response;
5+
export declare var fetch: typeof globalThis.fetch;

0 commit comments

Comments
 (0)