vivth 1.4.10 → 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.
- package/README.md +6060 -2037
- package/README.src.md +22 -14
- package/bun.lock +154 -194
- package/dev/auto/.src.ignore +25 -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 +50 -14
- 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,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import('../typehints/VivthCleanup.mjs').VivthCleanup} VivthCleanup
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* @description
|
|
6
|
+
* - wrapper for `watcher` via `esbuild.context`;
|
|
7
|
+
* - watcher cleanup is automatically registered to `SafeExit`;
|
|
8
|
+
* @template {import('esbuild').BuildOptions} O
|
|
9
|
+
* @implements {VivthCleanup}
|
|
10
|
+
*/
|
|
11
|
+
export class EsWatcher<O extends import("esbuild").BuildOptions> implements VivthCleanup {
|
|
12
|
+
/**
|
|
13
|
+
* @description
|
|
14
|
+
* @param {Partial<O>} buildOptions
|
|
15
|
+
* @param {import('esbuild').WatchOptions} [watchOptions]
|
|
16
|
+
* @example
|
|
17
|
+
* import { EsWatcher } from 'vivth/node';
|
|
18
|
+
*
|
|
19
|
+
* const { context, remove } = new EsWatcher({
|
|
20
|
+
* ...esbuildOptions,
|
|
21
|
+
* });
|
|
22
|
+
*/
|
|
23
|
+
constructor(buildOptions: Partial<O>, watchOptions?: import("esbuild").WatchOptions);
|
|
24
|
+
/**
|
|
25
|
+
* @description
|
|
26
|
+
* - Promise of `BuildContext`;
|
|
27
|
+
* @type {Promise<import('esbuild').BuildContext<O>>}
|
|
28
|
+
*/
|
|
29
|
+
ctx: Promise<import("esbuild").BuildContext<O>>;
|
|
30
|
+
/**
|
|
31
|
+
* @type {()=>Promise<void>}
|
|
32
|
+
*/
|
|
33
|
+
vivthCleanup: () => Promise<void>;
|
|
34
|
+
rebuild: () => Promise<import("esbuild").BuildResult<O>>;
|
|
35
|
+
}
|
|
36
|
+
export type VivthCleanup = import("../typehints/VivthCleanup.mjs").VivthCleanup;
|
|
@@ -1,38 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef { import('../typehints/VivthCleanup.mjs').VivthCleanup } VivthCleanup
|
|
3
|
+
*/
|
|
1
4
|
/**
|
|
2
5
|
* @description
|
|
3
6
|
* - Signal implementation for `CustomEvent`, to dispatch and listen;
|
|
4
7
|
* - it's based on string as key, so it can be listened/dispatched even without direct instance reference;
|
|
5
|
-
* @template {
|
|
6
|
-
*
|
|
8
|
+
* @template {any} TYPE
|
|
9
|
+
* @implements {VivthCleanup}
|
|
7
10
|
*/
|
|
8
|
-
export class EventSignal<
|
|
11
|
+
export class EventSignal<TYPE extends unknown> implements VivthCleanup {
|
|
9
12
|
/**
|
|
10
|
-
* @
|
|
13
|
+
* @type {QChannel<string>}
|
|
11
14
|
*/
|
|
15
|
+
static #q: QChannel<string>;
|
|
12
16
|
/**
|
|
13
|
-
* @description
|
|
14
17
|
* - `Map` of `EventSignal`, using the `stringName` of the `EventSignal_instance` as `key`;
|
|
15
18
|
* @type {Map<string, EventSignal<any>>}
|
|
16
19
|
*/
|
|
17
|
-
static map: Map<string, EventSignal<any>>;
|
|
18
|
-
/**
|
|
19
|
-
* @type {QChannel<string>}
|
|
20
|
-
*/
|
|
21
|
-
static "__#private@#qChannelEventSignal": QChannel<string>;
|
|
20
|
+
static #map: Map<string, EventSignal<any>>;
|
|
22
21
|
/**
|
|
23
22
|
* @description
|
|
24
23
|
* - the constructor it self is set to `private`;
|
|
25
24
|
* - it's globally queued:
|
|
26
25
|
* >- the `Promise` nature is to prevent race condition on creating the instance;
|
|
27
26
|
* @param {string} stringName
|
|
28
|
-
* @param {IsListSignal} [isList_]
|
|
29
27
|
* @returns {Promise<EventSignal<any>>}
|
|
30
28
|
* @example
|
|
31
|
-
* import { EventSignal } from 'vivth';
|
|
29
|
+
* import { EventSignal, Trace } from 'vivth/neutral';
|
|
32
30
|
*
|
|
33
31
|
* const myEventSignal = await EventSignal.get('dataEvent');
|
|
32
|
+
* // recommendation
|
|
33
|
+
* const myEventSignalGenerator = async (name) => {
|
|
34
|
+
* return await EventSignal.get(`myEventSignalGenerator:${name}`);
|
|
35
|
+
* }
|
|
34
36
|
*/
|
|
35
|
-
static get: (stringName: string
|
|
37
|
+
static get: (stringName: string) => Promise<EventSignal<any>>;
|
|
36
38
|
/**
|
|
37
39
|
* @description
|
|
38
40
|
* - methods of this static property is lazily created;
|
|
@@ -47,7 +49,7 @@ export class EventSignal<ISLIST extends boolean> {
|
|
|
47
49
|
* @param {import('./Effect.mjs').Effect} effectInstance
|
|
48
50
|
* @returns {void}
|
|
49
51
|
* @example
|
|
50
|
-
* import { EventSignal } from 'vivth';
|
|
52
|
+
* import { EventSignal } from 'vivth/neutral';
|
|
51
53
|
*
|
|
52
54
|
* EventSignal.remove.subscriber('yourEventSignalName', myEffectInstance);
|
|
53
55
|
*/
|
|
@@ -59,7 +61,7 @@ export class EventSignal<ISLIST extends boolean> {
|
|
|
59
61
|
* @param {string} name
|
|
60
62
|
* @returns {void}
|
|
61
63
|
* @example
|
|
62
|
-
* import { EventSignal } from 'vivth';
|
|
64
|
+
* import { EventSignal } from 'vivth/neutral';
|
|
63
65
|
*
|
|
64
66
|
* EventSignal.remove.allSubscribers('yourEventSignalName');
|
|
65
67
|
*/
|
|
@@ -71,13 +73,13 @@ export class EventSignal<ISLIST extends boolean> {
|
|
|
71
73
|
* @param {string} name
|
|
72
74
|
* @returns {void}
|
|
73
75
|
* @example
|
|
74
|
-
* import { EventSignal } from 'vivth';
|
|
76
|
+
* import { EventSignal } from 'vivth/neutral';
|
|
75
77
|
*
|
|
76
78
|
* EventSignal.remove.refs('yourEventSignalName');
|
|
77
79
|
*/
|
|
78
80
|
refs: (name: string) => void;
|
|
79
81
|
} & {
|
|
80
|
-
|
|
82
|
+
[x: symbol]: {
|
|
81
83
|
/**
|
|
82
84
|
* @static remove
|
|
83
85
|
* @description
|
|
@@ -86,7 +88,7 @@ export class EventSignal<ISLIST extends boolean> {
|
|
|
86
88
|
* @param {import('./Effect.mjs').Effect} effectInstance
|
|
87
89
|
* @returns {void}
|
|
88
90
|
* @example
|
|
89
|
-
* import { EventSignal } from 'vivth';
|
|
91
|
+
* import { EventSignal } from 'vivth/neutral';
|
|
90
92
|
*
|
|
91
93
|
* EventSignal.remove.subscriber('yourEventSignalName', myEffectInstance);
|
|
92
94
|
*/
|
|
@@ -98,7 +100,7 @@ export class EventSignal<ISLIST extends boolean> {
|
|
|
98
100
|
* @param {string} name
|
|
99
101
|
* @returns {void}
|
|
100
102
|
* @example
|
|
101
|
-
* import { EventSignal } from 'vivth';
|
|
103
|
+
* import { EventSignal } from 'vivth/neutral';
|
|
102
104
|
*
|
|
103
105
|
* EventSignal.remove.allSubscribers('yourEventSignalName');
|
|
104
106
|
*/
|
|
@@ -110,7 +112,7 @@ export class EventSignal<ISLIST extends boolean> {
|
|
|
110
112
|
* @param {string} name
|
|
111
113
|
* @returns {void}
|
|
112
114
|
* @example
|
|
113
|
-
* import { EventSignal } from 'vivth';
|
|
115
|
+
* import { EventSignal } from 'vivth/neutral';
|
|
114
116
|
*
|
|
115
117
|
* EventSignal.remove.refs('yourEventSignalName');
|
|
116
118
|
*/
|
|
@@ -120,21 +122,21 @@ export class EventSignal<ISLIST extends boolean> {
|
|
|
120
122
|
/**
|
|
121
123
|
* @private
|
|
122
124
|
* @param {string} name
|
|
123
|
-
* @param {ISLIST} [isList]
|
|
124
125
|
*/
|
|
125
126
|
private constructor();
|
|
127
|
+
vivthCleanup: () => Promise<void>;
|
|
126
128
|
/**
|
|
127
129
|
* @type {string}
|
|
128
130
|
*/
|
|
129
131
|
name: string;
|
|
130
132
|
/**
|
|
131
133
|
* @description
|
|
132
|
-
* - is [Signal](#signal)
|
|
134
|
+
* - is [Signal](#signal) instance;
|
|
133
135
|
* - if needed to pass along the messages, it can be used as `dispatcher` and `listener` at the same time;
|
|
134
136
|
* - is `lazily` created;
|
|
135
|
-
* @type {Signal<
|
|
137
|
+
* @type {Signal<TYPE>}
|
|
136
138
|
* @example
|
|
137
|
-
* import { EventSignal, Effect, Console } from 'vivth';
|
|
139
|
+
* import { EventSignal, Effect, Console } from 'vivth/neutral';
|
|
138
140
|
*
|
|
139
141
|
* const myEventSignal = await EventSignal.get('dataEvent', false);
|
|
140
142
|
*
|
|
@@ -145,15 +147,15 @@ export class EventSignal<ISLIST extends boolean> {
|
|
|
145
147
|
* })
|
|
146
148
|
* myEventSignal.dispatch.value = 'hey';
|
|
147
149
|
*/
|
|
148
|
-
|
|
150
|
+
dispatcher: Signal<TYPE>;
|
|
149
151
|
/**
|
|
150
152
|
* @description
|
|
151
|
-
* - is [Derived](#derived)
|
|
153
|
+
* - is [Derived](#derived);
|
|
152
154
|
* - can be used as listener when passed down value shouldn't be modified manually;
|
|
153
155
|
* - is `lazily` created along with `dispatch`, if `listen` is accessed first, then `dispatch` will also be created automatically;
|
|
154
|
-
* @type {Derived<
|
|
156
|
+
* @type {Derived<TYPE>}
|
|
155
157
|
* @example
|
|
156
|
-
* import { EventSignal, Effect, Console } from 'vivth';
|
|
158
|
+
* import { EventSignal, Effect, Console } from 'vivth/neutral';
|
|
157
159
|
*
|
|
158
160
|
* const myEventSignal = await EventSignal.get('dataEvent', false);
|
|
159
161
|
*
|
|
@@ -164,7 +166,7 @@ export class EventSignal<ISLIST extends boolean> {
|
|
|
164
166
|
* })
|
|
165
167
|
* myEventSignal.dispatch.value = 'hey';
|
|
166
168
|
*/
|
|
167
|
-
|
|
169
|
+
listener: Derived<TYPE>;
|
|
168
170
|
remove: {
|
|
169
171
|
/**
|
|
170
172
|
* @instance remove
|
|
@@ -173,7 +175,7 @@ export class EventSignal<ISLIST extends boolean> {
|
|
|
173
175
|
* @param {import('./Effect.mjs').Effect} effectInstance
|
|
174
176
|
* @returns {void}
|
|
175
177
|
* @example
|
|
176
|
-
* import { EventSignal, Effect, Console } from 'vivth';
|
|
178
|
+
* import { EventSignal, Effect, Console } from 'vivth/neutral';
|
|
177
179
|
*
|
|
178
180
|
* const myEventSignal = await EventSignal.get('dataEvent', false);
|
|
179
181
|
*
|
|
@@ -191,7 +193,7 @@ export class EventSignal<ISLIST extends boolean> {
|
|
|
191
193
|
* - remove allSubscribers from the `EventSignal_instance`;
|
|
192
194
|
* @type {()=>void}
|
|
193
195
|
* @example
|
|
194
|
-
* import { EventSignal, Effect, Console } from 'vivth';
|
|
196
|
+
* import { EventSignal, Effect, Console } from 'vivth/neutral';
|
|
195
197
|
*
|
|
196
198
|
* const myEventSignal = await EventSignal.get('dataEvent', false);
|
|
197
199
|
*
|
|
@@ -209,7 +211,7 @@ export class EventSignal<ISLIST extends boolean> {
|
|
|
209
211
|
* - remove reference of the `proxySignals` of the `EventSignal_instance`;
|
|
210
212
|
* @type {()=>void}
|
|
211
213
|
* @example
|
|
212
|
-
* import { EventSignal, Effect, Console } from 'vivth';
|
|
214
|
+
* import { EventSignal, Effect, Console } from 'vivth/neutral';
|
|
213
215
|
*
|
|
214
216
|
* const myEventSignal = await EventSignal.get('dataEvent', false);
|
|
215
217
|
*
|
|
@@ -222,7 +224,7 @@ export class EventSignal<ISLIST extends boolean> {
|
|
|
222
224
|
*/
|
|
223
225
|
ref: () => void;
|
|
224
226
|
} & {
|
|
225
|
-
|
|
227
|
+
[x: symbol]: {
|
|
226
228
|
/**
|
|
227
229
|
* @instance remove
|
|
228
230
|
* @description
|
|
@@ -230,7 +232,7 @@ export class EventSignal<ISLIST extends boolean> {
|
|
|
230
232
|
* @param {import('./Effect.mjs').Effect} effectInstance
|
|
231
233
|
* @returns {void}
|
|
232
234
|
* @example
|
|
233
|
-
* import { EventSignal, Effect, Console } from 'vivth';
|
|
235
|
+
* import { EventSignal, Effect, Console } from 'vivth/neutral';
|
|
234
236
|
*
|
|
235
237
|
* const myEventSignal = await EventSignal.get('dataEvent', false);
|
|
236
238
|
*
|
|
@@ -248,7 +250,7 @@ export class EventSignal<ISLIST extends boolean> {
|
|
|
248
250
|
* - remove allSubscribers from the `EventSignal_instance`;
|
|
249
251
|
* @type {()=>void}
|
|
250
252
|
* @example
|
|
251
|
-
* import { EventSignal, Effect, Console } from 'vivth';
|
|
253
|
+
* import { EventSignal, Effect, Console } from 'vivth/neutral';
|
|
252
254
|
*
|
|
253
255
|
* const myEventSignal = await EventSignal.get('dataEvent', false);
|
|
254
256
|
*
|
|
@@ -266,7 +268,7 @@ export class EventSignal<ISLIST extends boolean> {
|
|
|
266
268
|
* - remove reference of the `proxySignals` of the `EventSignal_instance`;
|
|
267
269
|
* @type {()=>void}
|
|
268
270
|
* @example
|
|
269
|
-
* import { EventSignal, Effect, Console } from 'vivth';
|
|
271
|
+
* import { EventSignal, Effect, Console } from 'vivth/neutral';
|
|
270
272
|
*
|
|
271
273
|
* const myEventSignal = await EventSignal.get('dataEvent', false);
|
|
272
274
|
*
|
|
@@ -280,10 +282,8 @@ export class EventSignal<ISLIST extends boolean> {
|
|
|
280
282
|
ref: () => void;
|
|
281
283
|
};
|
|
282
284
|
};
|
|
283
|
-
#private;
|
|
284
285
|
}
|
|
286
|
+
export type VivthCleanup = import("../typehints/VivthCleanup.mjs").VivthCleanup;
|
|
285
287
|
import { Signal } from './Signal.mjs';
|
|
286
|
-
import { ListSignal } from './ListSignal.mjs';
|
|
287
288
|
import { Derived } from './Derived.mjs';
|
|
288
|
-
import { ListDerived } from './ListDerived.mjs';
|
|
289
289
|
import { QChannel } from './QChannel.mjs';
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import('../typehints/VivthCleanup.mjs').VivthCleanup} VivthCleanup
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* @description
|
|
6
|
+
* - class helper for chokidar abstraction to watch and iterate paths;
|
|
7
|
+
* - this class assume `Paths` and `SafeExit` to be instantiated;
|
|
8
|
+
* @template {any} PASSEDVALUE
|
|
9
|
+
* @implements {VivthCleanup}
|
|
10
|
+
*/
|
|
11
|
+
export class FSDirArchWatcher<PASSEDVALUE extends unknown> implements VivthCleanup {
|
|
12
|
+
/**
|
|
13
|
+
* @description
|
|
14
|
+
* @param {string[]} watchPaths
|
|
15
|
+
* @param {Object} options
|
|
16
|
+
* @param {FSDirArchWatcher<PASSEDVALUE>["eachHandler"]} options.each
|
|
17
|
+
* - throw to `ignore` OR `delete` path from the result passed to `.full`;
|
|
18
|
+
* @param {FSDirArchWatcher<PASSEDVALUE>["fullHandler"]} options.full
|
|
19
|
+
* @param {number} [options.debounce]
|
|
20
|
+
* - debounce on calling `fullHandler`;
|
|
21
|
+
* @param {import('chokidar').ChokidarOptions} [options.chokidarOptions]
|
|
22
|
+
* - `ChokidarOptions`;
|
|
23
|
+
* @example
|
|
24
|
+
* import { FSDirArchWatcher, IsSameFile } from "vivth/node";
|
|
25
|
+
*
|
|
26
|
+
* const settingFile = '/fsrouter.setting.mjs';
|
|
27
|
+
*
|
|
28
|
+
* new FSDirArchWatcher(['/routers/', '/fsrouter.setting.mjs'], {
|
|
29
|
+
* // debounce: 100,
|
|
30
|
+
* each: async (eventName, path, stats) => {
|
|
31
|
+
* // this callback is queued already;
|
|
32
|
+
* // path are already `Paths.normalized`;
|
|
33
|
+
* if(IsSameFile(path, settingFile)){
|
|
34
|
+
* // code;
|
|
35
|
+
* }
|
|
36
|
+
* switch (eventName) {
|
|
37
|
+
* case 'add':
|
|
38
|
+
* case 'change':
|
|
39
|
+
* // structure route here and return;
|
|
40
|
+
* // a throwed call, will delete from sharedMap;
|
|
41
|
+
* return {};
|
|
42
|
+
* default:
|
|
43
|
+
* // only for imperative handler when needed;
|
|
44
|
+
* // or you can just throw here;
|
|
45
|
+
* return {};
|
|
46
|
+
* }
|
|
47
|
+
* // only non throwed call of path is registered to sharedMap;
|
|
48
|
+
* // throwed call of path is unregistered from sharedMap;
|
|
49
|
+
* },
|
|
50
|
+
* full:async (sharedMap) => {
|
|
51
|
+
* // this callback is queued already;
|
|
52
|
+
* // loop through returned from loop then write to a file;
|
|
53
|
+
* },
|
|
54
|
+
* })
|
|
55
|
+
*/
|
|
56
|
+
constructor(watchPaths: string[], { chokidarOptions, each: eachHandler, full: fullHandler, debounce }: {
|
|
57
|
+
each: FSDirArchWatcher<PASSEDVALUE>["eachHandler"];
|
|
58
|
+
full: FSDirArchWatcher<PASSEDVALUE>["fullHandler"];
|
|
59
|
+
debounce?: number | undefined;
|
|
60
|
+
chokidarOptions?: Partial<{
|
|
61
|
+
persistent: boolean;
|
|
62
|
+
ignoreInitial: boolean;
|
|
63
|
+
followSymlinks: boolean;
|
|
64
|
+
cwd?: string;
|
|
65
|
+
usePolling: boolean;
|
|
66
|
+
interval: number;
|
|
67
|
+
binaryInterval: number;
|
|
68
|
+
alwaysStat?: boolean;
|
|
69
|
+
depth?: number;
|
|
70
|
+
ignorePermissionErrors: boolean;
|
|
71
|
+
atomic: boolean | number;
|
|
72
|
+
} & {
|
|
73
|
+
ignored: import("chokidar").Matcher | import("chokidar").Matcher[];
|
|
74
|
+
awaitWriteFinish: boolean | Partial<import("chokidar").AWF>;
|
|
75
|
+
}> | undefined;
|
|
76
|
+
});
|
|
77
|
+
/**
|
|
78
|
+
* @description
|
|
79
|
+
* - callback to handle each path;
|
|
80
|
+
* @type {(
|
|
81
|
+
* eventName: import('chokidar/handler.js').EventName,
|
|
82
|
+
* path: import('chokidar/handler.js').Path,
|
|
83
|
+
* stats?: import('node:fs').Stats,
|
|
84
|
+
* ) => Promise<PASSEDVALUE>
|
|
85
|
+
* }
|
|
86
|
+
*/
|
|
87
|
+
eachHandler: (eventName: import("chokidar/handler.js").EventName, path: import("chokidar/handler.js").Path, stats?: import("node:fs").Stats) => Promise<PASSEDVALUE>;
|
|
88
|
+
/**
|
|
89
|
+
* @description
|
|
90
|
+
* - callback to handle all registered path;
|
|
91
|
+
* - debounced to only handle last changes on full registry with:
|
|
92
|
+
* >- `options.debounce`;
|
|
93
|
+
* >- `QChannel` `isLastOnQ`;
|
|
94
|
+
* @type {(
|
|
95
|
+
* alphabeticallySortedSharedValue: {
|
|
96
|
+
* map: Map<string, PASSEDVALUE>,
|
|
97
|
+
* array: Array<[path: string, PASSEDVALUE]>,
|
|
98
|
+
* }
|
|
99
|
+
* ) => Promise<void>
|
|
100
|
+
* }
|
|
101
|
+
*/
|
|
102
|
+
fullHandler: (alphabeticallySortedSharedValue: {
|
|
103
|
+
map: Map<string, PASSEDVALUE>;
|
|
104
|
+
array: Array<[path: string, PASSEDVALUE]>;
|
|
105
|
+
}) => Promise<void>;
|
|
106
|
+
watcher: import("chokidar").FSWatcher;
|
|
107
|
+
vivthCleanup: () => Promise<void>;
|
|
108
|
+
#private;
|
|
109
|
+
}
|
|
110
|
+
export type VivthCleanup = import("../typehints/VivthCleanup.mjs").VivthCleanup;
|
|
@@ -6,24 +6,33 @@ export class FileSafe {
|
|
|
6
6
|
/**
|
|
7
7
|
* @description
|
|
8
8
|
* - method to safely detects whether filePaths exist;
|
|
9
|
-
* - uses fs/promises
|
|
9
|
+
* - uses `'node:fs/promises'.access` under the hood;
|
|
10
10
|
* - also returning promise of result & error as value;
|
|
11
11
|
* @param {string} filePath
|
|
12
|
-
* @returns {
|
|
12
|
+
* @returns {Promise<boolean>}
|
|
13
13
|
* @example
|
|
14
14
|
* import { join } from 'node:path';
|
|
15
|
-
* import { FileSafe
|
|
15
|
+
* import { FileSafe } from 'vivth/node';
|
|
16
|
+
* import { Paths } from 'vivth/neutral';
|
|
16
17
|
*
|
|
17
|
-
* const
|
|
18
|
+
* const isExist = await FileSafe.exist(
|
|
18
19
|
* join(Paths.root, '/some/path.mjs'),
|
|
19
20
|
* );
|
|
20
|
-
* if (!error) {
|
|
21
|
-
* // file exists
|
|
22
|
-
* } else {
|
|
23
|
-
* // file not exists
|
|
24
|
-
* }
|
|
25
21
|
*/
|
|
26
|
-
static exist: (filePath: string) =>
|
|
22
|
+
static exist: (filePath: string) => Promise<boolean>;
|
|
23
|
+
/**
|
|
24
|
+
* @param { Parameters<writeFile>[1] } string
|
|
25
|
+
* @returns { string }
|
|
26
|
+
*/
|
|
27
|
+
static #normalize: (string: Parameters<typeof writeFile>[1]) => string;
|
|
28
|
+
/**
|
|
29
|
+
* @param {Parameters<FileSafe.write>[0]} outFile
|
|
30
|
+
* @param {Parameters<FileSafe.write>[1]} content
|
|
31
|
+
* @param {Parameters<FileSafe.write>[2]} [options]
|
|
32
|
+
* @param {Parameters<FileSafe.write>[3]} [checkFuzySame]
|
|
33
|
+
* @returns {Promise<boolean>}
|
|
34
|
+
*/
|
|
35
|
+
static #validToOverWrite: (outFile: Parameters<(outFile: Parameters<typeof writeFile>[0], content: Parameters<typeof writeFile>[1], options?: Parameters<typeof writeFile>[2], checkFuzySame?: boolean) => ReturnType<typeof TryAsync<void>>>[0], content: Parameters<(outFile: Parameters<typeof writeFile>[0], content: Parameters<typeof writeFile>[1], options?: Parameters<typeof writeFile>[2], checkFuzySame?: boolean) => ReturnType<typeof TryAsync<void>>>[1], options?: Parameters<(outFile: Parameters<typeof writeFile>[0], content: Parameters<typeof writeFile>[1], options?: Parameters<typeof writeFile>[2], checkFuzySame?: boolean) => ReturnType<typeof TryAsync<void>>>[2], checkFuzySame?: Parameters<(outFile: Parameters<typeof writeFile>[0], content: Parameters<typeof writeFile>[1], options?: Parameters<typeof writeFile>[2], checkFuzySame?: boolean) => ReturnType<typeof TryAsync<void>>>[3]) => Promise<boolean>;
|
|
27
36
|
/**
|
|
28
37
|
* @description
|
|
29
38
|
* - method to create file safely by recursively mkdir the dirname of the outFile;
|
|
@@ -31,10 +40,14 @@ export class FileSafe {
|
|
|
31
40
|
* @param {Parameters<writeFile>[0]} outFile
|
|
32
41
|
* @param {Parameters<writeFile>[1]} content
|
|
33
42
|
* @param {Parameters<writeFile>[2]} [options]
|
|
43
|
+
* @param {boolean} [checkFuzySame]
|
|
44
|
+
* - true: check while normalize consecutive whitespace into singel white space;
|
|
45
|
+
* - false(default): check absolute value;
|
|
34
46
|
* @returns {ReturnType<typeof TryAsync<void>>}
|
|
35
47
|
* @example
|
|
36
48
|
* import { join } from 'node:path';
|
|
37
|
-
* import { FileSafe
|
|
49
|
+
* import { FileSafe } from 'vivth/node';
|
|
50
|
+
* import { Paths } from 'vivth/neutral';
|
|
38
51
|
*
|
|
39
52
|
* const [, errorWrite] = await FileSafe.write(
|
|
40
53
|
* join(Paths.root, '/some/path.mjs'),
|
|
@@ -42,7 +55,7 @@ export class FileSafe {
|
|
|
42
55
|
* { encoding: 'utf-8' }
|
|
43
56
|
* );
|
|
44
57
|
*/
|
|
45
|
-
static write: (outFile: Parameters<typeof writeFile>[0], content: Parameters<typeof writeFile>[1], options?: Parameters<typeof writeFile>[2]) => ReturnType<typeof TryAsync<void>>;
|
|
58
|
+
static write: (outFile: Parameters<typeof writeFile>[0], content: Parameters<typeof writeFile>[1], options?: Parameters<typeof writeFile>[2], checkFuzySame?: boolean) => ReturnType<typeof TryAsync<void>>;
|
|
46
59
|
/**
|
|
47
60
|
* @description
|
|
48
61
|
* - method to copy file/dir safely by recursively mkdir the dirname of the dest;
|
|
@@ -53,7 +66,8 @@ export class FileSafe {
|
|
|
53
66
|
* @returns {ReturnType<typeof TryAsync<void>>}
|
|
54
67
|
* @example
|
|
55
68
|
* import { join } from 'node:path';
|
|
56
|
-
* import { FileSafe
|
|
69
|
+
* import { FileSafe } from 'vivth/node';
|
|
70
|
+
* import { Paths } from 'vivth/neutral';
|
|
57
71
|
*
|
|
58
72
|
* const [, errorWrite] = await FileSafe.copy(
|
|
59
73
|
* join(Paths.root, '/some/path.mjs'),
|
|
@@ -71,7 +85,8 @@ export class FileSafe {
|
|
|
71
85
|
* @returns {ReturnType<typeof TryAsync<void>>}
|
|
72
86
|
* @example
|
|
73
87
|
* import { join } from 'node:path';
|
|
74
|
-
* import { FileSafe
|
|
88
|
+
* import { FileSafe} from 'vivth/node';
|
|
89
|
+
* import { Paths } from 'vivth/neutral';
|
|
75
90
|
*
|
|
76
91
|
* const [, errorRename] = await FileSafe.rename(
|
|
77
92
|
* join(Paths.root, 'some/path'),
|
|
@@ -97,14 +112,15 @@ export class FileSafe {
|
|
|
97
112
|
* @returns {ReturnType<typeof TryAsync<string|undefined>>}
|
|
98
113
|
* @example
|
|
99
114
|
* import { join } from 'node:path';
|
|
100
|
-
* import { FileSafe
|
|
115
|
+
* import { FileSafe } from 'vivth/node';
|
|
116
|
+
* import { Paths } from 'vivth/neutral';
|
|
101
117
|
*
|
|
102
118
|
* const [str, errorMkDir] = await FileSafe.mkdir(join(Paths.root, '/some/path/example'));
|
|
103
119
|
*/
|
|
104
120
|
static mkdir: (outDir: Parameters<typeof mkdir>[0]) => ReturnType<typeof TryAsync<string | undefined>>;
|
|
105
121
|
}
|
|
106
|
-
import { TryAsync } from '../function/TryAsync.mjs';
|
|
107
122
|
import { writeFile } from 'node:fs/promises';
|
|
123
|
+
import { TryAsync } from '../function/TryAsync.mjs';
|
|
108
124
|
import { copyFile } from 'node:fs/promises';
|
|
109
125
|
import { rename } from 'node:fs/promises';
|
|
110
126
|
import { rm } from 'node:fs/promises';
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description
|
|
3
|
+
* - is collections of safe `.forEach` wrapper;
|
|
4
|
+
* >- via [TrySync](#trysync);
|
|
5
|
+
*/
|
|
6
|
+
export class ForEach {
|
|
7
|
+
static #handler: (iter: any, handler: any) => any[];
|
|
8
|
+
/**
|
|
9
|
+
* @description
|
|
10
|
+
* - static method helper for `array` to be iterate safely;
|
|
11
|
+
* @template T, R
|
|
12
|
+
* @param {T[]} array
|
|
13
|
+
* @param {(value: T, index: number, array: T[]) => R} handler
|
|
14
|
+
* @returns {Array<ReturnType<typeof TrySync<R>>>}
|
|
15
|
+
* @example
|
|
16
|
+
* import { Foreach } from 'vivth/neutral';
|
|
17
|
+
*
|
|
18
|
+
* const arr = ['a','b'];
|
|
19
|
+
* ForEach(arr, (string, i, arr_)=>{
|
|
20
|
+
* // unsafe Code
|
|
21
|
+
* });
|
|
22
|
+
*/
|
|
23
|
+
static array<T, R>(array: T[], handler: (value: T, index: number, array: T[]) => R): Array<ReturnType<typeof TrySync<R>>>;
|
|
24
|
+
/**
|
|
25
|
+
* @description
|
|
26
|
+
* - static method helper for `set` to be iterate safely;
|
|
27
|
+
* @template T, R
|
|
28
|
+
* @param {Set<T>} set
|
|
29
|
+
* @param {(value: T, value2: T, set: Set<T>) => R} handler
|
|
30
|
+
* @returns {Array<ReturnType<typeof TrySync<R>>>}
|
|
31
|
+
* @example
|
|
32
|
+
* import { Foreach } from 'vivth/neutral';
|
|
33
|
+
*
|
|
34
|
+
* const set = new Set();
|
|
35
|
+
* ForEach(set, (value, value2, set_)=>{
|
|
36
|
+
* // unsafe Code
|
|
37
|
+
* });
|
|
38
|
+
*/
|
|
39
|
+
static set<T, R>(set: Set<T>, handler: (value: T, value2: T, set: Set<T>) => R): Array<ReturnType<typeof TrySync<R>>>;
|
|
40
|
+
/**
|
|
41
|
+
* @description
|
|
42
|
+
* - static method helper for `map` to be iterate safely;
|
|
43
|
+
* @template K, V, R
|
|
44
|
+
* @param {Map<K,V>} map
|
|
45
|
+
* @param {(value: V, key: K, map: Map<K,V>) => R} handler
|
|
46
|
+
* @returns {Array<ReturnType<typeof TrySync<R>>>}
|
|
47
|
+
* @example
|
|
48
|
+
* import { Foreach } from 'vivth/neutral';
|
|
49
|
+
*
|
|
50
|
+
* const map = new Map();
|
|
51
|
+
* ForEach(map, (value, key, map_)=>{
|
|
52
|
+
* // unsafe Code
|
|
53
|
+
* });
|
|
54
|
+
*/
|
|
55
|
+
static map<K, V, R>(map: Map<K, V>, handler: (value: V, key: K, map: Map<K, V>) => R): Array<ReturnType<typeof TrySync<R>>>;
|
|
56
|
+
}
|
|
57
|
+
import { TrySync } from '../function/TrySync.mjs';
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import('../typehints/VivthCleanup.mjs').VivthCleanup} VivthCleanup
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* @description
|
|
6
|
+
* - this class extends `Signal`;
|
|
7
|
+
* - `ForSignal_instance.runCleanUp` still needs to be manually called, when cleaning up this instance;
|
|
8
|
+
* @template {any} TYPE
|
|
9
|
+
* @implements {VivthCleanup}
|
|
10
|
+
* @extends {Signal<Array<TYPE|undefined>>}
|
|
11
|
+
*/
|
|
12
|
+
export class ForSignal<TYPE extends unknown> extends Signal<(TYPE | undefined)[]> implements VivthCleanup {
|
|
13
|
+
/**
|
|
14
|
+
* @description
|
|
15
|
+
* @param {(
|
|
16
|
+
* this: ForSignal<TYPE>,
|
|
17
|
+
* arg:{
|
|
18
|
+
* index:number,
|
|
19
|
+
* value:{ value:TYPE, isValueDefined:true, }|
|
|
20
|
+
* { value:undefined, isValueDefined:false, },
|
|
21
|
+
* prev:{ prev:TYPE, isPrevDefined:true, }|
|
|
22
|
+
* { prev:undefined, isPrevDefined:false, },
|
|
23
|
+
* })=>void
|
|
24
|
+
* } loopCallback
|
|
25
|
+
* - the diffence of `current` and `prev` or `isValueDefined` and `isPrevDefined` can be used for sideEffect, such as;
|
|
26
|
+
* >- `adding/removing/modifiying` `childNode`s on a parent element;
|
|
27
|
+
* >- `adding/removing/modifiying` `Signal` instances;
|
|
28
|
+
* @param {()=>void} [additionalCleanUp]
|
|
29
|
+
* - additional callback to be run when runCleanUp is called;
|
|
30
|
+
* @example
|
|
31
|
+
* import { ForSignal } from 'vivth/neutral';
|
|
32
|
+
*
|
|
33
|
+
* const myLoop = new ForSignal(
|
|
34
|
+
* function ({ index, value: {value, isValueDefined}, prev:{ prev, isPrevDefined} }) {
|
|
35
|
+
* // code
|
|
36
|
+
* },
|
|
37
|
+
* () => {
|
|
38
|
+
* // additional cleanup code
|
|
39
|
+
* }
|
|
40
|
+
* )
|
|
41
|
+
* // myLoop.runCleanUp(); // need to be called manually when the instance are to out of scope;
|
|
42
|
+
*/
|
|
43
|
+
constructor(loopCallback: (this: ForSignal<TYPE>, arg: {
|
|
44
|
+
index: number;
|
|
45
|
+
value: {
|
|
46
|
+
value: TYPE;
|
|
47
|
+
isValueDefined: true;
|
|
48
|
+
} | {
|
|
49
|
+
value: undefined;
|
|
50
|
+
isValueDefined: false;
|
|
51
|
+
};
|
|
52
|
+
prev: {
|
|
53
|
+
prev: TYPE;
|
|
54
|
+
isPrevDefined: true;
|
|
55
|
+
} | {
|
|
56
|
+
prev: undefined;
|
|
57
|
+
isPrevDefined: false;
|
|
58
|
+
};
|
|
59
|
+
}) => void, additionalCleanUp?: () => void);
|
|
60
|
+
#private;
|
|
61
|
+
}
|
|
62
|
+
export type VivthCleanup = import("../typehints/VivthCleanup.mjs").VivthCleanup;
|
|
63
|
+
import { Signal } from './Signal.mjs';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description
|
|
3
|
+
* - create getter setter in one place;
|
|
4
|
+
* @template {any} RET
|
|
5
|
+
* @template {((...any:any[])=>RET)} TG
|
|
6
|
+
* @template {((...any:any[])=>void)} TS
|
|
7
|
+
* @example
|
|
8
|
+
* import { GetterSetter } from 'vivth/neutral';
|
|
9
|
+
*
|
|
10
|
+
* const localA = new GetterSetter({
|
|
11
|
+
* get:() => {
|
|
12
|
+
* return localStorage.getItem('myAValue');
|
|
13
|
+
* },
|
|
14
|
+
* set:(newValue) => {
|
|
15
|
+
* return localStorage.setItem('myAValue', newValue);
|
|
16
|
+
* },
|
|
17
|
+
* });
|
|
18
|
+
* localA.get(); // null;
|
|
19
|
+
* localA.set('my new value');
|
|
20
|
+
* localA.get(); // 'my new value'
|
|
21
|
+
*/
|
|
22
|
+
export class GetterSetter<RET extends unknown, TG extends ((...any: any[]) => RET), TS extends ((...any: any[]) => void)> {
|
|
23
|
+
/**
|
|
24
|
+
* @param {{ get?: TG, set?: TS }} options
|
|
25
|
+
*/
|
|
26
|
+
constructor({ get, set }: {
|
|
27
|
+
get?: TG;
|
|
28
|
+
set?: TS;
|
|
29
|
+
});
|
|
30
|
+
/**
|
|
31
|
+
* @type {ConstructorParameters<typeof GetterSetter<RET,TG,TS>>[0]["get"]}
|
|
32
|
+
*/
|
|
33
|
+
get: ConstructorParameters<typeof GetterSetter<RET, TG, TS>>[0]["get"];
|
|
34
|
+
/**
|
|
35
|
+
* @type {ConstructorParameters<typeof GetterSetter<RET,TG,TS>>[0]["set"]}
|
|
36
|
+
*/
|
|
37
|
+
set: ConstructorParameters<typeof GetterSetter<RET, TG, TS>>[0]["set"];
|
|
38
|
+
}
|