@le-space/ui 0.3.13 → 0.3.14

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@le-space/ui",
3
- "version": "0.3.13",
3
+ "version": "0.3.14",
4
4
  "description": "Floating Aleph sponsor relay UI components for Svelte and React.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -36,8 +36,8 @@
36
36
  "access": "public"
37
37
  },
38
38
  "dependencies": {
39
- "@le-space/browser": "0.3.13",
40
- "@le-space/core": "0.3.13",
39
+ "@le-space/browser": "0.3.14",
40
+ "@le-space/core": "0.3.14",
41
41
  "viem": "^2.38.5"
42
42
  },
43
43
  "peerDependencies": {
package/react/index.js CHANGED
@@ -39,7 +39,7 @@ var RECENT_INSTANCE_RUNTIME_GRACE_MS = 10 * 60 * 1e3;
39
39
  var DEPLOYMENT_PENDING_WARNING_MS = 3 * 60 * 1e3;
40
40
 
41
41
  // src/shared/package-version.ts
42
- var UI_PACKAGE_VERSION = "0.3.13";
42
+ var UI_PACKAGE_VERSION = "0.3.14";
43
43
 
44
44
  // src/shared/format.ts
45
45
  function shortHash(value, head = 8, tail = 6) {
@@ -2078,6 +2078,7 @@ async function fetchUcGoPeerMetadata(args) {
2078
2078
  const delayMs = Math.max(0, Number(args.delayMs ?? 3e3));
2079
2079
  const sleep = args.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
2080
2080
  let lastPayload = null;
2081
+ let lastError = null;
2081
2082
  for (let attempt = 0; attempt < attempts; attempt += 1) {
2082
2083
  const controller = new AbortController();
2083
2084
  const timeout = setTimeout(
@@ -2094,8 +2095,14 @@ async function fetchUcGoPeerMetadata(args) {
2094
2095
  );
2095
2096
  const payload = await response.json().catch(() => null);
2096
2097
  lastPayload = payload;
2098
+ lastError = null;
2097
2099
  const ready = Boolean(
2098
- response.ok && payload && typeof payload === "object" && payload.status === "ready"
2100
+ args.isReady ? args.isReady({
2101
+ payload,
2102
+ ok: response.ok,
2103
+ status: response.status,
2104
+ requestUrl
2105
+ }) : response.ok && payload && typeof payload === "object" && payload.status === "ready"
2099
2106
  );
2100
2107
  args.onAttempt?.({
2101
2108
  payload,
@@ -2110,12 +2117,11 @@ async function fetchUcGoPeerMetadata(args) {
2110
2117
  if (ready) {
2111
2118
  return payload;
2112
2119
  }
2113
- if (response.status >= 500) {
2114
- throw new Error(
2115
- `Relay metadata request failed: ${response.status} ${typeof payload === "string" ? payload : JSON.stringify(payload ?? {})}`
2116
- );
2117
- }
2118
2120
  } catch (error) {
2121
+ lastError = error instanceof Error ? error.message : String(error);
2122
+ lastPayload = {
2123
+ error: lastError
2124
+ };
2119
2125
  args.onAttempt?.({
2120
2126
  payload: null,
2121
2127
  ready: false,
@@ -2124,9 +2130,8 @@ async function fetchUcGoPeerMetadata(args) {
2124
2130
  requestUrl,
2125
2131
  ok: false,
2126
2132
  status: null,
2127
- error: error instanceof Error ? error.message : String(error)
2133
+ error: lastError
2128
2134
  });
2129
- throw error;
2130
2135
  } finally {
2131
2136
  clearTimeout(timeout);
2132
2137
  }
@@ -2135,7 +2140,7 @@ async function fetchUcGoPeerMetadata(args) {
2135
2140
  }
2136
2141
  }
2137
2142
  throw new Error(
2138
- `Relay metadata did not become ready after ${attempts} attempts: ${typeof lastPayload === "string" ? lastPayload : JSON.stringify(lastPayload ?? {})}`
2143
+ `Relay metadata did not become ready after ${attempts} attempts: ${lastError ? lastError : typeof lastPayload === "string" ? lastPayload : JSON.stringify(lastPayload ?? {})}`
2139
2144
  );
2140
2145
  }
2141
2146
 
@@ -2814,6 +2819,7 @@ async function fetchRelayMetadataForRuntime(args) {
2814
2819
  attempts: args.attempts,
2815
2820
  delayMs: args.delayMs,
2816
2821
  timeoutMs: args.timeoutMs,
2822
+ isReady: (result) => extractRelayMetadata(result.payload) != null,
2817
2823
  onAttempt: (result) => {
2818
2824
  args.onAttempt?.({
2819
2825
  ...result,
package/shared/index.d.ts CHANGED
@@ -304,7 +304,7 @@ declare const STALE_INSTANCE_ALLOCATION_COOLDOWN_MS: number;
304
304
  declare const RECENT_INSTANCE_RUNTIME_GRACE_MS: number;
305
305
  declare const DEPLOYMENT_PENDING_WARNING_MS: number;
306
306
 
307
- declare const UI_PACKAGE_VERSION = "0.3.13";
307
+ declare const UI_PACKAGE_VERSION = "0.3.14";
308
308
 
309
309
  interface RootfsRequiredPortForward {
310
310
  port: number;
package/shared/index.js CHANGED
@@ -38,7 +38,7 @@ var RECENT_INSTANCE_RUNTIME_GRACE_MS = 10 * 60 * 1e3;
38
38
  var DEPLOYMENT_PENDING_WARNING_MS = 3 * 60 * 1e3;
39
39
 
40
40
  // src/shared/package-version.ts
41
- var UI_PACKAGE_VERSION = "0.3.13";
41
+ var UI_PACKAGE_VERSION = "0.3.14";
42
42
 
43
43
  // src/shared/format.ts
44
44
  function shortHash(value, head = 8, tail = 6) {
@@ -2077,6 +2077,7 @@ async function fetchUcGoPeerMetadata(args) {
2077
2077
  const delayMs = Math.max(0, Number(args.delayMs ?? 3e3));
2078
2078
  const sleep = args.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
2079
2079
  let lastPayload = null;
2080
+ let lastError = null;
2080
2081
  for (let attempt = 0; attempt < attempts; attempt += 1) {
2081
2082
  const controller = new AbortController();
2082
2083
  const timeout = setTimeout(
@@ -2093,8 +2094,14 @@ async function fetchUcGoPeerMetadata(args) {
2093
2094
  );
2094
2095
  const payload = await response.json().catch(() => null);
2095
2096
  lastPayload = payload;
2097
+ lastError = null;
2096
2098
  const ready = Boolean(
2097
- response.ok && payload && typeof payload === "object" && payload.status === "ready"
2099
+ args.isReady ? args.isReady({
2100
+ payload,
2101
+ ok: response.ok,
2102
+ status: response.status,
2103
+ requestUrl
2104
+ }) : response.ok && payload && typeof payload === "object" && payload.status === "ready"
2098
2105
  );
2099
2106
  args.onAttempt?.({
2100
2107
  payload,
@@ -2109,12 +2116,11 @@ async function fetchUcGoPeerMetadata(args) {
2109
2116
  if (ready) {
2110
2117
  return payload;
2111
2118
  }
2112
- if (response.status >= 500) {
2113
- throw new Error(
2114
- `Relay metadata request failed: ${response.status} ${typeof payload === "string" ? payload : JSON.stringify(payload ?? {})}`
2115
- );
2116
- }
2117
2119
  } catch (error) {
2120
+ lastError = error instanceof Error ? error.message : String(error);
2121
+ lastPayload = {
2122
+ error: lastError
2123
+ };
2118
2124
  args.onAttempt?.({
2119
2125
  payload: null,
2120
2126
  ready: false,
@@ -2123,9 +2129,8 @@ async function fetchUcGoPeerMetadata(args) {
2123
2129
  requestUrl,
2124
2130
  ok: false,
2125
2131
  status: null,
2126
- error: error instanceof Error ? error.message : String(error)
2132
+ error: lastError
2127
2133
  });
2128
- throw error;
2129
2134
  } finally {
2130
2135
  clearTimeout(timeout);
2131
2136
  }
@@ -2134,7 +2139,7 @@ async function fetchUcGoPeerMetadata(args) {
2134
2139
  }
2135
2140
  }
2136
2141
  throw new Error(
2137
- `Relay metadata did not become ready after ${attempts} attempts: ${typeof lastPayload === "string" ? lastPayload : JSON.stringify(lastPayload ?? {})}`
2142
+ `Relay metadata did not become ready after ${attempts} attempts: ${lastError ? lastError : typeof lastPayload === "string" ? lastPayload : JSON.stringify(lastPayload ?? {})}`
2138
2143
  );
2139
2144
  }
2140
2145
 
@@ -2813,6 +2818,7 @@ async function fetchRelayMetadataForRuntime(args) {
2813
2818
  attempts: args.attempts,
2814
2819
  delayMs: args.delayMs,
2815
2820
  timeoutMs: args.timeoutMs,
2821
+ isReady: (result) => extractRelayMetadata(result.payload) != null,
2816
2822
  onAttempt: (result) => {
2817
2823
  args.onAttempt?.({
2818
2824
  ...result,