@bldrs-ai/conway 1.335.1069 → 1.337.1075

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.
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=web_ifc_parity.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web_ifc_parity.test.d.ts","sourceRoot":"","sources":["../../../../src/compat/web-ifc/web_ifc_parity.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,113 @@
1
+ /* eslint-disable */
2
+ // Parity guard for the vendored web-ifc compat constants.
3
+ //
4
+ // Conway owns the IFC name<->typecode tables (src/compat/web-ifc/ifc2x4.ts
5
+ // and types-map.ts) so the shipped package never depends on `web-ifc` at
6
+ // runtime — that coupling is exactly what the conway-web-ifc-adapter removal
7
+ // retired. This test re-introduces `web-ifc` as a **devDependency only** and
8
+ // statically diffs the vendored tables against it, so:
9
+ //
10
+ // 1. the vendored constants are proven equal to the upstream they were
11
+ // copied from, and
12
+ // 2. when we step `web-ifc` forward to pick up upstream fixes, the bump
13
+ // fails here with the exact set of added / removed / re-coded types
14
+ // instead of drifting silently.
15
+ //
16
+ // Pinned to the same web-ifc version Bldrs Share's engine-comparison path
17
+ // uses (`web-ifc@0.0.35`); bump the devDependency and this header together.
18
+ //
19
+ // Static only — reads JS objects, never boots the wasm. web-ifc 0.0.35
20
+ // re-exports the `IFCxxx` name->code constants from its package root
21
+ // (web-ifc-api-node.js) but ships no type declarations for them, and its
22
+ // internal `IfcTypesMap` (code->name) is not a public export — hence the
23
+ // untyped namespace read below and the inverse-of-ifc2x4 check for the map.
24
+ import { describe, expect, test } from "@jest/globals";
25
+ import * as conwayIfc2x4 from "./ifc2x4.js";
26
+ import { IfcTypesMap, IfcElements as IfcElementsObject } from "./types-map.js";
27
+ import * as webIfcNamespace from "web-ifc";
28
+ /**
29
+ * Collect the `IFCxxx -> typecode` numeric constants from a module namespace,
30
+ * tolerating both ESM and interop-wrapped CommonJS shapes (the constants may
31
+ * sit on the namespace itself or under its `default`).
32
+ */
33
+ function ifcConstants(namespace) {
34
+ const out = new Map();
35
+ const candidate = namespace;
36
+ for (const source of [namespace, candidate?.default]) {
37
+ if (source === null || typeof source !== "object") {
38
+ continue;
39
+ }
40
+ for (const [name, value] of Object.entries(source)) {
41
+ if (name.startsWith("IFC") && typeof value === "number") {
42
+ out.set(name, value);
43
+ }
44
+ }
45
+ }
46
+ return out;
47
+ }
48
+ /**
49
+ * Read web-ifc's public `IfcElements` typecode array off a module namespace,
50
+ * tolerating the same ESM/CommonJS interop shapes as `ifcConstants`.
51
+ */
52
+ function ifcElementsArray(namespace) {
53
+ const candidate = namespace;
54
+ const value = candidate?.IfcElements ?? candidate?.default?.IfcElements;
55
+ return Array.isArray(value) ? value : [];
56
+ }
57
+ describe("web-ifc compat constants parity (web-ifc@0.0.35)", () => {
58
+ const conway = ifcConstants(conwayIfc2x4);
59
+ const web = ifcConstants(webIfcNamespace);
60
+ const conwayElements = conwayIfc2x4.IfcElements ?? [];
61
+ const webElements = ifcElementsArray(webIfcNamespace);
62
+ const elementsObjectEntries = Object.entries(IfcElementsObject);
63
+ test("both sides expose non-empty tables (guards every assertion below)", () => {
64
+ // If web-ifc reshapes its exports, or a generated table comes back empty,
65
+ // the parity assertions below could vacuously pass. Fail loudly here
66
+ // instead — one guard covering every collection the later tests compare.
67
+ expect(web.size).toBeGreaterThan(0);
68
+ expect(conway.size).toBeGreaterThan(0);
69
+ expect(webElements.length).toBeGreaterThan(0);
70
+ expect(conwayElements.length).toBeGreaterThan(0);
71
+ expect(elementsObjectEntries.length).toBeGreaterThan(0);
72
+ });
73
+ test("ifc2x4.ts mirrors web-ifc exactly (same names, same codes)", () => {
74
+ expect([...conway.keys()].sort()).toEqual([...web.keys()].sort());
75
+ // Compare as name=code strings so a mismatch reports which type and both
76
+ // values, not just "expected N".
77
+ const conwayPairs = [...conway.entries()].sort().map(([n, c]) => `${n}=${c}`);
78
+ const webPairs = [...web.entries()].sort().map(([n, c]) => `${n}=${c}`);
79
+ expect(conwayPairs).toEqual(webPairs);
80
+ });
81
+ test("IfcTypesMap is the exact inverse of the ifc2x4 constants", () => {
82
+ // types-map.ts (code->name) and ifc2x4.ts (name->code) are two views of
83
+ // the same data; this keeps them from drifting apart. web-ifc does not
84
+ // export its IfcTypesMap, so the upstream anchor is ifc2x4 (checked above)
85
+ // and this proves the map is its faithful inverse.
86
+ for (const [name, code] of conway) {
87
+ expect(IfcTypesMap[code]).toBe(name);
88
+ }
89
+ // Bijective: every map entry round-trips back to the same constant, so the
90
+ // distinct-name count equals the constant count.
91
+ const mapNames = new Set(Object.values(IfcTypesMap));
92
+ expect(mapNames.size).toBe(conway.size);
93
+ for (const [codeText, name] of Object.entries(IfcTypesMap)) {
94
+ expect(conway.get(name)).toBe(Number(codeText));
95
+ }
96
+ });
97
+ test("ifc2x4 IfcElements array mirrors web-ifc", () => {
98
+ // ifc2x4.ts re-exports web-ifc's IfcElements (the geometric-element
99
+ // typecode list). Order is irrelevant to consumers, so compare as sets.
100
+ // (Both sides are guarded non-empty above.)
101
+ expect([...conwayElements].sort((a, b) => a - b))
102
+ .toEqual([...webElements].sort((a, b) => a - b));
103
+ });
104
+ test("types-map IfcElements object is consistent with IfcTypesMap", () => {
105
+ // The IfcElements object (code->name) is web-ifc's properties-helper map;
106
+ // web-ifc does not export it publicly, so anchor it to IfcTypesMap (already
107
+ // proven against ifc2x4 above): every entry must name the same type the
108
+ // map does for that code.
109
+ for (const [code, name] of elementsObjectEntries) {
110
+ expect(IfcTypesMap[Number(code)]).toBe(name);
111
+ }
112
+ });
113
+ });
@@ -1,2 +1,2 @@
1
- const versionString = 'Conway Web-Ifc Shim v1.335.1069';
1
+ const versionString = 'Conway Web-Ifc Shim v1.337.1075';
2
2
  export { versionString };