@unseenco/theatre-core 0.3.0 → 0.4.1

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/index.d.ts CHANGED
@@ -210,12 +210,12 @@ type HistoricPositionalSequence = {
210
210
  }>;
211
211
  };
212
212
  /**
213
- * Currently just {@link BasicKeyframedTrack}.
213
+ * Discriminated union of sequence track kinds.
214
214
  *
215
215
  * Future: Other types of tracks can be added in, such as `MixedTrack` which would
216
216
  * look like `[keyframes, expression, moreKeyframes, anotherExpression, …]`.
217
217
  */
218
- type TrackData = BasicKeyframedTrack;
218
+ type TrackData = BasicKeyframedTrack | GsapClipTrack;
219
219
  type KeyframeType = 'bezier' | 'hold';
220
220
  type Keyframe = {
221
221
  id: KeyframeId;
@@ -247,6 +247,52 @@ type BasicKeyframedTrack = TrackDataCommon<'BasicKeyframedTrack'> & {
247
247
  */
248
248
  keyframes: Keyframe[];
249
249
  };
250
+ /**
251
+ * A GSAP tween segment on the Theatre sequence timeline, bridged at runtime
252
+ * via `@unseenco/theatre-gsap`.
253
+ */
254
+ type GsapTimelineChildClip = {
255
+ /** Stable id for this child tween within the parent timeline clip. */
256
+ childId: string;
257
+ /** Display label in the sequence editor. */
258
+ label: string;
259
+ /** Start time in seconds on the parent GSAP timeline (at progress 0). */
260
+ localStart: number;
261
+ /** Duration in seconds on the parent GSAP timeline. */
262
+ localDuration: number;
263
+ };
264
+ /** Timing snapshot captured when a GSAP clip is first added to the sequence. */
265
+ type GsapClipBaselineTiming = {
266
+ duration: number;
267
+ timelineSpan?: number;
268
+ timelineChildren?: GsapTimelineChildClip[];
269
+ };
270
+ type GsapClipTrack = TrackDataCommon<'GsapClipTrack'> & {
271
+ /**
272
+ * Registry animation id for this clip. Defaults to the sanitised GSAP sheet
273
+ * object key (e.g. `GSAP / Panel show`) when set via Studio; may differ if
274
+ * {@link registerGsapAnimation} was called with an explicit `id` override.
275
+ */
276
+ gsapAnimationId: string;
277
+ /** Sequence position where the clip starts (same units as the sequence). */
278
+ start: number;
279
+ /** Clip length on the sequence timeline. Must be &gt; 0. */
280
+ duration: number;
281
+ /**
282
+ * One-level child tweens when the registered animation is a GSAP timeline.
283
+ * Omitted for single tweens.
284
+ */
285
+ timelineChildren?: GsapTimelineChildClip[];
286
+ /**
287
+ * Parent timeline total duration in seconds when {@link timelineChildren} was
288
+ * last synced (used to map child local times into sequence space).
289
+ */
290
+ timelineSpan?: number;
291
+ /**
292
+ * Default clip timing before Studio edits; used by "Reset to original state".
293
+ */
294
+ baselineTiming?: GsapClipBaselineTiming;
295
+ };
250
296
 
251
297
  type SequenceVariantId = string;
252
298
 
@@ -1144,6 +1190,16 @@ interface ISequence {
1144
1190
  * ```
1145
1191
  */
1146
1192
  __experimental_getKeyframes(prop: Pointer<{}>): Keyframe[];
1193
+ /**
1194
+ * Returns GSAP clip tracks on the active sequence variant for all objects.
1195
+ *
1196
+ * @experimental
1197
+ */
1198
+ __experimental_getGsapClips(): Array<{
1199
+ objectKey: string;
1200
+ trackId: SequenceTrackId;
1201
+ clip: GsapClipTrack;
1202
+ }>;
1147
1203
  /**
1148
1204
  * Attaches an audio source to the sequence. Playing the sequence automatically
1149
1205
  * plays the audio source and their times are kept in sync.
package/dist/index.js CHANGED
@@ -985,6 +985,8 @@ function interpolationTripleAtPosition(ctx, trackP, timeD) {
985
985
  return (0, import_theatre_dataverse2.prism)(() => void 0);
986
986
  } else if (track.type === "BasicKeyframedTrack") {
987
987
  return _forKeyframedTrack(ctx, track, timeD);
988
+ } else if (track.type === "GsapClipTrack") {
989
+ return (0, import_theatre_dataverse2.prism)(() => void 0);
988
990
  } else {
989
991
  ctx.logger.error("Track type not yet supported.");
990
992
  return (0, import_theatre_dataverse2.prism)(() => void 0);
@@ -4002,9 +4004,13 @@ function getOrphanedTopLevelPropPathEncodings(config, sheetState, objectKey) {
4002
4004
  }
4003
4005
  function stripTransientPropsFromObjectInSheetState(sheetState, objectKey, prefixes) {
4004
4006
  if (prefixes.size === 0) return;
4005
- const staticOverrides = sheetState.staticOverrides.byObject[objectKey];
4006
- if (staticOverrides) {
4007
- sheetState.staticOverrides.byObject[objectKey] = stripTransientPathsFromSerializableMap(staticOverrides, prefixes);
4007
+ const byObject = sheetState.staticOverrides?.byObject;
4008
+ const staticOverrides = byObject?.[objectKey];
4009
+ if (staticOverrides && byObject) {
4010
+ byObject[objectKey] = stripTransientPathsFromSerializableMap(
4011
+ staticOverrides,
4012
+ prefixes
4013
+ );
4008
4014
  }
4009
4015
  if (sheetState.staticOverridesByVariant) {
4010
4016
  for (const variantOverrides of Object.values(
@@ -6098,6 +6104,9 @@ var TheatreSequence = class {
6098
6104
  __experimental_getKeyframes(prop) {
6099
6105
  return privateAPI(this).getKeyframesOfSimpleProp(prop);
6100
6106
  }
6107
+ __experimental_getGsapClips() {
6108
+ return privateAPI(this).getGsapClips();
6109
+ }
6101
6110
  async attachAudio(args) {
6102
6111
  const { audioContext, destinationNode, decodedBuffer, gainNode } = await resolveAudioBuffer(args);
6103
6112
  const playbackController = new AudioPlaybackController(
@@ -6203,6 +6212,14 @@ async function resolveAudioBuffer(args) {
6203
6212
  };
6204
6213
  }
6205
6214
 
6215
+ // shared/src/sequence/trackData.ts
6216
+ function isBasicKeyframedTrack(track) {
6217
+ return track.type === "BasicKeyframedTrack";
6218
+ }
6219
+ function isGsapClipTrack(track) {
6220
+ return track.type === "GsapClipTrack";
6221
+ }
6222
+
6206
6223
  // core/src/sequences/Sequence.ts
6207
6224
  var possibleDirections = [
6208
6225
  "normal",
@@ -6303,11 +6320,57 @@ var Sequence = class {
6303
6320
  return [];
6304
6321
  }
6305
6322
  const track = trackData[id];
6306
- if (!track) {
6323
+ if (!track || !isBasicKeyframedTrack(track)) {
6307
6324
  return [];
6308
6325
  }
6309
6326
  return track.keyframes;
6310
6327
  }
6328
+ /**
6329
+ * @internal Used by the public sequence API.
6330
+ */
6331
+ getGsapClipsForObject(objectKey) {
6332
+ const sheetState = (0, import_theatre_dataverse14.val)(
6333
+ this._project.pointers.historic.sheetsById[this._sheet.address.sheetId]
6334
+ );
6335
+ const tracksOfObject = getSequenceStateFromSheet(
6336
+ sheetState,
6337
+ this._sequenceVariant
6338
+ )?.tracksByObject[objectKey];
6339
+ if (!tracksOfObject) return [];
6340
+ const result = [];
6341
+ for (const [trackId, track] of Object.entries(tracksOfObject.trackData)) {
6342
+ if (track && isGsapClipTrack(track)) {
6343
+ result.push({ trackId, clip: track });
6344
+ }
6345
+ }
6346
+ return result.sort((a2, b2) => a2.clip.start - b2.clip.start);
6347
+ }
6348
+ getGsapClips() {
6349
+ const sheetState = (0, import_theatre_dataverse14.val)(
6350
+ this._project.pointers.historic.sheetsById[this._sheet.address.sheetId]
6351
+ );
6352
+ const sequenceState = getSequenceStateFromSheet(
6353
+ sheetState,
6354
+ this._sequenceVariant
6355
+ );
6356
+ if (!sequenceState) return [];
6357
+ const result = [];
6358
+ for (const [objectKey, tracksOfObject] of Object.entries(
6359
+ sequenceState.tracksByObject
6360
+ )) {
6361
+ if (!tracksOfObject) continue;
6362
+ for (const [trackId, track] of Object.entries(tracksOfObject.trackData)) {
6363
+ if (track && isGsapClipTrack(track)) {
6364
+ result.push({
6365
+ objectKey,
6366
+ trackId,
6367
+ clip: track
6368
+ });
6369
+ }
6370
+ }
6371
+ }
6372
+ return result.sort((a2, b2) => a2.clip.start - b2.clip.start);
6373
+ }
6311
6374
  get positionFormatter() {
6312
6375
  return this._positionFormatterD.getValue();
6313
6376
  }
@@ -8515,7 +8578,7 @@ var CoreBundle = class {
8515
8578
  return "Theatre_CoreBundle";
8516
8579
  }
8517
8580
  get version() {
8518
- return "0.3.0";
8581
+ return "0.4.1";
8519
8582
  }
8520
8583
  getBitsForStudio(studio, callback) {
8521
8584
  if (this._studio) {