@thanhnguyxn/pixelcraft 0.0.0-stage → 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.
Files changed (455) hide show
  1. package/.agents/plugins/marketplace.json +20 -0
  2. package/.antigravity-plugin/plugin.json +32 -0
  3. package/.claude-plugin/marketplace.json +20 -0
  4. package/.claude-plugin/plugin.json +22 -0
  5. package/.codex-plugin/plugin.json +45 -0
  6. package/.cursor-plugin/marketplace.json +17 -0
  7. package/.cursor-plugin/plugin.json +27 -0
  8. package/.devin-plugin/plugin.json +21 -0
  9. package/.github/plugin/marketplace.json +34 -0
  10. package/CHANGELOG.md +159 -0
  11. package/GEMINI.md +1 -0
  12. package/LICENSE +21 -0
  13. package/README.md +264 -2
  14. package/SECURITY.md +28 -0
  15. package/assets/README.md +28 -0
  16. package/assets/pixelcraft-logo-128.png +0 -0
  17. package/assets/pixelcraft-logo-256.png +0 -0
  18. package/assets/pixelcraft-logo-512.png +0 -0
  19. package/bin/pixelcraft.mjs +852 -0
  20. package/docs/ARCHITECTURE.md +105 -0
  21. package/docs/DESIGN-RATIONALE.md +191 -0
  22. package/docs/INSTALL.md +221 -0
  23. package/evals/README.md +37 -0
  24. package/evals/fixtures/3d-web-engineering.json +69 -0
  25. package/evals/fixtures/README.md +36 -0
  26. package/evals/fixtures/acceptance-checklist-rule03-gate.json +43 -0
  27. package/evals/fixtures/ai-ui-libraries.json +53 -0
  28. package/evals/fixtures/audio-visual-accessibility.json +69 -0
  29. package/evals/fixtures/auth-and-checkout-ui.json +53 -0
  30. package/evals/fixtures/brandkit-identity-governance.json +48 -0
  31. package/evals/fixtures/build-and-architecture.json +53 -0
  32. package/evals/fixtures/canvas-and-node-editors.json +53 -0
  33. package/evals/fixtures/chat-ai-exfiltration-ime-hitl-gate.json +43 -0
  34. package/evals/fixtures/completion-gate-scan-until-clean.json +44 -0
  35. package/evals/fixtures/component-systems.json +53 -0
  36. package/evals/fixtures/component-testing.json +53 -0
  37. package/evals/fixtures/constrained-voice-and-tv.json +43 -0
  38. package/evals/fixtures/creative-code-rendering.json +69 -0
  39. package/evals/fixtures/creative-reference-evidence.json +67 -0
  40. package/evals/fixtures/data-app-python-marimo.json +49 -0
  41. package/evals/fixtures/desktop-cpp-juce-audio.json +49 -0
  42. package/evals/fixtures/desktop-csharp-avalonia.json +49 -0
  43. package/evals/fixtures/desktop-native-workspace.json +48 -0
  44. package/evals/fixtures/desktop-python-anti-tkinter.json +49 -0
  45. package/evals/fixtures/direction-prototype-complexity.json +29 -0
  46. package/evals/fixtures/document-prepress-pdfx4-tounicode.json +43 -0
  47. package/evals/fixtures/document-rust-typst-invoice.json +49 -0
  48. package/evals/fixtures/document-typst-and-print-css.json +43 -0
  49. package/evals/fixtures/email-mjml-dark-mode.json +49 -0
  50. package/evals/fixtures/email-outlook-and-plaintext.json +43 -0
  51. package/evals/fixtures/enterprise-data-ui.json +53 -0
  52. package/evals/fixtures/extended-tui-toolkits.json +53 -0
  53. package/evals/fixtures/extensions-mv3-and-vscode.json +43 -0
  54. package/evals/fixtures/file-upload-media-ui.json +53 -0
  55. package/evals/fixtures/finish-gate-anti-slop.json +30 -0
  56. package/evals/fixtures/forms-accessibility-negative.json +29 -0
  57. package/evals/fixtures/forms-validation.json +53 -0
  58. package/evals/fixtures/game-go-ebitengine.json +49 -0
  59. package/evals/fixtures/game-godot-gdscript.json +49 -0
  60. package/evals/fixtures/game-ui-hud-and-engines.json +43 -0
  61. package/evals/fixtures/handoff-fidelity-tolerance.json +29 -0
  62. package/evals/fixtures/i18n-engineering.json +53 -0
  63. package/evals/fixtures/local-first-sync.json +53 -0
  64. package/evals/fixtures/lynxjs.json +53 -0
  65. package/evals/fixtures/maizzle-email.json +53 -0
  66. package/evals/fixtures/maps-geospatial.json +53 -0
  67. package/evals/fixtures/media-og-and-video-export.json +43 -0
  68. package/evals/fixtures/media-players.json +53 -0
  69. package/evals/fixtures/mobile-compose-16kb-foldable-store-gate.json +44 -0
  70. package/evals/fixtures/mobile-elixir-liveview-native.json +49 -0
  71. package/evals/fixtures/mobile-flutter-dynamic-type.json +49 -0
  72. package/evals/fixtures/mobile-harmonyos-arkui.json +49 -0
  73. package/evals/fixtures/mobile-jetpack-compose.json +49 -0
  74. package/evals/fixtures/mobile-swiftui-ios.json +49 -0
  75. package/evals/fixtures/motion-engineering.json +69 -0
  76. package/evals/fixtures/pdfjs-and-pptx.json +53 -0
  77. package/evals/fixtures/plan-brownfield-evidence.json +28 -0
  78. package/evals/fixtures/plan-discovery-interview.json +31 -0
  79. package/evals/fixtures/plan-grill-me-brainstorm-gate.json +49 -0
  80. package/evals/fixtures/reactive-data-apps.json +53 -0
  81. package/evals/fixtures/review-evidence-audit.json +43 -0
  82. package/evals/fixtures/rich-text-and-code-editors.json +53 -0
  83. package/evals/fixtures/scrollytelling-resilience.json +70 -0
  84. package/evals/fixtures/spatial-xr-comfort-and-platforms.json +43 -0
  85. package/evals/fixtures/state-architecture.json +53 -0
  86. package/evals/fixtures/styling-ecosystem.json +53 -0
  87. package/evals/fixtures/token-tooling.json +53 -0
  88. package/evals/fixtures/tui-go-bubbletea.json +49 -0
  89. package/evals/fixtures/tui-rust-ratatui-grapheme-paste-teardown.json +44 -0
  90. package/evals/fixtures/tui-rust-ratatui.json +49 -0
  91. package/evals/fixtures/ux-state-matrix-and-i18n.json +43 -0
  92. package/evals/fixtures/visual-qa-task-evidence.json +29 -0
  93. package/evals/fixtures/web-3d-engines.json +53 -0
  94. package/evals/fixtures/web-php-laravel-filament.json +49 -0
  95. package/evals/fixtures/web-ruby-viewcomponent-phlex.json +49 -0
  96. package/evals/fixtures/workflow-checkpoints.json +30 -0
  97. package/evals/pixelcraft-accessibility.md +74 -0
  98. package/evals/pixelcraft-brandkit.md +58 -0
  99. package/evals/pixelcraft-chat-ui.md +55 -0
  100. package/evals/pixelcraft-constrained.md +55 -0
  101. package/evals/pixelcraft-craft.md +76 -0
  102. package/evals/pixelcraft-data-apps.md +55 -0
  103. package/evals/pixelcraft-dataviz.md +59 -0
  104. package/evals/pixelcraft-desktop.md +55 -0
  105. package/evals/pixelcraft-direction.md +77 -0
  106. package/evals/pixelcraft-document.md +55 -0
  107. package/evals/pixelcraft-email.md +55 -0
  108. package/evals/pixelcraft-extensions.md +55 -0
  109. package/evals/pixelcraft-game-ui.md +59 -0
  110. package/evals/pixelcraft-handoff.md +57 -0
  111. package/evals/pixelcraft-media.md +55 -0
  112. package/evals/pixelcraft-mobile.md +59 -0
  113. package/evals/pixelcraft-patterns.md +73 -0
  114. package/evals/pixelcraft-plan.md +127 -0
  115. package/evals/pixelcraft-review.md +63 -0
  116. package/evals/pixelcraft-spatial.md +55 -0
  117. package/evals/pixelcraft-tokens.md +57 -0
  118. package/evals/pixelcraft-tui.md +55 -0
  119. package/evals/pixelcraft-ux.md +59 -0
  120. package/evals/pixelcraft-visual-qa.md +86 -0
  121. package/evals/pixelcraft-web.md +89 -0
  122. package/evals/pixelcraft.md +70 -0
  123. package/gemini-extension.json +6 -0
  124. package/install.ps1 +341 -0
  125. package/install.sh +512 -0
  126. package/package.json +91 -4
  127. package/plugin.json +29 -0
  128. package/scripts/build-adapters.mjs +288 -0
  129. package/scripts/build-release-archives.mjs +61 -0
  130. package/scripts/build-skill-zips.mjs +94 -0
  131. package/scripts/run-evals.mjs +397 -0
  132. package/scripts/sync-docs.mjs +381 -0
  133. package/scripts/test-build-adapters.mjs +61 -0
  134. package/scripts/test-cross-platform-qa.mjs +359 -0
  135. package/scripts/test-distribution.mjs +203 -0
  136. package/scripts/test-export-tokens.mjs +361 -0
  137. package/scripts/test-finish-gate.mjs +271 -0
  138. package/scripts/test-installers.mjs +216 -0
  139. package/scripts/test-release-archives.mjs +42 -0
  140. package/scripts/test-shoot.mjs +87 -0
  141. package/scripts/test-slop-scan.mjs +416 -0
  142. package/scripts/test-style-inventory.mjs +234 -0
  143. package/scripts/test-sync-docs.mjs +140 -0
  144. package/scripts/test-validate-skills.mjs +195 -0
  145. package/scripts/validate-skills.mjs +658 -0
  146. package/skills/pixelcraft/SKILL.md +155 -0
  147. package/skills/pixelcraft/references/design-brief.md +75 -0
  148. package/skills/pixelcraft/references/floor.md +90 -0
  149. package/skills/pixelcraft/references/report-template.md +49 -0
  150. package/skills/pixelcraft/references/stack-detection.md +226 -0
  151. package/skills/pixelcraft/references/surface-acceptance.md +52 -0
  152. package/skills/pixelcraft/references/workflow-checkpoints.md +71 -0
  153. package/skills/pixelcraft-accessibility/SKILL.md +54 -0
  154. package/skills/pixelcraft-accessibility/references/apg-patterns.md +64 -0
  155. package/skills/pixelcraft-accessibility/references/motion-canvas.md +57 -0
  156. package/skills/pixelcraft-accessibility/references/platforms.md +86 -0
  157. package/skills/pixelcraft-accessibility/references/verification.md +64 -0
  158. package/skills/pixelcraft-accessibility/references/wcag22-checks.md +99 -0
  159. package/skills/pixelcraft-brandkit/SKILL.md +127 -0
  160. package/skills/pixelcraft-brandkit/references/asset-pipeline.md +165 -0
  161. package/skills/pixelcraft-brandkit/references/brand-governance.md +82 -0
  162. package/skills/pixelcraft-brandkit/references/layouts.md +88 -0
  163. package/skills/pixelcraft-brandkit/references/logo-concepting.md +83 -0
  164. package/skills/pixelcraft-brandkit/references/logo-methods.md +97 -0
  165. package/skills/pixelcraft-brandkit/references/pixel-art-logos.md +82 -0
  166. package/skills/pixelcraft-brandkit/references/prompt-template.md +87 -0
  167. package/skills/pixelcraft-brandkit/references/qa-checklist.md +93 -0
  168. package/skills/pixelcraft-brandkit/references/visual-modes.md +123 -0
  169. package/skills/pixelcraft-chat-ui/SKILL.md +57 -0
  170. package/skills/pixelcraft-chat-ui/references/agentic-workspace.md +66 -0
  171. package/skills/pixelcraft-chat-ui/references/ai-ui-libraries.md +259 -0
  172. package/skills/pixelcraft-chat-ui/references/conversation-design.md +84 -0
  173. package/skills/pixelcraft-chat-ui/references/mobile-business-platforms.md +77 -0
  174. package/skills/pixelcraft-chat-ui/references/slack-discord.md +80 -0
  175. package/skills/pixelcraft-constrained/SKILL.md +52 -0
  176. package/skills/pixelcraft-constrained/references/specialized-hardware.md +90 -0
  177. package/skills/pixelcraft-constrained/references/tv-wearables.md +134 -0
  178. package/skills/pixelcraft-constrained/references/voice-ui.md +104 -0
  179. package/skills/pixelcraft-craft/SKILL.md +58 -0
  180. package/skills/pixelcraft-craft/references/color.md +125 -0
  181. package/skills/pixelcraft-craft/references/imagery-icons.md +37 -0
  182. package/skills/pixelcraft-craft/references/layout-quality.md +65 -0
  183. package/skills/pixelcraft-craft/references/layout.md +73 -0
  184. package/skills/pixelcraft-craft/references/motion.md +163 -0
  185. package/skills/pixelcraft-craft/references/typography.md +110 -0
  186. package/skills/pixelcraft-data-apps/SKILL.md +86 -0
  187. package/skills/pixelcraft-data-apps/references/ai-and-internal-data-apps.md +147 -0
  188. package/skills/pixelcraft-data-apps/references/dash.md +109 -0
  189. package/skills/pixelcraft-data-apps/references/evidence.md +90 -0
  190. package/skills/pixelcraft-data-apps/references/gradio.md +103 -0
  191. package/skills/pixelcraft-data-apps/references/julia-genie.md +89 -0
  192. package/skills/pixelcraft-data-apps/references/jupyter-widgets.md +91 -0
  193. package/skills/pixelcraft-data-apps/references/nicegui.md +102 -0
  194. package/skills/pixelcraft-data-apps/references/observable-framework.md +105 -0
  195. package/skills/pixelcraft-data-apps/references/panel.md +99 -0
  196. package/skills/pixelcraft-data-apps/references/r-shiny.md +124 -0
  197. package/skills/pixelcraft-data-apps/references/reactive-data-apps.md +186 -0
  198. package/skills/pixelcraft-data-apps/references/reflex.md +116 -0
  199. package/skills/pixelcraft-data-apps/references/shiny.md +110 -0
  200. package/skills/pixelcraft-data-apps/references/streamlit.md +113 -0
  201. package/skills/pixelcraft-dataviz/SKILL.md +60 -0
  202. package/skills/pixelcraft-dataviz/references/chart-choice.md +55 -0
  203. package/skills/pixelcraft-dataviz/references/color-accessibility.md +112 -0
  204. package/skills/pixelcraft-dataviz/references/encoding-tables-dashboards.md +107 -0
  205. package/skills/pixelcraft-dataviz/references/libraries.md +176 -0
  206. package/skills/pixelcraft-dataviz/references/maps-geospatial.md +159 -0
  207. package/skills/pixelcraft-dataviz/references/realtime-graphs-maps-scale.md +92 -0
  208. package/skills/pixelcraft-desktop/SKILL.md +93 -0
  209. package/skills/pixelcraft-desktop/references/appkit.md +92 -0
  210. package/skills/pixelcraft-desktop/references/avalonia.md +95 -0
  211. package/skills/pixelcraft-desktop/references/cpp-gui.md +129 -0
  212. package/skills/pixelcraft-desktop/references/electron.md +96 -0
  213. package/skills/pixelcraft-desktop/references/go-gui.md +83 -0
  214. package/skills/pixelcraft-desktop/references/gtk.md +97 -0
  215. package/skills/pixelcraft-desktop/references/javafx-swing.md +81 -0
  216. package/skills/pixelcraft-desktop/references/qt-pyside-qml.md +88 -0
  217. package/skills/pixelcraft-desktop/references/rust-gui.md +83 -0
  218. package/skills/pixelcraft-desktop/references/tauri.md +110 -0
  219. package/skills/pixelcraft-desktop/references/uno-platform.md +71 -0
  220. package/skills/pixelcraft-desktop/references/winui-wpf.md +98 -0
  221. package/skills/pixelcraft-desktop/references/working-context.md +84 -0
  222. package/skills/pixelcraft-direction/SKILL.md +120 -0
  223. package/skills/pixelcraft-direction/references/composition-library.md +84 -0
  224. package/skills/pixelcraft-direction/references/creative-brainstorming.md +72 -0
  225. package/skills/pixelcraft-direction/references/direction-card.md +64 -0
  226. package/skills/pixelcraft-direction/references/direction-scoring.md +76 -0
  227. package/skills/pixelcraft-direction/references/motion-identity.md +67 -0
  228. package/skills/pixelcraft-direction/references/movements.md +71 -0
  229. package/skills/pixelcraft-direction/references/reference-analysis.md +37 -0
  230. package/skills/pixelcraft-direction/references/repetition-history.md +75 -0
  231. package/skills/pixelcraft-direction/references/slop-fingerprints.md +83 -0
  232. package/skills/pixelcraft-direction/references/wildcards.md +47 -0
  233. package/skills/pixelcraft-document/SKILL.md +58 -0
  234. package/skills/pixelcraft-document/references/archetypes.md +106 -0
  235. package/skills/pixelcraft-document/references/pdf-tools.md +314 -0
  236. package/skills/pixelcraft-document/references/pdfjs-and-pptx.md +114 -0
  237. package/skills/pixelcraft-document/references/print-css.md +187 -0
  238. package/skills/pixelcraft-document/references/slides.md +198 -0
  239. package/skills/pixelcraft-email/SKILL.md +80 -0
  240. package/skills/pixelcraft-email/references/client-quirks.md +113 -0
  241. package/skills/pixelcraft-email/references/html-tables.md +114 -0
  242. package/skills/pixelcraft-email/references/maizzle.md +54 -0
  243. package/skills/pixelcraft-email/references/mjml.md +54 -0
  244. package/skills/pixelcraft-email/references/react-email.md +95 -0
  245. package/skills/pixelcraft-extensions/SKILL.md +56 -0
  246. package/skills/pixelcraft-extensions/references/browser-extensions.md +105 -0
  247. package/skills/pixelcraft-extensions/references/figma-office.md +106 -0
  248. package/skills/pixelcraft-extensions/references/ide-and-saas-plugins.md +125 -0
  249. package/skills/pixelcraft-extensions/references/raycast.md +98 -0
  250. package/skills/pixelcraft-extensions/references/vscode-webviews.md +100 -0
  251. package/skills/pixelcraft-game-ui/SKILL.md +80 -0
  252. package/skills/pixelcraft-game-ui/references/bevy.md +90 -0
  253. package/skills/pixelcraft-game-ui/references/godot.md +130 -0
  254. package/skills/pixelcraft-game-ui/references/hud-principles.md +67 -0
  255. package/skills/pixelcraft-game-ui/references/love2d.md +77 -0
  256. package/skills/pixelcraft-game-ui/references/monogame.md +68 -0
  257. package/skills/pixelcraft-game-ui/references/unity-ugui.md +109 -0
  258. package/skills/pixelcraft-game-ui/references/unity-ui-toolkit.md +107 -0
  259. package/skills/pixelcraft-game-ui/references/unreal-umg.md +80 -0
  260. package/skills/pixelcraft-game-ui/references/web-and-middleware-game-ui.md +122 -0
  261. package/skills/pixelcraft-handoff/SKILL.md +50 -0
  262. package/skills/pixelcraft-handoff/references/design-translation.md +134 -0
  263. package/skills/pixelcraft-handoff/references/fidelity-tolerance.md +78 -0
  264. package/skills/pixelcraft-handoff/references/motion-handoff.md +54 -0
  265. package/skills/pixelcraft-media/SKILL.md +49 -0
  266. package/skills/pixelcraft-media/references/banners-video.md +130 -0
  267. package/skills/pixelcraft-media/references/og-generation.md +154 -0
  268. package/skills/pixelcraft-media/references/social-cards.md +71 -0
  269. package/skills/pixelcraft-mobile/SKILL.md +86 -0
  270. package/skills/pixelcraft-mobile/references/dotnet-maui.md +91 -0
  271. package/skills/pixelcraft-mobile/references/flet.md +80 -0
  272. package/skills/pixelcraft-mobile/references/flutter.md +113 -0
  273. package/skills/pixelcraft-mobile/references/harmonyos-and-emerging-mobile.md +121 -0
  274. package/skills/pixelcraft-mobile/references/ionic-capacitor.md +87 -0
  275. package/skills/pixelcraft-mobile/references/jetpack-compose.md +129 -0
  276. package/skills/pixelcraft-mobile/references/kivy.md +82 -0
  277. package/skills/pixelcraft-mobile/references/kotlin-multiplatform.md +86 -0
  278. package/skills/pixelcraft-mobile/references/lynxjs.md +110 -0
  279. package/skills/pixelcraft-mobile/references/nativescript-and-skip.md +91 -0
  280. package/skills/pixelcraft-mobile/references/react-native-expo.md +106 -0
  281. package/skills/pixelcraft-mobile/references/swiftui.md +200 -0
  282. package/skills/pixelcraft-mobile/references/tactile-interactions.md +55 -0
  283. package/skills/pixelcraft-mobile/references/task-state-composition.md +85 -0
  284. package/skills/pixelcraft-mobile/references/uikit.md +92 -0
  285. package/skills/pixelcraft-patterns/SKILL.md +75 -0
  286. package/skills/pixelcraft-patterns/references/accessibility-resilience.md +29 -0
  287. package/skills/pixelcraft-patterns/references/ai-and-offline-patterns.md +54 -0
  288. package/skills/pixelcraft-patterns/references/auth-onboarding.md +44 -0
  289. package/skills/pixelcraft-patterns/references/billing-paywalls.md +40 -0
  290. package/skills/pixelcraft-patterns/references/command-workspace.md +56 -0
  291. package/skills/pixelcraft-patterns/references/commerce.md +47 -0
  292. package/skills/pixelcraft-patterns/references/communication.md +45 -0
  293. package/skills/pixelcraft-patterns/references/creative-tools.md +42 -0
  294. package/skills/pixelcraft-patterns/references/creative-web-composition.md +38 -0
  295. package/skills/pixelcraft-patterns/references/dashboard-admin.md +35 -0
  296. package/skills/pixelcraft-patterns/references/history-diff-undo.md +50 -0
  297. package/skills/pixelcraft-patterns/references/marketing.md +44 -0
  298. package/skills/pixelcraft-patterns/references/multi-tenant-rbac.md +47 -0
  299. package/skills/pixelcraft-patterns/references/narrative-systems.md +42 -0
  300. package/skills/pixelcraft-patterns/references/notifications-activity.md +57 -0
  301. package/skills/pixelcraft-patterns/references/pattern-selection.md +80 -0
  302. package/skills/pixelcraft-patterns/references/scheduling-kanban.md +47 -0
  303. package/skills/pixelcraft-patterns/references/scroll-implementation.md +37 -0
  304. package/skills/pixelcraft-patterns/references/search-filtering.md +42 -0
  305. package/skills/pixelcraft-patterns/references/settings.md +51 -0
  306. package/skills/pixelcraft-patterns/references/tables-crud.md +43 -0
  307. package/skills/pixelcraft-plan/SKILL.md +103 -0
  308. package/skills/pixelcraft-plan/references/design-input.md +69 -0
  309. package/skills/pixelcraft-plan/references/discovery-interview.md +110 -0
  310. package/skills/pixelcraft-plan/references/grill-me-protocol.md +63 -0
  311. package/skills/pixelcraft-plan/references/plan-template.md +134 -0
  312. package/skills/pixelcraft-plan/references/repo-discovery.md +49 -0
  313. package/skills/pixelcraft-plan/references/stack-freshness.md +67 -0
  314. package/skills/pixelcraft-plan/references/stack-selection.md +98 -0
  315. package/skills/pixelcraft-review/SKILL.md +86 -0
  316. package/skills/pixelcraft-review/references/audit-report.md +69 -0
  317. package/skills/pixelcraft-review/references/critique-protocol.md +89 -0
  318. package/skills/pixelcraft-review/references/heuristics.md +63 -0
  319. package/skills/pixelcraft-review/references/personas.md +53 -0
  320. package/skills/pixelcraft-review/references/polish.md +78 -0
  321. package/skills/pixelcraft-review/scripts/check-acceptance.mjs +619 -0
  322. package/skills/pixelcraft-review/scripts/fixtures/brand-critique-waivers.json +14 -0
  323. package/skills/pixelcraft-review/scripts/fixtures/brand-critique.css +18 -0
  324. package/skills/pixelcraft-review/scripts/fixtures/clean.html +43 -0
  325. package/skills/pixelcraft-review/scripts/fixtures/focus-after-block.css +4 -0
  326. package/skills/pixelcraft-review/scripts/fixtures/focus-at-rules.css +17 -0
  327. package/skills/pixelcraft-review/scripts/fixtures/focus-comments.css +10 -0
  328. package/skills/pixelcraft-review/scripts/fixtures/focus-html-quote-leak.html +12 -0
  329. package/skills/pixelcraft-review/scripts/fixtures/focus-invalid-replacements.css +27 -0
  330. package/skills/pixelcraft-review/scripts/fixtures/focus-longhand-removal.css +34 -0
  331. package/skills/pixelcraft-review/scripts/fixtures/focus-nested-rules.css +19 -0
  332. package/skills/pixelcraft-review/scripts/fixtures/focus-not-visible-skip.css +8 -0
  333. package/skills/pixelcraft-review/scripts/fixtures/focus-outline-shorthands.css +11 -0
  334. package/skills/pixelcraft-review/scripts/fixtures/focus-unknown-and-border.css +15 -0
  335. package/skills/pixelcraft-review/scripts/fixtures/focus-unknown-last-wins.css +19 -0
  336. package/skills/pixelcraft-review/scripts/fixtures/focus-valid-replacements-extended.css +29 -0
  337. package/skills/pixelcraft-review/scripts/fixtures/focus-visible-no-replacement.css +3 -0
  338. package/skills/pixelcraft-review/scripts/fixtures/focus-visible-valid-replacements.css +9 -0
  339. package/skills/pixelcraft-review/scripts/fixtures/slop.html +28 -0
  340. package/skills/pixelcraft-review/scripts/slop-scan.mjs +1233 -0
  341. package/skills/pixelcraft-spatial/SKILL.md +51 -0
  342. package/skills/pixelcraft-spatial/references/comfort-accessibility.md +39 -0
  343. package/skills/pixelcraft-spatial/references/platforms.md +147 -0
  344. package/skills/pixelcraft-tokens/SKILL.md +60 -0
  345. package/skills/pixelcraft-tokens/assets/tokens.example.json +71 -0
  346. package/skills/pixelcraft-tokens/assets/tokens.modes.example.json +47 -0
  347. package/skills/pixelcraft-tokens/references/adoption.md +55 -0
  348. package/skills/pixelcraft-tokens/references/format.md +84 -0
  349. package/skills/pixelcraft-tokens/references/governance.md +80 -0
  350. package/skills/pixelcraft-tokens/references/state-tokens.md +62 -0
  351. package/skills/pixelcraft-tokens/references/theme-presets.md +122 -0
  352. package/skills/pixelcraft-tokens/references/token-tooling.md +119 -0
  353. package/skills/pixelcraft-tokens/scripts/export-tokens.mjs +847 -0
  354. package/skills/pixelcraft-tui/SKILL.md +76 -0
  355. package/skills/pixelcraft-tui/references/bubbletea-lipgloss.md +79 -0
  356. package/skills/pixelcraft-tui/references/extended-tui-toolkits.md +127 -0
  357. package/skills/pixelcraft-tui/references/ink.md +109 -0
  358. package/skills/pixelcraft-tui/references/ratatui.md +102 -0
  359. package/skills/pixelcraft-tui/references/rich.md +82 -0
  360. package/skills/pixelcraft-tui/references/terminal-protocols.md +80 -0
  361. package/skills/pixelcraft-tui/references/textual.md +108 -0
  362. package/skills/pixelcraft-ux/SKILL.md +56 -0
  363. package/skills/pixelcraft-ux/references/cognitive-walkthrough.md +70 -0
  364. package/skills/pixelcraft-ux/references/feedback-performance.md +50 -0
  365. package/skills/pixelcraft-ux/references/flows-ia.md +44 -0
  366. package/skills/pixelcraft-ux/references/forms.md +151 -0
  367. package/skills/pixelcraft-ux/references/i18n.md +221 -0
  368. package/skills/pixelcraft-ux/references/laws.md +39 -0
  369. package/skills/pixelcraft-ux/references/locale-test-matrix.md +60 -0
  370. package/skills/pixelcraft-ux/references/state-matrix.md +53 -0
  371. package/skills/pixelcraft-ux/references/usability-testing.md +84 -0
  372. package/skills/pixelcraft-ux/references/ux-writing.md +44 -0
  373. package/skills/pixelcraft-visual-qa/SKILL.md +96 -0
  374. package/skills/pixelcraft-visual-qa/references/baseline-governance.md +70 -0
  375. package/skills/pixelcraft-visual-qa/references/capture-desktop-game.md +59 -0
  376. package/skills/pixelcraft-visual-qa/references/capture-document.md +70 -0
  377. package/skills/pixelcraft-visual-qa/references/capture-email.md +38 -0
  378. package/skills/pixelcraft-visual-qa/references/capture-mobile.md +50 -0
  379. package/skills/pixelcraft-visual-qa/references/capture-terminal.md +35 -0
  380. package/skills/pixelcraft-visual-qa/references/critique-rubric.md +71 -0
  381. package/skills/pixelcraft-visual-qa/references/finish-gate.md +35 -0
  382. package/skills/pixelcraft-visual-qa/references/measured-craft.md +30 -0
  383. package/skills/pixelcraft-visual-qa/references/motion-capture.md +63 -0
  384. package/skills/pixelcraft-visual-qa/references/performance-budgets.md +78 -0
  385. package/skills/pixelcraft-visual-qa/references/realtime-graphics.md +55 -0
  386. package/skills/pixelcraft-visual-qa/references/task-verification.md +81 -0
  387. package/skills/pixelcraft-visual-qa/scripts/check-contrast.mjs +442 -0
  388. package/skills/pixelcraft-visual-qa/scripts/check-email.mjs +397 -0
  389. package/skills/pixelcraft-visual-qa/scripts/check-pdf.mjs +189 -0
  390. package/skills/pixelcraft-visual-qa/scripts/check-tui.mjs +321 -0
  391. package/skills/pixelcraft-visual-qa/scripts/finish-gate.mjs +174 -0
  392. package/skills/pixelcraft-visual-qa/scripts/fixtures/shoot-aria-modal.html +19 -0
  393. package/skills/pixelcraft-visual-qa/scripts/fixtures/shoot-audit.html +34 -0
  394. package/skills/pixelcraft-visual-qa/scripts/fixtures/shoot-modal.html +17 -0
  395. package/skills/pixelcraft-visual-qa/scripts/fixtures/style-inventory-deferred.js +1 -0
  396. package/skills/pixelcraft-visual-qa/scripts/fixtures/style-inventory-edge.html +52 -0
  397. package/skills/pixelcraft-visual-qa/scripts/fixtures/style-inventory.html +80 -0
  398. package/skills/pixelcraft-visual-qa/scripts/fixtures/style-inventory.js +8 -0
  399. package/skills/pixelcraft-visual-qa/scripts/shoot.mjs +668 -0
  400. package/skills/pixelcraft-visual-qa/scripts/style-inventory.mjs +1226 -0
  401. package/skills/pixelcraft-web/SKILL.md +132 -0
  402. package/skills/pixelcraft-web/references/accessibility-performance.md +42 -0
  403. package/skills/pixelcraft-web/references/adaptive-layout.md +69 -0
  404. package/skills/pixelcraft-web/references/angular.md +108 -0
  405. package/skills/pixelcraft-web/references/assets-pipeline.md +67 -0
  406. package/skills/pixelcraft-web/references/astro.md +113 -0
  407. package/skills/pixelcraft-web/references/audio-reactive.md +61 -0
  408. package/skills/pixelcraft-web/references/auth-and-checkout-ui.md +115 -0
  409. package/skills/pixelcraft-web/references/build-and-architecture.md +215 -0
  410. package/skills/pixelcraft-web/references/canvas-and-node-editors.md +157 -0
  411. package/skills/pixelcraft-web/references/clojurescript.md +88 -0
  412. package/skills/pixelcraft-web/references/component-systems.md +102 -0
  413. package/skills/pixelcraft-web/references/component-testing.md +170 -0
  414. package/skills/pixelcraft-web/references/creative-effects.md +59 -0
  415. package/skills/pixelcraft-web/references/creative-runtime.md +34 -0
  416. package/skills/pixelcraft-web/references/elm.md +53 -0
  417. package/skills/pixelcraft-web/references/enterprise-data-ui.md +138 -0
  418. package/skills/pixelcraft-web/references/file-upload-media-ui.md +82 -0
  419. package/skills/pixelcraft-web/references/forms-validation.md +123 -0
  420. package/skills/pixelcraft-web/references/fsharp-fable.md +54 -0
  421. package/skills/pixelcraft-web/references/gsap.md +102 -0
  422. package/skills/pixelcraft-web/references/html-css.md +220 -0
  423. package/skills/pixelcraft-web/references/htmx-alpine.md +103 -0
  424. package/skills/pixelcraft-web/references/i18n-engineering.md +106 -0
  425. package/skills/pixelcraft-web/references/interaction-and-search-primitives.md +196 -0
  426. package/skills/pixelcraft-web/references/java-web.md +61 -0
  427. package/skills/pixelcraft-web/references/kotlin-web.md +57 -0
  428. package/skills/pixelcraft-web/references/leptos-yew.md +97 -0
  429. package/skills/pixelcraft-web/references/lit-web-components.md +63 -0
  430. package/skills/pixelcraft-web/references/local-first-sync.md +105 -0
  431. package/skills/pixelcraft-web/references/media-players.md +104 -0
  432. package/skills/pixelcraft-web/references/motion-react.md +96 -0
  433. package/skills/pixelcraft-web/references/motion-recipes.md +82 -0
  434. package/skills/pixelcraft-web/references/preact-fresh-hono.md +111 -0
  435. package/skills/pixelcraft-web/references/pwa.md +230 -0
  436. package/skills/pixelcraft-web/references/qwik.md +94 -0
  437. package/skills/pixelcraft-web/references/r3f-integration.md +69 -0
  438. package/skills/pixelcraft-web/references/react-next.md +168 -0
  439. package/skills/pixelcraft-web/references/rendering-choice.md +63 -0
  440. package/skills/pixelcraft-web/references/rendering-performance.md +80 -0
  441. package/skills/pixelcraft-web/references/rich-text-and-code-editors.md +220 -0
  442. package/skills/pixelcraft-web/references/rive-lottie.md +73 -0
  443. package/skills/pixelcraft-web/references/scala-laminar.md +53 -0
  444. package/skills/pixelcraft-web/references/scene-architecture.md +132 -0
  445. package/skills/pixelcraft-web/references/server-rendered.md +114 -0
  446. package/skills/pixelcraft-web/references/shader-workflow.md +77 -0
  447. package/skills/pixelcraft-web/references/smooth-scroll.md +58 -0
  448. package/skills/pixelcraft-web/references/solid.md +111 -0
  449. package/skills/pixelcraft-web/references/state-architecture.md +107 -0
  450. package/skills/pixelcraft-web/references/styling-ecosystem.md +273 -0
  451. package/skills/pixelcraft-web/references/svelte.md +111 -0
  452. package/skills/pixelcraft-web/references/tailwind.md +99 -0
  453. package/skills/pixelcraft-web/references/video-media.md +69 -0
  454. package/skills/pixelcraft-web/references/vue-nuxt.md +86 -0
  455. package/skills/pixelcraft-web/references/web-3d-engines.md +97 -0
@@ -0,0 +1,115 @@
1
+ # Auth, Passkeys (WebAuthn), OTP, and checkout UI patterns
2
+
3
+ This reference covers **frontend UI/UX engineering** for authentication and payment flows—never backend cryptography or PCI storage. Broken autofill, blocked password managers, missing passkey conditional UI, and confusing checkout error recovery are among the highest-impact conversion and accessibility failures in web products.
4
+
5
+ ## Auth & billing UI integration matrix
6
+
7
+ | Category | Platforms / SDKs | Frontend UI integration rule |
8
+ |---|---|---|
9
+ | **Auth SDKs & hosted UI** | **Better Auth** (self-hosted TS, passkey/2FA/org plugins), **Clerk** (embeddable `<SignIn>`/`<UserButton>`), **Auth.js (NextAuth v5)**, **Supabase Auth** (`@supabase/ssr`) | Map semantic design tokens into hosted component appearance props (e.g., Clerk `appearance.variables`); for custom forms (Better Auth / Auth.js / Supabase), preserve input on error, enforce `autocomplete` tokens, and keep OAuth/PKCE redirect errors recoverable with a clear retry link |
10
+ | **Direct payment gateways** | **Stripe Payment Element**, **Stripe Embedded Checkout**, Adyen Drop-in, Braintree | Use **Stripe Embedded Checkout** (`<EmbeddedCheckoutProvider>` / `stripe.initEmbeddedCheckout`) for full turnkey hosted checkout inside your route, or **Payment Element** (`appearance.variables`) for custom checkout layouts—never render raw card `<input>`s in app code |
11
+ | **Merchant of Record (MoR)** | **Polar**, **Paddle** (`Paddle.Checkout.open`), **Lemon Squeezy** | Prefer MoR overlay/inline checkouts + customer portals when global VAT/GST/sales-tax compliance and invoicing are out of scope; always show clear post-checkout confirmation/polling states while webhooks settle |
12
+
13
+ ## Passkeys & WebAuthn Level 3 Conditional UI
14
+
15
+ - **Feature detection**: prefer WebAuthn Level 3 **`await PublicKeyCredential.getClientCapabilities()`** (checking `caps.conditionalGet`, `caps.userVerifyingPlatformAuthenticator`, `caps.hybridTransport`) with fallback to `PublicKeyCredential.isConditionalMediationAvailable()`.
16
+ - **JSON parsing without manual Base64URL glue**: use **`PublicKeyCredential.parseRequestOptionsFromJSON(serverJson)`** (and `parseCreationOptionsFromJSON` for registration + `credential.toJSON()` for submission) instead of hand-rolled `Uint8Array` / Base64URL converters where supported (feature-detect or use `@simplewebauthn/browser` for older browsers).
17
+ - **Conditional UI (`autocomplete="username webauthn"`)**: start `navigator.credentials.get({ publicKey, mediation: 'conditional', signal: controller.signal })` on page load and always abort via `AbortController` if the user picks password/OAuth/magic link instead.
18
+ - **Password manager compatibility (WCAG 3.3.8 Accessible Authentication)**: never block paste (`onPaste={e => e.preventDefault()}`) on password or OTP inputs, and always use standard HTML `autocomplete` tokens (`username`, `current-password`, `new-password`, `one-time-code`).
19
+
20
+ ```html
21
+ <label for="email">Work email</label>
22
+ <input id="email" name="email" type="email" autocomplete="username webauthn" required />
23
+
24
+ <label for="pw">Password</label>
25
+ <input id="pw" name="pw" type="password" autocomplete="current-password" required />
26
+ ```
27
+
28
+ ```ts
29
+ const controller = new AbortController();
30
+
31
+ async function supportsConditionalPasskeys(): Promise<boolean> {
32
+ if (!window.PublicKeyCredential) return false;
33
+ if ('getClientCapabilities' in PublicKeyCredential) {
34
+ const caps = await PublicKeyCredential.getClientCapabilities();
35
+ return Boolean(caps.conditionalGet);
36
+ }
37
+ return Boolean(await PublicKeyCredential.isConditionalMediationAvailable?.());
38
+ }
39
+
40
+ if (await supportsConditionalPasskeys()) {
41
+ try {
42
+ const publicKey = PublicKeyCredential.parseRequestOptionsFromJSON(serverChallengeJson);
43
+ const cred = (await navigator.credentials.get({
44
+ publicKey,
45
+ mediation: 'conditional',
46
+ signal: controller.signal,
47
+ })) as PublicKeyCredential | null;
48
+ if (cred) await verifyAssertion(cred.toJSON());
49
+ } catch (err) {
50
+ if ((err as Error).name !== 'AbortError') showAuthRecoveryMessage(err);
51
+ }
52
+ }
53
+ ```
54
+
55
+ ## OTP, magic links, and MFA UI
56
+
57
+ - **One-time code (`one-time-code`)**: support pasting the full 6-digit code into either a single `inputmode="numeric" autocomplete="one-time-code"` field (preferred for screen readers and mobile SMS autofill) or segmented boxes that distribute pasted characters cleanly and allow `Backspace` across boxes.
58
+ - **Resend & expiry**: show an explicit countdown before re-enabling "Resend code", preserve the entered email address on error, and allow editing the email without restarting the entire flow.
59
+
60
+ ## Checkout, double-charge prevention & `401` session-expiry recovery
61
+
62
+ - **PCI isolation**: never mount raw `<input>` card-number fields inside your own app bundle; use Stripe Embedded Checkout / Payment Element, Polar/Paddle/Lemon Squeezy checkout, or Adyen Drop-in, passing semantic CSS custom properties into the provider's appearance config so visual craft stays coherent without touching raw PANs.
63
+ - **Express wallets & Payment Request**: surface Apple Pay / Google Pay / Link only when capability-detected on the current device/browser; never render broken wallet buttons on unsupported platforms.
64
+ - **Double-charge prevention (`Idempotency-Key` + synchronous submit lock)**: guard every payment, order creation, subscription change, or invite mutation with **both** a synchronous in-memory ref lock (`if (submittingRef.current) return; submittingRef.current = true;` before the first `await`, paired with `aria-busy="true"` / `disabled` and exact charge copy like `"Pay $49.00"`) **and** an `Idempotency-Key: <uuid>` header tied to that logical checkout attempt. Reuse the same `Idempotency-Key` across transient network retries; rotate a fresh UUID only when cart line items/amounts change or after a terminal `4xx` validation/decline error.
65
+ - **Decline & webhook recovery**: keep all billing/shipping fields intact if a card declines, move focus to the decline alert with actionable recovery (`"Try another card"` / `"Check postal code"`), and poll/stream webhook settlement (`"Confirming payment…"`) rather than assuming a client redirect guarantees entitlement.
66
+ - **`401` session-expiry draft preservation**: when an authenticated save/checkout/comment request returns `401 Unauthorized` mid-work, **never** redirect immediately and destroy unsaved user input. Snapshot dirty form/editor state (excluding raw secrets/PANs) into `IndexedDB` or `sessionStorage` keyed by route + user hint, open an inline re-auth modal (or pass a validated relative `returnTo` path), and automatically hydrate the saved draft with a confirmation banner once re-authenticated.
67
+
68
+ ```ts
69
+ // Synchronous lock + stable Idempotency-Key per checkout payload fingerprint
70
+ let inflight = false;
71
+ let attemptKey = crypto.randomUUID();
72
+
73
+ export async function submitOrder(payload: OrderPayload) {
74
+ if (inflight) return;
75
+ inflight = true;
76
+ try {
77
+ const res = await fetch('/api/orders', {
78
+ method: 'POST',
79
+ headers: { 'Content-Type': 'application/json', 'Idempotency-Key': attemptKey },
80
+ body: JSON.stringify(payload),
81
+ });
82
+ if (res.status === 401) {
83
+ sessionStorage.setItem('draft:checkout', JSON.stringify(payload));
84
+ window.location.assign(`/sign-in?returnTo=${encodeURIComponent(location.pathname + location.search)}`);
85
+ return;
86
+ }
87
+ if (res.status >= 400 && res.status < 500 && res.status !== 409 && res.status !== 429) {
88
+ attemptKey = crypto.randomUUID(); // rotate only on non-retryable 4xx validation/decline
89
+ }
90
+ return await res.json();
91
+ } finally {
92
+ inflight = false;
93
+ }
94
+ }
95
+ ```
96
+
97
+ ## Do/don't pairs
98
+
99
+ | Do | Don't |
100
+ |---|---|
101
+ | Use `getClientCapabilities()` + `parseRequestOptionsFromJSON()` + `mediation: "conditional"` + `AbortController` | Force a disruptive modal WebAuthn prompt on page load or hand-roll buggy Base64URL byte loops |
102
+ | Allow paste and password managers on password & OTP fields (WCAG 3.3.8) | Disable paste on password/confirm-password/OTP inputs |
103
+ | Use Stripe Embedded Checkout / Payment Element or Polar / Paddle / Lemon Squeezy themed with semantic tokens | Collect raw credit card numbers in custom React/Vue inputs |
104
+ | Lock submit synchronously before `await` and send a stable `Idempotency-Key` across network retries | Rely only on async `useState` `disabled` (vulnerable to fast double-click) or generate a new UUID per retry |
105
+ | Snapshot dirty drafts before `401` re-auth and preserve checkout fields on card decline | Redirect on `401` and wipe 10 minutes of form/editor work or assume redirect return equals settled entitlement |
106
+ | Enforce server-side session & authz checks with Better Auth / Clerk / Auth.js / Supabase SSR | Trust client-only auth state or unvalidated open-redirect `returnTo` URLs |
107
+
108
+ ## Verification commands
109
+
110
+ ```sh
111
+ npm run build
112
+ npx playwright test
113
+ ```
114
+
115
+ Verify password-manager autofill attributes and `Idempotency-Key` wiring (`static`), and test virtual authenticator WebAuthn conditional UI, OTP paste, rapid double-click submit lock, `401` session-expiry draft restoration, and card-decline input preservation in a real browser (`rendered`).
@@ -0,0 +1,215 @@
1
+ # Frontend build tools, application architecture, and browser runtime
2
+
3
+ Select the bundler, rendering architecture, microfrontend boundary, and browser runtime primitives to match the product's delivery constraints—not default templates. For PWA manifest/installability UX, read [pwa.md](pwa.md); for Lit Shadow DOM accessibility/form internals, read [lit-web-components.md](lit-web-components.md).
4
+
5
+ ## Build, linting, and bundling decision matrix
6
+
7
+ | Tool | Underlying engine | Best fit | Version & migration rules |
8
+ |---|---|---|---|
9
+ | **Vite 8+** | **Rolldown** (Rust bundler) + **Oxc** (JS/TS transform & minifier) | Modern React, Vue, Svelte, Solid, Astro, Qwik apps and libraries | Do not write legacy `esbuild` / `optimizeDeps.esbuildOptions` config on Vite 8+: migrate to `oxc`, `optimizeDeps.rolldownOptions`, and `build.rolldownOptions`. Vite 8 no longer ships `esbuild` by default. |
10
+ | **Vite 6–7** | Rollup (build) + esbuild (dev/dep pre-bundling) | Existing Vite 6–7 repos not yet upgraded to v8 | Verify installed major in `package.json` before choosing `rollupOptions` vs `rolldownOptions`. |
11
+ | **Rspack / Rsbuild** | Rust Webpack-compatible bundler | Webpack migrations, enterprise monorepos, Module Federation 2.0 | Use Rsbuild (`@rsbuild/core`) for ergonomic defaults (`performance.chunkSplit`, built-in `moduleFederation.options`); drop down to raw Rspack only for custom Webpack plugin pipelines. |
12
+ | **Turbopack** | Incremental Rust bundler (Next.js) | Next.js dev/production builds | Align loaders and resolve aliases with Next.js `turbopack` config; avoid Webpack-only plugins that block Turbopack adoption. |
13
+ | **`tsdown`** | Rolldown + Oxc (superseding `tsup`) | TypeScript/JS npm packages and workspace UI libraries | Prefer `tsdown` (`dts: true`, isolated declarations fast `.d.ts` emit) over legacy `tsup` for new library builds. |
14
+ | **Bun bundler (`bun build`)** | Zig native bundler + runtime | Bun-first full-stack apps, scripts, single-file executables | Verify Node/browser compatibility for plugins and SSR adapters when targeting non-Bun hosts. |
15
+ | **Webpack 5 / Parcel / esbuild** | JS / Rust / Go | Legacy enterprise Webpack pipelines; zero-config static bundles (Parcel); fast single-pass CLI transforms (esbuild) | Maintain existing setups; prefer Vite 8, Rsbuild, or `tsdown` for greenfield builds. |
16
+
17
+ ### Linting, formatting, and compiler plugins
18
+
19
+ - **Biome**: single Rust binary for formatting + linting (`biome check --write`) across JS/TS/JSX/CSS/JSON/HTML with zero Prettier/ESLint plugin sprawl; pair with framework-specific linters only where needed (e.g., complex Vue/Svelte template rules).
20
+ - **Oxlint & Oxfmt** (Oxc toolchain): ultra-fast Rust linter (`oxlint`) and formatter (`oxfmt`) that run orders of magnitude faster than ESLint in CI—either standalone or ahead of narrow type-aware/framework ESLint rules.
21
+ - **React Compiler build plugin**: enable `reactCompiler: true` in Next.js 15/16 or wire `babel-plugin-react-compiler` in Vite/Rsbuild (paired with `eslint-plugin-react-hooks` compiler rules) so pure React components auto-memoize without hand-written `useMemo`/`useCallback`.
22
+
23
+ ### Vite 8 (Rolldown + Oxc) and Vite Environment API idiom
24
+
25
+ - **Chunk splitting breaking change**: Vite 8 / Rolldown removes object-form `manualChunks` and deprecates function-form `manualChunks`. Use `build.rolldownOptions.output.codeSplitting.groups` (`name`, `test`, `priority`), and enable `strictExecutionOrder` only if aggressive chunk splitting causes module-initialization order errors.
26
+ - **Vite Environment API**: modern meta-frameworks (React Router v7, TanStack Start, Cloudflare Vite plugin, Nuxt, SvelteKit) separate client, SSR, and edge worker runtimes under `environments: { client: ..., ssr: ... }`—scope browser-only chunk rules under `environments.client.build` rather than mutating global build options blindly.
27
+
28
+ ```ts
29
+ // vite.config.ts (Vite 8+ with Environment API & Rolldown)
30
+ import { defineConfig } from 'vite';
31
+
32
+ export default defineConfig({
33
+ oxc: {
34
+ jsx: { runtime: 'automatic' },
35
+ },
36
+ optimizeDeps: {
37
+ rolldownOptions: {
38
+ // replaces deprecated optimizeDeps.esbuildOptions
39
+ },
40
+ },
41
+ environments: {
42
+ client: {
43
+ build: {
44
+ rolldownOptions: {
45
+ output: {
46
+ codeSplitting: {
47
+ groups: [
48
+ { name: 'framework-vendor', test: /node_modules[\\/](?:react|react-dom|scheduler)[\\/]/, priority: 30 },
49
+ { name: 'vendor', test: /node_modules[\\/]/, priority: 10 },
50
+ ],
51
+ },
52
+ minify: { compress: { dropConsole: true } },
53
+ },
54
+ },
55
+ },
56
+ },
57
+ },
58
+ });
59
+ ```
60
+
61
+ ## Rendering architecture decision matrix
62
+
63
+ Choose the lightest rendering strategy that satisfies interactivity, freshness, and SEO:
64
+
65
+ | Strategy | HTML generated | JS shipped to client | Best fit | Primary trap |
66
+ |---|---|---|---|---|
67
+ | **SSG** | Build time | Optional / minimal | Docs, marketing, blogs, catalogs with infrequent updates | Full rebuilds scaling poorly on 10k+ pages |
68
+ | **ISR / On-demand revalidation** | Build + cached server refresh | Page/route bundle | E-commerce, news, high-traffic CMS pages | Stale-while-revalidate surprises on auth-scoped content |
69
+ | **SSR (streaming)** | Per request | Full or selective hydration | Personalized pages, auth-gated dashboards, live SEO pages | Hydration mismatch & slow TTFB blocking first paint |
70
+ | **Islands / Partial Hydration** | Build or SSR | Only interactive islands (`client:visible`, `client:idle`) | Content-heavy sites with isolated widgets (Astro, Fresh, Leptos) | Accidental top-level wrapper hydrating the entire page |
71
+ | **Resumability** | SSR with serialized listeners | Lazy-loaded on interaction (Qwik) | Mobile-first, interaction-sensitive apps with tight INP budgets | Breaking serialization boundaries with non-serializable closures |
72
+ | **SPA (CSR)** | Empty shell + client render | Full app bundle | Authenticated tools, offline-first editors, canvas workspaces | Blank first paint, poor SEO, waterfall data fetching |
73
+
74
+ ## Microfrontends
75
+
76
+ Use microfrontends only when **independent team deployment** outweighs shared-state and bundle-duplication costs. Prefer a monorepo with package boundaries first.
77
+
78
+ | Approach | Mechanism | Best fit | Key rule |
79
+ |---|---|---|---|
80
+ | **Module Federation 2.0** (`@module-federation/core`, Rsbuild, `@module-federation/vite`) | Runtime remote container loading + `mf-manifest.json` + typed DTS | Multi-team React/Vue/Angular apps sharing runtime singletons | Always pin framework singletons (`singleton: true`, `requiredVersion`) and isolate CSS so remotes cannot collide. |
81
+ | **single-spa** | Lifecycle router (`bootstrap`, `mount`, `unmount`) across frameworks | Incremental migration between different frameworks (e.g. Angular → React) | Enforce strict unmount cleanup (listeners, timers, portals) to prevent memory leaks across route switches. |
82
+ | **Piral** | Shell + pilets plugin architecture | Extensible enterprise portals with third-party UI plugins | Version the pilet API contract strictly; never expose internal shell state directly. |
83
+
84
+ ```ts
85
+ // rsbuild.config.ts (Module Federation 2.0 remote)
86
+ import { defineConfig } from '@rsbuild/core';
87
+
88
+ export default defineConfig({
89
+ moduleFederation: {
90
+ options: {
91
+ name: 'billing_remote',
92
+ filename: 'remoteEntry.js',
93
+ exposes: { './InvoicePanel': './src/InvoicePanel' },
94
+ shared: {
95
+ react: { singleton: true, requiredVersion: '^19.0.0' },
96
+ 'react-dom': { singleton: true, requiredVersion: '^19.0.0' },
97
+ },
98
+ },
99
+ },
100
+ });
101
+ ```
102
+
103
+ ## Web Components ecosystem
104
+
105
+ When building framework-agnostic leaf components or cross-framework design systems:
106
+
107
+ - **Lit**: lightweight standards-based custom elements ([lit-web-components.md](lit-web-components.md)).
108
+ - **Stencil**: compiler generating standard Web Components plus framework wrapper packages (React/Vue/Angular) for enterprise design systems.
109
+ - **FAST**: Microsoft's Web Components foundation with design tokens and adaptive color recipes.
110
+ - **Shoelace / Web Awesome**: ready-to-use accessible Web Components (`sl-*` / `wa-*`) with CSS custom properties, `::part()` hooks, and React wrappers.
111
+
112
+ ## Browser runtime offloading
113
+
114
+ Keep the main thread free for input and 60fps rendering (INP < 200ms):
115
+
116
+ - **Web Workers**: move heavy JSON/CSV parsing, search indexing, syntax highlighting, diffing, and crypto off the main thread. Transfer `ArrayBuffer`s (zero-copy) instead of structured-cloning large payloads.
117
+ - **OffscreenCanvas**: transfer a canvas with `canvas.transferControlToOffscreen()` into a Worker for heavy 2D/WebGL rendering (charts, waveforms, image filters) so animations never stall UI input.
118
+ - **WebAssembly (WASM)**: reserve for compute-dense workloads (image/video codecs, CAD/layout engines, SQLite/DuckDB in-browser, audio DSP). Always load `.wasm` via `WebAssembly.instantiateStreaming` and run heavy compute inside a Worker.
119
+ - **Service Workers**: intercept network requests for caching and offline resilience; never store mutable app state in Service Worker memory (workers terminate when idle—use Cache API or IndexedDB).
120
+
121
+ ## Offline & Service Worker tooling (Serwist / Workbox)
122
+
123
+ Prefer **Serwist** (the actively maintained Workbox fork for Vite, Next.js, Nuxt, SvelteKit) or **Workbox** over hand-rolling raw `fetch` event listeners:
124
+
125
+ - **Precaching**: inject build-hashed assets into `self.__SW_MANIFEST` with `cleanupOutdatedCaches: true`.
126
+ - **Runtime caching**: match by `request.destination` (`StaleWhileRevalidate` for images, `CacheFirst` for hashed scripts/styles, `NetworkFirst` for HTML/API).
127
+ - **Background Sync**: use `BackgroundSyncPlugin` on mutating `POST`/`PATCH` routes—note that `fetchDidFail` triggers only on network exceptions, not HTTP `4xx`/`5xx` responses.
128
+
129
+ ```ts
130
+ // sw.ts (Serwist)
131
+ import { BackgroundSyncPlugin, CacheFirst, NetworkOnly, Serwist, StaleWhileRevalidate } from 'serwist';
132
+
133
+ const bgSync = new BackgroundSyncPlugin('offline-mutations', {
134
+ maxRetentionTime: 24 * 60, // minutes
135
+ });
136
+
137
+ const serwist = new Serwist({
138
+ precacheEntries: self.__SW_MANIFEST,
139
+ precacheOptions: { cleanupOutdatedCaches: true },
140
+ skipWaiting: true,
141
+ clientsClaim: true,
142
+ runtimeCaching: [
143
+ { matcher: ({ request }) => request.destination === 'image', handler: new StaleWhileRevalidate({ cacheName: 'images' }) },
144
+ { matcher: ({ request }) => request.destination === 'script', handler: new CacheFirst({ cacheName: 'scripts' }) },
145
+ { matcher: ({ url }) => url.pathname.startsWith('/api/sync'), handler: new NetworkOnly({ plugins: [bgSync] }), method: 'POST' },
146
+ ],
147
+ });
148
+
149
+ serwist.addEventListeners();
150
+ ```
151
+
152
+ ## Post-tag performance budgets & third-party script isolation
153
+
154
+ Measure production performance **after** analytics, GTM, ad pixels, A/B testing, and chat widgets are active—never solely on a clean dev build.
155
+
156
+ ### Mandatory production budgets (3-run median under 4G + 4× CPU throttle)
157
+
158
+ | Metric / Audit | Studio-grade floor | Measurement rule |
159
+ |---|---|---|
160
+ | **Lighthouse (Mobile + Desktop)** | **Perf ≥ 90**, **A11y ≥ 95**, **Best Practices ≥ 95**, **SEO ≥ 95** | **3-run median** on **every primary template** against production build with real tags/consent state active |
161
+ | **Initial compressed JS+CSS payload** | Content/editorial **`<= 150–250 KB`** · Dashboard/app **`<= 250–450 KB`** · Promotional/rich experience **`<= 350–700 KB`** · Embedded widget **`<= 100–200 KB`** | Initial pre-`load` compressed transfer (`~3.1 MB / 103 req` showcase median is a cost calibration benchmark, **never** an acceptable target budget) + **Network waterfall capture on heaviest page** |
162
+ | **Largest Contentful Paint (LCP)** | **< 2.5 s** (p75 field & lab) | Never lazy-load LCP hero media; set `fetchpriority="high"` + responsive `srcset` |
163
+ | **Interaction to Next Paint (INP) & `LoAF`** | **< 200 ms** (p75 field & lab); clean **Long Animation Frames (`LoAF`)** on scroll/drag | Yield long tasks (`scheduler.yield()`), isolate 3rd-party scripts off main thread, cap luminance flashes **`<= 3 Hz`** (`WCAG 2.3.1`) |
164
+ | **Cumulative Layout Shift (CLS)** | **< 0.10** (target `0.00` above fold) | Explicit media dimensions, metric-matched font fallbacks, zero-shift consent UI |
165
+
166
+ ### Third-party tag, pixel, and chat widget isolation
167
+
168
+ - **Edge / Worker offloading**: route analytics and ad pixels through server-side/edge gateways (**Cloudflare Zaraz**, server-side GTM) or isolate main-thread scripts in a Web Worker via **Partytown** (`@builder.io/partytown`) where compatible.
169
+ - **Interaction facades**: never boot heavy third-party embeds (YouTube/Vimeo iframes, Intercom/Crisp/Zendesk live chat, Calendly, heavy maps) on initial page load. Render a lightweight static button/thumbnail facade (`lite-youtube-embed` or a semantic `"Chat with support"` button) and dynamically import the vendor SDK on `pointerenter`, `focus`, or `click`.
170
+ - **Consent Mode v2 without CLS**: initialize default consent state synchronously in `<head>` (`ad_storage`, `ad_user_data`, `ad_personalization`, `analytics_storage` set to `'denied'` before any tag script executes) and upgrade via `gtag('consent', 'update', ...)` after explicit user choice. Render cookie/consent UI as a fixed bottom sheet/banner (`position: fixed`) with keyboard non-trapping focus—never inject a flow banner at the top of `<body>` that pushes page content down after hydration.
171
+
172
+ ## CDN cache control, HTTP security headers & deployment safety
173
+
174
+ | Resource class | Recommended `Cache-Control` header | Rationale |
175
+ |---|---|---|
176
+ | Content-hashed build assets (`/_next/static/*`, `/assets/*.[hash].*`, subset `.woff2`) | `public, max-age=31536000, immutable` | Safe 1-year browser + CDN edge caching; filename changes on rebuild |
177
+ | Public SSG/ISR HTML & public JSON feeds | `public, max-age=0, s-maxage=60, stale-while-revalidate=86400` | Instant CDN edge response with background revalidation |
178
+ | Authenticated, user-specific, checkout, or tenant-scoped HTML/API | `private, no-store` (+ `Vary: Cookie, Authorization` if shared proxy exists) | Prevents catastrophic cross-tenant/session cache poisoning at CDN edge |
179
+
180
+ Ship these baseline HTTP security headers on every HTML response (via edge middleware, CDN rules, or reverse proxy) alongside **isolated PR preview deployments** and a tested **instant rollback plan** (previous immutable artifact alias or CDN/edge deployment promotion):
181
+
182
+ - **`Content-Security-Policy`**: strict allowlist or per-request nonce (`script-src 'self' 'nonce-...' 'strict-dynamic'; object-src 'none'; base-uri 'self'; frame-ancestors 'none'`).
183
+ - **`Strict-Transport-Security`**: `max-age=63072000; includeSubDomains; preload`.
184
+ - **`X-Content-Type-Options`**: `nosniff`.
185
+ - **`Referrer-Policy`**: `strict-origin-when-cross-origin`.
186
+ - **`Permissions-Policy`**: `camera=(), microphone=(), geolocation=(), payment=(self)` (enable capabilities only on routes that use them).
187
+
188
+ ## Technical SEO, redesign migration & AI/social unfurl readiness
189
+
190
+ - **Per-route metadata & structured data**: emit a unique `<title>`, `<meta name="description">`, self-referencing `<link rel="canonical" href="https://...">`, `robots.txt`, generated `sitemap.xml`, `hreflang` + `x-default` alternates ([i18n-engineering.md](i18n-engineering.md)), and schema-valid JSON-LD (`Organization`, `Product`, `Article`, `FAQPage`, `BreadcrumbList`) matching visible page facts.
191
+ - **Redesign `301` redirect map & zero broken/orphan links**: when replacing an existing site, crawl and inventory every legacy URL before launch, enforce single-hop `301` (or method-preserving `308`) redirects for every changed slug, and run an automated link checker in CI to verify `0` internal `404`s, `0` redirect loops, and `0` orphaned public pages.
192
+ - **SSR/SSG semantic HTML & `/llms.txt` for AI search**: ensure primary headings, pricing, docs, and article copy render in initial SSR/SSG semantic HTML (`<main>`, `<article>`, `<table>`) without requiring client JS execution; publish a concise `/llms.txt` markdown index at the domain root linking canonical product, documentation, and policy URLs for AI crawlers and answer engines.
193
+ - **Zalo, Slack, iMessage, Facebook & LinkedIn Open Graph cards**: always serve `og:image` and `twitter:image` (`twitter:card="summary_large_image"`) as **`1200×630` absolute `https://` URLs** in **JPEG or PNG** (`< 600 KB`) with explicit `og:image:width="1200"` and `og:image:height="630"`. Never use relative `/og.png` paths, and never serve SVG or WebP-only `og:image` URLs—Zalo, enterprise Slack/Teams unfurlers, and legacy chat crawlers silently drop WebP/SVG previews.
194
+
195
+ ## Do/don't pairs
196
+
197
+ | Do | Don't |
198
+ |---|---|
199
+ | Use `oxc` and `build.rolldownOptions` on Vite 8+ | Copy legacy `esbuild` / `optimizeDeps.esbuildOptions` snippets into Vite 8 configs |
200
+ | Mark `react` / `react-dom` as `singleton: true` in Module Federation | Load duplicate React runtimes across host and remote containers |
201
+ | Gate 3rd-party pixels/chat behind Zaraz/Partytown, click-to-load facades, and fixed Consent Mode v2 UI | Load GTM, Intercom, and YouTube iframes synchronously on `<head>` or push layout down with a late cookie bar |
202
+ | Serve `immutable` cache headers on hashed assets, `private, no-store` on auth routes, CSP/HSTS/`nosniff`, PR previews, and a rollback plan | Cache personalized responses at the CDN edge or ship production changes without preview isolation and rollback |
203
+ | Ship a tested legacy `301` redirect map, `/llms.txt`, and `1200×630` HTTPS PNG/JPEG `og:image` tags | Drop old indexed URLs to `404` on redesign or use relative/WebP/SVG `og:image` URLs that break in Zalo/Slack |
204
+ | Persist offline state in IndexedDB/Cache API and use Serwist/Workbox | Store state in Service Worker module globals that vanish when the worker sleeps |
205
+ | Match rendering strategy (SSG/ISR/Islands/SSR/SPA) and initial JS+CSS budget (`<= 150–700 KB` by class) to route interactivity | Ship a `3.1 MB` showcase-bloated SPA bundle for a content/marketing site |
206
+
207
+ ## Verification commands
208
+
209
+ ```sh
210
+ npm run build
211
+ npx lighthouse http://localhost:4173 --preset=perf --form-factor=mobile
212
+ npx lighthouse http://localhost:4173 --preset=desktop
213
+ ```
214
+
215
+ Inspect generated bundle chunks against surface-class JS+CSS budgets, HTTP response/security/cache headers, `sitemap.xml`/`robots.txt`/`llms.txt`, PR preview/rollback config, and `301` redirect rules (`static`), and verify **3-run median** post-tag Lighthouse scores (`Perf >= 90`, `A11y/BP/SEO >= 95` on mobile + desktop per primary template), CWV (`LCP < 2.5s`, `INP < 200ms`, `CLS < 0.1`), `LoAF` scroll/drag traces, heaviest-page Network waterfall, and deliverable captures across **`Chrome`, `Firefox`, `Edge`, `Safari macOS`, real `Safari iOS`, and `Chrome Android`** (`rendered`).
@@ -0,0 +1,157 @@
1
+ # Canvas, diagram, node-based editors, and drag-and-drop
2
+
3
+ Choose between infinite whiteboard SDKs, 2D canvas scene graphs, DOM/SVG node-graph engines, and drag-and-drop toolchains by interaction model, object count, and accessibility requirements. For browser 3D scenes (`Three.js`, `R3F`, `Babylon.js`, `WebGL`/`WebGPU`), see [scene-architecture.md](scene-architecture.md) and [web-3d-engines.md](web-3d-engines.md); for embodied XR/VR/AR headset UX, use `pixelcraft-spatial`; for data charts, use `pixelcraft-dataviz`.
4
+
5
+ ## Engine decision matrix
6
+
7
+ | Product type | Tools | Rendering model | Best fit | Primary trade-off |
8
+ |---|---|---|---|---|
9
+ | **Infinite whiteboard** | **tldraw** (v4), **Excalidraw** | HTML/SVG hybrid (tldraw) or rough Canvas 2D (Excalidraw) | Collaborative whiteboards, spatial canvases, diagramming apps | tldraw requires commercial license to remove watermark in production; Excalidraw's hand-drawn style is opinionated |
10
+ | **2D Canvas scene graph** | **Konva** (`react-konva` / `vue-konva`), **Fabric.js**, **Paper.js** | HTML5 Canvas 2D (multi-layer in Konva; single canvas in Fabric/Paper) | Design/annotation editors, floor plans, image/vector manipulation, 1k–10k shapes | Canvas pixels are invisible to screen readers unless paired with a parallel DOM/ARIA model |
11
+ | **Workflow / node graph** | **React Flow / XYFlow** (`@xyflow/react`, `@xyflow/svelte`), **Rete.js** | DOM nodes + SVG edges (XYFlow) | Visual automation builders, AI agent pipelines, low-code workflows, dataflow graphs | DOM node count above ~500–1,000 visible nodes needs virtualization or simplified LOD |
12
+ | **Network & enterprise diagrams** | **Cytoscape.js**, **JointJS**, **GoJS** | Canvas/WebGL (Cytoscape), SVG (JointJS), Canvas (GoJS) | Graph analytics / topology (Cytoscape); UML/BPMN/CAD enterprise diagrams (JointJS, GoJS) | GoJS and JointJS+ are commercial; Cytoscape is graph-layout focused rather than arbitrary React UI inside nodes |
13
+ | **Drag-and-drop** | **dnd-kit** (`@dnd-kit/core` v6 or `@dnd-kit/react` v0.x rewrite), **Pragmatic Drag and Drop** (`@atlaskit/pragmatic-drag-and-drop`) | Pointer/Keyboard sensors (dnd-kit) or native HTML5 DnD (Pragmatic) | **dnd-kit**: accessible sortable lists, kanban, trees with built-in keyboard sensor; **Pragmatic DnD**: tiny, framework-agnostic, cross-window/file drops, huge tables | Pragmatic DnD relies on native HTML5 DnD—must pair with explicit keyboard + single-pointer reorder actions and ARIA live announcements |
14
+
15
+ ## Node-based editors (React Flow / XYFlow)
16
+
17
+ - Always import **`'@xyflow/react/dist/style.css'`** (not `'@xyflow/react/style.css'`) and give the `<ReactFlow>` parent container an explicit non-zero height and width.
18
+ - **Memoization rule**: define `nodeTypes` and `edgeTypes` **outside** the component or inside `useMemo(() => (...), [])`. Wrap custom node/edge components in `React.memo` and callbacks (`onNodesChange`, `onEdgesChange`, `onConnect`) in `useCallback`. Passing a fresh inline `nodeTypes={{ custom: MyNode }}` object on every render forces React Flow to unmount and remount nodes on every drag tick.
19
+
20
+ ```tsx
21
+ import { useMemo, useCallback } from 'react';
22
+ import { ReactFlow, useNodesState, useEdgesState, addEdge, type Connection } from '@xyflow/react';
23
+ import '@xyflow/react/dist/style.css';
24
+ import { TriggerNode } from './TriggerNode';
25
+
26
+ export function WorkflowCanvas() {
27
+ const [nodes, , onNodesChange] = useNodesState([]);
28
+ const [edges, setEdges, onEdgesChange] = useEdgesState([]);
29
+ const nodeTypes = useMemo(() => ({ trigger: TriggerNode }), []);
30
+
31
+ const onConnect = useCallback(
32
+ (connection: Connection) => setEdges((eds) => addEdge(connection, eds)),
33
+ [setEdges],
34
+ );
35
+
36
+ return (
37
+ <div style={{ width: '100%', height: '640px' }}>
38
+ <ReactFlow
39
+ nodes={nodes}
40
+ edges={edges}
41
+ nodeTypes={nodeTypes}
42
+ onNodesChange={onNodesChange}
43
+ onEdgesChange={onEdgesChange}
44
+ onConnect={onConnect}
45
+ fitView
46
+ />
47
+ </div>
48
+ );
49
+ }
50
+ ```
51
+
52
+ ## Infinite whiteboards (tldraw / Excalidraw)
53
+
54
+ - **tldraw**: import `'tldraw/tldraw.css'` and pass `persistenceKey="board-id"` for automatic IndexedDB persistence and cross-tab sync. When building custom shapes with `BaseBoxShapeUtil`, validate props via `T.*` (`RecordProps`), render interactive UI inside `<HTMLContainer>`, and call `onPointerDown={(e) => e.stopPropagation()}` on inner buttons/inputs so canvas pan/select gestures do not hijack clicks.
55
+ - **Excalidraw**: lazy-load `@excalidraw/excalidraw` on the client only (no SSR) and treat `excalidrawAPI` ref calls as imperative mutations rather than re-passing the entire scene array on every keystroke.
56
+
57
+ ## 2D Canvas performance (Konva / Fabric.js)
58
+
59
+ Every Konva `<Layer>` creates a separate `<canvas>` element. Keep layer count minimal (typically 2–4: static background, main scene, active drag layer):
60
+
61
+ - Set `listening={false}` on background/decorative layers and non-interactive shapes to skip hit-graph rendering.
62
+ - Set `perfectDrawEnabled={false}` on filled+stroked shapes where sub-pixel alpha overlap is unnecessary, and call `node.cache()` on complex static shapes/groups.
63
+ - Move the active shape onto a dedicated drag layer during `dragstart` and return it on `dragend` (via `shape.moveTo(dragLayer)` or `react-konva-utils` `<Portal>`) so dragging does not repaint the entire main layer on every frame.
64
+
65
+ ```ts
66
+ // Konva 3-layer drag optimization
67
+ const backgroundLayer = new Konva.Layer({ listening: false });
68
+ const mainLayer = new Konva.Layer();
69
+ const dragLayer = new Konva.Layer();
70
+
71
+ star.cache();
72
+ star.on('dragstart', () => star.moveTo(dragLayer));
73
+ star.on('dragend', () => star.moveTo(mainLayer));
74
+ ```
75
+
76
+ ## Drag-and-drop toolchains & accessibility
77
+
78
+ ### dnd-kit (`@dnd-kit/core` v6 vs `@dnd-kit/react` v0.x)
79
+
80
+ Check `package.json` before writing imports—there are two distinct API generations:
81
+
82
+ - **Stable `@dnd-kit/core` v6 (+ `@dnd-kit/sortable`)**: uses `<DndContext sensors={sensors}>` with `useSensors(useSensor(PointerSensor), useSensor(KeyboardSensor, { coordinateGetter: sortableKeyboardCoordinates }))`. Always include `KeyboardSensor` alongside `PointerSensor`.
83
+ - **Rewrite `@dnd-kit/react` v0.x (+ `@dnd-kit/dom`)**: uses `<DragDropProvider>` where custom sensor arrays **must extend** `defaults` (`sensors={(defaults) => [...]}`) so the default keyboard sensor is not dropped.
84
+ - Provide visible focus indicators on drag handles, screen-reader announcements (`accessibility.announcements`), and single-pointer reorder alternatives (WCAG 2.5.7).
85
+
86
+ ```tsx
87
+ // @dnd-kit/core v6 (stable production API)
88
+ import { DndContext, KeyboardSensor, PointerSensor, useSensor, useSensors } from '@dnd-kit/core';
89
+ import { sortableKeyboardCoordinates } from '@dnd-kit/sortable';
90
+
91
+ const sensors = useSensors(
92
+ useSensor(PointerSensor, { activationConstraint: { distance: 6 } }),
93
+ useSensor(KeyboardSensor, { coordinateGetter: sortableKeyboardCoordinates }),
94
+ );
95
+ <DndContext sensors={sensors}>{/* sortable items */}</DndContext>;
96
+
97
+ // @dnd-kit/react v0.x rewrite (extend defaults to keep KeyboardSensor)
98
+ import { DragDropProvider } from '@dnd-kit/react';
99
+ import { PointerSensor as DomPointerSensor } from '@dnd-kit/dom';
100
+
101
+ <DragDropProvider
102
+ sensors={(defaults) => [
103
+ ...defaults.filter((s) => s !== DomPointerSensor),
104
+ DomPointerSensor.configure({ /* activation constraints */ }),
105
+ ]}
106
+ >
107
+ {/* sortable items */}
108
+ </DragDropProvider>;
109
+ ```
110
+
111
+ ### Pragmatic Drag and Drop (`@atlaskit/pragmatic-drag-and-drop`)
112
+
113
+ - Always merge cleanup functions returned by `draggable()`, `dropTargetForElements()`, and `monitorForElements()` using `combine(...)` inside `useEffect` (or framework unmount) so global listeners never leak.
114
+ - Because native HTML5 DnD has no built-in keyboard mode, pair every Pragmatic DnD reorderable list/board with an explicit keyboard + single-pointer control (e.g., "Move up / Move down / Move to column" action menu) and announce the new position in an `aria-live="polite"` region.
115
+
116
+ ```ts
117
+ import { useEffect } from 'react';
118
+ import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
119
+ import {
120
+ draggable,
121
+ dropTargetForElements,
122
+ } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
123
+
124
+ useEffect(() => {
125
+ const el = cardRef.current;
126
+ if (!el) return;
127
+ return combine(
128
+ draggable({ element: el }),
129
+ dropTargetForElements({ element: el }),
130
+ );
131
+ }, []);
132
+ ```
133
+
134
+ ## Canvas & diagram accessibility rules
135
+
136
+ - **WCAG 2.2 SC 2.5.7 (Dragging Movements)**: keyboard-only reordering satisfies WCAG 2.1.1 but does **not** satisfy 2.5.7. Every non-essential drag interaction (sortable lists, kanban cards, sliders, map/diagram controls—everything except essential freehand drawing/signature pads) **must also** provide a **single-pointer (click/tap) alternative** without holding and dragging (for example, clickable "Move up / Move down" buttons, a "Move to column…" menu, or click-on-track slider jumps).
137
+ - Any canvas or node-graph product that users must operate—not just view—needs keyboard navigation (pan/zoom shortcuts, focusable nodes/handles, delete/undo shortcuts) and an accessible structural view (outline list or inspector panel) for screen-reader users.
138
+ - Honor `prefers-reduced-motion` on auto-layout transitions, `fitView` animations, and zoom springs.
139
+
140
+ ## Do/don't pairs
141
+
142
+ | Do | Don't |
143
+ |---|---|
144
+ | Memoize `nodeTypes` and `edgeTypes` outside render or in `useMemo` | Pass inline `nodeTypes={{ custom: CustomNode }}` literals into `<ReactFlow>` |
145
+ | Use `listening={false}`, `perfectDrawEnabled={false}`, and a drag layer in Konva | Redraw 500 uncached shapes on a single Konva layer every `pointermove` |
146
+ | Call `e.stopPropagation()` on `onPointerDown` for controls inside tldraw `HTMLContainer` | Let canvas drag gestures swallow button clicks inside custom shapes |
147
+ | Keep `KeyboardSensor` in dnd-kit or pair Pragmatic DnD with keyboard reorder actions | Ship pointer-only drag-and-drop with no keyboard alternative (WCAG 2.1.1 / 2.5.7) |
148
+ | Return `combine(draggable(...), dropTargetForElements(...))` from `useEffect` | Leak Pragmatic DnD listeners across route or list re-renders |
149
+
150
+ ## Verification commands
151
+
152
+ ```sh
153
+ npm run build
154
+ npx playwright test
155
+ ```
156
+
157
+ Verify 60fps drag/pan frame pacing, zoom-to-cursor accuracy, keyboard reordering, and pointer-vs-control event isolation in a real browser (`rendered`).
@@ -0,0 +1,88 @@
1
+ # ClojureScript: UIx v2, Helix, and Reagent / re-frame
2
+
3
+ ## Wrapper selection
4
+
5
+ | Library | React integration model | Best fit | Primary trade-off |
6
+ |---|---|---|---|
7
+ | **UIx v2 (`uix.core`)** | Zero-overhead React 18/19 wrapper (`defui`, `$`, `use-state`, `use-effect`, `use-ref`, Suspense, Error Boundaries) | New ClojureScript React 18/19 apps interoping cleanly with modern React hooks & headless UI libraries | Explicit React hook rules apply (use `uix.linter` / `clj-kondo` hooks) |
8
+ | **Helix (`helix.core`)** | Thin macro-based React hooks wrapper (`defnc`, `$`, `helix.hooks`) | Minimal React 18/19 interop with near-zero runtime abstraction | Smaller battery-included ecosystem than re-frame |
9
+ | **Reagent + re-frame** | Hiccup vectors + reactive atoms (`ratom`) + event/subscription graph | Existing Reagent/re-frame codebases and structured event-driven apps | Reagent wrapper indirection adds friction with React 18/19 concurrent hooks & modern JS libraries |
10
+
11
+ ## Token mapping
12
+
13
+ Emit CSS variables/semantic classes and consume them in UIx/Helix `$` props (`:class`) or Reagent hiccup. Keep visual constants in CSS/theme assets; do not scatter hex/style maps through every view. Global state (context, atom, or re-frame subscription) may control the root theme attribute/class.
14
+
15
+ ## Layout and responsive idioms
16
+
17
+ All three produce React-powered DOM. Use ordinary semantic HTML/CSS layout; ClojureScript components should expose composition without hiding markup semantics. re-frame owns event/subscription flow, not visual layout truth.
18
+
19
+ ## Typography/custom fonts
20
+
21
+ Configure fonts in static CSS/HTML and map semantic type classes. Verify keyword/class naming, fallback, scaling, localization expansion, and hydration/initial render behavior.
22
+
23
+ ## Motion/reduced motion
24
+
25
+ Use CSS or deliberate React-compatible animation libraries only when needed. Read `prefers-reduced-motion` through CSS or browser interop (`js/window.matchMedia` inside `use-effect` with cleanup); do not trigger animation purely because a ratom or state hook changed.
26
+
27
+ ## Accessibility specifics
28
+
29
+ Neither `$` props nor Hiccup keywords enforce accessibility. Use real controls, labels (`:html-for` / `:for` matching the chosen wrapper), visible focus, keyboard events, focus restoration after mutation/dialog close, and browser validation semantics. Avoid div-click handlers.
30
+
31
+ ## UIx v2 & Helix (React 18/19 hooks) idioms
32
+
33
+ In **UIx v2** (`defui` + `$`) and **Helix** (`defnc` + `$`), follow React 18/19 rules directly: use `use-id` for SSR-safe unique `<label>`/`aria-describedby` IDs, clean up observers/listeners in `use-effect` return functions (never return a non-function/nil carelessly—UIx enforces JS `undefined` vs cleanup fn), and interop with headless React primitives (`@base-ui/react`, `react-aria-components`, `radix-ui`) directly via `$`:
34
+
35
+ ```clojure
36
+ ;; UIx v2 idiom (React 18/19 hooks + semantic form controls)
37
+ (ns app.invoice-form
38
+ (:require [uix.core :as uix :refer [defui $]]))
39
+
40
+ (defui invoice-form [{:keys [on-save pending? error]}]
41
+ (let [input-id (uix/use-id)
42
+ error-id (str input-id "-err")
43
+ [email set-email] (uix/use-state "")]
44
+ ($ :form {:on-submit (fn [e]
45
+ (.preventDefault e)
46
+ (on-save email))}
47
+ ($ :label {:html-for input-id} "Billing email")
48
+ ($ :input {:id input-id
49
+ :type "email"
50
+ :auto-complete "email"
51
+ :value email
52
+ :aria-invalid (boolean error)
53
+ :aria-describedby (when error error-id)
54
+ :on-change #(set-email (.. % -target -value))})
55
+ (when error
56
+ ($ :p {:id error-id :role "alert"} error))
57
+ ($ :button {:type "submit" :disabled pending?}
58
+ (if pending? "Saving…" "Save invoice")))))
59
+ ```
60
+
61
+ ## States & Forms idiom
62
+
63
+ Model async state explicitly (tagged maps or Malli/Spec schemas: `:idle`, `:loading`, `:empty`, `:partial`, `:error`, `:offline`, `:optimistic`) instead of unrelated booleans. Preserve values after failed submit and map server validation back to fields; do not block paste or validate destructively on every keystroke.
64
+
65
+ ## Do/don't pairs
66
+
67
+ | Do | Don't |
68
+ |---|---|
69
+ | UIx v2 `($ :label {:html-for id} "Email")` / Reagent `[:label {:for id} "Email"]` | Placeholder-only input |
70
+ | `($ :button {:type "submit"} "Save")` / `[:button {:type "submit"} "Save"]` | Clickable `div` pretending to be a button |
71
+ | UIx v2 / Helix for new React 18/19 hook & third-party React library interop | Wrapping React 19 hook components inside Reagent class adaptors unnecessarily |
72
+ | Explicit async state maps/tags in state or re-frame `app-db` | Unrelated booleans hiding empty/error/loading conflicts |
73
+ | Cleanup function returned from `use-effect` and focus restoration on close | Leaking listeners or dropping focus on rerender/unmount |
74
+
75
+ ## Known traps
76
+
77
+ Returning non-cleanup values from `use-effect` in React interop, stale subscriptions, untyped `app-db` drift, keyword typos invisible at compile time, Reagent `r/adapt-react-class` friction with React 19 hooks, rerender focus/caret loss, inaccessible wrapped React components.
78
+
79
+ ## Verification commands
80
+
81
+ ```sh
82
+ clojure -M:test
83
+ npx shadow-cljs compile app
84
+ npx shadow-cljs watch app
85
+ npx playwright test
86
+ ```
87
+
88
+ Inspect DOM/accessibility tree, keyboard/focus behavior, production advanced-compiled output (`release`), offline/server errors, reduced motion, and localization/text scaling (`rendered`).