defuss-ssg 0.7.0 → 0.7.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/runtime.cjs CHANGED
@@ -443,6 +443,9 @@ const shouldPreserveHydratedBoundary = (boundary, options) => {
443
443
  if (!options.preserveHydratedState) {
444
444
  return false;
445
445
  }
446
+ if (options.preserveHydratedBoundaries === false) {
447
+ return false;
448
+ }
446
449
  if (options.kind === "component" && options.componentSrc) {
447
450
  return boundary.getAttribute("data-hydrate-src") !== options.componentSrc;
448
451
  }
@@ -685,6 +688,14 @@ const navigateTo = async (url, replace = false, options = {}) => {
685
688
  console.log(
686
689
  `[navigateTo] url=${url} key=${key} replace=${replace} cached=${pageCache.has(key)}`
687
690
  );
691
+ console.log("[defuss-ssg] Morph refresh: navigateTo start", {
692
+ url,
693
+ replace,
694
+ kind: options.kind || "other",
695
+ preserveHydratedState: options.preserveHydratedState !== false,
696
+ preserveHydratedBoundaries: options.preserveHydratedBoundaries !== false,
697
+ componentSrc: options.componentSrc || null
698
+ });
688
699
  if (!pageCache.has(key)) {
689
700
  await prefetch(url);
690
701
  }
@@ -722,9 +733,24 @@ const navigateTo = async (url, replace = false, options = {}) => {
722
733
  console.log(
723
734
  `[navigateTo] Morphing body content (new length=${bodyHtml.length})`
724
735
  );
736
+ console.log("[defuss-ssg] Morph refresh: DOM morph start", {
737
+ url,
738
+ bodyLength: bodyHtml.length,
739
+ kind: options.kind || "other"
740
+ });
725
741
  await defuss.$(document.body).update(bodyHtml);
742
+ console.log("[defuss-ssg] Morph refresh: DOM morph complete", {
743
+ url,
744
+ bodyLength: bodyHtml.length,
745
+ kind: options.kind || "other"
746
+ });
726
747
  await triggerHydration(document.body);
727
748
  restoreBoundaryStateSnapshots(boundaryStateSnapshots);
749
+ console.log("[defuss-ssg] Morph refresh: hydration restore complete", {
750
+ url,
751
+ kind: options.kind || "other",
752
+ boundarySnapshots: boundaryStateSnapshots.length
753
+ });
728
754
  if (replace) {
729
755
  history.replaceState({ ...history.state, navigated: true }, "", url);
730
756
  } else {
@@ -9,6 +9,7 @@ declare const setupLiveReload: () => void;
9
9
  type LiveReloadKind = "page" | "endpoint" | "component" | "asset" | "dependency" | "config" | "rpc" | "other";
10
10
  type NavigateOptions = {
11
11
  preserveHydratedState?: boolean;
12
+ preserveHydratedBoundaries?: boolean;
12
13
  kind?: LiveReloadKind;
13
14
  componentSrc?: string;
14
15
  };
@@ -9,6 +9,7 @@ declare const setupLiveReload: () => void;
9
9
  type LiveReloadKind = "page" | "endpoint" | "component" | "asset" | "dependency" | "config" | "rpc" | "other";
10
10
  type NavigateOptions = {
11
11
  preserveHydratedState?: boolean;
12
+ preserveHydratedBoundaries?: boolean;
12
13
  kind?: LiveReloadKind;
13
14
  componentSrc?: string;
14
15
  };
package/dist/runtime.mjs CHANGED
@@ -441,6 +441,9 @@ const shouldPreserveHydratedBoundary = (boundary, options) => {
441
441
  if (!options.preserveHydratedState) {
442
442
  return false;
443
443
  }
444
+ if (options.preserveHydratedBoundaries === false) {
445
+ return false;
446
+ }
444
447
  if (options.kind === "component" && options.componentSrc) {
445
448
  return boundary.getAttribute("data-hydrate-src") !== options.componentSrc;
446
449
  }
@@ -683,6 +686,14 @@ const navigateTo = async (url, replace = false, options = {}) => {
683
686
  console.log(
684
687
  `[navigateTo] url=${url} key=${key} replace=${replace} cached=${pageCache.has(key)}`
685
688
  );
689
+ console.log("[defuss-ssg] Morph refresh: navigateTo start", {
690
+ url,
691
+ replace,
692
+ kind: options.kind || "other",
693
+ preserveHydratedState: options.preserveHydratedState !== false,
694
+ preserveHydratedBoundaries: options.preserveHydratedBoundaries !== false,
695
+ componentSrc: options.componentSrc || null
696
+ });
686
697
  if (!pageCache.has(key)) {
687
698
  await prefetch(url);
688
699
  }
@@ -720,9 +731,24 @@ const navigateTo = async (url, replace = false, options = {}) => {
720
731
  console.log(
721
732
  `[navigateTo] Morphing body content (new length=${bodyHtml.length})`
722
733
  );
734
+ console.log("[defuss-ssg] Morph refresh: DOM morph start", {
735
+ url,
736
+ bodyLength: bodyHtml.length,
737
+ kind: options.kind || "other"
738
+ });
723
739
  await $(document.body).update(bodyHtml);
740
+ console.log("[defuss-ssg] Morph refresh: DOM morph complete", {
741
+ url,
742
+ bodyLength: bodyHtml.length,
743
+ kind: options.kind || "other"
744
+ });
724
745
  await triggerHydration(document.body);
725
746
  restoreBoundaryStateSnapshots(boundaryStateSnapshots);
747
+ console.log("[defuss-ssg] Morph refresh: hydration restore complete", {
748
+ url,
749
+ kind: options.kind || "other",
750
+ boundarySnapshots: boundaryStateSnapshots.length
751
+ });
726
752
  if (replace) {
727
753
  history.replaceState({ ...history.state, navigated: true }, "", url);
728
754
  } else {
@@ -1,7 +1,7 @@
1
1
  import mdx from '@mdx-js/rollup';
2
- import { createServer, mergeConfig } from 'vite';
2
+ import { createServer } from 'vite';
3
3
  import defuss from 'defuss-vite';
4
- import { v as validateProjectDir, r as readConfig, f as defussSsg, o as registerEndpoints, l as initializeRpc, s as readIncomingBody, t as createWebRequest, k as handleRpcRequest, u as sendWebResponse } from './vite-CSOGjlHB.mjs';
4
+ import { L as validateProjectDir, B as readConfig, n as defussSsg, A as mergeUserViteConfig, D as registerEndpoints, t as initializeRpc, C as readIncomingBody, m as createWebRequest, s as handleRpcRequest, I as sendWebResponse } from './vite-bKsy4atm.mjs';
5
5
  import { existsSync } from 'node:fs';
6
6
  import { join } from 'node:path';
7
7
  import process from 'node:process';
@@ -16,43 +16,44 @@ const dev = async ({
16
16
  }) => {
17
17
  const projectDirStatus = validateProjectDir(projectDir);
18
18
  if (projectDirStatus.code !== "OK") return projectDirStatus;
19
- const config = await readConfig(projectDir, debug);
20
- const server = await createServer(
21
- mergeConfig(
22
- {
23
- root: projectDir,
24
- configFile: false,
25
- appType: "custom",
26
- server: {
27
- host,
28
- port,
29
- watch: {
30
- ignored: [
31
- "**/node_modules/**",
32
- "**/dist/**",
33
- "**/.ssg-temp/**",
34
- "**/.endpoints/**",
35
- "**/.rpc/**"
36
- ]
37
- }
38
- },
39
- plugins: [
40
- defuss({ enableJsxDevMode: true }),
41
- mdx({
42
- jsxImportSource: "defuss",
43
- development: true,
44
- remarkPlugins: config.remarkPlugins,
45
- rehypePlugins: config.rehypePlugins
46
- }),
47
- ...defussSsg({
48
- projectDir,
49
- debug,
50
- writeDevOutput
51
- })
19
+ const initialConfig = await readConfig(projectDir, debug);
20
+ const currentViteConfig = {
21
+ root: projectDir,
22
+ configFile: false,
23
+ appType: "custom",
24
+ server: {
25
+ host,
26
+ port,
27
+ watch: {
28
+ ignored: [
29
+ "**/node_modules/**",
30
+ "**/dist/**",
31
+ "**/.ssg-temp/**",
32
+ "**/.endpoints/**",
33
+ "**/.rpc/**"
52
34
  ]
53
- },
54
- config.viteConfig ?? {}
55
- )
35
+ }
36
+ },
37
+ plugins: [
38
+ defuss({ enableJsxDevMode: true }),
39
+ mdx({
40
+ jsxImportSource: "defuss",
41
+ development: true,
42
+ remarkPlugins: initialConfig.remarkPlugins,
43
+ rehypePlugins: initialConfig.rehypePlugins
44
+ }),
45
+ ...defussSsg({
46
+ projectDir,
47
+ debug,
48
+ writeDevOutput
49
+ })
50
+ ]
51
+ };
52
+ const config = await readConfig(projectDir, debug, {
53
+ currentViteConfig
54
+ });
55
+ const server = await createServer(
56
+ mergeUserViteConfig(currentViteConfig, config.viteConfig)
56
57
  );
57
58
  await server.listen(port);
58
59
  server.printUrls();
@@ -7961,4 +7961,4 @@ interface SsgConfig {
7961
7961
  viteConfig?: InlineConfig;
7962
7962
  }
7963
7963
 
7964
- export type { BuildOptions as B, ContainerRuntime as C, DevOptions as D, EndpointRouteContext as E, PluginFn as P, RehypePlugins as R, SsgConfig as S, Status as a, ServeOptions as b, EndpointRouteRegistrar as c, BuildMode as d, ContentEntry as e, ContentGlobOptions as f, DefussSsgViteOptions as g, DevChangeKind as h, EndpointRouteMethod as i, EndpointRouteResponder as j, PluginFnPageDom as k, PluginFnPageHtml as l, PluginFnPageVdom as m, PluginFnPrePost as n, RemarkPlugins as o, SsgPlugin as p, StatusCode as q };
7964
+ export type { BuildMode as B, ContainerRuntime as C, DefussSsgViteOptions as D, EndpointRouteContext as E, PluginFn as P, RehypePlugins as R, ServeOptions as S, BuildOptions as a, ContentEntry as b, ContentGlobOptions as c, DevChangeKind as d, DevOptions as e, EndpointRouteMethod as f, EndpointRouteRegistrar as g, EndpointRouteResponder as h, PluginFnPageDom as i, PluginFnPageHtml as j, PluginFnPageVdom as k, PluginFnPrePost as l, RemarkPlugins as m, SsgConfig as n, SsgPlugin as o, Status as p, StatusCode as q };
@@ -7961,4 +7961,4 @@ interface SsgConfig {
7961
7961
  viteConfig?: InlineConfig;
7962
7962
  }
7963
7963
 
7964
- export type { BuildOptions as B, ContainerRuntime as C, DevOptions as D, EndpointRouteContext as E, PluginFn as P, RehypePlugins as R, SsgConfig as S, Status as a, ServeOptions as b, EndpointRouteRegistrar as c, BuildMode as d, ContentEntry as e, ContentGlobOptions as f, DefussSsgViteOptions as g, DevChangeKind as h, EndpointRouteMethod as i, EndpointRouteResponder as j, PluginFnPageDom as k, PluginFnPageHtml as l, PluginFnPageVdom as m, PluginFnPrePost as n, RemarkPlugins as o, SsgPlugin as p, StatusCode as q };
7964
+ export type { BuildMode as B, ContainerRuntime as C, DefussSsgViteOptions as D, EndpointRouteContext as E, PluginFn as P, RehypePlugins as R, ServeOptions as S, BuildOptions as a, ContentEntry as b, ContentGlobOptions as c, DevChangeKind as d, DevOptions as e, EndpointRouteMethod as f, EndpointRouteRegistrar as g, EndpointRouteResponder as h, PluginFnPageDom as i, PluginFnPageHtml as j, PluginFnPageVdom as k, PluginFnPrePost as l, RemarkPlugins as m, SsgConfig as n, SsgPlugin as o, Status as p, StatusCode as q };