@genesislcap/foundation-broadcast-channel 14.172.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. package/README.md +87 -0
  2. package/dist/dts/__test__/config.d.ts +12 -0
  3. package/dist/dts/__test__/config.d.ts.map +1 -0
  4. package/dist/dts/__test__/elements.d.ts +59 -0
  5. package/dist/dts/__test__/elements.d.ts.map +1 -0
  6. package/dist/dts/__test__/index.d.ts +4 -0
  7. package/dist/dts/__test__/index.d.ts.map +1 -0
  8. package/dist/dts/__test__/types.d.ts +28 -0
  9. package/dist/dts/__test__/types.d.ts.map +1 -0
  10. package/dist/dts/broadcast-channel/broadcast-channel.d.ts +123 -0
  11. package/dist/dts/broadcast-channel/broadcast-channel.d.ts.map +1 -0
  12. package/dist/dts/broadcast-channel/index.d.ts +2 -0
  13. package/dist/dts/broadcast-channel/index.d.ts.map +1 -0
  14. package/dist/dts/index.d.ts +3 -0
  15. package/dist/dts/index.d.ts.map +1 -0
  16. package/dist/dts/index.federated.d.ts +1 -0
  17. package/dist/dts/index.federated.d.ts.map +1 -0
  18. package/dist/dts/tsdoc-metadata.json +11 -0
  19. package/dist/dts/utils/index.d.ts +2 -0
  20. package/dist/dts/utils/index.d.ts.map +1 -0
  21. package/dist/dts/utils/logger.d.ts +5 -0
  22. package/dist/dts/utils/logger.d.ts.map +1 -0
  23. package/dist/esm/__test__/config.js +7 -0
  24. package/dist/esm/__test__/elements.js +108 -0
  25. package/dist/esm/__test__/index.js +3 -0
  26. package/dist/esm/__test__/types.js +24 -0
  27. package/dist/esm/broadcast-channel/broadcast-channel.js +61 -0
  28. package/dist/esm/broadcast-channel/index.js +1 -0
  29. package/dist/esm/index.federated.js +1 -0
  30. package/dist/esm/index.js +2 -0
  31. package/dist/esm/utils/index.js +1 -0
  32. package/dist/esm/utils/logger.js +5 -0
  33. package/dist/foundation-broadcast-channel.api.json +797 -0
  34. package/dist/foundation-broadcast-channel.d.ts +138 -0
  35. package/docs/.gitattributes +2 -0
  36. package/docs/api/foundation-broadcast-channel.createtypedbroadcastchannel.md +25 -0
  37. package/docs/api/foundation-broadcast-channel.defaulttypedbroadcastchannel.ismessagetype.md +13 -0
  38. package/docs/api/foundation-broadcast-channel.defaulttypedbroadcastchannel.md +24 -0
  39. package/docs/api/foundation-broadcast-channel.defaulttypedbroadcastchannel.postmessage.md +13 -0
  40. package/docs/api/foundation-broadcast-channel.logger.md +12 -0
  41. package/docs/api/foundation-broadcast-channel.md +32 -0
  42. package/docs/api/foundation-broadcast-channel.registertypedbroadcastchannel.md +24 -0
  43. package/docs/api/foundation-broadcast-channel.typedbroadcastchannel.ismessagetype.md +25 -0
  44. package/docs/api/foundation-broadcast-channel.typedbroadcastchannel.md +42 -0
  45. package/docs/api/foundation-broadcast-channel.typedbroadcastchannel.onmessage.md +34 -0
  46. package/docs/api/foundation-broadcast-channel.typedbroadcastchannel.onmessageerror.md +11 -0
  47. package/docs/api/foundation-broadcast-channel.typedbroadcastchannel.postmessage.md +29 -0
  48. package/docs/api/foundation-broadcast-channel.typedmessageevent.md +16 -0
  49. package/docs/api/index.md +12 -0
  50. package/docs/api-report.md +47 -0
  51. package/license.txt +46 -0
  52. package/package.json +43 -0
@@ -0,0 +1,138 @@
1
+ import { EventDetailMap } from '@genesislcap/foundation-events';
2
+ import { InterfaceSymbol } from '@microsoft/fast-foundation';
3
+ import { Logger } from '@genesislcap/foundation-logger';
4
+
5
+ /**
6
+ * Creates a strongly typed broadcast channel.
7
+ *
8
+ * @remarks
9
+ * `registerTypedBroadcastChannel` may be preferred, as it will create and register the channel in the DI.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * const channel = createTypedBroadcastChannel<GenesisResourcesEvents>(GenesisResourcesChannelId);
14
+ * ```
15
+ * @param name - The channel name.
16
+ * @returns The created TypedBroadcastChannel.
17
+ * @public
18
+ */
19
+ export declare const createTypedBroadcastChannel: <TEventDetailMap extends EventDetailMap>(name: string) => DefaultTypedBroadcastChannel<TEventDetailMap>;
20
+
21
+ /**
22
+ * Default TypedBroadcastChannel implementation.
23
+ * @public
24
+ */
25
+ export declare class DefaultTypedBroadcastChannel<TEventDetailMap extends EventDetailMap> extends BroadcastChannel implements TypedBroadcastChannel<TEventDetailMap> {
26
+ /** {@inheritDoc TypedBroadcastChannel.postMessage} */
27
+ postMessage: PostMessage<TEventDetailMap>;
28
+ /** {@inheritDoc TypedBroadcastChannel.isMessageType} */
29
+ isMessageType: <T extends keyof TEventDetailMap>(type: T, event: TypedMessageEvent<TEventDetailMap, keyof TEventDetailMap>) => event is TypedMessageEvent<TEventDetailMap, T>;
30
+ }
31
+
32
+ /**
33
+ * @public
34
+ */
35
+ export declare const logger: Logger;
36
+
37
+ /**
38
+ * @internal
39
+ */
40
+ declare type OnMessage<TEventDetailMap extends EventDetailMap> = ((this: BroadcastChannel, ev: TypedMessageEvent<TEventDetailMap, keyof TEventDetailMap>) => any) | null;
41
+
42
+ /**
43
+ * @internal
44
+ */
45
+ declare type OnMessageError<TEventDetailMap extends EventDetailMap> = OnMessage<TEventDetailMap>;
46
+
47
+ /**
48
+ * @internal
49
+ */
50
+ declare type PostMessage<TEventDetailMap extends EventDetailMap> = <K extends keyof TEventDetailMap>(...args: TEventDetailMap[K] extends void ? [type: K] : [type: K, detail: TEventDetailMap[K]]) => void;
51
+
52
+ /**
53
+ * Creates a dependency injection key for the broadcast channel being registered which is lazily created when injected.
54
+ * @example In a package's config.ts
55
+ * ```ts
56
+ * export interface GenesisResourcesChannel extends TypedBroadcastChannel<GenesisResourcesEvents> {}
57
+ * ...
58
+ * export const GenesisResourcesChannel = registerTypedBroadcastChannel<GenesisResourcesEvents>(GenesisResourcesChannelId);
59
+ * ```
60
+ * @param name - The channel name.
61
+ * @returns The created key.
62
+ * @public
63
+ */
64
+ export declare const registerTypedBroadcastChannel: <TEventDetailMap extends EventDetailMap>(name: string) => InterfaceSymbol<TypedBroadcastChannel<TEventDetailMap>>;
65
+
66
+ /**
67
+ * A TypedBroadcastChannel for sending and receiving typed messages based on {@link @genesislcap/foundation-events#EventDetailMap} input.
68
+ *
69
+ * @example
70
+ * ```ts
71
+ * export type GenesisResourcesEvents = {
72
+ * 'resources-loaded': ResourceItem[];
73
+ * 'resources-unloaded': void;
74
+ * };
75
+ * ...
76
+ * protected channel: TypedBroadcastChannel<GenesisResourcesEvents>;
77
+ * ```
78
+ *
79
+ * See the {@link registerTypedBroadcastChannel} and {@link createTypedBroadcastChannel} APIs below.
80
+ *
81
+ * @public
82
+ */
83
+ export declare interface TypedBroadcastChannel<TEventDetailMap extends EventDetailMap> extends Omit<BroadcastChannel, 'postMessage' | 'onmessage' | 'onmessageerror'> {
84
+ /**
85
+ * Post strongly typed messages.
86
+ * @example
87
+ * The event detail map provided to the channel on creation will provide `postMessage` typing.
88
+ * ```ts
89
+ * type GenesisResourcesEvents = {
90
+ * 'resources-loaded': ResourceItem[];
91
+ * 'resources-unloaded': void;
92
+ * };
93
+ * ...
94
+ * channel.postMessage('resources-loaded', this.resources); // ok, as this.resources is an array of ResourceItems.
95
+ * channel.postMessage('resources-loaded'); // not ok, as an array is expected for this message type.
96
+ * channel.postMessage('resources-unloaded'); // ok, as this message type maps to void for its detail.
97
+ * ```
98
+ */
99
+ postMessage: PostMessage<TEventDetailMap>;
100
+ /**
101
+ * On message handler.
102
+ * @example Use the `channel.isMessageType` method to narrow based on message types.
103
+ * ```ts
104
+ * import { GenesisResourcesChannel } from '@genesislcap/foundation-comms';
105
+ * ...
106
+ * @GenesisResourcesChannel protected channel: GenesisResourcesChannel;
107
+ * ...
108
+ * this.channel.onmessage = (ev) => {
109
+ * if (this.channel.isMessageType('resources-loaded', ev)) {
110
+ * if (!ev.data.detail.length) {
111
+ * throw Error('No backend resources available');
112
+ * }
113
+ * }
114
+ * };
115
+ * ...
116
+ * this.channel.close();
117
+ * ```
118
+ */
119
+ onmessage: OnMessage<TEventDetailMap>;
120
+ onmessageerror: OnMessageError<TEventDetailMap>;
121
+ /**
122
+ * A type predicate function to narrow down message events based on their 'type' property.
123
+ * @param type - The message type.
124
+ * @param event - The message event.
125
+ */
126
+ isMessageType<T extends keyof TEventDetailMap>(type: T, event: TypedMessageEvent<TEventDetailMap, keyof TEventDetailMap>): event is TypedMessageEvent<TEventDetailMap, T>;
127
+ }
128
+
129
+ /**
130
+ * A TypedMessageEvent for BroadcastChannel transmission.
131
+ * @public
132
+ */
133
+ export declare type TypedMessageEvent<TEventDetailMap extends EventDetailMap, T extends keyof TEventDetailMap> = MessageEvent<{
134
+ type: T;
135
+ detail: TEventDetailMap[T];
136
+ }>;
137
+
138
+ export { }
@@ -0,0 +1,2 @@
1
+ *.md -diff
2
+ *.md linguist-generated
@@ -0,0 +1,25 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@genesislcap/foundation-broadcast-channel](./foundation-broadcast-channel.md) &gt; [createTypedBroadcastChannel](./foundation-broadcast-channel.createtypedbroadcastchannel.md)
4
+
5
+ ## createTypedBroadcastChannel variable
6
+
7
+ Creates a strongly typed broadcast channel.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ createTypedBroadcastChannel: <TEventDetailMap extends EventDetailMap>(name: string) => DefaultTypedBroadcastChannel<TEventDetailMap>
13
+ ```
14
+
15
+ ## Remarks
16
+
17
+ `registerTypedBroadcastChannel` may be preferred, as it will create and register the channel in the DI.
18
+
19
+ ## Example
20
+
21
+
22
+ ```ts
23
+ const channel = createTypedBroadcastChannel<GenesisResourcesEvents>(GenesisResourcesChannelId);
24
+ ```
25
+
@@ -0,0 +1,13 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@genesislcap/foundation-broadcast-channel](./foundation-broadcast-channel.md) &gt; [DefaultTypedBroadcastChannel](./foundation-broadcast-channel.defaulttypedbroadcastchannel.md) &gt; [isMessageType](./foundation-broadcast-channel.defaulttypedbroadcastchannel.ismessagetype.md)
4
+
5
+ ## DefaultTypedBroadcastChannel.isMessageType property
6
+
7
+ A type predicate function to narrow down message events based on their 'type' property.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ isMessageType: <T extends keyof TEventDetailMap>(type: T, event: TypedMessageEvent<TEventDetailMap, keyof TEventDetailMap>) => event is TypedMessageEvent<TEventDetailMap, T>;
13
+ ```
@@ -0,0 +1,24 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@genesislcap/foundation-broadcast-channel](./foundation-broadcast-channel.md) &gt; [DefaultTypedBroadcastChannel](./foundation-broadcast-channel.defaulttypedbroadcastchannel.md)
4
+
5
+ ## DefaultTypedBroadcastChannel class
6
+
7
+ Default TypedBroadcastChannel implementation.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ export declare class DefaultTypedBroadcastChannel<TEventDetailMap extends EventDetailMap> extends BroadcastChannel implements TypedBroadcastChannel<TEventDetailMap>
13
+ ```
14
+ **Extends:** BroadcastChannel
15
+
16
+ **Implements:** [TypedBroadcastChannel](./foundation-broadcast-channel.typedbroadcastchannel.md)<!-- -->&lt;TEventDetailMap&gt;
17
+
18
+ ## Properties
19
+
20
+ | Property | Modifiers | Type | Description |
21
+ | --- | --- | --- | --- |
22
+ | [isMessageType](./foundation-broadcast-channel.defaulttypedbroadcastchannel.ismessagetype.md) | | &lt;T extends keyof TEventDetailMap&gt;(type: T, event: [TypedMessageEvent](./foundation-broadcast-channel.typedmessageevent.md)<!-- -->&lt;TEventDetailMap, keyof TEventDetailMap&gt;) =&gt; event is [TypedMessageEvent](./foundation-broadcast-channel.typedmessageevent.md)<!-- -->&lt;TEventDetailMap, T&gt; | A type predicate function to narrow down message events based on their 'type' property. |
23
+ | [postMessage](./foundation-broadcast-channel.defaulttypedbroadcastchannel.postmessage.md) | | PostMessage&lt;TEventDetailMap&gt; | Post strongly typed messages. |
24
+
@@ -0,0 +1,13 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@genesislcap/foundation-broadcast-channel](./foundation-broadcast-channel.md) &gt; [DefaultTypedBroadcastChannel](./foundation-broadcast-channel.defaulttypedbroadcastchannel.md) &gt; [postMessage](./foundation-broadcast-channel.defaulttypedbroadcastchannel.postmessage.md)
4
+
5
+ ## DefaultTypedBroadcastChannel.postMessage property
6
+
7
+ Post strongly typed messages.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ postMessage: PostMessage<TEventDetailMap>;
13
+ ```
@@ -0,0 +1,12 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@genesislcap/foundation-broadcast-channel](./foundation-broadcast-channel.md) &gt; [logger](./foundation-broadcast-channel.logger.md)
4
+
5
+ ## logger variable
6
+
7
+
8
+ **Signature:**
9
+
10
+ ```typescript
11
+ logger: import("@genesislcap/foundation-logger").Logger
12
+ ```
@@ -0,0 +1,32 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@genesislcap/foundation-broadcast-channel](./foundation-broadcast-channel.md)
4
+
5
+ ## foundation-broadcast-channel package
6
+
7
+ ## Classes
8
+
9
+ | Class | Description |
10
+ | --- | --- |
11
+ | [DefaultTypedBroadcastChannel](./foundation-broadcast-channel.defaulttypedbroadcastchannel.md) | Default TypedBroadcastChannel implementation. |
12
+
13
+ ## Interfaces
14
+
15
+ | Interface | Description |
16
+ | --- | --- |
17
+ | [TypedBroadcastChannel](./foundation-broadcast-channel.typedbroadcastchannel.md) | A TypedBroadcastChannel for sending and receiving typed messages based on input. |
18
+
19
+ ## Variables
20
+
21
+ | Variable | Description |
22
+ | --- | --- |
23
+ | [createTypedBroadcastChannel](./foundation-broadcast-channel.createtypedbroadcastchannel.md) | Creates a strongly typed broadcast channel. |
24
+ | [logger](./foundation-broadcast-channel.logger.md) | |
25
+ | [registerTypedBroadcastChannel](./foundation-broadcast-channel.registertypedbroadcastchannel.md) | Creates a dependency injection key for the broadcast channel being registered which is lazily created when injected. |
26
+
27
+ ## Type Aliases
28
+
29
+ | Type Alias | Description |
30
+ | --- | --- |
31
+ | [TypedMessageEvent](./foundation-broadcast-channel.typedmessageevent.md) | A TypedMessageEvent for BroadcastChannel transmission. |
32
+
@@ -0,0 +1,24 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@genesislcap/foundation-broadcast-channel](./foundation-broadcast-channel.md) &gt; [registerTypedBroadcastChannel](./foundation-broadcast-channel.registertypedbroadcastchannel.md)
4
+
5
+ ## registerTypedBroadcastChannel variable
6
+
7
+ Creates a dependency injection key for the broadcast channel being registered which is lazily created when injected.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ registerTypedBroadcastChannel: <TEventDetailMap extends EventDetailMap>(name: string) => import("@microsoft/fast-foundation").InterfaceSymbol<TypedBroadcastChannel<TEventDetailMap>>
13
+ ```
14
+
15
+ ## Example
16
+
17
+ In a package's config.ts
18
+
19
+ ```ts
20
+ export interface GenesisResourcesChannel extends TypedBroadcastChannel<GenesisResourcesEvents> {}
21
+ ...
22
+ export const GenesisResourcesChannel = registerTypedBroadcastChannel<GenesisResourcesEvents>(GenesisResourcesChannelId);
23
+ ```
24
+
@@ -0,0 +1,25 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@genesislcap/foundation-broadcast-channel](./foundation-broadcast-channel.md) &gt; [TypedBroadcastChannel](./foundation-broadcast-channel.typedbroadcastchannel.md) &gt; [isMessageType](./foundation-broadcast-channel.typedbroadcastchannel.ismessagetype.md)
4
+
5
+ ## TypedBroadcastChannel.isMessageType() method
6
+
7
+ A type predicate function to narrow down message events based on their 'type' property.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ isMessageType<T extends keyof TEventDetailMap>(type: T, event: TypedMessageEvent<TEventDetailMap, keyof TEventDetailMap>): event is TypedMessageEvent<TEventDetailMap, T>;
13
+ ```
14
+
15
+ ## Parameters
16
+
17
+ | Parameter | Type | Description |
18
+ | --- | --- | --- |
19
+ | type | T | The message type. |
20
+ | event | [TypedMessageEvent](./foundation-broadcast-channel.typedmessageevent.md)<!-- -->&lt;TEventDetailMap, keyof TEventDetailMap&gt; | The message event. |
21
+
22
+ **Returns:**
23
+
24
+ event is [TypedMessageEvent](./foundation-broadcast-channel.typedmessageevent.md)<!-- -->&lt;TEventDetailMap, T&gt;
25
+
@@ -0,0 +1,42 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@genesislcap/foundation-broadcast-channel](./foundation-broadcast-channel.md) &gt; [TypedBroadcastChannel](./foundation-broadcast-channel.typedbroadcastchannel.md)
4
+
5
+ ## TypedBroadcastChannel interface
6
+
7
+ A TypedBroadcastChannel for sending and receiving typed messages based on input.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ export interface TypedBroadcastChannel<TEventDetailMap extends EventDetailMap> extends Omit<BroadcastChannel, 'postMessage' | 'onmessage' | 'onmessageerror'>
13
+ ```
14
+ **Extends:** Omit&lt;BroadcastChannel, 'postMessage' \| 'onmessage' \| 'onmessageerror'&gt;
15
+
16
+ ## Example
17
+
18
+
19
+ ```ts
20
+ export type GenesisResourcesEvents = {
21
+ 'resources-loaded': ResourceItem[];
22
+ 'resources-unloaded': void;
23
+ };
24
+ ...
25
+ protected channel: TypedBroadcastChannel<GenesisResourcesEvents>;
26
+ ```
27
+ See the [registerTypedBroadcastChannel](./foundation-broadcast-channel.registertypedbroadcastchannel.md) and [createTypedBroadcastChannel](./foundation-broadcast-channel.createtypedbroadcastchannel.md) APIs below.
28
+
29
+ ## Properties
30
+
31
+ | Property | Modifiers | Type | Description |
32
+ | --- | --- | --- | --- |
33
+ | [onmessage](./foundation-broadcast-channel.typedbroadcastchannel.onmessage.md) | | OnMessage&lt;TEventDetailMap&gt; | On message handler. |
34
+ | [onmessageerror](./foundation-broadcast-channel.typedbroadcastchannel.onmessageerror.md) | | OnMessageError&lt;TEventDetailMap&gt; | |
35
+ | [postMessage](./foundation-broadcast-channel.typedbroadcastchannel.postmessage.md) | | PostMessage&lt;TEventDetailMap&gt; | Post strongly typed messages. |
36
+
37
+ ## Methods
38
+
39
+ | Method | Description |
40
+ | --- | --- |
41
+ | [isMessageType(type, event)](./foundation-broadcast-channel.typedbroadcastchannel.ismessagetype.md) | A type predicate function to narrow down message events based on their 'type' property. |
42
+
@@ -0,0 +1,34 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@genesislcap/foundation-broadcast-channel](./foundation-broadcast-channel.md) &gt; [TypedBroadcastChannel](./foundation-broadcast-channel.typedbroadcastchannel.md) &gt; [onmessage](./foundation-broadcast-channel.typedbroadcastchannel.onmessage.md)
4
+
5
+ ## TypedBroadcastChannel.onmessage property
6
+
7
+ On message handler.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ onmessage: OnMessage<TEventDetailMap>;
13
+ ```
14
+
15
+ ## Example
16
+
17
+ Use the `channel.isMessageType` method to narrow based on message types.
18
+
19
+ ```ts
20
+ import { GenesisResourcesChannel } from '@genesislcap/foundation-comms';
21
+ ...
22
+ @GenesisResourcesChannel protected channel: GenesisResourcesChannel;
23
+ ...
24
+ this.channel.onmessage = (ev) => {
25
+ if (this.channel.isMessageType('resources-loaded', ev)) {
26
+ if (!ev.data.detail.length) {
27
+ throw Error('No backend resources available');
28
+ }
29
+ }
30
+ };
31
+ ...
32
+ this.channel.close();
33
+ ```
34
+
@@ -0,0 +1,11 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@genesislcap/foundation-broadcast-channel](./foundation-broadcast-channel.md) &gt; [TypedBroadcastChannel](./foundation-broadcast-channel.typedbroadcastchannel.md) &gt; [onmessageerror](./foundation-broadcast-channel.typedbroadcastchannel.onmessageerror.md)
4
+
5
+ ## TypedBroadcastChannel.onmessageerror property
6
+
7
+ **Signature:**
8
+
9
+ ```typescript
10
+ onmessageerror: OnMessageError<TEventDetailMap>;
11
+ ```
@@ -0,0 +1,29 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@genesislcap/foundation-broadcast-channel](./foundation-broadcast-channel.md) &gt; [TypedBroadcastChannel](./foundation-broadcast-channel.typedbroadcastchannel.md) &gt; [postMessage](./foundation-broadcast-channel.typedbroadcastchannel.postmessage.md)
4
+
5
+ ## TypedBroadcastChannel.postMessage property
6
+
7
+ Post strongly typed messages.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ postMessage: PostMessage<TEventDetailMap>;
13
+ ```
14
+
15
+ ## Example
16
+
17
+ The event detail map provided to the channel on creation will provide `postMessage` typing.
18
+
19
+ ```ts
20
+ type GenesisResourcesEvents = {
21
+ 'resources-loaded': ResourceItem[];
22
+ 'resources-unloaded': void;
23
+ };
24
+ ...
25
+ channel.postMessage('resources-loaded', this.resources); // ok, as this.resources is an array of ResourceItems.
26
+ channel.postMessage('resources-loaded'); // not ok, as an array is expected for this message type.
27
+ channel.postMessage('resources-unloaded'); // ok, as this message type maps to void for its detail.
28
+ ```
29
+
@@ -0,0 +1,16 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@genesislcap/foundation-broadcast-channel](./foundation-broadcast-channel.md) &gt; [TypedMessageEvent](./foundation-broadcast-channel.typedmessageevent.md)
4
+
5
+ ## TypedMessageEvent type
6
+
7
+ A TypedMessageEvent for BroadcastChannel transmission.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ export type TypedMessageEvent<TEventDetailMap extends EventDetailMap, T extends keyof TEventDetailMap> = MessageEvent<{
13
+ type: T;
14
+ detail: TEventDetailMap[T];
15
+ }>;
16
+ ```
@@ -0,0 +1,12 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md)
4
+
5
+ ## API Reference
6
+
7
+ ## Packages
8
+
9
+ | Package | Description |
10
+ | --- | --- |
11
+ | [@genesislcap/foundation-broadcast-channel](./foundation-broadcast-channel.md) | |
12
+
@@ -0,0 +1,47 @@
1
+ ## API Report File for "@genesislcap/foundation-broadcast-channel"
2
+
3
+ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
+
5
+ ```ts
6
+
7
+ import { EventDetailMap } from '@genesislcap/foundation-events';
8
+ import { InterfaceSymbol } from '@microsoft/fast-foundation';
9
+ import { Logger } from '@genesislcap/foundation-logger';
10
+
11
+ // @public
12
+ export const createTypedBroadcastChannel: <TEventDetailMap extends EventDetailMap>(name: string) => DefaultTypedBroadcastChannel<TEventDetailMap>;
13
+
14
+ // @public
15
+ export class DefaultTypedBroadcastChannel<TEventDetailMap extends EventDetailMap> extends BroadcastChannel implements TypedBroadcastChannel<TEventDetailMap> {
16
+ isMessageType: <T extends keyof TEventDetailMap>(type: T, event: TypedMessageEvent<TEventDetailMap, keyof TEventDetailMap>) => event is TypedMessageEvent<TEventDetailMap, T>;
17
+ // Warning: (ae-forgotten-export) The symbol "PostMessage" needs to be exported by the entry point index.d.ts
18
+ postMessage: PostMessage<TEventDetailMap>;
19
+ }
20
+
21
+ // @public (undocumented)
22
+ export const logger: Logger;
23
+
24
+ // @public
25
+ export const registerTypedBroadcastChannel: <TEventDetailMap extends EventDetailMap>(name: string) => InterfaceSymbol<TypedBroadcastChannel<TEventDetailMap>>;
26
+
27
+ // @public
28
+ export interface TypedBroadcastChannel<TEventDetailMap extends EventDetailMap> extends Omit<BroadcastChannel, 'postMessage' | 'onmessage' | 'onmessageerror'> {
29
+ isMessageType<T extends keyof TEventDetailMap>(type: T, event: TypedMessageEvent<TEventDetailMap, keyof TEventDetailMap>): event is TypedMessageEvent<TEventDetailMap, T>;
30
+ // Warning: (ae-forgotten-export) The symbol "OnMessage" needs to be exported by the entry point index.d.ts
31
+ onmessage: OnMessage<TEventDetailMap>;
32
+ // Warning: (ae-forgotten-export) The symbol "OnMessageError" needs to be exported by the entry point index.d.ts
33
+ //
34
+ // (undocumented)
35
+ onmessageerror: OnMessageError<TEventDetailMap>;
36
+ postMessage: PostMessage<TEventDetailMap>;
37
+ }
38
+
39
+ // @public
40
+ export type TypedMessageEvent<TEventDetailMap extends EventDetailMap, T extends keyof TEventDetailMap> = MessageEvent<{
41
+ type: T;
42
+ detail: TEventDetailMap[T];
43
+ }>;
44
+
45
+ // (No @packageDocumentation comment for this package)
46
+
47
+ ```
package/license.txt ADDED
@@ -0,0 +1,46 @@
1
+ Developer License Agreement
2
+
3
+ This Developer License Agreement (the “Agreement”) is entered into by and between Genesis, Global FinTech Inc.(“Genesis”) and you and/or the entity on whose behalf you are downloading the Software (as defined below) (“you”). This Agreement forms a legally binding contract between you and Genesis in relation to your use of the software libraries, reference implementations, and other related demonstration code (collectively, the “Genesis Software”). [a]
4
+
5
+ To use the Software, you must first agree to this Agreement. You may not use the Software if you do not agree to be bound by the terms of this Agreement. Accordingly, you and Genesis acknowledge and agree as follows:
6
+
7
+ 1. LIMITED LICENSE.
8
+ Subject to your complete and ongoing compliance with all the terms and conditions set forth in this Agreement, including without limitation all license limitations and restrictions set forth herein, Genesis grants you the following limited, non-exclusive, non-transferable, non-sublicensable, revocable licenses to use, and (where applicable) authorize your employees to use, the Software internally solely in connection with building, developing and testing your own applications that interoperate with or incorporate the Software (“Applications”) for the purposes of evaluation.
9
+
10
+ 2. RESTRICTIONS.
11
+ A. By accessing or using the Software, you represent, warrant, and covenant that (a) you are a person or business entity engaged in the development of software applications, and (b) in the case of a business entity, you have the full power and authority to bind such entity to the terms of this Agreement.
12
+ B. You acknowledge that the foregoing license does not include any right to:
13
+ (i) redistribute, sell, lease, license, modify or otherwise create any derivative works of any portion of the Software, or;
14
+ (ii) distribute, deploy, or otherwise utilize Applications on a public, production, commercial, or other similar purpose other than internal use for evaluation and the development of non-public, experimental Applications (any other public, production, commercial, or similar use requires a separate agreement with Genesis), or
15
+ (iii) use or implement any undocumented feature or API or use any documented feature or API other than in accordance with applicable documentation. You agree to not to do any of the foregoing.
16
+ C. Except as expressly provided herein, you may not:
17
+ (a) reproduce, distribute, publicly display, or publicly perform any part of the Software;
18
+ (b) decompile, reverse engineer, or otherwise access or attempt to access the source code for the Software not made available to you in source code form;
19
+ (c) make or attempt to make any modification to, or otherwise create derivative works of the Software; or
20
+ (d) remove, obscure, interfere with or circumvent any feature of the Software, including without limitation any copyright or other intellectual property notices, security, or access control mechanism;
21
+ (f) use the Software to do anything illegal, including facilitating, promoting, or otherwise encouraging any illegal activities.
22
+
23
+ 3. RESERVATION OF RIGHTS.
24
+ A. The Software is owned by Genesis and licensed, not sold, to you. The Software, content, visual interfaces, interactive features, information, graphics, design, compilation, computer code, products, services, and all other elements of the Software and related documentation (the “Materials“), are protected by copyright, trade dress, patent, and trademark laws of the United States and other jurisdictions, international conventions, and all other relevant intellectual property and proprietary rights, and applicable laws (collectively, the “Intellectual Property Rights“).
25
+ B. You agree that Genesis or its subsidiaries or affiliated companies and/or its third-party licensors own all legal right, title and interest in and to the Software and Materials, including any and all Intellectual Property Rights. Genesis reserves all rights not expressly granted in this Agreement. You do not acquire any right, interest or title to the Materials, whether by implication, estoppel, or otherwise, except for the limited rights set forth in this Agreement.
26
+ C. You agree that the form and nature of the Software that Genesis provides may change without prior notice to you and that future versions of the Software may be incompatible with applications developed on previous of the Software. You agree that Genesis may stop (permanently or temporarily) providing the Software (or any features within the Software) to you or to users generally at Genesis’s sole discretion, without prior notice to you. Nothing in this Agreement gives you a right to use any of Genesis’s trade names, trademarks, service marks, logos, domain names, or other distinctive brand features.
27
+
28
+ 4. TERMINATION.
29
+ At Genesis’s sole discretion, Genesis may terminate your Developer License and cease provision of the Genesis Software with or without notice, effective immediately, for any reason or no reason at all. Upon the expiration or termination of this Agreement all rights and licenses granted under this Agreement will immediately terminate.
30
+
31
+ 5. THIRD PARTY SOFTWARE.
32
+ The Software consists of a package of components and may include references to certain third-party software (“Third Party Software”) that are provided by their authors under separate license terms (the “Third Party Terms”). Your use of any such Third-Party Software in conjunction with the Software in a manner consistent with this Agreement is permitted, however, you may have broader rights and/or restrictions under the applicable Third-Party Terms. Genesis cannot accept any responsibility for the Third-Party Software or your use thereof.
33
+
34
+ 6. DISCLAIMER OF WARRANTIES.
35
+ YOU EXPRESSLY UNDERSTAND AND AGREE THAT YOUR USE OF THE SOFTWARE IS AT YOUR SOLE RISK AND THAT THE SOFTWARE IS PROVIDED “AS IS” AND “AS AVAILABLE” WITHOUT WARRANTY OF ANY KIND FROM GENESIS. YOUR USE OF THE SOFTWARE AND ANY MATERIAL DOWNLOADED OR OTHERWISE OBTAINED THROUGH THE USE OF THE SOFTWARE IS AT YOUR OWN DISCRETION AND RISK AND YOU ARE SOLELY RESPONSIBLE FOR ANY DAMAGE TO YOUR COMPUTER SYSTEM OR OTHER DEVICE OR LOSS OF DATA THAT RESULTS FROM SUCH USE. GENESIS FURTHER EXPRESSLY DISCLAIMS ALL WARRANTIES AND CONDITIONS OF ANY KIND, WHETHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. GENESIS EXPRESSLY DISCLAIMS ANY WARRANTIES OF ANY KIND WITH RESPECT TO THE ACCURACY OR FUNCTIONALITY OF THE SOFTWARE, AND WITH RESPECT TO THE ACCURACY, VALIDITY, OR COMPLETENESS OF ANY INFORMATION OR FEATURES AVAILABLE THROUGH THE SOFTWARE, OR THE QUALITY OR CONSISTENCY OF THE SOFTWARE OR RESULTS OBTAINED THROUGH ITS USE.
36
+
37
+ 7. INDEMNIFICATION. To the maximum extent permitted by law, you agree to defend, indemnify, and hold harmless Genesis, its affiliates, and their respective directors, officers, employees, and agents, from and against any and all third-party claims, actions, suits, or proceedings, as well as any and all losses, liabilities, damages, costs, and expenses (including reasonable attorneys’ fees) arising out of or accruing from (a) your breach of this Developer License; (b) your use or misuse of the Genesis Software; (c) your negligence or willful misconduct; and/or (d) your use of the Genesis Software that actually or allegedly infringes any Intellectual Property Rights or privacy rights of any third party in any jurisdiction.
38
+
39
+ 8. MISCELLANEOUS.
40
+ (a) If you are agreeing to be bound by this Agreement on behalf of your employer or other entity, you represent and warrant that you have full legal authority to bind your employer or such entity to this Agreement. If you do not have the requisite authority, you may not accept this Agreement on behalf of your employer or other entity.
41
+ (b) This Developer License shall be governed by, and construed in accordance with, the laws of the State of New York without regard to conflict of law principles. For all purposes of this Developer License, the parties’ consent to exclusive jurisdiction and venue in the state and federal courts located in New York County, New York.
42
+ (c) Nothing in this Agreement, or in the nature of your access and use of the Genesis Software, shall create or is intended to create a joint-venture, partnership, or agency relationship between you and Genesis.
43
+ (d) You may not assign or transfer this Agreement or any of your rights or obligations hereunder, absent the prior written consent of Genesis.
44
+ (e) You agree that if Genesis does not exercise or enforce any legal right or remedy contained in this Agreement, this will not be taken to be a formal waiver of Genesis’s rights and that those rights or remedies will still be available to Genesis.
45
+ (f) This Agreement constitutes the complete understanding between you and Genesis with respect to the subject matter contained herein, and supersedes all prior written or oral communications, understandings, and agreements.
46
+ (g) If any provision of this Agreement is deemed to be illegal, invalid, or unenforceable, then that provision shall be removed, and the remaining terms will continue to be valid and enforceable.
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@genesislcap/foundation-broadcast-channel",
3
+ "description": "Genesis Broadcast Channel",
4
+ "version": "14.172.0",
5
+ "sideEffects": false,
6
+ "license": "SEE LICENSE IN license.txt",
7
+ "main": "dist/esm/index.js",
8
+ "types": "dist/dts/index.d.ts",
9
+ "engines": {
10
+ "node": ">=20.0.0"
11
+ },
12
+ "scripts": {
13
+ "build": "genx build -b ts",
14
+ "clean": "rimraf dist tsconfig.tsbuildinfo",
15
+ "dev": "genx dev -b ts",
16
+ "test": "tsc && genx test"
17
+ },
18
+ "devDependencies": {
19
+ "@genesislcap/foundation-testing": "14.172.0",
20
+ "@genesislcap/genx": "14.172.0",
21
+ "@genesislcap/rollup-builder": "14.172.0",
22
+ "@genesislcap/ts-builder": "14.172.0",
23
+ "@genesislcap/uvu-playwright-builder": "14.172.0",
24
+ "@genesislcap/vite-builder": "14.172.0",
25
+ "@genesislcap/webpack-builder": "14.172.0",
26
+ "rimraf": "^3.0.2"
27
+ },
28
+ "dependencies": {
29
+ "@genesislcap/foundation-events": "14.172.0",
30
+ "@genesislcap/foundation-logger": "14.172.0",
31
+ "@microsoft/fast-element": "^1.12.0",
32
+ "@microsoft/fast-foundation": "^2.49.4"
33
+ },
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "git+https://github.com/genesislcap/foundation-ui.git",
37
+ "directory": "packages/foundation/foundation-broadcast-channel"
38
+ },
39
+ "publishConfig": {
40
+ "access": "public"
41
+ },
42
+ "gitHead": "9ce48fc32022d61cd28b18c4b378af72e04b562f"
43
+ }