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