@zenfs/core 0.15.0 → 0.15.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.
@@ -18,7 +18,7 @@ import { BigIntStats, type Stats } from '../stats.js';
18
18
  import { Dir, Dirent } from './dir.js';
19
19
  import { ReadStream, WriteStream } from './streams.js';
20
20
  export * as constants from './constants.js';
21
- import '../symbol-dispose.js';
21
+ import '../polyfills.js';
22
22
  export declare class FileHandle implements promises.FileHandle {
23
23
  /**
24
24
  * The file descriptor for this file handle.
@@ -54,7 +54,7 @@ import { dirname, join, parse } from './path.js';
54
54
  import { _statfs, cred, fd2file, fdMap, file2fd, fixError, mounts, resolveMount } from './shared.js';
55
55
  import { ReadStream, WriteStream } from './streams.js';
56
56
  export * as constants from './constants.js';
57
- import '../symbol-dispose.js';
57
+ import '../polyfills.js';
58
58
  export class FileHandle {
59
59
  constructor(fdOrFile) {
60
60
  const isFile = typeof fdOrFile != 'number';
package/dist/file.d.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  import type { FileReadResult } from 'node:fs/promises';
4
4
  import type { FileSystem } from './filesystem.js';
5
5
  import { Stats, type FileType } from './stats.js';
6
- import './symbol-dispose.js';
6
+ import './polyfills.js';
7
7
  declare global {
8
8
  interface ArrayBuffer {
9
9
  readonly resizable: boolean;
package/dist/file.js CHANGED
@@ -2,7 +2,7 @@ import { O_APPEND, O_CREAT, O_EXCL, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY,
2
2
  import { Errno, ErrnoError } from './error.js';
3
3
  import { size_max } from './inode.js';
4
4
  import { Stats } from './stats.js';
5
- import './symbol-dispose.js';
5
+ import './polyfills.js';
6
6
  const validFlags = ['r', 'r+', 'rs', 'rs+', 'w', 'wx', 'w+', 'wx+', 'a', 'ax', 'a+', 'ax+'];
7
7
  export function parseFlag(flag) {
8
8
  if (typeof flag === 'number') {
@@ -0,0 +1,20 @@
1
+ Promise.withResolvers ?? (Promise.withResolvers = function () {
2
+ let _resolve,
3
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
+ _reject;
5
+ const promise = new Promise((resolve, reject) => {
6
+ _resolve = resolve;
7
+ _reject = reject;
8
+ });
9
+ return { promise, resolve: _resolve, reject: _reject };
10
+ });
11
+ /*
12
+ A polyfill for when these symbols are undefined.
13
+ For some reason, NodeJS does not polyfill them in a VM context.
14
+ Since jest uses a VM context for ESM, these need to be here.
15
+ */
16
+ // @ts-expect-error 2540
17
+ Symbol['dispose'] ?? (Symbol['dispose'] = Symbol('Symbol.dispose'));
18
+ // @ts-expect-error 2540
19
+ Symbol['asyncDispose'] ?? (Symbol['asyncDispose'] = Symbol('Symbol.asyncDispose'));
20
+ export {};
package/license.md CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) James P. and other ZenFS contributors.
1
+ Copyright (c) James Prevett and other ZenFS contributors.
2
2
  Copyright (c) 2013-2023 John Vilk and other BrowserFS contributors.
3
3
  Copyright (c) Joyent, Inc. and other Node contributors for `test/fixtures/node`.
4
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zenfs/core",
3
- "version": "0.15.0",
3
+ "version": "0.15.2",
4
4
  "description": "A filesystem, anywhere",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -34,7 +34,7 @@
34
34
  "url": "https://github.com/zen-fs/core/issues"
35
35
  },
36
36
  "engines": {
37
- "node": ">= 22"
37
+ "node": ">= 16"
38
38
  },
39
39
  "exports": {
40
40
  ".": "./dist/index.js",
@@ -80,6 +80,11 @@ export class FetchFS extends IndexFS {
80
80
  return;
81
81
  }
82
82
  await super.ready();
83
+
84
+ if (this._disableSync) {
85
+ return;
86
+ }
87
+
83
88
  /**
84
89
  * Iterate over all of the files and cache their contents
85
90
  */
@@ -5,6 +5,7 @@ import type { FileSystemMetadata } from '../filesystem.js';
5
5
  import { FileSystem } from '../filesystem.js';
6
6
  import type { Stats } from '../stats.js';
7
7
  import type { Backend } from './backend.js';
8
+ import '../polyfills.js';
8
9
 
9
10
  export interface MutexLock extends PromiseWithResolvers<void> {
10
11
  [Symbol.dispose](): void;
@@ -1,6 +1,6 @@
1
1
  import { ErrnoError } from '../../error.js';
2
2
  import type { Ino } from '../../inode.js';
3
- import '../../symbol-dispose.js';
3
+ import '../../polyfills.js';
4
4
 
5
5
  /**
6
6
  * Represents a key-value store.
@@ -18,7 +18,7 @@ import { dirname, join, parse } from './path.js';
18
18
  import { _statfs, cred, fd2file, fdMap, file2fd, fixError, mounts, resolveMount } from './shared.js';
19
19
  import { ReadStream, WriteStream } from './streams.js';
20
20
  export * as constants from './constants.js';
21
- import '../symbol-dispose.js';
21
+ import '../polyfills.js';
22
22
 
23
23
  export class FileHandle implements promises.FileHandle {
24
24
  /**
package/src/file.ts CHANGED
@@ -4,7 +4,7 @@ import { Errno, ErrnoError } from './error.js';
4
4
  import type { FileSystem } from './filesystem.js';
5
5
  import { size_max } from './inode.js';
6
6
  import { Stats, type FileType } from './stats.js';
7
- import './symbol-dispose.js';
7
+ import './polyfills.js';
8
8
 
9
9
  /*
10
10
  Typescript does not include a type declaration for resizable array buffers.
@@ -0,0 +1,20 @@
1
+ Promise.withResolvers ??= function <T>(): PromiseWithResolvers<T> {
2
+ let _resolve: ((value: T | PromiseLike<T>) => void) | undefined,
3
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
+ _reject: ((reason?: any) => void) | undefined;
5
+ const promise = new Promise<T>((resolve, reject) => {
6
+ _resolve = resolve;
7
+ _reject = reject;
8
+ });
9
+ return { promise, resolve: _resolve!, reject: _reject! };
10
+ };
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
+ // @ts-expect-error 2540
18
+ Symbol['dispose'] ??= Symbol('Symbol.dispose');
19
+ // @ts-expect-error 2540
20
+ Symbol['asyncDispose'] ??= Symbol('Symbol.asyncDispose');
@@ -1,10 +0,0 @@
1
- /*
2
- This file acts as a polyfill for when these symbols are undefined.
3
- For some reason, NodeJS does not polyfill them in a VM context.
4
- Since jest uses a VM context for ESM, these need to be here.
5
- */
6
- // @ts-expect-error 2540
7
- Symbol['dispose'] ?? (Symbol['dispose'] = Symbol('Symbol.dispose'));
8
- // @ts-expect-error 2540
9
- Symbol['asyncDispose'] ?? (Symbol['asyncDispose'] = Symbol('Symbol.asyncDispose'));
10
- export {};
@@ -1,9 +0,0 @@
1
- /*
2
- This file acts as a polyfill for when these symbols are undefined.
3
- For some reason, NodeJS does not polyfill them in a VM context.
4
- Since jest uses a VM context for ESM, these need to be here.
5
- */
6
- // @ts-expect-error 2540
7
- Symbol['dispose'] ??= Symbol('Symbol.dispose');
8
- // @ts-expect-error 2540
9
- Symbol['asyncDispose'] ??= Symbol('Symbol.asyncDispose');
File without changes