diff --git a/build/main.js b/build/main.js index 5843179..ab9fe2f 100644 --- a/build/main.js +++ b/build/main.js @@ -31,16 +31,13 @@ let Helper; const MsgErrUnknown = "Unknown Error"; let UpdateRunning = false; class Slideshow extends utils.Adapter { + isUnloaded; //#region Basic Adapter Functions constructor(options = {}) { super({ ...options, name: "slideshow" }); - //#endregion - //#region Timer and Action - this.tUpdatePictureStoreTimeout = null; - this.tUpdateCurrentPictureTimeout = null; this.on("ready", this.onReady.bind(this)); this.on("stateChange", this.onStateChange.bind(this)); this.on("unload", this.onUnload.bind(this)); @@ -102,6 +99,10 @@ class Slideshow extends utils.Adapter { callback(); } } + //#endregion + //#region Timer and Action + tUpdatePictureStoreTimeout = null; + tUpdateCurrentPictureTimeout = null; async updatePictureStoreTimer() { UpdateRunning = true; let updatePictureStoreResult = { success: false, picturecount: 0 }; diff --git a/build/main.js.map b/build/main.js.map index bc78c48..04e3794 100644 --- a/build/main.js.map +++ b/build/main.js.map @@ -2,6 +2,6 @@ "version": 3, "sources": ["../src/main.ts"], "sourcesContent": ["/*\n * Created with @iobroker/create-adapter v2.0.1\n */\n\n//#region Imports, Variables and Global\nimport * as utils from \"@iobroker/adapter-core\";\nimport {GlobalHelper} from \"./modules/global-helper\";\nimport * as slideBing from \"./modules/slideBing\";\nimport * as slideLocal from \"./modules/slideLocal\";\nimport * as slideFS from \"./modules/slideFS\";\nimport * as slideSyno from \"./modules/slideSynology\"\n\nlet Helper: GlobalHelper;\nconst MsgErrUnknown = \"Unknown Error\";\nlet UpdateRunning = false;\n\ninterface Picture{\n\turl: string;\n\tpath: string;\n\tinfo1: string;\n\tinfo2: string;\n\tinfo3: string;\n\tdate: Date | null ;\n}\n\ninterface PictureListUpdateResult{\n\tsuccess: boolean;\n\tpicturecount: number;\n}\n//#endregion\n\nclass Slideshow extends utils.Adapter {\n\n\tisUnloaded: boolean;\n\n\t//#region Basic Adapter Functions\n\n\tpublic constructor(options: Partial = {}) {\n\t\tsuper({\n\t\t\t...options,\n\t\t\tname: \"slideshow\",\n\t\t});\n\t\tthis.on(\"ready\", this.onReady.bind(this));\n\t\tthis.on(\"stateChange\", this.onStateChange.bind(this));\n\t\tthis.on(\"unload\", this.onUnload.bind(this));\n\n\t\tthis.isUnloaded = false;\n\t}\n\n\t/**\n\t * Is called when databases are connected and adapter received configuration.\n\t */\n\tprivate async onReady(): Promise {\n\t\ttry{\n\t\t\t// Init Helper\n\t\t\tHelper = new GlobalHelper(this);\n\n\t\t\t// Create button for updates\n\t\t\tawait this.setObjectNotExistsAsync(\"updatepicturelist\", {\n\t\t\t\ttype: \"state\",\n\t\t\t\tcommon: {\n\t\t\t\t\tname: \"updatepicturelist\",\n\t\t\t\t\ttype: \"boolean\",\n\t\t\t\t\trole: \"button\",\n\t\t\t\t\tread: true,\n\t\t\t\t\twrite: true,\n\t\t\t\t\tdesc: \"Update picture list\",\n\t\t\t\t\tdef: false\n\t\t\t\t},\n\t\t\t\tnative: {},\n\t\t\t});\n\t\t\tawait this.setStateAsync(\"updatepicturelist\", false, true);\n\t\t\tthis.subscribeStates(\"updatepicturelist\");\n\n\t\t\t// Starting updatePictureStoreTimer action\n\t\t\tawait this.updatePictureStoreTimer();\n\t\t}catch(err){\n\t\t\tHelper.ReportingError(err as Error, MsgErrUnknown, \"onReady\");\n\t\t}\n\t}\n\n\t/**\n\t * Is called if a subscribed state changes\n\t */\n\tprivate async onStateChange(id: string, state: ioBroker.State | null | undefined): Promise {\n\t\tif (state) {\n\t\t\tif (id === `${this.namespace}.updatepicturelist` && state?.val === true && state?.ack === false){\n\t\t\t\tif (UpdateRunning === true){\n\t\t\t\t\tHelper.ReportingInfo(\"Info\", \"Adapter\", \"Update picture list already running\");\n\t\t\t\t}else{\n\t\t\t\t\tHelper.ReportingInfo(\"Info\", \"Adapter\", \"Updating picture list\");\n\t\t\t\t\tclearTimeout(this.tUpdateCurrentPictureTimeout);\n\t\t\t\t\tawait this.updatePictureStoreTimer();\n\t\t\t\t}\n\t\t\t\tawait this.setStateAsync(\"updatepicturelist\", false, false);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Is called when adapter shuts down - callback has to be called under any circumstances!\n\t */\n\tprivate onUnload(callback: () => void): void {\n\t\ttry {\n\t\t\tthis.isUnloaded = true;\n\t\t\tclearTimeout(this.tUpdateCurrentPictureTimeout);\n\t\t\tclearTimeout(this.tUpdatePictureStoreTimeout);\n\t\t\tcallback();\n\t\t} catch (e) {\n\t\t\tcallback();\n\t\t}\n\t}\n\n\t//#endregion\n\n\t//#region Timer and Action\n\n\tprivate tUpdatePictureStoreTimeout: any = null;\n\tprivate tUpdateCurrentPictureTimeout: any = null;\n\n\tprivate async updatePictureStoreTimer(): Promise{\n\t\tUpdateRunning = true;\n\t\tlet updatePictureStoreResult: PictureListUpdateResult = { success: false, picturecount: 0};\n\t\tHelper.ReportingInfo(\"Debug\", \"Adapter\", \"UpdatePictureStoreTimer occured\");\n\t\ttry{\n\t\t\tthis.tUpdatePictureStoreTimeout && clearTimeout(this.tUpdatePictureStoreTimeout);\n\t\t}catch(err){\n\t\t\tHelper.ReportingError(err as Error, MsgErrUnknown, \"updatePictureStoreTimer\", \"Clear Timer\");\n\t\t}\n\t\ttry{\n\t\t\tswitch(this.config.provider){\n\t\t\t\tcase 1:\n\t\t\t\t\tupdatePictureStoreResult = await slideBing.updatePictureList(Helper);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 2:\n\t\t\t\t\tupdatePictureStoreResult = await slideLocal.updatePictureList(Helper);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 3:\n\t\t\t\t\tupdatePictureStoreResult = await slideFS.updatePictureList(Helper);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 4:\n\t\t\t\t\tupdatePictureStoreResult = await slideSyno.updatePictureList(Helper);\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}catch(err){\n\t\t\tHelper.ReportingError(err as Error, MsgErrUnknown, \"updatePictureStoreTimer\", \"Call Timer Action\");\n\t\t}\n\t\ttry{\n\t\t\tif (this.config.update_picture_list && this.config.update_picture_list > 0 && updatePictureStoreResult.success === true){\n\t\t\t\tHelper.ReportingInfo(\"Debug\", \"updatePictureStoreTimer\", `Update every ${this.config.update_picture_list} hours, starting timer`);\n\t\t\t\tthis.tUpdatePictureStoreTimeout = setTimeout(() => {\n\t\t\t\t\tthis.updatePictureStoreTimer();\n\t\t\t\t}, (this.config.update_picture_list * 3600000)); // Update every configured hours if successfull\n\t\t\t}else if (updatePictureStoreResult.success === false){\n\t\t\t\tthis.tUpdatePictureStoreTimeout = setTimeout(() => {\n\t\t\t\t\tthis.updatePictureStoreTimer();\n\t\t\t\t}, (this.config.update_interval * 300000)); // Update every minute if error\n\t\t\t}\n\t\t\tif (updatePictureStoreResult.success === true && updatePictureStoreResult.picturecount > 0 && this.isUnloaded === false){\n\t\t\t\t// Save picturecount\n\t\t\t\tawait this.setObjectNotExistsAsync(\"picturecount\", {\n\t\t\t\t\ttype: \"state\",\n\t\t\t\t\tcommon: {\n\t\t\t\t\t\tname: \"picturecount\",\n\t\t\t\t\t\ttype: \"number\",\n\t\t\t\t\t\trole: \"value\",\n\t\t\t\t\t\tread: true,\n\t\t\t\t\t\twrite: false,\n\t\t\t\t\t\tdesc: \"Pictures found\"\n\t\t\t\t\t},\n\t\t\t\t\tnative: {},\n\t\t\t\t});\n\t\t\t\tawait this.setStateAsync(\"picturecount\", { val: updatePictureStoreResult.picturecount, ack: true });\n\n\t\t\t\t// Starting updateCurrentPictureTimer action\n\t\t\t\tthis.updateCurrentPictureTimer();\n\t\t\t}\n\t\t}catch(err){\n\t\t\tHelper.ReportingError(err as Error, MsgErrUnknown, \"updatePictureStoreTimer\", \"Set Timer\");\n\t\t}\n\t\tUpdateRunning = false;\n\t}\n\n\tprivate async updateCurrentPictureTimer(): Promise{\n\t\tlet CurrentPictureResult: Picture | null = null;\n\t\tlet Provider = \"\";\n\t\tHelper.ReportingInfo(\"Debug\", \"Adapter\", \"updateCurrentPictureTimer occured\");\n\t\ttry{\n\t\t\tthis.tUpdateCurrentPictureTimeout && clearTimeout(this.tUpdateCurrentPictureTimeout);\n\t\t}catch(err){\n\t\t\tHelper.ReportingError(err as Error, MsgErrUnknown, \"updateCurrentPictureTimer\", \"Clear Timer\");\n\t\t}\n\t\ttry{\n\t\t\tswitch(this.config.provider){\n\t\t\t\tcase 1:\n\t\t\t\t\tCurrentPictureResult = await slideBing.getPicture(Helper);\n\t\t\t\t\tProvider = \"Bing\";\n\t\t\t\t\tbreak;\n\t\t\t\tcase 2:\n\t\t\t\t\tCurrentPictureResult = await slideLocal.getPicture(Helper);\n\t\t\t\t\tProvider = \"Local\";\n\t\t\t\t\tbreak;\n\t\t\t\tcase 3:\n\t\t\t\t\tCurrentPictureResult = await slideFS.getPicture(Helper);\n\t\t\t\t\tProvider = \"FileSystem\";\n\t\t\t\t\tbreak;\n\t\t\t\tcase 4:\n\t\t\t\t\tCurrentPictureResult = await slideSyno.getPicture(Helper);\n\t\t\t\t\tProvider = \"Synology\";\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}catch(err){\n\t\t\tHelper.ReportingError(err as Error, MsgErrUnknown, \"updateCurrentPictureTimer\", \"Call Timer Action\");\n\t\t}\n\t\ttry{\n\t\t\tif (CurrentPictureResult !== null && this.isUnloaded === false){\n\t\t\t\tHelper.ReportingInfo(\"Debug\", Provider, `Set picture to ${CurrentPictureResult.path}`);\n\t\t\t\t// Set picture\n\t\t\t\tawait this.setObjectNotExistsAsync(\"picture\", {\n\t\t\t\t\ttype: \"state\",\n\t\t\t\t\tcommon: {\n\t\t\t\t\t\tname: \"picture\",\n\t\t\t\t\t\ttype: \"string\",\n\t\t\t\t\t\trole: \"text\",\n\t\t\t\t\t\tread: true,\n\t\t\t\t\t\twrite: false,\n\t\t\t\t\t\tdesc: \"Current picture\"\n\t\t\t\t\t},\n\t\t\t\t\tnative: {},\n\t\t\t\t});\n\t\t\t\tawait this.setStateAsync(\"picture\", { val: CurrentPictureResult.url, ack: true });\n\t\t\t\t// Set info1\n\t\t\t\tawait this.setObjectNotExistsAsync(\"info1\", {\n\t\t\t\t\ttype: \"state\",\n\t\t\t\t\tcommon: {\n\t\t\t\t\t\tname: \"info1\",\n\t\t\t\t\t\ttype: \"string\",\n\t\t\t\t\t\trole: \"text\",\n\t\t\t\t\t\tread: true,\n\t\t\t\t\t\twrite: false,\n\t\t\t\t\t\tdesc: \"Info 1 for picture\"\n\t\t\t\t\t},\n\t\t\t\t\tnative: {},\n\t\t\t\t});\n\t\t\t\tawait this.setStateAsync(\"info1\", { val: CurrentPictureResult.info1, ack: true });\n\t\t\t\t// Set info2\n\t\t\t\tawait this.setObjectNotExistsAsync(\"info2\", {\n\t\t\t\t\ttype: \"state\",\n\t\t\t\t\tcommon: {\n\t\t\t\t\t\tname: \"info2\",\n\t\t\t\t\t\ttype: \"string\",\n\t\t\t\t\t\trole: \"text\",\n\t\t\t\t\t\tread: true,\n\t\t\t\t\t\twrite: false,\n\t\t\t\t\t\tdesc: \"Info 2 for picture\"\n\t\t\t\t\t},\n\t\t\t\t\tnative: {},\n\t\t\t\t});\n\t\t\t\tawait this.setStateAsync(\"info2\", { val: CurrentPictureResult.info2, ack: true });\n\t\t\t\t// Set info3\n\t\t\t\tawait this.setObjectNotExistsAsync(\"info3\", {\n\t\t\t\t\ttype: \"state\",\n\t\t\t\t\tcommon: {\n\t\t\t\t\t\tname: \"info3\",\n\t\t\t\t\t\ttype: \"string\",\n\t\t\t\t\t\trole: \"text\",\n\t\t\t\t\t\tread: true,\n\t\t\t\t\t\twrite: false,\n\t\t\t\t\t\tdesc: \"Info 3 for picture\"\n\t\t\t\t\t},\n\t\t\t\t\tnative: {},\n\t\t\t\t});\n\t\t\t\tawait this.setStateAsync(\"info3\", { val: CurrentPictureResult.info3, ack: true });\n\t\t\t\t// Set date\n\t\t\t\tawait this.setObjectNotExistsAsync(\"date\", {\n\t\t\t\t\ttype: \"state\",\n\t\t\t\t\tcommon: {\n\t\t\t\t\t\tname: \"date\",\n\t\t\t\t\t\ttype: \"number\",\n\t\t\t\t\t\trole: \"date\",\n\t\t\t\t\t\tread: true,\n\t\t\t\t\t\twrite: false,\n\t\t\t\t\t\tdesc: \"Date of picture\"\n\t\t\t\t\t},\n\t\t\t\t\tnative: {},\n\t\t\t\t});\n\t\t\t\tawait this.setStateAsync(\"date\", { val: CurrentPictureResult.date?.getTime() || null , ack: true });\n\t\t\t}\n\t\t}catch(err){\n\t\t\tHelper.ReportingError(err as Error, MsgErrUnknown, \"updateCurrentPictureTimer\", \"Call Timer Action\");\n\t\t}\n\t\ttry{\n\t\t\tthis.tUpdateCurrentPictureTimeout = setTimeout(() => {\n\t\t\t\tthis.updateCurrentPictureTimer();\n\t\t\t}, (this.config.update_interval * 1000));\n\t\t}catch(err){\n\t\t\tHelper.ReportingError(err as Error, MsgErrUnknown, \"updateCurrentPictureTimer\", \"Set Timer\");\n\t\t}\n\t}\n\n}\n\nif (module.parent) {\n\t// Export the constructor in compact mode\n\tmodule.exports = (options: Partial | undefined) => new Slideshow(options);\n} else {\n\t// otherwise start the instance directly\n\t(() => new Slideshow())();\n}"], - "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAKA,YAAuB;AACvB,2BAA2B;AAC3B,gBAA2B;AAC3B,iBAA4B;AAC5B,cAAyB;AACzB,gBAA2B;AAE3B,IAAI;AACJ,MAAM,gBAAgB;AACtB,IAAI,gBAAgB;AAiBpB,MAAM,kBAAkB,MAAM,QAAQ;AAAA;AAAA,EAM9B,YAAY,UAAyC,CAAC,GAAG;AAC/D,UAAM;AAAA,MACL,GAAG;AAAA,MACH,MAAM;AAAA,IACP,CAAC;AA4EF;AAAA;AAAA,SAAQ,6BAAkC;AAC1C,SAAQ,+BAAoC;AA5E3C,SAAK,GAAG,SAAS,KAAK,QAAQ,KAAK,IAAI,CAAC;AACxC,SAAK,GAAG,eAAe,KAAK,cAAc,KAAK,IAAI,CAAC;AACpD,SAAK,GAAG,UAAU,KAAK,SAAS,KAAK,IAAI,CAAC;AAE1C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A,IACD,SAAO,KAAI;AACV,aAAO,eAAe,KAAc,eAAe,6BAA6B,mBAAmB;AAAA,IACpG;AACA,QAAG;AACF,WAAK,+BAA+B,WAAW,MAAM;AACpD,aAAK,0BAA0B;AAAA,MAChC,GAAI,KAAK,OAAO,kBAAkB,GAAK;AAAA,IACxC,SAAO,KAAI;AACV,aAAO,eAAe,KAAc,eAAe,6BAA6B,WAAW;AAAA,IAC5F;AAAA,EACD;AAED;AAEA,IAAI,OAAO,QAAQ;AAElB,SAAO,UAAU,CAAC,YAAuD,IAAI,UAAU,OAAO;AAC/F,OAAO;AAEN,GAAC,MAAM,IAAI,UAAU,GAAG;AACzB;", "names": [] } diff --git a/build/modules/global-helper.js b/build/modules/global-helper.js index 00a2aac..0bc99a7 100644 --- a/build/modules/global-helper.js +++ b/build/modules/global-helper.js @@ -22,6 +22,8 @@ __export(global_helper_exports, { }); module.exports = __toCommonJS(global_helper_exports); class GlobalHelper { + Adapter; + Sentry; constructor(adapterInstance) { this.Adapter = adapterInstance; if (this.Adapter.supportsFeature && this.Adapter.supportsFeature("PLUGINS")) { diff --git a/build/modules/global-helper.js.map b/build/modules/global-helper.js.map index b21e152..847eae4 100644 --- a/build/modules/global-helper.js.map +++ b/build/modules/global-helper.js.map @@ -2,6 +2,6 @@ "version": 3, "sources": ["../../src/modules/global-helper.ts"], "sourcesContent": ["import * as SentryObj from \"@sentry/types\";\n\nexport class GlobalHelper{\n\tAdapter: ioBroker.Adapter;\n\tSentry?: SentryObj.Hub;\n\n\tconstructor(adapterInstance: ioBroker.Adapter){\n\t\tthis.Adapter = adapterInstance;\n\t\t// Init Sentry\n\t\tif (this.Adapter.supportsFeature && this.Adapter.supportsFeature(\"PLUGINS\")) {\n\t\t\tconst sentryInstance: ioBroker.Plugin|null = this.Adapter.getPluginInstance(\"sentry\");\n\t\t\tif (sentryInstance) {\n\t\t\t\tthis.Sentry = sentryInstance.getSentryObject();\n\t\t\t}\n\t\t}\n\t}\n\n\t//#region Helper Function ReportingError\n\t/**\n\t * Function for global error reporting\n\t * @param {Object} Err Error-Object\n\t * @param {string} FriendlyError Error message for user\n\t * @param {string} NameFunction Name of the function where error occured\n\t * @param {string} NameAction Name of the subfunction where error occured\n\t * @param {string} Info Contextual information\n\t * @param {boolean} ReportSentry Report error to sentry, default true\n\t */\n\tasync ReportingError(Err: Error|null, FriendlyError: string, NameFunction: string, NameAction = \"\", Info = \"\", ReportSentry = true): Promise{\n\t\ttry{\n\t\t\tlet sErrMsg = `Error occured: ${FriendlyError} in ${NameFunction}`;\n\t\t\tif (NameAction !== \"\") sErrMsg = sErrMsg + `(${NameAction})`;\n\t\t\tif (Err !== null) sErrMsg = sErrMsg + ` [${Err}] [${Info}]`;\n\t\t\tthis.Adapter.log.error(sErrMsg);\n\t\t} catch (e){\n\t\t\tthis.Adapter.log.error(`Exception in ErrorReporting [${e}]`);\n\t\t}\n\t\t// Sentry reporting\n\t\ttry{\n\t\t\tif (this.Sentry && this.Adapter.config.sentry_disable === false && ReportSentry === true) {\n\t\t\t\tthis.Sentry && this.Sentry.withScope(scope => {\n\t\t\t\t\tscope.setLevel(\"error\" as SentryObj.SeverityLevel);\n\t\t\t\t\tscope.setExtra(\"NameFunction\", NameFunction);\n\t\t\t\t\tscope.setExtra(\"NameAction\", NameAction);\n\t\t\t\t\tif (Info){\n\t\t\t\t\t\tscope.setExtra(\"Info\", Info);\n\t\t\t\t\t}\n\t\t\t\t\t//scope.setExtra(\"Config\", this.config);\n\t\t\t\t\tif (this.Sentry){\n\t\t\t\t\t\tthis.Sentry.captureException(Err);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t} catch (e){\n\t\t\tthis.Adapter.log.error(`Exception in ErrorReporting Sentry [${e}]`);\n\t\t}\n\t}\n\t//#endregion\n\n\t//#region Helper Function ReportingInfo\n\t/**\n\t * Function for global information reporting\n\t * @param {\"Info\"|\"Debug\"} Level Level for ioBroker Logging\n\t * @param {string} Category Category of information\n\t * @param {string} Message Message\n\t * @param {{[Key: string]: any}|undefined} Data Contextual data information\n\t */\n\tReportingInfo(Level: \"Info\"|\"Debug\", Category: string, Message: string, Data?:{[Key: string]: any}|undefined): void {\n\t\tlet iobMessage = Message;\n\t\tif (this.Adapter.log.level === \"debug\" || this.Adapter.log.level === \"silly\"){\n\t\t\tiobMessage = `[${Category}] ${Message}`;\n\t\t}\n\t\tswitch(Level){\n\t\t\tcase \"Debug\":\n\t\t\t\tthis.Adapter.log.debug(iobMessage);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthis.Adapter.log.info(iobMessage);\n\t\t\t\tbreak;\n\t\t}\n\t\tthis.Sentry?.addBreadcrumb({\n\t\t\tcategory: Category,\n\t\t\tmessage: Message,\n\t\t\tlevel: Level as SentryObj.Severity,\n\t\t\tdata: Data\n\t\t})\n\t}\n\t//#endregion\n}"], - "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,MAAM,aAAY;AAAA,EAIxB,YAAY,iBAAkC;AAC7C,SAAK,UAAU;AAEf,QAAI,KAAK,QAAQ,mBAAmB,KAAK,QAAQ,gBAAgB,SAAS,GAAG;AAC5E,YAAM,iBAAwC,KAAK,QAAQ,kBAAkB,QAAQ;AACrF,UAAI,gBAAgB;AACnB,aAAK,SAAS,eAAe,gBAAgB;AAAA,MAC9C;AAAA,IACD;AAAA,EACD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYA,MAAM,eAAe,KAAiB,eAAuB,cAAsB,aAAa,IAAI,OAAO,IAAI,eAAe,MAAoB;AACjJ,QAAG;AACF,UAAI,UAAU,kBAAkB,aAAa,OAAO,YAAY;AAChE,UAAI,eAAe;AAAI,kBAAU,UAAU,IAAI,UAAU;AACzD,UAAI,QAAQ;AAAM,kBAAU,UAAU,KAAK,GAAG,MAAM,IAAI;AACxD,WAAK,QAAQ,IAAI,MAAM,OAAO;AAAA,IAC/B,SAAS,GAAE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jB,QAAI,KAAK,QAAQ,IAAI,UAAU,WAAW,KAAK,QAAQ,IAAI,UAAU,SAAQ;AAC5E,mBAAa,IAAI,QAAQ,KAAK,OAAO;AAAA,IACtC;AACA,YAAO,OAAM;AAAA,MACZ,KAAK;AACJ,aAAK,QAAQ,IAAI,MAAM,UAAU;AACjC;AAAA,MACD;AACC,aAAK,QAAQ,IAAI,KAAK,UAAU;AAChC;AAAA,IACF;AACA,eAAK,WAAL,mBAAa,cAAc;AAAA,MAC1B,UAAU;AAAA,MACV,SAAS;AAAA,MACT,OAAO;AAAA,MACP,MAAM;AAAA,IACP;AAAA,EACD;AAAA;AAED;", "names": [] } diff --git a/package-lock.json b/package-lock.json index 2ea3e6b..2317ce1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,6 +23,7 @@ "@iobroker/adapter-dev": "^1.3.0", "@iobroker/testing": "^5.0.0", "@sentry/types": "^7.104.0", + "@tsconfig/node18": "^18.2.4", "@types/chai": "^4.3.20", "@types/chai-as-promised": "^8.0.1", "@types/image-size": "^0.8.0", @@ -44,7 +45,7 @@ "sinon-chai": "^3.7.0", "source-map-support": "^0.5.21", "ts-node": "^10.9.2", - "typescript": "~5.0.4" + "typescript": "~5.6.3" }, "engines": { "node": ">=18" @@ -1433,6 +1434,13 @@ "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", "dev": true }, + "node_modules/@tsconfig/node18": { + "version": "18.2.4", + "resolved": "https://registry.npmjs.org/@tsconfig/node18/-/node18-18.2.4.tgz", + "integrity": "sha512-5xxU8vVs9/FNcvm3gE07fPbn9tl6tqGGWA9tSlwsUEkBxtRnTsNmwrV8gasZ9F/EobaSv9+nu8AxUKccw77JpQ==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/chai": { "version": "4.3.20", "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.20.tgz", @@ -5228,16 +5236,17 @@ } }, "node_modules/typescript": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz", - "integrity": "sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==", + "version": "5.6.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.3.tgz", + "integrity": "sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw==", "dev": true, + "license": "Apache-2.0", "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" }, "engines": { - "node": ">=12.20" + "node": ">=14.17" } }, "node_modules/uc.micro": { diff --git a/package.json b/package.json index 5df9030..6baaafa 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "@iobroker/adapter-dev": "^1.3.0", "@iobroker/testing": "^5.0.0", "@sentry/types": "^7.104.0", + "@tsconfig/node18": "^18.2.4", "@types/chai": "^4.3.20", "@types/chai-as-promised": "^8.0.1", "@types/image-size": "^0.8.0", @@ -56,7 +57,7 @@ "sinon-chai": "^3.7.0", "source-map-support": "^0.5.21", "ts-node": "^10.9.2", - "typescript": "~5.0.4" + "typescript": "~5.6.3" }, "main": "build/main.js", "scripts": { diff --git a/tsconfig.json b/tsconfig.json index 94a41a5..535232c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,8 @@ // Root tsconfig to set the settings and power editor support for all TS files { - "compileOnSave": true, + // To update the compilation target, install a different version of @tsconfig/node... and reference it here + // https://github.com/tsconfig/bases#node-18-tsconfigjson + "extends": "@tsconfig/node18/tsconfig.json", "compilerOptions": { // do not compile anything, this file is just to configure type checking // the compilation is configured in tsconfig.build.json @@ -10,40 +12,28 @@ "allowJs": true, "checkJs": true, - "skipLibCheck": true, // Don't report errors in 3rd party definitions "noEmitOnError": true, "outDir": "./build/", "removeComments": false, - "module": "commonjs", - "moduleResolution": "node", - "esModuleInterop": true, - // this is necessary for the automatic typing of the adapter config + + // This is necessary for the automatic typing of the adapter config "resolveJsonModule": true, - // Set this to false if you want to disable the very strict rules (not recommended) - "strict": true, - // Or enable some of those features for more fine-grained control + // If you want to disable the stricter type checks (not recommended), uncomment the following line + // "strict": false, + // And enable some of those features for more fine-grained control // "strictNullChecks": true, // "strictPropertyInitialization": true, // "strictBindCallApply": true, // "noImplicitAny": true, // "noUnusedLocals": true, // "noUnusedParameters": true, - - // Consider targetting es2019 or higher if you only support Node.js 12+ - "target": "es2018", + // Uncomment this if you want the old behavior of catch variables being `any` + // "useUnknownInCatchVariables": false, "sourceMap": true, - "inlineSourceMap": false, - "watch": false + "inlineSourceMap": false }, - "include": [ - "src/**/*.ts", - "admin/**/*.ts", - "admin/**/*.tsx" - ], - "exclude": [ - "build/**", - "node_modules/**" - ] -} \ No newline at end of file + "include": ["src/**/*.ts", "test/**/*.ts"], + "exclude": ["build/**", "node_modules/**", "widgets/**"] +}