diff --git a/_config.ts b/_config.ts index e4a1a8cf..cc03c29b 100644 --- a/_config.ts +++ b/_config.ts @@ -194,7 +194,7 @@ site.filter("facetLoaderURL", (text) => { key = "uri"; } - return `kitchen/l/?${key}=${encodeURIComponent(text)}`; + return `l/?${key}=${encodeURIComponent(text)}`; }); //////////////////////////////////////////// diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 6f9ff650..5e23ccc0 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -25,14 +25,9 @@ A lot of components will have a worker (located in `worker.js` besides the `elem `src/definitions/` are lexicons, JSON schemas that describe data in the system. -## Themes - -Like orchestrator components, these are compositions of elements. Unlike orchestrators however, it doesn't compose by the use of selectors, instead we write the custom elements as HTML and use the DOM as the composition layer. Alternatively, custom elements can be created in Javascript and then added to the DOM from there. - - ## Other directories - `src/common`: Common Javascript code shared by various components and/or themes. - `src/styles`: Common CSS shared by themes, the index page or facets. - `src/favicons`, `src/fonts`, `src/images` are binary assets for themes and the index page (`src/index.vto`) -- `src/_components` and `src/_includes` are templates used in `.vto` templates, again themes and index page. +- `src/_components` and `src/_includes` are templates used in `.vto` templates. diff --git a/src/_components/element.vto b/src/_components/element.vto index 43ad6650..fdd36416 100644 --- a/src/_components/element.vto +++ b/src/_components/element.vto @@ -1,5 +1,7 @@
-

{{title}}

+ {{ set slug = title.toLowerCase().replace(/\s+/g, '-') }} + +

{{title}}

{{content}} diff --git a/src/_components/facets/examples.vto b/src/_components/examples.vto similarity index 100% rename from src/_components/facets/examples.vto rename to src/_components/examples.vto diff --git a/src/_components/facets/grid.vto b/src/_components/grid.vto similarity index 100% rename from src/_components/facets/grid.vto rename to src/_components/grid.vto diff --git a/src/_components/facets/nav.vto b/src/_components/nav.vto similarity index 50% rename from src/_components/facets/nav.vto rename to src/_components/nav.vto index ed06157f..12c02cb3 100644 --- a/src/_components/facets/nav.vto +++ b/src/_components/nav.vto @@ -2,28 +2,28 @@ {{ set slug = (cat) => cat.toLowerCase().replace(/\s+/g, '-') }}

- -
-

Usage

- -
-
-

- Diffuse is not your typical streaming service, we have to add sources of audio so we have stuff to play. This button below adds some demo content, so you can experiment with the software right away. -

- -

- -

-
- -
-

- If you do already have a place where you keep your audio files and want to connect it first thing, browse through all the various services that can be connected to Diffuse. -

- -

Look for "Connect ..."

- -

- Discover integrations -

-
-
- -
-
-

- Great, one of the hardest parts is already done. Now we should explore what is possible with our audio. Because Diffuse is cooperative and malleable software, our interface can look like anything, and we can pick the features we like. That might sound overwhelming, so let's keep it simple for now. -

-
- -
-

- Let's pick an interface that automatically puts audio from our collection into the queue, and another to play what got put into the queue. -

- -

- - - - - Fill up queue - - - - - - Play audio - - - -

-
-
- -
-
-

- So you said I could pick the features and interfaces that I liked, how does that work? -

- -

- To do that, we have to visit our kitchen. There you'll be able to browse through all the features and interfaces that are provided by Diffuse. To use a feature, you click the toggle to enable it, this will add it to your software. Interfaces can be added too, but it's not required, you can try them out right away by clicking the link in their title. -

- -

- Explore the kitchen -

-
- -
-

- What you mean, my software? What is software anyways? -

- -

- When we say software, we mean, having a user interface or code that manipulates your data in some way. Because you are picking those pieces that change how it looks and behaves, you are composing your own software, you made it yours. -

-
-
- -
-
-

- What is a feature exactly? -

- -

- A feature is a piece of code that expands the capabilities of your software or that makes it behave in a certain kind of way. It runs each time you open an interface, but may not necessarily be activated. Some examples, support for a particular audio source, or always add things automatically to the queue. -

-
- -
-

- What makes it cooperative? -

- -

- These features and interfaces aren't required to be built into Diffuse, they can come from any place on the web. This makes it cooperative, you can share your features and interfaces, and use ones from other people. Any of these can be edited by clicking the edit button on the "your software" page. -

-
-
- -
-
-

- How do I sync my data with my other devices? -

- -

- # -

-
-
-
- - -
-

Developers

- -

- If you're a programmer, you can use the (web) components of the system. These custom elements can be combined into an entire music player and browser, or whatever you want to build. -

- -

- Consume these using the kitchen build tool, the Javascript package, or the linked Javascript files down below. -

- -
- {{ await comp.element({ - title: "Configurators", - items: configurators, - content: ` - Elements that serve as an intermediate in order to make a particular kind of element configurable. In other words, these allow for an element to be swapped out with another that takes the same set of the actions and data output. - ` - }) }} - - {{ await comp.element({ - title: "Engines", - items: engines, - content: ` - Elements with each a singular purpose and don't have any UI. There are specialised UI and orchestrator elements that control these. - ` - }) }} - - {{ await comp.element({ - title: "Input", - items: input, - content: ` - Inputs are sources of audio tracks. Each track is an entry in the list of possible items to play. These can be files or streams, static or dynamic. - ` - }) }} - - {{ await comp.element({ - title: "Orchestrators", - items: orchestrators, - content: ` - These too are element compositions. However, unlike themes, these are purely logical. Mostly exist in order to construct sensible defaults to use across themes and other compositions. - ` - }) }} - - {{ await comp.element({ - title: "Output", - items: output, - content: ` - Output is application-derived data such as playlists. These elements can receive such data and keep it around. These are categorised by the type of data they ingest, or many types in the case of polymorphic. Optionally use transformers to convert output into the expected format. - ` - }) }} - - {{ await comp.element({ - title: "Processors", - items: processors, - content: ` - These elements work with the output generated by the input elements to add more data to them, or process them in some other way. - ` - }) }} - - {{ await comp.element({ - title: "Supplements", - items: supplements, - content: ` - Additional elements, such as scrobblers. - ` - }) }} - - {{ await comp.element({ - title: "Transformers", - items: transformers, - content: ` - Transform data from one format or schema into another. See schema section below for more information. Just as configurators, these are intermediates and require to have the same set of actions as the element it targets. - ` - }) }} -
-
- - -
-
-

Definitions

- -

All of the elements here are built with these data definitions in mind. That said, you can mix elements that use different definitions; you just have to put a transformer between them in order to translate between them, if needed.

- - {{ await comp.list({ items: definitions }) }} -
- -
- - - {{ await comp.list({ items: links }) }} -
-
diff --git a/src/kitchen/guide.vto b/src/kitchen/guide.vto deleted file mode 100644 index f07763cb..00000000 --- a/src/kitchen/guide.vto +++ /dev/null @@ -1,46 +0,0 @@ ---- -layout: layouts/kitchen.vto -base: ../../ -title: Guide | Kitchen | Diffuse ---- - -

Guide

- -
-
-

Getting started

- -

- To get started you can browse existing facets here on these pages, find one you like and then either you click the link in the title in case it's an interface. Or, you save it to your collection by using the toggle if it's a feature, which will activate it. -

-

- For example, say you want to play music; two options would be: (1) browse for a specific song and add it to the queue, or (2) automatically 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 controller could be used. -

-

- You might ask, why can't I do all of this in just one window? That's what themes are for, if you need something more streamlined. If you however want a customised experience, or prefer certain interfaces for certain things with an infinite number of optional features, that's what facets are for. -

-

- Every facet has access to your audio collection and your user data, along with any other shared state, be mindful of which facets you're interacting with. -

-
- -
-

Concept

- -

- Facets are unlike traditional software; instead of combining several features into a single user interface and producing data output, we do the opposite, we start with the data and work our way up from there. -

- -

- It provides every user the ability to choose what features and interface they want to layer on top of their data. -

- -

- Facets can provide any amount of features and user interface they see fit. The key here is that the user can combine facets because the components that consist of it are connected, they broadcast their state and your data that has been updated. -

- -

- Finally, facets are just regular web pages so they can live wherever. We save them to the user-data storage that's configured and give the user the option to share it. This means that you can load facets from other people, building software cooperatively. -

-
-
diff --git a/src/kitchen/index.vto b/src/kitchen/index.vto deleted file mode 100644 index c60c5be7..00000000 --- a/src/kitchen/index.vto +++ /dev/null @@ -1,11 +0,0 @@ ---- -layout: layouts/kitchen.vto -base: ../ -title: Featured | Kitchen | Diffuse ---- - -

Featured

- -
- {{ await comp.facets.grid({ id: "featured", items: facets.filter(f => f.featured) }) }} -
diff --git a/src/kitchen/l/index.js b/src/l/index.js similarity index 100% rename from src/kitchen/l/index.js rename to src/l/index.js diff --git a/src/kitchen/l/index.vto b/src/l/index.vto similarity index 93% rename from src/kitchen/l/index.vto rename to src/l/index.vto index b2863bdc..5014a0a0 100644 --- a/src/kitchen/l/index.vto +++ b/src/l/index.vto @@ -8,7 +8,7 @@ styles: - styles/loader.css scripts: - - facets/l/index.js + - l/index.js ---
diff --git a/src/styles/diffuse/colors.css b/src/styles/diffuse/colors.css index c225886d..188a8ddd 100644 --- a/src/styles/diffuse/colors.css +++ b/src/styles/diffuse/colors.css @@ -4,8 +4,8 @@ --color-2: oklch(98.369% 0.01834 67.664); --color-3: oklch(26.787% 0.00168 186.65); - /* Green */ - --accent: hsl(82, 39%, 30.2%); + /* Accent */ + --accent: oklch(0.49552082493478433 0.08959833768631711 126.18581796616421); /* Based on accent */ --accent-twist-1: oklch(0.4394087182327507 0.07236154661033459 126.18581796616421); @@ -28,14 +28,14 @@ @media (prefers-color-scheme: dark) { :root { - --accent: #9e86b8; + --accent: oklch(0.9588262863391736 0.06116191577190922 140.4794385054261); /* Based on accent */ - --accent-twist-1: oklch(0.8304625409973806 0.04463693607878053 306.25919097736113); - --accent-twist-2: oklch(0.8598598403285739 0.0562638076130437 71.2592389751063); - --accent-twist-3: oklch(0.9098598401854464 0.04000001621772218 71.25925756817853); - --accent-twist-4: oklch(0.759859834391464 0.0968658786601377 181.2591638095228); - --accent-twist-5: oklch(0.5798598316017731 0.08000002153797516 181.25916489227464); + --accent-twist-1: oklch(0.990000017539932 0.040000057532729824 140.4794373213467); + --accent-twist-2: oklch(0.8588262791075975 0.05264925002780416 250.47942154450243); + --accent-twist-3: oklch(0.6788262741405414 0.07999998302468042 250.47944272057788); + --accent-twist-4: oklch(0.758826283102734 0.08415801238169258 15.479456004219076); + --accent-twist-5: oklch(0.4288262770395823 0.05680666043681931 15.47945273215004); /* Derivatives */ --bg-color: var(--color-3); diff --git a/src/styles/diffuse/page.css b/src/styles/diffuse/page.css index 1c4ce119..9b07ab5a 100644 --- a/src/styles/diffuse/page.css +++ b/src/styles/diffuse/page.css @@ -459,6 +459,10 @@ a.button { small { font-size: var(--fs-xs); + + a { + text-underline-offset: 3px; + } } .button-col { @@ -576,6 +580,10 @@ ul li::marker { opacity: 0.25; } } + + &.diffuse-logo-container--condensed { + margin-bottom: var(--space-lg); + } } /** @@ -614,6 +622,11 @@ nav { text-decoration: none; transition-duration: 250ms; transition-property: opacity; + + &:hover, + &:focus { + opacity: 1; + } } a.hidden { @@ -627,6 +640,14 @@ nav { } } +#status--filler-container { + align-items: center; + display: flex; + height: 100%; + justify-content: end; + padding: 0 var(--space-lg); +} + /** * 😶‍🌫️ */ diff --git a/src/themes/index.js b/src/themes/index.js deleted file mode 100644 index eb689063..00000000 --- a/src/themes/index.js +++ /dev/null @@ -1,291 +0,0 @@ -import { html, render } from "lit-html"; -import { keyed } from "lit-html/directives/keyed.js"; - -import { basicSetup, EditorView } from "codemirror"; -import { css as langCss } from "@codemirror/lang-css"; -import { html as langHtml } from "@codemirror/lang-html"; -import { javascript as langJs } from "@codemirror/lang-javascript"; -import { autocompletion } from "@codemirror/autocomplete"; - -import * as TID from "@atcute/tid"; - -import * as CID from "~/common/cid.js"; -import foundation from "~/common/facets/foundation.js"; -import { effect, signal } from "~/common/signal.js"; -import { themeFromURI } from "~/common/themes/utils.js"; -import { loadURI } from "~/common/loader.js"; - -/** - * @import {Theme} from "~/definitions/types.d.ts" - */ - -//////////////////////////////////////////// -// SAVE & FORK -//////////////////////////////////////////// - -document.body.addEventListener( - "click", - /** - * @param {MouseEvent} event - */ - async (event) => { - const target = /** @type {HTMLElement} */ (event.target); - const rel = target.getAttribute("rel"); - if (!rel) return; - - const uri = target.closest("li")?.getAttribute("data-uri"); - if (!uri) return; - - const name = target.closest("li")?.getAttribute("data-name"); - if (!name) return; - - switch (rel) { - case "fork": { - const theme = await themeFromURI({ name, uri }, { fetchHTML: true }); - editTheme(theme); - document.querySelector("#build")?.scrollIntoView(); - break; - } - case "save": { - const theme = await themeFromURI({ name, uri }, { fetchHTML: false }); - const out = await foundation.orchestrator.output(); - - const col = out.themes.collection(); - out.themes.save([ - ...(col.state === "loaded" ? col.data : []), - theme, - ]); - break; - } - } - }, -); - -//////////////////////////////////////////// -// YOUR COLLECTION -//////////////////////////////////////////// - -/** @type {HTMLElement | null} */ -const listEl = document.querySelector("#list"); -if (!listEl) throw new Error("List element not found"); - -listEl.innerHTML = ""; - -const output = await foundation.orchestrator.output(); - -effect(() => { - const themesCol = output.themes.collection(); - const col = themesCol.state === "loaded" - ? [...themesCol.data].sort((a, b) => { - return a.name.toLocaleLowerCase().localeCompare(b.name.toLocaleLowerCase()); - }) - : []; - - const h = col.length && themesCol.state === "loaded" - ? html` - - ` - : themesCol.state === "loaded" - ? emptyThemesList - : html` -
- - Loading items -
- `; - - render(h, listEl); -}); - -const emptyThemesList = html` -

- You have not saved any themes yet. -

-`; - -/** - * @param {{ id: string }} _ - */ -function deleteTheme({ id }) { - return () => { - const c = confirm("Are you sure you want to delete this theme?"); - if (!c) return; - - const col = output.themes.collection(); - if (col.state !== "loaded") return; - output.themes.save(col.data.filter((c) => !(c.id === id))); - }; -} - -//////////////////////////////////////////// -// BUILD -//////////////////////////////////////////// - -const $editingTheme = signal(/** @type {Theme | null} */ (null)); - -// Code editor -const editorContainer = document.body.querySelector("#html-input-container"); -if (!editorContainer) throw new Error("Editor container not found"); - -const editor = new EditorView({ - parent: editorContainer, - doc: ``.trim(), - extensions: [ - basicSetup, - langHtml(), - langCss(), - langJs(), - autocompletion(), - ], -}); - -// Form submit -document.querySelector("#build-form")?.addEventListener( - "submit", - onBuildSubmit, -); - -/** - * @param {Event} event - */ -async function onBuildSubmit(event) { - event.preventDefault(); - - const nameEl = /** @type {HTMLInputElement | null} */ (document.querySelector( - "#name-input", - )); - - const html = editor.state.doc.toString(); - const cid = await CID.create(0x55, new TextEncoder().encode(html)); - const name = nameEl?.value ?? "nameless"; - - /** @type {Theme} */ - const theme = $editingTheme.value - ? { - ...$editingTheme.value, - cid, - html, - name, - } - : { - $type: "sh.diffuse.output.theme", - id: TID.now(), - cid, - html, - name, - }; - - switch (/** @type {any} */ (event).submitter.name) { - case "save": - await saveTheme(theme); - break; - case "save+open": - await saveTheme(theme); - globalThis.open(`./themes/l/?id=${theme.id}`, "blank"); - break; - } -} - -/** - * @param {Theme} ogTheme - */ -async function editTheme(ogTheme) { - const theme = { ...ogTheme }; - const nameEl = /** @type {HTMLInputElement | null} */ (document.querySelector( - "#name-input", - )); - - if (!nameEl) return; - - // Make sure HTML is loaded - if (!theme.html && theme.uri) { - const html = await loadURI(theme.uri); - const cid = await CID.create(0x55, new TextEncoder().encode(html)); - - theme.html = html; - theme.cid = cid; - } - - $editingTheme.value = theme; - nameEl.value = theme.name; - - editor.dispatch({ - changes: { from: 0, to: editor.state.doc.length, insert: theme.html }, - }); -} - -/** - * @param {Theme} theme - */ -async function saveTheme(theme) { - const col = output.themes.collection(); - const data = col.state === "loaded" ? col.data : []; - const colWithoutId = data.filter((c) => c.id !== theme.id); - await output.themes.save([...colWithoutId, { - ...theme, - updatedAt: new Date().toISOString(), - }]); -} diff --git a/src/themes/index.vto b/src/themes/index.vto deleted file mode 100644 index 534f9079..00000000 --- a/src/themes/index.vto +++ /dev/null @@ -1,130 +0,0 @@ ---- -layout: layouts/diffuse.vto -base: ../ - -styles: - - styles/base.css - - styles/diffuse/page.css - - vendor/@phosphor-icons/bold/style.css - - vendor/@phosphor-icons/fill/style.css - -scripts: - - themes/index.js - - common/pages/version-upgrade.js - -# THEMES - -builtIn: - - url: "themes/blur/" - title: "Blur" - todo: true - desc: > - **A theme with an Apple-inspired playback view.** Features two audio players instead of the usual one. - - url: "themes/webamp/" - title: "Webamp" - desc: > - **Winamp 2 + Windows 98**. Uses Webamp as the audio player connected to various Diffuse elements. Also features a desktop-like Windows 98 environment in which you can open "programs" that control the used Diffuse elements. ---- - -
-
-
- - {{ await comp.diffuse.logo() }} - - {{ await comp.diffuse.status() }} -
- -

- Themes -

- -

- Themes are element compositions and provide a traditional browser web application way of - using them. In other words, pretty much the whole thing, besides your data, lives inside a single browser tab. -

- -

- - - Each theme is unique, not just a skin; each one might have a totally different feature set. - -

- - -
-
-
-
- -
-
-

Built-in

- - {{ await comp.list({ items: builtIn }) }} -
- -
-

Community

-

- Check out some themes from the community and load them here. -

-

- Nothing here yet, too early. -

-
-
- - -
-
-

Your collection

-
-
- - Loading items -
-
-
- -
-
- - -
- - -
-

Build

- -
-
-

- If you know a bit of HTML & Javascript, you can write your own or plug in some code you found elsewhere: -

- -
-
-
- -
-

- Your code here will be loaded in a dedicated page, it'll be injected into a <iframe> element in the body. You have access to the elements listed on the index page and the facets foundation. -

- -

- - - - -

-
-
-
- -
diff --git a/src/themes/l/index.css b/src/themes/l/index.css deleted file mode 100644 index db9d60f7..00000000 --- a/src/themes/l/index.css +++ /dev/null @@ -1,12 +0,0 @@ -body { - margin: 0; - overflow: hidden; - padding: 0; -} - -iframe { - border: 0; - display: block; - height: 100dvh; - width: 100%; -} diff --git a/src/themes/l/index.js b/src/themes/l/index.js deleted file mode 100644 index 93db84f8..00000000 --- a/src/themes/l/index.js +++ /dev/null @@ -1,33 +0,0 @@ -import foundation from "~/common/facets/foundation.js"; -import * as CID from "~/common/cid.js"; -import { createLoader, renderError } from "~/common/loader.js"; - -const output = await foundation.orchestrator.output(); - -createLoader({ - $type: "sh.diffuse.output.theme", - label: "Theme", - source: () => output.themes, - async render(theme) { - if (theme.cid) { - const valid = await CID.verify( - new TextEncoder().encode(theme.html ?? ""), - theme.cid, - ); - - if (!valid) { - renderError( - document.body, - "CID mismatch: HTML content does not match the CID", - ); - return; - } - } - - const iframe = document.createElement("iframe"); - iframe.srcdoc = theme.html ?? ""; - - document.body.innerHTML = ""; - document.body.append(iframe); - }, -}); diff --git a/src/themes/l/index.vto b/src/themes/l/index.vto deleted file mode 100644 index f4fa9bdf..00000000 --- a/src/themes/l/index.vto +++ /dev/null @@ -1,21 +0,0 @@ ---- -layout: layouts/diffuse.vto -base: ../../ - -styles: - - vendor/@phosphor-icons/fill/style.css - - styles/base.css - - styles/loader.css - - themes/l/index.css - -scripts: - - themes/l/index.js ---- - -
-
-
- -
-
-