bigbluebutton-html-plugin-sdk 0.1.7 → 0.1.9
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/README.md +156 -76
- package/dist/cjs/core/api/BbbPluginSdk.js +6 -1
- package/dist/cjs/core/api/BbbPluginSdk.js.map +1 -1
- package/dist/cjs/core/api/types.d.ts +25 -7
- package/dist/cjs/core/auxiliary/join-url/getter.js.map +1 -1
- package/dist/cjs/core/auxiliary/plugin-information/locale-messages/types.d.ts +9 -5
- package/dist/cjs/core/auxiliary/plugin-information/locale-messages/useLocaleMessages.js +11 -14
- package/dist/cjs/core/auxiliary/plugin-information/locale-messages/useLocaleMessages.js.map +1 -1
- package/dist/cjs/core/auxiliary/plugin-information/locale-messages/utils.d.ts +5 -1
- package/dist/cjs/core/auxiliary/plugin-information/locale-messages/utils.js +86 -1
- package/dist/cjs/core/auxiliary/plugin-information/locale-messages/utils.js.map +1 -1
- package/dist/cjs/core/enum.d.ts +5 -2
- package/dist/cjs/core/enum.js +3 -1
- package/dist/cjs/core/enum.js.map +1 -1
- package/dist/cjs/core/types.d.ts +2 -1
- package/dist/cjs/data-consumption/domain/shared/custom-query/hooks.d.ts +2 -0
- package/dist/cjs/data-consumption/domain/shared/custom-query/hooks.js +11 -0
- package/dist/cjs/data-consumption/domain/shared/custom-query/hooks.js.map +1 -0
- package/dist/cjs/data-consumption/domain/shared/custom-query/types.d.ts +9 -0
- package/dist/cjs/data-consumption/domain/shared/custom-query/types.js +3 -0
- package/dist/cjs/data-consumption/domain/shared/custom-query/types.js.map +1 -0
- package/dist/cjs/data-consumption/domain/shared/index.d.ts +1 -0
- package/dist/cjs/data-consumption/domain/shared/types.d.ts +3 -0
- package/dist/cjs/data-consumption/domain/shared/types.js +3 -0
- package/dist/cjs/data-consumption/domain/shared/types.js.map +1 -0
- package/dist/cjs/data-consumption/domain/users/index.d.ts +1 -1
- package/dist/cjs/data-consumption/domain/users/users-basic-info/hooks.js +3 -3
- package/dist/cjs/data-consumption/domain/users/users-basic-info/hooks.js.map +1 -1
- package/dist/cjs/data-consumption/domain/users/users-basic-info/types.d.ts +8 -0
- package/dist/cjs/data-consumption/enums.d.ts +3 -1
- package/dist/cjs/data-consumption/enums.js +2 -0
- package/dist/cjs/data-consumption/enums.js.map +1 -1
- package/dist/cjs/data-creation/enums.d.ts +6 -0
- package/dist/cjs/data-creation/enums.js +11 -0
- package/dist/cjs/data-creation/enums.js.map +1 -0
- package/dist/cjs/data-creation/hook.d.ts +2 -0
- package/dist/cjs/data-creation/hook.js +74 -0
- package/dist/cjs/data-creation/hook.js.map +1 -0
- package/dist/cjs/data-creation/types.d.ts +21 -0
- package/dist/cjs/data-creation/types.js +3 -0
- package/dist/cjs/data-creation/types.js.map +1 -0
- package/dist/cjs/data-creation/utils.d.ts +6 -0
- package/dist/cjs/data-creation/utils.js +14 -0
- package/dist/cjs/data-creation/utils.js.map +1 -0
- package/dist/cjs/extensible-areas/audio-settings-dropdown-item/component.d.ts +3 -1
- package/dist/cjs/extensible-areas/audio-settings-dropdown-item/component.js +3 -1
- package/dist/cjs/extensible-areas/audio-settings-dropdown-item/component.js.map +1 -1
- package/dist/cjs/ui-commands/actions-bar/commands.d.ts +1 -1
- package/dist/cjs/ui-commands/actions-bar/commands.js +1 -1
- package/dist/cjs/ui-commands/commands.d.ts +2 -47
- package/dist/cjs/ui-commands/commands.js +2 -0
- package/dist/cjs/ui-commands/commands.js.map +1 -1
- package/dist/cjs/ui-commands/conference/commands.d.ts +1 -1
- package/dist/cjs/ui-commands/conference/commands.js +1 -1
- package/dist/cjs/ui-commands/index.d.ts +1 -1
- package/dist/cjs/ui-commands/index.js +2 -1
- package/dist/cjs/ui-commands/index.js.map +1 -1
- package/dist/cjs/ui-commands/layout/commands.d.ts +10 -2
- package/dist/cjs/ui-commands/layout/commands.js +15 -2
- package/dist/cjs/ui-commands/layout/commands.js.map +1 -1
- package/dist/cjs/ui-commands/layout/enums.d.ts +6 -2
- package/dist/cjs/ui-commands/layout/enums.js +15 -12
- package/dist/cjs/ui-commands/layout/enums.js.map +1 -1
- package/dist/cjs/ui-commands/layout/types.d.ts +6 -1
- package/dist/cjs/ui-commands/sidekick-area/commands.d.ts +2 -0
- package/dist/cjs/ui-commands/sidekick-area/commands.js +8 -0
- package/dist/cjs/ui-commands/sidekick-area/commands.js.map +1 -0
- package/dist/cjs/ui-commands/sidekick-area/options/commands.d.ts +2 -0
- package/dist/cjs/ui-commands/sidekick-area/options/commands.js +52 -0
- package/dist/cjs/ui-commands/sidekick-area/options/commands.js.map +1 -0
- package/dist/cjs/ui-commands/sidekick-area/options/enums.d.ts +6 -0
- package/dist/cjs/ui-commands/sidekick-area/options/enums.js +11 -0
- package/dist/cjs/ui-commands/sidekick-area/options/enums.js.map +1 -0
- package/dist/cjs/ui-commands/sidekick-area/options/panel/commands.d.ts +2 -0
- package/dist/cjs/ui-commands/sidekick-area/options/panel/commands.js +19 -0
- package/dist/cjs/ui-commands/sidekick-area/options/panel/commands.js.map +1 -0
- package/dist/cjs/ui-commands/sidekick-area/options/panel/enums.d.ts +4 -0
- package/dist/cjs/ui-commands/sidekick-area/options/panel/enums.js +9 -0
- package/dist/cjs/ui-commands/sidekick-area/options/panel/enums.js.map +1 -0
- package/dist/cjs/ui-commands/sidekick-area/options/panel/types.d.ts +4 -0
- package/dist/cjs/ui-commands/sidekick-area/options/panel/types.js +3 -0
- package/dist/cjs/ui-commands/sidekick-area/options/panel/types.js.map +1 -0
- package/dist/cjs/ui-commands/sidekick-area/options/types.d.ts +19 -0
- package/dist/cjs/ui-commands/sidekick-area/options/types.js +3 -0
- package/dist/cjs/ui-commands/sidekick-area/options/types.js.map +1 -0
- package/dist/cjs/ui-commands/sidekick-area/types.d.ts +4 -0
- package/dist/cjs/ui-commands/sidekick-area/types.js +3 -0
- package/dist/cjs/ui-commands/sidekick-area/types.js.map +1 -0
- package/dist/cjs/ui-commands/sidekick-options-container/commands.d.ts +4 -0
- package/dist/cjs/ui-commands/sidekick-options-container/commands.js +4 -0
- package/dist/cjs/ui-commands/sidekick-options-container/commands.js.map +1 -1
- package/dist/cjs/ui-commands/types.d.ts +2 -0
- package/dist/cjs/ui-data/domain/intl/locale/types.d.ts +5 -4
- package/package.json +1 -1
- package/dist/cjs/data-consumption/domain/users/users-basic-info/queries.d.ts +0 -1
- package/dist/cjs/data-consumption/domain/users/users-basic-info/queries.js +0 -5
- package/dist/cjs/data-consumption/domain/users/users-basic-info/queries.js.map +0 -1
package/README.md
CHANGED
|
@@ -41,7 +41,7 @@ _Running from source code with local BBB-server_
|
|
|
41
41
|
pluginManifests=[{"url": "http://localhost:4701/manifest.json"}]
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
_Running from source code with a remote BBB-server_
|
|
45
45
|
|
|
46
46
|
If you are running your BBB-server elsewhere, than you can't simply point the manifest URL to a local address, you'll need to either serve the built version into a CDN or serve the dev version using a service to make it public. And for the second option we'd recommend NGROK. Here are the instructions to do that:
|
|
47
47
|
|
|
@@ -69,7 +69,7 @@ Right after that, NGROK will create an interface into your terminal and will dis
|
|
|
69
69
|
|
|
70
70
|
Here's an example of URL: `https://<uuid>.ngrok-free.app`
|
|
71
71
|
|
|
72
|
-
You can already interact with this URL and access both
|
|
72
|
+
You can already interact with this URL and access both
|
|
73
73
|
|
|
74
74
|
`https://<uuid>.ngrok-free.app/manifest.json`
|
|
75
75
|
|
|
@@ -77,7 +77,6 @@ or
|
|
|
77
77
|
|
|
78
78
|
`https://<uuid>.ngrok-free.app/PickRandomUserPlugin.js`
|
|
79
79
|
|
|
80
|
-
|
|
81
80
|
5. Add this create parameter into the API-mate of the server you are testing it on:
|
|
82
81
|
|
|
83
82
|
```
|
|
@@ -123,21 +122,21 @@ Here is as complete `manifest.json` example with all possible configurations:
|
|
|
123
122
|
"name": "MyPlugin",
|
|
124
123
|
"javascriptEntrypointUrl": "MyPlugin.js",
|
|
125
124
|
"localesBaseUrl": "https://cdn.domain.com/my-plugin/", // Optional
|
|
126
|
-
"dataChannels":[
|
|
125
|
+
"dataChannels": [
|
|
127
126
|
{
|
|
128
127
|
"name": "public-channel",
|
|
129
|
-
"pushPermission": ["moderator","presenter"], // "moderator","presenter", "all"
|
|
128
|
+
"pushPermission": ["moderator", "presenter"], // "moderator","presenter", "all"
|
|
130
129
|
"replaceOrDeletePermission": ["moderator", "creator"] // "moderator", "presenter","all", "creator"
|
|
131
130
|
}
|
|
132
131
|
], // One can enable more data-channels to better organize client communication
|
|
133
132
|
"eventPersistence": {
|
|
134
|
-
"isEnabled": true
|
|
133
|
+
"isEnabled": true // By default it is not enabled
|
|
135
134
|
},
|
|
136
135
|
"remoteDataSources": [
|
|
137
136
|
{
|
|
138
137
|
"name": "allUsers",
|
|
139
138
|
"url": "${meta_pluginSettingsUserInformation}",
|
|
140
|
-
"fetchMode": "onMeetingCreate", // Possible values: "onMeetingCreate", "onDemand"
|
|
139
|
+
"fetchMode": "onMeetingCreate", // Possible values: "onMeetingCreate", "onDemand"
|
|
141
140
|
"permissions": ["moderator", "viewer"]
|
|
142
141
|
}
|
|
143
142
|
],
|
|
@@ -199,10 +198,12 @@ Foreach of the following ui-extensible-area, we have a different setter function
|
|
|
199
198
|
Mind that, although each area has its own structure, all the functions follows a certain argument structure, and returns nothing, that would be:
|
|
200
199
|
|
|
201
200
|
```ts
|
|
202
|
-
pluginApi.setterFunctionExample([
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
201
|
+
pluginApi.setterFunctionExample([
|
|
202
|
+
{
|
|
203
|
+
objectProperty1: 'string',
|
|
204
|
+
objectProperty2: 123,
|
|
205
|
+
},
|
|
206
|
+
]);
|
|
206
207
|
```
|
|
207
208
|
|
|
208
209
|
See, it is basically a function that requires an array as an argument, with which the more items you push to that array, the more of that extensible area you will have.
|
|
@@ -258,6 +259,54 @@ export interface GraphqlResponseWrapper<TData> {
|
|
|
258
259
|
|
|
259
260
|
So we have the `data`, which is different for each hook, that's why it's a generic, the error, that will be set if, and only if, there is an error, otherwise it is undefined, and loading, which tells the developer if the query is still loading (being fetched) or not.
|
|
260
261
|
|
|
262
|
+
### Realtime Data Creation
|
|
263
|
+
|
|
264
|
+
**`useCustomMutation` Hook**
|
|
265
|
+
|
|
266
|
+
The `useCustomMutation` hook enables you to post data to the backend (Postgres) using existing GraphQL mutations, respecting user permissions.
|
|
267
|
+
|
|
268
|
+
It works similarly to Apollo Client’s `useMutation`, returning a _trigger function_ and a _result object_ with information about the mutation execution. These will be described in more detail below.
|
|
269
|
+
|
|
270
|
+
One important difference is that the mutation query **must** be provided as a string. This is due to how the SDK communicates with the HTML5 client. As a consequence, you must explicitly define the type of the `variables` argument for the trigger function, as shown in the example below.
|
|
271
|
+
|
|
272
|
+
```typescript
|
|
273
|
+
interface MutationVariablesType {
|
|
274
|
+
reactionEmoji: string;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
const [trigger, result] = pluginApi.useCustomMutation<MutationVariablesType>(`
|
|
278
|
+
mutation SetReactionEmoji($reactionEmoji: String!) {
|
|
279
|
+
userSetReactionEmoji(reactionEmoji: $reactionEmoji)
|
|
280
|
+
}
|
|
281
|
+
`);
|
|
282
|
+
|
|
283
|
+
// Later in the code, you can trigger the mutation:
|
|
284
|
+
trigger({
|
|
285
|
+
variables: {
|
|
286
|
+
reactionEmoji: '👏',
|
|
287
|
+
},
|
|
288
|
+
});
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
Note that the same type (`MutationVariablesType`) passed as the generic parameter to `useCustomMutation` is also the type of the `variables` object in the trigger function.
|
|
292
|
+
|
|
293
|
+
The `result` object returned by the hook contains the following fields:
|
|
294
|
+
|
|
295
|
+
```typescript
|
|
296
|
+
const { called, data, error, loading } = result;
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
which follow this interface:
|
|
300
|
+
|
|
301
|
+
```typescript
|
|
302
|
+
interface MutationResultObject {
|
|
303
|
+
called: boolean; // Indicates if the trigger function has been called
|
|
304
|
+
data?: object; // Response data after the mutation is triggered
|
|
305
|
+
error?: object; // Error details from the mutation execution
|
|
306
|
+
loading: boolean; // Whether the mutation is currently loading (triggered or in progress)
|
|
307
|
+
}
|
|
308
|
+
```
|
|
309
|
+
|
|
261
310
|
### Real time data exchange
|
|
262
311
|
|
|
263
312
|
- `useDataChannel` hook: this will allow you to exchange information (Send and receive) amongst different users through the same plugin;
|
|
@@ -268,7 +317,7 @@ So for this hook to read the data from the data channel, the developer will be a
|
|
|
268
317
|
- LATEST_ITEM: Fetches only the latest item pushed to the data-channel within a specific subchannel-name since the beginning of the meeting;
|
|
269
318
|
- NEW_ITEMS: Fetches the new items pushed to the data-channel within a specific subchannel-name since the moment that the `useDataChannel` hook has been called (It will not see entries sent previous to that moment);
|
|
270
319
|
|
|
271
|
-
An interesting thing about this hook is that it is generic, so, you can use a custom type, and this will be
|
|
320
|
+
An interesting thing about this hook is that it is generic, so, you can use a custom type, and this will be found not only in the consumer part of the data structure returned, but also in functions in which you need to specify an object to be persisted, meaning it will force the object to be of the type you mentioned previously (that is the case for `pushEntry` and `replaceEntry`). One can find examples of usage of this in the data-channel plugin sample or most of the official ones. The syntax is described below:
|
|
272
321
|
|
|
273
322
|
```typescript
|
|
274
323
|
const {
|
|
@@ -279,7 +328,7 @@ const {
|
|
|
279
328
|
} = useDataChannel<CustomType>(
|
|
280
329
|
channelName, // Defined according to what is on manifest.json
|
|
281
330
|
DataChannelTypes.ALL_ITEMS, // | LATEST_ITEM | NEW_ITEMS -> ALL_ITEMS is default
|
|
282
|
-
subChannelName = 'default'
|
|
331
|
+
(subChannelName = 'default') // If no subchannelName is specified, it will be 'default'
|
|
283
332
|
);
|
|
284
333
|
```
|
|
285
334
|
|
|
@@ -287,22 +336,22 @@ Wiping all data off will delete every item from the specific data-channel within
|
|
|
287
336
|
|
|
288
337
|
**Data-channel configuration:**
|
|
289
338
|
|
|
290
|
-
The data-channel name must be in the `manifest.json` along with all the permissions for
|
|
339
|
+
The data-channel name must be in the `manifest.json` along with all the permissions for writing, reading and deleting, see example below:
|
|
291
340
|
|
|
292
341
|
```json
|
|
293
342
|
{
|
|
294
343
|
"requiredSdkVersion": "~0.0.59",
|
|
295
344
|
"name": "PluginName",
|
|
296
345
|
"javascriptEntrypointUrl": "PluginName.js",
|
|
297
|
-
"dataChannels":[
|
|
346
|
+
"dataChannels": [
|
|
298
347
|
{
|
|
299
348
|
"name": "channel-name",
|
|
300
|
-
"pushPermission": ["moderator","presenter"],
|
|
349
|
+
"pushPermission": ["moderator", "presenter"],
|
|
301
350
|
"replaceOrDeletePermission": ["moderator", "sender"]
|
|
302
351
|
}
|
|
303
352
|
]
|
|
304
353
|
}
|
|
305
|
-
```
|
|
354
|
+
```
|
|
306
355
|
|
|
307
356
|
If no permission is mentioned in that file (writing or deleting), no one will be able proceed with that specific action:
|
|
308
357
|
|
|
@@ -336,14 +385,16 @@ export type ObjectTo = ToUserId | ToRole;
|
|
|
336
385
|
Example of usage:
|
|
337
386
|
|
|
338
387
|
```ts
|
|
339
|
-
|
|
388
|
+
const currentLocale = pluginApi.useUiData(
|
|
389
|
+
IntlLocaleUiDataNames.CURRENT_LOCALE,
|
|
390
|
+
{
|
|
340
391
|
locale: 'en',
|
|
341
392
|
fallbackLocale: 'en',
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
393
|
+
}
|
|
394
|
+
);
|
|
395
|
+
// Do something with the currentLocale:
|
|
396
|
+
currentLocale.locale;
|
|
397
|
+
currentLocale.fallbackLocale;
|
|
347
398
|
```
|
|
348
399
|
|
|
349
400
|
Mind that foreach enum we have, a different type of fallback is needed as the second argument. In the example above, we want the `intl`, so the second argument, will follow the structure depicted.
|
|
@@ -354,23 +405,42 @@ One other thing is that the type of the return is precisely the same type requir
|
|
|
354
405
|
|
|
355
406
|
`uiCommands` object: It basically contains all the possible commands available to the developer to interact with the core BBB UI, see the ones implemented down below:
|
|
356
407
|
|
|
408
|
+
- actions-bar:
|
|
409
|
+
- setDisplayActionBar: this function decides whether to display the actions bar
|
|
410
|
+
- camera:
|
|
411
|
+
- setSelfViewDisableAllDevices: Sets the self-view camera disabled/enabled for all camera devices of a user;
|
|
412
|
+
- setSelfViewDisable: Sets the self-view camera disabled/enabled for specific camera.
|
|
357
413
|
- chat:
|
|
358
414
|
- form:
|
|
359
415
|
- open: this function will open the sidebar chat panel automatically;
|
|
360
|
-
- fill: this function will fill the form input field of the chat passed in the argument as {text: string}
|
|
416
|
+
- fill: this function will fill the form input field of the chat passed in the argument as `{text: string}`
|
|
417
|
+
- conference:
|
|
418
|
+
- setSpeakerLevel: this function will set the speaker volume level(audio output) of the conference to a certain number between 0 and 1;
|
|
361
419
|
- external-video:
|
|
362
420
|
- volume:
|
|
363
421
|
- set: this function will set the external video volume to a certain number between 0 and 1 (that is 0% and);
|
|
364
|
-
-
|
|
365
|
-
-
|
|
366
|
-
-
|
|
422
|
+
- layout:
|
|
423
|
+
- changeEnforcedLayout: (deprecated) Changes the enforced layout
|
|
424
|
+
- setEnforcedLayout: Sets the enforced layout
|
|
425
|
+
- navBar:
|
|
426
|
+
- setDisplayNavBar: Sets the displayNavBar to true (show it) or false (hide it).
|
|
427
|
+
- notification:
|
|
428
|
+
- send: This function will send a notification for the client to render, keep in mind that it's only client-side. Should you want it to be rendered in multiple clients, use this with a data-channel;
|
|
367
429
|
- presentation-area:
|
|
368
430
|
- open: this function will open the presentation area content automatically;
|
|
369
431
|
- close: this function will close the presentation area content automatically;
|
|
370
|
-
-
|
|
371
|
-
-
|
|
372
|
-
-
|
|
373
|
-
|
|
432
|
+
- sidekick-area:
|
|
433
|
+
- options:
|
|
434
|
+
- renameGenericContentMenu: this function will rename the menu of the generic content in the sidekick-area (must have the ID of the sidekick and the newName);
|
|
435
|
+
- renameGenericContentSection: this function will rename the section in which the menu with the specified ID is;
|
|
436
|
+
- setMenuBadge: this will set a badge for a specific generic content in the sidekick area;
|
|
437
|
+
- removeMenuBadge: this will remove any badges that a specific generic content might have;
|
|
438
|
+
- panel:
|
|
439
|
+
- open: this function will open the sidekick options panel automatically;
|
|
440
|
+
- close: this function will close the sidekick options panel automatically (and also the sidebar content if open, to avoid inconsistencies in ui);
|
|
441
|
+
- sidekick-options-container:
|
|
442
|
+
- open: this function will open the sidekick options panel automatically;
|
|
443
|
+
- close: this function will close the sidekick options panel automatically (and also the sidebar content if open, to avoid inconsistencies in ui);
|
|
374
444
|
- user-status:
|
|
375
445
|
- setAwayStatus: this function will set the away status of the user to a certain status;
|
|
376
446
|
- captions:
|
|
@@ -379,27 +449,28 @@ One other thing is that the type of the return is precisely the same type requir
|
|
|
379
449
|
See usage ahead:
|
|
380
450
|
|
|
381
451
|
```ts
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
452
|
+
pluginApi.uiCommands.chat.form.open();
|
|
453
|
+
pluginApi.uiCommands.chat.form.fill({
|
|
454
|
+
text: 'Just an example message filled by the plugin',
|
|
455
|
+
});
|
|
386
456
|
```
|
|
387
457
|
|
|
388
458
|
So the idea is that we have a `uiCommands` object and at a point, there will be the command to do the intended action, such as open the chat form and/or fill it, as demonstrated above
|
|
389
459
|
|
|
390
460
|
### Server Commands
|
|
391
|
-
|
|
392
|
-
`serverCommands` object: It contains all the possible commands available to the developer to interact with the BBB core server, see the ones implemented down below:
|
|
393
|
-
|
|
394
|
-
- chat:
|
|
395
|
-
- sendPublicMessage: This function sends a message to the public chat on behalf of the currently logged-in user.
|
|
396
461
|
|
|
397
|
-
|
|
398
|
-
|
|
462
|
+
`serverCommands` object: It contains all the possible commands available to the developer to interact with the BBB core server, see the ones implemented down below:
|
|
463
|
+
|
|
464
|
+
- chat:
|
|
465
|
+
|
|
466
|
+
- sendPublicMessage: This function sends a message to the public chat on behalf of the currently logged-in user.
|
|
399
467
|
|
|
400
|
-
-
|
|
401
|
-
|
|
402
|
-
|
|
468
|
+
- sendCustomPublicMessage: This function sends a text message to the public chat, optionally including custom metadata.
|
|
469
|
+
> **Note**: The custom messages sent by plugins are not automatically rendered by the client. To display these messages, a plugin must handle the rendering using `useLoadedChatMessages` and `useChatMessageDomElements`.
|
|
470
|
+
|
|
471
|
+
- caption:
|
|
472
|
+
- save: this function saves the given text, locale and caption type
|
|
473
|
+
- addLocale: this function sends a locale to be added to the available options
|
|
403
474
|
|
|
404
475
|
### Dom Element Manipulation
|
|
405
476
|
|
|
@@ -422,10 +493,9 @@ interface GenericDataForLearningAnalyticsDashboard {
|
|
|
422
493
|
|
|
423
494
|
So that the data will appear in the following form:
|
|
424
495
|
|
|
425
|
-
|
|
|
426
|
-
|
|
|
427
|
-
| user-name |
|
|
428
|
-
|
|
496
|
+
| User | Count | `<columnTitle>` |
|
|
497
|
+
| --------- | :---- | --------------: |
|
|
498
|
+
| user-name | 1 | `<value>` |
|
|
429
499
|
|
|
430
500
|
### External data resources
|
|
431
501
|
|
|
@@ -437,12 +507,12 @@ This is possible by simply configuring the dataResource name in the manifest and
|
|
|
437
507
|
{
|
|
438
508
|
// ...rest of manifest configuration
|
|
439
509
|
"remoteDataSources": [
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
510
|
+
{
|
|
511
|
+
"name": "allUsers",
|
|
512
|
+
"url": "${meta_pluginSettingsUserInformation}",
|
|
513
|
+
"fetchMode": "onMeetingCreate", // Possible values: "onMeetingCreate", "onDemand"
|
|
514
|
+
"permissions": ["moderator", "viewer"] // Possible values: "moderator", "viewer", "presenter"
|
|
515
|
+
}
|
|
446
516
|
]
|
|
447
517
|
}
|
|
448
518
|
```
|
|
@@ -468,20 +538,29 @@ See that we send the `meta_` parameter, for more information, refer to the [meta
|
|
|
468
538
|
Lastly, in the plugin, just use the function like:
|
|
469
539
|
|
|
470
540
|
```typescript
|
|
471
|
-
pluginApi
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
})
|
|
480
|
-
|
|
481
|
-
|
|
541
|
+
pluginApi
|
|
542
|
+
.getRemoteData('allUsers')
|
|
543
|
+
.then((response: Response) => {
|
|
544
|
+
if (response.ok) {
|
|
545
|
+
response
|
|
546
|
+
.json()
|
|
547
|
+
.then((r: CourseData) => {
|
|
548
|
+
// Do something with the jsonified data (if it's a json)
|
|
549
|
+
})
|
|
550
|
+
.catch((reason) => {
|
|
551
|
+
pluginLogger.error(
|
|
552
|
+
'Error while processing the json from success response: ',
|
|
553
|
+
reason
|
|
554
|
+
);
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
})
|
|
558
|
+
.catch((reason) => {
|
|
559
|
+
pluginLogger.error('Error while fetching external resource: ', reason);
|
|
560
|
+
});
|
|
482
561
|
```
|
|
483
562
|
|
|
484
|
-
###
|
|
563
|
+
### Meta\_ parameters
|
|
485
564
|
|
|
486
565
|
This is not part of the API, but it's a way of passing information to the manifest. Any value can be passed like this, one just needs to put something like `${meta_nameOfParameter}` in a specific config of the manifest, and in the `/create` call, set this meta-parameter to whatever is preferred, like `meta_nameOfParameter="Sample message"`
|
|
487
566
|
|
|
@@ -497,7 +576,7 @@ To use it, one first need to add the following lines to their `manifest.json`:
|
|
|
497
576
|
{
|
|
498
577
|
// ...rest of manifest configuration
|
|
499
578
|
"eventPersistence": {
|
|
500
|
-
|
|
579
|
+
"isEnabled": true
|
|
501
580
|
}
|
|
502
581
|
}
|
|
503
582
|
```
|
|
@@ -512,16 +591,17 @@ See example in the `sample-use-meeting` plugin here in this repository. It is as
|
|
|
512
591
|
|
|
513
592
|
```ts
|
|
514
593
|
useEffect(() => {
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
594
|
+
setInterval(() => {
|
|
595
|
+
pluginLogger.info('persisting event');
|
|
596
|
+
pluginApi.persistEvent('eventFromUseMeetingSample', { foo: 'bar' });
|
|
597
|
+
}, 5000);
|
|
598
|
+
}, []);
|
|
520
599
|
```
|
|
521
600
|
|
|
522
601
|
After the meeting is ended (considering it has been recorded), one can simply do the following steps to see the events:
|
|
523
602
|
|
|
524
603
|
In the server terminal run:
|
|
604
|
+
|
|
525
605
|
```bash
|
|
526
606
|
sudo updatedb
|
|
527
607
|
vi $(locate events.xml | grep <meeting-id>)
|
|
@@ -581,10 +661,10 @@ At this point, another folder will be created into the plugin directory called "
|
|
|
581
661
|
module.exports = {
|
|
582
662
|
// ... Other configurations
|
|
583
663
|
output: {
|
|
584
|
-
filename: 'MyPlugin.js'
|
|
585
|
-
}
|
|
664
|
+
filename: 'MyPlugin.js',
|
|
665
|
+
},
|
|
586
666
|
// ... Other configurations
|
|
587
|
-
}
|
|
667
|
+
};
|
|
588
668
|
```
|
|
589
669
|
|
|
590
670
|
**Does the builded plugin need to be in the same BBB server?**
|
|
@@ -30,6 +30,8 @@ var utils_1 = require("../../remote-data/utils");
|
|
|
30
30
|
var hooks_14 = require("../../event-persistence/hooks");
|
|
31
31
|
var useLocaleMessages_1 = __importDefault(require("../auxiliary/plugin-information/locale-messages/useLocaleMessages"));
|
|
32
32
|
var getters_1 = require("../../ui-data/getters/getters");
|
|
33
|
+
var hooks_15 = require("../../data-consumption/domain/shared/custom-query/hooks");
|
|
34
|
+
var hook_2 = require("../../data-creation/hook");
|
|
33
35
|
/**
|
|
34
36
|
* Class responsible for either initialize or get the PluginApi
|
|
35
37
|
*
|
|
@@ -56,6 +58,8 @@ var BbbPluginSdk = /** @class */ (function () {
|
|
|
56
58
|
throw new Error('Initializing pluginApi outside of a react function component. It should be done inside');
|
|
57
59
|
var pluginApi = window.bbb_plugins[uuid];
|
|
58
60
|
pluginApi.useCustomSubscription = (function (query, variablesObjectWrapper) { return (0, hooks_3.useCustomSubscription)(query, variablesObjectWrapper); });
|
|
61
|
+
pluginApi.useCustomQuery = (function (query, variablesObjectWrapper) { return (0, hooks_15.useCustomQuery)(query, variablesObjectWrapper); });
|
|
62
|
+
pluginApi.useCustomMutation = (function (mutation, options) { return (0, hook_2.useCustomMutation)(mutation, options); });
|
|
59
63
|
pluginApi.useCurrentPresentation = (function () { return (0, hooks_2.useCurrentPresentation)(); });
|
|
60
64
|
pluginApi.useLoadedUserList = (function () { return (0, hooks_4.useLoadedUserList)(); });
|
|
61
65
|
pluginApi.useCurrentUser = (function () { return (0, hooks_5.useCurrentUser)(); });
|
|
@@ -81,7 +85,8 @@ var BbbPluginSdk = /** @class */ (function () {
|
|
|
81
85
|
pluginApi.serverCommands = (0, commands_2.serverCommands)(pluginName);
|
|
82
86
|
pluginApi.sendGenericDataForLearningAnalyticsDashboard = function (data) { return (0, hooks_13.sendGenericDataForLearningAnalyticsDashboard)(data, pluginName); };
|
|
83
87
|
pluginApi.getRemoteData = function (dataSourceName) { return (0, utils_1.getRemoteData)(dataSourceName, pluginName); };
|
|
84
|
-
pluginApi
|
|
88
|
+
pluginApi
|
|
89
|
+
.persistEvent = function (eventName, payload) { return (0, hooks_14.persistEventFunctionWrapper)(pluginName, eventName, payload); };
|
|
85
90
|
pluginApi.useLocaleMessages = function (fetchConfigs) { return (0, useLocaleMessages_1.default)({ pluginApi: pluginApi, fetchConfigs: fetchConfigs }); };
|
|
86
91
|
}
|
|
87
92
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BbbPluginSdk.js","sourceRoot":"","sources":["../../../../src/core/api/BbbPluginSdk.ts"],"names":[],"mappings":";;;;;;AAAA,+BAA+B;AAC/B,+BAAkC;AAClC,0EAAsE;AAOtE,kDAA4D;AAO5D,uDAAwD;
|
|
1
|
+
{"version":3,"file":"BbbPluginSdk.js","sourceRoot":"","sources":["../../../../src/core/api/BbbPluginSdk.ts"],"names":[],"mappings":";;;;;;AAAA,+BAA+B;AAC/B,+BAAkC;AAClC,0EAAsE;AAOtE,kDAA4D;AAO5D,uDAAwD;AASxD,kDAAiE;AACjE,gGAEgF;AAChF,wFAEwE;AACxE,oFAA+F;AAC/F,gFAAwF;AACxF,oFAA+F;AAC/F,4DAAoE;AACpE,uDAA0D;AAC1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AE,cAAQ,CAAC;iBACd;gBACD,eAAe,EAAE,cAAM,OAAA,IAAA,wBAAe,GAAE,EAAjB,CAAiB;gBACxC,UAAU,YAAA;gBACV,cAAc,gBAAA;aACf,CAAC;SACH;QAED,OAAO,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;IACH,mBAAC;AAAD,CAAC,AAhJD,IAgJC;AAhJqB,oCAAY"}
|
|
@@ -35,6 +35,8 @@ import { PersistEventFunction } from '../../event-persistence/types';
|
|
|
35
35
|
import { UseLocaleMessagesFunction } from '../auxiliary/plugin-information/locale-messages/types';
|
|
36
36
|
import { UseShouldUnmountPluginFunction } from '../auxiliary/plugin-unmount/types';
|
|
37
37
|
import { GetUiDataFunction } from '../../ui-data/getters/types';
|
|
38
|
+
import { UseCustomQueryFunction } from '../../data-consumption/domain/shared/custom-query/types';
|
|
39
|
+
import { UseCustomMutationFunction } from '../../data-creation/types';
|
|
38
40
|
export type SetPresentationToolbarItems = (presentationToolbarItem: PresentationToolbarInterface[]) => string[];
|
|
39
41
|
export type SetUserListDropdownItems = (userListDropdownItem: UserListDropdownInterface[]) => string[];
|
|
40
42
|
export type SetMediaAreaItems = (mediaAreaDropdownInterface: MediaAreaInterface[]) => string[];
|
|
@@ -112,11 +114,11 @@ export interface PluginApi {
|
|
|
112
114
|
*/
|
|
113
115
|
useUsersBasicInfo?: UseUsersBasicInfoFunction;
|
|
114
116
|
/**
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
117
|
+
* Returns an object containing brief data on the messages already loaded in the chat.
|
|
118
|
+
*
|
|
119
|
+
* @returns `GraphqlResponseWrapper` with the LoadedChatMessages.
|
|
120
|
+
*
|
|
121
|
+
*/
|
|
120
122
|
useLoadedChatMessages?: UseLoadedChatMessagesFunction;
|
|
121
123
|
/**
|
|
122
124
|
* Returns an object containing the settings for the current plugin (with pluginName
|
|
@@ -146,13 +148,29 @@ export interface PluginApi {
|
|
|
146
148
|
*/
|
|
147
149
|
useShouldUnmountPlugin?: UseShouldUnmountPluginFunction;
|
|
148
150
|
/**
|
|
149
|
-
* Returns an object containing the data
|
|
150
|
-
*
|
|
151
|
+
* Returns an object containing the data related to the custom subscription made.
|
|
152
|
+
* This hook is reactive - If the resulting data changes, it updates the hook.
|
|
151
153
|
*
|
|
152
154
|
* @returns `GraphqlResponseWrapper` with the data type specified in the generic type.
|
|
153
155
|
*
|
|
154
156
|
*/
|
|
155
157
|
useCustomSubscription?: UseCustomSubscriptionFunction;
|
|
158
|
+
/**
|
|
159
|
+
* Returns an object containing the data related to the custom subscription made.
|
|
160
|
+
* This hook is not reactive - Once the data is returned, it doesn't update anymore.
|
|
161
|
+
*
|
|
162
|
+
* @returns `GraphqlResponseWrapper` with the data type specified in the generic type.
|
|
163
|
+
*
|
|
164
|
+
*/
|
|
165
|
+
useCustomQuery?: UseCustomQueryFunction;
|
|
166
|
+
/**
|
|
167
|
+
* Gives developer the ability to manipulate data from bbb using custom mutations.
|
|
168
|
+
* It can only use mutations that already exist in bbb.
|
|
169
|
+
*
|
|
170
|
+
* @returns an array with the trigger function and the result of the mutation.
|
|
171
|
+
*
|
|
172
|
+
*/
|
|
173
|
+
useCustomMutation?: UseCustomMutationFunction;
|
|
156
174
|
/**
|
|
157
175
|
* Returns an array with tha data wrapped in the `GraphqlResponseWrapper` in the first
|
|
158
176
|
* position of the array, the push function with which one plugin can inform
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getter.js","sourceRoot":"","sources":["../../../../../src/core/auxiliary/join-url/getter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,kDAA0D;AAI1D,SAAS,qBAAqB,CAAC,
|
|
1
|
+
{"version":3,"file":"getter.js","sourceRoot":"","sources":["../../../../../src/core/auxiliary/join-url/getter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,kDAA0D;AAI1D,SAAS,qBAAqB,CAAC,UAAqC;IAClE,IAAM,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC;SAC3C,GAAG,CAAC,UAAC,EAAY;YAAX,GAAG,QAAA,EAAE,KAAK,QAAA;QAAM,OAAA,UAAG,kBAAkB,CAAC,GAAG,CAAC,cAAI,kBAAkB,CAAC,KAAK,CAAC,CAAE;IAAzD,CAAyD,CAAC;SAChF,IAAI,CAAC,GAAG,CAAC,CAAC;IACb,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,SAAsB,UAAU,CAAC,UAAqC;;;;;;;oBAC9D,aAAa,GAAG,qBAAqB,CAAC,UAAU,CAAC,CAAC;oBAClD,OAAO,GAAG,CAAA,MAAA,MAAM,CAAC,qBAAqB,0CAAE,MAAM,CAAC,GAAG,CAAC,UAAU,KAAI,gBAAgB,CAAC;oBAClF,GAAG,GAAG,UAAG,OAAO,0CAAgC,IAAA,wBAAe,GAAE,cAAI,aAAa,CAAE,CAAC;oBAC1E,qBAAM,KAAK,CAAC,GAAG,EAAE;4BAChC,WAAW,EAAE,SAAS;yBACvB,CAAC,EAAA;;oBAFI,QAAQ,GAAG,SAEf;oBACkB,qBAAM,QAAQ,CAAC,IAAI,EAAE,EAAA;;oBAAnC,WAAW,GAAG,SAAqB;oBACzC,sBAAO,WAAW,CAAC,QAAQ,CAAC,GAAa,EAAC;;;;CAC3C;AATD,gCASC"}
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import { PluginApi } from '../../../api/types';
|
|
2
|
-
interface UseLocaleMessagesProps {
|
|
2
|
+
export interface UseLocaleMessagesProps {
|
|
3
3
|
pluginApi: PluginApi;
|
|
4
4
|
fetchConfigs?: RequestInit;
|
|
5
5
|
}
|
|
6
|
-
interface PluginInformationResult {
|
|
6
|
+
export interface PluginInformationResult {
|
|
7
7
|
javascriptEntrypointIntegrity: string;
|
|
8
8
|
javascriptEntrypointUrl: string;
|
|
9
9
|
localesBaseUrl: string;
|
|
10
10
|
}
|
|
11
|
-
interface IntlMessages {
|
|
11
|
+
export interface IntlMessages {
|
|
12
12
|
loading: boolean;
|
|
13
13
|
messages: Record<string, string>;
|
|
14
14
|
currentLocale: string;
|
|
15
15
|
}
|
|
16
|
-
type UseLocaleMessagesFunction = (fetchConfigs?: RequestInit) => IntlMessages;
|
|
17
|
-
export
|
|
16
|
+
export type UseLocaleMessagesFunction = (fetchConfigs?: RequestInit) => IntlMessages;
|
|
17
|
+
export interface DataWaitingWrapper<T> {
|
|
18
|
+
data: T;
|
|
19
|
+
loading: boolean;
|
|
20
|
+
error?: object;
|
|
21
|
+
}
|
|
@@ -37,21 +37,18 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
var react_1 = require("react");
|
|
40
|
-
var ui_data_1 = require("../../../../ui-data");
|
|
41
40
|
var utils_1 = require("../../../../utils");
|
|
42
41
|
var utils_2 = require("./utils");
|
|
43
42
|
function useLocaleMessagesAuxiliary(_a) {
|
|
44
43
|
var _this = this;
|
|
45
44
|
var pluginApi = _a.pluginApi, fetchConfigs = _a.fetchConfigs;
|
|
46
|
-
var currentLocale = pluginApi.useUiData(ui_data_1.IntlLocaleUiDataNames.CURRENT_LOCALE, {
|
|
47
|
-
locale: 'en',
|
|
48
|
-
fallbackLocale: 'en',
|
|
49
|
-
});
|
|
50
45
|
var _b = (0, react_1.useState)(true), loading = _b[0], setLoading = _b[1];
|
|
51
46
|
var _c = (0, react_1.useState)({}), messages = _c[0], setMessages = _c[1];
|
|
52
47
|
var _d = (0, react_1.useState)(), fallbackMessages = _d[0], setFallbackMessages = _d[1];
|
|
48
|
+
var localeDataWrapper = (0, utils_2.useGetNormalizedLocale)({ pluginApi: pluginApi, fetchConfigs: fetchConfigs });
|
|
49
|
+
var currentLocale = localeDataWrapper.data;
|
|
53
50
|
(0, react_1.useEffect)(function () {
|
|
54
|
-
if ((pluginApi === null || pluginApi === void 0 ? void 0 : pluginApi.localesBaseUrl) &&
|
|
51
|
+
if ((pluginApi === null || pluginApi === void 0 ? void 0 : pluginApi.localesBaseUrl) && !localeDataWrapper.loading) {
|
|
55
52
|
var localesBaseUrl = pluginApi.localesBaseUrl;
|
|
56
53
|
var locale = currentLocale.locale, fallbackLocale = currentLocale.fallbackLocale;
|
|
57
54
|
var localeUrl = "".concat(localesBaseUrl, "/").concat(locale, ".json");
|
|
@@ -63,7 +60,7 @@ function useLocaleMessagesAuxiliary(_a) {
|
|
|
63
60
|
if (locale !== fallbackLocale)
|
|
64
61
|
urlToFetchList.push(localeUrl);
|
|
65
62
|
Promise.all(urlToFetchList.map(function (url) { return __awaiter(_this, void 0, void 0, function () {
|
|
66
|
-
var
|
|
63
|
+
var err_1;
|
|
67
64
|
return __generator(this, function (_a) {
|
|
68
65
|
switch (_a.label) {
|
|
69
66
|
case 0:
|
|
@@ -72,26 +69,26 @@ function useLocaleMessagesAuxiliary(_a) {
|
|
|
72
69
|
case 1:
|
|
73
70
|
_a.trys.push([1, 3, , 4]);
|
|
74
71
|
return [4 /*yield*/, (0, utils_2.fetchLocaleAndStore)(url, fetchConfigs)];
|
|
75
|
-
case 2:
|
|
76
|
-
a = _a.sent();
|
|
77
|
-
return [2 /*return*/, a];
|
|
72
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
78
73
|
case 3:
|
|
79
74
|
err_1 = _a.sent();
|
|
80
75
|
utils_1.pluginLogger.error("[".concat(pluginApi.pluginName, "] - Something went wrong while trying to fetch [").concat(url, "] or parse its result: "), err_1);
|
|
81
76
|
return [2 /*return*/, Promise.resolve({})];
|
|
82
|
-
case 4:
|
|
77
|
+
case 4:
|
|
78
|
+
// The first of the list is the fallback
|
|
79
|
+
return [2 /*return*/, Promise.resolve(fallbackMessages)];
|
|
83
80
|
}
|
|
84
81
|
});
|
|
85
82
|
}); })).then(function (values) {
|
|
86
|
-
var
|
|
87
|
-
setMessages((0, utils_2.mergeLocaleMessages)(
|
|
83
|
+
var fallbackLocaleMessages = values[0], desiredLocaleMessages = values[1];
|
|
84
|
+
setMessages((0, utils_2.mergeLocaleMessages)(desiredLocaleMessages, fallbackLocaleMessages));
|
|
88
85
|
if (!fallbackMessages)
|
|
89
86
|
setFallbackMessages(fallbackLocaleMessages);
|
|
90
87
|
}).finally(function () {
|
|
91
88
|
setLoading(false);
|
|
92
89
|
});
|
|
93
90
|
}
|
|
94
|
-
}, [
|
|
91
|
+
}, [localeDataWrapper]);
|
|
95
92
|
return {
|
|
96
93
|
messages: messages,
|
|
97
94
|
loading: loading,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocaleMessages.js","sourceRoot":"","sources":["../../../../../../src/core/auxiliary/plugin-information/locale-messages/useLocaleMessages.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAA4C;AAC5C
|
|
1
|
+
{"version":3,"file":"useLocaleMessages.js","sourceRoot":"","sources":["../../../../../../src/core/auxiliary/plugin-information/locale-messages/useLocaleMessages.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAA4C;AAC5C,2CAAiD;AAEjD,iCAA2F;AAE3F,SAAS,0BAA0B,CACjC,EAAmD;IADrD,iBAiDC;QAhDG,SAAS,eAAA,EAAE,YAAY,kBAAA;IAEnB,IAAA,KAAwB,IAAA,gBAAQ,EAAC,IAAI,CAAC,EAArC,OAAO,QAAA,EAAE,UAAU,QAAkB,CAAC;IACvC,IAAA,KAA0B,IAAA,gBAAQ,EAAyB,EAAE,CAAC,EAA7D,QAAQ,QAAA,EAAE,WAAW,QAAwC,CAAC;IAC/D,IAAA,KAA0C,IAAA,gBAAQ,GAA0B,EAA3E,gBAAgB,QAAA,EAAE,mBAAmB,QAAsC,CAAC;IACnF,IAAM,iBAAiB,GAAG,IAAA,8BAAsB,EAAC,EAAE,SAAS,WAAA,EAAE,YAAY,cAA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A2B,MAAM,GAAjC,EAAE,qBAAqB,GAAI,MAAM,GAAV,CAAW;gBAC/D,WAAW,CAAC,IAAA,2BAAmB,EAAC,qBAAqB,EAAE,sBAAsB,CAAC,CAAC,CAAC;gBAChF,IAAI,CAAC,gBAAgB;oBAAE,mBAAmB,CAAC,sBAAsB,CAAC,CAAC;YACrE,CAAC,CAAC,CAAC,OAAO,CAAC;gBACT,UAAU,CAAC,KAAK,CAAC,CAAC;YACpB,CAAC,CAAC,CAAC;SACJ;IACH,CAAC,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAC;IACxB,OAAO;QACL,QAAQ,UAAA;QACR,OAAO,SAAA;QACP,aAAa,EAAE,aAAa,CAAC,MAAM;KACpC,CAAC;AACJ,CAAC;AAED,kBAAe,0BAA0B,CAAC"}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { DataWaitingWrapper, UseLocaleMessagesProps } from './types';
|
|
2
|
+
import { LocaleObject } from '../../../../ui-data/domain/intl/locale/types';
|
|
1
3
|
declare function fetchLocaleAndStore(localeUrl: string, fetchConfigs?: RequestInit): Promise<Record<string, string>>;
|
|
2
4
|
declare function mergeLocaleMessages(desiredMessages: Record<string, string>, fallbackMessages: Record<string, string>): Record<string, string>;
|
|
3
|
-
|
|
5
|
+
declare function useGetLocalesIndex(localeUrl: string | undefined, fetchConfigs?: RequestInit): DataWaitingWrapper<string[]>;
|
|
6
|
+
declare function useGetNormalizedLocale({ pluginApi, fetchConfigs }: UseLocaleMessagesProps): DataWaitingWrapper<LocaleObject>;
|
|
7
|
+
export { fetchLocaleAndStore, mergeLocaleMessages, useGetLocalesIndex, useGetNormalizedLocale, };
|