@zenfs/core 1.4.0 → 1.4.1

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.
@@ -42,23 +42,7 @@ export declare class Index extends Map<string, Stats> {
42
42
  */
43
43
  static parse(data: string): Index;
44
44
  }
45
- declare const IndexFS_base: import("../index.js").Mixin<typeof FileSystem, {
46
- metadata(): import("../filesystem.js").FileSystemMetadata;
47
- rename(oldPath: string, newPath: string): Promise<void>;
48
- renameSync(oldPath: string, newPath: string): void;
49
- createFile(path: string, flag: string, mode: number): Promise<import("../file.js").File>;
50
- createFileSync(path: string, flag: string, mode: number): import("../file.js").File;
51
- unlink(path: string): Promise<void>;
52
- unlinkSync(path: string): void;
53
- rmdir(path: string): Promise<void>;
54
- rmdirSync(path: string): void;
55
- mkdir(path: string, mode: number): Promise<void>;
56
- mkdirSync(path: string, mode: number): void;
57
- link(srcpath: string, dstpath: string): Promise<void>;
58
- linkSync(srcpath: string, dstpath: string): void;
59
- sync(path: string, data: Uint8Array, stats: Readonly<Stats>): Promise<void>;
60
- syncSync(path: string, data: Uint8Array, stats: Readonly<Stats>): void;
61
- }>;
45
+ declare const IndexFS_base: import("../index.js").Mixin<typeof FileSystem, import("../mixins/readonly.js").ReadonlyMixin>;
62
46
  export declare abstract class IndexFS extends IndexFS_base {
63
47
  private indexData;
64
48
  protected index: Index;
@@ -3,7 +3,6 @@ import type { ExtractProperties } from 'utilium';
3
3
  import { type MountConfiguration } from '../../config.js';
4
4
  import { File } from '../../file.js';
5
5
  import { FileSystem, type FileSystemMetadata } from '../../filesystem.js';
6
- import { Async } from '../../mixins/async.js';
7
6
  import { Stats } from '../../stats.js';
8
7
  import type { Backend, FilesystemOf } from '../backend.js';
9
8
  import * as RPC from './rpc.js';
@@ -51,7 +50,7 @@ export interface FSRequest<TMethod extends FSMethod = FSMethod> extends RPC.Requ
51
50
  method: TMethod;
52
51
  args: Parameters<FSMethods[TMethod]>;
53
52
  }
54
- declare const PortFS_base: import("../../index.js").Mixin<typeof FileSystem, Async>;
53
+ declare const PortFS_base: import("../../index.js").Mixin<typeof FileSystem, import("../../mixins/async.js").AsyncMixin>;
55
54
  /**
56
55
  * PortFS lets you access an FS instance that is running in a port, or the other way around.
57
56
  *
package/dist/context.d.ts CHANGED
@@ -25,7 +25,7 @@ export interface BoundContext extends Fn_FS, FSContext {
25
25
  }
26
26
  /**
27
27
  * Allows you to restrict operations to a specific root path and set of credentials.
28
- * Note that the credentials of a bound context are copied.
28
+ * Note that the default credentials of a bound context are copied from the global credentials.
29
29
  * @experimental
30
30
  */
31
31
  export declare function bindContext(root: string, credentials?: CredentialInit): BoundContext;
package/dist/context.js CHANGED
@@ -9,7 +9,7 @@ function _bindFunctions(fns, thisValue) {
9
9
  }
10
10
  /**
11
11
  * Allows you to restrict operations to a specific root path and set of credentials.
12
- * Note that the credentials of a bound context are copied.
12
+ * Note that the default credentials of a bound context are copied from the global credentials.
13
13
  * @experimental
14
14
  */
15
15
  export function bindContext(root, credentials = structuredClone(defaultCredentials)) {
@@ -9,7 +9,7 @@ export type AsyncOperation = {
9
9
  /**
10
10
  * @internal
11
11
  */
12
- export interface Async {
12
+ export interface AsyncMixin {
13
13
  /**
14
14
  * @internal @protected
15
15
  */
@@ -37,5 +37,5 @@ export interface Async {
37
37
  * During loading, the contents of the async file system are preloaded into the synchronous store.
38
38
  *
39
39
  */
40
- export declare function Async<const T extends typeof FileSystem>(FS: T): Mixin<T, Async>;
41
- export declare function asyncPatch<T extends typeof FileSystem>(fs: Mixin<T, Async>): void;
40
+ export declare function Async<const T extends typeof FileSystem>(FS: T): Mixin<T, AsyncMixin>;
41
+ export declare function asyncPatch<T extends typeof FileSystem>(fs: Mixin<T, AsyncMixin>): void;
@@ -3,9 +3,9 @@ import type { FileSystem, FileSystemMetadata } from '../filesystem.js';
3
3
  import type { Stats } from '../stats.js';
4
4
  import type { Mixin } from './shared.js';
5
5
  /**
6
- * Implements the non-readonly methods to throw `EROFS`
6
+ * @internal
7
7
  */
8
- export declare function Readonly<T extends typeof FileSystem>(FS: T): Mixin<T, {
8
+ export interface ReadonlyMixin {
9
9
  metadata(): FileSystemMetadata;
10
10
  rename(oldPath: string, newPath: string): Promise<void>;
11
11
  renameSync(oldPath: string, newPath: string): void;
@@ -21,4 +21,8 @@ export declare function Readonly<T extends typeof FileSystem>(FS: T): Mixin<T, {
21
21
  linkSync(srcpath: string, dstpath: string): void;
22
22
  sync(path: string, data: Uint8Array, stats: Readonly<Stats>): Promise<void>;
23
23
  syncSync(path: string, data: Uint8Array, stats: Readonly<Stats>): void;
24
- }>;
24
+ }
25
+ /**
26
+ * Implements the non-readonly methods to throw `EROFS`
27
+ */
28
+ export declare function Readonly<T extends typeof FileSystem>(FS: T): Mixin<T, ReadonlyMixin>;
package/dist/polyfills.js CHANGED
@@ -9,11 +9,6 @@ Promise.withResolvers ?? (Promise.withResolvers = function () {
9
9
  });
10
10
  return { promise, resolve: _resolve, reject: _reject };
11
11
  });
12
- /*
13
- A polyfill for when these symbols are undefined.
14
- For some reason, NodeJS does not polyfill them in a VM context.
15
- Since jest uses a VM context for ESM, these need to be here.
16
- */
17
12
  // @ts-expect-error 2540
18
13
  Symbol['dispose'] ?? (Symbol['dispose'] = Symbol('Symbol.dispose'));
19
14
  // @ts-expect-error 2540
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zenfs/core",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "A filesystem, anywhere",
5
5
  "funding": {
6
6
  "type": "individual",
package/readme.md CHANGED
@@ -9,13 +9,13 @@ It works using a system of backends, which are used by ZenFS to store and retrie
9
9
  ZenFS is modular and extensible. The core includes some built-in backends:
10
10
 
11
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)
12
- - `Overlay`: Use read-only file system as read-write by overlaying a writable file system on top of it. ([copy-on-write](https://en.wikipedia.org/wiki/Copy-on-write))
12
+ - `Overlay`: Use a read-only file system as read-write by overlaying a writable file system on top of it. ([copy-on-write](https://en.wikipedia.org/wiki/Copy-on-write))
13
13
  - `Fetch`: Downloads files over HTTP with the `fetch` API (_readonly_)
14
14
  - `Port`: Interacts with a remote over a `MessagePort`-like interface (e.g. a worker)
15
15
 
16
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.
17
17
 
18
- You can find all of the packages available over at [zenfs.dev](https://zenfs.dev).
18
+ You can find all of the packages available over on [NPM](https://www.npmjs.com/org/zenfs).
19
19
 
20
20
  As an added bonus, all ZenFS backends support synchronous operations. All of the backends included with the core are cross-platform.
21
21
 
@@ -51,7 +51,7 @@ The following example mounts a zip file to `/zip`, in-memory storage to `/tmp`,
51
51
  ```js
52
52
  import { configure, InMemory } from '@zenfs/core';
53
53
  import { IndexedDB } from '@zenfs/dom';
54
- import { Zip } from '@zenfs/zip';
54
+ import { Zip } from '@zenfs/archives';
55
55
 
56
56
  const res = await fetch('mydata.zip');
57
57
 
@@ -122,7 +122,7 @@ You can then mount and unmount the backend instance by using `mount` and `umount
122
122
  ```js
123
123
  import { configure, resolveMountConfig, InMemory } from '@zenfs/core';
124
124
  import { IndexedDB } from '@zenfs/dom';
125
- import { Zip } from '@zenfs/zip';
125
+ import { Zip } from '@zenfs/archives';
126
126
 
127
127
  await configure({
128
128
  mounts: {
package/scripts/test.js CHANGED
@@ -15,6 +15,7 @@ const { values: options, positionals } = parseArgs({
15
15
  auto: { short: 'a', type: 'boolean', default: false },
16
16
  build: { short: 'b', type: 'boolean', default: false },
17
17
  common: { short: 'c', type: 'boolean', default: false },
18
+ coverage: { type: 'string', default: 'tests/.coverage' },
18
19
  },
19
20
  allowPositionals: true,
20
21
  });
@@ -70,10 +71,9 @@ if (options.auto) {
70
71
  !options.quiet && console.log(`Auto-detected ${sum} test setup files`);
71
72
  }
72
73
 
73
- const coverage = join(import.meta.dirname, '../.coverage');
74
- if (existsSync(coverage)) rmSync(coverage, { recursive: true });
75
- mkdirSync(coverage);
76
- process.env.NODE_V8_COVERAGE = coverage;
74
+ if (existsSync(options.coverage)) rmSync(options.coverage, { recursive: true });
75
+ mkdirSync(options.coverage);
76
+ process.env.NODE_V8_COVERAGE = options.coverage;
77
77
 
78
78
  if (options.common) {
79
79
  !options.quiet && console.log('Running common tests...');
@@ -107,4 +107,4 @@ for (const setupFile of positionals) {
107
107
  }
108
108
 
109
109
  execSync('npx c8 report --reporter=text', { stdio: 'inherit' });
110
- rmSync('.coverage', { recursive: true });
110
+ rmSync(options.coverage, { recursive: true });