@mylasertools/kerfscript 0.0.0-stage → 0.2.1
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 +60 -0
- package/CLA.md +76 -0
- package/COMMERCIAL-LICENSE.md +63 -0
- package/LANGUAGE.md +398 -0
- package/LICENSE +661 -0
- package/README.md +187 -2
- package/THIRD-PARTY-NOTICES.md +124 -0
- package/TRADEMARKS.md +45 -0
- package/dist/ast.d.cts +160 -0
- package/dist/ast.d.ts +160 -0
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +19416 -0
- package/dist/customizer.d.cts +19 -0
- package/dist/customizer.d.ts +19 -0
- package/dist/evaluator.d.cts +129 -0
- package/dist/evaluator.d.ts +129 -0
- package/dist/export/dxf.d.cts +3 -0
- package/dist/export/dxf.d.ts +3 -0
- package/dist/export/svg.d.cts +15 -0
- package/dist/export/svg.d.ts +15 -0
- package/dist/functions.d.cts +4 -0
- package/dist/functions.d.ts +4 -0
- package/dist/geometry.d.cts +44 -0
- package/dist/geometry.d.ts +44 -0
- package/dist/index.cjs +44 -0
- package/dist/index.d.cts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +44 -0
- package/dist/joinery.d.cts +7 -0
- package/dist/joinery.d.ts +7 -0
- package/dist/lexer.d.cts +28 -0
- package/dist/lexer.d.ts +28 -0
- package/dist/parser.d.cts +6 -0
- package/dist/parser.d.ts +6 -0
- package/dist/paths.d.cts +28 -0
- package/dist/paths.d.ts +28 -0
- package/dist/render.d.cts +58 -0
- package/dist/render.d.ts +58 -0
- package/dist/stdlib.d.cts +1 -0
- package/dist/stdlib.d.ts +1 -0
- package/dist/text.d.cts +36 -0
- package/dist/text.d.ts +36 -0
- package/dist/values.d.cts +25 -0
- package/dist/values.d.ts +25 -0
- package/docs/cli.md +76 -0
- package/docs/compatibility.md +64 -0
- package/docs/customizer.md +74 -0
- package/docs/getting-started.md +115 -0
- package/docs/javascript.md +153 -0
- package/docs/kerf.md +67 -0
- package/docs/layers.md +108 -0
- package/docs/openscad.md +71 -0
- package/docs/parts-and-sheets.md +82 -0
- package/docs/versions.md +33 -0
- package/package.json +86 -4
package/README.md
CHANGED
|
@@ -1,3 +1,188 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://kerfscript.mylasertools.com"><img src=".github/readme/banner.png" alt="KerfScript, a programming language for laser cutting" width="840"></a>
|
|
3
|
+
</p>
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
<p align="center">
|
|
6
|
+
<a href="https://www.npmjs.com/package/@mylasertools/kerfscript"><img src="https://img.shields.io/npm/v/@mylasertools/kerfscript?color=d8361f&label=npm" alt="npm version"></a>
|
|
7
|
+
<a href="COMMERCIAL-LICENSE.md"><img src="https://img.shields.io/badge/licence-AGPL--3.0%20or%20free%20commercial-1f1a17" alt="Licence: AGPL-3.0 or free commercial"></a>
|
|
8
|
+
<a href="LANGUAGE.md"><img src="https://img.shields.io/badge/language-0.1-e3c69a" alt="Language version 0.1"></a>
|
|
9
|
+
<a href="https://kerfscript.mylasertools.com/playground/"><img src="https://img.shields.io/badge/try%20it-playground-5a3519" alt="Try it in the playground"></a>
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
<p align="center">
|
|
13
|
+
<a href="https://kerfscript.mylasertools.com">Website</a> ·
|
|
14
|
+
<a href="https://kerfscript.mylasertools.com/playground/">Playground</a> ·
|
|
15
|
+
<a href="https://kerfscript.mylasertools.com/models/">Models</a> ·
|
|
16
|
+
<a href="https://kerfscript.mylasertools.com/docs/">Docs</a> ·
|
|
17
|
+
<a href="https://www.npmjs.com/package/@mylasertools/kerfscript">npm</a>
|
|
18
|
+
</p>
|
|
19
|
+
|
|
20
|
+
Write a part once as code, change a number, and get a new cut file. KerfScript
|
|
21
|
+
is to laser cutters what OpenSCAD is to 3D printers, except it was designed for
|
|
22
|
+
flat parts from the start: cut, score and engrave layers, kerf compensation,
|
|
23
|
+
finger joints, living hinges, parts and sheets are part of the language.
|
|
24
|
+
|
|
25
|
+
<p align="center">
|
|
26
|
+
<a href="https://kerfscript.mylasertools.com/playground/?model=fractal-tree"><img src=".github/readme/playground.gif" alt="Moving a slider in the playground changes the number in the code and redraws the fractal tree" width="840"></a>
|
|
27
|
+
<br><sub>The <a href="https://kerfscript.mylasertools.com/playground/">playground</a> runs the interpreter in your browser. A comment after a number turns it into a slider.</sub>
|
|
28
|
+
</p>
|
|
29
|
+
|
|
30
|
+
## Example
|
|
31
|
+
|
|
32
|
+
<table>
|
|
33
|
+
<tr>
|
|
34
|
+
<td width="50%" valign="top">
|
|
35
|
+
|
|
36
|
+
```kerf
|
|
37
|
+
use <kerf/box>
|
|
38
|
+
|
|
39
|
+
/* [Size] */
|
|
40
|
+
width = 120; // [40:5:400]
|
|
41
|
+
depth = 80; // [40:5:400]
|
|
42
|
+
height = 50; // [20:5:300]
|
|
43
|
+
lid = true;
|
|
44
|
+
|
|
45
|
+
/* [Material] */
|
|
46
|
+
$thickness = 3; // [1.5:0.5:10]
|
|
47
|
+
$kerf = 0.15; // [0:0.01:0.5]
|
|
48
|
+
|
|
49
|
+
box([width, depth, height], lid = lid);
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
</td>
|
|
53
|
+
<td width="50%" valign="top">
|
|
54
|
+
<img src=".github/readme/model-box.png" alt="Six finger-jointed panels of a box, packed on a sheet">
|
|
55
|
+
</td>
|
|
56
|
+
</tr>
|
|
57
|
+
</table>
|
|
58
|
+
|
|
59
|
+
```sh
|
|
60
|
+
npx @mylasertools/kerfscript render box.kerf -o box.svg -D width=200
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
That writes all six panels packed on a sheet, kerf compensated, as a
|
|
64
|
+
millimetre SVG with one layer per operation. Output is checked automatically
|
|
65
|
+
in Inkscape; see [docs/compatibility.md](docs/compatibility.md) for what has
|
|
66
|
+
and has not been tested in other laser software.
|
|
67
|
+
|
|
68
|
+
## Made with KerfScript
|
|
69
|
+
|
|
70
|
+
Every model is a file in [examples/](examples). Open one on the website to
|
|
71
|
+
turn it around in 3D, change its settings and download the SVG or DXF, or copy
|
|
72
|
+
it as the start of your own design.
|
|
73
|
+
|
|
74
|
+
<table>
|
|
75
|
+
<tr>
|
|
76
|
+
<td width="33%" valign="top"><a href="https://kerfscript.mylasertools.com/models/hadal/"><img src="site/public/3d/hadal.webp" alt="Hadal sculpture, assembled"></a><br><b><a href="https://kerfscript.mylasertools.com/models/hadal/">Hadal sculpture</a></b><br><sub>13 slotted parts, ribs computed from lists</sub></td>
|
|
77
|
+
<td width="33%" valign="top"><a href="https://kerfscript.mylasertools.com/models/tilt-maze/"><img src="site/public/3d/tilt-maze.webp" alt="Tilt maze, assembled"></a><br><b><a href="https://kerfscript.mylasertools.com/models/tilt-maze/">Tilt maze</a></b><br><sub>a new maze for every seed, by recursion</sub></td>
|
|
78
|
+
<td width="33%" valign="top"><a href="https://kerfscript.mylasertools.com/models/topo-island/"><img src="site/public/3d/topo-island.webp" alt="Layered island, assembled"></a><br><b><a href="https://kerfscript.mylasertools.com/models/topo-island/">Layered island</a></b><br><sub>contours traced from a height formula</sub></td>
|
|
79
|
+
</tr>
|
|
80
|
+
<tr>
|
|
81
|
+
<td width="33%" valign="top"><a href="https://kerfscript.mylasertools.com/models/fractal-tree/"><img src="site/public/3d/fractal-tree.webp" alt="Fractal tree, assembled"></a><br><b><a href="https://kerfscript.mylasertools.com/models/fractal-tree/">Fractal tree</a></b><br><sub>a module that calls itself</sub></td>
|
|
82
|
+
<td width="33%" valign="top"><a href="https://kerfscript.mylasertools.com/models/round-badge/"><img src="site/public/3d/round-badge.webp" alt="Round badge, assembled"></a><br><b><a href="https://kerfscript.mylasertools.com/models/round-badge/">Round badge</a></b><br><sub>text set letter by letter around a circle</sub></td>
|
|
83
|
+
<td width="33%" valign="top"><a href="https://kerfscript.mylasertools.com/models/winterlight/"><img src="site/public/3d/winterlight.webp" alt="Winterlight ornaments, assembled"></a><br><b><a href="https://kerfscript.mylasertools.com/models/winterlight/">Winterlight ornaments</a></b><br><sub>one-piece ornaments with scored detail</sub></td>
|
|
84
|
+
</tr>
|
|
85
|
+
<tr>
|
|
86
|
+
<td width="33%" valign="top"><a href="https://kerfscript.mylasertools.com/models/xenospora/"><img src="site/public/3d/xenospora.webp" alt="Xenospora seed pod, assembled"></a><br><b><a href="https://kerfscript.mylasertools.com/models/xenospora/">Xenospora seed pod</a></b><br><sub>16 parts on 3 sheets, one file per sheet</sub></td>
|
|
87
|
+
<td width="33%" valign="top"><a href="https://kerfscript.mylasertools.com/models/solstice/"><img src="site/public/3d/solstice.webp" alt="Solstice lantern, assembled"></a><br><b><a href="https://kerfscript.mylasertools.com/models/solstice/">Solstice lantern</a></b><br><sub>tabs, slots and a fit test piece</sub></td>
|
|
88
|
+
<td width="33%" valign="top"><a href="https://kerfscript.mylasertools.com/models/box/"><img src="site/public/3d/box.webp" alt="Finger-jointed box, assembled"></a><br><b><a href="https://kerfscript.mylasertools.com/models/box/">Finger-jointed box</a></b><br><sub>six panels from one library call</sub></td>
|
|
89
|
+
</tr>
|
|
90
|
+
<tr>
|
|
91
|
+
<td width="33%" valign="top"><a href="https://kerfscript.mylasertools.com/models/wave-cathedral/"><img src="site/public/3d/wave-cathedral.webp" alt="Wave Cathedral, assembled"></a><br><b><a href="https://kerfscript.mylasertools.com/models/wave-cathedral/">Wave Cathedral</a></b><br><sub>17 different ribs from one formula</sub></td>
|
|
92
|
+
<td width="33%" valign="top"><a href="https://kerfscript.mylasertools.com/models/gift-tags/"><img src="site/public/3d/gift-tags.webp" alt="Gift tags from a list, assembled"></a><br><b><a href="https://kerfscript.mylasertools.com/models/gift-tags/">Gift tags from a list</a></b><br><sub>one tag per name, each name fitted</sub></td>
|
|
93
|
+
<td width="33%" valign="top"><a href="https://kerfscript.mylasertools.com/models/umbra/"><img src="site/public/3d/umbra.webp" alt="Umbra shadow machine, assembled"></a><br><b><a href="https://kerfscript.mylasertools.com/models/umbra/">Umbra shadow machine</a></b><br><sub>six fins whose shadows make one dragon</sub></td>
|
|
94
|
+
</tr>
|
|
95
|
+
</table>
|
|
96
|
+
|
|
97
|
+
## Why a new language
|
|
98
|
+
|
|
99
|
+
- **Laser concepts are built in.** `engrave()`, `score()` and `cut()` put
|
|
100
|
+
geometry on machine layers. Engraving is clipped to the material, inner
|
|
101
|
+
cuts come before outer ones, and the whole part is offset by half the kerf.
|
|
102
|
+
- **Parts, not just shapes.** `part("lid", qty = 2)` names a piece; the
|
|
103
|
+
renderer packs parts by material and thickness onto sheets.
|
|
104
|
+
- **Joinery that fits.** `finger_rect`, `finger_holes`, `tslot` and
|
|
105
|
+
`living_hinge` use `$thickness`, so changing the material keeps joints
|
|
106
|
+
tight.
|
|
107
|
+
- **Familiar syntax.** If you know OpenSCAD, you can read KerfScript. The
|
|
108
|
+
customizer comments are the same, so editors that understand OpenSCAD
|
|
109
|
+
parameters understand KerfScript ones.
|
|
110
|
+
- **Runs anywhere.** Pure TypeScript with no native code: the same interpreter
|
|
111
|
+
runs in browsers, Node, workers and the command line.
|
|
112
|
+
- **Safe to run.** Programs read libraries only through the resolver you
|
|
113
|
+
provide. Step and recursion limits stop runaway programs, and errors name
|
|
114
|
+
the line.
|
|
115
|
+
|
|
116
|
+
## Install
|
|
117
|
+
|
|
118
|
+
```sh
|
|
119
|
+
npm install @mylasertools/kerfscript
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Command line
|
|
123
|
+
|
|
124
|
+
```sh
|
|
125
|
+
kerf render design.kerf -o design.svg # or .dxf / .json
|
|
126
|
+
kerf render design.kerf -D width=200 -D 'label="Oak"' --font Inter.ttf
|
|
127
|
+
kerf render design.kerf --sheet 400x300 --kerf 0.1 --split
|
|
128
|
+
kerf params design.kerf # customizer parameters as JSON
|
|
129
|
+
kerf check design.kerf # parts, sizes, cut length, warnings
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Library
|
|
133
|
+
|
|
134
|
+
```js
|
|
135
|
+
import { render, parameters } from '@mylasertools/kerfscript';
|
|
136
|
+
|
|
137
|
+
const result = render(source, {
|
|
138
|
+
params: { width: 200 },
|
|
139
|
+
fonts: { inter: await (await fetch('/Inter.ttf')).arrayBuffer() },
|
|
140
|
+
sheet: [600, 400],
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
result.svg; // all sheets in one SVG
|
|
144
|
+
result.sheets; // [{ width, height, material, thickness, svg, dxf, items }]
|
|
145
|
+
result.parts; // [{ name, qty, width, height, pieces, cutLength, thickness, kerf, material }]
|
|
146
|
+
result.warnings; // e.g. a part that falls apart, or one bigger than the sheet
|
|
147
|
+
result.echoes; // echo() output
|
|
148
|
+
|
|
149
|
+
parameters(source).parameters; // [{ name, caption, group, type, initial, min, max, step, options, span }]
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Errors are thrown as `KerfError` with `line` and `col`.
|
|
153
|
+
|
|
154
|
+
## Learn the language
|
|
155
|
+
|
|
156
|
+
- [Getting started](docs/getting-started.md), then the guides on
|
|
157
|
+
[layers](docs/layers.md), [kerf](docs/kerf.md),
|
|
158
|
+
[parts and sheets](docs/parts-and-sheets.md), [settings](docs/customizer.md),
|
|
159
|
+
the [command line](docs/cli.md) and the [JavaScript API](docs/javascript.md)
|
|
160
|
+
- [Coming from OpenSCAD](docs/openscad.md): what is the same and what is not
|
|
161
|
+
- [LANGUAGE.md](LANGUAGE.md): the full language reference
|
|
162
|
+
- [Versions](docs/versions.md): language and package versions, and what stays
|
|
163
|
+
stable before 1.0
|
|
164
|
+
- [examples/](examples): every model on the website, including a
|
|
165
|
+
calibration square and a kerf test
|
|
166
|
+
|
|
167
|
+
## Community
|
|
168
|
+
|
|
169
|
+
Bug reports, cut reports and ideas are welcome; see
|
|
170
|
+
[CONTRIBUTING.md](CONTRIBUTING.md), the [roadmap](ROADMAP.md),
|
|
171
|
+
[SECURITY.md](SECURITY.md) and the [code of conduct](CODE_OF_CONDUCT.md).
|
|
172
|
+
|
|
173
|
+
## Licence
|
|
174
|
+
|
|
175
|
+
Copyright (c) 2026 MyLaserTools.
|
|
176
|
+
|
|
177
|
+
KerfScript is free software under the
|
|
178
|
+
[GNU AGPL 3.0](LICENSE), with an [additional permission](COMMERCIAL-LICENSE.md#additional-permission-your-designs-are-yours)
|
|
179
|
+
that makes **your `.kerf` designs and the files KerfScript generates yours to
|
|
180
|
+
license and sell however you like**.
|
|
181
|
+
|
|
182
|
+
Building KerfScript into a closed-source app, machine or service? The
|
|
183
|
+
[commercial licence](COMMERCIAL-LICENSE.md#free-commercial-licence) is free:
|
|
184
|
+
just email hi@mylasertools.com.
|
|
185
|
+
|
|
186
|
+
"KerfScript" is a trademark of MyLaserTools; see [TRADEMARKS.md](TRADEMARKS.md).
|
|
187
|
+
Contributions need the [CLA](CLA.md); see [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
188
|
+
Bundled third-party code is listed in [THIRD-PARTY-NOTICES.md](THIRD-PARTY-NOTICES.md).
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
KerfScript bundles the following software in `dist/`. Their licences apply to
|
|
4
|
+
those parts only.
|
|
5
|
+
|
|
6
|
+
## Clipper2 / clipper2-ts 2.0.1-18 (bundled)
|
|
7
|
+
|
|
8
|
+
Original Clipper2: Copyright Angus Johnson 2010–2025.
|
|
9
|
+
TypeScript port by Jeremy Tribby (countertype).
|
|
10
|
+
Source: https://github.com/countertype/clipper2-ts
|
|
11
|
+
|
|
12
|
+
```text
|
|
13
|
+
Boost Software License - Version 1.0 - August 17th, 2003
|
|
14
|
+
|
|
15
|
+
Permission is hereby granted, free of charge, to any person or organization
|
|
16
|
+
obtaining a copy of the software and accompanying documentation covered by
|
|
17
|
+
this license (the "Software") to use, reproduce, display, distribute,
|
|
18
|
+
execute, and transmit the Software, and to prepare derivative works of the
|
|
19
|
+
Software, and to permit third-parties to whom the Software is furnished to
|
|
20
|
+
do so, all subject to the following:
|
|
21
|
+
|
|
22
|
+
The copyright notices in the Software and this entire statement, including
|
|
23
|
+
the above license grant, this restriction and the following disclaimer,
|
|
24
|
+
must be included in all copies of the Software, in whole or in part, and
|
|
25
|
+
all derivative works of the Software, unless such copies or derivative
|
|
26
|
+
works are solely in the form of machine-executable object code generated by
|
|
27
|
+
a source language processor.
|
|
28
|
+
|
|
29
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
30
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
31
|
+
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
|
32
|
+
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
|
33
|
+
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
|
34
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
35
|
+
DEALINGS IN THE SOFTWARE.
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## opentype.js 1.3.4 (bundled)
|
|
39
|
+
|
|
40
|
+
Source: https://github.com/opentypejs/opentype.js
|
|
41
|
+
|
|
42
|
+
```text
|
|
43
|
+
The MIT License (MIT)
|
|
44
|
+
|
|
45
|
+
Copyright (c) 2020 Frederik De Bleser
|
|
46
|
+
|
|
47
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
48
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
49
|
+
the Software without restriction, including without limitation the rights to
|
|
50
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
51
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
52
|
+
subject to the following conditions:
|
|
53
|
+
|
|
54
|
+
The above copyright notice and this permission notice shall be included in all
|
|
55
|
+
copies or substantial portions of the Software.
|
|
56
|
+
|
|
57
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
58
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
59
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
60
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
61
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
62
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## tiny-inflate 1.0.3 (bundled, part of opentype.js)
|
|
66
|
+
|
|
67
|
+
Source: https://github.com/foliojs/tiny-inflate
|
|
68
|
+
|
|
69
|
+
```text
|
|
70
|
+
MIT License
|
|
71
|
+
|
|
72
|
+
Copyright (c) 2015-present Devon Govett
|
|
73
|
+
|
|
74
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
75
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
76
|
+
in the Software without restriction, including without limitation the rights
|
|
77
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
78
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
79
|
+
furnished to do so, subject to the following conditions:
|
|
80
|
+
|
|
81
|
+
The above copyright notice and this permission notice shall be included in all
|
|
82
|
+
copies or substantial portions of the Software.
|
|
83
|
+
|
|
84
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
85
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
86
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
87
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
88
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
89
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
90
|
+
SOFTWARE.
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## string.prototype.codepointat 0.2.1 (bundled, part of opentype.js)
|
|
94
|
+
|
|
95
|
+
Source: https://github.com/mathiasbynens/String.prototype.codePointAt
|
|
96
|
+
|
|
97
|
+
```text
|
|
98
|
+
Copyright Mathias Bynens <https://mathiasbynens.be/>
|
|
99
|
+
|
|
100
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
101
|
+
a copy of this software and associated documentation files (the
|
|
102
|
+
"Software"), to deal in the Software without restriction, including
|
|
103
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
104
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
105
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
106
|
+
the following conditions:
|
|
107
|
+
|
|
108
|
+
The above copyright notice and this permission notice shall be
|
|
109
|
+
included in all copies or substantial portions of the Software.
|
|
110
|
+
|
|
111
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
112
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
113
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
114
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
115
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
116
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
117
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Atkinson Hyperlegible (test fixture only, not published to npm)
|
|
121
|
+
|
|
122
|
+
`test/fixtures/AtkinsonHyperlegible-Regular.ttf`, Copyright 2020 Braille
|
|
123
|
+
Institute of America, Inc., licensed under the SIL Open Font License 1.1. See
|
|
124
|
+
`test/fixtures/OFL.txt`.
|
package/TRADEMARKS.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Trademark policy
|
|
2
|
+
|
|
3
|
+
"KerfScript", the `.kerf` file format name used as a product name, and the
|
|
4
|
+
KerfScript logo are trademarks of MyLaserTools. The software licences
|
|
5
|
+
(AGPL-3.0-only and the free commercial licence) cover the code. They do not grant rights to the
|
|
6
|
+
name or logo.
|
|
7
|
+
|
|
8
|
+
This policy identifies the official KerfScript project while allowing others
|
|
9
|
+
to describe tools that work with the language. MyLaserTools controls the
|
|
10
|
+
official language versions and releases.
|
|
11
|
+
|
|
12
|
+
## You may, without asking
|
|
13
|
+
|
|
14
|
+
- say your design, tutorial, course, video or library is written **in**
|
|
15
|
+
KerfScript or works **with** KerfScript
|
|
16
|
+
- describe an independent editor, implementation or service as compatible
|
|
17
|
+
with a specific KerfScript language version when the claim is accurate,
|
|
18
|
+
its limitations are clear and you do not imply MyLaserTools endorsement
|
|
19
|
+
- use KerfScript in a descriptive phrase such as "an editor for KerfScript"
|
|
20
|
+
alongside your own distinct product name
|
|
21
|
+
- use the `.kerf` file extension for KerfScript programs
|
|
22
|
+
- use the name to refer to this project and to unmodified copies of it
|
|
23
|
+
- publish a fork for development, as long as it is clearly marked as a fork
|
|
24
|
+
and does not use the name or logo as its own product name
|
|
25
|
+
|
|
26
|
+
## You need written permission to
|
|
27
|
+
|
|
28
|
+
- name a product, service, company, domain or package "KerfScript" or anything
|
|
29
|
+
confusingly similar (for example "KerfScript Pro", "kerfscript-cloud")
|
|
30
|
+
- call your own implementation, editor or service "official" or imply
|
|
31
|
+
that MyLaserTools endorses it
|
|
32
|
+
- use the logo, other than to link to this project
|
|
33
|
+
- distribute a modified interpreter under the KerfScript name
|
|
34
|
+
|
|
35
|
+
## Language specification
|
|
36
|
+
|
|
37
|
+
The language reference ([LANGUAGE.md](LANGUAGE.md)) is published under
|
|
38
|
+
Creative Commons Attribution 4.0 (CC BY 4.0). You may copy, translate and
|
|
39
|
+
adapt it with attribution and a note describing your changes. Adapted
|
|
40
|
+
references are not official KerfScript language versions. MyLaserTools
|
|
41
|
+
publishes the official reference and decides which language changes it adopts.
|
|
42
|
+
|
|
43
|
+
## Contact
|
|
44
|
+
|
|
45
|
+
hi@mylasertools.com
|
package/dist/ast.d.cts
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import type { Pos } from './lexer.cjs';
|
|
2
|
+
export type Expr = {
|
|
3
|
+
kind: 'num';
|
|
4
|
+
value: number;
|
|
5
|
+
pos: Pos;
|
|
6
|
+
} | {
|
|
7
|
+
kind: 'str';
|
|
8
|
+
value: string;
|
|
9
|
+
pos: Pos;
|
|
10
|
+
} | {
|
|
11
|
+
kind: 'bool';
|
|
12
|
+
value: boolean;
|
|
13
|
+
pos: Pos;
|
|
14
|
+
} | {
|
|
15
|
+
kind: 'undef';
|
|
16
|
+
pos: Pos;
|
|
17
|
+
} | {
|
|
18
|
+
kind: 'var';
|
|
19
|
+
name: string;
|
|
20
|
+
pos: Pos;
|
|
21
|
+
} | {
|
|
22
|
+
kind: 'list';
|
|
23
|
+
items: ListItem[];
|
|
24
|
+
pos: Pos;
|
|
25
|
+
} | {
|
|
26
|
+
kind: 'range';
|
|
27
|
+
start: Expr;
|
|
28
|
+
step: Expr | null;
|
|
29
|
+
end: Expr;
|
|
30
|
+
pos: Pos;
|
|
31
|
+
} | {
|
|
32
|
+
kind: 'unary';
|
|
33
|
+
op: string;
|
|
34
|
+
arg: Expr;
|
|
35
|
+
pos: Pos;
|
|
36
|
+
} | {
|
|
37
|
+
kind: 'binary';
|
|
38
|
+
op: string;
|
|
39
|
+
left: Expr;
|
|
40
|
+
right: Expr;
|
|
41
|
+
pos: Pos;
|
|
42
|
+
} | {
|
|
43
|
+
kind: 'ternary';
|
|
44
|
+
cond: Expr;
|
|
45
|
+
then: Expr;
|
|
46
|
+
else: Expr;
|
|
47
|
+
pos: Pos;
|
|
48
|
+
} | {
|
|
49
|
+
kind: 'index';
|
|
50
|
+
target: Expr;
|
|
51
|
+
index: Expr;
|
|
52
|
+
pos: Pos;
|
|
53
|
+
} | {
|
|
54
|
+
kind: 'member';
|
|
55
|
+
target: Expr;
|
|
56
|
+
name: string;
|
|
57
|
+
pos: Pos;
|
|
58
|
+
} | {
|
|
59
|
+
kind: 'call';
|
|
60
|
+
callee: Expr;
|
|
61
|
+
args: Arg[];
|
|
62
|
+
pos: Pos;
|
|
63
|
+
} | {
|
|
64
|
+
kind: 'lambda';
|
|
65
|
+
params: Param[];
|
|
66
|
+
body: Expr;
|
|
67
|
+
pos: Pos;
|
|
68
|
+
} | {
|
|
69
|
+
kind: 'let';
|
|
70
|
+
assigns: Assign[];
|
|
71
|
+
body: Expr;
|
|
72
|
+
pos: Pos;
|
|
73
|
+
};
|
|
74
|
+
export type ListItem = {
|
|
75
|
+
kind: 'item';
|
|
76
|
+
expr: Expr;
|
|
77
|
+
} | {
|
|
78
|
+
kind: 'each';
|
|
79
|
+
expr: Expr;
|
|
80
|
+
} | {
|
|
81
|
+
kind: 'for';
|
|
82
|
+
assigns: Assign[];
|
|
83
|
+
body: ListItem;
|
|
84
|
+
} | {
|
|
85
|
+
kind: 'if';
|
|
86
|
+
cond: Expr;
|
|
87
|
+
then: ListItem;
|
|
88
|
+
else: ListItem | null;
|
|
89
|
+
} | {
|
|
90
|
+
kind: 'let';
|
|
91
|
+
assigns: Assign[];
|
|
92
|
+
body: ListItem;
|
|
93
|
+
};
|
|
94
|
+
export interface Arg {
|
|
95
|
+
name: string | null;
|
|
96
|
+
value: Expr;
|
|
97
|
+
}
|
|
98
|
+
export interface Param {
|
|
99
|
+
name: string;
|
|
100
|
+
default: Expr | null;
|
|
101
|
+
}
|
|
102
|
+
export interface Assign {
|
|
103
|
+
name: string;
|
|
104
|
+
value: Expr;
|
|
105
|
+
pos: Pos;
|
|
106
|
+
}
|
|
107
|
+
export type Stmt = {
|
|
108
|
+
kind: 'assign';
|
|
109
|
+
name: string;
|
|
110
|
+
value: Expr;
|
|
111
|
+
span: [number, number];
|
|
112
|
+
pos: Pos;
|
|
113
|
+
} | {
|
|
114
|
+
kind: 'module';
|
|
115
|
+
name: string;
|
|
116
|
+
params: Param[];
|
|
117
|
+
body: Stmt[];
|
|
118
|
+
pos: Pos;
|
|
119
|
+
} | {
|
|
120
|
+
kind: 'function';
|
|
121
|
+
name: string;
|
|
122
|
+
params: Param[];
|
|
123
|
+
body: Expr;
|
|
124
|
+
pos: Pos;
|
|
125
|
+
} | {
|
|
126
|
+
kind: 'call';
|
|
127
|
+
name: string;
|
|
128
|
+
args: Arg[];
|
|
129
|
+
children: Stmt[];
|
|
130
|
+
modifier: string | null;
|
|
131
|
+
pos: Pos;
|
|
132
|
+
} | {
|
|
133
|
+
kind: 'for';
|
|
134
|
+
assigns: Assign[];
|
|
135
|
+
body: Stmt[];
|
|
136
|
+
pos: Pos;
|
|
137
|
+
} | {
|
|
138
|
+
kind: 'if';
|
|
139
|
+
cond: Expr;
|
|
140
|
+
then: Stmt[];
|
|
141
|
+
else: Stmt[];
|
|
142
|
+
pos: Pos;
|
|
143
|
+
} | {
|
|
144
|
+
kind: 'let';
|
|
145
|
+
assigns: Assign[];
|
|
146
|
+
body: Stmt[];
|
|
147
|
+
pos: Pos;
|
|
148
|
+
} | {
|
|
149
|
+
kind: 'block';
|
|
150
|
+
body: Stmt[];
|
|
151
|
+
pos: Pos;
|
|
152
|
+
} | {
|
|
153
|
+
kind: 'use';
|
|
154
|
+
path: string;
|
|
155
|
+
include: boolean;
|
|
156
|
+
pos: Pos;
|
|
157
|
+
};
|
|
158
|
+
export interface Program {
|
|
159
|
+
body: Stmt[];
|
|
160
|
+
}
|
package/dist/ast.d.ts
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import type { Pos } from './lexer.js';
|
|
2
|
+
export type Expr = {
|
|
3
|
+
kind: 'num';
|
|
4
|
+
value: number;
|
|
5
|
+
pos: Pos;
|
|
6
|
+
} | {
|
|
7
|
+
kind: 'str';
|
|
8
|
+
value: string;
|
|
9
|
+
pos: Pos;
|
|
10
|
+
} | {
|
|
11
|
+
kind: 'bool';
|
|
12
|
+
value: boolean;
|
|
13
|
+
pos: Pos;
|
|
14
|
+
} | {
|
|
15
|
+
kind: 'undef';
|
|
16
|
+
pos: Pos;
|
|
17
|
+
} | {
|
|
18
|
+
kind: 'var';
|
|
19
|
+
name: string;
|
|
20
|
+
pos: Pos;
|
|
21
|
+
} | {
|
|
22
|
+
kind: 'list';
|
|
23
|
+
items: ListItem[];
|
|
24
|
+
pos: Pos;
|
|
25
|
+
} | {
|
|
26
|
+
kind: 'range';
|
|
27
|
+
start: Expr;
|
|
28
|
+
step: Expr | null;
|
|
29
|
+
end: Expr;
|
|
30
|
+
pos: Pos;
|
|
31
|
+
} | {
|
|
32
|
+
kind: 'unary';
|
|
33
|
+
op: string;
|
|
34
|
+
arg: Expr;
|
|
35
|
+
pos: Pos;
|
|
36
|
+
} | {
|
|
37
|
+
kind: 'binary';
|
|
38
|
+
op: string;
|
|
39
|
+
left: Expr;
|
|
40
|
+
right: Expr;
|
|
41
|
+
pos: Pos;
|
|
42
|
+
} | {
|
|
43
|
+
kind: 'ternary';
|
|
44
|
+
cond: Expr;
|
|
45
|
+
then: Expr;
|
|
46
|
+
else: Expr;
|
|
47
|
+
pos: Pos;
|
|
48
|
+
} | {
|
|
49
|
+
kind: 'index';
|
|
50
|
+
target: Expr;
|
|
51
|
+
index: Expr;
|
|
52
|
+
pos: Pos;
|
|
53
|
+
} | {
|
|
54
|
+
kind: 'member';
|
|
55
|
+
target: Expr;
|
|
56
|
+
name: string;
|
|
57
|
+
pos: Pos;
|
|
58
|
+
} | {
|
|
59
|
+
kind: 'call';
|
|
60
|
+
callee: Expr;
|
|
61
|
+
args: Arg[];
|
|
62
|
+
pos: Pos;
|
|
63
|
+
} | {
|
|
64
|
+
kind: 'lambda';
|
|
65
|
+
params: Param[];
|
|
66
|
+
body: Expr;
|
|
67
|
+
pos: Pos;
|
|
68
|
+
} | {
|
|
69
|
+
kind: 'let';
|
|
70
|
+
assigns: Assign[];
|
|
71
|
+
body: Expr;
|
|
72
|
+
pos: Pos;
|
|
73
|
+
};
|
|
74
|
+
export type ListItem = {
|
|
75
|
+
kind: 'item';
|
|
76
|
+
expr: Expr;
|
|
77
|
+
} | {
|
|
78
|
+
kind: 'each';
|
|
79
|
+
expr: Expr;
|
|
80
|
+
} | {
|
|
81
|
+
kind: 'for';
|
|
82
|
+
assigns: Assign[];
|
|
83
|
+
body: ListItem;
|
|
84
|
+
} | {
|
|
85
|
+
kind: 'if';
|
|
86
|
+
cond: Expr;
|
|
87
|
+
then: ListItem;
|
|
88
|
+
else: ListItem | null;
|
|
89
|
+
} | {
|
|
90
|
+
kind: 'let';
|
|
91
|
+
assigns: Assign[];
|
|
92
|
+
body: ListItem;
|
|
93
|
+
};
|
|
94
|
+
export interface Arg {
|
|
95
|
+
name: string | null;
|
|
96
|
+
value: Expr;
|
|
97
|
+
}
|
|
98
|
+
export interface Param {
|
|
99
|
+
name: string;
|
|
100
|
+
default: Expr | null;
|
|
101
|
+
}
|
|
102
|
+
export interface Assign {
|
|
103
|
+
name: string;
|
|
104
|
+
value: Expr;
|
|
105
|
+
pos: Pos;
|
|
106
|
+
}
|
|
107
|
+
export type Stmt = {
|
|
108
|
+
kind: 'assign';
|
|
109
|
+
name: string;
|
|
110
|
+
value: Expr;
|
|
111
|
+
span: [number, number];
|
|
112
|
+
pos: Pos;
|
|
113
|
+
} | {
|
|
114
|
+
kind: 'module';
|
|
115
|
+
name: string;
|
|
116
|
+
params: Param[];
|
|
117
|
+
body: Stmt[];
|
|
118
|
+
pos: Pos;
|
|
119
|
+
} | {
|
|
120
|
+
kind: 'function';
|
|
121
|
+
name: string;
|
|
122
|
+
params: Param[];
|
|
123
|
+
body: Expr;
|
|
124
|
+
pos: Pos;
|
|
125
|
+
} | {
|
|
126
|
+
kind: 'call';
|
|
127
|
+
name: string;
|
|
128
|
+
args: Arg[];
|
|
129
|
+
children: Stmt[];
|
|
130
|
+
modifier: string | null;
|
|
131
|
+
pos: Pos;
|
|
132
|
+
} | {
|
|
133
|
+
kind: 'for';
|
|
134
|
+
assigns: Assign[];
|
|
135
|
+
body: Stmt[];
|
|
136
|
+
pos: Pos;
|
|
137
|
+
} | {
|
|
138
|
+
kind: 'if';
|
|
139
|
+
cond: Expr;
|
|
140
|
+
then: Stmt[];
|
|
141
|
+
else: Stmt[];
|
|
142
|
+
pos: Pos;
|
|
143
|
+
} | {
|
|
144
|
+
kind: 'let';
|
|
145
|
+
assigns: Assign[];
|
|
146
|
+
body: Stmt[];
|
|
147
|
+
pos: Pos;
|
|
148
|
+
} | {
|
|
149
|
+
kind: 'block';
|
|
150
|
+
body: Stmt[];
|
|
151
|
+
pos: Pos;
|
|
152
|
+
} | {
|
|
153
|
+
kind: 'use';
|
|
154
|
+
path: string;
|
|
155
|
+
include: boolean;
|
|
156
|
+
pos: Pos;
|
|
157
|
+
};
|
|
158
|
+
export interface Program {
|
|
159
|
+
body: Stmt[];
|
|
160
|
+
}
|
package/dist/cli.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|