node-opcua-address-space 2.187.0 → 2.187.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.
@@ -242,13 +242,6 @@ export class NodeIdManager {
242
242
  };
243
243
 
244
244
  const buildUpName2 = (nodeId: NodeId, suffix: string) => {
245
- // a parent registered under a name of its own (`X__2`) passes that name on to its members
246
- if (nodeId.namespace === this.namespaceIndex && nodeId.identifierType === NodeIdType.NUMERIC) {
247
- const registered = this._nameOfId.get(nodeId.value as number);
248
- if (registered !== undefined) {
249
- return registered + suffix;
250
- }
251
- }
252
245
  const namespaceIndex = nodeId.namespace;
253
246
  let name = "";
254
247
  let n: BaseNode | null = this.addressSpace.findNode(nodeId);
@@ -257,6 +250,16 @@ export class NodeIdManager {
257
250
  name = compose(e, name);
258
251
  n = n.parentNodeId ? this.addressSpace.findNode(n.parentNodeId) : null;
259
252
  }
253
+ // a parent registered under a name of its own (`X__2`) passes that name on to its
254
+ // members. A parent hanging from another namespace is registered with that chain in
255
+ // front (`OPCBinary_TypeDictionary`), which its members never carry, as the
256
+ // ModelCompiler spells them (`TypeDictionary_NamespaceUri`)
257
+ if (nodeId.namespace === this.namespaceIndex && nodeId.identifierType === NodeIdType.NUMERIC) {
258
+ const registered = this._nameOfId.get(nodeId.value as number);
259
+ if (registered !== undefined && !(registered + suffix).endsWith(`_${name}`)) {
260
+ return registered + suffix;
261
+ }
262
+ }
260
263
  return name;
261
264
  };
262
265
 
@@ -256,6 +256,9 @@ export class UAVariableImpl<T extends UAVariableEvents & ListenerSignature<T> =
256
256
  */
257
257
  declare public _refreshFuncWrapsGetter?: boolean;
258
258
  declare public __waiting_callbacks?: CallbackT<DataValue>[];
259
+ // the variant types already found to fit the DataType below (bit k: DataType k), set on the first write
260
+ declare private _validatedForDataType?: NodeId;
261
+ declare private _validatedVariantTypes?: number;
259
262
  declare private __satisfy_waiting_callbacks?: (err: Error | null, dataValue?: DataValue) => void;
260
263
 
261
264
  get typeDefinitionObj(): UAVariableType {
@@ -1908,7 +1911,27 @@ export class UAVariableImpl<T extends UAVariableEvents & ListenerSignature<T> =
1908
1911
  }
1909
1912
 
1910
1913
  public _validate_DataType(variantDataType: DataType): boolean {
1911
- return validateDataTypeCorrectness(this.addressSpace, this.dataType, variantDataType, /* allow Nulls */ false, this.nodeId);
1914
+ // every write of a Variable checks the same variant type against the same DataType: a check that
1915
+ // passed is remembered while the DataType stays the same; a refusal is always checked again
1916
+ const bit = variantDataType >= 0 && variantDataType < 31 ? 1 << variantDataType : 0;
1917
+ if (bit && this._validatedForDataType === this.dataType && ((this._validatedVariantTypes ?? 0) & bit) !== 0) {
1918
+ return true;
1919
+ }
1920
+ const valid = validateDataTypeCorrectness(
1921
+ this.addressSpace,
1922
+ this.dataType,
1923
+ variantDataType,
1924
+ /* allow Nulls */ false,
1925
+ this.nodeId
1926
+ );
1927
+ if (valid && bit) {
1928
+ if (this._validatedForDataType !== this.dataType) {
1929
+ this._validatedForDataType = this.dataType;
1930
+ this._validatedVariantTypes = 0;
1931
+ }
1932
+ this._validatedVariantTypes = (this._validatedVariantTypes ?? 0) | bit;
1933
+ }
1934
+ return valid;
1912
1935
  }
1913
1936
 
1914
1937
  public _internal_set_value(value: Variant): void {
@@ -2270,26 +2293,24 @@ type f3<T, D, R> = (this: T, data: D, callback: (err: Error | null, r?: R) => vo
2270
2293
  function turn_sync_to_async<T, D, R>(f: f1<T, D, R> | f2<T, D, R> | f3<T, D, R>, numberOfArgs: number): f3<T, D, R> {
2271
2294
  if (f.length <= numberOfArgs) {
2272
2295
  return function (this: T, data: D, callback: (err: Error | null, r?: R) => void) {
2273
- new Promise<R>((resolve, reject) => {
2274
- try {
2275
- // const ff1 = f as f1<T, D, R>;
2276
- const ff2 = f as f2<T, D, R>;
2277
- const r: R | Promise<R> = ff2.call(this, data);
2278
- if (r instanceof Promise) {
2279
- r.then(resolve, reject);
2280
- } else {
2281
- resolve(r);
2282
- }
2283
- } catch (err) {
2284
- reject(err);
2285
- }
2286
- })
2287
- .then((r) => {
2288
- callback(null, r);
2289
- })
2290
- .catch((err) => {
2291
- callback(err as Error);
2292
- });
2296
+ const ff2 = f as f2<T, D, R>;
2297
+ let r: R | Promise<R>;
2298
+ try {
2299
+ r = ff2.call(this, data);
2300
+ } catch (err) {
2301
+ callback(err as Error);
2302
+ return;
2303
+ }
2304
+ if (r instanceof Promise) {
2305
+ r.then(
2306
+ (value) => callback(null, value),
2307
+ (err) => callback(err as Error)
2308
+ );
2309
+ return;
2310
+ }
2311
+ // a synchronous function answers at once: a Write of such Variables completes without waiting
2312
+ // a turn per value, under one permission cache for the whole request
2313
+ callback(null, r);
2293
2314
  };
2294
2315
  } else {
2295
2316
  assert(f.length === numberOfArgs + 1);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "node-opcua-address-space",
3
3
  "type": "module",
4
- "version": "2.187.0",
4
+ "version": "2.187.1",
5
5
  "description": "pure nodejs OPCUA SDK - module address-space",
6
6
  "main": "./dist/api/index.js",
7
7
  "types": "./dist/api/index.d.ts",
@@ -24,7 +24,7 @@
24
24
  "chalk": "6.0.1",
25
25
  "dequeue": "^1.0.5",
26
26
  "node-opcua-address-space-base": "2.187.0",
27
- "node-opcua-address-space-store": "2.187.0",
27
+ "node-opcua-address-space-store": "2.187.1",
28
28
  "node-opcua-assert": "2.186.7",
29
29
  "node-opcua-basic-types": "2.187.0",
30
30
  "node-opcua-binary-stream": "2.187.0",
@@ -84,7 +84,7 @@
84
84
  "internet of things"
85
85
  ],
86
86
  "homepage": "http://node-opcua.github.io/",
87
- "gitHead": "3397e8ca2017b8592a50912b34c747f3da617763",
87
+ "gitHead": "706db482c6f77cd5c7c1f98f9f7cf1c5841a0161",
88
88
  "files": [
89
89
  "dist",
90
90
  "distHelpers",