@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.
@@ -63,7 +63,7 @@ __export(index_node_exports, {
63
63
  Module: () => Module,
64
64
  NODE: () => NODE,
65
65
  Navigate: () => Navigate,
66
- Node: () => Node,
66
+ Node: () => Node2,
67
67
  NodeFactory: () => NodeFactory,
68
68
  ORCA_CLIENT_COMPONENT: () => ORCA_CLIENT_COMPONENT,
69
69
  ORCA_ELEMENT_TYPE: () => ORCA_ELEMENT_TYPE,
@@ -149,7 +149,7 @@ __export(shared_exports, {
149
149
  Module: () => Module,
150
150
  NODE: () => NODE,
151
151
  Navigate: () => Navigate,
152
- Node: () => Node,
152
+ Node: () => Node2,
153
153
  ORCA_CLIENT_COMPONENT: () => ORCA_CLIENT_COMPONENT,
154
154
  ORCA_ELEMENT_TYPE: () => ORCA_ELEMENT_TYPE,
155
155
  ORCA_FRAGMENT_TYPE: () => ORCA_FRAGMENT_TYPE,
@@ -378,7 +378,7 @@ var ProviderNormalizer = class {
378
378
  return { scope: "singleton", ...provider };
379
379
  }
380
380
  };
381
- var Node = class {
381
+ var Node2 = class {
382
382
  constructor(name) {
383
383
  this.name = name;
384
384
  this.children = [];
@@ -431,7 +431,7 @@ var Compiler = class {
431
431
  const target = this.isDynamicModule(moduleOrDynamic) ? moduleOrDynamic.module : moduleOrDynamic;
432
432
  if (this.nodes.has(target.name))
433
433
  return this.nodes.get(target.name);
434
- const node = new Node(target.name);
434
+ const node = new Node2(target.name);
435
435
  this.nodes.set(target.name, node);
436
436
  const imports = this.getImports(moduleOrDynamic);
437
437
  node.setChildren(imports.map((imp) => this.createNode(imp)));
@@ -930,13 +930,22 @@ var StreamRenderer = class {
930
930
  return this.renderClassComponent(vnode, injector);
931
931
  }
932
932
  if (isIntrinsicElement(vnode)) {
933
+ const dangerousHTML = vnode.props?.dangerouslySetInnerHTML;
934
+ let children;
935
+ if (dangerousHTML && dangerousHTML.__html) {
936
+ children = this.parseHTMLToJSX(dangerousHTML.__html, injector);
937
+ } else {
938
+ children = this.mapChildren(vnode.props?.children, injector);
939
+ }
933
940
  return {
934
- $$typeof: ORCA_ELEMENT_TYPE,
941
+ $typeof: ORCA_ELEMENT_TYPE,
935
942
  type: vnode.type,
936
943
  id: vnode.id,
937
944
  props: {
938
945
  ...vnode.props,
939
- children: this.mapChildren(vnode.props?.children, injector)
946
+ dangerouslySetInnerHTML: void 0,
947
+ // Remove after processing
948
+ children
940
949
  },
941
950
  key: vnode.key ?? null
942
951
  };
@@ -987,6 +996,59 @@ var StreamRenderer = class {
987
996
  }
988
997
  return this.buildSyncTree(children, injector);
989
998
  }
999
+ parseHTMLToJSX(html, injector) {
1000
+ const parser = new DOMParser();
1001
+ const doc = parser.parseFromString(html, "text/html");
1002
+ const convertNode = (node) => {
1003
+ if (node.nodeType === Node.TEXT_NODE) {
1004
+ return node.textContent;
1005
+ }
1006
+ if (node.nodeType === Node.ELEMENT_NODE) {
1007
+ const element = node;
1008
+ const tagName = element.tagName.toLowerCase();
1009
+ const props = {};
1010
+ for (let i = 0; i < element.attributes.length; i++) {
1011
+ const attr = element.attributes[i];
1012
+ let propName = attr.name;
1013
+ if (propName === "class")
1014
+ propName = "className";
1015
+ if (propName === "for")
1016
+ propName = "htmlFor";
1017
+ props[propName] = attr.value;
1018
+ }
1019
+ const children = [];
1020
+ for (let i = 0; i < element.childNodes.length; i++) {
1021
+ const child = convertNode(element.childNodes[i]);
1022
+ if (child !== null && child !== "") {
1023
+ children.push(child);
1024
+ }
1025
+ }
1026
+ const jsxElement = {
1027
+ $$typeof: ORCA_ELEMENT_TYPE,
1028
+ type: tagName,
1029
+ id: this.generateId(),
1030
+ props: {
1031
+ ...props,
1032
+ children: children.length === 0 ? void 0 : children.length === 1 ? children[0] : children
1033
+ },
1034
+ key: null
1035
+ };
1036
+ return this.buildSyncTree(jsxElement, injector);
1037
+ }
1038
+ return null;
1039
+ };
1040
+ const bodyChildren = [];
1041
+ for (let i = 0; i < doc.body.childNodes.length; i++) {
1042
+ const child = convertNode(doc.body.childNodes[i]);
1043
+ if (child !== null && child !== "") {
1044
+ bodyChildren.push(child);
1045
+ }
1046
+ }
1047
+ return bodyChildren.length === 0 ? void 0 : bodyChildren.length === 1 ? bodyChildren[0] : bodyChildren;
1048
+ }
1049
+ generateId() {
1050
+ return `jsx_${Math.random().toString(36).substr(2, 9)}`;
1051
+ }
990
1052
  createPendingReference(vnode, promise, injector) {
991
1053
  const id = vnode.id;
992
1054
  const abortController = new AbortController();