@le-space/ui 0.1.52
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/README.md +22 -0
- package/package.json +37 -0
- package/react/index.d.ts +315 -0
- package/react/index.js +1856 -0
- package/shared/index.d.ts +339 -0
- package/shared/index.js +1695 -0
- package/styles.css +17 -0
- package/svelte/SponsorRelayFab.svelte +492 -0
- package/svelte/components/AccordionSection.svelte +37 -0
- package/svelte/components/CopyButton.svelte +31 -0
- package/svelte/components/LauncherButton.svelte +44 -0
- package/svelte/components/StatusLed.svelte +50 -0
- package/svelte/index.js +2 -0
- package/svelte/styles/theme.css +17 -0
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
type MessageStatus = 'processed' | 'pending' | 'rejected' | 'unknown';
|
|
2
|
+
interface BalanceResponse {
|
|
3
|
+
address: string;
|
|
4
|
+
balance: string;
|
|
5
|
+
locked_amount: string;
|
|
6
|
+
details?: Record<string, string>;
|
|
7
|
+
credit_balance: number;
|
|
8
|
+
}
|
|
9
|
+
interface Price {
|
|
10
|
+
payg?: string | number | null;
|
|
11
|
+
holding?: string | number | null;
|
|
12
|
+
fixed?: string | number | null;
|
|
13
|
+
credit?: string | number | null;
|
|
14
|
+
}
|
|
15
|
+
interface ComputeUnit {
|
|
16
|
+
vcpus: number;
|
|
17
|
+
memory_mib: number;
|
|
18
|
+
disk_mib: number;
|
|
19
|
+
}
|
|
20
|
+
interface Tier {
|
|
21
|
+
id: string;
|
|
22
|
+
compute_units: number;
|
|
23
|
+
vram?: number | null;
|
|
24
|
+
model?: string | null;
|
|
25
|
+
}
|
|
26
|
+
interface InstancePricing {
|
|
27
|
+
price: {
|
|
28
|
+
storage?: Price;
|
|
29
|
+
compute_unit?: Price;
|
|
30
|
+
};
|
|
31
|
+
compute_unit: ComputeUnit;
|
|
32
|
+
tiers: Tier[];
|
|
33
|
+
}
|
|
34
|
+
interface CrnUsage {
|
|
35
|
+
cpu?: {
|
|
36
|
+
count?: number;
|
|
37
|
+
};
|
|
38
|
+
mem?: {
|
|
39
|
+
available_kB?: number;
|
|
40
|
+
};
|
|
41
|
+
disk?: {
|
|
42
|
+
available_kB?: number;
|
|
43
|
+
};
|
|
44
|
+
active?: boolean;
|
|
45
|
+
}
|
|
46
|
+
interface CrnLocation {
|
|
47
|
+
city?: string | null;
|
|
48
|
+
region?: string | null;
|
|
49
|
+
country?: string | null;
|
|
50
|
+
country_code?: string | null;
|
|
51
|
+
}
|
|
52
|
+
interface Crn {
|
|
53
|
+
hash: string;
|
|
54
|
+
name: string;
|
|
55
|
+
address: string;
|
|
56
|
+
score?: number | string | null;
|
|
57
|
+
performance?: number | string | null;
|
|
58
|
+
decentralization?: number | string | null;
|
|
59
|
+
qemu_support?: boolean;
|
|
60
|
+
confidential_support?: boolean;
|
|
61
|
+
gpu_support?: boolean;
|
|
62
|
+
system_usage?: CrnUsage | null;
|
|
63
|
+
payment_receiver_address?: string | null;
|
|
64
|
+
version?: string | null;
|
|
65
|
+
city?: string | null;
|
|
66
|
+
region?: string | null;
|
|
67
|
+
country?: string | null;
|
|
68
|
+
country_code?: string | null;
|
|
69
|
+
location?: CrnLocation | string | null;
|
|
70
|
+
resolved_ip?: string | null;
|
|
71
|
+
geo_source?: string | null;
|
|
72
|
+
}
|
|
73
|
+
type PaymentMode = 'hold' | 'credit';
|
|
74
|
+
interface InstanceMessage {
|
|
75
|
+
item_hash: string;
|
|
76
|
+
sender: string;
|
|
77
|
+
chain: string;
|
|
78
|
+
type: 'INSTANCE';
|
|
79
|
+
channel?: string;
|
|
80
|
+
content?: {
|
|
81
|
+
metadata?: {
|
|
82
|
+
name?: string;
|
|
83
|
+
};
|
|
84
|
+
payment?: {
|
|
85
|
+
type?: PaymentMode;
|
|
86
|
+
chain?: string;
|
|
87
|
+
};
|
|
88
|
+
rootfs?: {
|
|
89
|
+
parent?: {
|
|
90
|
+
ref?: string;
|
|
91
|
+
};
|
|
92
|
+
size_mib?: number;
|
|
93
|
+
};
|
|
94
|
+
requirements?: {
|
|
95
|
+
node?: {
|
|
96
|
+
node_hash?: string;
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
time?: string | number;
|
|
101
|
+
reception_time?: string;
|
|
102
|
+
confirmed?: boolean;
|
|
103
|
+
status?: string;
|
|
104
|
+
}
|
|
105
|
+
interface InstancePortMapping {
|
|
106
|
+
host?: number;
|
|
107
|
+
tcp?: boolean;
|
|
108
|
+
udp?: boolean;
|
|
109
|
+
}
|
|
110
|
+
interface InstanceExecutionStatus {
|
|
111
|
+
defined_at?: string | null;
|
|
112
|
+
preparing_at?: string | null;
|
|
113
|
+
prepared_at?: string | null;
|
|
114
|
+
starting_at?: string | null;
|
|
115
|
+
started_at?: string | null;
|
|
116
|
+
stopping_at?: string | null;
|
|
117
|
+
stopped_at?: string | null;
|
|
118
|
+
}
|
|
119
|
+
interface InstanceExecutionNetworking {
|
|
120
|
+
ipv4?: string | null;
|
|
121
|
+
ipv6?: string | null;
|
|
122
|
+
ipv4_network?: string | null;
|
|
123
|
+
host_ipv4?: string | null;
|
|
124
|
+
ipv6_network?: string | null;
|
|
125
|
+
ipv6_ip?: string | null;
|
|
126
|
+
ipv4_ip?: string | null;
|
|
127
|
+
proxy_url?: string | null;
|
|
128
|
+
mapped_ports?: Record<string, InstancePortMapping>;
|
|
129
|
+
}
|
|
130
|
+
interface InstanceExecution {
|
|
131
|
+
crnUrl: string;
|
|
132
|
+
version: 'v1' | 'v2';
|
|
133
|
+
running?: boolean;
|
|
134
|
+
networking: InstanceExecutionNetworking;
|
|
135
|
+
status?: InstanceExecutionStatus | null;
|
|
136
|
+
}
|
|
137
|
+
interface RootfsRequiredPortForward {
|
|
138
|
+
port: number;
|
|
139
|
+
tcp?: boolean;
|
|
140
|
+
udp?: boolean;
|
|
141
|
+
purpose?: string;
|
|
142
|
+
}
|
|
143
|
+
interface RootfsManifest {
|
|
144
|
+
profile?: string;
|
|
145
|
+
version: string;
|
|
146
|
+
rootfsInstallStrategy?: 'thin' | 'prebaked' | string;
|
|
147
|
+
requiresBootstrapNetwork?: boolean;
|
|
148
|
+
bootstrapSummary?: string;
|
|
149
|
+
requiredPortForwards?: RootfsRequiredPortForward[];
|
|
150
|
+
rootfsItemHash: string;
|
|
151
|
+
rootfsSizeMiB: number;
|
|
152
|
+
rootfsSourceSizeBytes?: number;
|
|
153
|
+
createdAt: string;
|
|
154
|
+
notes?: string;
|
|
155
|
+
}
|
|
156
|
+
interface RootfsManifestState {
|
|
157
|
+
manifest: RootfsManifest | null;
|
|
158
|
+
valid: boolean;
|
|
159
|
+
errors: string[];
|
|
160
|
+
}
|
|
161
|
+
type GatewayProbeStatus = 'reachable' | 'timeout' | 'error' | 'unavailable' | 'unknown';
|
|
162
|
+
interface RootfsResolution {
|
|
163
|
+
itemHash: string;
|
|
164
|
+
messageStatus: MessageStatus;
|
|
165
|
+
messageType: string | null;
|
|
166
|
+
cid: string | null;
|
|
167
|
+
receptionTime?: string | null;
|
|
168
|
+
rejectionErrorCode?: number | null;
|
|
169
|
+
rejectionReason?: string | null;
|
|
170
|
+
gatewayUrl: string | null;
|
|
171
|
+
gatewayStatus: GatewayProbeStatus;
|
|
172
|
+
gatewayError?: string | null;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
type SponsorRelayHealthTone = 'ok' | 'caution' | 'error' | 'idle';
|
|
176
|
+
interface SponsorRelayProps {
|
|
177
|
+
libp2p?: unknown;
|
|
178
|
+
manifestUrl?: string;
|
|
179
|
+
manifestJson?: string;
|
|
180
|
+
sshPublicKey?: string;
|
|
181
|
+
instanceName?: string;
|
|
182
|
+
showInstances?: boolean;
|
|
183
|
+
openByDefault?: boolean;
|
|
184
|
+
launcherMode?: 'floating' | 'inline';
|
|
185
|
+
apiHost?: string;
|
|
186
|
+
crnListUrl?: string;
|
|
187
|
+
schedulerApiHost?: string;
|
|
188
|
+
twoN6ApiHost?: string;
|
|
189
|
+
}
|
|
190
|
+
interface SponsorRelayWalletState {
|
|
191
|
+
connected: boolean;
|
|
192
|
+
address: string | null;
|
|
193
|
+
chainId: string | null;
|
|
194
|
+
isMetaMask: boolean;
|
|
195
|
+
}
|
|
196
|
+
interface SponsorRelayPricingSummary {
|
|
197
|
+
pricing: InstancePricing | null;
|
|
198
|
+
tier: Tier | null;
|
|
199
|
+
requiredCredits: number | null;
|
|
200
|
+
availableCredits: number | null;
|
|
201
|
+
vcpus: number | null;
|
|
202
|
+
memoryMiB: number | null;
|
|
203
|
+
diskMiB: number | null;
|
|
204
|
+
}
|
|
205
|
+
interface SponsorRelayRootfsHealth {
|
|
206
|
+
tone: SponsorRelayHealthTone;
|
|
207
|
+
label: string;
|
|
208
|
+
detail: string | null;
|
|
209
|
+
}
|
|
210
|
+
interface RelayPingState {
|
|
211
|
+
tone: SponsorRelayHealthTone;
|
|
212
|
+
sent: boolean;
|
|
213
|
+
received: boolean;
|
|
214
|
+
lastPeerId: string | null;
|
|
215
|
+
lastLatencyMs: number | null;
|
|
216
|
+
lastSentAt: number | null;
|
|
217
|
+
lastReceivedAt: number | null;
|
|
218
|
+
error: string | null;
|
|
219
|
+
}
|
|
220
|
+
interface CompactInstanceDetails {
|
|
221
|
+
messageStatus: string;
|
|
222
|
+
allocationSource: string | null;
|
|
223
|
+
crnUrl: string | null;
|
|
224
|
+
hostIpv4: string | null;
|
|
225
|
+
ipv6: string | null;
|
|
226
|
+
vmIpv4: string | null;
|
|
227
|
+
webUrl: string | null;
|
|
228
|
+
sshCommand: string | null;
|
|
229
|
+
mappedPorts: Array<{
|
|
230
|
+
label: string;
|
|
231
|
+
hostPort: number | null;
|
|
232
|
+
}>;
|
|
233
|
+
execution: InstanceExecution | null;
|
|
234
|
+
error: string | null;
|
|
235
|
+
}
|
|
236
|
+
interface CompactInstanceRecord {
|
|
237
|
+
instance: InstanceMessage;
|
|
238
|
+
details: CompactInstanceDetails;
|
|
239
|
+
}
|
|
240
|
+
interface SponsorRelayState {
|
|
241
|
+
ready: boolean;
|
|
242
|
+
open: boolean;
|
|
243
|
+
wallet: SponsorRelayWalletState;
|
|
244
|
+
manifestUrl: string;
|
|
245
|
+
manifestJson: string;
|
|
246
|
+
sshPublicKey: string;
|
|
247
|
+
instanceName: string;
|
|
248
|
+
tierId: string;
|
|
249
|
+
showInstances: boolean;
|
|
250
|
+
showPasteManifest: boolean;
|
|
251
|
+
busy: {
|
|
252
|
+
connectingWallet: boolean;
|
|
253
|
+
refreshing: boolean;
|
|
254
|
+
deploying: boolean;
|
|
255
|
+
deletingInstanceHash: string | null;
|
|
256
|
+
};
|
|
257
|
+
statusText: string;
|
|
258
|
+
errorText: string | null;
|
|
259
|
+
manifestState: RootfsManifestState;
|
|
260
|
+
manifest: RootfsManifest | null;
|
|
261
|
+
rootfsResolution: RootfsResolution | null;
|
|
262
|
+
rootfsVerified: boolean;
|
|
263
|
+
rootfsHealth: SponsorRelayRootfsHealth;
|
|
264
|
+
pricingSummary: SponsorRelayPricingSummary;
|
|
265
|
+
balance: BalanceResponse | null;
|
|
266
|
+
crns: Crn[];
|
|
267
|
+
selectedCrn: Crn | null;
|
|
268
|
+
instances: CompactInstanceRecord[];
|
|
269
|
+
relayPing: RelayPingState;
|
|
270
|
+
lastDeploymentHash: string | null;
|
|
271
|
+
}
|
|
272
|
+
type SponsorRelaySubscriber = (state: SponsorRelayState) => void;
|
|
273
|
+
|
|
274
|
+
declare const DEFAULT_INSTANCE_NAME = "sponsor-relay";
|
|
275
|
+
declare const DEFAULT_MANIFEST_URL = "./rootfs-manifest.json";
|
|
276
|
+
declare const DEFAULT_TIER_ID = "tier-1";
|
|
277
|
+
declare const ROOTFS_MISSING_STATE: SponsorRelayRootfsHealth;
|
|
278
|
+
declare const RELAY_PING_IDLE_STATE: RelayPingState;
|
|
279
|
+
declare const REFRESH_INTERVAL_MS = 30000;
|
|
280
|
+
declare const RELAY_PING_INTERVAL_MS = 20000;
|
|
281
|
+
|
|
282
|
+
declare function shortHash(value: string | null | undefined, head?: number, tail?: number): string;
|
|
283
|
+
declare function formatNumber(value: number | null | undefined, digits?: number): string;
|
|
284
|
+
declare function formatDateTime(value: string | number | null | undefined): string;
|
|
285
|
+
declare function buildSshCommand(hostIpv4: string | null, mappedPorts: CompactInstanceRecord['details']['mappedPorts']): string | null;
|
|
286
|
+
declare function joinMappedPorts(mappedPorts: CompactInstanceRecord['details']['mappedPorts']): string;
|
|
287
|
+
|
|
288
|
+
declare function resolveManifestSource(args: {
|
|
289
|
+
manifestJson: string;
|
|
290
|
+
}): RootfsManifestState | null;
|
|
291
|
+
|
|
292
|
+
interface EthereumProviderLike {
|
|
293
|
+
isMetaMask?: boolean;
|
|
294
|
+
request<T = unknown>(args: {
|
|
295
|
+
method: string;
|
|
296
|
+
params?: unknown[] | Record<string, unknown>;
|
|
297
|
+
}): Promise<T>;
|
|
298
|
+
on?(event: string, listener: (...args: unknown[]) => void): void;
|
|
299
|
+
removeListener?(event: string, listener: (...args: unknown[]) => void): void;
|
|
300
|
+
}
|
|
301
|
+
declare function getEthereumProvider(): EthereumProviderLike | null;
|
|
302
|
+
declare function connectWallet(provider?: EthereumProviderLike | null): Promise<SponsorRelayWalletState>;
|
|
303
|
+
declare function personalSign(address: string, message: string, provider?: EthereumProviderLike | null): Promise<string>;
|
|
304
|
+
declare function watchWallet(onChange: () => void, provider?: EthereumProviderLike | null): () => void;
|
|
305
|
+
|
|
306
|
+
declare class SponsorRelayController {
|
|
307
|
+
private state;
|
|
308
|
+
private subscribers;
|
|
309
|
+
private client;
|
|
310
|
+
private refreshTimer;
|
|
311
|
+
private pingTimer;
|
|
312
|
+
private stopWalletWatch;
|
|
313
|
+
private props;
|
|
314
|
+
constructor(props?: SponsorRelayProps);
|
|
315
|
+
subscribe(subscriber: SponsorRelaySubscriber): () => void;
|
|
316
|
+
getState(): SponsorRelayState;
|
|
317
|
+
private emit;
|
|
318
|
+
private patch;
|
|
319
|
+
init(): Promise<void>;
|
|
320
|
+
destroy(): void;
|
|
321
|
+
setOpen(open: boolean): void;
|
|
322
|
+
toggleOpen(): void;
|
|
323
|
+
setManifestUrl(manifestUrl: string): void;
|
|
324
|
+
setManifestJson(manifestJson: string): void;
|
|
325
|
+
setShowPasteManifest(showPasteManifest: boolean): void;
|
|
326
|
+
setSshPublicKey(sshPublicKey: string): void;
|
|
327
|
+
setInstanceName(instanceName: string): void;
|
|
328
|
+
setTierId(tierId: string): void;
|
|
329
|
+
private recomputePricingSummary;
|
|
330
|
+
connectWallet(): Promise<void>;
|
|
331
|
+
private refreshWalletDerivedState;
|
|
332
|
+
refresh(): Promise<void>;
|
|
333
|
+
refreshRelayPing(): Promise<void>;
|
|
334
|
+
deploy(): Promise<void>;
|
|
335
|
+
deleteInstance(instanceHash: string): Promise<void>;
|
|
336
|
+
}
|
|
337
|
+
declare function createSponsorRelayController(props?: SponsorRelayProps): SponsorRelayController;
|
|
338
|
+
|
|
339
|
+
export { type CompactInstanceDetails, type CompactInstanceRecord, DEFAULT_INSTANCE_NAME, DEFAULT_MANIFEST_URL, DEFAULT_TIER_ID, type EthereumProviderLike, REFRESH_INTERVAL_MS, RELAY_PING_IDLE_STATE, RELAY_PING_INTERVAL_MS, ROOTFS_MISSING_STATE, type RelayPingState, SponsorRelayController, type SponsorRelayHealthTone, type SponsorRelayPricingSummary, type SponsorRelayProps, type SponsorRelayRootfsHealth, type SponsorRelayState, type SponsorRelaySubscriber, type SponsorRelayWalletState, buildSshCommand, connectWallet, createSponsorRelayController, formatDateTime, formatNumber, getEthereumProvider, joinMappedPorts, personalSign, resolveManifestSource, shortHash, watchWallet };
|