silgi 0.9.29 → 0.9.31

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.29";
1
+ const version = "0.9.31";
2
2
  const peerDependencies = {
3
3
  "@fastify/deepmerge": "^2.0.2",
4
4
  "@nuxt/kit": "^3.15.3",
@@ -147,7 +147,8 @@ async function readCoreFile(silgi) {
147
147
  });
148
148
  try {
149
149
  if (silgi.options.commandType === "prepare") {
150
- injectedResult.code = `global.$silgiSharedRuntimeConfig = ${JSON.stringify(silgi.options.runtimeConfig)};
150
+ globalThis.$silgiSharedRuntimeConfig = silgi.options.runtimeConfig;
151
+ injectedResult.code = `globalThis.$silgiSharedRuntimeConfig = ${JSON.stringify(silgi.options.runtimeConfig)};
151
152
  ${injectedResult.code}`;
152
153
  injectedResult.code = injectedResult.code.replace(/runtimeConfig: \{\}/, `runtimeConfig: ${JSON.stringify(silgi.options.runtimeConfig)}`);
153
154
  }
@@ -661,14 +661,18 @@ async function cacheExecute(input, operation, handler, event) {
661
661
  };
662
662
  }
663
663
 
664
- function merge(items, maxLevel = 4, currentLevel = 3) {
664
+ function merge(items, maxLevel = 4, currentLevel = 1) {
665
665
  const arrayItems = Array.isArray(items) ? items : [items];
666
666
  return arrayItems.reduce((acc, item) => {
667
+ if (!item)
668
+ return acc;
667
669
  Object.keys(item).forEach((key) => {
668
670
  if (typeof item[key] === "object" && item[key] !== null && currentLevel < maxLevel) {
669
- acc[key] = acc[key] || {};
671
+ if (!acc[key] || typeof acc[key] !== "object") {
672
+ acc[key] = {};
673
+ }
670
674
  acc[key] = merge([acc[key], item[key]], maxLevel, currentLevel + 1);
671
- } else {
675
+ } else if (acc[key] === void 0) {
672
676
  acc[key] = item[key];
673
677
  }
674
678
  });
@@ -12,7 +12,6 @@ import { c as checkSilgiCompatibility } from '../cli/compatibility.mjs';
12
12
  import { existsSync, promises } from 'node:fs';
13
13
  import { fileURLToPath } from 'node:url';
14
14
  import { resolveAlias as resolveAlias$1 } from 'pathe/utils';
15
- import process$1 from 'node:process';
16
15
  import destr from 'destr';
17
16
  import { klona } from 'klona';
18
17
  import 'semver/functions/satisfies.js';
@@ -256,11 +255,14 @@ async function resolveSilgiModule(base, paths) {
256
255
  return resolved;
257
256
  }
258
257
 
259
- const _inlineRuntimeConfig = process$1.env.RUNTIME_CONFIG;
258
+ const _inlineRuntimeConfig = (
259
+ /** */
260
+ process.env.RUNTIME_CONFIG
261
+ );
260
262
  const envOptions = {
261
263
  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
+ altPrefix: _inlineRuntimeConfig?.nitro.envPrefix ?? process.env.NITRO_ENV_PREFIX ?? "_",
265
+ envExpansion: _inlineRuntimeConfig?.nitro.envExpansion ?? process.env.NITRO_ENV_EXPANSION ?? false
264
266
  };
265
267
  const _sharedRuntimeConfig = _deepFreeze(
266
268
  applyEnv(klona(_inlineRuntimeConfig ?? {}), envOptions)
@@ -268,9 +270,9 @@ const _sharedRuntimeConfig = _deepFreeze(
268
270
  function useSilgiRuntimeConfig(event) {
269
271
  const silgi = tryUseSilgi();
270
272
  if (!silgi) {
271
- const data = globalThis.$silgiSharedRuntimeConfig;
272
- if (data) {
273
- return data;
273
+ const globalRuntimeConfig = globalThis.$silgiSharedRuntimeConfig;
274
+ if (globalRuntimeConfig && !event) {
275
+ return globalRuntimeConfig;
274
276
  }
275
277
  if (!event) {
276
278
  return _sharedRuntimeConfig;
@@ -283,11 +285,11 @@ function useSilgiRuntimeConfig(event) {
283
285
  prefix: "NITRO_",
284
286
  altPrefix: "NUXT_",
285
287
  silgiPrefix: "SILGI_",
286
- envExpansion: silgi.options.experimental?.envExpansion ?? !!process$1.env.NITRO_ENV_EXPANSION,
288
+ envExpansion: silgi.options.experimental?.envExpansion ?? !!process.env.NITRO_ENV_EXPANSION,
287
289
  ...silgi.envOptions
288
290
  });
289
291
  }
290
- function getEnv(key, opts, env = process$1.env) {
292
+ function getEnv(key, opts, env = process.env) {
291
293
  const envKey = snakeCase(key).toUpperCase();
292
294
  return destr(
293
295
  env[opts.prefix + envKey] ?? env[opts.altPrefix + envKey] ?? env[opts.silgiPrefix + envKey]
@@ -319,7 +321,7 @@ function applyEnv(obj, opts, parentKey = "") {
319
321
  return obj;
320
322
  }
321
323
  const envExpandRx = /\{\{([^{}]*)\}\}/g;
322
- function _expandFromEnv(value, env = process$1.env) {
324
+ function _expandFromEnv(value, env = process.env) {
323
325
  return value.replace(envExpandRx, (match, key) => {
324
326
  return env[key] || match;
325
327
  });
@@ -1,4 +1,4 @@
1
- const version = "0.9.29";
1
+ const version = "0.9.31";
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.29";
1
+ const version = "0.9.31";
2
2
  const peerDependencies = {
3
3
  "@fastify/deepmerge": "^2.0.2",
4
4
  "@nuxt/kit": "^3.15.3",
@@ -1,2 +1,2 @@
1
- declare const _default: readonly [any, any, any, any];
1
+ declare const _default: readonly [any, any, any, any, any];
2
2
  export default _default;
@@ -1,10 +1,12 @@
1
1
  import _h3 from "./h3/preset.mjs";
2
2
  import _nitro from "./nitro/preset.mjs";
3
+ import _npmPackage from "./npmPackage/preset.mjs";
3
4
  import _npmpackage from "./npmpackage/preset.mjs";
4
5
  import _nuxt from "./nuxt/preset.mjs";
5
6
  export default [
6
7
  ..._h3,
7
8
  ..._nitro,
9
+ ..._npmPackage,
8
10
  ..._npmpackage,
9
11
  ..._nuxt
10
12
  ];
@@ -0,0 +1,2 @@
1
+ declare const _default: readonly [any];
2
+ export default _default;
@@ -0,0 +1,20 @@
1
+ import { defineSilgiPreset } from "silgi/kit";
2
+ const npmPackage = defineSilgiPreset(
3
+ {
4
+ output: {
5
+ dir: "{{ rootDir }}/.output",
6
+ publicDir: "{{ output.dir }}/public"
7
+ },
8
+ serverDir: "{{ rootDir }}/src",
9
+ silgi: {
10
+ serverDir: "{{ serverDir }}/silgi"
11
+ },
12
+ modules: ["./src"]
13
+ },
14
+ {
15
+ name: "npm-package",
16
+ compatibilityDate: "2025-02-04",
17
+ url: import.meta.url
18
+ }
19
+ );
20
+ export default [npmPackage];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "silgi",
3
3
  "type": "module",
4
- "version": "0.9.29",
4
+ "version": "0.9.31",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "exports": {