@floless/app 0.107.0 → 0.108.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/dist/floless-server.cjs +269 -94
- package/dist/skills/floless-app-steel-model/SKILL.md +30 -1
- package/dist/skills/floless-app-workflows/references/dev-server-and-run-trace.md +11 -8
- package/dist/skills/reading-structural-drawings/SKILL.md +28 -0
- package/dist/web/grid-core.js +61 -0
- package/dist/web/steel-3d-core.js +145 -6
- package/dist/web/steel-detail-refs.js +116 -0
- package/dist/web/steel-editor.html +40 -16
- package/dist/web/steel-model-adapter.js +160 -10
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* steel-model-adapter.js — the READ side of the steel editor's model boundary (unit 5, P2).
|
|
2
|
+
* steel-model-adapter.js — the READ side of the steel editor's model boundary (unit 5, P2 + P5).
|
|
3
3
|
*
|
|
4
4
|
* PURE and framework-free (no DOM, no Three.js), node-tested from server/steel-model-adapter.test.ts —
|
|
5
5
|
* same shape as grid-core.js / steel-3d-core.js.
|
|
@@ -11,11 +11,16 @@
|
|
|
11
11
|
* answers in WORLD MILLIMETRES regardless of how the contract underneath stores things, so P5 can add a v2
|
|
12
12
|
* arm behind the same six methods and the editor never learns which one it is talking to.
|
|
13
13
|
*
|
|
14
|
-
* SCOPE — read only, and NOT
|
|
15
|
-
* P2
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
14
|
+
* SCOPE — read only, and STILL NOT WIRED IN.
|
|
15
|
+
* P2 shipped this tested and unconsumed on purpose. Rewiring the editor's read sites would have invalidated
|
|
16
|
+
* the characterization baseline recorded in the same PR (that baseline is the only evidence a refactor
|
|
17
|
+
* changes nothing). P3 took the write half into `steel-model-commands.js` and left the read half here, so
|
|
18
|
+
* nothing loads this module yet: no `<script>` tag references it, and the sole non-test mention in `web/`
|
|
19
|
+
* is a signpost comment in `steel-editor.html`. P5 adds the v2 arm below on the same terms — the arm
|
|
20
|
+
* exists and is tested; nothing can reach it until P7 registers a v2 renderer.
|
|
21
|
+
*
|
|
22
|
+
* UNITS AND SIGNS BELOW DESCRIBE THE v1 ARM. The v2 arm needs none of them (world mm is already world mm);
|
|
23
|
+
* see `createModelAdapterV2`.
|
|
19
24
|
*
|
|
20
25
|
* UNITS AND SIGNS — the one thing to get right.
|
|
21
26
|
* Contract geometry is per-sheet display pixels scaled by `plan.pt_per_ft`, with Y growing DOWNWARD, and
|
|
@@ -39,7 +44,7 @@
|
|
|
39
44
|
* recorded here rather than asserted, since pinning a NaN as expected output would entrench a bug).
|
|
40
45
|
*/
|
|
41
46
|
|
|
42
|
-
import { MODEL_V2_TOL } from './steel-3d-core.js';
|
|
47
|
+
import { MODEL_V2_TOL, memberGeometryV2 } from './steel-3d-core.js';
|
|
43
48
|
|
|
44
49
|
const FT_MM = 304.8;
|
|
45
50
|
const IN_MM = 25.4; // ← becomes 1 when the contract stores elevations in mm (metric canonicalization)
|
|
@@ -64,12 +69,27 @@ const num = (v) => {
|
|
|
64
69
|
};
|
|
65
70
|
|
|
66
71
|
/**
|
|
67
|
-
* A read-only, world-mm view over a steel contract.
|
|
72
|
+
* A read-only, world-mm view over a steel contract — v1 or v2, and the caller cannot tell which.
|
|
68
73
|
*
|
|
69
74
|
* `activeSheet` selects which sheet `grid()` answers for; it defaults to the contract's own `active` index,
|
|
70
|
-
* so a caller that does not care gets the sheet the editor has open.
|
|
75
|
+
* so a caller that does not care gets the sheet the editor has open. It is MEANINGLESS to a v2 model and
|
|
76
|
+
* documented as such on `createModelAdapterV2` — v2 has one model grid, not one per sheet.
|
|
77
|
+
*
|
|
78
|
+
* The dispatch is the type DISCRIMINATOR and nothing else, mirroring `isModelV2` (`steel-model-read.ts`)
|
|
79
|
+
* for the same reason it gives: it answers "does this document claim to be v2", never "is it usable".
|
|
80
|
+
* Validity is the server's to judge, and a read boundary that quietly fell back to the v1 arm for a
|
|
81
|
+
* malformed v2 document would answer with confident nonsense — a v2 member has no `wp`, so every method
|
|
82
|
+
* would report an absence rather than a problem. Mirrored rather than imported because that module is
|
|
83
|
+
* server TypeScript and this is a browser module; the same is true of the `dispToMm` mirror above.
|
|
71
84
|
*/
|
|
72
|
-
export function createModelAdapter(contract,
|
|
85
|
+
export function createModelAdapter(contract, opts = {}) {
|
|
86
|
+
return (contract && typeof contract === 'object' && contract.type === 'steel.model/v2')
|
|
87
|
+
? createModelAdapterV2(contract)
|
|
88
|
+
: createModelAdapterV1(contract, opts);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** The steel.takeoff/v1 arm — per-sheet display pixels and inch elevations, converted here to world mm. */
|
|
92
|
+
function createModelAdapterV1(contract, { activeSheet } = {}) {
|
|
73
93
|
const plans = (contract && Array.isArray(contract.plans)) ? contract.plans : [];
|
|
74
94
|
const planFor = (m) => plans.find(p => Array.isArray(p.members) && p.members.includes(m)) || null;
|
|
75
95
|
|
|
@@ -208,3 +228,133 @@ export function createModelAdapter(contract, { activeSheet } = {}) {
|
|
|
208
228
|
},
|
|
209
229
|
};
|
|
210
230
|
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* The steel.model/v2 arm (unit 5, P5) — INACTIVE. Same six methods, same world-mm contract, and no way
|
|
234
|
+
* for a caller to tell which arm it holds. That indistinguishability is the point: epic §15 answer 4
|
|
235
|
+
* chose "the inactive gate, at the ADAPTER BOUNDARY — not scattered `if (v2)` branches through the editor
|
|
236
|
+
* closure", so this file is where the version knowledge stops.
|
|
237
|
+
*
|
|
238
|
+
* NOTHING REACHES IT YET, and that is P5's premise rather than an oversight: no `<script>` loads this
|
|
239
|
+
* module, `renderers.js` has no `steel.model/v2` entry, and every steel route refuses a v2 document
|
|
240
|
+
* (`steel-model-gate.test.ts`). Opening a v2 contract is P7's registration act.
|
|
241
|
+
*
|
|
242
|
+
* `activeSheet` IS DELIBERATELY NOT ACCEPTED. In v1 it selects which sheet `grid()` answers for; v2 has
|
|
243
|
+
* ONE model grid in world mm ("v1 had one grid PER PLAN in that plan's display space, which is half of
|
|
244
|
+
* why sheets were never registered to a common frame" — `$defs.modelGrid`), so there is nothing for it to
|
|
245
|
+
* select. Taking the option and ignoring it would read as support.
|
|
246
|
+
*
|
|
247
|
+
* THE CONVERSIONS ALL DISAPPEAR HERE, which is the whole reason v2 exists: work points are stored in
|
|
248
|
+
* world mm, so there is no px scale, no Y negation, no inches, and no `default_tos`. What remains is the
|
|
249
|
+
* elevation union, and `memberGeometryV2` owns it — see that function for why a v2 column is not plumbed.
|
|
250
|
+
*/
|
|
251
|
+
function createModelAdapterV2(contract) {
|
|
252
|
+
const members = (contract && Array.isArray(contract.members)) ? contract.members : [];
|
|
253
|
+
const memberById = (id) => members.find((m) => m && m.id === id);
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* The member's two world-mm work points as NAMED endpoints, or null when either elevation is unknown
|
|
257
|
+
* or the record is malformed.
|
|
258
|
+
*
|
|
259
|
+
* `memberGeometryV2` already answers this; what this adds is shape. It returns `line[0]`/`line[1]` to
|
|
260
|
+
* match the v1 `memberGeometry` its consumers expect, and reading an ARRAY position back out under
|
|
261
|
+
* `noUncheckedIndexedAccess` makes the result optional — which widened `createModelAdapter`'s inferred
|
|
262
|
+
* `geometry()` union until `g.from` read as possibly-undefined at every existing v1 call site. Naming
|
|
263
|
+
* the endpoints once, here, keeps both arms inferring the same return type.
|
|
264
|
+
*
|
|
265
|
+
* THE DESTRUCTURING DEFAULTS ARE UNREACHABLE, and are here for the type checker alone: a non-null
|
|
266
|
+
* `memberGeometryV2` always carries a two-point line of three finite numbers each, having already
|
|
267
|
+
* refused a malformed endpoint and an unknown elevation. Said plainly so the next reader does not
|
|
268
|
+
* infer a runtime possibility that the callee has already excluded — and so that removing them is
|
|
269
|
+
* understood to be a typechecking decision, not a safety one.
|
|
270
|
+
*/
|
|
271
|
+
const ends = (m) => {
|
|
272
|
+
const g = memberGeometryV2(m);
|
|
273
|
+
if (!g) return null;
|
|
274
|
+
const [a = [], b = []] = g.line;
|
|
275
|
+
const [ax, ay, az] = a, [bx, by, bz] = b;
|
|
276
|
+
return { from: [ax, ay, az], to: [bx, by, bz], z0: Number(az), z1: Number(bz) };
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
return {
|
|
280
|
+
/**
|
|
281
|
+
* Every member in the model. v2 holds ONE root array — `members` is not a plan property at all — so
|
|
282
|
+
* this is the whole model by construction rather than by flattening.
|
|
283
|
+
*
|
|
284
|
+
* A FRESH array of LIVE member objects, exactly as the v1 arm returns: the elements are the contract's
|
|
285
|
+
* own records (P3's mutation commands operate on these), while the array is a copy so that a caller's
|
|
286
|
+
* `push`/`splice` cannot add or drop a member behind the write boundary's back.
|
|
287
|
+
*/
|
|
288
|
+
members() {
|
|
289
|
+
return members.slice();
|
|
290
|
+
},
|
|
291
|
+
|
|
292
|
+
/** The member with this id, or undefined. Ids are model-global in v2, so "first match" is the match. */
|
|
293
|
+
memberById,
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* The member's WORK LINE in world mm — the two stored work points, verbatim.
|
|
297
|
+
*
|
|
298
|
+
* Null for an unknown id, malformed work points, or an endpoint whose elevation is `{unknown}`. An
|
|
299
|
+
* unknown elevation is an RFI, not a position, so it is never guessed — the same refusal the v1 arm
|
|
300
|
+
* makes for an unreadable `tos`, and the one `sceneFromModel` makes by declining to build at all.
|
|
301
|
+
*
|
|
302
|
+
* `frame` is a SPACE TAG naming the coordinate space, not a local UCS — as in the v1 arm.
|
|
303
|
+
*/
|
|
304
|
+
geometry(id) {
|
|
305
|
+
const e = ends(memberById(id));
|
|
306
|
+
return e ? { from: e.from, to: e.to, frame: 'world-mm' } : null;
|
|
307
|
+
},
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* THE model grid, or null. Returned AS STORED — grid-core owns the notation, which v2 keeps unchanged;
|
|
311
|
+
* only its coordinates became world mm. `inferGridMm` is the sibling that proposes one.
|
|
312
|
+
*
|
|
313
|
+
* Unlike v1 this does not depend on which sheet is active, because there is nothing per-sheet left to
|
|
314
|
+
* depend on. A v2 plan has no `grid` property at all.
|
|
315
|
+
*/
|
|
316
|
+
grid() {
|
|
317
|
+
return (contract && contract.grid) || null;
|
|
318
|
+
},
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Always null for v2 — and this is an answer, not a gap.
|
|
322
|
+
*
|
|
323
|
+
* A v2 plan still carries `frame`, and it is still stored in that plan's DISPLAY space by design
|
|
324
|
+
* ("epic §10 keeps plan frame/dims local" — `$defs.frame`; migration copies it verbatim). The
|
|
325
|
+
* transform that would carry it into world mm is the SHEET REGISTRATION, and that is computed during
|
|
326
|
+
* migration and never persisted: `steel-model-migrate.ts` feeds each `registerSheet` result straight
|
|
327
|
+
* into `materializeMembers`, and the stored `migration` block keeps only id maps.
|
|
328
|
+
*
|
|
329
|
+
* So the only conversion available here — scale by `pt_per_ft` and flip Y, as the v1 arm does — would
|
|
330
|
+
* yield a SHEET-LOCAL mm frame published under a WORLD-mm contract. That is the same fabrication this
|
|
331
|
+
* boundary refuses when it reports null instead of substituting `default_tos` for an unreadable
|
|
332
|
+
* elevation, and it would be harder to notice: a plausible frame, silently in the wrong space.
|
|
333
|
+
*
|
|
334
|
+
* A real answer is derivable — resolve `datum_ref`/`control2_ref` against the model grid, pair them
|
|
335
|
+
* with `datum_at`/`control2_at`, and run the existing `registerSheet` — but that re-implements
|
|
336
|
+
* migration's `registerSheets` and is activation machinery, so it is recorded as P7's in the P5 design
|
|
337
|
+
* note rather than improvised here. Meanwhile null is this method's existing, tested vocabulary for
|
|
338
|
+
* "this sheet uses global axes", and every caller already handles it.
|
|
339
|
+
*/
|
|
340
|
+
sheetFrame() {
|
|
341
|
+
return null;
|
|
342
|
+
},
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* The member's single top-of-steel elevation in mm, or null when it does not have one.
|
|
346
|
+
*
|
|
347
|
+
* Identical rule to v1, over a different storage: a column spans base→top by definition and so has no
|
|
348
|
+
* one level (read `geometry(id).to[2]` for its top), a member with an unknown endpoint has none to
|
|
349
|
+
* report, and two ends further apart than the pinned authoring quantum are a slope rather than a
|
|
350
|
+
* level. Null means "no one elevation", never zero.
|
|
351
|
+
*/
|
|
352
|
+
elevationOf(id) {
|
|
353
|
+
const m = memberById(id);
|
|
354
|
+
if (!m || m.role === 'column') return null;
|
|
355
|
+
const e = ends(m);
|
|
356
|
+
if (!e) return null;
|
|
357
|
+
return Math.abs(e.z0 - e.z1) <= MODEL_V2_TOL.CUT_PLANE_MM ? e.z0 : null;
|
|
358
|
+
},
|
|
359
|
+
};
|
|
360
|
+
}
|