@nexus-cross/connect-kit-core 1.3.4 → 1.3.5-beta.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/dist/index.d.ts CHANGED
@@ -302,6 +302,65 @@ interface NetworkConfig {
302
302
  blockExplorerUrl?: string;
303
303
  testnet?: boolean;
304
304
  }
305
+ /**
306
+ * The user-flow lifecycle events the kit EMITS. connect-kit is an SDK: it
307
+ * never stores, batches, or ships telemetry — it only surfaces these
308
+ * events through {@link AnalyticsPort} (react: `useConnectKitAnalytics`),
309
+ * and the DApp is the collection owner.
310
+ *
311
+ * See `docs/connect-kit/09-analytics-events.md`.
312
+ */
313
+ type ConnectKitEventName = 'connect_modal_opened' | 'connect_modal_closed' | 'wallet_selected' | 'connect_started' | 'connect_succeeded' | 'connect_failed' | 'connect_cancelled' | 'wallet_switched' | 'disconnected';
314
+ /** Why a connect attempt terminally failed. */
315
+ type ConnectFailReason = 'connector_error' | 'connector_not_found' | 'fallback_failed' | 'unknown';
316
+ /** Where in the flow the user abandoned a connect attempt. */
317
+ type ConnectCancelStage = 'modal' | 'popup' | 'stalled';
318
+ /**
319
+ * A single user-flow event. Discriminated on {@link ConnectKitEventName}.
320
+ *
321
+ * PRIVACY: payloads carry only categorical/structural values — walletId,
322
+ * walletType, chainId, reason, stage. Never an address, PIN, token, email,
323
+ * balance, or signature. `timestamp` (ms epoch) is stamped by the react
324
+ * adapter, not core (core has no clock).
325
+ */
326
+ interface ConnectKitEventBase {
327
+ name: ConnectKitEventName;
328
+ /** ms epoch, stamped by the react adapter (core has no side effects). */
329
+ timestamp: number;
330
+ }
331
+ type ConnectKitEvent = (ConnectKitEventBase & {
332
+ name: 'connect_modal_opened';
333
+ }) | (ConnectKitEventBase & {
334
+ name: 'connect_modal_closed';
335
+ completed: boolean;
336
+ }) | (ConnectKitEventBase & {
337
+ name: 'wallet_selected';
338
+ walletId: WalletId;
339
+ walletType: ConnectorType;
340
+ }) | (ConnectKitEventBase & {
341
+ name: 'connect_started';
342
+ walletId: WalletId;
343
+ walletType: ConnectorType;
344
+ }) | (ConnectKitEventBase & {
345
+ name: 'connect_succeeded';
346
+ walletId: WalletId;
347
+ walletType: ConnectorType;
348
+ chainId: number;
349
+ }) | (ConnectKitEventBase & {
350
+ name: 'connect_failed';
351
+ walletId: WalletId;
352
+ reason: ConnectFailReason;
353
+ }) | (ConnectKitEventBase & {
354
+ name: 'connect_cancelled';
355
+ walletId: WalletId;
356
+ stage: ConnectCancelStage;
357
+ }) | (ConnectKitEventBase & {
358
+ name: 'wallet_switched';
359
+ index: number;
360
+ }) | (ConnectKitEventBase & {
361
+ name: 'disconnected';
362
+ walletId: WalletId | null;
363
+ });
305
364
  type Unsubscribe = () => void;
306
365
 
307
366
  /**
@@ -391,6 +450,22 @@ interface OAuthPort {
391
450
  signIn(provider: OAuthProvider): Promise<void>;
392
451
  }
393
452
 
453
+ /**
454
+ * Outbound analytics sink. The kit EMITS user-flow events; it never
455
+ * stores, batches, or ships them. The DApp implements this port (in the
456
+ * react layer, via the `useConnectKitAnalytics` hook) to route events into
457
+ * its own analytics (GA, Amplitude, backend, …).
458
+ *
459
+ * Sync + fire-and-forget (like {@link ModalControlPort}): a slow or
460
+ * throwing handler must never block or break the connect flow — the react
461
+ * adapter swallows handler errors.
462
+ *
463
+ * See `docs/connect-kit/09-analytics-events.md`.
464
+ */
465
+ interface AnalyticsPort {
466
+ track(event: ConnectKitEvent): void;
467
+ }
468
+
394
469
  /**
395
470
  * Theme-mode resolution.
396
471
  *
@@ -442,4 +517,4 @@ declare function formatBalance(value: bigint, decimals: number, displayDecimals?
442
517
  */
443
518
  declare function formatWei(wei: bigint, displayDecimals?: number): string;
444
519
 
445
- export { type Account, type AppMetadata, type BalancePort, type ChainBalance, type ColorOverrides, ConnectionStatus, type ConnectorPort, type ConnectorResult, type ConnectorType, type CrossConnectKitConfig, type LegalLinks, type ModalControlPort, type ModalView, type NetworkConfig, type OAuthPort, type OAuthProvider, type PinKeyboardMode, type PinKeyboardOption, type StoragePort, type Theme, type ThemeMode, type ThemePort, type ThemeTokens, type Unsubscribe, type WalletDescriptor, type WalletDetectionPort, type WalletId, type WalletState, formatBalance, formatWei, resolveThemeMode };
520
+ export { type Account, type AnalyticsPort, type AppMetadata, type BalancePort, type ChainBalance, type ColorOverrides, type ConnectCancelStage, type ConnectFailReason, type ConnectKitEvent, type ConnectKitEventName, ConnectionStatus, type ConnectorPort, type ConnectorResult, type ConnectorType, type CrossConnectKitConfig, type LegalLinks, type ModalControlPort, type ModalView, type NetworkConfig, type OAuthPort, type OAuthProvider, type PinKeyboardMode, type PinKeyboardOption, type StoragePort, type Theme, type ThemeMode, type ThemePort, type ThemeTokens, type Unsubscribe, type WalletDescriptor, type WalletDetectionPort, type WalletId, type WalletState, formatBalance, formatWei, resolveThemeMode };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- var f={CONNECTED:"connected",DISCONNECTED:"disconnected",CONNECTING:"connecting",RECONNECTING:"reconnecting"};function u(e,t){if(t&&typeof window<"u"&&window.matchMedia)try{return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}catch{}return typeof e=="string"?e:e&&typeof e=="object"&&"mode"in e?e.mode??"dark":"dark"}function m(e,t,r=4){if(t<0||!Number.isInteger(t))throw new RangeError(`formatBalance: decimals must be a non-negative integer, got ${t}`);if(r<0||!Number.isInteger(r))throw new RangeError(`formatBalance: displayDecimals must be a non-negative integer, got ${r}`);let n=e<0n,i=n?-e:e;if(t===0){let o=i.toString();return n?`-${o}`:o}let l=10n**BigInt(t),s=i/l,g=i%l;if(r===0){let o=s.toString();return n?`-${o}`:o}let c=g.toString().padStart(t,"0").slice(0,r),a=c.length;for(;a>0&&c.charCodeAt(a-1)===48;)a--;let d=c.slice(0,a),p=d?`${s}.${d}`:s.toString();return n?`-${p}`:p}function y(e,t=4){return m(e,18,t)}import{OnRampError as M,normalizeDisallowReason as S}from"@nexus-cross/onramp";export{f as ConnectionStatus,M as OnRampError,m as formatBalance,y as formatWei,S as normalizeDisallowReason,u as resolveThemeMode};
1
+ var f={CONNECTED:"connected",DISCONNECTED:"disconnected",CONNECTING:"connecting",RECONNECTING:"reconnecting"};function u(e,t){if(t&&typeof window<"u"&&window.matchMedia)try{return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}catch{}return typeof e=="string"?e:e&&typeof e=="object"&&"mode"in e?e.mode??"dark":"dark"}function m(e,t,n=4){if(t<0||!Number.isInteger(t))throw new RangeError(`formatBalance: decimals must be a non-negative integer, got ${t}`);if(n<0||!Number.isInteger(n))throw new RangeError(`formatBalance: displayDecimals must be a non-negative integer, got ${n}`);let r=e<0n,c=r?-e:e;if(t===0){let o=c.toString();return r?`-${o}`:o}let s=10n**BigInt(t),i=c/s,g=c%s;if(n===0){let o=i.toString();return r?`-${o}`:o}let l=g.toString().padStart(t,"0").slice(0,n),a=l.length;for(;a>0&&l.charCodeAt(a-1)===48;)a--;let d=l.slice(0,a),p=d?`${i}.${d}`:i.toString();return r?`-${p}`:p}function C(e,t=4){return m(e,18,t)}import{OnRampError as E,normalizeDisallowReason as O}from"@nexus-cross/onramp";export{f as ConnectionStatus,E as OnRampError,m as formatBalance,C as formatWei,O as normalizeDisallowReason,u as resolveThemeMode};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nexus-cross/connect-kit-core",
3
- "version": "1.3.4",
3
+ "version": "1.3.5-beta.2",
4
4
  "description": "Core domain logic for @nexus-cross/connect-kit — types, ports, utilities",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -20,7 +20,7 @@
20
20
  "access": "public"
21
21
  },
22
22
  "dependencies": {
23
- "@nexus-cross/onramp": "1.3.4"
23
+ "@nexus-cross/onramp": "1.3.5-beta.2"
24
24
  },
25
25
  "devDependencies": {
26
26
  "tsup": "^8.4.0",