Initial commit: notification-elements-demo app

Interactive Angular 19 demo for @sda/notification-elements-ui with
6 sections: Bell & Feed, Notification Center, Inbox, Comments &
Threads, Mention Input, and Full-Featured layout. Includes mock
data, dark mode toggle, and real-time event log.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Giuliano Silvestro
2026-02-13 21:49:19 +10:00
commit 5d0c9ec7eb
36473 changed files with 3778146 additions and 0 deletions

39
node_modules/@jsonjoy.com/fs-core/lib/File.d.ts generated vendored Normal file
View File

@@ -0,0 +1,39 @@
import { Buffer } from '@jsonjoy.com/fs-node-builtins/lib/internal/buffer';
import type { Link } from './Link';
import type { Node } from './Node';
/**
* Represents an open file (file descriptor) that points to a `Link` (Hard-link) and a `Node`.
*
* @todo Rename to `OpenFile`.
*/
export declare class File {
readonly link: Link;
readonly node: Node;
flags: number;
fd: number;
/**
* A cursor/offset position in a file, where data will be written on write.
* User can "seek" this position.
*/
position: number;
/**
* Open a Link-Node pair. `node` is provided separately as that might be a different node
* rather the one `link` points to, because it might be a symlink.
* @param link
* @param node
* @param flags
* @param fd
*/
constructor(link: Link, node: Node, flags: number, fd: number);
getString(encoding?: string): string;
setString(str: string): void;
getBuffer(): Buffer;
setBuffer(buf: Buffer): void;
getSize(): number;
truncate(len?: number): void;
seekTo(position: number): void;
write(buf: Buffer, offset?: number, length?: number, position?: number | null): number;
read(buf: Buffer | ArrayBufferView | DataView, offset?: number, length?: number, position?: number): number;
chmod(perm: number): void;
chown(uid: number, gid: number): void;
}

72
node_modules/@jsonjoy.com/fs-core/lib/File.js generated vendored Normal file
View File

@@ -0,0 +1,72 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.File = void 0;
const fs_node_utils_1 = require("@jsonjoy.com/fs-node-utils");
const { O_APPEND } = fs_node_utils_1.constants;
/**
* Represents an open file (file descriptor) that points to a `Link` (Hard-link) and a `Node`.
*
* @todo Rename to `OpenFile`.
*/
class File {
/**
* Open a Link-Node pair. `node` is provided separately as that might be a different node
* rather the one `link` points to, because it might be a symlink.
* @param link
* @param node
* @param flags
* @param fd
*/
constructor(link, node, flags, fd) {
this.link = link;
this.node = node;
this.flags = flags;
this.fd = fd;
this.position = 0;
if (this.flags & O_APPEND)
this.position = this.getSize();
}
getString(encoding = 'utf8') {
return this.node.getString();
}
setString(str) {
this.node.setString(str);
}
getBuffer() {
return this.node.getBuffer();
}
setBuffer(buf) {
this.node.setBuffer(buf);
}
getSize() {
return this.node.getSize();
}
truncate(len) {
this.node.truncate(len);
}
seekTo(position) {
this.position = position;
}
write(buf, offset = 0, length = buf.length, position) {
if (typeof position !== 'number')
position = this.position;
const bytes = this.node.write(buf, offset, length, position);
this.position = position + bytes;
return bytes;
}
read(buf, offset = 0, length = buf.byteLength, position) {
if (typeof position !== 'number')
position = this.position;
const bytes = this.node.read(buf, offset, length, position);
this.position = position + bytes;
return bytes;
}
chmod(perm) {
this.node.chmod(perm);
}
chown(uid, gid) {
this.node.chown(uid, gid);
}
}
exports.File = File;
//# sourceMappingURL=File.js.map

1
node_modules/@jsonjoy.com/fs-core/lib/File.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"File.js","sourceRoot":"","sources":["../src/File.ts"],"names":[],"mappings":";;;AAAA,8DAAuD;AAKvD,MAAM,EAAE,QAAQ,EAAE,GAAG,yBAAS,CAAC;AAE/B;;;;GAIG;AACH,MAAa,IAAI;IAOf;;;;;;;OAOG;IACH,YACkB,IAAU,EACV,IAAU,EACnB,KAAa,EACb,EAAU;QAHD,SAAI,GAAJ,IAAI,CAAM;QACV,SAAI,GAAJ,IAAI,CAAM;QACnB,UAAK,GAAL,KAAK,CAAQ;QACb,OAAE,GAAF,EAAE,CAAQ;QAEjB,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;QAClB,IAAI,IAAI,CAAC,KAAK,GAAG,QAAQ;YAAE,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;IAC5D,CAAC;IAED,SAA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AC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;QAC5D,IAAI,CAAC,QAAQ,GAAG,QAAQ,GAAG,KAAK,CAAC;QACjC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,KAAK,CAAC,IAAY;QAChB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,GAAW,EAAE,GAAW;QAC5B,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAC5B,CAAC;CACF;AA/ED,oBA+EC"}

38
node_modules/@jsonjoy.com/fs-core/lib/Link.d.ts generated vendored Normal file
View File

@@ -0,0 +1,38 @@
import { FanOut } from 'thingies/lib/fanout';
import type { Node } from './Node';
import type { Superblock } from './Superblock';
export type LinkEventChildAdd = [type: 'child:add', link: Link, parent: Link];
export type LinkEventChildDelete = [type: 'child:del', link: Link, parent: Link];
export type LinkEvent = LinkEventChildAdd | LinkEventChildDelete;
/**
* Represents a hard link that points to an i-node `node`.
*/
export declare class Link {
readonly changes: FanOut<LinkEvent>;
vol: Superblock;
parent: Link | undefined;
children: Map<string, Link | undefined>;
private _steps;
node: Node;
ino: number;
length: number;
name: string;
get steps(): string[];
set steps(val: string[]);
constructor(vol: Superblock, parent: Link | undefined, name: string);
setNode(node: Node): void;
getNode(): Node;
createChild(name: string, node?: Node): Link;
setChild(name: string, link?: Link): Link;
deleteChild(link: Link): void;
getChild(name: string): Link | undefined;
getPath(): string;
getParentPath(): string;
getName(): string;
toJSON(): {
steps: string[];
ino: number;
children: string[];
};
syncSteps(): void;
}

105
node_modules/@jsonjoy.com/fs-core/lib/Link.js generated vendored Normal file
View File

@@ -0,0 +1,105 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Link = void 0;
const fs_node_utils_1 = require("@jsonjoy.com/fs-node-utils");
const fanout_1 = require("thingies/lib/fanout");
const { S_IFREG } = fs_node_utils_1.constants;
/**
* Represents a hard link that points to an i-node `node`.
*/
class Link {
get steps() {
return this._steps;
}
// Recursively sync children steps, e.g. in case of dir rename
set steps(val) {
this._steps = val;
for (const [child, link] of this.children.entries()) {
if (child === '.' || child === '..') {
continue;
}
link?.syncSteps();
}
}
constructor(vol, parent, name) {
this.changes = new fanout_1.FanOut();
this.children = new Map();
// Path to this node as Array: ['usr', 'bin', 'node'].
this._steps = [];
// "i-node" number of the node.
this.ino = 0;
// Number of children.
this.length = 0;
this.vol = vol;
this.parent = parent;
this.name = name;
this.syncSteps();
}
setNode(node) {
this.node = node;
this.ino = node.ino;
}
getNode() {
return this.node;
}
createChild(name, node = this.vol.createNode(S_IFREG | 0o666)) {
const link = new Link(this.vol, this, name);
link.setNode(node);
if (node.isDirectory()) {
link.children.set('.', link);
link.getNode().nlink++;
}
this.setChild(name, link);
return link;
}
setChild(name, link = new Link(this.vol, this, name)) {
this.children.set(name, link);
link.parent = this;
this.length++;
const node = link.getNode();
if (node.isDirectory()) {
link.children.set('..', this);
this.getNode().nlink++;
}
this.getNode().mtime = new Date();
this.changes.emit(['child:add', link, this]);
return link;
}
deleteChild(link) {
const node = link.getNode();
if (node.isDirectory()) {
link.children.delete('..');
this.getNode().nlink--;
}
this.children.delete(link.getName());
this.length--;
this.getNode().mtime = new Date();
this.changes.emit(['child:del', link, this]);
}
getChild(name) {
this.getNode().atime = new Date();
return this.children.get(name);
}
getPath() {
return this.steps.join("/" /* PATH.SEP */);
}
getParentPath() {
const parent = this.steps.slice(0, -1).join("/" /* PATH.SEP */);
return parent ? parent : "/" /* PATH.SEP */;
}
getName() {
return this.steps[this.steps.length - 1];
}
toJSON() {
return {
steps: this.steps,
ino: this.ino,
children: Array.from(this.children.keys()),
};
}
syncSteps() {
this.steps = this.parent ? this.parent.steps.concat([this.name]) : [this.name];
}
}
exports.Link = Link;
//# sourceMappingURL=Link.js.map

1
node_modules/@jsonjoy.com/fs-core/lib/Link.js.map generated vendored Normal file
View File

@@ -0,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IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;SAC3C,CAAC;IACJ,CAAC;IAED,SAAS;QACP,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjF,CAAC;CACF;AA/HD,oBA+HC"}

85
node_modules/@jsonjoy.com/fs-core/lib/Node.d.ts generated vendored Normal file
View File

@@ -0,0 +1,85 @@
import { FanOut } from 'thingies/lib/fanout';
import { Buffer } from '@jsonjoy.com/fs-node-builtins/lib/internal/buffer';
export type NodeEventModify = [type: 'modify'];
export type NodeEventDelete = [type: 'delete'];
export type NodeEvent = NodeEventModify | NodeEventDelete;
/**
* Node in a file system (like i-node, v-node).
*/
export declare class Node {
readonly changes: FanOut<NodeEvent>;
ino: number;
private _uid;
private _gid;
private _atime;
private _mtime;
private _ctime;
buf: Buffer;
/** Total allocated memory capacity for this node. */
private capacity;
/** Actually used bytes to store content. */
private size;
rdev: number;
mode: number;
private _nlink;
symlink: string;
constructor(ino: number, mode?: number);
set ctime(ctime: Date);
get ctime(): Date;
set uid(uid: number);
get uid(): number;
set gid(gid: number);
get gid(): number;
set atime(atime: Date);
get atime(): Date;
set mtime(mtime: Date);
get mtime(): Date;
get perm(): number;
set perm(perm: number);
set nlink(nlink: number);
get nlink(): number;
getString(encoding?: BufferEncoding): string;
setString(str: string): void;
getBuffer(): Buffer;
setBuffer(buf: Buffer): void;
private _setBuf;
getSize(): number;
setModeProperty(property: number): void;
isFile(): boolean;
isDirectory(): boolean;
isSymlink(): boolean;
isCharacterDevice(): boolean;
makeSymlink(symlink: string): void;
write(buf: Buffer, off?: number, len?: number, pos?: number): number;
/**
* Read data from the file.
*
* @param buf Buffer to read data into.
* @param off Offset int the `buf` where to start writing data.
* @param len How many bytes to read. Equals to `buf.byteLength` by default.
* @param pos Position offset in file where to start reading. Defaults to `0`.
* @returns Returns the number of bytes read.
*/
read(buf: Buffer | ArrayBufferView | DataView, off?: number, len?: number, pos?: number): number;
truncate(len?: number): void;
chmod(perm: number): void;
chown(uid: number, gid: number): void;
touch(): void;
canRead(uid?: number, gid?: number): boolean;
canWrite(uid?: number, gid?: number): boolean;
canExecute(uid?: number, gid?: number): boolean;
del(): void;
toJSON(): {
ino: number;
uid: number;
gid: number;
atime: number;
mtime: number;
ctime: number;
perm: number;
mode: number;
nlink: number;
symlink: string;
data: string;
};
}

287
node_modules/@jsonjoy.com/fs-core/lib/Node.js generated vendored Normal file
View File

@@ -0,0 +1,287 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Node = void 0;
const fanout_1 = require("thingies/lib/fanout");
const process_1 = require("./process");
const buffer_1 = require("@jsonjoy.com/fs-node-builtins/lib/internal/buffer");
const fs_node_utils_1 = require("@jsonjoy.com/fs-node-utils");
const { S_IFMT, S_IFDIR, S_IFREG, S_IFLNK, S_IFCHR } = fs_node_utils_1.constants;
const getuid = () => process_1.default.getuid?.() ?? 0;
const getgid = () => process_1.default.getgid?.() ?? 0;
const EMPTY_BUFFER = (0, buffer_1.bufferAllocUnsafe)(0);
/**
* Node in a file system (like i-node, v-node).
*/
class Node {
constructor(ino, mode = 0o666) {
this.changes = new fanout_1.FanOut();
// User ID and group ID.
this._uid = getuid();
this._gid = getgid();
this._atime = new Date();
this._mtime = new Date();
this._ctime = new Date();
this.buf = EMPTY_BUFFER;
/** Total allocated memory capacity for this node. */
this.capacity = 0;
/** Actually used bytes to store content. */
this.size = 0;
this.rdev = 0;
// Number of hard links pointing at this Node.
this._nlink = 1;
this.mode = mode;
this.ino = ino;
}
set ctime(ctime) {
this._ctime = ctime;
}
get ctime() {
return this._ctime;
}
set uid(uid) {
this._uid = uid;
this.ctime = new Date();
}
get uid() {
return this._uid;
}
set gid(gid) {
this._gid = gid;
this.ctime = new Date();
}
get gid() {
return this._gid;
}
set atime(atime) {
this._atime = atime;
}
get atime() {
return this._atime;
}
set mtime(mtime) {
this._mtime = mtime;
this.ctime = new Date();
}
get mtime() {
return this._mtime;
}
get perm() {
return this.mode & ~S_IFMT;
}
set perm(perm) {
this.mode = (this.mode & S_IFMT) | (perm & ~S_IFMT);
this.ctime = new Date();
}
set nlink(nlink) {
this._nlink = nlink;
this.ctime = new Date();
}
get nlink() {
return this._nlink;
}
getString(encoding = 'utf8') {
this.atime = new Date();
return this.getBuffer().toString(encoding);
}
setString(str) {
this._setBuf((0, buffer_1.bufferFrom)(str, 'utf8'));
}
getBuffer() {
this.atime = new Date();
if (!this.buf)
this.buf = (0, buffer_1.bufferAllocUnsafe)(0);
return (0, buffer_1.bufferFrom)(this.buf.subarray(0, this.size)); // Return a copy of used portion.
}
setBuffer(buf) {
const copy = (0, buffer_1.bufferFrom)(buf); // Creates a copy of data.
this._setBuf(copy);
}
_setBuf(buf) {
const size = buf.length;
this.buf = buf;
this.capacity = size;
this.size = size;
this.touch();
}
getSize() {
return this.size;
}
setModeProperty(property) {
this.mode = property;
}
isFile() {
return (this.mode & S_IFMT) === S_IFREG;
}
isDirectory() {
return (this.mode & S_IFMT) === S_IFDIR;
}
isSymlink() {
// return !!this.symlink;
return (this.mode & S_IFMT) === S_IFLNK;
}
isCharacterDevice() {
return (this.mode & S_IFMT) === S_IFCHR;
}
makeSymlink(symlink) {
this.mode = S_IFLNK | 0o666;
this.symlink = symlink;
}
write(buf, off = 0, len = buf.length, pos = 0) {
const bufLength = buf.length;
if (off + len > bufLength)
len = bufLength - off;
if (len <= 0)
return 0;
const requiredSize = pos + len;
if (requiredSize > this.capacity) {
let newCapacity = Math.max(this.capacity * 2, 64);
while (newCapacity < requiredSize)
newCapacity *= 2;
const newBuf = (0, buffer_1.bufferAllocUnsafe)(newCapacity);
if (this.size > 0)
this.buf.copy(newBuf, 0, 0, this.size);
this.buf = newBuf;
this.capacity = newCapacity;
}
if (pos > this.size)
this.buf.fill(0, this.size, pos);
buf.copy(this.buf, pos, off, off + len);
if (requiredSize > this.size)
this.size = requiredSize;
this.touch();
return len;
}
/**
* Read data from the file.
*
* @param buf Buffer to read data into.
* @param off Offset int the `buf` where to start writing data.
* @param len How many bytes to read. Equals to `buf.byteLength` by default.
* @param pos Position offset in file where to start reading. Defaults to `0`.
* @returns Returns the number of bytes read.
*/
read(buf, off = 0, len = buf.byteLength, pos = 0) {
this.atime = new Date();
if (pos >= this.size)
return 0;
let actualLen = len;
if (actualLen > buf.byteLength)
actualLen = buf.byteLength;
if (actualLen + pos > this.size)
actualLen = this.size - pos;
if (actualLen <= 0)
return 0;
const buf2 = buf instanceof buffer_1.Buffer ? buf : buffer_1.Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
this.buf.copy(buf2, off, pos, pos + actualLen);
return actualLen;
}
truncate(len = 0) {
if (!len) {
this.buf = EMPTY_BUFFER;
this.capacity = 0;
this.size = 0;
this.touch();
return;
}
if (len <= this.size)
this.size = len;
else {
if (len > this.capacity) {
let newCapacity = Math.max(this.capacity * 2, 64);
while (newCapacity < len)
newCapacity *= 2;
const buf = (0, buffer_1.bufferAllocUnsafe)(newCapacity);
if (this.size > 0)
this.buf.copy(buf, 0, 0, this.size);
buf.fill(0, this.size, len);
this.buf = buf;
this.capacity = newCapacity;
}
else
this.buf.fill(0, this.size, len);
this.size = len;
}
this.touch();
}
chmod(perm) {
this.mode = (this.mode & S_IFMT) | (perm & ~S_IFMT);
this.touch();
}
chown(uid, gid) {
this.uid = uid;
this.gid = gid;
this.touch();
}
touch() {
this.mtime = new Date();
this.changes.emit(['modify']);
}
canRead(uid = getuid(), gid = getgid()) {
if (this.perm & 4 /* S.IROTH */) {
return true;
}
if (gid === this.gid) {
if (this.perm & 32 /* S.IRGRP */) {
return true;
}
}
if (uid === this.uid) {
if (this.perm & 256 /* S.IRUSR */) {
return true;
}
}
return false;
}
canWrite(uid = getuid(), gid = getgid()) {
if (this.perm & 2 /* S.IWOTH */) {
return true;
}
if (gid === this.gid) {
if (this.perm & 16 /* S.IWGRP */) {
return true;
}
}
if (uid === this.uid) {
if (this.perm & 128 /* S.IWUSR */) {
return true;
}
}
return false;
}
canExecute(uid = getuid(), gid = getgid()) {
if (this.perm & 1 /* S.IXOTH */) {
return true;
}
if (gid === this.gid) {
if (this.perm & 8 /* S.IXGRP */) {
return true;
}
}
if (uid === this.uid) {
if (this.perm & 64 /* S.IXUSR */) {
return true;
}
}
return false;
}
del() {
this.changes.emit(['delete']);
}
toJSON() {
return {
ino: this.ino,
uid: this.uid,
gid: this.gid,
atime: this.atime.getTime(),
mtime: this.mtime.getTime(),
ctime: this.ctime.getTime(),
perm: this.perm,
mode: this.mode,
nlink: this.nlink,
symlink: this.symlink,
data: this.getString(),
};
}
}
exports.Node = Node;
//# sourceMappingURL=Node.js.map

1
node_modules/@jsonjoy.com/fs-core/lib/Node.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

92
node_modules/@jsonjoy.com/fs-core/lib/Superblock.d.ts generated vendored Normal file
View File

@@ -0,0 +1,92 @@
import { Node } from './Node';
import { Link } from './Link';
import { File } from './File';
import { Buffer } from '@jsonjoy.com/fs-node-builtins/lib/internal/buffer';
import { DirectoryJSON, NestedDirectoryJSON } from './json';
import type { PathLike } from '@jsonjoy.com/fs-node-utils/lib/types/misc';
import { TFileId, StatError } from './types';
import { Result } from './result';
/**
* Represents a filesystem superblock, which is the root of a virtual
* filesystem in Linux.
* @see https://lxr.linux.no/linux+v3.11.2/include/linux/fs.h#L1242
*/
export declare class Superblock {
static fromJSON(json: DirectoryJSON, cwd?: string): Superblock;
static fromNestedJSON(json: NestedDirectoryJSON, cwd?: string): Superblock;
/**
* Global file descriptor counter. UNIX file descriptors start from 0 and go sequentially
* up, so here, in order not to conflict with them, we choose some big number and descrease
* the file descriptor of every new opened file.
* @type {number}
* @todo This should not be static, right?
*/
static fd: number;
root: Link;
ino: number;
inodes: {
[ino: number]: Node;
};
releasedInos: number[];
fds: {
[fd: number]: File;
};
releasedFds: number[];
maxFiles: number;
openFiles: number;
constructor(props?: {});
createLink(): Link;
createLink(parent: Link, name: string, isDirectory?: boolean, mode?: number): Link;
deleteLink(link: Link): boolean;
private newInoNumber;
private newFdNumber;
createNode(mode: number): Node;
deleteNode(node: Node): void;
walk(steps: string[], resolveSymlinks: boolean, checkExistence: boolean, checkAccess: boolean, funcName?: string): Result<Link | null, StatError>;
walk(filename: string, resolveSymlinks: boolean, checkExistence: boolean, checkAccess: boolean, funcName?: string): Result<Link | null, StatError>;
walk(link: Link, resolveSymlinks: boolean, checkExistence: boolean, checkAccess: boolean, funcName?: string): Result<Link | null, StatError>;
walk(stepsOrFilenameOrLink: string[] | string | Link, resolveSymlinks: boolean, checkExistence: boolean, checkAccess: boolean, funcName?: string): Result<Link | null, StatError>;
getLink(steps: string[]): Link | null;
getLinkOrThrow(filename: string, funcName?: string): Link;
getResolvedLink(filenameOrSteps: string | string[]): Link | null;
/**
* Just like `getLinkOrThrow`, but also dereference/resolves symbolic links.
*/
getResolvedLinkOrThrow(filename: string, funcName?: string): Link;
getResolvedLinkResult(filename: string, funcName?: string): Result<Link, StatError>;
resolveSymlinks(link: Link): Link | null;
/**
* Just like `getLinkOrThrow`, but also verifies that the link is a directory.
*/
getLinkAsDirOrThrow(filename: string, funcName?: string): Link;
getLinkParent(steps: string[]): Link | null;
getLinkParentAsDirOrThrow(filenameOrSteps: string | string[], funcName?: string): Link;
getFileByFd(fd: number): File;
getFileByFdOrThrow(fd: number, funcName?: string): File;
_toJSON(link?: Link, json?: {}, path?: string, asBuffer?: boolean): DirectoryJSON<string | null>;
toJSON(paths?: PathLike | PathLike[], json?: {}, isRelative?: boolean, asBuffer?: boolean): DirectoryJSON<string | null>;
fromJSON(json: DirectoryJSON, cwd?: string): void;
fromNestedJSON(json: NestedDirectoryJSON, cwd?: string): void;
reset(): void;
mountSync(mountpoint: string, json: DirectoryJSON): void;
openLink(link: Link, flagsNum: number, resolveSymlinks?: boolean): File;
protected openFile(filename: string, flagsNum: number, modeNum: number | undefined, resolveSymlinks?: boolean): File;
readonly open: (filename: string, flagsNum: number, modeNum: number, resolveSymlinks?: boolean) => number;
readonly writeFile: (id: TFileId, buf: Buffer, flagsNum: number, modeNum: number) => void;
readonly read: (fd: number, buffer: Buffer | ArrayBufferView | DataView, offset: number, length: number, position: number | null) => number;
readonly readv: (fd: number, buffers: ArrayBufferView[], position: number | null) => number;
readonly link: (filename1: string, filename2: string) => void;
readonly unlink: (filename: string) => void;
readonly symlink: (targetFilename: string, pathFilename: string) => Link;
readonly rename: (oldPathFilename: string, newPathFilename: string) => void;
readonly mkdir: (filename: string, modeNum: number) => void;
/**
* Creates directory tree recursively.
*/
readonly mkdirp: (filename: string, modeNum: number) => string | undefined;
readonly rmdir: (filename: string, recursive?: boolean) => void;
readonly rm: (filename: string, force?: boolean, recursive?: boolean) => void;
protected closeFile(file: File): void;
readonly close: (fd: number) => void;
write(fd: number, buf: Buffer, offset?: number, length?: number, position?: number | null): number;
}

688
node_modules/@jsonjoy.com/fs-core/lib/Superblock.js generated vendored Normal file
View File

@@ -0,0 +1,688 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Superblock = void 0;
const path_1 = require("@jsonjoy.com/fs-node-builtins/lib/path");
const Node_1 = require("./Node");
const Link_1 = require("./Link");
const File_1 = require("./File");
const buffer_1 = require("@jsonjoy.com/fs-node-builtins/lib/internal/buffer");
const process_1 = require("./process");
const fs_node_utils_1 = require("@jsonjoy.com/fs-node-utils");
const fs_node_utils_2 = require("@jsonjoy.com/fs-node-utils");
const util_1 = require("./util");
const json_1 = require("./json");
const result_1 = require("./result");
const pathSep = path_1.posix ? path_1.posix.sep : path_1.sep;
const pathRelative = path_1.posix ? path_1.posix.relative : path_1.relative;
const pathJoin = path_1.posix ? path_1.posix.join : path_1.join;
const { O_RDONLY, O_WRONLY, O_RDWR, O_CREAT, O_EXCL, O_TRUNC, O_APPEND, O_DIRECTORY } = fs_node_utils_1.constants;
/**
* Represents a filesystem superblock, which is the root of a virtual
* filesystem in Linux.
* @see https://lxr.linux.no/linux+v3.11.2/include/linux/fs.h#L1242
*/
class Superblock {
static fromJSON(json, cwd) {
const vol = new Superblock();
vol.fromJSON(json, cwd);
return vol;
}
static fromNestedJSON(json, cwd) {
const vol = new Superblock();
vol.fromNestedJSON(json, cwd);
return vol;
}
constructor(props = {}) {
// I-node number counter.
this.ino = 0;
// A mapping for i-node numbers to i-nodes (`Node`);
this.inodes = {};
// List of released i-node numbers, for reuse.
this.releasedInos = [];
// A mapping for file descriptors to `File`s.
this.fds = {};
// A list of reusable (opened and closed) file descriptors, that should be
// used first before creating a new file descriptor.
this.releasedFds = [];
// Max number of open files.
this.maxFiles = 10000;
// Current number of open files.
this.openFiles = 0;
this.open = (filename, flagsNum, modeNum, resolveSymlinks = true) => {
const file = this.openFile(filename, flagsNum, modeNum, resolveSymlinks);
if (!file)
throw (0, util_1.createError)("ENOENT" /* ERROR_CODE.ENOENT */, 'open', filename);
return file.fd;
};
this.writeFile = (id, buf, flagsNum, modeNum) => {
const isUserFd = typeof id === 'number';
let fd;
if (isUserFd)
fd = id;
else
fd = this.open((0, util_1.pathToFilename)(id), flagsNum, modeNum);
let offset = 0;
let length = buf.length;
let position = flagsNum & O_APPEND ? undefined : 0;
try {
while (length > 0) {
const written = this.write(fd, buf, offset, length, position);
offset += written;
length -= written;
if (position !== undefined)
position += written;
}
}
finally {
if (!isUserFd)
this.close(fd);
}
};
this.read = (fd, buffer, offset, length, position) => {
if (buffer.byteLength < length) {
throw (0, util_1.createError)("ERR_OUT_OF_RANGE" /* ERROR_CODE.ERR_OUT_OF_RANGE */, 'read', undefined, undefined, RangeError);
}
const file = this.getFileByFdOrThrow(fd);
if (file.node.isSymlink()) {
throw (0, util_1.createError)("EPERM" /* ERROR_CODE.EPERM */, 'read', file.link.getPath());
}
return file.read(buffer, Number(offset), Number(length), position === -1 || typeof position !== 'number' ? undefined : position);
};
this.readv = (fd, buffers, position) => {
const file = this.getFileByFdOrThrow(fd);
let p = position ?? undefined;
if (p === -1)
p = undefined;
let bytesRead = 0;
for (const buffer of buffers) {
const bytes = file.read(buffer, 0, buffer.byteLength, p);
p = undefined;
bytesRead += bytes;
if (bytes < buffer.byteLength)
break;
}
return bytesRead;
};
this.link = (filename1, filename2) => {
let link1;
try {
link1 = this.getLinkOrThrow(filename1, 'link');
}
catch (err) {
if (err.code)
err = (0, util_1.createError)(err.code, 'link', filename1, filename2);
throw err;
}
const dirname2 = (0, path_1.dirname)(filename2);
let dir2;
try {
dir2 = this.getLinkOrThrow(dirname2, 'link');
}
catch (err) {
// Augment error with filename1
if (err.code)
err = (0, util_1.createError)(err.code, 'link', filename1, filename2);
throw err;
}
const name = (0, path_1.basename)(filename2);
if (dir2.getChild(name))
throw (0, util_1.createError)("EEXIST" /* ERROR_CODE.EEXIST */, 'link', filename1, filename2);
const node = link1.getNode();
node.nlink++;
dir2.createChild(name, node);
};
this.unlink = (filename) => {
const link = this.getLinkOrThrow(filename, 'unlink');
// TODO: Check if it is file, dir, other...
if (link.length)
throw Error('Dir not empty...');
this.deleteLink(link);
const node = link.getNode();
node.nlink--;
// When all hard links to i-node are deleted, remove the i-node, too.
if (node.nlink <= 0) {
this.deleteNode(node);
}
};
this.symlink = (targetFilename, pathFilename) => {
const pathSteps = (0, util_1.filenameToSteps)(pathFilename);
// Check if directory exists, where we about to create a symlink.
let dirLink;
try {
dirLink = this.getLinkParentAsDirOrThrow(pathSteps);
}
catch (err) {
// Catch error to populate with the correct fields - getLinkParentAsDirOrThrow won't be aware of the second path
if (err.code)
err = (0, util_1.createError)(err.code, 'symlink', targetFilename, pathFilename);
throw err;
}
const name = pathSteps[pathSteps.length - 1];
// Check if new file already exists.
if (dirLink.getChild(name))
throw (0, util_1.createError)("EEXIST" /* ERROR_CODE.EEXIST */, 'symlink', targetFilename, pathFilename);
// Check permissions on the path where we are creating the symlink.
// Note we're not checking permissions on the target path: It is not an error to create a symlink to a
// non-existent or inaccessible target
const node = dirLink.getNode();
if (!node.canExecute() || !node.canWrite())
throw (0, util_1.createError)("EACCES" /* ERROR_CODE.EACCES */, 'symlink', targetFilename, pathFilename);
// Create symlink.
const symlink = dirLink.createChild(name);
symlink.getNode().makeSymlink(targetFilename);
return symlink;
};
this.rename = (oldPathFilename, newPathFilename) => {
let link;
try {
link = this.getResolvedLinkOrThrow(oldPathFilename);
}
catch (err) {
// Augment err with newPathFilename
if (err.code)
err = (0, util_1.createError)(err.code, 'rename', oldPathFilename, newPathFilename);
throw err;
}
// TODO: Check if it is directory, if non-empty, we cannot move it, right?
// Check directory exists for the new location.
let newPathDirLink;
try {
newPathDirLink = this.getLinkParentAsDirOrThrow(newPathFilename);
}
catch (err) {
// Augment error with oldPathFilename
if (err.code)
err = (0, util_1.createError)(err.code, 'rename', oldPathFilename, newPathFilename);
throw err;
}
// TODO: Also treat cases with directories and symbolic links.
// TODO: See: http://man7.org/linux/man-pages/man2/rename.2.html
// Remove hard link from old folder.
const oldLinkParent = link.parent;
if (!oldLinkParent)
throw (0, util_1.createError)("EINVAL" /* ERROR_CODE.EINVAL */, 'rename', oldPathFilename, newPathFilename);
// Check we have access and write permissions in both places
const oldParentNode = oldLinkParent.getNode();
const newPathDirNode = newPathDirLink.getNode();
if (!oldParentNode.canExecute() ||
!oldParentNode.canWrite() ||
!newPathDirNode.canExecute() ||
!newPathDirNode.canWrite()) {
throw (0, util_1.createError)("EACCES" /* ERROR_CODE.EACCES */, 'rename', oldPathFilename, newPathFilename);
}
oldLinkParent.deleteChild(link);
// Rename should overwrite the new path, if that exists.
const name = (0, path_1.basename)(newPathFilename);
link.name = name;
link.steps = [...newPathDirLink.steps, name];
newPathDirLink.setChild(link.getName(), link);
};
this.mkdir = (filename, modeNum) => {
const steps = (0, util_1.filenameToSteps)(filename);
// This will throw if user tries to create root dir `fs.mkdirSync('/')`.
if (!steps.length)
throw (0, util_1.createError)("EEXIST" /* ERROR_CODE.EEXIST */, 'mkdir', filename);
const dir = this.getLinkParentAsDirOrThrow(filename, 'mkdir');
// Check path already exists.
const name = steps[steps.length - 1];
if (dir.getChild(name))
throw (0, util_1.createError)("EEXIST" /* ERROR_CODE.EEXIST */, 'mkdir', filename);
const node = dir.getNode();
if (!node.canWrite() || !node.canExecute())
throw (0, util_1.createError)("EACCES" /* ERROR_CODE.EACCES */, 'mkdir', filename);
dir.createChild(name, this.createNode(fs_node_utils_1.constants.S_IFDIR | modeNum));
};
/**
* Creates directory tree recursively.
*/
this.mkdirp = (filename, modeNum) => {
let created = false;
const steps = (0, util_1.filenameToSteps)(filename);
let curr = null;
let i = steps.length;
// Find the longest subpath of filename that still exists:
for (i = steps.length; i >= 0; i--) {
curr = this.getResolvedLink(steps.slice(0, i));
if (curr)
break;
}
if (!curr) {
curr = this.root;
i = 0;
}
// curr is now the last directory that still exists.
// (If none of them existed, curr is the root.)
// Check access the lazy way:
curr = this.getResolvedLinkOrThrow(path_1.sep + steps.slice(0, i).join(path_1.sep), 'mkdir');
// Start creating directories:
for (i; i < steps.length; i++) {
const node = curr.getNode();
if (node.isDirectory()) {
// Check we have permissions
if (!node.canExecute() || !node.canWrite())
throw (0, util_1.createError)("EACCES" /* ERROR_CODE.EACCES */, 'mkdir', filename);
}
else {
throw (0, util_1.createError)("ENOTDIR" /* ERROR_CODE.ENOTDIR */, 'mkdir', filename);
}
created = true;
curr = curr.createChild(steps[i], this.createNode(fs_node_utils_1.constants.S_IFDIR | modeNum));
}
return created ? filename : undefined;
};
this.rmdir = (filename, recursive = false) => {
const link = this.getLinkAsDirOrThrow(filename, 'rmdir');
if (link.length && !recursive)
throw (0, util_1.createError)("ENOTEMPTY" /* ERROR_CODE.ENOTEMPTY */, 'rmdir', filename);
this.deleteLink(link);
};
this.rm = (filename, force = false, recursive = false) => {
// "stat" is used to match Node's native error message.
let link;
try {
link = this.getResolvedLinkOrThrow(filename, 'stat');
}
catch (err) {
// Silently ignore missing paths if force option is true
if (err.code === "ENOENT" /* ERROR_CODE.ENOENT */ && force)
return;
else
throw err;
}
if (link.getNode().isDirectory() && !recursive)
throw (0, util_1.createError)("ERR_FS_EISDIR" /* ERROR_CODE.ERR_FS_EISDIR */, 'rm', filename);
if (!link.parent?.getNode().canWrite())
throw (0, util_1.createError)("EACCES" /* ERROR_CODE.EACCES */, 'rm', filename);
this.deleteLink(link);
};
this.close = (fd) => {
(0, util_1.validateFd)(fd);
const file = this.getFileByFdOrThrow(fd, 'close');
this.closeFile(file);
};
const root = this.createLink();
root.setNode(this.createNode(fs_node_utils_1.constants.S_IFDIR | 0o777));
root.setChild('.', root);
root.getNode().nlink++;
root.setChild('..', root);
root.getNode().nlink++;
this.root = root;
}
createLink(parent, name, isDirectory = false, mode) {
if (!parent) {
return new Link_1.Link(this, void 0, '');
}
if (!name) {
throw new Error('createLink: name cannot be empty');
}
// If no explicit permission is provided, use defaults based on type
const finalPerm = mode ?? (isDirectory ? 0o777 : 0o666);
// To prevent making a breaking change, `mode` can also just be a permission number
// and the file type is set based on `isDirectory`
const hasFileType = mode && mode & fs_node_utils_1.constants.S_IFMT;
const modeType = hasFileType ? mode & fs_node_utils_1.constants.S_IFMT : isDirectory ? fs_node_utils_1.constants.S_IFDIR : fs_node_utils_1.constants.S_IFREG;
const finalMode = (finalPerm & ~fs_node_utils_1.constants.S_IFMT) | modeType;
return parent.createChild(name, this.createNode(finalMode));
}
deleteLink(link) {
const parent = link.parent;
if (parent) {
parent.deleteChild(link);
return true;
}
return false;
}
newInoNumber() {
const releasedFd = this.releasedInos.pop();
if (releasedFd)
return releasedFd;
else {
this.ino = (this.ino + 1) % 0xffffffff;
return this.ino;
}
}
newFdNumber() {
const releasedFd = this.releasedFds.pop();
return typeof releasedFd === 'number' ? releasedFd : Superblock.fd--;
}
createNode(mode) {
const node = new Node_1.Node(this.newInoNumber(), mode);
this.inodes[node.ino] = node;
return node;
}
deleteNode(node) {
node.del();
delete this.inodes[node.ino];
this.releasedInos.push(node.ino);
}
walk(stepsOrFilenameOrLink, resolveSymlinks = false, checkExistence = false, checkAccess = false, funcName) {
let steps;
let filename;
if (stepsOrFilenameOrLink instanceof Link_1.Link) {
steps = stepsOrFilenameOrLink.steps;
filename = pathSep + steps.join(pathSep);
}
else if (typeof stepsOrFilenameOrLink === 'string') {
steps = (0, util_1.filenameToSteps)(stepsOrFilenameOrLink);
filename = stepsOrFilenameOrLink;
}
else {
steps = stepsOrFilenameOrLink;
filename = pathSep + steps.join(pathSep);
}
let curr = this.root;
let i = 0;
while (i < steps.length) {
let node = curr.getNode();
// Check access permissions if current link is a directory
if (node.isDirectory()) {
if (checkAccess && !node.canExecute()) {
return (0, result_1.Err)((0, util_1.createStatError)("EACCES" /* ERROR_CODE.EACCES */, funcName, filename));
}
}
else {
if (i < steps.length - 1) {
return (0, result_1.Err)((0, util_1.createStatError)("ENOTDIR" /* ERROR_CODE.ENOTDIR */, funcName, filename));
}
}
curr = curr.getChild(steps[i]) ?? null;
// Check existence of current link
if (!curr)
if (checkExistence) {
return (0, result_1.Err)((0, util_1.createStatError)("ENOENT" /* ERROR_CODE.ENOENT */, funcName, filename));
}
else {
return (0, result_1.Ok)(null);
}
node = curr?.getNode();
// Resolve symlink if we're resolving all symlinks OR if this is an intermediate path component
// This allows lstat to traverse through symlinks in intermediate directories while not resolving the final component
if (node.isSymlink() && (resolveSymlinks || i < steps.length - 1)) {
const resolvedPath = (0, path_1.isAbsolute)(node.symlink) ? node.symlink : pathJoin((0, path_1.dirname)(curr.getPath()), node.symlink); // Relative to symlink's parent
steps = (0, util_1.filenameToSteps)(resolvedPath).concat(steps.slice(i + 1));
curr = this.root;
i = 0;
continue;
}
// After resolving symlinks, check if it's not a directory and we still have more steps
// This handles the case where we try to traverse through a file
// Only do this check when we're doing filesystem operations (checkExistence = true)
if (checkExistence && !node.isDirectory() && i < steps.length - 1) {
// On Windows, use ENOENT for consistency with Node.js behavior
// On other platforms, use ENOTDIR which is more semantically correct
const errorCode = process_1.default.platform === 'win32' ? "ENOENT" /* ERROR_CODE.ENOENT */ : "ENOTDIR" /* ERROR_CODE.ENOTDIR */;
return (0, result_1.Err)((0, util_1.createStatError)(errorCode, funcName, filename));
}
i++;
}
return (0, result_1.Ok)(curr);
}
// Returns a `Link` (hard link) referenced by path "split" into steps.
getLink(steps) {
const result = this.walk(steps, false, false, false);
if (result.ok) {
return result.value;
}
throw result.err.toError();
}
// Just link `getLink`, but throws a correct user error, if link to found.
getLinkOrThrow(filename, funcName) {
const result = this.walk(filename, false, true, true, funcName);
if (result.ok) {
return result.value;
}
throw result.err.toError();
}
// Just like `getLink`, but also dereference/resolves symbolic links.
getResolvedLink(filenameOrSteps) {
const result = this.walk(filenameOrSteps, true, false, false);
if (result.ok) {
return result.value;
}
throw result.err.toError();
}
/**
* Just like `getLinkOrThrow`, but also dereference/resolves symbolic links.
*/
getResolvedLinkOrThrow(filename, funcName) {
const result = this.walk(filename, true, true, true, funcName);
if (result.ok) {
return result.value;
}
throw result.err.toError();
}
getResolvedLinkResult(filename, funcName) {
const result = this.walk(filename, true, true, true, funcName);
if (result.ok) {
return (0, result_1.Ok)(result.value);
}
return result;
}
resolveSymlinks(link) {
return this.getResolvedLink(link.steps.slice(1));
}
/**
* Just like `getLinkOrThrow`, but also verifies that the link is a directory.
*/
getLinkAsDirOrThrow(filename, funcName) {
const link = this.getLinkOrThrow(filename, funcName);
if (!link.getNode().isDirectory())
throw (0, util_1.createError)("ENOTDIR" /* ERROR_CODE.ENOTDIR */, funcName, filename);
return link;
}
// Get the immediate parent directory of the link.
getLinkParent(steps) {
return this.getLink(steps.slice(0, -1));
}
getLinkParentAsDirOrThrow(filenameOrSteps, funcName) {
const steps = (filenameOrSteps instanceof Array ? filenameOrSteps : (0, util_1.filenameToSteps)(filenameOrSteps)).slice(0, -1);
const filename = pathSep + steps.join(pathSep);
const link = this.getLinkOrThrow(filename, funcName);
if (!link.getNode().isDirectory())
throw (0, util_1.createError)("ENOTDIR" /* ERROR_CODE.ENOTDIR */, funcName, filename);
return link;
}
getFileByFd(fd) {
return this.fds[String(fd)];
}
getFileByFdOrThrow(fd, funcName) {
if (!(0, util_1.isFd)(fd))
throw TypeError(fs_node_utils_2.ERRSTR.FD);
const file = this.getFileByFd(fd);
if (!file)
throw (0, util_1.createError)("EBADF" /* ERROR_CODE.EBADF */, funcName);
return file;
}
_toJSON(link = this.root, json = {}, path, asBuffer) {
let isEmpty = true;
let children = link.children;
if (link.getNode().isFile()) {
children = new Map([[link.getName(), link.parent.getChild(link.getName())]]);
link = link.parent;
}
for (const name of children.keys()) {
if (name === '.' || name === '..') {
continue;
}
isEmpty = false;
const child = link.getChild(name);
if (!child) {
throw new Error('_toJSON: unexpected undefined');
}
const node = child.getNode();
if (node.isFile()) {
let filename = child.getPath();
if (path)
filename = pathRelative(path, filename);
json[filename] = asBuffer ? node.getBuffer() : node.getString();
}
else if (node.isDirectory()) {
this._toJSON(child, json, path, asBuffer);
}
}
let dirPath = link.getPath();
if (path)
dirPath = pathRelative(path, dirPath);
if (dirPath && isEmpty) {
json[dirPath] = null;
}
return json;
}
toJSON(paths, json = {}, isRelative = false, asBuffer = false) {
const links = [];
if (paths) {
if (!Array.isArray(paths))
paths = [paths];
for (const path of paths) {
const filename = (0, util_1.pathToFilename)(path);
const link = this.getResolvedLink(filename);
if (!link)
continue;
links.push(link);
}
}
else {
links.push(this.root);
}
if (!links.length)
return json;
for (const link of links)
this._toJSON(link, json, isRelative ? link.getPath() : '', asBuffer);
return json;
}
// TODO: `cwd` should probably not invoke `process.cwd()`.
fromJSON(json, cwd = process_1.default.cwd()) {
for (let filename in json) {
const data = json[filename];
filename = (0, util_1.resolve)(filename, cwd);
if (typeof data === 'string' || data instanceof buffer_1.Buffer) {
const dir = (0, path_1.dirname)(filename);
this.mkdirp(dir, 511 /* MODE.DIR */);
const buffer = (0, util_1.dataToBuffer)(data);
this.writeFile(filename, buffer, fs_node_utils_2.FLAGS.w, 438 /* MODE.DEFAULT */);
}
else {
this.mkdirp(filename, 511 /* MODE.DIR */);
}
}
}
fromNestedJSON(json, cwd) {
this.fromJSON((0, json_1.flattenJSON)(json), cwd);
}
reset() {
this.ino = 0;
this.inodes = {};
this.releasedInos = [];
this.fds = {};
this.releasedFds = [];
this.openFiles = 0;
this.root = this.createLink();
this.root.setNode(this.createNode(fs_node_utils_1.constants.S_IFDIR | 0o777));
}
// Legacy interface
mountSync(mountpoint, json) {
this.fromJSON(json, mountpoint);
}
openLink(link, flagsNum, resolveSymlinks = true) {
if (this.openFiles >= this.maxFiles) {
// Too many open files.
throw (0, util_1.createError)("EMFILE" /* ERROR_CODE.EMFILE */, 'open', link.getPath());
}
// Resolve symlinks.
//
// @TODO: This should be superfluous. This method is only ever called by openFile(), which does its own symlink resolution
// prior to calling.
let realLink = link;
if (resolveSymlinks)
realLink = this.getResolvedLinkOrThrow(link.getPath(), 'open');
const node = realLink.getNode();
// Check whether node is a directory
if (node.isDirectory()) {
if ((flagsNum & (O_RDONLY | O_RDWR | O_WRONLY)) !== O_RDONLY)
throw (0, util_1.createError)("EISDIR" /* ERROR_CODE.EISDIR */, 'open', link.getPath());
}
else {
if (flagsNum & O_DIRECTORY)
throw (0, util_1.createError)("ENOTDIR" /* ERROR_CODE.ENOTDIR */, 'open', link.getPath());
}
// Check node permissions
// For read access: check if flags are O_RDONLY or O_RDWR (i.e., not only O_WRONLY)
if ((flagsNum & (O_RDONLY | O_RDWR | O_WRONLY)) !== O_WRONLY) {
if (!node.canRead()) {
throw (0, util_1.createError)("EACCES" /* ERROR_CODE.EACCES */, 'open', link.getPath());
}
}
// For write access: check if flags are O_WRONLY or O_RDWR
if (flagsNum & (O_WRONLY | O_RDWR)) {
if (!node.canWrite()) {
throw (0, util_1.createError)("EACCES" /* ERROR_CODE.EACCES */, 'open', link.getPath());
}
}
const file = new File_1.File(link, node, flagsNum, this.newFdNumber());
this.fds[file.fd] = file;
this.openFiles++;
if (flagsNum & O_TRUNC)
file.truncate();
return file;
}
openFile(filename, flagsNum, modeNum, resolveSymlinks = true) {
const steps = (0, util_1.filenameToSteps)(filename);
let link;
try {
link = resolveSymlinks ? this.getResolvedLinkOrThrow(filename, 'open') : this.getLinkOrThrow(filename, 'open');
// Check if file already existed when trying to create it exclusively (O_CREAT and O_EXCL flags are set).
// This is an error, see https://pubs.opengroup.org/onlinepubs/009695399/functions/open.html:
// "If O_CREAT and O_EXCL are set, open() shall fail if the file exists."
if (link && flagsNum & O_CREAT && flagsNum & O_EXCL)
throw (0, util_1.createError)("EEXIST" /* ERROR_CODE.EEXIST */, 'open', filename);
}
catch (err) {
// Try creating a new file, if it does not exist and O_CREAT flag is set.
// Note that this will still throw if the ENOENT came from one of the
// intermediate directories instead of the file itself.
if (err.code === "ENOENT" /* ERROR_CODE.ENOENT */ && flagsNum & O_CREAT) {
const dirName = (0, path_1.dirname)(filename);
const dirLink = this.getResolvedLinkOrThrow(dirName);
const dirNode = dirLink.getNode();
// Check that the place we create the new file is actually a directory and that we are allowed to do so:
if (!dirNode.isDirectory())
throw (0, util_1.createError)("ENOTDIR" /* ERROR_CODE.ENOTDIR */, 'open', filename);
if (!dirNode.canExecute() || !dirNode.canWrite())
throw (0, util_1.createError)("EACCES" /* ERROR_CODE.EACCES */, 'open', filename);
// This is a difference to the original implementation, which would simply not create a file unless modeNum was specified.
// However, current Node versions will default to 0o666.
modeNum ?? (modeNum = 0o666);
link = this.createLink(dirLink, steps[steps.length - 1], false, modeNum);
}
else
throw err;
}
if (link)
return this.openLink(link, flagsNum, resolveSymlinks);
throw (0, util_1.createError)("ENOENT" /* ERROR_CODE.ENOENT */, 'open', filename);
}
closeFile(file) {
if (!this.fds[file.fd])
return;
this.openFiles--;
delete this.fds[file.fd];
this.releasedFds.push(file.fd);
}
write(fd, buf, offset, length, position) {
const file = this.getFileByFdOrThrow(fd, 'write');
if (file.node.isSymlink()) {
throw (0, util_1.createError)("EBADF" /* ERROR_CODE.EBADF */, 'write', file.link.getPath());
}
return file.write(buf, offset, length, position === -1 || typeof position !== 'number' ? undefined : position);
}
}
exports.Superblock = Superblock;
/**
* Global file descriptor counter. UNIX file descriptors start from 0 and go sequentially
* up, so here, in order not to conflict with them, we choose some big number and descrease
* the file descriptor of every new opened file.
* @type {number}
* @todo This should not be static, right?
*/
Superblock.fd = 0x7fffffff;
//# sourceMappingURL=Superblock.js.map

File diff suppressed because one or more lines are too long

15
node_modules/@jsonjoy.com/fs-core/lib/constants.d.ts generated vendored Normal file
View File

@@ -0,0 +1,15 @@
export declare const enum ERROR_CODE {
EPERM = "EPERM",
ENOENT = "ENOENT",
EBADF = "EBADF",
EINVAL = "EINVAL",
EEXIST = "EEXIST",
ENOTDIR = "ENOTDIR",
EMFILE = "EMFILE",
EACCES = "EACCES",
EISDIR = "EISDIR",
ENOTEMPTY = "ENOTEMPTY",
ENOSYS = "ENOSYS",
ERR_FS_EISDIR = "ERR_FS_EISDIR",
ERR_OUT_OF_RANGE = "ERR_OUT_OF_RANGE"
}

3
node_modules/@jsonjoy.com/fs-core/lib/constants.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=constants.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":""}

6
node_modules/@jsonjoy.com/fs-core/lib/encoding.d.ts generated vendored Normal file
View File

@@ -0,0 +1,6 @@
import { Buffer } from '@jsonjoy.com/fs-node-builtins/lib/internal/buffer';
export type TDataOut = string | Buffer;
export type TEncodingExtended = BufferEncoding | 'buffer';
export declare const ENCODING_UTF8: BufferEncoding;
export declare function assertEncoding(encoding: string | undefined): void;
export declare function strToEncoding(str: string, encoding?: TEncodingExtended): TDataOut;

20
node_modules/@jsonjoy.com/fs-core/lib/encoding.js generated vendored Normal file
View File

@@ -0,0 +1,20 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ENCODING_UTF8 = void 0;
exports.assertEncoding = assertEncoding;
exports.strToEncoding = strToEncoding;
const buffer_1 = require("@jsonjoy.com/fs-node-builtins/lib/internal/buffer");
const errors = require("@jsonjoy.com/fs-node-builtins/lib/internal/errors");
exports.ENCODING_UTF8 = 'utf8';
function assertEncoding(encoding) {
if (encoding && !buffer_1.Buffer.isEncoding(encoding))
throw new errors.TypeError('ERR_INVALID_OPT_VALUE_ENCODING', encoding);
}
function strToEncoding(str, encoding) {
if (!encoding || encoding === exports.ENCODING_UTF8)
return str; // UTF-8
if (encoding === 'buffer')
return new buffer_1.Buffer(str); // `buffer` encoding
return new buffer_1.Buffer(str).toString(encoding); // Custom encoding
}
//# sourceMappingURL=encoding.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"encoding.js","sourceRoot":"","sources":["../src/encoding.ts"],"names":[],"mappings":";;;AAQA,wCAEC;AAED,sCAIC;AAhBD,8EAA2E;AAC3E,4EAA4E;AAK/D,QAAA,aAAa,GAAmB,MAAM,CAAC;AAEpD,SAAgB,cAAc,CAAC,QAA4B;IACzD,IAAI,QAAQ,IAAI,CAAC,eAAM,CAAC,UAAU,CAAC,QAAQ,CAAC;QAAE,MAAM,IAAI,MAAM,CAAC,SAAS,CAAC,gCAAgC,EAAE,QAAQ,CAAC,CAAC;AACvH,CAAC;AAED,SAAgB,aAAa,CAAC,GAAW,EAAE,QAA4B;IACrE,IAAI,CAAC,QAAQ,IAAI,QAAQ,KAAK,qBAAa;QAAE,OAAO,GAAG,CAAC,CAAC,QAAQ;IACjE,IAAI,QAAQ,KAAK,QAAQ;QAAE,OAAO,IAAI,eAAM,CAAC,GAAG,CAAC,CAAC,CAAC,oBAAoB;IACvE,OAAO,IAAI,eAAM,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,kBAAkB;AAC/D,CAAC"}

9
node_modules/@jsonjoy.com/fs-core/lib/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,9 @@
export * from './types';
export * from './json';
export * from './constants';
export * from './result';
export { Node, type NodeEvent } from './Node';
export { Link, type LinkEvent } from './Link';
export { File } from './File';
export { Superblock } from './Superblock';
export { dataToBuffer, filenameToSteps, isFd, validateFd, createError, createStatError, pathToFilename, resolve, } from './util';

26
node_modules/@jsonjoy.com/fs-core/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,26 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.resolve = exports.pathToFilename = exports.createStatError = exports.createError = exports.validateFd = exports.isFd = exports.filenameToSteps = exports.dataToBuffer = exports.Superblock = exports.File = exports.Link = exports.Node = void 0;
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./types"), exports);
tslib_1.__exportStar(require("./json"), exports);
tslib_1.__exportStar(require("./constants"), exports);
tslib_1.__exportStar(require("./result"), exports);
var Node_1 = require("./Node");
Object.defineProperty(exports, "Node", { enumerable: true, get: function () { return Node_1.Node; } });
var Link_1 = require("./Link");
Object.defineProperty(exports, "Link", { enumerable: true, get: function () { return Link_1.Link; } });
var File_1 = require("./File");
Object.defineProperty(exports, "File", { enumerable: true, get: function () { return File_1.File; } });
var Superblock_1 = require("./Superblock");
Object.defineProperty(exports, "Superblock", { enumerable: true, get: function () { return Superblock_1.Superblock; } });
var util_1 = require("./util");
Object.defineProperty(exports, "dataToBuffer", { enumerable: true, get: function () { return util_1.dataToBuffer; } });
Object.defineProperty(exports, "filenameToSteps", { enumerable: true, get: function () { return util_1.filenameToSteps; } });
Object.defineProperty(exports, "isFd", { enumerable: true, get: function () { return util_1.isFd; } });
Object.defineProperty(exports, "validateFd", { enumerable: true, get: function () { return util_1.validateFd; } });
Object.defineProperty(exports, "createError", { enumerable: true, get: function () { return util_1.createError; } });
Object.defineProperty(exports, "createStatError", { enumerable: true, get: function () { return util_1.createStatError; } });
Object.defineProperty(exports, "pathToFilename", { enumerable: true, get: function () { return util_1.pathToFilename; } });
Object.defineProperty(exports, "resolve", { enumerable: true, get: function () { return util_1.resolve; } });
//# sourceMappingURL=index.js.map

1
node_modules/@jsonjoy.com/fs-core/lib/index.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,kDAAwB;AACxB,iDAAuB;AACvB,sDAA4B;AAC5B,mDAAyB;AACzB,+BAA8C;AAArC,4FAAA,IAAI,OAAA;AACb,+BAA8C;AAArC,4FAAA,IAAI,OAAA;AACb,+BAA8B;AAArB,4FAAA,IAAI,OAAA;AACb,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,+BASgB;AARd,oGAAA,YAAY,OAAA;AACZ,uGAAA,eAAe,OAAA;AACf,4FAAA,IAAI,OAAA;AACJ,kGAAA,UAAU,OAAA;AACV,mGAAA,WAAW,OAAA;AACX,uGAAA,eAAe,OAAA;AACf,sGAAA,cAAc,OAAA;AACd,+FAAA,OAAO,OAAA"}

9
node_modules/@jsonjoy.com/fs-core/lib/json.d.ts generated vendored Normal file
View File

@@ -0,0 +1,9 @@
import { Buffer } from '@jsonjoy.com/fs-node-builtins/lib/internal/buffer';
export type DirectoryContent = string | Buffer | null;
export interface DirectoryJSON<T extends DirectoryContent = DirectoryContent> {
[key: string]: T;
}
export interface NestedDirectoryJSON<T extends DirectoryContent = DirectoryContent> {
[key: string]: T | NestedDirectoryJSON;
}
export declare const flattenJSON: (nestedJSON: NestedDirectoryJSON) => DirectoryJSON;

35
node_modules/@jsonjoy.com/fs-core/lib/json.js generated vendored Normal file
View File

@@ -0,0 +1,35 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.flattenJSON = void 0;
const buffer_1 = require("@jsonjoy.com/fs-node-builtins/lib/internal/buffer");
const path_1 = require("@jsonjoy.com/fs-node-builtins/lib/path");
const pathJoin = path_1.posix ? path_1.posix.join : path_1.join;
const flattenJSON = (nestedJSON) => {
const flatJSON = {};
function flatten(pathPrefix, node) {
for (const path in node) {
const contentOrNode = node[path];
// TODO: Can we avoid using `join` here? Just concatenate?
const joinedPath = pathJoin(pathPrefix, path);
if (typeof contentOrNode === 'string' || contentOrNode instanceof buffer_1.Buffer) {
flatJSON[joinedPath] = contentOrNode;
}
else if (typeof contentOrNode === 'object' &&
contentOrNode !== null &&
!(contentOrNode instanceof buffer_1.Buffer) &&
Object.keys(contentOrNode).length > 0) {
// empty directories need an explicit entry and therefore get handled in `else`, non-empty ones are implicitly considered
flatten(joinedPath, contentOrNode);
}
else {
// without this branch null, empty-object or non-object entries would not be handled in the same way
// by both fromJSON() and fromNestedJSON()
flatJSON[joinedPath] = null;
}
}
}
flatten('', nestedJSON);
return flatJSON;
};
exports.flattenJSON = flattenJSON;
//# sourceMappingURL=json.js.map

1
node_modules/@jsonjoy.com/fs-core/lib/json.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"json.js","sourceRoot":"","sources":["../src/json.ts"],"names":[],"mappings":";;;AAAA,8EAA2E;AAC3E,iEAAqE;AAErE,MAAM,QAAQ,GAAG,YAAK,CAAC,CAAC,CAAC,YAAK,CAAC,IAAI,CAAC,CAAC,CAAC,WAAI,CAAC;AAWpC,MAAM,WAAW,GAAG,CAAC,UAA+B,EAAiB,EAAE;IAC5E,MAAM,QAAQ,GAAkB,EAAE,CAAC;IACnC,SAAS,OAAO,CAAC,UAAkB,EAAE,IAAyB;QAC5D,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;YACxB,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;YACjC,0DAA0D;YAC1D,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;YAC9C,IAAI,OAAO,aAAa,KAAK,QAAQ,IAAI,aAAa,YAAY,eAAM,EAAE,CAAC;gBACzE,QAAQ,CAAC,UAAU,CAAC,GAAG,aAAa,CAAC;YACvC,CAAC;iBAAM,IACL,OAAO,aAAa,KAAK,QAAQ;gBACjC,aAAa,KAAK,IAAI;gBACtB,CAAC,CAAC,aAAa,YAAY,eAAM,CAAC;gBAClC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,MAAM,GAAG,CAAC,EACrC,CAAC;gBACD,yHAAyH;gBACzH,OAAO,CAAC,UAAU,EAAE,aAAsD,CAAC,CAAC;YAC9E,CAAC;iBAAM,CAAC;gBACN,oGAAoG;gBACpG,0CAA0C;gBAC1C,QAAQ,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;YAC9B,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;IACxB,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AA1BW,QAAA,WAAW,eA0BtB"}

11
node_modules/@jsonjoy.com/fs-core/lib/process.d.ts generated vendored Normal file
View File

@@ -0,0 +1,11 @@
export interface IProcess {
getuid?(): number;
getgid?(): number;
cwd(): string;
platform: string;
emitWarning: (message: string, type: string) => void;
env: {};
}
export declare function createProcess(): IProcess;
declare const _default: IProcess;
export default _default;

40
node_modules/@jsonjoy.com/fs-core/lib/process.js generated vendored Normal file
View File

@@ -0,0 +1,40 @@
"use strict";
// Here we mock the global `process` variable in case we are not in Node's environment.
Object.defineProperty(exports, "__esModule", { value: true });
exports.createProcess = createProcess;
/**
* Looks to return a `process` object, if one is available.
*
* The global `process` is returned if defined;
* otherwise `require('process')` is attempted.
*
* If that fails, `undefined` is returned.
*
* @return {IProcess | undefined}
*/
const maybeReturnProcess = () => {
if (typeof process !== 'undefined') {
return process;
}
try {
return require('process');
}
catch {
return undefined;
}
};
function createProcess() {
const p = maybeReturnProcess() || {};
if (!p.cwd)
p.cwd = () => '/';
if (!p.emitWarning)
p.emitWarning = (message, type) => {
// tslint:disable-next-line:no-console
console.warn(`${type}${type ? ': ' : ''}${message}`);
};
if (!p.env)
p.env = {};
return p;
}
exports.default = createProcess();
//# sourceMappingURL=process.js.map

1
node_modules/@jsonjoy.com/fs-core/lib/process.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"process.js","sourceRoot":"","sources":["../src/process.ts"],"names":[],"mappings":";AAAA,uFAAuF;;AAgCvF,sCAUC;AA/BD;;;;;;;;;GASG;AACH,MAAM,kBAAkB,GAAG,GAAyB,EAAE;IACpD,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE,CAAC;QACnC,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,IAAI,CAAC;QACH,OAAO,OAAO,CAAC,SAAS,CAAC,CAAC;IAC5B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC,CAAC;AAEF,SAAgB,aAAa;IAC3B,MAAM,CAAC,GAAa,kBAAkB,EAAE,IAAK,EAAe,CAAC;IAC7D,IAAI,CAAC,CAAC,CAAC,GAAG;QAAE,CAAC,CAAC,GAAG,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC;IAC9B,IAAI,CAAC,CAAC,CAAC,WAAW;QAChB,CAAC,CAAC,WAAW,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE;YAChC,sCAAsC;YACtC,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;QACvD,CAAC,CAAC;IACJ,IAAI,CAAC,CAAC,CAAC,GAAG;QAAE,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC;IACvB,OAAO,CAAC,CAAC;AACX,CAAC;AAED,kBAAe,aAAa,EAAE,CAAC"}

11
node_modules/@jsonjoy.com/fs-core/lib/result.d.ts generated vendored Normal file
View File

@@ -0,0 +1,11 @@
export interface Ok<T> {
ok: true;
value: T;
}
export interface Err<E> {
ok: false;
err: E;
}
export type Result<T, E> = Ok<T> | Err<E>;
export declare function Ok<T>(value: T): Ok<T>;
export declare function Err<E>(err: E): Err<E>;

11
node_modules/@jsonjoy.com/fs-core/lib/result.js generated vendored Normal file
View File

@@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Ok = Ok;
exports.Err = Err;
function Ok(value) {
return { ok: true, value };
}
function Err(err) {
return { ok: false, err };
}
//# sourceMappingURL=result.js.map

1
node_modules/@jsonjoy.com/fs-core/lib/result.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"result.js","sourceRoot":"","sources":["../src/result.ts"],"names":[],"mappings":";;AAYA,gBAEC;AAED,kBAEC;AAND,SAAgB,EAAE,CAAI,KAAQ;IAC5B,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;AAC7B,CAAC;AAED,SAAgB,GAAG,CAAI,GAAM;IAC3B,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;AAC5B,CAAC"}

8
node_modules/@jsonjoy.com/fs-core/lib/types.d.ts generated vendored Normal file
View File

@@ -0,0 +1,8 @@
import type { PathLike } from '@jsonjoy.com/fs-node-utils/lib/types/misc';
export type TFileId = PathLike | number;
export interface StatError {
code: string;
message: string;
path?: string;
toError(): Error;
}

3
node_modules/@jsonjoy.com/fs-core/lib/types.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=types.js.map

1
node_modules/@jsonjoy.com/fs-core/lib/types.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}

18
node_modules/@jsonjoy.com/fs-core/lib/util.d.ts generated vendored Normal file
View File

@@ -0,0 +1,18 @@
import { Buffer } from '@jsonjoy.com/fs-node-builtins/lib/internal/buffer';
import { TDataOut, TEncodingExtended } from './encoding';
import type * as misc from '@jsonjoy.com/fs-node-utils/lib/types/misc';
import type { StatError } from './types';
export declare const isWin: boolean;
type TData = TDataOut | ArrayBufferView | DataView;
export declare const unixify: (filepath: string, stripTrailing?: boolean) => string;
type TResolve = (filename: string, base?: string) => string;
declare let resolve: TResolve;
export { resolve };
export declare const filenameToSteps: (filename: string, base?: string) => string[];
export declare function isFd(path: any): boolean;
export declare function validateFd(fd: any): void;
export declare function dataToBuffer(data: TData, encoding?: TEncodingExtended): Buffer;
export declare function nullCheck(path: any, callback?: any): boolean;
export declare function pathToFilename(path: misc.PathLike): string;
export declare function createError(errorCode: string, func?: string, path?: string, path2?: string, Constructor?: ErrorConstructor): Error;
export declare function createStatError(errorCode: string, func?: string, path?: string, path2?: string): StatError;

199
node_modules/@jsonjoy.com/fs-core/lib/util.js generated vendored Normal file
View File

@@ -0,0 +1,199 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.filenameToSteps = exports.resolve = exports.unixify = exports.isWin = void 0;
exports.isFd = isFd;
exports.validateFd = validateFd;
exports.dataToBuffer = dataToBuffer;
exports.nullCheck = nullCheck;
exports.pathToFilename = pathToFilename;
exports.createError = createError;
exports.createStatError = createStatError;
const path_1 = require("@jsonjoy.com/fs-node-builtins/lib/path");
const buffer_1 = require("@jsonjoy.com/fs-node-builtins/lib/internal/buffer");
const errors = require("@jsonjoy.com/fs-node-builtins/lib/internal/errors");
const process_1 = require("./process");
const encoding_1 = require("./encoding");
const fs_node_utils_1 = require("@jsonjoy.com/fs-node-utils");
exports.isWin = process_1.default.platform === 'win32';
const resolveCrossPlatform = path_1.resolve;
const pathSep = path_1.posix ? path_1.posix.sep : path_1.sep;
const isSeparator = (str, i) => {
let char = str[i];
return i > 0 && (char === '/' || (exports.isWin && char === '\\'));
};
const removeTrailingSeparator = (str) => {
let i = str.length - 1;
if (i < 2)
return str;
while (isSeparator(str, i))
i--;
return str.substr(0, i + 1);
};
const normalizePath = (str, stripTrailing) => {
if (typeof str !== 'string')
throw new TypeError('expected a string');
str = str.replace(/[\\\/]+/g, '/');
if (stripTrailing !== false)
str = removeTrailingSeparator(str);
return str;
};
const unixify = (filepath, stripTrailing = true) => {
if (exports.isWin) {
filepath = normalizePath(filepath, stripTrailing);
return filepath.replace(/^([a-zA-Z]+:|\.\/)/, '');
}
return filepath;
};
exports.unixify = unixify;
let resolve = (filename, base = process_1.default.cwd()) => resolveCrossPlatform(base, filename);
exports.resolve = resolve;
if (exports.isWin) {
const _resolve = resolve;
exports.resolve = resolve = (filename, base) => (0, exports.unixify)(_resolve(filename, base));
}
const filenameToSteps = (filename, base) => {
const fullPath = resolve(filename, base);
const fullPathSansSlash = fullPath.substring(1);
if (!fullPathSansSlash)
return [];
return fullPathSansSlash.split(pathSep);
};
exports.filenameToSteps = filenameToSteps;
function isFd(path) {
return path >>> 0 === path;
}
function validateFd(fd) {
if (!isFd(fd))
throw TypeError(fs_node_utils_1.ERRSTR.FD);
}
function dataToBuffer(data, encoding = encoding_1.ENCODING_UTF8) {
if (buffer_1.Buffer.isBuffer(data))
return data;
else if (data instanceof Uint8Array)
return (0, buffer_1.bufferFrom)(data);
else if (encoding === 'buffer')
return (0, buffer_1.bufferFrom)(String(data), 'utf8');
else
return (0, buffer_1.bufferFrom)(String(data), encoding);
}
function nullCheck(path, callback) {
if (('' + path).indexOf('\u0000') !== -1) {
const er = new Error('Path must be a string without null bytes');
er.code = 'ENOENT';
if (typeof callback !== 'function')
throw er;
Promise.resolve().then(() => callback(er));
return false;
}
return true;
}
function getPathFromURLPosix(url) {
if (url.hostname !== '') {
throw new errors.TypeError('ERR_INVALID_FILE_URL_HOST', process_1.default.platform);
}
const pathname = url.pathname;
for (let n = 0; n < pathname.length; n++) {
if (pathname[n] === '%') {
const third = pathname.codePointAt(n + 2) | 0x20;
if (pathname[n + 1] === '2' && third === 102) {
throw new errors.TypeError('ERR_INVALID_FILE_URL_PATH', 'must not include encoded / characters');
}
}
}
return decodeURIComponent(pathname);
}
function pathToFilename(path) {
if (path instanceof Uint8Array) {
path = (0, buffer_1.bufferFrom)(path);
}
if (typeof path !== 'string' && !buffer_1.Buffer.isBuffer(path)) {
try {
if (!(path instanceof require('url').URL))
throw new TypeError(fs_node_utils_1.ERRSTR.PATH_STR);
}
catch (err) {
throw new TypeError(fs_node_utils_1.ERRSTR.PATH_STR);
}
path = getPathFromURLPosix(path);
}
const pathString = String(path);
nullCheck(pathString);
return pathString;
}
const ENOENT = 'ENOENT';
const EBADF = 'EBADF';
const EINVAL = 'EINVAL';
const EPERM = 'EPERM';
const EPROTO = 'EPROTO';
const EEXIST = 'EEXIST';
const ENOTDIR = 'ENOTDIR';
const EMFILE = 'EMFILE';
const EACCES = 'EACCES';
const EISDIR = 'EISDIR';
const ENOTEMPTY = 'ENOTEMPTY';
const ENOSYS = 'ENOSYS';
const ERR_FS_EISDIR = 'ERR_FS_EISDIR';
const ERR_OUT_OF_RANGE = 'ERR_OUT_OF_RANGE';
function formatError(errorCode, func = '', path = '', path2 = '') {
let pathFormatted = '';
if (path)
pathFormatted = ` '${path}'`;
if (path2)
pathFormatted += ` -> '${path2}'`;
switch (errorCode) {
case ENOENT:
return `ENOENT: no such file or directory, ${func}${pathFormatted}`;
case EBADF:
return `EBADF: bad file descriptor, ${func}${pathFormatted}`;
case EINVAL:
return `EINVAL: invalid argument, ${func}${pathFormatted}`;
case EPERM:
return `EPERM: operation not permitted, ${func}${pathFormatted}`;
case EPROTO:
return `EPROTO: protocol error, ${func}${pathFormatted}`;
case EEXIST:
return `EEXIST: file already exists, ${func}${pathFormatted}`;
case ENOTDIR:
return `ENOTDIR: not a directory, ${func}${pathFormatted}`;
case EISDIR:
return `EISDIR: illegal operation on a directory, ${func}${pathFormatted}`;
case EACCES:
return `EACCES: permission denied, ${func}${pathFormatted}`;
case ENOTEMPTY:
return `ENOTEMPTY: directory not empty, ${func}${pathFormatted}`;
case EMFILE:
return `EMFILE: too many open files, ${func}${pathFormatted}`;
case ENOSYS:
return `ENOSYS: function not implemented, ${func}${pathFormatted}`;
case ERR_FS_EISDIR:
return `[ERR_FS_EISDIR]: Path is a directory: ${func} returned EISDIR (is a directory) ${path}`;
case ERR_OUT_OF_RANGE:
return `[ERR_OUT_OF_RANGE]: value out of range, ${func}${pathFormatted}`;
default:
return `${errorCode}: error occurred, ${func}${pathFormatted}`;
}
}
function createError(errorCode, func = '', path = '', path2 = '', Constructor = Error) {
const error = new Constructor(formatError(errorCode, func, path, path2));
error.code = errorCode;
if (path) {
error.path = path;
}
return error;
}
function createStatError(errorCode, func = '', path = '', path2 = '') {
return {
code: errorCode,
message: formatError(errorCode, func, path, path2),
path,
toError() {
const error = new Error(this.message);
error.code = this.code;
if (this.path) {
error.path = this.path;
}
return error;
},
};
}
//# sourceMappingURL=util.js.map

1
node_modules/@jsonjoy.com/fs-core/lib/util.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long