From 3fc59a96b94dab25154348386ec834029052f4f8 Mon Sep 17 00:00:00 2001 From: Steven Vandevelde Date: Mon, 9 Feb 2026 22:42:25 +0100 Subject: [PATCH] fix: process sources after adding a source --- src/common/constituents/foundation.js | 11 +++++++++-- .../orchestrator/process-tracks/element.js | 1 - src/components/orchestrator/sources/element.js | 1 - src/themes/webamp/configurators/input/index.js | 13 +++++++++++++ 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/common/constituents/foundation.js b/src/common/constituents/foundation.js index 0a1376ba..36b7ba78 100644 --- a/src/common/constituents/foundation.js +++ b/src/common/constituents/foundation.js @@ -199,7 +199,11 @@ function output() { return findExistingOrAdd(o); } -function processTracks() { +/** + * @param {Object} opts - Options + * @param {boolean} [opts.disableWhenReady] - Whether to disable processing when ready. + */ +function processTracks(opts = { disableWhenReady: false }) { const i = input(); const o = output(); const m = metadata(); @@ -209,7 +213,10 @@ function processTracks() { opt.setAttribute("input-selector", i.selector); opt.setAttribute("output-selector", o.selector); opt.setAttribute("metadata-processor-selector", m.selector); - opt.toggleAttribute("process-when-ready"); + + if (!opts.disableWhenReady) { + opt.toggleAttribute("process-when-ready"); + } return findExistingOrAdd(opt); } diff --git a/src/components/orchestrator/process-tracks/element.js b/src/components/orchestrator/process-tracks/element.js index 806d3577..e7744002 100644 --- a/src/components/orchestrator/process-tracks/element.js +++ b/src/components/orchestrator/process-tracks/element.js @@ -2,7 +2,6 @@ import { BroadcastableDiffuseElement, query } from "@common/element.js"; import { signal, untracked } from "@common/signal.js"; /** - * @import {Track} from "@definitions/types.d.ts" * @import {ProxiedActions} from "@common/worker.d.ts" * @import {InputElement} from "@components/input/types.d.ts" * @import {OutputElement} from "@components/output/types.d.ts" diff --git a/src/components/orchestrator/sources/element.js b/src/components/orchestrator/sources/element.js index 085be547..41be7bb5 100644 --- a/src/components/orchestrator/sources/element.js +++ b/src/components/orchestrator/sources/element.js @@ -3,7 +3,6 @@ import { groupTracksPerScheme } from "@common/utils.js"; import { signal } from "@common/signal.js"; /** - * @import {Track} from "@definitions/types.d.ts" * @import {InputElement, Source} from "@components/input/types.d.ts" * @import {OutputElement} from "@components/output/types.d.ts" */ diff --git a/src/themes/webamp/configurators/input/index.js b/src/themes/webamp/configurators/input/index.js index 940e2e9f..fb7c4ded 100644 --- a/src/themes/webamp/configurators/input/index.js +++ b/src/themes/webamp/configurators/input/index.js @@ -1,8 +1,10 @@ import foundation from "@common/constituents/foundation.js"; import InputConfigElement from "@themes/webamp/configurators/input/element.js"; +import { effect } from "@common/signal.js"; const inp = foundation.orchestrator.input(); const out = foundation.orchestrator.output(); +const pro = foundation.orchestrator.processTracks({ disableWhenReady: true }); const sou = foundation.orchestrator.sources(); const el = new InputConfigElement(); @@ -11,3 +13,14 @@ el.setAttribute("output-selector", out.selector); el.setAttribute("sources-orchestrator-selector", sou.selector); document.querySelector("#placeholder")?.replaceWith(el); + +// EFFECTS + +let initEffect = false; + +effect(() => { + const _trigger = sou.sources(); + if (out.tracks.state() !== "loaded") return; + if (initEffect) pro.process(); + initEffect = true; +}); -- 2.54.0