vivth 1.4.9 → 1.5.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 (379) hide show
  1. package/README.md +6060 -2037
  2. package/README.src.md +22 -14
  3. package/bun.lock +154 -194
  4. package/dev/auto/.src.ignore +25 -0
  5. package/dev/auto-doc.mjs +137 -0
  6. package/generated/types/generated/vivth/exports/all.d.mts +145 -0
  7. package/generated/types/generated/vivth/exports/neutral.d.mts +105 -0
  8. package/generated/types/generated/vivth/exports/node.d.mts +40 -0
  9. package/generated/types/src/bundler/CompileAS.d.mts +30 -0
  10. package/generated/types/src/bundler/CompileJS.d.mts +109 -0
  11. package/{types → generated/types}/src/bundler/CreateESPlugin.d.mts +1 -1
  12. package/{types → generated/types}/src/bundler/EsBundler.d.mts +9 -7
  13. package/generated/types/src/bundler/FSAnalyzer.d.mts +58 -0
  14. package/generated/types/src/bundler/FSasar.bundled.d.mts +28 -0
  15. package/generated/types/src/bundler/FSasar.d.mts +51 -0
  16. package/generated/types/src/bundler/FileSelfMapper.d.mts +137 -0
  17. package/generated/types/src/bundler/JSDirMapper.d.mts +128 -0
  18. package/generated/types/src/bundler/RunWatchThenCompileJSOnSafeExit.d.mts +63 -0
  19. package/generated/types/src/bundler/adds/BrowserExternals.d.mts +21 -0
  20. package/generated/types/src/bundler/adds/CreateTransform.d.mts +26 -0
  21. package/generated/types/src/bundler/adds/LastEditedUnix.d.mts +5 -0
  22. package/generated/types/src/bundler/adds/NodeModuleList.d.mts +15 -0
  23. package/generated/types/src/bundler/adds/PathFSBundles.bundled.d.mts +25 -0
  24. package/generated/types/src/bundler/adds/PathFSBundles.d.mts +48 -0
  25. package/generated/types/src/bundler/adds/PathFSDir.bundled.d.mts +30 -0
  26. package/generated/types/src/bundler/adds/PathFSDir.d.mts +48 -0
  27. package/generated/types/src/bundler/adds/PathFSFile.bundled.d.mts +25 -0
  28. package/generated/types/src/bundler/adds/PathFSFile.d.mts +40 -0
  29. package/{types → generated/types}/src/bundler/adds/ToBundledJSPlugin.d.mts +6 -6
  30. package/generated/types/src/bundler/adds/autoExternalize.d.mts +2 -0
  31. package/generated/types/src/bundler/adds/emptyBufferValue.d.mts +1 -0
  32. package/generated/types/src/bundler/adds/isModuleTheBundledVersion.d.mts +1 -0
  33. package/generated/types/src/bundler/adds/onEndEsBuildErrorLogger.d.mts +1 -0
  34. package/generated/types/src/bundler/adds/resolveJSDependencyPath.d.mts +1 -0
  35. package/generated/types/src/class/AwaitSignal.d.mts +48 -0
  36. package/generated/types/src/class/Console.d.mts +82 -0
  37. package/generated/types/src/class/DataLog.d.mts +25 -0
  38. package/generated/types/src/class/Derived.d.mts +74 -0
  39. package/generated/types/src/class/Effect.d.mts +213 -0
  40. package/{types → generated/types}/src/class/EnvSignal.d.mts +6 -2
  41. package/generated/types/src/class/EsWatcher.d.mts +36 -0
  42. package/{types → generated/types}/src/class/EventSignal.d.mts +39 -39
  43. package/generated/types/src/class/FSDirArchWatcher.d.mts +110 -0
  44. package/{types → generated/types}/src/class/FileSafe.d.mts +32 -16
  45. package/generated/types/src/class/ForEach.d.mts +57 -0
  46. package/generated/types/src/class/ForSignal.d.mts +63 -0
  47. package/generated/types/src/class/GetterSetter.d.mts +38 -0
  48. package/generated/types/src/class/JSONFileHandler.d.mts +50 -0
  49. package/{types → generated/types}/src/class/ListSignal.d.mts +49 -15
  50. package/{types → generated/types}/src/class/LitExp.d.mts +18 -18
  51. package/generated/types/src/class/ObjectSignal.d.mts +267 -0
  52. package/generated/types/src/class/Paths.d.mts +95 -0
  53. package/generated/types/src/class/Prettivy.d.mts +26 -0
  54. package/{types → generated/types}/src/class/QChannel.d.mts +24 -16
  55. package/generated/types/src/class/SafeExit.d.mts +69 -0
  56. package/{types → generated/types}/src/class/Setup.d.mts +29 -16
  57. package/{types → generated/types}/src/class/Signal.d.mts +29 -15
  58. package/generated/types/src/class/SignalCollection.d.mts +96 -0
  59. package/{types → generated/types}/src/class/WalkThrough.d.mts +4 -19
  60. package/generated/types/src/class/WorkerMainThread.bundled.d.mts +83 -0
  61. package/{types → generated/types}/src/class/WorkerMainThread.d.mts +33 -39
  62. package/{types → generated/types}/src/class/WorkerThread.d.mts +11 -5
  63. package/{types → generated/types}/src/common/Base64URL.d.mts +2 -1
  64. package/generated/types/src/common/Base64URLFromFile.d.mts +20 -0
  65. package/generated/types/src/common/BundledV.bundled.d.mts +3 -0
  66. package/generated/types/src/common/BundledV.d.mts +36 -0
  67. package/{types → generated/types}/src/common/CreateStringID.d.mts +5 -4
  68. package/generated/types/src/common/EnvMode.d.mts +79 -0
  69. package/generated/types/src/common/FactoryKey.d.mts +9 -0
  70. package/generated/types/src/common/Preferrence.d.mts +25 -0
  71. package/{types → generated/types}/src/common/Trace.d.mts +1 -1
  72. package/{types → generated/types}/src/common/TracePath.d.mts +1 -1
  73. package/generated/types/src/common/VivthUnBundledCodeBlock.d.mts +6 -0
  74. package/generated/types/src/doc/JSautoDOC.d.mts +172 -0
  75. package/generated/types/src/doc/cleanPreserveTypedef.d.mts +1 -0
  76. package/{types/src/doc/parsedFile.d.mts → generated/types/src/doc/parsedFileForDOC.d.mts} +56 -27
  77. package/generated/types/src/function/ClearRequireCache.d.mts +1 -0
  78. package/{types → generated/types}/src/function/CreateImmutable.d.mts +5 -4
  79. package/{types → generated/types}/src/function/EventCheck.d.mts +3 -1
  80. package/{types → generated/types}/src/function/EventObject.d.mts +2 -6
  81. package/generated/types/src/function/ForInAsync.d.mts +36 -0
  82. package/generated/types/src/function/ForInSync.d.mts +36 -0
  83. package/generated/types/src/function/ForOfAsync.d.mts +25 -0
  84. package/generated/types/src/function/ForOfSync.d.mts +36 -0
  85. package/generated/types/src/function/GetBufferFromRelativePath.d.mts +15 -0
  86. package/generated/types/src/function/GetFilesFromDir.d.mts +14 -0
  87. package/generated/types/src/function/GetMaxFilenameLength.d.mts +9 -0
  88. package/generated/types/src/function/GetModuleEsbuildPlatform.d.mts +13 -0
  89. package/{types → generated/types}/src/function/GetNamedImportAlias.d.mts +1 -1
  90. package/generated/types/src/function/GetRuntime.d.mts +2 -0
  91. package/generated/types/src/function/InstantiateAssemblyScript.d.mts +15 -0
  92. package/{types → generated/types}/src/function/IsAsync.d.mts +1 -1
  93. package/generated/types/src/function/IsInstanceOf.d.mts +25 -0
  94. package/generated/types/src/function/IsSameFile.d.mts +16 -0
  95. package/generated/types/src/function/IsStringLooksLikeAPath.d.mts +16 -0
  96. package/generated/types/src/function/IsTypeOf.d.mts +25 -0
  97. package/{types → generated/types}/src/function/LazyFactory.d.mts +9 -10
  98. package/generated/types/src/function/MonkeyPatch.d.mts +33 -0
  99. package/generated/types/src/function/NewAnimationTimeline.d.mts +24 -0
  100. package/generated/types/src/function/NewChainable.d.mts +35 -0
  101. package/generated/types/src/function/NewDynamicsExport.d.mts +49 -0
  102. package/generated/types/src/function/NewObjectWrapper.d.mts +10 -0
  103. package/generated/types/src/function/ObjectRegistrar.d.mts +17 -0
  104. package/generated/types/src/function/ParseSQLFile.d.mts +25 -0
  105. package/generated/types/src/function/PipeAsync.d.mts +19 -0
  106. package/generated/types/src/function/PipeSync.d.mts +17 -0
  107. package/generated/types/src/function/SafeImport.d.mts +21 -0
  108. package/generated/types/src/function/TemplateLiteral.d.mts +23 -0
  109. package/{types → generated/types}/src/function/Timeout.d.mts +1 -1
  110. package/{types → generated/types}/src/function/Tries.d.mts +4 -4
  111. package/{types → generated/types}/src/function/TryAsync.d.mts +2 -2
  112. package/{types → generated/types}/src/function/TryNew.d.mts +1 -1
  113. package/generated/types/src/function/TsToMjs.d.mts +27 -0
  114. package/generated/types/src/function/UniqueFSTempName.d.mts +9 -0
  115. package/generated/types/src/function/errorToMessage.d.mts +5 -0
  116. package/generated/types/src/neinth/VivthyNeinth.d.mts +202 -0
  117. package/generated/types/src/typehints/ArrayToKeys.d.mts +23 -0
  118. package/generated/types/src/typehints/AssemblyScriptExportsType.d.mts +4 -0
  119. package/generated/types/src/typehints/AssemblyScriptLoaderInstantiate.d.mts +4 -0
  120. package/generated/types/src/typehints/AutoDocASOptions.d.mts +15 -0
  121. package/generated/types/src/typehints/ChainableType.d.mts +3 -0
  122. package/generated/types/src/typehints/ComponentDecorator_Constructor.d.mts +3 -0
  123. package/generated/types/src/typehints/ConsoleAdditionalSettingType.d.mts +3 -0
  124. package/generated/types/src/typehints/Decorator.d.mts +11 -0
  125. package/generated/types/src/typehints/DecoratorMonkeyPatch.d.mts +15 -0
  126. package/{types/src/types → generated/types/src/typehints}/DevTestCB.d.mts +2 -2
  127. package/generated/types/src/typehints/EnvModeType.d.mts +4 -0
  128. package/generated/types/src/typehints/ListArg.d.mts +4 -0
  129. package/generated/types/src/typehints/MonkeyPatchedType.d.mts +1 -0
  130. package/generated/types/src/typehints/ParametersFollowingN.d.mts +13 -0
  131. package/generated/types/src/typehints/PrefixedKeysOf.d.mts +1 -0
  132. package/generated/types/src/typehints/Runtime.d.mts +4 -0
  133. package/generated/types/src/typehints/SafeImportReturnType.d.mts +1 -0
  134. package/generated/types/src/typehints/StylePropRefType.d.mts +2 -0
  135. package/generated/types/src/typehints/TemplateLiteralValueHandler.d.mts +10 -0
  136. package/generated/types/src/typehints/VLifecycleCallbacks.d.mts +6 -0
  137. package/generated/types/src/typehints/VivthCleanup.d.mts +12 -0
  138. package/generated/types/src/web/BrowserDirMapper.d.mts +70 -0
  139. package/generated/types/src/web/EnsureValidTag.d.mts +7 -0
  140. package/generated/types/src/web/ViteAddDynamics.d.mts +28 -0
  141. package/generated/types/src/web/ViteGetAllHTMLFile.d.mts +9 -0
  142. package/generated/types/src/web/WC_extendsA.d.mts +135 -0
  143. package/generated/types/src/web/WC_extendsB.d.mts +135 -0
  144. package/generated/types/src/web/bindings/WC_StyleProp_bind.d.mts +42 -0
  145. package/generated/types/src/web/bindings/WC_createElement_bind.d.mts +51 -0
  146. package/generated/types/src/web/bindings/WC_createNamedSlot.d.mts +26 -0
  147. package/generated/types/src/web/bindings/WC_litRender_bind.d.mts +20 -0
  148. package/generated/types/src/web/bindings/WC_litStyleMap.d.mts +7 -0
  149. package/generated/types/src/web/common/CSS.d.mts +23 -0
  150. package/generated/types/src/web/common/E.d.mts +41 -0
  151. package/generated/types/src/web/common/NewStyleSheetAsync.d.mts +15 -0
  152. package/generated/types/src/web/common/NewStyleSheetSync.d.mts +15 -0
  153. package/generated/types/src/web/common/WC_TagName_type.d.mts +15 -0
  154. package/generated/types/src/web/signals/IsInViewPortSignal.d.mts +52 -0
  155. package/generated/types/src/web/signals/ObserverSignal.d.mts +32 -0
  156. package/generated/types/src/web/signals/WC_litRef.d.mts +26 -0
  157. package/generated/types/src/web/signals/WC_loopedSiblingsRef.d.mts +44 -0
  158. package/generated/vivth/exports/all.mjs +233 -0
  159. package/generated/vivth/exports/neutral.mjs +193 -0
  160. package/generated/vivth/exports/node.mjs +46 -0
  161. package/package.json +50 -14
  162. package/src/bundler/CompileAS.mjs +36 -0
  163. package/src/bundler/CompileJS.mjs +98 -171
  164. package/src/bundler/CreateESPlugin.mjs +1 -1
  165. package/src/bundler/EsBundler.mjs +38 -13
  166. package/src/bundler/FSAnalyzer.mjs +253 -0
  167. package/src/bundler/FSasar.bundled.mjs +128 -0
  168. package/src/bundler/FSasar.mjs +96 -0
  169. package/src/bundler/FileSelfMapper.mjs +491 -0
  170. package/src/bundler/JSDirMapper.mjs +528 -0
  171. package/src/bundler/RunWatchThenCompileJSOnSafeExit.mjs +129 -0
  172. package/src/bundler/adds/BrowserExternals.mjs +37 -0
  173. package/src/bundler/adds/CreateTransform.mjs +36 -0
  174. package/src/bundler/adds/LastEditedUnix.mjs +12 -0
  175. package/src/bundler/adds/NodeModuleList.mjs +33 -0
  176. package/src/bundler/adds/PathFSBundles.bundled.mjs +41 -0
  177. package/src/bundler/adds/PathFSBundles.mjs +91 -0
  178. package/src/bundler/adds/PathFSDir.bundled.mjs +53 -0
  179. package/src/bundler/adds/PathFSDir.mjs +100 -0
  180. package/src/bundler/adds/PathFSFile.bundled.mjs +40 -0
  181. package/src/bundler/adds/PathFSFile.mjs +85 -0
  182. package/src/bundler/adds/ToBundledJSPlugin.mjs +116 -55
  183. package/src/bundler/adds/autoExternalize.mjs +81 -0
  184. package/src/bundler/adds/emptyBufferValue.mjs +5 -0
  185. package/src/bundler/adds/isModuleTheBundledVersion.mjs +10 -0
  186. package/src/bundler/adds/onEndEsBuildErrorLogger.mjs +34 -0
  187. package/src/bundler/adds/resolveJSDependencyPath.mjs +17 -0
  188. package/src/class/AwaitSignal.mjs +119 -0
  189. package/src/class/Console.mjs +36 -14
  190. package/src/class/DataLog.mjs +29 -0
  191. package/src/class/Derived.mjs +67 -55
  192. package/src/class/Effect.mjs +270 -84
  193. package/src/class/EnvSignal.mjs +11 -8
  194. package/src/class/EsWatcher.mjs +60 -0
  195. package/src/class/EventSignal.mjs +46 -58
  196. package/src/class/FSDirArchWatcher.mjs +246 -0
  197. package/src/class/FileSafe.mjs +72 -24
  198. package/src/class/ForEach.mjs +78 -0
  199. package/src/class/ForSignal.mjs +115 -0
  200. package/src/class/GetterSetter.mjs +40 -0
  201. package/src/class/JSONFileHandler.mjs +90 -0
  202. package/src/class/ListSignal.mjs +68 -26
  203. package/src/class/LitExp.mjs +59 -36
  204. package/src/class/ObjectSignal.mjs +225 -0
  205. package/src/class/Paths.mjs +56 -20
  206. package/src/class/Prettivy.mjs +51 -0
  207. package/src/class/QChannel.mjs +48 -26
  208. package/src/class/SafeExit.mjs +156 -99
  209. package/src/class/Setup.mjs +28 -16
  210. package/src/class/Signal.mjs +50 -27
  211. package/src/class/SignalCollection.mjs +130 -0
  212. package/src/class/WalkThrough.mjs +6 -23
  213. package/src/class/{WorkerMainThreadBundled.mjs → WorkerMainThread.bundled.mjs} +61 -84
  214. package/src/class/WorkerMainThread.mjs +103 -102
  215. package/src/class/WorkerThread.mjs +24 -17
  216. package/src/common/Base64URL.mjs +6 -3
  217. package/src/common/Base64URLFromFile.mjs +17 -4
  218. package/src/common/BundledV.bundled.mjs +7 -0
  219. package/src/common/BundledV.mjs +45 -0
  220. package/src/common/CreateStringID.mjs +8 -7
  221. package/src/common/EnvMode.mjs +172 -0
  222. package/src/common/FactoryKey.mjs +11 -0
  223. package/src/common/Preferrence.mjs +27 -0
  224. package/src/common/Trace.mjs +1 -1
  225. package/src/common/TracePath.mjs +53 -3
  226. package/src/common/VivthUnBundledCodeBlock.mjs +8 -0
  227. package/src/doc/JSautoDOC.mjs +673 -284
  228. package/src/doc/cleanPreserveTypedef.mjs +27 -0
  229. package/src/doc/correctBeforeParse.mjs +57 -48
  230. package/src/doc/{parsedFile.mjs → parsedFileForDOC.mjs} +133 -120
  231. package/src/function/ClearRequireCache.mjs +33 -0
  232. package/src/function/CreateImmutable.mjs +40 -37
  233. package/src/function/EventCheck.mjs +5 -2
  234. package/src/function/EventObject.mjs +2 -6
  235. package/src/function/ForInAsync.mjs +76 -0
  236. package/src/function/ForInSync.mjs +87 -0
  237. package/src/function/ForOfAsync.mjs +61 -0
  238. package/src/function/ForOfSync.mjs +70 -0
  239. package/src/function/GetBufferFromRelativePath.mjs +25 -0
  240. package/src/function/GetFilesFromDir.mjs +49 -0
  241. package/src/function/GetMaxFilenameLength.mjs +32 -0
  242. package/src/function/GetModuleEsbuildPlatform.mjs +118 -0
  243. package/src/function/GetNamedImportAlias.mjs +2 -2
  244. package/src/function/GetRuntime.mjs +10 -14
  245. package/src/function/InstantiateAssemblyScript.mjs +22 -0
  246. package/src/function/IsAsync.mjs +1 -1
  247. package/src/function/IsInstanceOf.mjs +29 -0
  248. package/src/function/IsSameFile.mjs +41 -0
  249. package/src/function/IsStringLooksLikeAPath.mjs +20 -0
  250. package/src/function/IsTypeOf.mjs +27 -0
  251. package/src/function/IsTypeOf.mts +31 -0
  252. package/src/function/LazyFactory.mjs +25 -23
  253. package/src/function/MonkeyPatch.mjs +38 -0
  254. package/src/function/NewAnimationTimeline.mjs +55 -0
  255. package/src/function/NewChainable.mjs +69 -0
  256. package/src/function/NewDynamicsExport.mjs +312 -0
  257. package/src/function/NewObjectWrapper.mjs +14 -0
  258. package/src/function/ObjectRegistrar.mjs +23 -0
  259. package/src/function/ParseSQLFile.mjs +129 -0
  260. package/src/function/PipeAsync.mjs +30 -0
  261. package/src/function/PipeSync.mjs +28 -0
  262. package/src/function/SafeImport.mjs +77 -0
  263. package/src/function/TemplateLiteral.mjs +42 -23
  264. package/src/function/Timeout.mjs +4 -4
  265. package/src/function/Tries.mjs +22 -16
  266. package/src/function/TryAsync.mjs +3 -2
  267. package/src/function/TryNew.mjs +1 -1
  268. package/src/function/TsToMjs.mjs +184 -21
  269. package/src/function/UniqueFSTempName.mjs +33 -0
  270. package/src/function/errorToMessage.mjs +21 -0
  271. package/src/function/resolveErrorArray.mjs +15 -1
  272. package/src/neinth/VivthyNeinth.mjs +487 -0
  273. package/src/typehints/ArrayToKeys.mjs +17 -0
  274. package/src/typehints/ArrayToKeys.mts +31 -0
  275. package/src/typehints/AssemblyScriptExportsType.mjs +7 -0
  276. package/src/typehints/AssemblyScriptLoaderInstantiate.mjs +7 -0
  277. package/src/typehints/AutoDocASOptions.mjs +14 -0
  278. package/src/typehints/ChainableType.mjs +11 -0
  279. package/src/typehints/ComponentDecorator_Constructor.mjs +10 -0
  280. package/src/typehints/ConsoleAdditionalSettingType.mjs +6 -0
  281. package/src/typehints/Decorator.mjs +9 -0
  282. package/src/typehints/Decorator.mts +31 -0
  283. package/src/typehints/DecoratorMonkeyPatch.mjs +10 -0
  284. package/src/typehints/DecoratorMonkeyPatch.mts +43 -0
  285. package/src/{types → typehints}/DevTestCB.mjs +2 -2
  286. package/src/typehints/EnvModeType.mjs +6 -0
  287. package/src/{types → typehints}/ListArg.mjs +1 -1
  288. package/src/{types → typehints}/LitExpResultType.mjs +1 -1
  289. package/src/typehints/MonkeyPatchedType.mjs +13 -0
  290. package/src/typehints/ParametersFollowingN.mjs +8 -0
  291. package/src/typehints/ParametersFollowingN.mts +17 -0
  292. package/src/typehints/PrefixedKeysOf.mjs +9 -0
  293. package/src/typehints/Runtime.mjs +6 -0
  294. package/src/typehints/SafeImportReturnType.mjs +6 -0
  295. package/src/typehints/StylePropRefType.mjs +12 -0
  296. package/src/typehints/TemplateLiteralValueHandler.mjs +14 -0
  297. package/src/typehints/VLifecycleCallbacks.mjs +10 -0
  298. package/src/typehints/VivthCleanup.mjs +14 -0
  299. package/src/web/BrowserDirMapper.mjs +255 -0
  300. package/src/web/EnsureValidTag.mjs +5 -0
  301. package/src/web/EnsureValidTag.mts +10 -0
  302. package/src/web/ViteAddDynamics.mjs +34 -0
  303. package/src/web/ViteGetAllHTMLFile.mjs +97 -0
  304. package/src/web/WC_extendsA.mjs +330 -0
  305. package/src/web/WC_extendsB.mjs +332 -0
  306. package/src/web/bindings/WC_StyleProp_bind.mjs +70 -0
  307. package/src/web/bindings/WC_createElement_bind.mjs +95 -0
  308. package/src/web/bindings/WC_createNamedSlot.mjs +29 -0
  309. package/src/web/bindings/WC_litRender_bind.mjs +26 -0
  310. package/src/web/bindings/WC_litStyleMap.mjs +14 -0
  311. package/src/web/common/CSS.mjs +35 -0
  312. package/src/web/common/E.mjs +126 -0
  313. package/src/web/common/NewStyleSheetAsync.mjs +21 -0
  314. package/src/web/common/NewStyleSheetSync.mjs +21 -0
  315. package/src/web/common/WC_TagName_type.mjs +10 -0
  316. package/src/web/common/WC_TagName_type.mts +36 -0
  317. package/src/web/signals/IsInViewPortSignal.mjs +140 -0
  318. package/src/web/signals/ObserverSignal.mjs +93 -0
  319. package/src/web/signals/WC_litRef.mjs +61 -0
  320. package/src/web/signals/WC_loopedSiblingsRef.mjs +100 -0
  321. package/tsconfig.json +44 -41
  322. package/index.mjs +0 -91
  323. package/src/bundler/FSInline.mjs +0 -67
  324. package/src/bundler/FSInlineAnalyzer.mjs +0 -228
  325. package/src/bundler/FSInlineBundled.mjs +0 -38
  326. package/src/bundler/adds/externals.mjs +0 -8
  327. package/src/class/ListDerived.mjs +0 -42
  328. package/src/common/Dev.mjs +0 -134
  329. package/src/common/DevBundled.mjs +0 -5
  330. package/src/common/lazie.mjs +0 -3
  331. package/src/types/IsListSignal.mjs +0 -6
  332. package/src/types/Runtime.mjs +0 -6
  333. package/src/types/VivthDevCodeBlockStringType.mjs +0 -6
  334. package/types/index.d.mts +0 -58
  335. package/types/src/bundler/CompileJS.d.mts +0 -119
  336. package/types/src/bundler/FSInline.d.mts +0 -50
  337. package/types/src/bundler/FSInlineAnalyzer.d.mts +0 -37
  338. package/types/src/bundler/FSInlineBundled.d.mts +0 -22
  339. package/types/src/bundler/adds/externals.d.mts +0 -1
  340. package/types/src/class/Console.d.mts +0 -71
  341. package/types/src/class/Derived.d.mts +0 -98
  342. package/types/src/class/Effect.d.mts +0 -216
  343. package/types/src/class/ListDerived.d.mts +0 -38
  344. package/types/src/class/Paths.d.mts +0 -69
  345. package/types/src/class/SafeExit.d.mts +0 -103
  346. package/types/src/class/WorkerMainThreadBundled.d.mts +0 -83
  347. package/types/src/common/Base64URLFromFile.d.mts +0 -16
  348. package/types/src/common/Dev.d.mts +0 -68
  349. package/types/src/common/DevBundled.d.mts +0 -3
  350. package/types/src/common/lazie.d.mts +0 -1
  351. package/types/src/doc/JSautoDOC.d.mts +0 -83
  352. package/types/src/function/GetRuntime.d.mts +0 -2
  353. package/types/src/function/TemplateLiteral.d.mts +0 -22
  354. package/types/src/function/TsToMjs.d.mts +0 -23
  355. package/types/src/types/IsListSignal.d.mts +0 -4
  356. package/types/src/types/ListArg.d.mts +0 -4
  357. package/types/src/types/Runtime.d.mts +0 -4
  358. package/types/src/types/VivthDevCodeBlockStringType.d.mts +0 -4
  359. /package/{types → generated/types}/src/bundler/adds/pluginVivthBundle.d.mts +0 -0
  360. /package/{types → generated/types}/src/class/WorkerResult.d.mts +0 -0
  361. /package/{types → generated/types}/src/common/EventNameSpace.d.mts +0 -0
  362. /package/{types → generated/types}/src/common/eventObjects.d.mts +0 -0
  363. /package/{types → generated/types}/src/common/keys.d.mts +0 -0
  364. /package/{types → generated/types}/src/doc/correctBeforeParse.d.mts +0 -0
  365. /package/{types → generated/types}/src/function/TrySync.d.mts +0 -0
  366. /package/{types → generated/types}/src/function/resolveErrorArray.d.mts +0 -0
  367. /package/{types/src/types → generated/types/src/typehints}/AnyButUndefined.d.mts +0 -0
  368. /package/{types/src/types → generated/types/src/typehints}/ExtnameType.d.mts +0 -0
  369. /package/{types/src/types → generated/types/src/typehints}/LitExpKeyType.d.mts +0 -0
  370. /package/{types/src/types → generated/types/src/typehints}/LitExpResultType.d.mts +0 -0
  371. /package/{types/src/types → generated/types/src/typehints}/MutationType.d.mts +0 -0
  372. /package/{types/src/types → generated/types/src/typehints}/QCBFIFOReturn.d.mts +0 -0
  373. /package/{types/src/types → generated/types/src/typehints}/QCBReturn.d.mts +0 -0
  374. /package/src/{types → typehints}/AnyButUndefined.mjs +0 -0
  375. /package/src/{types → typehints}/ExtnameType.mjs +0 -0
  376. /package/src/{types → typehints}/LitExpKeyType.mjs +0 -0
  377. /package/src/{types → typehints}/MutationType.mjs +0 -0
  378. /package/src/{types → typehints}/QCBFIFOReturn.mjs +0 -0
  379. /package/src/{types → typehints}/QCBReturn.mjs +0 -0
@@ -4,6 +4,8 @@ import { SafeExit } from './SafeExit.mjs';
4
4
  import { Paths } from './Paths.mjs';
5
5
  import { WorkerMainThread } from './WorkerMainThread.mjs';
6
6
  import { WorkerThread } from './WorkerThread.mjs';
7
+ import { EnvMode } from '../common/EnvMode.mjs';
8
+ import { Preferrence } from '../common/Preferrence.mjs';
7
9
 
8
10
  /**
9
11
  * @description
@@ -14,27 +16,16 @@ export class Setup {
14
16
  * @description
15
17
  * - proxy `SafeExit_instance` for Setup
16
18
  * @example
17
- * import { Setup, Console } from 'vivth';
19
+ * import { Setup } from 'vivth/node';
18
20
  *
19
- * new Setup.safeExit({
20
- * // eventNames are blank by default, you need to manually name them all;
21
- * // 'exit' will be omited, as it might cause async callbacks failed to execute;
22
- * eventNames: ['SIGINT', 'SIGTERM', ...eventNames],
23
- * terminator : () => process.exit(0),
24
- * listener : (eventName) => {
25
- * process.once(eventName, function () {
26
- * SafeExit.instance?.exiting.correction(true);
27
- * Console.log(`safe exit via "${eventName}"`);
28
- * });
29
- * }
30
- * });
21
+ * new Setup.safeExit('SIGINT', 'SIGTERM', ...eventNames);
31
22
  */
32
23
  static safeExit = SafeExit;
33
24
  /**
34
25
  * @description
35
26
  * - proxy `Paths_instance` for Setup;
36
27
  * @example
37
- * import { Setup } from 'vivth';
28
+ * import { Setup } from 'vivth/node';
38
29
  *
39
30
  * new Setup.paths({
40
31
  * root: location.origin, // browser example
@@ -45,7 +36,7 @@ export class Setup {
45
36
  * @description
46
37
  * - proxy `WorkerMainThread_instance` for Setup;
47
38
  * @example
48
- * import { Setup } from 'vivth';
39
+ * import { Setup } from 'vivth/node';
49
40
  * import { Worker } from 'node:worker_threads';
50
41
  *
51
42
  * Setup.workerMain({
@@ -64,7 +55,7 @@ export class Setup {
64
55
  * - correct `parentPort` reference when needed;
65
56
  * - export to create new reference to be use to create new WorkerThread instance;
66
57
  * @example
67
- * import { Setup } from 'vivth';
58
+ * import { Setup } from 'vivth/node';
68
59
  * import { parentPort } from 'node:worker_threads';
69
60
  *
70
61
  * export const MyWorkerThreadRef = Setup.workerThread({parentPort});
@@ -72,4 +63,25 @@ export class Setup {
72
63
  * // you need to call this method;
73
64
  */
74
65
  static workerThread = WorkerThread.setup;
66
+ /**
67
+ * @description
68
+ * - setup envMode into `developement`('default') or `production`;
69
+ * @example
70
+ * import { Setup } from 'vivth/node';
71
+ *
72
+ * Setup.enforceEnvMode('prod');
73
+ *
74
+ * // default behaviour, technically only need to be call for reactive functionality;
75
+ * Setup.enforceEnvMode('dev');
76
+ */
77
+ static enforceEnvMode = EnvMode.enforce;
78
+ /**
79
+ * @description
80
+ * - setup `vivth `preffered encoding;
81
+ * @example
82
+ * import { Setup } from 'vivth/node';
83
+ *
84
+ * Setup.preferrence({ encoding: 'utf-8' });
85
+ */
86
+ static preferrence = Preferrence.setup;
75
87
  }
@@ -6,6 +6,11 @@ import { TryAsync } from '../function/TryAsync.mjs';
6
6
  import { TrySync } from '../function/TrySync.mjs';
7
7
  import { Console } from './Console.mjs';
8
8
  import { Effect, mapOfEffects } from './Effect.mjs';
9
+ import { DataLog } from './DataLog.mjs';
10
+
11
+ /**
12
+ * @typedef { import('../typehints/VivthCleanup.mjs').VivthCleanup } VivthCleanup
13
+ */
9
14
 
10
15
  /**
11
16
  * @type {Set<Signal<any>>}
@@ -16,21 +21,33 @@ export const setOFSignals = new Set();
16
21
  * @description
17
22
  * - a class for creating effect to signals;
18
23
  * @template VALUE
24
+ * @implements {VivthCleanup}
19
25
  */
20
26
  export class Signal {
27
+ vivthCleanup = async () => {
28
+ this.remove.ref();
29
+ };
21
30
  /**
22
31
  * @description
23
32
  * - create a `Signal`;
24
33
  * @param {VALUE} value
34
+ * @param {(data:DataLog<VALUE>)=>void} [performanceChangesReport]
35
+ * - callback independent from effect;
36
+ * >- it will always be called when there's value change;
25
37
  * @example
26
- * import { Signal, Effect } from 'vivth';
38
+ * import { Signal, Effect } from 'vivth/neutral';
27
39
  *
28
40
  * const count = new Signal(0);
29
41
  */
30
- constructor(value) {
42
+ constructor(value, performanceChangesReport = undefined) {
31
43
  this.#value = value;
44
+ this.#performanceChangesReport = performanceChangesReport;
32
45
  setOFSignals.add(this);
33
46
  }
47
+ /**
48
+ * @type {ConstructorParameters<typeof Signal<VALUE>>[1]}
49
+ */
50
+ #performanceChangesReport;
34
51
  /**
35
52
  * @description
36
53
  * - subsrcibers reference of this instance;
@@ -48,9 +65,10 @@ export class Signal {
48
65
  * @description
49
66
  * - manually notify on non primitive value or value that have depths;
50
67
  * @param {(options:{signalInstance:Signal<VALUE>})=>Promise<void>} [callback]
51
- * @returns {void}
68
+ * @param {(error:Error|undefined)=>Promise<void>} [afterCompletion]
69
+ * @returns {Promise<void>}
52
70
  * @example
53
- * import { Signal } from 'vivth';
71
+ * import { Signal } from 'vivth/neutral';
54
72
  *
55
73
  * // for deep signal like array or object you can:
56
74
  * const arraySignal = new Signal([1,2]);
@@ -64,32 +82,41 @@ export class Signal {
64
82
  * signalInstance.value['d'] = 'testd';
65
83
  * });
66
84
  */
67
- notify: (callback = undefined) => {
85
+ notify: async (callback = undefined, afterCompletion = undefined) => {
86
+ if (this.#performanceChangesReport) {
87
+ this.#performanceChangesReport(new DataLog(this.#value));
88
+ }
68
89
  if (callback === undefined) {
69
- Signal.#notify(this);
90
+ await Signal.#notify(this, afterCompletion);
70
91
  return;
71
92
  }
72
- TryAsync(async () => {
93
+ const [, errorRunningCallback] = await TryAsync(async () => {
73
94
  await callback({ signalInstance: this });
74
- }).then(([, error]) => {
75
- if (error) {
76
- Console.error({ message: 'unable to run callback', callback, error });
77
- return;
78
- }
79
- Signal.#notify(this);
80
95
  });
96
+ if (errorRunningCallback) {
97
+ Console.error({ errorRunningCallback });
98
+ return;
99
+ }
100
+ await Signal.#notify(this, afterCompletion);
81
101
  },
82
102
  }));
83
103
  /**
84
104
  * @param {Signal<any>} signalInstance
105
+ * @param {(error:Error|undefined)=>void} [afterCompletion]
106
+ * @returns {Promise<void>}
85
107
  */
86
- static #notify = (signalInstance) => {
87
- const [, error] = TrySync(() => {
108
+ static #notify = async (
109
+ signalInstance,
110
+ afterCompletion = async (error) => {
111
+ if (error === undefined) {
112
+ return;
113
+ }
114
+ Console.error(error);
115
+ },
116
+ ) => {
117
+ const [, errorRunningWalkThrough] = TrySync(() => {
88
118
  WalkThrough.set(signalInstance.subscribers.setOf, (effectInstance) => {
89
- if (
90
- //
91
- !mapOfEffects.has(effectInstance)
92
- ) {
119
+ if (!mapOfEffects.has(effectInstance)) {
93
120
  effectInstance.options.removeSignal(signalInstance);
94
121
  return;
95
122
  }
@@ -99,10 +126,7 @@ export class Signal {
99
126
  effectInstance.run();
100
127
  });
101
128
  });
102
- if (error === undefined) {
103
- return;
104
- }
105
- Console.error(error);
129
+ afterCompletion(errorRunningWalkThrough);
106
130
  };
107
131
  /**
108
132
  * @description
@@ -147,7 +171,6 @@ export class Signal {
147
171
  setOFSignals.delete(this);
148
172
  },
149
173
  }));
150
-
151
174
  /**
152
175
  * @type {VALUE|undefined}
153
176
  */
@@ -169,7 +192,7 @@ export class Signal {
169
192
  * - value after change;
170
193
  * @returns {VALUE}
171
194
  * @example
172
- * import { Signal, Effect, Derived } from 'vivth';
195
+ * import { Signal, Effect, Derived } from 'vivth/neutral';
173
196
  *
174
197
  * const count = new Signal(0);
175
198
  * count.value; // not reactive
@@ -177,7 +200,7 @@ export class Signal {
177
200
  * new Effect(async ({ subscribe }) =>{
178
201
  * const countValue = subscribe(count).value; // reactive
179
202
  * })
180
- * const oneMoreThanCount = new Derived(async ({ subscribe }) =>{
203
+ * const oneMoreThanCount = new Derived(async function({ subscribe }){
181
204
  * return subscribe(count).value + 1; // reactive
182
205
  * })
183
206
  */
@@ -189,7 +212,7 @@ export class Signal {
189
212
  * - assign new value then automatically notify all subscribers;
190
213
  * @type {VALUE}
191
214
  * @example
192
- * import { Signal } from 'vivth';
215
+ * import { Signal } from 'vivth/neutral';
193
216
  *
194
217
  * const count = new Signal(0);
195
218
  * count.value++;
@@ -0,0 +1,130 @@
1
+ // @ts-check
2
+
3
+ import { ForInSync } from '../function/ForInSync.mjs';
4
+
5
+ /**
6
+ * @typedef {import('../typehints/VivthCleanup.mjs').VivthCleanup} VivthCleanup
7
+ */
8
+
9
+ /**
10
+ * @description
11
+ * - class helper for creating Collection of `Signals` for Object of Signals to be subscribed to(on `Effect`/`Derived`) collectively as signals;
12
+ * >- uses as `Facade` Pattern;
13
+ * @template {Record<string, import('./Signal.mjs').Signal<any>>} SIGNALS
14
+ * @implements {VivthCleanup}
15
+ */
16
+ export class SignalCollection {
17
+ vivthCleanup = async () => {
18
+ this.forInSignals((_key, signal) => {
19
+ signal.remove.ref();
20
+ });
21
+ };
22
+ /**
23
+ * @description
24
+ * - creates instance of `SignalCollection`, by referencing to named Signal;
25
+ * @param {SIGNALS} signalsObject
26
+ * @example
27
+ * import { Signal, Derived, SignalCollection } from 'vivth/neutral';
28
+ *
29
+ * const a = new Signal('a');
30
+ * const b = new Signal('b');
31
+ * const c = new Derived(async ({ subscribe }) => {
32
+ * return `${subscribe(b).value}_b`;
33
+ * });
34
+ *
35
+ * const f = new SignalCollection({ a, c });
36
+ */
37
+ constructor(signalsObject) {
38
+ this.#signals = signalsObject;
39
+ }
40
+ /**
41
+ * @type {SIGNALS}
42
+ */
43
+ #signals;
44
+ /**
45
+ * @description
46
+ * - accessor for signals, to be subscribed to;
47
+ * @param {import('./Effect.mjs').Effect["options"]["subscribe"]} [subscribe]
48
+ * @returns {SIGNALS}
49
+ * @example
50
+ * import { Signal, Derived, Effect, SignalCollection } from 'vivth/neutral';
51
+ *
52
+ * const a = new Signal('a');
53
+ * const b = new Signal('b');
54
+ * const c = new Derived(async ({ subscribe }) => {
55
+ * return `${subscribe(b).value}_b`;
56
+ * });
57
+ *
58
+ * const f = new SignalCollection({ a, c });
59
+ *
60
+ * new Effect(async ({ subscribe, isLastCalled }) => {
61
+ * const {
62
+ * a: { value: aa }, // aa is safely desctructured and auto subscribed
63
+ * c: { value: cc }, // cc is safely desctructured and auto subscribed
64
+ * } = f.signals(subscribe);
65
+ * if(!await isLastCalled(100)) {
66
+ * return; // impertaive debounce
67
+ * }
68
+ * });
69
+ *
70
+ * const d = new Derived(async function({ subscribe, isLastCalled }) {
71
+ * const {
72
+ * a: { value: aa }, // aa is safely desctructured and auto subscribed
73
+ * c: { value: cc }, // cc is safely desctructured and auto subscribed
74
+ * } = f.signals(subscribe);
75
+ * if(!await isLastCalled(100)) {
76
+ * return this.dontUpdate; // impertaive debounce
77
+ * }
78
+ * // return something;
79
+ * });
80
+ */
81
+ signals = (subscribe = undefined) => {
82
+ const signals = this.#signals;
83
+ if (subscribe) {
84
+ ForInSync(signals, (_key, signal) => {
85
+ subscribe(signal);
86
+ });
87
+ }
88
+ return signals;
89
+ };
90
+ /**
91
+ * @description
92
+ * - is looping synchronously;
93
+ * >- will not await any async block;
94
+ * - use for operation that doesn't need the value:
95
+ * >- unsub from the signal;
96
+ * @template {keyof SIGNALS} K
97
+ * @param {(key: K,
98
+ * signal: SIGNALS[K]
99
+ * )=>void} callback
100
+ * @returns {void}
101
+ * @example
102
+ * import { Signal, Derived, Effect, SignalCollection } from 'vivth/neutral';
103
+ *
104
+ * const a = new Signal('a');
105
+ * const b = new Signal('b');
106
+ * const c = new Derived(async ({ subscribe }) => {
107
+ * return `${subscribe(b).value}_b`;
108
+ * });
109
+ *
110
+ * const f = new SignalCollection({ a, c });
111
+ *
112
+ * f.forInSignals((key, signal)=>{
113
+ * // code
114
+ * })
115
+ */
116
+ forInSignals(callback) {
117
+ ForInSync(this.#signals, (key, signal) => {
118
+ callback(
119
+ /**
120
+ * @type {K}
121
+ */
122
+ (key),
123
+ /**
124
+ * @type {SIGNALS[K]}
125
+ */
126
+ (signal),
127
+ );
128
+ });
129
+ }
130
+ }
@@ -27,7 +27,7 @@ export class WalkThrough {
27
27
  * @param {(value:VAL)=>void} callback
28
28
  * @returns {void}
29
29
  * @example
30
- * import { WalkThrough } from 'vivth';
30
+ * import { WalkThrough } from 'vivth/neutral';
31
31
  *
32
32
  * WalkThrough.set(setOfSomething, (value) => {
33
33
  * // code
@@ -35,7 +35,7 @@ export class WalkThrough {
35
35
  */
36
36
  static set(setInstance, callback) {
37
37
  WalkThrough.#handler(setInstance.values(), callback);
38
- };
38
+ }
39
39
  /**
40
40
  * @description
41
41
  * - method helper to WalkThrough `Map`;
@@ -44,7 +44,7 @@ export class WalkThrough {
44
44
  * @param {(res:[key: KEY, value: VAL]) => void} callback
45
45
  * @returns {void}
46
46
  * @example
47
- * import { WalkThrough } from 'vivth';
47
+ * import { WalkThrough } from 'vivth/neutral';
48
48
  *
49
49
  * WalkThrough.map(mapOfSomething, ([key, value]) => {
50
50
  * // code
@@ -52,7 +52,7 @@ export class WalkThrough {
52
52
  */
53
53
  static map(mapInstance, callback) {
54
54
  WalkThrough.#handler(mapInstance.entries(), callback);
55
- };
55
+ }
56
56
  /**
57
57
  * @description
58
58
  * - method helper to WalkThrough `Array`;
@@ -61,7 +61,7 @@ export class WalkThrough {
61
61
  * @param {(res:[value: VAL, index: number]) => void} callback
62
62
  * @returns {void}
63
63
  * @example
64
- * import { WalkThrough } from 'vivth';
64
+ * import { WalkThrough } from 'vivth/neutral';
65
65
  *
66
66
  * WalkThrough.array(arrayOfSomething, ([value, index]) => {
67
67
  * // code
@@ -69,22 +69,5 @@ export class WalkThrough {
69
69
  */
70
70
  static array(arrayInstance, callback) {
71
71
  WalkThrough.#handler(arrayInstance.values(), callback);
72
- };
73
- /**
74
- * @description
75
- * - method helper to WalkThrough `Generator`;
76
- * @template T
77
- * @param {Generator<T, any, any>} generatorInstance
78
- * @param {(value: T) => void} callback
79
- * @returns {void}
80
- * @example
81
- * import { WalkThrough } from 'vivth';
82
- *
83
- * WalkThrough.generator(generatorOfSomething, (value) => {
84
- * // code
85
- * })
86
- */
87
- static generator(generatorInstance, callback) {
88
- WalkThrough.#handler(generatorInstance, callback);
89
- };
72
+ }
90
73
  }
@@ -1,34 +1,43 @@
1
1
  // @ts-check
2
2
 
3
- import { FSInline } from '../bundler/FSInline.mjs';
3
+ import { PathFSFile } from '../bundler/adds/PathFSFile.mjs';
4
+ import { FSasar } from '../bundler/FSasar.mjs';
4
5
  import { Base64URL } from '../common/Base64URL.mjs';
5
- import { closeWorkerThreadEventObject } from '../common/eventObjects.mjs';
6
+ import { Preferrence } from '../common/Preferrence.mjs';
6
7
  import { GetRuntime } from '../function/GetRuntime.mjs';
7
8
  import { Tries } from '../function/Tries.mjs';
8
9
  import { Console } from './Console.mjs';
9
10
  import { Derived } from './Derived.mjs';
10
11
  import { Effect } from './Effect.mjs';
11
- import { Paths } from './Paths.mjs';
12
- import { SafeExit } from './SafeExit.mjs';
13
12
  import { Signal } from './Signal.mjs';
13
+ import { closeWorkerThreadEventObject } from '../common/eventObjects.mjs';
14
14
 
15
15
  /**
16
- * @template POST
17
- * @typedef {import('./WorkerResult.mjs').WorkerResult<POST>} WorkerResult
18
- */
19
- /**
20
- * @template RECEIVE
21
- * @template POST
22
- * @typedef {import('./WorkerThread.mjs').WorkerThread<RECEIVE, POST>} WorkerThread
16
+ * it supposed to be able to call on browser too
17
+ * ```js
18
+ * import { SafeExit } from './SafeExit.mjs';
19
+ * ```
20
+ * need to add cleaner for SafeExit.instance?.addCallback
23
21
  */
22
+
24
23
  /**
25
- * @typedef {import('../common/lazie.mjs').unwrapLazy} unwrapLazy
24
+ * @typedef {import('../typehints/VivthCleanup.mjs').VivthCleanup} VivthCleanup
26
25
  */
27
26
 
28
27
  /**
29
28
  * @template {WorkerThread<any, any>} WT
29
+ * @implements {VivthCleanup}
30
30
  */
31
31
  export class WorkerMainThread {
32
+ /**
33
+ * @template POST
34
+ * @typedef {import('./WorkerResult.mjs').WorkerResult<POST>} WorkerResult
35
+ */
36
+ /**
37
+ * @template RECEIVE
38
+ * @template POST
39
+ * @typedef {import('./WorkerThread.mjs').WorkerThread<RECEIVE, POST>} WorkerThread
40
+ */
32
41
  /**
33
42
  * @type {boolean}
34
43
  */
@@ -39,9 +48,6 @@ export class WorkerMainThread {
39
48
  * @param {typeof WorkerMainThread["pathValidator"]} param0.pathValidator
40
49
  */
41
50
  static setup = ({ workerClass, pathValidator }) => {
42
- if (Paths.root === undefined) {
43
- return;
44
- }
45
51
  if (WorkerMainThread.#isRegistered) {
46
52
  Console.warn({ message: 'WorkerMainThread.setup, can only be called once' });
47
53
  return;
@@ -63,17 +69,8 @@ export class WorkerMainThread {
63
69
  type: 'module',
64
70
  });
65
71
  /**
66
- * @template {WorkerThread<any, any>} WT
67
- * @param {string} handler
68
- * @param {Omit<WorkerOptions|import('node:worker_threads').WorkerOptions, 'eval'|'type'>} [options]
69
- * @returns {WorkerMainThread<WT>}
70
- */
71
- static newVivthWorker(handler, options = {}) {
72
- return new WorkerMainThread(handler, options);
73
- }
74
- /**
75
- * @param {Parameters<typeof WorkerMainThread<WT>["newVivthWorker"]>[0]} handler
76
- * @param {Parameters<typeof WorkerMainThread<WT>["newVivthWorker"]>[1]} [options]
72
+ * @param {PathFSFile} handler
73
+ * @param {Omit<WorkerOptions|import('node:worker_threads').WorkerOptions, 'eval'|'type'>} options
77
74
  */
78
75
  constructor(handler, options = {}) {
79
76
  /**
@@ -83,7 +80,7 @@ export class WorkerMainThread {
83
80
  const listener = (ev) => {
84
81
  this.#proxyReceiver.value = ev;
85
82
  };
86
- WorkerMainThread.#workerFilehandler(handler, options, this, listener);
83
+ WorkerMainThread.#workerFilehandler(handler.path, options, this, listener);
87
84
  }
88
85
  /**
89
86
  * @type {import('./Signal.mjs').Signal<import('./WorkerResult.mjs').WorkerResult<WT["POST"]>|MessageEvent<import('./WorkerResult.mjs').WorkerResult<WT["POST"]>>>}
@@ -100,83 +97,62 @@ export class WorkerMainThread {
100
97
  * @returns {Promise<void>}
101
98
  */
102
99
  static async #workerFilehandler(handler, options, worker, listener) {
103
- let resolvedPath;
104
100
  WorkerMainThread.#options.eval = true;
105
- resolvedPath = (await FSInline.vivthFSInlineFile(handler)).toString('utf-8');
101
+ const resolvedPath =
102
+ (await FSasar.file(PathFSFile.vivthFile(handler)))?.toString(Preferrence.encoding) ?? '';
106
103
  const runtime = GetRuntime();
107
104
  const workerClass = WorkerMainThread.workerClass;
108
- if (
109
- //
110
- !workerClass
111
- ) {
112
- Console.error('invalid `Worker` inputed to `WorkerMainThread`;');
105
+ if (!workerClass) {
106
+ Console.error('invalid `Worker` inputed to `WorkerMainThread`;', { now: true });
113
107
  return;
114
108
  }
115
- const [, errorCreatingWorker] = await Tries({
109
+ const [[key], errorCreatingWorker] = await Tries({
116
110
  browser: async () => {
117
111
  if (runtime !== 'browser') {
118
- throw new Error('not a browser');
112
+ throw 'not a browser';
119
113
  }
120
- let worker_;
121
114
  const inlineURL = Base64URL(handler, 'application/javascript', btoa);
122
- worker_ = worker.#worker.value = new workerClass(
123
- inlineURL,
124
- // @ts-expect-error
125
- {
126
- ...options,
127
- ...WorkerMainThread.#options,
128
- }
129
- );
115
+ const worker_ = (worker.#worker.value = new workerClass(inlineURL, {
116
+ ...options,
117
+ ...WorkerMainThread.#options,
118
+ }));
130
119
  if ('onmessage' in worker_ === false) {
131
- throw new Error('not a browser');
120
+ throw 'not a browser';
132
121
  }
133
122
  worker_.onmessage = listener;
134
- if (SafeExit.instance) {
135
- SafeExit.instance.addCallback(async () => {
136
- worker_.onmessage = null;
137
- });
138
- }
123
+ // SafeExit.instance?.addCallback(async () => {
124
+ // worker_.onmessage = null;
125
+ // });
139
126
  },
140
127
  nonBrowser: async () => {
141
- const worker_ = (worker.#worker.value = new workerClass(
142
- resolvedPath,
143
- // @ts-expect-error
144
- {
145
- ...options,
146
- ...WorkerMainThread.#options,
147
- }
148
- ));
128
+ const worker_ = (worker.#worker.value = new workerClass(resolvedPath, {
129
+ ...options,
130
+ ...WorkerMainThread.#options,
131
+ }));
149
132
  if ('addEventListener' in worker_) {
150
133
  worker_.addEventListener('message', listener);
151
- if (SafeExit.instance) {
152
- SafeExit.instance.addCallback(async () => {
153
- worker_.removeEventListener('message', listener);
154
- });
155
- }
156
- } else if ('addListener' in worker_) {
134
+ // SafeExit.instance?.addCallback(async () => {
135
+ // worker_.removeEventListener('message', listener);
136
+ // });
137
+ return;
138
+ }
139
+ if ('addListener' in worker_) {
157
140
  worker_.addListener('message', listener);
158
- if (SafeExit.instance) {
159
- SafeExit.instance.addCallback(async () => {
160
- worker_.removeListener('message', listener);
161
- });
162
- }
163
- } else {
164
- throw new Error('not a standard non browser');
141
+ // SafeExit.instance?.addCallback(async () => {
142
+ // worker_.removeListener('message', listener);
143
+ // });
144
+ return;
165
145
  }
146
+ throw 'not a standard non browser';
166
147
  },
167
148
  });
168
- if (errorCreatingWorker) {
169
- Console.error(errorCreatingWorker);
149
+ if (!key) {
150
+ Console.error({ errorCreatingWorker }, { now: true });
170
151
  return;
171
152
  }
172
- if (SafeExit.instance) {
173
- SafeExit.instance.addCallback(async () => {
174
- if (worker.#worker.value) {
175
- worker.#worker.value.postMessage(closeWorkerThreadEventObject, []);
176
- }
177
- await worker.terminate();
178
- });
179
- }
153
+ // SafeExit.instance?.addCallback(async () => {
154
+ // worker.terminate();
155
+ // });
180
156
  }
181
157
  /**
182
158
  * lazyly generated because node version need to await
@@ -197,9 +173,10 @@ export class WorkerMainThread {
197
173
  worker.postMessage(postData, []);
198
174
  });
199
175
  /**
200
- * @return {void}
176
+ * @return {Promise<void>}
201
177
  */
202
- terminate = () => {
178
+ vivthCleanup = async () => {
179
+ this.postMessage(closeWorkerThreadEventObject);
203
180
  /**
204
181
  * this is more for browser, as most of this are automatically cleaned with `SafeExit`;
205
182
  */