@optique/env 1.0.0-dev.0 → 1.0.0-dev.452
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/index.cjs +9 -2
- package/dist/index.d.cts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +9 -3
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -26,6 +26,12 @@ const __optique_core_message = __toESM(require("@optique/core/message"));
|
|
|
26
26
|
const __optique_core_valueparser = __toESM(require("@optique/core/valueparser"));
|
|
27
27
|
|
|
28
28
|
//#region src/index.ts
|
|
29
|
+
/**
|
|
30
|
+
* Unique symbol for environment source data in annotations.
|
|
31
|
+
*
|
|
32
|
+
* @since 1.0.0
|
|
33
|
+
*/
|
|
34
|
+
const envKey = Symbol.for("@optique/env");
|
|
29
35
|
const activeEnvSourceRegistry = /* @__PURE__ */ new Map();
|
|
30
36
|
/**
|
|
31
37
|
* Sets active environment source data for a context.
|
|
@@ -78,7 +84,7 @@ function createEnvContext(options = {}) {
|
|
|
78
84
|
source
|
|
79
85
|
};
|
|
80
86
|
setActiveEnvSource(contextId, sourceData);
|
|
81
|
-
return { [
|
|
87
|
+
return { [envKey]: sourceData };
|
|
82
88
|
},
|
|
83
89
|
[Symbol.dispose]() {
|
|
84
90
|
clearActiveEnvSource(contextId);
|
|
@@ -176,7 +182,7 @@ function wrapForMode(mode, value) {
|
|
|
176
182
|
}
|
|
177
183
|
function getEnvOrDefault(state, options, mode, innerParser, innerState) {
|
|
178
184
|
const annotations = (0, __optique_core_annotations.getAnnotations)(state);
|
|
179
|
-
const sourceData = annotations?.[
|
|
185
|
+
const sourceData = annotations?.[envKey] ?? getActiveEnvSource(options.context.id);
|
|
180
186
|
const fullKey = `${sourceData?.prefix ?? options.context.prefix}${options.key}`;
|
|
181
187
|
const rawValue = sourceData?.source(fullKey);
|
|
182
188
|
if (rawValue !== void 0) {
|
|
@@ -256,5 +262,6 @@ exports.bindEnv = bindEnv;
|
|
|
256
262
|
exports.bool = bool;
|
|
257
263
|
exports.clearActiveEnvSource = clearActiveEnvSource;
|
|
258
264
|
exports.createEnvContext = createEnvContext;
|
|
265
|
+
exports.envKey = envKey;
|
|
259
266
|
exports.getActiveEnvSource = getActiveEnvSource;
|
|
260
267
|
exports.setActiveEnvSource = setActiveEnvSource;
|
package/dist/index.d.cts
CHANGED
|
@@ -5,6 +5,12 @@ import { NonEmptyString, ValueParser } from "@optique/core/valueparser";
|
|
|
5
5
|
|
|
6
6
|
//#region src/index.d.ts
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Unique symbol for environment source data in annotations.
|
|
10
|
+
*
|
|
11
|
+
* @since 1.0.0
|
|
12
|
+
*/
|
|
13
|
+
declare const envKey: unique symbol;
|
|
8
14
|
/**
|
|
9
15
|
* Function type for reading environment variable values.
|
|
10
16
|
*
|
|
@@ -151,4 +157,4 @@ interface BoolOptions {
|
|
|
151
157
|
*/
|
|
152
158
|
declare function bool(options?: BoolOptions): ValueParser<"sync", boolean>;
|
|
153
159
|
//#endregion
|
|
154
|
-
export { BindEnvOptions, BoolOptions, EnvContext, EnvContextOptions, EnvSource, bindEnv, bool, clearActiveEnvSource, createEnvContext, getActiveEnvSource, setActiveEnvSource };
|
|
160
|
+
export { BindEnvOptions, BoolOptions, EnvContext, EnvContextOptions, EnvSource, bindEnv, bool, clearActiveEnvSource, createEnvContext, envKey, getActiveEnvSource, setActiveEnvSource };
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,12 @@ import { Mode, Parser } from "@optique/core/parser";
|
|
|
5
5
|
|
|
6
6
|
//#region src/index.d.ts
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Unique symbol for environment source data in annotations.
|
|
10
|
+
*
|
|
11
|
+
* @since 1.0.0
|
|
12
|
+
*/
|
|
13
|
+
declare const envKey: unique symbol;
|
|
8
14
|
/**
|
|
9
15
|
* Function type for reading environment variable values.
|
|
10
16
|
*
|
|
@@ -151,4 +157,4 @@ interface BoolOptions {
|
|
|
151
157
|
*/
|
|
152
158
|
declare function bool(options?: BoolOptions): ValueParser<"sync", boolean>;
|
|
153
159
|
//#endregion
|
|
154
|
-
export { BindEnvOptions, BoolOptions, EnvContext, EnvContextOptions, EnvSource, bindEnv, bool, clearActiveEnvSource, createEnvContext, getActiveEnvSource, setActiveEnvSource };
|
|
160
|
+
export { BindEnvOptions, BoolOptions, EnvContext, EnvContextOptions, EnvSource, bindEnv, bool, clearActiveEnvSource, createEnvContext, envKey, getActiveEnvSource, setActiveEnvSource };
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,12 @@ import { message, valueSet } from "@optique/core/message";
|
|
|
3
3
|
import { ensureNonEmptyString } from "@optique/core/valueparser";
|
|
4
4
|
|
|
5
5
|
//#region src/index.ts
|
|
6
|
+
/**
|
|
7
|
+
* Unique symbol for environment source data in annotations.
|
|
8
|
+
*
|
|
9
|
+
* @since 1.0.0
|
|
10
|
+
*/
|
|
11
|
+
const envKey = Symbol.for("@optique/env");
|
|
6
12
|
const activeEnvSourceRegistry = /* @__PURE__ */ new Map();
|
|
7
13
|
/**
|
|
8
14
|
* Sets active environment source data for a context.
|
|
@@ -55,7 +61,7 @@ function createEnvContext(options = {}) {
|
|
|
55
61
|
source
|
|
56
62
|
};
|
|
57
63
|
setActiveEnvSource(contextId, sourceData);
|
|
58
|
-
return { [
|
|
64
|
+
return { [envKey]: sourceData };
|
|
59
65
|
},
|
|
60
66
|
[Symbol.dispose]() {
|
|
61
67
|
clearActiveEnvSource(contextId);
|
|
@@ -153,7 +159,7 @@ function wrapForMode(mode, value) {
|
|
|
153
159
|
}
|
|
154
160
|
function getEnvOrDefault(state, options, mode, innerParser, innerState) {
|
|
155
161
|
const annotations = getAnnotations(state);
|
|
156
|
-
const sourceData = annotations?.[
|
|
162
|
+
const sourceData = annotations?.[envKey] ?? getActiveEnvSource(options.context.id);
|
|
157
163
|
const fullKey = `${sourceData?.prefix ?? options.context.prefix}${options.key}`;
|
|
158
164
|
const rawValue = sourceData?.source(fullKey);
|
|
159
165
|
if (rawValue !== void 0) {
|
|
@@ -229,4 +235,4 @@ function bool(options = {}) {
|
|
|
229
235
|
}
|
|
230
236
|
|
|
231
237
|
//#endregion
|
|
232
|
-
export { bindEnv, bool, clearActiveEnvSource, createEnvContext, getActiveEnvSource, setActiveEnvSource };
|
|
238
|
+
export { bindEnv, bool, clearActiveEnvSource, createEnvContext, envKey, getActiveEnvSource, setActiveEnvSource };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@optique/env",
|
|
3
|
-
"version": "1.0.0-dev.
|
|
3
|
+
"version": "1.0.0-dev.452+dd54f74f",
|
|
4
4
|
"description": "Environment variable support for Optique",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"CLI",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
},
|
|
55
55
|
"sideEffects": false,
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@optique/core": "1.0.0"
|
|
57
|
+
"@optique/core": "1.0.0-dev.452+dd54f74f"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@types/node": "^20.19.9",
|