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

Function loadComponentBundle

www/js/ext/component.js:830–846  ·  view source on GitHub ↗
(url)

Source from the content-addressed store, hash-verified

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