xref: /wasmtime-44.0.1/docs/js/index.js (revision 2de55ccf)
1const WASMTIME_20 = moment.utc('2024-04-20');
2const DATE_FORMAT = 'MMMM D YYYY';
3
4function releaseDate(version) {
5  return WASMTIME_20.clone().add(version - 20, 'months');
6}
7
8function eolDate(version) {
9  const release = releaseDate(version);
10  if (version % 12 == 0)
11    return release.add(2, 'year');
12  return release.add(2, 'months');
13}
14
15function addReleases(table) {
16  const today = moment.utc();
17  const monthsSince20 = Math.floor(today.diff(WASMTIME_20, 'months'));
18  const currentRelease = 20 + monthsSince20;
19
20  // Add in some relevant releases, such as the current one, one future one, and
21  // two past ones.
22  let channels = [];
23  channels.push(currentRelease + 1);
24  channels.push(currentRelease);
25  channels.push(currentRelease - 1);
26  channels.push(currentRelease - 2);
27
28  // Add in historical LTS channels. Start with the current release and go
29  // backwards looking for two LTS channels.
30  let lts = 0;
31  let cur = currentRelease;
32  for (let cur = currentRelease; cur > 20 && lts < 2; cur--) {
33    if (cur % 12 == 0) {
34      channels.push(cur);
35      lts += 1;
36    }
37  }
38
39  // Add in a future LTS channel starting with the release after the current
40  // one.
41  for (let cur = currentRelease + 1; ; cur++) {
42    if (cur % 12 == 0) {
43      channels.push(cur);
44      break;
45    }
46  }
47
48  // Deduplicate and sort everything.
49  channels = [...new Set(channels)];
50  channels.sort();
51
52let mermaid = `
53gantt
54    tickInterval 12month
55    title Release Schedule
56    dateFormat  YYYY-MM
57`;
58
59  for (let channel of channels) {
60    const row = document.createElement('tr');
61    const date = releaseDate(channel);
62    const eol = eolDate(channel);
63
64    if (date <= today && today <= eol)
65      row.style.fontWeight = 'bold';
66
67    const version = document.createElement('td');
68    version.innerText = channel + '.0.0';
69    row.appendChild(version);
70
71    const lts = document.createElement('td');
72    if (channel % 12 == 0)
73      lts.innerText = '✅';
74    row.appendChild(lts);
75
76    const branch = document.createElement('td');
77    branch.innerText = date.clone().add(-15, 'days').format(DATE_FORMAT);
78    row.appendChild(branch);
79
80    const release = document.createElement('td');
81    release.innerText = date.format(DATE_FORMAT);
82    row.appendChild(release);
83
84    const eolRow = document.createElement('td');
85    eolRow.innerText = eol.format(DATE_FORMAT);
86    row.appendChild(eolRow);
87
88    dur = eol.diff(date, 'days')
89    mermaid += `    ${channel}.0.0    :a1, ${date.format('YYYY-MM-DD')}, ${dur}d\n`;
90
91    table.appendChild(row);
92  }
93
94  const gantt = document.createElement('pre');
95  gantt.classList.add('mermaid');
96  gantt.innerHTML = mermaid;
97  document.querySelector('#version-table').appendChild(gantt);
98}
99
100const table = document.querySelector('#version-table table tbody');
101if (table) {
102  addReleases(table);
103  mermaid.initialize({ theme: 'dark' });
104}
105