@capacitor/android 5.7.4 → 5.7.6

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.
@@ -109,6 +109,12 @@ var nativeBridge = (function (exports) {
109
109
  headers: { 'Content-Type': contentType || 'application/octet-stream' },
110
110
  };
111
111
  }
112
+ else if (body instanceof URLSearchParams) {
113
+ return {
114
+ data: body.toString(),
115
+ type: 'text',
116
+ };
117
+ }
112
118
  else if (body instanceof FormData) {
113
119
  const formData = await convertFormData(body);
114
120
  const boundary = `${Date.now()}`;
@@ -379,15 +385,15 @@ var nativeBridge = (function (exports) {
379
385
  typeof c.dir === 'function');
380
386
  };
381
387
  const serializeConsoleMessage = (msg) => {
382
- if (typeof msg === 'object') {
383
- try {
388
+ try {
389
+ if (typeof msg === 'object') {
384
390
  msg = JSON.stringify(msg);
385
391
  }
386
- catch (e) {
387
- // ignore
388
- }
392
+ return String(msg);
393
+ }
394
+ catch (e) {
395
+ return '';
389
396
  }
390
- return String(msg);
391
397
  };
392
398
  const platform = getPlatformId(win);
393
399
  if (platform == 'android' || platform == 'ios') {
@@ -496,11 +502,11 @@ var nativeBridge = (function (exports) {
496
502
  if (request.url.startsWith(`${cap.getServerUrl()}/`)) {
497
503
  return win.CapacitorWebFetch(resource, options);
498
504
  }
499
- if (!(options === null || options === void 0 ? void 0 : options.method) ||
500
- options.method.toLocaleUpperCase() === 'GET' ||
501
- options.method.toLocaleUpperCase() === 'HEAD' ||
502
- options.method.toLocaleUpperCase() === 'OPTIONS' ||
503
- options.method.toLocaleUpperCase() === 'TRACE') {
505
+ const { method } = request;
506
+ if (method.toLocaleUpperCase() === 'GET' ||
507
+ method.toLocaleUpperCase() === 'HEAD' ||
508
+ method.toLocaleUpperCase() === 'OPTIONS' ||
509
+ method.toLocaleUpperCase() === 'TRACE') {
504
510
  if (typeof resource === 'string') {
505
511
  return await win.CapacitorWebFetch(createProxyUrl(resource, win), options);
506
512
  }
@@ -512,8 +518,7 @@ var nativeBridge = (function (exports) {
512
518
  const tag = `CapacitorHttp fetch ${Date.now()} ${resource}`;
513
519
  console.time(tag);
514
520
  try {
515
- // intercept request & pass to the bridge
516
- const { body, method } = request;
521
+ const { body } = request;
517
522
  const optionHeaders = Object.fromEntries(request.headers.entries());
518
523
  const { data: requestData, type, headers, } = await convertBody((options === null || options === void 0 ? void 0 : options.body) || body || undefined, optionHeaders['Content-Type'] || optionHeaders['content-type']);
519
524
  const nativeResponse = await cap.nativePromise('CapacitorHttp', 'request', {
@@ -564,20 +569,7 @@ var nativeBridge = (function (exports) {
564
569
  value: xhr.method,
565
570
  writable: true,
566
571
  },
567
- readyState: {
568
- get: function () {
569
- var _a;
570
- return (_a = this._readyState) !== null && _a !== void 0 ? _a : 0;
571
- },
572
- set: function (val) {
573
- this._readyState = val;
574
- setTimeout(() => {
575
- this.dispatchEvent(new Event('readystatechange'));
576
- });
577
- },
578
- },
579
572
  });
580
- xhr.readyState = 0;
581
573
  const prototype = win.CapacitorWebXMLHttpRequest.prototype;
582
574
  const isProgressEventAvailable = () => typeof ProgressEvent !== 'undefined' &&
583
575
  ProgressEvent.prototype instanceof Event;
@@ -607,6 +599,20 @@ var nativeBridge = (function (exports) {
607
599
  this._url = createProxyUrl(this._url, win);
608
600
  return win.CapacitorWebXMLHttpRequest.open.call(this, method, this._url);
609
601
  }
602
+ Object.defineProperties(this, {
603
+ readyState: {
604
+ get: function () {
605
+ var _a;
606
+ return (_a = this._readyState) !== null && _a !== void 0 ? _a : 0;
607
+ },
608
+ set: function (val) {
609
+ this._readyState = val;
610
+ setTimeout(() => {
611
+ this.dispatchEvent(new Event('readystatechange'));
612
+ });
613
+ },
614
+ },
615
+ });
610
616
  setTimeout(() => {
611
617
  this.dispatchEvent(new Event('loadstart'));
612
618
  });
@@ -11,8 +11,8 @@ import com.getcapacitor.annotation.CapacitorPlugin;
11
11
  import com.getcapacitor.annotation.Permission;
12
12
  import com.getcapacitor.plugin.util.CapacitorHttpUrlConnection;
13
13
  import com.getcapacitor.plugin.util.HttpRequestHandler;
14
- import java.util.HashMap;
15
14
  import java.util.Map;
15
+ import java.util.concurrent.ConcurrentHashMap;
16
16
  import java.util.concurrent.ExecutorService;
17
17
  import java.util.concurrent.Executors;
18
18
 
@@ -24,7 +24,7 @@ import java.util.concurrent.Executors;
24
24
  )
25
25
  public class CapacitorHttp extends Plugin {
26
26
 
27
- private final Map<Runnable, PluginCall> activeRequests = new HashMap<>();
27
+ private final Map<Runnable, PluginCall> activeRequests = new ConcurrentHashMap<>();
28
28
  private final ExecutorService executor = Executors.newCachedThreadPool();
29
29
 
30
30
  @Override
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor/android",
3
- "version": "5.7.4",
3
+ "version": "5.7.6",
4
4
  "description": "Capacitor: Cross-platform apps with JavaScript and the web",
5
5
  "homepage": "https://capacitorjs.com",
6
6
  "author": "Ionic Team <hi@ionic.io> (https://ionic.io)",