@field/cascade 0.10.0 → 0.12.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 (229) hide show
  1. package/AGENTS.md +25 -5
  2. package/ARCHITECTURE.md +5 -4
  3. package/CHANGELOG.md +382 -0
  4. package/README.md +1 -2
  5. package/dist/assets/AgentPanel-1JugFjE4.css +1 -0
  6. package/dist/assets/AgentPanel-BDL5MddA.js +5 -0
  7. package/dist/assets/{CodeEditor-DSZBpzdy.js → CodeEditor-C-xYG-Wn.js} +120 -120
  8. package/dist/assets/CodePanel-CtXd50m6.js +2 -0
  9. package/dist/assets/CookInfoPanel-B3NMhKJF.css +1 -0
  10. package/dist/assets/CookInfoPanel-DG4_TRsX.js +2 -0
  11. package/dist/assets/CustomNodeDialog-CHfZUs-r.js +1 -0
  12. package/dist/assets/DefinitionNode-CaRTXQ_b.js +1 -0
  13. package/dist/assets/DefinitionPanel-C3CxZY9r.js +1 -0
  14. package/dist/assets/DefinitionPanel-VNLnAiQD.css +1 -0
  15. package/dist/assets/OpenGraphDialog-BLdr6k_q.js +1 -0
  16. package/dist/assets/ProjectSettings-ZnvmIAir.js +2 -0
  17. package/dist/assets/{SettingsDialog-p25h3tj0.js → SettingsDialog-CBX3Wa87.js} +1 -1
  18. package/dist/assets/TimelinePanel-CDeR0arY.css +1 -0
  19. package/dist/assets/TimelinePanel-CWgnFH1e.js +1 -0
  20. package/dist/assets/{VersionHistoryDialog-DzFLUotB.js → VersionHistoryDialog-BOSoW1R-.js} +1 -1
  21. package/dist/assets/assert-BO2_erPD.js +1 -0
  22. package/dist/assets/assert-hvykGCnP.js +1 -0
  23. package/dist/assets/builder-BmBKcDix.js +1 -0
  24. package/dist/assets/camera-DFF7YA3F.js +1 -0
  25. package/dist/assets/checks-DAvyO9Gf.js +1 -0
  26. package/dist/assets/contactSheet-N1NcaWxw.js +2 -0
  27. package/dist/assets/{core-BICrEt0y.js → core-DB-MkGjj.js} +3 -4
  28. package/dist/assets/coreTypes-DtnDATZ7.js +1 -0
  29. package/dist/assets/{cssMode-D7TXw57I.js → cssMode-DPVckSOc.js} +1 -1
  30. package/dist/assets/definitions-B227e7f_.js +1 -0
  31. package/dist/assets/definitions-D0WOUJd7.js +1 -0
  32. package/dist/assets/{editor.api-DvkCO3ko.js → editor.api-Dkutg_Z1.js} +1 -1
  33. package/dist/assets/expressions-X-Z-GrgW.js +5 -0
  34. package/dist/assets/file-DAL6IfjV.js +1 -0
  35. package/dist/assets/filters-D3k1LRMa.js +1 -0
  36. package/dist/assets/{freemarker2-BA2lxsF1.js → freemarker2-CLiLKk3B.js} +1 -1
  37. package/dist/assets/generators-BhDxRAFC.js +1 -0
  38. package/dist/assets/geo-BsMImJIJ.js +1 -0
  39. package/dist/assets/geo-C4YngDob.js +2 -0
  40. package/dist/assets/{handlebars-BcDiyPd8.js → handlebars-CcD3aMeL.js} +1 -1
  41. package/dist/assets/{html-C7O4TyhX.js → html-DvZWGfqb.js} +1 -1
  42. package/dist/assets/{htmlMode-WaDGF3Mj.js → htmlMode-DUD3VaoN.js} +1 -1
  43. package/dist/assets/image-0SfH-snh.js +1 -0
  44. package/dist/assets/image-Ck-RdGU4.js +2 -0
  45. package/dist/assets/index-BWnrmIB9.js +137 -0
  46. package/dist/assets/index-DIaxEONI.css +1 -0
  47. package/dist/assets/io-BGmt2g0D.js +1 -0
  48. package/dist/assets/{javascript-CpIEK7tz.js → javascript-Cap2ahgh.js} +1 -1
  49. package/dist/assets/{jsonMode-B2FltW0f.js → jsonMode-B0uLjp9C.js} +1 -1
  50. package/dist/assets/{liquid-CN6FFHZE.js → liquid-CnxwhfLn.js} +1 -1
  51. package/dist/assets/{lspLanguageFeatures-QhV9XtLp.js → lspLanguageFeatures-Dn9hlKX6.js} +1 -1
  52. package/dist/assets/math-GeULS-sk.js +1 -0
  53. package/dist/assets/{mdx-DE89pafV.js → mdx-BV3jbrVa.js} +1 -1
  54. package/dist/assets/pop-KMF_qloi.js +1 -0
  55. package/dist/assets/preload-helper-Czpn1I53.js +1 -0
  56. package/dist/assets/{python-ByTllTB9.js → python-CGyFk4XK.js} +1 -1
  57. package/dist/assets/{razor-USYlRRCE.js → razor-CQfzX3-N.js} +1 -1
  58. package/dist/assets/remap-5SjXQU-q.js +1 -0
  59. package/dist/assets/renderMarkdown-ork0Oir7.js +67 -0
  60. package/dist/assets/studioImages-CAyH-0Pl.js +1 -0
  61. package/dist/assets/text-ZpX7qNkx.js +2 -0
  62. package/dist/assets/time-P_OiBhcf.js +1 -0
  63. package/dist/assets/{tsMode-BXpN8iUz.js → tsMode-BOeXzO9H.js} +1 -1
  64. package/dist/assets/{typescript-DInBjGQQ.js → typescript-J1SnE_Tu.js} +1 -1
  65. package/dist/assets/{workers-C7Ye5B7D.js → workers-CYwwTiVF.js} +1 -1
  66. package/dist/assets/{xml-U0Uocqyo.js → xml-DnPRNzK9.js} +1 -1
  67. package/dist/assets/{yaml-CBw_PVYf.js → yaml-BmmYBNa9.js} +1 -1
  68. package/dist/cli/DefinitionNode-P7AA4TAU.js +15 -0
  69. package/dist/cli/Graph-OB6EWSGL.js +2975 -0
  70. package/dist/cli/assert-GROGQNCQ.js +25 -0
  71. package/dist/cli/checks-3WB44XBL.js +189 -0
  72. package/dist/cli/chunk-2JEU3MGB.js +1125 -0
  73. package/dist/cli/chunk-2KXB47FP.js +115 -0
  74. package/dist/cli/chunk-3RXL5GHB.js +816 -0
  75. package/dist/cli/chunk-53LGFPWX.js +138 -0
  76. package/dist/cli/chunk-5ORUQ6ES.js +267 -0
  77. package/dist/cli/chunk-73S4JZXK.js +336 -0
  78. package/dist/cli/chunk-7QE2ZNSN.js +121 -0
  79. package/dist/cli/chunk-BP7UKF36.js +376 -0
  80. package/dist/cli/chunk-BPODRH52.js +201 -0
  81. package/dist/cli/chunk-BZ63XQ3I.js +1301 -0
  82. package/dist/cli/chunk-CKS2FQWR.js +89 -0
  83. package/dist/cli/chunk-CO22XHNG.js +593 -0
  84. package/dist/cli/chunk-CTPLRSWF.js +2197 -0
  85. package/dist/cli/chunk-DEQSEFFH.js +153 -0
  86. package/dist/cli/chunk-EU4ZFZ7Y.js +122 -0
  87. package/dist/cli/chunk-EZRWJ4G2.js +104 -0
  88. package/dist/cli/chunk-FWMSGKEH.js +71 -0
  89. package/dist/cli/chunk-G23A2BZZ.js +705 -0
  90. package/dist/cli/chunk-GRIN2DDP.js +1465 -0
  91. package/dist/cli/chunk-HFHWYL55.js +139 -0
  92. package/dist/cli/chunk-HSNOBIVT.js +263 -0
  93. package/dist/cli/chunk-ICH7N5PN.js +26 -0
  94. package/dist/cli/chunk-J7VK7MNF.js +418 -0
  95. package/dist/cli/chunk-JVOCK5W4.js +83 -0
  96. package/dist/cli/chunk-KBGUO27Q.js +15 -0
  97. package/dist/cli/chunk-KH4MUBKF.js +1551 -0
  98. package/dist/cli/chunk-L6B6FUQP.js +330 -0
  99. package/dist/cli/chunk-LTXWBXOM.js +438 -0
  100. package/dist/cli/chunk-MI5JLQYA.js +220 -0
  101. package/dist/cli/chunk-MP653A5O.js +3766 -0
  102. package/dist/cli/chunk-NJFMDXHR.js +320 -0
  103. package/dist/cli/chunk-OM6BEME6.js +267 -0
  104. package/dist/cli/chunk-OWWBYLHC.js +136 -0
  105. package/dist/cli/chunk-QQPA2ZHH.js +273 -0
  106. package/dist/cli/chunk-RUU3YWXU.js +99 -0
  107. package/dist/cli/chunk-RXDIMXN5.js +98 -0
  108. package/dist/cli/chunk-ST6LROUG.js +267 -0
  109. package/dist/cli/chunk-TJW67QSI.js +225 -0
  110. package/dist/cli/chunk-WD62JIP6.js +118 -0
  111. package/dist/cli/chunk-WGKPJZDY.js +364 -0
  112. package/dist/cli/chunk-X4WKAOQP.js +634 -0
  113. package/dist/cli/chunk-X566FWBV.js +156 -0
  114. package/dist/cli/chunk-YH637PDL.js +317 -0
  115. package/dist/cli/chunk-ZL4JTG5Y.js +37 -0
  116. package/dist/cli/chunk-ZSCUZE6I.js +112 -0
  117. package/dist/cli/cliCommands-JJN5Z3ZC.js +3470 -0
  118. package/dist/cli/commands-PHYFYA3F.js +1374 -0
  119. package/dist/cli/contactSheet-2PQVRUFW.js +11 -0
  120. package/dist/cli/definitions-BPOPW52L.js +32 -0
  121. package/dist/cli/doctorCommand-ORWQRNYP.js +106 -0
  122. package/dist/cli/edit-S5KEQ5RA.js +28 -0
  123. package/dist/cli/editorCommands-NFR32JOY.js +41 -0
  124. package/dist/cli/encode-ICPEPMH5.js +17 -0
  125. package/dist/cli/file-3HTQHPYQ.js +41 -0
  126. package/dist/cli/filters-6ODFWYK4.js +379 -0
  127. package/dist/cli/frames-LSAUBZ7P.js +16 -0
  128. package/dist/cli/generators-YU7GB4MD.js +210 -0
  129. package/dist/cli/geo-6ZPGKZRU.js +43 -0
  130. package/dist/cli/graphCommands-EOUOBOIJ.js +184 -0
  131. package/dist/cli/graphFile-YTGJB5F5.js +292 -0
  132. package/dist/cli/headlessCanvas-ENRHC7GS.js +16 -0
  133. package/dist/cli/helpCommand-PULH6ZYB.js +157 -0
  134. package/dist/cli/image-TXELZZK5.js +55 -0
  135. package/dist/cli/index.js +100 -30756
  136. package/dist/cli/math-RSYRQ3C6.js +16 -0
  137. package/dist/cli/mcp-JVZFQOEX.js +164 -0
  138. package/dist/cli/parity-X6DEH2DV.js +334 -0
  139. package/dist/cli/pop-B7SIIYKN.js +39 -0
  140. package/dist/cli/project-VYGIA7JX.js +12 -0
  141. package/dist/cli/projectDefinition-F3D7UIHJ.js +27 -0
  142. package/dist/cli/projectRuntime-2Q4JKEH3.js +55 -0
  143. package/dist/cli/registerStandardNodes-BXJCB6E4.js +744 -0
  144. package/dist/cli/render-PT4MWI6U.js +438 -0
  145. package/dist/cli/runCommand-HNPQVZMS.js +198 -0
  146. package/dist/cli/runner-5XPXVW7J.js +43 -0
  147. package/dist/cli/runtime/image.ts +302 -0
  148. package/dist/cli/runtime/io.ts +78 -0
  149. package/dist/cli/runtime/stage.ts +4 -1
  150. package/dist/cli/share-MHF6TNRK.js +166 -0
  151. package/dist/cli/stageCache-TY2BFZJR.js +15 -0
  152. package/dist/cli/stageRunner-KY2EJP7X.js +10 -0
  153. package/dist/cli/text-MB3EKR4H.js +126 -0
  154. package/dist/cli/verbs-PI2JH5FI.js +19 -0
  155. package/dist/cli/webBuild-WPPMGGW7.js +44 -0
  156. package/dist/contracts/capabilities.d.ts +18 -1
  157. package/dist/contracts/color.d.ts +8 -0
  158. package/dist/contracts/color.js +23 -0
  159. package/dist/contracts/definition.d.ts +10 -0
  160. package/dist/contracts/documentFormat.d.ts +18 -0
  161. package/dist/contracts/documentFormat.js +195 -0
  162. package/dist/contracts/editor.d.ts +17 -0
  163. package/dist/contracts/index.d.ts +1 -0
  164. package/dist/contracts/index.js +1 -0
  165. package/dist/contracts/schema.d.ts +1 -1
  166. package/dist/contracts/schema.js +1 -0
  167. package/dist/contracts/validate.js +11 -1
  168. package/dist/contracts/values.d.ts +24 -0
  169. package/dist/image.d.ts +156 -0
  170. package/dist/image.js +161 -0
  171. package/dist/index.html +8 -2
  172. package/dist/io.d.ts +29 -0
  173. package/dist/io.js +40 -0
  174. package/dist/player/app.js +3 -2
  175. package/dist/player/editor.js +35 -9
  176. package/dist/player/editorEngine.js +3 -2
  177. package/dist/runtime/builtins/assert/checks.d.ts +18 -0
  178. package/dist/runtime/builtins/assert/checks.js +207 -0
  179. package/dist/runtime/builtins/assert/definitions.d.ts +130 -0
  180. package/dist/runtime/builtins/assert/definitions.js +54 -0
  181. package/dist/runtime/builtins/assert/index.d.ts +152 -0
  182. package/dist/runtime/builtins/assert/index.js +36 -0
  183. package/dist/runtime/builtins/image/contactSheet.d.ts +64 -0
  184. package/dist/runtime/builtins/image/contactSheet.js +150 -0
  185. package/dist/runtime/builtins/image/definitions.d.ts +950 -0
  186. package/dist/runtime/builtins/image/definitions.js +343 -0
  187. package/dist/runtime/builtins/image/file.d.ts +8 -0
  188. package/dist/runtime/builtins/image/file.js +37 -0
  189. package/dist/runtime/builtins/image/filters.d.ts +8 -0
  190. package/dist/runtime/builtins/image/filters.js +394 -0
  191. package/dist/runtime/builtins/image/generators.d.ts +7 -0
  192. package/dist/runtime/builtins/image/generators.js +144 -0
  193. package/dist/runtime/builtins/image/index.d.ts +952 -0
  194. package/dist/runtime/builtins/image/index.js +44 -0
  195. package/dist/runtime/builtins/image/io.d.ts +100 -0
  196. package/dist/runtime/builtins/image/io.js +142 -0
  197. package/dist/runtime/builtins/image/planar.d.ts +55 -0
  198. package/dist/runtime/builtins/image/planar.js +274 -0
  199. package/dist/runtime/builtins/image/simplex.d.ts +22 -0
  200. package/dist/runtime/builtins/image/simplex.js +92 -0
  201. package/dist/runtime/builtins/image/text.d.ts +4 -0
  202. package/dist/runtime/builtins/image/text.js +141 -0
  203. package/dist/runtime/builtins/index.d.ts +3 -0
  204. package/dist/runtime/builtins/index.js +7 -0
  205. package/dist/runtime/gpu.d.ts +25 -0
  206. package/dist/runtime/gpu.js +40 -0
  207. package/dist/runtime/runtime.d.ts +2 -0
  208. package/dist/runtime/runtime.js +268 -44
  209. package/dist/runtime/types.d.ts +30 -0
  210. package/dist/stage.js +4 -1
  211. package/doc/CLI_REFERENCE.md +91 -2
  212. package/doc/EDITOR_EXPORT.md +37 -2
  213. package/doc/MCP.md +18 -1
  214. package/doc/NODE_REFERENCE.md +424 -10
  215. package/doc/PROJECT_AUTHORING.md +222 -7
  216. package/package.json +19 -4
  217. package/dist/assets/CodePanel-sY6sZa7B.js +0 -2
  218. package/dist/assets/CustomNodeDialog-BRKnqZhp.js +0 -1
  219. package/dist/assets/ExportDialog-C7dVGua4.js +0 -358
  220. package/dist/assets/ExportDialog-DOq0flMV.css +0 -1
  221. package/dist/assets/OpenGraphDialog-ZsgL-iwr.js +0 -1
  222. package/dist/assets/ProjectSettings-Cw17nNe3.js +0 -2
  223. package/dist/assets/definitions-DUww2Rt-.js +0 -1
  224. package/dist/assets/geo-C2RHOVHC.js +0 -1
  225. package/dist/assets/image-DR4oeyJB.js +0 -2062
  226. package/dist/assets/index-7vae6YFC.css +0 -1
  227. package/dist/assets/index-DyvDC6pS.js +0 -219
  228. package/dist/assets/math-DaDEgWKt.js +0 -1
  229. package/dist/assets/pop-pLH7L0PW.js +0 -1
@@ -0,0 +1,210 @@
1
+ import {
2
+ Planar,
3
+ normalizeColor,
4
+ output
5
+ } from "./chunk-WGKPJZDY.js";
6
+
7
+ // packages/runtime/src/builtins/image/simplex.ts
8
+ var SQRT3 = Math.sqrt(3);
9
+ var F2 = 0.5 * (SQRT3 - 1);
10
+ var G2 = (3 - SQRT3) / 6;
11
+ var fastFloor = (x) => Math.floor(x) | 0;
12
+ var grad2 = new Float64Array([1, 1, -1, 1, 1, -1, -1, -1, 1, 0, -1, 0, 1, 0, -1, 0, 0, 1, 0, -1, 0, 1, 0, -1]);
13
+ function buildPermutationTable(random) {
14
+ const tableSize = 512;
15
+ const p = new Uint8Array(tableSize);
16
+ for (let i = 0; i < tableSize / 2; i++) p[i] = i;
17
+ for (let i = 0; i < tableSize / 2 - 1; i++) {
18
+ const r = i + ~~(random() * (256 - i));
19
+ const aux = p[i];
20
+ p[i] = p[r];
21
+ p[r] = aux;
22
+ }
23
+ for (let i = 256; i < tableSize; i++) p[i] = p[i - 256];
24
+ return p;
25
+ }
26
+ function createNoise2D(random) {
27
+ const perm = buildPermutationTable(random);
28
+ const permGrad2x = new Float64Array(perm).map((v) => grad2[v % 12 * 2]);
29
+ const permGrad2y = new Float64Array(perm).map((v) => grad2[v % 12 * 2 + 1]);
30
+ return function noise2D(x, y) {
31
+ let n0 = 0;
32
+ let n1 = 0;
33
+ let n2 = 0;
34
+ const s = (x + y) * F2;
35
+ const i = fastFloor(x + s);
36
+ const j = fastFloor(y + s);
37
+ const t = (i + j) * G2;
38
+ const X0 = i - t;
39
+ const Y0 = j - t;
40
+ const x0 = x - X0;
41
+ const y0 = y - Y0;
42
+ let i1, j1;
43
+ if (x0 > y0) {
44
+ i1 = 1;
45
+ j1 = 0;
46
+ } else {
47
+ i1 = 0;
48
+ j1 = 1;
49
+ }
50
+ const x1 = x0 - i1 + G2;
51
+ const y1 = y0 - j1 + G2;
52
+ const x2 = x0 - 1 + 2 * G2;
53
+ const y2 = y0 - 1 + 2 * G2;
54
+ const ii = i & 255;
55
+ const jj = j & 255;
56
+ let t0 = 0.5 - x0 * x0 - y0 * y0;
57
+ if (t0 >= 0) {
58
+ const gi0 = ii + perm[jj];
59
+ t0 *= t0;
60
+ n0 = t0 * t0 * (permGrad2x[gi0] * x0 + permGrad2y[gi0] * y0);
61
+ }
62
+ let t1 = 0.5 - x1 * x1 - y1 * y1;
63
+ if (t1 >= 0) {
64
+ const gi1 = ii + i1 + perm[jj + j1];
65
+ t1 *= t1;
66
+ n1 = t1 * t1 * (permGrad2x[gi1] * x1 + permGrad2y[gi1] * y1);
67
+ }
68
+ let t2 = 0.5 - x2 * x2 - y2 * y2;
69
+ if (t2 >= 0) {
70
+ const gi2 = ii + 1 + perm[jj + 1];
71
+ t2 *= t2;
72
+ n2 = t2 * t2 * (permGrad2x[gi2] * x2 + permGrad2y[gi2] * y2);
73
+ }
74
+ return 70 * (n0 + n1 + n2);
75
+ };
76
+ }
77
+
78
+ // packages/runtime/src/builtins/image/generators.ts
79
+ function size(resolution) {
80
+ return [resolution[0], resolution[1]];
81
+ }
82
+ async function executeColor(context) {
83
+ const [width, height] = size(context.props.resolution);
84
+ await output(context, Planar.solid(width, height, normalizeColor(context.props.color)));
85
+ }
86
+ async function executeCheckers(context) {
87
+ const { props } = context;
88
+ const [width, height] = size(props.resolution);
89
+ const color1 = normalizeColor(props.color1);
90
+ const color2 = normalizeColor(props.color2);
91
+ const checkerSize = props.mode === "size" ? props.size : width / props.divisions;
92
+ let offsetX = 0;
93
+ let offsetY = 0;
94
+ if (props.centered) {
95
+ offsetX = width / 2 % checkerSize - checkerSize / 2;
96
+ offsetY = height / 2 % checkerSize - checkerSize / 2;
97
+ }
98
+ const buffer = Planar.rgba(width, height);
99
+ const [r, g, b, a] = buffer.channels;
100
+ for (let y = 0; y < height; y++) {
101
+ for (let x = 0; x < width; x++) {
102
+ const idx = y * width + x;
103
+ const even = (Math.floor((x - offsetX) / checkerSize) + Math.floor((y - offsetY) / checkerSize)) % 2 === 0;
104
+ const color = even ? color1 : color2;
105
+ r[idx] = color.r;
106
+ g[idx] = color.g;
107
+ b[idx] = color.b;
108
+ a[idx] = color.a;
109
+ }
110
+ }
111
+ await output(context, buffer);
112
+ }
113
+ async function executeNoise(context) {
114
+ const { props } = context;
115
+ const [width, height] = size(props.resolution);
116
+ let rng = props.seed;
117
+ const noise2D = createNoise2D(() => {
118
+ rng = (rng * 9301 + 49297) % 233280;
119
+ return rng / 233280;
120
+ });
121
+ const buffer = Planar.grayscale(width, height);
122
+ const gray = buffer.channels[0];
123
+ for (let y = 0; y < height; y++) {
124
+ for (let x = 0; x < width; x++) {
125
+ let value = 0;
126
+ let amplitude = 1;
127
+ let frequency = props.scale;
128
+ let maxValue = 0;
129
+ for (let i = 0; i < props.iterations; i++) {
130
+ value += noise2D(x * frequency, y * frequency) * amplitude;
131
+ maxValue += amplitude;
132
+ amplitude *= 0.5;
133
+ frequency *= 2;
134
+ }
135
+ gray[y * width + x] = (value / maxValue + 1) * 0.5;
136
+ }
137
+ }
138
+ await output(context, buffer);
139
+ }
140
+ function interpolateColor(color1, color2, t, interpolation) {
141
+ if (interpolation === "constant") return t < 0.5 ? color1 : color2;
142
+ if (interpolation === "smooth") t = t * t * (3 - 2 * t);
143
+ return {
144
+ r: color1.r + (color2.r - color1.r) * t,
145
+ g: color1.g + (color2.g - color1.g) * t,
146
+ b: color1.b + (color2.b - color1.b) * t,
147
+ a: (color1.a ?? 1) + ((color2.a ?? 1) - (color1.a ?? 1)) * t
148
+ };
149
+ }
150
+ function colorAt(points, position) {
151
+ const sorted = [...points].sort((a, b) => a.position - b.position);
152
+ position = Math.max(0, Math.min(1, position));
153
+ let before = null;
154
+ let after = null;
155
+ for (const point of sorted) {
156
+ if (point.position <= position) before = point;
157
+ if (point.position >= position && !after) {
158
+ after = point;
159
+ break;
160
+ }
161
+ }
162
+ if (!before && after) return normalizeColor(after.color);
163
+ if (before && !after) return normalizeColor(before.color);
164
+ if (!before || !after) return { r: 0, g: 0, b: 0, a: 1 };
165
+ if (before.position === position) return normalizeColor(before.color);
166
+ if (after.position === position) return normalizeColor(after.color);
167
+ const t = (position - before.position) / (after.position - before.position);
168
+ return interpolateColor(normalizeColor(before.color), normalizeColor(after.color), t, after.interpolation || "linear");
169
+ }
170
+ async function executeRamp(context) {
171
+ const { props } = context;
172
+ const [width, height] = size(props.resolution);
173
+ const points = props.points ?? [];
174
+ if (points.length === 0) return;
175
+ const buffer = Planar.rgba(width, height);
176
+ const [r, g, b, a] = buffer.channels;
177
+ const centerX = width / 2;
178
+ const centerY = height / 2;
179
+ const maxDist = Math.sqrt(centerX * centerX + centerY * centerY);
180
+ for (let y = 0; y < height; y++) {
181
+ for (let x = 0; x < width; x++) {
182
+ let position = 0;
183
+ if (props.type === "horizontal") {
184
+ position = x / width;
185
+ } else if (props.type === "vertical") {
186
+ position = y / height;
187
+ } else if (props.type === "radial") {
188
+ position = (Math.atan2(y - centerY, x - centerX) + Math.PI) / (2 * Math.PI);
189
+ } else if (props.type === "concentric") {
190
+ const dx = x - centerX;
191
+ const dy = y - centerY;
192
+ position = Math.sqrt(dx * dx + dy * dy) / maxDist;
193
+ }
194
+ const color = colorAt(points, position);
195
+ const idx = y * width + x;
196
+ r[idx] = color.r;
197
+ g[idx] = color.g;
198
+ b[idx] = color.b;
199
+ a[idx] = color.a ?? 1;
200
+ }
201
+ }
202
+ await output(context, buffer);
203
+ }
204
+ export {
205
+ executeCheckers,
206
+ executeColor,
207
+ executeNoise,
208
+ executeRamp
209
+ };
210
+ //# sourceMappingURL=generators-YU7GB4MD.js.map
@@ -0,0 +1,43 @@
1
+ import {
2
+ browserAssetCapability
3
+ } from "./chunk-ZSCUZE6I.js";
4
+ import {
5
+ registerDefinitionNodes
6
+ } from "./chunk-BPODRH52.js";
7
+ import "./chunk-CTPLRSWF.js";
8
+ import "./chunk-RUU3YWXU.js";
9
+ import {
10
+ geoNodeDefinitions,
11
+ geoNodeRegistrations
12
+ } from "./chunk-GRIN2DDP.js";
13
+ import "./chunk-DEQSEFFH.js";
14
+ import "./chunk-HSNOBIVT.js";
15
+ import "./chunk-L6B6FUQP.js";
16
+ import "./chunk-HFHWYL55.js";
17
+ import "./chunk-CO22XHNG.js";
18
+ import "./chunk-J7VK7MNF.js";
19
+ import "./chunk-FWMSGKEH.js";
20
+
21
+ // src/nodes/geo/library.ts
22
+ var geoLibrary = {
23
+ id: "geo",
24
+ label: "Geometry",
25
+ icon: "Shapes",
26
+ categories: [{
27
+ id: "geometry",
28
+ label: "Geometry",
29
+ nodes: geoNodeDefinitions.map(([moduleId, definition]) => ({
30
+ name: definition.label ?? moduleId.split(".").pop(),
31
+ icon: definition.icon ?? "Shapes",
32
+ description: definition.description ?? "",
33
+ type: moduleId
34
+ }))
35
+ }]
36
+ };
37
+
38
+ // src/nodes/geo/index.ts
39
+ registerDefinitionNodes(geoNodeRegistrations, { assets: browserAssetCapability });
40
+ export {
41
+ geoLibrary
42
+ };
43
+ //# sourceMappingURL=geo-6ZPGKZRU.js.map
@@ -0,0 +1,184 @@
1
+ import {
2
+ VERBS,
3
+ graphOptions
4
+ } from "./chunk-G23A2BZZ.js";
5
+
6
+ // src/cli/graphCommands.ts
7
+ import fs from "node:fs/promises";
8
+ import path from "node:path";
9
+ var loadGraphFile = async () => (await import("./graphFile-YTGJB5F5.js")).GraphFile;
10
+ async function runGraphCommand(args, options) {
11
+ const parsed = parseArguments(args);
12
+ const [command, ...rest] = parsed.positional;
13
+ const say = options.json ? () => {
14
+ } : (line) => console.log(line);
15
+ if (command === "graph") {
16
+ const [sub, file2] = rest;
17
+ if (sub === "create") {
18
+ const created = await (await loadGraphFile()).create(required(file2, "cascade graph create <graph>"), optional(parsed.values.name));
19
+ say(`created ${created}`);
20
+ return { file: created };
21
+ }
22
+ if (sub === "read") {
23
+ const graph = await (await loadGraphFile()).open(required(file2, "cascade graph read <graph>"));
24
+ const { readGraph } = await import("./edit-S5KEQ5RA.js");
25
+ const read = readGraph(graph.document, optional(parsed.values.in, "in"));
26
+ if (!options.json) printGraph(read);
27
+ return { file: graph.file, ...read };
28
+ }
29
+ if (sub === "list") {
30
+ const listed = await listGraphs(file2 ?? ".");
31
+ for (const entry of listed) say(`${entry.file} ${entry.name ?? ""} (${entry.nodes} nodes, ${entry.wires} wires)`);
32
+ return { graphs: listed };
33
+ }
34
+ throw new Error("usage: cascade graph create|read|list ...");
35
+ }
36
+ const twoWords = command === "node" || command === "subnet";
37
+ const [file, ...operands] = twoWords ? rest.slice(1) : rest;
38
+ const graphFile = required(file, `cascade ${command} <graph> ...`);
39
+ const operations = command === "edit" ? await readOperations(required(operands[0], "cascade edit <graph> <operations.json | ->")) : [operationFor(twoWords ? `${command} ${rest[0]}` : command, operands, parsed)];
40
+ return applyEdits(graphFile, operations, { dryRun: parsed.flags.has("dry-run"), json: options.json });
41
+ }
42
+ function operationFor(name, operands, parsed) {
43
+ const verb = VERBS.find((candidate) => candidate.handler === "graph" && (candidate.name === name || candidate.aliases?.includes(name)));
44
+ if (!verb?.operation) throw new Error(`Unknown graph command: cascade ${name}. Run "cascade --help".`);
45
+ return verb.operation(operands, parsed);
46
+ }
47
+ async function applyEdits(file, operations, options = {}) {
48
+ const graph = await (await loadGraphFile()).open(file);
49
+ const outcome = await graph.applyAll(operations, { dryRun: options.dryRun === true });
50
+ if (!options.json) for (const result of outcome.results) console.log(describe(result));
51
+ for (const warning of outcome.warnings) console.warn(options.json ? warning : `warning: ${warning}`);
52
+ if (options.dryRun && !options.json) console.log("dry run: nothing written");
53
+ return { file: graph.file, changed: outcome.changed, dryRun: options.dryRun === true, results: outcome.results };
54
+ }
55
+ function describe(result) {
56
+ const node = result.node;
57
+ const at = (summary) => `${summary.position.x},${summary.position.y}`;
58
+ switch (result.op) {
59
+ case "node.add":
60
+ return `added ${node.id} (${node.module})${node.parent ? ` in ${node.parent}` : ""} at ${at(node)}`;
61
+ case "node.remove": {
62
+ const wires = result.wires;
63
+ return `removed ${result.removed.join(", ")}${wires.length ? `; unwired ${wires.join(", ")}` : ""}`;
64
+ }
65
+ case "connect": {
66
+ const moved = result.moved;
67
+ return `connected ${result.wire}${result.replaced ? ` (replaced ${result.replaced})` : ""}${moved ? `; placed ${moved.id} at ${at(moved)}` : ""}`;
68
+ }
69
+ case "disconnect":
70
+ return `disconnected ${result.removed.join(", ")}`;
71
+ case "set":
72
+ return `set ${result.node}.${result.param}: ${show(result.before)} -> ${show(result.after)}`;
73
+ case "subnet.create": {
74
+ const subnet = result.subnet;
75
+ const inputs = result.inputs;
76
+ const outputs = result.outputs;
77
+ return `created subnet ${subnet.id}${inputs.length ? `; inputs ${inputs.join(", ")}` : ""}${outputs.length ? `; outputs ${outputs.join(", ")}` : ""}`;
78
+ }
79
+ case "subnet.move":
80
+ return `moved ${result.moved.join(", ")} to ${result.to ?? "the top level"}`;
81
+ case "subnet.dissolve":
82
+ return `dissolved; lifted ${result.lifted.join(", ") || "nothing"}`;
83
+ default:
84
+ return JSON.stringify(result);
85
+ }
86
+ }
87
+ function show(value) {
88
+ return value === void 0 || value === null ? "(default)" : JSON.stringify(value);
89
+ }
90
+ function printGraph(read) {
91
+ console.log(`${read.name ?? "(untitled)"}: ${read.nodes.length} nodes, ${read.wires.length} wires`);
92
+ const byParent = /* @__PURE__ */ new Map();
93
+ for (const node of read.nodes) byParent.set(node.parent, [...byParent.get(node.parent) ?? [], node]);
94
+ const print = (parent, depth) => {
95
+ for (const node of byParent.get(parent) ?? []) {
96
+ const ports = node.ports ? ` in: ${node.ports.inputs.join(", ") || "-"} out: ${node.ports.outputs.join(", ") || "-"}` : "";
97
+ const props = node.props ? ` ${JSON.stringify(node.props)}` : "";
98
+ console.log(`${" ".repeat(depth)}${node.id} ${node.module}${ports}${props}`);
99
+ print(node.id, depth + 1);
100
+ }
101
+ };
102
+ print(read.nodes.some((node) => node.parent === null) ? null : read.nodes[0]?.parent ?? null, 1);
103
+ if (read.wires.length) console.log("wires:");
104
+ for (const wire of read.wires) console.log(` ${wire}`);
105
+ }
106
+ async function listGraphs(directory) {
107
+ const skip = /* @__PURE__ */ new Set(["node_modules", ".git", "dist", ".cascade-cache", ".cascade", "renders", "out"]);
108
+ const found = [];
109
+ const walk = async (dir, depth) => {
110
+ let entries;
111
+ try {
112
+ entries = await fs.readdir(dir, { withFileTypes: true });
113
+ } catch {
114
+ return;
115
+ }
116
+ for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {
117
+ if (entry.isDirectory() && depth < 3 && !skip.has(entry.name) && !entry.name.startsWith(".")) await walk(path.join(dir, entry.name), depth + 1);
118
+ else if (entry.isFile() && entry.name.endsWith(".cascade")) found.push(path.join(dir, entry.name));
119
+ }
120
+ };
121
+ await walk(path.resolve(directory), 0);
122
+ return Promise.all(found.map(async (file) => {
123
+ try {
124
+ const document = JSON.parse(await fs.readFile(file, "utf8"));
125
+ return {
126
+ file: path.relative(process.cwd(), file) || file,
127
+ name: typeof document.metadata?.name === "string" ? document.metadata.name : null,
128
+ nodes: Array.isArray(document.nodes) ? document.nodes.length : 0,
129
+ wires: Array.isArray(document.connections) ? document.connections.length : 0
130
+ };
131
+ } catch {
132
+ return { file: path.relative(process.cwd(), file) || file, name: null, nodes: 0, wires: 0 };
133
+ }
134
+ }));
135
+ }
136
+ async function readOperations(source) {
137
+ const text = source === "-" ? await readStdin() : await fs.readFile(source, "utf8");
138
+ const parsed = JSON.parse(text);
139
+ const operations = Array.isArray(parsed) ? parsed : parsed?.operations;
140
+ if (!Array.isArray(operations)) throw new Error('cascade edit expects a JSON array of operations, or { "operations": [...] }');
141
+ return operations;
142
+ }
143
+ async function readStdin() {
144
+ const chunks = [];
145
+ for await (const chunk of process.stdin) chunks.push(chunk);
146
+ return Buffer.concat(chunks).toString("utf8");
147
+ }
148
+ var OPTIONS = graphOptions();
149
+ function parseArguments(args) {
150
+ const positional = [];
151
+ const values = {};
152
+ const lists = {};
153
+ const flags = /* @__PURE__ */ new Set();
154
+ for (let index = 0; index < args.length; index += 1) {
155
+ const argument = args[index];
156
+ if (!argument.startsWith("--")) {
157
+ positional.push(argument);
158
+ continue;
159
+ }
160
+ const [name, inline] = argument.slice(2).split(/=(.*)/s, 2);
161
+ if (OPTIONS.flag.has(name)) {
162
+ flags.add(name);
163
+ continue;
164
+ }
165
+ if (!OPTIONS.value.has(name) && !OPTIONS.list.has(name)) throw new Error(`Unknown option --${name}`);
166
+ const value = inline ?? args[++index];
167
+ if (value === void 0) throw new Error(`--${name} needs a value`);
168
+ if (OPTIONS.list.has(name)) (lists[name] ??= []).push(value);
169
+ else values[name] = value;
170
+ }
171
+ return { positional, values, lists, flags };
172
+ }
173
+ function required(value, usage) {
174
+ if (!value) throw new Error(`usage: ${usage}`);
175
+ return value;
176
+ }
177
+ function optional(value, key = "name") {
178
+ return value === void 0 ? {} : { [key]: value };
179
+ }
180
+ export {
181
+ applyEdits,
182
+ runGraphCommand
183
+ };
184
+ //# sourceMappingURL=graphCommands-EOUOBOIJ.js.map