@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.
- package/README.md +8 -0
- package/coverage/clover.xml +356 -95
- package/coverage/lcov-report/index.html +55 -25
- package/coverage/lcov-report/src/components/ContextProvider.tsx.html +194 -0
- package/coverage/lcov-report/src/components/TivioProvider.tsx.html +109 -37
- package/coverage/lcov-report/src/components/TivioWidgetError.tsx.html +3 -3
- package/coverage/lcov-report/src/components/TivioWidgetLoader.tsx.html +3 -3
- package/coverage/lcov-report/src/components/context/ChannelsContext.tsx.html +197 -0
- package/coverage/lcov-report/src/components/context/OrganizationSubscriptionsContext.tsx.html +179 -0
- package/coverage/lcov-report/src/components/context/PurchasesWithVideosContext.tsx.html +179 -0
- package/coverage/lcov-report/src/components/context/RowItemsContext.tsx.html +191 -0
- package/coverage/lcov-report/src/components/context/ScreensContext.tsx.html +185 -0
- package/coverage/lcov-report/src/components/context/SectionsContext.tsx.html +200 -0
- package/coverage/lcov-report/src/components/context/UserContext.tsx.html +176 -0
- package/coverage/lcov-report/src/components/context/VideosContext.tsx.html +200 -0
- package/coverage/lcov-report/src/components/context/index.html +231 -0
- package/coverage/lcov-report/src/components/context/index.ts.html +104 -0
- package/coverage/lcov-report/src/components/index.html +32 -32
- package/coverage/lcov-report/src/conf.ts.html +27 -21
- package/coverage/lcov-report/src/index.html +21 -6
- package/coverage/lcov-report/src/services/bundleLoader.ts.html +127 -157
- package/coverage/lcov-report/src/services/dependencyResolver.ts.html +36 -30
- package/coverage/lcov-report/src/services/index.html +102 -42
- package/coverage/lcov-report/src/services/logger.ts.html +53 -98
- package/coverage/lcov-report/src/services/packageLoader.ts.html +31 -31
- package/coverage/lcov-report/src/services/pubSub.ts.html +9 -9
- package/coverage/lcov-report/src/services/sentry.ts.html +170 -0
- package/coverage/lcov-report/src/services/settings.ts.html +34 -34
- package/coverage/lcov-report/src/setupTests.ts.html +9 -9
- package/coverage/lcov.info +641 -141
- package/dist/components/TivioProvider.d.ts +3 -0
- package/dist/components/hooks/usePurchaseSubscription.d.ts +2 -7
- package/dist/components/hooks/useTransactionPayment.d.ts +2 -7
- package/dist/conf.d.ts +1 -0
- package/dist/index.js +1 -2
- package/dist/services/dependencyResolver.d.ts +2 -1
- package/dist/services/sentry.d.ts +2 -5
- package/dist/types.d.ts +5 -13
- package/env +0 -0
- package/package.json +12 -12
- package/scripts/build_dev.sh +3 -0
- package/scripts/build_prod.sh +3 -0
- package/scripts/postpublish.ts +10 -0
- package/scripts/start.sh +3 -0
- 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">
|
26
|
+
<span class="strong">75% </span>
|
27
27
|
<span class="quiet">Statements</span>
|
28
|
-
<span class='fraction'>
|
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">
|
33
|
+
<span class="strong">50% </span>
|
34
34
|
<span class="quiet">Branches</span>
|
35
|
-
<span class='fraction'>
|
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">
|
40
|
+
<span class="strong">90.91% </span>
|
41
41
|
<span class="quiet">Functions</span>
|
42
|
-
<span class='fraction'>
|
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">
|
47
|
+
<span class="strong">75% </span>
|
48
48
|
<span class="quiet">Lines</span>
|
49
|
-
<span class='fraction'>
|
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"> </span>
|
256
|
+
<a name='L197'></a><a href='#L197'>197</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span>
|
267
257
|
<span class="cline-any cline-neutral"> </span>
|
268
258
|
<span class="cline-any cline-neutral"> </span>
|
269
259
|
<span class="cline-any cline-neutral"> </span>
|
@@ -277,26 +267,10 @@
|
|
277
267
|
<span class="cline-any cline-yes">1x</span>
|
278
268
|
<span class="cline-any cline-neutral"> </span>
|
279
269
|
<span class="cline-any cline-neutral"> </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"> </span>
|
283
|
-
<span class="cline-any cline-neutral"> </span>
|
284
|
-
<span class="cline-any cline-neutral"> </span>
|
285
|
-
<span class="cline-any cline-neutral"> </span>
|
286
|
-
<span class="cline-any cline-neutral"> </span>
|
287
|
-
<span class="cline-any cline-neutral"> </span>
|
288
|
-
<span class="cline-any cline-neutral"> </span>
|
289
|
-
<span class="cline-any cline-neutral"> </span>
|
290
|
-
<span class="cline-any cline-neutral"> </span>
|
291
|
-
<span class="cline-any cline-neutral"> </span>
|
292
|
-
<span class="cline-any cline-neutral"> </span>
|
293
|
-
<span class="cline-any cline-neutral"> </span>
|
294
|
-
<span class="cline-any cline-neutral"> </span>
|
295
|
-
<span class="cline-any cline-neutral"> </span>
|
296
|
-
<span class="cline-any cline-neutral"> </span>
|
297
|
-
<span class="cline-any cline-neutral"> </span>
|
298
270
|
<span class="cline-any cline-neutral"> </span>
|
299
271
|
<span class="cline-any cline-neutral"> </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"> </span>
|
301
275
|
<span class="cline-any cline-neutral"> </span>
|
302
276
|
<span class="cline-any cline-neutral"> </span>
|
@@ -305,37 +279,43 @@
|
|
305
279
|
<span class="cline-any cline-neutral"> </span>
|
306
280
|
<span class="cline-any cline-neutral"> </span>
|
307
281
|
<span class="cline-any cline-neutral"> </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"> </span>
|
286
|
+
<span class="cline-any cline-yes">19x</span>
|
309
287
|
<span class="cline-any cline-neutral"> </span>
|
310
288
|
<span class="cline-any cline-neutral"> </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"> </span>
|
311
292
|
<span class="cline-any cline-neutral"> </span>
|
293
|
+
<span class="cline-any cline-no"> </span>
|
294
|
+
<span class="cline-any cline-no"> </span>
|
312
295
|
<span class="cline-any cline-neutral"> </span>
|
313
296
|
<span class="cline-any cline-neutral"> </span>
|
314
|
-
<span class="cline-any cline-yes">
|
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"> </span>
|
318
|
-
<span class="cline-any cline-yes">12x</span>
|
319
299
|
<span class="cline-any cline-neutral"> </span>
|
320
300
|
<span class="cline-any cline-neutral"> </span>
|
321
301
|
<span class="cline-any cline-neutral"> </span>
|
322
302
|
<span class="cline-any cline-neutral"> </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"> </span>
|
324
|
-
<span class="cline-any cline-yes">
|
325
|
-
<span class="cline-any cline-yes">
|
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"> </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"> </span>
|
331
311
|
<span class="cline-any cline-yes">2x</span>
|
332
312
|
<span class="cline-any cline-neutral"> </span>
|
333
313
|
<span class="cline-any cline-neutral"> </span>
|
334
|
-
<span class="cline-any cline-yes">
|
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"> </span>
|
337
317
|
<span class="cline-any cline-neutral"> </span>
|
338
|
-
<span class="cline-any cline-yes">
|
318
|
+
<span class="cline-any cline-yes">15x</span>
|
339
319
|
<span class="cline-any cline-neutral"> </span>
|
340
320
|
<span class="cline-any cline-neutral"> </span>
|
341
321
|
<span class="cline-any cline-neutral"> </span>
|
@@ -343,25 +323,26 @@
|
|
343
323
|
<span class="cline-any cline-neutral"> </span>
|
344
324
|
<span class="cline-any cline-neutral"> </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"> </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"> </span>
|
349
|
-
<span class="cline-any cline-yes">
|
350
|
-
<span class="cline-any cline-yes">
|
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"> </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"> </span>
|
356
337
|
<span class="cline-any cline-yes">1x</span>
|
357
338
|
<span class="cline-any cline-neutral"> </span>
|
358
339
|
<span class="cline-any cline-neutral"> </span>
|
359
|
-
<span class="cline-any cline-yes">
|
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"> </span>
|
362
343
|
<span class="cline-any cline-neutral"> </span>
|
363
|
-
<span class="cline-any cline-yes">
|
364
|
-
<span class="cline-any cline-yes">
|
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"> </span>
|
366
347
|
<span class="cline-any cline-neutral"> </span>
|
367
348
|
<span class="cline-any cline-no"> </span>
|
@@ -372,8 +353,6 @@
|
|
372
353
|
<span class="cline-any cline-no"> </span>
|
373
354
|
<span class="cline-any cline-neutral"> </span>
|
374
355
|
<span class="cline-any cline-neutral"> </span>
|
375
|
-
<span class="cline-any cline-neutral"> </span>
|
376
|
-
<span class="cline-any cline-neutral"> </span>
|
377
356
|
<span class="cline-any cline-no"> </span>
|
378
357
|
<span class="cline-any cline-neutral"> </span>
|
379
358
|
<span class="cline-any cline-neutral"> </span>
|
@@ -384,11 +363,12 @@
|
|
384
363
|
<span class="cline-any cline-yes">7x</span>
|
385
364
|
<span class="cline-any cline-neutral"> </span>
|
386
365
|
<span class="cline-any cline-yes">7x</span>
|
387
|
-
<span class="cline-any cline-yes">
|
366
|
+
<span class="cline-any cline-yes">9x</span>
|
388
367
|
<span class="cline-any cline-neutral"> </span>
|
389
368
|
<span class="cline-any cline-neutral"> </span>
|
390
369
|
<span class="cline-any cline-neutral"> </span>
|
391
370
|
<span class="cline-any cline-neutral"> </span>
|
371
|
+
<span class="cline-any cline-yes">9x</span>
|
392
372
|
<span class="cline-any cline-neutral"> </span>
|
393
373
|
<span class="cline-any cline-neutral"> </span>
|
394
374
|
<span class="cline-any cline-neutral"> </span>
|
@@ -397,8 +377,6 @@
|
|
397
377
|
<span class="cline-any cline-neutral"> </span>
|
398
378
|
<span class="cline-any cline-neutral"> </span>
|
399
379
|
<span class="cline-any cline-neutral"> </span>
|
400
|
-
<span class="cline-any cline-yes">14x</span>
|
401
|
-
<span class="cline-any cline-neutral"> </span>
|
402
380
|
<span class="cline-any cline-neutral"> </span>
|
403
381
|
<span class="cline-any cline-neutral"> </span>
|
404
382
|
<span class="cline-any cline-neutral"> </span>
|
@@ -408,13 +386,12 @@
|
|
408
386
|
<span class="cline-any cline-neutral"> </span>
|
409
387
|
<span class="cline-any cline-neutral"> </span>
|
410
388
|
<span class="cline-any cline-neutral"> </span>
|
411
|
-
<span class="cline-any cline-
|
412
|
-
<span class="cline-any cline-
|
413
|
-
<span class="cline-any cline-no"> </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"> </span>
|
415
392
|
<span class="cline-any cline-neutral"> </span>
|
416
393
|
<span class="cline-any cline-neutral"> </span>
|
417
|
-
<span class="cline-any cline-
|
394
|
+
<span class="cline-any cline-yes">7x</span>
|
418
395
|
<span class="cline-any cline-neutral"> </span>
|
419
396
|
<span class="cline-any cline-no"> </span>
|
420
397
|
<span class="cline-any cline-no"> </span>
|
@@ -435,34 +412,37 @@
|
|
435
412
|
<span class="cline-any cline-neutral"> </span>
|
436
413
|
<span class="cline-any cline-neutral"> </span>
|
437
414
|
<span class="cline-any cline-neutral"> </span>
|
438
|
-
<span class="cline-any cline-no"> </span>
|
439
|
-
<span class="cline-any cline-no"> </span>
|
440
415
|
<span class="cline-any cline-neutral"> </span>
|
441
416
|
<span class="cline-any cline-neutral"> </span>
|
442
|
-
<span class="cline-any cline-no"> </span>
|
443
417
|
<span class="cline-any cline-neutral"> </span>
|
444
|
-
<span class="cline-any cline-no"> </span>
|
445
418
|
<span class="cline-any cline-neutral"> </span>
|
446
419
|
<span class="cline-any cline-neutral"> </span>
|
447
420
|
<span class="cline-any cline-neutral"> </span>
|
421
|
+
<span class="cline-any cline-no"> </span>
|
422
|
+
<span class="cline-any cline-no"> </span>
|
448
423
|
<span class="cline-any cline-neutral"> </span>
|
449
424
|
<span class="cline-any cline-neutral"> </span>
|
425
|
+
<span class="cline-any cline-yes">7x</span>
|
450
426
|
<span class="cline-any cline-neutral"> </span>
|
427
|
+
<span class="cline-any cline-yes">2x</span>
|
451
428
|
<span class="cline-any cline-neutral"> </span>
|
452
429
|
<span class="cline-any cline-neutral"> </span>
|
453
430
|
<span class="cline-any cline-neutral"> </span>
|
454
431
|
<span class="cline-any cline-neutral"> </span>
|
455
|
-
<span class="cline-any cline-no"> </span>
|
456
432
|
<span class="cline-any cline-neutral"> </span>
|
457
433
|
<span class="cline-any cline-neutral"> </span>
|
434
|
+
<span class="cline-any cline-yes">2x</span>
|
458
435
|
<span class="cline-any cline-neutral"> </span>
|
459
|
-
<span class="cline-any cline-no"> </span>
|
460
436
|
<span class="cline-any cline-neutral"> </span>
|
461
437
|
<span class="cline-any cline-neutral"> </span>
|
438
|
+
<span class="cline-any cline-yes">9x</span>
|
462
439
|
<span class="cline-any cline-neutral"> </span>
|
463
440
|
<span class="cline-any cline-neutral"> </span>
|
464
441
|
<span class="cline-any cline-neutral"> </span>
|
465
442
|
<span class="cline-any cline-neutral"> </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"> </span>
|
467
447
|
<span class="cline-any cline-neutral"> </span>
|
468
448
|
<span class="cline-any cline-neutral"> </span>
|
@@ -483,45 +463,34 @@
|
|
483
463
|
import { useEffect, useState } from 'react'
|
484
464
|
|
485
465
|
import { InternalConf } from '../conf'
|
466
|
+
|
467
|
+
import { Nullable, TivioBundle } from '../types'
|
486
468
|
import { resolveShared } from './dependencyResolver'
|
487
469
|
import { createSettings, Settings } from './settings'
|
488
470
|
|
489
|
-
|
490
|
-
Conf,
|
491
|
-
TivioComponents,
|
492
|
-
TivioSources,
|
493
|
-
TivioSubscriptions,
|
494
|
-
TivioGetters,
|
495
|
-
} from '../types'
|
496
|
-
import { Language } from '../types'
|
497
|
-
|
498
|
-
export type TivioBundle = {
|
499
|
-
init: (config: Conf) => void | Promise<void>
|
500
|
-
setUser: (userId: string, userPayload?: unknown) => void
|
501
|
-
setLanguage: (language: Language) => void
|
502
|
-
components: TivioComponents
|
503
|
-
sources: TivioSources
|
504
|
-
subscriptions: TivioSubscriptions
|
505
|
-
getters: TivioGetters
|
506
|
-
}
|
507
|
-
|
508
|
-
export type RemoteBundleState = {
|
509
|
-
state: 'loading' | 'error' | 'ready'
|
510
|
-
error: string | null
|
511
|
-
setLanguage: ((language: Language) => void) | null
|
471
|
+
type RemoteBundleState = {
|
512
472
|
conf: InternalConf
|
473
|
+
error: string | null
|
513
474
|
settings: Settings
|
514
|
-
|
515
|
-
|
516
|
-
subscriptions: TivioSubscriptions | null
|
517
|
-
getters: TivioGetters | null
|
518
|
-
}
|
475
|
+
state: 'loading' | 'error' | 'ready'
|
476
|
+
} & Nullable<TivioBundle>
|
519
477
|
|
520
|
-
|
478
|
+
const fetchResolver = (conf: InternalConf) => {
|
521
479
|
const resolverUrl = conf.resolverUrl
|
522
480
|
const fetchPackage = conf.fetchPackage
|
523
481
|
|
524
482
|
return fetchPackage(resolverUrl)
|
483
|
+
}
|
484
|
+
|
485
|
+
const fetchBundle = async (secret: string, conf: InternalConf): Promise<string> => {
|
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
|
+
|
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
|
+
|
493
|
+
return fetchResolver(conf)
|
525
494
|
.then((source: string) => {
|
526
495
|
const exports: {
|
527
496
|
tivio?: {
|
@@ -533,7 +502,8 @@ export const fetchResolver = async (conf: InternalConf): Promise<string> =
|
|
533
502
|
try {
|
534
503
|
const fn = new Function('require', 'module', 'exports', source)
|
535
504
|
fn(resolveShared, module, exports)
|
536
|
-
}
|
505
|
+
}
|
506
|
+
catch (error) {
|
537
507
|
return Promise.reject(`Cannot load Tivio Resolver ${error}`)
|
538
508
|
}
|
539
509
|
|
@@ -541,16 +511,16 @@ export const fetchResolver = async (conf: InternalConf): Promise<string> =
|
|
541
511
|
return Promise.reject('Invalid Tivio Resolver export')
|
542
512
|
}
|
543
513
|
|
544
|
-
return module.exports.tivio.fetch(
|
514
|
+
return module.exports.tivio.fetch(secret, conf.sdkVersion)
|
545
515
|
})
|
546
516
|
}
|
547
517
|
|
548
518
|
/**
|
549
519
|
* Fetch & load CommonJS remote module.
|
550
520
|
*/
|
551
|
-
|
552
|
-
return async (conf: InternalConf): Promise<TivioBundle> => {
|
553
|
-
return
|
521
|
+
const createRemotePackageLoader = () => {
|
522
|
+
return async (secret: string, conf: InternalConf): Promise<TivioBundle> => {
|
523
|
+
return fetchBundle(secret, conf)
|
554
524
|
.then((source: string) => {
|
555
525
|
const exports: { Tivio?: TivioBundle } = {}
|
556
526
|
const module = { exports }
|
@@ -558,7 +528,8 @@ export const createRemotePackageLoader = () => {
|
|
558
528
|
try {
|
559
529
|
const fn = new Function('require', 'module', 'exports', source)
|
560
530
|
fn(resolveShared, module, exports)
|
561
|
-
}
|
531
|
+
}
|
532
|
+
catch (error) {
|
562
533
|
return Promise.reject(`Cannot load module ${error}`)
|
563
534
|
}
|
564
535
|
|
@@ -577,15 +548,13 @@ export const createRemotePackageLoader = () => {
|
|
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
|
-
|
581
|
-
// console.error('Tivio bundle', module.exports.Tivio)
|
582
551
|
|
583
552
|
<span class="cstat-no" title="statement not covered" > return module.exports.Tivio</span>
|
584
553
|
})
|
585
554
|
}
|
586
555
|
}
|
587
556
|
|
588
|
-
|
557
|
+
const createUseRemoteBundle = (): ((conf: InternalConf) => RemoteBundleState) => {
|
589
558
|
const loadPackage = createRemotePackageLoader()
|
590
559
|
let isBundleInitialized = false
|
591
560
|
|
@@ -593,88 +562,89 @@ export const createUseRemoteBundle = (): ((conf: InternalConf) => RemoteBundl
|
|
593
562
|
const settings = createSettings(conf)
|
594
563
|
|
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<RemoteBundleState>({
|
607
|
-
|
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
|
|
618
|
-
|
619
|
-
<span class="
|
585
|
+
useEffect(() => {
|
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
|
|
623
|
-
|
624
|
-
.then(<span class="fstat-no" title="function not covered" >
|
590
|
+
loadPackage(conf.secret, conf)
|
591
|
+
.then(<span class="fstat-no" title="function not covered" >async </span>(bundle) => {
|
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
|
|
630
597
|
<span class="cstat-no" title="statement not covered" > settings.onSetUser(bundle.setUser)</span>
|
631
598
|
|
632
599
|
const remoteBundleState: RemoteBundleState = <span class="cstat-no" title="statement not covered" >{</span>
|
633
|
-
|
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
|
-
|
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
|
|
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(
|
648
|
-
|
620
|
+
.catch((error: Error) => {
|
621
|
+
conf.logger?.exception(error)
|
649
622
|
|
650
|
-
|
651
|
-
|
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
|
-
|
630
|
+
conf.pubSub.publish('on-error', error)
|
662
631
|
})
|
663
632
|
}, [])
|
664
633
|
|
665
|
-
|
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
|
+
|
638
|
+
export {
|
639
|
+
fetchBundle,
|
640
|
+
createRemotePackageLoader,
|
641
|
+
createUseRemoteBundle,
|
642
|
+
}
|
643
|
+
|
644
|
+
export type { TivioBundle } from '../types'
|
645
|
+
export type {
|
646
|
+
RemoteBundleState,
|
647
|
+
}
|
678
648
|
</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) => 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
|
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>
|