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.
- package/README.md +6060 -2037
- package/README.src.md +22 -14
- package/bun.lock +154 -194
- package/dev/auto/.src.ignore +28 -0
- package/dev/auto-doc.mjs +137 -0
- package/generated/types/generated/vivth/exports/all.d.mts +145 -0
- package/generated/types/generated/vivth/exports/neutral.d.mts +105 -0
- package/generated/types/generated/vivth/exports/node.d.mts +40 -0
- package/generated/types/src/bundler/CompileAS.d.mts +30 -0
- package/generated/types/src/bundler/CompileJS.d.mts +109 -0
- package/{types → generated/types}/src/bundler/CreateESPlugin.d.mts +1 -1
- package/{types → generated/types}/src/bundler/EsBundler.d.mts +9 -7
- package/generated/types/src/bundler/FSAnalyzer.d.mts +58 -0
- package/generated/types/src/bundler/FSasar.bundled.d.mts +28 -0
- package/generated/types/src/bundler/FSasar.d.mts +51 -0
- package/generated/types/src/bundler/FileSelfMapper.d.mts +137 -0
- package/generated/types/src/bundler/JSDirMapper.d.mts +128 -0
- package/generated/types/src/bundler/RunWatchThenCompileJSOnSafeExit.d.mts +63 -0
- package/generated/types/src/bundler/adds/BrowserExternals.d.mts +21 -0
- package/generated/types/src/bundler/adds/CreateTransform.d.mts +26 -0
- package/generated/types/src/bundler/adds/LastEditedUnix.d.mts +5 -0
- package/generated/types/src/bundler/adds/NodeModuleList.d.mts +15 -0
- package/generated/types/src/bundler/adds/PathFSBundles.bundled.d.mts +25 -0
- package/generated/types/src/bundler/adds/PathFSBundles.d.mts +48 -0
- package/generated/types/src/bundler/adds/PathFSDir.bundled.d.mts +30 -0
- package/generated/types/src/bundler/adds/PathFSDir.d.mts +48 -0
- package/generated/types/src/bundler/adds/PathFSFile.bundled.d.mts +25 -0
- package/generated/types/src/bundler/adds/PathFSFile.d.mts +40 -0
- package/{types → generated/types}/src/bundler/adds/ToBundledJSPlugin.d.mts +6 -6
- package/generated/types/src/bundler/adds/autoExternalize.d.mts +2 -0
- package/generated/types/src/bundler/adds/emptyBufferValue.d.mts +1 -0
- package/generated/types/src/bundler/adds/isModuleTheBundledVersion.d.mts +1 -0
- package/generated/types/src/bundler/adds/onEndEsBuildErrorLogger.d.mts +1 -0
- package/generated/types/src/bundler/adds/resolveJSDependencyPath.d.mts +1 -0
- package/generated/types/src/class/AwaitSignal.d.mts +48 -0
- package/generated/types/src/class/Console.d.mts +82 -0
- package/generated/types/src/class/DataLog.d.mts +25 -0
- package/generated/types/src/class/Derived.d.mts +74 -0
- package/generated/types/src/class/Effect.d.mts +213 -0
- package/{types → generated/types}/src/class/EnvSignal.d.mts +6 -2
- package/generated/types/src/class/EsWatcher.d.mts +36 -0
- package/{types → generated/types}/src/class/EventSignal.d.mts +39 -39
- package/generated/types/src/class/FSDirArchWatcher.d.mts +110 -0
- package/{types → generated/types}/src/class/FileSafe.d.mts +32 -16
- package/generated/types/src/class/ForEach.d.mts +57 -0
- package/generated/types/src/class/ForSignal.d.mts +63 -0
- package/generated/types/src/class/GetterSetter.d.mts +38 -0
- package/generated/types/src/class/JSONFileHandler.d.mts +50 -0
- package/{types → generated/types}/src/class/ListSignal.d.mts +49 -15
- package/{types → generated/types}/src/class/LitExp.d.mts +18 -18
- package/generated/types/src/class/ObjectSignal.d.mts +267 -0
- package/generated/types/src/class/Paths.d.mts +95 -0
- package/generated/types/src/class/Prettivy.d.mts +26 -0
- package/{types → generated/types}/src/class/QChannel.d.mts +24 -16
- package/generated/types/src/class/SafeExit.d.mts +69 -0
- package/{types → generated/types}/src/class/Setup.d.mts +29 -16
- package/{types → generated/types}/src/class/Signal.d.mts +29 -15
- package/generated/types/src/class/SignalCollection.d.mts +96 -0
- package/{types → generated/types}/src/class/WalkThrough.d.mts +4 -19
- package/generated/types/src/class/WorkerMainThread.bundled.d.mts +83 -0
- package/{types → generated/types}/src/class/WorkerMainThread.d.mts +33 -39
- package/{types → generated/types}/src/class/WorkerThread.d.mts +11 -5
- package/{types → generated/types}/src/common/Base64URL.d.mts +2 -1
- package/generated/types/src/common/Base64URLFromFile.d.mts +20 -0
- package/generated/types/src/common/BundledV.bundled.d.mts +3 -0
- package/generated/types/src/common/BundledV.d.mts +36 -0
- package/{types → generated/types}/src/common/CreateStringID.d.mts +5 -4
- package/generated/types/src/common/EnvMode.d.mts +79 -0
- package/generated/types/src/common/FactoryKey.d.mts +9 -0
- package/generated/types/src/common/Preferrence.d.mts +25 -0
- package/{types → generated/types}/src/common/Trace.d.mts +1 -1
- package/{types → generated/types}/src/common/TracePath.d.mts +1 -1
- package/generated/types/src/common/VivthUnBundledCodeBlock.d.mts +6 -0
- package/generated/types/src/doc/JSautoDOC.d.mts +172 -0
- package/generated/types/src/doc/cleanPreserveTypedef.d.mts +1 -0
- package/{types/src/doc/parsedFile.d.mts → generated/types/src/doc/parsedFileForDOC.d.mts} +56 -27
- package/generated/types/src/function/ClearRequireCache.d.mts +1 -0
- package/{types → generated/types}/src/function/CreateImmutable.d.mts +5 -4
- package/{types → generated/types}/src/function/EventCheck.d.mts +3 -1
- package/{types → generated/types}/src/function/EventObject.d.mts +2 -6
- package/generated/types/src/function/ForInAsync.d.mts +36 -0
- package/generated/types/src/function/ForInSync.d.mts +36 -0
- package/generated/types/src/function/ForOfAsync.d.mts +25 -0
- package/generated/types/src/function/ForOfSync.d.mts +36 -0
- package/generated/types/src/function/GetBufferFromRelativePath.d.mts +15 -0
- package/generated/types/src/function/GetFilesFromDir.d.mts +14 -0
- package/generated/types/src/function/GetMaxFilenameLength.d.mts +9 -0
- package/generated/types/src/function/GetModuleEsbuildPlatform.d.mts +13 -0
- package/{types → generated/types}/src/function/GetNamedImportAlias.d.mts +1 -1
- package/generated/types/src/function/GetRuntime.d.mts +2 -0
- package/generated/types/src/function/InstantiateAssemblyScript.d.mts +15 -0
- package/{types → generated/types}/src/function/IsAsync.d.mts +1 -1
- package/generated/types/src/function/IsInstanceOf.d.mts +25 -0
- package/generated/types/src/function/IsSameFile.d.mts +16 -0
- package/generated/types/src/function/IsStringLooksLikeAPath.d.mts +16 -0
- package/generated/types/src/function/IsTypeOf.d.mts +25 -0
- package/{types → generated/types}/src/function/LazyFactory.d.mts +9 -10
- package/generated/types/src/function/MonkeyPatch.d.mts +33 -0
- package/generated/types/src/function/NewAnimationTimeline.d.mts +24 -0
- package/generated/types/src/function/NewChainable.d.mts +35 -0
- package/generated/types/src/function/NewDynamicsExport.d.mts +49 -0
- package/generated/types/src/function/NewObjectWrapper.d.mts +10 -0
- package/generated/types/src/function/ObjectRegistrar.d.mts +17 -0
- package/generated/types/src/function/ParseSQLFile.d.mts +25 -0
- package/generated/types/src/function/PipeAsync.d.mts +19 -0
- package/generated/types/src/function/PipeSync.d.mts +17 -0
- package/generated/types/src/function/SafeImport.d.mts +21 -0
- package/generated/types/src/function/TemplateLiteral.d.mts +23 -0
- package/{types → generated/types}/src/function/Timeout.d.mts +1 -1
- package/{types → generated/types}/src/function/Tries.d.mts +4 -4
- package/{types → generated/types}/src/function/TryAsync.d.mts +2 -2
- package/{types → generated/types}/src/function/TryNew.d.mts +1 -1
- package/generated/types/src/function/TsToMjs.d.mts +27 -0
- package/generated/types/src/function/UniqueFSTempName.d.mts +9 -0
- package/generated/types/src/function/errorToMessage.d.mts +5 -0
- package/generated/types/src/neinth/VivthyNeinth.d.mts +202 -0
- package/generated/types/src/typehints/ArrayToKeys.d.mts +23 -0
- package/generated/types/src/typehints/AssemblyScriptExportsType.d.mts +4 -0
- package/generated/types/src/typehints/AssemblyScriptLoaderInstantiate.d.mts +4 -0
- package/generated/types/src/typehints/AutoDocASOptions.d.mts +15 -0
- package/generated/types/src/typehints/ChainableType.d.mts +3 -0
- package/generated/types/src/typehints/ComponentDecorator_Constructor.d.mts +3 -0
- package/generated/types/src/typehints/ConsoleAdditionalSettingType.d.mts +3 -0
- package/generated/types/src/typehints/Decorator.d.mts +11 -0
- package/generated/types/src/typehints/DecoratorMonkeyPatch.d.mts +15 -0
- package/{types/src/types → generated/types/src/typehints}/DevTestCB.d.mts +2 -2
- package/generated/types/src/typehints/EnvModeType.d.mts +4 -0
- package/generated/types/src/typehints/ListArg.d.mts +4 -0
- package/generated/types/src/typehints/MonkeyPatchedType.d.mts +1 -0
- package/generated/types/src/typehints/ParametersFollowingN.d.mts +13 -0
- package/generated/types/src/typehints/PrefixedKeysOf.d.mts +1 -0
- package/generated/types/src/typehints/Runtime.d.mts +4 -0
- package/generated/types/src/typehints/SafeImportReturnType.d.mts +1 -0
- package/generated/types/src/typehints/StylePropRefType.d.mts +2 -0
- package/generated/types/src/typehints/TemplateLiteralValueHandler.d.mts +10 -0
- package/generated/types/src/typehints/VLifecycleCallbacks.d.mts +6 -0
- package/generated/types/src/typehints/VivthCleanup.d.mts +12 -0
- package/generated/types/src/web/BrowserDirMapper.d.mts +70 -0
- package/generated/types/src/web/EnsureValidTag.d.mts +7 -0
- package/generated/types/src/web/ViteAddDynamics.d.mts +28 -0
- package/generated/types/src/web/ViteGetAllHTMLFile.d.mts +9 -0
- package/generated/types/src/web/WC_extendsA.d.mts +135 -0
- package/generated/types/src/web/WC_extendsB.d.mts +135 -0
- package/generated/types/src/web/bindings/WC_StyleProp_bind.d.mts +42 -0
- package/generated/types/src/web/bindings/WC_createElement_bind.d.mts +51 -0
- package/generated/types/src/web/bindings/WC_createNamedSlot.d.mts +26 -0
- package/generated/types/src/web/bindings/WC_litRender_bind.d.mts +20 -0
- package/generated/types/src/web/bindings/WC_litStyleMap.d.mts +7 -0
- package/generated/types/src/web/common/CSS.d.mts +23 -0
- package/generated/types/src/web/common/E.d.mts +41 -0
- package/generated/types/src/web/common/NewStyleSheetAsync.d.mts +15 -0
- package/generated/types/src/web/common/NewStyleSheetSync.d.mts +15 -0
- package/generated/types/src/web/common/WC_TagName_type.d.mts +15 -0
- package/generated/types/src/web/signals/IsInViewPortSignal.d.mts +52 -0
- package/generated/types/src/web/signals/ObserverSignal.d.mts +32 -0
- package/generated/types/src/web/signals/WC_litRef.d.mts +26 -0
- package/generated/types/src/web/signals/WC_loopedSiblingsRef.d.mts +44 -0
- package/generated/vivth/exports/all.mjs +233 -0
- package/generated/vivth/exports/neutral.mjs +193 -0
- package/generated/vivth/exports/node.mjs +46 -0
- package/package.json +78 -42
- package/src/bundler/CompileAS.mjs +36 -0
- package/src/bundler/CompileJS.mjs +98 -171
- package/src/bundler/CreateESPlugin.mjs +1 -1
- package/src/bundler/EsBundler.mjs +38 -13
- package/src/bundler/FSAnalyzer.mjs +253 -0
- package/src/bundler/FSasar.bundled.mjs +128 -0
- package/src/bundler/FSasar.mjs +96 -0
- package/src/bundler/FileSelfMapper.mjs +491 -0
- package/src/bundler/JSDirMapper.mjs +528 -0
- package/src/bundler/RunWatchThenCompileJSOnSafeExit.mjs +129 -0
- package/src/bundler/adds/BrowserExternals.mjs +37 -0
- package/src/bundler/adds/CreateTransform.mjs +36 -0
- package/src/bundler/adds/LastEditedUnix.mjs +12 -0
- package/src/bundler/adds/NodeModuleList.mjs +33 -0
- package/src/bundler/adds/PathFSBundles.bundled.mjs +41 -0
- package/src/bundler/adds/PathFSBundles.mjs +91 -0
- package/src/bundler/adds/PathFSDir.bundled.mjs +53 -0
- package/src/bundler/adds/PathFSDir.mjs +100 -0
- package/src/bundler/adds/PathFSFile.bundled.mjs +40 -0
- package/src/bundler/adds/PathFSFile.mjs +85 -0
- package/src/bundler/adds/ToBundledJSPlugin.mjs +116 -55
- package/src/bundler/adds/autoExternalize.mjs +81 -0
- package/src/bundler/adds/emptyBufferValue.mjs +5 -0
- package/src/bundler/adds/isModuleTheBundledVersion.mjs +10 -0
- package/src/bundler/adds/onEndEsBuildErrorLogger.mjs +34 -0
- package/src/bundler/adds/resolveJSDependencyPath.mjs +17 -0
- package/src/class/AwaitSignal.mjs +119 -0
- package/src/class/Console.mjs +36 -14
- package/src/class/DataLog.mjs +29 -0
- package/src/class/Derived.mjs +67 -55
- package/src/class/Effect.mjs +270 -84
- package/src/class/EnvSignal.mjs +11 -8
- package/src/class/EsWatcher.mjs +60 -0
- package/src/class/EventSignal.mjs +46 -58
- package/src/class/FSDirArchWatcher.mjs +246 -0
- package/src/class/FileSafe.mjs +72 -24
- package/src/class/ForEach.mjs +78 -0
- package/src/class/ForSignal.mjs +115 -0
- package/src/class/GetterSetter.mjs +40 -0
- package/src/class/JSONFileHandler.mjs +90 -0
- package/src/class/ListSignal.mjs +68 -26
- package/src/class/LitExp.mjs +59 -36
- package/src/class/ObjectSignal.mjs +225 -0
- package/src/class/Paths.mjs +56 -20
- package/src/class/Prettivy.mjs +51 -0
- package/src/class/QChannel.mjs +48 -26
- package/src/class/SafeExit.mjs +156 -99
- package/src/class/Setup.mjs +28 -16
- package/src/class/Signal.mjs +50 -27
- package/src/class/SignalCollection.mjs +130 -0
- package/src/class/WalkThrough.mjs +6 -23
- package/src/class/{WorkerMainThreadBundled.mjs → WorkerMainThread.bundled.mjs} +56 -77
- package/src/class/WorkerMainThread.mjs +98 -94
- package/src/class/WorkerThread.mjs +24 -17
- package/src/common/Base64URL.mjs +6 -3
- package/src/common/Base64URLFromFile.mjs +17 -4
- package/src/common/BundledV.bundled.mjs +7 -0
- package/src/common/BundledV.mjs +45 -0
- package/src/common/CreateStringID.mjs +8 -7
- package/src/common/EnvMode.mjs +172 -0
- package/src/common/FactoryKey.mjs +11 -0
- package/src/common/Preferrence.mjs +27 -0
- package/src/common/Trace.mjs +1 -1
- package/src/common/TracePath.mjs +53 -3
- package/src/common/VivthUnBundledCodeBlock.mjs +8 -0
- package/src/doc/JSautoDOC.mjs +673 -284
- package/src/doc/cleanPreserveTypedef.mjs +27 -0
- package/src/doc/correctBeforeParse.mjs +57 -48
- package/src/doc/{parsedFile.mjs → parsedFileForDOC.mjs} +133 -120
- package/src/function/ClearRequireCache.mjs +33 -0
- package/src/function/CreateImmutable.mjs +40 -37
- package/src/function/EventCheck.mjs +5 -2
- package/src/function/EventObject.mjs +2 -6
- package/src/function/ForInAsync.mjs +76 -0
- package/src/function/ForInSync.mjs +87 -0
- package/src/function/ForOfAsync.mjs +61 -0
- package/src/function/ForOfSync.mjs +70 -0
- package/src/function/GetBufferFromRelativePath.mjs +25 -0
- package/src/function/GetFilesFromDir.mjs +49 -0
- package/src/function/GetMaxFilenameLength.mjs +32 -0
- package/src/function/GetModuleEsbuildPlatform.mjs +118 -0
- package/src/function/GetNamedImportAlias.mjs +2 -2
- package/src/function/GetRuntime.mjs +10 -14
- package/src/function/InstantiateAssemblyScript.mjs +22 -0
- package/src/function/IsAsync.mjs +1 -1
- package/src/function/IsInstanceOf.mjs +29 -0
- package/src/function/IsSameFile.mjs +41 -0
- package/src/function/IsStringLooksLikeAPath.mjs +20 -0
- package/src/function/IsTypeOf.mjs +27 -0
- package/src/function/IsTypeOf.mts +31 -0
- package/src/function/LazyFactory.mjs +25 -23
- package/src/function/MonkeyPatch.mjs +38 -0
- package/src/function/NewAnimationTimeline.mjs +55 -0
- package/src/function/NewChainable.mjs +69 -0
- package/src/function/NewDynamicsExport.mjs +312 -0
- package/src/function/NewObjectWrapper.mjs +14 -0
- package/src/function/ObjectRegistrar.mjs +23 -0
- package/src/function/ParseSQLFile.mjs +129 -0
- package/src/function/PipeAsync.mjs +30 -0
- package/src/function/PipeSync.mjs +28 -0
- package/src/function/SafeImport.mjs +77 -0
- package/src/function/TemplateLiteral.mjs +42 -23
- package/src/function/Timeout.mjs +4 -4
- package/src/function/Tries.mjs +22 -16
- package/src/function/TryAsync.mjs +3 -2
- package/src/function/TryNew.mjs +1 -1
- package/src/function/TsToMjs.mjs +184 -21
- package/src/function/UniqueFSTempName.mjs +33 -0
- package/src/function/errorToMessage.mjs +21 -0
- package/src/function/resolveErrorArray.mjs +15 -1
- package/src/neinth/VivthyNeinth.mjs +487 -0
- package/src/typehints/ArrayToKeys.mjs +17 -0
- package/src/typehints/ArrayToKeys.mts +31 -0
- package/src/typehints/AssemblyScriptExportsType.mjs +7 -0
- package/src/typehints/AssemblyScriptLoaderInstantiate.mjs +7 -0
- package/src/typehints/AutoDocASOptions.mjs +14 -0
- package/src/typehints/ChainableType.mjs +11 -0
- package/src/typehints/ComponentDecorator_Constructor.mjs +10 -0
- package/src/typehints/ConsoleAdditionalSettingType.mjs +6 -0
- package/src/typehints/Decorator.mjs +9 -0
- package/src/typehints/Decorator.mts +31 -0
- package/src/typehints/DecoratorMonkeyPatch.mjs +10 -0
- package/src/typehints/DecoratorMonkeyPatch.mts +43 -0
- package/src/{types → typehints}/DevTestCB.mjs +2 -2
- package/src/typehints/EnvModeType.mjs +6 -0
- package/src/{types → typehints}/ListArg.mjs +1 -1
- package/src/{types → typehints}/LitExpResultType.mjs +1 -1
- package/src/typehints/MonkeyPatchedType.mjs +13 -0
- package/src/typehints/ParametersFollowingN.mjs +8 -0
- package/src/typehints/ParametersFollowingN.mts +17 -0
- package/src/typehints/PrefixedKeysOf.mjs +9 -0
- package/src/typehints/Runtime.mjs +6 -0
- package/src/typehints/SafeImportReturnType.mjs +6 -0
- package/src/typehints/StylePropRefType.mjs +12 -0
- package/src/typehints/TemplateLiteralValueHandler.mjs +14 -0
- package/src/typehints/VLifecycleCallbacks.mjs +10 -0
- package/src/typehints/VivthCleanup.mjs +14 -0
- package/src/web/BrowserDirMapper.mjs +255 -0
- package/src/web/EnsureValidTag.mjs +5 -0
- package/src/web/EnsureValidTag.mts +10 -0
- package/src/web/ViteAddDynamics.mjs +34 -0
- package/src/web/ViteGetAllHTMLFile.mjs +97 -0
- package/src/web/WC_extendsA.mjs +330 -0
- package/src/web/WC_extendsB.mjs +332 -0
- package/src/web/bindings/WC_StyleProp_bind.mjs +70 -0
- package/src/web/bindings/WC_createElement_bind.mjs +95 -0
- package/src/web/bindings/WC_createNamedSlot.mjs +29 -0
- package/src/web/bindings/WC_litRender_bind.mjs +26 -0
- package/src/web/bindings/WC_litStyleMap.mjs +14 -0
- package/src/web/common/CSS.mjs +35 -0
- package/src/web/common/E.mjs +126 -0
- package/src/web/common/NewStyleSheetAsync.mjs +21 -0
- package/src/web/common/NewStyleSheetSync.mjs +21 -0
- package/src/web/common/WC_TagName_type.mjs +10 -0
- package/src/web/common/WC_TagName_type.mts +36 -0
- package/src/web/signals/IsInViewPortSignal.mjs +140 -0
- package/src/web/signals/ObserverSignal.mjs +93 -0
- package/src/web/signals/WC_litRef.mjs +61 -0
- package/src/web/signals/WC_loopedSiblingsRef.mjs +100 -0
- package/tsconfig.json +44 -41
- package/index.mjs +0 -91
- package/src/bundler/FSInline.mjs +0 -67
- package/src/bundler/FSInlineAnalyzer.mjs +0 -228
- package/src/bundler/FSInlineBundled.mjs +0 -38
- package/src/bundler/adds/externals.mjs +0 -8
- package/src/class/ListDerived.mjs +0 -42
- package/src/common/Dev.mjs +0 -142
- package/src/common/DevBundled.mjs +0 -5
- package/src/common/lazie.mjs +0 -3
- package/src/types/IsListSignal.mjs +0 -6
- package/src/types/Runtime.mjs +0 -6
- package/src/types/VivthDevCodeBlockStringType.mjs +0 -6
- package/types/index.d.mts +0 -58
- package/types/src/bundler/CompileJS.d.mts +0 -119
- package/types/src/bundler/FSInline.d.mts +0 -50
- package/types/src/bundler/FSInlineAnalyzer.d.mts +0 -37
- package/types/src/bundler/FSInlineBundled.d.mts +0 -22
- package/types/src/bundler/adds/externals.d.mts +0 -1
- package/types/src/class/Console.d.mts +0 -71
- package/types/src/class/Derived.d.mts +0 -98
- package/types/src/class/Effect.d.mts +0 -216
- package/types/src/class/ListDerived.d.mts +0 -38
- package/types/src/class/Paths.d.mts +0 -69
- package/types/src/class/SafeExit.d.mts +0 -103
- package/types/src/class/WorkerMainThreadBundled.d.mts +0 -83
- package/types/src/common/Base64URLFromFile.d.mts +0 -16
- package/types/src/common/Dev.d.mts +0 -68
- package/types/src/common/DevBundled.d.mts +0 -3
- package/types/src/common/lazie.d.mts +0 -1
- package/types/src/doc/JSautoDOC.d.mts +0 -83
- package/types/src/function/GetRuntime.d.mts +0 -2
- package/types/src/function/TemplateLiteral.d.mts +0 -22
- package/types/src/function/TsToMjs.d.mts +0 -23
- package/types/src/types/IsListSignal.d.mts +0 -4
- package/types/src/types/ListArg.d.mts +0 -4
- package/types/src/types/Runtime.d.mts +0 -4
- package/types/src/types/VivthDevCodeBlockStringType.d.mts +0 -4
- /package/{types → generated/types}/src/bundler/adds/pluginVivthBundle.d.mts +0 -0
- /package/{types → generated/types}/src/class/WorkerResult.d.mts +0 -0
- /package/{types → generated/types}/src/common/EventNameSpace.d.mts +0 -0
- /package/{types → generated/types}/src/common/eventObjects.d.mts +0 -0
- /package/{types → generated/types}/src/common/keys.d.mts +0 -0
- /package/{types → generated/types}/src/doc/correctBeforeParse.d.mts +0 -0
- /package/{types → generated/types}/src/function/TrySync.d.mts +0 -0
- /package/{types → generated/types}/src/function/resolveErrorArray.d.mts +0 -0
- /package/{types/src/types → generated/types/src/typehints}/AnyButUndefined.d.mts +0 -0
- /package/{types/src/types → generated/types/src/typehints}/ExtnameType.d.mts +0 -0
- /package/{types/src/types → generated/types/src/typehints}/LitExpKeyType.d.mts +0 -0
- /package/{types/src/types → generated/types/src/typehints}/LitExpResultType.d.mts +0 -0
- /package/{types/src/types → generated/types/src/typehints}/MutationType.d.mts +0 -0
- /package/{types/src/types → generated/types/src/typehints}/QCBFIFOReturn.d.mts +0 -0
- /package/{types/src/types → generated/types/src/typehints}/QCBReturn.d.mts +0 -0
- /package/src/{types → typehints}/AnyButUndefined.mjs +0 -0
- /package/src/{types → typehints}/ExtnameType.mjs +0 -0
- /package/src/{types → typehints}/LitExpKeyType.mjs +0 -0
- /package/src/{types → typehints}/MutationType.mjs +0 -0
- /package/src/{types → typehints}/QCBFIFOReturn.mjs +0 -0
- /package/src/{types → typehints}/QCBReturn.mjs +0 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
import { context } from 'esbuild';
|
|
4
|
+
import { SafeExit } from './SafeExit.mjs';
|
|
5
|
+
import { TryAsync } from '../function/TryAsync.mjs';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {import('../typehints/VivthCleanup.mjs').VivthCleanup} VivthCleanup
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @description
|
|
13
|
+
* - wrapper for `watcher` via `esbuild.context`;
|
|
14
|
+
* - watcher cleanup is automatically registered to `SafeExit`;
|
|
15
|
+
* @template {import('esbuild').BuildOptions} O
|
|
16
|
+
* @implements {VivthCleanup}
|
|
17
|
+
*/
|
|
18
|
+
export class EsWatcher {
|
|
19
|
+
/**
|
|
20
|
+
* @description
|
|
21
|
+
* @param {Partial<O>} buildOptions
|
|
22
|
+
* @param {import('esbuild').WatchOptions} [watchOptions]
|
|
23
|
+
* @example
|
|
24
|
+
* import { EsWatcher } from 'vivth/node';
|
|
25
|
+
*
|
|
26
|
+
* const { context, remove } = new EsWatcher({
|
|
27
|
+
* ...esbuildOptions,
|
|
28
|
+
* });
|
|
29
|
+
*/
|
|
30
|
+
constructor(buildOptions, watchOptions) {
|
|
31
|
+
const context_ = (this.ctx = context(
|
|
32
|
+
// @ts-expect-error
|
|
33
|
+
buildOptions,
|
|
34
|
+
));
|
|
35
|
+
context_.then(async (ctx) => {
|
|
36
|
+
await ctx.watch(watchOptions);
|
|
37
|
+
SafeExit.instance?.addCallback(this.vivthCleanup);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @type {()=>Promise<void>}
|
|
43
|
+
*/
|
|
44
|
+
vivthCleanup = async () => {
|
|
45
|
+
SafeExit.instance?.removeCallback(this.vivthCleanup);
|
|
46
|
+
const { cancel, dispose } = await this.ctx;
|
|
47
|
+
await Promise.all([TryAsync(cancel), TryAsync(dispose)]);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @description
|
|
52
|
+
* - Promise of `BuildContext`;
|
|
53
|
+
* @type {Promise<import('esbuild').BuildContext<O>>}
|
|
54
|
+
*/
|
|
55
|
+
ctx;
|
|
56
|
+
rebuild = async () => {
|
|
57
|
+
const ctx = await this.ctx;
|
|
58
|
+
return ctx.rebuild();
|
|
59
|
+
};
|
|
60
|
+
}
|
|
@@ -2,82 +2,79 @@
|
|
|
2
2
|
|
|
3
3
|
import { LazyFactory } from '../function/LazyFactory.mjs';
|
|
4
4
|
import { Derived } from './Derived.mjs';
|
|
5
|
-
import { ListDerived } from './ListDerived.mjs';
|
|
6
|
-
import { ListSignal } from './ListSignal.mjs';
|
|
7
5
|
import { QChannel } from './QChannel.mjs';
|
|
8
6
|
import { Signal } from './Signal.mjs';
|
|
9
7
|
|
|
8
|
+
/**
|
|
9
|
+
* @typedef { import('../typehints/VivthCleanup.mjs').VivthCleanup } VivthCleanup
|
|
10
|
+
*/
|
|
11
|
+
|
|
10
12
|
/**
|
|
11
13
|
* @description
|
|
12
14
|
* - Signal implementation for `CustomEvent`, to dispatch and listen;
|
|
13
15
|
* - it's based on string as key, so it can be listened/dispatched even without direct instance reference;
|
|
14
|
-
* @template {
|
|
15
|
-
*
|
|
16
|
+
* @template {any} TYPE
|
|
17
|
+
* @implements {VivthCleanup}
|
|
16
18
|
*/
|
|
17
19
|
export class EventSignal {
|
|
20
|
+
vivthCleanup = async () => {
|
|
21
|
+
this.remove.ref();
|
|
22
|
+
};
|
|
18
23
|
/**
|
|
19
|
-
* @
|
|
24
|
+
* @type {QChannel<string>}
|
|
20
25
|
*/
|
|
26
|
+
static #q = LazyFactory(() => new QChannel('EventSignal'));
|
|
21
27
|
/**
|
|
22
|
-
* @description
|
|
23
28
|
* - `Map` of `EventSignal`, using the `stringName` of the `EventSignal_instance` as `key`;
|
|
24
29
|
* @type {Map<string, EventSignal<any>>}
|
|
25
30
|
*/
|
|
26
|
-
static map = new Map();
|
|
27
|
-
/**
|
|
28
|
-
* @type {QChannel<string>}
|
|
29
|
-
*/
|
|
30
|
-
static #qChannelEventSignal = LazyFactory(() => new QChannel('EventSignal'));
|
|
31
|
+
static #map = new Map();
|
|
31
32
|
/**
|
|
32
33
|
* @description
|
|
33
34
|
* - the constructor it self is set to `private`;
|
|
34
35
|
* - it's globally queued:
|
|
35
36
|
* >- the `Promise` nature is to prevent race condition on creating the instance;
|
|
36
37
|
* @param {string} stringName
|
|
37
|
-
* @param {IsListSignal} [isList_]
|
|
38
38
|
* @returns {Promise<EventSignal<any>>}
|
|
39
39
|
* @example
|
|
40
|
-
* import { EventSignal } from 'vivth';
|
|
40
|
+
* import { EventSignal, Trace } from 'vivth/neutral';
|
|
41
41
|
*
|
|
42
42
|
* const myEventSignal = await EventSignal.get('dataEvent');
|
|
43
|
+
* // recommendation
|
|
44
|
+
* const myEventSignalGenerator = async (name) => {
|
|
45
|
+
* return await EventSignal.get(`myEventSignalGenerator:${name}`);
|
|
46
|
+
* }
|
|
43
47
|
*/
|
|
44
|
-
static get = async (stringName
|
|
45
|
-
const { resume } = await EventSignal.#
|
|
46
|
-
const mapped = EventSignal
|
|
47
|
-
if (mapped.has(stringName)
|
|
48
|
-
let instance = new EventSignal(stringName
|
|
48
|
+
static get = async (stringName) => {
|
|
49
|
+
const { resume } = await EventSignal.#q.key(stringName);
|
|
50
|
+
const mapped = EventSignal.#map;
|
|
51
|
+
if (!mapped.has(stringName)) {
|
|
52
|
+
let instance = new EventSignal(stringName);
|
|
49
53
|
mapped.set(stringName, instance);
|
|
50
54
|
}
|
|
51
55
|
resume();
|
|
52
|
-
// @ts-expect-error
|
|
56
|
+
// @ts-expect-error already setted upstream
|
|
53
57
|
return mapped.get(stringName);
|
|
54
58
|
};
|
|
55
59
|
/**
|
|
56
60
|
* @private
|
|
57
61
|
* @param {string} name
|
|
58
|
-
* @param {ISLIST} [isList]
|
|
59
62
|
*/
|
|
60
|
-
|
|
61
|
-
constructor(name, isList = false) {
|
|
63
|
+
constructor(name) {
|
|
62
64
|
this.name = name;
|
|
63
|
-
this.#isList = isList;
|
|
64
65
|
}
|
|
65
|
-
/**
|
|
66
|
-
* @type {IsListSignal}
|
|
67
|
-
*/
|
|
68
|
-
#isList;
|
|
69
66
|
/**
|
|
70
67
|
* @type {string}
|
|
71
68
|
*/
|
|
72
69
|
name;
|
|
73
70
|
/**
|
|
74
71
|
* @description
|
|
75
|
-
* - is [Signal](#signal)
|
|
72
|
+
* - is [Signal](#signal) instance;
|
|
76
73
|
* - if needed to pass along the messages, it can be used as `dispatcher` and `listener` at the same time;
|
|
77
74
|
* - is `lazily` created;
|
|
78
|
-
* @type {Signal<
|
|
75
|
+
* @type {Signal<TYPE>}
|
|
79
76
|
* @example
|
|
80
|
-
* import { EventSignal, Effect, Console } from 'vivth';
|
|
77
|
+
* import { EventSignal, Effect, Console } from 'vivth/neutral';
|
|
81
78
|
*
|
|
82
79
|
* const myEventSignal = await EventSignal.get('dataEvent', false);
|
|
83
80
|
*
|
|
@@ -88,20 +85,18 @@ export class EventSignal {
|
|
|
88
85
|
* })
|
|
89
86
|
* myEventSignal.dispatch.value = 'hey';
|
|
90
87
|
*/
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
return new ListSignal([]);
|
|
94
|
-
}
|
|
88
|
+
// @ts-expect-error
|
|
89
|
+
dispatcher = LazyFactory(() => {
|
|
95
90
|
return new Signal(undefined);
|
|
96
91
|
});
|
|
97
92
|
/**
|
|
98
93
|
* @description
|
|
99
|
-
* - is [Derived](#derived)
|
|
94
|
+
* - is [Derived](#derived);
|
|
100
95
|
* - can be used as listener when passed down value shouldn't be modified manually;
|
|
101
96
|
* - is `lazily` created along with `dispatch`, if `listen` is accessed first, then `dispatch` will also be created automatically;
|
|
102
|
-
* @type {Derived<
|
|
97
|
+
* @type {Derived<TYPE>}
|
|
103
98
|
* @example
|
|
104
|
-
* import { EventSignal, Effect, Console } from 'vivth';
|
|
99
|
+
* import { EventSignal, Effect, Console } from 'vivth/neutral';
|
|
105
100
|
*
|
|
106
101
|
* const myEventSignal = await EventSignal.get('dataEvent', false);
|
|
107
102
|
*
|
|
@@ -112,15 +107,8 @@ export class EventSignal {
|
|
|
112
107
|
* })
|
|
113
108
|
* myEventSignal.dispatch.value = 'hey';
|
|
114
109
|
*/
|
|
115
|
-
|
|
116
|
-
const dispatch = this.
|
|
117
|
-
// @ts-expect-error
|
|
118
|
-
const _ = dispatch.value;
|
|
119
|
-
if (this.#isList) {
|
|
120
|
-
return new ListDerived(async ({ subscribe }) => {
|
|
121
|
-
return subscribe(dispatch).value;
|
|
122
|
-
});
|
|
123
|
-
}
|
|
110
|
+
listener = LazyFactory(() => {
|
|
111
|
+
const dispatch = this.dispatcher;
|
|
124
112
|
return new Derived(async ({ subscribe }) => {
|
|
125
113
|
return subscribe(dispatch).value;
|
|
126
114
|
});
|
|
@@ -139,7 +127,7 @@ export class EventSignal {
|
|
|
139
127
|
* @param {import('./Effect.mjs').Effect} effectInstance
|
|
140
128
|
* @returns {void}
|
|
141
129
|
* @example
|
|
142
|
-
* import { EventSignal } from 'vivth';
|
|
130
|
+
* import { EventSignal } from 'vivth/neutral';
|
|
143
131
|
*
|
|
144
132
|
* EventSignal.remove.subscriber('yourEventSignalName', myEffectInstance);
|
|
145
133
|
*/
|
|
@@ -159,7 +147,7 @@ export class EventSignal {
|
|
|
159
147
|
* @param {string} name
|
|
160
148
|
* @returns {void}
|
|
161
149
|
* @example
|
|
162
|
-
* import { EventSignal } from 'vivth';
|
|
150
|
+
* import { EventSignal } from 'vivth/neutral';
|
|
163
151
|
*
|
|
164
152
|
* EventSignal.remove.allSubscribers('yourEventSignalName');
|
|
165
153
|
*/
|
|
@@ -175,7 +163,7 @@ export class EventSignal {
|
|
|
175
163
|
* @param {string} name
|
|
176
164
|
* @returns {void}
|
|
177
165
|
* @example
|
|
178
|
-
* import { EventSignal } from 'vivth';
|
|
166
|
+
* import { EventSignal } from 'vivth/neutral';
|
|
179
167
|
*
|
|
180
168
|
* EventSignal.remove.refs('yourEventSignalName');
|
|
181
169
|
*/
|
|
@@ -193,7 +181,7 @@ export class EventSignal {
|
|
|
193
181
|
* @param {import('./Effect.mjs').Effect} effectInstance
|
|
194
182
|
* @returns {void}
|
|
195
183
|
* @example
|
|
196
|
-
* import { EventSignal, Effect, Console } from 'vivth';
|
|
184
|
+
* import { EventSignal, Effect, Console } from 'vivth/neutral';
|
|
197
185
|
*
|
|
198
186
|
* const myEventSignal = await EventSignal.get('dataEvent', false);
|
|
199
187
|
*
|
|
@@ -209,8 +197,8 @@ export class EventSignal {
|
|
|
209
197
|
* this part is not needed, as the effect might need to react to other signals
|
|
210
198
|
// effectInstance.options.removeEffect();
|
|
211
199
|
*/
|
|
212
|
-
this.
|
|
213
|
-
this.
|
|
200
|
+
this.dispatcher.remove.subscriber(effectInstance);
|
|
201
|
+
this.listener.remove.subscriber(effectInstance);
|
|
214
202
|
},
|
|
215
203
|
/**
|
|
216
204
|
* @instance remove
|
|
@@ -218,7 +206,7 @@ export class EventSignal {
|
|
|
218
206
|
* - remove allSubscribers from the `EventSignal_instance`;
|
|
219
207
|
* @type {()=>void}
|
|
220
208
|
* @example
|
|
221
|
-
* import { EventSignal, Effect, Console } from 'vivth';
|
|
209
|
+
* import { EventSignal, Effect, Console } from 'vivth/neutral';
|
|
222
210
|
*
|
|
223
211
|
* const myEventSignal = await EventSignal.get('dataEvent', false);
|
|
224
212
|
*
|
|
@@ -230,8 +218,8 @@ export class EventSignal {
|
|
|
230
218
|
* eventSignal_instance.remove.allSubscribers();
|
|
231
219
|
*/
|
|
232
220
|
allSubscribers: () => {
|
|
233
|
-
this.
|
|
234
|
-
this.
|
|
221
|
+
this.dispatcher.remove.allSubscribers();
|
|
222
|
+
this.listener.remove.allSubscribers();
|
|
235
223
|
},
|
|
236
224
|
/**
|
|
237
225
|
* @instance remove
|
|
@@ -239,7 +227,7 @@ export class EventSignal {
|
|
|
239
227
|
* - remove reference of the `proxySignals` of the `EventSignal_instance`;
|
|
240
228
|
* @type {()=>void}
|
|
241
229
|
* @example
|
|
242
|
-
* import { EventSignal, Effect, Console } from 'vivth';
|
|
230
|
+
* import { EventSignal, Effect, Console } from 'vivth/neutral';
|
|
243
231
|
*
|
|
244
232
|
* const myEventSignal = await EventSignal.get('dataEvent', false);
|
|
245
233
|
*
|
|
@@ -251,8 +239,8 @@ export class EventSignal {
|
|
|
251
239
|
* eventSignal_instance.remove.ref();
|
|
252
240
|
*/
|
|
253
241
|
ref: () => {
|
|
254
|
-
this.
|
|
255
|
-
this.
|
|
242
|
+
this.dispatcher.remove.ref();
|
|
243
|
+
this.listener.remove.ref();
|
|
256
244
|
},
|
|
257
245
|
}));
|
|
258
246
|
}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
import { watch } from 'chokidar';
|
|
4
|
+
|
|
5
|
+
import { Paths } from './Paths.mjs';
|
|
6
|
+
import { Signal } from './Signal.mjs';
|
|
7
|
+
import { SafeExit } from './SafeExit.mjs';
|
|
8
|
+
import { QChannel } from './QChannel.mjs';
|
|
9
|
+
import { Effect } from './Effect.mjs';
|
|
10
|
+
import { TryAsync } from '../function/TryAsync.mjs';
|
|
11
|
+
import { WalkThrough } from './WalkThrough.mjs';
|
|
12
|
+
import { LazyFactory } from '../function/LazyFactory.mjs';
|
|
13
|
+
import { Console } from './Console.mjs';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @typedef {import('../typehints/VivthCleanup.mjs').VivthCleanup} VivthCleanup
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @description
|
|
21
|
+
* - class helper for chokidar abstraction to watch and iterate paths;
|
|
22
|
+
* - this class assume `Paths` and `SafeExit` to be instantiated;
|
|
23
|
+
* @template {any} PASSEDVALUE
|
|
24
|
+
* @implements {VivthCleanup}
|
|
25
|
+
*/
|
|
26
|
+
export class FSDirArchWatcher {
|
|
27
|
+
/**
|
|
28
|
+
* @type {QChannel<string|FSDirArchWatcher<any>>}
|
|
29
|
+
*/
|
|
30
|
+
#q = LazyFactory(() => new QChannel('FSDirArchWatcher'));
|
|
31
|
+
/**
|
|
32
|
+
* @description
|
|
33
|
+
* - callback to handle each path;
|
|
34
|
+
* @type {(
|
|
35
|
+
* eventName: import('chokidar/handler.js').EventName,
|
|
36
|
+
* path: import('chokidar/handler.js').Path,
|
|
37
|
+
* stats?: import('node:fs').Stats,
|
|
38
|
+
* ) => Promise<PASSEDVALUE>
|
|
39
|
+
* }
|
|
40
|
+
*/
|
|
41
|
+
eachHandler;
|
|
42
|
+
/**
|
|
43
|
+
* @description
|
|
44
|
+
* - callback to handle all registered path;
|
|
45
|
+
* - debounced to only handle last changes on full registry with:
|
|
46
|
+
* >- `options.debounce`;
|
|
47
|
+
* >- `QChannel` `isLastOnQ`;
|
|
48
|
+
* @type {(
|
|
49
|
+
* alphabeticallySortedSharedValue: {
|
|
50
|
+
* map: Map<string, PASSEDVALUE>,
|
|
51
|
+
* array: Array<[path: string, PASSEDVALUE]>,
|
|
52
|
+
* }
|
|
53
|
+
* ) => Promise<void>
|
|
54
|
+
* }
|
|
55
|
+
*/
|
|
56
|
+
fullHandler;
|
|
57
|
+
/**
|
|
58
|
+
* @description
|
|
59
|
+
* @param {string[]} watchPaths
|
|
60
|
+
* @param {Object} options
|
|
61
|
+
* @param {FSDirArchWatcher<PASSEDVALUE>["eachHandler"]} options.each
|
|
62
|
+
* - throw to `ignore` OR `delete` path from the result passed to `.full`;
|
|
63
|
+
* @param {FSDirArchWatcher<PASSEDVALUE>["fullHandler"]} options.full
|
|
64
|
+
* @param {number} [options.debounce]
|
|
65
|
+
* - debounce on calling `fullHandler`;
|
|
66
|
+
* @param {import('chokidar').ChokidarOptions} [options.chokidarOptions]
|
|
67
|
+
* - `ChokidarOptions`;
|
|
68
|
+
* @example
|
|
69
|
+
* import { FSDirArchWatcher, IsSameFile } from "vivth/node";
|
|
70
|
+
*
|
|
71
|
+
* const settingFile = '/fsrouter.setting.mjs';
|
|
72
|
+
*
|
|
73
|
+
* new FSDirArchWatcher(['/routers/', '/fsrouter.setting.mjs'], {
|
|
74
|
+
* // debounce: 100,
|
|
75
|
+
* each: async (eventName, path, stats) => {
|
|
76
|
+
* // this callback is queued already;
|
|
77
|
+
* // path are already `Paths.normalized`;
|
|
78
|
+
* if(IsSameFile(path, settingFile)){
|
|
79
|
+
* // code;
|
|
80
|
+
* }
|
|
81
|
+
* switch (eventName) {
|
|
82
|
+
* case 'add':
|
|
83
|
+
* case 'change':
|
|
84
|
+
* // structure route here and return;
|
|
85
|
+
* // a throwed call, will delete from sharedMap;
|
|
86
|
+
* return {};
|
|
87
|
+
* default:
|
|
88
|
+
* // only for imperative handler when needed;
|
|
89
|
+
* // or you can just throw here;
|
|
90
|
+
* return {};
|
|
91
|
+
* }
|
|
92
|
+
* // only non throwed call of path is registered to sharedMap;
|
|
93
|
+
* // throwed call of path is unregistered from sharedMap;
|
|
94
|
+
* },
|
|
95
|
+
* full:async (sharedMap) => {
|
|
96
|
+
* // this callback is queued already;
|
|
97
|
+
* // loop through returned from loop then write to a file;
|
|
98
|
+
* },
|
|
99
|
+
* })
|
|
100
|
+
*/
|
|
101
|
+
constructor(
|
|
102
|
+
watchPaths,
|
|
103
|
+
{ chokidarOptions = undefined, each: eachHandler, full: fullHandler, debounce = 100 },
|
|
104
|
+
) {
|
|
105
|
+
const setOfWatchPath = new Set(watchPaths);
|
|
106
|
+
WalkThrough.set(setOfWatchPath, (watchPath) => {
|
|
107
|
+
const absolutePath = Paths.diskAbsolute(watchPath);
|
|
108
|
+
if (setOfWatchPath.has(absolutePath)) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
setOfWatchPath.delete(watchPath);
|
|
112
|
+
setOfWatchPath.add(absolutePath);
|
|
113
|
+
});
|
|
114
|
+
this.fullHandler = fullHandler;
|
|
115
|
+
this.eachHandler = eachHandler;
|
|
116
|
+
this.watcher = watch(Array.from(setOfWatchPath), chokidarOptions);
|
|
117
|
+
this.#debounce = debounce;
|
|
118
|
+
this.watcher.addListener('all', this.#eachHandler);
|
|
119
|
+
SafeExit.instance?.addCallback(this.vivthCleanup);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
vivthCleanup = async () => {
|
|
123
|
+
SafeExit.instance?.removeCallback(this.vivthCleanup);
|
|
124
|
+
this.watcher.removeAllListeners();
|
|
125
|
+
await this.watcher.close();
|
|
126
|
+
Console.log(
|
|
127
|
+
{
|
|
128
|
+
FSDirArchWatcher: 'watcher closed',
|
|
129
|
+
},
|
|
130
|
+
{ now: true },
|
|
131
|
+
);
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* @type {Signal<Map<string, PASSEDVALUE>>}
|
|
136
|
+
*/
|
|
137
|
+
#mappedFilePaths = new Signal(new Map());
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* @param {() => boolean} isLastOnQ
|
|
141
|
+
* @param {(signalInstance: any) => any} subscribe
|
|
142
|
+
* @param {(timeoutMS?: number | undefined) => Promise<boolean>} isLastCalled
|
|
143
|
+
* @returns
|
|
144
|
+
*/
|
|
145
|
+
#mappedFilePathsHandlerQ = async (isLastOnQ, subscribe, isLastCalled) => {
|
|
146
|
+
const originalMap = subscribe(this.#mappedFilePaths).value;
|
|
147
|
+
if (!isLastOnQ() || !(await isLastCalled(this.#debounce))) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
const array = [...originalMap.entries()].sort(([a], [b]) => a.localeCompare(b));
|
|
151
|
+
/**
|
|
152
|
+
* @type {Map<string, PASSEDVALUE>}
|
|
153
|
+
*/
|
|
154
|
+
const map = new Map(array);
|
|
155
|
+
await this.fullHandler({ map, array });
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
// @ts-expect-error
|
|
159
|
+
#mappedFilePathsHandler = new Effect(async ({ isLastCalled, subscribe }) => {
|
|
160
|
+
this.#q.callback(this, async ({ isLastOnQ }) => {
|
|
161
|
+
await this.#mappedFilePathsHandlerQ(isLastOnQ, subscribe, isLastCalled);
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* @type {ConstructorParameters<typeof FSDirArchWatcher<PASSEDVALUE>>[1]["debounce"]}
|
|
167
|
+
*/
|
|
168
|
+
#debounce;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* @param {()=>boolean} isLastOnQ
|
|
172
|
+
* @param {import('chokidar/handler.js').EventName} eventName
|
|
173
|
+
* @param {import('chokidar/handler.js').Path} path
|
|
174
|
+
* @param {import('node:fs').Stats} [stats]
|
|
175
|
+
*/
|
|
176
|
+
#eachHandlerQ = async (isLastOnQ, eventName, path, stats) => {
|
|
177
|
+
if (!isLastOnQ()) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
switch (eventName) {
|
|
181
|
+
case 'add':
|
|
182
|
+
case 'change':
|
|
183
|
+
{
|
|
184
|
+
if (
|
|
185
|
+
/**
|
|
186
|
+
* - only MARKED file PATH;
|
|
187
|
+
*/
|
|
188
|
+
!stats ||
|
|
189
|
+
!stats.isFile()
|
|
190
|
+
) {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* - outside notify, as to be awaited by `QChannel.callback`
|
|
195
|
+
*/
|
|
196
|
+
const [shared, errorCallingEachHandler] = await TryAsync(async () => {
|
|
197
|
+
return await this.eachHandler(eventName, path, stats);
|
|
198
|
+
});
|
|
199
|
+
this.#mappedFilePaths.subscribers.notify(async ({ signalInstance }) => {
|
|
200
|
+
if (errorCallingEachHandler) {
|
|
201
|
+
signalInstance.value.delete(path);
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
signalInstance.value.set(path, shared);
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
break;
|
|
208
|
+
default:
|
|
209
|
+
{
|
|
210
|
+
if (
|
|
211
|
+
/**
|
|
212
|
+
* - only handle MARKED PATH;
|
|
213
|
+
* - which in this case must be a file that no longer exist;
|
|
214
|
+
* - and not a dir;
|
|
215
|
+
*/
|
|
216
|
+
!this.#mappedFilePaths.value.has(path)
|
|
217
|
+
) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* - outside notify, as to be awaited by `QChannel.callback`
|
|
222
|
+
*/
|
|
223
|
+
await TryAsync(async () => {
|
|
224
|
+
await this.eachHandler(eventName, path, stats);
|
|
225
|
+
});
|
|
226
|
+
this.#mappedFilePaths.subscribers.notify(async ({ signalInstance }) => {
|
|
227
|
+
signalInstance.value.delete(path);
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
break;
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* @param {import('chokidar/handler.js').EventName} eventName
|
|
236
|
+
* @param {import('chokidar/handler.js').Path} path
|
|
237
|
+
* @param {import('node:fs').Stats} [stats]
|
|
238
|
+
* @returns {void}
|
|
239
|
+
*/
|
|
240
|
+
#eachHandler = (eventName, path, stats) => {
|
|
241
|
+
path = Paths.normalize(path);
|
|
242
|
+
this.#q.callback(path, async ({ isLastOnQ }) => {
|
|
243
|
+
await this.#eachHandlerQ(isLastOnQ, eventName, path, stats);
|
|
244
|
+
});
|
|
245
|
+
};
|
|
246
|
+
}
|