@awesome-flow/noise 0.1.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/dist/abstract/index.cjs +4234 -0
- package/dist/abstract/index.cjs.map +1 -0
- package/dist/abstract/index.d.cts +137 -0
- package/dist/abstract/index.d.ts +137 -0
- package/dist/abstract/index.js +4271 -0
- package/dist/abstract/index.js.map +1 -0
- package/dist/handle-types-D-v5S53h.d.cts +22 -0
- package/dist/handle-types-D-v5S53h.d.ts +22 -0
- package/dist/layout/index.cjs +164 -0
- package/dist/layout/index.cjs.map +1 -0
- package/dist/layout/index.d.cts +26 -0
- package/dist/layout/index.d.ts +26 -0
- package/dist/layout/index.js +136 -0
- package/dist/layout/index.js.map +1 -0
- package/dist/modules/index.cjs +71 -0
- package/dist/modules/index.cjs.map +1 -0
- package/dist/modules/index.d.cts +18 -0
- package/dist/modules/index.d.ts +18 -0
- package/dist/modules/index.js +34 -0
- package/dist/modules/index.js.map +1 -0
- package/dist/node-props-CeZ8Oshz.d.ts +161 -0
- package/dist/node-props-hKW-_KOU.d.cts +161 -0
- package/dist/nodes/generators/index.cjs +640 -0
- package/dist/nodes/generators/index.cjs.map +1 -0
- package/dist/nodes/generators/index.d.cts +38 -0
- package/dist/nodes/generators/index.d.ts +38 -0
- package/dist/nodes/generators/index.js +592 -0
- package/dist/nodes/generators/index.js.map +1 -0
- package/dist/nodes/groups/index.cjs +104 -0
- package/dist/nodes/groups/index.cjs.map +1 -0
- package/dist/nodes/groups/index.d.cts +7 -0
- package/dist/nodes/groups/index.d.ts +7 -0
- package/dist/nodes/groups/index.js +78 -0
- package/dist/nodes/groups/index.js.map +1 -0
- package/dist/nodes/index.cjs +2830 -0
- package/dist/nodes/index.cjs.map +1 -0
- package/dist/nodes/index.d.cts +16 -0
- package/dist/nodes/index.d.ts +16 -0
- package/dist/nodes/index.js +2840 -0
- package/dist/nodes/index.js.map +1 -0
- package/dist/nodes/modifiers/index.cjs +1593 -0
- package/dist/nodes/modifiers/index.cjs.map +1 -0
- package/dist/nodes/modifiers/index.d.cts +32 -0
- package/dist/nodes/modifiers/index.d.ts +32 -0
- package/dist/nodes/modifiers/index.js +1612 -0
- package/dist/nodes/modifiers/index.js.map +1 -0
- package/dist/nodes/output/index.cjs +210 -0
- package/dist/nodes/output/index.cjs.map +1 -0
- package/dist/nodes/output/index.d.cts +13 -0
- package/dist/nodes/output/index.d.ts +13 -0
- package/dist/nodes/output/index.js +181 -0
- package/dist/nodes/output/index.js.map +1 -0
- package/dist/nodes/selectors/index.cjs +136 -0
- package/dist/nodes/selectors/index.cjs.map +1 -0
- package/dist/nodes/selectors/index.d.cts +16 -0
- package/dist/nodes/selectors/index.d.ts +16 -0
- package/dist/nodes/selectors/index.js +113 -0
- package/dist/nodes/selectors/index.js.map +1 -0
- package/dist/nodes/transformers/index.cjs +477 -0
- package/dist/nodes/transformers/index.cjs.map +1 -0
- package/dist/nodes/transformers/index.d.cts +22 -0
- package/dist/nodes/transformers/index.d.ts +22 -0
- package/dist/nodes/transformers/index.js +459 -0
- package/dist/nodes/transformers/index.js.map +1 -0
- package/dist/properties-BxwtU6i9.d.cts +9 -0
- package/dist/properties-BxwtU6i9.d.ts +9 -0
- package/dist/templates/generators/index.cjs +1714 -0
- package/dist/templates/generators/index.cjs.map +1 -0
- package/dist/templates/generators/index.d.cts +89 -0
- package/dist/templates/generators/index.d.ts +89 -0
- package/dist/templates/generators/index.js +1723 -0
- package/dist/templates/generators/index.js.map +1 -0
- package/dist/templates/groups/index.cjs +1690 -0
- package/dist/templates/groups/index.cjs.map +1 -0
- package/dist/templates/groups/index.d.cts +11 -0
- package/dist/templates/groups/index.d.ts +11 -0
- package/dist/templates/groups/index.js +1711 -0
- package/dist/templates/groups/index.js.map +1 -0
- package/dist/templates/index.cjs +1758 -0
- package/dist/templates/index.cjs.map +1 -0
- package/dist/templates/index.d.cts +15 -0
- package/dist/templates/index.d.ts +15 -0
- package/dist/templates/index.js +1745 -0
- package/dist/templates/index.js.map +1 -0
- package/dist/templates/modifiers/index.cjs +1708 -0
- package/dist/templates/modifiers/index.cjs.map +1 -0
- package/dist/templates/modifiers/index.d.cts +71 -0
- package/dist/templates/modifiers/index.d.ts +71 -0
- package/dist/templates/modifiers/index.js +1720 -0
- package/dist/templates/modifiers/index.js.map +1 -0
- package/dist/templates/output/index.cjs +1696 -0
- package/dist/templates/output/index.cjs.map +1 -0
- package/dist/templates/output/index.d.cts +29 -0
- package/dist/templates/output/index.d.ts +29 -0
- package/dist/templates/output/index.js +1714 -0
- package/dist/templates/output/index.js.map +1 -0
- package/dist/templates/selectors/index.cjs +1692 -0
- package/dist/templates/selectors/index.cjs.map +1 -0
- package/dist/templates/selectors/index.d.cts +22 -0
- package/dist/templates/selectors/index.d.ts +22 -0
- package/dist/templates/selectors/index.js +1712 -0
- package/dist/templates/selectors/index.js.map +1 -0
- package/dist/templates/transformers/index.cjs +1698 -0
- package/dist/templates/transformers/index.cjs.map +1 -0
- package/dist/templates/transformers/index.d.cts +40 -0
- package/dist/templates/transformers/index.d.ts +40 -0
- package/dist/templates/transformers/index.js +1715 -0
- package/dist/templates/transformers/index.js.map +1 -0
- package/package.json +111 -0
|
@@ -0,0 +1,2840 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
8
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
20
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
21
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
22
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
23
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
24
|
+
mod
|
|
25
|
+
));
|
|
26
|
+
|
|
27
|
+
// ../../node_modules/fast-deep-equal/index.js
|
|
28
|
+
var require_fast_deep_equal = __commonJS({
|
|
29
|
+
"../../node_modules/fast-deep-equal/index.js"(exports, module) {
|
|
30
|
+
"use strict";
|
|
31
|
+
module.exports = function equal(a, b) {
|
|
32
|
+
if (a === b)
|
|
33
|
+
return true;
|
|
34
|
+
if (a && b && typeof a == "object" && typeof b == "object") {
|
|
35
|
+
if (a.constructor !== b.constructor)
|
|
36
|
+
return false;
|
|
37
|
+
var length, i, keys;
|
|
38
|
+
if (Array.isArray(a)) {
|
|
39
|
+
length = a.length;
|
|
40
|
+
if (length != b.length)
|
|
41
|
+
return false;
|
|
42
|
+
for (i = length; i-- !== 0; )
|
|
43
|
+
if (!equal(a[i], b[i]))
|
|
44
|
+
return false;
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
if (a.constructor === RegExp)
|
|
48
|
+
return a.source === b.source && a.flags === b.flags;
|
|
49
|
+
if (a.valueOf !== Object.prototype.valueOf)
|
|
50
|
+
return a.valueOf() === b.valueOf();
|
|
51
|
+
if (a.toString !== Object.prototype.toString)
|
|
52
|
+
return a.toString() === b.toString();
|
|
53
|
+
keys = Object.keys(a);
|
|
54
|
+
length = keys.length;
|
|
55
|
+
if (length !== Object.keys(b).length)
|
|
56
|
+
return false;
|
|
57
|
+
for (i = length; i-- !== 0; )
|
|
58
|
+
if (!Object.prototype.hasOwnProperty.call(b, keys[i]))
|
|
59
|
+
return false;
|
|
60
|
+
for (i = length; i-- !== 0; ) {
|
|
61
|
+
var key = keys[i];
|
|
62
|
+
if (!equal(a[key], b[key]))
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
return a !== a && b !== b;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
// src/nodes/generators/noise-billow-node.tsx
|
|
73
|
+
import { NodeContainer, NodeTrackConnections } from "@awesome-flow/core/layout";
|
|
74
|
+
import { useCallback as useCallback2, useMemo as useMemo2 } from "react";
|
|
75
|
+
import { Billow } from "libnoise-ts/module/generator";
|
|
76
|
+
import { useUpdateNodeComputedData } from "@awesome-flow/core/hooks";
|
|
77
|
+
import { nodeDataPropertyExcept as nodeDataPropertyExcept2 } from "@awesome-flow/core/abstract";
|
|
78
|
+
|
|
79
|
+
// src/layout/node-property-variables.tsx
|
|
80
|
+
import { useIncomingNodeData, useUpdateNodeData } from "@awesome-flow/core/hooks";
|
|
81
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
82
|
+
import { Group, Stack } from "@mantine/core";
|
|
83
|
+
import { getObjectKeys } from "@awesome-flow/core/utils";
|
|
84
|
+
import { nodeDataPropertyExcept } from "@awesome-flow/core/abstract";
|
|
85
|
+
|
|
86
|
+
// src/layout/node-value-input.tsx
|
|
87
|
+
import { Input, NumberInput, Switch } from "@mantine/core";
|
|
88
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
89
|
+
function NodeValueInput({ value, disabled, step, onChange }) {
|
|
90
|
+
if (value === void 0 || value === null) {
|
|
91
|
+
return /* @__PURE__ */ jsx(Fragment, {});
|
|
92
|
+
}
|
|
93
|
+
switch (typeof value) {
|
|
94
|
+
case "boolean": {
|
|
95
|
+
return /* @__PURE__ */ jsx(
|
|
96
|
+
Switch,
|
|
97
|
+
{
|
|
98
|
+
checked: value,
|
|
99
|
+
disabled,
|
|
100
|
+
onChange: (e) => onChange(e.currentTarget.checked)
|
|
101
|
+
}
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
case "number": {
|
|
105
|
+
return /* @__PURE__ */ jsx(NumberInput, { value, disabled, step, onChange: (e) => onChange(e) });
|
|
106
|
+
}
|
|
107
|
+
case "string": {
|
|
108
|
+
return /* @__PURE__ */ jsx(
|
|
109
|
+
Input,
|
|
110
|
+
{
|
|
111
|
+
value,
|
|
112
|
+
disabled,
|
|
113
|
+
onChange: (e) => onChange(e.currentTarget.value)
|
|
114
|
+
}
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
default:
|
|
118
|
+
throw new Error(`Unknown input node for value of type: ${typeof value} (${value})`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
var node_value_input_default = NodeValueInput;
|
|
122
|
+
|
|
123
|
+
// src/layout/node-property-input.tsx
|
|
124
|
+
import { Fragment as Fragment2, jsx as jsx2 } from "react/jsx-runtime";
|
|
125
|
+
function NodePropertyInput({ property, onChange }) {
|
|
126
|
+
if (!property) {
|
|
127
|
+
return /* @__PURE__ */ jsx2(Fragment2, {});
|
|
128
|
+
}
|
|
129
|
+
return /* @__PURE__ */ jsx2(
|
|
130
|
+
node_value_input_default,
|
|
131
|
+
{
|
|
132
|
+
value: property.value,
|
|
133
|
+
disabled: property.disabled,
|
|
134
|
+
step: property.step,
|
|
135
|
+
onChange: (value) => onChange(property.name, value)
|
|
136
|
+
}
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
var node_property_input_default = NodePropertyInput;
|
|
140
|
+
|
|
141
|
+
// src/layout/node-property-variables.tsx
|
|
142
|
+
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
143
|
+
function NodePropertyVariables({
|
|
144
|
+
data,
|
|
145
|
+
nodeId,
|
|
146
|
+
onPropertiesChange,
|
|
147
|
+
except = nodeDataPropertyExcept
|
|
148
|
+
}) {
|
|
149
|
+
const [properties, setProperties] = useState(() => {
|
|
150
|
+
const keys = getObjectKeys(data, except);
|
|
151
|
+
const dataProps = {};
|
|
152
|
+
for (const key of keys) {
|
|
153
|
+
dataProps[key] = {
|
|
154
|
+
name: key,
|
|
155
|
+
value: data[key]
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
return dataProps;
|
|
159
|
+
});
|
|
160
|
+
const updateNodeData = useUpdateNodeData();
|
|
161
|
+
const incoming = useIncomingNodeData(nodeId);
|
|
162
|
+
const resetAllDisabled = useCallback(() => {
|
|
163
|
+
const keys = Object.keys(properties);
|
|
164
|
+
keys.forEach((k) => {
|
|
165
|
+
properties[k].disabled = false;
|
|
166
|
+
});
|
|
167
|
+
setProperties(properties);
|
|
168
|
+
}, []);
|
|
169
|
+
const updatePropertyValue = useCallback((name, value, disabled) => {
|
|
170
|
+
let property = properties[name];
|
|
171
|
+
if (property) {
|
|
172
|
+
property.value = value;
|
|
173
|
+
} else {
|
|
174
|
+
property = {
|
|
175
|
+
name,
|
|
176
|
+
value
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
property.disabled = disabled;
|
|
180
|
+
setProperties({ ...properties, [name]: property });
|
|
181
|
+
updateNodeData(nodeId, { [name]: value });
|
|
182
|
+
}, []);
|
|
183
|
+
useEffect(() => {
|
|
184
|
+
resetAllDisabled();
|
|
185
|
+
if (incoming?.length) {
|
|
186
|
+
for (const connection of incoming) {
|
|
187
|
+
if (connection.property && properties[connection.property.name] !== void 0) {
|
|
188
|
+
updatePropertyValue(connection.property.name, connection.property.value, true);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}, [incoming]);
|
|
193
|
+
useEffect(() => {
|
|
194
|
+
if (onPropertiesChange) {
|
|
195
|
+
onPropertiesChange(properties);
|
|
196
|
+
}
|
|
197
|
+
}, [onPropertiesChange, properties]);
|
|
198
|
+
const nodes = useMemo(() => {
|
|
199
|
+
return Object.keys(properties).map((key) => {
|
|
200
|
+
const property = properties[key];
|
|
201
|
+
return /* @__PURE__ */ jsxs(Group, { children: [
|
|
202
|
+
property.name,
|
|
203
|
+
":",
|
|
204
|
+
/* @__PURE__ */ jsx3(node_property_input_default, { property, onChange: updatePropertyValue })
|
|
205
|
+
] }, key);
|
|
206
|
+
});
|
|
207
|
+
}, [properties, updatePropertyValue]);
|
|
208
|
+
return /* @__PURE__ */ jsx3(Stack, { children: nodes });
|
|
209
|
+
}
|
|
210
|
+
var node_property_variables_default = NodePropertyVariables;
|
|
211
|
+
|
|
212
|
+
// src/nodes/generators/noise-billow-node.tsx
|
|
213
|
+
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
214
|
+
function NoiseBillowNode({ id, selected, data, type }) {
|
|
215
|
+
const updateComputedData = useUpdateNodeComputedData();
|
|
216
|
+
const module = useMemo2(() => new Billow(), []);
|
|
217
|
+
const onPropertiesChange = useCallback2(
|
|
218
|
+
(properties) => {
|
|
219
|
+
Object.keys(properties).forEach((k) => {
|
|
220
|
+
module[k] = properties[k].value;
|
|
221
|
+
});
|
|
222
|
+
updateComputedData(id, { module });
|
|
223
|
+
},
|
|
224
|
+
[id, module, updateComputedData]
|
|
225
|
+
);
|
|
226
|
+
return /* @__PURE__ */ jsxs2(NodeContainer, { id, selected, data, type, children: [
|
|
227
|
+
/* @__PURE__ */ jsx4(
|
|
228
|
+
node_property_variables_default,
|
|
229
|
+
{
|
|
230
|
+
data,
|
|
231
|
+
except: nodeDataPropertyExcept2,
|
|
232
|
+
nodeId: id,
|
|
233
|
+
onPropertiesChange
|
|
234
|
+
}
|
|
235
|
+
),
|
|
236
|
+
/* @__PURE__ */ jsx4(NodeTrackConnections, { handles: data.handles, nodeId: id, type: "target" })
|
|
237
|
+
] });
|
|
238
|
+
}
|
|
239
|
+
var noise_billow_node_default = NoiseBillowNode;
|
|
240
|
+
|
|
241
|
+
// src/nodes/generators/noise-checkerboard-node.tsx
|
|
242
|
+
import { NodeContainer as NodeContainer2 } from "@awesome-flow/core/layout";
|
|
243
|
+
import { useEffect as useEffect2, useMemo as useMemo3 } from "react";
|
|
244
|
+
import { Checkerboard } from "libnoise-ts/module/generator";
|
|
245
|
+
import { useUpdateNodeComputedData as useUpdateNodeComputedData2 } from "@awesome-flow/core/hooks";
|
|
246
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
247
|
+
function NoiseCheckerboardNode({ id, selected, data, type }) {
|
|
248
|
+
const updateComputedData = useUpdateNodeComputedData2();
|
|
249
|
+
const module = useMemo3(() => new Checkerboard(), []);
|
|
250
|
+
useEffect2(() => {
|
|
251
|
+
updateComputedData(id, { module });
|
|
252
|
+
}, [id, module, updateComputedData]);
|
|
253
|
+
return /* @__PURE__ */ jsx5(NodeContainer2, { id, selected, data, type });
|
|
254
|
+
}
|
|
255
|
+
var noise_checkerboard_node_default = NoiseCheckerboardNode;
|
|
256
|
+
|
|
257
|
+
// src/nodes/generators/noise-const-node.tsx
|
|
258
|
+
import { NodeContainer as NodeContainer3 } from "@awesome-flow/core/layout";
|
|
259
|
+
import { useEffect as useEffect3, useMemo as useMemo4, useState as useState2 } from "react";
|
|
260
|
+
import { Group as Group2, NumberInput as NumberInput2, Stack as Stack2 } from "@mantine/core";
|
|
261
|
+
import { useUpdateNodeComputedData as useUpdateNodeComputedData3, useUpdateNodeData as useUpdateNodeData2 } from "@awesome-flow/core/hooks";
|
|
262
|
+
import { Const } from "libnoise-ts/module/generator";
|
|
263
|
+
import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
264
|
+
function NoiseConstNode({ id, selected, data, type }) {
|
|
265
|
+
const [min, setMin] = useState2(data.min);
|
|
266
|
+
const [max, setMax] = useState2(data.max);
|
|
267
|
+
const [noise, setNoise] = useState2(data.noise);
|
|
268
|
+
const updateNodeData = useUpdateNodeData2();
|
|
269
|
+
const updateComputedData = useUpdateNodeComputedData3();
|
|
270
|
+
const module = useMemo4(() => new Const(), []);
|
|
271
|
+
useEffect3(() => {
|
|
272
|
+
module.value = noise;
|
|
273
|
+
updateNodeData(id, { noise, min, max });
|
|
274
|
+
updateComputedData(id, { module });
|
|
275
|
+
}, [noise, min, max, module, updateNodeData, id, updateComputedData]);
|
|
276
|
+
return /* @__PURE__ */ jsx6(NodeContainer3, { id, selected, data, type, children: /* @__PURE__ */ jsxs3(Stack2, { children: [
|
|
277
|
+
/* @__PURE__ */ jsxs3(Group2, { children: [
|
|
278
|
+
/* @__PURE__ */ jsx6(NumberInput2, { size: "xs", w: 100, value: min, onChange: (e) => setMin(Number(e)) }),
|
|
279
|
+
/* @__PURE__ */ jsx6(NumberInput2, { size: "xs", w: 100, value: max, onChange: (e) => setMax(Number(e)) })
|
|
280
|
+
] }),
|
|
281
|
+
/* @__PURE__ */ jsxs3(Group2, { children: [
|
|
282
|
+
"noise:",
|
|
283
|
+
/* @__PURE__ */ jsx6(
|
|
284
|
+
NumberInput2,
|
|
285
|
+
{
|
|
286
|
+
size: "xs",
|
|
287
|
+
value: noise,
|
|
288
|
+
onChange: (e) => setNoise(Number(e)),
|
|
289
|
+
max,
|
|
290
|
+
min,
|
|
291
|
+
step: 0.1
|
|
292
|
+
}
|
|
293
|
+
)
|
|
294
|
+
] })
|
|
295
|
+
] }) });
|
|
296
|
+
}
|
|
297
|
+
var noise_const_node_default = NoiseConstNode;
|
|
298
|
+
|
|
299
|
+
// src/nodes/generators/noise-cylinders-node.tsx
|
|
300
|
+
import { NodeContainer as NodeContainer4, NodeTrackConnections as NodeTrackConnections2 } from "@awesome-flow/core/layout";
|
|
301
|
+
import { useCallback as useCallback3, useMemo as useMemo5 } from "react";
|
|
302
|
+
import { Cylinders } from "libnoise-ts/module/generator";
|
|
303
|
+
import { useUpdateNodeComputedData as useUpdateNodeComputedData4 } from "@awesome-flow/core/hooks";
|
|
304
|
+
import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
305
|
+
function NoiseCylindersNode({ id, selected, data, type }) {
|
|
306
|
+
const updateComputedData = useUpdateNodeComputedData4();
|
|
307
|
+
const module = useMemo5(() => new Cylinders(), []);
|
|
308
|
+
const onPropertiesChange = useCallback3(
|
|
309
|
+
(properties) => {
|
|
310
|
+
Object.keys(properties).forEach((k) => {
|
|
311
|
+
module[k] = properties[k].value;
|
|
312
|
+
});
|
|
313
|
+
updateComputedData(id, { module });
|
|
314
|
+
},
|
|
315
|
+
[id, module, updateComputedData]
|
|
316
|
+
);
|
|
317
|
+
return /* @__PURE__ */ jsxs4(NodeContainer4, { id, selected, data, type, children: [
|
|
318
|
+
/* @__PURE__ */ jsx7(node_property_variables_default, { data, nodeId: id, onPropertiesChange }),
|
|
319
|
+
/* @__PURE__ */ jsx7(NodeTrackConnections2, { handles: data.handles, nodeId: id, type: "target" })
|
|
320
|
+
] });
|
|
321
|
+
}
|
|
322
|
+
var noise_cylinders_node_default = NoiseCylindersNode;
|
|
323
|
+
|
|
324
|
+
// src/nodes/generators/noise-perlin-node.tsx
|
|
325
|
+
import { NodeContainer as NodeContainer5, NodeTrackConnections as NodeTrackConnections3 } from "@awesome-flow/core/layout";
|
|
326
|
+
import { useCallback as useCallback4, useMemo as useMemo6 } from "react";
|
|
327
|
+
import { Perlin } from "libnoise-ts/module/generator";
|
|
328
|
+
import { useUpdateNodeComputedData as useUpdateNodeComputedData5 } from "@awesome-flow/core/hooks";
|
|
329
|
+
import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
330
|
+
function NoisePerlinNode({ id, selected, data, type }) {
|
|
331
|
+
const updateComputedData = useUpdateNodeComputedData5();
|
|
332
|
+
const module = useMemo6(() => new Perlin(), []);
|
|
333
|
+
const onPropertiesChange = useCallback4(
|
|
334
|
+
(properties) => {
|
|
335
|
+
Object.keys(properties).forEach((k) => {
|
|
336
|
+
module[k] = properties[k].value;
|
|
337
|
+
});
|
|
338
|
+
updateComputedData(id, { module });
|
|
339
|
+
},
|
|
340
|
+
[id, module, updateComputedData]
|
|
341
|
+
);
|
|
342
|
+
return /* @__PURE__ */ jsxs5(NodeContainer5, { id, selected, data, type, children: [
|
|
343
|
+
/* @__PURE__ */ jsx8(node_property_variables_default, { data, nodeId: id, onPropertiesChange }),
|
|
344
|
+
/* @__PURE__ */ jsx8(NodeTrackConnections3, { handles: data.handles, nodeId: id, type: "target" })
|
|
345
|
+
] });
|
|
346
|
+
}
|
|
347
|
+
var noise_perlin_node_default = NoisePerlinNode;
|
|
348
|
+
|
|
349
|
+
// src/nodes/generators/noise-ridgedmulti-node.tsx
|
|
350
|
+
import { NodeContainer as NodeContainer6, NodeTrackConnections as NodeTrackConnections4 } from "@awesome-flow/core/layout";
|
|
351
|
+
import { useCallback as useCallback5, useMemo as useMemo7 } from "react";
|
|
352
|
+
import { RidgedMulti } from "libnoise-ts/module/generator";
|
|
353
|
+
import { useUpdateNodeComputedData as useUpdateNodeComputedData6 } from "@awesome-flow/core/hooks";
|
|
354
|
+
import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
355
|
+
function NoiseRidgedMultiNode({ id, selected, data, type }) {
|
|
356
|
+
const updateComputedData = useUpdateNodeComputedData6();
|
|
357
|
+
const module = useMemo7(() => new RidgedMulti(), []);
|
|
358
|
+
const onPropertiesChange = useCallback5((properties) => {
|
|
359
|
+
Object.keys(properties).forEach((k) => module[k] = properties[k].value);
|
|
360
|
+
updateComputedData(id, { module });
|
|
361
|
+
}, []);
|
|
362
|
+
return /* @__PURE__ */ jsxs6(NodeContainer6, { id, selected, data, type, children: [
|
|
363
|
+
/* @__PURE__ */ jsx9(node_property_variables_default, { data, nodeId: id, onPropertiesChange }),
|
|
364
|
+
/* @__PURE__ */ jsx9(NodeTrackConnections4, { handles: data.handles, nodeId: id, type: "target" })
|
|
365
|
+
] });
|
|
366
|
+
}
|
|
367
|
+
var noise_ridgedmulti_node_default = NoiseRidgedMultiNode;
|
|
368
|
+
|
|
369
|
+
// src/nodes/generators/noise-simplex-node.tsx
|
|
370
|
+
import { NodeContainer as NodeContainer7 } from "@awesome-flow/core/layout";
|
|
371
|
+
import { useEffect as useEffect4, useMemo as useMemo8 } from "react";
|
|
372
|
+
import { useUpdateNodeComputedData as useUpdateNodeComputedData7 } from "@awesome-flow/core/hooks";
|
|
373
|
+
|
|
374
|
+
// src/modules/simplex-module.ts
|
|
375
|
+
import Module from "libnoise-ts/module/Module";
|
|
376
|
+
import { createNoise3D } from "simplex-noise";
|
|
377
|
+
var SimplexModule = class extends Module {
|
|
378
|
+
noise;
|
|
379
|
+
constructor(random) {
|
|
380
|
+
super();
|
|
381
|
+
this.noise = createNoise3D(random);
|
|
382
|
+
}
|
|
383
|
+
getValue(x, y, z) {
|
|
384
|
+
return this.noise(x, y, z);
|
|
385
|
+
}
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
// src/nodes/generators/noise-simplex-node.tsx
|
|
389
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
390
|
+
function NoiseSimplexNode({ id, selected, data, type }) {
|
|
391
|
+
const updateComputedData = useUpdateNodeComputedData7();
|
|
392
|
+
const module = useMemo8(() => new SimplexModule(), []);
|
|
393
|
+
useEffect4(() => {
|
|
394
|
+
updateComputedData(id, { module });
|
|
395
|
+
}, []);
|
|
396
|
+
return /* @__PURE__ */ jsx10(NodeContainer7, { id, selected, data, type });
|
|
397
|
+
}
|
|
398
|
+
var noise_simplex_node_default = NoiseSimplexNode;
|
|
399
|
+
|
|
400
|
+
// src/nodes/generators/noise-spheres-node.tsx
|
|
401
|
+
import { NodeContainer as NodeContainer8, NodeTrackConnections as NodeTrackConnections5 } from "@awesome-flow/core/layout";
|
|
402
|
+
import { useCallback as useCallback6, useMemo as useMemo9 } from "react";
|
|
403
|
+
import { Spheres } from "libnoise-ts/module/generator";
|
|
404
|
+
import { useUpdateNodeComputedData as useUpdateNodeComputedData8 } from "@awesome-flow/core/hooks";
|
|
405
|
+
import { jsx as jsx11, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
406
|
+
function NoiseSpheresNode({ id, selected, data, type }) {
|
|
407
|
+
const updateComputedData = useUpdateNodeComputedData8();
|
|
408
|
+
const module = useMemo9(() => new Spheres(), []);
|
|
409
|
+
const onPropertiesChange = useCallback6((properties) => {
|
|
410
|
+
Object.keys(properties).forEach((k) => module[k] = properties[k].value);
|
|
411
|
+
updateComputedData(id, { module });
|
|
412
|
+
}, []);
|
|
413
|
+
return /* @__PURE__ */ jsxs7(NodeContainer8, { id, selected, data, type, children: [
|
|
414
|
+
/* @__PURE__ */ jsx11(node_property_variables_default, { data, nodeId: id, onPropertiesChange }),
|
|
415
|
+
/* @__PURE__ */ jsx11(NodeTrackConnections5, { handles: data.handles, nodeId: id, type: "target" })
|
|
416
|
+
] });
|
|
417
|
+
}
|
|
418
|
+
var noise_spheres_node_default = NoiseSpheresNode;
|
|
419
|
+
|
|
420
|
+
// src/nodes/generators/noise-voronoi-node.tsx
|
|
421
|
+
import { NodeContainer as NodeContainer9, NodeTrackConnections as NodeTrackConnections6 } from "@awesome-flow/core/layout";
|
|
422
|
+
import { useCallback as useCallback7 } from "react";
|
|
423
|
+
import { Voronoi } from "libnoise-ts/module/generator";
|
|
424
|
+
import { useUpdateNodeComputedData as useUpdateNodeComputedData9 } from "@awesome-flow/core/hooks";
|
|
425
|
+
import { jsx as jsx12, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
426
|
+
function NoiseVoronoiNode({ id, selected, data, type }) {
|
|
427
|
+
const updateComputedData = useUpdateNodeComputedData9();
|
|
428
|
+
const onPropertiesChange = useCallback7(
|
|
429
|
+
(properties) => {
|
|
430
|
+
const module = new Voronoi(
|
|
431
|
+
properties.frequency.value,
|
|
432
|
+
properties.displacement.value,
|
|
433
|
+
properties.distance.value,
|
|
434
|
+
properties.seed.value
|
|
435
|
+
);
|
|
436
|
+
updateComputedData(id, { module });
|
|
437
|
+
},
|
|
438
|
+
[]
|
|
439
|
+
);
|
|
440
|
+
return /* @__PURE__ */ jsxs8(NodeContainer9, { id, selected, data, type, children: [
|
|
441
|
+
/* @__PURE__ */ jsx12(node_property_variables_default, { data, nodeId: id, onPropertiesChange }),
|
|
442
|
+
/* @__PURE__ */ jsx12(NodeTrackConnections6, { handles: data.handles, nodeId: id, type: "target" })
|
|
443
|
+
] });
|
|
444
|
+
}
|
|
445
|
+
var noise_voronoi_node_default = NoiseVoronoiNode;
|
|
446
|
+
|
|
447
|
+
// src/nodes/generators/position-const-node.tsx
|
|
448
|
+
import { NodeContainer as NodeContainer10 } from "@awesome-flow/core/layout";
|
|
449
|
+
import { useEffect as useEffect5, useState as useState3 } from "react";
|
|
450
|
+
import { Group as Group3, NumberInput as NumberInput3, Stack as Stack3 } from "@mantine/core";
|
|
451
|
+
import { useUpdateNodeComputedData as useUpdateNodeComputedData10, useUpdateNodeData as useUpdateNodeData3 } from "@awesome-flow/core/hooks";
|
|
452
|
+
import { jsx as jsx13, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
453
|
+
function PositionConstNode({ id, selected, data, type }) {
|
|
454
|
+
const position = data.position ?? { x: 0, y: 0, z: 0 };
|
|
455
|
+
const [x, setX] = useState3(position.x);
|
|
456
|
+
const [y, setY] = useState3(position.y);
|
|
457
|
+
const [z, setZ] = useState3(position.z);
|
|
458
|
+
const updateNodeData = useUpdateNodeData3();
|
|
459
|
+
const updateComputedData = useUpdateNodeComputedData10();
|
|
460
|
+
useEffect5(() => {
|
|
461
|
+
const position2 = { x, y, z };
|
|
462
|
+
updateNodeData(id, {
|
|
463
|
+
position: position2
|
|
464
|
+
});
|
|
465
|
+
updateComputedData(id, {
|
|
466
|
+
positions: [position2]
|
|
467
|
+
});
|
|
468
|
+
}, [x, y, z]);
|
|
469
|
+
return /* @__PURE__ */ jsx13(NodeContainer10, { id, selected, data, type, children: /* @__PURE__ */ jsxs9(Stack3, { children: [
|
|
470
|
+
/* @__PURE__ */ jsxs9(Group3, { children: [
|
|
471
|
+
"x: ",
|
|
472
|
+
/* @__PURE__ */ jsx13(NumberInput3, { size: "xs", w: 100, value: x, onChange: (e) => setX(Number(e)) })
|
|
473
|
+
] }),
|
|
474
|
+
/* @__PURE__ */ jsxs9(Group3, { children: [
|
|
475
|
+
"y: ",
|
|
476
|
+
/* @__PURE__ */ jsx13(NumberInput3, { size: "xs", w: 100, value: y, onChange: (e) => setY(Number(e)) })
|
|
477
|
+
] }),
|
|
478
|
+
/* @__PURE__ */ jsxs9(Group3, { children: [
|
|
479
|
+
"z: ",
|
|
480
|
+
/* @__PURE__ */ jsx13(NumberInput3, { size: "xs", w: 100, value: z, onChange: (e) => setZ(Number(e)) })
|
|
481
|
+
] })
|
|
482
|
+
] }) });
|
|
483
|
+
}
|
|
484
|
+
var position_const_node_default = PositionConstNode;
|
|
485
|
+
|
|
486
|
+
// src/nodes/generators/position-grid-node.tsx
|
|
487
|
+
import { NodeContainer as NodeContainer11 } from "@awesome-flow/core/layout";
|
|
488
|
+
import { useEffect as useEffect6, useState as useState4 } from "react";
|
|
489
|
+
import { Group as Group4, NumberInput as NumberInput4, Stack as Stack4 } from "@mantine/core";
|
|
490
|
+
import { useUpdateNodeComputedData as useUpdateNodeComputedData11, useUpdateNodeData as useUpdateNodeData4 } from "@awesome-flow/core/hooks";
|
|
491
|
+
import { jsx as jsx14, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
492
|
+
function PositionGridNode({ id, selected, data, type }) {
|
|
493
|
+
const [x, setX] = useState4(data.center?.x);
|
|
494
|
+
const [y, setY] = useState4(data.center?.y);
|
|
495
|
+
const [z, setZ] = useState4(data.center?.z);
|
|
496
|
+
const [radius, setRadius] = useState4(data.radius);
|
|
497
|
+
const updateNodeData = useUpdateNodeData4();
|
|
498
|
+
const updateComputedData = useUpdateNodeComputedData11();
|
|
499
|
+
useEffect6(() => {
|
|
500
|
+
updateNodeData(id, {
|
|
501
|
+
center: { x, y, z }
|
|
502
|
+
});
|
|
503
|
+
}, [x, y, z]);
|
|
504
|
+
useEffect6(() => {
|
|
505
|
+
updateNodeData(id, {
|
|
506
|
+
radius
|
|
507
|
+
});
|
|
508
|
+
}, [radius]);
|
|
509
|
+
useEffect6(() => {
|
|
510
|
+
const positions = [];
|
|
511
|
+
for (let i = -radius; i < radius; i++) {
|
|
512
|
+
for (let j = -radius; j < radius; j++) {
|
|
513
|
+
positions.push({ x: x + i, y: y + j, z });
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
updateComputedData(id, {
|
|
517
|
+
positions
|
|
518
|
+
});
|
|
519
|
+
}, [x, y, z, radius]);
|
|
520
|
+
return /* @__PURE__ */ jsx14(NodeContainer11, { id, selected, data, type, children: /* @__PURE__ */ jsxs10(Stack4, { children: [
|
|
521
|
+
/* @__PURE__ */ jsxs10(Group4, { children: [
|
|
522
|
+
"x: ",
|
|
523
|
+
/* @__PURE__ */ jsx14(NumberInput4, { size: "xs", w: 100, value: x, onChange: (e) => setX(Number(e)) })
|
|
524
|
+
] }),
|
|
525
|
+
/* @__PURE__ */ jsxs10(Group4, { children: [
|
|
526
|
+
"y: ",
|
|
527
|
+
/* @__PURE__ */ jsx14(NumberInput4, { size: "xs", w: 100, value: y, onChange: (e) => setY(Number(e)) })
|
|
528
|
+
] }),
|
|
529
|
+
/* @__PURE__ */ jsxs10(Group4, { children: [
|
|
530
|
+
"z: ",
|
|
531
|
+
/* @__PURE__ */ jsx14(NumberInput4, { size: "xs", w: 100, value: z, onChange: (e) => setZ(Number(e)) })
|
|
532
|
+
] }),
|
|
533
|
+
/* @__PURE__ */ jsxs10(Group4, { children: [
|
|
534
|
+
"r: ",
|
|
535
|
+
/* @__PURE__ */ jsx14(NumberInput4, { size: "xs", w: 100, value: radius, onChange: (e) => setRadius(Number(e)) })
|
|
536
|
+
] })
|
|
537
|
+
] }) });
|
|
538
|
+
}
|
|
539
|
+
var position_grid_node_default = PositionGridNode;
|
|
540
|
+
|
|
541
|
+
// src/nodes/generators/variable-property-node.tsx
|
|
542
|
+
import { NodeCombobox, NodeContainer as NodeContainer12, NodeTrackConnections as NodeTrackConnections7 } from "@awesome-flow/core/layout";
|
|
543
|
+
import { useCallback as useCallback8, useEffect as useEffect7, useState as useState5 } from "react";
|
|
544
|
+
import { Stack as Stack5 } from "@mantine/core";
|
|
545
|
+
import { useIncomingNodeData as useIncomingNodeData2, useOutgoingNodes, useUpdateNodeData as useUpdateNodeData5 } from "@awesome-flow/core/hooks";
|
|
546
|
+
import { getObjectPropertyMap } from "@awesome-flow/core/utils";
|
|
547
|
+
import { nodeDataPropertyExcept as nodeDataPropertyExcept3 } from "@awesome-flow/core/abstract";
|
|
548
|
+
import { jsx as jsx15, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
549
|
+
function VariablePropertyNode({
|
|
550
|
+
id,
|
|
551
|
+
selected,
|
|
552
|
+
data,
|
|
553
|
+
type
|
|
554
|
+
}) {
|
|
555
|
+
const [options3, setOptions] = useState5({});
|
|
556
|
+
const [selectedProperty, setSelectedProperty] = useState5(data.property);
|
|
557
|
+
const updateNodeData = useUpdateNodeData5();
|
|
558
|
+
const outgoing = useOutgoingNodes(id);
|
|
559
|
+
const incoming = useIncomingNodeData2(id);
|
|
560
|
+
useEffect7(() => {
|
|
561
|
+
if (outgoing?.length) {
|
|
562
|
+
const { data: data2 } = outgoing[0];
|
|
563
|
+
const properties = getObjectPropertyMap(data2, nodeDataPropertyExcept3);
|
|
564
|
+
setOptions(properties);
|
|
565
|
+
if (!selectedProperty) {
|
|
566
|
+
const keys = Object.keys(properties);
|
|
567
|
+
if (keys.length) {
|
|
568
|
+
setSelectedProperty({
|
|
569
|
+
name: keys[0],
|
|
570
|
+
value: properties[keys[0]]
|
|
571
|
+
});
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
} else {
|
|
575
|
+
setSelectedProperty(null);
|
|
576
|
+
}
|
|
577
|
+
}, [outgoing]);
|
|
578
|
+
useEffect7(() => {
|
|
579
|
+
if (!incoming?.length && selectedProperty?.disabled) {
|
|
580
|
+
setSelectedProperty({ ...selectedProperty, disabled: false });
|
|
581
|
+
} else if (incoming?.length && selectedProperty) {
|
|
582
|
+
const incomingValue = incoming[0].value;
|
|
583
|
+
if (incomingValue !== void 0 && incomingValue !== null) {
|
|
584
|
+
setSelectedProperty({
|
|
585
|
+
name: selectedProperty.name,
|
|
586
|
+
value: incomingValue,
|
|
587
|
+
disabled: true
|
|
588
|
+
});
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
}, [incoming]);
|
|
592
|
+
useEffect7(() => {
|
|
593
|
+
if (selectedProperty) {
|
|
594
|
+
updateNodeData(id, { property: selectedProperty });
|
|
595
|
+
}
|
|
596
|
+
}, [selectedProperty]);
|
|
597
|
+
const onPropertyChange = useCallback8(
|
|
598
|
+
(selected2) => {
|
|
599
|
+
setSelectedProperty({
|
|
600
|
+
name: selected2,
|
|
601
|
+
value: options3[selected2]
|
|
602
|
+
});
|
|
603
|
+
},
|
|
604
|
+
[options3]
|
|
605
|
+
);
|
|
606
|
+
const onValueChange = useCallback8((name, value) => {
|
|
607
|
+
setSelectedProperty({
|
|
608
|
+
name,
|
|
609
|
+
value
|
|
610
|
+
});
|
|
611
|
+
}, []);
|
|
612
|
+
return /* @__PURE__ */ jsxs11(NodeContainer12, { id, selected, data, type, children: [
|
|
613
|
+
/* @__PURE__ */ jsxs11(Stack5, { align: "center", children: [
|
|
614
|
+
/* @__PURE__ */ jsx15(
|
|
615
|
+
NodeCombobox,
|
|
616
|
+
{
|
|
617
|
+
options: options3,
|
|
618
|
+
onChange: onPropertyChange,
|
|
619
|
+
selected: selectedProperty?.name,
|
|
620
|
+
hideListValues: true
|
|
621
|
+
}
|
|
622
|
+
),
|
|
623
|
+
/* @__PURE__ */ jsx15(node_property_input_default, { property: selectedProperty, onChange: onValueChange })
|
|
624
|
+
] }),
|
|
625
|
+
/* @__PURE__ */ jsx15(NodeTrackConnections7, { handles: data.handles, nodeId: id })
|
|
626
|
+
] });
|
|
627
|
+
}
|
|
628
|
+
var variable_property_node_default = VariablePropertyNode;
|
|
629
|
+
|
|
630
|
+
// src/nodes/generators/variable-value-node.tsx
|
|
631
|
+
import { NodeContainer as NodeContainer13, NodeTrackConnections as NodeTrackConnections8 } from "@awesome-flow/core/layout";
|
|
632
|
+
import { useCallback as useCallback9, useState as useState6 } from "react";
|
|
633
|
+
import { useUpdateNodeData as useUpdateNodeData6 } from "@awesome-flow/core/hooks";
|
|
634
|
+
import { jsx as jsx16, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
635
|
+
function VariableValueNode({ id, selected, data, type }) {
|
|
636
|
+
const [value, setValue] = useState6(data.value || 0);
|
|
637
|
+
const updateNodeData = useUpdateNodeData6();
|
|
638
|
+
const onValueChange = useCallback9((newValue) => {
|
|
639
|
+
updateNodeData(id, { value: newValue });
|
|
640
|
+
setValue(newValue);
|
|
641
|
+
}, []);
|
|
642
|
+
return /* @__PURE__ */ jsxs12(NodeContainer13, { id, selected, data, type, children: [
|
|
643
|
+
/* @__PURE__ */ jsx16(node_value_input_default, { value, onChange: onValueChange }),
|
|
644
|
+
/* @__PURE__ */ jsx16(NodeTrackConnections8, { handles: data.handles, nodeId: id, type: "source" })
|
|
645
|
+
] });
|
|
646
|
+
}
|
|
647
|
+
var variable_value_node_default = VariableValueNode;
|
|
648
|
+
|
|
649
|
+
// src/nodes/groups/node-module-group.tsx
|
|
650
|
+
import { NodeContainer as NodeContainer14, NodeCollapse } from "@awesome-flow/core/layout";
|
|
651
|
+
import { NodeResizer, useStore, useUpdateNodeInternals } from "@xyflow/react";
|
|
652
|
+
import { FlowContext } from "@awesome-flow/core/abstract";
|
|
653
|
+
import { useCallback as useCallback10, useContext, useEffect as useEffect8, useMemo as useMemo10 } from "react";
|
|
654
|
+
import { shallow } from "zustand/shallow";
|
|
655
|
+
import { Badge, Group as Group5 } from "@mantine/core";
|
|
656
|
+
import { jsx as jsx17, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
657
|
+
function ModuleGroupNode({
|
|
658
|
+
id,
|
|
659
|
+
selected,
|
|
660
|
+
data,
|
|
661
|
+
type,
|
|
662
|
+
width,
|
|
663
|
+
height
|
|
664
|
+
}) {
|
|
665
|
+
const context = useContext(FlowContext);
|
|
666
|
+
const updateNodeInternals = useUpdateNodeInternals();
|
|
667
|
+
const triggerNodeChanges = useStore((s) => s.triggerNodeChanges);
|
|
668
|
+
const { groupNodes, setGroupCollapsed } = context.useFlowStore(
|
|
669
|
+
useCallback10(
|
|
670
|
+
(state) => ({ groupNodes: state.groups[id], setGroupCollapsed: state.setGroupCollapsed }),
|
|
671
|
+
[]
|
|
672
|
+
)
|
|
673
|
+
);
|
|
674
|
+
const intersectingNode = context.useInteractivityStore(
|
|
675
|
+
useCallback10((state) => state.nodeIntersectionTargets[id], [id]),
|
|
676
|
+
shallow
|
|
677
|
+
);
|
|
678
|
+
useEffect8(() => {
|
|
679
|
+
updateNodeInternals(id);
|
|
680
|
+
}, [width, height]);
|
|
681
|
+
useEffect8(() => {
|
|
682
|
+
triggerNodeChanges([
|
|
683
|
+
{
|
|
684
|
+
id,
|
|
685
|
+
type: "select",
|
|
686
|
+
selected: !!intersectingNode
|
|
687
|
+
}
|
|
688
|
+
]);
|
|
689
|
+
}, [intersectingNode]);
|
|
690
|
+
const onCollapsed = useCallback10((collapsed) => {
|
|
691
|
+
setGroupCollapsed(id, collapsed);
|
|
692
|
+
}, []);
|
|
693
|
+
const size = useMemo10(() => {
|
|
694
|
+
return {
|
|
695
|
+
width: data.initialSize?.width || 100,
|
|
696
|
+
height: data.initialSize?.height || 50
|
|
697
|
+
};
|
|
698
|
+
}, [data.initialSize]);
|
|
699
|
+
return /* @__PURE__ */ jsx17(
|
|
700
|
+
NodeContainer14,
|
|
701
|
+
{
|
|
702
|
+
id,
|
|
703
|
+
selected,
|
|
704
|
+
data,
|
|
705
|
+
title: /* @__PURE__ */ jsx17(Group5, { justify: "space-between", children: /* @__PURE__ */ jsxs13(Group5, { gap: "xs", children: [
|
|
706
|
+
/* @__PURE__ */ jsx17(Badge, { size: "xs", variant: "outline", radius: "xs", color: "gray", children: groupNodes?.length || 0 }),
|
|
707
|
+
/* @__PURE__ */ jsx17(NodeCollapse, { nodeId: id, isCollapsed: data.isCollapsed, onCollapsed })
|
|
708
|
+
] }) }),
|
|
709
|
+
type,
|
|
710
|
+
children: /* @__PURE__ */ jsx17(
|
|
711
|
+
NodeResizer,
|
|
712
|
+
{
|
|
713
|
+
nodeId: id,
|
|
714
|
+
minWidth: size.width,
|
|
715
|
+
minHeight: size.height,
|
|
716
|
+
isVisible: selected && !data.isCollapsed
|
|
717
|
+
}
|
|
718
|
+
)
|
|
719
|
+
}
|
|
720
|
+
);
|
|
721
|
+
}
|
|
722
|
+
var node_module_group_default = ModuleGroupNode;
|
|
723
|
+
|
|
724
|
+
// src/nodes/modifiers/noise-abs-node.tsx
|
|
725
|
+
import { NodeContainer as NodeContainer15, NodeTrackConnections as NodeTrackConnections9 } from "@awesome-flow/core/layout";
|
|
726
|
+
import { useEffect as useEffect9 } from "react";
|
|
727
|
+
import { useIncomingComputedData, useUpdateNodeComputedData as useUpdateNodeComputedData12 } from "@awesome-flow/core/hooks";
|
|
728
|
+
import { Abs } from "libnoise-ts/module/modifier";
|
|
729
|
+
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
730
|
+
function NoiseAbsNode({ id, selected, data, type }) {
|
|
731
|
+
const incoming = useIncomingComputedData(id);
|
|
732
|
+
const updateComputedData = useUpdateNodeComputedData12();
|
|
733
|
+
useEffect9(() => {
|
|
734
|
+
if (incoming?.length > 0) {
|
|
735
|
+
const module = new Abs(incoming[0].module);
|
|
736
|
+
updateComputedData(id, { module });
|
|
737
|
+
}
|
|
738
|
+
}, [incoming]);
|
|
739
|
+
return /* @__PURE__ */ jsx18(NodeContainer15, { id, selected, data, type, children: /* @__PURE__ */ jsx18(NodeTrackConnections9, { handles: data.handles, nodeId: id, type: "target" }) });
|
|
740
|
+
}
|
|
741
|
+
var noise_abs_node_default = NoiseAbsNode;
|
|
742
|
+
|
|
743
|
+
// src/nodes/modifiers/noise-clamp-node.tsx
|
|
744
|
+
import { NodeContainer as NodeContainer16, NodeTrackConnections as NodeTrackConnections10 } from "@awesome-flow/core/layout";
|
|
745
|
+
import { useEffect as useEffect10, useState as useState7 } from "react";
|
|
746
|
+
import { Group as Group6, NumberInput as NumberInput5, Stack as Stack6 } from "@mantine/core";
|
|
747
|
+
import {
|
|
748
|
+
useIncomingComputedData as useIncomingComputedData2,
|
|
749
|
+
useUpdateNodeComputedData as useUpdateNodeComputedData13,
|
|
750
|
+
useUpdateNodeData as useUpdateNodeData7
|
|
751
|
+
} from "@awesome-flow/core/hooks";
|
|
752
|
+
import { Clamp } from "libnoise-ts/module/modifier";
|
|
753
|
+
import { jsx as jsx19, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
754
|
+
function NoiseClampNode({ id, selected, data, type }) {
|
|
755
|
+
const [lowerBound, setLowerBound] = useState7(data.lowerBound);
|
|
756
|
+
const [upperBound, setUpperBound] = useState7(data.upperBound);
|
|
757
|
+
const incoming = useIncomingComputedData2(id);
|
|
758
|
+
const updateNodeData = useUpdateNodeData7();
|
|
759
|
+
const updateComputedData = useUpdateNodeComputedData13();
|
|
760
|
+
useEffect10(() => {
|
|
761
|
+
if (incoming?.length) {
|
|
762
|
+
const module = new Clamp(incoming[0].module, lowerBound, upperBound);
|
|
763
|
+
updateComputedData(id, { module });
|
|
764
|
+
}
|
|
765
|
+
updateNodeData(id, { lowerBound, upperBound });
|
|
766
|
+
}, [incoming, lowerBound, upperBound]);
|
|
767
|
+
return /* @__PURE__ */ jsxs14(NodeContainer16, { id, selected, data, type, children: [
|
|
768
|
+
/* @__PURE__ */ jsx19(Stack6, { children: /* @__PURE__ */ jsxs14(Group6, { children: [
|
|
769
|
+
/* @__PURE__ */ jsx19(
|
|
770
|
+
NumberInput5,
|
|
771
|
+
{
|
|
772
|
+
size: "xs",
|
|
773
|
+
w: 100,
|
|
774
|
+
value: lowerBound,
|
|
775
|
+
onChange: (e) => setLowerBound(Number(e)),
|
|
776
|
+
step: 0.1
|
|
777
|
+
}
|
|
778
|
+
),
|
|
779
|
+
/* @__PURE__ */ jsx19(
|
|
780
|
+
NumberInput5,
|
|
781
|
+
{
|
|
782
|
+
size: "xs",
|
|
783
|
+
w: 100,
|
|
784
|
+
value: upperBound,
|
|
785
|
+
onChange: (e) => setUpperBound(Number(e)),
|
|
786
|
+
step: 0.1
|
|
787
|
+
}
|
|
788
|
+
)
|
|
789
|
+
] }) }),
|
|
790
|
+
/* @__PURE__ */ jsx19(NodeTrackConnections10, { handles: data.handles, nodeId: id, type: "target" })
|
|
791
|
+
] });
|
|
792
|
+
}
|
|
793
|
+
var noise_clamp_node_default = NoiseClampNode;
|
|
794
|
+
|
|
795
|
+
// src/nodes/modifiers/noise-combine-node.tsx
|
|
796
|
+
import { NodeCombobox as NodeCombobox2, NodeContainer as NodeContainer17, NodeTrackConnections as NodeTrackConnections11 } from "@awesome-flow/core/layout";
|
|
797
|
+
import { useCallback as useCallback11, useEffect as useEffect11 } from "react";
|
|
798
|
+
import {
|
|
799
|
+
useIncomingComputedData as useIncomingComputedData3,
|
|
800
|
+
useUpdateNodeComputedData as useUpdateNodeComputedData14,
|
|
801
|
+
useUpdateNodeData as useUpdateNodeData8
|
|
802
|
+
} from "@awesome-flow/core/hooks";
|
|
803
|
+
import {
|
|
804
|
+
IconAsterisk,
|
|
805
|
+
IconChevronLeft,
|
|
806
|
+
IconChevronRight,
|
|
807
|
+
IconChevronUp,
|
|
808
|
+
IconPlus
|
|
809
|
+
} from "@tabler/icons-react";
|
|
810
|
+
|
|
811
|
+
// src/abstract/operations.ts
|
|
812
|
+
import { Add, Max, Min, Multiply, Power } from "libnoise-ts/module/combiner";
|
|
813
|
+
var noiseCombineModuleMap = {
|
|
814
|
+
["add" /* add */]: Add,
|
|
815
|
+
["max" /* max */]: Max,
|
|
816
|
+
["min" /* min */]: Min,
|
|
817
|
+
["multiply" /* multiply */]: Multiply,
|
|
818
|
+
["power" /* power */]: Power
|
|
819
|
+
};
|
|
820
|
+
|
|
821
|
+
// src/nodes/modifiers/noise-combine-node.tsx
|
|
822
|
+
import { jsx as jsx20, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
823
|
+
var options = {
|
|
824
|
+
add: /* @__PURE__ */ jsx20(IconPlus, {}),
|
|
825
|
+
min: /* @__PURE__ */ jsx20(IconChevronLeft, {}),
|
|
826
|
+
max: /* @__PURE__ */ jsx20(IconChevronRight, {}),
|
|
827
|
+
multiply: /* @__PURE__ */ jsx20(IconAsterisk, {}),
|
|
828
|
+
power: /* @__PURE__ */ jsx20(IconChevronUp, {})
|
|
829
|
+
};
|
|
830
|
+
function NoiseCombineNode({ id, selected, data, type }) {
|
|
831
|
+
const updateNodeData = useUpdateNodeData8();
|
|
832
|
+
const updateComputedData = useUpdateNodeComputedData14();
|
|
833
|
+
const incoming = useIncomingComputedData3(id);
|
|
834
|
+
useEffect11(() => {
|
|
835
|
+
const ModuleFactory = noiseCombineModuleMap[data.operation];
|
|
836
|
+
if (incoming?.length > 1) {
|
|
837
|
+
const module = new ModuleFactory(incoming[0].module, incoming[1].module);
|
|
838
|
+
updateComputedData(id, { module });
|
|
839
|
+
}
|
|
840
|
+
}, [data.operation, incoming]);
|
|
841
|
+
const onChange = useCallback11((operation) => {
|
|
842
|
+
updateNodeData(id, { operation });
|
|
843
|
+
}, []);
|
|
844
|
+
return /* @__PURE__ */ jsxs15(NodeContainer17, { id, selected, data, type, children: [
|
|
845
|
+
/* @__PURE__ */ jsx20(NodeCombobox2, { options, selected: data.operation, onChange }),
|
|
846
|
+
/* @__PURE__ */ jsx20(NodeTrackConnections11, { handles: data.handles, nodeId: id, type: "target" })
|
|
847
|
+
] });
|
|
848
|
+
}
|
|
849
|
+
var noise_combine_node_default = NoiseCombineNode;
|
|
850
|
+
|
|
851
|
+
// src/nodes/modifiers/noise-curve-node.tsx
|
|
852
|
+
import { NodeContainer as NodeContainer18, NodeTrackConnections as NodeTrackConnections12 } from "@awesome-flow/core/layout";
|
|
853
|
+
import { ActionIcon, Button, Group as Group7, NumberInput as NumberInput6, Space } from "@mantine/core";
|
|
854
|
+
import {
|
|
855
|
+
useIncomingComputedData as useIncomingComputedData4,
|
|
856
|
+
useUpdateNodeComputedData as useUpdateNodeComputedData15,
|
|
857
|
+
useUpdateNodeData as useUpdateNodeData9
|
|
858
|
+
} from "@awesome-flow/core/hooks";
|
|
859
|
+
|
|
860
|
+
// ../../node_modules/@mantine/form/esm/use-form.mjs
|
|
861
|
+
import { useState as useState11, useCallback as useCallback17 } from "react";
|
|
862
|
+
|
|
863
|
+
// ../../node_modules/@mantine/form/esm/actions/actions.mjs
|
|
864
|
+
import { useLayoutEffect, useEffect as useEffect12 } from "react";
|
|
865
|
+
function validateFormName(name) {
|
|
866
|
+
if (!/^[0-9a-zA-Z-]+$/.test(name)) {
|
|
867
|
+
throw new Error(
|
|
868
|
+
`[@mantine/use-form] Form name "${name}" is invalid, it should contain only letters, numbers and dashes`
|
|
869
|
+
);
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
var useIsomorphicEffect = typeof window !== "undefined" ? useLayoutEffect : useEffect12;
|
|
873
|
+
function useFormEvent(eventKey, handler) {
|
|
874
|
+
useIsomorphicEffect(() => {
|
|
875
|
+
if (eventKey) {
|
|
876
|
+
window.addEventListener(eventKey, handler);
|
|
877
|
+
return () => window.removeEventListener(eventKey, handler);
|
|
878
|
+
}
|
|
879
|
+
return void 0;
|
|
880
|
+
}, [eventKey]);
|
|
881
|
+
}
|
|
882
|
+
function useFormActions(name, form) {
|
|
883
|
+
if (name) {
|
|
884
|
+
validateFormName(name);
|
|
885
|
+
}
|
|
886
|
+
useFormEvent(
|
|
887
|
+
`mantine-form:${name}:set-field-value`,
|
|
888
|
+
(event) => form.setFieldValue(event.detail.path, event.detail.value)
|
|
889
|
+
);
|
|
890
|
+
useFormEvent(
|
|
891
|
+
`mantine-form:${name}:set-values`,
|
|
892
|
+
(event) => form.setValues(event.detail)
|
|
893
|
+
);
|
|
894
|
+
useFormEvent(
|
|
895
|
+
`mantine-form:${name}:set-initial-values`,
|
|
896
|
+
(event) => form.setInitialValues(event.detail)
|
|
897
|
+
);
|
|
898
|
+
useFormEvent(
|
|
899
|
+
`mantine-form:${name}:set-errors`,
|
|
900
|
+
(event) => form.setErrors(event.detail)
|
|
901
|
+
);
|
|
902
|
+
useFormEvent(
|
|
903
|
+
`mantine-form:${name}:set-field-error`,
|
|
904
|
+
(event) => form.setFieldError(event.detail.path, event.detail.error)
|
|
905
|
+
);
|
|
906
|
+
useFormEvent(
|
|
907
|
+
`mantine-form:${name}:clear-field-error`,
|
|
908
|
+
(event) => form.clearFieldError(event.detail)
|
|
909
|
+
);
|
|
910
|
+
useFormEvent(`mantine-form:${name}:clear-errors`, form.clearErrors);
|
|
911
|
+
useFormEvent(`mantine-form:${name}:reset`, form.reset);
|
|
912
|
+
useFormEvent(`mantine-form:${name}:validate`, form.validate);
|
|
913
|
+
useFormEvent(
|
|
914
|
+
`mantine-form:${name}:validate-field`,
|
|
915
|
+
(event) => form.validateField(event.detail)
|
|
916
|
+
);
|
|
917
|
+
useFormEvent(
|
|
918
|
+
`mantine-form:${name}:reorder-list-item`,
|
|
919
|
+
(event) => form.reorderListItem(event.detail.path, event.detail.payload)
|
|
920
|
+
);
|
|
921
|
+
useFormEvent(
|
|
922
|
+
`mantine-form:${name}:remove-list-item`,
|
|
923
|
+
(event) => form.removeListItem(event.detail.path, event.detail.index)
|
|
924
|
+
);
|
|
925
|
+
useFormEvent(
|
|
926
|
+
`mantine-form:${name}:insert-list-item`,
|
|
927
|
+
(event) => form.insertListItem(event.detail.path, event.detail.item, event.detail.index)
|
|
928
|
+
);
|
|
929
|
+
useFormEvent(
|
|
930
|
+
`mantine-form:${name}:set-dirty`,
|
|
931
|
+
(event) => form.setDirty(event.detail)
|
|
932
|
+
);
|
|
933
|
+
useFormEvent(
|
|
934
|
+
`mantine-form:${name}:set-touched`,
|
|
935
|
+
(event) => form.setTouched(event.detail)
|
|
936
|
+
);
|
|
937
|
+
useFormEvent(
|
|
938
|
+
`mantine-form:${name}:reset-dirty`,
|
|
939
|
+
(event) => form.resetDirty(event.detail)
|
|
940
|
+
);
|
|
941
|
+
useFormEvent(`mantine-form:${name}:reset-touched`, form.resetTouched);
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
// ../../node_modules/@mantine/form/esm/get-input-on-change/get-input-on-change.mjs
|
|
945
|
+
function getInputOnChange(setValue) {
|
|
946
|
+
return (val) => {
|
|
947
|
+
if (!val) {
|
|
948
|
+
setValue(val);
|
|
949
|
+
} else if (typeof val === "function") {
|
|
950
|
+
setValue(val);
|
|
951
|
+
} else if (typeof val === "object" && "nativeEvent" in val) {
|
|
952
|
+
const { currentTarget } = val;
|
|
953
|
+
if (currentTarget instanceof HTMLInputElement) {
|
|
954
|
+
if (currentTarget.type === "checkbox") {
|
|
955
|
+
setValue(currentTarget.checked);
|
|
956
|
+
} else {
|
|
957
|
+
setValue(currentTarget.value);
|
|
958
|
+
}
|
|
959
|
+
} else if (currentTarget instanceof HTMLTextAreaElement || currentTarget instanceof HTMLSelectElement) {
|
|
960
|
+
setValue(currentTarget.value);
|
|
961
|
+
}
|
|
962
|
+
} else {
|
|
963
|
+
setValue(val);
|
|
964
|
+
}
|
|
965
|
+
};
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
// ../../node_modules/@mantine/form/esm/hooks/use-form-errors/use-form-errors.mjs
|
|
969
|
+
import { useState as useState8, useCallback as useCallback12 } from "react";
|
|
970
|
+
|
|
971
|
+
// ../../node_modules/@mantine/form/esm/hooks/use-form-errors/filter-errors/filter-errors.mjs
|
|
972
|
+
function filterErrors(errors) {
|
|
973
|
+
if (errors === null || typeof errors !== "object") {
|
|
974
|
+
return {};
|
|
975
|
+
}
|
|
976
|
+
return Object.keys(errors).reduce((acc, key) => {
|
|
977
|
+
const errorValue = errors[key];
|
|
978
|
+
if (errorValue !== void 0 && errorValue !== null && errorValue !== false) {
|
|
979
|
+
acc[key] = errorValue;
|
|
980
|
+
}
|
|
981
|
+
return acc;
|
|
982
|
+
}, {});
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
// ../../node_modules/@mantine/form/esm/hooks/use-form-errors/use-form-errors.mjs
|
|
986
|
+
function useFormErrors(initialErrors) {
|
|
987
|
+
const [errorsState, setErrorsState] = useState8(filterErrors(initialErrors));
|
|
988
|
+
const setErrors = useCallback12((errors) => {
|
|
989
|
+
setErrorsState(
|
|
990
|
+
(current) => filterErrors(typeof errors === "function" ? errors(current) : errors)
|
|
991
|
+
);
|
|
992
|
+
}, []);
|
|
993
|
+
const clearErrors = useCallback12(() => setErrorsState({}), []);
|
|
994
|
+
const clearFieldError = useCallback12(
|
|
995
|
+
(path) => {
|
|
996
|
+
if (errorsState[path] === void 0) {
|
|
997
|
+
return;
|
|
998
|
+
}
|
|
999
|
+
setErrors((current) => {
|
|
1000
|
+
const errors = { ...current };
|
|
1001
|
+
delete errors[path];
|
|
1002
|
+
return errors;
|
|
1003
|
+
});
|
|
1004
|
+
},
|
|
1005
|
+
[errorsState]
|
|
1006
|
+
);
|
|
1007
|
+
const setFieldError = useCallback12(
|
|
1008
|
+
(path, error) => {
|
|
1009
|
+
if (error == null || error === false) {
|
|
1010
|
+
clearFieldError(path);
|
|
1011
|
+
} else if (errorsState[path] !== error) {
|
|
1012
|
+
setErrors((current) => ({ ...current, [path]: error }));
|
|
1013
|
+
}
|
|
1014
|
+
},
|
|
1015
|
+
[errorsState]
|
|
1016
|
+
);
|
|
1017
|
+
return {
|
|
1018
|
+
errorsState,
|
|
1019
|
+
setErrors,
|
|
1020
|
+
clearErrors,
|
|
1021
|
+
setFieldError,
|
|
1022
|
+
clearFieldError
|
|
1023
|
+
};
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
// ../../node_modules/@mantine/form/esm/hooks/use-form-list/use-form-list.mjs
|
|
1027
|
+
import { useCallback as useCallback13 } from "react";
|
|
1028
|
+
|
|
1029
|
+
// ../../node_modules/@mantine/form/esm/lists/clear-list-state.mjs
|
|
1030
|
+
function clearListState(field, state) {
|
|
1031
|
+
if (state === null || typeof state !== "object") {
|
|
1032
|
+
return {};
|
|
1033
|
+
}
|
|
1034
|
+
const clone = { ...state };
|
|
1035
|
+
Object.keys(state).forEach((errorKey) => {
|
|
1036
|
+
if (errorKey.includes(`${String(field)}.`)) {
|
|
1037
|
+
delete clone[errorKey];
|
|
1038
|
+
}
|
|
1039
|
+
});
|
|
1040
|
+
return clone;
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
// ../../node_modules/@mantine/form/esm/lists/change-error-indices.mjs
|
|
1044
|
+
function getIndexFromKeyAfterPath(key, path) {
|
|
1045
|
+
const split = key.substring(path.length + 1).split(".")[0];
|
|
1046
|
+
return parseInt(split, 10);
|
|
1047
|
+
}
|
|
1048
|
+
function changeErrorIndices(path, index, errors, change) {
|
|
1049
|
+
if (index === void 0) {
|
|
1050
|
+
return errors;
|
|
1051
|
+
}
|
|
1052
|
+
const pathString = `${String(path)}`;
|
|
1053
|
+
let clearedErrors = errors;
|
|
1054
|
+
if (change === -1) {
|
|
1055
|
+
clearedErrors = clearListState(`${pathString}.${index}`, clearedErrors);
|
|
1056
|
+
}
|
|
1057
|
+
const cloned = { ...clearedErrors };
|
|
1058
|
+
const changedKeys = /* @__PURE__ */ new Set();
|
|
1059
|
+
Object.entries(clearedErrors).filter(([key]) => {
|
|
1060
|
+
if (!key.startsWith(`${pathString}.`)) {
|
|
1061
|
+
return false;
|
|
1062
|
+
}
|
|
1063
|
+
const currIndex = getIndexFromKeyAfterPath(key, pathString);
|
|
1064
|
+
if (Number.isNaN(currIndex)) {
|
|
1065
|
+
return false;
|
|
1066
|
+
}
|
|
1067
|
+
return currIndex >= index;
|
|
1068
|
+
}).forEach(([key, value]) => {
|
|
1069
|
+
const currIndex = getIndexFromKeyAfterPath(key, pathString);
|
|
1070
|
+
const newKey = key.replace(
|
|
1071
|
+
`${pathString}.${currIndex}`,
|
|
1072
|
+
`${pathString}.${currIndex + change}`
|
|
1073
|
+
);
|
|
1074
|
+
cloned[newKey] = value;
|
|
1075
|
+
changedKeys.add(newKey);
|
|
1076
|
+
if (!changedKeys.has(key)) {
|
|
1077
|
+
delete cloned[key];
|
|
1078
|
+
}
|
|
1079
|
+
});
|
|
1080
|
+
return cloned;
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1083
|
+
// ../../node_modules/@mantine/form/esm/lists/reorder-errors.mjs
|
|
1084
|
+
function reorderErrors(path, { from, to }, errors) {
|
|
1085
|
+
const oldKeyStart = `${path}.${from}`;
|
|
1086
|
+
const newKeyStart = `${path}.${to}`;
|
|
1087
|
+
const clone = { ...errors };
|
|
1088
|
+
Object.keys(errors).every((key) => {
|
|
1089
|
+
let oldKey;
|
|
1090
|
+
let newKey;
|
|
1091
|
+
if (key.startsWith(oldKeyStart)) {
|
|
1092
|
+
oldKey = key;
|
|
1093
|
+
newKey = key.replace(oldKeyStart, newKeyStart);
|
|
1094
|
+
}
|
|
1095
|
+
if (key.startsWith(newKeyStart)) {
|
|
1096
|
+
oldKey = key.replace(newKeyStart, oldKeyStart);
|
|
1097
|
+
newKey = key;
|
|
1098
|
+
}
|
|
1099
|
+
if (oldKey && newKey) {
|
|
1100
|
+
const value1 = clone[oldKey];
|
|
1101
|
+
const value2 = clone[newKey];
|
|
1102
|
+
value2 === void 0 ? delete clone[oldKey] : clone[oldKey] = value2;
|
|
1103
|
+
value1 === void 0 ? delete clone[newKey] : clone[newKey] = value1;
|
|
1104
|
+
return false;
|
|
1105
|
+
}
|
|
1106
|
+
return true;
|
|
1107
|
+
});
|
|
1108
|
+
return clone;
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
// ../../node_modules/klona/full/index.mjs
|
|
1112
|
+
function set(obj, key, val) {
|
|
1113
|
+
if (typeof val.value === "object")
|
|
1114
|
+
val.value = klona(val.value);
|
|
1115
|
+
if (!val.enumerable || val.get || val.set || !val.configurable || !val.writable || key === "__proto__") {
|
|
1116
|
+
Object.defineProperty(obj, key, val);
|
|
1117
|
+
} else
|
|
1118
|
+
obj[key] = val.value;
|
|
1119
|
+
}
|
|
1120
|
+
function klona(x) {
|
|
1121
|
+
if (typeof x !== "object")
|
|
1122
|
+
return x;
|
|
1123
|
+
var i = 0, k, list, tmp, str = Object.prototype.toString.call(x);
|
|
1124
|
+
if (str === "[object Object]") {
|
|
1125
|
+
tmp = Object.create(x.__proto__ || null);
|
|
1126
|
+
} else if (str === "[object Array]") {
|
|
1127
|
+
tmp = Array(x.length);
|
|
1128
|
+
} else if (str === "[object Set]") {
|
|
1129
|
+
tmp = /* @__PURE__ */ new Set();
|
|
1130
|
+
x.forEach(function(val) {
|
|
1131
|
+
tmp.add(klona(val));
|
|
1132
|
+
});
|
|
1133
|
+
} else if (str === "[object Map]") {
|
|
1134
|
+
tmp = /* @__PURE__ */ new Map();
|
|
1135
|
+
x.forEach(function(val, key) {
|
|
1136
|
+
tmp.set(klona(key), klona(val));
|
|
1137
|
+
});
|
|
1138
|
+
} else if (str === "[object Date]") {
|
|
1139
|
+
tmp = /* @__PURE__ */ new Date(+x);
|
|
1140
|
+
} else if (str === "[object RegExp]") {
|
|
1141
|
+
tmp = new RegExp(x.source, x.flags);
|
|
1142
|
+
} else if (str === "[object DataView]") {
|
|
1143
|
+
tmp = new x.constructor(klona(x.buffer));
|
|
1144
|
+
} else if (str === "[object ArrayBuffer]") {
|
|
1145
|
+
tmp = x.slice(0);
|
|
1146
|
+
} else if (str.slice(-6) === "Array]") {
|
|
1147
|
+
tmp = new x.constructor(x);
|
|
1148
|
+
}
|
|
1149
|
+
if (tmp) {
|
|
1150
|
+
for (list = Object.getOwnPropertySymbols(x); i < list.length; i++) {
|
|
1151
|
+
set(tmp, list[i], Object.getOwnPropertyDescriptor(x, list[i]));
|
|
1152
|
+
}
|
|
1153
|
+
for (i = 0, list = Object.getOwnPropertyNames(x); i < list.length; i++) {
|
|
1154
|
+
if (Object.hasOwnProperty.call(tmp, k = list[i]) && tmp[k] === x[k])
|
|
1155
|
+
continue;
|
|
1156
|
+
set(tmp, k, Object.getOwnPropertyDescriptor(x, k));
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
return tmp || x;
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
// ../../node_modules/@mantine/form/esm/paths/get-splitted-path.mjs
|
|
1163
|
+
function getSplittedPath(path) {
|
|
1164
|
+
if (typeof path !== "string") {
|
|
1165
|
+
return [];
|
|
1166
|
+
}
|
|
1167
|
+
return path.split(".");
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
// ../../node_modules/@mantine/form/esm/paths/get-path.mjs
|
|
1171
|
+
function getPath(path, values) {
|
|
1172
|
+
const splittedPath = getSplittedPath(path);
|
|
1173
|
+
if (splittedPath.length === 0 || typeof values !== "object" || values === null) {
|
|
1174
|
+
return void 0;
|
|
1175
|
+
}
|
|
1176
|
+
let value = values[splittedPath[0]];
|
|
1177
|
+
for (let i = 1; i < splittedPath.length; i += 1) {
|
|
1178
|
+
if (value === void 0) {
|
|
1179
|
+
break;
|
|
1180
|
+
}
|
|
1181
|
+
value = value[splittedPath[i]];
|
|
1182
|
+
}
|
|
1183
|
+
return value;
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
// ../../node_modules/@mantine/form/esm/paths/set-path.mjs
|
|
1187
|
+
function setPath(path, value, values) {
|
|
1188
|
+
const splittedPath = getSplittedPath(path);
|
|
1189
|
+
if (splittedPath.length === 0) {
|
|
1190
|
+
return values;
|
|
1191
|
+
}
|
|
1192
|
+
const cloned = klona(values);
|
|
1193
|
+
if (splittedPath.length === 1) {
|
|
1194
|
+
cloned[splittedPath[0]] = value;
|
|
1195
|
+
return cloned;
|
|
1196
|
+
}
|
|
1197
|
+
let val = cloned[splittedPath[0]];
|
|
1198
|
+
for (let i = 1; i < splittedPath.length - 1; i += 1) {
|
|
1199
|
+
if (val === void 0) {
|
|
1200
|
+
return cloned;
|
|
1201
|
+
}
|
|
1202
|
+
val = val[splittedPath[i]];
|
|
1203
|
+
}
|
|
1204
|
+
val[splittedPath[splittedPath.length - 1]] = value;
|
|
1205
|
+
return cloned;
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1208
|
+
// ../../node_modules/@mantine/form/esm/paths/reorder-path.mjs
|
|
1209
|
+
function reorderPath(path, { from, to }, values) {
|
|
1210
|
+
const currentValue = getPath(path, values);
|
|
1211
|
+
if (!Array.isArray(currentValue)) {
|
|
1212
|
+
return values;
|
|
1213
|
+
}
|
|
1214
|
+
const cloned = [...currentValue];
|
|
1215
|
+
const item = currentValue[from];
|
|
1216
|
+
cloned.splice(from, 1);
|
|
1217
|
+
cloned.splice(to, 0, item);
|
|
1218
|
+
return setPath(path, cloned, values);
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
// ../../node_modules/@mantine/form/esm/paths/insert-path.mjs
|
|
1222
|
+
function insertPath(path, value, index, values) {
|
|
1223
|
+
const currentValue = getPath(path, values);
|
|
1224
|
+
if (!Array.isArray(currentValue)) {
|
|
1225
|
+
return values;
|
|
1226
|
+
}
|
|
1227
|
+
const cloned = [...currentValue];
|
|
1228
|
+
cloned.splice(typeof index === "number" ? index : cloned.length, 0, value);
|
|
1229
|
+
return setPath(path, cloned, values);
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1232
|
+
// ../../node_modules/@mantine/form/esm/paths/remove-path.mjs
|
|
1233
|
+
function removePath(path, index, values) {
|
|
1234
|
+
const currentValue = getPath(path, values);
|
|
1235
|
+
if (!Array.isArray(currentValue)) {
|
|
1236
|
+
return values;
|
|
1237
|
+
}
|
|
1238
|
+
return setPath(
|
|
1239
|
+
path,
|
|
1240
|
+
currentValue.filter((_, itemIndex) => itemIndex !== index),
|
|
1241
|
+
values
|
|
1242
|
+
);
|
|
1243
|
+
}
|
|
1244
|
+
|
|
1245
|
+
// ../../node_modules/@mantine/form/esm/hooks/use-form-list/use-form-list.mjs
|
|
1246
|
+
function useFormList({
|
|
1247
|
+
$values,
|
|
1248
|
+
$errors,
|
|
1249
|
+
$status
|
|
1250
|
+
}) {
|
|
1251
|
+
const reorderListItem = useCallback13((path, payload) => {
|
|
1252
|
+
$status.clearFieldDirty(path);
|
|
1253
|
+
$errors.setErrors((errs) => reorderErrors(path, payload, errs));
|
|
1254
|
+
$values.setValues({
|
|
1255
|
+
values: reorderPath(path, payload, $values.refValues.current),
|
|
1256
|
+
updateState: true
|
|
1257
|
+
});
|
|
1258
|
+
}, []);
|
|
1259
|
+
const removeListItem = useCallback13((path, index) => {
|
|
1260
|
+
$status.clearFieldDirty(path);
|
|
1261
|
+
$errors.setErrors((errs) => changeErrorIndices(path, index, errs, -1));
|
|
1262
|
+
$values.setValues({
|
|
1263
|
+
values: removePath(path, index, $values.refValues.current),
|
|
1264
|
+
updateState: true
|
|
1265
|
+
});
|
|
1266
|
+
}, []);
|
|
1267
|
+
const insertListItem = useCallback13((path, item, index) => {
|
|
1268
|
+
$status.clearFieldDirty(path);
|
|
1269
|
+
$errors.setErrors((errs) => changeErrorIndices(path, index, errs, 1));
|
|
1270
|
+
$values.setValues({
|
|
1271
|
+
values: insertPath(path, item, index, $values.refValues.current),
|
|
1272
|
+
updateState: true
|
|
1273
|
+
});
|
|
1274
|
+
}, []);
|
|
1275
|
+
return { reorderListItem, removeListItem, insertListItem };
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
// ../../node_modules/@mantine/form/esm/hooks/use-form-status/use-form-status.mjs
|
|
1279
|
+
var import_fast_deep_equal = __toESM(require_fast_deep_equal(), 1);
|
|
1280
|
+
import { useState as useState9, useRef, useCallback as useCallback14 } from "react";
|
|
1281
|
+
|
|
1282
|
+
// ../../node_modules/@mantine/form/esm/get-status/get-status.mjs
|
|
1283
|
+
function getStatus(status, path) {
|
|
1284
|
+
const paths = Object.keys(status);
|
|
1285
|
+
if (typeof path === "string") {
|
|
1286
|
+
const nestedPaths = paths.filter((statusPath) => statusPath.startsWith(`${path}.`));
|
|
1287
|
+
return status[path] || nestedPaths.some((statusPath) => status[statusPath]) || false;
|
|
1288
|
+
}
|
|
1289
|
+
return paths.some((statusPath) => status[statusPath]);
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
// ../../node_modules/@mantine/form/esm/hooks/use-form-status/use-form-status.mjs
|
|
1293
|
+
function useFormStatus({
|
|
1294
|
+
initialDirty,
|
|
1295
|
+
initialTouched,
|
|
1296
|
+
mode,
|
|
1297
|
+
$values
|
|
1298
|
+
}) {
|
|
1299
|
+
const [touchedState, setTouchedState] = useState9(initialTouched);
|
|
1300
|
+
const [dirtyState, setDirtyState] = useState9(initialDirty);
|
|
1301
|
+
const touchedRef = useRef(initialTouched);
|
|
1302
|
+
const dirtyRef = useRef(initialDirty);
|
|
1303
|
+
const setTouched = useCallback14((values) => {
|
|
1304
|
+
const resolvedValues = typeof values === "function" ? values(touchedRef.current) : values;
|
|
1305
|
+
touchedRef.current = resolvedValues;
|
|
1306
|
+
if (mode === "controlled") {
|
|
1307
|
+
setTouchedState(resolvedValues);
|
|
1308
|
+
}
|
|
1309
|
+
}, []);
|
|
1310
|
+
const setDirty = useCallback14((values) => {
|
|
1311
|
+
const resolvedValues = typeof values === "function" ? values(dirtyRef.current) : values;
|
|
1312
|
+
dirtyRef.current = resolvedValues;
|
|
1313
|
+
if (mode === "controlled") {
|
|
1314
|
+
setDirtyState(resolvedValues);
|
|
1315
|
+
}
|
|
1316
|
+
}, []);
|
|
1317
|
+
const resetTouched = useCallback14(() => setTouched({}), []);
|
|
1318
|
+
const resetDirty = (values) => {
|
|
1319
|
+
const newSnapshot = values ? { ...values, ...$values.refValues.current } : $values.refValues.current;
|
|
1320
|
+
$values.setValuesSnapshot(newSnapshot);
|
|
1321
|
+
setDirty({});
|
|
1322
|
+
};
|
|
1323
|
+
const setFieldTouched = useCallback14((path, touched) => {
|
|
1324
|
+
setTouched((currentTouched) => {
|
|
1325
|
+
if (getStatus(currentTouched, path) === touched) {
|
|
1326
|
+
return currentTouched;
|
|
1327
|
+
}
|
|
1328
|
+
return { ...currentTouched, [path]: touched };
|
|
1329
|
+
});
|
|
1330
|
+
}, []);
|
|
1331
|
+
const setFieldDirty = useCallback14((path, dirty) => {
|
|
1332
|
+
setDirty((currentDirty) => {
|
|
1333
|
+
if (getStatus(currentDirty, path) === dirty) {
|
|
1334
|
+
return currentDirty;
|
|
1335
|
+
}
|
|
1336
|
+
return { ...currentDirty, [path]: dirty };
|
|
1337
|
+
});
|
|
1338
|
+
}, []);
|
|
1339
|
+
const isTouched = useCallback14(
|
|
1340
|
+
(path) => getStatus(touchedRef.current, path),
|
|
1341
|
+
[]
|
|
1342
|
+
);
|
|
1343
|
+
const clearFieldDirty = useCallback14(
|
|
1344
|
+
(path) => setDirty((current) => {
|
|
1345
|
+
if (typeof path !== "string") {
|
|
1346
|
+
return current;
|
|
1347
|
+
}
|
|
1348
|
+
const result = clearListState(path, current);
|
|
1349
|
+
delete result[path];
|
|
1350
|
+
if ((0, import_fast_deep_equal.default)(result, current)) {
|
|
1351
|
+
return current;
|
|
1352
|
+
}
|
|
1353
|
+
return result;
|
|
1354
|
+
}),
|
|
1355
|
+
[]
|
|
1356
|
+
);
|
|
1357
|
+
const isDirty = useCallback14((path) => {
|
|
1358
|
+
if (path) {
|
|
1359
|
+
const overriddenValue = getPath(path, dirtyRef.current);
|
|
1360
|
+
if (typeof overriddenValue === "boolean") {
|
|
1361
|
+
return overriddenValue;
|
|
1362
|
+
}
|
|
1363
|
+
const sliceOfValues = getPath(path, $values.refValues.current);
|
|
1364
|
+
const sliceOfInitialValues = getPath(path, $values.valuesSnapshot.current);
|
|
1365
|
+
return !(0, import_fast_deep_equal.default)(sliceOfValues, sliceOfInitialValues);
|
|
1366
|
+
}
|
|
1367
|
+
const isOverridden = Object.keys(dirtyRef.current).length > 0;
|
|
1368
|
+
if (isOverridden) {
|
|
1369
|
+
return getStatus(dirtyRef.current);
|
|
1370
|
+
}
|
|
1371
|
+
return !(0, import_fast_deep_equal.default)($values.refValues.current, $values.valuesSnapshot.current);
|
|
1372
|
+
}, []);
|
|
1373
|
+
const getDirty = useCallback14(() => dirtyRef.current, []);
|
|
1374
|
+
const getTouched = useCallback14(() => touchedRef.current, []);
|
|
1375
|
+
return {
|
|
1376
|
+
touchedState,
|
|
1377
|
+
dirtyState,
|
|
1378
|
+
touchedRef,
|
|
1379
|
+
dirtyRef,
|
|
1380
|
+
setTouched,
|
|
1381
|
+
setDirty,
|
|
1382
|
+
resetDirty,
|
|
1383
|
+
resetTouched,
|
|
1384
|
+
isTouched,
|
|
1385
|
+
setFieldTouched,
|
|
1386
|
+
setFieldDirty,
|
|
1387
|
+
setTouchedState,
|
|
1388
|
+
setDirtyState,
|
|
1389
|
+
clearFieldDirty,
|
|
1390
|
+
isDirty,
|
|
1391
|
+
getDirty,
|
|
1392
|
+
getTouched
|
|
1393
|
+
};
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
// ../../node_modules/@mantine/form/esm/hooks/use-form-values/use-form-values.mjs
|
|
1397
|
+
import { useRef as useRef2, useState as useState10, useCallback as useCallback15 } from "react";
|
|
1398
|
+
function useFormValues({
|
|
1399
|
+
initialValues,
|
|
1400
|
+
onValuesChange,
|
|
1401
|
+
mode
|
|
1402
|
+
}) {
|
|
1403
|
+
const initialized = useRef2(false);
|
|
1404
|
+
const [stateValues, setStateValues] = useState10(initialValues || {});
|
|
1405
|
+
const refValues = useRef2(stateValues);
|
|
1406
|
+
const valuesSnapshot = useRef2(stateValues);
|
|
1407
|
+
const setValues = useCallback15(
|
|
1408
|
+
({
|
|
1409
|
+
values,
|
|
1410
|
+
subscribers,
|
|
1411
|
+
updateState = true,
|
|
1412
|
+
mergeWithPreviousValues = true
|
|
1413
|
+
}) => {
|
|
1414
|
+
const previousValues = refValues.current;
|
|
1415
|
+
const resolvedValues = values instanceof Function ? values(refValues.current) : values;
|
|
1416
|
+
const updatedValues = mergeWithPreviousValues ? { ...previousValues, ...resolvedValues } : resolvedValues;
|
|
1417
|
+
refValues.current = updatedValues;
|
|
1418
|
+
updateState && setStateValues(updatedValues);
|
|
1419
|
+
onValuesChange?.(updatedValues, previousValues);
|
|
1420
|
+
subscribers?.filter(Boolean).forEach((subscriber) => subscriber({ updatedValues, previousValues }));
|
|
1421
|
+
},
|
|
1422
|
+
[onValuesChange]
|
|
1423
|
+
);
|
|
1424
|
+
const setFieldValue = useCallback15((payload) => {
|
|
1425
|
+
const currentValue = getPath(payload.path, refValues.current);
|
|
1426
|
+
const updatedValue = payload.value instanceof Function ? payload.value(currentValue) : payload.value;
|
|
1427
|
+
if (currentValue !== updatedValue) {
|
|
1428
|
+
const previousValues = refValues.current;
|
|
1429
|
+
const updatedValues = setPath(payload.path, updatedValue, refValues.current);
|
|
1430
|
+
setValues({ values: updatedValues, updateState: payload.updateState });
|
|
1431
|
+
payload.subscribers?.filter(Boolean).forEach(
|
|
1432
|
+
(subscriber) => subscriber({ path: payload.path, updatedValues, previousValues })
|
|
1433
|
+
);
|
|
1434
|
+
}
|
|
1435
|
+
}, []);
|
|
1436
|
+
const setValuesSnapshot = useCallback15((payload) => {
|
|
1437
|
+
valuesSnapshot.current = payload;
|
|
1438
|
+
}, []);
|
|
1439
|
+
const initialize = useCallback15((values, onInitialize) => {
|
|
1440
|
+
if (!initialized.current) {
|
|
1441
|
+
initialized.current = true;
|
|
1442
|
+
setValues({ values, updateState: mode === "controlled" });
|
|
1443
|
+
setValuesSnapshot(values);
|
|
1444
|
+
onInitialize();
|
|
1445
|
+
}
|
|
1446
|
+
}, []);
|
|
1447
|
+
const resetValues = useCallback15(() => {
|
|
1448
|
+
setValues({
|
|
1449
|
+
values: valuesSnapshot.current,
|
|
1450
|
+
updateState: true,
|
|
1451
|
+
mergeWithPreviousValues: false
|
|
1452
|
+
});
|
|
1453
|
+
}, []);
|
|
1454
|
+
const getValues = useCallback15(() => refValues.current, []);
|
|
1455
|
+
return {
|
|
1456
|
+
initialized,
|
|
1457
|
+
stateValues,
|
|
1458
|
+
refValues,
|
|
1459
|
+
valuesSnapshot,
|
|
1460
|
+
setValues,
|
|
1461
|
+
setFieldValue,
|
|
1462
|
+
resetValues,
|
|
1463
|
+
setValuesSnapshot,
|
|
1464
|
+
initialize,
|
|
1465
|
+
getValues
|
|
1466
|
+
};
|
|
1467
|
+
}
|
|
1468
|
+
|
|
1469
|
+
// ../../node_modules/@mantine/form/esm/hooks/use-form-watch/use-form-watch.mjs
|
|
1470
|
+
import { useRef as useRef3, useCallback as useCallback16, useEffect as useEffect13 } from "react";
|
|
1471
|
+
function useFormWatch({
|
|
1472
|
+
$status
|
|
1473
|
+
}) {
|
|
1474
|
+
const subscribers = useRef3(
|
|
1475
|
+
{}
|
|
1476
|
+
);
|
|
1477
|
+
const watch = useCallback16((path, callback) => {
|
|
1478
|
+
useEffect13(() => {
|
|
1479
|
+
subscribers.current[path] = subscribers.current[path] || [];
|
|
1480
|
+
subscribers.current[path].push(callback);
|
|
1481
|
+
return () => {
|
|
1482
|
+
subscribers.current[path] = subscribers.current[path].filter((cb) => cb !== callback);
|
|
1483
|
+
};
|
|
1484
|
+
}, [callback]);
|
|
1485
|
+
}, []);
|
|
1486
|
+
const getFieldSubscribers = useCallback16((path) => {
|
|
1487
|
+
if (!subscribers.current[path]) {
|
|
1488
|
+
return [];
|
|
1489
|
+
}
|
|
1490
|
+
return subscribers.current[path].map(
|
|
1491
|
+
(callback) => (input) => callback({
|
|
1492
|
+
previousValue: getPath(path, input.previousValues),
|
|
1493
|
+
value: getPath(path, input.updatedValues),
|
|
1494
|
+
touched: $status.isTouched(path),
|
|
1495
|
+
dirty: $status.isDirty(path)
|
|
1496
|
+
})
|
|
1497
|
+
);
|
|
1498
|
+
}, []);
|
|
1499
|
+
return {
|
|
1500
|
+
subscribers,
|
|
1501
|
+
watch,
|
|
1502
|
+
getFieldSubscribers
|
|
1503
|
+
};
|
|
1504
|
+
}
|
|
1505
|
+
|
|
1506
|
+
// ../../node_modules/@mantine/form/esm/validate/validate-values.mjs
|
|
1507
|
+
function getValidationResults(errors) {
|
|
1508
|
+
const filteredErrors = filterErrors(errors);
|
|
1509
|
+
return { hasErrors: Object.keys(filteredErrors).length > 0, errors: filteredErrors };
|
|
1510
|
+
}
|
|
1511
|
+
function validateRulesRecord(rules, values, path = "", errors = {}) {
|
|
1512
|
+
if (typeof rules !== "object" || rules === null) {
|
|
1513
|
+
return errors;
|
|
1514
|
+
}
|
|
1515
|
+
return Object.keys(rules).reduce((acc, ruleKey) => {
|
|
1516
|
+
const rule = rules[ruleKey];
|
|
1517
|
+
const rulePath = `${path === "" ? "" : `${path}.`}${ruleKey}`;
|
|
1518
|
+
const value = getPath(rulePath, values);
|
|
1519
|
+
let arrayValidation = false;
|
|
1520
|
+
if (typeof rule === "function") {
|
|
1521
|
+
acc[rulePath] = rule(value, values, rulePath);
|
|
1522
|
+
}
|
|
1523
|
+
if (typeof rule === "object" && Array.isArray(value)) {
|
|
1524
|
+
arrayValidation = true;
|
|
1525
|
+
value.forEach(
|
|
1526
|
+
(_item, index) => validateRulesRecord(rule, values, `${rulePath}.${index}`, acc)
|
|
1527
|
+
);
|
|
1528
|
+
}
|
|
1529
|
+
if (typeof rule === "object" && typeof value === "object" && value !== null) {
|
|
1530
|
+
if (!arrayValidation) {
|
|
1531
|
+
validateRulesRecord(rule, values, rulePath, acc);
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1534
|
+
return acc;
|
|
1535
|
+
}, errors);
|
|
1536
|
+
}
|
|
1537
|
+
function validateValues(validate, values) {
|
|
1538
|
+
if (typeof validate === "function") {
|
|
1539
|
+
return getValidationResults(validate(values));
|
|
1540
|
+
}
|
|
1541
|
+
return getValidationResults(validateRulesRecord(validate, values));
|
|
1542
|
+
}
|
|
1543
|
+
|
|
1544
|
+
// ../../node_modules/@mantine/form/esm/validate/validate-field-value.mjs
|
|
1545
|
+
function validateFieldValue(path, rules, values) {
|
|
1546
|
+
if (typeof path !== "string") {
|
|
1547
|
+
return { hasError: false, error: null };
|
|
1548
|
+
}
|
|
1549
|
+
const results = validateValues(rules, values);
|
|
1550
|
+
const pathInError = Object.keys(results.errors).find(
|
|
1551
|
+
(errorKey) => path.split(".").every((pathPart, i) => pathPart === errorKey.split(".")[i])
|
|
1552
|
+
);
|
|
1553
|
+
return { hasError: !!pathInError, error: pathInError ? results.errors[pathInError] : null };
|
|
1554
|
+
}
|
|
1555
|
+
|
|
1556
|
+
// ../../node_modules/@mantine/form/esm/form-index.mjs
|
|
1557
|
+
var FORM_INDEX = "__MANTINE_FORM_INDEX__";
|
|
1558
|
+
|
|
1559
|
+
// ../../node_modules/@mantine/form/esm/validate/should-validate-on-change.mjs
|
|
1560
|
+
function shouldValidateOnChange(path, validateInputOnChange) {
|
|
1561
|
+
if (!validateInputOnChange) {
|
|
1562
|
+
return false;
|
|
1563
|
+
}
|
|
1564
|
+
if (typeof validateInputOnChange === "boolean") {
|
|
1565
|
+
return validateInputOnChange;
|
|
1566
|
+
}
|
|
1567
|
+
if (Array.isArray(validateInputOnChange)) {
|
|
1568
|
+
return validateInputOnChange.includes(path.replace(/[.][0-9]/g, `.${FORM_INDEX}`));
|
|
1569
|
+
}
|
|
1570
|
+
return false;
|
|
1571
|
+
}
|
|
1572
|
+
|
|
1573
|
+
// ../../node_modules/@mantine/form/esm/use-form.mjs
|
|
1574
|
+
function useForm({
|
|
1575
|
+
name,
|
|
1576
|
+
mode = "controlled",
|
|
1577
|
+
initialValues,
|
|
1578
|
+
initialErrors = {},
|
|
1579
|
+
initialDirty = {},
|
|
1580
|
+
initialTouched = {},
|
|
1581
|
+
clearInputErrorOnChange = true,
|
|
1582
|
+
validateInputOnChange = false,
|
|
1583
|
+
validateInputOnBlur = false,
|
|
1584
|
+
onValuesChange,
|
|
1585
|
+
transformValues = (values) => values,
|
|
1586
|
+
enhanceGetInputProps,
|
|
1587
|
+
validate: rules
|
|
1588
|
+
} = {}) {
|
|
1589
|
+
const $errors = useFormErrors(initialErrors);
|
|
1590
|
+
const $values = useFormValues({ initialValues, onValuesChange, mode });
|
|
1591
|
+
const $status = useFormStatus({ initialDirty, initialTouched, $values, mode });
|
|
1592
|
+
const $list = useFormList({ $values, $errors, $status });
|
|
1593
|
+
const $watch = useFormWatch({ $status });
|
|
1594
|
+
const [formKey, setFormKey] = useState11(0);
|
|
1595
|
+
const [fieldKeys, setFieldKeys] = useState11({});
|
|
1596
|
+
const reset = useCallback17(() => {
|
|
1597
|
+
$values.resetValues();
|
|
1598
|
+
$errors.clearErrors();
|
|
1599
|
+
$status.resetDirty();
|
|
1600
|
+
$status.resetTouched();
|
|
1601
|
+
mode === "uncontrolled" && setFormKey((key2) => key2 + 1);
|
|
1602
|
+
}, []);
|
|
1603
|
+
const initialize = useCallback17((values) => {
|
|
1604
|
+
$values.initialize(values, () => mode === "uncontrolled" && setFormKey((key2) => key2 + 1));
|
|
1605
|
+
}, []);
|
|
1606
|
+
const setFieldValue = useCallback17(
|
|
1607
|
+
(path, value, options3) => {
|
|
1608
|
+
const shouldValidate = shouldValidateOnChange(path, validateInputOnChange);
|
|
1609
|
+
$status.clearFieldDirty(path);
|
|
1610
|
+
$status.setFieldTouched(path, true);
|
|
1611
|
+
!shouldValidate && clearInputErrorOnChange && $errors.clearFieldError(path);
|
|
1612
|
+
$values.setFieldValue({
|
|
1613
|
+
path,
|
|
1614
|
+
value,
|
|
1615
|
+
updateState: mode === "controlled",
|
|
1616
|
+
subscribers: [
|
|
1617
|
+
...$watch.getFieldSubscribers(path),
|
|
1618
|
+
shouldValidate ? (payload) => {
|
|
1619
|
+
const validationResults = validateFieldValue(path, rules, payload.updatedValues);
|
|
1620
|
+
validationResults.hasError ? $errors.setFieldError(path, validationResults.error) : $errors.clearFieldError(path);
|
|
1621
|
+
} : null,
|
|
1622
|
+
options3?.forceUpdate !== false && mode !== "controlled" ? () => setFieldKeys((keys) => ({
|
|
1623
|
+
...keys,
|
|
1624
|
+
[path]: (keys[path] || 0) + 1
|
|
1625
|
+
})) : null
|
|
1626
|
+
]
|
|
1627
|
+
});
|
|
1628
|
+
},
|
|
1629
|
+
[onValuesChange, rules]
|
|
1630
|
+
);
|
|
1631
|
+
const setValues = useCallback17(
|
|
1632
|
+
(values) => {
|
|
1633
|
+
const previousValues = $values.refValues.current;
|
|
1634
|
+
$values.setValues({ values, updateState: mode === "controlled" });
|
|
1635
|
+
clearInputErrorOnChange && $errors.clearErrors();
|
|
1636
|
+
mode === "uncontrolled" && setFormKey((key2) => key2 + 1);
|
|
1637
|
+
Object.keys($watch.subscribers.current).forEach((path) => {
|
|
1638
|
+
const value = getPath(path, $values.refValues.current);
|
|
1639
|
+
const previousValue = getPath(path, previousValues);
|
|
1640
|
+
if (value !== previousValue) {
|
|
1641
|
+
$watch.getFieldSubscribers(path).forEach((cb) => cb({ previousValues, updatedValues: $values.refValues.current }));
|
|
1642
|
+
}
|
|
1643
|
+
});
|
|
1644
|
+
},
|
|
1645
|
+
[onValuesChange, clearInputErrorOnChange]
|
|
1646
|
+
);
|
|
1647
|
+
const validate = useCallback17(() => {
|
|
1648
|
+
const results = validateValues(rules, $values.refValues.current);
|
|
1649
|
+
$errors.setErrors(results.errors);
|
|
1650
|
+
return results;
|
|
1651
|
+
}, [rules]);
|
|
1652
|
+
const validateField = useCallback17(
|
|
1653
|
+
(path) => {
|
|
1654
|
+
const results = validateFieldValue(path, rules, $values.refValues.current);
|
|
1655
|
+
results.hasError ? $errors.setFieldError(path, results.error) : $errors.clearFieldError(path);
|
|
1656
|
+
return results;
|
|
1657
|
+
},
|
|
1658
|
+
[rules]
|
|
1659
|
+
);
|
|
1660
|
+
const getInputProps = (path, { type = "input", withError = true, withFocus = true, ...otherOptions } = {}) => {
|
|
1661
|
+
const onChange = getInputOnChange(
|
|
1662
|
+
(value) => setFieldValue(path, value, { forceUpdate: false })
|
|
1663
|
+
);
|
|
1664
|
+
const payload = { onChange };
|
|
1665
|
+
if (withError) {
|
|
1666
|
+
payload.error = $errors.errorsState[path];
|
|
1667
|
+
}
|
|
1668
|
+
if (type === "checkbox") {
|
|
1669
|
+
payload[mode === "controlled" ? "checked" : "defaultChecked"] = getPath(
|
|
1670
|
+
path,
|
|
1671
|
+
$values.refValues.current
|
|
1672
|
+
);
|
|
1673
|
+
} else {
|
|
1674
|
+
payload[mode === "controlled" ? "value" : "defaultValue"] = getPath(
|
|
1675
|
+
path,
|
|
1676
|
+
$values.refValues.current
|
|
1677
|
+
);
|
|
1678
|
+
}
|
|
1679
|
+
if (withFocus) {
|
|
1680
|
+
payload.onFocus = () => $status.setFieldTouched(path, true);
|
|
1681
|
+
payload.onBlur = () => {
|
|
1682
|
+
if (shouldValidateOnChange(path, validateInputOnBlur)) {
|
|
1683
|
+
const validationResults = validateFieldValue(path, rules, $values.refValues.current);
|
|
1684
|
+
validationResults.hasError ? $errors.setFieldError(path, validationResults.error) : $errors.clearFieldError(path);
|
|
1685
|
+
}
|
|
1686
|
+
};
|
|
1687
|
+
}
|
|
1688
|
+
return Object.assign(
|
|
1689
|
+
payload,
|
|
1690
|
+
enhanceGetInputProps?.({
|
|
1691
|
+
inputProps: payload,
|
|
1692
|
+
field: path,
|
|
1693
|
+
options: { type, withError, withFocus, ...otherOptions },
|
|
1694
|
+
form
|
|
1695
|
+
})
|
|
1696
|
+
);
|
|
1697
|
+
};
|
|
1698
|
+
const onSubmit = (handleSubmit, handleValidationFailure) => (event) => {
|
|
1699
|
+
event?.preventDefault();
|
|
1700
|
+
const results = validate();
|
|
1701
|
+
if (results.hasErrors) {
|
|
1702
|
+
handleValidationFailure?.(results.errors, $values.refValues.current, event);
|
|
1703
|
+
} else {
|
|
1704
|
+
handleSubmit?.(transformValues($values.refValues.current), event);
|
|
1705
|
+
}
|
|
1706
|
+
};
|
|
1707
|
+
const getTransformedValues = (input) => transformValues(input || $values.refValues.current);
|
|
1708
|
+
const onReset = useCallback17((event) => {
|
|
1709
|
+
event.preventDefault();
|
|
1710
|
+
reset();
|
|
1711
|
+
}, []);
|
|
1712
|
+
const isValid = useCallback17(
|
|
1713
|
+
(path) => path ? !validateFieldValue(path, rules, $values.refValues.current).hasError : !validateValues(rules, $values.refValues.current).hasErrors,
|
|
1714
|
+
[rules]
|
|
1715
|
+
);
|
|
1716
|
+
const key = (path) => `${formKey}-${path}-${fieldKeys[path] || 0}`;
|
|
1717
|
+
const form = {
|
|
1718
|
+
watch: $watch.watch,
|
|
1719
|
+
initialized: $values.initialized.current,
|
|
1720
|
+
values: $values.stateValues,
|
|
1721
|
+
getValues: $values.getValues,
|
|
1722
|
+
setInitialValues: $values.setValuesSnapshot,
|
|
1723
|
+
initialize,
|
|
1724
|
+
setValues,
|
|
1725
|
+
setFieldValue,
|
|
1726
|
+
errors: $errors.errorsState,
|
|
1727
|
+
setErrors: $errors.setErrors,
|
|
1728
|
+
setFieldError: $errors.setFieldError,
|
|
1729
|
+
clearFieldError: $errors.clearFieldError,
|
|
1730
|
+
clearErrors: $errors.clearErrors,
|
|
1731
|
+
resetDirty: $status.resetDirty,
|
|
1732
|
+
setTouched: $status.setTouched,
|
|
1733
|
+
setDirty: $status.setDirty,
|
|
1734
|
+
isTouched: $status.isTouched,
|
|
1735
|
+
resetTouched: $status.resetTouched,
|
|
1736
|
+
isDirty: $status.isDirty,
|
|
1737
|
+
getTouched: $status.getTouched,
|
|
1738
|
+
getDirty: $status.getDirty,
|
|
1739
|
+
reorderListItem: $list.reorderListItem,
|
|
1740
|
+
insertListItem: $list.insertListItem,
|
|
1741
|
+
removeListItem: $list.removeListItem,
|
|
1742
|
+
reset,
|
|
1743
|
+
validate,
|
|
1744
|
+
validateField,
|
|
1745
|
+
getInputProps,
|
|
1746
|
+
onSubmit,
|
|
1747
|
+
onReset,
|
|
1748
|
+
isValid,
|
|
1749
|
+
getTransformedValues,
|
|
1750
|
+
key
|
|
1751
|
+
};
|
|
1752
|
+
useFormActions(name, form);
|
|
1753
|
+
return form;
|
|
1754
|
+
}
|
|
1755
|
+
|
|
1756
|
+
// src/nodes/modifiers/noise-curve-node.tsx
|
|
1757
|
+
import { useCallback as useCallback18, useEffect as useEffect14, useState as useState12 } from "react";
|
|
1758
|
+
import { Curve } from "libnoise-ts/module/modifier";
|
|
1759
|
+
import { Tuple } from "libnoise-ts/util";
|
|
1760
|
+
import { IconX } from "@tabler/icons-react";
|
|
1761
|
+
import { randomId } from "@mantine/hooks";
|
|
1762
|
+
import { NodeState } from "@awesome-flow/core/abstract";
|
|
1763
|
+
import { Fragment as Fragment3, jsx as jsx21, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
1764
|
+
function NoiseCurveNode({ id, selected, data, type }) {
|
|
1765
|
+
const incoming = useIncomingComputedData4(id);
|
|
1766
|
+
const updateNodeData = useUpdateNodeData9();
|
|
1767
|
+
const updateComputedData = useUpdateNodeComputedData15();
|
|
1768
|
+
const [values, setValues] = useState12([]);
|
|
1769
|
+
const form = useForm({
|
|
1770
|
+
mode: "uncontrolled",
|
|
1771
|
+
initialValues: {
|
|
1772
|
+
points: []
|
|
1773
|
+
},
|
|
1774
|
+
validateInputOnChange: [`points.${FORM_INDEX}.input`],
|
|
1775
|
+
clearInputErrorOnChange: true,
|
|
1776
|
+
validate: {
|
|
1777
|
+
points: {
|
|
1778
|
+
input: (value, values2) => {
|
|
1779
|
+
const counts = {};
|
|
1780
|
+
values2.points.forEach((x) => {
|
|
1781
|
+
counts[x.input] = (counts[x.input] || 0) + 1;
|
|
1782
|
+
});
|
|
1783
|
+
return counts[value] > 1;
|
|
1784
|
+
}
|
|
1785
|
+
}
|
|
1786
|
+
},
|
|
1787
|
+
onValuesChange: useCallback18((values2) => {
|
|
1788
|
+
if (form.isValid()) {
|
|
1789
|
+
const points = values2.points.map((v) => ({ input: v.input, output: v.output }));
|
|
1790
|
+
setValues(points);
|
|
1791
|
+
updateNodeData(id, { points });
|
|
1792
|
+
}
|
|
1793
|
+
form.validate();
|
|
1794
|
+
}, [])
|
|
1795
|
+
});
|
|
1796
|
+
useEffect14(() => {
|
|
1797
|
+
const points = data.points?.length ? data.points.map((v) => ({ input: v.input, output: v.output, key: randomId() })) : [1, 2, 3, 4].map(() => ({ input: 0, output: 0, key: randomId() }));
|
|
1798
|
+
form.initialize({ points });
|
|
1799
|
+
}, []);
|
|
1800
|
+
useEffect14(() => {
|
|
1801
|
+
if (incoming?.length && values?.length >= 4) {
|
|
1802
|
+
const module = new Curve(
|
|
1803
|
+
incoming[0].module,
|
|
1804
|
+
values.map((p) => new Tuple(p.input, p.output))
|
|
1805
|
+
);
|
|
1806
|
+
updateComputedData(id, { module });
|
|
1807
|
+
}
|
|
1808
|
+
}, [values, incoming]);
|
|
1809
|
+
const fields = form.getValues().points.map((item, index) => /* @__PURE__ */ jsxs16(Group7, { mt: "xs", children: [
|
|
1810
|
+
/* @__PURE__ */ jsx21(
|
|
1811
|
+
NumberInput6,
|
|
1812
|
+
{
|
|
1813
|
+
size: "xs",
|
|
1814
|
+
w: 100,
|
|
1815
|
+
placeholder: "Input Value",
|
|
1816
|
+
...form.getInputProps(`points.${index}.input`),
|
|
1817
|
+
step: 0.1
|
|
1818
|
+
},
|
|
1819
|
+
form.key(`points.${index}.input`)
|
|
1820
|
+
),
|
|
1821
|
+
/* @__PURE__ */ jsx21(
|
|
1822
|
+
NumberInput6,
|
|
1823
|
+
{
|
|
1824
|
+
size: "xs",
|
|
1825
|
+
w: 100,
|
|
1826
|
+
placeholder: "Output Value",
|
|
1827
|
+
...form.getInputProps(`points.${index}.output`),
|
|
1828
|
+
step: 0.1
|
|
1829
|
+
},
|
|
1830
|
+
form.key(`points.${index}.output`)
|
|
1831
|
+
),
|
|
1832
|
+
data.state === NodeState.edit && values.length > 4 && /* @__PURE__ */ jsx21(
|
|
1833
|
+
ActionIcon,
|
|
1834
|
+
{
|
|
1835
|
+
color: "red",
|
|
1836
|
+
variant: "outline",
|
|
1837
|
+
size: "sm",
|
|
1838
|
+
onClick: () => form.removeListItem("points", index),
|
|
1839
|
+
children: /* @__PURE__ */ jsx21(IconX, { size: "1rem" })
|
|
1840
|
+
}
|
|
1841
|
+
)
|
|
1842
|
+
] }, item.key));
|
|
1843
|
+
return /* @__PURE__ */ jsxs16(NodeContainer18, { id, selected, type, data, children: [
|
|
1844
|
+
fields,
|
|
1845
|
+
data.state === NodeState.edit && /* @__PURE__ */ jsxs16(Fragment3, { children: [
|
|
1846
|
+
/* @__PURE__ */ jsx21(Space, { h: 10 }),
|
|
1847
|
+
/* @__PURE__ */ jsx21(
|
|
1848
|
+
Button,
|
|
1849
|
+
{
|
|
1850
|
+
variant: "outline",
|
|
1851
|
+
size: "xs",
|
|
1852
|
+
fullWidth: true,
|
|
1853
|
+
onClick: () => form.insertListItem("points", { input: 0, output: 0, key: randomId() }),
|
|
1854
|
+
children: "Add control point"
|
|
1855
|
+
}
|
|
1856
|
+
)
|
|
1857
|
+
] }),
|
|
1858
|
+
/* @__PURE__ */ jsx21(NodeTrackConnections12, { handles: data.handles, nodeId: id, type: "target" })
|
|
1859
|
+
] });
|
|
1860
|
+
}
|
|
1861
|
+
var noise_curve_node_default = NoiseCurveNode;
|
|
1862
|
+
|
|
1863
|
+
// src/nodes/modifiers/noise-exponent-node.tsx
|
|
1864
|
+
import { NodeContainer as NodeContainer19, NodeTrackConnections as NodeTrackConnections13 } from "@awesome-flow/core/layout";
|
|
1865
|
+
import { useEffect as useEffect15, useState as useState13 } from "react";
|
|
1866
|
+
import { Group as Group8, NumberInput as NumberInput7, Stack as Stack7 } from "@mantine/core";
|
|
1867
|
+
import {
|
|
1868
|
+
useIncomingComputedData as useIncomingComputedData5,
|
|
1869
|
+
useUpdateNodeComputedData as useUpdateNodeComputedData16,
|
|
1870
|
+
useUpdateNodeData as useUpdateNodeData10
|
|
1871
|
+
} from "@awesome-flow/core/hooks";
|
|
1872
|
+
import { Exponent } from "libnoise-ts/module/modifier";
|
|
1873
|
+
import { jsx as jsx22, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
1874
|
+
function NoiseExponentNode({ id, selected, data, type }) {
|
|
1875
|
+
const [exponent, setExponent] = useState13(data.exponent);
|
|
1876
|
+
const incoming = useIncomingComputedData5(id);
|
|
1877
|
+
const updateNodeData = useUpdateNodeData10();
|
|
1878
|
+
const updateComputedData = useUpdateNodeComputedData16();
|
|
1879
|
+
useEffect15(() => {
|
|
1880
|
+
if (incoming?.length > 0) {
|
|
1881
|
+
const module = new Exponent(incoming[0].module, exponent);
|
|
1882
|
+
updateComputedData(id, { module });
|
|
1883
|
+
}
|
|
1884
|
+
updateNodeData(id, { exponent });
|
|
1885
|
+
}, [incoming, exponent]);
|
|
1886
|
+
return /* @__PURE__ */ jsxs17(NodeContainer19, { id, selected, data, type, children: [
|
|
1887
|
+
/* @__PURE__ */ jsx22(Stack7, { children: /* @__PURE__ */ jsxs17(Group8, { children: [
|
|
1888
|
+
"Exponent:",
|
|
1889
|
+
/* @__PURE__ */ jsx22(
|
|
1890
|
+
NumberInput7,
|
|
1891
|
+
{
|
|
1892
|
+
size: "xs",
|
|
1893
|
+
value: exponent,
|
|
1894
|
+
onChange: (e) => setExponent(Number(e)),
|
|
1895
|
+
step: 0.1
|
|
1896
|
+
}
|
|
1897
|
+
)
|
|
1898
|
+
] }) }),
|
|
1899
|
+
/* @__PURE__ */ jsx22(NodeTrackConnections13, { handles: data.handles, nodeId: id, type: "target" })
|
|
1900
|
+
] });
|
|
1901
|
+
}
|
|
1902
|
+
var noise_exponent_node_default = NoiseExponentNode;
|
|
1903
|
+
|
|
1904
|
+
// src/nodes/modifiers/noise-invert-node.tsx
|
|
1905
|
+
import { NodeContainer as NodeContainer20, NodeTrackConnections as NodeTrackConnections14 } from "@awesome-flow/core/layout";
|
|
1906
|
+
import { useEffect as useEffect16 } from "react";
|
|
1907
|
+
import { useIncomingComputedData as useIncomingComputedData6, useUpdateNodeComputedData as useUpdateNodeComputedData17 } from "@awesome-flow/core/hooks";
|
|
1908
|
+
import { Invert } from "libnoise-ts/module/modifier";
|
|
1909
|
+
import { jsx as jsx23 } from "react/jsx-runtime";
|
|
1910
|
+
function NoiseInvertNode({ id, selected, data, type }) {
|
|
1911
|
+
const incoming = useIncomingComputedData6(id);
|
|
1912
|
+
const updateComputedData = useUpdateNodeComputedData17();
|
|
1913
|
+
useEffect16(() => {
|
|
1914
|
+
if (incoming?.length > 0) {
|
|
1915
|
+
const module = new Invert(incoming[0].module);
|
|
1916
|
+
updateComputedData(id, { module });
|
|
1917
|
+
}
|
|
1918
|
+
}, [incoming]);
|
|
1919
|
+
return /* @__PURE__ */ jsx23(NodeContainer20, { id, selected, data, type, children: /* @__PURE__ */ jsx23(NodeTrackConnections14, { handles: data.handles, nodeId: id, type: "target" }) });
|
|
1920
|
+
}
|
|
1921
|
+
var noise_invert_node_default = NoiseInvertNode;
|
|
1922
|
+
|
|
1923
|
+
// src/nodes/modifiers/noise-normalize-node.tsx
|
|
1924
|
+
import { NodeContainer as NodeContainer21, NodeTrackConnections as NodeTrackConnections15 } from "@awesome-flow/core/layout";
|
|
1925
|
+
import { useEffect as useEffect17, useState as useState14 } from "react";
|
|
1926
|
+
import { Group as Group9, NumberInput as NumberInput8, Stack as Stack8 } from "@mantine/core";
|
|
1927
|
+
import {
|
|
1928
|
+
useIncomingComputedData as useIncomingComputedData7,
|
|
1929
|
+
useUpdateNodeComputedData as useUpdateNodeComputedData18,
|
|
1930
|
+
useUpdateNodeData as useUpdateNodeData11
|
|
1931
|
+
} from "@awesome-flow/core/hooks";
|
|
1932
|
+
|
|
1933
|
+
// src/modules/normalize-noise-module.ts
|
|
1934
|
+
import ModifierModule from "libnoise-ts/module/modifier";
|
|
1935
|
+
var NormalizeNoiseModule = class extends ModifierModule {
|
|
1936
|
+
constructor(source, lowerBound, upperBound) {
|
|
1937
|
+
super(source);
|
|
1938
|
+
this.lowerBound = lowerBound;
|
|
1939
|
+
this.upperBound = upperBound;
|
|
1940
|
+
}
|
|
1941
|
+
getValue(x, y, z) {
|
|
1942
|
+
return normalize(this.sourceModule.getValue(x, y, z), this.lowerBound, this.upperBound);
|
|
1943
|
+
}
|
|
1944
|
+
};
|
|
1945
|
+
function normalize(value, min, max) {
|
|
1946
|
+
return (value - min) / (max - min);
|
|
1947
|
+
}
|
|
1948
|
+
|
|
1949
|
+
// src/nodes/modifiers/noise-normalize-node.tsx
|
|
1950
|
+
import { jsx as jsx24, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
1951
|
+
function NoiseNormalizeNode({ id, selected, data, type }) {
|
|
1952
|
+
const [intervalStart, setIntervalStart] = useState14(data.intervalStart);
|
|
1953
|
+
const [intervalEnd, setIntervalEnd] = useState14(data.intervalEnd);
|
|
1954
|
+
const incoming = useIncomingComputedData7(id);
|
|
1955
|
+
const updateNodeData = useUpdateNodeData11();
|
|
1956
|
+
const updateComputedData = useUpdateNodeComputedData18();
|
|
1957
|
+
useEffect17(() => {
|
|
1958
|
+
if (incoming?.length) {
|
|
1959
|
+
const source = incoming[0].module;
|
|
1960
|
+
const module = new NormalizeNoiseModule(source, intervalStart, intervalEnd);
|
|
1961
|
+
updateComputedData(id, { module });
|
|
1962
|
+
}
|
|
1963
|
+
updateNodeData(id, { intervalStart, intervalEnd });
|
|
1964
|
+
}, [incoming, intervalStart, intervalEnd]);
|
|
1965
|
+
return /* @__PURE__ */ jsxs18(NodeContainer21, { id, selected, data, type, children: [
|
|
1966
|
+
/* @__PURE__ */ jsx24(Stack8, { children: /* @__PURE__ */ jsxs18(Group9, { children: [
|
|
1967
|
+
/* @__PURE__ */ jsx24(
|
|
1968
|
+
NumberInput8,
|
|
1969
|
+
{
|
|
1970
|
+
size: "xs",
|
|
1971
|
+
w: 100,
|
|
1972
|
+
value: intervalStart,
|
|
1973
|
+
onChange: (e) => setIntervalStart(Number(e))
|
|
1974
|
+
}
|
|
1975
|
+
),
|
|
1976
|
+
/* @__PURE__ */ jsx24(
|
|
1977
|
+
NumberInput8,
|
|
1978
|
+
{
|
|
1979
|
+
size: "xs",
|
|
1980
|
+
w: 100,
|
|
1981
|
+
value: intervalEnd,
|
|
1982
|
+
onChange: (e) => setIntervalEnd(Number(e))
|
|
1983
|
+
}
|
|
1984
|
+
)
|
|
1985
|
+
] }) }),
|
|
1986
|
+
/* @__PURE__ */ jsx24(NodeTrackConnections15, { handles: data.handles, nodeId: id, type: "target" })
|
|
1987
|
+
] });
|
|
1988
|
+
}
|
|
1989
|
+
var noise_normalize_node_default = NoiseNormalizeNode;
|
|
1990
|
+
|
|
1991
|
+
// src/nodes/modifiers/noise-scale-bias-node.tsx
|
|
1992
|
+
import { NodeContainer as NodeContainer22, NodeTrackConnections as NodeTrackConnections16 } from "@awesome-flow/core/layout";
|
|
1993
|
+
import { useEffect as useEffect18, useState as useState15 } from "react";
|
|
1994
|
+
import { Group as Group10, NumberInput as NumberInput9, Stack as Stack9 } from "@mantine/core";
|
|
1995
|
+
import {
|
|
1996
|
+
useIncomingComputedData as useIncomingComputedData8,
|
|
1997
|
+
useUpdateNodeComputedData as useUpdateNodeComputedData19,
|
|
1998
|
+
useUpdateNodeData as useUpdateNodeData12
|
|
1999
|
+
} from "@awesome-flow/core/hooks";
|
|
2000
|
+
import { ScaleBias } from "libnoise-ts/module/modifier";
|
|
2001
|
+
import { jsx as jsx25, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
2002
|
+
function NoiseScaleBiasNode({ id, selected, data, type }) {
|
|
2003
|
+
const [scale, setScale] = useState15(data.scale);
|
|
2004
|
+
const [bias, setBias] = useState15(data.bias);
|
|
2005
|
+
const incoming = useIncomingComputedData8(id);
|
|
2006
|
+
const updateNodeData = useUpdateNodeData12();
|
|
2007
|
+
const updateComputedData = useUpdateNodeComputedData19();
|
|
2008
|
+
useEffect18(() => {
|
|
2009
|
+
if (incoming?.length > 0) {
|
|
2010
|
+
const module = new ScaleBias(incoming[0].module, scale, bias);
|
|
2011
|
+
updateComputedData(id, { module });
|
|
2012
|
+
}
|
|
2013
|
+
updateNodeData(id, { scale, bias });
|
|
2014
|
+
}, [incoming, scale, bias]);
|
|
2015
|
+
return /* @__PURE__ */ jsxs19(NodeContainer22, { id, selected, data, type, children: [
|
|
2016
|
+
/* @__PURE__ */ jsxs19(Stack9, { children: [
|
|
2017
|
+
/* @__PURE__ */ jsxs19(Group10, { children: [
|
|
2018
|
+
"Scale:",
|
|
2019
|
+
/* @__PURE__ */ jsx25(
|
|
2020
|
+
NumberInput9,
|
|
2021
|
+
{
|
|
2022
|
+
size: "xs",
|
|
2023
|
+
w: 100,
|
|
2024
|
+
value: scale,
|
|
2025
|
+
onChange: (e) => setScale(Number(e)),
|
|
2026
|
+
step: 0.1
|
|
2027
|
+
}
|
|
2028
|
+
)
|
|
2029
|
+
] }),
|
|
2030
|
+
/* @__PURE__ */ jsxs19(Group10, { children: [
|
|
2031
|
+
"Bias:",
|
|
2032
|
+
/* @__PURE__ */ jsx25(
|
|
2033
|
+
NumberInput9,
|
|
2034
|
+
{
|
|
2035
|
+
size: "xs",
|
|
2036
|
+
w: 100,
|
|
2037
|
+
value: bias,
|
|
2038
|
+
onChange: (e) => setBias(Number(e)),
|
|
2039
|
+
step: 0.1
|
|
2040
|
+
}
|
|
2041
|
+
)
|
|
2042
|
+
] })
|
|
2043
|
+
] }),
|
|
2044
|
+
/* @__PURE__ */ jsx25(NodeTrackConnections16, { handles: data.handles, nodeId: id, type: "target" })
|
|
2045
|
+
] });
|
|
2046
|
+
}
|
|
2047
|
+
var noise_scale_bias_node_default = NoiseScaleBiasNode;
|
|
2048
|
+
|
|
2049
|
+
// src/nodes/modifiers/noise-terrace-node.tsx
|
|
2050
|
+
import { NodeContainer as NodeContainer23, NodeTrackConnections as NodeTrackConnections17 } from "@awesome-flow/core/layout";
|
|
2051
|
+
import { ActionIcon as ActionIcon2, Button as Button2, Group as Group11, NumberInput as NumberInput10, Space as Space2 } from "@mantine/core";
|
|
2052
|
+
import {
|
|
2053
|
+
useIncomingComputedData as useIncomingComputedData9,
|
|
2054
|
+
useUpdateNodeComputedData as useUpdateNodeComputedData20,
|
|
2055
|
+
useUpdateNodeData as useUpdateNodeData13
|
|
2056
|
+
} from "@awesome-flow/core/hooks";
|
|
2057
|
+
import { useCallback as useCallback19, useEffect as useEffect19, useState as useState16 } from "react";
|
|
2058
|
+
import { Terrace } from "libnoise-ts/module/modifier";
|
|
2059
|
+
import { IconX as IconX2 } from "@tabler/icons-react";
|
|
2060
|
+
import { randomId as randomId2 } from "@mantine/hooks";
|
|
2061
|
+
import { NodeState as NodeState2 } from "@awesome-flow/core/abstract";
|
|
2062
|
+
import { Fragment as Fragment4, jsx as jsx26, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
2063
|
+
function NoiseTerraceNode({ id, selected, data, type }) {
|
|
2064
|
+
const incoming = useIncomingComputedData9(id);
|
|
2065
|
+
const updateNodeData = useUpdateNodeData13();
|
|
2066
|
+
const updateComputedData = useUpdateNodeComputedData20();
|
|
2067
|
+
const [values, setValues] = useState16([]);
|
|
2068
|
+
const form = useForm({
|
|
2069
|
+
mode: "uncontrolled",
|
|
2070
|
+
initialValues: {
|
|
2071
|
+
points: []
|
|
2072
|
+
},
|
|
2073
|
+
validateInputOnChange: [`points.${FORM_INDEX}.input`],
|
|
2074
|
+
clearInputErrorOnChange: true,
|
|
2075
|
+
onValuesChange: useCallback19((values2) => {
|
|
2076
|
+
if (form.isValid()) {
|
|
2077
|
+
const points = values2.points.map((v) => v.value);
|
|
2078
|
+
setValues(points);
|
|
2079
|
+
updateNodeData(id, { points });
|
|
2080
|
+
}
|
|
2081
|
+
form.validate();
|
|
2082
|
+
}, [])
|
|
2083
|
+
});
|
|
2084
|
+
useEffect19(() => {
|
|
2085
|
+
const points = data.points?.length ? data.points.map((v) => ({ value: v, key: randomId2() })) : [1, 2].map(() => ({ value: 0, key: randomId2() }));
|
|
2086
|
+
form.initialize({ points });
|
|
2087
|
+
}, []);
|
|
2088
|
+
useEffect19(() => {
|
|
2089
|
+
if (incoming?.length && values?.length >= 2) {
|
|
2090
|
+
const module = new Terrace(incoming[0].module, values);
|
|
2091
|
+
updateComputedData(id, { module });
|
|
2092
|
+
}
|
|
2093
|
+
}, [values, incoming]);
|
|
2094
|
+
const fields = form.getValues().points.map((item, index) => /* @__PURE__ */ jsxs20(Group11, { mt: "xs", children: [
|
|
2095
|
+
/* @__PURE__ */ jsx26(
|
|
2096
|
+
NumberInput10,
|
|
2097
|
+
{
|
|
2098
|
+
size: "xs",
|
|
2099
|
+
placeholder: "Input Value",
|
|
2100
|
+
...form.getInputProps(`points.${index}.value`),
|
|
2101
|
+
step: 0.1
|
|
2102
|
+
},
|
|
2103
|
+
form.key(`points.${index}.value`)
|
|
2104
|
+
),
|
|
2105
|
+
data.state === NodeState2.edit && values.length > 2 && /* @__PURE__ */ jsx26(
|
|
2106
|
+
ActionIcon2,
|
|
2107
|
+
{
|
|
2108
|
+
color: "red",
|
|
2109
|
+
variant: "outline",
|
|
2110
|
+
size: "sm",
|
|
2111
|
+
onClick: () => form.removeListItem("points", index),
|
|
2112
|
+
children: /* @__PURE__ */ jsx26(IconX2, { size: "1rem" })
|
|
2113
|
+
}
|
|
2114
|
+
)
|
|
2115
|
+
] }, item.key));
|
|
2116
|
+
return /* @__PURE__ */ jsxs20(NodeContainer23, { id, selected, type, data, children: [
|
|
2117
|
+
fields,
|
|
2118
|
+
data.state === NodeState2.edit && /* @__PURE__ */ jsxs20(Fragment4, { children: [
|
|
2119
|
+
/* @__PURE__ */ jsx26(Space2, { h: 10 }),
|
|
2120
|
+
/* @__PURE__ */ jsx26(
|
|
2121
|
+
Button2,
|
|
2122
|
+
{
|
|
2123
|
+
variant: "outline",
|
|
2124
|
+
size: "xs",
|
|
2125
|
+
fullWidth: true,
|
|
2126
|
+
onClick: () => form.insertListItem("points", { value: 0, key: randomId2() }),
|
|
2127
|
+
children: "Add control point"
|
|
2128
|
+
}
|
|
2129
|
+
)
|
|
2130
|
+
] }),
|
|
2131
|
+
/* @__PURE__ */ jsx26(NodeTrackConnections17, { handles: data.handles, nodeId: id, type: "target" })
|
|
2132
|
+
] });
|
|
2133
|
+
}
|
|
2134
|
+
var noise_terrace_node_default = NoiseTerraceNode;
|
|
2135
|
+
|
|
2136
|
+
// src/nodes/modifiers/variable-combine-node.tsx
|
|
2137
|
+
import { NodeCombobox as NodeCombobox3, NodeContainer as NodeContainer24, NodeTrackConnections as NodeTrackConnections18 } from "@awesome-flow/core/layout";
|
|
2138
|
+
import { useCallback as useCallback20, useEffect as useEffect20, useState as useState17 } from "react";
|
|
2139
|
+
import { useIncomingNodeData as useIncomingNodeData3, useUpdateNodeData as useUpdateNodeData14 } from "@awesome-flow/core/hooks";
|
|
2140
|
+
import {
|
|
2141
|
+
IconAsterisk as IconAsterisk2,
|
|
2142
|
+
IconChevronLeft as IconChevronLeft2,
|
|
2143
|
+
IconChevronRight as IconChevronRight2,
|
|
2144
|
+
IconChevronUp as IconChevronUp2,
|
|
2145
|
+
IconDivide,
|
|
2146
|
+
IconPlus as IconPlus2
|
|
2147
|
+
} from "@tabler/icons-react";
|
|
2148
|
+
import { jsx as jsx27, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
2149
|
+
var options2 = {
|
|
2150
|
+
add: /* @__PURE__ */ jsx27(IconPlus2, {}),
|
|
2151
|
+
divide: /* @__PURE__ */ jsx27(IconDivide, {}),
|
|
2152
|
+
min: /* @__PURE__ */ jsx27(IconChevronLeft2, {}),
|
|
2153
|
+
max: /* @__PURE__ */ jsx27(IconChevronRight2, {}),
|
|
2154
|
+
multiply: /* @__PURE__ */ jsx27(IconAsterisk2, {}),
|
|
2155
|
+
power: /* @__PURE__ */ jsx27(IconChevronUp2, {})
|
|
2156
|
+
};
|
|
2157
|
+
function VariableCombineNode({
|
|
2158
|
+
id,
|
|
2159
|
+
selected,
|
|
2160
|
+
data,
|
|
2161
|
+
type
|
|
2162
|
+
}) {
|
|
2163
|
+
const [operation, setOperation] = useState17(data.operation);
|
|
2164
|
+
const [value, setValue] = useState17(data.value);
|
|
2165
|
+
const updateNodeData = useUpdateNodeData14();
|
|
2166
|
+
const incoming = useIncomingNodeData3(id);
|
|
2167
|
+
useEffect20(() => {
|
|
2168
|
+
if (incoming?.length > 1) {
|
|
2169
|
+
const result = getOperationResult(operation, incoming[0].value, incoming[1].value);
|
|
2170
|
+
setValue(result);
|
|
2171
|
+
updateNodeData(id, { value: result });
|
|
2172
|
+
}
|
|
2173
|
+
}, [operation, incoming]);
|
|
2174
|
+
const onChange = useCallback20((op) => {
|
|
2175
|
+
updateNodeData(id, { operation: op });
|
|
2176
|
+
setOperation(op);
|
|
2177
|
+
}, []);
|
|
2178
|
+
return /* @__PURE__ */ jsxs21(NodeContainer24, { id, selected, data, type, children: [
|
|
2179
|
+
/* @__PURE__ */ jsx27(NodeCombobox3, { options: options2, selected: operation, onChange }),
|
|
2180
|
+
/* @__PURE__ */ jsx27(node_value_input_default, { value, onChange: () => {
|
|
2181
|
+
}, disabled: true }),
|
|
2182
|
+
/* @__PURE__ */ jsx27(NodeTrackConnections18, { handles: data.handles, nodeId: id, type: "target" })
|
|
2183
|
+
] });
|
|
2184
|
+
}
|
|
2185
|
+
function getOperationResult(operation, value1, value2) {
|
|
2186
|
+
switch (operation) {
|
|
2187
|
+
case "add" /* add */:
|
|
2188
|
+
return Number(value1) + Number(value2);
|
|
2189
|
+
case "divide" /* divide */:
|
|
2190
|
+
return Number(value1) / (Number(value2) || 1);
|
|
2191
|
+
case "max" /* max */:
|
|
2192
|
+
return Number(value1) > Number(value2) ? value1 : value2;
|
|
2193
|
+
case "min" /* min */:
|
|
2194
|
+
return Number(value1) < Number(value2) ? value1 : value2;
|
|
2195
|
+
case "multiply" /* multiply */:
|
|
2196
|
+
return Number(value1) * Number(value2);
|
|
2197
|
+
case "power" /* power */:
|
|
2198
|
+
return Number(value1) ** Number(value2);
|
|
2199
|
+
}
|
|
2200
|
+
}
|
|
2201
|
+
var variable_combine_node_default = VariableCombineNode;
|
|
2202
|
+
|
|
2203
|
+
// src/nodes/output/noise-logger-node.tsx
|
|
2204
|
+
import { NodeContainer as NodeContainer25, NodeTrackConnections as NodeTrackConnections19 } from "@awesome-flow/core/layout";
|
|
2205
|
+
import { useMemo as useMemo11 } from "react";
|
|
2206
|
+
import { Divider, Stack as Stack10, Text } from "@mantine/core";
|
|
2207
|
+
import { useIncomingComputedData as useIncomingComputedData10 } from "@awesome-flow/core/hooks";
|
|
2208
|
+
import { jsx as jsx28, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
2209
|
+
function NoiseLoggerNode({ id, selected, data, type }) {
|
|
2210
|
+
const incoming = useIncomingComputedData10(id);
|
|
2211
|
+
const noise = useMemo11(() => incoming?.map((p) => p.noise).flat(), [incoming]);
|
|
2212
|
+
return /* @__PURE__ */ jsxs22(NodeContainer25, { id, selected, data, type, children: [
|
|
2213
|
+
/* @__PURE__ */ jsxs22(Text, { children: [
|
|
2214
|
+
"Size: ",
|
|
2215
|
+
noise?.length || 0
|
|
2216
|
+
] }),
|
|
2217
|
+
/* @__PURE__ */ jsx28(Divider, { h: 5 }),
|
|
2218
|
+
/* @__PURE__ */ jsx28(Stack10, { children: noise?.map((v, i) => /* @__PURE__ */ jsxs22(Text, { children: [
|
|
2219
|
+
v.position?.x,
|
|
2220
|
+
":",
|
|
2221
|
+
v.position?.y,
|
|
2222
|
+
":",
|
|
2223
|
+
v.position?.z,
|
|
2224
|
+
": ",
|
|
2225
|
+
v.value
|
|
2226
|
+
] }, i)) }),
|
|
2227
|
+
/* @__PURE__ */ jsx28(NodeTrackConnections19, { handles: data.handles, nodeId: id, type: "target" })
|
|
2228
|
+
] });
|
|
2229
|
+
}
|
|
2230
|
+
var noise_logger_node_default = NoiseLoggerNode;
|
|
2231
|
+
|
|
2232
|
+
// src/nodes/output/noise-output-node.tsx
|
|
2233
|
+
import { NodeContainer as NodeContainer26, NodeTrackConnections as NodeTrackConnections20 } from "@awesome-flow/core/layout";
|
|
2234
|
+
import { useIncomingComputedData as useIncomingComputedData11, useUpdateNodeComputedData as useUpdateNodeComputedData21 } from "@awesome-flow/core/hooks";
|
|
2235
|
+
import { Box, Group as Group12, LoadingOverlay, Stack as Stack11 } from "@mantine/core";
|
|
2236
|
+
import { useEffect as useEffect21, useState as useState18 } from "react";
|
|
2237
|
+
import { jsx as jsx29, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
2238
|
+
function NoiseOutputNode({ id, selected, data, type }) {
|
|
2239
|
+
const [generating, setGenerating] = useState18(false);
|
|
2240
|
+
const updateComputedData = useUpdateNodeComputedData21();
|
|
2241
|
+
const incomingModules = useIncomingComputedData11(id, 8 /* module */);
|
|
2242
|
+
const incomingPositions = useIncomingComputedData11(
|
|
2243
|
+
id,
|
|
2244
|
+
4 /* position */
|
|
2245
|
+
);
|
|
2246
|
+
useEffect21(() => {
|
|
2247
|
+
if (incomingPositions?.length && incomingModules?.length) {
|
|
2248
|
+
const { module } = incomingModules[0];
|
|
2249
|
+
if (module) {
|
|
2250
|
+
setGenerating(true);
|
|
2251
|
+
}
|
|
2252
|
+
}
|
|
2253
|
+
}, [incomingModules, incomingPositions]);
|
|
2254
|
+
useEffect21(() => {
|
|
2255
|
+
if (incomingPositions?.length && incomingModules?.length) {
|
|
2256
|
+
const { module } = incomingModules[0];
|
|
2257
|
+
if (module && generating) {
|
|
2258
|
+
const noise = [];
|
|
2259
|
+
for (const input of incomingPositions) {
|
|
2260
|
+
for (const position of input.positions) {
|
|
2261
|
+
const value = module.getValue(position.x, position.y, position.z);
|
|
2262
|
+
noise.push({
|
|
2263
|
+
position,
|
|
2264
|
+
value
|
|
2265
|
+
});
|
|
2266
|
+
}
|
|
2267
|
+
}
|
|
2268
|
+
console.log("SET COMPUTED DATA");
|
|
2269
|
+
updateComputedData(id, { noise, module });
|
|
2270
|
+
setGenerating(false);
|
|
2271
|
+
}
|
|
2272
|
+
}
|
|
2273
|
+
}, [generating]);
|
|
2274
|
+
return /* @__PURE__ */ jsxs23(NodeContainer26, { id, selected, data, type, children: [
|
|
2275
|
+
/* @__PURE__ */ jsxs23(Box, { pos: "relative", children: [
|
|
2276
|
+
/* @__PURE__ */ jsx29(
|
|
2277
|
+
LoadingOverlay,
|
|
2278
|
+
{
|
|
2279
|
+
visible: generating,
|
|
2280
|
+
zIndex: 1e3,
|
|
2281
|
+
overlayProps: { radius: "sm", blur: 2 }
|
|
2282
|
+
}
|
|
2283
|
+
),
|
|
2284
|
+
/* @__PURE__ */ jsxs23(Stack11, { children: [
|
|
2285
|
+
/* @__PURE__ */ jsxs23(Group12, { children: [
|
|
2286
|
+
"Position Inputs: ",
|
|
2287
|
+
incomingPositions?.length
|
|
2288
|
+
] }),
|
|
2289
|
+
/* @__PURE__ */ jsxs23(Group12, { children: [
|
|
2290
|
+
"Module Inputs: ",
|
|
2291
|
+
incomingModules?.length
|
|
2292
|
+
] })
|
|
2293
|
+
] })
|
|
2294
|
+
] }),
|
|
2295
|
+
/* @__PURE__ */ jsx29(NodeTrackConnections20, { handles: data.handles, nodeId: id, type: "target" })
|
|
2296
|
+
] });
|
|
2297
|
+
}
|
|
2298
|
+
var noise_output_node_default = NoiseOutputNode;
|
|
2299
|
+
|
|
2300
|
+
// src/nodes/output/noise-raw-texture-node.tsx
|
|
2301
|
+
import { NodeContainer as NodeContainer27, NodeTrackConnections as NodeTrackConnections21 } from "@awesome-flow/core/layout";
|
|
2302
|
+
import { useEffect as useEffect22, useMemo as useMemo12, useState as useState19 } from "react";
|
|
2303
|
+
import { useIncomingComputedData as useIncomingComputedData12, useUpdateNodeComputedData as useUpdateNodeComputedData22 } from "@awesome-flow/core/hooks";
|
|
2304
|
+
import { Group as Group13, Stack as Stack12 } from "@mantine/core";
|
|
2305
|
+
import { jsx as jsx30, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
2306
|
+
function NoiseRawTextureNode({ id, selected, data, type }) {
|
|
2307
|
+
const updateComputedData = useUpdateNodeComputedData22();
|
|
2308
|
+
const [dataLength, setDataLength] = useState19(0);
|
|
2309
|
+
const [resolution, setResolution] = useState19(0);
|
|
2310
|
+
const incoming = useIncomingComputedData12(id);
|
|
2311
|
+
const noise = useMemo12(() => incoming?.map((p) => p.noise).flat(), [incoming]);
|
|
2312
|
+
useEffect22(() => {
|
|
2313
|
+
if (noise?.length) {
|
|
2314
|
+
const size = Math.ceil(Math.sqrt(noise.length));
|
|
2315
|
+
const colors = noise.map((n) => [n.value * 255, n.value * 255, n.value * 255, 255]).flat();
|
|
2316
|
+
const dataArray = new Uint8Array(size * size * 4);
|
|
2317
|
+
dataArray.set(colors);
|
|
2318
|
+
setResolution(size);
|
|
2319
|
+
setDataLength(dataArray.length);
|
|
2320
|
+
updateComputedData(id, { textureData: dataArray, textureResolution: size });
|
|
2321
|
+
}
|
|
2322
|
+
}, [noise]);
|
|
2323
|
+
return /* @__PURE__ */ jsxs24(NodeContainer27, { id, selected, data, type, children: [
|
|
2324
|
+
/* @__PURE__ */ jsxs24(Stack12, { children: [
|
|
2325
|
+
/* @__PURE__ */ jsxs24(Group13, { children: [
|
|
2326
|
+
"Resolution: ",
|
|
2327
|
+
resolution,
|
|
2328
|
+
"x",
|
|
2329
|
+
resolution
|
|
2330
|
+
] }),
|
|
2331
|
+
/* @__PURE__ */ jsxs24(Group13, { children: [
|
|
2332
|
+
"Input Length: ",
|
|
2333
|
+
noise?.length || 0
|
|
2334
|
+
] }),
|
|
2335
|
+
/* @__PURE__ */ jsxs24(Group13, { children: [
|
|
2336
|
+
"Output Length (",
|
|
2337
|
+
resolution,
|
|
2338
|
+
"*",
|
|
2339
|
+
resolution,
|
|
2340
|
+
"*4): ",
|
|
2341
|
+
dataLength
|
|
2342
|
+
] })
|
|
2343
|
+
] }),
|
|
2344
|
+
/* @__PURE__ */ jsx30(NodeTrackConnections21, { handles: data.handles, nodeId: id, type: "target" })
|
|
2345
|
+
] });
|
|
2346
|
+
}
|
|
2347
|
+
var noise_raw_texture_node_default = NoiseRawTextureNode;
|
|
2348
|
+
|
|
2349
|
+
// src/nodes/output/positions-logger-node.tsx
|
|
2350
|
+
import { NodeContainer as NodeContainer28, NodeTrackConnections as NodeTrackConnections22 } from "@awesome-flow/core/layout";
|
|
2351
|
+
import { useMemo as useMemo13 } from "react";
|
|
2352
|
+
import { Divider as Divider2, Stack as Stack13, Text as Text2 } from "@mantine/core";
|
|
2353
|
+
import { useIncomingComputedData as useIncomingComputedData13 } from "@awesome-flow/core/hooks";
|
|
2354
|
+
import { jsx as jsx31, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
2355
|
+
function PositionsLoggerNode({ id, selected, data, type }) {
|
|
2356
|
+
const incoming = useIncomingComputedData13(id);
|
|
2357
|
+
const positions = useMemo13(() => {
|
|
2358
|
+
return incoming?.map((p) => p.positions).flat();
|
|
2359
|
+
}, [incoming]);
|
|
2360
|
+
return /* @__PURE__ */ jsxs25(NodeContainer28, { id, selected, data, type, children: [
|
|
2361
|
+
/* @__PURE__ */ jsxs25(Text2, { children: [
|
|
2362
|
+
"Size: ",
|
|
2363
|
+
positions?.length || 0
|
|
2364
|
+
] }),
|
|
2365
|
+
/* @__PURE__ */ jsx31(Divider2, { h: 5 }),
|
|
2366
|
+
/* @__PURE__ */ jsx31(Stack13, { children: positions?.map((v, i) => /* @__PURE__ */ jsxs25(Text2, { children: [
|
|
2367
|
+
v.x,
|
|
2368
|
+
":",
|
|
2369
|
+
v.y,
|
|
2370
|
+
":",
|
|
2371
|
+
v.z
|
|
2372
|
+
] }, i)) }),
|
|
2373
|
+
/* @__PURE__ */ jsx31(NodeTrackConnections22, { handles: data.handles, nodeId: id, type: "target" })
|
|
2374
|
+
] });
|
|
2375
|
+
}
|
|
2376
|
+
var positions_logger_node_default = PositionsLoggerNode;
|
|
2377
|
+
|
|
2378
|
+
// src/nodes/selectors/noise-blend-node.tsx
|
|
2379
|
+
import { NodeContainer as NodeContainer29, NodeTrackConnections as NodeTrackConnections23 } from "@awesome-flow/core/layout";
|
|
2380
|
+
import { useEffect as useEffect23 } from "react";
|
|
2381
|
+
import { useIncomingComputedData as useIncomingComputedData14, useUpdateNodeComputedData as useUpdateNodeComputedData23 } from "@awesome-flow/core/hooks";
|
|
2382
|
+
import { Blend } from "libnoise-ts/module/selector";
|
|
2383
|
+
import { Group as Group14 } from "@mantine/core";
|
|
2384
|
+
import { jsx as jsx32, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
2385
|
+
function NoiseBlendNode({ id, selected, data, type }) {
|
|
2386
|
+
const incoming = useIncomingComputedData14(id);
|
|
2387
|
+
const updateComputedData = useUpdateNodeComputedData23();
|
|
2388
|
+
useEffect23(() => {
|
|
2389
|
+
if (incoming?.length > 2) {
|
|
2390
|
+
const module = new Blend(incoming[0].module, incoming[1].module, incoming[2].module);
|
|
2391
|
+
updateComputedData(id, { module });
|
|
2392
|
+
}
|
|
2393
|
+
}, [id, incoming, updateComputedData]);
|
|
2394
|
+
return /* @__PURE__ */ jsxs26(NodeContainer29, { id, selected, data, type, children: [
|
|
2395
|
+
/* @__PURE__ */ jsxs26(Group14, { children: [
|
|
2396
|
+
"Modules: ",
|
|
2397
|
+
incoming?.length
|
|
2398
|
+
] }),
|
|
2399
|
+
/* @__PURE__ */ jsx32(NodeTrackConnections23, { handles: data.handles, nodeId: id, type: "target" })
|
|
2400
|
+
] });
|
|
2401
|
+
}
|
|
2402
|
+
var noise_blend_node_default = NoiseBlendNode;
|
|
2403
|
+
|
|
2404
|
+
// src/nodes/selectors/noise-select-node.tsx
|
|
2405
|
+
import { NodeContainer as NodeContainer30, NodeTrackConnections as NodeTrackConnections24 } from "@awesome-flow/core/layout";
|
|
2406
|
+
import { useEffect as useEffect24, useState as useState20 } from "react";
|
|
2407
|
+
import {
|
|
2408
|
+
useIncomingComputedData as useIncomingComputedData15,
|
|
2409
|
+
useUpdateNodeComputedData as useUpdateNodeComputedData24,
|
|
2410
|
+
useUpdateNodeData as useUpdateNodeData15
|
|
2411
|
+
} from "@awesome-flow/core/hooks";
|
|
2412
|
+
import { Select } from "libnoise-ts/module/selector";
|
|
2413
|
+
import { Group as Group15, NumberInput as NumberInput11, Stack as Stack14 } from "@mantine/core";
|
|
2414
|
+
import { jsx as jsx33, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
2415
|
+
function NoiseSelectNode({ id, selected, data, type }) {
|
|
2416
|
+
const [edgeFalloff, setEdgeFalloff] = useState20(data.edgeFalloff);
|
|
2417
|
+
const [lowerBound, setLowerBound] = useState20(data.lowerBound);
|
|
2418
|
+
const [upperBound, setUpperBound] = useState20(data.upperBound);
|
|
2419
|
+
const incoming = useIncomingComputedData15(id);
|
|
2420
|
+
const updateNodeData = useUpdateNodeData15();
|
|
2421
|
+
const updateComputedData = useUpdateNodeComputedData24();
|
|
2422
|
+
useEffect24(() => {
|
|
2423
|
+
if (incoming?.length > 2) {
|
|
2424
|
+
const module = new Select(
|
|
2425
|
+
incoming[0].module,
|
|
2426
|
+
incoming[1].module,
|
|
2427
|
+
incoming[2].module,
|
|
2428
|
+
edgeFalloff,
|
|
2429
|
+
lowerBound,
|
|
2430
|
+
upperBound
|
|
2431
|
+
);
|
|
2432
|
+
updateComputedData(id, { module });
|
|
2433
|
+
}
|
|
2434
|
+
updateNodeData(id, { edgeFalloff, lowerBound, upperBound });
|
|
2435
|
+
}, [incoming, edgeFalloff, lowerBound, upperBound, updateNodeData, id, updateComputedData]);
|
|
2436
|
+
return /* @__PURE__ */ jsxs27(NodeContainer30, { id, selected, data, type, children: [
|
|
2437
|
+
/* @__PURE__ */ jsxs27(Stack14, { children: [
|
|
2438
|
+
/* @__PURE__ */ jsxs27(Group15, { children: [
|
|
2439
|
+
"Edge Falloff:",
|
|
2440
|
+
/* @__PURE__ */ jsx33(
|
|
2441
|
+
NumberInput11,
|
|
2442
|
+
{
|
|
2443
|
+
size: "xs",
|
|
2444
|
+
w: 100,
|
|
2445
|
+
value: edgeFalloff,
|
|
2446
|
+
onChange: (e) => setEdgeFalloff(Number(e)),
|
|
2447
|
+
step: 0.1
|
|
2448
|
+
}
|
|
2449
|
+
)
|
|
2450
|
+
] }),
|
|
2451
|
+
/* @__PURE__ */ jsxs27(Group15, { children: [
|
|
2452
|
+
"Lower Bound:",
|
|
2453
|
+
/* @__PURE__ */ jsx33(
|
|
2454
|
+
NumberInput11,
|
|
2455
|
+
{
|
|
2456
|
+
size: "xs",
|
|
2457
|
+
w: 100,
|
|
2458
|
+
value: lowerBound,
|
|
2459
|
+
onChange: (e) => setLowerBound(Number(e)),
|
|
2460
|
+
step: 0.1
|
|
2461
|
+
}
|
|
2462
|
+
)
|
|
2463
|
+
] }),
|
|
2464
|
+
/* @__PURE__ */ jsxs27(Group15, { children: [
|
|
2465
|
+
"Upper Bound:",
|
|
2466
|
+
/* @__PURE__ */ jsx33(
|
|
2467
|
+
NumberInput11,
|
|
2468
|
+
{
|
|
2469
|
+
size: "xs",
|
|
2470
|
+
w: 100,
|
|
2471
|
+
value: upperBound,
|
|
2472
|
+
onChange: (e) => setUpperBound(Number(e)),
|
|
2473
|
+
step: 0.1
|
|
2474
|
+
}
|
|
2475
|
+
)
|
|
2476
|
+
] }),
|
|
2477
|
+
/* @__PURE__ */ jsxs27(Group15, { children: [
|
|
2478
|
+
"Modules: ",
|
|
2479
|
+
incoming?.length
|
|
2480
|
+
] })
|
|
2481
|
+
] }),
|
|
2482
|
+
/* @__PURE__ */ jsx33(NodeTrackConnections24, { handles: data.handles, nodeId: id, type: "target" })
|
|
2483
|
+
] });
|
|
2484
|
+
}
|
|
2485
|
+
var noise_select_node_default = NoiseSelectNode;
|
|
2486
|
+
|
|
2487
|
+
// src/nodes/transformers/noise-displace-node.tsx
|
|
2488
|
+
import { NodeContainer as NodeContainer31, NodeTrackConnections as NodeTrackConnections25 } from "@awesome-flow/core/layout";
|
|
2489
|
+
import { useEffect as useEffect25, useMemo as useMemo14 } from "react";
|
|
2490
|
+
import { useIncomingHandleData, useUpdateNodeComputedData as useUpdateNodeComputedData25 } from "@awesome-flow/core/hooks";
|
|
2491
|
+
import { Displace } from "libnoise-ts/module/transformer";
|
|
2492
|
+
import { Badge as Badge2, Stack as Stack15 } from "@mantine/core";
|
|
2493
|
+
import { jsx as jsx34, jsxs as jsxs28 } from "react/jsx-runtime";
|
|
2494
|
+
function NoiseDisplaceNode({ id, selected, data, type }) {
|
|
2495
|
+
const updateComputedData = useUpdateNodeComputedData25();
|
|
2496
|
+
const incomingHandleData = useIncomingHandleData(id, data.handles);
|
|
2497
|
+
const { sourceModule, xModule, yModule, zModule } = useMemo14(() => {
|
|
2498
|
+
return {
|
|
2499
|
+
sourceModule: incomingHandleData["source" /* sourceModule */],
|
|
2500
|
+
xModule: incomingHandleData["x-module" /* xModule */],
|
|
2501
|
+
yModule: incomingHandleData["y-module" /* yModule */],
|
|
2502
|
+
zModule: incomingHandleData["z-module" /* zModule */]
|
|
2503
|
+
};
|
|
2504
|
+
}, [incomingHandleData]);
|
|
2505
|
+
useEffect25(() => {
|
|
2506
|
+
if (sourceModule && xModule && yModule && zModule) {
|
|
2507
|
+
const module = new Displace(
|
|
2508
|
+
sourceModule[0].module,
|
|
2509
|
+
xModule[0].module,
|
|
2510
|
+
yModule[0].module,
|
|
2511
|
+
zModule[0].module
|
|
2512
|
+
);
|
|
2513
|
+
updateComputedData(id, { module });
|
|
2514
|
+
}
|
|
2515
|
+
}, [id, updateComputedData, sourceModule, xModule, yModule, zModule]);
|
|
2516
|
+
const { sourceColor, xColor, yColor, zColor } = useMemo14(() => {
|
|
2517
|
+
return {
|
|
2518
|
+
sourceColor: sourceModule ? "green" : "orange",
|
|
2519
|
+
xColor: xModule ? "green" : "orange",
|
|
2520
|
+
yColor: yModule ? "green" : "orange",
|
|
2521
|
+
zColor: zModule ? "green" : "orange"
|
|
2522
|
+
};
|
|
2523
|
+
}, [sourceModule, xModule, yModule, zModule]);
|
|
2524
|
+
return /* @__PURE__ */ jsxs28(NodeContainer31, { id, selected, data, type, children: [
|
|
2525
|
+
/* @__PURE__ */ jsxs28(Stack15, { align: "center", children: [
|
|
2526
|
+
/* @__PURE__ */ jsx34(Badge2, { color: sourceColor, children: "Source Module" }),
|
|
2527
|
+
/* @__PURE__ */ jsx34(Badge2, { color: xColor, children: "X Module" }),
|
|
2528
|
+
/* @__PURE__ */ jsx34(Badge2, { color: yColor, children: "Y Module" }),
|
|
2529
|
+
/* @__PURE__ */ jsx34(Badge2, { color: zColor, children: "Z Module" })
|
|
2530
|
+
] }),
|
|
2531
|
+
/* @__PURE__ */ jsx34(NodeTrackConnections25, { handles: data.handles, nodeId: id, type: "target" })
|
|
2532
|
+
] });
|
|
2533
|
+
}
|
|
2534
|
+
var noise_displace_node_default = NoiseDisplaceNode;
|
|
2535
|
+
|
|
2536
|
+
// src/nodes/transformers/noise-rotate-point-node.tsx
|
|
2537
|
+
import { NodeContainer as NodeContainer32, NodeTrackConnections as NodeTrackConnections26 } from "@awesome-flow/core/layout";
|
|
2538
|
+
import { useEffect as useEffect26, useState as useState21 } from "react";
|
|
2539
|
+
import {
|
|
2540
|
+
useIncomingComputedData as useIncomingComputedData16,
|
|
2541
|
+
useUpdateNodeComputedData as useUpdateNodeComputedData26,
|
|
2542
|
+
useUpdateNodeData as useUpdateNodeData16
|
|
2543
|
+
} from "@awesome-flow/core/hooks";
|
|
2544
|
+
import { Group as Group16, NumberInput as NumberInput12, Stack as Stack16 } from "@mantine/core";
|
|
2545
|
+
import { RotatePoint } from "libnoise-ts/module/transformer";
|
|
2546
|
+
import { jsx as jsx35, jsxs as jsxs29 } from "react/jsx-runtime";
|
|
2547
|
+
function NoiseRotatePointNode({
|
|
2548
|
+
id,
|
|
2549
|
+
selected,
|
|
2550
|
+
data,
|
|
2551
|
+
type
|
|
2552
|
+
}) {
|
|
2553
|
+
const [xAngle, setXAngle] = useState21(data.xAngle);
|
|
2554
|
+
const [yAngle, setYAngle] = useState21(data.yAngle);
|
|
2555
|
+
const [zAngle, setZAngle] = useState21(data.zAngle);
|
|
2556
|
+
const incoming = useIncomingComputedData16(id);
|
|
2557
|
+
const updateNodeData = useUpdateNodeData16();
|
|
2558
|
+
const updateComputedData = useUpdateNodeComputedData26();
|
|
2559
|
+
useEffect26(() => {
|
|
2560
|
+
if (incoming?.length) {
|
|
2561
|
+
const module = new RotatePoint(incoming[0].module, xAngle, yAngle, zAngle);
|
|
2562
|
+
updateComputedData(id, { module });
|
|
2563
|
+
}
|
|
2564
|
+
updateNodeData(id, { xAngle, yAngle, zAngle });
|
|
2565
|
+
}, [id, updateComputedData, updateNodeData, incoming, xAngle, yAngle, zAngle]);
|
|
2566
|
+
return /* @__PURE__ */ jsxs29(NodeContainer32, { id, selected, data, type, children: [
|
|
2567
|
+
/* @__PURE__ */ jsxs29(Stack16, { children: [
|
|
2568
|
+
/* @__PURE__ */ jsxs29(Group16, { children: [
|
|
2569
|
+
"X Angle:",
|
|
2570
|
+
/* @__PURE__ */ jsx35(
|
|
2571
|
+
NumberInput12,
|
|
2572
|
+
{
|
|
2573
|
+
size: "xs",
|
|
2574
|
+
w: 100,
|
|
2575
|
+
value: xAngle,
|
|
2576
|
+
onChange: (e) => setXAngle(Number(e)),
|
|
2577
|
+
step: 0.01
|
|
2578
|
+
}
|
|
2579
|
+
)
|
|
2580
|
+
] }),
|
|
2581
|
+
/* @__PURE__ */ jsxs29(Group16, { children: [
|
|
2582
|
+
"Y Angle:",
|
|
2583
|
+
/* @__PURE__ */ jsx35(
|
|
2584
|
+
NumberInput12,
|
|
2585
|
+
{
|
|
2586
|
+
size: "xs",
|
|
2587
|
+
w: 100,
|
|
2588
|
+
value: yAngle,
|
|
2589
|
+
onChange: (e) => setYAngle(Number(e)),
|
|
2590
|
+
step: 0.01
|
|
2591
|
+
}
|
|
2592
|
+
)
|
|
2593
|
+
] }),
|
|
2594
|
+
/* @__PURE__ */ jsxs29(Group16, { children: [
|
|
2595
|
+
"Z Angle:",
|
|
2596
|
+
/* @__PURE__ */ jsx35(
|
|
2597
|
+
NumberInput12,
|
|
2598
|
+
{
|
|
2599
|
+
size: "xs",
|
|
2600
|
+
w: 100,
|
|
2601
|
+
value: zAngle,
|
|
2602
|
+
onChange: (e) => setZAngle(Number(e)),
|
|
2603
|
+
step: 0.01
|
|
2604
|
+
}
|
|
2605
|
+
)
|
|
2606
|
+
] })
|
|
2607
|
+
] }),
|
|
2608
|
+
/* @__PURE__ */ jsx35(NodeTrackConnections26, { handles: data.handles, nodeId: id, type: "target" })
|
|
2609
|
+
] });
|
|
2610
|
+
}
|
|
2611
|
+
var noise_rotate_point_node_default = NoiseRotatePointNode;
|
|
2612
|
+
|
|
2613
|
+
// src/nodes/transformers/noise-scale-point-node.tsx
|
|
2614
|
+
import { NodeContainer as NodeContainer33, NodeTrackConnections as NodeTrackConnections27 } from "@awesome-flow/core/layout";
|
|
2615
|
+
import { useEffect as useEffect27, useState as useState22 } from "react";
|
|
2616
|
+
import {
|
|
2617
|
+
useIncomingComputedData as useIncomingComputedData17,
|
|
2618
|
+
useUpdateNodeComputedData as useUpdateNodeComputedData27,
|
|
2619
|
+
useUpdateNodeData as useUpdateNodeData17
|
|
2620
|
+
} from "@awesome-flow/core/hooks";
|
|
2621
|
+
import { Group as Group17, NumberInput as NumberInput13, Stack as Stack17 } from "@mantine/core";
|
|
2622
|
+
import { ScalePoint } from "libnoise-ts/module/transformer";
|
|
2623
|
+
import { jsx as jsx36, jsxs as jsxs30 } from "react/jsx-runtime";
|
|
2624
|
+
function NoiseScalePointNode({
|
|
2625
|
+
id,
|
|
2626
|
+
selected,
|
|
2627
|
+
data,
|
|
2628
|
+
type
|
|
2629
|
+
}) {
|
|
2630
|
+
const [xScale, setXScale] = useState22(data.xScale);
|
|
2631
|
+
const [yScale, setYScale] = useState22(data.yScale);
|
|
2632
|
+
const [zScale, setZScale] = useState22(data.zScale);
|
|
2633
|
+
const incoming = useIncomingComputedData17(id);
|
|
2634
|
+
const updateNodeData = useUpdateNodeData17();
|
|
2635
|
+
const updateComputedData = useUpdateNodeComputedData27();
|
|
2636
|
+
useEffect27(() => {
|
|
2637
|
+
if (incoming?.length) {
|
|
2638
|
+
const module = new ScalePoint(incoming[0].module, xScale, yScale, zScale);
|
|
2639
|
+
updateComputedData(id, { module });
|
|
2640
|
+
}
|
|
2641
|
+
updateNodeData(id, { xScale, yScale, zScale });
|
|
2642
|
+
}, [id, incoming, updateComputedData, updateNodeData, xScale, yScale, zScale]);
|
|
2643
|
+
return /* @__PURE__ */ jsxs30(NodeContainer33, { id, selected, data, type, children: [
|
|
2644
|
+
/* @__PURE__ */ jsxs30(Stack17, { children: [
|
|
2645
|
+
/* @__PURE__ */ jsxs30(Group17, { children: [
|
|
2646
|
+
"X Scale:",
|
|
2647
|
+
/* @__PURE__ */ jsx36(
|
|
2648
|
+
NumberInput13,
|
|
2649
|
+
{
|
|
2650
|
+
size: "xs",
|
|
2651
|
+
w: 100,
|
|
2652
|
+
value: xScale,
|
|
2653
|
+
onChange: (e) => setXScale(Number(e)),
|
|
2654
|
+
step: 0.01
|
|
2655
|
+
}
|
|
2656
|
+
)
|
|
2657
|
+
] }),
|
|
2658
|
+
/* @__PURE__ */ jsxs30(Group17, { children: [
|
|
2659
|
+
"Y Scale:",
|
|
2660
|
+
/* @__PURE__ */ jsx36(
|
|
2661
|
+
NumberInput13,
|
|
2662
|
+
{
|
|
2663
|
+
size: "xs",
|
|
2664
|
+
w: 100,
|
|
2665
|
+
value: yScale,
|
|
2666
|
+
onChange: (e) => setYScale(Number(e)),
|
|
2667
|
+
step: 0.01
|
|
2668
|
+
}
|
|
2669
|
+
)
|
|
2670
|
+
] }),
|
|
2671
|
+
/* @__PURE__ */ jsxs30(Group17, { children: [
|
|
2672
|
+
"Z Scale:",
|
|
2673
|
+
/* @__PURE__ */ jsx36(
|
|
2674
|
+
NumberInput13,
|
|
2675
|
+
{
|
|
2676
|
+
size: "xs",
|
|
2677
|
+
w: 100,
|
|
2678
|
+
value: zScale,
|
|
2679
|
+
onChange: (e) => setZScale(Number(e)),
|
|
2680
|
+
step: 0.01
|
|
2681
|
+
}
|
|
2682
|
+
)
|
|
2683
|
+
] })
|
|
2684
|
+
] }),
|
|
2685
|
+
/* @__PURE__ */ jsx36(NodeTrackConnections27, { handles: data.handles, nodeId: id, type: "target" })
|
|
2686
|
+
] });
|
|
2687
|
+
}
|
|
2688
|
+
var noise_scale_point_node_default = NoiseScalePointNode;
|
|
2689
|
+
|
|
2690
|
+
// src/nodes/transformers/noise-translate-point-node.tsx
|
|
2691
|
+
import { NodeContainer as NodeContainer34, NodeTrackConnections as NodeTrackConnections28 } from "@awesome-flow/core/layout";
|
|
2692
|
+
import { useEffect as useEffect28, useState as useState23 } from "react";
|
|
2693
|
+
import {
|
|
2694
|
+
useIncomingComputedData as useIncomingComputedData18,
|
|
2695
|
+
useUpdateNodeComputedData as useUpdateNodeComputedData28,
|
|
2696
|
+
useUpdateNodeData as useUpdateNodeData18
|
|
2697
|
+
} from "@awesome-flow/core/hooks";
|
|
2698
|
+
import { Group as Group18, NumberInput as NumberInput14, Stack as Stack18 } from "@mantine/core";
|
|
2699
|
+
import { TranslatePoint } from "libnoise-ts/module/transformer";
|
|
2700
|
+
import { jsx as jsx37, jsxs as jsxs31 } from "react/jsx-runtime";
|
|
2701
|
+
function NoiseTranslatePointNode({
|
|
2702
|
+
id,
|
|
2703
|
+
selected,
|
|
2704
|
+
data,
|
|
2705
|
+
type
|
|
2706
|
+
}) {
|
|
2707
|
+
const [translateX, setTranslateX] = useState23(data.translateX);
|
|
2708
|
+
const [translateY, setTranslateY] = useState23(data.translateY);
|
|
2709
|
+
const [translateZ, setTranslateZ] = useState23(data.translateZ);
|
|
2710
|
+
const incoming = useIncomingComputedData18(id);
|
|
2711
|
+
const updateNodeData = useUpdateNodeData18();
|
|
2712
|
+
const updateComputedData = useUpdateNodeComputedData28();
|
|
2713
|
+
useEffect28(() => {
|
|
2714
|
+
if (incoming?.length) {
|
|
2715
|
+
const module = new TranslatePoint(incoming[0].module, translateX, translateY, translateZ);
|
|
2716
|
+
updateComputedData(id, { module });
|
|
2717
|
+
}
|
|
2718
|
+
updateNodeData(id, { translateX, translateY, translateZ });
|
|
2719
|
+
}, [id, incoming, translateX, translateY, translateZ, updateComputedData, updateNodeData]);
|
|
2720
|
+
return /* @__PURE__ */ jsxs31(NodeContainer34, { id, selected, data, type, children: [
|
|
2721
|
+
/* @__PURE__ */ jsxs31(Stack18, { children: [
|
|
2722
|
+
/* @__PURE__ */ jsxs31(Group18, { children: [
|
|
2723
|
+
"Translate X:",
|
|
2724
|
+
/* @__PURE__ */ jsx37(
|
|
2725
|
+
NumberInput14,
|
|
2726
|
+
{
|
|
2727
|
+
size: "xs",
|
|
2728
|
+
w: 100,
|
|
2729
|
+
value: translateX,
|
|
2730
|
+
onChange: (e) => setTranslateX(Number(e)),
|
|
2731
|
+
step: 1
|
|
2732
|
+
}
|
|
2733
|
+
)
|
|
2734
|
+
] }),
|
|
2735
|
+
/* @__PURE__ */ jsxs31(Group18, { children: [
|
|
2736
|
+
"Translate Y:",
|
|
2737
|
+
/* @__PURE__ */ jsx37(
|
|
2738
|
+
NumberInput14,
|
|
2739
|
+
{
|
|
2740
|
+
size: "xs",
|
|
2741
|
+
w: 100,
|
|
2742
|
+
value: translateY,
|
|
2743
|
+
onChange: (e) => setTranslateY(Number(e)),
|
|
2744
|
+
step: 1
|
|
2745
|
+
}
|
|
2746
|
+
)
|
|
2747
|
+
] }),
|
|
2748
|
+
/* @__PURE__ */ jsxs31(Group18, { children: [
|
|
2749
|
+
"Translate Z:",
|
|
2750
|
+
/* @__PURE__ */ jsx37(
|
|
2751
|
+
NumberInput14,
|
|
2752
|
+
{
|
|
2753
|
+
size: "xs",
|
|
2754
|
+
w: 100,
|
|
2755
|
+
value: translateZ,
|
|
2756
|
+
onChange: (e) => setTranslateZ(Number(e)),
|
|
2757
|
+
step: 1
|
|
2758
|
+
}
|
|
2759
|
+
)
|
|
2760
|
+
] })
|
|
2761
|
+
] }),
|
|
2762
|
+
/* @__PURE__ */ jsx37(NodeTrackConnections28, { handles: data.handles, nodeId: id, type: "target" })
|
|
2763
|
+
] });
|
|
2764
|
+
}
|
|
2765
|
+
var noise_translate_point_node_default = NoiseTranslatePointNode;
|
|
2766
|
+
|
|
2767
|
+
// src/nodes/transformers/noise-turbulence-node .tsx
|
|
2768
|
+
import { NodeContainer as NodeContainer35, NodeTrackConnections as NodeTrackConnections29 } from "@awesome-flow/core/layout";
|
|
2769
|
+
import { useCallback as useCallback21, useEffect as useEffect29, useState as useState24 } from "react";
|
|
2770
|
+
import { useIncomingComputedData as useIncomingComputedData19, useUpdateNodeComputedData as useUpdateNodeComputedData29 } from "@awesome-flow/core/hooks";
|
|
2771
|
+
import { Turbulence } from "libnoise-ts/module/transformer";
|
|
2772
|
+
import { jsx as jsx38, jsxs as jsxs32 } from "react/jsx-runtime";
|
|
2773
|
+
function NoiseTurbulenceNode({
|
|
2774
|
+
id,
|
|
2775
|
+
selected,
|
|
2776
|
+
data,
|
|
2777
|
+
type
|
|
2778
|
+
}) {
|
|
2779
|
+
const [properties, setProperties] = useState24(null);
|
|
2780
|
+
const incoming = useIncomingComputedData19(id);
|
|
2781
|
+
const updateComputedData = useUpdateNodeComputedData29();
|
|
2782
|
+
const onPropertiesChange = useCallback21((props) => {
|
|
2783
|
+
setProperties(props);
|
|
2784
|
+
}, []);
|
|
2785
|
+
useEffect29(() => {
|
|
2786
|
+
if (incoming?.length) {
|
|
2787
|
+
const module = new Turbulence(
|
|
2788
|
+
incoming[0].module,
|
|
2789
|
+
properties.frequency.value,
|
|
2790
|
+
properties.power.value,
|
|
2791
|
+
properties.roughness.value,
|
|
2792
|
+
properties.seed.value
|
|
2793
|
+
);
|
|
2794
|
+
updateComputedData(id, { module });
|
|
2795
|
+
}
|
|
2796
|
+
}, [id, incoming, properties, updateComputedData]);
|
|
2797
|
+
return /* @__PURE__ */ jsxs32(NodeContainer35, { id, selected, data, type, children: [
|
|
2798
|
+
/* @__PURE__ */ jsx38(node_property_variables_default, { data, nodeId: id, onPropertiesChange }),
|
|
2799
|
+
/* @__PURE__ */ jsx38(NodeTrackConnections29, { handles: data.handles, nodeId: id, type: "target" })
|
|
2800
|
+
] });
|
|
2801
|
+
}
|
|
2802
|
+
var noise_turbulence_node_default = NoiseTurbulenceNode;
|
|
2803
|
+
export {
|
|
2804
|
+
node_module_group_default as ModuleGroupNode,
|
|
2805
|
+
noise_abs_node_default as NoiseAbsNode,
|
|
2806
|
+
noise_billow_node_default as NoiseBillowNode,
|
|
2807
|
+
noise_blend_node_default as NoiseBlendNode,
|
|
2808
|
+
noise_checkerboard_node_default as NoiseCheckerboardNode,
|
|
2809
|
+
noise_clamp_node_default as NoiseClampNode,
|
|
2810
|
+
noise_combine_node_default as NoiseCombineNode,
|
|
2811
|
+
noise_const_node_default as NoiseConstNode,
|
|
2812
|
+
noise_curve_node_default as NoiseCurveNode,
|
|
2813
|
+
noise_cylinders_node_default as NoiseCylindersNode,
|
|
2814
|
+
noise_displace_node_default as NoiseDisplaceNode,
|
|
2815
|
+
noise_exponent_node_default as NoiseExponentNode,
|
|
2816
|
+
noise_invert_node_default as NoiseInvertNode,
|
|
2817
|
+
noise_logger_node_default as NoiseLoggerNode,
|
|
2818
|
+
noise_normalize_node_default as NoiseNormalizeNode,
|
|
2819
|
+
noise_output_node_default as NoiseOutputNode,
|
|
2820
|
+
noise_perlin_node_default as NoisePerlinNode,
|
|
2821
|
+
noise_raw_texture_node_default as NoiseRawTextureNode,
|
|
2822
|
+
noise_ridgedmulti_node_default as NoiseRidgedMultiNode,
|
|
2823
|
+
noise_rotate_point_node_default as NoiseRotatePointNode,
|
|
2824
|
+
noise_scale_bias_node_default as NoiseScaleBiasNode,
|
|
2825
|
+
noise_scale_point_node_default as NoiseScalePointNode,
|
|
2826
|
+
noise_select_node_default as NoiseSelectNode,
|
|
2827
|
+
noise_simplex_node_default as NoiseSimplexNode,
|
|
2828
|
+
noise_spheres_node_default as NoiseSpheresNode,
|
|
2829
|
+
noise_terrace_node_default as NoiseTerraceNode,
|
|
2830
|
+
noise_translate_point_node_default as NoiseTranslatePointNode,
|
|
2831
|
+
noise_turbulence_node_default as NoiseTurbulenceNode,
|
|
2832
|
+
noise_voronoi_node_default as NoiseVoronoiNode,
|
|
2833
|
+
position_const_node_default as PositionConstNode,
|
|
2834
|
+
position_grid_node_default as PositionGridNode,
|
|
2835
|
+
positions_logger_node_default as PositionsLoggerNode,
|
|
2836
|
+
variable_combine_node_default as VariableCombineNode,
|
|
2837
|
+
variable_property_node_default as VariablePropertyNode,
|
|
2838
|
+
variable_value_node_default as VariableValueNode
|
|
2839
|
+
};
|
|
2840
|
+
//# sourceMappingURL=index.js.map
|