@ifc-lite/viewer 1.23.0 → 1.25.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/.turbo/turbo-build.log +34 -31
- package/CHANGELOG.md +96 -0
- package/dist/assets/{basketViewActivator-Dn_bHUl2.js → basketViewActivator-CU8_toGq.js} +7 -7
- package/dist/assets/{bcf-B9SFl84i.js → bcf-DXGDhw56.js} +23 -23
- package/dist/assets/{deflate-yMpdCIqk.js → deflate-Bb1_H2Yf.js} +1 -1
- package/dist/assets/{exporters-D-BvrNIg.js → exporters-DZhLN0ux.js} +1861 -1658
- package/dist/assets/geometry-controller.worker-DQOSYqtw.js +7 -0
- package/dist/assets/geometry.worker-B62e03Ao.js +1 -0
- package/dist/assets/{geotiff-D1tvcDCb.js → geotiff-y0ZxbRJd.js} +10 -10
- package/dist/assets/{ids-DZLs0snJ.js → ids-DruUNtfD.js} +4 -4
- package/dist/assets/ifc-lite-Ch2T9pP9.js +7 -0
- package/dist/assets/{ifc-lite_bg-DyHX37GQ.wasm → ifc-lite_bg-D7O1WHgP.wasm} +0 -0
- package/dist/assets/{ifc-lite_bg-BIryVCXQ.wasm → ifc-lite_bg-iH_07wf8.wasm} +0 -0
- package/dist/assets/index-Bws3UAkj.css +1 -0
- package/dist/assets/{index-CXSBhkcJ.js → index-Dr88ZlSY.js} +64100 -47030
- package/dist/assets/{jpeg-DUMcZp24.js → jpeg-B3_loqFe.js} +1 -1
- package/dist/assets/lens-PYsLu_MA.js +1 -0
- package/dist/assets/{lerc-IN4uWojP.js → lerc-nkwS8ZUe.js} +1 -1
- package/dist/assets/{lzw-Cnw0hH-m.js → lzw-D3cW5Wpg.js} +1 -1
- package/dist/assets/{native-bridge-BVf2uzoH.js → native-bridge-BcYJooq8.js} +2 -2
- package/dist/assets/{packbits-BskJCwk0.js → packbits-DDN4xzB5.js} +1 -1
- package/dist/assets/{parser.worker-BdtkkaGf.js → parser.worker-BW1IMUed.js} +3 -3
- package/dist/assets/raw-CoIXstQ-.js +1 -0
- package/dist/assets/{sandbox-VLI_y7cl.js → sandbox-DETNEyQb.js} +498 -470
- package/dist/assets/{server-client-BLcKaWQB.js → server-client-CmzJOeS7.js} +1 -1
- package/dist/assets/{wasm-bridge-BAfZh7YT.js → wasm-bridge-CT7mK9W0.js} +1 -1
- package/dist/assets/{webimage-Db2xzze3.js → webimage-CBjgg4up.js} +1 -1
- package/dist/assets/{workerHelpers--sAYm9yN.js → workerHelpers-IEQDo8r3.js} +1 -1
- package/dist/assets/{zstd-BDToOQyD.js → zstd-C8oQ6qdS.js} +1 -1
- package/dist/index.html +8 -8
- package/package.json +11 -9
- package/src/App.tsx +5 -2
- package/src/components/extensions/AuditLogPanel.tsx +259 -0
- package/src/components/extensions/BundlePreview.tsx +102 -0
- package/src/components/extensions/CapabilityReview.tsx +333 -0
- package/src/components/extensions/ExtensionDockHost.tsx +192 -0
- package/src/components/extensions/ExtensionToolbarSlot.tsx +106 -0
- package/src/components/extensions/ExtensionsPanel.tsx +481 -0
- package/src/components/extensions/FlavorDialog.tsx +398 -0
- package/src/components/extensions/FlavorImportPreview.tsx +79 -0
- package/src/components/extensions/FlavorIndicator.tsx +81 -0
- package/src/components/extensions/FlavorListView.tsx +318 -0
- package/src/components/extensions/FlavorMergeDialog.tsx +326 -0
- package/src/components/extensions/HelpHint.tsx +182 -0
- package/src/components/extensions/IdeasPanel.tsx +344 -0
- package/src/components/extensions/PlanCard.tsx +227 -0
- package/src/components/extensions/PrivacyPanel.tsx +312 -0
- package/src/components/extensions/PromoteToolDialog.tsx +313 -0
- package/src/components/extensions/RepairQueuePanel.tsx +222 -0
- package/src/components/extensions/icon-registry.ts +92 -0
- package/src/components/extensions/toast-helpers.ts +49 -0
- package/src/components/extensions/widget/WidgetErrorBoundary.tsx +62 -0
- package/src/components/extensions/widget/WidgetRenderer.tsx +428 -0
- package/src/components/viewer/ChatPanel.tsx +251 -3
- package/src/components/viewer/CommandPalette.tsx +74 -4
- package/src/components/viewer/Drawing2DCanvas.tsx +178 -1
- package/src/components/viewer/EntityContextMenu.tsx +70 -0
- package/src/components/viewer/ExportDialog.tsx +9 -1
- package/src/components/viewer/KeyboardShortcutsDialog.tsx +21 -6
- package/src/components/viewer/LensPanel.tsx +50 -0
- package/src/components/viewer/MainToolbar.tsx +170 -87
- package/src/components/viewer/ScriptPanel.tsx +105 -1
- package/src/components/viewer/Section2DPanel.tsx +58 -2
- package/src/components/viewer/StatusBar.tsx +18 -0
- package/src/components/viewer/ViewerLayout.tsx +53 -4
- package/src/components/viewer/Viewport.tsx +72 -0
- package/src/hooks/useActionLogger.test.ts +161 -0
- package/src/hooks/useActionLogger.ts +141 -0
- package/src/hooks/useForkExtension.ts +51 -0
- package/src/hooks/useIfcFederation.ts +7 -1
- package/src/hooks/useInstalledExtensions.ts +43 -0
- package/src/hooks/usePrivacyDisclosure.ts +48 -0
- package/src/hooks/useRunExtensionTests.ts +67 -0
- package/src/hooks/useSlotContributions.ts +38 -0
- package/src/hooks/useSymbolicAnnotations.test.ts +124 -0
- package/src/hooks/useSymbolicAnnotations.ts +776 -0
- package/src/lib/desktop-product.ts +7 -1
- package/src/lib/lens/adapter.ts +14 -0
- package/src/lib/llm/prompt-cache.ts +77 -0
- package/src/lib/llm/stream-client.ts +20 -2
- package/src/lib/llm/stream-direct.ts +11 -1
- package/src/lib/llm/system-prompt.ts +42 -0
- package/src/lib/safe-mode.ts +30 -0
- package/src/sdk/ExtensionHostProvider.tsx +103 -0
- package/src/services/extensions/flavor-service.ts +183 -0
- package/src/services/extensions/host-commands.ts +112 -0
- package/src/services/extensions/host-installer.ts +289 -0
- package/src/services/extensions/host.ts +514 -0
- package/src/services/extensions/idb-flavor-storage.test.ts +140 -0
- package/src/services/extensions/idb-flavor-storage.ts +241 -0
- package/src/services/extensions/idb-log-storage.test.ts +110 -0
- package/src/services/extensions/idb-log-storage.ts +171 -0
- package/src/services/extensions/idb-storage.ts +228 -0
- package/src/services/extensions/runtime-errors.ts +26 -0
- package/src/services/extensions/sandbox-factory.ts +217 -0
- package/src/store/constants.ts +48 -6
- package/src/store/index.ts +6 -1
- package/src/store/slices/drawing2DSlice.ts +8 -0
- package/src/store/slices/extensionsSlice.ts +90 -0
- package/src/store/slices/lensSlice.ts +28 -0
- package/src/store/slices/visibilitySlice.test.ts +6 -0
- package/src/store/slices/visibilitySlice.ts +17 -8
- package/src/store/types.ts +2 -0
- package/dist/assets/geometry-controller.worker-Cm5pvyR6.js +0 -7
- package/dist/assets/geometry.worker-ClNvXIrj.js +0 -1
- package/dist/assets/ifc-lite-BDg0iIbj.js +0 -7
- package/dist/assets/index-DS_xJQfP.css +0 -1
- package/dist/assets/lens-CpjUdqpw.js +0 -1
- package/dist/assets/raw-DzTtEZIY.js +0 -1
|
@@ -9,10 +9,12 @@ import {
|
|
|
9
9
|
type Drawing2D,
|
|
10
10
|
type ElementData,
|
|
11
11
|
} from '@ifc-lite/drawing-2d';
|
|
12
|
+
import type { DrawingLine2D } from '@ifc-lite/renderer';
|
|
12
13
|
import { formatDistance } from './tools/formatDistance';
|
|
13
14
|
import { formatArea, computePolygonCentroid } from './tools/computePolygonArea';
|
|
14
15
|
import { drawCloudOnCanvas } from './tools/cloudPathGenerator';
|
|
15
16
|
import type { PolygonArea2DResult, TextAnnotation2D, CloudAnnotation2D, Annotation2DTool, Point2D, SelectedAnnotation2D } from '@/store/slices/drawing2DSlice';
|
|
17
|
+
import type { AnnotationFill2D, AnnotationText2D } from '@/hooks/useSymbolicAnnotations';
|
|
16
18
|
|
|
17
19
|
// Fill colors for IFC types (architectural convention)
|
|
18
20
|
const IFC_TYPE_FILL_COLORS: Record<string, string> = {
|
|
@@ -53,6 +55,142 @@ export function getFillColorForType(ifcType: string): string {
|
|
|
53
55
|
return IFC_TYPE_FILL_COLORS[ifcType] || IFC_TYPE_FILL_COLORS.default;
|
|
54
56
|
}
|
|
55
57
|
|
|
58
|
+
// ─── IFC annotation overlay helpers (issue #812) ─────────────────────────────
|
|
59
|
+
|
|
60
|
+
/** Linear sRGB straight-alpha [0..1] tuple → CSS `rgba(...)`. */
|
|
61
|
+
function rgbaToCss(c: readonly [number, number, number, number]): string {
|
|
62
|
+
const r = Math.round(Math.max(0, Math.min(1, c[0])) * 255);
|
|
63
|
+
const g = Math.round(Math.max(0, Math.min(1, c[1])) * 255);
|
|
64
|
+
const b = Math.round(Math.max(0, Math.min(1, c[2])) * 255);
|
|
65
|
+
return `rgba(${r}, ${g}, ${b}, ${Math.max(0, Math.min(1, c[3]))})`;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Map IFC `BoxAlignment` to canvas2d `textAlign` + `textBaseline`. Mirrors
|
|
70
|
+
* the renderer's `parseBoxAlignment` semantics so the 2D overlay anchors
|
|
71
|
+
* text the same way the 3D pipeline does. Unknown / empty strings default
|
|
72
|
+
* to bottom-left (IFC4 IfcTextLiteralWithExtent default).
|
|
73
|
+
*/
|
|
74
|
+
function alignmentToCanvas(s: string): { align: CanvasTextAlign; baseline: CanvasTextBaseline } {
|
|
75
|
+
const norm = (s ?? '').toLowerCase().trim();
|
|
76
|
+
let align: CanvasTextAlign = 'left';
|
|
77
|
+
let baseline: CanvasTextBaseline = 'alphabetic';
|
|
78
|
+
if (norm.includes('right')) align = 'right';
|
|
79
|
+
else if (norm.includes('center')) align = 'center';
|
|
80
|
+
if (norm.includes('top')) baseline = 'top';
|
|
81
|
+
else if (norm.includes('middle') || (norm.includes('center') && !norm.includes('center-'))) baseline = 'middle';
|
|
82
|
+
return { align, baseline };
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Render IFC annotation fills, lines, and text into the canvas, in screen
|
|
87
|
+
* pixels. The caller supplies:
|
|
88
|
+
* - `modelToScreen` – drawing-coord → screen-pixel conversion (accounts
|
|
89
|
+
* for axis flips and sheet-mode paper scale)
|
|
90
|
+
* - `mmLineToScreen` – mm line weight → screen px stroke width
|
|
91
|
+
* - `worldHeightToScreenPx` – world-units text height → screen px font size
|
|
92
|
+
*
|
|
93
|
+
* Called from both the sheet-mode and direct-mode render paths in
|
|
94
|
+
* `Drawing2DCanvas`. Splitting it out keeps the two paths in sync without
|
|
95
|
+
* duplicating ~80 lines of canvas calls.
|
|
96
|
+
*
|
|
97
|
+
* Text rendering uses identity transform (no canvas rotate-with-scale) so
|
|
98
|
+
* `direct mode`'s y-flip doesn't mirror glyphs. The baseline direction is
|
|
99
|
+
* recovered in screen space from `dirX/dirY` mapped through `modelToScreen`.
|
|
100
|
+
*/
|
|
101
|
+
function drawIfcAnnotationsScreenSpace(
|
|
102
|
+
ctx: CanvasRenderingContext2D,
|
|
103
|
+
lines: readonly DrawingLine2D[] | undefined,
|
|
104
|
+
texts: readonly AnnotationText2D[] | undefined,
|
|
105
|
+
fills: readonly AnnotationFill2D[] | undefined,
|
|
106
|
+
modelToScreen: (x: number, y: number) => { x: number; y: number },
|
|
107
|
+
mmLineToScreen: (mmWeight: number) => number,
|
|
108
|
+
worldHeightToScreenPx: (worldHeight: number) => number,
|
|
109
|
+
): void {
|
|
110
|
+
// Fills first so lines/text composite cleanly on top.
|
|
111
|
+
if (fills && fills.length > 0) {
|
|
112
|
+
for (const fill of fills) {
|
|
113
|
+
const pts = fill.points;
|
|
114
|
+
if (pts.length < 6) continue;
|
|
115
|
+
const holes = fill.holesOffsets;
|
|
116
|
+
|
|
117
|
+
ctx.fillStyle = rgbaToCss(fill.color);
|
|
118
|
+
ctx.beginPath();
|
|
119
|
+
|
|
120
|
+
// Outer ring runs from index 0 up to the first hole offset (or end of
|
|
121
|
+
// points if no holes). Each hole offset is a vertex index where the
|
|
122
|
+
// next ring starts. Path subpaths use moveTo + lineTo + closePath; the
|
|
123
|
+
// even-odd fill rule handles the holes.
|
|
124
|
+
const ringStarts: number[] = [0];
|
|
125
|
+
for (let i = 0; i < holes.length; i++) ringStarts.push(holes[i]);
|
|
126
|
+
ringStarts.push(pts.length / 2); // sentinel end
|
|
127
|
+
|
|
128
|
+
for (let ri = 0; ri < ringStarts.length - 1; ri++) {
|
|
129
|
+
const start = ringStarts[ri];
|
|
130
|
+
const end = ringStarts[ri + 1];
|
|
131
|
+
if (end - start < 3) continue;
|
|
132
|
+
const first = modelToScreen(pts[start * 2], pts[start * 2 + 1]);
|
|
133
|
+
ctx.moveTo(first.x, first.y);
|
|
134
|
+
for (let i = start + 1; i < end; i++) {
|
|
135
|
+
const p = modelToScreen(pts[i * 2], pts[i * 2 + 1]);
|
|
136
|
+
ctx.lineTo(p.x, p.y);
|
|
137
|
+
}
|
|
138
|
+
ctx.closePath();
|
|
139
|
+
}
|
|
140
|
+
ctx.fill('evenodd');
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (lines && lines.length > 0) {
|
|
145
|
+
// Slightly heavier than the drawing-2d 'annotation' category (0.13 mm)
|
|
146
|
+
// so coplanar overlays read clearly against the cut polygons beneath.
|
|
147
|
+
// This is the 2D equivalent of the 3D thicker-lines suggestion in #812.
|
|
148
|
+
const lineWidthMm = 0.2;
|
|
149
|
+
ctx.strokeStyle = '#000000';
|
|
150
|
+
ctx.lineWidth = mmLineToScreen(lineWidthMm);
|
|
151
|
+
ctx.setLineDash([]);
|
|
152
|
+
ctx.beginPath();
|
|
153
|
+
for (const ln of lines) {
|
|
154
|
+
const a = modelToScreen(ln.line.start.x, ln.line.start.y);
|
|
155
|
+
const b = modelToScreen(ln.line.end.x, ln.line.end.y);
|
|
156
|
+
ctx.moveTo(a.x, a.y);
|
|
157
|
+
ctx.lineTo(b.x, b.y);
|
|
158
|
+
}
|
|
159
|
+
ctx.stroke();
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (texts && texts.length > 0) {
|
|
163
|
+
for (const t of texts) {
|
|
164
|
+
if (!t.content) continue;
|
|
165
|
+
const anchor = modelToScreen(t.x, t.y);
|
|
166
|
+
// Recover baseline direction in SCREEN space. modelToScreen may flip
|
|
167
|
+
// axes (e.g. direct-mode flips Y), so atan2(dirY, dirX) on raw model
|
|
168
|
+
// dirs would draw the text mirrored on those axes.
|
|
169
|
+
const baselineEnd = modelToScreen(t.x + t.dirX, t.y + t.dirY);
|
|
170
|
+
const sx = baselineEnd.x - anchor.x;
|
|
171
|
+
const sy = baselineEnd.y - anchor.y;
|
|
172
|
+
const angle = Math.abs(sx) + Math.abs(sy) > 1e-6 ? Math.atan2(sy, sx) : 0;
|
|
173
|
+
|
|
174
|
+
const fontPx = t.targetPx && t.targetPx > 0 ? t.targetPx : worldHeightToScreenPx(t.height);
|
|
175
|
+
const { align, baseline } = alignmentToCanvas(t.alignment);
|
|
176
|
+
// Multi-line literals stack downward in world Y in 3D. In 2D screen
|
|
177
|
+
// space the equivalent is `+ fontPx` per line below the anchor along
|
|
178
|
+
// the baseline-perpendicular (handled by the canvas rotate below).
|
|
179
|
+
const lineOffsetPx = (t.lineYOffset ?? 0) * (fontPx / Math.max(1e-6, t.height));
|
|
180
|
+
|
|
181
|
+
ctx.save();
|
|
182
|
+
ctx.fillStyle = t.color ? rgbaToCss(t.color) : '#000000';
|
|
183
|
+
ctx.font = `${fontPx}px system-ui, sans-serif`;
|
|
184
|
+
ctx.textAlign = align;
|
|
185
|
+
ctx.textBaseline = baseline;
|
|
186
|
+
ctx.translate(anchor.x, anchor.y);
|
|
187
|
+
ctx.rotate(angle);
|
|
188
|
+
ctx.fillText(t.content, 0, lineOffsetPx);
|
|
189
|
+
ctx.restore();
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
56
194
|
// Static constants to avoid creating new objects/arrays on every render
|
|
57
195
|
const CANVAS_STYLE = { imageRendering: 'crisp-edges' as const };
|
|
58
196
|
const EMPTY_MEASURE_RESULTS: Measure2DResultData[] = [];
|
|
@@ -97,6 +235,10 @@ interface Drawing2DCanvasProps {
|
|
|
97
235
|
cloudAnnotations?: CloudAnnotation2D[];
|
|
98
236
|
// Selection
|
|
99
237
|
selectedAnnotation?: SelectedAnnotation2D | null;
|
|
238
|
+
// IFC annotation overlay (issue #812)
|
|
239
|
+
ifcAnnotationLines?: readonly DrawingLine2D[];
|
|
240
|
+
ifcAnnotationTexts?: readonly AnnotationText2D[];
|
|
241
|
+
ifcAnnotationFills?: readonly AnnotationFill2D[];
|
|
100
242
|
}
|
|
101
243
|
|
|
102
244
|
export function Drawing2DCanvas({
|
|
@@ -126,6 +268,9 @@ export function Drawing2DCanvas({
|
|
|
126
268
|
cloudAnnotationPoints = [],
|
|
127
269
|
cloudAnnotations = [],
|
|
128
270
|
selectedAnnotation = null,
|
|
271
|
+
ifcAnnotationLines,
|
|
272
|
+
ifcAnnotationTexts,
|
|
273
|
+
ifcAnnotationFills,
|
|
129
274
|
}: Drawing2DCanvasProps): React.ReactElement {
|
|
130
275
|
const canvasRef = useRef<HTMLCanvasElement>(null);
|
|
131
276
|
const [canvasSize, setCanvasSize] = useState({ width: 0, height: 0 });
|
|
@@ -630,6 +775,17 @@ export function Drawing2DCanvas({
|
|
|
630
775
|
ctx.stroke();
|
|
631
776
|
ctx.setLineDash([]);
|
|
632
777
|
}
|
|
778
|
+
|
|
779
|
+
// IFC annotation overlay (issue #812)
|
|
780
|
+
drawIfcAnnotationsScreenSpace(
|
|
781
|
+
ctx,
|
|
782
|
+
ifcAnnotationLines,
|
|
783
|
+
ifcAnnotationTexts,
|
|
784
|
+
ifcAnnotationFills,
|
|
785
|
+
modelToScreen,
|
|
786
|
+
(mm) => Math.max(0.5, mmToScreen(mm) * 0.3),
|
|
787
|
+
(worldHeight) => Math.max(8, worldHeight * drawingTransform.scaleFactor * transform.scale),
|
|
788
|
+
);
|
|
633
789
|
};
|
|
634
790
|
|
|
635
791
|
drawModelContent();
|
|
@@ -945,6 +1101,27 @@ export function Drawing2DCanvas({
|
|
|
945
1101
|
}
|
|
946
1102
|
|
|
947
1103
|
ctx.restore();
|
|
1104
|
+
|
|
1105
|
+
// IFC annotation overlay (issue #812). Rendered after ctx.restore so we
|
|
1106
|
+
// can size lines and text in screen pixels rather than fighting the
|
|
1107
|
+
// ctx.scale applied above (which would inverse-scale everything).
|
|
1108
|
+
const directScaleX = sectionAxis === 'side' ? -transform.scale : transform.scale;
|
|
1109
|
+
const directScaleY = sectionAxis === 'down' ? transform.scale : -transform.scale;
|
|
1110
|
+
drawIfcAnnotationsScreenSpace(
|
|
1111
|
+
ctx,
|
|
1112
|
+
ifcAnnotationLines,
|
|
1113
|
+
ifcAnnotationTexts,
|
|
1114
|
+
ifcAnnotationFills,
|
|
1115
|
+
(x, y) => ({ x: x * directScaleX + transform.x, y: y * directScaleY + transform.y }),
|
|
1116
|
+
// No paper scale here: take a baseline 0.3 px per "default mm" so
|
|
1117
|
+
// weights match the heavier projection lines visually. Annotation
|
|
1118
|
+
// strokes in IFC are intentionally lighter than projection lines,
|
|
1119
|
+
// but a hair too thin on a 1× screen disappears entirely.
|
|
1120
|
+
(mmWeight) => Math.max(0.5, mmWeight * transform.scale * 0.3),
|
|
1121
|
+
// World height directly to screen pixels through the active zoom.
|
|
1122
|
+
// 8 px floor so labels stay legible when zoomed way out.
|
|
1123
|
+
(worldHeight) => Math.max(8, worldHeight * transform.scale),
|
|
1124
|
+
);
|
|
948
1125
|
}
|
|
949
1126
|
|
|
950
1127
|
// ═══════════════════════════════════════════════════════════════════════
|
|
@@ -1399,7 +1576,7 @@ export function Drawing2DCanvas({
|
|
|
1399
1576
|
}
|
|
1400
1577
|
}
|
|
1401
1578
|
}
|
|
1402
|
-
}, [drawing, transform, showHiddenLines, canvasSize, overrideEngine, overridesEnabled, entityColorMap, useIfcMaterials, measureMode, measureStart, measureCurrent, measureResults, measureSnapPoint, sheetEnabled, activeSheet, sectionAxis, isPinned, annotation2DActiveTool, annotation2DCursorPos, polygonAreaPoints, polygonAreaResults, textAnnotations, textAnnotationEditing, cloudAnnotationPoints, cloudAnnotations, selectedAnnotation]);
|
|
1579
|
+
}, [drawing, transform, showHiddenLines, canvasSize, overrideEngine, overridesEnabled, entityColorMap, useIfcMaterials, measureMode, measureStart, measureCurrent, measureResults, measureSnapPoint, sheetEnabled, activeSheet, sectionAxis, isPinned, annotation2DActiveTool, annotation2DCursorPos, polygonAreaPoints, polygonAreaResults, textAnnotations, textAnnotationEditing, cloudAnnotationPoints, cloudAnnotations, selectedAnnotation, ifcAnnotationLines, ifcAnnotationTexts, ifcAnnotationFills]);
|
|
1403
1580
|
|
|
1404
1581
|
return (
|
|
1405
1582
|
<canvas
|
|
@@ -32,6 +32,11 @@ import {
|
|
|
32
32
|
} from '@/store/basket/basketCommands';
|
|
33
33
|
import { useIfc } from '@/hooks/useIfc';
|
|
34
34
|
import { toast } from '@/components/ui/toast';
|
|
35
|
+
import { useSlotContributions } from '@/hooks/useSlotContributions';
|
|
36
|
+
import { useOptionalExtensionHost } from '@/sdk/ExtensionHostProvider';
|
|
37
|
+
import { evaluateWhen, parseWhen, type CommandContribution, type ResolvedContextMenuContribution } from '@ifc-lite/extensions';
|
|
38
|
+
import { resolveExtensionIcon } from '@/components/extensions/icon-registry';
|
|
39
|
+
import { describeRunCommandError } from '@/services/extensions/runtime-errors';
|
|
35
40
|
|
|
36
41
|
export function EntityContextMenu() {
|
|
37
42
|
const contextMenu = useViewerStore((s) => s.contextMenu);
|
|
@@ -404,10 +409,75 @@ export function EntityContextMenu() {
|
|
|
404
409
|
<MenuItem icon={Eye} label="Show all" onClick={handleShowAll} />
|
|
405
410
|
</>
|
|
406
411
|
)}
|
|
412
|
+
|
|
413
|
+
<ExtensionContextItems
|
|
414
|
+
slot={contextMenu.entityId != null ? 'contextMenu.entity' : 'contextMenu.canvas'}
|
|
415
|
+
hasEntity={contextMenu.entityId != null}
|
|
416
|
+
/>
|
|
407
417
|
</div>
|
|
408
418
|
);
|
|
409
419
|
}
|
|
410
420
|
|
|
421
|
+
/**
|
|
422
|
+
* Renders extension-contributed entries for the entity or canvas
|
|
423
|
+
* context-menu slot. Each contribution is `when`-filtered; clicking
|
|
424
|
+
* dispatches the contributed command through the extension host.
|
|
425
|
+
*/
|
|
426
|
+
function ExtensionContextItems({
|
|
427
|
+
slot,
|
|
428
|
+
hasEntity,
|
|
429
|
+
}: {
|
|
430
|
+
slot: 'contextMenu.entity' | 'contextMenu.canvas';
|
|
431
|
+
hasEntity: boolean;
|
|
432
|
+
}) {
|
|
433
|
+
// Loader enriches the contextMenu payload with icon + title from
|
|
434
|
+
// the linked command (see manifestToContributions). Fall back to
|
|
435
|
+
// the commandPalette lookup for title if a manifest somehow omits it.
|
|
436
|
+
const contributions = useSlotContributions<ResolvedContextMenuContribution>(slot);
|
|
437
|
+
const commandPalette = useSlotContributions<CommandContribution>('commandPalette');
|
|
438
|
+
const host = useOptionalExtensionHost();
|
|
439
|
+
const closeContextMenu = useViewerStore((s) => s.closeContextMenu);
|
|
440
|
+
if (contributions.length === 0) return null;
|
|
441
|
+
const whenContext = {
|
|
442
|
+
'selection.count': hasEntity ? 1 : 0,
|
|
443
|
+
'model.loaded': true,
|
|
444
|
+
};
|
|
445
|
+
const titleFor = (c: ResolvedContextMenuContribution): string => {
|
|
446
|
+
if (c.title) return c.title;
|
|
447
|
+
const found = commandPalette.find((cp) => cp.payload.id === c.command);
|
|
448
|
+
return found?.payload.title ?? c.command;
|
|
449
|
+
};
|
|
450
|
+
const visible = contributions.filter((c) => {
|
|
451
|
+
const when = c.payload.when;
|
|
452
|
+
if (!when) return true;
|
|
453
|
+
const parsed = parseWhen(when);
|
|
454
|
+
if (!parsed.ok) return false;
|
|
455
|
+
return evaluateWhen(parsed.value, whenContext);
|
|
456
|
+
});
|
|
457
|
+
if (visible.length === 0) return null;
|
|
458
|
+
return (
|
|
459
|
+
<>
|
|
460
|
+
<div className="h-px bg-border my-1" />
|
|
461
|
+
{visible.map((c) => {
|
|
462
|
+
const Icon = resolveExtensionIcon(c.payload.icon);
|
|
463
|
+
return (
|
|
464
|
+
<MenuItem
|
|
465
|
+
key={`${c.extensionId}:${c.payload.command}`}
|
|
466
|
+
icon={Icon}
|
|
467
|
+
label={titleFor(c.payload)}
|
|
468
|
+
onClick={() => {
|
|
469
|
+
closeContextMenu();
|
|
470
|
+
host?.runCommand(c.payload.command).catch((err) => {
|
|
471
|
+
toast.error(describeRunCommandError(c.payload.command, err));
|
|
472
|
+
});
|
|
473
|
+
}}
|
|
474
|
+
/>
|
|
475
|
+
);
|
|
476
|
+
})}
|
|
477
|
+
</>
|
|
478
|
+
);
|
|
479
|
+
}
|
|
480
|
+
|
|
411
481
|
type MenuItemTone = 'default' | 'destructive';
|
|
412
482
|
|
|
413
483
|
interface MenuItemProps {
|
|
@@ -50,6 +50,7 @@ import {
|
|
|
50
50
|
} from '@/components/ui/alert';
|
|
51
51
|
import { Progress } from '@/components/ui/progress';
|
|
52
52
|
import { useViewerStore } from '@/store';
|
|
53
|
+
import { useOptionalExtensionHost } from '@/sdk/ExtensionHostProvider';
|
|
53
54
|
import { configureMutationView } from '@/utils/configureMutationView';
|
|
54
55
|
import { toast } from '@/components/ui/toast';
|
|
55
56
|
import { ensureModelExportReady } from '@/services/desktop-export';
|
|
@@ -85,6 +86,9 @@ export function ExportDialog({ trigger }: ExportDialogProps) {
|
|
|
85
86
|
// Also get legacy single-model state for backward compatibility
|
|
86
87
|
const legacyIfcDataStore = useViewerStore((s) => s.ifcDataStore);
|
|
87
88
|
const legacyGeometryResult = useViewerStore((s) => s.geometryResult);
|
|
89
|
+
// Optional extension host — emits the export.run action when present
|
|
90
|
+
// so the local pattern miner can spot load → export workflows.
|
|
91
|
+
const extensionHost = useOptionalExtensionHost();
|
|
88
92
|
|
|
89
93
|
const [open, setOpen] = useState(false);
|
|
90
94
|
const [schema, setSchema] = useState<SchemaVersion | ''>('');
|
|
@@ -315,6 +319,10 @@ export function ExportDialog({ trigger }: ExportDialogProps) {
|
|
|
315
319
|
if (!schema) return;
|
|
316
320
|
if (exportScope === 'single' && !selectedModel) return;
|
|
317
321
|
|
|
322
|
+
// Action log: content-free emit so the miner can spot
|
|
323
|
+
// "load → export" patterns. Format label only — no path / data.
|
|
324
|
+
extensionHost?.emitAction('export.run', { format: outputInfo.ext.replace(/^\./, '') });
|
|
325
|
+
|
|
318
326
|
setIsExporting(true);
|
|
319
327
|
setExportResult(null);
|
|
320
328
|
setExportProgress(null);
|
|
@@ -556,7 +564,7 @@ export function ExportDialog({ trigger }: ExportDialogProps) {
|
|
|
556
564
|
} finally {
|
|
557
565
|
setIsExporting(false);
|
|
558
566
|
}
|
|
559
|
-
}, [selectedModel, selectedModelId, schema, isIfc5, exportScope, includeGeometry, applyMutations, changesOnly, visibleOnly, onlyKnownProperties, getMutationView, getLocalHiddenIds, getLocalIsolatedIds, modifiedCount, models]);
|
|
567
|
+
}, [selectedModel, selectedModelId, schema, isIfc5, exportScope, includeGeometry, applyMutations, changesOnly, visibleOnly, onlyKnownProperties, getMutationView, getLocalHiddenIds, getLocalIsolatedIds, modifiedCount, models, extensionHost, outputInfo]);
|
|
560
568
|
|
|
561
569
|
return (
|
|
562
570
|
<Dialog open={open} onOpenChange={setOpen}>
|
|
@@ -20,6 +20,7 @@ function GithubIcon({ className }: { className?: string }) {
|
|
|
20
20
|
import { Button } from '@/components/ui/button';
|
|
21
21
|
import { Tabs, TabsList, TabsTrigger, TabsContent } from '@/components/ui/tabs';
|
|
22
22
|
import { KEYBOARD_SHORTCUTS } from '@/hooks/useKeyboardShortcuts';
|
|
23
|
+
import { navigateToPath } from '@/services/app-navigation';
|
|
23
24
|
|
|
24
25
|
const GITHUB_URL = 'https://github.com/LTplus-AG/ifc-lite';
|
|
25
26
|
|
|
@@ -431,12 +432,26 @@ export function KeyboardShortcutsDialog({ open, onClose }: InfoDialogProps) {
|
|
|
431
432
|
return (
|
|
432
433
|
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm">
|
|
433
434
|
<div className="bg-card border rounded-lg shadow-xl w-full max-w-md m-4">
|
|
434
|
-
{/* Header
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
435
|
+
{/* Header — the MCP CTA lives here, in line with the title, so
|
|
436
|
+
it's a discoverable "what else can this do?" affordance
|
|
437
|
+
without crowding the modeling toolbar. */}
|
|
438
|
+
<div className="flex items-center justify-between gap-2 p-4 border-b">
|
|
439
|
+
<h2 className="text-lg font-semibold shrink-0">Info</h2>
|
|
440
|
+
<div className="flex items-center gap-1 min-w-0">
|
|
441
|
+
<button
|
|
442
|
+
type="button"
|
|
443
|
+
onClick={() => { onClose(); navigateToPath('/mcp'); }}
|
|
444
|
+
className="group inline-flex items-center gap-1.5 rounded-full border border-primary/30 bg-primary/5 hover:bg-primary/10 hover:border-primary/50 transition-colors px-3 py-1.5 text-xs font-medium text-primary"
|
|
445
|
+
aria-label="Open ifc-lite MCP — drive ifc-lite from any LLM"
|
|
446
|
+
>
|
|
447
|
+
<Sparkles className="h-3.5 w-3.5 group-hover:rotate-12 transition-transform" />
|
|
448
|
+
<span className="whitespace-nowrap">Drive from any LLM</span>
|
|
449
|
+
<ExternalLink className="h-3 w-3 opacity-60" />
|
|
450
|
+
</button>
|
|
451
|
+
<Button variant="ghost" size="icon-sm" onClick={onClose}>
|
|
452
|
+
<X className="h-4 w-4" />
|
|
453
|
+
</Button>
|
|
454
|
+
</div>
|
|
440
455
|
</div>
|
|
441
456
|
|
|
442
457
|
{/* Tabbed Content */}
|
|
@@ -44,6 +44,7 @@ const TYPE_LABELS: Record<string, string> = {
|
|
|
44
44
|
quantity: 'Quantity',
|
|
45
45
|
classification: 'Classification',
|
|
46
46
|
material: 'Material',
|
|
47
|
+
model: 'Model',
|
|
47
48
|
};
|
|
48
49
|
|
|
49
50
|
interface LensPanelProps {
|
|
@@ -285,6 +286,11 @@ function RuleEditor({
|
|
|
285
286
|
onRequestDiscovery: (categories: { properties?: boolean; quantities?: boolean; classifications?: boolean; materials?: boolean }) => void;
|
|
286
287
|
}) {
|
|
287
288
|
const criteriaType = rule.criteria.type;
|
|
289
|
+
const loadedModels = useViewerStore((s) => s.models);
|
|
290
|
+
const modelOptions = useMemo(
|
|
291
|
+
() => Array.from(loadedModels.values()).sort((a, b) => a.name.localeCompare(b.name)),
|
|
292
|
+
[loadedModels],
|
|
293
|
+
);
|
|
288
294
|
|
|
289
295
|
// Trigger lazy discovery when user selects a criteria type that needs it
|
|
290
296
|
useEffect(() => {
|
|
@@ -300,6 +306,18 @@ function RuleEditor({
|
|
|
300
306
|
}
|
|
301
307
|
}, [criteriaType, discovered, onRequestDiscovery]);
|
|
302
308
|
|
|
309
|
+
// Auto-populate the single available model so the selector-hidden branch
|
|
310
|
+
// doesn't leave a model rule permanently invalid.
|
|
311
|
+
useEffect(() => {
|
|
312
|
+
if (criteriaType !== 'model') return;
|
|
313
|
+
if (modelOptions.length !== 1) return;
|
|
314
|
+
if (rule.criteria.modelId) return;
|
|
315
|
+
const updated = { ...rule.criteria, modelId: modelOptions[0].id };
|
|
316
|
+
onChange({ criteria: updated, name: deriveRuleName(updated) });
|
|
317
|
+
// deriveRuleName is stable for this render; depending on rule.criteria/onChange is enough.
|
|
318
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
319
|
+
}, [criteriaType, modelOptions, rule.criteria, onChange]);
|
|
320
|
+
|
|
303
321
|
// Derived lists from discovered data
|
|
304
322
|
const ifcClasses = useMemo(() => discovered?.classes ?? [], [discovered]);
|
|
305
323
|
const psetNames = useMemo((): string[] => {
|
|
@@ -350,6 +368,9 @@ function RuleEditor({
|
|
|
350
368
|
case 'material':
|
|
351
369
|
base.materialName = '';
|
|
352
370
|
break;
|
|
371
|
+
case 'model':
|
|
372
|
+
base.modelId = modelOptions.length === 1 ? modelOptions[0].id : '';
|
|
373
|
+
break;
|
|
353
374
|
}
|
|
354
375
|
onChange({ criteria: base, name: rule.name === 'New Rule' ? TYPE_LABELS[newType] : rule.name });
|
|
355
376
|
};
|
|
@@ -363,6 +384,10 @@ function RuleEditor({
|
|
|
363
384
|
case 'quantity': return criteria.quantityName || 'Quantity';
|
|
364
385
|
case 'classification': return criteria.classificationCode || criteria.classificationSystem || 'Classification';
|
|
365
386
|
case 'material': return criteria.materialName || 'Material';
|
|
387
|
+
case 'model': {
|
|
388
|
+
const selected = modelOptions.find(m => m.id === criteria.modelId);
|
|
389
|
+
return selected?.name || 'Model';
|
|
390
|
+
}
|
|
366
391
|
default: return 'Rule';
|
|
367
392
|
}
|
|
368
393
|
};
|
|
@@ -516,6 +541,30 @@ function RuleEditor({
|
|
|
516
541
|
/>
|
|
517
542
|
)}
|
|
518
543
|
|
|
544
|
+
{/* Model: dropdown from loaded federated models */}
|
|
545
|
+
{criteriaType === 'model' && (
|
|
546
|
+
modelOptions.length <= 1 ? (
|
|
547
|
+
<span className="flex-1 min-w-0 text-xs text-zinc-400 dark:text-zinc-500 truncate">
|
|
548
|
+
{modelOptions.length === 0 ? 'No models loaded' : modelOptions[0]?.name ?? 'Model'}
|
|
549
|
+
</span>
|
|
550
|
+
) : (
|
|
551
|
+
<select
|
|
552
|
+
value={rule.criteria.modelId ?? ''}
|
|
553
|
+
onChange={(e) => {
|
|
554
|
+
const modelId = e.target.value;
|
|
555
|
+
const updated = { ...rule.criteria, modelId };
|
|
556
|
+
onChange({ criteria: updated, name: deriveRuleName(updated) });
|
|
557
|
+
}}
|
|
558
|
+
className={cn(selectClass, 'flex-1 min-w-0')}
|
|
559
|
+
>
|
|
560
|
+
<option value="">Model...</option>
|
|
561
|
+
{modelOptions.map(m => (
|
|
562
|
+
<option key={m.id} value={m.id}>{m.name}</option>
|
|
563
|
+
))}
|
|
564
|
+
</select>
|
|
565
|
+
)
|
|
566
|
+
)}
|
|
567
|
+
|
|
519
568
|
<button
|
|
520
569
|
onClick={onRemove}
|
|
521
570
|
className="text-zinc-400 hover:text-red-500 dark:text-zinc-500 dark:hover:text-red-400 p-0.5 flex-shrink-0"
|
|
@@ -644,6 +693,7 @@ function LensEditor({
|
|
|
644
693
|
case 'quantity': return !!c.quantitySet && !!c.quantityName;
|
|
645
694
|
case 'classification': return !!c.classificationSystem || !!c.classificationCode;
|
|
646
695
|
case 'material': return !!c.materialName;
|
|
696
|
+
case 'model': return !!c.modelId;
|
|
647
697
|
default: return false;
|
|
648
698
|
}
|
|
649
699
|
};
|