Repository navigation
feat: add support for custom host calls and branding information in W… - #10
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds two new host capabilities plugins can use: a generic escape hatch for custom host functions, and live workspace branding lookup.
custom_host_call.go(wasip1):CallHostFunction(hostFn, request, response)— a low-level escape hatch for a plugin that needs a host capability beyond what this SDK exposes directly (e.g. an SMTP-sending mail plugin's outbound socket access), gated behind a manifest permission the plugin declares for itself. The plugin author still declares their own//go:wasmimportbinding using the(reqPtr, reqLen, resPtrPtr, resLenPtr int64)calling convention (CustomHostImport);CallHostFunctionhandles the JSON marshal/unmarshal and WASM linear-memory pointer plumbing this SDK already uses internally forFetch/DB/etc., so plugin authors don't have to hand-roll unsafe pointer arithmetic.wasm_imports.go/wasm_backends.go: newpaca.settings_gethost import andGetBranding()wrapper. ReturnsBrandingInfo(logo URL, brand name, light/dark primary colors) mirroring the workspace's publicGET /brandingendpoint. Meant to be called at render/send time rather than cached, so a branding change is reflected immediately in anything a plugin renders afterward (e.g. an email template).native_backends.go: matching native (non-WASM) stubs forBrandingInfo,GetBranding,CustomHostImport, andCallHostFunction, all returningerrNotWASM, so plugin code compiles and runs the same way undergo testas it does underwasip1.Deliberately not added: an
email.send-style SDK function. Sending mail is specific to one class of plugin (SMTP, and later SES/SendGrid/Mailgun), not a general-purpose capability every plugin needs — a mail plugin instead declares its own privatesend_emailgo:wasmimportbinding and drives it throughCallHostFunction.Test plan
go build ./...,go vet ./...clean (native)GOOS=wasip1 GOARCH=wasm go build ./...clean