@mylasertools/kerfscript 0.2.0 → 0.3.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.
Files changed (46) hide show
  1. package/CHANGELOG.md +97 -0
  2. package/CLA.md +8 -5
  3. package/COMMERCIAL-LICENSE.md +23 -28
  4. package/LANGUAGE.md +194 -60
  5. package/README.md +89 -39
  6. package/THIRD-PARTY-NOTICES.md +68 -4
  7. package/TRADEMARKS.md +16 -10
  8. package/dist/cli.js +773 -297
  9. package/dist/evaluator.d.cts +26 -0
  10. package/dist/evaluator.d.ts +26 -0
  11. package/dist/export/dxf.d.cts +1 -1
  12. package/dist/export/dxf.d.ts +1 -1
  13. package/dist/export/svg.d.cts +2 -0
  14. package/dist/export/svg.d.ts +2 -0
  15. package/dist/font.d.cts +3 -0
  16. package/dist/font.d.ts +3 -0
  17. package/dist/functions.d.cts +21 -2
  18. package/dist/functions.d.ts +21 -2
  19. package/dist/index.cjs +14 -14
  20. package/dist/index.d.cts +2 -2
  21. package/dist/index.d.ts +2 -2
  22. package/dist/index.js +14 -14
  23. package/dist/lexer.d.cts +4 -1
  24. package/dist/lexer.d.ts +4 -1
  25. package/dist/parser.d.cts +1 -1
  26. package/dist/parser.d.ts +1 -1
  27. package/dist/render.d.cts +3 -2
  28. package/dist/render.d.ts +3 -2
  29. package/dist/values.d.cts +10 -2
  30. package/dist/values.d.ts +10 -2
  31. package/dist/wasm.d.cts +1 -0
  32. package/dist/wasm.d.ts +1 -0
  33. package/docs/cli.md +69 -28
  34. package/docs/compatibility.md +40 -65
  35. package/docs/customizer.md +40 -28
  36. package/docs/desktop.md +96 -0
  37. package/docs/getting-started.md +48 -31
  38. package/docs/javascript.md +108 -51
  39. package/docs/kerf.md +36 -39
  40. package/docs/layers.md +71 -37
  41. package/docs/openscad.md +52 -48
  42. package/docs/parts-and-sheets.md +45 -31
  43. package/docs/versions.md +20 -30
  44. package/docs/webassembly.md +131 -0
  45. package/fonts/OFL.txt +92 -0
  46. package/package.json +10 -6
package/README.md CHANGED
@@ -1,17 +1,38 @@
1
- # KerfScript
2
-
3
- **A programming language for laser cutting.**
4
-
5
- [Website](https://kerfscript.mylasertools.com) ·
6
- [Playground](https://kerfscript.mylasertools.com/playground/) ·
7
- [Models](https://kerfscript.mylasertools.com/models/) ·
8
- [Docs](https://kerfscript.mylasertools.com/docs/)
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>
4
+
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>
9
19
 
10
20
  Write a part once as code, change a number, and get a new cut file. KerfScript
11
21
  is to laser cutters what OpenSCAD is to 3D printers, except it was designed for
12
22
  flat parts from the start: cut, score and engrave layers, kerf compensation,
13
23
  finger joints, living hinges, parts and sheets are part of the language.
14
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
+
15
36
  ```kerf
16
37
  use <kerf/box>
17
38
 
@@ -28,6 +49,13 @@ $kerf = 0.15; // [0:0.01:0.5]
28
49
  box([width, depth, height], lid = lid);
29
50
  ```
30
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
+
31
59
  ```sh
32
60
  npx @mylasertools/kerfscript render box.kerf -o box.svg -D width=200
33
61
  ```
@@ -37,6 +65,35 @@ millimetre SVG with one layer per operation. Output is checked automatically
37
65
  in Inkscape; see [docs/compatibility.md](docs/compatibility.md) for what has
38
66
  and has not been tested in other laser software.
39
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
+
40
97
  ## Why a new language
41
98
 
42
99
  - **Laser concepts are built in.** `engrave()`, `score()` and `cut()` put
@@ -44,17 +101,20 @@ and has not been tested in other laser software.
44
101
  cuts come before outer ones, and the whole part is offset by half the kerf.
45
102
  - **Parts, not just shapes.** `part("lid", qty = 2)` names a piece; the
46
103
  renderer packs parts by material and thickness onto sheets.
47
- - **Joinery that fits.** `finger_rect`, `finger_holes`, `tslot` and
48
- `living_hinge` use `$thickness`, so changing the material keeps joints
49
- tight.
50
- - **Familiar syntax.** If you know OpenSCAD, you can read KerfScript. The
51
- customizer comments are the same, so editors that understand OpenSCAD
52
- parameters understand KerfScript ones.
104
+ - **Joinery that follows the material.** `finger_rect`, `finger_holes`,
105
+ `tslot` and `living_hinge` use `$thickness`, so the joints resize when the
106
+ material changes. Measure your kerf and cut a test piece for a snug fit.
107
+ - **Readable code.** Variables, modules, functions, loops and transforms like
108
+ `translate()` and `rotate()`. Settings come from comments such as
109
+ `// [10:1:100]`, which the playground turns into sliders. If you have used
110
+ OpenSCAD, [Coming from OpenSCAD](docs/openscad.md) lists what differs.
53
111
  - **Runs anywhere.** Pure TypeScript with no native code: the same interpreter
54
112
  runs in browsers, Node, workers and the command line.
55
- - **Safe to run.** Programs read libraries only through the resolver you
56
- provide. Step and recursion limits stop runaway programs, and errors name
57
- the line.
113
+ - **Contained.** Programs read libraries only through the resolver you
114
+ provide and have no other access to files or the network. Step, recursion
115
+ and size limits stop runaway programs, and errors name the line. Run
116
+ programs you did not write in a worker or process you can stop; see
117
+ [Running untrusted code](docs/javascript.md#running-untrusted-code).
58
118
 
59
119
  ## Install
60
120
 
@@ -62,6 +122,12 @@ and has not been tested in other laser software.
62
122
  npm install @mylasertools/kerfscript
63
123
  ```
64
124
 
125
+ The `kerf` command line also comes as a standalone binary that needs no
126
+ Node.js, and through Homebrew, winget, Chocolatey, Scoop, Snap, the AUR,
127
+ MacPorts and Docker: see [Command line](docs/cli.md#without-nodejs). The
128
+ desktop app is in [Desktop app](docs/desktop.md), and the WebAssembly module
129
+ in [WebAssembly](docs/webassembly.md).
130
+
65
131
  ## Command line
66
132
 
67
133
  ```sh
@@ -99,7 +165,9 @@ Errors are thrown as `KerfError` with `line` and `col`.
99
165
  - [Getting started](docs/getting-started.md), then the guides on
100
166
  [layers](docs/layers.md), [kerf](docs/kerf.md),
101
167
  [parts and sheets](docs/parts-and-sheets.md), [settings](docs/customizer.md),
102
- the [command line](docs/cli.md) and the [JavaScript API](docs/javascript.md)
168
+ the [desktop app](docs/desktop.md), the [command line](docs/cli.md), the
169
+ [JavaScript API](docs/javascript.md)
170
+ and [WebAssembly](docs/webassembly.md) for other languages
103
171
  - [Coming from OpenSCAD](docs/openscad.md): what is the same and what is not
104
172
  - [LANGUAGE.md](LANGUAGE.md): the full language reference
105
173
  - [Versions](docs/versions.md): language and package versions, and what stays
@@ -107,25 +175,6 @@ Errors are thrown as `KerfError` with `line` and `col`.
107
175
  - [examples/](examples): every model on the website, including a
108
176
  calibration square and a kerf test
109
177
 
110
- ## Website
111
-
112
- kerfscript.mylasertools.com is an Astro site in [site/](site), deployed to
113
- Cloudflare as a static assets Worker. Every model picture and the guides are
114
- built from [examples/](examples), [docs/](docs) and LANGUAGE.md by this
115
- version of KerfScript.
116
-
117
- ```sh
118
- npm --prefix site install
119
- npm run site # build KerfScript, then the site into site/dist
120
- npm run site:serve # preview on http://localhost:4321
121
- npm --prefix site run deploy
122
- ```
123
-
124
- ## Checking output
125
-
126
- `npm run compat` renders a reference set of models and opens every SVG and
127
- DXF in Inkscape to check sizes, layers and fills.
128
-
129
178
  ## Community
130
179
 
131
180
  Bug reports, cut reports and ideas are welcome; see
@@ -141,8 +190,9 @@ KerfScript is free software under the
141
190
  that makes **your `.kerf` designs and the files KerfScript generates yours to
142
191
  license and sell however you like**.
143
192
 
144
- Using KerfScript in a closed source product or hosted service without
145
- publishing your source requires a [commercial licence](COMMERCIAL-LICENSE.md).
193
+ Building KerfScript into a closed-source app, machine or service? The
194
+ [commercial licence](COMMERCIAL-LICENSE.md#free-commercial-licence) is free:
195
+ just email hi@mylasertools.com.
146
196
 
147
197
  "KerfScript" is a trademark of MyLaserTools; see [TRADEMARKS.md](TRADEMARKS.md).
148
198
  Contributions need the [CLA](CLA.md); see [CONTRIBUTING.md](CONTRIBUTING.md).
@@ -62,8 +62,72 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
62
62
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
63
63
  ```
64
64
 
65
- ## Atkinson Hyperlegible (test fixture only, not published to npm)
65
+ ## tiny-inflate 1.0.3 (bundled, part of opentype.js)
66
66
 
67
- `test/fixtures/AtkinsonHyperlegible-Regular.ttf`, Copyright 2020 Braille
68
- Institute of America, Inc., licensed under the SIL Open Font License 1.1. See
69
- `test/fixtures/OFL.txt`.
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
+ ## Desktop app
121
+
122
+ The desktop app is also built from Rust crates (Tauri and its dependencies)
123
+ under MIT, Apache-2.0, MPL-2.0, BSD, ISC, Zlib, Unicode and similar licences.
124
+ `desktop/THIRD-PARTY-LICENSES.md` lists each one with its licence text, and
125
+ the installers place it next to the app.
126
+
127
+ ## Atkinson Hyperlegible (built into the command line and kerfscript.wasm)
128
+
129
+ `fonts/AtkinsonHyperlegible-Regular.ttf`, Copyright 2020 Braille Institute
130
+ of America, Inc., licensed under the SIL Open Font License 1.1. See
131
+ `fonts/OFL.txt`. It is embedded unmodified in `dist/cli.js` and
132
+ `kerfscript.wasm`, and the playground serves it; `dist/index.js` does not
133
+ include it.
package/TRADEMARKS.md CHANGED
@@ -2,16 +2,22 @@
2
2
 
3
3
  "KerfScript", the `.kerf` file format name used as a product name, and the
4
4
  KerfScript logo are trademarks of MyLaserTools. The software licences
5
- (AGPL-3.0-only and commercial) cover the code. They do not grant rights to the
5
+ (AGPL-3.0-only and the free commercial licence) cover the code. They do not grant rights to the
6
6
  name or logo.
7
7
 
8
- This policy keeps "KerfScript" meaning one well defined language, so a `.kerf`
9
- file written for one KerfScript tool works in every tool that uses the name.
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.
10
11
 
11
12
  ## You may, without asking
12
13
 
13
14
  - say your design, tutorial, course, video or library is written **in**
14
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
15
21
  - use the `.kerf` file extension for KerfScript programs
16
22
  - use the name to refer to this project and to unmodified copies of it
17
23
  - publish a fork for development, as long as it is clearly marked as a fork
@@ -21,19 +27,19 @@ file written for one KerfScript tool works in every tool that uses the name.
21
27
 
22
28
  - name a product, service, company, domain or package "KerfScript" or anything
23
29
  confusingly similar (for example "KerfScript Pro", "kerfscript-cloud")
24
- - call your own implementation, editor or service "KerfScript compatible" or
25
- "official". Compatibility claims require passing the KerfScript conformance
26
- tests for the language version you claim
30
+ - call your own implementation, editor or service "official" or imply
31
+ that MyLaserTools endorses it
27
32
  - use the logo, other than to link to this project
28
33
  - distribute a modified interpreter under the KerfScript name
29
34
 
30
35
  ## Language specification
31
36
 
32
37
  The language reference ([LANGUAGE.md](LANGUAGE.md)) is published under
33
- Creative Commons Attribution-NoDerivatives 4.0 (CC BY-ND 4.0). You may copy and
34
- share it unchanged with attribution. Changes to the language are made by
35
- MyLaserTools through this repository, so there is one KerfScript.
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.
36
42
 
37
43
  ## Contact
38
44
 
39
- julia@mylasertools.com
45
+ hi@mylasertools.com