@hanzogui/web 7.3.1 → 7.3.3

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.
@@ -69,6 +69,10 @@ Gui: Using global config fallback. This may indicate duplicate gui instances (e.
69
69
  }
70
70
  return globalThis.__guiConfig;
71
71
  }
72
+ if (typeof document === "undefined") {
73
+ try { __lazyCG().createGui({ themes: { light: {}, dark: {} } }); } catch {}
74
+ if (conf) return conf;
75
+ }
72
76
  return null;
73
77
  };
74
78
  const getSetting = key => {
@@ -199,7 +199,7 @@ function useMedia(componentContext, debug) {
199
199
  }
200
200
  });
201
201
  }
202
- const getServerSnapshot = () => initState;
202
+ const getServerSnapshot = () => initState ?? getMedia();
203
203
  let disableMediaTouch = false;
204
204
  function _disableMediaTouch(val) {
205
205
  disableMediaTouch = val;
@@ -64,7 +64,7 @@ const useThemeState = (props, isRoot = false, keys, schemeKeys) => {
64
64
  disable
65
65
  } = props;
66
66
  const parentId = (0, import_react.useContext)(ThemeStateContext);
67
- if (!parentId && !isRoot) throw new Error(process.env.NODE_ENV === "development" ? `${import_constants3.MISSING_THEME_MESSAGE}
67
+ if (!parentId && !isRoot && typeof document !== "undefined") throw new Error(process.env.NODE_ENV === "development" ? `${import_constants3.MISSING_THEME_MESSAGE}
68
68
 
69
69
  Looked for theme${props.name ? ` "${props.name}"` : ""}${props.componentName ? ` (component: ${props.componentName})` : ""}, but no parent theme context was found (parentId: ${parentId}).` : import_constants3.MISSING_THEME_MESSAGE);
70
70
  if (disable) return states.get(parentId) || {
@@ -185,7 +185,7 @@ const getNextState = (lastState, props, propsKey, isRoot = false, id, parentId,
185
185
  }];
186
186
  }
187
187
  if (!name) {
188
- const next = lastState ?? parentState;
188
+ const next = lastState ?? parentState ?? (typeof document === "undefined" ? { name: "light", theme: {}, isNew: false } : void 0);
189
189
  if (!next) throw new Error(process.env.NODE_ENV === "development" ? `${import_constants3.MISSING_THEME_MESSAGE}
190
190
 
191
191
  Looked for theme${props.name ? ` "${props.name}"` : ""}${props.componentName ? ` (component: ${props.componentName})` : ""}, but no theme state was resolved (parentId: ${parentId}, id: ${id}).` : import_constants3.MISSING_THEME_MESSAGE);
@@ -1,4 +1,5 @@
1
1
  import { isWeb } from "@hanzogui/constants";
2
+ import { createGui as __lazyCreateGui } from "./createGui.mjs";
2
3
  import { MISSING_THEME_MESSAGE } from "./constants/constants.mjs";
3
4
  let conf;
4
5
  let setConfigCalledByThisInstance = false;
@@ -26,6 +27,14 @@ Gui: Using global config fallback. This may indicate duplicate gui instances (e.
26
27
  }
27
28
  return globalThis.__guiConfig;
28
29
  }
30
+ // Server-side, nothing configured anywhere: a prerender worker reached a gui
31
+ // component before any config module evaluated (chunk-graph dependent). Build
32
+ // a minimal config so the render degrades instead of throwing; the client
33
+ // hydrates with the real config.
34
+ if (typeof document === "undefined") {
35
+ try { __lazyCreateGui({ themes: { light: {}, dark: {} } }); } catch {}
36
+ if (conf) return conf;
37
+ }
29
38
  return null;
30
39
  };
31
40
  const getSetting = key => {
@@ -160,7 +160,7 @@ function useMedia(componentContext, debug) {
160
160
  }
161
161
  });
162
162
  }
163
- const getServerSnapshot = () => initState;
163
+ const getServerSnapshot = () => initState ?? getMedia();
164
164
  let disableMediaTouch = false;
165
165
  function _disableMediaTouch(val) {
166
166
  disableMediaTouch = val;
@@ -32,7 +32,7 @@ const useThemeState = (props, isRoot = false, keys, schemeKeys) => {
32
32
  disable
33
33
  } = props;
34
34
  const parentId = useContext(ThemeStateContext);
35
- if (!parentId && !isRoot) throw new Error(process.env.NODE_ENV === "development" ? `${MISSING_THEME_MESSAGE}
35
+ if (!parentId && !isRoot && typeof document !== "undefined") throw new Error(process.env.NODE_ENV === "development" ? `${MISSING_THEME_MESSAGE}
36
36
 
37
37
  Looked for theme${props.name ? ` "${props.name}"` : ""}${props.componentName ? ` (component: ${props.componentName})` : ""}, but no parent theme context was found (parentId: ${parentId}).` : MISSING_THEME_MESSAGE);
38
38
  if (disable) return states.get(parentId) || {
@@ -153,7 +153,7 @@ const getNextState = (lastState, props, propsKey, isRoot = false, id, parentId,
153
153
  }];
154
154
  }
155
155
  if (!name) {
156
- const next = lastState ?? parentState;
156
+ const next = lastState ?? parentState ?? (typeof document === "undefined" ? { name: "light", theme: {}, isNew: false } : void 0);
157
157
  if (!next) throw new Error(process.env.NODE_ENV === "development" ? `${MISSING_THEME_MESSAGE}
158
158
 
159
159
  Looked for theme${props.name ? ` "${props.name}"` : ""}${props.componentName ? ` (component: ${props.componentName})` : ""}, but no theme state was resolved (parentId: ${parentId}, id: ${id}).` : MISSING_THEME_MESSAGE);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanzogui/web",
3
- "version": "7.3.1",
3
+ "version": "7.3.3",
4
4
  "license": "BSD-3-Clause",
5
5
  "author": "Hanzo AI <dev@hanzo.ai>",
6
6
  "repository": {
@@ -41,13 +41,6 @@
41
41
  "publishConfig": {
42
42
  "access": "public"
43
43
  },
44
- "scripts": {
45
- "build": "gui-build",
46
- "watch": "gui-build --watch",
47
- "clean": "gui-build clean",
48
- "clean:build": "gui-build clean:build",
49
- "test:web": "vitest --typecheck --run"
50
- },
51
44
  "dependencies": {
52
45
  "@hanzogui/compose-refs": "7.3.1",
53
46
  "@hanzogui/constants": "7.3.1",
@@ -89,5 +82,12 @@
89
82
  "react-native": {
90
83
  "optional": true
91
84
  }
85
+ },
86
+ "scripts": {
87
+ "build": "gui-build",
88
+ "watch": "gui-build --watch",
89
+ "clean": "gui-build clean",
90
+ "clean:build": "gui-build clean:build",
91
+ "test:web": "vitest --typecheck --run"
92
92
  }
93
- }
93
+ }