@yuneta/gobj-ui 7.26.42 → 7.26.44
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/README.md +227 -36
- package/dist/gobj-ui.cjs.js +770 -192
- package/dist/gobj-ui.es.js +770 -192
- package/package.json +2 -2
- package/scripts/validate-locales.mjs +355 -63
- package/src/c_yui_form.js +268 -155
- package/src/c_yui_node.js +51 -7
- package/src/c_yui_schema_editor.js +49 -3
- package/src/c_yui_shell.css +4 -1
- package/src/c_yui_shell.js +28 -2
- package/src/c_yui_window.js +373 -62
- package/src/c_yui_window_manager.js +74 -2
- package/src/escape_taken.js +58 -0
- package/src/form_close_asks_for_edits.wiring.test.js +6 -3
- package/src/form_json_editor_names.js +3 -1
- package/src/form_json_editor_names.wiring.test.js +8 -4
- package/src/form_json_expand.wiring.test.js +6 -3
- package/src/form_json_field.wiring.test.js +8 -4
- package/src/form_label_i18n.wiring.test.js +10 -5
- package/src/form_table_edits_ask.wiring.test.js +18 -8
- package/src/form_table_rearm.wiring.test.js +13 -5
- package/src/form_table_rows.wiring.test.js +533 -0
- package/src/form_table_validator.wiring.test.js +8 -4
- package/src/form_template_field.wiring.test.js +6 -3
- package/src/g6_long_press_clock.test.js +8 -3
- package/src/i18n_key_functions.js +63 -25
- package/src/i18n_key_functions.test.js +230 -8
- package/src/modal_guard_back.wiring.test.js +53 -0
- package/src/named_controls.wiring.test.js +53 -13
- package/src/node_nav_events.wiring.test.js +93 -1
- package/src/schema_editor_diagram_click.wiring.test.js +277 -0
- package/src/shell_dialog_names.wiring.test.js +149 -0
- package/src/shell_escape_taken.wiring.test.js +142 -0
- package/src/shell_focus_trap.js +30 -2
- package/src/shell_focus_trap.test.js +90 -6
- package/src/shell_modals.js +90 -19
- package/src/table_editor_name.wiring.test.js +10 -5
- package/src/treedb_column_title.wiring.test.js +8 -4
- package/src/treedb_graph_writes.wiring.test.js +6 -3
- package/src/treedb_json_drill.wiring.test.js +6 -3
- package/src/uplot_add_serie.test.js +6 -3
- package/src/uplot_ink.test.js +8 -4
- package/src/window_dialog.wiring.test.js +486 -0
- package/src/window_dock_band.wiring.test.js +189 -0
- package/src/window_rect_rounding.wiring.test.js +121 -0
- package/src/yui_tabulator_i18n.js +31 -1
- package/src/yui_tabulator_i18n.test.js +46 -0
|
@@ -64,6 +64,7 @@
|
|
|
64
64
|
* `t.apply(x, [k])`; an array there is i18next's list of
|
|
65
65
|
* fallback keys, each one a key (`t([k, "fallback"])`). A
|
|
66
66
|
* `.bind()` that binds a key (`const tk = t.bind(null, k)`)
|
|
67
|
+
* hands t() that key, read where the bind is written, and
|
|
67
68
|
* makes a translator whose calls hand i18next its options or
|
|
68
69
|
* its default value, not a key: what they hand is not read;
|
|
69
70
|
* - each element a translator handed as a CALLBACK walks, and
|
|
@@ -75,21 +76,28 @@
|
|
|
75
76
|
* `[].forEach.call(keys, t)`) --, `Array.from(keys, t)` and
|
|
76
77
|
* `Array.fromAsync(keys, t)`; and what `.then(t)` /
|
|
77
78
|
* `.catch(t)` settle with, which no source writes;
|
|
78
|
-
* - the string given to an `i18n`
|
|
79
|
+
* - the string given to an `i18n` property, to a
|
|
79
80
|
* `data-i18n*` attribute (as a property, also computed by a
|
|
80
81
|
* const, `{[ATTR]: k}`; as a member written, `x.i18n = k`,
|
|
81
82
|
* `x["data-i18n-title"] = k`, `x[ATTR] = k`,
|
|
82
83
|
* `el.dataset.i18nTitle = k`; by setAttribute() or
|
|
83
84
|
* setAttributeNS(), the name a literal or a const; or written
|
|
84
|
-
* in markup), and the
|
|
85
|
-
* (
|
|
85
|
+
* in markup), and to a `code` property in the modules of the
|
|
86
|
+
* library whose codes are keys (CODE_KEY_MODULES: the
|
|
87
|
+
* findings and conflicts of the schema checks, which the
|
|
88
|
+
* schema editor hands to t()); in an app a `code` is no key
|
|
89
|
+
* unless its package.json names it (`attr_keys`);
|
|
86
90
|
* - the strings given to a gobj-ui function that RECEIVES a key
|
|
87
91
|
* as an argument (`yui_shell_show_error(shell, "<key>")`,
|
|
88
92
|
* `icon_button(..., "<key>")`), at the positions its table
|
|
89
93
|
* names: I18N_KEY_FUNCTIONS, src/i18n_key_functions.js --
|
|
90
94
|
* however the call reaches it: its name, an import under any
|
|
91
95
|
* name, a re-export, a const alias, a map
|
|
92
|
-
* (`API.info(...)`), `.call()`, `.apply()
|
|
96
|
+
* (`API.info(...)`), `.call()`, `.apply()`, and a `.bind()`
|
|
97
|
+
* (`f.bind(x, shell, k)`), read at the positions it binds. A
|
|
98
|
+
* position that is only the fallback of others (`fallbacks`:
|
|
99
|
+
* a card's id, behind its name and its aria_label) is not
|
|
100
|
+
* read where one of those is surely given. A position may
|
|
93
101
|
* hold DOM as well, which is no key: an array (a
|
|
94
102
|
* createElement2 spec; not an array of string literals,
|
|
95
103
|
* which is none), createElement2(), createOneHtml() or
|
|
@@ -193,8 +201,9 @@
|
|
|
193
201
|
* A TRANSLATED text where a key is read -- `t("k")`, any
|
|
194
202
|
* translator above, or a string built from one, `t("k") + ":"`,
|
|
195
203
|
* `t("k").toUpperCase()` -- is a violation, MARKED OR NOT, given
|
|
196
|
-
* to t() (`t(t("k") + "!")`), to an i18n /
|
|
197
|
-
*
|
|
204
|
+
* to t() (`t(t("k") + "!")`), to an i18n / data-i18n* value or a
|
|
205
|
+
* `code` where it is a key (`{i18n: t("k")}`), or to a data-i18n*
|
|
206
|
+
* attribute: the
|
|
198
207
|
* place keeps the translation as its key, and it never changes
|
|
199
208
|
* language. Up to 7.26.41 only a marked one failed.
|
|
200
209
|
*
|
|
@@ -228,8 +237,7 @@
|
|
|
228
237
|
* alias of (a parameter `translate`, a `let` alias,
|
|
229
238
|
* `i18next.getFixedT()`), or called by what is no name of it --
|
|
230
239
|
* `(0, t)(k)`, `[t][0](k)`, `Reflect.apply(t, x, [k])`,
|
|
231
|
-
* `Function.prototype.call.call(t, x, k)` --; a
|
|
232
|
-
* the translator, `t.bind(null, k)`; a parameter a closure
|
|
240
|
+
* `Function.prototype.call.call(t, x, k)` --; a parameter a closure
|
|
233
241
|
* returns (`const inner = () => key; t(inner())`: the search for
|
|
234
242
|
* the functions that forward a key does not see it); a translator
|
|
235
243
|
* handed to a function (`{t: t}`, `yui_tabulator_lang(t)`: it
|
|
@@ -249,6 +257,15 @@
|
|
|
249
257
|
* package (gobj-js, i18next); what is written into a const table
|
|
250
258
|
* after its declaration; a window's `title` given as an attr at
|
|
251
259
|
* gobj_create().
|
|
260
|
+
*
|
|
261
|
+
* Where the reader GIVES UP on a value it says so, with the file
|
|
262
|
+
* and the line, and that fails: a chain of consts, aliases or
|
|
263
|
+
* calls more than MAX_DEPTH (24) steps deep, a const that leads
|
|
264
|
+
* back to itself, an expression that can take more than
|
|
265
|
+
* MAX_VALUES (10000) values -- a key behind it would go unasked.
|
|
266
|
+
* Up to 7.26.42 it stopped there in silence, and a chain of consts
|
|
267
|
+
* that doubles at every link died with a RangeError naming no
|
|
268
|
+
* file. A const is read once, wherever it is read.
|
|
252
269
|
|
|
253
270
|
* Options (paths relative to the app's directory):
|
|
254
271
|
*
|
|
@@ -899,11 +916,6 @@ function callee_name(callee)
|
|
|
899
916
|
return null;
|
|
900
917
|
}
|
|
901
918
|
|
|
902
|
-
function is_string_literal(n, re)
|
|
903
|
-
{
|
|
904
|
-
return !!n && n.type === "Literal" && typeof n.value === "string" && (!re || re.test(n.value));
|
|
905
|
-
}
|
|
906
|
-
|
|
907
919
|
/***************************************************************
|
|
908
920
|
* `Object.<name>(...)`?
|
|
909
921
|
***************************************************************/
|
|
@@ -1759,7 +1771,11 @@ const TRANSLATOR = Object.freeze({kind: "t", name: "t"});
|
|
|
1759
1771
|
***************************************************************/
|
|
1760
1772
|
function callee_of(node, scope, depth = 0)
|
|
1761
1773
|
{
|
|
1762
|
-
if(!node
|
|
1774
|
+
if(!node) {
|
|
1775
|
+
return null;
|
|
1776
|
+
}
|
|
1777
|
+
if(depth > MAX_DEPTH) {
|
|
1778
|
+
give_up(node, scope, GIVE_UP_DEEP);
|
|
1763
1779
|
return null;
|
|
1764
1780
|
}
|
|
1765
1781
|
switch(node.type) {
|
|
@@ -1910,10 +1926,10 @@ function var_function(b)
|
|
|
1910
1926
|
* b (null when `.apply()` hands an array the source does not write
|
|
1911
1927
|
* out). A callee with arguments BOUND (`const g = f.bind(x, a)`)
|
|
1912
1928
|
* receives those first: they stand as holes (null) before what the
|
|
1913
|
-
* call hands -- a position
|
|
1914
|
-
*
|
|
1915
|
-
* spread hides how many were bound. Cached per call: what
|
|
1916
|
-
* does not change.
|
|
1929
|
+
* call hands -- a position not read HERE: what a bind binds is read
|
|
1930
|
+
* where the bind is written (bind_kind()) --, and the arguments are
|
|
1931
|
+
* null when a spread hides how many were bound. Cached per call: what
|
|
1932
|
+
* it calls does not change.
|
|
1917
1933
|
*
|
|
1918
1934
|
* -> {target, args} | null
|
|
1919
1935
|
***************************************************************/
|
|
@@ -1954,6 +1970,47 @@ function call_target(call, scope)
|
|
|
1954
1970
|
return r;
|
|
1955
1971
|
}
|
|
1956
1972
|
|
|
1973
|
+
/***************************************************************
|
|
1974
|
+
* A `.bind()` of a key function or of a translator, read as the
|
|
1975
|
+
* call it prepares: `yui_shell_show_info.bind(null, shell, "k")`
|
|
1976
|
+
* hands "k" at position 1 of yui_shell_show_info, `t.bind(null, "k")`
|
|
1977
|
+
* hands t() its key -- where the bind is written, since a call of
|
|
1978
|
+
* what it makes no longer hands those positions (call_target()).
|
|
1979
|
+
* Up to 7.26.42 what a bind binds was not read: a key bound there
|
|
1980
|
+
* went unasked, and a parameter bound there passed the rule per call.
|
|
1981
|
+
*
|
|
1982
|
+
* -> {kind: "key", entry, target, args} | {kind: "t", target, args}
|
|
1983
|
+
* | null, `args` the arguments the function receives, the ones
|
|
1984
|
+
* bound before (`f.bind(x, a).bind(y, b)`) as holes, and null
|
|
1985
|
+
* when a spread hides them
|
|
1986
|
+
***************************************************************/
|
|
1987
|
+
function bind_kind(call, scope, table = I18N_KEY_FUNCTIONS)
|
|
1988
|
+
{
|
|
1989
|
+
let c = call.callee;
|
|
1990
|
+
if(c.type !== "MemberExpression" || c.computed || c.property.type !== "Identifier"
|
|
1991
|
+
|| c.property.name !== "bind" || call.arguments.length < 2) {
|
|
1992
|
+
return null;
|
|
1993
|
+
}
|
|
1994
|
+
let inner = callee_of(c.object, scope);
|
|
1995
|
+
if(!inner) {
|
|
1996
|
+
return null;
|
|
1997
|
+
}
|
|
1998
|
+
let args = inner.bound_spread? null : [...new Array(inner.bound || 0).fill(null), ...call.arguments.slice(1)];
|
|
1999
|
+
if(inner.kind === "t") {
|
|
2000
|
+
return {kind: "t", target: inner, args};
|
|
2001
|
+
}
|
|
2002
|
+
let module = lib_module_of(inner.url);
|
|
2003
|
+
let fns = module? key_fn_index(table).by_module.get(module) : null;
|
|
2004
|
+
let entry = fns? (fns.get(inner.name) || null) : null;
|
|
2005
|
+
if(entry) {
|
|
2006
|
+
return {kind: "key", entry, target: inner, args};
|
|
2007
|
+
}
|
|
2008
|
+
if(TRANSLATOR_NAMES.has(inner.name)) {
|
|
2009
|
+
return {kind: "t", target: inner, args};
|
|
2010
|
+
}
|
|
2011
|
+
return null;
|
|
2012
|
+
}
|
|
2013
|
+
|
|
1957
2014
|
/***************************************************************
|
|
1958
2015
|
* What kind of call a call is, for the reader:
|
|
1959
2016
|
*
|
|
@@ -2033,7 +2090,11 @@ function is_translated_text(n, scope, depth = 0)
|
|
|
2033
2090
|
while(n && n.type === "ChainExpression") {
|
|
2034
2091
|
n = n.expression;
|
|
2035
2092
|
}
|
|
2036
|
-
if(!n
|
|
2093
|
+
if(!n) {
|
|
2094
|
+
return false;
|
|
2095
|
+
}
|
|
2096
|
+
if(depth > MAX_DEPTH) {
|
|
2097
|
+
give_up(n, scope, GIVE_UP_DEEP);
|
|
2037
2098
|
return false;
|
|
2038
2099
|
}
|
|
2039
2100
|
let sub = (x) => is_translated_text(x, scope, depth + 1);
|
|
@@ -2145,8 +2206,60 @@ function is_key_function(target)
|
|
|
2145
2206
|
***************************/
|
|
2146
2207
|
|
|
2147
2208
|
|
|
2148
|
-
/* How far a chain of consts is followed
|
|
2209
|
+
/* How far a chain of consts, aliases or calls is followed (a cycle stops
|
|
2210
|
+
* here too), and how many values one expression may take. Past either the
|
|
2211
|
+
* reader GIVES UP, and says so (give_up()): a key behind a value it does
|
|
2212
|
+
* not follow would go unasked, and the build say OK */
|
|
2149
2213
|
const MAX_DEPTH = 24;
|
|
2214
|
+
const MAX_VALUES = 10000;
|
|
2215
|
+
|
|
2216
|
+
/***************************************************************
|
|
2217
|
+
* Where the reader GAVE UP on a value: a chain deeper than
|
|
2218
|
+
* MAX_DEPTH, a const that leads back to itself, an expression that
|
|
2219
|
+
* can take more than MAX_VALUES values. A key behind it would go
|
|
2220
|
+
* unasked, so it is a violation, with the file and the line
|
|
2221
|
+
* (collect_used_keys(); the library's own test holds the library to
|
|
2222
|
+
* none). Up to 7.26.42 the reader stopped there in silence: a chain
|
|
2223
|
+
* of 24 aliases of a const asked for nothing, and a chain of consts
|
|
2224
|
+
* that doubles at every step (`{...O, ...O}`) grew without end and
|
|
2225
|
+
* died with a RangeError naming no file.
|
|
2226
|
+
*
|
|
2227
|
+
* `node` is the value it gave up on, `scope` the chain of its
|
|
2228
|
+
* ancestors (the first one, the module: where it is said).
|
|
2229
|
+
***************************************************************/
|
|
2230
|
+
const GAVE_UP = new Map(); // node -> {node, scope, why}
|
|
2231
|
+
|
|
2232
|
+
const GIVE_UP_DEEP = `it is more than ${MAX_DEPTH} steps deep (a chain of consts, aliases or calls ` +
|
|
2233
|
+
`that long): shorten the chain`;
|
|
2234
|
+
const GIVE_UP_CYCLE = `it is a const that leads back to itself: break the cycle`;
|
|
2235
|
+
const GIVE_UP_MANY = `it can take more than ${MAX_VALUES} values: split it`;
|
|
2236
|
+
|
|
2237
|
+
function give_up(node, scope, why)
|
|
2238
|
+
{
|
|
2239
|
+
if(node && !GAVE_UP.has(node)) {
|
|
2240
|
+
GAVE_UP.set(node, {node, scope: scope || [], why});
|
|
2241
|
+
}
|
|
2242
|
+
}
|
|
2243
|
+
|
|
2244
|
+
/* Where the reader gave up so far -- in one parsed file, when it is
|
|
2245
|
+
* given: [{url, line, text, why}] */
|
|
2246
|
+
function gave_up(ast = null)
|
|
2247
|
+
{
|
|
2248
|
+
let out = [];
|
|
2249
|
+
for(let {node, scope, why} of GAVE_UP.values()) {
|
|
2250
|
+
let program = (scope.length > 0 && typeof scope[0].code === "string")? scope[0] : null;
|
|
2251
|
+
if(ast && program !== ast) {
|
|
2252
|
+
continue;
|
|
2253
|
+
}
|
|
2254
|
+
out.push({
|
|
2255
|
+
url: program? (PROGRAM_URL.get(program) || null) : null,
|
|
2256
|
+
line: program? line_of(program, node.start) : 0,
|
|
2257
|
+
text: program? program.code.slice(node.start, node.end).replace(/\s+/g, " ").slice(0, 80) : "",
|
|
2258
|
+
why
|
|
2259
|
+
});
|
|
2260
|
+
}
|
|
2261
|
+
return out;
|
|
2262
|
+
}
|
|
2150
2263
|
|
|
2151
2264
|
/***************************************************************
|
|
2152
2265
|
* The values an expression can take, as far as the source writes
|
|
@@ -2211,6 +2324,16 @@ const MAX_DEPTH = 24;
|
|
|
2211
2324
|
* read for the declaration of a const: `via` stops growing there.
|
|
2212
2325
|
***************************************************************/
|
|
2213
2326
|
function expand(node, ctx, depth = 0)
|
|
2327
|
+
{
|
|
2328
|
+
let out = expand_node(node, ctx, depth);
|
|
2329
|
+
if(out.length > MAX_VALUES) {
|
|
2330
|
+
give_up(node, ctx.scope, GIVE_UP_MANY);
|
|
2331
|
+
return [{kind: "unknown", node, scope: ctx.scope, via: ctx.off? ctx.via : [...ctx.via, node], off: ctx.off}];
|
|
2332
|
+
}
|
|
2333
|
+
return out;
|
|
2334
|
+
}
|
|
2335
|
+
|
|
2336
|
+
function expand_node(node, ctx, depth)
|
|
2214
2337
|
{
|
|
2215
2338
|
if(!node) {
|
|
2216
2339
|
return [];
|
|
@@ -2219,6 +2342,7 @@ function expand(node, ctx, depth = 0)
|
|
|
2219
2342
|
let here = {scope: ctx.scope, via: via, off: ctx.off};
|
|
2220
2343
|
let item = (kind, extra) => Object.assign({kind, node, scope: ctx.scope, via, off: ctx.off}, extra);
|
|
2221
2344
|
if(depth > MAX_DEPTH) {
|
|
2345
|
+
give_up(node, ctx.scope, GIVE_UP_DEEP);
|
|
2222
2346
|
return [item("unknown")];
|
|
2223
2347
|
}
|
|
2224
2348
|
|
|
@@ -2321,12 +2445,38 @@ function expand(node, ctx, depth = 0)
|
|
|
2321
2445
|
/***************************************************************
|
|
2322
2446
|
* The values of a const (a binding of binding_of(), or a const
|
|
2323
2447
|
* module_export() found in another module): its value read where it
|
|
2324
|
-
* is declared, the steps a destructuring reads from it, its default
|
|
2448
|
+
* is declared, the steps a destructuring reads from it, its default.
|
|
2449
|
+
*
|
|
2450
|
+
* Its value is read ONCE, without repeats, and kept: a const is read
|
|
2451
|
+
* where it is declared, so what it holds is the same wherever it is
|
|
2452
|
+
* read -- only `via`, the place it is read from, differs, and it is
|
|
2453
|
+
* the same for every value (the reader leaves the place for the
|
|
2454
|
+
* declaration). Up to 7.26.42 a const was read again at every read,
|
|
2455
|
+
* so `const O1 = c()? O0 : {...O0, ...O0}`, chained, took three
|
|
2456
|
+
* times as long at every link (eleven links, 906 ms) and grew its
|
|
2457
|
+
* values until a RangeError. A const met again while its value is
|
|
2458
|
+
* being read leads back to itself: the reader gives up on it
|
|
2459
|
+
* (give_up()).
|
|
2325
2460
|
***************************************************************/
|
|
2461
|
+
const CONST_VALUES = new WeakMap(); // the init of a const -> its values, `via` left out
|
|
2462
|
+
const CONST_READING = new Set(); // the inits being read
|
|
2463
|
+
|
|
2326
2464
|
function const_values(b, node, via, depth)
|
|
2327
2465
|
{
|
|
2328
2466
|
let ctx = {scope: b.scope, via: via, off: true};
|
|
2329
|
-
|
|
2467
|
+
if(!CONST_VALUES.has(b.init)) {
|
|
2468
|
+
if(CONST_READING.has(b.init)) {
|
|
2469
|
+
give_up(b.init, b.scope, GIVE_UP_CYCLE);
|
|
2470
|
+
return [{kind: "unknown", node: b.init, scope: b.scope, via, off: true}];
|
|
2471
|
+
}
|
|
2472
|
+
CONST_READING.add(b.init);
|
|
2473
|
+
try {
|
|
2474
|
+
CONST_VALUES.set(b.init, unique_values(expand(b.init, {scope: b.scope, via: [], off: true}, depth + 1)));
|
|
2475
|
+
} finally {
|
|
2476
|
+
CONST_READING.delete(b.init);
|
|
2477
|
+
}
|
|
2478
|
+
}
|
|
2479
|
+
let out = CONST_VALUES.get(b.init).map((v) => Object.assign({}, v, {via}));
|
|
2330
2480
|
for(let step of b.steps || []) {
|
|
2331
2481
|
out = out.flatMap((o) => step_values(o, step, node, depth + 1));
|
|
2332
2482
|
}
|
|
@@ -2602,9 +2752,44 @@ function assigned_properties(o, step, depth)
|
|
|
2602
2752
|
* The values of property `name` of an object literal (`name` null:
|
|
2603
2753
|
* of every property), each followed with expand(). A spread is read
|
|
2604
2754
|
* for it: an object literal, or a parameter (`{...opts}` holds
|
|
2605
|
-
* opts.title as its title)
|
|
2755
|
+
* opts.title as its title).
|
|
2756
|
+
*
|
|
2757
|
+
* An object reached from a declaration (`o.off`: every value it
|
|
2758
|
+
* gives carries the same `via`) is read once per property, without
|
|
2759
|
+
* repeats, and kept -- as a const is (const_values()): a spread of the
|
|
2760
|
+
* same object twice, `{...O, ...O}`, gives its values once.
|
|
2606
2761
|
***************************************************************/
|
|
2762
|
+
const PROPERTY_VALUES = new WeakMap(); // an object literal -> Map(property -> its values, `via` left out)
|
|
2763
|
+
|
|
2607
2764
|
function property_values(o, name, depth)
|
|
2765
|
+
{
|
|
2766
|
+
if(!o.off) {
|
|
2767
|
+
return capped(o, property_values_of(o, name, depth));
|
|
2768
|
+
}
|
|
2769
|
+
let known = PROPERTY_VALUES.get(o.node);
|
|
2770
|
+
if(!known) {
|
|
2771
|
+
known = new Map();
|
|
2772
|
+
PROPERTY_VALUES.set(o.node, known);
|
|
2773
|
+
}
|
|
2774
|
+
if(!known.has(name)) {
|
|
2775
|
+
let values = unique_values(property_values_of(Object.assign({}, o, {via: []}), name, depth));
|
|
2776
|
+
known.set(name, capped(Object.assign({}, o, {via: []}), values));
|
|
2777
|
+
}
|
|
2778
|
+
return known.get(name).map((v) => Object.assign({}, v, {via: o.via}));
|
|
2779
|
+
}
|
|
2780
|
+
|
|
2781
|
+
/* The values of a value, or the reader giving up on it when they are
|
|
2782
|
+
* more than MAX_VALUES */
|
|
2783
|
+
function capped(o, values)
|
|
2784
|
+
{
|
|
2785
|
+
if(values.length <= MAX_VALUES) {
|
|
2786
|
+
return values;
|
|
2787
|
+
}
|
|
2788
|
+
give_up(o.node, o.scope, GIVE_UP_MANY);
|
|
2789
|
+
return [Object.assign({}, o, {kind: "unknown", binding: null, var_root: null})];
|
|
2790
|
+
}
|
|
2791
|
+
|
|
2792
|
+
function property_values_of(o, name, depth)
|
|
2608
2793
|
{
|
|
2609
2794
|
let out = [];
|
|
2610
2795
|
let scope = [...o.scope, o.node];
|
|
@@ -2667,9 +2852,30 @@ function elements_of(node, ctx, depth)
|
|
|
2667
2852
|
/***************************************************************
|
|
2668
2853
|
* The elements of one value of expand(): see elements_of(). Each
|
|
2669
2854
|
* element of a rest parameter is another parameter: no position can
|
|
2670
|
-
* name one, and the reader cannot follow it.
|
|
2855
|
+
* name one, and the reader cannot follow it. The elements of an array
|
|
2856
|
+
* literal (or of a `.map()` of one) reached from a declaration are
|
|
2857
|
+
* read once, without repeats, and kept, as the properties of an
|
|
2858
|
+
* object are (property_values()): `[...A, ...A]` gives A's once.
|
|
2671
2859
|
***************************************************************/
|
|
2860
|
+
const ELEMENT_VALUES = new WeakMap(); // an array literal or a .map() -> its elements, `via` left out
|
|
2861
|
+
|
|
2672
2862
|
function element_values(v, depth)
|
|
2863
|
+
{
|
|
2864
|
+
let literal = v.kind === "value" && (v.node.type === "ArrayExpression" || is_mapping(v.node));
|
|
2865
|
+
if(!literal) {
|
|
2866
|
+
return element_values_of(v, depth);
|
|
2867
|
+
}
|
|
2868
|
+
if(!v.off) {
|
|
2869
|
+
return capped(v, element_values_of(v, depth));
|
|
2870
|
+
}
|
|
2871
|
+
if(!ELEMENT_VALUES.has(v.node)) {
|
|
2872
|
+
let bare = Object.assign({}, v, {via: []});
|
|
2873
|
+
ELEMENT_VALUES.set(v.node, capped(bare, unique_values(element_values_of(bare, depth))));
|
|
2874
|
+
}
|
|
2875
|
+
return ELEMENT_VALUES.get(v.node).map((x) => Object.assign({}, x, {via: v.via}));
|
|
2876
|
+
}
|
|
2877
|
+
|
|
2878
|
+
function element_values_of(v, depth)
|
|
2673
2879
|
{
|
|
2674
2880
|
let out = [];
|
|
2675
2881
|
if(v.kind === "param" && v.binding.rest) {
|
|
@@ -2925,8 +3131,16 @@ function static_keys(node, scope = [])
|
|
|
2925
3131
|
* A position the call does not reach (an argument not given) has no
|
|
2926
3132
|
* leaf: its default applies. An options object held in a variable,
|
|
2927
3133
|
* a spread, a parameter, a copy: followed like any value.
|
|
3134
|
+
*
|
|
3135
|
+
* `fallbacks` (the entry's `fallbacks` of the position, or null):
|
|
3136
|
+
* the positions the function reads FIRST, the position itself being
|
|
3137
|
+
* only their fallback (`it.name || it.aria_label || it.id`). An
|
|
3138
|
+
* object that surely gives one of them -- every value it can take
|
|
3139
|
+
* there is a non-empty string -- does not reach the position, and has
|
|
3140
|
+
* no leaf there; any other object (one that may give none of them, a
|
|
3141
|
+
* parameter, data) reaches it.
|
|
2928
3142
|
***************************************************************/
|
|
2929
|
-
function values_at(call, path, scope = [], args = call.arguments)
|
|
3143
|
+
function values_at(call, path, scope = [], args = call.arguments, fallbacks = null)
|
|
2930
3144
|
{
|
|
2931
3145
|
let segs = String(path).split(".");
|
|
2932
3146
|
let first = segs.shift().match(/^(\d+)(\[\])?$/);
|
|
@@ -2948,11 +3162,16 @@ function values_at(call, path, scope = [], args = call.arguments)
|
|
|
2948
3162
|
|
|
2949
3163
|
let ctx = {scope: call_scope, via: [call], off: false};
|
|
2950
3164
|
let cur = first[2]? elements_of(arg, ctx, 0) : expand(arg, ctx);
|
|
2951
|
-
|
|
3165
|
+
let parent = String(path).slice(0, String(path).lastIndexOf(".") + 1);
|
|
3166
|
+
let shortcuts = (fallbacks || []).map((f) => f.slice(parent.length).split("."));
|
|
3167
|
+
for(let [i, seg] of segs.entries()) {
|
|
2952
3168
|
let m = seg.match(/^([\w$]+)(\[\])?$/);
|
|
2953
3169
|
if(!m) {
|
|
2954
3170
|
return [at_call];
|
|
2955
3171
|
}
|
|
3172
|
+
if(i === segs.length - 1 && shortcuts.length > 0) {
|
|
3173
|
+
cur = cur.filter((v) => !shortcuts.some((rel) => surely_given(v, rel)));
|
|
3174
|
+
}
|
|
2956
3175
|
let next = [];
|
|
2957
3176
|
for(let v of cur) {
|
|
2958
3177
|
if(v.kind === "nothing" || (v.kind === "value" && v.node.type === "Literal")) {
|
|
@@ -2968,6 +3187,24 @@ function values_at(call, path, scope = [], args = call.arguments)
|
|
|
2968
3187
|
return cur.map(classify);
|
|
2969
3188
|
}
|
|
2970
3189
|
|
|
3190
|
+
/* Does a value surely give a non-empty string at the steps `rel`
|
|
3191
|
+
* (["name"], ["roll", "label"]) -- every value it can take there is
|
|
3192
|
+
* one? Nothing, a parameter, data: not surely. */
|
|
3193
|
+
function surely_given(v, rel)
|
|
3194
|
+
{
|
|
3195
|
+
let cur = [v];
|
|
3196
|
+
for(let prop of rel) {
|
|
3197
|
+
cur = cur.flatMap((o) => (o.kind === "nothing")? [o] : step_values(o, {prop, computed: false}, null, 0));
|
|
3198
|
+
}
|
|
3199
|
+
return cur.length > 0 && cur.every((x) => classify(x).kind === "key");
|
|
3200
|
+
}
|
|
3201
|
+
|
|
3202
|
+
/* The `fallbacks` of a position of an entry of I18N_KEY_FUNCTIONS */
|
|
3203
|
+
function fallbacks_of(entry, path)
|
|
3204
|
+
{
|
|
3205
|
+
return (entry.fallbacks && entry.fallbacks[path]) || null;
|
|
3206
|
+
}
|
|
3207
|
+
|
|
2971
3208
|
/***************************************************************
|
|
2972
3209
|
* The steps from a `let` / `var` to the member a node names, when
|
|
2973
3210
|
* the node is the variable itself (no step) or a member of it
|
|
@@ -3163,9 +3400,10 @@ function assigned_values(binding, members = false)
|
|
|
3163
3400
|
}
|
|
3164
3401
|
break;
|
|
3165
3402
|
case "CallExpression": {
|
|
3166
|
-
if(n.callee.type === "Identifier" && n.callee.name === "eval") {
|
|
3403
|
+
if(n.callee.type === "Identifier" && n.callee.name === "eval" && !n.optional) {
|
|
3167
3404
|
/* Not run: a direct eval() of the SOURCE writes what its text says, which no
|
|
3168
|
-
* reader reads (in a module no other binding can be called `eval`)
|
|
3405
|
+
* reader reads (in a module no other binding can be called `eval`); `eval?.()`
|
|
3406
|
+
* is an indirect one, which runs in the global scope */
|
|
3169
3407
|
unknown.push({node: n, steps: [], scope: chain});
|
|
3170
3408
|
break;
|
|
3171
3409
|
}
|
|
@@ -3250,6 +3488,7 @@ function var_leaves(root, seen = new Set(), depth = 0)
|
|
|
3250
3488
|
}
|
|
3251
3489
|
seen.add(id);
|
|
3252
3490
|
if(depth > MAX_DEPTH) {
|
|
3491
|
+
give_up(b.declarators[0], b.scope, GIVE_UP_DEEP);
|
|
3253
3492
|
out.complete = false;
|
|
3254
3493
|
out.unread.push(b.declarators[0]);
|
|
3255
3494
|
return out;
|
|
@@ -3400,7 +3639,11 @@ function let_literals(b, seen)
|
|
|
3400
3639
|
***************************************************************/
|
|
3401
3640
|
function literal_values(n, scope, seen, depth = 0)
|
|
3402
3641
|
{
|
|
3403
|
-
if(!n
|
|
3642
|
+
if(!n) {
|
|
3643
|
+
return null;
|
|
3644
|
+
}
|
|
3645
|
+
if(depth > MAX_DEPTH) {
|
|
3646
|
+
give_up(n, scope, GIVE_UP_DEEP);
|
|
3404
3647
|
return null;
|
|
3405
3648
|
}
|
|
3406
3649
|
let sub = (x, s = scope) => literal_values(x, s, seen, depth + 1);
|
|
@@ -3529,7 +3772,11 @@ function param_flows(node, scope, seen = new Set(), depth = 0)
|
|
|
3529
3772
|
{
|
|
3530
3773
|
/* Through a call or an iteration a path names no position any more */
|
|
3531
3774
|
let unnamed = (flows) => flows.map((f) => (f.path === null)? f : {binding: f.binding, path: null, priv: f.priv});
|
|
3532
|
-
if(!node || typeof node.type !== "string"
|
|
3775
|
+
if(!node || typeof node.type !== "string") {
|
|
3776
|
+
return [];
|
|
3777
|
+
}
|
|
3778
|
+
if(depth > MAX_DEPTH) {
|
|
3779
|
+
give_up(node, scope, GIVE_UP_DEEP);
|
|
3533
3780
|
return [];
|
|
3534
3781
|
}
|
|
3535
3782
|
let sub = (n, s = scope) => param_flows(n, s, seen, depth + 1);
|
|
@@ -3854,7 +4101,7 @@ function key_calls(ast, lib_module, table = I18N_KEY_FUNCTIONS)
|
|
|
3854
4101
|
return;
|
|
3855
4102
|
}
|
|
3856
4103
|
ancestors.push(n);
|
|
3857
|
-
let c = call_kind(n, ancestors, table);
|
|
4104
|
+
let c = call_kind(n, ancestors, table) || bind_kind(n, ancestors, table);
|
|
3858
4105
|
ancestors.pop();
|
|
3859
4106
|
if(c && c.kind === "key") {
|
|
3860
4107
|
out.push({entry: c.entry, call: n, scope: ancestors.slice(), args: c.args});
|
|
@@ -3973,7 +4220,7 @@ function call_rule_violations(ast, lib_module, table)
|
|
|
3973
4220
|
};
|
|
3974
4221
|
for(let {entry, call, scope, args} of key_calls(ast, lib_module, table)) {
|
|
3975
4222
|
for(let path of entry.keys) {
|
|
3976
|
-
check(values_at(call, path, scope, args), call, entry.name, path, null);
|
|
4223
|
+
check(values_at(call, path, scope, args, fallbacks_of(entry, path)), call, entry.name, path, null);
|
|
3977
4224
|
}
|
|
3978
4225
|
}
|
|
3979
4226
|
for(let {call, scope, callback} of translator_callbacks(ast, lib_module)) {
|
|
@@ -4267,7 +4514,11 @@ function list_mutations(ast, lists = [])
|
|
|
4267
4514
|
while(n && n.type === "ChainExpression") {
|
|
4268
4515
|
n = n.expression;
|
|
4269
4516
|
}
|
|
4270
|
-
if(!n
|
|
4517
|
+
if(!n) {
|
|
4518
|
+
return null;
|
|
4519
|
+
}
|
|
4520
|
+
if(depth > MAX_DEPTH) {
|
|
4521
|
+
give_up(n, chain, GIVE_UP_DEEP);
|
|
4271
4522
|
return null;
|
|
4272
4523
|
}
|
|
4273
4524
|
if(n.type === "MemberExpression") {
|
|
@@ -4358,6 +4609,21 @@ function list_mutations(ast, lists = [])
|
|
|
4358
4609
|
***************************/
|
|
4359
4610
|
|
|
4360
4611
|
|
|
4612
|
+
/***************************************************************
|
|
4613
|
+
* The modules of the library whose `code` properties are i18n keys:
|
|
4614
|
+
* the findings of the schema checks (schema_validate.js) and the
|
|
4615
|
+
* conflicts of an import (schema_import.js), which the schema editor
|
|
4616
|
+
* (c_yui_schema_editor.js, which also writes some) hands to
|
|
4617
|
+
* `t(finding.code)` / `t(conflict.code)`. Anywhere else a `code` is
|
|
4618
|
+
* whatever the code says -- a language (`{code: "en"}`), an error
|
|
4619
|
+
* number --, and no key: up to 7.26.42 every `code` of every file was
|
|
4620
|
+
* read as one, and so was any `add("error", x)`, a `classList.add()`
|
|
4621
|
+
* included. (The checks' own add() is a key function of the table.)
|
|
4622
|
+
* i18n_key_functions.test.js holds the list to the library: a module
|
|
4623
|
+
* that writes a literal `code` is in it, and only those.
|
|
4624
|
+
***************************************************************/
|
|
4625
|
+
const CODE_KEY_MODULES = new Set(["schema_validate.js", "schema_import.js", "c_yui_schema_editor.js"]);
|
|
4626
|
+
|
|
4361
4627
|
/***************************************************************
|
|
4362
4628
|
* Every place a parsed file READS a key, with the leaves of what
|
|
4363
4629
|
* stands there (leaves_of(), values_at()):
|
|
@@ -4370,13 +4636,13 @@ function list_mutations(ast, lists = [])
|
|
|
4370
4636
|
* tr(), `i18next.t()`, an alias, `t?.()`,
|
|
4371
4637
|
* `t.call(x, key)`); an array there is the list of
|
|
4372
4638
|
* keys i18next tries in turn, each one a key
|
|
4373
|
-
* "code" the code of a schema check, add("error", <code>)
|
|
4374
4639
|
* "attribute" setAttribute("data-i18n*", <key>) and
|
|
4375
4640
|
* setAttributeNS(ns, "data-i18n*", <key>), the name a
|
|
4376
4641
|
* literal or a const the reader follows to one
|
|
4377
|
-
* "property" an `i18n
|
|
4378
|
-
*
|
|
4379
|
-
*
|
|
4642
|
+
* "property" an `i18n` or `data-i18n*` property of an object
|
|
4643
|
+
* literal (`{[ATTR]: k}` with ATTR a const bound to
|
|
4644
|
+
* one), one of ctx.attr_keys, or a `code` in a module
|
|
4645
|
+
* of CODE_KEY_MODULES
|
|
4380
4646
|
* "array" an element of one of ctx.array_keys
|
|
4381
4647
|
* "assignment" `x.i18n = <key>`, `x["data-i18n-title"] = <key>`,
|
|
4382
4648
|
* `x[ATTR] = <key>`, `el.dataset.i18nTitle = <key>`
|
|
@@ -4423,12 +4689,13 @@ function key_places(ast, ctx = {})
|
|
|
4423
4689
|
return (s !== null)? [s] : static_keys(node, scope).keys;
|
|
4424
4690
|
};
|
|
4425
4691
|
let is_i18n_name = (name) => name === "i18n" || DATA_I18N_ATTR_RE.test(name);
|
|
4426
|
-
let
|
|
4692
|
+
let codes_are_keys = CODE_KEY_MODULES.has(ctx.lib_module);
|
|
4693
|
+
let is_property_key = (x) => is_i18n_name(x) || (x === "code" && codes_are_keys) || attr_keys.has(x);
|
|
4427
4694
|
walk(ast, (n, ancestors) => {
|
|
4428
4695
|
switch(n.type) {
|
|
4429
4696
|
case "CallExpression": {
|
|
4430
4697
|
ancestors.push(n);
|
|
4431
|
-
let c = call_kind(n, ancestors, table);
|
|
4698
|
+
let c = call_kind(n, ancestors, table) || bind_kind(n, ancestors, table);
|
|
4432
4699
|
ancestors.pop();
|
|
4433
4700
|
if(c && c.kind === "key") {
|
|
4434
4701
|
/* A key function (a `tr` of the library too): read where its table says */
|
|
@@ -4440,9 +4707,6 @@ function key_places(ast, ctx = {})
|
|
|
4440
4707
|
let name = callee_name(n.callee);
|
|
4441
4708
|
if(c && c.kind === "t") {
|
|
4442
4709
|
read_t(c.args? c.args[0] : null, [...ancestors, n], n);
|
|
4443
|
-
} else if(name === "add" && is_string_literal(n.arguments[0], /^(error|warning)$/)) {
|
|
4444
|
-
/* The codes the schema checks hand to `t(finding.code)` */
|
|
4445
|
-
read("code", n.arguments[1], [...ancestors, n], n);
|
|
4446
4710
|
} else if((name === "setAttribute" && n.arguments.length >= 2)
|
|
4447
4711
|
|| (name === "setAttributeNS" && n.arguments.length >= 3)) {
|
|
4448
4712
|
/* setAttributeNS(ns, name, value): the same, one argument on */
|
|
@@ -4520,7 +4784,8 @@ function key_places(ast, ctx = {})
|
|
|
4520
4784
|
}
|
|
4521
4785
|
for(let {entry, call, scope, args} of calls) {
|
|
4522
4786
|
for(let path of entry.keys) {
|
|
4523
|
-
out.push({what: "call", node: call, entry, path,
|
|
4787
|
+
out.push({what: "call", node: call, entry, path,
|
|
4788
|
+
leaves: values_at(call, path, scope, args, fallbacks_of(entry, path))});
|
|
4524
4789
|
}
|
|
4525
4790
|
}
|
|
4526
4791
|
for(let {call, scope, callback} of callbacks) {
|
|
@@ -4635,8 +4900,8 @@ function key_list_leaves(node, scope, root)
|
|
|
4635
4900
|
* known: shape_owner_check()).
|
|
4636
4901
|
*
|
|
4637
4902
|
* A TRANSLATED text (is_translation()) where a key is read -- given
|
|
4638
|
-
* to t(), to an `i18n` / `
|
|
4639
|
-
* data-i18n* attribute -- is an error, MARKED OR NOT
|
|
4903
|
+
* to t(), to an `i18n` / `data-i18n*` value (a `code` where it is a
|
|
4904
|
+
* key), to a data-i18n* attribute -- is an error, MARKED OR NOT
|
|
4640
4905
|
* (`translated_errors`): the place keeps the translation as its key,
|
|
4641
4906
|
* and it never changes language. Up to 7.26.41 only a marked one
|
|
4642
4907
|
* failed, so `{i18n: t("k")}` passed and `{i18n: /\* i18n: data *\/
|
|
@@ -4648,7 +4913,6 @@ function key_list_leaves(node, scope, root)
|
|
|
4648
4913
|
/* Where key_places() reads a key, as a message says it */
|
|
4649
4914
|
const PLACE_NAMES = {
|
|
4650
4915
|
t: "handed to a translator as its key",
|
|
4651
|
-
code: "handed as the code of a schema check",
|
|
4652
4916
|
attribute: "given to a data-i18n* attribute",
|
|
4653
4917
|
property: "given to a property that holds a key (i18n, code, data-i18n*)",
|
|
4654
4918
|
array: "given as an element of a list of keys",
|
|
@@ -4973,6 +5237,7 @@ function shape_owner_check(shape, keys, shapes)
|
|
|
4973
5237
|
***************************************************************/
|
|
4974
5238
|
function collect_used_keys(opts)
|
|
4975
5239
|
{
|
|
5240
|
+
GAVE_UP.clear();
|
|
4976
5241
|
let keys = new Set();
|
|
4977
5242
|
let lib_keys = new Set();
|
|
4978
5243
|
let attr_keys = opts.attr_keys || [];
|
|
@@ -5131,6 +5396,14 @@ function collect_used_keys(opts)
|
|
|
5131
5396
|
}
|
|
5132
5397
|
}
|
|
5133
5398
|
|
|
5399
|
+
/* Where the reader gave up: a key behind it would go unasked */
|
|
5400
|
+
for(let g of gave_up()) {
|
|
5401
|
+
let module = lib_module_of(g.url);
|
|
5402
|
+
let label = module? `gobj-ui/src/${module}` : g.url? relative(process.cwd(), fileURLToPath(g.url)) : "?";
|
|
5403
|
+
fail(`${label}:${g.line}: the reader gave up on \`${g.text}\`, and a key behind it would go ` +
|
|
5404
|
+
`unasked: ${g.why}`);
|
|
5405
|
+
}
|
|
5406
|
+
|
|
5134
5407
|
return {keys, lib_keys};
|
|
5135
5408
|
}
|
|
5136
5409
|
|
|
@@ -5303,12 +5576,18 @@ function node_tree_keys(config, keys, is_key)
|
|
|
5303
5576
|
* the item in every layout -- a tab, an entry of a vertical menu,
|
|
5304
5577
|
* a submenu or an icon bar, a card, an accordion head, a crumb
|
|
5305
5578
|
* (`name || aria_label || id`: c_yui_nav.js, nav_cards_helpers.js)
|
|
5306
|
-
* -- and its title too, when it has no `tooltip`;
|
|
5579
|
+
* -- and its title too, when it has no `tooltip`; the navs its
|
|
5580
|
+
* submenu opens, and the landing of a SECTION INDEX it opens
|
|
5581
|
+
* (`submenu.index`), are labelled the same way (c_yui_shell.js,
|
|
5582
|
+
* shell_section_index.js), so they ask for nothing more;
|
|
5307
5583
|
* - when it has no `name`, in a menu drawn as a BREADCRUMB that shows
|
|
5308
|
-
* its labels: the text of the crumb is `name || id
|
|
5309
|
-
*
|
|
5310
|
-
*
|
|
5311
|
-
*
|
|
5584
|
+
* its labels: the text of the crumb is `name || id`.
|
|
5585
|
+
*
|
|
5586
|
+
* And the id of a MENU (`menu.<id>`) drawn as a "submenu" in a zone
|
|
5587
|
+
* that hosts it: that layout heads the nav with its `nav_label`, and
|
|
5588
|
+
* the shell gives a menu none, so the heading is the menu's id, as a
|
|
5589
|
+
* key (render_submenu(), c_yui_nav.js). Up to gobj-ui 7.26.42 the
|
|
5590
|
+
* validator did not ask for it.
|
|
5312
5591
|
*
|
|
5313
5592
|
* The items are those of every menu (`menu.<id>.items`) and of every
|
|
5314
5593
|
* submenu of them (`submenu.items`) -- and the rows of the dropdown
|
|
@@ -5334,7 +5613,8 @@ function menu_item_keys(config, keys, is_key)
|
|
|
5334
5613
|
let cfg = (typeof r === "string")? {layout: r} : r;
|
|
5335
5614
|
return !!cfg && typeof cfg === "object" && cfg.layout === "breadcrumb" && cfg.show_label !== false;
|
|
5336
5615
|
};
|
|
5337
|
-
let
|
|
5616
|
+
let layout_of = (r) => (typeof r === "string")? r : (r && typeof r === "object")? r.layout : null;
|
|
5617
|
+
let read_items = (items, crumbs) => {
|
|
5338
5618
|
for(let it of (Array.isArray(items)? items : [])) {
|
|
5339
5619
|
if(!it || typeof it !== "object" || it.type === "header" || it.type === "divider") {
|
|
5340
5620
|
continue;
|
|
@@ -5349,17 +5629,14 @@ function menu_item_keys(config, keys, is_key)
|
|
|
5349
5629
|
* as an entry is (route_map_model.js, nav_node_from_item()) */
|
|
5350
5630
|
let a = it.action;
|
|
5351
5631
|
if(a && typeof a === "object" && a.type === "dropdown") {
|
|
5352
|
-
read_items(a.items, false
|
|
5632
|
+
read_items(a.items, false);
|
|
5353
5633
|
}
|
|
5354
5634
|
continue;
|
|
5355
5635
|
}
|
|
5356
|
-
if(top && sub.index && it.route && !it.target && !it.name) {
|
|
5357
|
-
ask(it.id);
|
|
5358
|
-
}
|
|
5359
5636
|
/* A submenu is drawn in each zone its `render` names ("*" is no
|
|
5360
5637
|
* zone for it) */
|
|
5361
5638
|
let render = (sub.render && typeof sub.render === "object")? sub.render : {};
|
|
5362
|
-
read_items(sub.items, Object.keys(render).some((z) => z !== "*" && draws_crumbs(render[z]))
|
|
5639
|
+
read_items(sub.items, Object.keys(render).some((z) => z !== "*" && draws_crumbs(render[z])));
|
|
5363
5640
|
}
|
|
5364
5641
|
};
|
|
5365
5642
|
for(let menu_id of Object.keys(menus)) {
|
|
@@ -5370,9 +5647,11 @@ function menu_item_keys(config, keys, is_key)
|
|
|
5370
5647
|
/* A menu is drawn in each zone that hosts it, with that zone's
|
|
5371
5648
|
* render, else the render "*", else a vertical menu */
|
|
5372
5649
|
let render = (menu.render && typeof menu.render === "object")? menu.render : {};
|
|
5373
|
-
let
|
|
5374
|
-
|
|
5375
|
-
|
|
5650
|
+
let hosts = Object.keys(zones).filter((z) => zones[z] && zones[z].host === `menu.${menu_id}`);
|
|
5651
|
+
if(hosts.some((z) => layout_of(render[z] || render["*"]) === "submenu")) {
|
|
5652
|
+
ask(menu_id);
|
|
5653
|
+
}
|
|
5654
|
+
read_items(menu.items, hosts.some((z) => draws_crumbs(render[z] || render["*"])));
|
|
5376
5655
|
}
|
|
5377
5656
|
}
|
|
5378
5657
|
|
|
@@ -5386,7 +5665,10 @@ function menu_item_keys(config, keys, is_key)
|
|
|
5386
5665
|
* - an action item (any `type` but "brand", "avatar", "connection");
|
|
5387
5666
|
* - the menu a dropdown opens (`action.type` "dropdown"), named as
|
|
5388
5667
|
* its trigger, except an avatar's, which the shell names "user
|
|
5389
|
-
* menu"
|
|
5668
|
+
* menu" -- and the one a RIGHT-click opens (`context_action`, which
|
|
5669
|
+
* the shell wires on an action item and on a connection), named
|
|
5670
|
+
* the same way (up to gobj-ui 7.26.42 the shell named it by the
|
|
5671
|
+
* raw id, and the validator did not read it);
|
|
5390
5672
|
* - each entry of that menu (`action.items`) that is drawn: not a
|
|
5391
5673
|
* divider, and with an `action` of its own;
|
|
5392
5674
|
* - each row the SITE MAP draws under a toolbar node that is not the
|
|
@@ -5440,8 +5722,16 @@ function toolbar_item_keys(config, keys, is_key)
|
|
|
5440
5722
|
if(kind === "action" && nameless(it)) {
|
|
5441
5723
|
ask(it.id);
|
|
5442
5724
|
}
|
|
5443
|
-
|
|
5444
|
-
|
|
5725
|
+
/* The menu a click opens, and the one a right-click opens: the
|
|
5726
|
+
* shell wires `context_action` on an action item and a connection */
|
|
5727
|
+
let actions = [it.action];
|
|
5728
|
+
if(kind === "action" || kind === "connection") {
|
|
5729
|
+
actions.push(it.context_action);
|
|
5730
|
+
}
|
|
5731
|
+
for(let action of actions) {
|
|
5732
|
+
if(!action || typeof action !== "object" || action.type !== "dropdown") {
|
|
5733
|
+
continue;
|
|
5734
|
+
}
|
|
5445
5735
|
if(kind !== "avatar" && nameless(it)) {
|
|
5446
5736
|
ask(it.id);
|
|
5447
5737
|
}
|
|
@@ -5568,6 +5858,8 @@ function lib_imports(ast, barrel, lib_module)
|
|
|
5568
5858
|
/* The readers, for a test of the library and for an app whose catalog
|
|
5569
5859
|
* has another shape (gobj-ui's test-app) */
|
|
5570
5860
|
export {
|
|
5861
|
+
CODE_KEY_MODULES,
|
|
5862
|
+
gave_up,
|
|
5571
5863
|
parse_source,
|
|
5572
5864
|
walk,
|
|
5573
5865
|
line_of,
|