@opendaw/studio-core 0.0.42 → 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 (46) hide show
  1. package/dist/AssetService.d.ts +28 -0
  2. package/dist/AssetService.d.ts.map +1 -0
  3. package/dist/AssetService.js +94 -0
  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 -11
  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/dawproject/DawProjectService.js +1 -1
  15. package/dist/processors.js +27 -5
  16. package/dist/processors.js.map +4 -4
  17. package/dist/project/Project.d.ts +2 -2
  18. package/dist/project/Project.d.ts.map +1 -1
  19. package/dist/project/Project.js +2 -3
  20. package/dist/samples/OpenSampleAPI.d.ts.map +1 -1
  21. package/dist/samples/OpenSampleAPI.js +5 -3
  22. package/dist/samples/SampleService.d.ts +10 -13
  23. package/dist/samples/SampleService.d.ts.map +1 -1
  24. package/dist/samples/SampleService.js +20 -43
  25. package/dist/samples/SampleStorage.d.ts +1 -1
  26. package/dist/samples/SampleStorage.d.ts.map +1 -1
  27. package/dist/samples/SampleStorage.js +1 -1
  28. package/dist/soundfont/DefaultSoundfontLoader.d.ts +2 -1
  29. package/dist/soundfont/DefaultSoundfontLoader.d.ts.map +1 -1
  30. package/dist/soundfont/DefaultSoundfontLoader.js +14 -4
  31. package/dist/soundfont/DefaultSoundfontLoaderManager.d.ts +2 -1
  32. package/dist/soundfont/DefaultSoundfontLoaderManager.d.ts.map +1 -1
  33. package/dist/soundfont/DefaultSoundfontLoaderManager.js +1 -0
  34. package/dist/soundfont/OpenSoundfontAPI.d.ts.map +1 -1
  35. package/dist/soundfont/OpenSoundfontAPI.js +6 -4
  36. package/dist/soundfont/SoundfontService.d.ts +10 -13
  37. package/dist/soundfont/SoundfontService.d.ts.map +1 -1
  38. package/dist/soundfont/SoundfontService.js +33 -52
  39. package/dist/workers-main.js +2 -2
  40. package/dist/workers-main.js.map +3 -3
  41. package/dist/ysync/YService.d.ts.map +1 -1
  42. package/dist/ysync/YService.js +4 -3
  43. package/dist/ysync/YSync.d.ts.map +1 -1
  44. package/dist/ysync/YSync.js +79 -51
  45. package/package.json +17 -16
  46. package/dist/cloud/CloudBackupSoundfont.d.ts.map +0 -1
@@ -0,0 +1,28 @@
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";
5
+ export declare namespace AssetService {
6
+ type ImportArgs = {
7
+ uuid?: UUID.Bytes;
8
+ name?: string;
9
+ arrayBuffer: ArrayBuffer;
10
+ progressHandler?: Progress.Handler;
11
+ };
12
+ }
13
+ export declare abstract class AssetService<T extends Sample | Soundfont> {
14
+ protected readonly onUpdate: Procedure<T>;
15
+ protected abstract readonly nameSingular: string;
16
+ protected abstract readonly namePlural: string;
17
+ protected abstract readonly boxType: Class<AudioFileBox | SoundfontFileBox>;
18
+ protected abstract readonly filePickerOptions: FilePickerOptions;
19
+ protected constructor(onUpdate: Procedure<T>);
20
+ browse(multiple: boolean): Promise<ReadonlyArray<T>>;
21
+ abstract importFile(args: AssetService.ImportArgs): Promise<T>;
22
+ replaceMissingFiles(boxGraph: BoxGraph, manager: {
23
+ invalidate: (uuid: UUID.Bytes) => void;
24
+ }): Promise<void>;
25
+ protected browseFiles(multiple: boolean, filePickerSettings: FilePickerOptions): Promise<ReadonlyArray<T>>;
26
+ protected abstract collectAllFiles(): Promise<ReadonlyArray<T>>;
27
+ }
28
+ //# sourceMappingURL=AssetService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AssetService.d.ts","sourceRoot":"","sources":["../src/AssetService.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,EAML,SAAS,EACT,QAAQ,EAER,IAAI,EACP,MAAM,kBAAkB,CAAA;AAGzB,OAAO,EAAC,QAAQ,EAAC,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAC,MAAM,EAAE,SAAS,EAAC,MAAM,0BAA0B,CAAA;AAC1D,OAAO,EAAC,YAAY,EAAE,gBAAgB,EAAC,MAAM,uBAAuB,CAAA;AAEpE,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,SAAS,MAAM,GAAG,SAAS;IAMrC,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC;IAL/D,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAChD,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC9C,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,YAAY,GAAG,gBAAgB,CAAC,CAAA;IAC3E,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB,CAAA;IAEhE,SAAS,aAAgC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC;IAEzD,MAAM,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAI1D,QAAQ,CAAC,UAAU,CAAC,IAAI,EAAE,YAAY,CAAC,UAAU,GAAG,OAAO,CAAC,CAAC,CAAC;IAExD,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE;QAAE,UAAU,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"}
@@ -0,0 +1,94 @@
1
+ import { DefaultObservableValue, Errors, isInstanceOf, isNotUndefined, panic, Progress, RuntimeNotifier, UUID } from "@opendaw/lib-std";
2
+ import { Files } from "@opendaw/lib-dom";
3
+ import { Promises } from "@opendaw/lib-runtime";
4
+ export class AssetService {
5
+ onUpdate;
6
+ constructor(onUpdate) {
7
+ this.onUpdate = onUpdate;
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
+ }
54
+ async browseFiles(multiple, filePickerSettings) {
55
+ const { error, status, value: files } = await Promises.tryCatch(Files.open({ ...filePickerSettings, multiple }));
56
+ if (status === "rejected") {
57
+ if (Errors.isAbort(error)) {
58
+ return [];
59
+ }
60
+ else {
61
+ return panic(String(error));
62
+ }
63
+ }
64
+ const progress = new DefaultObservableValue(0.0);
65
+ const dialog = RuntimeNotifier.progress({
66
+ headline: `Importing ${files.length === 1 ? this.nameSingular : this.namePlural}...`, progress
67
+ });
68
+ const progressHandler = Progress.split(value => progress.setValue(value), files.length);
69
+ const rejected = [];
70
+ const imported = [];
71
+ for (const [index, file] of files.entries()) {
72
+ const arrayBuffer = await file.arrayBuffer();
73
+ const { status, value, error } = await Promises.tryCatch(this.importFile({
74
+ name: file.name,
75
+ arrayBuffer: arrayBuffer,
76
+ progressHandler: progressHandler[index]
77
+ }));
78
+ if (status === "rejected") {
79
+ rejected.push(String(error));
80
+ }
81
+ else {
82
+ imported.push(value);
83
+ }
84
+ }
85
+ dialog.terminate();
86
+ if (rejected.length > 0) {
87
+ await RuntimeNotifier.info({
88
+ headline: `${this.nameSingular} Import Issues`,
89
+ message: `${rejected.join(", ")} could not be imported.`
90
+ });
91
+ }
92
+ return imported;
93
+ }
94
+ }
@@ -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;;IACjE,MAAM,CAAC,EAAE,EAAE,GAAG,CAAQ;IAEtB,QAAQ,CAAC,EAAE,SAAqB;gBAqBpB,OAAO,EAAE,gBAAgB,EACzB,OAAO,EAAE,OAAO,EAChB,mBAAmB,CAAC,EAAE,wBAAwB,EAC9C,OAAO,CAAC,EAAE,gBAAgB;IAsHtC,IAAI,IAAI,IAAI;IACZ,IAAI,CAAC,KAAK,GAAE,OAAe,GAAG,IAAI;IAClC,WAAW,CAAC,QAAQ,EAAE,IAAI,GAAG,IAAI;IACjC,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IACtC,aAAa,IAAI,IAAI;IACrB,KAAK,IAAI,IAAI;IAEb,IAAI,S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AAI,iBAAiB,IAAI,sBAAsB,CAAC,MAAM,CAAC,CAAiC;IACxF,IAAI,wBAAwB,IAAI,sBAAsB,CAAC,OAAO,CAAC,CAAwC;IACvG,IAAI,gBAAgB,IAAI,sBAAsB,CAAC,OAAO,CAAC,CAAgC;IACvF,IAAI,WAAW,IAAI,eAAe,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,CAA2B;IAC1F,IAAI,OAAO,IAAI,OAAO,CAAuB;IAE7C,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IACxB,oBAAoB,IAAI,OAAO,CAAC,OAAO,CAAC;IACxC,UAAU,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IACpC,cAAc,CAAC,QAAQ,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,YAAY;IAC5D,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,GAAG,IAAI;IACxC,gBAAgB,CAAC,OAAO,EAAE,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI;IAI1D,gBAAgB,CAAC,QAAQ,EAAE,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI;IAG3D,yBAAyB,CAAC,QAAQ,EAAE,QAAQ,CAAC,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;AAI3C,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"}
@@ -3,7 +3,7 @@ import { Promises } from "@opendaw/lib-runtime";
3
3
  import { DropboxHandler } from "./DropboxHandler";
4
4
  import { GoogleDriveHandler } from "./GoogleDriveHandler";
5
5
  export class CloudAuthManager {
6
- static create() { return new CloudAuthManager(); }
6
+ static create(clientIds) { return new CloudAuthManager(clientIds); }
7
7
  static async #createCodes() {
8
8
  const array = new Uint8Array(32);
9
9
  crypto.getRandomValues(array);
@@ -20,10 +20,9 @@ export class CloudAuthManager {
20
20
  .replace(/=/g, "");
21
21
  return { codeVerifier, codeChallenge };
22
22
  }
23
- static #ID = 0;
24
- id = CloudAuthManager.#ID++;
23
+ #clientIds;
25
24
  #memoizedHandlers = new Map();
26
- constructor() { }
25
+ constructor(clientIds) { this.#clientIds = clientIds; }
27
26
  async getHandler(service) {
28
27
  const memo = Maps.createIfAbsent(this.#memoizedHandlers, service, service => {
29
28
  switch (service) {
@@ -38,10 +37,12 @@ export class CloudAuthManager {
38
37
  }
39
38
  });
40
39
  const handler = await memo();
41
- const { status } = await Promises.tryCatch(handler.alive());
40
+ const { status, error } = await Promises.tryCatch(handler.alive());
42
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.
43
44
  this.#memoizedHandlers.delete(service);
44
- return this.getHandler(service);
45
+ return Promise.reject(error);
45
46
  }
46
47
  console.debug(`Handler for '${service}' is alive`);
47
48
  return handler;
@@ -74,7 +75,7 @@ export class CloudAuthManager {
74
75
  let handled = false;
75
76
  channel.onmessage = async (event) => {
76
77
  const data = asDefined(event.data, "No data");
77
- console.debug("[CloudAuth] Received via BroadcastChannel:", this.id, data);
78
+ console.debug("[CloudAuth] Received via BroadcastChannel");
78
79
  if (data.type === "auth-callback" && isDefined(data.code)) {
79
80
  if (handled) {
80
81
  return;
@@ -98,7 +99,7 @@ export class CloudAuthManager {
98
99
  if (!response.ok) {
99
100
  const errorText = await response.text();
100
101
  console.error("[CloudAuth] Token exchange error:", errorText);
101
- return panic(`Token exchange failed: ${response.statusText}`);
102
+ return panic(`Token exchange failed: ${errorText}`);
102
103
  }
103
104
  const dataJson = await response.json();
104
105
  const accessToken = dataJson.access_token;
@@ -130,7 +131,7 @@ export class CloudAuthManager {
130
131
  async #oauthDropbox() {
131
132
  return this.#oauthPkceFlow({
132
133
  service: "dropbox",
133
- clientId: asDefined(import.meta.env?.VITE_DROPBOX_CLIENT_ID, "Missing VITE_DROPBOX_CLIENT_ID"),
134
+ clientId: this.#clientIds.Dropbox,
134
135
  authUrlBase: "https://www.dropbox.com/oauth2/authorize",
135
136
  tokenUrl: "https://api.dropboxapi.com/oauth2/token",
136
137
  scope: "", // Dropbox scope is optional
@@ -140,7 +141,7 @@ export class CloudAuthManager {
140
141
  });
141
142
  }
142
143
  async #oauthGoogle() {
143
- const clientId = asDefined(import.meta.env?.VITE_GOOGLE_CLIENT_ID, "Missing VITE_GOOGLE_CLIENT_ID");
144
+ const clientId = this.#clientIds.GoogleDrive;
144
145
  const scope = "https://www.googleapis.com/auth/drive.appdata";
145
146
  const redirectUri = `${location.origin}/auth-callback.html`;
146
147
  const params = new URLSearchParams({
@@ -166,7 +167,7 @@ export class CloudAuthManager {
166
167
  });
167
168
  channel.onmessage = async (event) => {
168
169
  const data = asDefined(event.data, "No data");
169
- console.debug("[CloudAuth] Received via BroadcastChannel:", this.id, data);
170
+ console.debug("[CloudAuth] Received via BroadcastChannel:", data);
170
171
  if (data.type === "auth-callback" && isDefined(data.access_token)) {
171
172
  try {
172
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
  }));
@@ -33,7 +33,7 @@ export class DawProjectService {
33
33
  const { skeleton, audioIds } = importResult.value;
34
34
  await Promise.all(audioIds
35
35
  .map(uuid => resources.fromUUID(uuid))
36
- .map(resource => this.sampleService.importSample({
36
+ .map(resource => this.sampleService.importFile({
37
37
  uuid: resource.uuid,
38
38
  name: resource.name,
39
39
  arrayBuffer: resource.buffer