@getflip/bridge 0.0.0-beta-20260114160010

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.
Files changed (133) hide show
  1. package/LICENSE.md +25 -0
  2. package/README.md +569 -0
  3. package/dist/dialog/dialog.d.ts +10 -0
  4. package/dist/dialog/dialog.js +45 -0
  5. package/dist/dialog/dialog.js.map +1 -0
  6. package/dist/dialog/dialog.spec.d.ts +1 -0
  7. package/dist/dialog/dialog.spec.js +83 -0
  8. package/dist/dialog/dialog.spec.js.map +1 -0
  9. package/dist/dialog/dialog.types.d.ts +33 -0
  10. package/dist/dialog/dialog.types.js +2 -0
  11. package/dist/dialog/dialog.types.js.map +1 -0
  12. package/dist/dialog/index.d.ts +2 -0
  13. package/dist/dialog/index.js +3 -0
  14. package/dist/dialog/index.js.map +1 -0
  15. package/dist/download/download.d.ts +1 -0
  16. package/dist/download/download.js +17 -0
  17. package/dist/download/download.js.map +1 -0
  18. package/dist/download/download.spec.d.ts +1 -0
  19. package/dist/download/download.spec.js +39 -0
  20. package/dist/download/download.spec.js.map +1 -0
  21. package/dist/download/download.types.d.ts +9 -0
  22. package/dist/download/download.types.js +2 -0
  23. package/dist/download/download.types.js.map +1 -0
  24. package/dist/download/index.d.ts +2 -0
  25. package/dist/download/index.js +3 -0
  26. package/dist/download/index.js.map +1 -0
  27. package/dist/events/events.d.ts +3 -0
  28. package/dist/events/events.js +44 -0
  29. package/dist/events/events.js.map +1 -0
  30. package/dist/events/events.spec.d.ts +1 -0
  31. package/dist/events/events.spec.js +64 -0
  32. package/dist/events/events.spec.js.map +1 -0
  33. package/dist/events/events.types.d.ts +29 -0
  34. package/dist/events/events.types.js +10 -0
  35. package/dist/events/events.types.js.map +1 -0
  36. package/dist/events/index.d.ts +2 -0
  37. package/dist/events/index.js +3 -0
  38. package/dist/events/index.js.map +1 -0
  39. package/dist/i18n/i18n.d.ts +3 -0
  40. package/dist/i18n/i18n.js +18 -0
  41. package/dist/i18n/i18n.js.map +1 -0
  42. package/dist/i18n/i18n.spec.d.ts +1 -0
  43. package/dist/i18n/i18n.spec.js +27 -0
  44. package/dist/i18n/i18n.spec.js.map +1 -0
  45. package/dist/i18n/i18n.types.d.ts +6 -0
  46. package/dist/i18n/i18n.types.js +2 -0
  47. package/dist/i18n/i18n.types.js.map +1 -0
  48. package/dist/i18n/index.d.ts +2 -0
  49. package/dist/i18n/index.js +3 -0
  50. package/dist/i18n/index.js.map +1 -0
  51. package/dist/index.cjs.js +329 -0
  52. package/dist/index.cjs.js.map +1 -0
  53. package/dist/index.d.ts +17 -0
  54. package/dist/index.js +18 -0
  55. package/dist/index.js.map +1 -0
  56. package/dist/index.mjs +310 -0
  57. package/dist/index.mjs.map +1 -0
  58. package/dist/index.spec.d.ts +1 -0
  59. package/dist/index.spec.js +20 -0
  60. package/dist/index.spec.js.map +1 -0
  61. package/dist/logging/index.d.ts +1 -0
  62. package/dist/logging/index.js +2 -0
  63. package/dist/logging/index.js.map +1 -0
  64. package/dist/logging/logging.d.ts +1 -0
  65. package/dist/logging/logging.js +8 -0
  66. package/dist/logging/logging.js.map +1 -0
  67. package/dist/logging/logging.spec.d.ts +1 -0
  68. package/dist/logging/logging.spec.js +19 -0
  69. package/dist/logging/logging.spec.js.map +1 -0
  70. package/dist/messaging/index.d.ts +2 -0
  71. package/dist/messaging/index.js +3 -0
  72. package/dist/messaging/index.js.map +1 -0
  73. package/dist/messaging/messaging.d.ts +15 -0
  74. package/dist/messaging/messaging.js +70 -0
  75. package/dist/messaging/messaging.js.map +1 -0
  76. package/dist/messaging/messaging.spec.d.ts +1 -0
  77. package/dist/messaging/messaging.spec.js +59 -0
  78. package/dist/messaging/messaging.spec.js.map +1 -0
  79. package/dist/messaging/messaging.types.d.ts +11 -0
  80. package/dist/messaging/messaging.types.js +2 -0
  81. package/dist/messaging/messaging.types.js.map +1 -0
  82. package/dist/modal/index.d.ts +2 -0
  83. package/dist/modal/index.js +3 -0
  84. package/dist/modal/index.js.map +1 -0
  85. package/dist/modal/modal.d.ts +10 -0
  86. package/dist/modal/modal.js +45 -0
  87. package/dist/modal/modal.js.map +1 -0
  88. package/dist/modal/modal.spec.d.ts +1 -0
  89. package/dist/modal/modal.spec.js +81 -0
  90. package/dist/modal/modal.spec.js.map +1 -0
  91. package/dist/modal/modal.types.d.ts +30 -0
  92. package/dist/modal/modal.types.js +2 -0
  93. package/dist/modal/modal.types.js.map +1 -0
  94. package/dist/navigation/index.d.ts +2 -0
  95. package/dist/navigation/index.js +3 -0
  96. package/dist/navigation/index.js.map +1 -0
  97. package/dist/navigation/navigation.d.ts +1 -0
  98. package/dist/navigation/navigation.js +12 -0
  99. package/dist/navigation/navigation.js.map +1 -0
  100. package/dist/navigation/navigation.spec.d.ts +1 -0
  101. package/dist/navigation/navigation.spec.js +22 -0
  102. package/dist/navigation/navigation.spec.js.map +1 -0
  103. package/dist/navigation/navigation.types.d.ts +6 -0
  104. package/dist/navigation/navigation.types.js +2 -0
  105. package/dist/navigation/navigation.types.js.map +1 -0
  106. package/dist/theming/index.d.ts +2 -0
  107. package/dist/theming/index.js +3 -0
  108. package/dist/theming/index.js.map +1 -0
  109. package/dist/theming/theming.d.ts +4 -0
  110. package/dist/theming/theming.js +19 -0
  111. package/dist/theming/theming.js.map +1 -0
  112. package/dist/theming/theming.spec.d.ts +1 -0
  113. package/dist/theming/theming.spec.js +30 -0
  114. package/dist/theming/theming.spec.js.map +1 -0
  115. package/dist/theming/theming.types.d.ts +12 -0
  116. package/dist/theming/theming.types.js +2 -0
  117. package/dist/theming/theming.types.js.map +1 -0
  118. package/dist/toast/index.d.ts +2 -0
  119. package/dist/toast/index.js +3 -0
  120. package/dist/toast/index.js.map +1 -0
  121. package/dist/toast/toast.d.ts +2 -0
  122. package/dist/toast/toast.js +12 -0
  123. package/dist/toast/toast.js.map +1 -0
  124. package/dist/toast/toast.spec.d.ts +1 -0
  125. package/dist/toast/toast.spec.js +32 -0
  126. package/dist/toast/toast.spec.js.map +1 -0
  127. package/dist/toast/toast.types.d.ts +11 -0
  128. package/dist/toast/toast.types.js +2 -0
  129. package/dist/toast/toast.types.js.map +1 -0
  130. package/dist/types.d.ts +57 -0
  131. package/dist/types.js +26 -0
  132. package/dist/types.js.map +1 -0
  133. package/package.json +38 -0
package/LICENSE.md ADDED
@@ -0,0 +1,25 @@
1
+ Copyright (c) 2022-present Flip GmbH
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the "Software"), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7
+ the Software, and to permit persons to whom the Software is furnished to do so,
8
+ subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ The rights granted above may only be exercised to develop and distribute
14
+ applications that integrate or interoperate with Flip software or services, and
15
+ in the case of external, stand-alone applications that do not embed directly
16
+ inside Flip, the rights granted above may only be exercised to develop and
17
+ distribute applications that are dissimilar and visually distinct from Flip
18
+ products and services, as determined by Flip in its sole discretion.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
22
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
23
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
24
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,569 @@
1
+ # Flip Bridge
2
+
3
+ The Flip Bridge handles communication between your embeddable apps and the Flip
4
+ App or Flip Admin Console.
5
+
6
+ **Contents**
7
+
8
+ - [Installation](#installation)
9
+ - [Usage](#usage)
10
+ - [Methods](#methods)
11
+ - [Internationalization](#internationalization)
12
+ - [Navigation](#navigation)
13
+ - [Theming](#theming)
14
+ - [Dialogs](#dialogs)
15
+ - [Modals](#modals)
16
+ - [Toasts](#toasts)
17
+ - [Downloads](#download)
18
+ - [Events](#events)
19
+ - [Error Handling](#error-handling)
20
+ - [Development](#development)
21
+
22
+ ## Installation
23
+
24
+ ```sh
25
+ npm install --save @getflip/bridge
26
+ # or
27
+ yarn add @getflip/bridge
28
+ ```
29
+
30
+ ## Usage
31
+
32
+ The library exposes a set of functions and listeners you can use to communicate
33
+ with the Flip App and Flip Admin Console (host app for short).
34
+
35
+ **Before using the provided functions, you have to call the `initFlipBridge`
36
+ function to set up the Flip Bridge.**
37
+
38
+ ```js
39
+ import { initFlipBridge } from "@getflip/bridge";
40
+
41
+ initFlipBridge({
42
+ debug: true,
43
+ hostAppOrigin: "http://localhost:4200", // has to be the origin of the targeted host app
44
+ });
45
+ ```
46
+
47
+ ## Methods
48
+
49
+ ### Internationalization
50
+
51
+ #### `getAvailableLangs`
52
+
53
+ Get all available languages of the host app.
54
+
55
+ **Returns** `Promise<string[]>`
56
+
57
+ **Example**
58
+
59
+ ```js
60
+ import { getAvailableLangs } from "@getflip/bridge";
61
+
62
+ const availableLanguages = await getAvailableLangs(); // e.g. ['de', 'en', 'fr', …]
63
+ ```
64
+
65
+ #### `getLang`
66
+
67
+ Get the current language of the host app.
68
+
69
+ **Returns** `Promise<string>`
70
+
71
+ **Example**
72
+
73
+ ```js
74
+ import { getLang } from "@getflip/bridge";
75
+
76
+ const currentLanguage = await getLang(); // e.g. 'en'
77
+ ```
78
+
79
+ ### Navigation
80
+
81
+ #### `navigate`
82
+
83
+ Navigate to a specific route.
84
+
85
+ **Param** `string`
86
+
87
+ **Returns** `Promise<boolean>`
88
+
89
+ **Example**
90
+
91
+ ```js
92
+ import { navigate } from "@getflip/bridge";
93
+
94
+ await navigate("/my-app/settings");
95
+ ```
96
+
97
+ ### Theming
98
+
99
+ #### `getTheme`
100
+
101
+ Get the current theme.
102
+
103
+ **Returns**
104
+
105
+ ```js
106
+ Promise<{
107
+ activeTheme: "light" | "dark";
108
+ preferredTheme: "light" | "dark" | undefined;
109
+ }>
110
+ ```
111
+
112
+ **Example**
113
+
114
+ ```js
115
+ import { getTheme } from "@getflip/bridge";
116
+
117
+ const theme = await getTheme();
118
+ ```
119
+
120
+ #### `setTheme`
121
+
122
+ Set the theme. Pass `undefined` to reset to the user's system theme.
123
+
124
+ **Param** `"light" | "dark" | undefined`
125
+
126
+ **Returns** `Promise<"light" | "dark" | undefined>`
127
+
128
+ **Example**
129
+
130
+ ```js
131
+ import { setTheme } from "@getflip/bridge";
132
+
133
+ const newTheme = await setTheme("dark");
134
+ ```
135
+
136
+ ### Dialogs
137
+
138
+ #### `createDialog`
139
+
140
+ Creates a modal dialog rendered by the host app.
141
+
142
+ **Param**
143
+
144
+ ```js
145
+ {
146
+ hideLabel?: boolean;
147
+ id: string;
148
+ intent?: 'primary' | 'critical';
149
+ label: string;
150
+ text: string;
151
+ primaryAction?: {
152
+ label: string;
153
+ };
154
+ secondaryAction?: {
155
+ label: string;
156
+ };
157
+ }
158
+ ```
159
+
160
+ **Returns**
161
+
162
+ ```js
163
+ Promise<boolean>
164
+ ```
165
+
166
+ **Example**
167
+
168
+ ```js
169
+ import { createDialog } from "@getflip/bridge";
170
+
171
+ const dialog = await createDialog({
172
+ id: "my-dialog",
173
+ label: "My Dialog",
174
+ text: "Lorem ipsum",
175
+ primaryAction: {
176
+ label: "Close",
177
+ },
178
+ });
179
+ ```
180
+
181
+ #### `openDialog`
182
+
183
+ Opens a dialog.
184
+
185
+ **Param**
186
+
187
+ ```js
188
+ {
189
+ id: string; // the dialog id
190
+ }
191
+ ```
192
+
193
+ **Returns** `Promise<boolean>`
194
+
195
+ **Example**
196
+
197
+ ```js
198
+ import { createDialog, openDialog } from "@getflip/bridge";
199
+
200
+ await createDialog({
201
+ id: "my-dialog",
202
+ label: "My Dialog",
203
+ text: "Lorem ipsum",
204
+ });
205
+
206
+ await openDialog({ id: "my-dialog" });
207
+ ```
208
+
209
+ #### `closeDialog`
210
+
211
+ Closes a dialog.
212
+
213
+ **Param**
214
+
215
+ ```js
216
+ {
217
+ id: string; // the dialog id
218
+ }
219
+ ```
220
+
221
+ **Returns** `Promise<boolean>`
222
+
223
+ **Example**
224
+
225
+ ```js
226
+ import { closeDialog } from "@getflip/bridge";
227
+
228
+ await closeDialog({ id: "my-dialog" });
229
+ ```
230
+
231
+ #### `destroyDialog`
232
+
233
+ Destroys a dialog, removing it from the DOM.
234
+
235
+ **Param**
236
+
237
+ ```js
238
+ {
239
+ id: string; // the dialog id
240
+ }
241
+ ```
242
+
243
+ **Returns** `Promise<boolean>`
244
+
245
+ **Example**
246
+
247
+ ```js
248
+ import { destroyDialog } from "@getflip/bridge";
249
+
250
+ await destroyDialog({ id: "my-dialog" });
251
+ ```
252
+
253
+ ### Modals
254
+
255
+ #### `createModal`
256
+
257
+ Creates a modal rendered by the host app. The modal will show the passed URL as
258
+ an iFrame.
259
+
260
+ **Param**
261
+
262
+ ```js
263
+ {
264
+ id: string;
265
+ label: string;
266
+ primaryAction?: {
267
+ label: string;
268
+ };
269
+ secondaryAction?: {
270
+ label: string;
271
+ };
272
+ url: string;
273
+ }
274
+ ```
275
+
276
+ **Returns**
277
+
278
+ ```js
279
+ Promise<boolean>
280
+ ```
281
+
282
+ **Example**
283
+
284
+ ```js
285
+ import { createModal } from "@getflip/bridge";
286
+
287
+ const modal = await createModal({
288
+ id: "my-moadl",
289
+ label: "My Modal",
290
+ primaryAction: {
291
+ label: "Close",
292
+ },
293
+ url: "https://google.com",
294
+ });
295
+ ```
296
+
297
+ #### `openModal`
298
+
299
+ Opens a modal.
300
+
301
+ **Param**
302
+
303
+ ```js
304
+ {
305
+ id: string; // the modal id
306
+ }
307
+ ```
308
+
309
+ **Returns** `Promise<boolean>`
310
+
311
+ **Example**
312
+
313
+ ```js
314
+ import { createModal, openModal } from "@getflip/bridge";
315
+
316
+ await createModal({
317
+ id: "my-modal",
318
+ label: "My Modal",
319
+ url: "https://google.com",
320
+ });
321
+
322
+ await openModal({ id: "my-modal" });
323
+ ```
324
+
325
+ #### `closeModal`
326
+
327
+ Closes a modal.
328
+
329
+ **Param**
330
+
331
+ ```js
332
+ {
333
+ id: string; // the modal id
334
+ }
335
+ ```
336
+
337
+ **Returns** `Promise<boolean>`
338
+
339
+ **Example**
340
+
341
+ ```js
342
+ import { closeModal } from "@getflip/bridge";
343
+
344
+ await closeModal({ id: "my-modal" });
345
+ ```
346
+
347
+ #### `destroyModal`
348
+
349
+ Destroys a modal, removing it from the DOM.
350
+
351
+ **Param**
352
+
353
+ ```js
354
+ {
355
+ id: string; // the modal id
356
+ }
357
+ ```
358
+
359
+ **Returns** `Promise<boolean>`
360
+
361
+ **Example**
362
+
363
+ ```js
364
+ import { destroyModal } from "@getflip/bridge";
365
+
366
+ await destroyModal({ id: "my-modal" });
367
+ ```
368
+
369
+ ### Toasts
370
+
371
+ #### `showToast`
372
+
373
+ Shows a toast by the host app.
374
+
375
+ **Param**
376
+
377
+ ```js
378
+ {
379
+ text: string;
380
+ duration?: number;
381
+ icon?: string;
382
+ intent?: SwirlToastIntent;
383
+ }
384
+ ```
385
+
386
+ **Returns** `Promise<boolean>`
387
+
388
+ **Example**
389
+
390
+ ```js
391
+ import { showToast } from "@getflip/bridge";
392
+
393
+ await showToast({
394
+ text: "My toast",
395
+ duration: 5000,
396
+ icon: "icon",
397
+ intent: "success",
398
+ });
399
+ ```
400
+
401
+ ### Downloads
402
+
403
+ #### `download`
404
+
405
+ Downloads a file via the host app.
406
+
407
+ **Param**
408
+
409
+ ```js
410
+ {
411
+ fileName: string; // filename
412
+ fileType: string; // file type
413
+ url?: string; // optional file URL
414
+ dataUrl?: string; // optional base64 encoded file data
415
+ }
416
+ ```
417
+
418
+ **Returns** `Promise<boolean>`
419
+
420
+ **Example**
421
+
422
+ ```js
423
+ import { download } from "@getflip/bridge";
424
+
425
+ await download({
426
+ fileName: "my-file.txt",
427
+ fileType: "text/plain",
428
+ url: "https://example.com/my-file.txt",
429
+ });
430
+ ```
431
+
432
+ ## Events
433
+
434
+ Use the `subscribe` functions to subscribe to events.
435
+
436
+ ```js
437
+ import { subscribe, BridgeEventType } from "@getflip/bridge";
438
+
439
+ const unsubscribe = await subscribe(BridgeEventType.THEME_CHANGE, (event) => {
440
+ console.log(event.data);
441
+ });
442
+
443
+ // …
444
+
445
+ await unsubscribe();
446
+ ```
447
+
448
+ ### `NAVIGATION_END`
449
+
450
+ Fires when the application successfully navigated to a different route.
451
+
452
+ **Event**
453
+
454
+ ```js
455
+ {
456
+ data: {
457
+ route: string; // e.g. '/notifications'
458
+ }
459
+ type: BridgeEventType.NAVIGATION_END;
460
+ }
461
+ ```
462
+
463
+ ### `LANG_CHANGE`
464
+
465
+ Fires when the user selected language changes.
466
+
467
+ **Event**
468
+
469
+ ```js
470
+ {
471
+ data: string; // e.g. 'en'
472
+ type: BridgeEventType.LANG_CHANGE;
473
+ }
474
+ ```
475
+
476
+ ### `PRIMARY_ACTION_CLICK`
477
+
478
+ Fires when the primary action button of a dialog or modal is clicked.
479
+
480
+ **Event**
481
+
482
+ ```js
483
+ {
484
+ data: {
485
+ parentId: string; // id of the action's dialog or modal
486
+ }
487
+ type: BridgeEventType.PRIMARY_ACTION_CLICK;
488
+ }
489
+ ```
490
+
491
+ ### `SECONDARY_ACTION_CLICK`
492
+
493
+ Fires when the secondary action button of a dialog or modal is clicked.
494
+
495
+ **Event**
496
+
497
+ ```js
498
+ {
499
+ data: {
500
+ parentId: string; // id of the action's dialog or modal
501
+ }
502
+ type: BridgeEventType.SECONDARY_ACTION_CLICK;
503
+ }
504
+ ```
505
+
506
+ ### `THEME_CHANGE`
507
+
508
+ Fires when the user theme changes.
509
+
510
+ **Event**
511
+
512
+ ```js
513
+ {
514
+ data: {
515
+ activeTheme: "light" | "dark";
516
+ preferredTheme: "light" | "dark" | undefined;
517
+ }
518
+ type: BridgeEventType.THEME_CHANGE;
519
+ }
520
+ ```
521
+
522
+ ### `TITLE_CHANGE`
523
+
524
+ Fires when the HTML title tag value of the app changes.
525
+
526
+ **Event**
527
+
528
+ ```js
529
+ {
530
+ data: {
531
+ title: string;
532
+ }
533
+ type: BridgeEventType.TITLE_CHANGE;
534
+ }
535
+ ```
536
+
537
+ ## Error Handling
538
+
539
+ All provided functions return promises that throw an error if the execution
540
+ failed. The errors have the following format.
541
+
542
+ ```js
543
+ {
544
+ code: BridgeErrorCode; // e.g. 'FORBIDDEN_ORIGIN'
545
+ }
546
+ ```
547
+
548
+ ### `FORBIDDEN_ORIGIN`
549
+
550
+ Thrown when the origin of the requesting app is not allowed by the host app.
551
+ Please check if your app is correctly registered in the Flip Partner Dashboard
552
+ and the `hostAppOrigin` option is set (see [Usage](#usage)).
553
+
554
+ ### `INVALID_REQUEST`
555
+
556
+ The host app identified the request as invalid. This typically occurs when the
557
+ provided parameters are invalid.
558
+
559
+ ## Development
560
+
561
+ Start the compiler in watch mode for local development:
562
+
563
+ ```
564
+ yarn dev
565
+ ```
566
+
567
+ Production builds and releases are managed via our Github workflows. Make sure
568
+ to create a Changeset using `yarn changeset` if you want to trigger a new
569
+ release.
@@ -0,0 +1,10 @@
1
+ import { CloseDialogRequest, CloseDialogRequestParams, CreateDialogRequestParams, DestroyDialogRequest, DestroyDialogRequestParams, OpenDialogRequest, OpenDialogRequestParams } from "./dialog.types";
2
+ export declare function createDialog(params: CreateDialogRequestParams): Promise<{
3
+ id: string;
4
+ open: () => Promise<import("../types").BridgeError | OpenDialogRequest>;
5
+ close: () => Promise<import("../types").BridgeError | CloseDialogRequest>;
6
+ destroy: () => Promise<import("../types").BridgeError | DestroyDialogRequest>;
7
+ } | undefined>;
8
+ export declare function openDialog(params: OpenDialogRequestParams): Promise<import("../types").BridgeError | OpenDialogRequest>;
9
+ export declare function closeDialog(params: CloseDialogRequestParams): Promise<import("../types").BridgeError | CloseDialogRequest>;
10
+ export declare function destroyDialog(params: DestroyDialogRequestParams): Promise<import("../types").BridgeError | DestroyDialogRequest>;
@@ -0,0 +1,45 @@
1
+ import { v4 as uuidv4 } from "uuid";
2
+ import { makeRequest } from "../messaging";
3
+ import { BridgeMethod } from "../types";
4
+ export async function createDialog(params) {
5
+ const request = {
6
+ id: uuidv4(),
7
+ method: BridgeMethod.CREATE_DIALOG,
8
+ params,
9
+ };
10
+ const result = await makeRequest(request);
11
+ if (!result) {
12
+ return;
13
+ }
14
+ return {
15
+ id: params.id,
16
+ open: async () => openDialog({ id: params.id }),
17
+ close: async () => closeDialog({ id: params.id }),
18
+ destroy: async () => destroyDialog({ id: params.id }),
19
+ };
20
+ }
21
+ export async function openDialog(params) {
22
+ const request = {
23
+ id: uuidv4(),
24
+ method: BridgeMethod.OPEN_DIALOG,
25
+ params,
26
+ };
27
+ return makeRequest(request);
28
+ }
29
+ export async function closeDialog(params) {
30
+ const request = {
31
+ id: uuidv4(),
32
+ method: BridgeMethod.CLOSE_DIALOG,
33
+ params,
34
+ };
35
+ return makeRequest(request);
36
+ }
37
+ export async function destroyDialog(params) {
38
+ const request = {
39
+ id: uuidv4(),
40
+ method: BridgeMethod.DESTROY_DIALOG,
41
+ params,
42
+ };
43
+ return makeRequest(request);
44
+ }
45
+ //# sourceMappingURL=dialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dialog.js","sourceRoot":"","sources":["../../src/dialog/dialog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAYxC,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,MAAiC;IAClE,MAAM,OAAO,GAAwB;QACnC,EAAE,EAAE,MAAM,EAAE;QACZ,MAAM,EAAE,YAAY,CAAC,aAAa;QAClC,MAAM;KACP,CAAC;IAEF,MAAM,MAAM,GAAG,MAAM,WAAW,CAAsB,OAAO,CAAC,CAAC;IAE/D,IAAI,CAAC,MAAM,EAAE;QACX,OAAO;KACR;IAED,OAAO;QACL,EAAE,EAAE,MAAM,CAAC,EAAE;QACb,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC,UAAU,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC;QAC/C,KAAK,EAAE,KAAK,IAAI,EAAE,CAAC,WAAW,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC;QACjD,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC,aAAa,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC;KACtD,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,MAA+B;IAC9D,MAAM,OAAO,GAAsB;QACjC,EAAE,EAAE,MAAM,EAAE;QACZ,MAAM,EAAE,YAAY,CAAC,WAAW;QAChC,MAAM;KACP,CAAC;IAEF,OAAO,WAAW,CAAoB,OAAO,CAAC,CAAC;AACjD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,MAAgC;IAChE,MAAM,OAAO,GAAuB;QAClC,EAAE,EAAE,MAAM,EAAE;QACZ,MAAM,EAAE,YAAY,CAAC,YAAY;QACjC,MAAM;KACP,CAAC;IAEF,OAAO,WAAW,CAAqB,OAAO,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,MAAkC;IACpE,MAAM,OAAO,GAAyB;QACpC,EAAE,EAAE,MAAM,EAAE;QACZ,MAAM,EAAE,YAAY,CAAC,cAAc;QACnC,MAAM;KACP,CAAC;IAEF,OAAO,WAAW,CAAuB,OAAO,CAAC,CAAC;AACpD,CAAC"}
@@ -0,0 +1 @@
1
+ export {};