@unseenco/theatre-core 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +9 -0
- package/dist/index.js +107 -10
- package/dist/index.js.map +4 -4
- package/dist/index.mjs +107 -10
- package/dist/index.mjs.map +4 -4
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -4183,6 +4183,14 @@ function setDeepImmutable(obj, path, replace) {
|
|
|
4183
4183
|
|
|
4184
4184
|
// core/src/sequences/sequenceVariants.ts
|
|
4185
4185
|
import { val as val3 } from "@unseenco/theatre-dataverse";
|
|
4186
|
+
|
|
4187
|
+
// shared/src/utils/sheetProps.ts
|
|
4188
|
+
var SHEET_PROPS_OBJECT_KEY = "__theatre_sheet_props__";
|
|
4189
|
+
function isSheetPropsObjectKey(objectKey) {
|
|
4190
|
+
return objectKey === SHEET_PROPS_OBJECT_KEY;
|
|
4191
|
+
}
|
|
4192
|
+
|
|
4193
|
+
// core/src/sequences/sequenceVariants.ts
|
|
4186
4194
|
var DEFAULT_SEQUENCE_VARIANT = "default";
|
|
4187
4195
|
function mergeSequenceTrackMaps(defaultTracks, overrideTracks, activeVariant) {
|
|
4188
4196
|
const merged = {};
|
|
@@ -4212,6 +4220,9 @@ function getDefaultStaticOverridesByObject(sheetState) {
|
|
|
4212
4220
|
return sheetState?.staticOverrides?.byObject;
|
|
4213
4221
|
}
|
|
4214
4222
|
function getEffectiveStaticOverrideForObject(sheetState, variantId, objectKey) {
|
|
4223
|
+
if (isSheetPropsObjectKey(objectKey)) {
|
|
4224
|
+
return getDefaultStaticOverridesByObject(sheetState)?.[objectKey];
|
|
4225
|
+
}
|
|
4215
4226
|
const defaultOverrides = getDefaultStaticOverridesByObject(sheetState)?.[objectKey];
|
|
4216
4227
|
if (variantId === DEFAULT_SEQUENCE_VARIANT) {
|
|
4217
4228
|
return defaultOverrides;
|
|
@@ -4399,7 +4410,8 @@ var SheetObject = class {
|
|
|
4399
4410
|
withAhistoricStaticsCache
|
|
4400
4411
|
);
|
|
4401
4412
|
const activeVariant = val4(this.sheet.effectiveActiveSequenceVariantD);
|
|
4402
|
-
const
|
|
4413
|
+
const staticVariant = isSheetPropsObjectKey(this.address.objectKey) ? DEFAULT_SEQUENCE_VARIANT : activeVariant;
|
|
4414
|
+
const statics = val4(this.template.getStaticValues(staticVariant));
|
|
4403
4415
|
const withStaticsCache = prism4.memo(
|
|
4404
4416
|
"withStatics",
|
|
4405
4417
|
() => /* @__PURE__ */ new WeakMap(),
|
|
@@ -4474,10 +4486,11 @@ var SheetObject = class {
|
|
|
4474
4486
|
getSequencedValues() {
|
|
4475
4487
|
return prism4(() => {
|
|
4476
4488
|
const activeVariant = val4(this.sheet.effectiveActiveSequenceVariantD);
|
|
4489
|
+
const sequenceVariant = isSheetPropsObjectKey(this.address.objectKey) ? DEFAULT_SEQUENCE_VARIANT : activeVariant;
|
|
4477
4490
|
const tracksToProcessD = prism4.memo(
|
|
4478
4491
|
"tracksToProcess",
|
|
4479
|
-
() => this.template.getArrayOfValidSequenceTracks(
|
|
4480
|
-
[
|
|
4492
|
+
() => this.template.getArrayOfValidSequenceTracks(sequenceVariant),
|
|
4493
|
+
[sequenceVariant]
|
|
4481
4494
|
);
|
|
4482
4495
|
const tracksToProcess = val4(tracksToProcessD);
|
|
4483
4496
|
const valsAtom = new Atom3({});
|
|
@@ -5414,6 +5427,9 @@ var SheetObjectTemplate = class {
|
|
|
5414
5427
|
"getArrayOfValidSequenceTracks:".concat(sequenceVariant),
|
|
5415
5428
|
() => prism5(
|
|
5416
5429
|
() => {
|
|
5430
|
+
const effectiveSequenceVariant = isSheetPropsObjectKey(
|
|
5431
|
+
this.address.objectKey
|
|
5432
|
+
) ? DEFAULT_SEQUENCE_VARIANT : sequenceVariant;
|
|
5417
5433
|
const pointerToSheetState = this.project.pointers.historic.sheetsById[this.address.sheetId];
|
|
5418
5434
|
val5(pointerToSheetState.variantObjectOverrides);
|
|
5419
5435
|
const defaultTrackIdByPropPath = valTrackIdByPropPathForObject(
|
|
@@ -5421,19 +5437,19 @@ var SheetObjectTemplate = class {
|
|
|
5421
5437
|
DEFAULT_SEQUENCE_VARIANT,
|
|
5422
5438
|
this.address.objectKey
|
|
5423
5439
|
);
|
|
5424
|
-
const variantTrackIdByPropPath =
|
|
5440
|
+
const variantTrackIdByPropPath = effectiveSequenceVariant === DEFAULT_SEQUENCE_VARIANT ? void 0 : valTrackIdByPropPathForObject(
|
|
5425
5441
|
pointerToSheetState,
|
|
5426
|
-
|
|
5442
|
+
effectiveSequenceVariant,
|
|
5427
5443
|
this.address.objectKey
|
|
5428
5444
|
);
|
|
5429
5445
|
const mergedTrackMap = mergeSequenceTrackMaps(
|
|
5430
5446
|
defaultTrackIdByPropPath,
|
|
5431
5447
|
variantTrackIdByPropPath,
|
|
5432
|
-
|
|
5448
|
+
effectiveSequenceVariant
|
|
5433
5449
|
);
|
|
5434
|
-
const unsequencedPropPaths =
|
|
5450
|
+
const unsequencedPropPaths = effectiveSequenceVariant === DEFAULT_SEQUENCE_VARIANT ? void 0 : valUnsequencedPropPathsForObject(
|
|
5435
5451
|
pointerToSheetState,
|
|
5436
|
-
|
|
5452
|
+
effectiveSequenceVariant,
|
|
5437
5453
|
this.address.objectKey
|
|
5438
5454
|
);
|
|
5439
5455
|
const unsequencedPropPathSet = unsequencedPropPaths ? new Set(unsequencedPropPaths) : void 0;
|
|
@@ -6693,6 +6709,11 @@ var TheatreSheet = class {
|
|
|
6693
6709
|
key,
|
|
6694
6710
|
"sheet.object"
|
|
6695
6711
|
);
|
|
6712
|
+
if (isSheetPropsObjectKey(sanitizedPath)) {
|
|
6713
|
+
throw new InvalidArgumentError(
|
|
6714
|
+
'The key "'.concat(sanitizedPath, '" is reserved for sheet-level props. Use sheet.props() instead of sheet.object().')
|
|
6715
|
+
);
|
|
6716
|
+
}
|
|
6696
6717
|
const existingObject = internal2.getObject(sanitizedPath);
|
|
6697
6718
|
const nativeObject = null;
|
|
6698
6719
|
const actions = opts?.__actions__THIS_API_IS_UNSTABLE_AND_WILL_CHANGE_IN_THE_NEXT_VERSION;
|
|
@@ -6789,6 +6810,74 @@ var TheatreSheet = class {
|
|
|
6789
6810
|
return object.publicApi;
|
|
6790
6811
|
}
|
|
6791
6812
|
}
|
|
6813
|
+
props(config, opts) {
|
|
6814
|
+
const internal2 = privateAPI(this);
|
|
6815
|
+
const objectKey = SHEET_PROPS_OBJECT_KEY;
|
|
6816
|
+
const existingObject = internal2.getSheetPropsObject();
|
|
6817
|
+
const nativeObject = null;
|
|
6818
|
+
const actions = opts?.__actions__THIS_API_IS_UNSTABLE_AND_WILL_CHANGE_IN_THE_NEXT_VERSION;
|
|
6819
|
+
if (existingObject) {
|
|
6820
|
+
if (process.env.NODE_ENV !== "production") {
|
|
6821
|
+
const prevConfig = getUnsanitizedObjectProps(existingObject);
|
|
6822
|
+
if (prevConfig) {
|
|
6823
|
+
if (!(0, import_fast_deep_equal2.default)(config, prevConfig)) {
|
|
6824
|
+
if (opts?.reconfigure === true) {
|
|
6825
|
+
const sanitizedConfig2 = compound(config);
|
|
6826
|
+
existingObject.template.reconfigure(sanitizedConfig2);
|
|
6827
|
+
if (opts.transient !== void 0) {
|
|
6828
|
+
existingObject.template.setTransientPropPaths(
|
|
6829
|
+
opts.transient,
|
|
6830
|
+
sanitizedConfig2
|
|
6831
|
+
);
|
|
6832
|
+
}
|
|
6833
|
+
if (opts.static !== void 0) {
|
|
6834
|
+
existingObject.template.setStaticPropPaths(
|
|
6835
|
+
opts.static,
|
|
6836
|
+
sanitizedConfig2
|
|
6837
|
+
);
|
|
6838
|
+
}
|
|
6839
|
+
setUnsanitizedObjectProps(existingObject, config);
|
|
6840
|
+
return existingObject.publicApi;
|
|
6841
|
+
} else {
|
|
6842
|
+
throw new Error(
|
|
6843
|
+
"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."
|
|
6844
|
+
);
|
|
6845
|
+
}
|
|
6846
|
+
}
|
|
6847
|
+
}
|
|
6848
|
+
}
|
|
6849
|
+
if (actions) {
|
|
6850
|
+
existingObject.template._temp_setActions(actions);
|
|
6851
|
+
}
|
|
6852
|
+
if (opts?.transient !== void 0) {
|
|
6853
|
+
existingObject.template.setTransientPropPaths(
|
|
6854
|
+
opts.transient,
|
|
6855
|
+
existingObject.template.staticConfig
|
|
6856
|
+
);
|
|
6857
|
+
}
|
|
6858
|
+
if (opts?.static !== void 0) {
|
|
6859
|
+
existingObject.template.setStaticPropPaths(
|
|
6860
|
+
opts.static,
|
|
6861
|
+
existingObject.template.staticConfig
|
|
6862
|
+
);
|
|
6863
|
+
}
|
|
6864
|
+
return existingObject.publicApi;
|
|
6865
|
+
}
|
|
6866
|
+
const sanitizedConfig = compound(config);
|
|
6867
|
+
const object = internal2.createObject(
|
|
6868
|
+
objectKey,
|
|
6869
|
+
nativeObject,
|
|
6870
|
+
sanitizedConfig,
|
|
6871
|
+
actions,
|
|
6872
|
+
false,
|
|
6873
|
+
opts?.transient,
|
|
6874
|
+
opts?.static
|
|
6875
|
+
);
|
|
6876
|
+
if (process.env.NODE_ENV !== "production") {
|
|
6877
|
+
setUnsanitizedObjectProps(object, config);
|
|
6878
|
+
}
|
|
6879
|
+
return object.publicApi;
|
|
6880
|
+
}
|
|
6792
6881
|
get sequence() {
|
|
6793
6882
|
return privateAPI(this).getSequence().publicApi;
|
|
6794
6883
|
}
|
|
@@ -6813,6 +6902,11 @@ var TheatreSheet = class {
|
|
|
6813
6902
|
key,
|
|
6814
6903
|
'sheet.deleteObject("'.concat(key, '")')
|
|
6815
6904
|
);
|
|
6905
|
+
if (isSheetPropsObjectKey(sanitizedPath)) {
|
|
6906
|
+
throw new InvalidArgumentError(
|
|
6907
|
+
"Sheet props cannot be detached. They are removed when the sheet instance is unloaded."
|
|
6908
|
+
);
|
|
6909
|
+
}
|
|
6816
6910
|
const obj = internal2.getObject(sanitizedPath);
|
|
6817
6911
|
if (!obj) {
|
|
6818
6912
|
notify.warning(
|
|
@@ -6919,9 +7013,12 @@ var Sheet = class {
|
|
|
6919
7013
|
}
|
|
6920
7014
|
getObjects() {
|
|
6921
7015
|
return Object.values(this._objects.get()).filter(
|
|
6922
|
-
(obj) => !!obj
|
|
7016
|
+
(obj) => !!obj && !isSheetPropsObjectKey(obj.address.objectKey)
|
|
6923
7017
|
);
|
|
6924
7018
|
}
|
|
7019
|
+
getSheetPropsObject() {
|
|
7020
|
+
return this.getObject(SHEET_PROPS_OBJECT_KEY);
|
|
7021
|
+
}
|
|
6925
7022
|
deleteObject(objectKey) {
|
|
6926
7023
|
const obj = this._objects.get()[objectKey];
|
|
6927
7024
|
this._objects.reduce((state) => {
|
|
@@ -8542,7 +8639,7 @@ var CoreBundle = class {
|
|
|
8542
8639
|
return "Theatre_CoreBundle";
|
|
8543
8640
|
}
|
|
8544
8641
|
get version() {
|
|
8545
|
-
return "0.2.
|
|
8642
|
+
return "0.2.3";
|
|
8546
8643
|
}
|
|
8547
8644
|
getBitsForStudio(studio, callback) {
|
|
8548
8645
|
if (this._studio) {
|