@mingozhou/dsh-replay 0.3.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.
Files changed (65) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +164 -0
  3. package/README.zh.md +164 -0
  4. package/cordis.patch.yml +6 -0
  5. package/lib/client.js +2478 -0
  6. package/lib/core.js +720 -0
  7. package/lib/index.js +111 -0
  8. package/lib/types/demo/main.d.ts +1 -0
  9. package/lib/types/demo/samples.d.ts +21 -0
  10. package/lib/types/src/client/api.d.ts +43 -0
  11. package/lib/types/src/client/components/AuditView.d.ts +8 -0
  12. package/lib/types/src/client/components/CompareView.d.ts +9 -0
  13. package/lib/types/src/client/components/ForkTreeView.d.ts +7 -0
  14. package/lib/types/src/client/components/ItemDetail.d.ts +6 -0
  15. package/lib/types/src/client/components/OverviewView.d.ts +8 -0
  16. package/lib/types/src/client/components/ReplayApp.d.ts +12 -0
  17. package/lib/types/src/client/components/ReplayModal.d.ts +8 -0
  18. package/lib/types/src/client/components/SessionPicker.d.ts +6 -0
  19. package/lib/types/src/client/components/TimelineView.d.ts +6 -0
  20. package/lib/types/src/client/export.d.ts +13 -0
  21. package/lib/types/src/client/i18n.d.ts +24 -0
  22. package/lib/types/src/client/index.d.ts +12 -0
  23. package/lib/types/src/client/mascot-image.d.ts +1 -0
  24. package/lib/types/src/client/mascot.d.ts +17 -0
  25. package/lib/types/src/client/viewer-entry.d.ts +1 -0
  26. package/lib/types/src/core/audit.d.ts +39 -0
  27. package/lib/types/src/core/compare.d.ts +31 -0
  28. package/lib/types/src/core/cost.d.ts +30 -0
  29. package/lib/types/src/core/decode.d.ts +25 -0
  30. package/lib/types/src/core/forktree.d.ts +33 -0
  31. package/lib/types/src/core/index.d.ts +7 -0
  32. package/lib/types/src/core/timeline.d.ts +96 -0
  33. package/lib/types/src/core/types.d.ts +88 -0
  34. package/lib/types/src/index.d.ts +20 -0
  35. package/lib/viewer.js +812 -0
  36. package/package.json +107 -0
  37. package/scripts/build.mjs +131 -0
  38. package/src/client/api.ts +119 -0
  39. package/src/client/components/AuditView.tsx +57 -0
  40. package/src/client/components/CompareView.tsx +186 -0
  41. package/src/client/components/ForkTreeView.tsx +123 -0
  42. package/src/client/components/ItemDetail.tsx +117 -0
  43. package/src/client/components/OverviewView.tsx +258 -0
  44. package/src/client/components/ReplayApp.tsx +205 -0
  45. package/src/client/components/ReplayModal.tsx +53 -0
  46. package/src/client/components/SessionPicker.tsx +60 -0
  47. package/src/client/components/TimelineView.tsx +296 -0
  48. package/src/client/export.ts +43 -0
  49. package/src/client/i18n.ts +360 -0
  50. package/src/client/index.ts +146 -0
  51. package/src/client/mascot-image.ts +1 -0
  52. package/src/client/mascot.tsx +192 -0
  53. package/src/client/styles.css +719 -0
  54. package/src/client/viewer-entry.tsx +66 -0
  55. package/src/core/audit.ts +227 -0
  56. package/src/core/compare.ts +0 -0
  57. package/src/core/cost.ts +61 -0
  58. package/src/core/decode.ts +125 -0
  59. package/src/core/forktree.ts +104 -0
  60. package/src/core/index.ts +7 -0
  61. package/src/core/timeline.ts +396 -0
  62. package/src/core/types.ts +90 -0
  63. package/src/index.ts +157 -0
  64. package/tsconfig.json +18 -0
  65. package/types.d.ts +15 -0
@@ -0,0 +1,192 @@
1
+ /**
2
+ * 鲸小深 (Jing Xiaoshen) — dsh-replay's mascot, an original whale-catgirl
3
+ * character. When `assets/jingxiaoshen.png` exists at build time it is
4
+ * embedded and used everywhere; otherwise a built-in SVG chibi stands in.
5
+ * Hide globally with: .dshr-mascot { display: none }
6
+ */
7
+ import React from 'react'
8
+ import { mascotImage } from './mascot-image.js'
9
+
10
+ export type MascotMood = 'idle' | 'happy' | 'alert'
11
+
12
+ const INK = '#233a80'
13
+
14
+ export function Mascot({
15
+ mood = 'idle',
16
+ size = 88,
17
+ }: {
18
+ mood?: MascotMood
19
+ size?: number
20
+ }): React.ReactElement {
21
+ if (mascotImage !== undefined) {
22
+ return (
23
+ <img
24
+ className="dshr-mascot"
25
+ src={mascotImage}
26
+ width={size}
27
+ height={size}
28
+ style={{ borderRadius: '50%', objectFit: 'cover' }}
29
+ alt="鲸小深 Jing Xiaoshen, the dsh-replay mascot"
30
+ />
31
+ )
32
+ }
33
+ const eyes =
34
+ mood === 'happy' ? (
35
+ <g stroke={INK} strokeWidth={3.4} strokeLinecap="round" fill="none">
36
+ <path d="M 53 82 q 8 -9 16 0" />
37
+ <path d="M 91 82 q 8 -9 16 0" />
38
+ </g>
39
+ ) : mood === 'alert' ? (
40
+ <g stroke={INK} strokeWidth={3.2} strokeLinecap="round" fill="none">
41
+ <path d="M 52 78 l 13 6 l -13 6" />
42
+ <path d="M 108 78 l -13 6 l 13 6" />
43
+ </g>
44
+ ) : (
45
+ <g>
46
+ {/* upper lash lines */}
47
+ <path d="M 50 74 q 11 -7 22 -1" stroke={INK} strokeWidth={3.6} strokeLinecap="round" fill="none" />
48
+ <path d="M 88 73 q 11 -6 22 1" stroke={INK} strokeWidth={3.6} strokeLinecap="round" fill="none" />
49
+ {/* irises */}
50
+ <ellipse cx={61} cy={84} rx={9.5} ry={11.5} fill="url(#dshr-iris)" />
51
+ <ellipse cx={99} cy={84} rx={9.5} ry={11.5} fill="url(#dshr-iris)" />
52
+ {/* pupils + sparkle */}
53
+ <ellipse cx={61} cy={86} rx={4.2} ry={5.4} fill={INK} />
54
+ <ellipse cx={99} cy={86} rx={4.2} ry={5.4} fill={INK} />
55
+ <circle cx={57.5} cy={79.5} r={3.1} fill="#fff" />
56
+ <circle cx={95.5} cy={79.5} r={3.1} fill="#fff" />
57
+ <circle cx={64.5} cy={90} r={1.5} fill="#fff" opacity={0.9} />
58
+ <circle cx={102.5} cy={90} r={1.5} fill="#fff" opacity={0.9} />
59
+ </g>
60
+ )
61
+ return (
62
+ <svg
63
+ className="dshr-mascot"
64
+ width={size}
65
+ height={size}
66
+ viewBox="0 0 160 150"
67
+ role="img"
68
+ aria-label="鲸小深 Jing Xiaoshen, the dsh-replay mascot"
69
+ >
70
+ <defs>
71
+ <linearGradient id="dshr-hair" x1="0" y1="0" x2="0.4" y2="1">
72
+ <stop offset="0" stopColor="#4a6cf0" />
73
+ <stop offset="0.55" stopColor="#2f57c9" />
74
+ <stop offset="1" stopColor="#1e3f9e" />
75
+ </linearGradient>
76
+ <linearGradient id="dshr-hair-lt" x1="0" y1="0" x2="0" y2="1">
77
+ <stop offset="0" stopColor="#6f8cf7" />
78
+ <stop offset="1" stopColor="#3a60d4" />
79
+ </linearGradient>
80
+ <radialGradient id="dshr-iris" cx="0.5" cy="0.35" r="0.75">
81
+ <stop offset="0" stopColor="#8fb6ff" />
82
+ <stop offset="0.6" stopColor="#3d6fe0" />
83
+ <stop offset="1" stopColor="#1e3f9e" />
84
+ </radialGradient>
85
+ </defs>
86
+
87
+ {/* ==== long back hair (wavy, falls behind shoulders) ==== */}
88
+ <path
89
+ d="M 24 66 Q 20 22 80 20 Q 140 22 136 66
90
+ L 138 96 Q 141 108 134 120 Q 130 110 127 104
91
+ Q 128 122 120 134 Q 116 122 113 114
92
+ Q 111 130 100 140 Q 99 128 97 120
93
+ L 63 120 Q 61 128 60 140 Q 49 130 47 114
94
+ Q 44 122 40 134 Q 32 122 33 104
95
+ Q 30 110 26 120 Q 19 108 22 96 Z"
96
+ fill="url(#dshr-hair)"
97
+ />
98
+
99
+ {/* ==== cat ears (on top of hair) ==== */}
100
+ <path d="M 34 44 Q 30 16 44 8 Q 56 18 58 34 Z" fill="url(#dshr-hair-lt)" />
101
+ <path d="M 126 44 Q 130 16 116 8 Q 104 18 102 34 Z" fill="url(#dshr-hair-lt)" />
102
+ <path d="M 40 38 Q 39 22 45 15 Q 52 22 53 32 Z" fill="#ffc9d6" />
103
+ <path d="M 120 38 Q 121 22 115 15 Q 108 22 107 32 Z" fill="#ffc9d6" />
104
+
105
+ {/* ==== maid frill headband ==== */}
106
+ <path
107
+ d="M 38 40 Q 42 30 52 28 Q 54 34 60 32 Q 60 26 70 24 Q 73 30 80 29
108
+ Q 87 30 90 24 Q 100 26 100 32 Q 106 34 108 28 Q 118 30 122 40
109
+ Q 112 36 80 35 Q 48 36 38 40 Z"
110
+ fill="#ffffff"
111
+ stroke="#dfe3f2"
112
+ strokeWidth={1}
113
+ />
114
+
115
+ {/* ==== face ==== */}
116
+ <path
117
+ d="M 36 76 Q 36 44 80 42 Q 124 44 124 76 Q 124 104 80 108 Q 36 104 36 76 Z"
118
+ fill="#ffeee6"
119
+ />
120
+
121
+ {/* ==== bangs — pointed anime locks sweeping over the forehead ==== */}
122
+ <path
123
+ d="M 34 76 Q 33 40 80 38 Q 127 40 126 76
124
+ Q 121 68 117 60 Q 114 72 108 78 Q 104 64 100 58 Q 96 72 88 78 Q 84 62 80 56
125
+ Q 76 62 72 78 Q 64 72 60 58 Q 56 64 52 78 Q 46 72 43 60 Q 39 68 34 76 Z"
126
+ fill="url(#dshr-hair)"
127
+ />
128
+ {/* lock highlights following the strands */}
129
+ <path d="M 66 46 Q 68 56 72 66" stroke="#7f9bf9" strokeWidth={2} strokeLinecap="round" fill="none" opacity={0.65} />
130
+ <path d="M 94 46 Q 92 56 88 66" stroke="#7f9bf9" strokeWidth={2} strokeLinecap="round" fill="none" opacity={0.65} />
131
+
132
+ {/* ==== ahoge ==== */}
133
+ <path d="M 76 22 Q 70 6 88 4 Q 78 10 84 20 Z" fill="url(#dshr-hair-lt)" />
134
+
135
+ {/* ==== side locks framing the face ==== */}
136
+ <path d="M 34 66 Q 28 88 34 110 Q 40 104 41 92 Q 44 78 40 64 Z" fill="url(#dshr-hair-lt)" />
137
+ <path d="M 126 66 Q 132 88 126 110 Q 120 104 119 92 Q 116 78 120 64 Z" fill="url(#dshr-hair-lt)" />
138
+
139
+ {/* ==== whale-tail hair ornament (clipped onto the side lock) ==== */}
140
+ <g transform="translate(118, 62) rotate(24)">
141
+ <path d="M 0 9 Q 9 -3 16 2 Q 11 5 11 9 Q 18 6 23 11 Q 14 16 5 14 Q 1 12 0 9 Z" fill="#a9c6ff" stroke="#5b7dff" strokeWidth={1.4} />
142
+ </g>
143
+
144
+ {eyes}
145
+
146
+ {/* blush */}
147
+ <ellipse cx={48} cy={94} rx={6.5} ry={3.2} fill="#ffa8bb" opacity={0.6} />
148
+ <ellipse cx={112} cy={94} rx={6.5} ry={3.2} fill="#ffa8bb" opacity={0.6} />
149
+
150
+ {/* cat mouth (w) / open smile per mood */}
151
+ {mood === 'alert' ? (
152
+ <ellipse cx={80} cy={99} rx={4} ry={5} fill="#e26a7d" />
153
+ ) : (
154
+ <path
155
+ d="M 73 97 q 3.5 4 7 0 q 3.5 4 7 0"
156
+ stroke={INK}
157
+ strokeWidth={2.6}
158
+ strokeLinecap="round"
159
+ fill="none"
160
+ />
161
+ )}
162
+
163
+ {/* ==== shoulders: navy maid dress + white apron bib ==== */}
164
+ <path d="M 52 116 Q 80 108 108 116 L 116 140 Q 80 148 44 140 Z" fill="#20388f" />
165
+ <path d="M 66 118 Q 80 112 94 118 L 97 140 Q 80 145 63 140 Z" fill="#ffffff" />
166
+ <path d="M 66 118 Q 80 112 94 118" stroke="#dfe3f2" strokeWidth={1.4} fill="none" />
167
+ {/* tiny bow at the collar */}
168
+ <path d="M 80 114 l -7 -4 q -2 4 0 8 Z" fill="#4a6cf0" />
169
+ <path d="M 80 114 l 7 -4 q 2 4 0 8 Z" fill="#4a6cf0" />
170
+ <circle cx={80} cy={114} r={2.2} fill="#2f57c9" />
171
+ </svg>
172
+ )
173
+ }
174
+
175
+ export function MascotState({
176
+ mood,
177
+ text,
178
+ size = 110,
179
+ }: {
180
+ mood: MascotMood
181
+ text: string
182
+ size?: number
183
+ }): React.ReactElement {
184
+ return (
185
+ <div className="dshr-center dshr-mascot-state">
186
+ <div>
187
+ <Mascot mood={mood} size={size} />
188
+ <div className="dshr-mascot-text">{text}</div>
189
+ </div>
190
+ </div>
191
+ )
192
+ }