@floless/app 0.174.1 → 0.175.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/autostart.mjs +117 -10
- package/dist/floless-server.cjs +2 -2
- package/dist/pdf-engine/floless_pdf/__init__.py +7 -3
- package/dist/pdf-engine/floless_pdf/backend_pdfium.py +292 -13
- package/dist/pdf-engine/floless_pdf/backend_pymupdf.py +25 -3
- package/dist/pdf-engine/floless_pdf/images.py +4 -3
- package/dist/pdf-engine/floless_pdf/pages.py +136 -0
- package/dist/schemas/steel.model.v2.schema.json +44 -1
- package/dist/skills/floless-app-approval/SKILL.md +28 -3
- package/dist/skills/floless-app-knowledge/SKILL.md +3 -2
- package/dist/skills/floless-app-sketches/SKILL.md +71 -0
- package/dist/skills/floless-app-sketches/references/steel-plate.md +15 -0
- package/dist/skills/floless-app-steel-model/SKILL.md +11 -1
- package/dist/skills/floless-app-steel-model/references/elements.md +90 -23
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +11 -6
- package/dist/web/agents.js +1 -1
- package/dist/web/app.css +120 -15
- package/dist/web/app.js +89 -38
- package/dist/web/aware-hold.js +10 -0
- package/dist/web/aware.js +405 -51
- package/dist/web/boot-watchdog.js +249 -0
- package/dist/web/card-details.js +88 -0
- package/dist/web/chat.css +29 -0
- package/dist/web/chat.js +430 -128
- package/dist/web/commands-connection-design.js +23 -0
- package/dist/web/commands-revit.js +3 -0
- package/dist/web/commands-shell.js +226 -10
- package/dist/web/commands-steel.js +93 -4
- package/dist/web/commands-tekla-parser.js +21 -1
- package/dist/web/connection-design-editor.html +71 -0
- package/dist/web/connection-design-editor.js +794 -61
- package/dist/web/connection-design-handles.js +9 -3
- package/dist/web/element-approval.js +74 -0
- package/dist/web/element-context.js +76 -6
- package/dist/web/element-geometry.js +8 -2
- package/dist/web/element-holds.js +68 -5
- package/dist/web/element-type-actions.js +22 -3
- package/dist/web/element-types.js +12 -5
- package/dist/web/element-words.js +15 -11
- package/dist/web/grid-place.js +51 -0
- package/dist/web/guide.js +2 -0
- package/dist/web/index.html +13 -16
- package/dist/web/instructor.js +5 -2
- package/dist/web/missed-routines.js +6 -1
- package/dist/web/model-change-findings.js +100 -30
- package/dist/web/model-change-review.js +411 -27
- package/dist/web/model-clash-check.css +100 -0
- package/dist/web/model-clash-check.js +681 -0
- package/dist/web/model-clip-box.js +204 -0
- package/dist/web/model-clip-list.js +153 -3
- package/dist/web/model-clip-session.js +3 -3
- package/dist/web/model-clip-three-overlay.js +135 -25
- package/dist/web/model-editor.css +2 -0
- package/dist/web/model-elements.js +273 -18
- package/dist/web/model-fit-checks.js +354 -0
- package/dist/web/model-spatial-panel.js +9 -3
- package/dist/web/model-spatial-tools.js +12 -3
- package/dist/web/model-tekla-selection.js +74 -0
- package/dist/web/model-view-query.js +70 -14
- package/dist/web/model-viewport-revit-adapter.js +8 -7
- package/dist/web/model-viewport-toolbar.js +8 -4
- package/dist/web/pages.js +78 -1
- package/dist/web/project-history.js +31 -1
- package/dist/web/revit-editor.css +34 -1
- package/dist/web/revit-editor.js +174 -55
- package/dist/web/run-history.js +8 -0
- package/dist/web/sketch-editor.js +141 -2
- package/dist/web/sketches.js +192 -6
- package/dist/web/start-place.js +46 -0
- package/dist/web/steel-3d-core.js +70 -0
- package/dist/web/steel-3d-view.js +288 -47
- package/dist/web/steel-change-review.css +28 -0
- package/dist/web/steel-custom-connection.js +6 -0
- package/dist/web/steel-editor.html +532 -33
- package/dist/web/steel-filter.html +8 -3
- package/dist/web/steel-model-checks.css +76 -0
- package/dist/web/steel-model-v2-commands.js +17 -0
- package/dist/web/steel-view-generation.js +6 -2
- package/dist/web/teams.js +259 -19
- package/dist/web/tekla-editor.html +1 -0
- package/dist/web/terminal-requests.js +6 -0
- package/dist/web/vendor/connection-engine.js +886 -91
- package/dist/web/workspaces.js +630 -48
- package/package.json +2 -1
- package/preferences-file.mjs +27 -0
|
@@ -44,7 +44,7 @@ const stateWords = (h) => (h.state === 'conflict' ? 'breaks a rule' : h.state ==
|
|
|
44
44
|
/** The compact conflict line beside a pill (slice 2c), cut short on a narrow canvas; the whole line is the tooltip. */
|
|
45
45
|
const clipLine = (s) => (s.length > 40 ? `${s.slice(0, 39)}…` : s);
|
|
46
46
|
|
|
47
|
-
export function createHandles({ host, view, getEngine, onCommit, onSolve, onPreview, onCancel, onIdle, announce }) {
|
|
47
|
+
export function createHandles({ host, view, getEngine, onCommit, onSolve, onPreview, onCancel, onIdle, onMenu, announce }) {
|
|
48
48
|
const svg = el('svg', { id: 'handleLayer', 'aria-label': 'Dimensions of the connection', role: 'group' });
|
|
49
49
|
svg.style.cssText = 'position:absolute;inset:0;width:100%;height:100%;pointer-events:none;overflow:visible';
|
|
50
50
|
const defs = el('defs', {}, svg);
|
|
@@ -115,7 +115,13 @@ export function createHandles({ host, view, getEngine, onCommit, onSolve, onPrev
|
|
|
115
115
|
n.hit.addEventListener('pointerdown', (e) => beginDrag(h, e));
|
|
116
116
|
n.pill.style.pointerEvents = 'all'; n.text.style.pointerEvents = 'none';
|
|
117
117
|
n.pill.addEventListener('pointerdown', (e) => beginDrag(h, e));
|
|
118
|
-
g.addEventListener('keydown', (e) =>
|
|
118
|
+
g.addEventListener('keydown', (e) => {
|
|
119
|
+
// Slice 2d: Shift+F10 or the menu key opens the rule menu of the param this dimension moves.
|
|
120
|
+
if ((e.key === 'F10' && e.shiftKey) || e.key === 'ContextMenu') { e.preventDefault(); e.stopPropagation(); if (!H.drag) onMenu?.(h, g); return; }
|
|
121
|
+
onKey(h, e);
|
|
122
|
+
});
|
|
123
|
+
// Right-click opens the same menu; a click still only selects, and never changes the design.
|
|
124
|
+
g.addEventListener('contextmenu', (e) => { e.preventDefault(); e.stopPropagation(); if (!H.drag) onMenu?.(h, g); });
|
|
119
125
|
g.addEventListener('focus', () => { H.focus = h.id; H.dirty = true; warmSession(h); });
|
|
120
126
|
g.addEventListener('blur', () => { if (H.focus === h.id) H.focus = null; H.dirty = true; });
|
|
121
127
|
}
|
|
@@ -123,7 +129,7 @@ export function createHandles({ host, view, getEngine, onCommit, onSolve, onPrev
|
|
|
123
129
|
g.addEventListener('pointerleave', () => { if (H.hover === h.id) H.hover = null; H.dirty = true; });
|
|
124
130
|
const line = h.factId && H.lines[h.factId] ? ` ${H.lines[h.factId]}.` : '';
|
|
125
131
|
const tip = h.drives
|
|
126
|
-
? `${h.label}: ${stateWords(h)}.${line} Drag, or use the arrow keys.`
|
|
132
|
+
? `${h.label}: ${stateWords(h)}.${line} Drag, or use the arrow keys. Right-click (or Shift+F10) for its rules.`
|
|
127
133
|
: `${h.label}: ${stateWords(h)}.${line} ${h.fixed || ''}`.trim();
|
|
128
134
|
g.setAttribute('data-tip', tip);
|
|
129
135
|
nodes.set(h.id, n);
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The comparison with the approved version (#3680 part C, C1-C3; plan docs/superpowers/specs/2026-11-22-e1c-part-c-PLAN.md).
|
|
3
|
+
*
|
|
4
|
+
* The server proves the project's approval (`server/approval-ledger.ts`) and hands its density sources to every
|
|
5
|
+
* evaluation (`elementEvaluationFor` → `evaluationContextFor`, which freezes them as `ctx.approval` and resolves every
|
|
6
|
+
* approved row in the same catalogue snapshot as the working types' rows). This module compares, per element, the
|
|
7
|
+
* catalogue state each approved layer was worked out on with today's resolution of THE SAME ROW. It never reads the
|
|
8
|
+
* working element's current type (E1a drift plan rev 2, P1 1): retyping away and back, deleting and placing again, or an
|
|
9
|
+
* edit into another hold of its own cannot hide the change or clear it.
|
|
10
|
+
*
|
|
11
|
+
* Only catalogue states are compared (round-2 fold 3): a person's density the approval used, on a row that still gives
|
|
12
|
+
* none, is unchanged; when the row later gains a density, that is a change. The engine (`element-holds.js`) turns a
|
|
13
|
+
* change into the hold; this module decides nothing about holds, labels or counting. Pure.
|
|
14
|
+
*/
|
|
15
|
+
import { canonicalValue, digestOf, isObj } from './element-base.js';
|
|
16
|
+
|
|
17
|
+
const text = (v) => (typeof v === 'string' ? v : null);
|
|
18
|
+
const num = (v) => (typeof v === 'number' && Number.isFinite(v) ? v : null);
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* What a catalogue row gives, in the shape the approval recorded (`ApprovalSource.catalogue`): its density only when
|
|
22
|
+
* the row itself gives one, its provider, version and source digest. Null when the row does not resolve.
|
|
23
|
+
* @param {any} material a resolved row (`materialFromCatalogueRow`), or null
|
|
24
|
+
*/
|
|
25
|
+
export function catalogueStateOf(material) {
|
|
26
|
+
if (!isObj(material)) return null;
|
|
27
|
+
const ref = isObj(material.ref) ? material.ref : {};
|
|
28
|
+
const provider = isObj(ref.provider) ? ref.provider : {};
|
|
29
|
+
const density = isObj(material.density) ? material.density : null;
|
|
30
|
+
return {
|
|
31
|
+
kgM3: density && density.status === 'catalogue' ? num(density.kgM3) : null,
|
|
32
|
+
providerId: text(provider.id), providerVersion: text(provider.version), sourceSha256: text(ref.sourceSha256),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** The row an approved layer names, as the catalogue resolves it. */
|
|
37
|
+
export const approvedRowOf = (source) => ({ class: source?.class ?? null, environment: source?.environment ?? null, catalogId: source?.catalogId ?? null });
|
|
38
|
+
|
|
39
|
+
/** An approved element's sources (an array), `'no-stored-result'`, or undefined when the approval does not hold it. */
|
|
40
|
+
export function approvedSourcesOf(approval, id) {
|
|
41
|
+
if (!isObj(approval) || approval.state !== 'approved' || !isObj(approval.sources)) return undefined;
|
|
42
|
+
return Object.prototype.hasOwnProperty.call(approval.sources, id) ? approval.sources[id] : undefined;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Whether element `id`'s approved densities still are what the catalogue gives today, from the frozen approval and
|
|
47
|
+
* the context's resolver. Null when there is nothing to compare (no approval, one that could not be read, an element
|
|
48
|
+
* not in it, one approved with no saved values) or nothing changed. Otherwise the change: the approved version and
|
|
49
|
+
* date, the two fingerprints that identify it (`approved`: the element's approved sources; `today`: today's state of
|
|
50
|
+
* those same rows; parent plan C3 and round-1 fold 1), and each changed layer's `{ was, now }` (`now` null when the
|
|
51
|
+
* row no longer resolves).
|
|
52
|
+
* @param {any} approval `ctx.approval`
|
|
53
|
+
* @param {string} id
|
|
54
|
+
* @param {((ref: any) => any) | null} resolve `ctx.resolve`
|
|
55
|
+
*/
|
|
56
|
+
export function approvalDensityDrift(approval, id, resolve) {
|
|
57
|
+
const sources = approvedSourcesOf(approval, id);
|
|
58
|
+
if (!Array.isArray(sources) || !sources.length) return null;
|
|
59
|
+
const today = sources.map((s) => {
|
|
60
|
+
let row = null;
|
|
61
|
+
if (typeof resolve === 'function') { try { row = resolve(approvedRowOf(s)) ?? null; } catch { row = null; } }
|
|
62
|
+
return catalogueStateOf(row);
|
|
63
|
+
});
|
|
64
|
+
const layers = [];
|
|
65
|
+
sources.forEach((s, i) => {
|
|
66
|
+
const was = isObj(s) && isObj(s.catalogue) ? s.catalogue : null;
|
|
67
|
+
if (digestOf(canonicalValue(was)) !== digestOf(canonicalValue(today[i]))) layers.push({ ...approvedRowOf(s), was, now: today[i] });
|
|
68
|
+
});
|
|
69
|
+
if (!layers.length) return null;
|
|
70
|
+
return {
|
|
71
|
+
approvedVersion: approval.version, approvedAt: approval.at ?? null,
|
|
72
|
+
approved: digestOf(canonicalValue(sources)), today: digestOf(canonicalValue(today)), layers,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
@@ -51,7 +51,7 @@ export function contextOf(doc, opts = {}) {
|
|
|
51
51
|
if (isEvaluationContext(opts) || (isObj(opts) && opts[PLAIN_CONTEXT] === true)) return opts;
|
|
52
52
|
return {
|
|
53
53
|
[PLAIN_CONTEXT]: true,
|
|
54
|
-
resolve: opts
|
|
54
|
+
resolve: resolverOf(opts), environment: elementEnvironment(doc, opts.projectEnvironment),
|
|
55
55
|
typeKeys: isObj(opts.typeKeys) ? opts.typeKeys : null,
|
|
56
56
|
};
|
|
57
57
|
}
|
|
@@ -69,6 +69,48 @@ function materialRefOf(t) {
|
|
|
69
69
|
}
|
|
70
70
|
const refKey = (ref) => canonicalJson(canonicalValue({ class: ref.class, environment: ref.environment, catalogId: ref.catalogId }));
|
|
71
71
|
|
|
72
|
+
/**
|
|
73
|
+
* The catalogue an evaluation reads: the resolver it was given; else, for a context rebuilt from plain data
|
|
74
|
+
* (`catalogue`, the rows a frozen context resolved, keyed by row: `serializableEvaluation`), an answer from those rows
|
|
75
|
+
* only, so a worker that cannot receive a function never reads a live catalogue (#3680 part C, round-3 fold 2); else
|
|
76
|
+
* the server's registered one. A row the snapshot does not hold reads as not in the catalogue.
|
|
77
|
+
*/
|
|
78
|
+
function resolverOf(opts) {
|
|
79
|
+
if (opts.resolve !== undefined) return opts.resolve;
|
|
80
|
+
if (isObj(opts.catalogue)) {
|
|
81
|
+
const rows = opts.catalogue;
|
|
82
|
+
return (ref) => {
|
|
83
|
+
if (!isObj(ref) || typeof ref.catalogId !== 'string') return null;
|
|
84
|
+
const key = refKey(ref);
|
|
85
|
+
return Object.prototype.hasOwnProperty.call(rows, key) && isObj(rows[key]) ? rows[key] : null;
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
return registeredResolve;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const deepFreeze = (v) => { if (v && typeof v === 'object') { for (const x of Object.values(v)) deepFreeze(x); Object.freeze(v); } return v; };
|
|
92
|
+
/**
|
|
93
|
+
* The approval an evaluation compares with (#3680 part C, C1), as the server proved it (`elementEvaluationFor`):
|
|
94
|
+
* `{ state: 'approved', version, at, sources }` (sources by element id: the approved layers, or 'no-stored-result'),
|
|
95
|
+
* `{ state: 'unavailable', reason }`, `{ state: 'none' }`, or null when none was given. Frozen plain data, so it
|
|
96
|
+
* crosses JSON and a worker unchanged (`sources` may arrive as a Map or as an object). An approved record that is not
|
|
97
|
+
* well formed is unavailable, never "nothing to compare".
|
|
98
|
+
*/
|
|
99
|
+
function frozenApproval(a) {
|
|
100
|
+
if (!isObj(a)) return null;
|
|
101
|
+
if (a.state === 'none') return Object.freeze({ state: 'none' });
|
|
102
|
+
if (a.state !== 'approved' || !Number.isSafeInteger(a.version) || !(a.sources instanceof Map || isObj(a.sources))) {
|
|
103
|
+
return Object.freeze({ state: 'unavailable', reason: a.state === 'unavailable' && typeof a.reason === 'string' ? a.reason : 'approval-malformed' });
|
|
104
|
+
}
|
|
105
|
+
const entries = (a.sources instanceof Map ? [...a.sources] : Object.entries(a.sources)).filter(([id]) => typeof id === 'string').sort(([x], [y]) => (x < y ? -1 : x > y ? 1 : 0));
|
|
106
|
+
const sources = {};
|
|
107
|
+
for (const [id, v] of entries) {
|
|
108
|
+
// Defined, never assigned, so an element id such as "__proto__" is a key like any other.
|
|
109
|
+
Object.defineProperty(sources, id, { value: Array.isArray(v) ? canonicalValue(v) : 'no-stored-result', enumerable: true });
|
|
110
|
+
}
|
|
111
|
+
return deepFreeze({ state: 'approved', version: a.version, at: typeof a.at === 'string' ? a.at : null, sources });
|
|
112
|
+
}
|
|
113
|
+
|
|
72
114
|
/**
|
|
73
115
|
* The one immutable evaluation context of a model (hold-engine plan, "An explicit, immutable evaluation context"): the
|
|
74
116
|
* environment under the one rule; the catalogue, every row the model's types name resolved ONCE, here, and nowhere
|
|
@@ -77,14 +119,23 @@ const refKey = (ref) => canonicalJson(canonicalValue({ class: ref.class, environ
|
|
|
77
119
|
* (the keys of the stored document a save replaces, `typeKeysOf`). Frozen: identical arguments always give identical
|
|
78
120
|
* answers, and nothing an engine function is handed changes under it.
|
|
79
121
|
* @param {any} model
|
|
80
|
-
* @param {{ projectEnvironment?: unknown, resolve?: ((ref: any) => any) | null, registry?: Record<string, string> | null, typeKeys?: Record<string, string> | null, storedKeys?: Iterable<string> | null, stored?: any }} [opts]
|
|
122
|
+
* @param {{ projectEnvironment?: unknown, resolve?: ((ref: any) => any) | null, registry?: Record<string, string> | null, typeKeys?: Record<string, string> | null, storedKeys?: Iterable<string> | null, stored?: any, approval?: any }} [opts]
|
|
81
123
|
*/
|
|
82
124
|
export function evaluationContextFor(model, opts = {}) {
|
|
83
125
|
if (isEvaluationContext(opts)) return opts;
|
|
84
|
-
const resolve = opts
|
|
126
|
+
const resolve = resolverOf(opts);
|
|
85
127
|
const catalogue = {};
|
|
86
|
-
|
|
87
|
-
|
|
128
|
+
const approval = frozenApproval(opts.approval);
|
|
129
|
+
// Every row the model's types name, and every row an approved element was worked out on, whether or not a working
|
|
130
|
+
// type still names it (part C, round-1 fold 2): the comparison reads today's state of the approved row itself.
|
|
131
|
+
const refs = (Array.isArray(model?.element_types) ? model.element_types : []).map(materialRefOf);
|
|
132
|
+
if (approval?.state === 'approved') {
|
|
133
|
+
for (const layers of Object.values(approval.sources)) {
|
|
134
|
+
if (!Array.isArray(layers)) continue;
|
|
135
|
+
for (const s of layers) if (isObj(s) && typeof s.class === 'string' && typeof s.environment === 'string' && typeof s.catalogId === 'string') refs.push({ class: s.class, environment: s.environment, catalogId: s.catalogId });
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
for (const ref of refs) {
|
|
88
139
|
if (!ref) continue;
|
|
89
140
|
const key = refKey(ref);
|
|
90
141
|
if (key in catalogue) continue;
|
|
@@ -101,10 +152,29 @@ export function evaluationContextFor(model, opts = {}) {
|
|
|
101
152
|
return Object.freeze({
|
|
102
153
|
[CONTEXT]: true,
|
|
103
154
|
environment: elementEnvironment(model, opts.projectEnvironment),
|
|
104
|
-
catalogue, registry, storedKeys,
|
|
155
|
+
catalogue, registry, storedKeys, approval,
|
|
105
156
|
// The readers below layer 6 ask `resolve(ref)`; in a context it answers only from the snapshot.
|
|
106
157
|
resolve: hasCatalogue ? (ref) => (isObj(ref) && typeof ref.catalogId === 'string' ? catalogue[refKey(ref)] ?? null : null) : null,
|
|
107
158
|
// The old name of the registry, for readers that still ask for it.
|
|
108
159
|
typeKeys: registry,
|
|
109
160
|
});
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* A model's frozen evaluation context as plain JSON-safe data (#3680 part C, round-3 fold 2): the project's environment,
|
|
165
|
+
* the record status of every key, the approval it compares with, and every catalogue row it resolved. Handed to
|
|
166
|
+
* `evaluationContextFor` (or any reader's options) elsewhere, for instance in the approval bake's worker, it gives the
|
|
167
|
+
* same answers without a resolver function and without reading the live catalogue there.
|
|
168
|
+
* @param {any} model
|
|
169
|
+
* @param {Parameters<typeof evaluationContextFor>[1]} [opts]
|
|
170
|
+
*/
|
|
171
|
+
export function serializableEvaluation(model, opts = {}) {
|
|
172
|
+
const ctx = evaluationContextFor(model, opts);
|
|
173
|
+
const plain = (v) => (v == null ? v : JSON.parse(JSON.stringify(v)));
|
|
174
|
+
return {
|
|
175
|
+
projectEnvironment: ctx.environment,
|
|
176
|
+
typeKeys: plain(ctx.registry),
|
|
177
|
+
...(ctx.approval ? { approval: plain(ctx.approval) } : {}),
|
|
178
|
+
...(typeof ctx.resolve === 'function' ? { catalogue: plain(ctx.catalogue) } : {}),
|
|
179
|
+
};
|
|
110
180
|
}
|
|
@@ -17,10 +17,16 @@ const mul = (a, k) => [a[0] * k, a[1] * k];
|
|
|
17
17
|
const len = (a) => Math.hypot(a[0], a[1]);
|
|
18
18
|
const cross = (a, b) => a[0] * b[1] - a[1] * b[0];
|
|
19
19
|
|
|
20
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* Signed area (mm²), positive when counter-clockwise. Summed relative to the ring's first vertex, so a georeferenced
|
|
22
|
+
* ring (coordinates of 1e9 mm) measures what the same ring does at the origin: the shoelace's absolute products
|
|
23
|
+
* (~1e18) round by more than a thin piece's whole area.
|
|
24
|
+
*/
|
|
21
25
|
export function signedArea(ring) {
|
|
26
|
+
if (ring.length < 3) return 0;
|
|
27
|
+
const o = ring[0];
|
|
22
28
|
let s = 0;
|
|
23
|
-
for (let i =
|
|
29
|
+
for (let i = 1; i < ring.length - 1; i++) s += cross(sub(ring[i], o), sub(ring[i + 1], o));
|
|
24
30
|
return s / 2;
|
|
25
31
|
}
|
|
26
32
|
const ccw = (ring) => (signedArea(ring) < 0 ? [...ring].reverse() : ring);
|
|
@@ -30,7 +30,8 @@ import {
|
|
|
30
30
|
wallSolid,
|
|
31
31
|
} from './element-geometry.js';
|
|
32
32
|
import { boundDensityAssumption, elementInputsDigest } from './element-binding.js';
|
|
33
|
-
import { EDIT_CARD, MAP_CARD, TYPE_CARD, distinctOffers, fixOffer, typeActionsFor, typeOffers, unjoinOffer } from './element-type-actions.js';
|
|
33
|
+
import { EDIT_CARD, MAP_CARD, TYPE_CARD, distinctOffers, fixOffer, reapproveOffer, typeActionsFor, typeOffers, unjoinOffer } from './element-type-actions.js';
|
|
34
|
+
import { approvalDensityDrift } from './element-approval.js';
|
|
34
35
|
|
|
35
36
|
// ---- codes, statuses, cards -------------------------------------------------------------------------
|
|
36
37
|
|
|
@@ -48,10 +49,12 @@ export const HOLD_CODES = Object.freeze({
|
|
|
48
49
|
CORNER_INVALID: 'element-corner-invalid',
|
|
49
50
|
CORNER_PARTNER_HELD: 'element-corner-partner-held',
|
|
50
51
|
UNDER_HELD_WALL: 'element-under-held-wall',
|
|
52
|
+
DENSITY_CHANGED_SINCE_APPROVAL: 'element-density-changed-since-approval',
|
|
51
53
|
});
|
|
52
54
|
export const {
|
|
53
55
|
TYPE_CHOICE_OPEN, TYPE_NOT_MADE_HERE, TYPE_RECORD_UNCHECKED, KIND_VERSION_UNREADABLE, TYPE_NOT_CATALOGUE, TYPE_OTHER_KIND,
|
|
54
56
|
DENSITY_MISSING, PLACEMENT_INVALID, INPUT_INVALID, CORNER_INVALID, CORNER_PARTNER_HELD, UNDER_HELD_WALL,
|
|
57
|
+
DENSITY_CHANGED_SINCE_APPROVAL,
|
|
55
58
|
} = HOLD_CODES;
|
|
56
59
|
/** Every status an element can have. Decided only here. */
|
|
57
60
|
export const ELEMENT_STATUSES = Object.freeze(['verified', 'accepted', 'assumed', 'drifted', 'held', 'unknown', 'record']);
|
|
@@ -70,8 +73,17 @@ const STAGE_ONE = new Set([TYPE_CHOICE_OPEN, TYPE_NOT_MADE_HERE, TYPE_RECORD_UNC
|
|
|
70
73
|
|
|
71
74
|
// ---- identity -----------------------------------------------------------------------------------------
|
|
72
75
|
|
|
73
|
-
/**
|
|
74
|
-
|
|
76
|
+
/**
|
|
77
|
+
* A reason's identity: its code and canonical refs. Never its words. A drift's approved version is in its refs for
|
|
78
|
+
* audit and left out of its identity (#3680 part C, C3): an unrelated re-approval whose sources for the element are the
|
|
79
|
+
* same does not end a keep of it; its fingerprints do.
|
|
80
|
+
*/
|
|
81
|
+
const identityRefs = (code, refs) => {
|
|
82
|
+
if (code !== DENSITY_CHANGED_SINCE_APPROVAL || !isObj(refs)) return refs ?? {};
|
|
83
|
+
const { approvedVersion: _audit, ...rest } = refs;
|
|
84
|
+
return rest;
|
|
85
|
+
};
|
|
86
|
+
export const reasonKey = (code, refs) => `${code}|${canonicalJson(canonicalValue(identityRefs(code, refs)))}`;
|
|
75
87
|
const rootKey = (r) => `${r.owner}|${reasonKey(r.code, r.refs)}`;
|
|
76
88
|
const byKey = (a, b) => { const x = reasonKey(a.code, a.refs); const y = reasonKey(b.code, b.refs); return x < y ? -1 : x > y ? 1 : 0; };
|
|
77
89
|
const list = (v) => (Array.isArray(v) ? v : []);
|
|
@@ -167,6 +179,17 @@ export function densityChange(stored, now) {
|
|
|
167
179
|
return `its density changed since it was worked out: ${d(was)} from ${from(was)}, now ${d(is)} from ${from(is)}`;
|
|
168
180
|
}
|
|
169
181
|
|
|
182
|
+
/** A density changed since approval, named the way a detailer reads it: the approval, what it used and what is given now. */
|
|
183
|
+
export function densityChangedSentence(drift) {
|
|
184
|
+
const l = drift.layers[0];
|
|
185
|
+
const state = (c) => (!isObj(c) ? 'no catalogue row' : `${c.kgM3 === null ? 'no catalogue density' : `${c.kgM3} kg/m³`} from ${c.providerId ?? '?'} ${c.providerVersion ?? '?'}${c.sourceSha256 ? ` (${c.sourceSha256.slice(0, 12)})` : ''}`);
|
|
186
|
+
const more = drift.layers.length > 1 ? ` (and ${drift.layers.length - 1} more layer${drift.layers.length > 2 ? 's' : ''})` : '';
|
|
187
|
+
return `its density changed since approval v${drift.approvedVersion}${drift.approvedAt ? ` on ${String(drift.approvedAt).slice(0, 10)}` : ''}: material row ${l.catalogId ?? '?'} was ${state(l.was)}, now ${state(l.now)}${more}`;
|
|
188
|
+
}
|
|
189
|
+
const REAPPROVE_WAY = 're-approve to accept the new catalogue value (the approval screen, a person approves)';
|
|
190
|
+
/** Working the values out again while the drift holds (#3680 part C, step 4): never said as if it cleared it. */
|
|
191
|
+
const CORRECT_ON_TODAYS_ROW_WAY = 'work its values out again on today\'s catalogue (resolve-save, answer corrected); it stays held and still needs a person to re-approve';
|
|
192
|
+
|
|
170
193
|
// ---- the stages -----------------------------------------------------------------------------------------
|
|
171
194
|
|
|
172
195
|
/**
|
|
@@ -186,6 +209,16 @@ function reason(e, code, refs, text, extra = {}) {
|
|
|
186
209
|
}
|
|
187
210
|
const put = (m, r) => { const k = reasonKey(r.code, r.refs); if (!m.has(k)) m.set(k, r); return m.get(k); };
|
|
188
211
|
|
|
212
|
+
/**
|
|
213
|
+
* The approval comparison (#3680 part C, C2): keyed by the APPROVED rows and today's state of them, never by the
|
|
214
|
+
* working type. Collected for every element before stage (ii)'s unreadable-kind exit (round-2 fold 8), so the
|
|
215
|
+
* stored-values acceptance of an unreadable kind version never counts an element whose density changed.
|
|
216
|
+
*/
|
|
217
|
+
function approvalStage(e, ctx, R) {
|
|
218
|
+
const d = approvalDensityDrift(ctx.approval, e.id, ctx.resolve);
|
|
219
|
+
if (d) put(R, reason(e, DENSITY_CHANGED_SINCE_APPROVAL, { approvedVersion: d.approvedVersion, approved: d.approved, today: d.today }, densityChangedSentence(d)));
|
|
220
|
+
}
|
|
221
|
+
|
|
189
222
|
/** Stage (i): the element's type identity, read whatever its kind version or its type's payload. */
|
|
190
223
|
function stageOne(e, model, ctx, typeById, R) {
|
|
191
224
|
const c = isObj(e.typeChoice) ? e.typeChoice : null;
|
|
@@ -281,7 +314,7 @@ const CORNER_WORDS = {
|
|
|
281
314
|
* @param {any} model
|
|
282
315
|
* @param {any} [ctxIn] an `evaluationContextFor` context (or the options to build one)
|
|
283
316
|
* @param {Map<string, any>} [keeps] element id → keep record; each element's own `storedValues` by default
|
|
284
|
-
* @returns {Map<string, { element: any, fresh: any, freshFindings: any[], holds: Holds, status: any, selected: any }>}
|
|
317
|
+
* @returns {Map<string, { element: any, fresh: any, freshFindings: any[], holds: Holds, status: any, selected: any, correctable: boolean }>}
|
|
285
318
|
*/
|
|
286
319
|
export function evaluateElements(model, ctxIn = {}, keeps = undefined) {
|
|
287
320
|
const ctx = evaluationContextFor(model, ctxIn);
|
|
@@ -302,6 +335,7 @@ export function evaluateElements(model, ctxIn = {}, keeps = undefined) {
|
|
|
302
335
|
freshWhy.set(e.id, []);
|
|
303
336
|
if (e.kind === UNMODELLED && kindIsKnown(e)) continue;
|
|
304
337
|
stageOne(e, model, ctx, typeById, R);
|
|
338
|
+
approvalStage(e, ctx, R);
|
|
305
339
|
if (!kindIsKnown(e)) {
|
|
306
340
|
freshWhy.get(e.id).push(put(R, reason(e, KIND_VERSION_UNREADABLE, { kind: e.kind ?? null, kindVersion: e.kindVersion ?? null }, `FloLess cannot read "${e.kind}" version ${e.kindVersion}`)));
|
|
307
341
|
continue;
|
|
@@ -474,7 +508,10 @@ export function evaluateElements(model, ctxIn = {}, keeps = undefined) {
|
|
|
474
508
|
const holds = { reasons: R, keepable: reasonsList.every((r) => r.keepable), keptBy: keptByOf(e, model, ctx, reasonsList, rec) };
|
|
475
509
|
const f = fresh.get(e.id) ?? null;
|
|
476
510
|
const status = statusFrom(e, holds, model, ctx, f, rec, reads.get(e.id)?.person ?? null);
|
|
477
|
-
out.set(e.id, {
|
|
511
|
+
out.set(e.id, {
|
|
512
|
+
element: e, fresh: f, freshFindings: f ? [] : [...freshWhy.get(e.id)].sort(byKey), holds, status, selected: selectionOf(status.status, f, e), typeActions: typeActionsFor(e, model, ctx),
|
|
513
|
+
correctable: correctableOnTodaysRow(e, model, ctx, reasonsList, rec, f),
|
|
514
|
+
});
|
|
478
515
|
}
|
|
479
516
|
return out;
|
|
480
517
|
}
|
|
@@ -541,6 +578,23 @@ function keptByOf(e, model, ctx, reasonsList, rec) {
|
|
|
541
578
|
return reasonsList.every((r) => covers(cover, r)) ? rec : null;
|
|
542
579
|
}
|
|
543
580
|
|
|
581
|
+
/**
|
|
582
|
+
* Whether `resolve-save` may work this element's values out again on today's row while a density changed since
|
|
583
|
+
* approval holds it (#3680 part C, step 4; plan round-2 fold 1): a drift reason holds it, every other reason is one the
|
|
584
|
+
* person's own binding keep covers, FloLess can read it and work it out. It corrects the working copy only: the drift
|
|
585
|
+
* stays until a person approves, so the element stays held and uncounted. Any other open reason keeps today's answer.
|
|
586
|
+
* The one decision the edit route, the materializer and the ways on all read (the result's `correctable`).
|
|
587
|
+
*/
|
|
588
|
+
function correctableOnTodaysRow(e, model, ctx, reasonsList, rec, fresh) {
|
|
589
|
+
if (!fresh || !reasonsList.some((r) => r.code === DENSITY_CHANGED_SINCE_APPROVAL)) return false;
|
|
590
|
+
if (reasonsList.some((r) => r.code === KIND_VERSION_UNREADABLE || !r.keepable)) return false;
|
|
591
|
+
const others = reasonsList.filter((r) => r.code !== DENSITY_CHANGED_SINCE_APPROVAL);
|
|
592
|
+
if (!others.length) return true;
|
|
593
|
+
if (!isObj(rec) || rec.choice !== KEEP_HELD || !keepBinds(e, model, ctx, rec)) return false;
|
|
594
|
+
const cover = coveredBy(rec);
|
|
595
|
+
return others.every((r) => covers(cover, r));
|
|
596
|
+
}
|
|
597
|
+
|
|
544
598
|
/**
|
|
545
599
|
* The keep record a keep card writes; nothing else writes one. Pure: every input is an argument, the time included.
|
|
546
600
|
* @param {{ element: any, model: any, ctx: any, holds: Holds, statement: string, at: string }} args
|
|
@@ -992,6 +1046,15 @@ function waysOfOne(model, e, v, keep, waysOfPartner, results) {
|
|
|
992
1046
|
}
|
|
993
1047
|
if (code === CORNER_PARTNER_HELD && partner) return [way('fix', null, partner, `fix wall ${partner} (${results.get(partner)?.status?.reason ?? 'the reason given'})`), ...detach(model, e, partner), ...keep];
|
|
994
1048
|
if (code === CORNER_INVALID) return [way('fix', null, id, 'fix the corner (join or unjoin, model.edit-elements)'), ...keep];
|
|
1049
|
+
// Part C: a density changed since approval is settled by the person re-approving (human-only: the AI opens the
|
|
1050
|
+
// screen), or by keeping the saved values as an unverified assumption. Saved values still on the old density can be
|
|
1051
|
+
// worked out again on today's row first (step 4), which never clears the drift: its words say so.
|
|
1052
|
+
if (code === DENSITY_CHANGED_SINCE_APPROVAL) {
|
|
1053
|
+
const again = answer ? reapproveOffer(e, answer, REAPPROVE_WAY) : null;
|
|
1054
|
+
const r = results.get(id);
|
|
1055
|
+
const stale = r?.correctable === true && !(isObj(e.evaluated) && canonicalJson(e.evaluated) === canonicalJson(r.fresh));
|
|
1056
|
+
return [...(again ? [again] : []), ...(stale ? [way('resolve-corrected', EDIT_CARD, id, CORRECT_ON_TODAYS_ROW_WAY)] : []), ...keep];
|
|
1057
|
+
}
|
|
995
1058
|
// A placement or input fault, or anything else: fix it where it is, or keep the saved values where that keeps.
|
|
996
1059
|
return [way('fix', null, id, `fix what holds it (${EDIT_CARD})`), ...keep];
|
|
997
1060
|
}
|
|
@@ -15,9 +15,14 @@ import { typeInputs, typeProblem } from './element-types.js';
|
|
|
15
15
|
export const TYPE_CARD = 'model.update-element-type';
|
|
16
16
|
export const MAP_CARD = 'model.map-element-type';
|
|
17
17
|
export const EDIT_CARD = 'model.edit-elements';
|
|
18
|
+
/** The approval screen (`projects.approve`, human-only): re-approving is a person's sign-off, the AI only opens it. */
|
|
19
|
+
export const APPROVE_CARD = 'projects.approve';
|
|
18
20
|
|
|
19
|
-
/**
|
|
20
|
-
|
|
21
|
+
/**
|
|
22
|
+
* The type decisions, the detach and the re-approval this module owns: no element module but this one writes these
|
|
23
|
+
* names. `re-approve` joined them with #3680 part C: which elements a re-approval is offered on is decided here too.
|
|
24
|
+
*/
|
|
25
|
+
export const TYPE_ACTIONS = Object.freeze(['choose-type', 'map-type', 'set-type', 'keep-type', 'move-type', 'unjoin', 're-approve']);
|
|
21
26
|
|
|
22
27
|
const typeOf = (model, id) => (Array.isArray(model?.element_types) ? model.element_types : []).find((t) => isObj(t) && t.id === id) ?? null;
|
|
23
28
|
const lower = (kind) => kindWord(kind).toLowerCase();
|
|
@@ -80,7 +85,10 @@ export function typeActionsFor(e, model, ctx) {
|
|
|
80
85
|
const readable = changeable(e);
|
|
81
86
|
const choiceOpen = isObj(e?.typeChoice);
|
|
82
87
|
const unread = no(`${e?.id} is "${e?.kind}" version ${e?.kindVersion}, which this FloLess cannot read, so it cannot change it`);
|
|
83
|
-
|
|
88
|
+
// Re-approving takes a proven approval to approve past; it is the person's on the approval screen, never the AI's,
|
|
89
|
+
// and FloLess offers it whether or not it can read the element (approving changes nothing on it).
|
|
90
|
+
const reapprove = ctx?.approval?.state === 'approved' ? REAPPROVE : no('this project has no approved version FloLess could read to approve again');
|
|
91
|
+
if (!readable) return { readable, choiceOpen, on: null, choose: [], map: unread, setType: unread, keep: unread, reapprove };
|
|
84
92
|
const own = typeOf(model, e.typeId);
|
|
85
93
|
let on = null; const choose = [];
|
|
86
94
|
if (choiceOpen) {
|
|
@@ -93,8 +101,19 @@ export function typeActionsFor(e, model, ctx) {
|
|
|
93
101
|
map: choiceOpen ? mapAllowed(e) : own ? YES : no(`"${e.typeId}" is not a type in this model`),
|
|
94
102
|
setType: setTypeAllowed(e),
|
|
95
103
|
keep: own ? keepAllowed(e, own, ctx.environment, ctx.typeKeys) : no(`"${e.typeId}" is not a type in this model`),
|
|
104
|
+
reapprove,
|
|
96
105
|
};
|
|
97
106
|
}
|
|
107
|
+
const REAPPROVE = Object.freeze({ ok: true, humanOnly: true, card: APPROVE_CARD });
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* The re-approval offer for element `e`, when its answer from `typeActionsFor` allows one: human-only, so the AI only
|
|
111
|
+
* opens the approval screen where the person approves. Null otherwise.
|
|
112
|
+
* @param {any} e @param {ReturnType<typeof typeActionsFor>} a @param {string} label
|
|
113
|
+
*/
|
|
114
|
+
export function reapproveOffer(e, a, label) {
|
|
115
|
+
return a?.reapprove?.ok ? offer('re-approve', APPROVE_CARD, e.id, label, { humanOnly: true }) : null;
|
|
116
|
+
}
|
|
98
117
|
|
|
99
118
|
const offer = (action, card, element, label, extra = {}) => ({ action, card, element, label, ...extra });
|
|
100
119
|
|
|
@@ -235,7 +235,7 @@ export function typeSizeOf(t, key) {
|
|
|
235
235
|
* The name FloLess shows for a type, worked out every time ("Wall 200, C30/37"); never stored. A model type shows the
|
|
236
236
|
* name the person gave it. A catalogue type's material name is its row's, from the catalogue when one is at hand.
|
|
237
237
|
* @param {any} t
|
|
238
|
-
* @param {EvaluationOptions & { material?: any }} [opts] material: the material already resolved for it
|
|
238
|
+
* @param {EvaluationOptions & { material?: any, unread?: boolean }} [opts] material: the material already resolved for it; unread: false leaves out the "(its depth cannot be read)" note, for a sentence that says it itself
|
|
239
239
|
*/
|
|
240
240
|
export function typeDisplayName(t, opts = {}) {
|
|
241
241
|
if (!isObj(t)) return '';
|
|
@@ -252,10 +252,17 @@ export function typeDisplayName(t, opts = {}) {
|
|
|
252
252
|
const m = p.materialAssignment?.layers?.[0]?.material;
|
|
253
253
|
materialName = typeof m?.name === 'string' ? m.name : undefined;
|
|
254
254
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
255
|
+
// Each size the type gives, in order; one it does not give (or gives as something other than a positive length) is
|
|
256
|
+
// never printed as "undefined" or "?": the name lists the sizes it has and says which it cannot read (E1d step 5).
|
|
257
|
+
const dims = t.kind === FOOTING
|
|
258
|
+
? (p.form === 'pad' ? [['length', p.lengthMm], ['width', p.widthMm], ['depth', p.depthMm]] : p.form === 'strip' ? [['width', p.widthMm], ['depth', p.depthMm]] : [['depth', p.depthMm]])
|
|
259
|
+
: [['thickness', p.thicknessMm]];
|
|
260
|
+
const readable = (v) => num(v) && v > 0;
|
|
261
|
+
const sizes = dims.filter(([, v]) => readable(v)).map(([, v]) => v).join('x');
|
|
262
|
+
const unread = dims.filter(([, v]) => !readable(v)).map(([n]) => n);
|
|
263
|
+
const unreadNote = unread.length && opts.unread !== false
|
|
264
|
+
? ` (its ${unread.length > 1 ? `${unread.slice(0, -1).join(', ')} and ${unread[unread.length - 1]}` : unread[0]} cannot be read)` : '';
|
|
265
|
+
return `${kindWord(t.kind, p.form)}${sizes ? ` ${sizes}` : ''}${materialName ? `, ${materialName}` : ''}${unreadNote}`;
|
|
259
266
|
}
|
|
260
267
|
// ---- materials (design §5.2, §5.7) -------------------------------------------------------------------
|
|
261
268
|
|
|
@@ -8,21 +8,25 @@
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* What the fit check
|
|
12
|
-
*
|
|
13
|
-
* surface may show an all-clear for it (#3296 E1b, owner fallback 2026-11-17).
|
|
11
|
+
* What the fit check does not cover at all yet, said at the end of every fit summary (`fitSummarySentence`, server
|
|
12
|
+
* element-fit.ts), which states what was measured, what was found and what could not be measured (#3296 E1d §4).
|
|
14
13
|
*/
|
|
15
|
-
export const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
export const STEEL_MEETS_CONCRETE_NOT_CHECKED = 'Not checked yet: how steel meets concrete.';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* What a surface says when it shows walls, slabs and footings but has no fit measured to summarise (a plan whose
|
|
18
|
+
* reply carried none). It claims no coverage and no finding.
|
|
19
|
+
*/
|
|
20
|
+
export const ELEMENT_FIT_UNREAD = `How walls, slabs and footings fit was not measured for this view. ${STEEL_MEETS_CONCRETE_NOT_CHECKED}`;
|
|
19
21
|
|
|
20
22
|
/**
|
|
21
23
|
* The plan's note: why some elements are not shown (the cut, the registration), the ones it cannot draw, and, whenever
|
|
22
|
-
* it shows or names any element,
|
|
23
|
-
*
|
|
24
|
+
* it shows or names any element, the fit summary the evaluate reply carried (`fit.summary`: what was measured, found
|
|
25
|
+
* and not measured), or that no fit was measured for it. Null when there is nothing to say.
|
|
26
|
+
* @param {{ cutNote?: string | null, leftOut?: string | null, shown?: number, fitSummary?: string | null }} parts
|
|
24
27
|
*/
|
|
25
|
-
export function elementPlanNote({ cutNote = null, leftOut = null, shown = 0 } = {}) {
|
|
26
|
-
const
|
|
28
|
+
export function elementPlanNote({ cutNote = null, leftOut = null, shown = 0, fitSummary = null } = {}) {
|
|
29
|
+
const fit = typeof fitSummary === 'string' && fitSummary.trim() ? fitSummary : ELEMENT_FIT_UNREAD;
|
|
30
|
+
const parts = [cutNote, leftOut, shown > 0 || leftOut ? fit : null].filter(Boolean);
|
|
27
31
|
return parts.length ? parts.join(' ') : null;
|
|
28
32
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Where a point is on the model's grid, said the way a detailer would (#3296 E1d, plan
|
|
3
|
+
* 2026-11-24-e1d-fit-checks-PLAN.md §4): "C/1" on two grid lines, "between B and C, 1,250 mm from B, on 1" between
|
|
4
|
+
* them, and "no grid: at x 6,000, y 0 mm" when the model has none. Pure: it reads the grid's X and Y spacings and
|
|
5
|
+
* their labels through grid-core's one labelling rule (`axisLabelsFor`), so a fit finding names a grid line exactly as
|
|
6
|
+
* the plan's bubbles do.
|
|
7
|
+
*/
|
|
8
|
+
import { axisLabelsFor, parseSpacings } from './grid-core.js';
|
|
9
|
+
|
|
10
|
+
/** A point this close to a grid line (mm) is on it. */
|
|
11
|
+
const ON_LINE_MM = 0.5;
|
|
12
|
+
const fmt = (n) => Math.round(n).toLocaleString('en-US');
|
|
13
|
+
const isObj = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
|
|
14
|
+
|
|
15
|
+
/** The grid lines of one direction at their model positions, lowest first, or none. */
|
|
16
|
+
function linesOf(grid, dir) {
|
|
17
|
+
if (!isObj(grid) || typeof grid[dir] !== 'string' || !grid[dir].trim()) return [];
|
|
18
|
+
const parsed = parseSpacings(grid[dir]);
|
|
19
|
+
if (parsed.err || !parsed.offsets.length) return [];
|
|
20
|
+
const origin = Array.isArray(grid.origin) ? Number(grid.origin[dir === 'x' ? 0 : 1]) : 0;
|
|
21
|
+
const base = Number.isFinite(origin) ? origin : 0;
|
|
22
|
+
const labels = axisLabelsFor(grid, dir, dir === 'x' ? 'num' : 'alpha', parsed.offsets.length);
|
|
23
|
+
return parsed.offsets.map((o, i) => ({ at: base + o, label: String(labels[i] ?? '').trim() || `${dir.toUpperCase()}${i + 1}` }))
|
|
24
|
+
.sort((a, b) => a.at - b.at);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Where a coordinate lies among one direction's lines: on one, between two, or beyond the last; null with none. */
|
|
28
|
+
function along(lines, v) {
|
|
29
|
+
if (!lines.length) return null;
|
|
30
|
+
const on = lines.find((l) => Math.abs(l.at - v) <= ON_LINE_MM);
|
|
31
|
+
if (on) return { on: true, text: on.label };
|
|
32
|
+
const below = [...lines].reverse().find((l) => l.at < v);
|
|
33
|
+
const above = lines.find((l) => l.at > v);
|
|
34
|
+
if (below && above) return { on: false, text: `between ${below.label} and ${above.label}, ${fmt(v - below.at)} mm from ${below.label}` };
|
|
35
|
+
const near = below ?? above;
|
|
36
|
+
return { on: false, text: `${fmt(Math.abs(v - near.at))} mm ${below ? 'past' : 'before'} ${near.label}` };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The grid location of a plan point.
|
|
41
|
+
* @param {unknown} grid the model's `grid`
|
|
42
|
+
* @param {[number, number]} xy the point, in model millimetres
|
|
43
|
+
* @returns {string}
|
|
44
|
+
*/
|
|
45
|
+
export function gridPlace(grid, xy) {
|
|
46
|
+
const x = along(linesOf(grid, 'x'), xy[0]);
|
|
47
|
+
const y = along(linesOf(grid, 'y'), xy[1]);
|
|
48
|
+
if (!x && !y) return `no grid: at x ${fmt(xy[0])}, y ${fmt(xy[1])} mm`;
|
|
49
|
+
if (x?.on && y?.on) return `${y.text}/${x.text}`;
|
|
50
|
+
return [y, x].filter(Boolean).map((p) => (p.on ? `on ${p.text}` : p.text)).join(', ');
|
|
51
|
+
}
|
package/dist/web/guide.js
CHANGED
|
@@ -2176,3 +2176,5 @@
|
|
|
2176
2176
|
}, 2500);
|
|
2177
2177
|
if (window.flolessChat) askLater(); else window.addEventListener('floless:chat-ready', askLater, { once: true });
|
|
2178
2178
|
})();
|
|
2179
|
+
window.__flolessCoreReady = Object.assign(window.__flolessCoreReady || {}, { 'guide.js': true });
|
|
2180
|
+
window.flolessBoot?.ready('guide.js');
|