@squide/env-vars 1.1.2 → 1.1.3
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/CHANGELOG.md +16 -7
- package/README.md +2 -2
- package/dist/EnvironmentVariablesPlugin.js +4 -4
- package/dist/EnvironmentVariablesPlugin.js.map +1 -1
- package/dist/EnvironmentVariablesRegistry.js +1 -1
- package/dist/EnvironmentVariablesRegistry.js.map +1 -1
- package/dist/useEnvironmentVariable.js +4 -4
- package/dist/useEnvironmentVariable.js.map +1 -1
- package/package.json +14 -18
- package/src/EnvironmentVariablesRegistry.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,36 +1,45 @@
|
|
|
1
1
|
# @squide/env-vars
|
|
2
2
|
|
|
3
|
+
## 1.1.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#244](https://github.com/workleap/wl-squide/pull/244) [`5d13eb0`](https://github.com/workleap/wl-squide/commit/5d13eb038a724b499b820d7e1dc864c87954510b) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Updated dependencies.
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`5d13eb0`](https://github.com/workleap/wl-squide/commit/5d13eb038a724b499b820d7e1dc864c87954510b)]:
|
|
10
|
+
- @squide/core@5.4.3
|
|
11
|
+
|
|
3
12
|
## 1.1.2
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
|
6
15
|
|
|
7
|
-
- [#231](https://github.com/
|
|
16
|
+
- [#231](https://github.com/workleap/wl-squide/pull/231) [`3c6bce0`](https://github.com/workleap/wl-squide/commit/3c6bce0cd559d0b8517d644661b6fb2b818ab2f6) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Packages now includes source code and sourcemap.
|
|
8
17
|
|
|
9
|
-
- Updated dependencies [[`3c6bce0`](https://github.com/
|
|
18
|
+
- Updated dependencies [[`3c6bce0`](https://github.com/workleap/wl-squide/commit/3c6bce0cd559d0b8517d644661b6fb2b818ab2f6)]:
|
|
10
19
|
- @squide/core@5.4.2
|
|
11
20
|
|
|
12
21
|
## 1.1.1
|
|
13
22
|
|
|
14
23
|
### Patch Changes
|
|
15
24
|
|
|
16
|
-
- [#221](https://github.com/
|
|
25
|
+
- [#221](https://github.com/workleap/wl-squide/pull/221) [`8411080`](https://github.com/workleap/wl-squide/commit/8411080dfd0df6d0eafb01888298154fa5e5d925) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Fix deferred registrations.
|
|
17
26
|
|
|
18
|
-
- Updated dependencies [[`8411080`](https://github.com/
|
|
27
|
+
- Updated dependencies [[`8411080`](https://github.com/workleap/wl-squide/commit/8411080dfd0df6d0eafb01888298154fa5e5d925)]:
|
|
19
28
|
- @squide/core@5.4.1
|
|
20
29
|
|
|
21
30
|
## 1.1.0
|
|
22
31
|
|
|
23
32
|
### Minor Changes
|
|
24
33
|
|
|
25
|
-
- [#219](https://github.com/
|
|
34
|
+
- [#219](https://github.com/workleap/wl-squide/pull/219) [`25cb482`](https://github.com/workleap/wl-squide/commit/25cb482779ee280f3f7109de4607b92dcfeef7f3) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Now dispatching events to enable instrumentation packages for observability platforms.
|
|
26
35
|
|
|
27
36
|
### Patch Changes
|
|
28
37
|
|
|
29
|
-
- Updated dependencies [[`25cb482`](https://github.com/
|
|
38
|
+
- Updated dependencies [[`25cb482`](https://github.com/workleap/wl-squide/commit/25cb482779ee280f3f7109de4607b92dcfeef7f3)]:
|
|
30
39
|
- @squide/core@5.4.0
|
|
31
40
|
|
|
32
41
|
## 1.0.0
|
|
33
42
|
|
|
34
43
|
### Major Changes
|
|
35
44
|
|
|
36
|
-
- [#208](https://github.com/
|
|
45
|
+
- [#208](https://github.com/workleap/wl-squide/pull/208) [`a41b2bc`](https://github.com/workleap/wl-squide/commit/a41b2bc519bcfd197272943e726921d9ca8d6611) Thanks [@patricklafrance](https://github.com/patricklafrance)! - First release of the new `EnvironmentVariablesPlugin`. For additional information read the [guide](https://workleap.github.io/wl-squide/guides/use-environment-variables/).
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Usage
|
|
4
4
|
|
|
5
|
-
View the [user's documentation](https://
|
|
5
|
+
View the [user's documentation](https://workleap.github.io/wl-squide/).
|
|
6
6
|
|
|
7
7
|
## 🤝 Contributing
|
|
8
8
|
|
|
@@ -10,4 +10,4 @@ View the [contributor's documentation](../../CONTRIBUTING.md).
|
|
|
10
10
|
|
|
11
11
|
## License
|
|
12
12
|
|
|
13
|
-
Copyright © 2024, Workleap. This code is licensed under the Apache License, Version 2.0. You may obtain a copy of this license at https://github.com/
|
|
13
|
+
Copyright © 2024, Workleap. This code is licensed under the Apache License, Version 2.0. You may obtain a copy of this license at https://github.com/workleap/workleap-license/blob/master/LICENSE.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE__squide_core_7a405b8f__ from "@squide/core";
|
|
2
2
|
import * as __WEBPACK_EXTERNAL_MODULE__EnvironmentVariablesRegistry_js_a784aed2__ from "./EnvironmentVariablesRegistry.js";
|
|
3
3
|
|
|
4
|
-
;// CONCATENATED MODULE: external "
|
|
4
|
+
;// CONCATENATED MODULE: external "@squide/core"
|
|
5
5
|
|
|
6
6
|
;// CONCATENATED MODULE: external "./EnvironmentVariablesRegistry.js"
|
|
7
7
|
|
|
@@ -9,7 +9,7 @@ import * as __WEBPACK_EXTERNAL_MODULE__EnvironmentVariablesRegistry_js_a784aed2_
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
const EnvironmentVariablesPluginName = "env-vars-plugin";
|
|
12
|
-
class EnvironmentVariablesPlugin extends
|
|
12
|
+
class EnvironmentVariablesPlugin extends __WEBPACK_EXTERNAL_MODULE__squide_core_7a405b8f__.Plugin {
|
|
13
13
|
#environmentVariablesRegistry = new __WEBPACK_EXTERNAL_MODULE__EnvironmentVariablesRegistry_js_a784aed2__.EnvironmentVariablesRegistry();
|
|
14
14
|
constructor(runtime){
|
|
15
15
|
super(EnvironmentVariablesPluginName, runtime);
|
|
@@ -31,7 +31,7 @@ class EnvironmentVariablesPlugin extends __WEBPACK_EXTERNAL_MODULE__core_src_ind
|
|
|
31
31
|
}
|
|
32
32
|
function getEnvironmentVariablesPlugin(runtime) {
|
|
33
33
|
const plugin = runtime.getPlugin(EnvironmentVariablesPluginName);
|
|
34
|
-
if ((0,
|
|
34
|
+
if ((0,__WEBPACK_EXTERNAL_MODULE__squide_core_7a405b8f__.isNil)(plugin)) {
|
|
35
35
|
throw new Error("[squide] The getEnvironmentVariablesPlugin function is called but no EnvironmentVariablesPlugin instance has been registered with the runtime.");
|
|
36
36
|
}
|
|
37
37
|
return plugin;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnvironmentVariablesPlugin.js","sources":["webpack://@squide/env-vars/./src/EnvironmentVariablesPlugin.ts"],"sourcesContent":["import { isNil, Plugin, type Runtime } from \"@squide/core\";\nimport { type EnvironmentVariables, EnvironmentVariablesRegistry, type EnvironmentVariablesRegistryKey, type EnvironmentVariablesRegistryValue } from \"./EnvironmentVariablesRegistry.ts\";\n\nexport const EnvironmentVariablesPluginName = \"env-vars-plugin\";\n\nexport class EnvironmentVariablesPlugin extends Plugin {\n readonly #environmentVariablesRegistry = new EnvironmentVariablesRegistry();\n\n constructor(runtime: Runtime) {\n super(EnvironmentVariablesPluginName, runtime);\n }\n\n registerVariable(key: EnvironmentVariablesRegistryKey, value: EnvironmentVariablesRegistryValue) {\n this.#environmentVariablesRegistry.add(key, value);\n\n this._runtime.logger.debug(`[squide] An environment variable for key \"${key}\" has been registered with the value \"${value}\".`);\n }\n\n registerVariables(variables: Partial<EnvironmentVariables>) {\n this.#environmentVariablesRegistry.addVariables(variables);\n\n this._runtime.logger.debug(\"[squide] The following environment variables has been registered:\", variables);\n }\n\n getVariable(key: EnvironmentVariablesRegistryKey) {\n return this.#environmentVariablesRegistry.getVariable(key);\n }\n\n getVariables() {\n return this.#environmentVariablesRegistry.getVariables();\n }\n}\n\nexport function getEnvironmentVariablesPlugin(runtime: Runtime) {\n const plugin = runtime.getPlugin(EnvironmentVariablesPluginName);\n\n if (isNil(plugin)) {\n throw new Error(\"[squide] The getEnvironmentVariablesPlugin function is called but no EnvironmentVariablesPlugin instance has been registered with the runtime.\");\n }\n\n return plugin as EnvironmentVariablesPlugin;\n}\n"],"names":["isNil","Plugin","EnvironmentVariablesRegistry","EnvironmentVariablesPluginName","EnvironmentVariablesPlugin","runtime","key","value","variables","getEnvironmentVariablesPlugin","plugin","Error"],"mappings":";;;;;;;;AAA2D;AAC+H;AAEnL,MAAMG,iCAAiC,kBAAkB;AAEzD,MAAMC,mCAAmCH,
|
|
1
|
+
{"version":3,"file":"EnvironmentVariablesPlugin.js","sources":["webpack://@squide/env-vars/./src/EnvironmentVariablesPlugin.ts"],"sourcesContent":["import { isNil, Plugin, type Runtime } from \"@squide/core\";\nimport { type EnvironmentVariables, EnvironmentVariablesRegistry, type EnvironmentVariablesRegistryKey, type EnvironmentVariablesRegistryValue } from \"./EnvironmentVariablesRegistry.ts\";\n\nexport const EnvironmentVariablesPluginName = \"env-vars-plugin\";\n\nexport class EnvironmentVariablesPlugin extends Plugin {\n readonly #environmentVariablesRegistry = new EnvironmentVariablesRegistry();\n\n constructor(runtime: Runtime) {\n super(EnvironmentVariablesPluginName, runtime);\n }\n\n registerVariable(key: EnvironmentVariablesRegistryKey, value: EnvironmentVariablesRegistryValue) {\n this.#environmentVariablesRegistry.add(key, value);\n\n this._runtime.logger.debug(`[squide] An environment variable for key \"${key}\" has been registered with the value \"${value}\".`);\n }\n\n registerVariables(variables: Partial<EnvironmentVariables>) {\n this.#environmentVariablesRegistry.addVariables(variables);\n\n this._runtime.logger.debug(\"[squide] The following environment variables has been registered:\", variables);\n }\n\n getVariable(key: EnvironmentVariablesRegistryKey) {\n return this.#environmentVariablesRegistry.getVariable(key);\n }\n\n getVariables() {\n return this.#environmentVariablesRegistry.getVariables();\n }\n}\n\nexport function getEnvironmentVariablesPlugin(runtime: Runtime) {\n const plugin = runtime.getPlugin(EnvironmentVariablesPluginName);\n\n if (isNil(plugin)) {\n throw new Error(\"[squide] The getEnvironmentVariablesPlugin function is called but no EnvironmentVariablesPlugin instance has been registered with the runtime.\");\n }\n\n return plugin as EnvironmentVariablesPlugin;\n}\n"],"names":["isNil","Plugin","EnvironmentVariablesRegistry","EnvironmentVariablesPluginName","EnvironmentVariablesPlugin","runtime","key","value","variables","getEnvironmentVariablesPlugin","plugin","Error"],"mappings":";;;;;;;;AAA2D;AAC+H;AAEnL,MAAMG,iCAAiC,kBAAkB;AAEzD,MAAMC,mCAAmCH,wDAAMA;IACzC,6BAA6B,GAAG,IAAIC,kGAA4BA,GAAG;IAE5E,YAAYG,OAAgB,CAAE;QAC1B,KAAK,CAACF,gCAAgCE;IAC1C;IAEA,iBAAiBC,GAAoC,EAAEC,KAAwC,EAAE;QAC7F,IAAI,CAAC,6BAA6B,CAAC,GAAG,CAACD,KAAKC;QAE5C,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,0CAA0C,EAAED,IAAI,sCAAsC,EAAEC,MAAM,EAAE,CAAC;IACjI;IAEA,kBAAkBC,SAAwC,EAAE;QACxD,IAAI,CAAC,6BAA6B,CAAC,YAAY,CAACA;QAEhD,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,qEAAqEA;IACpG;IAEA,YAAYF,GAAoC,EAAE;QAC9C,OAAO,IAAI,CAAC,6BAA6B,CAAC,WAAW,CAACA;IAC1D;IAEA,eAAe;QACX,OAAO,IAAI,CAAC,6BAA6B,CAAC,YAAY;IAC1D;AACJ;AAEO,SAASG,8BAA8BJ,OAAgB;IAC1D,MAAMK,SAASL,QAAQ,SAAS,CAACF;IAEjC,IAAIH,2DAAKA,CAACU,SAAS;QACf,MAAM,IAAIC,MAAM;IACpB;IAEA,OAAOD;AACX"}
|
|
@@ -21,7 +21,7 @@ class EnvironmentVariablesRegistry {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
addVariables(variables) {
|
|
24
|
-
// Do not clear the "getVariables" memoize result
|
|
24
|
+
// Do not clear the "getVariables" memoize result if there are no variables.
|
|
25
25
|
if (Object.keys(variables).length > 0) {
|
|
26
26
|
for (const [key, value] of Object.entries(variables)){
|
|
27
27
|
this.add(key, value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnvironmentVariablesRegistry.js","sources":["webpack://@squide/env-vars/./src/EnvironmentVariablesRegistry.ts"],"sourcesContent":["import memoize, { memoizeClear } from \"memoize\";\n\n// The \"EnvironmentVariables\" interface is expected to be extended by remote modules adding their own environment variables to the runtime.\n// This magic is called module augmentation: https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation.\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface EnvironmentVariables {}\n\nexport type EnvironmentVariablesRegistryKey = keyof EnvironmentVariables;\nexport type EnvironmentVariablesRegistryValue = EnvironmentVariables[keyof EnvironmentVariables];\n\nexport class EnvironmentVariablesRegistry {\n readonly #variables = new Map<EnvironmentVariablesRegistryKey, EnvironmentVariablesRegistryValue>();\n\n // Since the \"getVariables\" function is transforming the variables from a Map to an Object, the result of\n // the transformation is memoized to ensure the returned Object is immutable and can be use in React closures.\n readonly #memoizedGetVariables = memoize(() => Object.fromEntries(this.#variables) as unknown as EnvironmentVariables);\n\n add(key: EnvironmentVariablesRegistryKey, value: EnvironmentVariablesRegistryValue) {\n if (this.#variables.has(key)) {\n const existingValue = this.#variables.get(key);\n\n if (existingValue !== value) {\n throw new Error(`[squide] An environment variable with the key \"${key}\" already exist and the new value differs from the existing one. Existing value: \"${existingValue}\" - New Value: \"${value}\"`);\n }\n } else {\n this.#variables.set(key, value);\n\n memoizeClear(this.#memoizedGetVariables);\n }\n }\n\n addVariables(variables: Partial<EnvironmentVariables>) {\n // Do not clear the \"getVariables\" memoize result
|
|
1
|
+
{"version":3,"file":"EnvironmentVariablesRegistry.js","sources":["webpack://@squide/env-vars/./src/EnvironmentVariablesRegistry.ts"],"sourcesContent":["import memoize, { memoizeClear } from \"memoize\";\n\n// The \"EnvironmentVariables\" interface is expected to be extended by remote modules adding their own environment variables to the runtime.\n// This magic is called module augmentation: https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation.\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface EnvironmentVariables {}\n\nexport type EnvironmentVariablesRegistryKey = keyof EnvironmentVariables;\nexport type EnvironmentVariablesRegistryValue = EnvironmentVariables[keyof EnvironmentVariables];\n\nexport class EnvironmentVariablesRegistry {\n readonly #variables = new Map<EnvironmentVariablesRegistryKey, EnvironmentVariablesRegistryValue>();\n\n // Since the \"getVariables\" function is transforming the variables from a Map to an Object, the result of\n // the transformation is memoized to ensure the returned Object is immutable and can be use in React closures.\n readonly #memoizedGetVariables = memoize(() => Object.fromEntries(this.#variables) as unknown as EnvironmentVariables);\n\n add(key: EnvironmentVariablesRegistryKey, value: EnvironmentVariablesRegistryValue) {\n if (this.#variables.has(key)) {\n const existingValue = this.#variables.get(key);\n\n if (existingValue !== value) {\n throw new Error(`[squide] An environment variable with the key \"${key}\" already exist and the new value differs from the existing one. Existing value: \"${existingValue}\" - New Value: \"${value}\"`);\n }\n } else {\n this.#variables.set(key, value);\n\n memoizeClear(this.#memoizedGetVariables);\n }\n }\n\n addVariables(variables: Partial<EnvironmentVariables>) {\n // Do not clear the \"getVariables\" memoize result if there are no variables.\n if (Object.keys(variables).length > 0) {\n for (const [key, value] of Object.entries(variables)) {\n this.add(key as EnvironmentVariablesRegistryKey, value as EnvironmentVariablesRegistryValue);\n }\n\n memoizeClear(this.#memoizedGetVariables);\n }\n }\n\n getVariable(key: EnvironmentVariablesRegistryKey) {\n const value = this.#variables.get(key);\n\n if (!value) {\n throw new Error(`[squide] No environment variable has been registered for the key \"${key}\".`);\n }\n\n return value;\n }\n\n getVariables() {\n return this.#memoizedGetVariables();\n }\n}\n"],"names":["memoize","memoizeClear","EnvironmentVariablesRegistry","Map","Object","key","value","existingValue","Error","variables"],"mappings":";;;;;AAAgD;AAUzC,MAAME;IACA,UAAU,GAAG,IAAIC,MAA0E;IAEpG,yGAAyG;IACzG,8GAA8G;IACrG,qBAAqB,GAAGH,kDAAOA,CAAC,IAAMI,OAAO,WAAW,CAAC,IAAI,CAAC,UAAU,GAAsC;IAEvH,IAAIC,GAAoC,EAAEC,KAAwC,EAAE;QAChF,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAACD,MAAM;YAC1B,MAAME,gBAAgB,IAAI,CAAC,UAAU,CAAC,GAAG,CAACF;YAE1C,IAAIE,kBAAkBD,OAAO;gBACzB,MAAM,IAAIE,MAAM,CAAC,+CAA+C,EAAEH,IAAI,kFAAkF,EAAEE,cAAc,gBAAgB,EAAED,MAAM,CAAC,CAAC;YACtM;QACJ,OAAO;YACH,IAAI,CAAC,UAAU,CAAC,GAAG,CAACD,KAAKC;YAEzBL,oDAAYA,CAAC,IAAI,CAAC,qBAAqB;QAC3C;IACJ;IAEA,aAAaQ,SAAwC,EAAE;QACnD,4EAA4E;QAC5E,IAAIL,OAAO,IAAI,CAACK,WAAW,MAAM,GAAG,GAAG;YACnC,KAAK,MAAM,CAACJ,KAAKC,MAAM,IAAIF,OAAO,OAAO,CAACK,WAAY;gBAClD,IAAI,CAAC,GAAG,CAACJ,KAAwCC;YACrD;YAEAL,oDAAYA,CAAC,IAAI,CAAC,qBAAqB;QAC3C;IACJ;IAEA,YAAYI,GAAoC,EAAE;QAC9C,MAAMC,QAAQ,IAAI,CAAC,UAAU,CAAC,GAAG,CAACD;QAElC,IAAI,CAACC,OAAO;YACR,MAAM,IAAIE,MAAM,CAAC,kEAAkE,EAAEH,IAAI,EAAE,CAAC;QAChG;QAEA,OAAOC;IACX;IAEA,eAAe;QACX,OAAO,IAAI,CAAC,qBAAqB;IACrC;AACJ"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE__squide_core_7a405b8f__ from "@squide/core";
|
|
2
2
|
import * as __WEBPACK_EXTERNAL_MODULE__EnvironmentVariablesPlugin_js_3420fecf__ from "./EnvironmentVariablesPlugin.js";
|
|
3
3
|
|
|
4
|
-
;// CONCATENATED MODULE: external "
|
|
4
|
+
;// CONCATENATED MODULE: external "@squide/core"
|
|
5
5
|
|
|
6
6
|
;// CONCATENATED MODULE: external "./EnvironmentVariablesPlugin.js"
|
|
7
7
|
|
|
@@ -9,12 +9,12 @@ import * as __WEBPACK_EXTERNAL_MODULE__EnvironmentVariablesPlugin_js_3420fecf__
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
function useEnvironmentVariable(key) {
|
|
12
|
-
const runtime = (0,
|
|
12
|
+
const runtime = (0,__WEBPACK_EXTERNAL_MODULE__squide_core_7a405b8f__.useRuntime)();
|
|
13
13
|
const plugin = (0,__WEBPACK_EXTERNAL_MODULE__EnvironmentVariablesPlugin_js_3420fecf__.getEnvironmentVariablesPlugin)(runtime);
|
|
14
14
|
return plugin.getVariable(key);
|
|
15
15
|
}
|
|
16
16
|
function useEnvironmentVariables() {
|
|
17
|
-
const runtime = (0,
|
|
17
|
+
const runtime = (0,__WEBPACK_EXTERNAL_MODULE__squide_core_7a405b8f__.useRuntime)();
|
|
18
18
|
const plugin = (0,__WEBPACK_EXTERNAL_MODULE__EnvironmentVariablesPlugin_js_3420fecf__.getEnvironmentVariablesPlugin)(runtime);
|
|
19
19
|
return plugin.getVariables();
|
|
20
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEnvironmentVariable.js","sources":["webpack://@squide/env-vars/./src/useEnvironmentVariable.ts"],"sourcesContent":["import { useRuntime } from \"@squide/core\";\nimport { getEnvironmentVariablesPlugin } from \"./EnvironmentVariablesPlugin.ts\";\nimport type { EnvironmentVariablesRegistryKey } from \"./EnvironmentVariablesRegistry.ts\";\n\nexport function useEnvironmentVariable(key: EnvironmentVariablesRegistryKey) {\n const runtime = useRuntime();\n const plugin = getEnvironmentVariablesPlugin(runtime);\n\n return plugin.getVariable(key);\n}\n\nexport function useEnvironmentVariables() {\n const runtime = useRuntime();\n const plugin = getEnvironmentVariablesPlugin(runtime);\n\n return plugin.getVariables();\n}\n"],"names":["useRuntime","getEnvironmentVariablesPlugin","useEnvironmentVariable","key","runtime","plugin","useEnvironmentVariables"],"mappings":";;;;;;;;AAA0C;AACsC;AAGzE,SAASE,uBAAuBC,GAAoC;IACvE,MAAMC,UAAUJ,
|
|
1
|
+
{"version":3,"file":"useEnvironmentVariable.js","sources":["webpack://@squide/env-vars/./src/useEnvironmentVariable.ts"],"sourcesContent":["import { useRuntime } from \"@squide/core\";\nimport { getEnvironmentVariablesPlugin } from \"./EnvironmentVariablesPlugin.ts\";\nimport type { EnvironmentVariablesRegistryKey } from \"./EnvironmentVariablesRegistry.ts\";\n\nexport function useEnvironmentVariable(key: EnvironmentVariablesRegistryKey) {\n const runtime = useRuntime();\n const plugin = getEnvironmentVariablesPlugin(runtime);\n\n return plugin.getVariable(key);\n}\n\nexport function useEnvironmentVariables() {\n const runtime = useRuntime();\n const plugin = getEnvironmentVariablesPlugin(runtime);\n\n return plugin.getVariables();\n}\n"],"names":["useRuntime","getEnvironmentVariablesPlugin","useEnvironmentVariable","key","runtime","plugin","useEnvironmentVariables"],"mappings":";;;;;;;;AAA0C;AACsC;AAGzE,SAASE,uBAAuBC,GAAoC;IACvE,MAAMC,UAAUJ,gEAAUA;IAC1B,MAAMK,SAASJ,qGAA6BA,CAACG;IAE7C,OAAOC,OAAO,WAAW,CAACF;AAC9B;AAEO,SAASG;IACZ,MAAMF,UAAUJ,gEAAUA;IAC1B,MAAMK,SAASJ,qGAA6BA,CAACG;IAE7C,OAAOC,OAAO,YAAY;AAC9B"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@squide/env-vars",
|
|
3
3
|
"author": "Workleap",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.3",
|
|
5
5
|
"description": "Add support for environment variables to @squide application shell.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/
|
|
9
|
+
"url": "git+https://github.com/workleap/wl-squide.git",
|
|
10
10
|
"directory": "packages/env-vars"
|
|
11
11
|
},
|
|
12
12
|
"type": "module",
|
|
@@ -31,27 +31,23 @@
|
|
|
31
31
|
"react": "*"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@types/react": "19.0.
|
|
35
|
-
"memoize": "10.
|
|
36
|
-
"@squide/core": "5.4.
|
|
34
|
+
"@types/react": "19.0.10",
|
|
35
|
+
"memoize": "10.1.0",
|
|
36
|
+
"@squide/core": "5.4.3"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@rsbuild/core": "1.
|
|
40
|
-
"@rslib/core": "0.
|
|
41
|
-
"@
|
|
42
|
-
"@
|
|
43
|
-
"@
|
|
44
|
-
"@typescript-eslint/parser": "8.20.0",
|
|
45
|
-
"@workleap/eslint-plugin": "3.2.6",
|
|
39
|
+
"@rsbuild/core": "1.2.19",
|
|
40
|
+
"@rslib/core": "0.5.4",
|
|
41
|
+
"@typescript-eslint/parser": "8.26.1",
|
|
42
|
+
"@vitejs/plugin-react": "4.3.4",
|
|
43
|
+
"@workleap/eslint-plugin": "3.3.0",
|
|
46
44
|
"@workleap/rslib-configs": "1.0.2",
|
|
47
|
-
"@workleap/swc-configs": "2.2.4",
|
|
48
45
|
"@workleap/typescript-configs": "3.0.2",
|
|
49
46
|
"eslint": "8.57.0",
|
|
50
|
-
"
|
|
51
|
-
"jest-environment-jsdom": "29.7.0",
|
|
47
|
+
"happy-dom": "17.4.4",
|
|
52
48
|
"react": "19.0.0",
|
|
53
|
-
"
|
|
54
|
-
"
|
|
49
|
+
"typescript": "5.8.2",
|
|
50
|
+
"vitest": "3.0.8"
|
|
55
51
|
},
|
|
56
52
|
"sideEffects": false,
|
|
57
53
|
"engines": {
|
|
@@ -61,6 +57,6 @@
|
|
|
61
57
|
"build": "rslib build --config ./rslib.build.ts",
|
|
62
58
|
"eslint": "eslint . --max-warnings=-0 --cache --cache-location node_modules/.cache/eslint",
|
|
63
59
|
"typecheck": "tsc",
|
|
64
|
-
"test": "
|
|
60
|
+
"test": "vitest --config vitest.config.ts --no-watch"
|
|
65
61
|
}
|
|
66
62
|
}
|
|
@@ -30,7 +30,7 @@ export class EnvironmentVariablesRegistry {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
addVariables(variables: Partial<EnvironmentVariables>) {
|
|
33
|
-
// Do not clear the "getVariables" memoize result
|
|
33
|
+
// Do not clear the "getVariables" memoize result if there are no variables.
|
|
34
34
|
if (Object.keys(variables).length > 0) {
|
|
35
35
|
for (const [key, value] of Object.entries(variables)) {
|
|
36
36
|
this.add(key as EnvironmentVariablesRegistryKey, value as EnvironmentVariablesRegistryValue);
|