@bubblewrap/core 1.18.1 → 1.20.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.
- package/README.md +1 -1
- package/dist/lib/DigitalAssetLinks.js +11 -14
- package/dist/lib/ImageHelper.js +3 -6
- package/dist/lib/ShortcutInfo.js +4 -2
- package/dist/lib/TwaManifest.d.ts +3 -3
- package/dist/lib/TwaManifest.js +3 -3
- package/dist/lib/androidSdk/AndroidSdkTools.d.ts +1 -1
- package/dist/lib/androidSdk/AndroidSdkTools.js +1 -1
- package/dist/lib/features/FeatureManager.js +4 -0
- package/dist/lib/wrappers/svg2img.d.ts +1 -9
- package/dist/lib/wrappers/svg2img.js +13 -29
- package/package.json +6 -5
- package/template_project/app/build.gradle +5 -5
- package/template_project/app/src/main/AndroidManifest.xml +4 -0
- package/template_project/app/.gitignore +0 -1
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ application that launches an existing Progressive Web App (PWA) using a
|
|
|
22
22
|
[Trusted Web Activity (TWA)](https://developer.chrome.com/docs/android/trusted-web-activity/).
|
|
23
23
|
|
|
24
24
|
## Requirements
|
|
25
|
-
- [Node.js](https://nodejs.org/en/)
|
|
25
|
+
- [Node.js](https://nodejs.org/en/) 14.15.0 or above
|
|
26
26
|
|
|
27
27
|
## Setting up the Environment
|
|
28
28
|
|
|
@@ -18,20 +18,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
18
18
|
exports.DigitalAssetLinks = void 0;
|
|
19
19
|
class DigitalAssetLinks {
|
|
20
20
|
static generateAssetLinks(applicationId, ...sha256Fingerprints) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
});
|
|
33
|
-
assetlinks.push(']');
|
|
34
|
-
return assetlinks.join('');
|
|
21
|
+
if (sha256Fingerprints.length === 0) {
|
|
22
|
+
return '[]';
|
|
23
|
+
}
|
|
24
|
+
return `[{
|
|
25
|
+
"relation": ["delegate_permission/common.handle_all_urls"],
|
|
26
|
+
"target": {
|
|
27
|
+
"namespace": "android_app",
|
|
28
|
+
"package_name": "${applicationId}",
|
|
29
|
+
"sha256_cert_fingerprints": ["${sha256Fingerprints.join('\", \"')}"]
|
|
30
|
+
}
|
|
31
|
+
}]\n`;
|
|
35
32
|
}
|
|
36
33
|
}
|
|
37
34
|
exports.DigitalAssetLinks = DigitalAssetLinks;
|
package/dist/lib/ImageHelper.js
CHANGED
|
@@ -101,15 +101,12 @@ class ImageHelper {
|
|
|
101
101
|
}
|
|
102
102
|
let body = await response.arrayBuffer();
|
|
103
103
|
if (contentType.startsWith('image/svg')) {
|
|
104
|
-
|
|
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(
|
|
106
|
+
body = await svg2img_1.svg2img(textDecoder.decode(body));
|
|
110
107
|
}
|
|
111
108
|
catch (error) {
|
|
112
|
-
throw new Error(`Problem reading ${iconUrl}: ${error
|
|
109
|
+
throw new Error(`Problem reading ${iconUrl}: ${error}`);
|
|
113
110
|
}
|
|
114
111
|
}
|
|
115
112
|
return {
|
package/dist/lib/ShortcutInfo.js
CHANGED
|
@@ -45,8 +45,10 @@ class ShortcutInfo {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
toString(index) {
|
|
48
|
-
return `[name:'${this.name}',
|
|
49
|
-
`
|
|
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}`;
|
|
@@ -45,12 +45,12 @@ declare type alphaDependencies = {
|
|
|
45
45
|
* enableSiteSettingsShortcut: true, // Set to false to disable the shortcut into site settings.
|
|
46
46
|
* // Add shortcuts for your app here. Every shortcut must include the following fields:
|
|
47
47
|
* // - name: String that will show up in the shortcut.
|
|
48
|
-
* // -
|
|
48
|
+
* // - shortName: Shorter string used if |name| is too long.
|
|
49
49
|
* // - url: Absolute path of the URL to launch the app with (e.g '/create').
|
|
50
|
-
* // -
|
|
50
|
+
* // - chosenIconUrl: Name of the resource in the drawable folder to use as an icon.
|
|
51
51
|
* shortcuts: [
|
|
52
52
|
* // Insert shortcuts here, for example:
|
|
53
|
-
* //
|
|
53
|
+
* // { name: 'Open SVG', shortName: 'Open', url: '/open', chosenIconUrl: 'https://example.com/example.svg' }
|
|
54
54
|
* ],
|
|
55
55
|
* // The duration of fade out animation in milliseconds to be played when removing splash screen.
|
|
56
56
|
* splashScreenFadeOutDuration: 300
|
package/dist/lib/TwaManifest.js
CHANGED
|
@@ -83,12 +83,12 @@ const DEFAULT_ORIENTATION = 'default';
|
|
|
83
83
|
* enableSiteSettingsShortcut: true, // Set to false to disable the shortcut into site settings.
|
|
84
84
|
* // Add shortcuts for your app here. Every shortcut must include the following fields:
|
|
85
85
|
* // - name: String that will show up in the shortcut.
|
|
86
|
-
* // -
|
|
86
|
+
* // - shortName: Shorter string used if |name| is too long.
|
|
87
87
|
* // - url: Absolute path of the URL to launch the app with (e.g '/create').
|
|
88
|
-
* // -
|
|
88
|
+
* // - chosenIconUrl: Name of the resource in the drawable folder to use as an icon.
|
|
89
89
|
* shortcuts: [
|
|
90
90
|
* // Insert shortcuts here, for example:
|
|
91
|
-
* //
|
|
91
|
+
* // { name: 'Open SVG', shortName: 'Open', url: '/open', chosenIconUrl: 'https://example.com/example.svg' }
|
|
92
92
|
* ],
|
|
93
93
|
* // The duration of fade out animation in milliseconds to be played when removing splash screen.
|
|
94
94
|
* splashScreenFadeOutDuration: 300
|
|
@@ -4,7 +4,7 @@ import { JdkHelper } from '../jdk/JdkHelper';
|
|
|
4
4
|
import { Log } from '../../lib/Log';
|
|
5
5
|
import { Result } from '../../lib/Result';
|
|
6
6
|
import { ValidatePathError } from '../errors/ValidatePathError';
|
|
7
|
-
export declare const BUILD_TOOLS_VERSION = "
|
|
7
|
+
export declare const BUILD_TOOLS_VERSION = "33.0.2";
|
|
8
8
|
/**
|
|
9
9
|
* Wraps functionality of the Android SDK Tools and allows them to be invoked programatically.
|
|
10
10
|
*/
|
|
@@ -22,7 +22,7 @@ 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 = '33.0.2';
|
|
26
26
|
/**
|
|
27
27
|
* Wraps functionality of the Android SDK Tools and allows them to be invoked programatically.
|
|
28
28
|
*/
|
|
@@ -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
|
|
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.
|
|
19
|
-
|
|
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
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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,7 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bubblewrap/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.20.0",
|
|
4
4
|
"description": "Core Library to generate, build and sign TWA projects",
|
|
5
|
+
"engines": {
|
|
6
|
+
"node": ">=14.15.0"
|
|
7
|
+
},
|
|
5
8
|
"scripts": {
|
|
6
9
|
"build": "tsc",
|
|
7
10
|
"clean": "del dist",
|
|
@@ -30,6 +33,7 @@
|
|
|
30
33
|
"author": "",
|
|
31
34
|
"license": "Apache-2.0",
|
|
32
35
|
"dependencies": {
|
|
36
|
+
"@resvg/resvg-js": "^2.2.0",
|
|
33
37
|
"@types/color": "^3.0.0",
|
|
34
38
|
"@types/extract-zip": "^1.6.2",
|
|
35
39
|
"@types/gapi.client.androidpublisher": "^3.0.0",
|
|
@@ -53,8 +57,5 @@
|
|
|
53
57
|
"tar": "^6.1.0",
|
|
54
58
|
"valid-url": "^1.0.9"
|
|
55
59
|
},
|
|
56
|
-
"
|
|
57
|
-
"svg2img": "^0.9.3"
|
|
58
|
-
},
|
|
59
|
-
"gitHead": "ce4579232bfb1a211e7c5cf2328fa52bdb26020d"
|
|
60
|
+
"gitHead": "8e1716ce14bbc2b06e175753094b7ffccbafd19d"
|
|
60
61
|
}
|
|
@@ -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
|
|
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 %>',
|
|
@@ -50,11 +50,11 @@ def twaManifest = [
|
|
|
50
50
|
]
|
|
51
51
|
|
|
52
52
|
android {
|
|
53
|
-
compileSdkVersion
|
|
53
|
+
compileSdkVersion 33
|
|
54
54
|
defaultConfig {
|
|
55
55
|
applicationId "<%= packageId %>"
|
|
56
56
|
minSdkVersion <%= minSdkVersion %>
|
|
57
|
-
targetSdkVersion
|
|
57
|
+
targetSdkVersion 33
|
|
58
58
|
versionCode <%= appVersionCode %>
|
|
59
59
|
versionName "<%= appVersionName %>"
|
|
60
60
|
|
|
@@ -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
|
|
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
|
|
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
|
<% } %>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/build
|