@ifc-lite/encoding 1.15.1 → 2.0.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/README.md +1 -1
- package/dist/ifc-string.d.ts +6 -0
- package/dist/ifc-string.d.ts.map +1 -1
- package/dist/ifc-string.js +14 -0
- package/dist/ifc-string.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/property-value.d.ts +15 -1
- package/dist/property-value.d.ts.map +1 -1
- package/dist/property-value.js +19 -6
- package/dist/property-value.js.map +1 -1
- package/dist/step-string-literal.d.ts +9 -0
- package/dist/step-string-literal.d.ts.map +1 -0
- package/dist/step-string-literal.js +101 -0
- package/dist/step-string-literal.js.map +1 -0
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -34,7 +34,7 @@ parsePropertyValue(['IFCBOOLEAN', '.T.']); // { displayValue: 'True', ifcType: .
|
|
|
34
34
|
- `generateIfcGuid`, `generateUuid`: new identifiers
|
|
35
35
|
- `uuidToIfcGuid`, `ifcGuidToUuid`: convert between UUIDs and 22-char IFC GUIDs
|
|
36
36
|
- `isValidIfcGuid`, `isValidUuid`: validation
|
|
37
|
-
- `parsePropertyValue`: turn
|
|
37
|
+
- `parsePropertyValue`: turn a parsed STEP property value (typed arrays, `.T.`/`.F.`, enums) into a display string plus optional IFC type name. It does **not** decode `\X2\`-style escapes: every ifc-lite parse path already decodes exactly once, at the parse boundary, and decoding a second time would collapse an authored `\\` a second time. Pass a still-encoded literal through `decodeIfcString` first.
|
|
38
38
|
|
|
39
39
|
## Links
|
|
40
40
|
|
package/dist/ifc-string.d.ts
CHANGED
|
@@ -6,6 +6,12 @@
|
|
|
6
6
|
* - \X\XX\ - ISO-8859-1 hex encoding
|
|
7
7
|
* - \S\X - Extended ASCII with escape
|
|
8
8
|
* - \P..\ - Code page switches (supported as directives and removed)
|
|
9
|
+
* - \\ - one literal backslash (ISO 10303-21 doubles the reverse solidus)
|
|
10
|
+
*
|
|
11
|
+
* The \\ pair is collapsed AFTER the directive arms: a directive immediately
|
|
12
|
+
* followed by an escaped backslash ends in three backslashes
|
|
13
|
+
* (`\X2\00FC\X0\` + `\\`), so collapsing pairs in a pre-pass would eat the
|
|
14
|
+
* directive's own terminator and leave an unterminated `\X2\`.
|
|
9
15
|
*
|
|
10
16
|
* This handles only backslash escapes. The '' doubled-quote escape is collapsed
|
|
11
17
|
* by the STEP tokenizer's consumers (they strip surrounding quotes and
|
package/dist/ifc-string.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ifc-string.d.ts","sourceRoot":"","sources":["../src/ifc-string.ts"],"names":[],"mappings":"AAIA
|
|
1
|
+
{"version":3,"file":"ifc-string.d.ts","sourceRoot":"","sources":["../src/ifc-string.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAkHnD;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CA6BnD"}
|
package/dist/ifc-string.js
CHANGED
|
@@ -9,6 +9,12 @@
|
|
|
9
9
|
* - \X\XX\ - ISO-8859-1 hex encoding
|
|
10
10
|
* - \S\X - Extended ASCII with escape
|
|
11
11
|
* - \P..\ - Code page switches (supported as directives and removed)
|
|
12
|
+
* - \\ - one literal backslash (ISO 10303-21 doubles the reverse solidus)
|
|
13
|
+
*
|
|
14
|
+
* The \\ pair is collapsed AFTER the directive arms: a directive immediately
|
|
15
|
+
* followed by an escaped backslash ends in three backslashes
|
|
16
|
+
* (`\X2\00FC\X0\` + `\\`), so collapsing pairs in a pre-pass would eat the
|
|
17
|
+
* directive's own terminator and leave an unterminated `\X2\`.
|
|
12
18
|
*
|
|
13
19
|
* This handles only backslash escapes. The '' doubled-quote escape is collapsed
|
|
14
20
|
* by the STEP tokenizer's consumers (they strip surrounding quotes and
|
|
@@ -108,6 +114,14 @@ export function decodeIfcString(str) {
|
|
|
108
114
|
}
|
|
109
115
|
}
|
|
110
116
|
}
|
|
117
|
+
// Handle \\ - one literal backslash. Checked after the directive arms so a
|
|
118
|
+
// `\X0\`/`\X\` terminator adjacent to an escaped backslash is consumed by
|
|
119
|
+
// its own directive first, never paired with the escape that follows it.
|
|
120
|
+
if (str[i + 1] === '\\') {
|
|
121
|
+
result += '\\';
|
|
122
|
+
i += 2;
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
111
125
|
// Unknown escape sequence: keep the backslash and move on.
|
|
112
126
|
result += str[i];
|
|
113
127
|
i += 1;
|
package/dist/ifc-string.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ifc-string.js","sourceRoot":"","sources":["../src/ifc-string.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D
|
|
1
|
+
{"version":3,"file":"ifc-string.js","sourceRoot":"","sources":["../src/ifc-string.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,eAAe,CAAC,GAAW;IACzC,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,GAAG,CAAC;IAEhD,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,IAAI,CAAC,GAAG,CAAC,CAAC;IAEV,OAAO,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC;QACtB,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;YACpB,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC;YACjB,CAAC,IAAI,CAAC,CAAC;YACP,SAAS;QACX,CAAC;QAED,sEAAsE;QACtE,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,CAA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AE,CAAC;YAC3E,SAAS;QACX,CAAC;QAED,IAAI,SAAS,IAAI,MAAM,EAAE,CAAC;YACxB,OAAO,IAAI,SAAS,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,QAAQ,CAAC;YAClF,SAAS;QACX,CAAC;QAED,OAAO,IAAI,SAAS,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,QAAQ,CAAC;IACpF,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { decodeIfcString, encodeIfcString } from './ifc-string.js';
|
|
2
|
+
export { decodeStepStringLiteral } from './step-string-literal.js';
|
|
2
3
|
export { uuidToIfcGuid, ifcGuidToUuid, generateIfcGuid, generateUuid, isValidIfcGuid, isValidUuid, } from './guid.js';
|
|
3
4
|
export type { RandomSource } from './guid.js';
|
|
4
5
|
export { parsePropertyValue } from './property-value.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EACL,aAAa,EACb,aAAa,EACb,eAAe,EACf,YAAY,EACZ,cAAc,EACd,WAAW,GACZ,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,YAAY,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EACL,aAAa,EACb,aAAa,EACb,eAAe,EACf,YAAY,EACZ,cAAc,EACd,WAAW,GACZ,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,YAAY,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
3
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
4
|
export { decodeIfcString, encodeIfcString } from './ifc-string.js';
|
|
5
|
+
export { decodeStepStringLiteral } from './step-string-literal.js';
|
|
5
6
|
export { uuidToIfcGuid, ifcGuidToUuid, generateIfcGuid, generateUuid, isValidIfcGuid, isValidUuid, } from './guid.js';
|
|
6
7
|
export { parsePropertyValue } from './property-value.js';
|
|
7
8
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EACL,aAAa,EACb,aAAa,EACb,eAAe,EACf,YAAY,EACZ,cAAc,EACd,WAAW,GACZ,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EACL,aAAa,EACb,aAAa,EACb,eAAe,EACf,YAAY,EACZ,cAAc,EACd,WAAW,GACZ,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/property-value.d.ts
CHANGED
|
@@ -11,9 +11,23 @@ export interface ParsedPropertyValue {
|
|
|
11
11
|
* Handles:
|
|
12
12
|
* - TypedValues like [IFCIDENTIFIER, '100 x 150mm'] -> display '100 x 150mm', tooltip 'Identifier'
|
|
13
13
|
* - Boolean enums like '.T.' -> 'True'
|
|
14
|
-
* - IFC encoded strings with \X2\, \X\ escape sequences
|
|
15
14
|
* - Null/undefined -> '\u2014'
|
|
16
15
|
* - Regular values -> string conversion
|
|
16
|
+
*
|
|
17
|
+
* It deliberately does NOT decode STEP escapes. Every producer of a property
|
|
18
|
+
* value decodes exactly once, at parse time: the TypeScript path via
|
|
19
|
+
* `EntityExtractor.parseAttributeValue` / `columnar-parser-attributes.ts`, the
|
|
20
|
+
* Rust/WASM and server paths via `AttributeValue::from_token`. The input here
|
|
21
|
+
* is therefore already literal text, and decoding a second time is not a no-op
|
|
22
|
+
* \u2014 since #2394 `decodeIfcString` collapses `\\` to `\`, so an authored UNC
|
|
23
|
+
* path `\\server\share` would render as `\server\share`. `C:\temp` is a fixed
|
|
24
|
+
* point of the decoder, which is why the defect hides on the common case.
|
|
25
|
+
*
|
|
26
|
+
* Making the decoder idempotent instead would not work: idempotence requires
|
|
27
|
+
* treating an already-decoded `\` and an authored, still-doubled `\\` the same
|
|
28
|
+
* way, which is exactly the ambiguity the one-decode rule removes. The
|
|
29
|
+
* invariant to hold is "decode once, at the parse boundary", not "decode
|
|
30
|
+
* defensively wherever a string is displayed".
|
|
17
31
|
*/
|
|
18
32
|
export declare function parsePropertyValue(value: unknown): ParsedPropertyValue;
|
|
19
33
|
//# sourceMappingURL=property-value.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"property-value.d.ts","sourceRoot":"","sources":["../src/property-value.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"property-value.d.ts","sourceRoot":"","sources":["../src/property-value.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAuCD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,mBAAmB,CAqEtE"}
|
package/dist/property-value.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
2
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
3
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
|
-
import { decodeIfcString } from './ifc-string.js';
|
|
5
4
|
/**
|
|
6
5
|
* Map of IFC boolean enumeration values to human-readable text
|
|
7
6
|
*/
|
|
@@ -42,9 +41,23 @@ const IFC_TYPE_DISPLAY_NAMES = {
|
|
|
42
41
|
* Handles:
|
|
43
42
|
* - TypedValues like [IFCIDENTIFIER, '100 x 150mm'] -> display '100 x 150mm', tooltip 'Identifier'
|
|
44
43
|
* - Boolean enums like '.T.' -> 'True'
|
|
45
|
-
* - IFC encoded strings with \X2\, \X\ escape sequences
|
|
46
44
|
* - Null/undefined -> '\u2014'
|
|
47
45
|
* - Regular values -> string conversion
|
|
46
|
+
*
|
|
47
|
+
* It deliberately does NOT decode STEP escapes. Every producer of a property
|
|
48
|
+
* value decodes exactly once, at parse time: the TypeScript path via
|
|
49
|
+
* `EntityExtractor.parseAttributeValue` / `columnar-parser-attributes.ts`, the
|
|
50
|
+
* Rust/WASM and server paths via `AttributeValue::from_token`. The input here
|
|
51
|
+
* is therefore already literal text, and decoding a second time is not a no-op
|
|
52
|
+
* \u2014 since #2394 `decodeIfcString` collapses `\\` to `\`, so an authored UNC
|
|
53
|
+
* path `\\server\share` would render as `\server\share`. `C:\temp` is a fixed
|
|
54
|
+
* point of the decoder, which is why the defect hides on the common case.
|
|
55
|
+
*
|
|
56
|
+
* Making the decoder idempotent instead would not work: idempotence requires
|
|
57
|
+
* treating an already-decoded `\` and an authored, still-doubled `\\` the same
|
|
58
|
+
* way, which is exactly the ambiguity the one-decode rule removes. The
|
|
59
|
+
* invariant to hold is "decode once, at the parse boundary", not "decode
|
|
60
|
+
* defensively wherever a string is displayed".
|
|
48
61
|
*/
|
|
49
62
|
export function parsePropertyValue(value) {
|
|
50
63
|
// Handle null/undefined
|
|
@@ -85,11 +98,11 @@ export function parsePropertyValue(value) {
|
|
|
85
98
|
if (BOOLEAN_MAP[upperInner]) {
|
|
86
99
|
return { displayValue: BOOLEAN_MAP[upperInner], ifcType: friendlyType };
|
|
87
100
|
}
|
|
88
|
-
//
|
|
89
|
-
return { displayValue:
|
|
101
|
+
// Already decoded by the parse path (see the note on this function).
|
|
102
|
+
return { displayValue: innerValue, ifcType: friendlyType };
|
|
90
103
|
}
|
|
91
|
-
//
|
|
92
|
-
return { displayValue:
|
|
104
|
+
// Already decoded by the parse path (see the note on this function).
|
|
105
|
+
return { displayValue: value };
|
|
93
106
|
}
|
|
94
107
|
// Handle native booleans
|
|
95
108
|
if (typeof value === 'boolean') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"property-value.js","sourceRoot":"","sources":["../src/property-value.ts"],"names":[],"mappings":"AAAA;;+DAE+D;
|
|
1
|
+
{"version":3,"file":"property-value.js","sourceRoot":"","sources":["../src/property-value.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAW/D;;GAEG;AACH,MAAM,WAAW,GAA2B;IAC1C,KAAK,EAAE,MAAM;IACb,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,SAAS;CACjB,CAAC;AAE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YAED,qEAAqE;YACrE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;QAC7D,CAAC;QAED,qEAAqE;QACrE,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;IACjC,CAAC;IAED,yBAAyB;IACzB,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;QAC/B,OAAO,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;IACxE,CAAC;IAED,iBAAiB;IACjB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC;YACvC,CAAC,CAAC,KAAK,CAAC,cAAc,EAAE;YACxB,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,SAAS,EAAE,EAAE,qBAAqB,EAAE,CAAC,EAAE,CAAC,CAAC;QAClE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,CAAC;IACrC,CAAC;IAED,2BAA2B;IAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decode the inner text of a STEP string literal (outer `'…'` already
|
|
3
|
+
* stripped) to its Unicode value.
|
|
4
|
+
*
|
|
5
|
+
* @param inner the literal's contents, still carrying `''` / `\\` doublings and
|
|
6
|
+
* any backslash directives.
|
|
7
|
+
*/
|
|
8
|
+
export declare function decodeStepStringLiteral(inner: string): string;
|
|
9
|
+
//# sourceMappingURL=step-string-literal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-string-literal.d.ts","sourceRoot":"","sources":["../src/step-string-literal.ts"],"names":[],"mappings":"AAoDA;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAwC7D"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
|
+
/**
|
|
5
|
+
* The one decoder for the INNER TEXT of an ISO 10303-21 string literal.
|
|
6
|
+
*
|
|
7
|
+
* A STEP string literal carries two independent escape layers, and a reader
|
|
8
|
+
* that resolves only one of them is wrong on real files:
|
|
9
|
+
*
|
|
10
|
+
* 1. the two lexical DOUBLINGS, `''` for a quote and `\\` for a reverse
|
|
11
|
+
* solidus, which the tokenizer's consumers strip along with the outer
|
|
12
|
+
* quotes;
|
|
13
|
+
* 2. the backslash DIRECTIVES — `\X2\HHHH\X0\`, `\X4\…\X0\`, `\X\HH`, `\S\x`,
|
|
14
|
+
* `\Px\` — which carry every non-ASCII character an IFC file may hold, and
|
|
15
|
+
* which {@link decodeIfcString} resolves.
|
|
16
|
+
*
|
|
17
|
+
* Hand-rolled `\\`->`\` regexes have been written twice in this repo and were
|
|
18
|
+
* wrong the same way both times: they leave a directive untouched, so
|
|
19
|
+
* `\X2\00FC\X0\` reads back as the literal nine characters instead of `ü`
|
|
20
|
+
* (`packages/parser/src/source-header.ts` in #2486, `parseStepValue` in
|
|
21
|
+
* `@ifc-lite/data` in #2490). Hence one exported implementation rather than a
|
|
22
|
+
* doc comment asking the next reader to be careful.
|
|
23
|
+
*
|
|
24
|
+
* ## Why the two layers cannot be resolved by two independent passes
|
|
25
|
+
*
|
|
26
|
+
* A naive split at every doubled backslash consumes a DIRECTIVE'S closing
|
|
27
|
+
* backslash whenever the directive is immediately followed by an escaped
|
|
28
|
+
* backslash: `\X2\00FC\X0\` + `\\` ends in three backslashes and the split eats
|
|
29
|
+
* the first two, leaving an unterminated `\X2\` that never decodes. So this
|
|
30
|
+
* scans left to right and gives directives precedence — each whole directive
|
|
31
|
+
* span moves into the pending segment atomically, `\\` is a literal backslash
|
|
32
|
+
* only OUTSIDE a span, and the segments are handed to {@link decodeIfcString}
|
|
33
|
+
* untouched.
|
|
34
|
+
*
|
|
35
|
+
* Giving directives precedence is also what keeps ESCAPED directive text
|
|
36
|
+
* literal: `\\X2\\00FC\\X0\\` means the characters `\X2\00FC\X0\` and must not
|
|
37
|
+
* decode to `ü`. The scan sees `\\` first at every step there, so it never
|
|
38
|
+
* forms a directive span.
|
|
39
|
+
*
|
|
40
|
+
* ## The writer's half of the contract
|
|
41
|
+
*
|
|
42
|
+
* {@link decodeIfcString} deliberately PRESERVES an unknown escape (it cannot
|
|
43
|
+
* collapse `\\` itself without ambiguity), which is why the pair handling lives
|
|
44
|
+
* here. A writer paired with this reader may either emit non-ASCII raw (UTF-8,
|
|
45
|
+
* no backslashes to double) or emit `\X2\` directives — both round-trip — but
|
|
46
|
+
* it must double a literal reverse solidus, or this reader will read one as the
|
|
47
|
+
* start of a directive.
|
|
48
|
+
*/
|
|
49
|
+
import { decodeIfcString } from './ifc-string.js';
|
|
50
|
+
/**
|
|
51
|
+
* Decode the inner text of a STEP string literal (outer `'…'` already
|
|
52
|
+
* stripped) to its Unicode value.
|
|
53
|
+
*
|
|
54
|
+
* @param inner the literal's contents, still carrying `''` / `\\` doublings and
|
|
55
|
+
* any backslash directives.
|
|
56
|
+
*/
|
|
57
|
+
export function decodeStepStringLiteral(inner) {
|
|
58
|
+
const value = inner.replace(/''/g, "'");
|
|
59
|
+
let out = '';
|
|
60
|
+
let seg = ''; // pending directive-bearing text, flushed through decodeIfcString
|
|
61
|
+
let i = 0;
|
|
62
|
+
while (i < value.length) {
|
|
63
|
+
if (value[i] === '\\') {
|
|
64
|
+
// Whole directive spans move into `seg` atomically so their own
|
|
65
|
+
// backslashes (terminators, \S\ operands) never match the pair escape.
|
|
66
|
+
if (value.startsWith('\\X2\\', i) || value.startsWith('\\X4\\', i)) {
|
|
67
|
+
const end = value.indexOf('\\X0\\', i + 4);
|
|
68
|
+
if (end !== -1) {
|
|
69
|
+
seg += value.slice(i, end + 4);
|
|
70
|
+
i = end + 4;
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
else if (value.startsWith('\\S\\', i) && i + 3 < value.length) {
|
|
75
|
+
seg += value.slice(i, i + 4); // \S\ + operand char (may itself be '\')
|
|
76
|
+
i += 4;
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
else if (value.startsWith('\\X\\', i)) {
|
|
80
|
+
seg += value.slice(i, i + 5); // \X\ + two hex digits
|
|
81
|
+
i += 5;
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
else if (/^\\P[A-Z]\\/.test(value.slice(i, i + 4))) {
|
|
85
|
+
seg += value.slice(i, i + 4);
|
|
86
|
+
i += 4;
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
if (value[i + 1] === '\\') {
|
|
90
|
+
out += decodeIfcString(seg) + '\\';
|
|
91
|
+
seg = '';
|
|
92
|
+
i += 2;
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
seg += value[i];
|
|
97
|
+
i += 1;
|
|
98
|
+
}
|
|
99
|
+
return out + decodeIfcString(seg);
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=step-string-literal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-string-literal.js","sourceRoot":"","sources":["../src/step-string-literal.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CAAC,KAAa;IACnD,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACxC,IAA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AAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;gBACrD,GAAG,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;gBAC7B,CAAC,IAAI,CAAC,CAAC;gBACP,SAAS;YACX,CAAC;YACD,IAAI,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;gBAC1B,GAAG,IAAI,eAAe,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;gBACnC,GAAG,GAAG,EAAE,CAAC;gBACT,CAAC,IAAI,CAAC,CAAC;gBACP,SAAS;YACX,CAAC;QACH,CAAC;QACD,GAAG,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC;QAChB,CAAC,IAAI,CAAC,CAAC;IACT,CAAC;IACD,OAAO,GAAG,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC;AACpC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ifc-lite/encoding",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "IFC string encoding/decoding and property value parsing for IFC-Lite",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
],
|
|
42
42
|
"scripts": {
|
|
43
43
|
"build": "pnpm exec tsc",
|
|
44
|
+
"typecheck": "node ../../scripts/typecheck-tests.mjs",
|
|
44
45
|
"dev": "pnpm exec tsc --watch",
|
|
45
46
|
"test": "vitest run"
|
|
46
47
|
}
|