@optique/core 1.0.0-dev.1870 → 1.0.0-dev.1874

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.
@@ -157,6 +157,16 @@ function tryCloneRegExpSubclass(source) {
157
157
  return void 0;
158
158
  }
159
159
  }
160
+ function tryCloneArraySubclass(source) {
161
+ const cloneConstructor = resolveCloneConstructor(source);
162
+ if (cloneConstructor == null) return void 0;
163
+ try {
164
+ const cloned = Reflect.apply(Array.from, cloneConstructor, [source]);
165
+ return Array.isArray(cloned) ? cloned : void 0;
166
+ } catch {
167
+ return void 0;
168
+ }
169
+ }
160
170
  function tryCloneURLSearchParamsSubclass(source) {
161
171
  const cloneConstructor = resolveCloneConstructor(source);
162
172
  if (cloneConstructor == null) return void 0;
@@ -251,7 +261,8 @@ function cloneRegExpShape(source) {
251
261
  }
252
262
  function createProtectedObjectView(target, context) {
253
263
  if (Array.isArray(target)) {
254
- const view$1 = Object.setPrototypeOf([], Object.getPrototypeOf(target));
264
+ const targetPrototype = Object.getPrototypeOf(target);
265
+ const view$1 = targetPrototype === Array.prototype || targetPrototype === null ? Object.setPrototypeOf([], targetPrototype) : tryCloneArraySubclass(target) ?? [];
255
266
  view$1.length = target.length;
256
267
  registerProtectedAnnotationView(context, target, view$1);
257
268
  for (const key of Reflect.ownKeys(target)) {
@@ -156,6 +156,16 @@ function tryCloneRegExpSubclass(source) {
156
156
  return void 0;
157
157
  }
158
158
  }
159
+ function tryCloneArraySubclass(source) {
160
+ const cloneConstructor = resolveCloneConstructor(source);
161
+ if (cloneConstructor == null) return void 0;
162
+ try {
163
+ const cloned = Reflect.apply(Array.from, cloneConstructor, [source]);
164
+ return Array.isArray(cloned) ? cloned : void 0;
165
+ } catch {
166
+ return void 0;
167
+ }
168
+ }
159
169
  function tryCloneURLSearchParamsSubclass(source) {
160
170
  const cloneConstructor = resolveCloneConstructor(source);
161
171
  if (cloneConstructor == null) return void 0;
@@ -250,7 +260,8 @@ function cloneRegExpShape(source) {
250
260
  }
251
261
  function createProtectedObjectView(target, context) {
252
262
  if (Array.isArray(target)) {
253
- const view$1 = Object.setPrototypeOf([], Object.getPrototypeOf(target));
263
+ const targetPrototype = Object.getPrototypeOf(target);
264
+ const view$1 = targetPrototype === Array.prototype || targetPrototype === null ? Object.setPrototypeOf([], targetPrototype) : tryCloneArraySubclass(target) ?? [];
254
265
  view$1.length = target.length;
255
266
  registerProtectedAnnotationView(context, target, view$1);
256
267
  for (const key of Reflect.ownKeys(target)) {
@@ -197,7 +197,7 @@ interface SourceContext<TRequiredOptions = void> {
197
197
  * during phase 1. Can be a Promise for async operations (e.g.,
198
198
  * loading config files).
199
199
  */
200
- getAnnotations(request?: SourceContextRequest, options?: unknown): Promise<Annotations> | Annotations;
200
+ getAnnotations(request?: SourceContextRequest, options?: unknown): Promise<Annotations | ReadonlyAnnotations> | Annotations | ReadonlyAnnotations;
201
201
  /**
202
202
  * Optional hook to provide additional internal annotations during
203
203
  * annotation collection. Called after {@link getAnnotations} with the
@@ -212,7 +212,7 @@ interface SourceContext<TRequiredOptions = void> {
212
212
  * @returns Additional annotations to merge, or `undefined`.
213
213
  * @since 1.0.0
214
214
  */
215
- getInternalAnnotations?(request: SourceContextRequest, annotations: Annotations): Annotations | undefined;
215
+ getInternalAnnotations?(request: SourceContextRequest, annotations: Annotations | ReadonlyAnnotations): Annotations | ReadonlyAnnotations | undefined;
216
216
  /**
217
217
  * Optional synchronous cleanup method. Called by `runWith()` and
218
218
  * `runWithSync()` after parsing completes. In `runWith()`, this happens
package/dist/context.d.ts CHANGED
@@ -197,7 +197,7 @@ interface SourceContext<TRequiredOptions = void> {
197
197
  * during phase 1. Can be a Promise for async operations (e.g.,
198
198
  * loading config files).
199
199
  */
200
- getAnnotations(request?: SourceContextRequest, options?: unknown): Promise<Annotations> | Annotations;
200
+ getAnnotations(request?: SourceContextRequest, options?: unknown): Promise<Annotations | ReadonlyAnnotations> | Annotations | ReadonlyAnnotations;
201
201
  /**
202
202
  * Optional hook to provide additional internal annotations during
203
203
  * annotation collection. Called after {@link getAnnotations} with the
@@ -212,7 +212,7 @@ interface SourceContext<TRequiredOptions = void> {
212
212
  * @returns Additional annotations to merge, or `undefined`.
213
213
  * @since 1.0.0
214
214
  */
215
- getInternalAnnotations?(request: SourceContextRequest, annotations: Annotations): Annotations | undefined;
215
+ getInternalAnnotations?(request: SourceContextRequest, annotations: Annotations | ReadonlyAnnotations): Annotations | ReadonlyAnnotations | undefined;
216
216
  /**
217
217
  * Optional synchronous cleanup method. Called by `runWith()` and
218
218
  * `runWithSync()` after parsing completes. In `runWith()`, this happens
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/core",
3
- "version": "1.0.0-dev.1870+f804a6a6",
3
+ "version": "1.0.0-dev.1874+39daa8c1",
4
4
  "description": "Type-safe combinatorial command-line interface parser",
5
5
  "keywords": [
6
6
  "CLI",