-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient_extensions.go
More file actions
61 lines (52 loc) · 2.05 KB
/
Copy pathclient_extensions.go
File metadata and controls
61 lines (52 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package client
// SetMode explicitly sets the compilation mode (e.g., "S", "M", "L").
// This is useful for CLI tools or programmatic control.
func (w *WasmClient) SetMode(mode string) {
w.storageMu.Lock()
defer w.storageMu.Unlock()
// Ensure mode is valid or use default shortcuts?
// The underlying UpdateCurrentBuilder handles shortcuts matching.
w.UpdateCurrentBuilder(mode)
// Also persist to DB if configured?
if w.Database != nil {
w.Database.Set(StoreKeySizeMode, mode)
}
}
// UseProductionTinyGo configures the client to compile with TinyGo in production
// (smallest possible binary). Callers (e.g. goflare) use this method instead of
// hardcoding the internal mode letter "S" — if the letter ever changes, only
// this method is updated, not every dependent.
//
// Persists the mode to disk storage so it survives across runs and is not
// silently overridden by a stale value (e.g. a previous "L" run).
func (w *WasmClient) UseProductionTinyGo() {
w.SetMode("S")
}
// UseDebugTinyGo configures the client to compile with TinyGo in debug mode.
// Useful when iterating locally and you need TinyGo-compatible builds with
// extra debug info; never for deploy.
func (w *WasmClient) UseDebugTinyGo() {
w.SetMode("M")
}
// UseStandardGo configures the client to compile with the standard Go compiler.
// Produces large binaries (2-10 MB) and is incompatible with edge environments
// that enforce a 1 MiB wasm limit. Useful only when binary size does not matter
// (e.g. local servers that load wasm in a desktop browser).
func (w *WasmClient) UseStandardGo() {
w.SetMode("L")
}
// Compile performs a synchronous compilation using the current settings.
// This exposes the underlying Storage's Compile method.
func (w *WasmClient) Compile() error {
w.storageMu.RLock()
defer w.storageMu.RUnlock()
if w.Storage == nil {
return nil
}
return w.Storage.Compile()
}
// SetOnCompile. registers a callback invoked after each compilation
// triggered by a file event. err==nil indicates success.
func (w *WasmClient) SetOnCompile(fn func(err error)) {
w.OnCompile = fn
}