@optique/core 1.0.0-dev.1787 → 1.0.0-dev.1791

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.
@@ -63,7 +63,7 @@ function getWrappedChildParseState(parentState, childState, parser) {
63
63
  const annotations = require_annotations.getAnnotations(parentState);
64
64
  const shouldInheritAnnotations = Reflect.get(parser, require_parser.inheritParentAnnotationsKey) === true;
65
65
  if (childState == null) {
66
- if (annotations !== void 0 && shouldInheritAnnotations) return require_annotations.injectAnnotations({}, annotations);
66
+ if (annotations !== void 0 && shouldInheritAnnotations) return require_annotations.injectAnnotations(childState, annotations);
67
67
  return childState;
68
68
  }
69
69
  if (annotations === void 0 || typeof childState !== "object" || require_annotations.getAnnotations(childState) === annotations || !shouldInheritAnnotations) return childState;
@@ -80,7 +80,7 @@ function getWrappedChildState(parentState, childState, parser) {
80
80
  const annotations = require_annotations.getAnnotations(parentState);
81
81
  const shouldInheritAnnotations = Reflect.get(parser, require_parser.inheritParentAnnotationsKey) === true;
82
82
  if (childState == null) {
83
- if (annotations !== void 0 && shouldInheritAnnotations) return require_annotations.injectAnnotations({}, annotations);
83
+ if (annotations !== void 0 && shouldInheritAnnotations) return require_annotations.injectAnnotations(childState, annotations);
84
84
  return childState;
85
85
  }
86
86
  if (annotations === void 0 || typeof childState !== "object" || require_annotations.getAnnotations(childState) === annotations) return childState;
@@ -90,6 +90,17 @@ function getWrappedChildState(parentState, childState, parser) {
90
90
  }
91
91
  return withAnnotationView(childState, annotations);
92
92
  }
93
+ /**
94
+ * Reconciles object-owned child state with parent annotations using the same
95
+ * shared object-state inheritance rule across parser families.
96
+ *
97
+ * @internal
98
+ */
99
+ function reconcileObjectChildState(parentState, childState) {
100
+ const annotations = require_annotations.getAnnotations(parentState);
101
+ if (annotations === void 0 || childState == null || typeof childState !== "object" || require_annotations.getAnnotations(childState) === annotations) return childState;
102
+ return require_annotations.inheritAnnotations(parentState, childState);
103
+ }
93
104
 
94
105
  //#endregion
95
106
  exports.annotationViewTargets = annotationViewTargets;
@@ -97,4 +108,5 @@ exports.getWrappedChildParseState = getWrappedChildParseState;
97
108
  exports.getWrappedChildState = getWrappedChildState;
98
109
  exports.isAnnotationWrappedInitialState = isAnnotationWrappedInitialState;
99
110
  exports.normalizeInjectedAnnotationState = normalizeInjectedAnnotationState;
111
+ exports.reconcileObjectChildState = reconcileObjectChildState;
100
112
  exports.unwrapAnnotationView = unwrapAnnotationView;
@@ -1,4 +1,4 @@
1
- import { annotationKey, getAnnotations, injectAnnotations, unwrapInjectedAnnotationWrapper } from "./annotations.js";
1
+ import { annotationKey, getAnnotations, inheritAnnotations, injectAnnotations, unwrapInjectedAnnotationWrapper } from "./annotations.js";
2
2
  import { inheritParentAnnotationsKey } from "./parser.js";
3
3
 
4
4
  //#region src/annotation-state.ts
@@ -63,7 +63,7 @@ function getWrappedChildParseState(parentState, childState, parser) {
63
63
  const annotations = getAnnotations(parentState);
64
64
  const shouldInheritAnnotations = Reflect.get(parser, inheritParentAnnotationsKey) === true;
65
65
  if (childState == null) {
66
- if (annotations !== void 0 && shouldInheritAnnotations) return injectAnnotations({}, annotations);
66
+ if (annotations !== void 0 && shouldInheritAnnotations) return injectAnnotations(childState, annotations);
67
67
  return childState;
68
68
  }
69
69
  if (annotations === void 0 || typeof childState !== "object" || getAnnotations(childState) === annotations || !shouldInheritAnnotations) return childState;
@@ -80,7 +80,7 @@ function getWrappedChildState(parentState, childState, parser) {
80
80
  const annotations = getAnnotations(parentState);
81
81
  const shouldInheritAnnotations = Reflect.get(parser, inheritParentAnnotationsKey) === true;
82
82
  if (childState == null) {
83
- if (annotations !== void 0 && shouldInheritAnnotations) return injectAnnotations({}, annotations);
83
+ if (annotations !== void 0 && shouldInheritAnnotations) return injectAnnotations(childState, annotations);
84
84
  return childState;
85
85
  }
86
86
  if (annotations === void 0 || typeof childState !== "object" || getAnnotations(childState) === annotations) return childState;
@@ -90,6 +90,17 @@ function getWrappedChildState(parentState, childState, parser) {
90
90
  }
91
91
  return withAnnotationView(childState, annotations);
92
92
  }
93
+ /**
94
+ * Reconciles object-owned child state with parent annotations using the same
95
+ * shared object-state inheritance rule across parser families.
96
+ *
97
+ * @internal
98
+ */
99
+ function reconcileObjectChildState(parentState, childState) {
100
+ const annotations = getAnnotations(parentState);
101
+ if (annotations === void 0 || childState == null || typeof childState !== "object" || getAnnotations(childState) === annotations) return childState;
102
+ return inheritAnnotations(parentState, childState);
103
+ }
93
104
 
94
105
  //#endregion
95
- export { annotationViewTargets, getWrappedChildParseState, getWrappedChildState, isAnnotationWrappedInitialState, normalizeInjectedAnnotationState, unwrapAnnotationView };
106
+ export { annotationViewTargets, getWrappedChildParseState, getWrappedChildState, isAnnotationWrappedInitialState, normalizeInjectedAnnotationState, reconcileObjectChildState, unwrapAnnotationView };
@@ -305,9 +305,7 @@ function getAnnotatedFieldState(parentState, field, parser) {
305
305
  return require_annotation_state.getWrappedChildState(parentState, sourceState, parser);
306
306
  }
307
307
  function getObjectParseChildState(parentState, childState, _parser) {
308
- const annotations = require_annotations.getAnnotations(parentState);
309
- if (annotations === void 0 || childState == null || typeof childState !== "object" || require_annotations.getAnnotations(childState) === annotations) return childState;
310
- return require_annotations.inheritAnnotations(parentState, childState);
308
+ return require_annotation_state.reconcileObjectChildState(parentState, childState);
311
309
  }
312
310
  function buildSuggestRuntimeNodesFromPairs(pairs, state, parentPath) {
313
311
  const prefix = parentPath ?? [];
@@ -10,7 +10,7 @@ import { completeOrExtractPhase2Seed, extractPhase2Seed, extractPhase2SeedKey, p
10
10
  import { DEFAULT_FIND_SIMILAR_OPTIONS, createErrorWithSuggestions, createSuggestionMessage, deduplicateSuggestions, findSimilar } from "./suggestion.js";
11
11
  import { collectLeadingCandidates } from "./usage-internals.js";
12
12
  import { defineInheritedAnnotationParser, getParserSuggestRuntimeNodes, unmatchedNonCliDependencySourceStateMarker } from "./parser.js";
13
- import { annotationViewTargets, getWrappedChildParseState, getWrappedChildState, unwrapAnnotationView } from "./annotation-state.js";
13
+ import { annotationViewTargets, getWrappedChildParseState, getWrappedChildState, reconcileObjectChildState, unwrapAnnotationView } from "./annotation-state.js";
14
14
 
15
15
  //#region src/constructs.ts
16
16
  /**
@@ -305,9 +305,7 @@ function getAnnotatedFieldState(parentState, field, parser) {
305
305
  return getWrappedChildState(parentState, sourceState, parser);
306
306
  }
307
307
  function getObjectParseChildState(parentState, childState, _parser) {
308
- const annotations = getAnnotations(parentState);
309
- if (annotations === void 0 || childState == null || typeof childState !== "object" || getAnnotations(childState) === annotations) return childState;
310
- return inheritAnnotations(parentState, childState);
308
+ return reconcileObjectChildState(parentState, childState);
311
309
  }
312
310
  function buildSuggestRuntimeNodesFromPairs(pairs, state, parentPath) {
313
311
  const prefix = parentPath ?? [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/core",
3
- "version": "1.0.0-dev.1787+4a55dc3b",
3
+ "version": "1.0.0-dev.1791+dde5b366",
4
4
  "description": "Type-safe combinatorial command-line interface parser",
5
5
  "keywords": [
6
6
  "CLI",