@partylayer/sdk 0.10.2 → 0.11.0
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/dist/index.d.mts +35 -2
- package/dist/index.d.ts +35 -2
- package/dist/index.js +32 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +32 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.d.mts
CHANGED
|
@@ -299,10 +299,25 @@ interface ErrorEvent {
|
|
|
299
299
|
type: 'error';
|
|
300
300
|
error: Error;
|
|
301
301
|
}
|
|
302
|
+
/**
|
|
303
|
+
* Wallet-list changed event — the set of listable wallets changed since the last
|
|
304
|
+
* `listWallets()` (e.g. a wallet announced late via `canton:announceProvider`,
|
|
305
|
+
* after the picker already loaded). SIGNAL-ONLY: it carries no wallet payload
|
|
306
|
+
* because `listWallets()` does registry-merge + discovery-gating + identity-
|
|
307
|
+
* bridging + filtering that a raw announce doesn't reflect — the authoritative
|
|
308
|
+
* read is to re-call `listWallets()` (mirrors EIP-6963/mipd: store emits, UI
|
|
309
|
+
* re-reads). Emitted debounced (coalesces a burst into one). Never emitted when
|
|
310
|
+
* nothing announces (byte-identical idle).
|
|
311
|
+
*/
|
|
312
|
+
interface WalletsChangedEvent {
|
|
313
|
+
type: 'wallets:changed';
|
|
314
|
+
/** Why the list changed. Currently only late/inject-time announce discovery. */
|
|
315
|
+
reason: 'announced';
|
|
316
|
+
}
|
|
302
317
|
/**
|
|
303
318
|
* All event types
|
|
304
319
|
*/
|
|
305
|
-
type PartyLayerEvent = RegistryUpdatedEvent | RegistryStatusEvent | SessionConnectedEvent | SessionDisconnectedEvent | SessionExpiredEvent | SessionNetworkMismatchEvent | TxStatusEvent | ErrorEvent;
|
|
320
|
+
type PartyLayerEvent = RegistryUpdatedEvent | RegistryStatusEvent | SessionConnectedEvent | SessionDisconnectedEvent | SessionExpiredEvent | SessionNetworkMismatchEvent | TxStatusEvent | WalletsChangedEvent | ErrorEvent;
|
|
306
321
|
/**
|
|
307
322
|
* Event handler type
|
|
308
323
|
*/
|
|
@@ -334,6 +349,8 @@ declare class PartyLayerClient {
|
|
|
334
349
|
private announceEntriesCache;
|
|
335
350
|
private readonly announceRegistry;
|
|
336
351
|
private announceUnsubscribe;
|
|
352
|
+
/** Pending debounced `wallets:changed` emit (coalesces an announce burst). */
|
|
353
|
+
private walletsChangedTimer;
|
|
337
354
|
private origin;
|
|
338
355
|
constructor(config: PartyLayerConfig);
|
|
339
356
|
/**
|
|
@@ -390,6 +407,22 @@ declare class PartyLayerClient {
|
|
|
390
407
|
* `canton:requestProvider` handshake (e.g. after a wallet is installed).
|
|
391
408
|
*/
|
|
392
409
|
refreshDiscovery(): void;
|
|
410
|
+
/**
|
|
411
|
+
* Persistent-accumulator callback (mounted at construction). On each newly
|
|
412
|
+
* announced provider:
|
|
413
|
+
* 1. record it in the live `announceRegistry` (unchanged);
|
|
414
|
+
* 2. invalidate the one-shot `announceEntriesCache` — the SAME invalidation
|
|
415
|
+
* as {@link refreshDiscovery}, so the next `listWallets()` re-aggregates
|
|
416
|
+
* and surfaces the wallet. This does NOT touch `warmPlans` (those hold
|
|
417
|
+
* only GenericDiscoveryAdapter popup plans — a disjoint set);
|
|
418
|
+
* 3. emit a DEBOUNCED `wallets:changed` signal so a reactive consumer (e.g.
|
|
419
|
+
* the React provider) re-lists. The debounce coalesces a burst — and the
|
|
420
|
+
* construction-time reply storm — into one emit (no re-discovery storm).
|
|
421
|
+
*
|
|
422
|
+
* Byte-identical idle: with zero announces this never fires — no invalidation,
|
|
423
|
+
* no emit, no re-list.
|
|
424
|
+
*/
|
|
425
|
+
private onAnnounceAccumulated;
|
|
393
426
|
/**
|
|
394
427
|
* Aggregate `canton:announceProvider` wallets into the picker list (A2).
|
|
395
428
|
*
|
|
@@ -850,4 +883,4 @@ declare function isTelemetryConfig(value: unknown): value is TelemetryConfig;
|
|
|
850
883
|
*/
|
|
851
884
|
declare function createTelemetryAdapter(config: TelemetryAdapter | TelemetryConfig | undefined): TelemetryAdapter | undefined;
|
|
852
885
|
|
|
853
|
-
export { ANNOUNCED_WALLET_ID_PREFIX, type AdapterClass, PartyLayerClient as CantonConnectClient, type PartyLayerConfig as CantonConnectConfig, type PartyLayerEvent as CantonConnectEvent, type ConnectOptions, DEFAULT_REGISTRY_URL, type ErrorEvent, type EventHandler, GenericAnnounceAdapter, type GenericAnnounceAdapterArgs, GenericDiscoveryAdapter, type GenericDiscoveryAdapterArgs, MetricsTelemetryAdapter, PartyLayerClient, type PartyLayerConfig, type PartyLayerEvent, type RegistryUpdatedEvent, type SessionConnectedEvent, type SessionDisconnectedEvent, type SessionExpiredEvent, type TelemetryConfig, type TxStatusEvent, type WalletFilter, PartyLayerClient as _PartyLayerClientInternal, announcedWalletId, createPartyLayer as createCantonConnect, createPartyLayer, createTelemetryAdapter, getBuiltinAdapters, isTelemetryConfig };
|
|
886
|
+
export { ANNOUNCED_WALLET_ID_PREFIX, type AdapterClass, PartyLayerClient as CantonConnectClient, type PartyLayerConfig as CantonConnectConfig, type PartyLayerEvent as CantonConnectEvent, type ConnectOptions, DEFAULT_REGISTRY_URL, type ErrorEvent, type EventHandler, GenericAnnounceAdapter, type GenericAnnounceAdapterArgs, GenericDiscoveryAdapter, type GenericDiscoveryAdapterArgs, MetricsTelemetryAdapter, PartyLayerClient, type PartyLayerConfig, type PartyLayerEvent, type RegistryUpdatedEvent, type SessionConnectedEvent, type SessionDisconnectedEvent, type SessionExpiredEvent, type TelemetryConfig, type TxStatusEvent, type WalletFilter, type WalletsChangedEvent, PartyLayerClient as _PartyLayerClientInternal, announcedWalletId, createPartyLayer as createCantonConnect, createPartyLayer, createTelemetryAdapter, getBuiltinAdapters, isTelemetryConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -299,10 +299,25 @@ interface ErrorEvent {
|
|
|
299
299
|
type: 'error';
|
|
300
300
|
error: Error;
|
|
301
301
|
}
|
|
302
|
+
/**
|
|
303
|
+
* Wallet-list changed event — the set of listable wallets changed since the last
|
|
304
|
+
* `listWallets()` (e.g. a wallet announced late via `canton:announceProvider`,
|
|
305
|
+
* after the picker already loaded). SIGNAL-ONLY: it carries no wallet payload
|
|
306
|
+
* because `listWallets()` does registry-merge + discovery-gating + identity-
|
|
307
|
+
* bridging + filtering that a raw announce doesn't reflect — the authoritative
|
|
308
|
+
* read is to re-call `listWallets()` (mirrors EIP-6963/mipd: store emits, UI
|
|
309
|
+
* re-reads). Emitted debounced (coalesces a burst into one). Never emitted when
|
|
310
|
+
* nothing announces (byte-identical idle).
|
|
311
|
+
*/
|
|
312
|
+
interface WalletsChangedEvent {
|
|
313
|
+
type: 'wallets:changed';
|
|
314
|
+
/** Why the list changed. Currently only late/inject-time announce discovery. */
|
|
315
|
+
reason: 'announced';
|
|
316
|
+
}
|
|
302
317
|
/**
|
|
303
318
|
* All event types
|
|
304
319
|
*/
|
|
305
|
-
type PartyLayerEvent = RegistryUpdatedEvent | RegistryStatusEvent | SessionConnectedEvent | SessionDisconnectedEvent | SessionExpiredEvent | SessionNetworkMismatchEvent | TxStatusEvent | ErrorEvent;
|
|
320
|
+
type PartyLayerEvent = RegistryUpdatedEvent | RegistryStatusEvent | SessionConnectedEvent | SessionDisconnectedEvent | SessionExpiredEvent | SessionNetworkMismatchEvent | TxStatusEvent | WalletsChangedEvent | ErrorEvent;
|
|
306
321
|
/**
|
|
307
322
|
* Event handler type
|
|
308
323
|
*/
|
|
@@ -334,6 +349,8 @@ declare class PartyLayerClient {
|
|
|
334
349
|
private announceEntriesCache;
|
|
335
350
|
private readonly announceRegistry;
|
|
336
351
|
private announceUnsubscribe;
|
|
352
|
+
/** Pending debounced `wallets:changed` emit (coalesces an announce burst). */
|
|
353
|
+
private walletsChangedTimer;
|
|
337
354
|
private origin;
|
|
338
355
|
constructor(config: PartyLayerConfig);
|
|
339
356
|
/**
|
|
@@ -390,6 +407,22 @@ declare class PartyLayerClient {
|
|
|
390
407
|
* `canton:requestProvider` handshake (e.g. after a wallet is installed).
|
|
391
408
|
*/
|
|
392
409
|
refreshDiscovery(): void;
|
|
410
|
+
/**
|
|
411
|
+
* Persistent-accumulator callback (mounted at construction). On each newly
|
|
412
|
+
* announced provider:
|
|
413
|
+
* 1. record it in the live `announceRegistry` (unchanged);
|
|
414
|
+
* 2. invalidate the one-shot `announceEntriesCache` — the SAME invalidation
|
|
415
|
+
* as {@link refreshDiscovery}, so the next `listWallets()` re-aggregates
|
|
416
|
+
* and surfaces the wallet. This does NOT touch `warmPlans` (those hold
|
|
417
|
+
* only GenericDiscoveryAdapter popup plans — a disjoint set);
|
|
418
|
+
* 3. emit a DEBOUNCED `wallets:changed` signal so a reactive consumer (e.g.
|
|
419
|
+
* the React provider) re-lists. The debounce coalesces a burst — and the
|
|
420
|
+
* construction-time reply storm — into one emit (no re-discovery storm).
|
|
421
|
+
*
|
|
422
|
+
* Byte-identical idle: with zero announces this never fires — no invalidation,
|
|
423
|
+
* no emit, no re-list.
|
|
424
|
+
*/
|
|
425
|
+
private onAnnounceAccumulated;
|
|
393
426
|
/**
|
|
394
427
|
* Aggregate `canton:announceProvider` wallets into the picker list (A2).
|
|
395
428
|
*
|
|
@@ -850,4 +883,4 @@ declare function isTelemetryConfig(value: unknown): value is TelemetryConfig;
|
|
|
850
883
|
*/
|
|
851
884
|
declare function createTelemetryAdapter(config: TelemetryAdapter | TelemetryConfig | undefined): TelemetryAdapter | undefined;
|
|
852
885
|
|
|
853
|
-
export { ANNOUNCED_WALLET_ID_PREFIX, type AdapterClass, PartyLayerClient as CantonConnectClient, type PartyLayerConfig as CantonConnectConfig, type PartyLayerEvent as CantonConnectEvent, type ConnectOptions, DEFAULT_REGISTRY_URL, type ErrorEvent, type EventHandler, GenericAnnounceAdapter, type GenericAnnounceAdapterArgs, GenericDiscoveryAdapter, type GenericDiscoveryAdapterArgs, MetricsTelemetryAdapter, PartyLayerClient, type PartyLayerConfig, type PartyLayerEvent, type RegistryUpdatedEvent, type SessionConnectedEvent, type SessionDisconnectedEvent, type SessionExpiredEvent, type TelemetryConfig, type TxStatusEvent, type WalletFilter, PartyLayerClient as _PartyLayerClientInternal, announcedWalletId, createPartyLayer as createCantonConnect, createPartyLayer, createTelemetryAdapter, getBuiltinAdapters, isTelemetryConfig };
|
|
886
|
+
export { ANNOUNCED_WALLET_ID_PREFIX, type AdapterClass, PartyLayerClient as CantonConnectClient, type PartyLayerConfig as CantonConnectConfig, type PartyLayerEvent as CantonConnectEvent, type ConnectOptions, DEFAULT_REGISTRY_URL, type ErrorEvent, type EventHandler, GenericAnnounceAdapter, type GenericAnnounceAdapterArgs, GenericDiscoveryAdapter, type GenericDiscoveryAdapterArgs, MetricsTelemetryAdapter, PartyLayerClient, type PartyLayerConfig, type PartyLayerEvent, type RegistryUpdatedEvent, type SessionConnectedEvent, type SessionDisconnectedEvent, type SessionExpiredEvent, type TelemetryConfig, type TxStatusEvent, type WalletFilter, type WalletsChangedEvent, PartyLayerClient as _PartyLayerClientInternal, announcedWalletId, createPartyLayer as createCantonConnect, createPartyLayer, createTelemetryAdapter, getBuiltinAdapters, isTelemetryConfig };
|
package/dist/index.js
CHANGED
|
@@ -579,6 +579,7 @@ function createTelemetryAdapter(config) {
|
|
|
579
579
|
return config;
|
|
580
580
|
}
|
|
581
581
|
var SESSION_STORAGE_KEY = "active_session";
|
|
582
|
+
var WALLETS_CHANGED_DEBOUNCE_MS = 50;
|
|
582
583
|
var PartyLayerClient = class {
|
|
583
584
|
config;
|
|
584
585
|
adapters = /* @__PURE__ */ new Map();
|
|
@@ -605,6 +606,8 @@ var PartyLayerClient = class {
|
|
|
605
606
|
// torn down in destroy(). Empty → listWallets() output is byte-identical.
|
|
606
607
|
announceRegistry = /* @__PURE__ */ new Map();
|
|
607
608
|
announceUnsubscribe = null;
|
|
609
|
+
/** Pending debounced `wallets:changed` emit (coalesces an announce burst). */
|
|
610
|
+
walletsChangedTimer = null;
|
|
608
611
|
origin;
|
|
609
612
|
constructor(config) {
|
|
610
613
|
this.config = config;
|
|
@@ -648,7 +651,7 @@ var PartyLayerClient = class {
|
|
|
648
651
|
this.updateRegistryStatus();
|
|
649
652
|
if (this.announceEnabled) {
|
|
650
653
|
this.announceUnsubscribe = provider.subscribeAnnouncedProviders(
|
|
651
|
-
(p) => this.
|
|
654
|
+
(p) => this.onAnnounceAccumulated(p),
|
|
652
655
|
{ createProvider: (a) => provider.createExtensionChannelProvider({ target: a.target ?? a.id }) }
|
|
653
656
|
);
|
|
654
657
|
}
|
|
@@ -795,6 +798,30 @@ var PartyLayerClient = class {
|
|
|
795
798
|
refreshDiscovery() {
|
|
796
799
|
this.announceEntriesCache = null;
|
|
797
800
|
}
|
|
801
|
+
/**
|
|
802
|
+
* Persistent-accumulator callback (mounted at construction). On each newly
|
|
803
|
+
* announced provider:
|
|
804
|
+
* 1. record it in the live `announceRegistry` (unchanged);
|
|
805
|
+
* 2. invalidate the one-shot `announceEntriesCache` — the SAME invalidation
|
|
806
|
+
* as {@link refreshDiscovery}, so the next `listWallets()` re-aggregates
|
|
807
|
+
* and surfaces the wallet. This does NOT touch `warmPlans` (those hold
|
|
808
|
+
* only GenericDiscoveryAdapter popup plans — a disjoint set);
|
|
809
|
+
* 3. emit a DEBOUNCED `wallets:changed` signal so a reactive consumer (e.g.
|
|
810
|
+
* the React provider) re-lists. The debounce coalesces a burst — and the
|
|
811
|
+
* construction-time reply storm — into one emit (no re-discovery storm).
|
|
812
|
+
*
|
|
813
|
+
* Byte-identical idle: with zero announces this never fires — no invalidation,
|
|
814
|
+
* no emit, no re-list.
|
|
815
|
+
*/
|
|
816
|
+
onAnnounceAccumulated(p) {
|
|
817
|
+
this.announceRegistry.set(p.id, p);
|
|
818
|
+
this.announceEntriesCache = null;
|
|
819
|
+
if (this.walletsChangedTimer !== null) return;
|
|
820
|
+
this.walletsChangedTimer = setTimeout(() => {
|
|
821
|
+
this.walletsChangedTimer = null;
|
|
822
|
+
this.emit("wallets:changed", { type: "wallets:changed", reason: "announced" });
|
|
823
|
+
}, WALLETS_CHANGED_DEBOUNCE_MS);
|
|
824
|
+
}
|
|
798
825
|
/**
|
|
799
826
|
* Aggregate `canton:announceProvider` wallets into the picker list (A2).
|
|
800
827
|
*
|
|
@@ -1335,6 +1362,10 @@ var PartyLayerClient = class {
|
|
|
1335
1362
|
this.announceUnsubscribe?.();
|
|
1336
1363
|
this.announceUnsubscribe = null;
|
|
1337
1364
|
this.announceRegistry.clear();
|
|
1365
|
+
if (this.walletsChangedTimer !== null) {
|
|
1366
|
+
clearTimeout(this.walletsChangedTimer);
|
|
1367
|
+
this.walletsChangedTimer = null;
|
|
1368
|
+
}
|
|
1338
1369
|
this.eventHandlers.clear();
|
|
1339
1370
|
this.activeSession = null;
|
|
1340
1371
|
}
|