@specter-automation/test 1.0.158 → 1.0.159
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.
|
@@ -100,6 +100,13 @@ export declare class SpecterLocator<T = any> {
|
|
|
100
100
|
* locator files add themselves here, since this file can't import them.
|
|
101
101
|
*/
|
|
102
102
|
static locatorFactories: Record<string, (transport: SpecterTransport, pipeline: LocatorStep[]) => SpecterLocator<any>>;
|
|
103
|
+
private static warnedLowerCaseKeys;
|
|
104
|
+
/**
|
|
105
|
+
* Struct fields used to come back lower-cased ("eventtype" for EventType). They now come back as declared.
|
|
106
|
+
* Tests written against the old names keep working through hidden aliases, which warn once each.
|
|
107
|
+
* The aliases aren't enumerable, so they don't show in toEqual, Object.keys or JSON.
|
|
108
|
+
*/
|
|
109
|
+
private static addLowerCaseAliases;
|
|
103
110
|
/** Turns the engine's object references (in a value, an array or a struct) into locators */
|
|
104
111
|
protected hydrateValue(val: any): any;
|
|
105
112
|
getMaterialScalarParameter(parameterName: string, options?: {
|
|
@@ -247,8 +247,11 @@ class SpecterLocator {
|
|
|
247
247
|
return data;
|
|
248
248
|
}
|
|
249
249
|
const unpackValue = (val) => this.hydrateValue(val);
|
|
250
|
+
// A function with one output gives that value, whatever the output is called: a Blueprint
|
|
251
|
+
// function's output pin named "Open" used to come back as { Open: true }. With several outputs,
|
|
252
|
+
// an object of them by name.
|
|
250
253
|
const keys = Object.keys(data);
|
|
251
|
-
if (keys.length === 1
|
|
254
|
+
if (keys.length === 1) {
|
|
252
255
|
return unpackValue(data[keys[0]]);
|
|
253
256
|
}
|
|
254
257
|
if (keys.length === 0) {
|
|
@@ -291,6 +294,31 @@ class SpecterLocator {
|
|
|
291
294
|
* locator files add themselves here, since this file can't import them.
|
|
292
295
|
*/
|
|
293
296
|
static locatorFactories = {};
|
|
297
|
+
static warnedLowerCaseKeys = new Set();
|
|
298
|
+
/**
|
|
299
|
+
* Struct fields used to come back lower-cased ("eventtype" for EventType). They now come back as declared.
|
|
300
|
+
* Tests written against the old names keep working through hidden aliases, which warn once each.
|
|
301
|
+
* The aliases aren't enumerable, so they don't show in toEqual, Object.keys or JSON.
|
|
302
|
+
*/
|
|
303
|
+
static addLowerCaseAliases(obj) {
|
|
304
|
+
for (const key of Object.keys(obj)) {
|
|
305
|
+
const lower = key.toLowerCase();
|
|
306
|
+
if (lower === key || lower in obj) {
|
|
307
|
+
continue;
|
|
308
|
+
}
|
|
309
|
+
Object.defineProperty(obj, lower, {
|
|
310
|
+
enumerable: false,
|
|
311
|
+
configurable: true,
|
|
312
|
+
get() {
|
|
313
|
+
if (!SpecterLocator.warnedLowerCaseKeys.has(lower)) {
|
|
314
|
+
SpecterLocator.warnedLowerCaseKeys.add(lower);
|
|
315
|
+
console.warn(`[SPECTER] "${lower}" is the old lower-cased name of the struct field "${key}". Use "${key}": the old name will stop working in a later version.`);
|
|
316
|
+
}
|
|
317
|
+
return obj[key];
|
|
318
|
+
},
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
}
|
|
294
322
|
/** Turns the engine's object references (in a value, an array or a struct) into locators */
|
|
295
323
|
hydrateValue(val) {
|
|
296
324
|
if (Array.isArray(val)) {
|
|
@@ -325,6 +353,7 @@ class SpecterLocator {
|
|
|
325
353
|
for (const [key, inner] of Object.entries(val)) {
|
|
326
354
|
out[key] = this.hydrateValue(inner);
|
|
327
355
|
}
|
|
356
|
+
SpecterLocator.addLowerCaseAliases(out);
|
|
328
357
|
return out;
|
|
329
358
|
}
|
|
330
359
|
}
|