cornfield 0.26.0 → 0.28.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/config.js +7 -2
- package/core/contrast.js +1 -0
- package/core/strings.js +117 -0
- package/core/theme.js +85 -4
- package/core/validate.js +4 -2
- package/explorer/explorer.css +6 -3
- package/explorer/forge-panel.js +11 -10
- package/explorer/index.html +33 -33
- package/explorer/labels.js +13 -6
- package/explorer/main.js +4 -1
- package/explorer/map-style.js +428 -0
- package/explorer/panels.js +3 -2
- package/explorer/plugins.js +6 -2
- package/explorer/proposal.js +6 -2
- package/explorer/renderer-canvas2d.js +26 -5
- package/explorer/renderer-webgl.js +182 -38
- package/explorer/review.js +11 -5
- package/explorer/runs-view.js +6 -5
- package/explorer/scene.js +13 -2
- package/explorer/shaders.js +27 -0
- package/explorer/strings.js +68 -0
- package/explorer/theme.js +4 -1
- package/explorer/tokens.css +71 -0
- package/explorer/view.js +2 -1
- package/package.json +1 -1
- package/server/server.js +4 -1
package/core/config.js
CHANGED
|
@@ -26,8 +26,9 @@
|
|
|
26
26
|
* hookPoll: { specs: '5m' }, // how often cornfield looks for ready specs and thread activity on its own, for the spec.ready and thread.* hooks; false turns it off (docs/config.md#hook-poll)
|
|
27
27
|
* threads: { label: 'idea' }, // an idea is an issue with this label, its thread the issue's comments; false turns threads off (docs/threads.md)
|
|
28
28
|
* links: [], // [{ label, href }] shown in the explorer's header
|
|
29
|
-
* theme: {}, // { css, fonts, fontHosts, names, default, contrast }: a repo's own look, CSS only (docs/config.md#theme)
|
|
29
|
+
* theme: {}, // { css, fonts, fontHosts, names, default, icons, pixelated, contrast }: a repo's own look, CSS only (docs/config.md#theme)
|
|
30
30
|
* brand: {}, // { logo, wordmark, favicon, appName, color, background }: a repo's own logo and name, images from the repo (docs/config.md#brand)
|
|
31
|
+
* strings: {}, // { approve: 'Ship it', … }: a repo's own words for the visible labels, plain text (core/strings.js, docs/theming.md#words)
|
|
31
32
|
* proxy: {}, // { '/api/': 'http://127.0.0.1:3245' }: same-origin paths for a live source
|
|
32
33
|
* importMap: {}, // bare imports a repo-local browser module needs: { name: '/repo/path.js' }
|
|
33
34
|
* dataDir: null, // where cornfield keeps its own state (reviews; the SQLite file in v1)
|
|
@@ -44,6 +45,7 @@ import path from 'node:path';
|
|
|
44
45
|
import { pathToFileURL, fileURLToPath } from 'node:url';
|
|
45
46
|
import { themeProblems } from './theme.js';
|
|
46
47
|
import { brandProblems } from './brand.js';
|
|
48
|
+
import { stringsProblems } from './strings.js';
|
|
47
49
|
import { PROFILE_SOURCE, MAX_NUMBER, MAX_BRIEF_CHARS, RUN_KINDS, TRIGGER_EVENTS, CREDENTIAL_VALUE_SOURCE } from './agent-contract.js';
|
|
48
50
|
|
|
49
51
|
export { TRIGGER_EVENTS };
|
|
@@ -168,8 +170,9 @@ export const DEFAULTS = Object.freeze({
|
|
|
168
170
|
hookPoll: { specs: '5m' },
|
|
169
171
|
threads: { label: 'idea' },
|
|
170
172
|
links: [],
|
|
171
|
-
theme: { css: null, fonts: [], fontHosts: [], names: {}, default: null, contrast: 'error' },
|
|
173
|
+
theme: { css: null, fonts: [], fontHosts: [], names: {}, default: null, icons: {}, pixelated: false, contrast: 'error' },
|
|
172
174
|
brand: { logo: null, wordmark: null, favicon: null, appName: null, color: null, background: null },
|
|
175
|
+
strings: {},
|
|
173
176
|
proxy: {},
|
|
174
177
|
importMap: {},
|
|
175
178
|
dataDir: null,
|
|
@@ -344,6 +347,7 @@ export function configProblems(c) {
|
|
|
344
347
|
}
|
|
345
348
|
out.push(...themeProblems(c.theme));
|
|
346
349
|
out.push(...brandProblems(c.brand));
|
|
350
|
+
out.push(...stringsProblems(c.strings));
|
|
347
351
|
if (c.proxy !== undefined) {
|
|
348
352
|
if (!isObject(c.proxy)) out.push('"proxy" is { "/path/": "http://upstream" }.');
|
|
349
353
|
else for (const [p, t] of Object.entries(c.proxy)) {
|
|
@@ -532,6 +536,7 @@ export async function loadConfig(root, { env = process.env, file } = {}) {
|
|
|
532
536
|
};
|
|
533
537
|
config.theme = { ...structuredClone(DEFAULTS.theme), ...(raw.theme || {}) };
|
|
534
538
|
config.brand = { ...DEFAULTS.brand, ...(raw.brand || {}) };
|
|
539
|
+
config.strings = { ...(raw.strings || {}) };
|
|
535
540
|
// `threads: false` stays false; an object is read over the default
|
|
536
541
|
config.threads = raw.threads === false ? false : { ...DEFAULTS.threads, ...(raw.threads || {}) };
|
|
537
542
|
// `hookPoll: false` is `{ specs: false }`; an object is read over the default
|
package/core/contrast.js
CHANGED
|
@@ -379,6 +379,7 @@ export const PAINTED_TEXT = Object.freeze([
|
|
|
379
379
|
['--corn-text-2', tint('--corn-text-3', 10), 'a check'],
|
|
380
380
|
['--corn-text-2', tint('--corn-text-2', 12), 'a web badge'],
|
|
381
381
|
['--corn-text-2', '--corn-line-soft', 'a text button, hovered'],
|
|
382
|
+
['--corn-map-collision', GROUND, 'a collision tag on the map'],
|
|
382
383
|
]);
|
|
383
384
|
/**
|
|
384
385
|
* The parts of the interface a person needs to see to use it (WCAG 1.4.11), at 3:1: `[fg, bg, what]`. The focus indicators, and the
|
package/core/strings.js
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/strings
|
|
3
|
+
*
|
|
4
|
+
* The words a repo may say in its own voice (`strings` in cornfield.config.js, docs/theming.md "Words"). ONE table, `STRINGS`,
|
|
5
|
+
* holds every overridable label and its default. The config check (core/config.js, so `cornfield validate`), the browser
|
|
6
|
+
* (explorer/strings.js; this file is served to it, server/server.js BROWSER_CORE) and the docs table (`stringsTable`, kept in step by
|
|
7
|
+
* a test) all read it, so the three cannot drift.
|
|
8
|
+
*
|
|
9
|
+
* A value is plain text: it reaches the page through textContent and attributes only, never as HTML, so `<b>` is shown as the
|
|
10
|
+
* characters it is. One line, at most MAX_STRING_LENGTH characters. A missing key means the default; an unknown key is refused.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/** Overridable label by key: the default words. Keys are camelCase; add one here and the docs test says what else to update. */
|
|
14
|
+
export const STRINGS = Object.freeze({
|
|
15
|
+
// The header
|
|
16
|
+
layers: 'Layers',
|
|
17
|
+
dataFlow: 'Data flow',
|
|
18
|
+
house: 'House',
|
|
19
|
+
proposals: 'Proposals',
|
|
20
|
+
issuesAndPrs: 'Issues & PRs',
|
|
21
|
+
searchPlaceholder: 'Search...',
|
|
22
|
+
signOut: 'Sign out',
|
|
23
|
+
poweredBy: 'powered by cornfield',
|
|
24
|
+
// The proposal bar and the review
|
|
25
|
+
before: 'Before',
|
|
26
|
+
diff: 'Diff',
|
|
27
|
+
after: 'After',
|
|
28
|
+
closeProposal: 'Close',
|
|
29
|
+
approve: 'Approve',
|
|
30
|
+
sendBack: 'Send back',
|
|
31
|
+
reviewNoteLabel: 'Note for the drafting agent',
|
|
32
|
+
reviewNotePlaceholder: 'What should change? Needed to send it back, optional to approve.',
|
|
33
|
+
// The issues and pull requests panel
|
|
34
|
+
tabPulls: 'Pull requests',
|
|
35
|
+
tabIssues: 'Issues',
|
|
36
|
+
tabThreads: 'Threads',
|
|
37
|
+
tabDeploys: 'Deploys',
|
|
38
|
+
tabAgents: 'Agents',
|
|
39
|
+
tabNotes: 'Release notes',
|
|
40
|
+
newIdea: 'New idea',
|
|
41
|
+
landIt: 'Land it',
|
|
42
|
+
// Agent runs
|
|
43
|
+
startAgent: 'Start an agent',
|
|
44
|
+
askRunner: 'Ask the runner',
|
|
45
|
+
startAgain: 'Start again',
|
|
46
|
+
stop: 'Stop',
|
|
47
|
+
continueRun: 'Continue',
|
|
48
|
+
reply: 'Reply',
|
|
49
|
+
// The node panel
|
|
50
|
+
propsTitle: 'Properties & Attributes',
|
|
51
|
+
detailsTitle: 'Details',
|
|
52
|
+
openRoute: 'Open Live Route',
|
|
53
|
+
copySpec: 'Copy Spec',
|
|
54
|
+
// The hint, loading and errors
|
|
55
|
+
hintInspect: 'Tap node to inspect live spec',
|
|
56
|
+
hintDrag: 'Drag nodes to move • Double-tap to inspect',
|
|
57
|
+
hintDataFlow: 'Data flow: browser → servers → API → tables → services → outside',
|
|
58
|
+
loading: 'Loading topology.json …',
|
|
59
|
+
errorTitle: 'The map could not be loaded',
|
|
60
|
+
retry: 'Retry',
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
/** The longest a value may be, in characters */
|
|
64
|
+
export const MAX_STRING_LENGTH = 80;
|
|
65
|
+
|
|
66
|
+
const isObject = (v) => v !== null && typeof v === 'object' && !Array.isArray(v);
|
|
67
|
+
/** Whether `key` is one of the table's (an own key: `__proto__` and `toString` are not) */
|
|
68
|
+
export const isStringKey = (key) => typeof key === 'string' && Object.hasOwn(STRINGS, key);
|
|
69
|
+
/** A line break or any other control character */
|
|
70
|
+
const CONTROL = new RegExp('[\\u0000-\\u001f\\u007f-\\u009f\\u2028\\u2029]');
|
|
71
|
+
/**
|
|
72
|
+
* What is wrong with one value, or null.
|
|
73
|
+
* @param {unknown} v
|
|
74
|
+
* @returns {string|null}
|
|
75
|
+
*/
|
|
76
|
+
export function stringProblem(v) {
|
|
77
|
+
if (typeof v !== 'string') return 'is text';
|
|
78
|
+
if (!v.trim()) return 'is empty (leave the key out to keep the default)';
|
|
79
|
+
if (CONTROL.test(v)) return 'is one line of plain text (no line break or control character)';
|
|
80
|
+
if ([...v].length > MAX_STRING_LENGTH) return `is at most ${MAX_STRING_LENGTH} characters`;
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* What is wrong with a `strings` value (as the config file wrote it). HTML is not a problem: it is shown as text.
|
|
86
|
+
* @param {unknown} s
|
|
87
|
+
* @returns {string[]}
|
|
88
|
+
*/
|
|
89
|
+
export function stringsProblems(s) {
|
|
90
|
+
if (s === undefined) return [];
|
|
91
|
+
if (!isObject(s)) return ['"strings" is an object of labels: { approve: \'Ship it\' }.'];
|
|
92
|
+
const out = [];
|
|
93
|
+
for (const [key, value] of Object.entries(s)) {
|
|
94
|
+
if (!isStringKey(key)) { out.push(`strings: unknown key "${key}". Known: ${Object.keys(STRINGS).join(', ')}.`); continue; }
|
|
95
|
+
const problem = stringProblem(value);
|
|
96
|
+
if (problem) out.push(`strings.${key} ${problem}.`);
|
|
97
|
+
}
|
|
98
|
+
return out;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* The overrides the browser is sent: known keys with a good value, nothing else (the defaults live in the browser already).
|
|
103
|
+
* @param {unknown} s
|
|
104
|
+
* @returns {Record<string, string>}
|
|
105
|
+
*/
|
|
106
|
+
export function clientStrings(s) {
|
|
107
|
+
const out = {};
|
|
108
|
+
if (!isObject(s)) return out;
|
|
109
|
+
for (const [key, value] of Object.entries(s)) if (isStringKey(key) && !stringProblem(value)) out[key] = value;
|
|
110
|
+
return out;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** The docs' key table (docs/theming.md "Words"), generated from STRINGS; a test fails when the docs hold anything else */
|
|
114
|
+
export function stringsTable() {
|
|
115
|
+
const cell = (v) => v.replace(/\|/g, '\\|');
|
|
116
|
+
return ['| Key | Default |', '|---|---|', ...Object.entries(STRINGS).map(([k, v]) => `| \`${k}\` | ${cell(v)} |`)].join('\n');
|
|
117
|
+
}
|
package/core/theme.js
CHANGED
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
* fontHosts: [], // the hosts of the font FILES, when a fonts host is not a known pair
|
|
12
12
|
* names: { day: './tools/cornfield/day.css' }, // named themes: data-theme-name on <html>, a picker in the header
|
|
13
13
|
* default: 'day', // the name used until a viewer picks one
|
|
14
|
+
* icons: { app: './tools/cornfield/icons/app.svg' }, // an icon per node kind, drawn inside the node on the map (svg or png)
|
|
15
|
+
* pixelated: true, // small icons are drawn crisp (nearest-neighbour), not smoothed
|
|
14
16
|
* contrast: 'error', // 'warn' turns a failing contrast pair in `validate` into a warning
|
|
15
17
|
* }
|
|
16
18
|
*
|
|
@@ -19,8 +21,13 @@
|
|
|
19
21
|
|
|
20
22
|
import fs from 'node:fs';
|
|
21
23
|
import path from 'node:path';
|
|
24
|
+
import { NODE_THEMES } from './schema.js';
|
|
22
25
|
|
|
23
|
-
export const THEME_KEYS = Object.freeze(['css', 'fonts', 'fontHosts', 'names', 'default', 'contrast']);
|
|
26
|
+
export const THEME_KEYS = Object.freeze(['css', 'fonts', 'fontHosts', 'names', 'default', 'icons', 'pixelated', 'contrast']);
|
|
27
|
+
/** The node kinds an icon may be set for: every node type of the map */
|
|
28
|
+
export const ICON_KINDS = Object.freeze(Object.keys(NODE_THEMES));
|
|
29
|
+
/** The file types of a node icon */
|
|
30
|
+
export const ICON_EXTENSIONS = Object.freeze(['.svg', '.png']);
|
|
24
31
|
/** The largest a theme file may be, in bytes */
|
|
25
32
|
export const MAX_THEME_BYTES = 256 * 1024;
|
|
26
33
|
export const MAX_THEME_NAMES = 12;
|
|
@@ -60,7 +67,7 @@ export function fontUrl(v) {
|
|
|
60
67
|
*/
|
|
61
68
|
export function themeProblems(t) {
|
|
62
69
|
if (t === undefined) return [];
|
|
63
|
-
if (!isObject(t)) return ['"theme" is { css?, fonts?, fontHosts?, names?, default?, contrast? }.'];
|
|
70
|
+
if (!isObject(t)) return ['"theme" is { css?, fonts?, fontHosts?, names?, default?, icons?, pixelated?, contrast? }.'];
|
|
64
71
|
const out = [];
|
|
65
72
|
for (const k of Object.keys(t)) if (!THEME_KEYS.includes(k)) out.push(`theme.${k}: the keys are ${THEME_KEYS.join(', ')}.`);
|
|
66
73
|
if (t.css !== undefined && t.css !== null && !cssPathInRepo(t.css)) out.push('theme.css is one stylesheet (a .css file) inside the repo, written relative to it, like "./tools/cornfield/theme.css".');
|
|
@@ -100,6 +107,48 @@ export function themeProblems(t) {
|
|
|
100
107
|
if (!isText(t.default)) out.push('theme.default is the name of one of theme.names.');
|
|
101
108
|
else if (!names.includes(t.default)) out.push(`theme.default "${t.default}" is not one of theme.names (${names.join(', ') || 'none are listed'}).`);
|
|
102
109
|
}
|
|
110
|
+
if (t.pixelated !== undefined && typeof t.pixelated !== 'boolean') out.push('theme.pixelated is true or false.');
|
|
111
|
+
if (t.icons !== undefined) {
|
|
112
|
+
if (!isObject(t.icons)) out.push('theme.icons is { "<node kind>": "./path.svg" }.');
|
|
113
|
+
else {
|
|
114
|
+
for (const [kind, rel] of Object.entries(t.icons)) {
|
|
115
|
+
if (!ICON_KINDS.includes(kind)) out.push(`theme.icons "${kind}": not a node kind (${ICON_KINDS.join(', ')}).`);
|
|
116
|
+
const found = themeIconAsset(t, rel);
|
|
117
|
+
if ('problem' in found) out.push(`theme.icons.${kind} ${found.problem}`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return out;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Where a node icon of the config is served, by its repo path: `{ asset }` (the path after THEME_ASSET_PREFIX) or `{ problem }`.
|
|
126
|
+
* An icon is an .svg or .png file inside the repo, and inside the theme folder (themeAssetDir): it is served by the route that serves the
|
|
127
|
+
* images beside a theme, nothing else. No disk is read here (core/validate.js checks the file).
|
|
128
|
+
* @param {object} theme
|
|
129
|
+
* @param {unknown} rel the icon's path as the config wrote it
|
|
130
|
+
* @returns {{ asset: string } | { problem: string }}
|
|
131
|
+
*/
|
|
132
|
+
export function themeIconAsset(theme, rel) {
|
|
133
|
+
if (!isText(rel) || path.isAbsolute(rel) || /^[a-z]:/i.test(rel) || rel.includes('\0') || rel.includes('\\') || rel.split('/').includes('..')) return { problem: 'is an .svg or .png file inside the repo, written relative to it, like "./tools/cornfield/icons/app.svg".' };
|
|
134
|
+
if (!ICON_EXTENSIONS.includes(path.posix.extname(rel).toLowerCase())) return { problem: `(${rel}) is not an .svg or .png file.` };
|
|
135
|
+
const dir = themeAssetDir(theme);
|
|
136
|
+
if (!dir) return { problem: `(${rel}) cannot be served: icons are served beside the theme files, so the theme needs a stylesheet (theme.css or theme.names) in a folder, not at the top of the repo.` };
|
|
137
|
+
const norm = path.posix.normalize(rel);
|
|
138
|
+
if (!norm.startsWith(`${dir}/`)) return { problem: `(${rel}) is outside the theme folder ${dir}, the only folder whose images are served; put the icon under it.` };
|
|
139
|
+
const asset = themeAssetPath(norm.slice(dir.length + 1));
|
|
140
|
+
return asset ? { asset } : { problem: `(${rel}) has a name that cannot be served (letters, digits, ".", "_" and "-" only, no segment starting with a dot).` };
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** The icons the browser is told: `{ kind: '/cornfield/theme/assets/<path>' }`, those the config names validly */
|
|
144
|
+
export function iconUrls(theme) {
|
|
145
|
+
const out = {};
|
|
146
|
+
if (!theme || !isObject(theme.icons)) return out;
|
|
147
|
+
for (const [kind, rel] of Object.entries(theme.icons)) {
|
|
148
|
+
if (!ICON_KINDS.includes(kind)) continue;
|
|
149
|
+
const found = themeIconAsset(theme, rel);
|
|
150
|
+
if (!('problem' in found)) out[kind] = THEME_ASSET_PREFIX + found.asset;
|
|
151
|
+
}
|
|
103
152
|
return out;
|
|
104
153
|
}
|
|
105
154
|
|
|
@@ -303,11 +352,14 @@ export function themeUrlTarget(ref, servedAt) {
|
|
|
303
352
|
return asset ? { asset } : { problem: why };
|
|
304
353
|
}
|
|
305
354
|
|
|
306
|
-
/** The theme as the browser is told it: names and the default, never a path on this machine */
|
|
355
|
+
/** The theme as the browser is told it: names and the default, the icons' served paths and the pixelated flag, never a path on this machine */
|
|
307
356
|
export function clientTheme(theme) {
|
|
308
357
|
if (!theme) return null;
|
|
309
358
|
const names = Object.keys(theme.names || {});
|
|
310
|
-
|
|
359
|
+
const icons = iconUrls(theme);
|
|
360
|
+
const pixelated = theme.pixelated === true;
|
|
361
|
+
if (!names.length && !Object.keys(icons).length && !pixelated) return null;
|
|
362
|
+
return { names, default: names.length ? theme.default || null : null, ...(Object.keys(icons).length ? { icons } : {}), ...(pixelated ? { pixelated } : {}) };
|
|
311
363
|
}
|
|
312
364
|
|
|
313
365
|
/**
|
|
@@ -337,3 +389,32 @@ export function themeAssetFile(root, theme, rel) {
|
|
|
337
389
|
if (stats.size > MAX_THEME_ASSET_BYTES) return { problem: `${dir}/${rel} is ${Math.ceil(stats.size / 1024)} KB; an asset beside a theme is at most ${MAX_THEME_ASSET_BYTES / 1024 / 1024} MB.` };
|
|
338
390
|
return { file: real, size: stats.size, type };
|
|
339
391
|
}
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* What is wrong with the icon files of the config (`theme.icons`): each one exists as a plain file under the theme folder (a link out of it is
|
|
395
|
+
* refused), is at most MAX_THEME_ASSET_BYTES, and is what its extension says (an .svg is text with an <svg> element and no script, a .png starts
|
|
396
|
+
* with the PNG signature). The server serves an icon only if themeAssetFile finds it, so this is the same rule.
|
|
397
|
+
* @param {{ root: string, theme?: object }} config
|
|
398
|
+
* @returns {string[]}
|
|
399
|
+
*/
|
|
400
|
+
export function themeIconFileProblems(config) {
|
|
401
|
+
const out = [];
|
|
402
|
+
const icons = config.theme && isObject(config.theme.icons) ? config.theme.icons : {};
|
|
403
|
+
for (const [kind, rel] of Object.entries(icons)) {
|
|
404
|
+
const where = `theme.icons.${kind} (${rel})`;
|
|
405
|
+
const target = themeIconAsset(config.theme, rel);
|
|
406
|
+
if ('problem' in target) { out.push(`${where} ${target.problem}`); continue; }
|
|
407
|
+
const found = themeAssetFile(config.root, config.theme, target.asset);
|
|
408
|
+
if ('problem' in found) { out.push(`${where} ${found.problem}`); continue; }
|
|
409
|
+
let head;
|
|
410
|
+
try { head = fs.readFileSync(found.file); } catch { out.push(`${where} cannot be read.`); continue; }
|
|
411
|
+
if (path.posix.extname(target.asset).toLowerCase() === '.png') {
|
|
412
|
+
if (!head.subarray(0, 8).equals(Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]))) out.push(`${where} is not a PNG image.`);
|
|
413
|
+
} else {
|
|
414
|
+
const text = head.toString('utf8');
|
|
415
|
+
if (!/<svg[\s>]/i.test(text)) out.push(`${where} is not an SVG image (no <svg> element).`);
|
|
416
|
+
else if (/<\s*script\b|\son[a-z]+\s*=|javascript\s*:/i.test(text)) out.push(`${where} holds script, which an icon may not (an icon is an image only).`);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
return out;
|
|
420
|
+
}
|
package/core/validate.js
CHANGED
|
@@ -25,7 +25,7 @@ import { missingPaths, planSync } from './sync.js';
|
|
|
25
25
|
import { repoPaths, repoReader } from './repo.js';
|
|
26
26
|
import { checkThemeContrast } from './contrast.js';
|
|
27
27
|
import { BRAND_IMAGE_KEYS, brandAssetFile } from './brand.js';
|
|
28
|
-
import { MAX_THEME_BYTES, cssProblems, cssUrls, themeAssetFile, themeFileUrl, themeFiles, themeUrlTarget } from './theme.js';
|
|
28
|
+
import { MAX_THEME_BYTES, cssProblems, cssUrls, themeAssetFile, themeFileUrl, themeFiles, themeIconFileProblems, themeUrlTarget } from './theme.js';
|
|
29
29
|
|
|
30
30
|
/** How a page is produced today, and whether it is baked to a file */
|
|
31
31
|
export const RENDER_NOW = ['build', 'request', 'build+request', 'rom'];
|
|
@@ -36,7 +36,8 @@ const ONLY_REMOVES_HINT = '(A proposal that adds nothing cannot show it has been
|
|
|
36
36
|
/**
|
|
37
37
|
* The config's theme files (docs/config.md#theme): each one exists, is a plain file inside the repo (a link out of it is refused),
|
|
38
38
|
* is at most MAX_THEME_BYTES, is CSS that keeps out of script (core/theme.js `cssProblems`), and every url() in it is a data: image
|
|
39
|
-
* or an image or font the server serves beside the theme (core/theme.js `themeUrlTarget`, `themeAssetFile`)
|
|
39
|
+
* or an image or font the server serves beside the theme (core/theme.js `themeUrlTarget`, `themeAssetFile`), and every node icon
|
|
40
|
+
* (`theme.icons`) is an .svg or .png file there (`themeIconFileProblems`).
|
|
40
41
|
* @param {{ root: string, theme?: object }} config
|
|
41
42
|
* @returns {string[]}
|
|
42
43
|
*/
|
|
@@ -65,6 +66,7 @@ export function validateThemeFiles(config) {
|
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
68
|
}
|
|
69
|
+
errors.push(...themeIconFileProblems(config)); // theme.icons: each file is there, served, and an image
|
|
68
70
|
return errors;
|
|
69
71
|
}
|
|
70
72
|
|
package/explorer/explorer.css
CHANGED
|
@@ -804,10 +804,10 @@ a.hx-forge-row:hover, button.hx-forge-row:hover { background: var(--corn-surface
|
|
|
804
804
|
.hx-run-overlay.is-static .hx-run-ring { animation: none; transform: none; opacity: 1; border-width: calc(var(--corn-border-strong) + var(--corn-border)); }
|
|
805
805
|
@media (prefers-reduced-motion: reduce) { .hx-run-ring { animation: none !important; transform: none; opacity: 1; border-width: calc(var(--corn-border-strong) + var(--corn-border)); } }
|
|
806
806
|
/* Collision: dashed, a sign and words; the same ring whether or not colour is seen */
|
|
807
|
-
.hx-run-mark--collision .hx-run-ring { border: calc(var(--corn-border-strong) + var(--corn-border)) dashed var(--corn-
|
|
808
|
-
.hx-run-tag { position: absolute; left: 0; top: calc(var(--r) + 4px); transform: translateX(-50%); white-space: nowrap; padding: calc(var(--corn-space-1) / 2) var(--corn-space-2); border-radius: var(--corn-radius-pill); border: var(--corn-border) solid var(--corn-
|
|
807
|
+
.hx-run-mark--collision .hx-run-ring { border: calc(var(--corn-border-strong) + var(--corn-border)) dashed var(--corn-map-collision); animation: none; }
|
|
808
|
+
.hx-run-tag { position: absolute; left: 0; top: calc(var(--r) + 4px); transform: translateX(-50%); white-space: nowrap; padding: calc(var(--corn-space-1) / 2) var(--corn-space-2); border-radius: var(--corn-radius-pill); border: var(--corn-border) solid var(--corn-map-collision); background: color-mix(in srgb, var(--corn-ground) 80%, transparent); color: var(--corn-map-collision); font-size: var(--corn-text-xs); font-weight: 700; }
|
|
809
809
|
.hx-run-swatch { display: inline-block; width: 14px; height: 14px; flex: none; box-sizing: border-box; border-radius: 50%; border: var(--corn-border-strong) solid var(--corn-added); }
|
|
810
|
-
.hx-run-swatch--collision { border: var(--corn-border-strong) dashed var(--corn-
|
|
810
|
+
.hx-run-swatch--collision { border: var(--corn-border-strong) dashed var(--corn-map-collision); }
|
|
811
811
|
|
|
812
812
|
/* The Runs view (forge-panel.js, runs-view.js): each run, its limits beside what was reported, its timeline; the compare puts profiles side by side */
|
|
813
813
|
.hx-runs-list { display: flex; flex-direction: column; gap: var(--corn-space-3); margin: 0; padding: 0; list-style: none; }
|
|
@@ -835,3 +835,6 @@ a.hx-forge-row:hover, button.hx-forge-row:hover { background: var(--corn-surface
|
|
|
835
835
|
.hx-stage:has(.hx-forge .hx-run-compare):has(.drawer-open) { --hx-forge-w: min(400px, calc(100% - 24px)); }
|
|
836
836
|
.hx-stage:has(.drawer-open) .hx-run-columns { grid-template-columns: 1fr; }
|
|
837
837
|
}
|
|
838
|
+
|
|
839
|
+
/* theme.pixelated (docs/config.md#theme): small pixel-art images are sampled without smoothing, in the page as on the map (map-style.js) */
|
|
840
|
+
:root[data-pixelated] img { image-rendering: pixelated; }
|
package/explorer/forge-panel.js
CHANGED
|
@@ -82,6 +82,7 @@ import {
|
|
|
82
82
|
threadsUrl, threadUrl, issueUrl, IDEAS_URL, threadKindWords, threadMeta, litForThread, mentionsIndex, ideaRequest, ideaWords,
|
|
83
83
|
} from './forge-panel-model.js';
|
|
84
84
|
import { cornStateAttr } from './corn-state.js';
|
|
85
|
+
import { t } from './strings.js';
|
|
85
86
|
|
|
86
87
|
const $ = (id) => document.getElementById(id);
|
|
87
88
|
const FORGE_NAMES = { github: 'GitHub', forgejo: 'Forgejo' };
|
|
@@ -883,7 +884,7 @@ function itemHtml(item, before = '', after = '') {
|
|
|
883
884
|
? `<button type="button" class="hx-btn hx-forge-act hx-forge-startspec" data-forge-spec="${item.number}" aria-label="Start a spec for issue ${item.number}"${ui.busy ? ' disabled' : ''}>Start a spec …</button>`
|
|
884
885
|
: '';
|
|
885
886
|
const agent = item.state === 'open'
|
|
886
|
-
? `<button type="button" class="hx-btn hx-forge-act hx-forge-startspec" data-forge-agent="issue:${item.number}" aria-label="
|
|
887
|
+
? `<button type="button" class="hx-btn hx-forge-act hx-forge-startspec" data-forge-agent="issue:${item.number}" aria-label="${escHtml(t('startAgent'))} on issue ${item.number}">${escHtml(t('startAgent'))} …</button>`
|
|
887
888
|
: '';
|
|
888
889
|
return link
|
|
889
890
|
? `<li class="hx-forge-item"><a class="hx-forge-row" href="${escHtml(link)}" target="_blank" rel="noreferrer" data-corn="row">${inner}<span class="hx-sr-only"> (opens ${escHtml(forgeName())} in a new tab)</span></a>${spec}${agent}</li>`
|
|
@@ -906,7 +907,7 @@ function groupsHtml(groups) {
|
|
|
906
907
|
return groups.map((g, i) => {
|
|
907
908
|
const link = g.issue && safeUrl(g.issue.url) ? ` <a class="hx-link hx-forge-gout" href="${escHtml(g.issue.url)}" target="_blank" rel="noreferrer" aria-label="Open issue ${g.number} on ${escHtml(forgeName())} (new tab)">↗</a>` : '';
|
|
908
909
|
const startRef = g.kind === 'issue' && g.issue && g.issue.state === 'open' ? `issue:${g.number}` : g.kind === 'proposal' ? `proposal:${g.slug}` : null;
|
|
909
|
-
const start = startRef ? ` <button type="button" class="hx-btn hx-forge-act" data-forge-agent="${escHtml(startRef)}" aria-label="
|
|
910
|
+
const start = startRef ? ` <button type="button" class="hx-btn hx-forge-act" data-forge-agent="${escHtml(startRef)}" aria-label="${escHtml(t('startAgent'))} on ${escHtml(g.kind === 'issue' ? `issue ${g.number}` : `proposal ${g.slug}`)}">${escHtml(t('startAgent'))} …</button>` : '';
|
|
910
911
|
return `<li class="hx-forge-group"><h3 class="hx-forge-gtitle" id="forge-group-${i}">${escHtml(g.title)}${link}</h3>${start}<p class="hx-forge-meta">${escHtml(groupWords(g))}</p><ul class="hx-forge-list" aria-labelledby="forge-group-${i}">${g.entries.map(workHtml).join('')}</ul></li>`;
|
|
911
912
|
}).join('');
|
|
912
913
|
}
|
|
@@ -1012,7 +1013,7 @@ function detailHtml() {
|
|
|
1012
1013
|
const block = mergeBlock(ui.detail);
|
|
1013
1014
|
const act = block
|
|
1014
1015
|
? `<p class="hx-forge-why hx-faint">${pull.state === 'merged' ? '' : 'Cannot be landed from here. '}${escHtml(block)}</p>`
|
|
1015
|
-
: `<button type="button" class="hx-btn hx-btn--approve hx-forge-act" data-forge-merge="${pull.number}"${ui.busy ? ' disabled' : ''} data-corn-kind="approve"
|
|
1016
|
+
: `<button type="button" class="hx-btn hx-btn--approve hx-forge-act" data-forge-merge="${pull.number}"${ui.busy ? ' disabled' : ''} data-corn-kind="approve">${escHtml(t('landIt'))} …</button><p class="hx-forge-why hx-faint">Opens a confirm step that shows what will land. Never forced, never deployed.</p>`;
|
|
1016
1017
|
// A spec approved with `proposals.approveLands` waits for its checks: said here, with a way to stop it
|
|
1017
1018
|
const waiting = ui.landing && pull.state === 'open'
|
|
1018
1019
|
? `<div class="hx-forge-step"><p class="hx-forge-notice hx-forge-notice--ok" role="status" data-corn="notice" data-corn-state="success">${escHtml(landingWords(ui.landing, now()))}</p><button type="button" class="hx-btn hx-forge-act" data-forge-landing-cancel="${pull.number}"${ui.busy ? ' disabled' : ''}>Cancel</button></div>`
|
|
@@ -1034,7 +1035,7 @@ function detailHtml() {
|
|
|
1034
1035
|
<h4 class="hx-forge-sub">Checks: ${escHtml(checksWords(checks))}</h4>
|
|
1035
1036
|
${checks.length ? `<ul class="hx-forge-checks">${checkRows}</ul>` : ''}
|
|
1036
1037
|
${build}
|
|
1037
|
-
<h4 class="hx-forge-subact"
|
|
1038
|
+
<h4 class="hx-forge-subact">${escHtml(t('landIt'))}</h4>
|
|
1038
1039
|
${note}
|
|
1039
1040
|
${waiting}
|
|
1040
1041
|
${act}
|
|
@@ -1322,7 +1323,7 @@ function showConfirm(what, goLabel, state) {
|
|
|
1322
1323
|
/** Opens the confirm step for landing the selected pull request: what will land, exactly */
|
|
1323
1324
|
function openConfirm(opener) {
|
|
1324
1325
|
if (!confirmEl() || ui.confirm || ui.busy || !ui.detail || mergeBlock(ui.detail)) return;
|
|
1325
|
-
showConfirm(confirmMerge(ui.detail, forgeName(), ui.config && ui.config.forge && ui.config.forge.mergeMethod), '
|
|
1326
|
+
showConfirm(confirmMerge(ui.detail, forgeName(), ui.config && ui.config.forge && ui.config.forge.mergeMethod), t('landIt'), { opener, kind: 'merge' });
|
|
1326
1327
|
}
|
|
1327
1328
|
|
|
1328
1329
|
/** What a pipeline step came to, on the panel (with a link to what it made) and through the live region */
|
|
@@ -1483,7 +1484,7 @@ async function openAgent(ref, opener, again = null, brief = null) {
|
|
|
1483
1484
|
$('agent-profile').innerHTML = option('', 'No profile', !(again && again.profile)) + shown.map((p) => option(p, p, !!again && p === again.profile)).join('');
|
|
1484
1485
|
$('agent-profile-field').hidden = !shown.length;
|
|
1485
1486
|
$('agent-profile').value = again && again.profile ? again.profile : ''; // as well as `selected`, which not every DOM honours
|
|
1486
|
-
$('agent-start-title').textContent = again ? '
|
|
1487
|
+
$('agent-start-title').textContent = again ? t('startAgain') : t('startAgent');
|
|
1487
1488
|
const note = $('agent-retry-note');
|
|
1488
1489
|
note.hidden = !again;
|
|
1489
1490
|
note.textContent = again ? retryWords(again) : '';
|
|
@@ -1497,11 +1498,11 @@ async function openAgent(ref, opener, again = null, brief = null) {
|
|
|
1497
1498
|
const go = $('agent-start-go');
|
|
1498
1499
|
go.disabled = false;
|
|
1499
1500
|
go.removeAttribute('aria-busy');
|
|
1500
|
-
go.textContent = '
|
|
1501
|
+
go.textContent = t('askRunner');
|
|
1501
1502
|
document.addEventListener('focusin', keepFocusInAgent);
|
|
1502
1503
|
agentEl().hidden = false;
|
|
1503
1504
|
$('agent-kind').focus();
|
|
1504
|
-
announce(`${again ? '
|
|
1505
|
+
announce(`${again ? t('startAgain') : t('startAgent')} on ${aboutWords(refs)}. ${confirmStartWords(refs, forgeName())}`);
|
|
1505
1506
|
}
|
|
1506
1507
|
|
|
1507
1508
|
/** "Start again" on a run that failed or was stopped. A brief the list shows cut is read whole first: the dialog never starts from part of one */
|
|
@@ -1587,7 +1588,7 @@ async function submitAgent(e) {
|
|
|
1587
1588
|
ui.agent.posting = false;
|
|
1588
1589
|
go.disabled = false;
|
|
1589
1590
|
go.removeAttribute('aria-busy');
|
|
1590
|
-
go.textContent = '
|
|
1591
|
+
go.textContent = t('askRunner');
|
|
1591
1592
|
const bad = $('agent-start-msg');
|
|
1592
1593
|
bad.textContent = `A limit is a number above zero, or blank for the config's (${wrong.join(', ')}).`;
|
|
1593
1594
|
bad.hidden = false;
|
|
@@ -1612,7 +1613,7 @@ async function submitAgent(e) {
|
|
|
1612
1613
|
}
|
|
1613
1614
|
go.disabled = false;
|
|
1614
1615
|
go.removeAttribute('aria-busy');
|
|
1615
|
-
go.textContent = '
|
|
1616
|
+
go.textContent = t('askRunner');
|
|
1616
1617
|
const msg = $('agent-start-msg');
|
|
1617
1618
|
msg.textContent = text;
|
|
1618
1619
|
msg.hidden = false;
|