@bubblewrap/core 1.18.0 → 1.19.1

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/README.md CHANGED
@@ -19,7 +19,7 @@
19
19
 
20
20
  Bubblewrap Core is a NodeJS library that helps developers to create a Project for an Android
21
21
  application that launches an existing Progressive Web App (PWA) using a
22
- [Trusted Web Activity (TWA)](https://developers.google.com/web/android/trusted-web-activity/).
22
+ [Trusted Web Activity (TWA)](https://developer.chrome.com/docs/android/trusted-web-activity/).
23
23
 
24
24
  ## Requirements
25
25
  - [Node.js](https://nodejs.org/en/) 12.0 or above
@@ -101,15 +101,12 @@ class ImageHelper {
101
101
  }
102
102
  let body = await response.arrayBuffer();
103
103
  if (contentType.startsWith('image/svg')) {
104
- if (!svg2img_1.isSvgSupported()) {
105
- throw new Error(`This installation doesn't support image/svg. Please, ensure the optional
106
- "svg2img" library is installed or use an alternative image format.`);
107
- }
104
+ const textDecoder = new TextDecoder();
108
105
  try {
109
- body = await svg2img_1.svg2img(iconUrl);
106
+ body = await svg2img_1.svg2img(textDecoder.decode(body));
110
107
  }
111
108
  catch (error) {
112
- throw new Error(`Problem reading ${iconUrl}: ${error.message}`);
109
+ throw new Error(`Problem reading ${iconUrl}: ${error}`);
113
110
  }
114
111
  }
115
112
  return {
@@ -45,8 +45,10 @@ class ShortcutInfo {
45
45
  }
46
46
  }
47
47
  toString(index) {
48
- return `[name:'${this.name}', short_name:'${this.shortName}', ` +
49
- `url:'${this.url}', icon:'${this.assetName(index)}']`;
48
+ return `[name:'${util_1.escapeGradleString(this.name)}', ` +
49
+ `short_name:'${util_1.escapeGradleString(this.shortName)}', ` +
50
+ `url:'${this.url}', ` +
51
+ `icon:'${this.assetName(index)}']`;
50
52
  }
51
53
  assetName(index) {
52
54
  return `shortcut_${index}`;
@@ -23,8 +23,8 @@ const FirstRunFlagFeature_1 = require("./FirstRunFlagFeature");
23
23
  const Log_1 = require("../Log");
24
24
  const ArCoreFeature_1 = require("./ArCoreFeature");
25
25
  const ANDROID_BROWSER_HELPER_VERSIONS = {
26
- stable: 'com.google.androidbrowserhelper:androidbrowserhelper:2.3.0',
27
- alpha: 'com.google.androidbrowserhelper:androidbrowserhelper:2.3.0',
26
+ stable: 'com.google.androidbrowserhelper:androidbrowserhelper:2.4.0',
27
+ alpha: 'com.google.androidbrowserhelper:androidbrowserhelper:2.4.0',
28
28
  };
29
29
  /**
30
30
  * Analyzes a TwaManifest to collect enable features and aggregates all customizations that will
@@ -91,6 +91,10 @@ class FeatureManager {
91
91
  if ((_g = twaManifest.features.arCore) === null || _g === void 0 ? void 0 : _g.enabled) {
92
92
  this.addFeature(new ArCoreFeature_1.ArCoreFeature());
93
93
  }
94
+ // Android T+ needs permission to request sending notifications.
95
+ if (twaManifest.enableNotifications) {
96
+ this.androidManifest.permissions.add('android.permission.POST_NOTIFICATIONS');
97
+ }
94
98
  }
95
99
  addFeature(feature) {
96
100
  // Adds properties to build.
@@ -4,12 +4,4 @@ export declare enum Format {
4
4
  jpg = "jpg",
5
5
  png = "png"
6
6
  }
7
- export interface Svg2imgOptions {
8
- width?: number;
9
- height?: number;
10
- preserveAspectRatio?: boolean | string;
11
- format?: Format;
12
- quality?: number;
13
- }
14
- export declare function isSvgSupported(): boolean;
15
- export declare function svg2img(svg: string, options?: Svg2imgOptions): Promise<Buffer>;
7
+ export declare function svg2img(svg: string): Promise<Buffer>;
@@ -15,40 +15,24 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.svg2img = exports.isSvgSupported = exports.Format = void 0;
19
- // This class is needed because svg2img's typescript type definitions didn't work.
20
- // once it will, there is no need for this class.
21
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
22
- let _svg2img;
23
- try {
24
- // eslint-disable-next-line @typescript-eslint/no-var-requires
25
- _svg2img = require('svg2img');
26
- }
27
- catch (e) {
28
- console.debug('Unable to load the "svg2img" library. SVGs are not supported');
29
- }
18
+ exports.svg2img = exports.Format = void 0;
19
+ const resvg_js_1 = require("@resvg/resvg-js");
30
20
  var Format;
31
21
  (function (Format) {
32
22
  Format["jpeg"] = "jpeg";
33
23
  Format["jpg"] = "jpg";
34
24
  Format["png"] = "png";
35
25
  })(Format = exports.Format || (exports.Format = {}));
36
- function isSvgSupported() {
37
- return _svg2img !== undefined;
38
- }
39
- exports.isSvgSupported = isSvgSupported;
40
- function svg2img(svg, options = {}) {
41
- if (!_svg2img) {
42
- return Promise.reject(new Error('Failed to parse the SVG. The installation of the "svg2img" dependency failed ' +
43
- 'or Bubblewrap was installed with "--no-optional".'));
44
- }
45
- return new Promise((resolve, reject) => {
46
- _svg2img(svg, options, (error, buffer) => {
47
- if (error) {
48
- return reject(error);
49
- }
50
- return resolve(buffer);
51
- });
52
- });
26
+ async function svg2img(svg) {
27
+ const opt = {
28
+ fitTo: {
29
+ mode: 'width',
30
+ value: 1200,
31
+ },
32
+ };
33
+ const resvg = new resvg_js_1.Resvg(svg, opt);
34
+ const pngData = resvg.render();
35
+ const pngBuffer = pngData.asPng();
36
+ return pngBuffer;
53
37
  }
54
38
  exports.svg2img = svg2img;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bubblewrap/core",
3
- "version": "1.18.0",
3
+ "version": "1.19.1",
4
4
  "description": "Core Library to generate, build and sign TWA projects",
5
5
  "scripts": {
6
6
  "build": "tsc",
@@ -30,6 +30,7 @@
30
30
  "author": "",
31
31
  "license": "Apache-2.0",
32
32
  "dependencies": {
33
+ "@resvg/resvg-js": "^2.2.0",
33
34
  "@types/color": "^3.0.0",
34
35
  "@types/extract-zip": "^1.6.2",
35
36
  "@types/gapi.client.androidpublisher": "^3.0.0",
@@ -53,8 +54,5 @@
53
54
  "tar": "^6.1.0",
54
55
  "valid-url": "^1.0.9"
55
56
  },
56
- "optionalDependencies": {
57
- "svg2img": "^0.9.3"
58
- },
59
- "gitHead": "e9713580c8eebacdb96d745618414b186dcfddc3"
57
+ "gitHead": "0214f23544fd43aab07b7963a16d2d8fe25be7b4"
60
58
  }
@@ -42,7 +42,7 @@ def twaManifest = [
42
42
  // The duration of fade out animation in milliseconds to be played when removing splash screen.
43
43
  splashScreenFadeOutDuration: <%= splashScreenFadeOutDuration %>,
44
44
  generatorApp: '<%= generatorApp %>', // Application that generated the Android Project
45
- // The fallback strategy for when Trusted Web Activity is not avilable. Possible values are
45
+ // The fallback strategy for when Trusted Web Activity is not available. Possible values are
46
46
  // 'customtabs' and 'webview'.
47
47
  fallbackType: '<%= fallbackType %>',
48
48
  enableSiteSettingsShortcut: '<%= enableSiteSettingsShortcut %>',
@@ -86,7 +86,7 @@ android {
86
86
  <% } %>
87
87
 
88
88
  // The hostname is used when building the intent-filter, so the TWA is able to
89
- // handle Intents to open https://svgomg.firebaseapp.com.
89
+ // handle Intents to open host url of the application.
90
90
  resValue "string", "hostName", twaManifest.hostName
91
91
 
92
92
  // This attribute sets the status bar color for the TWA. It can be either set here or in
@@ -118,7 +118,7 @@ android {
118
118
  // Trusted Web Activity.
119
119
  resValue "color", "backgroundColor", twaManifest.backgroundColor
120
120
 
121
- // Defines a provider authority fot the Splash Screen
121
+ // Defines a provider authority for the Splash Screen
122
122
  resValue "string", "providerAuthority", twaManifest.applicationId + '.fileprovider'
123
123
 
124
124
  // The enableNotification resource is used to enable or disable the
@@ -233,6 +233,10 @@
233
233
  </intent-filter>
234
234
  </service>
235
235
 
236
+ <% if (enableNotifications) { %>
237
+ <activity android:name="com.google.androidbrowserhelper.trusted.NotificationPermissionRequestActivity" />
238
+ <% } %>
239
+
236
240
  <% for(const component of androidManifest.components) { %>
237
241
  <%= component %>
238
242
  <% } %>