@unseenco/theatre-core 0.5.0 → 0.6.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/index.js CHANGED
@@ -278,7 +278,7 @@ __export(index_exports, {
278
278
  syncNativeDocumentScrollToSequencePosition: () => syncNativeDocumentScrollToSequencePosition,
279
279
  syncPageScrollToSequencePosition: () => syncPageScrollToSequencePosition,
280
280
  types: () => propTypes_exports,
281
- val: () => val12
281
+ val: () => val14
282
282
  });
283
283
  module.exports = __toCommonJS(index_exports);
284
284
 
@@ -322,7 +322,7 @@ __export(coreExports_exports, {
322
322
  syncNativeDocumentScrollToSequencePosition: () => syncNativeDocumentScrollToSequencePosition,
323
323
  syncPageScrollToSequencePosition: () => syncPageScrollToSequencePosition,
324
324
  types: () => propTypes_exports,
325
- val: () => val12
325
+ val: () => val14
326
326
  });
327
327
 
328
328
  // core/src/projects/projectsSingleton.ts
@@ -1014,7 +1014,7 @@ var SimpleCache = class {
1014
1014
  };
1015
1015
 
1016
1016
  // core/src/sheetObjects/SheetObjectTemplate.ts
1017
- var import_theatre_dataverse8 = require("@unseenco/theatre-dataverse");
1017
+ var import_theatre_dataverse9 = require("@unseenco/theatre-dataverse");
1018
1018
 
1019
1019
  // ../node_modules/lodash-es/_defineProperty.js
1020
1020
  var defineProperty = (function() {
@@ -1125,181 +1125,6 @@ function generateDefaultsForCompound(config) {
1125
1125
  return defaults;
1126
1126
  }
1127
1127
 
1128
- // core/src/sequences/interpolationTripleAtPosition.ts
1129
- var import_theatre_dataverse3 = require("@unseenco/theatre-dataverse");
1130
- var import_UnitBezier = __toESM(require_UnitBezier());
1131
- function interpolationTripleAtPosition(ctx, trackP, timeD) {
1132
- return (0, import_theatre_dataverse3.prism)(() => {
1133
- const track = (0, import_theatre_dataverse3.val)(trackP);
1134
- const driverD = import_theatre_dataverse3.prism.memo(
1135
- "driver",
1136
- () => {
1137
- if (!track) {
1138
- return (0, import_theatre_dataverse3.prism)(() => void 0);
1139
- } else if (track.type === "BasicKeyframedTrack") {
1140
- return _forKeyframedTrack(ctx, track, timeD);
1141
- } else if (track.type === "GsapClipTrack") {
1142
- return (0, import_theatre_dataverse3.prism)(() => void 0);
1143
- } else {
1144
- ctx.logger.error("Track type not yet supported.");
1145
- return (0, import_theatre_dataverse3.prism)(() => void 0);
1146
- }
1147
- },
1148
- [track]
1149
- );
1150
- return driverD.getValue();
1151
- });
1152
- }
1153
- function _forKeyframedTrack(ctx, track, timeD) {
1154
- return (0, import_theatre_dataverse3.prism)(() => {
1155
- let stateRef = import_theatre_dataverse3.prism.ref("state", { started: false });
1156
- let state = stateRef.current;
1157
- const time = timeD.getValue();
1158
- if (!state.started || time < state.validFrom || state.validTo <= time) {
1159
- stateRef.current = state = updateState(ctx, timeD, track);
1160
- }
1161
- return state.der.getValue();
1162
- });
1163
- }
1164
- var undefinedConstD = (0, import_theatre_dataverse3.prism)(() => void 0);
1165
- function updateState(ctx, progressionD, track) {
1166
- const progression = progressionD.getValue();
1167
- if (track.keyframes.length === 0) {
1168
- return {
1169
- started: true,
1170
- validFrom: -Infinity,
1171
- validTo: Infinity,
1172
- der: undefinedConstD
1173
- };
1174
- }
1175
- let currentKeyframeIndex = 0;
1176
- while (true) {
1177
- const currentKeyframe = track.keyframes[currentKeyframeIndex];
1178
- if (!currentKeyframe) {
1179
- if (process.env.NODE_ENV !== "production") {
1180
- ctx.logger.error("Bug here");
1181
- }
1182
- return states.error;
1183
- }
1184
- const isLastKeyframe = currentKeyframeIndex === track.keyframes.length - 1;
1185
- if (progression < currentKeyframe.position) {
1186
- if (currentKeyframeIndex === 0) {
1187
- return states.beforeFirstKeyframe(currentKeyframe);
1188
- } else {
1189
- if (process.env.NODE_ENV !== "production") {
1190
- ctx.logger.error("Bug here");
1191
- }
1192
- return states.error;
1193
- }
1194
- } else if (currentKeyframe.position === progression) {
1195
- if (isLastKeyframe) {
1196
- return states.lastKeyframe(currentKeyframe);
1197
- } else {
1198
- return states.between(
1199
- currentKeyframe,
1200
- track.keyframes[currentKeyframeIndex + 1],
1201
- progressionD
1202
- );
1203
- }
1204
- } else {
1205
- if (currentKeyframeIndex === track.keyframes.length - 1) {
1206
- return states.lastKeyframe(currentKeyframe);
1207
- } else {
1208
- const nextKeyframeIndex = currentKeyframeIndex + 1;
1209
- if (track.keyframes[nextKeyframeIndex].position <= progression) {
1210
- currentKeyframeIndex = nextKeyframeIndex;
1211
- continue;
1212
- } else {
1213
- return states.between(
1214
- currentKeyframe,
1215
- track.keyframes[currentKeyframeIndex + 1],
1216
- progressionD
1217
- );
1218
- }
1219
- }
1220
- }
1221
- }
1222
- }
1223
- var states = {
1224
- beforeFirstKeyframe(kf) {
1225
- return {
1226
- started: true,
1227
- validFrom: -Infinity,
1228
- validTo: kf.position,
1229
- der: (0, import_theatre_dataverse3.prism)(() => ({ left: kf.value, progression: 0 }))
1230
- };
1231
- },
1232
- lastKeyframe(kf) {
1233
- return {
1234
- started: true,
1235
- validFrom: kf.position,
1236
- validTo: Infinity,
1237
- der: (0, import_theatre_dataverse3.prism)(() => ({ left: kf.value, progression: 0 }))
1238
- };
1239
- },
1240
- between(left, right, progressionD) {
1241
- if (!left.connectedRight) {
1242
- return {
1243
- started: true,
1244
- validFrom: left.position,
1245
- validTo: right.position,
1246
- der: (0, import_theatre_dataverse3.prism)(() => ({ left: left.value, progression: 0 }))
1247
- };
1248
- }
1249
- const globalProgressionToLocalProgression = (globalProgression) => {
1250
- return (globalProgression - left.position) / (right.position - left.position);
1251
- };
1252
- if (!left.type || left.type === "bezier") {
1253
- const solver = new import_UnitBezier.default(
1254
- left.handles[2],
1255
- left.handles[3],
1256
- right.handles[0],
1257
- right.handles[1]
1258
- );
1259
- const bezierDer = (0, import_theatre_dataverse3.prism)(() => {
1260
- const progression = globalProgressionToLocalProgression(
1261
- progressionD.getValue()
1262
- );
1263
- const valueProgression = solver.solveSimple(progression);
1264
- return {
1265
- left: left.value,
1266
- right: right.value,
1267
- progression: valueProgression
1268
- };
1269
- });
1270
- return {
1271
- started: true,
1272
- validFrom: left.position,
1273
- validTo: right.position,
1274
- der: bezierDer
1275
- };
1276
- }
1277
- const holdDer = (0, import_theatre_dataverse3.prism)(() => {
1278
- const progression = globalProgressionToLocalProgression(
1279
- progressionD.getValue()
1280
- );
1281
- const valueProgression = Math.floor(progression);
1282
- return {
1283
- left: left.value,
1284
- right: right.value,
1285
- progression: valueProgression
1286
- };
1287
- });
1288
- return {
1289
- started: true,
1290
- validFrom: left.position,
1291
- validTo: right.position,
1292
- der: holdDer
1293
- };
1294
- },
1295
- error: {
1296
- started: true,
1297
- validFrom: -Infinity,
1298
- validTo: Infinity,
1299
- der: undefinedConstD
1300
- }
1301
- };
1302
-
1303
1128
  // shared/src/utils/deepMergeWithCache.ts
1304
1129
  function deepMergeWithCache(base, override, cache2) {
1305
1130
  const _cache = cache2;
@@ -1331,18 +1156,18 @@ function pointerDeep(base, toAppend) {
1331
1156
  }
1332
1157
 
1333
1158
  // shared/src/utils/valToAtom.ts
1334
- var import_theatre_dataverse4 = require("@unseenco/theatre-dataverse");
1159
+ var import_theatre_dataverse3 = require("@unseenco/theatre-dataverse");
1335
1160
  var valToAtom = (key, vals) => {
1336
- const a2 = import_theatre_dataverse4.prism.memo(key, () => new import_theatre_dataverse4.Atom(vals), []);
1161
+ const a2 = import_theatre_dataverse3.prism.memo(key, () => new import_theatre_dataverse3.Atom(vals), []);
1337
1162
  a2.set(vals);
1338
1163
  return a2;
1339
1164
  };
1340
1165
 
1341
1166
  // core/src/sheetObjects/SheetObject.ts
1342
- var import_theatre_dataverse7 = require("@unseenco/theatre-dataverse");
1167
+ var import_theatre_dataverse8 = require("@unseenco/theatre-dataverse");
1343
1168
 
1344
1169
  // core/src/sheetObjects/TheatreSheetObject.ts
1345
- var import_theatre_dataverse5 = require("@unseenco/theatre-dataverse");
1170
+ var import_theatre_dataverse4 = require("@unseenco/theatre-dataverse");
1346
1171
 
1347
1172
  // core/src/propTypes/index.ts
1348
1173
  var propTypes_exports = {};
@@ -3383,11 +3208,11 @@ function sanitizeCompoundProps(props) {
3383
3208
  );
3384
3209
  }
3385
3210
  }
3386
- const val13 = props[key];
3387
- if (isLonghandPropType(val13)) {
3388
- sanitizedProps[key] = val13;
3211
+ const val15 = props[key];
3212
+ if (isLonghandPropType(val15)) {
3213
+ sanitizedProps[key] = val15;
3389
3214
  } else {
3390
- sanitizedProps[key] = toLonghandProp(val13);
3215
+ sanitizedProps[key] = toLonghandProp(val15);
3391
3216
  }
3392
3217
  }
3393
3218
  return sanitizedProps;
@@ -3485,15 +3310,15 @@ var file = (defaultValue, opts = {}) => {
3485
3310
  deserializeAndSanitize: _ensureFile
3486
3311
  };
3487
3312
  };
3488
- var _ensureFile = (val13) => {
3489
- if (!val13) return void 0;
3313
+ var _ensureFile = (val15) => {
3314
+ if (!val15) return void 0;
3490
3315
  let valid = true;
3491
- if (typeof val13.id !== "string" && ![null, void 0].includes(val13.id)) {
3316
+ if (typeof val15.id !== "string" && ![null, void 0].includes(val15.id)) {
3492
3317
  valid = false;
3493
3318
  }
3494
- if (val13.type !== "file") valid = false;
3319
+ if (val15.type !== "file") valid = false;
3495
3320
  if (!valid) return void 0;
3496
- return val13;
3321
+ return val15;
3497
3322
  };
3498
3323
  var image = (defaultValue, opts = {}) => {
3499
3324
  if (process.env.NODE_ENV !== "production") {
@@ -3517,15 +3342,15 @@ var image = (defaultValue, opts = {}) => {
3517
3342
  deserializeAndSanitize: _ensureImage
3518
3343
  };
3519
3344
  };
3520
- var _ensureImage = (val13) => {
3521
- if (!val13) return void 0;
3345
+ var _ensureImage = (val15) => {
3346
+ if (!val15) return void 0;
3522
3347
  let valid = true;
3523
- if (typeof val13.id !== "string" && ![null, void 0].includes(val13.id)) {
3348
+ if (typeof val15.id !== "string" && ![null, void 0].includes(val15.id)) {
3524
3349
  valid = false;
3525
3350
  }
3526
- if (val13.type !== "image") valid = false;
3351
+ if (val15.type !== "image") valid = false;
3527
3352
  if (!valid) return void 0;
3528
- return val13;
3353
+ return val15;
3529
3354
  };
3530
3355
  var number = (defaultValue, opts = {}) => {
3531
3356
  if (process.env.NODE_ENV !== "production") {
@@ -3648,11 +3473,11 @@ var rgba = (defaultValue = { r: 0, g: 0, b: 0, a: 1 }, opts = {}) => {
3648
3473
  deserializeAndSanitize: _sanitizeRgba
3649
3474
  };
3650
3475
  };
3651
- var _sanitizeRgba = (val13) => {
3652
- if (!val13) return void 0;
3476
+ var _sanitizeRgba = (val15) => {
3477
+ if (!val15) return void 0;
3653
3478
  let valid = true;
3654
3479
  for (const c2 of ["r", "g", "b", "a"]) {
3655
- if (!Object.prototype.hasOwnProperty.call(val13, c2) || typeof val13[c2] !== "number") {
3480
+ if (!Object.prototype.hasOwnProperty.call(val15, c2) || typeof val15[c2] !== "number") {
3656
3481
  valid = false;
3657
3482
  }
3658
3483
  }
@@ -3661,7 +3486,7 @@ var _sanitizeRgba = (val13) => {
3661
3486
  for (const c2 of ["r", "g", "b", "a"]) {
3662
3487
  ;
3663
3488
  sanitized[c2] = Math.min(
3664
- Math.max(val13[c2], 0),
3489
+ Math.max(val15[c2], 0),
3665
3490
  1
3666
3491
  );
3667
3492
  }
@@ -3700,8 +3525,8 @@ var boolean = (defaultValue, opts = {}) => {
3700
3525
  deserializeAndSanitize: _ensureBoolean
3701
3526
  };
3702
3527
  };
3703
- var _ensureBoolean = (val13) => {
3704
- return typeof val13 === "boolean" ? val13 : void 0;
3528
+ var _ensureBoolean = (val15) => {
3529
+ return typeof val15 === "boolean" ? val15 : void 0;
3705
3530
  };
3706
3531
  function leftInterpolate(left) {
3707
3532
  return left;
@@ -3859,8 +3684,8 @@ var TheatreSheetObject = class {
3859
3684
  _valuesPrism() {
3860
3685
  return this._cache.get("_valuesPrism", () => {
3861
3686
  const sheetObject = privateAPI(this);
3862
- const d2 = (0, import_theatre_dataverse5.prism)(() => {
3863
- return (0, import_theatre_dataverse5.val)(sheetObject.getValues().getValue());
3687
+ const d2 = (0, import_theatre_dataverse4.prism)(() => {
3688
+ return (0, import_theatre_dataverse4.val)(sheetObject.getValues().getValue());
3864
3689
  });
3865
3690
  return d2;
3866
3691
  });
@@ -3868,10 +3693,10 @@ var TheatreSheetObject = class {
3868
3693
  _valuesWithVariantPrism() {
3869
3694
  return this._cache.get("_valuesWithVariantPrism", () => {
3870
3695
  const sheetObject = privateAPI(this);
3871
- return (0, import_theatre_dataverse5.prism)(() => {
3696
+ return (0, import_theatre_dataverse4.prism)(() => {
3872
3697
  return {
3873
- values: (0, import_theatre_dataverse5.val)(sheetObject.getValues().getValue()),
3874
- variant: (0, import_theatre_dataverse5.val)(sheetObject.sheet.effectiveActiveSequenceVariantD)
3698
+ values: (0, import_theatre_dataverse4.val)(sheetObject.getValues().getValue()),
3699
+ variant: (0, import_theatre_dataverse4.val)(sheetObject.sheet.effectiveActiveSequenceVariantD)
3875
3700
  };
3876
3701
  });
3877
3702
  });
@@ -3908,8 +3733,8 @@ var TheatreSheetObject = class {
3908
3733
  }
3909
3734
  return der.getValue();
3910
3735
  }
3911
- set initialValue(val13) {
3912
- privateAPI(this).setInitialValue(val13);
3736
+ set initialValue(val15) {
3737
+ privateAPI(this).setInitialValue(val15);
3913
3738
  }
3914
3739
  showPropsOf(objects) {
3915
3740
  const host = privateAPI(this);
@@ -3949,54 +3774,232 @@ var TheatreSheetObject = class {
3949
3774
  }
3950
3775
  };
3951
3776
 
3952
- // shared/src/propTypes/utils.ts
3953
- var import_fast_deep_equal = __toESM(require_fast_deep_equal());
3954
-
3955
- // shared/src/utils/memoizeFn.ts
3956
- function memoizeFn(producer) {
3957
- const cache2 = /* @__PURE__ */ new WeakMap();
3958
- return (k2) => {
3959
- if (!cache2.has(k2)) {
3960
- cache2.set(k2, producer(k2));
3961
- }
3962
- return cache2.get(k2);
3963
- };
3777
+ // core/src/sequences/interpolationTripleAtPosition.ts
3778
+ var import_theatre_dataverse5 = require("@unseenco/theatre-dataverse");
3779
+ var import_UnitBezier = __toESM(require_UnitBezier());
3780
+ function interpolationTripleAtPosition(ctx, trackP, timeD) {
3781
+ return (0, import_theatre_dataverse5.prism)(() => {
3782
+ const track = (0, import_theatre_dataverse5.val)(trackP);
3783
+ const driverD = import_theatre_dataverse5.prism.memo(
3784
+ "driver",
3785
+ () => {
3786
+ if (!track) {
3787
+ return (0, import_theatre_dataverse5.prism)(() => void 0);
3788
+ } else if (track.type === "BasicKeyframedTrack") {
3789
+ return _forKeyframedTrack(ctx, track, timeD);
3790
+ } else if (track.type === "GsapClipTrack") {
3791
+ return (0, import_theatre_dataverse5.prism)(() => void 0);
3792
+ } else {
3793
+ ctx.logger.error("Track type not yet supported.");
3794
+ return (0, import_theatre_dataverse5.prism)(() => void 0);
3795
+ }
3796
+ },
3797
+ [track]
3798
+ );
3799
+ return driverD.getValue();
3800
+ });
3964
3801
  }
3965
-
3966
- // shared/src/utils/addresses.ts
3967
- var encodePathToProp = memoizeFn(
3968
- (p2) => (
3969
- // we're using JSON.stringify here, but we could use a faster alternative.
3970
- // If you happen to do that, first make sure no `PathToProp_Encoded` is ever
3971
- // used in the store, otherwise you'll have to write a migration.
3972
- JSON.stringify(p2)
3973
- )
3974
- );
3975
-
3976
- // shared/src/utils/removePathFromObject.ts
3977
- function removePathFromObject(base, path) {
3978
- if (typeof base !== "object" || base === null) return;
3979
- if (path.length === 0) {
3980
- for (const key of Object.keys(base)) {
3981
- delete base[key];
3802
+ function _forKeyframedTrack(ctx, track, timeD) {
3803
+ return (0, import_theatre_dataverse5.prism)(() => {
3804
+ let stateRef = import_theatre_dataverse5.prism.ref("state", { started: false });
3805
+ let state = stateRef.current;
3806
+ const time = timeD.getValue();
3807
+ if (!state.started || time < state.validFrom || state.validTo <= time) {
3808
+ stateRef.current = state = updateState(ctx, timeD, track);
3982
3809
  }
3983
- return;
3810
+ return state.der.getValue();
3811
+ });
3812
+ }
3813
+ var undefinedConstD = (0, import_theatre_dataverse5.prism)(() => void 0);
3814
+ function updateState(ctx, progressionD, track) {
3815
+ const progression = progressionD.getValue();
3816
+ if (track.keyframes.length === 0) {
3817
+ return {
3818
+ started: true,
3819
+ validFrom: -Infinity,
3820
+ validTo: Infinity,
3821
+ der: undefinedConstD
3822
+ };
3984
3823
  }
3985
- const keysUpToLastKey = path.slice(0, path.length - 1);
3986
- let cur = base;
3987
- const childToParentMapping = /* @__PURE__ */ new WeakMap();
3988
- for (const key of keysUpToLastKey) {
3989
- const parent2 = cur;
3990
- const child = parent2[key];
3991
- if (typeof child !== "object" || child === null) {
3992
- return;
3993
- } else {
3994
- childToParentMapping.set(child, parent2);
3995
- cur = child;
3824
+ let currentKeyframeIndex = 0;
3825
+ while (true) {
3826
+ const currentKeyframe = track.keyframes[currentKeyframeIndex];
3827
+ if (!currentKeyframe) {
3828
+ if (process.env.NODE_ENV !== "production") {
3829
+ ctx.logger.error("Bug here");
3830
+ }
3831
+ return states.error;
3996
3832
  }
3997
- }
3998
- const keysReversed = path.slice().reverse();
3999
- for (const key of keysReversed) {
3833
+ const isLastKeyframe = currentKeyframeIndex === track.keyframes.length - 1;
3834
+ if (progression < currentKeyframe.position) {
3835
+ if (currentKeyframeIndex === 0) {
3836
+ return states.beforeFirstKeyframe(currentKeyframe);
3837
+ } else {
3838
+ if (process.env.NODE_ENV !== "production") {
3839
+ ctx.logger.error("Bug here");
3840
+ }
3841
+ return states.error;
3842
+ }
3843
+ } else if (currentKeyframe.position === progression) {
3844
+ if (isLastKeyframe) {
3845
+ return states.lastKeyframe(currentKeyframe);
3846
+ } else {
3847
+ return states.between(
3848
+ currentKeyframe,
3849
+ track.keyframes[currentKeyframeIndex + 1],
3850
+ progressionD
3851
+ );
3852
+ }
3853
+ } else {
3854
+ if (currentKeyframeIndex === track.keyframes.length - 1) {
3855
+ return states.lastKeyframe(currentKeyframe);
3856
+ } else {
3857
+ const nextKeyframeIndex = currentKeyframeIndex + 1;
3858
+ if (track.keyframes[nextKeyframeIndex].position <= progression) {
3859
+ currentKeyframeIndex = nextKeyframeIndex;
3860
+ continue;
3861
+ } else {
3862
+ return states.between(
3863
+ currentKeyframe,
3864
+ track.keyframes[currentKeyframeIndex + 1],
3865
+ progressionD
3866
+ );
3867
+ }
3868
+ }
3869
+ }
3870
+ }
3871
+ }
3872
+ var states = {
3873
+ beforeFirstKeyframe(kf) {
3874
+ return {
3875
+ started: true,
3876
+ validFrom: -Infinity,
3877
+ validTo: kf.position,
3878
+ der: (0, import_theatre_dataverse5.prism)(() => ({ left: kf.value, progression: 0 }))
3879
+ };
3880
+ },
3881
+ lastKeyframe(kf) {
3882
+ return {
3883
+ started: true,
3884
+ validFrom: kf.position,
3885
+ validTo: Infinity,
3886
+ der: (0, import_theatre_dataverse5.prism)(() => ({ left: kf.value, progression: 0 }))
3887
+ };
3888
+ },
3889
+ between(left, right, progressionD) {
3890
+ if (!left.connectedRight) {
3891
+ return {
3892
+ started: true,
3893
+ validFrom: left.position,
3894
+ validTo: right.position,
3895
+ der: (0, import_theatre_dataverse5.prism)(() => ({ left: left.value, progression: 0 }))
3896
+ };
3897
+ }
3898
+ const globalProgressionToLocalProgression = (globalProgression) => {
3899
+ return (globalProgression - left.position) / (right.position - left.position);
3900
+ };
3901
+ if (!left.type || left.type === "bezier") {
3902
+ const solver = new import_UnitBezier.default(
3903
+ left.handles[2],
3904
+ left.handles[3],
3905
+ right.handles[0],
3906
+ right.handles[1]
3907
+ );
3908
+ const bezierDer = (0, import_theatre_dataverse5.prism)(() => {
3909
+ const progression = globalProgressionToLocalProgression(
3910
+ progressionD.getValue()
3911
+ );
3912
+ const valueProgression = solver.solveSimple(progression);
3913
+ return {
3914
+ left: left.value,
3915
+ right: right.value,
3916
+ progression: valueProgression
3917
+ };
3918
+ });
3919
+ return {
3920
+ started: true,
3921
+ validFrom: left.position,
3922
+ validTo: right.position,
3923
+ der: bezierDer
3924
+ };
3925
+ }
3926
+ const holdDer = (0, import_theatre_dataverse5.prism)(() => {
3927
+ const progression = globalProgressionToLocalProgression(
3928
+ progressionD.getValue()
3929
+ );
3930
+ const valueProgression = Math.floor(progression);
3931
+ return {
3932
+ left: left.value,
3933
+ right: right.value,
3934
+ progression: valueProgression
3935
+ };
3936
+ });
3937
+ return {
3938
+ started: true,
3939
+ validFrom: left.position,
3940
+ validTo: right.position,
3941
+ der: holdDer
3942
+ };
3943
+ },
3944
+ error: {
3945
+ started: true,
3946
+ validFrom: -Infinity,
3947
+ validTo: Infinity,
3948
+ der: undefinedConstD
3949
+ }
3950
+ };
3951
+
3952
+ // core/src/sheetObjects/sheetObjectSequencedFull.ts
3953
+ var import_theatre_dataverse7 = require("@unseenco/theatre-dataverse");
3954
+
3955
+ // shared/src/propTypes/utils.ts
3956
+ var import_fast_deep_equal = __toESM(require_fast_deep_equal());
3957
+
3958
+ // shared/src/utils/memoizeFn.ts
3959
+ function memoizeFn(producer) {
3960
+ const cache2 = /* @__PURE__ */ new WeakMap();
3961
+ return (k2) => {
3962
+ if (!cache2.has(k2)) {
3963
+ cache2.set(k2, producer(k2));
3964
+ }
3965
+ return cache2.get(k2);
3966
+ };
3967
+ }
3968
+
3969
+ // shared/src/utils/addresses.ts
3970
+ var encodePathToProp = memoizeFn(
3971
+ (p2) => (
3972
+ // we're using JSON.stringify here, but we could use a faster alternative.
3973
+ // If you happen to do that, first make sure no `PathToProp_Encoded` is ever
3974
+ // used in the store, otherwise you'll have to write a migration.
3975
+ JSON.stringify(p2)
3976
+ )
3977
+ );
3978
+
3979
+ // shared/src/utils/removePathFromObject.ts
3980
+ function removePathFromObject(base, path) {
3981
+ if (typeof base !== "object" || base === null) return;
3982
+ if (path.length === 0) {
3983
+ for (const key of Object.keys(base)) {
3984
+ delete base[key];
3985
+ }
3986
+ return;
3987
+ }
3988
+ const keysUpToLastKey = path.slice(0, path.length - 1);
3989
+ let cur = base;
3990
+ const childToParentMapping = /* @__PURE__ */ new WeakMap();
3991
+ for (const key of keysUpToLastKey) {
3992
+ const parent2 = cur;
3993
+ const child = parent2[key];
3994
+ if (typeof child !== "object" || child === null) {
3995
+ return;
3996
+ } else {
3997
+ childToParentMapping.set(child, parent2);
3998
+ cur = child;
3999
+ }
4000
+ }
4001
+ const keysReversed = path.slice().reverse();
4002
+ for (const key of keysReversed) {
4000
4003
  delete cur[key];
4001
4004
  if (Object.keys(cur).length > 0) {
4002
4005
  return;
@@ -4266,43 +4269,6 @@ function* iteratePropType(conf, pathPrefix) {
4266
4269
  }
4267
4270
  }
4268
4271
 
4269
- // shared/src/utils/updateDeep.ts
4270
- function updateDeep(obj, path, reducer) {
4271
- if (path.length === 0) return reducer(obj);
4272
- return hoop(obj, path, reducer);
4273
- }
4274
- var hoop = (s2, path, reducer) => {
4275
- if (path.length === 0) {
4276
- return reducer(s2);
4277
- }
4278
- if (Array.isArray(s2)) {
4279
- let [index, ...restOfPath] = path;
4280
- index = parseInt(String(index), 10);
4281
- if (isNaN(index)) index = 0;
4282
- const oldVal = s2[index];
4283
- const newVal = hoop(oldVal, restOfPath, reducer);
4284
- if (oldVal === newVal) return s2;
4285
- const newS = [...s2];
4286
- newS.splice(index, 1, newVal);
4287
- return newS;
4288
- } else if (typeof s2 === "object" && s2 !== null) {
4289
- const [key, ...restOfPath] = path;
4290
- const oldVal = s2[key];
4291
- const newVal = hoop(oldVal, restOfPath, reducer);
4292
- if (oldVal === newVal) return s2;
4293
- const newS = { ...s2, [key]: newVal };
4294
- return newS;
4295
- } else {
4296
- const [key, ...restOfPath] = path;
4297
- return { [key]: hoop(void 0, restOfPath, reducer) };
4298
- }
4299
- };
4300
-
4301
- // shared/src/utils/setDeepImmutable.ts
4302
- function setDeepImmutable(obj, path, replace) {
4303
- return updateDeep(obj, path, () => replace);
4304
- }
4305
-
4306
4272
  // core/src/sequences/sequenceVariants.ts
4307
4273
  var import_theatre_dataverse6 = require("@unseenco/theatre-dataverse");
4308
4274
 
@@ -4456,53 +4422,185 @@ function validateSequenceVariantsOrThrow(variants, fnName) {
4456
4422
  return sanitized;
4457
4423
  }
4458
4424
 
4459
- // core/src/sheetObjects/SheetObject.ts
4460
- var SheetObject = class {
4461
- constructor(sheet, template, nativeObject) {
4462
- this.sheet = sheet;
4463
- this.template = template;
4464
- this.nativeObject = nativeObject;
4465
- __publicField(this, "$$isPointerToPrismProvider", true);
4466
- __publicField(this, "address");
4467
- __publicField(this, "publicApi");
4468
- __publicField(this, "_initialValue", new import_theatre_dataverse7.Atom({}));
4469
- /**
4470
- * Highest-priority override layer, written to by `RemoteSync` when a value
4471
- * update arrives from a remote editor window (see `internal/RemoteSync.ts`).
4472
- * Empty (`{}`) unless a remote editor is actually connected, so it's a
4473
- * no-op merge for every app that never uses the remote-sync feature.
4474
- */
4475
- __publicField(this, "_remoteOverride", new import_theatre_dataverse7.Atom({}));
4476
- /**
4477
- * Session-only overrides for props with `persist: false`. Not written to
4478
- * persisted project state and cleared on refresh.
4479
- */
4480
- __publicField(this, "_sessionOverrides", new import_theatre_dataverse7.Atom({}));
4481
- __publicField(this, "_cache", new SimpleCache());
4482
- __publicField(this, "_logger");
4483
- __publicField(this, "_internalUtilCtx");
4484
- this._logger = sheet._logger.named(
4485
- "SheetObject",
4486
- template.address.objectKey
4425
+ // core/src/sheetObjects/sheetObjectSequencedFull.ts
4426
+ function trackIdToPrism(obj, trackId, trackVariant) {
4427
+ const activeVariant = (0, import_theatre_dataverse7.val)(obj.sheet.effectiveActiveSequenceVariantD);
4428
+ const trackP = pointerToSequenceTrackData(
4429
+ obj.template.project.pointers.historic.sheetsById[obj.address.sheetId],
4430
+ trackVariant,
4431
+ obj.address.objectKey,
4432
+ trackId
4433
+ );
4434
+ const timeD = obj.sheet.getSequence(activeVariant).positionPrism;
4435
+ return interpolationTripleAtPosition(obj._internalUtilCtx, trackP, timeD);
4436
+ }
4437
+ function getSequencedValues(obj) {
4438
+ return (0, import_theatre_dataverse7.prism)(() => {
4439
+ const activeVariant = (0, import_theatre_dataverse7.val)(obj.sheet.effectiveActiveSequenceVariantD);
4440
+ const sequenceVariant = isSheetPropsObjectKey(obj.address.objectKey) ? DEFAULT_SEQUENCE_VARIANT : activeVariant;
4441
+ const tracksToProcessD = import_theatre_dataverse7.prism.memo(
4442
+ "tracksToProcess",
4443
+ () => obj.template.getArrayOfValidSequenceTracks(sequenceVariant),
4444
+ [sequenceVariant]
4487
4445
  );
4488
- this._logger._trace("creating object");
4489
- this._internalUtilCtx = { logger: this._logger.utilFor.internal() };
4490
- this.address = {
4491
- ...template.address,
4492
- sheetInstanceId: sheet.address.sheetInstanceId
4493
- };
4494
- this.publicApi = new TheatreSheetObject(this);
4446
+ const tracksToProcess = (0, import_theatre_dataverse7.val)(tracksToProcessD);
4447
+ const valsAtom = new import_theatre_dataverse7.Atom({});
4448
+ const config = (0, import_theatre_dataverse7.val)(obj.template.configPointer);
4449
+ import_theatre_dataverse7.prism.effect(
4450
+ "processTracks",
4451
+ () => {
4452
+ const untaps = [];
4453
+ for (const { trackId, pathToProp, trackVariant } of tracksToProcess) {
4454
+ if (obj.template.isNonSequencablePropPath(pathToProp)) continue;
4455
+ const pr = trackIdToPrism(obj, trackId, trackVariant);
4456
+ const propConfig = getPropConfigByPath(
4457
+ config,
4458
+ pathToProp
4459
+ );
4460
+ const deserializeAndSanitize = propConfig.deserializeAndSanitize;
4461
+ const interpolate = propConfig.interpolate;
4462
+ const updateSequenceValueFromItsPrism = () => {
4463
+ const triple = pr.getValue();
4464
+ if (!triple)
4465
+ return valsAtom.setByPointer(
4466
+ (p2) => pointerDeep(p2, pathToProp),
4467
+ void 0
4468
+ );
4469
+ const leftDeserialized = deserializeAndSanitize(triple.left);
4470
+ const left = leftDeserialized === void 0 ? propConfig.default : leftDeserialized;
4471
+ if (triple.right === void 0)
4472
+ return valsAtom.setByPointer(
4473
+ (p2) => pointerDeep(p2, pathToProp),
4474
+ left
4475
+ );
4476
+ const rightDeserialized = deserializeAndSanitize(triple.right);
4477
+ const right = rightDeserialized === void 0 ? propConfig.default : rightDeserialized;
4478
+ return valsAtom.setByPointer(
4479
+ (p2) => pointerDeep(p2, pathToProp),
4480
+ interpolate(left, right, triple.progression)
4481
+ );
4482
+ };
4483
+ const untap = pr.onStale(updateSequenceValueFromItsPrism);
4484
+ updateSequenceValueFromItsPrism();
4485
+ untaps.push(untap);
4486
+ }
4487
+ return () => {
4488
+ for (const untap of untaps) {
4489
+ untap();
4490
+ }
4491
+ };
4492
+ },
4493
+ [config, ...tracksToProcess]
4494
+ );
4495
+ return valsAtom.pointer;
4496
+ });
4497
+ }
4498
+ function mergeSequencedValuesIntoFinal(obj, base, withSeqsCache) {
4499
+ const pointerToSequencedValuesD = import_theatre_dataverse7.prism.memo(
4500
+ "seq",
4501
+ () => getSequencedValues(obj),
4502
+ []
4503
+ );
4504
+ const sequenced = (0, import_theatre_dataverse7.val)((0, import_theatre_dataverse7.val)(pointerToSequencedValuesD));
4505
+ return deepMergeWithCache(base, sequenced, withSeqsCache);
4506
+ }
4507
+
4508
+ // core/src/utils/isTheatreLiteMode.ts
4509
+ function isTheatreLiteMode() {
4510
+ if (false) {
4511
+ return true;
4495
4512
  }
4496
- get type() {
4513
+ if (typeof globalThis !== "undefined") {
4514
+ return !!globalThis.__THEATRE_FORCE_LITE__;
4515
+ }
4516
+ return false;
4517
+ }
4518
+
4519
+ // shared/src/utils/updateDeep.ts
4520
+ function updateDeep(obj, path, reducer) {
4521
+ if (path.length === 0) return reducer(obj);
4522
+ return hoop(obj, path, reducer);
4523
+ }
4524
+ var hoop = (s2, path, reducer) => {
4525
+ if (path.length === 0) {
4526
+ return reducer(s2);
4527
+ }
4528
+ if (Array.isArray(s2)) {
4529
+ let [index, ...restOfPath] = path;
4530
+ index = parseInt(String(index), 10);
4531
+ if (isNaN(index)) index = 0;
4532
+ const oldVal = s2[index];
4533
+ const newVal = hoop(oldVal, restOfPath, reducer);
4534
+ if (oldVal === newVal) return s2;
4535
+ const newS = [...s2];
4536
+ newS.splice(index, 1, newVal);
4537
+ return newS;
4538
+ } else if (typeof s2 === "object" && s2 !== null) {
4539
+ const [key, ...restOfPath] = path;
4540
+ const oldVal = s2[key];
4541
+ const newVal = hoop(oldVal, restOfPath, reducer);
4542
+ if (oldVal === newVal) return s2;
4543
+ const newS = { ...s2, [key]: newVal };
4544
+ return newS;
4545
+ } else {
4546
+ const [key, ...restOfPath] = path;
4547
+ return { [key]: hoop(void 0, restOfPath, reducer) };
4548
+ }
4549
+ };
4550
+
4551
+ // shared/src/utils/setDeepImmutable.ts
4552
+ function setDeepImmutable(obj, path, replace) {
4553
+ return updateDeep(obj, path, () => replace);
4554
+ }
4555
+
4556
+ // core/src/sheetObjects/SheetObject.ts
4557
+ var SheetObject = class {
4558
+ constructor(sheet, template, nativeObject) {
4559
+ this.sheet = sheet;
4560
+ this.template = template;
4561
+ this.nativeObject = nativeObject;
4562
+ __publicField(this, "$$isPointerToPrismProvider", true);
4563
+ __publicField(this, "address");
4564
+ __publicField(this, "publicApi");
4565
+ __publicField(this, "_initialValue", new import_theatre_dataverse8.Atom({}));
4566
+ /**
4567
+ * Highest-priority override layer, written to by `RemoteSync` when a value
4568
+ * update arrives from a remote editor window (see `internal/RemoteSync.ts`).
4569
+ * Empty (`{}`) unless a remote editor is actually connected, so it's a
4570
+ * no-op merge for every app that never uses the remote-sync feature.
4571
+ */
4572
+ __publicField(this, "_remoteOverride", new import_theatre_dataverse8.Atom({}));
4573
+ /**
4574
+ * Session-only overrides for props with `persist: false`. Not written to
4575
+ * persisted project state and cleared on refresh.
4576
+ */
4577
+ __publicField(this, "_sessionOverrides", new import_theatre_dataverse8.Atom({}));
4578
+ __publicField(this, "_cache", new SimpleCache());
4579
+ __publicField(this, "_logger");
4580
+ /** @internal Used by `sheetObjectSequencedFull`. */
4581
+ __publicField(this, "_internalUtilCtx");
4582
+ this._logger = sheet._logger.named(
4583
+ "SheetObject",
4584
+ template.address.objectKey
4585
+ );
4586
+ this._logger._trace("creating object");
4587
+ this._internalUtilCtx = { logger: this._logger.utilFor.internal() };
4588
+ this.address = {
4589
+ ...template.address,
4590
+ sheetInstanceId: sheet.address.sheetInstanceId
4591
+ };
4592
+ this.publicApi = new TheatreSheetObject(this);
4593
+ }
4594
+ get type() {
4497
4595
  return "Theatre_SheetObject";
4498
4596
  }
4499
4597
  getValues() {
4500
4598
  return this._cache.get(
4501
4599
  "getValues()",
4502
- () => (0, import_theatre_dataverse7.prism)(() => {
4503
- const defaults = (0, import_theatre_dataverse7.val)(this.template.getDefaultValues());
4504
- const initial = (0, import_theatre_dataverse7.val)(this._initialValue.pointer);
4505
- const withInitialCache = import_theatre_dataverse7.prism.memo(
4600
+ () => (0, import_theatre_dataverse8.prism)(() => {
4601
+ const defaults = (0, import_theatre_dataverse8.val)(this.template.getDefaultValues());
4602
+ const initial = (0, import_theatre_dataverse8.val)(this._initialValue.pointer);
4603
+ const withInitialCache = import_theatre_dataverse8.prism.memo(
4506
4604
  "withInitialCache",
4507
4605
  () => /* @__PURE__ */ new WeakMap(),
4508
4606
  []
@@ -4512,8 +4610,8 @@ var SheetObject = class {
4512
4610
  initial,
4513
4611
  withInitialCache
4514
4612
  );
4515
- const ahistoricStatics = (0, import_theatre_dataverse7.val)(this.template.getAhistoricStaticValues());
4516
- const withAhistoricStaticsCache = import_theatre_dataverse7.prism.memo(
4613
+ const ahistoricStatics = (0, import_theatre_dataverse8.val)(this.template.getAhistoricStaticValues());
4614
+ const withAhistoricStaticsCache = import_theatre_dataverse8.prism.memo(
4517
4615
  "withAhistoricStatics",
4518
4616
  () => /* @__PURE__ */ new WeakMap(),
4519
4617
  []
@@ -4523,10 +4621,10 @@ var SheetObject = class {
4523
4621
  ahistoricStatics,
4524
4622
  withAhistoricStaticsCache
4525
4623
  );
4526
- const activeVariant = (0, import_theatre_dataverse7.val)(this.sheet.effectiveActiveSequenceVariantD);
4624
+ const activeVariant = (0, import_theatre_dataverse8.val)(this.sheet.effectiveActiveSequenceVariantD);
4527
4625
  const staticVariant = isSheetPropsObjectKey(this.address.objectKey) ? DEFAULT_SEQUENCE_VARIANT : activeVariant;
4528
- const statics = (0, import_theatre_dataverse7.val)(this.template.getStaticValues(staticVariant));
4529
- const withStaticsCache = import_theatre_dataverse7.prism.memo(
4626
+ const statics = (0, import_theatre_dataverse8.val)(this.template.getStaticValues(staticVariant));
4627
+ const withStaticsCache = import_theatre_dataverse8.prism.memo(
4530
4628
  "withStatics",
4531
4629
  () => /* @__PURE__ */ new WeakMap(),
4532
4630
  []
@@ -4537,24 +4635,16 @@ var SheetObject = class {
4537
4635
  withStaticsCache
4538
4636
  );
4539
4637
  let final = withStatics;
4540
- let sequenced;
4541
- {
4542
- const pointerToSequencedValuesD = import_theatre_dataverse7.prism.memo(
4543
- "seq",
4544
- () => this.getSequencedValues(),
4545
- []
4546
- );
4547
- const withSeqsCache = import_theatre_dataverse7.prism.memo(
4638
+ if (!isTheatreLiteMode()) {
4639
+ const withSeqsCache = import_theatre_dataverse8.prism.memo(
4548
4640
  "withSeqsCache",
4549
4641
  () => /* @__PURE__ */ new WeakMap(),
4550
4642
  []
4551
4643
  );
4552
- sequenced = (0, import_theatre_dataverse7.val)((0, import_theatre_dataverse7.val)(pointerToSequencedValuesD));
4553
- const withSeqs = deepMergeWithCache(final, sequenced, withSeqsCache);
4554
- final = withSeqs;
4644
+ final = mergeSequencedValuesIntoFinal(this, final, withSeqsCache);
4555
4645
  }
4556
- const sessionOverrides = (0, import_theatre_dataverse7.val)(this._sessionOverrides.pointer);
4557
- const withSessionOverridesCache = import_theatre_dataverse7.prism.memo(
4646
+ const sessionOverrides = (0, import_theatre_dataverse8.val)(this._sessionOverrides.pointer);
4647
+ const withSessionOverridesCache = import_theatre_dataverse8.prism.memo(
4558
4648
  "withSessionOverridesCache",
4559
4649
  () => /* @__PURE__ */ new WeakMap(),
4560
4650
  []
@@ -4564,8 +4654,8 @@ var SheetObject = class {
4564
4654
  sessionOverrides,
4565
4655
  withSessionOverridesCache
4566
4656
  );
4567
- const remoteOverride = (0, import_theatre_dataverse7.val)(this._remoteOverride.pointer);
4568
- const withRemoteOverrideCache = import_theatre_dataverse7.prism.memo(
4657
+ const remoteOverride = (0, import_theatre_dataverse8.val)(this._remoteOverride.pointer);
4658
+ const withRemoteOverrideCache = import_theatre_dataverse8.prism.memo(
4569
4659
  "withRemoteOverrideCache",
4570
4660
  () => /* @__PURE__ */ new WeakMap(),
4571
4661
  []
@@ -4580,106 +4670,31 @@ var SheetObject = class {
4580
4670
  })
4581
4671
  );
4582
4672
  }
4583
- getValueByPointer(pointer3) {
4584
- const allValuesP = (0, import_theatre_dataverse7.val)(this.getValues());
4585
- const { path } = (0, import_theatre_dataverse7.getPointerParts)(pointer3);
4586
- return (0, import_theatre_dataverse7.val)(
4673
+ getValueByPointer(pointer4) {
4674
+ const allValuesP = (0, import_theatre_dataverse8.val)(this.getValues());
4675
+ const { path } = (0, import_theatre_dataverse8.getPointerParts)(pointer4);
4676
+ return (0, import_theatre_dataverse8.val)(
4587
4677
  pointerDeep(allValuesP, path)
4588
4678
  );
4589
4679
  }
4590
- pointerToPrism(pointer3) {
4591
- const { path } = (0, import_theatre_dataverse7.getPointerParts)(pointer3);
4592
- return (0, import_theatre_dataverse7.prism)(() => {
4593
- const allValuesP = (0, import_theatre_dataverse7.val)(this.getValues());
4594
- return (0, import_theatre_dataverse7.val)(pointerDeep(allValuesP, path));
4595
- });
4596
- }
4597
- /**
4598
- * Returns values of props that are sequenced.
4599
- */
4600
- getSequencedValues() {
4601
- return (0, import_theatre_dataverse7.prism)(() => {
4602
- const activeVariant = (0, import_theatre_dataverse7.val)(this.sheet.effectiveActiveSequenceVariantD);
4603
- const sequenceVariant = isSheetPropsObjectKey(this.address.objectKey) ? DEFAULT_SEQUENCE_VARIANT : activeVariant;
4604
- const tracksToProcessD = import_theatre_dataverse7.prism.memo(
4605
- "tracksToProcess",
4606
- () => this.template.getArrayOfValidSequenceTracks(sequenceVariant),
4607
- [sequenceVariant]
4608
- );
4609
- const tracksToProcess = (0, import_theatre_dataverse7.val)(tracksToProcessD);
4610
- const valsAtom = new import_theatre_dataverse7.Atom({});
4611
- const config = (0, import_theatre_dataverse7.val)(this.template.configPointer);
4612
- import_theatre_dataverse7.prism.effect(
4613
- "processTracks",
4614
- () => {
4615
- const untaps = [];
4616
- for (const { trackId, pathToProp, trackVariant } of tracksToProcess) {
4617
- if (this.template.isNonSequencablePropPath(pathToProp)) continue;
4618
- const pr = this._trackIdToPrism(trackId, trackVariant);
4619
- const propConfig = getPropConfigByPath(
4620
- config,
4621
- pathToProp
4622
- );
4623
- const deserializeAndSanitize = propConfig.deserializeAndSanitize;
4624
- const interpolate = propConfig.interpolate;
4625
- const updateSequenceValueFromItsPrism = () => {
4626
- const triple = pr.getValue();
4627
- if (!triple)
4628
- return valsAtom.setByPointer(
4629
- (p2) => pointerDeep(p2, pathToProp),
4630
- void 0
4631
- );
4632
- const leftDeserialized = deserializeAndSanitize(triple.left);
4633
- const left = leftDeserialized === void 0 ? propConfig.default : leftDeserialized;
4634
- if (triple.right === void 0)
4635
- return valsAtom.setByPointer(
4636
- (p2) => pointerDeep(p2, pathToProp),
4637
- left
4638
- );
4639
- const rightDeserialized = deserializeAndSanitize(triple.right);
4640
- const right = rightDeserialized === void 0 ? propConfig.default : rightDeserialized;
4641
- return valsAtom.setByPointer(
4642
- (p2) => pointerDeep(p2, pathToProp),
4643
- interpolate(left, right, triple.progression)
4644
- );
4645
- };
4646
- const untap = pr.onStale(updateSequenceValueFromItsPrism);
4647
- updateSequenceValueFromItsPrism();
4648
- untaps.push(untap);
4649
- }
4650
- return () => {
4651
- for (const untap of untaps) {
4652
- untap();
4653
- }
4654
- };
4655
- },
4656
- [config, ...tracksToProcess]
4657
- );
4658
- return valsAtom.pointer;
4680
+ pointerToPrism(pointer4) {
4681
+ const { path } = (0, import_theatre_dataverse8.getPointerParts)(pointer4);
4682
+ return (0, import_theatre_dataverse8.prism)(() => {
4683
+ const allValuesP = (0, import_theatre_dataverse8.val)(this.getValues());
4684
+ return (0, import_theatre_dataverse8.val)(pointerDeep(allValuesP, path));
4659
4685
  });
4660
4686
  }
4661
- _trackIdToPrism(trackId, trackVariant) {
4662
- const activeVariant = (0, import_theatre_dataverse7.val)(this.sheet.effectiveActiveSequenceVariantD);
4663
- const trackP = pointerToSequenceTrackData(
4664
- this.template.project.pointers.historic.sheetsById[this.address.sheetId],
4665
- trackVariant,
4666
- this.address.objectKey,
4667
- trackId
4668
- );
4669
- const timeD = this.sheet.getSequence(activeVariant).positionPrism;
4670
- return interpolationTripleAtPosition(this._internalUtilCtx, trackP, timeD);
4671
- }
4672
4687
  get propsP() {
4673
4688
  return this._cache.get(
4674
4689
  "propsP",
4675
- () => (0, import_theatre_dataverse7.pointer)({ root: this, path: [] })
4690
+ () => (0, import_theatre_dataverse8.pointer)({ root: this, path: [] })
4676
4691
  );
4677
4692
  }
4678
- validateValue(pointer3, value) {
4693
+ validateValue(pointer4, value) {
4679
4694
  }
4680
- setInitialValue(val13) {
4681
- this.validateValue(this.propsP, val13);
4682
- this._initialValue.set(val13);
4695
+ setInitialValue(val15) {
4696
+ this.validateValue(this.propsP, val15);
4697
+ this._initialValue.set(val15);
4683
4698
  }
4684
4699
  setSessionOverride(path, value) {
4685
4700
  const propConfig = getPropConfigByPath(this.template.staticConfig, path);
@@ -4699,8 +4714,8 @@ var SheetObject = class {
4699
4714
  * Internal: called by `RemoteSync` when a value update for this object
4700
4715
  * arrives from a remote editor window. Not exposed on the public API.
4701
4716
  */
4702
- setRemoteOverride(val13) {
4703
- this._remoteOverride.set(val13);
4717
+ setRemoteOverride(val15) {
4718
+ this._remoteOverride.set(val15);
4704
4719
  }
4705
4720
  /**
4706
4721
  * Internal: used by `RemoteSync` to subscribe to this object's fully
@@ -4709,7 +4724,7 @@ var SheetObject = class {
4709
4724
  */
4710
4725
  onFinalValueChange(fn2) {
4711
4726
  return onChange(
4712
- (0, import_theatre_dataverse7.prism)(() => (0, import_theatre_dataverse7.val)(this.getValues().getValue())),
4727
+ (0, import_theatre_dataverse8.prism)(() => (0, import_theatre_dataverse8.val)(this.getValues().getValue())),
4713
4728
  fn2
4714
4729
  );
4715
4730
  }
@@ -5280,9 +5295,9 @@ var SheetObjectTemplate = class {
5280
5295
  config,
5281
5296
  sheetTemplate.project
5282
5297
  );
5283
- this._config = new import_theatre_dataverse8.Atom(configWithPrecisionDefaults);
5284
- this._temp_actions_atom = new import_theatre_dataverse8.Atom(_temp_actions);
5285
- this.showPropsOf_atom = new import_theatre_dataverse8.Atom([]);
5298
+ this._config = new import_theatre_dataverse9.Atom(configWithPrecisionDefaults);
5299
+ this._temp_actions_atom = new import_theatre_dataverse9.Atom(_temp_actions);
5300
+ this.showPropsOf_atom = new import_theatre_dataverse9.Atom([]);
5286
5301
  this._transientPropPaths = normalizeTransientPropPaths(
5287
5302
  transient,
5288
5303
  config,
@@ -5339,7 +5354,7 @@ var SheetObjectTemplate = class {
5339
5354
  return this.showPropsOf_atom.pointer;
5340
5355
  }
5341
5356
  _stripNonPersistingPropsFromAhistoricState() {
5342
- const config = (0, import_theatre_dataverse8.val)(this.configPointer);
5357
+ const config = (0, import_theatre_dataverse9.val)(this.configPointer);
5343
5358
  this.project._stripNonPersistingPropsFromAhistoric(
5344
5359
  this.address.sheetId,
5345
5360
  this.address.objectKey,
@@ -5468,8 +5483,8 @@ var SheetObjectTemplate = class {
5468
5483
  getDefaultValues() {
5469
5484
  return this._cache.get(
5470
5485
  "getDefaultValues()",
5471
- () => (0, import_theatre_dataverse8.prism)(() => {
5472
- const config = (0, import_theatre_dataverse8.val)(this.configPointer);
5486
+ () => (0, import_theatre_dataverse9.prism)(() => {
5487
+ const config = (0, import_theatre_dataverse9.val)(this.configPointer);
5473
5488
  return getPropDefaultsOfSheetObject(config);
5474
5489
  })
5475
5490
  );
@@ -5481,14 +5496,14 @@ var SheetObjectTemplate = class {
5481
5496
  getStaticValues(sequenceVariant = DEFAULT_SEQUENCE_VARIANT) {
5482
5497
  return this._cache.get(
5483
5498
  "getStaticValues:".concat(sequenceVariant),
5484
- () => (0, import_theatre_dataverse8.prism)(() => {
5485
- const sheetState = (0, import_theatre_dataverse8.val)(this.pointerToSheetState);
5499
+ () => (0, import_theatre_dataverse9.prism)(() => {
5500
+ const sheetState = (0, import_theatre_dataverse9.val)(this.pointerToSheetState);
5486
5501
  const json = getEffectiveStaticOverrideForObject(
5487
5502
  sheetState,
5488
5503
  sequenceVariant,
5489
5504
  this.address.objectKey
5490
5505
  ) ?? {};
5491
- const config = (0, import_theatre_dataverse8.val)(this.configPointer);
5506
+ const config = (0, import_theatre_dataverse9.val)(this.configPointer);
5492
5507
  const deserialized = config.deserializeAndSanitize(json) || {};
5493
5508
  const withoutNonPersisting = stripNonPersistingPropValuesFromMap(
5494
5509
  deserialized,
@@ -5511,9 +5526,9 @@ var SheetObjectTemplate = class {
5511
5526
  getAhistoricStaticValues() {
5512
5527
  return this._cache.get(
5513
5528
  "getAhistoricStaticValues",
5514
- () => (0, import_theatre_dataverse8.prism)(() => {
5515
- const json = (0, import_theatre_dataverse8.val)(this.pointerToAhistoricStaticOverrides) ?? {};
5516
- const config = (0, import_theatre_dataverse8.val)(this.configPointer);
5529
+ () => (0, import_theatre_dataverse9.prism)(() => {
5530
+ const json = (0, import_theatre_dataverse9.val)(this.pointerToAhistoricStaticOverrides) ?? {};
5531
+ const config = (0, import_theatre_dataverse9.val)(this.configPointer);
5517
5532
  const deserialized = config.deserializeAndSanitize(json) || {};
5518
5533
  return stripNonPersistingPropValuesFromMap(deserialized, config);
5519
5534
  })
@@ -5528,13 +5543,13 @@ var SheetObjectTemplate = class {
5528
5543
  getArrayOfValidSequenceTracks(sequenceVariant) {
5529
5544
  return this._cache.get(
5530
5545
  "getArrayOfValidSequenceTracks:".concat(sequenceVariant),
5531
- () => (0, import_theatre_dataverse8.prism)(
5546
+ () => (0, import_theatre_dataverse9.prism)(
5532
5547
  () => {
5533
5548
  const effectiveSequenceVariant = isSheetPropsObjectKey(
5534
5549
  this.address.objectKey
5535
5550
  ) ? DEFAULT_SEQUENCE_VARIANT : sequenceVariant;
5536
5551
  const pointerToSheetState = this.project.pointers.historic.sheetsById[this.address.sheetId];
5537
- (0, import_theatre_dataverse8.val)(pointerToSheetState.variantObjectOverrides);
5552
+ (0, import_theatre_dataverse9.val)(pointerToSheetState.variantObjectOverrides);
5538
5553
  const defaultTrackIdByPropPath = valTrackIdByPropPathForObject(
5539
5554
  pointerToSheetState,
5540
5555
  DEFAULT_SEQUENCE_VARIANT,
@@ -5560,7 +5575,7 @@ var SheetObjectTemplate = class {
5560
5575
  return emptyArray;
5561
5576
  }
5562
5577
  const arrayOfIds = [];
5563
- const objectConfig = (0, import_theatre_dataverse8.val)(this.configPointer);
5578
+ const objectConfig = (0, import_theatre_dataverse9.val)(this.configPointer);
5564
5579
  for (const [pathToPropInString, effectiveTrack] of Object.entries(
5565
5580
  mergedTrackMap
5566
5581
  )) {
@@ -5610,8 +5625,8 @@ var SheetObjectTemplate = class {
5610
5625
  getMapOfValidSequenceTracks_forStudio(sequenceVariant) {
5611
5626
  return this._cache.get(
5612
5627
  "getMapOfValidSequenceTracks_forStudio:".concat(sequenceVariant),
5613
- () => (0, import_theatre_dataverse8.prism)(() => {
5614
- const arr = (0, import_theatre_dataverse8.val)(this.getArrayOfValidSequenceTracks(sequenceVariant));
5628
+ () => (0, import_theatre_dataverse9.prism)(() => {
5629
+ const arr = (0, import_theatre_dataverse9.val)(this.getArrayOfValidSequenceTracks(sequenceVariant));
5615
5630
  let map = {};
5616
5631
  for (const { pathToProp, trackId } of arr) {
5617
5632
  set_default(map, pathToProp, trackId);
@@ -5631,9 +5646,9 @@ var SheetObjectTemplate = class {
5631
5646
  getStaticButNotSequencedOverrides(sequenceVariant) {
5632
5647
  return this._cache.get(
5633
5648
  "getStaticButNotSequencedOverrides:".concat(sequenceVariant),
5634
- () => (0, import_theatre_dataverse8.prism)(() => {
5635
- const staticOverrides = (0, import_theatre_dataverse8.val)(this.getStaticValues(sequenceVariant));
5636
- const arrayOfValidSequenceTracks = (0, import_theatre_dataverse8.val)(
5649
+ () => (0, import_theatre_dataverse9.prism)(() => {
5650
+ const staticOverrides = (0, import_theatre_dataverse9.val)(this.getStaticValues(sequenceVariant));
5651
+ const arrayOfValidSequenceTracks = (0, import_theatre_dataverse9.val)(
5637
5652
  this.getArrayOfValidSequenceTracks(sequenceVariant)
5638
5653
  );
5639
5654
  const staticButNotSequencedOverrides = cloneDeep_default(staticOverrides);
@@ -5658,8 +5673,8 @@ var SheetObjectTemplate = class {
5658
5673
  })
5659
5674
  );
5660
5675
  }
5661
- getDefaultsAtPointer(pointer3) {
5662
- const { path } = (0, import_theatre_dataverse8.getPointerParts)(pointer3);
5676
+ getDefaultsAtPointer(pointer4) {
5677
+ const { path } = (0, import_theatre_dataverse9.getPointerParts)(pointer4);
5663
5678
  const defaults = this.getDefaultValues().getValue();
5664
5679
  const defaultsAtPath = getDeep(defaults, path);
5665
5680
  return defaultsAtPath;
@@ -5680,247 +5695,81 @@ function parsePathToProp(pathToPropInString) {
5680
5695
  }
5681
5696
 
5682
5697
  // core/src/sheets/SheetTemplate.ts
5683
- var import_theatre_dataverse19 = require("@unseenco/theatre-dataverse");
5684
-
5685
- // shared/src/utils/didYouMean.ts
5686
- var import_propose = __toESM(require_propose());
5687
- function didYouMean(str, dictionary, prepend = "Did you mean ", append = "?") {
5688
- const p2 = (0, import_propose.default)(str, dictionary, {
5689
- threshold: 0.7
5690
- });
5691
- if (p2) {
5692
- return prepend + JSON.stringify(p2) + append;
5693
- } else {
5694
- return "";
5695
- }
5696
- }
5697
-
5698
- // core/src/sequences/Sequence.ts
5699
- var import_theatre_dataverse12 = require("@unseenco/theatre-dataverse");
5700
- var import_theatre_dataverse13 = require("@unseenco/theatre-dataverse");
5701
- var import_theatre_dataverse14 = require("@unseenco/theatre-dataverse");
5702
- var import_theatre_dataverse15 = require("@unseenco/theatre-dataverse");
5703
-
5704
- // shared/src/utils/defer.ts
5705
- function defer() {
5706
- let resolve;
5707
- let reject;
5708
- const promise = new Promise((rs, rj) => {
5709
- resolve = (v2) => {
5710
- rs(v2);
5711
- deferred.status = "resolved";
5712
- };
5713
- reject = (v2) => {
5714
- rj(v2);
5715
- deferred.status = "rejected";
5716
- };
5717
- });
5718
- const deferred = {
5719
- resolve,
5720
- reject,
5721
- promise,
5722
- status: "pending"
5723
- };
5724
- return deferred;
5725
- }
5698
+ var import_theatre_dataverse23 = require("@unseenco/theatre-dataverse");
5726
5699
 
5727
- // shared/src/utils/noop.ts
5728
- var noop = () => {
5729
- };
5730
- var noop_default = noop;
5700
+ // core/src/sequences/LiteSequence.ts
5701
+ var import_theatre_dataverse11 = require("@unseenco/theatre-dataverse");
5731
5702
 
5732
- // core/src/sequences/playbackControllers/DefaultPlaybackController.ts
5733
- var import_theatre_dataverse9 = require("@unseenco/theatre-dataverse");
5734
- var DefaultPlaybackController = class {
5703
+ // core/src/sequences/TheatreSequenceLite.ts
5704
+ var import_theatre_dataverse10 = require("@unseenco/theatre-dataverse");
5705
+ var LITE_DEFAULT_LENGTH = 10;
5706
+ var TheatreSequenceLite = class {
5735
5707
  constructor() {
5736
- __publicField(this, "_stopPlayCallback", noop_default);
5737
- __publicField(this, "_state", new import_theatre_dataverse9.Atom({
5738
- position: 0,
5739
- playing: false
5708
+ __publicField(this, "type", "Theatre_Sequence_PublicAPI");
5709
+ __publicField(this, "_state", new import_theatre_dataverse10.Atom({
5710
+ playing: false,
5711
+ length: LITE_DEFAULT_LENGTH,
5712
+ position: 0
5740
5713
  }));
5741
- __publicField(this, "statePointer");
5742
- this.statePointer = this._state.pointer;
5714
+ __publicField(this, "pointer", (0, import_theatre_dataverse10.pointer)({ root: this._state.pointer, path: [] }));
5743
5715
  }
5744
- destroy() {
5716
+ play() {
5717
+ return Promise.resolve(true);
5745
5718
  }
5746
5719
  pause() {
5747
- this._stopPlayCallback();
5748
- this.playing = false;
5749
- this._stopPlayCallback = noop_default;
5750
5720
  }
5751
- gotoPosition(time) {
5752
- this._updatePositionInState(time);
5721
+ get position() {
5722
+ return 0;
5753
5723
  }
5754
- _updatePositionInState(time) {
5755
- this._state.setByPointer((p2) => p2.position, time);
5724
+ set position(_position) {
5756
5725
  }
5757
- getCurrentPosition() {
5758
- return this._state.get().position;
5726
+ __experimental_getKeyframes(_prop) {
5727
+ return [];
5759
5728
  }
5760
- get playing() {
5761
- return this._state.get().playing;
5729
+ __experimental_getGsapClips() {
5730
+ return [];
5762
5731
  }
5763
- set playing(playing) {
5764
- this._state.setByPointer((p2) => p2.playing, playing);
5732
+ __experimental_getGsapScrollTriggers() {
5733
+ return [];
5765
5734
  }
5766
- play(iterationCount, range, rate, direction, ticker) {
5767
- if (this.playing) {
5768
- this.pause();
5735
+ attachAudio(_args) {
5736
+ return Promise.reject(
5737
+ new Error(
5738
+ "sequence.attachAudio() is not available in @unseenco/theatre-core-lite"
5739
+ )
5740
+ );
5741
+ }
5742
+ };
5743
+
5744
+ // core/src/sequences/LiteSequence.ts
5745
+ var LiteSequence = class {
5746
+ constructor() {
5747
+ __publicField(this, "publicApi", new TheatreSequenceLite());
5748
+ __publicField(this, "positionPrism", (0, import_theatre_dataverse11.prism)(() => 0));
5749
+ }
5750
+ pause() {
5751
+ }
5752
+ };
5753
+
5754
+ // shared/src/globalVariableNames.ts
5755
+ var studioBundle = "__TheatreJS_StudioBundle";
5756
+ var coreBundle = "__TheatreJS_CoreBundle";
5757
+ var notifications = "__TheatreJS_Notifications";
5758
+
5759
+ // shared/src/notify.ts
5760
+ var createHandler = (type) => (...args) => {
5761
+ switch (type) {
5762
+ case "success": {
5763
+ logger_default.debug(args.slice(0, 2).join("\n"));
5764
+ break;
5769
5765
  }
5770
- this.playing = true;
5771
- const iterationLength = range[1] - range[0];
5772
- {
5773
- const startPos = this.getCurrentPosition();
5774
- if (startPos < range[0] || startPos > range[1]) {
5775
- if (direction === "normal" || direction === "alternate") {
5776
- this._updatePositionInState(range[0]);
5777
- } else if (direction === "reverse" || direction === "alternateReverse") {
5778
- this._updatePositionInState(range[1]);
5779
- }
5780
- } else if (direction === "normal" || direction === "alternate") {
5781
- if (startPos === range[1]) {
5782
- this._updatePositionInState(range[0]);
5783
- }
5784
- } else {
5785
- if (startPos === range[0]) {
5786
- this._updatePositionInState(range[1]);
5787
- }
5788
- }
5766
+ case "info": {
5767
+ logger_default.debug(args.slice(0, 2).join("\n"));
5768
+ break;
5789
5769
  }
5790
- const deferred = defer();
5791
- const initialTickerTime = ticker.time;
5792
- const totalPlaybackLength = iterationLength * iterationCount;
5793
- let initialElapsedPos = this.getCurrentPosition() - range[0];
5794
- if (direction === "reverse" || direction === "alternateReverse") {
5795
- initialElapsedPos = range[1] - this.getCurrentPosition();
5796
- }
5797
- const tick = (currentTickerTime) => {
5798
- const elapsedTickerTime = Math.max(
5799
- currentTickerTime - initialTickerTime,
5800
- 0
5801
- );
5802
- const elapsedTickerTimeInSeconds = elapsedTickerTime / 1e3;
5803
- const elapsedPos = Math.min(
5804
- elapsedTickerTimeInSeconds * rate + initialElapsedPos,
5805
- totalPlaybackLength
5806
- );
5807
- if (elapsedPos !== totalPlaybackLength) {
5808
- const iterationNumber = Math.floor(elapsedPos / iterationLength);
5809
- let currentIterationPos = elapsedPos / iterationLength % 1 * iterationLength;
5810
- if (direction !== "normal") {
5811
- if (direction === "reverse") {
5812
- currentIterationPos = iterationLength - currentIterationPos;
5813
- } else {
5814
- const isCurrentIterationNumberEven = iterationNumber % 2 === 0;
5815
- if (direction === "alternate") {
5816
- if (!isCurrentIterationNumberEven) {
5817
- currentIterationPos = iterationLength - currentIterationPos;
5818
- }
5819
- } else {
5820
- if (isCurrentIterationNumberEven) {
5821
- currentIterationPos = iterationLength - currentIterationPos;
5822
- }
5823
- }
5824
- }
5825
- }
5826
- this._updatePositionInState(currentIterationPos + range[0]);
5827
- requestNextTick();
5828
- } else {
5829
- if (direction === "normal") {
5830
- this._updatePositionInState(range[1]);
5831
- } else if (direction === "reverse") {
5832
- this._updatePositionInState(range[0]);
5833
- } else {
5834
- const isLastIterationEven = (iterationCount - 1) % 2 === 0;
5835
- if (direction === "alternate") {
5836
- if (isLastIterationEven) {
5837
- this._updatePositionInState(range[1]);
5838
- } else {
5839
- this._updatePositionInState(range[0]);
5840
- }
5841
- } else {
5842
- if (isLastIterationEven) {
5843
- this._updatePositionInState(range[0]);
5844
- } else {
5845
- this._updatePositionInState(range[1]);
5846
- }
5847
- }
5848
- }
5849
- this.playing = false;
5850
- deferred.resolve(true);
5851
- }
5852
- };
5853
- this._stopPlayCallback = () => {
5854
- ticker.offThisOrNextTick(tick);
5855
- ticker.offNextTick(tick);
5856
- if (this.playing) deferred.resolve(false);
5857
- };
5858
- const requestNextTick = () => ticker.onNextTick(tick);
5859
- ticker.onThisOrNextTick(tick);
5860
- return deferred.promise;
5861
- }
5862
- playDynamicRange(rangeD, ticker) {
5863
- if (this.playing) {
5864
- this.pause();
5865
- }
5866
- this.playing = true;
5867
- const deferred = defer();
5868
- const untapFromRangeD = rangeD.keepHot();
5869
- void deferred.promise.then(untapFromRangeD, untapFromRangeD);
5870
- let lastTickerTime = ticker.time;
5871
- const tick = (currentTickerTime) => {
5872
- const elapsedSinceLastTick = Math.max(
5873
- currentTickerTime - lastTickerTime,
5874
- 0
5875
- );
5876
- lastTickerTime = currentTickerTime;
5877
- const elapsedSinceLastTickInSeconds = elapsedSinceLastTick / 1e3;
5878
- const lastPosition = this.getCurrentPosition();
5879
- const range = rangeD.getValue();
5880
- if (lastPosition < range[0] || lastPosition > range[1]) {
5881
- this.gotoPosition(range[0]);
5882
- } else {
5883
- let newPosition = lastPosition + elapsedSinceLastTickInSeconds;
5884
- if (newPosition > range[1]) {
5885
- newPosition = range[0] + (newPosition - range[1]);
5886
- }
5887
- this.gotoPosition(newPosition);
5888
- }
5889
- requestNextTick();
5890
- };
5891
- this._stopPlayCallback = () => {
5892
- ticker.offThisOrNextTick(tick);
5893
- ticker.offNextTick(tick);
5894
- deferred.resolve(false);
5895
- };
5896
- const requestNextTick = () => ticker.onNextTick(tick);
5897
- ticker.onThisOrNextTick(tick);
5898
- return deferred.promise;
5899
- }
5900
- };
5901
-
5902
- // core/src/sequences/playbackControllers/AudioPlaybackController.ts
5903
- var import_theatre_dataverse10 = require("@unseenco/theatre-dataverse");
5904
-
5905
- // shared/src/globalVariableNames.ts
5906
- var studioBundle = "__TheatreJS_StudioBundle";
5907
- var coreBundle = "__TheatreJS_CoreBundle";
5908
- var notifications = "__TheatreJS_Notifications";
5909
-
5910
- // shared/src/notify.ts
5911
- var createHandler = (type) => (...args) => {
5912
- switch (type) {
5913
- case "success": {
5914
- logger_default.debug(args.slice(0, 2).join("\n"));
5915
- break;
5916
- }
5917
- case "info": {
5918
- logger_default.debug(args.slice(0, 2).join("\n"));
5919
- break;
5920
- }
5921
- case "warning": {
5922
- logger_default.warn(args.slice(0, 2).join("\n"));
5923
- break;
5770
+ case "warning": {
5771
+ logger_default.warn(args.slice(0, 2).join("\n"));
5772
+ break;
5924
5773
  }
5925
5774
  case "error": {
5926
5775
  }
@@ -5951,99 +5800,634 @@ if (typeof window !== "undefined") {
5951
5800
  });
5952
5801
  }
5953
5802
 
5954
- // core/src/sequences/playbackControllers/AudioPlaybackController.ts
5955
- var AudioPlaybackController = class {
5956
- constructor(_decodedBuffer, _audioContext, _nodeDestination) {
5957
- this._decodedBuffer = _decodedBuffer;
5958
- this._audioContext = _audioContext;
5959
- this._nodeDestination = _nodeDestination;
5960
- __publicField(this, "_mainGain");
5961
- __publicField(this, "_state", new import_theatre_dataverse10.Atom({
5962
- position: 0,
5963
- playing: false
5964
- }));
5965
- __publicField(this, "statePointer");
5966
- __publicField(this, "_stopPlayCallback", noop_default);
5967
- this.statePointer = this._state.pointer;
5968
- this._mainGain = this._audioContext.createGain();
5969
- this._mainGain.connect(this._nodeDestination);
5970
- }
5971
- playDynamicRange(rangeD, ticker) {
5972
- const deferred = defer();
5973
- if (this._playing) this.pause();
5974
- this._playing = true;
5975
- let stop = void 0;
5976
- const play = () => {
5977
- stop?.();
5978
- stop = this._loopInRange(rangeD.getValue(), ticker).stop;
5979
- };
5980
- const untapFromRangeD = rangeD.onStale(play);
5981
- play();
5982
- this._stopPlayCallback = () => {
5983
- stop?.();
5984
- untapFromRangeD();
5985
- deferred.resolve(false);
5986
- };
5987
- return deferred.promise;
5988
- }
5989
- _loopInRange(range, ticker) {
5990
- const rate = 1;
5991
- let startPos = this.getCurrentPosition();
5992
- const iterationLength = range[1] - range[0];
5993
- if (startPos < range[0] || startPos > range[1]) {
5994
- this._updatePositionInState(range[0]);
5995
- } else if (startPos === range[1]) {
5996
- this._updatePositionInState(range[0]);
5997
- }
5998
- startPos = this.getCurrentPosition();
5999
- const currentSource = this._audioContext.createBufferSource();
6000
- currentSource.buffer = this._decodedBuffer;
6001
- currentSource.connect(this._mainGain);
6002
- currentSource.playbackRate.value = rate;
6003
- currentSource.loop = true;
6004
- currentSource.loopStart = range[0];
6005
- currentSource.loopEnd = range[1];
6006
- const initialTickerTime = ticker.time;
6007
- let initialElapsedPos = startPos - range[0];
6008
- currentSource.start(0, startPos);
6009
- const tick = (currentTickerTime) => {
6010
- const elapsedTickerTime = Math.max(
6011
- currentTickerTime - initialTickerTime,
6012
- 0
6013
- );
6014
- const elapsedTickerTimeInSeconds = elapsedTickerTime / 1e3;
6015
- const elapsedPos = elapsedTickerTimeInSeconds * rate + initialElapsedPos;
6016
- let currentIterationPos = elapsedPos / iterationLength % 1 * iterationLength;
6017
- this._updatePositionInState(currentIterationPos + range[0]);
6018
- requestNextTick();
6019
- };
6020
- const requestNextTick = () => ticker.onNextTick(tick);
6021
- ticker.onThisOrNextTick(tick);
6022
- const stop = () => {
6023
- currentSource.stop();
6024
- currentSource.disconnect();
6025
- ticker.offThisOrNextTick(tick);
6026
- ticker.offNextTick(tick);
6027
- };
6028
- return { stop };
5803
+ // shared/src/utils/slashedPaths.ts
5804
+ var normalizeSlashedPath = (p2) => p2.replace(/^[\s\/]*/, "").replace(/[\s\/]*$/, "").replace(/\s*\/\s*/g, " / ");
5805
+ var getValidationErrorsOfSlashedPath = (p2) => {
5806
+ if (typeof p2 !== "string") return "it is not a string. (it is a ".concat(typeof p2, ")");
5807
+ const components = p2.split(/\//);
5808
+ if (components.length === 0) return "it is empty.";
5809
+ for (let i2 = 0; i2 < components.length; i2++) {
5810
+ const component = components[i2].trim();
5811
+ if (component.length === 0) return "the component #".concat(i2 + 1, " is empty.");
5812
+ if (component.length > 64)
5813
+ return "the component '".concat(component, "' must have 64 characters or less.");
6029
5814
  }
6030
- get _playing() {
6031
- return this._state.get().playing;
5815
+ };
5816
+ function validateAndSanitiseSlashedPathOrThrow(unsanitisedPath, fnName) {
5817
+ const sanitisedPath = normalizeSlashedPath(unsanitisedPath);
5818
+ if (process.env.NODE_ENV !== "development") {
5819
+ return sanitisedPath;
6032
5820
  }
6033
- set _playing(playing) {
6034
- this._state.setByPointer((p2) => p2.playing, playing);
5821
+ const validation = getValidationErrorsOfSlashedPath(sanitisedPath);
5822
+ if (validation) {
5823
+ throw new InvalidArgumentError(
5824
+ "The path in ".concat(fnName, "(").concat(typeof unsanitisedPath === "string" ? '"'.concat(unsanitisedPath, '"') : "", ") is invalid because ").concat(validation)
5825
+ );
6035
5826
  }
6036
- destroy() {
5827
+ if (unsanitisedPath !== sanitisedPath) {
5828
+ notify.warning(
5829
+ "Invalid path provided to object",
5830
+ "The path in `".concat(fnName, '("').concat(unsanitisedPath, '")` was sanitized to `"').concat(sanitisedPath, '"`.\n\n') + "Please replace the path with the sanitized one, otherwise it will likely break in the future.",
5831
+ [
5832
+ {
5833
+ url: "https://unseen-theatre.netlify.app/docs/guide/manual/objects#creating-objects",
5834
+ title: "Sheet Objects"
5835
+ },
5836
+ {
5837
+ url: "https://unseen-theatre.netlify.app/docs/api/theatre-core#sheet.object",
5838
+ title: "API"
5839
+ }
5840
+ ]
5841
+ );
6037
5842
  }
6038
- pause() {
6039
- this._stopPlayCallback();
6040
- this._playing = false;
6041
- this._stopPlayCallback = noop_default;
5843
+ return sanitisedPath;
5844
+ }
5845
+
5846
+ // shared/src/utils/outlineNamespaces.ts
5847
+ function parseOutlineNamespacePath(namespacePath, fnName) {
5848
+ return validateAndSanitiseSlashedPathOrThrow(namespacePath, fnName).split(
5849
+ /\s*\/\s*/g
5850
+ );
5851
+ }
5852
+
5853
+ // core/src/sheets/TheatreSheet.ts
5854
+ var import_fast_deep_equal2 = __toESM(require_fast_deep_equal());
5855
+ var TheatreSheet = class {
5856
+ get type() {
5857
+ return "Theatre_Sheet_PublicAPI";
6042
5858
  }
6043
- gotoPosition(time) {
6044
- this._updatePositionInState(time);
5859
+ /**
5860
+ * @internal
5861
+ */
5862
+ constructor(sheet) {
5863
+ setPrivateAPI(this, sheet);
6045
5864
  }
6046
- _updatePositionInState(time) {
5865
+ object(key, config, opts) {
5866
+ const internal2 = privateAPI(this);
5867
+ const sanitizedPath = validateAndSanitiseSlashedPathOrThrow(
5868
+ key,
5869
+ "sheet.object"
5870
+ );
5871
+ if (isSheetPropsObjectKey(sanitizedPath)) {
5872
+ throw new InvalidArgumentError(
5873
+ 'The key "'.concat(sanitizedPath, '" is reserved for sheet-level props. Use sheet.props() instead of sheet.object().')
5874
+ );
5875
+ }
5876
+ const existingObject = internal2.getObject(sanitizedPath);
5877
+ const nativeObject = null;
5878
+ const actions = opts?.__actions__THIS_API_IS_UNSTABLE_AND_WILL_CHANGE_IN_THE_NEXT_VERSION;
5879
+ if (existingObject) {
5880
+ if (process.env.NODE_ENV !== "production") {
5881
+ const prevConfig = getUnsanitizedObjectProps(existingObject);
5882
+ if (prevConfig) {
5883
+ if (!(0, import_fast_deep_equal2.default)(config, prevConfig)) {
5884
+ if (opts?.reconfigure === true) {
5885
+ const sanitizedConfig = compound(config);
5886
+ existingObject.template.reconfigure(sanitizedConfig);
5887
+ if (opts.transient !== void 0) {
5888
+ existingObject.template.setTransientPropPaths(
5889
+ opts.transient,
5890
+ sanitizedConfig
5891
+ );
5892
+ }
5893
+ if (opts.static !== void 0) {
5894
+ existingObject.template.setStaticPropPaths(
5895
+ opts.static,
5896
+ sanitizedConfig
5897
+ );
5898
+ }
5899
+ if (opts.showPropsOf !== void 0) {
5900
+ existingObject.template.setShowPropsOf(
5901
+ resolveShowPropsOfSources(
5902
+ existingObject,
5903
+ opts.showPropsOf,
5904
+ "sheet.object(..., {showPropsOf})"
5905
+ )
5906
+ );
5907
+ }
5908
+ setUnsanitizedObjectProps(existingObject, config);
5909
+ return existingObject.publicApi;
5910
+ } else {
5911
+ throw new Error(
5912
+ 'You seem to have called sheet.object("'.concat(key, '", config) twice, with different values for `config`. ') + "This is disallowed because changing the config of an object on the fly would make it difficult to reason about.\n\n" + 'You can fix this by either re-using the existing object, or calling sheet.object("'.concat(key, '", config) with the same config.\n\n') + "If you mean to reconfigure the object's config, set `{reconfigure: true}` in sheet.object(\"".concat(key, '", config, {reconfigure: true})')
5913
+ );
5914
+ }
5915
+ }
5916
+ }
5917
+ }
5918
+ if (actions) {
5919
+ existingObject.template._temp_setActions(actions);
5920
+ }
5921
+ if (opts?.visible !== void 0) {
5922
+ existingObject.template.setVisibleInOutline(opts.visible);
5923
+ }
5924
+ if (opts?.transient !== void 0) {
5925
+ existingObject.template.setTransientPropPaths(
5926
+ opts.transient,
5927
+ existingObject.template.staticConfig
5928
+ );
5929
+ }
5930
+ if (opts?.static !== void 0) {
5931
+ existingObject.template.setStaticPropPaths(
5932
+ opts.static,
5933
+ existingObject.template.staticConfig
5934
+ );
5935
+ }
5936
+ if (opts?.showPropsOf !== void 0) {
5937
+ existingObject.template.setShowPropsOf(
5938
+ resolveShowPropsOfSources(
5939
+ existingObject,
5940
+ opts.showPropsOf,
5941
+ "sheet.object(..., {showPropsOf})"
5942
+ )
5943
+ );
5944
+ }
5945
+ return existingObject.publicApi;
5946
+ } else {
5947
+ const sanitizedConfig = compound(config);
5948
+ const object = internal2.createObject(
5949
+ sanitizedPath,
5950
+ nativeObject,
5951
+ sanitizedConfig,
5952
+ actions,
5953
+ opts?.visible,
5954
+ opts?.transient,
5955
+ opts?.static
5956
+ );
5957
+ if (process.env.NODE_ENV !== "production") {
5958
+ setUnsanitizedObjectProps(object, config);
5959
+ }
5960
+ if (opts?.showPropsOf !== void 0) {
5961
+ object.template.setShowPropsOf(
5962
+ resolveShowPropsOfSources(
5963
+ object,
5964
+ opts.showPropsOf,
5965
+ "sheet.object(..., {showPropsOf})"
5966
+ )
5967
+ );
5968
+ }
5969
+ return object.publicApi;
5970
+ }
5971
+ }
5972
+ props(config, opts) {
5973
+ const internal2 = privateAPI(this);
5974
+ const objectKey = SHEET_PROPS_OBJECT_KEY;
5975
+ const existingObject = internal2.getSheetPropsObject();
5976
+ const nativeObject = null;
5977
+ const actions = opts?.__actions__THIS_API_IS_UNSTABLE_AND_WILL_CHANGE_IN_THE_NEXT_VERSION;
5978
+ if (existingObject) {
5979
+ if (process.env.NODE_ENV !== "production") {
5980
+ const prevConfig = getUnsanitizedObjectProps(existingObject);
5981
+ if (prevConfig) {
5982
+ if (!(0, import_fast_deep_equal2.default)(config, prevConfig)) {
5983
+ if (opts?.reconfigure === true) {
5984
+ const sanitizedConfig2 = compound(config);
5985
+ existingObject.template.reconfigure(sanitizedConfig2);
5986
+ if (opts.transient !== void 0) {
5987
+ existingObject.template.setTransientPropPaths(
5988
+ opts.transient,
5989
+ sanitizedConfig2
5990
+ );
5991
+ }
5992
+ if (opts.static !== void 0) {
5993
+ existingObject.template.setStaticPropPaths(
5994
+ opts.static,
5995
+ sanitizedConfig2
5996
+ );
5997
+ }
5998
+ setUnsanitizedObjectProps(existingObject, config);
5999
+ return existingObject.publicApi;
6000
+ } else {
6001
+ throw new Error(
6002
+ "You seem to have called sheet.props(config) twice, with different values for `config`. Use the same config on repeat calls, or pass `{reconfigure: true}` to change the schema."
6003
+ );
6004
+ }
6005
+ }
6006
+ }
6007
+ }
6008
+ if (actions) {
6009
+ existingObject.template._temp_setActions(actions);
6010
+ }
6011
+ if (opts?.transient !== void 0) {
6012
+ existingObject.template.setTransientPropPaths(
6013
+ opts.transient,
6014
+ existingObject.template.staticConfig
6015
+ );
6016
+ }
6017
+ if (opts?.static !== void 0) {
6018
+ existingObject.template.setStaticPropPaths(
6019
+ opts.static,
6020
+ existingObject.template.staticConfig
6021
+ );
6022
+ }
6023
+ return existingObject.publicApi;
6024
+ }
6025
+ const sanitizedConfig = compound(config);
6026
+ const object = internal2.createObject(
6027
+ objectKey,
6028
+ nativeObject,
6029
+ sanitizedConfig,
6030
+ actions,
6031
+ false,
6032
+ opts?.transient,
6033
+ opts?.static
6034
+ );
6035
+ if (process.env.NODE_ENV !== "production") {
6036
+ setUnsanitizedObjectProps(object, config);
6037
+ }
6038
+ return object.publicApi;
6039
+ }
6040
+ get sequence() {
6041
+ return privateAPI(this).getSequence().publicApi;
6042
+ }
6043
+ declareSequenceVariants(variants) {
6044
+ privateAPI(this).template.declareSequenceVariants(variants);
6045
+ }
6046
+ setActiveSequenceVariant(variant) {
6047
+ privateAPI(this).setActiveSequenceVariant(variant);
6048
+ }
6049
+ getActiveSequenceVariant() {
6050
+ return privateAPI(this).getActiveSequenceVariant();
6051
+ }
6052
+ getSequenceMode() {
6053
+ return privateAPI(this).getSequenceMode();
6054
+ }
6055
+ setSequenceMode(mode) {
6056
+ privateAPI(this).setSequenceMode(mode);
6057
+ }
6058
+ setPageScrollDriver(driver) {
6059
+ privateAPI(this).setPageScrollDriver(driver);
6060
+ }
6061
+ get project() {
6062
+ return privateAPI(this).project.publicApi;
6063
+ }
6064
+ get address() {
6065
+ return { ...privateAPI(this).address };
6066
+ }
6067
+ detachObject(key) {
6068
+ const internal2 = privateAPI(this);
6069
+ const sanitizedPath = validateAndSanitiseSlashedPathOrThrow(
6070
+ key,
6071
+ 'sheet.deleteObject("'.concat(key, '")')
6072
+ );
6073
+ if (isSheetPropsObjectKey(sanitizedPath)) {
6074
+ throw new InvalidArgumentError(
6075
+ "Sheet props cannot be detached. They are removed when the sheet instance is unloaded."
6076
+ );
6077
+ }
6078
+ const obj = internal2.getObject(sanitizedPath);
6079
+ if (!obj) {
6080
+ notify.warning(
6081
+ "Couldn't delete object \"".concat(sanitizedPath, '"'),
6082
+ 'There is no object with key "'.concat(sanitizedPath, '".\n\nTo fix this, make sure you are calling `sheet.deleteObject("').concat(sanitizedPath, '")` with the correct key.')
6083
+ );
6084
+ console.warn('Object key "'.concat(sanitizedPath, '" does not exist.'));
6085
+ return;
6086
+ }
6087
+ internal2.deleteObject(sanitizedPath);
6088
+ }
6089
+ getObjects() {
6090
+ return privateAPI(this).getObjects().map((obj) => obj.publicApi);
6091
+ }
6092
+ unload() {
6093
+ privateAPI(this).unload();
6094
+ }
6095
+ declareOutlineNamespace(namespacePath, opts) {
6096
+ const internal2 = privateAPI(this);
6097
+ const parsedPath = parseOutlineNamespacePath(
6098
+ namespacePath,
6099
+ "sheet.declareOutlineNamespace"
6100
+ );
6101
+ internal2.template.setOutlineNamespaceConfig(parsedPath.join(" / "), {
6102
+ defaultCollapsed: opts?.collapsed
6103
+ });
6104
+ }
6105
+ setOutlineNamespaceCollapsed(namespacePath, collapsed) {
6106
+ const internal2 = privateAPI(this);
6107
+ const parsedPath = parseOutlineNamespacePath(
6108
+ namespacePath,
6109
+ "sheet.setOutlineNamespaceCollapsed"
6110
+ );
6111
+ internal2.template.setOutlineNamespaceConfig(parsedPath.join(" / "), {
6112
+ collapsed
6113
+ });
6114
+ }
6115
+ };
6116
+
6117
+ // core/src/sheets/Sheet.ts
6118
+ var import_theatre_dataverse22 = require("@unseenco/theatre-dataverse");
6119
+
6120
+ // shared/src/utils/didYouMean.ts
6121
+ var import_propose = __toESM(require_propose());
6122
+ function didYouMean(str, dictionary, prepend = "Did you mean ", append = "?") {
6123
+ const p2 = (0, import_propose.default)(str, dictionary, {
6124
+ threshold: 0.7
6125
+ });
6126
+ if (p2) {
6127
+ return prepend + JSON.stringify(p2) + append;
6128
+ } else {
6129
+ return "";
6130
+ }
6131
+ }
6132
+
6133
+ // core/src/sequences/Sequence.ts
6134
+ var import_theatre_dataverse15 = require("@unseenco/theatre-dataverse");
6135
+ var import_theatre_dataverse16 = require("@unseenco/theatre-dataverse");
6136
+ var import_theatre_dataverse17 = require("@unseenco/theatre-dataverse");
6137
+ var import_theatre_dataverse18 = require("@unseenco/theatre-dataverse");
6138
+
6139
+ // shared/src/utils/defer.ts
6140
+ function defer() {
6141
+ let resolve;
6142
+ let reject;
6143
+ const promise = new Promise((rs, rj) => {
6144
+ resolve = (v2) => {
6145
+ rs(v2);
6146
+ deferred.status = "resolved";
6147
+ };
6148
+ reject = (v2) => {
6149
+ rj(v2);
6150
+ deferred.status = "rejected";
6151
+ };
6152
+ });
6153
+ const deferred = {
6154
+ resolve,
6155
+ reject,
6156
+ promise,
6157
+ status: "pending"
6158
+ };
6159
+ return deferred;
6160
+ }
6161
+
6162
+ // shared/src/utils/noop.ts
6163
+ var noop = () => {
6164
+ };
6165
+ var noop_default = noop;
6166
+
6167
+ // core/src/sequences/playbackControllers/DefaultPlaybackController.ts
6168
+ var import_theatre_dataverse12 = require("@unseenco/theatre-dataverse");
6169
+ var DefaultPlaybackController = class {
6170
+ constructor() {
6171
+ __publicField(this, "_stopPlayCallback", noop_default);
6172
+ __publicField(this, "_state", new import_theatre_dataverse12.Atom({
6173
+ position: 0,
6174
+ playing: false
6175
+ }));
6176
+ __publicField(this, "statePointer");
6177
+ this.statePointer = this._state.pointer;
6178
+ }
6179
+ destroy() {
6180
+ }
6181
+ pause() {
6182
+ this._stopPlayCallback();
6183
+ this.playing = false;
6184
+ this._stopPlayCallback = noop_default;
6185
+ }
6186
+ gotoPosition(time) {
6187
+ this._updatePositionInState(time);
6188
+ }
6189
+ _updatePositionInState(time) {
6190
+ this._state.setByPointer((p2) => p2.position, time);
6191
+ }
6192
+ getCurrentPosition() {
6193
+ return this._state.get().position;
6194
+ }
6195
+ get playing() {
6196
+ return this._state.get().playing;
6197
+ }
6198
+ set playing(playing) {
6199
+ this._state.setByPointer((p2) => p2.playing, playing);
6200
+ }
6201
+ play(iterationCount, range, rate, direction, ticker) {
6202
+ if (this.playing) {
6203
+ this.pause();
6204
+ }
6205
+ this.playing = true;
6206
+ const iterationLength = range[1] - range[0];
6207
+ {
6208
+ const startPos = this.getCurrentPosition();
6209
+ if (startPos < range[0] || startPos > range[1]) {
6210
+ if (direction === "normal" || direction === "alternate") {
6211
+ this._updatePositionInState(range[0]);
6212
+ } else if (direction === "reverse" || direction === "alternateReverse") {
6213
+ this._updatePositionInState(range[1]);
6214
+ }
6215
+ } else if (direction === "normal" || direction === "alternate") {
6216
+ if (startPos === range[1]) {
6217
+ this._updatePositionInState(range[0]);
6218
+ }
6219
+ } else {
6220
+ if (startPos === range[0]) {
6221
+ this._updatePositionInState(range[1]);
6222
+ }
6223
+ }
6224
+ }
6225
+ const deferred = defer();
6226
+ const initialTickerTime = ticker.time;
6227
+ const totalPlaybackLength = iterationLength * iterationCount;
6228
+ let initialElapsedPos = this.getCurrentPosition() - range[0];
6229
+ if (direction === "reverse" || direction === "alternateReverse") {
6230
+ initialElapsedPos = range[1] - this.getCurrentPosition();
6231
+ }
6232
+ const tick = (currentTickerTime) => {
6233
+ const elapsedTickerTime = Math.max(
6234
+ currentTickerTime - initialTickerTime,
6235
+ 0
6236
+ );
6237
+ const elapsedTickerTimeInSeconds = elapsedTickerTime / 1e3;
6238
+ const elapsedPos = Math.min(
6239
+ elapsedTickerTimeInSeconds * rate + initialElapsedPos,
6240
+ totalPlaybackLength
6241
+ );
6242
+ if (elapsedPos !== totalPlaybackLength) {
6243
+ const iterationNumber = Math.floor(elapsedPos / iterationLength);
6244
+ let currentIterationPos = elapsedPos / iterationLength % 1 * iterationLength;
6245
+ if (direction !== "normal") {
6246
+ if (direction === "reverse") {
6247
+ currentIterationPos = iterationLength - currentIterationPos;
6248
+ } else {
6249
+ const isCurrentIterationNumberEven = iterationNumber % 2 === 0;
6250
+ if (direction === "alternate") {
6251
+ if (!isCurrentIterationNumberEven) {
6252
+ currentIterationPos = iterationLength - currentIterationPos;
6253
+ }
6254
+ } else {
6255
+ if (isCurrentIterationNumberEven) {
6256
+ currentIterationPos = iterationLength - currentIterationPos;
6257
+ }
6258
+ }
6259
+ }
6260
+ }
6261
+ this._updatePositionInState(currentIterationPos + range[0]);
6262
+ requestNextTick();
6263
+ } else {
6264
+ if (direction === "normal") {
6265
+ this._updatePositionInState(range[1]);
6266
+ } else if (direction === "reverse") {
6267
+ this._updatePositionInState(range[0]);
6268
+ } else {
6269
+ const isLastIterationEven = (iterationCount - 1) % 2 === 0;
6270
+ if (direction === "alternate") {
6271
+ if (isLastIterationEven) {
6272
+ this._updatePositionInState(range[1]);
6273
+ } else {
6274
+ this._updatePositionInState(range[0]);
6275
+ }
6276
+ } else {
6277
+ if (isLastIterationEven) {
6278
+ this._updatePositionInState(range[0]);
6279
+ } else {
6280
+ this._updatePositionInState(range[1]);
6281
+ }
6282
+ }
6283
+ }
6284
+ this.playing = false;
6285
+ deferred.resolve(true);
6286
+ }
6287
+ };
6288
+ this._stopPlayCallback = () => {
6289
+ ticker.offThisOrNextTick(tick);
6290
+ ticker.offNextTick(tick);
6291
+ if (this.playing) deferred.resolve(false);
6292
+ };
6293
+ const requestNextTick = () => ticker.onNextTick(tick);
6294
+ ticker.onThisOrNextTick(tick);
6295
+ return deferred.promise;
6296
+ }
6297
+ playDynamicRange(rangeD, ticker) {
6298
+ if (this.playing) {
6299
+ this.pause();
6300
+ }
6301
+ this.playing = true;
6302
+ const deferred = defer();
6303
+ const untapFromRangeD = rangeD.keepHot();
6304
+ void deferred.promise.then(untapFromRangeD, untapFromRangeD);
6305
+ let lastTickerTime = ticker.time;
6306
+ const tick = (currentTickerTime) => {
6307
+ const elapsedSinceLastTick = Math.max(
6308
+ currentTickerTime - lastTickerTime,
6309
+ 0
6310
+ );
6311
+ lastTickerTime = currentTickerTime;
6312
+ const elapsedSinceLastTickInSeconds = elapsedSinceLastTick / 1e3;
6313
+ const lastPosition = this.getCurrentPosition();
6314
+ const range = rangeD.getValue();
6315
+ if (lastPosition < range[0] || lastPosition > range[1]) {
6316
+ this.gotoPosition(range[0]);
6317
+ } else {
6318
+ let newPosition = lastPosition + elapsedSinceLastTickInSeconds;
6319
+ if (newPosition > range[1]) {
6320
+ newPosition = range[0] + (newPosition - range[1]);
6321
+ }
6322
+ this.gotoPosition(newPosition);
6323
+ }
6324
+ requestNextTick();
6325
+ };
6326
+ this._stopPlayCallback = () => {
6327
+ ticker.offThisOrNextTick(tick);
6328
+ ticker.offNextTick(tick);
6329
+ deferred.resolve(false);
6330
+ };
6331
+ const requestNextTick = () => ticker.onNextTick(tick);
6332
+ ticker.onThisOrNextTick(tick);
6333
+ return deferred.promise;
6334
+ }
6335
+ };
6336
+
6337
+ // core/src/sequences/playbackControllers/AudioPlaybackController.ts
6338
+ var import_theatre_dataverse13 = require("@unseenco/theatre-dataverse");
6339
+ var AudioPlaybackController = class {
6340
+ constructor(_decodedBuffer, _audioContext, _nodeDestination) {
6341
+ this._decodedBuffer = _decodedBuffer;
6342
+ this._audioContext = _audioContext;
6343
+ this._nodeDestination = _nodeDestination;
6344
+ __publicField(this, "_mainGain");
6345
+ __publicField(this, "_state", new import_theatre_dataverse13.Atom({
6346
+ position: 0,
6347
+ playing: false
6348
+ }));
6349
+ __publicField(this, "statePointer");
6350
+ __publicField(this, "_stopPlayCallback", noop_default);
6351
+ this.statePointer = this._state.pointer;
6352
+ this._mainGain = this._audioContext.createGain();
6353
+ this._mainGain.connect(this._nodeDestination);
6354
+ }
6355
+ playDynamicRange(rangeD, ticker) {
6356
+ const deferred = defer();
6357
+ if (this._playing) this.pause();
6358
+ this._playing = true;
6359
+ let stop = void 0;
6360
+ const play = () => {
6361
+ stop?.();
6362
+ stop = this._loopInRange(rangeD.getValue(), ticker).stop;
6363
+ };
6364
+ const untapFromRangeD = rangeD.onStale(play);
6365
+ play();
6366
+ this._stopPlayCallback = () => {
6367
+ stop?.();
6368
+ untapFromRangeD();
6369
+ deferred.resolve(false);
6370
+ };
6371
+ return deferred.promise;
6372
+ }
6373
+ _loopInRange(range, ticker) {
6374
+ const rate = 1;
6375
+ let startPos = this.getCurrentPosition();
6376
+ const iterationLength = range[1] - range[0];
6377
+ if (startPos < range[0] || startPos > range[1]) {
6378
+ this._updatePositionInState(range[0]);
6379
+ } else if (startPos === range[1]) {
6380
+ this._updatePositionInState(range[0]);
6381
+ }
6382
+ startPos = this.getCurrentPosition();
6383
+ const currentSource = this._audioContext.createBufferSource();
6384
+ currentSource.buffer = this._decodedBuffer;
6385
+ currentSource.connect(this._mainGain);
6386
+ currentSource.playbackRate.value = rate;
6387
+ currentSource.loop = true;
6388
+ currentSource.loopStart = range[0];
6389
+ currentSource.loopEnd = range[1];
6390
+ const initialTickerTime = ticker.time;
6391
+ let initialElapsedPos = startPos - range[0];
6392
+ currentSource.start(0, startPos);
6393
+ const tick = (currentTickerTime) => {
6394
+ const elapsedTickerTime = Math.max(
6395
+ currentTickerTime - initialTickerTime,
6396
+ 0
6397
+ );
6398
+ const elapsedTickerTimeInSeconds = elapsedTickerTime / 1e3;
6399
+ const elapsedPos = elapsedTickerTimeInSeconds * rate + initialElapsedPos;
6400
+ let currentIterationPos = elapsedPos / iterationLength % 1 * iterationLength;
6401
+ this._updatePositionInState(currentIterationPos + range[0]);
6402
+ requestNextTick();
6403
+ };
6404
+ const requestNextTick = () => ticker.onNextTick(tick);
6405
+ ticker.onThisOrNextTick(tick);
6406
+ const stop = () => {
6407
+ currentSource.stop();
6408
+ currentSource.disconnect();
6409
+ ticker.offThisOrNextTick(tick);
6410
+ ticker.offNextTick(tick);
6411
+ };
6412
+ return { stop };
6413
+ }
6414
+ get _playing() {
6415
+ return this._state.get().playing;
6416
+ }
6417
+ set _playing(playing) {
6418
+ this._state.setByPointer((p2) => p2.playing, playing);
6419
+ }
6420
+ destroy() {
6421
+ }
6422
+ pause() {
6423
+ this._stopPlayCallback();
6424
+ this._playing = false;
6425
+ this._stopPlayCallback = noop_default;
6426
+ }
6427
+ gotoPosition(time) {
6428
+ this._updatePositionInState(time);
6429
+ }
6430
+ _updatePositionInState(time) {
6047
6431
  this._state.reduce((s2) => ({ ...s2, position: time }));
6048
6432
  }
6049
6433
  getCurrentPosition() {
@@ -6303,8 +6687,8 @@ async function resolveAudioBuffer(args) {
6303
6687
  }
6304
6688
 
6305
6689
  // shared/src/gsap/gsapStudioRegistryRevision.ts
6306
- var import_theatre_dataverse11 = require("@unseenco/theatre-dataverse");
6307
- var revisionAtom = new import_theatre_dataverse11.Atom(0);
6690
+ var import_theatre_dataverse14 = require("@unseenco/theatre-dataverse");
6691
+ var revisionAtom = new import_theatre_dataverse14.Atom(0);
6308
6692
  var gsapStudioRegistryRevisionPointer = revisionAtom.pointer;
6309
6693
 
6310
6694
  // shared/src/gsap/scrollTriggerRegistry.ts
@@ -6369,7 +6753,7 @@ var Sequence = class {
6369
6753
  __publicField(this, "_positionD");
6370
6754
  __publicField(this, "_positionFormatterD");
6371
6755
  __publicField(this, "_playableRangeD");
6372
- __publicField(this, "pointer", (0, import_theatre_dataverse14.pointer)({ root: this, path: [] }));
6756
+ __publicField(this, "pointer", (0, import_theatre_dataverse17.pointer)({ root: this, path: [] }));
6373
6757
  __publicField(this, "$$isPointerToPrismProvider", true);
6374
6758
  __publicField(this, "_logger");
6375
6759
  __publicField(this, "closestGridPosition", (posInUnitSpace) => {
@@ -6382,760 +6766,488 @@ var Sequence = class {
6382
6766
  this._logger = _project._logger.named("Sheet", _sheet.address.sheetId).named("Instance", _sheet.address.sheetInstanceId).named("Variant", _sequenceVariant);
6383
6767
  this.address = { ...this._sheet.address, sequenceName: _sequenceVariant };
6384
6768
  this.publicApi = new TheatreSequence(this);
6385
- this._playbackControllerBox = new import_theatre_dataverse13.Atom(
6769
+ this._playbackControllerBox = new import_theatre_dataverse16.Atom(
6386
6770
  playbackController ?? new DefaultPlaybackController()
6387
6771
  );
6388
- this._prismOfStatePointer = (0, import_theatre_dataverse15.prism)(
6389
- () => this._playbackControllerBox.prism.getValue().statePointer
6390
- );
6391
- this._positionD = (0, import_theatre_dataverse15.prism)(() => {
6392
- const statePointer = this._prismOfStatePointer.getValue();
6393
- return (0, import_theatre_dataverse15.val)(statePointer.position);
6394
- });
6395
- this._positionFormatterD = (0, import_theatre_dataverse15.prism)(() => {
6396
- const subUnitsPerUnit = (0, import_theatre_dataverse15.val)(this._subUnitsPerUnitD);
6397
- if (this._sheet.getSequenceMode() === "page") {
6398
- return new PercentBasedPositionFormatter(subUnitsPerUnit);
6399
- }
6400
- return new TimeBasedPositionFormatter(subUnitsPerUnit);
6401
- });
6402
- }
6403
- pointerToPrism(pointer3) {
6404
- const { path } = (0, import_theatre_dataverse12.getPointerParts)(pointer3);
6405
- if (path.length === 0) {
6406
- return (0, import_theatre_dataverse15.prism)(() => ({
6407
- length: (0, import_theatre_dataverse15.val)(this.pointer.length),
6408
- playing: (0, import_theatre_dataverse15.val)(this.pointer.playing),
6409
- position: (0, import_theatre_dataverse15.val)(this.pointer.position)
6410
- }));
6411
- }
6412
- if (path.length > 1) {
6413
- return (0, import_theatre_dataverse15.prism)(() => void 0);
6414
- }
6415
- const [prop] = path;
6416
- if (prop === "length") {
6417
- return this._lengthD;
6418
- } else if (prop === "position") {
6419
- return this._positionD;
6420
- } else if (prop === "playing") {
6421
- return (0, import_theatre_dataverse15.prism)(() => {
6422
- return (0, import_theatre_dataverse15.val)(this._prismOfStatePointer.getValue().playing);
6423
- });
6424
- } else {
6425
- return (0, import_theatre_dataverse15.prism)(() => void 0);
6426
- }
6427
- }
6428
- /**
6429
- * Takes a pointer to a property of a SheetObject and returns the keyframes of that property.
6430
- *
6431
- * Theoretically, this method can be called from inside a prism so it can be reactive.
6432
- */
6433
- getKeyframesOfSimpleProp(prop) {
6434
- const { path, root: root2 } = (0, import_theatre_dataverse12.getPointerParts)(prop);
6435
- if (!isSheetObject(root2)) {
6436
- throw new InvalidArgumentError(
6437
- "Argument prop must be a pointer to a SheetObject property"
6438
- );
6439
- }
6440
- const sheetState = (0, import_theatre_dataverse15.val)(
6441
- this._project.pointers.historic.sheetsById[this._sheet.address.sheetId]
6442
- );
6443
- const trackP = getSequenceStateFromSheet(sheetState, this._sequenceVariant)?.tracksByObject[root2.address.objectKey];
6444
- if (!trackP) {
6445
- return [];
6446
- }
6447
- const { trackData, trackIdByPropPath } = trackP;
6448
- const objectAddress = encodePathToProp(path);
6449
- const id = trackIdByPropPath[objectAddress];
6450
- if (!id) {
6451
- return [];
6452
- }
6453
- const track = trackData[id];
6454
- if (!track || !isBasicKeyframedTrack(track)) {
6455
- return [];
6456
- }
6457
- return track.keyframes;
6458
- }
6459
- /**
6460
- * @internal Used by the public sequence API.
6461
- */
6462
- getGsapClipsForObject(objectKey) {
6463
- const sheetState = (0, import_theatre_dataverse15.val)(
6464
- this._project.pointers.historic.sheetsById[this._sheet.address.sheetId]
6465
- );
6466
- const tracksOfObject = getSequenceStateFromSheet(
6467
- sheetState,
6468
- this._sequenceVariant
6469
- )?.tracksByObject[objectKey];
6470
- if (!tracksOfObject) return [];
6471
- const result = [];
6472
- for (const [trackId, track] of Object.entries(tracksOfObject.trackData)) {
6473
- if (track && isGsapClipTrack(track)) {
6474
- result.push({ trackId, clip: track });
6475
- }
6476
- }
6477
- return result.sort((a2, b2) => a2.clip.start - b2.clip.start);
6478
- }
6479
- getGsapClips() {
6480
- const sheetState = (0, import_theatre_dataverse15.val)(
6481
- this._project.pointers.historic.sheetsById[this._sheet.address.sheetId]
6482
- );
6483
- const sequenceState = getSequenceStateFromSheet(
6484
- sheetState,
6485
- this._sequenceVariant
6486
- );
6487
- if (!sequenceState) return [];
6488
- const result = [];
6489
- for (const [objectKey, tracksOfObject] of Object.entries(
6490
- sequenceState.tracksByObject
6491
- )) {
6492
- if (!tracksOfObject) continue;
6493
- for (const [trackId, track] of Object.entries(tracksOfObject.trackData)) {
6494
- if (track && isGsapClipTrack(track)) {
6495
- result.push({
6496
- objectKey,
6497
- trackId,
6498
- clip: track
6499
- });
6500
- }
6501
- }
6502
- }
6503
- return result.sort((a2, b2) => a2.clip.start - b2.clip.start);
6504
- }
6505
- getGsapScrollTriggers() {
6506
- if (this._sheet.getSequenceMode() !== "page") {
6507
- return [];
6508
- }
6509
- const key = sheetAddressKey(this._sheet.address);
6510
- return listScrollTriggerEntriesForSheet(key).filter((entry) => entry.sheetObject != null).map((entry) => ({
6511
- objectKey: entry.sheetObject.address.objectKey,
6512
- scrollTriggerId: entry.id,
6513
- label: entry.label,
6514
- layout: entry.layout,
6515
- kind: entry.kind,
6516
- animationSpanSeconds: entry.animationSpanSeconds,
6517
- timelineChildren: entry.timelineChildren
6518
- }));
6519
- }
6520
- get positionFormatter() {
6521
- return this._positionFormatterD.getValue();
6522
- }
6523
- get prismOfStatePointer() {
6524
- return this._prismOfStatePointer;
6525
- }
6526
- get length() {
6527
- return this._lengthD.getValue();
6528
- }
6529
- get positionPrism() {
6530
- return this._positionD;
6531
- }
6532
- get position() {
6533
- return this._playbackControllerBox.get().getCurrentPosition();
6534
- }
6535
- get subUnitsPerUnit() {
6536
- return this._subUnitsPerUnitD.getValue();
6537
- }
6538
- get positionSnappedToGrid() {
6539
- return this.closestGridPosition(this.position);
6540
- }
6541
- set position(requestedPosition) {
6542
- let position = requestedPosition;
6543
- this.pause();
6544
- if (process.env.NODE_ENV !== "production") {
6545
- if (typeof position !== "number") {
6546
- console.error(
6547
- "value t in sequence.position = t must be a number. ".concat(typeof position, " given")
6548
- );
6549
- position = 0;
6550
- }
6551
- if (position < 0) {
6552
- console.error(
6553
- "sequence.position must be a positive number. ".concat(position, " given")
6554
- );
6555
- position = 0;
6772
+ this._prismOfStatePointer = (0, import_theatre_dataverse18.prism)(
6773
+ () => this._playbackControllerBox.prism.getValue().statePointer
6774
+ );
6775
+ this._positionD = (0, import_theatre_dataverse18.prism)(() => {
6776
+ const statePointer = this._prismOfStatePointer.getValue();
6777
+ return (0, import_theatre_dataverse18.val)(statePointer.position);
6778
+ });
6779
+ this._positionFormatterD = (0, import_theatre_dataverse18.prism)(() => {
6780
+ const subUnitsPerUnit = (0, import_theatre_dataverse18.val)(this._subUnitsPerUnitD);
6781
+ if (this._sheet.getSequenceMode() === "page") {
6782
+ return new PercentBasedPositionFormatter(subUnitsPerUnit);
6556
6783
  }
6784
+ return new TimeBasedPositionFormatter(subUnitsPerUnit);
6785
+ });
6786
+ }
6787
+ pointerToPrism(pointer4) {
6788
+ const { path } = (0, import_theatre_dataverse15.getPointerParts)(pointer4);
6789
+ if (path.length === 0) {
6790
+ return (0, import_theatre_dataverse18.prism)(() => ({
6791
+ length: (0, import_theatre_dataverse18.val)(this.pointer.length),
6792
+ playing: (0, import_theatre_dataverse18.val)(this.pointer.playing),
6793
+ position: (0, import_theatre_dataverse18.val)(this.pointer.position)
6794
+ }));
6557
6795
  }
6558
- if (position > this.length) {
6559
- position = this.length;
6796
+ if (path.length > 1) {
6797
+ return (0, import_theatre_dataverse18.prism)(() => void 0);
6798
+ }
6799
+ const [prop] = path;
6800
+ if (prop === "length") {
6801
+ return this._lengthD;
6802
+ } else if (prop === "position") {
6803
+ return this._positionD;
6804
+ } else if (prop === "playing") {
6805
+ return (0, import_theatre_dataverse18.prism)(() => {
6806
+ return (0, import_theatre_dataverse18.val)(this._prismOfStatePointer.getValue().playing);
6807
+ });
6808
+ } else {
6809
+ return (0, import_theatre_dataverse18.prism)(() => void 0);
6560
6810
  }
6561
- const dur = this.length;
6562
- this._playbackControllerBox.get().gotoPosition(position > dur ? dur : position);
6563
- }
6564
- getDurationCold() {
6565
- return this._lengthD.getValue();
6566
- }
6567
- get playing() {
6568
- return (0, import_theatre_dataverse15.val)(this._playbackControllerBox.get().statePointer.playing);
6569
- }
6570
- _makeRangeFromSequenceTemplate() {
6571
- return (0, import_theatre_dataverse15.prism)(() => {
6572
- return [0, (0, import_theatre_dataverse15.val)(this._lengthD)];
6573
- });
6574
6811
  }
6575
6812
  /**
6576
- * Controls the playback within a range. Repeats infinitely unless stopped.
6577
- *
6578
- * @remarks
6579
- * One use case for this is to play the playback within the focus range.
6580
- *
6581
- * @param rangeD - The prism that contains the range that will be used for the playback
6582
- *
6583
- * @returns a promise that gets rejected if the playback stopped for whatever reason
6813
+ * Takes a pointer to a property of a SheetObject and returns the keyframes of that property.
6584
6814
  *
6815
+ * Theoretically, this method can be called from inside a prism so it can be reactive.
6585
6816
  */
6586
- playDynamicRange(rangeD, ticker) {
6587
- return this._playbackControllerBox.get().playDynamicRange(rangeD, ticker);
6588
- }
6589
- async play(conf, ticker) {
6590
- if (this._sheet.getSequenceMode() === "page") {
6591
- notify.warning(
6592
- "Playback is disabled in page mode",
6593
- "The sequence is driven by page scroll. Scrub the playhead or scroll the page instead of calling sequence.play()."
6817
+ getKeyframesOfSimpleProp(prop) {
6818
+ const { path, root: root2 } = (0, import_theatre_dataverse15.getPointerParts)(prop);
6819
+ if (!isSheetObject(root2)) {
6820
+ throw new InvalidArgumentError(
6821
+ "Argument prop must be a pointer to a SheetObject property"
6594
6822
  );
6595
- return false;
6596
- }
6597
- const sequenceDuration = this.length;
6598
- const range = conf && conf.range ? conf.range : [0, sequenceDuration];
6599
- if (process.env.NODE_ENV !== "production") {
6600
- if (typeof range[0] !== "number" || range[0] < 0) {
6601
- throw new InvalidArgumentError(
6602
- "Argument conf.range[0] in sequence.play(conf) must be a positive number. ".concat(JSON.stringify(
6603
- range[0]
6604
- ), " given.")
6605
- );
6606
- }
6607
- if (range[0] >= sequenceDuration) {
6608
- throw new InvalidArgumentError(
6609
- "Argument conf.range[0] in sequence.play(conf) cannot be longer than the duration of the sequence, which is ".concat(sequenceDuration, "s. ").concat(JSON.stringify(
6610
- range[0]
6611
- ), " given.")
6612
- );
6613
- }
6614
- if (typeof range[1] !== "number" || range[1] <= 0) {
6615
- throw new InvalidArgumentError(
6616
- "Argument conf.range[1] in sequence.play(conf) must be a number larger than zero. ".concat(JSON.stringify(
6617
- range[1]
6618
- ), " given.")
6619
- );
6620
- }
6621
- if (range[1] > sequenceDuration) {
6622
- notify.warning(
6623
- "Couldn't play sequence in given range",
6624
- "Your animation will still play until the end of the sequence, however the argument `conf.range[1]` given in `sequence.play(conf)` (".concat(JSON.stringify(
6625
- range[1]
6626
- ), "s) is longer than the duration of the sequence (").concat(sequenceDuration, "s).\n\nTo fix this, either set `conf.range[1]` to be less the duration of the sequence, or adjust the sequence duration in the UI."),
6627
- [
6628
- {
6629
- url: "https://unseen-theatre.netlify.app/docs/guide/manual/sequences",
6630
- title: "Sequences"
6631
- },
6632
- {
6633
- url: "https://unseen-theatre.netlify.app/docs/guide/manual/sequences",
6634
- title: "Playback API"
6635
- }
6636
- ]
6637
- );
6638
- range[1] = sequenceDuration;
6639
- }
6640
- if (range[1] <= range[0]) {
6641
- throw new InvalidArgumentError(
6642
- "Argument conf.range[1] in sequence.play(conf) must be larger than conf.range[0]. ".concat(JSON.stringify(
6643
- range
6644
- ), " given.")
6645
- );
6646
- }
6647
- }
6648
- const iterationCount = conf && typeof conf.iterationCount === "number" ? conf.iterationCount : 1;
6649
- if (process.env.NODE_ENV !== "production") {
6650
- if (!(Number.isInteger(iterationCount) && iterationCount > 0) && iterationCount !== Infinity) {
6651
- throw new InvalidArgumentError(
6652
- "Argument conf.iterationCount in sequence.play(conf) must be an integer larger than 0. ".concat(JSON.stringify(
6653
- iterationCount
6654
- ), " given.")
6655
- );
6656
- }
6657
- }
6658
- const rate = conf && typeof conf.rate !== "undefined" ? conf.rate : 1;
6659
- if (process.env.NODE_ENV !== "production") {
6660
- if (typeof rate !== "number" || rate === 0) {
6661
- throw new InvalidArgumentError(
6662
- "Argument conf.rate in sequence.play(conf) must be a number larger than 0. ".concat(JSON.stringify(
6663
- rate
6664
- ), " given.")
6665
- );
6666
- }
6667
- if (rate < 0) {
6668
- throw new InvalidArgumentError(
6669
- "Argument conf.rate in sequence.play(conf) must be a number larger than 0. ".concat(JSON.stringify(
6670
- rate
6671
- ), " given. If you want the animation to play backwards, try setting conf.direction to 'reverse' or 'alternateReverse'.")
6672
- );
6673
- }
6674
- }
6675
- const direction = conf && conf.direction ? conf.direction : "normal";
6676
- if (process.env.NODE_ENV !== "production") {
6677
- if (possibleDirections.indexOf(direction) === -1) {
6678
- throw new InvalidArgumentError(
6679
- "Argument conf.direction in sequence.play(conf) must be one of ".concat(JSON.stringify(
6680
- possibleDirections
6681
- ), ". ").concat(JSON.stringify(direction), " given. ").concat(didYouMean(
6682
- direction,
6683
- possibleDirections
6684
- ))
6685
- );
6686
- }
6687
6823
  }
6688
- return await this._play(
6689
- iterationCount,
6690
- [range[0], range[1]],
6691
- rate,
6692
- direction,
6693
- ticker
6824
+ const sheetState = (0, import_theatre_dataverse18.val)(
6825
+ this._project.pointers.historic.sheetsById[this._sheet.address.sheetId]
6694
6826
  );
6695
- }
6696
- _play(iterationCount, range, rate, direction, ticker) {
6697
- return this._playbackControllerBox.get().play(iterationCount, range, rate, direction, ticker);
6698
- }
6699
- pause() {
6700
- this._playbackControllerBox.get().pause();
6701
- }
6702
- replacePlaybackController(playbackController) {
6703
- this.pause();
6704
- const oldController = this._playbackControllerBox.get();
6705
- this._playbackControllerBox.set(playbackController);
6706
- const time = oldController.getCurrentPosition();
6707
- oldController.destroy();
6708
- playbackController.gotoPosition(time);
6709
- }
6710
- };
6711
- var TimeBasedPositionFormatter = class {
6712
- constructor(_fps) {
6713
- this._fps = _fps;
6714
- }
6715
- formatSubUnitForGrid(posInUnitSpace) {
6716
- const subSecondPos = posInUnitSpace % 1;
6717
- const frame = 1 / this._fps;
6718
- const frames = Math.round(subSecondPos / frame);
6719
- return frames + "f";
6720
- }
6721
- formatFullUnitForGrid(posInUnitSpace) {
6722
- let p2 = posInUnitSpace;
6723
- let s2 = "";
6724
- if (p2 >= hour) {
6725
- const hours = Math.floor(p2 / hour);
6726
- s2 += hours + "h";
6727
- p2 = p2 % hour;
6728
- }
6729
- if (p2 >= minute) {
6730
- const minutes = Math.floor(p2 / minute);
6731
- s2 += minutes + "m";
6732
- p2 = p2 % minute;
6827
+ const trackP = getSequenceStateFromSheet(sheetState, this._sequenceVariant)?.tracksByObject[root2.address.objectKey];
6828
+ if (!trackP) {
6829
+ return [];
6733
6830
  }
6734
- if (p2 >= second) {
6735
- const seconds = Math.floor(p2 / second);
6736
- s2 += seconds + "s";
6737
- p2 = p2 % second;
6831
+ const { trackData, trackIdByPropPath } = trackP;
6832
+ const objectAddress = encodePathToProp(path);
6833
+ const id = trackIdByPropPath[objectAddress];
6834
+ if (!id) {
6835
+ return [];
6738
6836
  }
6739
- const frame = 1 / this._fps;
6740
- if (p2 >= frame) {
6741
- const frames = Math.floor(p2 / frame);
6742
- s2 += frames + "f";
6743
- p2 = p2 % frame;
6837
+ const track = trackData[id];
6838
+ if (!track || !isBasicKeyframedTrack(track)) {
6839
+ return [];
6744
6840
  }
6745
- return s2.length === 0 ? "0s" : s2;
6841
+ return track.keyframes;
6746
6842
  }
6747
- formatForPlayhead(posInUnitSpace) {
6748
- let p2 = posInUnitSpace;
6749
- let s2 = "";
6750
- if (p2 >= hour) {
6751
- const hours = Math.floor(p2 / hour);
6752
- s2 += padStart_default(hours.toString(), 2, "0") + "h";
6753
- p2 = p2 % hour;
6754
- }
6755
- if (p2 >= minute) {
6756
- const minutes = Math.floor(p2 / minute);
6757
- s2 += padStart_default(minutes.toString(), 2, "0") + "m";
6758
- p2 = p2 % minute;
6759
- } else if (s2.length > 0) {
6760
- s2 += "00m";
6843
+ /**
6844
+ * @internal Used by the public sequence API.
6845
+ */
6846
+ getGsapClipsForObject(objectKey) {
6847
+ const sheetState = (0, import_theatre_dataverse18.val)(
6848
+ this._project.pointers.historic.sheetsById[this._sheet.address.sheetId]
6849
+ );
6850
+ const tracksOfObject = getSequenceStateFromSheet(
6851
+ sheetState,
6852
+ this._sequenceVariant
6853
+ )?.tracksByObject[objectKey];
6854
+ if (!tracksOfObject) return [];
6855
+ const result = [];
6856
+ for (const [trackId, track] of Object.entries(tracksOfObject.trackData)) {
6857
+ if (track && isGsapClipTrack(track)) {
6858
+ result.push({ trackId, clip: track });
6859
+ }
6761
6860
  }
6762
- if (p2 >= second) {
6763
- const seconds = Math.floor(p2 / second);
6764
- s2 += padStart_default(seconds.toString(), 2, "0") + "s";
6765
- p2 = p2 % second;
6766
- } else {
6767
- s2 += "00s";
6861
+ return result.sort((a2, b2) => a2.clip.start - b2.clip.start);
6862
+ }
6863
+ getGsapClips() {
6864
+ const sheetState = (0, import_theatre_dataverse18.val)(
6865
+ this._project.pointers.historic.sheetsById[this._sheet.address.sheetId]
6866
+ );
6867
+ const sequenceState = getSequenceStateFromSheet(
6868
+ sheetState,
6869
+ this._sequenceVariant
6870
+ );
6871
+ if (!sequenceState) return [];
6872
+ const result = [];
6873
+ for (const [objectKey, tracksOfObject] of Object.entries(
6874
+ sequenceState.tracksByObject
6875
+ )) {
6876
+ if (!tracksOfObject) continue;
6877
+ for (const [trackId, track] of Object.entries(tracksOfObject.trackData)) {
6878
+ if (track && isGsapClipTrack(track)) {
6879
+ result.push({
6880
+ objectKey,
6881
+ trackId,
6882
+ clip: track
6883
+ });
6884
+ }
6885
+ }
6768
6886
  }
6769
- const frameLength = 1 / this._fps;
6770
- if (p2 >= frameLength) {
6771
- const frames = Math.round(p2 / frameLength);
6772
- s2 += padStart_default(frames.toString(), 2, "0") + "f";
6773
- p2 = p2 % frameLength;
6774
- } else if (p2 / frameLength > 0.98) {
6775
- const frames = 1;
6776
- s2 += padStart_default(frames.toString(), 2, "0") + "f";
6777
- p2 = p2 % frameLength;
6778
- } else {
6779
- s2 += "00f";
6887
+ return result.sort((a2, b2) => a2.clip.start - b2.clip.start);
6888
+ }
6889
+ getGsapScrollTriggers() {
6890
+ if (this._sheet.getSequenceMode() !== "page") {
6891
+ return [];
6780
6892
  }
6781
- return s2.length === 0 ? "00s00f" : s2;
6893
+ const key = sheetAddressKey(this._sheet.address);
6894
+ return listScrollTriggerEntriesForSheet(key).filter((entry) => entry.sheetObject != null).map((entry) => ({
6895
+ objectKey: entry.sheetObject.address.objectKey,
6896
+ scrollTriggerId: entry.id,
6897
+ label: entry.label,
6898
+ layout: entry.layout,
6899
+ kind: entry.kind,
6900
+ animationSpanSeconds: entry.animationSpanSeconds,
6901
+ timelineChildren: entry.timelineChildren
6902
+ }));
6782
6903
  }
6783
- formatBasic(posInUnitSpace) {
6784
- return posInUnitSpace.toFixed(2) + "s";
6904
+ get positionFormatter() {
6905
+ return this._positionFormatterD.getValue();
6785
6906
  }
6786
- };
6787
- var PercentBasedPositionFormatter = class {
6788
- constructor(_subUnitsPerUnit) {
6789
- this._subUnitsPerUnit = _subUnitsPerUnit;
6907
+ get prismOfStatePointer() {
6908
+ return this._prismOfStatePointer;
6790
6909
  }
6791
- formatSubUnitForGrid(posInUnitSpace) {
6792
- const subUnitSize = 1 / this._subUnitsPerUnit;
6793
- const withinUnit = posInUnitSpace % 1;
6794
- const tenths = Math.round(withinUnit / subUnitSize);
6795
- return tenths + "t";
6910
+ get length() {
6911
+ return this._lengthD.getValue();
6796
6912
  }
6797
- formatFullUnitForGrid(posInUnitSpace) {
6798
- return Math.round(posInUnitSpace) + "%";
6913
+ get positionPrism() {
6914
+ return this._positionD;
6799
6915
  }
6800
- formatForPlayhead(posInUnitSpace) {
6801
- const whole = Math.floor(posInUnitSpace);
6802
- const subUnitSize = 1 / this._subUnitsPerUnit;
6803
- const withinUnit = posInUnitSpace - whole;
6804
- const tenths = Math.round(withinUnit / subUnitSize);
6805
- if (tenths <= 0) {
6806
- return whole + "%";
6807
- }
6808
- return whole + "." + tenths + "%";
6916
+ get position() {
6917
+ return this._playbackControllerBox.get().getCurrentPosition();
6809
6918
  }
6810
- formatBasic(posInUnitSpace) {
6811
- return posInUnitSpace.toFixed(1) + "%";
6919
+ get subUnitsPerUnit() {
6920
+ return this._subUnitsPerUnitD.getValue();
6812
6921
  }
6813
- };
6814
- var second = 1;
6815
- var minute = second * 60;
6816
- var hour = minute * 60;
6817
-
6818
- // shared/src/utils/slashedPaths.ts
6819
- var normalizeSlashedPath = (p2) => p2.replace(/^[\s\/]*/, "").replace(/[\s\/]*$/, "").replace(/\s*\/\s*/g, " / ");
6820
- var getValidationErrorsOfSlashedPath = (p2) => {
6821
- if (typeof p2 !== "string") return "it is not a string. (it is a ".concat(typeof p2, ")");
6822
- const components = p2.split(/\//);
6823
- if (components.length === 0) return "it is empty.";
6824
- for (let i2 = 0; i2 < components.length; i2++) {
6825
- const component = components[i2].trim();
6826
- if (component.length === 0) return "the component #".concat(i2 + 1, " is empty.");
6827
- if (component.length > 64)
6828
- return "the component '".concat(component, "' must have 64 characters or less.");
6922
+ get positionSnappedToGrid() {
6923
+ return this.closestGridPosition(this.position);
6829
6924
  }
6830
- };
6831
- function validateAndSanitiseSlashedPathOrThrow(unsanitisedPath, fnName) {
6832
- const sanitisedPath = normalizeSlashedPath(unsanitisedPath);
6833
- if (process.env.NODE_ENV !== "development") {
6834
- return sanitisedPath;
6925
+ set position(requestedPosition) {
6926
+ let position = requestedPosition;
6927
+ this.pause();
6928
+ if (process.env.NODE_ENV !== "production") {
6929
+ if (typeof position !== "number") {
6930
+ console.error(
6931
+ "value t in sequence.position = t must be a number. ".concat(typeof position, " given")
6932
+ );
6933
+ position = 0;
6934
+ }
6935
+ if (position < 0) {
6936
+ console.error(
6937
+ "sequence.position must be a positive number. ".concat(position, " given")
6938
+ );
6939
+ position = 0;
6940
+ }
6941
+ }
6942
+ if (position > this.length) {
6943
+ position = this.length;
6944
+ }
6945
+ const dur = this.length;
6946
+ this._playbackControllerBox.get().gotoPosition(position > dur ? dur : position);
6835
6947
  }
6836
- const validation = getValidationErrorsOfSlashedPath(sanitisedPath);
6837
- if (validation) {
6838
- throw new InvalidArgumentError(
6839
- "The path in ".concat(fnName, "(").concat(typeof unsanitisedPath === "string" ? '"'.concat(unsanitisedPath, '"') : "", ") is invalid because ").concat(validation)
6840
- );
6948
+ getDurationCold() {
6949
+ return this._lengthD.getValue();
6841
6950
  }
6842
- if (unsanitisedPath !== sanitisedPath) {
6843
- notify.warning(
6844
- "Invalid path provided to object",
6845
- "The path in `".concat(fnName, '("').concat(unsanitisedPath, '")` was sanitized to `"').concat(sanitisedPath, '"`.\n\n') + "Please replace the path with the sanitized one, otherwise it will likely break in the future.",
6846
- [
6847
- {
6848
- url: "https://unseen-theatre.netlify.app/docs/guide/manual/objects#creating-objects",
6849
- title: "Sheet Objects"
6850
- },
6851
- {
6852
- url: "https://unseen-theatre.netlify.app/docs/api/theatre-core#sheet.object",
6853
- title: "API"
6854
- }
6855
- ]
6856
- );
6951
+ get playing() {
6952
+ return (0, import_theatre_dataverse18.val)(this._playbackControllerBox.get().statePointer.playing);
6857
6953
  }
6858
- return sanitisedPath;
6859
- }
6860
-
6861
- // shared/src/utils/outlineNamespaces.ts
6862
- function parseOutlineNamespacePath(namespacePath, fnName) {
6863
- return validateAndSanitiseSlashedPathOrThrow(namespacePath, fnName).split(
6864
- /\s*\/\s*/g
6865
- );
6866
- }
6867
-
6868
- // core/src/sheets/TheatreSheet.ts
6869
- var import_fast_deep_equal2 = __toESM(require_fast_deep_equal());
6870
- var TheatreSheet = class {
6871
- get type() {
6872
- return "Theatre_Sheet_PublicAPI";
6954
+ _makeRangeFromSequenceTemplate() {
6955
+ return (0, import_theatre_dataverse18.prism)(() => {
6956
+ return [0, (0, import_theatre_dataverse18.val)(this._lengthD)];
6957
+ });
6873
6958
  }
6874
6959
  /**
6875
- * @internal
6960
+ * Controls the playback within a range. Repeats infinitely unless stopped.
6961
+ *
6962
+ * @remarks
6963
+ * One use case for this is to play the playback within the focus range.
6964
+ *
6965
+ * @param rangeD - The prism that contains the range that will be used for the playback
6966
+ *
6967
+ * @returns a promise that gets rejected if the playback stopped for whatever reason
6968
+ *
6876
6969
  */
6877
- constructor(sheet) {
6878
- setPrivateAPI(this, sheet);
6970
+ playDynamicRange(rangeD, ticker) {
6971
+ return this._playbackControllerBox.get().playDynamicRange(rangeD, ticker);
6879
6972
  }
6880
- object(key, config, opts) {
6881
- const internal2 = privateAPI(this);
6882
- const sanitizedPath = validateAndSanitiseSlashedPathOrThrow(
6883
- key,
6884
- "sheet.object"
6885
- );
6886
- if (isSheetPropsObjectKey(sanitizedPath)) {
6887
- throw new InvalidArgumentError(
6888
- 'The key "'.concat(sanitizedPath, '" is reserved for sheet-level props. Use sheet.props() instead of sheet.object().')
6973
+ async play(conf, ticker) {
6974
+ if (this._sheet.getSequenceMode() === "page") {
6975
+ notify.warning(
6976
+ "Playback is disabled in page mode",
6977
+ "The sequence is driven by page scroll. Scrub the playhead or scroll the page instead of calling sequence.play()."
6889
6978
  );
6979
+ return false;
6890
6980
  }
6891
- const existingObject = internal2.getObject(sanitizedPath);
6892
- const nativeObject = null;
6893
- const actions = opts?.__actions__THIS_API_IS_UNSTABLE_AND_WILL_CHANGE_IN_THE_NEXT_VERSION;
6894
- if (existingObject) {
6895
- if (process.env.NODE_ENV !== "production") {
6896
- const prevConfig = getUnsanitizedObjectProps(existingObject);
6897
- if (prevConfig) {
6898
- if (!(0, import_fast_deep_equal2.default)(config, prevConfig)) {
6899
- if (opts?.reconfigure === true) {
6900
- const sanitizedConfig = compound(config);
6901
- existingObject.template.reconfigure(sanitizedConfig);
6902
- if (opts.transient !== void 0) {
6903
- existingObject.template.setTransientPropPaths(
6904
- opts.transient,
6905
- sanitizedConfig
6906
- );
6907
- }
6908
- if (opts.static !== void 0) {
6909
- existingObject.template.setStaticPropPaths(
6910
- opts.static,
6911
- sanitizedConfig
6912
- );
6913
- }
6914
- if (opts.showPropsOf !== void 0) {
6915
- existingObject.template.setShowPropsOf(
6916
- resolveShowPropsOfSources(
6917
- existingObject,
6918
- opts.showPropsOf,
6919
- "sheet.object(..., {showPropsOf})"
6920
- )
6921
- );
6922
- }
6923
- setUnsanitizedObjectProps(existingObject, config);
6924
- return existingObject.publicApi;
6925
- } else {
6926
- throw new Error(
6927
- 'You seem to have called sheet.object("'.concat(key, '", config) twice, with different values for `config`. ') + "This is disallowed because changing the config of an object on the fly would make it difficult to reason about.\n\n" + 'You can fix this by either re-using the existing object, or calling sheet.object("'.concat(key, '", config) with the same config.\n\n') + "If you mean to reconfigure the object's config, set `{reconfigure: true}` in sheet.object(\"".concat(key, '", config, {reconfigure: true})')
6928
- );
6929
- }
6930
- }
6931
- }
6932
- }
6933
- if (actions) {
6934
- existingObject.template._temp_setActions(actions);
6935
- }
6936
- if (opts?.visible !== void 0) {
6937
- existingObject.template.setVisibleInOutline(opts.visible);
6981
+ const sequenceDuration = this.length;
6982
+ const range = conf && conf.range ? conf.range : [0, sequenceDuration];
6983
+ if (process.env.NODE_ENV !== "production") {
6984
+ if (typeof range[0] !== "number" || range[0] < 0) {
6985
+ throw new InvalidArgumentError(
6986
+ "Argument conf.range[0] in sequence.play(conf) must be a positive number. ".concat(JSON.stringify(
6987
+ range[0]
6988
+ ), " given.")
6989
+ );
6938
6990
  }
6939
- if (opts?.transient !== void 0) {
6940
- existingObject.template.setTransientPropPaths(
6941
- opts.transient,
6942
- existingObject.template.staticConfig
6991
+ if (range[0] >= sequenceDuration) {
6992
+ throw new InvalidArgumentError(
6993
+ "Argument conf.range[0] in sequence.play(conf) cannot be longer than the duration of the sequence, which is ".concat(sequenceDuration, "s. ").concat(JSON.stringify(
6994
+ range[0]
6995
+ ), " given.")
6943
6996
  );
6944
6997
  }
6945
- if (opts?.static !== void 0) {
6946
- existingObject.template.setStaticPropPaths(
6947
- opts.static,
6948
- existingObject.template.staticConfig
6998
+ if (typeof range[1] !== "number" || range[1] <= 0) {
6999
+ throw new InvalidArgumentError(
7000
+ "Argument conf.range[1] in sequence.play(conf) must be a number larger than zero. ".concat(JSON.stringify(
7001
+ range[1]
7002
+ ), " given.")
6949
7003
  );
6950
7004
  }
6951
- if (opts?.showPropsOf !== void 0) {
6952
- existingObject.template.setShowPropsOf(
6953
- resolveShowPropsOfSources(
6954
- existingObject,
6955
- opts.showPropsOf,
6956
- "sheet.object(..., {showPropsOf})"
6957
- )
7005
+ if (range[1] > sequenceDuration) {
7006
+ notify.warning(
7007
+ "Couldn't play sequence in given range",
7008
+ "Your animation will still play until the end of the sequence, however the argument `conf.range[1]` given in `sequence.play(conf)` (".concat(JSON.stringify(
7009
+ range[1]
7010
+ ), "s) is longer than the duration of the sequence (").concat(sequenceDuration, "s).\n\nTo fix this, either set `conf.range[1]` to be less the duration of the sequence, or adjust the sequence duration in the UI."),
7011
+ [
7012
+ {
7013
+ url: "https://unseen-theatre.netlify.app/docs/guide/manual/sequences",
7014
+ title: "Sequences"
7015
+ },
7016
+ {
7017
+ url: "https://unseen-theatre.netlify.app/docs/guide/manual/sequences",
7018
+ title: "Playback API"
7019
+ }
7020
+ ]
6958
7021
  );
7022
+ range[1] = sequenceDuration;
6959
7023
  }
6960
- return existingObject.publicApi;
6961
- } else {
6962
- const sanitizedConfig = compound(config);
6963
- const object = internal2.createObject(
6964
- sanitizedPath,
6965
- nativeObject,
6966
- sanitizedConfig,
6967
- actions,
6968
- opts?.visible,
6969
- opts?.transient,
6970
- opts?.static
6971
- );
6972
- if (process.env.NODE_ENV !== "production") {
6973
- setUnsanitizedObjectProps(object, config);
6974
- }
6975
- if (opts?.showPropsOf !== void 0) {
6976
- object.template.setShowPropsOf(
6977
- resolveShowPropsOfSources(
6978
- object,
6979
- opts.showPropsOf,
6980
- "sheet.object(..., {showPropsOf})"
6981
- )
7024
+ if (range[1] <= range[0]) {
7025
+ throw new InvalidArgumentError(
7026
+ "Argument conf.range[1] in sequence.play(conf) must be larger than conf.range[0]. ".concat(JSON.stringify(
7027
+ range
7028
+ ), " given.")
6982
7029
  );
6983
7030
  }
6984
- return object.publicApi;
6985
7031
  }
6986
- }
6987
- props(config, opts) {
6988
- const internal2 = privateAPI(this);
6989
- const objectKey = SHEET_PROPS_OBJECT_KEY;
6990
- const existingObject = internal2.getSheetPropsObject();
6991
- const nativeObject = null;
6992
- const actions = opts?.__actions__THIS_API_IS_UNSTABLE_AND_WILL_CHANGE_IN_THE_NEXT_VERSION;
6993
- if (existingObject) {
6994
- if (process.env.NODE_ENV !== "production") {
6995
- const prevConfig = getUnsanitizedObjectProps(existingObject);
6996
- if (prevConfig) {
6997
- if (!(0, import_fast_deep_equal2.default)(config, prevConfig)) {
6998
- if (opts?.reconfigure === true) {
6999
- const sanitizedConfig2 = compound(config);
7000
- existingObject.template.reconfigure(sanitizedConfig2);
7001
- if (opts.transient !== void 0) {
7002
- existingObject.template.setTransientPropPaths(
7003
- opts.transient,
7004
- sanitizedConfig2
7005
- );
7006
- }
7007
- if (opts.static !== void 0) {
7008
- existingObject.template.setStaticPropPaths(
7009
- opts.static,
7010
- sanitizedConfig2
7011
- );
7012
- }
7013
- setUnsanitizedObjectProps(existingObject, config);
7014
- return existingObject.publicApi;
7015
- } else {
7016
- throw new Error(
7017
- "You seem to have called sheet.props(config) twice, with different values for `config`. Use the same config on repeat calls, or pass `{reconfigure: true}` to change the schema."
7018
- );
7019
- }
7020
- }
7021
- }
7022
- }
7023
- if (actions) {
7024
- existingObject.template._temp_setActions(actions);
7032
+ const iterationCount = conf && typeof conf.iterationCount === "number" ? conf.iterationCount : 1;
7033
+ if (process.env.NODE_ENV !== "production") {
7034
+ if (!(Number.isInteger(iterationCount) && iterationCount > 0) && iterationCount !== Infinity) {
7035
+ throw new InvalidArgumentError(
7036
+ "Argument conf.iterationCount in sequence.play(conf) must be an integer larger than 0. ".concat(JSON.stringify(
7037
+ iterationCount
7038
+ ), " given.")
7039
+ );
7025
7040
  }
7026
- if (opts?.transient !== void 0) {
7027
- existingObject.template.setTransientPropPaths(
7028
- opts.transient,
7029
- existingObject.template.staticConfig
7041
+ }
7042
+ const rate = conf && typeof conf.rate !== "undefined" ? conf.rate : 1;
7043
+ if (process.env.NODE_ENV !== "production") {
7044
+ if (typeof rate !== "number" || rate === 0) {
7045
+ throw new InvalidArgumentError(
7046
+ "Argument conf.rate in sequence.play(conf) must be a number larger than 0. ".concat(JSON.stringify(
7047
+ rate
7048
+ ), " given.")
7030
7049
  );
7031
7050
  }
7032
- if (opts?.static !== void 0) {
7033
- existingObject.template.setStaticPropPaths(
7034
- opts.static,
7035
- existingObject.template.staticConfig
7051
+ if (rate < 0) {
7052
+ throw new InvalidArgumentError(
7053
+ "Argument conf.rate in sequence.play(conf) must be a number larger than 0. ".concat(JSON.stringify(
7054
+ rate
7055
+ ), " given. If you want the animation to play backwards, try setting conf.direction to 'reverse' or 'alternateReverse'.")
7036
7056
  );
7037
7057
  }
7038
- return existingObject.publicApi;
7039
7058
  }
7040
- const sanitizedConfig = compound(config);
7041
- const object = internal2.createObject(
7042
- objectKey,
7043
- nativeObject,
7044
- sanitizedConfig,
7045
- actions,
7046
- false,
7047
- opts?.transient,
7048
- opts?.static
7049
- );
7059
+ const direction = conf && conf.direction ? conf.direction : "normal";
7050
7060
  if (process.env.NODE_ENV !== "production") {
7051
- setUnsanitizedObjectProps(object, config);
7061
+ if (possibleDirections.indexOf(direction) === -1) {
7062
+ throw new InvalidArgumentError(
7063
+ "Argument conf.direction in sequence.play(conf) must be one of ".concat(JSON.stringify(
7064
+ possibleDirections
7065
+ ), ". ").concat(JSON.stringify(direction), " given. ").concat(didYouMean(
7066
+ direction,
7067
+ possibleDirections
7068
+ ))
7069
+ );
7070
+ }
7052
7071
  }
7053
- return object.publicApi;
7072
+ return await this._play(
7073
+ iterationCount,
7074
+ [range[0], range[1]],
7075
+ rate,
7076
+ direction,
7077
+ ticker
7078
+ );
7054
7079
  }
7055
- get sequence() {
7056
- return privateAPI(this).getSequence().publicApi;
7080
+ _play(iterationCount, range, rate, direction, ticker) {
7081
+ return this._playbackControllerBox.get().play(iterationCount, range, rate, direction, ticker);
7057
7082
  }
7058
- declareSequenceVariants(variants) {
7059
- privateAPI(this).template.declareSequenceVariants(variants);
7083
+ pause() {
7084
+ this._playbackControllerBox.get().pause();
7060
7085
  }
7061
- setActiveSequenceVariant(variant) {
7062
- privateAPI(this).setActiveSequenceVariant(variant);
7086
+ replacePlaybackController(playbackController) {
7087
+ this.pause();
7088
+ const oldController = this._playbackControllerBox.get();
7089
+ this._playbackControllerBox.set(playbackController);
7090
+ const time = oldController.getCurrentPosition();
7091
+ oldController.destroy();
7092
+ playbackController.gotoPosition(time);
7063
7093
  }
7064
- getActiveSequenceVariant() {
7065
- return privateAPI(this).getActiveSequenceVariant();
7094
+ };
7095
+ var TimeBasedPositionFormatter = class {
7096
+ constructor(_fps) {
7097
+ this._fps = _fps;
7066
7098
  }
7067
- getSequenceMode() {
7068
- return privateAPI(this).getSequenceMode();
7099
+ formatSubUnitForGrid(posInUnitSpace) {
7100
+ const subSecondPos = posInUnitSpace % 1;
7101
+ const frame = 1 / this._fps;
7102
+ const frames = Math.round(subSecondPos / frame);
7103
+ return frames + "f";
7104
+ }
7105
+ formatFullUnitForGrid(posInUnitSpace) {
7106
+ let p2 = posInUnitSpace;
7107
+ let s2 = "";
7108
+ if (p2 >= hour) {
7109
+ const hours = Math.floor(p2 / hour);
7110
+ s2 += hours + "h";
7111
+ p2 = p2 % hour;
7112
+ }
7113
+ if (p2 >= minute) {
7114
+ const minutes = Math.floor(p2 / minute);
7115
+ s2 += minutes + "m";
7116
+ p2 = p2 % minute;
7117
+ }
7118
+ if (p2 >= second) {
7119
+ const seconds = Math.floor(p2 / second);
7120
+ s2 += seconds + "s";
7121
+ p2 = p2 % second;
7122
+ }
7123
+ const frame = 1 / this._fps;
7124
+ if (p2 >= frame) {
7125
+ const frames = Math.floor(p2 / frame);
7126
+ s2 += frames + "f";
7127
+ p2 = p2 % frame;
7128
+ }
7129
+ return s2.length === 0 ? "0s" : s2;
7130
+ }
7131
+ formatForPlayhead(posInUnitSpace) {
7132
+ let p2 = posInUnitSpace;
7133
+ let s2 = "";
7134
+ if (p2 >= hour) {
7135
+ const hours = Math.floor(p2 / hour);
7136
+ s2 += padStart_default(hours.toString(), 2, "0") + "h";
7137
+ p2 = p2 % hour;
7138
+ }
7139
+ if (p2 >= minute) {
7140
+ const minutes = Math.floor(p2 / minute);
7141
+ s2 += padStart_default(minutes.toString(), 2, "0") + "m";
7142
+ p2 = p2 % minute;
7143
+ } else if (s2.length > 0) {
7144
+ s2 += "00m";
7145
+ }
7146
+ if (p2 >= second) {
7147
+ const seconds = Math.floor(p2 / second);
7148
+ s2 += padStart_default(seconds.toString(), 2, "0") + "s";
7149
+ p2 = p2 % second;
7150
+ } else {
7151
+ s2 += "00s";
7152
+ }
7153
+ const frameLength = 1 / this._fps;
7154
+ if (p2 >= frameLength) {
7155
+ const frames = Math.round(p2 / frameLength);
7156
+ s2 += padStart_default(frames.toString(), 2, "0") + "f";
7157
+ p2 = p2 % frameLength;
7158
+ } else if (p2 / frameLength > 0.98) {
7159
+ const frames = 1;
7160
+ s2 += padStart_default(frames.toString(), 2, "0") + "f";
7161
+ p2 = p2 % frameLength;
7162
+ } else {
7163
+ s2 += "00f";
7164
+ }
7165
+ return s2.length === 0 ? "00s00f" : s2;
7069
7166
  }
7070
- setSequenceMode(mode) {
7071
- privateAPI(this).setSequenceMode(mode);
7167
+ formatBasic(posInUnitSpace) {
7168
+ return posInUnitSpace.toFixed(2) + "s";
7072
7169
  }
7073
- setPageScrollDriver(driver) {
7074
- privateAPI(this).setPageScrollDriver(driver);
7170
+ };
7171
+ var PercentBasedPositionFormatter = class {
7172
+ constructor(_subUnitsPerUnit) {
7173
+ this._subUnitsPerUnit = _subUnitsPerUnit;
7075
7174
  }
7076
- get project() {
7077
- return privateAPI(this).project.publicApi;
7175
+ formatSubUnitForGrid(posInUnitSpace) {
7176
+ const subUnitSize = 1 / this._subUnitsPerUnit;
7177
+ const withinUnit = posInUnitSpace % 1;
7178
+ const tenths = Math.round(withinUnit / subUnitSize);
7179
+ return tenths + "t";
7078
7180
  }
7079
- get address() {
7080
- return { ...privateAPI(this).address };
7181
+ formatFullUnitForGrid(posInUnitSpace) {
7182
+ return Math.round(posInUnitSpace) + "%";
7081
7183
  }
7082
- detachObject(key) {
7083
- const internal2 = privateAPI(this);
7084
- const sanitizedPath = validateAndSanitiseSlashedPathOrThrow(
7085
- key,
7086
- 'sheet.deleteObject("'.concat(key, '")')
7087
- );
7088
- if (isSheetPropsObjectKey(sanitizedPath)) {
7089
- throw new InvalidArgumentError(
7090
- "Sheet props cannot be detached. They are removed when the sheet instance is unloaded."
7091
- );
7092
- }
7093
- const obj = internal2.getObject(sanitizedPath);
7094
- if (!obj) {
7095
- notify.warning(
7096
- "Couldn't delete object \"".concat(sanitizedPath, '"'),
7097
- 'There is no object with key "'.concat(sanitizedPath, '".\n\nTo fix this, make sure you are calling `sheet.deleteObject("').concat(sanitizedPath, '")` with the correct key.')
7098
- );
7099
- console.warn('Object key "'.concat(sanitizedPath, '" does not exist.'));
7100
- return;
7184
+ formatForPlayhead(posInUnitSpace) {
7185
+ const whole = Math.floor(posInUnitSpace);
7186
+ const subUnitSize = 1 / this._subUnitsPerUnit;
7187
+ const withinUnit = posInUnitSpace - whole;
7188
+ const tenths = Math.round(withinUnit / subUnitSize);
7189
+ if (tenths <= 0) {
7190
+ return whole + "%";
7101
7191
  }
7102
- internal2.deleteObject(sanitizedPath);
7103
- }
7104
- getObjects() {
7105
- return privateAPI(this).getObjects().map((obj) => obj.publicApi);
7106
- }
7107
- unload() {
7108
- privateAPI(this).unload();
7109
- }
7110
- declareOutlineNamespace(namespacePath, opts) {
7111
- const internal2 = privateAPI(this);
7112
- const parsedPath = parseOutlineNamespacePath(
7113
- namespacePath,
7114
- "sheet.declareOutlineNamespace"
7115
- );
7116
- internal2.template.setOutlineNamespaceConfig(parsedPath.join(" / "), {
7117
- defaultCollapsed: opts?.collapsed
7118
- });
7192
+ return whole + "." + tenths + "%";
7119
7193
  }
7120
- setOutlineNamespaceCollapsed(namespacePath, collapsed) {
7121
- const internal2 = privateAPI(this);
7122
- const parsedPath = parseOutlineNamespacePath(
7123
- namespacePath,
7124
- "sheet.setOutlineNamespaceCollapsed"
7125
- );
7126
- internal2.template.setOutlineNamespaceConfig(parsedPath.join(" / "), {
7127
- collapsed
7128
- });
7194
+ formatBasic(posInUnitSpace) {
7195
+ return posInUnitSpace.toFixed(1) + "%";
7129
7196
  }
7130
7197
  };
7198
+ var second = 1;
7199
+ var minute = second * 60;
7200
+ var hour = minute * 60;
7131
7201
 
7132
- // core/src/sheets/Sheet.ts
7133
- var import_theatre_dataverse18 = require("@unseenco/theatre-dataverse");
7202
+ // core/src/sheets/sheetGetSequenceFull.ts
7203
+ var import_theatre_dataverse19 = require("@unseenco/theatre-dataverse");
7134
7204
 
7135
7205
  // core/src/sheets/sheetSequenceMode.ts
7136
7206
  var PAGE_MODE_SEQUENCE_LENGTH = 100;
7137
7207
  var PAGE_MODE_SUB_UNITS_PER_UNIT = 10;
7138
7208
 
7209
+ // core/src/sheets/sheetGetSequenceFull.ts
7210
+ var sanitizeSequenceLength = (len) => typeof len === "number" && isFinite(len) && len > 0 ? len : 10;
7211
+ var sanitizeSequenceSubUnitsPerUnit = (subs) => typeof subs === "number" && isInteger_default(subs) && subs > 0 ? subs : 30;
7212
+ function getOrCreateFullSequence(sheet, sequences, variantId) {
7213
+ if (!sequences[variantId]) {
7214
+ const lengthD = (0, import_theatre_dataverse19.prism)(() => {
7215
+ if ((0, import_theatre_dataverse19.val)(sheet.sequenceModeP) === "page") {
7216
+ return PAGE_MODE_SEQUENCE_LENGTH;
7217
+ }
7218
+ const sheetState = (0, import_theatre_dataverse19.val)(
7219
+ sheet.project.pointers.historic.sheetsById[sheet.address.sheetId]
7220
+ );
7221
+ const unsanitized = getSequenceStateFromSheet(
7222
+ sheetState,
7223
+ variantId
7224
+ )?.length;
7225
+ return sanitizeSequenceLength(unsanitized);
7226
+ });
7227
+ const subUnitsPerUnitD = (0, import_theatre_dataverse19.prism)(() => {
7228
+ if ((0, import_theatre_dataverse19.val)(sheet.sequenceModeP) === "page") {
7229
+ return PAGE_MODE_SUB_UNITS_PER_UNIT;
7230
+ }
7231
+ const sheetState = (0, import_theatre_dataverse19.val)(
7232
+ sheet.project.pointers.historic.sheetsById[sheet.address.sheetId]
7233
+ );
7234
+ const unsanitized = getSequenceStateFromSheet(
7235
+ sheetState,
7236
+ variantId
7237
+ )?.subUnitsPerUnit;
7238
+ return sanitizeSequenceSubUnitsPerUnit(unsanitized);
7239
+ });
7240
+ sequences[variantId] = new Sequence(
7241
+ sheet.template.project,
7242
+ sheet,
7243
+ lengthD,
7244
+ subUnitsPerUnitD,
7245
+ variantId
7246
+ );
7247
+ }
7248
+ return sequences[variantId];
7249
+ }
7250
+
7139
7251
  // shared/src/gsap/applyTimelineChildTiming.ts
7140
7252
  function applyTimelineChildTimingToGsap(rootAnimation, timelineChildren, childById, onRebuild) {
7141
7253
  if (!timelineChildren.length) return true;
@@ -7264,7 +7376,7 @@ function getAnimationEntryBySheetAddressKey(sheetObjectAddressKey, animationId)
7264
7376
  }
7265
7377
 
7266
7378
  // shared/src/gsap/subscribeGsapClipSyncAtPlayhead.ts
7267
- var import_theatre_dataverse16 = require("@unseenco/theatre-dataverse");
7379
+ var import_theatre_dataverse20 = require("@unseenco/theatre-dataverse");
7268
7380
 
7269
7381
  // shared/src/gsap/syncGsapClipsAtSequencePosition.ts
7270
7382
  function syncGsapClipsAtSequencePosition(position, clips) {
@@ -7277,12 +7389,12 @@ function syncGsapClipsAtSequencePosition(position, clips) {
7277
7389
  // shared/src/gsap/subscribeGsapClipSyncAtPlayhead.ts
7278
7390
  function subscribeGsapClipSyncAtPlayhead(source) {
7279
7391
  const positionPointer = source.pointer.position;
7280
- const positionPrism = (0, import_theatre_dataverse16.pointerToPrism)(positionPointer);
7281
- const clipsPrism = (0, import_theatre_dataverse16.prism)(() => source.getGsapClipTimings());
7392
+ const positionPrism = (0, import_theatre_dataverse20.pointerToPrism)(positionPointer);
7393
+ const clipsPrism = (0, import_theatre_dataverse20.prism)(() => source.getGsapClipTimings());
7282
7394
  const syncNow = () => {
7283
7395
  const clips = clipsPrism.getValue();
7284
7396
  if (clips.length === 0) return;
7285
- syncGsapClipsAtSequencePosition((0, import_theatre_dataverse16.val)(positionPointer), clips);
7397
+ syncGsapClipsAtSequencePosition((0, import_theatre_dataverse20.val)(positionPointer), clips);
7286
7398
  };
7287
7399
  const untapPosition = positionPrism.onStale(syncNow);
7288
7400
  const untapClips = clipsPrism.onStale(syncNow);
@@ -7316,7 +7428,7 @@ function attachGsapSequenceBridge(sheet) {
7316
7428
  }
7317
7429
 
7318
7430
  // core/src/sheets/attachSheetScrollDriver.ts
7319
- var import_theatre_dataverse17 = require("@unseenco/theatre-dataverse");
7431
+ var import_theatre_dataverse21 = require("@unseenco/theatre-dataverse");
7320
7432
  var sheetScrollDrivers = /* @__PURE__ */ new WeakMap();
7321
7433
  var pageScrollDrivenSequencePositionListeners = /* @__PURE__ */ new Set();
7322
7434
  function onPageScrollDrivenSequencePosition(listener) {
@@ -7457,7 +7569,7 @@ function attachSheetScrollDriver(sheet, driver = createNativeDocumentScrollDrive
7457
7569
  rememberSheetScrollDriver(sheet, driver);
7458
7570
  const sequence = sheet.sequence;
7459
7571
  const syncPositionFromScroll = (progress) => {
7460
- const length = (0, import_theatre_dataverse17.val)(sequence.pointer.length);
7572
+ const length = (0, import_theatre_dataverse21.val)(sequence.pointer.length);
7461
7573
  if (length <= 0) return;
7462
7574
  sequence.position = progress * length;
7463
7575
  };
@@ -7471,12 +7583,12 @@ function attachSheetScrollDriver(sheet, driver = createNativeDocumentScrollDrive
7471
7583
  };
7472
7584
  }
7473
7585
  function pageScrollProgressFromSequence(sheet) {
7474
- const length = (0, import_theatre_dataverse17.val)(sheet.sequence.pointer.length);
7586
+ const length = (0, import_theatre_dataverse21.val)(sheet.sequence.pointer.length);
7475
7587
  if (length <= 0) return 0;
7476
7588
  return sheet.sequence.position / length;
7477
7589
  }
7478
7590
  function setPageScrollProgress(sheet, progress) {
7479
- const length = (0, import_theatre_dataverse17.val)(sheet.sequence.pointer.length);
7591
+ const length = (0, import_theatre_dataverse21.val)(sheet.sequence.pointer.length);
7480
7592
  if (length <= 0) return;
7481
7593
  const clamped = Math.max(0, Math.min(1, progress));
7482
7594
  sheet.sequence.position = clamped * length;
@@ -7489,14 +7601,46 @@ function syncNativeDocumentScrollToSequencePosition(sheet) {
7489
7601
  syncPageScrollToSequencePosition(sheet, createNativeDocumentScrollDriver());
7490
7602
  }
7491
7603
 
7604
+ // core/src/sheets/sheetPageScrollAndGsapFull.ts
7605
+ function syncPageScrollDriverForSheet(host) {
7606
+ host._pageScrollDisposer?.();
7607
+ host._pageScrollDisposer = void 0;
7608
+ if (host.getSequenceMode() === "page") {
7609
+ const driver = host._customPageScrollDriver ?? createNativeDocumentScrollDriver();
7610
+ host._pageScrollDisposer = attachSheetScrollDriver(host.publicApi, driver);
7611
+ }
7612
+ }
7613
+ function reattachGsapBridgeForSheet(host) {
7614
+ if (host._gsapBridgeDisposer) {
7615
+ host._gsapBridgeDisposer();
7616
+ host._gsapBridgeDisposer = attachGsapSequenceBridge(host.publicApi);
7617
+ }
7618
+ }
7619
+ function enableGsapSequenceBridgeForSheet(host) {
7620
+ if (host._gsapBridgeDisposer) return;
7621
+ host._gsapBridgeDisposer = attachGsapSequenceBridge(host.publicApi);
7622
+ syncPageScrollDriverForSheet(host);
7623
+ }
7624
+ function disposeRuntimeIntegrationsForSheet(host) {
7625
+ host._pageScrollDisposer?.();
7626
+ host._pageScrollDisposer = void 0;
7627
+ host._gsapBridgeDisposer?.();
7628
+ host._gsapBridgeDisposer = void 0;
7629
+ }
7630
+ function setPageScrollDriverForSheet(host, driver) {
7631
+ host._customPageScrollDriver = driver;
7632
+ syncPageScrollDriverForSheet(host);
7633
+ }
7634
+
7492
7635
  // core/src/sheets/Sheet.ts
7493
7636
  var Sheet = class {
7494
7637
  constructor(template, instanceId) {
7495
7638
  this.template = template;
7496
7639
  this.instanceId = instanceId;
7497
- __publicField(this, "_objects", new import_theatre_dataverse18.Atom({}));
7640
+ __publicField(this, "_objects", new import_theatre_dataverse22.Atom({}));
7498
7641
  __publicField(this, "_sequences", {});
7499
- __publicField(this, "_activeSequenceVariant", new import_theatre_dataverse18.Atom(
7642
+ __publicField(this, "_liteSequences", {});
7643
+ __publicField(this, "_activeSequenceVariant", new import_theatre_dataverse22.Atom(
7500
7644
  DEFAULT_SEQUENCE_VARIANT
7501
7645
  ));
7502
7646
  /**
@@ -7504,11 +7648,14 @@ var Sheet = class {
7504
7648
  * value resolution (preview). User code can still update `_activeSequenceVariant`
7505
7649
  * via `setActiveSequenceVariant()` without affecting the Studio preview.
7506
7650
  */
7507
- __publicField(this, "_studioPreviewVariantOverride", new import_theatre_dataverse18.Atom(void 0));
7508
- __publicField(this, "_sequenceMode", new import_theatre_dataverse18.Atom("time"));
7651
+ __publicField(this, "_studioPreviewVariantOverride", new import_theatre_dataverse22.Atom(void 0));
7652
+ __publicField(this, "_sequenceMode", new import_theatre_dataverse22.Atom("time"));
7509
7653
  __publicField(this, "sequenceModeP", this._sequenceMode.pointer);
7654
+ /** @internal Used by full-runtime scroll/GSAP helpers (`sheetPageScrollAndGsapFull`). */
7510
7655
  __publicField(this, "_pageScrollDisposer");
7656
+ /** @internal */
7511
7657
  __publicField(this, "_customPageScrollDriver");
7658
+ /** @internal */
7512
7659
  __publicField(this, "_gsapBridgeDisposer");
7513
7660
  __publicField(this, "activeSequenceVariantP", this._activeSequenceVariant.pointer);
7514
7661
  __publicField(this, "effectiveActiveSequenceVariantD");
@@ -7526,12 +7673,12 @@ var Sheet = class {
7526
7673
  sheetInstanceId: this.instanceId
7527
7674
  };
7528
7675
  this.publicApi = new TheatreSheet(this);
7529
- this.effectiveActiveSequenceVariantD = (0, import_theatre_dataverse18.prism)(() => {
7530
- const studioOverride = (0, import_theatre_dataverse18.val)(this._studioPreviewVariantOverride.pointer);
7676
+ this.effectiveActiveSequenceVariantD = (0, import_theatre_dataverse22.prism)(() => {
7677
+ const studioOverride = (0, import_theatre_dataverse22.val)(this._studioPreviewVariantOverride.pointer);
7531
7678
  if (studioOverride !== void 0) {
7532
7679
  return studioOverride;
7533
7680
  }
7534
- return (0, import_theatre_dataverse18.val)(this._activeSequenceVariant.pointer);
7681
+ return (0, import_theatre_dataverse22.val)(this._activeSequenceVariant.pointer);
7535
7682
  });
7536
7683
  }
7537
7684
  /**
@@ -7583,8 +7730,10 @@ var Sheet = class {
7583
7730
  */
7584
7731
  unload() {
7585
7732
  this.disposeRuntimeIntegrations();
7586
- for (const sequence of Object.values(this._sequences)) {
7587
- sequence.pause();
7733
+ if (!isTheatreLiteMode()) {
7734
+ for (const sequence of Object.values(this._sequences)) {
7735
+ sequence.pause();
7736
+ }
7588
7737
  }
7589
7738
  for (const objectKey of Object.keys(
7590
7739
  this._objects.get()
@@ -7594,43 +7743,14 @@ var Sheet = class {
7594
7743
  this.project._unloadSheetInstance(this);
7595
7744
  }
7596
7745
  getSequence(variant) {
7597
- const variantId = variant ?? (0, import_theatre_dataverse18.val)(this._activeSequenceVariant.pointer);
7598
- if (!this._sequences[variantId]) {
7599
- const lengthD = (0, import_theatre_dataverse18.prism)(() => {
7600
- if ((0, import_theatre_dataverse18.val)(this._sequenceMode.pointer) === "page") {
7601
- return PAGE_MODE_SEQUENCE_LENGTH;
7602
- }
7603
- const sheetState = (0, import_theatre_dataverse18.val)(
7604
- this.project.pointers.historic.sheetsById[this.address.sheetId]
7605
- );
7606
- const unsanitized = getSequenceStateFromSheet(
7607
- sheetState,
7608
- variantId
7609
- )?.length;
7610
- return sanitizeSequenceLength(unsanitized);
7611
- });
7612
- const subUnitsPerUnitD = (0, import_theatre_dataverse18.prism)(() => {
7613
- if ((0, import_theatre_dataverse18.val)(this._sequenceMode.pointer) === "page") {
7614
- return PAGE_MODE_SUB_UNITS_PER_UNIT;
7615
- }
7616
- const sheetState = (0, import_theatre_dataverse18.val)(
7617
- this.project.pointers.historic.sheetsById[this.address.sheetId]
7618
- );
7619
- const unsanitized = getSequenceStateFromSheet(
7620
- sheetState,
7621
- variantId
7622
- )?.subUnitsPerUnit;
7623
- return sanitizeSequenceSubUnitsPerUnit(unsanitized);
7624
- });
7625
- this._sequences[variantId] = new Sequence(
7626
- this.template.project,
7627
- this,
7628
- lengthD,
7629
- subUnitsPerUnitD,
7630
- variantId
7631
- );
7746
+ const variantId = variant ?? (0, import_theatre_dataverse22.val)(this._activeSequenceVariant.pointer);
7747
+ if (isTheatreLiteMode()) {
7748
+ if (!this._liteSequences[variantId]) {
7749
+ this._liteSequences[variantId] = new LiteSequence();
7750
+ }
7751
+ return this._liteSequences[variantId];
7632
7752
  }
7633
- return this._sequences[variantId];
7753
+ return getOrCreateFullSequence(this, this._sequences, variantId);
7634
7754
  }
7635
7755
  getActiveSequenceVariant() {
7636
7756
  return this._activeSequenceVariant.get();
@@ -7669,43 +7789,28 @@ var Sheet = class {
7669
7789
  return this._sequenceMode.get();
7670
7790
  }
7671
7791
  setSequenceMode(mode) {
7792
+ if (isTheatreLiteMode()) return;
7672
7793
  if (this._sequenceMode.get() === mode) return;
7673
7794
  this._sequenceMode.set(mode);
7674
- this.syncPageScrollDriver();
7675
- if (this._gsapBridgeDisposer) {
7676
- this._gsapBridgeDisposer();
7677
- this._gsapBridgeDisposer = attachGsapSequenceBridge(this.publicApi);
7678
- }
7795
+ syncPageScrollDriverForSheet(this);
7796
+ reattachGsapBridgeForSheet(this);
7679
7797
  }
7680
7798
  enableGsapSequenceBridge() {
7681
- if (this._gsapBridgeDisposer) return;
7682
- this._gsapBridgeDisposer = attachGsapSequenceBridge(this.publicApi);
7683
- this.syncPageScrollDriver();
7799
+ if (isTheatreLiteMode()) return;
7800
+ enableGsapSequenceBridgeForSheet(this);
7684
7801
  }
7685
7802
  disposeRuntimeIntegrations() {
7686
- this._pageScrollDisposer?.();
7687
- this._pageScrollDisposer = void 0;
7688
- this._gsapBridgeDisposer?.();
7689
- this._gsapBridgeDisposer = void 0;
7690
- }
7691
- syncPageScrollDriver() {
7692
- this._pageScrollDisposer?.();
7693
- this._pageScrollDisposer = void 0;
7694
- if (this.getSequenceMode() === "page") {
7695
- const driver = this._customPageScrollDriver ?? createNativeDocumentScrollDriver();
7696
- this._pageScrollDisposer = attachSheetScrollDriver(this.publicApi, driver);
7697
- }
7803
+ if (isTheatreLiteMode()) return;
7804
+ disposeRuntimeIntegrationsForSheet(this);
7698
7805
  }
7699
7806
  setPageScrollDriver(driver) {
7700
- this._customPageScrollDriver = driver;
7701
- this.syncPageScrollDriver();
7807
+ if (isTheatreLiteMode()) return;
7808
+ setPageScrollDriverForSheet(this, driver);
7702
7809
  }
7703
7810
  getPageScrollDriver() {
7704
7811
  return this._customPageScrollDriver;
7705
7812
  }
7706
7813
  };
7707
- var sanitizeSequenceLength = (len) => typeof len === "number" && isFinite(len) && len > 0 ? len : 10;
7708
- var sanitizeSequenceSubUnitsPerUnit = (subs) => typeof subs === "number" && isInteger_default(subs) && subs >= 1 && subs <= 1e3 ? subs : 30;
7709
7814
 
7710
7815
  // core/src/sheets/SheetTemplate.ts
7711
7816
  var SheetTemplate = class {
@@ -7713,13 +7818,13 @@ var SheetTemplate = class {
7713
7818
  this.project = project;
7714
7819
  __publicField(this, "type", "Theatre_SheetTemplate");
7715
7820
  __publicField(this, "address");
7716
- __publicField(this, "_instances", new import_theatre_dataverse19.Atom({}));
7821
+ __publicField(this, "_instances", new import_theatre_dataverse23.Atom({}));
7717
7822
  __publicField(this, "instancesP", this._instances.pointer);
7718
- __publicField(this, "_objectTemplates", new import_theatre_dataverse19.Atom({}));
7823
+ __publicField(this, "_objectTemplates", new import_theatre_dataverse23.Atom({}));
7719
7824
  __publicField(this, "objectTemplatesP", this._objectTemplates.pointer);
7720
7825
  __publicField(this, "_pendingOutlineNamespaces", {});
7721
7826
  __publicField(this, "_sequenceVariants", [DEFAULT_SEQUENCE_VARIANT]);
7722
- __publicField(this, "_visibleInOutline", new import_theatre_dataverse19.Atom(true));
7827
+ __publicField(this, "_visibleInOutline", new import_theatre_dataverse23.Atom(true));
7723
7828
  __publicField(this, "visibleInOutlineP", this._visibleInOutline.pointer);
7724
7829
  this.address = { ...project.address, sheetId };
7725
7830
  }
@@ -7801,8 +7906,8 @@ var SheetTemplate = class {
7801
7906
  };
7802
7907
 
7803
7908
  // core/src/projects/Project.ts
7804
- var import_theatre_dataverse22 = require("@unseenco/theatre-dataverse");
7805
- var import_theatre_dataverse23 = require("@unseenco/theatre-dataverse");
7909
+ var import_theatre_dataverse26 = require("@unseenco/theatre-dataverse");
7910
+ var import_theatre_dataverse27 = require("@unseenco/theatre-dataverse");
7806
7911
 
7807
7912
  // shared/src/utils/delay.ts
7808
7913
  var delay = (dur) => new Promise((resolve) => setTimeout(resolve, dur));
@@ -8370,7 +8475,7 @@ function setRemotePageScrollMetrics(metrics) {
8370
8475
  }
8371
8476
 
8372
8477
  // core/src/internal/RemoteSync.ts
8373
- var import_theatre_dataverse20 = require("@unseenco/theatre-dataverse");
8478
+ var import_theatre_dataverse24 = require("@unseenco/theatre-dataverse");
8374
8479
 
8375
8480
  // core/src/internal/createDebouncedCallback.ts
8376
8481
  function createDebouncedCallback(fn2, delayMs) {
@@ -8554,12 +8659,12 @@ var RemoteSync = class {
8554
8659
  };
8555
8660
  void studio.initialized.then(() => {
8556
8661
  this.historicSyncUnsubs.push(
8557
- (0, import_theatre_dataverse20.pointerToPrism)(studio.atomP.historic.coreByProject[projectId]).onChange(
8662
+ (0, import_theatre_dataverse24.pointerToPrism)(studio.atomP.historic.coreByProject[projectId]).onChange(
8558
8663
  studio.ticker,
8559
8664
  scheduleHistoricSync,
8560
8665
  true
8561
8666
  ),
8562
- (0, import_theatre_dataverse20.pointerToPrism)(
8667
+ (0, import_theatre_dataverse24.pointerToPrism)(
8563
8668
  studio.atomP.ahistoric.coreByProject[projectId]
8564
8669
  ).onChange(studio.ticker, scheduleHistoricSync, true)
8565
8670
  );
@@ -8568,14 +8673,14 @@ var RemoteSync = class {
8568
8673
  _readHistoricSnapshotFromStudio() {
8569
8674
  if (!this.studio) return void 0;
8570
8675
  const projectId = this.project.address.projectId;
8571
- const historic = (0, import_theatre_dataverse20.val)(
8676
+ const historic = (0, import_theatre_dataverse24.val)(
8572
8677
  this.studio.atomP.historic.coreByProject[projectId]
8573
8678
  );
8574
8679
  if (!historic) return void 0;
8575
8680
  const data = {
8576
8681
  historic: JSON.parse(JSON.stringify(historic))
8577
8682
  };
8578
- const ahistoric = (0, import_theatre_dataverse20.val)(
8683
+ const ahistoric = (0, import_theatre_dataverse24.val)(
8579
8684
  this.studio.atomP.ahistoric.coreByProject[projectId]
8580
8685
  );
8581
8686
  if (ahistoric) {
@@ -8768,7 +8873,7 @@ function _coreLogger(config) {
8768
8873
  }
8769
8874
 
8770
8875
  // shared/src/utils/assets.ts
8771
- var import_theatre_dataverse21 = require("@unseenco/theatre-dataverse");
8876
+ var import_theatre_dataverse25 = require("@unseenco/theatre-dataverse");
8772
8877
 
8773
8878
  // shared/src/utils/forEachDeep.ts
8774
8879
  function forEachPropDeep(m, fn2, startingPath = []) {
@@ -8838,7 +8943,7 @@ var Project = class {
8838
8943
  __publicField(this, "_studioReadyDeferred");
8839
8944
  __publicField(this, "_assetStorageReadyDeferred");
8840
8945
  __publicField(this, "_readyPromise");
8841
- __publicField(this, "_sheetTemplates", new import_theatre_dataverse23.Atom({}));
8946
+ __publicField(this, "_sheetTemplates", new import_theatre_dataverse27.Atom({}));
8842
8947
  __publicField(this, "sheetTemplatesP", this._sheetTemplates.pointer);
8843
8948
  __publicField(this, "_studio");
8844
8949
  __publicField(this, "_onDiskStateAtom");
@@ -8851,7 +8956,7 @@ var Project = class {
8851
8956
  this._logger.traceDev("creating project");
8852
8957
  this.address = { projectId: id };
8853
8958
  this._remoteSync = new RemoteSync(this);
8854
- const onDiskStateAtom = new import_theatre_dataverse23.Atom({
8959
+ const onDiskStateAtom = new import_theatre_dataverse27.Atom({
8855
8960
  ahistoric: {
8856
8961
  ahistoricStuff: ""
8857
8962
  },
@@ -8877,9 +8982,9 @@ var Project = class {
8877
8982
  }
8878
8983
  };
8879
8984
  this._pointerProxies = {
8880
- historic: new import_theatre_dataverse22.PointerProxy(onDiskStateAtom.pointer.historic),
8881
- ahistoric: new import_theatre_dataverse22.PointerProxy(onDiskStateAtom.pointer.ahistoric),
8882
- ephemeral: new import_theatre_dataverse22.PointerProxy(onDiskStateAtom.pointer.ephemeral)
8985
+ historic: new import_theatre_dataverse26.PointerProxy(onDiskStateAtom.pointer.historic),
8986
+ ahistoric: new import_theatre_dataverse26.PointerProxy(onDiskStateAtom.pointer.ahistoric),
8987
+ ephemeral: new import_theatre_dataverse26.PointerProxy(onDiskStateAtom.pointer.ephemeral)
8883
8988
  };
8884
8989
  this.pointers = {
8885
8990
  historic: this._pointerProxies.historic.pointer,
@@ -9258,13 +9363,13 @@ var Project = class {
9258
9363
  };
9259
9364
 
9260
9365
  // shared/src/utils/sanitizers.ts
9261
- var _validateSym = (val13, thingy, range) => {
9262
- if (typeof val13 !== "string") {
9263
- return "".concat(thingy, " must be a string. ").concat(userReadableTypeOfValue_default(val13), " given.");
9264
- } else if (val13.trim().length !== val13.length) {
9265
- return "".concat(thingy, " must not have leading or trailing spaces. '").concat(val13, "' given.");
9266
- } else if (val13.length < range[0] || val13.length > range[1]) {
9267
- return "".concat(thingy, " must have between ").concat(range[0], " and ").concat(range[1], " characters. '").concat(val13, "' given.");
9366
+ var _validateSym = (val15, thingy, range) => {
9367
+ if (typeof val15 !== "string") {
9368
+ return "".concat(thingy, " must be a string. ").concat(userReadableTypeOfValue_default(val15), " given.");
9369
+ } else if (val15.trim().length !== val15.length) {
9370
+ return "".concat(thingy, " must not have leading or trailing spaces. '").concat(val15, "' given.");
9371
+ } else if (val15.length < range[0] || val15.length > range[1]) {
9372
+ return "".concat(thingy, " must have between ").concat(range[0], " and ").concat(range[1], " characters. '").concat(val15, "' given.");
9268
9373
  }
9269
9374
  };
9270
9375
  var validateName = (name, thingy, shouldThrow = false) => {
@@ -9378,64 +9483,10 @@ var TheatreProject = class {
9378
9483
  }
9379
9484
  };
9380
9485
 
9381
- // core/src/coreExports.ts
9486
+ // core/src/coreExportsShared.ts
9382
9487
  var import_fast_deep_equal3 = __toESM(require_fast_deep_equal());
9383
- var import_theatre_dataverse24 = require("@unseenco/theatre-dataverse");
9384
- var import_theatre_dataverse25 = require("@unseenco/theatre-dataverse");
9385
-
9386
- // core/src/sheets/theatrePageScroll.ts
9387
- var pageScrollConfig = {};
9388
- function buildPageScrollContextFromConfig() {
9389
- return {
9390
- scroller: pageScrollConfig.scroller ?? defaultPageScrollContext.scroller,
9391
- axis: pageScrollConfig.axis ?? defaultPageScrollContext.axis
9392
- };
9393
- }
9394
- function configureTheatrePageScroll(config) {
9395
- const prev = pageScrollConfig;
9396
- pageScrollConfig = {
9397
- scroller: config.scroller ?? prev.scroller,
9398
- axis: config.axis ?? prev.axis
9399
- };
9400
- if (config.scroller !== void 0 || config.axis !== void 0) {
9401
- setActivePageScrollContext(buildPageScrollContextFromConfig());
9402
- }
9403
- return {
9404
- reset() {
9405
- pageScrollConfig = prev;
9406
- setActivePageScrollContext(
9407
- prev.scroller !== void 0 || prev.axis !== void 0 ? {
9408
- scroller: prev.scroller ?? defaultPageScrollContext.scroller,
9409
- axis: prev.axis ?? defaultPageScrollContext.axis
9410
- } : defaultPageScrollContext
9411
- );
9412
- }
9413
- };
9414
- }
9415
- function getTheatrePageScrollConfig() {
9416
- return pageScrollConfig;
9417
- }
9418
- function getTheatrePageScrollContext() {
9419
- const ctx = buildPageScrollContextFromConfig();
9420
- setActivePageScrollContext(ctx);
9421
- return ctx;
9422
- }
9423
- function createDefaultPageScrollDriver(scroller = getTheatrePageScrollContext().scroller, axis = resolvePageScrollAxis(getTheatrePageScrollContext())) {
9424
- if (typeof document !== "undefined" && scroller != null && !isNativeDocumentScroller(scroller) && scroller instanceof HTMLElement) {
9425
- return axis === "horizontal" ? createElementHorizontalScrollDriver(scroller) : createElementScrollDriver(scroller);
9426
- }
9427
- return axis === "horizontal" ? createNativeDocumentHorizontalScrollDriver() : createNativeDocumentScrollDriver();
9428
- }
9429
- function attachTheatrePageScroll(sheet, options = {}) {
9430
- const ctx = getTheatrePageScrollContext();
9431
- const driver = options.driver ?? createDefaultPageScrollDriver(ctx.scroller, resolvePageScrollAxis(ctx));
9432
- sheet.setPageScrollDriver(driver);
9433
- return () => {
9434
- sheet.setPageScrollDriver(void 0);
9435
- };
9436
- }
9437
-
9438
- // core/src/coreExports.ts
9488
+ var import_theatre_dataverse28 = require("@unseenco/theatre-dataverse");
9489
+ var import_theatre_dataverse29 = require("@unseenco/theatre-dataverse");
9439
9490
  function getProject(id, config = {}) {
9440
9491
  const existingProject = projectsSingleton_default.get(id);
9441
9492
  if (existingProject) {
@@ -9476,7 +9527,7 @@ var shallowValidateOnDiskState = (projectId, s2) => {
9476
9527
  throw new InvalidArgumentError(
9477
9528
  "Error validating conf.state in Theatre.getProject(".concat(JSON.stringify(
9478
9529
  projectId
9479
- ), ", conf). The state seems to be formatted in a way that is unreadable to Theatre.js. Read more at https://unseen-theatre.netlify.app/docs/guide/manual/projects#state")
9530
+ ), ", conf). The state seems to be formatted in a way that is unreadable to Theatre.js. Read more at https://www.theatrejs.com/docs/latest/manual/projects#state")
9480
9531
  );
9481
9532
  }
9482
9533
  };
@@ -9513,28 +9564,97 @@ var validateProjectIdOrThrow = (value) => {
9513
9564
  );
9514
9565
  }
9515
9566
  };
9516
- function onChange(pointer3, callback, rafDriver) {
9567
+ function onChange(pointer4, callback, rafDriver) {
9517
9568
  const ticker = rafDriver ? privateAPI(rafDriver).ticker : getCoreTicker();
9518
- if ((0, import_theatre_dataverse24.isPointer)(pointer3)) {
9519
- const pr = (0, import_theatre_dataverse25.pointerToPrism)(pointer3);
9569
+ if ((0, import_theatre_dataverse28.isPointer)(pointer4)) {
9570
+ const pr = (0, import_theatre_dataverse29.pointerToPrism)(pointer4);
9520
9571
  return pr.onChange(ticker, callback, true);
9521
- } else if ((0, import_theatre_dataverse25.isPrism)(pointer3)) {
9522
- return pointer3.onChange(ticker, callback, true);
9572
+ } else if ((0, import_theatre_dataverse29.isPrism)(pointer4)) {
9573
+ return pointer4.onChange(ticker, callback, true);
9523
9574
  } else {
9524
9575
  throw new Error(
9525
9576
  "Called onChange(p) where p is neither a pointer nor a prism."
9526
9577
  );
9527
9578
  }
9528
9579
  }
9529
- function val12(pointer3) {
9530
- if ((0, import_theatre_dataverse24.isPointer)(pointer3)) {
9531
- return (0, import_theatre_dataverse25.pointerToPrism)(pointer3).getValue();
9580
+ function val14(pointer4) {
9581
+ if ((0, import_theatre_dataverse28.isPointer)(pointer4)) {
9582
+ return (0, import_theatre_dataverse29.pointerToPrism)(pointer4).getValue();
9532
9583
  } else {
9533
9584
  throw new Error("Called val(p) where p is not a pointer.");
9534
9585
  }
9535
9586
  }
9536
9587
 
9588
+ // core/src/sheets/theatrePageScroll.ts
9589
+ var pageScrollConfig = {};
9590
+ function buildPageScrollContextFromConfig() {
9591
+ return {
9592
+ scroller: pageScrollConfig.scroller ?? defaultPageScrollContext.scroller,
9593
+ axis: pageScrollConfig.axis ?? defaultPageScrollContext.axis
9594
+ };
9595
+ }
9596
+ function configureTheatrePageScroll(config) {
9597
+ const prev = pageScrollConfig;
9598
+ pageScrollConfig = {
9599
+ scroller: config.scroller ?? prev.scroller,
9600
+ axis: config.axis ?? prev.axis
9601
+ };
9602
+ if (config.scroller !== void 0 || config.axis !== void 0) {
9603
+ setActivePageScrollContext(buildPageScrollContextFromConfig());
9604
+ }
9605
+ return {
9606
+ reset() {
9607
+ pageScrollConfig = prev;
9608
+ setActivePageScrollContext(
9609
+ prev.scroller !== void 0 || prev.axis !== void 0 ? {
9610
+ scroller: prev.scroller ?? defaultPageScrollContext.scroller,
9611
+ axis: prev.axis ?? defaultPageScrollContext.axis
9612
+ } : defaultPageScrollContext
9613
+ );
9614
+ }
9615
+ };
9616
+ }
9617
+ function getTheatrePageScrollConfig() {
9618
+ return pageScrollConfig;
9619
+ }
9620
+ function getTheatrePageScrollContext() {
9621
+ const ctx = buildPageScrollContextFromConfig();
9622
+ setActivePageScrollContext(ctx);
9623
+ return ctx;
9624
+ }
9625
+ function createDefaultPageScrollDriver(scroller = getTheatrePageScrollContext().scroller, axis = resolvePageScrollAxis(getTheatrePageScrollContext())) {
9626
+ if (typeof document !== "undefined" && scroller != null && !isNativeDocumentScroller(scroller) && scroller instanceof HTMLElement) {
9627
+ return axis === "horizontal" ? createElementHorizontalScrollDriver(scroller) : createElementScrollDriver(scroller);
9628
+ }
9629
+ return axis === "horizontal" ? createNativeDocumentHorizontalScrollDriver() : createNativeDocumentScrollDriver();
9630
+ }
9631
+ function attachTheatrePageScroll(sheet, options = {}) {
9632
+ const ctx = getTheatrePageScrollContext();
9633
+ const driver = options.driver ?? createDefaultPageScrollDriver(ctx.scroller, resolvePageScrollAxis(ctx));
9634
+ sheet.setPageScrollDriver(driver);
9635
+ return () => {
9636
+ sheet.setPageScrollDriver(void 0);
9637
+ };
9638
+ }
9639
+
9640
+ // core/src/coreExports-lite.ts
9641
+ var coreExports_lite_exports = {};
9642
+ __export(coreExports_lite_exports, {
9643
+ createRafDriver: () => createRafDriver,
9644
+ getProject: () => getProject,
9645
+ getTheatreCoreRafDriver: () => getTheatreCoreRafDriver,
9646
+ isRemoteEditorWindow: () => isRemoteEditorWindow,
9647
+ notify: () => notify,
9648
+ onChange: () => onChange,
9649
+ privateAPI: () => privateAPI,
9650
+ setCoreRafDriver: () => setCoreRafDriver,
9651
+ setPrivateAPI: () => setPrivateAPI,
9652
+ types: () => propTypes_exports,
9653
+ val: () => val14
9654
+ });
9655
+
9537
9656
  // core/src/CoreBundle.ts
9657
+ var coreExports = isTheatreLiteMode() ? coreExports_lite_exports : coreExports_exports;
9538
9658
  var CoreBundle = class {
9539
9659
  constructor() {
9540
9660
  __publicField(this, "_studio");
@@ -9543,7 +9663,7 @@ var CoreBundle = class {
9543
9663
  return "Theatre_CoreBundle";
9544
9664
  }
9545
9665
  get version() {
9546
- return "0.5.0";
9666
+ return "0.6.0";
9547
9667
  }
9548
9668
  getBitsForStudio(studio, callback) {
9549
9669
  if (this._studio) {
@@ -9555,7 +9675,7 @@ var CoreBundle = class {
9555
9675
  const bits = {
9556
9676
  projectsP: projectsSingleton_default.atom.pointer.projects,
9557
9677
  privateAPI,
9558
- coreExports: coreExports_exports,
9678
+ coreExports,
9559
9679
  getCoreRafDriver
9560
9680
  };
9561
9681
  callback(bits);
@@ -9566,6 +9686,15 @@ var CoreBundle = class {
9566
9686
  registerCoreBundle();
9567
9687
  function registerCoreBundle() {
9568
9688
  if (typeof window == "undefined") return;
9689
+ if (globalThis.__THEATRE_FORCE_LITE__) {
9690
+ const liteBundle = (
9691
+ // @ts-ignore ignore
9692
+ window[coreBundle]
9693
+ );
9694
+ if (liteBundle) {
9695
+ return;
9696
+ }
9697
+ }
9569
9698
  const existingBundle = (
9570
9699
  // @ts-ignore ignore
9571
9700
  window[coreBundle]