@mylasertools/kerfscript 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/CHANGELOG.md +88 -0
- package/LANGUAGE.md +13 -5
- package/README.md +2 -1
- package/dist/assembly.d.cts +2 -0
- package/dist/assembly.d.ts +2 -0
- package/dist/bores.d.cts +10 -0
- package/dist/bores.d.ts +10 -0
- package/dist/cli.js +7899 -6630
- package/dist/customizer.d.cts +3 -0
- package/dist/customizer.d.ts +3 -0
- package/dist/effects.d.cts +31 -0
- package/dist/effects.d.ts +31 -0
- package/dist/evaluator.d.cts +1 -0
- package/dist/evaluator.d.ts +1 -0
- package/dist/export/mesh.d.cts +53 -0
- package/dist/export/mesh.d.ts +53 -0
- package/dist/export/model.d.cts +12 -0
- package/dist/export/model.d.ts +12 -0
- package/dist/export/triangulate.d.cts +5 -0
- package/dist/export/triangulate.d.ts +5 -0
- package/dist/export/zip.d.cts +5 -0
- package/dist/export/zip.d.ts +5 -0
- package/dist/geometry.d.cts +1 -0
- package/dist/geometry.d.ts +1 -0
- package/dist/highlight.cjs +2 -2
- package/dist/highlight.js +2 -2
- package/dist/import/dbg.d.cts +1 -0
- package/dist/import/dbg.d.ts +1 -0
- package/dist/index.cjs +435 -48
- package/dist/index.d.cts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +435 -48
- package/dist/language.cjs +410 -30
- package/dist/language.js +410 -30
- package/dist/libraries.cjs +393 -14
- package/dist/libraries.js +393 -14
- package/dist/render.d.cts +3 -0
- package/dist/render.d.ts +3 -0
- package/dist/signatures.cjs +23 -5
- package/dist/signatures.js +23 -5
- package/dist/text.d.cts +6 -0
- package/dist/text.d.ts +6 -0
- package/docs/3d-files.md +72 -0
- package/docs/cli.md +27 -22
- package/docs/customizer.md +56 -0
- package/docs/javascript.md +46 -0
- package/docs/library.md +120 -0
- package/docs/openscad.md +15 -13
- package/docs/parts-and-sheets.md +2 -1
- package/docs/versions.md +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,93 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.10.0 (2026-11-16)
|
|
4
|
+
|
|
5
|
+
Language version 0.3, as in 0.9.0: programs run as before, except that
|
|
6
|
+
`color()` and `linear_extrude()` now warn instead of stopping.
|
|
7
|
+
|
|
8
|
+
Changes to the output of existing programs, each a fix (see Fixes below):
|
|
9
|
+
|
|
10
|
+
- Slots for parts that pass through at an angle are cut to what passes
|
|
11
|
+
through the sheet, so they can be narrower than before; check the fit of
|
|
12
|
+
angled tabs, tapered ones especially.
|
|
13
|
+
- `intersection()` with a part as its first child clips the part instead of
|
|
14
|
+
emptying it.
|
|
15
|
+
- A default such as `w = $thickness` takes the `$thickness` passed with the
|
|
16
|
+
call.
|
|
17
|
+
- Parts riding a bent part, and mirrored copies of bent parts, are placed,
|
|
18
|
+
slotted and bored where they end up.
|
|
19
|
+
- SVG import reads units on shapes and keeps a viewBox's proportions.
|
|
20
|
+
|
|
21
|
+
Language:
|
|
22
|
+
|
|
23
|
+
- `text(fit = [w, h])` keeps text no wider than `w` and its capitals no
|
|
24
|
+
taller than `h`; `valign = "cap"` centres the capitals on y = 0.
|
|
25
|
+
- `text_size()` gives a text's measurements as a record: `width`, `height`,
|
|
26
|
+
`bounds`, `cap`, `ascent`, `descent` and the `size` used.
|
|
27
|
+
- `ellipse(d = [w, h])` takes the width and height, as `circle(d)` does.
|
|
28
|
+
- `color()` and `linear_extrude()` run as their children with a warning, so
|
|
29
|
+
the 2D part of an OpenSCAD file runs unchanged.
|
|
30
|
+
- Recursion and step-limit errors say what to check, instead of assuming an
|
|
31
|
+
endless loop.
|
|
32
|
+
- `use <...>` takes a Windows path, as `use <C:\Designs\lib\feet>`, and
|
|
33
|
+
paths with spaces; a library named that way finds the libraries beside it.
|
|
34
|
+
|
|
35
|
+
Fixes:
|
|
36
|
+
|
|
37
|
+
- `intersection()` clips a part that is its first child to the other
|
|
38
|
+
children, and warns when it leaves a part nothing to cut.
|
|
39
|
+
- A module's or function's defaults see the special variables passed with
|
|
40
|
+
the call: `w = $thickness` called with `$thickness = 6` is 6.
|
|
41
|
+
- Slots for parts at an angle cut only what passes through the sheet: a
|
|
42
|
+
tapered tab no longer cuts its wider part into the slot.
|
|
43
|
+
- Parts riding a bent part (`on = "host"`) have their slots, bores and
|
|
44
|
+
halvings cut where they ride.
|
|
45
|
+
- `sort()` counts its comparisons against the step limit.
|
|
46
|
+
- A mirrored copy of a bent part bends as its mirror image, and the copies
|
|
47
|
+
of a mirrored rider each ride their own host.
|
|
48
|
+
- Children that define a layer are evaluated each time they are used.
|
|
49
|
+
- Shaft capture fails when a part on the shaft can slide off over a bearing
|
|
50
|
+
and its retainer.
|
|
51
|
+
- SVG import: lengths on shapes keep their units (`width="40mm"`), and a
|
|
52
|
+
viewBox keeps its proportions as `preserveAspectRatio` says, centred by
|
|
53
|
+
default.
|
|
54
|
+
|
|
55
|
+
3D files:
|
|
56
|
+
|
|
57
|
+
- `kerf render model.kerf -o model.glb` writes the model in 3D: `.glb` to view
|
|
58
|
+
or render, `.3mf` to 3D print in colour, `.stl` as one mesh. Each part is a
|
|
59
|
+
closed solid as thick as its sheet, where the assembly puts it, bent on its
|
|
60
|
+
living hinges; engraving and scoring are thin coloured bodies on its faces,
|
|
61
|
+
and hardware rods and balls. `--flat` lays the parts side by side, front
|
|
62
|
+
face up, for printing; `--mark-height` sets how far the marks stand off,
|
|
63
|
+
and `--print` is `--flat` with the marks 0.6 mm high.
|
|
64
|
+
- In JavaScript, `toModel(result, "glb" | "3mf" | "stl", options)`, with
|
|
65
|
+
`meshBodies()` for the solid bodies and `result.flat` for every part flat.
|
|
66
|
+
|
|
67
|
+
Libraries:
|
|
68
|
+
|
|
69
|
+
- `kerf/shapes`: `heart`, `teardrop`, `egg`, `lens`, `crescent`, `capsule`,
|
|
70
|
+
`diamond`, `rounded_polygon`, `shield`, `arrow`, `chevron`, `banner`,
|
|
71
|
+
`house`, `tag`, `ring`, `scalloped`, `flower`, `cloud` and
|
|
72
|
+
`speech_bubble`, each sized to a box and centred; shapes with one outline
|
|
73
|
+
also give it as points, `heart_points()` and the like.
|
|
74
|
+
- `kerf/stand`: `stand()` stands a sign or a photo in a base, upright or
|
|
75
|
+
leaning back, with `stand_tabs()` and `stand_slots()` for a base of your
|
|
76
|
+
own.
|
|
77
|
+
|
|
78
|
+
Customizer:
|
|
79
|
+
|
|
80
|
+
- `kerf check --settings` tries each setting across its range and says what
|
|
81
|
+
it changes: the files, only the assembled view, or nothing. It points out
|
|
82
|
+
where a slider stops changing anything and menu choices that give the same
|
|
83
|
+
result, and exits with 1 when a setting changes nothing or the program
|
|
84
|
+
stops at its values.
|
|
85
|
+
`settingEffects()` gives the same in JavaScript.
|
|
86
|
+
- A setting can end its comment with `when` and a condition on the other
|
|
87
|
+
settings, `// [0:0.05:0.5] when mount == "stand"`: the playground and the
|
|
88
|
+
desktop app show it only while the condition holds. `shown()` evaluates
|
|
89
|
+
it in JavaScript.
|
|
90
|
+
|
|
3
91
|
## 0.9.0 (2026-11-09)
|
|
4
92
|
|
|
5
93
|
Language version 0.3, as in 0.8.0: programs run as before.
|
package/LANGUAGE.md
CHANGED
|
@@ -368,13 +368,14 @@ export examples.
|
|
|
368
368
|
| ---------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
|
|
369
369
|
| `rect(size, center = false, r = 0)` | `size` is a number or `[w, h]`; `r` rounds the corners. `square` is an alias |
|
|
370
370
|
| `circle(r)` or `circle(d = ...)` | |
|
|
371
|
-
| `ellipse([rx, ry])`
|
|
371
|
+
| `ellipse([rx, ry])` or `ellipse(d = [w, h])` | radii, or the width and height |
|
|
372
372
|
| `regular_polygon(n, r)` | corner radius `r` |
|
|
373
373
|
| `star(n, r, inner)` | |
|
|
374
374
|
| `polygon(points, paths)` | even-odd fill, `paths` lists point indexes per outline |
|
|
375
375
|
| `path(d, fill = "evenodd", close = false)` | SVG path data; closed subpaths become shapes, open ones lines unless `close` |
|
|
376
|
-
| `text(text, size = 10, font, halign, valign, spacing = 1)` | `halign`: left, center, right; `valign`: baseline, top, center, bottom
|
|
376
|
+
| `text(text, size = 10, font, halign, valign, spacing = 1)` | `halign`: left, center, right; `valign`: baseline, top, center, bottom, or cap (capitals centred on y = 0) |
|
|
377
377
|
| `text(text, size, fit = width)` | no wider than `fit`: the size shrinks to fit, never above `size` if given |
|
|
378
|
+
| `text(text, size, fit = [w, h])` | no wider than `w`, capitals no taller than `h`; either may be `undef` |
|
|
378
379
|
| `text(text, size, weight = "bold")` | strokes thickened by 3.5% of the size, or by a number of mm (less than 0 thins) |
|
|
379
380
|
| `text(text, size, bridge = w)` | every island (an i's dot, an accent, a stencil's counter) joined to the rest by a strip `w` wide, for cut-out and stencil lettering |
|
|
380
381
|
| `line(from, to)` | a line, not an area |
|
|
@@ -581,11 +582,18 @@ related but different pattern.
|
|
|
581
582
|
|
|
582
583
|
`text_width(text, size, font)` returns the advance width, including glyph
|
|
583
584
|
spacing. `text_metrics(text, size, font)` returns
|
|
584
|
-
`[advance, [[x0, y0], [x1, y1]], ascent, descent]`.
|
|
585
|
+
`[advance, [[x0, y0], [x1, y1]], ascent, descent]`. `text_size(text, size,
|
|
586
|
+
font)` returns the same as a record, with the capital height and the size
|
|
587
|
+
used: `width`, `height`, `bounds`, `cap`, `ascent`, `descent` and `size`.
|
|
585
588
|
|
|
586
|
-
|
|
589
|
+
```kerf
|
|
590
|
+
m = text_size("Anna", fit = [80, 20]);
|
|
591
|
+
echo(m.size, m.cap); // the size that fits, and capitals 20 mm tall
|
|
592
|
+
```
|
|
593
|
+
|
|
594
|
+
With `fit` they measure the text at the size `text()` would fit it to.
|
|
587
595
|
|
|
588
|
-
|
|
596
|
+
All three require the font to be available to the renderer, just like `text()`.
|
|
589
597
|
|
|
590
598
|
### Joint dimensions
|
|
591
599
|
|
package/README.md
CHANGED
|
@@ -235,7 +235,8 @@ Errors are thrown as `KerfError` with `line` and `col`.
|
|
|
235
235
|
|
|
236
236
|
- [Getting started](docs/getting-started.md), then the guides on
|
|
237
237
|
[layers](docs/layers.md), [kerf](docs/kerf.md),
|
|
238
|
-
[parts and sheets](docs/parts-and-sheets.md), [
|
|
238
|
+
[parts and sheets](docs/parts-and-sheets.md), [3D files](docs/3d-files.md),
|
|
239
|
+
[settings](docs/customizer.md),
|
|
239
240
|
the [desktop app](docs/desktop.md), the [command line](docs/cli.md), the
|
|
240
241
|
[JavaScript API](docs/javascript.md),
|
|
241
242
|
[assembly verification](docs/verification.md),
|
package/dist/assembly.d.cts
CHANGED
|
@@ -39,6 +39,8 @@ export declare function translation(x: number, y: number, z: number): number[];
|
|
|
39
39
|
export declare const IDENTITY4: number[];
|
|
40
40
|
export declare function invert(m: number[]): number[];
|
|
41
41
|
export declare function sortedBends(bends: Bend[]): Bend[];
|
|
42
|
+
/** Where each bend lies along the part's own x, as [from, to] */
|
|
43
|
+
export declare function bendSpans(bends: Bend[]): [number, number][];
|
|
42
44
|
export declare function bendRuns(bends: Bend[], t: number): number[][];
|
|
43
45
|
export declare function bendPoint(bends: Bend[], t: number, p: Vec3): Vec3;
|
|
44
46
|
export declare function runOf(bends: Bend[], x: number): number;
|
package/dist/assembly.d.ts
CHANGED
|
@@ -39,6 +39,8 @@ export declare function translation(x: number, y: number, z: number): number[];
|
|
|
39
39
|
export declare const IDENTITY4: number[];
|
|
40
40
|
export declare function invert(m: number[]): number[];
|
|
41
41
|
export declare function sortedBends(bends: Bend[]): Bend[];
|
|
42
|
+
/** Where each bend lies along the part's own x, as [from, to] */
|
|
43
|
+
export declare function bendSpans(bends: Bend[]): [number, number][];
|
|
42
44
|
export declare function bendRuns(bends: Bend[], t: number): number[][];
|
|
43
45
|
export declare function bendPoint(bends: Bend[], t: number, p: Vec3): Vec3;
|
|
44
46
|
export declare function runOf(bends: Bend[], x: number): number;
|
package/dist/bores.d.cts
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import type { HardwareItem } from './evaluator.cjs';
|
|
2
2
|
import { type Poly } from './geometry.cjs';
|
|
3
3
|
import type { Solid } from './slots.cjs';
|
|
4
|
+
type Vec3 = [number, number, number];
|
|
4
5
|
export declare const FITS: Record<string, number>;
|
|
6
|
+
/** A rod's axes: along it, and across it, v towards `up` (a [w, h]
|
|
7
|
+
* section's h, a polygon's first corner) and u square to both (its w). The
|
|
8
|
+
* 3D files use the same, so a rod fits the bore cut for it. */
|
|
9
|
+
export declare function rodFrame(h: HardwareItem): {
|
|
10
|
+
axis: Vec3;
|
|
11
|
+
u: Vec3;
|
|
12
|
+
v: Vec3;
|
|
13
|
+
};
|
|
5
14
|
export declare function boreFor(target: Solid, h: HardwareItem, room: number): Poly | undefined;
|
|
15
|
+
export {};
|
package/dist/bores.d.ts
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import type { HardwareItem } from './evaluator.js';
|
|
2
2
|
import { type Poly } from './geometry.js';
|
|
3
3
|
import type { Solid } from './slots.js';
|
|
4
|
+
type Vec3 = [number, number, number];
|
|
4
5
|
export declare const FITS: Record<string, number>;
|
|
6
|
+
/** A rod's axes: along it, and across it, v towards `up` (a [w, h]
|
|
7
|
+
* section's h, a polygon's first corner) and u square to both (its w). The
|
|
8
|
+
* 3D files use the same, so a rod fits the bore cut for it. */
|
|
9
|
+
export declare function rodFrame(h: HardwareItem): {
|
|
10
|
+
axis: Vec3;
|
|
11
|
+
u: Vec3;
|
|
12
|
+
v: Vec3;
|
|
13
|
+
};
|
|
5
14
|
export declare function boreFor(target: Solid, h: HardwareItem, room: number): Poly | undefined;
|
|
15
|
+
export {};
|