MCPcopy Create free account
hub / github.com/bigskysoftware/_hyperscript / loadComponentBundle

Function loadComponentBundle

www/js/ext/component.esm.js:829–845  ·  view source on GitHub ↗
(url)

Source from the content-addressed store, hash-verified

827 registerComponent(tmpl, script || "");
828 }
829 function loadComponentBundle(url) {
830 if (fetchedBundles.has(url)) return fetchedBundles.get(url);
831 var p = fetch(url).then(function(r) {
832 if (!r.ok) throw new Error("HTTP " + r.status + " fetching " + url);
833 return r.text();
834 }).then(function(html) {
835 var doc = new DOMParser().parseFromString(html, "text/html");
836 for (let tmpl of doc.querySelectorAll('script[type="text/hyperscript-template"][component]')) {
837 registerTemplate(tmpl);
838 }
839 }).catch(function(err) {
840 console.error("hyperscript component bundle '" + url + "': " + err.message);
841 fetchedBundles.delete(url);
842 });
843 fetchedBundles.set(url, p);
844 return p;
845 }
846 _hyperscript.addBeforeProcessHook(function(elt) {
847 ensureFouceGuard();
848 if (!elt || !elt.querySelectorAll) return;

Callers 1

componentPluginFunction · 0.70

Calls 5

registerTemplateFunction · 0.70
fetchFunction · 0.50
getMethod · 0.45
deleteMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected