@hub3js/std 0.2.3 → 0.2.4-next.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.
@@ -0,0 +1,19 @@
1
+ /**
2
+ * A `Map` that preserves the correlation between its keys and value types.
3
+ *
4
+ * ```ts
5
+ * type ProviderObject = {
6
+ * [EVM_NAMESPACE]: EvmProviderApi;
7
+ * [SOLANA_NAMESPACE]: SolanaProviderApi;
8
+ * };
9
+ *
10
+ * const instances: InstanceMap<ProviderObject> = new Map();
11
+ * instances.set(EVM_NAMESPACE, evmInstance);
12
+ * instances.get(EVM_NAMESPACE); // EvmProviderApi | undefined, not a union
13
+ * ```
14
+ */
15
+ export interface InstanceMap<T> extends Map<keyof T, T[keyof T]> {
16
+ get<K extends keyof T>(key: K): T[K] | undefined;
17
+ set<K extends keyof T>(key: K, value: T[K]): this;
18
+ }
19
+ //# sourceMappingURL=instanceMap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instanceMap.d.ts","sourceRoot":"","sources":["../../src/types/instanceMap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,WAAW,CAAC,CAAC,CAAE,SAAQ,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;IAC9D,GAAG,CAAC,CAAC,SAAS,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;IACjD,GAAG,CAAC,CAAC,SAAS,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;CACnD"}
@@ -1,3 +1,4 @@
1
1
  export type { CommonActions, AutoImplementedActionsByRecommended, } from './namespace.js';
2
2
  export type { CaipAccount, Accounts, AccountsWithActiveChain, } from './accounts.js';
3
+ export type { InstanceMap } from './instanceMap.js';
3
4
  //# sourceMappingURL=mod.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/types/mod.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,aAAa,EACb,mCAAmC,GACpC,MAAM,gBAAgB,CAAC;AAExB,YAAY,EACV,WAAW,EACX,QAAQ,EACR,uBAAuB,GACxB,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/types/mod.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,aAAa,EACb,mCAAmC,GACpC,MAAM,gBAAgB,CAAC;AAExB,YAAY,EACV,WAAW,EACX,QAAQ,EACR,uBAAuB,GACxB,MAAM,eAAe,CAAC;AAEvB,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hub3js/std",
3
- "version": "0.2.3",
3
+ "version": "0.2.4-next.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
package/readme.md CHANGED
@@ -11,5 +11,5 @@ Exposed via subpaths:
11
11
  - `@hub3js/std/actions` — shared action implementations (e.g. `disconnect`)
12
12
  - `@hub3js/std/builders` — pre-wired `ActionBuilder` factories
13
13
  - `@hub3js/std/hooks` — reusable subscriber builders (e.g. `ChangeAccountSubscriberBuilder`)
14
- - `@hub3js/std/types` — foundational types (`Namespace`, CAIP accounts, common actions)
14
+ - `@hub3js/std/types` — foundational types (`Namespace`, CAIP accounts, common actions, `InstanceMap`)
15
15
  - `@hub3js/std/utils` — CAIP validation, error standardization
@@ -0,0 +1,18 @@
1
+ /**
2
+ * A `Map` that preserves the correlation between its keys and value types.
3
+ *
4
+ * ```ts
5
+ * type ProviderObject = {
6
+ * [EVM_NAMESPACE]: EvmProviderApi;
7
+ * [SOLANA_NAMESPACE]: SolanaProviderApi;
8
+ * };
9
+ *
10
+ * const instances: InstanceMap<ProviderObject> = new Map();
11
+ * instances.set(EVM_NAMESPACE, evmInstance);
12
+ * instances.get(EVM_NAMESPACE); // EvmProviderApi | undefined, not a union
13
+ * ```
14
+ */
15
+ export interface InstanceMap<T> extends Map<keyof T, T[keyof T]> {
16
+ get<K extends keyof T>(key: K): T[K] | undefined;
17
+ set<K extends keyof T>(key: K, value: T[K]): this;
18
+ }
package/src/types/mod.ts CHANGED
@@ -8,3 +8,5 @@ export type {
8
8
  Accounts,
9
9
  AccountsWithActiveChain,
10
10
  } from './accounts.js';
11
+
12
+ export type { InstanceMap } from './instanceMap.js';