@ifc-lite/encoding 2.3.0 → 2.4.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/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/step-string-end.d.ts +23 -0
- package/dist/step-string-end.d.ts.map +1 -0
- package/dist/step-string-end.js +40 -0
- package/dist/step-string-end.js.map +1 -0
- package/dist/step-top-level-split.d.ts +15 -0
- package/dist/step-top-level-split.d.ts.map +1 -0
- package/dist/step-top-level-split.js +50 -0
- package/dist/step-top-level-split.js.map +1 -0
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { decodeIfcString, encodeIfcString } from './ifc-string.js';
|
|
2
2
|
export { decodeStepStringLiteral } from './step-string-literal.js';
|
|
3
|
+
export { isStepPageQuoteOperand, stepStringLiteralEnd } from './step-string-end.js';
|
|
4
|
+
export { splitStepTopLevel } from './step-top-level-split.js';
|
|
3
5
|
export { uuidToIfcGuid, ifcGuidToUuid, generateIfcGuid, generateUuid, isValidIfcGuid, isValidUuid, } from './guid.js';
|
|
4
6
|
export type { RandomSource } from './guid.js';
|
|
5
7
|
export { uuidFromSeed } from './deterministic-uuid.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,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,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,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,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACpF,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,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,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,YAAY,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
4
|
export { decodeIfcString, encodeIfcString } from './ifc-string.js';
|
|
5
5
|
export { decodeStepStringLiteral } from './step-string-literal.js';
|
|
6
|
+
export { isStepPageQuoteOperand, stepStringLiteralEnd } from './step-string-end.js';
|
|
7
|
+
export { splitStepTopLevel } from './step-top-level-split.js';
|
|
6
8
|
export { uuidToIfcGuid, ifcGuidToUuid, generateIfcGuid, generateUuid, isValidIfcGuid, isValidUuid, } from './guid.js';
|
|
7
9
|
export { uuidFromSeed } from './deterministic-uuid.js';
|
|
8
10
|
export { uuidV5 } from './uuid-v5.js';
|
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,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,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,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,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACpF,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EACL,aAAa,EACb,aAAa,EACb,eAAe,EACf,YAAY,EACZ,cAAc,EACd,WAAW,GACZ,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where an ISO 10303-21 string literal ends, for every walker that splits,
|
|
3
|
+
* rewrites or scans STEP text (#7589).
|
|
4
|
+
*
|
|
5
|
+
* Inside a literal, `''` is an escaped quote and the PAGE directive `\S\` takes
|
|
6
|
+
* the next character as its operand, which may itself be an apostrophe:
|
|
7
|
+
* `'Para \S\' 5'` is one literal reading "Para § 5". The entity scanners learnt
|
|
8
|
+
* that in #7540; a walker that ends the literal at the operand misreads every
|
|
9
|
+
* later comma, paren and reference in the record. The PAGE test comes first,
|
|
10
|
+
* because `'5\S\''` is "5§" and closes at its last quote, and no other legal
|
|
11
|
+
* string unit can end in `\S\` right before a quote, so the lookback cannot
|
|
12
|
+
* misfire on a legal file. The byte-level twin is `isPageQuoteOperand` in
|
|
13
|
+
* `@ifc-lite/parser` (`step-lexing.ts`); the Rust one is
|
|
14
|
+
* `ifc_lite_core::step_encoding::step_string_literal_end`.
|
|
15
|
+
*/
|
|
16
|
+
/** Whether the apostrophe at `pos` (inside a literal) is a `\S\` operand. */
|
|
17
|
+
export declare function isStepPageQuoteOperand(text: string, pos: number): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Index just past the apostrophe closing the literal whose opening apostrophe
|
|
20
|
+
* is at `open`, or `-1` when it never closes.
|
|
21
|
+
*/
|
|
22
|
+
export declare function stepStringLiteralEnd(text: string, open: number): number;
|
|
23
|
+
//# sourceMappingURL=step-string-end.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-string-end.d.ts","sourceRoot":"","sources":["../src/step-string-end.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;GAcG;AAEH,6EAA6E;AAC7E,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAGzE;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAOvE"}
|
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
* Where an ISO 10303-21 string literal ends, for every walker that splits,
|
|
6
|
+
* rewrites or scans STEP text (#7589).
|
|
7
|
+
*
|
|
8
|
+
* Inside a literal, `''` is an escaped quote and the PAGE directive `\S\` takes
|
|
9
|
+
* the next character as its operand, which may itself be an apostrophe:
|
|
10
|
+
* `'Para \S\' 5'` is one literal reading "Para § 5". The entity scanners learnt
|
|
11
|
+
* that in #7540; a walker that ends the literal at the operand misreads every
|
|
12
|
+
* later comma, paren and reference in the record. The PAGE test comes first,
|
|
13
|
+
* because `'5\S\''` is "5§" and closes at its last quote, and no other legal
|
|
14
|
+
* string unit can end in `\S\` right before a quote, so the lookback cannot
|
|
15
|
+
* misfire on a legal file. The byte-level twin is `isPageQuoteOperand` in
|
|
16
|
+
* `@ifc-lite/parser` (`step-lexing.ts`); the Rust one is
|
|
17
|
+
* `ifc_lite_core::step_encoding::step_string_literal_end`.
|
|
18
|
+
*/
|
|
19
|
+
/** Whether the apostrophe at `pos` (inside a literal) is a `\S\` operand. */
|
|
20
|
+
export function isStepPageQuoteOperand(text, pos) {
|
|
21
|
+
return pos >= 3 && text.charCodeAt(pos - 1) === 0x5c && text.charCodeAt(pos - 2) === 0x53
|
|
22
|
+
&& text.charCodeAt(pos - 3) === 0x5c;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Index just past the apostrophe closing the literal whose opening apostrophe
|
|
26
|
+
* is at `open`, or `-1` when it never closes.
|
|
27
|
+
*/
|
|
28
|
+
export function stepStringLiteralEnd(text, open) {
|
|
29
|
+
for (let p = text.indexOf("'", open + 1); p >= 0; p = text.indexOf("'", p + 1)) {
|
|
30
|
+
if (isStepPageQuoteOperand(text, p))
|
|
31
|
+
continue;
|
|
32
|
+
if (text.charCodeAt(p + 1) === 0x27) {
|
|
33
|
+
p++;
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
return p + 1;
|
|
37
|
+
}
|
|
38
|
+
return -1;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=step-string-end.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-string-end.js","sourceRoot":"","sources":["../src/step-string-end.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D;;;;;;;;;;;;;;GAcG;AAEH,6EAA6E;AAC7E,MAAM,UAAU,sBAAsB,CAAC,IAAY,EAAE,GAAW;IAC9D,OAAO,GAAG,IAAI,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,GAAG,CAAC,CAAC,KAAK,IAAI,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,GAAG,CAAC,CAAC,KAAK,IAAI;WACpF,IAAI,CAAC,UAAU,CAAC,GAAG,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC;AACzC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAAY,EAAE,IAAY;IAC7D,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,GAAG,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;QAC/E,IAAI,sBAAsB,CAAC,IAAI,EAAE,CAAC,CAAC;YAAE,SAAS;QAC9C,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;YAAC,CAAC,EAAE,CAAC;YAAC,SAAS;QAAC,CAAC;QACvD,OAAO,CAAC,GAAG,CAAC,CAAC;IACf,CAAC;IACD,OAAO,CAAC,CAAC,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Split STEP parameter text at commas that are not inside parentheses or
|
|
3
|
+
* brackets, a string literal, or a `/* ... *\/` comment (#7785).
|
|
4
|
+
*
|
|
5
|
+
* The one TS splitter for text that is not a whole record. A literal ends by
|
|
6
|
+
* `stepStringLiteralEnd` (`''` and a `\S\'` PAGE operand stay inside, #7589),
|
|
7
|
+
* and a comment is skipped atomically, so a `,`, `(`, `)` or `'` in either is
|
|
8
|
+
* not structure. An unterminated literal or comment runs to the end of the
|
|
9
|
+
* text. Each comment collapses to one space so the tokens around it are not
|
|
10
|
+
* spliced (`5/* c *\/6` is not `56`). Items are trimmed; the last item is
|
|
11
|
+
* always returned, even when empty (callers decide whether a trailing empty
|
|
12
|
+
* item is a value).
|
|
13
|
+
*/
|
|
14
|
+
export declare function splitStepTopLevel(text: string): string[];
|
|
15
|
+
//# sourceMappingURL=step-top-level-split.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-top-level-split.d.ts","sourceRoot":"","sources":["../src/step-top-level-split.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CA0BxD"}
|
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
import { stepStringLiteralEnd } from './step-string-end.js';
|
|
5
|
+
/**
|
|
6
|
+
* Split STEP parameter text at commas that are not inside parentheses or
|
|
7
|
+
* brackets, a string literal, or a `/* ... *\/` comment (#7785).
|
|
8
|
+
*
|
|
9
|
+
* The one TS splitter for text that is not a whole record. A literal ends by
|
|
10
|
+
* `stepStringLiteralEnd` (`''` and a `\S\'` PAGE operand stay inside, #7589),
|
|
11
|
+
* and a comment is skipped atomically, so a `,`, `(`, `)` or `'` in either is
|
|
12
|
+
* not structure. An unterminated literal or comment runs to the end of the
|
|
13
|
+
* text. Each comment collapses to one space so the tokens around it are not
|
|
14
|
+
* spliced (`5/* c *\/6` is not `56`). Items are trimmed; the last item is
|
|
15
|
+
* always returned, even when empty (callers decide whether a trailing empty
|
|
16
|
+
* item is a value).
|
|
17
|
+
*/
|
|
18
|
+
export function splitStepTopLevel(text) {
|
|
19
|
+
const items = [];
|
|
20
|
+
let depth = 0;
|
|
21
|
+
let current = '';
|
|
22
|
+
for (let i = 0; i < text.length; i++) {
|
|
23
|
+
const ch = text[i];
|
|
24
|
+
if (ch === "'") {
|
|
25
|
+
const close = stepStringLiteralEnd(text, i);
|
|
26
|
+
const stop = close < 0 ? text.length : close;
|
|
27
|
+
current += text.slice(i, stop);
|
|
28
|
+
i = stop - 1;
|
|
29
|
+
}
|
|
30
|
+
else if (ch === '/' && text[i + 1] === '*') {
|
|
31
|
+
const close = text.indexOf('*/', i + 2);
|
|
32
|
+
current += ' ';
|
|
33
|
+
i = (close < 0 ? text.length : close + 2) - 1;
|
|
34
|
+
}
|
|
35
|
+
else if (ch === ',' && depth === 0) {
|
|
36
|
+
items.push(current.trim());
|
|
37
|
+
current = '';
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
if (ch === '(' || ch === '[')
|
|
41
|
+
depth++;
|
|
42
|
+
else if (ch === ')' || ch === ']')
|
|
43
|
+
depth--;
|
|
44
|
+
current += ch;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
items.push(current.trim());
|
|
48
|
+
return items;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=step-top-level-split.js.map
|
|
@@ -0,0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AAG,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;YACrC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;YAC3B,OAAO,GAAG,EAAE,CAAC;QACf,CAAC;aAAM,CAAC;YACN,IAAI,EAAE,KAAK,GAAG,IAAI,EAAE,KAAK,GAAG;gBAAE,KAAK,EAAE,CAAC;iBACjC,IAAI,EAAE,KAAK,GAAG,IAAI,EAAE,KAAK,GAAG;gBAAE,KAAK,EAAE,CAAC;YAC3C,OAAO,IAAI,EAAE,CAAC;QAChB,CAAC;IACH,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;IAC3B,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ifc-lite/encoding",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.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",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"typescript": "^6.0.3",
|
|
17
|
-
"vitest": "^5.0.
|
|
17
|
+
"vitest": "^5.0.3",
|
|
18
18
|
"@ifc-lite/timing-ladder": "^0.1.0"
|
|
19
19
|
},
|
|
20
20
|
"license": "MPL-2.0",
|