@@ -1363,11 +1363,11 @@ const vis = {
1363
1363
label: '%2',
1364
1364
kind: 'alu',
1365
1365
values: function* () {
1366
- let base = 0x1000000000000;
1366
+ let addr = 0x1000000000000;
1367
1367
while (true) {
1368
- const last = base ;
1369
- base += 4;
1370
- yield `0x${last.toString(16)}` ;
1368
+ const r = `0x${addr.toString(16)}` ;
1369
+ addr += 4;
1370
+ yield r ;
1371
1371
}
1372
1372
},
1373
1373
},
@@ -1387,11 +1387,13 @@ const vis = {
1387
1387
label: '%4',
1388
1388
kind: 'alu',
1389
1389
values: function* () {
1390
- let base = 0x2000000000000;
1390
+ const base = 0x2000000000000;
1391
+ let offset = 0;
1391
1392
while (true) {
1392
- const last = base;
1393
- base += 4;
1394
- yield `0x${last.toString(16)}`;
1393
+ const last = offset;
1394
+ offset += 4;
1395
+ // yield `0x${last.toString(16)}`;
1396
+ yield `0x20..${last.toString(16).padStart(2, '0')}`;
1395
1397
}
1396
1398
},
1397
1399
},
@@ -1479,7 +1481,10 @@ const vis = {
1479
1481
reject('el not found');
1480
1482
});
1481
1483
1482
- // TODO: we should hoist state into the DOM and update it instead of react-style re-rendering, but...
1484
+ // TODO: we should hoist state into the DOM and update it instead of react-style re-rendering
1485
+ // but:
1486
+ // 1. where do we put `gen` (the current state for the value generator)? That's assuming it's even worth keeping
1487
+ // 2. for wip purposes, it's convenient to have a thing that knows how to render any state, and oh look I accidentally a react.
1483
1488
function updateModule() {
1484
1489
if (state.cur >= ops.length) return;
1485
1490
if (!state.gen) state.gen = ops[state.cur]!.values();
@@ -1491,11 +1496,18 @@ const vis = {
1491
1496
// TODO we really want something like this for a `<text>`, don't we?
1492
1497
// or maybe for every result to be its own `g` so we can add a child?
1493
1498
// el.insertAdjacentElement()
1494
-
1495
- // TODO oh of course (?) this blows up with:
1496
- // Uncaught HierarchyRequestError: Failed to execute 'appendChild' on 'Node': Nodes of type 'title' may not be inserted inside nodes of type 'rect'.
1497
1499
const titleEl = el.appendChild(document.createElementNS('http://www.w3.org/2000/svg', 'title'));
1498
1500
titleEl.textContent = state.gen.next().value || 'uh oh'; // TODO
1501
+
1502
+ // seems like there's a few problems to solve:
1503
+ // 1. how wide does this result need to be now (we lose fixed width)
1504
+ // -> do we need to "re-flow" everything to the right?
1505
+ // -> should we be using SVG for this at all, then, if we're gonna be doing that?
1506
+ // 2. where do we put the <text> ? we can center it on the result's center,
1507
+ // as long as we know we'll fit (see above)
1508
+ // 3. how do we make the label accessible, without needing to supply an ID for every
1509
+ // sub-result (or do we just generate one based on the indexes?)
1510
+ // cf. https://www.scottohara.me/blog/2019/05/22/contextual-images-svgs-and-a11y.html
1499
1511
}
1500
1512
}
1501
1513
@@ -1539,6 +1551,7 @@ const vis = {
1539
1551
const gEl = opSvg.appendChild(document.createElementNS('http://www.w3.org/2000/svg', 'g'));
1540
1552
gEl.classList.add('results');
1541
1553
1554
+ const gen = op.values();
1542
1555
// <rect width =" 20" height =" 20" x =" 20" y =" 80 + ..." class =" result dispatched completed" ></rect >
1543
1556
for (var i = 0; i < parseInt (svgEl.dataset.lanes || ''); i ++) {
1544
1557
const resEl = gEl .appendChild (document .createElementNS (' http://www.w3.org/2000/svg' , ' rect' ));
@@ -1547,9 +1560,21 @@ const vis = {
1547
1560
resEl .setAttribute (' width' , ' 20' );
1548
1561
resEl .setAttribute (' height' , ' 20' );
1549
1562
resEl .classList .add (' result' );
1550
- if (idx < state .cur || (idx == state .cur && state .last [i ] == ' completed' ))
1551
- resEl .classList .add (' completed' );
1552
1563
if (idx <= state .cur ) resEl .classList .add (' dispatched' );
1564
+ if (idx < state .cur || (idx == state .cur && state .last [i ] == ' completed' )) {
1565
+ resEl .classList .add (' completed' );
1566
+ const titleEl = resEl .appendChild (
1567
+ document .createElementNS (' http://www.w3.org/2000/svg' , ' title' )
1568
+ );
1569
+ titleEl .textContent = gen .next ().value || ' oh no, generator ran out of values' ;
1570
+ const textEl = gEl .appendChild (document .createElementNS (' http://www.w3.org/2000/svg' , ' text' ));
1571
+
1572
+ textEl .setAttribute (' x' , ' 30' );
1573
+ textEl .setAttribute (' y' , ` ${80 + 30 * i + 10 }px ` );
1574
+ textEl .setAttribute (' dominant-baseline' , ' middle' );
1575
+ textEl .setAttribute (' text-anchor' , ' middle' );
1576
+ textEl .textContent = titleEl .textContent ;
1577
+ }
1553
1578
}
1554
1579
1555
1580
return opSvg ;
@@ -1575,7 +1600,7 @@ const vis = {
1575
1600
1576
1601
transform-box: fill-box;
1577
1602
transform-origin: center;
1578
- transform: rotate(45deg);
1603
+ /* transform: rotate(45deg); */
1579
1604
}
1580
1605
1581
1606
circle {
0 commit comments