@nice-code/commander 0.103.0 → 0.104.0

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/build/cli.mjs CHANGED
@@ -22167,6 +22167,20 @@ var RealmRuleTrie = class {
22167
22167
  params
22168
22168
  };
22169
22169
  }
22170
+ /**
22171
+ * Whether some rule's pattern can match a path strictly BENEATH `path` (a `**` at or above it
22172
+ * counts). Ignores `view` conditions — the answer is about schema reachability, not access.
22173
+ */
22174
+ reachesBeneath(path) {
22175
+ return this._reachesBeneath(this._root, path, 0);
22176
+ }
22177
+ _reachesBeneath(node, path, depth) {
22178
+ if (node.deep != null) return true;
22179
+ if (depth === path.length) return (node.lit?.size ?? 0) > 0 || node.var != null || node.star != null;
22180
+ const litChild = node.lit?.get(path[depth]);
22181
+ if (litChild != null && this._reachesBeneath(litChild, path, depth + 1)) return true;
22182
+ return node.var != null && this._reachesBeneath(node.var.node, path, depth + 1);
22183
+ }
22170
22184
  _match(node, path, depth) {
22171
22185
  if (depth === path.length) return node.exact;
22172
22186
  const seg = path[depth];
@@ -22726,14 +22740,22 @@ const OMIT = {
22726
22740
  value: void 0,
22727
22741
  anyVisible: false
22728
22742
  };
22729
- function pruneNode(ctx, node, value, path) {
22743
+ /** Does `path` pass through a record entry? Its containers are then data, not structure. */
22744
+ function underRecordEntry(schemaRoot, path) {
22745
+ for (let depth = 1; depth < path.length; depth++) {
22746
+ const parent = schemaNodeAtPath(schemaRoot, path.slice(0, depth));
22747
+ if (parent != null && unwrapOptional(parent).kind === "record") return true;
22748
+ }
22749
+ return false;
22750
+ }
22751
+ function pruneNode(ctx, node, value, path, inEntry = underRecordEntry(ctx.schemaRoot, path)) {
22730
22752
  if (value === void 0) return OMIT;
22731
22753
  const inner = unwrapOptional(node);
22732
22754
  if (inner.kind === "object") {
22733
22755
  const out = {};
22734
22756
  let anyVisible = false;
22735
22757
  for (const [key, child] of Object.entries(inner.entries)) {
22736
- const pruned = pruneNode(ctx, child, value[key], [...path, key]);
22758
+ const pruned = pruneNode(ctx, child, value[key], [...path, key], inEntry);
22737
22759
  if (pruned.anyVisible) {
22738
22760
  out[key] = pruned.value;
22739
22761
  anyVisible = true;
@@ -22748,15 +22770,16 @@ function pruneNode(ctx, node, value, path) {
22748
22770
  const out = {};
22749
22771
  let anyVisible = false;
22750
22772
  if (value != null && typeof value === "object") for (const [key, entry] of Object.entries(value)) {
22751
- const pruned = pruneNode(ctx, inner.value, entry, [...path, key]);
22773
+ const pruned = pruneNode(ctx, inner.value, entry, [...path, key], true);
22752
22774
  if (pruned.anyVisible) {
22753
22775
  out[key] = pruned.value;
22754
22776
  anyVisible = true;
22755
22777
  }
22756
22778
  }
22779
+ const structural = !inEntry && ctx.trie.reachesBeneath(path);
22757
22780
  return {
22758
22781
  value: out,
22759
- anyVisible: anyVisible || leafVisible(ctx, path)
22782
+ anyVisible: anyVisible || structural || leafVisible(ctx, path)
22760
22783
  };
22761
22784
  }
22762
22785
  return leafVisible(ctx, path) ? {