@gjsify/fs 0.4.34 → 0.4.36

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.
@@ -0,0 +1 @@
1
+ import{__exportAll as e}from"../_virtual/_rolldown/runtime.js";import{accessSync as t,appendFileSync as n,chmodSync as r,chownSync as i,closeSync as a,copyFileSync as o,existsSync as s,linkSync as c,lstatSync as l,mkdirSync as u,mkdtempSync as d,openSync as f,readFileSync as p,readSync as m,readdirSync as h,readlinkSync as g,realpathSync as _,renameSync as v,rmSync as y,rmdirSync as b,statSync as x,symlinkSync as S,truncateSync as C,unlinkSync as w,utimesSync as T,writeFileSync as E,writeSync as D}from"./sync.js";var O=e({access:()=>access,appendFile:()=>appendFile,chmod:()=>chmod,chown:()=>chown,close:()=>close,copyFile:()=>copyFile,exists:()=>exists,link:()=>link,lstat:()=>lstat,mkdir:()=>mkdir,mkdtemp:()=>mkdtemp,open:()=>open,read:()=>read,readFile:()=>readFile,readdir:()=>readdir,readlink:()=>readlink,realpath:()=>realpath,rename:()=>rename,rm:()=>rm,rmdir:()=>rmdir,stat:()=>stat,symlink:()=>symlink,truncate:()=>truncate,unlink:()=>unlink,utimes:()=>utimes,write:()=>write,writeFile:()=>writeFile});function defer(e,t){queueMicrotask(()=>{try{t?.(null,e())}catch(e){t?.(e)}})}function pickCb(...e){for(let t of e)if(typeof t==`function`)return t}function readFile(e,t,n){let r=pickCb(t,n),i=typeof t==`function`?void 0:t;defer(()=>p(e,i),r)}function writeFile(e,t,n,r){let i=pickCb(n,r),a=typeof n==`function`?void 0:n;defer(()=>E(e,t,a),i)}function appendFile(e,t,r,i){let a=pickCb(r,i),o=typeof r==`function`?void 0:r;defer(()=>n(e,t,o),a)}function stat(e,t){defer(()=>x(e),t)}function lstat(e,t){defer(()=>l(e),t)}function exists(e,t){queueMicrotask(()=>t?.(s(e)))}function access(e,n,r){let i=pickCb(n,r),a=typeof n==`number`?n:0;defer(()=>t(e,a),i)}function readdir(e,t,n){let r=pickCb(t,n),i=typeof t==`function`?void 0:t;defer(()=>h(e,i),r)}function mkdir(e,t,n){let r=pickCb(t,n),i=typeof t==`function`?void 0:t;defer(()=>u(e,i),r)}function rmdir(e,t,n){let r=pickCb(t,n),i=typeof t==`function`?void 0:t;defer(()=>b(e,i),r)}function rm(e,t,n){let r=pickCb(t,n),i=typeof t==`function`?void 0:t;defer(()=>y(e,i),r)}function unlink(e,t){defer(()=>w(e),t)}function rename(e,t,n){defer(()=>v(e,t),n)}function copyFile(e,t,n,r){let i=pickCb(n,r),a=typeof n==`number`?n:0;defer(()=>o(e,t,a),i)}function link(e,t,n){defer(()=>c(e,t),n)}function symlink(e,t,n,r){defer(()=>S(e,t),pickCb(n,r))}function readlink(e,t){defer(()=>g(e),t)}function realpath(e,t){defer(()=>_(e),t)}realpath.native=realpath;function chmod(e,t,n){defer(()=>r(e,t),n)}function chown(e,t,n,r){defer(()=>i(e,t,n),r)}function truncate(e,t,n){let r=pickCb(t,n),i=typeof t==`number`?t:0;defer(()=>C(e,i),r)}function utimes(e,t,n,r){defer(()=>T(e,t,n),r)}function mkdtemp(e,t){defer(()=>d(e),t)}function open(e,t,n,r){let i=pickCb(t,n,r),a=typeof t==`string`?t:`r`,o=typeof n==`number`?n:438;defer(()=>f(e,a,o),i)}function close(e,t){defer(()=>a(e),t)}function read(e,t,n,r,i,a){queueMicrotask(()=>{try{let o=m(e,t,n,r,i);a?.(null,o,t)}catch(e){a?.(e,0,t)}})}function write(e,t,n,r,i,a){let o=pickCb(n,i,a),s=typeof n==`number`?n:0,c=typeof r==`number`?r:void 0,l=typeof i==`number`?i:null;queueMicrotask(()=>{try{let n=D(e,t,s,c,l);o?.(null,n)}catch(e){o?.(e,0)}})}export{access,appendFile,O as async_exports,chmod,chown,close,copyFile,exists,link,lstat,mkdir,mkdtemp,open,read,readFile,readdir,readlink,realpath,rename,rm,rmdir,stat,symlink,truncate,unlink,utimes,write,writeFile};
@@ -0,0 +1 @@
1
+ const e=0,t=4,n=2,r=1,i=1,a=2,o=4,s=0,c=1,l=2,u=64,d=128,f=512,p=1024,m=1052672,h=2048,g=65536,_=131072,v=61440,y=32768,b=16384,x=8192,S=24576,C=4096,w=40960,T=49152,E=448,D=256,O=128,k=64,A=56,j=32,M=16,N=8,P=7,F=4,I=2,L=1,R={F_OK:0,R_OK:4,W_OK:2,X_OK:1,COPYFILE_EXCL:1,COPYFILE_FICLONE:2,COPYFILE_FICLONE_FORCE:4,O_RDONLY:0,O_WRONLY:1,O_RDWR:2,O_CREAT:64,O_EXCL:128,O_TRUNC:512,O_APPEND:p,O_SYNC:m,O_NONBLOCK:h,O_DIRECTORY:g,O_NOFOLLOW:_,S_IFMT:v,S_IFREG:y,S_IFDIR:b,S_IFCHR:x,S_IFBLK:S,S_IFIFO:C,S_IFLNK:w,S_IFSOCK:T,S_IRWXU:448,S_IRUSR:256,S_IWUSR:128,S_IXUSR:64,S_IRWXG:56,S_IRGRP:32,S_IWGRP:16,S_IXGRP:8,S_IRWXO:7,S_IROTH:4,S_IWOTH:2,S_IXOTH:1};export{i as COPYFILE_EXCL,a as COPYFILE_FICLONE,o as COPYFILE_FICLONE_FORCE,e as F_OK,p as O_APPEND,u as O_CREAT,g as O_DIRECTORY,d as O_EXCL,_ as O_NOFOLLOW,h as O_NONBLOCK,s as O_RDONLY,l as O_RDWR,m as O_SYNC,f as O_TRUNC,c as O_WRONLY,t as R_OK,S as S_IFBLK,x as S_IFCHR,b as S_IFDIR,C as S_IFIFO,w as S_IFLNK,v as S_IFMT,y as S_IFREG,T as S_IFSOCK,j as S_IRGRP,F as S_IROTH,D as S_IRUSR,A as S_IRWXG,P as S_IRWXO,E as S_IRWXU,M as S_IWGRP,I as S_IWOTH,O as S_IWUSR,N as S_IXGRP,L as S_IXOTH,k as S_IXUSR,n as W_OK,r as X_OK,R as constants};
@@ -0,0 +1 @@
1
+ import"../_virtual/_rolldown/runtime.js";const e={ENOENT:-2,EEXIST:-17,EISDIR:-21,ENOTDIR:-20,EACCES:-13,EBADF:-9,EINVAL:-22,ENOTEMPTY:-39,ENOSYS:-38,ENOTSUP:-45,EPERM:-1},t={ENOENT:`no such file or directory`,EEXIST:`file already exists`,EISDIR:`illegal operation on a directory`,ENOTDIR:`not a directory`,EACCES:`permission denied`,EBADF:`bad file descriptor`,EINVAL:`invalid argument`,ENOTEMPTY:`directory not empty`,ENOSYS:`function not implemented`,ENOTSUP:`operation not supported`,EPERM:`operation not permitted`};function createError(n,r,i,a){let o=`${n}: ${t[n]}, ${r}${i?` '${i}'`:``}${a?` -> '${a}'`:``}`,s=Error(o);return s.code=n,s.errno=e[n],s.syscall=r,i!==void 0&&(s.path=i),a!==void 0&&(s.dest=a),s}const ENOENT=(e,t)=>createError(`ENOENT`,e,t),EEXIST=(e,t)=>createError(`EEXIST`,e,t),EISDIR=(e,t)=>createError(`EISDIR`,e,t),ENOTDIR=(e,t)=>createError(`ENOTDIR`,e,t),EACCES=(e,t)=>createError(`EACCES`,e,t),EBADF=e=>createError(`EBADF`,e),EINVAL=(e,t)=>createError(`EINVAL`,e,t),ENOTEMPTY=(e,t)=>createError(`ENOTEMPTY`,e,t),ENOTSUP=(e,t)=>createError(`ENOTSUP`,e,t);export{EACCES,EBADF,EEXIST,EINVAL,EISDIR,ENOENT,ENOTDIR,ENOTEMPTY,ENOTSUP,createError};
@@ -0,0 +1 @@
1
+ import"../_virtual/_rolldown/runtime.js";function normalize(e){if(typeof e!=`string`)throw TypeError(`path must be a string`);if(e.length===0)return`.`;let t=e.charCodeAt(0)===47,n=e.charCodeAt(e.length-1)===47,r=e.split(`/`),i=[];for(let e of r)if(!(e===``||e===`.`)){if(e===`..`){i.length&&i[i.length-1]!==`..`?i.pop():t||i.push(`..`);continue}i.push(e)}let a=i.join(`/`);return n&&!a.endsWith(`/`)&&(a+=`/`),t?`/`+a:a||`.`}function resolve(...e){let t=``,n=!1;for(let r=e.length-1;r>=0&&!n;r--){let i=e[r];if(typeof i!=`string`)throw TypeError(`path segment must be a string`);i&&(t=i+`/`+t,i.charCodeAt(0)===47&&(n=!0))}return n||(t=`/`+t),normalize(t).replace(/\/$/,``)||`/`}function dirname(e){if(e.length===0)return`.`;let t=e.charCodeAt(0)===47,n=-1,r=!0;for(let t=e.length-1;t>=1;t--)if(e.charCodeAt(t)===47){if(!r){n=t;break}}else r=!1;return n===-1?t?`/`:`.`:t&&n===0?`/`:e.slice(0,n)}function basename(e,t){if(e.length===0)return``;let n=0,r=-1,i=!0;for(let t=e.length-1;t>=0;t--)if(e.charCodeAt(t)===47){if(!i){n=t+1;break}}else r===-1&&(i=!1,r=t+1);if(r===-1)return``;let a=e.slice(n,r);return t&&a.endsWith(t)&&a!==t&&(a=a.slice(0,-t.length)),a}function toPath(e){if(typeof e==`string`)return e;if(e instanceof URL){if(e.protocol!==`file:`)throw TypeError(`unsupported URL scheme: ${e.protocol}`);return decodeURIComponent(e.pathname)}if(e&&typeof e.toString==`function`)return e.toString();throw TypeError(`path must be a string, Buffer, or URL`)}function split(e){let t=normalize(e);if(t===`/`)return[];let n=+(t.charCodeAt(0)===47);return t.slice(n).split(`/`).filter(Boolean)}export{basename,dirname,normalize,resolve,split,toPath};
@@ -0,0 +1 @@
1
+ import{constants as e}from"./constants.js";import{FileHandle as t,access as n,appendFile as r,chmod as i,chown as a,copyFile as o,link as s,lstat as c,mkdir as l,mkdtemp as u,open as d,readFile as f,readdir as p,readlink as m,realpath as h,rename as g,rm as _,rmdir as v,stat as y,symlink as b,truncate as x,unlink as S,utimes as C,writeFile as w}from"./promises.js";var T={readFile:f,writeFile:w,appendFile:r,stat:y,lstat:c,access:n,readdir:p,mkdir:l,rmdir:v,rm:_,unlink:S,rename:g,copyFile:o,link:s,symlink:b,readlink:m,realpath:h,chmod:i,chown:a,truncate:x,utimes:C,mkdtemp:u,open:d,FileHandle:t};export{t as FileHandle,n as access,r as appendFile,i as chmod,a as chown,e as constants,o as copyFile,T as default,s as link,c as lstat,l as mkdir,u as mkdtemp,d as open,f as readFile,p as readdir,m as readlink,h as realpath,g as rename,_ as rm,v as rmdir,y as stat,b as symlink,x as truncate,S as unlink,C as utimes,w as writeFile};
@@ -0,0 +1 @@
1
+ import{__exportAll as e}from"../_virtual/_rolldown/runtime.js";import{accessSync as t,appendFileSync as n,chmodSync as r,chownSync as i,closeSync as a,copyFileSync as o,linkSync as s,lstatSync as c,mkdirSync as l,mkdtempSync as u,openSync as d,readFileSync as f,readSync as p,readdirSync as m,readlinkSync as h,realpathSync as g,renameSync as _,rmSync as v,rmdirSync as y,statSync as b,symlinkSync as x,truncateSync as S,unlinkSync as C,utimesSync as w,writeFileSync as T,writeSync as E}from"./sync.js";var D=e({FileHandle:()=>FileHandle,access:()=>N,appendFile:()=>A,chmod:()=>G,chown:()=>K,copyFile:()=>B,link:()=>V,lstat:()=>M,mkdir:()=>F,mkdtemp:()=>Y,open:()=>open,readFile:()=>O,readdir:()=>P,readlink:()=>U,realpath:()=>W,rename:()=>z,rm:()=>L,rmdir:()=>I,stat:()=>j,symlink:()=>H,truncate:()=>q,unlink:()=>R,utimes:()=>J,writeFile:()=>k});function async_(e){return((...t)=>new Promise((n,r)=>queueMicrotask(()=>{try{n(e(...t))}catch(e){r(e)}})))}const O=async_(f),k=async_(T),A=async_(n),j=async_(b),M=async_(c),N=async_(t),P=async_(m),F=async_(l),I=async_(y),L=async_(v),R=async_(C),z=async_(_),B=async_(o),V=async_(s),H=async_(x),U=async_(h),W=async_(g),G=async_(r),K=async_(i),q=async_(S),J=async_(w),Y=async_(u);var FileHandle=class{fd;constructor(e){this.fd=e}read(e,t,n,r){return new Promise((i,a)=>queueMicrotask(()=>{try{i({bytesRead:p(this.fd,e,t??0,n??e.byteLength,r??null),buffer:e})}catch(e){a(e)}}))}write(e,t,n,r){return new Promise((i,a)=>queueMicrotask(()=>{try{i({bytesWritten:E(this.fd,e,t??0,n,r),buffer:e})}catch(e){a(e)}}))}readFile(){return new Promise((e,t)=>queueMicrotask(()=>{try{let t=new Uint8Array(64*1024),n=[],r=0;for(;(r=p(this.fd,t,0,t.byteLength,null))>0;)n.push(t.slice(0,r));let i=n.reduce((e,t)=>e+t.byteLength,0),a=new Uint8Array(i),o=0;for(let e of n)a.set(e,o),o+=e.byteLength;e(a)}catch(e){t(e)}}))}close(){return new Promise((e,t)=>queueMicrotask(()=>{try{a(this.fd),e()}catch(e){t(e)}}))}};function open(e,t=`r`,n=438){return new Promise((r,i)=>queueMicrotask(()=>{try{r(new FileHandle(d(e,t,n)))}catch(e){i(e)}}))}export{FileHandle,N as access,A as appendFile,G as chmod,K as chown,B as copyFile,V as link,M as lstat,F as mkdir,Y as mkdtemp,open,D as promises_exports,O as readFile,P as readdir,U as readlink,W as realpath,z as rename,L as rm,I as rmdir,j as stat,H as symlink,q as truncate,R as unlink,J as utimes,k as writeFile};
@@ -0,0 +1 @@
1
+ import{__exportAll as e}from"../_virtual/_rolldown/runtime.js";import{__defaultVolume as t,absolutise as n}from"./volume.js";import{appendFileSync as r,writeFileSync as i}from"./sync.js";var a=e({FSWatcher:()=>FSWatcher,ReadStream:()=>ReadStream,StatWatcher:()=>StatWatcher,WriteStream:()=>WriteStream,createReadStream:()=>createReadStream,createWriteStream:()=>createWriteStream,unwatchFile:()=>unwatchFile,watch:()=>watch,watchFile:()=>watchFile}),EventBus=class{listeners=new Map;on(e,t){let n=this.listeners.get(e)??[];return n.push(t),this.listeners.set(e,n),this}once(e,t){let wrapper=(...n)=>{this.off(e,wrapper),t(...n)};return this.on(e,wrapper)}off(e,t){let n=this.listeners.get(e);if(!n)return this;let r=n.indexOf(t);return r>=0&&n.splice(r,1),this}emit(e,...t){let n=this.listeners.get(e);if(!n||n.length===0)return!1;for(let e of n.slice())e(...t);return!0}removeAllListeners(e){return e?this.listeners.delete(e):this.listeners.clear(),this}},ReadStream=class extends EventBus{path;destroyed=!1;buffer;position;end;chunkSize;encoding;constructor(e,r={}){super(),this.path=n(e);try{this.buffer=t.readFileSync(this.path)}catch(e){this.buffer=new Uint8Array,queueMicrotask(()=>this.emit(`error`,e));return}this.position=r.start??0,this.end=Math.min(r.end??this.buffer.byteLength-1,this.buffer.byteLength-1),this.chunkSize=r.highWaterMark??65536,this.encoding=r.encoding,queueMicrotask(()=>this._pump())}_pump(){if(!this.destroyed){for(;this.position<=this.end;){let e=Math.min(this.position+this.chunkSize,this.end+1),t=this.buffer.subarray(this.position,e);this.position=e,this.encoding?this.emit(`data`,new TextDecoder(this.encoding).decode(t)):this.emit(`data`,t)}this.emit(`end`),this.emit(`close`)}}pipe(e){return this.on(`data`,t=>{e.write(t)}),this.on(`end`,()=>{e.end?.()}),e}destroy(e){this.destroyed=!0,e&&this.emit(`error`,e),this.emit(`close`)}async*[Symbol.asyncIterator](){let e=[],t=!1,n=null;for(this.on(`data`,t=>{e.push(t),n?.()}),this.on(`end`,()=>{t=!0,n?.()});!t||e.length>0;){if(e.length===0){await new Promise(e=>{n=e}),n=null;continue}let t=e.shift();t!==void 0&&(yield t)}}get bytesRead(){return this.position}};function createReadStream(e,t){return new ReadStream(e,t)}var WriteStream=class extends EventBus{path;destroyed=!1;parts=[];ended=!1;flags;mode;encoding;bytesWritten=0;constructor(e,t={}){super(),this.path=n(e),this.flags=t.flags??`w`,this.mode=t.mode??438,this.encoding=t.encoding,queueMicrotask(()=>this.emit(`open`,-1))}write(e,t,n){if(this.destroyed||this.ended)return!1;let r=typeof t==`function`?t:n,i=typeof e==`string`?new TextEncoder().encode(e):e;return this.parts.push(i),this.bytesWritten+=i.byteLength,queueMicrotask(()=>r?.(null)),!0}end(e,t){this.ended||(e&&this.write(e),this.ended=!0,queueMicrotask(()=>{try{let e=new Uint8Array(this.parts.reduce((e,t)=>e+t.byteLength,0)),n=0;for(let t of this.parts)e.set(t,n),n+=t.byteLength;this.flags===`a`||this.flags===`a+`?r(this.path,e):i(this.path,e,{mode:this.mode}),this.emit(`finish`),this.emit(`close`),t?.()}catch(e){this.emit(`error`,e)}}))}destroy(e){this.destroyed=!0,e&&this.emit(`error`,e),this.emit(`close`)}};function createWriteStream(e,t){return new WriteStream(e,t)}var FSWatcher=class extends EventBus{path;closed=!1;constructor(e){super(),this.path=n(e)}close(){this.closed||(this.closed=!0,this.emit(`close`))}ref(){return this}unref(){return this}};function watch(e,t,n){return new FSWatcher(e)}var StatWatcher=class extends EventBus{close(){this.emit(`close`)}ref(){return this}unref(){return this}};function watchFile(e){return new StatWatcher}function unwatchFile(e){}export{FSWatcher,ReadStream,StatWatcher,WriteStream,createReadStream,createWriteStream,a as stream_exports,unwatchFile,watch,watchFile};
@@ -0,0 +1 @@
1
+ import{__exportAll as e}from"../_virtual/_rolldown/runtime.js";import{dirname as t,resolve as n}from"./path-utils.js";import{BigIntStats as r,Dirent as i,Stats as a}from"./types.js";import{__defaultVolume as o,absolutise as s}from"./volume.js";var c=e({accessSync:()=>accessSync,appendFileSync:()=>appendFileSync,chmodSync:()=>chmodSync,chownSync:()=>chownSync,closeSync:()=>closeSync,copyFileSync:()=>copyFileSync,existsSync:()=>existsSync,linkSync:()=>linkSync,lstatSync:()=>lstatSync,mkdirSync:()=>mkdirSync,mkdtempSync:()=>mkdtempSync,openSync:()=>openSync,readFileSync:()=>readFileSync,readSync:()=>readSync,readdirSync:()=>readdirSync,readlinkSync:()=>readlinkSync,realpathSync:()=>realpathSync,renameSync:()=>renameSync,rmSync:()=>rmSync,rmdirSync:()=>rmdirSync,statSync:()=>statSync,symlinkSync:()=>symlinkSync,truncateSync:()=>truncateSync,unlinkSync:()=>unlinkSync,utimesSync:()=>utimesSync,writeFileSync:()=>writeFileSync,writeSync:()=>writeSync});function toBytes(e,t){if(typeof e==`string`){if(!t||t===`utf8`||t===`utf-8`)return new TextEncoder().encode(e);if(t===`ascii`||t===`binary`){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&255;return t}if(t===`base64`){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}if(t===`hex`){let t=new Uint8Array(e.length/2);for(let n=0;n<t.length;n++)t[n]=parseInt(e.slice(n*2,n*2+2),16);return t}return new TextEncoder().encode(e)}return e instanceof Uint8Array?e:new Uint8Array(e.buffer,e.byteOffset??0,e.byteLength??e.buffer.byteLength)}function decodeBytes(e,t){if(!t)return e;if(t===`utf8`||t===`utf-8`)return new TextDecoder(`utf-8`).decode(e);if(t===`ascii`||t===`binary`){let t=``;for(let n=0;n<e.byteLength;n++)t+=String.fromCharCode(e[n]);return t}if(t===`base64`){let t=``;for(let n=0;n<e.byteLength;n++)t+=String.fromCharCode(e[n]);return btoa(t)}if(t===`hex`){let t=``;for(let n=0;n<e.byteLength;n++)t+=e[n].toString(16).padStart(2,`0`);return t}return new TextDecoder(`utf-8`).decode(e)}function statsFor(e,t,n){return n?.bigint?new r(t):new a(t)}function readFileSync(e,t){return decodeBytes(o.readFileSync(s(e)),(typeof t==`string`?t:t?.encoding)??null)}function writeFileSync(e,t,n){let r=typeof n==`string`?n:n?.encoding,i=typeof n==`object`&&n?n.mode:void 0;o.writeFileSync(s(e),toBytes(t,r),i)}function appendFileSync(e,t,n){let r=typeof n==`string`?n:n?.encoding,i=typeof n==`object`&&n?n.mode:void 0;o.appendFileSync(s(e),toBytes(t,r),i)}function statSync(e,t){try{return statsFor(e,o.statSync(s(e)),t)}catch(e){if(t?.throwIfNoEntry===!1)return;throw e}}function lstatSync(e,t){try{return statsFor(e,o.lstatSync(s(e)),t)}catch(e){if(t?.throwIfNoEntry===!1)return;throw e}}function existsSync(e){try{return o.existsSync(s(e))}catch{return!1}}function accessSync(e,t=0){o.accessSync(s(e),t)}function readdirSync(e,t){let n=s(e);return t?.withFileTypes?o.readdirEntriesSync(n).map(e=>new i(e.name,e.kind,n)):o.readdirSync(n)}function mkdirSync(e,t){let n=typeof t==`number`?{mode:t}:t??{};return o.mkdirSync(s(e),n)}function rmdirSync(e,t){o.rmdirSync(s(e),t??{})}function rmSync(e,t){o.rmSync(s(e),t??{})}function unlinkSync(e){o.unlinkSync(s(e))}function renameSync(e,t){o.renameSync(s(e),s(t))}function copyFileSync(e,t,n=0){o.copyFileSync(s(e),s(t),n)}function linkSync(e,t){o.linkSync(s(e),s(t))}function symlinkSync(e,t){o.symlinkSync(typeof e==`string`?e:e.toString(),s(t))}function readlinkSync(e){return o.readlinkSync(s(e))}function realpathSync(e){return o.realpathSync(s(e))}realpathSync.native=realpathSync;function chmodSync(e,t){o.chmodSync(s(e),t)}function chownSync(e,t,n){o.chownSync(s(e),t,n)}function truncateSync(e,t=0){o.truncateSync(s(e),t)}function utimesSync(e,t,n){let r=t instanceof Date?t.getTime():t*1e3,i=n instanceof Date?n.getTime():n*1e3;o.utimesSync(s(e),r,i)}function mkdtempSync(e){let r=n(e+(Math.floor(Math.random()*1e10).toString(36)+Date.now().toString(36).slice(-4)).slice(0,6));return o.mkdirSync(t(r),{recursive:!0}),o.mkdirSync(r),r}function openSync(e,t=`r`,n=438){return o.openSync(s(e),t,n)}function closeSync(e){o.closeSync(e)}function readSync(e,t,n,r,i){return o.readSync(e,t,n,r,i)}function writeSync(e,t,n,r,i){let a=typeof t==`string`?new TextEncoder().encode(t):t;if(typeof t==`string`){let t=n??null;return o.writeSync(e,a,0,a.byteLength,t)}return o.writeSync(e,a,n??0,r??a.byteLength,i??null)}export{accessSync,appendFileSync,chmodSync,chownSync,closeSync,copyFileSync,existsSync,linkSync,lstatSync,mkdirSync,mkdtempSync,openSync,readFileSync,readSync,readdirSync,readlinkSync,realpathSync,renameSync,rmSync,rmdirSync,statSync,symlinkSync,c as sync_exports,truncateSync,unlinkSync,utimesSync,writeFileSync,writeSync};
@@ -0,0 +1 @@
1
+ import"../_virtual/_rolldown/runtime.js";import{S_IFDIR as e,S_IFLNK as t,S_IFREG as n}from"./constants.js";var KindTests=class{isFile(){return this._kind()===`file`}isDirectory(){return this._kind()===`dir`}isSymbolicLink(){return this._kind()===`symlink`}isBlockDevice(){return!1}isCharacterDevice(){return!1}isFIFO(){return!1}isSocket(){return!1}},Stats=class extends KindTests{kind;dev=0;ino;mode;nlink;uid;gid;rdev=0;size;blksize=4096;blocks;atimeMs;mtimeMs;ctimeMs;birthtimeMs;atime;mtime;ctime;birthtime;constructor(e){super(),this.kind=e.kind,this.size=e.size,this.mode=e.mode,this.uid=e.uid,this.gid=e.gid,this.ino=e.ino,this.nlink=e.nlink,this.atimeMs=e.atimeMs,this.mtimeMs=e.mtimeMs,this.ctimeMs=e.ctimeMs,this.birthtimeMs=e.birthtimeMs,this.blocks=Math.ceil(e.size/512),this.atime=new Date(e.atimeMs),this.mtime=new Date(e.mtimeMs),this.ctime=new Date(e.ctimeMs),this.birthtime=new Date(e.birthtimeMs)}_kind(){return this.kind}},BigIntStats=class extends KindTests{kind;dev=0n;ino;mode;nlink;uid;gid;rdev=0n;size;blksize=4096n;blocks;atimeMs;mtimeMs;ctimeMs;birthtimeMs;atimeNs;mtimeNs;ctimeNs;birthtimeNs;atime;mtime;ctime;birthtime;constructor(e){super(),this.kind=e.kind,this.size=BigInt(e.size),this.mode=BigInt(e.mode),this.uid=BigInt(e.uid),this.gid=BigInt(e.gid),this.ino=BigInt(e.ino),this.nlink=BigInt(e.nlink),this.atimeMs=BigInt(Math.floor(e.atimeMs)),this.mtimeMs=BigInt(Math.floor(e.mtimeMs)),this.ctimeMs=BigInt(Math.floor(e.ctimeMs)),this.birthtimeMs=BigInt(Math.floor(e.birthtimeMs)),this.atimeNs=this.atimeMs*1000000n,this.mtimeNs=this.mtimeMs*1000000n,this.ctimeNs=this.ctimeMs*1000000n,this.birthtimeNs=this.birthtimeMs*1000000n,this.blocks=BigInt(Math.ceil(e.size/512)),this.atime=new Date(e.atimeMs),this.mtime=new Date(e.mtimeMs),this.ctime=new Date(e.ctimeMs),this.birthtime=new Date(e.birthtimeMs)}_kind(){return this.kind}},Dirent=class extends KindTests{name;parentPath;path;kind;constructor(e,t,n){super(),this.name=e,this.parentPath=n,this.path=n,this.kind=t}_kind(){return this.kind}};function modeFor(r,i){return(r===`dir`?e:r===`symlink`?t:n)|i&4095}export{BigIntStats,Dirent,Stats,modeFor};
@@ -0,0 +1 @@
1
+ import"../_virtual/_rolldown/runtime.js";import{EACCES as e,EBADF as t,EEXIST as n,EINVAL as r,EISDIR as i,ENOENT as a,ENOTDIR as o,ENOTEMPTY as s}from"./errors.js";import{dirname as c,normalize as l,resolve as u,split as d}from"./path-utils.js";import{modeFor as f}from"./types.js";const p=new Uint8Array,now=()=>Date.now();function toStatFields(e){return{kind:e.kind,size:e.kind===`file`?e.data.byteLength:e.kind===`symlink`?e.target.length:0,mode:e.mode,atimeMs:e.atimeMs,mtimeMs:e.mtimeMs,ctimeMs:e.ctimeMs,birthtimeMs:e.birthtimeMs,uid:e.uid,gid:e.gid,ino:e.ino,nlink:e.nlink}}var Volume=class{root;nextIno=2;fds=new Map;nextFd=3;constructor(){this.root={kind:`dir`,children:new Map,...this.mkBase(`dir`,493),nlink:2},this.root.ino=1}mkBase(e,t){let n=now();return{mode:f(e,t),uid:0,gid:0,atimeMs:n,mtimeMs:n,ctimeMs:n,birthtimeMs:n,ino:this.nextIno++,nlink:1}}mkNode(e,t){let n=this.mkBase(e,t);return e===`file`?{kind:`file`,data:p,...n}:e===`dir`?{kind:`dir`,children:new Map,...n,nlink:2}:{kind:`symlink`,target:``,...n}}lookup(e,t){let n=u(e);if(n===`/`)return this.root;let r=this.root;for(let e of d(n)){if(r.kind!==`dir`)throw o(t,n);let i=r.children.get(e);if(!i)throw a(t,n);r=i}return r}lookupParent(e,t){let n=u(e);if(n===`/`)throw r(t,n);let i=this.lookup(c(n),t);if(i.kind!==`dir`)throw o(t,c(n));let a=d(n);return{parent:i,name:a[a.length-1],abs:n}}existsSync(e){try{return this.lookup(e,`stat`),!0}catch{return!1}}statSync(e){let t=this.lookup(e,`stat`);return t.atimeMs=now(),toStatFields(t)}lstatSync(e){return this.statSync(e)}accessSync(e,t){this.lookup(e,`access`)}readFileSync(e){let t=this.lookup(e,`open`);if(t.kind===`dir`)throw i(`read`,u(e));if(t.kind===`symlink`)throw r(`read`,u(e));return t.atimeMs=now(),new Uint8Array(t.data)}writeFileSync(e,t,n=438){let a=u(e);try{let e=this.lookup(a,`open`);if(e.kind===`dir`)throw i(`open`,a);if(e.kind===`symlink`)throw r(`open`,a);e.data=new Uint8Array(t),e.mtimeMs=e.ctimeMs=now()}catch(e){if(e.code!==`ENOENT`)throw e;let{parent:r,name:i}=this.lookupParent(a,`open`),o=this.mkNode(`file`,n);o.data=new Uint8Array(t),r.children.set(i,o),r.mtimeMs=r.ctimeMs=now()}}appendFileSync(e,t,n=438){let r=u(e);try{let e=this.lookup(r,`open`);if(e.kind!==`file`)throw i(`open`,r);let n=new Uint8Array(e.data.byteLength+t.byteLength);n.set(e.data,0),n.set(t,e.data.byteLength),e.data=n,e.mtimeMs=e.ctimeMs=now()}catch(e){if(e.code!==`ENOENT`)throw e;this.writeFileSync(r,t,n)}}truncateSync(e,t=0){let n=this.lookup(e,`open`);if(n.kind!==`file`)throw i(`open`,u(e));if(t<n.data.byteLength)n.data=n.data.slice(0,t);else if(t>n.data.byteLength){let e=new Uint8Array(t);e.set(n.data,0),n.data=e}n.mtimeMs=n.ctimeMs=now()}readdirSync(e){let t=this.lookup(e,`scandir`);if(t.kind!==`dir`)throw o(`scandir`,u(e));return[...t.children.keys()]}readdirEntriesSync(e){let t=this.lookup(e,`scandir`);if(t.kind!==`dir`)throw o(`scandir`,u(e));return[...t.children.entries()].map(([e,t])=>({name:e,kind:t.kind}))}mkdirSync(e,t={}){let r=u(e);if(r===`/`){if(t.recursive)return;throw n(`mkdir`,r)}let i=d(r),s=t.mode??511,c,l=this.root,f=``;for(let e=0;e<i.length;e++){let u=i[e];f+=`/`+u;let d=l.children.get(u);if(!d){if(!t.recursive&&e!==i.length-1)throw a(`mkdir`,r);let n=this.mkNode(`dir`,s);l.children.set(u,n),l.mtimeMs=l.ctimeMs=now(),c===void 0&&(c=f),l=n}else if(d.kind!==`dir`)throw o(`mkdir`,f);else if(e===i.length-1&&!t.recursive)throw n(`mkdir`,r);else l=d}return c}rmdirSync(t,n={}){let r=u(t);if(r===`/`)throw e(`rmdir`,r);let{parent:i,name:c}=this.lookupParent(r,`rmdir`),l=i.children.get(c);if(!l)throw a(`rmdir`,r);if(l.kind!==`dir`)throw o(`rmdir`,r);if(!n.recursive&&l.children.size>0)throw s(`rmdir`,r);i.children.delete(c),i.mtimeMs=i.ctimeMs=now()}unlinkSync(e){let t=u(e),{parent:n,name:r}=this.lookupParent(t,`unlink`),o=n.children.get(r);if(!o)throw a(`unlink`,t);if(o.kind===`dir`)throw i(`unlink`,t);n.children.delete(r),n.mtimeMs=n.ctimeMs=now()}rmSync(e,t={}){let n=u(e),r;try{r=this.lookup(n,`unlink`)}catch(e){if(t.force&&e.code===`ENOENT`)return;throw e}if(r.kind===`dir`){if(!t.recursive)throw i(`unlink`,n);this.rmdirSync(n,{recursive:!0});return}this.unlinkSync(n)}renameSync(e,t){let n=u(e),r=u(t);if(n===r)return;let{parent:i,name:o}=this.lookupParent(n,`rename`),c=i.children.get(o);if(!c)throw a(`rename`,n);let{parent:l,name:d}=this.lookupParent(r,`rename`),f=l.children.get(d);if(f?.kind===`dir`&&f.children.size>0)throw s(`rename`,r);i.children.delete(o),l.children.set(d,c);let p=now();i.mtimeMs=i.ctimeMs=p,l.mtimeMs=l.ctimeMs=p,c.ctimeMs=p}copyFileSync(e,t,r=0){let a=this.lookup(e,`copyfile`);if(a.kind!==`file`)throw i(`copyfile`,u(e));if(r&1&&this.existsSync(t))throw n(`copyfile`,u(t));this.writeFileSync(t,a.data,a.mode&511)}linkSync(e,t){let r=this.lookup(e,`link`);if(r.kind!==`file`)throw i(`link`,u(e));let{parent:a,name:o}=this.lookupParent(t,`link`);if(a.children.has(o))throw n(`link`,u(t));r.nlink+=1,a.children.set(o,{...r,kind:`file`}),a.mtimeMs=a.ctimeMs=now()}symlinkSync(e,t){let r=u(t),{parent:i,name:a}=this.lookupParent(r,`symlink`);if(i.children.has(a))throw n(`symlink`,r);let o=this.mkNode(`symlink`,511);o.target=e,i.children.set(a,o),i.mtimeMs=i.ctimeMs=now()}readlinkSync(e){let t=this.lookup(e,`readlink`);if(t.kind!==`symlink`)throw r(`readlink`,u(e));return t.target}realpathSync(e){let t=u(e);return this.lookup(t,`lstat`),t}chmodSync(e,t){let n=this.lookup(e,`chmod`);n.mode=n.mode&-4096|t&4095,n.ctimeMs=now()}chownSync(e,t,n){let r=this.lookup(e,`chown`);r.uid=t,r.gid=n,r.ctimeMs=now()}utimesSync(e,t,n){let r=this.lookup(e,`utimes`);r.atimeMs=t,r.mtimeMs=n,r.ctimeMs=now()}openSync(e,t,r=438){let a=u(e),o=t.includes(`w`)||t.includes(`a`)||t.includes(`x`),s=t===`w`||t===`w+`,c=t.includes(`x`),l;try{let e=this.lookup(a,`open`);if(e.kind!==`file`)throw i(`open`,a);if(c)throw n(`open`,a);l=e,s&&(l.data=p,l.mtimeMs=l.ctimeMs=now())}catch(e){if(e.code!==`ENOENT`||!o)throw e;let{parent:t,name:n}=this.lookupParent(a,`open`);l=this.mkNode(`file`,r),t.children.set(n,l),t.mtimeMs=t.ctimeMs=now()}let d=this.nextFd++;return this.fds.set(d,{node:l,path:a,position:t.includes(`a`)?l.data.byteLength:0,flags:t}),d}closeSync(e){if(!this.fds.delete(e))throw t(`close`)}readSync(e,n,r,i,a){let o=this.fds.get(e);if(!o)throw t(`read`);let s=a??o.position,c=o.node.data,l=Math.max(0,Math.min(s+i,c.byteLength)-s);return l>0&&n.set(c.subarray(s,s+l),r),a===null&&(o.position+=l),o.node.atimeMs=now(),l}writeSync(e,n,r,i,a){let o=this.fds.get(e);if(!o)throw t(`write`);let s=a??o.position,c=n.subarray(r,r+i),l=s+c.byteLength;if(l>o.node.data.byteLength){let e=new Uint8Array(l);e.set(o.node.data,0),o.node.data=e}return o.node.data.set(c,s),a===null&&(o.position=l),o.node.mtimeMs=o.node.ctimeMs=now(),c.byteLength}toJSON(){let e={},walk=(t,n)=>{t.children.size===0&&n!==`/`&&(e[n]=null);for(let[r,i]of t.children){let t=n===`/`?`/`+r:n+`/`+r;i.kind===`dir`?walk(i,t):i.kind===`file`?e[t]=new TextDecoder().decode(i.data):e[t]=`[symlink → ${i.target}]`}};return walk(this.root,`/`),e}fromJSON(e,t=`/`){for(let[n,r]of Object.entries(e)){let e=u(t,n);if(this.mkdirSync(c(e),{recursive:!0}),r===null)try{this.mkdirSync(e,{recursive:!0})}catch{}else{let t=typeof r==`string`?new TextEncoder().encode(r):r;this.writeFileSync(e,t)}}}reset(){this.root.children.clear(),this.fds.clear(),this.nextIno=2,this.nextFd=3}};const m=new Volume;function absolutise(e){if(typeof e==`string`)return u(l(e));if(e instanceof URL){if(e.protocol!==`file:`)throw TypeError(`unsupported URL scheme: ${e.protocol}`);return u(decodeURIComponent(e.pathname))}if(e&&typeof e.toString==`function`)return u(e.toString());throw TypeError(`path must be a string, Buffer, or URL`)}export{Volume,m as __defaultVolume,absolutise};
@@ -0,0 +1 @@
1
+ import{COPYFILE_EXCL as ee,COPYFILE_FICLONE as te,COPYFILE_FICLONE_FORCE as e,F_OK as t,O_APPEND as n,O_CREAT as r,O_DIRECTORY as i,O_EXCL as a,O_NOFOLLOW as ne,O_NONBLOCK as o,O_RDONLY as s,O_RDWR as c,O_SYNC as l,O_TRUNC as u,O_WRONLY as d,R_OK as f,S_IFBLK as p,S_IFCHR as m,S_IFDIR as h,S_IFIFO as g,S_IFLNK as _,S_IFMT as v,S_IFREG as y,S_IFSOCK as b,S_IRGRP as x,S_IROTH as S,S_IRUSR as C,S_IRWXG as w,S_IRWXO as T,S_IRWXU as E,S_IWGRP as D,S_IWOTH as O,S_IWUSR as k,S_IXGRP as A,S_IXOTH as j,S_IXUSR as M,W_OK as N,X_OK as P,constants as F}from"./browser/constants.js";import{BigIntStats as I,Dirent as L,Stats as R}from"./browser/types.js";import{Volume as z,__defaultVolume as B}from"./browser/volume.js";import{accessSync as V,appendFileSync as H,chmodSync as U,chownSync as W,closeSync as G,copyFileSync as K,existsSync as q,linkSync as J,lstatSync as Y,mkdirSync as X,mkdtempSync as Z,openSync as re,readFileSync as ie,readSync as ae,readdirSync as oe,readlinkSync as se,realpathSync as Q,renameSync as ce,rmSync as le,rmdirSync as ue,statSync as de,symlinkSync as fe,sync_exports as pe,truncateSync as me,unlinkSync as he,utimesSync as ge,writeFileSync as _e,writeSync as ve}from"./browser/sync.js";import{access as ye,appendFile as be,async_exports as xe,chmod as Se,chown as Ce,close as we,copyFile as Te,exists as Ee,link as De,lstat as Oe,mkdir as ke,mkdtemp as Ae,open as je,read as Me,readFile as Ne,readdir as Pe,readlink as Fe,realpath as Ie,rename as Le,rm as Re,rmdir as ze,stat as Be,symlink as Ve,truncate as He,unlink as Ue,utimes as We,write as Ge,writeFile as Ke}from"./browser/async.js";import{FSWatcher as qe,ReadStream as Je,StatWatcher as Ye,WriteStream as Xe,createReadStream as Ze,createWriteStream as Qe,stream_exports as $e,unwatchFile as et,watch as tt,watchFile as nt}from"./browser/stream.js";import{promises_exports as $}from"./browser/promises.js";const rt={constants:F,Volume:z,__defaultVolume:B,Stats:R,BigIntStats:I,Dirent:L,...pe,...xe,...$e,promises:$};export{I as BigIntStats,ee as COPYFILE_EXCL,te as COPYFILE_FICLONE,e as COPYFILE_FICLONE_FORCE,L as Dirent,qe as FSWatcher,t as F_OK,n as O_APPEND,r as O_CREAT,i as O_DIRECTORY,a as O_EXCL,ne as O_NOFOLLOW,o as O_NONBLOCK,s as O_RDONLY,c as O_RDWR,l as O_SYNC,u as O_TRUNC,d as O_WRONLY,f as R_OK,Je as ReadStream,p as S_IFBLK,m as S_IFCHR,h as S_IFDIR,g as S_IFIFO,_ as S_IFLNK,v as S_IFMT,y as S_IFREG,b as S_IFSOCK,x as S_IRGRP,S as S_IROTH,C as S_IRUSR,w as S_IRWXG,T as S_IRWXO,E as S_IRWXU,D as S_IWGRP,O as S_IWOTH,k as S_IWUSR,A as S_IXGRP,j as S_IXOTH,M as S_IXUSR,Ye as StatWatcher,R as Stats,z as Volume,N as W_OK,Xe as WriteStream,P as X_OK,B as __defaultVolume,ye as access,V as accessSync,be as appendFile,H as appendFileSync,Se as chmod,U as chmodSync,Ce as chown,W as chownSync,we as close,G as closeSync,F as constants,Te as copyFile,K as copyFileSync,Ze as createReadStream,Qe as createWriteStream,rt as default,Ee as exists,q as existsSync,De as link,J as linkSync,Oe as lstat,Y as lstatSync,ke as mkdir,X as mkdirSync,Ae as mkdtemp,Z as mkdtempSync,je as open,re as openSync,$ as promises,Me as read,Ne as readFile,ie as readFileSync,ae as readSync,Pe as readdir,oe as readdirSync,Fe as readlink,se as readlinkSync,Ie as realpath,Q as realpathSync,Le as rename,ce as renameSync,Re as rm,le as rmSync,ze as rmdir,ue as rmdirSync,Be as stat,de as statSync,Ve as symlink,fe as symlinkSync,He as truncate,me as truncateSync,Ue as unlink,he as unlinkSync,et as unwatchFile,We as utimes,ge as utimesSync,tt as watch,nt as watchFile,Ge as write,Ke as writeFile,_e as writeFileSync,ve as writeSync};
@@ -0,0 +1,31 @@
1
+ import * as sync from './sync.js';
2
+ import type { Stats, BigIntStats, Dirent } from './types.js';
3
+ type ErrCb<T = void> = (err: NodeJS.ErrnoException | null, value?: T) => void;
4
+ export declare function readFile(path: Parameters<typeof sync.readFileSync>[0], optsOrCb: Parameters<typeof sync.readFileSync>[1] | ErrCb<string | Uint8Array>, maybeCb?: ErrCb<string | Uint8Array>): void;
5
+ export declare function writeFile(path: Parameters<typeof sync.writeFileSync>[0], data: Parameters<typeof sync.writeFileSync>[1], optsOrCb: Parameters<typeof sync.writeFileSync>[2] | ErrCb, maybeCb?: ErrCb): void;
6
+ export declare function appendFile(path: Parameters<typeof sync.appendFileSync>[0], data: Parameters<typeof sync.appendFileSync>[1], optsOrCb: Parameters<typeof sync.appendFileSync>[2] | ErrCb, maybeCb?: ErrCb): void;
7
+ export declare function stat(path: Parameters<typeof sync.statSync>[0], cb?: ErrCb<Stats | BigIntStats | undefined>): void;
8
+ export declare function lstat(path: Parameters<typeof sync.lstatSync>[0], cb?: ErrCb<Stats | BigIntStats | undefined>): void;
9
+ export declare function exists(path: Parameters<typeof sync.existsSync>[0], cb?: (exists: boolean) => void): void;
10
+ export declare function access(path: Parameters<typeof sync.accessSync>[0], modeOrCb?: number | ErrCb, maybeCb?: ErrCb): void;
11
+ export declare function readdir(path: Parameters<typeof sync.readdirSync>[0], optsOrCb: Parameters<typeof sync.readdirSync>[1] | ErrCb<string[] | Dirent[]>, maybeCb?: ErrCb<string[] | Dirent[]>): void;
12
+ export declare function mkdir(path: Parameters<typeof sync.mkdirSync>[0], optsOrCb: Parameters<typeof sync.mkdirSync>[1] | ErrCb<string | undefined>, maybeCb?: ErrCb<string | undefined>): void;
13
+ export declare function rmdir(path: Parameters<typeof sync.rmdirSync>[0], optsOrCb: Parameters<typeof sync.rmdirSync>[1] | ErrCb, maybeCb?: ErrCb): void;
14
+ export declare function rm(path: Parameters<typeof sync.rmSync>[0], optsOrCb: Parameters<typeof sync.rmSync>[1] | ErrCb, maybeCb?: ErrCb): void;
15
+ export declare function unlink(path: Parameters<typeof sync.unlinkSync>[0], cb?: ErrCb): void;
16
+ export declare function rename(oldPath: Parameters<typeof sync.renameSync>[0], newPath: Parameters<typeof sync.renameSync>[1], cb?: ErrCb): void;
17
+ export declare function copyFile(src: Parameters<typeof sync.copyFileSync>[0], dest: Parameters<typeof sync.copyFileSync>[1], flagsOrCb: number | ErrCb, maybeCb?: ErrCb): void;
18
+ export declare function link(existingPath: Parameters<typeof sync.linkSync>[0], newPath: Parameters<typeof sync.linkSync>[1], cb?: ErrCb): void;
19
+ export declare function symlink(target: Parameters<typeof sync.symlinkSync>[0], linkPath: Parameters<typeof sync.symlinkSync>[1], typeOrCb?: string | ErrCb, maybeCb?: ErrCb): void;
20
+ export declare function readlink(path: Parameters<typeof sync.readlinkSync>[0], cb?: ErrCb<string>): void;
21
+ export declare function realpath(path: Parameters<typeof sync.realpathSync>[0], cb?: ErrCb<string>): void;
22
+ export declare function chmod(path: Parameters<typeof sync.chmodSync>[0], mode: number, cb?: ErrCb): void;
23
+ export declare function chown(path: Parameters<typeof sync.chownSync>[0], uid: number, gid: number, cb?: ErrCb): void;
24
+ export declare function truncate(path: Parameters<typeof sync.truncateSync>[0], lenOrCb?: number | ErrCb, maybeCb?: ErrCb): void;
25
+ export declare function utimes(path: Parameters<typeof sync.utimesSync>[0], atime: number | Date, mtime: number | Date, cb?: ErrCb): void;
26
+ export declare function mkdtemp(prefix: string, cb?: ErrCb<string>): void;
27
+ export declare function open(path: Parameters<typeof sync.openSync>[0], flagsOrCb?: string | ErrCb<number>, modeOrCb?: number | ErrCb<number>, maybeCb?: ErrCb<number>): void;
28
+ export declare function close(fd: number, cb?: ErrCb): void;
29
+ export declare function read(fd: number, buf: Uint8Array, offset: number, length: number, position: number | null, cb?: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: Uint8Array) => void): void;
30
+ export declare function write(fd: number, buf: Uint8Array | string, offsetOrCb?: number | ErrCb<number>, lengthOrEnc?: number | string, positionOrCb?: number | null | ErrCb<number>, maybeCb?: ErrCb<number>): void;
31
+ export {};
@@ -0,0 +1,78 @@
1
+ export declare const F_OK = 0;
2
+ export declare const R_OK = 4;
3
+ export declare const W_OK = 2;
4
+ export declare const X_OK = 1;
5
+ export declare const COPYFILE_EXCL = 1;
6
+ export declare const COPYFILE_FICLONE = 2;
7
+ export declare const COPYFILE_FICLONE_FORCE = 4;
8
+ export declare const O_RDONLY = 0;
9
+ export declare const O_WRONLY = 1;
10
+ export declare const O_RDWR = 2;
11
+ export declare const O_CREAT = 64;
12
+ export declare const O_EXCL = 128;
13
+ export declare const O_TRUNC = 512;
14
+ export declare const O_APPEND = 1024;
15
+ export declare const O_SYNC = 1052672;
16
+ export declare const O_NONBLOCK = 2048;
17
+ export declare const O_DIRECTORY = 65536;
18
+ export declare const O_NOFOLLOW = 131072;
19
+ export declare const S_IFMT = 61440;
20
+ export declare const S_IFREG = 32768;
21
+ export declare const S_IFDIR = 16384;
22
+ export declare const S_IFCHR = 8192;
23
+ export declare const S_IFBLK = 24576;
24
+ export declare const S_IFIFO = 4096;
25
+ export declare const S_IFLNK = 40960;
26
+ export declare const S_IFSOCK = 49152;
27
+ export declare const S_IRWXU = 448;
28
+ export declare const S_IRUSR = 256;
29
+ export declare const S_IWUSR = 128;
30
+ export declare const S_IXUSR = 64;
31
+ export declare const S_IRWXG = 56;
32
+ export declare const S_IRGRP = 32;
33
+ export declare const S_IWGRP = 16;
34
+ export declare const S_IXGRP = 8;
35
+ export declare const S_IRWXO = 7;
36
+ export declare const S_IROTH = 4;
37
+ export declare const S_IWOTH = 2;
38
+ export declare const S_IXOTH = 1;
39
+ export declare const constants: {
40
+ F_OK: number;
41
+ R_OK: number;
42
+ W_OK: number;
43
+ X_OK: number;
44
+ COPYFILE_EXCL: number;
45
+ COPYFILE_FICLONE: number;
46
+ COPYFILE_FICLONE_FORCE: number;
47
+ O_RDONLY: number;
48
+ O_WRONLY: number;
49
+ O_RDWR: number;
50
+ O_CREAT: number;
51
+ O_EXCL: number;
52
+ O_TRUNC: number;
53
+ O_APPEND: number;
54
+ O_SYNC: number;
55
+ O_NONBLOCK: number;
56
+ O_DIRECTORY: number;
57
+ O_NOFOLLOW: number;
58
+ S_IFMT: number;
59
+ S_IFREG: number;
60
+ S_IFDIR: number;
61
+ S_IFCHR: number;
62
+ S_IFBLK: number;
63
+ S_IFIFO: number;
64
+ S_IFLNK: number;
65
+ S_IFSOCK: number;
66
+ S_IRWXU: number;
67
+ S_IRUSR: number;
68
+ S_IWUSR: number;
69
+ S_IXUSR: number;
70
+ S_IRWXG: number;
71
+ S_IRGRP: number;
72
+ S_IWGRP: number;
73
+ S_IXGRP: number;
74
+ S_IRWXO: number;
75
+ S_IROTH: number;
76
+ S_IWOTH: number;
77
+ S_IXOTH: number;
78
+ };
@@ -0,0 +1,72 @@
1
+ export type ErrnoCode = 'ENOENT' | 'EEXIST' | 'EISDIR' | 'ENOTDIR' | 'EACCES' | 'EBADF' | 'EINVAL' | 'ENOTEMPTY' | 'ENOSYS' | 'ENOTSUP' | 'EPERM';
2
+ /** Construct a Node-shaped errno error. */
3
+ export declare function createError(code: ErrnoCode, syscall: string, path?: string, dest?: string): Error & {
4
+ code: ErrnoCode;
5
+ errno: number;
6
+ syscall: string;
7
+ path?: string;
8
+ dest?: string;
9
+ };
10
+ export declare const ENOENT: (syscall: string, path?: string) => Error & {
11
+ code: ErrnoCode;
12
+ errno: number;
13
+ syscall: string;
14
+ path?: string;
15
+ dest?: string;
16
+ };
17
+ export declare const EEXIST: (syscall: string, path?: string) => Error & {
18
+ code: ErrnoCode;
19
+ errno: number;
20
+ syscall: string;
21
+ path?: string;
22
+ dest?: string;
23
+ };
24
+ export declare const EISDIR: (syscall: string, path?: string) => Error & {
25
+ code: ErrnoCode;
26
+ errno: number;
27
+ syscall: string;
28
+ path?: string;
29
+ dest?: string;
30
+ };
31
+ export declare const ENOTDIR: (syscall: string, path?: string) => Error & {
32
+ code: ErrnoCode;
33
+ errno: number;
34
+ syscall: string;
35
+ path?: string;
36
+ dest?: string;
37
+ };
38
+ export declare const EACCES: (syscall: string, path?: string) => Error & {
39
+ code: ErrnoCode;
40
+ errno: number;
41
+ syscall: string;
42
+ path?: string;
43
+ dest?: string;
44
+ };
45
+ export declare const EBADF: (syscall: string) => Error & {
46
+ code: ErrnoCode;
47
+ errno: number;
48
+ syscall: string;
49
+ path?: string;
50
+ dest?: string;
51
+ };
52
+ export declare const EINVAL: (syscall: string, path?: string) => Error & {
53
+ code: ErrnoCode;
54
+ errno: number;
55
+ syscall: string;
56
+ path?: string;
57
+ dest?: string;
58
+ };
59
+ export declare const ENOTEMPTY: (syscall: string, path?: string) => Error & {
60
+ code: ErrnoCode;
61
+ errno: number;
62
+ syscall: string;
63
+ path?: string;
64
+ dest?: string;
65
+ };
66
+ export declare const ENOTSUP: (syscall: string, path?: string) => Error & {
67
+ code: ErrnoCode;
68
+ errno: number;
69
+ syscall: string;
70
+ path?: string;
71
+ dest?: string;
72
+ };
@@ -0,0 +1,10 @@
1
+ /** Normalise a POSIX path: collapse repeated slashes, resolve `.` / `..`. */
2
+ export declare function normalize(p: string): string;
3
+ /** Resolve into an absolute path. */
4
+ export declare function resolve(...segments: string[]): string;
5
+ export declare function dirname(p: string): string;
6
+ export declare function basename(p: string, ext?: string): string;
7
+ /** Coerce a Node `PathLike` (string | Buffer | URL) to a POSIX path string. */
8
+ export declare function toPath(p: unknown): string;
9
+ /** Split a POSIX path into its components (no leading empty for absolutes). */
10
+ export declare function split(p: string): string[];
@@ -0,0 +1,90 @@
1
+ export { readFile, writeFile, appendFile, stat, lstat, access, readdir, mkdir, rmdir, rm, unlink, rename, copyFile, link, symlink, readlink, realpath, chmod, chown, truncate, utimes, mkdtemp, open, FileHandle, } from './promises.js';
2
+ import { open, FileHandle } from './promises.js';
3
+ export { constants } from './constants.js';
4
+ declare const _default: {
5
+ readFile: (path: string | URL | {
6
+ toString(): string;
7
+ }, opts?: ("utf8" | "utf-8" | "ascii" | "binary" | "base64" | "hex") | import("./sync.js").ReadFileOpts) => Promise<string | Uint8Array<ArrayBufferLike>>;
8
+ writeFile: (path: string | URL | {
9
+ toString(): string;
10
+ }, data: string | (Uint8Array<ArrayBufferLike> | {
11
+ buffer: ArrayBufferLike;
12
+ byteOffset?: number;
13
+ byteLength?: number;
14
+ }), opts?: ("utf8" | "utf-8" | "ascii" | "binary" | "base64" | "hex") | import("./sync.js").WriteFileOpts) => Promise<void>;
15
+ appendFile: (path: string | URL | {
16
+ toString(): string;
17
+ }, data: string | (Uint8Array<ArrayBufferLike> | {
18
+ buffer: ArrayBufferLike;
19
+ byteOffset?: number;
20
+ byteLength?: number;
21
+ }), opts?: ("utf8" | "utf-8" | "ascii" | "binary" | "base64" | "hex") | import("./sync.js").WriteFileOpts) => Promise<void>;
22
+ stat: (path: string | URL | {
23
+ toString(): string;
24
+ }, opts?: import("./sync.js").StatOpts) => Promise<import("./types.js").Stats | import("./types.js").BigIntStats>;
25
+ lstat: (path: string | URL | {
26
+ toString(): string;
27
+ }, opts?: import("./sync.js").StatOpts) => Promise<import("./types.js").Stats | import("./types.js").BigIntStats>;
28
+ access: (path: string | URL | {
29
+ toString(): string;
30
+ }, mode?: number) => Promise<void>;
31
+ readdir: (path: string | URL | {
32
+ toString(): string;
33
+ }, opts?: import("./sync.js").ReadDirOpts) => Promise<string[] | import("./types.js").Dirent[]>;
34
+ mkdir: (path: string | URL | {
35
+ toString(): string;
36
+ }, opts?: number | import("./sync.js").MkdirOpts) => Promise<string>;
37
+ rmdir: (path: string | URL | {
38
+ toString(): string;
39
+ }, opts?: {
40
+ recursive?: boolean;
41
+ }) => Promise<void>;
42
+ rm: (path: string | URL | {
43
+ toString(): string;
44
+ }, opts?: import("./sync.js").RmOpts) => Promise<void>;
45
+ unlink: (path: string | URL | {
46
+ toString(): string;
47
+ }) => Promise<void>;
48
+ rename: (oldPath: string | URL | {
49
+ toString(): string;
50
+ }, newPath: string | URL | {
51
+ toString(): string;
52
+ }) => Promise<void>;
53
+ copyFile: (src: string | URL | {
54
+ toString(): string;
55
+ }, dest: string | URL | {
56
+ toString(): string;
57
+ }, flags?: number) => Promise<void>;
58
+ link: (existingPath: string | URL | {
59
+ toString(): string;
60
+ }, newPath: string | URL | {
61
+ toString(): string;
62
+ }) => Promise<void>;
63
+ symlink: (target: string | URL | {
64
+ toString(): string;
65
+ }, linkPath: string | URL | {
66
+ toString(): string;
67
+ }) => Promise<void>;
68
+ readlink: (path: string | URL | {
69
+ toString(): string;
70
+ }) => Promise<string>;
71
+ realpath: (path: string | URL | {
72
+ toString(): string;
73
+ }) => Promise<string>;
74
+ chmod: (path: string | URL | {
75
+ toString(): string;
76
+ }, mode: number) => Promise<void>;
77
+ chown: (path: string | URL | {
78
+ toString(): string;
79
+ }, uid: number, gid: number) => Promise<void>;
80
+ truncate: (path: string | URL | {
81
+ toString(): string;
82
+ }, len?: number) => Promise<void>;
83
+ utimes: (path: string | URL | {
84
+ toString(): string;
85
+ }, atime: number | Date, mtime: number | Date) => Promise<void>;
86
+ mkdtemp: (prefix: string) => Promise<string>;
87
+ open: typeof open;
88
+ FileHandle: typeof FileHandle;
89
+ };
90
+ export default _default;
@@ -0,0 +1,98 @@
1
+ import * as sync from './sync.js';
2
+ export declare const readFile: (path: string | URL | {
3
+ toString(): string;
4
+ }, opts?: ("utf8" | "utf-8" | "ascii" | "binary" | "base64" | "hex") | sync.ReadFileOpts) => Promise<string | Uint8Array<ArrayBufferLike>>;
5
+ export declare const writeFile: (path: string | URL | {
6
+ toString(): string;
7
+ }, data: string | (Uint8Array<ArrayBufferLike> | {
8
+ buffer: ArrayBufferLike;
9
+ byteOffset?: number;
10
+ byteLength?: number;
11
+ }), opts?: ("utf8" | "utf-8" | "ascii" | "binary" | "base64" | "hex") | sync.WriteFileOpts) => Promise<void>;
12
+ export declare const appendFile: (path: string | URL | {
13
+ toString(): string;
14
+ }, data: string | (Uint8Array<ArrayBufferLike> | {
15
+ buffer: ArrayBufferLike;
16
+ byteOffset?: number;
17
+ byteLength?: number;
18
+ }), opts?: ("utf8" | "utf-8" | "ascii" | "binary" | "base64" | "hex") | sync.WriteFileOpts) => Promise<void>;
19
+ export declare const stat: (path: string | URL | {
20
+ toString(): string;
21
+ }, opts?: sync.StatOpts) => Promise<import("./types.js").Stats | import("./types.js").BigIntStats>;
22
+ export declare const lstat: (path: string | URL | {
23
+ toString(): string;
24
+ }, opts?: sync.StatOpts) => Promise<import("./types.js").Stats | import("./types.js").BigIntStats>;
25
+ export declare const access: (path: string | URL | {
26
+ toString(): string;
27
+ }, mode?: number) => Promise<void>;
28
+ export declare const readdir: (path: string | URL | {
29
+ toString(): string;
30
+ }, opts?: sync.ReadDirOpts) => Promise<string[] | import("./types.js").Dirent[]>;
31
+ export declare const mkdir: (path: string | URL | {
32
+ toString(): string;
33
+ }, opts?: number | sync.MkdirOpts) => Promise<string>;
34
+ export declare const rmdir: (path: string | URL | {
35
+ toString(): string;
36
+ }, opts?: {
37
+ recursive?: boolean;
38
+ }) => Promise<void>;
39
+ export declare const rm: (path: string | URL | {
40
+ toString(): string;
41
+ }, opts?: sync.RmOpts) => Promise<void>;
42
+ export declare const unlink: (path: string | URL | {
43
+ toString(): string;
44
+ }) => Promise<void>;
45
+ export declare const rename: (oldPath: string | URL | {
46
+ toString(): string;
47
+ }, newPath: string | URL | {
48
+ toString(): string;
49
+ }) => Promise<void>;
50
+ export declare const copyFile: (src: string | URL | {
51
+ toString(): string;
52
+ }, dest: string | URL | {
53
+ toString(): string;
54
+ }, flags?: number) => Promise<void>;
55
+ export declare const link: (existingPath: string | URL | {
56
+ toString(): string;
57
+ }, newPath: string | URL | {
58
+ toString(): string;
59
+ }) => Promise<void>;
60
+ export declare const symlink: (target: string | URL | {
61
+ toString(): string;
62
+ }, linkPath: string | URL | {
63
+ toString(): string;
64
+ }) => Promise<void>;
65
+ export declare const readlink: (path: string | URL | {
66
+ toString(): string;
67
+ }) => Promise<string>;
68
+ export declare const realpath: (path: string | URL | {
69
+ toString(): string;
70
+ }) => Promise<string>;
71
+ export declare const chmod: (path: string | URL | {
72
+ toString(): string;
73
+ }, mode: number) => Promise<void>;
74
+ export declare const chown: (path: string | URL | {
75
+ toString(): string;
76
+ }, uid: number, gid: number) => Promise<void>;
77
+ export declare const truncate: (path: string | URL | {
78
+ toString(): string;
79
+ }, len?: number) => Promise<void>;
80
+ export declare const utimes: (path: string | URL | {
81
+ toString(): string;
82
+ }, atime: number | Date, mtime: number | Date) => Promise<void>;
83
+ export declare const mkdtemp: (prefix: string) => Promise<string>;
84
+ export declare class FileHandle {
85
+ readonly fd: number;
86
+ constructor(fd: number);
87
+ read(buf: Uint8Array, offset?: number, length?: number, position?: number | null): Promise<{
88
+ bytesRead: number;
89
+ buffer: Uint8Array;
90
+ }>;
91
+ write(buf: Uint8Array | string, offset?: number, length?: number, position?: number | null): Promise<{
92
+ bytesWritten: number;
93
+ buffer: Uint8Array | string;
94
+ }>;
95
+ readFile(): Promise<Uint8Array>;
96
+ close(): Promise<void>;
97
+ }
98
+ export declare function open(path: Parameters<typeof sync.openSync>[0], flags?: string, mode?: number): Promise<FileHandle>;
@@ -0,0 +1,75 @@
1
+ export interface ReadOpts {
2
+ encoding?: string;
3
+ start?: number;
4
+ end?: number;
5
+ highWaterMark?: number;
6
+ flags?: string;
7
+ }
8
+ export interface WriteOpts {
9
+ encoding?: string;
10
+ mode?: number;
11
+ flags?: string;
12
+ }
13
+ declare class EventBus {
14
+ private listeners;
15
+ on(event: string, fn: (...args: unknown[]) => void): this;
16
+ once(event: string, fn: (...args: unknown[]) => void): this;
17
+ off(event: string, fn: (...args: unknown[]) => void): this;
18
+ emit(event: string, ...args: unknown[]): boolean;
19
+ removeAllListeners(event?: string): this;
20
+ }
21
+ export declare class ReadStream extends EventBus {
22
+ readonly path: string;
23
+ private destroyed;
24
+ private buffer;
25
+ private position;
26
+ private end;
27
+ private chunkSize;
28
+ private encoding?;
29
+ constructor(path: string | URL, opts?: ReadOpts);
30
+ private _pump;
31
+ pipe<W extends {
32
+ write(chunk: Uint8Array): boolean | unknown;
33
+ end?: () => void;
34
+ }>(dest: W): W;
35
+ destroy(err?: Error): void;
36
+ [Symbol.asyncIterator](): AsyncIterableIterator<Uint8Array | string>;
37
+ get bytesRead(): number;
38
+ }
39
+ export declare function createReadStream(path: string | URL, opts?: ReadOpts): ReadStream;
40
+ export declare class WriteStream extends EventBus {
41
+ readonly path: string;
42
+ private destroyed;
43
+ private parts;
44
+ private ended;
45
+ private flags;
46
+ private mode;
47
+ private encoding?;
48
+ bytesWritten: number;
49
+ constructor(path: string | URL, opts?: WriteOpts);
50
+ write(chunk: Uint8Array | string, encOrCb?: string | ((err: Error | null) => void), maybeCb?: (err: Error | null) => void): boolean;
51
+ end(chunk?: Uint8Array | string, cb?: () => void): void;
52
+ destroy(err?: Error): void;
53
+ }
54
+ export declare function createWriteStream(path: string | URL, opts?: WriteOpts): WriteStream;
55
+ export declare class FSWatcher extends EventBus {
56
+ readonly path: string;
57
+ private closed;
58
+ constructor(path: string | URL);
59
+ close(): void;
60
+ ref(): this;
61
+ unref(): this;
62
+ }
63
+ export declare function watch(path: string | URL, _opts?: {
64
+ persistent?: boolean;
65
+ recursive?: boolean;
66
+ encoding?: string;
67
+ }, _listener?: (eventType: string, filename: string | null) => void): FSWatcher;
68
+ export declare class StatWatcher extends EventBus {
69
+ close(): void;
70
+ ref(): this;
71
+ unref(): this;
72
+ }
73
+ export declare function watchFile(_path: string | URL): StatWatcher;
74
+ export declare function unwatchFile(_path: string | URL): void;
75
+ export {};
@@ -0,0 +1,68 @@
1
+ import { BigIntStats, Dirent, Stats } from './types.js';
2
+ type PathLike = string | URL | {
3
+ toString(): string;
4
+ };
5
+ type BufferLike = Uint8Array | {
6
+ buffer: ArrayBufferLike;
7
+ byteOffset?: number;
8
+ byteLength?: number;
9
+ };
10
+ type Encoding = 'utf8' | 'utf-8' | 'ascii' | 'binary' | 'base64' | 'hex' | null;
11
+ export interface ReadFileOpts {
12
+ encoding?: Encoding;
13
+ flag?: string;
14
+ }
15
+ export interface WriteFileOpts {
16
+ encoding?: Encoding;
17
+ mode?: number;
18
+ flag?: string;
19
+ }
20
+ export interface MkdirOpts {
21
+ recursive?: boolean;
22
+ mode?: number;
23
+ }
24
+ export interface RmOpts {
25
+ recursive?: boolean;
26
+ force?: boolean;
27
+ maxRetries?: number;
28
+ retryDelay?: number;
29
+ }
30
+ export interface StatOpts {
31
+ bigint?: boolean;
32
+ throwIfNoEntry?: boolean;
33
+ }
34
+ export declare function readFileSync(path: PathLike, opts?: Encoding | ReadFileOpts): string | Uint8Array;
35
+ export declare function writeFileSync(path: PathLike, data: string | BufferLike, opts?: Encoding | WriteFileOpts): void;
36
+ export declare function appendFileSync(path: PathLike, data: string | BufferLike, opts?: Encoding | WriteFileOpts): void;
37
+ export declare function statSync(path: PathLike, opts?: StatOpts): Stats | BigIntStats | undefined;
38
+ export declare function lstatSync(path: PathLike, opts?: StatOpts): Stats | BigIntStats | undefined;
39
+ export declare function existsSync(path: PathLike): boolean;
40
+ export declare function accessSync(path: PathLike, mode?: number): void;
41
+ export interface ReadDirOpts {
42
+ withFileTypes?: boolean;
43
+ recursive?: boolean;
44
+ encoding?: string;
45
+ }
46
+ export declare function readdirSync(path: PathLike, opts?: ReadDirOpts): string[] | Dirent[];
47
+ export declare function mkdirSync(path: PathLike, opts?: MkdirOpts | number): string | undefined;
48
+ export declare function rmdirSync(path: PathLike, opts?: {
49
+ recursive?: boolean;
50
+ }): void;
51
+ export declare function rmSync(path: PathLike, opts?: RmOpts): void;
52
+ export declare function unlinkSync(path: PathLike): void;
53
+ export declare function renameSync(oldPath: PathLike, newPath: PathLike): void;
54
+ export declare function copyFileSync(src: PathLike, dest: PathLike, flags?: number): void;
55
+ export declare function linkSync(existingPath: PathLike, newPath: PathLike): void;
56
+ export declare function symlinkSync(target: PathLike, linkPath: PathLike): void;
57
+ export declare function readlinkSync(path: PathLike): string;
58
+ export declare function realpathSync(path: PathLike): string;
59
+ export declare function chmodSync(path: PathLike, mode: number): void;
60
+ export declare function chownSync(path: PathLike, uid: number, gid: number): void;
61
+ export declare function truncateSync(path: PathLike, len?: number): void;
62
+ export declare function utimesSync(path: PathLike, atime: number | Date, mtime: number | Date): void;
63
+ export declare function mkdtempSync(prefix: string): string;
64
+ export declare function openSync(path: PathLike, flags?: string, mode?: number): number;
65
+ export declare function closeSync(fd: number): void;
66
+ export declare function readSync(fd: number, buf: Uint8Array, offset: number, length: number, position: number | null): number;
67
+ export declare function writeSync(fd: number, buf: Uint8Array | string, offsetOrPos?: number | null, lengthOrEnc?: number | string, position?: number | null): number;
68
+ export {};
@@ -0,0 +1,87 @@
1
+ export type NodeKind = 'file' | 'dir' | 'symlink';
2
+ export interface StatFields {
3
+ kind: NodeKind;
4
+ size: number;
5
+ mode: number;
6
+ atimeMs: number;
7
+ mtimeMs: number;
8
+ ctimeMs: number;
9
+ birthtimeMs: number;
10
+ uid: number;
11
+ gid: number;
12
+ ino: number;
13
+ nlink: number;
14
+ }
15
+ /** Shared `is*` mixin used by `Stats`, `BigIntStats`, and `Dirent`. */
16
+ declare abstract class KindTests {
17
+ protected abstract _kind(): NodeKind;
18
+ isFile(): boolean;
19
+ isDirectory(): boolean;
20
+ isSymbolicLink(): boolean;
21
+ isBlockDevice(): boolean;
22
+ isCharacterDevice(): boolean;
23
+ isFIFO(): boolean;
24
+ isSocket(): boolean;
25
+ }
26
+ export declare class Stats extends KindTests {
27
+ kind: NodeKind;
28
+ dev: number;
29
+ ino: number;
30
+ mode: number;
31
+ nlink: number;
32
+ uid: number;
33
+ gid: number;
34
+ rdev: number;
35
+ size: number;
36
+ blksize: number;
37
+ blocks: number;
38
+ atimeMs: number;
39
+ mtimeMs: number;
40
+ ctimeMs: number;
41
+ birthtimeMs: number;
42
+ atime: Date;
43
+ mtime: Date;
44
+ ctime: Date;
45
+ birthtime: Date;
46
+ constructor(f: StatFields);
47
+ protected _kind(): NodeKind;
48
+ }
49
+ export declare class BigIntStats extends KindTests {
50
+ kind: NodeKind;
51
+ dev: bigint;
52
+ ino: bigint;
53
+ mode: bigint;
54
+ nlink: bigint;
55
+ uid: bigint;
56
+ gid: bigint;
57
+ rdev: bigint;
58
+ size: bigint;
59
+ blksize: bigint;
60
+ blocks: bigint;
61
+ atimeMs: bigint;
62
+ mtimeMs: bigint;
63
+ ctimeMs: bigint;
64
+ birthtimeMs: bigint;
65
+ atimeNs: bigint;
66
+ mtimeNs: bigint;
67
+ ctimeNs: bigint;
68
+ birthtimeNs: bigint;
69
+ atime: Date;
70
+ mtime: Date;
71
+ ctime: Date;
72
+ birthtime: Date;
73
+ constructor(f: StatFields);
74
+ protected _kind(): NodeKind;
75
+ }
76
+ export declare class Dirent extends KindTests {
77
+ name: string;
78
+ parentPath: string;
79
+ /** @deprecated mirrors Node — duplicate of `parentPath`. */
80
+ path: string;
81
+ private kind;
82
+ constructor(name: string, kind: NodeKind, parentPath: string);
83
+ protected _kind(): NodeKind;
84
+ }
85
+ /** mode bits for a `kind`, OR'd with the user-supplied permission bits. */
86
+ export declare function modeFor(kind: NodeKind, perm: number): number;
87
+ export {};
@@ -0,0 +1,61 @@
1
+ import { type NodeKind, type StatFields } from './types.js';
2
+ /** Single in-memory volume — exported so test code can build isolated instances. */
3
+ export declare class Volume {
4
+ private root;
5
+ private nextIno;
6
+ private fds;
7
+ private nextFd;
8
+ constructor();
9
+ private mkBase;
10
+ private mkNode;
11
+ private lookup;
12
+ private lookupParent;
13
+ existsSync(path: string): boolean;
14
+ statSync(path: string): StatFields;
15
+ lstatSync(path: string): StatFields;
16
+ accessSync(path: string, _mode: number): void;
17
+ readFileSync(path: string): Uint8Array;
18
+ writeFileSync(path: string, data: Uint8Array, mode?: number): void;
19
+ appendFileSync(path: string, data: Uint8Array, mode?: number): void;
20
+ truncateSync(path: string, len?: number): void;
21
+ readdirSync(path: string): string[];
22
+ readdirEntriesSync(path: string): Array<{
23
+ name: string;
24
+ kind: NodeKind;
25
+ }>;
26
+ mkdirSync(path: string, opts?: {
27
+ recursive?: boolean;
28
+ mode?: number;
29
+ }): string | undefined;
30
+ rmdirSync(path: string, opts?: {
31
+ recursive?: boolean;
32
+ }): void;
33
+ unlinkSync(path: string): void;
34
+ rmSync(path: string, opts?: {
35
+ recursive?: boolean;
36
+ force?: boolean;
37
+ }): void;
38
+ renameSync(oldPath: string, newPath: string): void;
39
+ copyFileSync(src: string, dest: string, flags?: number): void;
40
+ linkSync(existingPath: string, newPath: string): void;
41
+ symlinkSync(target: string, linkPath: string): void;
42
+ readlinkSync(path: string): string;
43
+ realpathSync(path: string): string;
44
+ chmodSync(path: string, mode: number): void;
45
+ chownSync(path: string, uid: number, gid: number): void;
46
+ utimesSync(path: string, atime: number, mtime: number): void;
47
+ openSync(path: string, flags: string, mode?: number): number;
48
+ closeSync(fd: number): void;
49
+ readSync(fd: number, buf: Uint8Array, offset: number, length: number, position: number | null): number;
50
+ writeSync(fd: number, buf: Uint8Array, offset: number, length: number, position: number | null): number;
51
+ /** Snapshot the volume as a memfs-shaped `DirectoryJSON`. */
52
+ toJSON(): Record<string, string | null>;
53
+ /** Seed the volume from a flat `path -> content` map (memfs parity). */
54
+ fromJSON(json: Record<string, string | Uint8Array | null>, cwd?: string): void;
55
+ /** Wipe all state. */
56
+ reset(): void;
57
+ }
58
+ /** The process-wide default volume. */
59
+ export declare const __defaultVolume: Volume;
60
+ /** Normalise an input path (string | Buffer | URL) plus apply `resolve`. */
61
+ export declare function absolutise(p: unknown): string;
@@ -0,0 +1,193 @@
1
+ export { constants } from './browser/constants.js';
2
+ export * from './browser/constants.js';
3
+ export { Volume, __defaultVolume } from './browser/volume.js';
4
+ export { Stats, BigIntStats, Dirent } from './browser/types.js';
5
+ export * from './browser/sync.js';
6
+ export * from './browser/async.js';
7
+ export { createReadStream, ReadStream, createWriteStream, WriteStream, FSWatcher, StatWatcher, watch, watchFile, unwatchFile, } from './browser/stream.js';
8
+ import * as promises from './browser/promises.js';
9
+ export { promises };
10
+ import * as syncApi from './browser/sync.js';
11
+ import * as streamApi from './browser/stream.js';
12
+ import { Volume as VolumeCls } from './browser/volume.js';
13
+ import { Stats as StatsCls, BigIntStats as BigIntStatsCls, Dirent as DirentCls } from './browser/types.js';
14
+ declare const defaultExport: {
15
+ promises: typeof promises;
16
+ createReadStream(path: string | URL, opts?: streamApi.ReadOpts): streamApi.ReadStream;
17
+ createWriteStream(path: string | URL, opts?: streamApi.WriteOpts): streamApi.WriteStream;
18
+ watch(path: string | URL, _opts?: {
19
+ persistent?: boolean;
20
+ recursive?: boolean;
21
+ encoding?: string;
22
+ }, _listener?: (eventType: string, filename: string | null) => void): streamApi.FSWatcher;
23
+ watchFile(_path: string | URL): streamApi.StatWatcher;
24
+ unwatchFile(_path: string | URL): void;
25
+ ReadStream: typeof streamApi.ReadStream;
26
+ WriteStream: typeof streamApi.WriteStream;
27
+ FSWatcher: typeof streamApi.FSWatcher;
28
+ StatWatcher: typeof streamApi.StatWatcher;
29
+ readFile(path: Parameters<typeof syncApi.readFileSync>[0], optsOrCb: Parameters<typeof syncApi.readFileSync>[1] | ((err: NodeJS.ErrnoException | null, value?: string | Uint8Array<ArrayBufferLike>) => void), maybeCb?: (err: NodeJS.ErrnoException | null, value?: string | Uint8Array<ArrayBufferLike>) => void): void;
30
+ writeFile(path: Parameters<typeof syncApi.writeFileSync>[0], data: Parameters<typeof syncApi.writeFileSync>[1], optsOrCb: Parameters<typeof syncApi.writeFileSync>[2] | ((err: NodeJS.ErrnoException | null, value?: void) => void), maybeCb?: (err: NodeJS.ErrnoException | null, value?: void) => void): void;
31
+ appendFile(path: Parameters<typeof syncApi.appendFileSync>[0], data: Parameters<typeof syncApi.appendFileSync>[1], optsOrCb: Parameters<typeof syncApi.appendFileSync>[2] | ((err: NodeJS.ErrnoException | null, value?: void) => void), maybeCb?: (err: NodeJS.ErrnoException | null, value?: void) => void): void;
32
+ stat(path: Parameters<typeof syncApi.statSync>[0], cb?: (err: NodeJS.ErrnoException | null, value?: StatsCls | BigIntStatsCls) => void): void;
33
+ lstat(path: Parameters<typeof syncApi.lstatSync>[0], cb?: (err: NodeJS.ErrnoException | null, value?: StatsCls | BigIntStatsCls) => void): void;
34
+ exists(path: Parameters<typeof syncApi.existsSync>[0], cb?: (exists: boolean) => void): void;
35
+ access(path: Parameters<typeof syncApi.accessSync>[0], modeOrCb?: number | ((err: NodeJS.ErrnoException | null, value?: void) => void), maybeCb?: (err: NodeJS.ErrnoException | null, value?: void) => void): void;
36
+ readdir(path: Parameters<typeof syncApi.readdirSync>[0], optsOrCb: Parameters<typeof syncApi.readdirSync>[1] | ((err: NodeJS.ErrnoException | null, value?: string[] | DirentCls[]) => void), maybeCb?: (err: NodeJS.ErrnoException | null, value?: string[] | DirentCls[]) => void): void;
37
+ mkdir(path: Parameters<typeof syncApi.mkdirSync>[0], optsOrCb: Parameters<typeof syncApi.mkdirSync>[1] | ((err: NodeJS.ErrnoException | null, value?: string) => void), maybeCb?: (err: NodeJS.ErrnoException | null, value?: string) => void): void;
38
+ rmdir(path: Parameters<typeof syncApi.rmdirSync>[0], optsOrCb: Parameters<typeof syncApi.rmdirSync>[1] | ((err: NodeJS.ErrnoException | null, value?: void) => void), maybeCb?: (err: NodeJS.ErrnoException | null, value?: void) => void): void;
39
+ rm(path: Parameters<typeof syncApi.rmSync>[0], optsOrCb: Parameters<typeof syncApi.rmSync>[1] | ((err: NodeJS.ErrnoException | null, value?: void) => void), maybeCb?: (err: NodeJS.ErrnoException | null, value?: void) => void): void;
40
+ unlink(path: Parameters<typeof syncApi.unlinkSync>[0], cb?: (err: NodeJS.ErrnoException | null, value?: void) => void): void;
41
+ rename(oldPath: Parameters<typeof syncApi.renameSync>[0], newPath: Parameters<typeof syncApi.renameSync>[1], cb?: (err: NodeJS.ErrnoException | null, value?: void) => void): void;
42
+ copyFile(src: Parameters<typeof syncApi.copyFileSync>[0], dest: Parameters<typeof syncApi.copyFileSync>[1], flagsOrCb: number | ((err: NodeJS.ErrnoException | null, value?: void) => void), maybeCb?: (err: NodeJS.ErrnoException | null, value?: void) => void): void;
43
+ link(existingPath: Parameters<typeof syncApi.linkSync>[0], newPath: Parameters<typeof syncApi.linkSync>[1], cb?: (err: NodeJS.ErrnoException | null, value?: void) => void): void;
44
+ symlink(target: Parameters<typeof syncApi.symlinkSync>[0], linkPath: Parameters<typeof syncApi.symlinkSync>[1], typeOrCb?: string | ((err: NodeJS.ErrnoException | null, value?: void) => void), maybeCb?: (err: NodeJS.ErrnoException | null, value?: void) => void): void;
45
+ readlink(path: Parameters<typeof syncApi.readlinkSync>[0], cb?: (err: NodeJS.ErrnoException | null, value?: string) => void): void;
46
+ realpath(path: Parameters<typeof syncApi.realpathSync>[0], cb?: (err: NodeJS.ErrnoException | null, value?: string) => void): void;
47
+ chmod(path: Parameters<typeof syncApi.chmodSync>[0], mode: number, cb?: (err: NodeJS.ErrnoException | null, value?: void) => void): void;
48
+ chown(path: Parameters<typeof syncApi.chownSync>[0], uid: number, gid: number, cb?: (err: NodeJS.ErrnoException | null, value?: void) => void): void;
49
+ truncate(path: Parameters<typeof syncApi.truncateSync>[0], lenOrCb?: number | ((err: NodeJS.ErrnoException | null, value?: void) => void), maybeCb?: (err: NodeJS.ErrnoException | null, value?: void) => void): void;
50
+ utimes(path: Parameters<typeof syncApi.utimesSync>[0], atime: number | Date, mtime: number | Date, cb?: (err: NodeJS.ErrnoException | null, value?: void) => void): void;
51
+ mkdtemp(prefix: string, cb?: (err: NodeJS.ErrnoException | null, value?: string) => void): void;
52
+ open(path: Parameters<typeof syncApi.openSync>[0], flagsOrCb?: string | ((err: NodeJS.ErrnoException | null, value?: number) => void), modeOrCb?: number | ((err: NodeJS.ErrnoException | null, value?: number) => void), maybeCb?: (err: NodeJS.ErrnoException | null, value?: number) => void): void;
53
+ close(fd: number, cb?: (err: NodeJS.ErrnoException | null, value?: void) => void): void;
54
+ read(fd: number, buf: Uint8Array, offset: number, length: number, position: number | null, cb?: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: Uint8Array) => void): void;
55
+ write(fd: number, buf: Uint8Array | string, offsetOrCb?: number | ((err: NodeJS.ErrnoException | null, value?: number) => void), lengthOrEnc?: number | string, positionOrCb?: number | null | ((err: NodeJS.ErrnoException | null, value?: number) => void), maybeCb?: (err: NodeJS.ErrnoException | null, value?: number) => void): void;
56
+ readFileSync(path: string | URL | {
57
+ toString(): string;
58
+ }, opts?: ("utf8" | "utf-8" | "ascii" | "binary" | "base64" | "hex") | syncApi.ReadFileOpts): string | Uint8Array;
59
+ writeFileSync(path: string | URL | {
60
+ toString(): string;
61
+ }, data: string | (Uint8Array<ArrayBufferLike> | {
62
+ buffer: ArrayBufferLike;
63
+ byteOffset?: number;
64
+ byteLength?: number;
65
+ }), opts?: ("utf8" | "utf-8" | "ascii" | "binary" | "base64" | "hex") | syncApi.WriteFileOpts): void;
66
+ appendFileSync(path: string | URL | {
67
+ toString(): string;
68
+ }, data: string | (Uint8Array<ArrayBufferLike> | {
69
+ buffer: ArrayBufferLike;
70
+ byteOffset?: number;
71
+ byteLength?: number;
72
+ }), opts?: ("utf8" | "utf-8" | "ascii" | "binary" | "base64" | "hex") | syncApi.WriteFileOpts): void;
73
+ statSync(path: string | URL | {
74
+ toString(): string;
75
+ }, opts?: syncApi.StatOpts): StatsCls | BigIntStatsCls | undefined;
76
+ lstatSync(path: string | URL | {
77
+ toString(): string;
78
+ }, opts?: syncApi.StatOpts): StatsCls | BigIntStatsCls | undefined;
79
+ existsSync(path: string | URL | {
80
+ toString(): string;
81
+ }): boolean;
82
+ accessSync(path: string | URL | {
83
+ toString(): string;
84
+ }, mode?: number): void;
85
+ readdirSync(path: string | URL | {
86
+ toString(): string;
87
+ }, opts?: syncApi.ReadDirOpts): string[] | DirentCls[];
88
+ mkdirSync(path: string | URL | {
89
+ toString(): string;
90
+ }, opts?: syncApi.MkdirOpts | number): string | undefined;
91
+ rmdirSync(path: string | URL | {
92
+ toString(): string;
93
+ }, opts?: {
94
+ recursive?: boolean;
95
+ }): void;
96
+ rmSync(path: string | URL | {
97
+ toString(): string;
98
+ }, opts?: syncApi.RmOpts): void;
99
+ unlinkSync(path: string | URL | {
100
+ toString(): string;
101
+ }): void;
102
+ renameSync(oldPath: string | URL | {
103
+ toString(): string;
104
+ }, newPath: string | URL | {
105
+ toString(): string;
106
+ }): void;
107
+ copyFileSync(src: string | URL | {
108
+ toString(): string;
109
+ }, dest: string | URL | {
110
+ toString(): string;
111
+ }, flags?: number): void;
112
+ linkSync(existingPath: string | URL | {
113
+ toString(): string;
114
+ }, newPath: string | URL | {
115
+ toString(): string;
116
+ }): void;
117
+ symlinkSync(target: string | URL | {
118
+ toString(): string;
119
+ }, linkPath: string | URL | {
120
+ toString(): string;
121
+ }): void;
122
+ readlinkSync(path: string | URL | {
123
+ toString(): string;
124
+ }): string;
125
+ realpathSync(path: string | URL | {
126
+ toString(): string;
127
+ }): string;
128
+ chmodSync(path: string | URL | {
129
+ toString(): string;
130
+ }, mode: number): void;
131
+ chownSync(path: string | URL | {
132
+ toString(): string;
133
+ }, uid: number, gid: number): void;
134
+ truncateSync(path: string | URL | {
135
+ toString(): string;
136
+ }, len?: number): void;
137
+ utimesSync(path: string | URL | {
138
+ toString(): string;
139
+ }, atime: number | Date, mtime: number | Date): void;
140
+ mkdtempSync(prefix: string): string;
141
+ openSync(path: string | URL | {
142
+ toString(): string;
143
+ }, flags?: string, mode?: number): number;
144
+ closeSync(fd: number): void;
145
+ readSync(fd: number, buf: Uint8Array, offset: number, length: number, position: number | null): number;
146
+ writeSync(fd: number, buf: Uint8Array | string, offsetOrPos?: number | null, lengthOrEnc?: number | string, position?: number | null): number;
147
+ constants: {
148
+ F_OK: number;
149
+ R_OK: number;
150
+ W_OK: number;
151
+ X_OK: number;
152
+ COPYFILE_EXCL: number;
153
+ COPYFILE_FICLONE: number;
154
+ COPYFILE_FICLONE_FORCE: number;
155
+ O_RDONLY: number;
156
+ O_WRONLY: number;
157
+ O_RDWR: number;
158
+ O_CREAT: number;
159
+ O_EXCL: number;
160
+ O_TRUNC: number;
161
+ O_APPEND: number;
162
+ O_SYNC: number;
163
+ O_NONBLOCK: number;
164
+ O_DIRECTORY: number;
165
+ O_NOFOLLOW: number;
166
+ S_IFMT: number;
167
+ S_IFREG: number;
168
+ S_IFDIR: number;
169
+ S_IFCHR: number;
170
+ S_IFBLK: number;
171
+ S_IFIFO: number;
172
+ S_IFLNK: number;
173
+ S_IFSOCK: number;
174
+ S_IRWXU: number;
175
+ S_IRUSR: number;
176
+ S_IWUSR: number;
177
+ S_IXUSR: number;
178
+ S_IRWXG: number;
179
+ S_IRGRP: number;
180
+ S_IWGRP: number;
181
+ S_IXGRP: number;
182
+ S_IRWXO: number;
183
+ S_IROTH: number;
184
+ S_IWOTH: number;
185
+ S_IXOTH: number;
186
+ };
187
+ Volume: typeof VolumeCls;
188
+ __defaultVolume: VolumeCls;
189
+ Stats: typeof StatsCls;
190
+ BigIntStats: typeof BigIntStatsCls;
191
+ Dirent: typeof DirentCls;
192
+ };
193
+ export default defaultExport;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/fs",
3
- "version": "0.4.34",
3
+ "version": "0.4.36",
4
4
  "description": "Node.js fs module for Gjs",
5
5
  "module": "lib/esm/index.js",
6
6
  "types": "lib/types/index.d.ts",
@@ -16,6 +16,30 @@
16
16
  "./promises": {
17
17
  "types": "./lib/types/promises.d.ts",
18
18
  "default": "./lib/esm/promises.js"
19
+ },
20
+ "./browser": {
21
+ "types": "./lib/types/browser.d.ts",
22
+ "default": "./lib/esm/browser.js"
23
+ },
24
+ "./browser/promises": {
25
+ "types": "./lib/types/browser/promises-entry.d.ts",
26
+ "default": "./lib/esm/browser/promises-entry.js"
27
+ },
28
+ "./browser/volume": {
29
+ "types": "./lib/types/browser/volume.d.ts",
30
+ "default": "./lib/esm/browser/volume.js"
31
+ },
32
+ "./browser/sync": {
33
+ "types": "./lib/types/browser/sync.d.ts",
34
+ "default": "./lib/esm/browser/sync.js"
35
+ },
36
+ "./browser/async": {
37
+ "types": "./lib/types/browser/async.d.ts",
38
+ "default": "./lib/esm/browser/async.js"
39
+ },
40
+ "./browser/stream": {
41
+ "types": "./lib/types/browser/stream.d.ts",
42
+ "default": "./lib/esm/browser/stream.js"
19
43
  }
20
44
  },
21
45
  "scripts": {
@@ -37,25 +61,35 @@
37
61
  "fs"
38
62
  ],
39
63
  "devDependencies": {
40
- "@gjsify/cli": "^0.4.34",
41
- "@gjsify/unit": "^0.4.34",
64
+ "@gjsify/cli": "^0.4.36",
65
+ "@gjsify/unit": "^0.4.36",
42
66
  "@types/node": "^25.9.1",
43
- "typescript": "^6.0.3"
67
+ "typescript": "^5.9.3"
44
68
  },
45
69
  "dependencies": {
46
- "@girs/gio-2.0": "2.88.0-4.0.1",
47
- "@girs/glib-2.0": "2.88.0-4.0.1",
48
- "@gjsify/buffer": "^0.4.34",
49
- "@gjsify/events": "^0.4.34",
50
- "@gjsify/stream": "^0.4.34",
51
- "@gjsify/url": "^0.4.34",
52
- "@gjsify/utils": "^0.4.34"
70
+ "@girs/gio-2.0": "2.88.0-4.0.4",
71
+ "@girs/glib-2.0": "2.88.0-4.0.4",
72
+ "@gjsify/buffer": "^0.4.36",
73
+ "@gjsify/events": "^0.4.36",
74
+ "@gjsify/stream": "^0.4.36",
75
+ "@gjsify/url": "^0.4.36",
76
+ "@gjsify/utils": "^0.4.36"
53
77
  },
54
78
  "gjsify": {
55
79
  "runtimes": {
56
80
  "gjs": "polyfill",
57
81
  "node": "none",
58
- "browser": "none"
82
+ "browser": "partial"
59
83
  }
60
- }
84
+ },
85
+ "license": "MIT",
86
+ "repository": {
87
+ "type": "git",
88
+ "url": "git+https://github.com/gjsify/gjsify.git",
89
+ "directory": "packages/node/fs"
90
+ },
91
+ "bugs": {
92
+ "url": "https://github.com/gjsify/gjsify/issues"
93
+ },
94
+ "homepage": "https://github.com/gjsify/gjsify/tree/main/packages/node/fs#readme"
61
95
  }