@trackunit/react-core-contexts 0.4.569 → 0.4.571
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/index.cjs.js +54 -29
- package/index.esm.js +54 -29
- package/package.json +1 -1
- package/src/oemBranding/OemBrandingProviderIrisApp.d.ts +2 -3
- package/src/token/TokenProviderIrisApp.d.ts +2 -3
- package/src/user/CurrentUserProviderIrisApp.d.ts +2 -3
- package/src/user/preference/CurrentUserPreferenceProviderIrisApp.d.ts +2 -2
package/index.cjs.js
CHANGED
|
@@ -366,21 +366,22 @@ const NavigationProviderIrisApp = ({ children }) => {
|
|
|
366
366
|
* This is a provider for the IOemBrandingContext.
|
|
367
367
|
*/
|
|
368
368
|
const OemBrandingContextProviderIrisApp = ({ children }) => {
|
|
369
|
-
const [oemBrandingContext, setOemBrandingContext] =
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
setOemBrandingContext(null);
|
|
377
|
-
// eslint-disable-next-line no-console
|
|
378
|
-
console.error("Could not load Iris App Oem!");
|
|
369
|
+
const [oemBrandingContext, setOemBrandingContext] = React.useState(null);
|
|
370
|
+
const [ctxError, setCtxError] = React.useState(false);
|
|
371
|
+
React.useEffect(() => {
|
|
372
|
+
irisAppRuntimeCore.OemBrandingContextRuntime.getOemBrandingContextRuntime()
|
|
373
|
+
.then((ctx) => {
|
|
374
|
+
if (!ctx) {
|
|
375
|
+
setCtxError(true);
|
|
379
376
|
return;
|
|
380
377
|
}
|
|
381
|
-
|
|
382
|
-
|
|
378
|
+
setOemBrandingContext(ctx);
|
|
379
|
+
})
|
|
380
|
+
.catch(() => setCtxError(true));
|
|
383
381
|
}, []);
|
|
382
|
+
if (ctxError) {
|
|
383
|
+
throw new Error("OemBranding context is invalid");
|
|
384
|
+
}
|
|
384
385
|
if (!oemBrandingContext) {
|
|
385
386
|
return null;
|
|
386
387
|
}
|
|
@@ -415,22 +416,26 @@ const ToastProviderIrisApp = ({ children }) => {
|
|
|
415
416
|
* This is a provider for the TokenContext.
|
|
416
417
|
*/
|
|
417
418
|
const TokenProviderIrisApp = ({ children }) => {
|
|
418
|
-
const [tokenContext, setTokenContext] =
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
419
|
+
const [tokenContext, setTokenContext] = React.useState(null);
|
|
420
|
+
const [ctxError, setCtxError] = React.useState(false);
|
|
421
|
+
React.useEffect(() => {
|
|
422
|
+
irisAppRuntimeCore.TokenRuntime.getTokenContext()
|
|
423
|
+
.then((ctx) => {
|
|
424
|
+
if (!ctx) {
|
|
425
|
+
setCtxError(true);
|
|
426
|
+
return;
|
|
426
427
|
}
|
|
427
|
-
|
|
428
|
-
|
|
428
|
+
setTokenContext(ctx);
|
|
429
|
+
})
|
|
430
|
+
.catch(() => setCtxError(true));
|
|
429
431
|
}, []);
|
|
430
|
-
const methods =
|
|
432
|
+
const methods = React.useMemo(() => ({
|
|
431
433
|
onTokenChanged: setTokenContext,
|
|
432
434
|
}), [setTokenContext]);
|
|
433
435
|
useSubscribeToHostChanges(methods);
|
|
436
|
+
if (ctxError) {
|
|
437
|
+
throw new Error("Token context is invalid");
|
|
438
|
+
}
|
|
434
439
|
if (!tokenContext) {
|
|
435
440
|
return null;
|
|
436
441
|
}
|
|
@@ -441,12 +446,22 @@ const TokenProviderIrisApp = ({ children }) => {
|
|
|
441
446
|
* This is a provider for the CurrentUserContext.
|
|
442
447
|
*/
|
|
443
448
|
const CurrentUserProviderIrisApp = ({ children }) => {
|
|
444
|
-
const [currentuserContext, setCurrentUserContext] =
|
|
445
|
-
|
|
449
|
+
const [currentuserContext, setCurrentUserContext] = React.useState(null);
|
|
450
|
+
const [ctxError, setCtxError] = React.useState(false);
|
|
451
|
+
React.useEffect(() => {
|
|
446
452
|
irisAppRuntimeCore.CurrentUserRuntime.getCurrentUserContext()
|
|
447
|
-
.
|
|
448
|
-
|
|
453
|
+
.then((ctx) => {
|
|
454
|
+
if (!ctx) {
|
|
455
|
+
setCtxError(true);
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
458
|
+
setCurrentUserContext(ctx);
|
|
459
|
+
})
|
|
460
|
+
.catch(() => setCtxError(true));
|
|
449
461
|
}, []);
|
|
462
|
+
if (ctxError) {
|
|
463
|
+
throw new Error("Current user context is invalid");
|
|
464
|
+
}
|
|
450
465
|
if (!currentuserContext) {
|
|
451
466
|
return null;
|
|
452
467
|
}
|
|
@@ -460,10 +475,17 @@ const CurrentUserPreferenceProviderIrisApp = ({ children }) => {
|
|
|
460
475
|
const [language, setLanguage] = React.useState(null);
|
|
461
476
|
const [systemOfMeasurement, setSystemOfMeasurement] = React.useState(null);
|
|
462
477
|
const [timeZonePreference, setTimeZonePreference] = React.useState(null);
|
|
478
|
+
const [ctxError, setCtxError] = React.useState(false);
|
|
463
479
|
React.useEffect(() => {
|
|
464
480
|
irisAppRuntimeCore.CurrentUserPreferenceRuntime.getCurrentUserLanguage()
|
|
465
|
-
.
|
|
466
|
-
|
|
481
|
+
.then((lang) => {
|
|
482
|
+
if (!lang) {
|
|
483
|
+
setCtxError(true);
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
486
|
+
setLanguage(lang);
|
|
487
|
+
})
|
|
488
|
+
.catch(() => setCtxError(true));
|
|
467
489
|
}, [setLanguage]);
|
|
468
490
|
React.useEffect(() => {
|
|
469
491
|
irisAppRuntimeCore.CurrentUserPreferenceRuntime.getCurrentUserSystemOfMeasurement()
|
|
@@ -475,6 +497,9 @@ const CurrentUserPreferenceProviderIrisApp = ({ children }) => {
|
|
|
475
497
|
.catch(() => null)
|
|
476
498
|
.then(setTimeZonePreference);
|
|
477
499
|
}, []);
|
|
500
|
+
if (ctxError) {
|
|
501
|
+
throw new Error("Language context is invalid");
|
|
502
|
+
}
|
|
478
503
|
if (!language) {
|
|
479
504
|
return null;
|
|
480
505
|
}
|
package/index.esm.js
CHANGED
|
@@ -346,21 +346,22 @@ const NavigationProviderIrisApp = ({ children }) => {
|
|
|
346
346
|
* This is a provider for the IOemBrandingContext.
|
|
347
347
|
*/
|
|
348
348
|
const OemBrandingContextProviderIrisApp = ({ children }) => {
|
|
349
|
-
const [oemBrandingContext, setOemBrandingContext] =
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
setOemBrandingContext(null);
|
|
357
|
-
// eslint-disable-next-line no-console
|
|
358
|
-
console.error("Could not load Iris App Oem!");
|
|
349
|
+
const [oemBrandingContext, setOemBrandingContext] = useState(null);
|
|
350
|
+
const [ctxError, setCtxError] = useState(false);
|
|
351
|
+
useEffect(() => {
|
|
352
|
+
OemBrandingContextRuntime.getOemBrandingContextRuntime()
|
|
353
|
+
.then((ctx) => {
|
|
354
|
+
if (!ctx) {
|
|
355
|
+
setCtxError(true);
|
|
359
356
|
return;
|
|
360
357
|
}
|
|
361
|
-
|
|
362
|
-
|
|
358
|
+
setOemBrandingContext(ctx);
|
|
359
|
+
})
|
|
360
|
+
.catch(() => setCtxError(true));
|
|
363
361
|
}, []);
|
|
362
|
+
if (ctxError) {
|
|
363
|
+
throw new Error("OemBranding context is invalid");
|
|
364
|
+
}
|
|
364
365
|
if (!oemBrandingContext) {
|
|
365
366
|
return null;
|
|
366
367
|
}
|
|
@@ -395,22 +396,26 @@ const ToastProviderIrisApp = ({ children }) => {
|
|
|
395
396
|
* This is a provider for the TokenContext.
|
|
396
397
|
*/
|
|
397
398
|
const TokenProviderIrisApp = ({ children }) => {
|
|
398
|
-
const [tokenContext, setTokenContext] =
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
399
|
+
const [tokenContext, setTokenContext] = useState(null);
|
|
400
|
+
const [ctxError, setCtxError] = useState(false);
|
|
401
|
+
useEffect(() => {
|
|
402
|
+
TokenRuntime.getTokenContext()
|
|
403
|
+
.then((ctx) => {
|
|
404
|
+
if (!ctx) {
|
|
405
|
+
setCtxError(true);
|
|
406
|
+
return;
|
|
406
407
|
}
|
|
407
|
-
|
|
408
|
-
|
|
408
|
+
setTokenContext(ctx);
|
|
409
|
+
})
|
|
410
|
+
.catch(() => setCtxError(true));
|
|
409
411
|
}, []);
|
|
410
|
-
const methods =
|
|
412
|
+
const methods = useMemo(() => ({
|
|
411
413
|
onTokenChanged: setTokenContext,
|
|
412
414
|
}), [setTokenContext]);
|
|
413
415
|
useSubscribeToHostChanges(methods);
|
|
416
|
+
if (ctxError) {
|
|
417
|
+
throw new Error("Token context is invalid");
|
|
418
|
+
}
|
|
414
419
|
if (!tokenContext) {
|
|
415
420
|
return null;
|
|
416
421
|
}
|
|
@@ -421,12 +426,22 @@ const TokenProviderIrisApp = ({ children }) => {
|
|
|
421
426
|
* This is a provider for the CurrentUserContext.
|
|
422
427
|
*/
|
|
423
428
|
const CurrentUserProviderIrisApp = ({ children }) => {
|
|
424
|
-
const [currentuserContext, setCurrentUserContext] =
|
|
425
|
-
|
|
429
|
+
const [currentuserContext, setCurrentUserContext] = useState(null);
|
|
430
|
+
const [ctxError, setCtxError] = useState(false);
|
|
431
|
+
useEffect(() => {
|
|
426
432
|
CurrentUserRuntime.getCurrentUserContext()
|
|
427
|
-
.
|
|
428
|
-
|
|
433
|
+
.then((ctx) => {
|
|
434
|
+
if (!ctx) {
|
|
435
|
+
setCtxError(true);
|
|
436
|
+
return;
|
|
437
|
+
}
|
|
438
|
+
setCurrentUserContext(ctx);
|
|
439
|
+
})
|
|
440
|
+
.catch(() => setCtxError(true));
|
|
429
441
|
}, []);
|
|
442
|
+
if (ctxError) {
|
|
443
|
+
throw new Error("Current user context is invalid");
|
|
444
|
+
}
|
|
430
445
|
if (!currentuserContext) {
|
|
431
446
|
return null;
|
|
432
447
|
}
|
|
@@ -440,10 +455,17 @@ const CurrentUserPreferenceProviderIrisApp = ({ children }) => {
|
|
|
440
455
|
const [language, setLanguage] = useState(null);
|
|
441
456
|
const [systemOfMeasurement, setSystemOfMeasurement] = useState(null);
|
|
442
457
|
const [timeZonePreference, setTimeZonePreference] = useState(null);
|
|
458
|
+
const [ctxError, setCtxError] = useState(false);
|
|
443
459
|
useEffect(() => {
|
|
444
460
|
CurrentUserPreferenceRuntime.getCurrentUserLanguage()
|
|
445
|
-
.
|
|
446
|
-
|
|
461
|
+
.then((lang) => {
|
|
462
|
+
if (!lang) {
|
|
463
|
+
setCtxError(true);
|
|
464
|
+
return;
|
|
465
|
+
}
|
|
466
|
+
setLanguage(lang);
|
|
467
|
+
})
|
|
468
|
+
.catch(() => setCtxError(true));
|
|
447
469
|
}, [setLanguage]);
|
|
448
470
|
useEffect(() => {
|
|
449
471
|
CurrentUserPreferenceRuntime.getCurrentUserSystemOfMeasurement()
|
|
@@ -455,6 +477,9 @@ const CurrentUserPreferenceProviderIrisApp = ({ children }) => {
|
|
|
455
477
|
.catch(() => null)
|
|
456
478
|
.then(setTimeZonePreference);
|
|
457
479
|
}, []);
|
|
480
|
+
if (ctxError) {
|
|
481
|
+
throw new Error("Language context is invalid");
|
|
482
|
+
}
|
|
458
483
|
if (!language) {
|
|
459
484
|
return null;
|
|
460
485
|
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
interface IProps {
|
|
1
|
+
interface OemBrandingContextProviderIrisAppProps {
|
|
3
2
|
children: React.ReactNode;
|
|
4
3
|
}
|
|
5
4
|
/**
|
|
6
5
|
* This is a provider for the IOemBrandingContext.
|
|
7
6
|
*/
|
|
8
|
-
export declare const OemBrandingContextProviderIrisApp: ({ children }:
|
|
7
|
+
export declare const OemBrandingContextProviderIrisApp: ({ children }: OemBrandingContextProviderIrisAppProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
9
8
|
export {};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
interface IProps {
|
|
1
|
+
interface TokenProviderIrisAppProps {
|
|
3
2
|
children: React.ReactNode;
|
|
4
3
|
}
|
|
5
4
|
/**
|
|
6
5
|
* This is a provider for the TokenContext.
|
|
7
6
|
*/
|
|
8
|
-
export declare const TokenProviderIrisApp: ({ children }:
|
|
7
|
+
export declare const TokenProviderIrisApp: ({ children }: TokenProviderIrisAppProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
9
8
|
export {};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
interface IProps {
|
|
1
|
+
interface CurrentUserProviderIrisAppProps {
|
|
3
2
|
children: React.ReactNode;
|
|
4
3
|
}
|
|
5
4
|
/**
|
|
6
5
|
* This is a provider for the CurrentUserContext.
|
|
7
6
|
*/
|
|
8
|
-
export declare const CurrentUserProviderIrisApp: ({ children }:
|
|
7
|
+
export declare const CurrentUserProviderIrisApp: ({ children }: CurrentUserProviderIrisAppProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
9
8
|
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { IUserPreferencesContext } from "@trackunit/react-core-contexts-api";
|
|
2
2
|
import { ReactNode } from "react";
|
|
3
3
|
export type UserPreferencesContextIrisApp = Pick<IUserPreferencesContext, "language" | "timeZonePreference" | "timeZonePreference">;
|
|
4
|
-
interface
|
|
4
|
+
interface CurrentUserPreferenceProviderIrisAppProps {
|
|
5
5
|
children: ReactNode;
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
8
|
* This is a provider for the CurrentUserContext.
|
|
9
9
|
*/
|
|
10
|
-
export declare const CurrentUserPreferenceProviderIrisApp: ({ children }:
|
|
10
|
+
export declare const CurrentUserPreferenceProviderIrisApp: ({ children }: CurrentUserPreferenceProviderIrisAppProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
11
11
|
export {};
|