@moonwitness/ui 0.1.0 → 7.1.3
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/CHANGELOG.md +18 -0
- package/LICENSE +21 -0
- package/README.md +135 -260
- package/TOKENS.md +62 -0
- package/dist/cartoon/anime-avatar.d.ts +8 -0
- package/dist/cartoon/anime-avatar.js +135 -0
- package/dist/cartoon/anime-stage.d.ts +67 -0
- package/dist/cartoon/anime-stage.js +106 -0
- package/dist/cartoon/index.d.ts +113 -0
- package/dist/cartoon/index.js +119 -0
- package/dist/cartoon.d.ts +59 -0
- package/dist/cartoon.js +238 -0
- package/dist/characters.d.ts +71 -0
- package/dist/characters.js +543 -0
- package/dist/components/accordion.d.ts +11 -0
- package/dist/components/accordion.js +26 -0
- package/dist/components/alert.d.ts +14 -0
- package/dist/components/alert.js +36 -0
- package/dist/components/appearance-menu.d.ts +22 -0
- package/dist/components/appearance-menu.js +64 -0
- package/dist/components/artwork-frame.d.ts +10 -0
- package/dist/components/artwork-frame.js +12 -0
- package/dist/components/audio.d.ts +19 -0
- package/dist/components/audio.js +49 -0
- package/dist/components/avatar.d.ts +9 -0
- package/dist/components/avatar.js +28 -0
- package/dist/components/badge.d.ts +12 -0
- package/dist/components/badge.js +21 -0
- package/dist/components/brand-mark.d.ts +13 -0
- package/dist/components/brand-mark.js +32 -0
- package/dist/components/breadcrumbs.d.ts +15 -0
- package/dist/components/breadcrumbs.js +25 -0
- package/dist/components/button.d.ts +17 -0
- package/dist/components/button.js +119 -0
- package/dist/components/card.d.ts +20 -0
- package/dist/components/card.js +57 -0
- package/dist/components/character-badge.d.ts +9 -0
- package/dist/components/character-badge.js +19 -0
- package/dist/components/character-preview.d.ts +10 -0
- package/dist/components/character-preview.js +47 -0
- package/dist/components/character-stage.d.ts +54 -0
- package/dist/components/character-stage.js +38 -0
- package/dist/components/chart.d.ts +36 -0
- package/dist/components/chart.js +154 -0
- package/dist/components/checkbox.d.ts +7 -0
- package/dist/components/checkbox.js +15 -0
- package/dist/components/comic-panel.d.ts +17 -0
- package/dist/components/comic-panel.js +118 -0
- package/dist/components/comic-theater.d.ts +19 -0
- package/dist/components/comic-theater.js +54 -0
- package/dist/components/command.d.ts +32 -0
- package/dist/components/command.js +56 -0
- package/dist/components/confirm-dialog.d.ts +19 -0
- package/dist/components/confirm-dialog.js +32 -0
- package/dist/components/copy-button.d.ts +14 -0
- package/dist/components/copy-button.js +17 -0
- package/dist/components/date-picker.d.ts +21 -0
- package/dist/components/date-picker.js +45 -0
- package/dist/components/dialog.d.ts +20 -0
- package/dist/components/dialog.js +51 -0
- package/dist/components/dna-icon.d.ts +24 -0
- package/dist/components/dna-icon.js +14 -0
- package/dist/components/dropdown-menu.d.ts +13 -0
- package/dist/components/dropdown-menu.js +26 -0
- package/dist/components/effects.d.ts +143 -0
- package/dist/components/effects.js +248 -0
- package/dist/components/empty-state.d.ts +15 -0
- package/dist/components/empty-state.js +18 -0
- package/dist/components/epistemic-branch-panel.d.ts +10 -0
- package/dist/components/epistemic-branch-panel.js +45 -0
- package/dist/components/error-state.d.ts +20 -0
- package/dist/components/error-state.js +44 -0
- package/dist/components/field.d.ts +13 -0
- package/dist/components/field.js +35 -0
- package/dist/components/filter-facet-bar.d.ts +15 -0
- package/dist/components/filter-facet-bar.js +38 -0
- package/dist/components/inbox-popover.d.ts +28 -0
- package/dist/components/inbox-popover.js +14 -0
- package/dist/components/input.d.ts +7 -0
- package/dist/components/input.js +8 -0
- package/dist/components/kanban-board.d.ts +21 -0
- package/dist/components/kanban-board.js +38 -0
- package/dist/components/label.d.ts +6 -0
- package/dist/components/label.js +7 -0
- package/dist/components/layered-scene.d.ts +74 -0
- package/dist/components/layered-scene.js +316 -0
- package/dist/components/log-console.d.ts +29 -0
- package/dist/components/log-console.js +82 -0
- package/dist/components/metric-tile.d.ts +15 -0
- package/dist/components/metric-tile.js +30 -0
- package/dist/components/mode-picker.d.ts +9 -0
- package/dist/components/mode-picker.js +72 -0
- package/dist/components/motion-timeline.d.ts +56 -0
- package/dist/components/motion-timeline.js +215 -0
- package/dist/components/number-input.d.ts +29 -0
- package/dist/components/number-input.js +45 -0
- package/dist/components/page-header.d.ts +16 -0
- package/dist/components/page-header.js +48 -0
- package/dist/components/pagination.d.ts +10 -0
- package/dist/components/pagination.js +17 -0
- package/dist/components/panel.d.ts +18 -0
- package/dist/components/panel.js +28 -0
- package/dist/components/paper-note.d.ts +6 -0
- package/dist/components/paper-note.js +35 -0
- package/dist/components/popover.d.ts +11 -0
- package/dist/components/popover.js +29 -0
- package/dist/components/progress.d.ts +17 -0
- package/dist/components/progress.js +26 -0
- package/dist/components/quest-card.d.ts +82 -0
- package/dist/components/quest-card.js +89 -0
- package/dist/components/radio-group.d.ts +8 -0
- package/dist/components/radio-group.js +23 -0
- package/dist/components/riot-sticker.d.ts +28 -0
- package/dist/components/riot-sticker.js +61 -0
- package/dist/components/scene-particles.d.ts +31 -0
- package/dist/components/scene-particles.js +90 -0
- package/dist/components/scene-transitions.d.ts +16 -0
- package/dist/components/scene-transitions.js +51 -0
- package/dist/components/section-ribbon.d.ts +17 -0
- package/dist/components/section-ribbon.js +21 -0
- package/dist/components/select-field.d.ts +7 -0
- package/dist/components/select-field.js +8 -0
- package/dist/components/select.d.ts +14 -0
- package/dist/components/select.js +22 -0
- package/dist/components/separator.d.ts +9 -0
- package/dist/components/separator.js +12 -0
- package/dist/components/sheet.d.ts +14 -0
- package/dist/components/sheet.js +39 -0
- package/dist/components/skeleton.d.ts +7 -0
- package/dist/components/skeleton.js +11 -0
- package/dist/components/sketch-annotation.d.ts +22 -0
- package/dist/components/sketch-annotation.js +21 -0
- package/dist/components/smart-button-box.d.ts +24 -0
- package/dist/components/smart-button-box.js +26 -0
- package/dist/components/speech-bubble.d.ts +33 -0
- package/dist/components/speech-bubble.js +18 -0
- package/dist/components/spinner.d.ts +11 -0
- package/dist/components/spinner.js +10 -0
- package/dist/components/sprite-player.d.ts +50 -0
- package/dist/components/sprite-player.js +230 -0
- package/dist/components/status-bar.d.ts +14 -0
- package/dist/components/status-bar.js +16 -0
- package/dist/components/status-pill.d.ts +11 -0
- package/dist/components/status-pill.js +20 -0
- package/dist/components/switch.d.ts +15 -0
- package/dist/components/switch.js +16 -0
- package/dist/components/table.d.ts +15 -0
- package/dist/components/table.js +66 -0
- package/dist/components/tabs.d.ts +11 -0
- package/dist/components/tabs.js +24 -0
- package/dist/components/tag-input.d.ts +17 -0
- package/dist/components/tag-input.js +79 -0
- package/dist/components/textarea.d.ts +7 -0
- package/dist/components/textarea.js +8 -0
- package/dist/components/toast.d.ts +7 -0
- package/dist/components/toast.js +8 -0
- package/dist/components/toolbar.d.ts +8 -0
- package/dist/components/toolbar.js +11 -0
- package/dist/components/tooltip.d.ts +9 -0
- package/dist/components/tooltip.js +18 -0
- package/dist/components/update-banner.d.ts +14 -0
- package/dist/components/update-banner.js +39 -0
- package/dist/components/xv-primitives.d.ts +63 -0
- package/dist/components/xv-primitives.js +53 -0
- package/dist/css-exports.d.ts +77 -0
- package/dist/css-exports.js +116 -0
- package/dist/dna.d.ts +26 -0
- package/dist/dna.js +79 -0
- package/dist/game/boss-hud.d.ts +73 -0
- package/dist/game/boss-hud.js +78 -0
- package/dist/game/index.d.ts +194 -0
- package/dist/game/index.js +222 -0
- package/dist/game/tactical.d.ts +41 -0
- package/dist/game/tactical.js +46 -0
- package/dist/game.d.ts +95 -0
- package/dist/game.js +263 -0
- package/dist/icons/activity.d.ts +7 -0
- package/dist/icons/activity.js +8 -0
- package/dist/icons/add.d.ts +7 -0
- package/dist/icons/add.js +8 -0
- package/dist/icons/addon.d.ts +7 -0
- package/dist/icons/addon.js +8 -0
- package/dist/icons/anime-anger.d.ts +7 -0
- package/dist/icons/anime-anger.js +8 -0
- package/dist/icons/anime-shock.d.ts +7 -0
- package/dist/icons/anime-shock.js +8 -0
- package/dist/icons/anime-sparkle.d.ts +7 -0
- package/dist/icons/anime-sparkle.js +8 -0
- package/dist/icons/anime-sweatdrop.d.ts +7 -0
- package/dist/icons/anime-sweatdrop.js +8 -0
- package/dist/icons/archive.d.ts +7 -0
- package/dist/icons/archive.js +8 -0
- package/dist/icons/arrow-left.d.ts +7 -0
- package/dist/icons/arrow-left.js +8 -0
- package/dist/icons/arrow-right.d.ts +7 -0
- package/dist/icons/arrow-right.js +8 -0
- package/dist/icons/attachment.d.ts +7 -0
- package/dist/icons/attachment.js +8 -0
- package/dist/icons/bank.d.ts +7 -0
- package/dist/icons/bank.js +8 -0
- package/dist/icons/bolt.d.ts +7 -0
- package/dist/icons/bolt.js +8 -0
- package/dist/icons/book-open.d.ts +7 -0
- package/dist/icons/book-open.js +8 -0
- package/dist/icons/bookmark.d.ts +7 -0
- package/dist/icons/bookmark.js +8 -0
- package/dist/icons/boss-skull.d.ts +7 -0
- package/dist/icons/boss-skull.js +8 -0
- package/dist/icons/calendar-clock.d.ts +7 -0
- package/dist/icons/calendar-clock.js +8 -0
- package/dist/icons/calendar.d.ts +7 -0
- package/dist/icons/calendar.js +8 -0
- package/dist/icons/check-circle.d.ts +7 -0
- package/dist/icons/check-circle.js +8 -0
- package/dist/icons/check-square.d.ts +7 -0
- package/dist/icons/check-square.js +8 -0
- package/dist/icons/check.d.ts +7 -0
- package/dist/icons/check.js +8 -0
- package/dist/icons/chevron-right.d.ts +7 -0
- package/dist/icons/chevron-right.js +8 -0
- package/dist/icons/chevrons-left.d.ts +7 -0
- package/dist/icons/chevrons-left.js +8 -0
- package/dist/icons/chevrons-right.d.ts +7 -0
- package/dist/icons/chevrons-right.js +8 -0
- package/dist/icons/clapperboard.d.ts +7 -0
- package/dist/icons/clapperboard.js +8 -0
- package/dist/icons/clock.d.ts +7 -0
- package/dist/icons/clock.js +8 -0
- package/dist/icons/close.d.ts +7 -0
- package/dist/icons/close.js +8 -0
- package/dist/icons/code.d.ts +7 -0
- package/dist/icons/code.js +8 -0
- package/dist/icons/columns.d.ts +7 -0
- package/dist/icons/columns.js +8 -0
- package/dist/icons/combo-flame.d.ts +7 -0
- package/dist/icons/combo-flame.js +8 -0
- package/dist/icons/company.d.ts +7 -0
- package/dist/icons/company.js +8 -0
- package/dist/icons/credit-card.d.ts +7 -0
- package/dist/icons/credit-card.js +8 -0
- package/dist/icons/critical-star.d.ts +7 -0
- package/dist/icons/critical-star.js +8 -0
- package/dist/icons/currency.d.ts +7 -0
- package/dist/icons/currency.js +8 -0
- package/dist/icons/delete.d.ts +7 -0
- package/dist/icons/delete.js +8 -0
- package/dist/icons/document.d.ts +7 -0
- package/dist/icons/document.js +8 -0
- package/dist/icons/download.d.ts +7 -0
- package/dist/icons/download.js +8 -0
- package/dist/icons/dpad.d.ts +7 -0
- package/dist/icons/dpad.js +8 -0
- package/dist/icons/edit.d.ts +7 -0
- package/dist/icons/edit.js +8 -0
- package/dist/icons/element-fire.d.ts +7 -0
- package/dist/icons/element-fire.js +8 -0
- package/dist/icons/element-ice.d.ts +7 -0
- package/dist/icons/element-ice.js +8 -0
- package/dist/icons/element-solar.d.ts +7 -0
- package/dist/icons/element-solar.js +8 -0
- package/dist/icons/element-void.d.ts +7 -0
- package/dist/icons/element-void.js +8 -0
- package/dist/icons/element-volt.d.ts +7 -0
- package/dist/icons/element-volt.js +8 -0
- package/dist/icons/element-wind.d.ts +7 -0
- package/dist/icons/element-wind.js +8 -0
- package/dist/icons/error.d.ts +7 -0
- package/dist/icons/error.js +8 -0
- package/dist/icons/external-link.d.ts +7 -0
- package/dist/icons/external-link.js +8 -0
- package/dist/icons/field.d.ts +7 -0
- package/dist/icons/field.js +8 -0
- package/dist/icons/file-spreadsheet.d.ts +7 -0
- package/dist/icons/file-spreadsheet.js +8 -0
- package/dist/icons/filter.d.ts +7 -0
- package/dist/icons/filter.js +8 -0
- package/dist/icons/gacha-ticket.d.ts +7 -0
- package/dist/icons/gacha-ticket.js +8 -0
- package/dist/icons/gamepad.d.ts +7 -0
- package/dist/icons/gamepad.js +8 -0
- package/dist/icons/globe.d.ts +7 -0
- package/dist/icons/globe.js +8 -0
- package/dist/icons/grid.d.ts +7 -0
- package/dist/icons/grid.js +8 -0
- package/dist/icons/hash.d.ts +7 -0
- package/dist/icons/hash.js +8 -0
- package/dist/icons/heart-hp.d.ts +7 -0
- package/dist/icons/heart-hp.js +8 -0
- package/dist/icons/history.d.ts +7 -0
- package/dist/icons/history.js +8 -0
- package/dist/icons/home.d.ts +7 -0
- package/dist/icons/home.js +8 -0
- package/dist/icons/image.d.ts +7 -0
- package/dist/icons/image.js +8 -0
- package/dist/icons/impact-slash.d.ts +7 -0
- package/dist/icons/impact-slash.js +8 -0
- package/dist/icons/inbox.d.ts +7 -0
- package/dist/icons/inbox.js +8 -0
- package/dist/icons/index.d.ts +120 -0
- package/dist/icons/index.js +120 -0
- package/dist/icons/info.d.ts +7 -0
- package/dist/icons/info.js +8 -0
- package/dist/icons/jobs.d.ts +7 -0
- package/dist/icons/jobs.js +8 -0
- package/dist/icons/katana.d.ts +7 -0
- package/dist/icons/katana.js +8 -0
- package/dist/icons/key.d.ts +7 -0
- package/dist/icons/key.js +8 -0
- package/dist/icons/keyboard.d.ts +7 -0
- package/dist/icons/keyboard.js +8 -0
- package/dist/icons/keyframe-diamond.d.ts +7 -0
- package/dist/icons/keyframe-diamond.js +8 -0
- package/dist/icons/knowledge.d.ts +7 -0
- package/dist/icons/knowledge.js +8 -0
- package/dist/icons/language.d.ts +7 -0
- package/dist/icons/language.js +8 -0
- package/dist/icons/lock.d.ts +7 -0
- package/dist/icons/lock.js +8 -0
- package/dist/icons/logout.d.ts +7 -0
- package/dist/icons/logout.js +8 -0
- package/dist/icons/loot-chest.d.ts +7 -0
- package/dist/icons/loot-chest.js +8 -0
- package/dist/icons/mail.d.ts +7 -0
- package/dist/icons/mail.js +8 -0
- package/dist/icons/mana-crystal.d.ts +7 -0
- package/dist/icons/mana-crystal.js +8 -0
- package/dist/icons/map-pin.d.ts +7 -0
- package/dist/icons/map-pin.js +8 -0
- package/dist/icons/mecha-helm.d.ts +7 -0
- package/dist/icons/mecha-helm.js +8 -0
- package/dist/icons/menu.d.ts +7 -0
- package/dist/icons/menu.js +8 -0
- package/dist/icons/message.d.ts +7 -0
- package/dist/icons/message.js +8 -0
- package/dist/icons/model.d.ts +7 -0
- package/dist/icons/model.js +8 -0
- package/dist/icons/moon.d.ts +7 -0
- package/dist/icons/moon.js +8 -0
- package/dist/icons/notification.d.ts +7 -0
- package/dist/icons/notification.js +8 -0
- package/dist/icons/partner.d.ts +7 -0
- package/dist/icons/partner.js +8 -0
- package/dist/icons/pause.d.ts +7 -0
- package/dist/icons/pause.js +8 -0
- package/dist/icons/phone.d.ts +7 -0
- package/dist/icons/phone.js +8 -0
- package/dist/icons/play.d.ts +7 -0
- package/dist/icons/play.js +8 -0
- package/dist/icons/potion-flask.d.ts +7 -0
- package/dist/icons/potion-flask.js +8 -0
- package/dist/icons/quest-scroll.d.ts +7 -0
- package/dist/icons/quest-scroll.js +8 -0
- package/dist/icons/radar-ping.d.ts +7 -0
- package/dist/icons/radar-ping.js +8 -0
- package/dist/icons/refresh.d.ts +7 -0
- package/dist/icons/refresh.js +8 -0
- package/dist/icons/relation.d.ts +7 -0
- package/dist/icons/relation.js +8 -0
- package/dist/icons/save.d.ts +7 -0
- package/dist/icons/save.js +8 -0
- package/dist/icons/search.d.ts +7 -0
- package/dist/icons/search.js +8 -0
- package/dist/icons/security.d.ts +7 -0
- package/dist/icons/security.js +8 -0
- package/dist/icons/send.d.ts +7 -0
- package/dist/icons/send.js +8 -0
- package/dist/icons/settings.d.ts +7 -0
- package/dist/icons/settings.js +8 -0
- package/dist/icons/shield-crest.d.ts +7 -0
- package/dist/icons/shield-crest.js +8 -0
- package/dist/icons/shuriken.d.ts +7 -0
- package/dist/icons/shuriken.js +8 -0
- package/dist/icons/signal-off.d.ts +7 -0
- package/dist/icons/signal-off.js +8 -0
- package/dist/icons/signal.d.ts +7 -0
- package/dist/icons/signal.js +8 -0
- package/dist/icons/skill-node.d.ts +7 -0
- package/dist/icons/skill-node.js +8 -0
- package/dist/icons/smartphone.d.ts +7 -0
- package/dist/icons/smartphone.js +8 -0
- package/dist/icons/sort-ascending.d.ts +7 -0
- package/dist/icons/sort-ascending.js +8 -0
- package/dist/icons/sort-descending.d.ts +7 -0
- package/dist/icons/sort-descending.js +8 -0
- package/dist/icons/sort.d.ts +7 -0
- package/dist/icons/sort.js +8 -0
- package/dist/icons/sparkle.d.ts +7 -0
- package/dist/icons/sparkle.js +8 -0
- package/dist/icons/speech-burst.d.ts +7 -0
- package/dist/icons/speech-burst.js +8 -0
- package/dist/icons/story.d.ts +7 -0
- package/dist/icons/story.js +8 -0
- package/dist/icons/sun.d.ts +7 -0
- package/dist/icons/sun.js +8 -0
- package/dist/icons/tag.d.ts +7 -0
- package/dist/icons/tag.js +8 -0
- package/dist/icons/team.d.ts +7 -0
- package/dist/icons/team.js +8 -0
- package/dist/icons/trophy-crown.d.ts +7 -0
- package/dist/icons/trophy-crown.js +8 -0
- package/dist/icons/upload.d.ts +7 -0
- package/dist/icons/upload.js +8 -0
- package/dist/icons/user.d.ts +7 -0
- package/dist/icons/user.js +8 -0
- package/dist/icons/users.d.ts +7 -0
- package/dist/icons/users.js +8 -0
- package/dist/icons/visibility-off.d.ts +7 -0
- package/dist/icons/visibility-off.js +8 -0
- package/dist/icons/visibility.d.ts +7 -0
- package/dist/icons/visibility.js +8 -0
- package/dist/icons/volume-off.d.ts +7 -0
- package/dist/icons/volume-off.js +8 -0
- package/dist/icons/volume.d.ts +7 -0
- package/dist/icons/volume.js +8 -0
- package/dist/icons/warning.d.ts +7 -0
- package/dist/icons/warning.js +8 -0
- package/dist/icons/workflow.d.ts +7 -0
- package/dist/icons/workflow.js +8 -0
- package/dist/icons.d.ts +124 -0
- package/dist/icons.js +361 -0
- package/dist/index.d.ts +81 -0
- package/dist/index.js +83 -0
- package/dist/lib/asset-registry.d.ts +104 -0
- package/dist/lib/asset-registry.js +328 -0
- package/dist/lib/audio-runtime.d.ts +23 -0
- package/dist/lib/audio-runtime.js +254 -0
- package/dist/lib/character-adapter.d.ts +63 -0
- package/dist/lib/character-adapter.js +232 -0
- package/dist/lib/character-registry.d.ts +159 -0
- package/dist/lib/character-registry.js +1950 -0
- package/dist/lib/cn.d.ts +2 -0
- package/dist/lib/cn.js +4 -0
- package/dist/lib/compose-refs.d.ts +7 -0
- package/dist/lib/compose-refs.js +14 -0
- package/dist/lib/sanitize-url.d.ts +6 -0
- package/dist/lib/sanitize-url.js +44 -0
- package/dist/lib/scene-camera.d.ts +70 -0
- package/dist/lib/scene-camera.js +317 -0
- package/dist/lib/scene-playback.d.ts +93 -0
- package/dist/lib/scene-playback.js +447 -0
- package/dist/lib/scene-soundscape.d.ts +35 -0
- package/dist/lib/scene-soundscape.js +117 -0
- package/dist/lib/scene-test-harness.d.ts +17 -0
- package/dist/lib/scene-test-harness.js +140 -0
- package/dist/lib/scene-timeline.d.ts +59 -0
- package/dist/lib/scene-timeline.js +280 -0
- package/dist/lib/use-animation-visibility.d.ts +7 -0
- package/dist/lib/use-animation-visibility.js +31 -0
- package/dist/lib/use-modal-focus.d.ts +6 -0
- package/dist/lib/use-modal-focus.js +211 -0
- package/dist/lib/use-reduced-motion.d.ts +5 -0
- package/dist/lib/use-reduced-motion.js +31 -0
- package/dist/motion/easing-presets.d.ts +21 -0
- package/dist/motion/easing-presets.js +207 -0
- package/dist/motion/index.d.ts +153 -0
- package/dist/motion/index.js +311 -0
- package/dist/motion/physics.d.ts +30 -0
- package/dist/motion/physics.js +178 -0
- package/dist/motion/timeline-math.d.ts +78 -0
- package/dist/motion/timeline-math.js +216 -0
- package/dist/motion.d.ts +76 -0
- package/dist/motion.js +316 -0
- package/dist/pixelfx-boundary.d.ts +79 -0
- package/dist/pixelfx-boundary.js +114 -0
- package/dist/pixelfx-registry.d.ts +127 -0
- package/dist/pixelfx-registry.js +861 -0
- package/dist/pixelfx.d.ts +161 -0
- package/dist/pixelfx.js +534 -0
- package/dist/provider.d.ts +27 -0
- package/dist/provider.js +15 -0
- package/dist/skin-catalog.d.ts +31 -0
- package/dist/skin-catalog.js +242 -0
- package/dist/skin-tokens.d.ts +3 -0
- package/dist/skin-tokens.js +390 -0
- package/dist/ssr/init-script.d.ts +36 -0
- package/dist/ssr/init-script.js +135 -0
- package/dist/ssr/resolve-skin.d.ts +34 -0
- package/dist/ssr/resolve-skin.js +168 -0
- package/dist/ssr/theme-mismatch-dev.d.ts +58 -0
- package/dist/ssr/theme-mismatch-dev.js +133 -0
- package/dist/tailwind-preset.css +109 -0
- package/dist/templates/battle-arena.d.ts +2 -0
- package/dist/templates/battle-arena.js +351 -0
- package/dist/templates/index.d.ts +3 -0
- package/dist/templates/index.js +77 -0
- package/dist/templates.d.ts +4 -0
- package/dist/templates.js +78 -0
- package/dist/themes/dna-presets.d.ts +18 -0
- package/dist/themes/dna-presets.js +84 -0
- package/dist/themes/index.d.ts +13 -0
- package/dist/themes/index.js +12 -0
- package/dist/themes/provider.d.ts +26 -0
- package/dist/themes/provider.js +111 -0
- package/dist/themes/types.d.ts +42 -0
- package/dist/themes/types.js +47 -0
- package/dist/themes.d.ts +2 -0
- package/dist/themes.js +2 -0
- package/dist/token-exporter.d.ts +5 -0
- package/dist/token-exporter.js +4 -0
- package/dist/token-exporters.d.ts +28 -0
- package/dist/token-exporters.js +257 -0
- package/dist/token-seeds.d.ts +38 -0
- package/dist/token-seeds.js +272 -0
- package/dist/token-snapshot.d.ts +21 -0
- package/dist/token-snapshot.js +131 -0
- package/dist/tokens.bundle.json +1669 -0
- package/dist/tokens.generated.css +599 -0
- package/dist/tokens.w3c.json +1931 -0
- package/dist/utils.d.ts +12 -0
- package/dist/utils.js +49 -0
- package/package.json +544 -42
- package/scripts/consumer-smoke.mjs +45 -0
- package/scripts/generate-icons.mjs +110 -0
- package/scripts/generate-token-artifacts.mjs +90 -0
- package/scripts/icon-svg-to-jsx.mjs +249 -0
- package/scripts/verification-diagnostics.mjs +40 -0
- package/scripts/verify-package.mjs +412 -0
- package/src/cartoon/anime-avatar.tsx +628 -0
- package/src/cartoon/anime-stage.tsx +458 -0
- package/src/cartoon/index.tsx +542 -0
- package/src/cartoon.tsx +645 -0
- package/src/characters.ts +625 -0
- package/src/components/accordion.tsx +77 -0
- package/src/components/alert.tsx +139 -0
- package/src/components/appearance-menu.tsx +181 -0
- package/src/components/artwork-frame.tsx +49 -0
- package/src/components/audio.tsx +97 -0
- package/src/components/avatar.tsx +75 -0
- package/src/components/badge.tsx +94 -0
- package/src/components/brand-mark.tsx +73 -0
- package/src/components/breadcrumbs.tsx +98 -0
- package/src/components/button.tsx +340 -0
- package/src/components/card.tsx +171 -0
- package/src/components/character-badge.tsx +58 -0
- package/src/components/character-preview.tsx +104 -0
- package/src/components/character-stage.tsx +225 -0
- package/src/components/chart.tsx +481 -0
- package/src/components/checkbox.tsx +64 -0
- package/src/components/comic-panel.tsx +301 -0
- package/src/components/comic-theater.tsx +170 -0
- package/src/components/command.tsx +189 -0
- package/src/components/confirm-dialog.tsx +129 -0
- package/src/components/copy-button.tsx +62 -0
- package/src/components/date-picker.tsx +126 -0
- package/src/components/dialog.tsx +164 -0
- package/src/components/dna-icon.tsx +77 -0
- package/src/components/dropdown-menu.tsx +87 -0
- package/src/components/effects.tsx +1021 -0
- package/src/components/empty-state.tsx +93 -0
- package/src/components/epistemic-branch-panel.tsx +101 -0
- package/src/components/error-state.tsx +137 -0
- package/src/components/field.tsx +96 -0
- package/src/components/filter-facet-bar.tsx +91 -0
- package/src/components/inbox-popover.tsx +146 -0
- package/src/components/input.tsx +25 -0
- package/src/components/kanban-board.tsx +190 -0
- package/src/components/label.tsx +19 -0
- package/src/components/layered-scene.tsx +555 -0
- package/src/components/log-console.tsx +261 -0
- package/src/components/metric-tile.tsx +99 -0
- package/src/components/mode-picker.tsx +149 -0
- package/src/components/motion-timeline.tsx +848 -0
- package/src/components/number-input.tsx +104 -0
- package/src/components/page-header.tsx +123 -0
- package/src/components/pagination.tsx +83 -0
- package/src/components/panel.tsx +121 -0
- package/src/components/paper-note.tsx +77 -0
- package/src/components/popover.tsx +72 -0
- package/src/components/progress.tsx +127 -0
- package/src/components/quest-card.tsx +319 -0
- package/src/components/radio-group.tsx +50 -0
- package/src/components/riot-sticker.tsx +151 -0
- package/src/components/scene-particles.tsx +196 -0
- package/src/components/scene-transitions.tsx +130 -0
- package/src/components/section-ribbon.tsx +94 -0
- package/src/components/select-field.tsx +27 -0
- package/src/components/select.tsx +81 -0
- package/src/components/separator.tsx +58 -0
- package/src/components/sheet.tsx +96 -0
- package/src/components/skeleton.tsx +35 -0
- package/src/components/sketch-annotation.tsx +87 -0
- package/src/components/smart-button-box.tsx +114 -0
- package/src/components/speech-bubble.tsx +116 -0
- package/src/components/spinner.tsx +69 -0
- package/src/components/sprite-player.tsx +412 -0
- package/src/components/status-bar.tsx +63 -0
- package/src/components/status-pill.tsx +68 -0
- package/src/components/switch.tsx +76 -0
- package/src/components/table.tsx +163 -0
- package/src/components/tabs.tsx +101 -0
- package/src/components/tag-input.tsx +170 -0
- package/src/components/textarea.tsx +25 -0
- package/src/components/toast.tsx +14 -0
- package/src/components/toolbar.tsx +39 -0
- package/src/components/tooltip.tsx +49 -0
- package/src/components/update-banner.tsx +220 -0
- package/src/components/xv-primitives.tsx +256 -0
- package/src/css-exports.ts +142 -0
- package/src/dna.tsx +137 -0
- package/src/game/boss-hud.tsx +384 -0
- package/src/game/index.tsx +886 -0
- package/src/game/tactical.tsx +245 -0
- package/src/game.tsx +770 -0
- package/src/icons/activity.tsx +38 -0
- package/src/icons/add.tsx +38 -0
- package/src/icons/addon.tsx +37 -0
- package/src/icons/anime-anger.tsx +37 -0
- package/src/icons/anime-shock.tsx +37 -0
- package/src/icons/anime-sparkle.tsx +38 -0
- package/src/icons/anime-sweatdrop.tsx +38 -0
- package/src/icons/archive.tsx +37 -0
- package/src/icons/arrow-left.tsx +37 -0
- package/src/icons/arrow-right.tsx +37 -0
- package/src/icons/attachment.tsx +38 -0
- package/src/icons/bank.tsx +37 -0
- package/src/icons/bolt.tsx +37 -0
- package/src/icons/book-open.tsx +37 -0
- package/src/icons/bookmark.tsx +37 -0
- package/src/icons/boss-skull.tsx +40 -0
- package/src/icons/calendar-clock.tsx +40 -0
- package/src/icons/calendar.tsx +38 -0
- package/src/icons/check-circle.tsx +38 -0
- package/src/icons/check-square.tsx +38 -0
- package/src/icons/check.tsx +37 -0
- package/src/icons/chevron-right.tsx +37 -0
- package/src/icons/chevrons-left.tsx +37 -0
- package/src/icons/chevrons-right.tsx +37 -0
- package/src/icons/clapperboard.tsx +38 -0
- package/src/icons/clock.tsx +38 -0
- package/src/icons/close.tsx +37 -0
- package/src/icons/code.tsx +37 -0
- package/src/icons/columns.tsx +38 -0
- package/src/icons/combo-flame.tsx +38 -0
- package/src/icons/company.tsx +38 -0
- package/src/icons/credit-card.tsx +38 -0
- package/src/icons/critical-star.tsx +37 -0
- package/src/icons/currency.tsx +38 -0
- package/src/icons/delete.tsx +37 -0
- package/src/icons/document.tsx +38 -0
- package/src/icons/download.tsx +37 -0
- package/src/icons/dpad.tsx +38 -0
- package/src/icons/edit.tsx +38 -0
- package/src/icons/element-fire.tsx +37 -0
- package/src/icons/element-ice.tsx +38 -0
- package/src/icons/element-solar.tsx +38 -0
- package/src/icons/element-void.tsx +38 -0
- package/src/icons/element-volt.tsx +38 -0
- package/src/icons/element-wind.tsx +37 -0
- package/src/icons/error.tsx +38 -0
- package/src/icons/external-link.tsx +38 -0
- package/src/icons/field.tsx +38 -0
- package/src/icons/file-spreadsheet.tsx +38 -0
- package/src/icons/filter.tsx +37 -0
- package/src/icons/gacha-ticket.tsx +38 -0
- package/src/icons/gamepad.tsx +40 -0
- package/src/icons/globe.tsx +38 -0
- package/src/icons/grid.tsx +40 -0
- package/src/icons/hash.tsx +37 -0
- package/src/icons/heart-hp.tsx +38 -0
- package/src/icons/history.tsx +37 -0
- package/src/icons/home.tsx +37 -0
- package/src/icons/image.tsx +39 -0
- package/src/icons/impact-slash.tsx +38 -0
- package/src/icons/inbox.tsx +38 -0
- package/src/icons/index.ts +120 -0
- package/src/icons/info.tsx +38 -0
- package/src/icons/jobs.tsx +38 -0
- package/src/icons/katana.tsx +38 -0
- package/src/icons/key.tsx +38 -0
- package/src/icons/keyboard.tsx +38 -0
- package/src/icons/keyframe-diamond.tsx +38 -0
- package/src/icons/knowledge.tsx +38 -0
- package/src/icons/language.tsx +39 -0
- package/src/icons/lock.tsx +38 -0
- package/src/icons/logout.tsx +37 -0
- package/src/icons/loot-chest.tsx +39 -0
- package/src/icons/mail.tsx +38 -0
- package/src/icons/mana-crystal.tsx +38 -0
- package/src/icons/map-pin.tsx +38 -0
- package/src/icons/mecha-helm.tsx +38 -0
- package/src/icons/menu.tsx +37 -0
- package/src/icons/message.tsx +38 -0
- package/src/icons/model.tsx +38 -0
- package/src/icons/moon.tsx +37 -0
- package/src/icons/notification.tsx +38 -0
- package/src/icons/partner.tsx +41 -0
- package/src/icons/pause.tsx +37 -0
- package/src/icons/phone.tsx +37 -0
- package/src/icons/play.tsx +37 -0
- package/src/icons/potion-flask.tsx +40 -0
- package/src/icons/quest-scroll.tsx +39 -0
- package/src/icons/radar-ping.tsx +40 -0
- package/src/icons/refresh.tsx +38 -0
- package/src/icons/relation.tsx +40 -0
- package/src/icons/save.tsx +38 -0
- package/src/icons/search.tsx +38 -0
- package/src/icons/security.tsx +38 -0
- package/src/icons/send.tsx +38 -0
- package/src/icons/settings.tsx +39 -0
- package/src/icons/shield-crest.tsx +38 -0
- package/src/icons/shuriken.tsx +38 -0
- package/src/icons/signal-off.tsx +37 -0
- package/src/icons/signal.tsx +37 -0
- package/src/icons/skill-node.tsx +40 -0
- package/src/icons/smartphone.tsx +38 -0
- package/src/icons/sort-ascending.tsx +37 -0
- package/src/icons/sort-descending.tsx +37 -0
- package/src/icons/sort.tsx +37 -0
- package/src/icons/sparkle.tsx +38 -0
- package/src/icons/speech-burst.tsx +37 -0
- package/src/icons/story.tsx +37 -0
- package/src/icons/sun.tsx +38 -0
- package/src/icons/tag.tsx +38 -0
- package/src/icons/team.tsx +40 -0
- package/src/icons/trophy-crown.tsx +39 -0
- package/src/icons/upload.tsx +37 -0
- package/src/icons/user.tsx +38 -0
- package/src/icons/users.tsx +39 -0
- package/src/icons/visibility-off.tsx +38 -0
- package/src/icons/visibility.tsx +38 -0
- package/src/icons/volume-off.tsx +37 -0
- package/src/icons/volume.tsx +37 -0
- package/src/icons/warning.tsx +38 -0
- package/src/icons/workflow.tsx +40 -0
- package/src/icons.tsx +965 -0
- package/src/index.ts +89 -0
- package/src/lib/asset-registry.ts +534 -0
- package/src/lib/audio-runtime.ts +314 -0
- package/src/lib/character-adapter.ts +370 -0
- package/src/lib/character-registry.ts +2368 -0
- package/src/lib/cn.ts +6 -0
- package/src/lib/compose-refs.ts +16 -0
- package/src/lib/sanitize-url.ts +51 -0
- package/src/lib/scene-camera.ts +483 -0
- package/src/lib/scene-playback.ts +622 -0
- package/src/lib/scene-soundscape.ts +151 -0
- package/src/lib/scene-test-harness.ts +200 -0
- package/src/lib/scene-timeline.ts +398 -0
- package/src/lib/use-animation-visibility.ts +45 -0
- package/src/lib/use-modal-focus.ts +270 -0
- package/src/lib/use-reduced-motion.ts +37 -0
- package/src/motion/easing-presets.ts +262 -0
- package/src/motion/index.tsx +894 -0
- package/src/motion/physics.ts +259 -0
- package/src/motion/timeline-math.ts +358 -0
- package/src/motion.tsx +639 -0
- package/src/pixelfx-boundary.ts +188 -0
- package/src/pixelfx-registry.ts +1190 -0
- package/src/pixelfx-types.d.ts +73 -0
- package/src/pixelfx.tsx +1022 -0
- package/src/provider.tsx +63 -0
- package/src/skin-catalog.ts +306 -0
- package/src/skin-tokens.ts +425 -0
- package/src/ssr/init-script.ts +281 -0
- package/src/ssr/resolve-skin.ts +217 -0
- package/src/ssr/theme-mismatch-dev.ts +181 -0
- package/src/styles/components.css +8007 -0
- package/src/styles/tokens.css +952 -0
- package/src/styles/visual-universe.css +149 -0
- package/src/styles/xv-primitives.css +192 -0
- package/src/templates/battle-arena.tsx +688 -0
- package/src/templates/index.tsx +314 -0
- package/src/templates.tsx +225 -0
- package/src/themes/dna-presets.ts +119 -0
- package/src/themes/index.ts +56 -0
- package/src/themes/provider.tsx +183 -0
- package/src/themes/types.ts +111 -0
- package/src/themes.ts +9 -0
- package/src/token-exporter.ts +12 -0
- package/src/token-exporters.ts +343 -0
- package/src/token-seeds.ts +335 -0
- package/src/token-snapshot.ts +179 -0
- package/src/utils.ts +58 -0
- package/styles.css +3 -0
- package/src/components.d.ts +0 -588
- package/src/components.js +0 -2044
- package/src/index.d.ts +0 -3
- package/src/index.js +0 -13
- package/src/skins.d.ts +0 -4
- package/src/skins.js +0 -20
- package/src/styles.css +0 -587
- package/src/tailwind.css +0 -24
- package/src/theme.d.ts +0 -71
- package/src/theme.js +0 -257
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* T13 — Client pre-hydration init script for SSR skin parity.
|
|
3
|
+
*
|
|
4
|
+
* INV-013: Theme state is carried by request data.
|
|
5
|
+
* Generates a dependency-free IIFE that runs before React hydration.
|
|
6
|
+
* Precedence: explicit inline state > server data-* attrs > mw-theme cookie > legacy localStorage > defaults.
|
|
7
|
+
* Dev mismatch warning integrates T09 theme-mismatch-dev.ts when `dev: true`.
|
|
8
|
+
*/
|
|
9
|
+
import { DEFAULT_SKIN_ID, themeRegistry, } from "../skin-catalog.js";
|
|
10
|
+
const VALID_MODES = new Set(["light", "dark"]);
|
|
11
|
+
const VALID_DENSITIES = new Set(["comfortable", "compact"]);
|
|
12
|
+
function isValidMode(value) {
|
|
13
|
+
return typeof value === "string" && VALID_MODES.has(value);
|
|
14
|
+
}
|
|
15
|
+
function isValidDensity(value) {
|
|
16
|
+
return typeof value === "string" && VALID_DENSITIES.has(value);
|
|
17
|
+
}
|
|
18
|
+
function isValidSkinId(value, registry) {
|
|
19
|
+
return typeof value === "string" && registry.has(value);
|
|
20
|
+
}
|
|
21
|
+
function resolveFromCookie(cookieValue, registry) {
|
|
22
|
+
if (!cookieValue)
|
|
23
|
+
return {};
|
|
24
|
+
let raw = cookieValue.trim();
|
|
25
|
+
try {
|
|
26
|
+
raw = decodeURIComponent(raw);
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
// keep raw
|
|
30
|
+
}
|
|
31
|
+
// Handle legacy bare mode like "dark"
|
|
32
|
+
if (isValidMode(raw))
|
|
33
|
+
return { theme_mode: raw };
|
|
34
|
+
const result = {};
|
|
35
|
+
for (const pair of raw.split(";")) {
|
|
36
|
+
const idx = pair.indexOf("=");
|
|
37
|
+
if (idx <= 0)
|
|
38
|
+
continue;
|
|
39
|
+
const key = pair.slice(0, idx).trim().toLowerCase();
|
|
40
|
+
const val = decodeURIComponent(pair.slice(idx + 1).trim());
|
|
41
|
+
if (key === "skin" && isValidSkinId(val, registry)) {
|
|
42
|
+
result.skin = val;
|
|
43
|
+
}
|
|
44
|
+
else if ((key === "mode" || key === "theme") && isValidMode(val)) {
|
|
45
|
+
result.theme_mode = val;
|
|
46
|
+
}
|
|
47
|
+
else if (key === "density" && isValidDensity(val)) {
|
|
48
|
+
result.density = val;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
function normalizeState(partial, registry) {
|
|
54
|
+
const skinId = isValidSkinId(partial.skin, registry) ? partial.skin : registry.defaultSkinId;
|
|
55
|
+
const metadata = registry.resolve(skinId);
|
|
56
|
+
const mode = isValidMode(partial.theme_mode) ? partial.theme_mode : metadata.defaultMode;
|
|
57
|
+
const density = isValidDensity(partial.density) ? partial.density : metadata.defaultDensity;
|
|
58
|
+
return { skin: metadata.id, theme_mode: mode, density };
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Create a pre-hydration init script that applies theme state to documentElement
|
|
62
|
+
* before React hydrates. The generated IIFE has zero dependencies and runs
|
|
63
|
+
* synchronously in the <head> or at the top of <body>.
|
|
64
|
+
*
|
|
65
|
+
* Precedence (highest first):
|
|
66
|
+
* 1. `serverState` passed explicitly (inline data-* attrs from server render)
|
|
67
|
+
* 2. `cookieValue` from mw-theme cookie (passed from server, or read at runtime)
|
|
68
|
+
* 3. Legacy localStorage keys (mw-ui-theme, mw-board-preferences, mw-theme)
|
|
69
|
+
* 4. Registry defaults
|
|
70
|
+
*
|
|
71
|
+
* When `dev: true`, emits a console.warn if the resolved skin differs from what
|
|
72
|
+
* the server would have resolved from the same cookie (T09 parity check).
|
|
73
|
+
*/
|
|
74
|
+
export function createSkinInitScript(options = {}) {
|
|
75
|
+
const { serverState, cookieValue, dev = false, registry = themeRegistry, storageKey = "mw-ui-theme", } = options;
|
|
76
|
+
// Build the explicit server state if provided
|
|
77
|
+
const serverStatePayload = serverState
|
|
78
|
+
? normalizeState(serverState, registry)
|
|
79
|
+
: null;
|
|
80
|
+
// Resolve what the cookie would produce (for dev parity check)
|
|
81
|
+
const cookieState = cookieValue
|
|
82
|
+
? normalizeState(resolveFromCookie(cookieValue, registry), registry)
|
|
83
|
+
: null;
|
|
84
|
+
// Serialize registry skin IDs for client-side validation
|
|
85
|
+
const skinIdsJson = JSON.stringify(registry.list().map((s) => s.id));
|
|
86
|
+
const defaultSkinIdJson = JSON.stringify(DEFAULT_SKIN_ID);
|
|
87
|
+
const storageKeyJson = JSON.stringify(storageKey);
|
|
88
|
+
// Build the IIFE body as a template
|
|
89
|
+
const parts = [];
|
|
90
|
+
parts.push("(function(){");
|
|
91
|
+
parts.push("try{");
|
|
92
|
+
// 1. Apply explicit server state if provided (inline data-* wins)
|
|
93
|
+
if (serverStatePayload) {
|
|
94
|
+
parts.push(`var s=${JSON.stringify(serverStatePayload)};`, `document.documentElement.dataset.skin=s.skin;`, `document.documentElement.dataset.density=s.density;`, `document.documentElement.dataset.theme=s.theme_mode;`, `document.documentElement.classList.toggle('dark',s.theme_mode==='dark');`, `document.documentElement.classList.toggle('high-contrast',s.theme_mode==='high-contrast');`);
|
|
95
|
+
}
|
|
96
|
+
else if (cookieValue !== undefined && cookieValue !== null) {
|
|
97
|
+
// 2a. Explicit cookieValue passed from server - use it directly if valid
|
|
98
|
+
const cookieParsed = resolveFromCookie(cookieValue, registry);
|
|
99
|
+
if (Object.keys(cookieParsed).length > 0) {
|
|
100
|
+
parts.push(`var c=${JSON.stringify(normalizeState(cookieParsed, registry))};`, `document.documentElement.dataset.skin=c.skin;`, `document.documentElement.dataset.density=c.density;`, `document.documentElement.dataset.theme=c.theme_mode;`, `document.documentElement.classList.toggle('dark',c.theme_mode==='dark');`, `document.documentElement.classList.toggle('high-contrast',c.theme_mode==='high-contrast');`);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
// 2b. Explicit cookieValue but invalid - fall through to runtime cookie + localStorage
|
|
104
|
+
parts.push(`var cookieVal=null;`, `var cookieHeader=document.cookie||'';`, `for(var i=0;i<cookieHeader.split(';').length;i++){`, ` var part=cookieHeader.split(';')[i].trim();`, ` var eq=part.indexOf('=');`, ` var key=eq>=0?part.slice(0,eq):part;`, ` if(key==='mw-theme'){ cookieVal=eq>=0?decodeURIComponent(part.slice(eq+1)):''; break; }`, `}`, `if(cookieVal){`, ` var parsed={};`, ` try{ cookieVal=decodeURIComponent(cookieVal); }catch(e){}`, ` if(cookieVal==='dark'||cookieVal==='light'){ parsed.theme_mode=cookieVal; }`, ` else{ for(var j=0;j<cookieVal.split(';').length;j++){ var p=cookieVal.split(';')[j].trim(); var ei=p.indexOf('='); if(ei<=0) continue; var pk=p.slice(0,ei).trim().toLowerCase(); var pv=decodeURIComponent(p.slice(ei+1).trim()); if(pk==='skin') parsed.skin=pv; else if(pk==='mode'||pk==='theme') parsed.theme_mode=pv; else if(pk==='density') parsed.density=pv; } }`, ` var allowed=${skinIdsJson};`, ` var skin=(parsed.skin&&allowed.indexOf(parsed.skin)!==-1)?parsed.skin:${defaultSkinIdJson};`, ` var mode=(parsed.theme_mode==='dark'||parsed.theme_mode==='light')?parsed.theme_mode:'light';`, ` var density=(parsed.density==='compact')?'compact':'comfortable';`, ` document.documentElement.dataset.skin=skin;`, ` document.documentElement.dataset.density=density;`, ` document.documentElement.dataset.theme=mode;`, ` document.documentElement.classList.toggle('dark',mode==='dark');`, ` document.documentElement.classList.toggle('high-contrast',mode==='high-contrast');`, `} else {`,
|
|
105
|
+
// 3. Legacy localStorage fallback
|
|
106
|
+
`var raw=localStorage.getItem(${storageKeyJson})||localStorage.getItem('mw-board-preferences')||localStorage.getItem('mw-theme');`, `var p=raw?JSON.parse(raw):null;`, `var allowed=${skinIdsJson};`, `var k=p&&typeof p.skin==='string'&&allowed.indexOf(p.skin)!==-1?p.skin:${defaultSkinIdJson};`, `var d=p&&p.density==='compact'?'compact':'comfortable';`, `var rawMode=p&&(p.mode||p.theme);`, `var m=(rawMode==='dark'||rawMode==='light'||rawMode==='high-contrast')?rawMode:'light';`, `document.documentElement.dataset.skin=k;`, `document.documentElement.dataset.density=d;`, `document.documentElement.dataset.theme=m;`, `document.documentElement.classList.toggle('dark',m==='dark');`, `document.documentElement.classList.toggle('high-contrast',m==='high-contrast');`, `}`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
// 2c. No explicit cookieValue - read mw-theme cookie at runtime, then localStorage
|
|
111
|
+
parts.push(`var cookieVal=null;`, `var cookieHeader=document.cookie||'';`, `for(var i=0;i<cookieHeader.split(';').length;i++){`, ` var part=cookieHeader.split(';')[i].trim();`, ` var eq=part.indexOf('=');`, ` var key=eq>=0?part.slice(0,eq):part;`, ` if(key==='mw-theme'){ cookieVal=eq>=0?decodeURIComponent(part.slice(eq+1)):''; break; }`, `}`, `if(cookieVal){`, ` var parsed={};`, ` try{ cookieVal=decodeURIComponent(cookieVal); }catch(e){}`, ` if(cookieVal==='dark'||cookieVal==='light'){ parsed.theme_mode=cookieVal; }`, ` else{ for(var j=0;j<cookieVal.split(';').length;j++){ var p=cookieVal.split(';')[j].trim(); var ei=p.indexOf('='); if(ei<=0) continue; var pk=p.slice(0,ei).trim().toLowerCase(); var pv=decodeURIComponent(p.slice(ei+1).trim()); if(pk==='skin') parsed.skin=pv; else if(pk==='mode'||pk==='theme') parsed.theme_mode=pv; else if(pk==='density') parsed.density=pv; } }`, ` var allowed=${skinIdsJson};`, ` var skin=(parsed.skin&&allowed.indexOf(parsed.skin)!==-1)?parsed.skin:${defaultSkinIdJson};`, ` var mode=(parsed.theme_mode==='dark'||parsed.theme_mode==='light')?parsed.theme_mode:'light';`, ` var density=(parsed.density==='compact')?'compact':'comfortable';`, ` document.documentElement.dataset.skin=skin;`, ` document.documentElement.dataset.density=density;`, ` document.documentElement.dataset.theme=mode;`, ` document.documentElement.classList.toggle('dark',mode==='dark');`, ` document.documentElement.classList.toggle('high-contrast',mode==='high-contrast');`, `} else {`,
|
|
112
|
+
// 3. Legacy localStorage fallback
|
|
113
|
+
`var raw=localStorage.getItem(${storageKeyJson})||localStorage.getItem('mw-board-preferences')||localStorage.getItem('mw-theme');`, `var p=raw?JSON.parse(raw):null;`, `var allowed=${skinIdsJson};`, `var k=p&&typeof p.skin==='string'&&allowed.indexOf(p.skin)!==-1?p.skin:${defaultSkinIdJson};`, `var d=p&&p.density==='compact'?'compact':'comfortable';`, `var rawMode=p&&(p.mode||p.theme);`, `var m=(rawMode==='dark'||rawMode==='light'||rawMode==='high-contrast')?rawMode:'light';`, `document.documentElement.dataset.skin=k;`, `document.documentElement.dataset.density=d;`, `document.documentElement.dataset.theme=m;`, `document.documentElement.classList.toggle('dark',m==='dark');`, `document.documentElement.classList.toggle('high-contrast',m==='high-contrast');`, `}`);
|
|
114
|
+
}
|
|
115
|
+
// Dev mismatch warning (T09 integration)
|
|
116
|
+
if (dev && serverStatePayload && cookieState) {
|
|
117
|
+
const serverSkin = serverStatePayload.skin;
|
|
118
|
+
const serverMode = serverStatePayload.theme_mode;
|
|
119
|
+
const serverDensity = serverStatePayload.density;
|
|
120
|
+
const cookieSkin = cookieState.skin;
|
|
121
|
+
const cookieMode = cookieState.theme_mode;
|
|
122
|
+
const cookieDensity = cookieState.density;
|
|
123
|
+
if (serverSkin !== cookieSkin ||
|
|
124
|
+
serverMode !== cookieMode ||
|
|
125
|
+
serverDensity !== cookieDensity) {
|
|
126
|
+
parts.push(`console.warn('[MoonWitness SSR] Theme mismatch: server={skin:"${serverSkin}",mode:"${serverMode}",density:"${serverDensity}"} cookie={skin:"${cookieSkin}",mode:"${cookieMode}",density:"${cookieDensity}"}. Inline state wins.');`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
parts.push("}catch(e){");
|
|
130
|
+
// Final safety net: apply defaults on any error
|
|
131
|
+
parts.push(`document.documentElement.dataset.skin=${defaultSkinIdJson};`, `document.documentElement.dataset.density='comfortable';`, `document.documentElement.dataset.theme='light';`, `document.documentElement.classList.remove('dark','high-contrast');`);
|
|
132
|
+
parts.push("}");
|
|
133
|
+
parts.push("})();");
|
|
134
|
+
return parts.join("");
|
|
135
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* T13 — SSR skin resolution from request data.
|
|
3
|
+
*
|
|
4
|
+
* INV-013: Theme state is carried by request data.
|
|
5
|
+
* No `localStorage`, `window`, or `document` access on this server path.
|
|
6
|
+
*/
|
|
7
|
+
import type { ThemeRegistry, UserThemePreferences } from "../themes/types.js";
|
|
8
|
+
export declare const THEME_COOKIE_NAME = "mw-theme";
|
|
9
|
+
export declare const THEME_HEADER_NAME = "x-mw-theme";
|
|
10
|
+
export type ThemeSource = "cookie" | "header" | "default";
|
|
11
|
+
export interface ResolvedSkin extends UserThemePreferences {
|
|
12
|
+
readonly source: ThemeSource;
|
|
13
|
+
readonly valid: boolean;
|
|
14
|
+
}
|
|
15
|
+
export type CookieInput = string | null | undefined | Headers | Record<string, string | string[] | undefined> | Map<string, string>;
|
|
16
|
+
export interface ResolveSkinOptions {
|
|
17
|
+
readonly registry?: ThemeRegistry;
|
|
18
|
+
readonly cookieName?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Resolve theme state from a cookie raw value, Cookie header, `Headers`,
|
|
22
|
+
* `x-mw-theme` header, or a plain header/cookie map.
|
|
23
|
+
*
|
|
24
|
+
* Precedence: mw-theme request data > x-mw-theme fallback > defaults.
|
|
25
|
+
*/
|
|
26
|
+
export declare function resolveSkin(input: CookieInput, options?: ResolveSkinOptions): ResolvedSkin;
|
|
27
|
+
/** Serialize resolved state into the URL-safe mw-theme cookie value. */
|
|
28
|
+
export declare function serializeSkinCookie(state: UserThemePreferences): string;
|
|
29
|
+
type MutableUserThemePreferences = {
|
|
30
|
+
-readonly [K in keyof UserThemePreferences]: UserThemePreferences[K];
|
|
31
|
+
};
|
|
32
|
+
/** Parse a raw mw-theme cookie value without registry normalization. */
|
|
33
|
+
export declare function parseSkinCookie(value: string | undefined | null, registry?: ThemeRegistry): Partial<MutableUserThemePreferences>;
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* T13 — SSR skin resolution from request data.
|
|
3
|
+
*
|
|
4
|
+
* INV-013: Theme state is carried by request data.
|
|
5
|
+
* No `localStorage`, `window`, or `document` access on this server path.
|
|
6
|
+
*/
|
|
7
|
+
import { DEFAULT_SKIN_ID, themeRegistry, } from "../skin-catalog.js";
|
|
8
|
+
export const THEME_COOKIE_NAME = "mw-theme";
|
|
9
|
+
export const THEME_HEADER_NAME = "x-mw-theme";
|
|
10
|
+
const THEME_VALUE_KEYS = new Set(["skin", "mode", "theme", "density"]);
|
|
11
|
+
const VALID_MODES = new Set(["light", "dark"]);
|
|
12
|
+
const VALID_DENSITIES = new Set(["comfortable", "compact"]);
|
|
13
|
+
function hasGet(input) {
|
|
14
|
+
return typeof input?.get === "function";
|
|
15
|
+
}
|
|
16
|
+
function headerValue(input, name) {
|
|
17
|
+
if (hasGet(input))
|
|
18
|
+
return input.get(name) ?? undefined;
|
|
19
|
+
if (input instanceof Map)
|
|
20
|
+
return input.get(name) ?? input.get(name.toLowerCase());
|
|
21
|
+
const direct = input[name] ?? input[name.toLowerCase()];
|
|
22
|
+
if (Array.isArray(direct))
|
|
23
|
+
return direct[0];
|
|
24
|
+
return direct;
|
|
25
|
+
}
|
|
26
|
+
function safeDecode(value) {
|
|
27
|
+
try {
|
|
28
|
+
return decodeURIComponent(value);
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/** Parse a theme value: `skin=x;mode=dark;density=compact` or legacy `dark`. */
|
|
35
|
+
function parseThemeValue(rawValue) {
|
|
36
|
+
if (!rawValue)
|
|
37
|
+
return {};
|
|
38
|
+
let raw = rawValue.trim();
|
|
39
|
+
if (/%3d/i.test(raw))
|
|
40
|
+
raw = safeDecode(raw);
|
|
41
|
+
if (VALID_MODES.has(raw))
|
|
42
|
+
return { mode: raw };
|
|
43
|
+
const result = {};
|
|
44
|
+
for (const pair of raw.split(";")) {
|
|
45
|
+
const separator = pair.indexOf("=");
|
|
46
|
+
if (separator <= 0) {
|
|
47
|
+
const bare = pair.trim();
|
|
48
|
+
if (VALID_MODES.has(bare))
|
|
49
|
+
result.mode = bare;
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
const key = pair.slice(0, separator).trim().toLowerCase();
|
|
53
|
+
if (!THEME_VALUE_KEYS.has(key))
|
|
54
|
+
continue;
|
|
55
|
+
result[key] = safeDecode(pair.slice(separator + 1).trim());
|
|
56
|
+
}
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
/** Read a cookie value from a Cookie header, including semicolon-delimited theme pairs. */
|
|
60
|
+
function rawCookieFromHeader(cookieHeader, name) {
|
|
61
|
+
let active = false;
|
|
62
|
+
let value;
|
|
63
|
+
for (const segment of cookieHeader.split(";")) {
|
|
64
|
+
const part = segment.trim();
|
|
65
|
+
if (!part)
|
|
66
|
+
continue;
|
|
67
|
+
const separator = part.indexOf("=");
|
|
68
|
+
const key = (separator >= 0 ? part.slice(0, separator) : part).trim();
|
|
69
|
+
if (separator < 0 && active) {
|
|
70
|
+
value += `;${part}`;
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
if (THEME_VALUE_KEYS.has(key.toLowerCase()) && active) {
|
|
74
|
+
value += `;${part}`;
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
active = key === name;
|
|
78
|
+
if (active)
|
|
79
|
+
value = separator >= 0 ? part.slice(separator + 1).trim() : "";
|
|
80
|
+
}
|
|
81
|
+
return value;
|
|
82
|
+
}
|
|
83
|
+
function readThemeRaw(input, cookieName) {
|
|
84
|
+
if (typeof input === "string") {
|
|
85
|
+
if (!input.includes("="))
|
|
86
|
+
return VALID_MODES.has(input.trim()) ? input.trim() : undefined;
|
|
87
|
+
return rawCookieFromHeader(input, cookieName);
|
|
88
|
+
}
|
|
89
|
+
if (input === null || input === undefined)
|
|
90
|
+
return undefined;
|
|
91
|
+
const direct = headerValue(input, cookieName);
|
|
92
|
+
if (direct !== undefined)
|
|
93
|
+
return direct;
|
|
94
|
+
const cookieHeader = headerValue(input, "cookie");
|
|
95
|
+
return cookieHeader ? rawCookieFromHeader(cookieHeader, cookieName) : undefined;
|
|
96
|
+
}
|
|
97
|
+
function readHeaderRaw(input) {
|
|
98
|
+
if (typeof input === "string" || input === null || input === undefined)
|
|
99
|
+
return undefined;
|
|
100
|
+
return headerValue(input, THEME_HEADER_NAME);
|
|
101
|
+
}
|
|
102
|
+
function hasUsableTheme(value, registry) {
|
|
103
|
+
if (typeof value.skin === "string" && registry.has(value.skin))
|
|
104
|
+
return true;
|
|
105
|
+
// legacy bare mode (e.g., "dark" without skin) — treat as unusable so default applies
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
function normalize(value, registry) {
|
|
109
|
+
const skinId = typeof value.skin === "string" && registry.has(value.skin)
|
|
110
|
+
? value.skin
|
|
111
|
+
: registry.defaultSkinId;
|
|
112
|
+
const metadata = registry.resolve(skinId);
|
|
113
|
+
const rawMode = value.mode ?? value.theme;
|
|
114
|
+
const mode = typeof rawMode === "string" && VALID_MODES.has(rawMode)
|
|
115
|
+
? rawMode
|
|
116
|
+
: metadata.defaultMode;
|
|
117
|
+
const density = typeof value.density === "string" && VALID_DENSITIES.has(value.density)
|
|
118
|
+
? value.density
|
|
119
|
+
: metadata.defaultDensity;
|
|
120
|
+
return { skin: metadata.id, theme_mode: mode, density };
|
|
121
|
+
}
|
|
122
|
+
function defaultState(registry) {
|
|
123
|
+
const fallback = registry.resolve(DEFAULT_SKIN_ID);
|
|
124
|
+
return {
|
|
125
|
+
skin: fallback.id,
|
|
126
|
+
theme_mode: fallback.defaultMode,
|
|
127
|
+
density: fallback.defaultDensity,
|
|
128
|
+
source: "default",
|
|
129
|
+
valid: false,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Resolve theme state from a cookie raw value, Cookie header, `Headers`,
|
|
134
|
+
* `x-mw-theme` header, or a plain header/cookie map.
|
|
135
|
+
*
|
|
136
|
+
* Precedence: mw-theme request data > x-mw-theme fallback > defaults.
|
|
137
|
+
*/
|
|
138
|
+
export function resolveSkin(input, options = {}) {
|
|
139
|
+
const registry = options.registry ?? themeRegistry;
|
|
140
|
+
const cookieName = options.cookieName ?? THEME_COOKIE_NAME;
|
|
141
|
+
const fromCookie = parseThemeValue(readThemeRaw(input, cookieName));
|
|
142
|
+
if (hasUsableTheme(fromCookie, registry)) {
|
|
143
|
+
return { ...normalize(fromCookie, registry), source: "cookie", valid: true };
|
|
144
|
+
}
|
|
145
|
+
const fromHeader = parseThemeValue(readHeaderRaw(input));
|
|
146
|
+
if (hasUsableTheme(fromHeader, registry)) {
|
|
147
|
+
return { ...normalize(fromHeader, registry), source: "header", valid: true };
|
|
148
|
+
}
|
|
149
|
+
return defaultState(registry);
|
|
150
|
+
}
|
|
151
|
+
/** Serialize resolved state into the URL-safe mw-theme cookie value. */
|
|
152
|
+
export function serializeSkinCookie(state) {
|
|
153
|
+
return `skin=${encodeURIComponent(state.skin)};mode=${encodeURIComponent(state.theme_mode)};density=${encodeURIComponent(state.density)}`;
|
|
154
|
+
}
|
|
155
|
+
/** Parse a raw mw-theme cookie value without registry normalization. */
|
|
156
|
+
export function parseSkinCookie(value, registry) {
|
|
157
|
+
const parsed = parseThemeValue(value ?? undefined);
|
|
158
|
+
const result = {};
|
|
159
|
+
if (parsed.skin && (!registry || registry.has(parsed.skin)))
|
|
160
|
+
result.skin = parsed.skin;
|
|
161
|
+
const rawMode = parsed.mode ?? parsed.theme;
|
|
162
|
+
if (rawMode === "light" || rawMode === "dark")
|
|
163
|
+
result.theme_mode = rawMode;
|
|
164
|
+
if (parsed.density === "compact" || parsed.density === "comfortable") {
|
|
165
|
+
result.density = parsed.density;
|
|
166
|
+
}
|
|
167
|
+
return result;
|
|
168
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dev-only SSR theme mismatch fixture for the W1/T09 smoke gate.
|
|
3
|
+
*
|
|
4
|
+
* INV-009: Theme state is visible to server and client.
|
|
5
|
+
*
|
|
6
|
+
* This module is intentionally small and dependency-free so the same
|
|
7
|
+
* deterministic logic can be exercised by:
|
|
8
|
+
* - the Playwright smoke spec (browser console hydration detection), and
|
|
9
|
+
* - a Node self-check when this file is executed directly (bunx fallback).
|
|
10
|
+
*
|
|
11
|
+
* Do not suppress hydration warnings. The gate must fail closed.
|
|
12
|
+
*/
|
|
13
|
+
export declare const THEME_COOKIE_NAME = "mw-theme";
|
|
14
|
+
export declare const THEME_FIXTURES: readonly ["light", "dark"];
|
|
15
|
+
export type Theme = (typeof THEME_FIXTURES)[number];
|
|
16
|
+
export interface ThemeHtmlState {
|
|
17
|
+
theme: Theme;
|
|
18
|
+
attributes: Record<string, string>;
|
|
19
|
+
}
|
|
20
|
+
export interface HydrationCheck {
|
|
21
|
+
passed: boolean;
|
|
22
|
+
warning: string | null;
|
|
23
|
+
}
|
|
24
|
+
export interface SelfTestCheck {
|
|
25
|
+
name: string;
|
|
26
|
+
passed: boolean;
|
|
27
|
+
detail?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface SelfTestResult {
|
|
30
|
+
passed: boolean;
|
|
31
|
+
checks: SelfTestCheck[];
|
|
32
|
+
}
|
|
33
|
+
/** Deterministic theme resolution: unknown/empty cookies fall back to light. */
|
|
34
|
+
export declare function resolveTheme(cookieValue: string | undefined | null): Theme;
|
|
35
|
+
/** Deterministic server-side theme state derived from the request cookie. */
|
|
36
|
+
export declare function serverRender(cookieValue: string | undefined | null): ThemeHtmlState;
|
|
37
|
+
/** Client hydration attributes derived from the same cookie. */
|
|
38
|
+
export declare function clientHydrationAttributes(cookieValue: string | undefined | null): Record<string, string>;
|
|
39
|
+
/** Stable serialization used on both sides so comparison is deterministic. */
|
|
40
|
+
export declare function serializeHtmlAttributes(attributes: Record<string, string>): string;
|
|
41
|
+
/** Full deterministic <html> open tag for a fixture cookie. */
|
|
42
|
+
export declare function renderServerHtml(cookieValue: string | undefined | null): string;
|
|
43
|
+
/**
|
|
44
|
+
* Negative fixture: simulate a client that ignores the cookie and hydrates
|
|
45
|
+
* with the light default while the server rendered dark.
|
|
46
|
+
*/
|
|
47
|
+
export declare function mismatchedClientAttributes(_cookieValue: string | undefined | null): Record<string, string>;
|
|
48
|
+
/** True when a console message is a hydration warning. Fail closed on these. */
|
|
49
|
+
export declare function isHydrationWarning(message: string): boolean;
|
|
50
|
+
/** Gate predicate used by the smoke spec: any hydration warning fails. */
|
|
51
|
+
export declare function gateFailsOnWarnings(messages: string[]): boolean;
|
|
52
|
+
/** Compare server attributes with the attributes the client hydrates with. */
|
|
53
|
+
export declare function checkHydration(cookieValue: string | undefined | null, clientAttributes?: Record<string, string>): HydrationCheck;
|
|
54
|
+
/**
|
|
55
|
+
* Deterministic Node-side verification for the three T09 acceptance criteria.
|
|
56
|
+
* Used when the bun/bunx shim is unavailable.
|
|
57
|
+
*/
|
|
58
|
+
export declare function runSelfTest(): SelfTestResult;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dev-only SSR theme mismatch fixture for the W1/T09 smoke gate.
|
|
3
|
+
*
|
|
4
|
+
* INV-009: Theme state is visible to server and client.
|
|
5
|
+
*
|
|
6
|
+
* This module is intentionally small and dependency-free so the same
|
|
7
|
+
* deterministic logic can be exercised by:
|
|
8
|
+
* - the Playwright smoke spec (browser console hydration detection), and
|
|
9
|
+
* - a Node self-check when this file is executed directly (bunx fallback).
|
|
10
|
+
*
|
|
11
|
+
* Do not suppress hydration warnings. The gate must fail closed.
|
|
12
|
+
*/
|
|
13
|
+
export const THEME_COOKIE_NAME = "mw-theme";
|
|
14
|
+
export const THEME_FIXTURES = ["light", "dark"];
|
|
15
|
+
/** Deterministic theme resolution: unknown/empty cookies fall back to light. */
|
|
16
|
+
export function resolveTheme(cookieValue) {
|
|
17
|
+
return cookieValue === "dark" ? "dark" : "light";
|
|
18
|
+
}
|
|
19
|
+
/** Deterministic server-side theme state derived from the request cookie. */
|
|
20
|
+
export function serverRender(cookieValue) {
|
|
21
|
+
const theme = resolveTheme(cookieValue);
|
|
22
|
+
return {
|
|
23
|
+
theme,
|
|
24
|
+
attributes: {
|
|
25
|
+
"data-theme": theme,
|
|
26
|
+
class: `theme-${theme}`,
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/** Client hydration attributes derived from the same cookie. */
|
|
31
|
+
export function clientHydrationAttributes(cookieValue) {
|
|
32
|
+
const theme = resolveTheme(cookieValue);
|
|
33
|
+
return {
|
|
34
|
+
"data-theme": theme,
|
|
35
|
+
class: `theme-${theme}`,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/** Stable serialization used on both sides so comparison is deterministic. */
|
|
39
|
+
export function serializeHtmlAttributes(attributes) {
|
|
40
|
+
return Object.keys(attributes)
|
|
41
|
+
.sort()
|
|
42
|
+
.map((key) => `${key}="${attributes[key]}"`)
|
|
43
|
+
.join(" ");
|
|
44
|
+
}
|
|
45
|
+
/** Full deterministic <html> open tag for a fixture cookie. */
|
|
46
|
+
export function renderServerHtml(cookieValue) {
|
|
47
|
+
return `<html ${serializeHtmlAttributes(serverRender(cookieValue).attributes)}>`;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Negative fixture: simulate a client that ignores the cookie and hydrates
|
|
51
|
+
* with the light default while the server rendered dark.
|
|
52
|
+
*/
|
|
53
|
+
export function mismatchedClientAttributes(_cookieValue) {
|
|
54
|
+
// Simulate a client that ignores the cookie and always hydrates light.
|
|
55
|
+
return {
|
|
56
|
+
"data-theme": "light",
|
|
57
|
+
class: "theme-light",
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/** True when a console message is a hydration warning. Fail closed on these. */
|
|
61
|
+
export function isHydrationWarning(message) {
|
|
62
|
+
return /hydrat|did not match|text content does not match|server rendered html/i.test(message);
|
|
63
|
+
}
|
|
64
|
+
/** Gate predicate used by the smoke spec: any hydration warning fails. */
|
|
65
|
+
export function gateFailsOnWarnings(messages) {
|
|
66
|
+
return messages.some(isHydrationWarning);
|
|
67
|
+
}
|
|
68
|
+
/** Compare server attributes with the attributes the client hydrates with. */
|
|
69
|
+
export function checkHydration(cookieValue, clientAttributes = clientHydrationAttributes(cookieValue)) {
|
|
70
|
+
const server = serializeHtmlAttributes(serverRender(cookieValue).attributes);
|
|
71
|
+
const client = serializeHtmlAttributes(clientAttributes);
|
|
72
|
+
if (server !== client) {
|
|
73
|
+
return {
|
|
74
|
+
passed: false,
|
|
75
|
+
warning: `Hydration attribute mismatch: server="${server}" client="${client}"`,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
return { passed: true, warning: null };
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Deterministic Node-side verification for the three T09 acceptance criteria.
|
|
82
|
+
* Used when the bun/bunx shim is unavailable.
|
|
83
|
+
*/
|
|
84
|
+
export function runSelfTest() {
|
|
85
|
+
const checks = [];
|
|
86
|
+
// AC2: server html attribute equals client html attribute for fixture cookie.
|
|
87
|
+
for (const cookie of THEME_FIXTURES) {
|
|
88
|
+
const result = checkHydration(cookie);
|
|
89
|
+
checks.push({
|
|
90
|
+
name: `server/client attribute parity for cookie=${cookie}`,
|
|
91
|
+
passed: result.passed,
|
|
92
|
+
detail: result.warning ?? undefined,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
// AC3: two cookie values produce two deterministic server renders.
|
|
96
|
+
for (const cookie of THEME_FIXTURES) {
|
|
97
|
+
const first = renderServerHtml(cookie);
|
|
98
|
+
const second = renderServerHtml(cookie);
|
|
99
|
+
checks.push({
|
|
100
|
+
name: `deterministic server render for cookie=${cookie}`,
|
|
101
|
+
passed: first === second,
|
|
102
|
+
detail: first === second ? undefined : `"${first}" !== "${second}"`,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
const lightHtml = renderServerHtml("light");
|
|
106
|
+
const darkHtml = renderServerHtml("dark");
|
|
107
|
+
checks.push({
|
|
108
|
+
name: "two cookie values produce distinct server renders",
|
|
109
|
+
passed: lightHtml !== darkHtml,
|
|
110
|
+
detail: lightHtml !== darkHtml ? undefined : `${lightHtml} === ${darkHtml}`,
|
|
111
|
+
});
|
|
112
|
+
// AC1: hydration warning fails the test (negative control).
|
|
113
|
+
const negative = checkHydration("dark", mismatchedClientAttributes("dark"));
|
|
114
|
+
const warningDetected = negative.passed === false && isHydrationWarning(negative.warning ?? "");
|
|
115
|
+
const gateFails = gateFailsOnWarnings([negative.warning ?? ""]);
|
|
116
|
+
checks.push({
|
|
117
|
+
name: "hydration warning fails the gate",
|
|
118
|
+
passed: warningDetected && gateFails,
|
|
119
|
+
detail: negative.warning ?? undefined,
|
|
120
|
+
});
|
|
121
|
+
return {
|
|
122
|
+
passed: checks.every((check) => check.passed),
|
|
123
|
+
checks,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
// Direct-run CLI fallback (Node 24 can execute .ts directly).
|
|
127
|
+
if (typeof process !== "undefined" && process.argv?.[1]?.endsWith("theme-mismatch-dev.ts")) {
|
|
128
|
+
const result = runSelfTest();
|
|
129
|
+
console.log(JSON.stringify(result, null, 2));
|
|
130
|
+
if (!result.passed) {
|
|
131
|
+
process.exitCode = 1;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/* Generated by @moonwitness/ui build — Tailwind v4 @theme preset */
|
|
2
|
+
@theme {
|
|
3
|
+
--color-mw-paper-cream: var(--mw-paper-cream);
|
|
4
|
+
--color-mw-ink-black: var(--mw-ink-black);
|
|
5
|
+
--color-mw-ink-panel: var(--mw-ink-panel);
|
|
6
|
+
--color-mw-paper: var(--mw-paper);
|
|
7
|
+
--color-mw-paper-raised: var(--mw-paper-raised);
|
|
8
|
+
--color-mw-ink: var(--mw-ink);
|
|
9
|
+
--color-mw-ink-soft: var(--mw-ink-soft);
|
|
10
|
+
--color-mw-ink-faint: var(--mw-ink-faint);
|
|
11
|
+
--color-mw-color-ink-muted: var(--mw-color-ink-muted);
|
|
12
|
+
--color-mw-signal-blue: var(--mw-signal-blue);
|
|
13
|
+
--color-mw-cyan: var(--mw-cyan);
|
|
14
|
+
--color-mw-night: var(--mw-night);
|
|
15
|
+
--color-mw-night-soft: var(--mw-night-soft);
|
|
16
|
+
--color-mw-night-raised: var(--mw-night-raised);
|
|
17
|
+
--color-mw-night-blue: var(--mw-night-blue);
|
|
18
|
+
--color-mw-night-magenta: var(--mw-night-magenta);
|
|
19
|
+
--color-mw-night-outline: var(--mw-night-outline);
|
|
20
|
+
--color-mw-paper-highlight: var(--mw-paper-highlight);
|
|
21
|
+
--color-mw-paper-muted: var(--mw-paper-muted);
|
|
22
|
+
--color-mw-moon: var(--mw-moon);
|
|
23
|
+
--color-mw-yellow: var(--mw-yellow);
|
|
24
|
+
--color-mw-magenta: var(--mw-magenta);
|
|
25
|
+
--color-mw-violet: var(--mw-violet);
|
|
26
|
+
--color-mw-yellow-readable: var(--mw-yellow-readable);
|
|
27
|
+
--color-mw-magenta-readable: var(--mw-magenta-readable);
|
|
28
|
+
--color-mw-cyan-readable: var(--mw-cyan-readable);
|
|
29
|
+
--color-mw-violet-readable: var(--mw-violet-readable);
|
|
30
|
+
--color-mw-on-accent: var(--mw-on-accent);
|
|
31
|
+
--color-mw-on-magenta: var(--mw-on-magenta);
|
|
32
|
+
--color-mw-on-violet: var(--mw-on-violet);
|
|
33
|
+
--color-mw-halftone-dot: var(--mw-halftone-dot);
|
|
34
|
+
--color-mw-highlight: var(--mw-highlight);
|
|
35
|
+
--color-mw-background: var(--mw-background);
|
|
36
|
+
--color-mw-foreground: var(--mw-foreground);
|
|
37
|
+
--color-mw-surface: var(--mw-surface);
|
|
38
|
+
--color-mw-surface-foreground: var(--mw-surface-foreground);
|
|
39
|
+
--color-mw-popover: var(--mw-popover);
|
|
40
|
+
--color-mw-popover-foreground: var(--mw-popover-foreground);
|
|
41
|
+
--color-mw-primary: var(--mw-primary);
|
|
42
|
+
--color-mw-primary-foreground: var(--mw-primary-foreground);
|
|
43
|
+
--color-mw-secondary: var(--mw-secondary);
|
|
44
|
+
--color-mw-secondary-foreground: var(--mw-secondary-foreground);
|
|
45
|
+
--color-mw-muted: var(--mw-muted);
|
|
46
|
+
--color-mw-muted-foreground: var(--mw-muted-foreground);
|
|
47
|
+
--color-mw-accent: var(--mw-accent);
|
|
48
|
+
--color-mw-accent-foreground: var(--mw-accent-foreground);
|
|
49
|
+
--color-mw-interactive-accent: var(--mw-interactive-accent);
|
|
50
|
+
--color-mw-error: var(--mw-error);
|
|
51
|
+
--color-mw-on-error: var(--mw-on-error);
|
|
52
|
+
--color-mw-destructive: var(--mw-destructive);
|
|
53
|
+
--color-mw-destructive-foreground: var(--mw-destructive-foreground);
|
|
54
|
+
--color-mw-border: var(--mw-border);
|
|
55
|
+
--color-mw-border-strong: var(--mw-border-strong);
|
|
56
|
+
--color-mw-border-subtle: var(--mw-border-subtle);
|
|
57
|
+
--color-mw-input: var(--mw-input);
|
|
58
|
+
--color-mw-focus: var(--mw-focus);
|
|
59
|
+
--color-mw-backdrop: var(--mw-backdrop);
|
|
60
|
+
--color-mw-success: var(--mw-success);
|
|
61
|
+
--color-mw-on-success: var(--mw-on-success);
|
|
62
|
+
--color-mw-warning: var(--mw-warning);
|
|
63
|
+
--color-mw-on-warning: var(--mw-on-warning);
|
|
64
|
+
--color-mw-warning-readable: var(--mw-warning-readable);
|
|
65
|
+
--color-mw-success-readable: var(--mw-success-readable);
|
|
66
|
+
--color-mw-info: var(--mw-info);
|
|
67
|
+
--color-mw-on-info: var(--mw-on-info);
|
|
68
|
+
--color-mw-chart-1: var(--mw-chart-1);
|
|
69
|
+
--color-mw-chart-2: var(--mw-chart-2);
|
|
70
|
+
--color-mw-chart-3: var(--mw-chart-3);
|
|
71
|
+
--color-mw-chart-4: var(--mw-chart-4);
|
|
72
|
+
--color-mw-chart-5: var(--mw-chart-5);
|
|
73
|
+
--color-mw-brand-crimson: var(--mw-brand-crimson);
|
|
74
|
+
--color-mw-signal-crimson: var(--mw-signal-crimson);
|
|
75
|
+
--color-mw-dna-cel-highlight: var(--mw-dna-cel-highlight);
|
|
76
|
+
--color-mw-anime-skin: var(--mw-anime-skin);
|
|
77
|
+
--color-mw-anime-skin-shade: var(--mw-anime-skin-shade);
|
|
78
|
+
--color-mw-anime-skin-highlight: var(--mw-anime-skin-highlight);
|
|
79
|
+
--color-mw-surface-muted: var(--mw-surface-muted);
|
|
80
|
+
--color-mw-surface-elevated: var(--mw-surface-elevated);
|
|
81
|
+
--color-mw-error-readable: var(--mw-error-readable);
|
|
82
|
+
--color-mw-anime-ink: var(--mw-anime-ink);
|
|
83
|
+
--color-mw-anime-face: var(--mw-anime-face);
|
|
84
|
+
--color-mw-anime-highlight: var(--mw-anime-highlight);
|
|
85
|
+
--color-mw-fx-flash: var(--mw-fx-flash);
|
|
86
|
+
--spacing-mw-avatar-size: var(--mw-avatar-size);
|
|
87
|
+
--spacing-mw-space-1: var(--mw-space-1);
|
|
88
|
+
--spacing-mw-space-2: var(--mw-space-2);
|
|
89
|
+
--spacing-mw-space-3: var(--mw-space-3);
|
|
90
|
+
--spacing-mw-space-4: var(--mw-space-4);
|
|
91
|
+
--spacing-mw-space-6: var(--mw-space-6);
|
|
92
|
+
--spacing-mw-space-8: var(--mw-space-8);
|
|
93
|
+
--spacing-mw-panel-gap-compact: var(--mw-panel-gap-compact);
|
|
94
|
+
--spacing-mw-panel-gap-comfortable: var(--mw-panel-gap-comfortable);
|
|
95
|
+
--spacing-mw-panel-padding-compact: var(--mw-panel-padding-compact);
|
|
96
|
+
--spacing-mw-panel-padding-comfortable: var(--mw-panel-padding-comfortable);
|
|
97
|
+
--spacing-mw-frame-width: var(--mw-frame-width);
|
|
98
|
+
--spacing-mw-torn-safe-inset: var(--mw-torn-safe-inset);
|
|
99
|
+
--spacing-mw-comic-border-width: var(--mw-comic-border-width);
|
|
100
|
+
--spacing-mw-comic-gutter: var(--mw-comic-gutter);
|
|
101
|
+
--spacing-mw-dna-border-heavy: var(--mw-dna-border-heavy);
|
|
102
|
+
--spacing-mw-space-5: var(--mw-space-5);
|
|
103
|
+
--radius-mw-radius-xs: var(--mw-radius-xs);
|
|
104
|
+
--radius-mw-radius-sm: var(--mw-radius-sm);
|
|
105
|
+
--radius-mw-radius-md: var(--mw-radius-md);
|
|
106
|
+
--radius-mw-radius-lg: var(--mw-radius-lg);
|
|
107
|
+
--radius-mw-radius-full: var(--mw-radius-full);
|
|
108
|
+
--radius-mw-grunge-radius-hand: var(--mw-grunge-radius-hand);
|
|
109
|
+
}
|