@yh-ui/components 0.1.27 → 0.1.29

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.
@@ -23,6 +23,7 @@ const isLoading = ref(false);
23
23
  const renderType = ref("image");
24
24
  const zoomLevel = ref(1);
25
25
  const graphContainerRef = ref(null);
26
+ const canUseDom = typeof window !== "undefined" && typeof document !== "undefined";
26
27
  const loadMermaid = async () => {
27
28
  if (mermaidModule.value) return mermaidModule.value;
28
29
  try {
@@ -41,6 +42,11 @@ const renderGraph = async () => {
41
42
  svgContent.value = "";
42
43
  return;
43
44
  }
45
+ if (!canUseDom) {
46
+ svgContent.value = "";
47
+ errorMessage.value = null;
48
+ return;
49
+ }
44
50
  isLoading.value = true;
45
51
  errorMessage.value = null;
46
52
  try {
@@ -74,7 +80,7 @@ ${processedCode}`;
74
80
  watch(
75
81
  [() => props.code, () => props.config],
76
82
  () => {
77
- if (renderType.value === "image") {
83
+ if (canUseDom && renderType.value === "image") {
78
84
  renderGraph();
79
85
  }
80
86
  },
@@ -86,7 +92,7 @@ const handleRenderTypeChange = (type) => {
86
92
  if (props.onRenderTypeChange) {
87
93
  props.onRenderTypeChange(type);
88
94
  }
89
- if (type === "image") {
95
+ if (canUseDom && type === "image") {
90
96
  renderGraph();
91
97
  }
92
98
  };