@thanhnguyxn/pixelcraft 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/plugins/marketplace.json +1 -1
- package/.antigravity-plugin/plugin.json +32 -0
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +15 -4
- package/.codex-plugin/plugin.json +45 -0
- package/.cursor-plugin/marketplace.json +17 -0
- package/.cursor-plugin/plugin.json +27 -0
- package/.devin-plugin/plugin.json +21 -0
- package/.github/plugin/marketplace.json +34 -0
- package/CHANGELOG.md +159 -0
- package/GEMINI.md +1 -0
- package/README.md +185 -328
- package/SECURITY.md +28 -0
- package/assets/pixelcraft-logo-128.png +0 -0
- package/assets/pixelcraft-logo-256.png +0 -0
- package/bin/pixelcraft.mjs +431 -23
- package/docs/ARCHITECTURE.md +40 -37
- package/docs/DESIGN-RATIONALE.md +51 -3
- package/docs/INSTALL.md +221 -0
- package/evals/README.md +16 -6
- package/evals/fixtures/3d-web-engineering.json +69 -0
- package/evals/fixtures/acceptance-checklist-rule03-gate.json +43 -0
- package/evals/fixtures/ai-ui-libraries.json +53 -0
- package/evals/fixtures/audio-visual-accessibility.json +69 -0
- package/evals/fixtures/auth-and-checkout-ui.json +53 -0
- package/evals/fixtures/brandkit-identity-governance.json +48 -0
- package/evals/fixtures/build-and-architecture.json +53 -0
- package/evals/fixtures/canvas-and-node-editors.json +53 -0
- package/evals/fixtures/chat-ai-exfiltration-ime-hitl-gate.json +43 -0
- package/evals/fixtures/completion-gate-scan-until-clean.json +44 -0
- package/evals/fixtures/component-systems.json +53 -0
- package/evals/fixtures/component-testing.json +53 -0
- package/evals/fixtures/constrained-voice-and-tv.json +43 -0
- package/evals/fixtures/creative-code-rendering.json +69 -0
- package/evals/fixtures/creative-reference-evidence.json +67 -0
- package/evals/fixtures/data-app-python-marimo.json +49 -0
- package/evals/fixtures/desktop-cpp-juce-audio.json +49 -0
- package/evals/fixtures/desktop-csharp-avalonia.json +49 -0
- package/evals/fixtures/desktop-native-workspace.json +48 -0
- package/evals/fixtures/desktop-python-anti-tkinter.json +49 -0
- package/evals/fixtures/document-prepress-pdfx4-tounicode.json +43 -0
- package/evals/fixtures/document-rust-typst-invoice.json +49 -0
- package/evals/fixtures/document-typst-and-print-css.json +43 -0
- package/evals/fixtures/email-mjml-dark-mode.json +49 -0
- package/evals/fixtures/email-outlook-and-plaintext.json +43 -0
- package/evals/fixtures/enterprise-data-ui.json +53 -0
- package/evals/fixtures/extended-tui-toolkits.json +53 -0
- package/evals/fixtures/extensions-mv3-and-vscode.json +43 -0
- package/evals/fixtures/file-upload-media-ui.json +53 -0
- package/evals/fixtures/forms-validation.json +53 -0
- package/evals/fixtures/game-go-ebitengine.json +49 -0
- package/evals/fixtures/game-godot-gdscript.json +49 -0
- package/evals/fixtures/game-ui-hud-and-engines.json +43 -0
- package/evals/fixtures/i18n-engineering.json +53 -0
- package/evals/fixtures/local-first-sync.json +53 -0
- package/evals/fixtures/lynxjs.json +53 -0
- package/evals/fixtures/maizzle-email.json +53 -0
- package/evals/fixtures/maps-geospatial.json +53 -0
- package/evals/fixtures/media-og-and-video-export.json +43 -0
- package/evals/fixtures/media-players.json +53 -0
- package/evals/fixtures/mobile-compose-16kb-foldable-store-gate.json +44 -0
- package/evals/fixtures/mobile-elixir-liveview-native.json +49 -0
- package/evals/fixtures/mobile-flutter-dynamic-type.json +49 -0
- package/evals/fixtures/mobile-harmonyos-arkui.json +49 -0
- package/evals/fixtures/mobile-jetpack-compose.json +49 -0
- package/evals/fixtures/mobile-swiftui-ios.json +49 -0
- package/evals/fixtures/motion-engineering.json +69 -0
- package/evals/fixtures/pdfjs-and-pptx.json +53 -0
- package/evals/fixtures/plan-discovery-interview.json +31 -0
- package/evals/fixtures/plan-grill-me-brainstorm-gate.json +49 -0
- package/evals/fixtures/reactive-data-apps.json +53 -0
- package/evals/fixtures/review-evidence-audit.json +43 -0
- package/evals/fixtures/rich-text-and-code-editors.json +53 -0
- package/evals/fixtures/scrollytelling-resilience.json +70 -0
- package/evals/fixtures/spatial-xr-comfort-and-platforms.json +43 -0
- package/evals/fixtures/state-architecture.json +53 -0
- package/evals/fixtures/styling-ecosystem.json +53 -0
- package/evals/fixtures/token-tooling.json +53 -0
- package/evals/fixtures/tui-go-bubbletea.json +49 -0
- package/evals/fixtures/tui-rust-ratatui-grapheme-paste-teardown.json +44 -0
- package/evals/fixtures/tui-rust-ratatui.json +49 -0
- package/evals/fixtures/ux-state-matrix-and-i18n.json +43 -0
- package/evals/fixtures/web-3d-engines.json +53 -0
- package/evals/fixtures/web-php-laravel-filament.json +49 -0
- package/evals/fixtures/web-ruby-viewcomponent-phlex.json +49 -0
- package/evals/pixelcraft-accessibility.md +17 -0
- package/evals/pixelcraft-craft.md +16 -0
- package/evals/pixelcraft-dataviz.md +3 -3
- package/evals/pixelcraft-direction.md +17 -0
- package/evals/pixelcraft-game-ui.md +3 -3
- package/evals/pixelcraft-mobile.md +3 -3
- package/evals/pixelcraft-patterns.md +16 -0
- package/evals/pixelcraft-plan.md +65 -3
- package/evals/pixelcraft-review.md +3 -3
- package/evals/pixelcraft-visual-qa.md +11 -5
- package/evals/pixelcraft-web.md +21 -3
- package/evals/pixelcraft.md +4 -4
- package/gemini-extension.json +3 -2
- package/install.ps1 +57 -11
- package/install.sh +82 -7
- package/package.json +32 -4
- package/plugin.json +6 -1
- package/scripts/build-adapters.mjs +11 -13
- package/scripts/run-evals.mjs +397 -0
- package/scripts/sync-docs.mjs +381 -0
- package/scripts/test-build-adapters.mjs +14 -1
- package/scripts/test-cross-platform-qa.mjs +359 -0
- package/scripts/test-distribution.mjs +86 -7
- package/scripts/test-export-tokens.mjs +259 -3
- package/scripts/test-finish-gate.mjs +133 -10
- package/scripts/test-installers.mjs +155 -6
- package/scripts/test-shoot.mjs +23 -1
- package/scripts/test-slop-scan.mjs +390 -3
- package/scripts/test-style-inventory.mjs +23 -0
- package/scripts/test-sync-docs.mjs +140 -0
- package/scripts/test-validate-skills.mjs +82 -4
- package/scripts/validate-skills.mjs +149 -3
- package/skills/pixelcraft/SKILL.md +67 -47
- package/skills/pixelcraft/references/design-brief.md +2 -2
- package/skills/pixelcraft/references/floor.md +36 -19
- package/skills/pixelcraft/references/report-template.md +25 -11
- package/skills/pixelcraft/references/stack-detection.md +138 -67
- package/skills/pixelcraft/references/surface-acceptance.md +33 -21
- package/skills/pixelcraft/references/workflow-checkpoints.md +49 -7
- package/skills/pixelcraft-accessibility/SKILL.md +34 -13
- package/skills/pixelcraft-accessibility/references/apg-patterns.md +13 -0
- package/skills/pixelcraft-accessibility/references/motion-canvas.md +57 -0
- package/skills/pixelcraft-accessibility/references/platforms.md +34 -6
- package/skills/pixelcraft-accessibility/references/verification.md +15 -10
- package/skills/pixelcraft-accessibility/references/wcag22-checks.md +38 -5
- package/skills/pixelcraft-brandkit/SKILL.md +42 -30
- package/skills/pixelcraft-brandkit/references/asset-pipeline.md +90 -50
- package/skills/pixelcraft-brandkit/references/brand-governance.md +29 -27
- package/skills/pixelcraft-brandkit/references/logo-methods.md +33 -34
- package/skills/pixelcraft-brandkit/references/prompt-template.md +53 -51
- package/skills/pixelcraft-brandkit/references/qa-checklist.md +7 -2
- package/skills/pixelcraft-brandkit/references/visual-modes.md +16 -16
- package/skills/pixelcraft-chat-ui/SKILL.md +31 -27
- package/skills/pixelcraft-chat-ui/references/agentic-workspace.md +66 -0
- package/skills/pixelcraft-chat-ui/references/ai-ui-libraries.md +259 -0
- package/skills/pixelcraft-chat-ui/references/conversation-design.md +12 -6
- package/skills/pixelcraft-chat-ui/references/mobile-business-platforms.md +58 -68
- package/skills/pixelcraft-chat-ui/references/slack-discord.md +60 -76
- package/skills/pixelcraft-constrained/SKILL.md +21 -20
- package/skills/pixelcraft-constrained/references/specialized-hardware.md +69 -45
- package/skills/pixelcraft-constrained/references/tv-wearables.md +123 -73
- package/skills/pixelcraft-constrained/references/voice-ui.md +86 -45
- package/skills/pixelcraft-craft/SKILL.md +29 -15
- package/skills/pixelcraft-craft/references/color.md +62 -6
- package/skills/pixelcraft-craft/references/layout.md +32 -0
- package/skills/pixelcraft-craft/references/motion.md +99 -12
- package/skills/pixelcraft-craft/references/typography.md +48 -9
- package/skills/pixelcraft-data-apps/SKILL.md +50 -31
- package/skills/pixelcraft-data-apps/references/ai-and-internal-data-apps.md +147 -0
- package/skills/pixelcraft-data-apps/references/dash.md +87 -31
- package/skills/pixelcraft-data-apps/references/evidence.md +41 -26
- package/skills/pixelcraft-data-apps/references/gradio.md +65 -27
- package/skills/pixelcraft-data-apps/references/julia-genie.md +64 -29
- package/skills/pixelcraft-data-apps/references/jupyter-widgets.md +65 -27
- package/skills/pixelcraft-data-apps/references/nicegui.md +73 -34
- package/skills/pixelcraft-data-apps/references/observable-framework.md +65 -27
- package/skills/pixelcraft-data-apps/references/panel.md +69 -23
- package/skills/pixelcraft-data-apps/references/r-shiny.md +104 -34
- package/skills/pixelcraft-data-apps/references/reactive-data-apps.md +186 -0
- package/skills/pixelcraft-data-apps/references/reflex.md +85 -31
- package/skills/pixelcraft-data-apps/references/shiny.md +84 -27
- package/skills/pixelcraft-data-apps/references/streamlit.md +73 -25
- package/skills/pixelcraft-dataviz/SKILL.md +21 -24
- package/skills/pixelcraft-dataviz/references/color-accessibility.md +2 -2
- package/skills/pixelcraft-dataviz/references/encoding-tables-dashboards.md +35 -25
- package/skills/pixelcraft-dataviz/references/libraries.md +165 -46
- package/skills/pixelcraft-dataviz/references/maps-geospatial.md +159 -0
- package/skills/pixelcraft-dataviz/references/realtime-graphs-maps-scale.md +58 -65
- package/skills/pixelcraft-desktop/SKILL.md +61 -39
- package/skills/pixelcraft-desktop/references/appkit.md +60 -26
- package/skills/pixelcraft-desktop/references/avalonia.md +65 -29
- package/skills/pixelcraft-desktop/references/cpp-gui.md +104 -27
- package/skills/pixelcraft-desktop/references/electron.md +68 -26
- package/skills/pixelcraft-desktop/references/go-gui.md +59 -30
- package/skills/pixelcraft-desktop/references/gtk.md +74 -31
- package/skills/pixelcraft-desktop/references/javafx-swing.md +54 -25
- package/skills/pixelcraft-desktop/references/qt-pyside-qml.md +57 -30
- package/skills/pixelcraft-desktop/references/rust-gui.md +59 -41
- package/skills/pixelcraft-desktop/references/tauri.md +80 -24
- package/skills/pixelcraft-desktop/references/uno-platform.md +42 -23
- package/skills/pixelcraft-desktop/references/winui-wpf.md +66 -26
- package/skills/pixelcraft-desktop/references/working-context.md +82 -3
- package/skills/pixelcraft-direction/SKILL.md +48 -82
- package/skills/pixelcraft-direction/references/creative-brainstorming.md +72 -0
- package/skills/pixelcraft-direction/references/direction-card.md +11 -1
- package/skills/pixelcraft-direction/references/direction-scoring.md +5 -1
- package/skills/pixelcraft-direction/references/motion-identity.md +67 -0
- package/skills/pixelcraft-direction/references/movements.md +3 -0
- package/skills/pixelcraft-direction/references/reference-analysis.md +37 -0
- package/skills/pixelcraft-direction/references/slop-fingerprints.md +32 -7
- package/skills/pixelcraft-document/SKILL.md +27 -23
- package/skills/pixelcraft-document/references/archetypes.md +27 -4
- package/skills/pixelcraft-document/references/pdf-tools.md +241 -81
- package/skills/pixelcraft-document/references/pdfjs-and-pptx.md +114 -0
- package/skills/pixelcraft-document/references/print-css.md +96 -43
- package/skills/pixelcraft-document/references/slides.md +123 -27
- package/skills/pixelcraft-email/SKILL.md +42 -20
- package/skills/pixelcraft-email/references/client-quirks.md +101 -33
- package/skills/pixelcraft-email/references/html-tables.md +83 -22
- package/skills/pixelcraft-email/references/maizzle.md +54 -0
- package/skills/pixelcraft-email/references/mjml.md +13 -11
- package/skills/pixelcraft-email/references/react-email.md +76 -34
- package/skills/pixelcraft-extensions/SKILL.md +32 -27
- package/skills/pixelcraft-extensions/references/browser-extensions.md +91 -17
- package/skills/pixelcraft-extensions/references/figma-office.md +97 -14
- package/skills/pixelcraft-extensions/references/ide-and-saas-plugins.md +125 -0
- package/skills/pixelcraft-extensions/references/raycast.md +90 -11
- package/skills/pixelcraft-extensions/references/vscode-webviews.md +91 -17
- package/skills/pixelcraft-game-ui/SKILL.md +45 -26
- package/skills/pixelcraft-game-ui/references/bevy.md +69 -31
- package/skills/pixelcraft-game-ui/references/godot.md +100 -27
- package/skills/pixelcraft-game-ui/references/hud-principles.md +50 -21
- package/skills/pixelcraft-game-ui/references/love2d.md +53 -27
- package/skills/pixelcraft-game-ui/references/monogame.md +45 -29
- package/skills/pixelcraft-game-ui/references/unity-ugui.md +109 -0
- package/skills/pixelcraft-game-ui/references/unity-ui-toolkit.md +69 -27
- package/skills/pixelcraft-game-ui/references/unreal-umg.md +53 -26
- package/skills/pixelcraft-game-ui/references/web-and-middleware-game-ui.md +122 -0
- package/skills/pixelcraft-handoff/SKILL.md +14 -13
- package/skills/pixelcraft-handoff/references/design-translation.md +40 -10
- package/skills/pixelcraft-handoff/references/motion-handoff.md +54 -0
- package/skills/pixelcraft-media/SKILL.md +20 -23
- package/skills/pixelcraft-media/references/banners-video.md +83 -65
- package/skills/pixelcraft-media/references/og-generation.md +110 -63
- package/skills/pixelcraft-media/references/social-cards.md +57 -58
- package/skills/pixelcraft-mobile/SKILL.md +53 -36
- package/skills/pixelcraft-mobile/references/dotnet-maui.md +62 -34
- package/skills/pixelcraft-mobile/references/flet.md +53 -26
- package/skills/pixelcraft-mobile/references/flutter.md +76 -32
- package/skills/pixelcraft-mobile/references/harmonyos-and-emerging-mobile.md +121 -0
- package/skills/pixelcraft-mobile/references/ionic-capacitor.md +48 -26
- package/skills/pixelcraft-mobile/references/jetpack-compose.md +92 -24
- package/skills/pixelcraft-mobile/references/kivy.md +54 -31
- package/skills/pixelcraft-mobile/references/kotlin-multiplatform.md +53 -27
- package/skills/pixelcraft-mobile/references/lynxjs.md +110 -0
- package/skills/pixelcraft-mobile/references/nativescript-and-skip.md +91 -0
- package/skills/pixelcraft-mobile/references/react-native-expo.md +66 -31
- package/skills/pixelcraft-mobile/references/swiftui.md +158 -28
- package/skills/pixelcraft-mobile/references/tactile-interactions.md +55 -0
- package/skills/pixelcraft-mobile/references/task-state-composition.md +82 -2
- package/skills/pixelcraft-mobile/references/uikit.md +57 -23
- package/skills/pixelcraft-patterns/SKILL.md +30 -13
- package/skills/pixelcraft-patterns/references/accessibility-resilience.md +29 -0
- package/skills/pixelcraft-patterns/references/ai-and-offline-patterns.md +54 -0
- package/skills/pixelcraft-patterns/references/auth-onboarding.md +32 -13
- package/skills/pixelcraft-patterns/references/billing-paywalls.md +40 -0
- package/skills/pixelcraft-patterns/references/command-workspace.md +56 -0
- package/skills/pixelcraft-patterns/references/commerce.md +35 -16
- package/skills/pixelcraft-patterns/references/communication.md +34 -15
- package/skills/pixelcraft-patterns/references/creative-tools.md +30 -17
- package/skills/pixelcraft-patterns/references/creative-web-composition.md +38 -0
- package/skills/pixelcraft-patterns/references/dashboard-admin.md +22 -18
- package/skills/pixelcraft-patterns/references/history-diff-undo.md +50 -0
- package/skills/pixelcraft-patterns/references/marketing.md +31 -19
- package/skills/pixelcraft-patterns/references/multi-tenant-rbac.md +47 -0
- package/skills/pixelcraft-patterns/references/narrative-systems.md +42 -0
- package/skills/pixelcraft-patterns/references/notifications-activity.md +57 -0
- package/skills/pixelcraft-patterns/references/pattern-selection.md +8 -2
- package/skills/pixelcraft-patterns/references/scheduling-kanban.md +47 -0
- package/skills/pixelcraft-patterns/references/scroll-implementation.md +37 -0
- package/skills/pixelcraft-patterns/references/settings.md +40 -12
- package/skills/pixelcraft-plan/SKILL.md +54 -18
- package/skills/pixelcraft-plan/references/discovery-interview.md +110 -0
- package/skills/pixelcraft-plan/references/grill-me-protocol.md +63 -0
- package/skills/pixelcraft-plan/references/plan-template.md +44 -9
- package/skills/pixelcraft-plan/references/repo-discovery.md +16 -9
- package/skills/pixelcraft-plan/references/stack-freshness.md +22 -5
- package/skills/pixelcraft-plan/references/stack-selection.md +65 -9
- package/skills/pixelcraft-review/SKILL.md +41 -19
- package/skills/pixelcraft-review/references/audit-report.md +20 -1
- package/skills/pixelcraft-review/references/heuristics.md +63 -18
- package/skills/pixelcraft-review/references/personas.md +41 -14
- package/skills/pixelcraft-review/references/polish.md +66 -26
- package/skills/pixelcraft-review/scripts/check-acceptance.mjs +619 -0
- package/skills/pixelcraft-review/scripts/fixtures/focus-longhand-removal.css +34 -0
- package/skills/pixelcraft-review/scripts/slop-scan.mjs +679 -32
- package/skills/pixelcraft-spatial/SKILL.md +16 -17
- package/skills/pixelcraft-spatial/references/comfort-accessibility.md +25 -84
- package/skills/pixelcraft-spatial/references/platforms.md +123 -53
- package/skills/pixelcraft-tokens/SKILL.md +18 -14
- package/skills/pixelcraft-tokens/assets/tokens.example.json +1 -1
- package/skills/pixelcraft-tokens/assets/tokens.modes.example.json +1 -1
- package/skills/pixelcraft-tokens/references/format.md +39 -9
- package/skills/pixelcraft-tokens/references/governance.md +1 -1
- package/skills/pixelcraft-tokens/references/theme-presets.md +36 -8
- package/skills/pixelcraft-tokens/references/token-tooling.md +119 -0
- package/skills/pixelcraft-tokens/scripts/export-tokens.mjs +637 -75
- package/skills/pixelcraft-tui/SKILL.md +41 -25
- package/skills/pixelcraft-tui/references/bubbletea-lipgloss.md +49 -30
- package/skills/pixelcraft-tui/references/extended-tui-toolkits.md +127 -0
- package/skills/pixelcraft-tui/references/ink.md +77 -28
- package/skills/pixelcraft-tui/references/ratatui.md +70 -30
- package/skills/pixelcraft-tui/references/rich.md +53 -33
- package/skills/pixelcraft-tui/references/terminal-protocols.md +80 -0
- package/skills/pixelcraft-tui/references/textual.md +75 -34
- package/skills/pixelcraft-ux/SKILL.md +22 -12
- package/skills/pixelcraft-ux/references/feedback-performance.md +39 -19
- package/skills/pixelcraft-ux/references/forms.md +57 -3
- package/skills/pixelcraft-ux/references/i18n.md +50 -12
- package/skills/pixelcraft-ux/references/laws.md +35 -14
- package/skills/pixelcraft-ux/references/state-matrix.md +15 -1
- package/skills/pixelcraft-ux/references/ux-writing.md +1 -0
- package/skills/pixelcraft-visual-qa/SKILL.md +21 -7
- package/skills/pixelcraft-visual-qa/references/capture-desktop-game.md +28 -7
- package/skills/pixelcraft-visual-qa/references/capture-document.md +70 -0
- package/skills/pixelcraft-visual-qa/references/capture-email.md +13 -9
- package/skills/pixelcraft-visual-qa/references/capture-mobile.md +20 -5
- package/skills/pixelcraft-visual-qa/references/capture-terminal.md +6 -2
- package/skills/pixelcraft-visual-qa/references/motion-capture.md +63 -0
- package/skills/pixelcraft-visual-qa/references/performance-budgets.md +25 -12
- package/skills/pixelcraft-visual-qa/references/realtime-graphics.md +55 -0
- package/skills/pixelcraft-visual-qa/scripts/check-contrast.mjs +442 -0
- package/skills/pixelcraft-visual-qa/scripts/check-email.mjs +397 -0
- package/skills/pixelcraft-visual-qa/scripts/check-pdf.mjs +189 -0
- package/skills/pixelcraft-visual-qa/scripts/check-tui.mjs +321 -0
- package/skills/pixelcraft-visual-qa/scripts/finish-gate.mjs +50 -11
- package/skills/pixelcraft-visual-qa/scripts/shoot.mjs +214 -59
- package/skills/pixelcraft-visual-qa/scripts/style-inventory.mjs +121 -49
- package/skills/pixelcraft-web/SKILL.md +105 -49
- package/skills/pixelcraft-web/references/accessibility-performance.md +42 -0
- package/skills/pixelcraft-web/references/adaptive-layout.md +52 -8
- package/skills/pixelcraft-web/references/angular.md +63 -16
- package/skills/pixelcraft-web/references/assets-pipeline.md +67 -0
- package/skills/pixelcraft-web/references/astro.md +64 -13
- package/skills/pixelcraft-web/references/audio-reactive.md +61 -0
- package/skills/pixelcraft-web/references/auth-and-checkout-ui.md +115 -0
- package/skills/pixelcraft-web/references/build-and-architecture.md +215 -0
- package/skills/pixelcraft-web/references/canvas-and-node-editors.md +157 -0
- package/skills/pixelcraft-web/references/clojurescript.md +52 -17
- package/skills/pixelcraft-web/references/component-systems.md +102 -0
- package/skills/pixelcraft-web/references/component-testing.md +170 -0
- package/skills/pixelcraft-web/references/creative-effects.md +59 -0
- package/skills/pixelcraft-web/references/creative-runtime.md +34 -0
- package/skills/pixelcraft-web/references/enterprise-data-ui.md +138 -0
- package/skills/pixelcraft-web/references/file-upload-media-ui.md +82 -0
- package/skills/pixelcraft-web/references/forms-validation.md +123 -0
- package/skills/pixelcraft-web/references/fsharp-fable.md +3 -2
- package/skills/pixelcraft-web/references/gsap.md +102 -0
- package/skills/pixelcraft-web/references/html-css.md +144 -12
- package/skills/pixelcraft-web/references/htmx-alpine.md +68 -18
- package/skills/pixelcraft-web/references/i18n-engineering.md +106 -0
- package/skills/pixelcraft-web/references/interaction-and-search-primitives.md +196 -0
- package/skills/pixelcraft-web/references/java-web.md +27 -18
- package/skills/pixelcraft-web/references/kotlin-web.md +6 -2
- package/skills/pixelcraft-web/references/leptos-yew.md +62 -19
- package/skills/pixelcraft-web/references/lit-web-components.md +4 -2
- package/skills/pixelcraft-web/references/local-first-sync.md +105 -0
- package/skills/pixelcraft-web/references/media-players.md +104 -0
- package/skills/pixelcraft-web/references/motion-react.md +96 -0
- package/skills/pixelcraft-web/references/motion-recipes.md +82 -0
- package/skills/pixelcraft-web/references/preact-fresh-hono.md +111 -0
- package/skills/pixelcraft-web/references/pwa.md +6 -1
- package/skills/pixelcraft-web/references/qwik.md +51 -11
- package/skills/pixelcraft-web/references/r3f-integration.md +69 -0
- package/skills/pixelcraft-web/references/react-next.md +112 -13
- package/skills/pixelcraft-web/references/rendering-choice.md +63 -0
- package/skills/pixelcraft-web/references/rendering-performance.md +80 -0
- package/skills/pixelcraft-web/references/rich-text-and-code-editors.md +220 -0
- package/skills/pixelcraft-web/references/rive-lottie.md +73 -0
- package/skills/pixelcraft-web/references/scene-architecture.md +132 -0
- package/skills/pixelcraft-web/references/server-rendered.md +106 -63
- package/skills/pixelcraft-web/references/shader-workflow.md +77 -0
- package/skills/pixelcraft-web/references/smooth-scroll.md +58 -0
- package/skills/pixelcraft-web/references/solid.md +67 -16
- package/skills/pixelcraft-web/references/state-architecture.md +107 -0
- package/skills/pixelcraft-web/references/styling-ecosystem.md +273 -0
- package/skills/pixelcraft-web/references/svelte.md +61 -11
- package/skills/pixelcraft-web/references/tailwind.md +40 -14
- package/skills/pixelcraft-web/references/video-media.md +69 -0
- package/skills/pixelcraft-web/references/vue-nuxt.md +37 -13
- package/skills/pixelcraft-web/references/web-3d-engines.md +97 -0
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
# Micro-interaction, search, icon, font, and image primitives
|
|
2
|
+
|
|
3
|
+
Stop hand-rolling fragile command palettes, swipeable drawers, toast queues, carousels, date grids, split panes, or search highlighters from scratch. Use native HTML primitives where sufficient (`<dialog>`, `[popover]`, `<input type="date">`, CSS Scroll Snap) and vetted, accessible libraries when interaction physics, keyboard navigation, or search ranking exceeds native HTML.
|
|
4
|
+
|
|
5
|
+
## Micro-interaction primitives
|
|
6
|
+
|
|
7
|
+
| Primitive | Recommended libraries | Core capabilities & accessibility contract | Avoid hand-rolling when |
|
|
8
|
+
|---|---|---|---|
|
|
9
|
+
| **Command palette** | **`cmdk`** (React), **`kbar`** (React) | ARIA `combobox` + `listbox`, `aria-activedescendant`, keyboard Arrow/Home/End/Enter/Esc, focus restoration to trigger, `shouldFilter={false}` for async server search, nested shortcut actions (`kbar`) | Any `⌘K`/`Ctrl+K` launcher, action menu, or multi-source quick-switcher |
|
|
10
|
+
| **Drawer / bottom sheet** | **`vaul`** (React; Radix Dialog core) | Touch velocity & drag physics, `snapPoints` / `activeSnapPoint`, `Escape` dismiss, inert background, focus trap & restoration, `prefers-reduced-motion` instant snap | Mobile sheets, filter drawers, or gesture-dismissible trays |
|
|
11
|
+
| **Toast notifications** | **`sonner`** (React; `vue-sonner`, `svelte-sonner`) | Stacked expansion, pause-on-hover and pause-on-focus, `aria-live="polite"`, swipe dismiss, built-in `action` button for reversible **Undo** flows | Any transient feedback; **never** put blocking form validation or critical errors solely inside an auto-dismissing toast |
|
|
12
|
+
| **Carousels** | **Embla Carousel** (default), **Splide**, **Swiper** | **Embla**: ~7 KB headless physics, plugin ecosystem, zero CSS lock-in; **Splide**: zero-dep with built-in accessible live-region controls; **Swiper**: heavy feature set (3D coverflow, virtual slides, synced thumbs) | Media galleries or horizontal shelves needing keyboard Prev/Next, `role="region" aria-roledescription="carousel"`, pauseable autoplay, and `prefers-reduced-motion` instant jumps |
|
|
13
|
+
| **Date pickers** | **`react-day-picker`** (v9), **React Aria `DatePicker`** | `locale` + `timeZone` support, single/range/multiple selection, full keyboard calendar grid (`Arrow`, `PageUp`/`PageDown`, `Home`/`End`), screen-reader date announcements | Date ranges, disabled-date calendars, or multi-locale pickers (use native `<input type="date">` for simple single dates like birthdates) |
|
|
14
|
+
| **Split panes** | **`react-resizable-panels`** | Keyboard-resizable `role="separator"` handles (`Arrow`, `Home`/`End`), `minSize`/`maxSize`/collapsible constraints, `autoSaveId` persisted layout without hydration flash | IDE panes, master-detail inspectors, or diff views |
|
|
15
|
+
|
|
16
|
+
### Command palette (`cmdk`) + Undo toast (`sonner`) idiom
|
|
17
|
+
|
|
18
|
+
```tsx
|
|
19
|
+
'use client';
|
|
20
|
+
|
|
21
|
+
import { useEffect, useRef, useState } from 'react';
|
|
22
|
+
import { Command } from 'cmdk';
|
|
23
|
+
import { toast } from 'sonner';
|
|
24
|
+
|
|
25
|
+
export function QuickSearch({ open, onOpenChange }: { open: boolean; onOpenChange: (v: boolean) => void }) {
|
|
26
|
+
const [query, setQuery] = useState('');
|
|
27
|
+
const [items, setItems] = useState<{ id: string; title: string }[]>([]);
|
|
28
|
+
const [status, setStatus] = useState<'idle' | 'loading' | 'error'>('idle');
|
|
29
|
+
const abortRef = useRef<AbortController | null>(null);
|
|
30
|
+
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (!open) return;
|
|
33
|
+
abortRef.current?.abort();
|
|
34
|
+
const controller = new AbortController();
|
|
35
|
+
abortRef.current = controller;
|
|
36
|
+
|
|
37
|
+
const timer = setTimeout(async () => {
|
|
38
|
+
setStatus('loading');
|
|
39
|
+
try {
|
|
40
|
+
const res = await fetch(`/api/search?q=${encodeURIComponent(query)}`, { signal: controller.signal });
|
|
41
|
+
if (!res.ok) throw new Error('Search request failed');
|
|
42
|
+
setItems(await res.json());
|
|
43
|
+
setStatus('idle');
|
|
44
|
+
} catch (err) {
|
|
45
|
+
if ((err as Error).name !== 'AbortError') setStatus('error');
|
|
46
|
+
}
|
|
47
|
+
}, 150);
|
|
48
|
+
|
|
49
|
+
return () => {
|
|
50
|
+
clearTimeout(timer);
|
|
51
|
+
controller.abort();
|
|
52
|
+
};
|
|
53
|
+
}, [open, query]);
|
|
54
|
+
|
|
55
|
+
function archiveItem(item: { id: string; title: string }) {
|
|
56
|
+
onOpenChange(false);
|
|
57
|
+
toast(`Archived "${item.title}"`, {
|
|
58
|
+
action: { label: 'Undo', onClick: () => fetch(`/api/items/${item.id}/restore`, { method: 'POST' }) },
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<Command.Dialog open={open} onOpenChange={onOpenChange} label="Global search" shouldFilter={false}>
|
|
64
|
+
<Command.Input value={query} onValueChange={setQuery} placeholder="Search invoices or actions…" />
|
|
65
|
+
<Command.List>
|
|
66
|
+
{status === 'loading' && <Command.Loading>Searching…</Command.Loading>}
|
|
67
|
+
{status === 'error' && <div role="alert">Search failed. Retry or check your connection.</div>}
|
|
68
|
+
{status === 'idle' && items.length === 0 && (
|
|
69
|
+
<Command.Empty>
|
|
70
|
+
No results for “{query}”.{' '}
|
|
71
|
+
<button type="button" onClick={() => setQuery('')}>Clear search</button>
|
|
72
|
+
</Command.Empty>
|
|
73
|
+
)}
|
|
74
|
+
{items.map((item) => (
|
|
75
|
+
<Command.Item key={item.id} value={item.id} onSelect={() => archiveItem(item)}>
|
|
76
|
+
{item.title}
|
|
77
|
+
</Command.Item>
|
|
78
|
+
))}
|
|
79
|
+
</Command.List>
|
|
80
|
+
</Command.Dialog>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Accessible carousel (`Embla`) & drawer (`vaul`) guardrails
|
|
86
|
+
|
|
87
|
+
- **Embla Carousel**: pair `useEmblaCarousel({ loop: false, duration: prefersReducedMotion ? 0 : 25 })` with explicit Previous/Next `<button>` controls, a visible slide indicator (`aria-current="true"`), and a live announcement (`aria-live="polite"`) only when the user explicitly advances slides—never auto-advance without a Pause button (WCAG 2.2.2).
|
|
88
|
+
- **Vaul Drawer**: always provide `<Drawer.Title>` and `<Drawer.Description>` (visually hidden only when redundant) so screen readers announce the dialog name; set `repositionInputs` thoughtfully on iOS Safari keyboards; respect `prefers-reduced-motion` by disabling spring overshoots.
|
|
89
|
+
- **Resizable panels**: give every `<PanelResizeHandle>` an explicit `aria-label` (e.g., `aria-label="Resize sidebar"`) and a visible `:focus-visible` indicator with at least a 4px interactive hit target.
|
|
90
|
+
|
|
91
|
+
### Global single-key hotkey guard & Safe-Triangle cascading menus
|
|
92
|
+
|
|
93
|
+
- **Single-key shortcut guard**: global single-key shortcuts (`/`, `,`, `c`, `?`, `j`/`k`, `e`) **must ignore** events whenever an IME composition is active (`event.isComposing || event.keyCode === 229`), a system modifier (`metaKey`, `ctrlKey`, `altKey`) is held, or focus resides inside `<input>`, `<textarea>`, `<select>`, `[contenteditable="true"]`, `[contenteditable="plaintext-only"]`, or `[role="textbox"]` (including across Shadow DOM via `event.composedPath()`):
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
export function shouldIgnoreSingleKeyHotkey(event: KeyboardEvent): boolean {
|
|
97
|
+
if (event.defaultPrevented || event.isComposing || event.keyCode === 229) return true;
|
|
98
|
+
if (event.metaKey || event.ctrlKey || event.altKey) return true;
|
|
99
|
+
for (const node of event.composedPath()) {
|
|
100
|
+
if (!(node instanceof HTMLElement)) continue;
|
|
101
|
+
if (node.isContentEditable) return true;
|
|
102
|
+
const tag = node.tagName;
|
|
103
|
+
if (tag === 'INPUT' || tag === 'TEXTAREA' || tag === 'SELECT') return true;
|
|
104
|
+
if (node.getAttribute('role') === 'textbox' || node.getAttribute('role') === 'combobox') return true;
|
|
105
|
+
}
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
- **Safe-Triangle submenu pointer corridor**: cascading hover/pointer submenus (`Menu.Sub` in `@base-ui/react`, `radix-ui`, Ariakit, or `useHover(context, { handleClose: safePolygon() })` in `@floating-ui/react`) must maintain a diagonal pointer corridor between the parent item's exit point and the submenu's near/far corners (`~75–150 ms` intent window) so diagonal mouse movement never collapses the submenu mid-flight, while keeping `ArrowRight`/`ArrowLeft`/`Escape` keyboard parity intact.
|
|
111
|
+
|
|
112
|
+
## Search UI engineering
|
|
113
|
+
|
|
114
|
+
Choose the search architecture by **index size, freshness, hosting budget, and ranking needs**:
|
|
115
|
+
|
|
116
|
+
| Engine / UI layer | Execution model | Best fit | Critical constraints |
|
|
117
|
+
|---|---|---|---|
|
|
118
|
+
| **Pagefind** | Build-time static WASM index chunked on demand | Astro, static docs, marketing sites, blogs (0 backend cost, scales to tens of thousands of pages) | Static build-time freshness only; run `npx pagefind --site dist` in build pipeline |
|
|
119
|
+
| **Orama** | In-browser or edge JS/TS full-text + vector hybrid | Interactive client/edge search, local-first docs, semantic + keyword blending | Budget serialized index download size for large corpora |
|
|
120
|
+
| **Fuse.js** | Lightweight client fuzzy matching | Small in-memory datasets (< ~5,000 short records) like command palettes or local filter lists | Main-thread CPU degrades sharply on large text bodies—move to a Web Worker or Pagefind/Orama beyond small sets |
|
|
121
|
+
| **Algolia InstantSearch** | Hosted typo-tolerant search + UI widgets/hooks | E-commerce catalogs, multi-facet directories, instant federated search | Metered hosted billing; keep public search-only API key strictly scoped |
|
|
122
|
+
| **Meilisearch** / **Typesense** | Self-hosted or cloud open-source engines + InstantSearch adapters (`instant-meilisearch`, `typesense-instantsearch-adapter`) | Fast typo-tolerant faceted search with predictable infrastructure costs and InstantSearch UI parity | Enforce tenant/filter security via server-issued scoped search keys, never expose master keys |
|
|
123
|
+
|
|
124
|
+
### Mandatory search UX contract
|
|
125
|
+
|
|
126
|
+
1. **Abort stale requests**: use `AbortController` (or monotonic request IDs) so a slow earlier query never overwrites a newer result set.
|
|
127
|
+
2. **Safe match highlighting**: render highlights from structured match indices/tokens into React/framework `<mark>` elements—never feed raw HTML strings into `dangerouslySetInnerHTML` without strict sanitization.
|
|
128
|
+
3. **URL synchronization**: sync query (`?q=`) and active facets to URL search params (`replaceState` while typing, `pushState` on facet toggles) so back/forward and shared links preserve results.
|
|
129
|
+
4. **Empty-result recovery**: state what was searched, show active filters that may have over-constrained the result, and offer a one-click reset or broader suggestion.
|
|
130
|
+
|
|
131
|
+
## Icon, font, and image craft
|
|
132
|
+
|
|
133
|
+
### Icons (`Lucide`, `Phosphor`, `Tabler`, `Iconify`)
|
|
134
|
+
|
|
135
|
+
- **Lucide**: clean 24px geometric 2px-stroke baseline for modern web apps.
|
|
136
|
+
- **Phosphor Icons**: 6 weights (`thin`, `light`, `regular`, `bold`, `fill`, `duotone`)—strong choice when brand tone or active-nav filled states need optical weight variation.
|
|
137
|
+
- **Tabler Icons**: 5,000+ crisp icons suited to technical, data, and operational dashboards.
|
|
138
|
+
- **Iconify**: unified schema across 150+ open sets—compile icons at build time (`unplugin-icons` / SVG sprites) rather than fetching icons at runtime from a third-party CDN on critical interactive controls.
|
|
139
|
+
- **Craft rules**: pick **one** icon library and consistent stroke weight per surface; tree-shake named imports (never import an entire icon barrel); mark decorative icons `aria-hidden="true"` and give icon-only buttons a concise `aria-label` or visually hidden text.
|
|
140
|
+
|
|
141
|
+
### Fonts (`Fontsource`)
|
|
142
|
+
|
|
143
|
+
- Prefer **`@fontsource-variable/*`** (or static `@fontsource/*`) self-hosted packages over third-party Google Fonts `<link>` tags: automatic unicode-range subsetting, same-origin HTTP/2+ caching, zero external DNS/TLS hop, and zero third-party IP leakage.
|
|
144
|
+
- Pair `font-display: swap` with metric-matched fallback stacks (`size-adjust`, `ascent-override`, `descent-override` or framework font helpers like `next/font`) to eliminate layout shift (CLS).
|
|
145
|
+
|
|
146
|
+
### Responsive images & low-byte placeholders (`Unpic`, `ThumbHash`, `BlurHash`)
|
|
147
|
+
|
|
148
|
+
- **Unpic** (`@unpic/react`, `@unpic/svelte`, `@unpic/vue`, `@unpic/astro`): detects major image CDNs (Cloudflare, Cloudinary, Imgix, Shopify, Vercel, Netlify) and emits responsive `srcset`, `sizes`, explicit `width`/`height`, and `priority` (`fetchPriority="high"`, `loading="eager"`) for LCP hero images without writing brittle URL math.
|
|
149
|
+
- **ThumbHash** (preferred over **BlurHash**): encodes aspect ratio, alpha channel, and richer color gradients in ~25 bytes (stored directly in the DB/API payload alongside the image URL) and decodes synchronously to an instant placeholder data URL with zero extra network round-trips.
|
|
150
|
+
|
|
151
|
+
```tsx
|
|
152
|
+
import { Image } from '@unpic/react';
|
|
153
|
+
import { thumbHashToDataURL } from 'thumbhash';
|
|
154
|
+
|
|
155
|
+
export function ProductPhoto({ src, alt, width, height, thumbhashBytes, isLcp }: {
|
|
156
|
+
src: string;
|
|
157
|
+
alt: string;
|
|
158
|
+
width: number;
|
|
159
|
+
height: number;
|
|
160
|
+
thumbhashBytes?: Uint8Array;
|
|
161
|
+
isLcp?: boolean;
|
|
162
|
+
}) {
|
|
163
|
+
const placeholder = thumbhashBytes ? thumbHashToDataURL(thumbhashBytes) : undefined;
|
|
164
|
+
return (
|
|
165
|
+
<Image
|
|
166
|
+
src={src}
|
|
167
|
+
alt={alt}
|
|
168
|
+
width={width}
|
|
169
|
+
height={height}
|
|
170
|
+
priority={isLcp}
|
|
171
|
+
background={placeholder}
|
|
172
|
+
sizes="(max-width: 768px) 100vw, 480px"
|
|
173
|
+
/>
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## Do/don't pairs
|
|
179
|
+
|
|
180
|
+
| Do | Don't |
|
|
181
|
+
|---|---|
|
|
182
|
+
| Use `cmdk`/`kbar`, `vaul`, `sonner`, Embla, `react-day-picker`, and `react-resizable-panels` when native HTML falls short | Hand-roll `keydown` command palettes, touch drag sheets, or custom toast timers from scratch |
|
|
183
|
+
| Set `shouldFilter={false}` in `cmdk` and abort stale fetches with `AbortController` | Mix client fuzzy filtering with async server results or let slow responses overwrite newer keystrokes |
|
|
184
|
+
| Use `sonner` with an Undo action for reversible non-blocking confirmations | Put form validation errors or critical failures only in auto-dismissing toasts |
|
|
185
|
+
| Use Pagefind (static SSG), Orama (in-browser/edge), or InstantSearch (Algolia/Meilisearch/Typesense) | Ship a 10 MB JSON blob into `Fuse.js` on the main thread |
|
|
186
|
+
| Compile/tree-shake one icon family (`Lucide`/`Phosphor`/`Tabler`/`unplugin-icons`) and self-host subsets with `Fontsource` | Mix three icon stroke styles, fetch icons from runtime CDNs on critical controls, or ship unsubsetted multi-MB font files |
|
|
187
|
+
| Emit responsive `srcset`/`sizes` + `priority` on LCP images (`Unpic`) and ~25-byte `ThumbHash` placeholders | Serve raw 4K PNGs with `loading="lazy"` on the LCP image or trigger CLS without `width`/`height` |
|
|
188
|
+
|
|
189
|
+
## Verification commands
|
|
190
|
+
|
|
191
|
+
```sh
|
|
192
|
+
npm run build
|
|
193
|
+
npx playwright test
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
Inspect bundle chunk sizes and verify no whole-library icon barrels or raw JSON search indices bloat the initial payload (`static`). In a real browser, test `⌘K` open/filter/Esc focus restoration, swipeable drawer + keyboard dismissal, toast pause-on-focus + Undo, carousel keyboard/reduced-motion behavior, empty search recovery, and zero-CLS image/font loading (`rendered`).
|
|
@@ -1,45 +1,54 @@
|
|
|
1
|
-
# Java web: Vaadin
|
|
1
|
+
# Java web: Vaadin Flow / Hilla, Thymeleaf + htmx, JTE, Quarkus Qute
|
|
2
|
+
|
|
3
|
+
## Stack selection
|
|
4
|
+
|
|
5
|
+
| Stack | Rendering model | Best fit | Primary watch-out |
|
|
6
|
+
|---|---|---|---|
|
|
7
|
+
| **Vaadin Flow** | Server-side Java UI driving Web Components over XHR/WebSocket | Internal enterprise apps owned purely by Java teams | Stateful server session memory and disconnect/reconnect UX |
|
|
8
|
+
| **Vaadin Hilla** | React + TypeScript frontend + auto-generated typed RPC from Spring `@BrowserCallable` endpoints | Java/Spring Boot backends needing modern React/Vite UI and offline/client responsiveness | Treat frontend with full React/WCAG/token discipline; never bypass `@RolesAllowed` / `@AnonymousAllowed` on endpoints |
|
|
9
|
+
| **Spring Boot + Thymeleaf + htmx** | Server-rendered HTML templates + `htmx-spring-boot` (`@HxRequest`) fragment controllers | Public web apps, CRUD portals, progressive enhancement | Include `Vary: HX-Request` on dual full-page/fragment routes and wire Spring Security CSRF header |
|
|
10
|
+
| **JTE (Java Template Engine)** | Precompiled, type-safe `.jte` templates with contextual HTML/JS/CSS escaping | High-throughput Spring Boot / Javalin / Ktor server HTML with compile-time checking | Keep business logic out of templates; configure precompiled mode for production |
|
|
11
|
+
| **Quarkus Qute** | Build-time type-checked reactive templates (native-image friendly) | Quarkus microservices rendering HTML/htmx fragments with low memory footprint | Validate template parameter types at build time (`@CheckedTemplate`) |
|
|
2
12
|
|
|
3
13
|
## Token mapping
|
|
4
14
|
|
|
5
|
-
Vaadin: map tokens to Lumo/custom CSS properties (`--lumo-primary-color`, application semantic variables)
|
|
15
|
+
Vaadin Flow/Hilla: map semantic tokens to Lumo/Aura custom CSS properties (`--lumo-primary-color`, application semantic variables) in the application theme folder (`frontend/themes/<name>/styles.css`); do not restyle every component instance. Thymeleaf, JTE, and Qute: import generated CSS variables in the shared base layout and consume semantic classes rather than copying hex into Java or templates.
|
|
6
16
|
|
|
7
17
|
## Layout and responsive idioms
|
|
8
18
|
|
|
9
|
-
Vaadin Flow routes
|
|
19
|
+
Vaadin Flow/Hilla routes and layouts produce real DOM/web components but still need intentional responsive CSS and narrow-viewport restructuring. Thymeleaf, JTE, and Qute are server-rendered HTML: design complete semantic pages first, compose fragments cleanly, and pair with htmx 2 (`htmx-alpine.md`) when partial updates improve task flow.
|
|
10
20
|
|
|
11
21
|
## Typography/custom fonts
|
|
12
22
|
|
|
13
|
-
Load fonts through static/theme CSS with fallback/subsetting. Vaadin theme typography should use documented custom properties; Thymeleaf
|
|
23
|
+
Load fonts through static/theme CSS with explicit fallback/subsetting. Vaadin theme typography should use documented custom properties; Thymeleaf/JTE/Qute use ordinary CSS. Verify scaling/localization in a real browser.
|
|
14
24
|
|
|
15
25
|
## Motion/reduced motion
|
|
16
26
|
|
|
17
|
-
Use CSS `@media (prefers-reduced-motion: reduce)`. Vaadin component animation coverage varies by component/version,
|
|
27
|
+
Use CSS `@media (prefers-reduced-motion: reduce)`. Vaadin component animation coverage varies by component/version—inspect overlays, drawers, dialogs, and progress bars in reduced-motion emulation and override in the theme stylesheet.
|
|
18
28
|
|
|
19
29
|
## Accessibility specifics
|
|
20
30
|
|
|
21
|
-
Vaadin
|
|
22
|
-
|
|
23
|
-
## States idiom
|
|
24
|
-
|
|
25
|
-
Vaadin: model loading/error/empty/permission/offline/push/session expiration explicitly; never leave dead UI after session disconnect. Thymeleaf: use HTTP semantics, redirects/flashes/form errors, no-js fallback, empty/error templates, and idempotency. Preserve deep links and scroll/back behavior.
|
|
31
|
+
Vaadin provides WCAG-oriented component primitives, but application composition can still break labels, landmarks, focus order, dialogs, grids, and screen-reader flow. In Thymeleaf/JTE/Qute, accessibility is exactly the emitted HTML—manage server round-trip focus, error summaries, and `aria-live` updates after htmx fragment swaps.
|
|
26
32
|
|
|
27
|
-
## Forms idiom
|
|
33
|
+
## States & Forms idiom
|
|
28
34
|
|
|
29
|
-
Vaadin
|
|
35
|
+
- **Vaadin Flow**: model loading/error/empty/permission/offline/push/session-expiration explicitly; never leave dead controls after session disconnect. Pair `Binder` validators with visible persistent labels and non-color required indicators.
|
|
36
|
+
- **Vaadin Hilla**: annotate every `@BrowserCallable` service with explicit Spring Security rules (`@RolesAllowed`, `@PermitAll`), consume generated TypeScript models/hooks with `useForm` (Hilla React Form) or `forms-validation.md` idioms, and preserve input across validation failures.
|
|
37
|
+
- **Spring + Thymeleaf / JTE / Qute + htmx**: return full pages on normal requests and partial fragments on `@HxRequest` (with `Vary: HX-Request`), expose CSRF tokens via hidden inputs or `hx-headers`, return HTTP 422 error fragments preserving posted values, and keep filter/pagination state in URLs.
|
|
30
38
|
|
|
31
39
|
## Do/don't pairs
|
|
32
40
|
|
|
33
41
|
| Do | Don't |
|
|
34
42
|
|---|---|
|
|
35
|
-
| Vaadin `new Button("Save invoice")` |
|
|
36
|
-
|
|
|
37
|
-
|
|
|
38
|
-
|
|
|
43
|
+
| Vaadin Flow `new Button("Save invoice")` or semantic `<button type="submit">` | Click listener on a layout `Div` with no keyboard semantics |
|
|
44
|
+
| Explicit `@RolesAllowed` on every Vaadin Hilla `@BrowserCallable` endpoint | Assuming frontend route guards protect generated Hilla RPC endpoints |
|
|
45
|
+
| Spring `@HxRequest` + `Vary: HX-Request` returning semantic error fragments with preserved values | Caching partial htmx fragments under the same cache key as full pages or losing POST input |
|
|
46
|
+
| Precompiled JTE / `@CheckedTemplate` Qute with contextual auto-escaping | String-concatenated HTML or bypassing template escaping on user text |
|
|
47
|
+
| Semantic CSS theme variables in `styles.css` | Per-instance inline hex colors scattered across Java views/templates |
|
|
39
48
|
|
|
40
49
|
## Known traps
|
|
41
50
|
|
|
42
|
-
|
|
51
|
+
Missing Spring Security annotations on Hilla `@BrowserCallable` endpoints, caching htmx fragments without `Vary: HX-Request`, Vaadin session timeout leaving silent dead buttons, bypassing JTE/Qute/Thymeleaf escaping, grid density clipping at 200% zoom, CSRF failures on htmx `hx-post` requests.
|
|
43
52
|
|
|
44
53
|
## Verification commands
|
|
45
54
|
|
|
@@ -49,4 +58,4 @@ Vaadin version/theme breaking changes, session timeout/push behavior, grid densi
|
|
|
49
58
|
npx playwright test
|
|
50
59
|
```
|
|
51
60
|
|
|
52
|
-
Inspect browser DOM/accessibility tree, session expiry/offline/push interruption, keyboard/focus order,
|
|
61
|
+
Inspect browser DOM/accessibility tree, session expiry/offline/push interruption, htmx no-JS + enhanced paths, keyboard/focus order, reduced motion, and zoom/localization behavior (`rendered`); Maven/Gradle builds and template checks are `static`.
|
|
@@ -39,15 +39,19 @@ In DOM mode use `<form>`, labels, autocomplete/inputmode, constraint validation
|
|
|
39
39
|
|
|
40
40
|
## Known traps
|
|
41
41
|
|
|
42
|
-
Confusing Compose HTML with canvas Compose
|
|
42
|
+
Confusing DOM-based Kobweb / Compose HTML with Skiko canvas-rendered Compose Multiplatform Web (`wasmJs` / `js`), WasmGC browser support and WASM startup size, browser semantics/autofill/SEO gaps on canvas targets, duplicate routing ownership, font/glyph mismatch, thinking Kotlin type safety implies accessibility.
|
|
43
43
|
|
|
44
44
|
## Verification commands
|
|
45
45
|
|
|
46
|
+
Run the task matching the project's configured Kotlin target (`wasmJs` for modern Compose Multiplatform Web WasmGC targets, `js` for Kotlin/JS and Kobweb):
|
|
47
|
+
|
|
46
48
|
```sh
|
|
47
49
|
./gradlew build
|
|
50
|
+
./gradlew wasmJsBrowserTest
|
|
51
|
+
./gradlew wasmJsBrowserDevelopmentRun
|
|
48
52
|
./gradlew jsBrowserTest
|
|
49
53
|
./gradlew jsBrowserDevelopmentRun
|
|
50
54
|
npx playwright test
|
|
51
55
|
```
|
|
52
56
|
|
|
53
|
-
Inspect initial HTML/DOM versus canvas pixels, keyboard/focus/accessibility tree, network failure, bundle size, browser zoom/text scaling, reduced motion, back/deep-link behavior.
|
|
57
|
+
Inspect initial HTML/DOM versus canvas pixels, keyboard/focus/accessibility tree, network failure, WASM/JS bundle size, browser zoom/text scaling, reduced motion, and back/deep-link behavior (`rendered`).
|
|
@@ -1,54 +1,97 @@
|
|
|
1
|
-
# Leptos
|
|
1
|
+
# Rust web: Leptos, Dioxus Web, Yew, and Axum + Askama/Maud + htmx
|
|
2
|
+
|
|
3
|
+
## Stack selection
|
|
4
|
+
|
|
5
|
+
| Stack | Rendering model | Best fit | Primary trade-off |
|
|
6
|
+
|---|---|---|---|
|
|
7
|
+
| **Leptos (0.7 / 0.8)** | Fine-grained signals + SSR + `#[island]` selective hydration + `#[server]` RPC | Full-stack Rust apps needing reactive client UI with minimal WASM hydration | Requires disciplined SSR/hydrate feature gating (`#[cfg(feature = "ssr")]`) |
|
|
8
|
+
| **Dioxus Web (0.6 / 0.7)** | `rsx!` macros, `use_signal`/`use_resource`, Dioxus Fullstack `#[server]` | Teams sharing Rust UI across web, desktop, and mobile | Virtual-DOM diffing + larger initial WASM download if full-page hydrated |
|
|
9
|
+
| **Yew** | Component/hook VDOM compiled to WASM | Existing Yew SPAs and client-side WASM tools | Heavier VDOM/WASM footprint; smaller SSR/islands ecosystem than Leptos |
|
|
10
|
+
| **Axum + Askama / Maud + htmx** | Zero-WASM server-rendered HTML templates + htmx partial swaps | Content, admin, and form-heavy Rust web apps prioritizing instant first load | Rich offline/canvas interactions still require small targeted JS or WASM islands |
|
|
2
11
|
|
|
3
12
|
## Token mapping
|
|
4
13
|
|
|
5
|
-
Compile once to WASM
|
|
14
|
+
Compile once to WASM (or render templates from Axum) and style real DOM with CSS. Import generated CSS variables in root HTML/CSS; consume semantic classes/custom properties rather than generating inline hex from Rust. Theme state should be a signal or cookie/header mapped to a root class or `data-theme`.
|
|
6
15
|
|
|
7
16
|
## Layout and responsive idioms
|
|
8
17
|
|
|
9
|
-
Use HTML/CSS layout, semantic landmarks, container/media queries, and SSR/hydration boundaries deliberately. Leptos
|
|
18
|
+
Use HTML/CSS layout, semantic landmarks, container/media queries, and SSR/hydration boundaries deliberately. In **Leptos 0.7/0.8**, annotate only interactive subtrees with `#[island]` when `islands` mode is enabled so static markup never ships WASM code. Do not copy a monolithic SPA bundle when islands or Axum + Askama/Maud + htmx suffice.
|
|
10
19
|
|
|
11
20
|
## Typography/custom fonts
|
|
12
21
|
|
|
13
|
-
Declare font files in static assets/root HTML with subset and fallback policy. Respect browser text scaling; verify WASM
|
|
22
|
+
Declare font files in static assets/root HTML with subset and fallback policy. Respect browser text scaling; verify WASM loading does not block readable initial HTML where SSR exists.
|
|
14
23
|
|
|
15
24
|
## Motion/reduced motion
|
|
16
25
|
|
|
17
|
-
Prefer CSS transitions/keyframes with `@media (prefers-reduced-motion: reduce)`. For Rust-side state use `web_sys::window().match_media("(prefers-reduced-motion: reduce)")`; in Leptos, `leptos_use::use_prefers_reduced_motion()`
|
|
26
|
+
Prefer CSS transitions/keyframes with `@media (prefers-reduced-motion: reduce)`. For Rust-side state use `web_sys::window().and_then(|w| w.match_media("(prefers-reduced-motion: reduce)").ok().flatten())`; in Leptos, `leptos_use::use_prefers_reduced_motion()` wraps this safely. Never assume `window()` exists during SSR.
|
|
18
27
|
|
|
19
28
|
## Accessibility specifics
|
|
20
29
|
|
|
21
30
|
Rust/WASM has no automatic accessibility advantage. Emit semantic HTML/ARIA attributes exactly as browser markup; manage focus after hydration/navigation; keep keyboard behavior and labels in generated DOM. Canvas/SVG widgets need explicit text alternatives/focus semantics.
|
|
22
31
|
|
|
23
|
-
##
|
|
24
|
-
|
|
25
|
-
|
|
32
|
+
## Modern Leptos 0.7/0.8, Dioxus Web, and Axum + Askama/Maud idioms
|
|
33
|
+
|
|
34
|
+
- **Leptos 0.7 / 0.8**: signals no longer take a `Scope` (`cx`) argument—use **`let (count, set_count) = signal(0);`** or **`let count = RwSignal::new(0);`** with `.get()`/`.set()`/`.update(...)`. Mark interactive islands with **`#[island]`**, define typed server RPCs with **`#[server]`** (`ServerFn`), and bind progressive HTML forms with **`<ActionForm action=save_action>`** so submissions work even before WASM loads.
|
|
35
|
+
- **Dioxus Web (0.6 / 0.7)**: use `rsx!`, `use_signal`, `use_memo`, and `use_resource` for async states (`None` loading, `Some(Err(...))` error, `Some(Ok(...))` data), plus `#[server]` functions in Dioxus Fullstack (`dx serve --platform web`).
|
|
36
|
+
- **Axum + Askama / Maud + htmx**: render compile-time checked HTML via Askama (`#[derive(Template)]`) or Maud (`html! { ... }`), return full pages on normal requests and fragments when the `HX-Request` header is present (with `Vary: HX-Request`), and follow `htmx-alpine.md` swap/focus hygiene.
|
|
37
|
+
|
|
38
|
+
```rust
|
|
39
|
+
// Leptos 0.7/0.8: #[server] + #[island] + <ActionForm> + RwSignal::new
|
|
40
|
+
use leptos::prelude::*;
|
|
41
|
+
|
|
42
|
+
#[server(SaveNote, "/api")]
|
|
43
|
+
pub async fn save_note(title: String) -> Result<String, ServerFnError> {
|
|
44
|
+
if title.trim().is_empty() {
|
|
45
|
+
return Err(ServerFnError::new("Title is required."));
|
|
46
|
+
}
|
|
47
|
+
Ok(title)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
#[island]
|
|
51
|
+
pub fn NoteComposer() -> impl IntoView {
|
|
52
|
+
let save = ServerAction::<SaveNote>::new();
|
|
53
|
+
let title = RwSignal::new(String::new());
|
|
54
|
+
let pending = save.pending();
|
|
55
|
+
|
|
56
|
+
view! {
|
|
57
|
+
<ActionForm action=save>
|
|
58
|
+
<label for="note-title">"Title"</label>
|
|
59
|
+
<input id="note-title" name="title" bind:value=title required />
|
|
60
|
+
<button type="submit" disabled=move || pending.get()>
|
|
61
|
+
{move || if pending.get() { "Saving…" } else { "Save note" }}
|
|
62
|
+
</button>
|
|
63
|
+
</ActionForm>
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
```
|
|
26
67
|
|
|
27
|
-
## Forms idiom
|
|
68
|
+
## States & Forms idiom
|
|
28
69
|
|
|
29
|
-
Use
|
|
70
|
+
Use resources/futures/signals (`Resource`, `use_resource`, `ActionForm`) or Axum HTTP 422 fragments for loading/error/empty/offline/permission states. Preserve input across failed actions and make retry/cancellation explicit. Treat hydration mismatch as UX failure.
|
|
30
71
|
|
|
31
72
|
## Do/don't pairs
|
|
32
73
|
|
|
33
74
|
| Do | Don't |
|
|
34
75
|
|---|---|
|
|
35
|
-
| `
|
|
36
|
-
|
|
|
37
|
-
|
|
|
38
|
-
|
|
|
76
|
+
| `RwSignal::new(...)` / `signal(...)`, `#[island]`, and `<ActionForm>` in Leptos 0.7/0.8 | Copy obsolete Leptos 0.5 `create_signal(cx, ...)` code or hydrate entire static pages |
|
|
77
|
+
| Choose Axum + Askama/Maud + htmx when zero-WASM fast SSR fits the UI | Ship a multi-megabyte WASM bundle just to render CRUD forms |
|
|
78
|
+
| `view! { <label for="email">"Email"</label><input id="email" type="email" autocomplete="email" /> }` | Clickable `<div>`s reconstructed in Rust |
|
|
79
|
+
| Guard `web_sys::window()` behind client-only branches or `leptos_use` | Panic during SSR by unwrapping `window()` unconditionally |
|
|
80
|
+
| Semantic CSS variables imported at document root | Hex literals embedded inside Rust view macros |
|
|
39
81
|
|
|
40
82
|
## Known traps
|
|
41
83
|
|
|
42
|
-
SSR/browser-only API mismatch,
|
|
84
|
+
SSR/browser-only API mismatch, legacy Leptos `cx` scope signatures copied from old tutorials, unoptimized debug WASM sizes, hydration mismatch, focus loss across async replacement, assuming Rust type safety verifies ARIA/labels/contrast, missing `Vary: HX-Request` on Axum + htmx endpoints.
|
|
43
85
|
|
|
44
86
|
## Verification commands
|
|
45
87
|
|
|
46
88
|
```sh
|
|
47
89
|
cargo test
|
|
48
90
|
cargo clippy -- -D warnings
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
91
|
+
cargo leptos watch # Leptos full-stack projects
|
|
92
|
+
dx serve --platform web # Dioxus Web projects
|
|
93
|
+
trunk serve # Yew / static WASM projects
|
|
94
|
+
npx playwright test # browser behavior
|
|
52
95
|
```
|
|
53
96
|
|
|
54
|
-
Inspect pre-hydration HTML, post-hydration DOM/accessibility tree, network throttling
|
|
97
|
+
Inspect pre-hydration HTML (`static`/no-JS `rendered`), post-hydration DOM/accessibility tree, WASM payload under network throttling, keyboard-only flow, and reduced-motion emulation (`rendered`).
|
|
@@ -51,11 +51,13 @@ ARIA/label boundary issues, focus delegation confusion, duplicate IDs across sha
|
|
|
51
51
|
|
|
52
52
|
## Verification commands
|
|
53
53
|
|
|
54
|
+
Run the project's configured browser test runner (`web-test-runner` or Playwright) without suppressing failures:
|
|
55
|
+
|
|
54
56
|
```sh
|
|
55
57
|
npm run test -- --run
|
|
56
58
|
npm run build
|
|
59
|
+
npx web-test-runner
|
|
57
60
|
npx playwright test
|
|
58
|
-
npx web-test-runner 2>/dev/null || true
|
|
59
61
|
```
|
|
60
62
|
|
|
61
|
-
Test in real browsers because shadow DOM behavior and accessibility trees differ from shallow unit rendering.
|
|
63
|
+
Test in real browsers (`rendered`) because shadow DOM behavior, `ElementInternals` form participation, and accessibility trees differ from shallow unit rendering.
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Local-first, realtime sync, and CRDT engines
|
|
2
|
+
|
|
3
|
+
Choose a sync/CRDT architecture when the UI requires **instant local writes, offline resilience, cross-tab consistency, or live multiplayer editing**—not for ordinary request/response CRUD where TanStack Query suffices ([state-architecture.md](state-architecture.md)).
|
|
4
|
+
|
|
5
|
+
## Sync engine decision matrix
|
|
6
|
+
|
|
7
|
+
| Engine | Data model | Offline / persistence | Presence / realtime | Best fit |
|
|
8
|
+
|---|---|---|---|---|
|
|
9
|
+
| **Yjs** (`yjs`, `y-indexeddb`, `y-websocket`, Hocuspocus) | Sequence & map CRDTs (`Y.Doc`, `Y.Text`, `Y.XmlFragment`) | `IndexeddbPersistence` (`y-indexeddb`) | Built-in Awareness protocol | Collaborative rich text (Tiptap, Lexical, CodeMirror, Monaco) and whiteboards |
|
|
10
|
+
| **Automerge** (`@automerge/automerge-repo`) | JSON-like document CRDT (WASM Rust core) + binary sync | `IndexedDBStorageAdapter` + `BroadcastChannel` | Ephemeral messages | Local-first structured documents, offline multi-device apps, git-like history |
|
|
11
|
+
| **Zero (Rocicorp)** | Postgres-backed client cache + ZQL reactive queries + custom mutators | IndexedDB / local query cache | Live incremental Postgres sync | Instant-UI SaaS apps backed by existing Postgres needing sub-frame optimistic writes |
|
|
12
|
+
| **ElectricSQL** | Postgres logical-replication HTTP **Shapes** streamed to clients | Pairs with local stores / **TanStack DB** / PGlite | Live Shape SSE/long-poll stream | Read-heavy sync of Postgres subsets into existing web apps without replacing Postgres |
|
|
13
|
+
| **TanStack DB** | Reactive client collections + differential dataflow live joins + optimistic mutations | Pluggable (TanStack Query, ElectricSQL, Zero, custom) | Driven by backing collection sync | Frontend-first reactive relational cache and instant optimistic UX across frameworks |
|
|
14
|
+
| **PowerSync** | SQLite-in-browser (WASM/OPFS) synced bi-directionally with Postgres/Mongo/MySQL | Full local SQLite (OPFS/IndexedDB) | Streaming sync buckets + upload queue | Offline-first SQL apps needing full local SQL queries and conflict-controlled server writes |
|
|
15
|
+
| **Jazz** | End-to-end encrypted collaborative values (`CoMap`, `CoList`, `CoFeed`) | Built-in IndexedDB / local-first | Realtime peer/mesh sync + group RBAC | Collaborative local-first apps wanting built-in E2E encryption and permissions |
|
|
16
|
+
| **InstantDB** | Realtime client graph DB (`InstaQL`) with declarative CEL permissions | Local IndexedDB cache + optimistic writes | Live WebSocket subscriptions + presence rooms | Realtime collaborative SaaS & multiplayer apps wanting Firebase-like ergonomics with relational queries |
|
|
17
|
+
| **Convex** | Reactive TypeScript backend (`useQuery`/`useMutation`) + transactional DB | Optimistic updates (online-first reactive) | Automatic live WebSocket query invalidation | Full-stack TypeScript apps wanting end-to-end reactive queries without hand-building sync |
|
|
18
|
+
| **TinyBase** | Lightweight reactive tabular/key-value store + optional CRDT/synchronizer | IndexedDB / OPFS / SQLite / `localStorage` persisters | WebSocket / BroadcastChannel / Durable Objects synchronizers | Small-footprint reactive local stores, local-first tools, and custom sync topologies |
|
|
19
|
+
| **Liveblocks** (`@liveblocks/react`) | Managed realtime rooms (`LiveObject`/`LiveList`/Yjs) + comments | Managed cloud + Yjs integration | First-class `useMyPresence` / `useOthers` | Turnkey multiplayer SaaS (live cursors, threads, collaborative React Flow/tldraw/Tiptap) |
|
|
20
|
+
| **RxDB** (`rxdb`) | Local-first reactive NoSQL database + replication | `getRxStorageDexie()` / IndexedDB / OPFS | Via replication | Offline-first collection apps needing reactive RxJS queries (`.find().$`) and JSON schemas |
|
|
21
|
+
| **PartyKit / Cloudflare Durable Objects** | Stateful edge WebSocket rooms (per-document actor) | Hibernatable WebSockets + SQLite DO storage | Direct room broadcasts (`y-partyserver`, custom presence) | Hosting your own low-latency multiplayer rooms or Yjs sync servers at the edge |
|
|
22
|
+
|
|
23
|
+
## Verified implementation idioms
|
|
24
|
+
|
|
25
|
+
### Yjs + `y-indexeddb` lifecycle
|
|
26
|
+
|
|
27
|
+
- Always group related mutations inside `ydoc.transact(() => { ... })` so observers and network providers emit a single atomic update.
|
|
28
|
+
- Calling `ydoc.destroy()` automatically tears down attached `IndexeddbPersistence` providers (preserving stored IndexedDB data). If a provider may be destroyed before opening completes, guard `provider.whenSynced.catch(() => {})`.
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import * as Y from 'yjs';
|
|
32
|
+
import { IndexeddbPersistence } from 'y-indexeddb';
|
|
33
|
+
|
|
34
|
+
const doc = new Y.Doc();
|
|
35
|
+
const persistence = new IndexeddbPersistence('doc-123', doc);
|
|
36
|
+
|
|
37
|
+
await persistence.whenSynced;
|
|
38
|
+
doc.transact(() => {
|
|
39
|
+
doc.getMap('meta').set('title', 'Q4 Plan');
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// Cleanup on unmount (closes DB connection without deleting stored data)
|
|
43
|
+
doc.destroy();
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Automerge Repo (`@automerge/automerge-repo`)
|
|
47
|
+
|
|
48
|
+
- Combine `BroadcastChannelNetworkAdapter` (instant cross-tab sync), `WebSocketClientAdapter` (remote sync), and `IndexedDBStorageAdapter` (offline persistence) in one `Repo`.
|
|
49
|
+
- **Mutation API**: in core `@automerge/automerge-repo`, mutate via **`handle.change((d) => { ... })`** on a `DocHandle` (never mutate `handle.docSync()` snapshots in place). When using `@automerge/automerge-repo-react-hooks`, `useDocument(docUrl)` returns `[doc, changeDoc]` which delegates to `handle.change(...)` under the hood.
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
import { Repo } from '@automerge/automerge-repo';
|
|
53
|
+
import { BroadcastChannelNetworkAdapter } from '@automerge/automerge-repo-network-broadcastchannel';
|
|
54
|
+
import { WebSocketClientAdapter } from '@automerge/automerge-repo-network-websocket';
|
|
55
|
+
import { IndexedDBStorageAdapter } from '@automerge/automerge-repo-storage-indexeddb';
|
|
56
|
+
|
|
57
|
+
export const repo = new Repo({
|
|
58
|
+
network: [
|
|
59
|
+
new BroadcastChannelNetworkAdapter(),
|
|
60
|
+
new WebSocketClientAdapter('wss://sync.example.com'),
|
|
61
|
+
],
|
|
62
|
+
storage: new IndexedDBStorageAdapter(),
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const handle = repo.create<{ title: string }>({ title: 'Draft' });
|
|
66
|
+
handle.change((d) => {
|
|
67
|
+
d.title = 'Q4 Plan';
|
|
68
|
+
});
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Database-backed sync (Zero / ElectricSQL + TanStack DB / PowerSync / Convex / InstantDB)
|
|
72
|
+
|
|
73
|
+
- **Authorization boundary**: client sync caches cannot enforce security—always enforce row-level permissions on the sync server (Zero permissions/custom mutators, Electric auth proxy + Shape filters, PowerSync sync rules, Convex server mutations, InstantDB permission rules).
|
|
74
|
+
- **Optimistic mutation reconciliation**: show immediate local updates, attach clear rollback/conflict recovery if the server rejects a custom mutator, and avoid syncing unbounded tables into browser storage (scope Shapes/queries to the active workspace or time window).
|
|
75
|
+
|
|
76
|
+
### Liveblocks, RxDB, TinyBase, and Durable Objects
|
|
77
|
+
|
|
78
|
+
- **Liveblocks**: use `authEndpoint="/api/liveblocks-auth"` (never expose a `publicApiKey` for private rooms) and wrap room consumers in `<ClientSideSuspense fallback={...}>` so SSR never crashes.
|
|
79
|
+
- **RxDB**: declare `indexes` on sorted/filtered fields in the collection JSON schema and unsubscribe from reactive `query.$` observables on unmount.
|
|
80
|
+
- **PartyKit / Cloudflare Durable Objects**: enable WebSocket Hibernation on room DOs and persist snapshots/WALs to DO storage so idle rooms scale to zero without losing edits.
|
|
81
|
+
|
|
82
|
+
## Multiplayer & offline UX contract
|
|
83
|
+
|
|
84
|
+
- **Explicit sync state**: surface `Saved locally (offline)`, `Syncing…`, `Synced`, and `Sync error (retry)` calmly—never hide offline unsynced edits behind a fake "Saved" checkmark.
|
|
85
|
+
- **Presence restraint**: throttle pointer/cursor broadcasts (`~30–60 ms`), fade idle cursors, and respect `prefers-reduced-motion` on remote cursor interpolation.
|
|
86
|
+
- **Per-user undo**: in collaborative docs, scope Undo/Redo to the local user's operations (`Y.UndoManager` / collaborative history), never rolling back a teammate's edits.
|
|
87
|
+
|
|
88
|
+
## Do/don't pairs
|
|
89
|
+
|
|
90
|
+
| Do | Don't |
|
|
91
|
+
|---|---|
|
|
92
|
+
| Batch multi-field Yjs edits inside `doc.transact()` and call `doc.destroy()` on unmount | Emit 50 individual network updates in a loop or leak IndexedDB/WebSocket providers |
|
|
93
|
+
| Mutate Automerge docs via `handle.change((d) => ...)` (or `changeDoc` from `useDocument`) | Mutate frozen Automerge `doc` snapshots in place |
|
|
94
|
+
| Scope Electric Shapes / Zero queries / PowerSync buckets to authorized workspace slices | Replicate an entire multi-tenant database into browser IndexedDB/OPFS |
|
|
95
|
+
| Use `authEndpoint` for private Liveblocks rooms + `<ClientSideSuspense>` | Ship `publicApiKey` on private collaborative documents |
|
|
96
|
+
| Scope Undo/Redo to the local user (`Y.UndoManager`) and show honest offline sync status | Let `Ctrl+Z` revert another collaborator's work or display "Saved" while offline |
|
|
97
|
+
|
|
98
|
+
## Verification commands
|
|
99
|
+
|
|
100
|
+
```sh
|
|
101
|
+
npm run build
|
|
102
|
+
npx playwright test
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Verify offline edit → reload → reconnect merge convergence and authorization rejection rollback across two browser contexts (simulating two collaborators + offline mode) in Playwright (`rendered`).
|