@syncbridge/common 2.3.0 → 2.3.1

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/app-factory.js CHANGED
@@ -266,7 +266,13 @@ export var AppFactory;
266
266
  }
267
267
  });
268
268
  }
269
- function _patchValues(ctx, instance, target, valPath, newValues, newVariables, oldValues, oldVariables) {
269
+ /**
270
+ * A running element's values, patched with a new profile's: its hot-plug
271
+ * settings alone - those of a hot-plug group all of them. A list - of
272
+ * values or of groups - is replaced whole, never merged into an object.
273
+ * The paths changed are kept for its 'values-updated' event.
274
+ */
275
+ function _patchValues(ctx, instance, target, valPath, newValues, newVariables, oldValues, oldVariables, hot = false) {
270
276
  if (oldValues)
271
277
  Object.assign(target, oldValues);
272
278
  const updatedValues = ctx.valueUpdates?.get(instance) || [];
@@ -274,17 +280,20 @@ export var AppFactory;
274
280
  if (newVariables) {
275
281
  for (const [varKey, varMeta] of Object.entries(newVariables)) {
276
282
  const keyPath = valPath ? valPath + '.' + varKey : varKey;
277
- /** Update only hotplug variables */
278
- if (varMeta?.hotPlug !== true)
283
+ /** Update only hotplug variables, and all of a hotplug group */
284
+ if (!hot && varMeta?.hotPlug !== true)
279
285
  continue;
280
- if (varMeta.type === 'nested') {
286
+ if (varMeta.type === 'nested' && !varMeta.isArray) {
281
287
  target[varKey] = {};
282
- _patchValues(ctx, instance, target[varKey], keyPath, newValues[varKey], newVariables[varKey]?.variables || {}, oldValues?.[varKey], oldVariables?.[varKey]?.variables);
288
+ _patchValues(ctx, instance, target[varKey], keyPath, newValues?.[varKey], newVariables[varKey]?.variables || {}, oldValues?.[varKey], oldVariables?.[varKey]?.variables, true);
283
289
  continue;
284
290
  }
285
- if (!equal(target[varKey], newValues[varKey])) {
291
+ const value = newValues?.[varKey];
292
+ if (!equal(target[varKey], value)) {
286
293
  updatedValues.push(keyPath);
287
- target[varKey] = newValues[varKey];
294
+ /* Its own copy: the profile's left as it is */
295
+ target[varKey] =
296
+ value && typeof value === 'object' ? clone(value) : value;
288
297
  }
289
298
  }
290
299
  }
package/constants.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const version = "2.3.0";
1
+ export declare const version = "2.3.1";
2
2
  export declare const CLASS_METADATA: unique symbol;
3
3
  export declare const CLASS_TYPE: unique symbol;
4
4
  export declare const VARIABLE_CONTAINER: unique symbol;
package/constants.js CHANGED
@@ -1,4 +1,4 @@
1
- export const version = '2.3.0';
1
+ export const version = '2.3.1';
2
2
  export const CLASS_METADATA = Symbol.for('CLASS_METADATA');
3
3
  export const CLASS_TYPE = Symbol.for('CLASS_TYPE');
4
4
  export const VARIABLE_CONTAINER = Symbol.for('VARIABLE_CONTAINER');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@syncbridge/common",
3
- "version": "2.3.0",
3
+ "version": "2.3.1",
4
4
  "description": "SyncBridge Common utilities",
5
5
  "author": "Panates Inc",
6
6
  "license": "MIT",