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 CHANGED
@@ -128,8 +128,7 @@ lineadraw manifest Validate all modules and write .lineadraw/marketplace.json
128
128
  lineadraw check Validate without writing; fail if the committed manifest is stale
129
129
  lineadraw init Add the marketplace structure to the current npm project
130
130
 
131
- lineadraw status Is the Linea desktop app serving agents? port, open editors
132
- lineadraw editors The open drawings: id, name, path, kind, dirty
131
+ lineadraw status App version, port, the open drawings: id, name, path, kind, dirty
133
132
  lineadraw open <file.linea> Open a file in a new window
134
133
  lineadraw close [--editor <x>] [--discard]
135
134
  lineadraw call <operation> ['<json>'] [--editor <x>] Run one linea_* tool
@@ -142,7 +141,8 @@ token; `--port`, `--token` and `LINEA_BRIDGE_TOKEN` override) — see
142
141
  docs/desktop-bridge.md in the linea repo.
143
142
 
144
143
  The manifest is deterministic (repo-relative paths, no git metadata), so
145
- `check` is a byte-for-byte diff — the included CI workflow runs it on every
144
+ `check` compares the parsed JSON (formatting, a trailing newline or CRLF
145
+ line endings never make it stale) — the included CI workflow runs it on every
146
146
  push and PR. `manifest`/`check` also **dry-run every block** through
147
147
  `lineadraw/sdk` and render thumbnails.
148
148
 
@@ -181,10 +181,10 @@ const walls = doc.addLayer({ name: "walls", color: "#e8e8e8", lineWidth: 0.5 });
181
181
  doc.add([
182
182
  { type: "polyline", layerId: walls, closed: true,
183
183
  points: [[0, 0], [6000, 0], [6000, 3000], [0, 3000]] },
184
- { type: "dimension", points: [[0, 0], [6000, 0]], offset: [0, -500],
184
+ { type: "dimension", points: [[0, 0], [6000, 0]], offset: -500,
185
185
  scale: 50 }, // annotations × drawing scale
186
186
  ]);
187
- doc.createLayout("Plan 1:50", { sheet: "A3", viewport: { scale: "1:50" } });
187
+ doc.addLayout("Plan 1:50", { sheet: "A3", viewport: { scale: "1:50" } });
188
188
  await doc.exportPng("check.png", { width: 1600 }); // verify by LOOKING at it
189
189
  await doc.save("plan.linea");
190
190
  await doc.exportPdf("plan.pdf");
@@ -212,7 +212,7 @@ await doc.exportPdf("plan.pdf");
212
212
  paper size (2.5 body / 3.5 / 5 titles). `scale` is NOT a `styleOverride`
213
213
  key; `add`/`update` reject it there.
214
214
  - **Reads are detached snapshots**: `doc.document`, `doc.objects`,
215
- `getObject`, `query()` return deep clones — mutating them does nothing.
215
+ `getObject`, `listObjects()` return deep clones — mutating them does nothing.
216
216
  - **New documents are layout-less**; `exportPdf` of a layout-less document
217
217
  falls back to one auto-fitted A3 page.
218
218
  - `transaction(fn)` groups edits into one undo step. `array(ids, count,
@@ -222,29 +222,50 @@ await doc.exportPdf("plan.pdf");
222
222
 
223
223
  ### API surface
224
224
 
225
- `newDrawing(name?)` / `drawingFromJson(text)` / `openDrawing(path)` → `Drawing`:
225
+ `newDrawing(name?, options?)` / `drawingFromJson(text)` / `openDrawing(path, options?)`
226
+ → `Drawing`; `options.marketplaces` lists the marketplaces to search and
227
+ install from (`{ kind: "github", spec: "owner/repo[@branch]", token? }` or
228
+ `{ kind: "folder", folder }`, priority order; the public collection is
229
+ appended when missing):
226
230
 
227
231
  - **Name**: `drawing.name` is the file name (set on `openDrawing`, updated
228
232
  by `save(path)`); `newDrawing(name)` names it until it is saved. The
229
233
  `.linea` JSON itself carries no name.
230
234
 
231
235
  - **Read**: `summary()`, `objects`, `layers`, `layouts`, `getObject`,
232
- `query({ids, type, layer, color, lineType, content, bbox, inside, near, layout})`,
236
+ `listObjects({ids, type, layer, color, lineType, content, bbox, inside, near, layout})`,
233
237
  `measure(id)` (`bboxOf(ids)`, `length(id)`, `area(id)`), `listLayers()`,
234
- `listLayouts()`, `listBlocks()`, `listCommands()`, `revision`
238
+ `listLayouts()`, `listTextStyles()`, `listDimStyles()`,
239
+ `listBlockDefinitions()`, `listUserCommands()`, `revision`
235
240
  - **Edit**: `add(objects, {layout?})`, `update(ids, patch)` or
236
241
  `update([{id, ...patch}])`, `remove(ids)` (→ count), `reorder(ids,
237
242
  "front" | "back" | {above} | {below})`, `transaction(fn)` (sync or async;
238
- a throw rolls back), `undo()`, `redo()`, `setDimStyle`,
239
- `setTextStyle`, `applyOps(ops)`, `ready()`
240
- - **Modules**: `await installBlocks(sources)` / `removeBlock(id)`,
241
- `await installCommands(sources)` / `removeCommand(id)`,
243
+ a throw rolls back), `undo()`, `redo()`, `applyOps(ops)`, `ready()`
244
+ - **Styles** (by name or id): `listTextStyles()`, `addTextStyle({name, …})`,
245
+ `updateTextStyle(nameOrId, patch)`, `removeTextStyle(nameOrId)` (refused
246
+ while objects use it) — the same four for `DimStyle`; `setTextStyle` /
247
+ `setDimStyle` remain as deprecated aliases of update
248
+ - **Line types / hatch patterns** (the document's own definitions, by
249
+ name, resolved ahead of the built-in catalogue): `listLineTypes()`,
250
+ `addLineTypes([{name, dashesMm}])`, `updateLineType(name, patch)`,
251
+ `removeLineType(name)`; `listHatchPatterns()`,
252
+ `addHatchPatterns([{name, lines}])`, `updateHatchPattern(name, patch)`,
253
+ `removeHatchPattern(name)`
254
+ - **Modules**: `await addBlockDefinitions(sources)` / `removeBlockDefinition(id)`,
255
+ `await addUserCommands(sources)` / `removeUserCommand(id)`,
242
256
  `await setBlockDefinitions(sources)`, `await setCommands(sources)`
257
+ - **Marketplaces**: `listMarketplaces()`, `await addMarketplaces(list)`
258
+ (verifies each catalog), `removeMarketplaces(names)`,
259
+ `await searchMarketplaces({ query?, kind?, marketplace? })` (entries with
260
+ install status), `await installMarketplaceEntries(ids, marketplace?)`
261
+ (declared block dependencies first, one undo step) — then insert a block
262
+ with `add([{ type: "block", definitionId }])`. Marketplaces are process
263
+ configuration, never written to the file.
243
264
  - **Scripts**: `await runScript(source, inputs?, params?)` runs a
244
265
  `defineCommand` module (the same one the editor palette runs) headlessly
245
266
  as ONE undo step — its declared `inputs` (points) are supplied up front,
246
267
  its declared `params` by name (`{ count: 3 }`; omitted ones take their
247
- defaults, unknown names and wrong types throw); `runCommand(id, inputs?,
268
+ defaults, unknown names and wrong types throw); `runUserCommand(id, inputs?,
248
269
  params?)` runs one of the document's own commands. Returns the script's
249
270
  return value.
250
271
  - **Layers**: `addLayer`, `updateLayer(nameOrId, patch)`,
@@ -253,14 +274,14 @@ await doc.exportPdf("plan.pdf");
253
274
  - **Assets**: `addAsset(dataUrl) → assetId` (for `image` objects;
254
275
  content-keyed), `removeAsset(id)` (refused while referenced)
255
276
  - **Transform**: `move`, `rotate` (radians), `scale`, `mirror`, `copy`, `array`
256
- - **Layouts**: `createLayout(name, {sheet, scale, viewport, index})`,
277
+ - **Layouts**: `addLayout(name, {sheet, scale, viewport, index})`,
257
278
  `updateLayout(nameOrId, {name, sheet, printPalette})`, `removeLayout`,
258
279
  `reorderLayouts`, `parseScale("1:50")`. `sheet` is `"A3"` (landscape when
259
280
  creating, the current orientation when patching), `{ name: "A3",
260
281
  orientation: "portrait" }`, or `{ width, height }` in mm.
261
282
  - **Export**: `renderSvg`/`exportSvg`, `renderPng`/`exportPng`, `await toDxf()`/`exportDxf`,
262
283
  `toDwg`/`exportDwg` (DWG R2000–2018, default AC1027), `renderPdf`/`exportPdf`,
263
- `toJson`/`save`
284
+ `toLinea`/`save`
264
285
  - **Import (merge)**: `importDxf(path)`/`importDxfText(text)` (with
265
286
  `unitOverride`), `importDwg(path)`/`importDwgData(bytes)` (DWG R13–R2018),
266
287
  `importPdfData(arrayBuffer)`
@@ -274,8 +295,12 @@ Full parameter docs are in the bundled `dist/index.d.ts` JSDoc.
274
295
  `hatch` (loops — outer + holes, even-odd; fill solid/pattern/lines) ·
275
296
  `text` (position, content; **default alignment center/center**; optional
276
297
  leaderLines with the arrowhead at index 0) · `dimension` (linear/angular/
277
- radial/diameter; `offset` is a vector from points[0] to the dimension line;
278
- linear with >2 points = chain) · `block` (instances of script definitions) ·
298
+ radial/diameter; linear: `offset` is the signed distance of the dimension
299
+ line from points[0] (left of the measuring direction positive) and
300
+ `rotation` an optional locked measuring direction; angular: `offset` is the
301
+ signed arc radius; `labels[i]` place and word each segment's text —
302
+ `along`/`across` in mm, unset = automatic, `content` with `{value}` for the
303
+ measurement; linear with >2 points = chain) · `block` (instances of script definitions) ·
279
304
  `viewport` (layouts only) · `image` (placement of an asset).
280
305
 
281
306
  ### Block scripts