@snaptrude/plugin-core 0.9.0 → 0.9.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.
Files changed (38) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/api-manifest.json +312 -0
  3. package/dist/api/core/io/terrain/index.d.ts +132 -0
  4. package/dist/api/core/io/terrain/index.d.ts.map +1 -1
  5. package/dist/api/presentation/annotate.d.ts +23 -4
  6. package/dist/api/presentation/annotate.d.ts.map +1 -1
  7. package/dist/api/presentation/diagrams.d.ts +64 -2
  8. package/dist/api/presentation/diagrams.d.ts.map +1 -1
  9. package/dist/api/presentation/index.d.ts +11 -1
  10. package/dist/api/presentation/index.d.ts.map +1 -1
  11. package/dist/api/presentation/placedViews.d.ts +772 -3
  12. package/dist/api/presentation/placedViews.d.ts.map +1 -1
  13. package/dist/api/presentation/shapes.d.ts +2 -2
  14. package/dist/api/presentation/sheets.d.ts +42 -0
  15. package/dist/api/presentation/sheets.d.ts.map +1 -1
  16. package/dist/api/presentation/slideshow.d.ts +125 -0
  17. package/dist/api/presentation/slideshow.d.ts.map +1 -0
  18. package/dist/api/presentation/tables.d.ts +81 -0
  19. package/dist/api/presentation/tables.d.ts.map +1 -0
  20. package/dist/api/program/site.d.ts +166 -2
  21. package/dist/api/program/site.d.ts.map +1 -1
  22. package/dist/api/workspace/index.d.ts +46 -1
  23. package/dist/api/workspace/index.d.ts.map +1 -1
  24. package/dist/index.cjs +829 -553
  25. package/dist/index.cjs.map +1 -1
  26. package/dist/index.js +797 -553
  27. package/dist/index.js.map +1 -1
  28. package/package.json +1 -1
  29. package/src/api/core/io/terrain/index.ts +143 -0
  30. package/src/api/presentation/annotate.ts +27 -2
  31. package/src/api/presentation/diagrams.ts +67 -2
  32. package/src/api/presentation/index.ts +11 -1
  33. package/src/api/presentation/placedViews.ts +760 -3
  34. package/src/api/presentation/sheets.ts +54 -0
  35. package/src/api/presentation/slideshow.ts +134 -0
  36. package/src/api/presentation/tables.ts +84 -0
  37. package/src/api/program/site.ts +110 -2
  38. package/src/api/workspace/index.ts +48 -1
@@ -9,8 +9,8 @@ import { PluginSheetPosition } from "./sheets"
9
9
  * (or the open canvas) — the live linked view shape
10
10
  * {@linkcode PluginPresentationSheetsApi.place} and the Present views panel's
11
11
  * drag-drop create. These methods read and edit the **layout** of those
12
- * shapes: where they sit, how big they are, their architectural scale, and
13
- * their crop. To refresh a placed view's **content** from the current model,
12
+ * shapes: where they sit, how big they are, their rotation, their
13
+ * architectural scale, and their crop. To refresh a placed view's **content** from the current model,
14
14
  * use `sheets.updatePlacedView` — content refresh lives on `sheets`,
15
15
  * layout lives here.
16
16
  *
@@ -212,6 +212,407 @@ export abstract class PluginPresentationPlacedViewsApi {
212
212
  shapeId: string,
213
213
  crop: PluginPlacedViewCrop | null,
214
214
  ): PluginApiReturn<PluginPlacedView>
215
+
216
+ /**
217
+ * Set a placed view's rotation.
218
+ *
219
+ * `rotation` is the **absolute** angle in radians (tldraw convention) — the
220
+ * value the record's `rotation` field reads back. Values are canonicalized
221
+ * into `[0, 2π)`, so pass values in that range for an exact round-trip
222
+ * (`setRotation(-0.1)` reads back as `2π − 0.1`). The view rotates about
223
+ * its bounds center (the same pivot as the UI rotation handle). One undo
224
+ * step. Joins the absolute-setter family
225
+ * `setScale`/`setCrop`/`setOpacity`/`setMask`.
226
+ *
227
+ * **3D placed views only.** 2D and site-plan views cannot rotate — the
228
+ * canvas hides their rotate handle and reverts any rotation applied to
229
+ * them — so calling this on one is refused with a typed
230
+ * `PRECONDITION_FAILED` instead of silently no-opping. Requires Present
231
+ * mode to be open.
232
+ *
233
+ * @param shapeId - The placed view shape to rotate.
234
+ * @param rotation - Absolute rotation in radians.
235
+ * @returns The updated {@linkcode PluginPlacedView}.
236
+ * @throws If Present mode is not open, `shapeId` is unknown or is not a
237
+ * placed view, `rotation` is not a finite number, or the placed view is
238
+ * a 2D/site-plan view (`PRECONDITION_FAILED` — only 3D views rotate).
239
+ *
240
+ * @examplePrompt Rotate the placed plan 90 degrees
241
+ * @examplePrompt Set this view's rotation to 45 degrees
242
+ * @examplePrompt Straighten the placed view back to zero rotation
243
+ *
244
+ * # Example
245
+ * ```ts
246
+ * await snaptrude.presentation.placedViews.setRotation(shapeId, Math.PI / 2)
247
+ * ```
248
+ */
249
+ public abstract setRotation(
250
+ shapeId: string,
251
+ rotation: number,
252
+ ): PluginApiReturn<PluginPlacedView>
253
+
254
+ // ── Present-mode styling ──────────────────────────────────────────────────
255
+
256
+ /**
257
+ * Read a placed view's (or sheet's) per-category presentation styles.
258
+ *
259
+ * Returns one entry per style category (Site, Topography, Space, Department,
260
+ * Envelope, Facade/Mass, Dimension, Reference Line, Adjacency Line,
261
+ * Landscape elements — sheets/auto-diagrams use their 3-category subset)
262
+ * with the **fully-resolved** setting values (defaults merged with this
263
+ * shape's overrides), which setting ids the category supports, whether the
264
+ * category is currently disabled (not visible in the view), and — where the
265
+ * category has a Text tab — its label font styles. Styles are stored **per
266
+ * placed shape instance**: the same saved view placed twice can read
267
+ * differently. Requires Present mode to be open.
268
+ *
269
+ * @param shapeId - The placed view (or sheet) shape to read.
270
+ * @throws If Present mode is not open or `shapeId` is not a styleable shape.
271
+ *
272
+ * @examplePrompt What line weights is this placed plan using?
273
+ * @examplePrompt Read the styling of the placed view
274
+ * @examplePrompt Which categories can I restyle on this sheet?
275
+ *
276
+ * # Example
277
+ * ```ts
278
+ * const styles = await snaptrude.presentation.placedViews.getStyles(shapeId)
279
+ * const space = styles.categories.find((c) => c.category === "Space")
280
+ * console.log(space?.settings.cutWidth, space?.settings.lineStyle)
281
+ * ```
282
+ */
283
+ public abstract getStyles(
284
+ shapeId: string,
285
+ ): PluginApiReturn<PluginPlacedViewStylesResult>
286
+
287
+ /**
288
+ * Update one style category on a placed view (or sheet) — the same writes
289
+ * the Present sidebar's per-category configure panel performs.
290
+ *
291
+ * The patch may set any subset of the category's settings: line style (7
292
+ * dash patterns), line color, dash-length multiplier, line weights in mm
293
+ * (`cutWidth` vs `projectionWidth` — Revit-style cut/projection distinction;
294
+ * `lineWidth` where the category has a single weight; `treeLineWidth` /
295
+ * `parkingLineWidth` for Landscape), fill `colorMode` (`department`,
296
+ * `texture`, `monochrome`, or `tag:<tagCategoryId>`), per-category fill
297
+ * `opacity` (0–100), category `hide` (cascades to that category's labels),
298
+ * the shape restyle `viewStyle` (`NONE` block / `FILLET` rounded with
299
+ * `radius` / `BUBBLE`) with `radius` and `inset`, and Topography's
300
+ * map/building sub-controls. Settings a category does not support are
301
+ * rejected. Writes are validated, undoable (one history stop per call), and
302
+ * re-render immediately; on an auto-diagram sheet the write fans out to
303
+ * every sheet in its diagram set. Requires Present mode to be open.
304
+ *
305
+ * @param shapeId - The placed view (or sheet) shape to restyle.
306
+ * @param category - The style category to update.
307
+ * @param patch - The settings to change (at least one).
308
+ * @returns The category's resolved styles after the update.
309
+ * @throws If Present mode is not open, `shapeId` is not a styleable shape,
310
+ * the category does not apply to this shape, or a patched setting is not
311
+ * supported by the category or fails validation.
312
+ *
313
+ * @examplePrompt Set the Space cut line weight to 0.5 mm
314
+ * @examplePrompt Make the Department lines dashed
315
+ * @examplePrompt Color the plan by department
316
+ * @examplePrompt Hide the dimension lines on this view
317
+ * @examplePrompt Round the space corners with a 2 ft radius
318
+ *
319
+ * # Example
320
+ * ```ts
321
+ * await snaptrude.presentation.placedViews.updateStyles(shapeId, "Space", {
322
+ * cutWidth: 0.5,
323
+ * projectionWidth: 0.18,
324
+ * lineStyle: "dashed",
325
+ * colorMode: "department",
326
+ * })
327
+ * ```
328
+ */
329
+ public abstract updateStyles(
330
+ shapeId: string,
331
+ category: PluginViewSettingCategory,
332
+ patch: PluginPlacedViewStylePatch,
333
+ ): PluginApiReturn<PluginPlacedViewCategoryStyles>
334
+
335
+ /**
336
+ * Reset a placed view's styling to defaults — the sidebar's Reset button:
337
+ * clears every per-category override and view-style restyle, resets font
338
+ * styles, and un-hides labels hidden by styling. Undoable. Requires Present
339
+ * mode to be open.
340
+ *
341
+ * @param shapeId - The placed view (or sheet) shape to reset.
342
+ * @throws If Present mode is not open or `shapeId` is not a styleable shape.
343
+ *
344
+ * @examplePrompt Reset this view's styling
345
+ * @examplePrompt Clear all the style overrides on the placed plan
346
+ * @examplePrompt Put the sheet styles back to default
347
+ */
348
+ public abstract resetStyles(shapeId: string): PluginApiReturn<void>
349
+
350
+ /**
351
+ * Update a category's label typography on a placed view (or sheet) — the
352
+ * configure panel's Text tab.
353
+ *
354
+ * Each category carries font styles per label type — `objectLabels` (the
355
+ * name), `department`, and `areas` — with `fontFamily` (system families or
356
+ * any Google Font; the font is loaded automatically and the weight is
357
+ * coerced to an available variant), `fontWeight` (numeric string, e.g.
358
+ * `"700"`), `fontStyle` (`normal`/`italic`), and `fontSize` in px.
359
+ * `visibleTypes` controls which label types render (an empty array hides
360
+ * all). Not every category has a Text tab — Topography, Facade/Mass,
361
+ * Reference Line and Adjacency Line reject font writes. Undoable. Requires
362
+ * Present mode to be open.
363
+ *
364
+ * @param shapeId - The placed view (or sheet) shape.
365
+ * @param category - The style category whose labels to restyle.
366
+ * @param patch - The font styles to change (at least one field).
367
+ * @throws If Present mode is not open, `shapeId` is not a styleable shape,
368
+ * or the category has no Text tab.
369
+ *
370
+ * @examplePrompt Set the space labels to Roboto 24px bold
371
+ * @examplePrompt Hide the area values on this plan
372
+ * @examplePrompt Make the department labels italic
373
+ *
374
+ * # Example
375
+ * ```ts
376
+ * await snaptrude.presentation.placedViews.updateFontStyles(shapeId, "Space", {
377
+ * objectLabels: { fontFamily: "Roboto", fontWeight: "700", fontSize: 24 },
378
+ * visibleTypes: ["objectLabels", "areas"],
379
+ * })
380
+ * ```
381
+ */
382
+ public abstract updateFontStyles(
383
+ shapeId: string,
384
+ category: PluginViewSettingCategory,
385
+ patch: PluginPlacedViewFontStylesPatch,
386
+ ): PluginApiReturn<void>
387
+
388
+ // ── Labels ────────────────────────────────────────────────────────────────
389
+
390
+ /**
391
+ * List a placed view's labels — the text children generated from the view's
392
+ * content (space names, departments, areas, dimension texts). Each label is
393
+ * individually addressable: it can be moved and hidden. Returns `[]` when
394
+ * the view has no labels. Requires Present mode to be open.
395
+ *
396
+ * @param shapeId - The placed view shape whose labels to list.
397
+ * @throws If Present mode is not open or `shapeId` is not a placed view.
398
+ *
399
+ * @examplePrompt List the labels on this placed plan
400
+ * @examplePrompt Where are the space labels on this view?
401
+ * @examplePrompt Show every label with its position
402
+ *
403
+ * # Example
404
+ * ```ts
405
+ * const { labels } = await snaptrude.presentation.placedViews.listLabels(shapeId)
406
+ * for (const l of labels) console.log(l.text, l.position, l.hidden)
407
+ * ```
408
+ */
409
+ public abstract listLabels(
410
+ shapeId: string,
411
+ ): PluginApiReturn<PluginPlacedViewLabelsResult>
412
+
413
+ /**
414
+ * Move a label to a new position (coordinates relative to its placed view,
415
+ * the same space `listLabels` reports). The manual position survives style
416
+ * changes. Undoable. Requires Present mode to be open.
417
+ *
418
+ * @param labelId - The label to move (from `listLabels`).
419
+ * @param position - New position, parent-view-relative.
420
+ * @throws If Present mode is not open or `labelId` is not a view label.
421
+ *
422
+ * @examplePrompt Move the kitchen label out of the hatched area
423
+ * @examplePrompt Nudge this label 20 units right
424
+ * @examplePrompt Reposition the area text
425
+ */
426
+ public abstract moveLabel(
427
+ labelId: string,
428
+ position: PluginSheetPosition,
429
+ ): PluginApiReturn<PluginPlacedViewLabel>
430
+
431
+ /**
432
+ * Hide or show a single label (independent of the category-level label
433
+ * visibility). Undoable. Requires Present mode to be open.
434
+ *
435
+ * @param labelId - The label to hide/show (from `listLabels`).
436
+ * @param hidden - `true` to hide, `false` to show.
437
+ * @throws If Present mode is not open or `labelId` is not a view label.
438
+ *
439
+ * @examplePrompt Hide the corridor label
440
+ * @examplePrompt Show that label again
441
+ */
442
+ public abstract setLabelHidden(
443
+ labelId: string,
444
+ hidden: boolean,
445
+ ): PluginApiReturn<PluginPlacedViewLabel>
446
+
447
+ // ── Canvas shapes (generated outputs, images, annotations) ────────────────
448
+
449
+ /**
450
+ * List the top-level shapes on the Present canvas — not just placed views:
451
+ * AI-generated outputs, placed diagram images, plugin-created shapes, and
452
+ * annotations, each with an `origin` classification. Sheets (frames) are
453
+ * not listed — use `sheets.list`. Pass `sheetId` to list only shapes on
454
+ * that sheet. Returns `[]` when Present mode is closed.
455
+ *
456
+ * @param sheetId - Optional sheet id to filter by.
457
+ *
458
+ * @examplePrompt List everything on the Present canvas
459
+ * @examplePrompt What AI outputs are on this sheet?
460
+ * @examplePrompt Show all the shapes with their positions
461
+ *
462
+ * # Example
463
+ * ```ts
464
+ * const { shapes } = await snaptrude.presentation.placedViews.listShapes()
465
+ * const aiOutputs = shapes.filter((s) => s.origin === "aiOutput")
466
+ * ```
467
+ */
468
+ public abstract listShapes(
469
+ sheetId?: string,
470
+ ): PluginApiReturn<PluginCanvasShapesListResult>
471
+
472
+ /**
473
+ * Get one Present-canvas shape by id — works for any top-level shape
474
+ * (placed view, AI output, diagram image, plugin shape, annotation), unlike
475
+ * `get` which requires a placed view. Requires Present mode to be open.
476
+ *
477
+ * @param shapeId - The shape to read.
478
+ * @throws If Present mode is not open or `shapeId` is unknown or a sheet.
479
+ *
480
+ * @examplePrompt Inspect the AI render I just generated
481
+ * @examplePrompt Get the bounds of that diagram image
482
+ */
483
+ public abstract getShape(shapeId: string): PluginApiReturn<PluginCanvasShape>
484
+
485
+ /**
486
+ * Move any Present-canvas shape (AI outputs, diagram images, plugin shapes,
487
+ * annotations — placed views too). Same coordinate semantics as `move`:
488
+ * sheet-local when on a sheet, page coordinates otherwise; pass
489
+ * `options.sheetId` to reparent onto a sheet. Undoable. Requires Present
490
+ * mode to be open.
491
+ *
492
+ * @param shapeId - The shape to move.
493
+ * @param position - New top-left position.
494
+ * @param options - Optional `sheetId` to move the shape onto that sheet.
495
+ * @throws If Present mode is not open, `shapeId` is unknown or a sheet, or
496
+ * `options.sheetId` is not a sheet.
497
+ *
498
+ * @examplePrompt Move the AI render to the top of the sheet
499
+ * @examplePrompt Put the diagram image at 100, 200
500
+ */
501
+ public abstract moveShape(
502
+ shapeId: string,
503
+ position: PluginSheetPosition,
504
+ options?: { sheetId?: string },
505
+ ): PluginApiReturn<PluginCanvasShape>
506
+
507
+ /**
508
+ * Resize any Present-canvas shape by a uniform factor about its top-left
509
+ * corner (aspect ratio held) — the generic counterpart of `scale`, which
510
+ * requires a placed view. Undoable. Requires Present mode to be open.
511
+ *
512
+ * @param shapeId - The shape to resize.
513
+ * @param factor - Uniform scale factor, between `0.01` and `100`.
514
+ * @throws If Present mode is not open, `shapeId` is unknown or a sheet, or
515
+ * `factor` is out of range.
516
+ *
517
+ * @examplePrompt Make the AI output half its size
518
+ * @examplePrompt Double the size of that image
519
+ */
520
+ public abstract resizeShape(
521
+ shapeId: string,
522
+ factor: number,
523
+ ): PluginApiReturn<PluginCanvasShape>
524
+
525
+ /**
526
+ * Rotate any Present-canvas shape (AI outputs, diagram images, plugin
527
+ * shapes, annotations — placed views too) — the generic counterpart of
528
+ * `setRotation`, same target rules as `moveShape`. Same semantics:
529
+ * **absolute** angle in radians (tldraw convention) about the shape's
530
+ * bounds center, canonicalized into `[0, 2π)` (pass values in that range
531
+ * for an exact round-trip via `getShape`), one undo step. A placed view
532
+ * passed here falls under the same 3D-only rule as `setRotation`: 2D and
533
+ * site-plan views cannot rotate and are refused with a typed
534
+ * `PRECONDITION_FAILED`. Requires Present mode to be open.
535
+ *
536
+ * @param shapeId - The shape to rotate.
537
+ * @param rotation - Absolute rotation in radians.
538
+ * @throws If Present mode is not open, `shapeId` is unknown or a sheet,
539
+ * `rotation` is not a finite number, or the target is a 2D/site-plan
540
+ * placed view (`PRECONDITION_FAILED` — only 3D views rotate).
541
+ *
542
+ * @examplePrompt Rotate the AI render 15 degrees
543
+ * @examplePrompt Turn that image sideways
544
+ * @examplePrompt Reset the diagram image's rotation
545
+ */
546
+ public abstract rotateShape(
547
+ shapeId: string,
548
+ rotation: number,
549
+ ): PluginApiReturn<PluginCanvasShape>
550
+
551
+ /**
552
+ * Delete Present-canvas shapes. One undoable step for the whole batch, and
553
+ * the batch is atomic — if any id is rejected, nothing is deleted.
554
+ *
555
+ * Deletable: placed views, AI-generated outputs, placed diagram images, and
556
+ * shapes created by plugins. **Not deletable here:** sheets (use
557
+ * `sheets.delete`) and user-drawn annotations (draw, geo, arrow, note,
558
+ * text, highlight, line shapes without a plugin ownership stamp) — those
559
+ * reject with a validation error. Requires Present mode to be open.
560
+ *
561
+ * @param shapeIds - The shapes to delete (at least one).
562
+ * @returns The deleted shape ids.
563
+ * @throws If Present mode is not open, or any id is unknown, a sheet, or a
564
+ * protected user annotation.
565
+ *
566
+ * @examplePrompt Delete the old AI renders from the sheet
567
+ * @examplePrompt Remove that placed view
568
+ * @examplePrompt Clear the diagram images I placed
569
+ *
570
+ * # Example
571
+ * ```ts
572
+ * const { deleted } = await snaptrude.presentation.placedViews.deleteShapes([
573
+ * out1.shapeId,
574
+ * out2.shapeId,
575
+ * ])
576
+ * ```
577
+ */
578
+ public abstract deleteShapes(
579
+ shapeIds: string[],
580
+ ): PluginApiReturn<PluginCanvasShapesDeleteResult>
581
+
582
+ /**
583
+ * Set a Present-canvas shape's opacity (`0` transparent .. `1` opaque) —
584
+ * the sidebar's whole-shape opacity slider (distinct from the per-category
585
+ * fill opacity in `updateStyles`). Works for any top-level shape. Undoable.
586
+ * Requires Present mode to be open.
587
+ *
588
+ * @param shapeId - The shape to change.
589
+ * @param opacity - Target opacity, `0`..`1`.
590
+ * @throws If Present mode is not open or `shapeId` is unknown or a sheet.
591
+ *
592
+ * @examplePrompt Fade the placed view to 50%
593
+ * @examplePrompt Make the AI render semi-transparent
594
+ */
595
+ public abstract setOpacity(
596
+ shapeId: string,
597
+ opacity: number,
598
+ ): PluginApiReturn<void>
599
+
600
+ /**
601
+ * Toggle "mask context buildings" on a placed view — mutes the inactive
602
+ * proposal buildings in the view (the sidebar checkbox). Views only.
603
+ * Undoable. Requires Present mode to be open.
604
+ *
605
+ * @param shapeId - The placed view shape.
606
+ * @param enabled - `true` to mask context buildings.
607
+ * @throws If Present mode is not open or `shapeId` is not a placed view.
608
+ *
609
+ * @examplePrompt Mask the context buildings in this view
610
+ * @examplePrompt Show the neighboring proposals again in the placed view
611
+ */
612
+ public abstract setMask(
613
+ shapeId: string,
614
+ enabled: boolean,
615
+ ): PluginApiReturn<void>
215
616
  }
216
617
 
217
618
  /** A point in crop space — fractions (0–1) of the uncropped view. */
@@ -253,7 +654,7 @@ export type PluginPlacedViewCrop = z.infer<typeof PluginPlacedViewCrop>
253
654
  * | `size` | `{ width: number, height: number }` | Displayed size on the canvas |
254
655
  * | `scale` | `number \| null` | Architectural scale (e.g. `100` = 1:100); `null` for 3D views |
255
656
  * | `is3d` | `boolean` | Whether it is a 3D view (no architectural scale) |
256
- * | `rotation` | `number` | Rotation in radians (nonzero only for 3D views) |
657
+ * | `rotation` | `number` | Rotation in radians, `[0, 2π)` (nonzero only for 3D views — 2D views cannot rotate; set with `setRotation`) |
257
658
  * | `crop` | {@linkcode PluginPlacedViewCrop}` \| null` | Crop window (`null` when uncropped) |
258
659
  * | `isUnlinked` | `boolean` | Whether the source proposal was removed (an unlinked view no longer refreshes) |
259
660
  */
@@ -361,3 +762,359 @@ export const PluginPresentationPlacedViewsSetCropArgs = z.object({
361
762
  export type PluginPresentationPlacedViewsSetCropArgs = z.infer<
362
763
  typeof PluginPresentationPlacedViewsSetCropArgs
363
764
  >
765
+
766
+ /**
767
+ * Arguments for {@linkcode PluginPresentationPlacedViewsApi.setRotation}.
768
+ *
769
+ * | Property | Type | Description |
770
+ * |---|---|---|
771
+ * | `shapeId` | `string` | The placed view shape to rotate |
772
+ * | `rotation` | `number` | Absolute rotation in radians (tldraw convention) |
773
+ */
774
+ export const PluginPresentationPlacedViewsSetRotationArgs = z.object({
775
+ shapeId: z.string().min(1),
776
+ rotation: z.number().finite(),
777
+ })
778
+ export type PluginPresentationPlacedViewsSetRotationArgs = z.infer<
779
+ typeof PluginPresentationPlacedViewsSetRotationArgs
780
+ >
781
+
782
+ // ── Styling ─────────────────────────────────────────────────────────────────
783
+
784
+ /**
785
+ * A Present-mode style category — mirrors the host's view-settings CATEGORIES
786
+ * exactly. Sheets/auto-diagrams use the subset Space / Department /
787
+ * Adjacency Line.
788
+ */
789
+ export const PluginViewSettingCategory = z.enum([
790
+ "Site",
791
+ "Topography",
792
+ "Space",
793
+ "Department",
794
+ "Envelope",
795
+ "Facade/Mass",
796
+ "Dimension",
797
+ "Reference Line",
798
+ "Adjacency Line",
799
+ "Landscape elements",
800
+ ])
801
+ export type PluginViewSettingCategory = z.infer<typeof PluginViewSettingCategory>
802
+
803
+ /** The 7 line dash styles (mirrors the host's LINE_STYLES). */
804
+ export const PluginViewLineStyle = z.enum([
805
+ "solid",
806
+ "dashed",
807
+ "dashdot",
808
+ "hidden",
809
+ "center",
810
+ "phantom",
811
+ "propertyLine",
812
+ ])
813
+ export type PluginViewLineStyle = z.infer<typeof PluginViewLineStyle>
814
+
815
+ /**
816
+ * A style patch for one category — any subset of the category's settings.
817
+ * Line weights are in **mm** (the printed weight); `opacity` values are 0–100;
818
+ * `colorMode` is `department` / `texture` / `monochrome` or `tag:<tagCategoryId>`
819
+ * (color by a project tag category).
820
+ *
821
+ * | Property | Type | Description |
822
+ * |---|---|---|
823
+ * | `hide` | `boolean`? | Hide the category (cascades to its labels) |
824
+ * | `lineStyle` | {@linkcode PluginViewLineStyle}? | Dash pattern |
825
+ * | `lineColor` | `string`? | Line color, 6-digit hex (`#` optional) |
826
+ * | `dashLength` | `number`? | Dash-length multiplier (> 0; `1` = default) |
827
+ * | `lineWidth` | `number`? | Single line weight in mm (categories without cut/projection) |
828
+ * | `cutWidth` | `number`? | Cut-line weight in mm |
829
+ * | `projectionWidth` | `number`? | Projection-line weight in mm |
830
+ * | `treeLineWidth` | `number`? | Tree line weight in mm (Landscape) |
831
+ * | `parkingLineWidth` | `number`? | Parking line weight in mm (Landscape) |
832
+ * | `colorMode` | `string`? | `department` \| `texture` \| `monochrome` \| `tag:<id>` |
833
+ * | `opacity` | `number`? | Category fill opacity, 0–100 |
834
+ * | `mapOpacity` | `number`? | Topography: map image opacity, 0–100 |
835
+ * | `buildingOpacity` | `number`? | Topography: context-building opacity, 0–100 |
836
+ * | `mapHide` | `boolean`? | Topography: hide the map image |
837
+ * | `buildingHide` | `boolean`? | Topography: hide context buildings |
838
+ * | `noBuilding` | `boolean`? | Topography: suppress buildings entirely |
839
+ * | `viewStyle` | `"NONE" \| "FILLET" \| "BUBBLE"`? | Shape restyle: block / rounded corner / bubble |
840
+ * | `radius` | `number`? | Corner radius for `FILLET` (feet) |
841
+ * | `inset` | `number`? | Shape inset/offset |
842
+ */
843
+ export const PluginPlacedViewStylePatch = z
844
+ .object({
845
+ hide: z.boolean().optional(),
846
+ lineStyle: PluginViewLineStyle.optional(),
847
+ lineColor: z
848
+ .string()
849
+ .regex(/^#?[0-9a-fA-F]{6}$/, "lineColor must be a 6-digit hex color")
850
+ .optional(),
851
+ dashLength: z.number().finite().positive().optional(),
852
+ lineWidth: z.number().finite().min(0).optional(),
853
+ cutWidth: z.number().finite().min(0).optional(),
854
+ projectionWidth: z.number().finite().min(0).optional(),
855
+ treeLineWidth: z.number().finite().min(0).optional(),
856
+ parkingLineWidth: z.number().finite().min(0).optional(),
857
+ colorMode: z
858
+ .string()
859
+ .refine(
860
+ (v) => ["department", "texture", "monochrome"].includes(v) || v.startsWith("tag:"),
861
+ { message: "colorMode must be department, texture, monochrome, or tag:<tagCategoryId>" },
862
+ )
863
+ .optional(),
864
+ opacity: z.number().finite().min(0).max(100).optional(),
865
+ mapOpacity: z.number().finite().min(0).max(100).optional(),
866
+ buildingOpacity: z.number().finite().min(0).max(100).optional(),
867
+ mapHide: z.boolean().optional(),
868
+ buildingHide: z.boolean().optional(),
869
+ noBuilding: z.boolean().optional(),
870
+ viewStyle: z.enum(["NONE", "FILLET", "BUBBLE"]).optional(),
871
+ radius: z.number().finite().min(0).optional(),
872
+ inset: z.number().finite().min(0).optional(),
873
+ })
874
+ .strict()
875
+ .refine((p) => Object.keys(p).length > 0, { message: "patch must set at least one setting" })
876
+ export type PluginPlacedViewStylePatch = z.infer<typeof PluginPlacedViewStylePatch>
877
+
878
+ /** Label types that carry typography in a category's Text tab. */
879
+ export const PluginViewLabelType = z.enum(["objectLabels", "department", "areas"])
880
+ export type PluginViewLabelType = z.infer<typeof PluginViewLabelType>
881
+
882
+ /** Typography patch for one label type. `fontSize` is in px. */
883
+ const PluginViewFontVariantPatch = z
884
+ .object({
885
+ fontFamily: z.string().min(1).optional(),
886
+ fontWeight: z
887
+ .string()
888
+ .regex(/^\d{3}$/, 'fontWeight must be a numeric string like "400" or "700"')
889
+ .optional(),
890
+ fontStyle: z.enum(["normal", "italic"]).optional(),
891
+ fontSize: z.number().finite().positive().max(200).optional(),
892
+ })
893
+ .strict()
894
+
895
+ /**
896
+ * Font-styles patch for one category's Text tab.
897
+ *
898
+ * | Property | Type | Description |
899
+ * |---|---|---|
900
+ * | `visibleTypes` | {@linkcode PluginViewLabelType}`[]`? | Which label types render (`[]` hides all) |
901
+ * | `objectLabels` | variant? | Typography for the name label |
902
+ * | `department` | variant? | Typography for the department label |
903
+ * | `areas` | variant? | Typography for the area/tag values |
904
+ */
905
+ export const PluginPlacedViewFontStylesPatch = z
906
+ .object({
907
+ visibleTypes: z.array(PluginViewLabelType).optional(),
908
+ objectLabels: PluginViewFontVariantPatch.optional(),
909
+ department: PluginViewFontVariantPatch.optional(),
910
+ areas: PluginViewFontVariantPatch.optional(),
911
+ })
912
+ .strict()
913
+ .refine((p) => Object.keys(p).length > 0, { message: "patch must set at least one field" })
914
+ export type PluginPlacedViewFontStylesPatch = z.infer<typeof PluginPlacedViewFontStylesPatch>
915
+
916
+ /** Resolved font styles for one label type (fontSize in px). */
917
+ export type PluginViewFontVariant = {
918
+ fontFamily?: string
919
+ fontWeight?: string
920
+ fontStyle?: "normal" | "italic"
921
+ fontSize?: number
922
+ }
923
+
924
+ /**
925
+ * One category's resolved styles on a placed view or sheet.
926
+ *
927
+ * | Property | Type | Description |
928
+ * |---|---|---|
929
+ * | `category` | {@linkcode PluginViewSettingCategory} | The category |
930
+ * | `disabled` | `boolean` | Not visible in this view — settings are inert |
931
+ * | `supported` | `string[]` | Setting ids this category accepts in `updateStyles` |
932
+ * | `settings` | {@linkcode PluginPlacedViewStylePatch} | Fully-resolved values (defaults + overrides) |
933
+ * | `fontStyles` | object? | Resolved Text-tab typography (absent when the category has no Text tab) |
934
+ */
935
+ export type PluginPlacedViewCategoryStyles = {
936
+ category: PluginViewSettingCategory
937
+ disabled: boolean
938
+ supported: string[]
939
+ settings: PluginPlacedViewStylePatch
940
+ fontStyles?: {
941
+ visibleTypes: PluginViewLabelType[]
942
+ objectLabels?: PluginViewFontVariant
943
+ department?: PluginViewFontVariant
944
+ areas?: PluginViewFontVariant
945
+ }
946
+ }
947
+
948
+ /**
949
+ * Result of {@link PluginPresentationPlacedViewsApi.getStyles}.
950
+ *
951
+ * | Property | Type | Description |
952
+ * |---|---|---|
953
+ * | `shapeId` | `string` | The styleable shape read |
954
+ * | `kind` | `"view" \| "sheet"` | Placed view or auto-diagram sheet |
955
+ * | `categories` | {@linkcode PluginPlacedViewCategoryStyles}`[]` | One entry per applicable category |
956
+ */
957
+ export type PluginPlacedViewStylesResult = {
958
+ shapeId: string
959
+ kind: "view" | "sheet"
960
+ categories: PluginPlacedViewCategoryStyles[]
961
+ }
962
+
963
+ /** Arguments for {@link PluginPresentationPlacedViewsApi.updateStyles}. */
964
+ export const PluginPlacedViewsUpdateStylesArgs = z.object({
965
+ shapeId: z.string().min(1),
966
+ category: PluginViewSettingCategory,
967
+ patch: PluginPlacedViewStylePatch,
968
+ })
969
+ export type PluginPlacedViewsUpdateStylesArgs = z.infer<typeof PluginPlacedViewsUpdateStylesArgs>
970
+
971
+ /** Arguments for {@link PluginPresentationPlacedViewsApi.updateFontStyles}. */
972
+ export const PluginPlacedViewsUpdateFontStylesArgs = z.object({
973
+ shapeId: z.string().min(1),
974
+ category: PluginViewSettingCategory,
975
+ patch: PluginPlacedViewFontStylesPatch,
976
+ })
977
+ export type PluginPlacedViewsUpdateFontStylesArgs = z.infer<
978
+ typeof PluginPlacedViewsUpdateFontStylesArgs
979
+ >
980
+
981
+ // ── Labels ──────────────────────────────────────────────────────────────────
982
+
983
+ /**
984
+ * A label on a placed view — a text child generated from the view content.
985
+ *
986
+ * | Property | Type | Description |
987
+ * |---|---|---|
988
+ * | `labelId` | `string` | The label's shape id (addressable in `moveLabel`/`setLabelHidden`) |
989
+ * | `category` | `string \| null` | The style category it belongs to (`null` when untagged) |
990
+ * | `text` | `string` | The rendered text |
991
+ * | `position` | {@linkcode PluginSheetPosition} | Position relative to the placed view |
992
+ * | `scale` | `number` | The label's scale factor |
993
+ * | `hidden` | `boolean` | Whether it is currently hidden |
994
+ */
995
+ export type PluginPlacedViewLabel = {
996
+ labelId: string
997
+ category: string | null
998
+ text: string
999
+ position: PluginSheetPosition
1000
+ scale: number
1001
+ hidden: boolean
1002
+ }
1003
+
1004
+ /** Result of {@link PluginPresentationPlacedViewsApi.listLabels}. */
1005
+ export type PluginPlacedViewLabelsResult = {
1006
+ labels: PluginPlacedViewLabel[]
1007
+ }
1008
+
1009
+ /** Arguments for {@link PluginPresentationPlacedViewsApi.moveLabel}. */
1010
+ export const PluginPlacedViewsMoveLabelArgs = z.object({
1011
+ labelId: z.string().min(1),
1012
+ position: PluginSheetPosition,
1013
+ })
1014
+ export type PluginPlacedViewsMoveLabelArgs = z.infer<typeof PluginPlacedViewsMoveLabelArgs>
1015
+
1016
+ /** Arguments for {@link PluginPresentationPlacedViewsApi.setLabelHidden}. */
1017
+ export const PluginPlacedViewsSetLabelHiddenArgs = z.object({
1018
+ labelId: z.string().min(1),
1019
+ hidden: z.boolean(),
1020
+ })
1021
+ export type PluginPlacedViewsSetLabelHiddenArgs = z.infer<
1022
+ typeof PluginPlacedViewsSetLabelHiddenArgs
1023
+ >
1024
+
1025
+ // ── Canvas shapes ───────────────────────────────────────────────────────────
1026
+
1027
+ /**
1028
+ * Origin classification of a Present-canvas shape: a placed view, an
1029
+ * AI-generated output, a placed diagram image, a plugin-created shape, a
1030
+ * user annotation, a plain image, or other.
1031
+ */
1032
+ export const PluginCanvasShapeOrigin = z.enum([
1033
+ "view",
1034
+ "aiOutput",
1035
+ "diagram",
1036
+ "pluginShape",
1037
+ "annotation",
1038
+ "image",
1039
+ "other",
1040
+ ])
1041
+ export type PluginCanvasShapeOrigin = z.infer<typeof PluginCanvasShapeOrigin>
1042
+
1043
+ /**
1044
+ * A top-level shape on the Present canvas.
1045
+ *
1046
+ * | Property | Type | Description |
1047
+ * |---|---|---|
1048
+ * | `shapeId` | `string` | The shape id |
1049
+ * | `type` | `string` | The canvas shape type (`view`, `image`, `geo`, `text`, …) |
1050
+ * | `origin` | {@linkcode PluginCanvasShapeOrigin} | What created it |
1051
+ * | `sheetId` | `string \| null` | The sheet it sits on (`null` when loose on the canvas) |
1052
+ * | `position` | {@linkcode PluginSheetPosition} | Top-left position (sheet-local; page coordinates off-sheet) |
1053
+ * | `size` | `{ width: number, height: number }` | Displayed size |
1054
+ * | `rotation` | `number` | Rotation in radians |
1055
+ * | `opacity` | `number` | Whole-shape opacity, 0–1 |
1056
+ */
1057
+ export type PluginCanvasShape = {
1058
+ shapeId: string
1059
+ type: string
1060
+ origin: PluginCanvasShapeOrigin
1061
+ sheetId: string | null
1062
+ position: PluginSheetPosition
1063
+ size: { width: number; height: number }
1064
+ rotation: number
1065
+ opacity: number
1066
+ }
1067
+
1068
+ /** Result of {@link PluginPresentationPlacedViewsApi.listShapes}. */
1069
+ export type PluginCanvasShapesListResult = {
1070
+ shapes: PluginCanvasShape[]
1071
+ }
1072
+
1073
+ /** Result of {@link PluginPresentationPlacedViewsApi.deleteShapes}. */
1074
+ export type PluginCanvasShapesDeleteResult = {
1075
+ deleted: string[]
1076
+ }
1077
+
1078
+ /** Arguments for {@link PluginPresentationPlacedViewsApi.moveShape}. */
1079
+ export const PluginPlacedViewsMoveShapeArgs = z.object({
1080
+ shapeId: z.string().min(1),
1081
+ position: PluginSheetPosition,
1082
+ sheetId: z.string().optional(),
1083
+ })
1084
+ export type PluginPlacedViewsMoveShapeArgs = z.infer<typeof PluginPlacedViewsMoveShapeArgs>
1085
+
1086
+ /** Arguments for {@link PluginPresentationPlacedViewsApi.resizeShape}. */
1087
+ export const PluginPlacedViewsResizeShapeArgs = z.object({
1088
+ shapeId: z.string().min(1),
1089
+ factor: z.number().finite().min(0.01).max(100),
1090
+ })
1091
+ export type PluginPlacedViewsResizeShapeArgs = z.infer<typeof PluginPlacedViewsResizeShapeArgs>
1092
+
1093
+ /** Arguments for {@link PluginPresentationPlacedViewsApi.rotateShape}. */
1094
+ export const PluginPresentationPlacedViewsRotateShapeArgs = z.object({
1095
+ shapeId: z.string().min(1),
1096
+ rotation: z.number().finite(),
1097
+ })
1098
+ export type PluginPresentationPlacedViewsRotateShapeArgs = z.infer<
1099
+ typeof PluginPresentationPlacedViewsRotateShapeArgs
1100
+ >
1101
+
1102
+ /** Arguments for {@link PluginPresentationPlacedViewsApi.deleteShapes}. */
1103
+ export const PluginPlacedViewsDeleteShapesArgs = z.object({
1104
+ shapeIds: z.array(z.string().min(1)).min(1).max(500),
1105
+ })
1106
+ export type PluginPlacedViewsDeleteShapesArgs = z.infer<typeof PluginPlacedViewsDeleteShapesArgs>
1107
+
1108
+ /** Arguments for {@link PluginPresentationPlacedViewsApi.setOpacity}. */
1109
+ export const PluginPlacedViewsSetOpacityArgs = z.object({
1110
+ shapeId: z.string().min(1),
1111
+ opacity: z.number().finite().min(0).max(1),
1112
+ })
1113
+ export type PluginPlacedViewsSetOpacityArgs = z.infer<typeof PluginPlacedViewsSetOpacityArgs>
1114
+
1115
+ /** Arguments for {@link PluginPresentationPlacedViewsApi.setMask}. */
1116
+ export const PluginPlacedViewsSetMaskArgs = z.object({
1117
+ shapeId: z.string().min(1),
1118
+ enabled: z.boolean(),
1119
+ })
1120
+ export type PluginPlacedViewsSetMaskArgs = z.infer<typeof PluginPlacedViewsSetMaskArgs>