node-opcua-data-model 2.172.0 → 2.174.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/dist/localized_text.d.ts +12 -3
- package/dist/localized_text.js +20 -4
- package/dist/localized_text.js.map +1 -1
- package/package.json +9 -9
- package/source/localized_text.ts +30 -10
package/dist/localized_text.d.ts
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @module node-opcua-data-model
|
|
3
|
+
*/
|
|
4
|
+
import { type LocaleId, type UAString } from "node-opcua-basic-types";
|
|
5
|
+
import type { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream";
|
|
6
|
+
import { BaseUAObject, type DecodeDebugOptions, type IStructuredTypeSchema } from "node-opcua-factory";
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @param value
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
4
12
|
export declare function coerceLocalizedText(value?: null | string | LocalizedTextOptions): LocalizedText | null;
|
|
13
|
+
export declare function coerceLocalizedTextStrict(value?: null | string | LocalizedTextOptions): LocalizedText;
|
|
5
14
|
export interface LocalizedTextOptions {
|
|
6
15
|
locale?: LocaleId;
|
|
7
16
|
text?: UAString;
|
package/dist/localized_text.js
CHANGED
|
@@ -2,10 +2,19 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LocalizedText = void 0;
|
|
4
4
|
exports.coerceLocalizedText = coerceLocalizedText;
|
|
5
|
+
exports.coerceLocalizedTextStrict = coerceLocalizedTextStrict;
|
|
5
6
|
exports.encodeLocalizedText = encodeLocalizedText;
|
|
6
7
|
exports.decodeLocalizedText = decodeLocalizedText;
|
|
8
|
+
/**
|
|
9
|
+
* @module node-opcua-data-model
|
|
10
|
+
*/
|
|
7
11
|
const node_opcua_basic_types_1 = require("node-opcua-basic-types");
|
|
8
12
|
const node_opcua_factory_1 = require("node-opcua-factory");
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
* @param value
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
9
18
|
function coerceLocalizedText(value) {
|
|
10
19
|
if (value === undefined || value === null) {
|
|
11
20
|
return null;
|
|
@@ -15,6 +24,13 @@ function coerceLocalizedText(value) {
|
|
|
15
24
|
}
|
|
16
25
|
return new LocalizedText(value);
|
|
17
26
|
}
|
|
27
|
+
function coerceLocalizedTextStrict(value) {
|
|
28
|
+
let result = coerceLocalizedText(value);
|
|
29
|
+
if (!result) {
|
|
30
|
+
result = new LocalizedText({ locale: null, text: null });
|
|
31
|
+
}
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
18
34
|
// --------------------------------------------------------------------------------------------
|
|
19
35
|
// see Part 3 - $8.5 page 63
|
|
20
36
|
const schemaLocalizedText = (0, node_opcua_factory_1.buildStructuredType)({
|
|
@@ -69,7 +85,7 @@ class LocalizedText extends node_opcua_factory_1.BaseUAObject {
|
|
|
69
85
|
this.text = options?.text || null;
|
|
70
86
|
}
|
|
71
87
|
toString() {
|
|
72
|
-
return
|
|
88
|
+
return `locale=${this.locale} text=${this.text}`;
|
|
73
89
|
}
|
|
74
90
|
// OPCUA Part 6 $ 5.2.2.14 : localizedText have a special encoding
|
|
75
91
|
encode(stream) {
|
|
@@ -84,12 +100,12 @@ class LocalizedText extends node_opcua_factory_1.BaseUAObject {
|
|
|
84
100
|
}
|
|
85
101
|
}
|
|
86
102
|
decodeDebug(stream, options) {
|
|
87
|
-
let cursorBefore;
|
|
103
|
+
let cursorBefore = 0;
|
|
88
104
|
const tracer = options.tracer;
|
|
89
|
-
tracer.trace("start", options.name
|
|
105
|
+
tracer.trace("start", `${options.name}(LocalizedText)`, stream.length, stream.length);
|
|
90
106
|
cursorBefore = stream.length;
|
|
91
107
|
const encodingMask = (0, node_opcua_basic_types_1.decodeByte)(stream);
|
|
92
|
-
tracer.trace("member", "encodingByte",
|
|
108
|
+
tracer.trace("member", "encodingByte", `0x${encodingMask.toString(16)}`, cursorBefore, stream.length, "Mask");
|
|
93
109
|
cursorBefore = stream.length;
|
|
94
110
|
if ((encodingMask & 0x01) === 0x01) {
|
|
95
111
|
this.locale = (0, node_opcua_basic_types_1.decodeString)(stream);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localized_text.js","sourceRoot":"","sources":["../source/localized_text.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"localized_text.js","sourceRoot":"","sources":["../source/localized_text.ts"],"names":[],"mappings":";;;AA+BA,kDAQC;AACD,8DAMC;AAqJD,kDAMC;AAED,kDAIC;AA/MD;;GAEG;AACH,mEAOgC;AAKhC,2DAS4B;AAE5B;;;;GAIG;AACH,SAAgB,mBAAmB,CAAC,KAA4C;IAC5E,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACxC,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,IAAI,KAAK,YAAY,aAAa,EAAE,CAAC;QACjC,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,OAAO,IAAI,aAAa,CAAC,KAAK,CAAC,CAAC;AACpC,CAAC;AACD,SAAgB,yBAAyB,CAAC,KAA4C;IACnF,IAAI,MAAM,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAC;IACvC,IAAI,CAAC,MAAM,EAAE,CAAC;QACV,MAAM,GAAG,IAAI,aAAa,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7D,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC;AAED,+FAA+F;AAC/F,4BAA4B;AAC5B,MAAM,mBAAmB,GAAG,IAAA,wCAAmB,EAAC;IAC5C,IAAI,EAAE,eAAe;IAErB,QAAQ,EAAE,cAAc;IACxB,QAAQ,EAAE,kCAAa,CAAC,KAAK;IAC7B,MAAM,EAAE;QACJ;YACI,IAAI,EAAE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AAC;aAAM,CAAC;YACJ,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACrB,CAAC;IACL,CAAC;;AAjGL,sCAkGC;AAED,mFAAmF;AACnF,IAAA,kDAA6B,EAAC,aAAa,CAAC,CAAC;AAI7C,SAAS,4BAA4B,CAAC,aAA4B;IAC9D,IAAI,YAAY,GAAG,CAAC,CAAC;IACrB,IAAI,aAAa,CAAC,MAAM,EAAE,CAAC;QACvB,YAAY,IAAI,IAAI,CAAC;IACzB,CAAC;IACD,IAAI,aAAa,CAAC,IAAI,EAAE,CAAC;QACrB,YAAY,IAAI,IAAI,CAAC;IACzB,CAAC;IACD,OAAO,YAAY,CAAC;AACxB,CAAC;AAED,MAAM,kBAAkB,GAAG,IAAI,aAAa,CAAC,EAAE,CAAC,CAAC;AAEjD,SAAgB,mBAAmB,CAAC,KAAoB,EAAE,MAA0B;IAChF,IAAI,KAAK,EAAE,CAAC;QACR,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACzB,CAAC;SAAM,CAAC;QACJ,kBAAkB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;AACL,CAAC;AAED,SAAgB,mBAAmB,CAAC,MAAoB,EAAE,KAAqB;IAC3E,KAAK,GAAG,KAAK,IAAI,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC;IACzC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACrB,OAAO,KAAK,CAAC;AACjB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-opcua-data-model",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.174.0",
|
|
4
4
|
"description": "pure nodejs OPCUA SDK - module data-model",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "tsc -b",
|
|
@@ -15,15 +15,15 @@
|
|
|
15
15
|
"types": "./dist/index.d.ts",
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"node-opcua-assert": "2.164.0",
|
|
18
|
-
"node-opcua-basic-types": "2.
|
|
19
|
-
"node-opcua-binary-stream": "2.
|
|
20
|
-
"node-opcua-enum": "2.
|
|
21
|
-
"node-opcua-factory": "2.
|
|
22
|
-
"node-opcua-nodeid": "2.
|
|
23
|
-
"node-opcua-status-code": "2.
|
|
18
|
+
"node-opcua-basic-types": "2.174.0",
|
|
19
|
+
"node-opcua-binary-stream": "2.173.0",
|
|
20
|
+
"node-opcua-enum": "2.173.0",
|
|
21
|
+
"node-opcua-factory": "2.174.0",
|
|
22
|
+
"node-opcua-nodeid": "2.174.0",
|
|
23
|
+
"node-opcua-status-code": "2.173.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"node-opcua-packet-analyzer": "2.
|
|
26
|
+
"node-opcua-packet-analyzer": "2.174.0"
|
|
27
27
|
},
|
|
28
28
|
"author": "Etienne Rossignon",
|
|
29
29
|
"license": "MIT",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"internet of things"
|
|
41
41
|
],
|
|
42
42
|
"homepage": "http://node-opcua.github.io/",
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "011657a3a4805ad106df7381c24ed84e2a18d8f1",
|
|
44
44
|
"files": [
|
|
45
45
|
"dist",
|
|
46
46
|
"source"
|
package/source/localized_text.ts
CHANGED
|
@@ -1,21 +1,34 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module node-opcua-data-model
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import {
|
|
5
|
+
decodeByte,
|
|
6
|
+
decodeString,
|
|
7
|
+
encodeByte,
|
|
8
|
+
encodeString,
|
|
9
|
+
type LocaleId,
|
|
10
|
+
type UAString
|
|
11
|
+
} from "node-opcua-basic-types";
|
|
12
|
+
import type {
|
|
13
|
+
BinaryStream,
|
|
14
|
+
OutputBinaryStream
|
|
15
|
+
} from "node-opcua-binary-stream";
|
|
7
16
|
import {
|
|
8
17
|
BaseUAObject,
|
|
9
18
|
buildStructuredType,
|
|
10
19
|
check_options_correctness_against_schema,
|
|
11
|
-
DecodeDebugOptions,
|
|
20
|
+
type DecodeDebugOptions,
|
|
12
21
|
FieldCategory,
|
|
13
|
-
|
|
14
|
-
IStructuredTypeSchema,
|
|
22
|
+
type IStructuredTypeSchema,
|
|
15
23
|
parameters,
|
|
16
24
|
registerSpecialVariantEncoder,
|
|
17
25
|
} from "node-opcua-factory";
|
|
18
26
|
|
|
27
|
+
/**
|
|
28
|
+
*
|
|
29
|
+
* @param value
|
|
30
|
+
* @returns
|
|
31
|
+
*/
|
|
19
32
|
export function coerceLocalizedText(value?: null | string | LocalizedTextOptions): LocalizedText | null {
|
|
20
33
|
if (value === undefined || value === null) {
|
|
21
34
|
return null;
|
|
@@ -25,6 +38,13 @@ export function coerceLocalizedText(value?: null | string | LocalizedTextOptions
|
|
|
25
38
|
}
|
|
26
39
|
return new LocalizedText(value);
|
|
27
40
|
}
|
|
41
|
+
export function coerceLocalizedTextStrict(value?: null | string | LocalizedTextOptions): LocalizedText {
|
|
42
|
+
let result = coerceLocalizedText(value);
|
|
43
|
+
if (!result) {
|
|
44
|
+
result = new LocalizedText({ locale: null, text: null });
|
|
45
|
+
}
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
28
48
|
|
|
29
49
|
// --------------------------------------------------------------------------------------------
|
|
30
50
|
// see Part 3 - $8.5 page 63
|
|
@@ -95,7 +115,7 @@ export class LocalizedText extends BaseUAObject {
|
|
|
95
115
|
}
|
|
96
116
|
|
|
97
117
|
public toString(): string {
|
|
98
|
-
return
|
|
118
|
+
return `locale=${this.locale} text=${this.text}`;
|
|
99
119
|
}
|
|
100
120
|
|
|
101
121
|
// OPCUA Part 6 $ 5.2.2.14 : localizedText have a special encoding
|
|
@@ -114,13 +134,13 @@ export class LocalizedText extends BaseUAObject {
|
|
|
114
134
|
}
|
|
115
135
|
|
|
116
136
|
public decodeDebug(stream: BinaryStream, options: DecodeDebugOptions): void {
|
|
117
|
-
let cursorBefore;
|
|
137
|
+
let cursorBefore: number= 0;
|
|
118
138
|
const tracer = options.tracer;
|
|
119
|
-
tracer.trace("start", options.name
|
|
139
|
+
tracer.trace("start", `${options.name}(LocalizedText)`, stream.length, stream.length);
|
|
120
140
|
cursorBefore = stream.length;
|
|
121
141
|
|
|
122
142
|
const encodingMask = decodeByte(stream);
|
|
123
|
-
tracer.trace("member", "encodingByte",
|
|
143
|
+
tracer.trace("member", "encodingByte", `0x${encodingMask.toString(16)}`, cursorBefore, stream.length, "Mask");
|
|
124
144
|
cursorBefore = stream.length;
|
|
125
145
|
|
|
126
146
|
if ((encodingMask & 0x01) === 0x01) {
|