1 //:build !wasm
2 3 // Package relayproxy is the bridge for the musiquay relay-proxy worker boundary.
4 // Two function sets in one package, used in different contexts:
5 //
6 // - Worker-internal (used only inside relay-proxy.wasm):
7 // OnMessage, Post.
8 //
9 // - Consumer-side (used only inside app.wasm):
10 // Send, OnMessage (consumer variant; route differs from worker variant).
11 //
12 // Functions called only from one context are dead-code-eliminated by the
13 // linker for the other context, so the two function sets do not pollute
14 // each other's wasm imports.
15 //
16 // Wire format on both directions: JSON-array MW-shape strings.
17 // e.g. ["REQ","sub-1",{"kinds":[1],"limit":50},["wss://relay.damus.io"]]
18 // e.g. ["EVENT","sub-1",{<event-json>}]
19 package relayproxy
20 21 // === Consumer-side (app.wasm) ===
22 23 // Send dispatches a JSON-array message to the relay-proxy worker via the
24 // supervisor. The worker decodes and acts on it.
25 func Send(msg string) { panic("jsbridge") }
26 27 // OnMessage registers a handler for messages from the relay-proxy worker.
28 // fn receives the raw JSON-array string; the consumer parses it.
29 func OnMessage(fn func(msg string)) { panic("jsbridge") }
30 31 // === Worker-internal (relay-proxy.wasm) ===
32 33 // WorkerOnMessage registers a handler for inbound messages on the worker
34 // side. JSON-array strings posted by the supervisor (originating from
35 // app.wasm or from internal sources) are delivered here.
36 func WorkerOnMessage(fn func(msg string)) { panic("jsbridge") }
37 38 // WorkerPost sends a JSON-array message back to the supervisor over the
39 // worker's natural postMessage channel. The supervisor forwards to app.wasm.
40 func WorkerPost(msg string) { panic("jsbridge") }
41 42 // WorkerSetTimeout schedules fn to run after ms milliseconds. Returns a
43 // handle for WorkerClearTimeout.
44 func WorkerSetTimeout(ms int32, fn func()) (n int32) { panic("jsbridge") }
45 46 // WorkerClearTimeout cancels a pending timeout by handle.
47 func WorkerClearTimeout(handle int32) { panic("jsbridge") }
48 49 // WorkerNowSeconds returns the current Unix time in seconds via Date.now().
50 func WorkerNowSeconds() (n int64) { panic("jsbridge") }
51