bimdown-cli 0.4.0 → 0.5.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.
- package/README.md +24 -3
- package/dist/chunk-4SKM4RHY.js +142 -0
- package/dist/chunk-4SKM4RHY.js.map +1 -0
- package/dist/chunk-4YHVOWS4.js +255 -0
- package/dist/chunk-4YHVOWS4.js.map +1 -0
- package/dist/chunk-AYAXRYGP.js +2129 -0
- package/dist/chunk-AYAXRYGP.js.map +1 -0
- package/dist/chunk-EC5MR5ZH.js +648 -0
- package/dist/chunk-EC5MR5ZH.js.map +1 -0
- package/dist/chunk-HS3PO2LB.js +487 -0
- package/dist/chunk-HS3PO2LB.js.map +1 -0
- package/dist/chunk-IQJA3EFO.js +179 -0
- package/dist/chunk-IQJA3EFO.js.map +1 -0
- package/dist/chunk-JY6KWRDB.js +80 -0
- package/dist/chunk-JY6KWRDB.js.map +1 -0
- package/dist/chunk-KWSGJUMZ.js +2501 -0
- package/dist/chunk-KWSGJUMZ.js.map +1 -0
- package/dist/chunk-LWYIPR64.js +35 -0
- package/dist/chunk-LWYIPR64.js.map +1 -0
- package/dist/chunk-OBY3UYCO.js +44 -0
- package/dist/chunk-OBY3UYCO.js.map +1 -0
- package/dist/chunk-XC6WHJRL.js +29 -0
- package/dist/chunk-XC6WHJRL.js.map +1 -0
- package/dist/chunk-XQU52JKB.js +187 -0
- package/dist/chunk-XQU52JKB.js.map +1 -0
- package/dist/clash-load-D3LNQR6G.js +941 -0
- package/dist/clash-load-D3LNQR6G.js.map +1 -0
- package/dist/cli.js +306 -3377
- package/dist/cli.js.map +1 -1
- package/dist/dehydrate-ZHAGOI7Q.js +90 -0
- package/dist/dehydrate-ZHAGOI7Q.js.map +1 -0
- package/dist/diff-T2KOK2WR.js +89 -0
- package/dist/diff-T2KOK2WR.js.map +1 -0
- package/dist/engine-2TPWJVEQ.js +12 -0
- package/dist/engine-2TPWJVEQ.js.map +1 -0
- package/dist/hydrate-V24H7IF3.js +673 -0
- package/dist/hydrate-V24H7IF3.js.map +1 -0
- package/dist/import-ifc-RCZSXDA6.js +5324 -0
- package/dist/import-ifc-RCZSXDA6.js.map +1 -0
- package/dist/info-QC7YXWNX.js +92 -0
- package/dist/info-QC7YXWNX.js.map +1 -0
- package/dist/init-VWDML3UC.js +112 -0
- package/dist/init-VWDML3UC.js.map +1 -0
- package/dist/lib.d.ts +427 -44
- package/dist/lib.js +6482 -225
- package/dist/lib.js.map +1 -1
- package/dist/mep-W4HJI363.js +25 -0
- package/dist/mep-W4HJI363.js.map +1 -0
- package/dist/merge-ESOPDSA5.js +413 -0
- package/dist/merge-ESOPDSA5.js.map +1 -0
- package/dist/publish-3TAXQCUV.js +80 -0
- package/dist/publish-3TAXQCUV.js.map +1 -0
- package/dist/render-UEWYHPN6.js +1807 -0
- package/dist/render-UEWYHPN6.js.map +1 -0
- package/dist/resolve-topology-AQ2RO3W3.js +338 -0
- package/dist/resolve-topology-AQ2RO3W3.js.map +1 -0
- package/dist/spec/csv-schema/annotation/dimension.yaml +77 -0
- package/dist/spec/csv-schema/annotation/tag.yaml +44 -0
- package/dist/spec/csv-schema/annotation/text_note.yaml +52 -0
- package/dist/spec/csv-schema/architecture/ceiling.yaml +8 -1
- package/dist/spec/csv-schema/architecture/column.yaml +5 -1
- package/dist/spec/csv-schema/architecture/curtain_wall.yaml +45 -5
- package/dist/spec/csv-schema/architecture/door.yaml +5 -0
- package/dist/spec/csv-schema/architecture/furniture.yaml +28 -0
- package/dist/spec/csv-schema/architecture/opening.yaml +27 -6
- package/dist/spec/csv-schema/architecture/railing.yaml +35 -0
- package/dist/spec/csv-schema/architecture/roof.yaml +34 -1
- package/dist/spec/csv-schema/architecture/slab.yaml +19 -0
- package/dist/spec/csv-schema/architecture/space.yaml +11 -1
- package/dist/spec/csv-schema/architecture/stair.yaml +49 -0
- package/dist/spec/csv-schema/architecture/stair_landing.yaml +36 -0
- package/dist/spec/csv-schema/architecture/stair_run.yaml +31 -0
- package/dist/spec/csv-schema/architecture/wall.yaml +14 -1
- package/dist/spec/csv-schema/architecture/window.yaml +19 -0
- package/dist/spec/csv-schema/base/element.yaml +20 -11
- package/dist/spec/csv-schema/base/furniture_params.yaml +60 -0
- package/dist/spec/csv-schema/base/hosted_element.yaml +10 -2
- package/dist/spec/csv-schema/base/mep_connectable.yaml +23 -0
- package/dist/spec/csv-schema/base/mep_design.yaml +24 -0
- package/dist/spec/csv-schema/base/mep_insulated.yaml +9 -0
- package/dist/spec/csv-schema/base/mep_system_tag.yaml +12 -0
- package/dist/spec/csv-schema/base/point_element.yaml +1 -0
- package/dist/spec/csv-schema/base/section_profile.yaml +5 -0
- package/dist/spec/csv-schema/base/spatial_line_element.yaml +4 -2
- package/dist/spec/csv-schema/base/structural_section_profile.yaml +50 -0
- package/dist/spec/csv-schema/base/vertical_span.yaml +5 -4
- package/dist/spec/csv-schema/base/wall_bounded.yaml +21 -0
- package/dist/spec/csv-schema/grid.yaml +5 -0
- package/dist/spec/csv-schema/mep/cable_tray.yaml +10 -3
- package/dist/spec/csv-schema/mep/circuit.yaml +70 -0
- package/dist/spec/csv-schema/mep/conduit.yaml +2 -2
- package/dist/spec/csv-schema/mep/connector.yaml +112 -0
- package/dist/spec/csv-schema/mep/duct.yaml +10 -3
- package/dist/spec/csv-schema/mep/equipment.yaml +18 -1
- package/dist/spec/csv-schema/mep/mep_node.yaml +91 -2
- package/dist/spec/csv-schema/mep/mep_system.yaml +21 -0
- package/dist/spec/csv-schema/mep/pipe.yaml +27 -3
- package/dist/spec/csv-schema/mep/terminal.yaml +22 -1
- package/dist/spec/csv-schema/model_group.yaml +40 -0
- package/dist/spec/csv-schema/sheet/sheet.yaml +50 -0
- package/dist/spec/csv-schema/sheet/sheet_viewport.yaml +86 -0
- package/dist/spec/csv-schema/structure/beam.yaml +29 -1
- package/dist/spec/csv-schema/structure/beam_system.yaml +29 -0
- package/dist/spec/csv-schema/structure/brace.yaml +24 -1
- package/dist/spec/csv-schema/structure/foundation.yaml +40 -7
- package/dist/spec/csv-schema/structure/structure_column.yaml +19 -1
- package/dist/spec/csv-schema/structure/structure_slab.yaml +32 -0
- package/dist/spec/csv-schema/structure/structure_wall.yaml +22 -0
- package/dist/spec/csv-schema/types/beam_type.yaml +11 -0
- package/dist/spec/csv-schema/types/ceiling_type.yaml +6 -0
- package/dist/spec/csv-schema/types/column_type.yaml +12 -0
- package/dist/spec/csv-schema/types/curtain_wall_type.yaml +32 -0
- package/dist/spec/csv-schema/types/door_type.yaml +27 -0
- package/dist/spec/csv-schema/types/element_type.yaml +21 -0
- package/dist/spec/csv-schema/types/fenestration.yaml +16 -0
- package/dist/spec/csv-schema/types/foundation_type.yaml +36 -0
- package/dist/spec/csv-schema/types/furniture_type.yaml +11 -0
- package/dist/spec/csv-schema/types/layered_type.yaml +13 -0
- package/dist/spec/csv-schema/types/railing_type.yaml +40 -0
- package/dist/spec/csv-schema/types/roof_type.yaml +7 -0
- package/dist/spec/csv-schema/types/slab_type.yaml +9 -0
- package/dist/spec/csv-schema/types/type_layer.yaml +47 -0
- package/dist/spec/csv-schema/types/wall_type.yaml +6 -0
- package/dist/spec/csv-schema/types/window_type.yaml +31 -0
- package/dist/spec/csv-schema/underlay.yaml +73 -0
- package/dist/spec/csv-schema/view.yaml +36 -0
- package/dist/spec/duckdb-strategy.md +4 -3
- package/dist/spec/geojson-schema/readme.md +380 -0
- package/dist/spec/mep-port-conventions.md +190 -0
- package/dist/spec/migration-guide.md +1 -1
- package/dist/spec/project_metadata.schema.yaml +52 -4
- package/dist/spec/readme.md +356 -97
- package/dist/spec/starter-types/global/beam_type.csv +5 -0
- package/dist/spec/starter-types/global/ceiling_type.csv +3 -0
- package/dist/spec/starter-types/global/column_type.csv +5 -0
- package/dist/spec/starter-types/global/curtain_wall_type.csv +2 -0
- package/dist/spec/starter-types/global/door_type.csv +6 -0
- package/dist/spec/starter-types/global/foundation_type.csv +7 -0
- package/dist/spec/starter-types/global/furniture_type.csv +11 -0
- package/dist/spec/starter-types/global/railing_type.csv +5 -0
- package/dist/spec/starter-types/global/roof_type.csv +3 -0
- package/dist/spec/starter-types/global/slab_type.csv +4 -0
- package/dist/spec/starter-types/global/type_layer.csv +40 -0
- package/dist/spec/starter-types/global/wall_type.csv +8 -0
- package/dist/spec/starter-types/global/window_type.csv +6 -0
- package/dist/spec/svg-schema/readme.md +47 -1
- package/package.json +6 -3
- package/dist/spec/csv-schema/base/mep_connected_segment.yaml +0 -17
- package/dist/spec/csv-schema/base/mep_system.yaml +0 -7
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
projectUnits
|
|
4
|
+
} from "./chunk-LWYIPR64.js";
|
|
5
|
+
import {
|
|
6
|
+
loadCatalog,
|
|
7
|
+
typeValues
|
|
8
|
+
} from "./chunk-XQU52JKB.js";
|
|
9
|
+
import {
|
|
10
|
+
buildRegistry,
|
|
11
|
+
getSpecDir
|
|
12
|
+
} from "./chunk-4YHVOWS4.js";
|
|
13
|
+
import {
|
|
14
|
+
readCsv
|
|
15
|
+
} from "./chunk-JY6KWRDB.js";
|
|
16
|
+
import {
|
|
17
|
+
discoverLayout,
|
|
18
|
+
listFiles
|
|
19
|
+
} from "./chunk-OBY3UYCO.js";
|
|
20
|
+
|
|
21
|
+
// src/commands/info.ts
|
|
22
|
+
import { existsSync } from "fs";
|
|
23
|
+
import { join } from "path";
|
|
24
|
+
var TYPES_LISTED = 12;
|
|
25
|
+
var num = (v) => v === void 0 ? "" : String(Math.round(Number(v) * 1e3) / 1e3);
|
|
26
|
+
function typeSize(t) {
|
|
27
|
+
const v = typeValues(t);
|
|
28
|
+
if (v.size_x || v.size_y) return [v.designation, `${num(v.size_x)}\xD7${num(v.size_y)}`].filter(Boolean).join(" ");
|
|
29
|
+
if (t.table === "foundation_type") return [v.kind, [v.width, v.length, v.thickness].filter(Boolean).map(num).join("\xD7")].filter(Boolean).join(" ");
|
|
30
|
+
if (v.width && v.height) return `${num(v.width)}\xD7${num(v.height)}`;
|
|
31
|
+
if (v.thickness) return num(v.thickness);
|
|
32
|
+
return v.family ?? "";
|
|
33
|
+
}
|
|
34
|
+
function projectInfoLines(dir) {
|
|
35
|
+
const registry = buildRegistry(getSpecDir());
|
|
36
|
+
const layout = discoverLayout(dir);
|
|
37
|
+
const lines = [];
|
|
38
|
+
const declared = existsSync(join(dir, "project_metadata.json"));
|
|
39
|
+
lines.push(`Units: ${projectUnits(dir)}${declared ? " (from project_metadata.json)" : " (default; no project_metadata.json yet)"}`, "");
|
|
40
|
+
const levelCsv = join(layout.globalDir, "level.csv");
|
|
41
|
+
if (existsSync(levelCsv)) {
|
|
42
|
+
lines.push("Levels:");
|
|
43
|
+
for (const row of readCsv(levelCsv).rows) lines.push(` ${row.id} ${row.name || row.number || ""} elevation=${row.elevation}`);
|
|
44
|
+
lines.push("");
|
|
45
|
+
}
|
|
46
|
+
const totals = {};
|
|
47
|
+
const typed = {};
|
|
48
|
+
for (const d of [{ name: "global", path: layout.globalDir }, ...layout.levelDirs]) {
|
|
49
|
+
if (!existsSync(d.path)) continue;
|
|
50
|
+
const counts = [];
|
|
51
|
+
for (const f of listFiles(d.path)) {
|
|
52
|
+
if (!f.endsWith(".csv")) continue;
|
|
53
|
+
const table = f.replace(".csv", "");
|
|
54
|
+
const def = registry.get(table);
|
|
55
|
+
if (!def || table.endsWith("_type") || table === "type_layer") continue;
|
|
56
|
+
const rows = readCsv(join(d.path, f)).rows;
|
|
57
|
+
counts.push(`${table}: ${rows.length}`);
|
|
58
|
+
totals[table] = (totals[table] ?? 0) + rows.length;
|
|
59
|
+
if (def.typeTable) typed[table] = (typed[table] ?? 0) + rows.filter((r) => r.type_id).length;
|
|
60
|
+
}
|
|
61
|
+
if (counts.length > 0) lines.push(`${d.name}/ ${counts.join(", ")}`);
|
|
62
|
+
}
|
|
63
|
+
lines.push("", "Totals:");
|
|
64
|
+
let grand = 0;
|
|
65
|
+
for (const [table, count] of Object.entries(totals).sort(([a], [b]) => a.localeCompare(b))) {
|
|
66
|
+
lines.push(` ${table}: ${count}`);
|
|
67
|
+
grand += count;
|
|
68
|
+
}
|
|
69
|
+
lines.push(` TOTAL: ${grand}`);
|
|
70
|
+
const catalog = loadCatalog(dir);
|
|
71
|
+
const byTable = /* @__PURE__ */ new Map();
|
|
72
|
+
for (const t of catalog.types.values()) {
|
|
73
|
+
const list = byTable.get(t.table);
|
|
74
|
+
if (list) list.push(t);
|
|
75
|
+
else byTable.set(t.table, [t]);
|
|
76
|
+
}
|
|
77
|
+
lines.push("", byTable.size > 0 ? "Types (global/*_type.csv; set type_id and leave the type's fields empty):" : "Types: none (global/*_type.csv; `bimdown init` writes a starter catalog)");
|
|
78
|
+
for (const [table, list] of [...byTable].sort(([a], [b]) => a.localeCompare(b))) {
|
|
79
|
+
const shown = list.slice(0, TYPES_LISTED).map((t) => {
|
|
80
|
+
const size = typeSize(t);
|
|
81
|
+
return size ? `${t.id} (${size})` : t.id;
|
|
82
|
+
});
|
|
83
|
+
lines.push(` ${table}: ${shown.join(", ")}${list.length > TYPES_LISTED ? `, \u2026 ${list.length - TYPES_LISTED} more` : ""}`);
|
|
84
|
+
}
|
|
85
|
+
const coverage = Object.entries(typed).filter(([t]) => totals[t] > 0).sort(([a], [b]) => a.localeCompare(b));
|
|
86
|
+
if (coverage.length > 0) lines.push(` typed: ${coverage.map(([t, n]) => `${t} ${n}/${totals[t]}`).join(", ")}`);
|
|
87
|
+
return lines;
|
|
88
|
+
}
|
|
89
|
+
export {
|
|
90
|
+
projectInfoLines
|
|
91
|
+
};
|
|
92
|
+
//# sourceMappingURL=info-QC7YXWNX.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/info.ts"],"sourcesContent":["/**\n * `bimdown info` (and the agent's model_info): units, levels, element counts,\n * the type catalog and how many elements use it.\n */\nimport { existsSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { buildRegistry, getSpecDir } from '../schema/registry.js';\nimport { discoverLayout, listFiles } from '../utils/fs.js';\nimport { readCsv } from '../utils/csv.js';\nimport { projectUnits } from '../utils/units.js';\nimport { loadCatalog, typeValues, type ElementType } from '../catalog/index.js';\n\nconst TYPES_LISTED = 12;\nconst num = (v: string | undefined) => (v === undefined ? '' : String(Math.round(Number(v) * 1000) / 1000));\n\n/** The size that tells a type apart: thickness, width×height, section, or the foundation footprint. */\nfunction typeSize(t: ElementType): string {\n const v = typeValues(t);\n if (v.size_x || v.size_y) return [v.designation, `${num(v.size_x)}×${num(v.size_y)}`].filter(Boolean).join(' ');\n if (t.table === 'foundation_type') return [v.kind, [v.width, v.length, v.thickness].filter(Boolean).map(num).join('×')].filter(Boolean).join(' ');\n if (v.width && v.height) return `${num(v.width)}×${num(v.height)}`;\n if (v.thickness) return num(v.thickness);\n return v.family ?? '';\n}\n\nexport function projectInfoLines(dir: string): string[] {\n const registry = buildRegistry(getSpecDir());\n const layout = discoverLayout(dir);\n const lines: string[] = [];\n\n const declared = existsSync(join(dir, 'project_metadata.json'));\n lines.push(`Units: ${projectUnits(dir)}${declared ? ' (from project_metadata.json)' : ' (default; no project_metadata.json yet)'}`, '');\n\n const levelCsv = join(layout.globalDir, 'level.csv');\n if (existsSync(levelCsv)) {\n lines.push('Levels:');\n for (const row of readCsv(levelCsv).rows) lines.push(` ${row.id} ${row.name || row.number || ''} elevation=${row.elevation}`);\n lines.push('');\n }\n\n const totals: Record<string, number> = {};\n const typed: Record<string, number> = {};\n for (const d of [{ name: 'global', path: layout.globalDir }, ...layout.levelDirs]) {\n if (!existsSync(d.path)) continue;\n const counts: string[] = [];\n for (const f of listFiles(d.path)) {\n if (!f.endsWith('.csv')) continue;\n const table = f.replace('.csv', '');\n const def = registry.get(table);\n if (!def || table.endsWith('_type') || table === 'type_layer') continue;\n const rows = readCsv(join(d.path, f)).rows;\n counts.push(`${table}: ${rows.length}`);\n totals[table] = (totals[table] ?? 0) + rows.length;\n if (def.typeTable) typed[table] = (typed[table] ?? 0) + rows.filter((r) => r.type_id).length;\n }\n if (counts.length > 0) lines.push(`${d.name}/ ${counts.join(', ')}`);\n }\n\n lines.push('', 'Totals:');\n let grand = 0;\n for (const [table, count] of Object.entries(totals).sort(([a], [b]) => a.localeCompare(b))) {\n lines.push(` ${table}: ${count}`);\n grand += count;\n }\n lines.push(` TOTAL: ${grand}`);\n\n const catalog = loadCatalog(dir);\n const byTable = new Map<string, ElementType[]>();\n for (const t of catalog.types.values()) {\n const list = byTable.get(t.table);\n if (list) list.push(t); else byTable.set(t.table, [t]);\n }\n lines.push('', byTable.size > 0\n ? 'Types (global/*_type.csv; set type_id and leave the type\\'s fields empty):'\n : 'Types: none (global/*_type.csv; `bimdown init` writes a starter catalog)');\n for (const [table, list] of [...byTable].sort(([a], [b]) => a.localeCompare(b))) {\n const shown = list.slice(0, TYPES_LISTED).map((t) => {\n const size = typeSize(t);\n return size ? `${t.id} (${size})` : t.id;\n });\n lines.push(` ${table}: ${shown.join(', ')}${list.length > TYPES_LISTED ? `, … ${list.length - TYPES_LISTED} more` : ''}`);\n }\n const coverage = Object.entries(typed).filter(([t]) => totals[t] > 0).sort(([a], [b]) => a.localeCompare(b));\n if (coverage.length > 0) lines.push(` typed: ${coverage.map(([t, n]) => `${t} ${n}/${totals[t]}`).join(', ')}`);\n return lines;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAIA,SAAS,kBAAkB;AAC3B,SAAS,YAAY;AAOrB,IAAM,eAAe;AACrB,IAAM,MAAM,CAAC,MAA2B,MAAM,SAAY,KAAK,OAAO,KAAK,MAAM,OAAO,CAAC,IAAI,GAAI,IAAI,GAAI;AAGzG,SAAS,SAAS,GAAwB;AACxC,QAAM,IAAI,WAAW,CAAC;AACtB,MAAI,EAAE,UAAU,EAAE,OAAQ,QAAO,CAAC,EAAE,aAAa,GAAG,IAAI,EAAE,MAAM,CAAC,OAAI,IAAI,EAAE,MAAM,CAAC,EAAE,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AAC9G,M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Ac,CAAC,CAAC,GAAG;AAC/E,UAAM,QAAQ,KAAK,MAAM,GAAG,YAAY,EAAE,IAAI,CAAC,MAAM;AACnD,YAAM,OAAO,SAAS,CAAC;AACvB,aAAO,OAAO,GAAG,EAAE,EAAE,KAAK,IAAI,MAAM,EAAE;AAAA,IACxC,CAAC;AACD,UAAM,KAAK,KAAK,KAAK,KAAK,MAAM,KAAK,IAAI,CAAC,GAAG,KAAK,SAAS,eAAe,YAAO,KAAK,SAAS,YAAY,UAAU,EAAE,EAAE;AAAA,EAC3H;AACA,QAAM,WAAW,OAAO,QAAQ,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;AAC3G,MAAI,SAAS,SAAS,EAAG,OAAM,KAAK,YAAY,SAAS,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,CAAC,EAAE,EAAE,KAAK,IAAI,CAAC,EAAE;AAC/G,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
UNIT_TO_M
|
|
4
|
+
} from "./chunk-LWYIPR64.js";
|
|
5
|
+
import {
|
|
6
|
+
getSpecDir
|
|
7
|
+
} from "./chunk-4YHVOWS4.js";
|
|
8
|
+
|
|
9
|
+
// src/commands/init.ts
|
|
10
|
+
import { mkdirSync, writeFileSync, existsSync, readdirSync, readFileSync } from "fs";
|
|
11
|
+
import { join } from "path";
|
|
12
|
+
var PROJECT_UNITS = ["m", "mm", "ft", "in"];
|
|
13
|
+
var LENGTH_COLUMNS = /* @__PURE__ */ new Set([
|
|
14
|
+
"thickness",
|
|
15
|
+
"width",
|
|
16
|
+
"length",
|
|
17
|
+
"height",
|
|
18
|
+
"frame_width",
|
|
19
|
+
"u_spacing",
|
|
20
|
+
"v_spacing",
|
|
21
|
+
"size_x",
|
|
22
|
+
"size_y",
|
|
23
|
+
"flange",
|
|
24
|
+
"web",
|
|
25
|
+
"root_radius",
|
|
26
|
+
"mullion_width",
|
|
27
|
+
"mullion_depth",
|
|
28
|
+
"top_rail_size",
|
|
29
|
+
"baluster_spacing",
|
|
30
|
+
"baluster_size"
|
|
31
|
+
]);
|
|
32
|
+
var round6 = (v) => Math.round(v * 1e6) / 1e6;
|
|
33
|
+
function scaleStarterCsv(csv, units) {
|
|
34
|
+
const perM = 1 / UNIT_TO_M[units];
|
|
35
|
+
if (perM === 1) return csv;
|
|
36
|
+
const lines = csv.split("\n");
|
|
37
|
+
const header = lines[0].split(",");
|
|
38
|
+
const scale = header.map((h) => LENGTH_COLUMNS.has(h));
|
|
39
|
+
return [lines[0], ...lines.slice(1).map((line) => {
|
|
40
|
+
if (line.trim() === "") return line;
|
|
41
|
+
return line.split(",").map((v, i) => {
|
|
42
|
+
const n = Number(v);
|
|
43
|
+
return scale[i] && v.trim() !== "" && Number.isFinite(n) ? String(round6(n * perM)) : v;
|
|
44
|
+
}).join(",");
|
|
45
|
+
})].join("\n");
|
|
46
|
+
}
|
|
47
|
+
function writeStarterTypes(globalDir, units = "m") {
|
|
48
|
+
const src = join(getSpecDir(), "starter-types", "global");
|
|
49
|
+
if (!existsSync(src)) return [];
|
|
50
|
+
const written = [];
|
|
51
|
+
for (const f of readdirSync(src)) {
|
|
52
|
+
if (!f.endsWith(".csv") || existsSync(join(globalDir, f))) continue;
|
|
53
|
+
writeFileSync(join(globalDir, f), scaleStarterCsv(readFileSync(join(src, f), "utf-8"), units), "utf-8");
|
|
54
|
+
written.push(f);
|
|
55
|
+
}
|
|
56
|
+
return written.sort();
|
|
57
|
+
}
|
|
58
|
+
function initProject(absDir, opts = {}) {
|
|
59
|
+
const units = opts.units ?? "m";
|
|
60
|
+
if (!PROJECT_UNITS.includes(units)) throw new Error(`Unknown units "${units}" (use ${PROJECT_UNITS.join(", ")})`);
|
|
61
|
+
const perM = 1 / UNIT_TO_M[units];
|
|
62
|
+
if (!existsSync(absDir)) {
|
|
63
|
+
mkdirSync(absDir, { recursive: true });
|
|
64
|
+
}
|
|
65
|
+
writeFileSync(join(absDir, ".bimdown"), "", "utf-8");
|
|
66
|
+
const metadataPath = join(absDir, "project_metadata.json");
|
|
67
|
+
if (!existsSync(metadataPath)) {
|
|
68
|
+
writeFileSync(
|
|
69
|
+
metadataPath,
|
|
70
|
+
JSON.stringify({ format_version: 2, units, spatial_z: "absolute" }, null, 2) + "\n",
|
|
71
|
+
"utf-8"
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
const globalDir = join(absDir, "global");
|
|
75
|
+
if (!existsSync(globalDir)) {
|
|
76
|
+
mkdirSync(globalDir, { recursive: true });
|
|
77
|
+
}
|
|
78
|
+
const levelCsvPath = join(globalDir, "level.csv");
|
|
79
|
+
if (!existsSync(levelCsvPath)) {
|
|
80
|
+
writeFileSync(levelCsvPath, "id,number,name,elevation\nlv-1,1,Level 1,0.0\n", "utf-8");
|
|
81
|
+
}
|
|
82
|
+
const gridCsvPath = join(globalDir, "grid.csv");
|
|
83
|
+
if (!existsSync(gridCsvPath)) {
|
|
84
|
+
const half = units === "ft" ? 30 : units === "in" ? 360 : 10 * perM;
|
|
85
|
+
const gridContent = [
|
|
86
|
+
"id,number,start_x,start_y,end_x,end_y",
|
|
87
|
+
`gr-1,A,${-half},0,${half},0`,
|
|
88
|
+
`gr-2,1,0,${-half},0,${half}`
|
|
89
|
+
].join("\n") + "\n";
|
|
90
|
+
writeFileSync(gridCsvPath, gridContent, "utf-8");
|
|
91
|
+
}
|
|
92
|
+
const types = writeStarterTypes(globalDir, units);
|
|
93
|
+
console.log(`Initialized empty BimDown project at ${absDir} (units: ${units})`);
|
|
94
|
+
console.log("Created:");
|
|
95
|
+
console.log(" - global/level.csv (lv-1)");
|
|
96
|
+
console.log(" - global/grid.csv (A, 1)");
|
|
97
|
+
if (types.length > 0) {
|
|
98
|
+
console.log(` - starter element types: ${types.map((f) => `global/${f}`).join(", ")}`);
|
|
99
|
+
if (units === "ft" || units === "in") {
|
|
100
|
+
console.log(` Note: the starter types are metric sizes (names in mm) converted to ${units}; add imperial types (e.g. 2x4 stud walls, 3'-0" doors) as needed.`);
|
|
101
|
+
} else if (units === "mm") {
|
|
102
|
+
console.log(" Note: starter type sizes are in mm (e.g. a 200 mm wall has thickness 200).");
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
export {
|
|
107
|
+
PROJECT_UNITS,
|
|
108
|
+
initProject,
|
|
109
|
+
scaleStarterCsv,
|
|
110
|
+
writeStarterTypes
|
|
111
|
+
};
|
|
112
|
+
//# sourceMappingURL=init-VWDML3UC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/init.ts"],"sourcesContent":["import { mkdirSync, writeFileSync, existsSync, readdirSync, readFileSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { getSpecDir } from '../schema/registry.js';\nimport { UNIT_TO_M } from '../utils/units.js';\n\nexport type ProjectUnits = 'm' | 'mm' | 'ft' | 'in';\nexport const PROJECT_UNITS: ProjectUnits[] = ['m', 'mm', 'ft', 'in'];\n\n/**\n * Starter-type columns that are lengths, scaled from the metric files to the\n * project units (same list as the editor's starter catalog, plus curtain-wall\n * mullion and railing sizes). u_value, shgc, vt, conductivity, seq are not.\n */\nconst LENGTH_COLUMNS = new Set([\n 'thickness', 'width', 'length', 'height', 'frame_width', 'u_spacing', 'v_spacing',\n 'size_x', 'size_y', 'flange', 'web', 'root_radius',\n 'mullion_width', 'mullion_depth', 'top_rail_size', 'baluster_spacing', 'baluster_size',\n]);\n\nconst round6 = (v: number) => Math.round(v * 1e6) / 1e6;\n\n/** A metric starter CSV with its length columns in `units` (plain split: the files have no quoted commas). */\nexport function scaleStarterCsv(csv: string, units: ProjectUnits): string {\n const perM = 1 / UNIT_TO_M[units];\n if (perM === 1) return csv;\n const lines = csv.split('\\n');\n const header = lines[0].split(',');\n const scale = header.map((h) => LENGTH_COLUMNS.has(h));\n return [lines[0], ...lines.slice(1).map((line) => {\n if (line.trim() === '') return line;\n return line.split(',').map((v, i) => {\n const n = Number(v);\n return scale[i] && v.trim() !== '' && Number.isFinite(n) ? String(round6(n * perM)) : v;\n }).join(',');\n })].join('\\n');\n}\n\n/** Write the built-in starter type catalog (spec/starter-types/global/*.csv, metric) into global/, scaled to `units`. */\nexport function writeStarterTypes(globalDir: string, units: ProjectUnits = 'm'): string[] {\n const src = join(getSpecDir(), 'starter-types', 'global');\n if (!existsSync(src)) return [];\n const written: string[] = [];\n for (const f of readdirSync(src)) {\n if (!f.endsWith('.csv') || existsSync(join(globalDir, f))) continue;\n writeFileSync(join(globalDir, f), scaleStarterCsv(readFileSync(join(src, f), 'utf-8'), units), 'utf-8');\n written.push(f);\n }\n return written.sort();\n}\n\nexport function initProject(absDir: string, opts: { units?: ProjectUnits } = {}) {\n const units = opts.units ?? 'm';\n if (!PROJECT_UNITS.includes(units)) throw new Error(`Unknown units \"${units}\" (use ${PROJECT_UNITS.join(', ')})`);\n const perM = 1 / UNIT_TO_M[units];\n\n if (!existsSync(absDir)) {\n mkdirSync(absDir, { recursive: true });\n }\n\n // Write marking file\n writeFileSync(join(absDir, '.bimdown'), '', 'utf-8');\n\n // project_metadata.json with current format_version\n const metadataPath = join(absDir, 'project_metadata.json');\n if (!existsSync(metadataPath)) {\n writeFileSync(\n metadataPath,\n JSON.stringify({ format_version: 2, units, spatial_z: 'absolute' }, null, 2) + '\\n',\n 'utf-8',\n );\n }\n\n // Create global dir\n const globalDir = join(absDir, 'global');\n if (!existsSync(globalDir)) {\n mkdirSync(globalDir, { recursive: true });\n }\n\n // Create level.csv\n const levelCsvPath = join(globalDir, 'level.csv');\n if (!existsSync(levelCsvPath)) {\n writeFileSync(levelCsvPath, 'id,number,name,elevation\\nlv-1,1,Level 1,0.0\\n', 'utf-8');\n }\n\n // Create grid.csv\n const gridCsvPath = join(globalDir, 'grid.csv');\n if (!existsSync(gridCsvPath)) {\n // 2 axes (mutually perpendicular), about 20 m long in the project units (ft: 30 → 60 ft)\n const half = units === 'ft' ? 30 : units === 'in' ? 360 : 10 * perM;\n const gridContent = [\n 'id,number,start_x,start_y,end_x,end_y',\n `gr-1,A,${-half},0,${half},0`,\n `gr-2,1,0,${-half},0,${half}`,\n ].join('\\n') + '\\n';\n writeFileSync(gridCsvPath, gridContent, 'utf-8');\n }\n\n const types = writeStarterTypes(globalDir, units);\n\n console.log(`Initialized empty BimDown project at ${absDir} (units: ${units})`);\n console.log('Created:');\n console.log(' - global/level.csv (lv-1)');\n console.log(' - global/grid.csv (A, 1)');\n if (types.length > 0) {\n console.log(` - starter element types: ${types.map((f) => `global/${f}`).join(', ')}`);\n if (units === 'ft' || units === 'in') {\n console.log(` Note: the starter types are metric sizes (names in mm) converted to ${units}; add imperial types (e.g. 2x4 stud walls, 3'-0\" doors) as needed.`);\n } else if (units === 'mm') {\n console.log(' Note: starter type sizes are in mm (e.g. a 200 mm wall has thickness 200).');\n }\n }\n}\n"],"mappings":";;;;;;;;;AAAA,SAAS,WAAW,eAAe,YAAY,aAAa,oBAAoB;AAChF,SAAS,YAAY;AAKd,IAAM,gBAAgC,CAAC,KAAK,MAAM,MAAM,IAAI;AAOnE,IAAM,iBAAiB,oBAAI,IAAI;AAAA,EAC7B;AAAA,EAAa;AAAA,EAAS;AAAA,EAAU;AAAA,EAAU;AAAA,EAAe;AAAA,EAAa;AAAA,EACtE;AAAA,EAAU;AAAA,EAAU;AAAA,EAAU;AAAA,EAAO;AAAA,EACrC;AAAA,EAAiB;AAAA,EAAiB;AAAA,EAAiB;AAAA,EAAoB;AACzE,CAAC;AAED,IAAM,SAAS,CAAC,MAAc,KAAK,MAAM,IAAI,GAAG,IAAI;AAG7C,SAAS,gBAAgB,KAAa,OAA6B;AACxE,QAAM,OAAO,IAAI,UAAU,KAAK;AAChC,MAAI,SAAS,EAA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