first commit

This commit is contained in:
Stefan Hacker
2026-04-03 09:38:48 +02:00
commit 37ad745546
47450 changed files with 3120798 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
export * from '@jsonjoy.com/fs-fsa-to-node';
+5
View File
@@ -0,0 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("@jsonjoy.com/fs-fsa-to-node"), exports);
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/fsa-to-node/index.ts"],"names":[],"mappings":";;;AAAA,sEAA4C"}
+1
View File
@@ -0,0 +1 @@
export * from '@jsonjoy.com/fs-fsa';
+5
View File
@@ -0,0 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("@jsonjoy.com/fs-fsa"), exports);
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/fsa/index.ts"],"names":[],"mappings":";;;AAAA,8DAAoC"}
+46
View File
@@ -0,0 +1,46 @@
import { Stats, Dirent, Volume, StatWatcher, FSWatcher } from '@jsonjoy.com/fs-node';
import type { IWriteStream } from '@jsonjoy.com/fs-node';
import { DirectoryJSON, NestedDirectoryJSON, type IProcess } from '@jsonjoy.com/fs-core';
import { constants } from '@jsonjoy.com/fs-node-utils';
import type { FsPromisesApi } from '@jsonjoy.com/fs-node-utils';
import type * as misc from '@jsonjoy.com/fs-node-utils/lib/types/misc';
export { DirectoryJSON, NestedDirectoryJSON, Volume };
export type { IProcess };
export declare const vol: Volume;
export interface IFs extends Volume {
constants: typeof constants;
Stats: new (...args: any[]) => Stats;
Dirent: new (...args: any[]) => Dirent;
StatWatcher: new () => StatWatcher;
FSWatcher: new () => FSWatcher;
ReadStream: new (...args: any[]) => misc.IReadStream;
WriteStream: new (...args: any[]) => IWriteStream;
promises: FsPromisesApi;
_toUnixTimestamp: any;
}
export declare function createFsFromVolume(vol: Volume): IFs;
export declare const fs: IFs;
/** Options for creating a memfs instance. */
export interface MemfsOptions {
/** Custom working directory for resolving relative paths. Defaults to `'/'`. */
cwd?: string;
/** Custom `process`-like object for controlling platform, uid, gid, and cwd behavior. */
process?: IProcess;
}
/**
* Creates a new file system instance.
*
* @param json File system structure expressed as a JSON object.
* Use `null` for empty directories and empty string for empty files.
* @param cwdOrOpts Current working directory (string) or options object.
* The JSON structure will be created relative to the cwd path.
* @returns A `memfs` file system instance, which is a drop-in replacement for
* the `fs` module.
*/
export declare const memfs: (json?: NestedDirectoryJSON, cwdOrOpts?: string | MemfsOptions) => {
fs: IFs;
vol: Volume;
};
export type IFsWithVolume = IFs & {
__vol: Volume;
};
+66
View File
@@ -0,0 +1,66 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.memfs = exports.fs = exports.vol = exports.Volume = void 0;
exports.createFsFromVolume = createFsFromVolume;
const fs_node_1 = require("@jsonjoy.com/fs-node");
Object.defineProperty(exports, "Volume", { enumerable: true, get: function () { return fs_node_1.Volume; } });
const fs_node_utils_1 = require("@jsonjoy.com/fs-node-utils");
const { F_OK, R_OK, W_OK, X_OK } = fs_node_utils_1.constants;
// Default volume.
exports.vol = new fs_node_1.Volume();
function createFsFromVolume(vol) {
const fs = { F_OK, R_OK, W_OK, X_OK, constants: fs_node_utils_1.constants, Stats: fs_node_1.Stats, Dirent: fs_node_1.Dirent };
// Bind FS methods.
for (const method of fs_node_1.fsSynchronousApiList)
if (typeof vol[method] === 'function')
fs[method] = vol[method].bind(vol);
for (const method of fs_node_1.fsCallbackApiList)
if (typeof vol[method] === 'function')
fs[method] = vol[method].bind(vol);
fs.StatWatcher = vol.StatWatcher;
fs.FSWatcher = vol.FSWatcher;
fs.WriteStream = vol.WriteStream;
fs.ReadStream = vol.ReadStream;
fs.promises = vol.promises;
// Handle realpath and realpathSync with their .native properties
if (typeof vol.realpath === 'function') {
fs.realpath = vol.realpath.bind(vol);
if (typeof vol.realpath.native === 'function') {
fs.realpath.native = vol.realpath.native.bind(vol);
}
}
if (typeof vol.realpathSync === 'function') {
fs.realpathSync = vol.realpathSync.bind(vol);
if (typeof vol.realpathSync.native === 'function') {
fs.realpathSync.native = vol.realpathSync.native.bind(vol);
}
}
fs._toUnixTimestamp = fs_node_1.toUnixTimestamp;
fs.__vol = vol;
return fs;
}
exports.fs = createFsFromVolume(exports.vol);
/**
* Creates a new file system instance.
*
* @param json File system structure expressed as a JSON object.
* Use `null` for empty directories and empty string for empty files.
* @param cwdOrOpts Current working directory (string) or options object.
* The JSON structure will be created relative to the cwd path.
* @returns A `memfs` file system instance, which is a drop-in replacement for
* the `fs` module.
*/
const memfs = (json = {}, cwdOrOpts = '/') => {
const opts = typeof cwdOrOpts === 'string' ? { cwd: cwdOrOpts } : cwdOrOpts;
// When no explicit cwd is given but a custom process is provided, let the
// Superblock use that process's cwd(). Otherwise default to '/' so the
// convenience function keeps its opinionated virtual-root default.
const cwd = opts.cwd ?? (opts.process ? undefined : '/');
const vol = fs_node_1.Volume.fromNestedJSON(json, cwd, { process: opts.process });
const fs = createFsFromVolume(vol);
return { fs, vol };
};
exports.memfs = memfs;
module.exports = { ...module.exports, ...exports.fs };
module.exports.semantic = true;
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAoCA,gDA+BC;AAnED,kDAS8B;AASe,uFAf3C,gBAAM,OAe2C;AANnD,8DAAuD;AAIvD,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,yBAAS,CAAC;AAK7C,kBAAkB;AACL,QAAA,GAAG,GAAG,IAAI,gBAAM,EAAE,CAAC;AAchC,SAAgB,kBAAkB,CAAC,GAAW;IAC5C,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAA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AAQ,GAAG,IAAI,CAAC"}
+1
View File
@@ -0,0 +1 @@
export * from '@jsonjoy.com/fs-node-to-fsa';
+5
View File
@@ -0,0 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("@jsonjoy.com/fs-node-to-fsa"), exports);
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/node-to-fsa/index.ts"],"names":[],"mappings":";;;AAAA,sEAA4C"}