/**
* A local, that is, client-side/browser-side, {@linkplain Resource resource}.
*/
export class LocalFile extends Resource {
/**
* Invoked by {@link LocalFiles} to create a resource object.
*/
constructor(uri, data, fileHandle) {
super(uri, data);
this._fileHandle = !fileHandle? null : fileHandle;
}
/**
* Returns the <code>FileSystemFileHandle</code> of this resource;
* <code>null</code> if this handle could not be determined (for example,
* when <code>loadResource</code> has been used or when the
* <a href="https://wicg.github.io/file-system-access/">File System
* Access</a> API is not supported by the browser).
*/
get fileHandle() {
return this._fileHandle;
}
toJSON(key) {
let obj = super.toJSON(key);
const handle = this.fileHandle;
obj.fileHandle =
(handle === null)? null : `<${handle.kind} "${handle.name}>"`;
return obj;
}
}