@ifc-lite/encoding 1.14.7 → 1.14.9
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 +46 -0
- package/dist/ifc-string.d.ts +4 -0
- package/dist/ifc-string.d.ts.map +1 -1
- package/dist/ifc-string.js +11 -3
- package/dist/ifc-string.js.map +1 -1
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# @ifc-lite/encoding
|
|
2
|
+
|
|
3
|
+
IFC string encoding and decoding, GlobalId (GUID) utilities, and property value parsing. Small, dependency-free helpers for the text-level details of IFC STEP files: the `\X2\...\X0\` escape sequences used for non-ASCII characters, the 22-character base64-like IFC GUID format, and typed STEP property values like `IFCBOOLEAN(.T.)`.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @ifc-lite/encoding
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import {
|
|
15
|
+
decodeIfcString,
|
|
16
|
+
encodeIfcString,
|
|
17
|
+
generateIfcGuid,
|
|
18
|
+
ifcGuidToUuid,
|
|
19
|
+
parsePropertyValue,
|
|
20
|
+
} from '@ifc-lite/encoding';
|
|
21
|
+
|
|
22
|
+
decodeIfcString('Gew\\X2\\00E4\\X0\\chshaus'); // 'Gewächshaus' (real umlaut)
|
|
23
|
+
encodeIfcString('Tür'); // 'T\\X\\FCr'
|
|
24
|
+
|
|
25
|
+
const guid = generateIfcGuid(); // 22-char IFC GlobalId
|
|
26
|
+
const uuid = ifcGuidToUuid(guid); // standard UUID form
|
|
27
|
+
|
|
28
|
+
parsePropertyValue(['IFCBOOLEAN', '.T.']); // { displayValue: 'True', ifcType: ... }
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Exports
|
|
32
|
+
|
|
33
|
+
- `decodeIfcString` / `encodeIfcString`: STEP `\X2\`, `\X\`, `\S\` escape handling
|
|
34
|
+
- `generateIfcGuid`, `generateUuid`: new identifiers
|
|
35
|
+
- `uuidToIfcGuid`, `ifcGuidToUuid`: convert between UUIDs and 22-char IFC GUIDs
|
|
36
|
+
- `isValidIfcGuid`, `isValidUuid`: validation
|
|
37
|
+
- `parsePropertyValue`: turn raw STEP property values (typed arrays, `.T.`/`.F.`, enums) into a display string plus optional IFC type name
|
|
38
|
+
|
|
39
|
+
## Links
|
|
40
|
+
|
|
41
|
+
- Docs: https://ltplus-ag.github.io/ifc-lite/
|
|
42
|
+
- Source: https://github.com/LTplus-AG/ifc-lite
|
|
43
|
+
|
|
44
|
+
## License
|
|
45
|
+
|
|
46
|
+
MPL-2.0
|
package/dist/ifc-string.d.ts
CHANGED
|
@@ -6,6 +6,10 @@
|
|
|
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
|
+
*
|
|
10
|
+
* This handles only backslash escapes. The '' doubled-quote escape is collapsed
|
|
11
|
+
* by the STEP tokenizer's consumers (they strip surrounding quotes and
|
|
12
|
+
* un-double), so decoding must not touch quotes or it would double-collapse.
|
|
9
13
|
*/
|
|
10
14
|
export declare function decodeIfcString(str: string): string;
|
|
11
15
|
/**
|
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;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CA4EnD;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CA6BnD"}
|
package/dist/ifc-string.js
CHANGED
|
@@ -9,6 +9,10 @@
|
|
|
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
|
+
*
|
|
13
|
+
* This handles only backslash escapes. The '' doubled-quote escape is collapsed
|
|
14
|
+
* by the STEP tokenizer's consumers (they strip surrounding quotes and
|
|
15
|
+
* un-double), so decoding must not touch quotes or it would double-collapse.
|
|
12
16
|
*/
|
|
13
17
|
export function decodeIfcString(str) {
|
|
14
18
|
if (!str || typeof str !== 'string')
|
|
@@ -26,10 +30,14 @@ export function decodeIfcString(str) {
|
|
|
26
30
|
i += 4;
|
|
27
31
|
continue;
|
|
28
32
|
}
|
|
29
|
-
// Handle \S\X where
|
|
33
|
+
// Handle \S\X where the value is the code point of X plus 128. Read X as a
|
|
34
|
+
// whole code point (advancing past a surrogate pair) so a malformed
|
|
35
|
+
// multi-byte X stays in parity with the Rust decoder instead of leaving a
|
|
36
|
+
// dangling surrogate.
|
|
30
37
|
if (str[i + 1] === 'S' && str[i + 2] === '\\' && i + 3 < str.length) {
|
|
31
|
-
|
|
32
|
-
|
|
38
|
+
const cp = str.codePointAt(i + 3);
|
|
39
|
+
result += String.fromCodePoint(cp + 128);
|
|
40
|
+
i += 3 + (cp > 0xFFFF ? 2 : 1);
|
|
33
41
|
continue;
|
|
34
42
|
}
|
|
35
43
|
// Handle \X\HH (8-bit value from ISO 10646 row 0 / ISO-8859-1 overlap).
|
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;;;;;;;;;;;;GAYG;AACH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,SAAS,IAAI,EAAE,IAAI,SAAS,IAAI,GAAG,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC;YACvD,OAAO,IAAI,EAAE,CAAC;YACd,SAAS;QACX,CAAC;QAED,IAAI,SAAS,IAAI,IAAI,EAAE,CAAC;YACtB,OAAO,IAAI,QAAQ,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ifc-lite/encoding",
|
|
3
|
-
"version": "1.14.
|
|
3
|
+
"version": "1.14.9",
|
|
4
4
|
"description": "IFC string encoding/decoding and property value parsing for IFC-Lite",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"typescript": "^6.0.3",
|
|
17
|
-
"vitest": "^4.1.
|
|
17
|
+
"vitest": "^4.1.9"
|
|
18
18
|
},
|
|
19
19
|
"license": "MPL-2.0",
|
|
20
20
|
"author": "Louis True",
|