@opendaw/studio-core 0.0.43 → 0.0.44

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.
Files changed (48) hide show
  1. package/dist/AssetService.d.ts +12 -2
  2. package/dist/AssetService.d.ts.map +1 -1
  3. package/dist/AssetService.js +46 -1
  4. package/dist/EngineWorklet.d.ts +1 -1
  5. package/dist/EngineWorklet.d.ts.map +1 -1
  6. package/dist/capture/CaptureDevices.js +1 -1
  7. package/dist/cloud/CloudAuthManager.d.ts +6 -2
  8. package/dist/cloud/CloudAuthManager.d.ts.map +1 -1
  9. package/dist/cloud/CloudAuthManager.js +12 -12
  10. package/dist/cloud/CloudBackup.js +1 -1
  11. package/dist/cloud/{CloudBackupSoundfont.d.ts → CloudBackupSoundfonts.d.ts} +1 -1
  12. package/dist/cloud/CloudBackupSoundfonts.d.ts.map +1 -0
  13. package/dist/cloud/{CloudBackupSoundfont.js → CloudBackupSoundfonts.js} +1 -1
  14. package/dist/processors.js +27 -5
  15. package/dist/processors.js.map +4 -4
  16. package/dist/project/Project.d.ts +2 -2
  17. package/dist/project/Project.d.ts.map +1 -1
  18. package/dist/project/Project.js +2 -3
  19. package/dist/samples/OpenSampleAPI.d.ts.map +1 -1
  20. package/dist/samples/OpenSampleAPI.js +5 -3
  21. package/dist/samples/SampleService.d.ts +5 -2
  22. package/dist/samples/SampleService.d.ts.map +1 -1
  23. package/dist/samples/SampleService.js +12 -4
  24. package/dist/samples/SampleStorage.d.ts +1 -1
  25. package/dist/samples/SampleStorage.d.ts.map +1 -1
  26. package/dist/samples/SampleStorage.js +1 -1
  27. package/dist/soundfont/DefaultSoundfontLoader.d.ts +2 -1
  28. package/dist/soundfont/DefaultSoundfontLoader.d.ts.map +1 -1
  29. package/dist/soundfont/DefaultSoundfontLoader.js +14 -4
  30. package/dist/soundfont/DefaultSoundfontLoaderManager.d.ts +2 -1
  31. package/dist/soundfont/DefaultSoundfontLoaderManager.d.ts.map +1 -1
  32. package/dist/soundfont/DefaultSoundfontLoaderManager.js +1 -0
  33. package/dist/soundfont/OpenSoundfontAPI.d.ts.map +1 -1
  34. package/dist/soundfont/OpenSoundfontAPI.js +6 -4
  35. package/dist/soundfont/SoundfontService.d.ts +5 -2
  36. package/dist/soundfont/SoundfontService.d.ts.map +1 -1
  37. package/dist/soundfont/SoundfontService.js +18 -8
  38. package/dist/workers-main.js +2 -2
  39. package/dist/workers-main.js.map +3 -3
  40. package/dist/ysync/YService.d.ts.map +1 -1
  41. package/dist/ysync/YService.js +4 -2
  42. package/dist/ysync/YSync.d.ts.map +1 -1
  43. package/dist/ysync/YSync.js +79 -51
  44. package/package.json +17 -16
  45. package/dist/cloud/CloudBackupSoundfont.d.ts.map +0 -1
  46. package/dist/env.d.ts +0 -6
  47. package/dist/env.d.ts.map +0 -1
  48. package/dist/env.js +0 -9
@@ -1,4 +1,7 @@
1
- import { Procedure, Progress, UUID } from "@opendaw/lib-std";
1
+ import { Class, Procedure, Progress, UUID } from "@opendaw/lib-std";
2
+ import { BoxGraph } from "@opendaw/lib-box";
3
+ import { Sample, Soundfont } from "@opendaw/studio-adapters";
4
+ import { AudioFileBox, SoundfontFileBox } from "@opendaw/studio-boxes";
2
5
  export declare namespace AssetService {
3
6
  type ImportArgs = {
4
7
  uuid?: UUID.Bytes;
@@ -7,12 +10,19 @@ export declare namespace AssetService {
7
10
  progressHandler?: Progress.Handler;
8
11
  };
9
12
  }
10
- export declare abstract class AssetService<T> {
13
+ export declare abstract class AssetService<T extends Sample | Soundfont> {
11
14
  protected readonly onUpdate: Procedure<T>;
12
15
  protected abstract readonly nameSingular: string;
13
16
  protected abstract readonly namePlural: string;
17
+ protected abstract readonly boxType: Class<AudioFileBox | SoundfontFileBox>;
18
+ protected abstract readonly filePickerOptions: FilePickerOptions;
14
19
  protected constructor(onUpdate: Procedure<T>);
20
+ browse(multiple: boolean): Promise<ReadonlyArray<T>>;
15
21
  abstract importFile(args: AssetService.ImportArgs): Promise<T>;
22
+ replaceMissingFiles(boxGraph: BoxGraph, manager: {
23
+ invalidate: (uuid: UUID.Bytes) => void;
24
+ }): Promise<void>;
16
25
  protected browseFiles(multiple: boolean, filePickerSettings: FilePickerOptions): Promise<ReadonlyArray<T>>;
26
+ protected abstract collectAllFiles(): Promise<ReadonlyArray<T>>;
17
27
  }
18
28
  //# sourceMappingURL=AssetService.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AssetService.d.ts","sourceRoot":"","sources":["../src/AssetService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwC,SAAS,EAAE,QAAQ,EAAmB,IAAI,EAAC,MAAM,kBAAkB,CAAA;AAIlH,yBAAiB,YAAY,CAAC;IAC1B,KAAY,UAAU,GAAG;QACrB,IAAI,CAAC,EAAE,IAAI,CAAC,KAAK,CAAA;QACjB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,WAAW,EAAE,WAAW,CAAC;QACzB,eAAe,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAA;KACrC,CAAA;CACJ;AAED,8BAAsB,YAAY,CAAC,CAAC;IAIV,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC;IAH/D,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAChD,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAE9C,SAAS,aAAgC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC;IAE/D,QAAQ,CAAC,UAAU,CAAC,IAAI,EAAE,YAAY,CAAC,UAAU,GAAG,OAAO,CAAC,CAAC,CAAC;cAE9C,WAAW,CAAC,QAAQ,EAAE,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;CAmCnH"}
1
+ {"version":3,"file":"AssetService.d.ts","sourceRoot":"","sources":["../src/AssetService.ts"],"names":[],"mappings":"AAAA,OA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AAU,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,KAAK,IAAI,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;cA+BjG,WAAW,CAAC,QAAQ,EAAE,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAgChH,SAAS,CAAC,QAAQ,CAAC,eAAe,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;CAClE"}
@@ -1,4 +1,4 @@
1
- import { DefaultObservableValue, Errors, panic, Progress, RuntimeNotifier } from "@opendaw/lib-std";
1
+ import { DefaultObservableValue, Errors, isInstanceOf, isNotUndefined, panic, Progress, RuntimeNotifier, UUID } from "@opendaw/lib-std";
2
2
  import { Files } from "@opendaw/lib-dom";
3
3
  import { Promises } from "@opendaw/lib-runtime";
4
4
  export class AssetService {
@@ -6,6 +6,51 @@ export class AssetService {
6
6
  constructor(onUpdate) {
7
7
  this.onUpdate = onUpdate;
8
8
  }
9
+ async browse(multiple) {
10
+ return this.browseFiles(multiple, this.filePickerOptions);
11
+ }
12
+ async replaceMissingFiles(boxGraph, manager) {
13
+ const available = await this.collectAllFiles();
14
+ const boxes = boxGraph.boxes().filter(box => isInstanceOf(box, this.boxType));
15
+ if (boxes.length === 0) {
16
+ return;
17
+ }
18
+ for (const box of boxes) {
19
+ const uuid = box.address.uuid;
20
+ const uuidAsString = UUID.toString(uuid);
21
+ if (isNotUndefined(available.find(({ uuid }) => uuid === uuidAsString))) {
22
+ continue;
23
+ }
24
+ const approved = await RuntimeNotifier.approve({
25
+ headline: "Missing Asset",
26
+ message: `Could not find ${this.nameSingular} '${box.fileName.getValue()}'`,
27
+ cancelText: "Ignore",
28
+ approveText: "Browse"
29
+ });
30
+ if (!approved) {
31
+ continue;
32
+ }
33
+ const { error, status, value: files } = await Promises.tryCatch(Files.open({ ...this.filePickerOptions, multiple: false }));
34
+ if (status === "rejected") {
35
+ if (Errors.isAbort(error)) {
36
+ return;
37
+ }
38
+ else {
39
+ return panic(String(error));
40
+ }
41
+ }
42
+ if (files.length === 0) {
43
+ return;
44
+ }
45
+ const arrayBuffer = await files[0].arrayBuffer();
46
+ const asset = await this.importFile({ uuid, arrayBuffer, progressHandler: Progress.Empty });
47
+ await RuntimeNotifier.info({
48
+ headline: "Replaced Asset",
49
+ message: `${asset.name} has been replaced`
50
+ });
51
+ manager.invalidate(uuid);
52
+ }
53
+ }
9
54
  async browseFiles(multiple, filePickerSettings) {
10
55
  const { error, status, value: files } = await Promises.tryCatch(Files.open({ ...filePickerSettings, multiple }));
11
56
  if (status === "rejected") {
@@ -1,8 +1,8 @@
1
1
  import { int, MutableObservableValue, Nullable, ObservableValue, Observer, Subscription, UUID } from "@opendaw/lib-std";
2
2
  import { ppqn } from "@opendaw/lib-dsp";
3
3
  import { ClipNotification, ExportStemsConfiguration, NoteSignal, ProcessorOptions } from "@opendaw/studio-adapters";
4
- import { Project } from "./project/Project";
5
4
  import { Engine } from "./Engine";
5
+ import { Project } from "./project";
6
6
  export declare class EngineWorklet extends AudioWorkletNode implements Engine {
7
7
  #private;
8
8
  static ID: int;
@@ -1 +1 @@
1
- {"version":3,"file":"EngineWorklet.d.ts","sourceRoot":"","sources":["../src/EngineWorklet.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,GAAG,EACH,sBAAsB,EAEtB,QAAQ,EACR,eAAe,EACf,QAAQ,EAER,YAAY,EAGZ,IAAI,EACP,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAC,IAAI,EAAC,MAAM,kBAAkB,CAAA;AAIrC,OAAO,EAEH,gBAAgB,EAOhB,wBAAwB,EACxB,UAAU,EACV,gBAAgB,EACnB,MAAM,0BAA0B,CAAA;AAEjC,OAAO,EAAC,OAAO,EAAC,MAAM,mBAAmB,CAAA;AACzC,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAA;AAG/B,qBAAa,aAAc,SAAQ,gBAAiB,YAAW,MAAM;;IACj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gBAAgB,CAAC,GAAG,YAAY;IAQ7E,SAAS,IAAI,IAAI;CAIpB"}
@@ -9,7 +9,7 @@ export class CaptureDevices {
9
9
  constructor(project) {
10
10
  this.#project = project;
11
11
  this.#captures = UUID.newSet(unit => unit.uuid);
12
- this.#subscription = this.#project.rootBox.audioUnits.pointerHub.catchupAndSubscribeTransactual({
12
+ this.#subscription = this.#project.rootBox.audioUnits.pointerHub.catchupAndSubscribe({
13
13
  onAdd: ({ box }) => {
14
14
  const audioUnitBox = asInstanceOf(box, AudioUnitBox);
15
15
  const capture = audioUnitBox.capture.targetVertex
@@ -1,10 +1,14 @@
1
1
  import { CloudService } from "./CloudService";
2
2
  import { CloudHandler } from "./CloudHandler";
3
+ type ClientIds = {
4
+ Dropbox: string;
5
+ GoogleDrive: string;
6
+ };
3
7
  export declare class CloudAuthManager {
4
8
  #private;
5
- static create(): CloudAuthManager;
6
- readonly id: number;
9
+ static create(clientIds: ClientIds): CloudAuthManager;
7
10
  private constructor();
8
11
  getHandler(service: CloudService): Promise<CloudHandler>;
9
12
  }
13
+ export {};
10
14
  //# sourceMappingURL=CloudAuthManager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CloudAuthManager.d.ts","sourceRoot":"","sources":["../../src/cloud/CloudAuthManager.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAA;AAK3C,qBAAa,gBAAgB;;IACzB,MAAM,CAAC,MAAM,IAAI,gBAAgB;IAqBjC,QAAQ,CAAC,EAAE,SAAyB;IAIpC,OAAO;IAED,UAAU,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;CAuLjE"}
1
+ {"version":3,"file":"CloudAuthManager.d.ts","sourceRoot":"","sources":["../../src/cloud/CloudAuthManager.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAA;AAI3C,KAAK,SAAS,GAAG;IACb,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,EAAE,MAAM,CAAA;CACtB,CAAA;AAED,qBAAa,gBAAgB;;IACzB,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,SAAS,GAAG,gBAAgB;IAuBrD,OAAO;IAED,UAAU,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;CAwLjE"}
@@ -2,9 +2,8 @@ import { asDefined, Errors, isDefined, isNull, Maps, panic, RuntimeNotifier, Tim
2
2
  import { Promises } from "@opendaw/lib-runtime";
3
3
  import { DropboxHandler } from "./DropboxHandler";
4
4
  import { GoogleDriveHandler } from "./GoogleDriveHandler";
5
- import { VITE_DROPBOX_CLIENT_ID, VITE_GOOGLE_CLIENT_ID } from "../env";
6
5
  export class CloudAuthManager {
7
- static create() { return new CloudAuthManager(); }
6
+ static create(clientIds) { return new CloudAuthManager(clientIds); }
8
7
  static async #createCodes() {
9
8
  const array = new Uint8Array(32);
10
9
  crypto.getRandomValues(array);
@@ -21,10 +20,9 @@ export class CloudAuthManager {
21
20
  .replace(/=/g, "");
22
21
  return { codeVerifier, codeChallenge };
23
22
  }
24
- static #ID = 0;
25
- id = CloudAuthManager.#ID++;
23
+ #clientIds;
26
24
  #memoizedHandlers = new Map();
27
- constructor() { }
25
+ constructor(clientIds) { this.#clientIds = clientIds; }
28
26
  async getHandler(service) {
29
27
  const memo = Maps.createIfAbsent(this.#memoizedHandlers, service, service => {
30
28
  switch (service) {
@@ -39,10 +37,12 @@ export class CloudAuthManager {
39
37
  }
40
38
  });
41
39
  const handler = await memo();
42
- const { status } = await Promises.tryCatch(handler.alive());
40
+ const { status, error } = await Promises.tryCatch(handler.alive());
43
41
  if (status === "rejected") {
42
+ // Do not auto-retry here to avoid reopening the OAuth popup in a loop.
43
+ // Instead, clear the memoized handler and surface the error to the caller.
44
44
  this.#memoizedHandlers.delete(service);
45
- return this.getHandler(service);
45
+ return Promise.reject(error);
46
46
  }
47
47
  console.debug(`Handler for '${service}' is alive`);
48
48
  return handler;
@@ -75,7 +75,7 @@ export class CloudAuthManager {
75
75
  let handled = false;
76
76
  channel.onmessage = async (event) => {
77
77
  const data = asDefined(event.data, "No data");
78
- console.debug("[CloudAuth] Received via BroadcastChannel:", this.id, data);
78
+ console.debug("[CloudAuth] Received via BroadcastChannel");
79
79
  if (data.type === "auth-callback" && isDefined(data.code)) {
80
80
  if (handled) {
81
81
  return;
@@ -99,7 +99,7 @@ export class CloudAuthManager {
99
99
  if (!response.ok) {
100
100
  const errorText = await response.text();
101
101
  console.error("[CloudAuth] Token exchange error:", errorText);
102
- return panic(`Token exchange failed: ${response.statusText}`);
102
+ return panic(`Token exchange failed: ${errorText}`);
103
103
  }
104
104
  const dataJson = await response.json();
105
105
  const accessToken = dataJson.access_token;
@@ -131,7 +131,7 @@ export class CloudAuthManager {
131
131
  async #oauthDropbox() {
132
132
  return this.#oauthPkceFlow({
133
133
  service: "dropbox",
134
- clientId: asDefined(VITE_DROPBOX_CLIENT_ID, "Missing VITE_DROPBOX_CLIENT_ID"),
134
+ clientId: this.#clientIds.Dropbox,
135
135
  authUrlBase: "https://www.dropbox.com/oauth2/authorize",
136
136
  tokenUrl: "https://api.dropboxapi.com/oauth2/token",
137
137
  scope: "", // Dropbox scope is optional
@@ -141,7 +141,7 @@ export class CloudAuthManager {
141
141
  });
142
142
  }
143
143
  async #oauthGoogle() {
144
- const clientId = asDefined(VITE_GOOGLE_CLIENT_ID, "Missing VITE_GOOGLE_CLIENT_ID");
144
+ const clientId = this.#clientIds.GoogleDrive;
145
145
  const scope = "https://www.googleapis.com/auth/drive.appdata";
146
146
  const redirectUri = `${location.origin}/auth-callback.html`;
147
147
  const params = new URLSearchParams({
@@ -167,7 +167,7 @@ export class CloudAuthManager {
167
167
  });
168
168
  channel.onmessage = async (event) => {
169
169
  const data = asDefined(event.data, "No data");
170
- console.debug("[CloudAuth] Received via BroadcastChannel:", this.id, data);
170
+ console.debug("[CloudAuth] Received via BroadcastChannel:", data);
171
171
  if (data.type === "auth-callback" && isDefined(data.access_token)) {
172
172
  try {
173
173
  const accessToken = data.access_token;
@@ -3,7 +3,7 @@ import { Browser } from "@opendaw/lib-dom";
3
3
  import { Promises } from "@opendaw/lib-runtime";
4
4
  import { CloudBackupSamples } from "./CloudBackupSamples";
5
5
  import { CloudBackupProjects } from "./CloudBackupProjects";
6
- import { CloudBackupSoundfonts } from "./CloudBackupSoundfont";
6
+ import { CloudBackupSoundfonts } from "./CloudBackupSoundfonts";
7
7
  import { ProjectSignals } from "../project";
8
8
  export var CloudBackup;
9
9
  (function (CloudBackup) {
@@ -10,4 +10,4 @@ export declare class CloudBackupSoundfonts {
10
10
  static start(cloudHandler: CloudHandler, progress: Progress.Handler, log: Procedure<string>): Promise<void>;
11
11
  private constructor();
12
12
  }
13
- //# sourceMappingURL=CloudBackupSoundfont.d.ts.map
13
+ //# sourceMappingURL=CloudBackupSoundfonts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CloudBackupSoundfonts.d.ts","sourceRoot":"","sources":["../../src/cloud/CloudBackupSoundfonts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,SAAS,EAAE,QAAQ,EAAmB,IAAI,EAAC,MAAM,kBAAkB,CAAA;AAElG,OAAO,EAAC,SAAS,EAAC,MAAM,0BAA0B,CAAA;AAClD,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAA;AAK3C,qBAAa,qBAAqB;;IAC9B,MAAM,CAAC,QAAQ,CAAC,UAAU,gBAAe;IACzC,MAAM,CAAC,QAAQ,CAAC,iBAAiB,SAAkC;IACnE,MAAM,CAAC,QAAQ,CAAC,kBAAkB,GAAI,aAAW,SAAS,EAAE,aAAW,SAAS,aAAY;IAE5F,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,GAAG,MAAM;WAE5B,KAAK,CAAC,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,QAAQ,CAAC,OAAO,EAC1B,GAAG,EAAE,SAAS,CAAC,MAAM,CAAC;IAgBzC,OAAO;CA2GV"}
@@ -104,7 +104,7 @@ export class CloudBackupSoundfonts {
104
104
  await SoundfontStorage.get().save({
105
105
  uuid: UUID.parse(soundfont.uuid),
106
106
  file: buffer,
107
- meta: soundfont
107
+ meta: { ...soundfont, size: buffer.byteLength }
108
108
  });
109
109
  return soundfont;
110
110
  }));