@unseenco/theatre-core 0.1.16 → 0.1.18
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.mjs
CHANGED
|
@@ -115,6 +115,51 @@ var require_UnitBezier = __commonJS({
|
|
|
115
115
|
}
|
|
116
116
|
});
|
|
117
117
|
|
|
118
|
+
// ../node_modules/fast-deep-equal/index.js
|
|
119
|
+
var require_fast_deep_equal = __commonJS({
|
|
120
|
+
"../node_modules/fast-deep-equal/index.js"(exports2, module2) {
|
|
121
|
+
"use strict";
|
|
122
|
+
module2.exports = function equal(a2, b2) {
|
|
123
|
+
if (a2 === b2)
|
|
124
|
+
return true;
|
|
125
|
+
if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") {
|
|
126
|
+
if (a2.constructor !== b2.constructor)
|
|
127
|
+
return false;
|
|
128
|
+
var length, i2, keys2;
|
|
129
|
+
if (Array.isArray(a2)) {
|
|
130
|
+
length = a2.length;
|
|
131
|
+
if (length != b2.length)
|
|
132
|
+
return false;
|
|
133
|
+
for (i2 = length; i2-- !== 0; )
|
|
134
|
+
if (!equal(a2[i2], b2[i2]))
|
|
135
|
+
return false;
|
|
136
|
+
return true;
|
|
137
|
+
}
|
|
138
|
+
if (a2.constructor === RegExp)
|
|
139
|
+
return a2.source === b2.source && a2.flags === b2.flags;
|
|
140
|
+
if (a2.valueOf !== Object.prototype.valueOf)
|
|
141
|
+
return a2.valueOf() === b2.valueOf();
|
|
142
|
+
if (a2.toString !== Object.prototype.toString)
|
|
143
|
+
return a2.toString() === b2.toString();
|
|
144
|
+
keys2 = Object.keys(a2);
|
|
145
|
+
length = keys2.length;
|
|
146
|
+
if (length !== Object.keys(b2).length)
|
|
147
|
+
return false;
|
|
148
|
+
for (i2 = length; i2-- !== 0; )
|
|
149
|
+
if (!Object.prototype.hasOwnProperty.call(b2, keys2[i2]))
|
|
150
|
+
return false;
|
|
151
|
+
for (i2 = length; i2-- !== 0; ) {
|
|
152
|
+
var key = keys2[i2];
|
|
153
|
+
if (!equal(a2[key], b2[key]))
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
return true;
|
|
157
|
+
}
|
|
158
|
+
return a2 !== a2 && b2 !== b2;
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
|
|
118
163
|
// ../node_modules/levenshtein-edit-distance/index.js
|
|
119
164
|
var require_levenshtein_edit_distance = __commonJS({
|
|
120
165
|
"../node_modules/levenshtein-edit-distance/index.js"(exports2, module2) {
|
|
@@ -204,51 +249,6 @@ var require_propose = __commonJS({
|
|
|
204
249
|
}
|
|
205
250
|
});
|
|
206
251
|
|
|
207
|
-
// ../node_modules/fast-deep-equal/index.js
|
|
208
|
-
var require_fast_deep_equal = __commonJS({
|
|
209
|
-
"../node_modules/fast-deep-equal/index.js"(exports2, module2) {
|
|
210
|
-
"use strict";
|
|
211
|
-
module2.exports = function equal(a2, b2) {
|
|
212
|
-
if (a2 === b2)
|
|
213
|
-
return true;
|
|
214
|
-
if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") {
|
|
215
|
-
if (a2.constructor !== b2.constructor)
|
|
216
|
-
return false;
|
|
217
|
-
var length, i2, keys2;
|
|
218
|
-
if (Array.isArray(a2)) {
|
|
219
|
-
length = a2.length;
|
|
220
|
-
if (length != b2.length)
|
|
221
|
-
return false;
|
|
222
|
-
for (i2 = length; i2-- !== 0; )
|
|
223
|
-
if (!equal(a2[i2], b2[i2]))
|
|
224
|
-
return false;
|
|
225
|
-
return true;
|
|
226
|
-
}
|
|
227
|
-
if (a2.constructor === RegExp)
|
|
228
|
-
return a2.source === b2.source && a2.flags === b2.flags;
|
|
229
|
-
if (a2.valueOf !== Object.prototype.valueOf)
|
|
230
|
-
return a2.valueOf() === b2.valueOf();
|
|
231
|
-
if (a2.toString !== Object.prototype.toString)
|
|
232
|
-
return a2.toString() === b2.toString();
|
|
233
|
-
keys2 = Object.keys(a2);
|
|
234
|
-
length = keys2.length;
|
|
235
|
-
if (length !== Object.keys(b2).length)
|
|
236
|
-
return false;
|
|
237
|
-
for (i2 = length; i2-- !== 0; )
|
|
238
|
-
if (!Object.prototype.hasOwnProperty.call(b2, keys2[i2]))
|
|
239
|
-
return false;
|
|
240
|
-
for (i2 = length; i2-- !== 0; ) {
|
|
241
|
-
var key = keys2[i2];
|
|
242
|
-
if (!equal(a2[key], b2[key]))
|
|
243
|
-
return false;
|
|
244
|
-
}
|
|
245
|
-
return true;
|
|
246
|
-
}
|
|
247
|
-
return a2 !== a2 && b2 !== b2;
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
});
|
|
251
|
-
|
|
252
252
|
// core/src/coreExports.ts
|
|
253
253
|
var coreExports_exports = {};
|
|
254
254
|
__export(coreExports_exports, {
|
|
@@ -1198,6 +1198,7 @@ var propTypes_exports = {};
|
|
|
1198
1198
|
__export(propTypes_exports, {
|
|
1199
1199
|
boolean: () => boolean,
|
|
1200
1200
|
compound: () => compound,
|
|
1201
|
+
compoundFromSanitizedProps: () => compoundFromSanitizedProps,
|
|
1201
1202
|
file: () => file,
|
|
1202
1203
|
image: () => image,
|
|
1203
1204
|
number: () => number,
|
|
@@ -3279,9 +3280,8 @@ var validateCommonOpts = (fnCallSignature, opts) => {
|
|
|
3279
3280
|
}
|
|
3280
3281
|
}
|
|
3281
3282
|
};
|
|
3282
|
-
|
|
3283
|
+
function compoundFromSanitizedProps(sanitizedProps, opts = {}) {
|
|
3283
3284
|
validateCommonOpts("t.compound(props, opts)", opts);
|
|
3284
|
-
const sanitizedProps = sanitizeCompoundProps(props);
|
|
3285
3285
|
const deserializationCache = /* @__PURE__ */ new WeakMap();
|
|
3286
3286
|
const config = {
|
|
3287
3287
|
type: "compound",
|
|
@@ -3316,6 +3316,10 @@ var compound = (props, opts = {}) => {
|
|
|
3316
3316
|
}
|
|
3317
3317
|
};
|
|
3318
3318
|
return config;
|
|
3319
|
+
}
|
|
3320
|
+
var compound = (props, opts = {}) => {
|
|
3321
|
+
const sanitizedProps = sanitizeCompoundProps(props);
|
|
3322
|
+
return compoundFromSanitizedProps(sanitizedProps, opts);
|
|
3319
3323
|
};
|
|
3320
3324
|
var file = (defaultValue, opts = {}) => {
|
|
3321
3325
|
if (process.env.NODE_ENV !== "production") {
|
|
@@ -3667,6 +3671,21 @@ function resolveShowPropsOfSources(host, objects, apiName) {
|
|
|
3667
3671
|
});
|
|
3668
3672
|
}
|
|
3669
3673
|
|
|
3674
|
+
// core/src/sheetObjects/unsanitizedObjectProps.ts
|
|
3675
|
+
var weakMapOfUnsanitizedProps = /* @__PURE__ */ new WeakMap();
|
|
3676
|
+
function getUnsanitizedObjectProps(object) {
|
|
3677
|
+
return weakMapOfUnsanitizedProps.get(object);
|
|
3678
|
+
}
|
|
3679
|
+
function setUnsanitizedObjectProps(object, config) {
|
|
3680
|
+
weakMapOfUnsanitizedProps.set(object, config);
|
|
3681
|
+
}
|
|
3682
|
+
function mergeUnsanitizedObjectProps(object, additional) {
|
|
3683
|
+
const existing = weakMapOfUnsanitizedProps.get(object) ?? {};
|
|
3684
|
+
const merged = { ...existing, ...additional };
|
|
3685
|
+
weakMapOfUnsanitizedProps.set(object, merged);
|
|
3686
|
+
return merged;
|
|
3687
|
+
}
|
|
3688
|
+
|
|
3670
3689
|
// core/src/sheetObjects/TheatreSheetObject.ts
|
|
3671
3690
|
var KEEP_HOT_FOR_MS = 5 * 1e3;
|
|
3672
3691
|
var TheatreSheetObject = class {
|
|
@@ -3771,8 +3790,25 @@ var TheatreSheetObject = class {
|
|
|
3771
3790
|
host.template.setStaticPropPaths(opts.static, sanitizedConfig);
|
|
3772
3791
|
}
|
|
3773
3792
|
}
|
|
3793
|
+
addProps(config, opts) {
|
|
3794
|
+
const host = privateAPI(this);
|
|
3795
|
+
host.template.addProps(config);
|
|
3796
|
+
if (process.env.NODE_ENV !== "production") {
|
|
3797
|
+
mergeUnsanitizedObjectProps(host, config);
|
|
3798
|
+
}
|
|
3799
|
+
const mergedConfig = host.template.staticConfig;
|
|
3800
|
+
if (opts?.transient !== void 0) {
|
|
3801
|
+
host.template.setTransientPropPaths(opts.transient, mergedConfig);
|
|
3802
|
+
}
|
|
3803
|
+
if (opts?.static !== void 0) {
|
|
3804
|
+
host.template.setStaticPropPaths(opts.static, mergedConfig);
|
|
3805
|
+
}
|
|
3806
|
+
}
|
|
3774
3807
|
};
|
|
3775
3808
|
|
|
3809
|
+
// shared/src/propTypes/utils.ts
|
|
3810
|
+
var import_fast_deep_equal = __toESM(require_fast_deep_equal());
|
|
3811
|
+
|
|
3776
3812
|
// shared/src/utils/memoizeFn.ts
|
|
3777
3813
|
function memoizeFn(producer) {
|
|
3778
3814
|
const cache2 = /* @__PURE__ */ new WeakMap();
|
|
@@ -5011,6 +5047,18 @@ function iterateOnAny(path, config, map) {
|
|
|
5011
5047
|
}
|
|
5012
5048
|
}
|
|
5013
5049
|
|
|
5050
|
+
// shared/src/utils/defaultPropValues.ts
|
|
5051
|
+
var objectPropConfigRegistry = /* @__PURE__ */ new Map();
|
|
5052
|
+
function objectPropConfigRegistryKey(projectId, sheetId, objectKey) {
|
|
5053
|
+
return "".concat(projectId, "\0").concat(sheetId, "\0").concat(objectKey);
|
|
5054
|
+
}
|
|
5055
|
+
function registerObjectPropConfig(projectId, sheetId, objectKey, config) {
|
|
5056
|
+
objectPropConfigRegistry.set(
|
|
5057
|
+
objectPropConfigRegistryKey(projectId, sheetId, objectKey),
|
|
5058
|
+
config
|
|
5059
|
+
);
|
|
5060
|
+
}
|
|
5061
|
+
|
|
5014
5062
|
// core/src/sheetObjects/SheetObjectTemplate.ts
|
|
5015
5063
|
function isObjectEmpty(obj) {
|
|
5016
5064
|
return typeof obj === "object" && obj !== null && Object.keys(obj).length === 0;
|
|
@@ -5057,6 +5105,12 @@ var SheetObjectTemplate = class {
|
|
|
5057
5105
|
objectKey,
|
|
5058
5106
|
this._transientPropPaths
|
|
5059
5107
|
);
|
|
5108
|
+
registerObjectPropConfig(
|
|
5109
|
+
this.address.projectId,
|
|
5110
|
+
this.address.sheetId,
|
|
5111
|
+
objectKey,
|
|
5112
|
+
config
|
|
5113
|
+
);
|
|
5060
5114
|
this.pointerToSheetState = this.sheetTemplate.project.pointers.historic.sheetsById[this.address.sheetId];
|
|
5061
5115
|
this.pointerToStaticOverrides = this.pointerToSheetState.staticOverrides.byObject[this.address.objectKey];
|
|
5062
5116
|
this.pointerToAhistoricSheetState = this.sheetTemplate.project.pointers.ahistoric.sheetsById[this.address.sheetId];
|
|
@@ -5127,6 +5181,29 @@ var SheetObjectTemplate = class {
|
|
|
5127
5181
|
config
|
|
5128
5182
|
);
|
|
5129
5183
|
}
|
|
5184
|
+
addProps(config) {
|
|
5185
|
+
const existing = this._config.get();
|
|
5186
|
+
const additional = compound(config);
|
|
5187
|
+
for (const key of Object.keys(additional.props)) {
|
|
5188
|
+
if (Object.prototype.hasOwnProperty.call(existing.props, key)) {
|
|
5189
|
+
throw new InvalidArgumentError(
|
|
5190
|
+
'Cannot add prop "'.concat(key, '" because it already exists on object "').concat(this.address.objectKey, '".')
|
|
5191
|
+
);
|
|
5192
|
+
}
|
|
5193
|
+
}
|
|
5194
|
+
const merged = compoundFromSanitizedProps({
|
|
5195
|
+
...existing.props,
|
|
5196
|
+
...additional.props
|
|
5197
|
+
});
|
|
5198
|
+
this._config.set(merged);
|
|
5199
|
+
registerObjectPropConfig(
|
|
5200
|
+
this.address.projectId,
|
|
5201
|
+
this.address.sheetId,
|
|
5202
|
+
this.address.objectKey,
|
|
5203
|
+
merged
|
|
5204
|
+
);
|
|
5205
|
+
this._stripNonPersistingPropsFromAhistoricState();
|
|
5206
|
+
}
|
|
5130
5207
|
setTransientPropPaths(transient, config) {
|
|
5131
5208
|
this._transientPropPaths = normalizeTransientPropPaths(
|
|
5132
5209
|
transient,
|
|
@@ -6513,8 +6590,7 @@ function parseOutlineNamespacePath(namespacePath, fnName) {
|
|
|
6513
6590
|
}
|
|
6514
6591
|
|
|
6515
6592
|
// core/src/sheets/TheatreSheet.ts
|
|
6516
|
-
var
|
|
6517
|
-
var weakMapOfUnsanitizedProps = /* @__PURE__ */ new WeakMap();
|
|
6593
|
+
var import_fast_deep_equal2 = __toESM(require_fast_deep_equal());
|
|
6518
6594
|
var TheatreSheet = class {
|
|
6519
6595
|
get type() {
|
|
6520
6596
|
return "Theatre_Sheet_PublicAPI";
|
|
@@ -6536,9 +6612,9 @@ var TheatreSheet = class {
|
|
|
6536
6612
|
const actions = opts?.__actions__THIS_API_IS_UNSTABLE_AND_WILL_CHANGE_IN_THE_NEXT_VERSION;
|
|
6537
6613
|
if (existingObject) {
|
|
6538
6614
|
if (process.env.NODE_ENV !== "production") {
|
|
6539
|
-
const prevConfig =
|
|
6615
|
+
const prevConfig = getUnsanitizedObjectProps(existingObject);
|
|
6540
6616
|
if (prevConfig) {
|
|
6541
|
-
if (!(0,
|
|
6617
|
+
if (!(0, import_fast_deep_equal2.default)(config, prevConfig)) {
|
|
6542
6618
|
if (opts?.reconfigure === true) {
|
|
6543
6619
|
const sanitizedConfig = compound(config);
|
|
6544
6620
|
existingObject.template.reconfigure(sanitizedConfig);
|
|
@@ -6563,7 +6639,7 @@ var TheatreSheet = class {
|
|
|
6563
6639
|
)
|
|
6564
6640
|
);
|
|
6565
6641
|
}
|
|
6566
|
-
|
|
6642
|
+
setUnsanitizedObjectProps(existingObject, config);
|
|
6567
6643
|
return existingObject.publicApi;
|
|
6568
6644
|
} else {
|
|
6569
6645
|
throw new Error(
|
|
@@ -6613,7 +6689,7 @@ var TheatreSheet = class {
|
|
|
6613
6689
|
opts?.static
|
|
6614
6690
|
);
|
|
6615
6691
|
if (process.env.NODE_ENV !== "production") {
|
|
6616
|
-
|
|
6692
|
+
setUnsanitizedObjectProps(object, config);
|
|
6617
6693
|
}
|
|
6618
6694
|
if (opts?.showPropsOf !== void 0) {
|
|
6619
6695
|
object.template.setShowPropsOf(
|
|
@@ -8136,6 +8212,15 @@ var Project = class {
|
|
|
8136
8212
|
});
|
|
8137
8213
|
}
|
|
8138
8214
|
}
|
|
8215
|
+
/** Re-initialize studio state from this project's `config.state`. */
|
|
8216
|
+
async reinitializeStateFromConfig() {
|
|
8217
|
+
if (!this._studio) {
|
|
8218
|
+
throw new Error(
|
|
8219
|
+
"Cannot reinitialize project ".concat(this.address.projectId, ": not attached to studio")
|
|
8220
|
+
);
|
|
8221
|
+
}
|
|
8222
|
+
await initialiseProjectState(this._studio, this, this.config.state);
|
|
8223
|
+
}
|
|
8139
8224
|
};
|
|
8140
8225
|
|
|
8141
8226
|
// shared/src/utils/sanitizers.ts
|
|
@@ -8260,14 +8345,14 @@ var TheatreProject = class {
|
|
|
8260
8345
|
};
|
|
8261
8346
|
|
|
8262
8347
|
// core/src/coreExports.ts
|
|
8263
|
-
var
|
|
8348
|
+
var import_fast_deep_equal3 = __toESM(require_fast_deep_equal());
|
|
8264
8349
|
import { isPointer } from "@unseenco/theatre-dataverse";
|
|
8265
8350
|
import { isPrism, pointerToPrism } from "@unseenco/theatre-dataverse";
|
|
8266
8351
|
function getProject(id, config = {}) {
|
|
8267
8352
|
const existingProject = projectsSingleton_default.get(id);
|
|
8268
8353
|
if (existingProject) {
|
|
8269
8354
|
if (process.env.NODE_ENV !== "production") {
|
|
8270
|
-
if (!(0,
|
|
8355
|
+
if (!(0, import_fast_deep_equal3.default)(config, existingProject.config)) {
|
|
8271
8356
|
throw new Error(
|
|
8272
8357
|
'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."
|
|
8273
8358
|
);
|
|
@@ -8357,7 +8442,7 @@ var CoreBundle = class {
|
|
|
8357
8442
|
return "Theatre_CoreBundle";
|
|
8358
8443
|
}
|
|
8359
8444
|
get version() {
|
|
8360
|
-
return "0.1.
|
|
8445
|
+
return "0.1.18";
|
|
8361
8446
|
}
|
|
8362
8447
|
getBitsForStudio(studio, callback) {
|
|
8363
8448
|
if (this._studio) {
|