@rulecad/cad 0.9.0 → 0.10.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/AGENTS.md +21 -6
- package/CHANGELOG.md +320 -0
- package/EXAMPLES.md +22 -17
- package/README.md +192 -40
- package/bin/cad.mjs +465 -80
- package/lib/assembly.mjs +68 -33
- package/lib/cache-file.mjs +105 -0
- package/lib/code-text.mjs +28 -0
- package/lib/design-imports.mjs +127 -0
- package/lib/design.mjs +251 -55
- package/lib/designshapes.mjs +142 -0
- package/lib/edit.mjs +24 -2
- package/lib/estimates.mjs +51 -0
- package/lib/fasten.mjs +11 -5
- package/lib/fe-key.mjs +29 -0
- package/lib/fittings.mjs +20 -15
- package/lib/fixings.mjs +17 -4
- package/lib/framebuild.mjs +1 -1
- package/lib/framegen.mjs +9 -1
- package/lib/frames.mjs +6 -2
- package/lib/framesize.mjs +8 -81
- package/lib/host.mjs +7 -3
- package/lib/kit.mjs +5 -5
- package/lib/list.mjs +29 -21
- package/lib/loads.mjs +35 -23
- package/lib/measured.mjs +738 -98
- package/lib/motors.mjs +9 -29
- package/lib/names.mjs +15 -0
- package/lib/optimise.mjs +34 -25
- package/lib/order.mjs +4 -10
- package/lib/parts.mjs +3 -0
- package/lib/rules.mjs +2 -1
- package/lib/sandbox-hooks.mjs +109 -15
- package/lib/sandbox-lock.mjs +225 -0
- package/lib/sandbox-preload.mjs +2 -2
- package/lib/sandbox-run.mjs +22 -24
- package/lib/sandbox.mjs +173 -30
- package/lib/sheet.mjs +114 -3
- package/lib/versions.mjs +195 -32
- package/lib/workspace.mjs +3 -2
- package/package.json +11 -11
- package/schemas/assembly.schema.json +1 -1
- package/schemas/project.schema.json +6 -0
- package/templates/coupons/MEASURE.md +109 -0
- package/templates/coupons/assemblies/fixings-test.json +20 -0
- package/templates/coupons/assemblies/slot-test.json +11 -0
- package/templates/coupons/objects/fixings-coupon.js +88 -0
- package/templates/coupons/objects/fixings-coupon.json +26 -0
- package/templates/coupons/objects/holds-coupon.js +130 -0
- package/templates/coupons/objects/holds-coupon.json +42 -0
- package/templates/coupons/objects/slot-coupon.js +89 -0
- package/templates/coupons/objects/slot-coupon.json +29 -0
- package/templates/coupons/project.json +10 -0
package/README.md
CHANGED
|
@@ -24,6 +24,7 @@ measured into rules, an optimised arm, a board, and a mechanism printed flat, ea
|
|
|
24
24
|
```
|
|
25
25
|
rules/ shared facts, one file per set: x1c.json (printer), mx.json (Cherry MX). A set from
|
|
26
26
|
@rulecad/rules is copied here the first time a design uses it: yours to keep and correct
|
|
27
|
+
(cad rules update <set> takes the kit's later corrections; see The workspace)
|
|
27
28
|
projects/<project>/
|
|
28
29
|
project.json name, title, description, default material, printer, objects, filaments (AMS slots)
|
|
29
30
|
(schemas/project.schema.json; written by cad new <project>, changed by cad set <project>)
|
|
@@ -39,6 +40,7 @@ exports/ .preview/ .versions/ .cache/ generated (ignore them in git); .cache/b
|
|
|
39
40
|
```sh
|
|
40
41
|
npx cad rules bathroom/soap-tray # every variable, its rule and source
|
|
41
42
|
npx cad check bathroom/soap-tray --set width=60 # change variables that have a tweak range
|
|
43
|
+
npx cad check bathroom/tray-on-shelf --set tray.width=60 # in an assembly: <item>.<variable>
|
|
42
44
|
npx cad variants keyboard/keycap # named sets of inputs: keyboard/keycap:legend-f
|
|
43
45
|
npx cad compare keyboard/keycap dsa legend-f # two variants (or releases) side by side
|
|
44
46
|
npx cad import-kle layout.json keyboard/mine # a layout from keyboard-layout-editor.com, into layouts/
|
|
@@ -153,6 +155,27 @@ else the current folder:
|
|
|
153
155
|
- Previews need Chrome or Chromium: `$CAD_CHROME`, else the usual install paths.
|
|
154
156
|
- Designs are code: run only designs you trust. Links and rule files are data and never run.
|
|
155
157
|
|
|
158
|
+
### Your copies of the kit's rule sets
|
|
159
|
+
|
|
160
|
+
The first time a design uses one of the kit's rule sets (`x1c`, `m3`, `pla`), cad copies it into `rules/` and from
|
|
161
|
+
then on reads only that copy: the workspace keeps every figure its designs were built on, and your measurements are
|
|
162
|
+
edits to your copy. A later version of the kit may correct a figure or add rules, and the copy keeps what it had until
|
|
163
|
+
you take them. `cad rules check` says when:
|
|
164
|
+
|
|
165
|
+
| Note | What it says | What to do |
|
|
166
|
+
|---|---|---|
|
|
167
|
+
| `rules.changed` | The kit has a different figure for a rule, checked after your copy's was, and your copy's is not `measured` | `cad rules update <set>` |
|
|
168
|
+
| `rules.new` | The kit's set has rules your copy lacks | `cad rules update <set>`, or copy the ones you want by hand |
|
|
169
|
+
| `rules.same` | Your copy is the kit's set word for word: nothing in it is yours | Keep it, or delete it: the next design to use the set copies in the kit's as it is then |
|
|
170
|
+
|
|
171
|
+
`cad rules update <set>` brings `rules/<set>.json` up to the kit's and prints each change: a figure the kit checked
|
|
172
|
+
after your copy's was (`13.8 → 14`), the kit's new rules, and the same figure with more said of it (its range, a newer
|
|
173
|
+
source). It keeps every figure of kind `measured`, every figure you checked on or after the kit's date (your own
|
|
174
|
+
word), and every rule the kit has none of. `--dry-run` prints what it would change and writes nothing; `--json` gives
|
|
175
|
+
it as `{ changed: [{ rule, from, to }], added, refreshed, fields, kept: { measured, newer, own } }`. A figure that
|
|
176
|
+
changes can move a printed size: check the designs that use the set afterwards. So that a correction of yours is never
|
|
177
|
+
taken for an old figure, record it with `"kind": "measured"` (or today's date in `checked`).
|
|
178
|
+
|
|
156
179
|
## Links
|
|
157
180
|
|
|
158
181
|
`cad link <project>/<object>` (and `cad show`) prints three links to the model page (`viewUrl`; a public one by default):
|
|
@@ -203,8 +226,13 @@ so in one line (on stderr), so that a workspace from elsewhere can't send your l
|
|
|
203
226
|
also checks the version; `"macropad/pcb@0.2.0"` reads that release. `cad rules` shows each borrowed number with the
|
|
204
227
|
object and version it came from; two objects can't read each other.
|
|
205
228
|
- `show`: on the rules card `cad show` hands its target (six at most). `interface`: other parts depend on it (versioning will compare these).
|
|
206
|
-
- `tweak: { min, max }`: may be changed with `--set`. Variables without one are fixed by their rule.
|
|
207
|
-
|
|
229
|
+
- `tweak: { min, max }`: may be changed with `--set`. Variables without one are fixed by their rule. On an assembly,
|
|
230
|
+
`--set <item>.<variable>=<value>` builds that object item at the value (`cad check`, `preview`, `export`, `show`,
|
|
231
|
+
`link`, `animate`, `cad list`, `wires` and `beams`); a name that is not one of the assembly's object items and that
|
|
232
|
+
object's variables is refused by name, never passed over. The commands that make a build from the file as written
|
|
233
|
+
(`kit`, `plates`, `order`, `frame`, `machine`, `plot`, `measured`) refuse `--set`: write the value with `cad set`.
|
|
234
|
+
- Inputs that hold names or text, not numbers (the design reads them; expressions can't), all settable with `--set`
|
|
235
|
+
and `cad set`, which keep the text as typed (`legend=007` stays `007`, never the number 7):
|
|
208
236
|
- `choice: ["dsa", "oem"]`: one of a list.
|
|
209
237
|
- `"type": "text"` (with `max`, characters): free text, e.g. a keycap's `legend`.
|
|
210
238
|
- `"type": "anchor"`: one of 9 places on a face, `tl tc tr / ml mc mr / bl bc br`, for placing a legend.
|
|
@@ -221,6 +249,9 @@ so in one line (on stderr), so that a workspace from elsewhere can't send your l
|
|
|
221
249
|
text so punctuation stays small, each straight stroke thickened to whole print lines, dots drawn round, and ↑ ↓ ← →
|
|
222
250
|
as arrows), `anchor(face, size, at)` (where something goes on a face, by anchor), and `cut(a, b)` (a subtract that
|
|
223
251
|
only touches a's faces near b; JSCAD's own splits every face along b's planes, which can leave slivers far away).
|
|
252
|
+
Its seats for bought parts, `shaftBore`, `bearingSeat`, `plainBearing` and `pulleyBore`, are reported by `cad check`
|
|
253
|
+
as `v.fixings`'s holes are (`seat.drawn`): what each was drawn to, the fit it rests on and that fit's kind (a press
|
|
254
|
+
fit on a shaft is an estimate until it is measured).
|
|
224
255
|
- `v.flexures`: compliant mechanisms (`@rulecad/flexures`): `leaf`, `fixedGuided`, `parallelGuide`, `serpentine`,
|
|
225
256
|
`notchHinge`, `bistable`, `livingHinge` as shapes, each with a `<name>Model(shape, { E })` giving its stiffness and the
|
|
226
257
|
strain at a travel, and `printable(shape, printer, material, model)` for how it prints. Drawn flat: bending along y,
|
|
@@ -232,7 +263,9 @@ so in one line (on stderr), so that a workspace from elsewhere can't send your l
|
|
|
232
263
|
print, and `engagement`, `seating` and `lengthFor` for first sums. Each reads the workspace's own thread set
|
|
233
264
|
(`rules/m3.json`) before the kit's, the project's printer and (for what a thread is in) its material, so a design
|
|
234
265
|
types no diameter and passes none. `cad check` lists what each call drew and the rule it rests on (`hole.drawn`,
|
|
235
|
-
`counterbore.drawn`, ...).
|
|
266
|
+
`counterbore.drawn`, ...). In an object that is not printed (`"role": "reference"` or `"board"`: a bought circuit
|
|
267
|
+
board, drilled by its maker), a hole is drawn to its rule's figure as it stands, with no hole compensation. A design
|
|
268
|
+
may also import `@rulecad/fixings` itself: then it reads the kit's sets only.
|
|
236
269
|
- `v.frames`: beams and profiles (`@rulecad/frames`): `profileModel` for a profile's figures, slots and faces
|
|
237
270
|
(`v.frames.profileModel('2020-misumi-hfs5').slots['slot-6-misumi'].opening`, to draw a tab that drops into a slot),
|
|
238
271
|
`slotModel`, `beamModel`, `beam` and `outline`. A profile measured into this workspace's `rules/` (`cad measure
|
|
@@ -255,8 +288,11 @@ so in one line (on stderr), so that a workspace from elsewhere can't send your l
|
|
|
255
288
|
was read from (`projects/p/project.json: the "printer" field "../x" is not a plain name`): a workspace's own files
|
|
256
289
|
cannot make the tool read or write anywhere but where it means to. In `"uses"`, another object is
|
|
257
290
|
`<project>/<object>`, optionally with `:<variant>` and `@<version>`, never a path to a file.
|
|
258
|
-
- Rules carry `kind`: spec (manufacturer), default (slicer), community (rule of thumb)
|
|
259
|
-
|
|
291
|
+
- Rules carry `kind`: spec (manufacturer), default (slicer), community (rule of thumb), estimate (a reasoned guess
|
|
292
|
+
nobody has measured yet), derived (worked out from other figures, such as a board's size read from its design file)
|
|
293
|
+
or measured (your own test print, which beats the rest), plus `source` and `checked`. `cad check` warns
|
|
294
|
+
(`rules.estimate`) when an object or an assembly rests on an estimate: a rule it reads, or a seat drawn to an
|
|
295
|
+
estimated fit (a press-fit `shaftBore`), naming each one to measure.
|
|
260
296
|
|
|
261
297
|
## Versions
|
|
262
298
|
|
|
@@ -266,11 +302,33 @@ Every object has its own semver version, kept as a git tag (`keyboard/keycap@1.2
|
|
|
266
302
|
- **major**: an earlier print may no longer fit. An `interface` variable changed or went away, including through a
|
|
267
303
|
rule it's built from (a new `x1c.hole_comp` widens the slot, so the keycap's slot changes: major).
|
|
268
304
|
- **minor**: something added that doesn't break fits: a new interface variable, a new tweakable option.
|
|
269
|
-
- **patch**: everything else: other variables, the shape's code, rules that don't reach the interface
|
|
305
|
+
- **patch**: everything else: other variables, the shape's code, rules that don't reach the interface, and any other
|
|
306
|
+
file the design reads (below).
|
|
307
|
+
|
|
308
|
+
A release records everything its design is built from, so that it can be rebuilt exactly and any later change to
|
|
309
|
+
one of those files asks for a new release. Its commit holds, and its tag names:
|
|
310
|
+
|
|
311
|
+
- the object's `.js` and `.json`, the rule sets in its `"uses"` and the layout files it can pick;
|
|
312
|
+
- the files of its project that its code imports (the starter template's `lid.js` imports `./box.js`);
|
|
313
|
+
- where it draws with `v.fixings` or `v.frames`, the workspace's own rule sets those read (thread, material and
|
|
314
|
+
profile sets, the printer's, and measured outlines in `rules/outlines/`), and the project's material and printer;
|
|
315
|
+
- the files of the objects it reads through `"uses"` (each one's own files, and what it reads), unless it names a
|
|
316
|
+
release of theirs (`"home/box@1.0.0"`), which is rebuilt from its own tag.
|
|
317
|
+
|
|
318
|
+
A release is rebuilt in `.versions/<project>/<object>@<version>/`, its files at the paths they have in the workspace,
|
|
319
|
+
with the rule sets, imports and other objects of its tag, never today's. `cad status` and `cad diff` compare each of
|
|
320
|
+
those files with the workspace's: a helper edited, a rule set measured again (`rules/m3.json`) or one added that its
|
|
321
|
+
fixings now read is a change to the part (`rules/m3.json changed`, `now reads rules/m3.json`), and a changed object
|
|
322
|
+
it reads counts through the numbers it takes from it. A release made before releases recorded this is rebuilt with
|
|
323
|
+
the files its code imports by a path (`./box.js`), and its rule sets as its tag holds them.
|
|
270
324
|
|
|
271
325
|
A lower `--bump` than the changes need is refused (`--force` overrides). Releases are logged in the project's
|
|
272
326
|
`CHANGELOG.md`. A project release (`cad release keyboard`) records the version of each object, and its bump is the
|
|
273
|
-
biggest of theirs
|
|
327
|
+
biggest of theirs: it writes `version` and `release` (each object's version) into the project's `project.json`, and
|
|
328
|
+
`cad set <project>` goes on working after it. A release is a git commit and tag, so the workspace must be in a git
|
|
329
|
+
repository (it may be a folder of a larger one) with a name and email address set (`git config user.name`, `git config
|
|
330
|
+
user.email`); `cad release` says what to run if either is missing. If git refuses the commit or the tag (a hook that
|
|
331
|
+
fails), the version and changelog are put back as they were, and the release can simply be run again. `cad printed` logs what you printed and how it came out in `prints.jsonl`; `cad history` shows
|
|
274
332
|
releases and prints together.
|
|
275
333
|
|
|
276
334
|
```sh
|
|
@@ -283,6 +341,61 @@ npx cad history keyboard/keycap
|
|
|
283
341
|
npx cad diff keyboard/keycap 1.0.0 1.1.0
|
|
284
342
|
```
|
|
285
343
|
|
|
344
|
+
### Measurements: `cad measured`
|
|
345
|
+
|
|
346
|
+
A figure measured on a test print goes back where the estimate was: `cad measured <project>/<assembly>
|
|
347
|
+
x1c.hole_comp=0.15` writes it into the workspace's copy of the rule set as `measured`, with the date and `--source`,
|
|
348
|
+
runs the assembly's checks before and after, and says what moved: each prediction with its figure before and after,
|
|
349
|
+
and each other finding whose words changed (the lid's hole measures 3.5 mm, now 3.55 mm). A finding is paired with
|
|
350
|
+
itself by its code and what it is about (the fasten, the fit's two parts, the join, the beam), so a fasten whose
|
|
351
|
+
screws come out in another order is still matched. A check's prediction is measured the same way (`c1.drop=0.4`,
|
|
352
|
+
`task.accuracy=0.8`). Each figure goes into the project's ledger, `projects/<project>/ledger.jsonl`, against what was
|
|
353
|
+
predicted; `cad history <project>/<assembly>` shows it.
|
|
354
|
+
|
|
355
|
+
A slip of the pen is refused before anything is written: an empty figure (`x1c.fit=`), a figure of the other sign
|
|
356
|
+
from the one it replaces, and one under half or over twice it (a tenth to ten times, for an estimate, which is a
|
|
357
|
+
guess the measurement is there to correct). A 0 goes in as typed for a figure a coupon in the kit measures, since
|
|
358
|
+
the coupons step either side of the kit's figure and some start at 0 (the fixings coupon's nut slots). A figure that
|
|
359
|
+
really is that far out goes in with `--force`. A figure
|
|
360
|
+
the coupon bounds by what a fit of its kind can be is held to that instead, and a drop or a sag is checked as it is
|
|
361
|
+
read.
|
|
362
|
+
|
|
363
|
+
A row written by mistake comes out of the ledger with `--strike <date> <name>` (`<name>=<figure>` where the ledger
|
|
364
|
+
has that name twice that day). The ledger and the rule set are separate files, so it says what the rule set still
|
|
365
|
+
holds: set that back yourself (`git checkout rules/x1c.json`, or `cad measured` with the right figure).
|
|
366
|
+
|
|
367
|
+
**Coupons.** The kit's test prints come into your workspace with `cad coupons`: it adds `projects/coupons`, with the
|
|
368
|
+
fixings coupon (pilots, insert holes, nut pockets and slots, printed threads), the holds coupon (snap pin sockets,
|
|
369
|
+
pins pressed and slipping, magnet pockets) and the slot coupon (tongues, carriers and printed slots for aluminium
|
|
370
|
+
beams), each with its figure beside every feature, and a `MEASURE.md` that says how to read each row and the command
|
|
371
|
+
that writes it back. A workspace that has the project already keeps it as it is. A coupon's figure needs no assembly:
|
|
372
|
+
`cad measured x1c.pilot_m3=2.9` writes it the same way, keeps its row in the workspace's own ledger, `ledger.jsonl`
|
|
373
|
+
(`cad history` alone shows it, `--strike` takes a row out), and has no checks to run either side; give an assembly
|
|
374
|
+
first to see what it moves there. The source written names the coupon's `MEASURE.md` in your workspace
|
|
375
|
+
(`projects/coupons/MEASURE.md`).
|
|
376
|
+
|
|
377
|
+
**Sending figures to the kit.** `cad measured --export` prints every figure measured in this workspace that the kit
|
|
378
|
+
does not hold yet (or holds as anything but a measurement checked that day or since) as a unified diff of the kit's
|
|
379
|
+
rule sets, `packages/rules/<set>.json`, the rest of each file as the kit has it: `npx cad measured --export >
|
|
380
|
+
measured.diff`, then send it with the printer and plastic to the kit's issues, or apply it to a copy of the repository
|
|
381
|
+
for a pull request. A set the kit has no file for (the joins set, a part of your own) is listed apart, on stderr, to
|
|
382
|
+
send as it is. `--json` gives the same as data.
|
|
383
|
+
|
|
384
|
+
`--table` lists what the assembly still assumes: every rule it reads that is an estimate, a community figure or a
|
|
385
|
+
default, with its figure, the coupon in the kit that measures it (marked where this assembly is that coupon), and how
|
|
386
|
+
to settle it; the figures a coupon in it measures that the rule set has no figure for yet; and each prediction its
|
|
387
|
+
checks make. `--json` gives the same rows as data, and `--out MEASURE.md` keeps the table in that file.
|
|
388
|
+
|
|
389
|
+
```sh
|
|
390
|
+
npx cad measured home/lidded-box --table # what to measure
|
|
391
|
+
npx cad measured home/lidded-box x1c.hole_comp=0.15 --source "fit bar, row 1"
|
|
392
|
+
npx cad measured home/lidded-box x1c.fit=0.5 --force # more than twice the 0.2 it replaces, and right
|
|
393
|
+
npx cad measured home/lidded-box --strike 2026-12-01 x1c.fit
|
|
394
|
+
npx cad coupons # the coupons, in projects/coupons, with MEASURE.md
|
|
395
|
+
npx cad measured x1c.pilot_m3=2.9 # a coupon's figure, with no assembly
|
|
396
|
+
npx cad measured --export > measured.diff # what you measured, to send to the kit
|
|
397
|
+
```
|
|
398
|
+
|
|
286
399
|
## Parts
|
|
287
400
|
|
|
288
401
|
`main()` can return named parts instead of one shape, described in the .json:
|
|
@@ -392,25 +505,44 @@ other items' variables, so a keycap can sit exactly where its slot meets the swi
|
|
|
392
505
|
`/explain`, `/schema`, `/errors`, `/optimise`, `/rules`, `/workspace`, `/versions`, `/layout`, `/preview`, `/targets`, `/threemf`.
|
|
393
506
|
- **Engines:** designs get `v.ops` (union, subtract, intersect): JSCAD's booleans by default, Manifold's (faster,
|
|
394
507
|
watertight; `npm install manifold-3d`) with `"engine": "manifold"` in the object's JSON or `CAD_ENGINE=manifold`.
|
|
395
|
-
- **Sandbox:** a
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
`
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
508
|
+
- **Sandbox:** a design (a board design's too) runs in a separate Node process under Node's permission model, with
|
|
509
|
+
none of your environment (no tokens), and an import hook on top to keep it to making shapes. What it can do there
|
|
510
|
+
depends on the Node it runs on:
|
|
511
|
+
|
|
512
|
+
| A design … | Node 22.13 to 22.14 | Node 22.15 to 24 | From Node 25 | What holds it |
|
|
513
|
+
|---|---|---|---|---|
|
|
514
|
+
| writes or deletes files | never | never | never | Node's permission model (no `--allow-fs-write`) |
|
|
515
|
+
| starts programs or loads addons | never | never | never | the permission model (no `--allow-child-process` or `--allow-addons`) |
|
|
516
|
+
| starts threads | never | never | never | the permission model (`--allow-worker` only where the hook needs one), and the runner, which shuts Node's modules to the design |
|
|
517
|
+
| reads files | only its project's files and the packages below, by importing them | the same | the same | the import hook, and below it the permission model, which holds a design that finds a way round the hook (through an allowed package's own CommonJS code, say) to the same folders: of the workspace only the design's own project, its `package.json` and the design's own cache folders (never another project; and since the permission model follows a link wherever it leads, a link anywhere in the project, its `node_modules` too, that leads to another project or out of the workspace stops the design before it runs, and a cache folder that holds a link is not read), and the tool, the `node_modules` folders above them and the packages designs use |
|
|
518
|
+
| imports | the packages below and its project's files: never Node's own modules, and never a CommonJS file (`.cjs`, or `require` and `module.exports`) | the same | the same | the import hook, and the runner, which shuts Node's own modules to the CommonJS loader before the design loads; those that reach the network, other programs or workers (`net`, `http`, `dns`, `child_process`, `worker_threads`, `vm` and the rest) load for no one at all, the tool's own code included |
|
|
519
|
+
| sends over the network | no way the tests know of | the same | never | from Node 25 the permission model (no `--allow-net`); before it, rulecad's runner alone (`fetch` and its kin are gone, none of Node's modules that reach the network loads, whoever asks, and the design's standard streams are plain ones with no socket behind them) |
|
|
520
|
+
|
|
521
|
+
The packages a design may import are <!-- ALLOWED -->`@jscad/modeling`, `@rulecad/shapes`, `@rulecad/flexures`,
|
|
522
|
+
`@rulecad/gears`, `@rulecad/motors`, `@rulecad/frames`, `@rulecad/fixings`<!-- /ALLOWED --> (the hook's own list,
|
|
523
|
+
`ALLOWED` in `lib/sandbox-hooks.mjs`), and no `node:` modules by `import` or `require()`. A design and its project's
|
|
524
|
+
files are ES modules (`import` and `export`): a CommonJS file of the project is refused before it runs, with
|
|
525
|
+
`designs can't load …: it is a CommonJS file`, as one could reach Node's own modules past the hook. Before Node 25
|
|
526
|
+
what keeps a design off the network is rulecad's own runner, in the design's own process, not Node: cad says so once
|
|
527
|
+
a run, `designs are kept off the network on Node 24 by rulecad alone, not by Node itself: use Node 25 or above for
|
|
528
|
+
designs you did not write`. Run only designs you trust, as with any code; from Node 25 Node itself holds the
|
|
529
|
+
writing, programs and network rows. (`test/sandbox-docs.test.mjs`, `test/sandbox-loader.test.mjs` and
|
|
530
|
+
`test/sandbox.test.mjs` try the writing, reading, importing, programs and network rows, and the ways round them, on
|
|
531
|
+
the Node they run on; the other rows rest on the Node flags they name.)
|
|
532
|
+
It reads by real paths: a `node_modules` link spelled through another link, as macOS spells its temporary folders
|
|
533
|
+
through `/tmp` and `/var`, is refused by name (make the link with the real path). A link inside the workspace that
|
|
534
|
+
leads out of it (a design's file, a folder of its project or a rule set in `rules/` that is a link to a file
|
|
535
|
+
elsewhere, which a workspace cloned from someone else can hold) is refused before the design runs, and whenever
|
|
536
|
+
rulecad reads one of the workspace's own files, with `workspace.outside` and the link's name, so no file of yours
|
|
537
|
+
elsewhere is read into a build or a model link; a kept result in `.cache/` that is such a link is not read but made
|
|
538
|
+
afresh. To share a file between workspaces, copy it into each, or put it in a package and install that (the
|
|
539
|
+
workspace's own `node_modules` is the packages', and may link anywhere). A target named in cad.config.json is held
|
|
540
|
+
to the same, by its real path. An import of a package must lead inside that package: a file of it is named by its
|
|
541
|
+
path there (`@jscad/modeling/src/primitives/index.js`), never with `..`, `.`, `node_modules`, a backslash, `%` or
|
|
542
|
+
`~`, and the file it finds must be the package's own, as rulecad finds it, or one in the project, so no path or link
|
|
543
|
+
climbs out of it to another file. A file of such a package may in turn import only what that package depends on (its
|
|
544
|
+
own tests' tools are refused).
|
|
545
|
+
It gets its values as data and returns its parts; what it prints
|
|
414
546
|
(`console.log`) comes out on stderr. What comes back is checked before it is used, since the design could have
|
|
415
547
|
written it itself: a reply that is not one rulecad makes stops the build with a `design.sandbox` message, and the
|
|
416
548
|
only files written from a reply are the cache's slow stages, each in the design's own folder of `.cache/stages/`,
|
|
@@ -446,7 +578,8 @@ other items' variables, so a keycap can sit exactly where its slot meets the swi
|
|
|
446
578
|
only its own designs in the tool's process: one from another folder (a path to it, or a link out) is refused. A
|
|
447
579
|
workspace held in memory (`memoryHost`, for tests and later a browser or an editor's server) runs its designs in the
|
|
448
580
|
same sandbox, through the host's `runDesign` (a copy of the design's project in a temporary folder, removed after),
|
|
449
|
-
and in the tool's own process only when `build` is called with `{ trusted: true }`.
|
|
581
|
+
and in the tool's own process only when `build` is called with `{ trusted: true }`. (`test/sandbox.test.mjs`,
|
|
582
|
+
`test/target-trust.test.mjs`, `test/board-trust.test.mjs` and `test/sandbox-limits.test.mjs` try each of these.)
|
|
450
583
|
- **Mistakes are named:** a design that reads a variable that isn't there (`v.widht`) stops with the name it
|
|
451
584
|
probably meant, not a shape drawn from `undefined`; errors in a design carry its file and line.
|
|
452
585
|
- **Units:** `cad check` warns where an expression mixes units (millimetres added to degrees, a sine of a length) or
|
|
@@ -588,10 +721,11 @@ draws its hole or pocket from the printer's rules:
|
|
|
588
721
|
|
|
589
722
|
`cad list` lists pins (printed, cut or bought) and magnets (bought) with their grams, and printed bolts among the
|
|
590
723
|
printed parts; `cad order` names each on its step. A fastener given as text (`"fastener": "push pin"`) is listed as
|
|
591
|
-
written, unchecked. The fits these rest on (`x1c.
|
|
592
|
-
`
|
|
593
|
-
|
|
594
|
-
|
|
724
|
+
written, unchecked. The fits these rest on (`x1c.pin_press`, `pin_slip`, `magnet_press`, `magnet_glue`,
|
|
725
|
+
`magnet_crush`, and a plastic's `strength_z`) are estimates until the holds coupon measures them (`x1c.snap_clearance`
|
|
726
|
+
is measured, on the launcher's fit test plate, and the coupon measures it again for your printer):
|
|
727
|
+
`cad coupons` adds it to your workspace with its `MEASURE.md` (rows 40 to 47), and `cad measured
|
|
728
|
+
x1c.pin_press=<figure>` writes the result back, refusing a figure no fit of its kind can be.
|
|
595
729
|
|
|
596
730
|
### Joints and poses
|
|
597
731
|
|
|
@@ -1188,12 +1322,14 @@ screws, the cut list, the frame checks, the build page) sees a hand-drawn frame.
|
|
|
1188
1322
|
joint `gantry`, with the poses `gantry-front` and `gantry-back`) or `shelf` (a box with `"shelves"` rings between,
|
|
1189
1323
|
default 1, spacing its height into equal clear bays). Beams across x are `x1`, `x2` .., along y `y1` .., by ring
|
|
1190
1324
|
from the bottom. The frame's outside starts at the origin.
|
|
1191
|
-
- `"inside"` is the clear volume it encloses, `[width, depth, height]` in mm; `"outside"` is the volume
|
|
1192
|
-
in
|
|
1325
|
+
- `"inside"` is the clear volume it encloses, `[width, depth, height]` in mm; `"outside"` is the volume the whole
|
|
1326
|
+
frame must fit in, its feet and end caps with it, so its beams come out smaller by what those add (refused on castor
|
|
1327
|
+
plates, whose castor is not drawn). Give one, as numbers. A portal takes `[width, height]`. `cad frame` says the
|
|
1328
|
+
whole frame's size, its feet and caps fitted, beside the beams'. A table's height is the clear height under its ring, a gantry's
|
|
1193
1329
|
under its side beams.
|
|
1194
1330
|
- `"profile"`: one square profile for every beam (2020, 3030, 4040 ..). A profile of two cells (2040) is refused:
|
|
1195
1331
|
its beams would face differently by how they lie.
|
|
1196
|
-
- `"join"` sets the corners, as a kind or `{ "kind", "fitting", "screw", "nut" }`. With a join against a face (`blind`,
|
|
1332
|
+
- `"join"` sets the corners, as a kind or `{ "kind", "fitting", "screw", "nut", "estimate" }`. With a join against a face (`blind`,
|
|
1197
1333
|
`end-tap`, `bracket`, `gusset`, `hidden`, `anchor`) the upright beams run through, top to bottom, and every other
|
|
1198
1334
|
beam butts against their faces, so it is shorter than the outside span it closes by the profile's width at each
|
|
1199
1335
|
end. With `cube` every beam butts into a corner node and is as long as the inside it bounds. A box round 300 x 300
|
|
@@ -1205,8 +1341,12 @@ screws, the cut list, the frame checks, the build page) sees a hand-drawn frame.
|
|
|
1205
1341
|
takes the first of `drop-in`, `roll-in`, `hammer` and `t-bolt` the kit has for the profile's slot (drop-in on
|
|
1206
1342
|
MISUMI's 2020, roll-in on item's 4040); `"nut"` names one of them, and `slide-in` is refused. A printed gusset lies
|
|
1207
1343
|
on the face of its upright that looks out of the frame (its join's `"face"`), so it never lands where the corner's
|
|
1208
|
-
third beam butts.
|
|
1209
|
-
|
|
1344
|
+
third beam butts. A join the kit cannot build is refused by name, saying what is missing: `cube` (its three-way
|
|
1345
|
+
corner comes with a later release), and `bracket`, `gusset`, `hidden` or `anchor` with no fitting (a printed one,
|
|
1346
|
+
or a bought set by name). `"estimate": true` (`cad new ... --estimate`) makes it all the same, each join warning
|
|
1347
|
+
`join.fitting` that no fitting is drawn, as a hand-drawn join does. A join that holds by slots is refused on a
|
|
1348
|
+
profile with none (a tube, a bar, an angle), and a blind or end-tap join on an inside too narrow for the taps at
|
|
1349
|
+
both ends of its butting beams (37 mm in 2020).
|
|
1210
1350
|
- A gantry's outside height is its inside plus three widths: the two rings and `g`, which lies on the top side beams
|
|
1211
1351
|
between the uprights' tops, its top level with theirs.
|
|
1212
1352
|
- `"feet"`: `foot`, `levelling` or `stacking` (printed), a bought foot's set by name, or a printed castor plate,
|
|
@@ -1359,7 +1499,14 @@ limit: it is a bay's to brace, not a beam's to thicken.
|
|
|
1359
1499
|
|
|
1360
1500
|
Once an assembly is checked, these say how to make it. They all read the assembly itself, so they can't disagree with it.
|
|
1361
1501
|
|
|
1362
|
-
- `cad
|
|
1502
|
+
- `cad list <project>/<assembly>`: what to buy (bought parts, fixings, wire, the cut list) and what to print, each
|
|
1503
|
+
printed part's grams and an estimate of its minutes from its volume and the printer's `print_flow`: the printer the
|
|
1504
|
+
project names (`project.json`'s `printer`, else `cad.config.json`'s), as `cad check` reads it. The total says whose
|
|
1505
|
+
flow it used, and says so where it assumed one (a printer whose rule set gives no `print_flow`: 12 mm³/s) or the
|
|
1506
|
+
material's density (a material with no rule set: PLA's 1.25 g/cm³). `--json` gives the same as `totals.printer`,
|
|
1507
|
+
`totals.flow`, `flowAssumed` and `densityAssumed`.
|
|
1508
|
+
|
|
1509
|
+
- `cad order <project>/<assembly>`: the order it goes together in, each step with the part and what fastens it. A `fasten` names its screws on the step where its parts are both there, with the key that turns them and how tight: its `torque`, or half what the seat under the head takes, held for a screw in a thread in plastic to half what the thread is estimated to strip at (`2. bracket goes on: bracket fastened to base (2 × M3x10 cap) with a 2.5 mm hex key, to 0.12 N m at most (half what the seat takes)`); `--json` gives each as `{ fit, fastener, count, key, tighten: { torque, given } }` (with `thread: true` where the thread sets the torque, `load: true` where the joint's load does), and the build page shows the same. What is not a screw (pins, a clip) is named on a fit that fastens: `"fastener": "push pin", "count": 2` puts it on the shopping list and the step. `--preview` writes a picture of each step to `.preview/`: what's there, and the new part held off along the way it goes on. The order is found by taking the assembly apart, so a part goes in after what it's fastened into, a bearing before its shaft, and a nut trapped by a wall before the neighbour that traps it. A part goes on along a straight line that clears everything already there; which line comes from the part as drawn.
|
|
1363
1510
|
- `cad order` on a **frame** (an assembly with `joins`) gives its build from bars to a square frame, in numbered steps:
|
|
1364
1511
|
1. **Cut** the beams: each mark's count and length, the bars to buy and the cuts on each (the cut list).
|
|
1365
1512
|
2. **Drill and tap** each mark as its cut-and-drill sheet shows (each mark's work and its sheet's file).
|
|
@@ -1489,7 +1636,7 @@ slotted face, its holes read from its own rule set (@rulecad/frames' README, Ser
|
|
|
1489
1636
|
printed carrier strip in the slot under the rail instead: a `nut-carrier` fitting item `<id>-nuts`, one hex nut
|
|
1490
1637
|
under each hole, slid in from the beam's end. The rail's screws go into its nuts as a fasten, and `cad list` counts
|
|
1491
1638
|
the strip with its grams and each nut once. An MGN7 cut to 200 mm on a 2020 takes a 189 mm strip of 9.3 g of PLA,
|
|
1492
|
-
thirteen M2x8 cap screws and thirteen M2 hex nuts; each nut holds about
|
|
1639
|
+
thirteen M2x8 cap screws and thirteen M2 hex nuts; each nut holds about 905 N straight out of the slot (an estimate
|
|
1493
1640
|
until tested). Where no carrier fits the slot either, `guide.fit` fails and says why.
|
|
1494
1641
|
- Each carriage (`"carriages"`, 1 by default) is a bought item `<id>-carriage-1`, ... on its own sliding joint
|
|
1495
1642
|
`<id>-1`, ... along the beam, from 0 to its travel: its share of the rail less its length with its seals. The
|
|
@@ -1923,8 +2070,13 @@ placed parts in `.cache/overlaps.json`, keyed by each part's build and placement
|
|
|
1923
2070
|
about 10 s, and a re-check after an edit measures only what the edit moved. The build cache keeps its 800 most
|
|
1924
2071
|
recently used builds, keyed by what a build is made from: the design's code, its values resolved, its parts' names
|
|
1925
2072
|
and roles, the rule sets and the tool's own code; a rule's words, a label or the version change nothing it builds,
|
|
1926
|
-
so they don't start one.
|
|
1927
|
-
|
|
2073
|
+
so they don't start one. The files of its project a design imports (the starter lid's `./box.js`, and whatever those
|
|
2074
|
+
import) are part of what it is made from: a kept build lists them, and is used only while each reads as it did, so an
|
|
2075
|
+
edit to a shared helper rebuilds every design that imports it. (A package a design imports, such as
|
|
2076
|
+
`@jscad/modeling`, is not followed that way: it changes with an install, and the tool's own packages are in the key.)
|
|
2077
|
+
A lamina mechanism's slow stages (its physics, a flooded frame's probe) are kept apart in
|
|
2078
|
+
a folder of each design's own in `.cache/stages/`, keyed by their own inputs and by what works them out (the code of
|
|
2079
|
+
`@rulecad/flexures` and the packages it calls, and the installed manifold-3d and `@jscad/modeling`), so a build that changes only what comes after them (a strap, a check)
|
|
1928
2080
|
takes minutes rather than the twenty a launcher's physics takes; the design's sandbox reads them and hands back what
|
|
1929
2081
|
it made for the tool to write. `CAD_NO_CACHE=1` computes everything afresh (and keeps it).
|
|
1930
2082
|
|