{"version":3,"sources":["hydrate.ts"],"sourcesContent":["import { app } from \"../app/app.ts\";\nimport { querySelector, querySelectorAll } from \"../uix-dom/dom/shadow_dom_selector.ts\";\nimport { domUtils } from \"../app/dom-context.ts\";\nimport { logger } from \"../utils/global-values.ts\";\n\nexport async function hydrate() {\n\tconst nodes = querySelectorAll(\"[uix-dry]\");\n\tconst ptrs = nodes\n\t\t.map(node => [node.getAttribute(\"uix-ptr\"), node])\n\t\t.filter(([id, node]) => {\n\t\t\tif (!id) {\n\t\t\t\tconsole.warn(\"hydrate: missing uix-ptr attribute in node\", node);\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\telse return true;\n\t\t})\n\t\t.map(([id]) => \"$\" + id);\n\n\tconst resolvedPtrs = await datex<any[]>(`${app.backend} :: [${ptrs.join(\",\")}]`);\n\n\tfor (const [index, resolved] of Object.entries(resolvedPtrs)) {\n\t\t// replace non-node pointer - this currently only happens with uix-placeholder elements\n\t\tif (!(resolved instanceof Node)) {\n\t\t\tconst node = querySelector(`[uix-ptr=\"${ptrs[Number(index)].substring(1)}\"]`)\n\t\t\tif (!node) logger.debug(\"hydrate: node for uix-ptr \" + ptrs[Number(index)] + \" no longer exists\")\n\t\t\telse domUtils.replaceWith(node, resolved, true)\n\t\t}\n\t}\n\n}"],"names":["app","querySelector","querySelectorAll","domUtils","logger","hydrate","ptrs","nodes","map","node","getAttribute","filter","id","console","warn","index","resolved","Object","entries","datex","backend","join","Node","Number","substring","replaceWith","debug"],"mappings":"AAAA,SAASA,GAAG,QAAQ,gBAAgB;AACpC,SAASC,aAAa,EAAEC,gBAAgB,QAAQ,wCAAwC;AACxF,SAASC,QAAQ,QAAQ,wBAAwB;AACjD,SAASC,MAAM,QAAQ,4BAA4B;AAEnD,OAAO,eAAeC;IAErB,IAAMC,OAAOC,AADCL,iBAAiB,aAE7BM,GAAG,CAACC,CAAAA,OAAQ;YAACA,KAAKC,YAAY,CAAC;YAAYD;SAAK,EAChDE,MAAM,CAAC,CAAC,CAACC,IAAIH,KAAK,GAClB,EAAKG,OACJC,QAAQC,IAAI,CAAC,8CAA8CL,OACpD,CAAA,IAIRD,GAAG,CAAC,CAAC,CAACI,GAAG,GAAK,MAAMA;IAItB,KAAK,IAAM,CAACG,OAAOC,SAAS,IAAIC,OAAOC,OAAO,CAFzB,MAAMC,MAAa,CAAC,EAAEnB,IAAIoB,OAAO,CAAC,KAAK,EAAEd,KAAKe,IAAI,CAAC,KAAK,CAAC,CAAC,GAI9E,IAAI,CAAEL,CAAAA,oBAAoBM,IAAG,GAAI;QAChC,IAAMb,OAAOR,cAAc,CAAC,UAAU,EAAEK,IAAI,CAACiB,OAAOR,OAAO,CAACS,SAAS,CAAC,GAAG,EAAE,CAAC;QACvEf,OACAN,SAASsB,WAAW,CAAChB,MAAMO,UAAU,CAAA,KAD/BZ,OAAOsB,KAAK,CAAC,+BAA+BpB,IAAI,CAACiB,OAAOR,OAAO,GAAG;IAE9E;AAGF","sourceRoot":"/lib/uix-0.4.39/src/hydration/","file":"hydrate.ts"}