Skip to content

Commit

Permalink
Sort features by phase and date
Browse files Browse the repository at this point in the history
In-progress proposals are sorted manually according to their start date.

Also includes some refactor required to do this properly.
  • Loading branch information
andylizi committed May 11, 2023
1 parent 6f2ff8f commit d2d90a4
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 60 deletions.
46 changes: 23 additions & 23 deletions features.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
"stdznDate": "2021-02-10",
"specVersion": "2.0"
},
"gc": {
"description": "Garbage collection",
"url":"https://github.com/WebAssembly/gc/blob/main/proposals/gc/Overview.md",
"phase": 3
},
"exceptions": {
"description": "Exception handling",
"url": "https://github.com/WebAssembly/exception-handling/blob/master/proposals/exception-handling/Exceptions.md",
Expand All @@ -27,21 +32,26 @@
"stdznDate": "2023-01-31",
"specVersion": "2.0"
},
"gc": {
"description": "Garbage collection",
"url":"https://github.com/WebAssembly/gc",
"threads": {
"description": "Threads and atomics",
"url": "https://github.com/WebAssembly/threads/blob/master/proposals/threads/Overview.md",
"phase": 3
},
"memory64": {
"description": "Memory64",
"url": "https://github.com/WebAssembly/memory64/blob/master/proposals/memory64/Overview.md",
"typeReflection": {
"description": "Type reflection",
"url": "https://github.com/WebAssembly/js-types/blob/main/proposals/js-types/Overview.md",
"phase": 3
},
"multiMemory": {
"description": "Multiple memories",
"url": "https://github.com/WebAssembly/multi-memory/blob/master/proposals/multi-memory/Overview.md",
"phase": 3
},
"memory64": {
"description": "Memory64",
"url": "https://github.com/WebAssembly/memory64/blob/master/proposals/memory64/Overview.md",
"phase": 3
},
"multiValue": {
"description": "Multi-value",
"url": "https://github.com/WebAssembly/spec/blob/master/proposals/multi-value/Overview.md",
Expand All @@ -68,16 +78,16 @@
"url": "https://github.com/WebAssembly/relaxed-simd/blob/main/proposals/relaxed-simd/Overview.md",
"phase": 3
},
"saturatedFloatToInt": {
"description": "Non-trapping float-to-int conversions",
"url": "https://github.com/WebAssembly/spec/blob/master/proposals/nontrapping-float-to-int-conversion/Overview.md",
"signExtensions": {
"description": "Sign-extension operations",
"url": "https://github.com/WebAssembly/spec/blob/master/proposals/sign-extension-ops/Overview.md",
"phase": 5,
"stdznDate": "2020-03-11",
"specVersion": "2.0"
},
"signExtensions": {
"description": "Sign-extension operations",
"url": "https://github.com/WebAssembly/spec/blob/master/proposals/sign-extension-ops/Overview.md",
"saturatedFloatToInt": {
"description": "Non-trapping float-to-int conversions",
"url": "https://github.com/WebAssembly/spec/blob/master/proposals/nontrapping-float-to-int-conversion/Overview.md",
"phase": 5,
"stdznDate": "2020-03-11",
"specVersion": "2.0"
Expand All @@ -95,16 +105,6 @@
"phase": 4,
"stdznDate": "2023-01-17",
"specVersion": "2.0"
},
"threads": {
"description": "Threads and atomics",
"url": "https://github.com/WebAssembly/threads/blob/master/proposals/threads/Overview.md",
"phase": 3
},
"typeReflection": {
"description": "Type reflection",
"url": "https://github.com/WebAssembly/js-types/blob/main/proposals/js-types/Overview.md",
"phase": 3
}
},
"browsers": {
Expand Down Expand Up @@ -206,7 +206,7 @@
"simd": "1.9",
"tailCall": ["flag", "Requires flag `--v8-flags=--experimental-wasm-return-call`"],
"threads": "1.9",
"typeReflection": ["flag", "Requires corresponding v8 flag (`--v8-flags=\"...\"`)"]
"typeReflection": ["flag", "Requires flag `--v8-flags=--experimental-wasm-type-reflection`"]
}
},
"Wasmtime": {
Expand Down
71 changes: 34 additions & 37 deletions roadmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,13 @@ const __feature_table_error_handler = (e) => {
);

let featureGroups = partitionArray(
Object.entries(features).map(([name, feature]) => Object.assign(feature, { name })),
Object.entries(features)
.map(([name, feature]) => Object.assign(feature, { name }))
.sort((a, b) => { // Sort by phase descending then date ascending
let i;
if (i = b.phase - a.phase) return i;
return (a.stdznDate || '9999-99-99').localeCompare(b.stdznDate || '9999-99-99')
}),
feature => feature.phase >= 4
);

Expand All @@ -95,37 +101,24 @@ const __feature_table_error_handler = (e) => {
{ name: 'In-progress proposals', features: featureGroups.unmatched },
];

// Collect all notes and assign an index to each unique item
// { "First unique note": 0, "Second unique note": 1, ...}
// Collect all footnotes
const notes = Object.values(browsers).flatMap(b =>
Object.values(b.features)
.filter(s => Array.isArray(s))
.map(s => s[1])
);
const note2index = new Map();
let noteIndex = 0;
for (const note of notes) {
if (!note2index.has(note)) {
note2index.set(note, noteIndex++);
}
}
const noteCache = new Map();
let nextNoteId = 0;

// Generate the footnote list. They are later referenced in the actual table.
// List containing all footnotes
const noteList = document.createElement('ol');
// Place footnote list outside of the scolling area
scrollbox.parentNode.insertBefore(noteList, scrollbox.nextSibling);
for (const [note, index] of note2index) {
const item = h('li', { id: `feature-note-${index}` });
noteList.appendChild(item).appendChild(renderNote(note));
}

// Create an <a> element that links to the specified footnote.
// Also returns the HTML id of the footnote it refers to.
function createNoteRef(index) {
const id = `feature-note-${index}`;
return [id, h('a', { href: `#${id}` }, [`[${toAlphabet(index)}]`])];
}

// Clip the tooltips to both <tbody> and the scrollbox.
// the former is to avoid blocking out the headers;
// the latter is to keep the tooltip inside the scrollable area
const tooltipBoundary = [tBody, scrollbox];
const columnCount = 2 + Object.keys(browsers).length;

for (const { name: groupName, features } of featureGroups) {
Expand Down Expand Up @@ -155,11 +148,11 @@ const __feature_table_error_handler = (e) => {
detectWasmFeature(feat.name).then(supported => {
detectResult.textContent = '';
detectResult.appendChild(buildCellInner(supported ? 'yes' : 'no'));
return addTooltip(detectResult, supported ? '✓ Supported' : '✗ Not supported', [tBody, scrollbox]);
return addTooltip(detectResult, supported ? '✓ Supported' : '✗ Not supported', tooltipBoundary);
}, _err => {
detectResult.textContent = '';
detectResult.appendChild(buildCellInner('unknown'));
return addTooltip(detectResult, 'Detection unavailable for this feature', [tBody, scrollbox]);
return addTooltip(detectResult, 'Detection unavailable for this feature', tooltipBoundary);
});

// Feature name and it's tooltip
Expand Down Expand Up @@ -236,23 +229,27 @@ const __feature_table_error_handler = (e) => {
icon.removeAttribute('aria-label');
}

if (note && note2index.has(note)) {
if (note && notes.includes(note)) {
cell.tabIndex = 0; // focusable
const index = note2index.get(note);
const [noteId, refLink] = createNoteRef(index);
box.appendChild(h('sup', {}, [refLink]));

const noteItem = document.getElementById(noteId);
if (noteItem) {
cell.addEventListener('mouseenter', () => noteItem.classList.add('ref-highlight'));
cell.addEventListener('mouseleave', () => noteItem.classList.remove('ref-highlight'));

// If we already have a <li> associated with this note, just use that.
let cache = noteCache.get(note);
if (!cache) {
const index = nextNoteId++;
const item = h('li', { id: `feature-note-${index}` });
noteCache.set(note, cache = { index, item });
noteList.appendChild(item).appendChild(renderNote(note));
}

const { index, item } = cache;
const noteRef = h('a', { href: `#${item.id}` }, [`[${toAlphabet(index)}]`]);
box.appendChild(h('sup', {}, [noteRef]));

cell.addEventListener('mouseenter', () => item.classList.add('ref-highlight'));
cell.addEventListener('mouseleave', () => item.classList.remove('ref-highlight'));
}

// Clip to both <tbody> and the scrollbox.
// the former is to avoid blocking out the headers;
// the latter is to keep the tooltip inside the scrollable area
addTooltip(cell, note, [tBody, scrollbox]);
addTooltip(cell, note, tooltipBoundary);
return cell;
})
])
Expand Down

0 comments on commit d2d90a4

Please sign in to comment.