vite-ssg-optimized 0.24.2-optimized.7 → 0.24.2-optimized.8

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.
@@ -14,8 +14,28 @@ require('html5parser');
14
14
 
15
15
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
16
16
  (async () => {
17
- const fnLog = (level = "info", msg) => {
18
- node_worker_threads.parentPort.postMessage({ type: "log", args: [msg], level });
17
+ const plainnify = (m) => {
18
+ if (m instanceof Function) {
19
+ return void 0;
20
+ }
21
+ if (Array.isArray(m)) {
22
+ return m.map(plainnify);
23
+ }
24
+ if (typeof m === "object" && m !== null) {
25
+ return Object.entries(m).reduce((acc, [key, value]) => {
26
+ acc[key] = plainnify(value);
27
+ return acc;
28
+ }, {});
29
+ }
30
+ return m?.toString();
31
+ };
32
+ const fnLog = (level = "info", ...msg) => {
33
+ const newMsg = msg.map(plainnify);
34
+ if (level === "error") {
35
+ process.stderr.write(`${kolorist.red("[vite-ssg-worker]")} ${newMsg}
36
+ `);
37
+ }
38
+ node_worker_threads.parentPort.postMessage({ type: "log", args: newMsg, level });
19
39
  };
20
40
  globalThis.console = Object.assign(globalThis.console, {
21
41
  info: fnLog.bind(globalThis.console, "info"),
@@ -11,8 +11,28 @@ import './vite-ssg-optimized.579feabb.mjs';
11
11
  import 'html5parser';
12
12
 
13
13
  (async () => {
14
- const fnLog = (level = "info", msg) => {
15
- parentPort.postMessage({ type: "log", args: [msg], level });
14
+ const plainnify = (m) => {
15
+ if (m instanceof Function) {
16
+ return void 0;
17
+ }
18
+ if (Array.isArray(m)) {
19
+ return m.map(plainnify);
20
+ }
21
+ if (typeof m === "object" && m !== null) {
22
+ return Object.entries(m).reduce((acc, [key, value]) => {
23
+ acc[key] = plainnify(value);
24
+ return acc;
25
+ }, {});
26
+ }
27
+ return m?.toString();
28
+ };
29
+ const fnLog = (level = "info", ...msg) => {
30
+ const newMsg = msg.map(plainnify);
31
+ if (level === "error") {
32
+ process.stderr.write(`${red("[vite-ssg-worker]")} ${newMsg}
33
+ `);
34
+ }
35
+ parentPort.postMessage({ type: "log", args: newMsg, level });
16
36
  };
17
37
  globalThis.console = Object.assign(globalThis.console, {
18
38
  info: fnLog.bind(globalThis.console, "info"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-ssg-optimized",
3
- "version": "0.24.2-optimized.7",
3
+ "version": "0.24.2-optimized.8",
4
4
  "description": "Server-side generation for Vite",
5
5
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",