@archilogic/extension-sdk 0.13.2 → 0.14.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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @archilogic/extension-sdk
2
2
 
3
+ ## 0.14.0
4
+
5
+ ### Minor Changes
6
+
7
+ - b4c58c3: Extensions can track the 2D viewport and frame arbitrary areas. The host may call the new `onCanvasChange` extension API (received as the `canvas-change` event) carrying a tagged `CanvasView2d` (`canvasMode: '2d'`) with the current `viewBox` in meters, `pixelsPerMeter` zoom scale and canvas pixel size — enabling screen-space tooling such as constant-pixel pick tolerances. The `canvasMode` discriminant reserves room for a future 3D canvas without renaming `CanvasChange`. The new `hostApi.zoomToBoundingBox({ min, max, animate })` lets an extension zoom the plan to a custom region, e.g. a drawing it rendered itself.
8
+ - 279ff09: Canvas pointer events now carry the keyboard `modifiers` (shift, alt, ctrl, meta) held at the time of the interaction, on both `onCanvasClick` and `onCanvasMouseMove`. The field is optional, so hosts that predate modifier forwarding keep working.
9
+ - c7bd399: Extensions can subscribe to canvas mousemove: the host may call the new `onCanvasMouseMove` extension API and extensions receive it as the `canvas-mousemove` event, enabling hover-driven tooling on the plan.
10
+
3
11
  ## 0.13.2
4
12
 
5
13
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -167,6 +167,47 @@ declare type BoundingBox3d = {
167
167
  max: Vector3;
168
168
  };
169
169
 
170
+ /**
171
+ * The canvas viewport as delivered to `onCanvasChange`. Today it is always the 2D view; a future
172
+ * 3D canvas would add a `CanvasView3d` (`canvasMode: '3d'`, camera pose) and widen this to
173
+ * `CanvasView2d | CanvasView3d` — extensions that switch on `canvasMode` stay forward-compatible.
174
+ */
175
+ export declare type CanvasChange = CanvasView2d;
176
+
177
+ /**
178
+ * Keyboard modifier state at the moment of a canvas pointer event. Extensions can't listen to
179
+ * keys on the host document, so the host snapshots the modifiers into each event — e.g. for
180
+ * CAD-style selection where shift-click adds and alt-click removes.
181
+ */
182
+ export declare type CanvasModifiers = {
183
+ shift: boolean;
184
+ alt: boolean;
185
+ ctrl: boolean;
186
+ meta: boolean;
187
+ };
188
+
189
+ /**
190
+ * State of the 2D canvas viewport, emitted whenever the user pans, zooms or the canvas resizes.
191
+ * Lets an extension work in screen space — e.g. keep a pick tolerance at a constant pixel size
192
+ * (`tolerancePx / pixelsPerMeter` meters) so it tightens as the user zooms in. The `canvasMode`
193
+ * discriminant leaves room for a future 3D canvas without changing the `CanvasChange` name.
194
+ */
195
+ export declare type CanvasView2d = {
196
+ canvasMode: '2d';
197
+ /** Visible plan area in meters, `[x, y]` corners in layout space. */
198
+ viewBox: {
199
+ min: Vector2;
200
+ max: Vector2;
201
+ };
202
+ /** Screen pixels per plan meter — the zoom scale. */
203
+ pixelsPerMeter: number;
204
+ /** Canvas size in CSS pixels. */
205
+ canvas: {
206
+ width: number;
207
+ height: number;
208
+ };
209
+ };
210
+
170
211
  declare interface CircleCurve extends CurveBase {
171
212
  type: CircleCurveType;
172
213
  position?: Vector2;
@@ -697,10 +738,19 @@ export declare type ExtensionApi = {
697
738
  position: [number, number];
698
739
  nodeId: string;
699
740
  }): void;
700
- onCanvasClick({ position, nodeId }: {
741
+ onCanvasClick({ position, nodeId, modifiers }: {
742
+ position: [number, number];
743
+ nodeId?: string;
744
+ /** Absent on hosts that predate modifier forwarding. */
745
+ modifiers?: CanvasModifiers;
746
+ }): void;
747
+ onCanvasMouseMove({ position, nodeId, modifiers }: {
701
748
  position: [number, number];
702
749
  nodeId?: string;
750
+ /** Absent on hosts that predate modifier forwarding. */
751
+ modifiers?: CanvasModifiers;
703
752
  }): void;
753
+ onCanvasChange(change: CanvasChange): void;
704
754
  };
705
755
 
706
756
  declare type ExtensionEventKey = keyof ExtensionEventMap;
@@ -712,6 +762,8 @@ declare type ExtensionEventMap = {
712
762
  'selection-change': Parameters<ExtensionApi['onSelectionChange']>[0];
713
763
  'graphic-drag': Parameters<ExtensionApi['onGraphicDrag']>[0];
714
764
  'canvas-click': Parameters<ExtensionApi['onCanvasClick']>[0];
765
+ 'canvas-mousemove': Parameters<ExtensionApi['onCanvasMouseMove']>[0];
766
+ 'canvas-change': Parameters<ExtensionApi['onCanvasChange']>[0];
715
767
  };
716
768
 
717
769
  declare class ExtrusionGeometry extends ParametricGeometryBase {
@@ -1129,6 +1181,15 @@ export declare type HostApi = {
1129
1181
  margin?: number;
1130
1182
  animate?: number | boolean;
1131
1183
  }) => Promise<boolean>;
1184
+ /**
1185
+ * Frame an arbitrary area in plan meters — e.g. a custom drawing the extension rendered that
1186
+ * the host floor's own extents don't cover.
1187
+ */
1188
+ zoomToBoundingBox: (args: {
1189
+ min: Vector2;
1190
+ max: Vector2;
1191
+ animate?: number | boolean;
1192
+ }) => Promise<boolean>;
1132
1193
  drawNodeUpdate: (args: {
1133
1194
  nodeId: string;
1134
1195
  style: 'selected' | ShapeStyle | false;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@archilogic/extension-sdk",
3
3
  "description": "",
4
- "version": "0.13.2",
4
+ "version": "0.14.0",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },