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

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.
@@ -596,21 +596,23 @@ function injectAnnotationsWithContext(state, annotations, context) {
596
596
  return cloned$1;
597
597
  }
598
598
  if (isInjectedAnnotationWrapper(state)) {
599
- state[annotationKey] = protectedAnnotations;
600
- return state;
599
+ const cloned$1 = Object.create(Object.getPrototypeOf(state), Object.getOwnPropertyDescriptors(state));
600
+ cloned$1[annotationKey] = protectedAnnotations;
601
+ injectedAnnotationWrappers.add(cloned$1);
602
+ return cloned$1;
601
603
  }
602
604
  if (state instanceof Date) {
603
- const cloned$1 = new Date(state.getTime());
605
+ const cloned$1 = tryCloneDateSubclass(state) ?? new Date(state.getTime());
604
606
  cloned$1[annotationKey] = protectedAnnotations;
605
607
  return cloned$1;
606
608
  }
607
609
  if (state instanceof Map) {
608
- const cloned$1 = new Map(state);
610
+ const cloned$1 = tryCloneMapSubclass(state, state) ?? new Map(state);
609
611
  cloned$1[annotationKey] = protectedAnnotations;
610
612
  return cloned$1;
611
613
  }
612
614
  if (state instanceof Set) {
613
- const cloned$1 = new Set(state);
615
+ const cloned$1 = tryCloneSetSubclass(state, state) ?? new Set(state);
614
616
  cloned$1[annotationKey] = protectedAnnotations;
615
617
  return cloned$1;
616
618
  }
@@ -702,17 +704,17 @@ function inheritAnnotations(source, target) {
702
704
  return cloned$1;
703
705
  }
704
706
  if (target instanceof Date) {
705
- const cloned$1 = new Date(target.getTime());
707
+ const cloned$1 = tryCloneDateSubclass(target) ?? new Date(target.getTime());
706
708
  cloned$1[annotationKey] = annotations;
707
709
  return cloned$1;
708
710
  }
709
711
  if (target instanceof Map) {
710
- const cloned$1 = new Map(target);
712
+ const cloned$1 = tryCloneMapSubclass(target, target) ?? new Map(target);
711
713
  cloned$1[annotationKey] = annotations;
712
714
  return cloned$1;
713
715
  }
714
716
  if (target instanceof Set) {
715
- const cloned$1 = new Set(target);
717
+ const cloned$1 = tryCloneSetSubclass(target, target) ?? new Set(target);
716
718
  cloned$1[annotationKey] = annotations;
717
719
  return cloned$1;
718
720
  }
@@ -595,21 +595,23 @@ function injectAnnotationsWithContext(state, annotations, context) {
595
595
  return cloned$1;
596
596
  }
597
597
  if (isInjectedAnnotationWrapper(state)) {
598
- state[annotationKey] = protectedAnnotations;
599
- return state;
598
+ const cloned$1 = Object.create(Object.getPrototypeOf(state), Object.getOwnPropertyDescriptors(state));
599
+ cloned$1[annotationKey] = protectedAnnotations;
600
+ injectedAnnotationWrappers.add(cloned$1);
601
+ return cloned$1;
600
602
  }
601
603
  if (state instanceof Date) {
602
- const cloned$1 = new Date(state.getTime());
604
+ const cloned$1 = tryCloneDateSubclass(state) ?? new Date(state.getTime());
603
605
  cloned$1[annotationKey] = protectedAnnotations;
604
606
  return cloned$1;
605
607
  }
606
608
  if (state instanceof Map) {
607
- const cloned$1 = new Map(state);
609
+ const cloned$1 = tryCloneMapSubclass(state, state) ?? new Map(state);
608
610
  cloned$1[annotationKey] = protectedAnnotations;
609
611
  return cloned$1;
610
612
  }
611
613
  if (state instanceof Set) {
612
- const cloned$1 = new Set(state);
614
+ const cloned$1 = tryCloneSetSubclass(state, state) ?? new Set(state);
613
615
  cloned$1[annotationKey] = protectedAnnotations;
614
616
  return cloned$1;
615
617
  }
@@ -701,17 +703,17 @@ function inheritAnnotations(source, target) {
701
703
  return cloned$1;
702
704
  }
703
705
  if (target instanceof Date) {
704
- const cloned$1 = new Date(target.getTime());
706
+ const cloned$1 = tryCloneDateSubclass(target) ?? new Date(target.getTime());
705
707
  cloned$1[annotationKey] = annotations;
706
708
  return cloned$1;
707
709
  }
708
710
  if (target instanceof Map) {
709
- const cloned$1 = new Map(target);
711
+ const cloned$1 = tryCloneMapSubclass(target, target) ?? new Map(target);
710
712
  cloned$1[annotationKey] = annotations;
711
713
  return cloned$1;
712
714
  }
713
715
  if (target instanceof Set) {
714
- const cloned$1 = new Set(target);
716
+ const cloned$1 = tryCloneSetSubclass(target, target) ?? new Set(target);
715
717
  cloned$1[annotationKey] = annotations;
716
718
  return cloned$1;
717
719
  }
package/dist/facade.cjs CHANGED
@@ -1620,7 +1620,7 @@ function runWithAsync(parser, programName, contexts, options) {
1620
1620
  * @returns A new parser with annotations in its initial state.
1621
1621
  */
1622
1622
  function injectAnnotationsIntoParser(parser, annotations) {
1623
- const newInitialState = require_annotations.injectAnnotations(parser.initialState, annotations);
1623
+ const newInitialState = require_annotations.injectFreshRunAnnotations(parser.initialState, annotations);
1624
1624
  const descriptors = { ...Object.getOwnPropertyDescriptors(parser) };
1625
1625
  const initialState = descriptors.initialState;
1626
1626
  descriptors.initialState = initialState == null ? {
package/dist/facade.js CHANGED
@@ -1,4 +1,4 @@
1
- import { injectAnnotations, isInjectedAnnotationWrapper, unwrapInjectedAnnotationWrapper } from "./annotations.js";
1
+ import { injectFreshRunAnnotations, isInjectedAnnotationWrapper, unwrapInjectedAnnotationWrapper } from "./annotations.js";
2
2
  import { commandLine, formatMessage, lineBreak, message, optionName, text, value } from "./message.js";
3
3
  import { bash, fish, nu, pwsh, zsh } from "./completion.js";
4
4
  import { validateCommandNames, validateContextIds, validateMetaNameCollisions, validateOptionNames, validateProgramName } from "./validate.js";
@@ -1620,7 +1620,7 @@ function runWithAsync(parser, programName, contexts, options) {
1620
1620
  * @returns A new parser with annotations in its initial state.
1621
1621
  */
1622
1622
  function injectAnnotationsIntoParser(parser, annotations) {
1623
- const newInitialState = injectAnnotations(parser.initialState, annotations);
1623
+ const newInitialState = injectFreshRunAnnotations(parser.initialState, annotations);
1624
1624
  const descriptors = { ...Object.getOwnPropertyDescriptors(parser) };
1625
1625
  const initialState = descriptors.initialState;
1626
1626
  descriptors.initialState = initialState == null ? {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/core",
3
- "version": "1.0.0-dev.1868+54bdb27a",
3
+ "version": "1.0.0-dev.1870+f804a6a6",
4
4
  "description": "Type-safe combinatorial command-line interface parser",
5
5
  "keywords": [
6
6
  "CLI",