cornfield 0.51.8 → 0.52.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/cli/cornfield.js +7 -0
- package/core/config.js +2 -1
- package/core/map-tokens.js +2 -4
- package/core/repo.js +59 -4
- package/core/strings.js +5 -0
- package/core/text.js +18 -0
- package/core/validate.js +17 -10
- package/explorer/engine/flow-legend.js +28 -0
- package/explorer/engine/flow-ui.js +3 -22
- package/explorer/engine/keyboard.js +28 -15
- package/explorer/engine/map-rect.js +2 -2
- package/explorer/engine/map-style.js +12 -6
- package/explorer/engine/piece.js +27 -2
- package/explorer/engine/render.js +7 -4
- package/explorer/engine/roots.js +71 -0
- package/explorer/engine/search-status.js +2 -8
- package/explorer/flows.js +2 -1
- package/explorer/glyphs.js +14 -6
- package/explorer/instance.js +39 -10
- package/explorer/pieces/around.js +114 -0
- package/explorer/pieces/layers.js +31 -17
- package/explorer/pieces/map.js +14 -1
- package/explorer/pieces/node-panel.js +33 -15
- package/explorer/pieces/search.js +43 -12
- package/explorer/renderer-canvas2d.js +46 -12
- package/explorer/renderer-webgl.js +3 -1
- package/explorer/scene.js +1 -1
- package/explorer/search-match.js +53 -0
- package/explorer/search-model.js +6 -48
- package/explorer/shaders.js +17 -6
- package/package.json +1 -1
- package/plugins/cloud/index.js +5 -3
- package/plugins/compose/index.js +12 -6
- package/plugins/docs/site.js +2 -2
- package/plugins/openapi/index.js +10 -5
- package/plugins/starter/index.js +2 -2
- package/plugins/world/index.js +3 -2
|
@@ -39,6 +39,7 @@ import { layerOn, projectLayerKey } from '../layer-model.js';
|
|
|
39
39
|
import { showSearchStatus, updateSearchStatus } from '../engine/search-status.js';
|
|
40
40
|
import { countText, moreLine, noMatchLine, searchNodes, stepIndex } from '../search-model.js';
|
|
41
41
|
import { scopeOf, place } from '../engine/piece.js';
|
|
42
|
+
import { listenRoots } from '../engine/roots.js';
|
|
42
43
|
|
|
43
44
|
/** The two fields: the desktop's and the phone's bar. Each has its input, count, list and the live region it shares with the other */
|
|
44
45
|
const FIELDS = [
|
|
@@ -52,12 +53,12 @@ export const MATCH_ZOOM = 1;
|
|
|
52
53
|
const FRAME_STOP = Symbol('frame all');
|
|
53
54
|
|
|
54
55
|
/** The markup of the piece: the field with the button that opens the phone's bar (`field`), and the phone's bar (`bar`) */
|
|
55
|
-
export const markup = () => ({
|
|
56
|
-
field: `<button type="button" id="mobile-search-toggle" class="hx-hdr-icon hx-only-mobile" data-corn="mobile-search-button" data-action="toggle-mobile-search" aria-label="Open Search" title="Search nodes" data-corn-kind="icon">
|
|
56
|
+
export const markup = ({ phone = true } = {}) => ({
|
|
57
|
+
field: `${phone ? `<button type="button" id="mobile-search-toggle" class="hx-hdr-icon hx-only-mobile" data-corn="mobile-search-button" data-action="toggle-mobile-search" aria-label="Open Search" title="Search nodes" data-corn-kind="icon">
|
|
57
58
|
<svg viewBox="0 0 16 16" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" aria-hidden="true" focusable="false"><circle cx="7" cy="7" r="4.5" /><path d="M10.5 10.5L14 14" /></svg>
|
|
58
59
|
</button>
|
|
59
60
|
|
|
60
|
-
<div class="hx-search" role="search" data-corn="search">
|
|
61
|
+
` : ''}<div class="hx-search" role="search" data-corn="search">
|
|
61
62
|
<svg class="hx-search-icon" viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" aria-hidden="true" focusable="false"><circle cx="7" cy="7" r="4.5" /><path d="M10.5 10.5L14 14" /></svg>
|
|
62
63
|
<input type="text" id="node-search" class="hx-search-input" placeholder="Search..." data-corn-string-placeholder="searchPlaceholder" aria-label="Search nodes" aria-keyshortcuts="/" data-corn="search-input" />
|
|
63
64
|
<kbd class="hx-kbd" data-corn="search-key" aria-hidden="true">/</kbd>
|
|
@@ -70,7 +71,7 @@ export const markup = () => ({
|
|
|
70
71
|
<div id="search-status" class="hx-search-status" role="status" aria-live="polite" data-corn="search-status"></div>
|
|
71
72
|
<div id="search-results" class="hx-search-results" data-corn="search-results" hidden></div>
|
|
72
73
|
</div>`,
|
|
73
|
-
bar: `<div id="mobile-search-bar" class="hx-mobile-search glass-header" role="search" hidden data-corn="mobile-search">
|
|
74
|
+
bar: !phone ? '' : `<div id="mobile-search-bar" class="hx-mobile-search glass-header" role="search" hidden data-corn="mobile-search">
|
|
74
75
|
<input type="text" id="mobile-node-search" class="hx-input hx-input--wide" placeholder="Search nodes, apps, components..." aria-label="Search nodes" data-corn="search-input" />
|
|
75
76
|
<button type="button" class="hx-textbtn" data-action="close-mobile-search" data-corn-kind="quiet">Cancel</button>
|
|
76
77
|
<span id="mobile-search-steps" class="hx-search-steps" data-corn="search-steps" hidden>
|
|
@@ -120,8 +121,8 @@ export function mount(root, inst, options = {}) {
|
|
|
120
121
|
const { state } = inst;
|
|
121
122
|
const scope = scopeOf(inst);
|
|
122
123
|
const made = [
|
|
123
|
-
...place(inst, root, markup().field, options.slots, 'field'),
|
|
124
|
-
...place(inst, root, markup().bar, options.slots, 'bar'),
|
|
124
|
+
...place(inst, root, markup({ phone: options.phone !== false }).field, options.slots, 'field'),
|
|
125
|
+
...place(inst, root, markup({ phone: options.phone !== false }).bar, options.slots, 'bar'),
|
|
125
126
|
];
|
|
126
127
|
/** An element of this piece by id */
|
|
127
128
|
const own = (id) => {
|
|
@@ -133,6 +134,8 @@ export function mount(root, inst, options = {}) {
|
|
|
133
134
|
return null;
|
|
134
135
|
};
|
|
135
136
|
scope.keepParts(...made);
|
|
137
|
+
/** The fields this mount has: both on cornfield's page; the field alone in a box of its own (`options.phone: false`, `<corn-search>`) */
|
|
138
|
+
const fields = FIELDS.filter((f) => own(f.input));
|
|
136
139
|
let memo = null; // { key, nodes, result }
|
|
137
140
|
let chosen = 0;
|
|
138
141
|
|
|
@@ -163,7 +166,7 @@ export function mount(root, inst, options = {}) {
|
|
|
163
166
|
function paintSearch({ keepOpen = true } = {}) {
|
|
164
167
|
const result = currentResult();
|
|
165
168
|
const text = countText(result, state.searchCurrent);
|
|
166
|
-
for (const field of
|
|
169
|
+
for (const field of fields) {
|
|
167
170
|
const count = own(field.count);
|
|
168
171
|
if (count) { count.textContent = text; count.dataset.empty = result.query && !result.total ? 'true' : 'false'; }
|
|
169
172
|
const steps = own(field.steps);
|
|
@@ -220,7 +223,7 @@ export function mount(root, inst, options = {}) {
|
|
|
220
223
|
state.searchQuery = query;
|
|
221
224
|
if (changed) state.searchCurrent = null; // a new question has no current answer yet
|
|
222
225
|
inst.touchScene();
|
|
223
|
-
for (const field of
|
|
226
|
+
for (const field of fields) {
|
|
224
227
|
const input = own(field.input);
|
|
225
228
|
if (input && input.value !== value) input.value = value || '';
|
|
226
229
|
const list = listOf(field);
|
|
@@ -340,7 +343,7 @@ export function mount(root, inst, options = {}) {
|
|
|
340
343
|
if (!match) return;
|
|
341
344
|
chooseMatch(match);
|
|
342
345
|
// On a phone the list would cover the match: it shuts, and the focus goes to the next-match button, which stays
|
|
343
|
-
const field =
|
|
346
|
+
const field = fields.find((f) => listOf(f) === e.currentTarget);
|
|
344
347
|
if (field && field.input === 'mobile-node-search' && isPhone(inst)) {
|
|
345
348
|
closeList(field);
|
|
346
349
|
const next = own(field.steps) && own(field.steps).querySelector('[data-action="search-next"]');
|
|
@@ -370,7 +373,7 @@ export function mount(root, inst, options = {}) {
|
|
|
370
373
|
}
|
|
371
374
|
|
|
372
375
|
// Both fields, their list, and the step and clear buttons
|
|
373
|
-
for (const field of
|
|
376
|
+
for (const field of fields) {
|
|
374
377
|
const input = own(field.input);
|
|
375
378
|
// A combobox whose popup is a listbox: its options (Frame all, then the rows) in labelled groups, reached with the down arrow and
|
|
376
379
|
// walked with the arrows (the focus moves from option to option), so a screen reader hears each row and its group
|
|
@@ -420,11 +423,37 @@ export function mount(root, inst, options = {}) {
|
|
|
420
423
|
const open = own('mobile-search-toggle');
|
|
421
424
|
if (open) open.click();
|
|
422
425
|
}
|
|
423
|
-
|
|
424
|
-
|
|
426
|
+
// On every root of the instance: with the map in another shadow root, `/` there reaches the field here
|
|
427
|
+
const tree = typeof root.getRootNode === 'function' ? root.getRootNode() : root;
|
|
428
|
+
scope.own(listenRoots(inst, 'keydown', (e) => {
|
|
429
|
+
if (e.key === '/' && !e.ctrlKey && !e.metaKey && !e.altKey && !typing(e.target) && !(tree.querySelector && tree.querySelector('[data-corn="dialog-scrim"]:not([hidden]), .hx-mockup-dialog'))) {
|
|
425
430
|
e.preventDefault();
|
|
431
|
+
// two search tags in one scope: the first that took the focus keeps it
|
|
432
|
+
const now = inst.active();
|
|
433
|
+
if (now && typeof now.matches === 'function' && now.matches('[data-corn="search-input"]') && !made.some((el) => el.contains(now))) return;
|
|
426
434
|
goToSearch();
|
|
427
435
|
}
|
|
436
|
+
}));
|
|
437
|
+
// What the live regions beside the fields say (engine/search-status.js tells the instance; the regions are this piece's own). A scope may hold two search
|
|
438
|
+
// tags: they are one search (one query, one current match), and only one of them speaks, the one last used (else the first), so it is said once
|
|
439
|
+
const voice = inst.slot('search-voice', () => ({ current: null, all: new Set() }));
|
|
440
|
+
const me = {};
|
|
441
|
+
voice.all.add(me);
|
|
442
|
+
if (!voice.current) voice.current = me;
|
|
443
|
+
for (const field of fields) scope.listen(own(field.input), 'focus', () => { voice.current = me; });
|
|
444
|
+
scope.own(() => { voice.all.delete(me); if (voice.current === me) voice.current = null; });
|
|
445
|
+
scope.on('search:status', (text) => {
|
|
446
|
+
if (!voice.current) voice.current = me;
|
|
447
|
+
for (const id of ['search-status', 'mobile-search-status']) { const el = own(id); if (el) el.textContent = voice.current === me ? text : ''; }
|
|
448
|
+
});
|
|
449
|
+
// ... and the other one shows what this one typed or chose (cornfield's page has one search: nothing here runs there)
|
|
450
|
+
scope.on('search', () => {
|
|
451
|
+
if (voice.all.size < 2 || made.some((el) => el.contains(inst.active()))) return;
|
|
452
|
+
for (const field of fields) {
|
|
453
|
+
const input = own(field.input);
|
|
454
|
+
if (input && input.value.trim() !== state.searchQuery) input.value = state.searchQuery;
|
|
455
|
+
}
|
|
456
|
+
paintSearch({ keepOpen: false });
|
|
428
457
|
});
|
|
429
458
|
|
|
430
459
|
// What the neighbours ask of the search, and a layer going on or off moving matches between the list and "In layers that are off"
|
|
@@ -443,6 +472,8 @@ export function mount(root, inst, options = {}) {
|
|
|
443
472
|
searchActive,
|
|
444
473
|
paintSearch,
|
|
445
474
|
toggleMobileSearch,
|
|
475
|
+
/** The focus goes to the field, its text selected (what `/` does) */
|
|
476
|
+
focusField() { const input = own('node-search'); if (input) { input.focus(); input.select(); } },
|
|
446
477
|
/** For tests: forget what was found */
|
|
447
478
|
reset() { memo = null; chosen++; state.searchQuery = ''; state.searchCurrent = null; },
|
|
448
479
|
update(props) {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* labels are the label layer's (labels.js), one transparent canvas over the map for either renderer.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { CORE_RATIO, ARROW, END_SHAPES, SHAPE_SIZES, EDGE_STRIKE, MARK_MIN_PX, edgePoint, looksFor, packetPoint } from './scene.js';
|
|
11
|
+
import { CORE_RATIO, ARROW, END_SHAPES, SHAPE_REACH, SHAPE_SIZES, EDGE_STRIKE, MARK_MIN_PX, edgePoint, looksFor, packetPoint, parseColor } from './scene.js';
|
|
12
12
|
import { GLYPH_TOKEN, ICON_RATIO, PLAIN_STYLE, looksWith, styledScene } from './engine/map-style.js';
|
|
13
13
|
import { LETTER_RATIO, letterImage, showsLetters } from './kind-letters.js';
|
|
14
14
|
import { GLYPH_RATIO, glyphImage, glyphInk, showsGlyph } from './glyphs.js';
|
|
@@ -18,6 +18,17 @@ const TAU = Math.PI * 2;
|
|
|
18
18
|
const GLOW_MIN_PX = 1.5;
|
|
19
19
|
/** A scene with this many edges or fewer is drawn directly each frame; more, and its lines go into the layer while packets move */
|
|
20
20
|
export const LAYER_MIN_EDGES = 600;
|
|
21
|
+
const alphas = new Map();
|
|
22
|
+
/** The alpha of a node's colour (0..1; 1 for what is not read), remembered: it is asked for every glowing node of every frame */
|
|
23
|
+
function alphaOf(color) {
|
|
24
|
+
let a = alphas.get(color);
|
|
25
|
+
if (a === undefined) {
|
|
26
|
+
if (alphas.size > 512) alphas.clear();
|
|
27
|
+
a = parseColor(color)[3];
|
|
28
|
+
alphas.set(color, a);
|
|
29
|
+
}
|
|
30
|
+
return a;
|
|
31
|
+
}
|
|
21
32
|
const circle = (ctx, x, y, r) => { ctx.beginPath(); ctx.arc(x, y, r, 0, TAU); };
|
|
22
33
|
|
|
23
34
|
/**
|
|
@@ -25,29 +36,30 @@ const circle = (ctx, x, y, r) => { ctx.beginPath(); ctx.arc(x, y, r, 0, TAU); };
|
|
|
25
36
|
* a rounded square for data, a hexagon for what is outside, a square for where things run, a diamond for people. The WebGL node shader draws the same shapes
|
|
26
37
|
* with the same sizes (scene.js `SHAPE_SIZES`, shaders.js `sdShape`).
|
|
27
38
|
*/
|
|
28
|
-
export function silhouette(ctx, shape, x, y, r) {
|
|
39
|
+
export function silhouette(ctx, shape, x, y, r, add = false) {
|
|
40
|
+
const begin = () => { if (!add) ctx.beginPath(); }; // `add`: another piece of the path being built (a clip with a hole), not a new path
|
|
29
41
|
if (shape === 'rounded-square' || shape === 'square') {
|
|
30
42
|
const h = r * (shape === 'square' ? SHAPE_SIZES.squareHalf : SHAPE_SIZES.roundedHalf);
|
|
31
43
|
const c = r * (shape === 'square' ? SHAPE_SIZES.squareCorner : SHAPE_SIZES.roundedCorner);
|
|
32
|
-
|
|
44
|
+
begin();
|
|
33
45
|
if (ctx.roundRect) ctx.roundRect(x - h, y - h, h * 2, h * 2, c); else ctx.rect(x - h, y - h, h * 2, h * 2);
|
|
34
46
|
return;
|
|
35
47
|
}
|
|
36
48
|
if (shape === 'hexagon') {
|
|
37
49
|
const R = (r * SHAPE_SIZES.hexInradius) / Math.cos(Math.PI / 6); // flat top and bottom: the inradius is what the SDF takes
|
|
38
|
-
|
|
50
|
+
begin();
|
|
39
51
|
for (let i = 0; i < 6; i++) { const a = Math.PI / 6 + (i * Math.PI) / 3; const px = x + R * Math.cos(a), py = y + R * Math.sin(a); if (i) ctx.lineTo(px, py); else ctx.moveTo(px, py); }
|
|
40
52
|
ctx.closePath();
|
|
41
53
|
return;
|
|
42
54
|
}
|
|
43
55
|
if (shape === 'diamond') {
|
|
44
56
|
const h = r * SHAPE_SIZES.diamondHalf;
|
|
45
|
-
|
|
57
|
+
begin();
|
|
46
58
|
ctx.moveTo(x, y - h); ctx.lineTo(x + h, y); ctx.lineTo(x, y + h); ctx.lineTo(x - h, y);
|
|
47
59
|
ctx.closePath();
|
|
48
60
|
return;
|
|
49
61
|
}
|
|
50
|
-
circle(ctx, x, y, r);
|
|
62
|
+
if (add) { ctx.moveTo(x + r, y); ctx.arc(x, y, r, 0, TAU); } else circle(ctx, x, y, r);
|
|
51
63
|
}
|
|
52
64
|
|
|
53
65
|
// ---------------------------------------------------------------------------
|
|
@@ -276,7 +288,7 @@ function edgesInView(scene, camera, width, height) {
|
|
|
276
288
|
// ---------------------------------------------------------------------------
|
|
277
289
|
// Nodes
|
|
278
290
|
// ---------------------------------------------------------------------------
|
|
279
|
-
function drawNode(ctx, node, zoom, looks, style) {
|
|
291
|
+
function drawNode(ctx, node, zoom, looks, style, theme) {
|
|
280
292
|
ctx.save();
|
|
281
293
|
ctx.globalAlpha = node.alpha;
|
|
282
294
|
|
|
@@ -319,9 +331,31 @@ function drawNode(ctx, node, zoom, looks, style) {
|
|
|
319
331
|
// A soft disc behind the node, not `shadowBlur` (see drawEdge): one cheap fill instead of a blur pass
|
|
320
332
|
ctx.save();
|
|
321
333
|
ctx.globalAlpha = node.alpha * 0.28;
|
|
322
|
-
|
|
334
|
+
const reach = node.r + node.glow * 0.7;
|
|
323
335
|
ctx.fillStyle = node.color;
|
|
324
|
-
|
|
336
|
+
if (alphaOf(node.color) < 1) {
|
|
337
|
+
// Under a translucent fill the glow is left out, so the fill alone sets what shows through it; WebGL's node shader does the same.
|
|
338
|
+
// The shape inside the glow's disc (the usual case): the disc with the shape as a hole, filled even-odd. A square's corners or a diamond's
|
|
339
|
+
// points can reach past a small glow's disc (a theme's --corn-map-glow), and that fill would put them over the glow: then the disc is
|
|
340
|
+
// clipped to everything but the shape (a square round both, the shape cut out even-odd)
|
|
341
|
+
if (node.r * (SHAPE_REACH[node.shape] || 1) < reach) {
|
|
342
|
+
circle(ctx, node.x, node.y, reach);
|
|
343
|
+
silhouette(ctx, node.shape, node.x, node.y, node.r, true);
|
|
344
|
+
ctx.fill('evenodd');
|
|
345
|
+
} else {
|
|
346
|
+
const side = reach + node.r;
|
|
347
|
+
ctx.beginPath();
|
|
348
|
+
ctx.rect(node.x - side, node.y - side, side * 2, side * 2);
|
|
349
|
+
silhouette(ctx, node.shape, node.x, node.y, node.r, true);
|
|
350
|
+
ctx.clip('evenodd');
|
|
351
|
+
circle(ctx, node.x, node.y, reach);
|
|
352
|
+
ctx.fill();
|
|
353
|
+
}
|
|
354
|
+
} else {
|
|
355
|
+
// An opaque fill hides the glow under it: drawn as it always was
|
|
356
|
+
circle(ctx, node.x, node.y, reach);
|
|
357
|
+
ctx.fill();
|
|
358
|
+
}
|
|
325
359
|
ctx.restore();
|
|
326
360
|
silhouette(ctx, node.shape, node.x, node.y, node.r);
|
|
327
361
|
}
|
|
@@ -331,7 +365,7 @@ function drawNode(ctx, node, zoom, looks, style) {
|
|
|
331
365
|
// The glyph takes the core dot's place: drawn over it, the dot would fill the glyph's own shapes and blur it at the sizes nodes have
|
|
332
366
|
const image = node.icon && style.icons ? style.icons.get(node.icon) : null;
|
|
333
367
|
const letters = !image && showsLetters(node, zoom);
|
|
334
|
-
const glyph = !image && !letters && showsGlyph(node, zoom) ? glyphImage(node.glyph, glyphInk(node, style)) : null;
|
|
368
|
+
const glyph = !image && !letters && showsGlyph(node, zoom) ? glyphImage(node.glyph, glyphInk(node, style, theme)) : null;
|
|
335
369
|
if (!glyph) {
|
|
336
370
|
circle(ctx, node.x, node.y, node.r * CORE_RATIO);
|
|
337
371
|
ctx.fillStyle = looks.core;
|
|
@@ -460,7 +494,7 @@ export function createCanvas2dRenderer(canvas, opts = {}) {
|
|
|
460
494
|
ctx.translate(camera.x, camera.y);
|
|
461
495
|
ctx.scale(camera.zoom, camera.zoom);
|
|
462
496
|
inView.forEach((edge) => { if (edge.packet) drawPacket(ctx, edge, timeMs, camera.zoom); });
|
|
463
|
-
scene.nodes.forEach((node) => drawNode(ctx, node, camera.zoom, looks, style));
|
|
497
|
+
scene.nodes.forEach((node) => drawNode(ctx, node, camera.zoom, looks, style, scene.theme));
|
|
464
498
|
ctx.restore();
|
|
465
499
|
return;
|
|
466
500
|
}
|
|
@@ -475,7 +509,7 @@ export function createCanvas2dRenderer(canvas, opts = {}) {
|
|
|
475
509
|
if (decor.rings.length) drawRings(ctx, decor.rings);
|
|
476
510
|
|
|
477
511
|
inView.forEach((edge) => drawEdge(ctx, edge, timeMs, camera.zoom));
|
|
478
|
-
scene.nodes.forEach((node) => drawNode(ctx, node, camera.zoom, looks, style));
|
|
512
|
+
scene.nodes.forEach((node) => drawNode(ctx, node, camera.zoom, looks, style, scene.theme));
|
|
479
513
|
// No text here: every label (and the strike through a removed one) is drawn by the label layer (labels.js) over this canvas
|
|
480
514
|
|
|
481
515
|
ctx.restore();
|
|
@@ -226,7 +226,7 @@ export function packIcons(scene, has, style = null) {
|
|
|
226
226
|
let kind = n.icon && has(n.icon) ? n.icon : null;
|
|
227
227
|
let side = n.r * ICON_RATIO;
|
|
228
228
|
if (!kind && !n.icon && n.letters && has(letterKey(n.letters))) { kind = letterKey(n.letters); side = n.r * LETTER_RATIO; }
|
|
229
|
-
if (!kind && !n.icon && !n.letters && n.glyph) { const key = glyphKey(n.glyph, glyphInk(n, style)); if (has(key)) { kind = key; side = n.r * GLYPH_RATIO; } } // the type's own glyph, last (glyphs.js)
|
|
229
|
+
if (!kind && !n.icon && !n.letters && n.glyph) { const key = glyphKey(n.glyph, glyphInk(n, style, scene.theme)); if (has(key)) { kind = key; side = n.r * GLYPH_RATIO; } } // the type's own glyph, last (glyphs.js)
|
|
230
230
|
if (!kind) return;
|
|
231
231
|
if (!byKind.has(kind)) byKind.set(kind, { rows: [], minR: Infinity, maxR: 0 });
|
|
232
232
|
const group = byKind.get(kind);
|
|
@@ -458,6 +458,7 @@ export function createWebglRenderer(canvas, opts = {}) {
|
|
|
458
458
|
let packed = null;
|
|
459
459
|
let packedScene = null;
|
|
460
460
|
let packedVersion;
|
|
461
|
+
let packedGround = null; // the ground the icon rows were packed for: a translucent node's glyph ink depends on it (glyphs.js)
|
|
461
462
|
let lastArgs = null;
|
|
462
463
|
|
|
463
464
|
/** A pass only a theme asks for (EXTRA_PASSES), built the first time it is wanted */
|
|
@@ -527,6 +528,7 @@ export function createWebglRenderer(canvas, opts = {}) {
|
|
|
527
528
|
gpu.glyphInk = ink;
|
|
528
529
|
packedScene = null; // the icon rows are made again for the new ink
|
|
529
530
|
}
|
|
531
|
+
if (packedGround !== style.ground) { packedGround = style.ground; packedScene = null; } // another ground: a translucent node's glyph may take the other ink
|
|
530
532
|
if (scene !== packedScene || scene.version !== packedVersion) {
|
|
531
533
|
packed = { ...packScene(scene), strokes: packStrokes(scene), icons: packIcons(scene, (kind) => (isLetterKey(kind) ? !!letterImage(lettersOfKey(kind), ink) : isGlyphKey(kind) ? !!glyphImage(glyphOfKey(kind).type, glyphOfKey(kind).ink) : !!(style.icons && style.icons.get(kind))), style) };
|
|
532
534
|
packedScene = scene;
|
package/explorer/scene.js
CHANGED
|
@@ -178,7 +178,7 @@ import { hasGlyph } from './glyphs.js';
|
|
|
178
178
|
import { outageFor, paintOutage } from './outage-model.js';
|
|
179
179
|
import { paintForge } from './forge-panel-model.js';
|
|
180
180
|
import { lightColor, lightenScene, parseColor } from './theme-model.js';
|
|
181
|
-
import { matchIds } from './search-
|
|
181
|
+
import { matchIds } from './search-match.js';
|
|
182
182
|
import { nodeColor } from './css-color.js';
|
|
183
183
|
import { activeSubgraph, kindEdgeWord } from './selection-model.js';
|
|
184
184
|
import { DIFF_MARK_COLORS, DIFF_LABEL_ALPHA, GREY_ALPHA, GREY_LABEL_ALPHA, EDGE_MIN_ALPHA, MARK_SHAPES, REMOVED_ALPHA } from './diff-marks.js';
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module explorer/search-match
|
|
3
|
+
*
|
|
4
|
+
* Whether a node matches a search, and how well (spec 0008 D3): the half of search-model.js the map itself needs, to halo what a query finds
|
|
5
|
+
* (scene.js `matchIds`). Pure. search-model.js builds the list, its groups and its words on it, and re-exports these.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/** The ranks, best first */
|
|
9
|
+
export const RANK = Object.freeze({ labelStart: 0, wordStart: 1, label: 2, idOrFile: 3, typeOrKind: 4 });
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The layer's name for each node type, as the Layers menu says it (layers.js `LAYER_DEFS`; a test keeps the two together).
|
|
13
|
+
* A type not here is its own name with a capital.
|
|
14
|
+
*/
|
|
15
|
+
export const TYPE_NAMES = Object.freeze({
|
|
16
|
+
root: 'Root', app: 'Apps', pkg: 'Packages', page: 'Pages & Routes', atom: 'Atoms', molecule: 'Molecules', token: 'Design Tokens',
|
|
17
|
+
tool: 'Dev Tools', core: 'Core', store: 'Stores', table: 'Tables', rom: 'ROM', service: 'Services', external: 'Cloud', stack: 'Infra',
|
|
18
|
+
machine: 'Machines', container: 'Containers', device: 'Devices', floor: 'House', room: 'House', persona: 'People',
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const capital = (s) => (s ? s.charAt(0).toUpperCase() + s.slice(1) : s);
|
|
22
|
+
|
|
23
|
+
/** The name of the group a node is listed under: its layer's name */
|
|
24
|
+
export const groupName = (node) => TYPE_NAMES[node.type] || capital(String(node.type || ''));
|
|
25
|
+
|
|
26
|
+
const lower = (s) => (typeof s === 'string' ? s.toLowerCase() : '');
|
|
27
|
+
const WORD_BREAK = /[^\p{L}\p{N}]+/u;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* How well `query` (trimmed) matches a node, as a RANK, or -1 for no match
|
|
31
|
+
* @param {{label?: string, id?: string, file?: string, type?: string, kind?: string}} node
|
|
32
|
+
* @param {string} query
|
|
33
|
+
*/
|
|
34
|
+
export function rankOf(node, query) {
|
|
35
|
+
const term = String(query || '').toLowerCase();
|
|
36
|
+
if (!term) return -1;
|
|
37
|
+
const label = lower(node.label);
|
|
38
|
+
if (label.startsWith(term)) return RANK.labelStart;
|
|
39
|
+
if (label.split(WORD_BREAK).some((w) => w && w.startsWith(term))) return RANK.wordStart;
|
|
40
|
+
if (label.includes(term)) return RANK.label;
|
|
41
|
+
if (lower(node.id).includes(term) || lower(node.file).includes(term)) return RANK.idOrFile;
|
|
42
|
+
if (lower(node.type).includes(term) || lower(groupName(node)).includes(term) || lower(node.kind).includes(term)) return RANK.typeOrKind;
|
|
43
|
+
return -1;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** The ids a query matches (what the map halos): a Set, empty for no query */
|
|
47
|
+
export function matchIds(nodes, query) {
|
|
48
|
+
const term = String(query || '').trim().toLowerCase();
|
|
49
|
+
const ids = new Set();
|
|
50
|
+
if (!term) return ids;
|
|
51
|
+
for (const node of nodes) if (rankOf(node, term) >= 0) ids.add(node.id);
|
|
52
|
+
return ids;
|
|
53
|
+
}
|
package/explorer/search-model.js
CHANGED
|
@@ -12,53 +12,20 @@
|
|
|
12
12
|
* - It groups by type, under the layer's name with a count, groups in the order of their best match, and puts the matches
|
|
13
13
|
* in layers that are off last, under their own heading.
|
|
14
14
|
*
|
|
15
|
-
* Substring matching only: no fuzzy matching, so a reviewer can always see why a node matched.
|
|
15
|
+
* Substring matching only: no fuzzy matching, so a reviewer can always see why a node matched. The matching itself is search-match.js.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
+
// Whether a node matches, and how well: search-match.js (what the map needs to halo the matches); kept as this module's too
|
|
19
|
+
import { RANK, TYPE_NAMES, groupName, rankOf, matchIds } from './search-match.js';
|
|
20
|
+
|
|
21
|
+
export { RANK, TYPE_NAMES, groupName, rankOf, matchIds };
|
|
22
|
+
|
|
18
23
|
/** The heading of the matches in layers that are off */
|
|
19
24
|
export const OFF_GROUP = 'In layers that are off';
|
|
20
25
|
|
|
21
26
|
/** Rows the list shows before "and N more" */
|
|
22
27
|
export const MAX_ROWS = 50;
|
|
23
28
|
|
|
24
|
-
/** The ranks, best first */
|
|
25
|
-
export const RANK = Object.freeze({ labelStart: 0, wordStart: 1, label: 2, idOrFile: 3, typeOrKind: 4 });
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* The layer's name for each node type, as the Layers menu says it (layers.js `LAYER_DEFS`; a test keeps the two together).
|
|
29
|
-
* A type not here is its own name with a capital.
|
|
30
|
-
*/
|
|
31
|
-
export const TYPE_NAMES = Object.freeze({
|
|
32
|
-
root: 'Root', app: 'Apps', pkg: 'Packages', page: 'Pages & Routes', atom: 'Atoms', molecule: 'Molecules', token: 'Design Tokens',
|
|
33
|
-
tool: 'Dev Tools', core: 'Core', store: 'Stores', table: 'Tables', rom: 'ROM', service: 'Services', external: 'Cloud', stack: 'Infra',
|
|
34
|
-
machine: 'Machines', container: 'Containers', device: 'Devices', floor: 'House', room: 'House', persona: 'People',
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
const capital = (s) => (s ? s.charAt(0).toUpperCase() + s.slice(1) : s);
|
|
38
|
-
|
|
39
|
-
/** The name of the group a node is listed under: its layer's name */
|
|
40
|
-
export const groupName = (node) => TYPE_NAMES[node.type] || capital(String(node.type || ''));
|
|
41
|
-
|
|
42
|
-
const lower = (s) => (typeof s === 'string' ? s.toLowerCase() : '');
|
|
43
|
-
const WORD_BREAK = /[^\p{L}\p{N}]+/u;
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* How well `query` (trimmed) matches a node, as a RANK, or -1 for no match
|
|
47
|
-
* @param {{label?: string, id?: string, file?: string, type?: string, kind?: string}} node
|
|
48
|
-
* @param {string} query
|
|
49
|
-
*/
|
|
50
|
-
export function rankOf(node, query) {
|
|
51
|
-
const term = String(query || '').toLowerCase();
|
|
52
|
-
if (!term) return -1;
|
|
53
|
-
const label = lower(node.label);
|
|
54
|
-
if (label.startsWith(term)) return RANK.labelStart;
|
|
55
|
-
if (label.split(WORD_BREAK).some((w) => w && w.startsWith(term))) return RANK.wordStart;
|
|
56
|
-
if (label.includes(term)) return RANK.label;
|
|
57
|
-
if (lower(node.id).includes(term) || lower(node.file).includes(term)) return RANK.idOrFile;
|
|
58
|
-
if (lower(node.type).includes(term) || lower(groupName(node)).includes(term) || lower(node.kind).includes(term)) return RANK.typeOrKind;
|
|
59
|
-
return -1;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
29
|
/**
|
|
63
30
|
* Every node the query finds, in the order the list shows them.
|
|
64
31
|
* @param {object[]} nodes the topology nodes
|
|
@@ -116,15 +83,6 @@ export function searchNodes(nodes, query, opts = {}) {
|
|
|
116
83
|
return out;
|
|
117
84
|
}
|
|
118
85
|
|
|
119
|
-
/** The ids a query matches (what the map halos): a Set, empty for no query */
|
|
120
|
-
export function matchIds(nodes, query) {
|
|
121
|
-
const term = String(query || '').trim().toLowerCase();
|
|
122
|
-
const ids = new Set();
|
|
123
|
-
if (!term) return ids;
|
|
124
|
-
for (const node of nodes) if (rankOf(node, term) >= 0) ids.add(node.id);
|
|
125
|
-
return ids;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
86
|
/**
|
|
129
87
|
* The match `by` steps (+1 or -1) from the one with id `currentId`, wrapping round; the first (or, going back, the last) when
|
|
130
88
|
* there is no current one or it is not among them.
|
package/explorer/shaders.js
CHANGED
|
@@ -289,15 +289,26 @@ void main() {
|
|
|
289
289
|
over(acc, ring.rgb, ring.a * al * coverBand(abs(len - (rw + u_haloGeom[halo].y) * zoom), u_haloGeom[halo].z * zoom * 0.5, pix));
|
|
290
290
|
}
|
|
291
291
|
|
|
292
|
-
// Glow: a blurred copy of the disc under it (see glowDisc)
|
|
293
|
-
float glow = v_color.w;
|
|
294
|
-
if (glow > 0.0) over(acc, v_color.rgb, v_kind.z * al * glowDisc(len, R, glow * 0.5 / u_dpr));
|
|
295
|
-
|
|
296
|
-
// The silhouette, and its white core unless the type's glyph is drawn there (glyphs.js: the icon pass draws it once the node is wide enough)
|
|
297
292
|
int shapeCode = int(v_kind.w + 0.5);
|
|
298
293
|
bool glyph = shapeCode >= 8;
|
|
299
294
|
if (glyph) shapeCode -= 8;
|
|
300
|
-
|
|
295
|
+
float shapeCover = coverEdge(sdShape(v_local, R, shapeCode, len), pix); // how much of this pixel the silhouette covers
|
|
296
|
+
|
|
297
|
+
// Glow: a blurred copy of the disc under it (see glowDisc), then the silhouette. An opaque fill hides the glow under it: drawn as it always was.
|
|
298
|
+
// Under a translucent fill the glow is left out, so the fill alone sets what is seen through it, as renderer-canvas2d.js drawNode does (a clip).
|
|
299
|
+
// Glow and fill are the same colour, so that is ONE layer: the fill in the part of the pixel the silhouette covers, the glow in the rest. Two
|
|
300
|
+
// layers (the glow times 1 - cover, then the fill times cover) would let the ground through both at the edge: a dark line round a square or a
|
|
301
|
+
// diamond, whose sides lie inside the glow's disc
|
|
302
|
+
float glow = v_color.w;
|
|
303
|
+
if (v_kind.z < 1.0) {
|
|
304
|
+
float soft = glow > 0.0 ? glowDisc(len, R, glow * 0.5 / u_dpr) : 0.0;
|
|
305
|
+
over(acc, v_color.rgb, v_kind.z * al * mix(soft, 1.0, shapeCover));
|
|
306
|
+
} else {
|
|
307
|
+
if (glow > 0.0) over(acc, v_color.rgb, v_kind.z * al * glowDisc(len, R, glow * 0.5 / u_dpr));
|
|
308
|
+
over(acc, v_color.rgb, v_kind.z * al * shapeCover);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// The white core unless the type's glyph is drawn there (glyphs.js: the icon pass draws it once the node is wide enough)
|
|
301
312
|
if (!glyph || 2.0 * R < u_glyphMin) over(acc, u_core.rgb, u_core.a * al * coverEdge(len - R * u_coreRatio, pix));
|
|
302
313
|
|
|
303
314
|
// Mark: a ring with the look of its own mark (dashed when its dash is set: added), and for removed a
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cornfield",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.52.1",
|
|
4
4
|
"description": "A self-hostable dev dashboard with the topology map at its centre: proposals on the map, scenarios, outages and what-if edits, for any repo.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "popcorn245 (https://github.com/popcorn245)",
|
package/plugins/cloud/index.js
CHANGED
|
@@ -31,7 +31,8 @@
|
|
|
31
31
|
|
|
32
32
|
import { CLOUD_FILE, deriveCloud, EVIDENCE_KINDS } from '../../core/cloud.js';
|
|
33
33
|
import { hostsIn } from './hosts.js';
|
|
34
|
-
import { leavesRepo, outsideProblem } from '../../core/repo.js';
|
|
34
|
+
import { fileOptionProblem, leavesRepo, outsideProblem } from '../../core/repo.js';
|
|
35
|
+
import { quote } from '../../core/text.js';
|
|
35
36
|
import { caddyEvidence, dockerfileSources, imageRef, workflowSources } from './sources.js';
|
|
36
37
|
|
|
37
38
|
const WORKFLOW_DIRS = ['.github/workflows', '.forgejo/workflows'];
|
|
@@ -152,8 +153,9 @@ export default {
|
|
|
152
153
|
|
|
153
154
|
// Caddyfiles the config names
|
|
154
155
|
for (const { file, from } of options.caddyfiles || []) {
|
|
155
|
-
|
|
156
|
-
if (
|
|
156
|
+
const bad = fileOptionProblem(ctx, 'cloud', 'caddyfiles[].file', file);
|
|
157
|
+
if (bad) { problems.push(bad); continue; }
|
|
158
|
+
if (!ctx.exists(file)) { warnings.push(`cloud: caddyfile ${quote(file)} does not exist.`); continue; }
|
|
157
159
|
for (const e of caddyEvidence(ctx.read(file))) add({ ...e, from, when: 'renew', file });
|
|
158
160
|
}
|
|
159
161
|
|
package/plugins/compose/index.js
CHANGED
|
@@ -35,7 +35,8 @@
|
|
|
35
35
|
*/
|
|
36
36
|
|
|
37
37
|
import { caddyRoutes, labelsOf, traefikRoutes } from './routes.js';
|
|
38
|
-
import {
|
|
38
|
+
import { eachPlaceOnce, fileOptionProblem } from '../../core/repo.js';
|
|
39
|
+
import { quote } from '../../core/text.js';
|
|
39
40
|
|
|
40
41
|
export const COMPOSE_NAMES = ['compose.yaml', 'compose.yml', 'docker-compose.yaml', 'docker-compose.yml'];
|
|
41
42
|
const CADDYFILE = /(?:^|\/)(?:Caddyfile|[\w.-]+\.caddyfile)$/i;
|
|
@@ -89,8 +90,12 @@ const targetPort = (p) => {
|
|
|
89
90
|
/** The compose files: the config's, else the first compose name in each folder */
|
|
90
91
|
function composeFiles(ctx, options, problems) {
|
|
91
92
|
if (Array.isArray(options.files)) {
|
|
92
|
-
const named = options.files.filter((f) =>
|
|
93
|
-
|
|
93
|
+
const named = eachPlaceOnce(options.files).filter((f) => {
|
|
94
|
+
const bad = fileOptionProblem(ctx, 'compose', 'files', f);
|
|
95
|
+
if (bad) problems.push(bad);
|
|
96
|
+
return !bad;
|
|
97
|
+
});
|
|
98
|
+
for (const f of named) if (!ctx.exists(f)) throw new Error(`compose file ${quote(f)} does not exist.`);
|
|
94
99
|
return named;
|
|
95
100
|
}
|
|
96
101
|
const found = ctx.walk('', (f) => COMPOSE_NAMES.includes(f.slice(f.lastIndexOf('/') + 1)));
|
|
@@ -170,11 +175,12 @@ const compose = {
|
|
|
170
175
|
for (const r of traefikRoutes(svc.name, svc.labels, svc.firstPort)) routes.push({ ...r, stack: s, from: s.file });
|
|
171
176
|
}
|
|
172
177
|
}
|
|
173
|
-
const caddyfiles = Array.isArray(options.caddyfiles) ? options.caddyfiles : ctx.walk('', (f) => CADDYFILE.test(f));
|
|
178
|
+
const caddyfiles = Array.isArray(options.caddyfiles) ? eachPlaceOnce(options.caddyfiles) : ctx.walk('', (f) => CADDYFILE.test(f));
|
|
174
179
|
const outside = new Set();
|
|
175
180
|
for (const file of caddyfiles) {
|
|
176
|
-
|
|
177
|
-
if (
|
|
181
|
+
const bad = fileOptionProblem(ctx, 'compose', 'caddyfiles', file);
|
|
182
|
+
if (bad) { problems.push(bad); continue; }
|
|
183
|
+
if (!ctx.exists(file)) { warnings.push(`compose: caddyfile ${quote(file)} does not exist.`); continue; }
|
|
178
184
|
const here = dirOf(file);
|
|
179
185
|
for (const r of caddyRoutes(ctx.read(file))) {
|
|
180
186
|
const serving = stacks.filter((s) => s.services.some((x) => x.name === r.service || x.containerName === r.service));
|
package/plugins/docs/site.js
CHANGED
|
@@ -19,7 +19,7 @@ import { deriveTopology } from '../../core/derive.js';
|
|
|
19
19
|
import { readTopology } from '../../core/validate.js';
|
|
20
20
|
import { renderMarkdown, safeUrl } from './markdown.js';
|
|
21
21
|
import docsDeriver, { resolveLink, SITE_OUTPUTS } from './index.js';
|
|
22
|
-
import { repoReader } from '../../core/repo.js';
|
|
22
|
+
import { outsideError, repoReader } from '../../core/repo.js';
|
|
23
23
|
|
|
24
24
|
/** The file a built site holds, so a rebuild knows the folder is its own */
|
|
25
25
|
export const SITE_MARKER = SITE_OUTPUTS[2];
|
|
@@ -223,7 +223,7 @@ export async function buildSite({ config, derivers, out, sourceUrl = sourceUrlOf
|
|
|
223
223
|
// What the site reads is the repo's: a path that leads out of it, by `..` or a symlink, is as if it were not there
|
|
224
224
|
const io = repoReader(root);
|
|
225
225
|
const read = (rel) => {
|
|
226
|
-
if (!io.inside(rel)) throw
|
|
226
|
+
if (!io.inside(rel)) throw outsideError(rel);
|
|
227
227
|
return fs.readFileSync(path.join(root, rel), 'utf8');
|
|
228
228
|
};
|
|
229
229
|
const exists = (rel) => io.inside(rel) && io.exists(rel);
|
package/plugins/openapi/index.js
CHANGED
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
* hand-written page under that app is removed. YAML needs the optional dependency js-yaml.
|
|
26
26
|
*/
|
|
27
27
|
|
|
28
|
-
import {
|
|
28
|
+
import { fileOptionProblem } from '../../core/repo.js';
|
|
29
|
+
import { quote } from '../../core/text.js';
|
|
29
30
|
|
|
30
31
|
const SPEC_FILE = /(?:^|\/)(?:openapi|swagger|[\w.-]+\.openapi|opencollection)\.(?:json|ya?ml)$/i;
|
|
31
32
|
const METHOD_ORDER = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS', 'TRACE'];
|
|
@@ -130,9 +131,13 @@ export function specKind(doc) {
|
|
|
130
131
|
|
|
131
132
|
/** The specs to read: `[{ file, app, prefix }]` */
|
|
132
133
|
function specsOf(ctx, options, warnings, problems) {
|
|
133
|
-
const inRepo = (
|
|
134
|
-
|
|
135
|
-
|
|
134
|
+
const inRepo = (option) => (s) => {
|
|
135
|
+
const bad = fileOptionProblem(ctx, 'openapi', option, s.file);
|
|
136
|
+
if (bad) problems.push(bad);
|
|
137
|
+
return !bad;
|
|
138
|
+
};
|
|
139
|
+
if (Array.isArray(options.specs)) return options.specs.map((s) => ({ app: DEFAULT_APP, ...s })).filter(inRepo('specs[].file'));
|
|
140
|
+
if (typeof options.file === 'string') return [{ file: options.file, app: options.app || DEFAULT_APP, prefix: options.prefix }].filter(inRepo('file'));
|
|
136
141
|
const found = ctx.walk('', (f) => SPEC_FILE.test(f));
|
|
137
142
|
if (found.length > 1) {
|
|
138
143
|
warnings.push(`openapi: ${found.length} API description files (${found.join(', ')}); name the ones to draw: { use: 'openapi', options: { specs: [{ file, app }] } }.`);
|
|
@@ -157,7 +162,7 @@ const openapi = {
|
|
|
157
162
|
const mapNodes = (ctx.map && ctx.map.nodes) || [];
|
|
158
163
|
let yaml;
|
|
159
164
|
for (const spec of specs) {
|
|
160
|
-
if (!spec.file || !ctx.exists(spec.file)) throw new Error(`API description ${spec.file} does not exist.`);
|
|
165
|
+
if (!spec.file || !ctx.exists(spec.file)) throw new Error(`API description ${quote(spec.file)} does not exist.`);
|
|
161
166
|
const text = ctx.read(spec.file);
|
|
162
167
|
let doc;
|
|
163
168
|
if (/\.json$/i.test(spec.file)) {
|
package/plugins/starter/index.js
CHANGED
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
*/
|
|
36
36
|
|
|
37
37
|
import { LANGUAGES, TEST_FILES, docSummary, expandMembers, goImports, goManifest, goWorkDirs, manifestLanguage, pyName, pythonImports, pythonManifest, rustManifest, rustName, rustUses } from './languages.js';
|
|
38
|
-
import { leavesRepo, outsideProblem } from '../../core/repo.js';
|
|
38
|
+
import { eachPlaceOnce, leavesRepo, outsideProblem } from '../../core/repo.js';
|
|
39
39
|
|
|
40
40
|
const DEFAULT_EXTENSIONS = LANGUAGES.js.extensions;
|
|
41
41
|
const TEST_DIRS = new Set(['test', 'tests', '__tests__', '__fixtures__', 'fixtures']);
|
|
@@ -97,7 +97,7 @@ function expandPatterns(patterns, io) {
|
|
|
97
97
|
for (const name of io.list(base)) if (!name.startsWith('.') && io.isDir(`${base}/${name}`)) dirs.push(`${base}/${name}`);
|
|
98
98
|
} else if (io.isDir(p)) dirs.push(p);
|
|
99
99
|
}
|
|
100
|
-
return
|
|
100
|
+
return eachPlaceOnce(dirs).sort(); // one place once, however it is spelled (`''` and `.` are the repo itself)
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
const readJson = (io, rel) => {
|
package/plugins/world/index.js
CHANGED
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
*/
|
|
34
34
|
|
|
35
35
|
import { slug } from '../compose/index.js';
|
|
36
|
-
import {
|
|
36
|
+
import { fileOptionProblem } from '../../core/repo.js';
|
|
37
37
|
|
|
38
38
|
export const WORLD_FILE = 'stacks/world.json';
|
|
39
39
|
const FILE_KEYS = ['version', 'hosts', 'runs'];
|
|
@@ -64,7 +64,8 @@ const world = {
|
|
|
64
64
|
const options = ctx.options || {};
|
|
65
65
|
const file = options.file || WORLD_FILE;
|
|
66
66
|
const parent = options.parent || 'root';
|
|
67
|
-
|
|
67
|
+
const refused = fileOptionProblem(ctx, 'world', 'file', file);
|
|
68
|
+
if (refused) return { nodes: [], edges: [], warnings: [], problems: [refused], info: { machines: [] } };
|
|
68
69
|
if (!ctx.exists(file)) return { nodes: [], edges: [], warnings: [], problems: [], info: { machines: [] } };
|
|
69
70
|
|
|
70
71
|
let doc;
|