@optique/core 1.0.0-dev.1858 → 1.0.0-dev.1860

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.
@@ -104,6 +104,9 @@ function copyOwnProperties(source, target, transformValue, excludedKeys) {
104
104
  Object.defineProperty(target, key, descriptor);
105
105
  }
106
106
  }
107
+ function normalizeProtectedCollectionItem(value, context) {
108
+ return context.rewrapProtectedViews && isProtectedAnnotationView(value) ? unwrapProtectedAnnotationTarget(value) : value;
109
+ }
107
110
  const regExpExcludedKeys = new Set(["lastIndex"]);
108
111
  function copyRegExpMetadata(source, target, transformValue) {
109
112
  copyOwnProperties(source, target, transformValue, regExpExcludedKeys);
@@ -156,7 +159,8 @@ function createProtectedObjectView(target, context) {
156
159
  }
157
160
  function createProtectedMapView(target, context) {
158
161
  const methodCache = /* @__PURE__ */ new Map();
159
- const cloned = new Map(target);
162
+ const cloned = /* @__PURE__ */ new Map();
163
+ for (const [entryKey, entryValue] of target.entries()) cloned.set(normalizeProtectedCollectionItem(entryKey, context), normalizeProtectedCollectionItem(entryValue, context));
160
164
  const view = new Proxy(cloned, {
161
165
  get(clonedTarget, key) {
162
166
  if (key === "size") return clonedTarget.size;
@@ -201,7 +205,8 @@ function createProtectedMapView(target, context) {
201
205
  }
202
206
  function createProtectedSetView(target, context) {
203
207
  const methodCache = /* @__PURE__ */ new Map();
204
- const cloned = new Set(target);
208
+ const cloned = /* @__PURE__ */ new Set();
209
+ for (const value of target.values()) cloned.add(normalizeProtectedCollectionItem(value, context));
205
210
  const view = new Proxy(cloned, {
206
211
  get(clonedTarget, key) {
207
212
  if (key === "size") return clonedTarget.size;
@@ -88,7 +88,7 @@ interface ParseOptions {
88
88
  * Optique treats these values as immutable input and exposes them back to
89
89
  * parsers only through protected read-only views.
90
90
  */
91
- annotations?: Annotations | ReadonlyAnnotations;
91
+ readonly annotations?: Annotations | ReadonlyAnnotations;
92
92
  }
93
93
  /**
94
94
  * Extracts annotations from parser state.
@@ -88,7 +88,7 @@ interface ParseOptions {
88
88
  * Optique treats these values as immutable input and exposes them back to
89
89
  * parsers only through protected read-only views.
90
90
  */
91
- annotations?: Annotations | ReadonlyAnnotations;
91
+ readonly annotations?: Annotations | ReadonlyAnnotations;
92
92
  }
93
93
  /**
94
94
  * Extracts annotations from parser state.
@@ -103,6 +103,9 @@ function copyOwnProperties(source, target, transformValue, excludedKeys) {
103
103
  Object.defineProperty(target, key, descriptor);
104
104
  }
105
105
  }
106
+ function normalizeProtectedCollectionItem(value, context) {
107
+ return context.rewrapProtectedViews && isProtectedAnnotationView(value) ? unwrapProtectedAnnotationTarget(value) : value;
108
+ }
106
109
  const regExpExcludedKeys = new Set(["lastIndex"]);
107
110
  function copyRegExpMetadata(source, target, transformValue) {
108
111
  copyOwnProperties(source, target, transformValue, regExpExcludedKeys);
@@ -155,7 +158,8 @@ function createProtectedObjectView(target, context) {
155
158
  }
156
159
  function createProtectedMapView(target, context) {
157
160
  const methodCache = /* @__PURE__ */ new Map();
158
- const cloned = new Map(target);
161
+ const cloned = /* @__PURE__ */ new Map();
162
+ for (const [entryKey, entryValue] of target.entries()) cloned.set(normalizeProtectedCollectionItem(entryKey, context), normalizeProtectedCollectionItem(entryValue, context));
159
163
  const view = new Proxy(cloned, {
160
164
  get(clonedTarget, key) {
161
165
  if (key === "size") return clonedTarget.size;
@@ -200,7 +204,8 @@ function createProtectedMapView(target, context) {
200
204
  }
201
205
  function createProtectedSetView(target, context) {
202
206
  const methodCache = /* @__PURE__ */ new Map();
203
- const cloned = new Set(target);
207
+ const cloned = /* @__PURE__ */ new Set();
208
+ for (const value of target.values()) cloned.add(normalizeProtectedCollectionItem(value, context));
204
209
  const view = new Proxy(cloned, {
205
210
  get(clonedTarget, key) {
206
211
  if (key === "size") return clonedTarget.size;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/core",
3
- "version": "1.0.0-dev.1858+fbabb36b",
3
+ "version": "1.0.0-dev.1860+656f0c47",
4
4
  "description": "Type-safe combinatorial command-line interface parser",
5
5
  "keywords": [
6
6
  "CLI",