@yuneta/gobj-ui 7.26.7 → 7.26.9

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.
Files changed (46) hide show
  1. package/README.md +53 -0
  2. package/dist/gobj-ui.cjs.js +534 -232
  3. package/dist/gobj-ui.es.js +534 -232
  4. package/package.json +2 -2
  5. package/src/c_g6_nodes_tree.js +65 -31
  6. package/src/c_yui_form.js +230 -63
  7. package/src/c_yui_gclass.js +23 -22
  8. package/src/c_yui_gobj_tree_js.js +13 -9
  9. package/src/c_yui_json.js +7 -6
  10. package/src/c_yui_json_graph.js +8 -7
  11. package/src/c_yui_json_pad.js +2 -1
  12. package/src/c_yui_map.js +25 -1
  13. package/src/c_yui_nav.js +9 -8
  14. package/src/c_yui_schema_editor.js +25 -24
  15. package/src/c_yui_shell.js +64 -3
  16. package/src/c_yui_treedb_topic_with_form.js +26 -21
  17. package/src/c_yui_treedb_topics.js +17 -16
  18. package/src/c_yui_window.js +73 -32
  19. package/src/c_yui_window_manager.js +3 -2
  20. package/src/form_json_field.js +10 -3
  21. package/src/form_json_field.test.js +6 -0
  22. package/src/form_json_field.wiring.test.js +1 -1
  23. package/src/form_table_rearm.wiring.test.js +158 -0
  24. package/src/form_toolbar_plan.js +5 -5
  25. package/src/g6_event_kw.js +36 -0
  26. package/src/map_stop_windows.wiring.test.js +112 -0
  27. package/src/nav_cards_helpers.js +2 -1
  28. package/src/nav_cards_helpers.test.js +7 -3
  29. package/src/overlay_marker_after_back.wiring.test.js +212 -0
  30. package/src/schema_to_c.js +10 -0
  31. package/src/schema_to_c.test.js +8 -1
  32. package/src/shell_modals.js +7 -5
  33. package/src/shell_route_map.js +12 -13
  34. package/src/treedb_topics_transport.wiring.test.js +26 -0
  35. package/src/vite_plugin_yuneta_html.test.js +94 -0
  36. package/src/window_show.wiring.test.js +83 -0
  37. package/src/window_veto_back.wiring.test.js +35 -0
  38. package/src/yui_asset.js +3 -2
  39. package/src/yui_data_color.js +33 -0
  40. package/src/yui_data_color.test.js +27 -0
  41. package/src/yui_dev.js +15 -13
  42. package/src/yui_frontend_view.js +4 -4
  43. package/src/yui_gclass_view.js +3 -3
  44. package/src/yui_text.js +43 -0
  45. package/src/yui_text.test.js +67 -0
  46. package/vite-plugin-yuneta-html.js +24 -5
@@ -0,0 +1,67 @@
1
+ /***********************************************************************
2
+ * yui_text.test.js
3
+ *
4
+ * Data goes into createElement2() as a Text node: a string that
5
+ * starts with '<' is parsed as markup there.
6
+ *
7
+ * Copyright (c) 2026, ArtGins.
8
+ * All Rights Reserved.
9
+ ***********************************************************************/
10
+ import {describe, test, expect} from "vitest";
11
+ import {install_dom_double} from "../test/dom_double.js";
12
+
13
+ install_dom_double();
14
+
15
+ const {createElement2} = await import("@yuneta/gobj-js");
16
+ const {
17
+ SDATA_END, gclass_create, gobj_start_up, gobj_create_yuno, gobj_create,
18
+ gobj_read_attr, set_log_callback
19
+ } = await import("@yuneta/gobj-js");
20
+ const {text_node, text_title_formatter} = await import("./yui_text.js");
21
+ const {register_c_yui_nav} = await import("./c_yui_nav.js");
22
+ const {card_descriptor} = await import("./nav_cards_helpers.js");
23
+
24
+ const EVIL = "<img src=x onerror=alert(1)>";
25
+
26
+ describe("text_node()", () => {
27
+ test("a value that looks like markup stays text", () => {
28
+ const $el = createElement2(["span", {}, text_node(EVIL)]);
29
+ expect($el.querySelector("img")).toBe(null);
30
+ expect($el.textContent).toBe(EVIL);
31
+ });
32
+
33
+ test("trimmed like a string content, and null is empty", () => {
34
+ expect(text_node(" a ").textContent).toBe("a");
35
+ expect(text_node(null).textContent).toBe("");
36
+ expect(text_node(0).textContent).toBe("0");
37
+ });
38
+
39
+ test("a nav card named by a backend (set_submenu) shows its name as text", () => {
40
+ const $card = createElement2(card_descriptor({id: "x", name: EVIL, route: "/x"}, true));
41
+ expect($card.querySelector("img")).toBe(null);
42
+ expect($card.textContent).toContain(EVIL);
43
+ });
44
+
45
+ test("a Tabulator column titled from a schema `header` shows it as text", () => {
46
+ const $title = text_title_formatter({getValue: () => EVIL});
47
+ expect($title instanceof Text).toBe(true);
48
+ expect($title.textContent).toBe(EVIL);
49
+ });
50
+
51
+ test("the accordion nav shows a section named by a backend as text", async () => {
52
+ const i18next = (await import("i18next")).default;
53
+ await i18next.init({lng: "en", resources: {}});
54
+ gobj_start_up(null, null, null, null, null, null, null);
55
+ set_log_callback(() => {});
56
+ gclass_create("C_TEST_TEXT_HOST", [], [["ST_IDLE", []]], {}, 0, [SDATA_END()], {}, 0, 0, 0, 0);
57
+ register_c_yui_nav();
58
+ const yuno = gobj_create_yuno("text_yuno", "C_TEST_TEXT_HOST", {});
59
+ const nav = gobj_create("acc", "C_YUI_NAV", {
60
+ layout: "accordion",
61
+ menu_items: [{id: "h", name: EVIL, submenu: {items: [{id: "s", name: EVIL, route: "/s"}]}}]
62
+ }, yuno);
63
+ const $c = gobj_read_attr(nav, "$container");
64
+ expect($c.querySelector("img")).toBe(null);
65
+ expect($c.querySelector(".yui-accordion-head").textContent).toBe(EVIL);
66
+ });
67
+ });
@@ -7,7 +7,8 @@
7
7
  * - <meta> tags from config.metadata
8
8
  * - Content-Security-Policy from config.csp_connect_src
9
9
  * (always emitted: connect-src 'self' alone when the
10
- * list is missing, with a warning)
10
+ * list is missing, with a warning; an entry that is
11
+ * not one CSP source -- a `;`, `,` or space -- is refused)
11
12
  *
12
13
  * Usage in vite.config.js (vendored copy):
13
14
  * import { yunetaHtmlPlugin } from "./src/gobj-ui/vite-plugin-yuneta-html.js";
@@ -44,13 +45,15 @@ export function yunetaHtmlPlugin(options = {}) {
44
45
  const configPath = options.configPath ||
45
46
  path.resolve(process.cwd(), "config.json");
46
47
 
48
+ /* Without a config.json the page still gets its policy
49
+ * (connect-src 'self' only): it used to get none at all. */
50
+ let config = {};
47
51
  if (!fs.existsSync(configPath)) {
48
52
  console.error("⚠️ config.json not found at", configPath);
49
- return html;
53
+ } else {
54
+ config = JSON.parse(fs.readFileSync(configPath, "utf-8"));
50
55
  }
51
56
 
52
- const config = JSON.parse(fs.readFileSync(configPath, "utf-8"));
53
-
54
57
  /*------------------------------------------*
55
58
  * Title
56
59
  *------------------------------------------*/
@@ -101,8 +104,24 @@ export function yunetaHtmlPlugin(options = {}) {
101
104
  {
102
105
  let origins = [];
103
106
  if (Array.isArray(config.csp_connect_src)) {
107
+ /* Escaped: an origin lands inside the content="..."
108
+ * attribute, where a quote would end it. */
104
109
  origins = config.csp_connect_src
105
- .filter(s => !s.startsWith("_comment"));
110
+ .filter(s => typeof s === "string" && !s.startsWith("_comment"))
111
+ .filter(s => {
112
+ /* One SOURCE of the CSP grammar: a `;` would
113
+ * open a new directive (`wss://a; base-uri *`),
114
+ * and a `,` or a space would add sources the
115
+ * entry does not name. */
116
+ if (/[;,\s]/.test(s)) {
117
+ console.error(
118
+ `❌ csp_connect_src entry refused, not a single source: ${JSON.stringify(s)}`
119
+ );
120
+ return false;
121
+ }
122
+ return true;
123
+ })
124
+ .map(escape_html);
106
125
  } else {
107
126
  console.warn(
108
127
  "⚠️ config.json has no csp_connect_src array: " +