//go:build !wasm //:build !wasm // Package httpproxy is the bridge for the smesh HTTP-proxy worker boundary. // Two function sets in one package, used in different contexts: // // - Worker-internal (used only inside http-proxy.wasm): // OnMessage, Post, Fetch, Cancel, RevokeBlob. // // - Consumer-side (used only inside app.wasm): // Request, RequestCancel. // // Functions called only from one context are dead-code-eliminated by the // linker for the other context, so the two function sets do not pollute // each other's wasm imports. package httpproxy // === Consumer-side: app.wasm asking the worker to do a fetch === // Request asks the http-proxy worker to fetch url and return a Blob URL. // onOK is called with (blobURL, contentType) on success. // onFail is called with (status, errMsg) on failure. // reqID must be unique per outstanding request; the same ID is used as the // correlation key for matching the result. // priority: higher values dispatched first; 0 is the default tier. func Request(reqID int32, url string, priority int32, onOK func(blobURL, contentType string), onFail func(status int32, errMsg string)) { panic("jsbridge") } // RequestCancel cancels an outstanding request by ID. func RequestCancel(reqID int32) { panic("jsbridge") } // === Worker-internal: http-proxy.wasm talking to its host shim === // OnMessage registers a handler for inbound messages. // fn receives the raw string payload (JSON-array shape: ["TYPE", arg1, arg2, ...]). // The same handler is invoked for messages from the page and for synthetic // internal messages (__FETCH_OK, __FETCH_FAIL) that the JS shim re-injects // after a fetch completes; the moxie code distinguishes by message type. func OnMessage(fn func(msg string)) { panic("jsbridge") } // Post sends a string message back to the page over the worker's natural // postMessage channel. func Post(msg string) { panic("jsbridge") } // Fetch issues an HTTP GET against the smesh /proxy/ endpoint // derived from url. The JS shim performs the fetch, builds a Blob URL on // success, and re-injects the result into OnMessage as either // ["__FETCH_OK", reqID, status, contentType, blobURL] or // ["__FETCH_FAIL", reqID, status, errMsg]. func Fetch(reqID int32, url string) { panic("jsbridge") } // Cancel aborts an in-flight fetch identified by reqID. No-op if the // request has already completed or never started. func Cancel(reqID int32) { panic("jsbridge") } // RevokeBlob releases the underlying Blob held by a blob: URL. Call this // when evicting from the LRU; without it the Blob is retained for the // lifetime of the worker. func RevokeBlob(url string) { panic("jsbridge") }