site-config-stack 5.0.1 → 5.0.2

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/dist/index.cjs CHANGED
@@ -38,6 +38,19 @@ function envSiteConfig(env = {}) {
38
38
  return config;
39
39
  }
40
40
 
41
+ function copyPlainData(value) {
42
+ if (Array.isArray(value))
43
+ return value.map(copyPlainData);
44
+ if (!value || typeof value !== "object" || value.__v_isRef || value.__v_isReactive)
45
+ return value;
46
+ const proto = Object.getPrototypeOf(value);
47
+ if (proto !== Object.prototype && proto !== null)
48
+ return value;
49
+ const copy = {};
50
+ for (const key in value)
51
+ copy[key] = copyPlainData(value[key]);
52
+ return copy;
53
+ }
41
54
  function normalizeSiteConfig(config) {
42
55
  if (typeof config.indexable !== "undefined")
43
56
  config.indexable = String(config.indexable) !== "false";
@@ -87,22 +100,22 @@ function createSiteConfigStack(options) {
87
100
  return () => {
88
101
  };
89
102
  }
90
- if (!input._context && debug) {
91
- let lastFunctionName = new Error("tmp").stack?.split("\n")[2]?.split(" ")[5];
92
- if (lastFunctionName?.includes("/"))
93
- lastFunctionName = "anonymous";
94
- input._context = lastFunctionName;
95
- }
96
103
  const entry = {};
97
104
  for (const k in input) {
98
105
  const val = input[k];
99
106
  if (typeof val !== "undefined" && val !== "")
100
- entry[k] = val;
107
+ entry[k] = copyPlainData(val);
101
108
  }
102
109
  if (!Object.keys(entry).some((k) => !k.startsWith("_"))) {
103
110
  return () => {
104
111
  };
105
112
  }
113
+ if (!entry._context && debug) {
114
+ let lastFunctionName = new Error("tmp").stack?.split("\n")[2]?.split(" ")[5];
115
+ if (lastFunctionName?.includes("/"))
116
+ lastFunctionName = "anonymous";
117
+ entry._context = lastFunctionName;
118
+ }
106
119
  stack.push(entry);
107
120
  return () => {
108
121
  const idx = stack.indexOf(entry);
package/dist/index.mjs CHANGED
@@ -36,6 +36,19 @@ function envSiteConfig(env = {}) {
36
36
  return config;
37
37
  }
38
38
 
39
+ function copyPlainData(value) {
40
+ if (Array.isArray(value))
41
+ return value.map(copyPlainData);
42
+ if (!value || typeof value !== "object" || value.__v_isRef || value.__v_isReactive)
43
+ return value;
44
+ const proto = Object.getPrototypeOf(value);
45
+ if (proto !== Object.prototype && proto !== null)
46
+ return value;
47
+ const copy = {};
48
+ for (const key in value)
49
+ copy[key] = copyPlainData(value[key]);
50
+ return copy;
51
+ }
39
52
  function normalizeSiteConfig(config) {
40
53
  if (typeof config.indexable !== "undefined")
41
54
  config.indexable = String(config.indexable) !== "false";
@@ -85,22 +98,22 @@ function createSiteConfigStack(options) {
85
98
  return () => {
86
99
  };
87
100
  }
88
- if (!input._context && debug) {
89
- let lastFunctionName = new Error("tmp").stack?.split("\n")[2]?.split(" ")[5];
90
- if (lastFunctionName?.includes("/"))
91
- lastFunctionName = "anonymous";
92
- input._context = lastFunctionName;
93
- }
94
101
  const entry = {};
95
102
  for (const k in input) {
96
103
  const val = input[k];
97
104
  if (typeof val !== "undefined" && val !== "")
98
- entry[k] = val;
105
+ entry[k] = copyPlainData(val);
99
106
  }
100
107
  if (!Object.keys(entry).some((k) => !k.startsWith("_"))) {
101
108
  return () => {
102
109
  };
103
110
  }
111
+ if (!entry._context && debug) {
112
+ let lastFunctionName = new Error("tmp").stack?.split("\n")[2]?.split(" ")[5];
113
+ if (lastFunctionName?.includes("/"))
114
+ lastFunctionName = "anonymous";
115
+ entry._context = lastFunctionName;
116
+ }
104
117
  stack.push(entry);
105
118
  return () => {
106
119
  const idx = stack.indexOf(entry);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "site-config-stack",
3
3
  "type": "module",
4
- "version": "5.0.1",
4
+ "version": "5.0.2",
5
5
  "description": "Shared site configuration utilities.",
6
6
  "license": "MIT",
7
7
  "funding": "https://github.com/sponsors/harlan-zw",