@floless/app 0.130.0 → 0.131.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/dist/floless-server.cjs +1422 -867
- package/dist/schemas/steel.model.v2.schema.json +28 -8
- package/dist/web/reference-changes.js +224 -0
- package/dist/web/reference-session.js +141 -0
- package/dist/web/steel-3d-view.js +533 -35
- package/dist/web/steel-editor.html +2124 -209
- package/dist/web/steel-split-view.js +169 -0
- package/package.json +1 -1
|
@@ -67,14 +67,24 @@
|
|
|
67
67
|
"override": { "type": ["string", "null"], "description": "Set only when the user overrode a file that LIES about its units." }
|
|
68
68
|
}
|
|
69
69
|
},
|
|
70
|
-
"filter": {
|
|
71
|
-
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"description": "The
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"
|
|
70
|
+
"filter": { "$ref": "#/$defs/referenceFilter" },
|
|
71
|
+
"versions": {
|
|
72
|
+
"type": "array",
|
|
73
|
+
"minItems": 1,
|
|
74
|
+
"description": "The chain of files this reference has been, OLDEST FIRST. The LAST entry is what is loaded now, and the top-level `file`/`name`/`filter` MIRROR it — a mirror rather than a lookup so every existing reader keeps working unchanged, and the invariant is asserted at the route rather than assumed. ABSENT on every reference imported before versioning existed, which is the ordinary state and not a defect: it is adopted as a chain of one the first time a new version is uploaded. Rollback REORDERS rather than truncates (a copy of the target is appended as the new last), so history survives and \"compare v3 against v1\" is still answerable while standing on v1.",
|
|
75
|
+
"items": {
|
|
76
|
+
"type": "object",
|
|
77
|
+
"additionalProperties": false,
|
|
78
|
+
"required": ["id", "file", "name", "sha256", "importedAt"],
|
|
79
|
+
"properties": {
|
|
80
|
+
"id": { "type": "string", "minLength": 1, "description": "Server-minted, opaque, unique within this chain. Versions are addressed by THIS, never by sha256: the same bytes can legitimately be uploaded twice under two names, so a sha is not unique within a chain and a lookup by it is ambiguous at exactly the moment (a rollback) when being wrong is least recoverable. JSON Schema cannot express uniqueness-by-key, so the routes check it too." },
|
|
81
|
+
"file": { "type": "string", "minLength": 1, "description": "Project-RELATIVE path to this version's retained original. Every version keeps its own file, which is what lets a removed object's ghost geometry be re-read from the version it vanished from." },
|
|
82
|
+
"name": { "type": "string", "description": "The display name this version was uploaded under." },
|
|
83
|
+
"sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$", "description": "The file's content hash, lowercase hex. DURABLE — unlike `sourceHash` on the reference cache, which lives in a reserved-internal file excluded from export, so it cannot answer \"which bytes was this version built from?\" after a round trip." },
|
|
84
|
+
"importedAt": { "type": "string", "description": "ISO-8601. For an `adopted` row this is when versioning RECORDED it, not when the file was imported — nothing durable records the latter." },
|
|
85
|
+
"adopted": { "const": true, "description": "Present and true ONLY on a v1 synthesised from a pre-versioning reference. Never false, so its absence cannot be read as a claim that the row was genuinely imported. It exists because such a row has no true import date: there is no durable record of when an existing reference was first inserted, so stamping `importedAt: now` would fabricate history in the one field a user reads to answer \"which of these did I load first?\". The UI renders it as \"recorded 14 Aug — first seen before versioning\", never \"imported 14 Aug\"." },
|
|
86
|
+
"filter": { "$ref": "#/$defs/referenceFilter" }
|
|
87
|
+
}
|
|
78
88
|
}
|
|
79
89
|
},
|
|
80
90
|
"display": {
|
|
@@ -631,6 +641,16 @@
|
|
|
631
641
|
}
|
|
632
642
|
]
|
|
633
643
|
},
|
|
644
|
+
"referenceFilter": {
|
|
645
|
+
"type": "object",
|
|
646
|
+
"additionalProperties": false,
|
|
647
|
+
"minProperties": 1,
|
|
648
|
+
"description": "The SUBSET of the file this reference was read from — ABSENT means the whole file. Stored so a re-read reproduces the same reference: without it, \"Reload its geometry\" would silently replace one storey with the whole building, from the one action a user takes when something already looks wrong. An empty list is never stored, and neither is an empty object: the reader treats an empty list as selecting NOTHING, so \"no filter\" is this key being absent. The two filters INTERSECT — storeys L1 plus type IFCBEAM means the beams on L1, not both sets.",
|
|
649
|
+
"properties": {
|
|
650
|
+
"storeys": { "type": "array", "minItems": 1, "items": { "type": "string", "minLength": 1 }, "description": "Storey names as `probe` reported them. Matched case-insensitively by the reader." },
|
|
651
|
+
"ifcTypes": { "type": "array", "minItems": 1, "items": { "type": "string", "minLength": 1 }, "description": "IFC entity names, e.g. IFCBEAM. Subtypes are included, so a supertype does not select nothing." }
|
|
652
|
+
}
|
|
653
|
+
},
|
|
634
654
|
"propLabels": {
|
|
635
655
|
"type": "object",
|
|
636
656
|
"additionalProperties": false,
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* reference-changes — what changed between two versions of a reference model. Refs #734, design §7.
|
|
3
|
+
*
|
|
4
|
+
* A reference model is borrowed geometry we never own: an IFC someone else authored, overlaid in the
|
|
5
|
+
* steel editor so you can see it, measure it and snap to it. The architect sends the NEXT version of
|
|
6
|
+
* that file; this panel is the answer to "what actually moved?".
|
|
7
|
+
*
|
|
8
|
+
* THIS MODULE RENDERS AN ANSWER IT DOES NOT COMPUTE. AWARE matches the objects (on IFC GlobalId and
|
|
9
|
+
* nothing else) and `server/reference-compare.ts` validates the response; everything here reads numbers
|
|
10
|
+
* out of that answer and draws them. floless never parses IFC and never compares geometry (CLAUDE.md).
|
|
11
|
+
*
|
|
12
|
+
* THE REFUSAL IS NOT AN ERROR STATE, AND DRAWING IT AS ONE WOULD BE A LIE OF TONE. When no ids pair,
|
|
13
|
+
* "everything added and everything removed" is the symptom of an exporter that regenerated every id, so
|
|
14
|
+
* AWARE returns no `changes` array at all and the server throws rather than handing us one. That is a
|
|
15
|
+
* correct, complete answer about two files that do not relate — not a failure of ours — so it is drawn
|
|
16
|
+
* in the neutral tokens, never `--err` red. THERE IS NO "COMPARE ANYWAY" AND THERE NEVER WILL BE: with
|
|
17
|
+
* no geometry fallback there is nothing left to compare with, so the button could only produce the
|
|
18
|
+
* fabricated list the refusal exists to prevent.
|
|
19
|
+
*
|
|
20
|
+
* TOKENS ARE THIS PAGE'S OWN. `web/steel-editor.html` DOES NOT LOAD `web/app.css` — it says so at :64
|
|
21
|
+
* and :995 — so `--surface-2`, `.guide-step`, `.canvas-empty` and friends do not exist here. Everything
|
|
22
|
+
* below uses the editor's vocabulary (`--panel`, `--sunken`, `--field`, `--mut`, `--line`, and the
|
|
23
|
+
* `--ok`/`--warn`/`--err` ink+bg+edge triads). A token that resolves to nothing fails SILENTLY and looks
|
|
24
|
+
* like an unstyled element rather than an error, so verify a name is in that page's `:root` before use.
|
|
25
|
+
*
|
|
26
|
+
* NO BESPOKE SCROLLBAR CSS IS NEEDED. The page's global `*{scrollbar-width:thin;scrollbar-color:…}` and
|
|
27
|
+
* `*::-webkit-scrollbar*` rules (`web/steel-editor.html:179`) already reach any container added here —
|
|
28
|
+
* the same reason the import modal's picker declares none (:1273). One outer scroll container owns the
|
|
29
|
+
* whole panel; nested scrollports are both where a native bar leaks in and a worse interaction.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/** Every count in design §7.3's header line. `uncomparable` is the one a clean-looking list hides. */
|
|
33
|
+
export const STAT_ORDER = ['added', 'removed', 'changed', 'uncomparable', 'unchanged'];
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* How a status reads — glyph, word, and class — because COLOUR ALONE IS NOT AN ENCODING.
|
|
37
|
+
*
|
|
38
|
+
* Each of the FOUR that assert something carries a glyph and a word in the DOM as well as a colour, so
|
|
39
|
+
* the list survives a colourblind reader, a grayscale print and a `data-tip` nobody hovers. (`unchanged`
|
|
40
|
+
* carries neither — see below, and the test asserts the glyphs for the four alone.) `uncomparable` is deliberately DASHED rather
|
|
41
|
+
* than filled even though it borrows the same amber as `changed`: shape is a distinction that survives
|
|
42
|
+
* losing colour entirely, and dashed says "we do not know" where filled asserts a fact.
|
|
43
|
+
*
|
|
44
|
+
* `unchanged` gets NO chip at all. Its whole job is to recede — a badge of equal weight to the other
|
|
45
|
+
* four fights the one thing it is there to communicate.
|
|
46
|
+
*/
|
|
47
|
+
export const STATUS = {
|
|
48
|
+
added: { glyph: '+', word: 'added', cls: 'rc-chip rc-add' },
|
|
49
|
+
removed: { glyph: '−', word: 'removed', cls: 'rc-chip rc-rem' },
|
|
50
|
+
changed: { glyph: '~', word: 'changed', cls: 'rc-chip rc-chg' },
|
|
51
|
+
uncomparable: { glyph: '?', word: 'could not compare', cls: 'rc-chip rc-unk' },
|
|
52
|
+
unchanged: { glyph: '', word: 'unchanged', cls: 'rc-plain' },
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The cap, and it is THIS PAGE'S CAP rather than a new one.
|
|
57
|
+
*
|
|
58
|
+
* The reference object tree solved this exact problem on this exact data and wrote down the
|
|
59
|
+
* measurement: filtering one real building for "mullion" matched ~8,000 objects across ten storeys, and
|
|
60
|
+
* force-expanding them built 2,795 rows — "a wall". So the list is capped and SAYS SO. A silent cap
|
|
61
|
+
* reads as "that is all there was", which on a change list is the same class of lie as folding
|
|
62
|
+
* `uncomparable` into `unchanged`.
|
|
63
|
+
*
|
|
64
|
+
* Kept in step with `REF_TREE_CAP` in `web/steel-editor.html` by intent, not by import: this file is an
|
|
65
|
+
* ES module surfaced on `window` by the same shim the page uses for `GridCore` (find it as
|
|
66
|
+
* `window.ReferenceChanges=RC`), while `REF_TREE_CAP` is a binding inside the editor's big inline
|
|
67
|
+
* classic script, which no module can see.
|
|
68
|
+
*
|
|
69
|
+
* AND NOW SOMETHING WATCHES. `server/reference-caps-parity.test.ts` reads both literals out of the two
|
|
70
|
+
* files and fails when they diverge — "kept in step by intent" is another way of saying unenforced.
|
|
71
|
+
* Cited by SYMBOL rather than line number, because every line citation this feature shipped had already
|
|
72
|
+
* drifted 20-150 lines inside the commit that wrote it.
|
|
73
|
+
*/
|
|
74
|
+
export const RC_CAP = 300;
|
|
75
|
+
|
|
76
|
+
/** `12806` → `12,806`. The page's own convention: the editor formats every count this way. NO COUNT OF
|
|
77
|
+
* USES IS QUOTED — one was, and it went stale on the very commit that quoted it. */
|
|
78
|
+
const num = (n) => (Number.isFinite(n) ? n.toLocaleString() : '—');
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* A distance in words as well as numbers, because "moved 250 mm" is the sentence a person reads.
|
|
82
|
+
*
|
|
83
|
+
* Only ever rendered when `location` actually fired. A column reserved for every changed row would be
|
|
84
|
+
* dead space in the ~90% that did not move, and a "0 mm" printed against a reprofiled column would be
|
|
85
|
+
* an assertion nobody made.
|
|
86
|
+
*/
|
|
87
|
+
export function movedPhrase(change) {
|
|
88
|
+
if (!change || !Array.isArray(change.changedBy) || !change.changedBy.includes('location')) return null;
|
|
89
|
+
const d = change.distance;
|
|
90
|
+
if (!Number.isFinite(d)) return null;
|
|
91
|
+
// Millimetres, one decimal under 10 so a sub-millimetre move is not rounded into "moved 0 mm" — which
|
|
92
|
+
// would read as "it did not move" for the exact case the tolerance was argued over.
|
|
93
|
+
const shown = d < 10 ? d.toFixed(1).replace(/\.0$/, '') : Math.round(d).toLocaleString();
|
|
94
|
+
return 'moved ' + shown + ' mm';
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* The five header counts, in the order urgency actually runs.
|
|
99
|
+
*
|
|
100
|
+
* NOT A SENTENCE. Rendered as prose, "12,806 unchanged" is the widest and loudest span on the line
|
|
101
|
+
* purely because it has five digits — the count that carries the least meaning dominating by accident of
|
|
102
|
+
* magnitude. As chips, the four that carry a decision or a fact sit at equal weight and `unchanged`
|
|
103
|
+
* comes last, toned down, reading as the odd one out rather than the anchor.
|
|
104
|
+
*
|
|
105
|
+
* EVERY COUNT APPEARS, including `uncomparable` and including zeroes. A zero that is drawn is a fact
|
|
106
|
+
* ("nothing was uncomparable"); a zero that is hidden is indistinguishable from a question nobody asked.
|
|
107
|
+
*/
|
|
108
|
+
export function summaryStats(summary) {
|
|
109
|
+
if (!summary) return [];
|
|
110
|
+
return STAT_ORDER.map((key) => ({
|
|
111
|
+
key,
|
|
112
|
+
n: summary[key],
|
|
113
|
+
text: num(summary[key]),
|
|
114
|
+
word: STATUS[key].word,
|
|
115
|
+
glyph: STATUS[key].glyph,
|
|
116
|
+
}));
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Which groups open themselves: the ones holding something to look at.
|
|
121
|
+
*
|
|
122
|
+
* The same instinct as the object tree's `wide` rule — never dump the whole building open, but never
|
|
123
|
+
* hide the thing that matters behind a chevron either. A storey that is 100% unchanged opens collapsed
|
|
124
|
+
* showing only its count, which is the honest summary of a storey nobody needs to read.
|
|
125
|
+
*/
|
|
126
|
+
export function groupNeedsAttention(rows) {
|
|
127
|
+
return Array.isArray(rows) && rows.some((r) => r && r.status && r.status !== 'unchanged');
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* The default view is "needs attention" — added, removed, changed, uncomparable.
|
|
132
|
+
*
|
|
133
|
+
* BOTH A READ AND A BUDGET. The unchanged rows are the ones nobody asked about, and not building them is
|
|
134
|
+
* also the cheap half of the performance answer: a 12,806-row DOM built on open is the wall the cap
|
|
135
|
+
* exists to prevent, reached before the user has typed anything.
|
|
136
|
+
*/
|
|
137
|
+
export function needsAttention(change) {
|
|
138
|
+
return !!change && change.status !== 'unchanged';
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* The window actually drawn, and the sentence that admits to it.
|
|
143
|
+
*
|
|
144
|
+
* Returns `{ shown, note }` — `note` is null only when nothing was withheld. Mirrors the object tree's
|
|
145
|
+
* centred-window recipe so a row the caller wants in view survives the cap rather than being sliced off
|
|
146
|
+
* the end of it.
|
|
147
|
+
*/
|
|
148
|
+
export function capWindow(list, wantIdx) {
|
|
149
|
+
const all = Array.isArray(list) ? list : [];
|
|
150
|
+
if (all.length <= RC_CAP) return { shown: all, note: null };
|
|
151
|
+
let from = 0;
|
|
152
|
+
if (Number.isFinite(wantIdx) && wantIdx >= RC_CAP) from = Math.min(wantIdx - (RC_CAP >> 1), all.length - RC_CAP);
|
|
153
|
+
return {
|
|
154
|
+
shown: all.slice(from, from + RC_CAP),
|
|
155
|
+
note: 'Showing ' + RC_CAP + ' of ' + num(all.length) + ' — use the filter above to narrow this list.',
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* The refusal's copy, built from the numbers AWARE actually reported.
|
|
161
|
+
*
|
|
162
|
+
* PLAIN ENGLISH AND IT DOES NOT BLAME THE USER. The two causes it names are the two that are real — this
|
|
163
|
+
* is not a revision of that file, or the exporter regenerated every id — and neither is something the
|
|
164
|
+
* person reading did. The wording is design §7.3's, kept verbatim through review.
|
|
165
|
+
*/
|
|
166
|
+
export function refusalCopy(refused, baseName) {
|
|
167
|
+
const revised = refused && refused.revisedName ? refused.revisedName : 'the new file';
|
|
168
|
+
const base = baseName || 'the version you have';
|
|
169
|
+
const n = refused && Number.isFinite(refused.revisedObjects) ? num(refused.revisedObjects) + ' objects' : 'its objects';
|
|
170
|
+
return {
|
|
171
|
+
lead: 'Nothing in these two files could be matched — none of ' + revised + "'s " + n +
|
|
172
|
+
' share an IFC id with ' + base + '.',
|
|
173
|
+
why: 'Either this is not a revision of ' + base + ', or the tool that exported it gave every object a new id.',
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* The three ways out of a refusal, weighted rather than equal.
|
|
179
|
+
*
|
|
180
|
+
* Design §7.3 calls the middle one "the honest remedy" and then draws three identical buttons, which
|
|
181
|
+
* undersells its own framing. Both files loaded side by side is a workflow that already works today and
|
|
182
|
+
* is what a user actually wants when the automatic answer is unavailable — so it is the primary, and the
|
|
183
|
+
* order runs quietest to loudest.
|
|
184
|
+
*
|
|
185
|
+
* THERE IS NO FOURTH BUTTON. See the module header.
|
|
186
|
+
*/
|
|
187
|
+
export const REFUSAL_ACTIONS = [
|
|
188
|
+
{ id: 'cancel', label: 'Cancel', weight: 'ghost' },
|
|
189
|
+
{ id: 'otherfile', label: 'Choose a different file', weight: 'secondary' },
|
|
190
|
+
{ id: 'separate', label: 'Load it as a separate reference instead', weight: 'primary' },
|
|
191
|
+
];
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Is this comparison like-for-like?
|
|
195
|
+
*
|
|
196
|
+
* A new version read under a different scope than the old one, with nothing saying so, is design §10's
|
|
197
|
+
* "must never happen": rows would appear as added or removed because of the FILTER rather than because
|
|
198
|
+
* the building changed. `selected` carries a receipt per side precisely so this is answerable.
|
|
199
|
+
*/
|
|
200
|
+
export function filterDiffers(selected) {
|
|
201
|
+
if (!selected) return false;
|
|
202
|
+
// WRITTEN AS ESCAPES, NOT AS RAW BYTES, and that is the whole change here — the behaviour is what it
|
|
203
|
+
// always was. These separators used to be literal U+0001/U+0002 characters in the source, which every
|
|
204
|
+
// reader renders as nothing: the line LOOKED like `join('')` with `+ '' +` between the axes. Two
|
|
205
|
+
// independent reviewers duly reported a collision bug that does not exist, and the next reader would
|
|
206
|
+
// eventually have 'fixed' the invisible separators away and created it for real.
|
|
207
|
+
//
|
|
208
|
+
// THEY ARE LOAD-BEARING. Without them `{storeys:['IfcWall']}` and `{ifcTypes:['IfcWall']}` normalise
|
|
209
|
+
// identically, as do `['L1','L2']` and `['L1L2']` — a silent FALSE NEGATIVE on the one check that
|
|
210
|
+
// stops rows being read as "the building changed" when the FILTER changed, which design §10 calls a
|
|
211
|
+
// thing that must never happen. Neither character can occur in an IFC storey or type name.
|
|
212
|
+
const ITEM = '\u0001', AXIS = '\u0002';
|
|
213
|
+
const norm = (s) => {
|
|
214
|
+
if (!s) return '';
|
|
215
|
+
const part = (v) => (Array.isArray(v) && v.length ? [...v].sort().join(ITEM) : '');
|
|
216
|
+
return part(s.storeys) + AXIS + part(s.ifcTypes) + AXIS + part(s.ids);
|
|
217
|
+
};
|
|
218
|
+
return norm(selected.base) !== norm(selected.revised);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export default {
|
|
222
|
+
RC_CAP, STATUS, STAT_ORDER, REFUSAL_ACTIONS,
|
|
223
|
+
summaryStats, movedPhrase, groupNeedsAttention, needsAttention, capWindow, refusalCopy, filterDiffers,
|
|
224
|
+
};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* reference-session — the live editor state a reference's re-read destroys. Refs #734, design §7.2.
|
|
3
|
+
*
|
|
4
|
+
* `Reload its geometry` and `Load a new version…` both replace a reference's objects wholesale. Three
|
|
5
|
+
* pieces of state the user built up are addressed by exactly what that replaces:
|
|
6
|
+
*
|
|
7
|
+
* the drilled-into object by ARRAY INDEX — migrated a layer down, in `revalidateSubSelection`,
|
|
8
|
+
* which keys on the file's own GlobalId
|
|
9
|
+
* the tree's open groups by POSITION — '2:1' is the second storey's second type; migrated
|
|
10
|
+
* HERE, on the storey/type labels the file supplies
|
|
11
|
+
* the measurement by RAW WORLD POINTS — not migrated, and cannot be; see below
|
|
12
|
+
*
|
|
13
|
+
* WHY THE MEASUREMENT IS NOT MIGRATED, stated here because it is a decision and not an omission.
|
|
14
|
+
* `refMeasureKept` records two world points and no object identity at all, so "keep it if both ends
|
|
15
|
+
* landed on something that did not move" cannot be evaluated from what is stored. Capturing that
|
|
16
|
+
* identity at measure time was costed and rejected on two grounds. First, `xrefSnapPoints` deduplicates
|
|
17
|
+
* its points ACROSS objects on a shared 0.5 mm key, so a corner touched by two objects is attributed to
|
|
18
|
+
* whichever reached it first — an endpoint's recorded owner can name a NEIGHBOUR, and the asymmetry runs
|
|
19
|
+
* the wrong way: dropping a measurement whose owner changed is merely wasteful, while KEEPING one whose
|
|
20
|
+
* recorded owner looks unchanged when the corner really belonged to a changed neighbour presents a wrong
|
|
21
|
+
* dimension as a measured one. Second, and decisively, a reload is not a comparison at all — nothing on
|
|
22
|
+
* that path classifies any object as unchanged, so the test is not hard to evaluate there, it is
|
|
23
|
+
* undefined. So the measurement is dropped on both paths and the drop is SAID. That is the honest half
|
|
24
|
+
* that was missing; what must never ship is the middle road of keeping the segment and hoping.
|
|
25
|
+
*
|
|
26
|
+
* NOTHING HERE TOUCHES THE DOM OR THE EDITOR'S GLOBALS. The impure halves — reading `refGeom`,
|
|
27
|
+
* `refTreeGroups`, the selection and the measurement — live in `web/steel-editor.html`, which calls in.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Re-key the tree's group state onto a new read, and report what could not be placed.
|
|
32
|
+
*
|
|
33
|
+
* `snapKeys` is the OLD state resolved into labels while the old objects still existed:
|
|
34
|
+
* `[{ storey, type, val }]`, where `type === undefined` marks a STOREY-level key and `val` is the
|
|
35
|
+
* `{ open, q }` the tree stores. `groups` is `groupReferenceObjects(newObjects)`.
|
|
36
|
+
*
|
|
37
|
+
* MATCHED ON THE RAW VALUES, NOT THE WORDS A HEADER SHOWS. Two types inside one storey can share a
|
|
38
|
+
* display word — that is exactly why the tree disambiguates them with the raw IFC token — so matching on
|
|
39
|
+
* words would silently merge two groups the file keeps apart. `null` is itself a real label here ("no
|
|
40
|
+
* storey recorded"), which is why absence is tagged rather than tested for falsiness.
|
|
41
|
+
*
|
|
42
|
+
* Returns `{ keys, lost }`. `lost` names only groups the user had OPEN: an explicit close is state worth
|
|
43
|
+
* migrating, but a vanished group they had collapsed cost them nothing, and naming it turns routine
|
|
44
|
+
* housekeeping into a wall. A missing STOREY is reported once, as the storey, rather than once per type
|
|
45
|
+
* inside it — otherwise dropping one level reports three losses for one event.
|
|
46
|
+
*/
|
|
47
|
+
export function migrateGroupKeys(snapKeys, groups) {
|
|
48
|
+
const tag = (v) => (v === null || v === undefined ? '-' : 'v' + v); // present values are 'v'-prefixed, so '-' cannot collide
|
|
49
|
+
const at = new Map();
|
|
50
|
+
(groups || []).forEach((s, si) => at.set(tag(s.storey), si));
|
|
51
|
+
const keys = new Map();
|
|
52
|
+
const lost = [];
|
|
53
|
+
const seenStorey = new Set();
|
|
54
|
+
for (const k of snapKeys || []) {
|
|
55
|
+
const si = at.get(tag(k.storey));
|
|
56
|
+
if (si === undefined) {
|
|
57
|
+
// The whole storey is gone. Reported once however many of its types were open.
|
|
58
|
+
if (k.val && k.val.open && !seenStorey.has(tag(k.storey))) {
|
|
59
|
+
seenStorey.add(tag(k.storey));
|
|
60
|
+
lost.push({ storey: k.storey, type: undefined });
|
|
61
|
+
}
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
if (k.type === undefined) { keys.set(String(si), k.val); continue; }
|
|
65
|
+
const ti = (groups[si].types || []).findIndex((t) => tag(t.type) === tag(k.type));
|
|
66
|
+
if (ti < 0) { if (k.val && k.val.open) lost.push({ storey: k.storey, type: k.type }); continue; }
|
|
67
|
+
keys.set(si + ':' + ti, k.val);
|
|
68
|
+
}
|
|
69
|
+
return { keys, lost };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Did the drilled-into object survive into this read — asked of the DATA, not of the 3D layer.
|
|
74
|
+
*
|
|
75
|
+
* The 3D layer migrates the selection itself (`revalidateSubSelection`), and the obvious way to report
|
|
76
|
+
* the loss is to look at whether the editor's index survived that call. It is also wrong: the push that
|
|
77
|
+
* runs it is a no-op whenever the 3D view is not the active one, so a user who switches to 2D while a
|
|
78
|
+
* re-read is in flight leaves the old index standing — which reads as "it survived", and the object is
|
|
79
|
+
* then quietly dropped later when 3D next rebuilds. The report has to be derivable from the objects
|
|
80
|
+
* themselves, in both views, or it is not a report. (Codex review.)
|
|
81
|
+
*
|
|
82
|
+
* The RULE IS THE ONE `revalidateSubSelection` ALREADY APPLIES, restated here rather than reached for:
|
|
83
|
+
* an id that is absent says nothing, and an id that appears twice cannot say which object you were on,
|
|
84
|
+
* so only an id appearing EXACTLY once counts as the same object.
|
|
85
|
+
*/
|
|
86
|
+
export function objectSurvives(globalId, objects) {
|
|
87
|
+
if (globalId === null || globalId === undefined || globalId === '') return false;
|
|
88
|
+
let seen = 0;
|
|
89
|
+
for (const o of objects || []) {
|
|
90
|
+
if (o && o.globalId === globalId && ++seen > 1) return false;
|
|
91
|
+
}
|
|
92
|
+
return seen === 1;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** How many lost group names are listed before the rest become a count. */
|
|
96
|
+
export const CARRYOVER_NAME_CAP = 3;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* The one phrase that stands for a set of lost groups — capped, and the cap admits to itself.
|
|
100
|
+
*
|
|
101
|
+
* Listing every name is the failure mode this shares with the change list's own row cap: a re-read that
|
|
102
|
+
* drops a whole storey can lose a dozen groups at once, and a sentence naming all twelve is not read.
|
|
103
|
+
*/
|
|
104
|
+
export function groupsFact(labels) {
|
|
105
|
+
const n = (labels || []).length;
|
|
106
|
+
if (!n) return null;
|
|
107
|
+
const shown = labels.slice(0, CARRYOVER_NAME_CAP);
|
|
108
|
+
const rest = n - shown.length;
|
|
109
|
+
return n + ' group' + (n === 1 ? '' : 's') + ' you had open ('
|
|
110
|
+
+ shown.join(', ') + (rest > 0 ? ', +' + rest + ' more' : '') + ')';
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* One sentence for up to three facts — never three separate boxes.
|
|
115
|
+
*
|
|
116
|
+
* Three stacked notes read as a checklist of problems. This is ordinary housekeeping after an act the
|
|
117
|
+
* user asked for, so it gets one plain sentence in the neutral voice, or — when everything migrated —
|
|
118
|
+
* nothing at all. `null` means SAY NOTHING, and every caller must honour it rather than rendering an
|
|
119
|
+
* empty container.
|
|
120
|
+
*
|
|
121
|
+
* `tail` differs per path on purpose and is not cosmetic: `Load a new version…` really does compare
|
|
122
|
+
* against "the version you had", while `Reload its geometry` re-reads the SAME file and has no earlier
|
|
123
|
+
* version to name. One shared string would make one of the two sentences false.
|
|
124
|
+
*/
|
|
125
|
+
export function carryoverSentence(facts, tail) {
|
|
126
|
+
const list = (facts || []).filter(Boolean);
|
|
127
|
+
if (!list.length) return null;
|
|
128
|
+
const lead = list.length === 1 ? 'One thing didn’t carry over' : 'A few things didn’t carry over';
|
|
129
|
+
const words = list.length === 1
|
|
130
|
+
? list[0]
|
|
131
|
+
: list.slice(0, -1).join(', ') + ' and ' + list[list.length - 1];
|
|
132
|
+
return lead + ' ' + tail + ': ' + words + '.';
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** The two tails, kept next to each other so the difference above stays visible. */
|
|
136
|
+
export const CARRYOVER_TAIL = {
|
|
137
|
+
reload: 'into the re-read file',
|
|
138
|
+
version: 'from the version you had',
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
export default { migrateGroupKeys, objectSurvives, groupsFact, carryoverSentence, CARRYOVER_NAME_CAP, CARRYOVER_TAIL };
|