silgi 0.9.27 → 0.9.29

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.29";
2
2
  const peerDependencies = {
3
3
  "@fastify/deepmerge": "^2.0.2",
4
4
  "@nuxt/kit": "^3.15.3",
@@ -1,8 +1,7 @@
1
1
  import { Buffer } from 'node:buffer';
2
2
  import * as consola from 'consola';
3
3
  import { ConsolaOptions } from 'consola';
4
- import * as silgi_types from 'silgi/types';
5
- import { ModuleOptionsCustom, ModuleDefinition, SilgiModule, SilgiCLI, SilgiPreset, SilgiPresetMeta, EnvOptions, SilgiTemplate, ResolvedSilgiTemplate } from 'silgi/types';
4
+ import { ModuleOptionsCustom, ModuleDefinition, SilgiModule, SilgiCLI, SilgiPreset, SilgiPresetMeta, EnvOptions, SilgiEvents, SilgiTemplate, ResolvedSilgiTemplate } from 'silgi/types';
6
5
 
7
6
  /**
8
7
  * Resolve a module from a given root path using an algorithm patterned on
@@ -83,7 +82,7 @@ declare function resolveSilgiModule(base: string, paths: string[]): Promise<stri
83
82
  *
84
83
  * This mirrors the runtime behavior of Nitro.
85
84
  */
86
- declare function useSilgiRuntimeConfig(): silgi_types.SilgiRuntimeOptions;
85
+ declare function useSilgiRuntimeConfig(event?: SilgiEvents): any;
87
86
  declare function applyEnv(obj: Record<string, any>, opts: EnvOptions, parentKey?: string): Record<string, any>;
88
87
 
89
88
  /**
@@ -1,8 +1,7 @@
1
1
  import { Buffer } from 'node:buffer';
2
2
  import * as consola from 'consola';
3
3
  import { ConsolaOptions } from 'consola';
4
- import * as silgi_types from 'silgi/types';
5
- import { ModuleOptionsCustom, ModuleDefinition, SilgiModule, SilgiCLI, SilgiPreset, SilgiPresetMeta, EnvOptions, SilgiTemplate, ResolvedSilgiTemplate } from 'silgi/types';
4
+ import { ModuleOptionsCustom, ModuleDefinition, SilgiModule, SilgiCLI, SilgiPreset, SilgiPresetMeta, EnvOptions, SilgiEvents, SilgiTemplate, ResolvedSilgiTemplate } from 'silgi/types';
6
5
 
7
6
  /**
8
7
  * Resolve a module from a given root path using an algorithm patterned on
@@ -83,7 +82,7 @@ declare function resolveSilgiModule(base: string, paths: string[]): Promise<stri
83
82
  *
84
83
  * This mirrors the runtime behavior of Nitro.
85
84
  */
86
- declare function useSilgiRuntimeConfig(): silgi_types.SilgiRuntimeOptions;
85
+ declare function useSilgiRuntimeConfig(event?: SilgiEvents): any;
87
86
  declare function applyEnv(obj: Record<string, any>, opts: EnvOptions, parentKey?: string): Record<string, any>;
88
87
 
89
88
  /**
@@ -256,10 +256,28 @@ 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
+ const runtimeConfig = klona(_inlineRuntimeConfig);
279
+ applyEnv(runtimeConfig, envOptions);
280
+ return runtimeConfig;
263
281
  }
264
282
  return applyEnv(klona(silgi.runtimeConfig), {
265
283
  prefix: "NITRO_",
@@ -306,6 +324,16 @@ function _expandFromEnv(value, env = process$1.env) {
306
324
  return env[key] || match;
307
325
  });
308
326
  }
327
+ function _deepFreeze(object) {
328
+ const propNames = Object.getOwnPropertyNames(object);
329
+ for (const name of propNames) {
330
+ const value = object[name];
331
+ if (value && typeof value === "object") {
332
+ _deepFreeze(value);
333
+ }
334
+ }
335
+ return Object.freeze(object);
336
+ }
309
337
 
310
338
  const RELATIVE_RE = /^([^.])/;
311
339
  function relativeWithDot(from, to) {
@@ -1,4 +1,4 @@
1
- const version = "0.9.27";
1
+ const version = "0.9.29";
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.29";
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.29",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "exports": {