···120120 */
121121export async function loadURI(uri) {
122122 const u = URI.parse(uri);
123123- console.log(u);
124123125124 switch (u.scheme) {
126125 case "at":
···144143 * @returns {Promise<T>}
145144 */
146145export async function ensureHTML(item) {
146146+ console.log(item.html, item.uri);
147147+147148 if (!item.html && item.uri) {
148149 const html = await loadURI(item.uri);
149150 const cid = await CID.create(0x55, new TextEncoder().encode(html));
150151152152+ console.log(html);
153153+151154 item.html = html;
152155 item.cid = cid;
153156 }
···181184182185/**
183186 * @param {string} uri
187187+ * @returns {Promise<string>}
184188 */
185189async function atprotoLoader(uri) {
186190 const parts = uri.replace(/at:\/\//, "").split("/");
···218222219223/**
220224 * @param {string} url
225225+ * @returns {Promise<string>}
221226 */
222227async function httpLoader(url) {
223228 return fetch(url).then((res) => res.text());
+10-9
src/facets/index.js
···1313import * as CID from "@common/cid.js";
1414import foundation from "@common/facets/foundation.js";
1515import { effect, signal } from "@common/signal.js";
1616-import { facetFromUrl } from "@common/facets/utils.js";
1616+import { facetFromURI } from "@common/facets/utils.js";
1717import { nothing } from "@common/element.js";
1818+import { loadURI } from "@common/loader.js";
18191920/**
2021 * @import {Facet} from "@definitions/types.d.ts"
···3435 const rel = target.getAttribute("rel");
3536 if (!rel) return;
36373737- const url = target.closest("li")?.getAttribute("data-url");
3838- if (!url) return;
3838+ const uri = target.closest("li")?.getAttribute("data-uri");
3939+ if (!uri) return;
39404041 const name = target.closest("li")?.getAttribute("data-name");
4142 if (!name) return;
42434344 switch (rel) {
4445 case "fork": {
4545- const facet = await facetFromUrl({ name, url }, { fetchHTML: true });
4646+ const facet = await facetFromURI({ name, uri }, { fetchHTML: true });
4647 editFacet(facet);
4748 document.querySelector("#build")?.scrollIntoView();
4849 break;
4950 }
5051 case "save": {
5151- const facet = await facetFromUrl({ name, url }, { fetchHTML: false });
5252+ const facet = await facetFromURI({ name, uri }, { fetchHTML: false });
5253 const out = foundation.orchestrator.output();
53545455 out.facets.save([
···110111 : nothing}
111112 </div>
112113 <div>
113113- ${c.url && !c.html
114114+ ${c.uri && !c.html
114115 ? html`
115116 <span class="with-icon">
116117 <i class="ph-fill ph-binoculars"></i>
117118 <span>Tracking the original <a href="${c
118118- .url}">URL</a></span>
119119+ .uri}">URI</a></span>
119120 </span>
120121 `
121122 : html`
···309310 document.querySelector("#build")?.scrollIntoView();
310311311312 // Make sure HTML is loaded
312312- if (!facet.html && facet.url) {
313313- const html = await fetch(facet.url).then((res) => res.text());
313313+ if (!facet.html && facet.uri) {
314314+ const html = await loadURI(facet.uri);
314315 const cid = await CID.create(0x55, new TextEncoder().encode(html));
315316316317 facet.html = html;
+6-6
src/facets/index.vto
···9999 <li>
100100 <p>
101101 <i class="ph-fill ph-plus"></i>
102102- <strong><a href="{{ ('themes/webamp/configurators/input/facet.html.txt') |> facetURL }}">Add</a></strong> audio from various places on the web and your device.
102102+ <strong><a href="{{ ('themes/webamp/configurators/input/facet.html.txt') |> facetLoaderURL }}">Add</a></strong> audio from various places on the web and your device.
103103 </p>
104104 </li>
105105 <li>
106106 <p>
107107 <i class="ph-fill ph-queue"></i>
108108- <strong><a href="{{ ('themes/webamp/browser/facet.html.txt') |> facetURL }}">Browse</a></strong> your collection to put something into the queue.
108108+ <strong><a href="{{ ('themes/webamp/browser/facet.html.txt') |> facetLoaderURL }}">Browse</a></strong> your collection to put something into the queue.
109109 </p>
110110 </li>
111111 <li>
112112 <p>
113113 <i class="ph-fill ph-queue"></i>
114114- <strong><a href="{{ ('facets/tools/auto-queue.html.txt') |> facetURL }}">Automate</a></strong> adding items to the queue, for infinite playback or listening to a playlist.
114114+ <strong><a href="{{ ('facets/tools/auto-queue.html.txt') |> facetLoaderURL }}">Automate</a></strong> adding items to the queue, for infinite playback or listening to a playlist.
115115 </p>
116116 </li>
117117 <li>
118118 <p>
119119 <i class="ph-fill ph-music-note"></i>
120120- <strong><a href="{{ ('themes/blur/artwork-controller/facet.html.txt') |> facetURL }}">Play</a></strong> queued songs.
120120+ <strong><a href="{{ ('themes/blur/artwork-controller/facet.html.txt') |> facetLoaderURL }}">Play</a></strong> queued songs.
121121 </p>
122122 </li>
123123 <li>
124124 <p>
125125 <i class="ph-fill ph-person"></i>
126126- <strong><a href="{{ ('themes/webamp/configurators/output/facet.html.txt') |> facetURL }}">Manage</a></strong> your user data, sync with your other devices or other people.
126126+ <strong><a href="{{ ('themes/webamp/configurators/output/facet.html.txt') |> facetLoaderURL }}">Manage</a></strong> your user data, sync with your other devices or other people.
127127 </p>
128128 </li>
129129 </ol>
···135135 To use these facets, simply open whichever ones provide the functionality that you're looking for at a given moment. You can browse existing ones here and create one below.
136136 </p>
137137 <p>
138138- For example, say you want to play music; two options would be: (1) <a href="{{ ('themes/webamp/browser/facet.html.txt') |> facetURL }}">browse</a> for a specific song and add it to the queue, or (2) <a href="{{ ('facets/tools/auto-queue.html.txt') |> facetURL }}">automatically</a> add a bunch of shuffled songs to the queue. Next, you need a way to play the items you added to the queue. That's where a <a href="{{ ('themes/blur/artwork-controller/facet.html.txt') |> facetURL }}">controller</a> could be used.
138138+ For example, say you want to play music; two options would be: (1) <a href="{{ ('themes/webamp/browser/facet.html.txt') |> facetLoaderURL }}">browse</a> for a specific song and add it to the queue, or (2) <a href="{{ ('facets/tools/auto-queue.html.txt') |> facetLoaderURL }}">automatically</a> add a bunch of shuffled songs to the queue. Next, you need a way to play the items you added to the queue. That's where a <a href="{{ ('themes/blur/artwork-controller/facet.html.txt') |> facetLoaderURL }}">controller</a> could be used.
139139 </p>
140140 <p>
141141 <em>You might ask, why can't I do all of this in just one window? That's what <a href="themes/">themes</a> are for, if you need something more streamlined. If you however want a customised experience, or prefer certain interfaces for certain things, that's what facets are for.</em>