cornfield 0.25.0 → 0.27.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/core/color.js +177 -0
- package/core/config.js +2 -2
- package/core/contrast.js +600 -0
- package/core/theme.js +88 -5
- package/core/validate.js +9 -3
- package/explorer/explorer.css +15 -11
- package/explorer/labels.js +13 -6
- package/explorer/main.js +4 -1
- package/explorer/map-style.js +428 -0
- package/explorer/proposal.js +4 -1
- package/explorer/renderer-canvas2d.js +26 -5
- package/explorer/renderer-webgl.js +182 -38
- package/explorer/scene.js +13 -2
- package/explorer/shaders.js +27 -0
- package/explorer/theme-model.js +6 -23
- package/explorer/theme.js +4 -1
- package/explorer/tokens.css +85 -9
- package/package.json +1 -1
- package/server/server.js +1 -1
|
@@ -25,8 +25,9 @@
|
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
27
|
import { ARROW, CORE_RATIO, EDGE_STRIKE, MARK_MIN_PX, edgePoint, looksFor, parseColor } from './scene.js';
|
|
28
|
+
import { ICON_RATIO, getMapStyle, looksWith, styledScene } from './map-style.js';
|
|
28
29
|
import {
|
|
29
|
-
CURVE_SEGMENTS, EDGE_FRAG, GRID_FRAG, GRID_VERT, LANE_FRAG, LANE_VERT, NODE_FRAG, NODE_VERT, PACKET_FRAG, PACKET_VERT,
|
|
30
|
+
CURVE_SEGMENTS, EDGE_FRAG, GRID_FRAG, GRID_VERT, ICON_FRAG, ICON_VERT, LANE_FRAG, LANE_VERT, NODE_FRAG, NODE_VERT, PACKET_FRAG, PACKET_VERT,
|
|
30
31
|
RING_FRAG, RING_VERT, TIP_FRAG, TIP_VERT, edgeVert,
|
|
31
32
|
} from './shaders.js';
|
|
32
33
|
|
|
@@ -45,6 +46,8 @@ export const GRID_STRIDE = 8;
|
|
|
45
46
|
|
|
46
47
|
/** Floats per edge: x1, y1, x2, y2 | control x, y, width, glow blur | rgba | glow rgb, glow strength | dash on, off | marked (0 or 1) */
|
|
47
48
|
export const EDGE_STRIDE = 19;
|
|
49
|
+
/** Floats per icon: x, y, side, alpha */
|
|
50
|
+
export const ICON_STRIDE = 4;
|
|
48
51
|
/** Floats per tip: x, y, direction x, y | rgba | kind (TIP_CODE) */
|
|
49
52
|
export const TIP_STRIDE = 9;
|
|
50
53
|
/** Floats per packet: x1, y1, x2, y2 | control x, y, speed, phase | rgba | glow rgb, glow strength | radius, glow blur */
|
|
@@ -173,13 +176,55 @@ export function packEdges(scene) {
|
|
|
173
176
|
/** Everything the GPU needs from a scene */
|
|
174
177
|
export const packScene = (scene) => ({ ...packDecor(scene), nodes: packNodes(scene), ...packEdges(scene) });
|
|
175
178
|
|
|
179
|
+
/**
|
|
180
|
+
* The outlines the theme gives nodes (--corn-map-stroke), as rows of the rings pass (the same shader, drawn over the nodes): a ring
|
|
181
|
+
* just inside the circle's edge, in the node's alpha. Empty for a scene whose nodes have none.
|
|
182
|
+
* @param {import('./scene.js').Scene} scene a scene through `styledScene`
|
|
183
|
+
*/
|
|
184
|
+
export function packStrokes(scene) {
|
|
185
|
+
const rows = [];
|
|
186
|
+
scene.nodes.forEach((n) => {
|
|
187
|
+
if (!n.stroke) return;
|
|
188
|
+
const [r, g, b, a] = rgba(n.stroke.color);
|
|
189
|
+
rows.push([n.x, n.y, Math.max(0, n.r - n.stroke.width / 2), n.stroke.width, r, g, b, a * n.alpha, 0, 0]);
|
|
190
|
+
});
|
|
191
|
+
const data = new Float32Array(rows.length * RING_STRIDE);
|
|
192
|
+
rows.forEach((row, i) => data.set(row, i * RING_STRIDE));
|
|
193
|
+
return { data, count: rows.length, stride: RING_STRIDE };
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* The icons of the nodes that have one, grouped by kind (one texture, one draw each), in scene order within a kind.
|
|
198
|
+
* @param {import('./scene.js').Scene} scene a scene through `styledScene`
|
|
199
|
+
* @param {(kind: string) => boolean} has whether the kind's image has loaded
|
|
200
|
+
* @returns {{data: Float32Array, count: number, stride: number, groups: {kind: string, first: number, count: number}[]}}
|
|
201
|
+
*/
|
|
202
|
+
export function packIcons(scene, has) {
|
|
203
|
+
const byKind = new Map();
|
|
204
|
+
scene.nodes.forEach((n) => {
|
|
205
|
+
if (!n.icon || !has(n.icon)) return;
|
|
206
|
+
if (!byKind.has(n.icon)) byKind.set(n.icon, []);
|
|
207
|
+
byKind.get(n.icon).push([n.x, n.y, n.r * ICON_RATIO, n.alpha]);
|
|
208
|
+
});
|
|
209
|
+
const groups = [];
|
|
210
|
+
const rows = [];
|
|
211
|
+
for (const [kind, list] of byKind) {
|
|
212
|
+
groups.push({ kind, first: rows.length, count: list.length });
|
|
213
|
+
rows.push(...list);
|
|
214
|
+
}
|
|
215
|
+
const data = new Float32Array(rows.length * ICON_STRIDE);
|
|
216
|
+
rows.forEach((row, i) => data.set(row, i * ICON_STRIDE));
|
|
217
|
+
return { data, count: rows.length, stride: ICON_STRIDE, groups };
|
|
218
|
+
}
|
|
219
|
+
|
|
176
220
|
/**
|
|
177
221
|
* The looks of scene.js (halo, mark, core) as flat float arrays for uniforms, indexed by the codes
|
|
178
222
|
* above, so the shaders hold no colour of their own and cannot drift from the Canvas 2D renderer.
|
|
179
|
-
* `theme` picks `looksFor(theme)`: the renderer sets them again when a scene's theme differs from the last.
|
|
223
|
+
* `theme` picks `looksFor(theme)`: the renderer sets them again when a scene's theme differs from the last. `style` (map-style.js)
|
|
224
|
+
* puts the theme's colours for the halos and the diff marks over them.
|
|
180
225
|
*/
|
|
181
|
-
export function styleTables(theme = 'dark') {
|
|
182
|
-
const { halo: HALO, mark: MARK, core: CORE_COLOR } = looksFor(theme);
|
|
226
|
+
export function styleTables(theme = 'dark', style = null) {
|
|
227
|
+
const { halo: HALO, mark: MARK, core: CORE_COLOR } = style ? looksWith(looksFor(theme), style) : looksFor(theme);
|
|
183
228
|
const haloFill = new Float32Array(16);
|
|
184
229
|
const haloRing = new Float32Array(16);
|
|
185
230
|
const haloGeom = new Float32Array(16);
|
|
@@ -287,52 +332,69 @@ function link(gl, vertSource, fragSource, label) {
|
|
|
287
332
|
}
|
|
288
333
|
|
|
289
334
|
/** Sets the one-time uniforms of every pass that has them, for `theme`'s looks */
|
|
290
|
-
|
|
291
|
-
|
|
335
|
+
/** What of a style the constants depend on: 0 for the plain one, else its version */
|
|
336
|
+
const styleKey = (style) => (!style || style.plain ? 0 : style.version);
|
|
337
|
+
|
|
338
|
+
function setConstants(gl, gpu, theme, style = null) {
|
|
339
|
+
const tables = styleTables(theme, style);
|
|
292
340
|
gpu.passes.forEach((pass) => {
|
|
293
341
|
if (!pass.spec.constants) return;
|
|
294
342
|
gl.useProgram(pass.program);
|
|
295
343
|
CONSTANTS[pass.spec.constants](gl, pass.at, tables);
|
|
296
344
|
});
|
|
297
345
|
gpu.theme = theme;
|
|
346
|
+
gpu.styleKey = styleKey(style);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/** One pass's program, vertex array and buffer (a unit quad per instance, unless the spec has `verts`) */
|
|
350
|
+
function makePass(gl, spec, corners) {
|
|
351
|
+
const program = link(gl, spec.vert, spec.frag, spec.name);
|
|
352
|
+
const vao = gl.createVertexArray();
|
|
353
|
+
const buffer = gl.createBuffer();
|
|
354
|
+
gl.bindVertexArray(vao);
|
|
355
|
+
if (!spec.verts) {
|
|
356
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, corners);
|
|
357
|
+
gl.enableVertexAttribArray(0);
|
|
358
|
+
gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0);
|
|
359
|
+
gl.vertexAttribDivisor(0, 0);
|
|
360
|
+
}
|
|
361
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
362
|
+
spec.attribs.forEach(([location, size, offset]) => {
|
|
363
|
+
gl.enableVertexAttribArray(location);
|
|
364
|
+
gl.vertexAttribPointer(location, size, gl.FLOAT, false, spec.stride * 4, offset * 4);
|
|
365
|
+
gl.vertexAttribDivisor(location, 1);
|
|
366
|
+
});
|
|
367
|
+
gl.bindVertexArray(null);
|
|
368
|
+
|
|
369
|
+
const at = (name) => gl.getUniformLocation(program, name);
|
|
370
|
+
return { spec, program, vao, buffer, at, count: 0, uniforms: { viewport: at('u_viewport'), cam: at('u_cam'), dpr: at('u_dpr'), time: spec.time ? at('u_time') : null } };
|
|
298
371
|
}
|
|
299
372
|
|
|
373
|
+
/**
|
|
374
|
+
* The passes only a theme asks for, built the first time one is needed so a map with no theme costs nothing: the node outlines (the rings
|
|
375
|
+
* shader, drawn over the nodes) and the icons (a textured square per node), after the nodes, in this order.
|
|
376
|
+
*/
|
|
377
|
+
export const EXTRA_PASSES = {
|
|
378
|
+
strokes: { name: 'strokes', vert: RING_VERT, frag: RING_FRAG, stride: RING_STRIDE, attribs: [[1, 4, 0], [2, 4, 4], [3, 2, 8]] },
|
|
379
|
+
icons: { name: 'icons', vert: ICON_VERT, frag: ICON_FRAG, stride: ICON_STRIDE, attribs: [[1, 4, 0]] },
|
|
380
|
+
};
|
|
381
|
+
|
|
300
382
|
/** Programs, vertex arrays and buffers for every pass, on this context, with `theme`'s looks. Throws when a shader fails. */
|
|
301
|
-
function buildGpu(gl, theme = 'dark') {
|
|
383
|
+
function buildGpu(gl, theme = 'dark', style = null) {
|
|
302
384
|
const corners = gl.createBuffer();
|
|
303
385
|
gl.bindBuffer(gl.ARRAY_BUFFER, corners);
|
|
304
386
|
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]), gl.STATIC_DRAW);
|
|
305
387
|
|
|
306
|
-
const passes = PASSES.map((spec) =>
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
const buffer = gl.createBuffer();
|
|
310
|
-
gl.bindVertexArray(vao);
|
|
311
|
-
if (!spec.verts) {
|
|
312
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, corners);
|
|
313
|
-
gl.enableVertexAttribArray(0);
|
|
314
|
-
gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0);
|
|
315
|
-
gl.vertexAttribDivisor(0, 0);
|
|
316
|
-
}
|
|
317
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
318
|
-
spec.attribs.forEach(([location, size, offset]) => {
|
|
319
|
-
gl.enableVertexAttribArray(location);
|
|
320
|
-
gl.vertexAttribPointer(location, size, gl.FLOAT, false, spec.stride * 4, offset * 4);
|
|
321
|
-
gl.vertexAttribDivisor(location, 1);
|
|
322
|
-
});
|
|
323
|
-
gl.bindVertexArray(null);
|
|
324
|
-
|
|
325
|
-
const at = (name) => gl.getUniformLocation(program, name);
|
|
326
|
-
return { spec, program, vao, buffer, at, count: 0, uniforms: { viewport: at('u_viewport'), cam: at('u_cam'), dpr: at('u_dpr'), time: spec.time ? at('u_time') : null } };
|
|
327
|
-
});
|
|
328
|
-
const gpu = { corners, passes, theme };
|
|
329
|
-
setConstants(gl, gpu, theme);
|
|
388
|
+
const passes = PASSES.map((spec) => makePass(gl, spec, corners));
|
|
389
|
+
const gpu = { corners, passes, theme, styleKey: 0, extras: { strokes: null, icons: null }, textures: new Map(), iconStore: null };
|
|
390
|
+
setConstants(gl, gpu, theme, style);
|
|
330
391
|
return gpu;
|
|
331
392
|
}
|
|
332
393
|
|
|
333
394
|
function destroyGpu(gl, gpu) {
|
|
334
395
|
gl.deleteBuffer(gpu.corners);
|
|
335
|
-
gpu.
|
|
396
|
+
gpu.textures.forEach(({ texture }) => gl.deleteTexture(texture));
|
|
397
|
+
[...gpu.passes, ...Object.values(gpu.extras).filter(Boolean)].forEach((p) => {
|
|
336
398
|
gl.deleteProgram(p.program);
|
|
337
399
|
gl.deleteVertexArray(p.vao);
|
|
338
400
|
gl.deleteBuffer(p.buffer);
|
|
@@ -345,7 +407,8 @@ function destroyGpu(gl, gpu) {
|
|
|
345
407
|
|
|
346
408
|
/**
|
|
347
409
|
* @param {HTMLCanvasElement} canvas the canvas to draw on (it must not have given a 2d context)
|
|
348
|
-
* @param {{gl?: WebGL2RenderingContext}} [opts] `gl`: a context already taken from the canvas
|
|
410
|
+
* @param {{gl?: WebGL2RenderingContext, mapStyle?: () => import('./map-style.js').MapStyle}} [opts] `gl`: a context already taken from the canvas.
|
|
411
|
+
* `mapStyle`: where the theme's map tokens and icons come from (default: the page's, map-style.js `getMapStyle`)
|
|
349
412
|
* @returns {import('./scene.js').Renderer & {stats: {uploads: number, draws: number}}}
|
|
350
413
|
* @throws {Error} when there is no WebGL2 context or a shader fails to compile or link
|
|
351
414
|
*/
|
|
@@ -353,6 +416,7 @@ export function createWebglRenderer(canvas, opts = {}) {
|
|
|
353
416
|
const gl = opts.gl || canvas.getContext('webgl2', CONTEXT_ATTRS);
|
|
354
417
|
if (!gl) throw new Error('WebGL2 is not available');
|
|
355
418
|
|
|
419
|
+
const styleOf = opts.mapStyle || getMapStyle;
|
|
356
420
|
const stats = { uploads: 0, draws: 0 };
|
|
357
421
|
let gpu = buildGpu(gl);
|
|
358
422
|
let lost = false;
|
|
@@ -363,6 +427,12 @@ export function createWebglRenderer(canvas, opts = {}) {
|
|
|
363
427
|
let packedVersion;
|
|
364
428
|
let lastArgs = null;
|
|
365
429
|
|
|
430
|
+
/** A pass only a theme asks for (EXTRA_PASSES), built the first time it is wanted */
|
|
431
|
+
function extra(name) {
|
|
432
|
+
if (!gpu.extras[name]) gpu.extras[name] = makePass(gl, EXTRA_PASSES[name], gpu.corners);
|
|
433
|
+
return gpu.extras[name];
|
|
434
|
+
}
|
|
435
|
+
|
|
366
436
|
/** Copies the packed arrays into the GPU buffers (only when the scene changed, or after a restore) */
|
|
367
437
|
function upload() {
|
|
368
438
|
gpu.passes.forEach((pass) => {
|
|
@@ -372,20 +442,63 @@ export function createWebglRenderer(canvas, opts = {}) {
|
|
|
372
442
|
gl.bindBuffer(gl.ARRAY_BUFFER, pass.buffer);
|
|
373
443
|
gl.bufferData(gl.ARRAY_BUFFER, rows.data, gl.DYNAMIC_DRAW);
|
|
374
444
|
});
|
|
445
|
+
for (const name of Object.keys(EXTRA_PASSES)) {
|
|
446
|
+
const rows = packed[name];
|
|
447
|
+
if (!rows.count && !gpu.extras[name]) continue;
|
|
448
|
+
const pass = extra(name);
|
|
449
|
+
pass.count = rows.count;
|
|
450
|
+
if (!rows.count) continue;
|
|
451
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, pass.buffer);
|
|
452
|
+
gl.bufferData(gl.ARRAY_BUFFER, rows.data, gl.DYNAMIC_DRAW);
|
|
453
|
+
}
|
|
375
454
|
stats.uploads++;
|
|
376
455
|
}
|
|
377
456
|
|
|
378
|
-
|
|
379
|
-
|
|
457
|
+
/** Nearest-neighbour sampling when the theme is pixelated (theme.pixelated), else smooth with mipmaps */
|
|
458
|
+
function sample(texture, pixelated) {
|
|
459
|
+
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
460
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, pixelated ? gl.NEAREST : gl.LINEAR_MIPMAP_LINEAR);
|
|
461
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, pixelated ? gl.NEAREST : gl.LINEAR);
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
/** The texture of a kind's icon: made when the image is first drawn, sampled as the style says */
|
|
465
|
+
function textureOf(kind, image, pixelated) {
|
|
466
|
+
let entry = gpu.textures.get(kind);
|
|
467
|
+
if (!entry || entry.image !== image) {
|
|
468
|
+
if (entry) gl.deleteTexture(entry.texture);
|
|
469
|
+
const texture = gl.createTexture();
|
|
470
|
+
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
471
|
+
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true); // the context blends premultiplied
|
|
472
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
|
|
473
|
+
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
|
|
474
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
475
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
476
|
+
gl.generateMipmap(gl.TEXTURE_2D);
|
|
477
|
+
entry = { image, texture, pixelated: null };
|
|
478
|
+
gpu.textures.set(kind, entry);
|
|
479
|
+
}
|
|
480
|
+
if (entry.pixelated !== pixelated) { sample(entry.texture, pixelated); entry.pixelated = pixelated; }
|
|
481
|
+
return entry.texture;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
function draw(drawn, camera, timeMs) {
|
|
485
|
+
lastArgs = [drawn, camera, timeMs];
|
|
380
486
|
if (lost || !gpu || !width || !height) return;
|
|
487
|
+
const style = styleOf();
|
|
488
|
+
const scene = styledScene(drawn, style); // the map in the theme's colours, outlines and icons (map-style.js); the scene itself when nothing is set
|
|
489
|
+
if (gpu.iconStore !== style.icons) { // a new set of icons (or none): the old ones' textures go now, not when the renderer does
|
|
490
|
+
gpu.textures.forEach(({ texture }) => gl.deleteTexture(texture));
|
|
491
|
+
gpu.textures.clear();
|
|
492
|
+
gpu.iconStore = style.icons;
|
|
493
|
+
}
|
|
381
494
|
if (scene !== packedScene || scene.version !== packedVersion) {
|
|
382
|
-
packed = packScene(scene);
|
|
495
|
+
packed = { ...packScene(scene), strokes: packStrokes(scene), icons: packIcons(scene, (kind) => !!(style.icons && style.icons.get(kind))) };
|
|
383
496
|
packedScene = scene;
|
|
384
497
|
packedVersion = scene.version;
|
|
385
498
|
upload();
|
|
386
499
|
}
|
|
387
500
|
const theme = scene.theme || 'dark';
|
|
388
|
-
if (gpu.theme !== theme) setConstants(gl, gpu, theme); // the halos, mark rings and core of the other ground
|
|
501
|
+
if (gpu.theme !== theme || gpu.styleKey !== styleKey(style)) setConstants(gl, gpu, theme, style); // the halos, mark rings and core of the other ground, in the theme's colours
|
|
389
502
|
|
|
390
503
|
gl.viewport(0, 0, canvas.width, canvas.height);
|
|
391
504
|
gl.clearColor(0, 0, 0, 0);
|
|
@@ -403,6 +516,37 @@ export function createWebglRenderer(canvas, opts = {}) {
|
|
|
403
516
|
gl.drawArraysInstanced(gl.TRIANGLE_STRIP, 0, pass.spec.verts || 4, pass.count);
|
|
404
517
|
stats.draws++;
|
|
405
518
|
});
|
|
519
|
+
|
|
520
|
+
// Over the nodes, only when the theme gave some an outline or an icon
|
|
521
|
+
const strokes = gpu.extras.strokes;
|
|
522
|
+
if (strokes && strokes.count) {
|
|
523
|
+
gl.useProgram(strokes.program);
|
|
524
|
+
gl.uniform2f(strokes.uniforms.viewport, width, height);
|
|
525
|
+
gl.uniform3f(strokes.uniforms.cam, camera.x, camera.y, camera.zoom);
|
|
526
|
+
gl.uniform1f(strokes.uniforms.dpr, canvas.width / width);
|
|
527
|
+
gl.bindVertexArray(strokes.vao);
|
|
528
|
+
gl.drawArraysInstanced(gl.TRIANGLE_STRIP, 0, 4, strokes.count);
|
|
529
|
+
stats.draws++;
|
|
530
|
+
}
|
|
531
|
+
const icons = gpu.extras.icons;
|
|
532
|
+
if (icons && icons.count) {
|
|
533
|
+
gl.useProgram(icons.program);
|
|
534
|
+
gl.uniform2f(icons.uniforms.viewport, width, height);
|
|
535
|
+
gl.uniform3f(icons.uniforms.cam, camera.x, camera.y, camera.zoom);
|
|
536
|
+
gl.uniform1f(icons.uniforms.dpr, canvas.width / width);
|
|
537
|
+
gl.uniform1i(icons.at('u_tex'), 0);
|
|
538
|
+
gl.activeTexture(gl.TEXTURE0);
|
|
539
|
+
gl.bindVertexArray(icons.vao);
|
|
540
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, icons.buffer);
|
|
541
|
+
for (const group of packed.icons.groups) {
|
|
542
|
+
const image = style.icons && style.icons.get(group.kind);
|
|
543
|
+
if (!image) continue;
|
|
544
|
+
gl.bindTexture(gl.TEXTURE_2D, textureOf(group.kind, image, !!style.pixelated));
|
|
545
|
+
gl.vertexAttribPointer(1, 4, gl.FLOAT, false, ICON_STRIDE * 4, group.first * ICON_STRIDE * 4); // this kind's rows
|
|
546
|
+
gl.drawArraysInstanced(gl.TRIANGLE_STRIP, 0, 4, group.count);
|
|
547
|
+
stats.draws++;
|
|
548
|
+
}
|
|
549
|
+
}
|
|
406
550
|
gl.bindVertexArray(null);
|
|
407
551
|
}
|
|
408
552
|
|
|
@@ -413,7 +557,7 @@ export function createWebglRenderer(canvas, opts = {}) {
|
|
|
413
557
|
};
|
|
414
558
|
const onRestored = () => {
|
|
415
559
|
try {
|
|
416
|
-
gpu = buildGpu(gl, lastArgs ? lastArgs[0].theme || 'dark' : 'dark');
|
|
560
|
+
gpu = buildGpu(gl, lastArgs ? lastArgs[0].theme || 'dark' : 'dark', styleOf());
|
|
417
561
|
lost = false;
|
|
418
562
|
if (packed) upload();
|
|
419
563
|
if (lastArgs) draw(...lastArgs);
|
package/explorer/scene.js
CHANGED
|
@@ -44,7 +44,8 @@
|
|
|
44
44
|
*
|
|
45
45
|
* @typedef {object} SceneNode One visible node, in draw order (later is on top)
|
|
46
46
|
* @property {string} id topology id
|
|
47
|
-
* @property {string} type topology type (`app`, `page`, `table`, ...)
|
|
47
|
+
* @property {string} type topology type (`app`, `page`, `table`, ...): the node's kind for the map tokens (map-style.js)
|
|
48
|
+
* @property {string} group the node's layer in the Layers menu (`app`, `cloud`, `web`, `house`, ...): the node's group for the map tokens
|
|
48
49
|
* @property {number} x world centre
|
|
49
50
|
* @property {number} y
|
|
50
51
|
* @property {number} r world radius of the filled circle
|
|
@@ -135,7 +136,9 @@
|
|
|
135
136
|
* @typedef {object} Scene
|
|
136
137
|
* @property {SceneNode[]} nodes
|
|
137
138
|
* @property {SceneEdge[]} edges
|
|
139
|
+
* @property {{nodes: Set<string>, edges: Set<string>}} painted the ids of the nodes and the keys of the edges a painter (an outage, a check's verdict, a pull request) gave a colour of its own: map-style.js leaves those alone
|
|
138
140
|
* @property {SceneDecor} decor
|
|
141
|
+
* @property {{node: {color: string, width: number}, edge: {color: string, width: number}}} [labelOutline] the outline under the labels when the theme sets one (map-style.js, `--corn-map-label-halo`); else `looksFor(theme).labelOutline`
|
|
139
142
|
* @property {boolean} preset the data-flow view: every node is labelled and the label boost differs (see `labelAt`)
|
|
140
143
|
* @property {'dark'|'light'} theme the ground it is drawn for (`state.theme`, theme.js): every colour in it already suits it; `looksFor(theme)` has the rest
|
|
141
144
|
* @property {number} version the `state.sceneVersion` it was built from
|
|
@@ -537,6 +540,9 @@ function buildEdges(state, subgraph, reduceMotion) {
|
|
|
537
540
|
// ---------------------------------------------------------------------------
|
|
538
541
|
// Nodes
|
|
539
542
|
// ---------------------------------------------------------------------------
|
|
543
|
+
/** A node's group: its layer in the Layers menu (layers.js), one per kind but for the rooms and floors (House) and the outside nodes (Cloud, or the Public web) */
|
|
544
|
+
const groupOf = (node) => (node.type === 'floor' || node.type === 'room' ? 'house' : node.type === 'external' ? externalLayer(node) : node.type);
|
|
545
|
+
|
|
540
546
|
function buildNodes(state, subgraph) {
|
|
541
547
|
const { nodes, selectedNode, searchQuery } = state;
|
|
542
548
|
const query = searchQuery.toLowerCase();
|
|
@@ -562,7 +568,7 @@ function buildNodes(state, subgraph) {
|
|
|
562
568
|
const big = shown.type === 'root' || shown.type === 'app';
|
|
563
569
|
|
|
564
570
|
out.push({
|
|
565
|
-
id: node.id, type: shown.type,
|
|
571
|
+
id: node.id, type: shown.type, group: groupOf(shown),
|
|
566
572
|
x: node.x, y: node.y, r: shown.r, color: shown.color,
|
|
567
573
|
alpha,
|
|
568
574
|
glow: connected && alpha >= 0.5 ? (big ? 15 : 9) : 0,
|
|
@@ -694,15 +700,20 @@ export function buildScene(state, opts = {}) {
|
|
|
694
700
|
nodes: buildNodes(state, subgraph),
|
|
695
701
|
edges: buildEdges(state, subgraph, !!opts.reduceMotion),
|
|
696
702
|
decor: { grid: { size: 48, color: 'rgba(255, 255, 255, 0.035)', width: 0.5, margin: 200 }, rings, lanes },
|
|
703
|
+
painted: { nodes: new Set(), edges: new Set() },
|
|
697
704
|
preset,
|
|
698
705
|
theme: 'dark',
|
|
699
706
|
version: state.sceneVersion || 0,
|
|
700
707
|
};
|
|
701
708
|
if (state.view === 'house') decorateHouseScene(scene, state); // its bands and tray as lanes, rooms unlabelled (house-model.js)
|
|
702
709
|
if (state.scenario) emphasiseScenario(scene, state.scenario, opts);
|
|
710
|
+
const colours = { nodes: scene.nodes.map((n) => n.color), edges: scene.edges.map((e) => e.color) };
|
|
703
711
|
if (state.scenario) paintOutage(scene, outageFor(state.scenario, state.nodes, state.edges)); // CLOUD-07: red, amber, violet by when the outage bites
|
|
704
712
|
if (state.scenario) paintVerdict(scene, state.scenario); // PHY-10: red, green or amber by the step's permission check
|
|
705
713
|
if (state.forgeLit) paintForge(scene, state.forgeLit); // CF-07: the selected pull request's nodes, the rest faded
|
|
714
|
+
// The nodes and edges a painter above gave a colour: the map's own styling (map-style.js) leaves them to it
|
|
715
|
+
scene.nodes.forEach((n, i) => { if (colours.nodes.length === scene.nodes.length && n.color !== colours.nodes[i]) scene.painted.nodes.add(n.id); });
|
|
716
|
+
scene.edges.forEach((e, i) => { if (colours.edges.length === scene.edges.length && e.color !== colours.edges[i]) scene.painted.edges.add(e.key); });
|
|
706
717
|
if (state.theme === 'light') lightenScene(scene); // MAP-01: last, so what every painter above set is themed with the rest (theme-model.js)
|
|
707
718
|
return scene;
|
|
708
719
|
}
|
package/explorer/shaders.js
CHANGED
|
@@ -533,3 +533,30 @@ void main() {
|
|
|
533
533
|
outColor = acc;
|
|
534
534
|
}
|
|
535
535
|
`;
|
|
536
|
+
|
|
537
|
+
// ---------------------------------------------------------------------------
|
|
538
|
+
// Icons: one textured square per node that has the theme's icon for its kind (theme.icons), drawn over the nodes
|
|
539
|
+
// ---------------------------------------------------------------------------
|
|
540
|
+
export const ICON_VERT = `${HEAD}${TO_CLIP}
|
|
541
|
+
layout(location = 0) in vec2 a_corner;
|
|
542
|
+
layout(location = 1) in vec4 a_geom; // x, y, side (world), alpha
|
|
543
|
+
out vec2 v_uv;
|
|
544
|
+
flat out float v_alpha;
|
|
545
|
+
void main() {
|
|
546
|
+
vec2 centre = u_cam.xy + a_geom.xy * u_cam.z;
|
|
547
|
+
vec2 pos = centre + a_corner * (a_geom.z * 0.5 * u_cam.z);
|
|
548
|
+
v_uv = vec2(a_corner.x * 0.5 + 0.5, 0.5 - a_corner.y * 0.5);
|
|
549
|
+
v_alpha = a_geom.w;
|
|
550
|
+
gl_Position = toClip(pos);
|
|
551
|
+
}
|
|
552
|
+
`;
|
|
553
|
+
|
|
554
|
+
export const ICON_FRAG = `${HEAD}
|
|
555
|
+
uniform sampler2D u_tex;
|
|
556
|
+
in vec2 v_uv;
|
|
557
|
+
flat in float v_alpha;
|
|
558
|
+
out vec4 outColor;
|
|
559
|
+
void main() {
|
|
560
|
+
outColor = texture(u_tex, v_uv) * v_alpha; // the texture is uploaded premultiplied
|
|
561
|
+
}
|
|
562
|
+
`;
|
package/explorer/theme-model.js
CHANGED
|
@@ -23,10 +23,12 @@
|
|
|
23
23
|
* lightColor(css, role) one colour for the light ground (memoised)
|
|
24
24
|
* themed(css, theme, role) the same, or the colour untouched in the dark theme
|
|
25
25
|
* lightenScene(scene) every colour of a built scene, in place (scene.js calls it)
|
|
26
|
-
* contrast(a, b) the WCAG contrast ratio of two CSS colours
|
|
26
|
+
* contrast(a, b) the WCAG contrast ratio of two CSS colours (core/color.js)
|
|
27
27
|
* parseColor(css) a CSS colour as [r, g, b, a] (scene.js re-exports it for the renderers)
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
|
+
import { parseColor, luminance, ratio, contrast } from '../core/color.js';
|
|
31
|
+
|
|
30
32
|
export const THEME_CHOICES = ['system', 'light', 'dark'];
|
|
31
33
|
/** Where the choice is kept in the browser (theme.js); `?theme=` in the address wins over it, without being kept */
|
|
32
34
|
export const THEME_STORAGE_KEY = 'topology-explorer:theme';
|
|
@@ -101,28 +103,9 @@ export function themeWords(choice, theme) {
|
|
|
101
103
|
// Colour arithmetic
|
|
102
104
|
// ---------------------------------------------------------------------------
|
|
103
105
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
let m = /^#([0-9a-f]{3})$/.exec(s);
|
|
108
|
-
if (m) return [...m[1]].map((h) => parseInt(h + h, 16)).concat(1);
|
|
109
|
-
m = /^#([0-9a-f]{6})$/.exec(s);
|
|
110
|
-
if (m) return [parseInt(m[1].slice(0, 2), 16), parseInt(m[1].slice(2, 4), 16), parseInt(m[1].slice(4, 6), 16), 1];
|
|
111
|
-
m = /^rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*(?:,\s*([\d.]+)\s*)?\)$/.exec(s);
|
|
112
|
-
if (m) return [Number(m[1]), Number(m[2]), Number(m[3]), m[4] === undefined ? 1 : Number(m[4])];
|
|
113
|
-
return [0, 0, 0, 0];
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const channel = (v) => {
|
|
117
|
-
const c = v / 255;
|
|
118
|
-
return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
|
|
119
|
-
};
|
|
120
|
-
/** WCAG relative luminance of `[r, g, b]` (0..255) */
|
|
121
|
-
export const luminance = ([r, g, b]) => 0.2126 * channel(r) + 0.7152 * channel(g) + 0.0722 * channel(b);
|
|
122
|
-
const ratio = (la, lb) => (Math.max(la, lb) + 0.05) / (Math.min(la, lb) + 0.05);
|
|
123
|
-
|
|
124
|
-
/** The WCAG contrast ratio of two opaque CSS colours (alpha is ignored) */
|
|
125
|
-
export const contrast = (a, b) => ratio(luminance(parseColor(a)), luminance(parseColor(b)));
|
|
106
|
+
// The colour arithmetic (parseColor, luminance, ratio, contrast) is core/color.js, shared with `cornfield validate`'s contrast check;
|
|
107
|
+
// scene.js and the tests still import it from here.
|
|
108
|
+
export { parseColor, luminance, contrast };
|
|
126
109
|
|
|
127
110
|
/** `[r, g, b]` (0..255) to `[h, s, l]` (h in degrees, s and l 0..1) */
|
|
128
111
|
export function toHsl([r, g, b]) {
|
package/explorer/theme.js
CHANGED
|
@@ -10,13 +10,15 @@
|
|
|
10
10
|
* - the theme in force is `<html data-theme="light|dark">`: explorer.css swaps its tokens on it,
|
|
11
11
|
* theme-boot.js sets it before the first paint (so a light page never flashes dark), and this module
|
|
12
12
|
* keeps it right afterwards;
|
|
13
|
-
* - the map: `state.theme`, then `touchScene()`, so the next scene is built for the new ground (scene.js)
|
|
13
|
+
* - the map: `state.theme`, then `touchScene()`, so the next scene is built for the new ground (scene.js), and the map's
|
|
14
|
+
* `--corn-map-*` tokens are read again for it (map-style.js; it also watches `data-theme-name` and `prefers-color-scheme` itself);
|
|
14
15
|
* - whatever else draws in colour from script listens with `onThemeChange` (the Layers menu's dots, the
|
|
15
16
|
* legend's mark colours).
|
|
16
17
|
*/
|
|
17
18
|
|
|
18
19
|
import { state, touchScene } from './state.js';
|
|
19
20
|
import { render } from './render.js';
|
|
21
|
+
import { refreshMapStyle } from './map-style.js';
|
|
20
22
|
import { THEME_STORAGE_KEY, nextChoice, resolveTheme, themeChoiceFrom, themeWords } from './theme-model.js';
|
|
21
23
|
|
|
22
24
|
const QUERY = '(prefers-color-scheme: light)';
|
|
@@ -63,6 +65,7 @@ function apply() {
|
|
|
63
65
|
const root = document.documentElement;
|
|
64
66
|
root.dataset.theme = theme;
|
|
65
67
|
syncButton(theme);
|
|
68
|
+
refreshMapStyle(); // the map's tokens (--corn-map-*) differ by theme: read them for this one (map-style.js)
|
|
66
69
|
if (state.theme === theme) return;
|
|
67
70
|
state.theme = theme;
|
|
68
71
|
touchScene();
|
package/explorer/tokens.css
CHANGED
|
@@ -32,14 +32,14 @@
|
|
|
32
32
|
/* Text */
|
|
33
33
|
--corn-text: #f8fafc;
|
|
34
34
|
--corn-text-2: #cbd5e1;
|
|
35
|
-
--corn-text-3: #
|
|
35
|
+
--corn-text-3: #9aa9bc;
|
|
36
36
|
--corn-text-on-accent: #fff;
|
|
37
37
|
--corn-mockup-ground: #fff;
|
|
38
38
|
|
|
39
39
|
/* Accent */
|
|
40
40
|
--corn-accent: #4f46e5;
|
|
41
|
-
--corn-accent-hover: #
|
|
42
|
-
--corn-accent-text: #
|
|
41
|
+
--corn-accent-hover: #6265f1;
|
|
42
|
+
--corn-accent-text: #98a1fa;
|
|
43
43
|
--corn-accent-soft: color-mix(in srgb, var(--corn-accent-hover) 20%, transparent);
|
|
44
44
|
--corn-focus: #818cf8;
|
|
45
45
|
--corn-brand-gradient: linear-gradient(135deg, #4299e1 0%, #818cf8 50%, #e53e3e 100%);
|
|
@@ -68,6 +68,9 @@
|
|
|
68
68
|
--corn-hue-fuchsia: #e879f9;
|
|
69
69
|
--corn-hue-pink: #f472b6;
|
|
70
70
|
--corn-hue-lime: #a3e635;
|
|
71
|
+
/* The orange as text on its own tint (the data-flow note in the Layers menu): the tint is the hue at 12% */
|
|
72
|
+
--corn-hue-orange-text: var(--corn-hue-orange);
|
|
73
|
+
--corn-hue-orange-soft: color-mix(in srgb, var(--corn-hue-orange) 12%, transparent);
|
|
71
74
|
|
|
72
75
|
/* Type */
|
|
73
76
|
--corn-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
|
@@ -107,6 +110,77 @@
|
|
|
107
110
|
--corn-glyph-mix: 100%;
|
|
108
111
|
|
|
109
112
|
color-scheme: dark;
|
|
113
|
+
|
|
114
|
+
/* The map (docs/theming.md, "The map"). explorer/map-style.js reads these from the computed style on load and on every theme change.
|
|
115
|
+
`auto` keeps what the map draws with no theme: the node's own colour from the topology (deepened on the light ground), and every
|
|
116
|
+
other colour as scene.js has it. A colour replaces it, as written, in both themes: set it again under :root[data-theme="light"] in a theme file
|
|
117
|
+
for the light ground. A kind's fill wins over its group's. */
|
|
118
|
+
--corn-map-stroke: auto;
|
|
119
|
+
--corn-map-stroke-width: 1.5px;
|
|
120
|
+
--corn-map-label: auto;
|
|
121
|
+
--corn-map-label-halo: auto;
|
|
122
|
+
--corn-map-collision: var(--corn-warn);
|
|
123
|
+
/* Diff, selection and focus */
|
|
124
|
+
--corn-map-added: auto;
|
|
125
|
+
--corn-map-changed: auto;
|
|
126
|
+
--corn-map-removed: auto;
|
|
127
|
+
--corn-map-edit: auto;
|
|
128
|
+
--corn-map-selected: auto;
|
|
129
|
+
--corn-map-match: auto;
|
|
130
|
+
--corn-map-lit: auto;
|
|
131
|
+
/* Edges by kind */
|
|
132
|
+
--corn-map-edge-ownership: auto;
|
|
133
|
+
--corn-map-edge-usage: auto;
|
|
134
|
+
--corn-map-edge-flow: auto;
|
|
135
|
+
--corn-map-edge-reads: auto;
|
|
136
|
+
--corn-map-edge-writes: auto;
|
|
137
|
+
--corn-map-edge-calls: auto;
|
|
138
|
+
--corn-map-edge-triggers: auto;
|
|
139
|
+
--corn-map-edge-delivers: auto;
|
|
140
|
+
--corn-map-edge-runs-on: auto;
|
|
141
|
+
--corn-map-edge-uses: auto;
|
|
142
|
+
--corn-map-edge-extends: auto;
|
|
143
|
+
/* Node fill by kind */
|
|
144
|
+
--corn-map-node-root: auto;
|
|
145
|
+
--corn-map-node-app: auto;
|
|
146
|
+
--corn-map-node-page: auto;
|
|
147
|
+
--corn-map-node-pkg: auto;
|
|
148
|
+
--corn-map-node-core: auto;
|
|
149
|
+
--corn-map-node-token: auto;
|
|
150
|
+
--corn-map-node-atom: auto;
|
|
151
|
+
--corn-map-node-molecule: auto;
|
|
152
|
+
--corn-map-node-tool: auto;
|
|
153
|
+
--corn-map-node-store: auto;
|
|
154
|
+
--corn-map-node-table: auto;
|
|
155
|
+
--corn-map-node-rom: auto;
|
|
156
|
+
--corn-map-node-service: auto;
|
|
157
|
+
--corn-map-node-external: auto;
|
|
158
|
+
--corn-map-node-stack: auto;
|
|
159
|
+
--corn-map-node-machine: auto;
|
|
160
|
+
--corn-map-node-container: auto;
|
|
161
|
+
--corn-map-node-persona: auto;
|
|
162
|
+
--corn-map-node-device: auto;
|
|
163
|
+
--corn-map-node-floor: auto;
|
|
164
|
+
--corn-map-node-room: auto;
|
|
165
|
+
/* Node fill by group */
|
|
166
|
+
--corn-map-group-app: auto;
|
|
167
|
+
--corn-map-group-pkg: auto;
|
|
168
|
+
--corn-map-group-page: auto;
|
|
169
|
+
--corn-map-group-atom: auto;
|
|
170
|
+
--corn-map-group-molecule: auto;
|
|
171
|
+
--corn-map-group-token: auto;
|
|
172
|
+
--corn-map-group-tool: auto;
|
|
173
|
+
--corn-map-group-table: auto;
|
|
174
|
+
--corn-map-group-rom: auto;
|
|
175
|
+
--corn-map-group-service: auto;
|
|
176
|
+
--corn-map-group-cloud: auto;
|
|
177
|
+
--corn-map-group-web: auto;
|
|
178
|
+
--corn-map-group-stack: auto;
|
|
179
|
+
--corn-map-group-machine: auto;
|
|
180
|
+
--corn-map-group-container: auto;
|
|
181
|
+
--corn-map-group-device: auto;
|
|
182
|
+
--corn-map-group-house: auto;
|
|
183
|
+
--corn-map-group-persona: auto;
|
|
110
184
|
}
|
|
111
185
|
|
|
112
186
|
/* Light: the same names, for the light ground */
|
|
@@ -135,10 +209,10 @@
|
|
|
135
209
|
--corn-focus: #4f46e5;
|
|
136
210
|
--corn-brand-gradient: linear-gradient(135deg, #2563eb 0%, #4f46e5 50%, #dc2626 100%);
|
|
137
211
|
|
|
138
|
-
--corn-ok: #
|
|
212
|
+
--corn-ok: #046f51;
|
|
139
213
|
--corn-warn: #854d0e;
|
|
140
214
|
--corn-bad: #b91c1c;
|
|
141
|
-
--corn-info: #
|
|
215
|
+
--corn-info: #03679e;
|
|
142
216
|
|
|
143
217
|
--corn-added: #209a8b;
|
|
144
218
|
--corn-changed: #b28103;
|
|
@@ -148,7 +222,8 @@
|
|
|
148
222
|
--corn-hue-orange: #c2410c;
|
|
149
223
|
--corn-hue-fuchsia: #a21caf;
|
|
150
224
|
--corn-hue-pink: #be185d;
|
|
151
|
-
--corn-hue-lime: #
|
|
225
|
+
--corn-hue-lime: #4c7b0f;
|
|
226
|
+
--corn-hue-orange-text: #9a3412;
|
|
152
227
|
|
|
153
228
|
--corn-house-line: color-mix(in srgb, var(--corn-hue-lime) 30%, transparent);
|
|
154
229
|
--corn-house-room: color-mix(in srgb, var(--corn-hue-lime) 55%, transparent);
|
|
@@ -183,10 +258,10 @@
|
|
|
183
258
|
--corn-focus: #4f46e5;
|
|
184
259
|
--corn-brand-gradient: linear-gradient(135deg, #2563eb 0%, #4f46e5 50%, #dc2626 100%);
|
|
185
260
|
|
|
186
|
-
--corn-ok: #
|
|
261
|
+
--corn-ok: #046f51;
|
|
187
262
|
--corn-warn: #854d0e;
|
|
188
263
|
--corn-bad: #b91c1c;
|
|
189
|
-
--corn-info: #
|
|
264
|
+
--corn-info: #03679e;
|
|
190
265
|
|
|
191
266
|
--corn-added: #209a8b;
|
|
192
267
|
--corn-changed: #b28103;
|
|
@@ -196,7 +271,8 @@
|
|
|
196
271
|
--corn-hue-orange: #c2410c;
|
|
197
272
|
--corn-hue-fuchsia: #a21caf;
|
|
198
273
|
--corn-hue-pink: #be185d;
|
|
199
|
-
--corn-hue-lime: #
|
|
274
|
+
--corn-hue-lime: #4c7b0f;
|
|
275
|
+
--corn-hue-orange-text: #9a3412;
|
|
200
276
|
|
|
201
277
|
--corn-house-line: color-mix(in srgb, var(--corn-hue-lime) 30%, transparent);
|
|
202
278
|
--corn-house-room: color-mix(in srgb, var(--corn-hue-lime) 55%, transparent);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cornfield",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.0",
|
|
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/server/server.js
CHANGED
|
@@ -78,7 +78,7 @@ import { createTriggers } from './triggers.js';
|
|
|
78
78
|
export const CORNFIELD_DIR = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
79
79
|
const EXPLORER_DIR = path.join(CORNFIELD_DIR, 'explorer');
|
|
80
80
|
/** The pure core modules the explorer imports (no Node built-ins, no files): the only ones of core/ served */
|
|
81
|
-
export const BROWSER_CORE = ['schema.js', 'proposal.js', 'personas.js', 'cloud.js', 'text.js', 'mentions.js'];
|
|
81
|
+
export const BROWSER_CORE = ['schema.js', 'proposal.js', 'personas.js', 'cloud.js', 'text.js', 'mentions.js', 'color.js'];
|
|
82
82
|
/** cornfield's own browser sources, by request path */
|
|
83
83
|
const BROWSER_PLUGINS = new Map(Object.values(BUILTIN_SOURCES).map((p) => [p, path.join(CORNFIELD_DIR, p)]));
|
|
84
84
|
const PKG = JSON.parse(fs.readFileSync(path.join(CORNFIELD_DIR, 'package.json'), 'utf8'));
|