@interopio/browser 3.4.8 → 3.5.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/browser.d.ts CHANGED
@@ -115,7 +115,20 @@ export namespace IOConnectBrowser {
115
115
  intents?: IOConnectBrowser.Intents.Config;
116
116
 
117
117
  /* Configure widget */
118
- widget?: IOBrowserWidget.Config;
118
+ widget?: Widget;
119
+ }
120
+
121
+ export interface Widget extends IOBrowserWidget.Config {
122
+ /**
123
+ * Whether to wait for IOBrowserWidget factory to resolve
124
+ * @default true
125
+ */
126
+ awaitFactory?: boolean;
127
+ /**
128
+ * Timeout to wait for the IOBrowserWidget factory to be fetched from the remote source
129
+ * @default 5000
130
+ */
131
+ timeout?: number;
119
132
  }
120
133
 
121
134
  export interface SystemLogger {
@@ -934,6 +947,13 @@ export namespace IOConnectBrowser {
934
947
  * Channels API.
935
948
  */
936
949
  export interface API {
950
+ /**
951
+ * Retrieves the current Channel mode (single or multi Channel). Set by the io.Connect framework based on configuration.
952
+ * @default "single"
953
+ * @since io.Connect Browser 3.5
954
+ */
955
+ mode: Mode;
956
+
937
957
  /**
938
958
  * Tracks the data in the current channel. Persisted after a channel change.
939
959
  * The callback isn't called when you publish the data.
@@ -980,6 +1000,20 @@ export namespace IOConnectBrowser {
980
1000
  */
981
1001
  get(name: string, options?: FDC3Options): Promise<ChannelContext>;
982
1002
 
1003
+ /**
1004
+ * Retrieves a list with the contexts of the current Channels. Can be used both in single and in multi Channel mode.
1005
+ * If used in single Channel mode, the returned array will always contain a single member if the window is joined to a Channel, or will be empty otherwise.
1006
+ * @since io.Connect Browser 3.5
1007
+ */
1008
+ getMyChannels(): Promise<ChannelContext[]>;
1009
+
1010
+ /**
1011
+ * Retrieves a list with the names of the current Channels. Can be used both in single and in multi Channel mode.
1012
+ * If used in single Channel mode, the returned array will always contain a single member if the window is joined to a Channel, or will be empty otherwise.
1013
+ * @since io.Connect Browser 3.5
1014
+ */
1015
+ myChannels(): string[];
1016
+
983
1017
  /**
984
1018
  * Joins a new channel by name. Leaves the current channel.
985
1019
  * @param name The name of the channel to join.
@@ -989,11 +1023,10 @@ export namespace IOConnectBrowser {
989
1023
  join(name: string, windowId?: string): Promise<void>;
990
1024
 
991
1025
  /**
992
- * Leaves the current channels.
993
- * @param config Settings for leaving channels.
994
- * @returns Promise that resolves when the channels has been left.
1026
+ * Removes the current or a specified window from the current or a specified Channel.
1027
+ * @param options Options for leaving Channels.
995
1028
  */
996
- leave(config?: ChannelsLeaveConfig): Promise<void>;
1029
+ leave(options?: LeaveOptions): Promise<void>;
997
1030
 
998
1031
  /**
999
1032
  * Returns the name of the current channel.
@@ -1003,8 +1036,8 @@ export namespace IOConnectBrowser {
1003
1036
  current(): string;
1004
1037
 
1005
1038
  /**
1006
- * Returns the name of the current channel.
1007
- * @returns The name of the current channel.
1039
+ * Retrieves the name of the current Channel.
1040
+ * It's recommended to use the `myChannels()` method instead, which can retrieve the names of the currently joined Channels both in single and in multi Channel mode.
1008
1041
  */
1009
1042
  my(): string;
1010
1043
 
@@ -1017,12 +1050,21 @@ export namespace IOConnectBrowser {
1017
1050
  changed(callback: (channel: string) => void): UnsubscribeFunction;
1018
1051
 
1019
1052
  /**
1020
- * Subscribes for the event which fires when a channel is changed.
1021
- * @param callback Callback function to handle channel changes.
1022
- * @returns Unsubscribe function.
1053
+ * Notifies when the current window joins or leaves a Channel. Returns an unsubscribe function.
1054
+ * It's recommended to use the `onChannelsChanged()` method instead, which can handle Channel changes both in single and in multi Channel mode.
1055
+ * @param callback Callback function for handling the event. Receives as an argument the name of the Channel which the window has joined or left.
1023
1056
  */
1024
1057
  onChanged(callback: (channel: string) => void): UnsubscribeFunction;
1025
1058
 
1059
+ /**
1060
+ * Notifies when the current window joins or leaves a Channel. Can be used both in single and in multi Channel mode.
1061
+ * If used in single Channel mode, when the window joins a Channel, the array argument passed to the callback for handling the event
1062
+ * will always contain a single member; when the window leaves the current Channel, the array will be empty. Returns an unsubscribe function.
1063
+ * @param callback Callback function for handling the event. Receives a list with the names of the currently joined Channels as an argument.
1064
+ * @since io.Connect Browser 3.5
1065
+ */
1066
+ onChannelsChanged(callback: (channels: string[]) => void): UnsubscribeFunction;
1067
+
1026
1068
  /**
1027
1069
  * Adds a new Channel.
1028
1070
  * @param info Initial Channel context.
@@ -1037,8 +1079,8 @@ export namespace IOConnectBrowser {
1037
1079
 
1038
1080
  /**
1039
1081
  * Retrieves the context of the current Channel.
1082
+ * It's recommended to use the `getMyChannels()` method instead, which can retrieve the contexts of the currently joined Channels both in single and in multi Channel mode.
1040
1083
  * @param options Settings for retrieving an FDC3 context published in the io.Connect Channel.
1041
- * @returns Promise that resolves with the context of the current Channel.
1042
1084
  */
1043
1085
  getMy(options?: FDC3Options): Promise<ChannelContext | undefined>;
1044
1086
 
@@ -1078,6 +1120,13 @@ export namespace IOConnectBrowser {
1078
1120
  restrictAll(restrictions: RestrictionsConfig): Promise<void>;
1079
1121
  }
1080
1122
 
1123
+ /**
1124
+ * Channel mode. In single Channel mode, io.Connect Windows can join or leave only one Channel at a time.
1125
+ * In multi Channel mode, io.Connect Windows can join or leave multiple Channels simultaneously.
1126
+ * The Channel mode is set by the io.Connect framework based on configuration.
1127
+ */
1128
+ export type Mode = "single" | "multi";
1129
+
1081
1130
  /**
1082
1131
  * Settings for retrieving and subscribing for FDC3 contexts published in an io.Connect Channel.
1083
1132
  */
@@ -1089,16 +1138,22 @@ export namespace IOConnectBrowser {
1089
1138
  }
1090
1139
 
1091
1140
  /**
1092
- * Options for leaving the Channels.
1141
+ * Options for leaving Channels.
1142
+ * If only a window ID is provided, the specified window will be removed from the current Channel if in single Channel mode,
1143
+ * or from all currently joined Channels if in multi Channel mode.
1144
+ * If you provide only the name of the Channel to leave, the current window will be removed from the specified Channel.
1145
+ * If you don't provide an argument, the current window will be removed from the current Channel if in single Channel mode,
1146
+ * or from all currently joined Channels if in multi Channel mode.
1147
+ * @since io.Connect Browser 3.5
1093
1148
  */
1094
- export interface ChannelsLeaveConfig {
1149
+ export interface LeaveOptions {
1095
1150
  /**
1096
- * ID of a window which to leave from a Channel. If not provided, will leave the current window from the current Channel
1151
+ * ID of an io.Connect Window which to remove from a Channel.
1097
1152
  */
1098
1153
  windowId?: string;
1099
1154
 
1100
1155
  /**
1101
- * Name of a channel which should be left. If not provided, will leave from all current channels.
1156
+ * Name of a Channel from which to remove the current or a specified window.
1102
1157
  */
1103
1158
  channel?: string;
1104
1159
  }
@@ -1156,6 +1211,38 @@ export namespace IOConnectBrowser {
1156
1211
  windowId?: string;
1157
1212
  }
1158
1213
 
1214
+ /**
1215
+ * Provide display hints for FDC3 User Channels intended to be visualized and selectable by end users.
1216
+ */
1217
+ export interface FDC3ChannelDisplayMetadata {
1218
+ /**
1219
+ * A user-readable name for this channel, e.g: `"Red"`. */
1220
+ name?: string;
1221
+ /**
1222
+ * The color that should be associated within this channel when displaying
1223
+ * this channel in a UI, e.g: `#FF0000`. May be any color value supported by
1224
+ * CSS, e.g. name, hex, rgba, etc.. */
1225
+ color?: string;
1226
+
1227
+ /**
1228
+ * A URL of an image that can be used to display this channel. */
1229
+ glyph?: string;
1230
+ }
1231
+
1232
+ export interface FDC3ChannelMeta {
1233
+ id: string;
1234
+ displayMetadata?: FDC3ChannelDisplayMetadata;
1235
+ }
1236
+
1237
+ export interface ChannelMeta {
1238
+ color: string;
1239
+ /**
1240
+ * Provide to enable FDC3 channel support.
1241
+ */
1242
+ fdc3?: FDC3ChannelMeta;
1243
+ [key: string]: any;
1244
+ }
1245
+
1159
1246
  /**
1160
1247
  * Initial context for creating a channel runtime.
1161
1248
  */
@@ -1163,7 +1250,7 @@ export namespace IOConnectBrowser {
1163
1250
  /** Unique name of the context. */
1164
1251
  name: string;
1165
1252
  /** Channel meta data (display name, color, image, etc.) */
1166
- meta: any;
1253
+ meta: ChannelMeta;
1167
1254
  /** Channel data. */
1168
1255
  data?: any;
1169
1256
  }
@@ -1953,6 +2040,20 @@ export namespace IOConnectBrowser {
1953
2040
  */
1954
2041
  clearSavedHandlers(): Promise<void>;
1955
2042
 
2043
+ /**
2044
+ * Notifies when a handler for an Intent is added. Returns an unsubscribe function.
2045
+ * @param callback Callback function for handling the event. Receives an object describing the added Intent handler as an argument.
2046
+ * @since io.Connect Browser 3.5
2047
+ */
2048
+ onHandlerAdded(callback: (handler: IntentHandler, intentName: string) => void): UnsubscribeFunction;
2049
+
2050
+ /**
2051
+ * Notifies when a handler for an Intent is removed. Returns an unsubscribe function.
2052
+ * @param callback Callback function for handling the event. Receives an object describing the removed Intent handler as an argument.
2053
+ * @since io.Connect Browser 3.5
2054
+ */
2055
+ onHandlerRemoved(callback: (handler: IntentHandler, intentName: string) => void): UnsubscribeFunction;
2056
+
1956
2057
  /**
1957
2058
  * An object, which exposes the Intents Resolver API.
1958
2059
  */
package/changelog.md CHANGED
@@ -1,3 +1,10 @@
1
+ 3.5.0
2
+ feat: io.CB 3.5
3
+ feat: Event methods in intents
4
+ feat: Block origins from platform config
5
+ feat: Multi channels
6
+ feat: New widget initialization + UIControllers in Platform and Client
7
+ feat: Add fdc3 channel dynamically
1
8
  3.4.7
2
9
  feat: added support for channel leave by windowId
3
10
  feat: added support for window.onChannelsChanged