@formo/analytics 1.38.2 → 1.39.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.
Files changed (38) hide show
  1. package/dist/cjs/src/FormoAnalytics.js +9 -4
  2. package/dist/cjs/src/FormoAnalyticsProvider.js +20 -0
  3. package/dist/cjs/src/solana/SolanaManager.d.ts +37 -9
  4. package/dist/cjs/src/solana/SolanaManager.js +135 -20
  5. package/dist/cjs/src/solana/SolanaStoreHandler.d.ts +6 -0
  6. package/dist/cjs/src/solana/SolanaStoreHandler.js +17 -8
  7. package/dist/cjs/src/solana/SolanaWalletStandardRegistry.d.ts +163 -0
  8. package/dist/cjs/src/solana/SolanaWalletStandardRegistry.js +447 -0
  9. package/dist/cjs/src/solana/index.d.ts +10 -5
  10. package/dist/cjs/src/solana/index.js +12 -6
  11. package/dist/cjs/src/solana/storeTypes.d.ts +20 -1
  12. package/dist/cjs/src/solana/types.d.ts +32 -9
  13. package/dist/cjs/src/solana/types.js +15 -0
  14. package/dist/cjs/src/solana/walletStandardTypes.d.ts +54 -0
  15. package/dist/cjs/src/solana/walletStandardTypes.js +21 -0
  16. package/dist/cjs/src/types/base.d.ts +15 -5
  17. package/dist/cjs/src/version.d.ts +1 -1
  18. package/dist/cjs/src/version.js +1 -1
  19. package/dist/esm/src/FormoAnalytics.js +9 -4
  20. package/dist/esm/src/FormoAnalyticsProvider.js +20 -0
  21. package/dist/esm/src/solana/SolanaManager.d.ts +37 -9
  22. package/dist/esm/src/solana/SolanaManager.js +135 -20
  23. package/dist/esm/src/solana/SolanaStoreHandler.d.ts +6 -0
  24. package/dist/esm/src/solana/SolanaStoreHandler.js +18 -9
  25. package/dist/esm/src/solana/SolanaWalletStandardRegistry.d.ts +163 -0
  26. package/dist/esm/src/solana/SolanaWalletStandardRegistry.js +444 -0
  27. package/dist/esm/src/solana/index.d.ts +10 -5
  28. package/dist/esm/src/solana/index.js +10 -5
  29. package/dist/esm/src/solana/storeTypes.d.ts +20 -1
  30. package/dist/esm/src/solana/types.d.ts +32 -9
  31. package/dist/esm/src/solana/types.js +14 -0
  32. package/dist/esm/src/solana/walletStandardTypes.d.ts +54 -0
  33. package/dist/esm/src/solana/walletStandardTypes.js +18 -0
  34. package/dist/esm/src/types/base.d.ts +15 -5
  35. package/dist/esm/src/version.d.ts +1 -1
  36. package/dist/esm/src/version.js +1 -1
  37. package/dist/index.umd.min.js +1 -1
  38. package/package.json +2 -2
@@ -72,13 +72,32 @@ export interface SolanaWalletConnectorMetadata {
72
72
  readonly name: string;
73
73
  readonly icon?: string;
74
74
  }
75
+ /** Cluster health as exposed by framework-kit. */
76
+ export type SolanaClusterStatus = Readonly<{
77
+ status: "idle";
78
+ }> | Readonly<{
79
+ status: "connecting";
80
+ }> | Readonly<{
81
+ status: "ready";
82
+ latencyMs?: number;
83
+ }> | Readonly<{
84
+ status: "error";
85
+ error: unknown;
86
+ }>;
87
+ /** @deprecated framework-kit emits {@link SolanaClusterStatus} objects. */
88
+ export type LegacySolanaClusterStatus = SolanaClusterStatus["status"];
75
89
  /**
76
90
  * Cluster state from the store.
77
91
  */
78
92
  export interface SolanaClusterState {
79
93
  readonly endpoint: string;
80
94
  readonly commitment?: string;
81
- readonly status: "idle" | "connecting" | "ready" | "error";
95
+ /**
96
+ * framework-kit's `ClusterStatus` is a discriminated union such as
97
+ * `{ status: 'ready', latencyMs?: number }`. The pre-1.39 string form is
98
+ * retained so custom stores and test doubles remain source-compatible.
99
+ */
100
+ readonly status: SolanaClusterStatus | LegacySolanaClusterStatus;
82
101
  }
83
102
  /**
84
103
  * The zustand vanilla store API that framework-kit exposes via `client.store`.
@@ -46,15 +46,32 @@ export interface SolanaPublicKey {
46
46
  */
47
47
  export type UnsubscribeFn = () => void;
48
48
  /**
49
- * Solana options for FormoAnalytics
49
+ * The rdns reported for a Solana wallet.
50
+ *
51
+ * The Wallet Standard has no reverse-domain identifier, so one is derived
52
+ * from the wallet's normalized name. Lowercasing and removing whitespace
53
+ * preserves the values historically reported by the framework-kit store;
54
+ * encoding keeps delimiters and other special characters safe for storage.
55
+ * Both Solana paths (Wallet Standard discovery and the framework-kit store)
56
+ * derive it the same way, so a wallet's `detect` and its `connect` share one
57
+ * rdns whichever path reported each.
58
+ */
59
+ export declare function solanaWalletRdns(walletName: string): string;
60
+ /**
61
+ * Solana options for FormoAnalytics.
62
+ *
63
+ * Wallet discovery through the Wallet Standard is on by default and needs
64
+ * none of these. They add framework-kit's store, or name the cluster.
50
65
  */
51
66
  export interface SolanaOptions {
52
67
  /**
53
- * The framework-kit client store (client.store) for automatic event tracking.
54
- * When provided, wallet connect/disconnect and transaction events are tracked
55
- * automatically by subscribing to zustand store state changes.
68
+ * The framework-kit client store (client.store).
69
+ * When provided, transaction lifecycle events and cluster switches are
70
+ * tracked from the store, and connect/disconnect come from the store
71
+ * rather than from Wallet Standard discovery.
56
72
  *
57
- * This is the recommended approach for apps using framework-kit.
73
+ * Only for apps using framework-kit (`@solana/client`). Other integrations
74
+ * do not need a store when their wallets register through Wallet Standard.
58
75
  *
59
76
  * @example
60
77
  * ```tsx
@@ -65,10 +82,16 @@ export interface SolanaOptions {
65
82
  */
66
83
  store?: import("./storeTypes").SolanaClientStore;
67
84
  /**
68
- * The Solana cluster/network.
69
- * Usually auto-detected from the store's endpoint URL.
70
- * Only needed for custom RPC URLs that don't contain a recognizable cluster name.
71
- * @default auto-detected, or "mainnet-beta" if detection fails
85
+ * The Solana cluster/network the app is on.
86
+ *
87
+ * With a store, usually auto-detected from its endpoint URL; only needed
88
+ * for custom RPC URLs that don't contain a recognizable cluster name.
89
+ * Without a store, the Wallet Standard cannot say which cluster the app
90
+ * uses, so a devnet or testnet app should set this (or call
91
+ * `formo.solana.setCluster()`); otherwise connections are reported on
92
+ * mainnet-beta.
93
+ * @default auto-detected from the store; otherwise mainnet-beta when the
94
+ * wallet supports it, or its first supported Solana cluster
72
95
  */
73
96
  cluster?: SolanaCluster;
74
97
  }
@@ -40,4 +40,18 @@ export function isSolanaChainId(chainId) {
40
40
  return false;
41
41
  return Object.values(SOLANA_CHAIN_IDS).includes(chainId);
42
42
  }
43
+ /**
44
+ * The rdns reported for a Solana wallet.
45
+ *
46
+ * The Wallet Standard has no reverse-domain identifier, so one is derived
47
+ * from the wallet's normalized name. Lowercasing and removing whitespace
48
+ * preserves the values historically reported by the framework-kit store;
49
+ * encoding keeps delimiters and other special characters safe for storage.
50
+ * Both Solana paths (Wallet Standard discovery and the framework-kit store)
51
+ * derive it the same way, so a wallet's `detect` and its `connect` share one
52
+ * rdns whichever path reported each.
53
+ */
54
+ export function solanaWalletRdns(walletName) {
55
+ return "sol.wallet.".concat(encodeURIComponent(walletName.toLowerCase().replace(/\s+/g, "")));
56
+ }
43
57
  //# sourceMappingURL=types.js.map
@@ -0,0 +1,54 @@
1
+ /**
2
+ * The subset of the Wallet Standard this SDK reads.
3
+ *
4
+ * Duck-typed on purpose: the SDK must not depend on `@wallet-standard/*`
5
+ * packages (see the dependency policy), and a wallet is discovered through
6
+ * window events, so nothing here is ever imported from a wallet library.
7
+ * Every field is what a conforming wallet exposes; the shapes are looser
8
+ * than the reference types so a slightly off wallet is skipped, not thrown
9
+ * on.
10
+ *
11
+ * @see https://github.com/wallet-standard/wallet-standard
12
+ */
13
+ /** `namespace:reference`, e.g. `solana:mainnet` or `solana:devnet`. */
14
+ export type WalletStandardChain = string;
15
+ export interface WalletStandardAccount {
16
+ readonly address: string;
17
+ readonly publicKey?: unknown;
18
+ /** Chains this account can sign for. Absent on a non-conforming wallet. */
19
+ readonly chains?: readonly WalletStandardChain[];
20
+ readonly features?: readonly string[];
21
+ readonly label?: string;
22
+ readonly icon?: string;
23
+ }
24
+ export interface WalletStandardWallet {
25
+ readonly version?: string;
26
+ readonly name: string;
27
+ readonly icon?: string;
28
+ /** Every chain the wallet supports, NOT the one currently selected. */
29
+ readonly chains: readonly WalletStandardChain[];
30
+ readonly features: Readonly<Record<string, unknown>>;
31
+ /** Accounts the app is currently authorized for; empty until connected. */
32
+ readonly accounts: readonly WalletStandardAccount[];
33
+ }
34
+ /** What a `standard:events` `change` event carries: only what changed. */
35
+ export interface WalletStandardChangeProperties {
36
+ readonly chains?: readonly WalletStandardChain[];
37
+ readonly features?: Readonly<Record<string, unknown>>;
38
+ readonly accounts?: readonly WalletStandardAccount[];
39
+ }
40
+ /** The `standard:events` feature. */
41
+ export interface WalletStandardEventsFeature {
42
+ readonly version?: string;
43
+ on(event: "change", listener: (properties: WalletStandardChangeProperties) => void): () => void;
44
+ }
45
+ /** The API an app hands to wallets so they can announce themselves. */
46
+ export interface WalletStandardRegisterApi {
47
+ register(...wallets: WalletStandardWallet[]): () => void;
48
+ }
49
+ /** Dispatched by the app on `window`; `detail` is the register API. */
50
+ export declare const WALLET_STANDARD_APP_READY_EVENT = "wallet-standard:app-ready";
51
+ /** Dispatched by a wallet on `window`; `detail` is a callback taking the API. */
52
+ export declare const WALLET_STANDARD_REGISTER_WALLET_EVENT = "wallet-standard:register-wallet";
53
+ export declare const WALLET_STANDARD_EVENTS_FEATURE = "standard:events";
54
+ //# sourceMappingURL=walletStandardTypes.d.ts.map
@@ -0,0 +1,18 @@
1
+ /**
2
+ * The subset of the Wallet Standard this SDK reads.
3
+ *
4
+ * Duck-typed on purpose: the SDK must not depend on `@wallet-standard/*`
5
+ * packages (see the dependency policy), and a wallet is discovered through
6
+ * window events, so nothing here is ever imported from a wallet library.
7
+ * Every field is what a conforming wallet exposes; the shapes are looser
8
+ * than the reference types so a slightly off wallet is skipped, not thrown
9
+ * on.
10
+ *
11
+ * @see https://github.com/wallet-standard/wallet-standard
12
+ */
13
+ /** Dispatched by the app on `window`; `detail` is the register API. */
14
+ export var WALLET_STANDARD_APP_READY_EVENT = "wallet-standard:app-ready";
15
+ /** Dispatched by a wallet on `window`; `detail` is a callback taking the API. */
16
+ export var WALLET_STANDARD_REGISTER_WALLET_EVENT = "wallet-standard:register-wallet";
17
+ export var WALLET_STANDARD_EVENTS_FEATURE = "standard:events";
18
+ //# sourceMappingURL=walletStandardTypes.js.map
@@ -246,16 +246,26 @@ export interface Options {
246
246
  */
247
247
  wagmi?: WagmiOptions;
248
248
  /**
249
- * Solana integration configuration.
250
- * Pass `store: client.store` from framework-kit for automatic tracking of
251
- * wallet connect/disconnect and transaction events.
249
+ * Solana wallet tracking.
250
+ *
251
+ * On by default: wallets are discovered through the Wallet Standard, the
252
+ * Solana analogue of EIP-6963, so connect and disconnect are autocaptured
253
+ * for compatible wallets registered with the page, including wallets used
254
+ * through Solana Kit, wallet-adapter, and framework-kit.
255
+ *
256
+ * - `false`: disable Solana wallet discovery and tracking entirely.
257
+ * - `SolanaOptions`: additionally pass `store: client.store` from
258
+ * framework-kit for transaction lifecycle events and cluster switches,
259
+ * or `cluster` to name the network a non-mainnet app is on.
252
260
  *
253
261
  * For signMessage/signTransaction, use formo.signature() directly
254
- * (framework-kit doesn't track these in the store).
262
+ * (neither the Wallet Standard nor framework-kit's store reports these).
255
263
  *
264
+ * @see https://github.com/wallet-standard/wallet-standard
256
265
  * @see https://github.com/solana-foundation/framework-kit
266
+ * @default true
257
267
  */
258
- solana?: SolanaOptions;
268
+ solana?: boolean | SolanaOptions;
259
269
  /**
260
270
  * Custom API host for sending events through your own domain to bypass ad blockers
261
271
  * - If not provided, events are sent directly to events.formo.so
@@ -1,2 +1,2 @@
1
- export declare const version = "1.38.2";
1
+ export declare const version = "1.39.0";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1,4 +1,4 @@
1
1
  // This file is auto-generated by scripts/update-version.js during npm version
2
2
  // Do not edit manually - it will be overwritten
3
- export var version = '1.38.2';
3
+ export var version = '1.39.0';
4
4
  //# sourceMappingURL=version.js.map