datapages-state
БесплатноБез исполняемых скриптовНе проверенAdd per-tab Datapages State[T], initialize and use it in handlers, dispatch state-scoped events, and configure the live instance limit. Activate when a…
от romshark★ 122 звезды на GitHubОб этом скилле
Per-tab state
Read datapages first for the build loop, hard rules and naming conventions.
Declare T as an exported, package-level struct in the app package. State[T] rejects pointers, anonymous structs and types from other packages. A page is stateful when one of its actions, On handlers or stream hooks takes datapages.State[T].
Every stateful handler on a page must use the same T. An app-level action may take State[T] only when the calling page uses that type. A mismatch returns 409 with Datapages-Retry: reconnect. Keep actions used by pages with different state types stateless.
type StateIndex struct{ Filter string }
func (PageIndex) StreamOpen(
r *http.Request, state datapages.State[StateIndex],
) error {
state.Values.Filter = "all"
return nil
}
GET cannot take state. The server allocates state when the tab connects its SSE stream. A stateful page gets a stream even when it has no stream hooks or event handlers. The server runs stateful handlers for 1 tab serially. They can read and write state.Values without another mutex.
A disconnect deletes the instance. A reconnect starts with a zero value. Initialize it in StreamOpen from the URL or signals when needed.
GET may return datapages.EnableBackgroundStreaming(true) to keep the stream and state active while the tab is hidden. This also disables the default refresh when the tab becomes visible. datapages.DisableRefreshAfterHidden(true) disables that refresh without preserving the stream or state. Only pages with a stream refresh after being hidden. Returning either value from a page without a stream is an error.
Do not retain state.Values after the handler returns. Do not capture it in a goroutine or a component that renders later. Copy the required fields instead. A returned datapages.File is served after the tab's lock is released: its Body must not read state.Values.
State exists in 1 server process. Route a tab's stream and actions to the same server with Datapages-Instance as the routing key. The instance ID script is inline: a Content-Security-Policy must allow script-src 'unsafe-inline' or set a nonce through WithCSPNonce. See datapages-server.
Events for 1 tab
A stateful handler may take stateID string with State[T]. Put the value in an event's datapages.SubjectStateID field to address that tab:
// EventFilterChanged is "filter.changed"
type EventFilterChanged struct {
Tab datapages.SubjectStateID
}
It must be the event's only subject field and cannot have a signal tag. A page that handles the event must use state. That page cannot also handle a user-addressed or signal-scoped event. stateID selects the event recipient. It does not provide access to the state value.
Limit
Each server allows datapages.DefaultMaxConcurrentInstances live instances by default. Change the limit with datapages.WithStateConfig(datapages.StateConfig{MaxConcurrentInstances: n}). When the server reaches the limit, a new stream receives 503 with Retry-After.
Установить datapages-state в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл datapages-state?
Add per-tab Datapages State[T], initialize and use it in handlers, dispatch state-scoped events, and configure the live instance limit. Activate when a Datapages page needs server-side values that belong to 1 browser tab.
Как установить скилл datapages-state?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл datapages-state запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic