silgi 0.9.27 → 0.9.28

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.
@@ -1,4 +1,4 @@
1
- const version = "0.9.27";
1
+ const version = "0.9.28";
2
2
  const peerDependencies = {
3
3
  "@fastify/deepmerge": "^2.0.2",
4
4
  "@nuxt/kit": "^3.15.3",
@@ -2,7 +2,7 @@ import { Buffer } from 'node:buffer';
2
2
  import * as consola from 'consola';
3
3
  import { ConsolaOptions } from 'consola';
4
4
  import * as silgi_types from 'silgi/types';
5
- import { ModuleOptionsCustom, ModuleDefinition, SilgiModule, SilgiCLI, SilgiPreset, SilgiPresetMeta, EnvOptions, SilgiTemplate, ResolvedSilgiTemplate } from 'silgi/types';
5
+ import { ModuleOptionsCustom, ModuleDefinition, SilgiModule, SilgiCLI, SilgiPreset, SilgiPresetMeta, EnvOptions, SilgiEvents, SilgiTemplate, ResolvedSilgiTemplate } from 'silgi/types';
6
6
 
7
7
  /**
8
8
  * Resolve a module from a given root path using an algorithm patterned on
@@ -83,7 +83,7 @@ declare function resolveSilgiModule(base: string, paths: string[]): Promise<stri
83
83
  *
84
84
  * This mirrors the runtime behavior of Nitro.
85
85
  */
86
- declare function useSilgiRuntimeConfig(): silgi_types.SilgiRuntimeOptions;
86
+ declare function useSilgiRuntimeConfig(event?: SilgiEvents): silgi_types.SilgiRuntimeOptions | undefined;
87
87
  declare function applyEnv(obj: Record<string, any>, opts: EnvOptions, parentKey?: string): Record<string, any>;
88
88
 
89
89
  /**
@@ -2,7 +2,7 @@ import { Buffer } from 'node:buffer';
2
2
  import * as consola from 'consola';
3
3
  import { ConsolaOptions } from 'consola';
4
4
  import * as silgi_types from 'silgi/types';
5
- import { ModuleOptionsCustom, ModuleDefinition, SilgiModule, SilgiCLI, SilgiPreset, SilgiPresetMeta, EnvOptions, SilgiTemplate, ResolvedSilgiTemplate } from 'silgi/types';
5
+ import { ModuleOptionsCustom, ModuleDefinition, SilgiModule, SilgiCLI, SilgiPreset, SilgiPresetMeta, EnvOptions, SilgiEvents, SilgiTemplate, ResolvedSilgiTemplate } from 'silgi/types';
6
6
 
7
7
  /**
8
8
  * Resolve a module from a given root path using an algorithm patterned on
@@ -83,7 +83,7 @@ declare function resolveSilgiModule(base: string, paths: string[]): Promise<stri
83
83
  *
84
84
  * This mirrors the runtime behavior of Nitro.
85
85
  */
86
- declare function useSilgiRuntimeConfig(): silgi_types.SilgiRuntimeOptions;
86
+ declare function useSilgiRuntimeConfig(event?: SilgiEvents): silgi_types.SilgiRuntimeOptions | undefined;
87
87
  declare function applyEnv(obj: Record<string, any>, opts: EnvOptions, parentKey?: string): Record<string, any>;
88
88
 
89
89
  /**
@@ -256,10 +256,26 @@ async function resolveSilgiModule(base, paths) {
256
256
  return resolved;
257
257
  }
258
258
 
259
- function useSilgiRuntimeConfig() {
259
+ const _inlineRuntimeConfig = process$1.env.RUNTIME_CONFIG;
260
+ const envOptions = {
261
+ prefix: "NITRO_",
262
+ altPrefix: _inlineRuntimeConfig?.nitro.envPrefix ?? process$1.env.NITRO_ENV_PREFIX ?? "_",
263
+ envExpansion: _inlineRuntimeConfig?.nitro.envExpansion ?? process$1.env.NITRO_ENV_EXPANSION ?? false
264
+ };
265
+ const _sharedRuntimeConfig = _deepFreeze(
266
+ applyEnv(klona(_inlineRuntimeConfig ?? {}), envOptions)
267
+ );
268
+ function useSilgiRuntimeConfig(event) {
260
269
  const silgi = tryUseSilgi();
261
270
  if (!silgi) {
262
- return globalThis.$silgiSharedRuntimeConfig;
271
+ const data = globalThis.$silgiSharedRuntimeConfig;
272
+ if (data) {
273
+ return data;
274
+ }
275
+ if (!event) {
276
+ return _sharedRuntimeConfig;
277
+ }
278
+ return;
263
279
  }
264
280
  return applyEnv(klona(silgi.runtimeConfig), {
265
281
  prefix: "NITRO_",
@@ -306,6 +322,16 @@ function _expandFromEnv(value, env = process$1.env) {
306
322
  return env[key] || match;
307
323
  });
308
324
  }
325
+ function _deepFreeze(object) {
326
+ const propNames = Object.getOwnPropertyNames(object);
327
+ for (const name of propNames) {
328
+ const value = object[name];
329
+ if (value && typeof value === "object") {
330
+ _deepFreeze(value);
331
+ }
332
+ }
333
+ return Object.freeze(object);
334
+ }
309
335
 
310
336
  const RELATIVE_RE = /^([^.])/;
311
337
  function relativeWithDot(from, to) {
@@ -1,4 +1,4 @@
1
- const version = "0.9.27";
1
+ const version = "0.9.28";
2
2
  const peerDependencies = {
3
3
  "@fastify/deepmerge": "^2.0.2",
4
4
  "@nuxt/kit": "^3.15.3",
@@ -1,4 +1,4 @@
1
- const version = "0.9.27";
1
+ const version = "0.9.28";
2
2
  const peerDependencies = {
3
3
  "@fastify/deepmerge": "^2.0.2",
4
4
  "@nuxt/kit": "^3.15.3",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "silgi",
3
3
  "type": "module",
4
- "version": "0.9.27",
4
+ "version": "0.9.28",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "exports": {