@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.js CHANGED
@@ -89,17 +89,21 @@ module.exports = __toCommonJS(tone_exports);
89
89
 
90
90
  // src/hooks/useAudioTracks.ts
91
91
  var import_react = require("react");
92
- var import_core = require("@waveform-playlist/core");
93
92
  var Tone = __toESM(require("tone"));
94
- function buildTrackFromConfig(config, index, audioBuffer, stableIds, contextSampleRate = 48e3) {
93
+
94
+ // src/hooks/buildTrackFromConfig.ts
95
+ var import_core = require("@waveform-playlist/core");
96
+ function buildTrackFromConfig(config, index, audioBuffer, stableIds, contextSampleRate = 48e3, options = {}) {
95
97
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
96
98
  const buffer = audioBuffer != null ? audioBuffer : config.audioBuffer;
97
99
  const sampleRate = (_c = (_b = buffer == null ? void 0 : buffer.sampleRate) != null ? _b : (_a = config.waveformData) == null ? void 0 : _a.sample_rate) != null ? _c : contextSampleRate;
98
100
  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;
99
101
  if (sourceDuration === void 0) {
100
- console.warn(
101
- `[waveform-playlist] Track ${index + 1} ("${(_h = config.name) != null ? _h : "unnamed"}"): Cannot create track \u2014 provide duration, audioBuffer, or waveformData with duration.`
102
- );
102
+ if (!options.suppressMissingDurationWarning) {
103
+ console.warn(
104
+ `[waveform-playlist] Track ${index + 1} ("${(_h = config.name) != null ? _h : "unnamed"}"): Cannot create track \u2014 provide duration, audioBuffer, or waveformData with duration.`
105
+ );
106
+ }
103
107
  return null;
104
108
  }
105
109
  const clip = (0, import_core.createClipFromSeconds)({
@@ -143,6 +147,8 @@ function buildTrackFromConfig(config, index, audioBuffer, stableIds, contextSamp
143
147
  }
144
148
  return track;
145
149
  }
150
+
151
+ // src/hooks/useAudioTracks.ts
146
152
  function useAudioTracks(configs, options = {}) {
147
153
  const { immediate = false, progressive = false } = options;
148
154
  const isImmediate = immediate || progressive;
@@ -157,12 +163,14 @@ function useAudioTracks(configs, options = {}) {
157
163
  if (!isImmediate) return null;
158
164
  const result = [];
159
165
  for (let i = 0; i < configs.length; i++) {
166
+ const pendingDecode = !loadedBuffers.has(i) && !configs[i].audioBuffer && configs[i].src != null;
160
167
  const track = buildTrackFromConfig(
161
168
  configs[i],
162
169
  i,
163
170
  loadedBuffers.get(i),
164
171
  stableIdsRef.current,
165
- contextSampleRateRef.current
172
+ contextSampleRateRef.current,
173
+ { suppressMissingDurationWarning: pendingDecode }
166
174
  );
167
175
  if (track) result.push(track);
168
176
  }