@optique/core 1.0.0-dev.453 → 1.0.0-dev.454

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/context.cjs CHANGED
@@ -12,6 +12,7 @@
12
12
  * @since 0.10.0
13
13
  */
14
14
  function isStaticContext(context) {
15
+ if (context.mode !== void 0) return context.mode === "static";
15
16
  const result = context.getAnnotations();
16
17
  if (result instanceof Promise) return false;
17
18
  return Object.getOwnPropertySymbols(result).length > 0;
@@ -2,6 +2,17 @@ import { Annotations } from "./annotations.cjs";
2
2
 
3
3
  //#region src/context.d.ts
4
4
 
5
+ /**
6
+ * Declares whether a {@link SourceContext} provides its annotations
7
+ * immediately (`"static"`) or only after a prior parse pass (`"dynamic"`).
8
+ *
9
+ * Used as the type of the optional `mode` field on {@link SourceContext}.
10
+ * When set, {@link isStaticContext} reads this value directly instead of
11
+ * calling `getAnnotations()`, preventing any side effects.
12
+ *
13
+ * @since 1.0.0
14
+ */
15
+ type SourceContextMode = "static" | "dynamic";
5
16
  /**
6
17
  * Brand symbol for ParserValuePlaceholder type.
7
18
  * @internal
@@ -93,6 +104,19 @@ interface SourceContext<TRequiredOptions = void> {
93
104
  * @internal
94
105
  */
95
106
  readonly $requiredOptions?: TRequiredOptions;
107
+ /**
108
+ * Optional declaration of whether this context is static or dynamic.
109
+ *
110
+ * When present, {@link isStaticContext} reads this field directly instead
111
+ * of calling {@link getAnnotations}, avoiding any side effects that
112
+ * `getAnnotations` might have (such as mutating a global registry).
113
+ *
114
+ * If omitted, {@link isStaticContext} falls back to calling
115
+ * `getAnnotations()` with no arguments to determine static-ness.
116
+ *
117
+ * @since 1.0.0
118
+ */
119
+ readonly mode?: SourceContextMode;
96
120
  /**
97
121
  * Get annotations to inject into parsing.
98
122
  *
@@ -139,4 +163,4 @@ interface SourceContext<TRequiredOptions = void> {
139
163
  */
140
164
  declare function isStaticContext(context: SourceContext<unknown>): boolean;
141
165
  //#endregion
142
- export { type Annotations, ParserValuePlaceholder, SourceContext, isStaticContext };
166
+ export { type Annotations, ParserValuePlaceholder, SourceContext, SourceContextMode, isStaticContext };
package/dist/context.d.ts CHANGED
@@ -2,6 +2,17 @@ import { Annotations } from "./annotations.js";
2
2
 
3
3
  //#region src/context.d.ts
4
4
 
5
+ /**
6
+ * Declares whether a {@link SourceContext} provides its annotations
7
+ * immediately (`"static"`) or only after a prior parse pass (`"dynamic"`).
8
+ *
9
+ * Used as the type of the optional `mode` field on {@link SourceContext}.
10
+ * When set, {@link isStaticContext} reads this value directly instead of
11
+ * calling `getAnnotations()`, preventing any side effects.
12
+ *
13
+ * @since 1.0.0
14
+ */
15
+ type SourceContextMode = "static" | "dynamic";
5
16
  /**
6
17
  * Brand symbol for ParserValuePlaceholder type.
7
18
  * @internal
@@ -93,6 +104,19 @@ interface SourceContext<TRequiredOptions = void> {
93
104
  * @internal
94
105
  */
95
106
  readonly $requiredOptions?: TRequiredOptions;
107
+ /**
108
+ * Optional declaration of whether this context is static or dynamic.
109
+ *
110
+ * When present, {@link isStaticContext} reads this field directly instead
111
+ * of calling {@link getAnnotations}, avoiding any side effects that
112
+ * `getAnnotations` might have (such as mutating a global registry).
113
+ *
114
+ * If omitted, {@link isStaticContext} falls back to calling
115
+ * `getAnnotations()` with no arguments to determine static-ness.
116
+ *
117
+ * @since 1.0.0
118
+ */
119
+ readonly mode?: SourceContextMode;
96
120
  /**
97
121
  * Get annotations to inject into parsing.
98
122
  *
@@ -139,4 +163,4 @@ interface SourceContext<TRequiredOptions = void> {
139
163
  */
140
164
  declare function isStaticContext(context: SourceContext<unknown>): boolean;
141
165
  //#endregion
142
- export { type Annotations, ParserValuePlaceholder, SourceContext, isStaticContext };
166
+ export { type Annotations, ParserValuePlaceholder, SourceContext, SourceContextMode, isStaticContext };
package/dist/context.js CHANGED
@@ -11,6 +11,7 @@
11
11
  * @since 0.10.0
12
12
  */
13
13
  function isStaticContext(context) {
14
+ if (context.mode !== void 0) return context.mode === "static";
14
15
  const result = context.getAnnotations();
15
16
  if (result instanceof Promise) return false;
16
17
  return Object.getOwnPropertySymbols(result).length > 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/core",
3
- "version": "1.0.0-dev.453+9dcddf47",
3
+ "version": "1.0.0-dev.454+d2244c89",
4
4
  "description": "Type-safe combinatorial command-line interface parser",
5
5
  "keywords": [
6
6
  "CLI",