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

View File

@@ -0,0 +1,72 @@
import { NodeFileSystemHandle } from './NodeFileSystemHandle';
import type { NodeFsaContext, NodeFsaFs } from './types';
import type { GetDirectoryHandleOptions, GetFileHandleOptions, IFileSystemDirectoryHandle, IFileSystemFileHandle, IFileSystemHandle, RemoveEntryOptions } from '@jsonjoy.com/fs-fsa';
/**
* @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: 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 IFileSystemHandle} from which
* to return the relative path.
*/
resolve(possibleDescendant: IFileSystemHandle): Promise<string[] | null>;
}

View File

@@ -0,0 +1,217 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NodeFileSystemDirectoryHandle = void 0;
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 = {}) {
const fullCtx = (0, util_1.ctx)(ctx);
super('directory', (0, util_1.basename)(path, fullCtx.separator));
this.fs = fs;
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 NodeFileSystemDirectoryHandle} object.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle/keys
*/
async *keys() {
const list = await this.fs.promises.readdir(this.__path);
for (const name of list)
yield '' + name;
}
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle/entries
*/
async *entries() {
const { __path: path, fs, ctx } = this;
const list = 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 [name, new NodeFileSystemDirectoryHandle(fs, newPath, ctx)];
else if (dirent.isFile())
yield [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
*/
async *values() {
for await (const [, value] of this.entries())
yield value;
}
/**
* 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;
const { fs } = this;
try {
const stats = await fs.promises.stat(filename);
if (!stats.isDirectory())
throw (0, util_1.newTypeMismatchError)();
return new NodeFileSystemDirectoryHandle(fs, filename, this.ctx);
}
catch (error) {
if (error instanceof DOMException)
throw error;
if (error && typeof error === 'object') {
switch (error.code) {
case 'ENOENT': {
if (options?.create) {
(0, util_1.assertCanWrite)(this.ctx.mode);
try {
await fs.promises.mkdir(filename);
}
catch (mkdirError) {
if (mkdirError && typeof mkdirError === 'object' && mkdirError.code === 'EEXIST') {
const stats = await fs.promises.stat(filename);
if (!stats.isDirectory())
throw (0, util_1.newTypeMismatchError)();
return new NodeFileSystemDirectoryHandle(fs, filename, this.ctx);
}
throw mkdirError;
}
return new NodeFileSystemDirectoryHandle(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?.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 IFileSystemHandle} 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

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 '@jsonjoy.com/fs-fsa';
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;
}

View File

@@ -0,0 +1,70 @@
"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 () => {
if (this.ctx.locks.isLocked(this.__path)) {
throw (0, util_1.newNoModificationAllowedError)();
}
return 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);
if (this.ctx.locks.isLocked(this.__path)) {
throw (0, util_1.newNoModificationAllowedError)();
}
return new NodeFileSystemWritableFileStream_1.NodeFileSystemWritableFileStream(this.fs, this.__path, keepExistingData, this.ctx);
}
}
exports.NodeFileSystemFileHandle = NodeFileSystemFileHandle;
//# sourceMappingURL=NodeFileSystemFileHandle.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"NodeFileSystemFileHandle.js","sourceRoot":"","sources":["../src/NodeFileSystemFileHandle.ts"],"names":[],"mappings":";;;AAAA,iEAA8D;AAC9D,qFAAkF;AAClF,iCAAuH;AACvH,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;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IACJ,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,cAAc,CACzB,EAAE,gBAAgB,GAAG,KAAK,KAA4B,EAAE,gBAAgB,EAAE,KAAK,EAAE;QAEjF,IAAA,qBAAc,EAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC9B,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;YACzC,MAAM,IAAA,oCAA6B,GAAE,CAAC;QACxC,CAAC;QACD,OAAO,IAAI,mEAAgC,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,MAAM,EAAE,gBAAgB,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;IAChG,CAAC;CACF;AAlED,4DAkEC"}

View File

@@ -0,0 +1,37 @@
import { NodePermissionStatus } from './NodePermissionStatus';
import type { IFileSystemHandle, FileSystemHandlePermissionDescriptor } from '@jsonjoy.com/fs-fsa';
import type { NodeFsaFs, NodeFsaContext } from './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;
protected abstract readonly fs: NodeFsaFs;
protected abstract readonly __path: string;
protected abstract readonly ctx: NodeFsaContext;
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: IFileSystemHandle): boolean;
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemHandle/queryPermission
*/
queryPermission(fileSystemHandlePermissionDescriptor: FileSystemHandlePermissionDescriptor): Promise<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;
}

View File

@@ -0,0 +1,68 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NodeFileSystemHandle = void 0;
const NodePermissionStatus_1 = require("./NodePermissionStatus");
/**
* 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
*/
async queryPermission(fileSystemHandlePermissionDescriptor) {
const { mode } = fileSystemHandlePermissionDescriptor;
// Check if the requested mode is compatible with the context mode
const requestedMode = mode;
const contextMode = this.ctx.mode;
// If requesting readwrite but context only allows read, deny
if (requestedMode === 'readwrite' && contextMode === 'read') {
return new NodePermissionStatus_1.NodePermissionStatus(requestedMode, 'denied');
}
try {
// Use Node.js fs.promises.access() to check permissions asynchronously
let accessMode = 0 /* AMODE.F_OK */;
if (mode === 'read') {
accessMode = 4 /* AMODE.R_OK */;
}
else if (mode === 'readwrite') {
accessMode = 4 /* AMODE.R_OK */ | 2 /* AMODE.W_OK */;
}
// Use asynchronous access check
await this.fs.promises.access(this.__path, accessMode);
return new NodePermissionStatus_1.NodePermissionStatus(mode, 'granted');
}
catch (error) {
// If access check fails, permission is denied
return new NodePermissionStatus_1.NodePermissionStatus(mode, 'denied');
}
}
/**
* @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

View File

@@ -0,0 +1 @@
{"version":3,"file":"NodeFileSystemHandle.js","sourceRoot":"","sources":["../src/NodeFileSystemHandle.ts"],"names":[],"mappings":";;;AACA,iEAA8D;AAI9D;;;;;GAKG;AACH,MAAsB,oBAAoB;IAKxC,YACkB,IAA0B,EAC1B,IAAY;QADZ,SAAI,GAAJ,IAAI,CAAsB;QAC1B,SAAI,GAAJ,IAAI,CAAQ;IAC3B,CAAC;IAEJ;;;;OAIG;IACI,WAAW,CAAC,gBAAmC;QACpD,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,MAAM,EAAE,IAAI,EAAE,GAAG,oCAAoC,CAAC;QAEtD,kEAAkE;QAClE,MAAM,aAAa,GAAG,IAAI,CAAC;QAC3B,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,aAAa,EAAE,QAAQ,CAAC,CAAC;QAC3D,CAAC;QAED,IAAI,CAAC;YACH,uEAAuE;YACvE,IAAI,UAAU,qBAAa,CAAC;YAE5B,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;gBACpB,UAAU,qBAAa,CAAC;YAC1B,CAAC;iBAAM,IAAI,IAAI,KAAK,WAAW,EAAE,CAAC;gBAChC,UAAU,GAAG,uCAAuB,CAAC;YACvC,CAAC;YAED,gCAAgC;YAChC,MAAM,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;YAEvD,OAAO,IAAI,2CAAoB,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QACnD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,8CAA8C;YAC9C,OAAO,IAAI,2CAAoB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAClD,CAAC;IACH,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;AAzED,oDAyEC"}

View File

@@ -0,0 +1,42 @@
import type { FileSystemReadWriteOptions, IFileSystemSyncAccessHandle } from '@jsonjoy.com/fs-fsa';
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>;
}

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("@jsonjoy.com/fs-node-builtins/lib/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+');
this.ctx.locks.acquireLock(this.path);
}
/**
* @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);
this.ctx.locks.releaseLock(this.path);
}
/**
* @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 = {}) {
const buf = buffer instanceof ArrayBuffer ? buffer_1.Buffer.from(buffer) : buffer;
try {
const size = this.fs.readSync(this.fd, buf, 0, buffer.byteLength, options.at ?? 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 = {}) {
(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, options.at ?? 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

View File

@@ -0,0 +1 @@
{"version":3,"file":"NodeFileSystemSyncAccessHandle.js","sourceRoot":"","sources":["../src/NodeFileSystemSyncAccessHandle.ts"],"names":[],"mappings":";;;AAAA,iCAAwC;AACxC,8EAA2E;AAI3E;;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,IAA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mB,CAAC,CAAC;oBAC7E,CAAC;gBACH,CAAC;YACH,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF;AA9FD,wEA8FC"}

View File

@@ -0,0 +1,56 @@
import type { Data, FileSystemWritableFileStreamParams, IFileSystemWritableFileStream } from '@jsonjoy.com/fs-fsa';
import type { IFileHandle } from '@jsonjoy.com/fs-node-utils/lib/types/misc';
import type { NodeFsaFs, NodeFsaContext } 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>;
}
declare const WS: typeof WritableStream;
/**
* 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 WS implements IFileSystemWritableFileStream {
protected readonly fs: NodeFsaFs;
protected readonly path: string;
protected readonly ctx: NodeFsaContext;
protected readonly swap: SwapFile;
constructor(fs: NodeFsaFs, path: string, keepExistingData: boolean, ctx: NodeFsaContext);
/**
* @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 {};

View File

@@ -0,0 +1,191 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NodeFileSystemWritableFileStream = exports.createSwapFile = void 0;
const buffer_1 = require("@jsonjoy.com/fs-node-builtins/lib/internal/buffer");
const util_1 = require("./util");
/**
* 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;
const WS = (typeof WritableStream === 'undefined' ? require('stream/web').WritableStream : WritableStream);
/**
* 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 WS {
constructor(fs, path, keepExistingData, ctx) {
const swap = { handle: undefined, path: '', offset: 0 };
super({
async start() {
if (ctx.locks.isLocked(path)) {
throw (0, util_1.newNoModificationAllowedError)();
}
ctx.locks.acquireLock(path);
try {
const promise = (0, exports.createSwapFile)(fs, path, keepExistingData);
swap.ready = promise.then(() => undefined);
const [handle, swapPath] = await promise;
swap.handle = handle;
swap.path = swapPath;
}
catch (error) {
ctx.locks.releaseLock(path);
throw error;
}
},
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
? new Uint8Array(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);
ctx.locks.releaseLock(path);
},
async abort() {
await swap.ready;
const handle = swap.handle;
if (!handle)
return;
await handle.close();
await fs.promises.unlink(swap.path);
ctx.locks.releaseLock(path);
},
});
this.fs = fs;
this.path = path;
this.ctx = ctx;
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

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');
}

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

View File

@@ -0,0 +1 @@
{"version":3,"file":"NodePermissionStatus.js","sourceRoot":"","sources":["../src/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"}

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
node_modules/@jsonjoy.com/fs-node-to-fsa/lib/index.js generated vendored Normal file
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

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/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"}

View File

@@ -0,0 +1,18 @@
import type { FsPromisesApi, FsSynchronousApi } from '@jsonjoy.com/fs-node-utils';
import type { FsCommonObjects } from '@jsonjoy.com/fs-node-utils/lib/types/FsCommonObjects';
import type { FileLockManager } from '@jsonjoy.com/fs-fsa';
/**
* 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' | 'accessSync'>;
export interface NodeFsaContext {
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;
}

View File

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

View File

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

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

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

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

@@ -0,0 +1,40 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.newNoModificationAllowedError = exports.newNotAllowedError = exports.newTypeMismatchError = exports.newNotFoundError = exports.assertCanWrite = exports.assertName = exports.ctx = exports.basename = void 0;
const fs_fsa_1 = require("@jsonjoy.com/fs-fsa");
var fs_node_utils_1 = require("@jsonjoy.com/fs-node-utils");
Object.defineProperty(exports, "basename", { enumerable: true, get: function () { return fs_node_utils_1.basename; } });
/**
* Creates a new {@link NodeFsaContext}.
*/
const ctx = (partial = {}) => {
return {
separator: '/',
syncHandleAllowed: false,
mode: 'read',
locks: new fs_fsa_1.FileLockManager(),
...partial,
};
};
exports.ctx = ctx;
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

View File

@@ -0,0 +1 @@
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;;AACA,gDAAsD;AAEtD,4DAAsD;AAA7C,yGAAA,QAAQ,OAAA;AAEjB;;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,wBAAe,EAAE;QAC5B,GAAG,OAAO;KACX,CAAC;AACJ,CAAC,CAAC;AARW,QAAA,GAAG,OAQd;AAEF,MAAM,SAAS,GAAG,8BAA8B,CAAC;AAE1C,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,MAAc,EAAE,KAAa,EAAE,EAAE;IACxE,MAAM,SAAS,GAAG,CAAC,IAAI,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChD,IAAI,SAAS;QAAE,MA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