lineadraw 0.7.0 → 0.8.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/lineadraw.d.ts CHANGED
@@ -18,6 +18,13 @@ declare module "lineadraw" {
18
18
  } | readonly [number, number, number?];
19
19
  /** Style overrides children may carry (otherwise inherited from the instance). */
20
20
  export type BaseStyle = {
21
+ /** Id of a document layer this object sits on. For a block child: absent
22
+ * = the instance's layer (the portable default; an id unknown to the
23
+ * document falls back to it); a child that names another layer hides
24
+ * with that layer, while its color / line type / width still follow the
25
+ * instance unless it sets its own (ByBlock, as in CAD). For
26
+ * `document.add`: absent = the current layer. */
27
+ layerId?: string;
21
28
  /** #rrggbb; absent = by layer. */
22
29
  color?: string;
23
30
  /** Line type; absent = by layer. */
@@ -26,6 +33,8 @@ declare module "lineadraw" {
26
33
  lineTypeScale?: number;
27
34
  /** Line weight in mm; absent = by layer. */
28
35
  lineWidth?: number;
36
+ /** Paint opacity 0..1; absent = by layer (opaque unless the layer says). */
37
+ opacity?: number;
29
38
  };
30
39
  /**
31
40
  * T plus the shared style fields, FLATTENED (the homomorphic map forces the
@@ -82,6 +91,17 @@ declare module "lineadraw" {
82
91
  }[];
83
92
  fill?: {
84
93
  kind: "solid";
94
+ }
95
+ /** A named pattern: the built-in catalogue (ANSI31, AR-CONC, …) or one of
96
+ * the document's own hatch patterns, by name. `angle` radians, `scale`
97
+ * multiplies the definition's mm; `origin` anchors the pattern frame
98
+ * (block-local mm; absent = the block origin). */
99
+ | {
100
+ kind: "pattern";
101
+ name: string;
102
+ angle: number;
103
+ scale: number;
104
+ origin?: Vec2Like;
85
105
  } | {
86
106
  kind: "lines";
87
107
  angle: number;
@@ -96,10 +116,26 @@ declare module "lineadraw" {
96
116
  /** Pattern spacing multiplier. */
97
117
  scale?: number;
98
118
  }>;
119
+ /** Character formatting over [start, end) of a text's `content` (JS string
120
+ * indices). Absent attributes inherit the text's style; `height` is a ratio
121
+ * of its cap height. Setting `content` without `spans` drops old spans. */
122
+ export type TextSpan = {
123
+ start: number;
124
+ end: number;
125
+ font?: string;
126
+ bold?: boolean;
127
+ italic?: boolean;
128
+ underline?: boolean;
129
+ /** "#rrggbb". */
130
+ color?: string;
131
+ height?: number;
132
+ script?: "sub" | "super";
133
+ };
99
134
  export type Text = Styled<{
100
135
  type: "text";
101
136
  position: Vec2Like;
102
137
  content: string;
138
+ spans?: readonly TextSpan[];
103
139
  rotation?: number;
104
140
  /** Justification, as in AutoCAD / DXF: which edge sits on the point —
105
141
  * "left" = the text runs right of it, "right" = left of it; vAlign
@@ -111,6 +147,8 @@ declare module "lineadraw" {
111
147
  frame?: "none" | "rectangle" | "circle" | "slot" | "bottom" | "firstLine";
112
148
  /** MLEADER-style arrow polylines pointing at the text (arrowhead at [0]). */
113
149
  leaderLines?: readonly (readonly Vec2Like[])[];
150
+ /** The document text style to follow (name or id); absent = the first. */
151
+ styleId?: string;
114
152
  /** Style overrides; absent keys inherit the document text style. */
115
153
  styleOverride?: {
116
154
  font?: string;
@@ -130,11 +168,26 @@ declare module "lineadraw" {
130
168
  kind?: "linear" | "angular" | "radial" | "diameter";
131
169
  /** linear: 2+ chained points (measured point to point); angular: [vertex, a, b]; radial: [center, p]; diameter: [p1, p2]. */
132
170
  points: readonly Vec2Like[];
133
- /** Dimension line offset from the kind's anchor (points[0]; diameter: the
134
- * points' midpoint). anchor + offset lies on the dimension line (angular:
135
- * on the arc; radial/diameter: at the text). */
136
- offset: Vec2Like;
137
- textOverride?: string;
171
+ /** linear only: the measuring direction, radians CCW from +X. Unset =
172
+ * aligned to the points. */
173
+ rotation?: number;
174
+ /** linear: signed distance of the dimension line from points[0], positive
175
+ * to the LEFT of the measuring direction; angular: signed arc radius
176
+ * (negative = the complementary arc). Not for radial/diameter. */
177
+ offset?: number;
178
+ /** One per measured segment (linear chain: points.length − 1, others: 1).
179
+ * `along` (mm along the line from the segment origin — radial/diameter:
180
+ * from the center) and `across` (mm off the line) place the text, unset =
181
+ * automatic; `content` is the text, `{value}` = the measurement. */
182
+ labels?: readonly {
183
+ along?: number;
184
+ across?: number;
185
+ content?: string;
186
+ /** Formatting over `content` (spans covering `{value}` format it). */
187
+ spans?: readonly TextSpan[];
188
+ }[];
189
+ /** The document dimension style to follow (name or id); absent = the first. */
190
+ styleId?: string;
138
191
  styleOverride?: {
139
192
  textHeight?: number;
140
193
  arrowSize?: number;
@@ -162,7 +215,9 @@ declare module "lineadraw" {
162
215
  }>;
163
216
  /** A table cell: plain text, or text with merge / alignment / style. */
164
217
  export type TableCell = string | {
165
- text?: string;
218
+ content?: string;
219
+ /** Character formatting over `content`. */
220
+ spans?: readonly TextSpan[];
166
221
  /** Merge from this (top-left) cell; covered cells are ignored. */
167
222
  span?: {
168
223
  cols: number;
@@ -197,7 +252,14 @@ declare module "lineadraw" {
197
252
  styleId?: string;
198
253
  styleOverride?: TextStyleOverride;
199
254
  }>;
200
- export type ModelObject = Line | Point | Polyline | Circle | Arc | Ellipse | Hatch | Text | Dimension | Block | Table;
255
+ /** What a script WRITES — the union of the authoring DTOs above (what
256
+ * `draw` returns, what `document.add` takes). Read results are
257
+ * `StoredObject`. */
258
+ export type ObjectInput = Line | Point | Polyline | Circle | Arc | Ellipse | Hatch | Text | Dimension | Block | Table;
259
+ /** @deprecated The input union is `ObjectInput`; in the SDK and core
260
+ * `ModelObject` is the STORED shape, so this name misled. Kept so existing
261
+ * scripts compile. */
262
+ export type ModelObject = ObjectInput;
201
263
  /** Identity + shared style fields every stored object carries. */
202
264
  export type StoredObjectBase = {
203
265
  id: string;
@@ -262,6 +324,8 @@ declare module "lineadraw" {
262
324
  name: string;
263
325
  angle: number;
264
326
  scale: number;
327
+ /** World anchor of the pattern frame; absent = the drawing origin. */
328
+ origin?: Vec2;
265
329
  } | {
266
330
  kind: "lines";
267
331
  angle: number;
@@ -286,6 +350,7 @@ declare module "lineadraw" {
286
350
  type: "text";
287
351
  position: Vec2;
288
352
  content: string;
353
+ spans?: readonly TextSpan[];
289
354
  leaderLines: readonly (readonly Vec2[])[];
290
355
  /** Word-wrap / frame width in mm; absent = no wrapping. */
291
356
  width?: number;
@@ -310,8 +375,14 @@ declare module "lineadraw" {
310
375
  type: "dimension";
311
376
  kind: "linear" | "angular" | "radial" | "diameter";
312
377
  points: readonly Vec2[];
313
- offset: Vec2;
314
- textOverride?: string;
378
+ rotation?: number;
379
+ offset?: number;
380
+ labels: readonly {
381
+ along?: number;
382
+ across?: number;
383
+ content?: string;
384
+ spans?: readonly TextSpan[];
385
+ }[];
315
386
  styleId?: string;
316
387
  /** Only the keys the user actually overrode on this dimension. */
317
388
  styleOverride?: {
@@ -388,6 +459,8 @@ declare module "lineadraw" {
388
459
  hiddenLayers: readonly string[];
389
460
  /** Switched off: not drawn. */
390
461
  hidden?: boolean;
462
+ /** Locked in the References panel: drawn and snapped, never picked. */
463
+ locked?: boolean;
391
464
  /** Crop rectangle in file coordinates. */
392
465
  clip?: {
393
466
  minX: number;
@@ -424,7 +497,8 @@ declare module "lineadraw" {
424
497
  /** One table cell as stored. */
425
498
  export type StoredTableCell = {
426
499
  /** Plain text; "\n" = line break. */
427
- text: string;
500
+ content: string;
501
+ spans?: readonly TextSpan[];
428
502
  /** Merge, on the anchor (top-left) cell; covered cells are ignored. */
429
503
  span?: {
430
504
  cols: number;
@@ -617,7 +691,7 @@ declare module "lineadraw" {
617
691
  */
618
692
  export type BlockParamDefs = readonly ParamDef[];
619
693
  /** What the script's `draw` export must return. */
620
- export type BlockScriptResult = ModelObject[];
694
+ export type BlockScriptResult = ObjectInput[];
621
695
  /** The value an enum option denotes (its string, or `value` of the record form). */
622
696
  type OptionValue<O extends ParameterOption> = O extends string ? O : O extends {
623
697
  value: infer V extends string;
@@ -650,6 +724,37 @@ declare module "lineadraw" {
650
724
  name: infer N extends string;
651
725
  } ? N : never]: E extends ParamDef ? ParamValue<E> : never;
652
726
  } : P;
727
+ /** A document line type definition — objects and layers name it in
728
+ * `lineType`, ahead of the built-in catalogue. */
729
+ export type LineType = {
730
+ /** Case-insensitive, unique per document. */
731
+ name: string;
732
+ description?: string;
733
+ /** Signed dash cycle, mm per 1 mm of line width: >0 dash, <0 gap, 0 dot.
734
+ * Empty = continuous. */
735
+ dashesMm: number[];
736
+ };
737
+ /** One line family of a hatch pattern, in the pattern's own frame. */
738
+ export type HatchPatternLine = {
739
+ /** Radians CCW. */
740
+ angle: number;
741
+ /** Base point, mm. */
742
+ origin: Vec2;
743
+ /** Shift along the line between successive lines (dash phase), mm. */
744
+ deltaX: number;
745
+ /** Perpendicular spacing between successive lines, mm. */
746
+ deltaY: number;
747
+ /** Dash cycle along the line: >0 dash, <0 gap, 0 dot; absent = solid. */
748
+ dashesMm?: number[];
749
+ };
750
+ /** A document hatch pattern definition — pattern fills name it in
751
+ * `fill.name`, ahead of the built-in catalogue. */
752
+ export type HatchPattern = {
753
+ /** Case-insensitive, unique per document. */
754
+ name: string;
755
+ description?: string;
756
+ lines: HatchPatternLine[];
757
+ };
653
758
  /** An axis-aligned box in world mm. */
654
759
  export type Box = {
655
760
  minX: number;
@@ -660,7 +765,7 @@ declare module "lineadraw" {
660
765
  /** Filters for Drawing.query — all present filters AND together. */
661
766
  export type ObjectQuery = {
662
767
  ids?: readonly string[];
663
- type?: ModelObject["type"];
768
+ type?: ObjectInput["type"];
664
769
  /** Layer name or id. */
665
770
  layer?: string;
666
771
  /** #rrggbb override (objects without one inherit from their layer). */
@@ -739,6 +844,48 @@ declare module "lineadraw" {
739
844
  params?: readonly ParamDef[];
740
845
  };
741
846
  /** What installing module sources reports. */
847
+ /** One configured marketplace (a block / command collection). */
848
+ export type MarketplaceConfig = {
849
+ kind: "builtin";
850
+ } | {
851
+ kind: "github";
852
+ spec: string;
853
+ token?: string;
854
+ } | {
855
+ kind: "folder";
856
+ folder: string;
857
+ };
858
+ /** A configured marketplace as listed — the token itself never shows. */
859
+ export type MarketplaceInfo = {
860
+ key: string;
861
+ kind: "builtin" | "github" | "folder";
862
+ label: string;
863
+ spec?: string;
864
+ folder?: string;
865
+ hasToken: boolean;
866
+ };
867
+ /** A marketplace search hit: the catalog row plus where it came from and
868
+ * how it relates to this document's modules. */
869
+ export type MarketplaceHit = {
870
+ kind: "block" | "command";
871
+ id: string;
872
+ name: string;
873
+ version: string;
874
+ description?: string;
875
+ tags: string[];
876
+ authors: string[];
877
+ dependencies: string[];
878
+ marketplace: MarketplaceInfo;
879
+ status: {
880
+ kind: "absent";
881
+ } | {
882
+ kind: "installed";
883
+ version?: string;
884
+ } | {
885
+ kind: "update";
886
+ from?: string;
887
+ };
888
+ };
742
889
  export type MergeReport = {
743
890
  /** The full library after the merge. */
744
891
  merged: readonly string[];
@@ -844,6 +991,9 @@ declare module "lineadraw" {
844
991
  name: string;
845
992
  objectCount: number;
846
993
  }[];
994
+ settings: {
995
+ units: "mm" | "in";
996
+ };
847
997
  };
848
998
  /** Filtered objects — model space, or one layout via `filter.layout`. */
849
999
  listObjects(filter?: ObjectQuery): ExistingObject[];
@@ -892,7 +1042,7 @@ declare module "lineadraw" {
892
1042
  toLinea(): string;
893
1043
  /** Add objects (each may carry `layer` — a name — instead of an id);
894
1044
  * returns the created ids. */
895
- add(objects: readonly (ModelObject & {
1045
+ add(objects: readonly (ObjectInput & {
896
1046
  layer?: string;
897
1047
  })[], opts?: {
898
1048
  layout?: string;
@@ -936,6 +1086,26 @@ declare module "lineadraw" {
936
1086
  /** Explicit total order (names or ids, every layer exactly once). */
937
1087
  reorderLayers(order: readonly string[]): void;
938
1088
  setCurrentLayer(nameOrId: string): void;
1089
+ /** Document-wide settings, merged over the current record. */
1090
+ updateSettings(patch: {
1091
+ units?: "mm" | "in";
1092
+ }): void;
1093
+ /** Configured marketplaces, priority order (tokens hidden). */
1094
+ listMarketplaces(): MarketplaceInfo[];
1095
+ /** Add marketplaces at the top of the priority list; each catalog must be
1096
+ * fetchable. `{ kind: "github", spec: "owner/repo[@branch]", token? }` or
1097
+ * `{ kind: "folder", folder }`. */
1098
+ addMarketplaces(list: readonly MarketplaceConfig[]): Promise<MarketplaceInfo[]>;
1099
+ /** Remove by key, spec, folder or label; the built-in collection stays. */
1100
+ removeMarketplaces(names: readonly string[]): MarketplaceInfo[];
1101
+ /** Search entries across the marketplaces, with install status. */
1102
+ searchMarketplaces(q?: {
1103
+ query?: string;
1104
+ kind?: "block" | "command";
1105
+ marketplace?: string;
1106
+ }): Promise<MarketplaceHit[]>;
1107
+ /** Install (or update) entries by id, dependencies first — one undo step. */
1108
+ installMarketplaceEntries(ids: readonly string[], marketplace?: string): Promise<MergeReport>;
939
1109
  listTextStyles(): ({
940
1110
  id: string;
941
1111
  name: string;
@@ -961,6 +1131,21 @@ declare module "lineadraw" {
961
1131
  setDimStyle(patch: Record<string, unknown>, styleId?: string): void;
962
1132
  /** @deprecated Use updateTextStyle (default here: the first style). */
963
1133
  setTextStyle(patch: Record<string, unknown>, styleId?: string): void;
1134
+ /** The document's own line type definitions (objects and layers name
1135
+ * them, ahead of the built-in catalogue). */
1136
+ listLineTypes(): LineType[];
1137
+ /** Add definitions (names unique, case-insensitive; a clash is refused). */
1138
+ addLineTypes(lineTypes: readonly LineType[]): void;
1139
+ updateLineType(name: string, patch: Partial<LineType>): void;
1140
+ /** Remove a definition; objects still naming it fall back to the
1141
+ * catalogue or continuous. */
1142
+ removeLineType(name: string): void;
1143
+ /** The document's own hatch pattern definitions (same model as line
1144
+ * types: fills name them, ahead of the catalogue). */
1145
+ listHatchPatterns(): HatchPattern[];
1146
+ addHatchPatterns(patterns: readonly HatchPattern[]): void;
1147
+ updateHatchPattern(name: string, patch: Partial<HatchPattern>): void;
1148
+ removeHatchPattern(name: string): void;
964
1149
  /** Embed image pixels (a data URL); returns the content-keyed assetId
965
1150
  * that `image` objects reference. */
966
1151
  addAsset(dataUrl: string): string;
@@ -1444,6 +1629,13 @@ type PolylineVertexLike = {
1444
1629
  } | readonly [number, number, number?];
1445
1630
  /** Style overrides children may carry (otherwise inherited from the instance). */
1446
1631
  type BaseStyle = {
1632
+ /** Id of a document layer this object sits on. For a block child: absent
1633
+ * = the instance's layer (the portable default; an id unknown to the
1634
+ * document falls back to it); a child that names another layer hides
1635
+ * with that layer, while its color / line type / width still follow the
1636
+ * instance unless it sets its own (ByBlock, as in CAD). For
1637
+ * `document.add`: absent = the current layer. */
1638
+ layerId?: string;
1447
1639
  /** #rrggbb; absent = by layer. */
1448
1640
  color?: string;
1449
1641
  /** Line type; absent = by layer. */
@@ -1452,6 +1644,8 @@ type BaseStyle = {
1452
1644
  lineTypeScale?: number;
1453
1645
  /** Line weight in mm; absent = by layer. */
1454
1646
  lineWidth?: number;
1647
+ /** Paint opacity 0..1; absent = by layer (opaque unless the layer says). */
1648
+ opacity?: number;
1455
1649
  };
1456
1650
  /**
1457
1651
  * T plus the shared style fields, FLATTENED (the homomorphic map forces the
@@ -1508,6 +1702,17 @@ type Hatch = Styled<{
1508
1702
  }[];
1509
1703
  fill?: {
1510
1704
  kind: "solid";
1705
+ }
1706
+ /** A named pattern: the built-in catalogue (ANSI31, AR-CONC, …) or one of
1707
+ * the document's own hatch patterns, by name. `angle` radians, `scale`
1708
+ * multiplies the definition's mm; `origin` anchors the pattern frame
1709
+ * (block-local mm; absent = the block origin). */
1710
+ | {
1711
+ kind: "pattern";
1712
+ name: string;
1713
+ angle: number;
1714
+ scale: number;
1715
+ origin?: Vec2Like;
1511
1716
  } | {
1512
1717
  kind: "lines";
1513
1718
  angle: number;
@@ -1522,10 +1727,26 @@ type Hatch = Styled<{
1522
1727
  /** Pattern spacing multiplier. */
1523
1728
  scale?: number;
1524
1729
  }>;
1730
+ /** Character formatting over [start, end) of a text's `content` (JS string
1731
+ * indices). Absent attributes inherit the text's style; `height` is a ratio
1732
+ * of its cap height. Setting `content` without `spans` drops old spans. */
1733
+ type TextSpan = {
1734
+ start: number;
1735
+ end: number;
1736
+ font?: string;
1737
+ bold?: boolean;
1738
+ italic?: boolean;
1739
+ underline?: boolean;
1740
+ /** "#rrggbb". */
1741
+ color?: string;
1742
+ height?: number;
1743
+ script?: "sub" | "super";
1744
+ };
1525
1745
  type Text = Styled<{
1526
1746
  type: "text";
1527
1747
  position: Vec2Like;
1528
1748
  content: string;
1749
+ spans?: readonly TextSpan[];
1529
1750
  rotation?: number;
1530
1751
  /** Justification, as in AutoCAD / DXF: which edge sits on the point —
1531
1752
  * "left" = the text runs right of it, "right" = left of it; vAlign
@@ -1537,6 +1758,8 @@ type Text = Styled<{
1537
1758
  frame?: "none" | "rectangle" | "circle" | "slot" | "bottom" | "firstLine";
1538
1759
  /** MLEADER-style arrow polylines pointing at the text (arrowhead at [0]). */
1539
1760
  leaderLines?: readonly (readonly Vec2Like[])[];
1761
+ /** The document text style to follow (name or id); absent = the first. */
1762
+ styleId?: string;
1540
1763
  /** Style overrides; absent keys inherit the document text style. */
1541
1764
  styleOverride?: {
1542
1765
  font?: string;
@@ -1556,11 +1779,26 @@ type Dimension = Styled<{
1556
1779
  kind?: "linear" | "angular" | "radial" | "diameter";
1557
1780
  /** linear: 2+ chained points (measured point to point); angular: [vertex, a, b]; radial: [center, p]; diameter: [p1, p2]. */
1558
1781
  points: readonly Vec2Like[];
1559
- /** Dimension line offset from the kind's anchor (points[0]; diameter: the
1560
- * points' midpoint). anchor + offset lies on the dimension line (angular:
1561
- * on the arc; radial/diameter: at the text). */
1562
- offset: Vec2Like;
1563
- textOverride?: string;
1782
+ /** linear only: the measuring direction, radians CCW from +X. Unset =
1783
+ * aligned to the points. */
1784
+ rotation?: number;
1785
+ /** linear: signed distance of the dimension line from points[0], positive
1786
+ * to the LEFT of the measuring direction; angular: signed arc radius
1787
+ * (negative = the complementary arc). Not for radial/diameter. */
1788
+ offset?: number;
1789
+ /** One per measured segment (linear chain: points.length − 1, others: 1).
1790
+ * `along` (mm along the line from the segment origin — radial/diameter:
1791
+ * from the center) and `across` (mm off the line) place the text, unset =
1792
+ * automatic; `content` is the text, `{value}` = the measurement. */
1793
+ labels?: readonly {
1794
+ along?: number;
1795
+ across?: number;
1796
+ content?: string;
1797
+ /** Formatting over `content` (spans covering `{value}` format it). */
1798
+ spans?: readonly TextSpan[];
1799
+ }[];
1800
+ /** The document dimension style to follow (name or id); absent = the first. */
1801
+ styleId?: string;
1564
1802
  styleOverride?: {
1565
1803
  textHeight?: number;
1566
1804
  arrowSize?: number;
@@ -1588,7 +1826,9 @@ type Block = Styled<{
1588
1826
  }>;
1589
1827
  /** A table cell: plain text, or text with merge / alignment / style. */
1590
1828
  type TableCell = string | {
1591
- text?: string;
1829
+ content?: string;
1830
+ /** Character formatting over `content`. */
1831
+ spans?: readonly TextSpan[];
1592
1832
  /** Merge from this (top-left) cell; covered cells are ignored. */
1593
1833
  span?: {
1594
1834
  cols: number;
@@ -1623,7 +1863,14 @@ type Table = Styled<{
1623
1863
  styleId?: string;
1624
1864
  styleOverride?: TextStyleOverride;
1625
1865
  }>;
1626
- type ModelObject = Line | Point | Polyline | Circle | Arc | Ellipse | Hatch | Text | Dimension | Block | Table;
1866
+ /** What a script WRITES — the union of the authoring DTOs above (what
1867
+ * `draw` returns, what `document.add` takes). Read results are
1868
+ * `StoredObject`. */
1869
+ type ObjectInput = Line | Point | Polyline | Circle | Arc | Ellipse | Hatch | Text | Dimension | Block | Table;
1870
+ /** @deprecated The input union is `ObjectInput`; in the SDK and core
1871
+ * `ModelObject` is the STORED shape, so this name misled. Kept so existing
1872
+ * scripts compile. */
1873
+ type ModelObject = ObjectInput;
1627
1874
  /** Identity + shared style fields every stored object carries. */
1628
1875
  type StoredObjectBase = {
1629
1876
  id: string;
@@ -1688,6 +1935,8 @@ type StoredHatchFill = {
1688
1935
  name: string;
1689
1936
  angle: number;
1690
1937
  scale: number;
1938
+ /** World anchor of the pattern frame; absent = the drawing origin. */
1939
+ origin?: Vec2;
1691
1940
  } | {
1692
1941
  kind: "lines";
1693
1942
  angle: number;
@@ -1712,6 +1961,7 @@ type StoredText = StoredShape<{
1712
1961
  type: "text";
1713
1962
  position: Vec2;
1714
1963
  content: string;
1964
+ spans?: readonly TextSpan[];
1715
1965
  leaderLines: readonly (readonly Vec2[])[];
1716
1966
  /** Word-wrap / frame width in mm; absent = no wrapping. */
1717
1967
  width?: number;
@@ -1736,8 +1986,14 @@ type StoredDimension = StoredShape<{
1736
1986
  type: "dimension";
1737
1987
  kind: "linear" | "angular" | "radial" | "diameter";
1738
1988
  points: readonly Vec2[];
1739
- offset: Vec2;
1740
- textOverride?: string;
1989
+ rotation?: number;
1990
+ offset?: number;
1991
+ labels: readonly {
1992
+ along?: number;
1993
+ across?: number;
1994
+ content?: string;
1995
+ spans?: readonly TextSpan[];
1996
+ }[];
1741
1997
  styleId?: string;
1742
1998
  /** Only the keys the user actually overrode on this dimension. */
1743
1999
  styleOverride?: {
@@ -1814,6 +2070,8 @@ type StoredReference = StoredShape<{
1814
2070
  hiddenLayers: readonly string[];
1815
2071
  /** Switched off: not drawn. */
1816
2072
  hidden?: boolean;
2073
+ /** Locked in the References panel: drawn and snapped, never picked. */
2074
+ locked?: boolean;
1817
2075
  /** Crop rectangle in file coordinates. */
1818
2076
  clip?: {
1819
2077
  minX: number;
@@ -1850,7 +2108,8 @@ type TextStyleOverride = {
1850
2108
  /** One table cell as stored. */
1851
2109
  type StoredTableCell = {
1852
2110
  /** Plain text; "\n" = line break. */
1853
- text: string;
2111
+ content: string;
2112
+ spans?: readonly TextSpan[];
1854
2113
  /** Merge, on the anchor (top-left) cell; covered cells are ignored. */
1855
2114
  span?: {
1856
2115
  cols: number;
@@ -2043,7 +2302,7 @@ type FlatParam<Q> = Q extends {
2043
2302
  */
2044
2303
  type BlockParamDefs = readonly ParamDef[];
2045
2304
  /** What the script's `draw` export must return. */
2046
- type BlockScriptResult = ModelObject[];
2305
+ type BlockScriptResult = ObjectInput[];
2047
2306
  /** The value an enum option denotes (its string, or `value` of the record form). */
2048
2307
  type OptionValue<O extends ParameterOption> = O extends string ? O : O extends {
2049
2308
  value: infer V extends string;
@@ -2076,6 +2335,37 @@ type ParamValues<P> = P extends () => infer R ? ParamValues<R> : P extends reado
2076
2335
  name: infer N extends string;
2077
2336
  } ? N : never]: E extends ParamDef ? ParamValue<E> : never;
2078
2337
  } : P;
2338
+ /** A document line type definition — objects and layers name it in
2339
+ * `lineType`, ahead of the built-in catalogue. */
2340
+ type LineType = {
2341
+ /** Case-insensitive, unique per document. */
2342
+ name: string;
2343
+ description?: string;
2344
+ /** Signed dash cycle, mm per 1 mm of line width: >0 dash, <0 gap, 0 dot.
2345
+ * Empty = continuous. */
2346
+ dashesMm: number[];
2347
+ };
2348
+ /** One line family of a hatch pattern, in the pattern's own frame. */
2349
+ type HatchPatternLine = {
2350
+ /** Radians CCW. */
2351
+ angle: number;
2352
+ /** Base point, mm. */
2353
+ origin: Vec2;
2354
+ /** Shift along the line between successive lines (dash phase), mm. */
2355
+ deltaX: number;
2356
+ /** Perpendicular spacing between successive lines, mm. */
2357
+ deltaY: number;
2358
+ /** Dash cycle along the line: >0 dash, <0 gap, 0 dot; absent = solid. */
2359
+ dashesMm?: number[];
2360
+ };
2361
+ /** A document hatch pattern definition — pattern fills name it in
2362
+ * `fill.name`, ahead of the built-in catalogue. */
2363
+ type HatchPattern = {
2364
+ /** Case-insensitive, unique per document. */
2365
+ name: string;
2366
+ description?: string;
2367
+ lines: HatchPatternLine[];
2368
+ };
2079
2369
  /** An axis-aligned box in world mm. */
2080
2370
  type Box = {
2081
2371
  minX: number;
@@ -2086,7 +2376,7 @@ type Box = {
2086
2376
  /** Filters for Drawing.query — all present filters AND together. */
2087
2377
  type ObjectQuery = {
2088
2378
  ids?: readonly string[];
2089
- type?: ModelObject["type"];
2379
+ type?: ObjectInput["type"];
2090
2380
  /** Layer name or id. */
2091
2381
  layer?: string;
2092
2382
  /** #rrggbb override (objects without one inherit from their layer). */
@@ -2165,6 +2455,48 @@ type CommandInfo = {
2165
2455
  params?: readonly ParamDef[];
2166
2456
  };
2167
2457
  /** What installing module sources reports. */
2458
+ /** One configured marketplace (a block / command collection). */
2459
+ type MarketplaceConfig = {
2460
+ kind: "builtin";
2461
+ } | {
2462
+ kind: "github";
2463
+ spec: string;
2464
+ token?: string;
2465
+ } | {
2466
+ kind: "folder";
2467
+ folder: string;
2468
+ };
2469
+ /** A configured marketplace as listed — the token itself never shows. */
2470
+ type MarketplaceInfo = {
2471
+ key: string;
2472
+ kind: "builtin" | "github" | "folder";
2473
+ label: string;
2474
+ spec?: string;
2475
+ folder?: string;
2476
+ hasToken: boolean;
2477
+ };
2478
+ /** A marketplace search hit: the catalog row plus where it came from and
2479
+ * how it relates to this document's modules. */
2480
+ type MarketplaceHit = {
2481
+ kind: "block" | "command";
2482
+ id: string;
2483
+ name: string;
2484
+ version: string;
2485
+ description?: string;
2486
+ tags: string[];
2487
+ authors: string[];
2488
+ dependencies: string[];
2489
+ marketplace: MarketplaceInfo;
2490
+ status: {
2491
+ kind: "absent";
2492
+ } | {
2493
+ kind: "installed";
2494
+ version?: string;
2495
+ } | {
2496
+ kind: "update";
2497
+ from?: string;
2498
+ };
2499
+ };
2168
2500
  type MergeReport = {
2169
2501
  /** The full library after the merge. */
2170
2502
  merged: readonly string[];
@@ -2270,6 +2602,9 @@ interface Drawing {
2270
2602
  name: string;
2271
2603
  objectCount: number;
2272
2604
  }[];
2605
+ settings: {
2606
+ units: "mm" | "in";
2607
+ };
2273
2608
  };
2274
2609
  /** Filtered objects — model space, or one layout via `filter.layout`. */
2275
2610
  listObjects(filter?: ObjectQuery): ExistingObject[];
@@ -2318,7 +2653,7 @@ interface Drawing {
2318
2653
  toLinea(): string;
2319
2654
  /** Add objects (each may carry `layer` — a name — instead of an id);
2320
2655
  * returns the created ids. */
2321
- add(objects: readonly (ModelObject & {
2656
+ add(objects: readonly (ObjectInput & {
2322
2657
  layer?: string;
2323
2658
  })[], opts?: {
2324
2659
  layout?: string;
@@ -2362,6 +2697,26 @@ interface Drawing {
2362
2697
  /** Explicit total order (names or ids, every layer exactly once). */
2363
2698
  reorderLayers(order: readonly string[]): void;
2364
2699
  setCurrentLayer(nameOrId: string): void;
2700
+ /** Document-wide settings, merged over the current record. */
2701
+ updateSettings(patch: {
2702
+ units?: "mm" | "in";
2703
+ }): void;
2704
+ /** Configured marketplaces, priority order (tokens hidden). */
2705
+ listMarketplaces(): MarketplaceInfo[];
2706
+ /** Add marketplaces at the top of the priority list; each catalog must be
2707
+ * fetchable. `{ kind: "github", spec: "owner/repo[@branch]", token? }` or
2708
+ * `{ kind: "folder", folder }`. */
2709
+ addMarketplaces(list: readonly MarketplaceConfig[]): Promise<MarketplaceInfo[]>;
2710
+ /** Remove by key, spec, folder or label; the built-in collection stays. */
2711
+ removeMarketplaces(names: readonly string[]): MarketplaceInfo[];
2712
+ /** Search entries across the marketplaces, with install status. */
2713
+ searchMarketplaces(q?: {
2714
+ query?: string;
2715
+ kind?: "block" | "command";
2716
+ marketplace?: string;
2717
+ }): Promise<MarketplaceHit[]>;
2718
+ /** Install (or update) entries by id, dependencies first — one undo step. */
2719
+ installMarketplaceEntries(ids: readonly string[], marketplace?: string): Promise<MergeReport>;
2365
2720
  listTextStyles(): ({
2366
2721
  id: string;
2367
2722
  name: string;
@@ -2387,6 +2742,21 @@ interface Drawing {
2387
2742
  setDimStyle(patch: Record<string, unknown>, styleId?: string): void;
2388
2743
  /** @deprecated Use updateTextStyle (default here: the first style). */
2389
2744
  setTextStyle(patch: Record<string, unknown>, styleId?: string): void;
2745
+ /** The document's own line type definitions (objects and layers name
2746
+ * them, ahead of the built-in catalogue). */
2747
+ listLineTypes(): LineType[];
2748
+ /** Add definitions (names unique, case-insensitive; a clash is refused). */
2749
+ addLineTypes(lineTypes: readonly LineType[]): void;
2750
+ updateLineType(name: string, patch: Partial<LineType>): void;
2751
+ /** Remove a definition; objects still naming it fall back to the
2752
+ * catalogue or continuous. */
2753
+ removeLineType(name: string): void;
2754
+ /** The document's own hatch pattern definitions (same model as line
2755
+ * types: fills name them, ahead of the catalogue). */
2756
+ listHatchPatterns(): HatchPattern[];
2757
+ addHatchPatterns(patterns: readonly HatchPattern[]): void;
2758
+ updateHatchPattern(name: string, patch: Partial<HatchPattern>): void;
2759
+ removeHatchPattern(name: string): void;
2390
2760
  /** Embed image pixels (a data URL); returns the content-keyed assetId
2391
2761
  * that `image` objects reference. */
2392
2762
  addAsset(dataUrl: string): string;