@vizij/node-graph-authoring 0.0.5 → 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/README.md +0 -1
- package/dist/{chunk-XYPRZPXJ.js → chunk-6WQOBROM.js} +32 -412
- package/dist/cli/reportIr.cjs +24 -301
- package/dist/cli/reportIr.js +1 -1
- package/dist/index.cjs +33 -422
- package/dist/index.d.cts +2 -13
- package/dist/index.d.ts +2 -13
- package/dist/index.js +1 -11
- package/package.json +4 -4
package/dist/cli/reportIr.cjs
CHANGED
|
@@ -6,8 +6,9 @@ var import_node_fs = require("fs");
|
|
|
6
6
|
var import_node_path = require("path");
|
|
7
7
|
|
|
8
8
|
// src/graphBuilder.ts
|
|
9
|
-
var
|
|
10
|
-
var
|
|
9
|
+
var import_utils4 = require("@vizij/utils");
|
|
10
|
+
var import_utils5 = require("@vizij/utils");
|
|
11
|
+
var import_metadata2 = require("@vizij/node-graph-wasm/metadata");
|
|
11
12
|
|
|
12
13
|
// src/state.ts
|
|
13
14
|
var import_utils = require("@vizij/utils");
|
|
@@ -49,8 +50,6 @@ function bindingTargetFromInput(input) {
|
|
|
49
50
|
valueType: "scalar"
|
|
50
51
|
};
|
|
51
52
|
}
|
|
52
|
-
var DEFAULT_INPUT_RANGE = { min: -1, max: 1 };
|
|
53
|
-
var DEFAULT_INPUT_ANCHOR = 0;
|
|
54
53
|
var LEGACY_SLOT_PATTERN = /^slot_(\d+)$/i;
|
|
55
54
|
var PRIMARY_SLOT_ID = "s1";
|
|
56
55
|
var PRIMARY_SLOT_ALIAS = "s1";
|
|
@@ -94,128 +93,7 @@ function rewriteLegacyExpression(expression, replacements) {
|
|
|
94
93
|
return `s${digits}`;
|
|
95
94
|
});
|
|
96
95
|
}
|
|
97
|
-
function clamp(value, min, max) {
|
|
98
|
-
return Math.min(max, Math.max(min, value));
|
|
99
|
-
}
|
|
100
|
-
function isFiniteNumber(value) {
|
|
101
|
-
return typeof value === "number" && Number.isFinite(value);
|
|
102
|
-
}
|
|
103
|
-
function deriveOutputDefaults(target) {
|
|
104
|
-
const { min, max } = target.range;
|
|
105
|
-
const anchor = clamp(target.defaultValue, min, max);
|
|
106
|
-
return {
|
|
107
|
-
outLow: min,
|
|
108
|
-
outAnchor: anchor,
|
|
109
|
-
outHigh: max
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
function deriveInputDefaults() {
|
|
113
|
-
return {
|
|
114
|
-
inLow: DEFAULT_INPUT_RANGE.min,
|
|
115
|
-
inAnchor: DEFAULT_INPUT_ANCHOR,
|
|
116
|
-
inHigh: DEFAULT_INPUT_RANGE.max
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
function migrateLegacyRemap(legacy, target) {
|
|
120
|
-
const inputDefaults = deriveInputDefaults();
|
|
121
|
-
const outputDefaults = deriveOutputDefaults(target);
|
|
122
|
-
const defaults = {
|
|
123
|
-
inLow: inputDefaults.inLow,
|
|
124
|
-
inAnchor: inputDefaults.inAnchor,
|
|
125
|
-
inHigh: inputDefaults.inHigh,
|
|
126
|
-
outLow: outputDefaults.outLow,
|
|
127
|
-
outAnchor: outputDefaults.outAnchor,
|
|
128
|
-
outHigh: outputDefaults.outHigh
|
|
129
|
-
};
|
|
130
|
-
if ("inLow" in legacy && "inHigh" in legacy && "outLow" in legacy && "outHigh" in legacy) {
|
|
131
|
-
const inLow2 = isFiniteNumber(legacy.inLow) ? legacy.inLow : defaults.inLow;
|
|
132
|
-
const inAnchor2 = isFiniteNumber(legacy.inAnchor) ? legacy.inAnchor : defaults.inAnchor;
|
|
133
|
-
const inHigh2 = isFiniteNumber(legacy.inHigh) ? legacy.inHigh : defaults.inHigh;
|
|
134
|
-
let outLow = isFiniteNumber(legacy.outLow) ? legacy.outLow : defaults.outLow;
|
|
135
|
-
let outHigh = isFiniteNumber(legacy.outHigh) ? legacy.outHigh : defaults.outHigh;
|
|
136
|
-
if (outLow > outHigh) {
|
|
137
|
-
const low = outHigh;
|
|
138
|
-
const high = outLow;
|
|
139
|
-
outLow = low;
|
|
140
|
-
outHigh = high;
|
|
141
|
-
}
|
|
142
|
-
const outAnchor2 = clamp(
|
|
143
|
-
isFiniteNumber(legacy.outAnchor) ? legacy.outAnchor : defaults.outAnchor,
|
|
144
|
-
outLow,
|
|
145
|
-
outHigh
|
|
146
|
-
);
|
|
147
|
-
return {
|
|
148
|
-
inLow: inLow2,
|
|
149
|
-
inAnchor: inAnchor2,
|
|
150
|
-
inHigh: inHigh2,
|
|
151
|
-
outLow,
|
|
152
|
-
outAnchor: outAnchor2,
|
|
153
|
-
outHigh
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
const legacyTyped = legacy;
|
|
157
|
-
const inLow = isFiniteNumber(legacyTyped.inMin) ? legacyTyped.inMin : defaults.inLow;
|
|
158
|
-
const inHigh = isFiniteNumber(legacyTyped.inMax) ? legacyTyped.inMax : defaults.inHigh;
|
|
159
|
-
const inAnchor = (inLow + inHigh) / 2;
|
|
160
|
-
const legacyOutMid = isFiniteNumber(legacyTyped.outMin) && isFiniteNumber(legacyTyped.outMax) ? (legacyTyped.outMin + legacyTyped.outMax) / 2 : defaults.outAnchor;
|
|
161
|
-
const outAnchor = clamp(legacyOutMid, defaults.outLow, defaults.outHigh);
|
|
162
|
-
return {
|
|
163
|
-
inLow,
|
|
164
|
-
inAnchor,
|
|
165
|
-
inHigh,
|
|
166
|
-
outLow: defaults.outLow,
|
|
167
|
-
outAnchor,
|
|
168
|
-
outHigh: defaults.outHigh
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
function normalizeRemap(remap, target) {
|
|
172
|
-
if (!remap) {
|
|
173
|
-
return createDefaultRemap(target);
|
|
174
|
-
}
|
|
175
|
-
return migrateLegacyRemap(remap, target);
|
|
176
|
-
}
|
|
177
|
-
function cloneRemap(remap) {
|
|
178
|
-
return (0, import_utils.cloneRemapSettings)(remap);
|
|
179
|
-
}
|
|
180
|
-
function sanitizeRemap(remap, target) {
|
|
181
|
-
const normalized = normalizeRemap(remap, target);
|
|
182
|
-
const outputDefaults = deriveOutputDefaults(target);
|
|
183
|
-
if (!Number.isFinite(normalized.outLow)) {
|
|
184
|
-
normalized.outLow = outputDefaults.outLow;
|
|
185
|
-
}
|
|
186
|
-
if (!Number.isFinite(normalized.outHigh)) {
|
|
187
|
-
normalized.outHigh = outputDefaults.outHigh;
|
|
188
|
-
}
|
|
189
|
-
if (!Number.isFinite(normalized.outAnchor)) {
|
|
190
|
-
normalized.outAnchor = outputDefaults.outAnchor;
|
|
191
|
-
}
|
|
192
|
-
if (normalized.outLow > normalized.outHigh) {
|
|
193
|
-
const low = normalized.outHigh;
|
|
194
|
-
const high = normalized.outLow;
|
|
195
|
-
normalized.outLow = low;
|
|
196
|
-
normalized.outHigh = high;
|
|
197
|
-
}
|
|
198
|
-
normalized.outAnchor = clamp(
|
|
199
|
-
normalized.outAnchor,
|
|
200
|
-
normalized.outLow,
|
|
201
|
-
normalized.outHigh
|
|
202
|
-
);
|
|
203
|
-
return normalized;
|
|
204
|
-
}
|
|
205
|
-
function createDefaultRemap(target) {
|
|
206
|
-
const inputDefaults = deriveInputDefaults();
|
|
207
|
-
const outputDefaults = deriveOutputDefaults(target);
|
|
208
|
-
return {
|
|
209
|
-
inLow: inputDefaults.inLow,
|
|
210
|
-
inAnchor: inputDefaults.inAnchor,
|
|
211
|
-
inHigh: inputDefaults.inHigh,
|
|
212
|
-
outLow: outputDefaults.outLow,
|
|
213
|
-
outAnchor: outputDefaults.outAnchor,
|
|
214
|
-
outHigh: outputDefaults.outHigh
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
96
|
function ensurePrimarySlot(binding, target) {
|
|
218
|
-
const normalizedBindingRemap = sanitizeRemap(binding.remap, target);
|
|
219
97
|
const targetValueType = getTargetValueType(target);
|
|
220
98
|
const aliasReplacements = /* @__PURE__ */ new Map();
|
|
221
99
|
const sourceSlots = Array.isArray(binding.slots) && binding.slots.length > 0 ? binding.slots : [
|
|
@@ -223,7 +101,6 @@ function ensurePrimarySlot(binding, target) {
|
|
|
223
101
|
id: PRIMARY_SLOT_ID,
|
|
224
102
|
alias: PRIMARY_SLOT_ALIAS,
|
|
225
103
|
inputId: binding.inputId ?? null,
|
|
226
|
-
remap: cloneRemap(normalizedBindingRemap),
|
|
227
104
|
valueType: targetValueType
|
|
228
105
|
}
|
|
229
106
|
];
|
|
@@ -238,8 +115,6 @@ function ensurePrimarySlot(binding, target) {
|
|
|
238
115
|
if (replaced && replaced !== normalizedAlias) {
|
|
239
116
|
aliasReplacements.set(replaced, normalizedAlias);
|
|
240
117
|
}
|
|
241
|
-
const slotRemapSource = slot.remap ?? (index === 0 ? normalizedBindingRemap : createDefaultRemap(target));
|
|
242
|
-
const normalizedSlotRemap = sanitizeRemap(slotRemapSource, target);
|
|
243
118
|
const inputId = slot.inputId !== void 0 && slot.inputId !== null ? slot.inputId : index === 0 ? binding.inputId ?? null : null;
|
|
244
119
|
const slotValueType = sanitizeSlotValueType(
|
|
245
120
|
slot.valueType,
|
|
@@ -249,13 +124,11 @@ function ensurePrimarySlot(binding, target) {
|
|
|
249
124
|
id: normalizedId,
|
|
250
125
|
alias: normalizedAlias,
|
|
251
126
|
inputId,
|
|
252
|
-
remap: cloneRemap(normalizedSlotRemap),
|
|
253
127
|
valueType: slotValueType
|
|
254
128
|
};
|
|
255
129
|
}
|
|
256
130
|
);
|
|
257
131
|
const primary = normalizedSlots[0];
|
|
258
|
-
const primaryRemap = sanitizeRemap(primary.remap, target);
|
|
259
132
|
const primaryInputId = primary.inputId === import_utils.SELF_BINDING_ID ? import_utils.SELF_BINDING_ID : primary.inputId ?? binding.inputId ?? null;
|
|
260
133
|
const primaryAlias = primaryInputId === import_utils.SELF_BINDING_ID ? "self" : primary.alias || PRIMARY_SLOT_ALIAS;
|
|
261
134
|
normalizedSlots[0] = {
|
|
@@ -263,16 +136,13 @@ function ensurePrimarySlot(binding, target) {
|
|
|
263
136
|
id: primary.id || PRIMARY_SLOT_ID,
|
|
264
137
|
alias: primaryAlias,
|
|
265
138
|
inputId: primaryInputId,
|
|
266
|
-
remap: cloneRemap(primaryRemap),
|
|
267
139
|
valueType: sanitizeSlotValueType(primary.valueType, targetValueType)
|
|
268
140
|
};
|
|
269
141
|
normalizedSlots.slice(1).forEach((slot, index) => {
|
|
270
|
-
const slotRemap = sanitizeRemap(slot.remap, target);
|
|
271
142
|
normalizedSlots[index + 1] = {
|
|
272
143
|
...slot,
|
|
273
144
|
id: slot.id || defaultSlotId(index + 1),
|
|
274
145
|
alias: slot.alias || defaultSlotId(index + 1),
|
|
275
|
-
remap: cloneRemap(slotRemap),
|
|
276
146
|
valueType: sanitizeSlotValueType(slot.valueType, targetValueType)
|
|
277
147
|
};
|
|
278
148
|
});
|
|
@@ -287,7 +157,6 @@ function ensurePrimarySlot(binding, target) {
|
|
|
287
157
|
const normalizedBinding = {
|
|
288
158
|
...binding,
|
|
289
159
|
inputId: normalizedSlots[0].inputId ?? null,
|
|
290
|
-
remap: cloneRemap(primaryRemap),
|
|
291
160
|
slots: normalizedSlots,
|
|
292
161
|
expression
|
|
293
162
|
};
|
|
@@ -296,36 +165,6 @@ function ensurePrimarySlot(binding, target) {
|
|
|
296
165
|
function ensureBindingStructure(binding, target) {
|
|
297
166
|
return ensurePrimarySlot(binding, target);
|
|
298
167
|
}
|
|
299
|
-
function sanitizeLiteral(value) {
|
|
300
|
-
if (!Number.isFinite(value)) {
|
|
301
|
-
return 0;
|
|
302
|
-
}
|
|
303
|
-
if (Object.is(value, -0)) {
|
|
304
|
-
return 0;
|
|
305
|
-
}
|
|
306
|
-
return value;
|
|
307
|
-
}
|
|
308
|
-
function formatVectorLiteral(values) {
|
|
309
|
-
return `vec(${values.map((value) => sanitizeLiteral(value)).join(", ")})`;
|
|
310
|
-
}
|
|
311
|
-
function buildPiecewiseRemapExpression(alias, remap) {
|
|
312
|
-
const sanitizedAlias = alias && alias.trim().length > 0 ? alias.trim() : PRIMARY_SLOT_ALIAS;
|
|
313
|
-
const inputBreakpoints = [remap.inLow, remap.inAnchor, remap.inHigh];
|
|
314
|
-
const outputBreakpoints = [remap.outLow, remap.outAnchor, remap.outHigh];
|
|
315
|
-
return `piecewise_remap(${sanitizedAlias}, ${formatVectorLiteral(
|
|
316
|
-
inputBreakpoints
|
|
317
|
-
)}, ${formatVectorLiteral(outputBreakpoints)})`;
|
|
318
|
-
}
|
|
319
|
-
function isSelfAlias(alias) {
|
|
320
|
-
return alias.trim().toLowerCase() === "self";
|
|
321
|
-
}
|
|
322
|
-
function buildDefaultSlotExpression(alias, inputId, remap) {
|
|
323
|
-
const sanitizedAlias = alias && alias.trim().length > 0 ? alias.trim() : PRIMARY_SLOT_ALIAS;
|
|
324
|
-
if (inputId === import_utils.SELF_BINDING_ID || isSelfAlias(sanitizedAlias)) {
|
|
325
|
-
return sanitizedAlias;
|
|
326
|
-
}
|
|
327
|
-
return buildPiecewiseRemapExpression(sanitizedAlias, remap);
|
|
328
|
-
}
|
|
329
168
|
function normalizeSlotAliasForExpression(slot, index) {
|
|
330
169
|
if (slot.alias && slot.alias.trim().length > 0) {
|
|
331
170
|
return slot.alias.trim();
|
|
@@ -342,16 +181,7 @@ function buildAliasOnlyExpression(slots) {
|
|
|
342
181
|
return slots.map((slot, index) => normalizeSlotAliasForExpression(slot, index)).join(" + ");
|
|
343
182
|
}
|
|
344
183
|
function buildCanonicalExpressionFromSlots(slots) {
|
|
345
|
-
|
|
346
|
-
return PRIMARY_SLOT_ALIAS;
|
|
347
|
-
}
|
|
348
|
-
return slots.map(
|
|
349
|
-
(slot, index) => buildDefaultSlotExpression(
|
|
350
|
-
normalizeSlotAliasForExpression(slot, index),
|
|
351
|
-
slot.inputId ?? null,
|
|
352
|
-
slot.remap
|
|
353
|
-
)
|
|
354
|
-
).join(" + ");
|
|
184
|
+
return buildAliasOnlyExpression(slots);
|
|
355
185
|
}
|
|
356
186
|
function expressionsEquivalent(left, right) {
|
|
357
187
|
return left.trim() === right.trim();
|
|
@@ -1441,9 +1271,7 @@ var DefaultExpressionVariableTable = class {
|
|
|
1441
1271
|
targetId: options.targetId,
|
|
1442
1272
|
animatableId: options.animatableId,
|
|
1443
1273
|
component: options.component,
|
|
1444
|
-
valueType: options.valueType
|
|
1445
|
-
remap: options.remap,
|
|
1446
|
-
autoRemap: options.autoRemap
|
|
1274
|
+
valueType: options.valueType
|
|
1447
1275
|
}
|
|
1448
1276
|
});
|
|
1449
1277
|
}
|
|
@@ -1539,9 +1367,6 @@ var RESERVED_EXPRESSION_VARIABLES = [
|
|
|
1539
1367
|
}
|
|
1540
1368
|
];
|
|
1541
1369
|
|
|
1542
|
-
// src/graphBuilder.ts
|
|
1543
|
-
var import_metadata2 = require("@vizij/node-graph-wasm/metadata");
|
|
1544
|
-
|
|
1545
1370
|
// src/ir/builder.ts
|
|
1546
1371
|
var graphSequence = 0;
|
|
1547
1372
|
function generateGraphId(faceId) {
|
|
@@ -1612,12 +1437,12 @@ function createIrGraphBuilder(options) {
|
|
|
1612
1437
|
function toIrBindingSummary(summaries) {
|
|
1613
1438
|
return summaries.map((summary) => ({
|
|
1614
1439
|
...summary,
|
|
1615
|
-
remap: { ...summary.remap },
|
|
1616
1440
|
issues: summary.issues ? [...summary.issues] : void 0
|
|
1617
1441
|
}));
|
|
1618
1442
|
}
|
|
1619
1443
|
|
|
1620
1444
|
// src/ir/compiler.ts
|
|
1445
|
+
var import_utils2 = require("@vizij/utils");
|
|
1621
1446
|
function compileIrGraph(graph, options = {}) {
|
|
1622
1447
|
const preferLegacy = options.preferLegacySpec === true;
|
|
1623
1448
|
const legacySpec = graph.legacy?.spec;
|
|
@@ -1702,7 +1527,7 @@ function cloneJsonLike(value) {
|
|
|
1702
1527
|
if (value === void 0 || value === null) {
|
|
1703
1528
|
return value;
|
|
1704
1529
|
}
|
|
1705
|
-
return
|
|
1530
|
+
return (0, import_utils2.cloneDeepSafe)(value);
|
|
1706
1531
|
}
|
|
1707
1532
|
function inlineSingleUseConstants(spec) {
|
|
1708
1533
|
const nodes = spec.nodes ?? [];
|
|
@@ -1741,8 +1566,9 @@ function inlineSingleUseConstants(spec) {
|
|
|
1741
1566
|
}
|
|
1742
1567
|
|
|
1743
1568
|
// src/bindingMetadata.ts
|
|
1569
|
+
var import_utils3 = require("@vizij/utils");
|
|
1744
1570
|
function cloneOperand(entry) {
|
|
1745
|
-
return
|
|
1571
|
+
return (0, import_utils3.cloneDeepSafe)(entry);
|
|
1746
1572
|
}
|
|
1747
1573
|
function describeSlot(entry) {
|
|
1748
1574
|
const metadata = entry.metadata;
|
|
@@ -1784,17 +1610,17 @@ function describeReference(node, variables) {
|
|
|
1784
1610
|
function stringifyExpression(node) {
|
|
1785
1611
|
switch (node.type) {
|
|
1786
1612
|
case "Literal":
|
|
1787
|
-
return Number.isFinite(node.value) ? `${node.value}` : "0";
|
|
1613
|
+
return Number.isFinite(node.value) ? `${node.value} ` : "0";
|
|
1788
1614
|
case "VectorLiteral":
|
|
1789
1615
|
return `vec(${node.values.join(", ")})`;
|
|
1790
1616
|
case "Reference":
|
|
1791
1617
|
return node.name;
|
|
1792
1618
|
case "Unary":
|
|
1793
|
-
return `${node.operator}${stringifyExpression(node.operand)}`;
|
|
1619
|
+
return `${node.operator}${stringifyExpression(node.operand)} `;
|
|
1794
1620
|
case "Binary":
|
|
1795
|
-
return `${stringifyExpression(node.left)} ${node.operator} ${stringifyExpression(node.right)}`;
|
|
1621
|
+
return `${stringifyExpression(node.left)} ${node.operator} ${stringifyExpression(node.right)} `;
|
|
1796
1622
|
case "Function":
|
|
1797
|
-
return `${node.name}(${node.args.map(stringifyExpression).join(", ")})`;
|
|
1623
|
+
return `${node.name} (${node.args.map(stringifyExpression).join(", ")})`;
|
|
1798
1624
|
default:
|
|
1799
1625
|
return "";
|
|
1800
1626
|
}
|
|
@@ -1878,7 +1704,6 @@ function evaluateBinding({
|
|
|
1878
1704
|
counter: 0,
|
|
1879
1705
|
reservedNodes: /* @__PURE__ */ new Map(),
|
|
1880
1706
|
nodeValueTypes: /* @__PURE__ */ new Map(),
|
|
1881
|
-
slotRemapNodes: /* @__PURE__ */ new Map(),
|
|
1882
1707
|
graphReservedNodes: context.graphReservedNodes,
|
|
1883
1708
|
generateReservedNodeId: context.generateReservedNodeId
|
|
1884
1709
|
};
|
|
@@ -1896,7 +1721,7 @@ function evaluateBinding({
|
|
|
1896
1721
|
const slotId = slot.id && slot.id.length > 0 ? slot.id : alias;
|
|
1897
1722
|
const slotValueType = slot.valueType === "vector" ? "vector" : "scalar";
|
|
1898
1723
|
let slotOutputId;
|
|
1899
|
-
if (slot.inputId ===
|
|
1724
|
+
if (slot.inputId === import_utils5.SELF_BINDING_ID) {
|
|
1900
1725
|
if (selfNodeId) {
|
|
1901
1726
|
slotOutputId = selfNodeId;
|
|
1902
1727
|
hasActiveSlot = true;
|
|
@@ -1935,9 +1760,7 @@ function evaluateBinding({
|
|
|
1935
1760
|
targetId,
|
|
1936
1761
|
animatableId,
|
|
1937
1762
|
component,
|
|
1938
|
-
valueType: slotValueType
|
|
1939
|
-
remap: { ...slot.remap },
|
|
1940
|
-
autoRemap: slot.inputId !== import_utils3.SELF_BINDING_ID && slotValueType === "scalar"
|
|
1763
|
+
valueType: slotValueType
|
|
1941
1764
|
});
|
|
1942
1765
|
setNodeValueType(
|
|
1943
1766
|
exprContext,
|
|
@@ -1951,7 +1774,6 @@ function evaluateBinding({
|
|
|
1951
1774
|
slotId,
|
|
1952
1775
|
slotAlias: alias,
|
|
1953
1776
|
inputId: slot.inputId ?? null,
|
|
1954
|
-
remap: { ...slot.remap },
|
|
1955
1777
|
expression: trimmedExpression,
|
|
1956
1778
|
valueType: slotValueType,
|
|
1957
1779
|
nodeId: slotOutputId,
|
|
@@ -1970,9 +1792,7 @@ function evaluateBinding({
|
|
|
1970
1792
|
targetId,
|
|
1971
1793
|
animatableId,
|
|
1972
1794
|
component,
|
|
1973
|
-
valueType: targetValueType
|
|
1974
|
-
remap: createDefaultRemap(target),
|
|
1975
|
-
autoRemap: false
|
|
1795
|
+
valueType: targetValueType
|
|
1976
1796
|
});
|
|
1977
1797
|
setNodeValueType(
|
|
1978
1798
|
exprContext,
|
|
@@ -1986,7 +1806,6 @@ function evaluateBinding({
|
|
|
1986
1806
|
slotId: PRIMARY_SLOT_ID,
|
|
1987
1807
|
slotAlias: alias,
|
|
1988
1808
|
inputId: null,
|
|
1989
|
-
remap: createDefaultRemap(target),
|
|
1990
1809
|
expression: trimmedExpression,
|
|
1991
1810
|
valueType: targetValueType,
|
|
1992
1811
|
nodeId: constantId,
|
|
@@ -2183,73 +2002,6 @@ function ensureOperandValueType(context, operandId, expected, functionName, inpu
|
|
|
2183
2002
|
`Function "${functionName}" expects ${expectation} input for "${inputId}", but the expression produced ${actual}.`
|
|
2184
2003
|
);
|
|
2185
2004
|
}
|
|
2186
|
-
function resolveSlotReferenceNode(entry, fallbackNodeId, context) {
|
|
2187
|
-
if (entry.kind !== "slot") {
|
|
2188
|
-
return fallbackNodeId;
|
|
2189
|
-
}
|
|
2190
|
-
const metadata = entry.metadata;
|
|
2191
|
-
if (!metadata || metadata.autoRemap === false || !metadata.remap) {
|
|
2192
|
-
return fallbackNodeId;
|
|
2193
|
-
}
|
|
2194
|
-
if (metadata.valueType !== "scalar") {
|
|
2195
|
-
return fallbackNodeId;
|
|
2196
|
-
}
|
|
2197
|
-
if (isIdentityRemap(metadata.remap)) {
|
|
2198
|
-
return fallbackNodeId;
|
|
2199
|
-
}
|
|
2200
|
-
const cacheKey = metadata.slotId ?? entry.name;
|
|
2201
|
-
const existing = context.slotRemapNodes.get(cacheKey);
|
|
2202
|
-
if (existing) {
|
|
2203
|
-
return existing;
|
|
2204
|
-
}
|
|
2205
|
-
const remapNodeId = createSlotRemapNode(
|
|
2206
|
-
context,
|
|
2207
|
-
fallbackNodeId,
|
|
2208
|
-
metadata.remap,
|
|
2209
|
-
metadata.slotAlias ?? cacheKey
|
|
2210
|
-
);
|
|
2211
|
-
context.slotRemapNodes.set(cacheKey, remapNodeId);
|
|
2212
|
-
return remapNodeId;
|
|
2213
|
-
}
|
|
2214
|
-
function createSlotRemapNode(context, sourceNodeId, remap, slotKey) {
|
|
2215
|
-
const safeSlotKey = sanitizeNodeId(slotKey || "slot");
|
|
2216
|
-
const nodeId = `slot_remap_${safeSlotKey}_${context.counter++}`;
|
|
2217
|
-
context.nodes.push({
|
|
2218
|
-
id: nodeId,
|
|
2219
|
-
type: "centered_remap",
|
|
2220
|
-
inputDefaults: {
|
|
2221
|
-
in_low: remap.inLow,
|
|
2222
|
-
in_anchor: remap.inAnchor,
|
|
2223
|
-
in_high: remap.inHigh,
|
|
2224
|
-
out_low: remap.outLow,
|
|
2225
|
-
out_anchor: remap.outAnchor,
|
|
2226
|
-
out_high: remap.outHigh
|
|
2227
|
-
}
|
|
2228
|
-
});
|
|
2229
|
-
context.edges.push({
|
|
2230
|
-
from: { nodeId: sourceNodeId },
|
|
2231
|
-
to: { nodeId, portId: "in" }
|
|
2232
|
-
});
|
|
2233
|
-
setNodeValueType(context, nodeId, "scalar");
|
|
2234
|
-
return nodeId;
|
|
2235
|
-
}
|
|
2236
|
-
function isIdentityRemap(remap) {
|
|
2237
|
-
return nearlyEqual(remap.inLow, remap.outLow) && nearlyEqual(remap.inAnchor, remap.outAnchor) && nearlyEqual(remap.inHigh, remap.outHigh);
|
|
2238
|
-
}
|
|
2239
|
-
function nearlyEqual(a, b, epsilon = 1e-4) {
|
|
2240
|
-
return Math.abs(a - b) <= epsilon;
|
|
2241
|
-
}
|
|
2242
|
-
var REMAP_FUNCTION_NODE_TYPES = /* @__PURE__ */ new Set([
|
|
2243
|
-
"piecewise_remap",
|
|
2244
|
-
"centered_remap",
|
|
2245
|
-
"remap"
|
|
2246
|
-
]);
|
|
2247
|
-
function shouldSkipAutoRemapForArgument(nodeType, index) {
|
|
2248
|
-
if (!REMAP_FUNCTION_NODE_TYPES.has(nodeType)) {
|
|
2249
|
-
return false;
|
|
2250
|
-
}
|
|
2251
|
-
return index === 0;
|
|
2252
|
-
}
|
|
2253
2005
|
function getConstantNodeId(context, value) {
|
|
2254
2006
|
const key = Number.isFinite(value) ? value.toString() : "NaN";
|
|
2255
2007
|
const existing = context.constants.get(key);
|
|
@@ -2708,8 +2460,7 @@ var BINARY_FUNCTION_OPERATOR_MAP = {
|
|
|
2708
2460
|
"&&": "and",
|
|
2709
2461
|
"||": "or"
|
|
2710
2462
|
};
|
|
2711
|
-
function materializeExpression(node, context, variables, issues
|
|
2712
|
-
const autoRemap = options?.autoRemap !== false;
|
|
2463
|
+
function materializeExpression(node, context, variables, issues) {
|
|
2713
2464
|
switch (node.type) {
|
|
2714
2465
|
case "Literal": {
|
|
2715
2466
|
return getConstantNodeId(context, node.value);
|
|
@@ -2724,10 +2475,7 @@ function materializeExpression(node, context, variables, issues, options) {
|
|
|
2724
2475
|
return getConstantNodeId(context, 0);
|
|
2725
2476
|
}
|
|
2726
2477
|
const mappedId = entry.nodeId ?? getConstantNodeId(context, 0);
|
|
2727
|
-
|
|
2728
|
-
return mappedId;
|
|
2729
|
-
}
|
|
2730
|
-
return resolveSlotReferenceNode(entry, mappedId, context);
|
|
2478
|
+
return mappedId;
|
|
2731
2479
|
}
|
|
2732
2480
|
case "Unary": {
|
|
2733
2481
|
const operandId = materializeExpression(
|
|
@@ -2865,13 +2613,7 @@ function materializeExpression(node, context, variables, issues, options) {
|
|
|
2865
2613
|
);
|
|
2866
2614
|
const operandNodes = argNodes.slice(0, operandLimit);
|
|
2867
2615
|
const operands = operandNodes.map(
|
|
2868
|
-
(arg,
|
|
2869
|
-
arg,
|
|
2870
|
-
context,
|
|
2871
|
-
variables,
|
|
2872
|
-
issues,
|
|
2873
|
-
shouldSkipAutoRemapForArgument(definition.nodeType, index) ? { autoRemap: false } : void 0
|
|
2874
|
-
)
|
|
2616
|
+
(arg, _index) => materializeExpression(arg, context, variables, issues)
|
|
2875
2617
|
);
|
|
2876
2618
|
const paramArgStart = operandLimit;
|
|
2877
2619
|
const paramArgNodes = paramArgCount > 0 ? argNodes.slice(paramArgStart, paramArgStart + paramArgCount) : [];
|
|
@@ -2947,7 +2689,7 @@ function buildRigGraphSpec({
|
|
|
2947
2689
|
try {
|
|
2948
2690
|
const target = bindingTargetFromInput(input);
|
|
2949
2691
|
const binding = ensureBindingStructure(inputBindingRaw, target);
|
|
2950
|
-
const requiresSelf = binding.inputId ===
|
|
2692
|
+
const requiresSelf = binding.inputId === import_utils5.SELF_BINDING_ID || binding.slots.some((slot) => slot.inputId === import_utils5.SELF_BINDING_ID);
|
|
2951
2693
|
let selfNodeId;
|
|
2952
2694
|
if (requiresSelf) {
|
|
2953
2695
|
const sliderNodeId = `input_raw_${sanitizeNodeId(inputId)}`;
|
|
@@ -3073,7 +2815,6 @@ function buildRigGraphSpec({
|
|
|
3073
2815
|
slotId: PRIMARY_SLOT_ID,
|
|
3074
2816
|
slotAlias: PRIMARY_SLOT_ALIAS,
|
|
3075
2817
|
inputId: null,
|
|
3076
|
-
remap: createDefaultRemap(target),
|
|
3077
2818
|
expression: PRIMARY_SLOT_ALIAS,
|
|
3078
2819
|
valueType: target.valueType === "vector" ? "vector" : "scalar",
|
|
3079
2820
|
issues: ["Binding not found."],
|
|
@@ -3128,7 +2869,7 @@ function buildRigGraphSpec({
|
|
|
3128
2869
|
let sourceId = entry.values.get(componentKey);
|
|
3129
2870
|
if (!sourceId) {
|
|
3130
2871
|
const componentDefault = entry.defaults.get(componentKey) ?? extractComponentDefault(
|
|
3131
|
-
(0,
|
|
2872
|
+
(0, import_utils4.buildAnimatableValue)(entry.animatable, void 0),
|
|
3132
2873
|
componentKey
|
|
3133
2874
|
);
|
|
3134
2875
|
const constNodeId = `const_${safeId}_${componentKey}`;
|
|
@@ -3231,7 +2972,6 @@ function buildRigGraphSpec({
|
|
|
3231
2972
|
}),
|
|
3232
2973
|
bindings: filteredSummaryBindings.map((binding) => ({
|
|
3233
2974
|
...binding,
|
|
3234
|
-
remap: { ...binding.remap },
|
|
3235
2975
|
expression: binding.expression,
|
|
3236
2976
|
valueType: binding.valueType,
|
|
3237
2977
|
issues: binding.issues ? [...binding.issues] : void 0,
|
|
@@ -3266,7 +3006,6 @@ function buildRigGraphSpec({
|
|
|
3266
3006
|
bindings: toIrBindingSummary(
|
|
3267
3007
|
filteredSummaryBindings.map((binding) => ({
|
|
3268
3008
|
...binding,
|
|
3269
|
-
remap: { ...binding.remap },
|
|
3270
3009
|
issues: binding.issues ? [...binding.issues] : void 0
|
|
3271
3010
|
}))
|
|
3272
3011
|
)
|
|
@@ -3385,7 +3124,7 @@ function cloneJsonLike2(value) {
|
|
|
3385
3124
|
if (value === void 0 || value === null) {
|
|
3386
3125
|
return value;
|
|
3387
3126
|
}
|
|
3388
|
-
return
|
|
3127
|
+
return (0, import_utils4.cloneDeepSafe)(value);
|
|
3389
3128
|
}
|
|
3390
3129
|
function validateRemapDefaults(nodes) {
|
|
3391
3130
|
const issues = [];
|
|
@@ -3413,15 +3152,8 @@ function validateRemapDefaults(nodes) {
|
|
|
3413
3152
|
|
|
3414
3153
|
// src/ir/inspection.ts
|
|
3415
3154
|
var import_metadata3 = require("@vizij/node-graph-wasm/metadata");
|
|
3155
|
+
var import_utils6 = require("@vizij/utils");
|
|
3416
3156
|
var MACHINE_REPORT_VERSION = 1;
|
|
3417
|
-
var REMAP_KEYS = [
|
|
3418
|
-
"inLow",
|
|
3419
|
-
"inAnchor",
|
|
3420
|
-
"inHigh",
|
|
3421
|
-
"outLow",
|
|
3422
|
-
"outAnchor",
|
|
3423
|
-
"outHigh"
|
|
3424
|
-
];
|
|
3425
3157
|
var DEFAULT_DIFF_LIMIT = 50;
|
|
3426
3158
|
function buildMachineReport(result) {
|
|
3427
3159
|
return {
|
|
@@ -3462,7 +3194,6 @@ function normalizeGraphBindingSummaries(bindings) {
|
|
|
3462
3194
|
slotId: binding.slotId,
|
|
3463
3195
|
slotAlias: binding.slotAlias,
|
|
3464
3196
|
inputId: binding.inputId ?? null,
|
|
3465
|
-
remap: normalizeRemap2(binding.remap),
|
|
3466
3197
|
expression: binding.expression,
|
|
3467
3198
|
valueType: binding.valueType,
|
|
3468
3199
|
nodeId: binding.nodeId,
|
|
@@ -3477,7 +3208,7 @@ function cloneBindingMetadata(metadata) {
|
|
|
3477
3208
|
if (!metadata) {
|
|
3478
3209
|
return void 0;
|
|
3479
3210
|
}
|
|
3480
|
-
return
|
|
3211
|
+
return (0, import_utils6.cloneDeepSafe)(metadata);
|
|
3481
3212
|
}
|
|
3482
3213
|
function normalizeIssues(issues) {
|
|
3483
3214
|
const byTargetEntries = Object.entries(issues.byTarget ?? {}).map(
|
|
@@ -3561,7 +3292,6 @@ function normalizeIrGraphSummary(summary) {
|
|
|
3561
3292
|
function normalizeIrBindingSummaries(bindings) {
|
|
3562
3293
|
const normalized = bindings.map((binding) => ({
|
|
3563
3294
|
...binding,
|
|
3564
|
-
remap: sortPlainObject(binding.remap),
|
|
3565
3295
|
issues: normalizeStringArray(binding.issues)
|
|
3566
3296
|
}));
|
|
3567
3297
|
normalized.sort((a, b) => bindingSortKey(a).localeCompare(bindingSortKey(b)));
|
|
@@ -3664,13 +3394,6 @@ function normalizeRegistryParamSpec(param) {
|
|
|
3664
3394
|
}
|
|
3665
3395
|
return normalized;
|
|
3666
3396
|
}
|
|
3667
|
-
function normalizeRemap2(remap) {
|
|
3668
|
-
const normalized = {};
|
|
3669
|
-
REMAP_KEYS.forEach((key) => {
|
|
3670
|
-
normalized[key] = remap[key];
|
|
3671
|
-
});
|
|
3672
|
-
return normalized;
|
|
3673
|
-
}
|
|
3674
3397
|
function normalizeStringArray(values) {
|
|
3675
3398
|
if (!values || values.length === 0) {
|
|
3676
3399
|
return void 0;
|