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

201
node_modules/@jsonjoy.com/fs-fsa/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2026 Vadims @streamich Daleckis <vadimsdaleckis@gmail.com>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

35
node_modules/@jsonjoy.com/fs-fsa/README.md generated vendored Normal file
View File

@@ -0,0 +1,35 @@
# @jsonjoy.com/fs-fsa
File System Access API implementation backed by `@jsonjoy.com/fs-core` primitives.
Provides a [File System Access API](https://developer.mozilla.org/en-US/docs/Web/API/File_System_API)
implementation that works with the `Superblock` filesystem abstraction.
## Installation
```bash
npm install @jsonjoy.com/fs-fsa
```
## Usage
```ts
import { fsa } from '@jsonjoy.com/fs-fsa';
const { dir, core, FileSystemObserver } = fsa({ mode: 'readwrite' });
// Create a file
const fileHandle = await dir.getFileHandle('hello.txt', { create: true });
const writable = await fileHandle.createWritable();
await writable.write('Hello, World!');
await writable.close();
// Read a file
const file = await fileHandle.getFile();
const contents = await file.text();
console.log(contents); // 'Hello, World!'
```
## License
Apache-2.0

View File

@@ -0,0 +1,73 @@
import { CoreFileSystemHandle } from './CoreFileSystemHandle';
import type { CoreFsaContext, GetDirectoryHandleOptions, GetFileHandleOptions, IFileSystemDirectoryHandle, IFileSystemFileHandle, IFileSystemHandle, RemoveEntryOptions } from './types';
import type { Superblock } from '@jsonjoy.com/fs-core';
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle
*/
export declare class CoreFileSystemDirectoryHandle extends CoreFileSystemHandle implements IFileSystemDirectoryHandle {
protected readonly _core: Superblock;
protected readonly ctx: CoreFsaContext;
/** Directory path with trailing slash. */
readonly __path: string;
constructor(_core: Superblock, path: string, ctx?: Partial<CoreFsaContext>);
/**
* Returns a new array iterator containing the keys for each item in
* {@link CoreFileSystemDirectoryHandle} 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, CoreFileSystemHandle]>;
/**
* 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<CoreFileSystemHandle>;
/**
* Returns a {@link CoreFileSystemDirectoryHandle} 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 CoreFileSystemHandle} 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 CoreFileSystemFileHandle} 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 CoreFileSystemHandle} 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 CoreFileSystemHandle} 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 CoreFileSystemHandle} from which
* to return the relative path.
*/
resolve(possibleDescendant: IFileSystemHandle): Promise<string[] | null>;
private _handleError;
}

View File

@@ -0,0 +1,265 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CoreFileSystemDirectoryHandle = void 0;
const CoreFileSystemHandle_1 = require("./CoreFileSystemHandle");
const util_1 = require("./util");
const CoreFileSystemFileHandle_1 = require("./CoreFileSystemFileHandle");
const buffer_1 = require("@jsonjoy.com/fs-node-builtins/lib/internal/buffer");
const fs_node_utils_1 = require("@jsonjoy.com/fs-node-utils");
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle
*/
class CoreFileSystemDirectoryHandle extends CoreFileSystemHandle_1.CoreFileSystemHandle {
constructor(_core, path, ctx = {}) {
const fullCtx = (0, util_1.ctx)(ctx);
super('directory', (0, util_1.basename)(path, fullCtx.separator), fullCtx);
this._core = _core;
this.ctx = fullCtx;
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 CoreFileSystemDirectoryHandle} object.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle/keys
*/
async *keys() {
try {
const link = this._core.getResolvedLinkOrThrow(this.__path);
const children = link.children;
for (const [name] of children) {
if (name !== '.' && name !== '..') {
yield name;
}
}
}
catch (error) {
this._handleError(error, 'keys');
}
}
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle/entries
*/
async *entries() {
const { __path: path, _core, ctx } = this;
try {
const link = _core.getResolvedLinkOrThrow(path);
const children = link.children;
for (const [name, childLink] of children) {
if (name !== '.' && name !== '..' && childLink) {
const childPath = path + name;
const node = childLink.getNode();
if (node.isDirectory()) {
yield [name, new CoreFileSystemDirectoryHandle(_core, childPath, ctx)];
}
else if (node.isFile()) {
yield [name, new CoreFileSystemFileHandle_1.CoreFileSystemFileHandle(_core, childPath, ctx)];
}
}
}
}
catch (error) {
this._handleError(error, 'entries');
}
}
/**
* 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
*/
async *values() {
for await (const [, value] of this.entries())
yield value;
}
/**
* Returns a {@link CoreFileSystemDirectoryHandle} 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 CoreFileSystemHandle} 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 link = this._core.getResolvedLink(filename);
if (link) {
const node = link.getNode();
if (!node.isDirectory())
throw (0, util_1.newTypeMismatchError)();
return new CoreFileSystemDirectoryHandle(this._core, filename, this.ctx);
}
else {
throw new Error('ENOENT'); // Simulate error for consistency with catch block
}
}
catch (error) {
if (error instanceof DOMException)
throw error;
if (error && typeof error === 'object') {
if (error.code === "ENOENT" /* ERROR_CODE.ENOENT */ || error.message === 'ENOENT') {
if (options?.create) {
(0, util_1.assertCanWrite)(this.ctx.mode);
try {
this._core.mkdir(filename, 0o755);
return new CoreFileSystemDirectoryHandle(this._core, filename, this.ctx);
}
catch (createError) {
if (createError && typeof createError === 'object' && createError.code === "EACCES" /* ERROR_CODE.EACCES */) {
throw (0, util_1.newNotAllowedError)();
}
throw createError;
}
}
throw (0, util_1.newNotFoundError)();
}
if (error.code === "EACCES" /* ERROR_CODE.EACCES */) {
throw (0, util_1.newNotAllowedError)();
}
}
throw error;
}
}
/**
* Returns a {@link CoreFileSystemFileHandle} 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 CoreFileSystemHandle} 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 link = this._core.getResolvedLink(filename);
if (link) {
const node = link.getNode();
if (!node.isFile())
throw (0, util_1.newTypeMismatchError)();
return new CoreFileSystemFileHandle_1.CoreFileSystemFileHandle(this._core, filename, this.ctx);
}
else {
throw new Error('ENOENT'); // Simulate error for consistency with catch block
}
}
catch (error) {
if (error instanceof DOMException)
throw error;
if (error && typeof error === 'object') {
if (error.code === "ENOENT" /* ERROR_CODE.ENOENT */ || error.message === 'ENOENT') {
if (options?.create) {
(0, util_1.assertCanWrite)(this.ctx.mode);
try {
this._core.writeFile(filename, buffer_1.Buffer.alloc(0), fs_node_utils_1.FLAGS.w, 438 /* MODE.FILE */);
return new CoreFileSystemFileHandle_1.CoreFileSystemFileHandle(this._core, filename, this.ctx);
}
catch (createError) {
if (createError && typeof createError === 'object' && createError.code === "EACCES" /* ERROR_CODE.EACCES */) {
throw (0, util_1.newNotAllowedError)();
}
throw createError;
}
}
throw (0, util_1.newNotFoundError)();
}
if (error.code === "EACCES" /* ERROR_CODE.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 CoreFileSystemHandle} 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;
try {
const link = this._core.getResolvedLinkOrThrow(filename);
const node = link.getNode();
if (node.isFile()) {
this._core.unlink(filename);
}
else if (node.isDirectory()) {
this._core.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" /* ERROR_CODE.ENOENT */: {
throw (0, util_1.newNotFoundError)();
}
case "EACCES" /* ERROR_CODE.EACCES */:
throw (0, util_1.newNotAllowedError)();
case "ENOTEMPTY" /* ERROR_CODE.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 CoreFileSystemHandle} from which
* to return the relative path.
*/
async resolve(possibleDescendant) {
if (possibleDescendant instanceof CoreFileSystemDirectoryHandle ||
possibleDescendant instanceof CoreFileSystemFileHandle_1.CoreFileSystemFileHandle) {
// First check if they are from the same core instance
if (possibleDescendant._core !== this._core)
return null;
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;
}
_handleError(error, method) {
if (error instanceof DOMException)
throw error;
if (error && typeof error === 'object') {
switch (error.code) {
case "ENOENT" /* ERROR_CODE.ENOENT */:
throw (0, util_1.newNotFoundError)();
case "EACCES" /* ERROR_CODE.EACCES */:
throw (0, util_1.newNotAllowedError)();
}
}
throw error;
}
}
exports.CoreFileSystemDirectoryHandle = CoreFileSystemDirectoryHandle;
//# sourceMappingURL=CoreFileSystemDirectoryHandle.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,25 @@
import { CoreFileSystemHandle } from './CoreFileSystemHandle';
import { CoreFileSystemWritableFileStream } from './CoreFileSystemWritableFileStream';
import type { CoreFsaContext, CreateWritableOptions, IFileSystemFileHandle, IFileSystemSyncAccessHandle } from './types';
import type { Superblock } from '@jsonjoy.com/fs-core';
export declare class CoreFileSystemFileHandle extends CoreFileSystemHandle implements IFileSystemFileHandle {
protected readonly _core: Superblock;
readonly __path: string;
protected readonly ctx: CoreFsaContext;
constructor(_core: Superblock, __path: string, ctx?: Partial<CoreFsaContext>);
/**
* 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<CoreFileSystemWritableFileStream>;
}

View File

@@ -0,0 +1,75 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CoreFileSystemFileHandle = void 0;
const CoreFileSystemHandle_1 = require("./CoreFileSystemHandle");
const CoreFileSystemSyncAccessHandle_1 = require("./CoreFileSystemSyncAccessHandle");
const util_1 = require("./util");
const CoreFileSystemWritableFileStream_1 = require("./CoreFileSystemWritableFileStream");
class CoreFileSystemFileHandle extends CoreFileSystemHandle_1.CoreFileSystemHandle {
constructor(_core, __path, ctx = {}) {
const fullCtx = (0, util_1.ctx)(ctx);
super('file', (0, util_1.basename)(__path, fullCtx.separator), fullCtx);
this._core = _core;
this.__path = __path;
this.ctx = fullCtx;
}
/**
* 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 link = this._core.getResolvedLinkOrThrow(path);
const node = link.getNode();
if (!node.isFile()) {
throw new Error('Not a file');
}
// Get file stats for lastModified
const lastModified = node.mtime ? node.mtime.getTime() : Date.now();
// Read file content
const buffer = node.getBuffer();
const data = new Uint8Array(buffer);
const file = new File([data], this.name, { lastModified });
return file;
}
catch (error) {
if (error instanceof DOMException)
throw error;
if (error && typeof error === 'object') {
switch (error.code) {
case "EACCES" /* ERROR_CODE.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 () => {
if (this.ctx.locks.isLocked(this.__path)) {
throw (0, util_1.newNoModificationAllowedError)();
}
return new CoreFileSystemSyncAccessHandle_1.CoreFileSystemSyncAccessHandle(this._core, 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);
if (this.ctx.locks.isLocked(this.__path)) {
throw (0, util_1.newNoModificationAllowedError)();
}
return new CoreFileSystemWritableFileStream_1.CoreFileSystemWritableFileStream(this._core, this.__path, keepExistingData, this.ctx);
}
}
exports.CoreFileSystemFileHandle = CoreFileSystemFileHandle;
//# sourceMappingURL=CoreFileSystemFileHandle.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"CoreFileSystemFileHandle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AAG,CAAC,CAAC;IACnG,CAAC;CACF;AA3ED,4DA2EC"}

View File

@@ -0,0 +1,34 @@
import { CorePermissionStatus } from './CorePermissionStatus';
import type { IFileSystemHandle, FileSystemHandlePermissionDescriptor, CoreFsaContext } from './types';
/**
* Represents a File System Access API file handle `FileSystemHandle` object,
* which was created from a core `Superblock`.
*
* @see [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemHandle)
*/
export declare abstract class CoreFileSystemHandle implements IFileSystemHandle {
readonly kind: 'file' | 'directory';
readonly name: string;
protected readonly ctx: CoreFsaContext;
constructor(kind: 'file' | 'directory', name: string, ctx: CoreFsaContext);
/**
* 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: CoreFileSystemHandle): boolean;
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemHandle/queryPermission
*/
queryPermission(fileSystemHandlePermissionDescriptor: FileSystemHandlePermissionDescriptor): Promise<CorePermissionStatus>;
/**
* @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): CorePermissionStatus;
}

View File

@@ -0,0 +1,53 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CoreFileSystemHandle = void 0;
const CorePermissionStatus_1 = require("./CorePermissionStatus");
/**
* Represents a File System Access API file handle `FileSystemHandle` object,
* which was created from a core `Superblock`.
*
* @see [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemHandle)
*/
class CoreFileSystemHandle {
constructor(kind, name, ctx) {
this.kind = kind;
this.name = name;
this.ctx = ctx;
}
/**
* 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
*/
async queryPermission(fileSystemHandlePermissionDescriptor) {
// Check if the requested mode is compatible with the context mode
const requestedMode = fileSystemHandlePermissionDescriptor.mode;
const contextMode = this.ctx.mode;
// If requesting readwrite but context only allows read, deny
if (requestedMode === 'readwrite' && contextMode === 'read') {
return new CorePermissionStatus_1.CorePermissionStatus('denied', requestedMode);
}
// Otherwise grant the permission
return new CorePermissionStatus_1.CorePermissionStatus('granted', requestedMode);
}
/**
* @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.CoreFileSystemHandle = CoreFileSystemHandle;
//# sourceMappingURL=CoreFileSystemHandle.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"CoreFileSystemHandle.js","sourceRoot":"","sources":["../src/CoreFileSystemHandle.ts"],"names":[],"mappings":";;;AAAA,iEAA8D;AAG9D;;;;;GAKG;AACH,MAAsB,oBAAoB;IAGxC,YACkB,IAA0B,EAC1B,IAAY,EAC5B,GAAmB;QAFH,SAAI,GAAJ,IAAI,CAAsB;QAC1B,SAAI,GAAJ,IAAI,CAAQ;QAG5B,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAED;;;;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,KAAK,CAAC,eAAe,CAC1B,oCAA0E;QAE1E,kEAAkE;QAClE,MAAM,aAAa,GAAG,oCAAoC,CAAC,IAAI,CAAC;QAChE,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;QAElC,6DAA6D;QAC7D,IAAI,aAAa,KAAK,WAAW,IAAI,WAAW,KAAK,MAAM,EAAE,CAAC;YAC5D,OAAO,IAAI,2CAAoB,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;QAC3D,CAAC;QAED,iCAAiC;QACjC,OAAO,IAAI,2CAAoB,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;IAC5D,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;AAxDD,oDAwDC"}

View File

@@ -0,0 +1,10 @@
import type { IFileSystemChangeRecord, IFileSystemDirectoryHandle, IFileSystemFileHandle, IFileSystemObserver, IFileSystemObserverObserveOptions, IFileSystemSyncAccessHandle } from './types';
import type { Superblock } from '@jsonjoy.com/fs-core';
export declare class CoreFileSystemObserver implements IFileSystemObserver {
protected readonly _core: Superblock;
protected readonly callback: (records: IFileSystemChangeRecord[], observer: IFileSystemObserver) => void;
constructor(_core: Superblock, callback: (records: IFileSystemChangeRecord[], observer: IFileSystemObserver) => void);
observe(handle: IFileSystemFileHandle | IFileSystemDirectoryHandle | IFileSystemSyncAccessHandle, options?: IFileSystemObserverObserveOptions): Promise<void>;
/** Disconnect and stop all observations. */
disconnect(): void;
}

View File

@@ -0,0 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CoreFileSystemObserver = void 0;
class CoreFileSystemObserver {
constructor(_core, callback) {
this._core = _core;
this.callback = callback;
}
async observe(handle, options) {
throw new Error('Method not implemented.');
}
/** Disconnect and stop all observations. */
disconnect() {
throw new Error('Method not implemented.');
}
}
exports.CoreFileSystemObserver = CoreFileSystemObserver;
//# sourceMappingURL=CoreFileSystemObserver.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"CoreFileSystemObserver.js","sourceRoot":"","sources":["../src/CoreFileSystemObserver.ts"],"names":[],"mappings":";;;AAUA,MAAa,sBAAsB;IACjC,YACqB,KAAiB,EACjB,QAAqF;QADrF,UAAK,GAAL,KAAK,CAAY;QACjB,aAAQ,GAAR,QAAQ,CAA6E;IACvG,CAAC;IAEG,KAAK,CAAC,OAAO,CAClB,MAAwF,EACxF,OAA2C;QAE3C,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAED,4CAA4C;IACrC,UAAU;QACf,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;CACF;AAjBD,wDAiBC"}

View File

@@ -0,0 +1,38 @@
import type { IFileSystemSyncAccessHandle, FileSystemReadWriteOptions, CoreFsaContext } from './types';
import type { Superblock } from '@jsonjoy.com/fs-core';
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemSyncAccessHandle
*/
export declare class CoreFileSystemSyncAccessHandle implements IFileSystemSyncAccessHandle {
private readonly _core;
private readonly _path;
private readonly _ctx;
private _fd;
private _closed;
constructor(_core: Superblock, _path: string, _ctx: CoreFsaContext);
private _ensureOpen;
/**
* @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
*/
truncate(newSize: number): Promise<void>;
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemSyncAccessHandle/write
*/
write(buffer: ArrayBuffer | ArrayBufferView | DataView, options?: FileSystemReadWriteOptions): Promise<number>;
}

View File

@@ -0,0 +1,123 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CoreFileSystemSyncAccessHandle = void 0;
const buffer_1 = require("@jsonjoy.com/fs-node-builtins/lib/internal/buffer");
const util_1 = require("./util");
const fs_node_utils_1 = require("@jsonjoy.com/fs-node-utils");
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemSyncAccessHandle
*/
class CoreFileSystemSyncAccessHandle {
constructor(_core, _path, _ctx) {
this._core = _core;
this._path = _path;
this._ctx = _ctx;
this._fd = null;
this._closed = false;
this._ctx.locks.acquireLock(this._path);
}
_ensureOpen() {
if (this._closed) {
throw new DOMException('The file handle is closed.', 'InvalidStateError');
}
if (this._fd === null) {
// Open file for read/write
const flags = this._ctx.mode === 'readwrite' ? fs_node_utils_1.FLAGS['r+'] : fs_node_utils_1.FLAGS.r;
this._fd = this._core.open(this._path, flags, 0o644);
}
return this._fd;
}
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemSyncAccessHandle/close
*/
async close() {
if (this._fd !== null) {
this._core.close(this._fd);
this._fd = null;
}
this._closed = true;
this._ctx.locks.releaseLock(this._path);
}
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemSyncAccessHandle/flush
*/
async flush() {
const fd = this._ensureOpen();
// Core doesn't have an explicit flush method, but we can try to sync if available
// For now, this is a no-op as the core writes are synchronous
}
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemSyncAccessHandle/getSize
*/
async getSize() {
try {
const link = this._core.getResolvedLinkOrThrow(this._path);
const node = link.getNode();
return node.getSize();
}
catch (error) {
if (error && typeof error === 'object' && error.code === "EACCES" /* ERROR_CODE.EACCES */) {
throw (0, util_1.newNotAllowedError)();
}
throw error;
}
}
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemSyncAccessHandle/read
*/
async read(buffer, options = {}) {
const fd = this._ensureOpen();
const { at: position = 0 } = options;
const buf = buffer_1.Buffer.from(buffer);
try {
return this._core.read(fd, buf, 0, buf.length, position);
}
catch (error) {
if (error && typeof error === 'object' && error.code === "EACCES" /* ERROR_CODE.EACCES */) {
throw (0, util_1.newNotAllowedError)();
}
throw error;
}
}
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemSyncAccessHandle/truncate
*/
async truncate(newSize) {
if (this._ctx.mode !== 'readwrite') {
throw (0, util_1.newNotAllowedError)();
}
try {
const link = this._core.getResolvedLinkOrThrow(this._path);
const node = link.getNode();
node.truncate(newSize);
}
catch (error) {
if (error && typeof error === 'object' && error.code === "EACCES" /* ERROR_CODE.EACCES */) {
throw (0, util_1.newNotAllowedError)();
}
throw error;
}
}
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemSyncAccessHandle/write
*/
async write(buffer, options = {}) {
if (this._ctx.mode !== 'readwrite') {
throw (0, util_1.newNotAllowedError)();
}
const fd = this._ensureOpen();
const { at: position = 0 } = options;
const buf = buffer_1.Buffer.from(buffer);
try {
return this._core.write(fd, buf, 0, buf.length, position);
}
catch (error) {
if (error && typeof error === 'object' && error.code === "EACCES" /* ERROR_CODE.EACCES */) {
throw (0, util_1.newNotAllowedError)();
}
throw error;
}
}
}
exports.CoreFileSystemSyncAccessHandle = CoreFileSystemSyncAccessHandle;
//# sourceMappingURL=CoreFileSystemSyncAccessHandle.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"CoreFileSystemSyncAccessHandle.js","sourceRoot":"","sources":["../src/CoreFileSystemSyncAccessHandle.ts"],"names":[],"mappings":";;;AAG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AC;YACf,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,qCAAsB,EAAE,CAAC;gBAC3E,MAAM,IAAA,yBAAkB,GAAE,CAAC;YAC7B,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF;AA3HD,wEA2HC"}

View File

@@ -0,0 +1,32 @@
import type { IFileSystemWritableFileStream, FileSystemWritableFileStreamParams, Data, CoreFsaContext } from './types';
import type { Superblock } from '@jsonjoy.com/fs-core';
declare const WS: typeof WritableStream;
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemWritableFileStream
*/
export declare class CoreFileSystemWritableFileStream extends WS implements IFileSystemWritableFileStream {
private _fd;
private _position;
private _closed;
private readonly _core;
private readonly _path;
private readonly _ctx;
constructor(core: Superblock, path: string, keepExistingData: boolean | undefined, ctx: CoreFsaContext);
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemWritableFileStream/seek
*/
seek(position: number): Promise<void>;
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemWritableFileStream/truncate
*/
truncate(size: number): Promise<void>;
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemWritableFileStream/write
*/
write(chunk: Data): Promise<void>;
write(params: FileSystemWritableFileStreamParams): Promise<void>;
private _write;
private _isParams;
private _dataToBuffer;
}
export {};

View File

@@ -0,0 +1,163 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CoreFileSystemWritableFileStream = void 0;
const buffer_1 = require("@jsonjoy.com/fs-node-builtins/lib/internal/buffer");
const util_1 = require("./util");
const fs_node_utils_1 = require("@jsonjoy.com/fs-node-utils");
const WS = (typeof WritableStream === 'undefined' ? require('stream/web').WritableStream : WritableStream);
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemWritableFileStream
*/
class CoreFileSystemWritableFileStream extends WS {
constructor(core, path, keepExistingData = false, ctx) {
let fd;
super({
start: controller => {
if (ctx.locks.isLocked(path)) {
throw (0, util_1.newNoModificationAllowedError)();
}
ctx.locks.acquireLock(path);
const flags = keepExistingData ? fs_node_utils_1.FLAGS['r+'] : fs_node_utils_1.FLAGS.w;
try {
fd = core.open(path, flags, 438 /* MODE.FILE */);
}
catch (error) {
ctx.locks.releaseLock(path);
if (error && typeof error === 'object' && error.code === "EACCES" /* ERROR_CODE.EACCES */) {
throw (0, util_1.newNotAllowedError)();
}
throw error;
}
},
write: async (chunk) => {
await this._write(chunk);
},
close: async () => {
if (!this._closed && this._fd !== undefined) {
core.close(this._fd);
this._closed = true;
ctx.locks.releaseLock(path);
}
},
abort: async () => {
if (!this._closed && this._fd !== undefined) {
core.close(this._fd);
this._closed = true;
ctx.locks.releaseLock(path);
}
},
});
this._position = 0;
this._closed = false;
this._core = core;
this._path = path;
this._fd = fd;
this._ctx = ctx;
}
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemWritableFileStream/seek
*/
async seek(position) {
if (this._closed) {
throw new DOMException('The stream is closed.', 'InvalidStateError');
}
this._position = position;
}
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemWritableFileStream/truncate
*/
async truncate(size) {
if (this._closed) {
throw new DOMException('The stream is closed.', 'InvalidStateError');
}
try {
const link = this._core.getResolvedLinkOrThrow(this._path);
const node = link.getNode();
node.truncate(size);
}
catch (error) {
if (error && typeof error === 'object' && error.code === "EACCES" /* ERROR_CODE.EACCES */) {
throw (0, util_1.newNotAllowedError)();
}
throw error;
}
}
async write(chunkOrParams) {
await this._write(chunkOrParams);
}
async _write(chunkOrParams) {
if (this._closed) {
throw new DOMException('The stream is closed.', 'InvalidStateError');
}
if (this._fd === undefined) {
throw new DOMException('The stream is not ready.', 'InvalidStateError');
}
try {
if (this._isParams(chunkOrParams)) {
const params = chunkOrParams;
switch (params.type) {
case 'write': {
if (params.data !== undefined) {
const buffer = this._dataToBuffer(params.data);
const position = params.position !== undefined ? params.position : this._position;
const written = this._core.write(this._fd, buffer, 0, buffer.length, position);
if (params.position === undefined) {
this._position += written;
}
}
break;
}
case 'seek': {
if (params.position !== undefined) {
this._position = params.position;
}
break;
}
case 'truncate': {
if (params.size !== undefined) {
await this.truncate(params.size);
}
break;
}
}
}
else {
// Direct data write
const buffer = this._dataToBuffer(chunkOrParams);
const written = this._core.write(this._fd, buffer, 0, buffer.length, this._position);
this._position += written;
}
}
catch (error) {
if (error && typeof error === 'object' && error.code === "EACCES" /* ERROR_CODE.EACCES */) {
throw (0, util_1.newNotAllowedError)();
}
throw error;
}
}
_isParams(chunk) {
return !!(chunk && typeof chunk === 'object' && 'type' in chunk);
}
_dataToBuffer(data) {
if (typeof data === 'string') {
return buffer_1.Buffer.from(data, 'utf8');
}
if (data instanceof buffer_1.Buffer) {
return data;
}
if (data instanceof ArrayBuffer) {
return buffer_1.Buffer.from(data);
}
if (ArrayBuffer.isView(data)) {
return buffer_1.Buffer.from(data.buffer, data.byteOffset, data.byteLength);
}
if (data instanceof Blob) {
// For Blob, we would need to read it asynchronously
// This is a simplified implementation
throw new Error('Blob data type not fully supported in this implementation');
}
throw new Error('Unsupported data type');
}
}
exports.CoreFileSystemWritableFileStream = CoreFileSystemWritableFileStream;
//# sourceMappingURL=CoreFileSystemWritableFileStream.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,9 @@
import type { IPermissionStatus } from './types';
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/PermissionStatus
*/
export declare class CorePermissionStatus implements IPermissionStatus {
readonly name: string;
readonly state: 'granted' | 'denied' | 'prompt';
constructor(state: 'granted' | 'denied' | 'prompt', name?: string);
}

View File

@@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CorePermissionStatus = void 0;
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/PermissionStatus
*/
class CorePermissionStatus {
constructor(state, name = '') {
this.name = name;
this.state = state;
}
}
exports.CorePermissionStatus = CorePermissionStatus;
//# sourceMappingURL=CorePermissionStatus.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"CorePermissionStatus.js","sourceRoot":"","sources":["../src/CorePermissionStatus.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACH,MAAa,oBAAoB;IAI/B,YAAY,KAAsC,EAAE,OAAe,EAAE;QACnE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF;AARD,oDAQC"}

View File

@@ -0,0 +1,7 @@
export declare class FileLockManager {
private locks;
acquireLock(path: string): boolean;
releaseLock(path: string): void;
isLocked(path: string): boolean;
clear(): void;
}

View File

@@ -0,0 +1,26 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FileLockManager = void 0;
class FileLockManager {
constructor() {
this.locks = new Map();
}
acquireLock(path) {
if (this.locks.get(path)) {
return false;
}
this.locks.set(path, true);
return true;
}
releaseLock(path) {
this.locks.delete(path);
}
isLocked(path) {
return this.locks.get(path) ?? false;
}
clear() {
this.locks.clear();
}
}
exports.FileLockManager = FileLockManager;
//# sourceMappingURL=FileLockManager.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"FileLockManager.js","sourceRoot":"","sources":["../src/FileLockManager.ts"],"names":[],"mappings":";;;AAAA,MAAa,eAAe;IAA5B;QACU,UAAK,GAAyB,IAAI,GAAG,EAAE,CAAC;IAqBlD,CAAC;IAnBQ,WAAW,CAAC,IAAY;QAC7B,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACzB,OAAO,KAAK,CAAC;QACf,CAAC;QACD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,WAAW,CAAC,IAAY;QAC7B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAEM,QAAQ,CAAC,IAAY;QAC1B,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC;IACvC,CAAC;IAEM,KAAK;QACV,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;CACF;AAtBD,0CAsBC"}

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

@@ -0,0 +1,33 @@
import { CoreFileSystemDirectoryHandle } from './CoreFileSystemDirectoryHandle';
import { CoreFsaContext, IFileSystemObserverConstructable } from './types';
import { Superblock } from '@jsonjoy.com/fs-core';
export * from './types';
export * from './CoreFileSystemHandle';
export * from './CoreFileSystemDirectoryHandle';
export * from './CoreFileSystemFileHandle';
export * from './CoreFileSystemSyncAccessHandle';
export * from './CoreFileSystemWritableFileStream';
export * from './CoreFileSystemObserver';
export * from './CorePermissionStatus';
export * from './FileLockManager';
/**
* Create a new instance of an in-memory File System Access API
* implementation rooted at the root directory of the filesystem.
*
* @param ctx Optional context for the File System Access API.
* @param core Optional low-level file system implementation to
* back the File System Access API. If not provided, a new empty
* Superblock instance will be created.
* @param dirPath Optional path within the filesystem to use as the root
* directory of the File System Access API. Defaults to `/`.
* @returns A File System Access API implementation `dir` rooted at
* the root directory of the filesystem, as well as the `core`,
* a low-level file system implementation itself. Also, returns
* `FileSystemObserver`, a class that can be used to create
* observers that watch for changes to files and directories.
*/
export declare const fsa: (ctx?: Partial<CoreFsaContext>, core?: Superblock, dirPath?: string) => {
core: Superblock;
dir: CoreFileSystemDirectoryHandle;
FileSystemObserver: IFileSystemObserverConstructable;
};

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

@@ -0,0 +1,43 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.fsa = void 0;
const tslib_1 = require("tslib");
const CoreFileSystemDirectoryHandle_1 = require("./CoreFileSystemDirectoryHandle");
const fs_core_1 = require("@jsonjoy.com/fs-core");
const CoreFileSystemObserver_1 = require("./CoreFileSystemObserver");
tslib_1.__exportStar(require("./types"), exports);
tslib_1.__exportStar(require("./CoreFileSystemHandle"), exports);
tslib_1.__exportStar(require("./CoreFileSystemDirectoryHandle"), exports);
tslib_1.__exportStar(require("./CoreFileSystemFileHandle"), exports);
tslib_1.__exportStar(require("./CoreFileSystemSyncAccessHandle"), exports);
tslib_1.__exportStar(require("./CoreFileSystemWritableFileStream"), exports);
tslib_1.__exportStar(require("./CoreFileSystemObserver"), exports);
tslib_1.__exportStar(require("./CorePermissionStatus"), exports);
tslib_1.__exportStar(require("./FileLockManager"), exports);
/**
* Create a new instance of an in-memory File System Access API
* implementation rooted at the root directory of the filesystem.
*
* @param ctx Optional context for the File System Access API.
* @param core Optional low-level file system implementation to
* back the File System Access API. If not provided, a new empty
* Superblock instance will be created.
* @param dirPath Optional path within the filesystem to use as the root
* directory of the File System Access API. Defaults to `/`.
* @returns A File System Access API implementation `dir` rooted at
* the root directory of the filesystem, as well as the `core`,
* a low-level file system implementation itself. Also, returns
* `FileSystemObserver`, a class that can be used to create
* observers that watch for changes to files and directories.
*/
const fsa = (ctx, core = new fs_core_1.Superblock(), dirPath = '/') => {
const dir = new CoreFileSystemDirectoryHandle_1.CoreFileSystemDirectoryHandle(core, dirPath, ctx);
const FileSystemObserver = class FileSystemObserver extends CoreFileSystemObserver_1.CoreFileSystemObserver {
constructor(callback) {
super(core, callback);
}
};
return { core, dir, FileSystemObserver };
};
exports.fsa = fsa;
//# sourceMappingURL=index.js.map

1
node_modules/@jsonjoy.com/fs-fsa/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,mFAAgF;AAOhF,kDAAkD;AAClD,qEAAkE;AAElE,kDAAwB;AACxB,iEAAuC;AACvC,0EAAgD;AAChD,qEAA2C;AAC3C,2EAAiD;AACjD,6EAAmD;AACnD,mEAAyC;AACzC,iEAAuC;AACvC,4DAAkC;AAElC;;;;;;;;;;;;;;;GAeG;AACI,MAAM,GAAG,GAAG,CAAC,GAA6B,EAAE,IAAI,GAAG,IAAI,oBAAU,EAAE,EAAE,UAAkB,GAAG,EAAE,EAAE;IACnG,MAAM,GAAG,GAAG,IAAI,6DAA6B,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;IAClE,MAAM,kBAAkB,GAAqC,MAAM,kBAAmB,SAAQ,+CAAsB;QAClH,YAAY,QAAqF;YAC/F,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QACxB,CAAC;KACF,CAAC;IACF,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,kBAAkB,EAAE,CAAC;AAC3C,CAAC,CAAC;AARW,QAAA,GAAG,OAQd"}

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

@@ -0,0 +1,182 @@
import type { FileLockManager } from './FileLockManager';
export interface IPermissionStatus {
name: string;
state: 'granted' | 'denied' | 'prompt';
}
export interface IFileSystemHandle {
kind: 'file' | 'directory';
name: string;
isSameEntry(fileSystemHandle: IFileSystemHandle): boolean;
queryPermission(fileSystemHandlePermissionDescriptor: FileSystemHandlePermissionDescriptor): Promise<IPermissionStatus>;
remove(options?: {
recursive?: boolean;
}): Promise<void>;
requestPermission(fileSystemHandlePermissionDescriptor: FileSystemHandlePermissionDescriptor): IPermissionStatus;
}
export interface FileSystemHandlePermissionDescriptor {
mode: 'read' | 'readwrite';
}
export interface IFileSystemDirectoryHandle extends IFileSystemHandle {
keys(): AsyncIterableIterator<string>;
entries(): AsyncIterableIterator<[string, IFileSystemHandle]>;
values(): AsyncIterableIterator<IFileSystemHandle>;
getDirectoryHandle(name: string, options?: GetDirectoryHandleOptions): Promise<IFileSystemDirectoryHandle>;
getFileHandle(name: string, options?: GetFileHandleOptions): Promise<IFileSystemFileHandle>;
removeEntry(name: string, options?: RemoveEntryOptions): Promise<void>;
resolve(possibleDescendant: IFileSystemHandle): Promise<string[] | null>;
}
/**
* Context for Core FSA operations - similar to NodeFsaContext but for Superblock
*/
export interface CoreFsaContext {
separator: '/' | '\\';
/** Whether synchronous file handles are allowed. */
syncHandleAllowed: boolean;
/** Whether writes are allowed, defaults to `read`. */
mode: 'read' | 'readwrite';
/** File lock manager for this context. */
locks: FileLockManager;
}
export interface CreateWritableOptions {
keepExistingData?: boolean;
}
export interface GetDirectoryHandleOptions {
/**
* A boolean value, which defaults to `false`. When set to `true` if the directory
* is not found, one with the specified name will be created and returned.
*/
create?: boolean;
}
export interface GetFileHandleOptions {
/**
* A Boolean. Default `false`. When set to `true` if the file is not found,
* one with the specified name will be created and returned.
*/
create?: boolean;
}
export interface RemoveEntryOptions {
/**
* A boolean value, which defaults to `false`. When set to true entries will
* be removed recursively.
*/
recursive?: boolean;
}
export interface IFileSystemFileHandle extends IFileSystemHandle {
getFile(): Promise<File>;
createSyncAccessHandle: undefined | (() => Promise<IFileSystemSyncAccessHandle>);
createWritable(options?: CreateWritableOptions): Promise<IFileSystemWritableFileStream>;
}
export interface CreateWritableOptions {
keepExistingData?: boolean;
}
export interface IFileSystemSyncAccessHandle {
close(): Promise<void>;
flush(): Promise<void>;
getSize(): Promise<number>;
read(buffer: ArrayBuffer | ArrayBufferView, options?: FileSystemReadWriteOptions): Promise<number>;
truncate(newSize: number): Promise<void>;
write(buffer: ArrayBuffer | ArrayBufferView | DataView, options?: FileSystemReadWriteOptions): Promise<number>;
}
export interface FileSystemReadWriteOptions {
/**
* A number representing the offset in bytes that the file should be read from.
*/
at?: number;
}
export interface IFileSystemWritableFileStream extends WritableStream {
seek(position: number): Promise<void>;
truncate(size: number): Promise<void>;
write(chunk: Data): Promise<void>;
write(params: FileSystemWritableFileStreamParams): Promise<void>;
}
export interface FileSystemWritableFileStreamParams {
type: 'write' | 'truncate' | 'seek';
data?: Data;
position?: number;
size?: number;
}
export type Data = ArrayBuffer | ArrayBufferView | Uint8Array | Uint8ClampedArray | Int8Array | Uint16Array | Int16Array | Uint32Array | Int32Array | Float32Array | Float64Array | BigUint64Array | BigInt64Array | DataView | Blob | string;
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemChangeRecord
*/
export interface IFileSystemChangeRecord {
/**
* A reference to the file system handle that the change was observed on. This
* property will be null for records with a "disappeared", "errored", or
* "unknown" type.
*/
changedHandle: IFileSystemHandle | IFileSystemSyncAccessHandle | IFileSystemDirectoryHandle | null;
/**
* An array containing the path components that make up the relative file path
* from the `root` to the `changedHandle`, including the `changedHandle`
* filename.
*/
relativePathComponents: string[];
/**
* An array containing the path components that make up the relative file path
* from the `root` to the `changedHandle`'s former location, in the case of
* observations with a `"moved"` type. If the type is not `"moved"`, this
* property will be `null`.
*/
relativePathMovedFrom: string[] | null;
/**
* A reference to the root file system handle, that is, the one passed to the
* `observe()` call that started the observation.
*/
root: IFileSystemHandle | IFileSystemSyncAccessHandle | IFileSystemDirectoryHandle;
/**
* The type of change that occurred.
*/
type: 'appeared'
/**
* The file or directory was deleted or moved out of the root file structure.
* To find out which file or directory `disappeared`, you can query the
* `relativePathComponents` property.
*/
| 'disappeared'
/** An error state occurred in the observed directory. */
| 'errored'
/** The file or directory was modified. */
| 'modified'
/**
* The file or directory was moved within the root file structure.
*
* Chrome note: On Windows, "moved" observations aren't supported between
* directories. They are reported as a "disappeared" observation in the
* source directory and an "appeared" observation in the destination directory.
*/
| 'moved'
/**
* Indicates that some observations were missed. If you wish to find out
* information on what changed in the missed observations, you could fall
* back to polling the observed directory.
*/
| 'unknown';
}
export interface IFileSystemObserverObserveOptions {
/** Whether to observe changes recursively in subdirectories. */
recursive?: boolean;
}
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemObserver
*/
export interface IFileSystemObserver {
/**
* Start observing changes to a given file or directory.
*
* @param handle The file or directory handle to observe.
* @param options Optional settings for the observation.
*/
observe(handle: IFileSystemFileHandle | IFileSystemDirectoryHandle | IFileSystemSyncAccessHandle, options?: IFileSystemObserverObserveOptions): Promise<void>;
/** Disconnect and stop all observations. */
disconnect(): void;
}
export interface IFileSystemObserverConstructable {
/**
* Constructor for creating a FileSystemObserver.
*
* @param callback Function called with file system change records and the
* observer instance
*/
new (callback: (records: IFileSystemChangeRecord[], observer: IFileSystemObserver) => void): IFileSystemObserver;
}

3
node_modules/@jsonjoy.com/fs-fsa/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-fsa/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":""}

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

@@ -0,0 +1,12 @@
import type { CoreFsaContext } from './types';
/**
* Creates a new {@link CoreFsaContext}.
*/
export declare const ctx: (partial?: Partial<CoreFsaContext>) => CoreFsaContext;
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;
export declare const newNoModificationAllowedError: () => DOMException;

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

@@ -0,0 +1,45 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.newNoModificationAllowedError = exports.newNotAllowedError = exports.newTypeMismatchError = exports.newNotFoundError = exports.assertCanWrite = exports.assertName = exports.basename = exports.ctx = void 0;
const FileLockManager_1 = require("./FileLockManager");
/**
* Creates a new {@link CoreFsaContext}.
*/
const ctx = (partial = {}) => {
return {
separator: '/',
syncHandleAllowed: false,
mode: 'read',
locks: new FileLockManager_1.FileLockManager(),
...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;
const newNoModificationAllowedError = () => new DOMException('The file is locked and cannot be modified.', 'NoModificationAllowedError');
exports.newNoModificationAllowedError = newNoModificationAllowedError;
//# sourceMappingURL=util.js.map

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

@@ -0,0 +1 @@
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;;AAAA,uDAAoD;AAGpD;;GAEG;AACI,MAAM,GAAG,GAAG,CAAC,UAAmC,EAAE,EAAkB,EAAE;IAC3E,OAAO;QACL,SAAS,EAAE,GAAG;QACd,iBAAiB,EAAE,KAAK;QACxB,IAAI,EAAE,MAAM;QACZ,KAAK,EAAE,IAAI,iCAAe,EAAE;QAC5B,GAAG,OAAO;KACX,CAAC;AACJ,CAAC,CAAC;AARW,QAAA,GAAG,OAQd;AAEK,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,SAAiB,EAAE,EAAE;IAC1D,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK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EhG,MAAM,6BAA6B,GAAG,GAAG,EAAE,CAChD,IAAI,YAAY,CAAC,4CAA4C,EAAE,4BAA4B,CAAC,CAAC;AADlF,QAAA,6BAA6B,iCACqD"}

88
node_modules/@jsonjoy.com/fs-fsa/package.json generated vendored Normal file
View File

@@ -0,0 +1,88 @@
{
"name": "@jsonjoy.com/fs-fsa",
"publishConfig": {
"access": "public"
},
"version": "4.56.10",
"description": "File System Access API implementation backed by core filesystem primitives",
"author": {
"name": "streamich",
"url": "https://github.com/streamich"
},
"homepage": "https://github.com/streamich/memfs/tree/master/packages/fs-fsa",
"repository": "streamich/memfs",
"license": "Apache-2.0",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/streamich"
},
"keywords": [
"fsa",
"file system access",
"native file system",
"webfs",
"opfs",
"fs",
"filesystem",
"virtual",
"memory"
],
"engines": {
"node": ">=10.0"
},
"main": "lib/index.js",
"types": "lib/index.d.ts",
"typings": "lib/index.d.ts",
"files": [
"LICENSE",
"lib/"
],
"scripts": {
"clean": "rimraf lib typedocs coverage gh-pages yarn-error.log",
"build": "tsc --project tsconfig.build.json --module commonjs --target es2020 --outDir lib",
"jest": "node -r ts-node/register ./node_modules/.bin/jest",
"test": "jest --maxWorkers 7",
"test:ci": "yarn jest --maxWorkers 3 --no-cache",
"coverage": "yarn test --collectCoverage",
"typedoc": "typedoc",
"typecheck": "tsc -p ."
},
"jest": {
"preset": "ts-jest",
"testEnvironment": "node",
"moduleFileExtensions": [
"ts",
"js",
"tsx"
],
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
"transformIgnorePatterns": [
".*/node_modules/.*"
],
"testRegex": ".*/(__tests__|__jest__|demo)/.*\\.(test|spec)\\.tsx?$",
"rootDir": ".",
"testPathIgnorePatterns": [
"node_modules"
]
},
"devDependencies": {
"@types/jest": "^29.0.0",
"@types/node": "^20.0.0",
"jest": "^29.0.0",
"rimraf": "^5.0.0",
"ts-jest": "^29.4.2",
"ts-node": "^10.9.2",
"typescript": "^5.9.2"
},
"peerDependencies": {
"tslib": "2"
},
"dependencies": {
"@jsonjoy.com/fs-core": "4.56.10",
"@jsonjoy.com/fs-node-builtins": "4.56.10",
"@jsonjoy.com/fs-node-utils": "4.56.10",
"thingies": "^2.5.0"
}
}