@elicdavis/node-flow 0.1.2 → 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/index.js +15 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -10
- package/dist/index.mjs.map +1 -1
- package/esbuild.ts +5 -1
- package/package.json +1 -1
- package/src/elements/text.ts +6 -6
- package/src/nodes/publisher.ts +5 -2
- package/src/port.ts +4 -3
package/esbuild.ts
CHANGED
|
@@ -25,7 +25,11 @@ if (enableWatch) {
|
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
serve(serveOpts, {}).then((result) => {
|
|
28
|
-
|
|
28
|
+
let host = result.host;
|
|
29
|
+
if (host === "0.0.0.0") {
|
|
30
|
+
host = "localhost"
|
|
31
|
+
}
|
|
32
|
+
console.log(`serving extension from "${serveOpts.servedir}" at "http://${host}:${result.port}"`);
|
|
29
33
|
});
|
|
30
34
|
}
|
|
31
35
|
|
package/package.json
CHANGED
package/src/elements/text.ts
CHANGED
|
@@ -17,6 +17,7 @@ export enum VerticalAlign {
|
|
|
17
17
|
export interface TextElementStyling extends RenderElementBaseStyling {
|
|
18
18
|
Align?: TextAlign
|
|
19
19
|
VerticalAlign?: VerticalAlign
|
|
20
|
+
LineHeight?: number
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
export class TextElement extends RenderElementBase {
|
|
@@ -26,11 +27,14 @@ export class TextElement extends RenderElementBase {
|
|
|
26
27
|
|
|
27
28
|
#verticalAlign: VerticalAlign;
|
|
28
29
|
|
|
30
|
+
#lineHeight: number;
|
|
31
|
+
|
|
29
32
|
constructor(text: Text, styling?: TextElementStyling) {
|
|
30
33
|
super(styling);
|
|
31
34
|
this.#text = text;
|
|
32
35
|
this.#align = styling?.Align ?? TextAlign.Left;
|
|
33
36
|
this.#verticalAlign = styling?.VerticalAlign ?? VerticalAlign.Top;
|
|
37
|
+
this.#lineHeight = styling?.LineHeight ?? 1;
|
|
34
38
|
}
|
|
35
39
|
|
|
36
40
|
doRender(ctx: CanvasRenderingContext2D, position: Vector2, graphScale: number, scaledFillableSpace: Vector2): void {
|
|
@@ -87,28 +91,24 @@ export class TextElement extends RenderElementBase {
|
|
|
87
91
|
for (let i = 0; i < eles.length; i++) {
|
|
88
92
|
eles[i].render(ctx, graphScale, justifiedPosition);
|
|
89
93
|
eles[i].size(ctx, 1, tempSize)
|
|
90
|
-
justifiedPosition.y +=
|
|
94
|
+
justifiedPosition.y += this.#text.style().getSize() * this.#lineHeight
|
|
91
95
|
}
|
|
92
96
|
}
|
|
93
97
|
}
|
|
94
98
|
|
|
95
99
|
calcSize(ctx: CanvasRenderingContext2D, out: Vector2, limitations: Vector2): void {
|
|
96
|
-
|
|
97
100
|
if (limitations.x <= 0) {
|
|
98
101
|
this.#text.size(ctx, 1, out);
|
|
99
102
|
return;
|
|
100
103
|
}
|
|
101
104
|
|
|
102
105
|
const eles = this.#text.breakIntoLines(ctx, limitations.x);
|
|
103
|
-
|
|
104
106
|
const tempSize = { x: 0, y: 0 };
|
|
105
107
|
out.x = 0;
|
|
106
|
-
out.y =
|
|
108
|
+
out.y = this.#text.style().getSize() * eles.length * this.#lineHeight;
|
|
107
109
|
for (let i = 0; i < eles.length; i++) {
|
|
108
110
|
eles[i].size(ctx, 1, tempSize)
|
|
109
111
|
out.x = Math.max(tempSize.x, out.x);
|
|
110
|
-
out.y += tempSize.y
|
|
111
112
|
}
|
|
112
|
-
|
|
113
113
|
}
|
|
114
114
|
}
|
package/src/nodes/publisher.ts
CHANGED
|
@@ -51,8 +51,10 @@ export class Publisher {
|
|
|
51
51
|
const subMenus = new Map<string, Map<string, FlowNodeConfig>>();
|
|
52
52
|
|
|
53
53
|
for (let [key, nodeConfig] of subMenu) {
|
|
54
|
-
const
|
|
55
|
-
|
|
54
|
+
const slashIndex = key.indexOf("/")
|
|
55
|
+
const bracketIndex = key.indexOf("[")
|
|
56
|
+
|
|
57
|
+
if (slashIndex === -1 || bracketIndex < slashIndex) {
|
|
56
58
|
items.push({
|
|
57
59
|
name: key,
|
|
58
60
|
callback: () => {
|
|
@@ -62,6 +64,7 @@ export class Publisher {
|
|
|
62
64
|
},
|
|
63
65
|
});
|
|
64
66
|
} else {
|
|
67
|
+
const elements = key.split("/");
|
|
65
68
|
if (!subMenus.has(elements[0])) {
|
|
66
69
|
subMenus.set(elements[0], new Map<string, FlowNodeConfig>());
|
|
67
70
|
}
|
package/src/port.ts
CHANGED
|
@@ -126,8 +126,9 @@ export class Port {
|
|
|
126
126
|
new Text(description, { color: "white", style: FontStyle.Italic }),
|
|
127
127
|
{
|
|
128
128
|
Align: TextAlign.Center,
|
|
129
|
-
Padding: { Top:
|
|
130
|
-
MaxWidth:
|
|
129
|
+
Padding: { Top: 16 },
|
|
130
|
+
MaxWidth: 400,
|
|
131
|
+
LineHeight: 1.5
|
|
131
132
|
}
|
|
132
133
|
));
|
|
133
134
|
}
|
|
@@ -135,7 +136,7 @@ export class Port {
|
|
|
135
136
|
this.#dataTypePopupElement = new ContainerRenderElement(
|
|
136
137
|
containerElements,
|
|
137
138
|
{
|
|
138
|
-
BackgroundColor: "rgba(0, 0, 0, 0.
|
|
139
|
+
BackgroundColor: "rgba(0, 0, 0, 0.85)",
|
|
139
140
|
Border: {
|
|
140
141
|
Radius: 6,
|
|
141
142
|
},
|