veryfront 0.1.692 → 0.1.693
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/esm/deno.js +1 -1
- package/esm/src/platform/compat/process/env.d.ts.map +1 -1
- package/esm/src/platform/compat/process/env.js +7 -0
- package/esm/src/server/project-env/storage.d.ts.map +1 -1
- package/esm/src/server/project-env/storage.js +98 -0
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/package.json +1 -1
package/esm/deno.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../../../../src/src/platform/compat/process/env.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../../../../src/src/platform/compat/process/env.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,MAAM,OAAO,CAAC;IACxB,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IAC5C,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACtC,CAAC;AAyBF,oDAAoD;AACpD,wBAAgB,GAAG,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAmB5C;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAW1D;AAqCD,kEAAkE;AAClE,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAWtD;AAKD,MAAM,WAAW,iBAAiB;IAChC,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAUD,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AAC9D,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;AAOpE,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AAC9D,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;AAUpE,wBAAgB,aAAa,CAC3B,GAAG,EAAE,MAAM,EACX,QAAQ,UAAQ,EAChB,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAmBT;AAED,gBAAgB;AAChB,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAgBvD;AAED,6CAA6C;AAC7C,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAgB3C;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,iBAAiB,GAAG,IAAI,CAS/D"}
|
|
@@ -13,6 +13,10 @@ function getOverlayEnvValue(store, key) {
|
|
|
13
13
|
const value = store.get(key);
|
|
14
14
|
return { hasValue: true, value: value ?? undefined };
|
|
15
15
|
}
|
|
16
|
+
function getHostProcessEnvFromProjectProxy(key) {
|
|
17
|
+
const getter = dntShim.dntGlobalThis.__vfHostProcessEnvGetter;
|
|
18
|
+
return typeof getter === "function" ? getter(key) : undefined;
|
|
19
|
+
}
|
|
16
20
|
/** Read and write process environment variables. */
|
|
17
21
|
export function env() {
|
|
18
22
|
const base = IS_DENO
|
|
@@ -43,6 +47,9 @@ export function getHostEnv(key) {
|
|
|
43
47
|
}
|
|
44
48
|
if (IS_DENO)
|
|
45
49
|
return dntShim.Deno.env.get(key);
|
|
50
|
+
const projectProxyHostValue = getHostProcessEnvFromProjectProxy(key);
|
|
51
|
+
if (projectProxyHostValue !== undefined)
|
|
52
|
+
return projectProxyHostValue;
|
|
46
53
|
if (runtimeProcess)
|
|
47
54
|
return runtimeProcess.env[key];
|
|
48
55
|
return undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../../src/src/server/project-env/storage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../../src/src/server/project-env/storage.ts"],"names":[],"mappings":"AAmIA;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAGjF;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAE7D;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,IAAI,OAAO,CAE5C;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAE1E"}
|
|
@@ -9,11 +9,108 @@
|
|
|
9
9
|
import * as dntShim from "../../../_dnt.shims.js";
|
|
10
10
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
11
11
|
const projectEnvStorage = new AsyncLocalStorage();
|
|
12
|
+
const PROCESS_ENV_PROXY_FLAG = "__vfProjectEnvProcessProxyInstalled";
|
|
13
|
+
const PROCESS_ENV_PROXY_REF = "__vfProjectEnvProcessProxy";
|
|
14
|
+
const PROCESS_ENV_HOST_GETTER = "__vfHostProcessEnvGetter";
|
|
15
|
+
function getGlobalProcess() {
|
|
16
|
+
const candidate = dntShim.dntGlobalThis.process;
|
|
17
|
+
return candidate && typeof candidate === "object" ? candidate : undefined;
|
|
18
|
+
}
|
|
19
|
+
function getActiveStore() {
|
|
20
|
+
return projectEnvStorage.getStore();
|
|
21
|
+
}
|
|
22
|
+
function installProcessEnvProxy() {
|
|
23
|
+
const globals = dntShim.dntGlobalThis;
|
|
24
|
+
const processLike = getGlobalProcess();
|
|
25
|
+
if (!processLike?.env)
|
|
26
|
+
return;
|
|
27
|
+
if (globals[PROCESS_ENV_PROXY_FLAG] && globals[PROCESS_ENV_PROXY_REF] === processLike.env)
|
|
28
|
+
return;
|
|
29
|
+
const hostEnv = processLike.env;
|
|
30
|
+
globals[PROCESS_ENV_HOST_GETTER] = (key) => hostEnv[key];
|
|
31
|
+
const proxy = new Proxy(hostEnv, {
|
|
32
|
+
get(target, property, receiver) {
|
|
33
|
+
if (typeof property !== "string") {
|
|
34
|
+
return Reflect.get(target, property, receiver);
|
|
35
|
+
}
|
|
36
|
+
const store = getActiveStore();
|
|
37
|
+
if (store !== undefined) {
|
|
38
|
+
return Object.prototype.hasOwnProperty.call(store, property) ? store[property] : undefined;
|
|
39
|
+
}
|
|
40
|
+
return target[property];
|
|
41
|
+
},
|
|
42
|
+
set(target, property, value, receiver) {
|
|
43
|
+
if (typeof property !== "string") {
|
|
44
|
+
return Reflect.set(target, property, value, receiver);
|
|
45
|
+
}
|
|
46
|
+
const normalized = String(value);
|
|
47
|
+
const store = getActiveStore();
|
|
48
|
+
if (store !== undefined) {
|
|
49
|
+
store[property] = normalized;
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
target[property] = normalized;
|
|
53
|
+
return true;
|
|
54
|
+
},
|
|
55
|
+
deleteProperty(target, property) {
|
|
56
|
+
if (typeof property !== "string") {
|
|
57
|
+
return Reflect.deleteProperty(target, property);
|
|
58
|
+
}
|
|
59
|
+
const store = getActiveStore();
|
|
60
|
+
if (store !== undefined) {
|
|
61
|
+
delete store[property];
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
return Reflect.deleteProperty(target, property);
|
|
65
|
+
},
|
|
66
|
+
has(target, property) {
|
|
67
|
+
if (typeof property !== "string") {
|
|
68
|
+
return Reflect.has(target, property);
|
|
69
|
+
}
|
|
70
|
+
const store = getActiveStore();
|
|
71
|
+
if (store !== undefined) {
|
|
72
|
+
return Object.prototype.hasOwnProperty.call(store, property);
|
|
73
|
+
}
|
|
74
|
+
return property in target;
|
|
75
|
+
},
|
|
76
|
+
ownKeys(target) {
|
|
77
|
+
const store = getActiveStore();
|
|
78
|
+
return store !== undefined ? Reflect.ownKeys(store) : Reflect.ownKeys(target);
|
|
79
|
+
},
|
|
80
|
+
getOwnPropertyDescriptor(target, property) {
|
|
81
|
+
if (typeof property !== "string") {
|
|
82
|
+
return Reflect.getOwnPropertyDescriptor(target, property);
|
|
83
|
+
}
|
|
84
|
+
const store = getActiveStore();
|
|
85
|
+
if (store !== undefined) {
|
|
86
|
+
if (!Object.prototype.hasOwnProperty.call(store, property)) {
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
configurable: true,
|
|
91
|
+
enumerable: true,
|
|
92
|
+
writable: true,
|
|
93
|
+
value: store[property],
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
return Reflect.getOwnPropertyDescriptor(target, property);
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
Object.defineProperty(processLike, "env", {
|
|
100
|
+
configurable: true,
|
|
101
|
+
enumerable: true,
|
|
102
|
+
writable: true,
|
|
103
|
+
value: proxy,
|
|
104
|
+
});
|
|
105
|
+
globals[PROCESS_ENV_PROXY_FLAG] = true;
|
|
106
|
+
globals[PROCESS_ENV_PROXY_REF] = proxy;
|
|
107
|
+
}
|
|
12
108
|
/**
|
|
13
109
|
* Run a function with project-specific environment variables.
|
|
14
110
|
* Within the callback, `getProjectEnv()` will return values from `vars`.
|
|
15
111
|
*/
|
|
16
112
|
export function runWithProjectEnv(vars, fn) {
|
|
113
|
+
installProcessEnvProxy();
|
|
17
114
|
return projectEnvStorage.run(vars, fn);
|
|
18
115
|
}
|
|
19
116
|
/**
|
|
@@ -44,3 +141,4 @@ export function getProjectEnvSnapshot() {
|
|
|
44
141
|
dntShim.dntGlobalThis.__vfProjectEnvGetter = getProjectEnv;
|
|
45
142
|
dntShim.dntGlobalThis.__vfProjectEnvActiveChecker = isProjectEnvActive;
|
|
46
143
|
dntShim.dntGlobalThis.__vfProjectEnvSnapshotGetter = getProjectEnvSnapshot;
|
|
144
|
+
installProcessEnvProxy();
|