Skip to content

feat: freeze data-* attribute API and add data-sync-ms (closes #23, closes #1)#27

Merged
kasunben merged 1 commit into
mainfrom
feat/freeze-data-attr-api
Jun 7, 2026
Merged

feat: freeze data-* attribute API and add data-sync-ms (closes #23, closes #1)#27
kasunben merged 1 commit into
mainfrom
feat/freeze-data-attr-api

Conversation

@kasunben

@kasunben kasunben commented Jun 7, 2026

Copy link
Copy Markdown
Owner

Summary

Closes #23 — audit and freeze the data-* attribute interface ahead of v1.
Also closes #1 — configurable poll interval via data-sync-ms.

  • Names confirmed, no renames. The five existing attributes are consistent within their type category (-url for URL values, -id for identifier values) and ready to commit as a stable v1 interface.
  • data-sync-ms implemented — configurable server sync poll interval (Mode 3 only); defaults to 30 000 ms; values ≤ 0 or non-numeric fall back to 30 s with a console.warn; replaces the hardcoded 30000 in setInterval.
  • Mutual exclusivity enforced at runtime — previously only a comment in the code; now console.warn fires and initP2P() is suppressed when both data-sync-url and data-room-id are set (if (_roomId && !_syncUrl)).
  • ## Script tag API section added to README — stable 6-attribute reference table with types, defaults, and the mutual-exclusivity note; positioned after Quick start for maximum discoverability.
  • CLAUDE.md updateddata-sync-ms row in the attribute table; two new Key Implementation Notes for _pollMs and the mutual-exclusivity guard.

Stable attribute table (as documented)

Attribute Type Default
data-site-id string "default"
data-sync-url URL
data-room-id UUID
data-relay-url WSS URL hosted relay
data-admin-id UUID
data-sync-ms integer (ms) 30000

Test plan

  • demo.html (offline) — no console warnings
  • demo-sync-with-server.html — no warnings; polls every 30 s
  • Both data-sync-url + data-room-id set → console.warn fires, P2P not initialized
  • data-sync-ms="5000" → polls every 5 s (verified via Network tab)
  • data-sync-ms="bad" / "-1" / "0"console.warn fires, falls back to 30 s
  • npm run test:coverage → 82 tests pass (server unchanged)
  • npm run test:e2e → 14/15 pass (1 pre-existing IDB flake; passes in isolation and covered by CI retries: 2)

🤖 Generated with Claude Code

…loses #1)

Stable public interface documented ahead of v1:
- data-site-id, data-sync-url, data-room-id, data-relay-url,
  data-admin-id confirmed — no renames needed; names are consistent
  within type category (-url for URLs, -id for identifiers, -ms for ms)
- data-sync-ms added: configurable server-sync poll interval (Mode 3
  only); defaults to 30 000 ms; invalid values fall back with a
  console.warn

Runtime enforcement:
- Mutual exclusivity of data-sync-url and data-room-id now enforced:
  console.warn fires and initP2P() is suppressed when both are set
  (previously only a code comment, no runtime guard)

Documentation:
- README: new ## Script tag API section with stable 6-attribute
  reference table positioned after Quick start
- CLAUDE.md: data-sync-ms row added to attribute table; Key
  Implementation Notes updated for _pollMs and the mutual-exclusivity guard

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@kasunben kasunben merged commit ccb8de4 into main Jun 7, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Audit and freeze the data-* attribute interface ahead of v1 Allow poll interval to be configured via data-sync-ms attribute (Server-sync mode only)

1 participant