vite-ssg-optimized 0.24.2-optimized.1

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.
Files changed (43) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +436 -0
  3. package/bin/vite-ssg.js +3 -0
  4. package/dist/chunks/jsdomGlobal.cjs +91 -0
  5. package/dist/chunks/jsdomGlobal.mjs +85 -0
  6. package/dist/client/single-page.cjs +52 -0
  7. package/dist/client/single-page.d.cts +12 -0
  8. package/dist/client/single-page.d.mts +12 -0
  9. package/dist/client/single-page.d.ts +12 -0
  10. package/dist/client/single-page.mjs +50 -0
  11. package/dist/index.cjs +88 -0
  12. package/dist/index.d.cts +12 -0
  13. package/dist/index.d.mts +12 -0
  14. package/dist/index.d.ts +12 -0
  15. package/dist/index.mjs +86 -0
  16. package/dist/node/cli.cjs +52 -0
  17. package/dist/node/cli.d.cts +2 -0
  18. package/dist/node/cli.d.mts +2 -0
  19. package/dist/node/cli.d.ts +2 -0
  20. package/dist/node/cli.mjs +45 -0
  21. package/dist/node.cjs +17 -0
  22. package/dist/node.d.cts +9 -0
  23. package/dist/node.d.mts +9 -0
  24. package/dist/node.d.ts +9 -0
  25. package/dist/node.mjs +11 -0
  26. package/dist/shared/build.worker.cjs +72 -0
  27. package/dist/shared/build.worker.d.cts +29 -0
  28. package/dist/shared/build.worker.d.mts +29 -0
  29. package/dist/shared/build.worker.d.ts +29 -0
  30. package/dist/shared/build.worker.mjs +69 -0
  31. package/dist/shared/vite-ssg-optimized.0250a125.cjs +27 -0
  32. package/dist/shared/vite-ssg-optimized.12fd9d22.d.cts +9 -0
  33. package/dist/shared/vite-ssg-optimized.31f4c9de.cjs +1460 -0
  34. package/dist/shared/vite-ssg-optimized.579feabb.mjs +34 -0
  35. package/dist/shared/vite-ssg-optimized.5912142e.mjs +24 -0
  36. package/dist/shared/vite-ssg-optimized.892682c8.d.mts +9 -0
  37. package/dist/shared/vite-ssg-optimized.950926bc.d.ts +9 -0
  38. package/dist/shared/vite-ssg-optimized.bee8a5a9.cjs +37 -0
  39. package/dist/shared/vite-ssg-optimized.cf5cb4ee.d.cts +167 -0
  40. package/dist/shared/vite-ssg-optimized.cf5cb4ee.d.mts +167 -0
  41. package/dist/shared/vite-ssg-optimized.cf5cb4ee.d.ts +167 -0
  42. package/dist/shared/vite-ssg-optimized.dc2a4a38.mjs +1449 -0
  43. package/package.json +144 -0
@@ -0,0 +1,69 @@
1
+ import { createRequire } from 'node:module';
2
+ import { parentPort, workerData } from 'node:worker_threads';
3
+ import { g as getBeastiesOrCritters, e as executeTaskFn } from './vite-ssg-optimized.dc2a4a38.mjs';
4
+ import { gray, blue } from 'kolorist';
5
+ import { resolveConfig } from 'vite';
6
+ import 'node:path';
7
+ import 'node:process';
8
+ import '@unhead/ssr';
9
+ import 'fs-extra';
10
+ import './vite-ssg-optimized.579feabb.mjs';
11
+ import 'html5parser';
12
+
13
+ (async () => {
14
+ const { serverEntry, out, beastiesOptions, viteConfig, mode, format, dirStyle, ...extraOpts } = workerData;
15
+ const nodeEnv = process.env.NODE_ENV || "production";
16
+ const config = await resolveConfig(viteConfig, "build", mode, nodeEnv);
17
+ const {
18
+ onPageRendered,
19
+ onBeforePageRender,
20
+ onDonePageRender
21
+ } = config.ssgOptions || {};
22
+ const { renderToString } = await import('vue/server-renderer');
23
+ const outDir = out.replace(process.cwd(), "").replace(/^\//g, "");
24
+ const _require = createRequire(import.meta.url);
25
+ const beasties = beastiesOptions !== false ? await getBeastiesOrCritters(outDir, beastiesOptions) : void 0;
26
+ if (beasties)
27
+ console.log(`${gray("[vite-ssg]")} ${blue("Critical CSS generation enabled via `beasties`")}`);
28
+ const { createApp } = format === "esm" ? await import(serverEntry) : _require(serverEntry);
29
+ const execMap = {
30
+ executeTaskFn: async (opts) => {
31
+ const newOpts = {
32
+ ...extraOpts,
33
+ out,
34
+ dirStyle,
35
+ createApp,
36
+ renderToString,
37
+ onPageRendered,
38
+ onBeforePageRender,
39
+ onDonePageRender,
40
+ beasties,
41
+ config: { logger: { info: (msg) => {
42
+ config.logger?.info?.(msg);
43
+ parentPort.postMessage({ type: "log", args: [msg] });
44
+ } } },
45
+ ...opts
46
+ };
47
+ return executeTaskFn(newOpts);
48
+ }
49
+ };
50
+ parentPort?.on("message", async (message) => {
51
+ const { type, id, args } = message;
52
+ if (type in execMap) {
53
+ parentPort.postMessage(`running ${type}`);
54
+ try {
55
+ process.stdout.write(JSON.stringify(args));
56
+ const result = await execMap[type](...args ?? []);
57
+ if (result.appCtx) {
58
+ Object.assign(result, {
59
+ appCtx: result.appCtx.router.push(result.route)
60
+ });
61
+ }
62
+ parentPort.postMessage({ type: "result", id, result });
63
+ } catch (e) {
64
+ process.stdout.write(JSON.stringify(e));
65
+ parentPort.postMessage({ type: "error", id, error: e.toString() });
66
+ }
67
+ }
68
+ });
69
+ })();
@@ -0,0 +1,27 @@
1
+ 'use strict';
2
+
3
+ const vue = require('vue');
4
+
5
+ function documentReady(_passThrough) {
6
+ if (document.readyState === "loading") {
7
+ return new Promise((resolve) => {
8
+ document.addEventListener("DOMContentLoaded", () => resolve(_passThrough));
9
+ });
10
+ }
11
+ return Promise.resolve(_passThrough);
12
+ }
13
+
14
+ const ClientOnly = vue.defineComponent({
15
+ setup(props, { slots }) {
16
+ const mounted = vue.ref(false);
17
+ vue.onMounted(() => mounted.value = true);
18
+ return () => {
19
+ if (!mounted.value)
20
+ return slots.placeholder && slots.placeholder({});
21
+ return slots.default && slots.default({});
22
+ };
23
+ }
24
+ });
25
+
26
+ exports.ClientOnly = ClientOnly;
27
+ exports.documentReady = documentReady;
@@ -0,0 +1,9 @@
1
+ import { InlineConfig } from 'vite';
2
+ import { b as ViteSSGOptions } from './vite-ssg-optimized.cf5cb4ee.cjs';
3
+
4
+ type Manifest = Record<string, string[]>;
5
+ declare function build(ssgOptions?: Partial<ViteSSGOptions & {
6
+ 'skip-build'?: boolean;
7
+ }>, viteConfig?: InlineConfig): Promise<void>;
8
+
9
+ export { type Manifest as M, build as b };