@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.
- package/dist/attachGsapSequenceBridge.d.ts +1 -7
- package/dist/attachGsapSequenceBridge.d.ts.map +1 -1
- package/dist/index.js +8 -220
- package/dist/index.js.map +4 -4
- package/dist/index.mjs +7 -219
- package/dist/index.mjs.map +4 -4
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -602,129 +602,7 @@ function setConfiguredGsapSheetObjectNamespace(namespace) {
|
|
|
602
602
|
g[GSAP_NAMESPACE_STORE_KEY] = namespace.trim();
|
|
603
603
|
}
|
|
604
604
|
|
|
605
|
-
// ../../theatre/shared/src/sequence/trackData.ts
|
|
606
|
-
function gsapClipEndTime(clip) {
|
|
607
|
-
return clip.start + clip.duration;
|
|
608
|
-
}
|
|
609
|
-
function gsapClipSyncProgress(sequencePosition, clip) {
|
|
610
|
-
if (clip.duration <= 0)
|
|
611
|
-
return 0;
|
|
612
|
-
if (sequencePosition < clip.start)
|
|
613
|
-
return 0;
|
|
614
|
-
const clipEnd = gsapClipEndTime(clip);
|
|
615
|
-
if (sequencePosition >= clipEnd - 1e-5)
|
|
616
|
-
return 1;
|
|
617
|
-
const raw = (sequencePosition - clip.start) / clip.duration;
|
|
618
|
-
if (raw <= 0)
|
|
619
|
-
return 0;
|
|
620
|
-
if (raw >= 1)
|
|
621
|
-
return 1;
|
|
622
|
-
return raw;
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
// ../../theatre/shared/src/gsap/applyTimelineChildTiming.ts
|
|
626
|
-
function applyTimelineChildTimingToGsap(rootAnimation, timelineChildren, childById, onRebuild) {
|
|
627
|
-
if (!timelineChildren.length)
|
|
628
|
-
return true;
|
|
629
|
-
let ok = applyTimelineChildTimingToGsapInner(
|
|
630
|
-
rootAnimation,
|
|
631
|
-
timelineChildren,
|
|
632
|
-
childById
|
|
633
|
-
);
|
|
634
|
-
if (!ok && onRebuild) {
|
|
635
|
-
const rebuilt = onRebuild();
|
|
636
|
-
if (rebuilt) {
|
|
637
|
-
ok = applyTimelineChildTimingToGsapInner(
|
|
638
|
-
rebuilt,
|
|
639
|
-
timelineChildren,
|
|
640
|
-
childById
|
|
641
|
-
);
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
return ok;
|
|
645
|
-
}
|
|
646
|
-
function applyTimelineChildTimingToGsapInner(rootAnimation, timelineChildren, childById) {
|
|
647
|
-
if (!childById || timelineChildren.length === 0)
|
|
648
|
-
return true;
|
|
649
|
-
let ok = true;
|
|
650
|
-
for (const childState of timelineChildren) {
|
|
651
|
-
const tween = childById.get(childState.childId);
|
|
652
|
-
if (!tween)
|
|
653
|
-
continue;
|
|
654
|
-
try {
|
|
655
|
-
const t = tween;
|
|
656
|
-
if (typeof t.startTime === "function") {
|
|
657
|
-
t.startTime(childState.localStart);
|
|
658
|
-
}
|
|
659
|
-
if (typeof t.duration === "function") {
|
|
660
|
-
t.duration(childState.localDuration);
|
|
661
|
-
}
|
|
662
|
-
} catch {
|
|
663
|
-
ok = false;
|
|
664
|
-
}
|
|
665
|
-
}
|
|
666
|
-
return ok;
|
|
667
|
-
}
|
|
668
|
-
|
|
669
605
|
// ../../theatre/shared/src/gsap/syncGsapClipProgress.ts
|
|
670
|
-
function getGsapAnimationTargetKey(animation, fallbackAnimationId) {
|
|
671
|
-
const tween = animation;
|
|
672
|
-
const targets = tween.targets?.();
|
|
673
|
-
if (targets && targets.length > 0) {
|
|
674
|
-
return targets[0];
|
|
675
|
-
}
|
|
676
|
-
return fallbackAnimationId;
|
|
677
|
-
}
|
|
678
|
-
function syncRegisteredGsapAnimationsForClips(sequencePosition, clips) {
|
|
679
|
-
const enriched = [];
|
|
680
|
-
for (const clip of clips) {
|
|
681
|
-
const entry = getAnimationEntryBySheetAddressKey(
|
|
682
|
-
clip.sheetObjectAddressKey,
|
|
683
|
-
clip.gsapAnimationId
|
|
684
|
-
);
|
|
685
|
-
if (!entry?.animation)
|
|
686
|
-
continue;
|
|
687
|
-
enriched.push({
|
|
688
|
-
...clip,
|
|
689
|
-
entry,
|
|
690
|
-
targetKey: getGsapAnimationTargetKey(
|
|
691
|
-
entry.animation,
|
|
692
|
-
clip.gsapAnimationId
|
|
693
|
-
)
|
|
694
|
-
});
|
|
695
|
-
}
|
|
696
|
-
const byTarget = /* @__PURE__ */ new Map();
|
|
697
|
-
for (const item of enriched) {
|
|
698
|
-
const list = byTarget.get(item.targetKey) ?? [];
|
|
699
|
-
list.push(item);
|
|
700
|
-
byTarget.set(item.targetKey, list);
|
|
701
|
-
}
|
|
702
|
-
for (const group of byTarget.values()) {
|
|
703
|
-
const sorted = [...group].sort((a, b) => a.start - b.start);
|
|
704
|
-
for (const clip of sorted) {
|
|
705
|
-
const progress = gsapClipSyncProgress(sequencePosition, clip);
|
|
706
|
-
const entry = clip.entry;
|
|
707
|
-
const animation = entry.animation;
|
|
708
|
-
if (entry.kind === "timeline" && clip.timelineChildren && clip.timelineChildren.length > 0) {
|
|
709
|
-
applyTimelineChildTimingToGsap(
|
|
710
|
-
entry.animation,
|
|
711
|
-
clip.timelineChildren,
|
|
712
|
-
entry.timelineChildById,
|
|
713
|
-
entry.onRebuildTimeline
|
|
714
|
-
);
|
|
715
|
-
const span = clip.timelineSpan ?? readGsapTweenTimelineDuration(entry.animation);
|
|
716
|
-
const t = progress * Math.max(span, 0.01);
|
|
717
|
-
if (typeof animation.time === "function") {
|
|
718
|
-
animation.time(t, true);
|
|
719
|
-
} else {
|
|
720
|
-
animation.progress?.(progress, true);
|
|
721
|
-
}
|
|
722
|
-
} else {
|
|
723
|
-
animation.progress?.(progress, true);
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
}
|
|
728
606
|
function readGsapTweenTimelineDuration(animation) {
|
|
729
607
|
const tween = animation;
|
|
730
608
|
const total = tween.totalDuration?.();
|
|
@@ -1431,11 +1309,6 @@ var Stack = class {
|
|
|
1431
1309
|
}
|
|
1432
1310
|
};
|
|
1433
1311
|
|
|
1434
|
-
// ../dataverse/src/prism/Interface.ts
|
|
1435
|
-
function isPrism(d) {
|
|
1436
|
-
return !!(d && d.isPrism && d.isPrism === true);
|
|
1437
|
-
}
|
|
1438
|
-
|
|
1439
1312
|
// ../dataverse/src/prism/discoveryMechanism.ts
|
|
1440
1313
|
function createMechanism() {
|
|
1441
1314
|
const noop = () => {
|
|
@@ -1777,14 +1650,14 @@ var PrismInstance = class {
|
|
|
1777
1650
|
getValue() {
|
|
1778
1651
|
reportResolutionStart(this);
|
|
1779
1652
|
const state2 = this._state;
|
|
1780
|
-
let
|
|
1653
|
+
let val;
|
|
1781
1654
|
if (state2.hot) {
|
|
1782
|
-
|
|
1655
|
+
val = state2.handle.getValue();
|
|
1783
1656
|
} else {
|
|
1784
|
-
|
|
1657
|
+
val = calculateColdPrism(this._fn);
|
|
1785
1658
|
}
|
|
1786
1659
|
reportResolutionEnd(this);
|
|
1787
|
-
return
|
|
1660
|
+
return val;
|
|
1788
1661
|
}
|
|
1789
1662
|
};
|
|
1790
1663
|
var HotScope = class _HotScope {
|
|
@@ -2187,8 +2060,8 @@ var Atom = class {
|
|
|
2187
2060
|
* atom.setByPointer((p) => p.a.b, 2) // atom.get().a.b === 2
|
|
2188
2061
|
* ```
|
|
2189
2062
|
*/
|
|
2190
|
-
setByPointer(pointerOrFn,
|
|
2191
|
-
this.reduceByPointer(pointerOrFn, () =>
|
|
2063
|
+
setByPointer(pointerOrFn, val) {
|
|
2064
|
+
this.reduceByPointer(pointerOrFn, () => val);
|
|
2192
2065
|
}
|
|
2193
2066
|
_checkUpdates(scope2, oldState, newState) {
|
|
2194
2067
|
if (oldState === newState)
|
|
@@ -2235,38 +2108,6 @@ var Atom = class {
|
|
|
2235
2108
|
}
|
|
2236
2109
|
};
|
|
2237
2110
|
|
|
2238
|
-
// ../dataverse/src/pointerToPrism.ts
|
|
2239
|
-
var identifyPrismWeakMap = /* @__PURE__ */ new WeakMap();
|
|
2240
|
-
function isPointerToPrismProvider(val2) {
|
|
2241
|
-
return typeof val2 === "object" && val2 !== null && val2["$$isPointerToPrismProvider"] === true;
|
|
2242
|
-
}
|
|
2243
|
-
var pointerToPrism = (pointer2) => {
|
|
2244
|
-
const meta = getPointerMeta(pointer2);
|
|
2245
|
-
let prismInstance = identifyPrismWeakMap.get(meta);
|
|
2246
|
-
if (!prismInstance) {
|
|
2247
|
-
const root2 = meta.root;
|
|
2248
|
-
if (!isPointerToPrismProvider(root2)) {
|
|
2249
|
-
throw new Error(
|
|
2250
|
-
`Cannot run pointerToPrism() on a pointer whose root is not an PointerToPrismProvider`
|
|
2251
|
-
);
|
|
2252
|
-
}
|
|
2253
|
-
prismInstance = root2.pointerToPrism(pointer2);
|
|
2254
|
-
identifyPrismWeakMap.set(meta, prismInstance);
|
|
2255
|
-
}
|
|
2256
|
-
return prismInstance;
|
|
2257
|
-
};
|
|
2258
|
-
|
|
2259
|
-
// ../dataverse/src/val.ts
|
|
2260
|
-
var val = (input) => {
|
|
2261
|
-
if (isPointer(input)) {
|
|
2262
|
-
return pointerToPrism(input).getValue();
|
|
2263
|
-
} else if (isPrism(input)) {
|
|
2264
|
-
return input.getValue();
|
|
2265
|
-
} else {
|
|
2266
|
-
return input;
|
|
2267
|
-
}
|
|
2268
|
-
};
|
|
2269
|
-
|
|
2270
2111
|
// ../../theatre/shared/src/gsap/gsapStudioRegistryRevision.ts
|
|
2271
2112
|
var revisionAtom = new Atom(0);
|
|
2272
2113
|
function bumpGsapStudioRegistryRevision() {
|
|
@@ -2344,9 +2185,6 @@ function getAnimationEntry(sheetObject, animationId) {
|
|
|
2344
2185
|
function getAnimationEntryForSheetObject(sheetObject) {
|
|
2345
2186
|
return getAnimationEntry(sheetObject);
|
|
2346
2187
|
}
|
|
2347
|
-
function getAnimationEntryBySheetAddressKey(sheetObjectAddressKey2, animationId) {
|
|
2348
|
-
return getStore2().bySheetAddress.get(sheetObjectAddressKey2)?.get(animationId);
|
|
2349
|
-
}
|
|
2350
2188
|
function listAnimationEntries() {
|
|
2351
2189
|
const entries = [];
|
|
2352
2190
|
for (const byAnim of getStore2().bySheetAddress.values()) {
|
|
@@ -2455,57 +2293,7 @@ function registerGsapAnimation(animation, sheet, options) {
|
|
|
2455
2293
|
}
|
|
2456
2294
|
|
|
2457
2295
|
// src/attachGsapSequenceBridge.ts
|
|
2458
|
-
import {
|
|
2459
|
-
|
|
2460
|
-
// ../../theatre/shared/src/gsap/syncGsapClipsAtSequencePosition.ts
|
|
2461
|
-
function syncGsapClipsAtSequencePosition(position, clips) {
|
|
2462
|
-
syncRegisteredGsapAnimationsForClips(
|
|
2463
|
-
position,
|
|
2464
|
-
clips
|
|
2465
|
-
);
|
|
2466
|
-
}
|
|
2467
|
-
|
|
2468
|
-
// ../../theatre/shared/src/gsap/subscribeGsapClipSyncAtPlayhead.ts
|
|
2469
|
-
function subscribeGsapClipSyncAtPlayhead(source2) {
|
|
2470
|
-
const positionPointer = source2.pointer.position;
|
|
2471
|
-
const positionPrism = pointerToPrism(positionPointer);
|
|
2472
|
-
const clipsPrism = prism_default(() => source2.getGsapClipTimings());
|
|
2473
|
-
const syncNow = () => {
|
|
2474
|
-
const clips = clipsPrism.getValue();
|
|
2475
|
-
if (clips.length === 0)
|
|
2476
|
-
return;
|
|
2477
|
-
syncGsapClipsAtSequencePosition(val(positionPointer), clips);
|
|
2478
|
-
};
|
|
2479
|
-
const untapPosition = positionPrism.onStale(syncNow);
|
|
2480
|
-
const untapClips = clipsPrism.onStale(syncNow);
|
|
2481
|
-
syncNow();
|
|
2482
|
-
return () => {
|
|
2483
|
-
untapPosition();
|
|
2484
|
-
untapClips();
|
|
2485
|
-
};
|
|
2486
|
-
}
|
|
2487
|
-
|
|
2488
|
-
// src/attachGsapSequenceBridge.ts
|
|
2489
|
-
function attachGsapSequenceBridge(sheet) {
|
|
2490
|
-
const sequence = sheet.sequence;
|
|
2491
|
-
const sheetAddress = privateAPI2(sheet).address;
|
|
2492
|
-
return subscribeGsapClipSyncAtPlayhead({
|
|
2493
|
-
pointer: sequence.pointer,
|
|
2494
|
-
getGsapClipTimings: () => sequence.__experimental_getGsapClips().map(({ objectKey, clip }) => ({
|
|
2495
|
-
sheetObjectAddressKey: sheetObjectAddressKeyFromParts({
|
|
2496
|
-
projectId: sheetAddress.projectId,
|
|
2497
|
-
sheetId: sheetAddress.sheetId,
|
|
2498
|
-
sheetInstanceId: sheetAddress.sheetInstanceId,
|
|
2499
|
-
objectKey
|
|
2500
|
-
}),
|
|
2501
|
-
gsapAnimationId: clip.gsapAnimationId,
|
|
2502
|
-
start: clip.start,
|
|
2503
|
-
duration: clip.duration,
|
|
2504
|
-
timelineChildren: clip.timelineChildren,
|
|
2505
|
-
timelineSpan: clip.timelineSpan
|
|
2506
|
-
}))
|
|
2507
|
-
});
|
|
2508
|
-
}
|
|
2296
|
+
import { attachGsapSequenceBridge } from "@unseenco/theatre-core";
|
|
2509
2297
|
export {
|
|
2510
2298
|
attachGsapSequenceBridge,
|
|
2511
2299
|
configureTheatreGsap,
|