@yuneta/gobj-ui 7.23.195 → 7.23.196

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 CHANGED
@@ -2003,16 +2003,17 @@ columns**, each in its declared `order`, with the storage composed underneath
2003
2003
  the qualified id, the fkey to the parent, the place among the siblings, and the
2004
2004
  versions that publish the change.
2005
2005
 
2006
- **The versions are the point, not a detail.** `topic_version` is what publishes
2007
- a change of a topic's columns: leave it and the persisted `topic_cols.json`
2008
- masks the whole edit — the restart succeeds and nothing moved. `schema_version`
2009
- is what publishes the schema as a whole ("the stored one wins on ties, and the
2010
- incoming one has to be strictly newer to take over", `c_treedb.c`), and raising
2011
- it is safe: re-projection from C compares `c_schema_version`, the version of
2012
- the **literal**, precisely so that an edit made here survives every start until
2013
- a newer literal arrives. So **every write carries both** and the operator is
2014
- never asked to remember either. The banner in the column screen is for the case
2015
- where something *else* wrote the topic and left its version alone.
2006
+ **An edit here is a draft** (7.23.196, with the SDK's M36 design). A write moves
2007
+ no version and reaches no treedb. The HOST publishes it with `C_TREEDB`'s
2008
+ `save-schema`, which raises the `topic_version` of each topic that changed
2009
+ (the one that regenerates `topic_cols.json`) and the `schema_version` (the one
2010
+ that makes the schema file win over the literal), once, and puts it in use with
2011
+ `apply-schema` and a restart of the owning yuno. Until 7.23.195 every write
2012
+ here raised both numbers, so an edit half made was already the schema of the
2013
+ next start. The topic list marks what this session wrote and has not saved,
2014
+ and the column screen says so in a banner; the host sends `EV_REFRESH` after a
2015
+ save, and the reload forgets the drafts. The export (C literal and JSON) warns
2016
+ while there are drafts: the literal carries the versions a save publishes.
2016
2017
 
2017
2018
  What the screens offer:
2018
2019
 
@@ -70163,10 +70163,11 @@ function register_c_yui_treedb_schema() {
70163
70163
  * operator drew does nothing at all. Restarting on
70164
70164
  * this is an outage with no gain.
70165
70165
  * `warning` the schema opens and something is not what it looks
70166
- * like — an unbumped `topic_version` masking the whole
70167
- * edit is the one that costs the most time, because
70168
- * the restart SUCCEEDS and the change is simply not
70169
- * there.
70166
+ * like.
70167
+ *
70168
+ * A version is not checked here: an edit is a DRAFT and moves no
70169
+ * version, and C_TREEDB's save-schema raises the versions of what
70170
+ * changed when it publishes it.
70170
70171
  *
70171
70172
  * Every `code` is an i18n key: the caller renders, this decides.
70172
70173
  *
@@ -70213,9 +70214,6 @@ var FKEY_TYPES = [
70213
70214
  ***************************************************************/
70214
70215
  function validate_schema(treedb, options) {
70215
70216
  let findings = [];
70216
- let opts = options || {};
70217
- let written = Array.isArray(opts.written_topics) ? opts.written_topics : [];
70218
- let baseline = opts.baseline || {};
70219
70217
  if (!treedb || !Array.isArray(treedb.topics)) return findings;
70220
70218
  let add = (severity, code, topic, col, detail) => {
70221
70219
  findings.push({
@@ -70236,10 +70234,6 @@ function validate_schema(treedb, options) {
70236
70234
  let pkey = topic.pkey || "id";
70237
70235
  if (col_names.indexOf(pkey) < 0) add("error", "pkey names no column", topic.name, "", pkey);
70238
70236
  for (let pkey2 of topic_pkey2s(topic.record)) if (col_names.indexOf(pkey2) < 0) add("error", "pkey2 names no column", topic.name, "", pkey2);
70239
- if (written.indexOf(topic.id) >= 0) {
70240
- let before = baseline[topic.id];
70241
- if (before !== void 0 && String(before) === String(topic.topic_version)) add("warning", "topic version not bumped", topic.name, "", String(topic.topic_version));
70242
- }
70243
70237
  for (let col of topic.cols) {
70244
70238
  let flags = col_flags(col.record);
70245
70239
  let type = col.record ? col.record.type : "";
@@ -71508,13 +71502,15 @@ function write_options(op) {
71508
71502
  * fkey, the order of a new sibling, the version that publishes
71509
71503
  * the change.
71510
71504
  *
71511
- * THE VERSION IS THE POINT, not a detail. A topic whose columns
71512
- * changed and whose `topic_version` did not is a topic whose
71513
- * persisted `topic_cols.json` masks the whole edit: the restart
71514
- * succeeds and nothing moved. Nothing in the store says so, and
71515
- * the log that would is on the node. So every write here raises
71516
- * the version of the topic it touched, and the toolbar says which
71517
- * topics are waiting for a restart.
71505
+ * AN EDIT IS A DRAFT. A write here moves no version and reaches no
71506
+ * treedb: the host SAVES it (C_TREEDB's save-schema raises the
71507
+ * topic_version of what changed and the schema_version, once) and
71508
+ * APPLIES it (apply-schema + a restart of the owning yuno). Until
71509
+ * the owner's design of M36 (2026-09-21 review) every write here
71510
+ * raised both versions, so an edit half made was already the
71511
+ * schema of the next start. The topic list marks what this session
71512
+ * wrote and has not saved; the host's EV_REFRESH after a save is
71513
+ * what forgets it.
71518
71514
  *
71519
71515
  * WHAT ELSE IS HERE, and why each is here and not somewhere else:
71520
71516
  *
@@ -71859,16 +71855,20 @@ function start_measuring(gobj) {
71859
71855
  for (let treedb of priv.model.treedbs) for (let topic of treedb.topics) priv.baseline[topic.id] = topic.topic_version;
71860
71856
  }
71861
71857
  /***************************************************************
71862
- * "This topic was written and its version did not move."
71858
+ * "This topic was written in this session and is not saved."
71863
71859
  *
71864
- * ONE predicate, because it is asked in two places -- the topic
71865
- * list draws a chip with it and the column view draws a banner --
71866
- * and two copies of a rule is how they drift.
71860
+ * An edit is a DRAFT: it moves no version and reaches no treedb
71861
+ * until the host saves it (C_TREEDB's save-schema, which raises the
71862
+ * versions of what changed) -- and the save makes the host send
71863
+ * EV_REFRESH, whose reload is what forgets the drafts.
71864
+ *
71865
+ * ONE predicate, because it is asked in three places -- the topic
71866
+ * list draws a chip with it, the column view a banner, the export
71867
+ * a warning -- and copies of a rule are how they drift.
71867
71868
  ***************************************************************/
71868
- function needs_version_bump(written, baseline, topic) {
71869
- if (!topic || !written || !baseline) return false;
71870
- if (!written[topic.id]) return false;
71871
- return String(baseline[topic.id]) === String(topic.topic_version);
71869
+ function topic_is_draft(written, topic) {
71870
+ if (!topic || !written) return false;
71871
+ return written[topic.id] ? true : false;
71872
71872
  }
71873
71873
  /***************************************************************
71874
71874
  * Say what the whole store would be refused for.
@@ -72310,7 +72310,7 @@ function render_topics(gobj, $body) {
72310
72310
  let twice = repeated_names(treedb.topics);
72311
72311
  let $rows = [];
72312
72312
  for (let topic of treedb.topics) {
72313
- let pending = needs_version_bump(priv.written, priv.baseline, topic);
72313
+ let pending = topic_is_draft(priv.written, topic);
72314
72314
  let ambiguous = !!twice[topic.name];
72315
72315
  let address = ambiguous ? topic.id : topic.name;
72316
72316
  let $actions = [];
@@ -72545,7 +72545,7 @@ function render_columns(gobj, $body) {
72545
72545
  { class: "SCHEMA_COLUMNS p-3" },
72546
72546
  []
72547
72547
  ]);
72548
- let $banner = version_banner(gobj, topic);
72548
+ let $banner = draft_banner(gobj, topic);
72549
72549
  if ($banner) $wrap.appendChild($banner);
72550
72550
  let twice = repeated_names(topic.cols);
72551
72551
  let $rows = [];
@@ -72623,66 +72623,37 @@ function render_columns(gobj, $body) {
72623
72623
  (0, _yuneta_gobj_js.refresh_language)($wrap, i18next.t);
72624
72624
  }
72625
72625
  /***************************************************************
72626
- * "This topic changed and its version did not."
72626
+ * "This topic has changes that are not saved."
72627
72627
  *
72628
- * Only shown when it is TRUE — the topic was written in this
72629
- * session and its `topic_version` still reads what it read when
72630
- * the model loaded. Every write this view makes raises it, so
72631
- * the banner is for the case where something else did not: an
72632
- * edit made from the raw tables, or a bump undone by hand.
72628
+ * A draft, not an error: the edit is in __system__ and moves no
72629
+ * version, so the treedb does not see it until the host saves it
72630
+ * (and applies it). The banner says so and offers nothing -- the
72631
+ * save is the host's, one level up, because it publishes the whole
72632
+ * treedb and not one topic.
72633
72633
  ***************************************************************/
72634
- function version_banner(gobj, topic) {
72634
+ function draft_banner(gobj, topic) {
72635
72635
  let priv = gobj.priv;
72636
- if (!needs_version_bump(priv.written, priv.baseline, topic)) return null;
72636
+ if (!topic_is_draft(priv.written, topic)) return null;
72637
72637
  if (is_readonly(gobj)) return null;
72638
- let $banner = (0, _yuneta_gobj_js.createElement2)([
72638
+ return (0, _yuneta_gobj_js.createElement2)([
72639
72639
  "div",
72640
72640
  {
72641
- class: "SCHEMA_VERSION_BANNER notification is-warning is-light p-3 mb-3 is-flex is-align-items-center",
72641
+ class: "SCHEMA_DRAFT_BANNER notification is-warning is-light p-3 mb-3 is-flex is-align-items-center",
72642
72642
  style: "gap:.5rem;"
72643
72643
  },
72644
- [
72645
- [
72646
- "span",
72647
- { class: "icon" },
72648
- [["i", { class: "yi-triangle-exclamation" }]]
72649
- ],
72650
- [
72651
- "span",
72652
- {
72653
- class: "SCHEMA_VERSION_TEXT is-size-7",
72654
- i18n: "version not raised"
72655
- },
72656
- (0, i18next.t)("version not raised")
72657
- ],
72658
- [
72659
- "button",
72660
- {
72661
- class: "SCHEMA_VERSION_BUMP button is-warning",
72662
- type: "button",
72663
- style: "margin-left:auto;",
72664
- title: (0, i18next.t)("raise the version"),
72665
- "aria-label": (0, i18next.t)("raise the version"),
72666
- "data-i18n-title": "raise the version",
72667
- "data-i18n-aria-label": "raise the version"
72668
- },
72669
- [[
72670
- "span",
72671
- { class: "icon" },
72672
- [["i", { class: "yi-circle-up" }]]
72673
- ], [
72674
- "span",
72675
- { i18n: "raise" },
72676
- (0, i18next.t)("raise")
72677
- ]]
72678
- ]
72679
- ]
72644
+ [[
72645
+ "span",
72646
+ { class: "icon" },
72647
+ [["i", { class: "yi-triangle-exclamation" }]]
72648
+ ], [
72649
+ "span",
72650
+ {
72651
+ class: "SCHEMA_DRAFT_TEXT is-size-7",
72652
+ i18n: "unsaved schema changes: save to publish them"
72653
+ },
72654
+ (0, i18next.t)("unsaved schema changes: save to publish them")
72655
+ ]]
72680
72656
  ]);
72681
- $banner.querySelector(".SCHEMA_VERSION_BUMP").addEventListener("click", (evt) => {
72682
- evt.stopPropagation();
72683
- (0, _yuneta_gobj_js.gobj_send_event)(gobj, "EV_BUMP_VERSION", { topic: topic.name }, gobj);
72684
- });
72685
- return $banner;
72686
72657
  }
72687
72658
  /***************************************************************
72688
72659
  * One column, as a row. The drag events carry INDEXES in the
@@ -73551,6 +73522,8 @@ function open_report(gobj, findings, treedb_id) {
73551
73522
  * as a download, which a published page cannot start anyway.
73552
73523
  ***************************************************************/
73553
73524
  function open_export(gobj, treedb) {
73525
+ let priv = gobj.priv;
73526
+ let drafts = treedb.topics.some((topic) => topic_is_draft(priv.written, topic));
73554
73527
  let c_text = schema_to_c(treedb);
73555
73528
  let json_text = JSON.stringify(schema_to_json(treedb), null, 4);
73556
73529
  let $content = (0, _yuneta_gobj_js.createElement2)([
@@ -73604,13 +73577,29 @@ function open_export(gobj, treedb) {
73604
73577
  },
73605
73578
  (0, i18next.t)("an edit made here works and lives in no source: this is what to paste back")
73606
73579
  ],
73580
+ drafts ? [
73581
+ "p",
73582
+ {
73583
+ class: "SCHEMA_EXPORT_DRAFTS notification is-warning is-light p-2 mb-2 is-size-7",
73584
+ i18n: "unsaved changes: save first, so the literal carries the versions that publish it"
73585
+ },
73586
+ (0, i18next.t)("unsaved changes: save first, so the literal carries the versions that publish it")
73587
+ ] : [
73588
+ "span",
73589
+ {},
73590
+ ""
73591
+ ],
73607
73592
  [
73608
73593
  "textarea",
73609
73594
  {
73610
73595
  class: "SCHEMA_EXPORT_TEXT textarea is-small is-family-monospace",
73611
73596
  rows: "18",
73612
73597
  readonly: "readonly",
73613
- spellcheck: "false"
73598
+ spellcheck: "false",
73599
+ title: (0, i18next.t)("schema"),
73600
+ "data-i18n-title": "schema",
73601
+ "aria-label": (0, i18next.t)("schema"),
73602
+ "data-i18n-aria-label": "schema"
73614
73603
  },
73615
73604
  c_text
73616
73605
  ],
@@ -73624,7 +73613,11 @@ function open_export(gobj, treedb) {
73624
73613
  "button",
73625
73614
  {
73626
73615
  class: "SCHEMA_EXPORT_COPY button",
73627
- type: "button"
73616
+ type: "button",
73617
+ title: (0, i18next.t)("copy"),
73618
+ "data-i18n-title": "copy",
73619
+ "aria-label": (0, i18next.t)("copy"),
73620
+ "data-i18n-aria-label": "copy"
73628
73621
  },
73629
73622
  [[
73630
73623
  "span",
@@ -73959,52 +73952,6 @@ function open_orphans(gobj) {
73959
73952
  * Writing
73960
73953
  ***************************/
73961
73954
  /***************************************************************
73962
- * THE TWO VERSIONS A SCHEMA EDIT HAS TO RAISE, and why both.
73963
- *
73964
- * `topic_version` is what publishes a change of a topic's
73965
- * columns: leave it and the persisted `topic_cols.json` masks
73966
- * the edit, the restart succeeds and nothing moved.
73967
- *
73968
- * `schema_version` is what publishes the schema as a whole —
73969
- * "the stored one wins on ties, and the incoming one has to be
73970
- * strictly newer to take over" (c_treedb.c). It is safe to
73971
- * raise: re-projection from C compares `c_schema_version`, the
73972
- * version of the LITERAL, precisely so that an edit made here
73973
- * survives every start until a newer literal arrives.
73974
- *
73975
- * So every write that changes a schema carries both, and the
73976
- * operator is never asked to remember either.
73977
- ***************************************************************/
73978
- function version_writes(gobj, topic) {
73979
- let treedb = current_treedb(gobj);
73980
- let writes = [];
73981
- if (topic) {
73982
- let version = Number(topic.topic_version);
73983
- if (!isFinite(version)) version = 0;
73984
- writes.push({
73985
- op: "update",
73986
- topic_name: T_TOPICS,
73987
- record: {
73988
- id: topic.id,
73989
- topic_version: version + 1
73990
- }
73991
- });
73992
- }
73993
- if (treedb) {
73994
- let version = Number(treedb.schema_version);
73995
- if (!isFinite(version)) version = 0;
73996
- writes.push({
73997
- op: "update",
73998
- topic_name: T_TREEDBS,
73999
- record: {
74000
- id: treedb.id,
74001
- schema_version: version + 1
74002
- }
74003
- });
74004
- }
74005
- return writes;
74006
- }
74007
- /***************************************************************
74008
73955
  * WHERE THE COLUMNS WERE before this session started moving them.
74009
73956
  *
74010
73957
  * A drag is a WRITE: the order is a field of the column, so the drop
@@ -74463,7 +74410,7 @@ function ac_save_column(gobj, event, kw, src) {
74463
74410
  op: kw.creating ? "create" : "update",
74464
74411
  topic_name: T_COLS,
74465
74412
  record: column_record(gobj, topic, col, values)
74466
- }].concat(version_writes(gobj, topic)));
74413
+ }]);
74467
74414
  }
74468
74415
  function ac_delete_column(gobj, event, kw, src) {
74469
74416
  let priv = gobj.priv;
@@ -74514,7 +74461,7 @@ function ac_move_column(gobj, event, kw, src) {
74514
74461
  };
74515
74462
  });
74516
74463
  if (writes.length === 0) return 0;
74517
- return queue_writes(gobj, writes.concat(version_writes(gobj, topic)));
74464
+ return queue_writes(gobj, writes);
74518
74465
  }
74519
74466
  /***************************************************************
74520
74467
  * Put the columns back where they were before the dragging
@@ -74534,7 +74481,7 @@ function ac_undo_order(gobj, event, kw, src) {
74534
74481
  return 0;
74535
74482
  }
74536
74483
  delete priv.order_undo[topic.id];
74537
- return queue_writes(gobj, writes.concat(version_writes(gobj, topic)));
74484
+ return queue_writes(gobj, writes);
74538
74485
  }
74539
74486
  /***************************************************************
74540
74487
  * Editing a topic.
@@ -74587,7 +74534,7 @@ function ac_save_topic(gobj, event, kw, src) {
74587
74534
  op: kw.creating ? "create" : "update",
74588
74535
  topic_name: T_TOPICS,
74589
74536
  record: topic_record(gobj, treedb, topic, values)
74590
- }].concat(version_writes(gobj, null)));
74537
+ }]);
74591
74538
  }
74592
74539
  function ac_delete_topic(gobj, event, kw, src) {
74593
74540
  let priv = gobj.priv;
@@ -74604,20 +74551,6 @@ function ac_delete_topic(gobj, event, kw, src) {
74604
74551
  return 0;
74605
74552
  }
74606
74553
  /***************************************************************
74607
- * Raising a version by hand: what the banner offers when
74608
- * something else wrote the topic and left its version alone.
74609
- ***************************************************************/
74610
- function ac_bump_version(gobj, event, kw, src) {
74611
- let priv = gobj.priv;
74612
- let topic = find_topic(priv.model, priv.treedb_id, kw.topic);
74613
- if (refuse_if_readonly(gobj, event)) return -1;
74614
- if (!topic) {
74615
- (0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: ${event} names no topic: ${kw.topic}`);
74616
- return -1;
74617
- }
74618
- return queue_writes(gobj, version_writes(gobj, topic));
74619
- }
74620
- /***************************************************************
74621
74554
  * Deleting a leftover.
74622
74555
  ***************************************************************/
74623
74556
  function ac_delete_orphan(gobj, event, kw, src) {
@@ -74766,11 +74699,10 @@ function ac_confirmed(gobj, event, kw, src) {
74766
74699
  topic_name: T_TOPICS,
74767
74700
  record: { id: topic.id }
74768
74701
  });
74769
- return queue_writes(gobj, writes.concat(version_writes(gobj, null)));
74702
+ return queue_writes(gobj, writes);
74770
74703
  }
74771
74704
  if (kw.what === "column") {
74772
- let topic = find_topic(priv.model, priv.treedb_id, kw.topic);
74773
- let col = topic ? find_col(priv.model, priv.treedb_id, kw.topic, kw.col) : null;
74705
+ let col = find_topic(priv.model, priv.treedb_id, kw.topic) ? find_col(priv.model, priv.treedb_id, kw.topic, kw.col) : null;
74774
74706
  if (!col) {
74775
74707
  (0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: ${event} names no column: ${kw.col}`);
74776
74708
  return -1;
@@ -74779,7 +74711,7 @@ function ac_confirmed(gobj, event, kw, src) {
74779
74711
  op: "delete",
74780
74712
  topic_name: T_COLS,
74781
74713
  record: { id: col.id }
74782
- }].concat(version_writes(gobj, topic)));
74714
+ }]);
74783
74715
  }
74784
74716
  (0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: ${event} of nothing this view asked about: ${kw.what}`);
74785
74717
  return -1;
@@ -74968,11 +74900,6 @@ function create_gclass$1(gclass_name) {
74968
74900
  "EV_UNDO_ORDER",
74969
74901
  ac_undo_order,
74970
74902
  null
74971
- ],
74972
- [
74973
- "EV_BUMP_VERSION",
74974
- ac_bump_version,
74975
- null
74976
74903
  ]
74977
74904
  ])],
74978
74905
  ["ST_SAVING", COMMON.slice()]
@@ -75001,7 +74928,6 @@ function create_gclass$1(gclass_name) {
75001
74928
  ["EV_SAVE_COLUMN", 0],
75002
74929
  ["EV_MOVE_COLUMN", 0],
75003
74930
  ["EV_UNDO_ORDER", 0],
75004
- ["EV_BUMP_VERSION", 0],
75005
74931
  ["EV_VALIDATE", 0],
75006
74932
  ["EV_EXPORT", 0],
75007
74933
  ["EV_IMPORT", 0],