@unseenco/theatre-core 0.1.2 → 0.1.4

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
@@ -9,6 +9,11 @@ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
9
  var __getProtoOf = Object.getPrototypeOf;
10
10
  var __hasOwnProp = Object.prototype.hasOwnProperty;
11
11
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
+ var __knownSymbol = (name, symbol) => {
13
+ if (symbol = Symbol[name])
14
+ return symbol;
15
+ throw Error("Symbol." + name + " is not defined");
16
+ };
12
17
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
18
  var __spreadValues = (a2, b2) => {
14
19
  for (var prop in b2 || (b2 = {}))
@@ -50,6 +55,43 @@ var __publicField = (obj, key, value) => {
50
55
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
51
56
  return value;
52
57
  };
58
+ var __await = function(promise, isYieldStar) {
59
+ this[0] = promise;
60
+ this[1] = isYieldStar;
61
+ };
62
+ var __yieldStar = (value) => {
63
+ var obj = value[__knownSymbol("asyncIterator")];
64
+ var isAwait = false;
65
+ var method;
66
+ var it = {};
67
+ if (obj == null) {
68
+ obj = value[__knownSymbol("iterator")]();
69
+ method = (k2) => it[k2] = (x2) => obj[k2](x2);
70
+ } else {
71
+ obj = obj.call(value);
72
+ method = (k2) => it[k2] = (v2) => {
73
+ if (isAwait) {
74
+ isAwait = false;
75
+ if (k2 === "throw")
76
+ throw v2;
77
+ return v2;
78
+ }
79
+ isAwait = true;
80
+ return {
81
+ done: false,
82
+ value: new __await(new Promise((resolve) => {
83
+ var x2 = obj[k2](v2);
84
+ if (!(x2 instanceof Object))
85
+ throw TypeError("Object expected");
86
+ resolve(x2);
87
+ }), 1)
88
+ };
89
+ };
90
+ }
91
+ return it[__knownSymbol("iterator")] = () => it, method("next"), "throw" in obj ? method("throw") : it.throw = (x2) => {
92
+ throw x2;
93
+ }, "return" in obj && method("return"), it;
94
+ };
53
95
 
54
96
  // ../node_modules/timing-function/lib/UnitBezier.js
55
97
  var require_UnitBezier = __commonJS({
@@ -272,11 +314,12 @@ var src_exports = {};
272
314
  __export(src_exports, {
273
315
  createRafDriver: () => createRafDriver,
274
316
  getProject: () => getProject,
317
+ isRemoteEditorWindow: () => isRemoteEditorWindow,
275
318
  notify: () => notify,
276
319
  onChange: () => onChange,
277
320
  setCoreRafDriver: () => setCoreRafDriver,
278
321
  types: () => propTypes_exports,
279
- val: () => val9
322
+ val: () => val10
280
323
  });
281
324
  module.exports = __toCommonJS(src_exports);
282
325
 
@@ -285,11 +328,12 @@ var coreExports_exports = {};
285
328
  __export(coreExports_exports, {
286
329
  createRafDriver: () => createRafDriver,
287
330
  getProject: () => getProject,
331
+ isRemoteEditorWindow: () => isRemoteEditorWindow,
288
332
  notify: () => notify,
289
333
  onChange: () => onChange,
290
334
  setCoreRafDriver: () => setCoreRafDriver,
291
335
  types: () => propTypes_exports,
292
- val: () => val9
336
+ val: () => val10
293
337
  });
294
338
 
295
339
  // core/src/projects/projectsSingleton.ts
@@ -3154,8 +3198,8 @@ var TheatreSheetObject = class {
3154
3198
  }
3155
3199
  return der.getValue();
3156
3200
  }
3157
- set initialValue(val10) {
3158
- privateAPI(this).setInitialValue(val10);
3201
+ set initialValue(val11) {
3202
+ privateAPI(this).setInitialValue(val11);
3159
3203
  }
3160
3204
  };
3161
3205
 
@@ -3170,6 +3214,192 @@ function memoizeFn(producer) {
3170
3214
  };
3171
3215
  }
3172
3216
 
3217
+ // shared/src/utils/addresses.ts
3218
+ var encodePathToProp = memoizeFn(
3219
+ (p2) => (
3220
+ // we're using JSON.stringify here, but we could use a faster alternative.
3221
+ // If you happen to do that, first make sure no `PathToProp_Encoded` is ever
3222
+ // used in the store, otherwise you'll have to write a migration.
3223
+ JSON.stringify(p2)
3224
+ )
3225
+ );
3226
+
3227
+ // shared/src/utils/removePathFromObject.ts
3228
+ function removePathFromObject(base, path) {
3229
+ if (typeof base !== "object" || base === null)
3230
+ return;
3231
+ if (path.length === 0) {
3232
+ for (const key of Object.keys(base)) {
3233
+ delete base[key];
3234
+ }
3235
+ return;
3236
+ }
3237
+ const keysUpToLastKey = path.slice(0, path.length - 1);
3238
+ let cur = base;
3239
+ const childToParentMapping = /* @__PURE__ */ new WeakMap();
3240
+ for (const key of keysUpToLastKey) {
3241
+ const parent2 = cur;
3242
+ const child = parent2[key];
3243
+ if (typeof child !== "object" || child === null) {
3244
+ return;
3245
+ } else {
3246
+ childToParentMapping.set(child, parent2);
3247
+ cur = child;
3248
+ }
3249
+ }
3250
+ const keysReversed = path.slice().reverse();
3251
+ for (const key of keysReversed) {
3252
+ delete cur[key];
3253
+ if (Object.keys(cur).length > 0) {
3254
+ return;
3255
+ } else {
3256
+ cur = childToParentMapping.get(cur);
3257
+ continue;
3258
+ }
3259
+ }
3260
+ }
3261
+
3262
+ // shared/src/utils/transientPropPaths.ts
3263
+ function parseTransientPropPath(input) {
3264
+ if (typeof input === "string") {
3265
+ if (input.length === 0) {
3266
+ throw new Error(
3267
+ 'Transient prop path cannot be an empty string. Use a dot-separated path like "foo.bar".'
3268
+ );
3269
+ }
3270
+ return input.split(".");
3271
+ }
3272
+ return [...input];
3273
+ }
3274
+ function isPathUnderTransientPrefix(path, prefixes) {
3275
+ for (let i2 = 1; i2 <= path.length; i2++) {
3276
+ const prefix = path.slice(0, i2);
3277
+ if (prefixes.has(encodePathToProp(prefix))) {
3278
+ return true;
3279
+ }
3280
+ }
3281
+ return false;
3282
+ }
3283
+ function normalizePropPaths(paths, config, objectKeyForError, optionName) {
3284
+ if (!paths || paths.length === 0) {
3285
+ return /* @__PURE__ */ new Set();
3286
+ }
3287
+ const result = /* @__PURE__ */ new Set();
3288
+ for (const rawPath of paths) {
3289
+ const pathToProp = parseTransientPropPath(rawPath);
3290
+ if (process.env.NODE_ENV !== "production") {
3291
+ const propConfig = getPropConfigByPath(config, pathToProp);
3292
+ if (!propConfig) {
3293
+ throw new Error(
3294
+ 'sheet.object("'.concat(objectKeyForError, '", ..., { ').concat(optionName, ": [...] }): ") + "path ".concat(JSON.stringify(
3295
+ rawPath
3296
+ ), " does not match any prop in the object's config.")
3297
+ );
3298
+ }
3299
+ }
3300
+ result.add(encodePathToProp(pathToProp));
3301
+ }
3302
+ return result;
3303
+ }
3304
+ function normalizeTransientPropPaths(paths, config, objectKeyForError) {
3305
+ return normalizePropPaths(paths, config, objectKeyForError, "transient");
3306
+ }
3307
+ function normalizeStaticPropPaths(paths, config, objectKeyForError) {
3308
+ return normalizePropPaths(paths, config, objectKeyForError, "static");
3309
+ }
3310
+ function stripTransientPathsFromSerializableMap(map, prefixes) {
3311
+ if (prefixes.size === 0) {
3312
+ return map;
3313
+ }
3314
+ const result = cloneDeep_default(map);
3315
+ for (const encodedPrefix of prefixes) {
3316
+ const path = JSON.parse(encodedPrefix);
3317
+ removePathFromObject(result, path);
3318
+ }
3319
+ return result;
3320
+ }
3321
+ function stripTransientPathsFromSequenceTracks(sequence, objectKey, prefixes) {
3322
+ var _a;
3323
+ if (!sequence || prefixes.size === 0)
3324
+ return;
3325
+ const objectTracks = (_a = sequence.tracksByObject) == null ? void 0 : _a[objectKey];
3326
+ if (!objectTracks)
3327
+ return;
3328
+ for (const [encodedPath, trackId] of Object.entries(
3329
+ objectTracks.trackIdByPropPath
3330
+ )) {
3331
+ if (typeof trackId !== "string")
3332
+ continue;
3333
+ const path = JSON.parse(encodedPath);
3334
+ if (isPathUnderTransientPrefix(path, prefixes)) {
3335
+ delete objectTracks.trackIdByPropPath[encodedPath];
3336
+ delete objectTracks.trackData[trackId];
3337
+ }
3338
+ }
3339
+ if (objectTracks.unsequencedPropPaths) {
3340
+ objectTracks.unsequencedPropPaths = objectTracks.unsequencedPropPaths.filter(
3341
+ (encodedPath) => !isPathUnderTransientPrefix(
3342
+ JSON.parse(encodedPath),
3343
+ prefixes
3344
+ )
3345
+ );
3346
+ }
3347
+ }
3348
+ function stripSequenceTracksForPathsFromObjectInSheetState(sheetState, objectKey, prefixes) {
3349
+ if (prefixes.size === 0)
3350
+ return;
3351
+ stripTransientPathsFromSequenceTracks(
3352
+ sheetState.sequence,
3353
+ objectKey,
3354
+ prefixes
3355
+ );
3356
+ if (sheetState.sequencesById) {
3357
+ for (const sequence of Object.values(sheetState.sequencesById)) {
3358
+ stripTransientPathsFromSequenceTracks(sequence, objectKey, prefixes);
3359
+ }
3360
+ }
3361
+ }
3362
+ function stripTransientPropsFromObjectInSheetState(sheetState, objectKey, prefixes) {
3363
+ if (prefixes.size === 0)
3364
+ return;
3365
+ const staticOverrides = sheetState.staticOverrides.byObject[objectKey];
3366
+ if (staticOverrides) {
3367
+ sheetState.staticOverrides.byObject[objectKey] = stripTransientPathsFromSerializableMap(staticOverrides, prefixes);
3368
+ }
3369
+ if (sheetState.staticOverridesByVariant) {
3370
+ for (const variantOverrides of Object.values(
3371
+ sheetState.staticOverridesByVariant
3372
+ )) {
3373
+ const objOverrides = variantOverrides == null ? void 0 : variantOverrides.byObject[objectKey];
3374
+ if (objOverrides) {
3375
+ variantOverrides.byObject[objectKey] = stripTransientPathsFromSerializableMap(objOverrides, prefixes);
3376
+ }
3377
+ }
3378
+ }
3379
+ stripTransientPathsFromSequenceTracks(
3380
+ sheetState.sequence,
3381
+ objectKey,
3382
+ prefixes
3383
+ );
3384
+ if (sheetState.sequencesById) {
3385
+ for (const sequence of Object.values(sheetState.sequencesById)) {
3386
+ stripTransientPathsFromSequenceTracks(sequence, objectKey, prefixes);
3387
+ }
3388
+ }
3389
+ }
3390
+ var transientPropPathsRegistry = /* @__PURE__ */ new Map();
3391
+ function transientPropPathsRegistryKey(projectId, sheetId, objectKey) {
3392
+ return "".concat(projectId, "\0").concat(sheetId, "\0").concat(objectKey);
3393
+ }
3394
+ function registerObjectTransientPropPaths(projectId, sheetId, objectKey, paths) {
3395
+ const key = transientPropPathsRegistryKey(projectId, sheetId, objectKey);
3396
+ if (paths.size === 0) {
3397
+ transientPropPathsRegistry.delete(key);
3398
+ } else {
3399
+ transientPropPathsRegistry.set(key, paths);
3400
+ }
3401
+ }
3402
+
3173
3403
  // shared/src/propTypes/utils.ts
3174
3404
  function isPropConfigComposite(c2) {
3175
3405
  return c2.type === "compound" || c2.type === "enum";
@@ -3185,6 +3415,25 @@ function getPropConfigByPath(parentConf, path) {
3185
3415
  const sub = parentConf.type === "enum" ? parentConf.cases[key] : parentConf.props[key];
3186
3416
  return getPropConfigByPath(sub, rest);
3187
3417
  }
3418
+ function propTypeConfigPersists(conf) {
3419
+ if (conf.type === "image") {
3420
+ return conf.persist !== false;
3421
+ }
3422
+ return true;
3423
+ }
3424
+ function getNonPersistingPropPathEncodings(config) {
3425
+ const result = /* @__PURE__ */ new Set();
3426
+ for (const { path, conf } of iteratePropType(config, [])) {
3427
+ if (!propTypeConfigPersists(conf)) {
3428
+ result.add(encodePathToProp(path));
3429
+ }
3430
+ }
3431
+ return result;
3432
+ }
3433
+ function stripNonPersistingPropValuesFromMap(map, config) {
3434
+ const paths = getNonPersistingPropPathEncodings(config);
3435
+ return stripTransientPathsFromSerializableMap(map, paths);
3436
+ }
3188
3437
  function isPropConfSequencable(conf) {
3189
3438
  return !isPropConfigComposite(conf);
3190
3439
  }
@@ -3206,6 +3455,61 @@ var compoundHasSimpleDescendants = memoizeFn(
3206
3455
  return false;
3207
3456
  }
3208
3457
  );
3458
+ function* iteratePropType(conf, pathPrefix) {
3459
+ if (conf.type === "compound") {
3460
+ for (const key in conf.props) {
3461
+ yield* __yieldStar(iteratePropType(conf.props[key], [
3462
+ ...pathPrefix,
3463
+ key
3464
+ ]));
3465
+ }
3466
+ } else if (conf.type === "enum") {
3467
+ throw new Error("Not implemented yet");
3468
+ } else {
3469
+ return yield { path: pathPrefix, conf };
3470
+ }
3471
+ }
3472
+
3473
+ // shared/src/utils/updateDeep.ts
3474
+ function updateDeep(obj, path, reducer) {
3475
+ if (path.length === 0)
3476
+ return reducer(obj);
3477
+ return hoop(obj, path, reducer);
3478
+ }
3479
+ var hoop = (s2, path, reducer) => {
3480
+ if (path.length === 0) {
3481
+ return reducer(s2);
3482
+ }
3483
+ if (Array.isArray(s2)) {
3484
+ let [index, ...restOfPath] = path;
3485
+ index = parseInt(String(index), 10);
3486
+ if (isNaN(index))
3487
+ index = 0;
3488
+ const oldVal = s2[index];
3489
+ const newVal = hoop(oldVal, restOfPath, reducer);
3490
+ if (oldVal === newVal)
3491
+ return s2;
3492
+ const newS = [...s2];
3493
+ newS.splice(index, 1, newVal);
3494
+ return newS;
3495
+ } else if (typeof s2 === "object" && s2 !== null) {
3496
+ const [key, ...restOfPath] = path;
3497
+ const oldVal = s2[key];
3498
+ const newVal = hoop(oldVal, restOfPath, reducer);
3499
+ if (oldVal === newVal)
3500
+ return s2;
3501
+ const newS = __spreadProps(__spreadValues({}, s2), { [key]: newVal });
3502
+ return newS;
3503
+ } else {
3504
+ const [key, ...restOfPath] = path;
3505
+ return { [key]: hoop(void 0, restOfPath, reducer) };
3506
+ }
3507
+ };
3508
+
3509
+ // shared/src/utils/setDeepImmutable.ts
3510
+ function setDeepImmutable(obj, path, replace) {
3511
+ return updateDeep(obj, path, () => replace);
3512
+ }
3209
3513
 
3210
3514
  // core/src/sequences/sequenceVariants.ts
3211
3515
  var import_theatre_dataverse5 = require("@unseenco/theatre-dataverse");
@@ -3418,6 +3722,11 @@ var SheetObject = class {
3418
3722
  * no-op merge for every app that never uses the remote-sync feature.
3419
3723
  */
3420
3724
  __publicField(this, "_remoteOverride", new import_theatre_dataverse6.Atom({}));
3725
+ /**
3726
+ * Session-only overrides for props with `persist: false`. Not written to
3727
+ * persisted project state and cleared on refresh.
3728
+ */
3729
+ __publicField(this, "_sessionOverrides", new import_theatre_dataverse6.Atom({}));
3421
3730
  __publicField(this, "_cache", new SimpleCache());
3422
3731
  __publicField(this, "_logger");
3423
3732
  __publicField(this, "_internalUtilCtx");
@@ -3491,6 +3800,17 @@ var SheetObject = class {
3491
3800
  const withSeqs = deepMergeWithCache(final, sequenced, withSeqsCache);
3492
3801
  final = withSeqs;
3493
3802
  }
3803
+ const sessionOverrides = (0, import_theatre_dataverse6.val)(this._sessionOverrides.pointer);
3804
+ const withSessionOverridesCache = import_theatre_dataverse6.prism.memo(
3805
+ "withSessionOverridesCache",
3806
+ () => /* @__PURE__ */ new WeakMap(),
3807
+ []
3808
+ );
3809
+ final = deepMergeWithCache(
3810
+ final,
3811
+ sessionOverrides,
3812
+ withSessionOverridesCache
3813
+ );
3494
3814
  const remoteOverride = (0, import_theatre_dataverse6.val)(this._remoteOverride.pointer);
3495
3815
  const withRemoteOverrideCache = import_theatre_dataverse6.prism.memo(
3496
3816
  "withRemoteOverrideCache",
@@ -3540,6 +3860,8 @@ var SheetObject = class {
3540
3860
  () => {
3541
3861
  const untaps = [];
3542
3862
  for (const { trackId, pathToProp, trackVariant } of tracksToProcess) {
3863
+ if (this.template.isNonSequencablePropPath(pathToProp))
3864
+ continue;
3543
3865
  const pr = this._trackIdToPrism(trackId, trackVariant);
3544
3866
  const propConfig = getPropConfigByPath(
3545
3867
  config,
@@ -3602,16 +3924,32 @@ var SheetObject = class {
3602
3924
  }
3603
3925
  validateValue(pointer3, value) {
3604
3926
  }
3605
- setInitialValue(val10) {
3606
- this.validateValue(this.propsP, val10);
3607
- this._initialValue.set(val10);
3927
+ setInitialValue(val11) {
3928
+ this.validateValue(this.propsP, val11);
3929
+ this._initialValue.set(val11);
3930
+ }
3931
+ setSessionOverride(path, value) {
3932
+ const propConfig = getPropConfigByPath(this.template.staticConfig, path);
3933
+ if (!propConfig)
3934
+ return;
3935
+ const sanitized = propConfig.deserializeAndSanitize(value);
3936
+ if (sanitized === void 0)
3937
+ return;
3938
+ this._sessionOverrides.set(
3939
+ setDeepImmutable(this._sessionOverrides.get(), path, sanitized)
3940
+ );
3941
+ }
3942
+ unsetSessionOverride(path) {
3943
+ const next = cloneDeep_default(this._sessionOverrides.get());
3944
+ removePathFromObject(next, path);
3945
+ this._sessionOverrides.set(next);
3608
3946
  }
3609
3947
  /**
3610
3948
  * Internal: called by `RemoteSync` when a value update for this object
3611
3949
  * arrives from a remote editor window. Not exposed on the public API.
3612
3950
  */
3613
- setRemoteOverride(val10) {
3614
- this._remoteOverride.set(val10);
3951
+ setRemoteOverride(val11) {
3952
+ this._remoteOverride.set(val11);
3615
3953
  }
3616
3954
  /**
3617
3955
  * Internal: used by `RemoteSync` to subscribe to this object's fully
@@ -4100,7 +4438,7 @@ function isObjectEmpty(obj) {
4100
4438
  return typeof obj === "object" && obj !== null && Object.keys(obj).length === 0;
4101
4439
  }
4102
4440
  var SheetObjectTemplate = class {
4103
- constructor(sheetTemplate, objectKey, nativeObject, config, _temp_actions) {
4441
+ constructor(sheetTemplate, objectKey, nativeObject, config, _temp_actions, transient, staticPropPaths) {
4104
4442
  this.sheetTemplate = sheetTemplate;
4105
4443
  __publicField(this, "address");
4106
4444
  __publicField(this, "type", "Theatre_SheetObjectTemplate");
@@ -4112,14 +4450,36 @@ var SheetObjectTemplate = class {
4112
4450
  __publicField(this, "pointerToStaticOverrides");
4113
4451
  __publicField(this, "pointerToAhistoricSheetState");
4114
4452
  __publicField(this, "pointerToAhistoricStaticOverrides");
4453
+ __publicField(this, "_transientPropPaths", /* @__PURE__ */ new Set());
4454
+ __publicField(this, "_staticPropPaths", /* @__PURE__ */ new Set());
4455
+ __publicField(this, "_visibleInOutline", true);
4115
4456
  this.address = __spreadProps(__spreadValues({}, sheetTemplate.address), { objectKey });
4116
4457
  this._config = new import_theatre_dataverse7.Atom(config);
4117
4458
  this._temp_actions_atom = new import_theatre_dataverse7.Atom(_temp_actions);
4459
+ this._transientPropPaths = normalizeTransientPropPaths(
4460
+ transient,
4461
+ config,
4462
+ objectKey
4463
+ );
4464
+ this._staticPropPaths = normalizeStaticPropPaths(
4465
+ staticPropPaths,
4466
+ config,
4467
+ objectKey
4468
+ );
4118
4469
  this.project = sheetTemplate.project;
4470
+ registerObjectTransientPropPaths(
4471
+ this.address.projectId,
4472
+ this.address.sheetId,
4473
+ objectKey,
4474
+ this._transientPropPaths
4475
+ );
4119
4476
  this.pointerToSheetState = this.sheetTemplate.project.pointers.historic.sheetsById[this.address.sheetId];
4120
4477
  this.pointerToStaticOverrides = this.pointerToSheetState.staticOverrides.byObject[this.address.objectKey];
4121
4478
  this.pointerToAhistoricSheetState = this.sheetTemplate.project.pointers.ahistoric.sheetsById[this.address.sheetId];
4122
4479
  this.pointerToAhistoricStaticOverrides = this.pointerToAhistoricSheetState.staticOverrides.byObject[this.address.objectKey];
4480
+ this._stripTransientFromHistoricState();
4481
+ this._stripSequencedStaticPathsFromHistoricState();
4482
+ this._stripNonPersistingPropsFromAhistoricState();
4123
4483
  }
4124
4484
  get staticConfig() {
4125
4485
  return this._config.get();
@@ -4133,12 +4493,85 @@ var SheetObjectTemplate = class {
4133
4493
  get _temp_actionsPointer() {
4134
4494
  return this._temp_actions_atom.pointer;
4135
4495
  }
4496
+ _stripNonPersistingPropsFromAhistoricState() {
4497
+ const config = (0, import_theatre_dataverse7.val)(this.configPointer);
4498
+ this.project._stripNonPersistingPropsFromAhistoric(
4499
+ this.address.sheetId,
4500
+ this.address.objectKey,
4501
+ config
4502
+ );
4503
+ this.project._stripNonPersistingPropsFromHistoric(
4504
+ this.address.sheetId,
4505
+ this.address.objectKey,
4506
+ config
4507
+ );
4508
+ }
4509
+ _stripTransientFromHistoricState() {
4510
+ if (this._transientPropPaths.size === 0)
4511
+ return;
4512
+ this.project._stripTransientPropsFromHistoric(
4513
+ this.address.sheetId,
4514
+ this.address.objectKey,
4515
+ this._transientPropPaths
4516
+ );
4517
+ }
4518
+ _stripSequencedStaticPathsFromHistoricState() {
4519
+ if (this._staticPropPaths.size === 0)
4520
+ return;
4521
+ this.project._stripSequenceTracksFromHistoric(
4522
+ this.address.sheetId,
4523
+ this.address.objectKey,
4524
+ this._staticPropPaths
4525
+ );
4526
+ }
4136
4527
  createInstance(sheet, nativeObject, config) {
4137
4528
  this._config.set(config);
4138
4529
  return new SheetObject(sheet, this, nativeObject);
4139
4530
  }
4140
4531
  reconfigure(config) {
4141
4532
  this._config.set(config);
4533
+ this._stripNonPersistingPropsFromAhistoricState();
4534
+ }
4535
+ setTransientPropPaths(transient, config) {
4536
+ this._transientPropPaths = normalizeTransientPropPaths(
4537
+ transient,
4538
+ config,
4539
+ this.address.objectKey
4540
+ );
4541
+ registerObjectTransientPropPaths(
4542
+ this.address.projectId,
4543
+ this.address.sheetId,
4544
+ this.address.objectKey,
4545
+ this._transientPropPaths
4546
+ );
4547
+ this._stripTransientFromHistoricState();
4548
+ }
4549
+ setStaticPropPaths(staticPropPaths, config) {
4550
+ this._staticPropPaths = normalizeStaticPropPaths(
4551
+ staticPropPaths,
4552
+ config,
4553
+ this.address.objectKey
4554
+ );
4555
+ this._stripSequencedStaticPathsFromHistoricState();
4556
+ }
4557
+ isStaticPropPath(path) {
4558
+ return isPathUnderTransientPrefix(path, this._staticPropPaths);
4559
+ }
4560
+ isNonSequencablePropPath(path) {
4561
+ if (this.isTransientPropPath(path) || this.isStaticPropPath(path)) {
4562
+ return true;
4563
+ }
4564
+ const propConfig = getPropConfigByPath(this.staticConfig, path);
4565
+ return propConfig ? !propTypeConfigPersists(propConfig) : false;
4566
+ }
4567
+ getStaticPropPaths() {
4568
+ return this._staticPropPaths;
4569
+ }
4570
+ isTransientPropPath(path) {
4571
+ return isPathUnderTransientPrefix(path, this._transientPropPaths);
4572
+ }
4573
+ getTransientPropPaths() {
4574
+ return this._transientPropPaths;
4142
4575
  }
4143
4576
  /**
4144
4577
  * The `actions` api is temporary until we implement events.
@@ -4146,6 +4579,12 @@ var SheetObjectTemplate = class {
4146
4579
  _temp_setActions(actions) {
4147
4580
  this._temp_actions_atom.set(actions);
4148
4581
  }
4582
+ setVisibleInOutline(visible) {
4583
+ this._visibleInOutline = visible;
4584
+ }
4585
+ isVisibleInOutline() {
4586
+ return this._visibleInOutline;
4587
+ }
4149
4588
  /**
4150
4589
  * Returns the default values (all defaults are read from the config)
4151
4590
  */
@@ -4175,7 +4614,17 @@ var SheetObjectTemplate = class {
4175
4614
  )) != null ? _a : {};
4176
4615
  const config = (0, import_theatre_dataverse7.val)(this.configPointer);
4177
4616
  const deserialized = config.deserializeAndSanitize(json) || {};
4178
- return deserialized;
4617
+ const withoutNonPersisting = stripNonPersistingPropValuesFromMap(
4618
+ deserialized,
4619
+ config
4620
+ );
4621
+ if (this._transientPropPaths.size > 0) {
4622
+ return stripTransientPathsFromSerializableMap(
4623
+ withoutNonPersisting,
4624
+ this._transientPropPaths
4625
+ );
4626
+ }
4627
+ return withoutNonPersisting;
4179
4628
  })
4180
4629
  );
4181
4630
  }
@@ -4191,7 +4640,7 @@ var SheetObjectTemplate = class {
4191
4640
  const json = (_a = (0, import_theatre_dataverse7.val)(this.pointerToAhistoricStaticOverrides)) != null ? _a : {};
4192
4641
  const config = (0, import_theatre_dataverse7.val)(this.configPointer);
4193
4642
  const deserialized = config.deserializeAndSanitize(json) || {};
4194
- return deserialized;
4643
+ return stripNonPersistingPropValuesFromMap(deserialized, config);
4195
4644
  })
4196
4645
  );
4197
4646
  }
@@ -4248,6 +4697,8 @@ var SheetObjectTemplate = class {
4248
4697
  const pathToProp = parsePathToProp(pathToPropInString);
4249
4698
  if (!pathToProp)
4250
4699
  continue;
4700
+ if (this.isNonSequencablePropPath(pathToProp))
4701
+ continue;
4251
4702
  const propConfig = getPropConfigByPath(objectConfig, pathToProp);
4252
4703
  const isSequencable = propConfig && isPropConfSequencable(propConfig);
4253
4704
  if (!isSequencable)
@@ -4359,16 +4810,6 @@ function parsePathToProp(pathToPropInString) {
4359
4810
  // core/src/sheets/SheetTemplate.ts
4360
4811
  var import_theatre_dataverse16 = require("@unseenco/theatre-dataverse");
4361
4812
 
4362
- // shared/src/utils/addresses.ts
4363
- var encodePathToProp = memoizeFn(
4364
- (p2) => (
4365
- // we're using JSON.stringify here, but we could use a faster alternative.
4366
- // If you happen to do that, first make sure no `PathToProp_Encoded` is ever
4367
- // used in the store, otherwise you'll have to write a migration.
4368
- JSON.stringify(p2)
4369
- )
4370
- );
4371
-
4372
4813
  // shared/src/utils/didYouMean.ts
4373
4814
  var import_propose = __toESM(require_propose());
4374
4815
  function didYouMean(str, dictionary, prepend = "Did you mean ", append = "?") {
@@ -5599,11 +6040,11 @@ function sanitizeCompoundProps(props) {
5599
6040
  );
5600
6041
  }
5601
6042
  }
5602
- const val10 = props[key];
5603
- if (isLonghandPropType(val10)) {
5604
- sanitizedProps[key] = val10;
6043
+ const val11 = props[key];
6044
+ if (isLonghandPropType(val11)) {
6045
+ sanitizedProps[key] = val11;
5605
6046
  } else {
5606
- sanitizedProps[key] = toLonghandProp(val10);
6047
+ sanitizedProps[key] = toLonghandProp(val11);
5607
6048
  }
5608
6049
  }
5609
6050
  return sanitizedProps;
@@ -5701,18 +6142,18 @@ var file = (defaultValue, opts = {}) => {
5701
6142
  deserializeAndSanitize: _ensureFile
5702
6143
  };
5703
6144
  };
5704
- var _ensureFile = (val10) => {
5705
- if (!val10)
6145
+ var _ensureFile = (val11) => {
6146
+ if (!val11)
5706
6147
  return void 0;
5707
6148
  let valid = true;
5708
- if (typeof val10.id !== "string" && ![null, void 0].includes(val10.id)) {
6149
+ if (typeof val11.id !== "string" && ![null, void 0].includes(val11.id)) {
5709
6150
  valid = false;
5710
6151
  }
5711
- if (val10.type !== "file")
6152
+ if (val11.type !== "file")
5712
6153
  valid = false;
5713
6154
  if (!valid)
5714
6155
  return void 0;
5715
- return val10;
6156
+ return val11;
5716
6157
  };
5717
6158
  var image = (defaultValue, opts = {}) => {
5718
6159
  if (process.env.NODE_ENV !== "production") {
@@ -5732,22 +6173,23 @@ var image = (defaultValue, opts = {}) => {
5732
6173
  valueType: null,
5733
6174
  [propTypeSymbol]: "TheatrePropType",
5734
6175
  label: opts.label,
6176
+ persist: opts.persist !== false,
5735
6177
  interpolate,
5736
6178
  deserializeAndSanitize: _ensureImage
5737
6179
  };
5738
6180
  };
5739
- var _ensureImage = (val10) => {
5740
- if (!val10)
6181
+ var _ensureImage = (val11) => {
6182
+ if (!val11)
5741
6183
  return void 0;
5742
6184
  let valid = true;
5743
- if (typeof val10.id !== "string" && ![null, void 0].includes(val10.id)) {
6185
+ if (typeof val11.id !== "string" && ![null, void 0].includes(val11.id)) {
5744
6186
  valid = false;
5745
6187
  }
5746
- if (val10.type !== "image")
6188
+ if (val11.type !== "image")
5747
6189
  valid = false;
5748
6190
  if (!valid)
5749
6191
  return void 0;
5750
- return val10;
6192
+ return val11;
5751
6193
  };
5752
6194
  var number = (defaultValue, opts = {}) => {
5753
6195
  var _a;
@@ -5862,12 +6304,12 @@ var rgba = (defaultValue = { r: 0, g: 0, b: 0, a: 1 }, opts = {}) => {
5862
6304
  deserializeAndSanitize: _sanitizeRgba
5863
6305
  };
5864
6306
  };
5865
- var _sanitizeRgba = (val10) => {
5866
- if (!val10)
6307
+ var _sanitizeRgba = (val11) => {
6308
+ if (!val11)
5867
6309
  return void 0;
5868
6310
  let valid = true;
5869
6311
  for (const c2 of ["r", "g", "b", "a"]) {
5870
- if (!Object.prototype.hasOwnProperty.call(val10, c2) || typeof val10[c2] !== "number") {
6312
+ if (!Object.prototype.hasOwnProperty.call(val11, c2) || typeof val11[c2] !== "number") {
5871
6313
  valid = false;
5872
6314
  }
5873
6315
  }
@@ -5877,7 +6319,7 @@ var _sanitizeRgba = (val10) => {
5877
6319
  for (const c2 of ["r", "g", "b", "a"]) {
5878
6320
  ;
5879
6321
  sanitized[c2] = Math.min(
5880
- Math.max(val10[c2], 0),
6322
+ Math.max(val11[c2], 0),
5881
6323
  1
5882
6324
  );
5883
6325
  }
@@ -5917,8 +6359,8 @@ var boolean = (defaultValue, opts = {}) => {
5917
6359
  deserializeAndSanitize: _ensureBoolean
5918
6360
  };
5919
6361
  };
5920
- var _ensureBoolean = (val10) => {
5921
- return typeof val10 === "boolean" ? val10 : void 0;
6362
+ var _ensureBoolean = (val11) => {
6363
+ return typeof val11 === "boolean" ? val11 : void 0;
5922
6364
  };
5923
6365
  function leftInterpolate(left) {
5924
6366
  return left;
@@ -6067,6 +6509,18 @@ var TheatreSheet = class {
6067
6509
  if ((opts == null ? void 0 : opts.reconfigure) === true) {
6068
6510
  const sanitizedConfig = compound(config);
6069
6511
  existingObject.template.reconfigure(sanitizedConfig);
6512
+ if (opts.transient !== void 0) {
6513
+ existingObject.template.setTransientPropPaths(
6514
+ opts.transient,
6515
+ sanitizedConfig
6516
+ );
6517
+ }
6518
+ if (opts.static !== void 0) {
6519
+ existingObject.template.setStaticPropPaths(
6520
+ opts.static,
6521
+ sanitizedConfig
6522
+ );
6523
+ }
6070
6524
  weakMapOfUnsanitizedProps.set(existingObject, config);
6071
6525
  return existingObject.publicApi;
6072
6526
  } else {
@@ -6080,6 +6534,21 @@ var TheatreSheet = class {
6080
6534
  if (actions) {
6081
6535
  existingObject.template._temp_setActions(actions);
6082
6536
  }
6537
+ if ((opts == null ? void 0 : opts.visible) !== void 0) {
6538
+ existingObject.template.setVisibleInOutline(opts.visible);
6539
+ }
6540
+ if ((opts == null ? void 0 : opts.transient) !== void 0) {
6541
+ existingObject.template.setTransientPropPaths(
6542
+ opts.transient,
6543
+ existingObject.template.staticConfig
6544
+ );
6545
+ }
6546
+ if ((opts == null ? void 0 : opts.static) !== void 0) {
6547
+ existingObject.template.setStaticPropPaths(
6548
+ opts.static,
6549
+ existingObject.template.staticConfig
6550
+ );
6551
+ }
6083
6552
  return existingObject.publicApi;
6084
6553
  } else {
6085
6554
  const sanitizedConfig = compound(config);
@@ -6087,7 +6556,10 @@ var TheatreSheet = class {
6087
6556
  sanitizedPath,
6088
6557
  nativeObject,
6089
6558
  sanitizedConfig,
6090
- actions
6559
+ actions,
6560
+ opts == null ? void 0 : opts.visible,
6561
+ opts == null ? void 0 : opts.transient,
6562
+ opts == null ? void 0 : opts.static
6091
6563
  );
6092
6564
  if (process.env.NODE_ENV !== "production") {
6093
6565
  weakMapOfUnsanitizedProps.set(object, config);
@@ -6196,13 +6668,18 @@ var Sheet = class {
6196
6668
  * @remarks At some point, we have to reconcile the concept of "an object"
6197
6669
  * with that of "an element."
6198
6670
  */
6199
- createObject(objectKey, nativeObject, config, actions = {}) {
6671
+ createObject(objectKey, nativeObject, config, actions = {}, visibleInOutline, transient, staticPropPaths) {
6200
6672
  const objTemplate = this.template.getObjectTemplate(
6201
6673
  objectKey,
6202
6674
  nativeObject,
6203
6675
  config,
6204
- actions
6676
+ actions,
6677
+ transient,
6678
+ staticPropPaths
6205
6679
  );
6680
+ if (visibleInOutline !== void 0) {
6681
+ objTemplate.setVisibleInOutline(visibleInOutline);
6682
+ }
6206
6683
  const object = objTemplate.createInstance(this, nativeObject, config);
6207
6684
  this._objects.setByPointer((p2) => p2[objectKey], object);
6208
6685
  this.project._remoteSync.registerObject(object);
@@ -6302,6 +6779,7 @@ var SheetTemplate = class {
6302
6779
  __publicField(this, "objectTemplatesP", this._objectTemplates.pointer);
6303
6780
  __publicField(this, "_pendingOutlineNamespaces", {});
6304
6781
  __publicField(this, "_sequenceVariants", [DEFAULT_SEQUENCE_VARIANT]);
6782
+ __publicField(this, "_visibleInOutline", true);
6305
6783
  this.address = __spreadProps(__spreadValues({}, project.address), { sheetId });
6306
6784
  }
6307
6785
  getInstance(instanceId) {
@@ -6312,7 +6790,7 @@ var SheetTemplate = class {
6312
6790
  }
6313
6791
  return inst;
6314
6792
  }
6315
- getObjectTemplate(objectKey, nativeObject, config, actions) {
6793
+ getObjectTemplate(objectKey, nativeObject, config, actions, transient, staticPropPaths) {
6316
6794
  let template = this._objectTemplates.get()[objectKey];
6317
6795
  if (!template) {
6318
6796
  template = new SheetObjectTemplate(
@@ -6320,9 +6798,18 @@ var SheetTemplate = class {
6320
6798
  objectKey,
6321
6799
  nativeObject,
6322
6800
  config,
6323
- actions
6801
+ actions,
6802
+ transient,
6803
+ staticPropPaths
6324
6804
  );
6325
6805
  this._objectTemplates.setByPointer((p2) => p2[objectKey], template);
6806
+ } else {
6807
+ if (transient !== void 0) {
6808
+ template.setTransientPropPaths(transient, config);
6809
+ }
6810
+ if (staticPropPaths !== void 0) {
6811
+ template.setStaticPropPaths(staticPropPaths, config);
6812
+ }
6326
6813
  }
6327
6814
  return template;
6328
6815
  }
@@ -6346,11 +6833,17 @@ var SheetTemplate = class {
6346
6833
  "sheet.declareSequenceVariants"
6347
6834
  );
6348
6835
  }
6836
+ setVisibleInOutline(visible) {
6837
+ this._visibleInOutline = visible;
6838
+ }
6839
+ isVisibleInOutline() {
6840
+ return this._visibleInOutline;
6841
+ }
6349
6842
  };
6350
6843
 
6351
6844
  // core/src/projects/Project.ts
6352
- var import_theatre_dataverse18 = require("@unseenco/theatre-dataverse");
6353
6845
  var import_theatre_dataverse19 = require("@unseenco/theatre-dataverse");
6846
+ var import_theatre_dataverse20 = require("@unseenco/theatre-dataverse");
6354
6847
 
6355
6848
  // shared/src/utils/delay.ts
6356
6849
  var delay = (dur) => new Promise((resolve) => setTimeout(resolve, dur));
@@ -6752,13 +7245,13 @@ var globals_default = globals;
6752
7245
  async function initialiseProjectState(studio, project, onDiskState) {
6753
7246
  await delay_default(0);
6754
7247
  studio.transaction(({ drafts }) => {
6755
- var _a;
7248
+ var _a, _b, _c;
6756
7249
  const projectId = project.address.projectId;
6757
7250
  drafts.ephemeral.coreByProject[projectId] = {
6758
7251
  lastExportedObject: null,
6759
7252
  loadingState: { type: "loading" }
6760
7253
  };
6761
- drafts.ahistoric.coreByProject[projectId] = {
7254
+ (_b = (_a = drafts.ahistoric.coreByProject)[projectId]) != null ? _b : _a[projectId] = {
6762
7255
  ahistoricStuff: ""
6763
7256
  };
6764
7257
  function useInitialState() {
@@ -6788,7 +7281,7 @@ async function initialiseProjectState(studio, project, onDiskState) {
6788
7281
  onDiskState: onDiskState2
6789
7282
  };
6790
7283
  }
6791
- const browserState = (_a = e(drafts.historic)) == null ? void 0 : _a.coreByProject[project.address.projectId];
7284
+ const browserState = (_c = e(drafts.historic)) == null ? void 0 : _c.coreByProject[project.address.projectId];
6792
7285
  if (!browserState) {
6793
7286
  if (!onDiskState) {
6794
7287
  useInitialState();
@@ -7008,6 +7501,63 @@ function _coreLogger(config) {
7008
7501
  return internal2.getLogger().named("Theatre");
7009
7502
  }
7010
7503
 
7504
+ // shared/src/utils/assets.ts
7505
+ var import_theatre_dataverse18 = require("@unseenco/theatre-dataverse");
7506
+
7507
+ // shared/src/utils/forEachDeep.ts
7508
+ function forEachPropDeep(m, fn2, startingPath = []) {
7509
+ if (typeof m === "object" && m) {
7510
+ if (isImage(m) || isRGBA(m)) {
7511
+ fn2(m, startingPath);
7512
+ return;
7513
+ }
7514
+ for (const [key, value] of Object.entries(m)) {
7515
+ forEachPropDeep(value, fn2, [...startingPath, key]);
7516
+ }
7517
+ } else if (m === void 0 || m === null) {
7518
+ return;
7519
+ } else {
7520
+ fn2(m, startingPath);
7521
+ }
7522
+ }
7523
+ var isImage = (value) => {
7524
+ return typeof value === "object" && value !== null && Object.hasOwnProperty.call(value, "type") && // @ts-ignore
7525
+ value.type === "image" && Object.hasOwnProperty.call(value, "id") && // @ts-ignore
7526
+ typeof value.id === "string" && // @ts-ignore
7527
+ value.id !== "";
7528
+ };
7529
+ var isRGBA = (value) => {
7530
+ return typeof value === "object" && value !== null && Object.hasOwnProperty.call(value, "r") && Object.hasOwnProperty.call(value, "g") && Object.hasOwnProperty.call(value, "b") && Object.hasOwnProperty.call(value, "a") && // @ts-ignore
7531
+ typeof value.r === "number" && // @ts-ignore
7532
+ typeof value.g === "number" && // @ts-ignore
7533
+ typeof value.b === "number" && // @ts-ignore
7534
+ typeof value.a === "number";
7535
+ };
7536
+
7537
+ // shared/src/utils/assets.ts
7538
+ function stripImageAssetsFromAhistoricStaticOverrides(ahistoricStaticOverridesByObject) {
7539
+ for (const objectKey of Object.keys(ahistoricStaticOverridesByObject)) {
7540
+ const overrides = ahistoricStaticOverridesByObject[objectKey];
7541
+ if (!overrides)
7542
+ continue;
7543
+ const cloned = cloneDeep_default(overrides);
7544
+ forEachPropDeep(
7545
+ cloned,
7546
+ (value, path) => {
7547
+ if ((value == null ? void 0 : value.type) === "image") {
7548
+ removePathFromObject(cloned, path);
7549
+ }
7550
+ },
7551
+ []
7552
+ );
7553
+ if (Object.keys(cloned).length === 0) {
7554
+ delete ahistoricStaticOverridesByObject[objectKey];
7555
+ } else {
7556
+ ahistoricStaticOverridesByObject[objectKey] = cloned;
7557
+ }
7558
+ }
7559
+ }
7560
+
7011
7561
  // core/src/projects/Project.ts
7012
7562
  var Project = class {
7013
7563
  constructor(id, config = {}, publicApi) {
@@ -7019,7 +7569,7 @@ var Project = class {
7019
7569
  __publicField(this, "_studioReadyDeferred");
7020
7570
  __publicField(this, "_assetStorageReadyDeferred");
7021
7571
  __publicField(this, "_readyPromise");
7022
- __publicField(this, "_sheetTemplates", new import_theatre_dataverse19.Atom({}));
7572
+ __publicField(this, "_sheetTemplates", new import_theatre_dataverse20.Atom({}));
7023
7573
  __publicField(this, "sheetTemplatesP", this._sheetTemplates.pointer);
7024
7574
  __publicField(this, "_studio");
7025
7575
  __publicField(this, "_onDiskStateAtom");
@@ -7033,7 +7583,7 @@ var Project = class {
7033
7583
  this._logger.traceDev("creating project");
7034
7584
  this.address = { projectId: id };
7035
7585
  this._remoteSync = new RemoteSync(this);
7036
- const onDiskStateAtom = new import_theatre_dataverse19.Atom({
7586
+ const onDiskStateAtom = new import_theatre_dataverse20.Atom({
7037
7587
  ahistoric: {
7038
7588
  ahistoricStuff: ""
7039
7589
  },
@@ -7062,9 +7612,9 @@ var Project = class {
7062
7612
  }
7063
7613
  };
7064
7614
  this._pointerProxies = {
7065
- historic: new import_theatre_dataverse18.PointerProxy(onDiskStateAtom.pointer.historic),
7066
- ahistoric: new import_theatre_dataverse18.PointerProxy(onDiskStateAtom.pointer.ahistoric),
7067
- ephemeral: new import_theatre_dataverse18.PointerProxy(onDiskStateAtom.pointer.ephemeral)
7615
+ historic: new import_theatre_dataverse19.PointerProxy(onDiskStateAtom.pointer.historic),
7616
+ ahistoric: new import_theatre_dataverse19.PointerProxy(onDiskStateAtom.pointer.ahistoric),
7617
+ ephemeral: new import_theatre_dataverse19.PointerProxy(onDiskStateAtom.pointer.ephemeral)
7068
7618
  };
7069
7619
  this.pointers = {
7070
7620
  historic: this._pointerProxies.historic.pointer,
@@ -7131,6 +7681,7 @@ var Project = class {
7131
7681
  this._pointerProxies.ephemeral.setPointer(
7132
7682
  studio.atomP.ephemeral.coreByProject[this.address.projectId]
7133
7683
  );
7684
+ this._stripImageAssetsFromAhistoricState();
7134
7685
  await studio.createAssetStorage(this, (_a = this.config.assets) == null ? void 0 : _a.baseUrl).then((assetStorage) => {
7135
7686
  this.assetStorage = assetStorage;
7136
7687
  this._assetStorageReadyDeferred.resolve(void 0);
@@ -7152,12 +7703,15 @@ var Project = class {
7152
7703
  isReady() {
7153
7704
  return this._studioReadyDeferred.status === "resolved" && this._assetStorageReadyDeferred.status === "resolved";
7154
7705
  }
7155
- getOrCreateSheet(sheetId, instanceId = "default") {
7706
+ getOrCreateSheet(sheetId, instanceId = "default", opts) {
7156
7707
  let template = this._sheetTemplates.get()[sheetId];
7157
7708
  if (!template) {
7158
7709
  template = new SheetTemplate(this, sheetId);
7159
7710
  this._sheetTemplates.reduce((s2) => __spreadProps(__spreadValues({}, s2), { [sheetId]: template }));
7160
7711
  }
7712
+ if ((opts == null ? void 0 : opts.visible) !== void 0) {
7713
+ template.setVisibleInOutline(opts.visible);
7714
+ }
7161
7715
  const sheet = template.getInstance(instanceId);
7162
7716
  this._remoteSync.registerSheet(sheet);
7163
7717
  return sheet;
@@ -7210,16 +7764,144 @@ var Project = class {
7210
7764
  });
7211
7765
  }
7212
7766
  }
7767
+ _stripImageAssetsFromAhistoricState() {
7768
+ const strip = (ahistoric) => {
7769
+ var _a;
7770
+ for (const sheetState of Object.values((_a = ahistoric.sheetsById) != null ? _a : {})) {
7771
+ if (!sheetState)
7772
+ continue;
7773
+ stripImageAssetsFromAhistoricStaticOverrides(
7774
+ sheetState.staticOverrides.byObject
7775
+ );
7776
+ }
7777
+ };
7778
+ if (this._studio) {
7779
+ this._studio.transaction(({ drafts }) => {
7780
+ const ahistoric = drafts.ahistoric.coreByProject[this.address.projectId];
7781
+ if (ahistoric)
7782
+ strip(ahistoric);
7783
+ });
7784
+ } else {
7785
+ this._mutateCoreAhistoric(strip);
7786
+ }
7787
+ }
7788
+ _stripNonPersistingPropsFromAhistoric(sheetId, objectKey, config) {
7789
+ const paths = getNonPersistingPropPathEncodings(config);
7790
+ if (paths.size === 0)
7791
+ return;
7792
+ const strip = (ahistoric) => {
7793
+ var _a;
7794
+ const sheetState = (_a = ahistoric.sheetsById) == null ? void 0 : _a[sheetId];
7795
+ if (!sheetState)
7796
+ return;
7797
+ const staticOverrides = sheetState.staticOverrides.byObject[objectKey];
7798
+ if (staticOverrides) {
7799
+ sheetState.staticOverrides.byObject[objectKey] = stripTransientPathsFromSerializableMap(staticOverrides, paths);
7800
+ }
7801
+ };
7802
+ if (this._studio) {
7803
+ this._studio.transaction(({ drafts }) => {
7804
+ const ahistoric = drafts.ahistoric.coreByProject[this.address.projectId];
7805
+ if (ahistoric)
7806
+ strip(ahistoric);
7807
+ });
7808
+ } else {
7809
+ this._mutateCoreAhistoric(strip);
7810
+ }
7811
+ }
7812
+ _stripNonPersistingPropsFromHistoric(sheetId, objectKey, config) {
7813
+ const paths = getNonPersistingPropPathEncodings(config);
7814
+ if (paths.size === 0)
7815
+ return;
7816
+ const strip = (historic) => {
7817
+ const sheetState = historic.sheetsById[sheetId];
7818
+ if (!sheetState)
7819
+ return;
7820
+ stripTransientPropsFromObjectInSheetState(sheetState, objectKey, paths);
7821
+ stripSequenceTracksForPathsFromObjectInSheetState(
7822
+ sheetState,
7823
+ objectKey,
7824
+ paths
7825
+ );
7826
+ };
7827
+ if (this._studio) {
7828
+ this._studio.transaction(({ drafts }) => {
7829
+ const historic = drafts.historic.coreByProject[this.address.projectId];
7830
+ if (historic)
7831
+ strip(historic);
7832
+ });
7833
+ } else {
7834
+ this._onDiskStateAtom.reduce((state) => {
7835
+ const historic = __spreadValues({}, state.historic);
7836
+ strip(historic);
7837
+ return __spreadProps(__spreadValues({}, state), { historic });
7838
+ });
7839
+ }
7840
+ }
7841
+ _stripTransientPropsFromHistoric(sheetId, objectKey, transientPaths) {
7842
+ if (transientPaths.size === 0)
7843
+ return;
7844
+ const strip = (historic) => {
7845
+ const sheetState = historic.sheetsById[sheetId];
7846
+ if (!sheetState)
7847
+ return;
7848
+ stripTransientPropsFromObjectInSheetState(
7849
+ sheetState,
7850
+ objectKey,
7851
+ transientPaths
7852
+ );
7853
+ };
7854
+ if (this._studio) {
7855
+ this._studio.transaction(({ drafts }) => {
7856
+ const historic = drafts.historic.coreByProject[this.address.projectId];
7857
+ if (historic)
7858
+ strip(historic);
7859
+ });
7860
+ } else {
7861
+ this._onDiskStateAtom.reduce((state) => {
7862
+ const historic = __spreadValues({}, state.historic);
7863
+ strip(historic);
7864
+ return __spreadProps(__spreadValues({}, state), { historic });
7865
+ });
7866
+ }
7867
+ }
7868
+ _stripSequenceTracksFromHistoric(sheetId, objectKey, propPaths) {
7869
+ if (propPaths.size === 0)
7870
+ return;
7871
+ const strip = (historic) => {
7872
+ const sheetState = historic.sheetsById[sheetId];
7873
+ if (!sheetState)
7874
+ return;
7875
+ stripSequenceTracksForPathsFromObjectInSheetState(
7876
+ sheetState,
7877
+ objectKey,
7878
+ propPaths
7879
+ );
7880
+ };
7881
+ if (this._studio) {
7882
+ this._studio.transaction(({ drafts }) => {
7883
+ const historic = drafts.historic.coreByProject[this.address.projectId];
7884
+ if (historic)
7885
+ strip(historic);
7886
+ });
7887
+ } else {
7888
+ this._onDiskStateAtom.reduce((state) => {
7889
+ const historic = __spreadValues({}, state.historic);
7890
+ strip(historic);
7891
+ return __spreadProps(__spreadValues({}, state), { historic });
7892
+ });
7893
+ }
7894
+ }
7213
7895
  };
7214
7896
 
7215
7897
  // shared/src/utils/sanitizers.ts
7216
- var _validateSym = (val10, thingy, range) => {
7217
- if (typeof val10 !== "string") {
7218
- return "".concat(thingy, " must be a string. ").concat(userReadableTypeOfValue_default(val10), " given.");
7219
- } else if (val10.trim().length !== val10.length) {
7220
- return "".concat(thingy, " must not have leading or trailing spaces. '").concat(val10, "' given.");
7221
- } else if (val10.length < range[0] || val10.length > range[1]) {
7222
- return "".concat(thingy, " must have between ").concat(range[0], " and ").concat(range[1], " characters. '").concat(val10, "' given.");
7898
+ var _validateSym = (val11, thingy, range) => {
7899
+ if (typeof val11 !== "string") {
7900
+ return "".concat(thingy, " must be a string. ").concat(userReadableTypeOfValue_default(val11), " given.");
7901
+ } else if (val11.trim().length !== val11.length) {
7902
+ return "".concat(thingy, " must not have leading or trailing spaces. '").concat(val11, "' given.");
7903
+ } else if (val11.length < range[0] || val11.length > range[1]) {
7904
+ return "".concat(thingy, " must have between ").concat(range[0], " and ").concat(range[1], " characters. '").concat(val11, "' given.");
7223
7905
  }
7224
7906
  };
7225
7907
  var validateName = (name, thingy, shouldThrow = false) => {
@@ -7268,11 +7950,19 @@ var TheatreProject = class {
7268
7950
  }
7269
7951
  return asset.id ? privateAPI(this).assetStorage.getAssetUrl(asset.id) : void 0;
7270
7952
  }
7271
- sheet(sheetId, instanceId = "default") {
7953
+ sheet(sheetId, instanceIdOrOpts = "default", opts) {
7272
7954
  const sanitizedPath = validateAndSanitiseSlashedPathOrThrow(
7273
7955
  sheetId,
7274
7956
  "project.sheet"
7275
7957
  );
7958
+ let instanceId = "default";
7959
+ let sheetOpts;
7960
+ if (typeof instanceIdOrOpts === "string") {
7961
+ instanceId = instanceIdOrOpts;
7962
+ sheetOpts = opts;
7963
+ } else {
7964
+ sheetOpts = instanceIdOrOpts;
7965
+ }
7276
7966
  if (process.env.NODE_ENV !== "production") {
7277
7967
  validateInstanceId(
7278
7968
  instanceId,
@@ -7282,15 +7972,16 @@ var TheatreProject = class {
7282
7972
  }
7283
7973
  return privateAPI(this).getOrCreateSheet(
7284
7974
  sanitizedPath,
7285
- instanceId
7975
+ instanceId,
7976
+ sheetOpts
7286
7977
  ).publicApi;
7287
7978
  }
7288
7979
  };
7289
7980
 
7290
7981
  // core/src/coreExports.ts
7291
7982
  var import_fast_deep_equal2 = __toESM(require_fast_deep_equal());
7292
- var import_theatre_dataverse20 = require("@unseenco/theatre-dataverse");
7293
7983
  var import_theatre_dataverse21 = require("@unseenco/theatre-dataverse");
7984
+ var import_theatre_dataverse22 = require("@unseenco/theatre-dataverse");
7294
7985
  function getProject(id, config = {}) {
7295
7986
  const existingProject = projectsSingleton_default.get(id);
7296
7987
  if (existingProject) {
@@ -7357,10 +8048,10 @@ var validateProjectIdOrThrow = (value) => {
7357
8048
  };
7358
8049
  function onChange(pointer3, callback, rafDriver) {
7359
8050
  const ticker = rafDriver ? privateAPI(rafDriver).ticker : getCoreTicker();
7360
- if ((0, import_theatre_dataverse20.isPointer)(pointer3)) {
7361
- const pr = (0, import_theatre_dataverse21.pointerToPrism)(pointer3);
8051
+ if ((0, import_theatre_dataverse21.isPointer)(pointer3)) {
8052
+ const pr = (0, import_theatre_dataverse22.pointerToPrism)(pointer3);
7362
8053
  return pr.onChange(ticker, callback, true);
7363
- } else if ((0, import_theatre_dataverse21.isPrism)(pointer3)) {
8054
+ } else if ((0, import_theatre_dataverse22.isPrism)(pointer3)) {
7364
8055
  return pointer3.onChange(ticker, callback, true);
7365
8056
  } else {
7366
8057
  throw new Error(
@@ -7368,9 +8059,9 @@ function onChange(pointer3, callback, rafDriver) {
7368
8059
  );
7369
8060
  }
7370
8061
  }
7371
- function val9(pointer3) {
7372
- if ((0, import_theatre_dataverse20.isPointer)(pointer3)) {
7373
- return (0, import_theatre_dataverse21.pointerToPrism)(pointer3).getValue();
8062
+ function val10(pointer3) {
8063
+ if ((0, import_theatre_dataverse21.isPointer)(pointer3)) {
8064
+ return (0, import_theatre_dataverse22.pointerToPrism)(pointer3).getValue();
7374
8065
  } else {
7375
8066
  throw new Error("Called val(p) where p is not a pointer.");
7376
8067
  }
@@ -7385,7 +8076,7 @@ var CoreBundle = class {
7385
8076
  return "Theatre_CoreBundle";
7386
8077
  }
7387
8078
  get version() {
7388
- return "0.1.2";
8079
+ return "0.1.4";
7389
8080
  }
7390
8081
  getBitsForStudio(studio, callback) {
7391
8082
  if (this._studio) {