@bubblewrap/core 1.20.1 → 1.22.0

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 (37) hide show
  1. package/dist/lib/Config.js +6 -4
  2. package/dist/lib/FetchUtils.d.ts +2 -2
  3. package/dist/lib/FetchUtils.js +4 -4
  4. package/dist/lib/GooglePlay.d.ts +1 -1
  5. package/dist/lib/GooglePlay.js +3 -3
  6. package/dist/lib/GradleWrapper.d.ts +0 -1
  7. package/dist/lib/GradleWrapper.js +1 -1
  8. package/dist/lib/ImageHelper.js +2 -2
  9. package/dist/lib/ShortcutInfo.js +5 -5
  10. package/dist/lib/TwaGenerator.d.ts +1 -1
  11. package/dist/lib/TwaGenerator.js +10 -8
  12. package/dist/lib/TwaManifest.d.ts +10 -7
  13. package/dist/lib/TwaManifest.js +26 -19
  14. package/dist/lib/androidSdk/AndroidSdkTools.d.ts +1 -2
  15. package/dist/lib/androidSdk/AndroidSdkTools.js +17 -12
  16. package/dist/lib/errors/ValidatePathError.d.ts +1 -1
  17. package/dist/lib/features/AppsFlyerFeature.d.ts +1 -1
  18. package/dist/lib/features/LocationDelegationFeature.d.ts +1 -1
  19. package/dist/lib/features/LocationDelegationFeature.js +1 -1
  20. package/dist/lib/features/PlayBillingFeature.d.ts +1 -1
  21. package/dist/lib/features/PlayBillingFeature.js +1 -1
  22. package/dist/lib/jdk/JarSigner.js +1 -1
  23. package/dist/lib/jdk/JdkHelper.d.ts +0 -1
  24. package/dist/lib/jdk/JdkHelper.js +4 -4
  25. package/dist/lib/jdk/KeyTool.js +12 -12
  26. package/dist/lib/types/WebManifest.d.ts +2 -2
  27. package/dist/lib/util.d.ts +0 -1
  28. package/dist/lib/util.js +21 -22
  29. package/dist/lib/wrappers/svg2img.d.ts +0 -1
  30. package/dist/lib/wrappers/svg2img.js +4 -4
  31. package/package.json +4 -4
  32. package/template_project/app/build.gradle +9 -2
  33. package/template_project/app/src/main/AndroidManifest.xml +4 -0
  34. package/template_project/build.gradle +1 -1
  35. package/template_project/gradle/wrapper/gradle-wrapper.properties +3 -1
  36. package/template_project/gradlew +172 -111
  37. package/template_project/gradlew.bat +25 -33
@@ -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
- declare type WebManifestDisplayMode = 'browser' | 'minimal-ui' | 'standalone' | 'fullscreen';
15
- export declare type OrientationLock = 'any' | 'natural' | 'landscape' | 'portrait' | 'portrait-primary' | 'portrait-secondary' | 'landscape-primary' | 'landscape-secondary';
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;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { WebManifestIcon, WebManifestJson } from './types/WebManifest';
3
2
  import { Log } from './Log';
4
3
  import { Orientation } from './TwaManifest';
package/dist/lib/util.js CHANGED
@@ -15,7 +15,21 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.escapeDoubleQuotedShellString = exports.escapeGradleString = exports.toAndroidScreenOrientation = exports.escapeJsonString = exports.getWebManifest = exports.rmdir = exports.validatePackageId = exports.validateNotEmpty = exports.generatePackageId = exports.findSuitableIcon = exports.execInteractive = exports.untar = exports.unzipFile = exports.executeFile = exports.execute = void 0;
18
+ exports.execute = execute;
19
+ exports.executeFile = executeFile;
20
+ exports.unzipFile = unzipFile;
21
+ exports.untar = untar;
22
+ exports.execInteractive = execInteractive;
23
+ exports.findSuitableIcon = findSuitableIcon;
24
+ exports.generatePackageId = generatePackageId;
25
+ exports.validateNotEmpty = validateNotEmpty;
26
+ exports.validatePackageId = validatePackageId;
27
+ exports.rmdir = rmdir;
28
+ exports.getWebManifest = getWebManifest;
29
+ exports.escapeJsonString = escapeJsonString;
30
+ exports.toAndroidScreenOrientation = toAndroidScreenOrientation;
31
+ exports.escapeGradleString = escapeGradleString;
32
+ exports.escapeDoubleQuotedShellString = escapeDoubleQuotedShellString;
19
33
  const extractZip = require("extract-zip");
20
34
  const fs = require("fs");
21
35
  const path_1 = require("path");
@@ -23,9 +37,9 @@ const util_1 = require("util");
23
37
  const child_process_1 = require("child_process");
24
38
  const tar_1 = require("tar");
25
39
  const FetchUtils_1 = require("./FetchUtils");
26
- const execPromise = util_1.promisify(child_process_1.exec);
27
- const execFilePromise = util_1.promisify(child_process_1.execFile);
28
- const extractZipPromise = util_1.promisify(extractZip);
40
+ const execPromise = (0, util_1.promisify)(child_process_1.exec);
41
+ const execFilePromise = (0, util_1.promisify)(child_process_1.execFile);
42
+ const extractZipPromise = (0, util_1.promisify)(extractZip);
29
43
  // Regex for disallowed characters on Android Packages, as per
30
44
  // https://developer.android.com/guide/topics/manifest/manifest-element.html#package
31
45
  const DISALLOWED_ANDROID_PACKAGE_CHARS_REGEX = /[^a-zA-Z0-9_\.]/g;
@@ -47,24 +61,21 @@ async function execute(cmd, env, log) {
47
61
  }
48
62
  return await execPromise(joinedCmd, { env: env });
49
63
  }
50
- exports.execute = execute;
51
64
  async function executeFile(cmd, args, env, log, cwd) {
52
65
  if (log) {
53
66
  log.debug(`Executing command ${cmd} with args ${args}`);
54
67
  }
55
68
  return await execFilePromise(cmd, args, { env: env, cwd: cwd });
56
69
  }
57
- exports.executeFile = executeFile;
58
70
  async function unzipFile(zipFile, destinationPath, deleteZipWhenDone = false) {
59
71
  await extractZipPromise(zipFile, { dir: destinationPath });
60
72
  if (deleteZipWhenDone) {
61
73
  fs.unlinkSync(zipFile);
62
74
  }
63
75
  }
64
- exports.unzipFile = unzipFile;
65
76
  async function untar(tarFile, destinationPath, deleteZipWhenDone = false) {
66
77
  console.log(`Extracting ${tarFile} to ${destinationPath}`);
67
- await tar_1.x({
78
+ await (0, tar_1.x)({
68
79
  file: tarFile,
69
80
  cwd: destinationPath,
70
81
  unlink: true,
@@ -73,9 +84,8 @@ async function untar(tarFile, destinationPath, deleteZipWhenDone = false) {
73
84
  fs.unlinkSync(tarFile);
74
85
  }
75
86
  }
76
- exports.untar = untar;
77
87
  function execInteractive(cwd, args, env) {
78
- const shell = child_process_1.spawn(`"${cwd}"`, args, {
88
+ const shell = (0, child_process_1.spawn)(`"${cwd}"`, args, {
79
89
  stdio: 'inherit',
80
90
  env: env,
81
91
  shell: true,
@@ -91,7 +101,6 @@ function execInteractive(cwd, args, env) {
91
101
  });
92
102
  });
93
103
  }
94
- exports.execInteractive = execInteractive;
95
104
  /**
96
105
  * Fetches data for the largest icon from the web app manifest with a given purpose.
97
106
  * @param {Array<WebManifestIcon>|undefined} icons List of the manifest icons.
@@ -120,7 +129,6 @@ function findSuitableIcon(icons, purpose, minSize = 0) {
120
129
  largestIcon.size = largestIconSize;
121
130
  return largestIcon;
122
131
  }
123
- exports.findSuitableIcon = findSuitableIcon;
124
132
  /**
125
133
  * Generates an Android Application Id / Package Name, using the reverse hostname as a base
126
134
  * and appending `.twa` to the end.
@@ -156,7 +164,6 @@ function generatePackageId(host) {
156
164
  packageId.push('twa');
157
165
  return packageId.join('.').replace(DISALLOWED_ANDROID_PACKAGE_CHARS_REGEX, '_');
158
166
  }
159
- exports.generatePackageId = generatePackageId;
160
167
  /**
161
168
  * Validates if a string is not null and not empty.
162
169
  * @param input the string to be validated
@@ -169,7 +176,6 @@ function validateNotEmpty(input, fieldName) {
169
176
  }
170
177
  return null;
171
178
  }
172
- exports.validateNotEmpty = validateNotEmpty;
173
179
  /**
174
180
  * Validates a Package Id, according to the documentation at:
175
181
  * https://developer.android.com/studio/build/application-id
@@ -206,7 +212,6 @@ function validatePackageId(input) {
206
212
  }
207
213
  return null;
208
214
  }
209
- exports.validatePackageId = validatePackageId;
210
215
  /**
211
216
  * Removes a file or directory. If the path is a directory, recursively deletes files and
212
217
  * directories inside it.
@@ -224,10 +229,9 @@ async function rmdir(path) {
224
229
  // This is a directory. We delete files and sub directories inside it, then delete the
225
230
  // directory itself.
226
231
  const entries = fs.readdirSync(path);
227
- await Promise.all(entries.map((entry) => rmdir(path_1.join(path, entry))));
232
+ await Promise.all(entries.map((entry) => rmdir((0, path_1.join)(path, entry))));
228
233
  await fs.promises.rmdir(path);
229
234
  }
230
- exports.rmdir = rmdir;
231
235
  ;
232
236
  /**
233
237
  * Given a Web Manifest's URL, the function returns the web manifest as a JSON object.
@@ -243,7 +247,6 @@ async function getWebManifest(webManifestUrl) {
243
247
  }
244
248
  return await response.json();
245
249
  }
246
- exports.getWebManifest = getWebManifest;
247
250
  /**
248
251
  * Given a JSON string, the function returns an escaped representation of the string.
249
252
  * eg: Turns every " instance into \\".
@@ -256,7 +259,6 @@ function escapeJsonString(stringToReplace) {
256
259
  const regExp = new RegExp('\"', 'g');
257
260
  return stringToReplace.replace(regExp, '\\\\\"');
258
261
  }
259
- exports.escapeJsonString = escapeJsonString;
260
262
  // This is the value of the screenOrientation for the LauncherActivity which determines the
261
263
  // orientation of the splash screen.
262
264
  // This methods maps the Web Manifest orientation to the android screenOrientation:
@@ -287,7 +289,6 @@ function toAndroidScreenOrientation(orientation) {
287
289
  default: return 'ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED';
288
290
  }
289
291
  }
290
- exports.toAndroidScreenOrientation = toAndroidScreenOrientation;
291
292
  /**
292
293
  * Escapes a string that will be written to the Gradle file. The characters need to be escaped
293
294
  * multiple times, as they also need to be escaped inside the Gradle file.
@@ -298,7 +299,6 @@ exports.toAndroidScreenOrientation = toAndroidScreenOrientation;
298
299
  function escapeGradleString(input) {
299
300
  return input.replace(/[\\']/g, '\\\\\\$&');
300
301
  }
301
- exports.escapeGradleString = escapeGradleString;
302
302
  /**
303
303
  * Escapes a string that will be used inside a double quoted block in the shell. The characters
304
304
  * ", $, `, and \ need escaping even when the string is surrounded by double quotes.
@@ -306,4 +306,3 @@ exports.escapeGradleString = escapeGradleString;
306
306
  function escapeDoubleQuotedShellString(input) {
307
307
  return input.replace(/([\$"`\\])/g, '\\$1');
308
308
  }
309
- exports.escapeDoubleQuotedShellString = escapeDoubleQuotedShellString;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  export declare enum Format {
3
2
  jpeg = "jpeg",
4
3
  jpg = "jpg",
@@ -15,19 +15,20 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.svg2img = exports.Format = void 0;
18
+ exports.Format = void 0;
19
+ exports.svg2img = svg2img;
19
20
  const resvg_js_1 = require("@resvg/resvg-js");
20
21
  var Format;
21
22
  (function (Format) {
22
23
  Format["jpeg"] = "jpeg";
23
24
  Format["jpg"] = "jpg";
24
25
  Format["png"] = "png";
25
- })(Format = exports.Format || (exports.Format = {}));
26
+ })(Format || (exports.Format = Format = {}));
26
27
  async function svg2img(svg) {
27
28
  const opt = {
28
29
  fitTo: {
29
30
  mode: 'width',
30
- value: 1200,
31
+ value: 1200, // Generate the SVG with 1200px width, for larger icons.
31
32
  },
32
33
  };
33
34
  const resvg = new resvg_js_1.Resvg(svg, opt);
@@ -35,4 +36,3 @@ async function svg2img(svg) {
35
36
  const pngBuffer = pngData.asPng();
36
37
  return pngBuffer;
37
38
  }
38
- exports.svg2img = svg2img;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bubblewrap/core",
3
- "version": "1.20.1",
3
+ "version": "1.22.0",
4
4
  "description": "Core Library to generate, build and sign TWA projects",
5
5
  "engines": {
6
6
  "node": ">=14.15.0"
@@ -37,7 +37,7 @@
37
37
  "@types/color": "^3.0.0",
38
38
  "@types/extract-zip": "^1.6.2",
39
39
  "@types/gapi.client.androidpublisher": "^3.0.0",
40
- "@types/inquirer": "^6.5.0",
40
+ "@types/inquirer": "^9.0.7",
41
41
  "@types/lodash.template": "^4.5.0",
42
42
  "@types/mime-types": "^2.1.0",
43
43
  "@types/node": "^12.20.1",
@@ -49,7 +49,7 @@
49
49
  "extract-zip": "^1.7.0",
50
50
  "fetch-h2": "^2.5.1",
51
51
  "googleapis": "^81.0.0",
52
- "inquirer": "^7.3.3",
52
+ "inquirer": "^9.0.7",
53
53
  "jimp": "^0.22.7",
54
54
  "lodash.template": "^4.5.0",
55
55
  "mime-types": "^2.1.28",
@@ -57,5 +57,5 @@
57
57
  "tar": "^6.1.0",
58
58
  "valid-url": "^1.0.9"
59
59
  },
60
- "gitHead": "176aee15be2723c805b8f4df505dd4e9d6684025"
60
+ "gitHead": "2395d6aea6be141c146a1db435bc21fd06c41978"
61
61
  }
@@ -27,6 +27,7 @@ def twaManifest = [
27
27
  name: '<%= escapeGradleString(name) %>', // The application name.
28
28
  launcherName: '<%= escapeGradleString(launcherName) %>', // The name shown on the Android Launcher.
29
29
  themeColor: '<%= themeColor.hex() %>', // The color used for the status bar.
30
+ themeColorDark: '<%= themeColorDark.hex() %>', // The color used for the dark status bar.
30
31
  navigationColor: '<%= navigationColor.hex() %>', // The color used for the navigation bar.
31
32
  navigationColorDark: '<%= navigationColorDark.hex() %>', // The color used for the dark navbar.
32
33
  navigationDividerColor: '<%= navigationDividerColor.hex() %>', // The navbar divider color.
@@ -50,11 +51,12 @@ def twaManifest = [
50
51
  ]
51
52
 
52
53
  android {
53
- compileSdkVersion 33
54
+ compileSdkVersion 35
55
+ namespace "<%= packageId %>"
54
56
  defaultConfig {
55
57
  applicationId "<%= packageId %>"
56
58
  minSdkVersion <%= minSdkVersion %>
57
- targetSdkVersion 33
59
+ targetSdkVersion 35
58
60
  versionCode <%= appVersionCode %>
59
61
  versionName "<%= appVersionName %>"
60
62
 
@@ -94,6 +96,11 @@ android {
94
96
  // compile. If not set, the status bar color defaults to #FFFFFF - white.
95
97
  resValue "color", "colorPrimary", twaManifest.themeColor
96
98
 
99
+ // This attribute sets the dark status bar color for the TWA. It can be either set here or in
100
+ // `res/values/colors.xml`. Setting in both places is an error and the app will not
101
+ // compile. If not set, the status bar color defaults to #000000 - white.
102
+ resValue "color", "colorPrimaryDark", twaManifest.themeColorDark
103
+
97
104
  // This attribute sets the navigation bar color for the TWA. It can be either set here or
98
105
  // in `res/values/colors.xml`. Setting in both places is an error and the app will not
99
106
  // compile. If not set, the navigation bar color defaults to #FFFFFF - white.
@@ -109,6 +109,10 @@
109
109
  android:name="android.support.customtabs.trusted.STATUS_BAR_COLOR"
110
110
  android:resource="@color/colorPrimary" />
111
111
 
112
+ <meta-data
113
+ android:name="android.support.customtabs.trusted.STATUS_BAR_COLOR_DARK"
114
+ android:resource="@color/colorPrimaryDark" />
115
+
112
116
  <meta-data
113
117
  android:name="android.support.customtabs.trusted.NAVIGATION_BAR_COLOR"
114
118
  android:resource="@color/navigationColor" />
@@ -23,7 +23,7 @@ buildscript {
23
23
  jcenter()
24
24
  }
25
25
  dependencies {
26
- classpath 'com.android.tools.build:gradle:4.1.3'
26
+ classpath 'com.android.tools.build:gradle:8.5.0'
27
27
 
28
28
  // NOTE: Do not place your application dependencies here; they belong
29
29
  // in the individual module build.gradle files
@@ -2,4 +2,6 @@ distributionBase=GRADLE_USER_HOME
2
2
  distributionPath=wrapper/dists
3
3
  zipStoreBase=GRADLE_USER_HOME
4
4
  zipStorePath=wrapper/dists
5
- distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
5
+ distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
6
+ networkTimeout=10000
7
+ validateDistributionUrl=true