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.

feat: force new worker for some input consumers

+35 -9
+7
src/common/element.d.ts
··· 13 13 html: HtmlTagFunction; 14 14 state: State; 15 15 }; 16 + 17 + export type WorkerOpts = { 18 + forceNew?: boolean | { 19 + self?: boolean; 20 + dependencies?: Record<string, boolean>; 21 + }; 22 + };
+16 -7
src/common/element.js
··· 9 9 export { keyed } from "lit-html/directives/keyed.js"; 10 10 11 11 /** 12 - * @import {BroadcastingStatus, ProvisionedWorker, ProvisionedWorkers} from "./element.d.ts" 12 + * @import {BroadcastingStatus, ProvisionedWorker, ProvisionedWorkers, WorkerOpts} from "./element.d.ts" 13 13 * @import {ProxiedActions, Tunnel} from "./worker.d.ts"; 14 14 * @import {Signal} from "./signal.d.ts" 15 15 */ ··· 166 166 167 167 /** 168 168 * @template {Record<string, (...args: any[]) => any>} Actions 169 + * @param {WorkerOpts} [opts] 169 170 * @returns {ProxiedActions<Actions>} 170 171 */ 171 - workerProxy() { 172 + workerProxy(opts) { 172 173 return workerProxy( 173 - () => this.workerTunnel().port, 174 + () => this.workerTunnel(opts).port, 174 175 ); 175 176 } 176 177 177 178 /** 178 - * @param {{ newWorker?: boolean }} [opts] 179 + * @param {WorkerOpts} [opts] 179 180 */ 180 - workerTunnel({ newWorker } = {}) { 181 + workerTunnel({ forceNew } = {}) { 181 182 // Creates a MessagePort that is connected to the worker. 182 183 // All the dependencies are added automatically. 183 - const worker = newWorker ? this.createWorker() : this.worker(); 184 + const worker = forceNew === true || 185 + (typeof forceNew === "object" && forceNew.self === true) 186 + ? this.createWorker() 187 + : this.worker(); 184 188 const deps = this.dependencies(); 185 189 186 190 let toWorker; ··· 194 198 /** @type {Array<[string, Tunnel]>} */ 195 199 const ports = Object.entries(deps).map( 196 200 /** @param {[string, DiffuseElement]} _ */ 197 - ([k, v]) => [k, v.workerTunnel()], 201 + ([k, v]) => { 202 + const n = typeof forceNew === "object" 203 + ? forceNew.dependencies?.[k] ?? false 204 + : false; 205 + return [k, v.workerTunnel({ forceNew: n })]; 206 + }, 198 207 ); 199 208 200 209 const decoded = await decodeMessage(msg);
+5 -1
src/components/orchestrator/process-tracks/element.js
··· 28 28 29 29 constructor() { 30 30 super(); 31 - this.#proxy = this.workerProxy(); 31 + this.#proxy = this.workerProxy({ 32 + forceNew: { 33 + dependencies: { input: true }, 34 + }, 35 + }); 32 36 } 33 37 34 38 // SIGNALS
+7 -1
src/components/orchestrator/search-tracks/element.js
··· 27 27 28 28 constructor() { 29 29 super(); 30 - this.#proxy = this.workerProxy(); 30 + this.#proxy = this.workerProxy({ 31 + forceNew: { 32 + dependencies: { 33 + input: true, 34 + }, 35 + }, 36 + }); 31 37 } 32 38 33 39 // LIFECYCLE