iobroker.javascript 10.2.4 → 10.3.0

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 (186) hide show
  1. package/README.md +10 -21
  2. package/admin/assets/AiChatPanel-CpY4Bun-.js +27 -0
  3. package/admin/assets/{AiChatService-Bsp_rhVx.js → AiChatService-QKcpW4jQ.js} +1 -1
  4. package/admin/assets/AiDiffView-DscPfZ38.js +1 -0
  5. package/admin/assets/{AiInlineProvider-BxOW88xU.js → AiInlineProvider-DTSPKoXG.js} +1 -1
  6. package/admin/assets/BlocklyEditor-BZyoN1JE.js +301 -0
  7. package/admin/assets/Compile-B0uHjrBE.css +1 -0
  8. package/admin/assets/Compile-Oss28m_f.js +165 -0
  9. package/admin/assets/Debugger-teJTIU-2.js +15 -0
  10. package/admin/assets/Documentation-uz4Ut9pT.js +4339 -0
  11. package/admin/assets/ExpandMore-V5Ix1QB1.js +1 -0
  12. package/admin/assets/FbEditor-B8S-mCvc.css +1 -0
  13. package/admin/assets/FbEditor-aOZ-RpPV.js +15 -0
  14. package/admin/assets/Import-BIC5Ee9z.js +1 -0
  15. package/admin/assets/NotificationsActive-BdzH44gp.js +1 -0
  16. package/admin/assets/RulesEditor-CcDVthPa.js +1 -0
  17. package/admin/assets/{ScriptEditor-BCGahS47.js → ScriptEditor-CviB6Hif.js} +2 -2
  18. package/admin/assets/ScriptEditorVanillaMonaco-ByuXwybM.js +3 -0
  19. package/admin/assets/Send-Mdo32jMb.js +1 -0
  20. package/admin/assets/_virtual_mf-localSharedImportMap___mfe_internal__iobroker_javascript__mf_owner__1-BnL93BgK.js +1 -0
  21. package/admin/assets/_virtual_mf___mfe_internal__iobroker_javascript__mf_owner__180366418666083__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-NI-3Uv4e.js +1217 -0
  22. package/admin/assets/_virtual_mf___mfe_internal__iobroker_javascript__mf_owner__180366418666083__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-DVaMIZyC.js +9 -0
  23. package/admin/assets/aiPromptBuilder-yTB6N2VT.js +1 -0
  24. package/admin/assets/blocklyTheme-CGhU3cEO.js +1 -0
  25. package/admin/assets/blocks_action-BQ4O7NRE.js +1 -0
  26. package/admin/assets/{blocks_convert-CLb0DLyc.js → blocks_convert-0VBjfhqQ.js} +1 -1
  27. package/admin/assets/blocks_logic-DAo99xDr.js +1 -0
  28. package/admin/assets/blocks_number-C--e19NU.js +1 -0
  29. package/admin/assets/blocks_object-D0TPhdzg.js +1 -0
  30. package/admin/assets/blocks_procedures-DgTxgXdB.js +3 -0
  31. package/admin/assets/{blocks_sendto-BxCMg9X4.js → blocks_sendto-CRIrtOUc.js} +1 -1
  32. package/admin/assets/blocks_switch-b_GYfF0n.js +2 -0
  33. package/admin/assets/blocks_system-BdkUdSsc.js +1 -0
  34. package/admin/assets/blocks_text-DSFhEVOf.js +1 -0
  35. package/admin/assets/blocks_time-CqALAiJp.js +1 -0
  36. package/admin/assets/blocks_timeout-yrOD2pZp.js +1 -0
  37. package/admin/assets/{blocks_trigger-XivsIDE5.js → blocks_trigger-DeAYXpSS.js} +1 -1
  38. package/admin/assets/{cronHoverProvider-BZMOFHO_.js → cronHoverProvider-DoO2_tpG.js} +1 -1
  39. package/admin/assets/{field_cron-CxKi__cX.js → field_cron-D3Ts_s9M.js} +1 -1
  40. package/admin/assets/{field_oid-CJIYiGxY.js → field_oid-BRNXredg.js} +1 -1
  41. package/admin/assets/{field_script-CehplM7L.js → field_script-3X6ousg7.js} +1 -1
  42. package/admin/assets/helpers-BTGaTdnT.js +1 -0
  43. package/admin/assets/{hostInit-Bs-bStPF.js → hostInit-2h2Cbsaw.js} +1 -1
  44. package/admin/assets/iconLibraryData-B5fiyl1C.js +1 -0
  45. package/admin/assets/index-BHhhebRG.css +1 -0
  46. package/admin/assets/index-CbQlIKB_.js +156 -0
  47. package/admin/assets/{inlineChatWidget-NIvdRGmU.js → inlineChatWidget-BwQVCPkx.js} +1 -1
  48. package/admin/assets/{inlineDiffController-Qh402KhK.js → inlineDiffController-BsDDsDHn.js} +1 -1
  49. package/admin/assets/loadBlocks-RpqM7PwO.js +117 -0
  50. package/admin/assets/loadMonaco-BVOEahNw.js +1 -0
  51. package/admin/assets/{mf-entry-bootstrap-0-019228a5.js → mf-entry-bootstrap-0-0deef484.js} +3 -3
  52. package/admin/assets/{pendingShares-B3t6ewri.js → pendingShares-BaAadIDv.js} +1 -1
  53. package/admin/assets/reactour.esm-DX9ZgYlx.js +137 -0
  54. package/admin/assets/stateHoverProvider-BEadnSXp.js +11 -0
  55. package/admin/assets/tileFbd-CWAy7R7m.svg +85 -0
  56. package/admin/custom/assets/Components-FkGDIlId.js +1 -0
  57. package/admin/custom/assets/_virtual_mf-localSharedImportMap___mfe_internal__ConfigCustomJavascriptSet__mf_owner__1-Cs88NUCd.js +1 -0
  58. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__37453319418803__loadShare___mf_0_emotion_mf_1_react__loadShare__.js-P-8ffWXw.js +1 -0
  59. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__37453319418803__loadShare___mf_0_emotion_mf_1_styled__loadShare__.js-ZVuRAEo5.js +1 -0
  60. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__37453319418803__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-DVb0ZZ1Q.js +1217 -0
  61. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__37453319418803__loadShare___mf_0_iobroker_mf_1_json_mf_2_config__loadShare__.js-Dna3WF04.js +1 -0
  62. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__37453319418803__loadShare___mf_0_mui_mf_1_x_mf_2_date_mf_2_pickers__loadShare__.js-DcjdCGAx.js +1 -0
  63. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__37453319418803__loadShare__date_mf_2_fns__loadShare__.js-CnhNjamd.js +1 -0
  64. package/admin/custom/assets/{_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__136440932828998__loadShare__leaflet__loadShare__.js-im3edKNs.js → _virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__37453319418803__loadShare__leaflet__loadShare__.js-Dz7BFJqH.js} +1 -1
  65. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__37453319418803__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-B0olko2J.js +1 -0
  66. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__37453319418803__prebuild___mf_0_iobroker_mf_1_json_mf_2_config__prebuild__-CzN4reh_.js +122 -0
  67. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__37453319418803__prebuild__leaflet__prebuild__-xPcBaiTQ.js +1 -0
  68. package/admin/custom/assets/{_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__136440932828998__prebuild__react_mf_1_jsx_mf_2_runtime__prebuild__-Byvr2uOb.js → _virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__37453319418803__prebuild__react_mf_1_jsx_mf_2_runtime__prebuild__-CXpyx8Vy.js} +1 -1
  69. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__37453319418803__prebuild__react_mf_2_dom_mf_1_client__prebuild__-DuFBE5fh.js +9 -0
  70. package/admin/custom/assets/{hostInit-IJMNq3h7.js → hostInit-6oh4UY2k.js} +1 -1
  71. package/admin/custom/assets/iconLibraryData-B5fiyl1C.js +1 -0
  72. package/admin/custom/assets/index-BrlyEy6J.js +1 -0
  73. package/admin/custom/assets/lib-BmDlTzq2.js +3 -0
  74. package/admin/custom/assets/{mf-entry-bootstrap-0-f149bc46.js → mf-entry-bootstrap-0-ad1cd7d0.js} +3 -3
  75. package/admin/custom/assets/pendingShares-kV2kwejX.js +1 -0
  76. package/admin/custom/assets/rolldown-runtime-Dqfqb5bO.js +1 -0
  77. package/admin/custom/customComponents.js +3 -2
  78. package/admin/custom/i18n/en.json +39 -39
  79. package/admin/custom/i18n/es.json +1 -1
  80. package/admin/custom/i18n/fr.json +2 -2
  81. package/admin/custom/i18n/it.json +1 -1
  82. package/admin/custom/i18n/nl.json +2 -2
  83. package/admin/custom/i18n/pt.json +2 -2
  84. package/admin/custom/i18n/ru.json +2 -2
  85. package/admin/custom/i18n/uk.json +1 -1
  86. package/admin/custom/i18n/zh-cn.json +1 -1
  87. package/admin/i18n/de.json +1 -1
  88. package/admin/i18n/en.json +115 -115
  89. package/admin/i18n/fr.json +115 -115
  90. package/admin/i18n/it.json +115 -115
  91. package/admin/i18n/nl.json +115 -115
  92. package/admin/i18n/pl.json +1 -1
  93. package/admin/i18n/pt.json +115 -115
  94. package/admin/i18n/ru.json +115 -115
  95. package/admin/i18n/uk.json +115 -115
  96. package/admin/i18n/zh-cn.json +115 -115
  97. package/admin/mf-manifest.json +1 -1
  98. package/admin/mf-stats.json +1 -1
  99. package/admin/remoteEntry.js +2 -2
  100. package/admin/tab.html +3 -7
  101. package/build/lib/fb/analyze.js +288 -0
  102. package/build/lib/fb/analyze.js.map +1 -0
  103. package/build/lib/fb/blocks.js +605 -0
  104. package/build/lib/fb/blocks.js.map +1 -0
  105. package/build/lib/fb/generate.js +326 -0
  106. package/build/lib/fb/generate.js.map +1 -0
  107. package/build/lib/fb/graph.js +240 -0
  108. package/build/lib/fb/graph.js.map +1 -0
  109. package/build/lib/fb/index.js +57 -0
  110. package/build/lib/fb/index.js.map +1 -0
  111. package/build/lib/fb/js.js +33 -0
  112. package/build/lib/fb/js.js.map +1 -0
  113. package/build/lib/fb/layout.js +205 -0
  114. package/build/lib/fb/layout.js.map +1 -0
  115. package/build/lib/fb/library.js +657 -0
  116. package/build/lib/fb/library.js.map +1 -0
  117. package/build/lib/fb/runtime.js +793 -0
  118. package/build/lib/fb/runtime.js.map +1 -0
  119. package/build/lib/fb/time.js +76 -0
  120. package/build/lib/fb/time.js.map +1 -0
  121. package/build/lib/fb/types.js +19 -0
  122. package/build/lib/fb/types.js.map +1 -0
  123. package/build/lib/fb/user.js +78 -0
  124. package/build/lib/fb/user.js.map +1 -0
  125. package/build/lib/javascript.d.ts +17 -17
  126. package/build/lib/mirror.js +4 -0
  127. package/build/lib/mirror.js.map +1 -1
  128. package/build/lib/sandbox.js +44 -0
  129. package/build/lib/sandbox.js.map +1 -1
  130. package/build/main.js +66 -1
  131. package/build/main.js.map +1 -1
  132. package/build/types.d.ts +9 -1
  133. package/docs/de/README.md +1 -1
  134. package/docs/de/fbd.md +274 -0
  135. package/docs/de/javascript.md +2167 -0
  136. package/docs/en/fbd.md +260 -0
  137. package/docs/en/javascript.md +28 -30
  138. package/io-package.json +52 -28
  139. package/package.json +8 -8
  140. package/admin/assets/AiChatPanel-AZko1BsN.js +0 -27
  141. package/admin/assets/AiDiffView-Cri2QFh1.js +0 -1
  142. package/admin/assets/Debugger-CVDh3kgz.js +0 -15
  143. package/admin/assets/Error-Ch2nx5uC.js +0 -1
  144. package/admin/assets/Import-XKVP-nRT.js +0 -1
  145. package/admin/assets/RulesEditor-DsO4cKIk.js +0 -1
  146. package/admin/assets/ScriptEditorVanillaMonaco-BDAw2Bw6.js +0 -3
  147. package/admin/assets/_virtual_mf-localSharedImportMap___mfe_internal__iobroker_javascript__mf_owner__1-BMAFQFoH.js +0 -1
  148. package/admin/assets/_virtual_mf___mfe_internal__iobroker_javascript__mf_owner__113183188387379__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-D-gi6Mty.js +0 -1217
  149. package/admin/assets/_virtual_mf___mfe_internal__iobroker_javascript__mf_owner__113183188387379__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-CDctpiPx.js +0 -9
  150. package/admin/assets/aiPromptBuilder-aJfHa-eU.js +0 -1
  151. package/admin/assets/blocks_action-DS28sNfo.js +0 -1
  152. package/admin/assets/blocks_logic-Dpp2fwlu.js +0 -1
  153. package/admin/assets/blocks_number-N4IfHvYD.js +0 -1
  154. package/admin/assets/blocks_object-uK7FHVhS.js +0 -1
  155. package/admin/assets/blocks_procedures-C_KD0Bm6.js +0 -3
  156. package/admin/assets/blocks_switch-C8Rls5pK.js +0 -2
  157. package/admin/assets/blocks_system-CEQnj5fY.js +0 -1
  158. package/admin/assets/blocks_text-BDEWxu0P.js +0 -1
  159. package/admin/assets/blocks_time-aHQQK1Uz.js +0 -1
  160. package/admin/assets/blocks_timeout-C2L93TLJ.js +0 -1
  161. package/admin/assets/helpers-DiwtLpXM.js +0 -1
  162. package/admin/assets/index-B0FfAYMN.js +0 -871
  163. package/admin/assets/index-CXaeqPRy.css +0 -1
  164. package/admin/assets/stateHoverProvider-BkW15VMN.js +0 -9
  165. package/admin/assets/virtualExposes-DgGB-18P.js +0 -1
  166. package/admin/assets/virtual_mf-REMOTE_ENTRY_ID___mfe_internal__iobroker_javascript__remoteEntry_js-CiidVc0O.js +0 -1
  167. package/admin/assets/virtual_mf-exposes___mfe_internal__iobroker_javascript__remoteEntry_js-ChiJXsfH.js +0 -1
  168. package/admin/custom/assets/Components-SGnA-3W_.js +0 -1
  169. package/admin/custom/assets/_virtual_mf-localSharedImportMap___mfe_internal__ConfigCustomJavascriptSet__mf_owner__1-Bx3X6TLB.js +0 -1
  170. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__136440932828998__loadShare___mf_0_emotion_mf_1_react__loadShare__.js-Cc7MmJgr.js +0 -1
  171. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__136440932828998__loadShare___mf_0_emotion_mf_1_styled__loadShare__.js-CdvEvX5z.js +0 -1
  172. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__136440932828998__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-D5NaoeJi.js +0 -1217
  173. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__136440932828998__loadShare___mf_0_iobroker_mf_1_json_mf_2_config__loadShare__.js-Cbgw_a3f.js +0 -1
  174. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__136440932828998__loadShare___mf_0_mui_mf_1_x_mf_2_date_mf_2_pickers__loadShare__.js-CMr75K5w.js +0 -1
  175. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__136440932828998__loadShare__date_mf_2_fns__loadShare__.js-DKIvPDPX.js +0 -1
  176. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__136440932828998__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-D50aYKgD.js +0 -1
  177. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__136440932828998__prebuild___mf_0_iobroker_mf_1_json_mf_2_config__prebuild__-CEzQFX7o.js +0 -122
  178. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__136440932828998__prebuild__leaflet__prebuild__-BUDmnAcx.js +0 -1
  179. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__136440932828998__prebuild__react_mf_2_dom_mf_1_client__prebuild__-D_1oh1WH.js +0 -9
  180. package/admin/custom/assets/index-7r4VklMp.js +0 -1
  181. package/admin/custom/assets/lib-DDU2Oe48.js +0 -3
  182. package/admin/custom/assets/pendingShares-DarGQhyO.js +0 -1
  183. package/admin/custom/assets/rolldown-runtime-BcKkbAw3.js +0 -1
  184. package/admin/custom/assets/virtualExposes-C0IqMANQ.js +0 -1
  185. package/admin/custom/assets/virtual_mf-REMOTE_ENTRY_ID___mfe_internal__ConfigCustomJavascriptSet__customComponents_js-CqKvh5Xu.js +0 -1
  186. package/admin/custom/assets/virtual_mf-exposes___mfe_internal__ConfigCustomJavascriptSet__customComponents_js-DrBN_S5o.js +0 -2
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../../src/lib/fb/runtime.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAi5BA,0BAgBC;AAaD,8BAMC;AAp7BD;;;;;;;;;GASG;AACH,iDAAmC;AACnC,qCAA2F;AAC3F,mCAAoG;AAEpG,gFAAgF;AAChF,2CAAyB;AAEZ,QAAA,OAAO,GAAG,0BAAkB,CAAC;AAE1C,sEAAsE;AACtE,MAAM,UAAU,GAAG,EAAE,CAAC;AAEtB,2FAA2F;AAC3F,MAAM,cAAc,GAAG,EAAE,CAAC;AAoH1B,4DAA4D;AAC5D,MAAM,UAAU,GAAG,GAAG,CAAC;AACvB,yDAAyD;AACzD,MAAM,YAAY,GAAG,IAAI,CAAC;AAO1B,oFAAoF;AACpF,SAAS,WAAW,CAAC,KAAyB;IAC1C,MAAM,MAAM,GAAY,EAAE,CAAC;IAC3B,KAAK,MAAM,IAAI,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QAC3C,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC;QAClE,IAAI,KAAK,EAAE,CAAC;YACR,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAChF,CAAC;IACL,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC;AAED;;;GAGG;AACH,SAAS,UAAU,CAAC,KAAY;IAC5B,OAAO,uBAAuB,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AACpD,CAAC;AAED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,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACtE,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAAG,eAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC5D,IAAI,KAAK,KAAK,QAAQ,EAAE,CAAC;QACrB,OAAO,CAAC,GAAG,CACP,4CAA4C,eAAe,SAAS,eAAO,sDAAsD,EACjI,MAAM,CACT,CAAC;IACN,CAAC;SAAM,IAAI,KAAK,GAAG,QAAQ,EAAE,CAAC;QAC1B,6CAA6C;QAC7C,OAAO,CAAC,GAAG,CACP,4CAA4C,eAAe,cAAc,eAAO,oCAAoC,EACpH,MAAM,CACT,CAAC;IACN,CAAC;IACD,OAAO,IAAI,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AACzC,CAAC;AAQD;;;;GAIG;AACH,SAAgB,SAAS,CAAC,KAAmB;IACzC,OAAO;QACH,GAAG,MAAM;QACT,OAAO,EAAP,eAAO;QACP,OAAO,EAAE,CAAC,OAAO,EAAE,eAAe,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,eAAe,EAAE,KAAK,CAAC;KAClF,CAAC;AACN,CAAC","sourcesContent":["/**\n * fb-runtime: what the code generated from a function block diagram calls.\n *\n * The scripts get it with `require('@iobroker/fb-runtime')`. The blocks live here and not as copies\n * in the generated code, so a fix reaches every diagram without generating it again.\n *\n * The module holds no state of its own - every diagram creates its instances and its runtime - and\n * it touches nothing outside: states, subscriptions and timers go through the functions of the\n * sandbox, which removes all of them when the script stops.\n */\nimport * as blocks from './blocks';\nimport { timeOfDay, toBool, toNum, type MessageBlock, type ScheduleBlock } from './blocks';\nimport { FB_RUNTIME_VERSION, type FbDebugCommand, type FbDebugStatus, type FbValue } from './types';\n\n// the blocks and the conversions are part of the module the generated code gets\nexport * from './blocks';\n\nexport const version = FB_RUNTIME_VERSION;\n\n/** Changes of inputs that arrive within this time run in one cycle */\nconst COLLECT_MS = 20;\n\n/** A cycle that took longer than the interval this many times in a row is reported once */\nconst OVERRUN_CYCLES = 10;\n\n// ---- the connection to the sandbox\n\ntype Timer = ReturnType<typeof setTimeout>;\n\n/** The functions of the script sandbox the runtime works with */\nexport interface FbSandbox {\n getStateAsync: (id: string) => Promise<ioBroker.State | null | undefined>;\n setState: (id: string, value: ioBroker.StateValue, ack: boolean) => void;\n on: (pattern: { id: string; change: 'ne' }, callback: (event: { state?: { val?: unknown } }) => void) => unknown;\n setInterval: (callback: () => void, ms: number) => Timer | null;\n clearInterval: (timer: Timer) => void;\n setTimeout: (callback: () => void, ms: number) => Timer | null;\n clearTimeout: (timer: Timer) => void;\n log: (message: string, severity?: 'info' | 'warn' | 'error' | 'debug') => void;\n onStop: (callback: () => void) => void;\n // for the calendar and the messages, since runtime 1.5\n schedule?: (pattern: string, callback: () => void) => unknown;\n getAstroDate?: (pattern: string, date?: Date | number) => Date | undefined;\n sendTo?: (instance: string, command: string, message: unknown) => void;\n registerNotification?: (message: string, isAlert?: boolean) => void;\n}\n\nexport interface FbRuntimeError {\n message: string;\n /** The block whose line of code failed, if it could be found */\n blockId?: string;\n}\n\n/**\n * What the online view of the editor gets. A snapshot comes at most every 250 ms, with the signals\n * that changed since the one before - and at least every 2 s, so the editor can tell a diagram that\n * stopped (the cycle count stands still) from one that only has nothing new.\n */\nexport interface FbSnapshot {\n ts: number;\n /** Cycles run since the start */\n cycle: number;\n mode: 'cyclic' | 'event';\n /** The signals that changed, or all of them with `full` */\n values?: Record<string, unknown>;\n /** Everything, for a viewer that just came */\n full?: boolean;\n /** The error of the last cycle, `null` once a cycle ran through again. Only when it changed, or with `full` */\n error?: FbRuntimeError | null;\n /** Forced values, breakpoints, paused or not. Only when it changed, or with `full` */\n debug?: FbDebugStatus;\n}\n\n/** What the online view set, kept while the script starts again - after it was saved, for example */\nexport interface FbDebugSettings {\n breakpoints: string[];\n forced: Record<string, FbValue>;\n}\n\n/** How the script tells the runtime whether somebody watches, and where the snapshots go - see `forScript()` */\nexport interface FbDebugHooks {\n /** 0 while nobody watches. Another number means another viewer, who needs everything once */\n watched: () => number;\n /**\n * The instances of user blocks whose inside an editor shows, as paths of instance IDs like\n * `b3/b7` - their signals come as well, as `b3/b7/<block>.<pin>`\n */\n paths?: () => string[];\n publish: (snapshot: FbSnapshot) => void;\n /** Hands the runtime the commands of the online view; returns the function that ends it */\n listen?: (handler: (command: FbDebugCommand) => FbDebugStatus) => () => void;\n /** Keeps the settings for the next start of the script; `null` forgets them */\n keep?: (settings: FbDebugSettings | null) => void;\n /** The settings kept from the last start */\n restore?: () => FbDebugSettings | null | undefined;\n}\n\nexport interface FbStartOptions {\n /** `cyclic`: every `ms`, and right after an input changed; `event`: only when an input changed */\n mode: 'cyclic' | 'event';\n ms: number;\n /** The states read by STATE_IN */\n inputs: string[];\n /** The states written by STATE_OUT */\n outputs: string[];\n /**\n * Where the code is, to find the block of an error: the line of the `rt.start()` call and the\n * line of the first block in `cycle()`, both counted in the generated source\n */\n lines?: { start: number; body: number };\n /** The blocks in the order of the lines of `cycle()`, one line each */\n blocks?: string[];\n}\n\n/**\n * One cycle of the generated code. Since runtime 1.2 it starts at block `at` and stops in front of a\n * block whose entry in the breakpoints (`B`) is set - it returns that block, or -1 at the end. `go`\n * is the block it goes on with after it stopped there, whose breakpoint must not stop it again. The\n * code of older versions runs the whole cycle and returns nothing.\n */\ntype CycleFunction = (dt: number, firstScan: boolean, at?: number, go?: number) => number | void;\n\n/** Where the cycles wait. `inCycle`: in the middle of a cycle, whose blocks before `at` ran already */\ninterface Halt {\n at: number;\n inCycle: boolean;\n dt: number;\n firstScan: boolean;\n}\n\ntype SignalType = 'BOOL' | 'INT' | 'REAL' | 'STRING';\n\ninterface Output {\n value: unknown;\n ts: number;\n pending?: { value: unknown; ack: boolean };\n timer?: Timer | null;\n}\n\n/** Snapshots for the online view come at most this often */\nconst PUBLISH_MS = 250;\n/** ... and at least this often, even without a change */\nconst HEARTBEAT_MS = 2000;\n\ninterface Frame {\n file: string;\n line: number;\n}\n\n/** The frames of a V8 stack: `at fn (file:line:column)` or `at file:line:column` */\nfunction parseFrames(stack: string | undefined): Frame[] {\n const frames: Frame[] = [];\n for (const text of (stack || '').split('\\n')) {\n const match = text.match(/^\\s*at (?:.*? \\()?(.*?):(\\d+):\\d+\\)?$/);\n if (match) {\n frames.push({ file: match[1].replace(/\\\\/g, '/'), line: Number(match[2]) });\n }\n }\n return frames;\n}\n\n/**\n * A frame of this module. The adapter maps stacks through the source maps, so a frame of this file\n * may name `runtime.ts` as well as `runtime.js`.\n */\nfunction isOwnFrame(frame: Frame): boolean {\n return /\\/fb\\/runtime\\.[jt]s$/.test(frame.file);\n}\n\n/** An own property - the objects of the code come from another realm, and IDs must not find `constructor` */\nfunction hasOwn(object: object, key: string): boolean {\n return Object.prototype.hasOwnProperty.call(object, key);\n}\n\nexport class FbRuntime {\n private readonly values = new Map<string, unknown>();\n private readonly outputs = new Map<string, Output>();\n /** IDs whose value could not be converted - reported once each */\n private readonly badInputs = new Set<string>();\n private cycle: CycleFunction | null = null;\n private options: FbStartOptions | null = null;\n private signals: Record<string, unknown> | null = null;\n private collectTimer: Timer | null = null;\n private lastRun = 0;\n private cycles = 0;\n /** The first cycle ran - with `firstScan` */\n private scanned = false;\n private overruns = 0;\n private overrunReported = false;\n private lastError = '';\n private error: FbRuntimeError | null = null;\n private started = false;\n private stopped = false;\n\n /** Where the generated code runs: its file name in the stack, and how its lines are shifted there */\n private scriptFile = '';\n private lineOffset = 0;\n\n /** What the online view got last; `null` while nobody watches */\n private sent: Map<string, unknown> | null = null;\n private sentError = 'null';\n private sentDebug = '';\n private sentPaths = '';\n private viewer = 0;\n private lastPublish = 0;\n\n /** The breakpoints of the code (`B`), one entry per block in the order of `options.blocks` */\n private breaks: unknown[] | null = null;\n /** The instances of the diagram (`I`) - an instance of a user block has its inside in `$I` and `$S` */\n private instances: Record<string, unknown> | null = null;\n private readonly breakpoints = new Set<string>();\n /** Forced signals, and what their blocks computed meanwhile */\n private readonly forced = new Map<string, FbValue>();\n private readonly computed = new Map<string, unknown>();\n /** Set while the cycles wait for the online view */\n private halt: Halt | null = null;\n private unlisten: (() => void) | null = null;\n\n /** The SCHEDULE blocks whose time the sandbox watches */\n private readonly schedules = new Set<ScheduleBlock>();\n /** The times of the sun events of `astroDay`, by `<event>|<offset>` */\n private readonly astroTimes = new Map<string, number>();\n private astroDay = '';\n\n constructor(\n private readonly sandbox: FbSandbox,\n private readonly hooks?: FbDebugHooks,\n ) {\n // the sandbox removes timers and subscriptions itself; this only stops a start still reading\n sandbox.onStop(() => {\n this.stopped = true;\n this.unlisten?.();\n this.unlisten = null;\n });\n }\n\n /** The value of a state, converted to the type the STATE_IN block puts out */\n input(id: string, type: SignalType): boolean | number | string {\n const value = this.values.get(id);\n if (type === 'BOOL') {\n return toBool(value);\n }\n if (type === 'STRING') {\n if (value === null || value === undefined) {\n return '';\n }\n // numbers and booleans come out the same as with String(), objects as JSON\n return typeof value === 'string' ? value : JSON.stringify(value);\n }\n let number = toNum(value);\n if (Number.isNaN(number)) {\n if (value !== null && value !== undefined && !this.badInputs.has(id)) {\n this.badInputs.add(id);\n this.sandbox.log(\n `State \"${id}\" has the value ${JSON.stringify(value)}, which is no number - 0 is used`,\n 'warn',\n );\n }\n number = 0;\n }\n return type === 'INT' ? Math.round(number) : number;\n }\n\n /**\n * Writes a state, but only when the value changed. With `minInterval`, writes of one state are\n * at least that many ms apart; the last value is written when the time is over.\n */\n output(id: string, value: unknown, ack: boolean, minInterval: number): void {\n const output = this.outputs.get(id) || { value: undefined, ts: 0 };\n this.outputs.set(id, output);\n\n const target = output.pending ? output.pending.value : output.value;\n if (value === target) {\n return;\n }\n if (value === output.value) {\n // back to what was written last: nothing is left to write\n output.pending = undefined;\n if (output.timer) {\n this.sandbox.clearTimeout(output.timer);\n output.timer = null;\n }\n return;\n }\n\n const wait = minInterval > 0 ? output.ts + minInterval - Date.now() : 0;\n if (wait <= 0) {\n this.write(id, output, value, ack);\n return;\n }\n output.pending = { value, ack };\n output.timer ||= this.sandbox.setTimeout(() => {\n output.timer = null;\n if (output.pending) {\n this.write(id, output, output.pending.value, output.pending.ack);\n }\n }, wait);\n }\n\n /**\n * SCHEDULE: whether the time of the cron pattern came since the last cycle. The first call has the\n * sandbox watch the time. When it comes, a cycle runs at once - and one after it, which ends the\n * pulse, in the event mode as well.\n */\n cron(instance: ScheduleBlock, pattern: string): boolean {\n if (!this.schedules.has(instance)) {\n this.schedules.add(instance);\n // an invalid pattern the sandbox reports itself\n try {\n this.sandbox.schedule?.(pattern, () => {\n instance.pending++;\n this.collect();\n });\n } catch (error: unknown) {\n this.sandbox.log(`SCHEDULE: cannot use \"${pattern}\": ${error as Error}`, 'warn');\n }\n }\n instance.run();\n if (instance.Q) {\n this.collect();\n }\n return instance.Q;\n }\n\n /**\n * ASTRO: the time of day of a sun event today, moved by `offset` minutes. Reckoned once a day. A\n * time that cannot be reckoned - the adapter has no position, the sun does not set - gives 0; the\n * sandbox says why.\n */\n astro(event: string, offset: number): number {\n const now = new Date();\n const day = now.toDateString();\n if (day !== this.astroDay) {\n this.astroDay = day;\n this.astroTimes.clear();\n }\n const key = `${event}|${offset}`;\n let time = this.astroTimes.get(key);\n if (time === undefined) {\n const date = this.sandbox.getAstroDate?.(event, now.getTime());\n const ts = date ? date.getTime() : NaN;\n time = Number.isFinite(ts) ? timeOfDay(ts + (offset || 0) * 60000) : 0;\n this.astroTimes.set(key, time);\n }\n return time;\n }\n\n /** SENDTO: the text of the block to an adapter, in the fields the messengers read */\n send(instance: MessageBlock, target: string, command: string, title: string): void {\n if (instance.last) {\n this.sandbox.log(`SENDTO ${target}: ${instance.note()}`, 'warn');\n }\n const message: Record<string, string> = { text: instance.text, message: instance.text };\n if (title) {\n message.title = title;\n message.subject = title;\n }\n this.sandbox.sendTo?.(target, command || 'send', message);\n }\n\n /** NOTIFY: the text of the block as a notification of ioBroker; `alert` or `message` */\n notify(instance: MessageBlock, category: string): void {\n if (instance.last) {\n this.sandbox.log(`NOTIFY: ${instance.note()}`, 'warn');\n }\n this.sandbox.registerNotification?.(instance.text, category === 'alert');\n }\n\n private write(id: string, output: Output, value: unknown, ack: boolean): void {\n if (output.timer) {\n this.sandbox.clearTimeout(output.timer);\n output.timer = null;\n }\n output.value = value;\n output.ts = Date.now();\n output.pending = undefined;\n this.sandbox.setState(id, value as ioBroker.StateValue, ack);\n }\n\n /**\n * Reads the inputs, subscribes to them and runs the first cycle.\n *\n * @param cycle one run through all blocks\n * @param options how and when to run\n * @param signals the signals of the diagram (`S`), for the online view\n * @param breaks the breakpoints of the code (`B`), since runtime 1.2\n * @param instances the instances of the code (`I`), since runtime 1.3\n */\n start(\n cycle: CycleFunction,\n options: FbStartOptions,\n signals?: Record<string, unknown>,\n breaks?: unknown[],\n instances?: Record<string, unknown>,\n ): void {\n if (this.started) {\n throw new Error('The function block diagram is already running');\n }\n this.started = true;\n this.cycle = cycle;\n this.options = options;\n this.signals = signals || null;\n this.breaks = breaks && options.blocks ? breaks : null;\n this.instances = instances || null;\n\n // The first frame outside this file is the `rt.start()` call of the generated code. Its line\n // there, against its line in the source, gives the shift of all lines - whatever the adapter\n // put in front of the source.\n const caller = parseFrames(new Error().stack).find(frame => !isOwnFrame(frame));\n if (caller && options.lines) {\n this.scriptFile = caller.file;\n this.lineOffset = caller.line - options.lines.start;\n }\n\n if (this.hooks?.listen) {\n this.unlisten = this.hooks.listen(command => this.command(command));\n }\n // what an editor set before the script started again - only while it still watches\n const kept = this.hooks && this.hooks.watched() ? this.hooks.restore?.() : null;\n if (kept) {\n // a block or a signal that is gone since is left out\n for (const block of kept.breakpoints) {\n if (this.breaks && options.blocks!.includes(block)) {\n this.breakpoints.add(block);\n }\n }\n this.updateBreaks();\n for (const [signal, value] of Object.entries(kept.forced)) {\n const target = this.holderOf(signal);\n if (target && hasOwn(target.holder, target.key)) {\n this.force(signal, value);\n }\n }\n }\n\n void this.init();\n }\n\n private async init(): Promise<void> {\n const { inputs, outputs, mode, ms } = this.options!;\n await Promise.all([\n ...inputs.map(async id => this.values.set(id, (await this.read(id))?.val)),\n ...outputs.map(async id => this.outputs.set(id, { value: (await this.read(id))?.val, ts: 0 })),\n ]);\n if (this.stopped) {\n return;\n }\n\n for (const id of inputs) {\n this.sandbox.on({ id, change: 'ne' }, event => {\n this.values.set(id, event.state?.val);\n this.badInputs.delete(id);\n this.collect();\n });\n }\n\n this.lastRun = Date.now();\n this.run(true);\n if (mode === 'cyclic') {\n this.sandbox.setInterval(() => this.run(false), ms);\n }\n if (this.hooks) {\n this.sandbox.setInterval(() => this.publish(), PUBLISH_MS);\n }\n }\n\n private async read(id: string): Promise<ioBroker.State | null | undefined> {\n try {\n return await this.sandbox.getStateAsync(id);\n } catch (error: unknown) {\n this.sandbox.log(`Cannot read state \"${id}\": ${error as Error}`, 'warn');\n return null;\n }\n }\n\n /** Changes that come together run in one cycle */\n private collect(): void {\n this.collectTimer ||= this.sandbox.setTimeout(() => {\n this.collectTimer = null;\n this.run(false);\n }, COLLECT_MS);\n }\n\n /**\n * The block whose line threw - the lines of `cycle()` are one block each. An error inside a user\n * block comes from a line of its factory first; the frame that counts is the one in `cycle()`,\n * the line of the instance.\n */\n private blockOf(error: unknown): string | undefined {\n const { lines, blocks } = this.options || {};\n if (!this.scriptFile || !lines || !blocks) {\n return undefined;\n }\n for (const frame of parseFrames((error as Error)?.stack)) {\n const index = frame.line - this.lineOffset - lines.body;\n if (frame.file === this.scriptFile && index >= 0 && index < blocks.length) {\n return blocks[index];\n }\n }\n return undefined;\n }\n\n private run(firstScan: boolean): void {\n if (this.collectTimer) {\n this.sandbox.clearTimeout(this.collectTimer);\n this.collectTimer = null;\n }\n if (this.halt) {\n // the cycles wait for the online view; the inputs are read when they go on\n return;\n }\n const now = Date.now();\n const dt = firstScan ? 0 : now - this.lastRun;\n this.lastRun = now;\n this.cycles++;\n this.scanned = true;\n\n const stop = this.execute(dt, firstScan, 0, -1);\n if (stop >= 0) {\n this.stopAt(stop, dt, firstScan);\n return;\n }\n\n const { mode, ms } = this.options!;\n if (mode === 'cyclic') {\n if (Date.now() - now > ms) {\n this.overruns++;\n if (this.overruns >= OVERRUN_CYCLES && !this.overrunReported) {\n this.overrunReported = true;\n this.sandbox.log(\n `A cycle takes longer than the cycle time of ${ms} ms - consider a longer cycle time`,\n 'warn',\n );\n }\n } else {\n this.overruns = 0;\n }\n }\n }\n\n /**\n * Runs the blocks from `at` on, see `CycleFunction`. Returns the block it stopped in front of, or\n * -1 when the cycle is over - also when a block failed, which ends the cycle.\n */\n private execute(dt: number, firstScan: boolean, at: number, go: number): number {\n try {\n const stop = this.cycle!(dt, firstScan, at, go);\n this.lastError = '';\n this.error = null;\n return typeof stop === 'number' ? stop : -1;\n } catch (error: unknown) {\n // An error from the script comes from another realm, so `instanceof Error` does not work\n const message = (error as Error)?.message ?? String(error);\n const blockId = this.blockOf(error);\n this.error = blockId ? { message, blockId } : { message };\n // A broken cycle would log at every run - once per error is enough. Not compared by the\n // stack: the first cycle is called from elsewhere than the ones after it.\n const key = `${blockId}|${message}`;\n if (key !== this.lastError) {\n this.lastError = key;\n this.sandbox.log(\n `Error in the function block diagram${blockId ? ` in block ${blockId}` : ''}: ${(error as Error)?.stack || String(error)}`,\n 'error',\n );\n }\n return -1;\n }\n }\n\n // ---- the online view: forced values, breakpoints, single steps\n\n /** The cycles wait in front of block `stop` of the cycle that has `dt` and `firstScan` */\n private stopAt(stop: number, dt: number, firstScan: boolean): void {\n this.halt = { at: stop, inCycle: true, dt, firstScan };\n this.publish();\n }\n\n /** A cycle started by hand: the time goes on by one cycle time - the time waited does not count */\n private begin(): { dt: number; firstScan: boolean } {\n const firstScan = !this.scanned;\n this.scanned = true;\n this.cycles++;\n this.lastRun = Date.now();\n return { dt: firstScan ? 0 : this.options!.ms, firstScan };\n }\n\n /** `all`: every block stops, for a single step */\n private updateBreaks(all = false): void {\n this.options?.blocks?.forEach((id, i) => {\n if (this.breaks) {\n this.breaks[i] = all || this.breakpoints.has(id) ? 1 : 0;\n }\n });\n }\n\n /** The signals inside an instance of a user block, by the path of the instance IDs: `b3/b7` */\n private instanceAt(path: string): Record<string, unknown> | null {\n let instances = this.instances;\n let signals: Record<string, unknown> | null = null;\n for (const id of path.split('/')) {\n const instance =\n instances && hasOwn(instances, id)\n ? (instances[id] as { $S?: Record<string, unknown>; $I?: Record<string, unknown> } | undefined)\n : undefined;\n if (!instance?.$S) {\n return null;\n }\n signals = instance.$S;\n instances = instance.$I || null;\n }\n return signals;\n }\n\n /** Where a signal lives: `S` of the diagram, or of the instance its path leads to */\n private holderOf(signal: string): { holder: Record<string, unknown>; key: string } | null {\n const slash = signal.lastIndexOf('/');\n if (slash === -1) {\n return this.signals ? { holder: this.signals, key: signal } : null;\n }\n const holder = this.instanceAt(signal.substring(0, slash));\n return holder ? { holder, key: signal.substring(slash + 1) } : null;\n }\n\n private status(): FbDebugStatus {\n const status: FbDebugStatus = {\n breaks: !!this.breaks,\n inside: !!this.instances,\n paused: !!this.halt,\n breakpoints: [...this.breakpoints],\n forced: Object.fromEntries(this.forced),\n };\n const at = this.halt && this.options?.blocks?.[this.halt.at];\n if (at) {\n status.at = at;\n }\n return status;\n }\n\n /** A command of the online view; throws when it cannot be done */\n command(command: FbDebugCommand): FbDebugStatus {\n switch (command?.command) {\n case 'force':\n this.force(command.signal, command.value);\n break;\n case 'release':\n this.release(command.signal);\n break;\n case 'breakpoint':\n this.setBreakpoint(command.block, command.on);\n break;\n case 'pause':\n this.halt ||= { at: 0, inCycle: false, dt: 0, firstScan: false };\n break;\n case 'resume':\n this.resume();\n break;\n case 'step':\n this.step();\n break;\n case 'cycle':\n this.runCycle();\n break;\n default:\n throw new Error(`Unknown command ${JSON.stringify((command as { command?: unknown })?.command)}`);\n }\n this.hooks?.keep?.(\n this.forced.size || this.breakpoints.size\n ? { breakpoints: [...this.breakpoints], forced: Object.fromEntries(this.forced) }\n : null,\n );\n this.publish();\n return this.status();\n }\n\n /**\n * Holds a signal at a value. Its block still computes, but what it writes is kept aside - the\n * signal becomes a property with a getter, so the code needs nothing for it.\n */\n private force(signal: string, value: FbValue): void {\n if (!this.signals) {\n throw new Error('The diagram was saved before values could be forced - save it once');\n }\n const target = this.holderOf(signal);\n if (!target || !hasOwn(target.holder, target.key)) {\n throw new Error(`Unknown signal ${signal}`);\n }\n const { holder, key } = target;\n // the value gets the type the signal has\n const current = this.forced.has(signal) ? this.computed.get(signal) : holder[key];\n let typed: FbValue;\n if (typeof current === 'boolean') {\n typed = toBool(value);\n } else if (typeof current === 'number') {\n typed = toNum(value);\n if (Number.isNaN(typed)) {\n throw new Error(`${JSON.stringify(value)} is no number`);\n }\n } else {\n typed = value === null || value === undefined ? '' : String(value);\n }\n\n if (!this.forced.has(signal)) {\n this.computed.set(signal, holder[key]);\n Object.defineProperty(holder, key, {\n configurable: true,\n enumerable: true,\n get: () => this.forced.get(signal),\n set: (computed: unknown) => this.computed.set(signal, computed),\n });\n }\n this.forced.set(signal, typed);\n // the blocks behind it see the value in the next cycle - it comes at once\n if (this.scanned) {\n this.collect();\n }\n }\n\n private release(signal?: string): void {\n const keys = signal === undefined ? [...this.forced.keys()] : [signal];\n let released = false;\n for (const key of keys) {\n const target = this.holderOf(key);\n if (target && this.forced.has(key)) {\n this.forced.delete(key);\n Object.defineProperty(target.holder, target.key, {\n configurable: true,\n enumerable: true,\n writable: true,\n value: this.computed.get(key),\n });\n this.computed.delete(key);\n released = true;\n }\n }\n if (released && this.scanned) {\n this.collect();\n }\n }\n\n private setBreakpoint(block: string | undefined, on: boolean): void {\n if (!this.breaks) {\n throw new Error('The diagram was saved before it could stop at blocks - save it once');\n }\n if (block === undefined) {\n if (!on) {\n this.breakpoints.clear();\n }\n } else if (!this.options!.blocks!.includes(block)) {\n throw new Error(`Unknown block ${block}`);\n } else if (on) {\n this.breakpoints.add(block);\n } else {\n this.breakpoints.delete(block);\n }\n this.updateBreaks();\n }\n\n /** Runs on: the rest of the cycle, then as usual - up to the next breakpoint */\n private resume(): void {\n const halt = this.halt;\n if (!halt) {\n return;\n }\n this.halt = null;\n if (halt.inCycle) {\n const stop = this.execute(halt.dt, halt.firstScan, halt.at, halt.at);\n if (stop >= 0) {\n this.stopAt(stop, halt.dt, halt.firstScan);\n return;\n }\n }\n // the time waited does not count, and what came meanwhile is taken at once\n this.lastRun = Date.now();\n if (this.scanned) {\n this.run(false);\n }\n }\n\n /** Runs one block. Not paused yet: stops in front of the next cycle */\n private step(): void {\n if (!this.breaks) {\n throw new Error('The diagram was saved before it could stop at blocks - save it once');\n }\n const halt = this.halt;\n if (!halt) {\n this.halt = { at: 0, inCycle: false, dt: 0, firstScan: false };\n return;\n }\n const { dt, firstScan } = halt.inCycle ? halt : this.begin();\n const at = halt.inCycle ? halt.at : 0;\n this.updateBreaks(true);\n const stop = this.execute(dt, firstScan, at, at);\n this.updateBreaks();\n if (stop >= 0) {\n this.stopAt(stop, dt, firstScan);\n } else {\n this.halt = { at: 0, inCycle: false, dt: 0, firstScan: false };\n }\n }\n\n /** Runs the rest of the cycle, or one whole cycle - up to a breakpoint. Not paused yet: pauses */\n private runCycle(): void {\n const halt = this.halt;\n if (!halt) {\n this.halt = { at: 0, inCycle: false, dt: 0, firstScan: false };\n return;\n }\n const { dt, firstScan } = halt.inCycle ? halt : this.begin();\n const at = halt.inCycle ? halt.at : 0;\n const stop = this.execute(dt, firstScan, at, halt.inCycle ? at : -1);\n if (stop >= 0) {\n this.stopAt(stop, dt, firstScan);\n } else {\n this.halt = { at: 0, inCycle: false, dt: 0, firstScan: false };\n }\n }\n\n /** Nobody watches any more: nothing stays forced, nothing waits */\n private endDebugging(): void {\n if (!this.forced.size && !this.breakpoints.size && !this.halt) {\n return;\n }\n this.release();\n this.breakpoints.clear();\n this.updateBreaks();\n this.hooks?.keep?.(null);\n this.sandbox.log(\n 'The online view of the diagram ended: forced values are released, breakpoints removed, the diagram runs on',\n 'info',\n );\n this.resume();\n }\n\n /** Sends the online view what changed - only while an editor watches */\n private publish(): void {\n if (!this.hooks || !this.options) {\n return;\n }\n const viewer = this.hooks.watched();\n if (!viewer) {\n this.sent = null;\n this.endDebugging();\n return;\n }\n\n const now = Date.now();\n const full = !this.sent || viewer !== this.viewer;\n if (full) {\n this.sent = new Map();\n this.viewer = viewer;\n }\n const sent = this.sent!;\n\n // The inside of the instances an editor shows comes as well. What was sent of an instance\n // nobody looks into any more is forgotten, so it comes again in full when somebody does.\n const paths = this.instances ? this.hooks.paths?.() || [] : [];\n const pathsKey = [...paths].sort().join('|');\n if (pathsKey !== this.sentPaths) {\n for (const key of [...sent.keys()]) {\n const slash = key.lastIndexOf('/');\n if (slash !== -1 && !paths.includes(key.substring(0, slash))) {\n sent.delete(key);\n }\n }\n this.sentPaths = pathsKey;\n }\n const groups: [string, Record<string, unknown> | null][] = [\n ['', this.signals],\n ...paths.map((path): [string, Record<string, unknown> | null] => [`${path}/`, this.instanceAt(path)]),\n ];\n\n const values: Record<string, unknown> = {};\n let changed = false;\n for (const [prefix, signals] of groups) {\n for (const [signal, value] of Object.entries(signals || {})) {\n const key = `${prefix}${signal}`;\n if (full || !sent.has(key) || !Object.is(sent.get(key), value)) {\n values[key] = value;\n sent.set(key, value);\n changed = true;\n }\n }\n }\n const error = JSON.stringify(this.error);\n const errorChanged = full || error !== this.sentError;\n const status = this.status();\n const debug = JSON.stringify(status);\n const debugChanged = full || debug !== this.sentDebug;\n\n if (!changed && !errorChanged && !debugChanged && now - this.lastPublish < HEARTBEAT_MS) {\n return;\n }\n const snapshot: FbSnapshot = { ts: now, cycle: this.cycles, mode: this.options.mode };\n if (changed || full) {\n snapshot.values = values;\n }\n if (full) {\n snapshot.full = true;\n }\n if (errorChanged) {\n snapshot.error = this.error;\n this.sentError = error;\n }\n if (debugChanged) {\n snapshot.debug = status;\n this.sentDebug = debug;\n }\n this.lastPublish = now;\n this.hooks.publish(snapshot);\n }\n}\n\n/** The runtime of one diagram */\nexport function runtime(sandbox: FbSandbox, requiredVersion: string, hooks?: FbDebugHooks): FbRuntime {\n const [major, minor] = String(requiredVersion).split('.').map(Number);\n const [ownMajor, ownMinor] = version.split('.').map(Number);\n if (major !== ownMajor) {\n sandbox.log(\n `The diagram was generated for fb-runtime ${requiredVersion}, but ${version} is installed - open and save it in the editor again`,\n 'warn',\n );\n } else if (minor > ownMinor) {\n // blocks of a newer library are missing here\n sandbox.log(\n `The diagram was generated for fb-runtime ${requiredVersion}, but only ${version} is installed - update the adapter`,\n 'warn',\n );\n }\n return new FbRuntime(sandbox, hooks);\n}\n\n/** What `require('@iobroker/fb-runtime')` gives a script: the blocks, the conversions and the runtime */\nexport type FbModule = typeof blocks & {\n version: string;\n runtime: (sandbox: FbSandbox, requiredVersion: string) => FbRuntime;\n};\n\n/**\n * The module as one script gets it: its runtimes report to the online view of the editor through\n * `hooks`, and take its commands from there. The generated code does not have to know about the\n * online view - so the diagrams saved before it existed have most of it too.\n */\nexport function forScript(hooks: FbDebugHooks): FbModule {\n return {\n ...blocks,\n version,\n runtime: (sandbox, requiredVersion) => runtime(sandbox, requiredVersion, hooks),\n };\n}\n"]}
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DAY_MS = void 0;
4
+ exports.parseTime = parseTime;
5
+ exports.formatTime = formatTime;
6
+ exports.formatClock = formatClock;
7
+ const TIME_UNITS = { ms: 1, s: 1000, m: 60000, h: 3600000, d: 86400000 };
8
+ /** ms of a day */
9
+ exports.DAY_MS = TIME_UNITS.d;
10
+ /**
11
+ * A time in ms. Takes a number of ms, a text like `2s`, `1m30s`, `500ms` or `T#2s` (IEC), or a time
12
+ * of day like `08:30` or `TOD#22:15:30` - as the time since midnight. Returns `null` if the text is
13
+ * not a time.
14
+ */
15
+ function parseTime(value) {
16
+ if (typeof value === 'number') {
17
+ return Number.isFinite(value) && value >= 0 ? Math.round(value) : null;
18
+ }
19
+ if (typeof value !== 'string') {
20
+ return null;
21
+ }
22
+ let text = value.trim().toLowerCase().replace(/_/g, '');
23
+ if (/^(t|time|tod|timeofday)#/.test(text)) {
24
+ text = text.substring(text.indexOf('#') + 1);
25
+ }
26
+ if (!text) {
27
+ return null;
28
+ }
29
+ const clock = text.match(/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/);
30
+ if (clock) {
31
+ const [hours, minutes, seconds] = [clock[1], clock[2], clock[3] || '0'].map(Number);
32
+ return minutes < 60 && seconds < 60 ? ((hours * 60 + minutes) * 60 + seconds) * 1000 : null;
33
+ }
34
+ if (/^\d+(\.\d+)?$/.test(text)) {
35
+ return Math.round(Number(text));
36
+ }
37
+ const parts = text.match(/(\d+(?:\.\d+)?)(ms|s|m|h|d)/g);
38
+ if (!parts || parts.join('') !== text) {
39
+ return null;
40
+ }
41
+ return Math.round(parts.reduce((sum, part) => {
42
+ const [, number, unit] = part.match(/(\d+(?:\.\d+)?)(ms|s|m|h|d)/);
43
+ return sum + Number(number) * TIME_UNITS[unit];
44
+ }, 0));
45
+ }
46
+ /** A time for people: `1500` gives `1.5s`, `5400000` gives `1h30m` */
47
+ function formatTime(ms) {
48
+ if (!ms) {
49
+ return '0ms';
50
+ }
51
+ if (ms < TIME_UNITS.m) {
52
+ return ms >= 1000 ? `${Math.round(ms / 100) / 10}s` : `${Math.round(ms)}ms`;
53
+ }
54
+ // from a minute on in parts: 1h30m, 2d4h, 1m30.5s
55
+ let rest = Math.round(ms);
56
+ const parts = [];
57
+ for (const unit of ['d', 'h', 'm']) {
58
+ const count = Math.floor(rest / TIME_UNITS[unit]);
59
+ if (count) {
60
+ parts.push(`${count}${unit}`);
61
+ rest -= count * TIME_UNITS[unit];
62
+ }
63
+ }
64
+ if (rest) {
65
+ parts.push(rest % 1000 ? `${Math.round(rest / 100) / 10}s` : `${rest / 1000}s`);
66
+ }
67
+ return parts.join('');
68
+ }
69
+ /** A time of day for people: `30600000` gives `08:30`, with seconds only when there are some */
70
+ function formatClock(ms) {
71
+ const total = Math.round((((ms % exports.DAY_MS) + exports.DAY_MS) % exports.DAY_MS) / 1000);
72
+ const pad = (n) => String(n).padStart(2, '0');
73
+ const text = `${pad(Math.floor(total / 3600))}:${pad(Math.floor(total / 60) % 60)}`;
74
+ return total % 60 ? `${text}:${pad(total % 60)}` : text;
75
+ }
76
+ //# sourceMappingURL=time.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"time.js","sourceRoot":"","sources":["../../../src/lib/fb/time.ts"],"names":[],"mappings":";;;AAiBA,8BAgCC;AAGD,gCAqBC;AAGD,kCAKC;AA1ED,MAAM,UAAU,GAA2B,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC;AAEjG,kBAAkB;AACL,QAAA,MAAM,GAAG,UAAU,CAAC,CAAC,CAAC;AAEnC;;;;GAIG;AACH,SAAgB,SAAS,CAAC,KAAiC;IACvD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC5B,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC3E,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC5B,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,IAAI,IAAI,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACxD,IAAI,0BAA0B,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACxC,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IACjD,CAAC;IACD,IAAI,CAAC,IAAI,EAAE,CAAC;QACR,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,MAA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AG,cAAM,CAAC,GAAG,cAAM,CAAC,GAAG,IAAI,CAAC,CAAC;IACrE,MAAM,GAAG,GAAG,CAAC,CAAS,EAAU,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC9D,MAAM,IAAI,GAAG,GAAG,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC;IACpF,OAAO,KAAK,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,GAAG,CAAC,KAAK,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AAC5D,CAAC","sourcesContent":["/**\n * Times as the diagrams write them: durations in ms, and times of day as ms since midnight.\n *\n * Here and not in the generator, because the blocks convert with them too (TO_TIME).\n */\nimport type { FbValue } from './types';\n\nconst TIME_UNITS: Record<string, number> = { ms: 1, s: 1000, m: 60000, h: 3600000, d: 86400000 };\n\n/** ms of a day */\nexport const DAY_MS = TIME_UNITS.d;\n\n/**\n * A time in ms. Takes a number of ms, a text like `2s`, `1m30s`, `500ms` or `T#2s` (IEC), or a time\n * of day like `08:30` or `TOD#22:15:30` - as the time since midnight. Returns `null` if the text is\n * not a time.\n */\nexport function parseTime(value: FbValue | null | undefined): number | null {\n if (typeof value === 'number') {\n return Number.isFinite(value) && value >= 0 ? Math.round(value) : null;\n }\n if (typeof value !== 'string') {\n return null;\n }\n let text = value.trim().toLowerCase().replace(/_/g, '');\n if (/^(t|time|tod|timeofday)#/.test(text)) {\n text = text.substring(text.indexOf('#') + 1);\n }\n if (!text) {\n return null;\n }\n const clock = text.match(/^(\\d{1,2}):(\\d{2})(?::(\\d{2}))?$/);\n if (clock) {\n const [hours, minutes, seconds] = [clock[1], clock[2], clock[3] || '0'].map(Number);\n return minutes < 60 && seconds < 60 ? ((hours * 60 + minutes) * 60 + seconds) * 1000 : null;\n }\n if (/^\\d+(\\.\\d+)?$/.test(text)) {\n return Math.round(Number(text));\n }\n const parts = text.match(/(\\d+(?:\\.\\d+)?)(ms|s|m|h|d)/g);\n if (!parts || parts.join('') !== text) {\n return null;\n }\n return Math.round(\n parts.reduce((sum, part) => {\n const [, number, unit] = part.match(/(\\d+(?:\\.\\d+)?)(ms|s|m|h|d)/)!;\n return sum + Number(number) * TIME_UNITS[unit];\n }, 0),\n );\n}\n\n/** A time for people: `1500` gives `1.5s`, `5400000` gives `1h30m` */\nexport function formatTime(ms: number): string {\n if (!ms) {\n return '0ms';\n }\n if (ms < TIME_UNITS.m) {\n return ms >= 1000 ? `${Math.round(ms / 100) / 10}s` : `${Math.round(ms)}ms`;\n }\n // from a minute on in parts: 1h30m, 2d4h, 1m30.5s\n let rest = Math.round(ms);\n const parts: string[] = [];\n for (const unit of ['d', 'h', 'm'] as const) {\n const count = Math.floor(rest / TIME_UNITS[unit]);\n if (count) {\n parts.push(`${count}${unit}`);\n rest -= count * TIME_UNITS[unit];\n }\n }\n if (rest) {\n parts.push(rest % 1000 ? `${Math.round(rest / 100) / 10}s` : `${rest / 1000}s`);\n }\n return parts.join('');\n}\n\n/** A time of day for people: `30600000` gives `08:30`, with seconds only when there are some */\nexport function formatClock(ms: number): string {\n const total = Math.round((((ms % DAY_MS) + DAY_MS) % DAY_MS) / 1000);\n const pad = (n: number): string => String(n).padStart(2, '0');\n const text = `${pad(Math.floor(total / 3600))}:${pad(Math.floor(total / 60) % 60)}`;\n return total % 60 ? `${text}:${pad(total % 60)}` : text;\n}\n"]}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ /**
3
+ * The data model of a function block diagram (FBD, in the style of CFC).
4
+ *
5
+ * This part is shared: the editor draws and edits the graph, the generator turns it into
6
+ * JavaScript. It must not depend on React, the DOM or Node, so it runs in the browser and in the
7
+ * adapter alike.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.FB_USER_PREFIX = exports.FB_RUNTIME_MODULE = exports.FB_RUNTIME_VERSION = exports.FB_FORMAT = void 0;
11
+ /** Version of the graph format - raised only when an older graph cannot be read as it is */
12
+ exports.FB_FORMAT = 1;
13
+ /** Version of the block library and of the runtime module the generated code needs */
14
+ exports.FB_RUNTIME_VERSION = '1.5.0';
15
+ /** Name under which the generated code requires the runtime module */
16
+ exports.FB_RUNTIME_MODULE = '@iobroker/fb-runtime';
17
+ /** Types of user blocks start with this, e.g. `@userFb/shutter` */
18
+ exports.FB_USER_PREFIX = '@userFb/';
19
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/lib/fb/types.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,4FAA4F;AAC/E,QAAA,SAAS,GAAG,CAAC,CAAC;AAE3B,sFAAsF;AACzE,QAAA,kBAAkB,GAAG,OAAO,CAAC;AAE1C,sEAAsE;AACzD,QAAA,iBAAiB,GAAG,sBAAsB,CAAC;AA8FxD,mEAAmE;AACtD,QAAA,cAAc,GAAG,UAAU,CAAC","sourcesContent":["/**\n * The data model of a function block diagram (FBD, in the style of CFC).\n *\n * This part is shared: the editor draws and edits the graph, the generator turns it into\n * JavaScript. It must not depend on React, the DOM or Node, so it runs in the browser and in the\n * adapter alike.\n */\n\n/** Version of the graph format - raised only when an older graph cannot be read as it is */\nexport const FB_FORMAT = 1;\n\n/** Version of the block library and of the runtime module the generated code needs */\nexport const FB_RUNTIME_VERSION = '1.5.0';\n\n/** Name under which the generated code requires the runtime module */\nexport const FB_RUNTIME_MODULE = '@iobroker/fb-runtime';\n\n/** The type of a signal */\nexport type FbSignalType = 'BOOL' | 'INT' | 'REAL' | 'TIME' | 'STRING';\n\n/**\n * The type of a pin: a signal type, `ANY` (an input that takes every type) or the type chosen in a\n * parameter of the block, like the output of STATE_IN.\n */\nexport type FbPinType = FbSignalType | 'ANY' | { param: string };\n\n/** A value of a parameter or of an input that is not connected */\nexport type FbValue = boolean | number | string;\n\n/**\n * How the diagram is executed.\n *\n * - `event`: one cycle per change of an input, several changes within a short window run together\n * - `cyclic`: at a fixed interval, and additionally right after an input changed\n * - `auto`: cyclic as soon as a block depends on time (a timer), otherwise event driven\n */\nexport type FbCycleMode = 'auto' | 'cyclic' | 'event';\n\nexport interface FbCycle {\n mode: FbCycleMode;\n /** Interval of the cyclic mode in ms */\n ms: number;\n}\n\nexport interface FbPinSettings {\n /** A BOOL input that is negated, drawn as a circle */\n inverted?: boolean;\n}\n\nexport interface FbBlock {\n /** Assigned once and never changed - signal keys, the online view and log lines refer to it */\n id: string;\n /** Type from the block library, e.g. `TON` */\n type: string;\n /** Instance name, free to change */\n name: string;\n /** A note of the user on this block */\n comment?: string;\n pos: [number, number];\n /** Position in the execution order, written back by the generator */\n order?: number;\n /** Parameters, and the values of inputs that are not connected */\n params?: Record<string, FbValue>;\n /** Only the pins that differ from the default */\n pins?: Record<string, FbPinSettings>;\n /** Keep the state over a restart - reserved, not supported yet */\n retain?: boolean;\n}\n\nexport interface FbLink {\n id: string;\n /** `[blockId, outputPinId]` */\n from: [string, string];\n /** `[blockId, inputPinId]` */\n to: [string, string];\n /**\n * Drawn as a connection mark - a named jump at both ends instead of a line through the diagram.\n * Only the drawing differs; the link works the same.\n */\n mark?: boolean;\n /** The name the marks show; without it, the name of the block the link comes from */\n label?: string;\n}\n\nexport interface FbComment {\n id: string;\n pos: [number, number];\n size: [number, number];\n text: string;\n}\n\nexport interface FbGraph {\n format: number;\n /** Version of the block library the graph was made with */\n runtime: string;\n cycle: FbCycle;\n blocks: FbBlock[];\n links: FbLink[];\n comments: FbComment[];\n /** Set when this diagram is a block to be used in other diagrams */\n block?: FbBlockInfo;\n /**\n * Copies of the user blocks this diagram uses, by type - also of those used inside them. With its\n * copies a diagram stays as it was when a block changes, until it is updated, and it can be\n * exported and imported on its own.\n */\n userBlocks?: Record<string, FbUserBlock>;\n}\n\n/** Types of user blocks start with this, e.g. `@userFb/shutter` */\nexport const FB_USER_PREFIX = '@userFb/';\n\n/** A diagram that is a block of its own - its FB_IN and FB_OUT blocks are the pins */\nexport interface FbBlockInfo {\n /** `@userFb/<identifier>` - never changed once the block is used */\n type: string;\n /** The name in the palette */\n name: string;\n /** Counts the saved changes; a diagram keeps the version it copied until it is updated */\n version: number;\n description?: string;\n}\n\n/** A user block as a diagram carries it */\nexport interface FbUserBlock extends FbBlockInfo {\n /** Its diagram, without `block` and `userBlocks` - the blocks it uses are in the map of the diagram */\n graph: FbGraph;\n}\n\n/** A category of the palette */\nexport type FbCategory =\n | 'logic'\n | 'memory'\n | 'timers'\n | 'counters'\n | 'compare'\n | 'arithmetic'\n | 'convert'\n | 'control'\n | 'calendar'\n | 'messages'\n | 'expert'\n | 'iobroker'\n | 'interface'\n | 'user';\n\nexport interface FbPinDef {\n id: string;\n type: FbPinType;\n /** Usually set as a value rather than connected, like the time of a timer */\n param?: boolean;\n /** Value of the input while it is not connected */\n default?: FbValue;\n /** A TIME that is a time of day, in ms since midnight - shown as `08:30` */\n clock?: boolean;\n}\n\nexport interface FbParamDef {\n id: string;\n /**\n * `OID` is an ioBroker state ID, `ENUM` one of `options`, `NAME` an identifier, `INSTANCE` an\n * adapter instance like `telegram.0`, `CRON` a cron pattern, `CODE` the body of a JavaScript\n * function\n */\n type: FbPinType | 'OID' | 'ENUM' | 'NAME' | 'INSTANCE' | 'CRON' | 'CODE';\n options?: string[];\n default?: FbValue;\n /** The diagram cannot run without it */\n required?: boolean;\n}\n\n/**\n * A block type of the library.\n *\n * The description is pure data - the editor draws the block from it and the generator writes the\n * code from `code`, so both always agree. In `code`:\n *\n * - `{PIN}`: an output is the signal it writes, an input the expression it reads\n * - `{PREFIX*:sep}`: all inputs of an extensible block, joined by `sep`\n * - `{$param}`: the value of a parameter as a literal\n * - `{I}`: the instance of a stateful block\n * - `dt` and `firstScan`: time since the last cycle in ms, and whether this is the first cycle\n */\nexport interface FbBlockDef {\n type: string;\n category: FbCategory;\n inputs: FbPinDef[];\n outputs: FbPinDef[];\n params?: FbParamDef[];\n /**\n * Inputs `<prefix>1` to `<prefix>n`; `n` is the parameter `inputs` of the block - `count` when a\n * block is placed, `min` if not given\n */\n extensible?: { prefix: string; type: FbPinType; default: FbValue; min: number; max: number; count?: number };\n /** Outputs `<prefix>1` to `<prefix>n` in the same way, by the parameter `outputs` */\n extensibleOutputs?: { prefix: string; type: FbPinType; min: number; max: number; count?: number };\n /** Remembers something from one cycle to the next; implemented by `fb.<type>()` of the runtime */\n stateful?: boolean;\n /** Depends on time, so the diagram has to run cyclically */\n timeDependent?: boolean;\n code: string;\n /** For a user block: its definition. Its code is generated from its diagram, not from `code` */\n user?: FbUserBlock;\n}\n\n/**\n * What the online view can do with a running diagram. The settings last as long as an editor watches\n * the diagram; when the last one goes, the runtime lets go of everything and runs on.\n */\nexport type FbDebugCommand =\n /**\n * Holds a signal `<block>.<pin>` at a value, whatever its block computes. A signal inside an\n * instance of a user block has the path of the instances in front: `<instance>/<block>.<pin>`.\n */\n | { command: 'force'; signal: string; value: FbValue }\n /** Lets a forced signal go again - all of them without `signal` */\n | { command: 'release'; signal?: string }\n /** Sets or removes the breakpoint of a block; without `block`, `on: false` removes all */\n | { command: 'breakpoint'; block?: string; on: boolean }\n /** Cycles wait from the next one on */\n | { command: 'pause' }\n /** Runs on, up to the next breakpoint */\n | { command: 'resume' }\n /** While paused: runs one block */\n | { command: 'step' }\n /** While paused: runs the rest of the cycle, or one whole cycle */\n | { command: 'cycle' };\n\n/** How the online view stands with a diagram */\nexport interface FbDebugStatus {\n /** The code can stop in front of a block - it was generated with runtime 1.2 or later */\n breaks: boolean;\n /** The inside of the instances of user blocks can be shown - generated with runtime 1.3 or later */\n inside: boolean;\n /** The cycles wait for `resume`, `step` or `cycle` */\n paused: boolean;\n /** While paused: the block that runs next */\n at?: string;\n breakpoints: string[];\n /** The forced signals with their values */\n forced: Record<string, FbValue>;\n}\n\n/** A problem found in a diagram; `message` is an English text with `%s` for `args` */\nexport interface FbIssue {\n severity: 'error' | 'warning';\n message: string;\n args?: string[];\n blockId?: string;\n /** For a problem that involves several blocks, like a loop */\n blockIds?: string[];\n linkId?: string;\n}\n"]}
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FB_USER_TYPE_PATTERN = void 0;
4
+ exports.toIdentifier = toIdentifier;
5
+ exports.createBlockInfo = createBlockInfo;
6
+ exports.factoryName = factoryName;
7
+ exports.userBlockOf = userBlockOf;
8
+ exports.mergeUserBlocks = mergeUserBlocks;
9
+ exports.usedUserBlocks = usedUserBlocks;
10
+ exports.containsUserBlock = containsUserBlock;
11
+ /**
12
+ * User blocks: diagrams that are used as blocks in other diagrams.
13
+ *
14
+ * A diagram becomes a block with `graph.block`; its FB_IN and FB_OUT blocks are the pins. A diagram
15
+ * that uses it carries a copy (`graph.userBlocks`), together with copies of the blocks used inside
16
+ * it. So the diagram keeps working as it is when the block changes, until it is updated on purpose.
17
+ */
18
+ const types_1 = require("./types");
19
+ /** `@userFb/<identifier>` */
20
+ exports.FB_USER_TYPE_PATTERN = /^@userFb\/[A-Za-z_][A-Za-z0-9_]*$/;
21
+ /** A text as an identifier: `Rollladen Süd` gives `Rollladen_S_d` */
22
+ function toIdentifier(text) {
23
+ const identifier = text.trim().replace(/[^A-Za-z0-9_]/g, '_');
24
+ return /^[A-Za-z_]/.test(identifier) ? identifier : `_${identifier}`;
25
+ }
26
+ /** The block info of a diagram that just became a block */
27
+ function createBlockInfo(name) {
28
+ return { type: `${types_1.FB_USER_PREFIX}${toIdentifier(name || 'block')}`, name: name || 'block', version: 1 };
29
+ }
30
+ /** The name of the factory function the generated code has for a user block */
31
+ function factoryName(type) {
32
+ return `UFB_${type.substring(types_1.FB_USER_PREFIX.length)}`;
33
+ }
34
+ /** The copy of a block to put into other diagrams, made of the diagram of the block */
35
+ function userBlockOf(graph) {
36
+ if (!graph.block) {
37
+ return null;
38
+ }
39
+ const { block, userBlocks: _userBlocks, ...rest } = graph;
40
+ // the order of a stored diagram is only for the display
41
+ const blocks = rest.blocks.map(({ order: _order, ...inner }) => inner);
42
+ return { ...block, graph: { ...rest, blocks } };
43
+ }
44
+ /**
45
+ * Puts the copies of `incoming` into `target`. A copy only replaces an older version - except for
46
+ * the types in `update`, which take the incoming one in any case.
47
+ */
48
+ function mergeUserBlocks(target, incoming, update) {
49
+ const result = { ...target };
50
+ for (const [type, user] of Object.entries(incoming || {})) {
51
+ const existing = result[type];
52
+ if (!existing || existing.version < user.version || update?.includes(type)) {
53
+ result[type] = user;
54
+ }
55
+ }
56
+ return result;
57
+ }
58
+ /** The user blocks a diagram needs: those it places, and those used inside them */
59
+ function usedUserBlocks(graph, userBlocks) {
60
+ const used = new Set();
61
+ const visit = (blocks) => {
62
+ for (const block of blocks) {
63
+ const user = userBlocks?.[block.type];
64
+ if (user && !used.has(block.type)) {
65
+ used.add(block.type);
66
+ visit(user.graph.blocks);
67
+ }
68
+ }
69
+ };
70
+ visit(graph.blocks);
71
+ return [...used];
72
+ }
73
+ /** Whether the block `type` contains `inner` - directly or deeper down */
74
+ function containsUserBlock(type, inner, userBlocks) {
75
+ const user = userBlocks?.[type];
76
+ return !!user && usedUserBlocks(user.graph, userBlocks).includes(inner);
77
+ }
78
+ //# sourceMappingURL=user.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user.js","sourceRoot":"","sources":["../../../src/lib/fb/user.ts"],"names":[],"mappings":";;;AAaA,oCAGC;AAGD,0CAEC;AAGD,kCAEC;AAGD,kCAQC;AAMD,0CAaC;AAGD,wCAaC;AAGD,8CAOC;AAlFD;;;;;;GAMG;AACH,mCAA2F;AAE3F,6BAA6B;AAChB,QAAA,oBAAoB,GAAG,mCAAmC,CAAC;AAExE,qEAAqE;AACrE,SAAgB,YAAY,CAAC,IAAY;IACrC,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC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AC","sourcesContent":["/**\n * User blocks: diagrams that are used as blocks in other diagrams.\n *\n * A diagram becomes a block with `graph.block`; its FB_IN and FB_OUT blocks are the pins. A diagram\n * that uses it carries a copy (`graph.userBlocks`), together with copies of the blocks used inside\n * it. So the diagram keeps working as it is when the block changes, until it is updated on purpose.\n */\nimport { FB_USER_PREFIX, type FbBlockInfo, type FbGraph, type FbUserBlock } from './types';\n\n/** `@userFb/<identifier>` */\nexport const FB_USER_TYPE_PATTERN = /^@userFb\\/[A-Za-z_][A-Za-z0-9_]*$/;\n\n/** A text as an identifier: `Rollladen Süd` gives `Rollladen_S_d` */\nexport function toIdentifier(text: string): string {\n const identifier = text.trim().replace(/[^A-Za-z0-9_]/g, '_');\n return /^[A-Za-z_]/.test(identifier) ? identifier : `_${identifier}`;\n}\n\n/** The block info of a diagram that just became a block */\nexport function createBlockInfo(name: string): FbBlockInfo {\n return { type: `${FB_USER_PREFIX}${toIdentifier(name || 'block')}`, name: name || 'block', version: 1 };\n}\n\n/** The name of the factory function the generated code has for a user block */\nexport function factoryName(type: string): string {\n return `UFB_${type.substring(FB_USER_PREFIX.length)}`;\n}\n\n/** The copy of a block to put into other diagrams, made of the diagram of the block */\nexport function userBlockOf(graph: FbGraph): FbUserBlock | null {\n if (!graph.block) {\n return null;\n }\n const { block, userBlocks: _userBlocks, ...rest } = graph;\n // the order of a stored diagram is only for the display\n const blocks = rest.blocks.map(({ order: _order, ...inner }) => inner);\n return { ...block, graph: { ...rest, blocks } };\n}\n\n/**\n * Puts the copies of `incoming` into `target`. A copy only replaces an older version - except for\n * the types in `update`, which take the incoming one in any case.\n */\nexport function mergeUserBlocks(\n target: Record<string, FbUserBlock> | undefined,\n incoming: Record<string, FbUserBlock> | undefined,\n update?: string[],\n): Record<string, FbUserBlock> {\n const result = { ...target };\n for (const [type, user] of Object.entries(incoming || {})) {\n const existing = result[type];\n if (!existing || existing.version < user.version || update?.includes(type)) {\n result[type] = user;\n }\n }\n return result;\n}\n\n/** The user blocks a diagram needs: those it places, and those used inside them */\nexport function usedUserBlocks(graph: FbGraph, userBlocks: Record<string, FbUserBlock> | undefined): string[] {\n const used = new Set<string>();\n const visit = (blocks: FbGraph['blocks']): void => {\n for (const block of blocks) {\n const user = userBlocks?.[block.type];\n if (user && !used.has(block.type)) {\n used.add(block.type);\n visit(user.graph.blocks);\n }\n }\n };\n visit(graph.blocks);\n return [...used];\n}\n\n/** Whether the block `type` contains `inner` - directly or deeper down */\nexport function containsUserBlock(\n type: string,\n inner: string,\n userBlocks: Record<string, FbUserBlock> | undefined,\n): boolean {\n const user = userBlocks?.[type];\n return !!user && usedUserBlocks(user.graph, userBlocks).includes(inner);\n}\n"]}
@@ -1104,7 +1104,7 @@ declare global {
1104
1104
  interface ScriptCommon extends ObjectCommon {
1105
1105
  name: string;
1106
1106
  /** Defines the type of the script, e.g., TypeScript/ts, Javascript/js or Blockly */
1107
- engineType: 'TypeScript/ts' | 'Blockly' | 'Rules' | 'Javascript/js';
1107
+ engineType: 'TypeScript/ts' | 'Blockly' | 'Rules' | 'FBD' | 'Javascript/js';
1108
1108
  /** The instance id of the instance which executes this script */
1109
1109
  engine: string;
1110
1110
  /** The source code of this script */
@@ -2157,43 +2157,43 @@ declare global {
2157
2157
  oldAck?: boolean;
2158
2158
  /** New value time stamp must be equal to given one (state.ts == ts) */
2159
2159
  ts?: number;
2160
- /** New value time stamp must be not equal to the given one (state.ts != ts) */
2160
+ /** New value time stamp must be greater than given one (state.ts > ts) */
2161
2161
  tsGt?: number;
2162
- /** New value time stamp must be greater than given value (state.ts > ts) */
2163
- tsGe?: number;
2164
2162
  /** New value time stamp must be greater or equal to given one (state.ts >= ts) */
2165
- tsLt?: number;
2163
+ tsGe?: number;
2166
2164
  /** New value time stamp must be smaller than given one (state.ts < ts) */
2165
+ tsLt?: number;
2166
+ /** New value time stamp must be smaller or equal to given one (state.ts <= ts) */
2167
2167
  tsLe?: number;
2168
2168
  /** Previous time stamp must be equal to given one (oldState.ts == ts) */
2169
2169
  oldTs?: number;
2170
- /** Previous time stamp must be not equal to the given one (oldState.ts != ts) */
2170
+ /** Previous time stamp must be greater than given one (oldState.ts > ts) */
2171
2171
  oldTsGt?: number;
2172
- /** Previous time stamp must be greater than the given value (oldState.ts > ts) */
2173
- oldTsGe?: number;
2174
2172
  /** Previous time stamp must be greater or equal to given one (oldState.ts >= ts) */
2175
- oldTsLt?: number;
2173
+ oldTsGe?: number;
2176
2174
  /** Previous time stamp must be smaller than given one (oldState.ts < ts) */
2175
+ oldTsLt?: number;
2176
+ /** Previous time stamp must be smaller or equal to given one (oldState.ts <= ts) */
2177
2177
  oldTsLe?: number;
2178
2178
  /** Last change time stamp must be equal to given one (state.lc == lc) */
2179
2179
  lc?: number;
2180
- /** Last change time stamp must be not equal to the given one (state.lc != lc) */
2180
+ /** Last change time stamp must be greater than given one (state.lc > lc) */
2181
2181
  lcGt?: number;
2182
- /** Last change time stamp must be greater than the given value (state.lc > lc) */
2183
- lcGe?: number;
2184
2182
  /** Last change time stamp must be greater or equal to given one (state.lc >= lc) */
2185
- lcLt?: number;
2183
+ lcGe?: number;
2186
2184
  /** Last change time stamp must be smaller than given one (state.lc < lc) */
2185
+ lcLt?: number;
2186
+ /** Last change time stamp must be smaller or equal to given one (state.lc <= lc) */
2187
2187
  lcLe?: number;
2188
2188
  /** Previous last change time stamp must be equal to given one (oldState.lc == lc) */
2189
2189
  oldLc?: number;
2190
- /** Previous last change time stamp must be not equal to the given one (oldState.lc != lc) */
2190
+ /** Previous last change time stamp must be greater than given one (oldState.lc > lc) */
2191
2191
  oldLcGt?: number;
2192
- /** Previous last change time stamp must be greater than the given value (oldState.lc > lc) */
2193
- oldLcGe?: number;
2194
2192
  /** Previous last change time stamp must be greater or equal to given one (oldState.lc >= lc) */
2195
- oldLcLt?: number;
2193
+ oldLcGe?: number;
2196
2194
  /** Previous last change time stamp must be smaller than given one (oldState.lc < lc) */
2195
+ oldLcLt?: number;
2196
+ /** Previous last change time stamp must be smaller or equal to given one (oldState.lc <= lc) */
2197
2197
  oldLcLe?: number;
2198
2198
  /** Channel ID must be equal or match to given one */
2199
2199
  channelId?: string | string[] | RegExp;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Mirror = void 0;
4
4
  const node_fs_1 = require("node:fs");
5
5
  const node_path_1 = require("node:path");
6
+ const graph_1 = require("./fb/graph");
6
7
  const tools_1 = require("./tools");
7
8
  const MODE_0777 = 511;
8
9
  class Mirror {
@@ -172,6 +173,9 @@ class Mirror {
172
173
  if (fileName.endsWith('.ts')) {
173
174
  return 'TypeScript/ts';
174
175
  }
176
+ if ((0, graph_1.isFbdSource)(data)) {
177
+ return 'FBD';
178
+ }
175
179
  return Mirror.isBlockly(data) ? 'Blockly' : Mirror.isRules(data) ? 'Rules' : 'Javascript/js';
176
180
  }
177
181
  updateFolderTime(id) {