@optique/env 1.0.0-dev.452 → 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/index.cjs +3 -9
- package/dist/index.d.cts +1 -7
- package/dist/index.d.ts +1 -7
- package/dist/index.js +4 -9
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -26,12 +26,6 @@ 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");
|
|
35
29
|
const activeEnvSourceRegistry = /* @__PURE__ */ new Map();
|
|
36
30
|
/**
|
|
37
31
|
* Sets active environment source data for a context.
|
|
@@ -78,13 +72,14 @@ function createEnvContext(options = {}) {
|
|
|
78
72
|
id: contextId,
|
|
79
73
|
prefix,
|
|
80
74
|
source,
|
|
75
|
+
mode: "static",
|
|
81
76
|
getAnnotations() {
|
|
82
77
|
const sourceData = {
|
|
83
78
|
prefix,
|
|
84
79
|
source
|
|
85
80
|
};
|
|
86
81
|
setActiveEnvSource(contextId, sourceData);
|
|
87
|
-
return { [
|
|
82
|
+
return { [contextId]: sourceData };
|
|
88
83
|
},
|
|
89
84
|
[Symbol.dispose]() {
|
|
90
85
|
clearActiveEnvSource(contextId);
|
|
@@ -182,7 +177,7 @@ function wrapForMode(mode, value) {
|
|
|
182
177
|
}
|
|
183
178
|
function getEnvOrDefault(state, options, mode, innerParser, innerState) {
|
|
184
179
|
const annotations = (0, __optique_core_annotations.getAnnotations)(state);
|
|
185
|
-
const sourceData = annotations?.[
|
|
180
|
+
const sourceData = annotations?.[options.context.id] ?? getActiveEnvSource(options.context.id);
|
|
186
181
|
const fullKey = `${sourceData?.prefix ?? options.context.prefix}${options.key}`;
|
|
187
182
|
const rawValue = sourceData?.source(fullKey);
|
|
188
183
|
if (rawValue !== void 0) {
|
|
@@ -262,6 +257,5 @@ exports.bindEnv = bindEnv;
|
|
|
262
257
|
exports.bool = bool;
|
|
263
258
|
exports.clearActiveEnvSource = clearActiveEnvSource;
|
|
264
259
|
exports.createEnvContext = createEnvContext;
|
|
265
|
-
exports.envKey = envKey;
|
|
266
260
|
exports.getActiveEnvSource = getActiveEnvSource;
|
|
267
261
|
exports.setActiveEnvSource = setActiveEnvSource;
|
package/dist/index.d.cts
CHANGED
|
@@ -5,12 +5,6 @@ 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;
|
|
14
8
|
/**
|
|
15
9
|
* Function type for reading environment variable values.
|
|
16
10
|
*
|
|
@@ -157,4 +151,4 @@ interface BoolOptions {
|
|
|
157
151
|
*/
|
|
158
152
|
declare function bool(options?: BoolOptions): ValueParser<"sync", boolean>;
|
|
159
153
|
//#endregion
|
|
160
|
-
export { BindEnvOptions, BoolOptions, EnvContext, EnvContextOptions, EnvSource, bindEnv, bool, clearActiveEnvSource, createEnvContext,
|
|
154
|
+
export { BindEnvOptions, BoolOptions, EnvContext, EnvContextOptions, EnvSource, bindEnv, bool, clearActiveEnvSource, createEnvContext, getActiveEnvSource, setActiveEnvSource };
|
package/dist/index.d.ts
CHANGED
|
@@ -5,12 +5,6 @@ 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;
|
|
14
8
|
/**
|
|
15
9
|
* Function type for reading environment variable values.
|
|
16
10
|
*
|
|
@@ -157,4 +151,4 @@ interface BoolOptions {
|
|
|
157
151
|
*/
|
|
158
152
|
declare function bool(options?: BoolOptions): ValueParser<"sync", boolean>;
|
|
159
153
|
//#endregion
|
|
160
|
-
export { BindEnvOptions, BoolOptions, EnvContext, EnvContextOptions, EnvSource, bindEnv, bool, clearActiveEnvSource, createEnvContext,
|
|
154
|
+
export { BindEnvOptions, BoolOptions, EnvContext, EnvContextOptions, EnvSource, bindEnv, bool, clearActiveEnvSource, createEnvContext, getActiveEnvSource, setActiveEnvSource };
|
package/dist/index.js
CHANGED
|
@@ -3,12 +3,6 @@ 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");
|
|
12
6
|
const activeEnvSourceRegistry = /* @__PURE__ */ new Map();
|
|
13
7
|
/**
|
|
14
8
|
* Sets active environment source data for a context.
|
|
@@ -55,13 +49,14 @@ function createEnvContext(options = {}) {
|
|
|
55
49
|
id: contextId,
|
|
56
50
|
prefix,
|
|
57
51
|
source,
|
|
52
|
+
mode: "static",
|
|
58
53
|
getAnnotations() {
|
|
59
54
|
const sourceData = {
|
|
60
55
|
prefix,
|
|
61
56
|
source
|
|
62
57
|
};
|
|
63
58
|
setActiveEnvSource(contextId, sourceData);
|
|
64
|
-
return { [
|
|
59
|
+
return { [contextId]: sourceData };
|
|
65
60
|
},
|
|
66
61
|
[Symbol.dispose]() {
|
|
67
62
|
clearActiveEnvSource(contextId);
|
|
@@ -159,7 +154,7 @@ function wrapForMode(mode, value) {
|
|
|
159
154
|
}
|
|
160
155
|
function getEnvOrDefault(state, options, mode, innerParser, innerState) {
|
|
161
156
|
const annotations = getAnnotations(state);
|
|
162
|
-
const sourceData = annotations?.[
|
|
157
|
+
const sourceData = annotations?.[options.context.id] ?? getActiveEnvSource(options.context.id);
|
|
163
158
|
const fullKey = `${sourceData?.prefix ?? options.context.prefix}${options.key}`;
|
|
164
159
|
const rawValue = sourceData?.source(fullKey);
|
|
165
160
|
if (rawValue !== void 0) {
|
|
@@ -235,4 +230,4 @@ function bool(options = {}) {
|
|
|
235
230
|
}
|
|
236
231
|
|
|
237
232
|
//#endregion
|
|
238
|
-
export { bindEnv, bool, clearActiveEnvSource, createEnvContext,
|
|
233
|
+
export { bindEnv, bool, clearActiveEnvSource, createEnvContext, 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.454+d2244c89",
|
|
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-dev.
|
|
57
|
+
"@optique/core": "1.0.0-dev.454+d2244c89"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@types/node": "^20.19.9",
|