lineadraw 0.10.0 → 0.11.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 +18 -7
- package/bin/lineadraw.mjs +60 -10
- package/dist/bridge.d.ts +1 -0
- package/dist/bridge.js +1 -1
- package/dist/{chunk-YYJAXJOY.js → chunk-7UFXC7OI.js} +1680 -141
- package/dist/chunk-7UFXC7OI.js.map +1 -0
- package/dist/chunk-FDLANLIC.js +1161 -0
- package/dist/chunk-FDLANLIC.js.map +1 -0
- package/dist/chunk-M3EDRSHW.js +81 -0
- package/dist/chunk-M3EDRSHW.js.map +1 -0
- package/dist/chunk-MYP7RUYK.js +9 -0
- package/dist/chunk-MYP7RUYK.js.map +1 -0
- package/dist/{chunk-L2CWZAKW.js → chunk-RNA2RDGL.js} +13 -6
- package/dist/chunk-RNA2RDGL.js.map +1 -0
- package/dist/dist-56K6CNML.js +188 -0
- package/dist/dist-56K6CNML.js.map +1 -0
- package/dist/dist-IEN64QSV.js +10 -0
- package/dist/dist-IEN64QSV.js.map +1 -0
- package/dist/emscripten-module-Q67P5WYC-ITCU5LXL.js +2424 -0
- package/dist/emscripten-module-Q67P5WYC-ITCU5LXL.js.map +1 -0
- package/dist/{exportDxf-C4CLQCC3.js → exportDxf-6XTXQ4XN.js} +2 -2
- package/dist/ffi-SHMEF5YV.js +82 -0
- package/dist/ffi-SHMEF5YV.js.map +1 -0
- package/dist/module-ES6BEMUI-BJFWC656.js +14 -0
- package/dist/module-ES6BEMUI-BJFWC656.js.map +1 -0
- package/dist/module-asyncify-2EFITU5U-7F5WZXRA.js +9 -0
- package/dist/module-asyncify-2EFITU5U-7F5WZXRA.js.map +1 -0
- package/dist/sdk.d.ts +868 -95
- package/dist/sdk.js +619 -558
- package/dist/sdk.js.map +1 -1
- package/lineadraw.d.ts +162 -8
- package/package.json +2 -2
- package/dist/chunk-L2CWZAKW.js.map +0 -1
- package/dist/chunk-YYJAXJOY.js.map +0 -1
- /package/dist/{exportDxf-C4CLQCC3.js.map → exportDxf-6XTXQ4XN.js.map} +0 -0
package/README.md
CHANGED
|
@@ -59,9 +59,13 @@ await doc.exportPdf("plan.pdf");
|
|
|
59
59
|
its objects; an object's own `opacity` overrides it. Paints across canvas,
|
|
60
60
|
SVG, and PDF; DXF/DWG export drops it (no direct mapping).
|
|
61
61
|
- **Annotation scale is per-object**: for a 1:N drawing set the top-level
|
|
62
|
-
`scale: N` on text, dimensions, and hatches, keeping
|
|
63
|
-
paper size (2.5 body / 3.5 / 5 titles). `scale` is NOT a
|
|
64
|
-
key; `add`/`update` reject it there.
|
|
62
|
+
`scale: N` on text, dimensions, and hatches, keeping the text height
|
|
63
|
+
at paper size (2.5 body / 3.5 / 5 titles). `scale` is NOT a
|
|
64
|
+
`styleOverride` key; `add`/`update` reject it there.
|
|
65
|
+
- **One shape per field.** Style keys of a text, table or dimension
|
|
66
|
+
(`textHeight`, `font`, `bold`, `arrowSize`, …) live in `styleOverride`
|
|
67
|
+
(or a named style via `styleId`), never at the top level; a hidden layer
|
|
68
|
+
is `visible: false`. Unknown fields throw, naming where they belong.
|
|
65
69
|
- **Reads are detached snapshots**: `doc.document`, `doc.objects`,
|
|
66
70
|
`getObject`, `listObjects()` return deep clones — mutating them does nothing.
|
|
67
71
|
- **New documents are layout-less**; `exportPdf` of a layout-less document
|
|
@@ -146,7 +150,10 @@ Full parameter docs are in the bundled `dist/sdk.d.ts` JSDoc.
|
|
|
146
150
|
|
|
147
151
|
`line` (a, b) · `polyline` (points with optional bulge, closed) · `circle` ·
|
|
148
152
|
`arc` (CCW start→end) · `ellipse` (center, majorAxis vector, ratio) ·
|
|
149
|
-
`point` (p) · `hatch` (loops — outer + holes, even-odd;
|
|
153
|
+
`point` (p) · `hatch` (loops — outer + holes, even-odd; each loop a closed
|
|
154
|
+
chain of `edges`: `line`, `arc`, `ellipse` or `spline`, with the fields of that
|
|
155
|
+
object type — a circle, ellipse or closed spline is one edge; `hatchLoop(points)`
|
|
156
|
+
builds a polygon / bulged loop; fill solid/pattern/lines) ·
|
|
150
157
|
`text` (position, content; **default alignment center/center**; optional
|
|
151
158
|
leaderLines with the arrowhead at index 0) · `dimension` (linear/angular/
|
|
152
159
|
radial/diameter; linear: `offset` is the signed distance of the dimension
|
|
@@ -327,7 +334,7 @@ stay holes:
|
|
|
327
334
|
```ts
|
|
328
335
|
const solid = union(...walls.map(wallRect)); // overlapping walls → clean outlines
|
|
329
336
|
return [
|
|
330
|
-
{ type: "hatch", loops: solid.map(
|
|
337
|
+
{ type: "hatch", loops: solid.map(hatchLoop), // a ring → line edges
|
|
331
338
|
fill: { kind: "pattern", name: "ANSI31", angle: 0, scale: 20 } },
|
|
332
339
|
...solid.map((points) => ({ type: "polyline", points, closed: true })),
|
|
333
340
|
];
|
|
@@ -509,8 +516,9 @@ the file.
|
|
|
509
516
|
lineadraw status App version, port, the open drawings: id, name, path, kind, dirty
|
|
510
517
|
lineadraw open <file.linea> Open a file in a new window
|
|
511
518
|
lineadraw close [--editor <x>] [--discard]
|
|
512
|
-
lineadraw call <operation> ['<json>'] [--editor <x>] Run one linea_* operation
|
|
513
|
-
lineadraw tools
|
|
519
|
+
lineadraw call <operation> ['<json>' | @file.json | -] [--editor <x>] Run one linea_* operation
|
|
520
|
+
lineadraw tools [<operation>] The operations the bridge offers, or one's argument schema
|
|
521
|
+
lineadraw --version
|
|
514
522
|
```
|
|
515
523
|
|
|
516
524
|
These commands talk to the running Linea desktop app on `127.0.0.1:7431`
|
|
@@ -524,6 +532,9 @@ SDK's [`connectEditors()`](#running-editors-the-desktop-bridge).
|
|
|
524
532
|
npx lineadraw call linea_add_objects '{"objects":[{"type":"circle","center":[0,0],"radius":500}]}'
|
|
525
533
|
```
|
|
526
534
|
|
|
535
|
+
The arguments can also come from a file (`@args.json`) or stdin (`-`),
|
|
536
|
+
which spares quoting JSON in PowerShell or cmd.
|
|
537
|
+
|
|
527
538
|
## Ecosystem
|
|
528
539
|
|
|
529
540
|
- [Linea](https://lineadraw.com) — the CAD editor, on the desktop and on
|
package/bin/lineadraw.mjs
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
13
13
|
import { isDeepStrictEqual } from "node:util";
|
|
14
14
|
import { dirname, join, resolve } from "node:path";
|
|
15
|
+
import { fileURLToPath } from "node:url";
|
|
15
16
|
import {
|
|
16
17
|
buildManifest,
|
|
17
18
|
manifestJson,
|
|
@@ -35,12 +36,42 @@ Running editors (the Linea desktop app on 127.0.0.1:7431):
|
|
|
35
36
|
status app version, port, the open drawings (id, name, path, kind, dirty)
|
|
36
37
|
open <file.linea> open a file in a window of its own (returns its editor)
|
|
37
38
|
close [--editor <x>] [--discard] close an editor like its window's x
|
|
38
|
-
call <operation> ['<json>'] [--editor <x>]
|
|
39
|
-
run one linea_* operation (see tools)
|
|
40
|
-
|
|
39
|
+
call <operation> ['<json>' | @file.json | -] [--editor <x>]
|
|
40
|
+
run one linea_* operation (see tools);
|
|
41
|
+
its arguments as JSON text, a file, or stdin
|
|
42
|
+
tools [<operation>] the operations the bridge offers, or
|
|
43
|
+
one operation's argument schema
|
|
41
44
|
|
|
42
45
|
The desktop's bridge.json (port, agent token) is read automatically;
|
|
43
|
-
LINEA_BRIDGE_TOKEN or --token override the token, --port the port
|
|
46
|
+
LINEA_BRIDGE_TOKEN or --token override the token, --port the port.
|
|
47
|
+
|
|
48
|
+
--version the lineadraw version --help this text`;
|
|
49
|
+
|
|
50
|
+
const VERSION = JSON.parse(
|
|
51
|
+
readFileSync(
|
|
52
|
+
join(dirname(fileURLToPath(import.meta.url)), "..", "package.json"),
|
|
53
|
+
"utf8",
|
|
54
|
+
),
|
|
55
|
+
).version;
|
|
56
|
+
|
|
57
|
+
/** `call`'s arguments: JSON text, `@file.json`, or `-` for stdin (quoting
|
|
58
|
+
* JSON on a Windows command line is a fight best not picked). */
|
|
59
|
+
const readCallArgs = (spec) => {
|
|
60
|
+
if (spec === undefined) return {};
|
|
61
|
+
const text =
|
|
62
|
+
spec === "-"
|
|
63
|
+
? readFileSync(0, "utf8")
|
|
64
|
+
: spec.startsWith("@")
|
|
65
|
+
? readFileSync(resolve(spec.slice(1)), "utf8")
|
|
66
|
+
: spec;
|
|
67
|
+
try {
|
|
68
|
+
return JSON.parse(text);
|
|
69
|
+
} catch (e) {
|
|
70
|
+
throw new Error(
|
|
71
|
+
`call: the arguments are not valid JSON (${e instanceof Error ? e.message : e})`,
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
44
75
|
|
|
45
76
|
const args = process.argv.slice(2);
|
|
46
77
|
const command = args[0];
|
|
@@ -90,12 +121,20 @@ const bridgeCommand = async (cmd, positional, flags) => {
|
|
|
90
121
|
const [operation, json] = positional;
|
|
91
122
|
if (!operation)
|
|
92
123
|
throw new Error("call needs an operation name (see `lineadraw tools`)");
|
|
93
|
-
return b.call(operation, json
|
|
94
|
-
|
|
95
|
-
|
|
124
|
+
return b.call(operation, readCallArgs(json), { editor });
|
|
125
|
+
}
|
|
126
|
+
case "tools": {
|
|
127
|
+
const tools = await b.tools();
|
|
128
|
+
const wanted = positional[0];
|
|
129
|
+
if (wanted === undefined)
|
|
130
|
+
return tools.map(({ name, description }) => ({ name, description }));
|
|
131
|
+
const tool = tools.find((t) => t.name === wanted);
|
|
132
|
+
if (!tool)
|
|
133
|
+
throw new Error(
|
|
134
|
+
`Unknown operation "${wanted}". \`lineadraw tools\` lists them.`,
|
|
135
|
+
);
|
|
136
|
+
return tool;
|
|
96
137
|
}
|
|
97
|
-
case "tools":
|
|
98
|
-
return b.tools();
|
|
99
138
|
default:
|
|
100
139
|
throw new Error(`Unknown command: ${cmd}\n\n${USAGE}`);
|
|
101
140
|
}
|
|
@@ -184,8 +223,19 @@ switch (command) {
|
|
|
184
223
|
}
|
|
185
224
|
break;
|
|
186
225
|
}
|
|
226
|
+
case "--version":
|
|
227
|
+
case "-v":
|
|
228
|
+
console.log(VERSION);
|
|
229
|
+
break;
|
|
230
|
+
case "--help":
|
|
231
|
+
case "-h":
|
|
232
|
+
case "help":
|
|
233
|
+
console.log(USAGE);
|
|
234
|
+
break;
|
|
187
235
|
default: {
|
|
188
|
-
if (
|
|
236
|
+
if (command === undefined) fail(USAGE);
|
|
237
|
+
if (!BRIDGE_COMMANDS.includes(command))
|
|
238
|
+
fail(`Unknown command "${command}".\n\n${USAGE}`);
|
|
189
239
|
const { positional, flags } = parseArgs(args.slice(1));
|
|
190
240
|
try {
|
|
191
241
|
const result = await bridgeCommand(command, positional, flags);
|
package/dist/bridge.d.ts
CHANGED
|
@@ -78,6 +78,7 @@ interface LineaBridge {
|
|
|
78
78
|
tools(): Promise<{
|
|
79
79
|
name: string;
|
|
80
80
|
description?: string;
|
|
81
|
+
inputSchema?: unknown;
|
|
81
82
|
}[]>;
|
|
82
83
|
/** Open a `.linea` file in a window of its own (an absolute path, or one
|
|
83
84
|
* relative to the current directory); resolves once it has loaded. */
|