@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,136 @@
1
+ // packages/contracts/src/documentFormat.ts
2
+ function formatCompactJSON(jsonString, indent = 2) {
3
+ let result = jsonString;
4
+ let previousResult = "";
5
+ while (result !== previousResult) {
6
+ previousResult = result;
7
+ result = formatCompactJSONPass(result, indent);
8
+ }
9
+ return result;
10
+ }
11
+ function formatCompactJSONPass(jsonString, indent = 2) {
12
+ const lines = jsonString.split("\n");
13
+ const result = [];
14
+ let i = 0;
15
+ while (i < lines.length) {
16
+ const line = lines[i];
17
+ const trimmed = line.trim();
18
+ if (trimmed.endsWith("[") && (trimmed.includes(":") || trimmed === "[")) {
19
+ let arrayLines = [line];
20
+ let bracketDepth = 1;
21
+ let j = i + 1;
22
+ while (j < lines.length && bracketDepth > 0) {
23
+ const currentLine = lines[j];
24
+ arrayLines.push(currentLine);
25
+ for (const char of currentLine) {
26
+ if (char === "[") bracketDepth++;
27
+ if (char === "]") bracketDepth--;
28
+ }
29
+ j++;
30
+ }
31
+ const arrayContent = [];
32
+ let k = 1;
33
+ while (k < arrayLines.length - 1) {
34
+ const currentLine = arrayLines[k].trim();
35
+ if (currentLine.endsWith("[") || currentLine.startsWith("[") && !currentLine.endsWith("]")) {
36
+ let nestedArrayLines = [arrayLines[k]];
37
+ let nestedDepth = 1;
38
+ let m = k + 1;
39
+ while (m < arrayLines.length - 1 && nestedDepth > 0) {
40
+ nestedArrayLines.push(arrayLines[m]);
41
+ for (const char of arrayLines[m]) {
42
+ if (char === "[") nestedDepth++;
43
+ if (char === "]") nestedDepth--;
44
+ }
45
+ m++;
46
+ }
47
+ const nestedContent = [];
48
+ for (let n = 1; n < nestedArrayLines.length - 1; n++) {
49
+ const nestedLine = nestedArrayLines[n].trim().replace(/,$/, "").trim();
50
+ if (nestedLine) {
51
+ nestedContent.push(nestedLine);
52
+ }
53
+ }
54
+ const nestedArray = "[" + nestedContent.map((c) => c.trim()).join(", ") + "]";
55
+ arrayContent.push(nestedArray);
56
+ k = m;
57
+ } else {
58
+ const content = currentLine.replace(/,$/, "").trim();
59
+ if (content) {
60
+ arrayContent.push(content);
61
+ }
62
+ k++;
63
+ }
64
+ }
65
+ const isSmallNumericArray = arrayContent.length >= 2 && arrayContent.length <= 4 && arrayContent.every((item) => {
66
+ const trimmed2 = item.trim();
67
+ return /^-?\d+(\.\d+)?([eE][+-]?\d+)?$/.test(trimmed2);
68
+ });
69
+ let isArrayOfSmallArrays = false;
70
+ if (arrayContent.length >= 2 && arrayContent.length <= 20) {
71
+ const allAreArrays = arrayContent.every((item) => {
72
+ const trimmed2 = item.trim();
73
+ if (trimmed2.startsWith("[") && trimmed2.endsWith("]")) {
74
+ const inner = trimmed2.slice(1, -1).trim();
75
+ const parts = inner.split(",").map((p) => p.trim()).filter((p) => p);
76
+ return parts.length >= 2 && parts.length <= 4;
77
+ }
78
+ if (trimmed2.endsWith("[")) {
79
+ return true;
80
+ }
81
+ return false;
82
+ });
83
+ if (allAreArrays) {
84
+ let allSmall = true;
85
+ for (const item of arrayContent) {
86
+ const trimmed2 = item.trim();
87
+ if (trimmed2.startsWith("[") && trimmed2.endsWith("]")) {
88
+ const inner = trimmed2.slice(1, -1).trim();
89
+ const parts = inner.split(",").map((p) => p.trim()).filter((p) => p);
90
+ if (parts.length < 2 || parts.length > 4) {
91
+ allSmall = false;
92
+ break;
93
+ }
94
+ } else if (trimmed2.endsWith("[")) {
95
+ } else {
96
+ allSmall = false;
97
+ break;
98
+ }
99
+ }
100
+ isArrayOfSmallArrays = allSmall;
101
+ }
102
+ }
103
+ if (isSmallNumericArray || isArrayOfSmallArrays) {
104
+ const indentLevel = (line.match(/^(\s*)/)?.[1] || "").length;
105
+ const keyMatch = trimmed.match(/^(.+?)\s*\[\s*$/);
106
+ const keyPart = keyMatch ? keyMatch[1] : "";
107
+ const closingLine = arrayLines[arrayLines.length - 1];
108
+ const hasComma = closingLine.trim().endsWith(",");
109
+ let formattedContent;
110
+ if (isArrayOfSmallArrays) {
111
+ formattedContent = arrayContent.map((c) => {
112
+ const trimmed2 = c.trim();
113
+ if (trimmed2.startsWith("[") && trimmed2.endsWith("]")) {
114
+ return trimmed2;
115
+ }
116
+ return trimmed2;
117
+ }).join(", ");
118
+ } else {
119
+ formattedContent = arrayContent.map((c) => c.trim()).join(", ");
120
+ }
121
+ const compactArray = keyPart + " [" + formattedContent + "]" + (hasComma ? "," : "");
122
+ result.push(" ".repeat(indentLevel) + compactArray);
123
+ i = j;
124
+ continue;
125
+ }
126
+ }
127
+ result.push(line);
128
+ i++;
129
+ }
130
+ return result.join("\n");
131
+ }
132
+
133
+ export {
134
+ formatCompactJSON
135
+ };
136
+ //# sourceMappingURL=chunk-OWWBYLHC.js.map
@@ -0,0 +1,273 @@
1
+ // packages/runtime/src/builtins/math/definitions.ts
2
+ function asComponents(value, label2) {
3
+ if (typeof value === "number") return [value];
4
+ if (Array.isArray(value) && value.every((part) => typeof part === "number"))
5
+ return value;
6
+ if (value === void 0 || value === null) return [0];
7
+ throw new Error(
8
+ `${label2} needs a number or a vector of numbers, and got ${describe(value)}`
9
+ );
10
+ }
11
+ function describe(value) {
12
+ if (Array.isArray(value)) return `an array of ${value.length}`;
13
+ return `a ${typeof value}`;
14
+ }
15
+ function combine(left, right, operate) {
16
+ const a = asComponents(left, "the first input");
17
+ const b = asComponents(right, "the second input");
18
+ if (a.length !== b.length && a.length !== 1 && b.length !== 1)
19
+ throw new Error(
20
+ `cannot combine a vector of ${a.length} with a vector of ${b.length}`
21
+ );
22
+ const width = Math.max(a.length, b.length);
23
+ const out = [];
24
+ for (let index = 0; index < width; index += 1)
25
+ out.push(operate(a[a.length === 1 ? 0 : index], b[b.length === 1 ? 0 : index]));
26
+ return width === 1 ? out[0] : out;
27
+ }
28
+ function map(value, operate) {
29
+ const components = asComponents(value, "the input");
30
+ const out = components.map(operate);
31
+ return out.length === 1 ? out[0] : out;
32
+ }
33
+ function divide(a, b) {
34
+ return b === 0 ? 0 : a / b;
35
+ }
36
+ var BINARY = {
37
+ add: (a, b) => a + b,
38
+ subtract: (a, b) => a - b,
39
+ multiply: (a, b) => a * b,
40
+ divide,
41
+ power: (a, b) => a ** b,
42
+ modulo: (a, b) => b === 0 ? 0 : a % b,
43
+ min: (a, b) => Math.min(a, b),
44
+ max: (a, b) => Math.max(a, b),
45
+ atan2: (a, b) => Math.atan2(a, b)
46
+ };
47
+ var DEG = Math.PI / 180;
48
+ var UNARY = {
49
+ abs: Math.abs,
50
+ negate: (a) => -a,
51
+ floor: Math.floor,
52
+ ceil: Math.ceil,
53
+ round: Math.round,
54
+ sqrt: (a) => a < 0 ? 0 : Math.sqrt(a),
55
+ sign: Math.sign,
56
+ // Trigonometry in RADIANS, matching the expression engine, where bare `sin`
57
+ // is radians too. `radians` and `degrees` are here for the conversion, and
58
+ // the divergence from `Transform`'s degrees is recorded in AGENTS.md.
59
+ sin: Math.sin,
60
+ cos: Math.cos,
61
+ tan: Math.tan,
62
+ asin: (a) => Math.asin(Math.max(-1, Math.min(1, a))),
63
+ acos: (a) => Math.acos(Math.max(-1, Math.min(1, a))),
64
+ exp: Math.exp,
65
+ log: (a) => a <= 0 ? 0 : Math.log(a),
66
+ radians: (a) => a * DEG,
67
+ degrees: (a) => a / DEG,
68
+ /** The fractional part, always positive — `fract(-0.25)` is `0.75`, which is
69
+ * what a repeating pattern wants and what GLSL's `fract` does. */
70
+ fract: (a) => a - Math.floor(a)
71
+ };
72
+ var COMPARE = {
73
+ greater: (a, b) => a > b,
74
+ "greater-or-equal": (a, b) => a >= b,
75
+ less: (a, b) => a < b,
76
+ "less-or-equal": (a, b) => a <= b,
77
+ equal: (a, b) => a === b,
78
+ "not-equal": (a, b) => a !== b
79
+ };
80
+ function options(table) {
81
+ return Object.keys(table).map((value) => ({ value, label: label(value) }));
82
+ }
83
+ function label(value) {
84
+ return value.split("-").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
85
+ }
86
+ var binaryDefinition = {
87
+ apiVersion: 1,
88
+ label: "Binary Math",
89
+ description: "Two values, one operation. Component-wise, and a scalar broadcasts against a vector.",
90
+ icon: "Plus",
91
+ runsOn: "portable",
92
+ inputs: {
93
+ a: { kind: "data", type: "any", default: 0, description: "First value." },
94
+ b: { kind: "data", type: "any", default: 0, description: "Second value." }
95
+ },
96
+ outputs: { value: { kind: "data", type: "any" } },
97
+ props: {
98
+ operation: {
99
+ type: "string",
100
+ default: "add",
101
+ control: "select",
102
+ options: options(BINARY),
103
+ label: "Operation"
104
+ }
105
+ }
106
+ };
107
+ function executeBinary(context) {
108
+ const operate = BINARY[context.props.operation];
109
+ if (!operate)
110
+ throw new Error(
111
+ `cascade.math.Binary has no operation "${context.props.operation}"`
112
+ );
113
+ context.outputs.value.set(combine(context.inputs.a, context.inputs.b, operate));
114
+ }
115
+ var unaryDefinition = {
116
+ apiVersion: 1,
117
+ label: "Unary Math",
118
+ description: "One value, one operation. Trigonometry is in radians.",
119
+ icon: "FunctionSquare",
120
+ runsOn: "portable",
121
+ inputs: {
122
+ value: { kind: "data", type: "any", default: 0 }
123
+ },
124
+ outputs: { value: { kind: "data", type: "any" } },
125
+ props: {
126
+ operation: {
127
+ type: "string",
128
+ default: "abs",
129
+ control: "select",
130
+ options: options(UNARY),
131
+ label: "Operation"
132
+ }
133
+ }
134
+ };
135
+ function executeUnary(context) {
136
+ const operate = UNARY[context.props.operation];
137
+ if (!operate)
138
+ throw new Error(
139
+ `cascade.math.Unary has no operation "${context.props.operation}"`
140
+ );
141
+ context.outputs.value.set(map(context.inputs.value, operate));
142
+ }
143
+ var clampDefinition = {
144
+ apiVersion: 1,
145
+ label: "Clamp",
146
+ description: "Hold a value between two bounds.",
147
+ icon: "Brackets",
148
+ runsOn: "portable",
149
+ inputs: {
150
+ value: { kind: "data", type: "any", default: 0 },
151
+ min: { kind: "data", type: "any", default: 0 },
152
+ max: { kind: "data", type: "any", default: 1 }
153
+ },
154
+ outputs: { value: { kind: "data", type: "any" } },
155
+ props: {}
156
+ };
157
+ function executeClamp(context) {
158
+ const lower = combine(context.inputs.value, context.inputs.min, Math.max);
159
+ context.outputs.value.set(combine(lower, context.inputs.max, Math.min));
160
+ }
161
+ var mixDefinition = {
162
+ apiVersion: 1,
163
+ label: "Mix",
164
+ description: "Blend between two values. Houdini's lerp.",
165
+ icon: "Blend",
166
+ runsOn: "portable",
167
+ inputs: {
168
+ a: { kind: "data", type: "any", default: 0, description: "The value at 0." },
169
+ b: { kind: "data", type: "any", default: 1, description: "The value at 1." },
170
+ bias: {
171
+ kind: "data",
172
+ type: "float",
173
+ default: 0.5,
174
+ min: 0,
175
+ max: 1,
176
+ step: 0.01,
177
+ description: "Not clamped: past 0..1 this extrapolates, which is useful."
178
+ }
179
+ },
180
+ outputs: { value: { kind: "data", type: "any" } },
181
+ props: {}
182
+ };
183
+ function executeMix(context) {
184
+ const bias = context.inputs.bias ?? 0.5;
185
+ const delta = combine(context.inputs.b, context.inputs.a, (b, a) => b - a);
186
+ context.outputs.value.set(
187
+ combine(context.inputs.a, delta, (a, d) => a + d * bias)
188
+ );
189
+ }
190
+ var compareDefinition = {
191
+ apiVersion: 1,
192
+ label: "Compare",
193
+ description: "Test two values. Outputs a bool, for a Switch.",
194
+ icon: "Equal",
195
+ runsOn: "portable",
196
+ inputs: {
197
+ a: { kind: "data", type: "float", default: 0 },
198
+ b: { kind: "data", type: "float", default: 0 }
199
+ },
200
+ outputs: { result: { kind: "data", type: "bool" } },
201
+ props: {
202
+ operation: {
203
+ type: "string",
204
+ default: "greater",
205
+ control: "select",
206
+ options: options(COMPARE),
207
+ label: "Test"
208
+ },
209
+ /**
210
+ * Scalars only, unlike the rest of this namespace.
211
+ *
212
+ * "Is this vector greater than that one" has no single right answer — all
213
+ * components, any component, or the length — and a node that picked one
214
+ * silently would be wrong for the other two readings. A comparison feeding
215
+ * a `Switch` wants one boolean, so the input is a `float` and the question
216
+ * does not arise.
217
+ */
218
+ tolerance: {
219
+ type: "float",
220
+ default: 0,
221
+ min: 0,
222
+ label: "Tolerance",
223
+ description: "Slack for Equal and Not Equal. Floating point rarely lands on exactly equal."
224
+ }
225
+ }
226
+ };
227
+ function executeCompare(context) {
228
+ const operation = context.props.operation;
229
+ const test = COMPARE[operation];
230
+ if (!test)
231
+ throw new Error(`cascade.math.Compare has no test "${context.props.operation}"`);
232
+ const a = context.inputs.a ?? 0;
233
+ const b = context.inputs.b ?? 0;
234
+ const tolerance = context.props.tolerance;
235
+ if (tolerance > 0 && (operation === "equal" || operation === "not-equal")) {
236
+ const near = Math.abs(a - b) <= tolerance;
237
+ context.outputs.result.set(operation === "equal" ? near : !near);
238
+ return;
239
+ }
240
+ context.outputs.result.set(test(a, b));
241
+ }
242
+ function registration(name, definition, execute) {
243
+ return {
244
+ kind: "definition-v1",
245
+ moduleId: `cascade.math.${name}`,
246
+ definition,
247
+ loadExecute: async () => execute
248
+ };
249
+ }
250
+ var binaryRegistration = registration("Binary", binaryDefinition, executeBinary);
251
+ var unaryRegistration = registration("Unary", unaryDefinition, executeUnary);
252
+ var clampRegistration = registration("Clamp", clampDefinition, executeClamp);
253
+ var mixRegistration = registration("Mix", mixDefinition, executeMix);
254
+ var compareRegistration = registration("Compare", compareDefinition, executeCompare);
255
+ var mathNodeRegistrations = Object.freeze([
256
+ binaryRegistration,
257
+ unaryRegistration,
258
+ clampRegistration,
259
+ mixRegistration,
260
+ compareRegistration
261
+ ]);
262
+ var mathNodeDefinitions = Object.freeze([
263
+ ["cascade.math.Binary", binaryDefinition],
264
+ ["cascade.math.Unary", unaryDefinition],
265
+ ["cascade.math.Clamp", clampDefinition],
266
+ ["cascade.math.Mix", mixDefinition],
267
+ ["cascade.math.Compare", compareDefinition]
268
+ ]);
269
+
270
+ export {
271
+ mathNodeRegistrations
272
+ };
273
+ //# sourceMappingURL=chunk-QQPA2ZHH.js.map
@@ -0,0 +1,99 @@
1
+ import {
2
+ ExpressionEvaluator,
3
+ parseBundleFieldPath
4
+ } from "./chunk-CO22XHNG.js";
5
+
6
+ // src/engine/expressions/ExpressionEngine.ts
7
+ var ExpressionEngine = class extends ExpressionEvaluator {
8
+ constructor() {
9
+ super();
10
+ this.graph = null;
11
+ const scope = {
12
+ resolveParam: (from, path) => this.resolveNodePath(from, path),
13
+ nodeExists: (from, path) => from.node(path) !== null,
14
+ inputNode: (from, index) => this.resolveInput(from, index)
15
+ };
16
+ this.setScope(scope);
17
+ }
18
+ /**
19
+ * Set the graph reference for node lookups
20
+ */
21
+ setGraph(graph) {
22
+ this.graph = graph;
23
+ }
24
+ /**
25
+ * Resolve a path to get the parameter value
26
+ */
27
+ resolveNodePath(fromNode, path) {
28
+ const lastSlash = path.lastIndexOf("/");
29
+ if (lastSlash === -1 || path.startsWith("./")) {
30
+ const paramName2 = path.replace("./", "");
31
+ const prop2 = fromNode.props[paramName2];
32
+ if (prop2) return { value: prop2.value };
33
+ return this.resolveBundleField(fromNode, paramName2);
34
+ }
35
+ const nodePath = path.substring(0, lastSlash) || ".";
36
+ const paramName = path.substring(lastSlash + 1);
37
+ const targetNode = fromNode.node(nodePath);
38
+ if (!targetNode) return null;
39
+ const prop = targetNode.props[paramName];
40
+ return prop ? { value: prop.value } : null;
41
+ }
42
+ /**
43
+ * `format.dpi`: field `dpi` of the bundle wired into this node's `format`
44
+ * input. Read off the input port, so it is whatever the producer committed
45
+ * on its last cook, which the wire guarantees came first.
46
+ */
47
+ resolveBundleField(node, name) {
48
+ const reference = parseBundleFieldPath(name);
49
+ if (!reference) return null;
50
+ const port = node.inputs.find((input) => input.name === reference.port);
51
+ if (!port || port.dataType !== "bundle") return null;
52
+ const bundle = port.value;
53
+ if (bundle === null || typeof bundle !== "object") return null;
54
+ if (!Object.prototype.hasOwnProperty.call(bundle, reference.field)) return null;
55
+ return { value: bundle[reference.field] };
56
+ }
57
+ /**
58
+ * Get input node by index
59
+ */
60
+ resolveInput(node, index) {
61
+ if (!this.graph) return null;
62
+ const inputPort = node.inputs[index];
63
+ if (!inputPort || inputPort.connections.length === 0) return null;
64
+ const conn = inputPort.connections[0];
65
+ return this.graph.getNode(conn.from.nodeId);
66
+ }
67
+ /**
68
+ * Validate all expression paths in the graph
69
+ * Returns list of broken paths with their locations
70
+ */
71
+ validateAllPaths() {
72
+ if (!this.graph) return [];
73
+ const warnings = [];
74
+ for (const node of this.graph.nodes) {
75
+ for (const [propKey, prop] of Object.entries(node.props)) {
76
+ if (!prop.expression) continue;
77
+ const paths = this.extractDependencies(prop.expression);
78
+ for (const path of paths) {
79
+ if (!this.validatePath(node, path)) {
80
+ warnings.push({
81
+ nodeId: node.id,
82
+ nodePath: node.path(),
83
+ propName: propKey,
84
+ expression: prop.expression,
85
+ brokenPath: path
86
+ });
87
+ }
88
+ }
89
+ }
90
+ }
91
+ return warnings;
92
+ }
93
+ };
94
+ var expressionEngine = new ExpressionEngine();
95
+
96
+ export {
97
+ expressionEngine
98
+ };
99
+ //# sourceMappingURL=chunk-RUU3YWXU.js.map
@@ -0,0 +1,98 @@
1
+ // packages/runtime/src/builtins/core/random.ts
2
+ var randomDefinition = {
3
+ apiVersion: 1,
4
+ label: "Random",
5
+ description: "Generate a deterministic unit value from an explicit seed.",
6
+ icon: "Dice5",
7
+ runsOn: "portable",
8
+ inputs: {
9
+ seed: {
10
+ kind: "data",
11
+ type: "int",
12
+ default: 0,
13
+ description: "Integer seed. Equal seeds always produce equal values."
14
+ },
15
+ sample: {
16
+ kind: "data",
17
+ type: "int",
18
+ default: 0,
19
+ description: "Stable sample index within the seeded sequence."
20
+ }
21
+ },
22
+ outputs: {
23
+ value: {
24
+ kind: "data",
25
+ type: "float",
26
+ description: "Deterministic value in the half-open range [0, 1)."
27
+ }
28
+ }
29
+ };
30
+ function randomFromSeed(seed, sample = 0) {
31
+ const streamSeed = (Math.trunc(seed) ^ Math.imul(Math.trunc(sample), 2654435761)) >>> 0;
32
+ let value = streamSeed + 1831565813 >>> 0;
33
+ value = Math.imul(value ^ value >>> 15, value | 1);
34
+ value ^= value + Math.imul(value ^ value >>> 7, value | 61);
35
+ return ((value ^ value >>> 14) >>> 0) / 4294967296;
36
+ }
37
+ function executeRandom(context) {
38
+ context.outputs.value.set(randomFromSeed(context.inputs.seed, context.inputs.sample));
39
+ }
40
+ var randomRegistration = {
41
+ kind: "definition-v1",
42
+ moduleId: "cascade.core.Random",
43
+ definition: randomDefinition,
44
+ loadExecute: async () => executeRandom
45
+ };
46
+
47
+ // packages/runtime/src/builtins/core/remap.ts
48
+ var remapDefinition = {
49
+ apiVersion: 1,
50
+ label: "Remap",
51
+ description: "Map a number from one range into another.",
52
+ icon: "ArrowRightLeft",
53
+ runsOn: "portable",
54
+ inputs: {
55
+ value: { kind: "data", type: "float", default: 0 },
56
+ inMin: { kind: "data", type: "float", default: 0 },
57
+ inMax: { kind: "data", type: "float", default: 1 },
58
+ outMin: { kind: "data", type: "float", default: 0 },
59
+ outMax: { kind: "data", type: "float", default: 1 }
60
+ },
61
+ outputs: {
62
+ result: { kind: "data", type: "float" }
63
+ },
64
+ props: {
65
+ clamp: {
66
+ type: "bool",
67
+ default: false,
68
+ label: "Clamp",
69
+ description: "Keep the normalized input between zero and one."
70
+ }
71
+ }
72
+ };
73
+ function remap(value, inMin, inMax, outMin, outMax, clamp) {
74
+ if (inMin === inMax) return outMin;
75
+ const normalized = (value - inMin) / (inMax - inMin);
76
+ const amount = clamp ? Math.min(1, Math.max(0, normalized)) : normalized;
77
+ return outMin + amount * (outMax - outMin);
78
+ }
79
+ function executeRemap(context) {
80
+ const { value, inMin, inMax, outMin, outMax } = context.inputs;
81
+ context.outputs.result.set(
82
+ remap(value, inMin, inMax, outMin, outMax, context.props.clamp)
83
+ );
84
+ }
85
+ var remapRegistration = {
86
+ kind: "definition-v1",
87
+ moduleId: "cascade.core.Remap",
88
+ definition: remapDefinition,
89
+ loadExecute: async () => executeRemap
90
+ };
91
+
92
+ export {
93
+ randomFromSeed,
94
+ randomRegistration,
95
+ remap,
96
+ remapRegistration
97
+ };
98
+ //# sourceMappingURL=chunk-RXDIMXN5.js.map