@gjsify/fs 0.46.0 → 0.47.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/fd-ops.js CHANGED
@@ -1 +1 @@
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};
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);let i;try{u(e(n)),i=!0}catch{i=!1}Promise.resolve().then(()=>r(i))}Object.defineProperty(exists,Symbol.for(`nodejs.util.promisify.custom`),{value:e=>new Promise(t=>exists(e,t))});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};
@@ -51,6 +51,24 @@ export declare function writevAsync(fd: number, buffers: NodeJS.ArrayBufferView[
51
51
  bytesWritten: number;
52
52
  buffers: NodeJS.ArrayBufferView<ArrayBufferLike>[];
53
53
  }>;
54
+ /**
55
+ * The one entry point in `node:fs` whose callback takes `(exists)` rather than
56
+ * `(err, value)`. Three consequences, all measured against node v24.19.0.
57
+ *
58
+ * The answer is DELIVERED, not handed over in place: Node reads it out of
59
+ * `fs.access`'s async completion, so `exists(p, cb)` returns before `cb` runs —
60
+ * the same one-microtask contract `withHandle` documents in `callback.ts`.
61
+ *
62
+ * Delivering it also moves the call OUT of the try below, which is the half
63
+ * that was silently wrong. The call used to sit inside, so a callback that
64
+ * threw was caught and re-entered with `false`: the caller's own exception came
65
+ * back to them as a filesystem answer, and an existing file read as missing.
66
+ * Node lets that throw reach the host. Sibling rule: `fs-semantics.spec.ts`
67
+ * K-19, the same defect in `mkdtemp`.
68
+ *
69
+ * `util.promisify.custom` below is what the `(exists)` shape costs: without it
70
+ * a promisified `exists` reads the lone `true` as an `err` and rejects.
71
+ */
54
72
  export declare function exists(path: PathLike, callback: (exists: boolean) => void): void;
55
73
  export declare function openAsBlob(path: PathLike, options?: {
56
74
  type?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/fs",
3
- "version": "0.46.0",
3
+ "version": "0.47.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.46.0",
70
- "@gjsify/unit": "^0.46.0",
71
- "@gjsify/web-streams": "^0.46.0",
69
+ "@gjsify/cli": "^0.47.0",
70
+ "@gjsify/unit": "^0.47.0",
71
+ "@gjsify/web-streams": "^0.47.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": "4.6.0",
77
77
  "@girs/giounix-2.0": "4.6.0",
78
78
  "@girs/glib-2.0": "4.6.0",
79
- "@gjsify/buffer": "^0.46.0",
80
- "@gjsify/events": "^0.46.0",
81
- "@gjsify/stream": "^0.46.0",
82
- "@gjsify/url": "^0.46.0",
83
- "@gjsify/utils": "^0.46.0"
79
+ "@gjsify/buffer": "^0.47.0",
80
+ "@gjsify/events": "^0.47.0",
81
+ "@gjsify/stream": "^0.47.0",
82
+ "@gjsify/url": "^0.47.0",
83
+ "@gjsify/utils": "^0.47.0"
84
84
  },
85
85
  "gjsify": {
86
86
  "runtimes": {