@glance-apps/sync 2.1.1 → 2.1.2

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/CHANGELOG.md CHANGED
@@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [2.1.2] - 2026-10-11
11
+
12
+ ### Fixed
13
+
14
+ - **`webdavFetch` awaits `nativeHttpRequest`.** The native path called the
15
+ bridge without `await`, so it only worked with a synchronous bridge, and a
16
+ synchronous bridge blocks the WebView's JS thread (input and rendering) for
17
+ the whole request. On Android that froze dayGLANCE for minutes on cold
18
+ start while a failing sync server timed out
19
+ (krelltunez/dayGLANCE#2048). The bridge may now return its result or a
20
+ Promise of it, as `SYNC_PACKAGE_SPEC.md` already documented; the type
21
+ says so too. A synchronous bridge keeps working unchanged.
22
+
10
23
  ## [2.1.1] - 2026-10-11
11
24
 
12
25
  ### Fixed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glance-apps/sync",
3
- "version": "2.1.1",
3
+ "version": "2.1.2",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/providers.js CHANGED
@@ -24,7 +24,8 @@ const toBase64 = (str) => btoa(String.fromCharCode(...new TextEncoder().encode(s
24
24
  * before deciding whether to pass a function here).
25
25
  *
26
26
  * @param {object} config
27
- * @param {Function|null} config.nativeHttpRequest - Android bridge fn, or null
27
+ * @param {Function|null} config.nativeHttpRequest - Android bridge fn, or null.
28
+ * May return its result or a Promise of it; prefer async (see webdavFetch).
28
29
  * @param {Function|null} config.electronProxyFetch - Electron proxy fn, or null
29
30
  * @param {string} [config.proxyUrl=''] - base URL for CORS proxy
30
31
  */
@@ -40,7 +41,11 @@ export const webdavFetch = (config) => async (method, targetUrl, authHeaders, bo
40
41
  if (body !== undefined && body !== null) {
41
42
  headers['Content-Type'] = extraHeaders['Content-Type'] || 'application/octet-stream';
42
43
  }
43
- const result = config.nativeHttpRequest(method, targetUrl, headers, body ?? '');
44
+ // Awaited: the bridge may return its result or a Promise of it. A
45
+ // synchronous bridge blocks the WebView's JS thread (input and rendering)
46
+ // for the whole request, so hosts should supply an async one
47
+ // (krelltunez/dayGLANCE#2048); awaiting a plain value is harmless.
48
+ const result = await config.nativeHttpRequest(method, targetUrl, headers, body ?? '');
44
49
  if (!result) throw new Error('Native HTTP bridge unavailable');
45
50
  return {
46
51
  status: result.status,
package/types/index.d.ts CHANGED
@@ -92,7 +92,7 @@ export type NativeHttpRequest = (
92
92
  url: string,
93
93
  headers: Record<string, string>,
94
94
  body: string | null,
95
- ) => NativeHttpResponse | null;
95
+ ) => NativeHttpResponse | null | Promise<NativeHttpResponse | null>;
96
96
 
97
97
  export type ElectronProxyFetch = (
98
98
  method: string,