@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.
- package/AGENTS.md +25 -5
- package/ARCHITECTURE.md +5 -4
- package/CHANGELOG.md +382 -0
- package/README.md +1 -2
- package/dist/assets/AgentPanel-1JugFjE4.css +1 -0
- package/dist/assets/AgentPanel-BDL5MddA.js +5 -0
- package/dist/assets/{CodeEditor-DSZBpzdy.js → CodeEditor-C-xYG-Wn.js} +120 -120
- package/dist/assets/CodePanel-CtXd50m6.js +2 -0
- package/dist/assets/CookInfoPanel-B3NMhKJF.css +1 -0
- package/dist/assets/CookInfoPanel-DG4_TRsX.js +2 -0
- package/dist/assets/CustomNodeDialog-CHfZUs-r.js +1 -0
- package/dist/assets/DefinitionNode-CaRTXQ_b.js +1 -0
- package/dist/assets/DefinitionPanel-C3CxZY9r.js +1 -0
- package/dist/assets/DefinitionPanel-VNLnAiQD.css +1 -0
- package/dist/assets/OpenGraphDialog-BLdr6k_q.js +1 -0
- package/dist/assets/ProjectSettings-ZnvmIAir.js +2 -0
- package/dist/assets/{SettingsDialog-p25h3tj0.js → SettingsDialog-CBX3Wa87.js} +1 -1
- package/dist/assets/TimelinePanel-CDeR0arY.css +1 -0
- package/dist/assets/TimelinePanel-CWgnFH1e.js +1 -0
- package/dist/assets/{VersionHistoryDialog-DzFLUotB.js → VersionHistoryDialog-BOSoW1R-.js} +1 -1
- package/dist/assets/assert-BO2_erPD.js +1 -0
- package/dist/assets/assert-hvykGCnP.js +1 -0
- package/dist/assets/builder-BmBKcDix.js +1 -0
- package/dist/assets/camera-DFF7YA3F.js +1 -0
- package/dist/assets/checks-DAvyO9Gf.js +1 -0
- package/dist/assets/contactSheet-N1NcaWxw.js +2 -0
- package/dist/assets/{core-BICrEt0y.js → core-DB-MkGjj.js} +3 -4
- package/dist/assets/coreTypes-DtnDATZ7.js +1 -0
- package/dist/assets/{cssMode-D7TXw57I.js → cssMode-DPVckSOc.js} +1 -1
- package/dist/assets/definitions-B227e7f_.js +1 -0
- package/dist/assets/definitions-D0WOUJd7.js +1 -0
- package/dist/assets/{editor.api-DvkCO3ko.js → editor.api-Dkutg_Z1.js} +1 -1
- package/dist/assets/expressions-X-Z-GrgW.js +5 -0
- package/dist/assets/file-DAL6IfjV.js +1 -0
- package/dist/assets/filters-D3k1LRMa.js +1 -0
- package/dist/assets/{freemarker2-BA2lxsF1.js → freemarker2-CLiLKk3B.js} +1 -1
- package/dist/assets/generators-BhDxRAFC.js +1 -0
- package/dist/assets/geo-BsMImJIJ.js +1 -0
- package/dist/assets/geo-C4YngDob.js +2 -0
- package/dist/assets/{handlebars-BcDiyPd8.js → handlebars-CcD3aMeL.js} +1 -1
- package/dist/assets/{html-C7O4TyhX.js → html-DvZWGfqb.js} +1 -1
- package/dist/assets/{htmlMode-WaDGF3Mj.js → htmlMode-DUD3VaoN.js} +1 -1
- package/dist/assets/image-0SfH-snh.js +1 -0
- package/dist/assets/image-Ck-RdGU4.js +2 -0
- package/dist/assets/index-BWnrmIB9.js +137 -0
- package/dist/assets/index-DIaxEONI.css +1 -0
- package/dist/assets/io-BGmt2g0D.js +1 -0
- package/dist/assets/{javascript-CpIEK7tz.js → javascript-Cap2ahgh.js} +1 -1
- package/dist/assets/{jsonMode-B2FltW0f.js → jsonMode-B0uLjp9C.js} +1 -1
- package/dist/assets/{liquid-CN6FFHZE.js → liquid-CnxwhfLn.js} +1 -1
- package/dist/assets/{lspLanguageFeatures-QhV9XtLp.js → lspLanguageFeatures-Dn9hlKX6.js} +1 -1
- package/dist/assets/math-GeULS-sk.js +1 -0
- package/dist/assets/{mdx-DE89pafV.js → mdx-BV3jbrVa.js} +1 -1
- package/dist/assets/pop-KMF_qloi.js +1 -0
- package/dist/assets/preload-helper-Czpn1I53.js +1 -0
- package/dist/assets/{python-ByTllTB9.js → python-CGyFk4XK.js} +1 -1
- package/dist/assets/{razor-USYlRRCE.js → razor-CQfzX3-N.js} +1 -1
- package/dist/assets/remap-5SjXQU-q.js +1 -0
- package/dist/assets/renderMarkdown-ork0Oir7.js +67 -0
- package/dist/assets/studioImages-CAyH-0Pl.js +1 -0
- package/dist/assets/text-ZpX7qNkx.js +2 -0
- package/dist/assets/time-P_OiBhcf.js +1 -0
- package/dist/assets/{tsMode-BXpN8iUz.js → tsMode-BOeXzO9H.js} +1 -1
- package/dist/assets/{typescript-DInBjGQQ.js → typescript-J1SnE_Tu.js} +1 -1
- package/dist/assets/{workers-C7Ye5B7D.js → workers-CYwwTiVF.js} +1 -1
- package/dist/assets/{xml-U0Uocqyo.js → xml-DnPRNzK9.js} +1 -1
- package/dist/assets/{yaml-CBw_PVYf.js → yaml-BmmYBNa9.js} +1 -1
- package/dist/cli/DefinitionNode-P7AA4TAU.js +15 -0
- package/dist/cli/Graph-OB6EWSGL.js +2975 -0
- package/dist/cli/assert-GROGQNCQ.js +25 -0
- package/dist/cli/checks-3WB44XBL.js +189 -0
- package/dist/cli/chunk-2JEU3MGB.js +1125 -0
- package/dist/cli/chunk-2KXB47FP.js +115 -0
- package/dist/cli/chunk-3RXL5GHB.js +816 -0
- package/dist/cli/chunk-53LGFPWX.js +138 -0
- package/dist/cli/chunk-5ORUQ6ES.js +267 -0
- package/dist/cli/chunk-73S4JZXK.js +336 -0
- package/dist/cli/chunk-7QE2ZNSN.js +121 -0
- package/dist/cli/chunk-BP7UKF36.js +376 -0
- package/dist/cli/chunk-BPODRH52.js +201 -0
- package/dist/cli/chunk-BZ63XQ3I.js +1301 -0
- package/dist/cli/chunk-CKS2FQWR.js +89 -0
- package/dist/cli/chunk-CO22XHNG.js +593 -0
- package/dist/cli/chunk-CTPLRSWF.js +2197 -0
- package/dist/cli/chunk-DEQSEFFH.js +153 -0
- package/dist/cli/chunk-EU4ZFZ7Y.js +122 -0
- package/dist/cli/chunk-EZRWJ4G2.js +104 -0
- package/dist/cli/chunk-FWMSGKEH.js +71 -0
- package/dist/cli/chunk-G23A2BZZ.js +705 -0
- package/dist/cli/chunk-GRIN2DDP.js +1465 -0
- package/dist/cli/chunk-HFHWYL55.js +139 -0
- package/dist/cli/chunk-HSNOBIVT.js +263 -0
- package/dist/cli/chunk-ICH7N5PN.js +26 -0
- package/dist/cli/chunk-J7VK7MNF.js +418 -0
- package/dist/cli/chunk-JVOCK5W4.js +83 -0
- package/dist/cli/chunk-KBGUO27Q.js +15 -0
- package/dist/cli/chunk-KH4MUBKF.js +1551 -0
- package/dist/cli/chunk-L6B6FUQP.js +330 -0
- package/dist/cli/chunk-LTXWBXOM.js +438 -0
- package/dist/cli/chunk-MI5JLQYA.js +220 -0
- package/dist/cli/chunk-MP653A5O.js +3766 -0
- package/dist/cli/chunk-NJFMDXHR.js +320 -0
- package/dist/cli/chunk-OM6BEME6.js +267 -0
- package/dist/cli/chunk-OWWBYLHC.js +136 -0
- package/dist/cli/chunk-QQPA2ZHH.js +273 -0
- package/dist/cli/chunk-RUU3YWXU.js +99 -0
- package/dist/cli/chunk-RXDIMXN5.js +98 -0
- package/dist/cli/chunk-ST6LROUG.js +267 -0
- package/dist/cli/chunk-TJW67QSI.js +225 -0
- package/dist/cli/chunk-WD62JIP6.js +118 -0
- package/dist/cli/chunk-WGKPJZDY.js +364 -0
- package/dist/cli/chunk-X4WKAOQP.js +634 -0
- package/dist/cli/chunk-X566FWBV.js +156 -0
- package/dist/cli/chunk-YH637PDL.js +317 -0
- package/dist/cli/chunk-ZL4JTG5Y.js +37 -0
- package/dist/cli/chunk-ZSCUZE6I.js +112 -0
- package/dist/cli/cliCommands-JJN5Z3ZC.js +3470 -0
- package/dist/cli/commands-PHYFYA3F.js +1374 -0
- package/dist/cli/contactSheet-2PQVRUFW.js +11 -0
- package/dist/cli/definitions-BPOPW52L.js +32 -0
- package/dist/cli/doctorCommand-ORWQRNYP.js +106 -0
- package/dist/cli/edit-S5KEQ5RA.js +28 -0
- package/dist/cli/editorCommands-NFR32JOY.js +41 -0
- package/dist/cli/encode-ICPEPMH5.js +17 -0
- package/dist/cli/file-3HTQHPYQ.js +41 -0
- package/dist/cli/filters-6ODFWYK4.js +379 -0
- package/dist/cli/frames-LSAUBZ7P.js +16 -0
- package/dist/cli/generators-YU7GB4MD.js +210 -0
- package/dist/cli/geo-6ZPGKZRU.js +43 -0
- package/dist/cli/graphCommands-EOUOBOIJ.js +184 -0
- package/dist/cli/graphFile-YTGJB5F5.js +292 -0
- package/dist/cli/headlessCanvas-ENRHC7GS.js +16 -0
- package/dist/cli/helpCommand-PULH6ZYB.js +157 -0
- package/dist/cli/image-TXELZZK5.js +55 -0
- package/dist/cli/index.js +100 -30756
- package/dist/cli/math-RSYRQ3C6.js +16 -0
- package/dist/cli/mcp-JVZFQOEX.js +164 -0
- package/dist/cli/parity-X6DEH2DV.js +334 -0
- package/dist/cli/pop-B7SIIYKN.js +39 -0
- package/dist/cli/project-VYGIA7JX.js +12 -0
- package/dist/cli/projectDefinition-F3D7UIHJ.js +27 -0
- package/dist/cli/projectRuntime-2Q4JKEH3.js +55 -0
- package/dist/cli/registerStandardNodes-BXJCB6E4.js +744 -0
- package/dist/cli/render-PT4MWI6U.js +438 -0
- package/dist/cli/runCommand-HNPQVZMS.js +198 -0
- package/dist/cli/runner-5XPXVW7J.js +43 -0
- package/dist/cli/runtime/image.ts +302 -0
- package/dist/cli/runtime/io.ts +78 -0
- package/dist/cli/runtime/stage.ts +4 -1
- package/dist/cli/share-MHF6TNRK.js +166 -0
- package/dist/cli/stageCache-TY2BFZJR.js +15 -0
- package/dist/cli/stageRunner-KY2EJP7X.js +10 -0
- package/dist/cli/text-MB3EKR4H.js +126 -0
- package/dist/cli/verbs-PI2JH5FI.js +19 -0
- package/dist/cli/webBuild-WPPMGGW7.js +44 -0
- package/dist/contracts/capabilities.d.ts +18 -1
- package/dist/contracts/color.d.ts +8 -0
- package/dist/contracts/color.js +23 -0
- package/dist/contracts/definition.d.ts +10 -0
- package/dist/contracts/documentFormat.d.ts +18 -0
- package/dist/contracts/documentFormat.js +195 -0
- package/dist/contracts/editor.d.ts +17 -0
- package/dist/contracts/index.d.ts +1 -0
- package/dist/contracts/index.js +1 -0
- package/dist/contracts/schema.d.ts +1 -1
- package/dist/contracts/schema.js +1 -0
- package/dist/contracts/validate.js +11 -1
- package/dist/contracts/values.d.ts +24 -0
- package/dist/image.d.ts +156 -0
- package/dist/image.js +161 -0
- package/dist/index.html +8 -2
- package/dist/io.d.ts +29 -0
- package/dist/io.js +40 -0
- package/dist/player/app.js +3 -2
- package/dist/player/editor.js +35 -9
- package/dist/player/editorEngine.js +3 -2
- package/dist/runtime/builtins/assert/checks.d.ts +18 -0
- package/dist/runtime/builtins/assert/checks.js +207 -0
- package/dist/runtime/builtins/assert/definitions.d.ts +130 -0
- package/dist/runtime/builtins/assert/definitions.js +54 -0
- package/dist/runtime/builtins/assert/index.d.ts +152 -0
- package/dist/runtime/builtins/assert/index.js +36 -0
- package/dist/runtime/builtins/image/contactSheet.d.ts +64 -0
- package/dist/runtime/builtins/image/contactSheet.js +150 -0
- package/dist/runtime/builtins/image/definitions.d.ts +950 -0
- package/dist/runtime/builtins/image/definitions.js +343 -0
- package/dist/runtime/builtins/image/file.d.ts +8 -0
- package/dist/runtime/builtins/image/file.js +37 -0
- package/dist/runtime/builtins/image/filters.d.ts +8 -0
- package/dist/runtime/builtins/image/filters.js +394 -0
- package/dist/runtime/builtins/image/generators.d.ts +7 -0
- package/dist/runtime/builtins/image/generators.js +144 -0
- package/dist/runtime/builtins/image/index.d.ts +952 -0
- package/dist/runtime/builtins/image/index.js +44 -0
- package/dist/runtime/builtins/image/io.d.ts +100 -0
- package/dist/runtime/builtins/image/io.js +142 -0
- package/dist/runtime/builtins/image/planar.d.ts +55 -0
- package/dist/runtime/builtins/image/planar.js +274 -0
- package/dist/runtime/builtins/image/simplex.d.ts +22 -0
- package/dist/runtime/builtins/image/simplex.js +92 -0
- package/dist/runtime/builtins/image/text.d.ts +4 -0
- package/dist/runtime/builtins/image/text.js +141 -0
- package/dist/runtime/builtins/index.d.ts +3 -0
- package/dist/runtime/builtins/index.js +7 -0
- package/dist/runtime/gpu.d.ts +25 -0
- package/dist/runtime/gpu.js +40 -0
- package/dist/runtime/runtime.d.ts +2 -0
- package/dist/runtime/runtime.js +268 -44
- package/dist/runtime/types.d.ts +30 -0
- package/dist/stage.js +4 -1
- package/doc/CLI_REFERENCE.md +91 -2
- package/doc/EDITOR_EXPORT.md +37 -2
- package/doc/MCP.md +18 -1
- package/doc/NODE_REFERENCE.md +424 -10
- package/doc/PROJECT_AUTHORING.md +222 -7
- package/package.json +19 -4
- package/dist/assets/CodePanel-sY6sZa7B.js +0 -2
- package/dist/assets/CustomNodeDialog-BRKnqZhp.js +0 -1
- package/dist/assets/ExportDialog-C7dVGua4.js +0 -358
- package/dist/assets/ExportDialog-DOq0flMV.css +0 -1
- package/dist/assets/OpenGraphDialog-ZsgL-iwr.js +0 -1
- package/dist/assets/ProjectSettings-Cw17nNe3.js +0 -2
- package/dist/assets/definitions-DUww2Rt-.js +0 -1
- package/dist/assets/geo-C2RHOVHC.js +0 -1
- package/dist/assets/image-DR4oeyJB.js +0 -2062
- package/dist/assets/index-7vae6YFC.css +0 -1
- package/dist/assets/index-DyvDC6pS.js +0 -219
- package/dist/assets/math-DaDEgWKt.js +0 -1
- package/dist/assets/pop-pLH7L0PW.js +0 -1
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
// packages/runtime/src/camera/index.ts
|
|
2
|
+
var DEG = Math.PI / 180;
|
|
3
|
+
function cross(a, b) {
|
|
4
|
+
return [
|
|
5
|
+
a[1] * b[2] - a[2] * b[1],
|
|
6
|
+
a[2] * b[0] - a[0] * b[2],
|
|
7
|
+
a[0] * b[1] - a[1] * b[0]
|
|
8
|
+
];
|
|
9
|
+
}
|
|
10
|
+
function normalize(v) {
|
|
11
|
+
const length = Math.hypot(v[0], v[1], v[2]);
|
|
12
|
+
if (length === 0) return [0, 0, 0];
|
|
13
|
+
return [v[0] / length, v[1] / length, v[2] / length];
|
|
14
|
+
}
|
|
15
|
+
function subtract(a, b) {
|
|
16
|
+
return [a[0] - b[0], a[1] - b[1], a[2] - b[2]];
|
|
17
|
+
}
|
|
18
|
+
function dot(a, b) {
|
|
19
|
+
return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
|
|
20
|
+
}
|
|
21
|
+
function lookAtRotation(from, to, up = [0, 1, 0]) {
|
|
22
|
+
const forward = normalize(subtract(to, from));
|
|
23
|
+
if (forward[0] === 0 && forward[1] === 0 && forward[2] === 0) return [0, 0, 0];
|
|
24
|
+
const horizontal = Math.hypot(forward[0], forward[2]);
|
|
25
|
+
const pitch = Math.atan2(forward[1], horizontal);
|
|
26
|
+
const yaw = Math.atan2(-forward[0], -forward[2]);
|
|
27
|
+
return [pitch / DEG, yaw / DEG, rollTowards(forward, pitch, yaw, up) / DEG];
|
|
28
|
+
}
|
|
29
|
+
function rollTowards(forward, pitch, yaw, up) {
|
|
30
|
+
const desired = normalize([
|
|
31
|
+
up[0] - forward[0] * dot(up, forward),
|
|
32
|
+
up[1] - forward[1] * dot(up, forward),
|
|
33
|
+
up[2] - forward[2] * dot(up, forward)
|
|
34
|
+
]);
|
|
35
|
+
if (desired[0] === 0 && desired[1] === 0 && desired[2] === 0) return 0;
|
|
36
|
+
const locked = cameraBasis({
|
|
37
|
+
...CAMERA_ROTATION_ONLY,
|
|
38
|
+
rotate: [pitch / DEG, yaw / DEG, 0]
|
|
39
|
+
}).up;
|
|
40
|
+
return Math.atan2(dot(cross(desired, locked), forward), dot(locked, desired));
|
|
41
|
+
}
|
|
42
|
+
var CAMERA_ROTATION_ONLY = {
|
|
43
|
+
translate: [0, 0, 0],
|
|
44
|
+
focal: 50,
|
|
45
|
+
aperture: 41.4214,
|
|
46
|
+
near: 1e-3,
|
|
47
|
+
far: 1e4,
|
|
48
|
+
resolution: [1, 1],
|
|
49
|
+
aspect: 1,
|
|
50
|
+
projection: "perspective",
|
|
51
|
+
orthowidth: 2
|
|
52
|
+
};
|
|
53
|
+
function cameraBasis(camera) {
|
|
54
|
+
const [rx, ry, rz] = camera.rotate;
|
|
55
|
+
const sx = Math.sin(rx * DEG);
|
|
56
|
+
const cx = Math.cos(rx * DEG);
|
|
57
|
+
const sy = Math.sin(ry * DEG);
|
|
58
|
+
const cy = Math.cos(ry * DEG);
|
|
59
|
+
const sz = Math.sin(rz * DEG);
|
|
60
|
+
const cz = Math.cos(rz * DEG);
|
|
61
|
+
const m00 = cy * cz + sy * sx * sz;
|
|
62
|
+
const m01 = -cy * sz + sy * sx * cz;
|
|
63
|
+
const m02 = sy * cx;
|
|
64
|
+
const m10 = cx * sz;
|
|
65
|
+
const m11 = cx * cz;
|
|
66
|
+
const m12 = -sx;
|
|
67
|
+
const m20 = -sy * cz + cy * sx * sz;
|
|
68
|
+
const m21 = sy * sz + cy * sx * cz;
|
|
69
|
+
const m22 = cy * cx;
|
|
70
|
+
const right = [m00, m10, m20];
|
|
71
|
+
const up = [m01, m11, m21];
|
|
72
|
+
const forward = [-m02, -m12, -m22];
|
|
73
|
+
return { eye: camera.translate, forward, right, up };
|
|
74
|
+
}
|
|
75
|
+
function frameAspect(camera) {
|
|
76
|
+
const [width, height] = camera.resolution;
|
|
77
|
+
if (height === 0) return 1;
|
|
78
|
+
return width * camera.aspect / height;
|
|
79
|
+
}
|
|
80
|
+
function viewMatrix(camera) {
|
|
81
|
+
const { eye, forward, right, up } = cameraBasis(camera);
|
|
82
|
+
const back = [-forward[0], -forward[1], -forward[2]];
|
|
83
|
+
return [
|
|
84
|
+
right[0],
|
|
85
|
+
up[0],
|
|
86
|
+
back[0],
|
|
87
|
+
0,
|
|
88
|
+
right[1],
|
|
89
|
+
up[1],
|
|
90
|
+
back[1],
|
|
91
|
+
0,
|
|
92
|
+
right[2],
|
|
93
|
+
up[2],
|
|
94
|
+
back[2],
|
|
95
|
+
0,
|
|
96
|
+
-(right[0] * eye[0] + right[1] * eye[1] + right[2] * eye[2]),
|
|
97
|
+
-(up[0] * eye[0] + up[1] * eye[1] + up[2] * eye[2]),
|
|
98
|
+
-(back[0] * eye[0] + back[1] * eye[1] + back[2] * eye[2]),
|
|
99
|
+
1
|
|
100
|
+
];
|
|
101
|
+
}
|
|
102
|
+
function projectionMatrix(camera) {
|
|
103
|
+
const { near, far } = camera;
|
|
104
|
+
const aspect = frameAspect(camera);
|
|
105
|
+
if (camera.projection === "orthographic") {
|
|
106
|
+
const halfWidth = camera.orthowidth / 2;
|
|
107
|
+
const halfHeight = aspect === 0 ? halfWidth : halfWidth / aspect;
|
|
108
|
+
return [
|
|
109
|
+
1 / halfWidth,
|
|
110
|
+
0,
|
|
111
|
+
0,
|
|
112
|
+
0,
|
|
113
|
+
0,
|
|
114
|
+
1 / halfHeight,
|
|
115
|
+
0,
|
|
116
|
+
0,
|
|
117
|
+
0,
|
|
118
|
+
0,
|
|
119
|
+
-2 / (far - near),
|
|
120
|
+
0,
|
|
121
|
+
0,
|
|
122
|
+
0,
|
|
123
|
+
-(far + near) / (far - near),
|
|
124
|
+
1
|
|
125
|
+
];
|
|
126
|
+
}
|
|
127
|
+
const focalScale = 2 * camera.focal / camera.aperture;
|
|
128
|
+
return [
|
|
129
|
+
focalScale,
|
|
130
|
+
0,
|
|
131
|
+
0,
|
|
132
|
+
0,
|
|
133
|
+
0,
|
|
134
|
+
focalScale * aspect,
|
|
135
|
+
0,
|
|
136
|
+
0,
|
|
137
|
+
0,
|
|
138
|
+
0,
|
|
139
|
+
-(far + near) / (far - near),
|
|
140
|
+
-1,
|
|
141
|
+
0,
|
|
142
|
+
0,
|
|
143
|
+
-2 * far * near / (far - near),
|
|
144
|
+
0
|
|
145
|
+
];
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export {
|
|
149
|
+
lookAtRotation,
|
|
150
|
+
viewMatrix,
|
|
151
|
+
projectionMatrix
|
|
152
|
+
};
|
|
153
|
+
//# sourceMappingURL=chunk-DEQSEFFH.js.map
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import {
|
|
2
|
+
readProjectManifest
|
|
3
|
+
} from "./chunk-2JEU3MGB.js";
|
|
4
|
+
|
|
5
|
+
// server/src/compile.ts
|
|
6
|
+
import * as esbuild from "esbuild";
|
|
7
|
+
import fs from "fs";
|
|
8
|
+
import path from "path";
|
|
9
|
+
import { fileURLToPath } from "url";
|
|
10
|
+
var __dirname_compile = path.dirname(fileURLToPath(import.meta.url));
|
|
11
|
+
function cascadeRuntimePlugin(project) {
|
|
12
|
+
return {
|
|
13
|
+
name: "cascade-runtime",
|
|
14
|
+
setup(build2) {
|
|
15
|
+
build2.onResolve({ filter: /^cascade\/(?:io|image|shell|net|config|stage)$/ }, (args) => ({
|
|
16
|
+
path: args.path,
|
|
17
|
+
namespace: "cascade-runtime"
|
|
18
|
+
}));
|
|
19
|
+
build2.onResolve({ filter: /^(?:@cascade|cascade)\/contracts$/ }, () => {
|
|
20
|
+
const candidates = [
|
|
21
|
+
path.join(__dirname_compile, "..", "contracts", "index.js"),
|
|
22
|
+
path.join(__dirname_compile, "..", "..", "packages", "contracts", "dist", "index.js")
|
|
23
|
+
];
|
|
24
|
+
const found = candidates.find((c) => fs.existsSync(c));
|
|
25
|
+
if (!found) {
|
|
26
|
+
return { errors: [{ text: `@cascade/contracts not found (looked in ${candidates.join(", ")})` }] };
|
|
27
|
+
}
|
|
28
|
+
return { path: found };
|
|
29
|
+
});
|
|
30
|
+
build2.onLoad({ filter: /.*/, namespace: "cascade-runtime" }, (args) => {
|
|
31
|
+
if (args.path === "cascade/config") {
|
|
32
|
+
return { contents: configRuntimeSource(readProjectManifest(project.root).settings), loader: "ts" };
|
|
33
|
+
}
|
|
34
|
+
const candidates = [
|
|
35
|
+
path.join(__dirname_compile, "runtime", `${args.path.slice("cascade/".length)}.ts`),
|
|
36
|
+
path.join(__dirname_compile, "..", "src", "runtime", `${args.path.slice("cascade/".length)}.ts`)
|
|
37
|
+
];
|
|
38
|
+
const found = candidates.find((c) => fs.existsSync(c));
|
|
39
|
+
if (!found) {
|
|
40
|
+
return { errors: [{ text: `${args.path} runtime not found (looked in ${candidates.join(", ")})` }] };
|
|
41
|
+
}
|
|
42
|
+
return { contents: fs.readFileSync(found, "utf-8"), loader: "ts", resolveDir: path.dirname(found) };
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function commonOptions(project) {
|
|
48
|
+
return {
|
|
49
|
+
bundle: true,
|
|
50
|
+
format: "esm",
|
|
51
|
+
platform: "browser",
|
|
52
|
+
target: "es2022",
|
|
53
|
+
write: false,
|
|
54
|
+
logLevel: "silent",
|
|
55
|
+
plugins: [cascadeRuntimePlugin(project)]
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
async function compileProjectModule(project, moduleName) {
|
|
59
|
+
try {
|
|
60
|
+
await project.moduleRunsOn(moduleName);
|
|
61
|
+
return await compileEntry(project, project.resolve(`nodes/${moduleName}/index.ts`));
|
|
62
|
+
} catch (err) {
|
|
63
|
+
return { ok: false, code: "", errors: [errorMessage(err)] };
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
async function compileProjectPanel(project, panelName) {
|
|
67
|
+
try {
|
|
68
|
+
return await compileEntry(project, await project.resolvePanelEntry(panelName));
|
|
69
|
+
} catch (err) {
|
|
70
|
+
return { ok: false, code: "", errors: [errorMessage(err)] };
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
async function compileEmbedded(project, code) {
|
|
74
|
+
try {
|
|
75
|
+
const result = await esbuild.build({
|
|
76
|
+
...commonOptions(project),
|
|
77
|
+
stdin: {
|
|
78
|
+
contents: code,
|
|
79
|
+
loader: "ts",
|
|
80
|
+
resolveDir: project.root,
|
|
81
|
+
sourcefile: "embedded.ts"
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
return toResult(result);
|
|
85
|
+
} catch (err) {
|
|
86
|
+
return { ok: false, code: "", errors: [errorMessage(err)] };
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function toResult(result) {
|
|
90
|
+
const errors = result.errors.map((e) => e.text);
|
|
91
|
+
const code = result.outputFiles?.[0]?.text ?? "";
|
|
92
|
+
return { ok: errors.length === 0, code, errors };
|
|
93
|
+
}
|
|
94
|
+
async function compileEntry(project, entryPath) {
|
|
95
|
+
return toResult(await esbuild.build({ ...commonOptions(project), entryPoints: [entryPath] }));
|
|
96
|
+
}
|
|
97
|
+
function configRuntimeSource(settings) {
|
|
98
|
+
return `function deepFreeze(value) { if (value && typeof value === 'object') { for (const item of Object.values(value)) deepFreeze(item); Object.freeze(value); } return value; }
|
|
99
|
+
const values = deepFreeze(${JSON.stringify(settings)});
|
|
100
|
+
function value(name) { return Object.prototype.hasOwnProperty.call(values, name) ? values[name] : undefined; }
|
|
101
|
+
export const config = Object.freeze({
|
|
102
|
+
get(name, fallback) { return value(name) ?? fallback; },
|
|
103
|
+
string(name, fallback = '') { const item = value(name); return typeof item === 'string' ? item : fallback; },
|
|
104
|
+
number(name, fallback = 0) { const item = value(name); return typeof item === 'number' && Number.isFinite(item) ? item : fallback; },
|
|
105
|
+
boolean(name, fallback = false) { const item = value(name); return typeof item === 'boolean' ? item : fallback; },
|
|
106
|
+
has(name) { return value(name) !== undefined; }
|
|
107
|
+
});`;
|
|
108
|
+
}
|
|
109
|
+
function errorMessage(err) {
|
|
110
|
+
if (err && typeof err === "object" && "errors" in err) {
|
|
111
|
+
const errors = err.errors;
|
|
112
|
+
if (errors?.length) return errors.map((e) => e.text).join("\n");
|
|
113
|
+
}
|
|
114
|
+
return err instanceof Error ? err.message : String(err);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export {
|
|
118
|
+
compileProjectModule,
|
|
119
|
+
compileProjectPanel,
|
|
120
|
+
compileEmbedded
|
|
121
|
+
};
|
|
122
|
+
//# sourceMappingURL=chunk-EU4ZFZ7Y.js.map
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// server/src/runtime/image.ts
|
|
2
|
+
var HOST_KEY = "__cascadeImageHost";
|
|
3
|
+
function installImageHost(host) {
|
|
4
|
+
const globals = globalThis;
|
|
5
|
+
const previous = globals[HOST_KEY];
|
|
6
|
+
globals[HOST_KEY] = host ?? void 0;
|
|
7
|
+
return () => {
|
|
8
|
+
globals[HOST_KEY] = previous;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// src/cli/headlessCanvas.ts
|
|
13
|
+
var CANVAS_PACKAGE = "@napi-rs/canvas";
|
|
14
|
+
var MISSING_CANVAS_MESSAGE = `Cascade cannot render offline: no canvas is available in this Node process. Install the optional renderer with "npm install ${CANVAS_PACKAGE}" and run again. (It is optional because it is a native, platform-specific binding \u2014 Cascade installs cleanly without it, but a node drawing with OffscreenCanvas or Canvas 2D needs it.)`;
|
|
15
|
+
var MissingCanvasError = class extends Error {
|
|
16
|
+
constructor(cause) {
|
|
17
|
+
super(MISSING_CANVAS_MESSAGE);
|
|
18
|
+
this.name = "MissingCanvasError";
|
|
19
|
+
if (cause !== void 0) this.cause = cause;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
var modulePromise;
|
|
23
|
+
async function loadCanvasModule() {
|
|
24
|
+
modulePromise ??= import(
|
|
25
|
+
/* @vite-ignore */
|
|
26
|
+
CANVAS_PACKAGE
|
|
27
|
+
).then((module) => module.default ?? module).catch((error) => {
|
|
28
|
+
modulePromise = void 0;
|
|
29
|
+
throw new MissingCanvasError(error);
|
|
30
|
+
});
|
|
31
|
+
return modulePromise;
|
|
32
|
+
}
|
|
33
|
+
async function canvasAvailable() {
|
|
34
|
+
try {
|
|
35
|
+
await loadCanvasModule();
|
|
36
|
+
return true;
|
|
37
|
+
} catch {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
async function installHeadlessCanvas() {
|
|
42
|
+
const canvas = await loadCanvasModule();
|
|
43
|
+
const globals = globalThis;
|
|
44
|
+
class HeadlessOffscreenCanvas extends canvas.Canvas {
|
|
45
|
+
async convertToBlob(options = {}) {
|
|
46
|
+
const type = options.type ?? "image/png";
|
|
47
|
+
const format = type.replace(/^image\//, "");
|
|
48
|
+
const quality = options.quality === void 0 ? void 0 : Math.round(options.quality * 100);
|
|
49
|
+
return new Blob([await this.encode(format, quality)], { type });
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const createBitmap = async (source) => {
|
|
53
|
+
const bytes = source instanceof Uint8Array ? source : new Uint8Array(source instanceof Blob ? await source.arrayBuffer() : source);
|
|
54
|
+
const image = new canvas.Image();
|
|
55
|
+
image.src = bytes;
|
|
56
|
+
await image.decode();
|
|
57
|
+
if (!image.width || !image.height) throw new Error("cascade: could not decode image data");
|
|
58
|
+
image.close = () => {
|
|
59
|
+
};
|
|
60
|
+
return image;
|
|
61
|
+
};
|
|
62
|
+
const installed = {
|
|
63
|
+
OffscreenCanvas: HeadlessOffscreenCanvas,
|
|
64
|
+
Image: canvas.Image,
|
|
65
|
+
ImageData: canvas.ImageData,
|
|
66
|
+
Path2D: canvas.Path2D,
|
|
67
|
+
DOMMatrix: canvas.DOMMatrix,
|
|
68
|
+
DOMPoint: canvas.DOMPoint,
|
|
69
|
+
DOMRect: canvas.DOMRect,
|
|
70
|
+
createImageBitmap: createBitmap
|
|
71
|
+
};
|
|
72
|
+
const previous = /* @__PURE__ */ new Map();
|
|
73
|
+
for (const [name, value] of Object.entries(installed)) {
|
|
74
|
+
if (value === void 0) continue;
|
|
75
|
+
previous.set(name, globals[name]);
|
|
76
|
+
globals[name] = value;
|
|
77
|
+
}
|
|
78
|
+
const renderer = `${CANVAS_PACKAGE} (Skia)`;
|
|
79
|
+
const disposeImageHost = installImageHost({
|
|
80
|
+
renderer,
|
|
81
|
+
registerFont(family, bytes) {
|
|
82
|
+
canvas.GlobalFonts.register(Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength), family);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
return {
|
|
86
|
+
renderer,
|
|
87
|
+
dispose() {
|
|
88
|
+
disposeImageHost();
|
|
89
|
+
for (const [name, value] of previous) {
|
|
90
|
+
if (value === void 0) delete globals[name];
|
|
91
|
+
else globals[name] = value;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export {
|
|
98
|
+
CANVAS_PACKAGE,
|
|
99
|
+
MISSING_CANVAS_MESSAGE,
|
|
100
|
+
MissingCanvasError,
|
|
101
|
+
canvasAvailable,
|
|
102
|
+
installHeadlessCanvas
|
|
103
|
+
};
|
|
104
|
+
//# sourceMappingURL=chunk-EZRWJ4G2.js.map
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// packages/contracts/src/values.ts
|
|
2
|
+
var CORE_TYPES = [
|
|
3
|
+
"float",
|
|
4
|
+
"int",
|
|
5
|
+
"bool",
|
|
6
|
+
"string",
|
|
7
|
+
"vec2",
|
|
8
|
+
"vec3",
|
|
9
|
+
"vec4",
|
|
10
|
+
"vec2i",
|
|
11
|
+
"vec3i",
|
|
12
|
+
"vec4i",
|
|
13
|
+
"mat2",
|
|
14
|
+
"mat3",
|
|
15
|
+
"mat4",
|
|
16
|
+
"image",
|
|
17
|
+
"texture",
|
|
18
|
+
"geometry",
|
|
19
|
+
"points",
|
|
20
|
+
"lines",
|
|
21
|
+
"polyline",
|
|
22
|
+
"mesh",
|
|
23
|
+
"rects",
|
|
24
|
+
"color",
|
|
25
|
+
"camera",
|
|
26
|
+
"scene",
|
|
27
|
+
"light",
|
|
28
|
+
"asset",
|
|
29
|
+
"array",
|
|
30
|
+
"object",
|
|
31
|
+
"bundle",
|
|
32
|
+
"any"
|
|
33
|
+
];
|
|
34
|
+
var TYPE_ALIASES = {
|
|
35
|
+
number: "float",
|
|
36
|
+
boolean: "bool",
|
|
37
|
+
curves: "polyline"
|
|
38
|
+
};
|
|
39
|
+
var IMPLICIT_TYPE_CONVERSIONS = {
|
|
40
|
+
int: ["float", "string"],
|
|
41
|
+
float: ["string"],
|
|
42
|
+
bool: ["int", "float", "string"],
|
|
43
|
+
vec2i: ["vec2"],
|
|
44
|
+
vec3i: ["vec3"],
|
|
45
|
+
vec4i: ["vec4"],
|
|
46
|
+
/**
|
|
47
|
+
* A geometry *is* a scene — one with the viewport's own camera and no lights.
|
|
48
|
+
* So the wire is legal and nothing is lost, which is the widening rule this
|
|
49
|
+
* table already follows. Every consumer of a `scene` input reads it through
|
|
50
|
+
* `asScene`, which performs the promotion; see `scene.ts`.
|
|
51
|
+
*/
|
|
52
|
+
geometry: ["scene"],
|
|
53
|
+
vec4: ["color"],
|
|
54
|
+
color: ["vec4"]
|
|
55
|
+
};
|
|
56
|
+
function normalizeCascadeType(type) {
|
|
57
|
+
if (!type) return "any";
|
|
58
|
+
return TYPE_ALIASES[type] ?? type;
|
|
59
|
+
}
|
|
60
|
+
function canConnectTypes(source, target) {
|
|
61
|
+
const from = normalizeCascadeType(source);
|
|
62
|
+
const to = normalizeCascadeType(target);
|
|
63
|
+
return from === to || from === "any" || to === "any" || (IMPLICIT_TYPE_CONVERSIONS[from]?.includes(to) ?? false);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export {
|
|
67
|
+
CORE_TYPES,
|
|
68
|
+
normalizeCascadeType,
|
|
69
|
+
canConnectTypes
|
|
70
|
+
};
|
|
71
|
+
//# sourceMappingURL=chunk-FWMSGKEH.js.map
|