vivth 1.4.10 → 1.5.1

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 +28 -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 +78 -42
  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} +56 -77
  214. package/src/class/WorkerMainThread.mjs +98 -94
  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 -142
  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
@@ -0,0 +1,487 @@
1
+ // @ts-check
2
+
3
+ import { extname } from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
5
+
6
+ import { watch } from 'chokidar';
7
+
8
+ import { EventSignal } from '../class/EventSignal.mjs';
9
+ import { Paths } from '../class/Paths.mjs';
10
+ import { TryAsync } from '../function/TryAsync.mjs';
11
+ import { SafeExit } from '../class/SafeExit.mjs';
12
+ import { QChannel } from '../class/QChannel.mjs';
13
+ import { LazyFactory } from '../function/LazyFactory.mjs';
14
+ import { Console } from '../class/Console.mjs';
15
+ import { ForOfSync } from '../function/ForOfSync.mjs';
16
+ import { TsToMjs } from '../function/TsToMjs.mjs';
17
+ import { Preferrence } from '../common/Preferrence.mjs';
18
+ import { ObjectRegistrar } from '../function/ObjectRegistrar.mjs';
19
+ import { Signal } from '../class/Signal.mjs';
20
+ import { Effect } from '../class/Effect.mjs';
21
+ import { Derived } from '../class/Derived.mjs';
22
+ import { TracePath } from '../common/TracePath.mjs';
23
+ import { SafeImport } from '../function/SafeImport.mjs';
24
+ import { IsInstanceOf } from '../function/IsInstanceOf.mjs';
25
+ import { IsTypeOf } from '../function/IsTypeOf.mjs';
26
+ /**
27
+ * @typedef {import('../bundler/FileSelfMapper.mjs').VivthCleanup} VivthCleanup
28
+ */
29
+ /**
30
+ * @description
31
+ * - alternative to `neinth`;
32
+ * @template {any} EXPORT
33
+ * @implements {VivthCleanup}
34
+ */
35
+ export class VivthyNeinth {
36
+ /**
37
+ * @type {QChannel<string>}
38
+ */
39
+ static #q = LazyFactory(() => new QChannel('VivthyNeinth singleton Q'));
40
+ static #hasStarted = false;
41
+ /**
42
+ * @type {Map<string, VivthyNeinth<any>>}
43
+ */
44
+ static #mappedInstance = new Map();
45
+ /**
46
+ * @type {Parameters<typeof VivthyNeinth["start"]>[0]["assemblyScriptOptions"]}
47
+ */
48
+ static #assemblyScriptOptions;
49
+ /**
50
+ * @description
51
+ * - DO NOT CALL THIS METHOD INSIDE
52
+ * @param {Object} options
53
+ * @param {string} options.dirPath
54
+ * @param {import('../typehints/AutoDocASOptions.mjs').AutoDocASOptions} [options.assemblyScriptOptions]
55
+ * @returns {ReturnType<typeof TryAsync<void>>}
56
+ */
57
+ static start = async ({ dirPath, assemblyScriptOptions = {} }) => {
58
+ return await TryAsync(async () => {
59
+ if (VivthyNeinth.#hasStarted) {
60
+ Console.error(
61
+ {
62
+ 'VivthyNeinth.start': 'is a singleton method',
63
+ message: 'calling singleton method will not trigger rerun',
64
+ },
65
+ { now: true },
66
+ );
67
+ return;
68
+ }
69
+ VivthyNeinth.#hasStarted = true;
70
+ VivthyNeinth.#assemblyScriptOptions = assemblyScriptOptions;
71
+ dirPath = Paths.diskAbsolute(dirPath);
72
+ const watcher = watch(dirPath);
73
+ Console.log(`'VivthyNeinth.start' begining to watch:'${dirPath}'`, { now: true });
74
+ watcher.addListener('all', VivthyNeinth.#watcherListener);
75
+ const vivthCleanup = async () => {
76
+ SafeExit.instance?.removeCallback(vivthCleanup);
77
+ watcher.removeAllListeners();
78
+ await watcher.close();
79
+ };
80
+ SafeExit.instance?.addCallback(vivthCleanup);
81
+ });
82
+ };
83
+
84
+ /**
85
+ * @param {import('chokidar/handler.js').EventName} eventName
86
+ * @param {string} path
87
+ * @param {import('node:fs').Stats} [stats]
88
+ */
89
+ static #watcherListenerQ = async (eventName, path, stats) => {
90
+ switch (eventName) {
91
+ case 'add':
92
+ case 'change':
93
+ if (!stats || !stats.isFile()) {
94
+ return;
95
+ }
96
+ await VivthyNeinth.#addListener(eventName, path, stats);
97
+ break;
98
+ default:
99
+ await VivthyNeinth.#negativeListener(eventName, path, stats);
100
+ break;
101
+ }
102
+ };
103
+ /**
104
+ * @param {import('chokidar/handler.js').EventName} eventName
105
+ * @param {string} path
106
+ * @param {import('node:fs').Stats} [stats]
107
+ * @returns {void}
108
+ */
109
+ static #watcherListener = (eventName, path, stats) => {
110
+ path = Paths.diskAbsolute(path);
111
+ VivthyNeinth.#q.callback(path, async () => {
112
+ await VivthyNeinth.#watcherListenerQ(eventName, path, stats);
113
+ });
114
+ };
115
+
116
+ /**
117
+ * @param {'add'|'change'} _eventName
118
+ * @param {string} path
119
+ * @param {import('node:fs').Stats} [_stats]
120
+ * @returns {Promise<void>}
121
+ */
122
+ static #addListener = async (_eventName, path, _stats) => {
123
+ const fileExt = extname(path);
124
+ switch (fileExt) {
125
+ case '.ts':
126
+ case '.mts':
127
+ return await TsToMjs(path, {
128
+ encoding: Preferrence.encoding,
129
+ assemblyScriptOptions: VivthyNeinth.#assemblyScriptOptions,
130
+ });
131
+ case '.mjs':
132
+ break;
133
+ default:
134
+ return;
135
+ }
136
+ /**
137
+ * @type {ReturnType<typeof TryAsync<any|VivthyNeinth<any>>>}
138
+ */
139
+ const res = TryAsync(async () => {
140
+ return (
141
+ /**
142
+ * - first check with the `baseNameNoExt` export;
143
+ * - `default` for fallback;
144
+ */
145
+ // @ts-expect-error
146
+ (await SafeImport(path))[0].default
147
+ );
148
+ });
149
+ if (!res) {
150
+ return;
151
+ }
152
+ const [newModule, errorSafeImport] = await res;
153
+ await VivthyNeinth.#ifPrevInstanceExistThenCleanup_(path);
154
+ if (IsInstanceOf(newModule, VivthyNeinth)) {
155
+ await newModule.#register();
156
+ return;
157
+ }
158
+ if (errorSafeImport) {
159
+ Console.error({ errorSafeImport }, { now: true });
160
+ return;
161
+ }
162
+ };
163
+
164
+ /**
165
+ * @param {string} _eventName
166
+ * @param {string} path
167
+ * @param {import('node:fs').Stats} [_stats]
168
+ * @returns {Promise<void>}
169
+ */
170
+ static #negativeListener = async (_eventName, path, _stats) => {
171
+ await VivthyNeinth.#ifPrevInstanceExistThenCleanup_(path);
172
+ const { dispatcher } = await EventSignal.get(path);
173
+ dispatcher.value = undefined;
174
+ };
175
+
176
+ /**
177
+ * @param {Object} options
178
+ * @param {(this:VivthyNeinth<EXPORT>, arg0:VivthyNeinth<EXPORT>)=>Promise<EXPORT>} options.export
179
+ * @param {boolean} [options.I__the_developer__have_provided_onFileMutations_cleanupCallbacks_for_every_long_running_object_in_this_file]
180
+ */
181
+ constructor({
182
+ export: exportCallback,
183
+ I__the_developer__have_provided_onFileMutations_cleanupCallbacks_for_every_long_running_object_in_this_file = false,
184
+ }) {
185
+ if (new.target !== VivthyNeinth) {
186
+ throw new Error('This class cannot be extended');
187
+ }
188
+ const [letter, path] = (
189
+ TracePath((path) => {
190
+ return !path.includes(Paths.normalize(fileURLToPath(import.meta.url)));
191
+ }) ?? ''
192
+ ).split(':');
193
+ this.path = [letter, path].join(':');
194
+ this.#allowToRegister =
195
+ I__the_developer__have_provided_onFileMutations_cleanupCallbacks_for_every_long_running_object_in_this_file;
196
+ this.#export = exportCallback;
197
+ }
198
+
199
+ #allowToRegister;
200
+
201
+ /**
202
+ * @type {ConstructorParameters<typeof VivthyNeinth<EXPORT>>[0]["export"]}
203
+ */
204
+ #export;
205
+
206
+ /**
207
+ * @type { string }
208
+ */
209
+ path;
210
+ /**
211
+ * @returns {Promise<EventSignal<EXPORT|undefined>>}
212
+ */
213
+ #import = async () => {
214
+ const path = this.path;
215
+ return await EventSignal.get(path);
216
+ };
217
+
218
+ /**
219
+ * @description
220
+ * - use this to update export value;
221
+ * - `WARNING`: this instance setter are accesible from outside, including importer;
222
+ * >- usefull for treating `VivthyNeinth` instance as global signal;
223
+ * >- you can accidentally ;
224
+ * @param {EXPORT|undefined} newExportValue
225
+ * @returns {void}
226
+ * @example
227
+ */
228
+ set exportedValue(newExportValue) {
229
+ this.#import().then(({ dispatcher }) => {
230
+ dispatcher.value = newExportValue;
231
+ });
232
+ }
233
+
234
+ /**
235
+ * @description
236
+ * - use this to listen to dependency changes(inside `Effect`);
237
+ * @returns {Promise<Derived<EXPORT|undefined>>}
238
+ * @example
239
+ */
240
+ get listener() {
241
+ return this.#import().then(({ listener }) => {
242
+ return listener;
243
+ });
244
+ }
245
+
246
+ /**
247
+ * @param {string} path
248
+ * @returns {Promise<void>}
249
+ */
250
+ static #ifPrevInstanceExistThenCleanup_ = async (path) => {
251
+ const prev = VivthyNeinth.#mappedInstance.get(path);
252
+ if (!prev) {
253
+ return;
254
+ }
255
+ await prev.vivthCleanup();
256
+ };
257
+
258
+ /**
259
+ * @description
260
+ * - generate autoCleaned `Signal` instance;
261
+ * @example
262
+ * /// on VivthyNeinth callback scope
263
+ * const { newSignal } = this;
264
+ * const numberSignal = newSignal(1);
265
+ * ///
266
+ */
267
+ newSignal = ObjectRegistrar(
268
+ /**
269
+ * @template {any} A
270
+ * @param {A} obj
271
+ * @returns {Signal<A>}
272
+ */
273
+ (obj) => {
274
+ const signalInstance = new Signal(obj);
275
+ this.onMutate(async () => {
276
+ signalInstance.remove.ref();
277
+ });
278
+ return signalInstance;
279
+ },
280
+ );
281
+
282
+ /**
283
+ * @description
284
+ * - generate autoCleaned `Effect` instance;
285
+ * @example
286
+ * /// on VivthyNeinth callback scope
287
+ * const { newEffect } = this;
288
+ * const numberSignal = newSignal(1);
289
+ * const effer = newEffect(async({subscribe})=>{
290
+ * const numberSignalValue = subscribe(numberSignal).value;
291
+ * });
292
+ * ///
293
+ */
294
+ newEffect = ObjectRegistrar(
295
+ /**
296
+ * @param {ConstructorParameters<typeof Effect>[0]} callback
297
+ * @returns {Effect}
298
+ */
299
+ (callback) => {
300
+ const effectInstance = new Effect(callback);
301
+ this.onMutate(async () => {
302
+ effectInstance.options.removeEffect();
303
+ });
304
+ return effectInstance;
305
+ },
306
+ );
307
+
308
+ /**
309
+ * @description
310
+ * - generate autoCleaned `Derived` instance;
311
+ * @example
312
+ * /// on VivthyNeinth callback scope
313
+ * const { newDerived } = this;
314
+ * const effer = newDerived(async({subscribe})=>{
315
+ * const numberSignalValue = subscribe(numberSignal).value;
316
+ * return numberSignalValue * 2;
317
+ * });
318
+ * ///
319
+ */
320
+ newDerived = ObjectRegistrar(
321
+ /**
322
+ * @template {ConstructorParameters<typeof Derived>[0]} CB
323
+ * @param {CB} callback
324
+ * @returns {Derived<ReturnType<CB|undefined>>}
325
+ */
326
+ (callback) => {
327
+ const derivedInstance = new Derived(callback);
328
+ this.onMutate(async () => {
329
+ derivedInstance.remove.ref();
330
+ });
331
+ return derivedInstance;
332
+ },
333
+ );
334
+
335
+ /**
336
+ * @description
337
+ * @type {Set<()=>Promise<void>>}
338
+ * @example
339
+ * import { watch } from "chokidar";
340
+ *
341
+ * /// on VivthyNeinth arg callback scope
342
+ * const { onCleanups } = this;
343
+ * const watcher = watch('/src/');
344
+ * watcher.addListener('all', (...args)=>{
345
+ * // listener code;
346
+ * });
347
+ * onCleanups.add(async()=>{
348
+ * watcher.removeAllListeners();
349
+ * watcher.close();
350
+ * })
351
+ * ///
352
+ */
353
+ #onCleanups = new Set();
354
+
355
+ /**
356
+ * @description
357
+ * - manually registering object celeanup;
358
+ * @param {()=>Promise<void>} callback
359
+ * @returns {void}
360
+ * @example
361
+ * import { watch } from 'chokidar';
362
+ *
363
+ * /// on VivthyNeinth export callback scope
364
+ * const watcher = watch('D://my/dir/path');
365
+ * // preferably to declare the cleanup right bellow it's object creation;
366
+ * // set 'I__the_developer__have_provided_onFileMutations_cleanupCallbacks_for_every_long_running_object_in_this_file' to false if you might want to save before full cleanup is written;
367
+ * this.onMutate(async () => {
368
+ * watcher.removeAllListeners();
369
+ * watcher.close();
370
+ * });
371
+ *
372
+ * watcher.addListener('all', (eventName, path, stats) => {
373
+ * //
374
+ * })
375
+ * ///
376
+ * // alternative: use vivth `modules` that returns object that implements `VivthCleanup`;
377
+ * // and call uses `registerObjectWithAutoCleanup`;
378
+ */
379
+ onMutate = (callback) => {
380
+ this.#onCleanups.add(callback);
381
+ this.onExit(callback);
382
+ };
383
+
384
+ /**
385
+ * @description
386
+ * - process SafeExit;
387
+ * @param {()=>Promise<void>} callback
388
+ * @returns {void}
389
+ * @example
390
+ * import { Console } from 'vivth/neutral';
391
+ *
392
+ * /// on VivthyNeinth export callback scope
393
+ * this.onExit(async()=>{
394
+ * Console.log('main process ends');
395
+ * })
396
+ * ///
397
+ */
398
+ onExit = (callback) => {
399
+ const handler = SafeExit.instance?.addCallback(callback);
400
+ if (!handler) {
401
+ return;
402
+ }
403
+ this.#onCleanups.add(
404
+ // @ts-expect-error
405
+ handler.removeCallback,
406
+ );
407
+ };
408
+
409
+ /**
410
+ * @description
411
+ * - register premade cleanup `vivthCleanup` method to `VivthyNeinth` lifecycle;
412
+ * @template {Object} OBJ
413
+ * @param { OBJ & VivthCleanup } obj
414
+ * @returns {OBJ}
415
+ * @example
416
+ * import { EsWatcher } from "vivth/node";
417
+ *
418
+ * /// on VivthyNeinth export callback scope
419
+ * const esWatcherInstance = this.registerObjectWithAutoCleanup(new EsWatcher({
420
+ * ...buildOptions,
421
+ * }));
422
+ * ///
423
+ */
424
+ registerObjectWithAutoCleanup(obj) {
425
+ if ('vivthCleanup' in obj && IsTypeOf(obj.vivthCleanup, 'function')) {
426
+ /**
427
+ * - this is not `VivthyNeinth` instance
428
+ */
429
+ this.onMutate(obj.vivthCleanup);
430
+ } else {
431
+ throw {
432
+ VivthyNeinthPath: this.path,
433
+ obj,
434
+ registerObjectCleanupCall: 'obj has no `vivthCleanup`',
435
+ };
436
+ }
437
+ return obj;
438
+ }
439
+
440
+ /**
441
+ * @returns {Promise<void>}
442
+ */
443
+ vivthCleanup = async () => {
444
+ await Promise.all(
445
+ ForOfSync(this.#onCleanups, async (cb) => {
446
+ this.#onCleanups.delete(cb);
447
+ await cb();
448
+ })[0],
449
+ );
450
+ };
451
+
452
+ /**
453
+ * @returns {boolean}
454
+ */
455
+ #checkIfAllowedToBeRegistered = () => {
456
+ if (this.#allowToRegister) {
457
+ return true;
458
+ }
459
+ Console.warn(
460
+ {
461
+ VivthyNeinthInstancePath: this.path,
462
+ I__the_developer__have_provided_onFileMutations_cleanupCallbacks_for_every_long_running_object_in_this_file:
463
+ this.#allowToRegister,
464
+ message: [
465
+ 'Developer must provide cleanup callbacks for long-running objects on file mutations',
466
+ 'then set `options.exportCallback.I__the_developer__have_provided_onFileMutations_cleanupCallbacks_for_every_long_running_object_in_this_file` to `true`',
467
+ ],
468
+ },
469
+ { now: true },
470
+ );
471
+ return false;
472
+ };
473
+ /**
474
+ * @returns {Promise<void>}
475
+ */
476
+ #register = async () => {
477
+ if (!this.#checkIfAllowedToBeRegistered()) {
478
+ return;
479
+ }
480
+ VivthyNeinth.#mappedInstance.set(this.path, this);
481
+ const [exportValue, { dispatcher }] = await Promise.all([
482
+ this.#export.call(this, this),
483
+ this.#import(),
484
+ ]);
485
+ dispatcher.value = exportValue;
486
+ };
487
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @preserve
3
+ * @description
4
+ * - extract unique string from ArrayString[];
5
+ * - Takes an array/tuple type and returns a unique UNION of its elements.
6
+ * ```ts
7
+ * const a = ['hi', 'there'] as const;
8
+ * const check = (aa:ArrayToKeys<typeof a>) => {};
9
+ * ```
10
+ * ```js
11
+ * const a = /** [at]type {const} *[blank]/ (['hi', 'there']);
12
+ * /** [at]param {ArrayToKeys<typeof a>} aa *[blank]/
13
+ * const check = (aa) => {};
14
+ * ```
15
+ * @template {readonly unknown[]} T
16
+ * @typedef {import('./ArrayToKeys.mts').ArrayToKeys<T>} ArrayToKeys
17
+ */
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @description
3
+ * - Internal utility to deduplicate a tuple
4
+ */
5
+ export type Deduplicate<
6
+ T extends readonly unknown[],
7
+ ACC extends readonly unknown[] = [],
8
+ > = T extends readonly [infer Head, ...infer Tail]
9
+ ? Head extends ACC[number]
10
+ ? Deduplicate<Tail, ACC>
11
+ : Deduplicate<Tail, readonly [...ACC, Head]>
12
+ : ACC;
13
+
14
+ /**
15
+ * @preserve
16
+ * @description
17
+ * - extract unique string from ArrayString[];
18
+ * - Takes an array/tuple type and returns a unique UNION of its elements.
19
+ * ```ts
20
+ * const a = ['hi', 'there'] as const;
21
+ * const check = (aa:ArrayToKeys<typeof a>) => {};
22
+ * ```
23
+ * ```js
24
+ * const a = /** [at]type {const} *[blank]/ (['hi', 'there']);
25
+ * /** [at]param {ArrayToKeys<typeof a>} aa *[blank]/
26
+ * const check = (aa) => {};
27
+ * ```
28
+ * @template {readonly unknown[]} T
29
+ * @[blank]typedef {import('./ArrayToKeys.mts').ArrayToKeys<T>} ArrayToKeys
30
+ */
31
+ export type ArrayToKeys<T extends readonly unknown[]> = Deduplicate<T>[number];
@@ -0,0 +1,7 @@
1
+ // @ts-check
2
+
3
+ /**
4
+ * - `AssemblyScript` `exports` type helper;
5
+ * @template {Record<string, unknown>} RESULTTYPE
6
+ * @typedef {Awaited<ReturnType<typeof import('@assemblyscript/loader').instantiate<RESULTTYPE>>>} AssemblyScriptExportsType
7
+ */
@@ -0,0 +1,7 @@
1
+ // @ts-check
2
+
3
+ /**
4
+ * - instantiate type helper;
5
+ * @template {Record<string, unknown>} RESULTTYPE
6
+ * @typedef {typeof import('@assemblyscript/loader').instantiate<RESULTTYPE>} AssemblyScriptLoaderInstantiate
7
+ */
@@ -0,0 +1,14 @@
1
+ // @ts-check
2
+
3
+ /**
4
+ * @typedef {Object} AutoDocASOptions
5
+ * @property {boolean} [generateFSasarImporter]
6
+ * - `true`: will generate `${fileName}.mjs` that uses `FSasar`;
7
+ * >- upon compiling with `vivth` it should be embeded as inline buffer;
8
+ * - `false`: does nothing;
9
+ * - on both cases, the `${fileName}.js` can be used for both browser or nodeJS compatibel runtime;
10
+ * @property {string[]} [ASArgv]
11
+ * - `argv` for assembley script compiler (`asc.main`), excluding `inputPath`, `--outputFile`, `--bindings`;
12
+ * >- `--bindings`: strictly using `esm`;
13
+ * @property {Parameters<typeof import('../bundler/CompileAS.mjs').CompileAS>[1]} [ASAPIOptions]
14
+ */
@@ -0,0 +1,11 @@
1
+ // @ts-check
2
+
3
+ /**
4
+ * @template {object} OBJ
5
+ * @typedef { {this: OBJ} & {
6
+ * [K in keyof OBJ]:
7
+ * OBJ[K] extends (...args: any[]) => any
8
+ * ? (...args: Parameters<OBJ[K]>) => ChainableType<OBJ>
9
+ * : OBJ[K]
10
+ * }} ChainableType
11
+ */
@@ -0,0 +1,10 @@
1
+ // @ts-check
2
+
3
+ /**
4
+ * @description Creates a constructor structure with custom static members added.
5
+ * @template {new (...args: any[]) => HTMLElement} BASE
6
+ * @template {readonly string[]} ATTRS
7
+ * @typedef {BASE & {
8
+ * readonly observedAttributes: ATTRS;
9
+ * }} ComponentDecorator_Constructor
10
+ */
@@ -0,0 +1,6 @@
1
+ // @ts-check
2
+
3
+ /**
4
+ * @typedef {Object} ConsoleAdditionalSettingType
5
+ * @property {boolean} [now]
6
+ */
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @preserve
3
+ * @description
4
+ * - type helper to create decorator;
5
+ * >- matches argument with host method;
6
+ * @template {(...args: any[]) => any} OriginalFn - The original method type;
7
+ * @template {readonly unknown[]} DecoratorArgs - Tuple of custom decorator arguments;
8
+ * @typedef {import('./Decorator.mts').Decorator<OriginalFn, DecoratorArgs>} Decorator
9
+ */
@@ -0,0 +1,31 @@
1
+ import type { ThisParameterOfOrUnknown } from './DecoratorMonkeyPatch.mts';
2
+
3
+ /**
4
+ * @preserve
5
+ * @description
6
+ * - type helper to create decorator;
7
+ * >- matches argument with host method;
8
+ * @template {(...args: any[]) => any} OriginalFn - The original method type;
9
+ * @template {readonly unknown[]} DecoratorArgs - Tuple of custom decorator arguments;
10
+ * @[blank]typedef {import('./Decorator.mts').Decorator<OriginalFn, DecoratorArgs>} Decorator
11
+ */
12
+ export type Decorator<
13
+ OriginalFn extends (this: any, ...args: any[]) => any,
14
+ DecoratorArgs extends readonly unknown[] = [],
15
+ > = DecoratorArgs['length'] extends 0
16
+ ? // --- CASE 1: NO ARGS ---
17
+ (
18
+ target: OriginalFn,
19
+ context: ClassMethodDecoratorContext<ThisParameterOfOrUnknown<OriginalFn>, OriginalFn>,
20
+ ) =>
21
+ | ((this: ThisParameterOfOrUnknown<OriginalFn>, ...args: Parameters<OriginalFn>) => any)
22
+ | void
23
+ : // --- CASE 2: WITH ARGS ---
24
+ (
25
+ ...args: DecoratorArgs
26
+ ) => (
27
+ target: OriginalFn,
28
+ context: ClassMethodDecoratorContext<ThisParameterOfOrUnknown<OriginalFn>, OriginalFn>,
29
+ ) =>
30
+ | ((this: ThisParameterOfOrUnknown<OriginalFn>, ...args: Parameters<OriginalFn>) => any)
31
+ | void;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @preserve
3
+ * @description
4
+ * - type helper to create decorator for monkeypatching class/instance method;
5
+ * >- matches argument with host method;
6
+ * >- matches return type with host method;
7
+ * @template {(...args: any[]) => any} OriginalFn - The original method type;
8
+ * @template {readonly unknown[]} DecoratorArgs - Tuple of custom decorator arguments;
9
+ * @typedef {import('./DecoratorMonkeyPatch.mts').DecoratorMonkeyPatch<OriginalFn, DecoratorArgs>} DecoratorMonkeyPatch
10
+ */
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Utility to extract the 'this' context from a function, defaulting to unknown.
3
+ */
4
+ export type ThisParameterOfOrUnknown<T> = T extends (this: infer U, ...args: any[]) => any
5
+ ? U
6
+ : unknown;
7
+
8
+ /**
9
+ * @preserve
10
+ * @description
11
+ * - type helper to create decorator for monkeypatching class/instance method;
12
+ * >- matches argument with host method;
13
+ * >- matches return type with host method;
14
+ * @template {(...args: any[]) => any} OriginalFn - The original method type;
15
+ * @template {readonly unknown[]} DecoratorArgs - Tuple of custom decorator arguments;
16
+ * @[blank]typedef {import('./DecoratorMonkeyPatch.mts').DecoratorMonkeyPatch<OriginalFn, DecoratorArgs>} DecoratorMonkeyPatch
17
+ */
18
+ export type DecoratorMonkeyPatch<
19
+ OriginalFn extends (this: any, ...args: any[]) => any,
20
+ DecoratorArgs extends readonly unknown[] = [],
21
+ > = DecoratorArgs['length'] extends 0
22
+ ? // --- CASE 1: NO ARGS ---
23
+ (
24
+ target: OriginalFn,
25
+ context: ClassMethodDecoratorContext<ThisParameterOfOrUnknown<OriginalFn>, OriginalFn>,
26
+ ) =>
27
+ | ((
28
+ this: ThisParameterOfOrUnknown<OriginalFn>,
29
+ ...args: Parameters<OriginalFn>
30
+ ) => ReturnType<OriginalFn>)
31
+ | void
32
+ : // --- CASE 2: WITH ARGS ---
33
+ (
34
+ ...args: DecoratorArgs
35
+ ) => (
36
+ target: OriginalFn,
37
+ context: ClassMethodDecoratorContext<ThisParameterOfOrUnknown<OriginalFn>, OriginalFn>,
38
+ ) =>
39
+ | ((
40
+ this: ThisParameterOfOrUnknown<OriginalFn>,
41
+ ...args: Parameters<OriginalFn>
42
+ ) => ReturnType<OriginalFn>)
43
+ | void;