@gjsify/fs 0.39.0 → 0.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/esm/callback.js +1 -1
- package/lib/esm/cp.js +1 -1
- package/lib/esm/dir.js +1 -1
- package/lib/esm/errors.js +1 -1
- package/lib/esm/fd-io.js +1 -1
- package/lib/esm/fd-ops.js +1 -1
- package/lib/esm/file-handle.js +1 -1
- package/lib/esm/glob.js +1 -1
- package/lib/esm/index.js +1 -1
- package/lib/esm/promises.js +1 -1
- package/lib/esm/stat-watcher.js +1 -1
- package/lib/esm/statfs.js +1 -1
- package/lib/esm/sync.js +1 -1
- package/lib/esm/utimes.js +1 -1
- package/lib/types/callback.d.ts +19 -1
- package/lib/types/errors.d.ts +40 -0
- package/lib/types/file-handle.d.ts +34 -5
- package/lib/types/index.d.ts +3 -2
- package/package.json +10 -9
package/lib/esm/callback.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./_virtual/_rolldown/runtime.js";import{normalizePath as e}from"./utils.js";import{createNodeError as t}from"./errors.js";import{STAT_ATTRIBUTES as
|
|
1
|
+
import"./_virtual/_rolldown/runtime.js";import{normalizePath as e}from"./utils.js";import{createNodeError as t,requireCallback as n}from"./errors.js";import{STAT_ATTRIBUTES as r,statsFrom as i}from"./stats.js";import{FileHandle as a}from"./file-handle.js";import{accessSync as o,appendFileSync as s,chmodSync as c,chownSync as l,copyFileSync as u,linkSync as d,mkdirSync as f,mkdtempSync as p,readFileSync as m,readdirSync as h,readlinkSync as g,realpathSync as _,renameSync as v,rmdirSync as y,truncateSync as b,writeFileSync as x}from"./sync.js";import{open as S,rm as C}from"./promises.js";import w from"@girs/glib-2.0";import T from"@girs/gio-2.0";import{Buffer as E}from"node:buffer";function withHandle(e,t,n){try{return a.getInstance(e,t)}catch(e){return Promise.resolve().then(()=>n(e)),null}}function parseOptsCb(e,t){return typeof e==`function`?{options:{},callback:e}:{options:e??{},callback:n(t)}}function statImpl(n,a,o,s,c){let l=e(n),u=T.File.new_for_path(l);u.query_info_async(r,a,w.PRIORITY_DEFAULT,null,(e,n)=>{try{c(null,i(u.query_info_finish(n),l,o,s?.bigint))}catch(e){c(t(e,o,l))}})}function stat(e,t,n){let{options:r,callback:i}=parseOptsCb(t,n);statImpl(e,T.FileQueryInfoFlags.NONE,`stat`,r,i)}function lstat(e,t,n){let{options:r,callback:i}=parseOptsCb(t,n);statImpl(e,T.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,`lstat`,r,i)}function readdir(e,n,r){let{options:i,callback:a}=parseOptsCb(n,r);Promise.resolve().then(()=>{try{a(null,h(e,i))}catch(n){a(t(n,`readdir`,e))}})}function realpath(e,t,n){let{callback:r}=parseOptsCb(t,n);Promise.resolve().then(()=>{try{r(null,_(e))}catch(e){r(e)}})}function symlink(r,i,a,o){let s=typeof a==`function`?a:n(o);if(typeof s!=`function`)throw TypeError(`Callback must be a function. Received `+typeof s);let c=e(i),l=e(r),u=T.File.new_for_path(c);u.make_symbolic_link_async(l,w.PRIORITY_DEFAULT,null,(e,n)=>{try{u.make_symbolic_link_finish(n),s(null)}catch(e){s(t(e,`symlink`,l,c))}})}function open(e,...t){let r,i,a;switch(t.length){case 1:a=t[0];break;case 2:r=t[0],a=t[1];break;case 3:r=t[0],i=t[1],a=t[2];break;default:break}let o=n(a);S(e,r,i).then(e=>{o(null,e.fd)}).catch(e=>{o(e,-1)})}function write(e,t,...r){n(r[r.length-1]);let i=withHandle(e,`write`,e=>{let n=r[r.length-1];typeof t==`string`?n(e,0,``):n(e,0,E.from([]))});if(!i)return;if(typeof t==`string`){let e=r.pop(),n=r[0],a=r[1];i.write(t,n,a).then(t=>{e(null,t.bytesWritten,t.buffer)}).catch(t=>{e(t,0,``)});return}let a=r[r.length-1],o=r[0],s=r[1],c=r[2];i.write(t,o,s,c).then(e=>{a(null,e.bytesWritten,e.buffer)}).catch(e=>{a(e,0,E.from([]))})}function read(e,...t){let r=n(t[t.length-1]),i=withHandle(e,`read`,e=>{typeof r==`function`&&r(e,0,E.from([]))});if(!i)return;let a,o,s,c;if(!(t.length<=1))if(typeof t[0]==`object`&&!ArrayBuffer.isView(t[0])){let e=t[0];a=e.buffer,o=e.offset,s=e.length,c=e.position}else a=t[0],o=t[1],s=t[2],c=t[3];i.read(a,o,s,c).then(e=>{r(null,e.bytesRead,e.buffer)}).catch(e=>{r(e,0,E.from([]))})}function close(e,t){let done=e=>{typeof t==`function`&&t(e)},n=withHandle(e,`close`,done);n&&n.close().then(()=>done(null)).catch(e=>done(e))}function rm(e,...t){let n={},r=t[t.length-1];t.length>=2&&(n=t[0]),C(e,n).then(()=>{r(null)}).catch(e=>{r(e)})}function rename(e,t,r){n(r),Promise.resolve().then(()=>{try{v(e,t),r(null)}catch(e){r(e)}})}function copyFile(e,t,r,i){let a=typeof r==`function`?0:r,o=typeof r==`function`?r:n(i);Promise.resolve().then(()=>{try{u(e,t,a),o(null)}catch(e){o(e)}})}function access(e,t,r){let i=typeof t==`function`?void 0:t,a=typeof t==`function`?t:n(r);Promise.resolve().then(()=>{try{o(e,i),a(null)}catch(e){a(e)}})}function appendFile(e,t,r,i){let a=typeof r==`function`?r:n(i),o=typeof r==`function`?void 0:r;Promise.resolve().then(()=>{try{s(e,t,o),a(null)}catch(e){a(e)}})}function readlink(e,t,r){let i=typeof t==`function`?t:n(r),a=typeof t==`function`?void 0:t;Promise.resolve().then(()=>{try{i(null,g(e,a))}catch(e){i(e,``)}})}function truncate(e,t,r){let i=typeof t==`function`?0:t,a=typeof t==`function`?t:n(r);Promise.resolve().then(()=>{try{b(e,i),a(null)}catch(e){a(e)}})}function chmod(e,t,r){n(r),Promise.resolve().then(()=>{try{c(e,t),r(null)}catch(e){r(e)}})}function chown(e,t,r,i){n(i),Promise.resolve().then(()=>{try{l(e,t,r),i(null)}catch(e){i(e)}})}function mkdir(e,t,r){let i=typeof t==`function`?t:n(r),a=typeof t==`function`?void 0:t;Promise.resolve().then(()=>{try{f(e,a),i(null)}catch(e){i(e)}})}function mkdtemp(e,t,r){let i=typeof t==`function`?t:n(r),a=typeof t==`function`?void 0:t;Promise.resolve().then(()=>{let t;try{t=p(e,a)}catch(e){i(e,void 0);return}i(null,t)})}function rmdir(e,t,r){let i=typeof t==`function`?t:n(r),a=typeof t==`function`?void 0:t;Promise.resolve().then(()=>{try{y(e,a),i(null)}catch(e){i(e)}})}function readFile(e,t,r){let i=typeof t==`function`?t:n(r),a=typeof t==`function`?void 0:t;Promise.resolve().then(()=>{try{let t=typeof a==`string`?{encoding:a,flag:`r`}:{encoding:a?.encoding??null,flag:a?.flag??`r`};i(null,m(e,t))}catch(e){i(e,null)}})}function writeFile(e,t,r,i){let a=typeof r==`function`?r:n(i),o=typeof r==`function`?void 0:r;Promise.resolve().then(()=>{try{x(e,t,o),a(null)}catch(e){a(e)}})}function link(e,t,r){n(r),Promise.resolve().then(()=>{try{d(e,t),r(null)}catch(e){r(e)}})}function unlink(t,r){n(r);let i=e(t);Promise.resolve().then(()=>{w.unlink(i),r(null)})}export{access,appendFile,chmod,chown,close,copyFile,link,lstat,mkdir,mkdtemp,open,read,readFile,readdir,readlink,realpath,rename,rm,rmdir,stat,symlink,truncate,unlink,write,writeFile};
|
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}from"./errors.js";import
|
|
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};
|
package/lib/esm/dir.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./_virtual/_rolldown/runtime.js";import{normalizePath as e}from"./utils.js";import{
|
|
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};
|
package/lib/esm/errors.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./_virtual/_rolldown/runtime.js";import{createNodeError as e,isNotFoundError as t}from"@gjsify/utils/core";function createNodeError(t,n,r,i){return typeof t?.code==`string`?t:e(t,n,{path:r.toString(),dest:i?.toString()})}export{createNodeError,t as isNotFoundError};
|
|
1
|
+
import"./_virtual/_rolldown/runtime.js";import{createNodeError as e,isNotFoundError as t}from"@gjsify/utils/core";function createNodeError(t,n,r,i){return typeof t?.code==`string`?t:e(t,n,{path:r.toString(),dest:i?.toString()})}function requireCallback(e,t=`cb`){if(typeof e==`function`)return e;let n=TypeError(`The "${t}" argument must be of type function. Received ${describeReceived(e)}`);throw n.code=`ERR_INVALID_ARG_TYPE`,n}function describeReceived(e){if(e==null)return String(e);if(typeof e==`object`){let t=e.constructor?.name;return`an instance of ${t&&t.length>0?t:`Object`}`}if(typeof e==`string`){let t=e.length>25?`${e.slice(0,25)}...`:e;return t.includes(`'`)?`type string ("${t}")`:`type string ('${t}')`}return typeof e==`bigint`?`type bigint (${e}n)`:typeof e==`symbol`?`type symbol (${e.toString()})`:`type ${typeof e} (${String(e)})`}function invalidState(e){let t=Error(`Invalid state: ${e}`);return t.code=`ERR_INVALID_STATE`,t}export{createNodeError,invalidState,t as isNotFoundError,requireCallback};
|
package/lib/esm/fd-io.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./_virtual/_rolldown/runtime.js";import{createNodeError as e}from"./errors.js";import t from"@girs/glib-2.0";import n from"@girs/gio-2.0";import r
|
|
1
|
+
import"./_virtual/_rolldown/runtime.js";import{createNodeError as e}from"./errors.js";import t from"@girs/glib-2.0";import n from"@girs/gio-2.0";import{splitPathComponents as r}from"@gjsify/utils/core";import i from"@girs/giounix-2.0";const a={EPERM:-1,ENOENT:-2,EIO:-5,ENXIO:-6,EBADF:-9,EACCES:-13,EEXIST:-17,ENOTDIR:-20,EISDIR:-21,EINVAL:-22,ENFILE:-23,EMFILE:-24,ETXTBSY:-26,ENOSPC:-28,ESPIPE:-29,EROFS:-30,ENAMETOOLONG:-36,ENOTEMPTY:-39,ELOOP:-40};function fsError(e,t,n,r){let i=`${e}: ${describe(e)}, ${t}`;n&&(i+=` '${n}'`),r&&(i+=` -> '${r}'`);let o=Error(i);return o.code=e,o.errno=a[e]??-1,o.syscall=t,n&&(o.path=n),r&&(o.dest=r),o}function describe(e){switch(e){case`ENOENT`:return`no such file or directory`;case`EEXIST`:return`file already exists`;case`EACCES`:return`permission denied`;case`EISDIR`:return`illegal operation on a directory`;case`ENOTDIR`:return`not a directory`;case`EBADF`:return`bad file descriptor`;case`EPERM`:return`operation not permitted`;case`EINVAL`:return`invalid argument`;case`ELOOP`:return`too many symbolic links encountered`;case`ENAMETOOLONG`:return`name too long`;case`EMFILE`:return`too many open files`;case`ENFILE`:return`file table overflow`;case`EROFS`:return`read-only file system`;case`ESPIPE`:return`invalid seek`;case`ENXIO`:return`no such device or address`;default:return`i/o error`}}let o=null;function hasProcFd(){return o===null&&(o=t.file_test(`/proc/self/fd`,t.FileTest.IS_DIR)),o}function fdPath(e){return hasProcFd()?`/proc/self/fd/${e}`:null}function openFd(e,n,r){let i=t.open(e,n.posix,r);if(i<0)throw classifyOpenFailure(e,n);return i}function closeFd(e){t.close(e)}function classifyOpenFailure(e,t){let r=nameTooLong(e,`open`);if(r)return r;let i=n.File.new_for_path(e),a=null,o=!1;try{let e=i.query_info(`standard::type,standard::symlink-target,unix::mode,access::can-read,access::can-write`,n.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null);answered(e)?a=e:o=!0}catch{a=null}if(o)return refusalNotAboutThePath(e,t,i,null);if(a){if(t.excl)return fsError(`EEXIST`,`open`,e);if(a.get_file_type()===n.FileType.SYMBOLIC_LINK&&!t.nofollow){let n=walkSymlinkChain(i);if(n===`loop`)return fsError(`ELOOP`,`open`,e);if(n===`too-long`)return fsError(`ENAMETOOLONG`,`open`,e);if(n===`dangling`&&!t.creat)return fsError(`ENOENT`,`open`,e)}return a.get_file_type()===n.FileType.DIRECTORY&&t.writable?fsError(`EISDIR`,`open`,e):t.directory&&a.get_file_type()!==n.FileType.DIRECTORY?fsError(`ENOTDIR`,`open`,e):refusalNotAboutThePath(e,t,i,a)}if(ancestorIsNotADirectory(i))return fsError(`ENOTDIR`,`open`,e);if(!t.creat)return fsError(`ENOENT`,`open`,e);let s=i.get_parent();if(!s)return fsError(`ENOENT`,`open`,e);try{s.query_info(`standard::type`,n.FileQueryInfoFlags.NONE,null)}catch{return fsError(`ENOENT`,`open`,e)}return refusalNotAboutThePath(e,t,i,null)}function ancestorIsNotADirectory(e){for(let t=e.get_parent();t;t=t.get_parent()){let e;try{e=t.query_info(`standard::type`,n.FileQueryInfoFlags.NONE,null)}catch{continue}return answered(e)?e.get_file_type()!==n.FileType.DIRECTORY:!1}return!1}function answered(e){return e!==null&&e.has_attribute(`standard::type`)}function nameTooLong(e,t){let n=new TextEncoder;if(n.encode(e).length>4096)return fsError(`ENAMETOOLONG`,t,e);for(let i of r(e))if(n.encode(i).length>255)return fsError(`ENAMETOOLONG`,t,e);return null}function walkSymlinkChain(e){let t=new TextEncoder,r=e;for(let e=0;e<40;e++){let e;try{e=r.query_info(`standard::type,standard::symlink-target`,n.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)}catch{return`dangling`}if(!answered(e)||e.get_file_type()!==n.FileType.SYMBOLIC_LINK)return`resolved`;let i=e.get_symlink_target();if(!i)return`dangling`;if(t.encode(i).length>4096)return`too-long`;let a=r.get_parent();r=i.startsWith(`/`)?n.File.new_for_path(i):a?.resolve_relative_path(i)??n.File.new_for_path(i)}return`loop`}function refusalNotAboutThePath(e,n,r,i){let a=t.open(`/dev/null`,0,0);if(a<0)return fsError(`EMFILE`,`open`,e);t.close(a);let o=i!==null&&(i.get_attribute_uint32(`unix::mode`)&146)==0;if((n.writable||n.creat)&&!o)try{if(r.query_filesystem_info(`filesystem::readonly`,null).get_attribute_boolean(`filesystem::readonly`))return fsError(`EROFS`,`open`,e)}catch{}return i&¬hingOnTheOtherEnd(n,i)?fsError(`ENXIO`,`open`,e):fsError(`EACCES`,`open`,e)}function nothingOnTheOtherEnd(e,t){if(!t.has_attribute(`unix::mode`))return!1;let n=t.get_attribute_uint32(`unix::mode`)&61440;if(!(n===8192||n===24576||n===4096))return!1;let permits=e=>t.has_attribute(e)&&t.get_attribute_boolean(e);return!(e.readable&&!permits(`access::can-read`)||e.writable&&!permits(`access::can-write`))}function classifyMkdirFailure(e){let t=nameTooLong(e,`mkdir`);if(t)return t;let r=n.File.new_for_path(e);try{return answered(r.query_info(`standard::type`,n.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null))?fsError(`EEXIST`,`mkdir`,e):fsError(`EACCES`,`mkdir`,e)}catch{}let i=r.get_parent();if(!i)return fsError(`ENOENT`,`mkdir`,e);try{let t=i.query_info(`standard::type`,n.FileQueryInfoFlags.NONE,null);if(answered(t)&&t.get_file_type()!==n.FileType.DIRECTORY)return fsError(`ENOTDIR`,`mkdir`,e)}catch{return fsError(`ENOENT`,`mkdir`,e)}return fsError(`EACCES`,`mkdir`,e)}const s=new Map,c=new Map,l=new Map;function seekHandle(e){let n=s.get(e);return n||(n=t.IOChannel.unix_new(e),n.set_encoding(null),n.set_buffered(!1),n.set_close_on_unref(!1),s.set(e,n)),n}function input(e){let t=c.get(e);return t||(t=i.InputStream.new(e,!1),c.set(e,t)),t}function output(e){let t=l.get(e);return t||(t=i.OutputStream.new(e,!1),l.set(e,t)),t}const u=new Map;function isSeekableFd(e,t){let n=u.get(e);return n===void 0&&(n=probeSeekable(e,t),u.set(e,n)),n}function probeSeekable(e,r){try{let t=n.File.new_for_path(fdPath(e)??r).query_info(`unix::mode`,n.FileQueryInfoFlags.NONE,null);if(t.has_attribute(`unix::mode`)){let e=t.get_attribute_uint32(`unix::mode`)&61440;if(e===4096||e===49152)return!1}}catch{}try{return seekHandle(e).seek_position(0,t.SeekType.CUR),!0}catch{return!1}}function seekFd(e,n){seekHandle(e).seek_position(n,t.SeekType.SET)}function tellFd(e){if(!hasProcFd())return null;try{let[n,r]=t.file_get_contents(`/proc/self/fdinfo/${e}`);if(!n)return null;let i=/^pos:\s*(\d+)/m.exec(new TextDecoder().decode(r));return i?Number(i[1]):null}catch{return null}}function readFd(e,t){return t<=0?new Uint8Array:input(e).read_bytes(t,null).get_data()??new Uint8Array}function writeFd(e,t){if(t.length===0)return 0;let[,n]=output(e).write_all(t,null);return n}function fsyncFd(e){output(e).flush(null),t.fsync(e)}function releaseFd(e){let t=l.get(e);if(t)try{t.flush(null)}catch{}s.delete(e),c.delete(e),l.delete(e),u.delete(e)}function sizeOfFd(e,t){let r=fdPath(e)??t,i=n.File.new_for_path(r).query_info(`standard::size`,n.FileQueryInfoFlags.NONE,null);return Number(i.get_size())}function truncateFd(t,r,i){let a=n.File.new_for_path(fdPath(t)??i),o;try{let e=a.append_to(n.FileCreateFlags.NONE,null);try{e.truncate(r,null)}finally{e.close(null)}return}catch(e){o=e}try{let e=a.open_readwrite(null);try{e.get_output_stream().truncate(r,null)}finally{e.close(null)}return}catch{}throw e(o,`ftruncate`,i)}export{answered,classifyMkdirFailure,classifyOpenFailure,closeFd,fdPath,fsError,fsyncFd,hasProcFd,isSeekableFd,openFd,readFd,releaseFd,seekFd,sizeOfFd,tellFd,truncateFd,writeFd};
|
package/lib/esm/fd-ops.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./_virtual/_rolldown/runtime.js";import{normalizePath as e}from"./utils.js";import{
|
|
1
|
+
import"./_virtual/_rolldown/runtime.js";import{normalizePath as e}from"./utils.js";import{requireCallback as t}from"./errors.js";import{utimesSync as n}from"./utimes.js";import{isStdFd as r,readStdFdSync as i,writeStdFdSync as a}from"./std-fd.js";import{FileHandle as o}from"./file-handle.js";import{chmodSync as s,chownSync as c,readFileSync as l,statSync as u}from"./sync.js";function getFH(e,t){return o.getInstance(e,t)}function fstatSync(e,t){return u(getFH(e,`fstat`)._fdStatTarget(),t)}function fstat(e,n,r){let i=typeof n==`function`?n:t(r);fstatAsync(e,typeof n==`function`?{}:n).then(e=>i(null,e),e=>i(e,void 0))}async function fstatAsync(e,t){return t?.bigint,fstatSync(e,t)}function ftruncateSync(e,t=0){getFH(e,`ftruncate`)._truncateSync(t)}function ftruncate(e,n,r){let i=typeof n==`function`?n:t(r);ftruncateAsync(e,typeof n==`function`?0:n).then(()=>i(null),i)}async function ftruncateAsync(e,t=0){ftruncateSync(e,t)}function fdatasyncSync(e){getFH(e,`fdatasync`)._flushSync()}function fdatasync(e,n){t(n),Promise.resolve().then(()=>fdatasyncSync(e)).then(()=>n(null),n)}async function fdatasyncAsync(e){fdatasyncSync(e)}function fsyncSync(e){getFH(e,`fsync`)._flushSync()}function fsync(e,n){t(n),Promise.resolve().then(()=>fsyncSync(e)).then(()=>n(null),n)}async function fsyncAsync(e){fsyncSync(e)}function fchmodSync(e,t){s(getFH(e,`fchmod`)._fdStatTarget(),t)}function fchmod(e,n,r){t(r),Promise.resolve().then(()=>fchmodSync(e,n)).then(()=>r(null),r)}async function fchmodAsync(e,t){fchmodSync(e,t)}function fchownSync(t,n,r){c(e(getFH(t,`fchown`).options.path),n,r)}function fchown(e,n,r,i){t(i),Promise.resolve().then(()=>fchownSync(e,n,r)).then(()=>i(null),i)}async function fchownAsync(e,t,n){fchownSync(e,t,n)}function futimesSync(t,r,i){n(e(getFH(t,`futimes`).options.path),r,i)}function futimes(e,n,r,i){t(i),Promise.resolve().then(()=>futimesSync(e,n,r)).then(()=>i(null),i)}async function futimesAsync(e,t,n){futimesSync(e,t,n)}function closeSync(e){r(e)||getFH(e,`close`)._closeSync()}function readSync(e,t,n,a,o){let s=0;return typeof n==`object`&&n?(s=n.offset??0,a=n.length??t.byteLength-s,o=n.position??null):(s=n??0,a??=t.byteLength-s),r(e)?i(e,t,s,a):getFH(e,`read`)._readSync(t,s,a,o??null)}function writeSync(e,t,n,i,o){let s;if(typeof t==`string`)s=new TextEncoder().encode(t),typeof n==`number`&&(o=n);else{let e=typeof n==`number`?n:0,r=typeof i==`number`?i:t.byteLength-e;s=new Uint8Array(t.buffer,t.byteOffset+e,r)}return r(e)?a(e,s):getFH(e,`write`)._writeSync(s,o??null)}function readvSync(e,t,n){let r=0;for(let i of t){let t=readSync(e,i,0,i.byteLength,n==null?null:n+r);if(r+=t,t<i.byteLength)break}return r}function readv(e,n,r,i){let a=typeof r==`function`?r:t(i);readvAsync(e,n,typeof r==`function`?null:r).then(e=>a(null,e.bytesRead,e.buffers),e=>a(e,0,n))}async function readvAsync(e,t,n){return{bytesRead:readvSync(e,t,n),buffers:t}}function writevSync(e,t,n){let r=0;for(let i of t){let t=writeSync(e,i,0,i.byteLength,n==null?null:n+r);r+=t}return r}function writev(e,n,r,i){let a=typeof r==`function`?r:t(i);writevAsync(e,n,typeof r==`function`?null:r).then(e=>a(null,e.bytesWritten,e.buffers),e=>a(e,0,n))}async function writevAsync(e,t,n){return{bytesWritten:writevSync(e,t,n),buffers:t}}function exists(n,r){t(r);try{u(e(n)),r(!0)}catch{r(!1)}}async function openAsBlob(t,n){let r=l(e(t));return new Blob([r],{type:n?.type??``})}export{closeSync,exists,fchmod,fchmodAsync,fchmodSync,fchown,fchownAsync,fchownSync,fdatasync,fdatasyncAsync,fdatasyncSync,fstat,fstatAsync,fstatSync,fsync,fsyncAsync,fsyncSync,ftruncate,ftruncateAsync,ftruncateSync,futimes,futimesAsync,futimesSync,openAsBlob,readSync,readv,readvAsync,readvSync,writeSync,writev,writevAsync,writevSync};
|
package/lib/esm/file-handle.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./_virtual/_rolldown/runtime.js";import{encodeUint8Array as e,getEncodingFromOptions as t}from"./encoding.js";import{normalizePath as n}from"./utils.js";import{
|
|
1
|
+
import"./_virtual/_rolldown/runtime.js";import{encodeUint8Array as e,getEncodingFromOptions as t}from"./encoding.js";import{normalizePath as n}from"./utils.js";import{invalidState as r}from"./errors.js";import{ReadStream as i}from"./read-stream.js";import{normalizeMode as a,parseOpenFlags as o}from"./posix-flags.js";import{WriteStream as s}from"./write-stream.js";import{closeFd as c,fdPath as l,fsError as u,fsyncFd as d,isSeekableFd as f,openFd as p,readFd as m,releaseFd as h,seekFd as g,sizeOfFd as _,tellFd as v,truncateFd as y,writeFd as b}from"./fd-io.js";import{STAT_ATTRIBUTES as x,statsFrom as S}from"./stats.js";import{chmodSync as C,chownSync as w}from"./sync.js";import T from"@girs/glib-2.0";import E from"@girs/gio-2.0";import{Buffer as D}from"node:buffer";import{createInterface as O}from"node:readline";var k=class FileHandle{options;_gFile;_pathStr;_spec;_pos=0;_closed=!1;_webStreamLocked=!1;static instances={};constructor(e){this.options=e,this.options.flags??=`r`;let t=n(e.path);this._spec=o(this.options.flags),this.options.mode??=438;let r=a(this.options.mode,438);return this.fd=p(t,this._spec,r),this._pathStr=t,this._gFile=E.File.new_for_path(t),FileHandle.instances[this.fd]=this,FileHandle.getInstance(this.fd)}_readCore(e,t,n,r){if(this._assertOpen(`read`),!this._spec.readable)throw u(`EBADF`,`read`,this._pathStr);if(n>e.byteLength-t){let r=RangeError(`The value of "length" is out of range. It must be <= ${e.byteLength-t}. Received ${n}`);throw r.code=`ERR_OUT_OF_RANGE`,r}let i=r!=null&&r>=0,a=f(this.fd,this._pathStr);if(i&&!a)throw u(`ESPIPE`,`read`,this._pathStr);let o=i?r:this._pos;a&&g(this.fd,o);let s=m(this.fd,n);return s.length>0&&new Uint8Array(e.buffer,e.byteOffset+t,s.length).set(s),!i&&a&&(this._pos=o+s.length),s.length}_writeCore(e,t){if(this._assertOpen(`write`),!this._spec.writable)throw u(`EBADF`,`write`,this._pathStr);if(this._spec.append){let t=b(this.fd,e);return this._pos=v(this.fd)??_(this.fd,this._pathStr),t}let n=t!=null&&t>=0,r=f(this.fd,this._pathStr);if(n&&!r)throw u(`ESPIPE`,`write`,this._pathStr);let i=n?t:this._pos;r&&g(this.fd,i);let a=b(this.fd,e);return!n&&r&&(this._pos=i+a),a}_assertOpen(e){if(this._closed)throw u(`EBADF`,e,this._pathStr)}_truncateCore(e){if(this._assertOpen(`ftruncate`),!this._spec.writable)throw u(`EINVAL`,`ftruncate`,this._pathStr);y(this.fd,Math.max(0,e),this._pathStr)}_readToEnd(){let e=[],t=0;for(;;){let n=new Uint8Array(64*1024),r=this._readCore(n,0,n.length,null);if(r===0)break;e.push(n.subarray(0,r)),t+=r}let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}_fdTarget(){return l(this.fd)??this._pathStr}fd;static getInstance(e,t=`read`){let n=e instanceof FileHandle?e.fd:e,r=FileHandle.instances[n];if(!r)throw u(`EBADF`,t);return r}async appendFile(e,t){await this.writeFile(e,t)}async chown(e,t){this._assertOpen(`fchown`),w(n(this.options.path),e,t)}async chmod(e){this._assertOpen(`fchmod`),C(this._fdTarget(),e)}createReadStream(e){return new i(this.options.path,{...e,fd:this.fd})}createWriteStream(e){return new s(this.options.path,{...e,fd:this.fd,fdFromHandle:!0})}async datasync(){this._assertOpen(`fdatasync`),d(this.fd)}async sync(){this._assertOpen(`fsync`),d(this.fd)}async read(...e){let t,n,r,i;if(typeof e[0]==`object`&&!(e[0]instanceof Uint8Array)&&!(e[0]instanceof D)){let a=e[0];t=a.buffer,n=a.offset,r=a.length,i=a.position}else t=e[0],n=e[1],r=e[2],i=e[3];let a=t,o=n??0,s=r??(a?a.byteLength-o:65536);return{bytesRead:this._readCore(t,o,s,i??null),buffer:t}}readableWebStream(){if(this._closed)throw r(`The FileHandle is closed`);if(this._webStreamLocked)throw r(`The FileHandle is locked`);let e=globalThis.ReadableStream;if(typeof e!=`function`)throw Error(`readableWebStream() requires a global ReadableStream. Import "node:stream/web" or "@gjsify/web-streams/register" before calling this method.`);return this._webStreamLocked=!0,new e({type:`bytes`,pull:e=>{if(this._closed){e.close(),e.byobRequest?.respond(0);return}let t=e.byobRequest?.view,n=t?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):new Uint8Array(64*1024),r;try{r=this._readCore(n,0,n.length,null)}catch(t){e.error(t);return}if(r===0){e.close(),e.byobRequest?.respond(0);return}if(e.byobRequest){e.byobRequest.respond(r);return}e.enqueue(n.subarray(0,r))}})}async readFile(n){return e(t(n,`buffer`),this._readToEnd())}readLines(e){return O({input:this.createReadStream(e),crlfDelay:1/0})}async stat(e){this._assertOpen(`fstat`);let t=E.File.new_for_path(this._fdTarget());return S(await new Promise((e,n)=>{t.query_info_async(x,E.FileQueryInfoFlags.NONE,T.PRIORITY_DEFAULT,null,(r,i)=>{try{e(t.query_info_finish(i))}catch(e){n(e)}})}),this._pathStr,`fstat`,e?.bigint)}async truncate(e=0){this._truncateCore(e)}async utimes(e,t){this._assertOpen(`futimes`);let{utimesSync:r}=await import(`./utimes.js`);r(n(this.options.path),e,t)}async writeFile(e,n){let r=t(n),i;i=typeof e==`string`?D.from(e,r||`utf8`):e,this._writeCore(i,null)}async write(e,...n){let r=null,i=null,a=null,o=null;typeof e==`string`?(r=n[0],i=n[1]):(a=n[0],o=n[1],r=n[2]),i=t(i,typeof e==`string`?`utf8`:null);let s;s=typeof e==`string`?new TextEncoder().encode(e):e;let c=a??0,l=o??s.byteLength-c,u=s.subarray(c,c+l);return{bytesWritten:this._writeCore(u,r??null),buffer:e}}async writev(e,t){let n=0;for(let r of e){let e=D.from(r.buffer,r.byteOffset,r.byteLength),i=await this.write(e,0,e.byteLength,t==null?null:t+n);n+=i.bytesWritten}return{bytesWritten:n,buffers:e}}async readv(e,t){let n=0;for(let r of e){let e=await this.read({buffer:D.from(r.buffer,r.byteOffset,r.byteLength),position:t==null?null:t+n});if(n+=e.bytesRead,e.bytesRead<r.byteLength)break}return{bytesRead:n,buffers:e}}_flushSync(){d(this.fd)}_closeSync(){this._teardown()}_readSync(e,t,n,r){return this._readCore(e,t,n,r)}_writeSync(e,t){return this._writeCore(e,t)}_readToEndSync(){return this._readToEnd()}_truncateSync(e){this._truncateCore(e)}_fdStatTarget(){return this._fdTarget()}_teardown(){if(this._closed)return;this._closed=!0,h(this.fd),c(this.fd);let e=FileHandle;delete e.instances[this.fd]}async close(){this._teardown()}async[Symbol.asyncDispose](){await this.close()}pull(...e){throw Error('FileHandle.pull() is not implemented in @gjsify/fs yet — requires `node:stream/iter` (Node 25.9+) which @gjsify/stream has not ported. Track gjsify Open TODO "Node 25 stream/iter integration".')}writer(e){throw Error('FileHandle.writer() is not implemented in @gjsify/fs yet — requires `node:stream/iter` (Node 25.9+) which @gjsify/stream has not ported. Track gjsify Open TODO "Node 25 stream/iter integration".')}};export{k as FileHandle};
|
package/lib/esm/glob.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./_virtual/_rolldown/runtime.js";import{normalizePath as e}from"./utils.js";import{
|
|
1
|
+
import"./_virtual/_rolldown/runtime.js";import{normalizePath as e}from"./utils.js";import{requireCallback as t}from"./errors.js";import{readdirSync as n}from"./sync.js";function segmentToRegexSrc(e){let t=/^([!*+?@])\((.+)\)$/.exec(e);if(t){let[,e,n]=t,r=n.split(`|`).map(e=>segmentToRegexSrc(e)),i=`(?:`+r.join(`|`)+`)`;switch(e){case`!`:return`(?!(?:`+r.join(`|`)+`))[^/]*`;case`*`:return i+`*`;case`+`:return i+`+`;case`?`:return i+`?`;case`@`:return i}}let n=``,r=0;for(;r<e.length;){let t=e[r];if(t===`*`){n+=`[^/]*`,r++;continue}if(t===`?`){n+=`[^/]`,r++;continue}if(t===`[`){let t=e.indexOf(`]`,r+1);if(t===-1){n+=`\\[`,r++;continue}n+=e.slice(r,t+1),r=t+1;continue}if(t===`{`){let t=e.indexOf(`}`,r+1);if(t===-1){n+=`\\{`,r++;continue}let i=e.slice(r+1,t).split(`,`).map(e=>segmentToRegexSrc(e.trim()));n+=`(?:`+i.join(`|`)+`)`,r=t+1;continue}`.+^$|()[]{}`.includes(t)?n+=`\\`+t:n+=t,r++}return n}function globToRegex(e){e=e.replace(/\/+/g,`/`).replace(/^\.\//,``);let t=e.split(`/`),n=[];for(let e=0;e<t.length;e++){let r=t[e],i=e===t.length-1;r===`**`?i?n.length>0&&n[n.length-1]===`/`?(n.pop(),n.push(`(?:/.+)?`)):n.push(`(?:.+)?`):n.push(`(?:[^/]+/)*`):(n.push(segmentToRegexSrc(r)),i||n.push(`/`))}return RegExp(`^(?:`+n.join(``)+`)$`)}function buildExcludePredicate(e){if(!e)return null;if(typeof e==`function`)return e;let t=(Array.isArray(e)?e:[e]).map(e=>globToRegex(e));return e=>t.some(t=>t.test(e))}function matchAll(e,t,r){let i=globToRegex(e),a=buildExcludePredicate(r),o;try{o=n(t,{recursive:!0})}catch{return[]}let s=[`.`,...o],c=[];for(let e of s){let t=e.replace(/\\/g,`/`);i.test(t)&&(a&&a(t)||c.push(e))}return c}function globSync(t,n){let r=Array.isArray(t)?t:[t],i=n?.cwd?e(n.cwd):globalThis.process?.cwd?.()??`/`,a=n?.exclude,o=new Set,s=[];for(let e of r)for(let t of matchAll(e,i,a))o.has(t)||(o.add(t),s.push(t));return s}function glob(e,n,r){let i,a;typeof n==`function`?(a=n,i={}):(a=t(r),i=n||{}),Promise.resolve().then(()=>{try{let t=globSync(e,i);a(null,t)}catch(e){a(e,[])}})}async function*globAsync(e,t){let n=globSync(e,t);for(let e of n)yield e}export{glob,globAsync,globSync};
|
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
|
|
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};
|
package/lib/esm/promises.js
CHANGED
|
@@ -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{watchAsync as a}from"./fs-watcher.js";import{lchmodAsync as
|
|
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{watchAsync as a}from"./fs-watcher.js";import{createNodeError as o}from"./errors.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:()=>a,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 a=i(e),s=U.File.new_for_path(a),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 o(e,`open`,a)}if(!c)throw o(Error(`failed to read file`),`open`,a);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,a)=>{try{e(r.query_info_finish(a))}catch(e){t(o(e,`rmdir`,n))}})})).get_file_type()!==U.FileType.DIRECTORY)throw o(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,a)=>{try{e(r.enumerate_children_finish(a))}catch(e){t(o(e,`rmdir`,n))}})})).next_file(null)!==null)throw o(Object.assign(Error(),{code:5}),`rmdir`,n);await new Promise((e,t)=>{r.delete_async(H.PRIORITY_DEFAULT,null,(i,a)=>{try{r.delete_finish(a),e()}catch(e){t(o(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,a)=>{try{n.delete_finish(a),e()}catch(e){r(o(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 a=i(e);return new Promise((e,i)=>{let s=U.File.new_for_path(a);s.query_info_async(x,t,H.PRIORITY_DEFAULT,null,(t,c)=>{try{e(S(s.query_info_finish(c),a,n,r?.bigint))}catch(e){i(o(e,n,a))}})})}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 o(t,`scandir`,e)}}async function realpath(e){return P(e)}async function symlink(e,t,n){let r=i(t),a=i(e);return new Promise((e,t)=>{let n=U.File.new_for_path(r);n.make_symbolic_link_async(a,H.PRIORITY_DEFAULT,null,(i,s)=>{try{n.make_symbolic_link_finish(s),e()}catch(e){t(o(e,`symlink`,a,r))}})})}async function rm(e,t){let n=i(e),r=U.File.new_for_path(n),a=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 o(t,`rm`,e)}if(c===U.FileType.SYMBOLIC_LINK){await new Promise((t,n)=>{r.delete_async(H.PRIORITY_DEFAULT,null,(i,a)=>{try{r.delete_finish(a),t()}catch(r){if(s){t();return}n(o(r,`rm`,e))}})});return}if(c===U.FileType.DIRECTORY){let r=await readdir(e,{withFileTypes:!0});if(!a&&r.length)throw o(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,a)=>{try{r.delete_finish(a),t()}catch(r){if(s){t();return}n(o(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:a,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,a as watch,write,writeFile,b as writev};
|
package/lib/esm/stat-watcher.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./_virtual/_rolldown/runtime.js";import{
|
|
1
|
+
import"./_virtual/_rolldown/runtime.js";import{requireCallback as e}from"./errors.js";import{statSync as t}from"./sync.js";import{EventEmitter as n}from"node:events";function zeroedStat(){return{dev:0,ino:0,mode:0,nlink:0,uid:0,gid:0,rdev:0,size:0,blksize:0,blocks:0,atimeMs:0,mtimeMs:0,ctimeMs:0,birthtimeMs:0,atime:new Date(0),mtime:new Date(0),ctime:new Date(0),birthtime:new Date(0),isFile:()=>!1,isDirectory:()=>!1,isBlockDevice:()=>!1,isCharacterDevice:()=>!1,isSymbolicLink:()=>!1,isFIFO:()=>!1,isSocket:()=>!1}}var StatWatcher=class extends n{_path;_interval;_timerId=null;_prev;_changeCount=0;constructor(e,t){super(),this._path=e,this._interval=t,this._prev=zeroedStat()}start(){try{this._prev=t(this._path)}catch{}this._timerId=setInterval(()=>{let e;try{e=t(this._path)}catch{e=zeroedStat()}let n=this._prev;(e.mtimeMs!==n.mtimeMs||e.size!==n.size||e.ino!==n.ino)&&(this._prev=e,this.emit(`change`,e,n))},this._interval)}stop(){this._timerId!==null&&(clearInterval(this._timerId),this._timerId=null),this.emit(`stop`)}addChangeListener(e){this._changeCount++,this.on(`change`,e)}removeChangeListener(e){this._changeCount--,this.removeListener(`change`,e)}removeAllChangeListeners(){this._changeCount=0,this.removeAllListeners(`change`)}get changeListenerCount(){return this._changeCount}};const r=new Map;function watchFile(t,n,i){typeof n==`function`&&(i=n,n={}),e(i,`listener`);let a=n.interval??5007,o=t.toString(),s=r.get(o);return s||(s=new StatWatcher(o,a),s.start(),r.set(o,s)),i&&s.addChangeListener(i),s}function unwatchFile(e,t){let n=e.toString(),i=r.get(n);i&&(t?i.removeChangeListener(t):i.removeAllChangeListeners(),i.changeListenerCount===0&&(i.stop(),r.delete(n)))}export{StatWatcher,unwatchFile,watchFile};
|
package/lib/esm/statfs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./_virtual/_rolldown/runtime.js";import{normalizePath as e}from"./utils.js";import t from"@girs/glib-2.0";import
|
|
1
|
+
import"./_virtual/_rolldown/runtime.js";import{normalizePath as e}from"./utils.js";import{requireCallback as t}from"./errors.js";import n from"@girs/glib-2.0";import r from"@girs/gio-2.0";const i=[`filesystem::size`,`filesystem::free`].join(`,`),a=4096;function buildStatFs(e){let t=Number(e.get_attribute_uint64(`filesystem::size`)??0),n=Number(e.get_attribute_uint64(`filesystem::free`)??0),r=Math.floor(t/a),i=Math.floor(n/a);return{type:0,bsize:a,blocks:r,bfree:i,bavail:i,files:0,ffree:0}}function buildBigIntStatFs(e){let t=BigInt(e.get_attribute_uint64(`filesystem::size`)??0),n=BigInt(e.get_attribute_uint64(`filesystem::free`)??0),r=BigInt(a),i=t/r,o=n/r;return{type:0n,bsize:r,blocks:i,bfree:o,bavail:o,files:0n,ffree:0n}}function statfsSync(t,n){let a=r.File.new_for_path(e(t)).query_filesystem_info(i,null);return n?.bigint===!0?buildBigIntStatFs(a):buildStatFs(a)}function queryFsInfoAsync(t,a){return new Promise((o,s)=>{let c=r.File.new_for_path(e(t));c.query_filesystem_info_async(i,n.PRIORITY_DEFAULT,null,(e,t)=>{try{let e=c.query_filesystem_info_finish(t);o(a?buildBigIntStatFs(e):buildStatFs(e))}catch(e){s(e)}})})}function statfs(e,n,r){let i=typeof n==`function`?n:t(r);queryFsInfoAsync(e,(typeof n==`function`?{}:n)?.bigint===!0).then(e=>i(null,e),e=>i(e,null))}async function statfsAsync(e,t){return queryFsInfoAsync(e,t?.bigint===!0)}export{statfs,statfsAsync,statfsSync};
|
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{FSWatcher as a}from"./fs-watcher.js";import{
|
|
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{FSWatcher as a}from"./fs-watcher.js";import{createNodeError as o,isNotFoundError as s}from"./errors.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&&s(e))return;throw o(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&&s(e))return;throw o(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 a=r(e),s=y.File.new_for_path(a);try{let[e,r]=s.load_contents(null);if(!e)throw o(Error(`failed to read file`),`read`,a);return t(n(i,`buffer`),r)}catch(e){throw e.code&&typeof e.code==`string`?e:o(e,`read`,a)}}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 o(Object.assign(Error(),{code:4}),`rmdir`,n);if(i.enumerate_children(`standard::name`,y.FileQueryInfoFlags.NONE,null).next_file(null)!==null)throw o(Object.assign(Error(),{code:5}),`rmdir`,n);i.delete(null)}catch(e){throw e.code&&typeof e.code==`string`?e:o(e,`rmdir`,n)}}function unlinkSync(e){let t=r(e),n=y.File.new_for_path(t);try{n.delete(null)}catch(e){throw o(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),a=y.File.new_for_path(n),s=y.File.new_for_path(i);try{a.move(s,y.FileCopyFlags.OVERWRITE,null,null)}catch(e){throw o(e,`rename`,n,i)}}function copyFileSync(e,t,n){let i=r(e),a=r(t),s=y.File.new_for_path(i),c=y.File.new_for_path(a),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 o(e,`copyfile`,i,a)}stripPrivilegeBitsAfterCopy(c,i,a)}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 o(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 o(r,`access`,n)}}catch(e){throw e.code&&typeof e.code==`string`?e:o(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:o(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 o(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 o(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 o(e,`chown`,i)}}function watch(e,t,n){return new a(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),a=t?.recursive||!1,c=t?.force||!1,l;try{l=i.query_file_type(y.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)}catch(t){if(c&&s(t))return;throw o(t,`rm`,e)}if(l===y.FileType.SYMBOLIC_LINK){try{i.delete(null)}catch(t){if(c&&s(t))return;throw o(t,`rm`,e)}return}if(l===y.FileType.DIRECTORY){let r=readdirSync(e);if(!a&&r.length)throw o(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&&s(t))return;throw o(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};
|
package/lib/esm/utimes.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./_virtual/_rolldown/runtime.js";import{normalizePath as e}from"./utils.js";import t from"@girs/glib-2.0";import
|
|
1
|
+
import"./_virtual/_rolldown/runtime.js";import{normalizePath as e}from"./utils.js";import{requireCallback as t}from"./errors.js";import n from"@girs/glib-2.0";import r from"@girs/gio-2.0";function toGLibDateTime(e){let t=e instanceof Date?e.getTime():typeof e==`bigint`?Number(e):typeof e==`string`?Date.parse(e):e*1e3;return n.DateTime.new_from_unix_utc(Math.floor(t/1e3))}function setTimestamps(e,t,n,i){let a=r.File.new_for_path(e),o=new r.FileInfo;o.set_modification_date_time(toGLibDateTime(n)),o.set_access_date_time(toGLibDateTime(t)),a.set_attributes_from_info(o,i,null)}function utimesSync(t,n,i){setTimestamps(e(t),n,i,r.FileQueryInfoFlags.NONE)}function utimes(e,n,r,i){t(i),Promise.resolve().then(()=>utimesSync(e,n,r)).then(()=>i(null),i)}async function utimesAsync(e,t,n){utimesSync(e,t,n)}function lutimesSync(t,n,i){setTimestamps(e(t),n,i,r.FileQueryInfoFlags.NOFOLLOW_SYMLINKS)}function lutimes(e,n,r,i){t(i),Promise.resolve().then(()=>lutimesSync(e,n,r)).then(()=>i(null),i)}async function lutimesAsync(e,t,n){lutimesSync(e,t,n)}function lchownSync(t,n,i){let a=e(t),o=r.File.new_for_path(a),s=new r.FileInfo;n!==-1&&s.set_attribute_uint32(`unix::uid`,n),i!==-1&&s.set_attribute_uint32(`unix::gid`,i),o.set_attributes_from_info(s,r.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)}function lchown(e,n,r,i){t(i),Promise.resolve().then(()=>lchownSync(e,n,r)).then(()=>i(null),i)}async function lchownAsync(e,t,n){lchownSync(e,t,n)}function lchmodUnsupported(){let e=Error(`The lchmod() method is not implemented`);return e.code=`ERR_METHOD_NOT_IMPLEMENTED`,e}const i=void 0,a=void 0;async function lchmodAsync(e,t){throw lchmodUnsupported()}export{a as lchmod,lchmodAsync,i as lchmodSync,lchown,lchownAsync,lchownSync,lutimes,lutimesAsync,lutimesSync,utimes,utimesAsync,utimesSync};
|
package/lib/types/callback.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PathLike, OpenMode, Mode, ReadPosition, ReadAsyncOptions, NoParamCallback, RmOptions, RmDirOptions, MakeDirectoryOptions } from 'node:fs';
|
|
1
|
+
import type { PathLike, OpenMode, Mode, ReadPosition, ReadAsyncOptions, NoParamCallback, RmOptions, RmDirOptions, MakeDirectoryOptions, EncodingOption, BufferEncodingOption } from 'node:fs';
|
|
2
2
|
import { Buffer } from 'node:buffer';
|
|
3
3
|
import { Stats, BigIntStats } from './stats.js';
|
|
4
4
|
export declare function stat(path: PathLike, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void;
|
|
@@ -215,6 +215,24 @@ export declare function chmod(path: PathLike, mode: Mode, callback: NoParamCallb
|
|
|
215
215
|
export declare function chown(path: PathLike, uid: number, gid: number, callback: NoParamCallback): void;
|
|
216
216
|
export declare function mkdir(path: PathLike, callback: NoParamCallback): void;
|
|
217
217
|
export declare function mkdir(path: PathLike, options: MakeDirectoryOptions | Mode, callback: NoParamCallback): void;
|
|
218
|
+
/**
|
|
219
|
+
* `fs.mkdtemp(prefix[, options], callback)`.
|
|
220
|
+
*
|
|
221
|
+
* It was missing entirely — only `mkdtempSync` and `fsPromises.mkdtemp` existed —
|
|
222
|
+
* so `fs.mkdtemp(prefix, cb)` was a `TypeError` at the call. The bundler had been
|
|
223
|
+
* saying so out loud on every build that imported it:
|
|
224
|
+
*
|
|
225
|
+
* IMPORT_IS_UNDEFINED: Import 'mkdtemp' will always be undefined because there
|
|
226
|
+
* is no matching export in 'lib/esm/index.js'
|
|
227
|
+
*
|
|
228
|
+
* Nothing new is implemented here. `mkdtempAt()` is the shared body — the atomic
|
|
229
|
+
* `mkdir(2)`-retry loop with its 0700 ceiling — and `mkdtempSync` already wraps it
|
|
230
|
+
* with the encoding decision, so this wraps that. A second copy of the loop is how
|
|
231
|
+
* the private-scratch-space mode would eventually drift on one path only.
|
|
232
|
+
*/
|
|
233
|
+
export declare function mkdtemp(prefix: string, callback: (err: NodeJS.ErrnoException | null, folder: string) => void): void;
|
|
234
|
+
export declare function mkdtemp(prefix: string, options: EncodingOption, callback: (err: NodeJS.ErrnoException | null, folder: string) => void): void;
|
|
235
|
+
export declare function mkdtemp(prefix: string, options: BufferEncodingOption, callback: (err: NodeJS.ErrnoException | null, folder: Buffer) => void): void;
|
|
218
236
|
export declare function rmdir(path: PathLike, callback: NoParamCallback): void;
|
|
219
237
|
export declare function rmdir(path: PathLike, options: RmDirOptions, callback: NoParamCallback): void;
|
|
220
238
|
export declare function readFile(path: PathLike, callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void): void;
|
package/lib/types/errors.d.ts
CHANGED
|
@@ -16,3 +16,43 @@ export { isNotFoundError };
|
|
|
16
16
|
* remembering to hoist every throw out of every try, once per site, forever.
|
|
17
17
|
*/
|
|
18
18
|
export declare function createNodeError(err: unknown, syscall: string, path: PathLike, dest?: PathLike): NodeJS.ErrnoException;
|
|
19
|
+
/**
|
|
20
|
+
* Node's `validateFunction(cb, 'cb')`, which every callback-form `fs` entry point
|
|
21
|
+
* runs before it does any work.
|
|
22
|
+
*
|
|
23
|
+
* Why it is a shared helper and not a line per site: the sites that need it all
|
|
24
|
+
* spelled the same non-null assertion — `callback!`, `maybeCb!` — and that
|
|
25
|
+
* assertion is the defect, not a symptom of it. It silences the one type the
|
|
26
|
+
* compiler had, so a missing callback survived into the async body and surfaced as
|
|
27
|
+
* `callback is not a function` INSIDE a promise chain. Under GJS that is invisible:
|
|
28
|
+
* there is no host hook for `unhandledRejection`, so the runner never learns the
|
|
29
|
+
* caller made a mistake.
|
|
30
|
+
*
|
|
31
|
+
* THE `!` HEURISTIC IS NOT THE RULE, which is how the first sweep missed a third of
|
|
32
|
+
* them. `fs.chmod` declares its callback REQUIRED, so it needed no assertion — and a
|
|
33
|
+
* type is not enforced at a JS boundary. The rule is: every callback-form entry
|
|
34
|
+
* point validates, checked against Node one at a time.
|
|
35
|
+
*
|
|
36
|
+
* Node validates all of them synchronously with `ERR_INVALID_ARG_TYPE`. The two
|
|
37
|
+
* exceptions are `fs.close(fd)` and `WriteStream.close()`, genuinely optional and
|
|
38
|
+
* silent — #1039 settled those and `fs-semantics.spec.ts` K-16 pins them, so do NOT
|
|
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).
|
|
41
|
+
*
|
|
42
|
+
* `argName` is a parameter because Node is not uniform: `opendir` says `"callback"`
|
|
43
|
+
* and `watchFile` says `"listener"`, while the rest say `"cb"`.
|
|
44
|
+
*/
|
|
45
|
+
export declare function requireCallback<T>(value: T, argName?: 'cb' | 'callback' | 'listener'): T & ((...args: any[]) => void);
|
|
46
|
+
/**
|
|
47
|
+
* Node's `ERR_INVALID_STATE`, whose message is the literal `Invalid state: ` prefix
|
|
48
|
+
* plus the caller's clause — measured on v24.15.0 via
|
|
49
|
+
* `fh.readableWebStream()` twice ("Invalid state: The FileHandle is locked") and on
|
|
50
|
+
* a closed handle ("Invalid state: The FileHandle is closed").
|
|
51
|
+
*
|
|
52
|
+
* A plain `Error`, NOT a TypeError — measured, because the guess went the other
|
|
53
|
+
* way: `e instanceof TypeError` is false and `e.name` is `'Error'` on the second
|
|
54
|
+
* `readableWebStream()` call. `ERR_INVALID_STATE` has both an `Error` and a
|
|
55
|
+
* `TypeError` form in `lib/internal/errors.js`, and this is the one the file-handle
|
|
56
|
+
* lock raises.
|
|
57
|
+
*/
|
|
58
|
+
export declare function invalidState(clause: string): NodeJS.ErrnoException;
|
|
@@ -30,6 +30,10 @@ export declare class FileHandle implements IFileHandle {
|
|
|
30
30
|
*/
|
|
31
31
|
private _pos;
|
|
32
32
|
private _closed;
|
|
33
|
+
/** `readableWebStream()` takes this on the CALL, and never releases it — Node's
|
|
34
|
+
* handle lock is per-handle, not per-stream, so a second call throws even after
|
|
35
|
+
* the first stream has ended. Measured. */
|
|
36
|
+
private _webStreamLocked;
|
|
33
37
|
/** Not part of the default implementation, used internal by gjsify */
|
|
34
38
|
private static instances;
|
|
35
39
|
constructor(options: {
|
|
@@ -117,12 +121,37 @@ export declare class FileHandle implements IFileHandle {
|
|
|
117
121
|
read<T extends NodeJS.ArrayBufferView>(buffer: T, offset?: number | null, length?: number | null, position?: ReadPosition | null): Promise<FileReadResult<T>>;
|
|
118
122
|
read<T extends NodeJS.ArrayBufferView = Buffer>(options?: FileReadOptions<T>): Promise<FileReadResult<T>>;
|
|
119
123
|
/**
|
|
120
|
-
*
|
|
121
|
-
* on a second call or a closed handle; this returns a SOURCELESS stream that
|
|
122
|
-
* yields nothing, and enforces neither rule. Reading the file needs a source
|
|
123
|
-
* wired to `_readCore` — until then prefer `createReadStream()`.
|
|
124
|
+
* `filehandle.readableWebStream()` — a `ReadableStream` over the file's bytes.
|
|
124
125
|
*
|
|
125
|
-
*
|
|
126
|
+
* It used to return `new Ctor()`: a stream with NO underlying source, so
|
|
127
|
+
* `for await (const chunk of fh.readableWebStream())` never settled. A hang is
|
|
128
|
+
* the worst shape a missing feature can take — no error, no stack, no timeout —
|
|
129
|
+
* which is why this is implemented rather than made to throw.
|
|
130
|
+
*
|
|
131
|
+
* Every rule below is MEASURED against node v24.15.0 rather than read off the
|
|
132
|
+
* docs:
|
|
133
|
+
*
|
|
134
|
+
* - it streams from the handle's CURRENT position, not from byte 0. After
|
|
135
|
+
* `await fh.read(Buffer.alloc(6), 0, 6, null)` on "hello world", Node's
|
|
136
|
+
* stream yields "world". `_readCore(…, null)` is the cursor-relative read,
|
|
137
|
+
* which is what makes that true here too.
|
|
138
|
+
* - a SECOND call throws `ERR_INVALID_STATE` — "Invalid state: The FileHandle
|
|
139
|
+
* is locked". The lock is taken by the CALL, not by the first read.
|
|
140
|
+
* - on a CLOSED handle it throws `ERR_INVALID_STATE` — "…is closed" — and NOT
|
|
141
|
+
* the `EBADF` that `_assertOpen` raises, so this tests `_closed` itself
|
|
142
|
+
* rather than routing through it.
|
|
143
|
+
* - the handle is NOT closed when the stream ends; user code still calls
|
|
144
|
+
* `close()`.
|
|
145
|
+
*
|
|
146
|
+
* A BYTE stream (`type: 'bytes'`), because Node's is — measured, after the first
|
|
147
|
+
* version of this comment asserted the opposite and built a default stream:
|
|
148
|
+
* `fh.readableWebStream().getReader({ mode: 'byob' })` returns a
|
|
149
|
+
* `ReadableStreamBYOBReader` on v24.15.0 and reads into the caller's buffer. A
|
|
150
|
+
* default stream rejects that reader, so getting this backwards would have
|
|
151
|
+
* introduced a divergence inside the change that exists to remove them.
|
|
152
|
+
*
|
|
153
|
+
* The BYOB path also removes the 64 KiB allocation per pull whenever the consumer
|
|
154
|
+
* brings its own view.
|
|
126
155
|
*/
|
|
127
156
|
readableWebStream(): ReadableStream;
|
|
128
157
|
/**
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { existsSync, readdirSync, readFileSync, writeFileSync, mkdirSync, rmdirSync, unlinkSync, watch, mkdtempSync, rmSync, statSync, openSync, realpathSync, symlinkSync, lstatSync, renameSync, copyFileSync, accessSync, appendFileSync, readlinkSync, linkSync, truncateSync, chmodSync, chownSync } from './sync.js';
|
|
2
|
-
import { open, close, read, write, rm, realpath, readdir, symlink, lstat, stat, rename, copyFile, access, appendFile, readlink, truncate, chmod, chown, mkdir, rmdir, readFile, writeFile, unlink, link } from './callback.js';
|
|
2
|
+
import { open, close, read, write, rm, realpath, readdir, symlink, lstat, stat, rename, copyFile, access, appendFile, readlink, truncate, chmod, chown, mkdir, mkdtemp, rmdir, readFile, writeFile, unlink, link } from './callback.js';
|
|
3
3
|
import FSWatcher from './fs-watcher.js';
|
|
4
4
|
import { createReadStream, ReadStream } from './read-stream.js';
|
|
5
5
|
import { createWriteStream, WriteStream } from './write-stream.js';
|
|
@@ -44,7 +44,7 @@ declare const fixedConstants: {
|
|
|
44
44
|
S_IXOTH: number;
|
|
45
45
|
};
|
|
46
46
|
export declare const constants: typeof fixedConstants & PosixOpenFlags;
|
|
47
|
-
export { FSWatcher, StatWatcher, Stats, BigIntStats, Dirent, Dir, existsSync, readdirSync, readFileSync, writeFileSync, mkdirSync, rmdirSync, unlinkSync, 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, };
|
|
47
|
+
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
48
|
declare const _default: {
|
|
49
49
|
FSWatcher: typeof FSWatcher;
|
|
50
50
|
StatWatcher: typeof StatWatcher;
|
|
@@ -88,6 +88,7 @@ declare const _default: {
|
|
|
88
88
|
mkdirSync: typeof mkdirSync;
|
|
89
89
|
rmdirSync: typeof rmdirSync;
|
|
90
90
|
unlinkSync: typeof unlinkSync;
|
|
91
|
+
mkdtemp: typeof mkdtemp;
|
|
91
92
|
mkdtempSync: typeof mkdtempSync;
|
|
92
93
|
rmSync: typeof rmSync;
|
|
93
94
|
statSync: typeof statSync;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/fs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.40.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,8 +66,9 @@
|
|
|
66
66
|
"fs"
|
|
67
67
|
],
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"@gjsify/cli": "^0.
|
|
70
|
-
"@gjsify/unit": "^0.
|
|
69
|
+
"@gjsify/cli": "^0.40.0",
|
|
70
|
+
"@gjsify/unit": "^0.40.0",
|
|
71
|
+
"@gjsify/web-streams": "^0.40.0",
|
|
71
72
|
"@types/node": "^25.9.2",
|
|
72
73
|
"typescript": "^6.0.3"
|
|
73
74
|
},
|
|
@@ -75,11 +76,11 @@
|
|
|
75
76
|
"@girs/gio-2.0": "^4.1.0",
|
|
76
77
|
"@girs/giounix-2.0": "^4.1.0",
|
|
77
78
|
"@girs/glib-2.0": "^4.1.0",
|
|
78
|
-
"@gjsify/buffer": "^0.
|
|
79
|
-
"@gjsify/events": "^0.
|
|
80
|
-
"@gjsify/stream": "^0.
|
|
81
|
-
"@gjsify/url": "^0.
|
|
82
|
-
"@gjsify/utils": "^0.
|
|
79
|
+
"@gjsify/buffer": "^0.40.0",
|
|
80
|
+
"@gjsify/events": "^0.40.0",
|
|
81
|
+
"@gjsify/stream": "^0.40.0",
|
|
82
|
+
"@gjsify/url": "^0.40.0",
|
|
83
|
+
"@gjsify/utils": "^0.40.0"
|
|
83
84
|
},
|
|
84
85
|
"gjsify": {
|
|
85
86
|
"runtimes": {
|
|
@@ -94,7 +95,7 @@
|
|
|
94
95
|
"win32": "none"
|
|
95
96
|
},
|
|
96
97
|
"osNotes": {
|
|
97
|
-
"darwin": "The descriptor path is measured on Linux only. fstat/fchmod/ftruncate and the cursor read-back go through /proc/self/fd and /proc/self/fdinfo, which darwin does not have; fd-io.ts falls back to acting on the PATH there, and tellFd() to sizeOfFd(). Both fallbacks are gated on the measured CAN_PROC_FD capability rather than assumed, but no darwin host has run them — shipping an unmeasured darwin path is how the first cut of this work shipped a broken umask probe. The O_* table in posix-flags.ts carries darwin values (O_CREAT 0x200 collides with Linux O_TRUNC, which is why it is host-keyed at all) and those are equally unexercised: prebuilds.yml runs no darwin leg for this package.",
|
|
98
|
+
"darwin": "The descriptor path is measured on Linux only. fstat/fchmod/ftruncate and the cursor read-back go through /proc/self/fd and /proc/self/fdinfo, which darwin does not have; fd-io.ts falls back to acting on the PATH there, and tellFd() to sizeOfFd(). Both fallbacks are gated on the measured CAN_PROC_FD capability rather than assumed, but no darwin host has run them — shipping an unmeasured darwin path is how the first cut of this work shipped a broken umask probe. The O_* table in posix-flags.ts carries darwin values (O_CREAT 0x200 collides with Linux O_TRUNC, which is why it is host-keyed at all) and those are equally unexercised: prebuilds.yml runs no darwin leg for this package. copyFileSync additionally branches on isDarwin(): the kernel write-time privilege strip is not portable — Linux's should_remove_suid() keeps S_ISGID without S_IXGRP, XNU strips it either way (measured on both macOS legs, 2644 -> 0644 vs 2644 -> 2644). Node inherits that for free because the kernel does the stripping; we spell it.",
|
|
98
99
|
"win32": "Not attempted. The implementation is POSIX open(2)/mkdir(2) semantics with real O_CREAT|O_EXCL, an fd-owned cursor and mode-at-creation; win32 has no procfs, no POSIX mode bits and different open flags. The WIN32 branch in posix-flags.ts exists so the table is total, not because the package works there — the fs specs already carry `it.failing({ when: isWin32() })` rows saying the same."
|
|
99
100
|
},
|
|
100
101
|
"tier": 1
|