Initial commit

This commit is contained in:
2025-03-07 19:22:02 +01:00
commit 4a98255d83
55743 changed files with 5280367 additions and 0 deletions
+72
View File
@@ -0,0 +1,72 @@
import { NodeFileSystemHandle } from './NodeFileSystemHandle';
import type { NodeFsaContext, NodeFsaFs } from './types';
import type { GetDirectoryHandleOptions, GetFileHandleOptions, IFileSystemDirectoryHandle, IFileSystemFileHandle, RemoveEntryOptions } from '../fsa/types';
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle
*/
export declare class NodeFileSystemDirectoryHandle extends NodeFileSystemHandle implements IFileSystemDirectoryHandle {
protected readonly fs: NodeFsaFs;
protected readonly ctx: Partial<NodeFsaContext>;
/** Directory path with trailing slash. */
readonly __path: string;
constructor(fs: NodeFsaFs, path: string, ctx?: Partial<NodeFsaContext>);
/**
* Returns a new array iterator containing the keys for each item in
* {@link NodeFileSystemDirectoryHandle} object.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle/keys
*/
keys(): AsyncIterableIterator<string>;
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle/entries
*/
entries(): AsyncIterableIterator<[string, NodeFileSystemHandle]>;
/**
* Returns a new array iterator containing the values for each index in the
* {@link FileSystemDirectoryHandle} object.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle/values
*/
values(): AsyncIterableIterator<NodeFileSystemHandle>;
/**
* Returns a {@link NodeFileSystemDirectoryHandle} for a subdirectory with the specified
* name within the directory handle on which the method is called.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle/getDirectoryHandle
* @param name A string representing the {@link NodeFileSystemHandle} name of
* the subdirectory you wish to retrieve.
* @param options An optional object containing options for the retrieved
* subdirectory.
*/
getDirectoryHandle(name: string, options?: GetDirectoryHandleOptions): Promise<IFileSystemDirectoryHandle>;
/**
* Returns a {@link FileSystemFileHandle} for a file with the specified name,
* within the directory the method is called.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle/getFileHandle
* @param name A string representing the {@link NodeFileSystemHandle} name of
* the file you wish to retrieve.
* @param options An optional object containing options for the retrieved file.
*/
getFileHandle(name: string, options?: GetFileHandleOptions): Promise<IFileSystemFileHandle>;
/**
* Attempts to remove an entry if the directory handle contains a file or
* directory called the name specified.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle/removeEntry
* @param name A string representing the {@link FileSystemHandle} name of the
* entry you wish to remove.
* @param options An optional object containing options.
*/
removeEntry(name: string, { recursive }?: RemoveEntryOptions): Promise<void>;
/**
* The `resolve()` method of the {@link FileSystemDirectoryHandle} interface
* returns an {@link Array} of directory names from the parent handle to the specified
* child entry, with the name of the child entry as the last array item.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle/resolve
* @param possibleDescendant The {@link NodeFileSystemFileHandle} from which
* to return the relative path.
*/
resolve(possibleDescendant: NodeFileSystemHandle): Promise<string[] | null>;
}
+225
View File
@@ -0,0 +1,225 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NodeFileSystemDirectoryHandle = void 0;
const tslib_1 = require("tslib");
const NodeFileSystemHandle_1 = require("./NodeFileSystemHandle");
const util_1 = require("./util");
const NodeFileSystemFileHandle_1 = require("./NodeFileSystemFileHandle");
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle
*/
class NodeFileSystemDirectoryHandle extends NodeFileSystemHandle_1.NodeFileSystemHandle {
constructor(fs, path, ctx = {}) {
super('directory', (0, util_1.basename)(path, ctx.separator || '/'));
this.fs = fs;
this.ctx = (0, util_1.ctx)(ctx);
this.__path = path[path.length - 1] === this.ctx.separator ? path : path + this.ctx.separator;
}
/**
* Returns a new array iterator containing the keys for each item in
* {@link NodeFileSystemDirectoryHandle} object.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle/keys
*/
keys() {
return tslib_1.__asyncGenerator(this, arguments, function* keys_1() {
const list = yield tslib_1.__await(this.fs.promises.readdir(this.__path));
for (const name of list)
yield yield tslib_1.__await('' + name);
});
}
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle/entries
*/
entries() {
return tslib_1.__asyncGenerator(this, arguments, function* entries_1() {
const { __path: path, fs, ctx } = this;
const list = yield tslib_1.__await(fs.promises.readdir(path, { withFileTypes: true }));
for (const d of list) {
const dirent = d;
const name = dirent.name + '';
const newPath = path + name;
if (dirent.isDirectory())
yield yield tslib_1.__await([name, new NodeFileSystemDirectoryHandle(fs, newPath, ctx)]);
else if (dirent.isFile())
yield yield tslib_1.__await([name, new NodeFileSystemFileHandle_1.NodeFileSystemFileHandle(fs, newPath, ctx)]);
}
});
}
/**
* Returns a new array iterator containing the values for each index in the
* {@link FileSystemDirectoryHandle} object.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle/values
*/
values() {
return tslib_1.__asyncGenerator(this, arguments, function* values_1() {
var _a, e_1, _b, _c;
try {
for (var _d = true, _e = tslib_1.__asyncValues(this.entries()), _f; _f = yield tslib_1.__await(_e.next()), _a = _f.done, !_a; _d = true) {
_c = _f.value;
_d = false;
const [, value] = _c;
yield yield tslib_1.__await(value);
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (!_d && !_a && (_b = _e.return)) yield tslib_1.__await(_b.call(_e));
}
finally { if (e_1) throw e_1.error; }
}
});
}
/**
* Returns a {@link NodeFileSystemDirectoryHandle} for a subdirectory with the specified
* name within the directory handle on which the method is called.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle/getDirectoryHandle
* @param name A string representing the {@link NodeFileSystemHandle} name of
* the subdirectory you wish to retrieve.
* @param options An optional object containing options for the retrieved
* subdirectory.
*/
async getDirectoryHandle(name, options) {
(0, util_1.assertName)(name, 'getDirectoryHandle', 'FileSystemDirectoryHandle');
const filename = this.__path + name;
try {
const stats = await this.fs.promises.stat(filename);
if (!stats.isDirectory())
throw (0, util_1.newTypeMismatchError)();
return new NodeFileSystemDirectoryHandle(this.fs, filename, this.ctx);
}
catch (error) {
if (error instanceof DOMException)
throw error;
if (error && typeof error === 'object') {
switch (error.code) {
case 'ENOENT': {
if (options === null || options === void 0 ? void 0 : options.create) {
(0, util_1.assertCanWrite)(this.ctx.mode);
await this.fs.promises.mkdir(filename);
return new NodeFileSystemDirectoryHandle(this.fs, filename, this.ctx);
}
throw (0, util_1.newNotFoundError)();
}
case 'EPERM':
case 'EACCES':
throw (0, util_1.newNotAllowedError)();
}
}
throw error;
}
}
/**
* Returns a {@link FileSystemFileHandle} for a file with the specified name,
* within the directory the method is called.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle/getFileHandle
* @param name A string representing the {@link NodeFileSystemHandle} name of
* the file you wish to retrieve.
* @param options An optional object containing options for the retrieved file.
*/
async getFileHandle(name, options) {
(0, util_1.assertName)(name, 'getFileHandle', 'FileSystemDirectoryHandle');
const filename = this.__path + name;
try {
const stats = await this.fs.promises.stat(filename);
if (!stats.isFile())
throw (0, util_1.newTypeMismatchError)();
return new NodeFileSystemFileHandle_1.NodeFileSystemFileHandle(this.fs, filename, this.ctx);
}
catch (error) {
if (error instanceof DOMException)
throw error;
if (error && typeof error === 'object') {
switch (error.code) {
case 'ENOENT': {
if (options === null || options === void 0 ? void 0 : options.create) {
(0, util_1.assertCanWrite)(this.ctx.mode);
await this.fs.promises.writeFile(filename, '');
return new NodeFileSystemFileHandle_1.NodeFileSystemFileHandle(this.fs, filename, this.ctx);
}
throw (0, util_1.newNotFoundError)();
}
case 'EPERM':
case 'EACCES':
throw (0, util_1.newNotAllowedError)();
}
}
throw error;
}
}
/**
* Attempts to remove an entry if the directory handle contains a file or
* directory called the name specified.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle/removeEntry
* @param name A string representing the {@link FileSystemHandle} name of the
* entry you wish to remove.
* @param options An optional object containing options.
*/
async removeEntry(name, { recursive = false } = {}) {
(0, util_1.assertCanWrite)(this.ctx.mode);
(0, util_1.assertName)(name, 'removeEntry', 'FileSystemDirectoryHandle');
const filename = this.__path + name;
const promises = this.fs.promises;
try {
const stats = await promises.stat(filename);
if (stats.isFile()) {
await promises.unlink(filename);
}
else if (stats.isDirectory()) {
await promises.rmdir(filename, { recursive });
}
else
throw (0, util_1.newTypeMismatchError)();
}
catch (error) {
if (error instanceof DOMException)
throw error;
if (error && typeof error === 'object') {
switch (error.code) {
case 'ENOENT': {
throw (0, util_1.newNotFoundError)();
}
case 'EPERM':
case 'EACCES':
throw (0, util_1.newNotAllowedError)();
case 'ENOTEMPTY':
throw new DOMException('The object can not be modified in this way.', 'InvalidModificationError');
}
}
throw error;
}
}
/**
* The `resolve()` method of the {@link FileSystemDirectoryHandle} interface
* returns an {@link Array} of directory names from the parent handle to the specified
* child entry, with the name of the child entry as the last array item.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle/resolve
* @param possibleDescendant The {@link NodeFileSystemFileHandle} from which
* to return the relative path.
*/
async resolve(possibleDescendant) {
if (possibleDescendant instanceof NodeFileSystemDirectoryHandle ||
possibleDescendant instanceof NodeFileSystemFileHandle_1.NodeFileSystemFileHandle) {
const path = this.__path;
const childPath = possibleDescendant.__path;
if (!childPath.startsWith(path))
return null;
let relative = childPath.slice(path.length);
if (relative === '')
return [];
const separator = this.ctx.separator;
if (relative[0] === separator)
relative = relative.slice(1);
return relative.split(separator);
}
return null;
}
}
exports.NodeFileSystemDirectoryHandle = NodeFileSystemDirectoryHandle;
//# sourceMappingURL=NodeFileSystemDirectoryHandle.js.map
File diff suppressed because one or more lines are too long
+28
View File
@@ -0,0 +1,28 @@
import { NodeFileSystemHandle } from './NodeFileSystemHandle';
import { NodeFileSystemWritableFileStream } from './NodeFileSystemWritableFileStream';
import type { NodeFsaContext, NodeFsaFs } from './types';
import type { IFileSystemFileHandle, IFileSystemSyncAccessHandle } from '../fsa/types';
export declare class NodeFileSystemFileHandle extends NodeFileSystemHandle implements IFileSystemFileHandle {
protected readonly fs: NodeFsaFs;
readonly __path: string;
protected readonly ctx: NodeFsaContext;
constructor(fs: NodeFsaFs, __path: string, ctx?: Partial<NodeFsaContext>);
/**
* Returns a {@link Promise} which resolves to a {@link File} object
* representing the state on disk of the entry represented by the handle.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemFileHandle/getFile
*/
getFile(): Promise<File>;
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemFileHandle/createSyncAccessHandle
*/
get createSyncAccessHandle(): undefined | (() => Promise<IFileSystemSyncAccessHandle>);
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemFileHandle/createWritable
*/
createWritable({ keepExistingData }?: CreateWritableOptions): Promise<NodeFileSystemWritableFileStream>;
}
export interface CreateWritableOptions {
keepExistingData?: boolean;
}
+62
View File
@@ -0,0 +1,62 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NodeFileSystemFileHandle = void 0;
const NodeFileSystemHandle_1 = require("./NodeFileSystemHandle");
const NodeFileSystemSyncAccessHandle_1 = require("./NodeFileSystemSyncAccessHandle");
const util_1 = require("./util");
const NodeFileSystemWritableFileStream_1 = require("./NodeFileSystemWritableFileStream");
class NodeFileSystemFileHandle extends NodeFileSystemHandle_1.NodeFileSystemHandle {
constructor(fs, __path, ctx = {}) {
ctx = (0, util_1.ctx)(ctx);
super('file', (0, util_1.basename)(__path, ctx.separator));
this.fs = fs;
this.__path = __path;
this.ctx = ctx;
}
/**
* Returns a {@link Promise} which resolves to a {@link File} object
* representing the state on disk of the entry represented by the handle.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemFileHandle/getFile
*/
async getFile() {
try {
const path = this.__path;
const promises = this.fs.promises;
const stats = await promises.stat(path);
// TODO: Once implemented, use promises.readAsBlob() instead of promises.readFile().
const data = await promises.readFile(path);
const file = new File([data], this.name, { lastModified: stats.mtime.getTime() });
return file;
}
catch (error) {
if (error instanceof DOMException)
throw error;
if (error && typeof error === 'object') {
switch (error.code) {
case 'EPERM':
case 'EACCES':
throw (0, util_1.newNotAllowedError)();
}
}
throw error;
}
}
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemFileHandle/createSyncAccessHandle
*/
get createSyncAccessHandle() {
if (!this.ctx.syncHandleAllowed)
return undefined;
return async () => new NodeFileSystemSyncAccessHandle_1.NodeFileSystemSyncAccessHandle(this.fs, this.__path, this.ctx);
}
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemFileHandle/createWritable
*/
async createWritable({ keepExistingData = false } = { keepExistingData: false }) {
(0, util_1.assertCanWrite)(this.ctx.mode);
return new NodeFileSystemWritableFileStream_1.NodeFileSystemWritableFileStream(this.fs, this.__path, keepExistingData);
}
}
exports.NodeFileSystemFileHandle = NodeFileSystemFileHandle;
//# sourceMappingURL=NodeFileSystemFileHandle.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"NodeFileSystemFileHandle.js","sourceRoot":"","sources":["../../src/node-to-fsa/NodeFileSystemFileHandle.ts"],"names":[],"mappings":";;;AAAA,iEAA8D;AAC9D,qFAAkF;AAClF,iCAAwF;AACxF,yFAAsF;AAItF,MAAa,wBAAyB,SAAQ,2CAAoB;IAGhE,YACqB,EAAa,EAChB,MAAc,EAC9B,MAA+B,EAAE;QAEjC,GAAG,GAAG,IAAA,UAAS,EAAC,GAAG,CAAC,CAAC;QACrB,KAAK,CAAC,MAAM,EAAE,IAAA,eAAQ,EAAC,MAAM,EAAE,GAAG,CAAC,SAAU,CAAC,CAAC,CAAC;QAL7B,OAAE,GAAF,EAAE,CAAW;QAChB,WAAM,GAAN,MAAM,CAAQ;QAK9B,IAAI,CAAC,GAAG,GAAG,GAAqB,CAAC;IACnC,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,OAAO;QAClB,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,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O,IAAI,mEAAgC,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IACtF,CAAC;CACF;AA1DD,4DA0DC"}
+33
View File
@@ -0,0 +1,33 @@
import { NodePermissionStatus } from './NodePermissionStatus';
import type { IFileSystemHandle, FileSystemHandlePermissionDescriptor } from '../fsa/types';
/**
* Represents a File System Access API file handle `FileSystemHandle` object,
* which was created from a Node.js `fs` module.
*
* @see [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemHandle)
*/
export declare abstract class NodeFileSystemHandle implements IFileSystemHandle {
readonly kind: 'file' | 'directory';
readonly name: string;
constructor(kind: 'file' | 'directory', name: string);
/**
* Compares two handles to see if the associated entries (either a file or directory) match.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemHandle/isSameEntry
*/
isSameEntry(fileSystemHandle: NodeFileSystemHandle): boolean;
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemHandle/queryPermission
*/
queryPermission(fileSystemHandlePermissionDescriptor: FileSystemHandlePermissionDescriptor): NodePermissionStatus;
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemHandle/remove
*/
remove({ recursive }?: {
recursive?: boolean;
}): Promise<void>;
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemHandle/requestPermission
*/
requestPermission(fileSystemHandlePermissionDescriptor: FileSystemHandlePermissionDescriptor): NodePermissionStatus;
}
+43
View File
@@ -0,0 +1,43 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NodeFileSystemHandle = void 0;
/**
* Represents a File System Access API file handle `FileSystemHandle` object,
* which was created from a Node.js `fs` module.
*
* @see [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemHandle)
*/
class NodeFileSystemHandle {
constructor(kind, name) {
this.kind = kind;
this.name = name;
}
/**
* Compares two handles to see if the associated entries (either a file or directory) match.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemHandle/isSameEntry
*/
isSameEntry(fileSystemHandle) {
return (this.constructor === fileSystemHandle.constructor && this.__path === fileSystemHandle.__path);
}
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemHandle/queryPermission
*/
queryPermission(fileSystemHandlePermissionDescriptor) {
throw new Error('Not implemented');
}
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemHandle/remove
*/
async remove({ recursive } = { recursive: false }) {
throw new Error('Not implemented');
}
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemHandle/requestPermission
*/
requestPermission(fileSystemHandlePermissionDescriptor) {
throw new Error('Not implemented');
}
}
exports.NodeFileSystemHandle = NodeFileSystemHandle;
//# sourceMappingURL=NodeFileSystemHandle.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"NodeFileSystemHandle.js","sourceRoot":"","sources":["../../src/node-to-fsa/NodeFileSystemHandle.ts"],"names":[],"mappings":";;;AAGA;;;;;GAKG;AACH,MAAsB,oBAAoB;IACxC,YACkB,IAA0B,EAC1B,IAAY;QADZ,SAAI,GAAJ,IAAI,CAAsB;QAC1B,SAAI,GAAJ,IAAI,CAAQ;IAC3B,CAAC;IAEJ;;;;OAIG;IACI,WAAW,CAAC,gBAAsC;QACvD,OAAO,CACL,IAAI,CAAC,WAAW,KAAK,gBAAgB,CAAC,WAAW,IAAK,IAAY,CAAC,MAAM,KAAM,gBAAwB,CAAC,MAAM,CAC/G,CAAC;IACJ,CAAC;IAED;;OAEG;IACI,eAAe,CACpB,oCAA0E;QAE1E,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,MAAM,CAAC,EAAE,SAAS,KAA8B,EAAE,SAAS,EAAE,KAAK,EAAE;QAC/E,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IAED;;OAEG;IACI,iBAAiB,CACtB,oCAA0E;QAE1E,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;CACF;AAzCD,oDAyCC"}
+42
View File
@@ -0,0 +1,42 @@
import type { FileSystemReadWriteOptions, IFileSystemSyncAccessHandle } from '../fsa/types';
import type { NodeFsaContext, NodeFsaFs } from './types';
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemSyncAccessHandle
*/
export declare class NodeFileSystemSyncAccessHandle implements IFileSystemSyncAccessHandle {
protected readonly fs: NodeFsaFs;
protected readonly path: string;
protected readonly ctx: NodeFsaContext;
protected readonly fd: number;
constructor(fs: NodeFsaFs, path: string, ctx: NodeFsaContext);
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemSyncAccessHandle/close
*/
close(): Promise<void>;
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemSyncAccessHandle/flush
*/
flush(): Promise<void>;
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemSyncAccessHandle/getSize
*/
getSize(): Promise<number>;
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemSyncAccessHandle/read
*/
read(buffer: ArrayBuffer | ArrayBufferView, options?: FileSystemReadWriteOptions): Promise<number>;
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemSyncAccessHandle/truncate
* @param newSize The number of bytes to resize the file to.
*/
truncate(newSize: number): Promise<void>;
/**
* Writes the content of a specified buffer to the file associated with the
* handle, optionally at a given offset.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemSyncAccessHandle/write
* @param buffer
* @param options
*/
write(buffer: ArrayBuffer | ArrayBufferView | DataView, options?: FileSystemReadWriteOptions): Promise<number>;
}
+97
View File
@@ -0,0 +1,97 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NodeFileSystemSyncAccessHandle = void 0;
const util_1 = require("./util");
const buffer_1 = require("../internal/buffer");
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemSyncAccessHandle
*/
class NodeFileSystemSyncAccessHandle {
constructor(fs, path, ctx) {
this.fs = fs;
this.path = path;
this.ctx = ctx;
this.fd = fs.openSync(path, 'r+');
}
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemSyncAccessHandle/close
*/
async close() {
(0, util_1.assertCanWrite)(this.ctx.mode);
this.fs.closeSync(this.fd);
}
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemSyncAccessHandle/flush
*/
async flush() {
(0, util_1.assertCanWrite)(this.ctx.mode);
this.fs.fsyncSync(this.fd);
}
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemSyncAccessHandle/getSize
*/
async getSize() {
return this.fs.statSync(this.path).size;
}
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemSyncAccessHandle/read
*/
async read(buffer, options = {}) {
var _a;
const buf = buffer instanceof ArrayBuffer ? buffer_1.Buffer.from(buffer) : buffer;
try {
const size = this.fs.readSync(this.fd, buf, 0, buffer.byteLength, (_a = options.at) !== null && _a !== void 0 ? _a : 0);
return size;
}
catch (error) {
if (error instanceof DOMException)
throw error;
if (error && typeof error === 'object') {
switch (error.code) {
case 'EBADF': {
throw new DOMException('File handle already closed.', 'InvalidStateError');
}
}
}
throw error;
}
}
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemSyncAccessHandle/truncate
* @param newSize The number of bytes to resize the file to.
*/
async truncate(newSize) {
(0, util_1.assertCanWrite)(this.ctx.mode);
this.fs.truncateSync(this.fd, newSize);
}
/**
* Writes the content of a specified buffer to the file associated with the
* handle, optionally at a given offset.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemSyncAccessHandle/write
* @param buffer
* @param options
*/
async write(buffer, options = {}) {
var _a;
(0, util_1.assertCanWrite)(this.ctx.mode);
const buf = buffer instanceof ArrayBuffer ? buffer_1.Buffer.from(buffer) : buffer;
try {
return this.fs.writeSync(this.fd, buf, 0, buffer.byteLength, (_a = options.at) !== null && _a !== void 0 ? _a : 0);
}
catch (error) {
if (error instanceof DOMException)
throw error;
if (error && typeof error === 'object') {
switch (error.code) {
case 'EBADF': {
throw new DOMException('File handle already closed.', 'InvalidStateError');
}
}
}
throw error;
}
}
}
exports.NodeFileSystemSyncAccessHandle = NodeFileSystemSyncAccessHandle;
//# sourceMappingURL=NodeFileSystemSyncAccessHandle.js.map
@@ -0,0 +1 @@
{"version":3,"file":"NodeFileSystemSyncAccessHandle.js","sourceRoot":"","sources":["../../src/node-to-fsa/NodeFileSystemSyncAccessHandle.ts"],"names":[],"mappings":";;;AAAA,iCAAwC;AACxC,+CAA4C;AAI5C;;GAEG;AACH,MAAa,8BAA8B;IAGzC,YACqB,EAAa,EACb,IAAY,EACZ,GAAmB;QAFnB,OAAE,GAAF,EAAE,CAAW;QACb,SAAI,GAAJ,IAAI,CAAQ;QACZ,QAAG,GAAH,GAAG,CAAgB;QAEtC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACpC,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,KAAK;QAChB,IAAA,qBAAc,EAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC9B,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC7B,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,KAAK;QAChB,IAAA,qBAAc,EAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC9B,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC7B,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,OAAO;QAClB,OAAO,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC;IAC1C,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,IAAI,CAAC,MAAqC,EAAE,UAAsC,EAAE;;QA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,CAAC;YACH,OAAO,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,MAAM,CAAC,UAAU,EAAE,MAAA,OAAO,CAAC,EAAE,mCAAI,CAAC,CAAC,CAAC;QAChF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,YAAY;gBAAE,MAAM,KAAK,CAAC;YAC/C,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBACvC,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;oBACnB,KAAK,OAAO,CAAC,CAAC,CAAC;wBACb,MAAM,IAAI,YAAY,CAAC,6BAA6B,EAAE,mBAAmB,CAAC,CAAC;oBAC7E,CAAC;gBACH,CAAC;YACH,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF;AA5FD,wEA4FC"}
@@ -0,0 +1,54 @@
import type { Data, FileSystemWritableFileStreamParams, IFileSystemWritableFileStream } from '../fsa/types';
import type { IFileHandle } from '../node/types/misc';
import type { NodeFsaFs } from './types';
/**
* When Chrome writes to the file, it creates a copy of the file with extension
* `.crswap` and then replaces the original file with the copy only when the
* `close()` method is called. If the `abort()` method is called, the `.crswap`
* file is deleted.
*
* If a file name with with extension `.crswap` is already taken, it
* creates a new swap file with extension `.1.crswap` and so on.
*/
export declare const createSwapFile: (fs: NodeFsaFs, path: string, keepExistingData: boolean) => Promise<[handle: IFileHandle, path: string]>;
interface SwapFile {
/** Swap file full path name. */
path: string;
/** Seek offset in the file. */
offset: number;
/** Node.js open FileHandle. */
handle?: IFileHandle;
/** Resolves when swap file is ready for operations. */
ready?: Promise<void>;
}
/**
* Is a WritableStream object with additional convenience methods, which
* operates on a single file on disk. The interface is accessed through the
* `FileSystemFileHandle.createWritable()` method.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemWritableFileStream
*/
export declare class NodeFileSystemWritableFileStream extends WritableStream implements IFileSystemWritableFileStream {
protected readonly fs: NodeFsaFs;
protected readonly path: string;
protected readonly swap: SwapFile;
constructor(fs: NodeFsaFs, path: string, keepExistingData: boolean);
/**
* @sse https://developer.mozilla.org/en-US/docs/Web/API/FileSystemWritableFileStream/seek
* @param position An `unsigned long` describing the byte position from the top
* (beginning) of the file.
*/
seek(position: number): Promise<void>;
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemWritableFileStream/truncate
* @param size An `unsigned long` of the amount of bytes to resize the stream to.
*/
truncate(size: number): Promise<void>;
protected writeBase(chunk: Data): Promise<void>;
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemWritableFileStream/write
*/
write(chunk: Data): Promise<void>;
write(params: FileSystemWritableFileStreamParams): Promise<void>;
}
export {};
+172
View File
@@ -0,0 +1,172 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NodeFileSystemWritableFileStream = exports.createSwapFile = void 0;
const buffer_1 = require("../internal/buffer");
/**
* When Chrome writes to the file, it creates a copy of the file with extension
* `.crswap` and then replaces the original file with the copy only when the
* `close()` method is called. If the `abort()` method is called, the `.crswap`
* file is deleted.
*
* If a file name with with extension `.crswap` is already taken, it
* creates a new swap file with extension `.1.crswap` and so on.
*/
const createSwapFile = async (fs, path, keepExistingData) => {
let handle;
let swapPath = path + '.crswap';
try {
handle = await fs.promises.open(swapPath, 'ax');
}
catch (error) {
if (!error || typeof error !== 'object' || error.code !== 'EEXIST')
throw error;
}
if (!handle) {
for (let i = 1; i < 1000; i++) {
try {
swapPath = `${path}.${i}.crswap`;
handle = await fs.promises.open(swapPath, 'ax');
break;
}
catch (error) {
if (!error || typeof error !== 'object' || error.code !== 'EEXIST')
throw error;
}
}
}
if (!handle)
throw new Error(`Could not create a swap file for "${path}".`);
if (keepExistingData)
await fs.promises.copyFile(path, swapPath, fs.constants.COPYFILE_FICLONE);
return [handle, swapPath];
};
exports.createSwapFile = createSwapFile;
/**
* Is a WritableStream object with additional convenience methods, which
* operates on a single file on disk. The interface is accessed through the
* `FileSystemFileHandle.createWritable()` method.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemWritableFileStream
*/
class NodeFileSystemWritableFileStream extends WritableStream {
constructor(fs, path, keepExistingData) {
const swap = { handle: undefined, path: '', offset: 0 };
super({
async start() {
const promise = (0, exports.createSwapFile)(fs, path, keepExistingData);
swap.ready = promise.then(() => undefined);
const [handle, swapPath] = await promise;
swap.handle = handle;
swap.path = swapPath;
},
async write(chunk) {
await swap.ready;
const handle = swap.handle;
if (!handle)
throw new Error('Invalid state');
const buffer = buffer_1.Buffer.from(typeof chunk === 'string' ? chunk : chunk instanceof Blob ? await chunk.arrayBuffer() : chunk);
const { bytesWritten } = await handle.write(buffer, 0, buffer.length, swap.offset);
swap.offset += bytesWritten;
},
async close() {
await swap.ready;
const handle = swap.handle;
if (!handle)
return;
await handle.close();
await fs.promises.rename(swap.path, path);
},
async abort() {
await swap.ready;
const handle = swap.handle;
if (!handle)
return;
await handle.close();
await fs.promises.unlink(swap.path);
},
});
this.fs = fs;
this.path = path;
this.swap = swap;
}
/**
* @sse https://developer.mozilla.org/en-US/docs/Web/API/FileSystemWritableFileStream/seek
* @param position An `unsigned long` describing the byte position from the top
* (beginning) of the file.
*/
async seek(position) {
this.swap.offset = position;
}
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemWritableFileStream/truncate
* @param size An `unsigned long` of the amount of bytes to resize the stream to.
*/
async truncate(size) {
await this.swap.ready;
const handle = this.swap.handle;
if (!handle)
throw new Error('Invalid state');
await handle.truncate(size);
if (this.swap.offset > size)
this.swap.offset = size;
}
async writeBase(chunk) {
const writer = this.getWriter();
try {
await writer.write(chunk);
}
finally {
writer.releaseLock();
}
}
async write(params) {
if (!params)
throw new TypeError('Missing required argument: params');
switch (typeof params) {
case 'string': {
return this.writeBase(params);
}
case 'object': {
const constructor = params.constructor;
switch (constructor) {
case ArrayBuffer:
case Blob:
case DataView:
return this.writeBase(params);
default: {
if (ArrayBuffer.isView(params)) {
return this.writeBase(params);
}
else {
const options = params;
switch (options.type) {
case 'write': {
if (typeof options.position === 'number')
await this.seek(options.position);
return this.writeBase(params.data);
}
case 'truncate': {
if (typeof params.size !== 'number')
throw new TypeError('Missing required argument: size');
if (this.swap.offset > params.size)
this.swap.offset = params.size;
return this.truncate(params.size);
}
case 'seek':
if (typeof params.position !== 'number')
throw new TypeError('Missing required argument: position');
return this.seek(params.position);
default:
throw new TypeError('Invalid argument: params');
}
}
}
}
}
default:
throw new TypeError('Invalid argument: params');
}
}
}
exports.NodeFileSystemWritableFileStream = NodeFileSystemWritableFileStream;
//# sourceMappingURL=NodeFileSystemWritableFileStream.js.map
File diff suppressed because one or more lines are too long
+8
View File
@@ -0,0 +1,8 @@
/**
* @see [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/PermissionStatus)
*/
export declare class NodePermissionStatus {
readonly name: string;
readonly state: 'granted' | 'denied' | 'prompt';
constructor(name: string, state: 'granted' | 'denied' | 'prompt');
}
+14
View File
@@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NodePermissionStatus = void 0;
/**
* @see [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/PermissionStatus)
*/
class NodePermissionStatus {
constructor(name, state) {
this.name = name;
this.state = state;
}
}
exports.NodePermissionStatus = NodePermissionStatus;
//# sourceMappingURL=NodePermissionStatus.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"NodePermissionStatus.js","sourceRoot":"","sources":["../../src/node-to-fsa/NodePermissionStatus.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,MAAa,oBAAoB;IAC/B,YACkB,IAAY,EACZ,KAAsC;QADtC,SAAI,GAAJ,IAAI,CAAQ;QACZ,UAAK,GAAL,KAAK,CAAiC;IACrD,CAAC;CACL;AALD,oDAKC"}
+7
View File
@@ -0,0 +1,7 @@
import { NodeFileSystemDirectoryHandle } from './NodeFileSystemDirectoryHandle';
import { NodeFsaContext, NodeFsaFs } from './types';
export * from './types';
export * from './NodeFileSystemHandle';
export * from './NodeFileSystemDirectoryHandle';
export * from './NodeFileSystemFileHandle';
export declare const nodeToFsa: (fs: NodeFsaFs, dirPath: string, ctx?: Partial<NodeFsaContext>) => NodeFileSystemDirectoryHandle;
+14
View File
@@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.nodeToFsa = void 0;
const tslib_1 = require("tslib");
const NodeFileSystemDirectoryHandle_1 = require("./NodeFileSystemDirectoryHandle");
tslib_1.__exportStar(require("./types"), exports);
tslib_1.__exportStar(require("./NodeFileSystemHandle"), exports);
tslib_1.__exportStar(require("./NodeFileSystemDirectoryHandle"), exports);
tslib_1.__exportStar(require("./NodeFileSystemFileHandle"), exports);
const nodeToFsa = (fs, dirPath, ctx) => {
return new NodeFileSystemDirectoryHandle_1.NodeFileSystemDirectoryHandle(fs, dirPath, ctx);
};
exports.nodeToFsa = nodeToFsa;
//# 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,mFAAgF;AAGhF,kDAAwB;AACxB,iEAAuC;AACvC,0EAAgD;AAChD,qEAA2C;AAEpC,MAAM,SAAS,GAAG,CACvB,EAAa,EACb,OAAe,EACf,GAA6B,EACE,EAAE;IACjC,OAAO,IAAI,6DAA6B,CAAC,EAAE,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;AAC7D,CAAC,CAAC;AANW,QAAA,SAAS,aAMpB"}
+15
View File
@@ -0,0 +1,15 @@
import type { FsPromisesApi, FsSynchronousApi } from '../node/types';
import type { FsCommonObjects } from '../node/types/FsCommonObjects';
/**
* Required Node.js `fs` module functions for File System Access API.
*/
export type NodeFsaFs = Pick<FsCommonObjects, 'constants'> & {
promises: FsPromisesApi;
} & Pick<FsSynchronousApi, 'openSync' | 'fsyncSync' | 'statSync' | 'closeSync' | 'readSync' | 'truncateSync' | 'writeSync'>;
export interface NodeFsaContext {
separator: '/' | '\\';
/** Whether synchronous file handles are allowed. */
syncHandleAllowed: boolean;
/** Whether writes are allowed, defaults to `read`. */
mode: 'read' | 'readwrite';
}
+3
View File
@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=types.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/node-to-fsa/types.ts"],"names":[],"mappings":""}
+11
View File
@@ -0,0 +1,11 @@
import type { NodeFsaContext } from './types';
/**
* Creates a new {@link NodeFsaContext}.
*/
export declare const ctx: (partial?: Partial<NodeFsaContext>) => NodeFsaContext;
export declare const basename: (path: string, separator: string) => string;
export declare const assertName: (name: string, method: string, klass: string) => void;
export declare const assertCanWrite: (mode: "read" | "readwrite") => void;
export declare const newNotFoundError: () => DOMException;
export declare const newTypeMismatchError: () => DOMException;
export declare const newNotAllowedError: () => DOMException;
+36
View File
@@ -0,0 +1,36 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.newNotAllowedError = exports.newTypeMismatchError = exports.newNotFoundError = exports.assertCanWrite = exports.assertName = exports.basename = exports.ctx = void 0;
/**
* Creates a new {@link NodeFsaContext}.
*/
const ctx = (partial = {}) => {
return Object.assign({ separator: '/', syncHandleAllowed: false, mode: 'read' }, partial);
};
exports.ctx = ctx;
const basename = (path, separator) => {
if (path[path.length - 1] === separator)
path = path.slice(0, -1);
const lastSlashIndex = path.lastIndexOf(separator);
return lastSlashIndex === -1 ? path : path.slice(lastSlashIndex + 1);
};
exports.basename = basename;
const nameRegex = /^(\.{1,2})$|^(.*([\/\\]).*)$/;
const assertName = (name, method, klass) => {
const isInvalid = !name || nameRegex.test(name);
if (isInvalid)
throw new TypeError(`Failed to execute '${method}' on '${klass}': Name is not allowed.`);
};
exports.assertName = assertName;
const assertCanWrite = (mode) => {
if (mode !== 'readwrite')
throw new DOMException('The request is not allowed by the user agent or the platform in the current context.', 'NotAllowedError');
};
exports.assertCanWrite = assertCanWrite;
const newNotFoundError = () => new DOMException('A requested file or directory could not be found at the time an operation was processed.', 'NotFoundError');
exports.newNotFoundError = newNotFoundError;
const newTypeMismatchError = () => new DOMException('The path supplied exists, but was not an entry of requested type.', 'TypeMismatchError');
exports.newTypeMismatchError = newTypeMismatchError;
const newNotAllowedError = () => new DOMException('Permission not granted.', 'NotAllowedError');
exports.newNotAllowedError = newNotAllowedError;
//# sourceMappingURL=util.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/node-to-fsa/util.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACI,MAAM,GAAG,GAAG,CAAC,UAAmC,EAAE,EAAkB,EAAE;IAC3E,uBACE,SAAS,EAAE,GAAG,EACd,iBAAiB,EAAE,KAAK,EACxB,IAAI,EAAE,MAAM,IACT,OAAO,EACV;AACJ,CAAC,CAAC;AAPW,QAAA,GAAG,OAOd;AAEK,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,SAAiB,EAAE,EAAE;IAC1D,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,SAAS;QAAE,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAClE,MAAM,cAAc,GAAG,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IACnD,OAAO,cAAc,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,GAAG,CAAC,CAAC,CAAC;AACvE,CAAC,CAAC;AAJW,QAAA,QAAQ,YAInB;AAEF,MAAM,SAAS,GAAG,8BAA8B,CAAC;AAE1C,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,MAAc,EAAE,KAAa,EAAE,EAAE;IACxE,MAAM,SAAS,GAAG,C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