@optique/core 1.0.0-dev.1802 → 1.0.0-dev.1806

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.
package/dist/facade.cjs CHANGED
@@ -1098,21 +1098,20 @@ function validateContextPhases(contexts) {
1098
1098
  */
1099
1099
  async function collectPhase1Annotations(contexts, options) {
1100
1100
  const annotationsList = [];
1101
- const snapshots = [];
1102
- let needsTwoPhase = false;
1101
+ let snapshots;
1103
1102
  for (const context of contexts) {
1104
1103
  const result = context.getAnnotations(void 0, options);
1105
1104
  const annotations = result instanceof Promise ? await result : result;
1106
1105
  const internalAnnotations = context.getInternalAnnotations?.(void 0, annotations);
1107
1106
  const snapshot = internalAnnotations == null ? annotations : mergeAnnotations([annotations, internalAnnotations]);
1108
1107
  annotationsList.push(snapshot);
1109
- snapshots.push(snapshot);
1110
- needsTwoPhase ||= context.phase === "two-pass";
1108
+ if (snapshots != null) snapshots.push(snapshot);
1109
+ else if (context.phase === "two-pass") snapshots = [...annotationsList];
1111
1110
  }
1112
1111
  return {
1113
1112
  annotations: mergeAnnotations(annotationsList),
1114
- needsTwoPhase,
1115
- snapshots
1113
+ needsTwoPhase: snapshots != null,
1114
+ snapshots: snapshots ?? []
1116
1115
  };
1117
1116
  }
1118
1117
  /**
@@ -1158,21 +1157,20 @@ async function collectFinalAnnotations(contexts, phase1Snapshots, parsed, option
1158
1157
  */
1159
1158
  function collectPhase1AnnotationsSync(contexts, options) {
1160
1159
  const annotationsList = [];
1161
- const snapshots = [];
1162
- let needsTwoPhase = false;
1160
+ let snapshots;
1163
1161
  for (const context of contexts) {
1164
1162
  const result = context.getAnnotations(void 0, options);
1165
1163
  if (result instanceof Promise) throw new Error(`Context ${String(context.id)} returned a Promise in sync mode. Use runWith() or runWithAsync() for async contexts.`);
1166
1164
  const internalAnnotations = context.getInternalAnnotations?.(void 0, result);
1167
1165
  const snapshot = internalAnnotations == null ? result : mergeAnnotations([result, internalAnnotations]);
1168
1166
  annotationsList.push(snapshot);
1169
- snapshots.push(snapshot);
1170
- needsTwoPhase ||= context.phase === "two-pass";
1167
+ if (snapshots != null) snapshots.push(snapshot);
1168
+ else if (context.phase === "two-pass") snapshots = [...annotationsList];
1171
1169
  }
1172
1170
  return {
1173
1171
  annotations: mergeAnnotations(annotationsList),
1174
- needsTwoPhase,
1175
- snapshots
1172
+ needsTwoPhase: snapshots != null,
1173
+ snapshots: snapshots ?? []
1176
1174
  };
1177
1175
  }
1178
1176
  /**
package/dist/facade.js CHANGED
@@ -1098,21 +1098,20 @@ function validateContextPhases(contexts) {
1098
1098
  */
1099
1099
  async function collectPhase1Annotations(contexts, options) {
1100
1100
  const annotationsList = [];
1101
- const snapshots = [];
1102
- let needsTwoPhase = false;
1101
+ let snapshots;
1103
1102
  for (const context of contexts) {
1104
1103
  const result = context.getAnnotations(void 0, options);
1105
1104
  const annotations = result instanceof Promise ? await result : result;
1106
1105
  const internalAnnotations = context.getInternalAnnotations?.(void 0, annotations);
1107
1106
  const snapshot = internalAnnotations == null ? annotations : mergeAnnotations([annotations, internalAnnotations]);
1108
1107
  annotationsList.push(snapshot);
1109
- snapshots.push(snapshot);
1110
- needsTwoPhase ||= context.phase === "two-pass";
1108
+ if (snapshots != null) snapshots.push(snapshot);
1109
+ else if (context.phase === "two-pass") snapshots = [...annotationsList];
1111
1110
  }
1112
1111
  return {
1113
1112
  annotations: mergeAnnotations(annotationsList),
1114
- needsTwoPhase,
1115
- snapshots
1113
+ needsTwoPhase: snapshots != null,
1114
+ snapshots: snapshots ?? []
1116
1115
  };
1117
1116
  }
1118
1117
  /**
@@ -1158,21 +1157,20 @@ async function collectFinalAnnotations(contexts, phase1Snapshots, parsed, option
1158
1157
  */
1159
1158
  function collectPhase1AnnotationsSync(contexts, options) {
1160
1159
  const annotationsList = [];
1161
- const snapshots = [];
1162
- let needsTwoPhase = false;
1160
+ let snapshots;
1163
1161
  for (const context of contexts) {
1164
1162
  const result = context.getAnnotations(void 0, options);
1165
1163
  if (result instanceof Promise) throw new Error(`Context ${String(context.id)} returned a Promise in sync mode. Use runWith() or runWithAsync() for async contexts.`);
1166
1164
  const internalAnnotations = context.getInternalAnnotations?.(void 0, result);
1167
1165
  const snapshot = internalAnnotations == null ? result : mergeAnnotations([result, internalAnnotations]);
1168
1166
  annotationsList.push(snapshot);
1169
- snapshots.push(snapshot);
1170
- needsTwoPhase ||= context.phase === "two-pass";
1167
+ if (snapshots != null) snapshots.push(snapshot);
1168
+ else if (context.phase === "two-pass") snapshots = [...annotationsList];
1171
1169
  }
1172
1170
  return {
1173
1171
  annotations: mergeAnnotations(annotationsList),
1174
- needsTwoPhase,
1175
- snapshots
1172
+ needsTwoPhase: snapshots != null,
1173
+ snapshots: snapshots ?? []
1176
1174
  };
1177
1175
  }
1178
1176
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/core",
3
- "version": "1.0.0-dev.1802+accfecbe",
3
+ "version": "1.0.0-dev.1806+8e8ab746",
4
4
  "description": "Type-safe combinatorial command-line interface parser",
5
5
  "keywords": [
6
6
  "CLI",