@ogabrielluiz/patchflow 0.1.3 → 0.1.4
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/{chunk-4VUBNFI4.js → chunk-YONEHQMI.js} +1 -1
- package/dist/chunk-YONEHQMI.js.map +1 -0
- package/dist/index.cjs +32 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +33 -13
- package/dist/index.js.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +6 -0
- package/dist/types.d.ts +6 -0
- package/dist/types.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-4VUBNFI4.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
SIGNAL_OPERATORS,
|
|
3
3
|
__commonJS,
|
|
4
4
|
__toESM
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-YONEHQMI.js";
|
|
6
6
|
|
|
7
7
|
// node_modules/@dagrejs/graphlib/lib/graph.js
|
|
8
8
|
var require_graph = __commonJS({
|
|
@@ -4284,14 +4284,33 @@ function layout(graph, options = {}) {
|
|
|
4284
4284
|
const feedbackSpace = hasFeedback ? diagramBottom - maxY + feedbackArcOffset + 30 + 16 : 0;
|
|
4285
4285
|
const width = maxX + margin;
|
|
4286
4286
|
const height = maxY + margin + feedbackSpace;
|
|
4287
|
+
const warnings = checkHeightInvariant({
|
|
4288
|
+
blocks: layoutBlocks,
|
|
4289
|
+
height,
|
|
4290
|
+
hasFeedback,
|
|
4291
|
+
feedbackBottom: diagramBottom + feedbackArcOffset
|
|
4292
|
+
});
|
|
4287
4293
|
return {
|
|
4288
4294
|
blocks: layoutBlocks,
|
|
4289
4295
|
connections: layoutConnections,
|
|
4290
4296
|
width,
|
|
4291
4297
|
height,
|
|
4292
|
-
signalTypeStats: graph.signalTypeStats
|
|
4298
|
+
signalTypeStats: graph.signalTypeStats,
|
|
4299
|
+
warnings
|
|
4293
4300
|
};
|
|
4294
4301
|
}
|
|
4302
|
+
function checkHeightInvariant(args) {
|
|
4303
|
+
const { blocks, height, hasFeedback, feedbackBottom } = args;
|
|
4304
|
+
const warnings = [];
|
|
4305
|
+
const blockBottomMax = blocks.length > 0 ? Math.max(...blocks.map((b) => b.y + b.height)) : 0;
|
|
4306
|
+
const contentBottom = hasFeedback ? Math.max(blockBottomMax, feedbackBottom) : blockBottomMax;
|
|
4307
|
+
if (height < contentBottom) {
|
|
4308
|
+
warnings.push(
|
|
4309
|
+
`layout: computed height (${height.toFixed(1)}) is below content bottom (${contentBottom.toFixed(1)}); legend/notes may overlap block content`
|
|
4310
|
+
);
|
|
4311
|
+
}
|
|
4312
|
+
return warnings;
|
|
4313
|
+
}
|
|
4295
4314
|
|
|
4296
4315
|
// src/renderer.ts
|
|
4297
4316
|
function genId() {
|
|
@@ -4531,7 +4550,7 @@ function buildAnnotations(theme, connections, layoutHeight) {
|
|
|
4531
4550
|
});
|
|
4532
4551
|
return parts.join("");
|
|
4533
4552
|
}
|
|
4534
|
-
function buildLegend(theme, layoutResult) {
|
|
4553
|
+
function buildLegend(theme, layoutResult, diagramBottom) {
|
|
4535
4554
|
const order = ["audio", "cv", "pitch", "gate", "trigger", "clock"];
|
|
4536
4555
|
const used = order.filter((t) => (layoutResult.signalTypeStats[t] ?? 0) > 0);
|
|
4537
4556
|
if (used.length === 0) return "";
|
|
@@ -4540,7 +4559,7 @@ function buildLegend(theme, layoutResult) {
|
|
|
4540
4559
|
const itemWidth = 70;
|
|
4541
4560
|
const totalWidth = used.length * itemWidth;
|
|
4542
4561
|
const legendStartX = layoutResult.width - totalWidth;
|
|
4543
|
-
const y =
|
|
4562
|
+
const y = diagramBottom - 20;
|
|
4544
4563
|
for (let i = 0; i < used.length; i++) {
|
|
4545
4564
|
const sig = used[i];
|
|
4546
4565
|
const color = theme.cable.colors[sig].stroke;
|
|
@@ -4572,6 +4591,14 @@ function renderSvg(layoutResult, theme) {
|
|
|
4572
4591
|
`<pattern id="${idPrefix}-dots" width="${spacing}" height="${spacing}" patternUnits="userSpaceOnUse"><circle cx="${spacing / 2}" cy="${spacing / 2}" r="${theme.grid.dotRadius}" fill="${theme.grid.dotColor}" opacity="${theme.grid.opacity}"/></pattern>`
|
|
4573
4592
|
);
|
|
4574
4593
|
}
|
|
4594
|
+
const labelPadX = 130;
|
|
4595
|
+
const vbWidth = width + labelPadX * 2;
|
|
4596
|
+
const topPad = 40;
|
|
4597
|
+
const noteCount = layoutResult.connections.filter((c) => c.annotation).length;
|
|
4598
|
+
const notesHeight = noteCount > 0 ? noteCount * 16 + 10 : 0;
|
|
4599
|
+
const bottomPad = Math.max(40, notesHeight + 10);
|
|
4600
|
+
const vbHeight = height + topPad + bottomPad;
|
|
4601
|
+
const diagramBottom = height + bottomPad;
|
|
4575
4602
|
const layers = [
|
|
4576
4603
|
`<g class="pf-layer-bg">${buildBackground(theme, idPrefix, width, height)}</g>`,
|
|
4577
4604
|
`<g class="pf-layer-cables">${buildCables(theme, layoutResult.connections)}</g>`,
|
|
@@ -4579,17 +4606,10 @@ function renderSvg(layoutResult, theme) {
|
|
|
4579
4606
|
`<g class="pf-layer-params">${buildParams(layoutResult.blocks, theme)}</g>`,
|
|
4580
4607
|
`<g class="pf-layer-jacks">${buildJacks(theme, idPrefix, layoutResult.blocks)}</g>`,
|
|
4581
4608
|
`<g class="pf-layer-labels">${buildLabels(theme, layoutResult.blocks, layoutResult.connections)}</g>`,
|
|
4582
|
-
`<g class="pf-layer-annotations">${buildAnnotations(theme, layoutResult.connections,
|
|
4583
|
-
`<g class="pf-layer-legend">${buildLegend(theme, layoutResult)}</g>`
|
|
4609
|
+
`<g class="pf-layer-annotations">${buildAnnotations(theme, layoutResult.connections, diagramBottom)}</g>`,
|
|
4610
|
+
`<g class="pf-layer-legend">${buildLegend(theme, layoutResult, diagramBottom)}</g>`
|
|
4584
4611
|
].join("");
|
|
4585
4612
|
const style = `<style>@media print { .pf-panel, .pf-jack { filter: none; } }</style>`;
|
|
4586
|
-
const labelPadX = 130;
|
|
4587
|
-
const vbWidth = width + labelPadX * 2;
|
|
4588
|
-
const topPad = 40;
|
|
4589
|
-
const noteCount = layoutResult.connections.filter((c) => c.annotation).length;
|
|
4590
|
-
const notesHeight = noteCount > 0 ? noteCount * 16 + 10 : 0;
|
|
4591
|
-
const bottomPad = Math.max(40, notesHeight + 10);
|
|
4592
|
-
const vbHeight = height + topPad + bottomPad;
|
|
4593
4613
|
const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="${-labelPadX} ${-topPad} ${vbWidth} ${vbHeight}" width="100%" data-pf-min-width="${minWidth + labelPadX * 2}" role="img" aria-labelledby="${idPrefix}-title ${idPrefix}-desc"><title id="${idPrefix}-title">Patch diagram</title><desc id="${idPrefix}-desc">${desc}</desc>` + style + `<defs>${defsParts.join("")}</defs>` + layers + `</svg>`;
|
|
4594
4614
|
return svg;
|
|
4595
4615
|
}
|