return s
},
}
const handlers = setup(ctx) ?? {}
const scope: IslandScope = { signals, handlers }
disposers.push(...bindScope(host, scope))
}
disposers.push(
scheduleTrigger(strategy, run, {
target: host as unknown as Element,
}),
)
}
return () => {
for (const dispose of disposers) dispose()
}
}
/**
* Server-side helper: the value for a host's `data-island-state` attribute. Plain JSON - emit it
* through an escaping renderer (`@nifrajs/web-vanilla`'s `html` escapes quotes in attributes), e.g.
* `html\`…\``.
*/
export function islandState(state: Record): string {
return JSON.stringify(state)
}