@zenfs/dom 1.0.5 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/IndexedDB.d.ts +4 -4
- package/dist/Storage.d.ts +1 -2
- package/dist/Storage.js +2 -6
- package/dist/access.d.ts +3 -4
- package/dist/access.js +9 -6
- package/dist/devices/dsp.d.ts +0 -1
- package/dist/devices/dsp.js +3 -3
- package/dist/devices/framebuffer.d.ts +9 -1
- package/dist/devices/framebuffer.js +33 -27
- package/package.json +4 -4
package/dist/IndexedDB.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { SharedConfig, Store } from '@zenfs/core';
|
|
2
|
-
import {
|
|
1
|
+
import type { AsyncMixin, SharedConfig, Store } from '@zenfs/core';
|
|
2
|
+
import { AsyncTransaction, StoreFS } from '@zenfs/core';
|
|
3
3
|
/**
|
|
4
4
|
* @hidden
|
|
5
5
|
*/
|
|
@@ -53,10 +53,10 @@ declare const _IndexedDB: {
|
|
|
53
53
|
};
|
|
54
54
|
};
|
|
55
55
|
readonly isAvailable: (idbFactory?: IDBFactory) => Promise<boolean>;
|
|
56
|
-
readonly create: (options: IndexedDBOptions & Partial<SharedConfig>) => Promise<
|
|
56
|
+
readonly create: (options: IndexedDBOptions & Partial<SharedConfig>) => Promise<AsyncMixin & StoreFS<IndexedDBStore>>;
|
|
57
57
|
};
|
|
58
58
|
type _IndexedDB = typeof _IndexedDB;
|
|
59
|
-
interface IndexedDB extends _IndexedDB {
|
|
59
|
+
export interface IndexedDB extends _IndexedDB {
|
|
60
60
|
}
|
|
61
61
|
export declare const IndexedDB: IndexedDB;
|
|
62
62
|
export {};
|
package/dist/Storage.d.ts
CHANGED
|
@@ -34,7 +34,6 @@ declare const _WebStorage: {
|
|
|
34
34
|
readonly storage: {
|
|
35
35
|
readonly type: "object";
|
|
36
36
|
readonly required: false;
|
|
37
|
-
readonly description: "The Storage to use. Defaults to globalThis.localStorage.";
|
|
38
37
|
};
|
|
39
38
|
};
|
|
40
39
|
/**
|
|
@@ -44,7 +43,7 @@ declare const _WebStorage: {
|
|
|
44
43
|
readonly create: ({ storage }: WebStorageOptions) => StoreFS<WebStorageStore>;
|
|
45
44
|
};
|
|
46
45
|
type _WebStorage = typeof _WebStorage;
|
|
47
|
-
interface WebStorage extends _WebStorage {
|
|
46
|
+
export interface WebStorage extends _WebStorage {
|
|
48
47
|
}
|
|
49
48
|
export declare const WebStorage: WebStorage;
|
|
50
49
|
export {};
|
package/dist/Storage.js
CHANGED
|
@@ -9,6 +9,7 @@ export class WebStorageStore {
|
|
|
9
9
|
constructor(storage) {
|
|
10
10
|
this.storage = storage;
|
|
11
11
|
}
|
|
12
|
+
/* node:coverage ignore next 10 */
|
|
12
13
|
clear() {
|
|
13
14
|
this.storage.clear();
|
|
14
15
|
}
|
|
@@ -17,7 +18,6 @@ export class WebStorageStore {
|
|
|
17
18
|
}
|
|
18
19
|
async sync() { }
|
|
19
20
|
transaction() {
|
|
20
|
-
// No need to differentiate.
|
|
21
21
|
return new SimpleTransaction(this);
|
|
22
22
|
}
|
|
23
23
|
keys() {
|
|
@@ -53,11 +53,7 @@ export class WebStorageStore {
|
|
|
53
53
|
const _WebStorage = {
|
|
54
54
|
name: 'WebStorage',
|
|
55
55
|
options: {
|
|
56
|
-
storage: {
|
|
57
|
-
type: 'object',
|
|
58
|
-
required: false,
|
|
59
|
-
description: 'The Storage to use. Defaults to globalThis.localStorage.',
|
|
60
|
-
},
|
|
56
|
+
storage: { type: 'object', required: false },
|
|
61
57
|
},
|
|
62
58
|
/**
|
|
63
59
|
* @todo Consider replacing `instanceof` with a duck-typing check?
|
package/dist/access.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { FileSystemMetadata } from '@zenfs/core';
|
|
2
|
-
import {
|
|
2
|
+
import { FileSystem, PreloadFile, Stats } from '@zenfs/core';
|
|
3
3
|
export interface WebAccessOptions {
|
|
4
4
|
handle: FileSystemDirectoryHandle;
|
|
5
5
|
}
|
|
6
|
-
declare const WebAccessFS_base: import("@zenfs/core").Mixin<typeof FileSystem,
|
|
6
|
+
declare const WebAccessFS_base: import("@zenfs/core").Mixin<typeof FileSystem, import("@zenfs/core").AsyncMixin>;
|
|
7
7
|
export declare class WebAccessFS extends WebAccessFS_base {
|
|
8
8
|
private _handles;
|
|
9
9
|
/**
|
|
@@ -31,14 +31,13 @@ declare const _WebAccess: {
|
|
|
31
31
|
readonly handle: {
|
|
32
32
|
readonly type: "object";
|
|
33
33
|
readonly required: true;
|
|
34
|
-
readonly description: "The directory handle to use for the root";
|
|
35
34
|
};
|
|
36
35
|
};
|
|
37
36
|
readonly isAvailable: () => boolean;
|
|
38
37
|
readonly create: (options: WebAccessOptions) => WebAccessFS;
|
|
39
38
|
};
|
|
40
39
|
type _WebAccess = typeof _WebAccess;
|
|
41
|
-
interface WebAccess extends _WebAccess {
|
|
40
|
+
export interface WebAccess extends _WebAccess {
|
|
42
41
|
}
|
|
43
42
|
export declare const WebAccess: WebAccess;
|
|
44
43
|
export {};
|
package/dist/access.js
CHANGED
|
@@ -2,6 +2,13 @@ import { Async, Errno, ErrnoError, FileSystem, InMemory, PreloadFile, Stats } fr
|
|
|
2
2
|
import { S_IFDIR, S_IFREG } from '@zenfs/core/emulation/constants.js';
|
|
3
3
|
import { basename, dirname, join } from '@zenfs/core/emulation/path.js';
|
|
4
4
|
import { convertException } from './utils.js';
|
|
5
|
+
function isResizable(buffer) {
|
|
6
|
+
if (buffer instanceof ArrayBuffer)
|
|
7
|
+
return buffer.resizable;
|
|
8
|
+
if (buffer instanceof SharedArrayBuffer)
|
|
9
|
+
return buffer.growable;
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
5
12
|
export class WebAccessFS extends Async(FileSystem) {
|
|
6
13
|
constructor(handle) {
|
|
7
14
|
super();
|
|
@@ -55,7 +62,7 @@ export class WebAccessFS extends Async(FileSystem) {
|
|
|
55
62
|
await this.unlink(oldPath);
|
|
56
63
|
}
|
|
57
64
|
async writeFile(path, data) {
|
|
58
|
-
if (data.buffer
|
|
65
|
+
if (isResizable(data.buffer)) {
|
|
59
66
|
throw new ErrnoError(Errno.EINVAL, 'Resizable buffers can not be written', path, 'write');
|
|
60
67
|
}
|
|
61
68
|
const handle = await this.getHandle(dirname(path));
|
|
@@ -171,11 +178,7 @@ export class WebAccessFS extends Async(FileSystem) {
|
|
|
171
178
|
const _WebAccess = {
|
|
172
179
|
name: 'WebAccess',
|
|
173
180
|
options: {
|
|
174
|
-
handle: {
|
|
175
|
-
type: 'object',
|
|
176
|
-
required: true,
|
|
177
|
-
description: 'The directory handle to use for the root',
|
|
178
|
-
},
|
|
181
|
+
handle: { type: 'object', required: true },
|
|
179
182
|
},
|
|
180
183
|
isAvailable() {
|
|
181
184
|
return typeof FileSystemHandle == 'function';
|
package/dist/devices/dsp.d.ts
CHANGED
package/dist/devices/dsp.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import './audioworklet.d.ts';
|
|
2
1
|
if ('AudioWorkletProcessor' in globalThis) {
|
|
3
2
|
class Dsp extends AudioWorkletProcessor {
|
|
4
3
|
constructor() {
|
|
@@ -41,14 +40,15 @@ export async function dsp(options = {}) {
|
|
|
41
40
|
});
|
|
42
41
|
return {
|
|
43
42
|
name: 'dsp',
|
|
44
|
-
|
|
43
|
+
singleton: true,
|
|
44
|
+
init(ino, options) {
|
|
45
45
|
return { data: dsp, major: 14, minor: 3 };
|
|
46
46
|
},
|
|
47
47
|
read() {
|
|
48
48
|
return 0;
|
|
49
49
|
},
|
|
50
50
|
write(file, data) {
|
|
51
|
-
|
|
51
|
+
file.device.data.port.postMessage(data.buffer);
|
|
52
52
|
return data.byteLength;
|
|
53
53
|
},
|
|
54
54
|
};
|
|
@@ -2,4 +2,12 @@ import type { DeviceDriver } from '@zenfs/core';
|
|
|
2
2
|
export interface FramebufferOptions {
|
|
3
3
|
canvas?: HTMLCanvasElement | null;
|
|
4
4
|
}
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* A frame buffer
|
|
7
|
+
*
|
|
8
|
+
* Setup:
|
|
9
|
+
* ```
|
|
10
|
+
* addDevice(framebuffer, { canvas: document.querySelector('#your-canvas') })
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare const framebuffer: DeviceDriver<CanvasRenderingContext2D>;
|
|
@@ -1,30 +1,36 @@
|
|
|
1
|
-
/* Credit: David Konsumer */
|
|
2
1
|
import { Errno, ErrnoError } from '@zenfs/core';
|
|
3
2
|
let framebufferN = 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
3
|
+
/**
|
|
4
|
+
* A frame buffer
|
|
5
|
+
*
|
|
6
|
+
* Setup:
|
|
7
|
+
* ```
|
|
8
|
+
* addDevice(framebuffer, { canvas: document.querySelector('#your-canvas') })
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export const framebuffer = {
|
|
12
|
+
name: 'framebuffer',
|
|
13
|
+
init(ino, { canvas } = {}) {
|
|
14
|
+
if (!canvas) {
|
|
15
|
+
canvas = document.createElement('canvas');
|
|
16
|
+
document.body.appendChild(canvas);
|
|
17
|
+
}
|
|
18
|
+
const ctx = canvas.getContext('2d');
|
|
19
|
+
if (!ctx) {
|
|
20
|
+
throw new ErrnoError(Errno.EIO, 'Could not get context from canvas whilst initializing frame buffer.');
|
|
21
|
+
}
|
|
22
|
+
return { data: ctx, major: 29, minor: framebufferN++, name: 'fb' };
|
|
23
|
+
},
|
|
24
|
+
read() {
|
|
25
|
+
return 0;
|
|
26
|
+
},
|
|
27
|
+
write(file, data) {
|
|
28
|
+
const { width, height } = file.device.data.canvas;
|
|
29
|
+
if (data.byteLength < 4 * width * height) {
|
|
19
30
|
return 0;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
ctx.putImageData(imageData, 0, 0);
|
|
27
|
-
return data.byteLength;
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
+
}
|
|
32
|
+
const imageData = new ImageData(new Uint8ClampedArray(data), width, height);
|
|
33
|
+
file.device.data.putImageData(imageData, 0, 0);
|
|
34
|
+
return data.byteLength;
|
|
35
|
+
},
|
|
36
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zenfs/dom",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "DOM backends for ZenFS",
|
|
5
5
|
"funding": {
|
|
6
6
|
"type": "individual",
|
|
@@ -50,12 +50,12 @@
|
|
|
50
50
|
"globals": "^15.10.0",
|
|
51
51
|
"prettier": "^3.2.5",
|
|
52
52
|
"tsx": "^4.19.2",
|
|
53
|
-
"typedoc": "^0.
|
|
54
|
-
"typescript": "^5.
|
|
53
|
+
"typedoc": "^0.27.2",
|
|
54
|
+
"typescript": "^5.7.2",
|
|
55
55
|
"typescript-eslint": "^8.8.1"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"@zenfs/core": "^1.
|
|
58
|
+
"@zenfs/core": "^1.6.4"
|
|
59
59
|
},
|
|
60
60
|
"optionalDependencies": {
|
|
61
61
|
"fake-indexeddb": "^6.0.0",
|