@gjsify/fs 0.52.0 → 0.54.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.
@@ -1 +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};
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}addListener(e,t){return this.on(e,t)}removeListener(e,t){return this.off(e,t)}},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"./_virtual/_rolldown/runtime.js";import{openFlagValues as e}from"./posix-flags.js";function openFlagDescriptors(){let t={};for(let n of Object.keys(e()))t[n]={enumerable:!0,configurable:!0,get:()=>e()[n]};return t}const t=Object.defineProperties({F_OK:0,R_OK:4,W_OK:2,X_OK:1,COPYFILE_EXCL:1,COPYFILE_FICLONE:2,COPYFILE_FICLONE_FORCE:4,S_IFMT:61440,S_IFREG:32768,S_IFDIR:16384,S_IFCHR:8192,S_IFBLK:24576,S_IFIFO:4096,S_IFLNK:40960,S_IFSOCK:49152,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},openFlagDescriptors());export{t as constants};
package/lib/esm/cp.js CHANGED
@@ -1 +1 @@
1
- import"./_virtual/_rolldown/runtime.js";import{normalizePath as e}from"./utils.js";import{createNodeError as t,requireCallback as n}from"./errors.js";import r from"@girs/gio-2.0";import{join as i}from"node:path";function makeEEXIST(e){let t=Error(`ERR_FS_CP_EEXIST: file already exists, copyfile '${e}'`);return t.code=`ERR_FS_CP_EEXIST`,t.syscall=`copyfile`,t.path=e,t}function makeEISDIR(e){let t=Error(`ERR_FS_EISDIR: illegal operation on a directory, copyfile '${e}'`);return t.code=`ERR_FS_EISDIR`,t.syscall=`copyfile`,t.path=e,t}function makeENOTDIR(e,t){let n=Error(`ENOTDIR: not a directory, copyfile '${e}' -> '${t}'`);return n.code=`ENOTDIR`,n.syscall=`copyfile`,n.path=e,n.dest=t,n}function makeSYMLINKLOOP(e,t){let n=Error(`ELOOP: too many levels of symbolic links, copyfile '${e}' -> '${t}'`);return n.code=`ELOOP`,n.syscall=`copyfile`,n.path=e,n.dest=t,n}function queryCopyFlags(e){let t=e.force??!0,n=r.FileCopyFlags.NONE;return t&&(n|=r.FileCopyFlags.OVERWRITE),e.preserveTimestamps&&(n|=r.FileCopyFlags.TARGET_DEFAULT_MODIFIED_TIME),e.dereference||(n|=r.FileCopyFlags.NOFOLLOW_SYMLINKS),n}function copyOneSyncFile(e,n,i,a,o){let s=o.force??!0;try{if(n.query_info(`standard::type`,r.FileQueryInfoFlags.NONE,null).get_file_type()===r.FileType.DIRECTORY)throw makeENOTDIR(i,a);if(!s){if(o.errorOnExist)throw makeEEXIST(a);return}}catch(e){if(typeof e.code==`string`)throw e}let c=queryCopyFlags(o);try{e.copy(n,c,null,null)}catch(e){throw t(e,`copyfile`,i,a)}}function cpOneDirSync(e,n,a,o,s){let c=a.endsWith(`/`)?``:`/`;if(o.startsWith(a+c)&&o!==a)throw makeSYMLINKLOOP(a,o);if(n.query_exists(null))try{if(n.query_info(`standard::type`,r.FileQueryInfoFlags.NONE,null).get_file_type()!==r.FileType.DIRECTORY)throw makeENOTDIR(o,a)}catch(e){if(typeof e.code==`string`)throw e}else try{n.make_directory_with_parents(null)}catch(e){throw t(e,`mkdir`,o)}let l;try{l=e.enumerate_children(`standard::name,standard::type,standard::is-symlink`,s.dereference?r.FileQueryInfoFlags.NONE:r.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)}catch(e){throw t(e,`scandir`,a)}let u=l.next_file(null);for(;u!==null;){let e=u.get_name(),t=i(a,e),n=i(o,e),r=s.filter;if(r&&!r(t,n)){u=l.next_file(null);continue}cpSyncInternal(t,n,s),u=l.next_file(null)}}function cpSyncInternal(e,n,i){let a=r.File.new_for_path(e),o=r.File.new_for_path(n),s;try{s=a.query_info(`standard::type,standard::is-symlink`,i.dereference?r.FileQueryInfoFlags.NONE:r.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)}catch(n){throw t(n,`stat`,e)}if(s.get_file_type()===r.FileType.DIRECTORY){if(!i.recursive)throw makeEISDIR(e);cpOneDirSync(a,o,e,n,i)}else copyOneSyncFile(a,o,e,n,i)}function cpSync(n,i,a){let o=e(n),s=e(i),c=a??{},l=r.File.new_for_path(o),u=c.filter;if(!(u&&!u(o,s))){try{if(l.query_info(`standard::type`,c.dereference?r.FileQueryInfoFlags.NONE:r.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null).get_file_type()===r.FileType.DIRECTORY&&!c.recursive)throw makeEISDIR(o)}catch(e){throw typeof e.code==`string`?e:t(e,`stat`,o)}cpSyncInternal(o,s,c)}}function cp(t,r,i,a){let o,s;typeof i==`function`?(s=i,o={}):(s=n(a),o=i);let c=o.filter;if(c){Promise.resolve(c(e(t),e(r))).then(e=>{if(!e){s(null);return}try{cpPromises(t,r,o).then(()=>s(null)).catch(s)}catch(e){s(e)}}).catch(s);return}Promise.resolve().then(()=>{try{cpSync(t,r,o),s(null)}catch(e){s(e)}})}async function cpPromisesDir(e,n,a){let o=e.endsWith(`/`)?``:`/`;if(n.startsWith(e+o)&&n!==e)throw makeSYMLINKLOOP(e,n);let s=r.File.new_for_path(n);if(!s.query_exists(null))try{s.make_directory_with_parents(null)}catch(e){throw t(e,`mkdir`,n)}let c=r.File.new_for_path(e),l;try{l=c.enumerate_children(`standard::name,standard::type`,a.dereference?r.FileQueryInfoFlags.NONE:r.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)}catch(n){throw t(n,`scandir`,e)}let u=l.next_file(null);for(;u!==null;){let t=u.get_name(),r=i(e,t),o=i(n,t),s=a.filter;if(s&&!await Promise.resolve(s(r,o))){u=l.next_file(null);continue}await cpPromises(r,o,a),u=l.next_file(null)}}async function cpPromises(n,i,a={}){let o=e(n),s=e(i),c=r.File.new_for_path(o),l;try{l=c.query_info(`standard::type`,a.dereference?r.FileQueryInfoFlags.NONE:r.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)}catch(e){throw t(e,`stat`,o)}if(l.get_file_type()===r.FileType.DIRECTORY){if(!a.recursive)throw makeEISDIR(o);await cpPromisesDir(o,s,a)}else copyOneSyncFile(c,r.File.new_for_path(s),o,s,a)}export{cp,cpPromises as cpAsync,cpSync};
1
+ import"./_virtual/_rolldown/runtime.js";import{normalizePath as e}from"./utils.js";import{createNodeError as t,requireCallback as n}from"./errors.js";import r from"@girs/gio-2.0";import{join as i,resolve as a,sep as o}from"node:path";function makeEEXIST(e){let t=Error(`ERR_FS_CP_EEXIST: file already exists, copyfile '${e}'`);return t.code=`ERR_FS_CP_EEXIST`,t.syscall=`copyfile`,t.path=e,t}function makeEISDIR(e){let t=Error(`ERR_FS_EISDIR: illegal operation on a directory, copyfile '${e}'`);return t.code=`ERR_FS_EISDIR`,t.syscall=`copyfile`,t.path=e,t}function makeENOTDIR(e,t){let n=Error(`ENOTDIR: not a directory, copyfile '${e}' -> '${t}'`);return n.code=`ENOTDIR`,n.syscall=`copyfile`,n.path=e,n.dest=t,n}function makeSubdirOfSelf(e,t){let n=Error(`Cannot copy ${e} to a subdirectory of self ${t}`);return n.code=`ERR_FS_CP_EINVAL`,n}function queryCopyFlags(e){let t=e.force??!0,n=r.FileCopyFlags.NONE;return t&&(n|=r.FileCopyFlags.OVERWRITE),e.preserveTimestamps&&(n|=r.FileCopyFlags.TARGET_DEFAULT_MODIFIED_TIME),e.dereference||(n|=r.FileCopyFlags.NOFOLLOW_SYMLINKS),n}function copyOneSyncFile(e,n,i,a,o){let s=o.force??!0;try{if(n.query_info(`standard::type`,r.FileQueryInfoFlags.NONE,null).get_file_type()===r.FileType.DIRECTORY)throw makeENOTDIR(i,a);if(!s){if(o.errorOnExist)throw makeEEXIST(a);return}}catch(e){if(typeof e.code==`string`)throw e}let c=queryCopyFlags(o);try{e.copy(n,c,null,null)}catch(e){throw t(e,`copyfile`,i,a)}}function isStrictSubdir(e,t){let n=a(e).split(o).filter(Boolean),r=a(t).split(o).filter(Boolean);return r.length>n.length&&n.every((e,t)=>r[t]===e)}function cpOneDirSync(e,n,a,o,s){if(isStrictSubdir(a,o))throw makeSubdirOfSelf(a,o);if(n.query_exists(null))try{if(n.query_info(`standard::type`,r.FileQueryInfoFlags.NONE,null).get_file_type()!==r.FileType.DIRECTORY)throw makeENOTDIR(o,a)}catch(e){if(typeof e.code==`string`)throw e}else try{n.make_directory_with_parents(null)}catch(e){throw t(e,`mkdir`,o)}let c;try{c=e.enumerate_children(`standard::name,standard::type,standard::is-symlink`,s.dereference?r.FileQueryInfoFlags.NONE:r.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)}catch(e){throw t(e,`scandir`,a)}let l=c.next_file(null);for(;l!==null;){let e=l.get_name(),t=i(a,e),n=i(o,e),r=s.filter;if(r&&!r(t,n)){l=c.next_file(null);continue}cpSyncInternal(t,n,s),l=c.next_file(null)}}function cpSyncInternal(e,n,i){let a=r.File.new_for_path(e),o=r.File.new_for_path(n),s;try{s=a.query_info(`standard::type,standard::is-symlink`,i.dereference?r.FileQueryInfoFlags.NONE:r.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)}catch(n){throw t(n,`stat`,e)}if(s.get_file_type()===r.FileType.DIRECTORY){if(!i.recursive)throw makeEISDIR(e);cpOneDirSync(a,o,e,n,i)}else copyOneSyncFile(a,o,e,n,i)}function cpSync(n,i,a){let o=e(n),s=e(i),c=a??{},l=r.File.new_for_path(o),u=c.filter;if(!(u&&!u(o,s))){try{if(l.query_info(`standard::type`,c.dereference?r.FileQueryInfoFlags.NONE:r.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null).get_file_type()===r.FileType.DIRECTORY&&!c.recursive)throw makeEISDIR(o)}catch(e){throw typeof e.code==`string`?e:t(e,`stat`,o)}cpSyncInternal(o,s,c)}}function cp(t,r,i,a){let o,s;typeof i==`function`?(s=i,o={}):(s=n(a),o=i);let c=o.filter;if(c){Promise.resolve(c(e(t),e(r))).then(e=>{if(!e){s(null);return}try{cpPromises(t,r,o).then(()=>s(null)).catch(s)}catch(e){s(e)}}).catch(s);return}Promise.resolve().then(()=>{try{cpSync(t,r,o),s(null)}catch(e){s(e)}})}async function cpPromisesDir(e,n,a){if(isStrictSubdir(e,n))throw makeSubdirOfSelf(e,n);let o=r.File.new_for_path(n);if(!o.query_exists(null))try{o.make_directory_with_parents(null)}catch(e){throw t(e,`mkdir`,n)}let s=r.File.new_for_path(e),c;try{c=s.enumerate_children(`standard::name,standard::type`,a.dereference?r.FileQueryInfoFlags.NONE:r.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)}catch(n){throw t(n,`scandir`,e)}let l=c.next_file(null);for(;l!==null;){let t=l.get_name(),r=i(e,t),o=i(n,t),s=a.filter;if(s&&!await Promise.resolve(s(r,o))){l=c.next_file(null);continue}await cpPromises(r,o,a),l=c.next_file(null)}}async function cpPromises(n,i,a={}){let o=e(n),s=e(i),c=r.File.new_for_path(o),l;try{l=c.query_info(`standard::type`,a.dereference?r.FileQueryInfoFlags.NONE:r.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)}catch(e){throw t(e,`stat`,o)}if(l.get_file_type()===r.FileType.DIRECTORY){if(!a.recursive)throw makeEISDIR(o);await cpPromisesDir(o,s,a)}else copyOneSyncFile(c,r.File.new_for_path(s),o,s,a)}export{cp,cpPromises as cpAsync,cpSync};
package/lib/esm/dir.js CHANGED
@@ -1 +1 @@
1
- import"./_virtual/_rolldown/runtime.js";import{normalizePath as e}from"./utils.js";import{createNodeError as t,requireCallback as n}from"./errors.js";import{Dirent as r}from"./dirent.js";import i from"@girs/glib-2.0";import a from"@girs/gio-2.0";const o=`standard::name,standard::type,standard::is-symlink,standard::size,standard::symlink-target,unix::uid,unix::gid,unix::mode,time::modified,time::access,time::created`;var Dir=class{path;_enumerator;_closed=!1;constructor(e,t){this.path=e,this._enumerator=t}_assertOpen(){if(this._closed){let e=Error(`Directory handle was closed`);throw e.code=`ERR_DIR_CLOSED`,e}}readSync(){this._assertOpen();try{let e=this._enumerator.next_file(null);if(e===null)return null;let t=e.get_name(),n=e.get_file_type();return new r(this.path.endsWith(`/`)?this.path+t:this.path+`/`+t,t,n)}catch(e){throw t(e,`readdir`,this.path)}}read(e){if(e!==void 0){if(typeof e!=`function`)throw TypeError(`The "callback" argument must be of type function`);try{this._assertOpen();let t=this.readSync();Promise.resolve().then(()=>e(null,t))}catch(t){Promise.resolve().then(()=>e(t,null))}return}return new Promise((e,t)=>{try{this._assertOpen(),e(this.readSync())}catch(e){t(e)}})}closeSync(){this._assertOpen(),this._closed=!0;try{this._enumerator.close(null)}catch{}this._enumerator=null}close(e){if(e!==void 0){if(typeof e!=`function`)throw TypeError(`The "callback" argument must be of type function`);try{this.closeSync(),Promise.resolve().then(()=>e(null))}catch(t){Promise.resolve().then(()=>e(t))}return}return new Promise((e,t)=>{try{this.closeSync(),e()}catch(e){t(e)}})}async*[Symbol.asyncIterator](){try{for(;;){let e=await this.read();if(e===null)break;yield e}}finally{this._closed||await this.close()}}};function _openDir(e){let n=a.File.new_for_path(e),r;try{r=n.enumerate_children(o,a.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)}catch(n){throw t(n,`opendir`,e)}return new Dir(e,r)}function opendirSync(t){return _openDir(e(t))}function opendir(e,t,r){let i;if(i=typeof t==`function`?t:n(r,`callback`),typeof i!=`function`)throw TypeError(`The "callback" argument must be of type function`);Promise.resolve().then(()=>{try{let t=opendirSync(e);i(null,t)}catch(e){i(e,null)}})}async function opendirAsync(n,r){return new Promise((r,s)=>{let c=e(n),l=a.File.new_for_path(c);l.enumerate_children_async(o,a.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,i.PRIORITY_DEFAULT,null,(e,n)=>{try{let e=l.enumerate_children_finish(n);r(new Dir(c,e))}catch(e){s(t(e,`opendir`,c))}})})}export{Dir,opendir,opendirAsync,opendirSync};
1
+ import"./_virtual/_rolldown/runtime.js";import{normalizePath as e}from"./utils.js";import{createNodeError as t,requireCallback as n}from"./errors.js";import{Dirent as r}from"./dirent.js";import i from"@girs/glib-2.0";import a from"@girs/gio-2.0";import{join as o}from"node:path";const s=`standard::name,standard::type,standard::is-symlink,standard::size,standard::symlink-target,unix::uid,unix::gid,unix::mode,time::modified,time::access,time::created`;var Dir=class{path;_enumerator;_closed=!1;constructor(e,t){this.path=e,this._enumerator=t}_assertOpen(){if(this._closed){let e=Error(`Directory handle was closed`);throw e.code=`ERR_DIR_CLOSED`,e}}readSync(){this._assertOpen();try{let e=this._enumerator.next_file(null);if(e===null)return null;let t=e.get_name(),n=e.get_file_type();return new r(o(this.path,t),t,n,void 0,this.path)}catch(e){throw t(e,`readdir`,this.path)}}read(e){if(e!==void 0){if(typeof e!=`function`)throw TypeError(`The "callback" argument must be of type function`);try{this._assertOpen();let t=this.readSync();Promise.resolve().then(()=>e(null,t))}catch(t){Promise.resolve().then(()=>e(t,null))}return}return new Promise((e,t)=>{try{this._assertOpen(),e(this.readSync())}catch(e){t(e)}})}closeSync(){this._assertOpen(),this._closed=!0;try{this._enumerator.close(null)}catch{}this._enumerator=null}close(e){if(e!==void 0){if(typeof e!=`function`)throw TypeError(`The "callback" argument must be of type function`);try{this.closeSync(),Promise.resolve().then(()=>e(null))}catch(t){Promise.resolve().then(()=>e(t))}return}return new Promise((e,t)=>{try{this.closeSync(),e()}catch(e){t(e)}})}async*[Symbol.asyncIterator](){try{for(;;){let e=await this.read();if(e===null)break;yield e}}finally{this._closed||await this.close()}}};function _openDir(e){let n=a.File.new_for_path(e),r;try{r=n.enumerate_children(s,a.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)}catch(n){throw t(n,`opendir`,e)}return new Dir(e,r)}function opendirSync(t){return _openDir(e(t))}function opendir(e,t,r){let i;if(i=typeof t==`function`?t:n(r,`callback`),typeof i!=`function`)throw TypeError(`The "callback" argument must be of type function`);Promise.resolve().then(()=>{try{let t=opendirSync(e);i(null,t)}catch(e){i(e,null)}})}async function opendirAsync(n,r){return new Promise((r,o)=>{let c=e(n),l=a.File.new_for_path(c);l.enumerate_children_async(s,a.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,i.PRIORITY_DEFAULT,null,(e,n)=>{try{let e=l.enumerate_children_finish(n);r(new Dir(c,e))}catch(e){o(t(e,`opendir`,c))}})})}export{Dir,opendir,opendirAsync,opendirSync};
package/lib/esm/dirent.js CHANGED
@@ -1 +1 @@
1
- import"./_virtual/_rolldown/runtime.js";import e from"@girs/gio-2.0";import{basename as t,dirname as n}from"node:path";var Dirent=class{name;parentPath;_isFile=!1;_isDirectory=!1;_isBlockDevice=!1;_isCharacterDevice=!1;_isSymbolicLink=!1;_isFIFO=!1;_isSocket=!1;_file;constructor(r,i,a,o){switch(i||=t(r),this.name=i,this.parentPath=n(r),this._file=e.File.new_for_path(r),a??this._file.query_file_type(e.FileQueryInfoFlags.NONE,null)){case e.FileType.DIRECTORY:this._isDirectory=!0;break;case e.FileType.MOUNTABLE:break;case e.FileType.REGULAR:this._isFile=!0;break;case e.FileType.SYMBOLIC_LINK:case e.FileType.SHORTCUT:this._isSymbolicLink=!0;break;case e.FileType.SPECIAL:this._classifySpecialFile(r,o);break}}_classifySpecialFile(t,n){try{let r=n?.has_attribute(`unix::mode`)===!0?n:e.File.new_for_path(t).query_info(`unix::mode`,e.FileQueryInfoFlags.NONE,null),i=r.has_attribute(`unix::mode`)?r.get_attribute_uint32(`unix::mode`):0;if(i===0)return;switch(i&61440){case 24576:this._isBlockDevice=!0;break;case 8192:this._isCharacterDevice=!0;break;case 49152:this._isSocket=!0;break;case 4096:this._isFIFO=!0;break}}catch{}}isFile(){return this._isFile}isDirectory(){return this._isDirectory}isBlockDevice(){return this._isBlockDevice}isCharacterDevice(){return this._isCharacterDevice}isSymbolicLink(){return this._isSymbolicLink}isFIFO(){return this._isFIFO}isSocket(){return this._isSocket}};export{Dirent};
1
+ import"./_virtual/_rolldown/runtime.js";import e from"@girs/gio-2.0";import{basename as t,dirname as n}from"node:path";var Dirent=class{name;parentPath;_isFile=!1;_isDirectory=!1;_isBlockDevice=!1;_isCharacterDevice=!1;_isSymbolicLink=!1;_isFIFO=!1;_isSocket=!1;_file;constructor(r,i,a,o,s){switch(i||=t(r),this.name=i,this.parentPath=s??n(r),this._file=e.File.new_for_path(r),a??this._file.query_file_type(e.FileQueryInfoFlags.NONE,null)){case e.FileType.DIRECTORY:this._isDirectory=!0;break;case e.FileType.MOUNTABLE:break;case e.FileType.REGULAR:this._isFile=!0;break;case e.FileType.SYMBOLIC_LINK:case e.FileType.SHORTCUT:this._isSymbolicLink=!0;break;case e.FileType.SPECIAL:this._classifySpecialFile(r,o);break}}_classifySpecialFile(t,n){try{let r=n?.has_attribute(`unix::mode`)===!0?n:e.File.new_for_path(t).query_info(`unix::mode`,e.FileQueryInfoFlags.NONE,null),i=r.has_attribute(`unix::mode`)?r.get_attribute_uint32(`unix::mode`):0;if(i===0)return;switch(i&61440){case 24576:this._isBlockDevice=!0;break;case 8192:this._isCharacterDevice=!0;break;case 49152:this._isSocket=!0;break;case 4096:this._isFIFO=!0;break}}catch{}}isFile(){return this._isFile}isDirectory(){return this._isDirectory}isBlockDevice(){return this._isBlockDevice}isCharacterDevice(){return this._isCharacterDevice}isSymbolicLink(){return this._isSymbolicLink}isFIFO(){return this._isFIFO}isSocket(){return this._isSocket}};export{Dirent};
package/lib/esm/index.js CHANGED
@@ -1 +1 @@
1
- import"./_virtual/_rolldown/runtime.js";import{FSWatcher as e}from"./fs-watcher.js";import{lchmod as t,lchmodSync as ee,lchown as te,lchownSync as n,lutimes as r,lutimesSync as i,utimes as a,utimesSync as o}from"./utimes.js";import{closeSync as s,exists as c,fchmod as l,fchmodSync as u,fchown as d,fchownSync as f,fdatasync as p,fdatasyncSync as m,fstat as h,fstatSync as g,fsync as _,fsyncSync as v,ftruncate as y,ftruncateSync as b,futimes as x,futimesSync as S,openAsBlob as C,readSync as w,readv as T,readvSync as E,writeSync as D,writev as O,writevSync as k}from"./fd-ops.js";import{ReadStream as A,createReadStream as j}from"./read-stream.js";import{openFlagValues as M}from"./posix-flags.js";import{WriteStream as N,createWriteStream as P}from"./write-stream.js";import{Dirent as F}from"./dirent.js";import{BigIntStats as I,Stats as L}from"./stats.js";import{accessSync as R,appendFileSync as z,chmodSync as B,chownSync as V,copyFileSync as H,existsSync as U,linkSync as W,lstatSync as G,mkdirSync as K,mkdtempSync as q,openSync as J,readFileSync as Y,readdirSync as X,readlinkSync as Z,realpathSync as Q,renameSync as ne,rmSync as $,rmdirSync as re,statSync as ie,symlinkSync as ae,truncateSync as oe,unlinkSync as se,watch as ce,writeFileSync as le}from"./sync.js";import{cp as ue,cpSync as de}from"./cp.js";import{Dir as fe,opendir as pe,opendirSync as me}from"./dir.js";import{glob as he,globSync as ge}from"./glob.js";import{statfs as _e,statfsSync as ve}from"./statfs.js";import{promises_exports as ye}from"./promises.js";import{access as be,appendFile as xe,chmod as Se,chown as Ce,close as we,copyFile as Te,link as Ee,lstat as De,mkdir as Oe,mkdtemp as ke,open as Ae,read as je,readFile as Me,readdir as Ne,readlink as Pe,realpath as Fe,rename as Ie,rm as Le,rmdir as Re,stat as ze,symlink as Be,truncate as Ve,unlink as He,write as Ue,writeFile as We}from"./callback.js";import{StatWatcher as Ge,unwatchFile as Ke,watchFile as qe}from"./stat-watcher.js";function openFlagDescriptors(){let e={};for(let t of Object.keys(M()))e[t]={enumerable:!0,configurable:!0,get:()=>M()[t]};return e}const Je=Object.defineProperties({F_OK:0,R_OK:4,W_OK:2,X_OK:1,COPYFILE_EXCL:1,COPYFILE_FICLONE:2,COPYFILE_FICLONE_FORCE:4,S_IFMT:61440,S_IFREG:32768,S_IFDIR:16384,S_IFCHR:8192,S_IFBLK:24576,S_IFIFO:4096,S_IFLNK:40960,S_IFSOCK:49152,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},openFlagDescriptors());var Ye={FSWatcher:e,StatWatcher:Ge,Stats:L,BigIntStats:I,Dirent:F,Dir:fe,constants:Je,existsSync:U,readdirSync:X,readFileSync:Y,writeFileSync:le,mkdirSync:K,rmdirSync:re,unlinkSync:se,mkdtemp:ke,mkdtempSync:q,rmSync:$,statSync:ie,openSync:J,realpathSync:Q,symlinkSync:ae,lstatSync:G,renameSync:ne,copyFileSync:H,accessSync:R,appendFileSync:z,readlinkSync:Z,linkSync:W,truncateSync:oe,chmodSync:B,chownSync:V,cpSync:de,opendirSync:me,globSync:ge,glob:he,watch:ce,watchFile:qe,unwatchFile:Ke,statfsSync:ve,statfs:_e,utimesSync:o,utimes:a,lutimesSync:i,lutimes:r,lchownSync:n,lchown:te,lchmodSync:void 0,lchmod:void 0,fstatSync:g,fstat:h,ftruncateSync:b,ftruncate:y,fdatasyncSync:m,fdatasync:p,fsyncSync:v,fsync:_,fchmodSync:u,fchmod:l,fchownSync:f,fchown:d,futimesSync:S,futimes:x,closeSync:s,readSync:w,writeSync:D,readvSync:E,readv:T,writevSync:k,writev:O,exists:c,openAsBlob:C,createReadStream:j,ReadStream:A,createWriteStream:P,WriteStream:N,promises:ye,open:Ae,close:we,read:je,write:Ue,rm:Le,realpath:Fe,readdir:Ne,symlink:Be,lstat:De,stat:ze,rename:Ie,copyFile:Te,cp:ue,access:be,appendFile:xe,readlink:Pe,truncate:Ve,chmod:Se,chown:Ce,mkdir:Oe,rmdir:Re,readFile:Me,writeFile:We,unlink:He,link:Ee,opendir:pe};export{I as BigIntStats,fe as Dir,F as Dirent,e as FSWatcher,A as ReadStream,Ge as StatWatcher,L as Stats,N as WriteStream,be as access,R as accessSync,xe as appendFile,z as appendFileSync,Se as chmod,B as chmodSync,Ce as chown,V as chownSync,we as close,s as closeSync,Je as constants,Te as copyFile,H as copyFileSync,ue as cp,de as cpSync,j as createReadStream,P as createWriteStream,Ye as default,c as exists,U as existsSync,l as fchmod,u as fchmodSync,d as fchown,f as fchownSync,p as fdatasync,m as fdatasyncSync,h as fstat,g as fstatSync,_ as fsync,v as fsyncSync,y as ftruncate,b as ftruncateSync,x as futimes,S as futimesSync,he as glob,ge as globSync,t as lchmod,ee as lchmodSync,te as lchown,n as lchownSync,Ee as link,W as linkSync,De as lstat,G as lstatSync,r as lutimes,i as lutimesSync,Oe as mkdir,K as mkdirSync,ke as mkdtemp,q as mkdtempSync,Ae as open,C as openAsBlob,J as openSync,pe as opendir,me as opendirSync,ye as promises,je as read,Me as readFile,Y as readFileSync,w as readSync,Ne as readdir,X as readdirSync,Pe as readlink,Z as readlinkSync,T as readv,E as readvSync,Fe as realpath,Q as realpathSync,Ie as rename,ne as renameSync,Le as rm,$ as rmSync,Re as rmdir,re as rmdirSync,ze as stat,ie as statSync,_e as statfs,ve as statfsSync,Be as symlink,ae as symlinkSync,Ve as truncate,oe as truncateSync,He as unlink,se as unlinkSync,Ke as unwatchFile,a as utimes,o as utimesSync,ce as watch,qe as watchFile,Ue as write,We as writeFile,le as writeFileSync,D as writeSync,O as writev,k as writevSync};
1
+ import{FSWatcher as e}from"./fs-watcher.js";import{lchmod as ee,lchmodSync as te,lchown as t,lchownSync as n,lutimes as r,lutimesSync as i,utimes as a,utimesSync as o}from"./utimes.js";import{closeSync as s,exists as c,fchmod as l,fchmodSync as u,fchown as d,fchownSync as f,fdatasync as p,fdatasyncSync as m,fstat as h,fstatSync as g,fsync as _,fsyncSync as v,ftruncate as y,ftruncateSync as b,futimes as x,futimesSync as S,openAsBlob as C,readSync as w,readv as T,readvSync as E,writeSync as D,writev as O,writevSync as k}from"./fd-ops.js";import{ReadStream as A,createReadStream as j}from"./read-stream.js";import{WriteStream as M,createWriteStream as N}from"./write-stream.js";import{Dirent as P}from"./dirent.js";import{BigIntStats as F,Stats as I}from"./stats.js";import{accessSync as L,appendFileSync as R,chmodSync as z,chownSync as B,copyFileSync as V,existsSync as H,linkSync as U,lstatSync as W,mkdirSync as G,mkdtempSync as K,openSync as q,readFileSync as J,readdirSync as Y,readlinkSync as X,realpathSync as ne,renameSync as Z,rmSync as Q,rmdirSync as re,statSync as ie,symlinkSync as ae,truncateSync as oe,unlinkSync as se,watch as ce,writeFileSync as le}from"./sync.js";import{cp as ue,cpSync as de}from"./cp.js";import{Dir as fe,opendir as pe,opendirSync as me}from"./dir.js";import{glob as he,globSync as ge}from"./glob.js";import{statfs as _e,statfsSync as ve}from"./statfs.js";import{constants as ye}from"./constants.js";import{promises_exports as be}from"./promises.js";import{access as xe,appendFile as Se,chmod as Ce,chown as we,close as Te,copyFile 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,write as We,writeFile as Ge}from"./callback.js";import{StatWatcher as Ke,unwatchFile as qe,watchFile as Je}from"./stat-watcher.js";const $={FSWatcher:e,StatWatcher:Ke,Stats:I,BigIntStats:F,Dirent:P,Dir:fe,constants:ye,existsSync:H,readdirSync:Y,readFileSync:J,writeFileSync:le,mkdirSync:G,rmdirSync:re,unlinkSync:se,mkdtemp:Ae,mkdtempSync:K,rmSync:Q,statSync:ie,openSync:q,realpathSync:ne,symlinkSync:ae,lstatSync:W,renameSync:Z,copyFileSync:V,accessSync:L,appendFileSync:R,readlinkSync:X,linkSync:U,truncateSync:oe,chmodSync:z,chownSync:B,cpSync:de,opendirSync:me,globSync:ge,glob:he,watch:ce,watchFile:Je,unwatchFile:qe,statfsSync:ve,statfs:_e,utimesSync:o,utimes:a,lutimesSync:i,lutimes:r,lchownSync:n,lchown:t,lchmodSync:void 0,lchmod:void 0,fstatSync:g,fstat:h,ftruncateSync:b,ftruncate:y,fdatasyncSync:m,fdatasync:p,fsyncSync:v,fsync:_,fchmodSync:u,fchmod:l,fchownSync:f,fchown:d,futimesSync:S,futimes:x,closeSync:s,readSync:w,writeSync:D,readvSync:E,readv:T,writevSync:k,writev:O,exists:c,openAsBlob:C,createReadStream:j,ReadStream:A,createWriteStream:N,WriteStream:M,promises:be,open:je,close:Te,read:Me,write:We,rm:Re,realpath:Ie,readdir:Pe,symlink:Ve,lstat:Oe,stat:Be,rename:Le,copyFile:Ee,cp:ue,access:xe,appendFile:Se,readlink:Fe,truncate:He,chmod:Ce,chown:we,mkdir:ke,rmdir:ze,readFile:Ne,writeFile:Ge,unlink:Ue,link:De,opendir:pe};export{F as BigIntStats,fe as Dir,P as Dirent,e as FSWatcher,A as ReadStream,Ke as StatWatcher,I as Stats,M as WriteStream,xe as access,L as accessSync,Se as appendFile,R as appendFileSync,Ce as chmod,z as chmodSync,we as chown,B as chownSync,Te as close,s as closeSync,ye as constants,Ee as copyFile,V as copyFileSync,ue as cp,de as cpSync,j as createReadStream,N as createWriteStream,$ as default,$ as"module.exports",c as exists,H as existsSync,l as fchmod,u as fchmodSync,d as fchown,f as fchownSync,p as fdatasync,m as fdatasyncSync,h as fstat,g as fstatSync,_ as fsync,v as fsyncSync,y as ftruncate,b as ftruncateSync,x as futimes,S as futimesSync,he as glob,ge as globSync,ee as lchmod,te as lchmodSync,t as lchown,n as lchownSync,De as link,U as linkSync,Oe as lstat,W as lstatSync,r as lutimes,i as lutimesSync,ke as mkdir,G as mkdirSync,Ae as mkdtemp,K as mkdtempSync,je as open,C as openAsBlob,q as openSync,pe as opendir,me as opendirSync,be as promises,Me as read,Ne as readFile,J as readFileSync,w as readSync,Pe as readdir,Y as readdirSync,Fe as readlink,X as readlinkSync,T as readv,E as readvSync,Ie as realpath,ne as realpathSync,Le as rename,Z as renameSync,Re as rm,Q as rmSync,ze as rmdir,re as rmdirSync,Be as stat,ie as statSync,_e as statfs,ve as statfsSync,Ve as symlink,ae as symlinkSync,He as truncate,oe as truncateSync,Ue as unlink,se as unlinkSync,qe as unwatchFile,a as utimes,o as utimesSync,ce as watch,Je as watchFile,We as write,Ge as writeFile,le as writeFileSync,D as writeSync,O as writev,k as writevSync};
@@ -1 +1 @@
1
- import{__exportAll as e}from"./_virtual/_rolldown/runtime.js";import{decode as t,encodeUint8Array as n,getEncodingFromOptions as r}from"./encoding.js";import{normalizePath as i}from"./utils.js";import{createNodeError as a}from"./errors.js";import{watchAsync as o}from"./fs-watcher.js";import{lchmodAsync as s,lchownAsync as c,lutimesAsync as l,utimesAsync as u}from"./utimes.js";import{fchmodAsync as d,fchownAsync as f,fdatasyncAsync as p,fstatAsync as m,fsyncAsync as h,ftruncateAsync as g,futimesAsync as _,openAsBlob as v,readvAsync as y,writevAsync as b}from"./fd-ops.js";import{STAT_ATTRIBUTES as x,statsFrom as S}from"./stats.js";import{FileHandle as C}from"./file-handle.js";import{accessSync as w,appendFileSync as T,chmodSync as E,chownSync as D,copyFileSync as O,linkSync as k,mkdirSync as A,mkdtempAt as j,readdirSync as M,readlinkSync as N,realpathSync as P,renameSync as F,truncateSync as I,writeFileSync as L}from"./sync.js";import{cpAsync as R}from"./cp.js";import{opendirAsync as z}from"./dir.js";import{globAsync as B}from"./glob.js";import{statfsAsync as V}from"./statfs.js";import H from"@girs/glib-2.0";import U from"@girs/gio-2.0";import{join as W}from"node:path";var G=e({access:()=>access,appendFile:()=>appendFile,chmod:()=>chmod,chown:()=>chown,copyFile:()=>copyFile,cp:()=>R,default:()=>K,fchmod:()=>d,fchown:()=>f,fdatasync:()=>p,fstat:()=>m,fsync:()=>h,ftruncate:()=>g,futimes:()=>_,glob:()=>B,lchmod:()=>s,lchown:()=>c,link:()=>link,lstat:()=>lstat,lutimes:()=>l,mkdir:()=>mkdir,mkdtemp:()=>mkdtemp,open:()=>open,openAsBlob:()=>v,opendir:()=>z,readFile:()=>readFile,readdir:()=>readdir,readlink:()=>readlink,readv:()=>y,realpath:()=>realpath,rename:()=>rename,rm:()=>rm,rmdir:()=>rmdir,stat:()=>stat,statfs:()=>V,symlink:()=>symlink,truncate:()=>truncate,unlink:()=>unlink,utimes:()=>u,watch:()=>o,write:()=>write,writeFile:()=>writeFile,writev:()=>b});async function mkdir(e,t){return A(i(e),t)}async function readFile(e,t={encoding:null,flag:`r`}){if(e instanceof C||typeof e==`number`){let i=C.getInstance(e,`read`);return n(r(t,`buffer`),i._readToEndSync())}let o=i(e),s=U.File.new_for_path(o),c,l;try{[c,l]=await new Promise((e,t)=>{s.load_contents_async(null,(n,r)=>{try{e(s.load_contents_finish(r))}catch(e){t(e)}})})}catch(e){throw a(e,`open`,o)}if(!c)throw a(Error(`failed to read file`),`open`,o);return n(r(t,`buffer`),l)}async function mkdtemp(e,n){let i=r(n);return t(j(e),i)}async function writeFile(e,t,n){L(e,typeof t==`string`||t instanceof Uint8Array?t:String(t),n??null)}async function rmdir(e,t){let n=i(e),r=U.File.new_for_path(n);if((await new Promise((e,t)=>{r.query_info_async(`standard::type`,U.FileQueryInfoFlags.NONE,H.PRIORITY_DEFAULT,null,(i,o)=>{try{e(r.query_info_finish(o))}catch(e){t(a(e,`rmdir`,n))}})})).get_file_type()!==U.FileType.DIRECTORY)throw a(Object.assign(Error(),{code:4}),`rmdir`,n);if((await new Promise((e,t)=>{r.enumerate_children_async(`standard::name`,U.FileQueryInfoFlags.NONE,H.PRIORITY_DEFAULT,null,(i,o)=>{try{e(r.enumerate_children_finish(o))}catch(e){t(a(e,`rmdir`,n))}})})).next_file(null)!==null)throw a(Object.assign(Error(),{code:5}),`rmdir`,n);await new Promise((e,t)=>{r.delete_async(H.PRIORITY_DEFAULT,null,(i,o)=>{try{r.delete_finish(o),e()}catch(e){t(a(e,`rmdir`,n))}})})}async function unlink(e){let t=i(e),n=U.File.new_for_path(t);await new Promise((e,r)=>{n.delete_async(H.PRIORITY_DEFAULT,null,(i,o)=>{try{n.delete_finish(o),e()}catch(e){r(a(e,`unlink`,t))}})})}async function open(e,t,n){return new C({path:e,flags:t,mode:n})}async function write(e,t,n,r,i){return typeof t==`string`?_writeStr(e,t,n,r):_writeBuf(e,t,n,r,i)}async function _writeBuf(e,t,n,r,i){return{bytesWritten:(await C.getInstance(e,`write`).write(t,n,r,i)).bytesWritten,buffer:t}}async function _writeStr(e,t,n,r){return{bytesWritten:(await C.getInstance(e,`write`).write(t,n,r)).bytesWritten,buffer:t}}function queryInfoAsync(e,t,n,r){let o=i(e);return new Promise((e,i)=>{let s=U.File.new_for_path(o);s.query_info_async(x,t,H.PRIORITY_DEFAULT,null,(t,c)=>{try{e(S(s.query_info_finish(c),o,n,r?.bigint))}catch(e){i(a(e,n,o))}})})}async function stat(e,t){return queryInfoAsync(e,U.FileQueryInfoFlags.NONE,`stat`,t)}async function lstat(e,t){return queryInfoAsync(e,U.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,`lstat`,t)}async function readdir(e,t){try{return M(e,t)}catch(t){throw a(t,`scandir`,e)}}async function realpath(e){return P(e)}async function symlink(e,t,n){let r=i(t),o=i(e);return new Promise((e,t)=>{let n=U.File.new_for_path(r);n.make_symbolic_link_async(o,H.PRIORITY_DEFAULT,null,(i,s)=>{try{n.make_symbolic_link_finish(s),e()}catch(e){t(a(e,`symlink`,o,r))}})})}async function rm(e,t){let n=i(e),r=U.File.new_for_path(n),o=t?.recursive||!1,s=t?.force||!1,c;try{c=r.query_file_type(U.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)}catch(t){if(s)return;throw a(t,`rm`,e)}if(c===U.FileType.SYMBOLIC_LINK){await new Promise((t,n)=>{r.delete_async(H.PRIORITY_DEFAULT,null,(i,o)=>{try{r.delete_finish(o),t()}catch(r){if(s){t();return}n(a(r,`rm`,e))}})});return}if(c===U.FileType.DIRECTORY){let r=await readdir(e,{withFileTypes:!0});if(!o&&r.length)throw a(Object.assign(Error(),{code:5}),`rm`,e);for(let e of r)typeof e!=`string`&&await rm(W(n,e.name),t)}await new Promise((t,n)=>{r.delete_async(H.PRIORITY_DEFAULT,null,(i,o)=>{try{r.delete_finish(o),t()}catch(r){if(s){t();return}n(a(r,`rm`,e))}})})}async function rename(e,t){F(e,t)}async function copyFile(e,t,n){O(e,t,n)}async function access(e,t){w(e,t)}async function appendFile(e,t,n){T(e,t,n)}async function readlink(e,t){return N(e,t)}async function truncate(e,t){I(e,t)}async function chmod(e,t){E(e,t)}async function chown(e,t,n){D(e,t,n)}async function link(e,t){k(e,t)}var K={readFile,mkdir,mkdtemp,realpath,readdir,writeFile,rmdir,unlink,open,write,rm,lstat,symlink,stat,rename,copyFile,access,appendFile,readlink,truncate,chmod,chown,link,cp:R,opendir:z,glob:B,watch:o,statfs:V,utimes:u,lutimes:l,lchown:c,lchmod:s,fstat:m,ftruncate:g,fdatasync:p,fsync:h,fchmod:d,fchown:f,futimes:_,readv:y,writev:b,openAsBlob:v};export{access,appendFile,chmod,chown,copyFile,R as cp,K as default,d as fchmod,f as fchown,p as fdatasync,m as fstat,h as fsync,g as ftruncate,_ as futimes,B as glob,s as lchmod,c as lchown,link,lstat,l as lutimes,mkdir,mkdtemp,open,v as openAsBlob,z as opendir,G as promises_exports,readFile,readdir,readlink,y as readv,realpath,rename,rm,rmdir,stat,V as statfs,symlink,truncate,unlink,u as utimes,o as watch,write,writeFile,b as writev};
1
+ import{__exportAll as e}from"./_virtual/_rolldown/runtime.js";import{decode as t,encodeUint8Array as n,getEncodingFromOptions as r}from"./encoding.js";import{normalizePath as i}from"./utils.js";import{createNodeError as a}from"./errors.js";import{watchAsync as o}from"./fs-watcher.js";import{lchmodAsync as s,lchownAsync as c,lutimesAsync as l,utimesAsync as u}from"./utimes.js";import{fchmodAsync as d,fchownAsync as f,fdatasyncAsync as p,fstatAsync as m,fsyncAsync as h,ftruncateAsync as g,futimesAsync as _,openAsBlob as v,readvAsync as y,writevAsync as b}from"./fd-ops.js";import{STAT_ATTRIBUTES as x,statsFrom as S}from"./stats.js";import{FileHandle as C}from"./file-handle.js";import{accessSync as w,appendFileSync as T,chmodSync as E,chownSync as D,copyFileSync as O,linkSync as k,mkdirSync as A,mkdtempAt as j,readdirSync as M,readlinkSync as N,realpathSync as P,renameSync as F,truncateSync as I,writeFileSync as L}from"./sync.js";import{cpAsync as R}from"./cp.js";import{opendirAsync as z}from"./dir.js";import{globAsync as B}from"./glob.js";import{statfsAsync as V}from"./statfs.js";import{constants as H}from"./constants.js";import U from"@girs/glib-2.0";import W from"@girs/gio-2.0";import{join as G}from"node:path";var K=e({access:()=>access,appendFile:()=>appendFile,chmod:()=>chmod,chown:()=>chown,constants:()=>H,copyFile:()=>copyFile,cp:()=>R,default:()=>q,fchmod:()=>d,fchown:()=>f,fdatasync:()=>p,fstat:()=>m,fsync:()=>h,ftruncate:()=>g,futimes:()=>_,glob:()=>B,lchmod:()=>s,lchown:()=>c,link:()=>link,lstat:()=>lstat,lutimes:()=>l,mkdir:()=>mkdir,mkdtemp:()=>mkdtemp,open:()=>open,openAsBlob:()=>v,opendir:()=>z,readFile:()=>readFile,readdir:()=>readdir,readlink:()=>readlink,readv:()=>y,realpath:()=>realpath,rename:()=>rename,rm:()=>rm,rmdir:()=>rmdir,stat:()=>stat,statfs:()=>V,symlink:()=>symlink,truncate:()=>truncate,unlink:()=>unlink,utimes:()=>u,watch:()=>o,write:()=>write,writeFile:()=>writeFile,writev:()=>b});async function mkdir(e,t){return A(i(e),t)}async function readFile(e,t={encoding:null,flag:`r`}){if(e instanceof C||typeof e==`number`){let i=C.getInstance(e,`read`);return n(r(t,`buffer`),i._readToEndSync())}let o=i(e),s=W.File.new_for_path(o),c,l;try{[c,l]=await new Promise((e,t)=>{s.load_contents_async(null,(n,r)=>{try{e(s.load_contents_finish(r))}catch(e){t(e)}})})}catch(e){throw a(e,`open`,o)}if(!c)throw a(Error(`failed to read file`),`open`,o);return n(r(t,`buffer`),l)}async function mkdtemp(e,n){let i=r(n);return t(j(e),i)}async function writeFile(e,t,n){L(e,typeof t==`string`||t instanceof Uint8Array?t:String(t),n??null)}async function rmdir(e,t){let n=i(e),r=W.File.new_for_path(n);if((await new Promise((e,t)=>{r.query_info_async(`standard::type`,W.FileQueryInfoFlags.NONE,U.PRIORITY_DEFAULT,null,(i,o)=>{try{e(r.query_info_finish(o))}catch(e){t(a(e,`rmdir`,n))}})})).get_file_type()!==W.FileType.DIRECTORY)throw a(Object.assign(Error(),{code:4}),`rmdir`,n);if((await new Promise((e,t)=>{r.enumerate_children_async(`standard::name`,W.FileQueryInfoFlags.NONE,U.PRIORITY_DEFAULT,null,(i,o)=>{try{e(r.enumerate_children_finish(o))}catch(e){t(a(e,`rmdir`,n))}})})).next_file(null)!==null)throw a(Object.assign(Error(),{code:5}),`rmdir`,n);await new Promise((e,t)=>{r.delete_async(U.PRIORITY_DEFAULT,null,(i,o)=>{try{r.delete_finish(o),e()}catch(e){t(a(e,`rmdir`,n))}})})}async function unlink(e){let t=i(e),n=W.File.new_for_path(t);await new Promise((e,r)=>{n.delete_async(U.PRIORITY_DEFAULT,null,(i,o)=>{try{n.delete_finish(o),e()}catch(e){r(a(e,`unlink`,t))}})})}async function open(e,t,n){return new C({path:e,flags:t,mode:n})}async function write(e,t,n,r,i){return typeof t==`string`?_writeStr(e,t,n,r):_writeBuf(e,t,n,r,i)}async function _writeBuf(e,t,n,r,i){return{bytesWritten:(await C.getInstance(e,`write`).write(t,n,r,i)).bytesWritten,buffer:t}}async function _writeStr(e,t,n,r){return{bytesWritten:(await C.getInstance(e,`write`).write(t,n,r)).bytesWritten,buffer:t}}function queryInfoAsync(e,t,n,r){let o=i(e);return new Promise((e,i)=>{let s=W.File.new_for_path(o);s.query_info_async(x,t,U.PRIORITY_DEFAULT,null,(t,c)=>{try{e(S(s.query_info_finish(c),o,n,r?.bigint))}catch(e){i(a(e,n,o))}})})}async function stat(e,t){return queryInfoAsync(e,W.FileQueryInfoFlags.NONE,`stat`,t)}async function lstat(e,t){return queryInfoAsync(e,W.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,`lstat`,t)}async function readdir(e,t){try{return M(e,t)}catch(t){throw a(t,`scandir`,e)}}async function realpath(e){return P(e)}async function symlink(e,t,n){let r=i(t),o=i(e);return new Promise((e,t)=>{let n=W.File.new_for_path(r);n.make_symbolic_link_async(o,U.PRIORITY_DEFAULT,null,(i,s)=>{try{n.make_symbolic_link_finish(s),e()}catch(e){t(a(e,`symlink`,o,r))}})})}async function rm(e,t){let n=i(e),r=W.File.new_for_path(n),o=t?.recursive||!1,s=t?.force||!1,c;try{c=r.query_file_type(W.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)}catch(t){if(s)return;throw a(t,`rm`,e)}if(c===W.FileType.SYMBOLIC_LINK){await new Promise((t,n)=>{r.delete_async(U.PRIORITY_DEFAULT,null,(i,o)=>{try{r.delete_finish(o),t()}catch(r){if(s){t();return}n(a(r,`rm`,e))}})});return}if(c===W.FileType.DIRECTORY){let r=await readdir(e,{withFileTypes:!0});if(!o&&r.length)throw a(Object.assign(Error(),{code:5}),`rm`,e);for(let e of r)typeof e!=`string`&&await rm(G(n,e.name),t)}await new Promise((t,n)=>{r.delete_async(U.PRIORITY_DEFAULT,null,(i,o)=>{try{r.delete_finish(o),t()}catch(r){if(s){t();return}n(a(r,`rm`,e))}})})}async function rename(e,t){F(e,t)}async function copyFile(e,t,n){O(e,t,n)}async function access(e,t){w(e,t)}async function appendFile(e,t,n){T(e,t,n)}async function readlink(e,t){return N(e,t)}async function truncate(e,t){I(e,t)}async function chmod(e,t){E(e,t)}async function chown(e,t,n){D(e,t,n)}async function link(e,t){k(e,t)}var q={readFile,mkdir,mkdtemp,realpath,readdir,writeFile,rmdir,unlink,open,write,rm,lstat,symlink,stat,rename,copyFile,access,appendFile,readlink,truncate,chmod,chown,link,cp:R,opendir:z,glob:B,watch:o,statfs:V,utimes:u,lutimes:l,lchown:c,lchmod:s,fstat:m,ftruncate:g,fdatasync:p,fsync:h,fchmod:d,fchown:f,futimes:_,readv:y,writev:b,openAsBlob:v,constants:H};export{access,appendFile,chmod,chown,H as constants,copyFile,R as cp,q as default,d as fchmod,f as fchown,p as fdatasync,m as fstat,h as fsync,g as ftruncate,_ as futimes,B as glob,s as lchmod,c as lchown,link,lstat,l as lutimes,mkdir,mkdtemp,open,v as openAsBlob,z as opendir,K as promises_exports,readFile,readdir,readlink,y as readv,realpath,rename,rm,rmdir,stat,V as statfs,symlink,truncate,unlink,u as utimes,o as watch,write,writeFile,b as writev};
package/lib/esm/sync.js CHANGED
@@ -1 +1 @@
1
- import"./_virtual/_rolldown/runtime.js";import{decode as e,encodeUint8Array as t,getEncodingFromOptions as n}from"./encoding.js";import{normalizePath as r,randomName as i}from"./utils.js";import{createNodeError as a,isNotFoundError as o}from"./errors.js";import{FSWatcher as s}from"./fs-watcher.js";import{isStdFd as c,readStdFdAll as l,writeStdFdSync as u}from"./std-fd.js";import{normalizeMode as d}from"./posix-flags.js";import{Dirent as f}from"./dirent.js";import{classifyMkdirFailure as p,fsError as m}from"./fd-io.js";import{STAT_ATTRIBUTES as h,statsFrom as g}from"./stats.js";import{FileHandle as _}from"./file-handle.js";import v from"@girs/glib-2.0";import y from"@girs/gio-2.0";import{join as b}from"node:path";import{Buffer as x}from"node:buffer";import{existsSync as S}from"@gjsify/utils";import{isDarwin as C}from"@gjsify/utils/core";function statSync(e,t){let n=r(e);try{return g(y.File.new_for_path(n).query_info(h,y.FileQueryInfoFlags.NONE,null),n,`stat`,t?.bigint)}catch(e){if(t?.throwIfNoEntry===!1&&o(e))return;throw a(e,`stat`,n)}}function lstatSync(e,t){let n=r(e);try{return g(y.File.new_for_path(n).query_info(h,y.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null),n,`lstat`,t?.bigint)}catch(e){if(t?.throwIfNoEntry===!1&&o(e))return;throw a(e,`lstat`,n)}}function readdirSync(e,t){let n=r(e),i=y.File.new_for_path(n).enumerate_children(`standard::name,standard::type`,y.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null),a=[];try{let e=i.next_file(null);for(;e!==null;)a.push({name:e.get_name(),type:e.get_file_type()}),e=i.next_file(null)}finally{try{i.close(null)}catch{}}let o=[];for(let e of a){let r=b(n,e.name);if(t?.withFileTypes?o.push(new f(r,e.name,e.type)):o.push(e.name),t?.recursive&&e.type===y.FileType.DIRECTORY){let n=readdirSync(r,t);for(let t of n)typeof t==`string`?o.push(b(e.name,t)):o.push(t)}}return o}function realpathSync(e){let t=r(e);return resolveEveryComponent(y.File.new_for_path(t),{left:40},t)}function resolveEveryComponent(e,t,n){let r=e.get_parent();return expandSymlinks(r===null?e:y.File.new_for_path(resolveEveryComponent(r,t,n)).get_child(e.get_basename()),t,n)}function expandSymlinks(e,t,n){let r=e;for(;;){let e=r.query_info(`standard::is-symlink,standard::symlink-target`,y.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null);if(!e.get_is_symlink())return r.get_path();if(--t.left<0)throw Error(`ELOOP: too many levels of symbolic links, realpath '${n}'`);let i=e.get_symlink_target(),a=r.get_parent(),o=v.path_is_absolute(i)?y.File.new_for_path(i):(a??r).resolve_relative_path(i);r=y.File.new_for_path(resolveEveryComponent(o,t,n))}}realpathSync.native=realpathSync;function symlinkSync(e,t,n){let i=r(t),a=r(e);y.File.new_for_path(i).make_symbolic_link(a,null)}function readFileSync(e,i={encoding:null,flag:`r`}){if(e instanceof _&&(e=e.fd),typeof e==`number`&&c(e))return t(n(i,`buffer`),l(e));if(typeof e==`number`)return t(n(i,`buffer`),_.getInstance(e,`read`)._readToEndSync());let o=r(e),s=y.File.new_for_path(o);try{let[e,r]=s.load_contents(null);if(!e)throw a(Error(`failed to read file`),`read`,o);return t(n(i,`buffer`),r)}catch(e){throw e.code&&typeof e.code==`string`?e:a(e,`read`,o)}}function mkdirSync(e,t){let n=!1,i;t!=null&&(typeof t==`object`?(t.recursive&&(n=t.recursive),t.mode!==void 0&&(i=t.mode)):i=t),e=r(e);let a=d(i,511);if(n)return mkdirSyncRecursive(e,a);mkdirWithMode(e,a)}function mkdirWithMode(e,t){if(v.mkdir(e,t)!==0)throw p(e)}function mkdirSyncRecursive(e,t){if(v.mkdir(e,t)===0)return e;let n=p(e);if(n.code===`EEXIST`){if(v.file_test(e,v.FileTest.IS_DIR))return;throw n}if(n.code!==`ENOENT`)throw n;let r=b(e,`..`),i=y.File.new_for_path(r).get_path();if(i===e)throw n;let a=mkdirSyncRecursive(i,t);return mkdirWithMode(e,t),a??e}function rmdirSync(e,t){let n=r(e),i=y.File.new_for_path(n);try{if(i.query_info(`standard::type`,y.FileQueryInfoFlags.NONE,null).get_file_type()!==y.FileType.DIRECTORY)throw a(Object.assign(Error(),{code:4}),`rmdir`,n);if(i.enumerate_children(`standard::name`,y.FileQueryInfoFlags.NONE,null).next_file(null)!==null)throw a(Object.assign(Error(),{code:5}),`rmdir`,n);i.delete(null)}catch(e){throw e.code&&typeof e.code==`string`?e:a(e,`rmdir`,n)}}function unlinkSync(e){let t=r(e),n=y.File.new_for_path(t);try{n.delete(null)}catch(e){throw a(e,`unlink`,t)}}function writeWholeFile(e,t,i,a){let o=n(i,`utf8`),s=typeof i==`object`&&i?i:{},l=typeof t==`string`?x.from(t,o||`utf8`):t;if(typeof e==`number`||e instanceof _){if(typeof e==`number`&&c(e)){u(e,l);return}_.getInstance(e,`write`)._writeSync(l,null);return}let d=new _({path:r(e),flags:s.flag??a,mode:s.mode??438});try{d._writeSync(l,null)}finally{d._closeSync()}}function writeFileSync(e,t,n){writeWholeFile(e,t,n??null,`w`)}function renameSync(e,t){let n=r(e),i=r(t),o=y.File.new_for_path(n),s=y.File.new_for_path(i);try{o.move(s,y.FileCopyFlags.OVERWRITE,null,null)}catch(e){throw a(e,`rename`,n,i)}}function copyFileSync(e,t,n){let i=r(e),o=r(t),s=y.File.new_for_path(i),c=y.File.new_for_path(o),l=y.FileCopyFlags.NONE;n&&!(n&1)?l=y.FileCopyFlags.OVERWRITE:n||(l=y.FileCopyFlags.OVERWRITE);try{s.copy(c,l,null,null)}catch(e){throw a(e,`copyfile`,i,o)}stripPrivilegeBitsAfterCopy(c,i,o)}function stripPrivilegeBitsAfterCopy(e,t,n){try{let t=e.query_info(`unix::mode,standard::size`,y.FileQueryInfoFlags.NONE,null);if(t.get_size()===0)return;let n=t.get_attribute_uint32(`unix::mode`),r=n&-2049;if((C()||n&8)&&(r&=-1025),r===n)return;e.set_attribute_uint32(`unix::mode`,r,y.FileQueryInfoFlags.NONE,null)}catch(e){throw a(e,`copyfile`,t,n)}}function accessSync(e,t){let n=r(e),i=y.File.new_for_path(n);try{let e=i.query_info(`access::*`,y.FileQueryInfoFlags.NONE,null);if(t!==void 0&&t!==0){let r={code:14,message:`permission denied, access '${n}'`};if(t&4&&!e.get_attribute_boolean(`access::can-read`)||t&2&&!e.get_attribute_boolean(`access::can-write`)||t&1&&!e.get_attribute_boolean(`access::can-execute`))throw a(r,`access`,n)}}catch(e){throw e.code&&typeof e.code==`string`?e:a(e,`access`,n)}}function appendFileSync(e,t,n){writeWholeFile(e,t,n??null,`a`)}function readlinkSync(e,t){let n=r(e),i=y.File.new_for_path(n);try{let e=i.query_info(`standard::symlink-target`,y.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null).get_symlink_target();if(!e)throw Object.assign(Error(`EINVAL: invalid argument, readlink '${n}'`),{code:`EINVAL`,errno:-22,syscall:`readlink`,path:n});return(typeof t==`string`?t:t?.encoding)===`buffer`?x.from(e):e}catch(e){throw typeof e.code==`string`?e:a(e,`readlink`,n)}}function linkSync(e,t){let n=r(e),i=r(t);if(y.File.new_for_path(n).query_file_type(y.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)===y.FileType.UNKNOWN)throw Object.assign(Error(`ENOENT: no such file or directory, link '${n}' -> '${i}'`),{code:`ENOENT`,errno:-2,syscall:`link`,path:n,dest:i});if(y.File.new_for_path(i).query_file_type(y.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)!==y.FileType.UNKNOWN)throw Object.assign(Error(`EEXIST: file already exists, link '${n}' -> '${i}'`),{code:`EEXIST`,errno:-17,syscall:`link`,path:n,dest:i});let a=``;try{let[,,e,t]=v.spawn_sync(null,[`ln`,`--`,n,i],null,v.SpawnFlags.SEARCH_PATH,null);if(a=e?new TextDecoder().decode(e).trim():``,!v.spawn_check_wait_status(t))throw Error(`ln exited non-zero (${t})`);return}catch(e){throw a===``&&e instanceof Error&&(a=e.message),Object.assign(Error(`EPERM: operation not permitted, link '${n}' -> '${i}'`+(a?` (${a})`:``)),{code:`EPERM`,errno:-1,syscall:`link`,path:n,dest:i})}}function truncateSync(e,t){let n=r(e),i=y.File.new_for_path(n);try{let e=i.open_readwrite(null);try{e.get_output_stream().truncate(Math.max(0,t??0),null)}finally{e.close(null)}}catch(e){throw a(e,`truncate`,n)}}function chmodSync(e,t){let n=r(e),i=d(t);try{y.File.new_for_path(n).set_attribute_uint32(`unix::mode`,i,y.FileQueryInfoFlags.NONE,null)}catch(e){throw a(e,`chmod`,n)}}function chownSync(e,t,n){let i=r(e);try{let e=y.File.new_for_path(i),r=new y.FileInfo;t!==-1&&r.set_attribute_uint32(`unix::uid`,t),n!==-1&&r.set_attribute_uint32(`unix::gid`,n),e.set_attributes_from_info(r,y.FileQueryInfoFlags.NONE,null)}catch(e){throw a(e,`chown`,i)}}function watch(e,t,n){return typeof t==`function`&&(n=t,t=void 0),new s(r(e),t,n)}function openSync(e,t,n){return new _({path:e,flags:t,mode:n})}function mkdtempSync(t,r){let i=n(r),a=mkdtempAt(t);return i===`buffer`?x.from(a):e(a,i)}function mkdtempAt(e){for(let t=0;t<64;t++){let t=e+i();if(v.mkdir(t,448)===0)return t;let n=p(t);if(n.code!==`EEXIST`)throw n.syscall=`mkdtemp`,n}throw m(`EEXIST`,`mkdtemp`,e+`XXXXXX`)}function rmSync(e,t){let n=r(e),i=y.File.new_for_path(n),s=t?.recursive||!1,c=t?.force||!1,l;try{l=i.query_file_type(y.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)}catch(t){if(c&&o(t))return;throw a(t,`rm`,e)}if(l===y.FileType.SYMBOLIC_LINK){try{i.delete(null)}catch(t){if(c&&o(t))return;throw a(t,`rm`,e)}return}if(l===y.FileType.DIRECTORY){let r=readdirSync(e);if(!s&&r.length)throw a(Object.assign(Error(),{code:5}),`rm`,e);for(let e of r)rmSync(b(n,e),t)}try{i.delete(null)}catch(t){if(c&&o(t))return;throw a(t,`rm`,e)}}export{accessSync,appendFileSync,chmodSync,chownSync,copyFileSync,S as existsSync,linkSync,lstatSync,mkdirSync,mkdtempAt,mkdtempSync,openSync,readFileSync,readdirSync,readlinkSync,realpathSync,renameSync,rmSync,rmdirSync,statSync,symlinkSync,truncateSync,unlinkSync,watch,writeFileSync};
1
+ import"./_virtual/_rolldown/runtime.js";import{decode as e,encodeUint8Array as t,getEncodingFromOptions as n}from"./encoding.js";import{normalizePath as r,randomName as i}from"./utils.js";import{createNodeError as a,isNotFoundError as o}from"./errors.js";import{FSWatcher as s}from"./fs-watcher.js";import{isStdFd as c,readStdFdAll as l,writeStdFdSync as u}from"./std-fd.js";import{normalizeMode as d}from"./posix-flags.js";import{Dirent as f}from"./dirent.js";import{classifyMkdirFailure as p,fsError as m}from"./fd-io.js";import{STAT_ATTRIBUTES as h,statsFrom as g}from"./stats.js";import{FileHandle as _}from"./file-handle.js";import v from"@girs/glib-2.0";import y from"@girs/gio-2.0";import{join as b}from"node:path";import{Buffer as x}from"node:buffer";import{existsSync as S}from"@gjsify/utils";import{isDarwin as C}from"@gjsify/utils/core";function statSync(e,t){let n=r(e);try{return g(y.File.new_for_path(n).query_info(h,y.FileQueryInfoFlags.NONE,null),n,`stat`,t?.bigint)}catch(e){if(t?.throwIfNoEntry===!1&&o(e))return;throw a(e,`stat`,n)}}function lstatSync(e,t){let n=r(e);try{return g(y.File.new_for_path(n).query_info(h,y.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null),n,`lstat`,t?.bigint)}catch(e){if(t?.throwIfNoEntry===!1&&o(e))return;throw a(e,`lstat`,n)}}function readdirSync(e,t){let n=r(e),i=y.File.new_for_path(n).enumerate_children(`standard::name,standard::type`,y.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null),a=[];try{let e=i.next_file(null);for(;e!==null;)a.push({name:e.get_name(),type:e.get_file_type()}),e=i.next_file(null)}finally{try{i.close(null)}catch{}}let o=[];for(let e of a){let r=b(n,e.name);if(t?.withFileTypes?o.push(new f(r,e.name,e.type,void 0,n)):o.push(e.name),t?.recursive&&e.type===y.FileType.DIRECTORY){let n=readdirSync(r,t);for(let t of n)typeof t==`string`?o.push(b(e.name,t)):o.push(t)}}return o}function realpathSync(e){let t=r(e);return resolveEveryComponent(y.File.new_for_path(t),{left:40},t)}function resolveEveryComponent(e,t,n){let r=e.get_parent();return expandSymlinks(r===null?e:y.File.new_for_path(resolveEveryComponent(r,t,n)).get_child(e.get_basename()),t,n)}function expandSymlinks(e,t,n){let r=e;for(;;){let e=r.query_info(`standard::is-symlink,standard::symlink-target`,y.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null);if(!e.get_is_symlink())return r.get_path();if(--t.left<0)throw Error(`ELOOP: too many levels of symbolic links, realpath '${n}'`);let i=e.get_symlink_target(),a=r.get_parent(),o=v.path_is_absolute(i)?y.File.new_for_path(i):(a??r).resolve_relative_path(i);r=y.File.new_for_path(resolveEveryComponent(o,t,n))}}realpathSync.native=realpathSync;function symlinkSync(e,t,n){let i=r(t),a=r(e);y.File.new_for_path(i).make_symbolic_link(a,null)}function readFileSync(e,i={encoding:null,flag:`r`}){if(e instanceof _&&(e=e.fd),typeof e==`number`&&c(e))return t(n(i,`buffer`),l(e));if(typeof e==`number`)return t(n(i,`buffer`),_.getInstance(e,`read`)._readToEndSync());let o=r(e),s=y.File.new_for_path(o);try{let[e,r]=s.load_contents(null);if(!e)throw a(Error(`failed to read file`),`read`,o);return t(n(i,`buffer`),r)}catch(e){throw e.code&&typeof e.code==`string`?e:a(e,`read`,o)}}function mkdirSync(e,t){let n=!1,i;t!=null&&(typeof t==`object`?(t.recursive&&(n=t.recursive),t.mode!==void 0&&(i=t.mode)):i=t),e=r(e);let a=d(i,511);if(n)return mkdirSyncRecursive(e,a);mkdirWithMode(e,a)}function mkdirWithMode(e,t){if(v.mkdir(e,t)!==0)throw p(e)}function mkdirSyncRecursive(e,t){if(v.mkdir(e,t)===0)return e;let n=p(e);if(n.code===`EEXIST`){if(v.file_test(e,v.FileTest.IS_DIR))return;throw n}if(n.code!==`ENOENT`)throw n;let r=b(e,`..`),i=y.File.new_for_path(r).get_path();if(i===e)throw n;let a=mkdirSyncRecursive(i,t);return mkdirWithMode(e,t),a??e}function rmdirSync(e,t){let n=r(e),i=y.File.new_for_path(n);try{if(i.query_info(`standard::type`,y.FileQueryInfoFlags.NONE,null).get_file_type()!==y.FileType.DIRECTORY)throw a(Object.assign(Error(),{code:4}),`rmdir`,n);if(i.enumerate_children(`standard::name`,y.FileQueryInfoFlags.NONE,null).next_file(null)!==null)throw a(Object.assign(Error(),{code:5}),`rmdir`,n);i.delete(null)}catch(e){throw e.code&&typeof e.code==`string`?e:a(e,`rmdir`,n)}}function unlinkSync(e){let t=r(e),n=y.File.new_for_path(t);try{n.delete(null)}catch(e){throw a(e,`unlink`,t)}}function writeWholeFile(e,t,i,a){let o=n(i,`utf8`),s=typeof i==`object`&&i?i:{},l=typeof t==`string`?x.from(t,o||`utf8`):t;if(typeof e==`number`||e instanceof _){if(typeof e==`number`&&c(e)){u(e,l);return}_.getInstance(e,`write`)._writeSync(l,null);return}let d=new _({path:r(e),flags:s.flag??a,mode:s.mode??438});try{d._writeSync(l,null)}finally{d._closeSync()}}function writeFileSync(e,t,n){writeWholeFile(e,t,n??null,`w`)}function renameSync(e,t){let n=r(e),i=r(t),o=y.File.new_for_path(n),s=y.File.new_for_path(i);try{o.move(s,y.FileCopyFlags.OVERWRITE,null,null)}catch(e){throw a(e,`rename`,n,i)}}function copyFileSync(e,t,n){let i=r(e),o=r(t),s=y.File.new_for_path(i),c=y.File.new_for_path(o),l=y.FileCopyFlags.NONE;n&&!(n&1)?l=y.FileCopyFlags.OVERWRITE:n||(l=y.FileCopyFlags.OVERWRITE);try{s.copy(c,l,null,null)}catch(e){throw a(e,`copyfile`,i,o)}stripPrivilegeBitsAfterCopy(c,i,o)}function stripPrivilegeBitsAfterCopy(e,t,n){try{let t=e.query_info(`unix::mode,standard::size`,y.FileQueryInfoFlags.NONE,null);if(t.get_size()===0)return;let n=t.get_attribute_uint32(`unix::mode`),r=n&-2049;if((C()||n&8)&&(r&=-1025),r===n)return;e.set_attribute_uint32(`unix::mode`,r,y.FileQueryInfoFlags.NONE,null)}catch(e){throw a(e,`copyfile`,t,n)}}function accessSync(e,t){let n=r(e),i=y.File.new_for_path(n);try{let e=i.query_info(`access::*`,y.FileQueryInfoFlags.NONE,null);if(t!==void 0&&t!==0){let r={code:14,message:`permission denied, access '${n}'`};if(t&4&&!e.get_attribute_boolean(`access::can-read`)||t&2&&!e.get_attribute_boolean(`access::can-write`)||t&1&&!e.get_attribute_boolean(`access::can-execute`))throw a(r,`access`,n)}}catch(e){throw e.code&&typeof e.code==`string`?e:a(e,`access`,n)}}function appendFileSync(e,t,n){writeWholeFile(e,t,n??null,`a`)}function readlinkSync(e,t){let n=r(e),i=y.File.new_for_path(n);try{let e=i.query_info(`standard::symlink-target`,y.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null).get_symlink_target();if(!e)throw Object.assign(Error(`EINVAL: invalid argument, readlink '${n}'`),{code:`EINVAL`,errno:-22,syscall:`readlink`,path:n});return(typeof t==`string`?t:t?.encoding)===`buffer`?x.from(e):e}catch(e){throw typeof e.code==`string`?e:a(e,`readlink`,n)}}function linkSync(e,t){let n=r(e),i=r(t);if(y.File.new_for_path(n).query_file_type(y.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)===y.FileType.UNKNOWN)throw Object.assign(Error(`ENOENT: no such file or directory, link '${n}' -> '${i}'`),{code:`ENOENT`,errno:-2,syscall:`link`,path:n,dest:i});if(y.File.new_for_path(i).query_file_type(y.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)!==y.FileType.UNKNOWN)throw Object.assign(Error(`EEXIST: file already exists, link '${n}' -> '${i}'`),{code:`EEXIST`,errno:-17,syscall:`link`,path:n,dest:i});let a=``;try{let[,,e,t]=v.spawn_sync(null,[`ln`,`--`,n,i],null,v.SpawnFlags.SEARCH_PATH,null);if(a=e?new TextDecoder().decode(e).trim():``,!v.spawn_check_wait_status(t))throw Error(`ln exited non-zero (${t})`);return}catch(e){throw a===``&&e instanceof Error&&(a=e.message),Object.assign(Error(`EPERM: operation not permitted, link '${n}' -> '${i}'`+(a?` (${a})`:``)),{code:`EPERM`,errno:-1,syscall:`link`,path:n,dest:i})}}function truncateSync(e,t){let n=r(e),i=y.File.new_for_path(n);try{let e=i.open_readwrite(null);try{e.get_output_stream().truncate(Math.max(0,t??0),null)}finally{e.close(null)}}catch(e){throw a(e,`truncate`,n)}}function chmodSync(e,t){let n=r(e),i=d(t);try{y.File.new_for_path(n).set_attribute_uint32(`unix::mode`,i,y.FileQueryInfoFlags.NONE,null)}catch(e){throw a(e,`chmod`,n)}}function chownSync(e,t,n){let i=r(e);try{let e=y.File.new_for_path(i),r=new y.FileInfo;t!==-1&&r.set_attribute_uint32(`unix::uid`,t),n!==-1&&r.set_attribute_uint32(`unix::gid`,n),e.set_attributes_from_info(r,y.FileQueryInfoFlags.NONE,null)}catch(e){throw a(e,`chown`,i)}}function watch(e,t,n){return typeof t==`function`&&(n=t,t=void 0),new s(r(e),t,n)}function openSync(e,t,n){return new _({path:e,flags:t,mode:n})}function mkdtempSync(t,r){let i=n(r),a=mkdtempAt(t);return i===`buffer`?x.from(a):e(a,i)}function mkdtempAt(e){for(let t=0;t<64;t++){let t=e+i();if(v.mkdir(t,448)===0)return t;let n=p(t);if(n.code!==`EEXIST`)throw n.syscall=`mkdtemp`,n}throw m(`EEXIST`,`mkdtemp`,e+`XXXXXX`)}function rmSync(e,t){let n=r(e),i=y.File.new_for_path(n),s=t?.recursive||!1,c=t?.force||!1,l;try{l=i.query_file_type(y.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)}catch(t){if(c&&o(t))return;throw a(t,`rm`,e)}if(l===y.FileType.SYMBOLIC_LINK){try{i.delete(null)}catch(t){if(c&&o(t))return;throw a(t,`rm`,e)}return}if(l===y.FileType.DIRECTORY){let r=readdirSync(e);if(!s&&r.length)throw a(Object.assign(Error(),{code:5}),`rm`,e);for(let e of r)rmSync(b(n,e),t)}try{i.delete(null)}catch(t){if(c&&o(t))return;throw a(t,`rm`,e)}}export{accessSync,appendFileSync,chmodSync,chownSync,copyFileSync,S as existsSync,linkSync,lstatSync,mkdirSync,mkdtempAt,mkdtempSync,openSync,readFileSync,readdirSync,readlinkSync,realpathSync,renameSync,rmSync,rmdirSync,statSync,symlinkSync,truncateSync,unlinkSync,watch,writeFileSync};
@@ -17,6 +17,8 @@ declare class EventBus {
17
17
  off(event: string, fn: (...args: unknown[]) => void): this;
18
18
  emit(event: string, ...args: unknown[]): boolean;
19
19
  removeAllListeners(event?: string): this;
20
+ addListener(event: string, fn: (...args: unknown[]) => void): this;
21
+ removeListener(event: string, fn: (...args: unknown[]) => void): this;
20
22
  }
21
23
  export declare class ReadStream extends EventBus {
22
24
  readonly path: string;
@@ -0,0 +1,2 @@
1
+ declare const _default: () => Promise<void>;
2
+ export default _default;
@@ -0,0 +1,32 @@
1
+ import { type PosixOpenFlags } from './posix-flags.js';
2
+ declare const fixedConstants: {
3
+ F_OK: number;
4
+ R_OK: number;
5
+ W_OK: number;
6
+ X_OK: number;
7
+ COPYFILE_EXCL: number;
8
+ COPYFILE_FICLONE: number;
9
+ COPYFILE_FICLONE_FORCE: number;
10
+ S_IFMT: number;
11
+ S_IFREG: number;
12
+ S_IFDIR: number;
13
+ S_IFCHR: number;
14
+ S_IFBLK: number;
15
+ S_IFIFO: number;
16
+ S_IFLNK: number;
17
+ S_IFSOCK: number;
18
+ S_IRWXU: number;
19
+ S_IRUSR: number;
20
+ S_IWUSR: number;
21
+ S_IXUSR: number;
22
+ S_IRWXG: number;
23
+ S_IRGRP: number;
24
+ S_IWGRP: number;
25
+ S_IXGRP: number;
26
+ S_IRWXO: number;
27
+ S_IROTH: number;
28
+ S_IWOTH: number;
29
+ S_IXOTH: number;
30
+ };
31
+ export declare const constants: typeof fixedConstants & PosixOpenFlags;
32
+ export {};
@@ -36,8 +36,13 @@ export declare class Dirent implements OriginalDirent {
36
36
  * `info` is the lookup `fileType` came from, where the caller has one.
37
37
  * Passing it is what makes `fstatSync` answer about the FILE and not about
38
38
  * the procfs link that names its descriptor — see {@link _classifySpecialFile}.
39
+ *
40
+ * `parentPath` is the directory AS THE CALLER SPELLED IT, which is what Node
41
+ * reports for `opendir`/`readdir` entries (`'/a/b/'` stays `'/a/b/'`). Derived
42
+ * from `path` instead, it came back normalised — and whatever separator the
43
+ * caller glued the name on with decided the rest.
39
44
  */
40
- constructor(path: string, filename?: string, fileType?: Gio.FileType, info?: Gio.FileInfo);
45
+ constructor(path: string, filename?: string, fileType?: Gio.FileType, info?: Gio.FileInfo, parentPath?: string);
41
46
  /**
42
47
  * Classify a SPECIAL file type using the unix::mode attribute from Gio.FileInfo.
43
48
  * Falls back to marking nothing if the mode attribute is unavailable.
@@ -37,7 +37,7 @@ export declare function createNodeError(err: unknown, syscall: string, path: Pat
37
37
  * exceptions are `fs.close(fd)` and `WriteStream.close()`, genuinely optional and
38
38
  * silent — #1039 settled those and `fs-semantics.spec.ts` K-16 pins them, so do NOT
39
39
  * route them through here — plus `fs.rm`, which Node does not validate either (it
40
- * crashes inside `internal/fs/rimraf` instead; `status/open-todos.md` records it).
40
+ * crashes inside `internal/fs/rimraf` instead; `status/open-todos/README.md` records it).
41
41
  *
42
42
  * `argName` is a parameter because Node is not uniform: `opendir` says `"callback"`
43
43
  * and `watchFile` says `"listener"`, while the rest say `"cb"`.
@@ -13,37 +13,8 @@ import { Stats, BigIntStats } from './stats.js';
13
13
  import { Dirent } from './dirent.js';
14
14
  import { utimesSync, utimes, lutimesSync, lutimes, lchownSync, lchown, lchmodSync, lchmod } from './utimes.js';
15
15
  import { fstatSync, fstat, ftruncateSync, ftruncate, fdatasyncSync, fdatasync, fsyncSync, fsync, fchmodSync, fchmod, fchownSync, fchown, futimesSync, futimes, closeSync, readSync, writeSync, readvSync, readv, writevSync, writev, exists, openAsBlob } from './fd-ops.js';
16
- import { type PosixOpenFlags } from './posix-flags.js';
17
- declare const fixedConstants: {
18
- F_OK: number;
19
- R_OK: number;
20
- W_OK: number;
21
- X_OK: number;
22
- COPYFILE_EXCL: number;
23
- COPYFILE_FICLONE: number;
24
- COPYFILE_FICLONE_FORCE: number;
25
- S_IFMT: number;
26
- S_IFREG: number;
27
- S_IFDIR: number;
28
- S_IFCHR: number;
29
- S_IFBLK: number;
30
- S_IFIFO: number;
31
- S_IFLNK: number;
32
- S_IFSOCK: number;
33
- S_IRWXU: number;
34
- S_IRUSR: number;
35
- S_IWUSR: number;
36
- S_IXUSR: number;
37
- S_IRWXG: number;
38
- S_IRGRP: number;
39
- S_IWGRP: number;
40
- S_IXGRP: number;
41
- S_IRWXO: number;
42
- S_IROTH: number;
43
- S_IWOTH: number;
44
- S_IXOTH: number;
45
- };
46
- export declare const constants: typeof fixedConstants & PosixOpenFlags;
16
+ import { constants } from './constants.js';
17
+ export { constants };
47
18
  export { FSWatcher, StatWatcher, Stats, BigIntStats, Dirent, Dir, existsSync, readdirSync, readFileSync, writeFileSync, mkdirSync, rmdirSync, unlinkSync, mkdtemp, mkdtempSync, rmSync, statSync, openSync, realpathSync, symlinkSync, lstatSync, renameSync, copyFileSync, accessSync, appendFileSync, readlinkSync, linkSync, truncateSync, chmodSync, chownSync, cpSync, opendirSync, globSync, glob, watch, watchFile, unwatchFile, statfsSync, statfs, utimesSync, utimes, lutimesSync, lutimes, lchownSync, lchown, lchmodSync, lchmod, fstatSync, fstat, ftruncateSync, ftruncate, fdatasyncSync, fdatasync, fsyncSync, fsync, fchmodSync, fchmod, fchownSync, fchown, futimesSync, futimes, closeSync, readSync, writeSync, readvSync, readv, writevSync, writev, exists, openAsBlob, createReadStream, ReadStream, createWriteStream, WriteStream, promises, open, close, read, write, rm, realpath, readdir, symlink, lstat, stat, rename, copyFile, cp, access, appendFile, readlink, truncate, chmod, chown, mkdir, rmdir, readFile, writeFile, unlink, link, opendir, };
48
19
  declare const _default: {
49
20
  FSWatcher: typeof FSWatcher;
@@ -80,7 +51,7 @@ declare const _default: {
80
51
  S_IROTH: number;
81
52
  S_IWOTH: number;
82
53
  S_IXOTH: number;
83
- } & PosixOpenFlags;
54
+ } & import("./posix-flags.js").PosixOpenFlags;
84
55
  existsSync: typeof existsSync;
85
56
  readdirSync: typeof readdirSync;
86
57
  readFileSync: typeof readFileSync;
@@ -178,3 +149,4 @@ declare const _default: {
178
149
  opendir: typeof opendir;
179
150
  };
180
151
  export default _default;
152
+ export { _default as 'module.exports' };
@@ -7,6 +7,7 @@ import { statfsAsync } from './statfs.js';
7
7
  import { utimesAsync, lutimesAsync, lchownAsync, lchmodAsync } from './utimes.js';
8
8
  import { fstatAsync, ftruncateAsync, fdatasyncAsync, fsyncAsync, fchmodAsync, fchownAsync, futimesAsync, readvAsync, writevAsync, openAsBlob } from './fd-ops.js';
9
9
  import { FileHandle } from './file-handle.js';
10
+ import { constants } from './constants.js';
10
11
  import type { Dirent } from './dirent.js';
11
12
  import type { Stats, BigIntStats } from './stats.js';
12
13
  import type { OpenFlags, ReadOptions } from './types/index.js';
@@ -142,7 +143,7 @@ declare function chmod(path: PathLike, mode: number | string): Promise<void>;
142
143
  declare function chown(path: PathLike, uid: number, gid: number): Promise<void>;
143
144
  declare function link(existingPath: PathLike, newPath: PathLike): Promise<void>;
144
145
  export type { Dir };
145
- export { readFile, mkdir, mkdtemp, realpath, readdir, writeFile, rmdir, unlink, open, write, rm, lstat, symlink, stat, rename, copyFile, access, appendFile, readlink, truncate, chmod, chown, link, cpAsync as cp, opendirAsync as opendir, globAsync as glob, watchAsync as watch, statfsAsync as statfs, utimesAsync as utimes, lutimesAsync as lutimes, lchownAsync as lchown, lchmodAsync as lchmod, fstatAsync as fstat, ftruncateAsync as ftruncate, fdatasyncAsync as fdatasync, fsyncAsync as fsync, fchmodAsync as fchmod, fchownAsync as fchown, futimesAsync as futimes, readvAsync as readv, writevAsync as writev, openAsBlob, };
146
+ export { readFile, mkdir, mkdtemp, realpath, readdir, writeFile, rmdir, unlink, open, write, rm, lstat, symlink, stat, rename, copyFile, access, appendFile, readlink, truncate, chmod, chown, link, cpAsync as cp, opendirAsync as opendir, globAsync as glob, watchAsync as watch, statfsAsync as statfs, utimesAsync as utimes, lutimesAsync as lutimes, lchownAsync as lchown, lchmodAsync as lchmod, fstatAsync as fstat, ftruncateAsync as ftruncate, fdatasyncAsync as fdatasync, fsyncAsync as fsync, fchmodAsync as fchmod, fchownAsync as fchown, futimesAsync as futimes, readvAsync as readv, writevAsync as writev, openAsBlob, constants, };
146
147
  declare const _default: {
147
148
  readFile: typeof readFile;
148
149
  mkdir: typeof mkdir;
@@ -186,5 +187,34 @@ declare const _default: {
186
187
  readv: typeof readvAsync;
187
188
  writev: typeof writevAsync;
188
189
  openAsBlob: typeof openAsBlob;
190
+ constants: {
191
+ F_OK: number;
192
+ R_OK: number;
193
+ W_OK: number;
194
+ X_OK: number;
195
+ COPYFILE_EXCL: number;
196
+ COPYFILE_FICLONE: number;
197
+ COPYFILE_FICLONE_FORCE: number;
198
+ S_IFMT: number;
199
+ S_IFREG: number;
200
+ S_IFDIR: number;
201
+ S_IFCHR: number;
202
+ S_IFBLK: number;
203
+ S_IFIFO: number;
204
+ S_IFLNK: number;
205
+ S_IFSOCK: number;
206
+ S_IRWXU: number;
207
+ S_IRUSR: number;
208
+ S_IWUSR: number;
209
+ S_IXUSR: number;
210
+ S_IRWXG: number;
211
+ S_IRGRP: number;
212
+ S_IWGRP: number;
213
+ S_IXGRP: number;
214
+ S_IRWXO: number;
215
+ S_IROTH: number;
216
+ S_IWOTH: number;
217
+ S_IXOTH: number;
218
+ } & import("./posix-flags.js").PosixOpenFlags;
189
219
  };
190
220
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/fs",
3
- "version": "0.52.0",
3
+ "version": "0.54.0",
4
4
  "description": "Node.js fs module for Gjs",
5
5
  "module": "lib/esm/index.js",
6
6
  "types": "lib/types/index.d.ts",
@@ -66,9 +66,9 @@
66
66
  "fs"
67
67
  ],
68
68
  "devDependencies": {
69
- "@gjsify/cli": "^0.52.0",
70
- "@gjsify/unit": "^0.52.0",
71
- "@gjsify/web-streams": "^0.52.0",
69
+ "@gjsify/cli": "^0.54.0",
70
+ "@gjsify/unit": "^0.54.0",
71
+ "@gjsify/web-streams": "^0.54.0",
72
72
  "@types/node": "^25.9.2",
73
73
  "typescript": "^6.0.3"
74
74
  },
@@ -76,11 +76,11 @@
76
76
  "@girs/gio-2.0": "5.4.0",
77
77
  "@girs/giounix-2.0": "5.4.0",
78
78
  "@girs/glib-2.0": "5.4.0",
79
- "@gjsify/buffer": "^0.52.0",
80
- "@gjsify/events": "^0.52.0",
81
- "@gjsify/stream": "^0.52.0",
82
- "@gjsify/url": "^0.52.0",
83
- "@gjsify/utils": "^0.52.0"
79
+ "@gjsify/buffer": "^0.54.0",
80
+ "@gjsify/events": "^0.54.0",
81
+ "@gjsify/stream": "^0.54.0",
82
+ "@gjsify/url": "^0.54.0",
83
+ "@gjsify/utils": "^0.54.0"
84
84
  },
85
85
  "gjsify": {
86
86
  "runtimes": {