@ifc-lite/encoding 2.0.0 → 2.1.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 CHANGED
@@ -2,6 +2,7 @@ export { decodeIfcString, encodeIfcString } from './ifc-string.js';
2
2
  export { decodeStepStringLiteral } from './step-string-literal.js';
3
3
  export { uuidToIfcGuid, ifcGuidToUuid, generateIfcGuid, generateUuid, isValidIfcGuid, isValidUuid, } from './guid.js';
4
4
  export type { RandomSource } from './guid.js';
5
+ export { isWhollyNumeric } from './numeric-literal.js';
5
6
  export { parsePropertyValue } from './property-value.js';
6
7
  export type { ParsedPropertyValue } from './property-value.js';
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -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,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,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
@@ -4,5 +4,6 @@
4
4
  export { decodeIfcString, encodeIfcString } from './ifc-string.js';
5
5
  export { decodeStepStringLiteral } from './step-string-literal.js';
6
6
  export { uuidToIfcGuid, ifcGuidToUuid, generateIfcGuid, generateUuid, isValidIfcGuid, isValidUuid, } from './guid.js';
7
+ export { isWhollyNumeric } from './numeric-literal.js';
7
8
  export { parsePropertyValue } from './property-value.js';
8
9
  //# 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,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"}
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,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Whether `v` is WHOLLY a signed decimal number, optionally in exponent form:
3
+ * `-0.35`, `+1`, `-1.5e-3`, `-.5`, `-1.`. Anchored at BOTH ends, so `-0.35=cmd`
4
+ * is not one and `1,000` is not one either.
5
+ *
6
+ * Lives here, in a package with no dependencies, because three different
7
+ * callers need it and only two of them can afford `@ifc-lite/export`: the CSV
8
+ * formula guard (`packages/export/src/csv-cell.ts`) exempts a genuine number
9
+ * from the `+`/`-` trigger so a spreadsheet column still sums (#1772), and
10
+ * `@ifc-lite/lists` needs the same decision in its own CSV writer.
11
+ * `rust/export/src/csv_cell.rs::is_wholly_numeric` decides the same language on
12
+ * the other side of the language boundary; what holds those two together is the
13
+ * shared vector fixture, not a promise that they look alike.
14
+ *
15
+ * The regex this replaces — `/^[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/` —
16
+ * is QUADRATIC on a failing match: `\d+\.?\d*` retries at every split point
17
+ * before the engine gives up. This scan is linear, which is the whole reason it
18
+ * is spelled out by hand. (For scale, on `-` + 60k digits + one letter the
19
+ * regex took ~1.8s and the scan ~1ms; the ratio is the point, not the numbers.)
20
+ *
21
+ * Cell text comes from IFC properties, so the input is attacker-controllable and
22
+ * a leading `-` is exactly what reaches this check. `\d` is ASCII-only in JS, and
23
+ * this scan matches that deliberately: a full-width or Arabic-Indic digit is NOT
24
+ * a number here and stays guarded.
25
+ */
26
+ export declare function isWhollyNumeric(v: string): boolean;
27
+ //# sourceMappingURL=numeric-literal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"numeric-literal.d.ts","sourceRoot":"","sources":["../src/numeric-literal.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAyBlD"}
@@ -0,0 +1,65 @@
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
+ * Whether `v` is WHOLLY a signed decimal number, optionally in exponent form:
6
+ * `-0.35`, `+1`, `-1.5e-3`, `-.5`, `-1.`. Anchored at BOTH ends, so `-0.35=cmd`
7
+ * is not one and `1,000` is not one either.
8
+ *
9
+ * Lives here, in a package with no dependencies, because three different
10
+ * callers need it and only two of them can afford `@ifc-lite/export`: the CSV
11
+ * formula guard (`packages/export/src/csv-cell.ts`) exempts a genuine number
12
+ * from the `+`/`-` trigger so a spreadsheet column still sums (#1772), and
13
+ * `@ifc-lite/lists` needs the same decision in its own CSV writer.
14
+ * `rust/export/src/csv_cell.rs::is_wholly_numeric` decides the same language on
15
+ * the other side of the language boundary; what holds those two together is the
16
+ * shared vector fixture, not a promise that they look alike.
17
+ *
18
+ * The regex this replaces — `/^[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/` —
19
+ * is QUADRATIC on a failing match: `\d+\.?\d*` retries at every split point
20
+ * before the engine gives up. This scan is linear, which is the whole reason it
21
+ * is spelled out by hand. (For scale, on `-` + 60k digits + one letter the
22
+ * regex took ~1.8s and the scan ~1ms; the ratio is the point, not the numbers.)
23
+ *
24
+ * Cell text comes from IFC properties, so the input is attacker-controllable and
25
+ * a leading `-` is exactly what reaches this check. `\d` is ASCII-only in JS, and
26
+ * this scan matches that deliberately: a full-width or Arabic-Indic digit is NOT
27
+ * a number here and stays guarded.
28
+ */
29
+ export function isWhollyNumeric(v) {
30
+ const n = v.length;
31
+ let i = 0;
32
+ if (i < n && (v[i] === '+' || v[i] === '-'))
33
+ i++;
34
+ // Mantissa: `\d+\.?\d*` or `\.\d+` — at least one digit either way.
35
+ let digits = 0;
36
+ while (i < n && v[i] >= '0' && v[i] <= '9') {
37
+ i++;
38
+ digits++;
39
+ }
40
+ if (i < n && v[i] === '.') {
41
+ i++;
42
+ while (i < n && v[i] >= '0' && v[i] <= '9') {
43
+ i++;
44
+ digits++;
45
+ }
46
+ }
47
+ if (digits === 0)
48
+ return false;
49
+ // Optional exponent, which must carry at least one digit if present.
50
+ if (i < n && (v[i] === 'e' || v[i] === 'E')) {
51
+ i++;
52
+ if (i < n && (v[i] === '+' || v[i] === '-'))
53
+ i++;
54
+ let expDigits = 0;
55
+ while (i < n && v[i] >= '0' && v[i] <= '9') {
56
+ i++;
57
+ expDigits++;
58
+ }
59
+ if (expDigits === 0)
60
+ return false;
61
+ }
62
+ // Anchored at the end: trailing anything, including a newline, disqualifies.
63
+ return i === n;
64
+ }
65
+ //# sourceMappingURL=numeric-literal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"numeric-literal.js","sourceRoot":"","sources":["../src/numeric-literal.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,eAAe,CAAC,CAAS;IACvC,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;IACnB,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC;QAAE,CAAC,EAAE,CAAC;IAEjD,oEAAoE;IACpE,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,EAAE,CAAC;QAAC,CAAC,EAAE,CAAC;QAAC,MAAM,EAAE,CAAC;IAAC,CAAC;IAC9D,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;QAC1B,CAAC,EAAE,CAAC;QACJ,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,EAAE,CAAC;YAAC,CAAC,EAAE,CAAC;YAAC,MAAM,EAAE,CAAC;QAAC,CAAC;IAChE,CAAC;IACD,IAAI,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAE/B,qEAAqE;IACrE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC;QAC5C,CAAC,EAAE,CAAC;QACJ,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC;YAAE,CAAC,EAAE,CAAC;QACjD,IAAI,SAAS,GAAG,CAAC,CAAC;QAClB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,EAAE,CAAC;YAAC,CAAC,EAAE,CAAC;YAAC,SAAS,EAAE,CAAC;QAAC,CAAC;QACjE,IAAI,SAAS,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC;IACpC,CAAC;IAED,6EAA6E;IAC7E,OAAO,CAAC,KAAK,CAAC,CAAC;AACjB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ifc-lite/encoding",
3
- "version": "2.0.0",
3
+ "version": "2.1.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",