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.

fix: broadcasting rpc

+16 -8
+7 -4
src/common/element.js
··· 312 312 this.broadcasted = true; 313 313 this.channelName = channelName; 314 314 315 + /** @type {RpcChannel<{}, Actions>} */ 315 316 const _rpc = rpc( 316 317 msg.port2, 317 - Object.fromEntries( 318 - Object.entries(actionsWithStrategy).map(([k, v]) => { 319 - return [k, v.fn.bind(this)]; 320 - }), 318 + /** @type {Actions} */ ( 319 + Object.fromEntries( 320 + Object.entries(actionsWithStrategy).map(([k, v]) => { 321 + return [k, v.fn.bind(this)]; 322 + }), 323 + ) 321 324 ), 322 325 ); 323 326
+7 -3
src/common/worker.js
··· 174 174 //////////////////////////////////////////// 175 175 176 176 /** 177 - * @template {Record<string, (...args: any[]) => any>} Actions 177 + * @template {Record<string, (...args: any[]) => any>} LocalAPI 178 + * @template {Record<string, (...args: any[]) => any>} RemoteAPI 178 179 * @param {MessagePort | Worker | MessengerRealm} context 179 - * @param {Actions} actions 180 + * @param {RemoteAPI} actions 181 + * @returns {RpcChannel<{}, RemoteAPI>} 180 182 */ 181 183 export function rpc(context, actions) { 182 - return new RpcChannel(context, { expose: actions }); 184 + /** @type {RpcChannel<{}, RemoteAPI>} */ 185 + const channel = new RpcChannel(context, { expose: actions }); 186 + return channel; 183 187 } 184 188 185 189 ////////////////////////////////////////////
+2 -1
src/common/worker/rpc-channel.js
··· 37 37 if (!msg || msg.__rpc !== true) return; 38 38 39 39 if (msg.type === "request") { 40 - this.#handleRequest(msg); 40 + if (this.#actions) this.#handleRequest(msg); 41 41 } else if (msg.type === "response") { 42 42 this.#handleResponse(msg); 43 43 } ··· 120 120 const fn = this.#actions?.[/** @type {keyof LocalAPI} */ (method)]; 121 121 122 122 if (typeof fn !== "function") { 123 + console.log(method, id, fn, this.#actions); 123 124 this.#port.postMessage({ 124 125 __rpc: true, 125 126 id,