@floless/app 0.131.1 → 0.132.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 +2374 -1901
- package/dist/schemas/steel.model.v2.schema.json +3 -1
- package/dist/skills/floless-app-onboarding/SKILL.md +12 -2
- package/dist/skills/floless-app-queue/SKILL.md +2 -2
- package/dist/web/app.css +359 -0
- package/dist/web/app.js +22 -0
- package/dist/web/aware.js +121 -13
- package/dist/web/commands-filter.js +157 -0
- package/dist/web/commands-shell.js +1316 -0
- package/dist/web/commands-steel.js +1829 -0
- package/dist/web/commands-vector.js +154 -0
- package/dist/web/commands-vector3d.js +96 -0
- package/dist/web/commands.js +316 -0
- package/dist/web/grid-core.js +124 -23
- package/dist/web/index.html +269 -164
- package/dist/web/instructor-reporter.js +201 -0
- package/dist/web/instructor.js +1178 -0
- package/dist/web/reference-geometry-worker.js +194 -0
- package/dist/web/steel-3d-core.js +486 -107
- package/dist/web/steel-3d-view.js +847 -204
- package/dist/web/steel-canvas-guidance.js +7 -4
- package/dist/web/steel-editor.html +1620 -1799
- package/dist/web/steel-filter-core.js +13 -5
- package/dist/web/steel-filter.html +36 -22
- package/dist/web/steel-model-adapter.js +17 -22
- package/dist/web/steel-model-commands.js +23 -10
- package/dist/web/steel-model-v2-client-validation.js +20 -3
- package/dist/web/steel-model-v2-commands.js +91 -3
- package/dist/web/steel-model-v2-projection.js +4 -5
- package/dist/web/steel-plan-transform.js +4 -8
- package/dist/web/steel-split-view.js +33 -0
- package/dist/web/vector-3d.html +19 -7
- package/dist/web/vector-editor.html +21 -8
- package/dist/web/workspaces.js +12 -25
- package/package.json +10 -1
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/* ──────────────────────────────────────────────────────────────────────────
|
|
2
|
+
The shared Instructor reporter — for child surfaces with no private state.
|
|
3
|
+
|
|
4
|
+
child → shell : a typed snapshot of what this surface is doing
|
|
5
|
+
shell → child : the rendered guidance payload (the shell owns the producer)
|
|
6
|
+
|
|
7
|
+
Deliberately read-only over the surface it observes: it reports, never arms.
|
|
8
|
+
|
|
9
|
+
── Why this is a module, and why steel-editor.html still has its own copy ──
|
|
10
|
+
The reporter in steel-editor.html is written INLINE, and must stay that way:
|
|
11
|
+
its snapshot reads `mode`, `cmTool`, `dimMode` and eleven more flags that are
|
|
12
|
+
lexically scoped inside that file's main(). No imported module can see them —
|
|
13
|
+
that is the phase-0 finding the whole reporter contract rests on.
|
|
14
|
+
|
|
15
|
+
The surfaces this file serves have no such flags: steel-filter, the vector
|
|
16
|
+
editor and the 3D trace viewer arm nothing (verified by reading each one's
|
|
17
|
+
complete interaction surface — the filter's eyedropper OPENS ON CLICK rather
|
|
18
|
+
than being armed first, and the 3D viewer's editing hooks are inert stubs).
|
|
19
|
+
Their snapshot is `{v, surface}` plus whatever page-local extras they choose
|
|
20
|
+
to pass in.
|
|
21
|
+
|
|
22
|
+
So: three copies of the reasoning below — capture phase, macrotask-not-
|
|
23
|
+
microtask, dedup, two-message teardown — would be three things to keep in
|
|
24
|
+
step, and this repo has paid for that mistake before (the three narrators
|
|
25
|
+
this whole design collapsed; sixteen of thirty-two skills drifted with
|
|
26
|
+
nothing watching). One copy, three mounts.
|
|
27
|
+
|
|
28
|
+
DO NOT "unify" the steel editor onto this module. It cannot be done without
|
|
29
|
+
giving up the lexical read, and the asymmetry is the design, not an oversight.
|
|
30
|
+
────────────────────────────────────────────────────────────────────────── */
|
|
31
|
+
(function () {
|
|
32
|
+
'use strict';
|
|
33
|
+
|
|
34
|
+
/* The input events that can change what a surface is doing. Capture phase, on
|
|
35
|
+
the document: a handler that calls stopPropagation cannot hide an event from
|
|
36
|
+
it, because document is the outermost node on the capture path. */
|
|
37
|
+
var WATCHED = ['pointerdown', 'pointerup', 'click', 'keydown', 'keyup', 'input', 'change', 'focusin'];
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Mount a reporter for this document.
|
|
41
|
+
*
|
|
42
|
+
* @param {object} opts
|
|
43
|
+
* @param {string} opts.surface one of Commands' SURFACE vocabulary
|
|
44
|
+
* @param {function} [opts.snapshot] extra page-local fields, merged into the
|
|
45
|
+
* snapshot. Must be cheap and must not throw
|
|
46
|
+
* on a half-torn-down page.
|
|
47
|
+
* @param {function} [opts.render] called with the shell's guidance payload.
|
|
48
|
+
* Surfaces that narrate nothing omit it.
|
|
49
|
+
*/
|
|
50
|
+
function mount(opts) {
|
|
51
|
+
var surface = opts && opts.surface;
|
|
52
|
+
if (!surface) return null;
|
|
53
|
+
|
|
54
|
+
var subs = new Set();
|
|
55
|
+
var lastPayload = null;
|
|
56
|
+
var lastJson = ''; // what was last EMITTED — the dedup key
|
|
57
|
+
var pending = false;
|
|
58
|
+
var disposed = false;
|
|
59
|
+
|
|
60
|
+
function snapshot() {
|
|
61
|
+
var snap = { v: 1, surface: surface };
|
|
62
|
+
if (typeof opts.snapshot === 'function') {
|
|
63
|
+
var extra;
|
|
64
|
+
// A throwing extension must not take the whole reporter down: the
|
|
65
|
+
// surface identity is still worth reporting, and it is what the shell's
|
|
66
|
+
// sheet ordering reads.
|
|
67
|
+
try { extra = opts.snapshot(); } catch (e) { extra = null; }
|
|
68
|
+
if (extra && typeof extra === 'object') {
|
|
69
|
+
Object.keys(extra).forEach(function (k) {
|
|
70
|
+
// `surface` is this module's to state — a page cannot rename itself
|
|
71
|
+
// into another surface's ordering block.
|
|
72
|
+
if (k !== 'surface' && k !== 'v') snap[k] = extra[k];
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return snap;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function emit(snap) {
|
|
80
|
+
subs.forEach(function (cb) { try { cb(snap); } catch (e) {} });
|
|
81
|
+
// Same-origin parent hand-off, matching the house convention (the shell
|
|
82
|
+
// already reaches into frames' contentWindow directly).
|
|
83
|
+
try {
|
|
84
|
+
if (window.parent && window.parent !== window && typeof window.parent.__instructorReport === 'function') {
|
|
85
|
+
window.parent.__instructorReport(snap, window);
|
|
86
|
+
}
|
|
87
|
+
} catch (e) { /* cross-origin or torn-down parent */ }
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/* Coalesce to one read per input event, then emit only on a real change.
|
|
91
|
+
setTimeout, not a microtask: a microtask checkpoint runs BETWEEN listener
|
|
92
|
+
callbacks during dispatch, so it would read the page's state before the
|
|
93
|
+
target handler had changed it. A macrotask is the first point at which the
|
|
94
|
+
whole event has been delivered. */
|
|
95
|
+
function publishSoon() {
|
|
96
|
+
if (pending || disposed) return;
|
|
97
|
+
pending = true;
|
|
98
|
+
setTimeout(function () {
|
|
99
|
+
pending = false;
|
|
100
|
+
if (disposed) return;
|
|
101
|
+
var snap, json;
|
|
102
|
+
/* stringify is INSIDE the try with the read. A snapshot extension that returns
|
|
103
|
+
something JSON cannot represent — a cycle, a BigInt — would otherwise throw out
|
|
104
|
+
of this timer on every input event for the rest of the session, because
|
|
105
|
+
lastJson never advances past the failure. Skipping the publish degrades to
|
|
106
|
+
"this surface stopped reporting"; throwing degrades to a console full of
|
|
107
|
+
errors AND no reporting. */
|
|
108
|
+
try { snap = snapshot(); json = JSON.stringify(snap); } catch (e) { return; }
|
|
109
|
+
if (json === lastJson) return; // nothing changed — stay silent
|
|
110
|
+
lastJson = json;
|
|
111
|
+
emit(snap);
|
|
112
|
+
}, 0);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function onInput() { publishSoon(); }
|
|
116
|
+
|
|
117
|
+
window.__instructor = {
|
|
118
|
+
version: 1,
|
|
119
|
+
getSnapshot: snapshot,
|
|
120
|
+
subscribe: function (cb) { subs.add(cb); cb(snapshot()); return function () { subs.delete(cb); }; },
|
|
121
|
+
/* shell → child: the produced guidance comes back here. A consumer renders
|
|
122
|
+
what it is handed and never derives its own. */
|
|
123
|
+
receiveGuidance: function (payload) {
|
|
124
|
+
lastPayload = payload;
|
|
125
|
+
if (typeof opts.render === 'function') { try { opts.render(payload); } catch (e) {} }
|
|
126
|
+
},
|
|
127
|
+
getGuidance: function () { return lastPayload; },
|
|
128
|
+
/* For state that changes with no input event of its own — an async load,
|
|
129
|
+
a contract arriving. Cheap: it only schedules. */
|
|
130
|
+
notifyChanged: publishSoon,
|
|
131
|
+
/* Teardown so a stale reporter can never narrate a dead surface. */
|
|
132
|
+
dispose: function () {
|
|
133
|
+
if (disposed) return;
|
|
134
|
+
disposed = true;
|
|
135
|
+
WATCHED.forEach(function (t) { document.removeEventListener(t, onInput, true); });
|
|
136
|
+
document.removeEventListener('keydown', onHelpKey, true);
|
|
137
|
+
subs.clear();
|
|
138
|
+
lastPayload = null;
|
|
139
|
+
try { delete window.__instructor; } catch (e) { window.__instructor = undefined; }
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
WATCHED.forEach(function (t) { document.addEventListener(t, onInput, true); });
|
|
144
|
+
|
|
145
|
+
/* ── `?` / F1 inside this frame ──────────────────────────────────────────
|
|
146
|
+
A keydown in an iframe never reaches the shell's handler, so without this
|
|
147
|
+
the help keys simply do nothing on the surface the user is looking at.
|
|
148
|
+
|
|
149
|
+
It FORWARDS rather than rendering its own sheet: the shell is the sole
|
|
150
|
+
producer, and a second sheet in here would be a second thing to keep in
|
|
151
|
+
step — and would show half the commands each.
|
|
152
|
+
|
|
153
|
+
Capture phase again, and the same yield-to-typing rule the shell applies:
|
|
154
|
+
a literal "?" typed into this page's own inputs must survive. F1 stays
|
|
155
|
+
reachable while typing, by design — it is unbound app-wide. */
|
|
156
|
+
function onHelpKey(e) {
|
|
157
|
+
if (e.ctrlKey || e.metaKey || e.altKey) return;
|
|
158
|
+
if (e.key !== '?' && e.key !== 'F1') return;
|
|
159
|
+
var t = e.target;
|
|
160
|
+
var typing = t && (t.isContentEditable || t.tagName === 'INPUT' || t.tagName === 'TEXTAREA' || t.tagName === 'SELECT');
|
|
161
|
+
if (e.key === '?' && typing) return;
|
|
162
|
+
try {
|
|
163
|
+
if (window.parent && window.parent !== window && typeof window.parent.__instructorKey === 'function') {
|
|
164
|
+
if (window.parent.__instructorKey(e.key)) e.preventDefault();
|
|
165
|
+
}
|
|
166
|
+
} catch (err) { /* cross-origin or torn-down parent */ }
|
|
167
|
+
}
|
|
168
|
+
document.addEventListener('keydown', onHelpKey, true);
|
|
169
|
+
|
|
170
|
+
/* Teardown is TWO messages, and sending only the first is a real bug this
|
|
171
|
+
contract was once shipped with: disposing the child stops it reporting,
|
|
172
|
+
but the shell goes on painting the last thing it heard. It was measured —
|
|
173
|
+
the band still read "Click the member end point" after the frame had
|
|
174
|
+
navigated to about:blank, because nothing had told the shell its reporter
|
|
175
|
+
was gone, and a probe that counted reports saw silence and called it
|
|
176
|
+
correctness.
|
|
177
|
+
|
|
178
|
+
Order matters: tell the shell FIRST, while this window is still
|
|
179
|
+
associated with the document it is describing. */
|
|
180
|
+
window.addEventListener('pagehide', function () {
|
|
181
|
+
try {
|
|
182
|
+
if (window.parent && window.parent !== window && typeof window.parent.__instructorReporterGone === 'function') {
|
|
183
|
+
window.parent.__instructorReporterGone(window);
|
|
184
|
+
}
|
|
185
|
+
} catch (e) { /* cross-origin or torn-down parent */ }
|
|
186
|
+
try { window.__instructor.dispose(); } catch (e) {}
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
publishSoon(); // first report, so the shell is not blank until the first click
|
|
190
|
+
|
|
191
|
+
try {
|
|
192
|
+
if (window.parent && window.parent !== window && typeof window.parent.__instructorReady === 'function') {
|
|
193
|
+
window.parent.__instructorReady(window); // the ready event the contract requires
|
|
194
|
+
}
|
|
195
|
+
} catch (e) {}
|
|
196
|
+
|
|
197
|
+
return window.__instructor;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
window.InstructorReporter = { mount: mount };
|
|
201
|
+
})();
|