@venizia/ardor-kernel 0.3.6 → 0.3.7
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/utilities/index.d.ts +1 -0
- package/dist/utilities/index.d.ts.map +1 -1
- package/dist/utilities/index.js +1 -0
- package/dist/utilities/index.js.map +1 -1
- package/dist/utilities/runtime-config.d.ts +17 -0
- package/dist/utilities/runtime-config.d.ts.map +1 -0
- package/dist/utilities/runtime-config.js +30 -0
- package/dist/utilities/runtime-config.js.map +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC;AACjC,cAAc,OAAO,CAAC"}
|
package/dist/utilities/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC;AACjC,cAAc,OAAO,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The name `config.js` writes the runtime config under: `window.__APP_CONFIG__`, a record of strings.
|
|
3
|
+
* The preset image writes it at container start, from the environment variables that start with `VITE_`.
|
|
4
|
+
*/
|
|
5
|
+
export declare const RUNTIME_CONFIG_GLOBAL = "__APP_CONFIG__";
|
|
6
|
+
/**
|
|
7
|
+
* One value of the app's config: the runtime one (`window.__APP_CONFIG__`, written when the container
|
|
8
|
+
* starts), else the build-time one (`buildTimeEnv`, which the app passes as `import.meta.env`; this
|
|
9
|
+
* package never reads `import.meta`), else `defaultValue`. Only a non-empty string counts at either
|
|
10
|
+
* level, and a missing global is not an error, so the same call works in dev, in a test and in the image.
|
|
11
|
+
*/
|
|
12
|
+
export declare const getRuntimeConfig: (opts: {
|
|
13
|
+
key: string;
|
|
14
|
+
buildTimeEnv?: Record<string, unknown>;
|
|
15
|
+
defaultValue?: string;
|
|
16
|
+
}) => string | undefined;
|
|
17
|
+
//# sourceMappingURL=runtime-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-config.d.ts","sourceRoot":"","sources":["../../src/utilities/runtime-config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,qBAAqB,mBAAmB,CAAC;AAmBtD;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAAI,MAAM;IACrC,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,KAAG,MAAM,GAAG,SAQZ,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The name `config.js` writes the runtime config under: `window.__APP_CONFIG__`, a record of strings.
|
|
3
|
+
* The preset image writes it at container start, from the environment variables that start with `VITE_`.
|
|
4
|
+
*/
|
|
5
|
+
export const RUNTIME_CONFIG_GLOBAL = '__APP_CONFIG__';
|
|
6
|
+
const readString = (opts) => {
|
|
7
|
+
const { source, key } = opts;
|
|
8
|
+
if (typeof source !== 'object' || source === null || Array.isArray(source)) {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
// Own keys only: `toString` and `constructor` are not config values.
|
|
12
|
+
if (!Object.prototype.hasOwnProperty.call(source, key)) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
const value = Reflect.get(source, key);
|
|
16
|
+
return typeof value === 'string' && value !== '' ? value : undefined;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* One value of the app's config: the runtime one (`window.__APP_CONFIG__`, written when the container
|
|
20
|
+
* starts), else the build-time one (`buildTimeEnv`, which the app passes as `import.meta.env`; this
|
|
21
|
+
* package never reads `import.meta`), else `defaultValue`. Only a non-empty string counts at either
|
|
22
|
+
* level, and a missing global is not an error, so the same call works in dev, in a test and in the image.
|
|
23
|
+
*/
|
|
24
|
+
export const getRuntimeConfig = (opts) => {
|
|
25
|
+
const { key, buildTimeEnv, defaultValue } = opts;
|
|
26
|
+
return (readString({ source: Reflect.get(globalThis, RUNTIME_CONFIG_GLOBAL), key }) ??
|
|
27
|
+
readString({ source: buildTimeEnv, key }) ??
|
|
28
|
+
defaultValue);
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=runtime-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-config.js","sourceRoot":"","sources":["../../src/utilities/runtime-config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,gBAAgB,CAAC;AAEtD,MAAM,UAAU,GAAG,CAAC,IAAsC,EAAsB,EAAE;IAChF,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAE7B,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAC3E,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,qEAAqE;IACrE,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;QACvD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,KAAK,GAAY,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAEhD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACvE,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,IAIhC,EAAsB,EAAE;IACvB,MAAM,EAAE,GAAG,EAAE,YAAY,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC;IAEjD,OAAO,CACL,UAAU,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,qBAAqB,CAAC,EAAE,GAAG,EAAE,CAAC;QAC3E,UAAU,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,CAAC;QACzC,YAAY,CACb,CAAC;AACJ,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@venizia/ardor-kernel",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.7",
|
|
4
4
|
"description": "ARDOR kernel - the isomorphic core of the ARDOR frontend framework: application base on IGNIS inversion, service and CRUD bases, request/auth constants, binding keys, logger, network fetchers and socket client. No React and no react-admin.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ardor",
|