@waveform-playlist/browser 15.3.3 → 15.4.0

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/tone.mjs CHANGED
@@ -40,20 +40,21 @@ var __async = (__this, __arguments, generator) => {
40
40
 
41
41
  // src/hooks/useAudioTracks.ts
42
42
  import { useState, useEffect, useRef, useMemo } from "react";
43
- import {
44
- createTrack,
45
- createClipFromSeconds
46
- } from "@waveform-playlist/core";
47
43
  import * as Tone from "tone";
48
- function buildTrackFromConfig(config, index, audioBuffer, stableIds, contextSampleRate = 48e3) {
44
+
45
+ // src/hooks/buildTrackFromConfig.ts
46
+ import { createTrack, createClipFromSeconds } from "@waveform-playlist/core";
47
+ function buildTrackFromConfig(config, index, audioBuffer, stableIds, contextSampleRate = 48e3, options = {}) {
49
48
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
50
49
  const buffer = audioBuffer != null ? audioBuffer : config.audioBuffer;
51
50
  const sampleRate = (_c = (_b = buffer == null ? void 0 : buffer.sampleRate) != null ? _b : (_a = config.waveformData) == null ? void 0 : _a.sample_rate) != null ? _c : contextSampleRate;
52
51
  const sourceDuration = (_g = (_e = buffer == null ? void 0 : buffer.duration) != null ? _e : (_d = config.waveformData) == null ? void 0 : _d.duration) != null ? _g : config.duration != null ? config.duration + ((_f = config.offset) != null ? _f : 0) : void 0;
53
52
  if (sourceDuration === void 0) {
54
- console.warn(
55
- `[waveform-playlist] Track ${index + 1} ("${(_h = config.name) != null ? _h : "unnamed"}"): Cannot create track \u2014 provide duration, audioBuffer, or waveformData with duration.`
56
- );
53
+ if (!options.suppressMissingDurationWarning) {
54
+ console.warn(
55
+ `[waveform-playlist] Track ${index + 1} ("${(_h = config.name) != null ? _h : "unnamed"}"): Cannot create track \u2014 provide duration, audioBuffer, or waveformData with duration.`
56
+ );
57
+ }
57
58
  return null;
58
59
  }
59
60
  const clip = createClipFromSeconds({
@@ -97,6 +98,8 @@ function buildTrackFromConfig(config, index, audioBuffer, stableIds, contextSamp
97
98
  }
98
99
  return track;
99
100
  }
101
+
102
+ // src/hooks/useAudioTracks.ts
100
103
  function useAudioTracks(configs, options = {}) {
101
104
  const { immediate = false, progressive = false } = options;
102
105
  const isImmediate = immediate || progressive;
@@ -111,12 +114,14 @@ function useAudioTracks(configs, options = {}) {
111
114
  if (!isImmediate) return null;
112
115
  const result = [];
113
116
  for (let i = 0; i < configs.length; i++) {
117
+ const pendingDecode = !loadedBuffers.has(i) && !configs[i].audioBuffer && configs[i].src != null;
114
118
  const track = buildTrackFromConfig(
115
119
  configs[i],
116
120
  i,
117
121
  loadedBuffers.get(i),
118
122
  stableIdsRef.current,
119
- contextSampleRateRef.current
123
+ contextSampleRateRef.current,
124
+ { suppressMissingDurationWarning: pendingDecode }
120
125
  );
121
126
  if (track) result.push(track);
122
127
  }