11import { createSupportsColor , isUnicodeSupported , stripAnsi , eastAsianWidth , clearTerminal , eraseLines } from "./jsenv_core_node_modules.js" ;
2- import { readFileSync as readFileSync$1 , existsSync , readdir , chmod , stat , lstat , chmodSync , statSync , lstatSync , promises , writeFile as writeFile$1 , readdirSync , openSync , closeSync , unlinkSync , rmdirSync , mkdirSync , writeFileSync as writeFileSync$1 , unlink , rmdir , watch , realpathSync } from "node:fs " ;
3- import { dirname , extname } from "node:path " ;
2+ import { extname } from "node:path " ;
3+ import { readFileSync as readFileSync$1 , existsSync , readdir , chmod , stat , lstat , chmodSync , statSync , lstatSync , promises , readdirSync , openSync , closeSync , unlinkSync , rmdirSync , mkdirSync , writeFileSync as writeFileSync$1 , unlink , rmdir , watch , realpathSync } from "node:fs " ;
44import crypto , { createHash } from "node:crypto" ;
55import { pathToFileURL , fileURLToPath } from "node:url" ;
66import { cpus , totalmem , freemem } from "node:os" ;
@@ -3867,44 +3867,6 @@ const writeDirectory = async (
38673867 }
38683868} ;
38693869
3870- const ensureParentDirectories = async ( destination ) => {
3871- const destinationUrl = assertAndNormalizeFileUrl ( destination ) ;
3872- const destinationPath = urlToFileSystemPath ( destinationUrl ) ;
3873- const destinationParentPath = dirname ( destinationPath ) ;
3874-
3875- await writeDirectory ( destinationParentPath , {
3876- recursive : true ,
3877- allowUseless : true ,
3878- } ) ;
3879- } ;
3880-
3881- const writeFile = async ( destination , content = "" ) => {
3882- const destinationUrl = assertAndNormalizeFileUrl ( destination ) ;
3883- const destinationUrlObject = new URL ( destinationUrl ) ;
3884- try {
3885- await writeFileNaive ( destinationUrlObject , content ) ;
3886- } catch ( error ) {
3887- if ( error . code === "ENOENT" ) {
3888- await ensureParentDirectories ( destinationUrl ) ;
3889- await writeFileNaive ( destinationUrlObject , content ) ;
3890- return ;
3891- }
3892- throw error ;
3893- }
3894- } ;
3895-
3896- const writeFileNaive = ( urlObject , content ) => {
3897- return new Promise ( ( resolve , reject ) => {
3898- writeFile$1 ( urlObject , content , ( error ) => {
3899- if ( error ) {
3900- reject ( error ) ;
3901- } else {
3902- resolve ( ) ;
3903- }
3904- } ) ;
3905- } ) ;
3906- } ;
3907-
39083870const mediaTypeInfos = {
39093871 "application/json" : {
39103872 extensions : [ "json" , "map" ] ,
@@ -5060,18 +5022,12 @@ const registerDirectoryLifecycle = (
50605022 } ;
50615023 const tracker = trackResources ( ) ;
50625024 const infoMap = new Map ( ) ;
5063- // type is given when already known (from the directory listing it comes
5064- // from): there is then no need to stat the entry, which matters when
5065- // indexing a large tree at startup
5066- const readEntryInfo = ( url , { type } = { } ) => {
5025+ const readEntryInfo = ( url ) => {
50675026 try {
50685027 const relativeUrl = urlToRelativeUrl ( url , source ) ;
50695028 const previousInfo = infoMap . get ( relativeUrl ) ;
5070- let stat = null ;
5071- if ( type === undefined ) {
5072- stat = readEntryStatSync ( new URL ( url ) ) ;
5073- type = statsToType ( stat ) ;
5074- }
5029+ const stat = readEntryStatSync ( new URL ( url ) ) ;
5030+ const type = statsToType ( stat ) ;
50755031 const patternValue = previousInfo
50765032 ? previousInfo . patternValue
50775033 : getWatchPatternValue ( { url, type } ) ;
@@ -5228,12 +5184,10 @@ const registerDirectoryLifecycle = (
52285184 const directoryUrl = entryInfo . url . endsWith ( "/" )
52295185 ? entryInfo . url
52305186 : `${ entryInfo . url } /` ;
5231- let direntArray ;
5187+ let entryNameArray ;
52325188 try {
52335189 const directoryUrlObject = new URL ( directoryUrl ) ;
5234- direntArray = readdirSync ( directoryUrlObject , {
5235- withFileTypes : true ,
5236- } ) ;
5190+ entryNameArray = readdirSync ( directoryUrlObject ) ;
52375191 } catch ( e ) {
52385192 if (
52395193 e . code === "ENOENT" ||
@@ -5245,17 +5199,12 @@ const registerDirectoryLifecycle = (
52455199 }
52465200 throw e ;
52475201 }
5248- for ( const dirent of direntArray ) {
5249- const childEntryUrl = new URL ( dirent . name , directoryUrl ) . href ;
5202+ for ( const entryName of entryNameArray ) {
5203+ const childEntryUrl = new URL ( entryName , directoryUrl ) . href ;
52505204 if ( seenSet . has ( childEntryUrl ) ) {
52515205 continue ;
52525206 }
5253- // the stat is read (and its mtime reported) only when the entry is
5254- // notified; a symlink or an exotic entry is stat'ed too, so that it
5255- // is typed as what it points to, as for any later event
5256- const childEntryInfo = readEntryInfo ( childEntryUrl , {
5257- type : notify ? undefined : direntToType ( dirent ) ,
5258- } ) ;
5207+ const childEntryInfo = readEntryInfo ( childEntryUrl ) ;
52595208 if ( childEntryInfo . type !== null && childEntryInfo . patternValue ) {
52605209 applyEntryDiscoveredEffects ( childEntryInfo ) ;
52615210 }
@@ -5297,7 +5246,7 @@ const registerDirectoryLifecycle = (
52975246 relativeUrl : entryInfo . relativeUrl ,
52985247 type : entryInfo . type ,
52995248 patternValue : entryInfo . patternValue ,
5300- mtime : entryInfo . stat ? entryInfo . stat . mtimeMs : undefined ,
5249+ mtime : entryInfo . stat . mtimeMs ,
53015250 } ) ;
53025251 }
53035252 } ;
@@ -5311,7 +5260,7 @@ const registerDirectoryLifecycle = (
53115260 relativeUrl : entryInfo . relativeUrl ,
53125261 type : entryInfo . type ,
53135262 patternValue : entryInfo . patternValue ,
5314- mtime : entryInfo . stat ? entryInfo . stat . mtimeMs : undefined ,
5263+ mtime : entryInfo . stat . mtimeMs ,
53155264 } ) ;
53165265 }
53175266 } ;
@@ -5323,9 +5272,7 @@ const registerDirectoryLifecycle = (
53235272 type : entryInfo . type ,
53245273 patternValue : entryInfo . patternValue ,
53255274 mtime : entryInfo . stat . mtimeMs ,
5326- previousMtime : entryInfo . previousInfo . stat
5327- ? entryInfo . previousInfo . stat . mtimeMs
5328- : undefined ,
5275+ previousMtime : entryInfo . previousInfo . stat . mtimeMs ,
53295276 } ) ;
53305277 }
53315278 } ;
@@ -5361,21 +5308,8 @@ ${relativeUrls.join("\n")}`,
53615308 return tracker . cleanup ;
53625309} ;
53635310
5364- const direntToType = ( dirent ) => {
5365- if ( dirent . isFile ( ) ) {
5366- return "file" ;
5367- }
5368- if ( dirent . isDirectory ( ) ) {
5369- return "directory" ;
5370- }
5371- return undefined ;
5372- } ;
5373-
53745311const shouldCallUpdated = ( entryInfo ) => {
53755312 const { stat, previousInfo } = entryInfo ;
5376- if ( ! previousInfo . stat ) {
5377- return true ;
5378- }
53795313 if ( ! stat . atimeMs ) {
53805314 return true ;
53815315 }
@@ -11297,4 +11231,4 @@ const escapeRegexpSpecialChars = (string) => {
1129711231 } ) ;
1129811232} ;
1129911233
11300- export { ANSI , Abort , CONTENT_TYPE , DATA_URL , JS_QUOTES , RUNTIME_COMPAT , UNICODE , URL_META , applyFileSystemMagicResolution , applyNodeEsmResolution , asSpecifierWithoutSearch , asUrlWithoutSearch , assertAndNormalizeDirectoryUrl , browserDefaultRuntimeCompat , bufferToEtag , clearDirectorySync , collectFiles , compareFileUrls , comparePathnames , composeTwoImportMaps , createDetailedMessage$1 as createDetailedMessage , createDynamicLog , createLogger , createLookupPackageDirectory , createTaskLog , distributePercentages , ensureEmptyDirectory , ensurePathnameTrailingSlash , ensureWindowsDriveLetter , errorToHTML , escapeRegexpSpecialChars , generateContentFrame , getCallerPosition , getExtensionsToTry , humanizeDuration , humanizeFileSize , humanizeMemory , inferRuntimeCompatFromClosestPackage , injectQueryParamIntoSpecifierWithoutEncoding , injectQueryParams , injectQueryParamsIntoSpecifier , isFileSystemPath , isSpecifierForNodeBuiltin , lookupPackageDirectory , moveUrl , nodeDefaultRuntimeCompat , normalizeImportMap , normalizeUrl , raceProcessTeardownEvents , readCustomConditionsFromProcessArgs , readEntryStatSync , readPackageAtOrNull , registerDirectoryLifecycle , renderBigSection , renderDetails , renderTable , renderUrlOrRelativeUrlFilename , resolveImport , setUrlBasename , setUrlExtension , setUrlFilename , startMonitoringCpuUsage , startMonitoringMemoryUsage , stringifyUrlSite , updateJsonFileSync , urlIsOrIsInsideOf , urlToBasename , urlToExtension$1 as urlToExtension , urlToFileSystemPath , urlToFilename$1 as urlToFilename , urlToPathname$1 as urlToPathname , urlToRelativeUrl , validateResponseIntegrity , writeFile , writeFileSync } ;
11234+ export { ANSI , Abort , CONTENT_TYPE , DATA_URL , JS_QUOTES , RUNTIME_COMPAT , UNICODE , URL_META , applyFileSystemMagicResolution , applyNodeEsmResolution , asSpecifierWithoutSearch , asUrlWithoutSearch , assertAndNormalizeDirectoryUrl , browserDefaultRuntimeCompat , bufferToEtag , clearDirectorySync , collectFiles , compareFileUrls , comparePathnames , composeTwoImportMaps , createDetailedMessage$1 as createDetailedMessage , createDynamicLog , createLogger , createLookupPackageDirectory , createTaskLog , distributePercentages , ensureEmptyDirectory , ensurePathnameTrailingSlash , ensureWindowsDriveLetter , errorToHTML , escapeRegexpSpecialChars , generateContentFrame , getCallerPosition , getExtensionsToTry , humanizeDuration , humanizeFileSize , humanizeMemory , inferRuntimeCompatFromClosestPackage , injectQueryParamIntoSpecifierWithoutEncoding , injectQueryParams , injectQueryParamsIntoSpecifier , isFileSystemPath , isSpecifierForNodeBuiltin , lookupPackageDirectory , moveUrl , nodeDefaultRuntimeCompat , normalizeImportMap , normalizeUrl , raceProcessTeardownEvents , readCustomConditionsFromProcessArgs , readEntryStatSync , readPackageAtOrNull , registerDirectoryLifecycle , renderBigSection , renderDetails , renderTable , renderUrlOrRelativeUrlFilename , resolveImport , setUrlBasename , setUrlExtension , setUrlFilename , startMonitoringCpuUsage , startMonitoringMemoryUsage , stringifyUrlSite , updateJsonFileSync , urlIsOrIsInsideOf , urlToBasename , urlToExtension$1 as urlToExtension , urlToFileSystemPath , urlToFilename$1 as urlToFilename , urlToPathname$1 as urlToPathname , urlToRelativeUrl , validateResponseIntegrity , writeFileSync } ;
0 commit comments