lineadraw 0.6.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/README.md +43 -18
- package/bin/lineadraw.mjs +291 -277
- package/dist/chunk-VWED6V6F.js +10020 -0
- package/dist/chunk-VWED6V6F.js.map +1 -0
- package/dist/exportDxf-2VU5475O.js +8 -0
- package/dist/exportDxf-2VU5475O.js.map +1 -0
- package/dist/{node-OWPSMNLK.js → node-PLO3I6OZ.js} +39 -1
- package/dist/node-PLO3I6OZ.js.map +1 -0
- package/dist/pkg/linea_dwg_bg.wasm +0 -0
- package/dist/sdk.d.ts +1656 -1036
- package/dist/sdk.js +3984 -9694
- package/dist/sdk.js.map +1 -1
- package/lineadraw.d.ts +577 -53
- package/package.json +2 -2
- package/templates/README.md +18 -18
- package/dist/node-OWPSMNLK.js.map +0 -1
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
|
-
/**
|
|
134
|
-
*
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
314
|
-
|
|
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
|
-
|
|
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 =
|
|
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?:
|
|
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[];
|
|
@@ -772,7 +919,12 @@ declare module "lineadraw" {
|
|
|
772
919
|
width: number;
|
|
773
920
|
height: number;
|
|
774
921
|
};
|
|
775
|
-
/**
|
|
922
|
+
/** What an import added (`objectIds` = the new objects). */
|
|
923
|
+
export interface ImportReport {
|
|
924
|
+
objects: number;
|
|
925
|
+
objectIds: string[];
|
|
926
|
+
}
|
|
927
|
+
/** Options for Drawing.addLayout. */
|
|
776
928
|
export type LayoutSpec = {
|
|
777
929
|
/** Default: A3 landscape. */
|
|
778
930
|
sheet?: SheetSpec;
|
|
@@ -839,9 +991,12 @@ declare module "lineadraw" {
|
|
|
839
991
|
name: string;
|
|
840
992
|
objectCount: number;
|
|
841
993
|
}[];
|
|
994
|
+
settings: {
|
|
995
|
+
units: "mm" | "in";
|
|
996
|
+
};
|
|
842
997
|
};
|
|
843
998
|
/** Filtered objects — model space, or one layout via `filter.layout`. */
|
|
844
|
-
|
|
999
|
+
listObjects(filter?: ObjectQuery): ExistingObject[];
|
|
845
1000
|
/** One object from ANY space, or undefined. */
|
|
846
1001
|
getObject(id: string): ExistingObject | undefined;
|
|
847
1002
|
/** bbox / curve length / enclosed area of one object. */
|
|
@@ -849,9 +1004,9 @@ declare module "lineadraw" {
|
|
|
849
1004
|
listLayers(): LayerInfo[];
|
|
850
1005
|
listLayouts(): LayoutInfo[];
|
|
851
1006
|
/** Compilable block definitions in this document. */
|
|
852
|
-
|
|
1007
|
+
listBlockDefinitions(): BlockInfo[];
|
|
853
1008
|
/** Compilable command modules travelling with this document. */
|
|
854
|
-
|
|
1009
|
+
listUserCommands(): CommandInfo[];
|
|
855
1010
|
/** Model space (or a layout via `layout`) as an SVG string. */
|
|
856
1011
|
renderSvg(opts?: {
|
|
857
1012
|
layout?: string;
|
|
@@ -859,6 +1014,18 @@ declare module "lineadraw" {
|
|
|
859
1014
|
padding?: number;
|
|
860
1015
|
palette?: "color" | "grayscale" | "monochrome";
|
|
861
1016
|
}): string;
|
|
1017
|
+
/** Model space (or a layout) as PNG bytes — absent on hosts that can't
|
|
1018
|
+
* rasterize, so check before calling. */
|
|
1019
|
+
renderPng?(opts?: {
|
|
1020
|
+
layout?: string;
|
|
1021
|
+
bbox?: Box;
|
|
1022
|
+
padding?: number;
|
|
1023
|
+
palette?: "color" | "grayscale" | "monochrome";
|
|
1024
|
+
/** Output width in px (height follows). Default 1024. */
|
|
1025
|
+
width?: number;
|
|
1026
|
+
/** Background fill, e.g. "#ffffff". Default: the dark canvas. */
|
|
1027
|
+
background?: string;
|
|
1028
|
+
}): Promise<Uint8Array>;
|
|
862
1029
|
/** Multi-page PDF of the layouts (default: all) — absent on hosts
|
|
863
1030
|
* without fonts, so check before calling. */
|
|
864
1031
|
renderPdf?(opts?: {
|
|
@@ -872,10 +1039,10 @@ declare module "lineadraw" {
|
|
|
872
1039
|
version?: string;
|
|
873
1040
|
}): Promise<Uint8Array>;
|
|
874
1041
|
/** The `.linea` file text. */
|
|
875
|
-
|
|
1042
|
+
toLinea(): string;
|
|
876
1043
|
/** Add objects (each may carry `layer` — a name — instead of an id);
|
|
877
1044
|
* returns the created ids. */
|
|
878
|
-
add(objects: readonly (
|
|
1045
|
+
add(objects: readonly (ObjectInput & {
|
|
879
1046
|
layer?: string;
|
|
880
1047
|
})[], opts?: {
|
|
881
1048
|
layout?: string;
|
|
@@ -897,7 +1064,7 @@ declare module "lineadraw" {
|
|
|
897
1064
|
/** count TOTAL copies at multiples of delta; returns the new ids. */
|
|
898
1065
|
array(ids: readonly string[], count: number, delta: Vec2Like): string[];
|
|
899
1066
|
/** Create a paper layout; returns its id. */
|
|
900
|
-
|
|
1067
|
+
addLayout(name: string, opts?: LayoutSpec): string;
|
|
901
1068
|
/** Patch a layout's name / sheet / print palette. A bare preset keeps the
|
|
902
1069
|
* layout's current orientation. */
|
|
903
1070
|
updateLayout(nameOrId: string, patch: {
|
|
@@ -919,20 +1086,108 @@ declare module "lineadraw" {
|
|
|
919
1086
|
/** Explicit total order (names or ids, every layer exactly once). */
|
|
920
1087
|
reorderLayers(order: readonly string[]): void;
|
|
921
1088
|
setCurrentLayer(nameOrId: string): void;
|
|
922
|
-
/**
|
|
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>;
|
|
1109
|
+
listTextStyles(): ({
|
|
1110
|
+
id: string;
|
|
1111
|
+
name: string;
|
|
1112
|
+
} & Record<string, unknown>)[];
|
|
1113
|
+
listDimStyles(): ({
|
|
1114
|
+
id: string;
|
|
1115
|
+
name: string;
|
|
1116
|
+
} & Record<string, unknown>)[];
|
|
1117
|
+
/** Create a style (unique name; unset fields take the defaults); returns
|
|
1118
|
+
* its id. Styles are addressed by name or id. */
|
|
1119
|
+
addTextStyle(props: {
|
|
1120
|
+
name: string;
|
|
1121
|
+
} & Record<string, unknown>): string;
|
|
1122
|
+
updateTextStyle(nameOrId: string, patch: Record<string, unknown>): void;
|
|
1123
|
+
/** Remove a style no object uses (refused otherwise). */
|
|
1124
|
+
removeTextStyle(nameOrId: string): void;
|
|
1125
|
+
addDimStyle(props: {
|
|
1126
|
+
name: string;
|
|
1127
|
+
} & Record<string, unknown>): string;
|
|
1128
|
+
updateDimStyle(nameOrId: string, patch: Record<string, unknown>): void;
|
|
1129
|
+
removeDimStyle(nameOrId: string): void;
|
|
1130
|
+
/** @deprecated Use updateDimStyle (default here: the first style). */
|
|
923
1131
|
setDimStyle(patch: Record<string, unknown>, styleId?: string): void;
|
|
924
|
-
/**
|
|
1132
|
+
/** @deprecated Use updateTextStyle (default here: the first style). */
|
|
925
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;
|
|
926
1149
|
/** Embed image pixels (a data URL); returns the content-keyed assetId
|
|
927
1150
|
* that `image` objects reference. */
|
|
928
1151
|
addAsset(dataUrl: string): string;
|
|
929
1152
|
/** Remove an asset (refused while an image references it). */
|
|
930
1153
|
removeAsset(id: string): void;
|
|
1154
|
+
/** Embedded image assets and how many images use each. */
|
|
1155
|
+
listAssets(): {
|
|
1156
|
+
id: string;
|
|
1157
|
+
mimeType: string;
|
|
1158
|
+
bytes: number;
|
|
1159
|
+
users: number;
|
|
1160
|
+
}[];
|
|
1161
|
+
/** Merge DXF text (new layers, objects, layouts); `unitOverride` = mm
|
|
1162
|
+
* per drawing unit. */
|
|
1163
|
+
importDxfText(text: string, opts?: {
|
|
1164
|
+
unitOverride?: number;
|
|
1165
|
+
}): ImportReport & {
|
|
1166
|
+
layers: number;
|
|
1167
|
+
layouts: number;
|
|
1168
|
+
layoutIds: string[];
|
|
1169
|
+
};
|
|
1170
|
+
/** Merge DWG bytes (transcoded to DXF). */
|
|
1171
|
+
importDwgData(data: Uint8Array, opts?: {
|
|
1172
|
+
unitOverride?: number;
|
|
1173
|
+
}): Promise<ImportReport & {
|
|
1174
|
+
layers: number;
|
|
1175
|
+
layouts: number;
|
|
1176
|
+
layoutIds: string[];
|
|
1177
|
+
}>;
|
|
1178
|
+
/** Merge a PDF: vectors/text onto the current layer, or (`as: "image"`,
|
|
1179
|
+
* not available on every host) each page as an image at true scale. */
|
|
1180
|
+
importPdfData(data: ArrayBuffer | Uint8Array, opts?: {
|
|
1181
|
+
as?: "vectors" | "image";
|
|
1182
|
+
origin?: Vec2Like;
|
|
1183
|
+
}): Promise<ImportReport & {
|
|
1184
|
+
pageCount: number;
|
|
1185
|
+
}>;
|
|
931
1186
|
/** Merge block module sources into the document library. */
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
1187
|
+
addBlockDefinitions(sources: readonly string[]): Promise<MergeReport>;
|
|
1188
|
+
removeBlockDefinition(id: string): void;
|
|
1189
|
+
addUserCommands(sources: readonly string[]): Promise<MergeReport>;
|
|
1190
|
+
removeUserCommand(id: string): void;
|
|
936
1191
|
/** Escape hatch: apply an already-shaped kernel op batch (validated,
|
|
937
1192
|
* atomic, one undo step). */
|
|
938
1193
|
applyOps(ops: readonly Record<string, unknown>[]): void;
|
|
@@ -977,7 +1232,14 @@ declare module "lineadraw" {
|
|
|
977
1232
|
layout: string;
|
|
978
1233
|
}): void;
|
|
979
1234
|
setSelection(ids: readonly string[]): void;
|
|
980
|
-
|
|
1235
|
+
/** "fit" (everything in the active space), "selection", some objects'
|
|
1236
|
+
* extents (`{ ids }`), or a window (`{ bbox }`, world mm; sheet mm in a
|
|
1237
|
+
* layout). */
|
|
1238
|
+
zoom(to: "fit" | "selection" | {
|
|
1239
|
+
ids: readonly string[];
|
|
1240
|
+
} | {
|
|
1241
|
+
bbox: Box;
|
|
1242
|
+
}): void;
|
|
981
1243
|
/** Await one snapped world point; `referencePoint` enables rubber-band
|
|
982
1244
|
* + relative typed entry from there. */
|
|
983
1245
|
pickPoint(opts?: {
|
|
@@ -1282,7 +1544,7 @@ declare module "lineadraw" {
|
|
|
1282
1544
|
* inputs: ["Anchor"],
|
|
1283
1545
|
* params: [{ name: "start", label: "First number", type: "number", default: 1 }],
|
|
1284
1546
|
* run: ({ document, editor, inputs: [anchor], params: { start } }) => {
|
|
1285
|
-
* const texts = document.
|
|
1547
|
+
* const texts = document.listObjects({
|
|
1286
1548
|
* type: "text",
|
|
1287
1549
|
* near: { point: anchor, tol: 500 },
|
|
1288
1550
|
* });
|
|
@@ -1367,6 +1629,13 @@ type PolylineVertexLike = {
|
|
|
1367
1629
|
} | readonly [number, number, number?];
|
|
1368
1630
|
/** Style overrides children may carry (otherwise inherited from the instance). */
|
|
1369
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;
|
|
1370
1639
|
/** #rrggbb; absent = by layer. */
|
|
1371
1640
|
color?: string;
|
|
1372
1641
|
/** Line type; absent = by layer. */
|
|
@@ -1375,6 +1644,8 @@ type BaseStyle = {
|
|
|
1375
1644
|
lineTypeScale?: number;
|
|
1376
1645
|
/** Line weight in mm; absent = by layer. */
|
|
1377
1646
|
lineWidth?: number;
|
|
1647
|
+
/** Paint opacity 0..1; absent = by layer (opaque unless the layer says). */
|
|
1648
|
+
opacity?: number;
|
|
1378
1649
|
};
|
|
1379
1650
|
/**
|
|
1380
1651
|
* T plus the shared style fields, FLATTENED (the homomorphic map forces the
|
|
@@ -1431,6 +1702,17 @@ type Hatch = Styled<{
|
|
|
1431
1702
|
}[];
|
|
1432
1703
|
fill?: {
|
|
1433
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;
|
|
1434
1716
|
} | {
|
|
1435
1717
|
kind: "lines";
|
|
1436
1718
|
angle: number;
|
|
@@ -1445,10 +1727,26 @@ type Hatch = Styled<{
|
|
|
1445
1727
|
/** Pattern spacing multiplier. */
|
|
1446
1728
|
scale?: number;
|
|
1447
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
|
+
};
|
|
1448
1745
|
type Text = Styled<{
|
|
1449
1746
|
type: "text";
|
|
1450
1747
|
position: Vec2Like;
|
|
1451
1748
|
content: string;
|
|
1749
|
+
spans?: readonly TextSpan[];
|
|
1452
1750
|
rotation?: number;
|
|
1453
1751
|
/** Justification, as in AutoCAD / DXF: which edge sits on the point —
|
|
1454
1752
|
* "left" = the text runs right of it, "right" = left of it; vAlign
|
|
@@ -1460,6 +1758,8 @@ type Text = Styled<{
|
|
|
1460
1758
|
frame?: "none" | "rectangle" | "circle" | "slot" | "bottom" | "firstLine";
|
|
1461
1759
|
/** MLEADER-style arrow polylines pointing at the text (arrowhead at [0]). */
|
|
1462
1760
|
leaderLines?: readonly (readonly Vec2Like[])[];
|
|
1761
|
+
/** The document text style to follow (name or id); absent = the first. */
|
|
1762
|
+
styleId?: string;
|
|
1463
1763
|
/** Style overrides; absent keys inherit the document text style. */
|
|
1464
1764
|
styleOverride?: {
|
|
1465
1765
|
font?: string;
|
|
@@ -1479,11 +1779,26 @@ type Dimension = Styled<{
|
|
|
1479
1779
|
kind?: "linear" | "angular" | "radial" | "diameter";
|
|
1480
1780
|
/** linear: 2+ chained points (measured point to point); angular: [vertex, a, b]; radial: [center, p]; diameter: [p1, p2]. */
|
|
1481
1781
|
points: readonly Vec2Like[];
|
|
1482
|
-
/**
|
|
1483
|
-
*
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
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;
|
|
1487
1802
|
styleOverride?: {
|
|
1488
1803
|
textHeight?: number;
|
|
1489
1804
|
arrowSize?: number;
|
|
@@ -1511,7 +1826,9 @@ type Block = Styled<{
|
|
|
1511
1826
|
}>;
|
|
1512
1827
|
/** A table cell: plain text, or text with merge / alignment / style. */
|
|
1513
1828
|
type TableCell = string | {
|
|
1514
|
-
|
|
1829
|
+
content?: string;
|
|
1830
|
+
/** Character formatting over `content`. */
|
|
1831
|
+
spans?: readonly TextSpan[];
|
|
1515
1832
|
/** Merge from this (top-left) cell; covered cells are ignored. */
|
|
1516
1833
|
span?: {
|
|
1517
1834
|
cols: number;
|
|
@@ -1546,7 +1863,14 @@ type Table = Styled<{
|
|
|
1546
1863
|
styleId?: string;
|
|
1547
1864
|
styleOverride?: TextStyleOverride;
|
|
1548
1865
|
}>;
|
|
1549
|
-
|
|
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;
|
|
1550
1874
|
/** Identity + shared style fields every stored object carries. */
|
|
1551
1875
|
type StoredObjectBase = {
|
|
1552
1876
|
id: string;
|
|
@@ -1611,6 +1935,8 @@ type StoredHatchFill = {
|
|
|
1611
1935
|
name: string;
|
|
1612
1936
|
angle: number;
|
|
1613
1937
|
scale: number;
|
|
1938
|
+
/** World anchor of the pattern frame; absent = the drawing origin. */
|
|
1939
|
+
origin?: Vec2;
|
|
1614
1940
|
} | {
|
|
1615
1941
|
kind: "lines";
|
|
1616
1942
|
angle: number;
|
|
@@ -1635,6 +1961,7 @@ type StoredText = StoredShape<{
|
|
|
1635
1961
|
type: "text";
|
|
1636
1962
|
position: Vec2;
|
|
1637
1963
|
content: string;
|
|
1964
|
+
spans?: readonly TextSpan[];
|
|
1638
1965
|
leaderLines: readonly (readonly Vec2[])[];
|
|
1639
1966
|
/** Word-wrap / frame width in mm; absent = no wrapping. */
|
|
1640
1967
|
width?: number;
|
|
@@ -1659,8 +1986,14 @@ type StoredDimension = StoredShape<{
|
|
|
1659
1986
|
type: "dimension";
|
|
1660
1987
|
kind: "linear" | "angular" | "radial" | "diameter";
|
|
1661
1988
|
points: readonly Vec2[];
|
|
1662
|
-
|
|
1663
|
-
|
|
1989
|
+
rotation?: number;
|
|
1990
|
+
offset?: number;
|
|
1991
|
+
labels: readonly {
|
|
1992
|
+
along?: number;
|
|
1993
|
+
across?: number;
|
|
1994
|
+
content?: string;
|
|
1995
|
+
spans?: readonly TextSpan[];
|
|
1996
|
+
}[];
|
|
1664
1997
|
styleId?: string;
|
|
1665
1998
|
/** Only the keys the user actually overrode on this dimension. */
|
|
1666
1999
|
styleOverride?: {
|
|
@@ -1737,6 +2070,8 @@ type StoredReference = StoredShape<{
|
|
|
1737
2070
|
hiddenLayers: readonly string[];
|
|
1738
2071
|
/** Switched off: not drawn. */
|
|
1739
2072
|
hidden?: boolean;
|
|
2073
|
+
/** Locked in the References panel: drawn and snapped, never picked. */
|
|
2074
|
+
locked?: boolean;
|
|
1740
2075
|
/** Crop rectangle in file coordinates. */
|
|
1741
2076
|
clip?: {
|
|
1742
2077
|
minX: number;
|
|
@@ -1773,7 +2108,8 @@ type TextStyleOverride = {
|
|
|
1773
2108
|
/** One table cell as stored. */
|
|
1774
2109
|
type StoredTableCell = {
|
|
1775
2110
|
/** Plain text; "\n" = line break. */
|
|
1776
|
-
|
|
2111
|
+
content: string;
|
|
2112
|
+
spans?: readonly TextSpan[];
|
|
1777
2113
|
/** Merge, on the anchor (top-left) cell; covered cells are ignored. */
|
|
1778
2114
|
span?: {
|
|
1779
2115
|
cols: number;
|
|
@@ -1966,7 +2302,7 @@ type FlatParam<Q> = Q extends {
|
|
|
1966
2302
|
*/
|
|
1967
2303
|
type BlockParamDefs = readonly ParamDef[];
|
|
1968
2304
|
/** What the script's `draw` export must return. */
|
|
1969
|
-
type BlockScriptResult =
|
|
2305
|
+
type BlockScriptResult = ObjectInput[];
|
|
1970
2306
|
/** The value an enum option denotes (its string, or `value` of the record form). */
|
|
1971
2307
|
type OptionValue<O extends ParameterOption> = O extends string ? O : O extends {
|
|
1972
2308
|
value: infer V extends string;
|
|
@@ -1999,6 +2335,37 @@ type ParamValues<P> = P extends () => infer R ? ParamValues<R> : P extends reado
|
|
|
1999
2335
|
name: infer N extends string;
|
|
2000
2336
|
} ? N : never]: E extends ParamDef ? ParamValue<E> : never;
|
|
2001
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
|
+
};
|
|
2002
2369
|
/** An axis-aligned box in world mm. */
|
|
2003
2370
|
type Box = {
|
|
2004
2371
|
minX: number;
|
|
@@ -2009,7 +2376,7 @@ type Box = {
|
|
|
2009
2376
|
/** Filters for Drawing.query — all present filters AND together. */
|
|
2010
2377
|
type ObjectQuery = {
|
|
2011
2378
|
ids?: readonly string[];
|
|
2012
|
-
type?:
|
|
2379
|
+
type?: ObjectInput["type"];
|
|
2013
2380
|
/** Layer name or id. */
|
|
2014
2381
|
layer?: string;
|
|
2015
2382
|
/** #rrggbb override (objects without one inherit from their layer). */
|
|
@@ -2088,6 +2455,48 @@ type CommandInfo = {
|
|
|
2088
2455
|
params?: readonly ParamDef[];
|
|
2089
2456
|
};
|
|
2090
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
|
+
};
|
|
2091
2500
|
type MergeReport = {
|
|
2092
2501
|
/** The full library after the merge. */
|
|
2093
2502
|
merged: readonly string[];
|
|
@@ -2121,7 +2530,12 @@ type SheetSpec = "A4" | "A3" | "A2" | "A1" | "A0" | {
|
|
|
2121
2530
|
width: number;
|
|
2122
2531
|
height: number;
|
|
2123
2532
|
};
|
|
2124
|
-
/**
|
|
2533
|
+
/** What an import added (`objectIds` = the new objects). */
|
|
2534
|
+
interface ImportReport {
|
|
2535
|
+
objects: number;
|
|
2536
|
+
objectIds: string[];
|
|
2537
|
+
}
|
|
2538
|
+
/** Options for Drawing.addLayout. */
|
|
2125
2539
|
type LayoutSpec = {
|
|
2126
2540
|
/** Default: A3 landscape. */
|
|
2127
2541
|
sheet?: SheetSpec;
|
|
@@ -2188,9 +2602,12 @@ interface Drawing {
|
|
|
2188
2602
|
name: string;
|
|
2189
2603
|
objectCount: number;
|
|
2190
2604
|
}[];
|
|
2605
|
+
settings: {
|
|
2606
|
+
units: "mm" | "in";
|
|
2607
|
+
};
|
|
2191
2608
|
};
|
|
2192
2609
|
/** Filtered objects — model space, or one layout via `filter.layout`. */
|
|
2193
|
-
|
|
2610
|
+
listObjects(filter?: ObjectQuery): ExistingObject[];
|
|
2194
2611
|
/** One object from ANY space, or undefined. */
|
|
2195
2612
|
getObject(id: string): ExistingObject | undefined;
|
|
2196
2613
|
/** bbox / curve length / enclosed area of one object. */
|
|
@@ -2198,9 +2615,9 @@ interface Drawing {
|
|
|
2198
2615
|
listLayers(): LayerInfo[];
|
|
2199
2616
|
listLayouts(): LayoutInfo[];
|
|
2200
2617
|
/** Compilable block definitions in this document. */
|
|
2201
|
-
|
|
2618
|
+
listBlockDefinitions(): BlockInfo[];
|
|
2202
2619
|
/** Compilable command modules travelling with this document. */
|
|
2203
|
-
|
|
2620
|
+
listUserCommands(): CommandInfo[];
|
|
2204
2621
|
/** Model space (or a layout via `layout`) as an SVG string. */
|
|
2205
2622
|
renderSvg(opts?: {
|
|
2206
2623
|
layout?: string;
|
|
@@ -2208,6 +2625,18 @@ interface Drawing {
|
|
|
2208
2625
|
padding?: number;
|
|
2209
2626
|
palette?: "color" | "grayscale" | "monochrome";
|
|
2210
2627
|
}): string;
|
|
2628
|
+
/** Model space (or a layout) as PNG bytes — absent on hosts that can't
|
|
2629
|
+
* rasterize, so check before calling. */
|
|
2630
|
+
renderPng?(opts?: {
|
|
2631
|
+
layout?: string;
|
|
2632
|
+
bbox?: Box;
|
|
2633
|
+
padding?: number;
|
|
2634
|
+
palette?: "color" | "grayscale" | "monochrome";
|
|
2635
|
+
/** Output width in px (height follows). Default 1024. */
|
|
2636
|
+
width?: number;
|
|
2637
|
+
/** Background fill, e.g. "#ffffff". Default: the dark canvas. */
|
|
2638
|
+
background?: string;
|
|
2639
|
+
}): Promise<Uint8Array>;
|
|
2211
2640
|
/** Multi-page PDF of the layouts (default: all) — absent on hosts
|
|
2212
2641
|
* without fonts, so check before calling. */
|
|
2213
2642
|
renderPdf?(opts?: {
|
|
@@ -2221,10 +2650,10 @@ interface Drawing {
|
|
|
2221
2650
|
version?: string;
|
|
2222
2651
|
}): Promise<Uint8Array>;
|
|
2223
2652
|
/** The `.linea` file text. */
|
|
2224
|
-
|
|
2653
|
+
toLinea(): string;
|
|
2225
2654
|
/** Add objects (each may carry `layer` — a name — instead of an id);
|
|
2226
2655
|
* returns the created ids. */
|
|
2227
|
-
add(objects: readonly (
|
|
2656
|
+
add(objects: readonly (ObjectInput & {
|
|
2228
2657
|
layer?: string;
|
|
2229
2658
|
})[], opts?: {
|
|
2230
2659
|
layout?: string;
|
|
@@ -2246,7 +2675,7 @@ interface Drawing {
|
|
|
2246
2675
|
/** count TOTAL copies at multiples of delta; returns the new ids. */
|
|
2247
2676
|
array(ids: readonly string[], count: number, delta: Vec2Like): string[];
|
|
2248
2677
|
/** Create a paper layout; returns its id. */
|
|
2249
|
-
|
|
2678
|
+
addLayout(name: string, opts?: LayoutSpec): string;
|
|
2250
2679
|
/** Patch a layout's name / sheet / print palette. A bare preset keeps the
|
|
2251
2680
|
* layout's current orientation. */
|
|
2252
2681
|
updateLayout(nameOrId: string, patch: {
|
|
@@ -2268,20 +2697,108 @@ interface Drawing {
|
|
|
2268
2697
|
/** Explicit total order (names or ids, every layer exactly once). */
|
|
2269
2698
|
reorderLayers(order: readonly string[]): void;
|
|
2270
2699
|
setCurrentLayer(nameOrId: string): void;
|
|
2271
|
-
/**
|
|
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>;
|
|
2720
|
+
listTextStyles(): ({
|
|
2721
|
+
id: string;
|
|
2722
|
+
name: string;
|
|
2723
|
+
} & Record<string, unknown>)[];
|
|
2724
|
+
listDimStyles(): ({
|
|
2725
|
+
id: string;
|
|
2726
|
+
name: string;
|
|
2727
|
+
} & Record<string, unknown>)[];
|
|
2728
|
+
/** Create a style (unique name; unset fields take the defaults); returns
|
|
2729
|
+
* its id. Styles are addressed by name or id. */
|
|
2730
|
+
addTextStyle(props: {
|
|
2731
|
+
name: string;
|
|
2732
|
+
} & Record<string, unknown>): string;
|
|
2733
|
+
updateTextStyle(nameOrId: string, patch: Record<string, unknown>): void;
|
|
2734
|
+
/** Remove a style no object uses (refused otherwise). */
|
|
2735
|
+
removeTextStyle(nameOrId: string): void;
|
|
2736
|
+
addDimStyle(props: {
|
|
2737
|
+
name: string;
|
|
2738
|
+
} & Record<string, unknown>): string;
|
|
2739
|
+
updateDimStyle(nameOrId: string, patch: Record<string, unknown>): void;
|
|
2740
|
+
removeDimStyle(nameOrId: string): void;
|
|
2741
|
+
/** @deprecated Use updateDimStyle (default here: the first style). */
|
|
2272
2742
|
setDimStyle(patch: Record<string, unknown>, styleId?: string): void;
|
|
2273
|
-
/**
|
|
2743
|
+
/** @deprecated Use updateTextStyle (default here: the first style). */
|
|
2274
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;
|
|
2275
2760
|
/** Embed image pixels (a data URL); returns the content-keyed assetId
|
|
2276
2761
|
* that `image` objects reference. */
|
|
2277
2762
|
addAsset(dataUrl: string): string;
|
|
2278
2763
|
/** Remove an asset (refused while an image references it). */
|
|
2279
2764
|
removeAsset(id: string): void;
|
|
2765
|
+
/** Embedded image assets and how many images use each. */
|
|
2766
|
+
listAssets(): {
|
|
2767
|
+
id: string;
|
|
2768
|
+
mimeType: string;
|
|
2769
|
+
bytes: number;
|
|
2770
|
+
users: number;
|
|
2771
|
+
}[];
|
|
2772
|
+
/** Merge DXF text (new layers, objects, layouts); `unitOverride` = mm
|
|
2773
|
+
* per drawing unit. */
|
|
2774
|
+
importDxfText(text: string, opts?: {
|
|
2775
|
+
unitOverride?: number;
|
|
2776
|
+
}): ImportReport & {
|
|
2777
|
+
layers: number;
|
|
2778
|
+
layouts: number;
|
|
2779
|
+
layoutIds: string[];
|
|
2780
|
+
};
|
|
2781
|
+
/** Merge DWG bytes (transcoded to DXF). */
|
|
2782
|
+
importDwgData(data: Uint8Array, opts?: {
|
|
2783
|
+
unitOverride?: number;
|
|
2784
|
+
}): Promise<ImportReport & {
|
|
2785
|
+
layers: number;
|
|
2786
|
+
layouts: number;
|
|
2787
|
+
layoutIds: string[];
|
|
2788
|
+
}>;
|
|
2789
|
+
/** Merge a PDF: vectors/text onto the current layer, or (`as: "image"`,
|
|
2790
|
+
* not available on every host) each page as an image at true scale. */
|
|
2791
|
+
importPdfData(data: ArrayBuffer | Uint8Array, opts?: {
|
|
2792
|
+
as?: "vectors" | "image";
|
|
2793
|
+
origin?: Vec2Like;
|
|
2794
|
+
}): Promise<ImportReport & {
|
|
2795
|
+
pageCount: number;
|
|
2796
|
+
}>;
|
|
2280
2797
|
/** Merge block module sources into the document library. */
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2798
|
+
addBlockDefinitions(sources: readonly string[]): Promise<MergeReport>;
|
|
2799
|
+
removeBlockDefinition(id: string): void;
|
|
2800
|
+
addUserCommands(sources: readonly string[]): Promise<MergeReport>;
|
|
2801
|
+
removeUserCommand(id: string): void;
|
|
2285
2802
|
/** Escape hatch: apply an already-shaped kernel op batch (validated,
|
|
2286
2803
|
* atomic, one undo step). */
|
|
2287
2804
|
applyOps(ops: readonly Record<string, unknown>[]): void;
|
|
@@ -2326,7 +2843,14 @@ interface EditorSurface {
|
|
|
2326
2843
|
layout: string;
|
|
2327
2844
|
}): void;
|
|
2328
2845
|
setSelection(ids: readonly string[]): void;
|
|
2329
|
-
|
|
2846
|
+
/** "fit" (everything in the active space), "selection", some objects'
|
|
2847
|
+
* extents (`{ ids }`), or a window (`{ bbox }`, world mm; sheet mm in a
|
|
2848
|
+
* layout). */
|
|
2849
|
+
zoom(to: "fit" | "selection" | {
|
|
2850
|
+
ids: readonly string[];
|
|
2851
|
+
} | {
|
|
2852
|
+
bbox: Box;
|
|
2853
|
+
}): void;
|
|
2330
2854
|
/** Await one snapped world point; `referencePoint` enables rubber-band
|
|
2331
2855
|
* + relative typed entry from there. */
|
|
2332
2856
|
pickPoint(opts?: {
|