@tixyel/streamelements 6.0.3 → 6.1.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/index.d.ts +56 -5
- package/dist/index.es.js +669 -367
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/package.json +2 -1
package/dist/index.d.ts
CHANGED
|
@@ -1740,15 +1740,12 @@ type UseStorageOptions<T> = {
|
|
|
1740
1740
|
data: T;
|
|
1741
1741
|
};
|
|
1742
1742
|
declare class useStorage<T extends JSONObject> extends EventProvider<UseStorageEvents<T>> {
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
*/
|
|
1743
|
+
private SE_API;
|
|
1744
|
+
/** The unique identifier for the storage instance. */
|
|
1746
1745
|
id: string;
|
|
1747
1746
|
loaded: boolean;
|
|
1748
1747
|
data: T;
|
|
1749
1748
|
constructor(options: UseStorageOptions<T>);
|
|
1750
|
-
SE_API: StreamElements.SE_API | null;
|
|
1751
|
-
private start;
|
|
1752
1749
|
/**
|
|
1753
1750
|
* Saves the current data to storage.
|
|
1754
1751
|
* @param data Data to save (defaults to current)
|
|
@@ -2829,6 +2826,58 @@ declare namespace Data {
|
|
|
2829
2826
|
}[];
|
|
2830
2827
|
}
|
|
2831
2828
|
|
|
2829
|
+
type MessageMap = Record<string, any>;
|
|
2830
|
+
type MessageTuple<T extends MessageMap> = {
|
|
2831
|
+
[K in keyof T]: [key: K, data: T[K]];
|
|
2832
|
+
}[keyof T];
|
|
2833
|
+
type BaseEvents<T extends MessageMap> = {
|
|
2834
|
+
load: [];
|
|
2835
|
+
message: MessageTuple<T>;
|
|
2836
|
+
};
|
|
2837
|
+
type UseCommsOptions = {
|
|
2838
|
+
id?: string;
|
|
2839
|
+
};
|
|
2840
|
+
type UseCommItem<T extends MessageMap> = {
|
|
2841
|
+
nonce: string;
|
|
2842
|
+
key: keyof T;
|
|
2843
|
+
value: T[keyof T];
|
|
2844
|
+
timestamp: string;
|
|
2845
|
+
};
|
|
2846
|
+
/**
|
|
2847
|
+
* A module for handling communications between different widgets inside streamelements.
|
|
2848
|
+
* @example
|
|
2849
|
+
* ```ts
|
|
2850
|
+
* type CommsMessages = {
|
|
2851
|
+
* hello: { loaded: boolean };
|
|
2852
|
+
* update: { value: number };
|
|
2853
|
+
* reload: {};
|
|
2854
|
+
* tags: string[];
|
|
2855
|
+
* }
|
|
2856
|
+
*
|
|
2857
|
+
* const comms = new useComms<CommsMessages>();
|
|
2858
|
+
*
|
|
2859
|
+
* comms.on('message', (message, data) => {
|
|
2860
|
+
* switch (message) {
|
|
2861
|
+
* case 'hello': {}
|
|
2862
|
+
* case 'update': {}
|
|
2863
|
+
* case 'reload': {}
|
|
2864
|
+
* case 'tags': {}
|
|
2865
|
+
* }
|
|
2866
|
+
* })
|
|
2867
|
+
* ```
|
|
2868
|
+
*/
|
|
2869
|
+
declare class useComms<T extends MessageMap> extends EventProvider<BaseEvents<T>> {
|
|
2870
|
+
private SE_API;
|
|
2871
|
+
id: string;
|
|
2872
|
+
loaded: boolean;
|
|
2873
|
+
private history;
|
|
2874
|
+
private detected;
|
|
2875
|
+
constructor(options?: UseCommsOptions);
|
|
2876
|
+
send<K extends keyof T>(key: K, data: T[K]): Promise<void>;
|
|
2877
|
+
update(history: Array<UseCommItem<T>>): void;
|
|
2878
|
+
on<K extends keyof BaseEvents<T>>(eventName: K, callback: (this: useComms<T>, ...args: BaseEvents<T>[K]) => void): this;
|
|
2879
|
+
}
|
|
2880
|
+
|
|
2832
2881
|
declare const main: {
|
|
2833
2882
|
SeAPI: Promise<StreamElements.SE_API>;
|
|
2834
2883
|
Client: typeof Client;
|
|
@@ -2841,6 +2890,7 @@ declare const main: {
|
|
|
2841
2890
|
useStorage: typeof useStorage;
|
|
2842
2891
|
useQueue: typeof useQueue;
|
|
2843
2892
|
useLogger: typeof useLogger;
|
|
2893
|
+
useComms: typeof useComms;
|
|
2844
2894
|
};
|
|
2845
2895
|
actions: {
|
|
2846
2896
|
Button: typeof Button;
|
|
@@ -2851,6 +2901,7 @@ declare const main: {
|
|
|
2851
2901
|
};
|
|
2852
2902
|
data: {
|
|
2853
2903
|
usedStorages: useStorage<any>[];
|
|
2904
|
+
usedComms: useComms<any>[];
|
|
2854
2905
|
};
|
|
2855
2906
|
pronouns: {
|
|
2856
2907
|
Alejo: typeof Alejo;
|