@bubblewrap/core 1.21.0 → 1.22.2
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.
- package/dist/lib/Config.js +6 -4
- package/dist/lib/FetchUtils.d.ts +2 -2
- package/dist/lib/FetchUtils.js +4 -4
- package/dist/lib/GooglePlay.d.ts +1 -1
- package/dist/lib/GooglePlay.js +3 -3
- package/dist/lib/GradleWrapper.d.ts +0 -1
- package/dist/lib/GradleWrapper.js +1 -1
- package/dist/lib/ImageHelper.js +2 -2
- package/dist/lib/ShortcutInfo.js +5 -5
- package/dist/lib/TwaGenerator.d.ts +1 -1
- package/dist/lib/TwaGenerator.js +10 -8
- package/dist/lib/TwaManifest.d.ts +6 -6
- package/dist/lib/TwaManifest.js +17 -15
- package/dist/lib/androidSdk/AndroidSdkTools.d.ts +1 -2
- package/dist/lib/androidSdk/AndroidSdkTools.js +17 -12
- package/dist/lib/errors/ValidatePathError.d.ts +1 -1
- package/dist/lib/features/AppsFlyerFeature.d.ts +1 -1
- package/dist/lib/features/LocationDelegationFeature.d.ts +1 -1
- package/dist/lib/features/PlayBillingFeature.d.ts +1 -1
- package/dist/lib/features/PlayBillingFeature.js +1 -1
- package/dist/lib/jdk/JarSigner.js +1 -1
- package/dist/lib/jdk/JdkHelper.d.ts +0 -1
- package/dist/lib/jdk/JdkHelper.js +4 -4
- package/dist/lib/jdk/KeyTool.js +12 -12
- package/dist/lib/types/WebManifest.d.ts +2 -2
- package/dist/lib/util.d.ts +0 -1
- package/dist/lib/util.js +22 -23
- package/dist/lib/wrappers/svg2img.d.ts +0 -1
- package/dist/lib/wrappers/svg2img.js +4 -4
- package/package.json +4 -4
- package/template_project/app/build.gradle +3 -2
- package/template_project/app/src/main/AndroidManifest.xml +5 -1
- package/template_project/build.gradle +1 -1
- package/template_project/gradle/wrapper/gradle-wrapper.properties +3 -1
- package/template_project/gradlew +172 -111
- package/template_project/gradlew.bat +25 -33
package/dist/lib/Config.js
CHANGED
|
@@ -27,7 +27,7 @@ class Config {
|
|
|
27
27
|
return JSON.stringify(this);
|
|
28
28
|
}
|
|
29
29
|
async saveConfig(path) {
|
|
30
|
-
await fs_1.promises.mkdir(path_1.dirname(path), { recursive: true });
|
|
30
|
+
await fs_1.promises.mkdir((0, path_1.dirname)(path), { recursive: true });
|
|
31
31
|
await fs_1.promises.writeFile(path, this.serialize());
|
|
32
32
|
}
|
|
33
33
|
static deserialize(data) {
|
|
@@ -40,9 +40,11 @@ class Config {
|
|
|
40
40
|
return Config.deserialize(data);
|
|
41
41
|
}
|
|
42
42
|
catch (err) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
if (err instanceof Error) {
|
|
44
|
+
// If config file does not exist
|
|
45
|
+
if (err.code === 'ENOENT')
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
46
48
|
throw err;
|
|
47
49
|
}
|
|
48
50
|
}
|
package/dist/lib/FetchUtils.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Response as FetchH2Response } from 'fetch-h2';
|
|
2
2
|
import { Response as NodeFetchResponse } from 'node-fetch';
|
|
3
|
-
export
|
|
4
|
-
export
|
|
3
|
+
export type FetchEngine = 'node-fetch' | 'fetch-h2';
|
|
4
|
+
export type NodeFetchOrFetchH2Response = FetchH2Response | NodeFetchResponse;
|
|
5
5
|
declare class FetchUtils {
|
|
6
6
|
private fetchEngine;
|
|
7
7
|
setFetchEngine(newFetchEngine: FetchEngine): void;
|
package/dist/lib/FetchUtils.js
CHANGED
|
@@ -21,7 +21,7 @@ const fetch_h2_1 = require("fetch-h2");
|
|
|
21
21
|
const node_fetch_1 = require("node-fetch");
|
|
22
22
|
const DEFAULT_FETCH_ENGINE = 'fetch-h2';
|
|
23
23
|
const userAgent = 'Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/81.0';
|
|
24
|
-
const fetchh2Ctx = fetch_h2_1.context({ userAgent: userAgent, overwriteUserAgent: true });
|
|
24
|
+
const fetchh2Ctx = (0, fetch_h2_1.context)({ userAgent: userAgent, overwriteUserAgent: true });
|
|
25
25
|
const fetchh2 = fetchh2Ctx.fetch;
|
|
26
26
|
class FetchUtils {
|
|
27
27
|
constructor() {
|
|
@@ -32,7 +32,7 @@ class FetchUtils {
|
|
|
32
32
|
}
|
|
33
33
|
async fetch(input) {
|
|
34
34
|
if (this.fetchEngine == 'node-fetch') {
|
|
35
|
-
return await node_fetch_1.default(input, { redirect: 'follow', headers: { 'User-Agent': userAgent } });
|
|
35
|
+
return await (0, node_fetch_1.default)(input, { redirect: 'follow', headers: { 'User-Agent': userAgent } });
|
|
36
36
|
}
|
|
37
37
|
else {
|
|
38
38
|
return await fetchh2(input, { redirect: 'follow' });
|
|
@@ -47,7 +47,7 @@ class FetchUtils {
|
|
|
47
47
|
let result;
|
|
48
48
|
let readableStream;
|
|
49
49
|
if (this.fetchEngine === 'node-fetch') {
|
|
50
|
-
result = await node_fetch_1.default(url);
|
|
50
|
+
result = await (0, node_fetch_1.default)(url);
|
|
51
51
|
readableStream = result.body;
|
|
52
52
|
}
|
|
53
53
|
else {
|
|
@@ -73,7 +73,7 @@ class FetchUtils {
|
|
|
73
73
|
reject(err);
|
|
74
74
|
});
|
|
75
75
|
fileStream.on('finish', () => {
|
|
76
|
-
resolve();
|
|
76
|
+
resolve({});
|
|
77
77
|
});
|
|
78
78
|
});
|
|
79
79
|
}
|
package/dist/lib/GooglePlay.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
declare const TRACK_VALUES: string[];
|
|
2
|
-
export
|
|
2
|
+
export type PlayStoreTrack = typeof TRACK_VALUES[number];
|
|
3
3
|
export declare const PlayStoreTracks: PlayStoreTrack[];
|
|
4
4
|
export declare function asPlayStoreTrack(input?: string): PlayStoreTrack | null;
|
|
5
5
|
export declare class GooglePlay {
|
package/dist/lib/GooglePlay.js
CHANGED
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.GooglePlay = exports.
|
|
18
|
+
exports.GooglePlay = exports.PlayStoreTracks = void 0;
|
|
19
|
+
exports.asPlayStoreTrack = asPlayStoreTrack;
|
|
19
20
|
const googleapis_1 = require("googleapis");
|
|
20
21
|
const fs_1 = require("fs");
|
|
21
22
|
// Possible values for release tracks
|
|
@@ -28,7 +29,6 @@ function asPlayStoreTrack(input) {
|
|
|
28
29
|
}
|
|
29
30
|
return TRACK_VALUES.includes(input) ? input : null;
|
|
30
31
|
}
|
|
31
|
-
exports.asPlayStoreTrack = asPlayStoreTrack;
|
|
32
32
|
class GooglePlay {
|
|
33
33
|
/**
|
|
34
34
|
* Constructs a Google Play object with the gradleWrapper so we can use a
|
|
@@ -80,7 +80,7 @@ class GooglePlay {
|
|
|
80
80
|
editId: editId,
|
|
81
81
|
packageName: packageName,
|
|
82
82
|
media: {
|
|
83
|
-
body: fs_1.createReadStream(filepath),
|
|
83
|
+
body: (0, fs_1.createReadStream)(filepath),
|
|
84
84
|
},
|
|
85
85
|
}, {
|
|
86
86
|
timeout: PLAY_API_TIMEOUT_MS,
|
|
@@ -56,7 +56,7 @@ class GradleWrapper {
|
|
|
56
56
|
*/
|
|
57
57
|
async executeGradleCommand(args) {
|
|
58
58
|
const env = this.androidSdkTools.getEnv();
|
|
59
|
-
await util_1.executeFile(this.gradleCmd, args, env, undefined, this.projectLocation);
|
|
59
|
+
await (0, util_1.executeFile)(this.gradleCmd, args, env, undefined, this.projectLocation);
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
exports.GradleWrapper = GradleWrapper;
|
package/dist/lib/ImageHelper.js
CHANGED
|
@@ -24,7 +24,7 @@ const FetchUtils_1 = require("./FetchUtils");
|
|
|
24
24
|
const util_1 = require("util");
|
|
25
25
|
const svg2img_1 = require("./wrappers/svg2img");
|
|
26
26
|
// fs.promises is marked as experimental. This should be replaced when stable.
|
|
27
|
-
const fsMkDir = util_1.promisify(fs.mkdir);
|
|
27
|
+
const fsMkDir = (0, util_1.promisify)(fs.mkdir);
|
|
28
28
|
class ImageHelper {
|
|
29
29
|
async saveIcon(icon, size, fileName, backgroundColor) {
|
|
30
30
|
const image = await Jimp.read(icon.data);
|
|
@@ -104,7 +104,7 @@ class ImageHelper {
|
|
|
104
104
|
if (contentType.startsWith('image/svg')) {
|
|
105
105
|
const textDecoder = new TextDecoder();
|
|
106
106
|
try {
|
|
107
|
-
body = await svg2img_1.svg2img(textDecoder.decode(body));
|
|
107
|
+
body = await (0, svg2img_1.svg2img)(textDecoder.decode(body));
|
|
108
108
|
}
|
|
109
109
|
catch (error) {
|
|
110
110
|
throw new Error(`Problem reading ${iconUrl}: ${error}`);
|
package/dist/lib/ShortcutInfo.js
CHANGED
|
@@ -45,8 +45,8 @@ class ShortcutInfo {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
toString(index) {
|
|
48
|
-
return `[name:'${util_1.escapeGradleString(this.name)}', ` +
|
|
49
|
-
`short_name:'${util_1.escapeGradleString(this.shortName)}', ` +
|
|
48
|
+
return `[name:'${(0, util_1.escapeGradleString)(this.name)}', ` +
|
|
49
|
+
`short_name:'${(0, util_1.escapeGradleString)(this.shortName)}', ` +
|
|
50
50
|
`url:'${this.url}', ` +
|
|
51
51
|
`icon:'${this.assetName(index)}']`;
|
|
52
52
|
}
|
|
@@ -66,9 +66,9 @@ class ShortcutInfo {
|
|
|
66
66
|
if (!shortcut.icons || !shortcut.url || !name) {
|
|
67
67
|
throw new Error('missing metadata');
|
|
68
68
|
}
|
|
69
|
-
const suitableIcon = util_1.findSuitableIcon(shortcut.icons, 'any', MIN_SHORTCUT_ICON_SIZE);
|
|
70
|
-
const suitableMaskableIcon = util_1.findSuitableIcon(shortcut.icons, 'maskable', MIN_SHORTCUT_ICON_SIZE);
|
|
71
|
-
const suitableMonochromeIcon = util_1.findSuitableIcon(shortcut.icons, 'monochrome', MIN_SHORTCUT_ICON_SIZE);
|
|
69
|
+
const suitableIcon = (0, util_1.findSuitableIcon)(shortcut.icons, 'any', MIN_SHORTCUT_ICON_SIZE);
|
|
70
|
+
const suitableMaskableIcon = (0, util_1.findSuitableIcon)(shortcut.icons, 'maskable', MIN_SHORTCUT_ICON_SIZE);
|
|
71
|
+
const suitableMonochromeIcon = (0, util_1.findSuitableIcon)(shortcut.icons, 'monochrome', MIN_SHORTCUT_ICON_SIZE);
|
|
72
72
|
if (!suitableIcon && !suitableMonochromeIcon) {
|
|
73
73
|
// maskable icons also need an equivalent any icon for lower API versions.
|
|
74
74
|
// any and monochrome icons work on all API versions.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TwaManifest } from './TwaManifest';
|
|
2
2
|
import { Log } from './Log';
|
|
3
|
-
export
|
|
3
|
+
export type twaGeneratorProgress = (progress: number, total: number) => void;
|
|
4
4
|
/**
|
|
5
5
|
* Generates TWA Projects from a TWA Manifest
|
|
6
6
|
*/
|
package/dist/lib/TwaGenerator.js
CHANGED
|
@@ -114,10 +114,10 @@ function shortcutImages(assetName) {
|
|
|
114
114
|
];
|
|
115
115
|
}
|
|
116
116
|
// fs.promises is marked as experimental. This should be replaced when stable.
|
|
117
|
-
const fsMkDir = util_1.promisify(fs.mkdir);
|
|
118
|
-
const fsCopyFile = util_1.promisify(fs.copyFile);
|
|
119
|
-
const fsWriteFile = util_1.promisify(fs.writeFile);
|
|
120
|
-
const fsReadFile = util_1.promisify(fs.readFile);
|
|
117
|
+
const fsMkDir = (0, util_1.promisify)(fs.mkdir);
|
|
118
|
+
const fsCopyFile = (0, util_1.promisify)(fs.copyFile);
|
|
119
|
+
const fsWriteFile = (0, util_1.promisify)(fs.writeFile);
|
|
120
|
+
const fsReadFile = (0, util_1.promisify)(fs.readFile);
|
|
121
121
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
122
122
|
const noOpProgress = () => { };
|
|
123
123
|
/**
|
|
@@ -176,7 +176,7 @@ class TwaGenerator {
|
|
|
176
176
|
async applyTemplate(sourceFile, destFile, args) {
|
|
177
177
|
await fsMkDir(path.dirname(destFile), { recursive: true });
|
|
178
178
|
const templateFile = await fsReadFile(sourceFile, 'utf-8');
|
|
179
|
-
const output = lodash_1.template(templateFile)(args);
|
|
179
|
+
const output = (0, lodash_1.template)(templateFile)(args);
|
|
180
180
|
await fsWriteFile(destFile, output);
|
|
181
181
|
}
|
|
182
182
|
async applyTemplateList(sourceDir, targetDir, fileList, args) {
|
|
@@ -191,7 +191,7 @@ class TwaGenerator {
|
|
|
191
191
|
const destFile = path.join(targetDir, JAVA_DIR, packageName.split('.').join('/'), filename);
|
|
192
192
|
await fsMkDir(path.dirname(destFile), { recursive: true });
|
|
193
193
|
const templateFile = await fsReadFile(sourceFile, 'utf-8');
|
|
194
|
-
const output = lodash_1.template(templateFile)(args);
|
|
194
|
+
const output = (0, lodash_1.template)(templateFile)(args);
|
|
195
195
|
await fsWriteFile(destFile, output);
|
|
196
196
|
}
|
|
197
197
|
applyJavaTemplates(sourceDir, targetDir, packageName, fileList, args) {
|
|
@@ -274,7 +274,9 @@ class TwaGenerator {
|
|
|
274
274
|
actions: ['android.intent.action.SEND'],
|
|
275
275
|
mimeTypes: [],
|
|
276
276
|
};
|
|
277
|
-
if (((_b = (_a = twaManifest.shareTarget) === null || _a === void 0 ? void 0 : _a.params) === null || _b === void 0 ? void 0 : _b.url) ||
|
|
277
|
+
if (((_b = (_a = twaManifest.shareTarget) === null || _a === void 0 ? void 0 : _a.params) === null || _b === void 0 ? void 0 : _b.url) ||
|
|
278
|
+
((_d = (_c = twaManifest.shareTarget) === null || _c === void 0 ? void 0 : _c.params) === null || _d === void 0 ? void 0 : _d.title) ||
|
|
279
|
+
((_f = (_e = twaManifest.shareTarget) === null || _e === void 0 ? void 0 : _e.params) === null || _f === void 0 ? void 0 : _f.text)) {
|
|
278
280
|
shareTargetIntentFilter.mimeTypes.push('text/plain');
|
|
279
281
|
}
|
|
280
282
|
if ((_h = (_g = twaManifest.shareTarget) === null || _g === void 0 ? void 0 : _g.params) === null || _h === void 0 ? void 0 : _h.files) {
|
|
@@ -356,7 +358,7 @@ class TwaGenerator {
|
|
|
356
358
|
* @param targetDirectory the directory where the project was created.
|
|
357
359
|
*/
|
|
358
360
|
async removeTwaProject(targetDirectory) {
|
|
359
|
-
await Promise.all(DELETE_PROJECT_FILE_LIST.map((entry) => util_2.rmdir(path.join(targetDirectory, entry))));
|
|
361
|
+
await Promise.all(DELETE_PROJECT_FILE_LIST.map((entry) => (0, util_2.rmdir)(path.join(targetDirectory, entry))));
|
|
360
362
|
}
|
|
361
363
|
}
|
|
362
364
|
exports.TwaGenerator = TwaGenerator;
|
|
@@ -7,22 +7,22 @@ import { PlayBillingConfig } from './features/PlayBillingFeature';
|
|
|
7
7
|
import { FirstRunFlagConfig } from './features/FirstRunFlagFeature';
|
|
8
8
|
import { ArCoreConfig } from './features/ArCoreFeature';
|
|
9
9
|
declare const DISPLAY_MODE_VALUES: string[];
|
|
10
|
-
export
|
|
10
|
+
export type DisplayMode = typeof DISPLAY_MODE_VALUES[number];
|
|
11
11
|
export declare const DisplayModes: DisplayMode[];
|
|
12
12
|
export declare function asDisplayMode(input: string): DisplayMode | null;
|
|
13
13
|
declare const ORIENTATION_VALUES: string[];
|
|
14
|
-
export
|
|
14
|
+
export type Orientation = typeof ORIENTATION_VALUES[number];
|
|
15
15
|
export declare const Orientations: Orientation[];
|
|
16
16
|
export declare function asOrientation(input?: string): Orientation | null;
|
|
17
|
-
export
|
|
18
|
-
|
|
17
|
+
export type FallbackType = 'customtabs' | 'webview';
|
|
18
|
+
type Features = {
|
|
19
19
|
appsFlyer?: AppsFlyerConfig;
|
|
20
20
|
locationDelegation?: LocationDelegationConfig;
|
|
21
21
|
playBilling?: PlayBillingConfig;
|
|
22
22
|
firstRunFlag?: FirstRunFlagConfig;
|
|
23
23
|
arCore?: ArCoreConfig;
|
|
24
24
|
};
|
|
25
|
-
|
|
25
|
+
type alphaDependencies = {
|
|
26
26
|
enabled: boolean;
|
|
27
27
|
};
|
|
28
28
|
/**
|
|
@@ -242,7 +242,7 @@ export interface SigningKeyInfo {
|
|
|
242
242
|
path: string;
|
|
243
243
|
alias: string;
|
|
244
244
|
}
|
|
245
|
-
export
|
|
245
|
+
export type Fingerprint = {
|
|
246
246
|
name?: string;
|
|
247
247
|
value: string;
|
|
248
248
|
};
|
package/dist/lib/TwaManifest.js
CHANGED
|
@@ -15,7 +15,9 @@
|
|
|
15
15
|
*/
|
|
16
16
|
'use strict';
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.TwaManifest = exports.
|
|
18
|
+
exports.TwaManifest = exports.Orientations = exports.DisplayModes = void 0;
|
|
19
|
+
exports.asDisplayMode = asDisplayMode;
|
|
20
|
+
exports.asOrientation = asOrientation;
|
|
19
21
|
const fs = require("fs");
|
|
20
22
|
const FetchUtils_1 = require("./FetchUtils");
|
|
21
23
|
const util_1 = require("./util");
|
|
@@ -34,7 +36,6 @@ exports.DisplayModes = [...DISPLAY_MODE_VALUES];
|
|
|
34
36
|
function asDisplayMode(input) {
|
|
35
37
|
return DISPLAY_MODE_VALUES.includes(input) ? input : null;
|
|
36
38
|
}
|
|
37
|
-
exports.asDisplayMode = asDisplayMode;
|
|
38
39
|
// Possible values for screen orientation, as defined in `android-browser-helper`:
|
|
39
40
|
// https://github.com/GoogleChrome/android-browser-helper/blob/alpha/androidbrowserhelper/src/main/java/com/google/androidbrowserhelper/trusted/LauncherActivityMetadata.java#L191-L216
|
|
40
41
|
const ORIENTATION_VALUES = ['default', 'any', 'natural', 'landscape', 'portrait',
|
|
@@ -46,7 +47,6 @@ function asOrientation(input) {
|
|
|
46
47
|
}
|
|
47
48
|
return ORIENTATION_VALUES.includes(input) ? input : null;
|
|
48
49
|
}
|
|
49
|
-
exports.asOrientation = asOrientation;
|
|
50
50
|
// Default values used on the Twa Manifest
|
|
51
51
|
const DEFAULT_SPLASHSCREEN_FADEOUT_DURATION = 300;
|
|
52
52
|
const DEFAULT_APP_NAME = 'My TWA';
|
|
@@ -58,7 +58,7 @@ const DEFAULT_NAVIGATION_DIVIDER_COLOR = '#00000000';
|
|
|
58
58
|
const DEFAULT_BACKGROUND_COLOR = '#FFFFFF';
|
|
59
59
|
const DEFAULT_APP_VERSION_CODE = 1;
|
|
60
60
|
const DEFAULT_APP_VERSION_NAME = DEFAULT_APP_VERSION_CODE.toString();
|
|
61
|
-
const DEFAULT_MIN_SDK_VERSION =
|
|
61
|
+
const DEFAULT_MIN_SDK_VERSION = 21;
|
|
62
62
|
const DEFAULT_SIGNING_KEY_PATH = './android.keystore';
|
|
63
63
|
const DEFAULT_SIGNING_KEY_ALIAS = 'android';
|
|
64
64
|
const DEFAULT_ENABLE_NOTIFICATIONS = true;
|
|
@@ -184,22 +184,22 @@ class TwaManifest {
|
|
|
184
184
|
*/
|
|
185
185
|
validate() {
|
|
186
186
|
let error;
|
|
187
|
-
error = util_1.validateNotEmpty(this.host, 'host');
|
|
187
|
+
error = (0, util_1.validateNotEmpty)(this.host, 'host');
|
|
188
188
|
if (error != null) {
|
|
189
189
|
return error;
|
|
190
190
|
}
|
|
191
|
-
error = util_1.validateNotEmpty(this.name, 'name');
|
|
191
|
+
error = (0, util_1.validateNotEmpty)(this.name, 'name');
|
|
192
192
|
if (error != null) {
|
|
193
193
|
return error;
|
|
194
194
|
}
|
|
195
|
-
error = util_1.validateNotEmpty(this.startUrl, 'startUrl');
|
|
195
|
+
error = (0, util_1.validateNotEmpty)(this.startUrl, 'startUrl');
|
|
196
196
|
if (error != null) {
|
|
197
197
|
return error;
|
|
198
198
|
}
|
|
199
199
|
if (!this.iconUrl) {
|
|
200
200
|
return 'iconUrl cannot be empty';
|
|
201
201
|
}
|
|
202
|
-
error = util_1.validateNotEmpty(this.iconUrl, 'iconUrl');
|
|
202
|
+
error = (0, util_1.validateNotEmpty)(this.iconUrl, 'iconUrl');
|
|
203
203
|
if (error != null) {
|
|
204
204
|
return error;
|
|
205
205
|
}
|
|
@@ -218,9 +218,9 @@ class TwaManifest {
|
|
|
218
218
|
*/
|
|
219
219
|
static fromWebManifestJson(webManifestUrl, webManifest) {
|
|
220
220
|
var _a;
|
|
221
|
-
const icon = util_1.findSuitableIcon(webManifest.icons, 'any', MIN_ICON_SIZE);
|
|
222
|
-
const maskableIcon = util_1.findSuitableIcon(webManifest.icons, 'maskable', MIN_ICON_SIZE);
|
|
223
|
-
const monochromeIcon = util_1.findSuitableIcon(webManifest.icons, 'monochrome', MIN_NOTIFICATION_ICON_SIZE);
|
|
221
|
+
const icon = (0, util_1.findSuitableIcon)(webManifest.icons, 'any', MIN_ICON_SIZE);
|
|
222
|
+
const maskableIcon = (0, util_1.findSuitableIcon)(webManifest.icons, 'maskable', MIN_ICON_SIZE);
|
|
223
|
+
const monochromeIcon = (0, util_1.findSuitableIcon)(webManifest.icons, 'monochrome', MIN_NOTIFICATION_ICON_SIZE);
|
|
224
224
|
const fullStartUrl = new URL(webManifest['start_url'] || '/', webManifestUrl);
|
|
225
225
|
const fullScopeUrl = new URL(webManifest['scope'] || '.', webManifestUrl);
|
|
226
226
|
const shortcuts = this.getShortcuts(webManifestUrl, webManifest);
|
|
@@ -228,10 +228,11 @@ class TwaManifest {
|
|
|
228
228
|
return icon ? new URL(icon.src, webManifestUrl).toString() : undefined;
|
|
229
229
|
}
|
|
230
230
|
const twaManifest = new TwaManifest({
|
|
231
|
-
packageId: util_1.generatePackageId(webManifestUrl.host) || '',
|
|
231
|
+
packageId: (0, util_1.generatePackageId)(webManifestUrl.host) || '',
|
|
232
232
|
host: webManifestUrl.host,
|
|
233
233
|
name: webManifest['name'] || webManifest['short_name'] || DEFAULT_APP_NAME,
|
|
234
|
-
launcherName: webManifest['short_name'] ||
|
|
234
|
+
launcherName: webManifest['short_name'] ||
|
|
235
|
+
((_a = webManifest['name']) === null || _a === void 0 ? void 0 : _a.substring(0, SHORT_NAME_MAX_SIZE)) || DEFAULT_APP_NAME,
|
|
235
236
|
display: asDisplayMode(webManifest['display']) || DEFAULT_DISPLAY_MODE,
|
|
236
237
|
themeColor: webManifest['theme_color'] || DEFAULT_THEME_COLOR,
|
|
237
238
|
themeColorDark: DEFAULT_THEME_COLOR_DARK,
|
|
@@ -355,7 +356,7 @@ class TwaManifest {
|
|
|
355
356
|
return icon ? new URL(icon.src, webManifestUrl).toString() : undefined;
|
|
356
357
|
}
|
|
357
358
|
return (fieldsToIgnore.includes(fieldName)) ? oldUrl :
|
|
358
|
-
resolveIconUrl(util_1.findSuitableIcon(icons, iconType, iconSize));
|
|
359
|
+
resolveIconUrl((0, util_1.findSuitableIcon)(icons, iconType, iconSize));
|
|
359
360
|
}
|
|
360
361
|
/**
|
|
361
362
|
* Merges the Twa Manifest with the web manifest. Ignores the specified fields.
|
|
@@ -382,7 +383,8 @@ class TwaManifest {
|
|
|
382
383
|
const twaManifest = new TwaManifest({
|
|
383
384
|
...oldTwaManifestJson,
|
|
384
385
|
name: this.getNewFieldValue('name', fieldsToIgnore, oldTwaManifest.name, webManifest['name'] || webManifest['short_name']),
|
|
385
|
-
launcherName: this.getNewFieldValue('short_name', fieldsToIgnore, oldTwaManifest.launcherName, webManifest['short_name'] ||
|
|
386
|
+
launcherName: this.getNewFieldValue('short_name', fieldsToIgnore, oldTwaManifest.launcherName, webManifest['short_name'] ||
|
|
387
|
+
((_a = webManifest['name']) === null || _a === void 0 ? void 0 : _a.substring(0, SHORT_NAME_MAX_SIZE))),
|
|
386
388
|
display: this.getNewFieldValue('display', fieldsToIgnore, oldTwaManifest.display, asDisplayMode(webManifest['display'])),
|
|
387
389
|
fullScopeUrl: this.getNewFieldValue('fullScopeUrl', fieldsToIgnore, (_b = oldTwaManifest.fullScopeUrl) === null || _b === void 0 ? void 0 : _b.toString(), fullScopeUrl.toString()),
|
|
388
390
|
themeColor: this.getNewFieldValue('themeColor', fieldsToIgnore, oldTwaManifest.themeColor.hex(), webManifest['theme_color']),
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { Config } from '../Config';
|
|
3
2
|
import { JdkHelper } from '../jdk/JdkHelper';
|
|
4
3
|
import { Log } from '../../lib/Log';
|
|
5
4
|
import { Result } from '../../lib/Result';
|
|
6
5
|
import { ValidatePathError } from '../errors/ValidatePathError';
|
|
7
|
-
export declare const BUILD_TOOLS_VERSION = "
|
|
6
|
+
export declare const BUILD_TOOLS_VERSION = "34.0.0";
|
|
8
7
|
/**
|
|
9
8
|
* Wraps functionality of the Android SDK Tools and allows them to be invoked programatically.
|
|
10
9
|
*/
|
|
@@ -22,11 +22,26 @@ const util = require("../util");
|
|
|
22
22
|
const Log_1 = require("../../lib/Log");
|
|
23
23
|
const Result_1 = require("../../lib/Result");
|
|
24
24
|
const ValidatePathError_1 = require("../errors/ValidatePathError");
|
|
25
|
-
exports.BUILD_TOOLS_VERSION = '
|
|
25
|
+
exports.BUILD_TOOLS_VERSION = '34.0.0';
|
|
26
26
|
/**
|
|
27
27
|
* Wraps functionality of the Android SDK Tools and allows them to be invoked programatically.
|
|
28
28
|
*/
|
|
29
29
|
class AndroidSdkTools {
|
|
30
|
+
static async create(process, config, jdkHelper, log = new Log_1.ConsoleLog('AndroidSdkTools')) {
|
|
31
|
+
// unwrap will throw an error in case that the the path is valid and else will do nothing.
|
|
32
|
+
(await AndroidSdkTools.validatePath(config.androidSdkPath)).unwrap();
|
|
33
|
+
try {
|
|
34
|
+
return new AndroidSdkTools(process, config, jdkHelper, log);
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
if (typeof error === 'string') {
|
|
38
|
+
throw new Error(error);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
throw error;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
30
45
|
/**
|
|
31
46
|
* Constructs a new instance of AndroidSdkTools.
|
|
32
47
|
*
|
|
@@ -46,16 +61,6 @@ class AndroidSdkTools {
|
|
|
46
61
|
this.pathJoin = path.posix.join;
|
|
47
62
|
}
|
|
48
63
|
}
|
|
49
|
-
static async create(process, config, jdkHelper, log = new Log_1.ConsoleLog('AndroidSdkTools')) {
|
|
50
|
-
// unwrap will throw an error in case that the the path is valid and else will do nothing.
|
|
51
|
-
(await AndroidSdkTools.validatePath(config.androidSdkPath)).unwrap();
|
|
52
|
-
try {
|
|
53
|
-
return new AndroidSdkTools(process, config, jdkHelper, log);
|
|
54
|
-
}
|
|
55
|
-
catch (error) {
|
|
56
|
-
throw new Error(error);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
64
|
/**
|
|
60
65
|
* Installs the build tools into the the Android SDK. Equivalent to running
|
|
61
66
|
*
|
|
@@ -200,7 +205,7 @@ class AndroidSdkTools {
|
|
|
200
205
|
const installCmd = [
|
|
201
206
|
`"${this.pathJoin(this.getAndroidHome(), '/platform-tools/adb')}"`,
|
|
202
207
|
'install',
|
|
203
|
-
'-r',
|
|
208
|
+
'-r', // Replace app if another with the same package id already installed.
|
|
204
209
|
...passthroughArgs,
|
|
205
210
|
apkFilePath,
|
|
206
211
|
];
|
|
@@ -20,7 +20,7 @@ const EmptyFeature_1 = require("./EmptyFeature");
|
|
|
20
20
|
class PlayBillingFeature extends EmptyFeature_1.EmptyFeature {
|
|
21
21
|
constructor() {
|
|
22
22
|
super('playbilling');
|
|
23
|
-
this.buildGradle.dependencies.push('com.google.androidbrowserhelper:billing:1.0.0-
|
|
23
|
+
this.buildGradle.dependencies.push('com.google.androidbrowserhelper:billing:1.0.0-alpha11');
|
|
24
24
|
this.androidManifest.components.push(`
|
|
25
25
|
<activity
|
|
26
26
|
android:name="com.google.androidbrowserhelper.playbilling.provider.PaymentActivity"
|
|
@@ -32,7 +32,7 @@ class JarSigner {
|
|
|
32
32
|
*/
|
|
33
33
|
async sign(signingKeyInfo, storepass, keypass, inputFile, outputFile) {
|
|
34
34
|
const env = this.jdkHelper.getEnv();
|
|
35
|
-
await util_1.executeFile(JARSIGNER_CMD, [
|
|
35
|
+
await (0, util_1.executeFile)(JARSIGNER_CMD, [
|
|
36
36
|
'-verbose',
|
|
37
37
|
'-sigalg',
|
|
38
38
|
SIGNATURE_ALGORITHM,
|
|
@@ -52,7 +52,7 @@ class JdkHelper {
|
|
|
52
52
|
async runJava(args) {
|
|
53
53
|
const java = this.process.platform === 'win32' ? '/bin/java.exe' : '/bin/java';
|
|
54
54
|
const runJavaCmd = this.joinPath(this.getJavaHome(), java);
|
|
55
|
-
return await util_1.executeFile(runJavaCmd, args, this.getEnv());
|
|
55
|
+
return await (0, util_1.executeFile)(runJavaCmd, args, this.getEnv());
|
|
56
56
|
}
|
|
57
57
|
/**
|
|
58
58
|
* Returns information from the JAVA_HOME, based on the config and platform.
|
|
@@ -87,7 +87,7 @@ class JdkHelper {
|
|
|
87
87
|
*/
|
|
88
88
|
static async validatePath(jdkPath, currentProcess = process) {
|
|
89
89
|
const join = JdkHelper.getJoinPath(currentProcess);
|
|
90
|
-
if (!fs_1.existsSync(jdkPath)) {
|
|
90
|
+
if (!(0, fs_1.existsSync)(jdkPath)) {
|
|
91
91
|
return Result_1.Result.error(new ValidatePathError_1.ValidatePathError(`jdkPath "${jdkPath}" does not exist.`, 'PathIsNotCorrect'));
|
|
92
92
|
}
|
|
93
93
|
;
|
|
@@ -95,8 +95,8 @@ class JdkHelper {
|
|
|
95
95
|
try {
|
|
96
96
|
const releaseFilePath = join(javaHome, 'release');
|
|
97
97
|
const file = await fs_1.promises.readFile(releaseFilePath, 'utf-8');
|
|
98
|
-
if (file.indexOf('JAVA_VERSION="
|
|
99
|
-
return Result_1.Result.error(new ValidatePathError_1.ValidatePathError('JDK version not supported. JDK version
|
|
98
|
+
if (file.indexOf('JAVA_VERSION="17.0') < 0) { // Checks if the jdk's version is 17 as needed
|
|
99
|
+
return Result_1.Result.error(new ValidatePathError_1.ValidatePathError('JDK version not supported. JDK version 17 is required.', 'PathIsNotSupported'));
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
catch (e) {
|
package/dist/lib/jdk/KeyTool.js
CHANGED
|
@@ -37,7 +37,7 @@ class KeyTool {
|
|
|
37
37
|
async createSigningKey(keyOptions, overwrite = false) {
|
|
38
38
|
this.log.debug('Generating Signature with keyOptions:', JSON.stringify(keyOptions));
|
|
39
39
|
// Checks if the key already exists and deletes it, if overriting is enabled.
|
|
40
|
-
if (fs_1.existsSync(keyOptions.path)) {
|
|
40
|
+
if ((0, fs_1.existsSync)(keyOptions.path)) {
|
|
41
41
|
if (overwrite) {
|
|
42
42
|
await fs_1.promises.unlink(keyOptions.path);
|
|
43
43
|
}
|
|
@@ -54,15 +54,15 @@ class KeyTool {
|
|
|
54
54
|
'keytool',
|
|
55
55
|
'-genkeypair',
|
|
56
56
|
`-dname "${dname}"`,
|
|
57
|
-
`-alias "${util_1.escapeDoubleQuotedShellString(keyOptions.alias)}"`,
|
|
58
|
-
`-keypass "${util_1.escapeDoubleQuotedShellString(keyOptions.keypassword)}"`,
|
|
59
|
-
`-keystore "${util_1.escapeDoubleQuotedShellString(keyOptions.path)}"`,
|
|
60
|
-
`-storepass "${util_1.escapeDoubleQuotedShellString(keyOptions.password)}"`,
|
|
57
|
+
`-alias "${(0, util_1.escapeDoubleQuotedShellString)(keyOptions.alias)}"`,
|
|
58
|
+
`-keypass "${(0, util_1.escapeDoubleQuotedShellString)(keyOptions.keypassword)}"`,
|
|
59
|
+
`-keystore "${(0, util_1.escapeDoubleQuotedShellString)(keyOptions.path)}"`,
|
|
60
|
+
`-storepass "${(0, util_1.escapeDoubleQuotedShellString)(keyOptions.password)}"`,
|
|
61
61
|
'-validity 20000',
|
|
62
62
|
'-keyalg RSA',
|
|
63
63
|
];
|
|
64
64
|
const env = this.jdkHelper.getEnv();
|
|
65
|
-
await util_1.execute(keytoolCmd, env);
|
|
65
|
+
await (0, util_1.execute)(keytoolCmd, env);
|
|
66
66
|
this.log.info('Signing Key created successfully');
|
|
67
67
|
}
|
|
68
68
|
/**
|
|
@@ -72,7 +72,7 @@ class KeyTool {
|
|
|
72
72
|
* @returns {Promise<string>} the raw output of the `keytool --list` command
|
|
73
73
|
*/
|
|
74
74
|
async list(keyOptions) {
|
|
75
|
-
if (!fs_1.existsSync(keyOptions.path)) {
|
|
75
|
+
if (!(0, fs_1.existsSync)(keyOptions.path)) {
|
|
76
76
|
throw new Error(`Couldn't find signing key at "${keyOptions.path}"`);
|
|
77
77
|
}
|
|
78
78
|
const keyListCmd = [
|
|
@@ -84,13 +84,13 @@ class KeyTool {
|
|
|
84
84
|
'-J-Duser.language=en',
|
|
85
85
|
'-list',
|
|
86
86
|
'-v',
|
|
87
|
-
`-keystore "${util_1.escapeDoubleQuotedShellString(keyOptions.path)}"`,
|
|
88
|
-
`-alias "${util_1.escapeDoubleQuotedShellString(keyOptions.alias)}"`,
|
|
89
|
-
`-storepass "${util_1.escapeDoubleQuotedShellString(keyOptions.password)}"`,
|
|
90
|
-
`-keypass "${util_1.escapeDoubleQuotedShellString(keyOptions.keypassword)}"`,
|
|
87
|
+
`-keystore "${(0, util_1.escapeDoubleQuotedShellString)(keyOptions.path)}"`,
|
|
88
|
+
`-alias "${(0, util_1.escapeDoubleQuotedShellString)(keyOptions.alias)}"`,
|
|
89
|
+
`-storepass "${(0, util_1.escapeDoubleQuotedShellString)(keyOptions.password)}"`,
|
|
90
|
+
`-keypass "${(0, util_1.escapeDoubleQuotedShellString)(keyOptions.keypassword)}"`,
|
|
91
91
|
];
|
|
92
92
|
const env = this.jdkHelper.getEnv();
|
|
93
|
-
const result = await util_1.execute(keyListCmd, env);
|
|
93
|
+
const result = await (0, util_1.execute)(keyListCmd, env);
|
|
94
94
|
return result.stdout;
|
|
95
95
|
}
|
|
96
96
|
/**
|
|
@@ -11,8 +11,8 @@ export interface WebManifestShortcutJson {
|
|
|
11
11
|
url?: string;
|
|
12
12
|
icons?: Array<WebManifestIcon>;
|
|
13
13
|
}
|
|
14
|
-
|
|
15
|
-
export
|
|
14
|
+
type WebManifestDisplayMode = 'browser' | 'minimal-ui' | 'standalone' | 'fullscreen';
|
|
15
|
+
export type OrientationLock = 'any' | 'natural' | 'landscape' | 'portrait' | 'portrait-primary' | 'portrait-secondary' | 'landscape-primary' | 'landscape-secondary';
|
|
16
16
|
export interface ShareTargetParams {
|
|
17
17
|
title?: string;
|
|
18
18
|
text?: string;
|
package/dist/lib/util.d.ts
CHANGED