@unisphere/nx 2.2.1 → 3.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/dist/generators/add-application/add-application.d.ts.map +1 -1
  2. package/dist/generators/add-application/add-application.js +77 -55
  3. package/dist/generators/add-application/schema.d.ts +3 -1
  4. package/dist/generators/add-application/schema.json +4 -8
  5. package/dist/generators/add-application/templates/default/.env-template +6 -0
  6. package/dist/generators/add-application/templates/default/.eslintrc.json +1 -1
  7. package/dist/generators/add-application/templates/default/jest.config.ts +3 -3
  8. package/dist/generators/add-application/templates/default/project.json.template +2 -2
  9. package/dist/generators/add-application/templates/default/readme.md.template +11 -0
  10. package/dist/generators/add-application/templates/default/src/app/app.tsx.template +77 -77
  11. package/dist/generators/add-application/templates/default/tsconfig.json +1 -1
  12. package/dist/generators/add-application/templates/default/webpack.config.js.template +6 -1
  13. package/dist/generators/add-package/README.md +2 -2
  14. package/dist/generators/add-package/add-package.d.ts.map +1 -1
  15. package/dist/generators/add-package/add-package.js +11 -23
  16. package/dist/generators/add-package/schema.d.ts +1 -1
  17. package/dist/generators/add-package/schema.json +27 -19
  18. package/dist/generators/add-package/templates/new-package/.eslintrc.json +1 -1
  19. package/dist/generators/add-package/templates/new-package/package.json.template +0 -1
  20. package/dist/generators/add-package/templates/new-package/project.json.template +4 -4
  21. package/dist/generators/add-package/templates/new-package/rollup.config.js +1 -1
  22. package/dist/generators/add-package/templates/new-package/tsconfig.json +1 -1
  23. package/dist/generators/add-package/templates/new-package/tsconfig.lib.json.template +1 -1
  24. package/dist/generators/add-package/templates/new-package/tsconfig.spec.json +1 -1
  25. package/dist/generators/add-runtime/add-runtime.d.ts.map +1 -1
  26. package/dist/generators/add-runtime/add-runtime.js +62 -9
  27. package/dist/generators/add-runtime/schema.d.ts +1 -0
  28. package/dist/generators/add-runtime/schema.json +1 -9
  29. package/dist/generators/add-runtime/templates/new-runtime/src/lib/create-factory.tsx.template +4 -4
  30. package/dist/generators/add-runtime/templates/new-runtime/src/lib/runtime.tsx.template +26 -2
  31. package/dist/generators/add-visual/add-visual.d.ts +1 -1
  32. package/dist/generators/add-visual/add-visual.d.ts.map +1 -1
  33. package/dist/generators/add-visual/add-visual.js +108 -15
  34. package/dist/generators/add-visual/schema.d.ts +3 -3
  35. package/dist/generators/add-visual/schema.json +2 -24
  36. package/dist/generators/dependency-config.d.ts.map +1 -1
  37. package/dist/generators/dependency-config.js +1 -0
  38. package/dist/generators/internal-dev-runner/generator.d.ts +3 -0
  39. package/dist/generators/internal-dev-runner/generator.d.ts.map +1 -0
  40. package/dist/generators/internal-dev-runner/generator.js +45 -0
  41. package/dist/generators/internal-dev-runner/schema.json +9 -0
  42. package/dist/generators/remove/remove.d.ts +19 -0
  43. package/dist/generators/remove/remove.d.ts.map +1 -0
  44. package/dist/generators/remove/remove.js +270 -0
  45. package/dist/generators/remove/schema.d.ts +4 -0
  46. package/dist/generators/remove/schema.json +38 -0
  47. package/dist/generators/rename-package/rename-package.d.ts +3 -0
  48. package/dist/generators/rename-package/rename-package.d.ts.map +1 -1
  49. package/dist/generators/rename-package/rename-package.js +139 -20
  50. package/dist/generators/utils.d.ts +30 -1
  51. package/dist/generators/utils.d.ts.map +1 -1
  52. package/dist/generators/utils.js +258 -7
  53. package/dist/migrations/1-22-0/patches/@changesets+cli+2.29.7.patch +36 -4
  54. package/dist/migrations/1-22-2/templates/_publish-artifacts.template +5 -5
  55. package/dist/migrations/1-24-2/templates/_publish-artifacts.template +5 -5
  56. package/dist/migrations/2-1-0/replace-readme-md.d.ts.map +1 -1
  57. package/dist/migrations/2-1-0/replace-readme-md.js +2 -3
  58. package/dist/migrations/2-2-0/templates/_publish-artifacts.template +5 -5
  59. package/dist/migrations/3-0-0/add-define-plugin-to-webpack.d.ts +3 -0
  60. package/dist/migrations/3-0-0/add-define-plugin-to-webpack.d.ts.map +1 -0
  61. package/dist/migrations/3-0-0/add-define-plugin-to-webpack.js +233 -0
  62. package/dist/migrations/3-0-0/add-env-to-application-gitignore.d.ts +3 -0
  63. package/dist/migrations/3-0-0/add-env-to-application-gitignore.d.ts.map +1 -0
  64. package/dist/migrations/3-0-0/add-env-to-application-gitignore.js +117 -0
  65. package/dist/migrations/3-0-0/fix-vite-config-cache-paths.d.ts +10 -0
  66. package/dist/migrations/3-0-0/fix-vite-config-cache-paths.d.ts.map +1 -0
  67. package/dist/migrations/3-0-0/fix-vite-config-cache-paths.js +66 -0
  68. package/dist/migrations/3-0-0/patches/@changesets+cli+2.29.7.patch +88 -0
  69. package/dist/migrations/3-0-0/post-cleanup-empty-directories.d.ts +12 -0
  70. package/dist/migrations/3-0-0/post-cleanup-empty-directories.d.ts.map +1 -0
  71. package/dist/migrations/3-0-0/post-cleanup-empty-directories.js +62 -0
  72. package/dist/migrations/3-0-0/pre-cleanup-empty-directories.d.ts +14 -0
  73. package/dist/migrations/3-0-0/pre-cleanup-empty-directories.d.ts.map +1 -0
  74. package/dist/migrations/3-0-0/pre-cleanup-empty-directories.js +105 -0
  75. package/dist/migrations/3-0-0/remove-kaltura-tools-to-pre-install.d.ts +3 -0
  76. package/dist/migrations/3-0-0/remove-kaltura-tools-to-pre-install.d.ts.map +1 -0
  77. package/dist/migrations/3-0-0/remove-kaltura-tools-to-pre-install.js +21 -0
  78. package/dist/migrations/3-0-0/remove-private-from-applications-and-runtimes.d.ts +9 -0
  79. package/dist/migrations/3-0-0/remove-private-from-applications-and-runtimes.d.ts.map +1 -0
  80. package/dist/migrations/3-0-0/remove-private-from-applications-and-runtimes.js +88 -0
  81. package/dist/migrations/3-0-0/remove-publish-config-from-packages.d.ts +9 -0
  82. package/dist/migrations/3-0-0/remove-publish-config-from-packages.d.ts.map +1 -0
  83. package/dist/migrations/3-0-0/remove-publish-config-from-packages.js +45 -0
  84. package/dist/migrations/3-0-0/reorganize-applications-by-distribution-channel.d.ts +15 -0
  85. package/dist/migrations/3-0-0/reorganize-applications-by-distribution-channel.d.ts.map +1 -0
  86. package/dist/migrations/3-0-0/reorganize-applications-by-distribution-channel.js +563 -0
  87. package/dist/migrations/3-0-0/reorganize-packages-by-distribution-channel.d.ts +23 -0
  88. package/dist/migrations/3-0-0/reorganize-packages-by-distribution-channel.d.ts.map +1 -0
  89. package/dist/migrations/3-0-0/reorganize-packages-by-distribution-channel.js +645 -0
  90. package/dist/migrations/3-0-0/replace-github-workflow.d.ts +3 -0
  91. package/dist/migrations/3-0-0/replace-github-workflow.d.ts.map +1 -0
  92. package/dist/migrations/3-0-0/replace-github-workflow.js +48 -0
  93. package/dist/migrations/3-0-0/sync-package-lock.d.ts +10 -0
  94. package/dist/migrations/3-0-0/sync-package-lock.d.ts.map +1 -0
  95. package/dist/migrations/3-0-0/sync-package-lock.js +26 -0
  96. package/dist/migrations/3-0-0/templates/_publish-artifacts.template +363 -0
  97. package/dist/migrations/3-0-0/templates/cicd.template +89 -0
  98. package/dist/migrations/3-0-0/update-changeset-patch.d.ts +3 -0
  99. package/dist/migrations/3-0-0/update-changeset-patch.d.ts.map +1 -0
  100. package/dist/migrations/3-0-0/update-changeset-patch.js +31 -0
  101. package/dist/migrations/3-0-0/upgrade-schema-to-2-0-0.d.ts +21 -0
  102. package/dist/migrations/3-0-0/upgrade-schema-to-2-0-0.d.ts.map +1 -0
  103. package/dist/migrations/3-0-0/upgrade-schema-to-2-0-0.js +105 -0
  104. package/dist/migrations/utils/has-react-dependency.d.ts +14 -0
  105. package/dist/migrations/utils/has-react-dependency.d.ts.map +1 -0
  106. package/dist/migrations/utils/has-react-dependency.js +72 -0
  107. package/dist/shared.d.ts +6 -0
  108. package/dist/shared.d.ts.map +1 -0
  109. package/dist/shared.js +9 -0
  110. package/generators.json +12 -1
  111. package/migrations.json +117 -0
  112. package/package.json +3 -2
  113. package/dist/generators/add-application/templates/local-dev-playground/.babelrc +0 -11
  114. package/dist/generators/add-application/templates/local-dev-playground/.eslintrc.json +0 -22
  115. package/dist/generators/add-application/templates/local-dev-playground/jest.config.ts +0 -11
  116. package/dist/generators/add-application/templates/local-dev-playground/package.json +0 -6
  117. package/dist/generators/add-application/templates/local-dev-playground/project.json +0 -9
  118. package/dist/generators/add-application/templates/local-dev-playground/src/app/app.tsx.template +0 -212
  119. package/dist/generators/add-application/templates/local-dev-playground/src/app/components/header.tsx.template +0 -123
  120. package/dist/generators/add-application/templates/local-dev-playground/src/app/components/settings-buttons.tsx +0 -57
  121. package/dist/generators/add-application/templates/local-dev-playground/src/app/components/settings-form.tsx +0 -108
  122. package/dist/generators/add-application/templates/local-dev-playground/src/app/components/settings.tsx +0 -74
  123. package/dist/generators/add-application/templates/local-dev-playground/src/app/configuration-provider.tsx +0 -163
  124. package/dist/generators/add-application/templates/local-dev-playground/src/app/definitions.ts +0 -25
  125. package/dist/generators/add-application/templates/local-dev-playground/src/app/utils/merge-deep.ts +0 -31
  126. package/dist/generators/add-application/templates/local-dev-playground/src/favicon.ico +0 -0
  127. package/dist/generators/add-application/templates/local-dev-playground/src/index.html +0 -17
  128. package/dist/generators/add-application/templates/local-dev-playground/src/main.tsx +0 -13
  129. package/dist/generators/add-application/templates/local-dev-playground/src/styles.css +0 -0
  130. package/dist/generators/add-application/templates/local-dev-playground/tsconfig.app.json +0 -24
  131. package/dist/generators/add-application/templates/local-dev-playground/tsconfig.json +0 -20
  132. package/dist/generators/add-application/templates/local-dev-playground/tsconfig.spec.json +0 -25
  133. package/dist/generators/add-application/templates/local-dev-playground/webpack.config.js +0 -33
  134. /package/dist/generators/add-runtime/templates/{core-templates → types-templates}/__runtimeName__-runtime/index.ts.template +0 -0
  135. /package/dist/generators/add-runtime/templates/{core-templates → types-templates}/__runtimeName__-runtime/runtime-types.ts.template +0 -0
@@ -1,123 +0,0 @@
1
- import React, { useContext, useState } from 'react';
2
- import {
3
- AppBar,
4
- Box,
5
- IconButton,
6
- ListItemIcon,
7
- Menu,
8
- MenuItem,
9
- Toolbar,
10
- Tooltip,
11
- Typography,
12
- } from '@mui/material';
13
- import { ConfigurationContext } from '../configuration-provider';
14
- import { isConfigurationValid } from '../definitions';
15
- import {
16
- DeveloperBoard as DeveloperBoardIcon,
17
- Settings as SettingsIcon,
18
- Storage as StorageIcon,
19
- } from '@mui/icons-material';
20
- import { Settings } from './settings';
21
-
22
- export const Header: React.FC = () => {
23
- const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
24
- const { configuration: Configuration, createSharedUrl } =
25
- useContext(ConfigurationContext);
26
-
27
- const open = Boolean(anchorEl);
28
- const replaceBaseUrlInNewTab = () => {
29
- const baseUrl = prompt('please provide the new base url');
30
- if (!baseUrl) {
31
- return;
32
- }
33
-
34
- const filteredUrl = baseUrl.replace(/\/configuration$/, '');
35
- window.open(
36
- createSharedUrl({
37
- baseUrl: `${filteredUrl}`,
38
- })
39
- );
40
- return;
41
- };
42
-
43
- const handleMenu = (event: React.MouseEvent<HTMLElement>) => {
44
- setAnchorEl(event.currentTarget);
45
- };
46
-
47
- const handleClose = () => {
48
- setAnchorEl(null);
49
- };
50
-
51
- const [settingsOpen, setSettingsOpen] = useState(() => {
52
- return !isConfigurationValid(Configuration);
53
- });
54
-
55
- const handleSettingsClosed = () => {
56
- setSettingsOpen(false);
57
- };
58
-
59
- return (
60
- <AppBar position="fixed" sx={{ zIndex: 1000 }}>
61
- <Toolbar style={{ justifyContent: 'space-between' }}>
62
- <Box
63
- sx={{
64
- display: 'flex',
65
- alignItems: 'center',
66
- }}
67
- >
68
- <Typography variant="h6" sx={{ flexGrow: 1 }}>
69
- <%= widgetName__pascalCase %> - <%= runtimeName__pascalCase %> Dev
70
- </Typography>
71
- </Box>
72
-
73
- <Box
74
- sx={{
75
- display: 'flex',
76
- alignItems: 'center',
77
- }}
78
- >
79
- <Tooltip title="Menu">
80
- <IconButton onClick={handleMenu} color="inherit" aria-label="menu">
81
- <SettingsIcon />
82
- </IconButton>
83
- </Tooltip>
84
-
85
- <Menu
86
- id="menu-appbar"
87
- anchorEl={anchorEl}
88
- anchorOrigin={{
89
- vertical: 'top',
90
- horizontal: 'right',
91
- }}
92
- keepMounted
93
- transformOrigin={{
94
- vertical: 'top',
95
- horizontal: 'right',
96
- }}
97
- open={open}
98
- onClose={handleClose}
99
- >
100
- <MenuItem
101
- onClick={() => {
102
- handleClose();
103
- setSettingsOpen(true);
104
- }}
105
- >
106
- <ListItemIcon>
107
- <StorageIcon fontSize="small" />
108
- </ListItemIcon>
109
- <Typography variant="inherit">Configuration</Typography>
110
- </MenuItem>
111
- <MenuItem onClick={replaceBaseUrlInNewTab}>
112
- <ListItemIcon>
113
- <DeveloperBoardIcon fontSize="small" />
114
- </ListItemIcon>
115
- <Typography variant="inherit">Change Base URL</Typography>
116
- </MenuItem>
117
- </Menu>
118
- </Box>
119
- </Toolbar>
120
- {settingsOpen && <Settings onClose={handleSettingsClosed} />}
121
- </AppBar>
122
- );
123
- };
@@ -1,57 +0,0 @@
1
- import React, { useContext, PropsWithChildren } from 'react';
2
- import { Box, Button } from '@mui/material';
3
- import {
4
- ConfigurationContext,
5
- ConfigurationTypes,
6
- } from '../configuration-provider';
7
-
8
- export interface SettingsButtonsProps {
9
- onReset: () => void;
10
- customSave?: React.ReactElement;
11
- }
12
-
13
- export const ButtonsContainer: React.FC<PropsWithChildren> = ({ children }) => {
14
- return (
15
- <Box
16
- sx={{
17
- display: 'flex',
18
- justifyContent: 'space-between',
19
- alignItems: 'center',
20
- marginTop: '20px',
21
- }}
22
- >
23
- {children}
24
- </Box>
25
- );
26
- };
27
-
28
- export const SettingsButtons: React.FC<SettingsButtonsProps> = ({
29
- customSave,
30
- onReset,
31
- }) => {
32
- const { ConfigurationType } = useContext(ConfigurationContext);
33
-
34
- return (
35
- <ButtonsContainer>
36
- <>
37
- {ConfigurationType === ConfigurationTypes.Localstorage && (
38
- <Button
39
- onClick={onReset}
40
- variant="contained"
41
- color="secondary"
42
- style={{ marginRight: '8px' }}
43
- >
44
- Clear All
45
- </Button>
46
- )}
47
- {customSave ? (
48
- customSave
49
- ) : (
50
- <Button variant="contained" color="primary" type={'submit'}>
51
- Save & Close
52
- </Button>
53
- )}
54
- </>
55
- </ButtonsContainer>
56
- );
57
- };
@@ -1,108 +0,0 @@
1
- import { Controller, useFormContext } from 'react-hook-form';
2
- import React, { MouseEvent } from 'react';
3
- import { MenuItem, Select, Stack, TextField, Typography } from '@mui/material';
4
- import { Configuration } from '../definitions';
5
- import { UseFormReturn } from 'react-hook-form/dist/types';
6
-
7
- const FormCard: React.FC<React.PropsWithChildren<{ title: string }>> = ({
8
- title,
9
- children,
10
- }) => {
11
- return (
12
- <Stack
13
- sx={{
14
- padding: '8px',
15
- border: '1px solid grey',
16
- borderRadius: '8px',
17
- gap: '16px',
18
- }}
19
- >
20
- <Typography variant="body1" sx={{ fontWeight: 700 }}>
21
- {title}
22
- </Typography>
23
- {children}
24
- </Stack>
25
- );
26
- };
27
-
28
- const FormItem: React.FC<React.PropsWithChildren<{ title: string }>> = ({
29
- title,
30
- children,
31
- }) => {
32
- return (
33
- <Stack
34
- sx={{
35
- padding: '4px',
36
- gap: '8px',
37
- }}
38
- >
39
- <Typography variant="body1">{title}</Typography>
40
- {children}
41
- </Stack>
42
- );
43
- };
44
-
45
- export const SettingsForm: React.FC = () => {
46
- const context = useFormContext<Configuration>();
47
-
48
- const {
49
- register,
50
- reset,
51
- formState: { errors },
52
- control,
53
- watch,
54
- } = context;
55
-
56
- return (
57
- <Stack gap="16px">
58
- <FormCard title="Host Settings">
59
- <TextField
60
- name={'unisphereServerUrl'}
61
- fullWidth
62
- inputProps={{
63
- ...register('unisphereServerUrl', { required: true }),
64
- }}
65
- label={'Service URL'}
66
- helperText={errors?.unisphereServerUrl ? 'required' : ''}
67
- error={!!errors?.unisphereServerUrl}
68
- />
69
-
70
- <TextField
71
- name={'language'}
72
- fullWidth
73
- inputProps={{ ...register('language') }}
74
- label={'Language code'}
75
- />
76
-
77
- <FormItem title="Theme">
78
- <Controller
79
- control={control}
80
- name="theme"
81
- render={({ field }) => (
82
- <Select {...field}>
83
- <MenuItem value="light">Light</MenuItem>
84
- <MenuItem value="dark">Dark</MenuItem>
85
- </Select>
86
- )}
87
- />
88
- </FormItem>
89
- </FormCard>
90
- <FormCard title="Unisphere Settings">
91
- <TextField
92
- name={'settings'}
93
- fullWidth
94
- inputProps={{
95
- ...register('settings', {
96
- required: `To pass empty settings, type "{}". Otherwise: (1) manually type valid JSON. (2) `,
97
- }),
98
- }}
99
- label={'Unisphere Settings'}
100
- helperText={`${
101
- errors?.settings?.message || ''
102
- }Easily copy settings from Unisphere by entering a workable host in NVQ2 and then do: Unisphere cmd+k > Manage Workspace Runtimes > show ... (actions) of desired runtime > copy settings`}
103
- error={!!errors?.settings?.message}
104
- />
105
- </FormCard>
106
- </Stack>
107
- );
108
- };
@@ -1,74 +0,0 @@
1
- import React, { useContext } from 'react';
2
- import { Dialog, DialogActions, DialogContent } from '@mui/material';
3
- import { FormProvider, useForm } from 'react-hook-form';
4
- import { ConfigurationContext } from '../configuration-provider';
5
- import { getDefaultConfiguration, Configuration } from '../definitions';
6
- import { SettingsButtons } from './settings-buttons';
7
- import { SettingsForm } from './settings-form';
8
-
9
- export const Settings: React.FC<{ onClose: () => void }> = ({ onClose }) => {
10
- const {
11
- clearConfiguration,
12
- configuration: Configuration,
13
- updateConfiguration,
14
- } = useContext(ConfigurationContext);
15
-
16
- const formMethods = useForm<Configuration>({
17
- defaultValues: Configuration,
18
- });
19
-
20
- const onSubmit = (data: any) => {
21
- const updatedData = {
22
- ...data,
23
- };
24
- updateConfiguration(updatedData);
25
-
26
- onClose();
27
-
28
- window.location.reload();
29
- };
30
-
31
- const handleClose = (event: any, reason: string) => {
32
- if (reason === 'backdropClick') {
33
- return;
34
- }
35
- onClose();
36
- };
37
-
38
- const handleReset = () => {
39
- // eslint-disable-next-line no-restricted-globals
40
- const accepted = confirm('Do you want to clear all values?');
41
- if (!accepted) {
42
- return;
43
- }
44
- clearConfiguration();
45
- formMethods.reset(getDefaultConfiguration());
46
- };
47
- return (
48
- <div>
49
- <Dialog open={true} onClose={handleClose} disableEscapeKeyDown={true}>
50
- <FormProvider {...formMethods}>
51
- <form
52
- noValidate
53
- autoComplete="off"
54
- onSubmit={formMethods.handleSubmit(onSubmit)}
55
- >
56
- <DialogContent
57
- sx={{
58
- display: 'flex',
59
- width: '500px',
60
- flexDirection: 'column',
61
- overflow: 'hidden',
62
- }}
63
- >
64
- <SettingsForm />
65
- <DialogActions sx={{ padding: 0 }}>
66
- <SettingsButtons onReset={handleReset} />
67
- </DialogActions>
68
- </DialogContent>
69
- </form>
70
- </FormProvider>
71
- </Dialog>
72
- </div>
73
- );
74
- };
@@ -1,163 +0,0 @@
1
- import React, { useMemo, useState } from 'react';
2
- import {
3
- getDefaultConfiguration,
4
- isConfigurationValid,
5
- Configuration,
6
- } from './definitions';
7
- import { mergeDeep } from './utils/merge-deep';
8
-
9
- export const ConfigurationContext = React.createContext<{
10
- configuration: Configuration;
11
- sharedUrl: string;
12
- clearConfiguration: () => void;
13
- updateConfiguration: (configuration: Configuration) => void;
14
- createSharedUrl: (options?: {
15
- baseUrl?: string;
16
- customConfiguration?: Configuration;
17
- }) => string;
18
- ConfigurationType: ConfigurationTypes;
19
- refreshConfiguration: () => void;
20
- }>(null as any);
21
-
22
- export const getConfigurationFromQueryParams = (
23
- configurationKey: string
24
- ): Configuration | null => {
25
- const search = window.location.search;
26
- const params = new URLSearchParams(search);
27
-
28
- if (!params || !configurationKey || !params.get(configurationKey))
29
- return null;
30
-
31
- const configuration = window.atob(params.get(configurationKey) || '');
32
- try {
33
- return JSON.parse(configuration);
34
- } catch (e: any) {
35
- console.warn(`Failed to parse login query string ${e.message} ${e.stack}`);
36
- return null;
37
- }
38
- };
39
-
40
- export enum ConfigurationTypes {
41
- None,
42
- Querystring,
43
- Localstorage,
44
- }
45
-
46
- const { hostname, port, protocol } = window.location;
47
- export const hosterAppUrl = `${protocol}//${hostname}${port ? `:${port}` : ''}`;
48
-
49
- const getConfigurationFromLocalStorage = (
50
- configurationKey: string
51
- ): Configuration | null => {
52
- const data = localStorage.getItem(configurationKey);
53
- return data ? JSON.parse(data) : null;
54
- };
55
-
56
- const loginParamsToBase64 = (configuration: Configuration | null): string => {
57
- if (!configuration) {
58
- return '';
59
- }
60
- try {
61
- return window.btoa(JSON.stringify(configuration));
62
- } catch (e) {
63
- return '';
64
- }
65
- };
66
-
67
- export const ConfigurationProvider: React.FC<
68
- React.PropsWithChildren<{
69
- configurationKey: string;
70
- }>
71
- > = (props) => {
72
- const { configurationKey } = props;
73
- const [ConfigurationType] = useState<ConfigurationTypes>(() => {
74
- return getConfigurationFromQueryParams(configurationKey)
75
- ? ConfigurationTypes.Querystring
76
- : ConfigurationTypes.Localstorage;
77
- });
78
- const [configuration, setConfiguration] = useState<Configuration | null>(
79
- () => {
80
- const configuration = mergeDeep(
81
- {},
82
- getDefaultConfiguration(),
83
- ConfigurationType === ConfigurationTypes.Querystring
84
- ? getConfigurationFromQueryParams(configurationKey)
85
- : getConfigurationFromLocalStorage(configurationKey)
86
- );
87
-
88
- return configuration && isConfigurationValid(configuration)
89
- ? configuration
90
- : getDefaultConfiguration();
91
- }
92
- );
93
-
94
- const providerValue = useMemo(() => {
95
- const createSharedUrl = (options?: {
96
- baseUrl?: string;
97
- customConfiguration?: Configuration;
98
- }) => {
99
- const { baseUrl = '', customConfiguration } = options || {};
100
-
101
- if (!options?.customConfiguration && !configuration) {
102
- return '';
103
- }
104
-
105
- return `${
106
- baseUrl || hosterAppUrl
107
- }/configuration?${configurationKey}=${loginParamsToBase64(
108
- customConfiguration || configuration
109
- )}`;
110
- };
111
-
112
- const saveToLocalStorage = (params: Configuration) => {
113
- if (ConfigurationType === ConfigurationTypes.Querystring) {
114
- const sharedUrl = createSharedUrl({
115
- customConfiguration: params,
116
- });
117
-
118
- if (sharedUrl) {
119
- window.location.href = sharedUrl;
120
- }
121
-
122
- return;
123
- }
124
-
125
- localStorage.setItem(
126
- configurationKey,
127
- params ? JSON.stringify(params) : ''
128
- );
129
- setConfiguration(params || null);
130
- };
131
-
132
- const clearLocalStorage = () => {
133
- localStorage.removeItem(configurationKey);
134
- setConfiguration(null);
135
- };
136
-
137
- const refreshConfiguration = () => {
138
- setConfiguration((prev) => {
139
- if (!prev) {
140
- return prev;
141
- }
142
- return {
143
- ...prev,
144
- };
145
- });
146
- };
147
- return {
148
- configuration: configuration || getDefaultConfiguration(),
149
- ConfigurationType,
150
- refreshConfiguration,
151
- updateConfiguration: saveToLocalStorage,
152
- clearConfiguration: clearLocalStorage,
153
- createSharedUrl,
154
- sharedUrl: createSharedUrl(),
155
- };
156
- }, [configuration]);
157
-
158
- return (
159
- <ConfigurationContext.Provider value={providerValue}>
160
- {props.children}
161
- </ConfigurationContext.Provider>
162
- );
163
- };
@@ -1,25 +0,0 @@
1
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2
- // @ts-ignore
3
- export const inProduction = process.env.NODE_ENV === 'production';
4
-
5
- // todo update the configuration and default values
6
- export interface Configuration {
7
- _schemaVersion: string;
8
- unisphereServerUrl: string;
9
- language: string;
10
- theme: 'light' | 'dark';
11
- settings: string;
12
- }
13
-
14
- export const getDefaultConfiguration = (): Configuration => ({
15
- unisphereServerUrl: 'https://unisphere.nvq2.ovp.kaltura.com/v1',
16
- language: 'en',
17
- _schemaVersion: '1',
18
- theme: 'light',
19
- settings: '',
20
- });
21
-
22
- // todo set here the logic needed to validate configuration
23
- export const isConfigurationValid = (config: any): config is Configuration => {
24
- return config?.unisphereServerUrl && config?.settings;
25
- };
@@ -1,31 +0,0 @@
1
- /**
2
- * Simple object check.
3
- * @param item
4
- * @returns {boolean}
5
- */
6
- export function isObject(item: any) {
7
- return item && typeof item === 'object' && !Array.isArray(item);
8
- }
9
-
10
- /**
11
- * Deep merge two objects.
12
- * @param target
13
- * @param ...sources
14
- */
15
- export function mergeDeep(target: any, ...sources: any[]): any {
16
- if (!sources.length) return target;
17
- const source = sources.shift();
18
-
19
- if (isObject(target) && isObject(source)) {
20
- for (const key in source) {
21
- if (isObject(source[key])) {
22
- if (!target[key]) Object.assign(target, { [key]: {} });
23
- mergeDeep(target[key], source[key]);
24
- } else {
25
- Object.assign(target, { [key]: source[key] });
26
- }
27
- }
28
- }
29
-
30
- return mergeDeep(target, ...sources);
31
- }
@@ -1,17 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
-
4
- <head>
5
- <meta charset="utf-8" />
6
- <title>
7
- <%= htmlPageTitle %>
8
- </title>
9
- <meta name="viewport" content="width=device-width, initial-scale=1" />
10
- <link rel="icon" type="image/x-icon" href="favicon.ico" />
11
- </head>
12
-
13
- <body>
14
- <div id="root"></div>
15
- </body>
16
-
17
- </html>
@@ -1,13 +0,0 @@
1
- import { StrictMode } from 'react';
2
- import * as ReactDOM from 'react-dom/client';
3
-
4
- import App from './app/app';
5
-
6
- const root = ReactDOM.createRoot(
7
- document.getElementById('root') as HTMLElement
8
- );
9
- root.render(
10
- <StrictMode>
11
- <App />
12
- </StrictMode>
13
- );
@@ -1,24 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "../../../dist/out-tsc",
5
- "types": [
6
- "node",
7
-
8
- "@nx/react/typings/cssmodule.d.ts",
9
- "@nx/react/typings/image.d.ts"
10
- ]
11
- },
12
- "exclude": [
13
- "jest.config.ts",
14
- "src/**/*.spec.ts",
15
- "src/**/*.test.ts",
16
- "src/**/*.spec.tsx",
17
- "src/**/*.test.tsx",
18
- "src/**/*.spec.js",
19
- "src/**/*.test.js",
20
- "src/**/*.spec.jsx",
21
- "src/**/*.test.jsx"
22
- ],
23
- "include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
24
- }
@@ -1,20 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "jsx": "react-jsx",
4
- "allowJs": false,
5
- "esModuleInterop": false,
6
- "allowSyntheticDefaultImports": true,
7
- "strict": true
8
- },
9
- "files": [],
10
- "include": [],
11
- "references": [
12
- {
13
- "path": "./tsconfig.app.json"
14
- },
15
- {
16
- "path": "./tsconfig.spec.json"
17
- }
18
- ],
19
- "extends": "../../../tsconfig.base.json"
20
- }
@@ -1,25 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "../../../dist/out-tsc",
5
- "module": "commonjs",
6
- "types": [
7
- "jest",
8
- "node",
9
- "@nx/react/typings/cssmodule.d.ts",
10
- "@nx/react/typings/image.d.ts"
11
- ]
12
- },
13
- "include": [
14
- "jest.config.ts",
15
- "src/**/*.test.ts",
16
- "src/**/*.spec.ts",
17
- "src/**/*.test.tsx",
18
- "src/**/*.spec.tsx",
19
- "src/**/*.test.js",
20
- "src/**/*.spec.js",
21
- "src/**/*.test.jsx",
22
- "src/**/*.spec.jsx",
23
- "src/**/*.d.ts"
24
- ]
25
- }