@ifc-lite/codegen 1.17.0 → 1.18.1

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,30 @@
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 { crc32 } from './crc32.js';
5
+ /** Render the generated CRC32 constants without coupling this to enum emission. */
6
+ export function generateTypeIdConstants(schema, cratePrivate, categorize) {
7
+ let code = `// This Source Code Form is subject to the terms of the Mozilla Public
8
+ // License, v. 2.0. If a copy of the MPL was not distributed with this
9
+ // file, You can obtain one at https://mozilla.org/MPL/2.0/.
10
+
11
+ //! Auto-generated IFC Type ID Constants
12
+ //!
13
+ //! CRC32 hashes for fast type identification.
14
+ //! Generated from EXPRESS schema: ${schema.name}
15
+ //!
16
+ //! DO NOT EDIT - This file is auto-generated by @ifc-lite/codegen
17
+
18
+ #![allow(dead_code)]
19
+
20
+ `;
21
+ for (const [category, entities] of Object.entries(categorize(schema))) {
22
+ code += `// ${category}\n`;
23
+ for (const entity of entities) {
24
+ code += `pub const ${entity.name.toUpperCase()}: u32 = ${crc32(entity.name)};\n`;
25
+ }
26
+ code += '\n';
27
+ }
28
+ return cratePrivate ? `${code.trimEnd()}\n` : code;
29
+ }
30
+ //# sourceMappingURL=rust-type-id-generator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rust-type-id-generator.js","sourceRoot":"","sources":["../src/rust-type-id-generator.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAGnC,mFAAmF;AACnF,MAAM,UAAU,uBAAuB,CACrC,MAAqB,EACrB,YAAqB,EACrB,UAAyE;IAEzE,IAAI,IAAI,GAAG;;;;;;;qCAOwB,MAAM,CAAC,IAAI;;;;;;CAM/C,CAAC;IAEA,KAAK,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;QACtE,IAAI,IAAI,MAAM,QAAQ,IAAI,CAAC;QAC3B,KAAK,MAAM,MAAM,IAAI,QAAQ,EAAE,CAAC;YAC9B,IAAI,IAAI,aAAa,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,WAAW,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;QACnF,CAAC;QACD,IAAI,IAAI,IAAI,CAAC;IACf,CAAC;IAED,OAAO,YAAY,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;AACrD,CAAC"}
@@ -8,12 +8,12 @@ export function generateTypeNameParser(schema) {
8
8
  return known;
9
9
  }
10
10
  if s.bytes().all(|b| b.is_ascii() && !b.is_ascii_lowercase()) {
11
- return Self::Unknown(crc32_hash(s));
11
+ return Self::Unknown(UnknownIfcType::new(s.to_owned()));
12
12
  }
13
13
  // Keep Unicode uppercase expansion and the exact unknown-type CRC.
14
14
  let upper = s.to_uppercase();
15
15
  Self::from_canonical_name(&upper)
16
- .unwrap_or_else(|| Self::Unknown(crc32_hash(&upper)))
16
+ .unwrap_or_else(|| Self::Unknown(UnknownIfcType::new(upper)))
17
17
  }
18
18
 
19
19
  fn from_canonical_name(s: &str) -> Option<Self> {
@@ -0,0 +1,3 @@
1
+ /** Render the generated owned representation for unsupported IFC keywords. */
2
+ export declare function generateUnknownIfcType(visibility: 'pub' | 'pub(crate)'): string;
3
+ //# sourceMappingURL=rust-unknown-ifc-type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rust-unknown-ifc-type.d.ts","sourceRoot":"","sources":["../src/rust-unknown-ifc-type.ts"],"names":[],"mappings":"AAIA,8EAA8E;AAC9E,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,KAAK,GAAG,YAAY,GAAG,MAAM,CA0B/E"}
@@ -0,0 +1,32 @@
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
+ /** Render the generated owned representation for unsupported IFC keywords. */
5
+ export function generateUnknownIfcType(visibility) {
6
+ return `/// A normalized IFC keyword not declared by the supported schema universe.
7
+ #[derive(Debug, Clone, PartialEq, Eq, Hash)]
8
+ ${visibility} struct UnknownIfcType {
9
+ name: String,
10
+ id: u32,
11
+ }
12
+
13
+ impl UnknownIfcType {
14
+ fn new(name: String) -> Self {
15
+ let id = crc32_hash(&name);
16
+ Self { name, id }
17
+ }
18
+
19
+ /// Normalized uppercase STEP keyword.
20
+ ${visibility} fn as_str(&self) -> &str {
21
+ &self.name
22
+ }
23
+
24
+ /// CRC32 identifier of the normalized keyword.
25
+ ${visibility} fn id(&self) -> u32 {
26
+ self.id
27
+ }
28
+ }
29
+
30
+ `;
31
+ }
32
+ //# sourceMappingURL=rust-unknown-ifc-type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rust-unknown-ifc-type.js","sourceRoot":"","sources":["../src/rust-unknown-ifc-type.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D,8EAA8E;AAC9E,MAAM,UAAU,sBAAsB,CAAC,UAAgC;IACrE,OAAO;;EAEP,UAAU;;;;;;;;;;;;MAYN,UAAU;;;;;MAKV,UAAU;;;;;CAKf,CAAC;AACF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ifc-lite/codegen",
3
- "version": "1.17.0",
3
+ "version": "1.18.1",
4
4
  "description": "TypeScript code generator from IFC EXPRESS schemas",
5
5
  "type": "module",
6
6
  "repository": {
@@ -47,12 +47,12 @@
47
47
  "license": "MPL-2.0",
48
48
  "dependencies": {
49
49
  "commander": "^15.0.0",
50
- "@ifc-lite/data": "^4.2.0"
50
+ "@ifc-lite/data": "^6.0.0"
51
51
  },
52
52
  "devDependencies": {
53
- "@types/node": "^26.4.1",
53
+ "@types/node": "^26.6.1",
54
54
  "typescript": "^6.0.3",
55
- "vitest": "^4.1.11"
55
+ "vitest": "^5.0.1"
56
56
  },
57
57
  "publishConfig": {
58
58
  "access": "public"