@opendaw/lib-fusion 0.0.25 → 0.0.27

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.
@@ -1,9 +1,9 @@
1
- import { Nullish, Subscription, Terminable } from "@opendaw/lib-std";
1
+ import { Maybe, Subscription, Terminable } from "@opendaw/lib-std";
2
2
  import { Address } from "@opendaw/lib-box";
3
3
  export declare class Subscribers<T> implements Terminable {
4
4
  #private;
5
5
  constructor();
6
- getOrNull(address: Address): Nullish<ReadonlyArray<T>>;
6
+ getOrNull(address: Address): Maybe<ReadonlyArray<T>>;
7
7
  isEmpty(address: Address): boolean;
8
8
  subscribe(address: Address, listener: T): Subscription;
9
9
  terminate(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"Subscribers.d.ts","sourceRoot":"","sources":["../../src/live-stream/Subscribers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,OAAO,EAAa,YAAY,EAAE,UAAU,EAAC,MAAM,kBAAkB,CAAA;AAChG,OAAO,EAAC,OAAO,EAAC,MAAM,kBAAkB,CAAA;AAIxC,qBAAa,WAAW,CAAC,CAAC,CAAE,YAAW,UAAU;;;IAK7C,SAAS,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAEtD,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO;IAElC,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,GAAG,YAAY;IAmBtD,SAAS,IAAI,IAAI;CACpB"}
1
+ {"version":3,"file":"Subscribers.d.ts","sourceRoot":"","sources":["../../src/live-stream/Subscribers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,EAAa,YAAY,EAAE,UAAU,EAAC,MAAM,kBAAkB,CAAA;AAC9F,OAAO,EAAC,OAAO,EAAC,MAAM,kBAAkB,CAAA;AAIxC,qBAAa,WAAW,CAAC,CAAC,CAAE,YAAW,UAAU;;;IAK7C,SAAS,CAAC,OAAO,EAAE,OAAO,GAAG,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAEpD,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO;IAElC,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,GAAG,YAAY;IAmBtD,SAAS,IAAI,IAAI;CACpB"}
@@ -1,12 +1,14 @@
1
- export type Kind = "file" | "directory";
2
- export type Entry = {
3
- name: string;
4
- kind: Kind;
5
- };
1
+ export declare namespace OpfsProtocol {
2
+ type Kind = "file" | "directory";
3
+ type Entry = {
4
+ name: string;
5
+ kind: Kind;
6
+ };
7
+ }
6
8
  export interface OpfsProtocol {
7
9
  write(path: string, data: Uint8Array): Promise<void>;
8
10
  read(path: string): Promise<Uint8Array>;
9
11
  delete(path: string): Promise<void>;
10
- list(path: string): Promise<ReadonlyArray<Entry>>;
12
+ list(path: string): Promise<ReadonlyArray<OpfsProtocol.Entry>>;
11
13
  }
12
14
  //# sourceMappingURL=OpfsProtocol.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"OpfsProtocol.d.ts","sourceRoot":"","sources":["../../src/opfs/OpfsProtocol.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,IAAI,GAAG,MAAM,GAAG,WAAW,CAAA;AACvC,MAAM,MAAM,KAAK,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,CAAA;AAEhD,MAAM,WAAW,YAAY;IACzB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACpD,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;IACvC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACnC,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAA;CACpD"}
1
+ {"version":3,"file":"OpfsProtocol.d.ts","sourceRoot":"","sources":["../../src/opfs/OpfsProtocol.ts"],"names":[],"mappings":"AAAA,yBAAiB,YAAY,CAAC;IAC1B,KAAY,IAAI,GAAG,MAAM,GAAG,WAAW,CAAA;IACvC,KAAY,KAAK,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,IAAI,CAAA;KAAE,CAAA;CACnD;AAED,MAAM,WAAW,YAAY;IACzB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACpD,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;IACvC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACnC,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAA;CACjE"}
@@ -1,12 +1,13 @@
1
1
  import { Communicator, Messenger } from "@opendaw/lib-runtime";
2
- import { Entry } from "./OpfsProtocol";
2
+ import { OpfsProtocol } from "./OpfsProtocol";
3
3
  import "../types";
4
4
  export declare namespace OpfsWorker {
5
5
  const init: (messenger: Messenger) => Communicator.Executor<{
6
6
  write(path: string, data: Uint8Array): Promise<void>;
7
7
  read(path: string): Promise<Uint8Array>;
8
8
  delete(path: string): Promise<void>;
9
- list(path: string): Promise<ReadonlyArray<Entry>>;
9
+ list(path: string): Promise<ReadonlyArray<OpfsProtocol.Entry>>;
10
+ clear(): Promise<void>;
10
11
  #resolveFile(path: string, options?: FileSystemGetDirectoryOptions): Promise<FileSystemSyncAccessHandle>;
11
12
  #resolveFolder(segments: ReadonlyArray<string>, options?: FileSystemGetDirectoryOptions): Promise<FileSystemDirectoryHandle>;
12
13
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"OpfsWorker.d.ts","sourceRoot":"","sources":["../../src/opfs/OpfsWorker.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAE,SAAS,EAAW,MAAM,sBAAsB,CAAA;AACtE,OAAO,EAAC,KAAK,EAAe,MAAM,gBAAgB,CAAA;AAClD,OAAO,UAAU,CAAA;AAEjB,yBAAiB,UAAU,CAAC;IAKjB,MAAM,IAAI,GAAI,WAAW,SAAS;oBAEf,MAAM,QAAQ,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;mBAWzC,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;qBAY1B,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;mBAMxB,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;2BAW9B,MAAM,YAAY,6BAA6B,GAAG,OAAO,CAAC,0BAA0B,CAAC;iCAO/E,aAAa,CAAC,MAAM,CAAC,YACrB,6BAA6B,GAAG,OAAO,CAAC,yBAAyB,CAAC;MAKnG,CAAA;CAMT"}
1
+ {"version":3,"file":"OpfsWorker.d.ts","sourceRoot":"","sources":["../../src/opfs/OpfsWorker.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAE,SAAS,EAAW,MAAM,sBAAsB,CAAA;AACtE,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAA;AAC3C,OAAO,UAAU,CAAA;AAEjB,yBAAiB,UAAU,CAAC;IAKjB,MAAM,IAAI,GAAI,WAAW,SAAS;oBAEf,MAAM,QAAQ,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;mBAWzC,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;qBAY1B,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;mBAOxB,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;iBAWrD,OAAO,CAAC,IAAI,CAAC;2BAWH,MAAM,YAAY,6BAA6B,GAAG,OAAO,CAAC,0BAA0B,CAAC;iCAO/E,aAAa,CAAC,MAAM,CAAC,YACrB,6BAA6B,GAAG,OAAO,CAAC,yBAAyB,CAAC;MAKnG,CAAA;CAMT"}
@@ -3,7 +3,7 @@ import { Communicator, Promises } from "@opendaw/lib-runtime";
3
3
  import "../types";
4
4
  export var OpfsWorker;
5
5
  (function (OpfsWorker) {
6
- const DEBUG = false;
6
+ const DEBUG = true;
7
7
  const readLimiter = new Promises.Limit(1);
8
8
  const writeLimiter = new Promises.Limit(1);
9
9
  OpfsWorker.init = (messenger) => Communicator.executor(messenger.channel("opfs"), new class {
@@ -34,6 +34,9 @@ export var OpfsWorker;
34
34
  }
35
35
  async delete(path) {
36
36
  const segments = pathToSegments(path);
37
+ if (segments.length === 0) {
38
+ return this.clear();
39
+ }
37
40
  return this.#resolveFolder(segments.slice(0, -1))
38
41
  .then(folder => folder.removeEntry(asDefined(segments.at(-1)), { recursive: true }));
39
42
  }
@@ -49,6 +52,17 @@ export var OpfsWorker;
49
52
  }
50
53
  return result;
51
54
  }
55
+ async clear() {
56
+ const root = await navigator.storage.getDirectory();
57
+ for await (const [name, handle] of root.entries()) {
58
+ if (handle.kind === "file") {
59
+ await root.removeEntry(name);
60
+ }
61
+ else if (handle.kind === "directory") {
62
+ await root.removeEntry(name, { recursive: true });
63
+ }
64
+ }
65
+ }
52
66
  async #resolveFile(path, options) {
53
67
  const segments = pathToSegments(path);
54
68
  return this.#resolveFolder(segments.slice(0, -1), options)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opendaw/lib-fusion",
3
- "version": "0.0.25",
3
+ "version": "0.0.27",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "license": "LGPL-3.0-or-later",
@@ -22,13 +22,13 @@
22
22
  "test": "echo \"No tests to run\""
23
23
  },
24
24
  "dependencies": {
25
- "@opendaw/lib-box": "^0.0.25",
26
- "@opendaw/lib-runtime": "^0.0.25",
27
- "@opendaw/lib-std": "^0.0.25"
25
+ "@opendaw/lib-box": "^0.0.27",
26
+ "@opendaw/lib-runtime": "^0.0.27",
27
+ "@opendaw/lib-std": "^0.0.27"
28
28
  },
29
29
  "devDependencies": {
30
- "@opendaw/eslint-config": "^0.0.18",
31
- "@opendaw/typescript-config": "^0.0.19"
30
+ "@opendaw/eslint-config": "^0.0.19",
31
+ "@opendaw/typescript-config": "^0.0.20"
32
32
  },
33
- "gitHead": "3d8d12f0591ea2182072dcb77b6f34c97b18a7ff"
33
+ "gitHead": "e94fe3bfdfa1c24ba8d16a695ebf7345286f3a32"
34
34
  }