@optique/core 1.0.0-dev.429 → 1.0.0-dev.432

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.
@@ -46,6 +46,10 @@ type ParserValuePlaceholder = {
46
46
  * - *Dynamic*: Data depends on parsing results (e.g., config files whose path
47
47
  * is determined by a CLI option)
48
48
  *
49
+ * Contexts may optionally implement `Disposable` or `AsyncDisposable` for
50
+ * cleanup. When present, `runWith()` and `runWithSync()` call the dispose
51
+ * method in a `finally` block after parsing completes.
52
+ *
49
53
  * @template TRequiredOptions Additional options that `runWith()` must provide
50
54
  * when this context is used. Use `void` (the default) for contexts that
51
55
  * don't require extra options. Use {@link ParserValuePlaceholder} in option
@@ -88,7 +92,7 @@ interface SourceContext<TRequiredOptions = void> {
88
92
  * Type-level marker for the required options. Not used at runtime.
89
93
  * @internal
90
94
  */
91
- readonly _requiredOptions?: TRequiredOptions;
95
+ readonly $requiredOptions?: TRequiredOptions;
92
96
  /**
93
97
  * Get annotations to inject into parsing.
94
98
  *
@@ -103,10 +107,24 @@ interface SourceContext<TRequiredOptions = void> {
103
107
  * @param parsed Optional parsed result from a previous parse pass.
104
108
  * Static contexts can ignore this parameter.
105
109
  * Dynamic contexts use this to extract necessary data.
110
+ * @param options Optional context-required options provided by the caller
111
+ * of `runWith()`. These are the options declared via the
112
+ * `TRequiredOptions` type parameter.
106
113
  * @returns Annotations to merge into the parsing session. Can be a Promise
107
114
  * for async operations (e.g., loading config files).
108
115
  */
109
- getAnnotations(parsed?: unknown): Promise<Annotations> | Annotations;
116
+ getAnnotations(parsed?: unknown, options?: unknown): Promise<Annotations> | Annotations;
117
+ /**
118
+ * Optional synchronous cleanup method. Called by `runWith()` and
119
+ * `runWithSync()` in a `finally` block after parsing completes.
120
+ */
121
+ [Symbol.dispose]?(): void;
122
+ /**
123
+ * Optional asynchronous cleanup method. Called by `runWith()` in a
124
+ * `finally` block after parsing completes. Takes precedence over
125
+ * `[Symbol.dispose]` in async runners.
126
+ */
127
+ [Symbol.asyncDispose]?(): void | PromiseLike<void>;
110
128
  }
111
129
  /**
112
130
  * Checks whether a context is static (returns annotations without needing
package/dist/context.d.ts CHANGED
@@ -46,6 +46,10 @@ type ParserValuePlaceholder = {
46
46
  * - *Dynamic*: Data depends on parsing results (e.g., config files whose path
47
47
  * is determined by a CLI option)
48
48
  *
49
+ * Contexts may optionally implement `Disposable` or `AsyncDisposable` for
50
+ * cleanup. When present, `runWith()` and `runWithSync()` call the dispose
51
+ * method in a `finally` block after parsing completes.
52
+ *
49
53
  * @template TRequiredOptions Additional options that `runWith()` must provide
50
54
  * when this context is used. Use `void` (the default) for contexts that
51
55
  * don't require extra options. Use {@link ParserValuePlaceholder} in option
@@ -88,7 +92,7 @@ interface SourceContext<TRequiredOptions = void> {
88
92
  * Type-level marker for the required options. Not used at runtime.
89
93
  * @internal
90
94
  */
91
- readonly _requiredOptions?: TRequiredOptions;
95
+ readonly $requiredOptions?: TRequiredOptions;
92
96
  /**
93
97
  * Get annotations to inject into parsing.
94
98
  *
@@ -103,10 +107,24 @@ interface SourceContext<TRequiredOptions = void> {
103
107
  * @param parsed Optional parsed result from a previous parse pass.
104
108
  * Static contexts can ignore this parameter.
105
109
  * Dynamic contexts use this to extract necessary data.
110
+ * @param options Optional context-required options provided by the caller
111
+ * of `runWith()`. These are the options declared via the
112
+ * `TRequiredOptions` type parameter.
106
113
  * @returns Annotations to merge into the parsing session. Can be a Promise
107
114
  * for async operations (e.g., loading config files).
108
115
  */
109
- getAnnotations(parsed?: unknown): Promise<Annotations> | Annotations;
116
+ getAnnotations(parsed?: unknown, options?: unknown): Promise<Annotations> | Annotations;
117
+ /**
118
+ * Optional synchronous cleanup method. Called by `runWith()` and
119
+ * `runWithSync()` in a `finally` block after parsing completes.
120
+ */
121
+ [Symbol.dispose]?(): void;
122
+ /**
123
+ * Optional asynchronous cleanup method. Called by `runWith()` in a
124
+ * `finally` block after parsing completes. Takes precedence over
125
+ * `[Symbol.dispose]` in async runners.
126
+ */
127
+ [Symbol.asyncDispose]?(): void | PromiseLike<void>;
110
128
  }
111
129
  /**
112
130
  * Checks whether a context is static (returns annotations without needing