@hub3js/std 0.2.3 → 0.3.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/types/instanceMap.d.ts +19 -0
- package/dist/types/instanceMap.d.ts.map +1 -0
- package/dist/types/mod.d.ts +1 -0
- package/dist/types/mod.d.ts.map +1 -1
- package/package.json +1 -1
- package/readme.md +1 -1
- package/src/types/instanceMap.ts +18 -0
- package/src/types/mod.ts +2 -0
|
@@ -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"}
|
package/dist/types/mod.d.ts
CHANGED
package/dist/types/mod.d.ts.map
CHANGED
|
@@ -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
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
|
+
}
|