@syncbridge/common 0.5.12 → 0.6.0
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/classes/base-element.js +4 -2
- package/constants.js +1 -1
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/package.json +3 -2
- package/processor-factory.js +30 -25
- /package/utils/{metadata-utils.d.ts → materialize-metadata.d.ts} +0 -0
- /package/utils/{metadata-utils.js → materialize-metadata.js} +0 -0
package/classes/base-element.js
CHANGED
|
@@ -12,8 +12,10 @@ export class BaseElement extends Runnable {
|
|
|
12
12
|
this.logger = init.logger;
|
|
13
13
|
this.name = init.name;
|
|
14
14
|
this.values = init.values;
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
this.on('error', err => this.logger?.error(err));
|
|
16
|
+
this.on('values-updated', (properties) => {
|
|
17
|
+
this.logger?.info(`Configuration changed. Updated properties: ${properties.join(',')}`);
|
|
18
|
+
});
|
|
17
19
|
}
|
|
18
20
|
get status() {
|
|
19
21
|
return this._context.calculatedStatus || this._context.status;
|
package/constants.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const version = '0.
|
|
1
|
+
export const version = '0.6.0';
|
|
2
2
|
export const OWN_ELEMENT_METADATA = Symbol.for('OWN_ELEMENT_METADATA');
|
|
3
3
|
export const COMPONENT_OPTIONS = Symbol.for('COMPONENT_OPTIONS');
|
|
4
4
|
export const PROCESSOR_OPTIONS = Symbol.for('PROCESSOR_OPTIONS');
|
package/index.d.ts
CHANGED
|
@@ -16,5 +16,5 @@ export * from './models-document.js';
|
|
|
16
16
|
export * from './processor-factory.js';
|
|
17
17
|
export * from './registry/extension-package.js';
|
|
18
18
|
export * from './registry/extension-registry.js';
|
|
19
|
-
export * from './utils/metadata
|
|
19
|
+
export * from './utils/materialize-metadata.js';
|
|
20
20
|
export * from './utils/profile-utils.js';
|
package/index.js
CHANGED
|
@@ -16,5 +16,5 @@ export * from './models-document.js';
|
|
|
16
16
|
export * from './processor-factory.js';
|
|
17
17
|
export * from './registry/extension-package.js';
|
|
18
18
|
export * from './registry/extension-registry.js';
|
|
19
|
-
export * from './utils/metadata
|
|
19
|
+
export * from './utils/materialize-metadata.js';
|
|
20
20
|
export * from './utils/profile-utils.js';
|
package/package.json
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@syncbridge/common",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "SyncBridge Common utilities",
|
|
5
5
|
"author": "Panates Inc",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@jsopen/objects": "^2.1.1",
|
|
9
|
+
"fast-deep-equal": "^3.1.3",
|
|
9
10
|
"node-events-async": "^1.5.0",
|
|
10
11
|
"reflect-metadata": "^0.2.2",
|
|
11
12
|
"semver": "^7.7.4",
|
|
12
13
|
"ts-gems": "^3.11.3",
|
|
13
|
-
"valgen": "^5.19.
|
|
14
|
+
"valgen": "^5.19.5"
|
|
14
15
|
},
|
|
15
16
|
"peerDependencies": {
|
|
16
17
|
"@opra/common": ">=1.17.1 <2"
|
package/processor-factory.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import equal from 'fast-deep-equal';
|
|
1
2
|
import { StackExecutor } from './classes/stack-executor.js';
|
|
2
3
|
import { initializeModelsDocument } from './models-document.js';
|
|
3
4
|
import { ExtensionRegistry } from './registry/extension-registry.js';
|
|
4
|
-
import { materializeMetadata } from './utils/metadata
|
|
5
|
+
import { materializeMetadata } from './utils/materialize-metadata.js';
|
|
5
6
|
export var ProcessorFactory;
|
|
6
7
|
(function (ProcessorFactory) {
|
|
7
8
|
ProcessorFactory.METADATA_KEY = Symbol('METADATA');
|
|
@@ -49,11 +50,12 @@ export var ProcessorFactory;
|
|
|
49
50
|
await signalUpdates(component);
|
|
50
51
|
}
|
|
51
52
|
}
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
const properties = ctx.valueUpdates.get(obj);
|
|
54
|
+
if (properties?.length) {
|
|
55
|
+
await obj.emitAsyncSafe('values-updated', properties);
|
|
54
56
|
}
|
|
55
57
|
};
|
|
56
|
-
signalUpdates(processor);
|
|
58
|
+
await signalUpdates(processor);
|
|
57
59
|
return {
|
|
58
60
|
issues: ctx.stackExecutor.issues,
|
|
59
61
|
};
|
|
@@ -93,7 +95,6 @@ export var ProcessorFactory;
|
|
|
93
95
|
oldMetadata?.className &&
|
|
94
96
|
oldMetadata?.className !== newMetadata.className)
|
|
95
97
|
throw new Error('Can not change component class while processor running. You should stop it first.');
|
|
96
|
-
ExtensionRegistry.getComponent(childMetadata.className);
|
|
97
98
|
/** Validate sub components */
|
|
98
99
|
if (childMetadata.components) {
|
|
99
100
|
_validateComponents({
|
|
@@ -125,14 +126,14 @@ export var ProcessorFactory;
|
|
|
125
126
|
});
|
|
126
127
|
}
|
|
127
128
|
async function _configureComponent(ctx, key, childMetadata) {
|
|
128
|
-
const {
|
|
129
|
+
const { newProfile, oldMetadata, oldProfile, curPath, owner, processor } = ctx;
|
|
129
130
|
const oldChildMetadata = oldMetadata?.components?.[key];
|
|
130
131
|
const oldChildProfile = oldProfile?.components?.[key];
|
|
131
132
|
const childProfile = newProfile.components[key];
|
|
132
133
|
const componentPath = curPath ? curPath + '/' + key : key;
|
|
133
134
|
let componentInstance = owner.components?.[key];
|
|
134
|
-
/** Create the component only if the
|
|
135
|
-
if (
|
|
135
|
+
/** Create the component only if the owner stopped */ // todo implement hotplug components
|
|
136
|
+
if (owner.stopped) {
|
|
136
137
|
const compReg = ExtensionRegistry.getComponent(childMetadata.className);
|
|
137
138
|
/** Create the component instance */
|
|
138
139
|
const compClass = await compReg.getClass();
|
|
@@ -150,26 +151,30 @@ export var ProcessorFactory;
|
|
|
150
151
|
}
|
|
151
152
|
else {
|
|
152
153
|
componentInstance.values = {};
|
|
153
|
-
const patchValues = (target, valPath, newValues, newVariables,
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
154
|
+
const patchValues = (target, valPath, newValues, newVariables, oldValues, oldVariables) => {
|
|
155
|
+
if (oldValues)
|
|
156
|
+
Object.assign(target, oldValues);
|
|
157
|
+
const updatedValues = ctx.valueUpdates.get(componentInstance) || [];
|
|
158
|
+
ctx.valueUpdates.set(componentInstance, updatedValues);
|
|
159
|
+
if (newVariables) {
|
|
160
|
+
for (const [varKey, varMeta] of Object.entries(newVariables)) {
|
|
161
|
+
const keyPath = valPath ? valPath + '.' + varKey : varKey;
|
|
162
|
+
/** Update only hotplug variables */
|
|
163
|
+
if (varMeta?.hotPlug !== true)
|
|
164
|
+
continue;
|
|
165
|
+
if (varMeta.type === 'nested') {
|
|
166
|
+
target[varKey] = {};
|
|
167
|
+
patchValues(target[varKey], keyPath, newValues[varKey], newVariables[varKey]?.variables || {}, oldValues?.[varKey], oldVariables?.[varKey]?.variables);
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
if (!equal(target[varKey], newValues[varKey])) {
|
|
171
|
+
updatedValues.push(keyPath);
|
|
172
|
+
target[varKey] = newValues[varKey];
|
|
173
|
+
}
|
|
165
174
|
}
|
|
166
|
-
updatedValues.push(keyPath);
|
|
167
|
-
target[varKey] = newValues[varKey];
|
|
168
175
|
}
|
|
169
|
-
if (updatedValues.length)
|
|
170
|
-
ctx.valueUpdates.set(componentInstance, updatedValues);
|
|
171
176
|
};
|
|
172
|
-
patchValues(componentInstance.values, '', childProfile.values || {}, childMetadata.variables || {},
|
|
177
|
+
patchValues(componentInstance.values, '', childProfile.values || {}, childMetadata.variables || {}, oldChildProfile?.values, oldChildMetadata?.variables);
|
|
173
178
|
}
|
|
174
179
|
/** Create the child logger */
|
|
175
180
|
componentInstance.logger = owner.logger?.child({
|
|
File without changes
|
|
File without changes
|