@yuneta/gobj-ui 7.23.111 → 7.23.113
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/dist/gobj-ui.cjs.js +136 -79
- package/dist/gobj-ui.es.js +136 -79
- package/package.json +1 -1
- package/src/c_yui_form.js +9 -6
- package/src/c_yui_nav.js +4 -1
- package/src/c_yui_treedb_topic_with_form.js +7 -1
- package/src/lib_maplibre.js +6 -0
- package/src/yui_dev.js +95 -59
package/src/yui_dev.js
CHANGED
|
@@ -31,7 +31,7 @@ import * as gobj_js from "@yuneta/gobj-js";
|
|
|
31
31
|
|
|
32
32
|
import {log_signature, log_is_periodic} from "./dev_machine_trace.js";
|
|
33
33
|
|
|
34
|
-
import i18next from 'i18next';
|
|
34
|
+
import i18next, {t} from 'i18next';
|
|
35
35
|
|
|
36
36
|
/***********************************************************************
|
|
37
37
|
* Traffic model (bounded ring buffer)
|
|
@@ -62,14 +62,18 @@ const TRAFFIC_TS_FIELDS = {
|
|
|
62
62
|
};
|
|
63
63
|
|
|
64
64
|
/* Trace toggles: [localStorage key, display label, handler]. */
|
|
65
|
+
/* `data-label` carries the i18n KEY and not the text: the chips are
|
|
66
|
+
* repainted from it by `refresh_dev_chrome()` on every toggle, so a
|
|
67
|
+
* label translated once at build time would come back in English at
|
|
68
|
+
* the first click. */
|
|
65
69
|
const TRACE_DEFS = [
|
|
66
|
-
["trace_automata", "
|
|
67
|
-
["trace_creation", "
|
|
68
|
-
["trace_start_stop", "
|
|
69
|
-
["trace_subscriptions", "
|
|
70
|
-
["trace_i18n", "
|
|
71
|
-
["trace_traffic", "
|
|
72
|
-
["no_poll", "
|
|
70
|
+
["trace_automata", "automata", trace_automata],
|
|
71
|
+
["trace_creation", "creation", trace_creation],
|
|
72
|
+
["trace_start_stop", "start / stop", trace_start_stop],
|
|
73
|
+
["trace_subscriptions", "subscriptions", trace_subscriptions],
|
|
74
|
+
["trace_i18n", "i18n", trace_i18n],
|
|
75
|
+
["trace_traffic", "traffic", trace_traffic],
|
|
76
|
+
["no_poll", "no poll", set_no_poll],
|
|
73
77
|
];
|
|
74
78
|
|
|
75
79
|
|
|
@@ -703,7 +707,10 @@ function traffic_bullets(obj)
|
|
|
703
707
|
/* A small mute affordance that silences this signature (persistent). */
|
|
704
708
|
function mute_button(sig)
|
|
705
709
|
{
|
|
706
|
-
|
|
710
|
+
/* `t('mute this message')` and not `'Mute ' + sig`: a composed
|
|
711
|
+
* title is no i18n key, and the row already says which message. */
|
|
712
|
+
return ['button', {class: 'TRAFFIC_MUTE', type: 'button',
|
|
713
|
+
title: t('mute this message'), 'data-i18n-title': 'mute this message'}, '⊘', {
|
|
707
714
|
click: (ev) => {
|
|
708
715
|
ev.stopPropagation();
|
|
709
716
|
ev.preventDefault();
|
|
@@ -1328,7 +1335,7 @@ function refresh_dev_chrome()
|
|
|
1328
1335
|
{
|
|
1329
1336
|
document.querySelectorAll('.YDEV_CHIP[data-trace]').forEach(($b) => {
|
|
1330
1337
|
let key = $b.getAttribute('data-trace');
|
|
1331
|
-
let label = $b.getAttribute('data-label') || '';
|
|
1338
|
+
let label = t($b.getAttribute('data-label') || '');
|
|
1332
1339
|
let v = dev_num(key, 0);
|
|
1333
1340
|
$b.textContent = (key === "trace_automata" && v > 0) ? (label + " " + v) : label;
|
|
1334
1341
|
$b.classList.toggle('is-active', v > 0);
|
|
@@ -1373,11 +1380,13 @@ function refresh_dev_chrome()
|
|
|
1373
1380
|
if(set.size) {
|
|
1374
1381
|
let $lbl = document.createElement('span');
|
|
1375
1382
|
$lbl.className = 'YDEV_LABEL';
|
|
1376
|
-
$lbl.textContent = '
|
|
1383
|
+
$lbl.textContent = t('muted');
|
|
1384
|
+
$lbl.setAttribute('data-i18n', 'muted');
|
|
1377
1385
|
$m.appendChild($lbl);
|
|
1378
1386
|
set.forEach((sig) => {
|
|
1379
1387
|
$m.appendChild(createElement2(
|
|
1380
|
-
['button', {class: 'YDEV_MUTED_CHIP', type: 'button',
|
|
1388
|
+
['button', {class: 'YDEV_MUTED_CHIP', type: 'button',
|
|
1389
|
+
title: t('unmute'), 'data-i18n-title': 'unmute'},
|
|
1381
1390
|
'⊘ ' + sig + ' ✕', {
|
|
1382
1391
|
click: (ev) => {
|
|
1383
1392
|
ev.stopPropagation();
|
|
@@ -1457,9 +1466,10 @@ function dev_fallback_copy(text)
|
|
|
1457
1466
|
* periodic filters, free-text search, copy, clear. Returns an element. */
|
|
1458
1467
|
function build_control_bar()
|
|
1459
1468
|
{
|
|
1460
|
-
let trace_chips = TRACE_DEFS.map(([key,
|
|
1461
|
-
class: 'YDEV_CHIP', 'data-trace': key, 'data-label':
|
|
1462
|
-
|
|
1469
|
+
let trace_chips = TRACE_DEFS.map(([key, label_key, fn]) => ['button', {
|
|
1470
|
+
class: 'YDEV_CHIP', 'data-trace': key, 'data-label': label_key,
|
|
1471
|
+
'data-i18n': label_key, type: 'button',
|
|
1472
|
+
}, t(label_key), {
|
|
1463
1473
|
click: (ev) => {
|
|
1464
1474
|
ev.stopPropagation();
|
|
1465
1475
|
fn();
|
|
@@ -1471,10 +1481,9 @@ function build_control_bar()
|
|
|
1471
1481
|
* emitted while Automata is on. */
|
|
1472
1482
|
let simple_mach = ['button', {
|
|
1473
1483
|
class: 'YDEV_CHIP', 'data-toggle': 'automata-simple', type: 'button',
|
|
1474
|
-
title: '
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
}, 'Simple mach', {
|
|
1484
|
+
title: t('machine trace shape'), 'data-i18n-title': 'machine trace shape',
|
|
1485
|
+
'data-i18n': 'simple mach',
|
|
1486
|
+
}, t('simple mach'), {
|
|
1478
1487
|
click: (ev) => {
|
|
1479
1488
|
ev.stopPropagation();
|
|
1480
1489
|
let v = dev_simple_mach() ? 0 : 1;
|
|
@@ -1484,7 +1493,8 @@ function build_control_bar()
|
|
|
1484
1493
|
}
|
|
1485
1494
|
}];
|
|
1486
1495
|
|
|
1487
|
-
let mk_view = (v, label) => ['button', {class: 'YDEV_SEG_BTN', 'data-view': v,
|
|
1496
|
+
let mk_view = (v, label) => ['button', {class: 'YDEV_SEG_BTN', 'data-view': v,
|
|
1497
|
+
'data-i18n': label, type: 'button'}, t(label), {
|
|
1488
1498
|
click: (ev) => {
|
|
1489
1499
|
ev.stopPropagation();
|
|
1490
1500
|
set_view(v);
|
|
@@ -1492,53 +1502,62 @@ function build_control_bar()
|
|
|
1492
1502
|
}];
|
|
1493
1503
|
|
|
1494
1504
|
let view_seg = ['div', {class: 'YDEV_SEG', id: 'ydev-seg'}, [
|
|
1495
|
-
mk_view('detailed', '
|
|
1496
|
-
mk_view('full', '
|
|
1497
|
-
mk_view('compact', '
|
|
1498
|
-
mk_view('name', '
|
|
1505
|
+
mk_view('detailed', 'detailed'),
|
|
1506
|
+
mk_view('full', 'expanded'),
|
|
1507
|
+
mk_view('compact', 'compact'),
|
|
1508
|
+
mk_view('name', 'name only'),
|
|
1499
1509
|
]];
|
|
1500
1510
|
|
|
1501
1511
|
/* Output routing: send traffic + all logs + automata to the dev window,
|
|
1502
1512
|
* the browser console, or both. */
|
|
1503
1513
|
let OUT_TITLES = {
|
|
1504
|
-
window: '
|
|
1505
|
-
console: '
|
|
1506
|
-
both: '
|
|
1514
|
+
window: 'dev window only',
|
|
1515
|
+
console: 'browser console only',
|
|
1516
|
+
both: 'dev window and browser console',
|
|
1507
1517
|
};
|
|
1508
1518
|
let mk_out = (v, label) => ['button', {
|
|
1509
|
-
class: 'YDEV_SEG_BTN', 'data-output': v, type: 'button',
|
|
1510
|
-
|
|
1519
|
+
class: 'YDEV_SEG_BTN', 'data-output': v, type: 'button',
|
|
1520
|
+
title: t(OUT_TITLES[v]), 'data-i18n-title': OUT_TITLES[v],
|
|
1521
|
+
'data-i18n': label,
|
|
1522
|
+
}, t(label), {
|
|
1511
1523
|
click: (ev) => {
|
|
1512
1524
|
ev.stopPropagation();
|
|
1513
1525
|
set_output_route(v);
|
|
1514
1526
|
}
|
|
1515
1527
|
}];
|
|
1516
1528
|
let output_seg = ['div', {class: 'YDEV_SEG', id: 'ydev-output'}, [
|
|
1517
|
-
mk_out('window', '
|
|
1518
|
-
mk_out('console', '
|
|
1519
|
-
mk_out('both', '
|
|
1529
|
+
mk_out('window', 'window'),
|
|
1530
|
+
mk_out('console', 'console'),
|
|
1531
|
+
mk_out('both', 'both'),
|
|
1520
1532
|
]];
|
|
1521
1533
|
|
|
1522
1534
|
/* Expanded-view section toggles (only meaningful in the 'full' view;
|
|
1523
1535
|
* the group is shown/hidden by refresh_dev_chrome). */
|
|
1536
|
+
/* The title says WHAT it does and not which section: composing
|
|
1537
|
+
* `'Show ' + label + '...'` gives a string that is no i18n key, so
|
|
1538
|
+
* it could never re-translate -- and the button's own label is the
|
|
1539
|
+
* section anyway. */
|
|
1524
1540
|
let mk_expand = (key, label) => ['button', {
|
|
1525
1541
|
class: 'YDEV_CHIP', 'data-expand': key, type: 'button',
|
|
1526
|
-
title: '
|
|
1527
|
-
|
|
1542
|
+
title: t('show this section in the expanded view'),
|
|
1543
|
+
'data-i18n-title': 'show this section in the expanded view',
|
|
1544
|
+
'data-i18n': label,
|
|
1545
|
+
}, t(label), {
|
|
1528
1546
|
click: (ev) => {
|
|
1529
1547
|
ev.stopPropagation();
|
|
1530
1548
|
toggle_pref(key, (key === 'dev_full_data') ? 1 : 0);
|
|
1531
1549
|
}
|
|
1532
1550
|
}];
|
|
1533
1551
|
let expand_grp = ['div', {class: 'YDEV_GROUP', id: 'ydev-expand-grp'}, [
|
|
1534
|
-
['span', {class: 'YDEV_LABEL'}, '
|
|
1535
|
-
mk_expand('dev_full_schema', '
|
|
1536
|
-
mk_expand('dev_full_data', '
|
|
1537
|
-
mk_expand('dev_full_meta', '
|
|
1552
|
+
['span', {class: 'YDEV_LABEL', 'data-i18n': 'expand'}, t('expand')],
|
|
1553
|
+
mk_expand('dev_full_schema', 'schema'),
|
|
1554
|
+
mk_expand('dev_full_data', 'data'),
|
|
1555
|
+
mk_expand('dev_full_meta', 'metadata'),
|
|
1538
1556
|
]];
|
|
1539
1557
|
|
|
1540
1558
|
let mk_dir = (dir, glyph, key, title) => ['button', {
|
|
1541
|
-
class: 'YDEV_CHIP s-' + dir, 'data-dir': key, type: 'button',
|
|
1559
|
+
class: 'YDEV_CHIP s-' + dir, 'data-dir': key, type: 'button',
|
|
1560
|
+
title: t(title), 'data-i18n-title': title,
|
|
1542
1561
|
}, glyph, {
|
|
1543
1562
|
click: (ev) => {
|
|
1544
1563
|
ev.stopPropagation();
|
|
@@ -1547,16 +1566,23 @@ function build_control_bar()
|
|
|
1547
1566
|
}];
|
|
1548
1567
|
|
|
1549
1568
|
let dir_chips = [
|
|
1550
|
-
mk_dir('out', '⇢', 'dev_filter_out', '
|
|
1551
|
-
mk_dir('in', '⇠', 'dev_filter_in', '
|
|
1552
|
-
mk_dir('err', '⚠', 'dev_filter_err', '
|
|
1569
|
+
mk_dir('out', '⇢', 'dev_filter_out', 'outgoing'),
|
|
1570
|
+
mk_dir('in', '⇠', 'dev_filter_in', 'incoming'),
|
|
1571
|
+
mk_dir('err', '⚠', 'dev_filter_err', 'errors'),
|
|
1553
1572
|
];
|
|
1554
1573
|
|
|
1555
1574
|
let periodic_chip = ['button', {
|
|
1556
1575
|
class: 'YDEV_CHIP', 'data-toggle': 'periodic', type: 'button',
|
|
1557
|
-
title: '
|
|
1558
|
-
|
|
1559
|
-
},
|
|
1576
|
+
title: t('hide the timers and the recurring traffic'),
|
|
1577
|
+
'data-i18n-title': 'hide the timers and the recurring traffic',
|
|
1578
|
+
}, [
|
|
1579
|
+
/* The glyph is its own element so the label beside it can carry
|
|
1580
|
+
* its key: `refresh_language()` replaces the FIRST text node of
|
|
1581
|
+
* the element that carries `data-i18n`, and that would have
|
|
1582
|
+
* eaten the glyph with the word. */
|
|
1583
|
+
['span', {class: 'YDEV_GLYPH'}, '⊘'],
|
|
1584
|
+
['span', {'data-i18n': 'periodic'}, t('periodic')]
|
|
1585
|
+
], {
|
|
1560
1586
|
click: (ev) => {
|
|
1561
1587
|
ev.stopPropagation();
|
|
1562
1588
|
toggle_pref('dev_hide_periodic', HIDE_PERIODIC_DEFAULT);
|
|
@@ -1564,7 +1590,9 @@ function build_control_bar()
|
|
|
1564
1590
|
}];
|
|
1565
1591
|
|
|
1566
1592
|
let search = ['input', {
|
|
1567
|
-
class: 'YDEV_SEARCH', type: 'search',
|
|
1593
|
+
class: 'YDEV_SEARCH', type: 'search', 'data-role': 'search',
|
|
1594
|
+
placeholder: t('filter events / payload'),
|
|
1595
|
+
'data-i18n-placeholder': 'filter events / payload',
|
|
1568
1596
|
}, '', {
|
|
1569
1597
|
input: (ev) => {
|
|
1570
1598
|
SEARCH_TEXT = String(ev.target.value || '').toLowerCase().trim();
|
|
@@ -1572,35 +1600,42 @@ function build_control_bar()
|
|
|
1572
1600
|
}
|
|
1573
1601
|
}];
|
|
1574
1602
|
|
|
1575
|
-
let copy = ['button', {class: 'YDEV_CHIP', type: 'button',
|
|
1603
|
+
let copy = ['button', {class: 'YDEV_CHIP', type: 'button',
|
|
1604
|
+
title: t('copy visible traffic to clipboard'),
|
|
1605
|
+
'data-i18n-title': 'copy visible traffic to clipboard',
|
|
1606
|
+
'data-i18n': 'copy'}, t('copy'), {
|
|
1576
1607
|
click: (ev) => {
|
|
1577
1608
|
ev.stopPropagation();
|
|
1578
1609
|
let btn = ev.currentTarget;
|
|
1579
1610
|
dev_copy_text(traffic_to_text()).then(() => {
|
|
1580
1611
|
let prev = btn.textContent;
|
|
1581
|
-
btn.textContent = '
|
|
1612
|
+
btn.textContent = t('copied');
|
|
1582
1613
|
setTimeout(() => { btn.textContent = prev; }, 1000);
|
|
1583
1614
|
});
|
|
1584
1615
|
}
|
|
1585
1616
|
}];
|
|
1586
1617
|
|
|
1587
|
-
let clear = ['button', {class: 'YDEV_CHIP', type: 'button',
|
|
1618
|
+
let clear = ['button', {class: 'YDEV_CHIP', type: 'button',
|
|
1619
|
+
title: t('clear captured traffic'),
|
|
1620
|
+
'data-i18n-title': 'clear captured traffic',
|
|
1621
|
+
'data-i18n': 'clear'}, t('clear'), {
|
|
1588
1622
|
click: (ev) => {
|
|
1589
1623
|
ev.stopPropagation();
|
|
1590
1624
|
clear_traffic();
|
|
1591
1625
|
}
|
|
1592
1626
|
}];
|
|
1593
1627
|
|
|
1594
|
-
let grp = (label, items) => ['div', {class: 'YDEV_GROUP'},
|
|
1628
|
+
let grp = (label, items) => ['div', {class: 'YDEV_GROUP'},
|
|
1629
|
+
[['span', {class: 'YDEV_LABEL', 'data-i18n': label}, t(label)], ...items]];
|
|
1595
1630
|
let sep = () => ['span', {class: 'YDEV_SEP'}, ''];
|
|
1596
1631
|
|
|
1597
1632
|
return createElement2(['div', {class: 'YDEV_BAR'}, [
|
|
1598
|
-
grp('
|
|
1599
|
-
grp('
|
|
1600
|
-
grp('
|
|
1601
|
-
grp('
|
|
1602
|
-
grp('
|
|
1603
|
-
grp('
|
|
1633
|
+
grp('traces', [...trace_chips, simple_mach]), sep(),
|
|
1634
|
+
grp('output', [output_seg]), sep(),
|
|
1635
|
+
grp('view', [view_seg]), expand_grp, sep(),
|
|
1636
|
+
grp('show', [...dir_chips, periodic_chip]), sep(),
|
|
1637
|
+
grp('find', [search]), sep(),
|
|
1638
|
+
grp('log', [copy, clear]),
|
|
1604
1639
|
]]);
|
|
1605
1640
|
}
|
|
1606
1641
|
|
|
@@ -1608,8 +1643,9 @@ function build_control_bar()
|
|
|
1608
1643
|
function build_title_header()
|
|
1609
1644
|
{
|
|
1610
1645
|
return createElement2(['div', {class: 'YDEV_TITLE'}, [
|
|
1611
|
-
['span', {class: 'YDEV_TITLE_MAIN'}, '
|
|
1612
|
-
['span', {class: 'YDEV_TITLE_SUB'
|
|
1646
|
+
['span', {class: 'YDEV_TITLE_MAIN', 'data-i18n': 'developer'}, t('developer')],
|
|
1647
|
+
['span', {class: 'YDEV_TITLE_SUB', 'data-i18n': 'yuno monitor'},
|
|
1648
|
+
t('yuno monitor')],
|
|
1613
1649
|
]]);
|
|
1614
1650
|
}
|
|
1615
1651
|
|
|
@@ -1710,7 +1746,7 @@ function setup_dev(self, show)
|
|
|
1710
1746
|
showFooter: false,
|
|
1711
1747
|
auto_save_size_and_position: true,
|
|
1712
1748
|
center: false,
|
|
1713
|
-
title: "
|
|
1749
|
+
title: "developer",
|
|
1714
1750
|
icon: "yi-terminal",
|
|
1715
1751
|
/* Opt into the dock/taskbar if the app provides one. `|| null`
|
|
1716
1752
|
* because gobj_find_service returns undefined when absent, and
|