mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-20 10:12:18 +00:00
Merge remote-tracking branch 'origin/main' into samehkhamis/kit-sweep-bhote-koshi
# Conflicts: # scripts/format-scope.json
This commit is contained in:
commit
36ef856ca2
28 files changed
+834
-71
No files matched your search
@@ -0,0 +1,150 @@
|
||||
// The AI chat panel's and the voice control's buttons and Material glyphs
|
||||
// are the kit's: neither their templates nor the voice card and panel
|
||||
// layout buttons they render hand-write a <button> or a Material Symbols
|
||||
// span. Their other glyphs (the chat bubble, the globe, attach, send and
|
||||
// stop, expand and the two Back chevrons) are inline SVG drawn with their own
|
||||
// strokes, which no Material symbol the page loads draws the same, so they
|
||||
// stay SVG. The voice panel's Preview and Settings are tabs (`role="tab"`
|
||||
// with `aria-selected`), not pressed toggles, and DISMISS is a text button,
|
||||
// not a cross, so it is a UiButton rather than a UiCloseButton. The chat's
|
||||
// message box, file picker and the minutes field stay native: the kit has
|
||||
// no text area, file or number field. The voice modules build no controls
|
||||
// in script.
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync, readdirSync } from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
/** A view's template block: everything outside script, style and comments. */
|
||||
function template(file) {
|
||||
const source = readFileSync(
|
||||
new URL(`../views/panels/${file}`, import.meta.url),
|
||||
'utf8',
|
||||
);
|
||||
return source
|
||||
.replace(/<(script|style)\b[\s\S]*?<\/\1\s*>/g, '')
|
||||
.replace(/<!--[\s\S]*?-->/g, '');
|
||||
}
|
||||
// A tag's attributes, read past quoted values so a handler's `=>` does not
|
||||
// end the tag early.
|
||||
const ATTRS = String.raw`(?:[^>"']|"[^"]*"|'[^']*')*`;
|
||||
const tag = (pattern, flags = '') =>
|
||||
new RegExp(pattern.replaceAll('ATTRS', ATTRS), flags);
|
||||
const tags = (markup, name) =>
|
||||
markup.match(tag(String.raw`<${name}\bATTRS>`, 'g')) ?? [];
|
||||
|
||||
const views = {
|
||||
// Settings, the quick prompts, an attachment's remove, Attach layer,
|
||||
// Attach a file, Expand conversation, the command suggestions, Expand
|
||||
// chat, Add attachment and Send / Stop reply.
|
||||
'ChatPanel.vue': {
|
||||
UiButton: 10,
|
||||
UiCloseButton: 1,
|
||||
UiIcon: 1,
|
||||
UiSelect: 1,
|
||||
svgs: 5,
|
||||
},
|
||||
// The tier button (dock and panel), the mic, Open AI chat, Back to chat,
|
||||
// Back to voice, the Preview and Settings tabs and DISMISS.
|
||||
'VoiceControl.vue': {
|
||||
UiButton: 9,
|
||||
UiCloseButton: 1,
|
||||
UiIcon: 2,
|
||||
UiSelect: 3,
|
||||
UiCheckbox: 2,
|
||||
svgs: 3,
|
||||
},
|
||||
'VoiceCard.vue': { UiButton: 0, UiCloseButton: 1, UiIcon: 0, svgs: 0 },
|
||||
// Dock and minimize.
|
||||
'PanelLayoutButtons.vue': { UiButton: 2, UiIcon: 0, svgs: 2 },
|
||||
'VoiceVisualizer.vue': { UiButton: 0, UiIcon: 0, svgs: 1 },
|
||||
};
|
||||
const markup = Object.fromEntries(
|
||||
Object.keys(views).map((file) => [file, template(file)]),
|
||||
);
|
||||
|
||||
test('the chat and voice views hand-write no button; each is the kit', () => {
|
||||
for (const [file, counts] of Object.entries(views)) {
|
||||
assert.deepEqual(markup[file].match(/<button\b/gi) ?? [], [], file);
|
||||
for (const name of ['UiButton', 'UiCloseButton', 'UiSelect', 'UiCheckbox'])
|
||||
assert.equal(tags(markup[file], name).length, counts[name] ?? 0, file);
|
||||
}
|
||||
});
|
||||
|
||||
test('the pressed toggles take the kit pressed state', () => {
|
||||
for (const [file, view] of Object.entries(markup))
|
||||
assert.doesNotMatch(view, /aria-pressed/, file);
|
||||
const voice = tags(markup['VoiceControl.vue'], 'UiButton');
|
||||
const tiers = voice.filter((button) => /id="gev-voice-tier"/.test(button));
|
||||
assert.equal(tiers.length, 2);
|
||||
for (const tier of tiers)
|
||||
assert.match(tier, /\s:pressed="Boolean\(view\.tier\.pressed\)"/);
|
||||
// The mic writes no aria-pressed while its owner has no state for it.
|
||||
assert.match(
|
||||
markup['VoiceControl.vue'],
|
||||
tag(
|
||||
String.raw`<UiButton\s+id="gev-voice-button"ATTRS\s:pressed="view\.button\.pressed \?\? undefined"`,
|
||||
),
|
||||
);
|
||||
assert.match(
|
||||
markup['PanelLayoutButtons.vue'],
|
||||
tag(
|
||||
String.raw`<UiButton\s+data-layout-dockATTRS\s:pressed="props\.docked"`,
|
||||
),
|
||||
);
|
||||
// The panel tabs are tabs: selected, never pressed.
|
||||
const tabs = voice.filter((button) => /role="tab"/.test(button));
|
||||
assert.equal(tabs.length, 2);
|
||||
for (const button of tabs) {
|
||||
assert.match(button, /\s:aria-selected="/);
|
||||
assert.doesNotMatch(button, /\s:pressed=/);
|
||||
}
|
||||
});
|
||||
|
||||
test('the views hand-write no Material glyph; each is a UiIcon the site sizes', () => {
|
||||
for (const [file, { UiIcon, svgs }] of Object.entries(views)) {
|
||||
assert.deepEqual(markup[file].match(/material-symbols/g) ?? [], [], file);
|
||||
const icons = tags(markup[file], 'UiIcon');
|
||||
assert.equal(icons.length, UiIcon, file);
|
||||
// Without it the kit writes an 18px size that beats voice-cost.css and
|
||||
// voice-card.css.
|
||||
for (const icon of icons) assert.match(icon, /\s:size="null"/, file);
|
||||
assert.equal(markup[file].match(/<svg\b/g)?.length ?? 0, svgs, file);
|
||||
}
|
||||
assert.match(
|
||||
markup['ChatPanel.vue'],
|
||||
/<UiIcon name="settings" class="gev-voice-settings-icon" :size="null" \/>/,
|
||||
);
|
||||
assert.equal(
|
||||
markup['VoiceControl.vue'].match(
|
||||
/<UiIcon name="(?:visibility|settings)" class="gev-voice-panel-tab-icon" :size="null" \/>/g,
|
||||
)?.length,
|
||||
2,
|
||||
);
|
||||
});
|
||||
|
||||
test('the only native fields left are the message box, file picker and minutes', () => {
|
||||
const inputs = Object.values(markup).flatMap((view) => tags(view, 'input'));
|
||||
assert.equal(inputs.length, 2);
|
||||
assert.match(inputs[0], /id="gev-chat-file" type="file"/);
|
||||
assert.match(inputs[1], /id="gev-voice-timeout-input" type="number"/);
|
||||
assert.equal(tags(markup['ChatPanel.vue'], 'textarea').length, 1);
|
||||
for (const view of Object.values(markup)) {
|
||||
assert.deepEqual(view.match(/<select\b/gi) ?? [], []);
|
||||
assert.doesNotMatch(view, /type="(?:checkbox|range)"/);
|
||||
}
|
||||
});
|
||||
|
||||
test('the voice modules build no buttons or Material glyphs in script', () => {
|
||||
const root = fileURLToPath(new URL('../../voice/', import.meta.url));
|
||||
const modules = readdirSync(root, { recursive: true })
|
||||
.filter((file) => file.endsWith('.js') && !/test|Harness/.test(file))
|
||||
.map((file) => path.join(root, file));
|
||||
assert.ok(modules.length > 50);
|
||||
for (const file of modules) {
|
||||
const source = readFileSync(file, 'utf8');
|
||||
assert.doesNotMatch(source, /createElement\(\s*['"]button/, file);
|
||||
assert.doesNotMatch(source, /<button\b|material-symbols/, file);
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,126 @@
|
||||
// UTILITIES ▸ Draw (its toggle, Clear, the colour swatches and the drawn
|
||||
// shapes' rows), Import and the Street Level panel are on the kit: none of
|
||||
// them hand-writes a <button>, a Material Symbols span, a select, a checkbox
|
||||
// or a range. The Draw toggle is a pressed toggle with `active`. The colour
|
||||
// swatches are `role="radio"` buttons: they say they are chosen with
|
||||
// `aria-checked` and their own `active` class, never `aria-pressed`. A drawn
|
||||
// shape's show/hide renames itself (Show …, Hide …) rather than being pressed.
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync } from 'node:fs';
|
||||
|
||||
const source = (file) =>
|
||||
readFileSync(new URL(`../views/panels/${file}`, import.meta.url), 'utf8');
|
||||
/** A view's template block: everything outside script, style and comments. */
|
||||
const template = (file) =>
|
||||
source(file)
|
||||
.replace(/<(script|style)\b[\s\S]*?<\/\1\s*>/g, '')
|
||||
.replace(/<!--[\s\S]*?-->/g, '');
|
||||
// A tag's attributes, read past quoted values so a handler's `=>` does not
|
||||
// end the tag early.
|
||||
const ATTRS = String.raw`(?:[^>"']|"[^"]*"|'[^']*')*`;
|
||||
const tag = (pattern, flags = '') =>
|
||||
new RegExp(pattern.replaceAll('ATTRS', ATTRS), flags);
|
||||
const tags = (markup, name) =>
|
||||
markup.match(tag(String.raw`<${name}\bATTRS>`, 'g')) ?? [];
|
||||
|
||||
const views = {
|
||||
// Draw and Clear.
|
||||
'DrawControls.vue': { buttons: 2, icons: 1, closes: 0 },
|
||||
// The five colours, one v-for.
|
||||
'DrawSwatches.vue': { buttons: 1, icons: 0, closes: 0 },
|
||||
// A row's swatch, show/hide, the application's actions and fly to; remove
|
||||
// is a UiCloseButton.
|
||||
'DrawMarkList.vue': { buttons: 4, icons: 3, closes: 1 },
|
||||
// Import and a file's row actions.
|
||||
'GeoImport.vue': { buttons: 2, icons: 2, closes: 0 },
|
||||
// The status toggle, EXPAND and the nearest-imagery button; the viewer's
|
||||
// close. EXPAND's ⤢ ⤡ and the errors' ⚠ are text, not Material symbols.
|
||||
'StreetLevelPanel.vue': { buttons: 3, icons: 0, closes: 1 },
|
||||
};
|
||||
const markup = Object.fromEntries(
|
||||
Object.keys(views).map((file) => [file, template(file)]),
|
||||
);
|
||||
|
||||
test('the Draw, Import and Street Level views hand-write no button', () => {
|
||||
for (const [file, { buttons, closes }] of Object.entries(views)) {
|
||||
const html = markup[file];
|
||||
assert.deepEqual(html.match(/<button\b/gi) ?? [], [], file);
|
||||
assert.deepEqual(html.match(/<component\b/gi) ?? [], [], file);
|
||||
assert.equal(tags(html, 'UiButton').length, buttons, file);
|
||||
assert.equal(tags(html, 'UiCloseButton').length, closes, file);
|
||||
}
|
||||
});
|
||||
|
||||
test('they hand-write no select, checkbox or range', () => {
|
||||
for (const [file, html] of Object.entries(markup)) {
|
||||
assert.deepEqual(html.match(/<select\b/gi) ?? [], [], file);
|
||||
assert.doesNotMatch(
|
||||
html,
|
||||
tag(String.raw`<input\bATTRS\stype="(?:checkbox|range)"`),
|
||||
file,
|
||||
);
|
||||
}
|
||||
// SINCE is the kit's range.
|
||||
assert.equal(tags(markup['StreetLevelPanel.vue'], 'UiSlider').length, 1);
|
||||
});
|
||||
|
||||
test('they hand-write no Material glyph; each is a UiIcon sized by the site', () => {
|
||||
for (const [file, { icons }] of Object.entries(views)) {
|
||||
const html = markup[file];
|
||||
assert.deepEqual(html.match(/material-symbols-outlined/g) ?? [], [], file);
|
||||
const found = tags(html, 'UiIcon');
|
||||
assert.equal(found.length, icons, file);
|
||||
// Without it the kit writes an 18px size that beats the site rules.
|
||||
for (const icon of found) assert.match(icon, /\s:size="null"/, file);
|
||||
}
|
||||
// Draw's and Import's glyphs keep pp-icon, which sizes them.
|
||||
for (const file of ['DrawControls.vue', 'GeoImport.vue']) {
|
||||
const [icon] = tags(markup[file], 'UiIcon');
|
||||
assert.match(icon, /\sclass="pp-icon"/, file);
|
||||
}
|
||||
});
|
||||
|
||||
test('no tag hand-writes aria-pressed; Draw is a pressed toggle with active', () => {
|
||||
for (const [file, html] of Object.entries(markup))
|
||||
assert.doesNotMatch(
|
||||
html,
|
||||
tag(String.raw`<\w+\bATTRS\s:?aria-pressed`),
|
||||
file,
|
||||
);
|
||||
const [draw] = tags(markup['DrawControls.vue'], 'UiButton').filter((b) =>
|
||||
/\sid="draw-toggle"/.test(b),
|
||||
);
|
||||
assert.match(draw, /\s:pressed="draw\?\.active \?\? false"/);
|
||||
assert.match(draw, /\spressed-class="active"/);
|
||||
const [clear] = tags(markup['DrawControls.vue'], 'UiButton').filter((b) =>
|
||||
/\sid="draw-clear"/.test(b),
|
||||
);
|
||||
assert.doesNotMatch(clear, /\s:pressed=/);
|
||||
// A shape's show/hide says what it does in its name, not by being pressed.
|
||||
for (const button of tags(markup['DrawMarkList.vue'], 'UiButton'))
|
||||
assert.doesNotMatch(button, /\s:pressed=/);
|
||||
});
|
||||
|
||||
test('the colour swatches are radios chosen by aria-checked, never pressed', () => {
|
||||
const [swatch] = tags(markup['DrawSwatches.vue'], 'UiButton');
|
||||
assert.match(swatch, /\srole="radio"/);
|
||||
assert.match(
|
||||
swatch,
|
||||
/\s:aria-checked="String\(color === props\.modelValue\)"/,
|
||||
);
|
||||
assert.match(swatch, /\s:class="\{ active: color === props\.modelValue \}"/);
|
||||
assert.doesNotMatch(swatch, /\s:pressed=|\spressed-class=/);
|
||||
});
|
||||
|
||||
test('code that focuses a converted button reaches its element', () => {
|
||||
// A template ref on a component holds the component, not the button.
|
||||
assert.match(
|
||||
source('DrawSwatches.vue'),
|
||||
/:ref="\(swatch\) => \(buttons\[index\] = swatch\?\.\$el\)"/,
|
||||
);
|
||||
assert.match(
|
||||
source('GeoImport.vue'),
|
||||
/importButton\.value\?\.\$el\.focus\(\)/,
|
||||
);
|
||||
});
|
||||
@@ -0,0 +1,142 @@
|
||||
// The space missions, Contacts, Radio and provider settings controls are the
|
||||
// kit's: none of their views hand-writes a <button>, a Material Symbols span,
|
||||
// a select or a checkbox. Radio's Enable, the RTL-SDR card's Connect and its
|
||||
// FM and ADS-B modes are pressed toggles with `active`; Radio's Play and the
|
||||
// card's Locate keep their own `active` class, since their words change
|
||||
// with their state rather than saying they are pressed. The RTL-SDR card's
|
||||
// FM frequency stays a native number field (the kit has none), and the radio
|
||||
// tuner's range stays native: its owner moves the handle back to the
|
||||
// selected station on a drag's first input without changing the slot.
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync } from 'node:fs';
|
||||
|
||||
/** A view's template block: everything outside script, style and comments. */
|
||||
function template(file) {
|
||||
const source = readFileSync(
|
||||
new URL(`../views/${file}`, import.meta.url),
|
||||
'utf8',
|
||||
);
|
||||
return source
|
||||
.replace(/<(script|style)\b[\s\S]*?<\/\1\s*>/g, '')
|
||||
.replace(/<!--[\s\S]*?-->/g, '');
|
||||
}
|
||||
// A tag's attributes, read past quoted values so a handler's `=>` does not
|
||||
// end the tag early.
|
||||
const ATTRS = String.raw`(?:[^>"']|"[^"]*"|'[^']*')*`;
|
||||
const tag = (pattern, flags = '') =>
|
||||
new RegExp(pattern.replaceAll('ATTRS', ATTRS), flags);
|
||||
const tags = (markup, name) =>
|
||||
markup.match(tag(String.raw`<${name}\bATTRS>`, 'g')) ?? [];
|
||||
const byId = (markup, name, id) => {
|
||||
const found = tags(markup, name).filter((t) =>
|
||||
new RegExp(String.raw`\sid="${id}"`).test(t),
|
||||
);
|
||||
assert.equal(found.length, 1, id);
|
||||
return found[0];
|
||||
};
|
||||
|
||||
// Each view's UiButtons, UiCloseButtons, UiIcons, UiSelects and UiSliders.
|
||||
const VIEWS = {
|
||||
// FOCUS, REPLAY ASCENT, the replay's pause, PREV, NEXT and SHOW ALL; the
|
||||
// header's deselect and the replay's Cancel close.
|
||||
'panels/MissionDetail.vue': [6, 2, 0, 0, 1],
|
||||
// A mission's row.
|
||||
'panels/MissionRoster.vue': [1, 0, 0, 0, 0],
|
||||
'panels/MissionReplayOverlay.vue': [0, 0, 0, 0, 0],
|
||||
'panels/SpaceMissionsPanel.vue': [0, 0, 0, 0, 0],
|
||||
// PREV, FOCUS, NEXT and a contact's row.
|
||||
'panels/AwarenessPanel.vue': [4, 0, 0, 0, 0],
|
||||
'panels/AwarenessDirection.vue': [0, 0, 0, 0, 0],
|
||||
'panels/AwarenessNames.vue': [0, 0, 0, 0, 0],
|
||||
// Connect, Locate, Change device, FM, ADS-B, Tune and the two seeks.
|
||||
'panels/SdrCard.vue': [8, 0, 0, 1, 1],
|
||||
// Enable, PREV, PLAY, NEXT and STOP.
|
||||
'panels/RadioPanel.vue': [5, 0, 0, 1, 1],
|
||||
'panels/RadioTuner.vue': [0, 0, 0, 0, 0],
|
||||
// The POWER UP chip and its bolt, a key's REMOVE, the voice auth toggle
|
||||
// and SAVE KEYS; the dialog's close.
|
||||
'ProviderSettingsView.vue': [4, 1, 1, 0, 0],
|
||||
};
|
||||
const views = Object.entries(VIEWS).map(([file, counts]) => ({
|
||||
file,
|
||||
markup: template(file),
|
||||
counts,
|
||||
}));
|
||||
|
||||
test('they hand-write no button; each is a UiButton or UiCloseButton', () => {
|
||||
for (const { file, markup, counts } of views) {
|
||||
assert.deepEqual(markup.match(/<button\b/gi) ?? [], [], file);
|
||||
assert.deepEqual(markup.match(/<component\b/gi) ?? [], [], file);
|
||||
assert.equal(tags(markup, 'UiButton').length, counts[0], file);
|
||||
assert.equal(tags(markup, 'UiCloseButton').length, counts[1], file);
|
||||
}
|
||||
});
|
||||
|
||||
test('they hand-write no Material glyph; each is a UiIcon sized by its site', () => {
|
||||
for (const { file, markup, counts } of views) {
|
||||
assert.deepEqual(
|
||||
markup.match(/material-symbols-outlined/g) ?? [],
|
||||
[],
|
||||
file,
|
||||
);
|
||||
const icons = tags(markup, 'UiIcon');
|
||||
assert.equal(icons.length, counts[2], file);
|
||||
// Without it the kit writes an 18px size that beats the site rules.
|
||||
for (const icon of icons) assert.match(icon, /\s:size="null"/, file);
|
||||
}
|
||||
});
|
||||
|
||||
test('their selects and ranges are the kit’s, apart from the tuner', () => {
|
||||
for (const { file, markup, counts } of views) {
|
||||
assert.deepEqual(markup.match(/<select\b/gi) ?? [], [], file);
|
||||
assert.doesNotMatch(markup, /type="checkbox"/, file);
|
||||
assert.equal(tags(markup, 'UiSelect').length, counts[3], file);
|
||||
assert.equal(tags(markup, 'UiSlider').length, counts[4], file);
|
||||
const ranges = tags(markup, 'input').filter((i) =>
|
||||
/\stype="range"/.test(i),
|
||||
);
|
||||
assert.equal(ranges.length, file === 'panels/RadioTuner.vue' ? 1 : 0, file);
|
||||
}
|
||||
});
|
||||
|
||||
test('no tag hand-writes aria-pressed; the pressed toggles take :pressed', () => {
|
||||
const pressed = {
|
||||
'panels/MissionDetail.vue': 1,
|
||||
'panels/SdrCard.vue': 3,
|
||||
'panels/RadioPanel.vue': 1,
|
||||
};
|
||||
for (const { file, markup } of views) {
|
||||
assert.doesNotMatch(
|
||||
markup,
|
||||
tag(String.raw`<\w+\bATTRS\s(?:v-bind)?:?aria-pressed`),
|
||||
file,
|
||||
);
|
||||
const toggles = tags(markup, 'UiButton').filter((b) =>
|
||||
/\s:pressed=/.test(b),
|
||||
);
|
||||
assert.equal(toggles.length, pressed[file] ?? 0, file);
|
||||
}
|
||||
const sdr = views.find((v) => v.file === 'panels/SdrCard.vue').markup;
|
||||
const radio = views.find((v) => v.file === 'panels/RadioPanel.vue').markup;
|
||||
for (const [markup, id] of [
|
||||
[sdr, 'sdr-connect-btn'],
|
||||
[sdr, 'sdr-mode-fm-btn'],
|
||||
[sdr, 'sdr-mode-adsb-btn'],
|
||||
[radio, 'radio-enable-btn'],
|
||||
])
|
||||
assert.match(byId(markup, 'UiButton', id), /\spressed-class="active"/, id);
|
||||
});
|
||||
|
||||
test('Play and Locate keep their own active class rather than pressed', () => {
|
||||
const sdr = views.find((v) => v.file === 'panels/SdrCard.vue').markup;
|
||||
const radio = views.find((v) => v.file === 'panels/RadioPanel.vue').markup;
|
||||
for (const [markup, id] of [
|
||||
[radio, 'radio-play-btn'],
|
||||
[sdr, 'sdr-locate-btn'],
|
||||
]) {
|
||||
const button = byId(markup, 'UiButton', id);
|
||||
assert.doesNotMatch(button, /\s:pressed=/, id);
|
||||
assert.match(button, /\sv-class-toggle="\{ active: /, id);
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user