@unseenco/theatre-gsap 0.4.2 → 0.4.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.
@@ -1,8 +1,2 @@
1
- import type { ISheet } from '@unseenco/theatre-core';
2
- /**
3
- * Drives registered GSAP animations from the sheet sequence playhead.
4
- *
5
- * @returns Disposer — call to detach the bridge.
6
- */
7
- export declare function attachGsapSequenceBridge(sheet: ISheet): () => void;
1
+ export { attachGsapSequenceBridge } from '@unseenco/theatre-core';
8
2
  //# sourceMappingURL=attachGsapSequenceBridge.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"attachGsapSequenceBridge.d.ts","sourceRoot":"","sources":["../src/attachGsapSequenceBridge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,wBAAwB,CAAA;AAMlD;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,IAAI,CAqBlE"}
1
+ {"version":3,"file":"attachGsapSequenceBridge.d.ts","sourceRoot":"","sources":["../src/attachGsapSequenceBridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,wBAAwB,EAAC,MAAM,wBAAwB,CAAA"}
package/dist/index.js CHANGED
@@ -20,7 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var src_exports = {};
22
22
  __export(src_exports, {
23
- attachGsapSequenceBridge: () => attachGsapSequenceBridge,
23
+ attachGsapSequenceBridge: () => import_theatre_core.attachGsapSequenceBridge,
24
24
  configureTheatreGsap: () => configureTheatreGsap,
25
25
  getAnimationEntry: () => getAnimationEntry2,
26
26
  getAnimationEntryById: () => getAnimationEntryById,
@@ -635,129 +635,7 @@ function setConfiguredGsapSheetObjectNamespace(namespace) {
635
635
  g[GSAP_NAMESPACE_STORE_KEY] = namespace.trim();
636
636
  }
637
637
 
638
- // ../../theatre/shared/src/sequence/trackData.ts
639
- function gsapClipEndTime(clip) {
640
- return clip.start + clip.duration;
641
- }
642
- function gsapClipSyncProgress(sequencePosition, clip) {
643
- if (clip.duration <= 0)
644
- return 0;
645
- if (sequencePosition < clip.start)
646
- return 0;
647
- const clipEnd = gsapClipEndTime(clip);
648
- if (sequencePosition >= clipEnd - 1e-5)
649
- return 1;
650
- const raw = (sequencePosition - clip.start) / clip.duration;
651
- if (raw <= 0)
652
- return 0;
653
- if (raw >= 1)
654
- return 1;
655
- return raw;
656
- }
657
-
658
- // ../../theatre/shared/src/gsap/applyTimelineChildTiming.ts
659
- function applyTimelineChildTimingToGsap(rootAnimation, timelineChildren, childById, onRebuild) {
660
- if (!timelineChildren.length)
661
- return true;
662
- let ok = applyTimelineChildTimingToGsapInner(
663
- rootAnimation,
664
- timelineChildren,
665
- childById
666
- );
667
- if (!ok && onRebuild) {
668
- const rebuilt = onRebuild();
669
- if (rebuilt) {
670
- ok = applyTimelineChildTimingToGsapInner(
671
- rebuilt,
672
- timelineChildren,
673
- childById
674
- );
675
- }
676
- }
677
- return ok;
678
- }
679
- function applyTimelineChildTimingToGsapInner(rootAnimation, timelineChildren, childById) {
680
- if (!childById || timelineChildren.length === 0)
681
- return true;
682
- let ok = true;
683
- for (const childState of timelineChildren) {
684
- const tween = childById.get(childState.childId);
685
- if (!tween)
686
- continue;
687
- try {
688
- const t = tween;
689
- if (typeof t.startTime === "function") {
690
- t.startTime(childState.localStart);
691
- }
692
- if (typeof t.duration === "function") {
693
- t.duration(childState.localDuration);
694
- }
695
- } catch {
696
- ok = false;
697
- }
698
- }
699
- return ok;
700
- }
701
-
702
638
  // ../../theatre/shared/src/gsap/syncGsapClipProgress.ts
703
- function getGsapAnimationTargetKey(animation, fallbackAnimationId) {
704
- const tween = animation;
705
- const targets = tween.targets?.();
706
- if (targets && targets.length > 0) {
707
- return targets[0];
708
- }
709
- return fallbackAnimationId;
710
- }
711
- function syncRegisteredGsapAnimationsForClips(sequencePosition, clips) {
712
- const enriched = [];
713
- for (const clip of clips) {
714
- const entry = getAnimationEntryBySheetAddressKey(
715
- clip.sheetObjectAddressKey,
716
- clip.gsapAnimationId
717
- );
718
- if (!entry?.animation)
719
- continue;
720
- enriched.push({
721
- ...clip,
722
- entry,
723
- targetKey: getGsapAnimationTargetKey(
724
- entry.animation,
725
- clip.gsapAnimationId
726
- )
727
- });
728
- }
729
- const byTarget = /* @__PURE__ */ new Map();
730
- for (const item of enriched) {
731
- const list = byTarget.get(item.targetKey) ?? [];
732
- list.push(item);
733
- byTarget.set(item.targetKey, list);
734
- }
735
- for (const group of byTarget.values()) {
736
- const sorted = [...group].sort((a, b) => a.start - b.start);
737
- for (const clip of sorted) {
738
- const progress = gsapClipSyncProgress(sequencePosition, clip);
739
- const entry = clip.entry;
740
- const animation = entry.animation;
741
- if (entry.kind === "timeline" && clip.timelineChildren && clip.timelineChildren.length > 0) {
742
- applyTimelineChildTimingToGsap(
743
- entry.animation,
744
- clip.timelineChildren,
745
- entry.timelineChildById,
746
- entry.onRebuildTimeline
747
- );
748
- const span = clip.timelineSpan ?? readGsapTweenTimelineDuration(entry.animation);
749
- const t = progress * Math.max(span, 0.01);
750
- if (typeof animation.time === "function") {
751
- animation.time(t, true);
752
- } else {
753
- animation.progress?.(progress, true);
754
- }
755
- } else {
756
- animation.progress?.(progress, true);
757
- }
758
- }
759
- }
760
- }
761
639
  function readGsapTweenTimelineDuration(animation) {
762
640
  const tween = animation;
763
641
  const total = tween.totalDuration?.();
@@ -1464,11 +1342,6 @@ var Stack = class {
1464
1342
  }
1465
1343
  };
1466
1344
 
1467
- // ../dataverse/src/prism/Interface.ts
1468
- function isPrism(d) {
1469
- return !!(d && d.isPrism && d.isPrism === true);
1470
- }
1471
-
1472
1345
  // ../dataverse/src/prism/discoveryMechanism.ts
1473
1346
  function createMechanism() {
1474
1347
  const noop = () => {
@@ -1810,14 +1683,14 @@ var PrismInstance = class {
1810
1683
  getValue() {
1811
1684
  reportResolutionStart(this);
1812
1685
  const state2 = this._state;
1813
- let val2;
1686
+ let val;
1814
1687
  if (state2.hot) {
1815
- val2 = state2.handle.getValue();
1688
+ val = state2.handle.getValue();
1816
1689
  } else {
1817
- val2 = calculateColdPrism(this._fn);
1690
+ val = calculateColdPrism(this._fn);
1818
1691
  }
1819
1692
  reportResolutionEnd(this);
1820
- return val2;
1693
+ return val;
1821
1694
  }
1822
1695
  };
1823
1696
  var HotScope = class _HotScope {
@@ -2220,8 +2093,8 @@ var Atom = class {
2220
2093
  * atom.setByPointer((p) => p.a.b, 2) // atom.get().a.b === 2
2221
2094
  * ```
2222
2095
  */
2223
- setByPointer(pointerOrFn, val2) {
2224
- this.reduceByPointer(pointerOrFn, () => val2);
2096
+ setByPointer(pointerOrFn, val) {
2097
+ this.reduceByPointer(pointerOrFn, () => val);
2225
2098
  }
2226
2099
  _checkUpdates(scope2, oldState, newState) {
2227
2100
  if (oldState === newState)
@@ -2268,38 +2141,6 @@ var Atom = class {
2268
2141
  }
2269
2142
  };
2270
2143
 
2271
- // ../dataverse/src/pointerToPrism.ts
2272
- var identifyPrismWeakMap = /* @__PURE__ */ new WeakMap();
2273
- function isPointerToPrismProvider(val2) {
2274
- return typeof val2 === "object" && val2 !== null && val2["$$isPointerToPrismProvider"] === true;
2275
- }
2276
- var pointerToPrism = (pointer2) => {
2277
- const meta = getPointerMeta(pointer2);
2278
- let prismInstance = identifyPrismWeakMap.get(meta);
2279
- if (!prismInstance) {
2280
- const root2 = meta.root;
2281
- if (!isPointerToPrismProvider(root2)) {
2282
- throw new Error(
2283
- `Cannot run pointerToPrism() on a pointer whose root is not an PointerToPrismProvider`
2284
- );
2285
- }
2286
- prismInstance = root2.pointerToPrism(pointer2);
2287
- identifyPrismWeakMap.set(meta, prismInstance);
2288
- }
2289
- return prismInstance;
2290
- };
2291
-
2292
- // ../dataverse/src/val.ts
2293
- var val = (input) => {
2294
- if (isPointer(input)) {
2295
- return pointerToPrism(input).getValue();
2296
- } else if (isPrism(input)) {
2297
- return input.getValue();
2298
- } else {
2299
- return input;
2300
- }
2301
- };
2302
-
2303
2144
  // ../../theatre/shared/src/gsap/gsapStudioRegistryRevision.ts
2304
2145
  var revisionAtom = new Atom(0);
2305
2146
  function bumpGsapStudioRegistryRevision() {
@@ -2377,9 +2218,6 @@ function getAnimationEntry(sheetObject, animationId) {
2377
2218
  function getAnimationEntryForSheetObject(sheetObject) {
2378
2219
  return getAnimationEntry(sheetObject);
2379
2220
  }
2380
- function getAnimationEntryBySheetAddressKey(sheetObjectAddressKey2, animationId) {
2381
- return getStore2().bySheetAddress.get(sheetObjectAddressKey2)?.get(animationId);
2382
- }
2383
2221
  function listAnimationEntries() {
2384
2222
  const entries = [];
2385
2223
  for (const byAnim of getStore2().bySheetAddress.values()) {
@@ -2488,55 +2326,5 @@ function registerGsapAnimation(animation, sheet, options) {
2488
2326
  }
2489
2327
 
2490
2328
  // src/attachGsapSequenceBridge.ts
2491
- var import_privateAPIs2 = require("@unseenco/theatre-core/privateAPIs");
2492
-
2493
- // ../../theatre/shared/src/gsap/syncGsapClipsAtSequencePosition.ts
2494
- function syncGsapClipsAtSequencePosition(position, clips) {
2495
- syncRegisteredGsapAnimationsForClips(
2496
- position,
2497
- clips
2498
- );
2499
- }
2500
-
2501
- // ../../theatre/shared/src/gsap/subscribeGsapClipSyncAtPlayhead.ts
2502
- function subscribeGsapClipSyncAtPlayhead(source2) {
2503
- const positionPointer = source2.pointer.position;
2504
- const positionPrism = pointerToPrism(positionPointer);
2505
- const clipsPrism = prism_default(() => source2.getGsapClipTimings());
2506
- const syncNow = () => {
2507
- const clips = clipsPrism.getValue();
2508
- if (clips.length === 0)
2509
- return;
2510
- syncGsapClipsAtSequencePosition(val(positionPointer), clips);
2511
- };
2512
- const untapPosition = positionPrism.onStale(syncNow);
2513
- const untapClips = clipsPrism.onStale(syncNow);
2514
- syncNow();
2515
- return () => {
2516
- untapPosition();
2517
- untapClips();
2518
- };
2519
- }
2520
-
2521
- // src/attachGsapSequenceBridge.ts
2522
- function attachGsapSequenceBridge(sheet) {
2523
- const sequence = sheet.sequence;
2524
- const sheetAddress = (0, import_privateAPIs2.privateAPI)(sheet).address;
2525
- return subscribeGsapClipSyncAtPlayhead({
2526
- pointer: sequence.pointer,
2527
- getGsapClipTimings: () => sequence.__experimental_getGsapClips().map(({ objectKey, clip }) => ({
2528
- sheetObjectAddressKey: sheetObjectAddressKeyFromParts({
2529
- projectId: sheetAddress.projectId,
2530
- sheetId: sheetAddress.sheetId,
2531
- sheetInstanceId: sheetAddress.sheetInstanceId,
2532
- objectKey
2533
- }),
2534
- gsapAnimationId: clip.gsapAnimationId,
2535
- start: clip.start,
2536
- duration: clip.duration,
2537
- timelineChildren: clip.timelineChildren,
2538
- timelineSpan: clip.timelineSpan
2539
- }))
2540
- });
2541
- }
2329
+ var import_theatre_core = require("@unseenco/theatre-core");
2542
2330
  //# sourceMappingURL=index.js.map