@bubblewrap/core 1.17.0 → 1.18.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/dist/lib/TwaGenerator.js +1 -1
- package/dist/lib/TwaManifest.d.ts +7 -0
- package/dist/lib/TwaManifest.js +12 -2
- package/dist/lib/features/PlayBillingFeature.js +1 -1
- package/dist/lib/types/WebManifest.d.ts +1 -0
- package/dist/lib/util.js +22 -0
- package/package.json +2 -2
- package/template_project/app/build.gradle +8 -3
- package/template_project/app/src/main/AndroidManifest.xml +29 -0
package/dist/lib/TwaGenerator.js
CHANGED
|
@@ -222,7 +222,7 @@ class TwaGenerator {
|
|
|
222
222
|
`Responded with status ${response.status}`);
|
|
223
223
|
}
|
|
224
224
|
// We're writing as a string, but attempt to convert to check if it's a well-formed JSON.
|
|
225
|
-
const webManifestJson = await response.
|
|
225
|
+
const webManifestJson = JSON.parse((await response.text()).trim());
|
|
226
226
|
// We want to ensure that "start_url" is the same used to launch the Trusted Web Activity.
|
|
227
227
|
webManifestJson['start_url'] = twaManifest.startUrl;
|
|
228
228
|
const webManifestLocation = path.join(targetDirectory, WEB_MANIFEST_LOCATION);
|
|
@@ -56,6 +56,7 @@ declare type alphaDependencies = {
|
|
|
56
56
|
* splashScreenFadeOutDuration: 300
|
|
57
57
|
* isChromeOSOnly: false, // Setting to true will enable a feature that prevents non-ChromeOS devices
|
|
58
58
|
* from installing the app.
|
|
59
|
+
* isMetaQuest: false, // Setting to true will generate the build compatible with Meta Quest devices.
|
|
59
60
|
* serviceAccountJsonFile: '<%= serviceAccountJsonFile %>', // The service account used to communicate with
|
|
60
61
|
* Google Play.
|
|
61
62
|
*
|
|
@@ -89,6 +90,9 @@ export declare class TwaManifest {
|
|
|
89
90
|
alphaDependencies: alphaDependencies;
|
|
90
91
|
enableSiteSettingsShortcut: boolean;
|
|
91
92
|
isChromeOSOnly: boolean;
|
|
93
|
+
isMetaQuest: boolean;
|
|
94
|
+
fullScopeUrl?: URL;
|
|
95
|
+
minSdkVersion: number;
|
|
92
96
|
shareTarget?: ShareTarget;
|
|
93
97
|
orientation: Orientation;
|
|
94
98
|
fingerprints: Fingerprint[];
|
|
@@ -221,6 +225,9 @@ export interface TwaManifestJson {
|
|
|
221
225
|
};
|
|
222
226
|
enableSiteSettingsShortcut?: boolean;
|
|
223
227
|
isChromeOSOnly?: boolean;
|
|
228
|
+
isMetaQuest?: boolean;
|
|
229
|
+
fullScopeUrl?: string;
|
|
230
|
+
minSdkVersion?: number;
|
|
224
231
|
shareTarget?: ShareTarget;
|
|
225
232
|
orientation?: Orientation;
|
|
226
233
|
fingerprints?: Fingerprint[];
|
package/dist/lib/TwaManifest.js
CHANGED
|
@@ -57,6 +57,7 @@ const DEFAULT_NAVIGATION_DIVIDER_COLOR = '#00000000';
|
|
|
57
57
|
const DEFAULT_BACKGROUND_COLOR = '#FFFFFF';
|
|
58
58
|
const DEFAULT_APP_VERSION_CODE = 1;
|
|
59
59
|
const DEFAULT_APP_VERSION_NAME = DEFAULT_APP_VERSION_CODE.toString();
|
|
60
|
+
const DEFAULT_MIN_SDK_VERSION = 19;
|
|
60
61
|
const DEFAULT_SIGNING_KEY_PATH = './android.keystore';
|
|
61
62
|
const DEFAULT_SIGNING_KEY_ALIAS = 'android';
|
|
62
63
|
const DEFAULT_ENABLE_NOTIFICATIONS = true;
|
|
@@ -93,6 +94,7 @@ const DEFAULT_ORIENTATION = 'default';
|
|
|
93
94
|
* splashScreenFadeOutDuration: 300
|
|
94
95
|
* isChromeOSOnly: false, // Setting to true will enable a feature that prevents non-ChromeOS devices
|
|
95
96
|
* from installing the app.
|
|
97
|
+
* isMetaQuest: false, // Setting to true will generate the build compatible with Meta Quest devices.
|
|
96
98
|
* serviceAccountJsonFile: '<%= serviceAccountJsonFile %>', // The service account used to communicate with
|
|
97
99
|
* Google Play.
|
|
98
100
|
*
|
|
@@ -133,6 +135,9 @@ class TwaManifest {
|
|
|
133
135
|
this.enableSiteSettingsShortcut = data.enableSiteSettingsShortcut != undefined ?
|
|
134
136
|
data.enableSiteSettingsShortcut : true;
|
|
135
137
|
this.isChromeOSOnly = data.isChromeOSOnly != undefined ? data.isChromeOSOnly : false;
|
|
138
|
+
this.isMetaQuest = data.isMetaQuest != undefined ? data.isMetaQuest : false;
|
|
139
|
+
this.fullScopeUrl = data.fullScopeUrl ? new URL(data.fullScopeUrl) : undefined;
|
|
140
|
+
this.minSdkVersion = data.minSdkVersion || DEFAULT_MIN_SDK_VERSION;
|
|
136
141
|
this.shareTarget = data.shareTarget;
|
|
137
142
|
this.orientation = data.orientation || DEFAULT_ORIENTATION;
|
|
138
143
|
this.fingerprints = data.fingerprints || [];
|
|
@@ -155,6 +160,7 @@ class TwaManifest {
|
|
|
155
160
|
backgroundColor: this.backgroundColor.hex(),
|
|
156
161
|
appVersion: this.appVersionName,
|
|
157
162
|
webManifestUrl: this.webManifestUrl ? this.webManifestUrl.toString() : undefined,
|
|
163
|
+
fullScopeUrl: this.fullScopeUrl ? this.fullScopeUrl.toString() : undefined,
|
|
158
164
|
});
|
|
159
165
|
}
|
|
160
166
|
/**
|
|
@@ -212,6 +218,7 @@ class TwaManifest {
|
|
|
212
218
|
const maskableIcon = util_1.findSuitableIcon(webManifest.icons, 'maskable', MIN_ICON_SIZE);
|
|
213
219
|
const monochromeIcon = util_1.findSuitableIcon(webManifest.icons, 'monochrome', MIN_NOTIFICATION_ICON_SIZE);
|
|
214
220
|
const fullStartUrl = new URL(webManifest['start_url'] || '/', webManifestUrl);
|
|
221
|
+
const fullScopeUrl = new URL(webManifest['scope'] || '.', webManifestUrl);
|
|
215
222
|
const shortcuts = this.getShortcuts(webManifestUrl, webManifest);
|
|
216
223
|
function resolveIconUrl(icon) {
|
|
217
224
|
return icon ? new URL(icon.src, webManifestUrl).toString() : undefined;
|
|
@@ -244,6 +251,7 @@ class TwaManifest {
|
|
|
244
251
|
features: {},
|
|
245
252
|
shareTarget: TwaManifest.verifyShareTarget(webManifestUrl, webManifest.share_target),
|
|
246
253
|
orientation: asOrientation(webManifest.orientation) || DEFAULT_ORIENTATION,
|
|
254
|
+
fullScopeUrl: fullScopeUrl.toString(),
|
|
247
255
|
});
|
|
248
256
|
return twaManifest;
|
|
249
257
|
}
|
|
@@ -273,7 +281,7 @@ class TwaManifest {
|
|
|
273
281
|
*/
|
|
274
282
|
static async fromWebManifest(url) {
|
|
275
283
|
const response = await FetchUtils_1.fetchUtils.fetch(url);
|
|
276
|
-
const webManifest = await response.
|
|
284
|
+
const webManifest = JSON.parse((await response.text()).trim());
|
|
277
285
|
const webManifestUrl = new URL(url);
|
|
278
286
|
return TwaManifest.fromWebManifestJson(webManifestUrl, webManifest);
|
|
279
287
|
}
|
|
@@ -355,7 +363,7 @@ class TwaManifest {
|
|
|
355
363
|
* @returns {Promise<TwaManifest>} the new and merged Twa manifest.
|
|
356
364
|
*/
|
|
357
365
|
static async merge(fieldsToIgnore, webManifestUrl, webManifest, oldTwaManifest) {
|
|
358
|
-
var _a;
|
|
366
|
+
var _a, _b;
|
|
359
367
|
let shortcuts = oldTwaManifest.shortcuts;
|
|
360
368
|
if (!(fieldsToIgnore.includes('shortcuts'))) {
|
|
361
369
|
shortcuts = this.getShortcuts(webManifestUrl, webManifest);
|
|
@@ -365,11 +373,13 @@ class TwaManifest {
|
|
|
365
373
|
const maskableIconUrl = this.getNewIconUrl(fieldsToIgnore, 'maskableIcons', oldTwaManifestJson.iconUrl, webManifest.icons, 'maskable', MIN_ICON_SIZE, webManifestUrl);
|
|
366
374
|
const monochromeIconUrl = this.getNewIconUrl(fieldsToIgnore, 'monochromeIcons', oldTwaManifestJson.iconUrl, webManifest.icons, 'monochrome', MIN_NOTIFICATION_ICON_SIZE, webManifestUrl);
|
|
367
375
|
const fullStartUrl = new URL(webManifest['start_url'] || '/', webManifestUrl);
|
|
376
|
+
const fullScopeUrl = new URL(webManifest['scope'] || '.', webManifestUrl);
|
|
368
377
|
const twaManifest = new TwaManifest({
|
|
369
378
|
...oldTwaManifestJson,
|
|
370
379
|
name: this.getNewFieldValue('name', fieldsToIgnore, oldTwaManifest.name, webManifest['name'] || webManifest['short_name']),
|
|
371
380
|
launcherName: this.getNewFieldValue('short_name', fieldsToIgnore, oldTwaManifest.launcherName, webManifest['short_name'] || ((_a = webManifest['name']) === null || _a === void 0 ? void 0 : _a.substring(0, SHORT_NAME_MAX_SIZE))),
|
|
372
381
|
display: this.getNewFieldValue('display', fieldsToIgnore, oldTwaManifest.display, asDisplayMode(webManifest['display'])),
|
|
382
|
+
fullScopeUrl: this.getNewFieldValue('fullScopeUrl', fieldsToIgnore, (_b = oldTwaManifest.fullScopeUrl) === null || _b === void 0 ? void 0 : _b.toString(), fullScopeUrl.toString()),
|
|
373
383
|
themeColor: this.getNewFieldValue('themeColor', fieldsToIgnore, oldTwaManifest.themeColor.hex(), webManifest['theme_color']),
|
|
374
384
|
backgroundColor: this.getNewFieldValue('backgroundColor', fieldsToIgnore, oldTwaManifest.backgroundColor.hex(), webManifest['background_color']),
|
|
375
385
|
startUrl: this.getNewFieldValue('startUrl', fieldsToIgnore, oldTwaManifest.startUrl, fullStartUrl.pathname + fullStartUrl.search),
|
|
@@ -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-alpha09');
|
|
24
24
|
this.androidManifest.components.push(`
|
|
25
25
|
<activity
|
|
26
26
|
android:name="com.google.androidbrowserhelper.playbilling.provider.PaymentActivity"
|
package/dist/lib/util.js
CHANGED
|
@@ -30,6 +30,16 @@ const extractZipPromise = util_1.promisify(extractZip);
|
|
|
30
30
|
// https://developer.android.com/guide/topics/manifest/manifest-element.html#package
|
|
31
31
|
const DISALLOWED_ANDROID_PACKAGE_CHARS_REGEX = /[^a-zA-Z0-9_\.]/g;
|
|
32
32
|
const VALID_PACKAGE_ID_SEGMENT_REGEX = /^[a-zA-Z][A-Za-z0-9_]*$/;
|
|
33
|
+
// List of keywords for Java 11, as listed at
|
|
34
|
+
// https://docs.oracle.com/javase/specs/jls/se11/html/jls-3.html#jls-3.9.
|
|
35
|
+
const JAVA_KEYWORDS = [
|
|
36
|
+
'abstract', 'assert', 'boolean', 'break', 'byte', 'case', 'catch', 'char', 'class', 'const',
|
|
37
|
+
'continue', 'default', 'do', 'double', 'else', 'enum', 'extends', 'final', 'finally', 'float',
|
|
38
|
+
'for', 'goto', 'if', 'implements', 'import', 'instanceof', 'int', 'interface', 'long', 'native',
|
|
39
|
+
'new', 'package', 'private', 'protected', 'public', 'return', 'short', 'static', 'strictfp',
|
|
40
|
+
'super', 'switch', 'synchronized', 'this', 'throw', 'throws', 'transient', 'try', 'void',
|
|
41
|
+
'volatile', 'while',
|
|
42
|
+
];
|
|
33
43
|
async function execute(cmd, env, log) {
|
|
34
44
|
const joinedCmd = cmd.join(' ');
|
|
35
45
|
if (log) {
|
|
@@ -132,6 +142,12 @@ function generatePackageId(host) {
|
|
|
132
142
|
if (part.trim().length === 0) {
|
|
133
143
|
continue;
|
|
134
144
|
}
|
|
145
|
+
// Package names cannot contain Java keywords. The recommendation is adding an '_' before the
|
|
146
|
+
// keyword. See https://docs.oracle.com/javase/tutorial/java/package/namingpkgs.html.
|
|
147
|
+
if (JAVA_KEYWORDS.includes(part)) {
|
|
148
|
+
packageId.push('_' + part);
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
135
151
|
packageId.push(part);
|
|
136
152
|
}
|
|
137
153
|
if (packageId.length === 0) {
|
|
@@ -176,6 +192,12 @@ function validatePackageId(input) {
|
|
|
176
192
|
return 'packageId must have at least 2 sections separated by "."';
|
|
177
193
|
}
|
|
178
194
|
for (const part of parts) {
|
|
195
|
+
// Package names cannot contain Java keywords. The recommendation is adding an '_' before the
|
|
196
|
+
// keyword. See https://docs.oracle.com/javase/tutorial/java/package/namingpkgs.html.
|
|
197
|
+
if (JAVA_KEYWORDS.includes(part)) {
|
|
198
|
+
return `Invalid packageId section: "${part}". ${part} is a Java keyword and cannot be used` +
|
|
199
|
+
'as a package section. Consider adding an "_" before the section name.';
|
|
200
|
+
}
|
|
179
201
|
if (part.match(VALID_PACKAGE_ID_SEGMENT_REGEX) === null) {
|
|
180
202
|
return `Invalid packageId section: "${part}". Only alphanumeric characters and ` +
|
|
181
203
|
'underscore [a-zA-Z0-9_] are allowed in packageId sections. Each section must ' +
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bubblewrap/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.18.0",
|
|
4
4
|
"description": "Core Library to generate, build and sign TWA projects",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "tsc",
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"optionalDependencies": {
|
|
57
57
|
"svg2img": "^0.9.3"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "e9713580c8eebacdb96d745618414b186dcfddc3"
|
|
60
60
|
}
|
|
@@ -53,7 +53,7 @@ android {
|
|
|
53
53
|
compileSdkVersion 31
|
|
54
54
|
defaultConfig {
|
|
55
55
|
applicationId "<%= packageId %>"
|
|
56
|
-
minSdkVersion
|
|
56
|
+
minSdkVersion <%= minSdkVersion %>
|
|
57
57
|
targetSdkVersion 31
|
|
58
58
|
versionCode <%= appVersionCode %>
|
|
59
59
|
versionName "<%= appVersionName %>"
|
|
@@ -70,11 +70,16 @@ android {
|
|
|
70
70
|
|
|
71
71
|
<% if (webManifestUrl) { %>
|
|
72
72
|
// The URL the Web Manifest for the Progressive Web App that the TWA points to. This
|
|
73
|
-
// is used by Chrome OS to open the Web version of the PWA instead of
|
|
74
|
-
// will probably give a better user experience for non-mobile devices.
|
|
73
|
+
// is used by Chrome OS and Meta Quest to open the Web version of the PWA instead of
|
|
74
|
+
// the TWA, as it will probably give a better user experience for non-mobile devices.
|
|
75
75
|
resValue "string", "webManifestUrl", '<%= webManifestUrl %>'
|
|
76
76
|
<% } %>
|
|
77
77
|
|
|
78
|
+
<% if (fullScopeUrl) { %>
|
|
79
|
+
// This is used by Meta Quest.
|
|
80
|
+
resValue "string", "fullScopeUrl", '<%= fullScopeUrl %>'
|
|
81
|
+
<% } %>
|
|
82
|
+
|
|
78
83
|
<% if (shareTarget) { %>
|
|
79
84
|
// The data for the app to support web share target.
|
|
80
85
|
resValue "string", "shareTarget", '<%= escapeJsonString(escapeGradleString(JSON.stringify(shareTarget))) %>'
|
|
@@ -26,10 +26,25 @@
|
|
|
26
26
|
<uses-permission android:name="<%= permission %>"/>
|
|
27
27
|
<% } %>
|
|
28
28
|
|
|
29
|
+
<% if (isMetaQuest) { %>
|
|
30
|
+
<uses-permission android:name="com.oculus.permission.HAND_TRACKING" />
|
|
31
|
+
<% } %>
|
|
32
|
+
|
|
29
33
|
<% if (isChromeOSOnly) { %>
|
|
30
34
|
<uses-feature android:name="org.chromium.arc" android:required="true" />
|
|
31
35
|
<% } %>
|
|
32
36
|
|
|
37
|
+
<% if (isMetaQuest) { %>
|
|
38
|
+
<uses-feature
|
|
39
|
+
android:name="android.hardware.vr.headtracking"
|
|
40
|
+
android:required="false"
|
|
41
|
+
android:version="1" />
|
|
42
|
+
|
|
43
|
+
<uses-feature
|
|
44
|
+
android:name="oculus.software.handtracking"
|
|
45
|
+
android:required="false" />
|
|
46
|
+
<% } %>
|
|
47
|
+
|
|
33
48
|
<application
|
|
34
49
|
android:name="Application"
|
|
35
50
|
android:allowBackup="true"
|
|
@@ -61,6 +76,20 @@
|
|
|
61
76
|
android:value="<%= metadata.value %>" />
|
|
62
77
|
<% } %>
|
|
63
78
|
|
|
79
|
+
<% if (isMetaQuest) { %>
|
|
80
|
+
<meta-data
|
|
81
|
+
android:name="com.oculus.pwa.NAME"
|
|
82
|
+
android:value="@string/appName" />
|
|
83
|
+
|
|
84
|
+
<meta-data
|
|
85
|
+
android:name="com.oculus.pwa.START_URL"
|
|
86
|
+
android:value="@string/launchUrl" />
|
|
87
|
+
|
|
88
|
+
<meta-data
|
|
89
|
+
android:name="com.oculus.pwa.SCOPE"
|
|
90
|
+
android:value="@string/fullScopeUrl" />
|
|
91
|
+
<% } %>
|
|
92
|
+
|
|
64
93
|
<% if (enableSiteSettingsShortcut) { %>
|
|
65
94
|
<activity android:name="com.google.androidbrowserhelper.trusted.ManageDataLauncherActivity">
|
|
66
95
|
<meta-data
|