@kithinji/orca 1.0.5 → 1.0.7

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.
@@ -1987,13 +1987,22 @@ var StreamRenderer = class {
1987
1987
  return this.renderClassComponent(vnode, injector);
1988
1988
  }
1989
1989
  if (isIntrinsicElement(vnode)) {
1990
+ const dangerousHTML = vnode.props?.dangerouslySetInnerHTML;
1991
+ let children;
1992
+ if (dangerousHTML && dangerousHTML.__html) {
1993
+ children = this.parseHTMLToJSX(dangerousHTML.__html, injector);
1994
+ } else {
1995
+ children = this.mapChildren(vnode.props?.children, injector);
1996
+ }
1990
1997
  return {
1991
- $$typeof: ORCA_ELEMENT_TYPE,
1998
+ $typeof: ORCA_ELEMENT_TYPE,
1992
1999
  type: vnode.type,
1993
2000
  id: vnode.id,
1994
2001
  props: {
1995
2002
  ...vnode.props,
1996
- children: this.mapChildren(vnode.props?.children, injector)
2003
+ dangerouslySetInnerHTML: void 0,
2004
+ // Remove after processing
2005
+ children
1997
2006
  },
1998
2007
  key: vnode.key ?? null
1999
2008
  };
@@ -2044,6 +2053,59 @@ var StreamRenderer = class {
2044
2053
  }
2045
2054
  return this.buildSyncTree(children, injector);
2046
2055
  }
2056
+ parseHTMLToJSX(html, injector) {
2057
+ const parser = new DOMParser();
2058
+ const doc = parser.parseFromString(html, "text/html");
2059
+ const convertNode = (node) => {
2060
+ if (node.nodeType === Node.TEXT_NODE) {
2061
+ return node.textContent;
2062
+ }
2063
+ if (node.nodeType === Node.ELEMENT_NODE) {
2064
+ const element = node;
2065
+ const tagName = element.tagName.toLowerCase();
2066
+ const props = {};
2067
+ for (let i = 0; i < element.attributes.length; i++) {
2068
+ const attr = element.attributes[i];
2069
+ let propName = attr.name;
2070
+ if (propName === "class")
2071
+ propName = "className";
2072
+ if (propName === "for")
2073
+ propName = "htmlFor";
2074
+ props[propName] = attr.value;
2075
+ }
2076
+ const children = [];
2077
+ for (let i = 0; i < element.childNodes.length; i++) {
2078
+ const child = convertNode(element.childNodes[i]);
2079
+ if (child !== null && child !== "") {
2080
+ children.push(child);
2081
+ }
2082
+ }
2083
+ const jsxElement = {
2084
+ $$typeof: ORCA_ELEMENT_TYPE,
2085
+ type: tagName,
2086
+ id: this.generateId(),
2087
+ props: {
2088
+ ...props,
2089
+ children: children.length === 0 ? void 0 : children.length === 1 ? children[0] : children
2090
+ },
2091
+ key: null
2092
+ };
2093
+ return this.buildSyncTree(jsxElement, injector);
2094
+ }
2095
+ return null;
2096
+ };
2097
+ const bodyChildren = [];
2098
+ for (let i = 0; i < doc.body.childNodes.length; i++) {
2099
+ const child = convertNode(doc.body.childNodes[i]);
2100
+ if (child !== null && child !== "") {
2101
+ bodyChildren.push(child);
2102
+ }
2103
+ }
2104
+ return bodyChildren.length === 0 ? void 0 : bodyChildren.length === 1 ? bodyChildren[0] : bodyChildren;
2105
+ }
2106
+ generateId() {
2107
+ return `jsx_${Math.random().toString(36).substr(2, 9)}`;
2108
+ }
2047
2109
  createPendingReference(vnode, promise, injector) {
2048
2110
  const id = vnode.id;
2049
2111
  const abortController = new AbortController();