@react-scad/core 0.1.15 → 0.1.17

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/README.md CHANGED
@@ -106,6 +106,8 @@ The path you pass to `createRoot()` is relative to the current working directory
106
106
 
107
107
  ## Advanced
108
108
 
109
+ ### Custom Behavior
110
+
109
111
  To write to a custom path or get the SCAD string in memory instead of using `createRoot(path)`, use `createContainer()`, `render()`, and `toScad()`:
110
112
 
111
113
  ```jsx
@@ -128,6 +130,37 @@ writeFileSync("out/model.scad", scadCode);
128
130
 
129
131
  Then run with `npx tsx main.tsx` or bundle with esbuild and run with Node.
130
132
 
133
+
134
+ ---
135
+
136
+ ### Interop with existing SCAD
137
+
138
+ You can reuse existing `.scad` libraries and snippets in two ways:
139
+
140
+ - **`Import`** — Emit OpenSCAD’s `import("path")` so the generated file pulls in another SCAD file (e.g. STL/DXF or a file that defines modules). Use this when the library is a separate file and you just need to reference it.
141
+
142
+ ```jsx
143
+ import { Import, Union } from "@react-scad/core";
144
+
145
+ <Union>
146
+ <Import file="lib/gears.scad" />
147
+ </Union>
148
+ ```
149
+
150
+ - **`Raw`** — Emit arbitrary SCAD code inline. Use this to paste a snippet, call a module from an imported library, or wrap a block of SCAD you don’t have a dedicated component for. Children are ignored; only the `code` prop is emitted (with indentation applied).
151
+
152
+ ```jsx
153
+ import { Raw, Union } from "@react-scad/core";
154
+
155
+ // After Import "lib/gears.scad", call a module from it:
156
+ <Raw code="gear(number_of_teeth=32, circular_pitch=200);" />
157
+
158
+ // Or inject a small SCAD block:
159
+ <Raw code={`include <BOSL2/std.scad>\nrounded_cube(20, 0.5);`} />
160
+ ```
161
+
162
+ Typical pattern: **`Import`** the library file once (at top level or where needed), then use **`Raw`** to call its modules or paste any SCAD that fits your tree.
163
+
131
164
  ---
132
165
 
133
166
  ## Primitives (SCAD coverage)
@@ -71,7 +71,7 @@ function serializeNode(node, indent, ctx) {
71
71
  }
72
72
  }
73
73
  }
74
- const CREDIT = "// Generated using react-scad (https://github.com/leonmeka/react-scad)";
74
+ const CREDIT = "// Generated using react-scad (https://github.com/react-scad/react-scad)";
75
75
  export function toScad(container) {
76
76
  const ctx = {
77
77
  serializeNode: (n, i) => serializeNode(n, i, ctx),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-scad/core",
3
- "version": "0.1.15",
3
+ "version": "0.1.17",
4
4
  "description": "Render JSX to OpenSCAD models using the React reconciler",
5
5
  "keywords": [
6
6
  "react",