@unseenco/theatre-gsap 0.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/animationRegistry.d.ts +17 -0
- package/dist/animationRegistry.d.ts.map +1 -0
- package/dist/animationRegistry.test.d.ts +2 -0
- package/dist/animationRegistry.test.d.ts.map +1 -0
- package/dist/attachGsapSequenceBridge.d.ts +8 -0
- package/dist/attachGsapSequenceBridge.d.ts.map +1 -0
- package/dist/config.d.ts +12 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/gsapTypes.d.ts +11 -0
- package/dist/gsapTypes.d.ts.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +161 -0
- package/dist/index.js.map +7 -0
- package/dist/index.mjs +144 -0
- package/dist/index.mjs.map +7 -0
- package/dist/registerGsapAnimation.d.ts +30 -0
- package/dist/registerGsapAnimation.d.ts.map +1 -0
- package/dist/tsdoc-metadata.json +11 -0
- package/package.json +54 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type SheetObject from '@unseenco/theatre-core/sheetObjects/SheetObject';
|
|
2
|
+
import type { GsapTweenLike } from './gsapTypes';
|
|
3
|
+
export type GsapAnimationRegistryEntry = {
|
|
4
|
+
id: string;
|
|
5
|
+
label: string;
|
|
6
|
+
animation: GsapTweenLike;
|
|
7
|
+
sheetObject?: SheetObject;
|
|
8
|
+
defaultDuration?: number;
|
|
9
|
+
onRebuildTimeline?: () => GsapTweenLike;
|
|
10
|
+
};
|
|
11
|
+
export declare function registerAnimationInRegistry(entry: GsapAnimationRegistryEntry): void;
|
|
12
|
+
export declare function getAnimationEntry(sheetObject: SheetObject, animationId?: string): GsapAnimationRegistryEntry | undefined;
|
|
13
|
+
export declare function getAnimationEntryById(id: string): GsapAnimationRegistryEntry | undefined;
|
|
14
|
+
export declare function getAnimationEntryForSheetObject(sheetObject: SheetObject): GsapAnimationRegistryEntry | undefined;
|
|
15
|
+
export declare function listAnimationEntries(): GsapAnimationRegistryEntry[];
|
|
16
|
+
export declare function clearAnimationRegistryForTests(): void;
|
|
17
|
+
//# sourceMappingURL=animationRegistry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"animationRegistry.d.ts","sourceRoot":"","sources":["../src/animationRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,iDAAiD,CAAA;AAC9E,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,aAAa,CAAA;AAU9C,MAAM,MAAM,0BAA0B,GAAG;IACvC,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,aAAa,CAAA;IACxB,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,iBAAiB,CAAC,EAAE,MAAM,aAAa,CAAA;CACxC,CAAA;AAED,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,0BAA0B,GAChC,IAAI,CASN;AAsBD,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,WAAW,EACxB,WAAW,CAAC,EAAE,MAAM,GACnB,0BAA0B,GAAG,SAAS,CAExC;AAED,wBAAgB,qBAAqB,CACnC,EAAE,EAAE,MAAM,GACT,0BAA0B,GAAG,SAAS,CAIxC;AAED,wBAAgB,+BAA+B,CAC7C,WAAW,EAAE,WAAW,GACvB,0BAA0B,GAAG,SAAS,CAExC;AAED,wBAAgB,oBAAoB,IAAI,0BAA0B,EAAE,CASnE;AAED,wBAAgB,8BAA8B,IAAI,IAAI,CAErD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"animationRegistry.test.d.ts","sourceRoot":"","sources":["../src/animationRegistry.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,8 @@
|
|
|
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;
|
|
8
|
+
//# sourceMappingURL=attachGsapSequenceBridge.d.ts.map
|
|
@@ -0,0 +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"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { OutlineNamespaceConfig } from '@unseenco/theatre-shared/utils/outlineNamespaces';
|
|
2
|
+
export type TheatreGsapConfig = {
|
|
3
|
+
/** Outline namespace segment for GSAP proxy objects (default `GSAP`). */
|
|
4
|
+
namespace?: string;
|
|
5
|
+
/** Applied to each sheet when the first GSAP object is registered on it. */
|
|
6
|
+
outlineNamespace?: OutlineNamespaceConfig;
|
|
7
|
+
};
|
|
8
|
+
export declare function configureTheatreGsap(config: TheatreGsapConfig): {
|
|
9
|
+
reset: () => void;
|
|
10
|
+
};
|
|
11
|
+
export declare function getTheatreGsapConfig(): TheatreGsapConfig;
|
|
12
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,sBAAsB,EAAC,MAAM,kDAAkD,CAAA;AAG5F,MAAM,MAAM,iBAAiB,GAAG;IAC9B,yEAAyE;IACzE,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,4EAA4E;IAC5E,gBAAgB,CAAC,EAAE,sBAAsB,CAAA;CAC1C,CAAA;AASD,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,iBAAiB,GAAG;IAC/D,KAAK,EAAE,MAAM,IAAI,CAAA;CAClB,CAYA;AAED,wBAAgB,oBAAoB,IAAI,iBAAiB,CAExD"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Minimal GSAP tween surface used by Theatre (avoids tight coupling to GSAP's TS exports). */
|
|
2
|
+
export type GsapTweenLike = {
|
|
3
|
+
pause(): void;
|
|
4
|
+
progress(value: number, suppressEvents?: boolean): number;
|
|
5
|
+
duration(): number;
|
|
6
|
+
totalDuration?(): number;
|
|
7
|
+
time?(value: number, suppressEvents?: boolean): number;
|
|
8
|
+
getChildren?(nested: boolean, tweens: boolean, timelines: boolean): GsapTweenLike[];
|
|
9
|
+
startTime?(value?: number): number;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=gsapTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gsapTypes.d.ts","sourceRoot":"","sources":["../src/gsapTypes.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,IAAI,IAAI,CAAA;IACb,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;IACzD,QAAQ,IAAI,MAAM,CAAA;IAClB,aAAa,CAAC,IAAI,MAAM,CAAA;IACxB,IAAI,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;IACtD,WAAW,CAAC,CACV,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,OAAO,EACf,SAAS,EAAE,OAAO,GACjB,aAAa,EAAE,CAAA;IAClB,SAAS,CAAC,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CACnC,CAAA"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { registerGsapAnimation } from './registerGsapAnimation';
|
|
2
|
+
export type { RegisterGsapAnimationOptions, RegisterGsapAnimationResult, } from './registerGsapAnimation';
|
|
3
|
+
export { attachGsapSequenceBridge } from './attachGsapSequenceBridge';
|
|
4
|
+
export { configureTheatreGsap, getTheatreGsapConfig } from './config';
|
|
5
|
+
export type { TheatreGsapConfig } from './config';
|
|
6
|
+
export { getAnimationEntry, getAnimationEntryById, getAnimationEntryForSheetObject, listAnimationEntries, } from './animationRegistry';
|
|
7
|
+
export type { GsapAnimationRegistryEntry } from './animationRegistry';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,qBAAqB,EAAC,MAAM,yBAAyB,CAAA;AAC7D,YAAY,EACV,4BAA4B,EAC5B,2BAA2B,GAC5B,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAC,wBAAwB,EAAC,MAAM,4BAA4B,CAAA;AACnE,OAAO,EAAC,oBAAoB,EAAE,oBAAoB,EAAC,MAAM,UAAU,CAAA;AACnE,YAAY,EAAC,iBAAiB,EAAC,MAAM,UAAU,CAAA;AAC/C,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,+BAA+B,EAC/B,oBAAoB,GACrB,MAAM,qBAAqB,CAAA;AAC5B,YAAY,EAAC,0BAA0B,EAAC,MAAM,qBAAqB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
attachGsapSequenceBridge: () => attachGsapSequenceBridge,
|
|
24
|
+
configureTheatreGsap: () => configureTheatreGsap,
|
|
25
|
+
getAnimationEntry: () => getAnimationEntry,
|
|
26
|
+
getAnimationEntryById: () => getAnimationEntryById,
|
|
27
|
+
getAnimationEntryForSheetObject: () => getAnimationEntryForSheetObject,
|
|
28
|
+
getTheatreGsapConfig: () => getTheatreGsapConfig,
|
|
29
|
+
listAnimationEntries: () => listAnimationEntries,
|
|
30
|
+
registerGsapAnimation: () => registerGsapAnimation
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(src_exports);
|
|
33
|
+
|
|
34
|
+
// src/registerGsapAnimation.ts
|
|
35
|
+
var import_privateAPIs = require("@unseenco/theatre-core/privateAPIs");
|
|
36
|
+
var import_buildGsapSheetObjectKey = require("@unseenco/theatre-shared/gsap/buildGsapSheetObjectKey");
|
|
37
|
+
var import_gsapAnimationRegistry2 = require("@unseenco/theatre-shared/gsap/gsapAnimationRegistry");
|
|
38
|
+
|
|
39
|
+
// src/config.ts
|
|
40
|
+
var import_gsapSheetObjectKey = require("@unseenco/theatre-shared/gsap/gsapSheetObjectKey");
|
|
41
|
+
var activeConfig = {
|
|
42
|
+
namespace: "GSAP",
|
|
43
|
+
outlineNamespace: { defaultCollapsed: false }
|
|
44
|
+
};
|
|
45
|
+
(0, import_gsapSheetObjectKey.setConfiguredGsapSheetObjectNamespace)(activeConfig.namespace);
|
|
46
|
+
function configureTheatreGsap(config) {
|
|
47
|
+
const prev = activeConfig;
|
|
48
|
+
activeConfig = {
|
|
49
|
+
namespace: config.namespace ?? prev.namespace ?? "GSAP",
|
|
50
|
+
outlineNamespace: config.outlineNamespace ?? prev.outlineNamespace
|
|
51
|
+
};
|
|
52
|
+
(0, import_gsapSheetObjectKey.setConfiguredGsapSheetObjectNamespace)(activeConfig.namespace ?? "GSAP");
|
|
53
|
+
return {
|
|
54
|
+
reset() {
|
|
55
|
+
activeConfig = prev;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function getTheatreGsapConfig() {
|
|
60
|
+
return activeConfig;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// src/animationRegistry.ts
|
|
64
|
+
var import_gsapAnimationRegistry = require("@unseenco/theatre-shared/gsap/gsapAnimationRegistry");
|
|
65
|
+
var import_syncGsapClipProgress = require("@unseenco/theatre-shared/gsap/syncGsapClipProgress");
|
|
66
|
+
function registerAnimationInRegistry(entry) {
|
|
67
|
+
(0, import_gsapAnimationRegistry.registerAnimationInRegistry)({
|
|
68
|
+
...entry,
|
|
69
|
+
animation: entry.animation,
|
|
70
|
+
defaultDuration: entry.defaultDuration ?? defaultClipDuration(entry.animation),
|
|
71
|
+
onRebuildTimeline: entry.onRebuildTimeline
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
function defaultClipDuration(animation) {
|
|
75
|
+
return (0, import_syncGsapClipProgress.readGsapTweenTimelineDuration)(animation);
|
|
76
|
+
}
|
|
77
|
+
function toPackageEntry(entry) {
|
|
78
|
+
if (!entry || !entry.animation)
|
|
79
|
+
return void 0;
|
|
80
|
+
return {
|
|
81
|
+
id: entry.id,
|
|
82
|
+
label: entry.label,
|
|
83
|
+
animation: entry.animation,
|
|
84
|
+
sheetObject: entry.sheetObject,
|
|
85
|
+
defaultDuration: entry.defaultDuration,
|
|
86
|
+
onRebuildTimeline: entry.onRebuildTimeline
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function getAnimationEntry(sheetObject, animationId) {
|
|
90
|
+
return toPackageEntry((0, import_gsapAnimationRegistry.getAnimationEntry)(sheetObject, animationId));
|
|
91
|
+
}
|
|
92
|
+
function getAnimationEntryById(id) {
|
|
93
|
+
return toPackageEntry(
|
|
94
|
+
(0, import_gsapAnimationRegistry.listAnimationEntries)().find((entry) => entry.id === id)
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
function getAnimationEntryForSheetObject(sheetObject) {
|
|
98
|
+
return toPackageEntry((0, import_gsapAnimationRegistry.getAnimationEntryForSheetObject)(sheetObject));
|
|
99
|
+
}
|
|
100
|
+
function listAnimationEntries() {
|
|
101
|
+
return (0, import_gsapAnimationRegistry.listAnimationEntries)().filter((e) => !!e.animation).map((entry) => ({
|
|
102
|
+
id: entry.id,
|
|
103
|
+
label: entry.label,
|
|
104
|
+
animation: entry.animation,
|
|
105
|
+
sheetObject: entry.sheetObject
|
|
106
|
+
}));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// src/registerGsapAnimation.ts
|
|
110
|
+
var import_outlineNamespaces = require("@unseenco/theatre-shared/utils/outlineNamespaces");
|
|
111
|
+
function registerGsapAnimation(animation, sheet, options) {
|
|
112
|
+
const config = getTheatreGsapConfig();
|
|
113
|
+
const namespace = options.namespace ?? config.namespace ?? "GSAP";
|
|
114
|
+
const objectKey = (0, import_buildGsapSheetObjectKey.buildGsapSheetObjectKey)(namespace, options.label);
|
|
115
|
+
const id = options.id ?? objectKey;
|
|
116
|
+
animation.pause();
|
|
117
|
+
const sheetObjectPublic = sheet.object(objectKey, {}, { reconfigure: false });
|
|
118
|
+
const sheetObjectInternal = (0, import_privateAPIs.privateAPI)(sheetObjectPublic);
|
|
119
|
+
const existing = (0, import_gsapAnimationRegistry2.getAnimationEntry)(sheetObjectInternal, id);
|
|
120
|
+
if (config.outlineNamespace && !existing) {
|
|
121
|
+
(0, import_privateAPIs.privateAPI)(sheet).template.setOutlineNamespaceConfig(
|
|
122
|
+
(0, import_outlineNamespaces.formatOutlineNamespacePathKey)([namespace]),
|
|
123
|
+
config.outlineNamespace
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
registerAnimationInRegistry({
|
|
127
|
+
id,
|
|
128
|
+
label: options.label,
|
|
129
|
+
animation,
|
|
130
|
+
sheetObject: sheetObjectInternal,
|
|
131
|
+
defaultDuration: options.defaultDuration,
|
|
132
|
+
onRebuildTimeline: options.onRebuildTimeline
|
|
133
|
+
});
|
|
134
|
+
return { id, sheetObject: sheetObjectPublic };
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// src/attachGsapSequenceBridge.ts
|
|
138
|
+
var import_privateAPIs2 = require("@unseenco/theatre-core/privateAPIs");
|
|
139
|
+
var import_gsapAnimationRegistry3 = require("@unseenco/theatre-shared/gsap/gsapAnimationRegistry");
|
|
140
|
+
var import_subscribeGsapClipSyncAtPlayhead = require("@unseenco/theatre-shared/gsap/subscribeGsapClipSyncAtPlayhead");
|
|
141
|
+
function attachGsapSequenceBridge(sheet) {
|
|
142
|
+
const sequence = sheet.sequence;
|
|
143
|
+
const sheetAddress = (0, import_privateAPIs2.privateAPI)(sheet).address;
|
|
144
|
+
return (0, import_subscribeGsapClipSyncAtPlayhead.subscribeGsapClipSyncAtPlayhead)({
|
|
145
|
+
pointer: sequence.pointer,
|
|
146
|
+
getGsapClipTimings: () => sequence.__experimental_getGsapClips().map(({ objectKey, clip }) => ({
|
|
147
|
+
sheetObjectAddressKey: (0, import_gsapAnimationRegistry3.sheetObjectAddressKeyFromParts)({
|
|
148
|
+
projectId: sheetAddress.projectId,
|
|
149
|
+
sheetId: sheetAddress.sheetId,
|
|
150
|
+
sheetInstanceId: sheetAddress.sheetInstanceId,
|
|
151
|
+
objectKey
|
|
152
|
+
}),
|
|
153
|
+
gsapAnimationId: clip.gsapAnimationId,
|
|
154
|
+
start: clip.start,
|
|
155
|
+
duration: clip.duration,
|
|
156
|
+
timelineChildren: clip.timelineChildren,
|
|
157
|
+
timelineSpan: clip.timelineSpan
|
|
158
|
+
}))
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.ts", "../src/registerGsapAnimation.ts", "../src/config.ts", "../src/animationRegistry.ts", "../src/attachGsapSequenceBridge.ts"],
|
|
4
|
+
"sourcesContent": ["export {registerGsapAnimation} from './registerGsapAnimation'\r\nexport type {\r\n RegisterGsapAnimationOptions,\r\n RegisterGsapAnimationResult,\r\n} from './registerGsapAnimation'\r\nexport {attachGsapSequenceBridge} from './attachGsapSequenceBridge'\r\nexport {configureTheatreGsap, getTheatreGsapConfig} from './config'\r\nexport type {TheatreGsapConfig} from './config'\r\nexport {\r\n getAnimationEntry,\r\n getAnimationEntryById,\r\n getAnimationEntryForSheetObject,\r\n listAnimationEntries,\r\n} from './animationRegistry'\r\nexport type {GsapAnimationRegistryEntry} from './animationRegistry'\r\n", "import type {ISheet, ISheetObject} from '@unseenco/theatre-core'\r\nimport type {GsapTweenLike} from './gsapTypes'\r\nimport {privateAPI} from '@unseenco/theatre-core/privateAPIs'\r\nimport {buildGsapSheetObjectKey} from '@unseenco/theatre-shared/gsap/buildGsapSheetObjectKey'\r\nimport {getAnimationEntry} from '@unseenco/theatre-shared/gsap/gsapAnimationRegistry'\r\nimport {getTheatreGsapConfig} from './config'\r\nimport {registerAnimationInRegistry} from './animationRegistry'\r\nimport {formatOutlineNamespacePathKey} from '@unseenco/theatre-shared/utils/outlineNamespaces'\r\n\r\nexport type RegisterGsapAnimationOptions = {\r\n /** Theatre object label (shown after the `GSAP/` namespace). */\r\n label: string\r\n /** Override namespace from {@link configureTheatreGsap}. */\r\n namespace?: string\r\n /**\r\n * Stable id for this animation on the sheet object. When omitted, defaults to\r\n * the sanitised sheet object key (e.g. `GSAP / Panel show`).\r\n * Re-registering with the same id updates the registry entry in place.\r\n */\r\n id?: string\r\n /** Clip length when adding to the sequence (defaults to tween duration). */\r\n defaultDuration?: number\r\n /** Rebuild the timeline when native child timing edits fail. */\r\n onRebuildTimeline?: () => GsapTweenLike\r\n}\r\n\r\nexport type RegisterGsapAnimationResult = {\r\n id: string\r\n sheetObject: ISheetObject<{}>\r\n}\r\n\r\n/**\r\n * Registers a GSAP tween for Theatre sequence bridging and creates an outline\r\n * proxy object under `GSAP/<label>` (namespace configurable).\r\n *\r\n * The animation is paused immediately so Theatre can drive progress.\r\n */\r\nexport function registerGsapAnimation(\r\n animation: GsapTweenLike,\r\n sheet: ISheet,\r\n options: RegisterGsapAnimationOptions,\r\n): RegisterGsapAnimationResult {\r\n const config = getTheatreGsapConfig()\r\n const namespace = options.namespace ?? config.namespace ?? 'GSAP'\r\n const objectKey = buildGsapSheetObjectKey(namespace, options.label)\r\n const id = options.id ?? objectKey\r\n\r\n animation.pause()\r\n\r\n const sheetObjectPublic = sheet.object(objectKey, {}, {reconfigure: false})\r\n const sheetObjectInternal = privateAPI(sheetObjectPublic)\r\n\r\n const existing = getAnimationEntry(sheetObjectInternal, id)\r\n\r\n if (config.outlineNamespace && !existing) {\r\n privateAPI(sheet).template.setOutlineNamespaceConfig(\r\n formatOutlineNamespacePathKey([namespace]),\r\n config.outlineNamespace,\r\n )\r\n }\r\n\r\n registerAnimationInRegistry({\r\n id,\r\n label: options.label,\r\n animation,\r\n sheetObject: sheetObjectInternal,\r\n defaultDuration: options.defaultDuration,\r\n onRebuildTimeline: options.onRebuildTimeline,\r\n })\r\n\r\n return {id, sheetObject: sheetObjectPublic}\r\n}\r\n", "import type {OutlineNamespaceConfig} from '@unseenco/theatre-shared/utils/outlineNamespaces'\r\nimport {setConfiguredGsapSheetObjectNamespace} from '@unseenco/theatre-shared/gsap/gsapSheetObjectKey'\r\n\r\nexport type TheatreGsapConfig = {\r\n /** Outline namespace segment for GSAP proxy objects (default `GSAP`). */\r\n namespace?: string\r\n /** Applied to each sheet when the first GSAP object is registered on it. */\r\n outlineNamespace?: OutlineNamespaceConfig\r\n}\r\n\r\nlet activeConfig: TheatreGsapConfig = {\r\n namespace: 'GSAP',\r\n outlineNamespace: {defaultCollapsed: false},\r\n}\r\n\r\nsetConfiguredGsapSheetObjectNamespace(activeConfig.namespace!)\r\n\r\nexport function configureTheatreGsap(config: TheatreGsapConfig): {\r\n reset: () => void\r\n} {\r\n const prev = activeConfig\r\n activeConfig = {\r\n namespace: config.namespace ?? prev.namespace ?? 'GSAP',\r\n outlineNamespace: config.outlineNamespace ?? prev.outlineNamespace,\r\n }\r\n setConfiguredGsapSheetObjectNamespace(activeConfig.namespace ?? 'GSAP')\r\n return {\r\n reset() {\r\n activeConfig = prev\r\n },\r\n }\r\n}\r\n\r\nexport function getTheatreGsapConfig(): TheatreGsapConfig {\r\n return activeConfig\r\n}\r\n", "import type SheetObject from '@unseenco/theatre-core/sheetObjects/SheetObject'\r\nimport type {GsapTweenLike} from './gsapTypes'\r\nimport {\r\n clearAnimationRegistryForTests as clearSharedAnimationRegistryForTests,\r\n getAnimationEntry as getSharedAnimationEntry,\r\n getAnimationEntryForSheetObject as getSharedAnimationEntryForSheetObject,\r\n listAnimationEntries as listSharedAnimationEntries,\r\n registerAnimationInRegistry as registerSharedAnimationInRegistry,\r\n} from '@unseenco/theatre-shared/gsap/gsapAnimationRegistry'\r\nimport {readGsapTweenTimelineDuration} from '@unseenco/theatre-shared/gsap/syncGsapClipProgress'\r\n\r\nexport type GsapAnimationRegistryEntry = {\r\n id: string\r\n label: string\r\n animation: GsapTweenLike\r\n sheetObject?: SheetObject\r\n defaultDuration?: number\r\n onRebuildTimeline?: () => GsapTweenLike\r\n}\r\n\r\nexport function registerAnimationInRegistry(\r\n entry: GsapAnimationRegistryEntry,\r\n): void {\r\n registerSharedAnimationInRegistry({\r\n ...entry,\r\n animation: entry.animation,\r\n defaultDuration:\r\n entry.defaultDuration ??\r\n defaultClipDuration(entry.animation as GsapTweenLike),\r\n onRebuildTimeline: entry.onRebuildTimeline,\r\n })\r\n}\r\n\r\nfunction defaultClipDuration(animation: GsapTweenLike): number {\r\n return readGsapTweenTimelineDuration(animation)\r\n}\r\n\r\nfunction toPackageEntry(\r\n entry: ReturnType<typeof getSharedAnimationEntryForSheetObject>,\r\n): GsapAnimationRegistryEntry | undefined {\r\n if (!entry || !entry.animation) return undefined\r\n return {\r\n id: entry.id,\r\n label: entry.label,\r\n animation: entry.animation as GsapTweenLike,\r\n sheetObject: entry.sheetObject,\r\n defaultDuration: entry.defaultDuration,\r\n onRebuildTimeline: entry.onRebuildTimeline as\r\n | (() => GsapTweenLike)\r\n | undefined,\r\n }\r\n}\r\n\r\nexport function getAnimationEntry(\r\n sheetObject: SheetObject,\r\n animationId?: string,\r\n): GsapAnimationRegistryEntry | undefined {\r\n return toPackageEntry(getSharedAnimationEntry(sheetObject, animationId))\r\n}\r\n\r\nexport function getAnimationEntryById(\r\n id: string,\r\n): GsapAnimationRegistryEntry | undefined {\r\n return toPackageEntry(\r\n listSharedAnimationEntries().find((entry) => entry.id === id),\r\n )\r\n}\r\n\r\nexport function getAnimationEntryForSheetObject(\r\n sheetObject: SheetObject,\r\n): GsapAnimationRegistryEntry | undefined {\r\n return toPackageEntry(getSharedAnimationEntryForSheetObject(sheetObject))\r\n}\r\n\r\nexport function listAnimationEntries(): GsapAnimationRegistryEntry[] {\r\n return listSharedAnimationEntries()\r\n .filter((e): e is typeof e & {animation: GsapTweenLike} => !!e.animation)\r\n .map((entry) => ({\r\n id: entry.id,\r\n label: entry.label,\r\n animation: entry.animation as GsapTweenLike,\r\n sheetObject: entry.sheetObject,\r\n }))\r\n}\r\n\r\nexport function clearAnimationRegistryForTests(): void {\r\n clearSharedAnimationRegistryForTests()\r\n}\r\n", "import type {ISheet} from '@unseenco/theatre-core'\r\nimport {privateAPI} from '@unseenco/theatre-core/privateAPIs'\r\nimport {sheetObjectAddressKeyFromParts} from '@unseenco/theatre-shared/gsap/gsapAnimationRegistry'\r\nimport type {ObjectAddressKey} from '@unseenco/theatre-shared/utils/ids'\r\nimport {subscribeGsapClipSyncAtPlayhead} from '@unseenco/theatre-shared/gsap/subscribeGsapClipSyncAtPlayhead'\r\n\r\n/**\r\n * Drives registered GSAP animations from the sheet sequence playhead.\r\n *\r\n * @returns Disposer \u2014 call to detach the bridge.\r\n */\r\nexport function attachGsapSequenceBridge(sheet: ISheet): () => void {\r\n const sequence = sheet.sequence\r\n const sheetAddress = privateAPI(sheet).address\r\n\r\n return subscribeGsapClipSyncAtPlayhead({\r\n pointer: sequence.pointer,\r\n getGsapClipTimings: () =>\r\n sequence.__experimental_getGsapClips().map(({objectKey, clip}) => ({\r\n sheetObjectAddressKey: sheetObjectAddressKeyFromParts({\r\n projectId: sheetAddress.projectId,\r\n sheetId: sheetAddress.sheetId,\r\n sheetInstanceId: sheetAddress.sheetInstanceId,\r\n objectKey: objectKey as ObjectAddressKey,\r\n }),\r\n gsapAnimationId: clip.gsapAnimationId,\r\n start: clip.start,\r\n duration: clip.duration,\r\n timelineChildren: clip.timelineChildren,\r\n timelineSpan: clip.timelineSpan,\r\n })),\r\n })\r\n}\r\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEA,yBAAyB;AACzB,qCAAsC;AACtC,IAAAA,gCAAgC;;;ACHhC,gCAAoD;AASpD,IAAI,eAAkC;AAAA,EACpC,WAAW;AAAA,EACX,kBAAkB,EAAC,kBAAkB,MAAK;AAC5C;AAAA,IAEA,iEAAsC,aAAa,SAAU;AAEtD,SAAS,qBAAqB,QAEnC;AACA,QAAM,OAAO;AACb,iBAAe;AAAA,IACb,WAAW,OAAO,aAAa,KAAK,aAAa;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;AAAA,MACf,kBAAkB,KAAK;AAAA,MACvB,cAAc,KAAK;AAAA,IACrB,EAAE;AAAA,EACN,CAAC;AACH;",
|
|
6
|
+
"names": ["import_gsapAnimationRegistry", "registerSharedAnimationInRegistry", "getSharedAnimationEntry", "listSharedAnimationEntries", "getSharedAnimationEntryForSheetObject", "import_privateAPIs", "import_gsapAnimationRegistry"]
|
|
7
|
+
}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
// src/registerGsapAnimation.ts
|
|
2
|
+
import { privateAPI } from "@unseenco/theatre-core/privateAPIs";
|
|
3
|
+
import { buildGsapSheetObjectKey } from "@unseenco/theatre-shared/gsap/buildGsapSheetObjectKey";
|
|
4
|
+
import { getAnimationEntry as getAnimationEntry2 } from "@unseenco/theatre-shared/gsap/gsapAnimationRegistry";
|
|
5
|
+
|
|
6
|
+
// src/config.ts
|
|
7
|
+
import { setConfiguredGsapSheetObjectNamespace } from "@unseenco/theatre-shared/gsap/gsapSheetObjectKey";
|
|
8
|
+
var activeConfig = {
|
|
9
|
+
namespace: "GSAP",
|
|
10
|
+
outlineNamespace: { defaultCollapsed: false }
|
|
11
|
+
};
|
|
12
|
+
setConfiguredGsapSheetObjectNamespace(activeConfig.namespace);
|
|
13
|
+
function configureTheatreGsap(config) {
|
|
14
|
+
const prev = activeConfig;
|
|
15
|
+
activeConfig = {
|
|
16
|
+
namespace: config.namespace ?? prev.namespace ?? "GSAP",
|
|
17
|
+
outlineNamespace: config.outlineNamespace ?? prev.outlineNamespace
|
|
18
|
+
};
|
|
19
|
+
setConfiguredGsapSheetObjectNamespace(activeConfig.namespace ?? "GSAP");
|
|
20
|
+
return {
|
|
21
|
+
reset() {
|
|
22
|
+
activeConfig = prev;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function getTheatreGsapConfig() {
|
|
27
|
+
return activeConfig;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// src/animationRegistry.ts
|
|
31
|
+
import {
|
|
32
|
+
clearAnimationRegistryForTests as clearSharedAnimationRegistryForTests,
|
|
33
|
+
getAnimationEntry as getSharedAnimationEntry,
|
|
34
|
+
getAnimationEntryForSheetObject as getSharedAnimationEntryForSheetObject,
|
|
35
|
+
listAnimationEntries as listSharedAnimationEntries,
|
|
36
|
+
registerAnimationInRegistry as registerSharedAnimationInRegistry
|
|
37
|
+
} from "@unseenco/theatre-shared/gsap/gsapAnimationRegistry";
|
|
38
|
+
import { readGsapTweenTimelineDuration } from "@unseenco/theatre-shared/gsap/syncGsapClipProgress";
|
|
39
|
+
function registerAnimationInRegistry(entry) {
|
|
40
|
+
registerSharedAnimationInRegistry({
|
|
41
|
+
...entry,
|
|
42
|
+
animation: entry.animation,
|
|
43
|
+
defaultDuration: entry.defaultDuration ?? defaultClipDuration(entry.animation),
|
|
44
|
+
onRebuildTimeline: entry.onRebuildTimeline
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function defaultClipDuration(animation) {
|
|
48
|
+
return readGsapTweenTimelineDuration(animation);
|
|
49
|
+
}
|
|
50
|
+
function toPackageEntry(entry) {
|
|
51
|
+
if (!entry || !entry.animation)
|
|
52
|
+
return void 0;
|
|
53
|
+
return {
|
|
54
|
+
id: entry.id,
|
|
55
|
+
label: entry.label,
|
|
56
|
+
animation: entry.animation,
|
|
57
|
+
sheetObject: entry.sheetObject,
|
|
58
|
+
defaultDuration: entry.defaultDuration,
|
|
59
|
+
onRebuildTimeline: entry.onRebuildTimeline
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function getAnimationEntry(sheetObject, animationId) {
|
|
63
|
+
return toPackageEntry(getSharedAnimationEntry(sheetObject, animationId));
|
|
64
|
+
}
|
|
65
|
+
function getAnimationEntryById(id) {
|
|
66
|
+
return toPackageEntry(
|
|
67
|
+
listSharedAnimationEntries().find((entry) => entry.id === id)
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
function getAnimationEntryForSheetObject(sheetObject) {
|
|
71
|
+
return toPackageEntry(getSharedAnimationEntryForSheetObject(sheetObject));
|
|
72
|
+
}
|
|
73
|
+
function listAnimationEntries() {
|
|
74
|
+
return listSharedAnimationEntries().filter((e) => !!e.animation).map((entry) => ({
|
|
75
|
+
id: entry.id,
|
|
76
|
+
label: entry.label,
|
|
77
|
+
animation: entry.animation,
|
|
78
|
+
sheetObject: entry.sheetObject
|
|
79
|
+
}));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// src/registerGsapAnimation.ts
|
|
83
|
+
import { formatOutlineNamespacePathKey } from "@unseenco/theatre-shared/utils/outlineNamespaces";
|
|
84
|
+
function registerGsapAnimation(animation, sheet, options) {
|
|
85
|
+
const config = getTheatreGsapConfig();
|
|
86
|
+
const namespace = options.namespace ?? config.namespace ?? "GSAP";
|
|
87
|
+
const objectKey = buildGsapSheetObjectKey(namespace, options.label);
|
|
88
|
+
const id = options.id ?? objectKey;
|
|
89
|
+
animation.pause();
|
|
90
|
+
const sheetObjectPublic = sheet.object(objectKey, {}, { reconfigure: false });
|
|
91
|
+
const sheetObjectInternal = privateAPI(sheetObjectPublic);
|
|
92
|
+
const existing = getAnimationEntry2(sheetObjectInternal, id);
|
|
93
|
+
if (config.outlineNamespace && !existing) {
|
|
94
|
+
privateAPI(sheet).template.setOutlineNamespaceConfig(
|
|
95
|
+
formatOutlineNamespacePathKey([namespace]),
|
|
96
|
+
config.outlineNamespace
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
registerAnimationInRegistry({
|
|
100
|
+
id,
|
|
101
|
+
label: options.label,
|
|
102
|
+
animation,
|
|
103
|
+
sheetObject: sheetObjectInternal,
|
|
104
|
+
defaultDuration: options.defaultDuration,
|
|
105
|
+
onRebuildTimeline: options.onRebuildTimeline
|
|
106
|
+
});
|
|
107
|
+
return { id, sheetObject: sheetObjectPublic };
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// src/attachGsapSequenceBridge.ts
|
|
111
|
+
import { privateAPI as privateAPI2 } from "@unseenco/theatre-core/privateAPIs";
|
|
112
|
+
import { sheetObjectAddressKeyFromParts } from "@unseenco/theatre-shared/gsap/gsapAnimationRegistry";
|
|
113
|
+
import { subscribeGsapClipSyncAtPlayhead } from "@unseenco/theatre-shared/gsap/subscribeGsapClipSyncAtPlayhead";
|
|
114
|
+
function attachGsapSequenceBridge(sheet) {
|
|
115
|
+
const sequence = sheet.sequence;
|
|
116
|
+
const sheetAddress = privateAPI2(sheet).address;
|
|
117
|
+
return subscribeGsapClipSyncAtPlayhead({
|
|
118
|
+
pointer: sequence.pointer,
|
|
119
|
+
getGsapClipTimings: () => sequence.__experimental_getGsapClips().map(({ objectKey, clip }) => ({
|
|
120
|
+
sheetObjectAddressKey: sheetObjectAddressKeyFromParts({
|
|
121
|
+
projectId: sheetAddress.projectId,
|
|
122
|
+
sheetId: sheetAddress.sheetId,
|
|
123
|
+
sheetInstanceId: sheetAddress.sheetInstanceId,
|
|
124
|
+
objectKey
|
|
125
|
+
}),
|
|
126
|
+
gsapAnimationId: clip.gsapAnimationId,
|
|
127
|
+
start: clip.start,
|
|
128
|
+
duration: clip.duration,
|
|
129
|
+
timelineChildren: clip.timelineChildren,
|
|
130
|
+
timelineSpan: clip.timelineSpan
|
|
131
|
+
}))
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
export {
|
|
135
|
+
attachGsapSequenceBridge,
|
|
136
|
+
configureTheatreGsap,
|
|
137
|
+
getAnimationEntry,
|
|
138
|
+
getAnimationEntryById,
|
|
139
|
+
getAnimationEntryForSheetObject,
|
|
140
|
+
getTheatreGsapConfig,
|
|
141
|
+
listAnimationEntries,
|
|
142
|
+
registerGsapAnimation
|
|
143
|
+
};
|
|
144
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/registerGsapAnimation.ts", "../src/config.ts", "../src/animationRegistry.ts", "../src/attachGsapSequenceBridge.ts"],
|
|
4
|
+
"sourcesContent": ["import type {ISheet, ISheetObject} from '@unseenco/theatre-core'\r\nimport type {GsapTweenLike} from './gsapTypes'\r\nimport {privateAPI} from '@unseenco/theatre-core/privateAPIs'\r\nimport {buildGsapSheetObjectKey} from '@unseenco/theatre-shared/gsap/buildGsapSheetObjectKey'\r\nimport {getAnimationEntry} from '@unseenco/theatre-shared/gsap/gsapAnimationRegistry'\r\nimport {getTheatreGsapConfig} from './config'\r\nimport {registerAnimationInRegistry} from './animationRegistry'\r\nimport {formatOutlineNamespacePathKey} from '@unseenco/theatre-shared/utils/outlineNamespaces'\r\n\r\nexport type RegisterGsapAnimationOptions = {\r\n /** Theatre object label (shown after the `GSAP/` namespace). */\r\n label: string\r\n /** Override namespace from {@link configureTheatreGsap}. */\r\n namespace?: string\r\n /**\r\n * Stable id for this animation on the sheet object. When omitted, defaults to\r\n * the sanitised sheet object key (e.g. `GSAP / Panel show`).\r\n * Re-registering with the same id updates the registry entry in place.\r\n */\r\n id?: string\r\n /** Clip length when adding to the sequence (defaults to tween duration). */\r\n defaultDuration?: number\r\n /** Rebuild the timeline when native child timing edits fail. */\r\n onRebuildTimeline?: () => GsapTweenLike\r\n}\r\n\r\nexport type RegisterGsapAnimationResult = {\r\n id: string\r\n sheetObject: ISheetObject<{}>\r\n}\r\n\r\n/**\r\n * Registers a GSAP tween for Theatre sequence bridging and creates an outline\r\n * proxy object under `GSAP/<label>` (namespace configurable).\r\n *\r\n * The animation is paused immediately so Theatre can drive progress.\r\n */\r\nexport function registerGsapAnimation(\r\n animation: GsapTweenLike,\r\n sheet: ISheet,\r\n options: RegisterGsapAnimationOptions,\r\n): RegisterGsapAnimationResult {\r\n const config = getTheatreGsapConfig()\r\n const namespace = options.namespace ?? config.namespace ?? 'GSAP'\r\n const objectKey = buildGsapSheetObjectKey(namespace, options.label)\r\n const id = options.id ?? objectKey\r\n\r\n animation.pause()\r\n\r\n const sheetObjectPublic = sheet.object(objectKey, {}, {reconfigure: false})\r\n const sheetObjectInternal = privateAPI(sheetObjectPublic)\r\n\r\n const existing = getAnimationEntry(sheetObjectInternal, id)\r\n\r\n if (config.outlineNamespace && !existing) {\r\n privateAPI(sheet).template.setOutlineNamespaceConfig(\r\n formatOutlineNamespacePathKey([namespace]),\r\n config.outlineNamespace,\r\n )\r\n }\r\n\r\n registerAnimationInRegistry({\r\n id,\r\n label: options.label,\r\n animation,\r\n sheetObject: sheetObjectInternal,\r\n defaultDuration: options.defaultDuration,\r\n onRebuildTimeline: options.onRebuildTimeline,\r\n })\r\n\r\n return {id, sheetObject: sheetObjectPublic}\r\n}\r\n", "import type {OutlineNamespaceConfig} from '@unseenco/theatre-shared/utils/outlineNamespaces'\r\nimport {setConfiguredGsapSheetObjectNamespace} from '@unseenco/theatre-shared/gsap/gsapSheetObjectKey'\r\n\r\nexport type TheatreGsapConfig = {\r\n /** Outline namespace segment for GSAP proxy objects (default `GSAP`). */\r\n namespace?: string\r\n /** Applied to each sheet when the first GSAP object is registered on it. */\r\n outlineNamespace?: OutlineNamespaceConfig\r\n}\r\n\r\nlet activeConfig: TheatreGsapConfig = {\r\n namespace: 'GSAP',\r\n outlineNamespace: {defaultCollapsed: false},\r\n}\r\n\r\nsetConfiguredGsapSheetObjectNamespace(activeConfig.namespace!)\r\n\r\nexport function configureTheatreGsap(config: TheatreGsapConfig): {\r\n reset: () => void\r\n} {\r\n const prev = activeConfig\r\n activeConfig = {\r\n namespace: config.namespace ?? prev.namespace ?? 'GSAP',\r\n outlineNamespace: config.outlineNamespace ?? prev.outlineNamespace,\r\n }\r\n setConfiguredGsapSheetObjectNamespace(activeConfig.namespace ?? 'GSAP')\r\n return {\r\n reset() {\r\n activeConfig = prev\r\n },\r\n }\r\n}\r\n\r\nexport function getTheatreGsapConfig(): TheatreGsapConfig {\r\n return activeConfig\r\n}\r\n", "import type SheetObject from '@unseenco/theatre-core/sheetObjects/SheetObject'\r\nimport type {GsapTweenLike} from './gsapTypes'\r\nimport {\r\n clearAnimationRegistryForTests as clearSharedAnimationRegistryForTests,\r\n getAnimationEntry as getSharedAnimationEntry,\r\n getAnimationEntryForSheetObject as getSharedAnimationEntryForSheetObject,\r\n listAnimationEntries as listSharedAnimationEntries,\r\n registerAnimationInRegistry as registerSharedAnimationInRegistry,\r\n} from '@unseenco/theatre-shared/gsap/gsapAnimationRegistry'\r\nimport {readGsapTweenTimelineDuration} from '@unseenco/theatre-shared/gsap/syncGsapClipProgress'\r\n\r\nexport type GsapAnimationRegistryEntry = {\r\n id: string\r\n label: string\r\n animation: GsapTweenLike\r\n sheetObject?: SheetObject\r\n defaultDuration?: number\r\n onRebuildTimeline?: () => GsapTweenLike\r\n}\r\n\r\nexport function registerAnimationInRegistry(\r\n entry: GsapAnimationRegistryEntry,\r\n): void {\r\n registerSharedAnimationInRegistry({\r\n ...entry,\r\n animation: entry.animation,\r\n defaultDuration:\r\n entry.defaultDuration ??\r\n defaultClipDuration(entry.animation as GsapTweenLike),\r\n onRebuildTimeline: entry.onRebuildTimeline,\r\n })\r\n}\r\n\r\nfunction defaultClipDuration(animation: GsapTweenLike): number {\r\n return readGsapTweenTimelineDuration(animation)\r\n}\r\n\r\nfunction toPackageEntry(\r\n entry: ReturnType<typeof getSharedAnimationEntryForSheetObject>,\r\n): GsapAnimationRegistryEntry | undefined {\r\n if (!entry || !entry.animation) return undefined\r\n return {\r\n id: entry.id,\r\n label: entry.label,\r\n animation: entry.animation as GsapTweenLike,\r\n sheetObject: entry.sheetObject,\r\n defaultDuration: entry.defaultDuration,\r\n onRebuildTimeline: entry.onRebuildTimeline as\r\n | (() => GsapTweenLike)\r\n | undefined,\r\n }\r\n}\r\n\r\nexport function getAnimationEntry(\r\n sheetObject: SheetObject,\r\n animationId?: string,\r\n): GsapAnimationRegistryEntry | undefined {\r\n return toPackageEntry(getSharedAnimationEntry(sheetObject, animationId))\r\n}\r\n\r\nexport function getAnimationEntryById(\r\n id: string,\r\n): GsapAnimationRegistryEntry | undefined {\r\n return toPackageEntry(\r\n listSharedAnimationEntries().find((entry) => entry.id === id),\r\n )\r\n}\r\n\r\nexport function getAnimationEntryForSheetObject(\r\n sheetObject: SheetObject,\r\n): GsapAnimationRegistryEntry | undefined {\r\n return toPackageEntry(getSharedAnimationEntryForSheetObject(sheetObject))\r\n}\r\n\r\nexport function listAnimationEntries(): GsapAnimationRegistryEntry[] {\r\n return listSharedAnimationEntries()\r\n .filter((e): e is typeof e & {animation: GsapTweenLike} => !!e.animation)\r\n .map((entry) => ({\r\n id: entry.id,\r\n label: entry.label,\r\n animation: entry.animation as GsapTweenLike,\r\n sheetObject: entry.sheetObject,\r\n }))\r\n}\r\n\r\nexport function clearAnimationRegistryForTests(): void {\r\n clearSharedAnimationRegistryForTests()\r\n}\r\n", "import type {ISheet} from '@unseenco/theatre-core'\r\nimport {privateAPI} from '@unseenco/theatre-core/privateAPIs'\r\nimport {sheetObjectAddressKeyFromParts} from '@unseenco/theatre-shared/gsap/gsapAnimationRegistry'\r\nimport type {ObjectAddressKey} from '@unseenco/theatre-shared/utils/ids'\r\nimport {subscribeGsapClipSyncAtPlayhead} from '@unseenco/theatre-shared/gsap/subscribeGsapClipSyncAtPlayhead'\r\n\r\n/**\r\n * Drives registered GSAP animations from the sheet sequence playhead.\r\n *\r\n * @returns Disposer \u2014 call to detach the bridge.\r\n */\r\nexport function attachGsapSequenceBridge(sheet: ISheet): () => void {\r\n const sequence = sheet.sequence\r\n const sheetAddress = privateAPI(sheet).address\r\n\r\n return subscribeGsapClipSyncAtPlayhead({\r\n pointer: sequence.pointer,\r\n getGsapClipTimings: () =>\r\n sequence.__experimental_getGsapClips().map(({objectKey, clip}) => ({\r\n sheetObjectAddressKey: sheetObjectAddressKeyFromParts({\r\n projectId: sheetAddress.projectId,\r\n sheetId: sheetAddress.sheetId,\r\n sheetInstanceId: sheetAddress.sheetInstanceId,\r\n objectKey: objectKey as ObjectAddressKey,\r\n }),\r\n gsapAnimationId: clip.gsapAnimationId,\r\n start: clip.start,\r\n duration: clip.duration,\r\n timelineChildren: clip.timelineChildren,\r\n timelineSpan: clip.timelineSpan,\r\n })),\r\n })\r\n}\r\n"],
|
|
5
|
+
"mappings": ";AAEA,SAAQ,kBAAiB;AACzB,SAAQ,+BAA8B;AACtC,SAAQ,qBAAAA,0BAAwB;;;ACHhC,SAAQ,6CAA4C;AASpD,IAAI,eAAkC;AAAA,EACpC,WAAW;AAAA,EACX,kBAAkB,EAAC,kBAAkB,MAAK;AAC5C;AAEA,sCAAsC,aAAa,SAAU;AAEtD,SAAS,qBAAqB,QAEnC;AACA,QAAM,OAAO;AACb,iBAAe;AAAA,IACb,WAAW,OAAO,aAAa,KAAK,aAAa;AAAA,IACjD,kBAAkB,OAAO,oBAAoB,KAAK;AAAA,EACpD;AACA,wCAAsC,aAAa,aAAa,MAAM;AACtE,SAAO;AAAA,IACL,QAAQ;AACN,qBAAe;AAAA,IACjB;AAAA,EACF;AACF;AAEO,SAAS,uBAA0C;AACxD,SAAO;AACT;;;ACjCA;AAAA,EACE,kCAAkC;AAAA,EAClC,qBAAqB;AAAA,EACrB,mCAAmC;AAAA,EACnC,wBAAwB;AAAA,EACxB,+BAA+B;AAAA,OAC1B;AACP,SAAQ,qCAAoC;AAWrC,SAAS,4BACd,OACM;AACN,oCAAkC;AAAA,IAChC,GAAG;AAAA,IACH,WAAW,MAAM;AAAA,IACjB,iBACE,MAAM,mBACN,oBAAoB,MAAM,SAA0B;AAAA,IACtD,mBAAmB,MAAM;AAAA,EAC3B,CAAC;AACH;AAEA,SAAS,oBAAoB,WAAkC;AAC7D,SAAO,8BAA8B,SAAS;AAChD;AAEA,SAAS,eACP,OACwC;AACxC,MAAI,CAAC,SAAS,CAAC,MAAM;AAAW,WAAO;AACvC,SAAO;AAAA,IACL,IAAI,MAAM;AAAA,IACV,OAAO,MAAM;AAAA,IACb,WAAW,MAAM;AAAA,IACjB,aAAa,MAAM;AAAA,IACnB,iBAAiB,MAAM;AAAA,IACvB,mBAAmB,MAAM;AAAA,EAG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C;;;AGtEA,SAAQ,cAAAC,mBAAiB;AACzB,SAAQ,sCAAqC;AAE7C,SAAQ,uCAAsC;AAOvC,SAAS,yBAAyB,OAA2B;AAClE,QAAM,WAAW,MAAM;AACvB,QAAM,eAAeA,YAAW,KAAK,EAAE;AAEvC,SAAO,gCAAgC;AAAA,IACrC,SAAS,SAAS;AAAA,IAClB,oBAAoB,MAClB,SAAS,4BAA4B,EAAE,IAAI,CAAC,EAAC,WAAW,KAAI,OAAO;AAAA,MACjE,uBAAuB,+BAA+B;AAAA,QACpD,WAAW,aAAa;AAAA,QACxB,SAAS,aAAa;AAAA,QACtB,iBAAiB,aAAa;AAAA,QAC9B;AAAA,MACF,CAAC;AAAA,MACD,iBAAiB,KAAK;AAAA,MACtB,OAAO,KAAK;AAAA,MACZ,UAAU,KAAK;AAAA,MACf,kBAAkB,KAAK;AAAA,MACvB,cAAc,KAAK;AAAA,IACrB,EAAE;AAAA,EACN,CAAC;AACH;",
|
|
6
|
+
"names": ["getAnimationEntry", "getAnimationEntry", "privateAPI"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ISheet, ISheetObject } from '@unseenco/theatre-core';
|
|
2
|
+
import type { GsapTweenLike } from './gsapTypes';
|
|
3
|
+
export type RegisterGsapAnimationOptions = {
|
|
4
|
+
/** Theatre object label (shown after the `GSAP/` namespace). */
|
|
5
|
+
label: string;
|
|
6
|
+
/** Override namespace from {@link configureTheatreGsap}. */
|
|
7
|
+
namespace?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Stable id for this animation on the sheet object. When omitted, defaults to
|
|
10
|
+
* the sanitised sheet object key (e.g. `GSAP / Panel show`).
|
|
11
|
+
* Re-registering with the same id updates the registry entry in place.
|
|
12
|
+
*/
|
|
13
|
+
id?: string;
|
|
14
|
+
/** Clip length when adding to the sequence (defaults to tween duration). */
|
|
15
|
+
defaultDuration?: number;
|
|
16
|
+
/** Rebuild the timeline when native child timing edits fail. */
|
|
17
|
+
onRebuildTimeline?: () => GsapTweenLike;
|
|
18
|
+
};
|
|
19
|
+
export type RegisterGsapAnimationResult = {
|
|
20
|
+
id: string;
|
|
21
|
+
sheetObject: ISheetObject<{}>;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Registers a GSAP tween for Theatre sequence bridging and creates an outline
|
|
25
|
+
* proxy object under `GSAP/<label>` (namespace configurable).
|
|
26
|
+
*
|
|
27
|
+
* The animation is paused immediately so Theatre can drive progress.
|
|
28
|
+
*/
|
|
29
|
+
export declare function registerGsapAnimation(animation: GsapTweenLike, sheet: ISheet, options: RegisterGsapAnimationOptions): RegisterGsapAnimationResult;
|
|
30
|
+
//# sourceMappingURL=registerGsapAnimation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registerGsapAnimation.d.ts","sourceRoot":"","sources":["../src/registerGsapAnimation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAE,YAAY,EAAC,MAAM,wBAAwB,CAAA;AAChE,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,aAAa,CAAA;AAQ9C,MAAM,MAAM,4BAA4B,GAAG;IACzC,gEAAgE;IAChE,KAAK,EAAE,MAAM,CAAA;IACb,4DAA4D;IAC5D,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;;OAIG;IACH,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,4EAA4E;IAC5E,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,gEAAgE;IAChE,iBAAiB,CAAC,EAAE,MAAM,aAAa,CAAA;CACxC,CAAA;AAED,MAAM,MAAM,2BAA2B,GAAG;IACxC,EAAE,EAAE,MAAM,CAAA;IACV,WAAW,EAAE,YAAY,CAAC,EAAE,CAAC,CAAA;CAC9B,CAAA;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,aAAa,EACxB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,4BAA4B,GACpC,2BAA2B,CA8B7B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
|
|
2
|
+
// It should be published with your NPM package. It should not be tracked by Git.
|
|
3
|
+
{
|
|
4
|
+
"tsdocVersion": "0.12",
|
|
5
|
+
"toolPackages": [
|
|
6
|
+
{
|
|
7
|
+
"packageName": "@microsoft/api-extractor",
|
|
8
|
+
"packageVersion": "7.18.11"
|
|
9
|
+
}
|
|
10
|
+
]
|
|
11
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@unseenco/theatre-gsap",
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"license": "AGPL-3.0-only",
|
|
5
|
+
"description": "GSAP time-mode bridge for Theatre.js",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "Aria Minaei",
|
|
8
|
+
"email": "aria@theatrejs.com",
|
|
9
|
+
"url": "https://github.com/AriaMinaei"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/craftedbygc/theatre",
|
|
14
|
+
"directory": "packages/gsap"
|
|
15
|
+
},
|
|
16
|
+
"main": "dist/index.js",
|
|
17
|
+
"module": "dist/index.mjs",
|
|
18
|
+
"types": "dist/index.d.ts",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"import": "./dist/index.mjs",
|
|
23
|
+
"require": "./dist/index.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"sideEffects": false,
|
|
27
|
+
"files": [
|
|
28
|
+
"dist/**/*"
|
|
29
|
+
],
|
|
30
|
+
"scripts": {
|
|
31
|
+
"prepack": "node ../../devEnv/ensurePublishing.js",
|
|
32
|
+
"typecheck": "yarn run build:ts",
|
|
33
|
+
"build": "run-s build:ts build:js build:api-json",
|
|
34
|
+
"build:ts": "tsc --build ./tsconfig.json",
|
|
35
|
+
"build:js": "node -r esbuild-register ./devEnv/build.ts",
|
|
36
|
+
"build:api-json": "api-extractor run --local --config devEnv/api-extractor.json",
|
|
37
|
+
"prepublish": "node ../../devEnv/ensurePublishing.js",
|
|
38
|
+
"clean": "rm -rf ./dist && rm -f tsconfig.tsbuildinfo"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@microsoft/api-extractor": "^7.18.11",
|
|
42
|
+
"@types/node": "^15.6.2",
|
|
43
|
+
"@unseenco/theatre-core": "0.4.0",
|
|
44
|
+
"esbuild": "^0.18.18",
|
|
45
|
+
"esbuild-register": "^2.5.0",
|
|
46
|
+
"gsap": "^3.12.5",
|
|
47
|
+
"npm-run-all": "^4.1.5",
|
|
48
|
+
"typescript": "5.1.6"
|
|
49
|
+
},
|
|
50
|
+
"peerDependencies": {
|
|
51
|
+
"@unseenco/theatre-core": "*",
|
|
52
|
+
"gsap": ">=3.0.0"
|
|
53
|
+
}
|
|
54
|
+
}
|