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
package/src/doc/JSautoDOC.mjs
CHANGED
|
@@ -1,36 +1,34 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
|
|
3
|
-
import { extname
|
|
3
|
+
import { extname } from 'node:path';
|
|
4
4
|
import { readFile } from 'node:fs/promises';
|
|
5
5
|
|
|
6
6
|
import prettier from 'prettier';
|
|
7
|
-
import chokidar from 'chokidar';
|
|
8
7
|
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
8
|
+
import { FileSafe } from '../class/FileSafe.mjs';
|
|
9
|
+
import { ForEach } from '../class/ForEach.mjs';
|
|
10
|
+
import { FSDirArchWatcher } from '../class/FSDirArchWatcher.mjs';
|
|
11
|
+
import { JSONFileHandler } from '../class/JSONFileHandler.mjs';
|
|
13
12
|
import { Paths } from '../class/Paths.mjs';
|
|
14
|
-
import {
|
|
13
|
+
import { IsSameFile } from '../function/IsSameFile.mjs';
|
|
15
14
|
import { LazyFactory } from '../function/LazyFactory.mjs';
|
|
16
15
|
import { TryAsync } from '../function/TryAsync.mjs';
|
|
17
|
-
import {
|
|
16
|
+
import { parsedFileForDOC } from './parsedFileForDOC.mjs';
|
|
17
|
+
import { Preferrence } from '../common/Preferrence.mjs';
|
|
18
|
+
import { basename, join } from 'node:path';
|
|
18
19
|
import { TsToMjs } from '../function/TsToMjs.mjs';
|
|
19
|
-
import {
|
|
20
|
+
import { Console } from '../class/Console.mjs';
|
|
20
21
|
import { correctBeforeParse } from './correctBeforeParse.mjs';
|
|
22
|
+
import { GetterSetter } from '../class/GetterSetter.mjs';
|
|
23
|
+
import { ForOfSync } from '../function/ForOfSync.mjs';
|
|
24
|
+
import { TryNew } from '../function/TryNew.mjs';
|
|
25
|
+
import { cleanPreserveTypedef } from './cleanPreserveTypedef.mjs';
|
|
26
|
+
|
|
27
|
+
export const multiExportEntryPointsPath = './generated/vivth/exports/';
|
|
21
28
|
|
|
22
29
|
/**
|
|
23
|
-
* @typedef {import('
|
|
24
|
-
*/
|
|
25
|
-
/**
|
|
26
|
-
* @type {BufferEncoding}
|
|
27
|
-
*/
|
|
28
|
-
const encoding = 'utf-8';
|
|
29
|
-
const readmesrcname = 'README.src.md';
|
|
30
|
-
/**
|
|
31
|
-
* @type {Set<import('../types/ExtnameType.mjs').ExtnameType>}
|
|
30
|
+
* @typedef {import('../typehints/VivthCleanup.mjs').VivthCleanup} VivthCleanup
|
|
32
31
|
*/
|
|
33
|
-
const acceptableExt = new Set(['.mjs', '.mts', '.ts']);
|
|
34
32
|
|
|
35
33
|
/**
|
|
36
34
|
* @description
|
|
@@ -54,358 +52,749 @@ const acceptableExt = new Set(['.mjs', '.mts', '.ts']);
|
|
|
54
52
|
* >>- static/instance method with generic template;
|
|
55
53
|
* >7) transpile `.ts` and `.mts` to `.mjs` with same name and directory;
|
|
56
54
|
* >>- use `"at"preserve` to preserve tsdoc comment section;
|
|
55
|
+
* >8) integrated with assembly script to wasm compiler on the doc;
|
|
56
|
+
* >>- see [AssemblyScript](#assemblyscript);
|
|
57
|
+
* >9) modify following root json files:
|
|
58
|
+
* >>- `package.json`: assign `exports`, `main`, `module`;
|
|
59
|
+
* >>- `tsconfig.json`: assign `includes`, anything passed on `options.jstsconfigs`;
|
|
60
|
+
* >>- `jsconfig.json`: assign `includes`, anything passed on `options.jstsconfigs`;
|
|
61
|
+
* >10) generates files to `/generated/vivth/exports/`:
|
|
62
|
+
* >>- `./browser.mjs`: able to be called on `browser` platform;
|
|
63
|
+
* >>- `./node.mjs`: able to be called on `node` platform;
|
|
64
|
+
* >>- `./neutral.mjs`: able to be called on `node` and `browser` platform;
|
|
65
|
+
* >>- `./unsupported.mjs`: most likely will throw error when called, it is more of a logged error to be managed;
|
|
66
|
+
* >>- `./all.mjs`: collections of all platform;
|
|
67
|
+
* >11) doesn't support accessor;
|
|
68
|
+
* >>- due to how TLS way accessor type not casting its getter and setter working around accessor requires ignoring this specific error, and it might become ugly real quick;
|
|
69
|
+
* >>- we recomend to stick with getter and setter;
|
|
70
|
+
* - for runtime example see file `/dev/auto-doc.mjs` on source code;
|
|
71
|
+
* @implements {VivthCleanup}
|
|
57
72
|
*/
|
|
58
73
|
export class JSautoDOC {
|
|
74
|
+
vivthCleanup = async () => {
|
|
75
|
+
await this.watcher?.vivthCleanup();
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* @typedef {'readme' |
|
|
79
|
+
* 'handledJS'
|
|
80
|
+
* } returnTypeStringType
|
|
81
|
+
*/
|
|
82
|
+
/**
|
|
83
|
+
* @typedef {FSDirArchWatcher<{
|
|
84
|
+
* path: string;
|
|
85
|
+
* parsed: undefined;
|
|
86
|
+
* ext: `.${string}`;
|
|
87
|
+
* type: returnTypeStringType;
|
|
88
|
+
* readme?:string;
|
|
89
|
+
* } | {
|
|
90
|
+
* path: string;
|
|
91
|
+
* parsed: parsedFileForDOC;
|
|
92
|
+
* ext: string;
|
|
93
|
+
* type: returnTypeStringType;
|
|
94
|
+
* readme?:string;
|
|
95
|
+
* }>} FSDirArchWatcher__
|
|
96
|
+
*/
|
|
59
97
|
/**
|
|
60
98
|
* @type {JSautoDOC|undefined}
|
|
61
99
|
*/
|
|
62
100
|
static #instance;
|
|
63
101
|
/**
|
|
64
102
|
* @description
|
|
65
|
-
* @param {Object}
|
|
66
|
-
* @param {
|
|
67
|
-
* @param {string} options.paths.file
|
|
68
|
-
* - entry point;
|
|
69
|
-
* @param {string} options.paths.readMe
|
|
70
|
-
* - readme target;
|
|
71
|
-
* @param {string} options.paths.dir
|
|
103
|
+
* @param {Object} options
|
|
104
|
+
* @param {string} options.src
|
|
72
105
|
* - source directory;
|
|
73
106
|
* @param {string} [options.copyright]
|
|
74
107
|
* @param {string} [options.tableOfContentTitle]
|
|
75
|
-
* @param {
|
|
108
|
+
* @param {number} [options.maxDebounceForGeneratingDocAndExport]
|
|
109
|
+
* - default `10_000`;
|
|
110
|
+
* @param {import('chokidar').ChokidarOptions} [options.chokidarOptions]
|
|
76
111
|
* - ChokidarOptions;
|
|
112
|
+
* @param {import('../typehints/AutoDocASOptions.mjs').AutoDocASOptions} [options.assemblyScriptOptions]
|
|
113
|
+
* - abstracted details to handle `.as.ts` file;
|
|
114
|
+
* @param {(arg0:{map:Map<string, {
|
|
115
|
+
* path: string;
|
|
116
|
+
* parsed: undefined;
|
|
117
|
+
* ext: `.${string}`;
|
|
118
|
+
* type: returnTypeStringType;
|
|
119
|
+
* readme?:string;
|
|
120
|
+
* } | {
|
|
121
|
+
* path: string;
|
|
122
|
+
* parsed: parsedFileForDOC;
|
|
123
|
+
* ext: string;
|
|
124
|
+
* type: returnTypeStringType;
|
|
125
|
+
* readme?:string;
|
|
126
|
+
* }>})=>Promise<void>} [options.onLastGeneratedCallback]
|
|
127
|
+
* - callback to be run on finishing generating document AND exports;
|
|
128
|
+
* - only handle that marked as `isLastCalled`;
|
|
129
|
+
* @param { import('typescript').CompilerOptions |
|
|
130
|
+
* import('typescript').ParsedCommandLine
|
|
131
|
+
* } [options.jstsconfigs]
|
|
132
|
+
* - type of `ts/jsconfig` to be assigned to existing respective `.json` file;
|
|
77
133
|
* @example
|
|
78
|
-
* import { JSautoDOC } from 'vivth';
|
|
134
|
+
* import { JSautoDOC } from 'vivth/node';
|
|
79
135
|
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
136
|
+
* new JSautoDOC({
|
|
137
|
+
* src: '/src',
|
|
82
138
|
* copyright: 'this library is made and distributed under MIT license;',
|
|
83
139
|
* tableOfContentTitle: 'list of exported API and typehelpers',
|
|
140
|
+
* // assemblyScriptOptions: {},
|
|
141
|
+
* // onLastGeneratedCallback: async (options) => {
|
|
142
|
+
* // Console.log(options);
|
|
143
|
+
* // },
|
|
84
144
|
* });
|
|
85
|
-
*
|
|
86
145
|
*/
|
|
87
146
|
constructor({
|
|
88
|
-
|
|
147
|
+
src = './src',
|
|
148
|
+
onLastGeneratedCallback = undefined,
|
|
89
149
|
tableOfContentTitle = 'exported-api-and-type-list',
|
|
90
150
|
copyright = '',
|
|
91
|
-
|
|
92
|
-
|
|
151
|
+
maxDebounceForGeneratingDocAndExport = 10_000,
|
|
152
|
+
assemblyScriptOptions = undefined,
|
|
153
|
+
chokidarOptions = undefined,
|
|
154
|
+
jstsconfigs = undefined,
|
|
155
|
+
}) {
|
|
93
156
|
if (JSautoDOC.#instance instanceof JSautoDOC) {
|
|
94
|
-
return
|
|
157
|
+
return JSautoDOC.#instance;
|
|
95
158
|
}
|
|
96
159
|
JSautoDOC.#instance = this;
|
|
160
|
+
this.#onLastGeneratedCallback = onLastGeneratedCallback;
|
|
97
161
|
this.#tableOfContentTitle = tableOfContentTitle;
|
|
98
|
-
this.#
|
|
162
|
+
this.#source = src;
|
|
99
163
|
this.#copyright = copyright;
|
|
100
|
-
|
|
101
|
-
|
|
164
|
+
this.#assemblyScriptOptions = assemblyScriptOptions;
|
|
165
|
+
this.#readmePath = Paths.diskAbsolute('/README.src.md');
|
|
166
|
+
Promise.all([
|
|
167
|
+
this.#jstsConfigAddInclude('/tsconfig.json', jstsconfigs),
|
|
168
|
+
this.#jstsConfigAddInclude('/jsconfig.json', jstsconfigs),
|
|
169
|
+
]);
|
|
170
|
+
FileSafe.exist(this.#readmePath).then(async (isExist) => {
|
|
171
|
+
if (isExist) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
await this.#writeREADMEDefaultSRC();
|
|
175
|
+
});
|
|
176
|
+
const [fsDirArchWatcher, errorfsDirArchWatcherInstance] = TryNew(
|
|
177
|
+
FSDirArchWatcher,
|
|
178
|
+
[src, this.#readmePath],
|
|
179
|
+
{
|
|
180
|
+
debounce: maxDebounceForGeneratingDocAndExport,
|
|
181
|
+
chokidarOptions,
|
|
182
|
+
/**
|
|
183
|
+
* @type {FSDirArchWatcher__["eachHandler"]}
|
|
184
|
+
*/
|
|
185
|
+
each: async (eventName, path, stats) => {
|
|
186
|
+
/**
|
|
187
|
+
* @type {`.${string}`}
|
|
188
|
+
*/
|
|
189
|
+
// @ts-expect-error
|
|
190
|
+
const ext = extname(path);
|
|
191
|
+
const readMeHandled = await this.checkReadmeFile(path);
|
|
192
|
+
if (readMeHandled.isBeingHandled) {
|
|
193
|
+
return { path, parsed: undefined, readme: readMeHandled.content, ext, type: 'readme' };
|
|
194
|
+
}
|
|
195
|
+
if (!this.#acceptableExt.has(ext)) {
|
|
196
|
+
throw '';
|
|
197
|
+
}
|
|
198
|
+
if (basename(path).endsWith(`.d${ext}`)) {
|
|
199
|
+
const renamedPath = path.replace(new RegExp(`.d${ext}$`), ext);
|
|
200
|
+
await FileSafe.rename(path, renamedPath);
|
|
201
|
+
throw '';
|
|
202
|
+
}
|
|
203
|
+
switch (eventName) {
|
|
204
|
+
case 'add':
|
|
205
|
+
case 'change':
|
|
206
|
+
if (ext !== '.mjs') {
|
|
207
|
+
await TsToMjs(path, {
|
|
208
|
+
encoding: Preferrence.encoding,
|
|
209
|
+
assemblyScriptOptions: this.#assemblyScriptOptions,
|
|
210
|
+
});
|
|
211
|
+
throw '';
|
|
212
|
+
}
|
|
213
|
+
if (!stats?.isFile()) {
|
|
214
|
+
throw '';
|
|
215
|
+
}
|
|
216
|
+
if (await FileSafe.exist(path.replace(/.mjs$/, '.mts'))) {
|
|
217
|
+
const newString = cleanPreserveTypedef(
|
|
218
|
+
await readFile(path, { encoding: Preferrence.encoding }),
|
|
219
|
+
);
|
|
220
|
+
if (newString) {
|
|
221
|
+
await FileSafe.write(path, newString, { encoding: Preferrence.encoding });
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return await this.#addAndChangesHandler(ext, path, stats);
|
|
225
|
+
default:
|
|
226
|
+
/**
|
|
227
|
+
* - auto deleted from the map so need to call `.delete`
|
|
228
|
+
*/
|
|
229
|
+
throw '';
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
// @ts-expect-error
|
|
233
|
+
full: this.#fullHandler,
|
|
234
|
+
},
|
|
235
|
+
);
|
|
236
|
+
if (errorfsDirArchWatcherInstance) {
|
|
237
|
+
Console.error({ errorfsDirArchWatcherInstance });
|
|
102
238
|
return;
|
|
103
239
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
240
|
+
this.watcher = fsDirArchWatcher;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* @type { FSDirArchWatcher<any>|undefined }
|
|
244
|
+
*/
|
|
245
|
+
watcher;
|
|
246
|
+
/**
|
|
247
|
+
* @type {string}
|
|
248
|
+
*/
|
|
249
|
+
#source = './src';
|
|
250
|
+
#packageJSONHandler = LazyFactory(() => new JSONFileHandler('/package.json'));
|
|
251
|
+
/**
|
|
252
|
+
* @type {Set<import('../typehints/ExtnameType.mjs').ExtnameType>}
|
|
253
|
+
*/
|
|
254
|
+
#acceptableExt = new Set(['.js', '.mjs', '.mts', '.ts']);
|
|
255
|
+
/**
|
|
256
|
+
* @param {string} configPath
|
|
257
|
+
* @param {ConstructorParameters<typeof JSautoDOC>[0]["jstsconfigs"]} jstsconfigs
|
|
258
|
+
*/
|
|
259
|
+
#jstsConfigAddInclude = async (configPath, jstsconfigs) => {
|
|
260
|
+
return await TryAsync(async () => {
|
|
261
|
+
if (!(await FileSafe.exist(Paths.diskAbsolute(configPath)))) {
|
|
118
262
|
return;
|
|
119
263
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
encoding,
|
|
124
|
-
});
|
|
264
|
+
const handler = new JSONFileHandler(configPath);
|
|
265
|
+
const [object, error] = await handler.read();
|
|
266
|
+
if (error) {
|
|
125
267
|
return;
|
|
126
268
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
269
|
+
const include =
|
|
270
|
+
// @ts-expect-error
|
|
271
|
+
new Set(object.include ?? []);
|
|
272
|
+
include.add(`.${Paths.normalizeForRoot(this.#source)}`);
|
|
273
|
+
include.add('./generated/vivth/exports');
|
|
274
|
+
const obj = { include: Array.from(include) };
|
|
275
|
+
if (!jstsconfigs) {
|
|
276
|
+
Object.assign(obj, jstsconfigs);
|
|
135
277
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
if (SafeExit.instance) {
|
|
140
|
-
SafeExit.instance.addCallback(async () => {
|
|
141
|
-
watcher.close();
|
|
142
|
-
watcherReadme.close();
|
|
143
|
-
watcher.removeAllListeners();
|
|
144
|
-
watcherReadme.removeAllListeners();
|
|
145
|
-
watcher.removeListener('all', listener);
|
|
146
|
-
watcherReadme.removeAllListeners(this.#readMeListener);
|
|
147
|
-
watcherReadme.removeListener('all', this.#readMeListener);
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
}
|
|
278
|
+
await handler.assign(obj);
|
|
279
|
+
});
|
|
280
|
+
};
|
|
151
281
|
/**
|
|
152
|
-
* @type {
|
|
282
|
+
* @type {ConstructorParameters<typeof JSautoDOC>[0]["onLastGeneratedCallback"]}
|
|
153
283
|
*/
|
|
154
|
-
#
|
|
284
|
+
#onLastGeneratedCallback;
|
|
155
285
|
/**
|
|
156
|
-
* @type {
|
|
157
|
-
* file: string;
|
|
158
|
-
* readMe: string;
|
|
159
|
-
* dir: string;
|
|
160
|
-
* }|undefined}
|
|
286
|
+
* @type {string|undefined}
|
|
161
287
|
*/
|
|
162
|
-
#
|
|
288
|
+
#tableOfContentTitle;
|
|
163
289
|
/**
|
|
164
290
|
* @type {string|undefined}
|
|
165
291
|
*/
|
|
166
|
-
#
|
|
292
|
+
#copyright;
|
|
167
293
|
/**
|
|
168
|
-
* @
|
|
169
|
-
* @param {string} path_
|
|
170
|
-
* @param {Stats|undefined} stats
|
|
171
|
-
* @returns {void}
|
|
294
|
+
* @type {string}
|
|
172
295
|
*/
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
readFile(path_, { encoding }).then((content) => {
|
|
178
|
-
this.#readMESRCContent.value = content;
|
|
179
|
-
});
|
|
180
|
-
};
|
|
296
|
+
// @ts-expect-error
|
|
297
|
+
#readmePath;
|
|
181
298
|
/**
|
|
182
|
-
* @type {
|
|
299
|
+
* @type { string }
|
|
183
300
|
*/
|
|
184
|
-
#
|
|
301
|
+
#readme = Paths.diskAbsolute('./README.md');
|
|
185
302
|
/**
|
|
186
|
-
* @type {
|
|
303
|
+
* @type { import('../typehints/AutoDocASOptions.mjs').AutoDocASOptions|undefined }
|
|
187
304
|
*/
|
|
188
|
-
#
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
305
|
+
#assemblyScriptOptions;
|
|
306
|
+
/**
|
|
307
|
+
* @param {string} path
|
|
308
|
+
* @returns {Promise<{isBeingHandled:boolean, content?: string}>}
|
|
309
|
+
* - is being handled;
|
|
310
|
+
*/
|
|
311
|
+
checkReadmeFile = async (path) => {
|
|
312
|
+
const isREADMEPATH = IsSameFile(this.#readmePath, path);
|
|
313
|
+
if (!isREADMEPATH) {
|
|
314
|
+
return { isBeingHandled: false };
|
|
195
315
|
}
|
|
196
|
-
|
|
197
|
-
if ((await
|
|
198
|
-
|
|
316
|
+
let content = '';
|
|
317
|
+
if (!(await FileSafe.exist(this.#readmePath))) {
|
|
318
|
+
await FileSafe.write(this.#readmePath, `README HEADER PLACEHOLDER`, {
|
|
319
|
+
encoding: Preferrence.encoding,
|
|
320
|
+
});
|
|
199
321
|
}
|
|
200
|
-
const
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
322
|
+
const [res] = await TryAsync(async () => {
|
|
323
|
+
return await readFile(path, { encoding: Preferrence.encoding });
|
|
324
|
+
});
|
|
325
|
+
if (!!res) {
|
|
326
|
+
content = res;
|
|
204
327
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
328
|
+
return { isBeingHandled: true, content };
|
|
329
|
+
};
|
|
330
|
+
/**
|
|
331
|
+
* @param {`.${string}`} extentionName
|
|
332
|
+
* @param {string} path
|
|
333
|
+
* @param {import('fs').Stats} [stats]
|
|
334
|
+
* @returns {Promise<{
|
|
335
|
+
* path: string;
|
|
336
|
+
* parsed: undefined;
|
|
337
|
+
* ext: `.${string}`;
|
|
338
|
+
* type: returnTypeStringType;
|
|
339
|
+
* } | {
|
|
340
|
+
* path: string;
|
|
341
|
+
* parsed: parsedFileForDOC;
|
|
342
|
+
* ext: string;
|
|
343
|
+
* type: returnTypeStringType;
|
|
344
|
+
* }>}
|
|
345
|
+
*/
|
|
346
|
+
#addAndChangesHandler = async (extentionName, path, stats) => {
|
|
347
|
+
const [checkCorrectBeforeParse, errorCorrectBeforeParse] = await TryAsync(async () => {
|
|
348
|
+
return await correctBeforeParse(path, Preferrence.encoding);
|
|
349
|
+
});
|
|
350
|
+
if (errorCorrectBeforeParse) {
|
|
351
|
+
Console.error({ errorCorrectBeforeParse }, { now: true });
|
|
352
|
+
throw '';
|
|
217
353
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
354
|
+
switch (checkCorrectBeforeParse) {
|
|
355
|
+
case 'shouldProceedNextCheck':
|
|
356
|
+
const parsed = new parsedFileForDOC(path, stats);
|
|
357
|
+
await parsed.parse();
|
|
358
|
+
return { ext: extentionName, parsed, path, type: 'handledJS' };
|
|
359
|
+
default:
|
|
360
|
+
throw '';
|
|
222
361
|
}
|
|
362
|
+
};
|
|
363
|
+
/**
|
|
364
|
+
* @returns {Promise<void>}
|
|
365
|
+
*/
|
|
366
|
+
#writeREADMEDefaultSRC = async () => {
|
|
367
|
+
await this.#readmeSourceGetterSetter.set?.(`---\n---\n---\nREADME SRC PLACEHOLDER\n---\n---\n`);
|
|
368
|
+
};
|
|
369
|
+
#readmeSourceGetterSetter = new GetterSetter({
|
|
370
|
+
get: async () => {
|
|
371
|
+
return await readFile(this.#readmePath, { encoding: Preferrence.encoding });
|
|
372
|
+
},
|
|
373
|
+
/**
|
|
374
|
+
* @param {string} content
|
|
375
|
+
*/
|
|
376
|
+
set: async (content) => {
|
|
377
|
+
await FileSafe.write(this.#readmePath, content, { encoding: Preferrence.encoding });
|
|
378
|
+
},
|
|
223
379
|
});
|
|
380
|
+
|
|
224
381
|
/**
|
|
225
|
-
* @param {string}
|
|
226
|
-
* @
|
|
382
|
+
* @param { string } [exporter]
|
|
383
|
+
* @param { string } [typedefString]
|
|
384
|
+
* @returns { string }
|
|
227
385
|
*/
|
|
228
|
-
#
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
386
|
+
#generateSingularMJSExportAndType = (exporter, typedefString) => {
|
|
387
|
+
let content = '';
|
|
388
|
+
if (exporter) {
|
|
389
|
+
content += exporter ?? '';
|
|
390
|
+
}
|
|
391
|
+
if (exporter && typedefString) {
|
|
392
|
+
content += '\n';
|
|
393
|
+
}
|
|
394
|
+
if (typedefString) {
|
|
395
|
+
content += typedefString ?? '';
|
|
396
|
+
}
|
|
397
|
+
return content;
|
|
233
398
|
};
|
|
399
|
+
|
|
234
400
|
/**
|
|
235
|
-
* @
|
|
236
|
-
* @
|
|
237
|
-
* @property { string } mjsFile
|
|
401
|
+
* @param { string[] } array
|
|
402
|
+
* @returns { string[] }
|
|
238
403
|
*/
|
|
404
|
+
#cleanupArrayString = (array) => {
|
|
405
|
+
return array.filter((s) => s.trim() !== '');
|
|
406
|
+
};
|
|
407
|
+
|
|
239
408
|
/**
|
|
240
|
-
* @param {string
|
|
241
|
-
*
|
|
242
|
-
*
|
|
409
|
+
* @param {[path: string, {
|
|
410
|
+
* path: string;
|
|
411
|
+
* parsed: undefined;
|
|
412
|
+
* ext: `.${string}`;
|
|
413
|
+
* type: returnTypeStringType;
|
|
414
|
+
* readme?: string;
|
|
415
|
+
* } | {
|
|
416
|
+
* path: string;
|
|
417
|
+
* parsed: parsedFileForDOC;
|
|
418
|
+
* ext: string;
|
|
419
|
+
* type: returnTypeStringType;
|
|
420
|
+
* readme?: string;
|
|
421
|
+
* }][]} array
|
|
422
|
+
* @returns {Promise<{
|
|
423
|
+
* readme:string,
|
|
424
|
+
* platforms:{
|
|
425
|
+
* node:string,
|
|
426
|
+
* browser:string,
|
|
427
|
+
* neutral:string,
|
|
428
|
+
* unsupported:string,
|
|
429
|
+
* all:string,
|
|
430
|
+
* },
|
|
431
|
+
* }|undefined>}
|
|
243
432
|
*/
|
|
244
|
-
#generateFromSRC = async (
|
|
433
|
+
#generateFromSRC = async (array) => {
|
|
434
|
+
const contentSRC = (await this.#readmeSourceGetterSetter.get?.()) ?? '';
|
|
245
435
|
if (this.#tableOfContentTitle === undefined || this.#copyright === undefined) {
|
|
246
436
|
return;
|
|
247
437
|
}
|
|
248
438
|
const tableID = this.#tableOfContentTitle.replace(/\s+/g, '-').toLowerCase();
|
|
439
|
+
/**
|
|
440
|
+
* @type { string[] }
|
|
441
|
+
*/
|
|
249
442
|
const tableOfContent = [];
|
|
443
|
+
/**
|
|
444
|
+
* @type { string[] }
|
|
445
|
+
*/
|
|
250
446
|
const apiDocuments = [];
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
447
|
+
/**
|
|
448
|
+
* @type { Array<string> }
|
|
449
|
+
*/
|
|
450
|
+
const all = [];
|
|
451
|
+
/**
|
|
452
|
+
* @type { Array<string> }
|
|
453
|
+
*/
|
|
454
|
+
const node = [];
|
|
455
|
+
/**
|
|
456
|
+
* @type { Array<string> }
|
|
457
|
+
*/
|
|
458
|
+
const browser = [];
|
|
459
|
+
/**
|
|
460
|
+
* @type { Array<string> }
|
|
461
|
+
*/
|
|
462
|
+
const neutral = [];
|
|
463
|
+
/**
|
|
464
|
+
* @type { Array<string> }
|
|
465
|
+
*/
|
|
466
|
+
const unsupported = [];
|
|
467
|
+
|
|
468
|
+
await Promise.all(
|
|
469
|
+
ForEach.array(array, async ([, { parsed }], i) => {
|
|
470
|
+
if (!parsed) {
|
|
471
|
+
return;
|
|
472
|
+
}
|
|
473
|
+
const {
|
|
474
|
+
documented,
|
|
475
|
+
content,
|
|
476
|
+
hasValidExportObject,
|
|
477
|
+
path: { relative: relativePath },
|
|
478
|
+
baseName: { noExt },
|
|
479
|
+
platform,
|
|
480
|
+
} = parsed;
|
|
481
|
+
const awaitedPlatform = await platform;
|
|
482
|
+
const trueContent = await content.string();
|
|
483
|
+
if (trueContent === undefined) {
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
486
|
+
const hasNoAutoDoc = /\/\*\*[\s\*]*?@noautodoc[\s\*]*?\*\//.test(trueContent);
|
|
487
|
+
/**
|
|
488
|
+
* @type { undefined|string }
|
|
489
|
+
*/
|
|
490
|
+
let comprehensiveExporter;
|
|
280
491
|
if (hasValidExportObject) {
|
|
281
|
-
|
|
492
|
+
comprehensiveExporter = `export { ${noExt} } from '${
|
|
493
|
+
relativePath.startsWith('.') ? relativePath : `./${relativePath}`
|
|
494
|
+
}';`;
|
|
282
495
|
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
496
|
+
/**
|
|
497
|
+
* @type {string[]}
|
|
498
|
+
*/
|
|
499
|
+
const currentDescription = [];
|
|
500
|
+
const { readme, typedef } = documented;
|
|
501
|
+
const [typedefString] = await TryAsync(async () => {
|
|
502
|
+
if (hasValidExportObject) {
|
|
503
|
+
throw 'has no valid export object';
|
|
504
|
+
}
|
|
505
|
+
const result = await typedef();
|
|
506
|
+
return result;
|
|
507
|
+
});
|
|
508
|
+
/**
|
|
509
|
+
* @type { undefined|string }
|
|
510
|
+
*/
|
|
511
|
+
let comprehensiveTypedefString;
|
|
512
|
+
if (typedefString) {
|
|
513
|
+
const typedefStringModule = typedefString.module;
|
|
514
|
+
comprehensiveTypedefString = typedefStringModule;
|
|
515
|
+
if (!hasNoAutoDoc) {
|
|
516
|
+
const nameVarID = noExt.toLowerCase();
|
|
517
|
+
tableOfContent[i] =
|
|
518
|
+
tableOfContent[i] ?? '' + `[${awaitedPlatform}.${noExt}](#${nameVarID})`;
|
|
519
|
+
apiDocuments[i] =
|
|
520
|
+
apiDocuments[i] ??
|
|
521
|
+
'' +
|
|
522
|
+
`<h2 id="${nameVarID}">${awaitedPlatform}.${noExt}</h2>\n\n- jsdoc types:\n\n\`\`\`js\n${
|
|
523
|
+
/** */
|
|
524
|
+
typedefString.readme.replace(/\[at\]/g, '@').replace(/\[blank\]/g, '[]')
|
|
525
|
+
}\n\`\`\`\n*) <sub>[go to ${this.#tableOfContentTitle}](#${tableID})</sub>\n\n---`;
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
if (!hasNoAutoDoc && hasValidExportObject) {
|
|
529
|
+
ForOfSync(
|
|
530
|
+
readme,
|
|
531
|
+
({
|
|
532
|
+
// fullDescription,
|
|
533
|
+
// instanceOrStatic,
|
|
534
|
+
// namedVar,
|
|
535
|
+
// typeOfVar,
|
|
536
|
+
parsedFullDescription,
|
|
537
|
+
reference,
|
|
538
|
+
}) => {
|
|
539
|
+
const { description, jsPreview } = parsedFullDescription;
|
|
540
|
+
currentDescription.push(
|
|
541
|
+
`\n#### reference: ${reference}\n${description}\n${jsPreview}`.replace(
|
|
542
|
+
/\[blank\]/g,
|
|
543
|
+
'',
|
|
544
|
+
),
|
|
545
|
+
);
|
|
546
|
+
},
|
|
295
547
|
);
|
|
548
|
+
const nameVarID = noExt.toLowerCase();
|
|
549
|
+
tableOfContent[i] =
|
|
550
|
+
tableOfContent[i] ?? '' + `[${awaitedPlatform}.${noExt}](#${noExt.toLowerCase()})`;
|
|
551
|
+
apiDocuments[i] =
|
|
552
|
+
apiDocuments[i] ??
|
|
553
|
+
'' +
|
|
554
|
+
`<h2 id="${nameVarID}">${awaitedPlatform}.${noExt}</h2>\n\n-current-description-to-replace-\n\n*) <sub>[go to ${
|
|
555
|
+
this.#tableOfContentTitle
|
|
556
|
+
}](#${tableID})</sub>\n\n---`.replace(
|
|
557
|
+
'-current-description-to-replace-',
|
|
558
|
+
currentDescription.join('\n'),
|
|
559
|
+
);
|
|
296
560
|
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
// fullDescription,
|
|
302
|
-
// instanceOrStatic,
|
|
303
|
-
// namedVar,
|
|
304
|
-
// typeOfVar,
|
|
305
|
-
parsedFullDescription,
|
|
306
|
-
reference,
|
|
307
|
-
} = ref;
|
|
308
|
-
const { description, jsPreview } = parsedFullDescription;
|
|
309
|
-
currentDescription.push(`\n#### reference:${reference}\n${description}\n${jsPreview}`);
|
|
310
|
-
});
|
|
311
|
-
const nameVarID = noExt.toLowerCase();
|
|
312
|
-
tableOfContent.push(`[${noExt}](#${noExt.toLowerCase()})`);
|
|
313
|
-
apiDocuments.push(
|
|
314
|
-
`<h2 id="${nameVarID}">${noExt}</h2>\n\n-current-description-to-replace-\n\n*) <sub>[go to ${
|
|
315
|
-
this.#tableOfContentTitle
|
|
316
|
-
}](#${tableID})</sub>`.replace(
|
|
317
|
-
'-current-description-to-replace-',
|
|
318
|
-
currentDescription.join('\n')
|
|
319
|
-
)
|
|
561
|
+
|
|
562
|
+
const collectedExportContent = this.#generateSingularMJSExportAndType(
|
|
563
|
+
comprehensiveExporter,
|
|
564
|
+
comprehensiveTypedefString,
|
|
320
565
|
);
|
|
321
|
-
|
|
322
|
-
|
|
566
|
+
if (collectedExportContent) {
|
|
567
|
+
all[i] = collectedExportContent;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
switch (awaitedPlatform) {
|
|
571
|
+
case 'node':
|
|
572
|
+
{
|
|
573
|
+
if (collectedExportContent) {
|
|
574
|
+
node[i] = collectedExportContent;
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
break;
|
|
578
|
+
case 'browser':
|
|
579
|
+
{
|
|
580
|
+
if (collectedExportContent) {
|
|
581
|
+
browser[i] = collectedExportContent;
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
break;
|
|
585
|
+
case 'neutral':
|
|
586
|
+
{
|
|
587
|
+
if (collectedExportContent) {
|
|
588
|
+
neutral[i] = collectedExportContent;
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
break;
|
|
592
|
+
default:
|
|
593
|
+
case 'unsupported':
|
|
594
|
+
{
|
|
595
|
+
if (collectedExportContent) {
|
|
596
|
+
unsupported[i] = collectedExportContent;
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
break;
|
|
600
|
+
}
|
|
601
|
+
}),
|
|
602
|
+
);
|
|
323
603
|
const tableOfContentString = `<h2 id="${this.#tableOfContentTitle
|
|
324
604
|
.replace(/\s+/g, '-')
|
|
325
605
|
.toLowerCase()}">${
|
|
326
606
|
this.#tableOfContentTitle
|
|
327
|
-
}</h2>\n\n - -table-of-content-to-replace-\n\n-api-document-to-replace-`
|
|
328
|
-
.replace(
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
const prefix = 'parsedFiles:';
|
|
607
|
+
}</h2>\n\n - -table-of-content-to-replace-\n\n---\n\n-api-document-to-replace-`
|
|
608
|
+
.replace(
|
|
609
|
+
'-table-of-content-to-replace-',
|
|
610
|
+
this.#cleanupArrayString(tableOfContent).join('\n - '),
|
|
611
|
+
)
|
|
612
|
+
.replace('-api-document-to-replace-', this.#cleanupArrayString(apiDocuments).join('\n\n'));
|
|
613
|
+
|
|
614
|
+
const readme = `${contentSRC}\n\n---\n\n${tableOfContentString}`;
|
|
615
|
+
|
|
337
616
|
return {
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
return dispatch;
|
|
346
|
-
},
|
|
347
|
-
/**
|
|
348
|
-
* @param {string} path__
|
|
349
|
-
* @returns {Promise<void>}
|
|
350
|
-
*/
|
|
351
|
-
unRef: async (path__) => {
|
|
352
|
-
const parsedFile = await this.#parsedFilesRef.get(`${prefix}${path__}`);
|
|
353
|
-
parsedFile.remove.ref();
|
|
617
|
+
readme,
|
|
618
|
+
platforms: {
|
|
619
|
+
all: this.#cleanupArrayString(all).join('\n'),
|
|
620
|
+
browser: this.#cleanupArrayString(browser).join('\n'),
|
|
621
|
+
neutral: this.#cleanupArrayString(neutral).join('\n'),
|
|
622
|
+
node: this.#cleanupArrayString(node).join('\n'),
|
|
623
|
+
unsupported: this.#cleanupArrayString(unsupported).join('\n'),
|
|
354
624
|
},
|
|
355
625
|
};
|
|
356
|
-
}
|
|
626
|
+
};
|
|
627
|
+
|
|
357
628
|
/**
|
|
358
|
-
* @
|
|
629
|
+
* @param {string} name
|
|
630
|
+
* @param {boolean} absolutePath
|
|
631
|
+
* @returns {string}
|
|
359
632
|
*/
|
|
360
|
-
#
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
) {
|
|
366
|
-
return;
|
|
367
|
-
}
|
|
368
|
-
const res = await correctBeforeParse(path__, 'utf-8');
|
|
369
|
-
switch (res) {
|
|
370
|
-
case 'shouldProceedNextCheck':
|
|
371
|
-
const dispatch = await this.#parsedFilesRef.get(path__);
|
|
372
|
-
dispatch.value = new parsedFile(path__, _stats, encoding);
|
|
373
|
-
this.#filePaths.subscribers.notify(async ({ signalInstance }) => {
|
|
374
|
-
await dispatch.value.parse();
|
|
375
|
-
dispatch.subscribers.notify();
|
|
376
|
-
Console.info({ vivthJSautoDOC: `${eventName} '${path__}' to export and doc` });
|
|
377
|
-
signalInstance.value.add(path__);
|
|
378
|
-
});
|
|
379
|
-
break;
|
|
380
|
-
case 'waitForRewrite':
|
|
381
|
-
case 'doNotProcess':
|
|
382
|
-
break;
|
|
633
|
+
#generateExportPath = (name, absolutePath) => {
|
|
634
|
+
const rel = Paths.normalize(join(multiExportEntryPointsPath, `${name}.mjs`));
|
|
635
|
+
if (!absolutePath) {
|
|
636
|
+
if (!rel.startsWith('.')) {
|
|
637
|
+
return `./${rel}`;
|
|
383
638
|
}
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
639
|
+
return rel;
|
|
640
|
+
}
|
|
641
|
+
return Paths.normalize(join(Paths.root, rel));
|
|
642
|
+
};
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* @param {string} content
|
|
646
|
+
* @returns {string}
|
|
647
|
+
*/
|
|
648
|
+
#generateExportMJSDOCFromstring = (content) => {
|
|
649
|
+
return `// @ts-check\n/**\n * automatically generated by \`JSautoDOC\`\n * @copyright\n${(
|
|
650
|
+
this.#copyright ?? ''
|
|
651
|
+
).replace(/^/gm, ' * ')}\n */\n${content}`;
|
|
652
|
+
};
|
|
653
|
+
|
|
654
|
+
/**
|
|
655
|
+
* @param {string} name
|
|
656
|
+
* @param {Object} [packageJSONObject]
|
|
657
|
+
* @returns {void}
|
|
658
|
+
*/
|
|
659
|
+
#assignToPackageJSONExports = (name, packageJSONObject) => {
|
|
660
|
+
if (!packageJSONObject) {
|
|
661
|
+
return;
|
|
662
|
+
}
|
|
663
|
+
const relativePath = this.#generateExportPath(name, false);
|
|
664
|
+
if (name === 'all') {
|
|
665
|
+
Object.assign(packageJSONObject, { main: relativePath, module: relativePath });
|
|
666
|
+
}
|
|
667
|
+
Object.assign(packageJSONObject, {
|
|
668
|
+
exports: {
|
|
669
|
+
...// @ts-expect-error
|
|
670
|
+
(packageJSONObject.exports ?? {}),
|
|
671
|
+
[`.${Paths.normalizeForRoot(name)}`]: {
|
|
672
|
+
import: relativePath,
|
|
673
|
+
types: relativePath.replace('./', './generated/types/').replace(/\.mjs$/g, '.d.mts'),
|
|
674
|
+
},
|
|
675
|
+
},
|
|
389
676
|
});
|
|
390
677
|
};
|
|
678
|
+
|
|
391
679
|
/**
|
|
392
|
-
* @
|
|
680
|
+
* @param {{
|
|
681
|
+
* all:string,
|
|
682
|
+
* node:string,
|
|
683
|
+
* browser:string,
|
|
684
|
+
* neutral:string,
|
|
685
|
+
* unsupported:string,
|
|
686
|
+
* }} platforms
|
|
687
|
+
* @param {BufferEncoding} encoding
|
|
688
|
+
* @param {any} packageJSONObject
|
|
689
|
+
* @param {'node'|'browser'|'neutral'|'unsupported'} name
|
|
690
|
+
* @returns {ReturnType<typeof TryAsync<void>>}
|
|
393
691
|
*/
|
|
394
|
-
#
|
|
395
|
-
TryAsync(async () => {
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
692
|
+
#generatePlatformsHandler = (platforms, encoding, packageJSONObject, name) => {
|
|
693
|
+
return TryAsync(async () => {
|
|
694
|
+
const path = this.#generateExportPath(name, true);
|
|
695
|
+
if (!platforms[name]) {
|
|
696
|
+
const [, errorRemovingPath] = await FileSafe.rm(path);
|
|
697
|
+
if (errorRemovingPath) {
|
|
698
|
+
return;
|
|
699
|
+
}
|
|
700
|
+
Console.info(
|
|
701
|
+
{
|
|
702
|
+
JSautoDOC: `✅ Successfully deleting '${path}' for having no valid exports`,
|
|
703
|
+
},
|
|
704
|
+
{
|
|
705
|
+
now: true,
|
|
706
|
+
},
|
|
707
|
+
);
|
|
402
708
|
return;
|
|
403
709
|
}
|
|
404
|
-
this.#
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
710
|
+
const content = this.#generateExportMJSDOCFromstring(platforms[name]);
|
|
711
|
+
this.#assignToPackageJSONExports(name, packageJSONObject);
|
|
712
|
+
await FileSafe.write(path, content, {
|
|
713
|
+
encoding,
|
|
408
714
|
});
|
|
715
|
+
Console.info(
|
|
716
|
+
{
|
|
717
|
+
JSautoDOC: `✅ Successfully write '${path}'`,
|
|
718
|
+
},
|
|
719
|
+
{
|
|
720
|
+
now: true,
|
|
721
|
+
},
|
|
722
|
+
);
|
|
409
723
|
});
|
|
410
724
|
};
|
|
725
|
+
|
|
726
|
+
/**
|
|
727
|
+
* @type {FSDirArchWatcher__["fullHandler"]}
|
|
728
|
+
*/
|
|
729
|
+
#fullHandler = async ({ array, map }) => {
|
|
730
|
+
const readmePath = this.#readme;
|
|
731
|
+
Console.info(
|
|
732
|
+
{
|
|
733
|
+
JSautoDOC: `generating content for '${Paths.normalize(readmePath)}'`,
|
|
734
|
+
},
|
|
735
|
+
{
|
|
736
|
+
now: true,
|
|
737
|
+
},
|
|
738
|
+
);
|
|
739
|
+
const res = await this.#generateFromSRC(array);
|
|
740
|
+
if (!res) {
|
|
741
|
+
return;
|
|
742
|
+
}
|
|
743
|
+
const { readme, platforms } = res;
|
|
744
|
+
const [packageJSONObject] = await this.#packageJSONHandler.read();
|
|
745
|
+
const encoding = Preferrence.encoding;
|
|
746
|
+
const [promises_] = ForOfSync(
|
|
747
|
+
['all', 'browser', 'node', 'neutral', 'unsupported'],
|
|
748
|
+
async (key) => {
|
|
749
|
+
await this.#generatePlatformsHandler(
|
|
750
|
+
platforms,
|
|
751
|
+
encoding,
|
|
752
|
+
packageJSONObject,
|
|
753
|
+
// @ts-expect-error
|
|
754
|
+
key,
|
|
755
|
+
);
|
|
756
|
+
},
|
|
757
|
+
);
|
|
758
|
+
const [[, errorWriteReadme]] = await Promise.all([
|
|
759
|
+
TryAsync(async () => {
|
|
760
|
+
return await FileSafe.write(
|
|
761
|
+
readmePath,
|
|
762
|
+
await prettier.format(readme, { parser: 'markdown' }),
|
|
763
|
+
{
|
|
764
|
+
encoding,
|
|
765
|
+
},
|
|
766
|
+
);
|
|
767
|
+
}),
|
|
768
|
+
...promises_,
|
|
769
|
+
]);
|
|
770
|
+
if (!!packageJSONObject) {
|
|
771
|
+
await this.#packageJSONHandler.write(packageJSONObject);
|
|
772
|
+
}
|
|
773
|
+
if (errorWriteReadme === undefined) {
|
|
774
|
+
Console.info(
|
|
775
|
+
{
|
|
776
|
+
JSautoDOC: `✅ Successfully generate '${Paths.normalize(readmePath)}';`,
|
|
777
|
+
},
|
|
778
|
+
{
|
|
779
|
+
now: true,
|
|
780
|
+
},
|
|
781
|
+
);
|
|
782
|
+
}
|
|
783
|
+
if (errorWriteReadme) {
|
|
784
|
+
Console.error(
|
|
785
|
+
{
|
|
786
|
+
JSautoDOC: `❌ Unable to generate '${Paths.normalize(readmePath)}';`,
|
|
787
|
+
errorWriteReadme,
|
|
788
|
+
},
|
|
789
|
+
{
|
|
790
|
+
now: true,
|
|
791
|
+
},
|
|
792
|
+
);
|
|
793
|
+
return;
|
|
794
|
+
}
|
|
795
|
+
if (!this.#onLastGeneratedCallback) {
|
|
796
|
+
return;
|
|
797
|
+
}
|
|
798
|
+
await this.#onLastGeneratedCallback({ map });
|
|
799
|
+
};
|
|
411
800
|
}
|