@yuneta/gobj-ui 7.23.197 → 7.25.1
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/gobj-ui.cjs.js +22 -13
- package/dist/gobj-ui.es.js +22 -13
- package/package.json +1 -1
- package/src/schema_to_diagram.js +25 -13
- package/src/schema_to_diagram.test.js +7 -1
package/dist/gobj-ui.cjs.js
CHANGED
|
@@ -70474,8 +70474,9 @@ function topic_descs(treedb) {
|
|
|
70474
70474
|
*
|
|
70475
70475
|
* Each link runs down its own LANE to the right of the boxes, the
|
|
70476
70476
|
* shorter links nearer to them, so no search is needed to lay it
|
|
70477
|
-
* out
|
|
70478
|
-
*
|
|
70477
|
+
* out. Where the line of one link crosses the lane of ANOTHER, the
|
|
70478
|
+
* horizontal passes over it (`─`): a junction (`┬`, `┴`) is only
|
|
70479
|
+
* ever drawn where the lines of one hook meet.
|
|
70479
70480
|
*
|
|
70480
70481
|
* The input is the schema as its literal holds it (what
|
|
70481
70482
|
* schema_to_json() answers, or the parsed literal itself):
|
|
@@ -70650,23 +70651,31 @@ function schema_to_diagram(schema) {
|
|
|
70650
70651
|
lanes[k] = (lanes[k] || []).concat([link]);
|
|
70651
70652
|
link.x = edge + LANE_GAP + LANE_GAP * k;
|
|
70652
70653
|
}
|
|
70653
|
-
let
|
|
70654
|
+
let cells = {};
|
|
70654
70655
|
let fixed = {};
|
|
70655
|
-
let join = (y, x, b) => {
|
|
70656
|
+
let join = (id, y, x, b) => {
|
|
70656
70657
|
let key = `${y},${x}`;
|
|
70657
|
-
|
|
70658
|
+
let cell = cells[key] = cells[key] || {};
|
|
70659
|
+
cell[id] = (cell[id] || 0) | b;
|
|
70658
70660
|
};
|
|
70659
|
-
let hline = (y, x1, x2) => {
|
|
70660
|
-
for (let x = x1; x <= x2; x++) join(y, x, (x > x1 ? L : 0) | (x < x2 ? R : 0));
|
|
70661
|
+
let hline = (id, y, x1, x2) => {
|
|
70662
|
+
for (let x = x1; x <= x2; x++) join(id, y, x, (x > x1 ? L : 0) | (x < x2 ? R : 0));
|
|
70661
70663
|
};
|
|
70662
|
-
let vline = (x, y1, y2) => {
|
|
70663
|
-
for (let y = y1; y <= y2; y++) join(y, x, (y > y1 ? U : 0) | (y < y2 ? D : 0));
|
|
70664
|
+
let vline = (id, x, y1, y2) => {
|
|
70665
|
+
for (let y = y1; y <= y2; y++) join(id, y, x, (y > y1 ? U : 0) | (y < y2 ? D : 0));
|
|
70664
70666
|
};
|
|
70665
|
-
|
|
70666
|
-
hline(link.from, edge + 2, link.x);
|
|
70667
|
-
hline(link.to, edge + 2, link.x);
|
|
70668
|
-
vline(link.x, link.top, link.bottom);
|
|
70667
|
+
links.forEach((link, id) => {
|
|
70668
|
+
hline(id, link.from, edge + 2, link.x);
|
|
70669
|
+
hline(id, link.to, edge + 2, link.x);
|
|
70670
|
+
vline(id, link.x, link.top, link.bottom);
|
|
70669
70671
|
fixed[`${link.from},${edge + 2}`] = "◀";
|
|
70672
|
+
});
|
|
70673
|
+
let bits = {};
|
|
70674
|
+
for (let [key, cell] of Object.entries(cells)) {
|
|
70675
|
+
let parts = Object.values(cell);
|
|
70676
|
+
let passing = parts.filter((b) => b === 3).length;
|
|
70677
|
+
let lane = parts.filter((b) => b === 12).length;
|
|
70678
|
+
bits[key] = passing && lane && passing + lane === parts.length ? 3 : parts.reduce((a, b) => a | b, 0);
|
|
70670
70679
|
}
|
|
70671
70680
|
let out = lines.map((line, y) => {
|
|
70672
70681
|
let chars = Array.from(line);
|
package/dist/gobj-ui.es.js
CHANGED
|
@@ -70469,8 +70469,9 @@ function topic_descs(treedb) {
|
|
|
70469
70469
|
*
|
|
70470
70470
|
* Each link runs down its own LANE to the right of the boxes, the
|
|
70471
70471
|
* shorter links nearer to them, so no search is needed to lay it
|
|
70472
|
-
* out
|
|
70473
|
-
*
|
|
70472
|
+
* out. Where the line of one link crosses the lane of ANOTHER, the
|
|
70473
|
+
* horizontal passes over it (`─`): a junction (`┬`, `┴`) is only
|
|
70474
|
+
* ever drawn where the lines of one hook meet.
|
|
70474
70475
|
*
|
|
70475
70476
|
* The input is the schema as its literal holds it (what
|
|
70476
70477
|
* schema_to_json() answers, or the parsed literal itself):
|
|
@@ -70645,23 +70646,31 @@ function schema_to_diagram(schema) {
|
|
|
70645
70646
|
lanes[k] = (lanes[k] || []).concat([link]);
|
|
70646
70647
|
link.x = edge + LANE_GAP + LANE_GAP * k;
|
|
70647
70648
|
}
|
|
70648
|
-
let
|
|
70649
|
+
let cells = {};
|
|
70649
70650
|
let fixed = {};
|
|
70650
|
-
let join = (y, x, b) => {
|
|
70651
|
+
let join = (id, y, x, b) => {
|
|
70651
70652
|
let key = `${y},${x}`;
|
|
70652
|
-
|
|
70653
|
+
let cell = cells[key] = cells[key] || {};
|
|
70654
|
+
cell[id] = (cell[id] || 0) | b;
|
|
70653
70655
|
};
|
|
70654
|
-
let hline = (y, x1, x2) => {
|
|
70655
|
-
for (let x = x1; x <= x2; x++) join(y, x, (x > x1 ? L : 0) | (x < x2 ? R : 0));
|
|
70656
|
+
let hline = (id, y, x1, x2) => {
|
|
70657
|
+
for (let x = x1; x <= x2; x++) join(id, y, x, (x > x1 ? L : 0) | (x < x2 ? R : 0));
|
|
70656
70658
|
};
|
|
70657
|
-
let vline = (x, y1, y2) => {
|
|
70658
|
-
for (let y = y1; y <= y2; y++) join(y, x, (y > y1 ? U : 0) | (y < y2 ? D : 0));
|
|
70659
|
+
let vline = (id, x, y1, y2) => {
|
|
70660
|
+
for (let y = y1; y <= y2; y++) join(id, y, x, (y > y1 ? U : 0) | (y < y2 ? D : 0));
|
|
70659
70661
|
};
|
|
70660
|
-
|
|
70661
|
-
hline(link.from, edge + 2, link.x);
|
|
70662
|
-
hline(link.to, edge + 2, link.x);
|
|
70663
|
-
vline(link.x, link.top, link.bottom);
|
|
70662
|
+
links.forEach((link, id) => {
|
|
70663
|
+
hline(id, link.from, edge + 2, link.x);
|
|
70664
|
+
hline(id, link.to, edge + 2, link.x);
|
|
70665
|
+
vline(id, link.x, link.top, link.bottom);
|
|
70664
70666
|
fixed[`${link.from},${edge + 2}`] = "◀";
|
|
70667
|
+
});
|
|
70668
|
+
let bits = {};
|
|
70669
|
+
for (let [key, cell] of Object.entries(cells)) {
|
|
70670
|
+
let parts = Object.values(cell);
|
|
70671
|
+
let passing = parts.filter((b) => b === 3).length;
|
|
70672
|
+
let lane = parts.filter((b) => b === 12).length;
|
|
70673
|
+
bits[key] = passing && lane && passing + lane === parts.length ? 3 : parts.reduce((a, b) => a | b, 0);
|
|
70665
70674
|
}
|
|
70666
70675
|
let out = lines.map((line, y) => {
|
|
70667
70676
|
let chars = Array.from(line);
|
package/package.json
CHANGED
package/src/schema_to_diagram.js
CHANGED
|
@@ -13,8 +13,9 @@
|
|
|
13
13
|
*
|
|
14
14
|
* Each link runs down its own LANE to the right of the boxes, the
|
|
15
15
|
* shorter links nearer to them, so no search is needed to lay it
|
|
16
|
-
* out
|
|
17
|
-
*
|
|
16
|
+
* out. Where the line of one link crosses the lane of ANOTHER, the
|
|
17
|
+
* horizontal passes over it (`─`): a junction (`┬`, `┴`) is only
|
|
18
|
+
* ever drawn where the lines of one hook meet.
|
|
18
19
|
*
|
|
19
20
|
* The input is the schema as its literal holds it (what
|
|
20
21
|
* schema_to_json() answers, or the parsed literal itself):
|
|
@@ -251,27 +252,38 @@ function schema_to_diagram(schema)
|
|
|
251
252
|
/*
|
|
252
253
|
* Draw them on a grid of direction bits, then as glyphs
|
|
253
254
|
*/
|
|
254
|
-
|
|
255
|
+
/* Bits are kept per link: two links meeting in a cell is a
|
|
256
|
+
* CROSSING unless they share a hook row or an fkey row. */
|
|
257
|
+
let cells = {};
|
|
255
258
|
let fixed = {};
|
|
256
|
-
let join = (y, x, b) => {
|
|
259
|
+
let join = (id, y, x, b) => {
|
|
257
260
|
let key = `${y},${x}`;
|
|
258
|
-
|
|
261
|
+
let cell = cells[key] = cells[key] || {};
|
|
262
|
+
cell[id] = (cell[id] || 0) | b;
|
|
259
263
|
};
|
|
260
|
-
let hline = (y, x1, x2) => {
|
|
264
|
+
let hline = (id, y, x1, x2) => {
|
|
261
265
|
for(let x = x1; x <= x2; x++) {
|
|
262
|
-
join(y, x, (x > x1 ? L : 0) | (x < x2 ? R : 0));
|
|
266
|
+
join(id, y, x, (x > x1 ? L : 0) | (x < x2 ? R : 0));
|
|
263
267
|
}
|
|
264
268
|
};
|
|
265
|
-
let vline = (x, y1, y2) => {
|
|
269
|
+
let vline = (id, x, y1, y2) => {
|
|
266
270
|
for(let y = y1; y <= y2; y++) {
|
|
267
|
-
join(y, x, (y > y1 ? U : 0) | (y < y2 ? D : 0));
|
|
271
|
+
join(id, y, x, (y > y1 ? U : 0) | (y < y2 ? D : 0));
|
|
268
272
|
}
|
|
269
273
|
};
|
|
270
|
-
|
|
271
|
-
hline(link.from, edge + 2, link.x);
|
|
272
|
-
hline(link.to, edge + 2, link.x);
|
|
273
|
-
vline(link.x, link.top, link.bottom);
|
|
274
|
+
links.forEach((link, id) => {
|
|
275
|
+
hline(id, link.from, edge + 2, link.x);
|
|
276
|
+
hline(id, link.to, edge + 2, link.x);
|
|
277
|
+
vline(id, link.x, link.top, link.bottom);
|
|
274
278
|
fixed[`${link.from},${edge + 2}`] = "◀";
|
|
279
|
+
});
|
|
280
|
+
let bits = {};
|
|
281
|
+
for(let [key, cell] of Object.entries(cells)) {
|
|
282
|
+
let parts = Object.values(cell);
|
|
283
|
+
let passing = parts.filter((b) => b === (L|R)).length;
|
|
284
|
+
let lane = parts.filter((b) => b === (U|D)).length;
|
|
285
|
+
let across = passing && lane && passing + lane === parts.length;
|
|
286
|
+
bits[key] = across ? (L|R) : parts.reduce((a, b) => a | b, 0);
|
|
275
287
|
}
|
|
276
288
|
|
|
277
289
|
let out = lines.map((line, y) => {
|
|
@@ -66,7 +66,7 @@ const EXPECTED = `treedb_sample (schema_version 4)
|
|
|
66
66
|
│ departments {} │ ◀─┐
|
|
67
67
|
│ department_id (↖) │ ──┘
|
|
68
68
|
│ users {} │ ◀─────┐
|
|
69
|
-
│ managers [] │
|
|
69
|
+
│ managers [] │ ◀─┬───────┐
|
|
70
70
|
│ manager [↖] │ ──┘ │ │
|
|
71
71
|
└───────────────────────────┘ │ │
|
|
72
72
|
│ │
|
|
@@ -88,6 +88,12 @@ describe("schema_to_diagram", () => {
|
|
|
88
88
|
expect(diagram).toBe(EXPECTED);
|
|
89
89
|
});
|
|
90
90
|
|
|
91
|
+
test("crossing another link's lane is a bridge, not a junction", () => {
|
|
92
|
+
const managers = diagram.split("\n").find((l) => l.includes("managers []"));
|
|
93
|
+
expect(managers).toContain("◀─┬───────┐");
|
|
94
|
+
expect(managers).not.toContain("┼");
|
|
95
|
+
});
|
|
96
|
+
|
|
91
97
|
test("no line ends in a space", () => {
|
|
92
98
|
for(const line of diagram.split("\n")) {
|
|
93
99
|
expect(line).toBe(line.trimEnd());
|