@hanzogui/web 7.3.2 → 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 => {
@@ -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 => {
@@ -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.2",
3
+ "version": "7.3.3",
4
4
  "license": "BSD-3-Clause",
5
5
  "author": "Hanzo AI <dev@hanzo.ai>",
6
6
  "repository": {