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

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)) {
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.1872+bf32b1c5",
4
4
  "description": "Type-safe combinatorial command-line interface parser",
5
5
  "keywords": [
6
6
  "CLI",