@zenfs/core 2.2.0 → 2.2.2

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.
@@ -710,7 +710,7 @@ export class SingleBufferStore extends BufferView {
710
710
  return this._fs;
711
711
  }
712
712
  set fs(fs) {
713
- if (this.buffer instanceof SharedArrayBuffer)
713
+ if (this.buffer.constructor.name === 'SharedArrayBuffer')
714
714
  fs === null || fs === void 0 ? void 0 : fs.attributes.set('no_id_tables', true);
715
715
  this._fs = fs;
716
716
  }
package/dist/index.js CHANGED
@@ -10,4 +10,5 @@ export * from './vfs/index.js';
10
10
  export { fs };
11
11
  import * as fs from './vfs/index.js';
12
12
  export default fs;
13
- globalThis.__zenfs__ = fs;
13
+ import $pkg from '../package.json' with { type: 'json' };
14
+ globalThis.__zenfs__ = Object.assign(Object.create(fs), { _version: $pkg.version });
package/dist/polyfills.js CHANGED
@@ -1,7 +1,8 @@
1
1
  /* node:coverage disable */
2
- var _a, _b, _c;
2
+ /* eslint-disable @typescript-eslint/unbound-method */
3
+ var _a, _b, _c, _d;
4
+ var _e;
3
5
  import { warn } from 'kerium/log';
4
- // eslint-disable-next-line @typescript-eslint/unbound-method
5
6
  (_a = Promise.withResolvers) !== null && _a !== void 0 ? _a : (Promise.withResolvers = (warn('Using a polyfill of Promise.withResolvers'),
6
7
  function () {
7
8
  let _resolve,
@@ -17,4 +18,12 @@ import { warn } from 'kerium/log';
17
18
  (_b = Symbol['dispose']) !== null && _b !== void 0 ? _b : (Symbol['dispose'] = (warn('Using a polyfill of Symbol.dispose'), Symbol('Symbol.dispose')));
18
19
  // @ts-expect-error 2540
19
20
  (_c = Symbol['asyncDispose']) !== null && _c !== void 0 ? _c : (Symbol['asyncDispose'] = (warn('Using a polyfill of Symbol.asyncDispose'), Symbol('Symbol.asyncDispose')));
21
+ function randomUUID() {
22
+ const bytes = crypto.getRandomValues(new Uint8Array(16));
23
+ bytes[6] = (bytes[6] & 0x0f) | 0x40;
24
+ bytes[8] = (bytes[8] & 0x3f) | 0x80;
25
+ const hex = [...bytes].map(b => b.toString(16).padStart(2, '0')).join('');
26
+ return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
27
+ }
28
+ (_d = (_e = globalThis.crypto).randomUUID) !== null && _d !== void 0 ? _d : (_e.randomUUID = (warn('Using a polyfill of crypto.randomUUID'), randomUUID));
20
29
  /* node:coverage enable */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zenfs/core",
3
- "version": "2.2.0",
3
+ "version": "2.2.2",
4
4
  "description": "A filesystem, anywhere",
5
5
  "funding": {
6
6
  "type": "individual",
@@ -81,10 +81,10 @@
81
81
  "@types/eslint__js": "^8.42.3",
82
82
  "c8": "^10.1.2",
83
83
  "eslint": "^9.15.0",
84
- "globals": "^15.9.0",
84
+ "globals": "^16.0.0",
85
85
  "prettier": "^3.2.5",
86
86
  "tsx": "^4.19.1",
87
- "typedoc": "^0.27.1",
87
+ "typedoc": "^0.28.0",
88
88
  "typescript": "^5.7.2",
89
89
  "typescript-eslint": "^8.16.0"
90
90
  }
package/readme.md CHANGED
@@ -1,23 +1,28 @@
1
1
  # ZenFS
2
2
 
3
- ZenFS is a cross-platform library that emulates the [NodeJS filesystem API](http://nodejs.org/api/fs.html). It works using a system of backends, which are used by ZenFS to store and retrieve data. ZenFS can also integrate with other tools.
3
+ ZenFS is a cross-platform library that emulates the [Node.js filesystem API](http://nodejs.org/api/fs.html).
4
+ It works using a system of backends, which are used by ZenFS to store and retrieve data.
5
+ ZenFS can also integrate with other tools.
4
6
 
5
7
  ## Backends
6
8
 
7
- ZenFS is modular and extensible. The core includes some built-in backends:
9
+ ZenFS is modular and easily extended. The core includes some built-in backends:
8
10
 
9
11
  - `InMemory`: Stores files in-memory. This is cleared when the runtime ends (e.g. a user navigating away from a web page or a Node process exiting)
10
- - `CopyOnWrite`: Use readable and writable file systems with ([copy-on-write](https://en.wikipedia.org/wiki/Copy-on-write)).
12
+ - `CopyOnWrite`: Use readable and writable file systems with [copy-on-write](https://en.wikipedia.org/wiki/Copy-on-write).
11
13
  - `Fetch`: Downloads files over HTTP with the `fetch` API
12
14
  - `Port`: Interacts with a remote over a `MessagePort`-like interface (e.g. a worker)
13
15
  - `Passthrough`: Use an existing `node:fs` interface with ZenFS
14
16
  - `SingleBuffer`: A backend contained within a single buffer. Can be used for synchronous multi-threaded operations using `SharedArrayBuffer`
15
17
 
16
- ZenFS supports a number of other backends. Many are provided as separate packages under `@zenfs`. More backends can be defined by separate libraries by extending the `FileSystem` class and providing a `Backend` object.
18
+ ZenFS supports a number of other backends.
19
+ Many are provided as separate packages under `@zenfs`.
20
+ More backends can be defined by separate libraries by extending the `FileSystem` class and providing a `Backend` object.
17
21
 
18
22
  You can find all of the packages available over on [NPM](https://www.npmjs.com/org/zenfs).
19
23
 
20
- As an added bonus, all ZenFS backends support synchronous operations. All of the backends included with the core are cross-platform.
24
+ As an added bonus, all ZenFS backends support synchronous operations.
25
+ Additionally, all of the backends included with the core are cross-platform.
21
26
 
22
27
  For more information, see the [docs](https://zenfs.dev/core).
23
28
 
@@ -27,7 +32,9 @@ For more information, see the [docs](https://zenfs.dev/core).
27
32
  npm install @zenfs/core
28
33
  ```
29
34
 
30
- If you're using ZenFS, especially for big projects, please consider supporting the project. Thousands of hours have been dedicated to its development. Your acknowledgment or financial support would go a long way toward improving ZenFS and its community.
35
+ If you're using ZenFS, especially for big projects, please consider supporting the project.
36
+ Thousands of hours have been dedicated to its development.
37
+ Your acknowledgment or financial support would go a long way toward improving ZenFS and its community.
31
38
 
32
39
  ## Usage
33
40
 
@@ -149,7 +156,7 @@ fs.umount('/mnt/zip'); // finished using the zip
149
156
 
150
157
  ### Devices and device files
151
158
 
152
- ZenFS includes experimental support for device files. These are designed to follow Linux's device file behavior, for consistency and ease of use. You can automatically add some normal devices with the `addDevices` configuration option:
159
+ ZenFS includes support for device files. These are designed to follow Linux's device file behavior, for consistency and ease of use. You can automatically add some normal devices with the `addDevices` configuration option:
153
160
 
154
161
  ```ts
155
162
  await configure({
@@ -208,9 +215,9 @@ A huge thank you to [![Deco.cx logo](https://avatars.githubusercontent.com/deco-
208
215
 
209
216
  ## Building
210
217
 
211
- - Make sure you have Node and NPM installed. You must have Node v18 or newer.
218
+ - Make sure you have Node and NPM installed. You must have Node v22 or newer.
212
219
  - Install dependencies with `npm install`
213
- - Build using `npm run build`
220
+ - Build using `npx tsc` or `npm run build`
214
221
  - You can find the built code in `dist`.
215
222
 
216
223
  ### Testing