@optique/core 1.0.0-dev.1659 → 1.0.0-dev.1661

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.
@@ -137,7 +137,11 @@ function containsAnnotationView(value, seen = /* @__PURE__ */ new WeakSet()) {
137
137
  if (Array.isArray(source)) return source.some((item) => containsAnnotationView(item, seen));
138
138
  const proto = Object.getPrototypeOf(source);
139
139
  if (proto !== Object.prototype && proto !== null) return false;
140
- return Reflect.ownKeys(source).some((key) => containsAnnotationView(source[key], seen));
140
+ const descriptors = Object.getOwnPropertyDescriptors(source);
141
+ return Reflect.ownKeys(descriptors).some((key) => {
142
+ const descriptor = descriptors[key];
143
+ return descriptor != null && "value" in descriptor ? containsAnnotationView(descriptor.value, seen) : false;
144
+ });
141
145
  }
142
146
  function unwrapNestedAnnotationViews(value, seen = /* @__PURE__ */ new WeakMap()) {
143
147
  if (value == null || typeof value !== "object") return value;
@@ -222,17 +226,18 @@ function getAnnotatedFieldState(parentState, field, parser) {
222
226
  }
223
227
  const annotationViewTargets = /* @__PURE__ */ new WeakMap();
224
228
  function withAnnotationView(state, annotations) {
225
- const view = new Proxy(state, {
226
- get(target, key) {
229
+ const target = unwrapAnnotationView(state);
230
+ const view = new Proxy(target, {
231
+ get(target$1, key) {
227
232
  if (key === require_annotations.annotationKey) return annotations;
228
- const value = Reflect.get(target, key, target);
229
- return typeof value === "function" ? value.bind(target) : value;
233
+ const value = Reflect.get(target$1, key, target$1);
234
+ return typeof value === "function" ? value.bind(target$1) : value;
230
235
  },
231
- has(target, key) {
232
- return key === require_annotations.annotationKey || Reflect.has(target, key);
236
+ has(target$1, key) {
237
+ return key === require_annotations.annotationKey || Reflect.has(target$1, key);
233
238
  }
234
239
  });
235
- annotationViewTargets.set(view, state);
240
+ annotationViewTargets.set(view, target);
236
241
  return view;
237
242
  }
238
243
  function getParseChildState(parentState, childState, parser) {
@@ -249,7 +254,7 @@ function getParseChildState(parentState, childState, parser) {
249
254
  function getObjectParseChildState(parentState, childState, _parser) {
250
255
  const annotations = require_annotations.getAnnotations(parentState);
251
256
  if (annotations === void 0 || childState == null || typeof childState !== "object" || require_annotations.getAnnotations(childState) === annotations) return childState;
252
- return require_annotations.injectAnnotations(childState, annotations);
257
+ return require_annotations.inheritAnnotations(parentState, childState);
253
258
  }
254
259
  function getAnnotatedChildState(parentState, childState, parser) {
255
260
  const annotations = require_annotations.getAnnotations(parentState);
@@ -137,7 +137,11 @@ function containsAnnotationView(value, seen = /* @__PURE__ */ new WeakSet()) {
137
137
  if (Array.isArray(source)) return source.some((item) => containsAnnotationView(item, seen));
138
138
  const proto = Object.getPrototypeOf(source);
139
139
  if (proto !== Object.prototype && proto !== null) return false;
140
- return Reflect.ownKeys(source).some((key) => containsAnnotationView(source[key], seen));
140
+ const descriptors = Object.getOwnPropertyDescriptors(source);
141
+ return Reflect.ownKeys(descriptors).some((key) => {
142
+ const descriptor = descriptors[key];
143
+ return descriptor != null && "value" in descriptor ? containsAnnotationView(descriptor.value, seen) : false;
144
+ });
141
145
  }
142
146
  function unwrapNestedAnnotationViews(value, seen = /* @__PURE__ */ new WeakMap()) {
143
147
  if (value == null || typeof value !== "object") return value;
@@ -222,17 +226,18 @@ function getAnnotatedFieldState(parentState, field, parser) {
222
226
  }
223
227
  const annotationViewTargets = /* @__PURE__ */ new WeakMap();
224
228
  function withAnnotationView(state, annotations) {
225
- const view = new Proxy(state, {
226
- get(target, key) {
229
+ const target = unwrapAnnotationView(state);
230
+ const view = new Proxy(target, {
231
+ get(target$1, key) {
227
232
  if (key === annotationKey) return annotations;
228
- const value = Reflect.get(target, key, target);
229
- return typeof value === "function" ? value.bind(target) : value;
233
+ const value = Reflect.get(target$1, key, target$1);
234
+ return typeof value === "function" ? value.bind(target$1) : value;
230
235
  },
231
- has(target, key) {
232
- return key === annotationKey || Reflect.has(target, key);
236
+ has(target$1, key) {
237
+ return key === annotationKey || Reflect.has(target$1, key);
233
238
  }
234
239
  });
235
- annotationViewTargets.set(view, state);
240
+ annotationViewTargets.set(view, target);
236
241
  return view;
237
242
  }
238
243
  function getParseChildState(parentState, childState, parser) {
@@ -249,7 +254,7 @@ function getParseChildState(parentState, childState, parser) {
249
254
  function getObjectParseChildState(parentState, childState, _parser) {
250
255
  const annotations = getAnnotations(parentState);
251
256
  if (annotations === void 0 || childState == null || typeof childState !== "object" || getAnnotations(childState) === annotations) return childState;
252
- return injectAnnotations(childState, annotations);
257
+ return inheritAnnotations(parentState, childState);
253
258
  }
254
259
  function getAnnotatedChildState(parentState, childState, parser) {
255
260
  const annotations = getAnnotations(parentState);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/core",
3
- "version": "1.0.0-dev.1659+94dcbc28",
3
+ "version": "1.0.0-dev.1661+6fc17d4f",
4
4
  "description": "Type-safe combinatorial command-line interface parser",
5
5
  "keywords": [
6
6
  "CLI",