@dynamic-labs/message-transport 2.0.0-alpha.26 → 2.0.0-alpha.27

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/CHANGELOG.md CHANGED
@@ -1,4 +1,13 @@
1
1
 
2
+ ## [2.0.0-alpha.27](https://github.com/dynamic-labs/DynamicAuth/compare/v2.0.0-alpha.26...v2.0.0-alpha.27) (2024-04-09)
3
+
4
+
5
+ ### Bug Fixes
6
+
7
+ * coinbase improvements ([#5268](https://github.com/dynamic-labs/DynamicAuth/issues/5268)) ([c10a6de](https://github.com/dynamic-labs/DynamicAuth/commit/c10a6debcacff6cd97f2436fbde387f85faa5682))
8
+ * show qr code for metamask on desktop when not installed ([#5262](https://github.com/dynamic-labs/DynamicAuth/issues/5262)) ([1dcb4d9](https://github.com/dynamic-labs/DynamicAuth/commit/1dcb4d98de8a95f6b11d7bad90b9059110087385))
9
+ * update title of hardware wallet select screen ([#5270](https://github.com/dynamic-labs/DynamicAuth/issues/5270)) ([6e8fe17](https://github.com/dynamic-labs/DynamicAuth/commit/6e8fe17306677786ccf528b97ab673b9ae6b57b9))
10
+
2
11
  ## [2.0.0-alpha.26](https://github.com/dynamic-labs/DynamicAuth/compare/v2.0.0-alpha.25...v2.0.0-alpha.26) (2024-04-08)
3
12
 
4
13
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/message-transport",
3
- "version": "2.0.0-alpha.26",
3
+ "version": "2.0.0-alpha.27",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/dynamic-labs/DynamicAuth.git",
@@ -24,5 +24,8 @@
24
24
  "require": "./src/index.cjs"
25
25
  },
26
26
  "./package.json": "./package.json"
27
+ },
28
+ "peerDependencies": {
29
+ "eventemitter3": "5.0.1"
27
30
  }
28
31
  }
@@ -0,0 +1 @@
1
+ export * from './store';
@@ -0,0 +1,9 @@
1
+ import { MessageTransportWithDefaultOrigin } from '../messageTransport';
2
+ import { Store } from './types';
3
+ type CreateStoreProps<T extends Record<string, unknown>, U extends string> = {
4
+ messageTransport: MessageTransportWithDefaultOrigin;
5
+ key: U;
6
+ initialState: T;
7
+ };
8
+ export declare const createStore: <T extends Record<string, unknown> = never, U extends string = never>({ initialState, key, messageTransport, }: CreateStoreProps<T, U>) => Store<T>;
9
+ export {};
@@ -0,0 +1 @@
1
+ export * from './storeSetter';
@@ -0,0 +1,8 @@
1
+ import { MessageTransportWithDefaultOrigin } from '../../messageTransport';
2
+ import { StoreSetter } from '../types';
3
+ type CreateStoreSetterProps<U extends string> = {
4
+ messageTransport: MessageTransportWithDefaultOrigin;
5
+ key: U;
6
+ };
7
+ export declare const createStoreSetter: <T extends Record<string, unknown> = never, U extends string = never>({ key, messageTransport, }: CreateStoreSetterProps<U>) => StoreSetter<T>;
8
+ export {};
@@ -0,0 +1,39 @@
1
+ import EventEmitter from 'eventemitter3';
2
+ /**
3
+ * Readonly getters for the store values
4
+ */
5
+ export type StoreStateGetters<T extends Record<string, unknown>> = {
6
+ readonly [K in keyof T]: T[K];
7
+ };
8
+ /**
9
+ * The type of a getter that allows reading and listening to values from a store
10
+ */
11
+ export type Store<T extends Record<string, unknown>> = {
12
+ getters: StoreStateGetters<T>;
13
+ emitters: Pick<EventEmitter<StoreStateEvents<T>>, 'on' | 'once' | 'off'>;
14
+ };
15
+ /**
16
+ * The type of a setter that allows setting values of all stores connected to the same
17
+ * messageTransport
18
+ */
19
+ export type StoreSetter<T extends Record<string, unknown>> = {
20
+ set: (values: Partial<T>) => void;
21
+ };
22
+ /**
23
+ * Defines how state change messages, to be sent across messageTransport, are named.
24
+ * These messages are not made public. They are only used to communicate state changes across the webview.
25
+ */
26
+ export type StoreStateChangeMessage<T extends Record<string, unknown>, K extends Extract<keyof T, string>, U extends string> = `${U}__${K}Changed`;
27
+ /**
28
+ * Defines how state change events are named.
29
+ * These events are emitted by the store, and are made public for client consumption.
30
+ *
31
+ * Do not confuse these with StoreStateChangeMessage, which are only for internal communication.
32
+ */
33
+ export type StoreStateChangeEvent<T extends Record<string, unknown>, K extends Extract<keyof T, string>> = `${K}Changed`;
34
+ /**
35
+ * Generates the event types for a StoreState
36
+ */
37
+ export type StoreStateEvents<T extends Record<string, unknown>> = {
38
+ [K in Extract<keyof T, string> as StoreStateChangeEvent<T, K>]: (value: T[K]) => void;
39
+ };