@le-space/ui 0.3.12 → 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.12",
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.12",
40
- "@le-space/core": "0.3.12",
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.12";
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,14 +2078,15 @@ 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(
2084
2085
  () => controller.abort(),
2085
2086
  Number(args.timeoutMs ?? 18e4)
2086
2087
  );
2088
+ const requestUrl = args.metadataUrl && args.metadataUrl.trim() ? args.metadataUrl : `http://${args.hostIpv4}:${args.setupPort}/metadata`;
2087
2089
  try {
2088
- const requestUrl = args.metadataUrl && args.metadataUrl.trim() ? args.metadataUrl : `http://${args.hostIpv4}:${args.setupPort}/metadata`;
2089
2090
  const response = await args.fetch(
2090
2091
  requestUrl,
2091
2092
  {
@@ -2094,22 +2095,43 @@ async function fetchUcGoPeerMetadata(args) {
2094
2095
  );
2095
2096
  const payload = await response.json().catch(() => null);
2096
2097
  lastPayload = payload;
2097
- args.onAttempt?.(
2098
- payload,
2099
- Boolean(
2100
- response.ok && payload && typeof payload === "object" && payload.status === "ready"
2101
- ),
2102
- attempt + 1,
2103
- attempts
2098
+ lastError = null;
2099
+ const ready = Boolean(
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"
2104
2106
  );
2105
- if (response.ok && payload && typeof payload === "object" && payload.status === "ready") {
2107
+ args.onAttempt?.({
2108
+ payload,
2109
+ ready,
2110
+ attempt: attempt + 1,
2111
+ attempts,
2112
+ requestUrl,
2113
+ ok: response.ok,
2114
+ status: response.status,
2115
+ error: null
2116
+ });
2117
+ if (ready) {
2106
2118
  return payload;
2107
2119
  }
2108
- if (response.status >= 500) {
2109
- throw new Error(
2110
- `Relay metadata request failed: ${response.status} ${typeof payload === "string" ? payload : JSON.stringify(payload ?? {})}`
2111
- );
2112
- }
2120
+ } catch (error) {
2121
+ lastError = error instanceof Error ? error.message : String(error);
2122
+ lastPayload = {
2123
+ error: lastError
2124
+ };
2125
+ args.onAttempt?.({
2126
+ payload: null,
2127
+ ready: false,
2128
+ attempt: attempt + 1,
2129
+ attempts,
2130
+ requestUrl,
2131
+ ok: false,
2132
+ status: null,
2133
+ error: lastError
2134
+ });
2113
2135
  } finally {
2114
2136
  clearTimeout(timeout);
2115
2137
  }
@@ -2118,7 +2140,7 @@ async function fetchUcGoPeerMetadata(args) {
2118
2140
  }
2119
2141
  }
2120
2142
  throw new Error(
2121
- `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 ?? {})}`
2122
2144
  );
2123
2145
  }
2124
2146
 
@@ -2796,7 +2818,16 @@ async function fetchRelayMetadataForRuntime(args) {
2796
2818
  fetch: args.fetch,
2797
2819
  attempts: args.attempts,
2798
2820
  delayMs: args.delayMs,
2799
- timeoutMs: args.timeoutMs
2821
+ timeoutMs: args.timeoutMs,
2822
+ isReady: (result) => extractRelayMetadata(result.payload) != null,
2823
+ onAttempt: (result) => {
2824
+ args.onAttempt?.({
2825
+ ...result,
2826
+ metadataUrl,
2827
+ hostIpv4: args.runtime.hostIpv4 ?? null,
2828
+ setupPort
2829
+ });
2830
+ }
2800
2831
  }).catch(() => null);
2801
2832
  return extractRelayMetadata(payload);
2802
2833
  }
@@ -3475,7 +3506,7 @@ var SponsorRelayController = class {
3475
3506
  )
3476
3507
  }
3477
3508
  };
3478
- await publishVmBootstrapConfig({
3509
+ const bootstrapConfigPublication = await publishVmBootstrapConfig({
3479
3510
  sender: this.state.wallet.address,
3480
3511
  record,
3481
3512
  signer: personalSign,
@@ -3484,6 +3515,15 @@ var SponsorRelayController = class {
3484
3515
  apiHost: this.client.apiHost,
3485
3516
  sync: true
3486
3517
  });
3518
+ this.trace("deploy:bootstrap-config-published", {
3519
+ itemHash: args.itemHash,
3520
+ deploymentToken: args.deploymentToken,
3521
+ registrationId: record.bootstrap?.registrationId ?? null,
3522
+ proxyUrl: record.runtime.proxyUrl ?? null,
3523
+ mappedPorts: record.runtime.mappedPorts,
3524
+ aggregateItemHash: bootstrapConfigPublication.aggregateItemHash,
3525
+ aggregateStatus: bootstrapConfigPublication.aggregateStatus
3526
+ });
3487
3527
  }
3488
3528
  this.emitProgress({
3489
3529
  stage: "publishing-bootstrap",
@@ -3499,7 +3539,30 @@ var SponsorRelayController = class {
3499
3539
  preferSecureMetadata: profile === "uc-go-peer",
3500
3540
  attempts: 80,
3501
3541
  delayMs: 3e3,
3502
- timeoutMs: 24e4
3542
+ timeoutMs: 24e4,
3543
+ onAttempt: (result) => {
3544
+ const payload = result.payload && typeof result.payload === "object" ? result.payload : null;
3545
+ const metadata = payload?.metadata && typeof payload.metadata === "object" ? payload.metadata : null;
3546
+ this.trace("deploy:relay-metadata-attempt", {
3547
+ itemHash: args.itemHash,
3548
+ attempt: result.attempt,
3549
+ attempts: result.attempts,
3550
+ requestUrl: result.requestUrl,
3551
+ metadataUrl: result.metadataUrl,
3552
+ hostIpv4: result.hostIpv4,
3553
+ setupPort: result.setupPort,
3554
+ ok: result.ok,
3555
+ status: result.status,
3556
+ ready: result.ready,
3557
+ error: result.error ?? null,
3558
+ payloadStatus: payload && typeof payload.status === "string" ? payload.status : null,
3559
+ peerId: metadata && typeof metadata.peer_id === "string" ? metadata.peer_id : null,
3560
+ probeMultiaddrCount: Array.isArray(metadata?.probe_multiaddrs) ? metadata.probe_multiaddrs.length : 0,
3561
+ browserBootstrapMultiaddrCount: Array.isArray(
3562
+ metadata?.browser_bootstrap_multiaddrs
3563
+ ) ? metadata.browser_bootstrap_multiaddrs.length : 0
3564
+ });
3565
+ }
3503
3566
  });
3504
3567
  if (!relayMetadata) {
3505
3568
  throw new Error("Relay metadata did not include a peer ID and public multiaddrs.");
@@ -4278,6 +4341,10 @@ var SponsorRelayController = class {
4278
4341
  });
4279
4342
  if (attemptItemHash) {
4280
4343
  if (attemptDeploymentToken) {
4344
+ this.trace("deploy:bootstrap-config-cleanup-start", {
4345
+ itemHash: attemptItemHash,
4346
+ deploymentToken: attemptDeploymentToken
4347
+ });
4281
4348
  await deleteVmBootstrapConfig({
4282
4349
  sender: this.state.wallet.address,
4283
4350
  deploymentToken: attemptDeploymentToken,
@@ -4286,8 +4353,26 @@ var SponsorRelayController = class {
4286
4353
  fetch: asJsonFetch,
4287
4354
  apiHost: this.client.apiHost,
4288
4355
  sync: true
4289
- }).catch(() => void 0);
4356
+ }).then((cleanupResult) => {
4357
+ this.trace("deploy:bootstrap-config-cleanup-complete", {
4358
+ itemHash: attemptItemHash,
4359
+ deploymentToken: attemptDeploymentToken,
4360
+ aggregateItemHash: cleanupResult.aggregateItemHash,
4361
+ aggregateStatus: cleanupResult.aggregateStatus
4362
+ });
4363
+ }).catch((cleanupError) => {
4364
+ this.trace("deploy:bootstrap-config-cleanup-error", {
4365
+ itemHash: attemptItemHash,
4366
+ deploymentToken: attemptDeploymentToken,
4367
+ error: cleanupError instanceof Error ? cleanupError.message : String(cleanupError)
4368
+ });
4369
+ });
4290
4370
  }
4371
+ this.trace("deploy:forget-failed-attempt-start", {
4372
+ itemHash: attemptItemHash,
4373
+ crnHash: candidateCrn.hash,
4374
+ crnName: candidateCrn.name
4375
+ });
4291
4376
  await forgetAlephMessages({
4292
4377
  sender: this.state.wallet.address,
4293
4378
  hashes: [attemptItemHash],
@@ -4306,6 +4391,11 @@ var SponsorRelayController = class {
4306
4391
  error: cleanupError instanceof Error ? cleanupError.message : String(cleanupError)
4307
4392
  });
4308
4393
  });
4394
+ this.trace("deploy:forget-failed-attempt-complete", {
4395
+ itemHash: attemptItemHash,
4396
+ crnHash: candidateCrn.hash,
4397
+ crnName: candidateCrn.name
4398
+ });
4309
4399
  }
4310
4400
  if (candidateIndex < orderedCrns.length - 1) {
4311
4401
  this.emitProgress({
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.12";
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.12";
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,14 +2077,15 @@ 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(
2083
2084
  () => controller.abort(),
2084
2085
  Number(args.timeoutMs ?? 18e4)
2085
2086
  );
2087
+ const requestUrl = args.metadataUrl && args.metadataUrl.trim() ? args.metadataUrl : `http://${args.hostIpv4}:${args.setupPort}/metadata`;
2086
2088
  try {
2087
- const requestUrl = args.metadataUrl && args.metadataUrl.trim() ? args.metadataUrl : `http://${args.hostIpv4}:${args.setupPort}/metadata`;
2088
2089
  const response = await args.fetch(
2089
2090
  requestUrl,
2090
2091
  {
@@ -2093,22 +2094,43 @@ async function fetchUcGoPeerMetadata(args) {
2093
2094
  );
2094
2095
  const payload = await response.json().catch(() => null);
2095
2096
  lastPayload = payload;
2096
- args.onAttempt?.(
2097
- payload,
2098
- Boolean(
2099
- response.ok && payload && typeof payload === "object" && payload.status === "ready"
2100
- ),
2101
- attempt + 1,
2102
- attempts
2097
+ lastError = null;
2098
+ const ready = Boolean(
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"
2103
2105
  );
2104
- if (response.ok && payload && typeof payload === "object" && payload.status === "ready") {
2106
+ args.onAttempt?.({
2107
+ payload,
2108
+ ready,
2109
+ attempt: attempt + 1,
2110
+ attempts,
2111
+ requestUrl,
2112
+ ok: response.ok,
2113
+ status: response.status,
2114
+ error: null
2115
+ });
2116
+ if (ready) {
2105
2117
  return payload;
2106
2118
  }
2107
- if (response.status >= 500) {
2108
- throw new Error(
2109
- `Relay metadata request failed: ${response.status} ${typeof payload === "string" ? payload : JSON.stringify(payload ?? {})}`
2110
- );
2111
- }
2119
+ } catch (error) {
2120
+ lastError = error instanceof Error ? error.message : String(error);
2121
+ lastPayload = {
2122
+ error: lastError
2123
+ };
2124
+ args.onAttempt?.({
2125
+ payload: null,
2126
+ ready: false,
2127
+ attempt: attempt + 1,
2128
+ attempts,
2129
+ requestUrl,
2130
+ ok: false,
2131
+ status: null,
2132
+ error: lastError
2133
+ });
2112
2134
  } finally {
2113
2135
  clearTimeout(timeout);
2114
2136
  }
@@ -2117,7 +2139,7 @@ async function fetchUcGoPeerMetadata(args) {
2117
2139
  }
2118
2140
  }
2119
2141
  throw new Error(
2120
- `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 ?? {})}`
2121
2143
  );
2122
2144
  }
2123
2145
 
@@ -2795,7 +2817,16 @@ async function fetchRelayMetadataForRuntime(args) {
2795
2817
  fetch: args.fetch,
2796
2818
  attempts: args.attempts,
2797
2819
  delayMs: args.delayMs,
2798
- timeoutMs: args.timeoutMs
2820
+ timeoutMs: args.timeoutMs,
2821
+ isReady: (result) => extractRelayMetadata(result.payload) != null,
2822
+ onAttempt: (result) => {
2823
+ args.onAttempt?.({
2824
+ ...result,
2825
+ metadataUrl,
2826
+ hostIpv4: args.runtime.hostIpv4 ?? null,
2827
+ setupPort
2828
+ });
2829
+ }
2799
2830
  }).catch(() => null);
2800
2831
  return extractRelayMetadata(payload);
2801
2832
  }
@@ -3474,7 +3505,7 @@ var SponsorRelayController = class {
3474
3505
  )
3475
3506
  }
3476
3507
  };
3477
- await publishVmBootstrapConfig({
3508
+ const bootstrapConfigPublication = await publishVmBootstrapConfig({
3478
3509
  sender: this.state.wallet.address,
3479
3510
  record,
3480
3511
  signer: personalSign,
@@ -3483,6 +3514,15 @@ var SponsorRelayController = class {
3483
3514
  apiHost: this.client.apiHost,
3484
3515
  sync: true
3485
3516
  });
3517
+ this.trace("deploy:bootstrap-config-published", {
3518
+ itemHash: args.itemHash,
3519
+ deploymentToken: args.deploymentToken,
3520
+ registrationId: record.bootstrap?.registrationId ?? null,
3521
+ proxyUrl: record.runtime.proxyUrl ?? null,
3522
+ mappedPorts: record.runtime.mappedPorts,
3523
+ aggregateItemHash: bootstrapConfigPublication.aggregateItemHash,
3524
+ aggregateStatus: bootstrapConfigPublication.aggregateStatus
3525
+ });
3486
3526
  }
3487
3527
  this.emitProgress({
3488
3528
  stage: "publishing-bootstrap",
@@ -3498,7 +3538,30 @@ var SponsorRelayController = class {
3498
3538
  preferSecureMetadata: profile === "uc-go-peer",
3499
3539
  attempts: 80,
3500
3540
  delayMs: 3e3,
3501
- timeoutMs: 24e4
3541
+ timeoutMs: 24e4,
3542
+ onAttempt: (result) => {
3543
+ const payload = result.payload && typeof result.payload === "object" ? result.payload : null;
3544
+ const metadata = payload?.metadata && typeof payload.metadata === "object" ? payload.metadata : null;
3545
+ this.trace("deploy:relay-metadata-attempt", {
3546
+ itemHash: args.itemHash,
3547
+ attempt: result.attempt,
3548
+ attempts: result.attempts,
3549
+ requestUrl: result.requestUrl,
3550
+ metadataUrl: result.metadataUrl,
3551
+ hostIpv4: result.hostIpv4,
3552
+ setupPort: result.setupPort,
3553
+ ok: result.ok,
3554
+ status: result.status,
3555
+ ready: result.ready,
3556
+ error: result.error ?? null,
3557
+ payloadStatus: payload && typeof payload.status === "string" ? payload.status : null,
3558
+ peerId: metadata && typeof metadata.peer_id === "string" ? metadata.peer_id : null,
3559
+ probeMultiaddrCount: Array.isArray(metadata?.probe_multiaddrs) ? metadata.probe_multiaddrs.length : 0,
3560
+ browserBootstrapMultiaddrCount: Array.isArray(
3561
+ metadata?.browser_bootstrap_multiaddrs
3562
+ ) ? metadata.browser_bootstrap_multiaddrs.length : 0
3563
+ });
3564
+ }
3502
3565
  });
3503
3566
  if (!relayMetadata) {
3504
3567
  throw new Error("Relay metadata did not include a peer ID and public multiaddrs.");
@@ -4277,6 +4340,10 @@ var SponsorRelayController = class {
4277
4340
  });
4278
4341
  if (attemptItemHash) {
4279
4342
  if (attemptDeploymentToken) {
4343
+ this.trace("deploy:bootstrap-config-cleanup-start", {
4344
+ itemHash: attemptItemHash,
4345
+ deploymentToken: attemptDeploymentToken
4346
+ });
4280
4347
  await deleteVmBootstrapConfig({
4281
4348
  sender: this.state.wallet.address,
4282
4349
  deploymentToken: attemptDeploymentToken,
@@ -4285,8 +4352,26 @@ var SponsorRelayController = class {
4285
4352
  fetch: asJsonFetch,
4286
4353
  apiHost: this.client.apiHost,
4287
4354
  sync: true
4288
- }).catch(() => void 0);
4355
+ }).then((cleanupResult) => {
4356
+ this.trace("deploy:bootstrap-config-cleanup-complete", {
4357
+ itemHash: attemptItemHash,
4358
+ deploymentToken: attemptDeploymentToken,
4359
+ aggregateItemHash: cleanupResult.aggregateItemHash,
4360
+ aggregateStatus: cleanupResult.aggregateStatus
4361
+ });
4362
+ }).catch((cleanupError) => {
4363
+ this.trace("deploy:bootstrap-config-cleanup-error", {
4364
+ itemHash: attemptItemHash,
4365
+ deploymentToken: attemptDeploymentToken,
4366
+ error: cleanupError instanceof Error ? cleanupError.message : String(cleanupError)
4367
+ });
4368
+ });
4289
4369
  }
4370
+ this.trace("deploy:forget-failed-attempt-start", {
4371
+ itemHash: attemptItemHash,
4372
+ crnHash: candidateCrn.hash,
4373
+ crnName: candidateCrn.name
4374
+ });
4290
4375
  await forgetAlephMessages({
4291
4376
  sender: this.state.wallet.address,
4292
4377
  hashes: [attemptItemHash],
@@ -4305,6 +4390,11 @@ var SponsorRelayController = class {
4305
4390
  error: cleanupError instanceof Error ? cleanupError.message : String(cleanupError)
4306
4391
  });
4307
4392
  });
4393
+ this.trace("deploy:forget-failed-attempt-complete", {
4394
+ itemHash: attemptItemHash,
4395
+ crnHash: candidateCrn.hash,
4396
+ crnName: candidateCrn.name
4397
+ });
4308
4398
  }
4309
4399
  if (candidateIndex < orderedCrns.length - 1) {
4310
4400
  this.emitProgress({