lineadraw 0.3.0 → 0.4.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 +133 -0
- package/package.json +3 -6
- package/templates/README.md +1 -1
- package/main.js +0 -0
package/README.md
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# lineadraw
|
|
2
|
+
|
|
3
|
+
Type definitions and marketplace tooling for [Linea](https://lineadraw.com)
|
|
4
|
+
blocks and commands — the one devDependency a block/command repository
|
|
5
|
+
needs. Zero runtime: your modules import types from `"lineadraw"`, and the
|
|
6
|
+
Linea editor provides the real implementation when it runs them.
|
|
7
|
+
|
|
8
|
+
- **Typings** — `lineadraw.d.ts` makes `import { defineBlock } from
|
|
9
|
+
"lineadraw"` and `import { … } from "lineadraw/helpers"` type-check in
|
|
10
|
+
any editor/CI, with parameter types inferred into your `draw` function.
|
|
11
|
+
- **CLI** — `lineadraw manifest | check | init` turns any repository into
|
|
12
|
+
a Linea **marketplace**: a git repo the editor can browse and install
|
|
13
|
+
blocks/commands from.
|
|
14
|
+
|
|
15
|
+
## Quick start
|
|
16
|
+
|
|
17
|
+
Scaffold a fresh marketplace repository:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm create lineadraw my-blocks
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Or add the structure to an existing project:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm i -D lineadraw
|
|
27
|
+
npx lineadraw init
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Either way you get `blocks/` and `commands/` folders, a `tsconfig.json`
|
|
31
|
+
wired to the typings, a sample block, a CI workflow, and a generated
|
|
32
|
+
catalog (`.lineadraw/marketplace.json`) — the repo is addable in the
|
|
33
|
+
editor from the first push.
|
|
34
|
+
|
|
35
|
+
## Writing a block
|
|
36
|
+
|
|
37
|
+
A block is one module with a single `defineBlock` default export:
|
|
38
|
+
typed parameters in, geometry out.
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
// blocks/surface.block.ts
|
|
42
|
+
import { defineBlock } from "lineadraw";
|
|
43
|
+
|
|
44
|
+
export default defineBlock({
|
|
45
|
+
// The id is the block's identity everywhere: @<collection>/<slug>.
|
|
46
|
+
// Re-publishing the same id updates installed copies in place.
|
|
47
|
+
id: "@my-blocks/surface",
|
|
48
|
+
name: "Surface",
|
|
49
|
+
version: "1.0.0",
|
|
50
|
+
params: [
|
|
51
|
+
{ name: "kind", type: "enum", default: "rock", options: ["rock", "ground"] },
|
|
52
|
+
],
|
|
53
|
+
place: ["Start point", "End point"], // one point pick per label, in order
|
|
54
|
+
draw: ({ params, inputs: [start, end] }) => {
|
|
55
|
+
params.kind; // "rock" | "ground" — inferred from the params table
|
|
56
|
+
return [{ type: "line", a: start, b: end }];
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Notable optional members: `place` may instead be an interactive
|
|
62
|
+
`({ params, pickPoint, pickObject })` function run once at insertion;
|
|
63
|
+
`dependencies` lists ids of blocks your `draw` emits instances of (installs
|
|
64
|
+
pull them along); `paramVisibility({ params })` hides property rows;
|
|
65
|
+
`previewInputs` curates the inputs used for thumbnails. Units are
|
|
66
|
+
millimeters, Y-up, angles in radians CCW.
|
|
67
|
+
|
|
68
|
+
## Writing a command
|
|
69
|
+
|
|
70
|
+
A command is a macro with a single `defineCommand` default export. Its
|
|
71
|
+
whole run is one undo step; Esc during a pick reverts cleanly.
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
// commands/circle-here.cmd.ts
|
|
75
|
+
import { defineCommand } from "lineadraw";
|
|
76
|
+
|
|
77
|
+
export default defineCommand({
|
|
78
|
+
id: "@my-blocks/circle-here",
|
|
79
|
+
name: "Circle here",
|
|
80
|
+
run: async ({ document, pickPoint, prompt, showToast }) => {
|
|
81
|
+
const center = await pickPoint("Center point");
|
|
82
|
+
const r = await prompt("Radius");
|
|
83
|
+
document.add([{ type: "circle", center, radius: Number.parseFloat(r) }]);
|
|
84
|
+
showToast("Done", "success");
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Imports are limited to `"lineadraw"` and `"lineadraw/helpers"` (geometry
|
|
90
|
+
helpers) — the editor resolves both when executing your module.
|
|
91
|
+
|
|
92
|
+
## The CLI
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
lineadraw manifest Validate all modules and write .lineadraw/marketplace.json
|
|
96
|
+
lineadraw check Validate without writing; fail if the committed manifest is stale
|
|
97
|
+
lineadraw init Add the marketplace structure to the current npm project
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
The manifest is deterministic (repo-relative paths, no git metadata), so
|
|
101
|
+
`check` is a byte-for-byte diff — the included CI workflow runs it on every
|
|
102
|
+
push and PR. With `@lineadraw/sdk` installed as a devDependency,
|
|
103
|
+
`manifest`/`check` additionally **dry-run every block** and render
|
|
104
|
+
thumbnails; without it the CLI still fully works.
|
|
105
|
+
|
|
106
|
+
Collection name and owner come from your package.json:
|
|
107
|
+
|
|
108
|
+
```json
|
|
109
|
+
{ "lineadraw": { "marketplaceName": "My blocks", "marketplaceOwner": "Me" } }
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Using a marketplace in the editor
|
|
113
|
+
|
|
114
|
+
In [the editor](https://lineadraw.com): **Library → Marketplace tab → +**
|
|
115
|
+
and enter `owner/repo` (or `owner/repo@branch`). For a private repository,
|
|
116
|
+
create a fine-grained personal access token with read-only Contents access
|
|
117
|
+
to just that repository and paste it in the add dialog — it is stored only
|
|
118
|
+
on that device. Installing embeds the module (and its declared dependency
|
|
119
|
+
closure) in the document, so drawings keep working offline and travel with
|
|
120
|
+
the file.
|
|
121
|
+
|
|
122
|
+
## Ecosystem
|
|
123
|
+
|
|
124
|
+
- [Linea editor](https://lineadraw.com) — the browser CAD app that runs
|
|
125
|
+
these modules.
|
|
126
|
+
- [`lineadraw/lineadraw`](https://github.com/lineadraw/lineadraw) — the
|
|
127
|
+
public collection: real blocks/commands to learn from, agent skill, and
|
|
128
|
+
guides.
|
|
129
|
+
- [`@lineadraw/sdk`](https://www.npmjs.com/package/@lineadraw/sdk) —
|
|
130
|
+
headless Node API over the same kernel (open/edit/render/export
|
|
131
|
+
`.linea` documents; also powers the CLI's block dry-runs).
|
|
132
|
+
- [`@lineadraw/mcp`](https://www.npmjs.com/package/@lineadraw/mcp) — MCP
|
|
133
|
+
server with the full editor as an in-chat app.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lineadraw",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Type definitions and marketplace tooling for Linea blocks and commands",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Mikhail Koshelev",
|
|
@@ -11,17 +11,14 @@
|
|
|
11
11
|
},
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
|
-
"types": "./lineadraw.d.ts"
|
|
15
|
-
"default": "./main.js"
|
|
14
|
+
"types": "./lineadraw.d.ts"
|
|
16
15
|
},
|
|
17
16
|
"./helpers": {
|
|
18
|
-
"types": "./lineadraw.d.ts"
|
|
19
|
-
"default": "./main.js"
|
|
17
|
+
"types": "./lineadraw.d.ts"
|
|
20
18
|
}
|
|
21
19
|
},
|
|
22
20
|
"files": [
|
|
23
21
|
"lineadraw.d.ts",
|
|
24
|
-
"main.js",
|
|
25
22
|
"bin",
|
|
26
23
|
"lib",
|
|
27
24
|
"templates"
|
package/templates/README.md
CHANGED
|
@@ -12,7 +12,7 @@ catalog (`.lineadraw/marketplace.json`).
|
|
|
12
12
|
|
|
13
13
|
## Using it in the editor
|
|
14
14
|
|
|
15
|
-
Library →
|
|
15
|
+
Library → Marketplace tab → + → add this repository
|
|
16
16
|
as `owner/repo`. For a private repository, create a fine-grained personal
|
|
17
17
|
access token with read-only Contents access to just this repository and
|
|
18
18
|
paste it in the add dialog — it is stored only on that device.
|
package/main.js
DELETED
|
File without changes
|