A music player that connects to your cloud/distributed storage.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

chore: add scrobble prelude to default facets, but disable it

+142 -46
+5
src/common/facets/constants.js
··· 1 1 export const TYPE = /** @type {const} */ ("sh.diffuse.output.facet"); 2 2 3 + export const STARTING_SET_DISABLED = [ 4 + "facets/misc/scrobble/index.html", 5 + ]; 6 + 3 7 export const STARTING_SET_URIS = [ 4 8 // INTERACTIVE 5 9 "facets/connect/index.html", ··· 11 15 "facets/data/input-bundle/index.html", 12 16 "facets/data/output-bundle/index.html", 13 17 "facets/data/process-tracks/prelude/index.html", 18 + "facets/misc/scrobble/index.html", 14 19 "facets/playback/auto-queue/prelude/index.html", 15 20 "facets/playback/preload/prelude/index.html", 16 21 ];
+8 -1
src/components/transformer/output/refiner/initial-contents/element.js
··· 5 5 import { OutputTransformer } from "../../base.js"; 6 6 import { defineElement } from "~/common/element.js"; 7 7 8 - import { STARTING_SET_URIS, TYPE } from "~/common/facets/constants.js"; 8 + import { 9 + STARTING_SET_DISABLED, 10 + STARTING_SET_URIS, 11 + TYPE, 12 + } from "~/common/facets/constants.js"; 9 13 import facets from "~/_data/facets.json" with { 10 14 type: "json", 11 15 }; ··· 80 84 $type: TYPE, 81 85 id: uriToRkey("diffuse://" + facet.url), 82 86 description: facet.desc, 87 + enabled: STARTING_SET_DISABLED.includes(facet.url) 88 + ? false 89 + : true, 83 90 kind: facet.kind === "prelude" 84 91 ? /** @type {const} */ ("prelude") 85 92 : /** @type {const} */ ("interactive"),
+129 -45
tests/common/facets/test.ts
··· 7 7 it("color returns accent-twist-4 for prelude kind", async () => { 8 8 const result = await testWeb(async () => { 9 9 const { color } = await import("~/common/facets/category.js"); 10 - return color({ $type: "sh.diffuse.output.facet", id: "1", name: "x", kind: "prelude" }); 10 + return color({ 11 + $type: "sh.diffuse.output.facet", 12 + id: "1", 13 + name: "x", 14 + kind: "prelude", 15 + }); 11 16 }); 12 17 expect(result).toBe("var(--accent-twist-4)"); 13 18 }); ··· 15 20 it("color returns accent-twist-2 for interactive kind", async () => { 16 21 const result = await testWeb(async () => { 17 22 const { color } = await import("~/common/facets/category.js"); 18 - return color({ $type: "sh.diffuse.output.facet", id: "1", name: "x", kind: "interactive" }); 23 + return color({ 24 + $type: "sh.diffuse.output.facet", 25 + id: "1", 26 + name: "x", 27 + kind: "interactive", 28 + }); 19 29 }); 20 30 expect(result).toBe("var(--accent-twist-2)"); 21 31 }); ··· 31 41 it("name returns 'feature' for prelude kind", async () => { 32 42 const result = await testWeb(async () => { 33 43 const { name } = await import("~/common/facets/category.js"); 34 - return name({ $type: "sh.diffuse.output.facet", id: "1", name: "x", kind: "prelude" }); 44 + return name({ 45 + $type: "sh.diffuse.output.facet", 46 + id: "1", 47 + name: "x", 48 + kind: "prelude", 49 + }); 35 50 }); 36 51 expect(result).toBe("feature"); 37 52 }); ··· 39 54 it("name returns 'interface' for interactive kind", async () => { 40 55 const result = await testWeb(async () => { 41 56 const { name } = await import("~/common/facets/category.js"); 42 - return name({ $type: "sh.diffuse.output.facet", id: "1", name: "x", kind: "interactive" }); 57 + return name({ 58 + $type: "sh.diffuse.output.facet", 59 + id: "1", 60 + name: "x", 61 + kind: "interactive", 62 + }); 43 63 }); 44 64 expect(result).toBe("interface"); 45 65 }); ··· 61 81 }); 62 82 expect(result).toBe("sh.diffuse.output.facet"); 63 83 }); 64 - 65 - it("STARTING_SET_URIS includes connect facet", async () => { 66 - const result = await testWeb(async () => { 67 - const { STARTING_SET_URIS } = await import("~/common/facets/constants.js"); 68 - return STARTING_SET_URIS; 69 - }); 70 - expect(result).toContain("facets/connect/index.html"); 71 - }); 72 - 73 - it("STARTING_SET_URIS includes blur artwork controller", async () => { 74 - const result = await testWeb(async () => { 75 - const { STARTING_SET_URIS } = await import("~/common/facets/constants.js"); 76 - return STARTING_SET_URIS; 77 - }); 78 - expect(result).toContain("themes/blur/artwork-controller/facet/index.html"); 79 - }); 80 - 81 - it("STARTING_SET_URIS has 9 entries", async () => { 82 - const result = await testWeb(async () => { 83 - const { STARTING_SET_URIS } = await import("~/common/facets/constants.js"); 84 - return STARTING_SET_URIS.length; 85 - }); 86 - expect(result).toBe(9); 87 - }); 88 84 }); 89 85 90 86 describe("common/facets/utils", () => { ··· 92 88 const result = await testWeb(async () => { 93 89 const { facetFromURI } = await import("~/common/facets/utils.js"); 94 90 const facet = await facetFromURI( 95 - { name: "Test", uri: "test.html", kind: undefined, description: undefined }, 91 + { 92 + name: "Test", 93 + uri: "test.html", 94 + kind: undefined, 95 + description: undefined, 96 + }, 96 97 { fetchHTML: false }, 97 98 ); 98 99 return facet.$type; ··· 104 105 const result = await testWeb(async () => { 105 106 const { facetFromURI } = await import("~/common/facets/utils.js"); 106 107 const facet = await facetFromURI( 107 - { name: "My Facet", uri: "facets/test/index.html", kind: undefined, description: undefined }, 108 + { 109 + name: "My Facet", 110 + uri: "facets/test/index.html", 111 + kind: undefined, 112 + description: undefined, 113 + }, 108 114 { fetchHTML: false }, 109 115 ); 110 116 return { name: facet.name, uri: facet.uri }; ··· 117 123 const result = await testWeb(async () => { 118 124 const { facetFromURI } = await import("~/common/facets/utils.js"); 119 125 const facet = await facetFromURI( 120 - { name: "Test", uri: "test.html", kind: undefined, description: undefined }, 126 + { 127 + name: "Test", 128 + uri: "test.html", 129 + kind: undefined, 130 + description: undefined, 131 + }, 121 132 { fetchHTML: false }, 122 133 ); 123 134 return { html: facet.html ?? null, cid: facet.cid ?? null }; ··· 130 141 const result = await testWeb(async () => { 131 142 const { facetFromURI } = await import("~/common/facets/utils.js"); 132 143 const facet = await facetFromURI( 133 - { name: "Test", uri: "test.html", kind: "prelude", description: undefined }, 144 + { 145 + name: "Test", 146 + uri: "test.html", 147 + kind: "prelude", 148 + description: undefined, 149 + }, 134 150 { fetchHTML: false }, 135 151 ); 136 152 return facet.kind; ··· 142 158 const result = await testWeb(async () => { 143 159 const { facetFromURI } = await import("~/common/facets/utils.js"); 144 160 const facet = await facetFromURI( 145 - { name: "Test", uri: "test.html", kind: "interactive", description: undefined }, 161 + { 162 + name: "Test", 163 + uri: "test.html", 164 + kind: "interactive", 165 + description: undefined, 166 + }, 146 167 { fetchHTML: false }, 147 168 ); 148 169 return facet.kind; ··· 154 175 const result = await testWeb(async () => { 155 176 const { facetFromURI } = await import("~/common/facets/utils.js"); 156 177 const facet = await facetFromURI( 157 - { name: "Test", uri: "test.html", kind: "unknown", description: undefined }, 178 + { 179 + name: "Test", 180 + uri: "test.html", 181 + kind: "unknown", 182 + description: undefined, 183 + }, 158 184 { fetchHTML: false }, 159 185 ); 160 186 return facet.kind ?? null; ··· 166 192 const result = await testWeb(async () => { 167 193 const { facetFromURI } = await import("~/common/facets/utils.js"); 168 194 const facet = await facetFromURI( 169 - { name: "Test", uri: "test.html", kind: undefined, description: "A test facet" }, 195 + { 196 + name: "Test", 197 + uri: "test.html", 198 + kind: undefined, 199 + description: "A test facet", 200 + }, 170 201 { fetchHTML: false }, 171 202 ); 172 203 return facet.description; ··· 178 209 const result = await testWeb(async () => { 179 210 const { facetFromURI } = await import("~/common/facets/utils.js"); 180 211 const facet = await facetFromURI( 181 - { name: "Test", uri: "test.html", kind: undefined, description: undefined }, 212 + { 213 + name: "Test", 214 + uri: "test.html", 215 + kind: undefined, 216 + description: undefined, 217 + }, 182 218 { fetchHTML: false }, 183 219 ); 184 220 return { createdAt: facet.createdAt, updatedAt: facet.updatedAt }; ··· 192 228 const result = await testWeb(async () => { 193 229 const { facetFromURI } = await import("~/common/facets/utils.js"); 194 230 const facet = await facetFromURI( 195 - { name: "Test", uri: "test.html", kind: undefined, description: undefined }, 231 + { 232 + name: "Test", 233 + uri: "test.html", 234 + kind: undefined, 235 + description: undefined, 236 + }, 196 237 { fetchHTML: false }, 197 238 ); 198 239 return facet.id; ··· 227 268 228 269 await insertPreludes( 229 270 [ 230 - { $type: "sh.diffuse.output.facet", id: "1", name: "A", kind: "interactive", html: "<span id='fp-interactive'></span>" }, 231 - { $type: "sh.diffuse.output.facet", id: "2", name: "B", kind: "prelude", html: "<span id='fp-prelude'></span>" }, 271 + { 272 + $type: "sh.diffuse.output.facet", 273 + id: "1", 274 + name: "A", 275 + kind: "interactive", 276 + html: "<span id='fp-interactive'></span>", 277 + }, 278 + { 279 + $type: "sh.diffuse.output.facet", 280 + id: "2", 281 + name: "B", 282 + kind: "prelude", 283 + html: "<span id='fp-prelude'></span>", 284 + }, 232 285 ], 233 286 container, 234 287 ); ··· 251 304 252 305 await insertPreludes( 253 306 [ 254 - { $type: "sh.diffuse.output.facet", id: "1", name: "Zebra", kind: "prelude", html: "<span class='fp-order'>Zebra</span>" }, 255 - { $type: "sh.diffuse.output.facet", id: "2", name: "Alpha", kind: "prelude", html: "<span class='fp-order'>Alpha</span>" }, 256 - { $type: "sh.diffuse.output.facet", id: "3", name: "Mango", kind: "prelude", html: "<span class='fp-order'>Mango</span>" }, 307 + { 308 + $type: "sh.diffuse.output.facet", 309 + id: "1", 310 + name: "Zebra", 311 + kind: "prelude", 312 + html: "<span class='fp-order'>Zebra</span>", 313 + }, 314 + { 315 + $type: "sh.diffuse.output.facet", 316 + id: "2", 317 + name: "Alpha", 318 + kind: "prelude", 319 + html: "<span class='fp-order'>Alpha</span>", 320 + }, 321 + { 322 + $type: "sh.diffuse.output.facet", 323 + id: "3", 324 + name: "Mango", 325 + kind: "prelude", 326 + html: "<span class='fp-order'>Mango</span>", 327 + }, 257 328 ], 258 329 container, 259 330 ); 260 331 261 - return Array.from(container.querySelectorAll(".fp-order")).map((el) => el.textContent); 332 + return Array.from(container.querySelectorAll(".fp-order")).map((el) => 333 + el.textContent 334 + ); 262 335 }); 263 336 264 337 expect(result).toEqual(["Alpha", "Mango", "Zebra"]); ··· 269 342 const { insertPreludes } = await import("~/common/facets/prelude.js"); 270 343 271 344 await insertPreludes([ 272 - { $type: "sh.diffuse.output.facet", id: "1", name: "Test", kind: "prelude", html: "<span id='fp-body-test'></span>" }, 345 + { 346 + $type: "sh.diffuse.output.facet", 347 + id: "1", 348 + name: "Test", 349 + kind: "prelude", 350 + html: "<span id='fp-body-test'></span>", 351 + }, 273 352 ]); 274 353 275 354 return !!document.body.querySelector("#fp-body-test"); ··· 285 364 document.body.append(container); 286 365 287 366 await insertPreludes( 288 - [{ $type: "sh.diffuse.output.facet", id: "1", name: "Empty", kind: "prelude" }], 367 + [{ 368 + $type: "sh.diffuse.output.facet", 369 + id: "1", 370 + name: "Empty", 371 + kind: "prelude", 372 + }], 289 373 container, 290 374 ); 291 375