Files
deepseek-harness/apps/web/tests/fixtures/plugins/fixture-synced-config/client.js
T
imccyu bd1d6dcd0c Merge pull request #8504 from deepseek-harness/feat/client-config-live-update
feat(client): sync volatile plugin config to the browser
2026-11-17 16:08:14 +08:00

30 lines
1.0 KiB
JavaScript

/** Client face of the synced-configuration fixture: exports no Config and records what its synced Config object shows. */
window.__ModuleLoader__.load({
id: '@fixture/synced-config',
factory() {
return {
apply(ctx, config) {
const data = document.documentElement.dataset
data.syncedApplies = String(Number(data.syncedApplies ?? 0) + 1)
// References are read at operation time; `Object.keys` lists the fields the Host sent.
const publish = () => {
data.syncedConfig = JSON.stringify({
keys: Object.keys(config).sort(),
greeting: config.greeting.get(),
account: config.account.get(),
})
}
publish()
let notifications = 0
const notified = () => {
notifications++
data.syncedNotifications = String(notifications)
publish()
}
ctx.effect(() => config.greeting.subscribe(notified))
ctx.effect(() => config.account.subscribe(notified))
},
}
},
})