@moonwitness/ui 7.3.1 → 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/package.json +2 -3
- package/scripts/consumer-smoke.mjs +0 -45
- package/scripts/generate-icons.mjs +0 -110
- package/scripts/generate-token-artifacts.mjs +0 -90
- package/scripts/icon-svg-to-jsx.mjs +0 -249
- package/scripts/verification-diagnostics.mjs +0 -40
- package/scripts/verify-package.mjs +0 -412
- package/src/cartoon/anime-avatar.tsx +0 -628
- package/src/cartoon/anime-stage.tsx +0 -458
- package/src/cartoon/index.tsx +0 -542
- package/src/cartoon.tsx +0 -645
- package/src/characters.ts +0 -625
- package/src/components/accordion.tsx +0 -77
- package/src/components/alert.tsx +0 -139
- package/src/components/appearance-menu.tsx +0 -181
- package/src/components/artwork-frame.tsx +0 -49
- package/src/components/audio.tsx +0 -97
- package/src/components/avatar.tsx +0 -75
- package/src/components/badge.tsx +0 -94
- package/src/components/brand-mark.tsx +0 -73
- package/src/components/breadcrumbs.tsx +0 -98
- package/src/components/button.tsx +0 -340
- package/src/components/card.tsx +0 -171
- package/src/components/character-badge.tsx +0 -58
- package/src/components/character-preview.tsx +0 -104
- package/src/components/character-stage.tsx +0 -225
- package/src/components/chart.tsx +0 -481
- package/src/components/checkbox.tsx +0 -64
- package/src/components/comic-panel.tsx +0 -301
- package/src/components/comic-theater.tsx +0 -170
- package/src/components/command.tsx +0 -189
- package/src/components/confirm-dialog.tsx +0 -129
- package/src/components/copy-button.tsx +0 -62
- package/src/components/date-picker.tsx +0 -126
- package/src/components/dialog.tsx +0 -164
- package/src/components/dna-icon.tsx +0 -77
- package/src/components/dropdown-menu.tsx +0 -87
- package/src/components/effects.tsx +0 -1021
- package/src/components/empty-state.tsx +0 -93
- package/src/components/epistemic-branch-panel.tsx +0 -101
- package/src/components/error-state.tsx +0 -137
- package/src/components/field.tsx +0 -96
- package/src/components/filter-facet-bar.tsx +0 -91
- package/src/components/inbox-popover.tsx +0 -146
- package/src/components/input.tsx +0 -25
- package/src/components/kanban-board.tsx +0 -190
- package/src/components/label.tsx +0 -19
- package/src/components/layered-scene.tsx +0 -555
- package/src/components/log-console.tsx +0 -261
- package/src/components/metric-tile.tsx +0 -99
- package/src/components/mode-picker.tsx +0 -149
- package/src/components/motion-timeline.tsx +0 -848
- package/src/components/number-input.tsx +0 -104
- package/src/components/page-header.tsx +0 -123
- package/src/components/pagination.tsx +0 -83
- package/src/components/panel.tsx +0 -121
- package/src/components/paper-note.tsx +0 -77
- package/src/components/popover.tsx +0 -72
- package/src/components/progress.tsx +0 -127
- package/src/components/quest-card.tsx +0 -319
- package/src/components/radio-group.tsx +0 -50
- package/src/components/riot-sticker.tsx +0 -151
- package/src/components/scene-particles.tsx +0 -196
- package/src/components/scene-transitions.tsx +0 -130
- package/src/components/section-ribbon.tsx +0 -94
- package/src/components/select-field.tsx +0 -27
- package/src/components/select.tsx +0 -81
- package/src/components/separator.tsx +0 -58
- package/src/components/sheet.tsx +0 -96
- package/src/components/skeleton.tsx +0 -35
- package/src/components/sketch-annotation.tsx +0 -87
- package/src/components/smart-button-box.tsx +0 -114
- package/src/components/speech-bubble.tsx +0 -116
- package/src/components/spinner.tsx +0 -69
- package/src/components/sprite-player.tsx +0 -412
- package/src/components/status-bar.tsx +0 -63
- package/src/components/status-pill.tsx +0 -68
- package/src/components/switch.tsx +0 -76
- package/src/components/table.tsx +0 -163
- package/src/components/tabs.tsx +0 -101
- package/src/components/tag-input.tsx +0 -170
- package/src/components/textarea.tsx +0 -25
- package/src/components/toast.tsx +0 -14
- package/src/components/toolbar.tsx +0 -39
- package/src/components/tooltip.tsx +0 -49
- package/src/components/update-banner.tsx +0 -220
- package/src/components/xv-primitives.tsx +0 -256
- package/src/css-exports.ts +0 -142
- package/src/dna.tsx +0 -137
- package/src/game/boss-hud.tsx +0 -384
- package/src/game/index.tsx +0 -886
- package/src/game/tactical.tsx +0 -245
- package/src/game.tsx +0 -770
- package/src/icons/activity.tsx +0 -38
- package/src/icons/add.tsx +0 -38
- package/src/icons/addon.tsx +0 -37
- package/src/icons/anime-anger.tsx +0 -37
- package/src/icons/anime-shock.tsx +0 -37
- package/src/icons/anime-sparkle.tsx +0 -38
- package/src/icons/anime-sweatdrop.tsx +0 -38
- package/src/icons/archive.tsx +0 -37
- package/src/icons/arrow-left.tsx +0 -37
- package/src/icons/arrow-right.tsx +0 -37
- package/src/icons/attachment.tsx +0 -38
- package/src/icons/bank.tsx +0 -37
- package/src/icons/bolt.tsx +0 -37
- package/src/icons/book-open.tsx +0 -37
- package/src/icons/bookmark.tsx +0 -37
- package/src/icons/boss-skull.tsx +0 -40
- package/src/icons/calendar-clock.tsx +0 -40
- package/src/icons/calendar.tsx +0 -38
- package/src/icons/check-circle.tsx +0 -38
- package/src/icons/check-square.tsx +0 -38
- package/src/icons/check.tsx +0 -37
- package/src/icons/chevron-right.tsx +0 -37
- package/src/icons/chevrons-left.tsx +0 -37
- package/src/icons/chevrons-right.tsx +0 -37
- package/src/icons/clapperboard.tsx +0 -38
- package/src/icons/clock.tsx +0 -38
- package/src/icons/close.tsx +0 -37
- package/src/icons/code.tsx +0 -37
- package/src/icons/columns.tsx +0 -38
- package/src/icons/combo-flame.tsx +0 -38
- package/src/icons/company.tsx +0 -38
- package/src/icons/credit-card.tsx +0 -38
- package/src/icons/critical-star.tsx +0 -37
- package/src/icons/currency.tsx +0 -38
- package/src/icons/delete.tsx +0 -37
- package/src/icons/document.tsx +0 -38
- package/src/icons/download.tsx +0 -37
- package/src/icons/dpad.tsx +0 -38
- package/src/icons/edit.tsx +0 -38
- package/src/icons/element-fire.tsx +0 -37
- package/src/icons/element-ice.tsx +0 -38
- package/src/icons/element-solar.tsx +0 -38
- package/src/icons/element-void.tsx +0 -38
- package/src/icons/element-volt.tsx +0 -38
- package/src/icons/element-wind.tsx +0 -37
- package/src/icons/error.tsx +0 -38
- package/src/icons/external-link.tsx +0 -38
- package/src/icons/field.tsx +0 -38
- package/src/icons/file-spreadsheet.tsx +0 -38
- package/src/icons/filter.tsx +0 -37
- package/src/icons/gacha-ticket.tsx +0 -38
- package/src/icons/gamepad.tsx +0 -40
- package/src/icons/globe.tsx +0 -38
- package/src/icons/grid.tsx +0 -40
- package/src/icons/hash.tsx +0 -37
- package/src/icons/heart-hp.tsx +0 -38
- package/src/icons/history.tsx +0 -37
- package/src/icons/home.tsx +0 -37
- package/src/icons/image.tsx +0 -39
- package/src/icons/impact-slash.tsx +0 -38
- package/src/icons/inbox.tsx +0 -38
- package/src/icons/index.ts +0 -120
- package/src/icons/info.tsx +0 -38
- package/src/icons/jobs.tsx +0 -38
- package/src/icons/katana.tsx +0 -38
- package/src/icons/key.tsx +0 -38
- package/src/icons/keyboard.tsx +0 -38
- package/src/icons/keyframe-diamond.tsx +0 -38
- package/src/icons/knowledge.tsx +0 -38
- package/src/icons/language.tsx +0 -39
- package/src/icons/lock.tsx +0 -38
- package/src/icons/logout.tsx +0 -37
- package/src/icons/loot-chest.tsx +0 -39
- package/src/icons/mail.tsx +0 -38
- package/src/icons/mana-crystal.tsx +0 -38
- package/src/icons/map-pin.tsx +0 -38
- package/src/icons/mecha-helm.tsx +0 -38
- package/src/icons/menu.tsx +0 -37
- package/src/icons/message.tsx +0 -38
- package/src/icons/model.tsx +0 -38
- package/src/icons/moon.tsx +0 -37
- package/src/icons/notification.tsx +0 -38
- package/src/icons/partner.tsx +0 -41
- package/src/icons/pause.tsx +0 -37
- package/src/icons/phone.tsx +0 -37
- package/src/icons/play.tsx +0 -37
- package/src/icons/potion-flask.tsx +0 -40
- package/src/icons/quest-scroll.tsx +0 -39
- package/src/icons/radar-ping.tsx +0 -40
- package/src/icons/refresh.tsx +0 -38
- package/src/icons/relation.tsx +0 -40
- package/src/icons/save.tsx +0 -38
- package/src/icons/search.tsx +0 -38
- package/src/icons/security.tsx +0 -38
- package/src/icons/send.tsx +0 -38
- package/src/icons/settings.tsx +0 -39
- package/src/icons/shield-crest.tsx +0 -38
- package/src/icons/shuriken.tsx +0 -38
- package/src/icons/signal-off.tsx +0 -37
- package/src/icons/signal.tsx +0 -37
- package/src/icons/skill-node.tsx +0 -40
- package/src/icons/smartphone.tsx +0 -38
- package/src/icons/sort-ascending.tsx +0 -37
- package/src/icons/sort-descending.tsx +0 -37
- package/src/icons/sort.tsx +0 -37
- package/src/icons/sparkle.tsx +0 -38
- package/src/icons/speech-burst.tsx +0 -37
- package/src/icons/story.tsx +0 -37
- package/src/icons/sun.tsx +0 -38
- package/src/icons/tag.tsx +0 -38
- package/src/icons/team.tsx +0 -40
- package/src/icons/trophy-crown.tsx +0 -39
- package/src/icons/upload.tsx +0 -37
- package/src/icons/user.tsx +0 -38
- package/src/icons/users.tsx +0 -39
- package/src/icons/visibility-off.tsx +0 -38
- package/src/icons/visibility.tsx +0 -38
- package/src/icons/volume-off.tsx +0 -37
- package/src/icons/volume.tsx +0 -37
- package/src/icons/warning.tsx +0 -38
- package/src/icons/workflow.tsx +0 -40
- package/src/icons.tsx +0 -965
- package/src/index.ts +0 -89
- package/src/lib/asset-registry.ts +0 -534
- package/src/lib/audio-runtime.ts +0 -314
- package/src/lib/character-adapter.ts +0 -370
- package/src/lib/character-registry.ts +0 -2368
- package/src/lib/cn.ts +0 -6
- package/src/lib/compose-refs.ts +0 -16
- package/src/lib/sanitize-url.ts +0 -51
- package/src/lib/scene-camera.ts +0 -483
- package/src/lib/scene-playback.ts +0 -622
- package/src/lib/scene-soundscape.ts +0 -151
- package/src/lib/scene-test-harness.ts +0 -200
- package/src/lib/scene-timeline.ts +0 -398
- package/src/lib/use-animation-visibility.ts +0 -45
- package/src/lib/use-modal-focus.ts +0 -270
- package/src/lib/use-reduced-motion.ts +0 -37
- package/src/motion/easing-presets.ts +0 -262
- package/src/motion/index.tsx +0 -894
- package/src/motion/physics.ts +0 -259
- package/src/motion/timeline-math.ts +0 -358
- package/src/motion.tsx +0 -639
- package/src/pixelfx-boundary.ts +0 -188
- package/src/pixelfx-registry.ts +0 -1190
- package/src/pixelfx-types.d.ts +0 -73
- package/src/pixelfx.tsx +0 -1022
- package/src/provider.tsx +0 -63
- package/src/skin-catalog.ts +0 -306
- package/src/skin-tokens.ts +0 -425
- package/src/ssr/init-script.ts +0 -281
- package/src/ssr/resolve-skin.ts +0 -217
- package/src/ssr/theme-mismatch-dev.ts +0 -181
- package/src/templates/battle-arena.tsx +0 -688
- package/src/templates/index.tsx +0 -314
- package/src/templates.tsx +0 -225
- package/src/themes/dna-presets.ts +0 -119
- package/src/themes/index.ts +0 -56
- package/src/themes/provider.tsx +0 -183
- package/src/themes/types.ts +0 -111
- package/src/themes.ts +0 -9
- package/src/token-exporter.ts +0 -12
- package/src/token-exporters.ts +0 -343
- package/src/token-seeds.ts +0 -335
- package/src/token-snapshot.ts +0 -179
- package/src/utils.ts +0 -58
package/src/motion.tsx
DELETED
|
@@ -1,639 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createContext,
|
|
3
|
-
useContext,
|
|
4
|
-
useEffect,
|
|
5
|
-
useMemo,
|
|
6
|
-
useState,
|
|
7
|
-
type CSSProperties,
|
|
8
|
-
type ReactNode,
|
|
9
|
-
} from "react";
|
|
10
|
-
import { Button } from "./components/button.js";
|
|
11
|
-
import { Badge } from "./components/badge.js";
|
|
12
|
-
|
|
13
|
-
export type MotionProfile = "off" | "subtle" | "expressive" | "cartoon";
|
|
14
|
-
|
|
15
|
-
export const MOTION_EASING_NAMES = [
|
|
16
|
-
"linear",
|
|
17
|
-
"ease-out",
|
|
18
|
-
"ease-in-out",
|
|
19
|
-
"expo-out",
|
|
20
|
-
"overshoot",
|
|
21
|
-
"anticipation",
|
|
22
|
-
"spring",
|
|
23
|
-
"elastic",
|
|
24
|
-
"bounce",
|
|
25
|
-
"steps-8",
|
|
26
|
-
"steps-12",
|
|
27
|
-
"steps-24",
|
|
28
|
-
] as const;
|
|
29
|
-
|
|
30
|
-
export type MotionEasingName = (typeof MOTION_EASING_NAMES)[number];
|
|
31
|
-
|
|
32
|
-
export type MotionEasingPreset = {
|
|
33
|
-
readonly id: MotionEasingName;
|
|
34
|
-
readonly label: string;
|
|
35
|
-
readonly category: "standard" | "physics" | "cel";
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export const MOTION_EASING_PRESETS: readonly MotionEasingPreset[] = [
|
|
39
|
-
{ id: "linear", label: "Linear", category: "standard" },
|
|
40
|
-
{ id: "ease-out", label: "Ease Out", category: "standard" },
|
|
41
|
-
{ id: "ease-in-out", label: "Ease In-Out", category: "standard" },
|
|
42
|
-
{ id: "expo-out", label: "Expo Out", category: "standard" },
|
|
43
|
-
{ id: "overshoot", label: "Back Overshoot", category: "physics" },
|
|
44
|
-
{ id: "anticipation", label: "Anticipation", category: "physics" },
|
|
45
|
-
{ id: "spring", label: "Spring", category: "physics" },
|
|
46
|
-
{ id: "elastic", label: "Elastic", category: "physics" },
|
|
47
|
-
{ id: "bounce", label: "Bounce", category: "physics" },
|
|
48
|
-
{ id: "steps-8", label: "8fps Cel", category: "cel" },
|
|
49
|
-
{ id: "steps-12", label: "12fps Cel", category: "cel" },
|
|
50
|
-
{ id: "steps-24", label: "24fps Cel", category: "cel" },
|
|
51
|
-
];
|
|
52
|
-
|
|
53
|
-
export type MotionTimelineKeyframe = {
|
|
54
|
-
readonly id: string;
|
|
55
|
-
readonly label: string;
|
|
56
|
-
readonly at: number;
|
|
57
|
-
readonly value: number;
|
|
58
|
-
readonly easing?: MotionEasingName;
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
export const DEFAULT_MOTION_TIMELINE_KEYFRAMES: readonly MotionTimelineKeyframe[] = [
|
|
62
|
-
{ id: "kf-0", label: "Anticipate", at: 0, value: 0.08, easing: "anticipation" },
|
|
63
|
-
{ id: "kf-1", label: "Launch", at: 0.35, value: 1.0, easing: "overshoot" },
|
|
64
|
-
{ id: "kf-2", label: "Settle", at: 0.72, value: 0.84, easing: "spring" },
|
|
65
|
-
{ id: "kf-3", label: "Rest", at: 1.0, value: 0.88, easing: "ease-out" },
|
|
66
|
-
];
|
|
67
|
-
|
|
68
|
-
export type ProceduralSfxPreset =
|
|
69
|
-
| "click-soft"
|
|
70
|
-
| "toggle-pop"
|
|
71
|
-
| "success-chime"
|
|
72
|
-
| "hit-impact"
|
|
73
|
-
| "boing"
|
|
74
|
-
| "cut-in-slash"
|
|
75
|
-
| "level-up"
|
|
76
|
-
| "gacha-sparkle"
|
|
77
|
-
| "gacha-fanfare";
|
|
78
|
-
|
|
79
|
-
export type ScreenFXKind =
|
|
80
|
-
| "speedlines-burst"
|
|
81
|
-
| "flash"
|
|
82
|
-
| "chromatic-pulse"
|
|
83
|
-
| "vignette"
|
|
84
|
-
| "vignette-impact";
|
|
85
|
-
|
|
86
|
-
export function evaluateEasing(
|
|
87
|
-
rawT: number,
|
|
88
|
-
name: MotionEasingName = "ease-out",
|
|
89
|
-
): number {
|
|
90
|
-
const t = Math.max(0, Math.min(1, rawT));
|
|
91
|
-
switch (name) {
|
|
92
|
-
case "linear":
|
|
93
|
-
return t;
|
|
94
|
-
case "ease-out":
|
|
95
|
-
return 1 - Math.pow(1 - t, 3);
|
|
96
|
-
case "ease-in-out":
|
|
97
|
-
return t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2;
|
|
98
|
-
case "expo-out":
|
|
99
|
-
return t === 1 ? 1 : 1 - Math.pow(2, -10 * t);
|
|
100
|
-
case "overshoot": {
|
|
101
|
-
const c1 = 1.70158;
|
|
102
|
-
const c3 = c1 + 1;
|
|
103
|
-
return 1 + c3 * Math.pow(t - 1, 3) + c1 * Math.pow(t - 1, 2);
|
|
104
|
-
}
|
|
105
|
-
case "anticipation": {
|
|
106
|
-
const c1 = 1.70158;
|
|
107
|
-
const c3 = c1 + 1;
|
|
108
|
-
return c3 * t * t * t - c1 * t * t;
|
|
109
|
-
}
|
|
110
|
-
case "spring":
|
|
111
|
-
return 1 - Math.exp(-6 * t) * Math.cos(12 * t);
|
|
112
|
-
case "elastic": {
|
|
113
|
-
if (t === 0 || t === 1) return t;
|
|
114
|
-
return (
|
|
115
|
-
Math.pow(2, -10 * t) * Math.sin(((t * 10 - 0.75) * (2 * Math.PI)) / 3) +
|
|
116
|
-
1
|
|
117
|
-
);
|
|
118
|
-
}
|
|
119
|
-
case "bounce": {
|
|
120
|
-
const n1 = 7.5625;
|
|
121
|
-
const d1 = 2.75;
|
|
122
|
-
if (t < 1 / d1) return n1 * t * t;
|
|
123
|
-
if (t < 2 / d1) {
|
|
124
|
-
const u = t - 1.5 / d1;
|
|
125
|
-
return n1 * u * u + 0.75;
|
|
126
|
-
}
|
|
127
|
-
if (t < 2.5 / d1) {
|
|
128
|
-
const u = t - 2.25 / d1;
|
|
129
|
-
return n1 * u * u + 0.9375;
|
|
130
|
-
}
|
|
131
|
-
const u = t - 2.625 / d1;
|
|
132
|
-
return n1 * u * u + 0.984375;
|
|
133
|
-
}
|
|
134
|
-
case "steps-8":
|
|
135
|
-
return Math.floor(t * 8) / 8;
|
|
136
|
-
case "steps-12":
|
|
137
|
-
return Math.floor(t * 12) / 12;
|
|
138
|
-
case "steps-24":
|
|
139
|
-
return Math.floor(t * 24) / 24;
|
|
140
|
-
default:
|
|
141
|
-
return t;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
export function sampleEasingCurve(
|
|
146
|
-
name: MotionEasingName,
|
|
147
|
-
samples = 48,
|
|
148
|
-
): ReadonlyArray<{ t: number; y: number }> {
|
|
149
|
-
const count = Math.max(4, samples);
|
|
150
|
-
return Array.from({ length: count + 1 }, (_, i) => {
|
|
151
|
-
const t = i / count;
|
|
152
|
-
return { t, y: evaluateEasing(t, name) };
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
export function applyEasingPresetToKeyframes(
|
|
157
|
-
keyframes: readonly MotionTimelineKeyframe[],
|
|
158
|
-
easing: MotionEasingName,
|
|
159
|
-
scope: "all" | "segment" = "all",
|
|
160
|
-
segmentIndex = 0,
|
|
161
|
-
): readonly MotionTimelineKeyframe[] {
|
|
162
|
-
return keyframes.map((kf, idx) => {
|
|
163
|
-
if (scope === "all" || idx === segmentIndex) {
|
|
164
|
-
return { ...kf, easing };
|
|
165
|
-
}
|
|
166
|
-
return kf;
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
let sharedAudioCtx: AudioContext | null = null;
|
|
171
|
-
|
|
172
|
-
export function playProceduralSfx(
|
|
173
|
-
preset: ProceduralSfxPreset,
|
|
174
|
-
enabled = true,
|
|
175
|
-
userGesture = true,
|
|
176
|
-
pitchScale = 1,
|
|
177
|
-
): void {
|
|
178
|
-
if (!enabled || !userGesture || typeof window === "undefined") return;
|
|
179
|
-
try {
|
|
180
|
-
const Ctor =
|
|
181
|
-
window.AudioContext ||
|
|
182
|
-
(window as unknown as { webkitAudioContext?: typeof AudioContext })
|
|
183
|
-
.webkitAudioContext;
|
|
184
|
-
if (!Ctor) return;
|
|
185
|
-
if (!sharedAudioCtx) sharedAudioCtx = new Ctor();
|
|
186
|
-
const ctx = sharedAudioCtx;
|
|
187
|
-
if (ctx.state === "suspended") {
|
|
188
|
-
void ctx.resume().catch(() => undefined);
|
|
189
|
-
}
|
|
190
|
-
const now = ctx.currentTime;
|
|
191
|
-
const osc = ctx.createOscillator();
|
|
192
|
-
const gain = ctx.createGain();
|
|
193
|
-
const pitch = Math.max(0.5, Math.min(2, pitchScale));
|
|
194
|
-
|
|
195
|
-
const freqMap: Record<ProceduralSfxPreset, [number, number, number]> = {
|
|
196
|
-
"click-soft": [520 * pitch, 680 * pitch, 0.05],
|
|
197
|
-
"toggle-pop": [360 * pitch, 720 * pitch, 0.08],
|
|
198
|
-
"success-chime": [523 * pitch, 784 * pitch, 0.16],
|
|
199
|
-
"hit-impact": [180 * pitch, 64 * pitch, 0.14],
|
|
200
|
-
boing: [240 * pitch, 540 * pitch, 0.18],
|
|
201
|
-
"cut-in-slash": [880 * pitch, 240 * pitch, 0.2],
|
|
202
|
-
"level-up": [440 * pitch, 880 * pitch, 0.24],
|
|
203
|
-
"gacha-sparkle": [660 * pitch, 1180 * pitch, 0.22],
|
|
204
|
-
"gacha-fanfare": [523 * pitch, 1046 * pitch, 0.28],
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
const [startHz, endHz, dur] = freqMap[preset] ?? [440, 660, 0.1];
|
|
208
|
-
osc.type = preset === "hit-impact" ? "sawtooth" : "triangle";
|
|
209
|
-
osc.frequency.setValueAtTime(startHz, now);
|
|
210
|
-
osc.frequency.exponentialRampToValueAtTime(Math.max(40, endHz), now + dur);
|
|
211
|
-
|
|
212
|
-
gain.gain.setValueAtTime(0.08, now);
|
|
213
|
-
gain.gain.exponentialRampToValueAtTime(0.001, now + dur);
|
|
214
|
-
|
|
215
|
-
osc.connect(gain);
|
|
216
|
-
gain.connect(ctx.destination);
|
|
217
|
-
osc.start(now);
|
|
218
|
-
osc.stop(now + dur);
|
|
219
|
-
} catch {
|
|
220
|
-
// Audio playback optional in restricted browser environments.
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
type MotionContextValue = {
|
|
225
|
-
profile: MotionProfile;
|
|
226
|
-
sfxEnabled: boolean;
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
const MotionContext = createContext<MotionContextValue>({
|
|
230
|
-
profile: "expressive",
|
|
231
|
-
sfxEnabled: false,
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
export function useMotionContext() {
|
|
235
|
-
return useContext(MotionContext);
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
export function MotionProvider({
|
|
239
|
-
profile = "expressive",
|
|
240
|
-
sfxEnabled = false,
|
|
241
|
-
syncDocumentAttribute = false,
|
|
242
|
-
children,
|
|
243
|
-
}: {
|
|
244
|
-
profile?: MotionProfile;
|
|
245
|
-
sfxEnabled?: boolean;
|
|
246
|
-
syncDocumentAttribute?: boolean;
|
|
247
|
-
children: ReactNode;
|
|
248
|
-
}) {
|
|
249
|
-
useEffect(() => {
|
|
250
|
-
if (!syncDocumentAttribute || typeof document === "undefined") return;
|
|
251
|
-
document.documentElement.setAttribute("data-mw-motion", profile);
|
|
252
|
-
}, [profile, syncDocumentAttribute]);
|
|
253
|
-
|
|
254
|
-
return (
|
|
255
|
-
<MotionContext.Provider value={{ profile, sfxEnabled }}>
|
|
256
|
-
{children}
|
|
257
|
-
</MotionContext.Provider>
|
|
258
|
-
);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
export function MotionStage({
|
|
262
|
-
children,
|
|
263
|
-
className = "",
|
|
264
|
-
style,
|
|
265
|
-
}: {
|
|
266
|
-
children: ReactNode;
|
|
267
|
-
className?: string;
|
|
268
|
-
style?: CSSProperties;
|
|
269
|
-
}) {
|
|
270
|
-
const { profile } = useMotionContext();
|
|
271
|
-
return (
|
|
272
|
-
<div
|
|
273
|
-
className={`mw-ui-motion-stage ${className}`.trim()}
|
|
274
|
-
data-motion-profile={profile}
|
|
275
|
-
style={{ position: "relative", ...style }}
|
|
276
|
-
>
|
|
277
|
-
{children}
|
|
278
|
-
</div>
|
|
279
|
-
);
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
export function ScrollReveal({
|
|
283
|
-
children,
|
|
284
|
-
className = "",
|
|
285
|
-
}: {
|
|
286
|
-
children: ReactNode;
|
|
287
|
-
className?: string;
|
|
288
|
-
}) {
|
|
289
|
-
return (
|
|
290
|
-
<div className={`mw-ui-scroll-reveal ${className}`.trim()}>{children}</div>
|
|
291
|
-
);
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
export function KineticText({
|
|
295
|
-
text,
|
|
296
|
-
splitBy = "word",
|
|
297
|
-
staggerMs = 45,
|
|
298
|
-
className = "",
|
|
299
|
-
}: {
|
|
300
|
-
text: string;
|
|
301
|
-
splitBy?: "word" | "char";
|
|
302
|
-
staggerMs?: number;
|
|
303
|
-
className?: string;
|
|
304
|
-
}) {
|
|
305
|
-
const { profile } = useMotionContext();
|
|
306
|
-
const tokens = splitBy === "char" ? Array.from(text) : text.split(/(\s+)/u);
|
|
307
|
-
|
|
308
|
-
return (
|
|
309
|
-
<span
|
|
310
|
-
className={`mw-ui-kinetic-text ${className}`.trim()}
|
|
311
|
-
data-split={splitBy}
|
|
312
|
-
style={{
|
|
313
|
-
display: "inline-flex",
|
|
314
|
-
flexWrap: "wrap",
|
|
315
|
-
fontFamily: "var(--mw-font-display)",
|
|
316
|
-
fontSize: "1.65rem",
|
|
317
|
-
lineHeight: 1.1,
|
|
318
|
-
letterSpacing: "0.02em",
|
|
319
|
-
}}
|
|
320
|
-
>
|
|
321
|
-
{tokens.map((tok, i) => (
|
|
322
|
-
<span
|
|
323
|
-
key={`${i}-${tok}`}
|
|
324
|
-
style={{
|
|
325
|
-
display: "inline-block",
|
|
326
|
-
whiteSpace: "pre",
|
|
327
|
-
transition:
|
|
328
|
-
profile === "off"
|
|
329
|
-
? "none"
|
|
330
|
-
: `transform 260ms ease ${i * staggerMs}ms`,
|
|
331
|
-
}}
|
|
332
|
-
>
|
|
333
|
-
{tok}
|
|
334
|
-
</span>
|
|
335
|
-
))}
|
|
336
|
-
</span>
|
|
337
|
-
);
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
export function AnimatedNumber({
|
|
341
|
-
value,
|
|
342
|
-
locale = "en-US",
|
|
343
|
-
className = "",
|
|
344
|
-
}: {
|
|
345
|
-
value: number;
|
|
346
|
-
locale?: string;
|
|
347
|
-
className?: string;
|
|
348
|
-
}) {
|
|
349
|
-
return (
|
|
350
|
-
<span
|
|
351
|
-
className={`mw-ui-animated-number ${className}`.trim()}
|
|
352
|
-
style={{ fontVariantNumeric: "tabular-nums" }}
|
|
353
|
-
>
|
|
354
|
-
{new Intl.NumberFormat(locale).format(value)}
|
|
355
|
-
</span>
|
|
356
|
-
);
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
export type MotionTimelineProps = {
|
|
360
|
-
title?: string;
|
|
361
|
-
subtitle?: string;
|
|
362
|
-
keyframes?: readonly MotionTimelineKeyframe[];
|
|
363
|
-
durationMs?: number;
|
|
364
|
-
defaultProgress?: number;
|
|
365
|
-
defaultLoop?: boolean;
|
|
366
|
-
showPreview?: boolean;
|
|
367
|
-
showPresetLibrary?: boolean;
|
|
368
|
-
onApplyEasingPreset?: (
|
|
369
|
-
easing: MotionEasingName,
|
|
370
|
-
scope: "all" | "segment",
|
|
371
|
-
segmentIndex: number,
|
|
372
|
-
) => void;
|
|
373
|
-
className?: string;
|
|
374
|
-
};
|
|
375
|
-
|
|
376
|
-
export function MotionTimeline({
|
|
377
|
-
title = "Motion Timeline",
|
|
378
|
-
subtitle,
|
|
379
|
-
keyframes = DEFAULT_MOTION_TIMELINE_KEYFRAMES,
|
|
380
|
-
durationMs = 1600,
|
|
381
|
-
defaultProgress = 0.28,
|
|
382
|
-
defaultLoop = true,
|
|
383
|
-
showPreview = true,
|
|
384
|
-
showPresetLibrary = false,
|
|
385
|
-
onApplyEasingPreset,
|
|
386
|
-
className = "",
|
|
387
|
-
}: MotionTimelineProps) {
|
|
388
|
-
const [progress, setProgress] = useState(defaultProgress);
|
|
389
|
-
const [playing, setPlaying] = useState(false);
|
|
390
|
-
const [selectedSegment, setSelectedSegment] = useState(0);
|
|
391
|
-
|
|
392
|
-
useEffect(() => {
|
|
393
|
-
if (!playing) return;
|
|
394
|
-
let raf = 0;
|
|
395
|
-
let last = performance.now();
|
|
396
|
-
const tick = (now: number) => {
|
|
397
|
-
const dt = (now - last) / Math.max(200, durationMs);
|
|
398
|
-
last = now;
|
|
399
|
-
setProgress((prev) => {
|
|
400
|
-
const next = prev + dt;
|
|
401
|
-
if (next >= 1) {
|
|
402
|
-
if (defaultLoop) return next - 1;
|
|
403
|
-
setPlaying(false);
|
|
404
|
-
return 1;
|
|
405
|
-
}
|
|
406
|
-
return next;
|
|
407
|
-
});
|
|
408
|
-
raf = window.requestAnimationFrame(tick);
|
|
409
|
-
};
|
|
410
|
-
raf = window.requestAnimationFrame(tick);
|
|
411
|
-
return () => window.cancelAnimationFrame(raf);
|
|
412
|
-
}, [playing, durationMs, defaultLoop]);
|
|
413
|
-
|
|
414
|
-
const currentVal = useMemo(() => {
|
|
415
|
-
if (keyframes.length === 0) return progress;
|
|
416
|
-
if (keyframes.length === 1) return keyframes[0].value;
|
|
417
|
-
for (let i = 0; i < keyframes.length - 1; i++) {
|
|
418
|
-
const a = keyframes[i];
|
|
419
|
-
const b = keyframes[i + 1];
|
|
420
|
-
if (progress >= a.at && progress <= b.at) {
|
|
421
|
-
const span = Math.max(0.0001, b.at - a.at);
|
|
422
|
-
const localT = (progress - a.at) / span;
|
|
423
|
-
const eased = evaluateEasing(localT, b.easing ?? "ease-out");
|
|
424
|
-
return a.value + (b.value - a.value) * eased;
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
return keyframes[keyframes.length - 1].value;
|
|
428
|
-
}, [keyframes, progress]);
|
|
429
|
-
|
|
430
|
-
const polylinePoints = useMemo(() => {
|
|
431
|
-
const pts: string[] = [];
|
|
432
|
-
for (let i = 0; i <= 40; i++) {
|
|
433
|
-
const p = i / 40;
|
|
434
|
-
let val = p;
|
|
435
|
-
for (let k = 0; k < keyframes.length - 1; k++) {
|
|
436
|
-
const a = keyframes[k];
|
|
437
|
-
const b = keyframes[k + 1];
|
|
438
|
-
if (p >= a.at && p <= b.at) {
|
|
439
|
-
const span = Math.max(0.0001, b.at - a.at);
|
|
440
|
-
val =
|
|
441
|
-
a.value +
|
|
442
|
-
(b.value - a.value) *
|
|
443
|
-
evaluateEasing((p - a.at) / span, b.easing ?? "ease-out");
|
|
444
|
-
break;
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
const x = 14 + p * 272;
|
|
448
|
-
const y = 84 - Math.max(-0.15, Math.min(1.15, val)) * 68;
|
|
449
|
-
pts.push(`${x.toFixed(1)},${y.toFixed(1)}`);
|
|
450
|
-
}
|
|
451
|
-
return pts.join(" ");
|
|
452
|
-
}, [keyframes]);
|
|
453
|
-
|
|
454
|
-
return (
|
|
455
|
-
<section
|
|
456
|
-
className={`mw-ui-motion-timeline ${className}`.trim()}
|
|
457
|
-
style={{
|
|
458
|
-
display: "grid",
|
|
459
|
-
gap: "0.85rem",
|
|
460
|
-
padding: "1rem",
|
|
461
|
-
border: "2px solid var(--mw-border-strong)",
|
|
462
|
-
background: "var(--mw-surface)",
|
|
463
|
-
boxShadow: "var(--mw-shadow-ink)",
|
|
464
|
-
}}
|
|
465
|
-
>
|
|
466
|
-
<header
|
|
467
|
-
style={{
|
|
468
|
-
display: "flex",
|
|
469
|
-
flexWrap: "wrap",
|
|
470
|
-
alignItems: "center",
|
|
471
|
-
justifyContent: "space-between",
|
|
472
|
-
gap: "0.5rem",
|
|
473
|
-
}}
|
|
474
|
-
>
|
|
475
|
-
<div>
|
|
476
|
-
<strong style={{ fontSize: "0.96rem" }}>{title}</strong>
|
|
477
|
-
{subtitle ? (
|
|
478
|
-
<p style={{ margin: "0.2rem 0 0", fontSize: "0.8rem", color: "var(--mw-muted-foreground)" }}>
|
|
479
|
-
{subtitle}
|
|
480
|
-
</p>
|
|
481
|
-
) : null}
|
|
482
|
-
</div>
|
|
483
|
-
<div style={{ display: "flex", alignItems: "center", gap: "0.45rem" }}>
|
|
484
|
-
<Badge size="sm" variant="cyan">
|
|
485
|
-
{Math.round(progress * durationMs)}ms / {durationMs}ms
|
|
486
|
-
</Badge>
|
|
487
|
-
<Button
|
|
488
|
-
size="xs"
|
|
489
|
-
variant={playing ? "magenta" : "default"}
|
|
490
|
-
onClick={() => setPlaying((p) => !p)}
|
|
491
|
-
>
|
|
492
|
-
{playing ? "Pause" : "Play"}
|
|
493
|
-
</Button>
|
|
494
|
-
</div>
|
|
495
|
-
</header>
|
|
496
|
-
|
|
497
|
-
<svg
|
|
498
|
-
viewBox="0 0 300 96"
|
|
499
|
-
role="img"
|
|
500
|
-
aria-label={`${title} curve`}
|
|
501
|
-
style={{
|
|
502
|
-
width: "100%",
|
|
503
|
-
height: "6rem",
|
|
504
|
-
background: "var(--mw-surface-muted)",
|
|
505
|
-
border: "1px solid var(--mw-border)",
|
|
506
|
-
}}
|
|
507
|
-
>
|
|
508
|
-
<polyline
|
|
509
|
-
fill="none"
|
|
510
|
-
stroke="var(--mw-primary)"
|
|
511
|
-
strokeWidth="2.5"
|
|
512
|
-
points={polylinePoints}
|
|
513
|
-
/>
|
|
514
|
-
{keyframes.map((kf, idx) => (
|
|
515
|
-
<circle
|
|
516
|
-
key={kf.id}
|
|
517
|
-
cx={14 + kf.at * 272}
|
|
518
|
-
cy={84 - Math.max(-0.15, Math.min(1.15, kf.value)) * 68}
|
|
519
|
-
r={idx === selectedSegment ? 5 : 3.5}
|
|
520
|
-
fill={idx === selectedSegment ? "var(--mw-magenta)" : "var(--mw-cyan)"}
|
|
521
|
-
stroke="var(--mw-ink)"
|
|
522
|
-
strokeWidth="1.2"
|
|
523
|
-
/>
|
|
524
|
-
))}
|
|
525
|
-
<line
|
|
526
|
-
x1={14 + progress * 272}
|
|
527
|
-
y1="6"
|
|
528
|
-
x2={14 + progress * 272}
|
|
529
|
-
y2="90"
|
|
530
|
-
stroke="var(--mw-magenta)"
|
|
531
|
-
strokeWidth="1.5"
|
|
532
|
-
strokeDasharray="3 2"
|
|
533
|
-
/>
|
|
534
|
-
</svg>
|
|
535
|
-
|
|
536
|
-
<label style={{ display: "grid", gap: "0.25rem", fontSize: "0.78rem" }}>
|
|
537
|
-
<span>
|
|
538
|
-
Scrub timeline: {(progress * 100).toFixed(0)}% · val{" "}
|
|
539
|
-
{currentVal.toFixed(2)}
|
|
540
|
-
</span>
|
|
541
|
-
<input
|
|
542
|
-
type="range"
|
|
543
|
-
min={0}
|
|
544
|
-
max={1}
|
|
545
|
-
step={0.01}
|
|
546
|
-
value={progress}
|
|
547
|
-
onChange={(e) => setProgress(Number(e.currentTarget.value))}
|
|
548
|
-
aria-label="Timeline scrub position"
|
|
549
|
-
/>
|
|
550
|
-
</label>
|
|
551
|
-
|
|
552
|
-
{showPreview ? (
|
|
553
|
-
<div
|
|
554
|
-
style={{
|
|
555
|
-
position: "relative",
|
|
556
|
-
height: "2.4rem",
|
|
557
|
-
border: "1px solid var(--mw-border)",
|
|
558
|
-
background: "var(--mw-surface-muted)",
|
|
559
|
-
overflow: "hidden",
|
|
560
|
-
}}
|
|
561
|
-
>
|
|
562
|
-
<div
|
|
563
|
-
style={{
|
|
564
|
-
position: "absolute",
|
|
565
|
-
top: "0.45rem",
|
|
566
|
-
left: `calc(8px + ${Math.max(0, Math.min(1, currentVal)).toFixed(3)} * (100% - 42px))`,
|
|
567
|
-
width: "1.5rem",
|
|
568
|
-
height: "1.5rem",
|
|
569
|
-
background: "var(--mw-magenta)",
|
|
570
|
-
border: "2px solid var(--mw-ink)",
|
|
571
|
-
}}
|
|
572
|
-
/>
|
|
573
|
-
</div>
|
|
574
|
-
) : null}
|
|
575
|
-
|
|
576
|
-
{showPresetLibrary && onApplyEasingPreset ? (
|
|
577
|
-
<div style={{ display: "flex", flexWrap: "wrap", gap: "0.35rem" }}>
|
|
578
|
-
{keyframes.map((kf, idx) => (
|
|
579
|
-
<Button
|
|
580
|
-
key={kf.id}
|
|
581
|
-
size="xs"
|
|
582
|
-
variant={selectedSegment === idx ? "default" : "outline"}
|
|
583
|
-
onClick={() => setSelectedSegment(idx)}
|
|
584
|
-
>
|
|
585
|
-
{kf.label} ({kf.easing ?? "ease-out"})
|
|
586
|
-
</Button>
|
|
587
|
-
))}
|
|
588
|
-
{(["overshoot", "elastic", "bounce", "steps-12"] as const).map(
|
|
589
|
-
(preset) => (
|
|
590
|
-
<Button
|
|
591
|
-
key={preset}
|
|
592
|
-
size="xs"
|
|
593
|
-
variant="ghost"
|
|
594
|
-
onClick={() =>
|
|
595
|
-
onApplyEasingPreset(preset, "segment", selectedSegment)
|
|
596
|
-
}
|
|
597
|
-
>
|
|
598
|
-
Apply {preset}
|
|
599
|
-
</Button>
|
|
600
|
-
),
|
|
601
|
-
)}
|
|
602
|
-
</div>
|
|
603
|
-
) : null}
|
|
604
|
-
</section>
|
|
605
|
-
);
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
export function ScreenFXOverlay({
|
|
609
|
-
effect,
|
|
610
|
-
active = false,
|
|
611
|
-
}: {
|
|
612
|
-
effect: ScreenFXKind;
|
|
613
|
-
active?: boolean;
|
|
614
|
-
}) {
|
|
615
|
-
if (!active) return null;
|
|
616
|
-
const bg =
|
|
617
|
-
effect === "flash"
|
|
618
|
-
? "var(--mw-fx-flash)"
|
|
619
|
-
: effect === "chromatic-pulse"
|
|
620
|
-
? "var(--mw-fx-chromatic-pulse)"
|
|
621
|
-
: effect === "speedlines-burst"
|
|
622
|
-
? "var(--mw-fx-speedlines-burst)"
|
|
623
|
-
: "var(--mw-fx-vignette)";
|
|
624
|
-
|
|
625
|
-
return (
|
|
626
|
-
<div
|
|
627
|
-
aria-hidden="true"
|
|
628
|
-
className="mw-ui-screen-fx-overlay"
|
|
629
|
-
data-effect={effect}
|
|
630
|
-
style={{
|
|
631
|
-
position: "absolute",
|
|
632
|
-
inset: 0,
|
|
633
|
-
pointerEvents: "none",
|
|
634
|
-
background: bg,
|
|
635
|
-
zIndex: 8,
|
|
636
|
-
}}
|
|
637
|
-
/>
|
|
638
|
-
);
|
|
639
|
-
}
|