@gramlot/gramlot 0.3.6 → 0.3.7

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/gramlot.js CHANGED
@@ -15353,7 +15353,7 @@ var VALUE = /* @__PURE__ */ Symbol("value");
15353
15353
  var META_ATTRS = /* @__PURE__ */ new Set([
15354
15354
  "_meta",
15355
15355
  "datapath",
15356
- "node_id",
15356
+ "nodeId",
15357
15357
  "ns",
15358
15358
  "form",
15359
15359
  "formId",
@@ -15480,7 +15480,7 @@ var SourceBagNode = class extends BagNode {
15480
15480
  /** Resolve a `#SYMBOL[.relpath]` path.
15481
15481
  * #FORM → nearest ancestor with formId set or form=true;
15482
15482
  * #ANCHOR → nearest ancestor with `_anchor` present;
15483
- * #<id> → node carrying that node_id. The anchor then resolves
15483
+ * #<id> → node carrying that nodeId. The anchor then resolves
15484
15484
  * `relpath` relatively (its own datapath chain is consulted). */
15485
15485
  _resolveSymbolicDatapath(path, raw) {
15486
15486
  const s = path.slice(1);
@@ -15497,7 +15497,7 @@ var SourceBagNode = class extends BagNode {
15497
15497
  if (!builder) {
15498
15498
  throw new Error(`#<id>: cannot resolve ${raw} on a node without builder`);
15499
15499
  }
15500
- anchor = builder.source.getNodeByAttr("node_id", symbol);
15500
+ anchor = builder.source.getNodeByAttr("nodeId", symbol);
15501
15501
  if (anchor === null || anchor === void 0) {
15502
15502
  throw new Error(`#<id>: cannot resolve ${raw}`);
15503
15503
  }
@@ -16030,7 +16030,7 @@ function validateElementValues(tag2, spec, value, attrs) {
16030
16030
  const supplied = { ...attrs };
16031
16031
  if (value !== null && value !== void 0) supplied.node_value = value;
16032
16032
  const known = new Set(signature.parameters.filter((p) => p.role === "attribute").map((p) => p.name));
16033
- const framework = /* @__PURE__ */ new Set(["node_label", "node_position", "node_id", "target_id", "datapath", "iterate", "store", "_tag", "_meta", "ns"]);
16033
+ const framework = /* @__PURE__ */ new Set(["node_label", "node_position", "nodeId", "target_id", "datapath", "iterate", "store", "_tag", "_meta", "ns"]);
16034
16034
  if (!signature.accepts_var_keyword) {
16035
16035
  for (const name of Object.keys(attrs)) if (!known.has(name) && !framework.has(name)) fail(tag2, `unknown attribute '${name}'`);
16036
16036
  }
@@ -16904,8 +16904,8 @@ var BuilderBase = class _BuilderBase {
16904
16904
  const branchBuilder = subbuilder || this;
16905
16905
  const branchBindings = value instanceof SourceBag ? value._builderBindingPlan(branchBuilder) : null;
16906
16906
  const rootBuilder = parentOverride?.rootBuilder || bag.root._builder || this;
16907
- if (attributes.node_id != null && rootBuilder.source.getNodeByAttr("node_id", attributes.node_id)) {
16908
- throw new Error(`Duplicate node_id '${attributes.node_id}'`);
16907
+ if (attributes.nodeId != null && rootBuilder.source.getNodeByAttr("nodeId", attributes.nodeId)) {
16908
+ throw new Error(`Duplicate nodeId '${attributes.nodeId}'`);
16909
16909
  }
16910
16910
  if (value instanceof SourceBag) {
16911
16911
  this._validateChildren(tag2, info, value.getNodes().map((node2) => node2.nodeTag), false);
@@ -17018,9 +17018,9 @@ var BuilderBase = class _BuilderBase {
17018
17018
  /** Source node carrying `nodeId` (per-builder id namespace), wrapped
17019
17019
  * so the grammar dispatch (`.li(...)`) works, like Python's __getattr__. */
17020
17020
  nodeById(nodeId) {
17021
- const node = this.source.getNodeByAttr("node_id", nodeId);
17021
+ const node = this.source.getNodeByAttr("nodeId", nodeId);
17022
17022
  if (node === null || node === void 0) {
17023
- throw new Error(`node_id not found: ${nodeId}`);
17023
+ throw new Error(`nodeId not found: ${nodeId}`);
17024
17024
  }
17025
17025
  return node.builder.wrapSource(node);
17026
17026
  }
@@ -23506,7 +23506,7 @@ var GramlotBuilderBagNode = class extends SourceBagNode {
23506
23506
  _finalizeAbsPath(path, attr) {
23507
23507
  return path === null ? null : super._finalizeAbsPath(path, attr);
23508
23508
  }
23509
- /** Builder's symbolic resolution; `#<node_id>` reads the node_id map of the page runtime when there is one (R06). */
23509
+ /** Builder's symbolic resolution; `#<nodeId>` reads the nodeId map of the page runtime when there is one (R06). */
23510
23510
  _resolveSymbolicDatapath(path, raw) {
23511
23511
  const symbol = path.slice(1).split(".", 1)[0];
23512
23512
  if (symbol === "FORM" || symbol === "ANCHOR") return super._resolveSymbolicDatapath(path, raw);
@@ -24374,11 +24374,11 @@ var GramlotBuilder = class _GramlotBuilder extends HtmlBuilder {
24374
24374
  evaluatePointerExpression(node, name, raw, expression, inputs) {
24375
24375
  return this.binding ? this.binding.inlineCompiler.compilePointerExpression(node, name, raw, expression.text)(inputs) : null;
24376
24376
  }
24377
- /** Builder's nodeById; inside a Gramlot page it reads the node_id map of the BindingRuntime (R06). */
24377
+ /** Builder's nodeById; inside a Gramlot page it reads the nodeId map of the BindingRuntime (R06). */
24378
24378
  nodeById(nodeId) {
24379
24379
  if (!this.binding) return super.nodeById(nodeId);
24380
24380
  const node = this.binding.nodeIds.get(nodeId);
24381
- if (!node) throw new Error(`node_id not found: ${nodeId}`);
24381
+ if (!node) throw new Error(`nodeId not found: ${nodeId}`);
24382
24382
  return node.builder.wrapSource(node);
24383
24383
  }
24384
24384
  loadCollection(document) {
@@ -26816,7 +26816,7 @@ var AskDialog = class {
26816
26816
  try {
26817
26817
  const builder = new GramlotBuilder();
26818
26818
  const dialog = builder.root.dialog({
26819
- node_id: id,
26819
+ nodeId: id,
26820
26820
  datapath: id,
26821
26821
  request: id,
26822
26822
  connect_oncancel: `${group}.cancel`,
@@ -26882,7 +26882,7 @@ var PROVIDERS = {
26882
26882
  dataRpc: RpcProvider,
26883
26883
  dataRemote: RemoteProvider
26884
26884
  };
26885
- var CONTEXT_ATTRIBUTES = ["datapath", "_anchor", "node_id", "form", "formId"];
26885
+ var CONTEXT_ATTRIBUTES = ["datapath", "_anchor", "nodeId", "form", "formId"];
26886
26886
  var BindingRuntime = class {
26887
26887
  #gramlot;
26888
26888
  #bindings = /* @__PURE__ */ new Map();
@@ -26947,7 +26947,7 @@ var BindingRuntime = class {
26947
26947
  get askDialog() {
26948
26948
  return this.#askDialog;
26949
26949
  }
26950
- /** `node_id → node` of the Source nodes with an open NodeBinding (R06). */
26950
+ /** `nodeId → node` of the Source nodes with an open NodeBinding (R06). */
26951
26951
  get nodeIds() {
26952
26952
  return this.#nodeIds;
26953
26953
  }
@@ -26988,7 +26988,7 @@ var BindingRuntime = class {
26988
26988
  const binding = this.bindingFor(node);
26989
26989
  if (binding) {
26990
26990
  this.#bindings.delete(node);
26991
- const nodeId = node.getAttr("node_id");
26991
+ const nodeId = node.getAttr("nodeId");
26992
26992
  if (this.nodeIds.get(nodeId) === node) this.nodeIds.delete(nodeId);
26993
26993
  try {
26994
26994
  binding.close();
@@ -27014,7 +27014,7 @@ var BindingRuntime = class {
27014
27014
  * Semantic work of one Source event, called inside the renderer FIFO (§5.2).
27015
27015
  *
27016
27016
  * The rows of the event matrix: opening and closing of the NodeBindings,
27017
- * the `node_id` map, the rebinding, and the installation of the `ins` and
27017
+ * the `nodeId` map, the rebinding, and the installation of the `ins` and
27018
27018
  * new-branch rows (§5.1 steps 2-5).
27019
27019
  *
27020
27020
  * A failing disposer does not block the rest of the event: the errors of the
@@ -27081,7 +27081,7 @@ var BindingRuntime = class {
27081
27081
  if (!binding.closed && binding.hasStamp("built")) this.#start(binding);
27082
27082
  }
27083
27083
  }
27084
- /** Close every NodeBinding, the `node_id` map and the Data subscription; a second call does nothing. */
27084
+ /** Close every NodeBinding, the `nodeId` map and the Data subscription; a second call does nothing. */
27085
27085
  dispose() {
27086
27086
  if (this.disposed) return;
27087
27087
  this.#disposed = true;
@@ -27099,8 +27099,8 @@ var BindingRuntime = class {
27099
27099
  if (errors.length) throw new AggregateError(errors, "Binding cleanup failed");
27100
27100
  }
27101
27101
  /**
27102
- * Steps 2-4 of §5.1 on `branch` (a SourceBagNode or a new SourceBag value). The `node_id` map is
27103
- * complete, and a duplicate refused, before the first write or registration, so a `#<node_id>`
27102
+ * Steps 2-4 of §5.1 on `branch` (a SourceBagNode or a new SourceBag value). The `nodeId` map is
27103
+ * complete, and a duplicate refused, before the first write or registration, so a `#<nodeId>`
27104
27104
  * of the branch translates; then the installation (`dataSetter`s and defaults), then one
27105
27105
  * NodeBinding per node and the registrations, providers included. On an error the NodeBindings
27106
27106
  * opened here are closed and the map entries they brought are removed; the Data is not rolled
@@ -27113,10 +27113,10 @@ var BindingRuntime = class {
27113
27113
  const known = new Set(nodes.filter((node) => this.bindingFor(node)));
27114
27114
  const entering = /* @__PURE__ */ new Map();
27115
27115
  for (const node of nodes) {
27116
- const nodeId = node.getAttr("node_id");
27116
+ const nodeId = node.getAttr("nodeId");
27117
27117
  if (nodeId == null) continue;
27118
27118
  if (entering.has(nodeId) || this.nodeIds.has(nodeId) && this.nodeIds.get(nodeId) !== node) {
27119
- throw new Error(`Duplicate node_id '${nodeId}'`);
27119
+ throw new Error(`Duplicate nodeId '${nodeId}'`);
27120
27120
  }
27121
27121
  entering.set(nodeId, node);
27122
27122
  }
@@ -27128,7 +27128,7 @@ var BindingRuntime = class {
27128
27128
  } catch (error) {
27129
27129
  const errors = [error];
27130
27130
  for (const node of nodes.filter((node2) => !known.has(node2)).reverse()) {
27131
- const nodeId = node.getAttr("node_id");
27131
+ const nodeId = node.getAttr("nodeId");
27132
27132
  if (entering.get(nodeId) === node && this.nodeIds.get(nodeId) === node) this.nodeIds.delete(nodeId);
27133
27133
  const binding = this.bindingFor(node);
27134
27134
  if (!binding) continue;
@@ -27177,16 +27177,16 @@ var BindingRuntime = class {
27177
27177
  }
27178
27178
  /**
27179
27179
  * An attribute change: the NodeBinding of the node is required first (GC-210 §090), then the inline
27180
- * declarations of the changed attributes are released (S09), then the `node_id` map, then the
27180
+ * declarations of the changed attributes are released (S09), then the `nodeId` map, then the
27181
27181
  * rebinding of the node, or of its branch for a context attribute.
27182
27182
  */
27183
27183
  #attributesChanged(node, diff) {
27184
27184
  const binding = this.#installedBinding(node);
27185
27185
  this.inlineCompiler.release(node, Object.keys(diff));
27186
- if (Object.hasOwn(diff, "node_id")) {
27187
- const { old: previous, new: current } = diff.node_id;
27186
+ if (Object.hasOwn(diff, "nodeId")) {
27187
+ const { old: previous, new: current } = diff.nodeId;
27188
27188
  if (current != null && this.nodeIds.has(current) && this.nodeIds.get(current) !== node) {
27189
- throw new Error(`Duplicate node_id '${current}'`);
27189
+ throw new Error(`Duplicate nodeId '${current}'`);
27190
27190
  }
27191
27191
  if (this.nodeIds.get(previous) === node) this.nodeIds.delete(previous);
27192
27192
  if (current != null) this.nodeIds.set(current, node);
@@ -28728,7 +28728,7 @@ var SubscriptionsHandler = class extends Handler {
28728
28728
  const forward = topic.parent || topic.iframe !== void 0 ? this.#frames.prepare(topic, payload) : null;
28729
28729
  if (Object.hasOwn(topic, "nodeId")) {
28730
28730
  const node = this.gramlot.src.binding.nodeIds.get(topic.nodeId);
28731
- if (!node) throw new Error(`node_id not found: ${topic.nodeId}`);
28731
+ if (!node) throw new Error(`nodeId not found: ${topic.nodeId}`);
28732
28732
  return this.publishNode(node, topic.topic, payload);
28733
28733
  }
28734
28734
  this.#deliver(topic.topic, payload);
@@ -28739,7 +28739,7 @@ var SubscriptionsHandler = class extends Handler {
28739
28739
  node = sourceTarget(node);
28740
28740
  const binding = this.gramlot.src.binding.bindingFor(node);
28741
28741
  if (!binding || binding.closed) throw new Error("Topic target is not an active Source node of this page");
28742
- let id = node.getAttr("node_id");
28742
+ let id = node.getAttr("nodeId");
28743
28743
  if (id == null) {
28744
28744
  if (!this.#nodeIds.has(node)) this.#nodeIds.set(node, `gramlot-self-${++this.#sequence}`);
28745
28745
  id = this.#nodeIds.get(node);
@@ -29597,7 +29597,7 @@ function mountIndexPage(renderer, root, onSelection = () => {
29597
29597
  const source = node(pane);
29598
29598
  const savedWidth = preferences[widthProperty];
29599
29599
  if (typeof savedWidth === "number" && Number.isFinite(savedWidth) && savedWidth > 0) set(pane, { width: `${savedWidth}px` });
29600
- const handle2 = gramlot.subscribe(`${source.getAttr("node_id")}_closable_change`, ({ open }) => {
29600
+ const handle2 = gramlot.subscribe(`${source.getAttr("nodeId")}_closable_change`, ({ open }) => {
29601
29601
  if (source.getAttr("hidden") === true || source.getAttr("drawer") === false) return;
29602
29602
  state.setItem(property, open);
29603
29603
  set(pane, { drawer: open ? true : "close" });
@@ -29608,7 +29608,7 @@ function mountIndexPage(renderer, root, onSelection = () => {
29608
29608
  releases.push(() => gramlot.unsubscribe(handle2));
29609
29609
  }
29610
29610
  const border = shell.querySelector("[data-index-regions]");
29611
- const handle = gramlot.subscribe(`${node(border).getAttr("node_id")}_splitter_resize`, ({ region, size }) => {
29611
+ const handle = gramlot.subscribe(`${node(border).getAttr("nodeId")}_splitter_resize`, ({ region, size }) => {
29612
29612
  set(region === "left" ? sidebar : codeSidebar, { width: size });
29613
29613
  state.setItem(region === "left" ? "preferredSidebarWidth" : "preferredCodeWidth", Number.parseFloat(size));
29614
29614
  savePreferences();