);
+const container: HTMLElement | null = document.getElementById('root');
+if (container) {
+ const root = createRoot(container);
+ root.render(
);
+}
// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
diff --git a/src/src/serviceWorker.js b/src/src/serviceWorker.ts
similarity index 89%
rename from src/src/serviceWorker.js
rename to src/src/serviceWorker.ts
index 13949f3..e969b77 100644
--- a/src/src/serviceWorker.js
+++ b/src/src/serviceWorker.ts
@@ -18,9 +18,10 @@ const isLocalhost = Boolean(
window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/),
);
-export function register(config) {
+export function register(config: any): void {
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
// The URL constructor is available in all browsers that support SW.
+ // @ts-expect-error some trick
const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);
if (publicUrl.origin !== window.location.origin) {
// Our service worker won't work if PUBLIC_URL is on a different origin
@@ -38,7 +39,7 @@ export function register(config) {
// Add some additional logging to localhost, pointing developers to the
// service worker/PWA documentation.
- navigator.serviceWorker.ready.then(() => {
+ void window.navigator.serviceWorker.ready.then(() => {
console.log(
'This web app is being served cache-first by a service ' +
'worker. To learn more, visit http://bit.ly/CRA-PWA',
@@ -52,7 +53,7 @@ export function register(config) {
}
}
-function registerValidSW(swUrl, config) {
+function registerValidSW(swUrl: string, config: any): void {
navigator.serviceWorker
.register(swUrl)
.then(registration => {
@@ -96,7 +97,7 @@ function registerValidSW(swUrl, config) {
});
}
-function checkValidServiceWorker(swUrl, config) {
+function checkValidServiceWorker(swUrl: string, config: any): void {
// Check if the service worker can be found. If it can't reload the page.
fetch(swUrl)
.then(response => {
@@ -104,8 +105,8 @@ function checkValidServiceWorker(swUrl, config) {
const contentType = response.headers.get('content-type');
if (response.status === 404 || (contentType != null && contentType.indexOf('javascript') === -1)) {
// No service worker found. Probably a different app. Reload the page.
- navigator.serviceWorker.ready.then(registration => {
- registration.unregister().then(() => {
+ void window.navigator.serviceWorker.ready.then(registration => {
+ void registration.unregister().then(() => {
window.location.reload();
});
});
@@ -119,10 +120,10 @@ function checkValidServiceWorker(swUrl, config) {
});
}
-export function unregister() {
+export function unregister(): void {
if ('serviceWorker' in navigator) {
- navigator.serviceWorker.ready.then(registration => {
- registration.unregister();
+ void window.navigator.serviceWorker.ready.then(async registration => {
+ await registration.unregister();
});
}
}
diff --git a/src/src/types.d.ts b/src/src/types.d.ts
new file mode 100644
index 0000000..3506336
--- /dev/null
+++ b/src/src/types.d.ts
@@ -0,0 +1,27 @@
+import type { URLImageSettings } from './Types/URLImage';
+import type { UrlBasicAuthImageSettings } from './Types/URLBasicAuthImage';
+import type { RTSPImageSettings } from './Types/RTSPImage';
+import type { RTSPReolinkE1Settings } from './Types/RTSPReolinkE1';
+import type { RTSPEufySettings } from './Types/RTSPEufy';
+import type { RTSPHiKamSettings } from './Types/RTSPHiKam';
+
+export type CameraSettings =
+ | URLImageSettings
+ | UrlBasicAuthImageSettings
+ | RTSPImageSettings
+ | RTSPReolinkE1Settings
+ | RTSPEufySettings
+ | RTSPHiKamSettings;
+
+export interface CamerasInstanceNative {
+ cameras: CameraSettings[];
+ webInstance: string;
+ bind: string;
+ defaultTimeout: number;
+ key: string;
+ port: number;
+ ffmpegPath: string;
+ tempPath: string;
+ defaultCacheTimeout: string;
+ dateFormat: string;
+}
diff --git a/src/tsconfig.json b/src/tsconfig.json
new file mode 100644
index 0000000..c6c0031
--- /dev/null
+++ b/src/tsconfig.json
@@ -0,0 +1,26 @@
+{
+ "compilerOptions": {
+ "target": "ESNext",
+ "lib": ["DOM", "DOM.Iterable", "ESNext"],
+ "allowJs": true,
+ "skipLibCheck": true,
+ "esModuleInterop": true,
+ "allowSyntheticDefaultImports": true,
+ "strict": true,
+ "forceConsistentCasingInFileNames": true,
+ "noFallthroughCasesInSwitch": true,
+ "module": "ESNext",
+ "moduleResolution": "Node",
+ "resolveJsonModule": true,
+ "isolatedModules": true,
+ "noEmit": true,
+ "jsx": "react-jsx",
+ "baseUrl": "./",
+ "types": ["@iobroker/types", "vite/client"],
+ "paths": {
+ "@/*": ["src/*"]
+ }
+ },
+ "include": ["src"],
+ "exclude": ["node_modules", "build"]
+}
diff --git a/src/vite.config.ts b/src/vite.config.ts
new file mode 100644
index 0000000..8f0f4b1
--- /dev/null
+++ b/src/vite.config.ts
@@ -0,0 +1,19 @@
+import type { UserConfig } from 'vite';
+
+export default {
+ build: {
+ outDir: 'build',
+ rollupOptions: {
+ onwarn: (warning: any, warn: (log: any) => void) => {
+ if (warning.code === 'MODULE_LEVEL_DIRECTIVE') {
+ return;
+ }
+ warn(warning);
+ },
+ },
+ },
+ base: './',
+ server: {
+ port: 3000,
+ },
+} satisfies UserConfig;
diff --git a/tasks.js b/tasks.js
index 4fb41ee..1a15433 100644
--- a/tasks.js
+++ b/tasks.js
@@ -8,7 +8,14 @@
const fs= require('node:fs');
const adapterName = require('./package.json').name.replace('iobroker.', '');
-const { deleteFoldersRecursive, npmInstall, buildReact, copyFiles, collectFiles, patchHtmlFile } = require('@iobroker/build-tools');
+const {
+ deleteFoldersRecursive,
+ npmInstall,
+ buildReact,
+ copyFiles,
+ collectFiles,
+ patchHtmlFile,
+} = require('@iobroker/build-tools');
function clean() {
deleteFoldersRecursive(`${__dirname}/admin`);
@@ -66,7 +73,7 @@ if (process.argv.includes('--0-clean')) {
.catch(e => console.error(e));
}
} else if (process.argv.includes('--2-build')) {
- buildReact(`${__dirname}/src/`, { rootDir: __dirname })
+ buildReact(`${__dirname}/src/`, { rootDir: __dirname, vite: true, tsc: true })
.catch(e => console.error(e));
} else if (process.argv.includes('--3-copy')) {
copyAllFiles();
@@ -83,7 +90,7 @@ if (process.argv.includes('--0-clean')) {
npmPromise = Promise.resolve();
}
npmPromise
- .then(() => buildReact(`${__dirname}/src/`, { rootDir: __dirname }))
+ .then(() => buildReact(`${__dirname}/src/`, { rootDir: __dirname, vite: true, tsc: true }))
.then(() => copyAllFiles())
.then(() => patchHtmlFile(`${__dirname}/admin/index_m.html`))
.catch(e => console.error(e));
@@ -112,8 +119,9 @@ if (process.argv.includes('--0-clean')) {
} else {
npmPromise = Promise.resolve();
}
+
npmPromise
- .then(() => buildReact(`${__dirname}/src/`, { rootDir: __dirname }))
+ .then(() => buildReact(`${__dirname}/src/`, { rootDir: __dirname, vite: true, tsc: true }))
.then(() => copyAllFiles())
.then(() => patchHtmlFile(`${__dirname}/admin/index_m.html`))
.then(() => cleanWidgets())
diff --git a/widgets/cameras/customWidgets.js b/widgets/cameras/customWidgets.js
index 1b7f143..7bc39e1 100644
--- a/widgets/cameras/customWidgets.js
+++ b/widgets/cameras/customWidgets.js
@@ -1,2 +1,2 @@
-var vis2CameraWidgets;!function(){"use strict";var e={1927:function(e,n,r){var t={"./RtspCamera":function(){return Promise.all([r.e("webpack_sharing_consume_default_react_react"),r.e("webpack_sharing_consume_default_prop-types_prop-types"),r.e("src_RtspCamera_jsx")]).then((function(){return function(){return r(7003)}}))},"./SnapshotCamera":function(){return Promise.all([r.e("webpack_sharing_consume_default_react_react"),r.e("webpack_sharing_consume_default_prop-types_prop-types"),r.e("webpack_sharing_consume_default_mui_icons-material_mui_icons-material-webpack_sharing_consume-6275fc"),r.e("src_SnapshotCamera_jsx")]).then((function(){return function(){return r(4779)}}))},"./translations":function(){return r.e("src_translations_js").then((function(){return function(){return r(9389)}}))}},o=function(e,n){return r.R=n,n=r.o(t,e)?t[e]():Promise.resolve().then((function(){throw new Error('Module "'+e+'" does not exist in container.')})),r.R=void 0,n},u=function(e,n){if(r.S){var t="default",o=r.S[t];if(o&&o!==e)throw new Error("Container initialization failed as it has already been initialized with a different share scope");return r.S[t]=e,r.I(t,n)}};r.d(n,{get:function(){return o},init:function(){return u}})}},n={};function r(t){var o=n[t];if(void 0!==o)return o.exports;var u=n[t]={exports:{}};return e[t](u,u.exports,r),u.exports}r.m=e,r.c=n,r.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(n,{a:n}),n},r.d=function(e,n){for(var t in n)r.o(n,t)&&!r.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:n[t]})},r.f={},r.e=function(e){return Promise.all(Object.keys(r.f).reduce((function(n,t){return r.f[t](e,n),n}),[]))},r.u=function(e){return"static/js/"+e+"."+{"vendors-node_modules_mui_system_DefaultPropsProvider_DefaultPropsProvider_js-node_modules_mui-b4726f":"107a30a1","vendors-node_modules_mui_material_utils_createSvgIcon_js":"0ce21a09","vendors-node_modules_mui_icons-material_esm_index_js":"e8655394",webpack_sharing_consume_default_react_react:"b0a6443e","webpack_sharing_consume_default_prop-types_prop-types":"aca21ded",webpack_sharing_consume_default_mui_system_mui_system:"22305f87","node_modules_react_jsx-runtime_js-node_modules_babel_runtime_helpers_esm_defineProperty_js-no-74b4ba0":"218d904f","vendors-node_modules_mui_system_Grid_createGrid_js-node_modules_mui_system_RtlProvider_index_-f04b9e":"7bee8596","vendors-node_modules_mui_material_index_js":"d546de2a","webpack_sharing_consume_default_react-dom_react-dom":"fb052048","node_modules_react_jsx-runtime_js-node_modules_babel_runtime_helpers_esm_assertThisInitialize-6ee429":"3fdfddda","vendors-node_modules_mui_system_index_js":"e4bd3f6b","node_modules_react_jsx-runtime_js-node_modules_babel_runtime_helpers_esm_defineProperty_js-no-74b4ba1":"597f9502","node_modules_prop-types_index_js":"a8c67e23","vendors-node_modules_react-dom_index_js":"ff3cc714",node_modules_react_index_js:"879044e2",src_RtspCamera_jsx:"c19f8b41","webpack_sharing_consume_default_mui_icons-material_mui_icons-material-webpack_sharing_consume-6275fc":"c0b39c5f",src_SnapshotCamera_jsx:"866fc03d",src_translations_js:"0c02be9a"}[e]+".chunk.js"},r.miniCssF=function(e){},r.g=function(){if("object"===typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"===typeof window)return window}}(),r.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},function(){var e={},n="iobroker.vis-2-widgets-camera:";r.l=function(t,o,u,_){if(e[t])e[t].push(o);else{var s,i;if(void 0!==u)for(var a=document.getElementsByTagName("script"),d=0;d
=0)){if(o.push(u),e[t])return e[t];r.o(r.S,t)||(r.S[t]={});var _=r.S[t],s="iobroker.vis-2-widgets-camera",i=function(e,n,r,t){var o=_[e]=_[e]||{},u=o[n];(!u||!u.loaded&&(!t!=!u.eager?t:s>u.from))&&(o[n]={get:r,from:s,eager:!!t})},a=[];if("default"===t)i("@mui/icons-material","*",(function(){return Promise.all([r.e("vendors-node_modules_mui_system_DefaultPropsProvider_DefaultPropsProvider_js-node_modules_mui-b4726f"),r.e("vendors-node_modules_mui_material_utils_createSvgIcon_js"),r.e("vendors-node_modules_mui_icons-material_esm_index_js"),r.e("webpack_sharing_consume_default_react_react"),r.e("webpack_sharing_consume_default_prop-types_prop-types"),r.e("webpack_sharing_consume_default_mui_system_mui_system"),r.e("node_modules_react_jsx-runtime_js-node_modules_babel_runtime_helpers_esm_defineProperty_js-no-74b4ba0")]).then((function(){return function(){return r(4640)}}))})),i("@mui/material","*",(function(){return Promise.all([r.e("vendors-node_modules_mui_system_DefaultPropsProvider_DefaultPropsProvider_js-node_modules_mui-b4726f"),r.e("vendors-node_modules_mui_material_utils_createSvgIcon_js"),r.e("vendors-node_modules_mui_system_Grid_createGrid_js-node_modules_mui_system_RtlProvider_index_-f04b9e"),r.e("vendors-node_modules_mui_material_index_js"),r.e("webpack_sharing_consume_default_react_react"),r.e("webpack_sharing_consume_default_prop-types_prop-types"),r.e("webpack_sharing_consume_default_mui_system_mui_system"),r.e("webpack_sharing_consume_default_react-dom_react-dom"),r.e("node_modules_react_jsx-runtime_js-node_modules_babel_runtime_helpers_esm_assertThisInitialize-6ee429")]).then((function(){return function(){return r(2879)}}))})),i("@mui/system","*",(function(){return Promise.all([r.e("vendors-node_modules_mui_system_DefaultPropsProvider_DefaultPropsProvider_js-node_modules_mui-b4726f"),r.e("vendors-node_modules_mui_system_Grid_createGrid_js-node_modules_mui_system_RtlProvider_index_-f04b9e"),r.e("vendors-node_modules_mui_system_index_js"),r.e("webpack_sharing_consume_default_react_react"),r.e("webpack_sharing_consume_default_prop-types_prop-types"),r.e("node_modules_react_jsx-runtime_js-node_modules_babel_runtime_helpers_esm_defineProperty_js-no-74b4ba1")]).then((function(){return function(){return r(1025)}}))})),i("prop-types","*",(function(){return r.e("node_modules_prop-types_index_js").then((function(){return function(){return r(2007)}}))})),i("react-dom","*",(function(){return Promise.all([r.e("vendors-node_modules_react-dom_index_js"),r.e("webpack_sharing_consume_default_react_react")]).then((function(){return function(){return r(4164)}}))})),i("react","*",(function(){return r.e("node_modules_react_index_js").then((function(){return function(){return r(2791)}}))}));return a.length?e[t]=Promise.all(a).then((function(){return e[t]=1})):e[t]=1}}}(),function(){var e;r.g.importScripts&&(e=r.g.location+"");var n=r.g.document;if(!e&&n&&(n.currentScript&&(e=n.currentScript.src),!e)){var t=n.getElementsByTagName("script");if(t.length)for(var o=t.length-1;o>-1&&!e;)e=t[o--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),r.p=e}(),function(){var e=function(e){var n=function(e){return e.split(".").map((function(e){return+e==e?+e:e}))},r=/^([^-+]+)?(?:-([^+]+))?(?:\+(.+))?$/.exec(e),t=r[1]?n(r[1]):[];return r[2]&&(t.length++,t.push.apply(t,n(r[2]))),r[3]&&(t.push([]),t.push.apply(t,n(r[3]))),t},n=function(n,r){n=e(n),r=e(r);for(var t=0;;){if(t>=n.length)return t=r.length)return"u"==u;var _=r[t],s=(typeof _)[0];if(u!=s)return"o"==u&&"n"==s||"s"==s||"u"==u;if("o"!=u&&"u"!=u&&o!=_)return o<_;t++}},t=function(e){var n=e[0],r="";if(1===e.length)return"*";if(n+.5){r+=0==n?">=":-1==n?"<":1==n?"^":2==n?"~":n>0?"=":"!=";for(var o=1,u=1;u0?".":"")+(o=2,s);return r}var _=[];for(u=1;u=r.length||"o"==(d=(typeof(a=r[_]))[0]))return!i||("u"==c?s>t&&!u:""==c!=u);if("u"==d){if(!i||"u"!=c)return!1}else if(i)if(c==d)if(s<=t){if(a!=n[s])return!1}else{if(u?a>n[s]:a=0)){if(o.push(u),e[t])return e[t];r.o(r.S,t)||(r.S[t]={});var _=r.S[t],s="iobroker.vis-2-widgets-camera",i=function(e,n,r,t){var o=_[e]=_[e]||{},u=o[n];(!u||!u.loaded&&(!t!=!u.eager?t:s>u.from))&&(o[n]={get:r,from:s,eager:!!t})},a=[];if("default"===t)i("@mui/icons-material","*",(function(){return Promise.all([r.e("vendors-node_modules_mui_system_DefaultPropsProvider_DefaultPropsProvider_js-node_modules_mui-b4726f"),r.e("vendors-node_modules_mui_material_utils_createSvgIcon_js"),r.e("vendors-node_modules_mui_icons-material_esm_index_js"),r.e("webpack_sharing_consume_default_react_react"),r.e("webpack_sharing_consume_default_prop-types_prop-types"),r.e("webpack_sharing_consume_default_mui_system_mui_system"),r.e("node_modules_react_jsx-runtime_js-node_modules_babel_runtime_helpers_esm_defineProperty_js-no-74b4ba0")]).then((function(){return function(){return r(4640)}}))})),i("@mui/material","*",(function(){return Promise.all([r.e("vendors-node_modules_mui_system_DefaultPropsProvider_DefaultPropsProvider_js-node_modules_mui-b4726f"),r.e("vendors-node_modules_mui_material_utils_createSvgIcon_js"),r.e("vendors-node_modules_mui_system_Grid_createGrid_js-node_modules_mui_system_RtlProvider_index_-f04b9e"),r.e("vendors-node_modules_mui_material_index_js"),r.e("webpack_sharing_consume_default_react_react"),r.e("webpack_sharing_consume_default_prop-types_prop-types"),r.e("webpack_sharing_consume_default_mui_system_mui_system"),r.e("webpack_sharing_consume_default_react-dom_react-dom"),r.e("node_modules_react_jsx-runtime_js-node_modules_babel_runtime_helpers_esm_assertThisInitialize-6ee429")]).then((function(){return function(){return r(2879)}}))})),i("@mui/system","*",(function(){return Promise.all([r.e("vendors-node_modules_mui_system_DefaultPropsProvider_DefaultPropsProvider_js-node_modules_mui-b4726f"),r.e("vendors-node_modules_mui_system_Grid_createGrid_js-node_modules_mui_system_RtlProvider_index_-f04b9e"),r.e("vendors-node_modules_mui_system_index_js"),r.e("webpack_sharing_consume_default_react_react"),r.e("webpack_sharing_consume_default_prop-types_prop-types"),r.e("node_modules_react_jsx-runtime_js-node_modules_babel_runtime_helpers_esm_defineProperty_js-no-74b4ba1")]).then((function(){return function(){return r(1025)}}))})),i("prop-types","*",(function(){return r.e("node_modules_prop-types_index_js").then((function(){return function(){return r(2007)}}))})),i("react-dom","*",(function(){return Promise.all([r.e("vendors-node_modules_react-dom_index_js"),r.e("webpack_sharing_consume_default_react_react")]).then((function(){return function(){return r(4164)}}))})),i("react","*",(function(){return r.e("node_modules_react_index_js").then((function(){return function(){return r(2791)}}))}));return a.length?e[t]=Promise.all(a).then((function(){return e[t]=1})):e[t]=1}}}(),function(){var e;r.g.importScripts&&(e=r.g.location+"");var n=r.g.document;if(!e&&n&&(n.currentScript&&(e=n.currentScript.src),!e)){var t=n.getElementsByTagName("script");if(t.length)for(var o=t.length-1;o>-1&&!e;)e=t[o--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),r.p=e}(),function(){var e=function(e){var n=function(e){return e.split(".").map((function(e){return+e==e?+e:e}))},r=/^([^-+]+)?(?:-([^+]+))?(?:\+(.+))?$/.exec(e),t=r[1]?n(r[1]):[];return r[2]&&(t.length++,t.push.apply(t,n(r[2]))),r[3]&&(t.push([]),t.push.apply(t,n(r[3]))),t},n=function(n,r){n=e(n),r=e(r);for(var t=0;;){if(t>=n.length)return t=r.length)return"u"==u;var _=r[t],s=(typeof _)[0];if(u!=s)return"o"==u&&"n"==s||"s"==s||"u"==u;if("o"!=u&&"u"!=u&&o!=_)return o<_;t++}},t=function(e){var n=e[0],r="";if(1===e.length)return"*";if(n+.5){r+=0==n?">=":-1==n?"<":1==n?"^":2==n?"~":n>0?"=":"!=";for(var o=1,u=1;u0?".":"")+(o=2,s);return r}var _=[];for(u=1;u=r.length||"o"==(c=(typeof(a=r[_]))[0]))return!i||("u"==d?s>t&&!u:""==d!=u);if("u"==c){if(!i||"u"!=d)return!1}else if(i)if(d==c)if(s<=t){if(a!=n[s])return!1}else{if(u?a>n[s]:a