@bubblewrap/core 1.15.0 → 1.17.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.
@@ -20,6 +20,9 @@ const fs = require("fs");
20
20
  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
+ 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 });
25
+ const fetchh2 = fetchh2Ctx.fetch;
23
26
  class FetchUtils {
24
27
  constructor() {
25
28
  this.fetchEngine = DEFAULT_FETCH_ENGINE;
@@ -29,10 +32,10 @@ class FetchUtils {
29
32
  }
30
33
  async fetch(input) {
31
34
  if (this.fetchEngine == 'node-fetch') {
32
- return await node_fetch_1.default(input, { redirect: 'follow' });
35
+ return await node_fetch_1.default(input, { redirect: 'follow', headers: { 'User-Agent': userAgent } });
33
36
  }
34
37
  else {
35
- return await fetch_h2_1.fetch(input, { redirect: 'follow' });
38
+ return await fetchh2(input, { redirect: 'follow' });
36
39
  }
37
40
  }
38
41
  /**
@@ -48,7 +51,7 @@ class FetchUtils {
48
51
  readableStream = result.body;
49
52
  }
50
53
  else {
51
- result = await fetch_h2_1.fetch(url, { redirect: 'follow' });
54
+ result = await fetchh2(url, { redirect: 'follow' });
52
55
  readableStream = await result.readable();
53
56
  }
54
57
  // Try to determine the file size via the `Content-Length` header. This may not be available
@@ -105,7 +105,12 @@ class ImageHelper {
105
105
  throw new Error(`This installation doesn't support image/svg. Please, ensure the optional
106
106
  "svg2img" library is installed or use an alternative image format.`);
107
107
  }
108
- body = await svg2img_1.svg2img(iconUrl);
108
+ try {
109
+ body = await svg2img_1.svg2img(iconUrl);
110
+ }
111
+ catch (error) {
112
+ throw new Error(`Problem reading ${iconUrl}: ${error.message}`);
113
+ }
109
114
  }
110
115
  return {
111
116
  url: iconUrl,
@@ -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="1.8') < 0) { // Checks if the jdk's version is 8 as needed
99
- return Result_1.Result.error(new ValidatePathError_1.ValidatePathError('JDK version not supported. JDK version 1.8 is required.', 'PathIsNotSupported'));
98
+ if (file.indexOf('JAVA_VERSION="11.0') < 0) { // Checks if the jdk's version is 11 as needed
99
+ return Result_1.Result.error(new ValidatePathError_1.ValidatePathError('JDK version not supported. JDK version 11 is required.', 'PathIsNotSupported'));
100
100
  }
101
101
  }
102
102
  catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bubblewrap/core",
3
- "version": "1.15.0",
3
+ "version": "1.17.1",
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": "cf5b2a9a6586d77a5cc051f43b0969cec541833e"
59
+ "gitHead": "3635b021e8531b783c2e89f5174668f9f4e2c6c5"
60
60
  }
@@ -77,7 +77,7 @@ android {
77
77
 
78
78
  <% if (shareTarget) { %>
79
79
  // The data for the app to support web share target.
80
- resValue "string", "shareTarget", '<%= escapeJsonString(JSON.stringify(shareTarget)) %>'
80
+ resValue "string", "shareTarget", '<%= escapeJsonString(escapeGradleString(JSON.stringify(shareTarget))) %>'
81
81
  <% } %>
82
82
 
83
83
  // The hostname is used when building the intent-filter, so the TWA is able to