@waveform-playlist/engine 14.0.0-next.2 → 14.0.0-next.3
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/README.md +3 -3
- package/dist/index.d.mts +14 -3
- package/dist/index.d.ts +14 -3
- package/dist/index.js +16 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -153,10 +153,10 @@ import { isLoadingClip as isLoadingClip5 } from "@waveform-playlist/core";
|
|
|
153
153
|
|
|
154
154
|
// src/arrangement/attach.ts
|
|
155
155
|
var ARRANGEMENT_ATTACH_DECODE = /* @__PURE__ */ Symbol.for(
|
|
156
|
-
"@waveform-playlist/engine/arrangement/attach-decode/
|
|
156
|
+
"@waveform-playlist/engine/arrangement/attach-decode/v3"
|
|
157
157
|
);
|
|
158
158
|
var ARRANGEMENT_ATTACH_TIME_BASE = /* @__PURE__ */ Symbol.for(
|
|
159
|
-
"@waveform-playlist/engine/arrangement/time-base/
|
|
159
|
+
"@waveform-playlist/engine/arrangement/time-base/v3"
|
|
160
160
|
);
|
|
161
161
|
function attachPoints(value) {
|
|
162
162
|
return typeof value === "object" && value !== null ? value : {};
|
|
@@ -978,6 +978,15 @@ function duplicateTrackId(trackId) {
|
|
|
978
978
|
var DEFAULT_MIN_DURATION_SECONDS = 0.1;
|
|
979
979
|
var DEFAULT_UNDO_LIMIT = 100;
|
|
980
980
|
var EMPTY_RECORDING = /* @__PURE__ */ new Set();
|
|
981
|
+
function insertIndex(index, length) {
|
|
982
|
+
if (index === void 0) return length;
|
|
983
|
+
if (typeof index !== "number" || !Number.isFinite(index)) {
|
|
984
|
+
throw new TypeError(
|
|
985
|
+
`[waveform-playlist] addTrack: index must be a finite number, got ${String(index)}`
|
|
986
|
+
);
|
|
987
|
+
}
|
|
988
|
+
return Math.max(0, Math.min(Math.trunc(index), length));
|
|
989
|
+
}
|
|
981
990
|
var ArrangementImpl = class {
|
|
982
991
|
constructor(options = {}) {
|
|
983
992
|
this._tracks = [];
|
|
@@ -1208,13 +1217,14 @@ var ArrangementImpl = class {
|
|
|
1208
1217
|
this._tracksVersion++;
|
|
1209
1218
|
this._emit({ type: "set" });
|
|
1210
1219
|
}
|
|
1211
|
-
addTrack(track) {
|
|
1220
|
+
addTrack(track, options) {
|
|
1221
|
+
const index = insertIndex(options?.index, this._tracks.length);
|
|
1212
1222
|
assertClipsOfTrackKind(track);
|
|
1213
1223
|
assertUniqueClipIds(track);
|
|
1214
1224
|
if (this._tracks.some((t) => t.id === track.id)) throw duplicateTrackId(track.id);
|
|
1215
1225
|
this._pushUndoSnapshot();
|
|
1216
1226
|
const enriched = this._ingest(track);
|
|
1217
|
-
this._tracks = [...this._tracks, enriched];
|
|
1227
|
+
this._tracks = [...this._tracks.slice(0, index), enriched, ...this._tracks.slice(index)];
|
|
1218
1228
|
this._mixer = seedMixer(this._mixer, [enriched]);
|
|
1219
1229
|
this._tracksVersion++;
|
|
1220
1230
|
this._emit({ type: "add", trackId: track.id });
|
|
@@ -2071,8 +2081,8 @@ var PlaylistEngine = class {
|
|
|
2071
2081
|
setTracks(tracks) {
|
|
2072
2082
|
this._arrangement.setTracks(tracks);
|
|
2073
2083
|
}
|
|
2074
|
-
addTrack(track) {
|
|
2075
|
-
this._arrangement.addTrack(track);
|
|
2084
|
+
addTrack(track, options) {
|
|
2085
|
+
this._arrangement.addTrack(track, options);
|
|
2076
2086
|
}
|
|
2077
2087
|
removeTrack(trackId) {
|
|
2078
2088
|
this._arrangement.removeTrack(trackId);
|