@zenfs/core 1.6.4 → 1.6.6

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/dist/devices.d.ts CHANGED
@@ -6,7 +6,7 @@ import type { StatsLike } from './stats.js';
6
6
  import { Stats } from './stats.js';
7
7
  /**
8
8
  * A device
9
- * @todo Maybe add major/minor number or some other device information, like a UUID?
9
+ * @todo Maybe add some other device information, like a UUID?
10
10
  * @privateRemarks
11
11
  * UUIDs were considered, however they don't make sense without an easy mechanism for persistence
12
12
  */
@@ -354,7 +354,6 @@ export declare function statfs(this: V_Context, path: fs.PathLike, opts: fs.Stat
354
354
  export declare function statfs(this: V_Context, path: fs.PathLike, opts?: fs.StatFsOptions): Promise<fs.StatsFs | fs.BigIntStatsFs>;
355
355
  /**
356
356
  * Retrieves the files matching the specified pattern.
357
- * @todo Implement
358
357
  */
359
358
  export declare function glob(this: V_Context, pattern: string | string[]): NodeJS.AsyncIterator<string>;
360
359
  export declare function glob(this: V_Context, pattern: string | string[], opt: fs.GlobOptionsWithFileTypes): NodeJS.AsyncIterator<Dirent>;
package/dist/inode.d.ts CHANGED
@@ -7,7 +7,7 @@ export declare const rootIno = 0n;
7
7
  /**
8
8
  * Generic inode definition that can easily be serialized.
9
9
  * @internal
10
- * @todo [BREAKING]
10
+ * @todo [BREAKING] Remove 58 byte Inode upgrade path
11
11
  */
12
12
  export declare class Inode implements StatsLike {
13
13
  constructor(buffer?: ArrayBufferLike | ArrayBufferView);
package/dist/inode.js CHANGED
@@ -47,7 +47,7 @@ export const rootIno = 0n;
47
47
  /**
48
48
  * Generic inode definition that can easily be serialized.
49
49
  * @internal
50
- * @todo [BREAKING]
50
+ * @todo [BREAKING] Remove 58 byte Inode upgrade path
51
51
  */
52
52
  let Inode = (() => {
53
53
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
@@ -111,14 +111,14 @@ let Inode = (() => {
111
111
  // Expand the buffer so it is the right size
112
112
  if (buffer.byteLength < sz_inode) {
113
113
  const newBuffer = new Uint8Array(sz_inode);
114
+ const buf = ArrayBuffer.isView(buffer) ? buffer.buffer : buffer;
114
115
  // Fill the new buffer with current data
115
- newBuffer.set(new Uint8Array(ArrayBuffer.isView(buffer) ? buffer.buffer : buffer));
116
+ newBuffer.set(new Uint8Array(buf));
116
117
  /* Add a random ino.
117
118
  This will be different from the actual one,
118
119
  but `ino` isn't used anywhere so it should be fine.
119
120
  */
120
- const randomIno = crypto.getRandomValues(new Uint32Array(2));
121
- newBuffer.set(randomIno, sz_inode - 2);
121
+ new DataView(newBuffer.buffer).setBigUint64(sz_inode - 1, randomBigInt());
122
122
  buffer = newBuffer;
123
123
  }
124
124
  deserialize(this, buffer);
package/dist/utils.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type * as fs from 'node:fs';
2
- import type { ClassLike, OptionalTuple } from 'utilium';
2
+ import { type ClassLike, type OptionalTuple } from 'utilium';
3
3
  import { type AbsolutePath } from './emulation/path.js';
4
4
  import { ErrnoError } from './error.js';
5
5
  import type { FileSystem } from './filesystem.js';
package/dist/utils.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { randomHex } from 'utilium';
1
2
  import { dirname, resolve } from './emulation/path.js';
2
3
  import { Errno, ErrnoError } from './error.js';
3
4
  /**
@@ -218,5 +219,11 @@ export function normalizeOptions(options, encoding = 'utf8', flag, mode = 0) {
218
219
  * @internal
219
220
  */
220
221
  export function randomBigInt() {
221
- return crypto.getRandomValues(new BigUint64Array(1))[0];
222
+ try {
223
+ return crypto.getRandomValues(new BigUint64Array(1))[0];
224
+ }
225
+ catch {
226
+ // fallback
227
+ return BigInt('0x' + randomHex(16 /* 4 bits per char */));
228
+ }
222
229
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zenfs/core",
3
- "version": "1.6.4",
3
+ "version": "1.6.6",
4
4
  "description": "A filesystem, anywhere",
5
5
  "funding": {
6
6
  "type": "individual",