@unseenco/theatre-core 0.1.16 → 0.1.17
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 +18 -0
- package/dist/index.js +141 -56
- package/dist/index.js.map +4 -4
- package/dist/index.mjs +141 -56
- package/dist/index.mjs.map +4 -4
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -306,6 +306,7 @@ type ShorthandCompoundPropsToLonghandCompoundProps<P extends UnknownShorthandCom
|
|
|
306
306
|
* ```
|
|
307
307
|
*
|
|
308
308
|
*/
|
|
309
|
+
declare function compoundFromSanitizedProps<Props extends UnknownValidCompoundProps>(sanitizedProps: Props, opts?: CommonOpts): PropTypeConfig_Compound<Props>;
|
|
309
310
|
declare const compound: <Props extends UnknownShorthandCompoundProps>(props: Props, opts?: CommonOpts) => PropTypeConfig_Compound<ShorthandCompoundPropsToLonghandCompoundProps<Props>>;
|
|
310
311
|
/**
|
|
311
312
|
* A file prop type
|
|
@@ -629,6 +630,7 @@ type PropTypeConfig_AllSimples = PropTypeConfig_Number | PropTypeConfig_Boolean
|
|
|
629
630
|
type PropTypeConfig = PropTypeConfig_AllSimples | PropTypeConfig_Compound<$IntentionalAny> | PropTypeConfig_Enum;
|
|
630
631
|
|
|
631
632
|
type index_d_UnknownShorthandCompoundProps = UnknownShorthandCompoundProps;
|
|
633
|
+
declare const index_d_compoundFromSanitizedProps: typeof compoundFromSanitizedProps;
|
|
632
634
|
declare const index_d_compound: typeof compound;
|
|
633
635
|
declare const index_d_file: typeof file;
|
|
634
636
|
declare const index_d_image: typeof image;
|
|
@@ -654,6 +656,7 @@ type index_d_PropTypeConfig = PropTypeConfig;
|
|
|
654
656
|
declare namespace index_d {
|
|
655
657
|
export {
|
|
656
658
|
index_d_UnknownShorthandCompoundProps as UnknownShorthandCompoundProps,
|
|
659
|
+
index_d_compoundFromSanitizedProps as compoundFromSanitizedProps,
|
|
657
660
|
index_d_compound as compound,
|
|
658
661
|
index_d_file as file,
|
|
659
662
|
index_d_image as image,
|
|
@@ -913,6 +916,21 @@ interface ISheetObject<Props extends UnknownShorthandCompoundProps = UnknownShor
|
|
|
913
916
|
transient?: readonly TransientPropPath[];
|
|
914
917
|
static?: readonly StaticPropPath[];
|
|
915
918
|
}): void;
|
|
919
|
+
/**
|
|
920
|
+
* Add new props to this object's config. Existing props are preserved; only
|
|
921
|
+
* the keys in `config` are added. Throws if a key already exists on the object.
|
|
922
|
+
*
|
|
923
|
+
* @example
|
|
924
|
+
* ```ts
|
|
925
|
+
* const obj = sheet.object('Box', {x: 0})
|
|
926
|
+
* obj.addProps({y: 0})
|
|
927
|
+
* // obj now has props x and y
|
|
928
|
+
* ```
|
|
929
|
+
*/
|
|
930
|
+
addProps(config: UnknownShorthandCompoundProps, opts?: {
|
|
931
|
+
transient?: readonly TransientPropPath[];
|
|
932
|
+
static?: readonly StaticPropPath[];
|
|
933
|
+
}): void;
|
|
916
934
|
}
|
|
917
935
|
|
|
918
936
|
type KeyframeId = Nominal<'KeyframeId'>;
|
package/dist/index.js
CHANGED
|
@@ -117,6 +117,51 @@ var require_UnitBezier = __commonJS({
|
|
|
117
117
|
}
|
|
118
118
|
});
|
|
119
119
|
|
|
120
|
+
// ../node_modules/fast-deep-equal/index.js
|
|
121
|
+
var require_fast_deep_equal = __commonJS({
|
|
122
|
+
"../node_modules/fast-deep-equal/index.js"(exports2, module2) {
|
|
123
|
+
"use strict";
|
|
124
|
+
module2.exports = function equal(a2, b2) {
|
|
125
|
+
if (a2 === b2)
|
|
126
|
+
return true;
|
|
127
|
+
if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") {
|
|
128
|
+
if (a2.constructor !== b2.constructor)
|
|
129
|
+
return false;
|
|
130
|
+
var length, i2, keys2;
|
|
131
|
+
if (Array.isArray(a2)) {
|
|
132
|
+
length = a2.length;
|
|
133
|
+
if (length != b2.length)
|
|
134
|
+
return false;
|
|
135
|
+
for (i2 = length; i2-- !== 0; )
|
|
136
|
+
if (!equal(a2[i2], b2[i2]))
|
|
137
|
+
return false;
|
|
138
|
+
return true;
|
|
139
|
+
}
|
|
140
|
+
if (a2.constructor === RegExp)
|
|
141
|
+
return a2.source === b2.source && a2.flags === b2.flags;
|
|
142
|
+
if (a2.valueOf !== Object.prototype.valueOf)
|
|
143
|
+
return a2.valueOf() === b2.valueOf();
|
|
144
|
+
if (a2.toString !== Object.prototype.toString)
|
|
145
|
+
return a2.toString() === b2.toString();
|
|
146
|
+
keys2 = Object.keys(a2);
|
|
147
|
+
length = keys2.length;
|
|
148
|
+
if (length !== Object.keys(b2).length)
|
|
149
|
+
return false;
|
|
150
|
+
for (i2 = length; i2-- !== 0; )
|
|
151
|
+
if (!Object.prototype.hasOwnProperty.call(b2, keys2[i2]))
|
|
152
|
+
return false;
|
|
153
|
+
for (i2 = length; i2-- !== 0; ) {
|
|
154
|
+
var key = keys2[i2];
|
|
155
|
+
if (!equal(a2[key], b2[key]))
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
return a2 !== a2 && b2 !== b2;
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
|
|
120
165
|
// ../node_modules/levenshtein-edit-distance/index.js
|
|
121
166
|
var require_levenshtein_edit_distance = __commonJS({
|
|
122
167
|
"../node_modules/levenshtein-edit-distance/index.js"(exports2, module2) {
|
|
@@ -206,51 +251,6 @@ var require_propose = __commonJS({
|
|
|
206
251
|
}
|
|
207
252
|
});
|
|
208
253
|
|
|
209
|
-
// ../node_modules/fast-deep-equal/index.js
|
|
210
|
-
var require_fast_deep_equal = __commonJS({
|
|
211
|
-
"../node_modules/fast-deep-equal/index.js"(exports2, module2) {
|
|
212
|
-
"use strict";
|
|
213
|
-
module2.exports = function equal(a2, b2) {
|
|
214
|
-
if (a2 === b2)
|
|
215
|
-
return true;
|
|
216
|
-
if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") {
|
|
217
|
-
if (a2.constructor !== b2.constructor)
|
|
218
|
-
return false;
|
|
219
|
-
var length, i2, keys2;
|
|
220
|
-
if (Array.isArray(a2)) {
|
|
221
|
-
length = a2.length;
|
|
222
|
-
if (length != b2.length)
|
|
223
|
-
return false;
|
|
224
|
-
for (i2 = length; i2-- !== 0; )
|
|
225
|
-
if (!equal(a2[i2], b2[i2]))
|
|
226
|
-
return false;
|
|
227
|
-
return true;
|
|
228
|
-
}
|
|
229
|
-
if (a2.constructor === RegExp)
|
|
230
|
-
return a2.source === b2.source && a2.flags === b2.flags;
|
|
231
|
-
if (a2.valueOf !== Object.prototype.valueOf)
|
|
232
|
-
return a2.valueOf() === b2.valueOf();
|
|
233
|
-
if (a2.toString !== Object.prototype.toString)
|
|
234
|
-
return a2.toString() === b2.toString();
|
|
235
|
-
keys2 = Object.keys(a2);
|
|
236
|
-
length = keys2.length;
|
|
237
|
-
if (length !== Object.keys(b2).length)
|
|
238
|
-
return false;
|
|
239
|
-
for (i2 = length; i2-- !== 0; )
|
|
240
|
-
if (!Object.prototype.hasOwnProperty.call(b2, keys2[i2]))
|
|
241
|
-
return false;
|
|
242
|
-
for (i2 = length; i2-- !== 0; ) {
|
|
243
|
-
var key = keys2[i2];
|
|
244
|
-
if (!equal(a2[key], b2[key]))
|
|
245
|
-
return false;
|
|
246
|
-
}
|
|
247
|
-
return true;
|
|
248
|
-
}
|
|
249
|
-
return a2 !== a2 && b2 !== b2;
|
|
250
|
-
};
|
|
251
|
-
}
|
|
252
|
-
});
|
|
253
|
-
|
|
254
254
|
// core/src/index.ts
|
|
255
255
|
var src_exports = {};
|
|
256
256
|
__export(src_exports, {
|
|
@@ -1208,6 +1208,7 @@ var propTypes_exports = {};
|
|
|
1208
1208
|
__export(propTypes_exports, {
|
|
1209
1209
|
boolean: () => boolean,
|
|
1210
1210
|
compound: () => compound,
|
|
1211
|
+
compoundFromSanitizedProps: () => compoundFromSanitizedProps,
|
|
1211
1212
|
file: () => file,
|
|
1212
1213
|
image: () => image,
|
|
1213
1214
|
number: () => number,
|
|
@@ -3289,9 +3290,8 @@ var validateCommonOpts = (fnCallSignature, opts) => {
|
|
|
3289
3290
|
}
|
|
3290
3291
|
}
|
|
3291
3292
|
};
|
|
3292
|
-
|
|
3293
|
+
function compoundFromSanitizedProps(sanitizedProps, opts = {}) {
|
|
3293
3294
|
validateCommonOpts("t.compound(props, opts)", opts);
|
|
3294
|
-
const sanitizedProps = sanitizeCompoundProps(props);
|
|
3295
3295
|
const deserializationCache = /* @__PURE__ */ new WeakMap();
|
|
3296
3296
|
const config = {
|
|
3297
3297
|
type: "compound",
|
|
@@ -3326,6 +3326,10 @@ var compound = (props, opts = {}) => {
|
|
|
3326
3326
|
}
|
|
3327
3327
|
};
|
|
3328
3328
|
return config;
|
|
3329
|
+
}
|
|
3330
|
+
var compound = (props, opts = {}) => {
|
|
3331
|
+
const sanitizedProps = sanitizeCompoundProps(props);
|
|
3332
|
+
return compoundFromSanitizedProps(sanitizedProps, opts);
|
|
3329
3333
|
};
|
|
3330
3334
|
var file = (defaultValue, opts = {}) => {
|
|
3331
3335
|
if (process.env.NODE_ENV !== "production") {
|
|
@@ -3677,6 +3681,21 @@ function resolveShowPropsOfSources(host, objects, apiName) {
|
|
|
3677
3681
|
});
|
|
3678
3682
|
}
|
|
3679
3683
|
|
|
3684
|
+
// core/src/sheetObjects/unsanitizedObjectProps.ts
|
|
3685
|
+
var weakMapOfUnsanitizedProps = /* @__PURE__ */ new WeakMap();
|
|
3686
|
+
function getUnsanitizedObjectProps(object) {
|
|
3687
|
+
return weakMapOfUnsanitizedProps.get(object);
|
|
3688
|
+
}
|
|
3689
|
+
function setUnsanitizedObjectProps(object, config) {
|
|
3690
|
+
weakMapOfUnsanitizedProps.set(object, config);
|
|
3691
|
+
}
|
|
3692
|
+
function mergeUnsanitizedObjectProps(object, additional) {
|
|
3693
|
+
const existing = weakMapOfUnsanitizedProps.get(object) ?? {};
|
|
3694
|
+
const merged = { ...existing, ...additional };
|
|
3695
|
+
weakMapOfUnsanitizedProps.set(object, merged);
|
|
3696
|
+
return merged;
|
|
3697
|
+
}
|
|
3698
|
+
|
|
3680
3699
|
// core/src/sheetObjects/TheatreSheetObject.ts
|
|
3681
3700
|
var KEEP_HOT_FOR_MS = 5 * 1e3;
|
|
3682
3701
|
var TheatreSheetObject = class {
|
|
@@ -3781,8 +3800,25 @@ var TheatreSheetObject = class {
|
|
|
3781
3800
|
host.template.setStaticPropPaths(opts.static, sanitizedConfig);
|
|
3782
3801
|
}
|
|
3783
3802
|
}
|
|
3803
|
+
addProps(config, opts) {
|
|
3804
|
+
const host = privateAPI(this);
|
|
3805
|
+
host.template.addProps(config);
|
|
3806
|
+
if (process.env.NODE_ENV !== "production") {
|
|
3807
|
+
mergeUnsanitizedObjectProps(host, config);
|
|
3808
|
+
}
|
|
3809
|
+
const mergedConfig = host.template.staticConfig;
|
|
3810
|
+
if (opts?.transient !== void 0) {
|
|
3811
|
+
host.template.setTransientPropPaths(opts.transient, mergedConfig);
|
|
3812
|
+
}
|
|
3813
|
+
if (opts?.static !== void 0) {
|
|
3814
|
+
host.template.setStaticPropPaths(opts.static, mergedConfig);
|
|
3815
|
+
}
|
|
3816
|
+
}
|
|
3784
3817
|
};
|
|
3785
3818
|
|
|
3819
|
+
// shared/src/propTypes/utils.ts
|
|
3820
|
+
var import_fast_deep_equal = __toESM(require_fast_deep_equal());
|
|
3821
|
+
|
|
3786
3822
|
// shared/src/utils/memoizeFn.ts
|
|
3787
3823
|
function memoizeFn(producer) {
|
|
3788
3824
|
const cache2 = /* @__PURE__ */ new WeakMap();
|
|
@@ -5021,6 +5057,18 @@ function iterateOnAny(path, config, map) {
|
|
|
5021
5057
|
}
|
|
5022
5058
|
}
|
|
5023
5059
|
|
|
5060
|
+
// shared/src/utils/defaultPropValues.ts
|
|
5061
|
+
var objectPropConfigRegistry = /* @__PURE__ */ new Map();
|
|
5062
|
+
function objectPropConfigRegistryKey(projectId, sheetId, objectKey) {
|
|
5063
|
+
return "".concat(projectId, "\0").concat(sheetId, "\0").concat(objectKey);
|
|
5064
|
+
}
|
|
5065
|
+
function registerObjectPropConfig(projectId, sheetId, objectKey, config) {
|
|
5066
|
+
objectPropConfigRegistry.set(
|
|
5067
|
+
objectPropConfigRegistryKey(projectId, sheetId, objectKey),
|
|
5068
|
+
config
|
|
5069
|
+
);
|
|
5070
|
+
}
|
|
5071
|
+
|
|
5024
5072
|
// core/src/sheetObjects/SheetObjectTemplate.ts
|
|
5025
5073
|
function isObjectEmpty(obj) {
|
|
5026
5074
|
return typeof obj === "object" && obj !== null && Object.keys(obj).length === 0;
|
|
@@ -5067,6 +5115,12 @@ var SheetObjectTemplate = class {
|
|
|
5067
5115
|
objectKey,
|
|
5068
5116
|
this._transientPropPaths
|
|
5069
5117
|
);
|
|
5118
|
+
registerObjectPropConfig(
|
|
5119
|
+
this.address.projectId,
|
|
5120
|
+
this.address.sheetId,
|
|
5121
|
+
objectKey,
|
|
5122
|
+
config
|
|
5123
|
+
);
|
|
5070
5124
|
this.pointerToSheetState = this.sheetTemplate.project.pointers.historic.sheetsById[this.address.sheetId];
|
|
5071
5125
|
this.pointerToStaticOverrides = this.pointerToSheetState.staticOverrides.byObject[this.address.objectKey];
|
|
5072
5126
|
this.pointerToAhistoricSheetState = this.sheetTemplate.project.pointers.ahistoric.sheetsById[this.address.sheetId];
|
|
@@ -5137,6 +5191,29 @@ var SheetObjectTemplate = class {
|
|
|
5137
5191
|
config
|
|
5138
5192
|
);
|
|
5139
5193
|
}
|
|
5194
|
+
addProps(config) {
|
|
5195
|
+
const existing = this._config.get();
|
|
5196
|
+
const additional = compound(config);
|
|
5197
|
+
for (const key of Object.keys(additional.props)) {
|
|
5198
|
+
if (Object.prototype.hasOwnProperty.call(existing.props, key)) {
|
|
5199
|
+
throw new InvalidArgumentError(
|
|
5200
|
+
'Cannot add prop "'.concat(key, '" because it already exists on object "').concat(this.address.objectKey, '".')
|
|
5201
|
+
);
|
|
5202
|
+
}
|
|
5203
|
+
}
|
|
5204
|
+
const merged = compoundFromSanitizedProps({
|
|
5205
|
+
...existing.props,
|
|
5206
|
+
...additional.props
|
|
5207
|
+
});
|
|
5208
|
+
this._config.set(merged);
|
|
5209
|
+
registerObjectPropConfig(
|
|
5210
|
+
this.address.projectId,
|
|
5211
|
+
this.address.sheetId,
|
|
5212
|
+
this.address.objectKey,
|
|
5213
|
+
merged
|
|
5214
|
+
);
|
|
5215
|
+
this._stripNonPersistingPropsFromAhistoricState();
|
|
5216
|
+
}
|
|
5140
5217
|
setTransientPropPaths(transient, config) {
|
|
5141
5218
|
this._transientPropPaths = normalizeTransientPropPaths(
|
|
5142
5219
|
transient,
|
|
@@ -6523,8 +6600,7 @@ function parseOutlineNamespacePath(namespacePath, fnName) {
|
|
|
6523
6600
|
}
|
|
6524
6601
|
|
|
6525
6602
|
// core/src/sheets/TheatreSheet.ts
|
|
6526
|
-
var
|
|
6527
|
-
var weakMapOfUnsanitizedProps = /* @__PURE__ */ new WeakMap();
|
|
6603
|
+
var import_fast_deep_equal2 = __toESM(require_fast_deep_equal());
|
|
6528
6604
|
var TheatreSheet = class {
|
|
6529
6605
|
get type() {
|
|
6530
6606
|
return "Theatre_Sheet_PublicAPI";
|
|
@@ -6546,9 +6622,9 @@ var TheatreSheet = class {
|
|
|
6546
6622
|
const actions = opts?.__actions__THIS_API_IS_UNSTABLE_AND_WILL_CHANGE_IN_THE_NEXT_VERSION;
|
|
6547
6623
|
if (existingObject) {
|
|
6548
6624
|
if (process.env.NODE_ENV !== "production") {
|
|
6549
|
-
const prevConfig =
|
|
6625
|
+
const prevConfig = getUnsanitizedObjectProps(existingObject);
|
|
6550
6626
|
if (prevConfig) {
|
|
6551
|
-
if (!(0,
|
|
6627
|
+
if (!(0, import_fast_deep_equal2.default)(config, prevConfig)) {
|
|
6552
6628
|
if (opts?.reconfigure === true) {
|
|
6553
6629
|
const sanitizedConfig = compound(config);
|
|
6554
6630
|
existingObject.template.reconfigure(sanitizedConfig);
|
|
@@ -6573,7 +6649,7 @@ var TheatreSheet = class {
|
|
|
6573
6649
|
)
|
|
6574
6650
|
);
|
|
6575
6651
|
}
|
|
6576
|
-
|
|
6652
|
+
setUnsanitizedObjectProps(existingObject, config);
|
|
6577
6653
|
return existingObject.publicApi;
|
|
6578
6654
|
} else {
|
|
6579
6655
|
throw new Error(
|
|
@@ -6623,7 +6699,7 @@ var TheatreSheet = class {
|
|
|
6623
6699
|
opts?.static
|
|
6624
6700
|
);
|
|
6625
6701
|
if (process.env.NODE_ENV !== "production") {
|
|
6626
|
-
|
|
6702
|
+
setUnsanitizedObjectProps(object, config);
|
|
6627
6703
|
}
|
|
6628
6704
|
if (opts?.showPropsOf !== void 0) {
|
|
6629
6705
|
object.template.setShowPropsOf(
|
|
@@ -8146,6 +8222,15 @@ var Project = class {
|
|
|
8146
8222
|
});
|
|
8147
8223
|
}
|
|
8148
8224
|
}
|
|
8225
|
+
/** Re-initialize studio state from this project's `config.state`. */
|
|
8226
|
+
async reinitializeStateFromConfig() {
|
|
8227
|
+
if (!this._studio) {
|
|
8228
|
+
throw new Error(
|
|
8229
|
+
"Cannot reinitialize project ".concat(this.address.projectId, ": not attached to studio")
|
|
8230
|
+
);
|
|
8231
|
+
}
|
|
8232
|
+
await initialiseProjectState(this._studio, this, this.config.state);
|
|
8233
|
+
}
|
|
8149
8234
|
};
|
|
8150
8235
|
|
|
8151
8236
|
// shared/src/utils/sanitizers.ts
|
|
@@ -8270,14 +8355,14 @@ var TheatreProject = class {
|
|
|
8270
8355
|
};
|
|
8271
8356
|
|
|
8272
8357
|
// core/src/coreExports.ts
|
|
8273
|
-
var
|
|
8358
|
+
var import_fast_deep_equal3 = __toESM(require_fast_deep_equal());
|
|
8274
8359
|
var import_theatre_dataverse21 = require("@unseenco/theatre-dataverse");
|
|
8275
8360
|
var import_theatre_dataverse22 = require("@unseenco/theatre-dataverse");
|
|
8276
8361
|
function getProject(id, config = {}) {
|
|
8277
8362
|
const existingProject = projectsSingleton_default.get(id);
|
|
8278
8363
|
if (existingProject) {
|
|
8279
8364
|
if (process.env.NODE_ENV !== "production") {
|
|
8280
|
-
if (!(0,
|
|
8365
|
+
if (!(0, import_fast_deep_equal3.default)(config, existingProject.config)) {
|
|
8281
8366
|
throw new Error(
|
|
8282
8367
|
'You seem to have called Theatre.getProject("'.concat(id, '", config) twice, with different config objects. ') + "This is disallowed because changing the config of a project on the fly can lead to hard-to-debug issues.\n\nYou can fix this by either calling Theatre.getProject() once per projectId, or calling it multiple times but with the exact same config."
|
|
8283
8368
|
);
|
|
@@ -8367,7 +8452,7 @@ var CoreBundle = class {
|
|
|
8367
8452
|
return "Theatre_CoreBundle";
|
|
8368
8453
|
}
|
|
8369
8454
|
get version() {
|
|
8370
|
-
return "0.1.
|
|
8455
|
+
return "0.1.17";
|
|
8371
8456
|
}
|
|
8372
8457
|
getBitsForStudio(studio, callback) {
|
|
8373
8458
|
if (this._studio) {
|