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
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
* @param {()=>Promise<boolean>} testCallback
|
|
7
7
|
* - already wrapped with `TryAsync`:
|
|
8
8
|
* >- if throws error will automatically return false;
|
|
9
|
-
* @returns {
|
|
10
|
-
* - calling `removeId` will remove
|
|
9
|
+
* @returns {{removeId:()=>void}}
|
|
10
|
+
* - calling `removeId` will remove this test from reports;
|
|
11
11
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @template {import(
|
|
4
|
+
* @template {import("./LitExpKeyType.mjs").LitExpKeyType} KEYS
|
|
5
5
|
* @typedef {{result:{whole:string[], named:Array<Record<keyof KEYS, string>>},
|
|
6
6
|
* regexp: RegExp}} LitExpResultType
|
|
7
7
|
*/
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @description
|
|
5
|
+
* - type helper for `MonkeyPatch`;
|
|
6
|
+
* @template {any} ORIOBJ
|
|
7
|
+
* @typedef {ORIOBJ extends (...args: infer A) => infer R
|
|
8
|
+
* ? (...args: A) => R
|
|
9
|
+
* : ORIOBJ extends abstract new (...args: infer C) => infer I
|
|
10
|
+
* ? abstract new (...args: C) => I
|
|
11
|
+
* : any
|
|
12
|
+
* } MonkeyPatchedType
|
|
13
|
+
*/
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @preserve
|
|
3
|
+
* @description
|
|
4
|
+
* - Drop the first N parameters from METHOD and return the rest;
|
|
5
|
+
* @template {(...args: any[]) => any} METHOD
|
|
6
|
+
* @template {number} N
|
|
7
|
+
* @typedef {import('./ParametersFollowingN.mts').ParametersFollowingN<N, METHOD>} ParametersFollowingN
|
|
8
|
+
*/
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility: build a tuple of length N filled with type T (default = any).
|
|
3
|
+
*/
|
|
4
|
+
export type TupleOfLength<N extends number, T = any, R extends any[] = []> = R['length'] extends N
|
|
5
|
+
? R
|
|
6
|
+
: TupleOfLength<N, T, [...R, T]>;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @preserve
|
|
10
|
+
* @description
|
|
11
|
+
* - Drop the first N parameters from METHOD and return the rest;
|
|
12
|
+
* @template {(...args: any[]) => any} METHOD
|
|
13
|
+
* @template {number} N
|
|
14
|
+
* @[blank]typedef {import('./ParametersFollowingN.mts').ParametersFollowingN<N, METHOD>} ParametersFollowingN
|
|
15
|
+
*/
|
|
16
|
+
export type ParametersFollowingN<METHOD extends (...args: any[]) => any, N extends number> =
|
|
17
|
+
Parameters<METHOD> extends [...TupleOfLength<N>, ...infer Rest] ? Rest : [];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// @ts-expect-error
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @import {WC_StyleProp_bind} from '../web/bindings/WC_StyleProp_bind.mjs'
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @description
|
|
9
|
+
* - typehelper to constrict [StyleRef](#styleref) values;
|
|
10
|
+
* @template {string} STRTYPE
|
|
11
|
+
* @typedef {ReturnType<typeof WC_StyleProp_bind<STRTYPE>>} StylePropRefType
|
|
12
|
+
*/
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* - type helper for typing `vivth.TemplateLiteral`;
|
|
5
|
+
* @template {any} INPUTTYPE
|
|
6
|
+
* @callback TemplateLiteralValueHandler
|
|
7
|
+
* @param {Object} arg0
|
|
8
|
+
* @param {INPUTTYPE} arg0.currentValue
|
|
9
|
+
* @param {number} arg0.index
|
|
10
|
+
* @param {TemplateStringsArray} arg0.templateStringsArray
|
|
11
|
+
* @param {INPUTTYPE[]} arg0.valuesArrays
|
|
12
|
+
* @param {number} arg0.inputLength
|
|
13
|
+
* @returns {(string|Promise<string>)}
|
|
14
|
+
*/
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @template {keyof HTMLElementTagNameMap} TAGNAME
|
|
5
|
+
* @typedef {Object} VLifecycleCallbacks
|
|
6
|
+
* @property {(this:HTMLElementTagNameMap[TAGNAME], defer:(onDisconnected:()=>void)=>void)=>void} [onConnected]
|
|
7
|
+
* @property {(this:HTMLElementTagNameMap[TAGNAME])=>void} [onDisconnected]
|
|
8
|
+
* @property {(this:HTMLElementTagNameMap[TAGNAME], defer:(onDisconnected:()=>void)=>void)=>void} [onAdopted]
|
|
9
|
+
* @property {(this:HTMLElementTagNameMap[TAGNAME], name:string, oldValue:string, newValue:string)=>void} [onAttributeChanged]
|
|
10
|
+
*/
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @description
|
|
5
|
+
* - return type of object have this method;
|
|
6
|
+
* @typedef {{vivthCleanup: ()=>Promise<any>}} VivthCleanup
|
|
7
|
+
* - you can call:
|
|
8
|
+
* ```js
|
|
9
|
+
* something.vivthCleanup();
|
|
10
|
+
* ```
|
|
11
|
+
* >- class that implements this;
|
|
12
|
+
* >- function that have this as part of it's return;
|
|
13
|
+
* - to clean up that object, usually a long lived process;
|
|
14
|
+
*/
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
import { join, relative, dirname, resolve } from 'node:path';
|
|
4
|
+
import { readFile } from 'node:fs/promises';
|
|
5
|
+
|
|
6
|
+
import domino from 'domino';
|
|
7
|
+
|
|
8
|
+
import { pluginVivthBundle } from '../bundler/adds/pluginVivthBundle.mjs';
|
|
9
|
+
import { JSDirMapper } from '../bundler/JSDirMapper.mjs';
|
|
10
|
+
import { FSDirArchWatcher } from '../class/FSDirArchWatcher.mjs';
|
|
11
|
+
import { Paths } from '../class/Paths.mjs';
|
|
12
|
+
import { FileSafe } from '../class/FileSafe.mjs';
|
|
13
|
+
import { ForOfSync } from '../function/ForOfSync.mjs';
|
|
14
|
+
import { Console } from '../class/Console.mjs';
|
|
15
|
+
import { LastEditedUnix } from '../bundler/adds/LastEditedUnix.mjs';
|
|
16
|
+
import { Prettivy } from '../class/Prettivy.mjs';
|
|
17
|
+
import { SafeExit } from '../class/SafeExit.mjs';
|
|
18
|
+
import { Preferrence } from '../common/Preferrence.mjs';
|
|
19
|
+
import { NewDynamicsExport } from '../function/NewDynamicsExport.mjs';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @typedef {import('../typehints/VivthCleanup.mjs').VivthCleanup} VivthCleanup
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @description
|
|
27
|
+
* - class helper to map dynamic mjs files;
|
|
28
|
+
* >- includes `mts` file too;
|
|
29
|
+
* @implements {VivthCleanup}
|
|
30
|
+
*/
|
|
31
|
+
export class BrowserDirMapper {
|
|
32
|
+
vivthCleanup = async () => {
|
|
33
|
+
SafeExit.instance?.removeCallback(this.#safeExitCallback);
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* @type {Set<string>}
|
|
37
|
+
*/
|
|
38
|
+
#setOfHtmlPaths = new Set();
|
|
39
|
+
/**
|
|
40
|
+
* @type {Map<string, number>}
|
|
41
|
+
* - `fullpath`;
|
|
42
|
+
* - `fullpath?t=${lastEditedUnixValue}`;
|
|
43
|
+
*/
|
|
44
|
+
#mapOfAssets = new Map();
|
|
45
|
+
/**
|
|
46
|
+
* @description
|
|
47
|
+
* - instantiate the mapper;
|
|
48
|
+
* @param {Object} path
|
|
49
|
+
* @param {string} path.watch
|
|
50
|
+
* @param {string} path.mapTo
|
|
51
|
+
* @param {(normalizedPath:string)=>boolean} [path.eachFilter]
|
|
52
|
+
* @param {ConstructorParameters<typeof JSDirMapper>[1] &
|
|
53
|
+
* {
|
|
54
|
+
* debounce?:number,
|
|
55
|
+
* chokidarOptions?:import('chokidar').ChokidarOptions
|
|
56
|
+
* }
|
|
57
|
+
* } options
|
|
58
|
+
* @example
|
|
59
|
+
* import { BrowserDirMapper } from 'vivth/node'
|
|
60
|
+
* import { Paths, SafeExit, BrowserDirMapper } from 'vivth/neutral';
|
|
61
|
+
*
|
|
62
|
+
* new Paths({
|
|
63
|
+
* root: process.env.INIT_CWD ?? process.cwd(),
|
|
64
|
+
* });
|
|
65
|
+
*
|
|
66
|
+
* new SafeExit();
|
|
67
|
+
*
|
|
68
|
+
* new BrowserDirMapper(
|
|
69
|
+
* { mapTo: '/dist/', watch: '/src/' },
|
|
70
|
+
* {
|
|
71
|
+
* esbuild: {
|
|
72
|
+
* buildOptions: {
|
|
73
|
+
* minify: true,
|
|
74
|
+
* },
|
|
75
|
+
* },
|
|
76
|
+
* },
|
|
77
|
+
* );
|
|
78
|
+
*/
|
|
79
|
+
constructor({ watch, mapTo, eachFilter }, options) {
|
|
80
|
+
this.#start({ watch, mapTo, eachFilter }, options);
|
|
81
|
+
SafeExit.instance?.addCallback(this.#safeExitCallback);
|
|
82
|
+
}
|
|
83
|
+
#safeExitCallback = async () => {
|
|
84
|
+
await Promise.all(
|
|
85
|
+
ForOfSync(this.#setOfHtmlPaths, async (htmlTargetPath) => {
|
|
86
|
+
const prettivy = new Prettivy(htmlTargetPath);
|
|
87
|
+
const document = domino.createDocument(
|
|
88
|
+
(await readFile(htmlTargetPath, { encoding: Preferrence.encoding })) ?? '',
|
|
89
|
+
);
|
|
90
|
+
const assetSelector = '[src], link[href], [srcset], object[data]';
|
|
91
|
+
const elements = document.querySelectorAll(assetSelector);
|
|
92
|
+
const htmlDirname = dirname(htmlTargetPath);
|
|
93
|
+
await Promise.all(
|
|
94
|
+
ForOfSync(elements, async (element) => {
|
|
95
|
+
if (element.hasAttribute('src')) {
|
|
96
|
+
const currentValue = element.getAttribute('src') ?? '';
|
|
97
|
+
const assetPath = Paths.normalize(resolve(htmlDirname, currentValue));
|
|
98
|
+
if (this.#mapOfAssets.has(assetPath)) {
|
|
99
|
+
const timedAsset = `./${Paths.normalize(relative(htmlDirname, assetPath))}?t=${this.#mapOfAssets.get(assetPath)}`;
|
|
100
|
+
element.setAttribute('src', timedAsset);
|
|
101
|
+
}
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (element.hasAttribute('srcset')) {
|
|
105
|
+
const currentValue = element.getAttribute('srcset') ?? '';
|
|
106
|
+
const assetPath = Paths.normalize(resolve(htmlDirname, currentValue));
|
|
107
|
+
if (this.#mapOfAssets.has(assetPath)) {
|
|
108
|
+
const timedAsset = `./${Paths.normalize(relative(htmlDirname, assetPath))}?t=${this.#mapOfAssets.get(assetPath)}`;
|
|
109
|
+
element.setAttribute('srcset', timedAsset);
|
|
110
|
+
}
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
if (element.tagName.toLowerCase() === 'link' && element.hasAttribute('href')) {
|
|
114
|
+
const currentValue = element.getAttribute('href') ?? '';
|
|
115
|
+
const assetPath = Paths.normalize(resolve(htmlDirname, currentValue));
|
|
116
|
+
if (this.#mapOfAssets.has(assetPath)) {
|
|
117
|
+
const timedAsset = `./${Paths.normalize(relative(htmlDirname, assetPath))}?t=${this.#mapOfAssets.get(assetPath)}`;
|
|
118
|
+
element.setAttribute('href', timedAsset);
|
|
119
|
+
}
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
if (element.tagName.toLowerCase() === 'object' && element.hasAttribute('data')) {
|
|
123
|
+
const currentValue = element.getAttribute('data') ?? '';
|
|
124
|
+
const assetPath = Paths.normalize(resolve(htmlDirname, currentValue));
|
|
125
|
+
if (this.#mapOfAssets.has(assetPath)) {
|
|
126
|
+
const timedAsset = `./${Paths.normalize(relative(htmlDirname, assetPath))}?t=${this.#mapOfAssets.get(assetPath)}`;
|
|
127
|
+
element.setAttribute('object', timedAsset);
|
|
128
|
+
}
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
})[0],
|
|
132
|
+
);
|
|
133
|
+
const updatedHtml = document.documentElement.outerHTML;
|
|
134
|
+
const finalFileString = await prettivy.format(`<!DOCTYPE html>\n${updatedHtml}`);
|
|
135
|
+
await FileSafe.write(htmlTargetPath, finalFileString, { encoding: Preferrence.encoding });
|
|
136
|
+
Console.info(`✅ Successfully patch '${htmlTargetPath}' assets path`);
|
|
137
|
+
})[0],
|
|
138
|
+
);
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* @param {ConstructorParameters<typeof BrowserDirMapper>} args
|
|
142
|
+
*/
|
|
143
|
+
#start = async (...args) => {
|
|
144
|
+
const [
|
|
145
|
+
{ watch, mapTo, eachFilter },
|
|
146
|
+
{
|
|
147
|
+
esbuild: { buildOptions, watchOption },
|
|
148
|
+
asTsToMjsHandler,
|
|
149
|
+
chokidarOptions,
|
|
150
|
+
debounce,
|
|
151
|
+
},
|
|
152
|
+
] = args;
|
|
153
|
+
const watchPath = Paths.diskAbsolute(watch);
|
|
154
|
+
const mapToPath = Paths.diskAbsolute(mapTo);
|
|
155
|
+
const pathDynamic = Paths.normalize(join(watchPath, 'dynamics'));
|
|
156
|
+
const dynamicImports = 'Dynamics';
|
|
157
|
+
const pathGeneratedDynamicMapped = Paths.normalize(join(pathDynamic, `${dynamicImports}.mjs`));
|
|
158
|
+
await Promise.all(
|
|
159
|
+
ForOfSync([pathDynamic], async (path) => {
|
|
160
|
+
FileSafe.exist(path).then(async (isExist) => {
|
|
161
|
+
if (isExist) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
await FileSafe.mkdir(path);
|
|
165
|
+
});
|
|
166
|
+
})[0],
|
|
167
|
+
);
|
|
168
|
+
const isExist = await FileSafe.exist(pathGeneratedDynamicMapped);
|
|
169
|
+
if (!isExist) {
|
|
170
|
+
const [, errorWriteInitialDynamicMapped] = await FileSafe.write(
|
|
171
|
+
pathGeneratedDynamicMapped,
|
|
172
|
+
'',
|
|
173
|
+
{
|
|
174
|
+
encoding: 'utf-8',
|
|
175
|
+
},
|
|
176
|
+
);
|
|
177
|
+
if (errorWriteInitialDynamicMapped) {
|
|
178
|
+
Console.error(
|
|
179
|
+
{
|
|
180
|
+
BrowserDirMapper: `❌ Error to write '${pathGeneratedDynamicMapped}'`,
|
|
181
|
+
errorWriteInitialDynamicMapped,
|
|
182
|
+
},
|
|
183
|
+
{ now: true },
|
|
184
|
+
);
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
const [dynamicDirWatcher, errorCreatingDynamicsWatcher] = await NewDynamicsExport({
|
|
189
|
+
rootPath: watchPath,
|
|
190
|
+
debounce,
|
|
191
|
+
chokidarOptions,
|
|
192
|
+
eachFilter,
|
|
193
|
+
});
|
|
194
|
+
if (errorCreatingDynamicsWatcher) {
|
|
195
|
+
Console.error({ errorCreatingDynamicsWatcher });
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
this.dynamicDirWatcher = dynamicDirWatcher;
|
|
199
|
+
dynamicDirWatcher.watcher._addIgnoredPath(pathGeneratedDynamicMapped);
|
|
200
|
+
this.dirMapper = new JSDirMapper(
|
|
201
|
+
{
|
|
202
|
+
mapTo: mapToPath,
|
|
203
|
+
watch: watchPath,
|
|
204
|
+
filter: async ({ source, eventName, target }) => {
|
|
205
|
+
switch (eventName) {
|
|
206
|
+
case 'add':
|
|
207
|
+
if (target.endsWith('.html')) {
|
|
208
|
+
this.#setOfHtmlPaths.add(target);
|
|
209
|
+
} else {
|
|
210
|
+
this.#mapOfAssets.set(target, await LastEditedUnix(source));
|
|
211
|
+
}
|
|
212
|
+
break;
|
|
213
|
+
case 'error':
|
|
214
|
+
case 'unlink':
|
|
215
|
+
if (target.endsWith('.html')) {
|
|
216
|
+
this.#setOfHtmlPaths.delete(target);
|
|
217
|
+
} else {
|
|
218
|
+
this.#mapOfAssets.delete(target);
|
|
219
|
+
}
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
return { shouldProcessDefault: true };
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
esbuild: {
|
|
227
|
+
/** */
|
|
228
|
+
buildOptions: {
|
|
229
|
+
...buildOptions,
|
|
230
|
+
platform: 'browser',
|
|
231
|
+
plugins: [
|
|
232
|
+
/** */
|
|
233
|
+
pluginVivthBundle,
|
|
234
|
+
...(buildOptions.plugins ?? []),
|
|
235
|
+
],
|
|
236
|
+
},
|
|
237
|
+
watchOption,
|
|
238
|
+
},
|
|
239
|
+
asTsToMjsHandler,
|
|
240
|
+
},
|
|
241
|
+
);
|
|
242
|
+
};
|
|
243
|
+
/**
|
|
244
|
+
* @description
|
|
245
|
+
* - `FSDirArchWatcher` instance;
|
|
246
|
+
* @type {FSDirArchWatcher<any>|undefined}
|
|
247
|
+
*/
|
|
248
|
+
dynamicDirWatcher;
|
|
249
|
+
/**
|
|
250
|
+
* @description
|
|
251
|
+
* - `JSDirMapper` instance;
|
|
252
|
+
* @type {JSDirMapper<any>|undefined}
|
|
253
|
+
*/
|
|
254
|
+
dirMapper;
|
|
255
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { WC_TagName_type } from './common/WC_TagName_type.mts';
|
|
2
|
+
|
|
3
|
+
// If T is valid, return T, otherwise return the literal string 'INVALID_TAG_NAME'
|
|
4
|
+
/**
|
|
5
|
+
* @preserve
|
|
6
|
+
* @template {string} T
|
|
7
|
+
* @[blank]typedef {import('./EnsureValidTag.mts').EnsureValidTag<T>} EnsureValidTag
|
|
8
|
+
*/
|
|
9
|
+
export type EnsureValidTag<T extends string> =
|
|
10
|
+
WC_TagName_type<T> extends T ? T : 'INVALID_TAG_NAME';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
import { NewDynamicsExport } from '../function/NewDynamicsExport.mjs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @description
|
|
7
|
+
* - `vite.rollup/down` plugin abstraction for [NewDynamicsExport](#newdynamicsexport);
|
|
8
|
+
* @param {Parameters<typeof NewDynamicsExport>} args
|
|
9
|
+
* @returns {import('vite').PluginOption}
|
|
10
|
+
*/
|
|
11
|
+
export function ViteAddDynamics(...args) {
|
|
12
|
+
/**
|
|
13
|
+
* @type {boolean|undefined}
|
|
14
|
+
*/
|
|
15
|
+
let started;
|
|
16
|
+
return {
|
|
17
|
+
name: 'vivth/web:AddDynamics',
|
|
18
|
+
apply: 'serve', // <-- only applies in dev server
|
|
19
|
+
async configureServer(devServer) {
|
|
20
|
+
if (started) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
started = true;
|
|
24
|
+
args[0].useFetchForAssets = false;
|
|
25
|
+
const [dynamicExports, errorCreatingDynamicExport] = await NewDynamicsExport(...args);
|
|
26
|
+
if (errorCreatingDynamicExport) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
devServer.httpServer?.on('close', () => {
|
|
30
|
+
dynamicExports.vivthCleanup();
|
|
31
|
+
});
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
/** */
|
|
5
|
+
resolve,
|
|
6
|
+
relative,
|
|
7
|
+
extname,
|
|
8
|
+
// sep,
|
|
9
|
+
} from 'node:path';
|
|
10
|
+
import { readdirSync, statSync } from 'node:fs';
|
|
11
|
+
import { Paths } from '../class/Paths.mjs';
|
|
12
|
+
import { TryAsync } from '../function/TryAsync.mjs';
|
|
13
|
+
import { Console } from '../class/Console.mjs';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @param {string} currentDir
|
|
17
|
+
* @param {string} absoluteDist
|
|
18
|
+
* @param {string} absoluteDir
|
|
19
|
+
* @param {Record<string, any>} inputs
|
|
20
|
+
* @returns {void}
|
|
21
|
+
*/
|
|
22
|
+
function scanDir(currentDir, absoluteDist, absoluteDir, inputs) {
|
|
23
|
+
// Fast paths to ignore heavy directories right away at the top level
|
|
24
|
+
const dirName = currentDir.split('/').pop() ?? '.';
|
|
25
|
+
if (dirName === 'node_modules' || dirName.startsWith('.')) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const files = readdirSync(currentDir);
|
|
30
|
+
|
|
31
|
+
for (const file of files) {
|
|
32
|
+
const fullPath = Paths.normalize(resolve(currentDir, file));
|
|
33
|
+
const isDirectory = statSync(fullPath).isDirectory();
|
|
34
|
+
|
|
35
|
+
// Safely check if the directory is actually the build destination folder
|
|
36
|
+
if (fullPath === absoluteDist || fullPath.startsWith(absoluteDist + '/')) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (isDirectory) {
|
|
41
|
+
scanDir(fullPath, absoluteDist, absoluteDir, inputs);
|
|
42
|
+
} else if (extname(file) === '.html') {
|
|
43
|
+
const relativePath = Paths.normalize(relative(absoluteDir, fullPath));
|
|
44
|
+
|
|
45
|
+
// Vite requires forward slashes for internal module IDs/names
|
|
46
|
+
const urlKey = relativePath.replace(/[\\]/g, '/').replace(/\.html$/, '');
|
|
47
|
+
|
|
48
|
+
inputs[urlKey] = fullPath;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @description
|
|
55
|
+
* - Automatically discovers HTML files in a directory and maps them to input keys;
|
|
56
|
+
* - [Paths](#paths) needs to be instantiated;
|
|
57
|
+
* @param {string} dirPath - The absolute or relative path to the directory to scan.
|
|
58
|
+
* @param {string} distPath - The distribution folder name to exclude.
|
|
59
|
+
* @returns {import('vite').PluginOption}
|
|
60
|
+
*/
|
|
61
|
+
export function ViteGetAllHTMLFile(dirPath, distPath) {
|
|
62
|
+
return {
|
|
63
|
+
name: 'vivth/web:ViteGetAllHTMLFile',
|
|
64
|
+
async config({ build }) {
|
|
65
|
+
const buildPromise = TryAsync(async () => {
|
|
66
|
+
const absoluteDir = Paths.diskAbsolute(dirPath);
|
|
67
|
+
const absoluteDist = Paths.diskAbsolute(distPath);
|
|
68
|
+
const inputs = {};
|
|
69
|
+
try {
|
|
70
|
+
scanDir(absoluteDir, absoluteDist, absoluteDir, inputs);
|
|
71
|
+
} catch (error) {
|
|
72
|
+
throw { autoHtmlInputs: `Error scanning directory '${dirPath}'`, error };
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
build = build || {};
|
|
76
|
+
const optionsKey = build.rolldownOptions ? 'rolldownOptions' : 'rollupOptions';
|
|
77
|
+
build[optionsKey] = build[optionsKey] || {};
|
|
78
|
+
const input = build[optionsKey].input ?? {};
|
|
79
|
+
build[optionsKey].input = {
|
|
80
|
+
// @ts-expect-error
|
|
81
|
+
...input,
|
|
82
|
+
...inputs,
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
console.log('📦 Dynamic HTML Inputs Generated:', inputs);
|
|
86
|
+
});
|
|
87
|
+
const dynamicsHandler = TryAsync(async () => {});
|
|
88
|
+
const [[, errorBuild], [, errorDynamic]] = await Promise.all([buildPromise, dynamicsHandler]);
|
|
89
|
+
if (errorBuild) {
|
|
90
|
+
Console.error({ errorBuild });
|
|
91
|
+
}
|
|
92
|
+
if (errorDynamic) {
|
|
93
|
+
Console.error({ errorDynamic });
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
}
|