formacad 0.0.0-stage → 0.2.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 (97) hide show
  1. package/LICENSE +200 -0
  2. package/README.md +98 -2
  3. package/build/cli/src/forma.d.ts +2 -0
  4. package/build/cli/src/forma.js +546 -0
  5. package/build/cli/src/forma.js.map +1 -0
  6. package/build/cli/src/mcp.d.ts +1 -0
  7. package/build/cli/src/mcp.js +495 -0
  8. package/build/cli/src/mcp.js.map +1 -0
  9. package/build/cli/src/preview.d.ts +31 -0
  10. package/build/cli/src/preview.js +427 -0
  11. package/build/cli/src/preview.js.map +1 -0
  12. package/build/core/fonts/Roboto-Bold.ttf +0 -0
  13. package/build/core/fonts/Roboto-Regular.ttf +0 -0
  14. package/build/core/src/bevel.d.ts +41 -0
  15. package/build/core/src/bevel.js +548 -0
  16. package/build/core/src/bevel.js.map +1 -0
  17. package/build/core/src/difflib.d.ts +3 -0
  18. package/build/core/src/difflib.js +94 -0
  19. package/build/core/src/difflib.js.map +1 -0
  20. package/build/core/src/errors.d.ts +9 -0
  21. package/build/core/src/errors.js +14 -0
  22. package/build/core/src/errors.js.map +1 -0
  23. package/build/core/src/export2d.d.ts +10 -0
  24. package/build/core/src/export2d.js +127 -0
  25. package/build/core/src/export2d.js.map +1 -0
  26. package/build/core/src/geometry.d.ts +93 -0
  27. package/build/core/src/geometry.js +946 -0
  28. package/build/core/src/geometry.js.map +1 -0
  29. package/build/core/src/gltf.d.ts +6 -0
  30. package/build/core/src/gltf.js +154 -0
  31. package/build/core/src/gltf.js.map +1 -0
  32. package/build/core/src/host.d.ts +28 -0
  33. package/build/core/src/host.js +113 -0
  34. package/build/core/src/host.js.map +1 -0
  35. package/build/core/src/importers.d.ts +12 -0
  36. package/build/core/src/importers.js +1025 -0
  37. package/build/core/src/importers.js.map +1 -0
  38. package/build/core/src/index.d.ts +92 -0
  39. package/build/core/src/index.js +227 -0
  40. package/build/core/src/index.js.map +1 -0
  41. package/build/core/src/inflate.d.ts +15 -0
  42. package/build/core/src/inflate.js +230 -0
  43. package/build/core/src/inflate.js.map +1 -0
  44. package/build/core/src/interp.d.ts +178 -0
  45. package/build/core/src/interp.js +3012 -0
  46. package/build/core/src/interp.js.map +1 -0
  47. package/build/core/src/lexer.d.ts +14 -0
  48. package/build/core/src/lexer.js +217 -0
  49. package/build/core/src/lexer.js.map +1 -0
  50. package/build/core/src/manifold.d.ts +26 -0
  51. package/build/core/src/manifold.js +687 -0
  52. package/build/core/src/manifold.js.map +1 -0
  53. package/build/core/src/modeling.d.ts +18 -0
  54. package/build/core/src/modeling.js +483 -0
  55. package/build/core/src/modeling.js.map +1 -0
  56. package/build/core/src/parser.d.ts +46 -0
  57. package/build/core/src/parser.js +478 -0
  58. package/build/core/src/parser.js.map +1 -0
  59. package/build/core/src/scad/colors.d.ts +1 -0
  60. package/build/core/src/scad/colors.js +37 -0
  61. package/build/core/src/scad/colors.js.map +1 -0
  62. package/build/core/src/scad/convert.d.ts +33 -0
  63. package/build/core/src/scad/convert.js +2842 -0
  64. package/build/core/src/scad/convert.js.map +1 -0
  65. package/build/core/src/scad/parser.d.ts +239 -0
  66. package/build/core/src/scad/parser.js +578 -0
  67. package/build/core/src/scad/parser.js.map +1 -0
  68. package/build/core/src/scad/sources.d.ts +39 -0
  69. package/build/core/src/scad/sources.js +171 -0
  70. package/build/core/src/scad/sources.js.map +1 -0
  71. package/build/core/src/std.d.ts +3 -0
  72. package/build/core/src/std.js +47 -0
  73. package/build/core/src/std.js.map +1 -0
  74. package/build/core/src/surface.d.ts +21 -0
  75. package/build/core/src/surface.js +253 -0
  76. package/build/core/src/surface.js.map +1 -0
  77. package/build/core/src/threemf.d.ts +4 -0
  78. package/build/core/src/threemf.js +127 -0
  79. package/build/core/src/threemf.js.map +1 -0
  80. package/build/core/src/ttf.d.ts +39 -0
  81. package/build/core/src/ttf.js +473 -0
  82. package/build/core/src/ttf.js.map +1 -0
  83. package/build/core/src/values.d.ts +146 -0
  84. package/build/core/src/values.js +365 -0
  85. package/build/core/src/values.js.map +1 -0
  86. package/build/core/src/xml.d.ts +13 -0
  87. package/build/core/src/xml.js +152 -0
  88. package/build/core/src/xml.js.map +1 -0
  89. package/build/core/std/electronics.forma +120 -0
  90. package/build/core/std/enclosures.forma +76 -0
  91. package/build/core/std/fasteners.forma +170 -0
  92. package/build/core/std/gridfinity.forma +182 -0
  93. package/build/core/std/joints.forma +120 -0
  94. package/build/core/std/mechanics.forma +276 -0
  95. package/build/core/std/patterns.forma +138 -0
  96. package/build/core/std/threads.forma +152 -0
  97. package/package.json +59 -4
package/LICENSE ADDED
@@ -0,0 +1,200 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the NOTICE text file within such
109
+ NOTICE file, excluding those notices that do not pertain to any
110
+ part of the Derivative Works, in at least one of the following
111
+ places: within a NOTICE text file distributed as part of the
112
+ Derivative Works; within the Source form or documentation,
113
+ if provided along with the Derivative Works; or, within a
114
+ display generated by the Derivative Works, if and wherever such
115
+ third-party notices normally appear. The contents of the NOTICE
116
+ file are for informational purposes only and do not modify the
117
+ License. You may add Your own attribution notices within
118
+ Derivative Works that You distribute, alongside or as an addendum
119
+ to the NOTICE text file from the Work, provided that such additional
120
+ attribution notices cannot be construed as modifying the License.
121
+
122
+ You may add Your own copyright notice to Your modifications and
123
+ may provide additional or different license terms and conditions
124
+ for use, reproduction, or distribution of Your modifications, or
125
+ for any such Derivative Works as a whole, provided Your use,
126
+ reproduction, and distribution of the Work otherwise complies with
127
+ the conditions stated in this License.
128
+
129
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
130
+ any Contribution intentionally submitted for inclusion in the Work
131
+ by You to the Licensor shall be under the terms and conditions of
132
+ this License, without any additional terms or conditions.
133
+ Notwithstanding the above, nothing herein shall supersede or modify
134
+ the terms of any separate license agreement you may have executed
135
+ with Licensor regarding such Contributions.
136
+
137
+ 6. Trademarks. This License does not grant permission to use the trade
138
+ names, trademarks, service marks, or product names of the Licensor,
139
+ except as required for reasonable and customary use in describing the
140
+ origin of the Work and reproducing the content of the NOTICE file.
141
+
142
+ 7. Disclaimer of Warranty. Unless required by applicable law or
143
+ agreed to in writing, Licensor provides the Work (and each
144
+ Contributor provides its Contributions) on an "AS IS" BASIS,
145
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
146
+ implied, including but not limited to any warranties or conditions
147
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
148
+ PARTICULAR PURPOSE. You are solely responsible for determining the
149
+ appropriateness of using or redistributing the Work and assume any
150
+ risks associated with Your exercise of permissions under this License.
151
+
152
+ 8. Limitation of Liability. In no event and under no legal theory,
153
+ whether in tort (including negligence), contract, or otherwise,
154
+ unless required by applicable law (including deliberate and grossly
155
+ negligent acts) or agreed to in writing, shall any Contributor be
156
+ liable to You for damages, including any direct, indirect, special,
157
+ incidental, or consequential damages of any character arising as a
158
+ result of this License or out of the use or inability to use the
159
+ Work (including but not limited to damages for loss of goodwill,
160
+ work stoppage, computer failure or loss of error, or any and all
161
+ other commercial damages or losses), even if such Contributor
162
+ has been advised of the possibility of such damages.
163
+
164
+ 9. Accepting Warranty or Additional Liability. While redistributing
165
+ the Work or Derivative Works thereof, You may choose to offer,
166
+ and accept support, warranty, or additional liability obligations
167
+ and/or rights consistent with this License. However, in accepting
168
+ such obligations, You may act only on Your own behalf and on Your
169
+ sole responsibility, not on behalf of any other Contributor, and
170
+ only if You agree to indemnify, defend, and hold each Contributor
171
+ harmless for any liability incurred by, or claims directed against,
172
+ any Contributor by reason of your accepting any such warranty or
173
+ additional liability.
174
+
175
+ END OF TERMS AND CONDITIONS
176
+
177
+ APPENDIX: How to apply the Apache License to your work.
178
+
179
+ To apply the Apache License to your work, attach the following
180
+ boilerplate notice, with the fields enclosed by brackets "[]"
181
+ replaced with your own identifying information. (Don't include
182
+ the brackets!) The text should be enclosed in the appropriate
183
+ comment files for the file syntax. We also recommend that a
184
+ file name or class name and description of use be included on the
185
+ same "printed page" as the copyright notice for the third-party
186
+ notices.
187
+
188
+ Copyright 2026 Ivan Makhnyk
189
+
190
+ Licensed under the Apache License, Version 2.0 (the "License");
191
+ you may not use this file except in compliance with the License.
192
+ You may obtain a copy of the License at
193
+
194
+ http://www.apache.org/licenses/LICENSE-2.0
195
+
196
+ Unless required by applicable law or agreed to in writing, software
197
+ distributed under the License is distributed on an "AS IS" BASIS,
198
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
199
+ See the License for the specific language governing permissions and
200
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,99 @@
1
- # Temporary Holding Version
1
+ # Forma
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A Swift-style language for 3D models: a model is code that is easy for people to read and for AI to write.
4
+ The output is an STL file, ready for 3D printing.
5
+
6
+ ```swift
7
+ Union {
8
+ Sphere(r: 25mm).at(z: 25mm)
9
+ Sphere(r: 18mm).at(z: 62mm)
10
+ Sphere(r: 12mm).at(z: 88mm)
11
+ Cone(r1: 2mm, h: 10mm).at(y: -11mm, z: 88mm).rotate(x: 90deg).color(.orange)
12
+ }
13
+ ```
14
+
15
+ **Try it in your browser: [ivanmakhnyk.github.io/formacad](https://ivanmakhnyk.github.io/formacad/)** — an editor with a live
16
+ 3D preview, parameter sliders, and STL/3MF export.
17
+
18
+ ![Examples](docs/images/twisted_vase.png)
19
+
20
+ ## Features
21
+
22
+ - **Language:** checked units (`mm`, `deg`, `mm²`), `let`, `param` (with `in min...max, step:` ranges, `in [...]` dropdowns, and `.animate()`), `func`, first-class `{ x in ... }` closures, `struct` (records with fields, defaults, methods, and `.with()`), `component` with `children`,
23
+ `for`, `if`, `? :`, lists with `.map`/`.filter`/`.contains`/`.firstIndex`/`.find`/`.reverse`/`.sort`/`.reduce`/`.join`, Swift-style string interpolation `"\(expr)"`, regex `.replace`, `chr`/`ord`, type checks (`typeOf`/`is*`), deterministic `Random(seed:)`, `stride`, `assert`, `print`, `import` of local & `std/*.forma` libraries.
24
+ - **3D:** `Sphere`, `Box`, `Cylinder`, `Cone`, `Torus`, `Polyhedron`, `Surface` (PNG lithophanes/heightmaps, `.dat`/`.csv`, and `{ x, y in ... }` math closures), `Loft`; `Union`, `Difference`, `Intersection`, `Hull`, `Minkowski`; `.fillet()`, `.chamfer()`, `.shell(wall:, open:)`, `.resize()`, `.transform(matrix:)`, `.align()`/`.above()`, and `Layer` (`.default`, `.debug`, `.reference`, `.hidden`, custom `Layer(...)`).
25
+ - **2D & Curves:** `Circle`, `Rect`, `Polygon`, `Text` + `Font` (bundled multilingual Roboto + custom `.ttf`), `Helix`, `Bezier`, `Spline`, `.offset()`, 3D → 2D `.slice()`/`.project()`, `.extrude(height:, twist:, scale:)`, `.revolve(angle:)`, `.sweep(path:, smooth:)`.
26
+ - **Standard libraries:** 8 built-in `std/*.forma` modules (`fasteners`, `joints`, `enclosures`, `electronics`, `mechanics`, `threads`, `gridfinity`, `patterns`) ready in CLI, VSCode, and Playground.
27
+ - **Import & Export:** import STL, OBJ (+MTL), 3MF, SVG, DXF, PNG/DAT heightmaps; export STL, 3MF (with colours), glTF/GLB, 2D SVG/DXF/1:1 PDF in mm, 4-view PNG previews, `--animate` PNG frames, and per-layer batch export (`--export-layers`).
28
+ - **Editor & AI:** VSCode extension (`packages/vscode`: highlighting, live diagnostics, autocompletion, 3D WebGL preview, export), built-in MCP server (`forma mcp`), errors with line/column/hint, JSON report, and `llms.txt`.
29
+
30
+ ## Quick start
31
+
32
+ Forma runs on Node.js 22.3+ (TypeScript + Manifold WASM engine). Install from [npm](https://www.npmjs.com/package/formacad) or run directly with `npx`:
33
+
34
+ ```bash
35
+ npm install -g formacad # installs the 'forma' CLI
36
+ # or without installing: npx formacad model.forma
37
+
38
+ forma examples/snowman.forma # → examples/snowman.stl
39
+ forma examples/snowman.forma -o snowman.3mf # → 3MF with colours
40
+ forma examples/keychain.forma -o keychain.svg # → 2D SVG (or .dxf) in mm
41
+ forma examples/raspberry_pi_case.forma --export-layers out/ # → one file per layer
42
+ forma examples/snowman.forma --preview snowman.png # → 4-view PNG preview
43
+ forma examples/pencil_cup.forma -D height=120mm --json # → JSON report
44
+ forma --list-std # → list built-in std/*.forma libraries
45
+ forma convert model.scad --units mm # → OpenSCAD model converted to model.forma
46
+ ```
47
+
48
+ Or use it as a JavaScript / TypeScript library:
49
+
50
+ ```js
51
+ import { build, MemoryHost, stlBytes } from 'formacad';
52
+
53
+ const host = new MemoryHost({ '/main.forma': 'Sphere(r: 10mm)' });
54
+ const { report, polys } = build({ host, file: '/main.forma' });
55
+ ```
56
+
57
+ Full language reference: [docs/language.md](docs/language.md). Design decisions: [docs/design.md](docs/design.md).
58
+ Roadmap: [docs/roadmap.md](docs/roadmap.md). Working on the code (people or AI): [CLAUDE.md](CLAUDE.md).
59
+
60
+ ## Website
61
+
62
+ The website (home page, playground, docs, gallery, tools, AI page) is built from this repository and published
63
+ to GitHub Pages by `.github/workflows/pages.yml` on every push to `main` — but only if all tests pass.
64
+ The playground runs the TypeScript + Manifold WASM engine in a Web Worker, with its own code editor and WebGL viewer.
65
+
66
+ ```bash
67
+ npm run build:site # builds site-dist/
68
+ npm run serve # preview at http://localhost:8080/
69
+ ```
70
+
71
+ To enable publishing once: repository **Settings → Pages → Build and deployment → Source: GitHub Actions**.
72
+
73
+ ## Layout
74
+
75
+ ```
76
+ packages/core/ the TypeScript + Manifold WASM engine: language, geometry, fonts, std/*.forma, import/export
77
+ packages/cli/ command line for Node (STL, 3MF, SVG, DXF, --export-layers, --preview, --watch, --json)
78
+ packages/web/ the website: playground app (editor, viewer, worker), styles
79
+ packages/vscode/ VSCode extension: highlighting, live diagnostics, completion, 3D WebGL preview, export
80
+ scripts/ site build, local preview server, gallery thumbnail renderer
81
+ examples/ examples; lib/ is a fastener library, assets/ holds files to import
82
+ tests/run_tests.mjs golden example and error tests
83
+ tests/golden.json expected sizes and volumes of the examples
84
+ tests/errors/ expected error messages
85
+ tests/js/ core API tests (files in memory, as in a browser)
86
+ tests/web/ browser smoke tests of the website (Playwright, run in CI before Pages deploy)
87
+ docs/ language reference and images (docs/images/gallery: website thumbnails)
88
+ ```
89
+
90
+ ## Tests
91
+
92
+ ```bash
93
+ npm test # build + core API tests + golden/error tests
94
+ node tests/run_tests.mjs --update # re-record golden.json after intentional changes
95
+ ```
96
+
97
+ ## License
98
+
99
+ Licensed under the [Apache License 2.0](LICENSE).
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};