@salesforce/storefront-next-runtime 0.1.1-alpha.0 → 0.2.0-alpha.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/DesignComponent.js +150 -0
- package/dist/DesignComponent.js.map +1 -0
- package/dist/DesignFrame.js +196 -0
- package/dist/DesignFrame.js.map +1 -0
- package/dist/DesignRegion.js +83 -0
- package/dist/DesignRegion.js.map +1 -0
- package/dist/apply-url-config.js +130 -0
- package/dist/apply-url-config.js.map +1 -0
- package/dist/component.types.d.ts +87 -0
- package/dist/component.types.d.ts.map +1 -0
- package/dist/config.d.ts +2 -0
- package/dist/config.js +0 -0
- package/dist/design-data.d.ts +983 -0
- package/dist/design-data.d.ts.map +1 -0
- package/dist/design-data.js +908 -0
- package/dist/design-data.js.map +1 -0
- package/dist/design-messaging.d.ts +2 -2
- package/dist/design-react-core.d.ts +50 -5
- package/dist/design-react-core.d.ts.map +1 -1
- package/dist/design-react-core.js +81 -2
- package/dist/design-react-core.js.map +1 -1
- package/dist/design-react.d.ts +20 -95
- package/dist/design-react.d.ts.map +1 -1
- package/dist/design-react.js +3 -485
- package/dist/design-styles.css +2 -1
- package/dist/design.d.ts +110 -2
- package/dist/design.d.ts.map +1 -0
- package/dist/events.d.ts +1 -1
- package/dist/index.d.ts +1110 -154
- package/dist/index.d.ts.map +1 -1
- package/dist/multi-site.d.ts +154 -0
- package/dist/multi-site.d.ts.map +1 -0
- package/dist/multi-site.js +393 -0
- package/dist/multi-site.js.map +1 -0
- package/dist/routing-app-wrapper.d.ts +18 -0
- package/dist/routing-app-wrapper.d.ts.map +1 -0
- package/dist/routing-app-wrapper.js +21 -0
- package/dist/routing-app-wrapper.js.map +1 -0
- package/dist/routing.d.ts +42 -0
- package/dist/routing.d.ts.map +1 -0
- package/dist/routing.js +171 -0
- package/dist/routing.js.map +1 -0
- package/dist/scapi.d.ts +69 -5
- package/dist/scapi.d.ts.map +1 -1
- package/dist/scapi.js +1 -1
- package/dist/scapi.js.map +1 -1
- package/dist/types.d.ts +40 -13289
- package/dist/types.d.ts.map +1 -1
- package/dist/types2.d.ts +13293 -0
- package/dist/types2.d.ts.map +1 -0
- package/dist/types3.d.ts +110 -0
- package/dist/types3.d.ts.map +1 -0
- package/dist/workspace.d.ts +46 -0
- package/dist/workspace.d.ts.map +1 -0
- package/dist/workspace.js +52 -0
- package/dist/workspace.js.map +1 -0
- package/package.json +44 -2
- package/dist/design-react.js.map +0 -1
- package/dist/index2.d.ts +0 -1171
- package/dist/index2.d.ts.map +0 -1
- /package/{LICENSE.txt → LICENSE} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,215 +1,1171 @@
|
|
|
1
|
-
|
|
1
|
+
import { r as ShopperExperience } from "./types2.js";
|
|
2
|
+
|
|
3
|
+
//#region src/design/messaging-api/domain-types.d.ts
|
|
4
|
+
|
|
5
|
+
interface WithBaseEvent {
|
|
6
|
+
eventType: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* @inline
|
|
10
|
+
* @hidden
|
|
11
|
+
*/
|
|
12
|
+
interface WithComponentId {
|
|
13
|
+
/**
|
|
14
|
+
* The id of the component that the event is related to.
|
|
15
|
+
*/
|
|
16
|
+
componentId: string;
|
|
17
|
+
}
|
|
18
|
+
interface WithComponentType {
|
|
19
|
+
/**
|
|
20
|
+
* The component type that the event is related to.
|
|
21
|
+
*/
|
|
22
|
+
componentType: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* @inline
|
|
26
|
+
* @hidden
|
|
27
|
+
*/
|
|
28
|
+
interface WithClientVector {
|
|
29
|
+
/**
|
|
30
|
+
* The x position of the event.
|
|
31
|
+
* The position is relative to the client window and does not take any scrolling into account.
|
|
32
|
+
*/
|
|
33
|
+
x: number;
|
|
34
|
+
/**
|
|
35
|
+
* The y position of the event.
|
|
36
|
+
* The position is relative to the client window and does not take any scrolling into account.
|
|
37
|
+
*/
|
|
38
|
+
y: number;
|
|
39
|
+
}
|
|
40
|
+
interface HostToClientConfiguration {
|
|
41
|
+
/**
|
|
42
|
+
* The components by id that are in the component tree.
|
|
43
|
+
*/
|
|
44
|
+
components: Record<string, ComponentInfo>;
|
|
45
|
+
/**
|
|
46
|
+
* A map of component types by id.
|
|
47
|
+
*/
|
|
48
|
+
componentTypes: Record<string, ComponentType>;
|
|
49
|
+
/**
|
|
50
|
+
* A map of labels by translation key. These labels will be in the locale of the user.
|
|
51
|
+
*/
|
|
52
|
+
labels: Record<string, string>;
|
|
53
|
+
/**
|
|
54
|
+
* The locale to use on the client.
|
|
55
|
+
*/
|
|
56
|
+
locale?: string;
|
|
57
|
+
}
|
|
2
58
|
/**
|
|
3
|
-
*
|
|
59
|
+
* The default keys that are forwarded from the host to the client.
|
|
60
|
+
* @hidden
|
|
61
|
+
*/
|
|
62
|
+
type DefaultForwardedKeys = 'ArrowUp' | 'ArrowDown' | 'ArrowLeft' | 'ArrowRight' | 'Delete';
|
|
63
|
+
/**
|
|
64
|
+
* Information about a component on the page.
|
|
65
|
+
*/
|
|
66
|
+
interface ComponentInfo {
|
|
67
|
+
/**
|
|
68
|
+
* The unique id of the component.
|
|
69
|
+
*/
|
|
70
|
+
id: string;
|
|
71
|
+
/**
|
|
72
|
+
* The component type.
|
|
73
|
+
*/
|
|
74
|
+
type: string;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Information about a component type.
|
|
78
|
+
*/
|
|
79
|
+
interface ComponentType {
|
|
80
|
+
/**
|
|
81
|
+
* The unique id of the component type.
|
|
82
|
+
*/
|
|
83
|
+
id: string;
|
|
84
|
+
/**
|
|
85
|
+
* The name of the component type.
|
|
86
|
+
*/
|
|
87
|
+
name: string;
|
|
88
|
+
/**
|
|
89
|
+
* The image of the component type.
|
|
90
|
+
*/
|
|
91
|
+
image: string;
|
|
92
|
+
/**
|
|
93
|
+
* The label for the component type.
|
|
94
|
+
*/
|
|
95
|
+
label: string;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Emitted by the client to establish a connection with the host.
|
|
99
|
+
* This event should be emitted by the client on an interval until a ClientAcknowledgedEvent is received from the host.
|
|
4
100
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
101
|
+
* - If there is already a registered client with the host with the same client name,
|
|
102
|
+
* the old client will be replaced with the new one.
|
|
103
|
+
* - If there is already a registered client with the host with a different client id,
|
|
104
|
+
* an error will be thrown.
|
|
8
105
|
*
|
|
9
|
-
*
|
|
106
|
+
* A client is a 1 to 1 with a host.
|
|
10
107
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
108
|
+
* ```mermaid
|
|
109
|
+
* sequenceDiagram
|
|
110
|
+
* Client->>Host: ClientInitializedEvent
|
|
111
|
+
* Host->>Client: ClientAcknowledgedEvent
|
|
112
|
+
* Client->>Host: ClientReadyEvent
|
|
113
|
+
* activate Client
|
|
114
|
+
* Client->>Host: ComponentSelectedEvent
|
|
115
|
+
* Host->>Client: ComponentPropertiesChangedEvent
|
|
116
|
+
* ```
|
|
117
|
+
*
|
|
118
|
+
* If the host is not ready to register the client, the client should retry at an interval until the host is ready.
|
|
119
|
+
*
|
|
120
|
+
* ```mermaid
|
|
121
|
+
* sequenceDiagram
|
|
122
|
+
* Client-->>Host: ClientInitializedEvent
|
|
123
|
+
* Client-->>Host: ClientInitializedEvent
|
|
124
|
+
* Client->>Host: ClientInitializedEvent
|
|
125
|
+
* Host->>Client: ClientAcknowledgedEvent
|
|
126
|
+
* Client->>Host: ClientReadyEvent
|
|
127
|
+
* activate Client
|
|
128
|
+
* Client->>Host: ComponentSelectedEvent
|
|
129
|
+
* Host->>Client: ComponentPropertiesChangedEvent
|
|
130
|
+
* ```
|
|
131
|
+
*
|
|
132
|
+
* @see {ClientAcknowledgedEvent}
|
|
133
|
+
* @target host
|
|
134
|
+
* @group Events
|
|
16
135
|
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
136
|
+
interface ClientInitializedEvent extends WithBaseEvent {
|
|
137
|
+
eventType: 'ClientInitialized';
|
|
138
|
+
/**
|
|
139
|
+
* The id to use for the client.
|
|
140
|
+
*/
|
|
141
|
+
clientId: string;
|
|
142
|
+
/**
|
|
143
|
+
* The keys that are forwarded from the host to the client.
|
|
144
|
+
*/
|
|
145
|
+
forwardedKeys?: string[];
|
|
146
|
+
/**
|
|
147
|
+
* The user session ID.
|
|
148
|
+
*/
|
|
149
|
+
usid?: string;
|
|
150
|
+
}
|
|
151
|
+
interface ClientReady extends WithBaseEvent {
|
|
152
|
+
eventType: 'ClientReady';
|
|
153
|
+
/**
|
|
154
|
+
* The id to use for the client.
|
|
155
|
+
*/
|
|
156
|
+
clientId: string;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Emits when a client disconnects from the host.
|
|
160
|
+
* This event may not fire depending on the circumstances of the disconnect.
|
|
161
|
+
* For example, if a crash occurs in the client environment, the event may not fire.
|
|
162
|
+
* @target host
|
|
163
|
+
* @group Events
|
|
164
|
+
*/
|
|
165
|
+
interface ClientDisconnectedEvent extends WithBaseEvent {
|
|
166
|
+
eventType: 'ClientDisconnected';
|
|
167
|
+
/**
|
|
168
|
+
* The id of the client that disconnected.
|
|
169
|
+
*/
|
|
170
|
+
clientId: string;
|
|
171
|
+
/**
|
|
172
|
+
* Whether the client is attempting to reconnect to the host.
|
|
173
|
+
* This occurs when the client as a configuration change.
|
|
174
|
+
*/
|
|
175
|
+
reconnect: boolean;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Emits when the components in the client configuration change.
|
|
179
|
+
* @target client
|
|
180
|
+
* @group Events
|
|
181
|
+
*/
|
|
182
|
+
interface ClientPageChangedEvent extends WithBaseEvent {
|
|
183
|
+
eventType: 'ClientPageChanged';
|
|
184
|
+
/**
|
|
185
|
+
* The page data from the client.
|
|
186
|
+
*/
|
|
187
|
+
page: ShopperExperience.schemas['Page'];
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Emits when the host disconnects from the client.
|
|
191
|
+
* @target client
|
|
192
|
+
* @group Events
|
|
193
|
+
*/
|
|
194
|
+
interface HostDisconnected extends WithBaseEvent {
|
|
195
|
+
eventType: 'HostDisconnected';
|
|
196
|
+
}
|
|
20
197
|
/**
|
|
21
|
-
*
|
|
198
|
+
* Emits from the host to the client to acknowledge that the client has been initialized.
|
|
199
|
+
* This event must be received by the client before any other events can be emitted from the client.
|
|
200
|
+
* @target client
|
|
201
|
+
* @group Events
|
|
22
202
|
*/
|
|
23
|
-
|
|
203
|
+
interface ClientAcknowledgedEvent extends WithBaseEvent, HostToClientConfiguration {
|
|
204
|
+
eventType: 'ClientAcknowledged';
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Emits when the client configuration changes from the host since the last ClientAcknowledgedEvent.
|
|
208
|
+
* @target client
|
|
209
|
+
* @group Events
|
|
210
|
+
*/
|
|
211
|
+
interface ClientConfigurationChangedEvent extends WithBaseEvent, HostToClientConfiguration {
|
|
212
|
+
eventType: 'ClientConfigurationChanged';
|
|
213
|
+
}
|
|
24
214
|
/**
|
|
25
|
-
*
|
|
215
|
+
* Emits when dragging from the host enters the client window.
|
|
216
|
+
* @target client
|
|
217
|
+
* @group Events
|
|
26
218
|
*/
|
|
27
|
-
interface
|
|
28
|
-
|
|
29
|
-
loader?: string;
|
|
30
|
-
/** Client-side loader function name */
|
|
31
|
-
clientLoader?: string;
|
|
32
|
-
/** Fallback component function name */
|
|
33
|
-
fallback?: string;
|
|
219
|
+
interface ClientWindowDragEnteredEvent extends WithBaseEvent, WithComponentType {
|
|
220
|
+
eventType: 'ClientWindowDragEntered';
|
|
34
221
|
}
|
|
35
222
|
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
223
|
+
* Emits when dragging from the host moves over the client window.
|
|
224
|
+
* @target client
|
|
225
|
+
* @group Events
|
|
38
226
|
*/
|
|
39
|
-
interface
|
|
40
|
-
|
|
41
|
-
default: TFrameworkComponent;
|
|
42
|
-
/** Optional fallback component for Suspense boundaries */
|
|
43
|
-
fallback?: TFrameworkComponent;
|
|
44
|
-
/** Any additional exports (loaders, etc.) */
|
|
45
|
-
[key: string]: unknown;
|
|
227
|
+
interface ClientWindowDragMovedEvent extends WithBaseEvent, WithClientVector, WithComponentType {
|
|
228
|
+
eventType: 'ClientWindowDragMoved';
|
|
46
229
|
}
|
|
47
230
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
231
|
+
* Emits when dragging from the host exits the client window.
|
|
232
|
+
* @target client
|
|
233
|
+
* @group Events
|
|
50
234
|
*/
|
|
51
|
-
interface
|
|
52
|
-
|
|
53
|
-
id?: string;
|
|
54
|
-
/** Component name for display */
|
|
55
|
-
name?: string;
|
|
56
|
-
/** Component group/category */
|
|
57
|
-
group?: string;
|
|
58
|
-
/** Component description */
|
|
59
|
-
description?: string;
|
|
60
|
-
/** Additional framework-specific metadata */
|
|
61
|
-
[key: string]: any;
|
|
235
|
+
interface ClientWindowDragExitedEvent extends WithBaseEvent, WithComponentType {
|
|
236
|
+
eventType: 'ClientWindowDragExited';
|
|
62
237
|
}
|
|
63
238
|
/**
|
|
64
|
-
*
|
|
65
|
-
*
|
|
239
|
+
* Emits when dragging from the host is released over the client window.
|
|
240
|
+
* @target client
|
|
241
|
+
* @group Events
|
|
66
242
|
*/
|
|
67
|
-
interface
|
|
68
|
-
|
|
69
|
-
id: ComponentId;
|
|
70
|
-
/** Eagerly loaded component (if registered directly) */
|
|
71
|
-
raw: TFrameworkComponent | null;
|
|
72
|
-
/** Lazily loaded component (if discovered via dynamic import) */
|
|
73
|
-
lazy?: TFrameworkComponent;
|
|
74
|
-
/** Dynamic importer function */
|
|
75
|
-
import?: () => Promise<ComponentModule<TProps, TFrameworkComponent>>;
|
|
76
|
-
/** Fallback component for loading states */
|
|
77
|
-
fallback?: TFrameworkComponent;
|
|
78
|
-
/** Loader function names for external invocation */
|
|
79
|
-
loaderNames?: LoaderNames;
|
|
243
|
+
interface ClientWindowDragDroppedEvent extends WithBaseEvent, WithComponentType {
|
|
244
|
+
eventType: 'ClientWindowDragDropped';
|
|
80
245
|
}
|
|
81
246
|
/**
|
|
82
|
-
*
|
|
83
|
-
*
|
|
247
|
+
* Emits when a component's properties change.
|
|
248
|
+
* @target client
|
|
249
|
+
* @group Events
|
|
84
250
|
*/
|
|
85
|
-
interface
|
|
251
|
+
interface ComponentPropertiesChangedEvent<TProps extends Record<string, unknown> = Record<string, unknown>> extends WithBaseEvent, WithComponentId {
|
|
252
|
+
eventType: 'ComponentPropertiesChanged';
|
|
86
253
|
/**
|
|
87
|
-
*
|
|
254
|
+
* The new properties of the component.
|
|
88
255
|
*/
|
|
89
|
-
|
|
90
|
-
|
|
256
|
+
properties: TProps;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Emits when a component is focused.
|
|
260
|
+
* @target client
|
|
261
|
+
* @group Events
|
|
262
|
+
*/
|
|
263
|
+
interface ComponentFocusedEvent extends WithBaseEvent, WithComponentId {
|
|
264
|
+
eventType: 'ComponentFocused';
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Event emitted from the host to the client when a key is pressed.
|
|
268
|
+
* Used to forward keypress events from the host environment to the client.
|
|
269
|
+
*
|
|
270
|
+
* @template TKey - The type of key being forwarded.
|
|
271
|
+
* @target client
|
|
272
|
+
* @group Events
|
|
273
|
+
*/
|
|
274
|
+
interface HostKeyPressedEvent<TKey extends string = DefaultForwardedKeys> extends WithBaseEvent {
|
|
275
|
+
eventType: 'HostKeyPressed';
|
|
276
|
+
key: TKey;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Emits when the page settings are modified within the host.
|
|
280
|
+
* @target client
|
|
281
|
+
* @group Events
|
|
282
|
+
*/
|
|
283
|
+
interface PageSettingsChangedEvent<TSettings extends Record<string, unknown> = Record<string, unknown>> extends WithBaseEvent {
|
|
284
|
+
eventType: 'PageSettingsChanged';
|
|
285
|
+
settings: TSettings;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Emits when the media is changed on the host.
|
|
289
|
+
* Media would include images, videos, style sheets, etc.
|
|
290
|
+
* @target client
|
|
291
|
+
* @group Events
|
|
292
|
+
*/
|
|
293
|
+
interface MediaChangedEvent extends WithBaseEvent {
|
|
294
|
+
eventType: 'MediaChanged';
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Emits when the clients window is scrolled.
|
|
298
|
+
* @target host
|
|
299
|
+
* @group Events
|
|
300
|
+
*/
|
|
301
|
+
interface WindowScrollChangedEvent extends WithBaseEvent {
|
|
302
|
+
eventType: 'WindowScrollChanged';
|
|
303
|
+
/**
|
|
304
|
+
* The horizontal scroll position of the window.
|
|
305
|
+
*/
|
|
306
|
+
scrollX?: number;
|
|
307
|
+
/**
|
|
308
|
+
* The vertical scroll position of the window.
|
|
309
|
+
*/
|
|
310
|
+
scrollY?: number;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Emits when a component is moved to a different region of a component.
|
|
314
|
+
* @target isomorphic
|
|
315
|
+
* @group Events
|
|
316
|
+
*/
|
|
317
|
+
interface ComponentMovedToRegionEvent extends WithBaseEvent, WithComponentId {
|
|
318
|
+
eventType: 'ComponentMovedToRegion';
|
|
319
|
+
/**
|
|
320
|
+
* The id of the component that comes before the insert component.
|
|
321
|
+
*/
|
|
322
|
+
beforeComponentId?: string;
|
|
323
|
+
/**
|
|
324
|
+
* The id of the component that comes afterthe insert component.
|
|
325
|
+
*/
|
|
326
|
+
afterComponentId?: string;
|
|
327
|
+
/**
|
|
328
|
+
* The id of the component this component should be inserted before or after.
|
|
329
|
+
* If not provided, then it is up to the host to determine where in the target region this is inserted.
|
|
330
|
+
*/
|
|
331
|
+
insertComponentId?: string;
|
|
332
|
+
/**
|
|
333
|
+
* When an insertComponentId is provided, this will insert the new component before or after the component with that component id.
|
|
334
|
+
*/
|
|
335
|
+
insertType?: 'before' | 'after';
|
|
336
|
+
/**
|
|
337
|
+
* The id of the component that owns the region this component is being moved to.
|
|
338
|
+
*/
|
|
339
|
+
targetComponentId: string;
|
|
340
|
+
/**
|
|
341
|
+
* The id of the region that the component is being moved to.
|
|
342
|
+
*/
|
|
343
|
+
targetRegionId: string;
|
|
344
|
+
/**
|
|
345
|
+
* The region that the component is being moved from.
|
|
346
|
+
*/
|
|
347
|
+
sourceRegionId: string;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Emits when a component is hovered over.
|
|
351
|
+
* @target isomorphic
|
|
352
|
+
* @group Events
|
|
353
|
+
*/
|
|
354
|
+
interface ComponentHoveredInEvent extends WithBaseEvent, WithComponentId {
|
|
355
|
+
eventType: 'ComponentHoveredIn';
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Emits when a component is hovered out of.
|
|
359
|
+
* @target isomorphic
|
|
360
|
+
* @group Events
|
|
361
|
+
*/
|
|
362
|
+
interface ComponentHoveredOutEvent extends WithBaseEvent, WithComponentId {
|
|
363
|
+
eventType: 'ComponentHoveredOut';
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Emits when a component is selected.
|
|
367
|
+
* @target isomorphic
|
|
368
|
+
* @group Events
|
|
369
|
+
*/
|
|
370
|
+
interface ComponentSelectedEvent extends WithBaseEvent, WithComponentId {
|
|
371
|
+
eventType: 'ComponentSelected';
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Emits when a component is deselected.
|
|
375
|
+
* @target isomorphic
|
|
376
|
+
* @group Events
|
|
377
|
+
*/
|
|
378
|
+
interface ComponentDeselectedEvent extends WithBaseEvent, WithComponentId {
|
|
379
|
+
eventType: 'ComponentDeselected';
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* Emits when a component is deleted.
|
|
383
|
+
* @target isomorphic
|
|
384
|
+
* @group Events
|
|
385
|
+
*/
|
|
386
|
+
interface ComponentDeletedEvent extends WithBaseEvent, WithComponentId {
|
|
387
|
+
eventType: 'ComponentDeleted';
|
|
388
|
+
/**
|
|
389
|
+
* The id of the component that the component was deleted from.
|
|
390
|
+
*/
|
|
391
|
+
sourceComponentId: string;
|
|
91
392
|
/**
|
|
92
|
-
*
|
|
93
|
-
* Each framework adapter implements its own decoration logic.
|
|
393
|
+
* The region that the component was deleted from.
|
|
94
394
|
*/
|
|
95
|
-
|
|
395
|
+
sourceRegionId: string;
|
|
96
396
|
}
|
|
97
397
|
/**
|
|
98
|
-
*
|
|
99
|
-
*
|
|
398
|
+
* Emits when a component is added to a region of a component.
|
|
399
|
+
* @template TProps - The type of the component properties.
|
|
400
|
+
* @target isomorphic
|
|
401
|
+
* @group Events
|
|
100
402
|
*/
|
|
101
|
-
interface
|
|
403
|
+
interface ComponentAddedToRegionEvent<TProps extends Record<string, unknown> = Record<string, unknown>> extends WithBaseEvent {
|
|
404
|
+
eventType: 'ComponentAddedToRegion';
|
|
405
|
+
/**
|
|
406
|
+
* The specifier of the component to add.
|
|
407
|
+
* This will be used to lookup the component in the registry.
|
|
408
|
+
*/
|
|
409
|
+
componentType: string;
|
|
102
410
|
/**
|
|
103
|
-
*
|
|
104
|
-
*
|
|
411
|
+
* The properties of the component to add.
|
|
412
|
+
* These will be used to initialize the component.
|
|
105
413
|
*/
|
|
106
|
-
|
|
414
|
+
componentProperties: TProps;
|
|
415
|
+
/**
|
|
416
|
+
* The id of the component that owns the region this component is being added to.
|
|
417
|
+
*/
|
|
418
|
+
targetComponentId: string;
|
|
419
|
+
/**
|
|
420
|
+
* The id of the region that the component is being added to.
|
|
421
|
+
*/
|
|
422
|
+
targetRegionId: string;
|
|
423
|
+
/**
|
|
424
|
+
* When an insertComponentId is provided, this will insert the new component before or after the component with that component id.
|
|
425
|
+
*/
|
|
426
|
+
insertType?: 'before' | 'after';
|
|
427
|
+
/**
|
|
428
|
+
* The id of the component this component should be inserted before or after.
|
|
429
|
+
* If not provided, then it is up to the host to determine where in the target region this is inserted.
|
|
430
|
+
*/
|
|
431
|
+
insertComponentId?: string;
|
|
432
|
+
/**
|
|
433
|
+
* The id of the component that comes before the insert component.
|
|
434
|
+
*/
|
|
435
|
+
beforeComponentId?: string;
|
|
436
|
+
/**
|
|
437
|
+
* The id of the component that comes afterthe insert component.
|
|
438
|
+
*/
|
|
439
|
+
afterComponentId?: string;
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Emits when a component drag starts from the host or client.
|
|
443
|
+
* @target isomorphic
|
|
444
|
+
* @group Events
|
|
445
|
+
*/
|
|
446
|
+
interface ComponentDragStartedEvent extends WithBaseEvent {
|
|
447
|
+
eventType: 'ComponentDragStarted';
|
|
448
|
+
/**
|
|
449
|
+
* The type of the component that is being dragged.
|
|
450
|
+
*/
|
|
451
|
+
componentType: string;
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* Emits when an error occurs.
|
|
455
|
+
* @target isomorphic
|
|
456
|
+
* @group Events
|
|
457
|
+
*/
|
|
458
|
+
interface ErrorEvent extends WithBaseEvent {
|
|
459
|
+
eventType: 'Error';
|
|
460
|
+
/**
|
|
461
|
+
* The error message.
|
|
462
|
+
*/
|
|
463
|
+
message: string;
|
|
464
|
+
/**
|
|
465
|
+
* TODO: Add error codes if we need the app to recover from the error.
|
|
466
|
+
* Add once scenarios are defined.
|
|
467
|
+
*/
|
|
468
|
+
code?: unknown;
|
|
107
469
|
}
|
|
108
470
|
//#endregion
|
|
109
|
-
//#region src/design/
|
|
471
|
+
//#region src/design/messaging-api/api-types.d.ts
|
|
472
|
+
type Source = 'host' | 'client';
|
|
110
473
|
/**
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
474
|
+
* A type that adds metadata to an event.
|
|
475
|
+
* @inline
|
|
476
|
+
* @expand
|
|
477
|
+
* @hidden
|
|
478
|
+
*/
|
|
479
|
+
interface WithMeta {
|
|
480
|
+
/**
|
|
481
|
+
* Metadata attached to an event.
|
|
482
|
+
*/
|
|
483
|
+
meta: {
|
|
484
|
+
/**
|
|
485
|
+
* Indicates that the event is part of the messaging api.
|
|
486
|
+
* Primarily used to distinguish messages events from other services.
|
|
487
|
+
*/
|
|
488
|
+
pdMessagingApi: true;
|
|
489
|
+
/**
|
|
490
|
+
* The source of the event.
|
|
491
|
+
* Since some events are bidirectional, we need to know which side the event is coming from.
|
|
492
|
+
*/
|
|
493
|
+
source: Source;
|
|
494
|
+
/**
|
|
495
|
+
* The id of the connected client.
|
|
496
|
+
*/
|
|
497
|
+
clientId?: string;
|
|
498
|
+
/**
|
|
499
|
+
* The id of the connected host.
|
|
500
|
+
*/
|
|
501
|
+
hostId?: string;
|
|
502
|
+
};
|
|
503
|
+
}
|
|
504
|
+
type EventPayload<TEvent> = Omit<TEvent, 'eventType' | 'meta'>;
|
|
505
|
+
/**
|
|
506
|
+
* The mapping of events, emitted on the host and client, to their corresponding event and API name.
|
|
507
|
+
* @hidden
|
|
508
|
+
*/
|
|
509
|
+
interface IsomorphicEventNameMapping {
|
|
510
|
+
ComponentDragStarted: ComponentDragStartedEvent;
|
|
511
|
+
ComponentHoveredIn: ComponentHoveredInEvent;
|
|
512
|
+
ComponentHoveredOut: ComponentHoveredOutEvent;
|
|
513
|
+
ComponentSelected: ComponentSelectedEvent;
|
|
514
|
+
ComponentDeselected: ComponentDeselectedEvent;
|
|
515
|
+
ComponentAddedToRegion: ComponentAddedToRegionEvent;
|
|
516
|
+
ComponentDeleted: ComponentDeletedEvent;
|
|
517
|
+
ComponentMovedToRegion: ComponentMovedToRegionEvent;
|
|
518
|
+
WindowScrollChanged: WindowScrollChangedEvent;
|
|
519
|
+
Error: ErrorEvent;
|
|
520
|
+
}
|
|
521
|
+
/**
|
|
522
|
+
* The mapping of host events, emitted on the host, to their corresponding event and API name.
|
|
523
|
+
* @hidden
|
|
524
|
+
*/
|
|
525
|
+
interface HostEventNameMapping extends IsomorphicEventNameMapping {
|
|
526
|
+
ClientInitialized: ClientInitializedEvent;
|
|
527
|
+
ClientReady: ClientReady;
|
|
528
|
+
ClientDisconnected: ClientDisconnectedEvent;
|
|
529
|
+
ClientPageChanged: ClientPageChangedEvent;
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* The mapping of client events to their corresponding event.
|
|
533
|
+
* @hidden
|
|
534
|
+
*/
|
|
535
|
+
interface ClientEventNameMapping extends IsomorphicEventNameMapping {
|
|
536
|
+
HostDisconnected: HostDisconnected;
|
|
537
|
+
PageSettingsChanged: PageSettingsChangedEvent;
|
|
538
|
+
HostKeyPressed: HostKeyPressedEvent;
|
|
539
|
+
ClientAcknowledged: ClientAcknowledgedEvent;
|
|
540
|
+
ClientConfigurationChanged: ClientConfigurationChangedEvent;
|
|
541
|
+
ClientWindowDragEntered: ClientWindowDragEnteredEvent;
|
|
542
|
+
ClientWindowDragMoved: ClientWindowDragMovedEvent;
|
|
543
|
+
ClientWindowDragExited: ClientWindowDragExitedEvent;
|
|
544
|
+
ClientWindowDragDropped: ClientWindowDragDroppedEvent;
|
|
545
|
+
ComponentPropertiesChanged: ComponentPropertiesChangedEvent;
|
|
546
|
+
MediaChangedEvent: MediaChangedEvent;
|
|
547
|
+
ComponentFocused: ComponentFocusedEvent;
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* @hidden
|
|
551
|
+
*/
|
|
552
|
+
type ClientMessage = ClientEventNameMapping[keyof ClientEventNameMapping];
|
|
553
|
+
/**
|
|
554
|
+
* @hidden
|
|
555
|
+
*/
|
|
556
|
+
type HostMessage = HostEventNameMapping[keyof HostEventNameMapping];
|
|
557
|
+
/**
|
|
558
|
+
* @hidden
|
|
559
|
+
*/
|
|
560
|
+
type EventTypeName = keyof HostEventNameMapping | keyof ClientEventNameMapping;
|
|
561
|
+
/**
|
|
562
|
+
* @inline
|
|
563
|
+
* @expand
|
|
564
|
+
* @hidden
|
|
565
|
+
*/
|
|
566
|
+
type WithEventType<TMapping, TEvent extends keyof TMapping = keyof TMapping> = {
|
|
567
|
+
/**
|
|
568
|
+
* The event type of the event.
|
|
569
|
+
*/
|
|
570
|
+
eventType: TEvent;
|
|
571
|
+
};
|
|
572
|
+
/**
|
|
573
|
+
* The type of a handler for an event.
|
|
129
574
|
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
575
|
+
* @template TMapping - The mapping of event names to their payload types.
|
|
576
|
+
* @template TEvent - The type of the event.
|
|
577
|
+
* @template TPartial - Whether the event is partial.
|
|
578
|
+
*/
|
|
579
|
+
type EventHandler<TMapping, TEvent extends keyof TMapping = keyof TMapping, TPartial = false> = (event: TPartial extends true ? Readonly<Partial<WithMeta & WithEventType<TMapping, TEvent> & TMapping[TEvent]>> : Readonly<WithMeta & WithEventType<TMapping, TEvent> & TMapping[TEvent]>) => unknown;
|
|
580
|
+
/**
|
|
581
|
+
* An emitter that will perform the underlying communication with the client or host.
|
|
582
|
+
*/
|
|
583
|
+
interface MessageEmitter<TInMapping, TOutMapping> {
|
|
584
|
+
/**
|
|
585
|
+
* Sends a message to the other side of the connection.
|
|
586
|
+
* @param message - The message to send.
|
|
587
|
+
*/
|
|
588
|
+
postMessage(message: WithMeta & WithEventType<TOutMapping>): void;
|
|
589
|
+
/**
|
|
590
|
+
* Provides a handler for incoming messages.
|
|
591
|
+
* The provided handler will determine if the message is for the messaging api and direct it accordingly.
|
|
592
|
+
* @param handler
|
|
593
|
+
* @returns A function to remove the event listener.
|
|
594
|
+
*/
|
|
595
|
+
addEventListener(handler: EventHandler<TInMapping, keyof TInMapping, true>): () => void;
|
|
596
|
+
}
|
|
597
|
+
/**
|
|
598
|
+
* Configuration that applies for both host and client.
|
|
133
599
|
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
600
|
+
* @inline
|
|
601
|
+
* @expand
|
|
602
|
+
* @hidden
|
|
603
|
+
* @stability development
|
|
604
|
+
*/
|
|
605
|
+
interface IsomorphicConfiguration {
|
|
606
|
+
/**
|
|
607
|
+
* The id of the client.
|
|
608
|
+
*/
|
|
609
|
+
id: string;
|
|
610
|
+
/**
|
|
611
|
+
* A logger for logging all messages.
|
|
612
|
+
*/
|
|
613
|
+
logger?: (message: unknown, source: 'host' | 'client') => void;
|
|
614
|
+
}
|
|
615
|
+
interface ClientConfiguration extends IsomorphicConfiguration {
|
|
616
|
+
/**
|
|
617
|
+
* The underlying message emitter that will be used to send events.
|
|
618
|
+
*/
|
|
619
|
+
emitter: MessageEmitter<ClientEventNameMapping, HostEventNameMapping>;
|
|
620
|
+
/**
|
|
621
|
+
* The keys that are forwarded from the host to the client.
|
|
622
|
+
*/
|
|
623
|
+
forwardedKeys?: string[];
|
|
624
|
+
}
|
|
625
|
+
interface HostConfiguration extends IsomorphicConfiguration {
|
|
626
|
+
/**
|
|
627
|
+
* The underlying message emitter that will be used to send events.
|
|
628
|
+
*/
|
|
629
|
+
emitter: MessageEmitter<HostEventNameMapping, ClientEventNameMapping>;
|
|
630
|
+
}
|
|
631
|
+
/**
|
|
632
|
+
* @inline
|
|
633
|
+
* @hidden
|
|
634
|
+
*/
|
|
635
|
+
interface IsomorphicApi {
|
|
636
|
+
/**
|
|
637
|
+
* Starts a component drag operation.
|
|
638
|
+
* This method initiates dragging of a specific component, typically in response
|
|
639
|
+
* to user interaction or programmatic requirements.
|
|
640
|
+
*
|
|
641
|
+
* @param event - The component drag start event
|
|
642
|
+
* @param event.componentId - The ID of the component to start dragging
|
|
643
|
+
* @param event.x - The x position where the drag operation starts
|
|
644
|
+
* @param event.y - The y position where the drag operation starts
|
|
645
|
+
* @stability development
|
|
646
|
+
*
|
|
647
|
+
* @example
|
|
648
|
+
* ```typescript
|
|
649
|
+
* api.startComponentDrag({
|
|
650
|
+
* componentId: 'draggable-component',
|
|
651
|
+
* x: 100,
|
|
652
|
+
* y: 150
|
|
653
|
+
* });
|
|
654
|
+
* ```
|
|
655
|
+
*
|
|
656
|
+
* @see {Domain.ComponentDragStartedEvent}
|
|
657
|
+
*/
|
|
658
|
+
startComponentDrag(event: EventPayload<ComponentDragStartedEvent>): void;
|
|
659
|
+
/**
|
|
660
|
+
* Moves a component to a different region of a component.
|
|
661
|
+
*
|
|
662
|
+
* @param event - The component move event containing the component and region information
|
|
663
|
+
* @param event.componentId - The ID of the component to move
|
|
664
|
+
* @param event.targetComponentId - The ID of the component where the component is being moved to
|
|
665
|
+
* @param event.targetRegionId - The ID of the region that the component is being moved to
|
|
666
|
+
* @stability development
|
|
667
|
+
*
|
|
668
|
+
* @example
|
|
669
|
+
* ```typescript
|
|
670
|
+
* api.moveComponentToRegion({
|
|
671
|
+
* componentId: 'component-123',
|
|
672
|
+
* targetComponentId: 'parent-component',
|
|
673
|
+
* targetRegionId: 'content-region'
|
|
674
|
+
* sourceRegionId: 'source-content-region'
|
|
675
|
+
* sourceComponentId: 'source-component'
|
|
676
|
+
* });
|
|
677
|
+
* ```
|
|
678
|
+
* @see {Domain.ComponentMovedToRegionEvent}
|
|
679
|
+
*/
|
|
680
|
+
moveComponentToRegion(event: EventPayload<ComponentMovedToRegionEvent>): void;
|
|
681
|
+
/**
|
|
682
|
+
* Notifies the host that a component is being hovered over.
|
|
683
|
+
*
|
|
684
|
+
* @param event - The component hover event containing the component ID
|
|
685
|
+
* @param event.componentId - The ID of the component being hovered over
|
|
686
|
+
* @stability development
|
|
687
|
+
*
|
|
688
|
+
* @example
|
|
689
|
+
* ```typescript
|
|
690
|
+
* api.hoverInToComponent({
|
|
691
|
+
* componentId: 'component-123'
|
|
692
|
+
* });
|
|
693
|
+
* ```
|
|
694
|
+
*/
|
|
695
|
+
hoverInToComponent(event: EventPayload<ComponentHoveredInEvent>): void;
|
|
696
|
+
/**
|
|
697
|
+
* Notifies the host that a component is no longer being hovered over.
|
|
698
|
+
*
|
|
699
|
+
* @param event - The component hover exit event containing the component ID
|
|
700
|
+
* @param event.componentId - The ID of the component that was hovered over
|
|
701
|
+
* @stability development
|
|
702
|
+
*
|
|
703
|
+
* @example
|
|
704
|
+
* ```typescript
|
|
705
|
+
* api.hoverOutOfComponent({
|
|
706
|
+
* componentId: 'component-123'
|
|
707
|
+
* });
|
|
708
|
+
* ```
|
|
709
|
+
*/
|
|
710
|
+
hoverOutOfComponent(event: EventPayload<ComponentHoveredOutEvent>): void;
|
|
711
|
+
/**
|
|
712
|
+
* Notifies the host that a component has been selected.
|
|
713
|
+
*
|
|
714
|
+
* @param event - The component selection event containing the component ID
|
|
715
|
+
* @param event.componentId - The ID of the component that was selected
|
|
716
|
+
* @stability development
|
|
717
|
+
*
|
|
718
|
+
* @example
|
|
719
|
+
* ```typescript
|
|
720
|
+
* api.selectComponent({
|
|
721
|
+
* componentId: 'component-123'
|
|
722
|
+
* });
|
|
723
|
+
* ```
|
|
724
|
+
*/
|
|
725
|
+
selectComponent(event: EventPayload<ComponentSelectedEvent>): void;
|
|
726
|
+
/**
|
|
727
|
+
* Notifies the host that a component has been deselected.
|
|
728
|
+
*
|
|
729
|
+
* @param event - The component deselection event containing the component ID
|
|
730
|
+
* @param event.componentId - The ID of the component that was deselected
|
|
731
|
+
* @stability development
|
|
732
|
+
*
|
|
733
|
+
* @example
|
|
734
|
+
* ```typescript
|
|
735
|
+
* api.deselectComponent({
|
|
736
|
+
* componentId: 'component-123'
|
|
737
|
+
* });
|
|
738
|
+
* ```
|
|
739
|
+
*/
|
|
740
|
+
deselectComponent(event: EventPayload<ComponentDeselectedEvent>): void;
|
|
741
|
+
/**
|
|
742
|
+
* Notifies the host that a component has been added to a specific region of another component.
|
|
743
|
+
*
|
|
744
|
+
* @param event - The component addition event containing component and region information
|
|
745
|
+
* @param event.targetComponentId - The ID of the component that owns the region
|
|
746
|
+
* @param event.targetRegionId - The ID of the region where the component is being added
|
|
747
|
+
* @param event.sourceComponentId - The ID of the component being added to the region
|
|
748
|
+
* @stability development
|
|
749
|
+
*
|
|
750
|
+
* @example
|
|
751
|
+
* ```typescript
|
|
752
|
+
* api.addComponentToRegion({
|
|
753
|
+
* targetComponentId: 'parent-component',
|
|
754
|
+
* targetRegionId: 'content-region',
|
|
755
|
+
* componentId: 'child-component'
|
|
756
|
+
* });
|
|
757
|
+
* ```
|
|
758
|
+
*/
|
|
759
|
+
addComponentToRegion(event: EventPayload<ComponentAddedToRegionEvent>): void;
|
|
760
|
+
/**
|
|
761
|
+
* Notifies the host that a component has been deleted.
|
|
762
|
+
*
|
|
763
|
+
* @param event - The component deletion event containing the component ID
|
|
764
|
+
* @param event.componentId - The ID of the component that was deleted
|
|
765
|
+
* @param event.sourceComponentId - The ID of the component that the component was deleted from
|
|
766
|
+
* @param event.sourceRegionId - The ID of the region that the component was deleted from
|
|
767
|
+
* @stability development
|
|
768
|
+
*
|
|
769
|
+
* @example
|
|
770
|
+
* ```typescript
|
|
771
|
+
* api.deleteComponent({
|
|
772
|
+
* componentId: 'component-123',
|
|
773
|
+
* sourceComponentId: 'parent-component',
|
|
774
|
+
* sourceRegionId: 'content-region'
|
|
775
|
+
* });
|
|
776
|
+
* ```
|
|
777
|
+
*/
|
|
778
|
+
deleteComponent(event: EventPayload<ComponentDeletedEvent>): void;
|
|
779
|
+
/**
|
|
780
|
+
* Notifies that an error has occurred.
|
|
781
|
+
*
|
|
782
|
+
* @param event - The error event containing the error message and stack trace
|
|
783
|
+
* @param event.message - The error message
|
|
784
|
+
* @param event.stack - The stack trace of the error
|
|
785
|
+
* @stability development
|
|
786
|
+
*
|
|
787
|
+
* @example
|
|
788
|
+
* ```typescript
|
|
789
|
+
* api.notifyError({
|
|
790
|
+
* message: 'An error occurred',
|
|
791
|
+
* stack: 'Error: An error occurred\n at ...'
|
|
792
|
+
* });
|
|
793
|
+
* ```
|
|
794
|
+
*/
|
|
795
|
+
notifyError(event: EventPayload<ErrorEvent>): void;
|
|
796
|
+
/**
|
|
797
|
+
* Notifies the host that the client window scroll position has changed.
|
|
798
|
+
*
|
|
799
|
+
* @param event - The window scroll change event containing the new scroll positions
|
|
800
|
+
* @param event.scrollX - The horizontal scroll position of the window
|
|
801
|
+
* @param event.scrollY - The vertical scroll position of the window
|
|
802
|
+
* @stability development
|
|
803
|
+
*
|
|
804
|
+
* @example
|
|
805
|
+
* ```typescript
|
|
806
|
+
* api.notifyWindowScrollChanged({
|
|
807
|
+
* scrollX: 100,
|
|
808
|
+
* scrollY: 200
|
|
809
|
+
* });
|
|
810
|
+
* ```
|
|
811
|
+
*/
|
|
812
|
+
notifyWindowScrollChanged(event: Partial<EventPayload<WindowScrollChangedEvent>>): void;
|
|
813
|
+
/**
|
|
814
|
+
* Gets the id of the remote side of the connection.
|
|
815
|
+
* @returns The id of the remote side of the connection.
|
|
816
|
+
*/
|
|
817
|
+
getRemoteId(): string | undefined;
|
|
818
|
+
}
|
|
819
|
+
interface ClientApi extends IsomorphicApi {
|
|
820
|
+
/**
|
|
821
|
+
* Disconnects the client from the host.
|
|
822
|
+
* @param options - Optional configuration for the disconnection process
|
|
823
|
+
* @param options.isReconnecting - Whether the client is attempting to reconnect to the host.
|
|
824
|
+
*/
|
|
825
|
+
disconnect(options?: {
|
|
826
|
+
isReconnecting?: boolean;
|
|
827
|
+
}): void;
|
|
828
|
+
/**
|
|
829
|
+
* Connects the client or host to the messaging api.
|
|
830
|
+
* This should be called when the client or host is initialized.
|
|
831
|
+
* This will start listening for events from the other side.
|
|
832
|
+
*
|
|
833
|
+
* @param options - Optional configuration for the connection process
|
|
834
|
+
* @param options.interval - Optional interval in milliseconds for retrying initialization
|
|
835
|
+
* @param options.timeout - Optional timeout in milliseconds for the connection process
|
|
836
|
+
* @param options.prepareClient - Optional function to prepare the client for the connection process
|
|
837
|
+
* @returns The client acknowledged event
|
|
838
|
+
* @stability development
|
|
839
|
+
*
|
|
840
|
+
* @example
|
|
841
|
+
* ```typescript
|
|
842
|
+
* await api.connect({ interval: 1_000 });
|
|
843
|
+
* // Connected to host.
|
|
844
|
+
*
|
|
845
|
+
* // With prepare logic
|
|
846
|
+
* await api.connect({ prepareClient: async () => await doSomethingAsync() });
|
|
847
|
+
* ```
|
|
848
|
+
*/
|
|
849
|
+
connect(options?: {
|
|
850
|
+
interval?: number;
|
|
851
|
+
prepareClient?: () => Promise<void>;
|
|
852
|
+
timeout?: number;
|
|
853
|
+
onHostConnected?: (event: HostToClientConfiguration) => void;
|
|
854
|
+
onHostDisconnected?: (reconnect: () => void) => void;
|
|
855
|
+
onError?: (error: Error) => void;
|
|
856
|
+
usid?: string;
|
|
857
|
+
}): void;
|
|
858
|
+
/**
|
|
859
|
+
* Notifies the host that the client is ready.
|
|
860
|
+
*
|
|
861
|
+
* @param event - The client ready event
|
|
862
|
+
* @stability development
|
|
863
|
+
*
|
|
864
|
+
* @example
|
|
865
|
+
* ```typescript
|
|
866
|
+
* api.notifyClientReady({});
|
|
867
|
+
* ```
|
|
868
|
+
*
|
|
869
|
+
* @see {Domain.ClientReady}
|
|
870
|
+
*/
|
|
871
|
+
notifyClientReady(event: EventPayload<ClientReady>): void;
|
|
872
|
+
/**
|
|
873
|
+
* Notifies the host that the client components have changed.
|
|
874
|
+
*
|
|
875
|
+
* @param event - The client components change event containing the new components
|
|
876
|
+
* @stability development
|
|
877
|
+
*
|
|
878
|
+
* @example
|
|
879
|
+
* ```typescript
|
|
880
|
+
* api.notifyClientComponentsChanged({ components: { ... }});
|
|
881
|
+
* ```
|
|
882
|
+
*/
|
|
883
|
+
notifyClientPageChanged(event: EventPayload<ClientPageChangedEvent>): void;
|
|
884
|
+
/**
|
|
885
|
+
* Registers an event handler for client-side events.
|
|
886
|
+
*
|
|
887
|
+
* @template TEvent - The type of client event to listen for
|
|
888
|
+
* @param event - The name of the event to listen for
|
|
889
|
+
* @param handler - The callback function that will be invoked when the event occurs
|
|
890
|
+
* @returns A function to remove the event listener.
|
|
891
|
+
* @stability development
|
|
892
|
+
*
|
|
893
|
+
* @example
|
|
894
|
+
* ```typescript
|
|
895
|
+
* api.on('ComponentSelected', (event) => {
|
|
896
|
+
* console.log('Component selected:', event.componentId);
|
|
897
|
+
* });
|
|
898
|
+
* ```
|
|
899
|
+
*/
|
|
900
|
+
on<TEvent extends keyof ClientEventNameMapping>(event: TEvent, handler: (handlerEvent: Readonly<WithMeta & ClientEventNameMapping[TEvent]>) => void): () => void;
|
|
901
|
+
on(event: 'Event', handler: (handlerEvent: Readonly<WithMeta & ClientMessage>) => void): () => void;
|
|
902
|
+
}
|
|
903
|
+
/**
|
|
904
|
+
* A function that returns a promise that resolves to the client acknowledged event.
|
|
905
|
+
* This is used to configure the client when it is initialized.
|
|
137
906
|
*/
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
907
|
+
type ConfigFactory = () => Promise<EventPayload<ClientAcknowledgedEvent>>;
|
|
908
|
+
interface HostApi extends IsomorphicApi {
|
|
909
|
+
/**
|
|
910
|
+
* Disconnects the host instance.
|
|
911
|
+
* This will remove all event listeners and clean up any resources.
|
|
912
|
+
*
|
|
913
|
+
* @stability development
|
|
914
|
+
*
|
|
915
|
+
* @example
|
|
916
|
+
* ```typescript
|
|
917
|
+
* api.disconnect();
|
|
918
|
+
* ```
|
|
919
|
+
*/
|
|
920
|
+
disconnect(): void;
|
|
921
|
+
/**
|
|
922
|
+
* Connects the client or host to the messaging api.
|
|
923
|
+
* This should be called when the client or host is initialized.
|
|
924
|
+
*
|
|
925
|
+
* @param params - The parameters for the connection process
|
|
926
|
+
* @param params.configFactory - A function for providing configuration to the client.
|
|
927
|
+
* This can be async if configuration needs to be fetched.
|
|
928
|
+
* @returns The boolean value that indicates if the connection process was successful
|
|
929
|
+
*
|
|
930
|
+
* @stability development
|
|
931
|
+
*
|
|
932
|
+
* @example
|
|
933
|
+
* ```typescript
|
|
934
|
+
* api.connect();
|
|
935
|
+
* // Start listening for client events.
|
|
936
|
+
* ```
|
|
937
|
+
*/
|
|
938
|
+
connect(params: {
|
|
939
|
+
configFactory: ConfigFactory;
|
|
940
|
+
onClientConnected?: (clientId: string) => void;
|
|
941
|
+
onClientDisconnected?: (clientId: string) => void;
|
|
942
|
+
onError?: (error: Error) => void;
|
|
943
|
+
}): void;
|
|
146
944
|
/**
|
|
147
|
-
* Registers
|
|
148
|
-
*
|
|
945
|
+
* Registers an event handler for host-side events.
|
|
946
|
+
*
|
|
947
|
+
* @template TEvent - The type of host event to listen for
|
|
948
|
+
* @param event - The name of the event to listen for
|
|
949
|
+
* @param handler - The callback function that will be invoked when the event occurs
|
|
950
|
+
* @returns A function to remove the event listener.
|
|
951
|
+
* @stability development
|
|
952
|
+
*
|
|
953
|
+
* @example
|
|
954
|
+
* ```typescript
|
|
955
|
+
* api.on('ComponentSelected', (event) => {
|
|
956
|
+
* console.log('Component selection changed:', event.componentId);
|
|
957
|
+
* });
|
|
958
|
+
* ```
|
|
149
959
|
*/
|
|
150
|
-
|
|
960
|
+
on<TEvent extends keyof HostEventNameMapping>(event: TEvent, handler: (handlerEvent: Readonly<WithMeta & HostEventNameMapping[TEvent]>) => void): () => void;
|
|
961
|
+
on(event: 'Event', handler: (handlerEvent: Readonly<WithMeta & HostMessage>) => void): () => void;
|
|
151
962
|
/**
|
|
152
|
-
*
|
|
963
|
+
* Notifies the host that the page settings have changed.
|
|
964
|
+
* This method allows the host to control the scroll position of connected clients.
|
|
965
|
+
*
|
|
966
|
+
* @param event - The page settings change event
|
|
967
|
+
* @stability development
|
|
968
|
+
*
|
|
969
|
+
* @example
|
|
970
|
+
* ```typescript
|
|
971
|
+
* api.notifyPageSettingsChanged({ settings: { ... }});
|
|
972
|
+
* ```
|
|
973
|
+
*
|
|
974
|
+
* @see {Domain.PageSettingsChangedEvent}
|
|
153
975
|
*/
|
|
154
|
-
|
|
976
|
+
notifyPageSettingsChanged(event: EventPayload<PageSettingsChangedEvent>): void;
|
|
155
977
|
/**
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
978
|
+
* Forwards a key press event from the host environment to the client.
|
|
979
|
+
* This allows the client to respond to keyboard input that occurs in the host context.
|
|
980
|
+
*
|
|
981
|
+
* @param event - The key press event containing the pressed key
|
|
982
|
+
* @param event.key - The key that was pressed (must be one of the forwarded keys)
|
|
983
|
+
* @stability development
|
|
984
|
+
*
|
|
985
|
+
* @example
|
|
986
|
+
* ```typescript
|
|
987
|
+
* // Forward arrow key navigation
|
|
988
|
+
* api.forwardKeyPress({ key: 'ArrowUp' });
|
|
989
|
+
* api.forwardKeyPress({ key: 'ArrowDown' });
|
|
990
|
+
*
|
|
991
|
+
* // Forward delete key
|
|
992
|
+
* api.forwardKeyPress({ key: 'Delete' });
|
|
993
|
+
* ```
|
|
994
|
+
*
|
|
995
|
+
* @see {Domain.HostKeyPressedEvent}
|
|
996
|
+
* @see {Domain.DefaultForwardedKeys}
|
|
160
997
|
*/
|
|
161
|
-
|
|
998
|
+
forwardKeyPress(event: EventPayload<HostKeyPressedEvent>): void;
|
|
162
999
|
/**
|
|
163
|
-
*
|
|
1000
|
+
* Notifies the host that a client window drag operation has entered a component.
|
|
1001
|
+
* This event is triggered when a drag operation starts over a component in the client window.
|
|
1002
|
+
*
|
|
1003
|
+
* @param event - The drag enter event containing component and position information
|
|
1004
|
+
* @param event.componentId - The ID of the component being dragged over
|
|
1005
|
+
* @param event.x - The x position of the drag event relative to the window
|
|
1006
|
+
* @param event.y - The y position of the drag event relative to the window
|
|
1007
|
+
* @stability development
|
|
164
1008
|
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
1009
|
+
* @example
|
|
1010
|
+
* ```typescript
|
|
1011
|
+
* api.notifyClientWindowDragEntered({
|
|
1012
|
+
* componentId: 'drop-zone-component',
|
|
1013
|
+
* x: 150,
|
|
1014
|
+
* y: 200
|
|
1015
|
+
* });
|
|
1016
|
+
* ```
|
|
168
1017
|
*
|
|
169
|
-
* @
|
|
1018
|
+
* @see {Domain.ClientWindowDragEnteredEvent}
|
|
170
1019
|
*/
|
|
171
|
-
|
|
172
|
-
/** Get loader function names for external invocation. */
|
|
173
|
-
getLoaderNames(id: ComponentId): LoaderNames | undefined;
|
|
174
|
-
hasLoaders(id: ComponentId): boolean;
|
|
1020
|
+
notifyClientWindowDragEntered(event: EventPayload<ClientWindowDragEnteredEvent>): void;
|
|
175
1021
|
/**
|
|
176
|
-
*
|
|
1022
|
+
* Notifies the host that a client window drag operation has moved over a component.
|
|
1023
|
+
* This event is triggered as the drag operation continues over a component.
|
|
1024
|
+
*
|
|
1025
|
+
* @param event - The drag move event containing component and position information
|
|
1026
|
+
* @param event.componentId - The ID of the component being dragged over
|
|
1027
|
+
* @param event.x - The current x position of the drag event relative to the window
|
|
1028
|
+
* @param event.y - The current y position of the drag event relative to the window
|
|
1029
|
+
* @stability development
|
|
1030
|
+
*
|
|
1031
|
+
* @example
|
|
1032
|
+
* ```typescript
|
|
1033
|
+
* api.notifyClientWindowDragMoved({
|
|
1034
|
+
* componentId: 'drop-zone-component',
|
|
1035
|
+
* x: 160,
|
|
1036
|
+
* y: 200
|
|
1037
|
+
* });
|
|
1038
|
+
* ```
|
|
177
1039
|
*
|
|
178
|
-
* @
|
|
179
|
-
* @param loaderArgs - Arguments to pass to the loader function
|
|
180
|
-
* @param loaderType - Type of loader to call ('loader' or 'clientLoader')
|
|
181
|
-
* @returns Promise resolving to the loader result
|
|
1040
|
+
* @see {Domain.ClientWindowDragMovedEvent}
|
|
182
1041
|
*/
|
|
183
|
-
|
|
184
|
-
/** Get fallback component if available. */
|
|
185
|
-
getFallback(id: ComponentId): TFrameworkComponent | undefined;
|
|
1042
|
+
notifyClientWindowDragMoved(event: EventPayload<ClientWindowDragMovedEvent>): void;
|
|
186
1043
|
/**
|
|
187
|
-
*
|
|
188
|
-
*
|
|
1044
|
+
* Notifies the host that a client window drag operation has exited a component.
|
|
1045
|
+
* This event is triggered when a drag operation leaves a component area.
|
|
1046
|
+
*
|
|
1047
|
+
* @param event - The drag exit event containing component and position information
|
|
1048
|
+
* @param event.componentId - The ID of the component that was being dragged over
|
|
1049
|
+
* @param event.x - The x position where the drag operation exited
|
|
1050
|
+
* @param event.y - The y position where the drag operation exited
|
|
1051
|
+
* @stability development
|
|
1052
|
+
*
|
|
1053
|
+
* @example
|
|
1054
|
+
* ```typescript
|
|
1055
|
+
* api.notifyClientWindowDragExited({
|
|
1056
|
+
* componentId: 'drop-zone-component',
|
|
1057
|
+
* x: 50,
|
|
1058
|
+
* y: 100
|
|
1059
|
+
* });
|
|
1060
|
+
* ```
|
|
1061
|
+
*
|
|
1062
|
+
* @see {Domain.ClientWindowDragExitedEvent}
|
|
189
1063
|
*/
|
|
190
|
-
|
|
1064
|
+
notifyClientWindowDragExited(event: EventPayload<ClientWindowDragExitedEvent>): void;
|
|
191
1065
|
/**
|
|
192
|
-
*
|
|
1066
|
+
* Notifies the host that a client window drag operation has been dropped on a component.
|
|
1067
|
+
* This event is triggered when a drag operation completes with a drop action.
|
|
1068
|
+
*
|
|
1069
|
+
* @param event - The drag drop event containing component and position information
|
|
1070
|
+
* @param event.componentId - The ID of the component where the drop occurred
|
|
1071
|
+
* @param event.x - The x position where the drop occurred
|
|
1072
|
+
* @param event.y - The y position where the drop occurred
|
|
1073
|
+
* @stability development
|
|
1074
|
+
*
|
|
1075
|
+
* @example
|
|
1076
|
+
* ```typescript
|
|
1077
|
+
* api.notifyClientWindowDragDropped({
|
|
1078
|
+
* componentId: 'target-component',
|
|
1079
|
+
* x: 200,
|
|
1080
|
+
* y: 150
|
|
1081
|
+
* });
|
|
1082
|
+
* ```
|
|
1083
|
+
*
|
|
1084
|
+
* @see {Domain.ClientWindowDragDroppedEvent}
|
|
1085
|
+
*/
|
|
1086
|
+
notifyClientWindowDragDropped(event: EventPayload<ClientWindowDragDroppedEvent>): void;
|
|
1087
|
+
/**
|
|
1088
|
+
* Notifies the host that media has changed or was updated.
|
|
1089
|
+
*
|
|
1090
|
+
* @param event - The media change event
|
|
1091
|
+
* @stability development
|
|
1092
|
+
*
|
|
1093
|
+
* @example
|
|
1094
|
+
* ```typescript
|
|
1095
|
+
* api.notifyMediaChanged({});
|
|
1096
|
+
* ```
|
|
1097
|
+
* @see {Domain.MediaChangedEvent}
|
|
1098
|
+
*/
|
|
1099
|
+
notifyMediaChanged(): void;
|
|
1100
|
+
/**
|
|
1101
|
+
* Sets the properties of a component.
|
|
1102
|
+
*
|
|
1103
|
+
* @param event - The component properties change event containing the component and properties
|
|
1104
|
+
* @param event.componentId - The ID of the component to set the properties of
|
|
1105
|
+
* @param event.properties - The new properties of the component
|
|
1106
|
+
* @stability development
|
|
1107
|
+
*
|
|
1108
|
+
* @example
|
|
1109
|
+
* ```typescript
|
|
1110
|
+
* api.setComponentProperties({
|
|
1111
|
+
* componentId: 'component-123',
|
|
1112
|
+
* properties: { color: 'red' }
|
|
1113
|
+
* });
|
|
1114
|
+
* ```
|
|
1115
|
+
*
|
|
1116
|
+
* @see {@link Domain.ComponentPropertiesChangedEvent}
|
|
193
1117
|
*/
|
|
194
|
-
|
|
1118
|
+
setComponentProperties<TProps extends Record<string, unknown> = Record<string, unknown>>(event: EventPayload<ComponentPropertiesChangedEvent<TProps>>): void;
|
|
195
1119
|
/**
|
|
196
|
-
*
|
|
197
|
-
*
|
|
198
|
-
*
|
|
1120
|
+
* Notifies the host that a component has been focused.
|
|
1121
|
+
*
|
|
1122
|
+
* @param event - The component focus event containing the component ID
|
|
1123
|
+
* @param event.componentId - The ID of the component that was focused
|
|
1124
|
+
* @stability development
|
|
199
1125
|
*/
|
|
200
|
-
|
|
201
|
-
private ensureLocalEntry;
|
|
1126
|
+
focusComponent(event: EventPayload<ComponentFocusedEvent>): void;
|
|
202
1127
|
/**
|
|
203
|
-
*
|
|
204
|
-
*
|
|
205
|
-
*
|
|
1128
|
+
* Notifies the host that the client configuration has changed.
|
|
1129
|
+
*
|
|
1130
|
+
* @param event - The client configuration change event containing the new configuration
|
|
1131
|
+
* @stability development
|
|
206
1132
|
*
|
|
207
|
-
* @
|
|
1133
|
+
* @example
|
|
1134
|
+
* ```typescript
|
|
1135
|
+
* api.setClientConfiguration({ ... });
|
|
1136
|
+
* ```
|
|
208
1137
|
*/
|
|
209
|
-
|
|
210
|
-
private buildFromImporter;
|
|
211
|
-
private buildFromLoadedModule;
|
|
1138
|
+
setClientConfiguration(event: EventPayload<ClientConfigurationChangedEvent>): void;
|
|
212
1139
|
}
|
|
213
1140
|
//#endregion
|
|
214
|
-
|
|
1141
|
+
//#region src/design/messaging-api/client.d.ts
|
|
1142
|
+
/**
|
|
1143
|
+
* Factory function to create a ClientApi instance.
|
|
1144
|
+
*
|
|
1145
|
+
* @public
|
|
1146
|
+
* @param _config - Configuration object for the client API (currently unused).
|
|
1147
|
+
* @returns {ClientApi} An instance of the ClientApi interface.
|
|
1148
|
+
*/
|
|
1149
|
+
declare function createClientApi({
|
|
1150
|
+
emitter,
|
|
1151
|
+
id,
|
|
1152
|
+
forwardedKeys,
|
|
1153
|
+
logger
|
|
1154
|
+
}: ClientConfiguration): ClientApi;
|
|
1155
|
+
//#endregion
|
|
1156
|
+
//#region src/design/messaging-api/host.d.ts
|
|
1157
|
+
/**
|
|
1158
|
+
* Factory function to create a HostApi instance.
|
|
1159
|
+
*
|
|
1160
|
+
* @public
|
|
1161
|
+
* @param {HostConfiguration} config - Configuration object for the host API.
|
|
1162
|
+
* @returns {HostApi} An instance of the HostApi interface.
|
|
1163
|
+
*/
|
|
1164
|
+
declare function createHostApi({
|
|
1165
|
+
emitter,
|
|
1166
|
+
id,
|
|
1167
|
+
logger
|
|
1168
|
+
}: HostConfiguration): HostApi;
|
|
1169
|
+
//#endregion
|
|
1170
|
+
export { ClientWindowDragExitedEvent as A, ComponentMovedToRegionEvent as B, ClientConfigurationChangedEvent as C, ClientReady as D, ClientPageChangedEvent as E, ComponentDragStartedEvent as F, ErrorEvent as G, ComponentSelectedEvent as H, ComponentFocusedEvent as I, HostToClientConfiguration as J, HostDisconnected as K, ComponentHoveredInEvent as L, ComponentAddedToRegionEvent as M, ComponentDeletedEvent as N, ClientWindowDragDroppedEvent as O, ComponentDeselectedEvent as P, ComponentHoveredOutEvent as R, ClientAcknowledgedEvent as S, ClientInitializedEvent as T, ComponentType as U, ComponentPropertiesChangedEvent as V, DefaultForwardedKeys as W, PageSettingsChangedEvent as X, MediaChangedEvent as Y, WindowScrollChangedEvent as Z, IsomorphicEventNameMapping as _, ClientEventNameMapping as a, WithEventType as b, EventHandler as c, HostApi as d, HostConfiguration as f, IsomorphicConfiguration as g, IsomorphicApi as h, ClientConfiguration as i, ClientWindowDragMovedEvent as j, ClientWindowDragEnteredEvent as k, EventPayload as l, HostMessage as m, createClientApi as n, ClientMessage as o, HostEventNameMapping as p, HostKeyPressedEvent as q, ClientApi as r, ConfigFactory as s, createHostApi as t, EventTypeName as u, MessageEmitter as v, ClientDisconnectedEvent as w, WithMeta as x, Source as y, ComponentInfo as z };
|
|
215
1171
|
//# sourceMappingURL=index.d.ts.map
|