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,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description
|
|
3
|
+
* - class helpers to define pathReference;
|
|
4
|
+
* - is a singleton;
|
|
5
|
+
* - most of functionality need to access `Paths.root`, if you get warning, you can instantiate `Paths` before running anything;
|
|
6
|
+
*/
|
|
7
|
+
export class Paths {
|
|
8
|
+
/**
|
|
9
|
+
* @type {Paths|undefined}
|
|
10
|
+
*/
|
|
11
|
+
static #instance: Paths | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* @description
|
|
14
|
+
* - MIGHT THROW AN ERROR;
|
|
15
|
+
* >- most `vivth` modules uses this value, so you need to instantiate Paths by all means before using them;
|
|
16
|
+
* - reference for rootPath
|
|
17
|
+
* - `Paths` needed to be instantiated via:
|
|
18
|
+
* >- `Paths` constructor;
|
|
19
|
+
* >- `Setup.paths` constructor;
|
|
20
|
+
* @type {string}
|
|
21
|
+
*/
|
|
22
|
+
static get root(): string;
|
|
23
|
+
/**
|
|
24
|
+
* @description
|
|
25
|
+
* - replace path separator to forward slash `/`;
|
|
26
|
+
* - remove repeating `./`;
|
|
27
|
+
* @param {string} path
|
|
28
|
+
* @returns {string}
|
|
29
|
+
* @example
|
|
30
|
+
* import { Paths } from 'vivth/neutral';
|
|
31
|
+
*
|
|
32
|
+
* Paths.normalize('file:\\D:\\myFile.mjs'); // "file://D://myFile.mjs"
|
|
33
|
+
*/
|
|
34
|
+
static normalize: (path: string) => string;
|
|
35
|
+
/**
|
|
36
|
+
* @description
|
|
37
|
+
* - replace path separator to `sep`;
|
|
38
|
+
* @param {string} path
|
|
39
|
+
* @returns {string}
|
|
40
|
+
* @example
|
|
41
|
+
* import { Paths } from 'vivth/neutral';
|
|
42
|
+
*
|
|
43
|
+
* Paths.nativeSep('path//myFile.mjs'); // "path\myFile.mjs" OR "path/myFile.mjs" depending on sep value;
|
|
44
|
+
*/
|
|
45
|
+
static nativeSep: (path: string) => string;
|
|
46
|
+
/**
|
|
47
|
+
* @description
|
|
48
|
+
* - normalized then starts with forward slash `/`;
|
|
49
|
+
* @param {string} path
|
|
50
|
+
* @returns {`/${string}`}
|
|
51
|
+
* @example
|
|
52
|
+
* import { Paths } from 'vivth/neutral';
|
|
53
|
+
*
|
|
54
|
+
* Paths.normalizesForRoot('path\\myFile.mjs'); // "/path/myFile.mjs"
|
|
55
|
+
*/
|
|
56
|
+
static normalizeForRoot: (path: string) => `/${string}`;
|
|
57
|
+
/**
|
|
58
|
+
* @description
|
|
59
|
+
* - convert path to diskAbsolute and normalized to be using forward slash;
|
|
60
|
+
* - usefull for arguments for `methods` OR `functions` that needs to be absolute disk path, regardles if path is relative to project root, or already absolute path;
|
|
61
|
+
* @param {string} path
|
|
62
|
+
* @returns {string}
|
|
63
|
+
* @example
|
|
64
|
+
* import { Paths } from 'vivth/neutral';
|
|
65
|
+
*
|
|
66
|
+
* Paths.normalizesForRoot('\\path\\myFile.mjs'); // "D://something/path/myFile.mjs"
|
|
67
|
+
*/
|
|
68
|
+
static diskAbsolute: (path: string) => string;
|
|
69
|
+
/**
|
|
70
|
+
* @description
|
|
71
|
+
* @param {Object} options
|
|
72
|
+
* @param {string} options.root
|
|
73
|
+
* - browser:
|
|
74
|
+
* ```js
|
|
75
|
+
* location.origin
|
|
76
|
+
* ```
|
|
77
|
+
* - node/bun compatible:
|
|
78
|
+
* ```js
|
|
79
|
+
* import process from 'node:process';
|
|
80
|
+
* process.env.INIT_CWD ?? process.cwd()
|
|
81
|
+
* ```
|
|
82
|
+
* - other: you need to check your JSRuntime for the rootPath reference;
|
|
83
|
+
* @example
|
|
84
|
+
* import { Paths } from 'vivth/neutral';
|
|
85
|
+
*
|
|
86
|
+
* new Paths({
|
|
87
|
+
* // root: location.origin,
|
|
88
|
+
* // root: process.env.INIT_CWD ?? process.cwd(),
|
|
89
|
+
* })
|
|
90
|
+
*/
|
|
91
|
+
constructor({ root }: {
|
|
92
|
+
root: string;
|
|
93
|
+
});
|
|
94
|
+
#private;
|
|
95
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description
|
|
3
|
+
* - `prettier` wrapper with option inference from path;
|
|
4
|
+
*/
|
|
5
|
+
export class Prettivy {
|
|
6
|
+
static #q: QChannel<import("../typehints/AnyButUndefined.mjs").AnyButUndefined> & {
|
|
7
|
+
[x: symbol]: QChannel<import("../typehints/AnyButUndefined.mjs").AnyButUndefined>;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* @param {string} path
|
|
11
|
+
*/
|
|
12
|
+
constructor(path: string);
|
|
13
|
+
/**
|
|
14
|
+
* @type {string}
|
|
15
|
+
*/
|
|
16
|
+
path: string;
|
|
17
|
+
getOptions: () => Promise<import("prettier").Options | null | undefined>;
|
|
18
|
+
options: import("prettier").Options | null | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* @param {string} contentBeforePrettified
|
|
21
|
+
* @returns {Promise<string>}
|
|
22
|
+
*/
|
|
23
|
+
format: (contentBeforePrettified: string) => Promise<string>;
|
|
24
|
+
#private;
|
|
25
|
+
}
|
|
26
|
+
import { QChannel } from './QChannel.mjs';
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef { import('../typehints/VivthCleanup.mjs').VivthCleanup } VivthCleanup
|
|
3
|
+
*/
|
|
1
4
|
/**
|
|
2
5
|
* @description
|
|
3
6
|
* - class for `Queue` handling;
|
|
4
7
|
* @template {AnyButUndefined} DEFINEDANY
|
|
8
|
+
* @implements {VivthCleanup}
|
|
5
9
|
*/
|
|
6
|
-
export class QChannel<DEFINEDANY extends import("../
|
|
10
|
+
export class QChannel<DEFINEDANY extends import("../typehints/AnyButUndefined.mjs").AnyButUndefined> implements VivthCleanup {
|
|
7
11
|
/**
|
|
8
|
-
* @typedef {import('../
|
|
9
|
-
* @typedef {import('../
|
|
10
|
-
* @typedef {import('../
|
|
12
|
+
* @typedef {import('../typehints/AnyButUndefined.mjs').AnyButUndefined} AnyButUndefined
|
|
13
|
+
* @typedef {import('../typehints/QCBReturn.mjs').QCBReturn} QCBReturn
|
|
14
|
+
* @typedef {import('../typehints/QCBFIFOReturn.mjs').QCBFIFOReturn} QCBFIFOReturn
|
|
11
15
|
*/
|
|
12
16
|
/**
|
|
13
17
|
* @description
|
|
@@ -16,16 +20,16 @@ export class QChannel<DEFINEDANY extends import("../types/AnyButUndefined.mjs").
|
|
|
16
20
|
* @returns {typeof QChannel}
|
|
17
21
|
* - usefull for Queue primitive on multiple library but single reference, like the Web by making the `Map` on `window` object;
|
|
18
22
|
* @example
|
|
19
|
-
* import { QChannel } from 'vivth';
|
|
23
|
+
* import { QChannel } from 'vivth/neutral';
|
|
20
24
|
*
|
|
21
25
|
* const myMappedQref = (window['myMappedQref'] = new Map());
|
|
22
26
|
* export const MyQClass = QChannel.setup(myMappedQref);
|
|
23
27
|
*/
|
|
24
|
-
static setup: (uniqueMap: Map<import("../
|
|
28
|
+
static setup: (uniqueMap: Map<import("../typehints/AnyButUndefined.mjs").AnyButUndefined, [Promise<any>, {}]>) => typeof QChannel;
|
|
25
29
|
/**
|
|
26
30
|
* @type {Map<AnyButUndefined, [Promise<any>, {}]>}
|
|
27
31
|
*/
|
|
28
|
-
static
|
|
32
|
+
static #uniquePromiser: Map<import("../typehints/AnyButUndefined.mjs").AnyButUndefined, [Promise<any>, {}]>;
|
|
29
33
|
/**
|
|
30
34
|
* - ensures that each id has only one task running at a time.
|
|
31
35
|
* - calls with the same id will wait for the previous call to finish.
|
|
@@ -33,7 +37,7 @@ export class QChannel<DEFINEDANY extends import("../types/AnyButUndefined.mjs").
|
|
|
33
37
|
* @param {QChannel<any>} instance
|
|
34
38
|
* @returns {Promise<QCBReturn>} Resolves when it's safe to proceed for the given id, returning a cleanup function
|
|
35
39
|
*/
|
|
36
|
-
static
|
|
40
|
+
static #uniqueCB: (id: import("../typehints/AnyButUndefined.mjs").AnyButUndefined, instance: QChannel<any>) => Promise<import("../typehints/QCBReturn.mjs").QCBReturn>;
|
|
37
41
|
/**
|
|
38
42
|
* @description
|
|
39
43
|
* - first in first out handler
|
|
@@ -49,7 +53,7 @@ export class QChannel<DEFINEDANY extends import("../types/AnyButUndefined.mjs").
|
|
|
49
53
|
* // blocks all `FIFO` called using this method and QChannel.fifoCallback;
|
|
50
54
|
* resume();
|
|
51
55
|
*/
|
|
52
|
-
key: () => Promise<import("../
|
|
56
|
+
key: () => Promise<import("../typehints/QCBFIFOReturn.mjs").QCBFIFOReturn>;
|
|
53
57
|
/**
|
|
54
58
|
* @static fifo
|
|
55
59
|
* @description
|
|
@@ -64,7 +68,7 @@ export class QChannel<DEFINEDANY extends import("../types/AnyButUndefined.mjs").
|
|
|
64
68
|
*/
|
|
65
69
|
callback: <RESULT>(asyncCallback: () => Promise<RESULT>) => ReturnType<typeof TryAsync<RESULT>>;
|
|
66
70
|
} & {
|
|
67
|
-
|
|
71
|
+
[x: symbol]: {
|
|
68
72
|
/**
|
|
69
73
|
* @static fifo
|
|
70
74
|
* @description
|
|
@@ -75,7 +79,7 @@ export class QChannel<DEFINEDANY extends import("../types/AnyButUndefined.mjs").
|
|
|
75
79
|
* // blocks all `FIFO` called using this method and QChannel.fifoCallback;
|
|
76
80
|
* resume();
|
|
77
81
|
*/
|
|
78
|
-
key: () => Promise<import("../
|
|
82
|
+
key: () => Promise<import("../typehints/QCBFIFOReturn.mjs").QCBFIFOReturn>;
|
|
79
83
|
/**
|
|
80
84
|
* @static fifo
|
|
81
85
|
* @description
|
|
@@ -94,21 +98,23 @@ export class QChannel<DEFINEDANY extends import("../types/AnyButUndefined.mjs").
|
|
|
94
98
|
/**
|
|
95
99
|
* @param {string} name
|
|
96
100
|
* - only used as helper for logging, and has nothing to do with runtime behaviour;
|
|
101
|
+
* @param {boolean} [log]
|
|
97
102
|
*/
|
|
98
|
-
constructor(name: string);
|
|
103
|
+
constructor(name: string, log?: boolean);
|
|
104
|
+
vivthCleanup: () => Promise<void>;
|
|
99
105
|
name: string;
|
|
100
106
|
/**
|
|
101
107
|
* @description
|
|
102
108
|
* - disable queue;
|
|
103
109
|
* - when `closed`, `isLastOnQ` will allways return `false`;
|
|
104
|
-
* @
|
|
110
|
+
* @type {()=>void}
|
|
105
111
|
*/
|
|
106
112
|
close: () => void;
|
|
107
113
|
/**
|
|
108
114
|
* @description
|
|
109
115
|
* - enable queue;
|
|
110
116
|
* - when `opened`, `isLastOnQ` will evaluate whether calls are actually the last of queue;
|
|
111
|
-
* @
|
|
117
|
+
* @type {()=>void}
|
|
112
118
|
*/
|
|
113
119
|
open: () => void;
|
|
114
120
|
/**
|
|
@@ -134,7 +140,7 @@ export class QChannel<DEFINEDANY extends import("../types/AnyButUndefined.mjs").
|
|
|
134
140
|
* }
|
|
135
141
|
* handler();
|
|
136
142
|
*/
|
|
137
|
-
key: (keyID: DEFINEDANY) => Promise<import("../
|
|
143
|
+
key: (keyID: DEFINEDANY) => Promise<import("../typehints/QCBReturn.mjs").QCBReturn>;
|
|
138
144
|
/**
|
|
139
145
|
* @description
|
|
140
146
|
* - `callbackBlock` with error as value:
|
|
@@ -154,9 +160,11 @@ export class QChannel<DEFINEDANY extends import("../types/AnyButUndefined.mjs").
|
|
|
154
160
|
* // return;
|
|
155
161
|
* // }
|
|
156
162
|
* // code
|
|
163
|
+
* // return result
|
|
157
164
|
* })
|
|
158
165
|
*/
|
|
159
|
-
callback<RESULT>(keyID: DEFINEDANY, asyncCallback: (options: Omit<import("../
|
|
166
|
+
callback<RESULT>(keyID: DEFINEDANY, asyncCallback: (options: Omit<import("../typehints/QCBReturn.mjs").QCBReturn, "resume">) => Promise<RESULT>): ReturnType<typeof TryAsync<RESULT>>;
|
|
160
167
|
#private;
|
|
161
168
|
}
|
|
169
|
+
export type VivthCleanup = import("../typehints/VivthCleanup.mjs").VivthCleanup;
|
|
162
170
|
import { TryAsync } from '../function/TryAsync.mjs';
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description
|
|
3
|
+
* - class helper for describing how to Safely Response on exit events
|
|
4
|
+
* - singleton;
|
|
5
|
+
* - most of functionality might need to access `SafeExit.instance.exiting`, if you get warning, you can instantiate `SafeExit` before running anything;
|
|
6
|
+
*/
|
|
7
|
+
export class SafeExit {
|
|
8
|
+
/**
|
|
9
|
+
* @description
|
|
10
|
+
* - only accessible after instantiation;
|
|
11
|
+
* @type {SafeExit|undefined}
|
|
12
|
+
*/
|
|
13
|
+
static instance: SafeExit | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* @description
|
|
16
|
+
* @param {...NodeJS.Signals} eventNames
|
|
17
|
+
* - `beforeExit` is auto included;
|
|
18
|
+
* - example:
|
|
19
|
+
* ```js
|
|
20
|
+
* ['SIGINT', 'SIGTERM'] // both are automatically added
|
|
21
|
+
* ```
|
|
22
|
+
* @example
|
|
23
|
+
* import process from 'node:process';
|
|
24
|
+
* import { SafeExit } from 'vivth/node';
|
|
25
|
+
*
|
|
26
|
+
* new SafeExit('SIGINT', 'SIGTERM', ...eventNames);
|
|
27
|
+
*/
|
|
28
|
+
constructor(...eventNames: NodeJS.Signals[]);
|
|
29
|
+
/**
|
|
30
|
+
* @type {Set<()=>Promise<void>>}
|
|
31
|
+
*/
|
|
32
|
+
safeCleanUpCBs: Set<() => Promise<void>>;
|
|
33
|
+
/**
|
|
34
|
+
* @description
|
|
35
|
+
* - `SafeExit` ${eventName}.Callback registration;
|
|
36
|
+
* - `onEventName` all callbacks are called simultanousely using `await Promise.all`;
|
|
37
|
+
* >- for sequential event you need to put them in a single callback;
|
|
38
|
+
* @param {()=>(Promise<void>)} safeExitCallback
|
|
39
|
+
* @returns {{removeCallback:()=>void}}
|
|
40
|
+
* @example
|
|
41
|
+
* import { SafeExit } from 'vivth/node';
|
|
42
|
+
*
|
|
43
|
+
* const exitCallback = async () => {
|
|
44
|
+
* // code
|
|
45
|
+
* }
|
|
46
|
+
* SafeExit.instance.addCallback(exitCallback);
|
|
47
|
+
*/
|
|
48
|
+
addCallback: (safeExitCallback: () => (Promise<void>)) => {
|
|
49
|
+
removeCallback: () => void;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* @description
|
|
53
|
+
* - optional exit event removal;
|
|
54
|
+
* - the callbacks will be removed from registered via `addCallback` exiting;
|
|
55
|
+
* @param {()=>(Promise<void>)} cb
|
|
56
|
+
* @example
|
|
57
|
+
* import { SafeExit } from 'vivth/node';
|
|
58
|
+
*
|
|
59
|
+
* const exitCallback () => {
|
|
60
|
+
* // code
|
|
61
|
+
* }
|
|
62
|
+
* SafeExit.instance.addCallback(exitCallback);
|
|
63
|
+
* // somewhere else
|
|
64
|
+
* SafeExit.instance.removeCallback(exitCallback);
|
|
65
|
+
*/
|
|
66
|
+
removeCallback: (cb: () => (Promise<void>)) => void;
|
|
67
|
+
triggerExit: () => Promise<void>;
|
|
68
|
+
#private;
|
|
69
|
+
}
|
|
@@ -7,27 +7,16 @@ export class Setup {
|
|
|
7
7
|
* @description
|
|
8
8
|
* - proxy `SafeExit_instance` for Setup
|
|
9
9
|
* @example
|
|
10
|
-
* import { Setup
|
|
10
|
+
* import { Setup } from 'vivth/node';
|
|
11
11
|
*
|
|
12
|
-
* new Setup.safeExit(
|
|
13
|
-
* // eventNames are blank by default, you need to manually name them all;
|
|
14
|
-
* // 'exit' will be omited, as it might cause async callbacks failed to execute;
|
|
15
|
-
* eventNames: ['SIGINT', 'SIGTERM', ...eventNames],
|
|
16
|
-
* terminator : () => process.exit(0),
|
|
17
|
-
* listener : (eventName) => {
|
|
18
|
-
* process.once(eventName, function () {
|
|
19
|
-
* SafeExit.instance?.exiting.correction(true);
|
|
20
|
-
* Console.log(`safe exit via "${eventName}"`);
|
|
21
|
-
* });
|
|
22
|
-
* }
|
|
23
|
-
* });
|
|
12
|
+
* new Setup.safeExit('SIGINT', 'SIGTERM', ...eventNames);
|
|
24
13
|
*/
|
|
25
14
|
static safeExit: typeof SafeExit;
|
|
26
15
|
/**
|
|
27
16
|
* @description
|
|
28
17
|
* - proxy `Paths_instance` for Setup;
|
|
29
18
|
* @example
|
|
30
|
-
* import { Setup } from 'vivth';
|
|
19
|
+
* import { Setup } from 'vivth/node';
|
|
31
20
|
*
|
|
32
21
|
* new Setup.paths({
|
|
33
22
|
* root: location.origin, // browser example
|
|
@@ -38,7 +27,7 @@ export class Setup {
|
|
|
38
27
|
* @description
|
|
39
28
|
* - proxy `WorkerMainThread_instance` for Setup;
|
|
40
29
|
* @example
|
|
41
|
-
* import { Setup } from 'vivth';
|
|
30
|
+
* import { Setup } from 'vivth/node';
|
|
42
31
|
* import { Worker } from 'node:worker_threads';
|
|
43
32
|
*
|
|
44
33
|
* Setup.workerMain({
|
|
@@ -60,7 +49,7 @@ export class Setup {
|
|
|
60
49
|
* - correct `parentPort` reference when needed;
|
|
61
50
|
* - export to create new reference to be use to create new WorkerThread instance;
|
|
62
51
|
* @example
|
|
63
|
-
* import { Setup } from 'vivth';
|
|
52
|
+
* import { Setup } from 'vivth/node';
|
|
64
53
|
* import { parentPort } from 'node:worker_threads';
|
|
65
54
|
*
|
|
66
55
|
* export const MyWorkerThreadRef = Setup.workerThread({parentPort});
|
|
@@ -68,8 +57,32 @@ export class Setup {
|
|
|
68
57
|
* // you need to call this method;
|
|
69
58
|
*/
|
|
70
59
|
static workerThread: typeof WorkerThread.setup;
|
|
60
|
+
/**
|
|
61
|
+
* @description
|
|
62
|
+
* - setup envMode into `developement`('default') or `production`;
|
|
63
|
+
* @example
|
|
64
|
+
* import { Setup } from 'vivth/node';
|
|
65
|
+
*
|
|
66
|
+
* Setup.enforceEnvMode('prod');
|
|
67
|
+
*
|
|
68
|
+
* // default behaviour, technically only need to be call for reactive functionality;
|
|
69
|
+
* Setup.enforceEnvMode('dev');
|
|
70
|
+
*/
|
|
71
|
+
static enforceEnvMode: (mode: EnvModeType) => void;
|
|
72
|
+
/**
|
|
73
|
+
* @description
|
|
74
|
+
* - setup `vivth `preffered encoding;
|
|
75
|
+
* @example
|
|
76
|
+
* import { Setup } from 'vivth/node';
|
|
77
|
+
*
|
|
78
|
+
* Setup.preferrence({ encoding: 'utf-8' });
|
|
79
|
+
*/
|
|
80
|
+
static preferrence: ({ encoding }: {
|
|
81
|
+
encoding: (typeof Preferrence)["encoding"];
|
|
82
|
+
}) => void;
|
|
71
83
|
}
|
|
72
84
|
import { SafeExit } from './SafeExit.mjs';
|
|
73
85
|
import { Paths } from './Paths.mjs';
|
|
74
86
|
import { WorkerMainThread } from './WorkerMainThread.mjs';
|
|
75
87
|
import { WorkerThread } from './WorkerThread.mjs';
|
|
88
|
+
import { Preferrence } from '../common/Preferrence.mjs';
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef { import('../typehints/VivthCleanup.mjs').VivthCleanup } VivthCleanup
|
|
3
|
+
*/
|
|
1
4
|
/**
|
|
2
5
|
* @type {Set<Signal<any>>}
|
|
3
6
|
*/
|
|
@@ -6,22 +9,29 @@ export const setOFSignals: Set<Signal<any>>;
|
|
|
6
9
|
* @description
|
|
7
10
|
* - a class for creating effect to signals;
|
|
8
11
|
* @template VALUE
|
|
12
|
+
* @implements {VivthCleanup}
|
|
9
13
|
*/
|
|
10
|
-
export class Signal<VALUE> {
|
|
14
|
+
export class Signal<VALUE> implements VivthCleanup {
|
|
11
15
|
/**
|
|
12
16
|
* @param {Signal<any>} signalInstance
|
|
17
|
+
* @param {(error:Error|undefined)=>void} [afterCompletion]
|
|
18
|
+
* @returns {Promise<void>}
|
|
13
19
|
*/
|
|
14
|
-
static
|
|
20
|
+
static #notify: (signalInstance: Signal<any>, afterCompletion?: (error: Error | undefined) => void) => Promise<void>;
|
|
15
21
|
/**
|
|
16
22
|
* @description
|
|
17
23
|
* - create a `Signal`;
|
|
18
24
|
* @param {VALUE} value
|
|
25
|
+
* @param {(data:DataLog<VALUE>)=>void} [performanceChangesReport]
|
|
26
|
+
* - callback independent from effect;
|
|
27
|
+
* >- it will always be called when there's value change;
|
|
19
28
|
* @example
|
|
20
|
-
* import { Signal, Effect } from
|
|
29
|
+
* import { Signal, Effect } from 'vivth/neutral';
|
|
21
30
|
*
|
|
22
31
|
* const count = new Signal(0);
|
|
23
32
|
*/
|
|
24
|
-
constructor(value: VALUE);
|
|
33
|
+
constructor(value: VALUE, performanceChangesReport?: (data: DataLog<VALUE>) => void);
|
|
34
|
+
vivthCleanup: () => Promise<void>;
|
|
25
35
|
/**
|
|
26
36
|
* @description
|
|
27
37
|
* - subsrcibers reference of this instance;
|
|
@@ -39,9 +49,10 @@ export class Signal<VALUE> {
|
|
|
39
49
|
* @description
|
|
40
50
|
* - manually notify on non primitive value or value that have depths;
|
|
41
51
|
* @param {(options:{signalInstance:Signal<VALUE>})=>Promise<void>} [callback]
|
|
42
|
-
* @
|
|
52
|
+
* @param {(error:Error|undefined)=>Promise<void>} [afterCompletion]
|
|
53
|
+
* @returns {Promise<void>}
|
|
43
54
|
* @example
|
|
44
|
-
* import { Signal } from 'vivth';
|
|
55
|
+
* import { Signal } from 'vivth/neutral';
|
|
45
56
|
*
|
|
46
57
|
* // for deep signal like array or object you can:
|
|
47
58
|
* const arraySignal = new Signal([1,2]);
|
|
@@ -57,9 +68,9 @@ export class Signal<VALUE> {
|
|
|
57
68
|
*/
|
|
58
69
|
notify: (callback?: (options: {
|
|
59
70
|
signalInstance: Signal<VALUE>;
|
|
60
|
-
}) => Promise<void>) => void
|
|
71
|
+
}) => Promise<void>, afterCompletion?: (error: Error | undefined) => Promise<void>) => Promise<void>;
|
|
61
72
|
} & {
|
|
62
|
-
|
|
73
|
+
[x: symbol]: {
|
|
63
74
|
/**
|
|
64
75
|
* @instance subscribers
|
|
65
76
|
* @description
|
|
@@ -72,9 +83,10 @@ export class Signal<VALUE> {
|
|
|
72
83
|
* @description
|
|
73
84
|
* - manually notify on non primitive value or value that have depths;
|
|
74
85
|
* @param {(options:{signalInstance:Signal<VALUE>})=>Promise<void>} [callback]
|
|
75
|
-
* @
|
|
86
|
+
* @param {(error:Error|undefined)=>Promise<void>} [afterCompletion]
|
|
87
|
+
* @returns {Promise<void>}
|
|
76
88
|
* @example
|
|
77
|
-
* import { Signal } from 'vivth';
|
|
89
|
+
* import { Signal } from 'vivth/neutral';
|
|
78
90
|
*
|
|
79
91
|
* // for deep signal like array or object you can:
|
|
80
92
|
* const arraySignal = new Signal([1,2]);
|
|
@@ -90,7 +102,7 @@ export class Signal<VALUE> {
|
|
|
90
102
|
*/
|
|
91
103
|
notify: (callback?: (options: {
|
|
92
104
|
signalInstance: Signal<VALUE>;
|
|
93
|
-
}) => Promise<void>) => void
|
|
105
|
+
}) => Promise<void>, afterCompletion?: (error: Error | undefined) => Promise<void>) => Promise<void>;
|
|
94
106
|
};
|
|
95
107
|
};
|
|
96
108
|
/**
|
|
@@ -121,7 +133,7 @@ export class Signal<VALUE> {
|
|
|
121
133
|
*/
|
|
122
134
|
ref: () => void;
|
|
123
135
|
} & {
|
|
124
|
-
|
|
136
|
+
[x: symbol]: {
|
|
125
137
|
/**
|
|
126
138
|
* @instance remove
|
|
127
139
|
* @description
|
|
@@ -157,7 +169,7 @@ export class Signal<VALUE> {
|
|
|
157
169
|
* - assign new value then automatically notify all subscribers;
|
|
158
170
|
* @type {VALUE}
|
|
159
171
|
* @example
|
|
160
|
-
* import { Signal } from
|
|
172
|
+
* import { Signal } from 'vivth/neutral';
|
|
161
173
|
*
|
|
162
174
|
* const count = new Signal(0);
|
|
163
175
|
* count.value++;
|
|
@@ -170,7 +182,7 @@ export class Signal<VALUE> {
|
|
|
170
182
|
* - value after change;
|
|
171
183
|
* @returns {VALUE}
|
|
172
184
|
* @example
|
|
173
|
-
* import { Signal, Effect, Derived } from
|
|
185
|
+
* import { Signal, Effect, Derived } from 'vivth/neutral';
|
|
174
186
|
*
|
|
175
187
|
* const count = new Signal(0);
|
|
176
188
|
* count.value; // not reactive
|
|
@@ -178,11 +190,13 @@ export class Signal<VALUE> {
|
|
|
178
190
|
* new Effect(async ({ subscribe }) =>{
|
|
179
191
|
* const countValue = subscribe(count).value; // reactive
|
|
180
192
|
* })
|
|
181
|
-
* const oneMoreThanCount = new Derived(async ({ subscribe })
|
|
193
|
+
* const oneMoreThanCount = new Derived(async function({ subscribe }){
|
|
182
194
|
* return subscribe(count).value + 1; // reactive
|
|
183
195
|
* })
|
|
184
196
|
*/
|
|
185
197
|
get value(): VALUE;
|
|
186
198
|
#private;
|
|
187
199
|
}
|
|
200
|
+
export type VivthCleanup = import("../typehints/VivthCleanup.mjs").VivthCleanup;
|
|
188
201
|
import { Effect } from './Effect.mjs';
|
|
202
|
+
import { DataLog } from './DataLog.mjs';
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import('../typehints/VivthCleanup.mjs').VivthCleanup} VivthCleanup
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* @description
|
|
6
|
+
* - class helper for creating Collection of `Signals` for Object of Signals to be subscribed to(on `Effect`/`Derived`) collectively as signals;
|
|
7
|
+
* >- uses as `Facade` Pattern;
|
|
8
|
+
* @template {Record<string, import('./Signal.mjs').Signal<any>>} SIGNALS
|
|
9
|
+
* @implements {VivthCleanup}
|
|
10
|
+
*/
|
|
11
|
+
export class SignalCollection<SIGNALS extends Record<string, import("./Signal.mjs").Signal<any>>> implements VivthCleanup {
|
|
12
|
+
/**
|
|
13
|
+
* @description
|
|
14
|
+
* - creates instance of `SignalCollection`, by referencing to named Signal;
|
|
15
|
+
* @param {SIGNALS} signalsObject
|
|
16
|
+
* @example
|
|
17
|
+
* import { Signal, Derived, SignalCollection } from 'vivth/neutral';
|
|
18
|
+
*
|
|
19
|
+
* const a = new Signal('a');
|
|
20
|
+
* const b = new Signal('b');
|
|
21
|
+
* const c = new Derived(async ({ subscribe }) => {
|
|
22
|
+
* return `${subscribe(b).value}_b`;
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
* const f = new SignalCollection({ a, c });
|
|
26
|
+
*/
|
|
27
|
+
constructor(signalsObject: SIGNALS);
|
|
28
|
+
vivthCleanup: () => Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* @description
|
|
31
|
+
* - accessor for signals, to be subscribed to;
|
|
32
|
+
* @param {import('./Effect.mjs').Effect["options"]["subscribe"]} [subscribe]
|
|
33
|
+
* @returns {SIGNALS}
|
|
34
|
+
* @example
|
|
35
|
+
* import { Signal, Derived, Effect, SignalCollection } from 'vivth/neutral';
|
|
36
|
+
*
|
|
37
|
+
* const a = new Signal('a');
|
|
38
|
+
* const b = new Signal('b');
|
|
39
|
+
* const c = new Derived(async ({ subscribe }) => {
|
|
40
|
+
* return `${subscribe(b).value}_b`;
|
|
41
|
+
* });
|
|
42
|
+
*
|
|
43
|
+
* const f = new SignalCollection({ a, c });
|
|
44
|
+
*
|
|
45
|
+
* new Effect(async ({ subscribe, isLastCalled }) => {
|
|
46
|
+
* const {
|
|
47
|
+
* a: { value: aa }, // aa is safely desctructured and auto subscribed
|
|
48
|
+
* c: { value: cc }, // cc is safely desctructured and auto subscribed
|
|
49
|
+
* } = f.signals(subscribe);
|
|
50
|
+
* if(!await isLastCalled(100)) {
|
|
51
|
+
* return; // impertaive debounce
|
|
52
|
+
* }
|
|
53
|
+
* });
|
|
54
|
+
*
|
|
55
|
+
* const d = new Derived(async function({ subscribe, isLastCalled }) {
|
|
56
|
+
* const {
|
|
57
|
+
* a: { value: aa }, // aa is safely desctructured and auto subscribed
|
|
58
|
+
* c: { value: cc }, // cc is safely desctructured and auto subscribed
|
|
59
|
+
* } = f.signals(subscribe);
|
|
60
|
+
* if(!await isLastCalled(100)) {
|
|
61
|
+
* return this.dontUpdate; // impertaive debounce
|
|
62
|
+
* }
|
|
63
|
+
* // return something;
|
|
64
|
+
* });
|
|
65
|
+
*/
|
|
66
|
+
signals: (subscribe?: import("./Effect.mjs").Effect["options"]["subscribe"]) => SIGNALS;
|
|
67
|
+
/**
|
|
68
|
+
* @description
|
|
69
|
+
* - is looping synchronously;
|
|
70
|
+
* >- will not await any async block;
|
|
71
|
+
* - use for operation that doesn't need the value:
|
|
72
|
+
* >- unsub from the signal;
|
|
73
|
+
* @template {keyof SIGNALS} K
|
|
74
|
+
* @param {(key: K,
|
|
75
|
+
* signal: SIGNALS[K]
|
|
76
|
+
* )=>void} callback
|
|
77
|
+
* @returns {void}
|
|
78
|
+
* @example
|
|
79
|
+
* import { Signal, Derived, Effect, SignalCollection } from 'vivth/neutral';
|
|
80
|
+
*
|
|
81
|
+
* const a = new Signal('a');
|
|
82
|
+
* const b = new Signal('b');
|
|
83
|
+
* const c = new Derived(async ({ subscribe }) => {
|
|
84
|
+
* return `${subscribe(b).value}_b`;
|
|
85
|
+
* });
|
|
86
|
+
*
|
|
87
|
+
* const f = new SignalCollection({ a, c });
|
|
88
|
+
*
|
|
89
|
+
* f.forInSignals((key, signal)=>{
|
|
90
|
+
* // code
|
|
91
|
+
* })
|
|
92
|
+
*/
|
|
93
|
+
forInSignals<K extends keyof SIGNALS>(callback: (key: K, signal: SIGNALS[K]) => void): void;
|
|
94
|
+
#private;
|
|
95
|
+
}
|
|
96
|
+
export type VivthCleanup = import("../typehints/VivthCleanup.mjs").VivthCleanup;
|
|
@@ -10,7 +10,7 @@ export class WalkThrough {
|
|
|
10
10
|
* @param {(...any:any[])=>void} callback
|
|
11
11
|
* @returns {void}
|
|
12
12
|
*/
|
|
13
|
-
static
|
|
13
|
+
static #handler: (iterator: Iterator<any, any, any>, callback: (...any: any[]) => void) => void;
|
|
14
14
|
/**
|
|
15
15
|
* @description
|
|
16
16
|
* - method helper to WalkThrough `Set`;
|
|
@@ -19,7 +19,7 @@ export class WalkThrough {
|
|
|
19
19
|
* @param {(value:VAL)=>void} callback
|
|
20
20
|
* @returns {void}
|
|
21
21
|
* @example
|
|
22
|
-
* import { WalkThrough } from 'vivth';
|
|
22
|
+
* import { WalkThrough } from 'vivth/neutral';
|
|
23
23
|
*
|
|
24
24
|
* WalkThrough.set(setOfSomething, (value) => {
|
|
25
25
|
* // code
|
|
@@ -34,7 +34,7 @@ export class WalkThrough {
|
|
|
34
34
|
* @param {(res:[key: KEY, value: VAL]) => void} callback
|
|
35
35
|
* @returns {void}
|
|
36
36
|
* @example
|
|
37
|
-
* import { WalkThrough } from 'vivth';
|
|
37
|
+
* import { WalkThrough } from 'vivth/neutral';
|
|
38
38
|
*
|
|
39
39
|
* WalkThrough.map(mapOfSomething, ([key, value]) => {
|
|
40
40
|
* // code
|
|
@@ -49,26 +49,11 @@ export class WalkThrough {
|
|
|
49
49
|
* @param {(res:[value: VAL, index: number]) => void} callback
|
|
50
50
|
* @returns {void}
|
|
51
51
|
* @example
|
|
52
|
-
* import { WalkThrough } from 'vivth';
|
|
52
|
+
* import { WalkThrough } from 'vivth/neutral';
|
|
53
53
|
*
|
|
54
54
|
* WalkThrough.array(arrayOfSomething, ([value, index]) => {
|
|
55
55
|
* // code
|
|
56
56
|
* })
|
|
57
57
|
*/
|
|
58
58
|
static array<VAL>(arrayInstance: VAL[], callback: (res: [value: VAL, index: number]) => void): void;
|
|
59
|
-
/**
|
|
60
|
-
* @description
|
|
61
|
-
* - method helper to WalkThrough `Generator`;
|
|
62
|
-
* @template T
|
|
63
|
-
* @param {Generator<T, any, any>} generatorInstance
|
|
64
|
-
* @param {(value: T) => void} callback
|
|
65
|
-
* @returns {void}
|
|
66
|
-
* @example
|
|
67
|
-
* import { WalkThrough } from 'vivth';
|
|
68
|
-
*
|
|
69
|
-
* WalkThrough.generator(generatorOfSomething, (value) => {
|
|
70
|
-
* // code
|
|
71
|
-
* })
|
|
72
|
-
*/
|
|
73
|
-
static generator<T>(generatorInstance: Generator<T, any, any>, callback: (value: T) => void): void;
|
|
74
59
|
}
|