silgi 0.9.30 → 0.9.32

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.30";
1
+ const version = "0.9.32";
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
  });
@@ -270,9 +270,9 @@ const _sharedRuntimeConfig = _deepFreeze(
270
270
  function useSilgiRuntimeConfig(event) {
271
271
  const silgi = tryUseSilgi();
272
272
  if (!silgi) {
273
- const data = globalThis.$silgiSharedRuntimeConfig;
274
- if (data) {
275
- return data;
273
+ const globalRuntimeConfig = globalThis.$silgiSharedRuntimeConfig;
274
+ if (globalRuntimeConfig && !event) {
275
+ return globalRuntimeConfig;
276
276
  }
277
277
  if (!event) {
278
278
  return _sharedRuntimeConfig;
@@ -1,4 +1,4 @@
1
- const version = "0.9.30";
1
+ const version = "0.9.32";
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.30";
1
+ const version = "0.9.32";
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.30",
4
+ "version": "0.9.32",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "exports": {