vivth 1.4.10 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6060 -2037
- package/README.src.md +22 -14
- package/bun.lock +154 -194
- package/dev/auto/.src.ignore +25 -0
- package/dev/auto-doc.mjs +137 -0
- package/generated/types/generated/vivth/exports/all.d.mts +145 -0
- package/generated/types/generated/vivth/exports/neutral.d.mts +105 -0
- package/generated/types/generated/vivth/exports/node.d.mts +40 -0
- package/generated/types/src/bundler/CompileAS.d.mts +30 -0
- package/generated/types/src/bundler/CompileJS.d.mts +109 -0
- package/{types → generated/types}/src/bundler/CreateESPlugin.d.mts +1 -1
- package/{types → generated/types}/src/bundler/EsBundler.d.mts +9 -7
- package/generated/types/src/bundler/FSAnalyzer.d.mts +58 -0
- package/generated/types/src/bundler/FSasar.bundled.d.mts +28 -0
- package/generated/types/src/bundler/FSasar.d.mts +51 -0
- package/generated/types/src/bundler/FileSelfMapper.d.mts +137 -0
- package/generated/types/src/bundler/JSDirMapper.d.mts +128 -0
- package/generated/types/src/bundler/RunWatchThenCompileJSOnSafeExit.d.mts +63 -0
- package/generated/types/src/bundler/adds/BrowserExternals.d.mts +21 -0
- package/generated/types/src/bundler/adds/CreateTransform.d.mts +26 -0
- package/generated/types/src/bundler/adds/LastEditedUnix.d.mts +5 -0
- package/generated/types/src/bundler/adds/NodeModuleList.d.mts +15 -0
- package/generated/types/src/bundler/adds/PathFSBundles.bundled.d.mts +25 -0
- package/generated/types/src/bundler/adds/PathFSBundles.d.mts +48 -0
- package/generated/types/src/bundler/adds/PathFSDir.bundled.d.mts +30 -0
- package/generated/types/src/bundler/adds/PathFSDir.d.mts +48 -0
- package/generated/types/src/bundler/adds/PathFSFile.bundled.d.mts +25 -0
- package/generated/types/src/bundler/adds/PathFSFile.d.mts +40 -0
- package/{types → generated/types}/src/bundler/adds/ToBundledJSPlugin.d.mts +6 -6
- package/generated/types/src/bundler/adds/autoExternalize.d.mts +2 -0
- package/generated/types/src/bundler/adds/emptyBufferValue.d.mts +1 -0
- package/generated/types/src/bundler/adds/isModuleTheBundledVersion.d.mts +1 -0
- package/generated/types/src/bundler/adds/onEndEsBuildErrorLogger.d.mts +1 -0
- package/generated/types/src/bundler/adds/resolveJSDependencyPath.d.mts +1 -0
- package/generated/types/src/class/AwaitSignal.d.mts +48 -0
- package/generated/types/src/class/Console.d.mts +82 -0
- package/generated/types/src/class/DataLog.d.mts +25 -0
- package/generated/types/src/class/Derived.d.mts +74 -0
- package/generated/types/src/class/Effect.d.mts +213 -0
- package/{types → generated/types}/src/class/EnvSignal.d.mts +6 -2
- package/generated/types/src/class/EsWatcher.d.mts +36 -0
- package/{types → generated/types}/src/class/EventSignal.d.mts +39 -39
- package/generated/types/src/class/FSDirArchWatcher.d.mts +110 -0
- package/{types → generated/types}/src/class/FileSafe.d.mts +32 -16
- package/generated/types/src/class/ForEach.d.mts +57 -0
- package/generated/types/src/class/ForSignal.d.mts +63 -0
- package/generated/types/src/class/GetterSetter.d.mts +38 -0
- package/generated/types/src/class/JSONFileHandler.d.mts +50 -0
- package/{types → generated/types}/src/class/ListSignal.d.mts +49 -15
- package/{types → generated/types}/src/class/LitExp.d.mts +18 -18
- package/generated/types/src/class/ObjectSignal.d.mts +267 -0
- package/generated/types/src/class/Paths.d.mts +95 -0
- package/generated/types/src/class/Prettivy.d.mts +26 -0
- package/{types → generated/types}/src/class/QChannel.d.mts +24 -16
- package/generated/types/src/class/SafeExit.d.mts +69 -0
- package/{types → generated/types}/src/class/Setup.d.mts +29 -16
- package/{types → generated/types}/src/class/Signal.d.mts +29 -15
- package/generated/types/src/class/SignalCollection.d.mts +96 -0
- package/{types → generated/types}/src/class/WalkThrough.d.mts +4 -19
- package/generated/types/src/class/WorkerMainThread.bundled.d.mts +83 -0
- package/{types → generated/types}/src/class/WorkerMainThread.d.mts +33 -39
- package/{types → generated/types}/src/class/WorkerThread.d.mts +11 -5
- package/{types → generated/types}/src/common/Base64URL.d.mts +2 -1
- package/generated/types/src/common/Base64URLFromFile.d.mts +20 -0
- package/generated/types/src/common/BundledV.bundled.d.mts +3 -0
- package/generated/types/src/common/BundledV.d.mts +36 -0
- package/{types → generated/types}/src/common/CreateStringID.d.mts +5 -4
- package/generated/types/src/common/EnvMode.d.mts +79 -0
- package/generated/types/src/common/FactoryKey.d.mts +9 -0
- package/generated/types/src/common/Preferrence.d.mts +25 -0
- package/{types → generated/types}/src/common/Trace.d.mts +1 -1
- package/{types → generated/types}/src/common/TracePath.d.mts +1 -1
- package/generated/types/src/common/VivthUnBundledCodeBlock.d.mts +6 -0
- package/generated/types/src/doc/JSautoDOC.d.mts +172 -0
- package/generated/types/src/doc/cleanPreserveTypedef.d.mts +1 -0
- package/{types/src/doc/parsedFile.d.mts → generated/types/src/doc/parsedFileForDOC.d.mts} +56 -27
- package/generated/types/src/function/ClearRequireCache.d.mts +1 -0
- package/{types → generated/types}/src/function/CreateImmutable.d.mts +5 -4
- package/{types → generated/types}/src/function/EventCheck.d.mts +3 -1
- package/{types → generated/types}/src/function/EventObject.d.mts +2 -6
- package/generated/types/src/function/ForInAsync.d.mts +36 -0
- package/generated/types/src/function/ForInSync.d.mts +36 -0
- package/generated/types/src/function/ForOfAsync.d.mts +25 -0
- package/generated/types/src/function/ForOfSync.d.mts +36 -0
- package/generated/types/src/function/GetBufferFromRelativePath.d.mts +15 -0
- package/generated/types/src/function/GetFilesFromDir.d.mts +14 -0
- package/generated/types/src/function/GetMaxFilenameLength.d.mts +9 -0
- package/generated/types/src/function/GetModuleEsbuildPlatform.d.mts +13 -0
- package/{types → generated/types}/src/function/GetNamedImportAlias.d.mts +1 -1
- package/generated/types/src/function/GetRuntime.d.mts +2 -0
- package/generated/types/src/function/InstantiateAssemblyScript.d.mts +15 -0
- package/{types → generated/types}/src/function/IsAsync.d.mts +1 -1
- package/generated/types/src/function/IsInstanceOf.d.mts +25 -0
- package/generated/types/src/function/IsSameFile.d.mts +16 -0
- package/generated/types/src/function/IsStringLooksLikeAPath.d.mts +16 -0
- package/generated/types/src/function/IsTypeOf.d.mts +25 -0
- package/{types → generated/types}/src/function/LazyFactory.d.mts +9 -10
- package/generated/types/src/function/MonkeyPatch.d.mts +33 -0
- package/generated/types/src/function/NewAnimationTimeline.d.mts +24 -0
- package/generated/types/src/function/NewChainable.d.mts +35 -0
- package/generated/types/src/function/NewDynamicsExport.d.mts +49 -0
- package/generated/types/src/function/NewObjectWrapper.d.mts +10 -0
- package/generated/types/src/function/ObjectRegistrar.d.mts +17 -0
- package/generated/types/src/function/ParseSQLFile.d.mts +25 -0
- package/generated/types/src/function/PipeAsync.d.mts +19 -0
- package/generated/types/src/function/PipeSync.d.mts +17 -0
- package/generated/types/src/function/SafeImport.d.mts +21 -0
- package/generated/types/src/function/TemplateLiteral.d.mts +23 -0
- package/{types → generated/types}/src/function/Timeout.d.mts +1 -1
- package/{types → generated/types}/src/function/Tries.d.mts +4 -4
- package/{types → generated/types}/src/function/TryAsync.d.mts +2 -2
- package/{types → generated/types}/src/function/TryNew.d.mts +1 -1
- package/generated/types/src/function/TsToMjs.d.mts +27 -0
- package/generated/types/src/function/UniqueFSTempName.d.mts +9 -0
- package/generated/types/src/function/errorToMessage.d.mts +5 -0
- package/generated/types/src/neinth/VivthyNeinth.d.mts +202 -0
- package/generated/types/src/typehints/ArrayToKeys.d.mts +23 -0
- package/generated/types/src/typehints/AssemblyScriptExportsType.d.mts +4 -0
- package/generated/types/src/typehints/AssemblyScriptLoaderInstantiate.d.mts +4 -0
- package/generated/types/src/typehints/AutoDocASOptions.d.mts +15 -0
- package/generated/types/src/typehints/ChainableType.d.mts +3 -0
- package/generated/types/src/typehints/ComponentDecorator_Constructor.d.mts +3 -0
- package/generated/types/src/typehints/ConsoleAdditionalSettingType.d.mts +3 -0
- package/generated/types/src/typehints/Decorator.d.mts +11 -0
- package/generated/types/src/typehints/DecoratorMonkeyPatch.d.mts +15 -0
- package/{types/src/types → generated/types/src/typehints}/DevTestCB.d.mts +2 -2
- package/generated/types/src/typehints/EnvModeType.d.mts +4 -0
- package/generated/types/src/typehints/ListArg.d.mts +4 -0
- package/generated/types/src/typehints/MonkeyPatchedType.d.mts +1 -0
- package/generated/types/src/typehints/ParametersFollowingN.d.mts +13 -0
- package/generated/types/src/typehints/PrefixedKeysOf.d.mts +1 -0
- package/generated/types/src/typehints/Runtime.d.mts +4 -0
- package/generated/types/src/typehints/SafeImportReturnType.d.mts +1 -0
- package/generated/types/src/typehints/StylePropRefType.d.mts +2 -0
- package/generated/types/src/typehints/TemplateLiteralValueHandler.d.mts +10 -0
- package/generated/types/src/typehints/VLifecycleCallbacks.d.mts +6 -0
- package/generated/types/src/typehints/VivthCleanup.d.mts +12 -0
- package/generated/types/src/web/BrowserDirMapper.d.mts +70 -0
- package/generated/types/src/web/EnsureValidTag.d.mts +7 -0
- package/generated/types/src/web/ViteAddDynamics.d.mts +28 -0
- package/generated/types/src/web/ViteGetAllHTMLFile.d.mts +9 -0
- package/generated/types/src/web/WC_extendsA.d.mts +135 -0
- package/generated/types/src/web/WC_extendsB.d.mts +135 -0
- package/generated/types/src/web/bindings/WC_StyleProp_bind.d.mts +42 -0
- package/generated/types/src/web/bindings/WC_createElement_bind.d.mts +51 -0
- package/generated/types/src/web/bindings/WC_createNamedSlot.d.mts +26 -0
- package/generated/types/src/web/bindings/WC_litRender_bind.d.mts +20 -0
- package/generated/types/src/web/bindings/WC_litStyleMap.d.mts +7 -0
- package/generated/types/src/web/common/CSS.d.mts +23 -0
- package/generated/types/src/web/common/E.d.mts +41 -0
- package/generated/types/src/web/common/NewStyleSheetAsync.d.mts +15 -0
- package/generated/types/src/web/common/NewStyleSheetSync.d.mts +15 -0
- package/generated/types/src/web/common/WC_TagName_type.d.mts +15 -0
- package/generated/types/src/web/signals/IsInViewPortSignal.d.mts +52 -0
- package/generated/types/src/web/signals/ObserverSignal.d.mts +32 -0
- package/generated/types/src/web/signals/WC_litRef.d.mts +26 -0
- package/generated/types/src/web/signals/WC_loopedSiblingsRef.d.mts +44 -0
- package/generated/vivth/exports/all.mjs +233 -0
- package/generated/vivth/exports/neutral.mjs +193 -0
- package/generated/vivth/exports/node.mjs +46 -0
- package/package.json +50 -14
- package/src/bundler/CompileAS.mjs +36 -0
- package/src/bundler/CompileJS.mjs +98 -171
- package/src/bundler/CreateESPlugin.mjs +1 -1
- package/src/bundler/EsBundler.mjs +38 -13
- package/src/bundler/FSAnalyzer.mjs +253 -0
- package/src/bundler/FSasar.bundled.mjs +128 -0
- package/src/bundler/FSasar.mjs +96 -0
- package/src/bundler/FileSelfMapper.mjs +491 -0
- package/src/bundler/JSDirMapper.mjs +528 -0
- package/src/bundler/RunWatchThenCompileJSOnSafeExit.mjs +129 -0
- package/src/bundler/adds/BrowserExternals.mjs +37 -0
- package/src/bundler/adds/CreateTransform.mjs +36 -0
- package/src/bundler/adds/LastEditedUnix.mjs +12 -0
- package/src/bundler/adds/NodeModuleList.mjs +33 -0
- package/src/bundler/adds/PathFSBundles.bundled.mjs +41 -0
- package/src/bundler/adds/PathFSBundles.mjs +91 -0
- package/src/bundler/adds/PathFSDir.bundled.mjs +53 -0
- package/src/bundler/adds/PathFSDir.mjs +100 -0
- package/src/bundler/adds/PathFSFile.bundled.mjs +40 -0
- package/src/bundler/adds/PathFSFile.mjs +85 -0
- package/src/bundler/adds/ToBundledJSPlugin.mjs +116 -55
- package/src/bundler/adds/autoExternalize.mjs +81 -0
- package/src/bundler/adds/emptyBufferValue.mjs +5 -0
- package/src/bundler/adds/isModuleTheBundledVersion.mjs +10 -0
- package/src/bundler/adds/onEndEsBuildErrorLogger.mjs +34 -0
- package/src/bundler/adds/resolveJSDependencyPath.mjs +17 -0
- package/src/class/AwaitSignal.mjs +119 -0
- package/src/class/Console.mjs +36 -14
- package/src/class/DataLog.mjs +29 -0
- package/src/class/Derived.mjs +67 -55
- package/src/class/Effect.mjs +270 -84
- package/src/class/EnvSignal.mjs +11 -8
- package/src/class/EsWatcher.mjs +60 -0
- package/src/class/EventSignal.mjs +46 -58
- package/src/class/FSDirArchWatcher.mjs +246 -0
- package/src/class/FileSafe.mjs +72 -24
- package/src/class/ForEach.mjs +78 -0
- package/src/class/ForSignal.mjs +115 -0
- package/src/class/GetterSetter.mjs +40 -0
- package/src/class/JSONFileHandler.mjs +90 -0
- package/src/class/ListSignal.mjs +68 -26
- package/src/class/LitExp.mjs +59 -36
- package/src/class/ObjectSignal.mjs +225 -0
- package/src/class/Paths.mjs +56 -20
- package/src/class/Prettivy.mjs +51 -0
- package/src/class/QChannel.mjs +48 -26
- package/src/class/SafeExit.mjs +156 -99
- package/src/class/Setup.mjs +28 -16
- package/src/class/Signal.mjs +50 -27
- package/src/class/SignalCollection.mjs +130 -0
- package/src/class/WalkThrough.mjs +6 -23
- package/src/class/{WorkerMainThreadBundled.mjs → WorkerMainThread.bundled.mjs} +56 -77
- package/src/class/WorkerMainThread.mjs +98 -94
- package/src/class/WorkerThread.mjs +24 -17
- package/src/common/Base64URL.mjs +6 -3
- package/src/common/Base64URLFromFile.mjs +17 -4
- package/src/common/BundledV.bundled.mjs +7 -0
- package/src/common/BundledV.mjs +45 -0
- package/src/common/CreateStringID.mjs +8 -7
- package/src/common/EnvMode.mjs +172 -0
- package/src/common/FactoryKey.mjs +11 -0
- package/src/common/Preferrence.mjs +27 -0
- package/src/common/Trace.mjs +1 -1
- package/src/common/TracePath.mjs +53 -3
- package/src/common/VivthUnBundledCodeBlock.mjs +8 -0
- package/src/doc/JSautoDOC.mjs +673 -284
- package/src/doc/cleanPreserveTypedef.mjs +27 -0
- package/src/doc/correctBeforeParse.mjs +57 -48
- package/src/doc/{parsedFile.mjs → parsedFileForDOC.mjs} +133 -120
- package/src/function/ClearRequireCache.mjs +33 -0
- package/src/function/CreateImmutable.mjs +40 -37
- package/src/function/EventCheck.mjs +5 -2
- package/src/function/EventObject.mjs +2 -6
- package/src/function/ForInAsync.mjs +76 -0
- package/src/function/ForInSync.mjs +87 -0
- package/src/function/ForOfAsync.mjs +61 -0
- package/src/function/ForOfSync.mjs +70 -0
- package/src/function/GetBufferFromRelativePath.mjs +25 -0
- package/src/function/GetFilesFromDir.mjs +49 -0
- package/src/function/GetMaxFilenameLength.mjs +32 -0
- package/src/function/GetModuleEsbuildPlatform.mjs +118 -0
- package/src/function/GetNamedImportAlias.mjs +2 -2
- package/src/function/GetRuntime.mjs +10 -14
- package/src/function/InstantiateAssemblyScript.mjs +22 -0
- package/src/function/IsAsync.mjs +1 -1
- package/src/function/IsInstanceOf.mjs +29 -0
- package/src/function/IsSameFile.mjs +41 -0
- package/src/function/IsStringLooksLikeAPath.mjs +20 -0
- package/src/function/IsTypeOf.mjs +27 -0
- package/src/function/IsTypeOf.mts +31 -0
- package/src/function/LazyFactory.mjs +25 -23
- package/src/function/MonkeyPatch.mjs +38 -0
- package/src/function/NewAnimationTimeline.mjs +55 -0
- package/src/function/NewChainable.mjs +69 -0
- package/src/function/NewDynamicsExport.mjs +312 -0
- package/src/function/NewObjectWrapper.mjs +14 -0
- package/src/function/ObjectRegistrar.mjs +23 -0
- package/src/function/ParseSQLFile.mjs +129 -0
- package/src/function/PipeAsync.mjs +30 -0
- package/src/function/PipeSync.mjs +28 -0
- package/src/function/SafeImport.mjs +77 -0
- package/src/function/TemplateLiteral.mjs +42 -23
- package/src/function/Timeout.mjs +4 -4
- package/src/function/Tries.mjs +22 -16
- package/src/function/TryAsync.mjs +3 -2
- package/src/function/TryNew.mjs +1 -1
- package/src/function/TsToMjs.mjs +184 -21
- package/src/function/UniqueFSTempName.mjs +33 -0
- package/src/function/errorToMessage.mjs +21 -0
- package/src/function/resolveErrorArray.mjs +15 -1
- package/src/neinth/VivthyNeinth.mjs +487 -0
- package/src/typehints/ArrayToKeys.mjs +17 -0
- package/src/typehints/ArrayToKeys.mts +31 -0
- package/src/typehints/AssemblyScriptExportsType.mjs +7 -0
- package/src/typehints/AssemblyScriptLoaderInstantiate.mjs +7 -0
- package/src/typehints/AutoDocASOptions.mjs +14 -0
- package/src/typehints/ChainableType.mjs +11 -0
- package/src/typehints/ComponentDecorator_Constructor.mjs +10 -0
- package/src/typehints/ConsoleAdditionalSettingType.mjs +6 -0
- package/src/typehints/Decorator.mjs +9 -0
- package/src/typehints/Decorator.mts +31 -0
- package/src/typehints/DecoratorMonkeyPatch.mjs +10 -0
- package/src/typehints/DecoratorMonkeyPatch.mts +43 -0
- package/src/{types → typehints}/DevTestCB.mjs +2 -2
- package/src/typehints/EnvModeType.mjs +6 -0
- package/src/{types → typehints}/ListArg.mjs +1 -1
- package/src/{types → typehints}/LitExpResultType.mjs +1 -1
- package/src/typehints/MonkeyPatchedType.mjs +13 -0
- package/src/typehints/ParametersFollowingN.mjs +8 -0
- package/src/typehints/ParametersFollowingN.mts +17 -0
- package/src/typehints/PrefixedKeysOf.mjs +9 -0
- package/src/typehints/Runtime.mjs +6 -0
- package/src/typehints/SafeImportReturnType.mjs +6 -0
- package/src/typehints/StylePropRefType.mjs +12 -0
- package/src/typehints/TemplateLiteralValueHandler.mjs +14 -0
- package/src/typehints/VLifecycleCallbacks.mjs +10 -0
- package/src/typehints/VivthCleanup.mjs +14 -0
- package/src/web/BrowserDirMapper.mjs +255 -0
- package/src/web/EnsureValidTag.mjs +5 -0
- package/src/web/EnsureValidTag.mts +10 -0
- package/src/web/ViteAddDynamics.mjs +34 -0
- package/src/web/ViteGetAllHTMLFile.mjs +97 -0
- package/src/web/WC_extendsA.mjs +330 -0
- package/src/web/WC_extendsB.mjs +332 -0
- package/src/web/bindings/WC_StyleProp_bind.mjs +70 -0
- package/src/web/bindings/WC_createElement_bind.mjs +95 -0
- package/src/web/bindings/WC_createNamedSlot.mjs +29 -0
- package/src/web/bindings/WC_litRender_bind.mjs +26 -0
- package/src/web/bindings/WC_litStyleMap.mjs +14 -0
- package/src/web/common/CSS.mjs +35 -0
- package/src/web/common/E.mjs +126 -0
- package/src/web/common/NewStyleSheetAsync.mjs +21 -0
- package/src/web/common/NewStyleSheetSync.mjs +21 -0
- package/src/web/common/WC_TagName_type.mjs +10 -0
- package/src/web/common/WC_TagName_type.mts +36 -0
- package/src/web/signals/IsInViewPortSignal.mjs +140 -0
- package/src/web/signals/ObserverSignal.mjs +93 -0
- package/src/web/signals/WC_litRef.mjs +61 -0
- package/src/web/signals/WC_loopedSiblingsRef.mjs +100 -0
- package/tsconfig.json +44 -41
- package/index.mjs +0 -91
- package/src/bundler/FSInline.mjs +0 -67
- package/src/bundler/FSInlineAnalyzer.mjs +0 -228
- package/src/bundler/FSInlineBundled.mjs +0 -38
- package/src/bundler/adds/externals.mjs +0 -8
- package/src/class/ListDerived.mjs +0 -42
- package/src/common/Dev.mjs +0 -142
- package/src/common/DevBundled.mjs +0 -5
- package/src/common/lazie.mjs +0 -3
- package/src/types/IsListSignal.mjs +0 -6
- package/src/types/Runtime.mjs +0 -6
- package/src/types/VivthDevCodeBlockStringType.mjs +0 -6
- package/types/index.d.mts +0 -58
- package/types/src/bundler/CompileJS.d.mts +0 -119
- package/types/src/bundler/FSInline.d.mts +0 -50
- package/types/src/bundler/FSInlineAnalyzer.d.mts +0 -37
- package/types/src/bundler/FSInlineBundled.d.mts +0 -22
- package/types/src/bundler/adds/externals.d.mts +0 -1
- package/types/src/class/Console.d.mts +0 -71
- package/types/src/class/Derived.d.mts +0 -98
- package/types/src/class/Effect.d.mts +0 -216
- package/types/src/class/ListDerived.d.mts +0 -38
- package/types/src/class/Paths.d.mts +0 -69
- package/types/src/class/SafeExit.d.mts +0 -103
- package/types/src/class/WorkerMainThreadBundled.d.mts +0 -83
- package/types/src/common/Base64URLFromFile.d.mts +0 -16
- package/types/src/common/Dev.d.mts +0 -68
- package/types/src/common/DevBundled.d.mts +0 -3
- package/types/src/common/lazie.d.mts +0 -1
- package/types/src/doc/JSautoDOC.d.mts +0 -83
- package/types/src/function/GetRuntime.d.mts +0 -2
- package/types/src/function/TemplateLiteral.d.mts +0 -22
- package/types/src/function/TsToMjs.d.mts +0 -23
- package/types/src/types/IsListSignal.d.mts +0 -4
- package/types/src/types/ListArg.d.mts +0 -4
- package/types/src/types/Runtime.d.mts +0 -4
- package/types/src/types/VivthDevCodeBlockStringType.d.mts +0 -4
- /package/{types → generated/types}/src/bundler/adds/pluginVivthBundle.d.mts +0 -0
- /package/{types → generated/types}/src/class/WorkerResult.d.mts +0 -0
- /package/{types → generated/types}/src/common/EventNameSpace.d.mts +0 -0
- /package/{types → generated/types}/src/common/eventObjects.d.mts +0 -0
- /package/{types → generated/types}/src/common/keys.d.mts +0 -0
- /package/{types → generated/types}/src/doc/correctBeforeParse.d.mts +0 -0
- /package/{types → generated/types}/src/function/TrySync.d.mts +0 -0
- /package/{types → generated/types}/src/function/resolveErrorArray.d.mts +0 -0
- /package/{types/src/types → generated/types/src/typehints}/AnyButUndefined.d.mts +0 -0
- /package/{types/src/types → generated/types/src/typehints}/ExtnameType.d.mts +0 -0
- /package/{types/src/types → generated/types/src/typehints}/LitExpKeyType.d.mts +0 -0
- /package/{types/src/types → generated/types/src/typehints}/LitExpResultType.d.mts +0 -0
- /package/{types/src/types → generated/types/src/typehints}/MutationType.d.mts +0 -0
- /package/{types/src/types → generated/types/src/typehints}/QCBFIFOReturn.d.mts +0 -0
- /package/{types/src/types → generated/types/src/typehints}/QCBReturn.d.mts +0 -0
- /package/src/{types → typehints}/AnyButUndefined.mjs +0 -0
- /package/src/{types → typehints}/ExtnameType.mjs +0 -0
- /package/src/{types → typehints}/LitExpKeyType.mjs +0 -0
- /package/src/{types → typehints}/MutationType.mjs +0 -0
- /package/src/{types → typehints}/QCBFIFOReturn.mjs +0 -0
- /package/src/{types → typehints}/QCBReturn.mjs +0 -0
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
|
|
3
|
+
import { spawnSync } from 'node:child_process';
|
|
3
4
|
import { readFile } from 'node:fs/promises';
|
|
4
5
|
import { join, extname, basename, dirname } from 'node:path';
|
|
5
6
|
import { platform } from 'node:os';
|
|
6
7
|
|
|
7
|
-
import { exec } from 'pkg';
|
|
8
|
-
|
|
9
8
|
import { EsBundler } from './EsBundler.mjs';
|
|
10
9
|
import { FileSafe } from '../class/FileSafe.mjs';
|
|
11
10
|
import { TryAsync } from '../function/TryAsync.mjs';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
11
|
+
import { commonContentFixesBundled } from './adds/ToBundledJSPlugin.mjs';
|
|
12
|
+
import { Preferrence } from '../common/Preferrence.mjs';
|
|
13
|
+
import { ForInSync } from '../function/ForInSync.mjs';
|
|
14
|
+
import { FSAnalyzer } from './FSAnalyzer.mjs';
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* @typedef {'win32' | 'linux' | 'darwin' | string} PlatformKey
|
|
17
|
-
* @typedef {import('./CreateESPlugin.mjs')["CreateESPlugin"]} CreateESPlugin
|
|
18
|
+
* @typedef {typeof import('./CreateESPlugin.mjs')["CreateESPlugin"]} CreateESPlugin
|
|
18
19
|
*/
|
|
19
20
|
|
|
20
21
|
/**
|
|
@@ -23,24 +24,28 @@ import { removeVivthDevCodeBlock } from './adds/ToBundledJSPlugin.mjs';
|
|
|
23
24
|
let binaryExtension;
|
|
24
25
|
|
|
25
26
|
/**
|
|
26
|
-
* @param {Record<string, string[]|string>}
|
|
27
|
+
* @param {Record<string, string[]|string>} bunCompilerArguments
|
|
27
28
|
* @returns {string[]}
|
|
28
29
|
*/
|
|
29
|
-
const generateFlagsValue = (
|
|
30
|
+
const generateFlagsValue = (bunCompilerArguments = {}) => {
|
|
31
|
+
/**
|
|
32
|
+
* @type {Array<string>}
|
|
33
|
+
*/
|
|
30
34
|
const options = [];
|
|
31
|
-
|
|
32
|
-
const value = compilerOptions[flag];
|
|
35
|
+
ForInSync(bunCompilerArguments, (flag, value) => {
|
|
33
36
|
options.push(`--${flag}`);
|
|
34
|
-
if (Array.isArray(value)
|
|
37
|
+
if (!Array.isArray(value)) {
|
|
38
|
+
value = value.trim();
|
|
35
39
|
if (value) {
|
|
36
40
|
options.push(value);
|
|
37
41
|
}
|
|
38
|
-
|
|
42
|
+
return;
|
|
39
43
|
}
|
|
40
44
|
options.push(value.filter((val) => !!val).join(','));
|
|
41
|
-
}
|
|
45
|
+
});
|
|
42
46
|
return options;
|
|
43
47
|
};
|
|
48
|
+
|
|
44
49
|
/**
|
|
45
50
|
* Maps Node.js platform to binary file extension.
|
|
46
51
|
*
|
|
@@ -53,11 +58,7 @@ const getBinaryExtension = () => {
|
|
|
53
58
|
binaryExtension = '.exe';
|
|
54
59
|
break;
|
|
55
60
|
case 'linux':
|
|
56
|
-
binaryExtension = ''; // Linux binaries typically have no extension
|
|
57
|
-
break;
|
|
58
61
|
case 'darwin':
|
|
59
|
-
binaryExtension = ''; // macOS binaries typically have no extension
|
|
60
|
-
break;
|
|
61
62
|
default:
|
|
62
63
|
binaryExtension = ''; // fallback for unknown platforms
|
|
63
64
|
break;
|
|
@@ -65,25 +66,26 @@ const getBinaryExtension = () => {
|
|
|
65
66
|
}
|
|
66
67
|
return binaryExtension;
|
|
67
68
|
};
|
|
69
|
+
|
|
68
70
|
/**
|
|
69
71
|
* @description
|
|
70
72
|
* - function to compile `.ts`|`.mts`|`.mjs` file, into a single executable;
|
|
71
73
|
* - also generate js representation of the `bundled` version of the target;
|
|
72
|
-
* - uses [
|
|
73
|
-
* >-
|
|
74
|
-
* >- `WorkerThread` will be converted to inline using `
|
|
74
|
+
* - uses [bun](https://bun.com/docs/bundler/executables) compiler under the hood;
|
|
75
|
+
* >- it is used only as packaging/compiler agent, and doesn't necessarily supports their advanced feature, such as, assets bundling(use [`FSasar`](#fsasar) instead);
|
|
76
|
+
* >- `WorkerThread` will be converted to inline using `FSasar` too;
|
|
75
77
|
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
78
|
+
* ---
|
|
79
|
+
* ---
|
|
80
|
+
* ---
|
|
79
81
|
*
|
|
80
82
|
* - This function does not obfuscate and will not prevent decompilation. Do not embed environment variables or sensitive information inside `options.entryPoint`;
|
|
81
|
-
* - It is designed for quick binarization, allowing execution on machines without `
|
|
82
|
-
* - The resulting binary will contain `
|
|
83
|
+
* - It is designed for quick binarization, allowing execution on machines without `Bun` installed;
|
|
84
|
+
* - The resulting binary will contain `FSasar` and `WorkerMainThread` target paths Buffers, which are loaded into memory at runtime. If your logic depends on the file system, use `node:fs` or `node:fs/promises` APIs and ship external files alongside the `binary` and `.asar` file (not compiled);
|
|
83
85
|
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
86
|
+
* ---
|
|
87
|
+
* ---
|
|
88
|
+
* ---
|
|
87
89
|
*
|
|
88
90
|
* @param {Object} options
|
|
89
91
|
* @param {string} options.entryPoint
|
|
@@ -95,105 +97,74 @@ const getBinaryExtension = () => {
|
|
|
95
97
|
* - to modify entry point before bundling;
|
|
96
98
|
* - `entryPointContent` is the original string of the entry point;
|
|
97
99
|
* - returned value then passed to `ESBundler`;
|
|
98
|
-
* @param {boolean} options.minifyFirst
|
|
100
|
+
* @param {boolean} [options.minifyFirst]
|
|
99
101
|
* - minify the bundle before compilation;
|
|
102
|
+
* @param {Object} [options.asar]
|
|
103
|
+
* @param {Parameters<typeof import('@electron/asar')["createPackageFromFiles"]>[3]} [options.asar.InputMetadata]
|
|
104
|
+
* @param {Parameters<typeof import('@electron/asar')["createPackageFromFiles"]>[4]} [options.asar.options]
|
|
100
105
|
* @param {string} options.outDir
|
|
101
106
|
* - need manual prefix;
|
|
102
|
-
* @param {
|
|
103
|
-
* - default: no comilation, just bundling;
|
|
104
|
-
* - `bun` and `pkg` is checked, if there's bug on `deno`, please report on github for issues;
|
|
105
|
-
* @param {Record<string, string>} [options.compilerArguments]
|
|
107
|
+
* @param {Record<string, string[]|string>} [options.bunCompilerArguments]
|
|
106
108
|
* - `key` are to used as `--keyName`;
|
|
107
|
-
* - value are the
|
|
109
|
+
* - value are the `value` of the `key`;
|
|
110
|
+
* >- `string`: will be inputed as is;
|
|
111
|
+
* >- `string[]`: will be joined with `,`;
|
|
108
112
|
* - no need to add the output/outdir, as it use the `options.outDir`;
|
|
109
113
|
* @param {ReturnType<CreateESPlugin>[]} [options.esBundlerPlugins]
|
|
110
114
|
* - plugins for `EsBundler`;
|
|
111
|
-
* @
|
|
115
|
+
* @param {Parameters<typeof EsBundler>[1]} [options.esbuildOptions]
|
|
116
|
+
* - options for `EsBundler`;
|
|
117
|
+
* @param {string[]} [options.additionalCommandArgument]
|
|
118
|
+
* - argument to be passed process generator;
|
|
119
|
+
* @return {ReturnType<typeof TryAsync<{compileResult: any,
|
|
112
120
|
* commandCalled: string|undefined;
|
|
113
121
|
* compiledBinFile: string|undefined;
|
|
114
|
-
* bundledJSFile:string|undefined
|
|
122
|
+
* bundledJSFile: string|undefined
|
|
115
123
|
* }>>}
|
|
116
124
|
* @example
|
|
117
125
|
* import process from 'node:process';
|
|
118
126
|
* import { join } from 'node:path';
|
|
119
127
|
*
|
|
120
|
-
* import { CompileJS,
|
|
128
|
+
* import { CompileJS, SafeExit } from 'vivth/node';
|
|
129
|
+
* import { Console, Paths } from 'vivth/neutral';
|
|
121
130
|
*
|
|
122
|
-
*
|
|
123
|
-
* new paths({
|
|
131
|
+
* new Paths({
|
|
124
132
|
* root: process.env.INIT_CWD ?? process.cwd(),
|
|
125
133
|
* });
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
134
|
+
*
|
|
135
|
+
* new SafeExit('SIGINT', 'SIGTERM');
|
|
136
|
+
*
|
|
137
|
+
* const pathRoot = Paths.root;
|
|
138
|
+
*
|
|
139
|
+
* const [,errorbun] = await CompileJS({
|
|
140
|
+
* entryPoint: join(pathRoot, '/dev/myEntryPoint.mjs'),
|
|
141
|
+
* minifyFirst: true,
|
|
142
|
+
* outDir: join(pathRoot, '/dev-bun/'),
|
|
143
|
+
* compiler: 'bun',
|
|
144
|
+
* compilerArguments: {
|
|
145
|
+
* target: 'bun-win-x64',
|
|
137
146
|
* },
|
|
147
|
+
* asar: {},
|
|
148
|
+
* encoding: 'utf-8',
|
|
138
149
|
* });
|
|
139
|
-
* const pathRoot = Paths.root;
|
|
140
|
-
* if (pathRoot) {
|
|
141
|
-
* const [[, error], [, errorbun]] = await Promise.all([
|
|
142
|
-
* CompileJS({
|
|
143
|
-
* entryPoint: join(pathRoot, '/dev/myEntryPoint.mjs'),
|
|
144
|
-
* minifyFirst: true,
|
|
145
|
-
* outDir: join(pathRoot, '/dev-pkg/'),
|
|
146
|
-
* compiler: 'pkg',
|
|
147
|
-
* compilerArguments: {
|
|
148
|
-
* target: 'node18-win-x64',
|
|
149
|
-
* },
|
|
150
|
-
* encoding: 'utf-8',
|
|
151
|
-
* }),
|
|
152
|
-
* await CompileJS({
|
|
153
|
-
* entryPoint: join(pathRoot, '/dev/myEntryPoint.mjs'),
|
|
154
|
-
* minifyFirst: true,
|
|
155
|
-
* outDir: join(pathRoot, '/dev-bun/'),
|
|
156
|
-
* compiler: 'bun',
|
|
157
|
-
* compilerArguments: {
|
|
158
|
-
* target: 'bun-win-x64',
|
|
159
|
-
* },
|
|
160
|
-
* encoding: 'utf-8',
|
|
161
|
-
* }),
|
|
162
|
-
* ]);
|
|
163
|
-
* if (error || errorbun) {
|
|
164
|
-
* Console.error({ error, errorbun });
|
|
165
|
-
* }
|
|
166
|
-
* }
|
|
167
150
|
*
|
|
151
|
+
* if (errorbun) {
|
|
152
|
+
* Console.error({ errorbun });
|
|
153
|
+
* }
|
|
168
154
|
*/
|
|
169
155
|
export async function CompileJS({
|
|
170
156
|
entryPoint,
|
|
171
|
-
minifyFirst,
|
|
172
|
-
encoding =
|
|
157
|
+
minifyFirst = true,
|
|
158
|
+
encoding = Preferrence.encoding,
|
|
173
159
|
outDir,
|
|
160
|
+
asar = {},
|
|
174
161
|
preprocessEntryPoint = undefined,
|
|
175
|
-
|
|
176
|
-
compilerArguments = {},
|
|
162
|
+
bunCompilerArguments = undefined,
|
|
177
163
|
esBundlerPlugins = [],
|
|
164
|
+
esbuildOptions = {},
|
|
165
|
+
additionalCommandArgument = [],
|
|
178
166
|
}) {
|
|
179
167
|
return await TryAsync(async () => {
|
|
180
|
-
/**
|
|
181
|
-
* @type {'cjs'|'esm'}
|
|
182
|
-
*/
|
|
183
|
-
let format;
|
|
184
|
-
switch (compiler) {
|
|
185
|
-
case 'pkg':
|
|
186
|
-
format = 'cjs';
|
|
187
|
-
break;
|
|
188
|
-
case 'bun':
|
|
189
|
-
case 'deno':
|
|
190
|
-
format = 'esm';
|
|
191
|
-
break;
|
|
192
|
-
default:
|
|
193
|
-
minifyFirst = true;
|
|
194
|
-
format = 'esm';
|
|
195
|
-
break;
|
|
196
|
-
}
|
|
197
168
|
const extOfSource = extname(entryPoint);
|
|
198
169
|
switch (extOfSource) {
|
|
199
170
|
case '.mts':
|
|
@@ -201,11 +172,12 @@ export async function CompileJS({
|
|
|
201
172
|
case '.mjs':
|
|
202
173
|
break;
|
|
203
174
|
default:
|
|
204
|
-
throw
|
|
205
|
-
`extention mismatch: "${extOfSource}", should be one of:".mjs"|".mts"|".ts"`
|
|
206
|
-
);
|
|
175
|
+
throw `extention mismatch: "${extOfSource}", should be one of:".mjs"|".mts"|".ts"`;
|
|
207
176
|
}
|
|
208
|
-
let sourceText =
|
|
177
|
+
let sourceText = commonContentFixesBundled(
|
|
178
|
+
entryPoint,
|
|
179
|
+
await readFile(entryPoint, { encoding }),
|
|
180
|
+
);
|
|
209
181
|
if (preprocessEntryPoint) {
|
|
210
182
|
sourceText = preprocessEntryPoint(sourceText);
|
|
211
183
|
}
|
|
@@ -214,89 +186,44 @@ export async function CompileJS({
|
|
|
214
186
|
content: sourceText,
|
|
215
187
|
extension: extOfSource,
|
|
216
188
|
root: dirname(entryPoint),
|
|
217
|
-
withBinHeader:
|
|
189
|
+
withBinHeader: !!bunCompilerArguments,
|
|
218
190
|
},
|
|
219
191
|
{
|
|
220
192
|
minify: minifyFirst,
|
|
221
|
-
format,
|
|
222
193
|
plugins: esBundlerPlugins,
|
|
223
|
-
|
|
194
|
+
...esbuildOptions,
|
|
195
|
+
},
|
|
224
196
|
);
|
|
225
197
|
if (errorPrep) {
|
|
226
198
|
throw errorPrep;
|
|
227
199
|
}
|
|
228
|
-
const
|
|
200
|
+
const outputBaseNameNoExt = join(outDir, basename(entryPoint).replace(extOfSource, ''));
|
|
201
|
+
const bundledJSFile = `${outputBaseNameNoExt}.mjs`;
|
|
202
|
+
const [analyzedBundled, errorAnalyze] = await FSAnalyzer.finalContent(
|
|
203
|
+
entryPoint,
|
|
229
204
|
bundledPrep,
|
|
230
|
-
|
|
205
|
+
asar,
|
|
206
|
+
bundledJSFile,
|
|
231
207
|
);
|
|
232
208
|
if (errorAnalyze) {
|
|
233
209
|
throw errorAnalyze;
|
|
234
210
|
}
|
|
235
|
-
const outputBaseNameNoExt = join(outDir, basename(entryPoint).replace(extOfSource, ''));
|
|
236
|
-
const bundledJSFile = `${outputBaseNameNoExt}${format === 'cjs' ? '.cjs' : '.mjs'}`;
|
|
237
211
|
await FileSafe.write(bundledJSFile, analyzedBundled, { encoding });
|
|
238
212
|
const compiledBinFile = `${outputBaseNameNoExt}${getBinaryExtension()}`;
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
case 'bun': {
|
|
255
|
-
const commandCalled = [
|
|
256
|
-
'build',
|
|
257
|
-
bundledJSFile,
|
|
258
|
-
'--compile',
|
|
259
|
-
...generateFlagsValue(compilerArguments),
|
|
260
|
-
'--outfile',
|
|
261
|
-
compiledBinFile,
|
|
262
|
-
];
|
|
263
|
-
return {
|
|
264
|
-
compileResult: await Bun.spawn(['bun', ...commandCalled]),
|
|
265
|
-
commandCalled: `bun ${commandCalled.join(' ')}`,
|
|
266
|
-
compiledBinFile,
|
|
267
|
-
bundledJSFile,
|
|
268
|
-
};
|
|
269
|
-
}
|
|
270
|
-
case 'deno': {
|
|
271
|
-
const commandCalled = [
|
|
272
|
-
'compile',
|
|
273
|
-
...generateFlagsValue(compilerArguments),
|
|
274
|
-
'--output',
|
|
275
|
-
compiledBinFile,
|
|
276
|
-
bundledJSFile,
|
|
277
|
-
'--verbose',
|
|
278
|
-
];
|
|
279
|
-
// @ts-expect-error
|
|
280
|
-
const command = new Deno.Command('deno', {
|
|
281
|
-
args: commandCalled,
|
|
282
|
-
stdout: 'piped',
|
|
283
|
-
stderr: 'piped',
|
|
284
|
-
});
|
|
285
|
-
return {
|
|
286
|
-
compileResult: await command.output(),
|
|
287
|
-
commandCalled: `deno ${commandCalled.join(' ')}`,
|
|
288
|
-
compiledBinFile,
|
|
289
|
-
bundledJSFile,
|
|
290
|
-
};
|
|
291
|
-
}
|
|
292
|
-
default: {
|
|
293
|
-
return {
|
|
294
|
-
compileResult: undefined,
|
|
295
|
-
commandCalled: undefined,
|
|
296
|
-
compiledBinFile: undefined,
|
|
297
|
-
bundledJSFile,
|
|
298
|
-
};
|
|
299
|
-
}
|
|
300
|
-
}
|
|
213
|
+
const commandCalled = [
|
|
214
|
+
'build',
|
|
215
|
+
bundledJSFile,
|
|
216
|
+
'--compile',
|
|
217
|
+
...generateFlagsValue(bunCompilerArguments ?? {}),
|
|
218
|
+
'--outfile',
|
|
219
|
+
compiledBinFile,
|
|
220
|
+
...additionalCommandArgument,
|
|
221
|
+
];
|
|
222
|
+
return {
|
|
223
|
+
compileResult: spawnSync('bun', commandCalled),
|
|
224
|
+
commandCalled: `bun ${commandCalled.join(' ')}`,
|
|
225
|
+
compiledBinFile,
|
|
226
|
+
bundledJSFile,
|
|
227
|
+
};
|
|
301
228
|
});
|
|
302
229
|
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @param {import('esbuild').Plugin["setup"]} setup
|
|
8
8
|
* @returns {import('esbuild').Plugin}
|
|
9
9
|
* @example
|
|
10
|
-
* import { CreateESPlugin } from 'vivth';
|
|
10
|
+
* import { CreateESPlugin } from 'vivth/neutral';
|
|
11
11
|
*
|
|
12
12
|
* export const pluginAddCopyRight = CreateESPlugin(
|
|
13
13
|
* 'MyCopyrightDeclaration',
|
|
@@ -6,27 +6,29 @@ import { Console } from '../class/Console.mjs';
|
|
|
6
6
|
import { Paths } from '../class/Paths.mjs';
|
|
7
7
|
import { TryAsync } from '../function/TryAsync.mjs';
|
|
8
8
|
import { pluginVivthBundle } from './adds/pluginVivthBundle.mjs';
|
|
9
|
-
import {
|
|
9
|
+
import { BrowserExternals } from './adds/BrowserExternals.mjs';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* @description
|
|
13
|
-
* - opinionated bundler for
|
|
13
|
+
* - opinionated bundler for limited extensions using esbuild;
|
|
14
14
|
* - bundles all imports into a single output string;
|
|
15
15
|
* @param {Object} options
|
|
16
16
|
* @param {string} options.content
|
|
17
17
|
* - the code can also uses composites from the result from multiple readFiles;
|
|
18
18
|
* @param {string} options.root
|
|
19
19
|
* - use dirname of said fileString path;
|
|
20
|
-
* @param {'.mts'|'.ts'|'.mjs'
|
|
20
|
+
* @param {'.mts'|'.ts'|'.mjs'} options.extension
|
|
21
|
+
* - supported extension;
|
|
21
22
|
* @param {boolean} [options.withBinHeader]
|
|
22
23
|
* @param {Omit<Parameters<build>[0],
|
|
23
|
-
* 'entryPoints'|'bundle'|'write'|'sourcemap'>
|
|
24
|
+
* 'entryPoints'|'bundle'|'write'|'sourcemap'|'outdir'|'splitting'|'format'>
|
|
24
25
|
* } [esbuildOptions]
|
|
26
|
+
* - assume `esm`;
|
|
25
27
|
* @returns {ReturnType<typeof TryAsync<string>>}
|
|
26
28
|
* @example
|
|
27
|
-
* import { EsBundler } from 'vivth';
|
|
29
|
+
* import { EsBundler } from 'vivth/node';
|
|
28
30
|
*
|
|
29
|
-
* const bundledString = EsBundler(
|
|
31
|
+
* const [bundledString, errorBundling] = EsBundler(
|
|
30
32
|
* {
|
|
31
33
|
* content: ``,
|
|
32
34
|
* extension: '.mts',
|
|
@@ -38,7 +40,7 @@ import { externals } from './adds/externals.mjs';
|
|
|
38
40
|
*/
|
|
39
41
|
export async function EsBundler(
|
|
40
42
|
{ content, extension, root, withBinHeader = false },
|
|
41
|
-
esbuildOptions = {}
|
|
43
|
+
esbuildOptions = {},
|
|
42
44
|
) {
|
|
43
45
|
return await TryAsync(async () => {
|
|
44
46
|
/**
|
|
@@ -51,7 +53,6 @@ export async function EsBundler(
|
|
|
51
53
|
loader = 'ts';
|
|
52
54
|
break;
|
|
53
55
|
case '.mjs':
|
|
54
|
-
case '.cjs':
|
|
55
56
|
loader = 'js';
|
|
56
57
|
break;
|
|
57
58
|
default:
|
|
@@ -60,21 +61,31 @@ export async function EsBundler(
|
|
|
60
61
|
message: 'Invalid extension passed to EsBundler',
|
|
61
62
|
acceptedextensions: ['.mts', '.ts', '.mjs'],
|
|
62
63
|
};
|
|
63
|
-
Console.error(error);
|
|
64
|
-
throw
|
|
64
|
+
Console.error(error, { now: true });
|
|
65
|
+
throw JSON.stringify(error);
|
|
66
|
+
}
|
|
67
|
+
const mainFields = esbuildOptions.mainFields;
|
|
68
|
+
if (!mainFields?.length) {
|
|
69
|
+
esbuildOptions.mainFields = ['module', 'main'];
|
|
70
|
+
}
|
|
71
|
+
esbuildOptions.external = [...(esbuildOptions?.external ?? [])];
|
|
72
|
+
if (esbuildOptions.platform === 'browser') {
|
|
73
|
+
esbuildOptions.external = Array.from(
|
|
74
|
+
new Set(esbuildOptions.external).union(BrowserExternals),
|
|
75
|
+
);
|
|
65
76
|
}
|
|
66
|
-
esbuildOptions.external = [...(esbuildOptions?.external ?? []), ...externals];
|
|
67
77
|
esbuildOptions.plugins = [...(esbuildOptions?.plugins ?? []), pluginVivthBundle];
|
|
68
78
|
const result = await build({
|
|
69
79
|
target: 'esnext',
|
|
70
80
|
platform: 'node',
|
|
71
|
-
format: 'esm',
|
|
72
81
|
...esbuildOptions,
|
|
73
82
|
stdin: {
|
|
74
83
|
contents: content,
|
|
75
84
|
loader,
|
|
76
85
|
resolveDir: root ?? Paths.root,
|
|
77
86
|
},
|
|
87
|
+
loader: esbuildOptions.loader,
|
|
88
|
+
format: 'esm',
|
|
78
89
|
bundle: true,
|
|
79
90
|
write: false,
|
|
80
91
|
sourcemap: false,
|
|
@@ -84,7 +95,21 @@ export async function EsBundler(
|
|
|
84
95
|
},
|
|
85
96
|
});
|
|
86
97
|
if (result.warnings?.length) {
|
|
87
|
-
|
|
98
|
+
const warningText = result.warnings.map((w) => w.text).join('\n');
|
|
99
|
+
const warningArray = [warningText];
|
|
100
|
+
/**
|
|
101
|
+
* auto cjs mitigation no longer supported
|
|
102
|
+
* ```js
|
|
103
|
+
* const regex = /import\.meta[\s\S]*cjs|cjs[\s\S]*import\.meta/i;
|
|
104
|
+
* if (regex.test(warningText)) {
|
|
105
|
+
* warningArray.push(
|
|
106
|
+
* `⚠️ Note: This is a false positive. 'vivth/node.EsBundler' already mitigates it with __filename.`,
|
|
107
|
+
* `As long as only 'import.meta.url' is accessed, it is most likely fine.`,
|
|
108
|
+
* );
|
|
109
|
+
* }
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
Console.warn(warningArray, { now: true });
|
|
88
113
|
}
|
|
89
114
|
const resString = result.outputFiles?.[0]?.text;
|
|
90
115
|
if (resString === undefined) {
|