package litehouse:plugin; interface plugin { record event { id: u64, timestamp: u64, inner: update, } variant update { time(u64), temperature(float64), wind-speed(float64), current(float64), voltage(u16), power(u16), on-off(bool), } variant subscription { time(time-subscription), update(update-subscription), } variant update-subscription { temperature, wind-speed, current, voltage, power, on-off } variant time-subscription { every(every), at(u64), } record every { amount: u64, unit: time-unit, } variant time-unit { second, minute, hour, day, week, month, year, } resource runner { constructor(nickname: string, config: option); subscribe: func() -> result, u32>; update: func(events: list) -> result; } record metadata { config-schema: option, version: string, identifier: string, } get-metadata: func() -> metadata; } interface media { // An additional interface for plugins that can play media resource media { play: func() -> result; pause: func() -> result; stop: func() -> result; next: func() -> result; previous: func() -> result; } } interface switch { // An additional interface for plugins that can be turned on and off resource switch { on: func() -> result; off: func() -> result; toggle: func() -> result; } } interface notify { // An additional interface for plugins that can notify the user resource notify { notify: func(message: string) -> result; } } world plugin-host { use plugin.{event, update, subscription}; import wasi:http/outgoing-handler@0.2.0; import wasi:sockets/tcp@0.2.0; import wasi:sockets/tcp-create-socket@0.2.0; import wasi:sockets/instance-network@0.2.0; import send-update: func(nickname: string, update: update); export plugin; }