@x-plat/design-system 0.3.7 → 0.3.9

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.
@@ -130,6 +130,7 @@ var HtmlTypeWriter = ({
130
130
  const [typedLen, setTypedLen] = import_react2.default.useState(0);
131
131
  const doneCalledRef = import_react2.default.useRef(false);
132
132
  const { doc, rangeMap, totalLength } = import_react2.default.useMemo(() => {
133
+ if (typeof window === "undefined") return { doc: null, rangeMap: /* @__PURE__ */ new Map(), totalLength: 0 };
133
134
  const decoded = decodeHtmlEntities(html);
134
135
  const doc2 = new DOMParser().parseFromString(decoded, "text/html");
135
136
  const { rangeMap: rangeMap2, totalLength: totalLength2 } = buildRangeMap(doc2.body);
@@ -159,8 +160,8 @@ var HtmlTypeWriter = ({
159
160
  }
160
161
  }, [typedLen, totalLength, onDone]);
161
162
  const parsed = import_react2.default.useMemo(
162
- () => htmlToReactProgressive(doc.body, typedLen, rangeMap),
163
- [doc.body, typedLen, rangeMap]
163
+ () => doc ? htmlToReactProgressive(doc.body, typedLen, rangeMap) : null,
164
+ [doc, typedLen, rangeMap]
164
165
  );
165
166
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "lib-xplat-htmlTypewriter", children: parsed });
166
167
  };
@@ -94,6 +94,7 @@ var HtmlTypeWriter = ({
94
94
  const [typedLen, setTypedLen] = React2.useState(0);
95
95
  const doneCalledRef = React2.useRef(false);
96
96
  const { doc, rangeMap, totalLength } = React2.useMemo(() => {
97
+ if (typeof window === "undefined") return { doc: null, rangeMap: /* @__PURE__ */ new Map(), totalLength: 0 };
97
98
  const decoded = decodeHtmlEntities(html);
98
99
  const doc2 = new DOMParser().parseFromString(decoded, "text/html");
99
100
  const { rangeMap: rangeMap2, totalLength: totalLength2 } = buildRangeMap(doc2.body);
@@ -123,8 +124,8 @@ var HtmlTypeWriter = ({
123
124
  }
124
125
  }, [typedLen, totalLength, onDone]);
125
126
  const parsed = React2.useMemo(
126
- () => htmlToReactProgressive(doc.body, typedLen, rangeMap),
127
- [doc.body, typedLen, rangeMap]
127
+ () => doc ? htmlToReactProgressive(doc.body, typedLen, rangeMap) : null,
128
+ [doc, typedLen, rangeMap]
128
129
  );
129
130
  return /* @__PURE__ */ jsx("div", { className: "lib-xplat-htmlTypewriter", children: parsed });
130
131
  };