@squide/env-vars 1.4.5 → 1.4.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/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @squide/env-vars
2
2
 
3
+ ## 1.4.7
4
+
5
+ ### Patch Changes
6
+
7
+ - [#339](https://github.com/workleap/wl-squide/pull/339) [`de6b333`](https://github.com/workleap/wl-squide/commit/de6b3335f538252bac9545d82c8f1218612eb923) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Bumped packages version.
8
+
9
+ - Updated dependencies [[`de6b333`](https://github.com/workleap/wl-squide/commit/de6b3335f538252bac9545d82c8f1218612eb923)]:
10
+ - @squide/core@6.1.4
11
+
12
+ ## 1.4.6
13
+
14
+ ### Patch Changes
15
+
16
+ - [#337](https://github.com/workleap/wl-squide/pull/337) [`04600f0`](https://github.com/workleap/wl-squide/commit/04600f08ba724291bfb8102ebdd2d977d8a69f45) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Environment variables can now be provided from the plugin constructor.
17
+
3
18
  ## 1.4.5
4
19
 
5
20
  ### Patch Changes
@@ -1,9 +1,12 @@
1
1
  import { Plugin, type Runtime } from "@squide/core";
2
2
  import { type EnvironmentVariables, type EnvironmentVariablesRegistryKey, type EnvironmentVariablesRegistryValue } from "./EnvironmentVariablesRegistry.ts";
3
3
  export declare const EnvironmentVariablesPluginName = "env-vars-plugin";
4
+ export interface EnvironmentVariablesPluginOptions {
5
+ environmentVariables?: Partial<EnvironmentVariables>;
6
+ }
4
7
  export declare class EnvironmentVariablesPlugin extends Plugin {
5
8
  #private;
6
- constructor(runtime: Runtime);
9
+ constructor(runtime: Runtime, options?: EnvironmentVariablesPluginOptions);
7
10
  registerVariable(key: EnvironmentVariablesRegistryKey, value: EnvironmentVariablesRegistryValue): void;
8
11
  registerVariables(variables: Partial<EnvironmentVariables>): void;
9
12
  getVariable(key: EnvironmentVariablesRegistryKey): never;
@@ -11,8 +11,12 @@ import { EnvironmentVariablesRegistry } from "./EnvironmentVariablesRegistry.js"
11
11
  const EnvironmentVariablesPluginName = "env-vars-plugin";
12
12
  class EnvironmentVariablesPlugin extends Plugin {
13
13
  #environmentVariablesRegistry = new EnvironmentVariablesRegistry();
14
- constructor(runtime){
14
+ constructor(runtime, options = {}){
15
15
  super(EnvironmentVariablesPluginName, runtime);
16
+ const { environmentVariables } = options;
17
+ if (environmentVariables) {
18
+ this.#environmentVariablesRegistry.addVariables(environmentVariables);
19
+ }
16
20
  }
17
21
  registerVariable(key, value) {
18
22
  this.#environmentVariablesRegistry.add(key, value);
@@ -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\n .withText(\"[squide] The following environment variables has been registered:\")\n .withObject(variables)\n .debug();\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,MAAMA;IACzC,6BAA6B,GAAG,IAAIC,4BAA4BA,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,CACf,QAAQ,CAAC,qEACT,UAAU,CAACA,WACX,KAAK;IACd;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,KAAKA,CAACU,SAAS;QACf,MAAM,IAAIC,MAAM;IACpB;IAEA,OAAOD;AACX"}
1
+ {"version":3,"file":"EnvironmentVariablesPlugin.js","sources":["../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 interface EnvironmentVariablesPluginOptions {\n environmentVariables?: Partial<EnvironmentVariables>;\n}\n\nexport class EnvironmentVariablesPlugin extends Plugin {\n readonly #environmentVariablesRegistry = new EnvironmentVariablesRegistry();\n\n constructor(runtime: Runtime, options: EnvironmentVariablesPluginOptions = {}) {\n super(EnvironmentVariablesPluginName, runtime);\n\n const {\n environmentVariables\n } = options;\n\n if (environmentVariables) {\n this.#environmentVariablesRegistry.addVariables(environmentVariables);\n }\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\n .withText(\"[squide] The following environment variables has been registered:\")\n .withObject(variables)\n .debug();\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","options","environmentVariables","key","value","variables","getEnvironmentVariablesPlugin","plugin","Error"],"mappings":";;;;;;;;AAA2D;AAC+H;AAEnL,MAAMG,iCAAiC,kBAAkB;AAMzD,MAAMC,mCAAmCH,MAAMA;IACzC,6BAA6B,GAAG,IAAIC,4BAA4BA,GAAG;IAE5E,YAAYG,OAAgB,EAAEC,UAA6C,CAAC,CAAC,CAAE;QAC3E,KAAK,CAACH,gCAAgCE;QAEtC,MAAM,EACFE,oBAAoB,EACvB,GAAGD;QAEJ,IAAIC,sBAAsB;YACtB,IAAI,CAAC,6BAA6B,CAAC,YAAY,CAACA;QACpD;IACJ;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,CACf,QAAQ,CAAC,qEACT,UAAU,CAACA,WACX,KAAK;IACd;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,8BAA8BN,OAAgB;IAC1D,MAAMO,SAASP,QAAQ,SAAS,CAACF;IAEjC,IAAIH,KAAKA,CAACY,SAAS;QACf,MAAM,IAAIC,MAAM;IACpB;IAEA,OAAOD;AACX"}
@@ -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 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,OAAOA,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,YAAYA,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,YAAYA,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
+ {"version":3,"file":"EnvironmentVariablesRegistry.js","sources":["../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,OAAOA,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,YAAYA,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,YAAYA,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"}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["webpack://@squide/env-vars/./src/index.ts"],"sourcesContent":["export * from \"./EnvironmentVariablesPlugin.ts\";\nexport type { EnvironmentVariables, EnvironmentVariablesRegistryKey, EnvironmentVariablesRegistryValue } from \"./EnvironmentVariablesRegistry.ts\";\nexport * from \"./useEnvironmentVariable.ts\";\n\n"],"names":[],"mappings":";;;;AAAgD;AAEJ"}
1
+ {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["export * from \"./EnvironmentVariablesPlugin.ts\";\nexport type { EnvironmentVariables, EnvironmentVariablesRegistryKey, EnvironmentVariablesRegistryValue } from \"./EnvironmentVariablesRegistry.ts\";\nexport * from \"./useEnvironmentVariable.ts\";\n\n"],"names":[],"mappings":";;;;AAAgD;AAEJ"}
@@ -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,UAAUA;IAC1B,MAAMK,SAASJ,6BAA6BA,CAACG;IAE7C,OAAOC,OAAO,WAAW,CAACF;AAC9B;AAEO,SAASG;IACZ,MAAMF,UAAUJ,UAAUA;IAC1B,MAAMK,SAASJ,6BAA6BA,CAACG;IAE7C,OAAOC,OAAO,YAAY;AAC9B"}
1
+ {"version":3,"file":"useEnvironmentVariable.js","sources":["../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,UAAUA;IAC1B,MAAMK,SAASJ,6BAA6BA,CAACG;IAE7C,OAAOC,OAAO,WAAW,CAACF;AAC9B;AAEO,SAASG;IACZ,MAAMF,UAAUJ,UAAUA;IAC1B,MAAMK,SAASJ,6BAA6BA,CAACG;IAE7C,OAAOC,OAAO,YAAY;AAC9B"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@squide/env-vars",
3
3
  "author": "Workleap",
4
- "version": "1.4.5",
4
+ "version": "1.4.7",
5
5
  "description": "Add support for environment variables to @squide application shell.",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -30,29 +30,30 @@
30
30
  "react": "^18.0.0 || ^19.0.0"
31
31
  },
32
32
  "dependencies": {
33
- "memoize": "^10.1.0",
34
- "@squide/core": "6.1.3"
33
+ "@workleap/logging": "^1.3.2",
34
+ "memoize": "^10.2.0",
35
+ "@squide/core": "6.1.4"
35
36
  },
36
37
  "devDependencies": {
37
- "@eslint/js": "9.38.0",
38
- "@rsbuild/core": "1.5.17",
39
- "@rslib/core": "0.16.1",
40
- "@types/react": "19.2.2",
41
- "@typescript-eslint/parser": "8.46.2",
42
- "@vitejs/plugin-react": "5.0.4",
43
- "@workleap/eslint-configs": "0.0.5",
38
+ "@eslint/js": "9.39.1",
39
+ "@rsbuild/core": "1.6.7",
40
+ "@rslib/core": "0.18.0",
41
+ "@types/react": "19.2.6",
42
+ "@typescript-eslint/parser": "8.47.0",
43
+ "@vitejs/plugin-react": "5.1.1",
44
+ "@workleap/eslint-configs": "1.1.5",
44
45
  "@workleap/rslib-configs": "1.1.3",
45
46
  "@workleap/typescript-configs": "3.0.7",
46
- "eslint": "9.38.0",
47
- "happy-dom": "20.0.8",
47
+ "eslint": "9.39.1",
48
+ "happy-dom": "20.0.10",
48
49
  "typescript": "5.9.3",
49
- "typescript-eslint": "8.46.2",
50
- "vitest": "4.0.2"
50
+ "typescript-eslint": "8.47.0",
51
+ "vitest": "4.0.10"
51
52
  },
52
53
  "sideEffects": false,
53
54
  "scripts": {
54
55
  "build": "rslib build --config ./rslib.build.ts",
55
- "eslint": "eslint . --max-warnings=-0 --cache --cache-location node_modules/.cache/eslint",
56
+ "eslint": "eslint . --max-warnings=0 --cache --cache-location node_modules/.cache/eslint",
56
57
  "typecheck": "tsc",
57
58
  "test": "vitest --config vitest.config.ts --no-watch"
58
59
  }
@@ -3,11 +3,23 @@ import { type EnvironmentVariables, EnvironmentVariablesRegistry, type Environme
3
3
 
4
4
  export const EnvironmentVariablesPluginName = "env-vars-plugin";
5
5
 
6
+ export interface EnvironmentVariablesPluginOptions {
7
+ environmentVariables?: Partial<EnvironmentVariables>;
8
+ }
9
+
6
10
  export class EnvironmentVariablesPlugin extends Plugin {
7
11
  readonly #environmentVariablesRegistry = new EnvironmentVariablesRegistry();
8
12
 
9
- constructor(runtime: Runtime) {
13
+ constructor(runtime: Runtime, options: EnvironmentVariablesPluginOptions = {}) {
10
14
  super(EnvironmentVariablesPluginName, runtime);
15
+
16
+ const {
17
+ environmentVariables
18
+ } = options;
19
+
20
+ if (environmentVariables) {
21
+ this.#environmentVariablesRegistry.addVariables(environmentVariables);
22
+ }
11
23
  }
12
24
 
13
25
  registerVariable(key: EnvironmentVariablesRegistryKey, value: EnvironmentVariablesRegistryValue) {