vivth 1.4.9 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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} +61 -84
- package/src/class/WorkerMainThread.mjs +103 -102
- 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 -134
- 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
|
@@ -1,90 +1,151 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
|
|
3
|
-
import { basename, extname } from 'node:path';
|
|
3
|
+
import { basename, dirname, extname, relative, resolve } from 'node:path';
|
|
4
4
|
import { readFile } from 'node:fs/promises';
|
|
5
5
|
|
|
6
6
|
import { CreateESPlugin } from '../CreateESPlugin.mjs';
|
|
7
7
|
import { GetNamedImportAlias } from '../../function/GetNamedImportAlias.mjs';
|
|
8
8
|
import { FileSafe } from '../../class/FileSafe.mjs';
|
|
9
|
+
import { Paths } from '../../class/Paths.mjs';
|
|
10
|
+
import { PipeSync } from '../../function/PipeSync.mjs';
|
|
11
|
+
import { VivthUnBundledCodeBlock } from '../../common/VivthUnBundledCodeBlock.mjs';
|
|
12
|
+
import { Preferrence } from '../../common/Preferrence.mjs';
|
|
13
|
+
import { isModuleTheBundledVersion } from './isModuleTheBundledVersion.mjs';
|
|
9
14
|
|
|
10
15
|
/**
|
|
16
|
+
* @param {string} filePath
|
|
11
17
|
* @param {string} originalContent_
|
|
12
18
|
* @returns {string}
|
|
13
19
|
*/
|
|
14
|
-
export const
|
|
15
|
-
|
|
20
|
+
export const commonContentFixesBundled = (filePath, originalContent_) => {
|
|
21
|
+
return PipeSync(
|
|
22
|
+
originalContent_,
|
|
23
|
+
(content) => {
|
|
24
|
+
for (let i = 0; i < PathFStoBefixed.length; i++) {
|
|
25
|
+
const stringToBeFixed = PathFStoBefixed[i];
|
|
26
|
+
if (!stringToBeFixed) {
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
content = fixPathFS(filePath, content, stringToBeFixed);
|
|
30
|
+
}
|
|
31
|
+
return content;
|
|
32
|
+
},
|
|
33
|
+
(content) => removeVivthUnBundledCodeBlock(content),
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const PathFStoBefixed = ['Bundles', 'Dir', 'File'];
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Rewrite all relative string arguments inside `PathFS` calls.
|
|
41
|
+
* @param {string} currentFilePath - Absolute path of the current file.
|
|
42
|
+
* @param {string} originalContent_ - The source code to scan and rewrite.
|
|
43
|
+
* @param {string} mode
|
|
44
|
+
* @returns {string} - Modified source code with paths rewritten.
|
|
45
|
+
*/
|
|
46
|
+
const fixPathFS = (currentFilePath, originalContent_, mode) => {
|
|
47
|
+
const alias = GetNamedImportAlias(originalContent_, `PathFS${mode}`, 'vivth/node');
|
|
48
|
+
if (!alias) {
|
|
49
|
+
return originalContent_;
|
|
50
|
+
}
|
|
51
|
+
// Regex: match alias("...") or alias('...'), enforcing same quote style
|
|
52
|
+
const callRegex = new RegExp(`${alias}\\.(vivth[\\w]+)\\((['"])(\\.?\\.?\\/[^'"]*)\\2`, 'g');
|
|
53
|
+
let modified = originalContent_;
|
|
54
|
+
modified = modified.replace(callRegex, (full, methodName, quote, relPath) => {
|
|
55
|
+
if (!relPath) {
|
|
56
|
+
return full;
|
|
57
|
+
}
|
|
58
|
+
const absPath = resolve(dirname(currentFilePath), relPath);
|
|
59
|
+
const relToRoot = relative(Paths.root, absPath);
|
|
60
|
+
const normalized = Paths.normalize(relToRoot);
|
|
61
|
+
return `${alias}.${methodName}(${quote}${normalized}${quote}`;
|
|
62
|
+
});
|
|
63
|
+
return modified;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @param {string} originalContent_
|
|
68
|
+
* @returns {string}
|
|
69
|
+
*/
|
|
70
|
+
const removeVivthUnBundledCodeBlock = (originalContent_) => {
|
|
71
|
+
const alias = GetNamedImportAlias(originalContent_, 'BundledV', 'vivth/neutral');
|
|
16
72
|
if (!alias) {
|
|
17
73
|
return originalContent_;
|
|
18
74
|
}
|
|
19
75
|
const regex = new RegExp(
|
|
20
|
-
`(\\s*${alias}
|
|
21
|
-
'g'
|
|
76
|
+
`(\\s*${alias}.${VivthUnBundledCodeBlock}\\s*\\([\\s\\S]*?['"]${VivthUnBundledCodeBlock}['"]\\s*\\)(?:\\;|,))`,
|
|
77
|
+
'g',
|
|
22
78
|
);
|
|
23
79
|
return originalContent_.replace(regex, '');
|
|
24
80
|
};
|
|
25
81
|
|
|
26
82
|
/**
|
|
27
83
|
* @description
|
|
28
|
-
* - generate `esbuild.Plugin` for changing
|
|
84
|
+
* - generate `esbuild.Plugin` for changing unbundled time file into runtime file;
|
|
29
85
|
* - on using esbuild with this plugin, it will:
|
|
30
86
|
* >- replace any module that have similiar file name but ended with Bundled(before extname);
|
|
31
|
-
* >- works on `.mts`|`.ts`|`.mjs`|`.
|
|
32
|
-
* >- `${fileName}.mjs` -> seek for and use `${fileName}
|
|
33
|
-
* >- removes `
|
|
87
|
+
* >- works on `.mts`|`.ts`|`.mjs`|`.js`;
|
|
88
|
+
* >- `${fileName}.mjs` -> seek for and use `${fileName}.bundled.mjs`, if not found use `${fileName}.mjs`;
|
|
89
|
+
* >- removes `BundledV.vivthUnBundledCodeBlock` code block;
|
|
34
90
|
* @param {string} includedInPath
|
|
35
91
|
* - is generalized path, you can freely uses forward or backward slash;
|
|
36
92
|
* @returns {ReturnType<CreateESPlugin>}
|
|
37
93
|
* @example
|
|
38
|
-
* import { ToBundledJSPlugin } from 'vivth';
|
|
94
|
+
* import { ToBundledJSPlugin } from 'vivth/node';
|
|
39
95
|
*
|
|
40
96
|
* export const myBundledPlugin = ToBundledJSPlugin('/myProjectName/src/');
|
|
41
97
|
*/
|
|
42
98
|
export function ToBundledJSPlugin(includedInPath) {
|
|
43
99
|
const filter = new RegExp(includedInPath.replace(/[\\/]/g, '[\\\\/]'), '');
|
|
44
|
-
return CreateESPlugin(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
100
|
+
return CreateESPlugin(
|
|
101
|
+
`ToBundledJSPlugin:${includedInPath}`,
|
|
102
|
+
({
|
|
103
|
+
/** */
|
|
104
|
+
onLoad,
|
|
105
|
+
}) => {
|
|
106
|
+
onLoad({ filter }, async ({ path: filePath }) => {
|
|
107
|
+
const extension = extname(filePath);
|
|
108
|
+
/**
|
|
109
|
+
* @type {'js'|'ts'|undefined}
|
|
110
|
+
*/
|
|
111
|
+
let loader;
|
|
112
|
+
switch (extension) {
|
|
113
|
+
case '.mts':
|
|
114
|
+
case '.cts':
|
|
115
|
+
case '.ts':
|
|
116
|
+
loader = 'ts';
|
|
117
|
+
break;
|
|
118
|
+
case '.mjs':
|
|
119
|
+
case '.js':
|
|
120
|
+
loader = 'js';
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* @type {ReturnType<Parameters<import('esbuild').PluginBuild["onLoad"]>[1]>}
|
|
125
|
+
*/
|
|
126
|
+
const ret = { loader };
|
|
127
|
+
if (loader === undefined || isModuleTheBundledVersion(filePath, extension)) {
|
|
128
|
+
const originalContent = (await readFile(filePath)).toString(Preferrence.encoding);
|
|
129
|
+
ret.contents = commonContentFixesBundled(filePath, originalContent);
|
|
130
|
+
return ret;
|
|
131
|
+
}
|
|
132
|
+
const originalBaseName = basename(filePath);
|
|
133
|
+
const originalFileName = originalBaseName.replace(extension, '');
|
|
134
|
+
const realRef = `${originalFileName}.bundled`;
|
|
135
|
+
const bundledFile = filePath.replace(
|
|
136
|
+
new RegExp(`${originalBaseName}\$`.replace('.', '\\.'), ''),
|
|
137
|
+
`${realRef}${extension}`,
|
|
138
|
+
);
|
|
139
|
+
const isExist = await FileSafe.exist(bundledFile);
|
|
140
|
+
if (!isExist) {
|
|
141
|
+
const originalContent = (await readFile(filePath)).toString(Preferrence.encoding);
|
|
142
|
+
ret.contents = commonContentFixesBundled(filePath, originalContent);
|
|
143
|
+
return ret;
|
|
144
|
+
}
|
|
145
|
+
const originalContent = (await readFile(bundledFile)).toString(Preferrence.encoding);
|
|
146
|
+
ret.contents = commonContentFixesBundled(filePath, originalContent);
|
|
70
147
|
return ret;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const realRef = `${originalFileName}Bundled`;
|
|
75
|
-
const bundledFile = filePath.replace(
|
|
76
|
-
new RegExp(`${originalBaseName}\$`.replace('.', '\\.'), ''),
|
|
77
|
-
`${realRef}${fileExt}`
|
|
78
|
-
);
|
|
79
|
-
const [, error] = await FileSafe.exist(bundledFile);
|
|
80
|
-
if (error) {
|
|
81
|
-
const originalContent = (await readFile(filePath)).toString('utf-8');
|
|
82
|
-
ret.contents = removeVivthDevCodeBlock(originalContent);
|
|
83
|
-
return ret;
|
|
84
|
-
}
|
|
85
|
-
const originalContent = (await readFile(bundledFile)).toString('utf-8');
|
|
86
|
-
ret.contents = removeVivthDevCodeBlock(originalContent);
|
|
87
|
-
return ret;
|
|
88
|
-
});
|
|
89
|
-
});
|
|
148
|
+
});
|
|
149
|
+
},
|
|
150
|
+
);
|
|
90
151
|
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
import { resolve, relative } from 'node:path';
|
|
4
|
+
|
|
5
|
+
import { Paths } from '../../class/Paths.mjs';
|
|
6
|
+
import { CreateESPlugin } from '../CreateESPlugin.mjs';
|
|
7
|
+
import { onEndEsBuildErrorLogger } from './onEndEsBuildErrorLogger.mjs';
|
|
8
|
+
import { LastEditedUnix } from './LastEditedUnix.mjs';
|
|
9
|
+
import { Console } from '../../class/Console.mjs';
|
|
10
|
+
import { ForOfSync } from '../../function/ForOfSync.mjs';
|
|
11
|
+
import { FileSafe } from '../../class/FileSafe.mjs';
|
|
12
|
+
import { resolveJSDependencyPath } from './resolveJSDependencyPath.mjs';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @import {Plugin} from 'esbuild'
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @param {string} path
|
|
20
|
+
* @param {string} targetPath
|
|
21
|
+
* @param {string} watchPath
|
|
22
|
+
* @param {string} mapToPath
|
|
23
|
+
* @param {Map<string, Set<string>>} depMap
|
|
24
|
+
* @param {Map<string, () => Promise<any>>} esbuildPathRebuild
|
|
25
|
+
* @returns {Plugin}
|
|
26
|
+
*/
|
|
27
|
+
export const autoExternalize = (
|
|
28
|
+
path,
|
|
29
|
+
targetPath,
|
|
30
|
+
watchPath,
|
|
31
|
+
mapToPath,
|
|
32
|
+
depMap,
|
|
33
|
+
esbuildPathRebuild,
|
|
34
|
+
) => {
|
|
35
|
+
return CreateESPlugin('JSDirMapper:auto-externalize', ({ onResolve, onEnd }) => {
|
|
36
|
+
onResolve({ filter: /^\.{1,2}\// }, async ({ resolveDir, path: pathSpecifier }) => {
|
|
37
|
+
const fullPath = Paths.normalize(resolve(resolveDir, pathSpecifier));
|
|
38
|
+
if (await resolveJSDependencyPath(fullPath)) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
const runtimePath = fullPath.replace(watchPath, mapToPath);
|
|
42
|
+
const transpiledModuleRuntimePath = await FileSafe.exist(`${runtimePath}.mjs`);
|
|
43
|
+
if (!fullPath.endsWith('.mjs') && transpiledModuleRuntimePath) {
|
|
44
|
+
pathSpecifier = `${pathSpecifier}.mjs`;
|
|
45
|
+
}
|
|
46
|
+
const rel = Paths.normalize(relative(watchPath, fullPath));
|
|
47
|
+
if (rel.startsWith('../')) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
if (!depMap.has(fullPath)) {
|
|
51
|
+
depMap.set(fullPath, new Set());
|
|
52
|
+
}
|
|
53
|
+
depMap.get(fullPath)?.add(path);
|
|
54
|
+
const resolvedPath = `${pathSpecifier}?t=${await LastEditedUnix(fullPath)}`;
|
|
55
|
+
return { external: true, path: resolvedPath };
|
|
56
|
+
});
|
|
57
|
+
onEnd(async ({ errors: errorsBuild }) => {
|
|
58
|
+
if (errorsBuild.length) {
|
|
59
|
+
onEndEsBuildErrorLogger(errorsBuild);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
Console.info(
|
|
63
|
+
{
|
|
64
|
+
JSDirMapper: `✅ Successfully Bundle'${path}' 👉 '${targetPath}'`,
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
now: true,
|
|
68
|
+
},
|
|
69
|
+
);
|
|
70
|
+
const importers = depMap.get(path);
|
|
71
|
+
if (!importers) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
await Promise.all(
|
|
75
|
+
ForOfSync(importers, async (importer) => {
|
|
76
|
+
await esbuildPathRebuild.get(importer)?.();
|
|
77
|
+
})[0],
|
|
78
|
+
);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
import { Console } from '../../class/Console.mjs';
|
|
4
|
+
import { IsStringLooksLikeAPath } from '../../function/IsStringLooksLikeAPath.mjs';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @param {import('esbuild').Message[]} errorData
|
|
8
|
+
* @returns { void }
|
|
9
|
+
*/
|
|
10
|
+
export const onEndEsBuildErrorLogger = (errorData) => {
|
|
11
|
+
const errorLog = {
|
|
12
|
+
...errorData[0],
|
|
13
|
+
suggestion: ['modify `FileSelfMapper` constructor `argument[1].esbuild`'],
|
|
14
|
+
};
|
|
15
|
+
const errorText = errorData[0]?.text;
|
|
16
|
+
const match = errorText?.toLocaleLowerCase().match(/could not resolve\s+"([^"]+)"/i);
|
|
17
|
+
if (match) {
|
|
18
|
+
const [, lib] = match;
|
|
19
|
+
if (IsStringLooksLikeAPath(lib ?? '')) {
|
|
20
|
+
Object.assign(errorLog, {
|
|
21
|
+
message: `'${lib}' doesn't exist`,
|
|
22
|
+
});
|
|
23
|
+
} else {
|
|
24
|
+
Object.assign(errorLog, {
|
|
25
|
+
platformSuggestion: {
|
|
26
|
+
node: `add esbuild.platform:'node' AND add '${lib}' into esbuild.external`,
|
|
27
|
+
browser: `add esbuild.platform:'browser'`,
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
Console.error(errorLog, { now: true });
|
|
33
|
+
return;
|
|
34
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
import { extname } from 'node:path';
|
|
4
|
+
import { FileSafe } from '../../class/FileSafe.mjs';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @param {string} jspath
|
|
8
|
+
* @returns {Promise<boolean>}
|
|
9
|
+
*/
|
|
10
|
+
export const resolveJSDependencyPath = async (jspath) => {
|
|
11
|
+
const ext = extname(jspath);
|
|
12
|
+
if (ext !== '.js') {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
const isExist = await FileSafe.exist(jspath.replace(/.js$/g, '.as.ts'));
|
|
16
|
+
return isExist;
|
|
17
|
+
};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
import { IsInstanceOf } from '../function/IsInstanceOf.mjs';
|
|
4
|
+
import { TryAsync } from '../function/TryAsync.mjs';
|
|
5
|
+
import { Console } from './Console.mjs';
|
|
6
|
+
import { Effect } from './Effect.mjs';
|
|
7
|
+
import { Signal } from './Signal.mjs';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @typedef {import('../typehints/VivthCleanup.mjs').VivthCleanup} VivthCleanup
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @description
|
|
15
|
+
* - `Signal` to unwrap `Promise`;
|
|
16
|
+
* - useful to create underlying mechanism for something like react `Suspense` component;
|
|
17
|
+
* - auto queued for last unwrap request;
|
|
18
|
+
* @template {any} VALUE
|
|
19
|
+
* @template {any[]} ARGS
|
|
20
|
+
* @extends {Signal<VALUE|Promise<VALUE>|Error>}
|
|
21
|
+
* @implements {VivthCleanup}
|
|
22
|
+
* @example
|
|
23
|
+
* import { AwaitSignal, Effect } from 'vivth/neutral'
|
|
24
|
+
* const bigAwaitSignal = new AwaitSignal(fetch('../SomethingReallyBig'));
|
|
25
|
+
* new Effect(async({ subscribe })=>{
|
|
26
|
+
* const myBigLoadProgress = subscribe(bigAwaitSignal).value;
|
|
27
|
+
* const isError = IsInstanceOf(myBigLoadProgress, Error);
|
|
28
|
+
* if(isError){
|
|
29
|
+
* // handle error here
|
|
30
|
+
* return;
|
|
31
|
+
* }
|
|
32
|
+
* const isAPromise = IsInstanceOf(myBigLoadProgress, Promise);
|
|
33
|
+
* if(isAPromise){
|
|
34
|
+
* // handle suspense here;
|
|
35
|
+
* return;
|
|
36
|
+
* }
|
|
37
|
+
* // handle ready state here;
|
|
38
|
+
* })
|
|
39
|
+
*/
|
|
40
|
+
export class AwaitSignal extends Signal {
|
|
41
|
+
/**
|
|
42
|
+
* @override
|
|
43
|
+
*/
|
|
44
|
+
vivthCleanup = async () => {
|
|
45
|
+
this.#unwrapper.vivthCleanup();
|
|
46
|
+
this.remove.ref();
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* @type {number}
|
|
50
|
+
*/
|
|
51
|
+
#latestPromise = Date.now();
|
|
52
|
+
/**
|
|
53
|
+
* @param {(...args:ARGS)=>Promise<VALUE>} callback
|
|
54
|
+
* @param {ARGS} firstCallArguments
|
|
55
|
+
*/
|
|
56
|
+
constructor(callback, ...firstCallArguments) {
|
|
57
|
+
super(callback(...firstCallArguments), ({ timeStamp, value }) => {
|
|
58
|
+
if (!IsInstanceOf(value, Promise)) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
this.#latestPromise = timeStamp;
|
|
62
|
+
});
|
|
63
|
+
this.#callback = callback;
|
|
64
|
+
this.#unwrapper = new Effect(async ({ subscribe, isLastCalled }) => {
|
|
65
|
+
const latestPromise = this.#latestPromise;
|
|
66
|
+
const currentValue = subscribe(this).value;
|
|
67
|
+
if (!IsInstanceOf(currentValue, Promise) || !(await isLastCalled())) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const [newValue, errorUnwrappingPromise] = await TryAsync(async () => {
|
|
71
|
+
return await currentValue;
|
|
72
|
+
});
|
|
73
|
+
if (latestPromise !== this.#latestPromise) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (!errorUnwrappingPromise) {
|
|
77
|
+
super.value = newValue;
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
Console.error({ errorUnwrappingPromise });
|
|
81
|
+
super.value = errorUnwrappingPromise;
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
#unwrapper;
|
|
85
|
+
/**
|
|
86
|
+
* @override
|
|
87
|
+
* @param {VALUE|Promise<VALUE>|Error} _newValue
|
|
88
|
+
*/
|
|
89
|
+
set value(_newValue) {
|
|
90
|
+
Console.warn({ _newValue, AwaitSignalValueSetter: 'are not to be used' });
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* @override
|
|
94
|
+
* @returns {VALUE|Promise<VALUE>|Error}
|
|
95
|
+
*/
|
|
96
|
+
get value() {
|
|
97
|
+
return super.value;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* @type {(...args:ARGS)=>Promise<VALUE>}
|
|
101
|
+
*/
|
|
102
|
+
#callback;
|
|
103
|
+
retryCount = 0;
|
|
104
|
+
/**
|
|
105
|
+
* @param {number} maxRetries
|
|
106
|
+
* - `0` for no limit;
|
|
107
|
+
* @param {ARGS} args
|
|
108
|
+
* - integer of retryCount;
|
|
109
|
+
*/
|
|
110
|
+
retry = (maxRetries, ...args) => {
|
|
111
|
+
if (maxRetries !== 0 || ++this.retryCount > maxRetries) {
|
|
112
|
+
Console.error({
|
|
113
|
+
AwaitSignal: { callback: this.#callback, retryCount: maxRetries },
|
|
114
|
+
});
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
super.value = this.#callback(...args);
|
|
118
|
+
};
|
|
119
|
+
}
|
package/src/class/Console.mjs
CHANGED
|
@@ -15,15 +15,33 @@ export class Console {
|
|
|
15
15
|
error: '\x1b[31m', // red
|
|
16
16
|
},
|
|
17
17
|
};
|
|
18
|
+
/**
|
|
19
|
+
* @param {any} data
|
|
20
|
+
* @param {import("../typehints/ConsoleAdditionalSettingType.mjs").ConsoleAdditionalSettingType} args
|
|
21
|
+
* @return {object}
|
|
22
|
+
*/
|
|
23
|
+
static #addArgsHandler = (data, { now: now_ }) => {
|
|
24
|
+
const obj = { message: data };
|
|
25
|
+
if (now_) {
|
|
26
|
+
Object.assign(obj, { now: Date.now() });
|
|
27
|
+
}
|
|
28
|
+
return obj;
|
|
29
|
+
};
|
|
18
30
|
/**
|
|
19
31
|
* @param {string} prefix
|
|
20
32
|
* @param {'log'|'info'|'error'|'warn'} mode
|
|
21
33
|
* @param {any} data
|
|
34
|
+
* @param {import("../typehints/ConsoleAdditionalSettingType.mjs").ConsoleAdditionalSettingType} [addArgs]
|
|
22
35
|
* @returns {void}
|
|
23
36
|
*/
|
|
24
|
-
static #call = (prefix, mode, data) => {
|
|
37
|
+
static #call = (prefix, mode, data, addArgs) => {
|
|
38
|
+
if (addArgs) {
|
|
39
|
+
data = Console.#addArgsHandler(data, addArgs);
|
|
40
|
+
}
|
|
25
41
|
const fn = console[mode];
|
|
26
|
-
if (typeof fn !== 'function')
|
|
42
|
+
if (typeof fn !== 'function') {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
27
45
|
|
|
28
46
|
const color = Console.#ansi.colors[mode] || '';
|
|
29
47
|
const styledPrefix = `${color}${Console.#ansi.bold}${prefix} ${mode.toUpperCase()}:${
|
|
@@ -35,57 +53,61 @@ export class Console {
|
|
|
35
53
|
/**
|
|
36
54
|
* @description
|
|
37
55
|
* @param {any} data
|
|
56
|
+
* @param {import("../typehints/ConsoleAdditionalSettingType.mjs").ConsoleAdditionalSettingType} [addArgs]
|
|
38
57
|
* @returns {void}
|
|
39
58
|
* @example
|
|
40
|
-
* import { Console } from 'vivth';
|
|
59
|
+
* import { Console } from 'vivth/neutral';
|
|
41
60
|
*
|
|
42
61
|
* Console.log({
|
|
43
62
|
* hello: 'world!!',
|
|
44
63
|
* });
|
|
45
64
|
*/
|
|
46
|
-
static log = (data) => {
|
|
47
|
-
return Console.#call('🟢', 'log', data);
|
|
65
|
+
static log = (data, addArgs) => {
|
|
66
|
+
return Console.#call('🟢', 'log', data, addArgs);
|
|
48
67
|
};
|
|
49
68
|
/**
|
|
50
69
|
* @description
|
|
51
70
|
* @param {any} data
|
|
71
|
+
* @param {import("../typehints/ConsoleAdditionalSettingType.mjs").ConsoleAdditionalSettingType} [addArgs]
|
|
52
72
|
* @returns {void}
|
|
53
73
|
* @example
|
|
54
|
-
* import { Console } from 'vivth';
|
|
74
|
+
* import { Console } from 'vivth/neutral';
|
|
55
75
|
*
|
|
56
76
|
* Console.info({
|
|
57
77
|
* hello: 'world!!',
|
|
58
78
|
* });
|
|
59
79
|
*/
|
|
60
|
-
static info = (data) => {
|
|
61
|
-
return Console.#call('🔵', 'info', data);
|
|
80
|
+
static info = (data, addArgs) => {
|
|
81
|
+
return Console.#call('🔵', 'info', data, addArgs);
|
|
62
82
|
};
|
|
63
83
|
/**
|
|
64
84
|
* @description
|
|
65
85
|
* @param {any} data
|
|
86
|
+
* @param {import("../typehints/ConsoleAdditionalSettingType.mjs").ConsoleAdditionalSettingType} [addArgs]
|
|
66
87
|
* @returns {void}
|
|
67
88
|
* @example
|
|
68
|
-
* import { Console } from 'vivth';
|
|
89
|
+
* import { Console } from 'vivth/neutral';
|
|
69
90
|
*
|
|
70
91
|
* Console.warn({
|
|
71
92
|
* hello: 'world!!',
|
|
72
93
|
* });
|
|
73
94
|
*/
|
|
74
|
-
static warn = (data) => {
|
|
75
|
-
return Console.#call('🟠', 'warn', data);
|
|
95
|
+
static warn = (data, addArgs) => {
|
|
96
|
+
return Console.#call('🟠', 'warn', data, addArgs);
|
|
76
97
|
};
|
|
77
98
|
/**
|
|
78
99
|
* @description
|
|
79
100
|
* @param {any} data
|
|
101
|
+
* @param {import("../typehints/ConsoleAdditionalSettingType.mjs").ConsoleAdditionalSettingType} [addArgs]
|
|
80
102
|
* @returns {void}
|
|
81
103
|
* @example
|
|
82
|
-
* import { Console } from 'vivth';
|
|
104
|
+
* import { Console } from 'vivth/neutral';
|
|
83
105
|
*
|
|
84
106
|
* Console.error({
|
|
85
107
|
* hello: 'world!!',
|
|
86
108
|
* });
|
|
87
109
|
*/
|
|
88
|
-
static error = (data) => {
|
|
89
|
-
return Console.#call('🔴', 'error', data);
|
|
110
|
+
static error = (data, addArgs) => {
|
|
111
|
+
return Console.#call('🔴', 'error', data, addArgs);
|
|
90
112
|
};
|
|
91
113
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @description
|
|
5
|
+
* - class helper for signal performant logging, more or less just for type hinting;
|
|
6
|
+
* - internally used as Signal value logging instance;
|
|
7
|
+
* @template {any} VALUE
|
|
8
|
+
*/
|
|
9
|
+
export class DataLog {
|
|
10
|
+
/**
|
|
11
|
+
* @description
|
|
12
|
+
* @param {VALUE} value
|
|
13
|
+
*/
|
|
14
|
+
constructor(value) {
|
|
15
|
+
this.value = value;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* @description
|
|
19
|
+
* - data value;
|
|
20
|
+
* @type {VALUE}
|
|
21
|
+
*/
|
|
22
|
+
value;
|
|
23
|
+
/**
|
|
24
|
+
* @description
|
|
25
|
+
* - occurence unix timestamp;
|
|
26
|
+
* @type {number}
|
|
27
|
+
*/
|
|
28
|
+
timeStamp = Date.now();
|
|
29
|
+
}
|