@zenfs/dom 1.0.0 → 1.0.1

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.
@@ -55,7 +55,7 @@ declare const _IndexedDB: {
55
55
  };
56
56
  readonly isAvailable: (idbFactory?: IDBFactory) => Promise<boolean>;
57
57
  readonly create: (options: IndexedDBOptions & Partial<SharedConfig>) => Promise<{
58
- _sync?: import("@zenfs/core").FileSystem | undefined;
58
+ _sync?: import("@zenfs/core").FileSystem;
59
59
  queueDone(): Promise<void>;
60
60
  ready(): Promise<void>;
61
61
  renameSync(oldPath: string, newPath: string): void;
package/dist/Storage.d.ts CHANGED
@@ -4,9 +4,9 @@ import { SimpleTransaction, StoreFS } from '@zenfs/core';
4
4
  * A synchronous key-value store backed by Storage.
5
5
  */
6
6
  export declare class WebStorageStore implements Store, SimpleSyncStore {
7
- protected _storage: Storage;
7
+ protected storage: Storage;
8
8
  get name(): string;
9
- constructor(_storage: Storage);
9
+ constructor(storage: Storage);
10
10
  clear(): void;
11
11
  clearSync(): void;
12
12
  sync(): Promise<void>;
package/dist/Storage.js CHANGED
@@ -1,4 +1,4 @@
1
- import { ErrnoError, Errno, SimpleTransaction, StoreFS, decode, encode } from '@zenfs/core';
1
+ import { ErrnoError, Errno, SimpleTransaction, StoreFS, decodeRaw, encodeRaw } from '@zenfs/core';
2
2
  /**
3
3
  * A synchronous key-value store backed by Storage.
4
4
  */
@@ -6,14 +6,14 @@ export class WebStorageStore {
6
6
  get name() {
7
7
  return WebStorage.name;
8
8
  }
9
- constructor(_storage) {
10
- this._storage = _storage;
9
+ constructor(storage) {
10
+ this.storage = storage;
11
11
  }
12
12
  clear() {
13
- this._storage.clear();
13
+ this.storage.clear();
14
14
  }
15
15
  clearSync() {
16
- this._storage.clear();
16
+ this.storage.clear();
17
17
  }
18
18
  async sync() { }
19
19
  transaction() {
@@ -21,15 +21,15 @@ export class WebStorageStore {
21
21
  return new SimpleTransaction(this);
22
22
  }
23
23
  get(key) {
24
- const data = this._storage.getItem(key.toString());
24
+ const data = this.storage.getItem(key.toString());
25
25
  if (typeof data != 'string') {
26
26
  return;
27
27
  }
28
- return encode(data);
28
+ return encodeRaw(data);
29
29
  }
30
30
  set(key, data) {
31
31
  try {
32
- this._storage.setItem(key.toString(), decode(data));
32
+ this.storage.setItem(key.toString(), decodeRaw(data));
33
33
  }
34
34
  catch (e) {
35
35
  throw new ErrnoError(Errno.ENOSPC, 'Storage is full.');
@@ -37,7 +37,7 @@ export class WebStorageStore {
37
37
  }
38
38
  delete(key) {
39
39
  try {
40
- this._storage.removeItem(key.toString());
40
+ this.storage.removeItem(key.toString());
41
41
  }
42
42
  catch (e) {
43
43
  throw new ErrnoError(Errno.EIO, 'Unable to delete key ' + key + ': ' + e);
package/dist/access.d.ts CHANGED
@@ -12,7 +12,7 @@ export interface WebAccessOptions {
12
12
  handle: FileSystemDirectoryHandle;
13
13
  }
14
14
  declare const WebAccessFS_base: import("@zenfs/core").Mixin<typeof FileSystem, {
15
- _sync?: FileSystem | undefined;
15
+ _sync?: FileSystem;
16
16
  queueDone(): Promise<void>;
17
17
  ready(): Promise<void>;
18
18
  renameSync(oldPath: string, newPath: string): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zenfs/dom",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "DOM backends for ZenFS",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -42,12 +42,12 @@
42
42
  "eslint": "^9.12.0",
43
43
  "globals": "^15.10.0",
44
44
  "prettier": "^3.2.5",
45
- "typedoc": "^0.25.1",
46
- "typescript": "^5.4.5",
45
+ "typedoc": "^0.26.10",
46
+ "typescript": "^5.5.0",
47
47
  "typescript-eslint": "^8.8.1"
48
48
  },
49
49
  "peerDependencies": {
50
- "@zenfs/core": "^1.0.5"
50
+ "@zenfs/core": "^1.1.0"
51
51
  },
52
52
  "keywords": [
53
53
  "filesystem",
package/src/Storage.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Backend, Ino, SimpleSyncStore, Store } from '@zenfs/core';
2
- import { ErrnoError, Errno, SimpleTransaction, StoreFS, decode, encode } from '@zenfs/core';
2
+ import { ErrnoError, Errno, SimpleTransaction, StoreFS, decodeRaw, encodeRaw } from '@zenfs/core';
3
3
 
4
4
  /**
5
5
  * A synchronous key-value store backed by Storage.
@@ -9,14 +9,14 @@ export class WebStorageStore implements Store, SimpleSyncStore {
9
9
  return WebStorage.name;
10
10
  }
11
11
 
12
- public constructor(protected _storage: Storage) {}
12
+ public constructor(protected storage: Storage) {}
13
13
 
14
14
  public clear(): void {
15
- this._storage.clear();
15
+ this.storage.clear();
16
16
  }
17
17
 
18
18
  public clearSync(): void {
19
- this._storage.clear();
19
+ this.storage.clear();
20
20
  }
21
21
 
22
22
  public async sync(): Promise<void> {}
@@ -27,17 +27,17 @@ export class WebStorageStore implements Store, SimpleSyncStore {
27
27
  }
28
28
 
29
29
  public get(key: Ino): Uint8Array | undefined {
30
- const data = this._storage.getItem(key.toString());
30
+ const data = this.storage.getItem(key.toString());
31
31
  if (typeof data != 'string') {
32
32
  return;
33
33
  }
34
34
 
35
- return encode(data);
35
+ return encodeRaw(data);
36
36
  }
37
37
 
38
38
  public set(key: Ino, data: Uint8Array): void {
39
39
  try {
40
- this._storage.setItem(key.toString(), decode(data));
40
+ this.storage.setItem(key.toString(), decodeRaw(data));
41
41
  } catch (e) {
42
42
  throw new ErrnoError(Errno.ENOSPC, 'Storage is full.');
43
43
  }
@@ -45,7 +45,7 @@ export class WebStorageStore implements Store, SimpleSyncStore {
45
45
 
46
46
  public delete(key: Ino): void {
47
47
  try {
48
- this._storage.removeItem(key.toString());
48
+ this.storage.removeItem(key.toString());
49
49
  } catch (e) {
50
50
  throw new ErrnoError(Errno.EIO, 'Unable to delete key ' + key + ': ' + e);
51
51
  }