@tivio/sdk-react 2.1.4 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. package/README.md +8 -0
  2. package/coverage/clover.xml +356 -95
  3. package/coverage/lcov-report/index.html +55 -25
  4. package/coverage/lcov-report/src/components/ContextProvider.tsx.html +194 -0
  5. package/coverage/lcov-report/src/components/TivioProvider.tsx.html +109 -37
  6. package/coverage/lcov-report/src/components/TivioWidgetError.tsx.html +3 -3
  7. package/coverage/lcov-report/src/components/TivioWidgetLoader.tsx.html +3 -3
  8. package/coverage/lcov-report/src/components/context/ChannelsContext.tsx.html +197 -0
  9. package/coverage/lcov-report/src/components/context/OrganizationSubscriptionsContext.tsx.html +179 -0
  10. package/coverage/lcov-report/src/components/context/PurchasesWithVideosContext.tsx.html +179 -0
  11. package/coverage/lcov-report/src/components/context/RowItemsContext.tsx.html +191 -0
  12. package/coverage/lcov-report/src/components/context/ScreensContext.tsx.html +185 -0
  13. package/coverage/lcov-report/src/components/context/SectionsContext.tsx.html +200 -0
  14. package/coverage/lcov-report/src/components/context/UserContext.tsx.html +176 -0
  15. package/coverage/lcov-report/src/components/context/VideosContext.tsx.html +200 -0
  16. package/coverage/lcov-report/src/components/context/index.html +231 -0
  17. package/coverage/lcov-report/src/components/context/index.ts.html +104 -0
  18. package/coverage/lcov-report/src/components/index.html +32 -32
  19. package/coverage/lcov-report/src/conf.ts.html +27 -21
  20. package/coverage/lcov-report/src/index.html +21 -6
  21. package/coverage/lcov-report/src/services/bundleLoader.ts.html +127 -157
  22. package/coverage/lcov-report/src/services/dependencyResolver.ts.html +36 -30
  23. package/coverage/lcov-report/src/services/index.html +102 -42
  24. package/coverage/lcov-report/src/services/logger.ts.html +53 -98
  25. package/coverage/lcov-report/src/services/packageLoader.ts.html +31 -31
  26. package/coverage/lcov-report/src/services/pubSub.ts.html +9 -9
  27. package/coverage/lcov-report/src/services/sentry.ts.html +170 -0
  28. package/coverage/lcov-report/src/services/settings.ts.html +34 -34
  29. package/coverage/lcov-report/src/setupTests.ts.html +9 -9
  30. package/coverage/lcov.info +641 -141
  31. package/dist/components/TivioProvider.d.ts +3 -0
  32. package/dist/components/hooks/usePurchaseSubscription.d.ts +2 -7
  33. package/dist/components/hooks/useTransactionPayment.d.ts +2 -7
  34. package/dist/conf.d.ts +1 -0
  35. package/dist/index.js +1 -2
  36. package/dist/services/dependencyResolver.d.ts +2 -1
  37. package/dist/services/sentry.d.ts +2 -5
  38. package/dist/types.d.ts +5 -13
  39. package/env +0 -0
  40. package/package.json +12 -12
  41. package/scripts/build_dev.sh +3 -0
  42. package/scripts/build_prod.sh +3 -0
  43. package/scripts/postpublish.ts +10 -0
  44. package/scripts/start.sh +3 -0
  45. package/dist/index.js.LICENSE.txt +0 -114
@@ -23,30 +23,30 @@
23
23
  <div class='clearfix'>
24
24
 
25
25
  <div class='fl pad1y space-right2'>
26
- <span class="strong">65.52% </span>
26
+ <span class="strong">75% </span>
27
27
  <span class="quiet">Statements</span>
28
- <span class='fraction'>38/58</span>
28
+ <span class='fraction'>48/64</span>
29
29
  </div>
30
30
 
31
31
 
32
32
  <div class='fl pad1y space-right2'>
33
- <span class="strong">35.71% </span>
33
+ <span class="strong">50% </span>
34
34
  <span class="quiet">Branches</span>
35
- <span class='fraction'>5/14</span>
35
+ <span class='fraction'>9/18</span>
36
36
  </div>
37
37
 
38
38
 
39
39
  <div class='fl pad1y space-right2'>
40
- <span class="strong">70% </span>
40
+ <span class="strong">90.91% </span>
41
41
  <span class="quiet">Functions</span>
42
- <span class='fraction'>7/10</span>
42
+ <span class='fraction'>10/11</span>
43
43
  </div>
44
44
 
45
45
 
46
46
  <div class='fl pad1y space-right2'>
47
- <span class="strong">63.64% </span>
47
+ <span class="strong">75% </span>
48
48
  <span class="quiet">Lines</span>
49
- <span class='fraction'>35/55</span>
49
+ <span class='fraction'>48/64</span>
50
50
  </div>
51
51
 
52
52
 
@@ -253,17 +253,7 @@
253
253
  <a name='L194'></a><a href='#L194'>194</a>
254
254
  <a name='L195'></a><a href='#L195'>195</a>
255
255
  <a name='L196'></a><a href='#L196'>196</a>
256
- <a name='L197'></a><a href='#L197'>197</a>
257
- <a name='L198'></a><a href='#L198'>198</a>
258
- <a name='L199'></a><a href='#L199'>199</a>
259
- <a name='L200'></a><a href='#L200'>200</a>
260
- <a name='L201'></a><a href='#L201'>201</a>
261
- <a name='L202'></a><a href='#L202'>202</a>
262
- <a name='L203'></a><a href='#L203'>203</a>
263
- <a name='L204'></a><a href='#L204'>204</a>
264
- <a name='L205'></a><a href='#L205'>205</a>
265
- <a name='L206'></a><a href='#L206'>206</a>
266
- <a name='L207'></a><a href='#L207'>207</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral">&nbsp;</span>
256
+ <a name='L197'></a><a href='#L197'>197</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral">&nbsp;</span>
267
257
  <span class="cline-any cline-neutral">&nbsp;</span>
268
258
  <span class="cline-any cline-neutral">&nbsp;</span>
269
259
  <span class="cline-any cline-neutral">&nbsp;</span>
@@ -277,26 +267,10 @@
277
267
  <span class="cline-any cline-yes">1x</span>
278
268
  <span class="cline-any cline-neutral">&nbsp;</span>
279
269
  <span class="cline-any cline-neutral">&nbsp;</span>
280
- <span class="cline-any cline-yes">1x</span>
281
- <span class="cline-any cline-yes">1x</span>
282
- <span class="cline-any cline-neutral">&nbsp;</span>
283
- <span class="cline-any cline-neutral">&nbsp;</span>
284
- <span class="cline-any cline-neutral">&nbsp;</span>
285
- <span class="cline-any cline-neutral">&nbsp;</span>
286
- <span class="cline-any cline-neutral">&nbsp;</span>
287
- <span class="cline-any cline-neutral">&nbsp;</span>
288
- <span class="cline-any cline-neutral">&nbsp;</span>
289
- <span class="cline-any cline-neutral">&nbsp;</span>
290
- <span class="cline-any cline-neutral">&nbsp;</span>
291
- <span class="cline-any cline-neutral">&nbsp;</span>
292
- <span class="cline-any cline-neutral">&nbsp;</span>
293
- <span class="cline-any cline-neutral">&nbsp;</span>
294
- <span class="cline-any cline-neutral">&nbsp;</span>
295
- <span class="cline-any cline-neutral">&nbsp;</span>
296
- <span class="cline-any cline-neutral">&nbsp;</span>
297
- <span class="cline-any cline-neutral">&nbsp;</span>
298
270
  <span class="cline-any cline-neutral">&nbsp;</span>
299
271
  <span class="cline-any cline-neutral">&nbsp;</span>
272
+ <span class="cline-any cline-yes">1x</span>
273
+ <span class="cline-any cline-yes">1x</span>
300
274
  <span class="cline-any cline-neutral">&nbsp;</span>
301
275
  <span class="cline-any cline-neutral">&nbsp;</span>
302
276
  <span class="cline-any cline-neutral">&nbsp;</span>
@@ -305,37 +279,43 @@
305
279
  <span class="cline-any cline-neutral">&nbsp;</span>
306
280
  <span class="cline-any cline-neutral">&nbsp;</span>
307
281
  <span class="cline-any cline-neutral">&nbsp;</span>
282
+ <span class="cline-any cline-yes">1x</span>
283
+ <span class="cline-any cline-yes">19x</span>
284
+ <span class="cline-any cline-yes">19x</span>
308
285
  <span class="cline-any cline-neutral">&nbsp;</span>
286
+ <span class="cline-any cline-yes">19x</span>
309
287
  <span class="cline-any cline-neutral">&nbsp;</span>
310
288
  <span class="cline-any cline-neutral">&nbsp;</span>
289
+ <span class="cline-any cline-yes">1x</span>
290
+ <span class="cline-any cline-yes">19x</span>
291
+ <span class="cline-any cline-no">&nbsp;</span>
311
292
  <span class="cline-any cline-neutral">&nbsp;</span>
293
+ <span class="cline-any cline-no">&nbsp;</span>
294
+ <span class="cline-any cline-no">&nbsp;</span>
312
295
  <span class="cline-any cline-neutral">&nbsp;</span>
313
296
  <span class="cline-any cline-neutral">&nbsp;</span>
314
- <span class="cline-any cline-yes">1x</span>
315
- <span class="cline-any cline-yes">12x</span>
316
- <span class="cline-any cline-yes">12x</span>
297
+ <span class="cline-any cline-yes">19x</span>
317
298
  <span class="cline-any cline-neutral">&nbsp;</span>
318
- <span class="cline-any cline-yes">12x</span>
319
299
  <span class="cline-any cline-neutral">&nbsp;</span>
320
300
  <span class="cline-any cline-neutral">&nbsp;</span>
321
301
  <span class="cline-any cline-neutral">&nbsp;</span>
322
302
  <span class="cline-any cline-neutral">&nbsp;</span>
303
+ <span class="cline-any cline-yes">19x</span>
304
+ <span class="cline-any cline-yes">19x</span>
323
305
  <span class="cline-any cline-neutral">&nbsp;</span>
324
- <span class="cline-any cline-yes">12x</span>
325
- <span class="cline-any cline-yes">12x</span>
306
+ <span class="cline-any cline-yes">19x</span>
307
+ <span class="cline-any cline-yes">19x</span>
308
+ <span class="cline-any cline-yes">17x</span>
326
309
  <span class="cline-any cline-neutral">&nbsp;</span>
327
- <span class="cline-any cline-yes">12x</span>
328
- <span class="cline-any cline-yes">12x</span>
329
- <span class="cline-any cline-yes">10x</span>
330
310
  <span class="cline-any cline-neutral">&nbsp;</span>
331
311
  <span class="cline-any cline-yes">2x</span>
332
312
  <span class="cline-any cline-neutral">&nbsp;</span>
333
313
  <span class="cline-any cline-neutral">&nbsp;</span>
334
- <span class="cline-any cline-yes">10x</span>
314
+ <span class="cline-any cline-yes">17x</span>
335
315
  <span class="cline-any cline-yes">2x</span>
336
316
  <span class="cline-any cline-neutral">&nbsp;</span>
337
317
  <span class="cline-any cline-neutral">&nbsp;</span>
338
- <span class="cline-any cline-yes">8x</span>
318
+ <span class="cline-any cline-yes">15x</span>
339
319
  <span class="cline-any cline-neutral">&nbsp;</span>
340
320
  <span class="cline-any cline-neutral">&nbsp;</span>
341
321
  <span class="cline-any cline-neutral">&nbsp;</span>
@@ -343,25 +323,26 @@
343
323
  <span class="cline-any cline-neutral">&nbsp;</span>
344
324
  <span class="cline-any cline-neutral">&nbsp;</span>
345
325
  <span class="cline-any cline-yes">1x</span>
326
+ <span class="cline-any cline-yes">16x</span>
327
+ <span class="cline-any cline-yes">15x</span>
328
+ <span class="cline-any cline-neutral">&nbsp;</span>
329
+ <span class="cline-any cline-yes">14x</span>
346
330
  <span class="cline-any cline-yes">14x</span>
347
- <span class="cline-any cline-yes">8x</span>
348
331
  <span class="cline-any cline-neutral">&nbsp;</span>
349
- <span class="cline-any cline-yes">7x</span>
350
- <span class="cline-any cline-yes">7x</span>
332
+ <span class="cline-any cline-yes">14x</span>
333
+ <span class="cline-any cline-yes">14x</span>
334
+ <span class="cline-any cline-yes">13x</span>
351
335
  <span class="cline-any cline-neutral">&nbsp;</span>
352
- <span class="cline-any cline-yes">7x</span>
353
- <span class="cline-any cline-yes">7x</span>
354
- <span class="cline-any cline-yes">6x</span>
355
336
  <span class="cline-any cline-neutral">&nbsp;</span>
356
337
  <span class="cline-any cline-yes">1x</span>
357
338
  <span class="cline-any cline-neutral">&nbsp;</span>
358
339
  <span class="cline-any cline-neutral">&nbsp;</span>
359
- <span class="cline-any cline-yes">6x</span>
340
+ <span class="cline-any cline-yes">13x</span>
360
341
  <span class="cline-any cline-yes">1x</span>
361
342
  <span class="cline-any cline-neutral">&nbsp;</span>
362
343
  <span class="cline-any cline-neutral">&nbsp;</span>
363
- <span class="cline-any cline-yes">5x</span>
364
- <span class="cline-any cline-yes">5x</span>
344
+ <span class="cline-any cline-yes">12x</span>
345
+ <span class="cline-any cline-yes">12x</span>
365
346
  <span class="cline-any cline-neutral">&nbsp;</span>
366
347
  <span class="cline-any cline-neutral">&nbsp;</span>
367
348
  <span class="cline-any cline-no">&nbsp;</span>
@@ -372,8 +353,6 @@
372
353
  <span class="cline-any cline-no">&nbsp;</span>
373
354
  <span class="cline-any cline-neutral">&nbsp;</span>
374
355
  <span class="cline-any cline-neutral">&nbsp;</span>
375
- <span class="cline-any cline-neutral">&nbsp;</span>
376
- <span class="cline-any cline-neutral">&nbsp;</span>
377
356
  <span class="cline-any cline-no">&nbsp;</span>
378
357
  <span class="cline-any cline-neutral">&nbsp;</span>
379
358
  <span class="cline-any cline-neutral">&nbsp;</span>
@@ -384,11 +363,12 @@
384
363
  <span class="cline-any cline-yes">7x</span>
385
364
  <span class="cline-any cline-neutral">&nbsp;</span>
386
365
  <span class="cline-any cline-yes">7x</span>
387
- <span class="cline-any cline-yes">14x</span>
366
+ <span class="cline-any cline-yes">9x</span>
388
367
  <span class="cline-any cline-neutral">&nbsp;</span>
389
368
  <span class="cline-any cline-neutral">&nbsp;</span>
390
369
  <span class="cline-any cline-neutral">&nbsp;</span>
391
370
  <span class="cline-any cline-neutral">&nbsp;</span>
371
+ <span class="cline-any cline-yes">9x</span>
392
372
  <span class="cline-any cline-neutral">&nbsp;</span>
393
373
  <span class="cline-any cline-neutral">&nbsp;</span>
394
374
  <span class="cline-any cline-neutral">&nbsp;</span>
@@ -397,8 +377,6 @@
397
377
  <span class="cline-any cline-neutral">&nbsp;</span>
398
378
  <span class="cline-any cline-neutral">&nbsp;</span>
399
379
  <span class="cline-any cline-neutral">&nbsp;</span>
400
- <span class="cline-any cline-yes">14x</span>
401
- <span class="cline-any cline-neutral">&nbsp;</span>
402
380
  <span class="cline-any cline-neutral">&nbsp;</span>
403
381
  <span class="cline-any cline-neutral">&nbsp;</span>
404
382
  <span class="cline-any cline-neutral">&nbsp;</span>
@@ -408,13 +386,12 @@
408
386
  <span class="cline-any cline-neutral">&nbsp;</span>
409
387
  <span class="cline-any cline-neutral">&nbsp;</span>
410
388
  <span class="cline-any cline-neutral">&nbsp;</span>
411
- <span class="cline-any cline-neutral">&nbsp;</span>
412
- <span class="cline-any cline-no">&nbsp;</span>
413
- <span class="cline-any cline-no">&nbsp;</span>
389
+ <span class="cline-any cline-yes">9x</span>
390
+ <span class="cline-any cline-yes">7x</span>
414
391
  <span class="cline-any cline-no">&nbsp;</span>
415
392
  <span class="cline-any cline-neutral">&nbsp;</span>
416
393
  <span class="cline-any cline-neutral">&nbsp;</span>
417
- <span class="cline-any cline-no">&nbsp;</span>
394
+ <span class="cline-any cline-yes">7x</span>
418
395
  <span class="cline-any cline-neutral">&nbsp;</span>
419
396
  <span class="cline-any cline-no">&nbsp;</span>
420
397
  <span class="cline-any cline-no">&nbsp;</span>
@@ -435,34 +412,37 @@
435
412
  <span class="cline-any cline-neutral">&nbsp;</span>
436
413
  <span class="cline-any cline-neutral">&nbsp;</span>
437
414
  <span class="cline-any cline-neutral">&nbsp;</span>
438
- <span class="cline-any cline-no">&nbsp;</span>
439
- <span class="cline-any cline-no">&nbsp;</span>
440
415
  <span class="cline-any cline-neutral">&nbsp;</span>
441
416
  <span class="cline-any cline-neutral">&nbsp;</span>
442
- <span class="cline-any cline-no">&nbsp;</span>
443
417
  <span class="cline-any cline-neutral">&nbsp;</span>
444
- <span class="cline-any cline-no">&nbsp;</span>
445
418
  <span class="cline-any cline-neutral">&nbsp;</span>
446
419
  <span class="cline-any cline-neutral">&nbsp;</span>
447
420
  <span class="cline-any cline-neutral">&nbsp;</span>
421
+ <span class="cline-any cline-no">&nbsp;</span>
422
+ <span class="cline-any cline-no">&nbsp;</span>
448
423
  <span class="cline-any cline-neutral">&nbsp;</span>
449
424
  <span class="cline-any cline-neutral">&nbsp;</span>
425
+ <span class="cline-any cline-yes">7x</span>
450
426
  <span class="cline-any cline-neutral">&nbsp;</span>
427
+ <span class="cline-any cline-yes">2x</span>
451
428
  <span class="cline-any cline-neutral">&nbsp;</span>
452
429
  <span class="cline-any cline-neutral">&nbsp;</span>
453
430
  <span class="cline-any cline-neutral">&nbsp;</span>
454
431
  <span class="cline-any cline-neutral">&nbsp;</span>
455
- <span class="cline-any cline-no">&nbsp;</span>
456
432
  <span class="cline-any cline-neutral">&nbsp;</span>
457
433
  <span class="cline-any cline-neutral">&nbsp;</span>
434
+ <span class="cline-any cline-yes">2x</span>
458
435
  <span class="cline-any cline-neutral">&nbsp;</span>
459
- <span class="cline-any cline-no">&nbsp;</span>
460
436
  <span class="cline-any cline-neutral">&nbsp;</span>
461
437
  <span class="cline-any cline-neutral">&nbsp;</span>
438
+ <span class="cline-any cline-yes">9x</span>
462
439
  <span class="cline-any cline-neutral">&nbsp;</span>
463
440
  <span class="cline-any cline-neutral">&nbsp;</span>
464
441
  <span class="cline-any cline-neutral">&nbsp;</span>
465
442
  <span class="cline-any cline-neutral">&nbsp;</span>
443
+ <span class="cline-any cline-yes">1x</span>
444
+ <span class="cline-any cline-yes">1x</span>
445
+ <span class="cline-any cline-yes">1x</span>
466
446
  <span class="cline-any cline-neutral">&nbsp;</span>
467
447
  <span class="cline-any cline-neutral">&nbsp;</span>
468
448
  <span class="cline-any cline-neutral">&nbsp;</span>
@@ -483,45 +463,34 @@
483
463
  import { useEffect, useState } from 'react'
484
464
  &nbsp;
485
465
  import { InternalConf } from '../conf'
466
+ &nbsp;
467
+ import { Nullable, TivioBundle } from '../types'
486
468
  import { resolveShared } from './dependencyResolver'
487
469
  import { createSettings, Settings } from './settings'
488
470
  &nbsp;
489
- import type {
490
- Conf,
491
- TivioComponents,
492
- TivioSources,
493
- TivioSubscriptions,
494
- TivioGetters,
495
- } from '../types'
496
- import { Language } from '../types'
497
- &nbsp;
498
- export type TivioBundle = {
499
- init: (config: Conf) =&gt; void | Promise&lt;void&gt;
500
- setUser: (userId: string, userPayload?: unknown) =&gt; void
501
- setLanguage: (language: Language) =&gt; void
502
- components: TivioComponents
503
- sources: TivioSources
504
- subscriptions: TivioSubscriptions
505
- getters: TivioGetters
506
- }
507
- &nbsp;
508
- export type RemoteBundleState = {
509
- state: 'loading' | 'error' | 'ready'
510
- error: string | null
511
- setLanguage: ((language: Language) =&gt; void) | null
471
+ type RemoteBundleState = {
512
472
  conf: InternalConf
473
+ error: string | null
513
474
  settings: Settings
514
- components: TivioComponents | null
515
- sources: TivioSources | null
516
- subscriptions: TivioSubscriptions | null
517
- getters: TivioGetters | null
518
- }
475
+ state: 'loading' | 'error' | 'ready'
476
+ } &amp; Nullable&lt;TivioBundle&gt;
519
477
  &nbsp;
520
- export const fetchResolver = async (conf: InternalConf): Promise&lt;string&gt; =&gt; {
478
+ const fetchResolver = (conf: InternalConf) =&gt; {
521
479
  const resolverUrl = conf.resolverUrl
522
480
  const fetchPackage = conf.fetchPackage
523
481
  &nbsp;
524
482
  return fetchPackage(resolverUrl)
483
+ }
484
+ &nbsp;
485
+ const fetchBundle = async (secret: string, conf: InternalConf): Promise&lt;string&gt; =&gt; {
486
+ <span class="missing-if-branch" title="if path not taken" >I</span>if (conf.bundleUrlOverride) {
487
+ <span class="cstat-no" title="statement not covered" > console.info('@tivio: Fetching bundle directly based on config.bundleUrlOverride', conf.bundleUrlOverride)</span>
488
+ &nbsp;
489
+ const source = <span class="cstat-no" title="statement not covered" >await (await fetch(conf.bundleUrlOverride)).text()</span>
490
+ <span class="cstat-no" title="statement not covered" > return source</span>
491
+ }
492
+ &nbsp;
493
+ return fetchResolver(conf)
525
494
  .then((source: string) =&gt; {
526
495
  const exports: {
527
496
  tivio?: {
@@ -533,7 +502,8 @@ export const fetchResolver = async (conf: InternalConf): Promise&lt;string&gt; =
533
502
  try {
534
503
  const fn = new Function('require', 'module', 'exports', source)
535
504
  fn(resolveShared, module, exports)
536
- } catch (error) {
505
+ }
506
+ catch (error) {
537
507
  return Promise.reject(`Cannot load Tivio Resolver ${error}`)
538
508
  }
539
509
  &nbsp;
@@ -541,16 +511,16 @@ export const fetchResolver = async (conf: InternalConf): Promise&lt;string&gt; =
541
511
  return Promise.reject('Invalid Tivio Resolver export')
542
512
  }
543
513
  &nbsp;
544
- return module.exports.tivio.fetch(conf.secret, conf.sdkVersion)
514
+ return module.exports.tivio.fetch(secret, conf.sdkVersion)
545
515
  })
546
516
  }
547
517
  &nbsp;
548
518
  /**
549
519
  * Fetch &amp; load CommonJS remote module.
550
520
  */
551
- export const createRemotePackageLoader = () =&gt; {
552
- return async (conf: InternalConf): Promise&lt;TivioBundle&gt; =&gt; {
553
- return fetchResolver(conf)
521
+ const createRemotePackageLoader = () =&gt; {
522
+ return async (secret: string, conf: InternalConf): Promise&lt;TivioBundle&gt; =&gt; {
523
+ return fetchBundle(secret, conf)
554
524
  .then((source: string) =&gt; {
555
525
  const exports: { Tivio?: TivioBundle } = {}
556
526
  const module = { exports }
@@ -558,7 +528,8 @@ export const createRemotePackageLoader = () =&gt; {
558
528
  try {
559
529
  const fn = new Function('require', 'module', 'exports', source)
560
530
  fn(resolveShared, module, exports)
561
- } catch (error) {
531
+ }
532
+ catch (error) {
562
533
  return Promise.reject(`Cannot load module ${error}`)
563
534
  }
564
535
  &nbsp;
@@ -577,15 +548,13 @@ export const createRemotePackageLoader = () =&gt; {
577
548
  <span class="cstat-no" title="statement not covered" > if (typeof module.exports.Tivio.init !== 'function') {</span>
578
549
  <span class="cstat-no" title="statement not covered" > return Promise.reject('Tivio namespace does not export "init" member')</span>
579
550
  }
580
- &nbsp;
581
- // console.error('Tivio bundle', module.exports.Tivio)
582
551
  &nbsp;
583
552
  <span class="cstat-no" title="statement not covered" > return module.exports.Tivio</span>
584
553
  })
585
554
  }
586
555
  }
587
556
  &nbsp;
588
- export const createUseRemoteBundle = (): ((conf: InternalConf) =&gt; RemoteBundleState) =&gt; {
557
+ const createUseRemoteBundle = (): ((conf: InternalConf) =&gt; RemoteBundleState) =&gt; {
589
558
  const loadPackage = createRemotePackageLoader()
590
559
  let isBundleInitialized = false
591
560
  &nbsp;
@@ -593,88 +562,89 @@ export const createUseRemoteBundle = (): ((conf: InternalConf) =&gt; RemoteBundl
593
562
  const settings = createSettings(conf)
594
563
  &nbsp;
595
564
  const [
596
- {
597
- state,
598
- error,
599
- components,
600
- setLanguage,
601
- sources,
602
- subscriptions,
603
- getters,
604
- },
565
+ bundle,
605
566
  setState,
606
567
  ] = useState&lt;RemoteBundleState&gt;({
607
- state: 'loading',
608
- error: null,
568
+ auth: null,
609
569
  components: null,
610
- sources: null,
611
- setLanguage: null,
612
570
  conf,
571
+ error: null,
572
+ getters: null,
573
+ init: null,
574
+ purchaseSubscriptionWithQerko: null,
575
+ purchaseVideoWithQerko: null,
576
+ setLanguage: null,
613
577
  settings,
578
+ setUser: null,
579
+ sources: null,
580
+ hooks: null,
581
+ state: 'loading',
614
582
  subscriptions: null,
615
- getters: null,
616
583
  })
617
584
  &nbsp;
618
- <span class="cstat-no" title="statement not covered" > useEffect(<span class="fstat-no" title="function not covered" >() =</span>&gt; {</span>
619
- <span class="cstat-no" title="statement not covered" > if (conf.enable === false) {</span>
585
+ useEffect(() =&gt; {
586
+ <span class="missing-if-branch" title="if path not taken" >I</span>if (conf.secret == null || conf.enable === false) {
620
587
  <span class="cstat-no" title="statement not covered" > return</span>
621
588
  }
622
589
  &nbsp;
623
- <span class="cstat-no" title="statement not covered" > loadPackage(conf)</span>
624
- .then(<span class="fstat-no" title="function not covered" >(b</span>undle) =&gt; {
590
+ loadPackage(conf.secret, conf)
591
+ .then(<span class="fstat-no" title="function not covered" >async </span>(bundle) =&gt; {
625
592
  <span class="cstat-no" title="statement not covered" > if (!isBundleInitialized) {</span>
626
- <span class="cstat-no" title="statement not covered" > bundle.init(conf)</span>
593
+ <span class="cstat-no" title="statement not covered" > await bundle.init(conf)</span>
627
594
  <span class="cstat-no" title="statement not covered" > isBundleInitialized = true</span>
628
595
  }
629
596
  &nbsp;
630
597
  <span class="cstat-no" title="statement not covered" > settings.onSetUser(bundle.setUser)</span>
631
598
  &nbsp;
632
599
  const remoteBundleState: RemoteBundleState = <span class="cstat-no" title="statement not covered" >{</span>
633
- state: 'ready',
600
+ auth: bundle.auth,
601
+ components: bundle.components,
602
+ conf,
634
603
  error: null,
604
+ getters: bundle.getters,
605
+ init: bundle.init,
606
+ purchaseSubscriptionWithQerko: bundle.purchaseSubscriptionWithQerko,
607
+ purchaseVideoWithQerko: bundle.purchaseVideoWithQerko,
635
608
  setLanguage: bundle.setLanguage,
636
- components: bundle.components,
609
+ settings,
610
+ setUser: bundle.setUser,
637
611
  sources: bundle.sources,
612
+ hooks: bundle.hooks,
613
+ state: 'ready',
638
614
  subscriptions: bundle.subscriptions,
639
- getters: bundle.getters,
640
- conf,
641
- settings,
642
615
  }
643
616
  &nbsp;
644
617
  <span class="cstat-no" title="statement not covered" > setState(remoteBundleState)</span>
645
618
  <span class="cstat-no" title="statement not covered" > conf.pubSub.publish('on-ready', remoteBundleState)</span>
646
619
  })
647
- .catch(<span class="fstat-no" title="function not covered" >(e</span>rror: Error) =&gt; {
648
- <span class="cstat-no" title="statement not covered" > conf.logger?.exception(error)</span>
620
+ .catch((error: Error) =&gt; {
621
+ conf.logger?.exception(error)
649
622
  &nbsp;
650
- <span class="cstat-no" title="statement not covered" > setState({</span>
651
- state: 'error',
652
- error: `${error}`,
653
- setLanguage: null,
654
- components: null,
655
- sources: null,
656
- subscriptions: null,
657
- getters: null,
623
+ setState({
624
+ ...bundle,
658
625
  conf,
626
+ error: `${error}`,
659
627
  settings,
628
+ state: 'error',
660
629
  })
661
- <span class="cstat-no" title="statement not covered" > conf.pubSub.publish('on-error', error)</span>
630
+ conf.pubSub.publish('on-error', error)
662
631
  })
663
632
  }, [])
664
633
  &nbsp;
665
- <span class="cstat-no" title="statement not covered" > return {</span>
666
- state,
667
- error,
668
- setLanguage,
669
- components,
670
- sources,
671
- conf,
672
- settings,
673
- subscriptions,
674
- getters: getters,
675
- }
634
+ return bundle
676
635
  }
677
636
  }
637
+ &nbsp;
638
+ export {
639
+ fetchBundle,
640
+ createRemotePackageLoader,
641
+ createUseRemoteBundle,
642
+ }
643
+ &nbsp;
644
+ export type { TivioBundle } from '../types'
645
+ export type {
646
+ RemoteBundleState,
647
+ }
678
648
  &nbsp;</pre></td></tr></table></pre>
679
649
 
680
650
  <div class='push'></div><!-- for sticky footer -->
@@ -682,7 +652,7 @@ export const createUseRemoteBundle = (): ((conf: InternalConf) =&gt; RemoteBundl
682
652
  <div class='footer quiet pad2 space-top1 center small'>
683
653
  Code coverage generated by
684
654
  <a href="https://istanbul.js.org/" target="_blank">istanbul</a>
685
- at Thu May 06 2021 13:19:37 GMT+0200 (Central European Summer Time)
655
+ at Sat Oct 23 2021 10:01:51 GMT+0200 (Central European Summer Time)
686
656
  </div>
687
657
  </div>
688
658
  <script src="../../prettify.js"></script>