MCPcopy Index your code
hub / github.com/bigskysoftware/_hyperscript / loadComponentBundle

Function loadComponentBundle

src/ext/component.js:283–302  ·  view source on GitHub ↗
(url)

Source from the content-addressed store, hash-verified

281 }
282
283 function loadComponentBundle(url) {
284 if (fetchedBundles.has(url)) return fetchedBundles.get(url);
285 var p = fetch(url)
286 .then(function (r) {
287 if (!r.ok) throw new Error('HTTP ' + r.status + ' fetching ' + url);
288 return r.text();
289 })
290 .then(function (html) {
291 var doc = new DOMParser().parseFromString(html, 'text/html');
292 for (let tmpl of doc.querySelectorAll('script[type="text/hyperscript-template"][component]')) {
293 registerTemplate(tmpl);
294 }
295 })
296 .catch(function (err) {
297 console.error("hyperscript component bundle '" + url + "': " + err.message);
298 fetchedBundles.delete(url); // allow retry
299 });
300 fetchedBundles.set(url, p);
301 return p;
302 }
303 _hyperscript.addBeforeProcessHook(function(elt) {
304 ensureFouceGuard();
305 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