live2dapi-noa 2.0.0 → 2.1.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/autoload.js +1 -1
- package/css/left.css +54 -72
- package/css/left.min.css +1 -1
- package/css/right.css +54 -72
- package/css/right.min.css +1 -1
- package/jsdelivr/random/autoload.js +1 -1
- package/jsdelivr/random/autoload.min.js +1 -1
- package/jsdelivr/random/waifu-tips.js +3 -2
- package/jsdelivr/sequential/autoload.js +1 -1
- package/jsdelivr/sequential/autoload.min.js +1 -1
- package/jsdelivr/sequential/waifu-tips.js +3 -2
- package/library/catalog.d.ts +29 -0
- package/live2d.min.js +12 -2
- package/modern/renderer.mjs +18 -18
- package/npm/random/autoload.js +1 -1
- package/npm/random/waifu-tips.js +3 -2
- package/npm/sequential/autoload.js +1 -1
- package/npm/sequential/waifu-tips.js +3 -2
- package/package.json +2 -1
- package/readme.md +56 -16
- package/widget.d.mts +5 -1
- package/widget.mjs +56 -8
package/css/right.css
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
/* src/styles/widget.css */
|
|
1
2
|
#waifu-toggle {
|
|
3
|
+
border: 0;
|
|
2
4
|
background-color: #fa0;
|
|
3
5
|
border-radius: 5px;
|
|
4
6
|
bottom: 66px;
|
|
@@ -13,18 +15,15 @@
|
|
|
13
15
|
width: 60px;
|
|
14
16
|
writing-mode: vertical-rl;
|
|
15
17
|
}
|
|
16
|
-
|
|
17
18
|
#waifu-toggle.waifu-toggle-active {
|
|
18
19
|
margin-left: -50px;
|
|
19
20
|
}
|
|
20
|
-
|
|
21
|
-
#waifu-toggle
|
|
21
|
+
#waifu-toggle.waifu-toggle-active:hover,
|
|
22
|
+
#waifu-toggle:focus-visible {
|
|
22
23
|
margin-left: -30px;
|
|
23
24
|
}
|
|
24
|
-
|
|
25
25
|
#waifu {
|
|
26
26
|
bottom: -1000px;
|
|
27
|
-
right: 0;
|
|
28
27
|
line-height: 0;
|
|
29
28
|
margin-bottom: 0px;
|
|
30
29
|
position: fixed;
|
|
@@ -32,12 +31,11 @@
|
|
|
32
31
|
transition: transform 0.3s ease-in-out, bottom 3s ease-in-out;
|
|
33
32
|
z-index: 1;
|
|
34
33
|
}
|
|
35
|
-
|
|
36
34
|
#waifu:hover {
|
|
37
35
|
transform: translateY(0);
|
|
38
36
|
}
|
|
39
|
-
|
|
40
37
|
#waifu-tips {
|
|
38
|
+
pointer-events: none;
|
|
41
39
|
animation: shake 50s ease-in-out 5s infinite;
|
|
42
40
|
background-color: rgba(236, 217, 188, 0.5);
|
|
43
41
|
border: 1px solid rgba(224, 186, 140, 0.62);
|
|
@@ -57,256 +55,240 @@
|
|
|
57
55
|
word-break: break-all;
|
|
58
56
|
top: -60px;
|
|
59
57
|
}
|
|
60
|
-
|
|
61
58
|
#waifu-tips.waifu-tips-active {
|
|
62
59
|
opacity: 1;
|
|
63
60
|
transition: opacity 0.2s;
|
|
64
61
|
}
|
|
65
|
-
|
|
66
62
|
#waifu-tips span {
|
|
67
63
|
color: #0099cc;
|
|
68
64
|
}
|
|
69
|
-
|
|
70
65
|
#live2d {
|
|
71
66
|
cursor: grab;
|
|
72
67
|
height: 350px;
|
|
73
68
|
position: relative;
|
|
74
69
|
width: 350px;
|
|
75
70
|
}
|
|
76
|
-
|
|
77
71
|
#live2d:active {
|
|
78
72
|
cursor: grabbing;
|
|
79
73
|
}
|
|
80
|
-
|
|
81
74
|
#waifu-tool {
|
|
82
75
|
color: #aaa;
|
|
83
76
|
opacity: 0;
|
|
84
77
|
position: absolute;
|
|
85
|
-
left: 10px;
|
|
86
78
|
top: 50px;
|
|
87
79
|
transition: opacity 1s;
|
|
88
80
|
}
|
|
89
|
-
|
|
90
|
-
#waifu:
|
|
81
|
+
#waifu:hover #waifu-tool,
|
|
82
|
+
#waifu:focus-within #waifu-tool {
|
|
91
83
|
opacity: 1;
|
|
92
84
|
}
|
|
93
|
-
|
|
94
|
-
|
|
85
|
+
#waifu-tool button {
|
|
86
|
+
appearance: none;
|
|
87
|
+
border: 0;
|
|
88
|
+
background: transparent;
|
|
89
|
+
padding: 0 4px;
|
|
90
|
+
cursor: pointer;
|
|
95
91
|
display: block;
|
|
96
92
|
height: 40px;
|
|
97
93
|
text-align: center;
|
|
98
94
|
}
|
|
99
|
-
|
|
100
95
|
#waifu-tool svg {
|
|
101
96
|
fill: #7b8c9d;
|
|
102
97
|
cursor: pointer;
|
|
103
98
|
height: 22px;
|
|
104
99
|
transition: fill 0.3s;
|
|
105
100
|
}
|
|
106
|
-
|
|
107
101
|
#waifu-tool svg:hover {
|
|
108
|
-
fill: #0684bd;
|
|
102
|
+
fill: #0684bd;
|
|
109
103
|
}
|
|
110
|
-
|
|
111
104
|
@keyframes shake {
|
|
112
105
|
2% {
|
|
113
106
|
transform: translate(0.5px, -1.5px) rotate(-0.5deg);
|
|
114
107
|
}
|
|
115
|
-
|
|
116
108
|
4% {
|
|
117
109
|
transform: translate(0.5px, 1.5px) rotate(1.5deg);
|
|
118
110
|
}
|
|
119
|
-
|
|
120
111
|
6% {
|
|
121
112
|
transform: translate(1.5px, 1.5px) rotate(1.5deg);
|
|
122
113
|
}
|
|
123
|
-
|
|
124
114
|
8% {
|
|
125
115
|
transform: translate(2.5px, 1.5px) rotate(0.5deg);
|
|
126
116
|
}
|
|
127
|
-
|
|
128
117
|
10% {
|
|
129
118
|
transform: translate(0.5px, 2.5px) rotate(0.5deg);
|
|
130
119
|
}
|
|
131
|
-
|
|
132
120
|
12% {
|
|
133
121
|
transform: translate(1.5px, 1.5px) rotate(0.5deg);
|
|
134
122
|
}
|
|
135
|
-
|
|
136
123
|
14% {
|
|
137
124
|
transform: translate(0.5px, 0.5px) rotate(0.5deg);
|
|
138
125
|
}
|
|
139
|
-
|
|
140
126
|
16% {
|
|
141
127
|
transform: translate(-1.5px, -0.5px) rotate(1.5deg);
|
|
142
128
|
}
|
|
143
|
-
|
|
144
129
|
18% {
|
|
145
130
|
transform: translate(0.5px, 0.5px) rotate(1.5deg);
|
|
146
131
|
}
|
|
147
|
-
|
|
148
132
|
20% {
|
|
149
133
|
transform: translate(2.5px, 2.5px) rotate(1.5deg);
|
|
150
134
|
}
|
|
151
|
-
|
|
152
135
|
22% {
|
|
153
136
|
transform: translate(0.5px, -1.5px) rotate(1.5deg);
|
|
154
137
|
}
|
|
155
|
-
|
|
156
138
|
24% {
|
|
157
139
|
transform: translate(-1.5px, 1.5px) rotate(-0.5deg);
|
|
158
140
|
}
|
|
159
|
-
|
|
160
141
|
26% {
|
|
161
142
|
transform: translate(1.5px, 0.5px) rotate(1.5deg);
|
|
162
143
|
}
|
|
163
|
-
|
|
164
144
|
28% {
|
|
165
145
|
transform: translate(-0.5px, -0.5px) rotate(-0.5deg);
|
|
166
146
|
}
|
|
167
|
-
|
|
168
147
|
30% {
|
|
169
148
|
transform: translate(1.5px, -0.5px) rotate(-0.5deg);
|
|
170
149
|
}
|
|
171
|
-
|
|
172
150
|
32% {
|
|
173
151
|
transform: translate(2.5px, -1.5px) rotate(1.5deg);
|
|
174
152
|
}
|
|
175
|
-
|
|
176
153
|
34% {
|
|
177
154
|
transform: translate(2.5px, 2.5px) rotate(-0.5deg);
|
|
178
155
|
}
|
|
179
|
-
|
|
180
156
|
36% {
|
|
181
157
|
transform: translate(0.5px, -1.5px) rotate(0.5deg);
|
|
182
158
|
}
|
|
183
|
-
|
|
184
159
|
38% {
|
|
185
160
|
transform: translate(2.5px, -0.5px) rotate(-0.5deg);
|
|
186
161
|
}
|
|
187
|
-
|
|
188
162
|
40% {
|
|
189
163
|
transform: translate(-0.5px, 2.5px) rotate(0.5deg);
|
|
190
164
|
}
|
|
191
|
-
|
|
192
165
|
42% {
|
|
193
166
|
transform: translate(-1.5px, 2.5px) rotate(0.5deg);
|
|
194
167
|
}
|
|
195
|
-
|
|
196
168
|
44% {
|
|
197
169
|
transform: translate(-1.5px, 1.5px) rotate(0.5deg);
|
|
198
170
|
}
|
|
199
|
-
|
|
200
171
|
46% {
|
|
201
172
|
transform: translate(1.5px, -0.5px) rotate(-0.5deg);
|
|
202
173
|
}
|
|
203
|
-
|
|
204
174
|
48% {
|
|
205
175
|
transform: translate(2.5px, -0.5px) rotate(0.5deg);
|
|
206
176
|
}
|
|
207
|
-
|
|
208
177
|
50% {
|
|
209
178
|
transform: translate(-1.5px, 1.5px) rotate(0.5deg);
|
|
210
179
|
}
|
|
211
|
-
|
|
212
180
|
52% {
|
|
213
181
|
transform: translate(-0.5px, 1.5px) rotate(0.5deg);
|
|
214
182
|
}
|
|
215
|
-
|
|
216
183
|
54% {
|
|
217
184
|
transform: translate(-1.5px, 1.5px) rotate(0.5deg);
|
|
218
185
|
}
|
|
219
|
-
|
|
220
186
|
56% {
|
|
221
187
|
transform: translate(0.5px, 2.5px) rotate(1.5deg);
|
|
222
188
|
}
|
|
223
|
-
|
|
224
189
|
58% {
|
|
225
190
|
transform: translate(2.5px, 2.5px) rotate(0.5deg);
|
|
226
191
|
}
|
|
227
|
-
|
|
228
192
|
60% {
|
|
229
193
|
transform: translate(2.5px, -1.5px) rotate(1.5deg);
|
|
230
194
|
}
|
|
231
|
-
|
|
232
195
|
62% {
|
|
233
196
|
transform: translate(-1.5px, 0.5px) rotate(1.5deg);
|
|
234
197
|
}
|
|
235
|
-
|
|
236
198
|
64% {
|
|
237
199
|
transform: translate(-1.5px, 1.5px) rotate(1.5deg);
|
|
238
200
|
}
|
|
239
|
-
|
|
240
201
|
66% {
|
|
241
202
|
transform: translate(0.5px, 2.5px) rotate(1.5deg);
|
|
242
203
|
}
|
|
243
|
-
|
|
244
204
|
68% {
|
|
245
205
|
transform: translate(2.5px, -1.5px) rotate(1.5deg);
|
|
246
206
|
}
|
|
247
|
-
|
|
248
207
|
70% {
|
|
249
208
|
transform: translate(2.5px, 2.5px) rotate(0.5deg);
|
|
250
209
|
}
|
|
251
|
-
|
|
252
210
|
72% {
|
|
253
211
|
transform: translate(-0.5px, -1.5px) rotate(1.5deg);
|
|
254
212
|
}
|
|
255
|
-
|
|
256
213
|
74% {
|
|
257
214
|
transform: translate(-1.5px, 2.5px) rotate(1.5deg);
|
|
258
215
|
}
|
|
259
|
-
|
|
260
216
|
76% {
|
|
261
217
|
transform: translate(-1.5px, 2.5px) rotate(1.5deg);
|
|
262
218
|
}
|
|
263
|
-
|
|
264
219
|
78% {
|
|
265
220
|
transform: translate(-1.5px, 2.5px) rotate(0.5deg);
|
|
266
221
|
}
|
|
267
|
-
|
|
268
222
|
80% {
|
|
269
223
|
transform: translate(-1.5px, 0.5px) rotate(-0.5deg);
|
|
270
224
|
}
|
|
271
|
-
|
|
272
225
|
82% {
|
|
273
226
|
transform: translate(-1.5px, 0.5px) rotate(-0.5deg);
|
|
274
227
|
}
|
|
275
|
-
|
|
276
228
|
84% {
|
|
277
229
|
transform: translate(-0.5px, 0.5px) rotate(1.5deg);
|
|
278
230
|
}
|
|
279
|
-
|
|
280
231
|
86% {
|
|
281
232
|
transform: translate(2.5px, 1.5px) rotate(0.5deg);
|
|
282
233
|
}
|
|
283
|
-
|
|
284
234
|
88% {
|
|
285
235
|
transform: translate(-1.5px, 0.5px) rotate(1.5deg);
|
|
286
236
|
}
|
|
287
|
-
|
|
288
237
|
90% {
|
|
289
238
|
transform: translate(-1.5px, -0.5px) rotate(-0.5deg);
|
|
290
239
|
}
|
|
291
|
-
|
|
292
240
|
92% {
|
|
293
241
|
transform: translate(-1.5px, -1.5px) rotate(1.5deg);
|
|
294
242
|
}
|
|
295
|
-
|
|
296
243
|
94% {
|
|
297
244
|
transform: translate(0.5px, 0.5px) rotate(-0.5deg);
|
|
298
245
|
}
|
|
299
|
-
|
|
300
246
|
96% {
|
|
301
247
|
transform: translate(2.5px, -0.5px) rotate(-0.5deg);
|
|
302
248
|
}
|
|
303
|
-
|
|
304
249
|
98% {
|
|
305
250
|
transform: translate(-1.5px, -1.5px) rotate(-0.5deg);
|
|
306
251
|
}
|
|
307
|
-
|
|
308
|
-
0%,
|
|
309
|
-
100% {
|
|
252
|
+
0%, 100% {
|
|
310
253
|
transform: translate(0, 0) rotate(0);
|
|
311
254
|
}
|
|
312
255
|
}
|
|
256
|
+
.waifu-sr-only {
|
|
257
|
+
position: absolute;
|
|
258
|
+
width: 1px;
|
|
259
|
+
height: 1px;
|
|
260
|
+
overflow: hidden;
|
|
261
|
+
clip-path: inset(50%);
|
|
262
|
+
}
|
|
263
|
+
#waifu-tool button:focus-visible,
|
|
264
|
+
#waifu-toggle:focus-visible {
|
|
265
|
+
outline: 2px solid #126381;
|
|
266
|
+
outline-offset: 2px;
|
|
267
|
+
}
|
|
268
|
+
@media (hover: none) {
|
|
269
|
+
#waifu-tool {
|
|
270
|
+
opacity: 1;
|
|
271
|
+
}
|
|
272
|
+
#waifu-tool button {
|
|
273
|
+
min-width: 44px;
|
|
274
|
+
min-height: 44px;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
@media (prefers-reduced-motion: reduce) {
|
|
278
|
+
#waifu,
|
|
279
|
+
#waifu-toggle,
|
|
280
|
+
#waifu-tool,
|
|
281
|
+
#waifu-tips,
|
|
282
|
+
#waifu-tips.waifu-tips-active {
|
|
283
|
+
animation: none;
|
|
284
|
+
transition: none;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/* src/styles/right.css */
|
|
289
|
+
#waifu {
|
|
290
|
+
right: 0;
|
|
291
|
+
}
|
|
292
|
+
#waifu-tool {
|
|
293
|
+
left: 10px;
|
|
294
|
+
}
|
package/css/right.min.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
#waifu-toggle{background-color:#fa0;border-radius:5px;bottom:66px;color:#fff;cursor:pointer;font-size:12px;left:0;margin-left:-100px;padding:5px 2px 5px 5px;position:fixed;transition:margin-left 1s;width:60px;writing-mode:vertical-rl}#waifu-toggle.waifu-toggle-active{margin-left:-50px}#waifu-toggle.waifu-toggle-active:hover{margin-left:-30px}#waifu{bottom:-1000px;
|
|
1
|
+
#waifu-toggle{border:0;background-color:#fa0;border-radius:5px;bottom:66px;color:#fff;cursor:pointer;font-size:12px;left:0;margin-left:-100px;padding:5px 2px 5px 5px;position:fixed;transition:margin-left 1s;width:60px;writing-mode:vertical-rl}#waifu-toggle.waifu-toggle-active{margin-left:-50px}#waifu-toggle.waifu-toggle-active:hover,#waifu-toggle:focus-visible{margin-left:-30px}#waifu{bottom:-1000px;line-height:0;margin-bottom:0;position:fixed;transform:translateY(3px);transition:transform .3s ease-in-out,bottom 3s ease-in-out;z-index:1}#waifu:hover{transform:translateY(0)}#waifu-tips{pointer-events:none;animation:shake 50s ease-in-out 5s infinite;background-color:#ecd9bc80;border:1px solid rgba(224,186,140,.62);border-radius:12px;box-shadow:0 3px 15px 2px #bf9e7633;font-size:14px;line-height:24px;margin:-30px 30px;min-height:75px;opacity:0;overflow:hidden;padding:5px 10px;position:absolute;text-overflow:ellipsis;transition:opacity 1s;width:280px;word-break:break-all;top:-60px}#waifu-tips.waifu-tips-active{opacity:1;transition:opacity .2s}#waifu-tips span{color:#09c}#live2d{cursor:grab;height:350px;position:relative;width:350px}#live2d:active{cursor:grabbing}#waifu-tool{color:#aaa;opacity:0;position:absolute;top:50px;transition:opacity 1s}#waifu:hover #waifu-tool,#waifu:focus-within #waifu-tool{opacity:1}#waifu-tool button{appearance:none;border:0;background:transparent;padding:0 4px;cursor:pointer;display:block;height:40px;text-align:center}#waifu-tool svg{fill:#7b8c9d;cursor:pointer;height:22px;transition:fill .3s}#waifu-tool svg:hover{fill:#0684bd}@keyframes shake{2%{transform:translate(.5px,-1.5px) rotate(-.5deg)}4%{transform:translate(.5px,1.5px) rotate(1.5deg)}6%{transform:translate(1.5px,1.5px) rotate(1.5deg)}8%{transform:translate(2.5px,1.5px) rotate(.5deg)}10%{transform:translate(.5px,2.5px) rotate(.5deg)}12%{transform:translate(1.5px,1.5px) rotate(.5deg)}14%{transform:translate(.5px,.5px) rotate(.5deg)}16%{transform:translate(-1.5px,-.5px) rotate(1.5deg)}18%{transform:translate(.5px,.5px) rotate(1.5deg)}20%{transform:translate(2.5px,2.5px) rotate(1.5deg)}22%{transform:translate(.5px,-1.5px) rotate(1.5deg)}24%{transform:translate(-1.5px,1.5px) rotate(-.5deg)}26%{transform:translate(1.5px,.5px) rotate(1.5deg)}28%{transform:translate(-.5px,-.5px) rotate(-.5deg)}30%{transform:translate(1.5px,-.5px) rotate(-.5deg)}32%{transform:translate(2.5px,-1.5px) rotate(1.5deg)}34%{transform:translate(2.5px,2.5px) rotate(-.5deg)}36%{transform:translate(.5px,-1.5px) rotate(.5deg)}38%{transform:translate(2.5px,-.5px) rotate(-.5deg)}40%{transform:translate(-.5px,2.5px) rotate(.5deg)}42%{transform:translate(-1.5px,2.5px) rotate(.5deg)}44%{transform:translate(-1.5px,1.5px) rotate(.5deg)}46%{transform:translate(1.5px,-.5px) rotate(-.5deg)}48%{transform:translate(2.5px,-.5px) rotate(.5deg)}50%{transform:translate(-1.5px,1.5px) rotate(.5deg)}52%{transform:translate(-.5px,1.5px) rotate(.5deg)}54%{transform:translate(-1.5px,1.5px) rotate(.5deg)}56%{transform:translate(.5px,2.5px) rotate(1.5deg)}58%{transform:translate(2.5px,2.5px) rotate(.5deg)}60%{transform:translate(2.5px,-1.5px) rotate(1.5deg)}62%{transform:translate(-1.5px,.5px) rotate(1.5deg)}64%{transform:translate(-1.5px,1.5px) rotate(1.5deg)}66%{transform:translate(.5px,2.5px) rotate(1.5deg)}68%{transform:translate(2.5px,-1.5px) rotate(1.5deg)}70%{transform:translate(2.5px,2.5px) rotate(.5deg)}72%{transform:translate(-.5px,-1.5px) rotate(1.5deg)}74%{transform:translate(-1.5px,2.5px) rotate(1.5deg)}76%{transform:translate(-1.5px,2.5px) rotate(1.5deg)}78%{transform:translate(-1.5px,2.5px) rotate(.5deg)}80%{transform:translate(-1.5px,.5px) rotate(-.5deg)}82%{transform:translate(-1.5px,.5px) rotate(-.5deg)}84%{transform:translate(-.5px,.5px) rotate(1.5deg)}86%{transform:translate(2.5px,1.5px) rotate(.5deg)}88%{transform:translate(-1.5px,.5px) rotate(1.5deg)}90%{transform:translate(-1.5px,-.5px) rotate(-.5deg)}92%{transform:translate(-1.5px,-1.5px) rotate(1.5deg)}94%{transform:translate(.5px,.5px) rotate(-.5deg)}96%{transform:translate(2.5px,-.5px) rotate(-.5deg)}98%{transform:translate(-1.5px,-1.5px) rotate(-.5deg)}0%,to{transform:translate(0) rotate(0)}}.waifu-sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)}#waifu-tool button:focus-visible,#waifu-toggle:focus-visible{outline:2px solid #126381;outline-offset:2px}@media(hover:none){#waifu-tool{opacity:1}#waifu-tool button{min-width:44px;min-height:44px}}@media(prefers-reduced-motion:reduce){#waifu,#waifu-toggle,#waifu-tool,#waifu-tips,#waifu-tips.waifu-tips-active{animation:none;transition:none}}#waifu{right:0}#waifu-tool{left:10px}
|
|
@@ -8,7 +8,7 @@ const live2d_path = (() => {
|
|
|
8
8
|
return new URL("../../", url).href;
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
|
-
return false ? "https://unpkg.com/live2dapi-noa@2.
|
|
11
|
+
return false ? "https://unpkg.com/live2dapi-noa@2.1.0/" : "https://cdn.jsdelivr.net/npm/live2dapi-noa@2.1.0/";
|
|
12
12
|
})();
|
|
13
13
|
function loadExternalResource(url, type) {
|
|
14
14
|
let tag;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! Live2D API | Generated from src/ | https://github.com/nova1751/live2d-api */
|
|
2
|
-
"use strict";const live2d_path=(()=>{const e=document.currentScript;if(e?.src){const i=new URL(e.src);if(/\/(?:live2dapi-noa|gh\/nova1751\/live2d-api)(?:@[^/]+)?\/(?:npm|jsdelivr)\/(?:random|sequential)\/autoload(?:\.min)?\.js$/.test(i.pathname))return new URL("../../",i).href}return"https://cdn.jsdelivr.net/npm/live2dapi-noa@2.
|
|
2
|
+
"use strict";const live2d_path=(()=>{const e=document.currentScript;if(e?.src){const i=new URL(e.src);if(/\/(?:live2dapi-noa|gh\/nova1751\/live2d-api)(?:@[^/]+)?\/(?:npm|jsdelivr)\/(?:random|sequential)\/autoload(?:\.min)?\.js$/.test(i.pathname))return new URL("../../",i).href}return"https://cdn.jsdelivr.net/npm/live2dapi-noa@2.1.0/"})();function loadExternalResource(e,i){let n;if(i==="css"){const t=document.createElement("link");t.href=e,t.rel="stylesheet",n=t}else{const t=document.createElement("script");t.src=e,e===live2d_path+"jsdelivr/random/waifu-tips.js"&&(t.dataset.asteroidsUrl=live2d_path+"asteroids.js"),n=t}return new Promise((t,s)=>{n.onload=()=>t(e),n.onerror=()=>s(e),document.head.appendChild(n)})}screen.width>=768&&Promise.all([loadExternalResource(live2d_path+"live2d.min.js","js"),loadExternalResource(live2d_path+"jsdelivr/random/waifu-tips.js","js")]).then(async()=>{document.body||await new Promise(e=>document.addEventListener("DOMContentLoaded",()=>e(),{once:!0})),window.initWidget({tools:["hitokoto","asteroids","switch-model","switch-texture","photo","info","quit"],cdnPath:live2d_path,waifuPath:live2d_path+"waifu-tips.json"})}).catch(e=>console.error("[Live2D]",e));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/*! Live2D API | Generated from src/ | https://github.com/nova1751/live2d-api */
|
|
2
|
-
"use strict";(()=>{var M={hitokoto:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M512 240c0 114.9-114.6 208-256 208c-37.1 0-72.3-6.4-104.1-17.9c-11.9 8.7-31.3 20.6-54.3 30.6C73.6 471.1 44.7 480 16 480c-6.5 0-12.3-3.9-14.8-9.9c-2.5-6-1.1-12.8 3.4-17.4l0 0 0 0 0 0 0 0 .3-.3c.3-.3 .7-.7 1.3-1.4c1.1-1.2 2.8-3.1 4.9-5.7c4.1-5 9.6-12.4 15.2-21.6c10-16.6 19.5-38.4 21.4-62.9C17.7 326.8 0 285.1 0 240C0 125.1 114.6 32 256 32s256 93.1 256 208z"/></svg>',asteroids:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M498.1 5.6c10.1 7 15.4 19.1 13.5 31.2l-64 416c-1.5 9.7-7.4 18.2-16 23s-18.9 5.4-28 1.6L284 427.7l-68.5 74.1c-8.9 9.7-22.9 12.9-35.2 8.1S160 493.2 160 480V396.4c0-4 1.5-7.8 4.2-10.7L331.8 202.8c5.8-6.3 5.6-16-.4-22s-15.7-6.4-22-.7L106 360.8 17.7 316.6C7.1 311.3 .3 300.7 0 288.9s5.9-22.8 16.1-28.7l448-256c10.7-6.1 23.9-5.5 34 1.4z"/></svg>',"switch-model":'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M399 384.2C376.9 345.8 335.4 320 288 320H224c-47.4 0-88.9 25.8-111 64.2c35.2 39.2 86.2 63.8 143 63.8s107.8-24.7 143-63.8zM0 256a256 256 0 1 1 512 0A256 256 0 1 1 0 256zm256 16a72 72 0 1 0 0-144 72 72 0 1 0 0 144z"/></svg>',"switch-texture":'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M320 64A64 64 0 1 0 192 64a64 64 0 1 0 128 0zm-96 96c-35.3 0-64 28.7-64 64v48c0 17.7 14.3 32 32 32h1.8l11.1 99.5c1.8 16.2 15.5 28.5 31.8 28.5h38.7c16.3 0 30-12.3 31.8-28.5L318.2 304H320c17.7 0 32-14.3 32-32V224c0-35.3-28.7-64-64-64H224zM132.3 394.2c13-2.4 21.7-14.9 19.3-27.9s-14.9-21.7-27.9-19.3c-32.4 5.9-60.9 14.2-82 24.8c-10.5 5.3-20.3 11.7-27.8 19.6C6.4 399.5 0 410.5 0 424c0 21.4 15.5 36.1 29.1 45c14.7 9.6 34.3 17.3 56.4 23.4C130.2 504.7 190.4 512 256 512s125.8-7.3 170.4-19.6c22.1-6.1 41.8-13.8 56.4-23.4c13.7-8.9 29.1-23.6 29.1-45c0-13.5-6.4-24.5-14-32.6c-7.5-7.9-17.3-14.3-27.8-19.6c-21-10.6-49.5-18.9-82-24.8c-13-2.4-25.5 6.3-27.9 19.3s6.3 25.5 19.3 27.9c30.2 5.5 53.7 12.8 69 20.5c3.2 1.6 5.8 3.1 7.9 4.5c3.6 2.4 3.6 7.2 0 9.6c-8.8 5.7-23.1 11.8-43 17.3C374.3 457 318.5 464 256 464s-118.3-7-157.7-17.9c-19.9-5.5-34.2-11.6-43-17.3c-3.6-2.4-3.6-7.2 0-9.6c2.1-1.4 4.8-2.9 7.9-4.5c15.3-7.7 38.8-14.9 69-20.5z"/></svg>',photo:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M220.6 121.2L271.1 96 448 96v96H333.2c-21.9-15.1-48.5-24-77.2-24s-55.2 8.9-77.2 24H64V128H192c9.9 0 19.7-2.3 28.6-6.8zM0 128V416c0 35.3 28.7 64 64 64H448c35.3 0 64-28.7 64-64V96c0-35.3-28.7-64-64-64H271.1c-9.9 0-19.7 2.3-28.6 6.8L192 64H160V48c0-8.8-7.2-16-16-16H80c-8.8 0-16 7.2-16 16l0 16C28.7 64 0 92.7 0 128zM168 304a88 88 0 1 1 176 0 88 88 0 1 1 -176 0z"/></svg>',info:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM216 336h24V272H216c-13.3 0-24-10.7-24-24s10.7-24 24-24h48c13.3 0 24 10.7 24 24v88h8c13.3 0 24 10.7 24 24s-10.7 24-24 24H216c-13.3 0-24-10.7-24-24s10.7-24 24-24zm40-208a32 32 0 1 1 0 64 32 32 0 1 1 0-64z"/></svg>',quit:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.3 256 342.6 150.6z"/></svg>'};function y(t){return Array.isArray(t)?t[Math.floor(Math.random()*t.length)]:t}function u(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var L,x;function C(){clearTimeout(L),sessionStorage.removeItem("waifu-text"),document.getElementById("waifu-tips")?.classList.remove("waifu-tips-active")}function S(t,e){clearTimeout(L),sessionStorage.setItem("waifu-text",String(e));let o=document.getElementById("waifu-tips");o.innerHTML=t,o.classList.add("waifu-tips-active")}function c(t,e,o){!t||x||Number(sessionStorage.getItem("waifu-text"))>o||(S(y(t),o),L=setTimeout(C,e))}function k(t,e){if(!e){c(u(t),5e3,11);return}x=e,S(u(t),11)}function E(t,e){x===t&&(x=void 0,e?C():L=setTimeout(C,1200))}function O(t){if(location.pathname==="/"){let s=new Date().getHours();for(let{hour:n,text:r}of t){let[a,w=a]=n.split("-").map(Number);if(a<=s&&s<=w)return r}}let e=`欢迎阅读<span>「${u(document.title.split(" - ")[0])}」</span>`;if(!document.referrer)return e;let{hostname:o}=new URL(document.referrer);return o===location.hostname?e:`Hello!来自 <span>${u({baidu:"百度",so:"360搜索",google:"谷歌搜索"}[o.split(".")[1]]??o)}</span> 的朋友<br>${e}`}function R(t){let[e,o]=t.split("/").map(Number);return e*100+o}function A(t){let e=[...t.message.default],o=new Date,i=(o.getMonth()+1)*100+o.getDate();for(let{date:l,text:m}of t.seasons){let[d,h=d]=l.split("-").map(R);d<=i&&i<=h&&e.push(y(m).replace("{year}",String(o.getFullYear())))}let s=!1,n,r=()=>{s=!0};window.addEventListener("mousemove",r),window.addEventListener("keydown",r),setInterval(()=>{s?(s=!1,clearInterval(n),n=void 0):n===void 0&&(n=setInterval(()=>c(e,6e3,9),2e4))},1e3),c(O(t.time),7e3,11);let a;for(let l of["mouseover","click"])window.addEventListener(l,({target:m})=>{if(!(m instanceof Element))return;let d=t[l].find(({selector:h})=>m.closest(h));!d||l==="mouseover"&&d.selector===a||(l==="mouseover"&&(a=d.selector),c(y(d.text).replace("{text}",()=>u(m.textContent??"")),4e3,8))});let w=()=>{};w.toString=()=>(c(t.message.console,6e3,9),""),console.log("%c",w),window.addEventListener("copy",()=>c(t.message.copy,6e3,9)),document.addEventListener("visibilitychange",()=>{document.hidden||c(t.message.visibilitychange,6e3,9)})}var D="/gh/nova1751/live2d-api@cdn-b3ac5ae545e2/",j="https://cdn.jsdelivr.net",b=j+D,P=/\/live2dapi-noa(?:@[^/]+)?\/?$/;function H(t){let e=new URL(t,document.baseURI);return!P.test(e.pathname)||/@1\.[^/]+\/?$/.test(e.pathname)?t:(e.hostname==="cdn.jsdmirror.com"?e.origin:j)+D}var T="我的新衣服好看嘛?",p=t=>Number(localStorage.getItem(t))||0;async function v(t){let e=await fetch(t);if(!e.ok)throw new Error(`Failed to load ${t} (HTTP ${e.status})`);return e.json()}var I=class{constructor(e){this.options=e;this.revision=0;this.loaded=!1;this.useCDN=typeof e.cdnPath=="string";let o=e.modelBaseUrl??(e.cdnPath&&H(e.cdnPath))??e.apiPath;if(typeof o!="string")throw new TypeError("Invalid initWidget argument");this.base=o.endsWith("/")?o:o+"/"}reopen(e){if(this.loaded)window.loadlive2d.show?.(e);else return this.load(void 0,void 0,void 0,e)}cancel(){this.revision++}async fetchCatalog(){let e=this.base+"model_list.json",o=await fetch(e);if(o.status===404&&!this.options.modelBaseUrl&&this.base!==b){let i=await v(b+"model_list.json");return this.base=b,i}if(!o.ok)throw new Error(`Failed to load ${e} (HTTP ${o.status})`);return o.json()}list(){return this.catalog??(this.catalog=this.fetchCatalog().catch(e=>{throw this.catalog=void 0,e}))}async load(e=p("modelId"),o=p("modelTexturesId"),i,s=!1,n=++this.revision,r=!1){let a;if(this.options.modelUrl)a=this.options.modelUrl;else if(this.useCDN){let{models:l}=await this.list();l[e]||(e=0);let m=l[e],d=Array.isArray(m)?m:[m];d[o]||(o=0);let h=r?d[o]:y(d);o=d.indexOf(h),a=this.base+"model/"+h+"/index.json"}else a=this.base+"get/?id="+e+"-"+o;if(n!==this.revision)return;let w=window.loadlive2d("live2d",a,{start:s,coreUrl:this.options.coreUrl});w&&await w,n===this.revision&&(this.options.modelUrl||(localStorage.setItem("modelId",String(e)),localStorage.setItem("modelTexturesId",String(o))),c(i,4e3,10),this.loaded=!0)}async costume(e){if(this.options.modelUrl||!this.useCDN)return;let o=++this.revision,i=p("modelId"),s=(await this.list()).models[i],r=(Array.isArray(s)?s:[s]).findIndex(a=>new URL(this.base+"model/"+a+"/index.json",document.baseURI).href===e);r>=0&&await this.load(i,r,T,!1,o,!0)}async nextModel(e=!1){let o=++this.revision,i=p("modelId");if(this.useCDN){let{models:n,messages:r}=await this.list(),a=(i+1)%n.length;return this.load(a,0,r[a],e,o)}let{model:s}=await v(this.base+"switch/?id="+i);return this.load(s.id,0,s.message,e,o)}async nextTexture(e=!1){let o=++this.revision,i=p("modelId"),s=p("modelTexturesId");if(this.useCDN){let r=(await this.list()).models[i],a=Array.isArray(r)?r.length:1;return this.load(i,s,T,e,o)}let{textures:n}=await v(this.base+"rand_textures/?id="+i+"-"+s);n.id===1&&s===1?c("我还没有其他衣服呢!",4e3,10):await this.load(i,n.id,T,e,o)}};var z=document.currentScript,$=z?.dataset.asteroidsUrl??"https://fastly.jsdelivr.net/gh/nova1751/live2d-api@latest/asteroids.js",f=t=>document.getElementById(t),g=t=>console.error("[Live2D]",t);async function N(){let t=await v("https://v1.hitokoto.cn");c(u(t.hitokoto),6e3,9),setTimeout(()=>{c(`这句一言来自 <span>「${u(String(t.from))}」</span>,是 <span>${u(String(t.creator))}</span> 在 hitokoto.cn 投稿的。`,4e3,9)},6e3)}function Y(){if(window.Asteroids)(window.ASTEROIDSPLAYERS??(window.ASTEROIDSPLAYERS=[])).push(new window.Asteroids);else{let t=document.createElement("script");t.src=$,document.head.appendChild(t)}}function U(){localStorage.removeItem("waifu-display"),f("waifu").style.display="",setTimeout(()=>{f("waifu").style.bottom="0"},0)}function F(t){return t.isTrusted&&!!window.loadlive2d.prepareInteraction?.()}function V(){window.loadlive2d.hide?.(),localStorage.setItem("waifu-display",String(Date.now())),c("愿你有一天能与重要的人重逢。",2e3,11),f("waifu").style.bottom="-500px",setTimeout(()=>{f("waifu").style.display="none",f("waifu-toggle").classList.add("waifu-toggle-active")},3e3)}function B(t,e,o=!1){sessionStorage.removeItem("waifu-text"),document.body.insertAdjacentHTML("beforeend",`<div id="waifu">
|
|
2
|
+
"use strict";(()=>{var k={hitokoto:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M512 240c0 114.9-114.6 208-256 208c-37.1 0-72.3-6.4-104.1-17.9c-11.9 8.7-31.3 20.6-54.3 30.6C73.6 471.1 44.7 480 16 480c-6.5 0-12.3-3.9-14.8-9.9c-2.5-6-1.1-12.8 3.4-17.4l0 0 0 0 0 0 0 0 .3-.3c.3-.3 .7-.7 1.3-1.4c1.1-1.2 2.8-3.1 4.9-5.7c4.1-5 9.6-12.4 15.2-21.6c10-16.6 19.5-38.4 21.4-62.9C17.7 326.8 0 285.1 0 240C0 125.1 114.6 32 256 32s256 93.1 256 208z"/></svg>',asteroids:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M498.1 5.6c10.1 7 15.4 19.1 13.5 31.2l-64 416c-1.5 9.7-7.4 18.2-16 23s-18.9 5.4-28 1.6L284 427.7l-68.5 74.1c-8.9 9.7-22.9 12.9-35.2 8.1S160 493.2 160 480V396.4c0-4 1.5-7.8 4.2-10.7L331.8 202.8c5.8-6.3 5.6-16-.4-22s-15.7-6.4-22-.7L106 360.8 17.7 316.6C7.1 311.3 .3 300.7 0 288.9s5.9-22.8 16.1-28.7l448-256c10.7-6.1 23.9-5.5 34 1.4z"/></svg>',"switch-model":'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M399 384.2C376.9 345.8 335.4 320 288 320H224c-47.4 0-88.9 25.8-111 64.2c35.2 39.2 86.2 63.8 143 63.8s107.8-24.7 143-63.8zM0 256a256 256 0 1 1 512 0A256 256 0 1 1 0 256zm256 16a72 72 0 1 0 0-144 72 72 0 1 0 0 144z"/></svg>',"switch-texture":'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M320 64A64 64 0 1 0 192 64a64 64 0 1 0 128 0zm-96 96c-35.3 0-64 28.7-64 64v48c0 17.7 14.3 32 32 32h1.8l11.1 99.5c1.8 16.2 15.5 28.5 31.8 28.5h38.7c16.3 0 30-12.3 31.8-28.5L318.2 304H320c17.7 0 32-14.3 32-32V224c0-35.3-28.7-64-64-64H224zM132.3 394.2c13-2.4 21.7-14.9 19.3-27.9s-14.9-21.7-27.9-19.3c-32.4 5.9-60.9 14.2-82 24.8c-10.5 5.3-20.3 11.7-27.8 19.6C6.4 399.5 0 410.5 0 424c0 21.4 15.5 36.1 29.1 45c14.7 9.6 34.3 17.3 56.4 23.4C130.2 504.7 190.4 512 256 512s125.8-7.3 170.4-19.6c22.1-6.1 41.8-13.8 56.4-23.4c13.7-8.9 29.1-23.6 29.1-45c0-13.5-6.4-24.5-14-32.6c-7.5-7.9-17.3-14.3-27.8-19.6c-21-10.6-49.5-18.9-82-24.8c-13-2.4-25.5 6.3-27.9 19.3s6.3 25.5 19.3 27.9c30.2 5.5 53.7 12.8 69 20.5c3.2 1.6 5.8 3.1 7.9 4.5c3.6 2.4 3.6 7.2 0 9.6c-8.8 5.7-23.1 11.8-43 17.3C374.3 457 318.5 464 256 464s-118.3-7-157.7-17.9c-19.9-5.5-34.2-11.6-43-17.3c-3.6-2.4-3.6-7.2 0-9.6c2.1-1.4 4.8-2.9 7.9-4.5c15.3-7.7 38.8-14.9 69-20.5z"/></svg>',photo:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M220.6 121.2L271.1 96 448 96v96H333.2c-21.9-15.1-48.5-24-77.2-24s-55.2 8.9-77.2 24H64V128H192c9.9 0 19.7-2.3 28.6-6.8zM0 128V416c0 35.3 28.7 64 64 64H448c35.3 0 64-28.7 64-64V96c0-35.3-28.7-64-64-64H271.1c-9.9 0-19.7 2.3-28.6 6.8L192 64H160V48c0-8.8-7.2-16-16-16H80c-8.8 0-16 7.2-16 16l0 16C28.7 64 0 92.7 0 128zM168 304a88 88 0 1 1 176 0 88 88 0 1 1 -176 0z"/></svg>',info:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM216 336h24V272H216c-13.3 0-24-10.7-24-24s10.7-24 24-24h48c13.3 0 24 10.7 24 24v88h8c13.3 0 24 10.7 24 24s-10.7 24-24 24H216c-13.3 0-24-10.7-24-24s10.7-24 24-24zm40-208a32 32 0 1 1 0 64 32 32 0 1 1 0-64z"/></svg>',quit:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.3 256 342.6 150.6z"/></svg>'};function x(o){return Array.isArray(o)?o[Math.floor(Math.random()*o.length)]:o}function p(o){return o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var C,I;function S(){clearTimeout(C),sessionStorage.removeItem("waifu-text"),document.getElementById("waifu-tips")?.classList.remove("waifu-tips-active")}function F(o,e){clearTimeout(C),sessionStorage.setItem("waifu-text",String(e));let t=document.getElementById("waifu-tips");t.innerHTML=o,t.classList.add("waifu-tips-active")}function u(o,e,t){!o||I||Number(sessionStorage.getItem("waifu-text"))>t||(F(x(o),t),C=setTimeout(S,e))}function U(o,e){if(!e){u(p(o),5e3,11);return}I=e,F(p(o),11)}function D(o,e){I===o&&(I=void 0,e?S():C=setTimeout(S,1200))}function z(o){if(location.pathname==="/"){let i=new Date().getHours();for(let{hour:n,text:r}of o){let[a,c=a]=n.split("-").map(Number);if(a<=i&&i<=c)return r}}let e=`欢迎阅读<span>「${p(document.title.split(" - ")[0])}」</span>`;if(!document.referrer)return e;let{hostname:t}=new URL(document.referrer);return t===location.hostname?e:`Hello!来自 <span>${p({baidu:"百度",so:"360搜索",google:"谷歌搜索"}[t.split(".")[1]]??t)}</span> 的朋友<br>${e}`}function V(o){let[e,t]=o.split("/").map(Number);return e*100+t}function R(o){let e=[...o.message.default],t=new Date,s=(t.getMonth()+1)*100+t.getDate();for(let{date:l,text:g}of o.seasons){let[d,y=d]=l.split("-").map(V);d<=s&&s<=y&&e.push(x(g).replace("{year}",String(t.getFullYear())))}let i=2e4,n=Date.now(),r;function a(){if(document.hidden)return;let l=i-(Date.now()-n);l<=0&&!localStorage.getItem("waifu-display")&&u(e,6e3,9),r=setTimeout(a,l>0?l:i)}let c=()=>{n=Date.now()};window.addEventListener("pointermove",c,{passive:!0}),window.addEventListener("pointerdown",c,{passive:!0}),window.addEventListener("keydown",c),document.hidden||(r=setTimeout(a,i)),u(z(o.time),7e3,11);let m;for(let l of["mouseover","click"])window.addEventListener(l,({target:g})=>{if(!(g instanceof Element))return;let d=o[l].find(({selector:y})=>g.closest(y));!d||l==="mouseover"&&d.selector===m||(l==="mouseover"&&(m=d.selector),u(x(d.text).replace("{text}",()=>p(g.textContent??"")),4e3,8))});let f=()=>{};f.toString=()=>(u(o.message.console,6e3,9),""),console.log("%c",f),window.addEventListener("copy",()=>u(o.message.copy,6e3,9)),document.addEventListener("visibilitychange",()=>{clearTimeout(r),document.hidden||(c(),r=setTimeout(a,i),localStorage.getItem("waifu-display")||u(o.message.visibilitychange,6e3,9))})}async function w(o){let e=await fetch(o);if(!e.ok)throw new Error(`Failed to load ${o} (HTTP ${e.status})`);return e.json()}var j="/gh/nova1751/live2d-api@cdn-b3ac5ae545e2/",O="https://cdn.jsdelivr.net",T=O+j,q=/\/live2dapi-noa(?:@[^/]+)?\/?$/;function B(o){let e=new URL(o,document.baseURI);return!q.test(e.pathname)||/@1\.[^/]+\/?$/.test(e.pathname)?o:(e.hostname==="cdn.jsdmirror.com"?e.origin:O)+j}var A="我的新衣服好看嘛?",b=o=>Number(localStorage.getItem(o))||0,M=class{constructor(e){this.options=e;this.revision=0;this.loaded=!1;this.useCDN=typeof e.cdnPath=="string";let t=e.modelBaseUrl??(e.cdnPath&&B(e.cdnPath))??e.apiPath;if(typeof t!="string")throw new TypeError("Invalid initWidget argument");this.base=t.endsWith("/")?t:t+"/"}reopen(e){if(this.loaded)window.loadlive2d.show?.(e);else return this.load(void 0,void 0,void 0,e)}cancel(){this.revision++}async fetchCatalog(){let e=this.base+"model_list.json",t=await fetch(e);if(t.status===404&&!this.options.modelBaseUrl&&this.base!==T){let s=await w(T+"model_list.json");return this.base=T,s}if(!t.ok)throw new Error(`Failed to load ${e} (HTTP ${t.status})`);return t.json()}list(){return this.catalog??(this.catalog=this.fetchCatalog().catch(e=>{throw this.catalog=void 0,e}))}async load(e=b("modelId"),t=b("modelTexturesId"),s,i=!1,n=++this.revision,r=!1){let a;if(this.options.modelUrl)a=this.options.modelUrl;else if(this.useCDN){let{models:m}=await this.list();m[e]||(e=0);let f=m[e],l=Array.isArray(f)?f:[f];l[t]||(t=0);let g=r?l[t]:x(l);t=l.indexOf(g),a=this.base+"model/"+g+"/index.json"}else a=this.base+"get/?id="+e+"-"+t;if(n!==this.revision)return;let c=window.loadlive2d("live2d",a,{start:i,coreUrl:this.options.coreUrl});c&&await c,n===this.revision&&(this.options.modelUrl||(localStorage.setItem("modelId",String(e)),localStorage.setItem("modelTexturesId",String(t))),u(s,4e3,10),this.loaded=!0)}async costume(e){if(this.options.modelUrl||!this.useCDN)return;let t=++this.revision,s=b("modelId"),i=(await this.list()).models[s],r=(Array.isArray(i)?i:[i]).findIndex(a=>new URL(this.base+"model/"+a+"/index.json",document.baseURI).href===e);r>=0&&await this.load(s,r,A,!1,t,!0)}async nextModel(e=!1){let t=++this.revision,s=b("modelId");if(this.useCDN){let{models:n,messages:r}=await this.list(),a=(s+1)%n.length;return this.load(a,0,r[a],e,t)}let{model:i}=await w(this.base+"switch/?id="+s);return this.load(i.id,0,i.message,e,t)}async nextTexture(e=!1){let t=++this.revision,s=b("modelId"),i=b("modelTexturesId");if(this.useCDN){let r=(await this.list()).models[s],a=Array.isArray(r)?r.length:1;return this.load(s,i,A,e,t)}let{textures:n}=await w(this.base+"rand_textures/?id="+s+"-"+i);n.id===1&&i===1?u("我还没有其他衣服呢!",4e3,10):await this.load(s,n.id,A,e,t)}};async function H(o){let e=new URL(o,document.baseURI),t=await fetch(e);if(!t.ok)throw new Error("Cannot load catalog: HTTP "+t.status);let s=await t.json();if(s.schemaVersion!==1||!s.models||!s.sources)throw new Error("Unsupported model catalog");let i=new Map,n=Object.keys(s.models).filter(a=>s.models[a].some(c=>c.manifest));function r(a,c){let m=s.models[a]?.find(d=>d.manifest&&(!c||d.source===c));if(!m?.manifest)throw new Error("No model manifest for "+a);let f=new URL(s.sources[m.source].baseUrl,t.url||e);e.hostname==="cdn.jsdmirror.com"&&f.hostname==="cdn.jsdelivr.net"&&f.pathname.startsWith("/gh/nova1751/live2d-api@cdn-")&&(f.hostname=e.hostname);let l=d=>new URL(d.split("/").map(encodeURIComponent).join("/"),f).href,g;if(m.dialogue){let d=i.get(m.source);d||(d=new Map((s.audio?.[m.source]??[]).map(y=>[y.toUpperCase(),l(y)])),i.set(m.source,d)),g={url:l(m.dialogue),audio:d}}return{modelUrl:l(m.manifest),dialogue:g,soundAliases:m.soundAliases}}return{ids:n,resolve:r,legacyIds:s.legacyIds}}var L=class{constructor(e,t){this.url=e;this.options=t;this.sequence=0;this.key="live2d:model:"+e}open(){return this.library??(this.library=H(this.url).catch(e=>{throw this.library=void 0,e}))}async select(e,t){let s=++this.sequence,i=await this.open();if(s!==this.sequence)return;let n=e(i.ids,i.legacyIds),{modelUrl:r,dialogue:a,soundAliases:c}=i.resolve(n);await window.loadlive2d("live2d",r,{start:t,coreUrl:this.options.coreUrl,dialogue:a,soundAliases:c}),s===this.sequence&&(this.active=n,localStorage.setItem(this.key,n),window.dispatchEvent(new CustomEvent("live2d:model",{detail:n})))}load(e,t,s,i=!1){return this.select((n,r)=>{let a=localStorage.getItem(this.key),c=r?.[Number(localStorage.getItem("modelId"))]?.[Number(localStorage.getItem("modelTexturesId"))];return this.options.modelId??(a&&n.includes(a)?a:c&&n.includes(c)?c:n[0])},i)}choose(e){return this.select(()=>e,!1)}cancel(){this.sequence++}reopen(e){if(this.active)window.loadlive2d.show?.(e);else return this.load(void 0,void 0,void 0,e)}character(e){return e.split("/").slice(0,2).join("/")}nextModel(e=!1){return this.select(t=>{let s=[...new Set(t.map(n=>this.character(n)))],i=s[(s.indexOf(this.character(this.active??""))+1)%s.length];return t.find(n=>this.character(n)===i)},e)}nextTexture(e=!1){return this.select(t=>{let s=t.filter(i=>this.character(i)===this.character(this.active??t[0]));return s[Math.floor(Math.random()*s.length)]},e)}async costume(e){let t=await this.open(),s=t.ids.find(i=>t.resolve(i).modelUrl===e);s&&await this.select(()=>s,!1)}};var Y=document.currentScript,_=Y?.dataset.asteroidsUrl??"https://fastly.jsdelivr.net/gh/nova1751/live2d-api@latest/asteroids.js",h=o=>document.getElementById(o);function v(o){console.error("[Live2D]",o);let e=document.getElementById("waifu-status");e&&(e.textContent="加载失败,请检查网络或切换模型后重试。",u(e.textContent,5e3,10))}async function W(){let o=await w("https://v1.hitokoto.cn");u(p(o.hitokoto),6e3,9),setTimeout(()=>{u(`这句一言来自 <span>「${p(String(o.from))}」</span>,是 <span>${p(String(o.creator))}</span> 在 hitokoto.cn 投稿的。`,4e3,9)},6e3)}function J(){if(window.Asteroids)(window.ASTEROIDSPLAYERS??(window.ASTEROIDSPLAYERS=[])).push(new window.Asteroids);else{let o=document.createElement("script");o.src=_,document.head.appendChild(o)}}var N;function $(){clearTimeout(N),localStorage.removeItem("waifu-display"),h("waifu-toggle").setAttribute("tabindex","-1"),h("waifu-toggle").setAttribute("aria-expanded","true"),h("waifu").style.display="",setTimeout(()=>{h("waifu").style.bottom="0"},0)}function E(o){return o.isTrusted&&!!window.loadlive2d.prepareInteraction?.()}function G(){let o=h("waifu").contains(document.activeElement);window.loadlive2d.hide?.(),localStorage.setItem("waifu-display",String(Date.now())),u("愿你有一天能与重要的人重逢。",2e3,11),h("waifu").style.bottom="-500px",N=setTimeout(()=>{h("waifu").style.display="none";let e=h("waifu-toggle");e.removeAttribute("tabindex"),e.setAttribute("aria-expanded","false"),e.classList.add("waifu-toggle-active"),o&&e.focus()},window.matchMedia("(prefers-reduced-motion: reduce)").matches?0:3e3)}function P(o,e,t=!1){sessionStorage.removeItem("waifu-text"),document.body.insertAdjacentHTML("beforeend",`<div id="waifu">
|
|
3
|
+
<div id="waifu-status" role="status" class="waifu-sr-only"></div>
|
|
3
4
|
<div id="waifu-tips"></div>
|
|
4
5
|
<canvas id="live2d" width="800" height="800"></canvas>
|
|
5
6
|
<div id="waifu-tool"></div>
|
|
6
|
-
</div>`)
|
|
7
|
+
</div>`),$(),window.addEventListener("live2d:dialogue",n=>{let{detail:r,playback:a}=n;typeof r=="string"&&U(r,a)}),window.addEventListener("live2d:dialogue-end",n=>{let r=n.detail;r?.playback&&D(r.playback,r.interrupted)}),window.addEventListener("live2d:costume",n=>{let r=n.detail;typeof r=="string"&&e.costume(r).catch(v)});let s={hitokoto:"听一句话",asteroids:"启动小游戏","switch-model":"切换人物","switch-texture":"切换造型",photo:"保存照片",info:"项目信息",quit:"收起看板娘"},i={hitokoto:()=>W().catch(v),asteroids:J,"switch-model":n=>e.nextModel(E(n)).catch(v),"switch-texture":n=>e.nextTexture(E(n)).catch(v),photo:()=>{u("照好了嘛,是不是很可爱呢?",6e3,9),!(window.loadlive2d.capture?.()||!window.Live2D)&&(window.Live2D.captureName="photo.png",window.Live2D.captureFrame=!0)},info:()=>window.open("https://github.com/nova1751/live2d-api"),quit:()=>{e.cancel(),G()}};for(let n of Array.isArray(o.tools)?o.tools:Object.keys(i)){if(o.modelUrl&&(n==="switch-model"||n==="switch-texture")||!Object.prototype.hasOwnProperty.call(i,n))continue;let r=n;h("waifu-tool").insertAdjacentHTML("beforeend",`<button type="button" id="waifu-tool-${r}" aria-label="${s[r]}" title="${s[r]}">${k[r]}</button>`),h("waifu-tool-"+r).addEventListener("click",i[r])}e.load(void 0,void 0,void 0,t).catch(v),w(o.waifuPath).then(R).catch(v)}window.initWidget=(o,e)=>{let t=typeof o=="string"?{waifuPath:o,apiPath:e}:o;if(document.getElementById("waifu-toggle"))return;document.body.insertAdjacentHTML("beforeend",'<button type="button" id="waifu-toggle" aria-label="打开看板娘" aria-controls="waifu"><span>看板娘</span></button>');let s=h("waifu-toggle");s.setAttribute("aria-expanded","false");let i=t.catalogUrl?new L(t.catalogUrl,t):new M(t);i instanceof L&&Object.defineProperty(window,Symbol.for("live2dapi-noa.selectModel"),{configurable:!0,value:async r=>((s.getAttribute("aria-expanded")==="false"||localStorage.getItem("waifu-display"))&&s.click(),i.choose(r))}),s.addEventListener("click",r=>{let a=E(r);s.classList.remove("waifu-toggle-active"),s.hasAttribute("first-time")?(P(t,i,a),s.removeAttribute("first-time")):($(),i.reopen(a)?.catch(v)),document.querySelector("#waifu-tool button")?.focus()});let n=Number(localStorage.getItem("waifu-display"));n&&Date.now()-n<=864e5?(s.setAttribute("first-time","true"),setTimeout(()=>s.classList.add("waifu-toggle-active"),0)):P(t,i)};})();
|
|
@@ -8,7 +8,7 @@ const live2d_path = (() => {
|
|
|
8
8
|
return new URL("../../", url).href;
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
|
-
return false ? "https://unpkg.com/live2dapi-noa@2.
|
|
11
|
+
return false ? "https://unpkg.com/live2dapi-noa@2.1.0/" : "https://cdn.jsdelivr.net/npm/live2dapi-noa@2.1.0/";
|
|
12
12
|
})();
|
|
13
13
|
function loadExternalResource(url, type) {
|
|
14
14
|
let tag;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! Live2D API | Generated from src/ | https://github.com/nova1751/live2d-api */
|
|
2
|
-
"use strict";const live2d_path=(()=>{const e=document.currentScript;if(e?.src){const i=new URL(e.src);if(/\/(?:live2dapi-noa|gh\/nova1751\/live2d-api)(?:@[^/]+)?\/(?:npm|jsdelivr)\/(?:random|sequential)\/autoload(?:\.min)?\.js$/.test(i.pathname))return new URL("../../",i).href}return"https://cdn.jsdelivr.net/npm/live2dapi-noa@2.
|
|
2
|
+
"use strict";const live2d_path=(()=>{const e=document.currentScript;if(e?.src){const i=new URL(e.src);if(/\/(?:live2dapi-noa|gh\/nova1751\/live2d-api)(?:@[^/]+)?\/(?:npm|jsdelivr)\/(?:random|sequential)\/autoload(?:\.min)?\.js$/.test(i.pathname))return new URL("../../",i).href}return"https://cdn.jsdelivr.net/npm/live2dapi-noa@2.1.0/"})();function loadExternalResource(e,i){let n;if(i==="css"){const t=document.createElement("link");t.href=e,t.rel="stylesheet",n=t}else{const t=document.createElement("script");t.src=e,e===live2d_path+"jsdelivr/sequential/waifu-tips.js"&&(t.dataset.asteroidsUrl=live2d_path+"asteroids.js"),n=t}return new Promise((t,s)=>{n.onload=()=>t(e),n.onerror=()=>s(e),document.head.appendChild(n)})}screen.width>=768&&Promise.all([loadExternalResource(live2d_path+"live2d.min.js","js"),loadExternalResource(live2d_path+"jsdelivr/sequential/waifu-tips.js","js")]).then(async()=>{document.body||await new Promise(e=>document.addEventListener("DOMContentLoaded",()=>e(),{once:!0})),window.initWidget({tools:["hitokoto","asteroids","switch-model","switch-texture","photo","info","quit"],cdnPath:live2d_path,waifuPath:live2d_path+"waifu-tips.json"})}).catch(e=>console.error("[Live2D]",e));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/*! Live2D API | Generated from src/ | https://github.com/nova1751/live2d-api */
|
|
2
|
-
"use strict";(()=>{var M={hitokoto:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M512 240c0 114.9-114.6 208-256 208c-37.1 0-72.3-6.4-104.1-17.9c-11.9 8.7-31.3 20.6-54.3 30.6C73.6 471.1 44.7 480 16 480c-6.5 0-12.3-3.9-14.8-9.9c-2.5-6-1.1-12.8 3.4-17.4l0 0 0 0 0 0 0 0 .3-.3c.3-.3 .7-.7 1.3-1.4c1.1-1.2 2.8-3.1 4.9-5.7c4.1-5 9.6-12.4 15.2-21.6c10-16.6 19.5-38.4 21.4-62.9C17.7 326.8 0 285.1 0 240C0 125.1 114.6 32 256 32s256 93.1 256 208z"/></svg>',asteroids:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M498.1 5.6c10.1 7 15.4 19.1 13.5 31.2l-64 416c-1.5 9.7-7.4 18.2-16 23s-18.9 5.4-28 1.6L284 427.7l-68.5 74.1c-8.9 9.7-22.9 12.9-35.2 8.1S160 493.2 160 480V396.4c0-4 1.5-7.8 4.2-10.7L331.8 202.8c5.8-6.3 5.6-16-.4-22s-15.7-6.4-22-.7L106 360.8 17.7 316.6C7.1 311.3 .3 300.7 0 288.9s5.9-22.8 16.1-28.7l448-256c10.7-6.1 23.9-5.5 34 1.4z"/></svg>',"switch-model":'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M399 384.2C376.9 345.8 335.4 320 288 320H224c-47.4 0-88.9 25.8-111 64.2c35.2 39.2 86.2 63.8 143 63.8s107.8-24.7 143-63.8zM0 256a256 256 0 1 1 512 0A256 256 0 1 1 0 256zm256 16a72 72 0 1 0 0-144 72 72 0 1 0 0 144z"/></svg>',"switch-texture":'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M320 64A64 64 0 1 0 192 64a64 64 0 1 0 128 0zm-96 96c-35.3 0-64 28.7-64 64v48c0 17.7 14.3 32 32 32h1.8l11.1 99.5c1.8 16.2 15.5 28.5 31.8 28.5h38.7c16.3 0 30-12.3 31.8-28.5L318.2 304H320c17.7 0 32-14.3 32-32V224c0-35.3-28.7-64-64-64H224zM132.3 394.2c13-2.4 21.7-14.9 19.3-27.9s-14.9-21.7-27.9-19.3c-32.4 5.9-60.9 14.2-82 24.8c-10.5 5.3-20.3 11.7-27.8 19.6C6.4 399.5 0 410.5 0 424c0 21.4 15.5 36.1 29.1 45c14.7 9.6 34.3 17.3 56.4 23.4C130.2 504.7 190.4 512 256 512s125.8-7.3 170.4-19.6c22.1-6.1 41.8-13.8 56.4-23.4c13.7-8.9 29.1-23.6 29.1-45c0-13.5-6.4-24.5-14-32.6c-7.5-7.9-17.3-14.3-27.8-19.6c-21-10.6-49.5-18.9-82-24.8c-13-2.4-25.5 6.3-27.9 19.3s6.3 25.5 19.3 27.9c30.2 5.5 53.7 12.8 69 20.5c3.2 1.6 5.8 3.1 7.9 4.5c3.6 2.4 3.6 7.2 0 9.6c-8.8 5.7-23.1 11.8-43 17.3C374.3 457 318.5 464 256 464s-118.3-7-157.7-17.9c-19.9-5.5-34.2-11.6-43-17.3c-3.6-2.4-3.6-7.2 0-9.6c2.1-1.4 4.8-2.9 7.9-4.5c15.3-7.7 38.8-14.9 69-20.5z"/></svg>',photo:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M220.6 121.2L271.1 96 448 96v96H333.2c-21.9-15.1-48.5-24-77.2-24s-55.2 8.9-77.2 24H64V128H192c9.9 0 19.7-2.3 28.6-6.8zM0 128V416c0 35.3 28.7 64 64 64H448c35.3 0 64-28.7 64-64V96c0-35.3-28.7-64-64-64H271.1c-9.9 0-19.7 2.3-28.6 6.8L192 64H160V48c0-8.8-7.2-16-16-16H80c-8.8 0-16 7.2-16 16l0 16C28.7 64 0 92.7 0 128zM168 304a88 88 0 1 1 176 0 88 88 0 1 1 -176 0z"/></svg>',info:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM216 336h24V272H216c-13.3 0-24-10.7-24-24s10.7-24 24-24h48c13.3 0 24 10.7 24 24v88h8c13.3 0 24 10.7 24 24s-10.7 24-24 24H216c-13.3 0-24-10.7-24-24s10.7-24 24-24zm40-208a32 32 0 1 1 0 64 32 32 0 1 1 0-64z"/></svg>',quit:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.3 256 342.6 150.6z"/></svg>'};function I(t){return Array.isArray(t)?t[Math.floor(Math.random()*t.length)]:t}function u(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var x,y;function C(){clearTimeout(x),sessionStorage.removeItem("waifu-text"),document.getElementById("waifu-tips")?.classList.remove("waifu-tips-active")}function k(t,e){clearTimeout(x),sessionStorage.setItem("waifu-text",String(e));let o=document.getElementById("waifu-tips");o.innerHTML=t,o.classList.add("waifu-tips-active")}function c(t,e,o){!t||y||Number(sessionStorage.getItem("waifu-text"))>o||(k(I(t),o),x=setTimeout(C,e))}function S(t,e){if(!e){c(u(t),5e3,11);return}y=e,k(u(t),11)}function E(t,e){y===t&&(y=void 0,e?C():x=setTimeout(C,1200))}function O(t){if(location.pathname==="/"){let s=new Date().getHours();for(let{hour:n,text:r}of t){let[a,w=a]=n.split("-").map(Number);if(a<=s&&s<=w)return r}}let e=`欢迎阅读<span>「${u(document.title.split(" - ")[0])}」</span>`;if(!document.referrer)return e;let{hostname:o}=new URL(document.referrer);return o===location.hostname?e:`Hello!来自 <span>${u({baidu:"百度",so:"360搜索",google:"谷歌搜索"}[o.split(".")[1]]??o)}</span> 的朋友<br>${e}`}function R(t){let[e,o]=t.split("/").map(Number);return e*100+o}function A(t){let e=[...t.message.default],o=new Date,i=(o.getMonth()+1)*100+o.getDate();for(let{date:l,text:m}of t.seasons){let[d,h=d]=l.split("-").map(R);d<=i&&i<=h&&e.push(I(m).replace("{year}",String(o.getFullYear())))}let s=!1,n,r=()=>{s=!0};window.addEventListener("mousemove",r),window.addEventListener("keydown",r),setInterval(()=>{s?(s=!1,clearInterval(n),n=void 0):n===void 0&&(n=setInterval(()=>c(e,6e3,9),2e4))},1e3),c(O(t.time),7e3,11);let a;for(let l of["mouseover","click"])window.addEventListener(l,({target:m})=>{if(!(m instanceof Element))return;let d=t[l].find(({selector:h})=>m.closest(h));!d||l==="mouseover"&&d.selector===a||(l==="mouseover"&&(a=d.selector),c(I(d.text).replace("{text}",()=>u(m.textContent??"")),4e3,8))});let w=()=>{};w.toString=()=>(c(t.message.console,6e3,9),""),console.log("%c",w),window.addEventListener("copy",()=>c(t.message.copy,6e3,9)),document.addEventListener("visibilitychange",()=>{document.hidden||c(t.message.visibilitychange,6e3,9)})}var D="/gh/nova1751/live2d-api@cdn-b3ac5ae545e2/",j="https://cdn.jsdelivr.net",L=j+D,P=/\/live2dapi-noa(?:@[^/]+)?\/?$/;function H(t){let e=new URL(t,document.baseURI);return!P.test(e.pathname)||/@1\.[^/]+\/?$/.test(e.pathname)?t:(e.hostname==="cdn.jsdmirror.com"?e.origin:j)+D}var T="我的新衣服好看嘛?",p=t=>Number(localStorage.getItem(t))||0;async function v(t){let e=await fetch(t);if(!e.ok)throw new Error(`Failed to load ${t} (HTTP ${e.status})`);return e.json()}var b=class{constructor(e){this.options=e;this.revision=0;this.loaded=!1;this.useCDN=typeof e.cdnPath=="string";let o=e.modelBaseUrl??(e.cdnPath&&H(e.cdnPath))??e.apiPath;if(typeof o!="string")throw new TypeError("Invalid initWidget argument");this.base=o.endsWith("/")?o:o+"/"}reopen(e){if(this.loaded)window.loadlive2d.show?.(e);else return this.load(void 0,void 0,void 0,e)}cancel(){this.revision++}async fetchCatalog(){let e=this.base+"model_list.json",o=await fetch(e);if(o.status===404&&!this.options.modelBaseUrl&&this.base!==L){let i=await v(L+"model_list.json");return this.base=L,i}if(!o.ok)throw new Error(`Failed to load ${e} (HTTP ${o.status})`);return o.json()}list(){return this.catalog??(this.catalog=this.fetchCatalog().catch(e=>{throw this.catalog=void 0,e}))}async load(e=p("modelId"),o=p("modelTexturesId"),i,s=!1,n=++this.revision,r=!1){let a;if(this.options.modelUrl)a=this.options.modelUrl;else if(this.useCDN){let{models:l}=await this.list();l[e]||(e=0);let m=l[e],d=Array.isArray(m)?m:[m];d[o]||(o=0);let h=d[o];o=d.indexOf(h),a=this.base+"model/"+h+"/index.json"}else a=this.base+"get/?id="+e+"-"+o;if(n!==this.revision)return;let w=window.loadlive2d("live2d",a,{start:s,coreUrl:this.options.coreUrl});w&&await w,n===this.revision&&(this.options.modelUrl||(localStorage.setItem("modelId",String(e)),localStorage.setItem("modelTexturesId",String(o))),c(i,4e3,10),this.loaded=!0)}async costume(e){if(this.options.modelUrl||!this.useCDN)return;let o=++this.revision,i=p("modelId"),s=(await this.list()).models[i],r=(Array.isArray(s)?s:[s]).findIndex(a=>new URL(this.base+"model/"+a+"/index.json",document.baseURI).href===e);r>=0&&await this.load(i,r,T,!1,o,!0)}async nextModel(e=!1){let o=++this.revision,i=p("modelId");if(this.useCDN){let{models:n,messages:r}=await this.list(),a=(i+1)%n.length;return this.load(a,0,r[a],e,o)}let{model:s}=await v(this.base+"switch/?id="+i);return this.load(s.id,0,s.message,e,o)}async nextTexture(e=!1){let o=++this.revision,i=p("modelId"),s=p("modelTexturesId");if(this.useCDN){let r=(await this.list()).models[i],a=Array.isArray(r)?r.length:1;return this.load(i,(s+1)%a,T,e,o)}let{textures:n}=await v(this.base+"rand_textures/?id="+i+"-"+s);n.id===1&&s===1?c("我还没有其他衣服呢!",4e3,10):await this.load(i,n.id,T,e,o)}};var z=document.currentScript,$=z?.dataset.asteroidsUrl??"https://fastly.jsdelivr.net/gh/nova1751/live2d-api@latest/asteroids.js",f=t=>document.getElementById(t),g=t=>console.error("[Live2D]",t);async function N(){let t=await v("https://v1.hitokoto.cn");c(u(t.hitokoto),6e3,9),setTimeout(()=>{c(`这句一言来自 <span>「${u(String(t.from))}」</span>,是 <span>${u(String(t.creator))}</span> 在 hitokoto.cn 投稿的。`,4e3,9)},6e3)}function Y(){if(window.Asteroids)(window.ASTEROIDSPLAYERS??(window.ASTEROIDSPLAYERS=[])).push(new window.Asteroids);else{let t=document.createElement("script");t.src=$,document.head.appendChild(t)}}function U(){localStorage.removeItem("waifu-display"),f("waifu").style.display="",setTimeout(()=>{f("waifu").style.bottom="0"},0)}function F(t){return t.isTrusted&&!!window.loadlive2d.prepareInteraction?.()}function V(){window.loadlive2d.hide?.(),localStorage.setItem("waifu-display",String(Date.now())),c("愿你有一天能与重要的人重逢。",2e3,11),f("waifu").style.bottom="-500px",setTimeout(()=>{f("waifu").style.display="none",f("waifu-toggle").classList.add("waifu-toggle-active")},3e3)}function B(t,e,o=!1){sessionStorage.removeItem("waifu-text"),document.body.insertAdjacentHTML("beforeend",`<div id="waifu">
|
|
2
|
+
"use strict";(()=>{var E={hitokoto:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M512 240c0 114.9-114.6 208-256 208c-37.1 0-72.3-6.4-104.1-17.9c-11.9 8.7-31.3 20.6-54.3 30.6C73.6 471.1 44.7 480 16 480c-6.5 0-12.3-3.9-14.8-9.9c-2.5-6-1.1-12.8 3.4-17.4l0 0 0 0 0 0 0 0 .3-.3c.3-.3 .7-.7 1.3-1.4c1.1-1.2 2.8-3.1 4.9-5.7c4.1-5 9.6-12.4 15.2-21.6c10-16.6 19.5-38.4 21.4-62.9C17.7 326.8 0 285.1 0 240C0 125.1 114.6 32 256 32s256 93.1 256 208z"/></svg>',asteroids:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M498.1 5.6c10.1 7 15.4 19.1 13.5 31.2l-64 416c-1.5 9.7-7.4 18.2-16 23s-18.9 5.4-28 1.6L284 427.7l-68.5 74.1c-8.9 9.7-22.9 12.9-35.2 8.1S160 493.2 160 480V396.4c0-4 1.5-7.8 4.2-10.7L331.8 202.8c5.8-6.3 5.6-16-.4-22s-15.7-6.4-22-.7L106 360.8 17.7 316.6C7.1 311.3 .3 300.7 0 288.9s5.9-22.8 16.1-28.7l448-256c10.7-6.1 23.9-5.5 34 1.4z"/></svg>',"switch-model":'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M399 384.2C376.9 345.8 335.4 320 288 320H224c-47.4 0-88.9 25.8-111 64.2c35.2 39.2 86.2 63.8 143 63.8s107.8-24.7 143-63.8zM0 256a256 256 0 1 1 512 0A256 256 0 1 1 0 256zm256 16a72 72 0 1 0 0-144 72 72 0 1 0 0 144z"/></svg>',"switch-texture":'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M320 64A64 64 0 1 0 192 64a64 64 0 1 0 128 0zm-96 96c-35.3 0-64 28.7-64 64v48c0 17.7 14.3 32 32 32h1.8l11.1 99.5c1.8 16.2 15.5 28.5 31.8 28.5h38.7c16.3 0 30-12.3 31.8-28.5L318.2 304H320c17.7 0 32-14.3 32-32V224c0-35.3-28.7-64-64-64H224zM132.3 394.2c13-2.4 21.7-14.9 19.3-27.9s-14.9-21.7-27.9-19.3c-32.4 5.9-60.9 14.2-82 24.8c-10.5 5.3-20.3 11.7-27.8 19.6C6.4 399.5 0 410.5 0 424c0 21.4 15.5 36.1 29.1 45c14.7 9.6 34.3 17.3 56.4 23.4C130.2 504.7 190.4 512 256 512s125.8-7.3 170.4-19.6c22.1-6.1 41.8-13.8 56.4-23.4c13.7-8.9 29.1-23.6 29.1-45c0-13.5-6.4-24.5-14-32.6c-7.5-7.9-17.3-14.3-27.8-19.6c-21-10.6-49.5-18.9-82-24.8c-13-2.4-25.5 6.3-27.9 19.3s6.3 25.5 19.3 27.9c30.2 5.5 53.7 12.8 69 20.5c3.2 1.6 5.8 3.1 7.9 4.5c3.6 2.4 3.6 7.2 0 9.6c-8.8 5.7-23.1 11.8-43 17.3C374.3 457 318.5 464 256 464s-118.3-7-157.7-17.9c-19.9-5.5-34.2-11.6-43-17.3c-3.6-2.4-3.6-7.2 0-9.6c2.1-1.4 4.8-2.9 7.9-4.5c15.3-7.7 38.8-14.9 69-20.5z"/></svg>',photo:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M220.6 121.2L271.1 96 448 96v96H333.2c-21.9-15.1-48.5-24-77.2-24s-55.2 8.9-77.2 24H64V128H192c9.9 0 19.7-2.3 28.6-6.8zM0 128V416c0 35.3 28.7 64 64 64H448c35.3 0 64-28.7 64-64V96c0-35.3-28.7-64-64-64H271.1c-9.9 0-19.7 2.3-28.6 6.8L192 64H160V48c0-8.8-7.2-16-16-16H80c-8.8 0-16 7.2-16 16l0 16C28.7 64 0 92.7 0 128zM168 304a88 88 0 1 1 176 0 88 88 0 1 1 -176 0z"/></svg>',info:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM216 336h24V272H216c-13.3 0-24-10.7-24-24s10.7-24 24-24h48c13.3 0 24 10.7 24 24v88h8c13.3 0 24 10.7 24 24s-10.7 24-24 24H216c-13.3 0-24-10.7-24-24s10.7-24 24-24zm40-208a32 32 0 1 1 0 64 32 32 0 1 1 0-64z"/></svg>',quit:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.3 256 342.6 150.6z"/></svg>'};function M(o){return Array.isArray(o)?o[Math.floor(Math.random()*o.length)]:o}function p(o){return o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var I,L;function S(){clearTimeout(I),sessionStorage.removeItem("waifu-text"),document.getElementById("waifu-tips")?.classList.remove("waifu-tips-active")}function F(o,e){clearTimeout(I),sessionStorage.setItem("waifu-text",String(e));let t=document.getElementById("waifu-tips");t.innerHTML=o,t.classList.add("waifu-tips-active")}function u(o,e,t){!o||L||Number(sessionStorage.getItem("waifu-text"))>t||(F(M(o),t),I=setTimeout(S,e))}function U(o,e){if(!e){u(p(o),5e3,11);return}L=e,F(p(o),11)}function D(o,e){L===o&&(L=void 0,e?S():I=setTimeout(S,1200))}function z(o){if(location.pathname==="/"){let i=new Date().getHours();for(let{hour:n,text:r}of o){let[a,c=a]=n.split("-").map(Number);if(a<=i&&i<=c)return r}}let e=`欢迎阅读<span>「${p(document.title.split(" - ")[0])}」</span>`;if(!document.referrer)return e;let{hostname:t}=new URL(document.referrer);return t===location.hostname?e:`Hello!来自 <span>${p({baidu:"百度",so:"360搜索",google:"谷歌搜索"}[t.split(".")[1]]??t)}</span> 的朋友<br>${e}`}function V(o){let[e,t]=o.split("/").map(Number);return e*100+t}function R(o){let e=[...o.message.default],t=new Date,s=(t.getMonth()+1)*100+t.getDate();for(let{date:l,text:g}of o.seasons){let[d,y=d]=l.split("-").map(V);d<=s&&s<=y&&e.push(M(g).replace("{year}",String(t.getFullYear())))}let i=2e4,n=Date.now(),r;function a(){if(document.hidden)return;let l=i-(Date.now()-n);l<=0&&!localStorage.getItem("waifu-display")&&u(e,6e3,9),r=setTimeout(a,l>0?l:i)}let c=()=>{n=Date.now()};window.addEventListener("pointermove",c,{passive:!0}),window.addEventListener("pointerdown",c,{passive:!0}),window.addEventListener("keydown",c),document.hidden||(r=setTimeout(a,i)),u(z(o.time),7e3,11);let m;for(let l of["mouseover","click"])window.addEventListener(l,({target:g})=>{if(!(g instanceof Element))return;let d=o[l].find(({selector:y})=>g.closest(y));!d||l==="mouseover"&&d.selector===m||(l==="mouseover"&&(m=d.selector),u(M(d.text).replace("{text}",()=>p(g.textContent??"")),4e3,8))});let f=()=>{};f.toString=()=>(u(o.message.console,6e3,9),""),console.log("%c",f),window.addEventListener("copy",()=>u(o.message.copy,6e3,9)),document.addEventListener("visibilitychange",()=>{clearTimeout(r),document.hidden||(c(),r=setTimeout(a,i),localStorage.getItem("waifu-display")||u(o.message.visibilitychange,6e3,9))})}async function w(o){let e=await fetch(o);if(!e.ok)throw new Error(`Failed to load ${o} (HTTP ${e.status})`);return e.json()}var j="/gh/nova1751/live2d-api@cdn-b3ac5ae545e2/",O="https://cdn.jsdelivr.net",C=O+j,q=/\/live2dapi-noa(?:@[^/]+)?\/?$/;function B(o){let e=new URL(o,document.baseURI);return!q.test(e.pathname)||/@1\.[^/]+\/?$/.test(e.pathname)?o:(e.hostname==="cdn.jsdmirror.com"?e.origin:O)+j}var k="我的新衣服好看嘛?",b=o=>Number(localStorage.getItem(o))||0,T=class{constructor(e){this.options=e;this.revision=0;this.loaded=!1;this.useCDN=typeof e.cdnPath=="string";let t=e.modelBaseUrl??(e.cdnPath&&B(e.cdnPath))??e.apiPath;if(typeof t!="string")throw new TypeError("Invalid initWidget argument");this.base=t.endsWith("/")?t:t+"/"}reopen(e){if(this.loaded)window.loadlive2d.show?.(e);else return this.load(void 0,void 0,void 0,e)}cancel(){this.revision++}async fetchCatalog(){let e=this.base+"model_list.json",t=await fetch(e);if(t.status===404&&!this.options.modelBaseUrl&&this.base!==C){let s=await w(C+"model_list.json");return this.base=C,s}if(!t.ok)throw new Error(`Failed to load ${e} (HTTP ${t.status})`);return t.json()}list(){return this.catalog??(this.catalog=this.fetchCatalog().catch(e=>{throw this.catalog=void 0,e}))}async load(e=b("modelId"),t=b("modelTexturesId"),s,i=!1,n=++this.revision,r=!1){let a;if(this.options.modelUrl)a=this.options.modelUrl;else if(this.useCDN){let{models:m}=await this.list();m[e]||(e=0);let f=m[e],l=Array.isArray(f)?f:[f];l[t]||(t=0);let g=l[t];t=l.indexOf(g),a=this.base+"model/"+g+"/index.json"}else a=this.base+"get/?id="+e+"-"+t;if(n!==this.revision)return;let c=window.loadlive2d("live2d",a,{start:i,coreUrl:this.options.coreUrl});c&&await c,n===this.revision&&(this.options.modelUrl||(localStorage.setItem("modelId",String(e)),localStorage.setItem("modelTexturesId",String(t))),u(s,4e3,10),this.loaded=!0)}async costume(e){if(this.options.modelUrl||!this.useCDN)return;let t=++this.revision,s=b("modelId"),i=(await this.list()).models[s],r=(Array.isArray(i)?i:[i]).findIndex(a=>new URL(this.base+"model/"+a+"/index.json",document.baseURI).href===e);r>=0&&await this.load(s,r,k,!1,t,!0)}async nextModel(e=!1){let t=++this.revision,s=b("modelId");if(this.useCDN){let{models:n,messages:r}=await this.list(),a=(s+1)%n.length;return this.load(a,0,r[a],e,t)}let{model:i}=await w(this.base+"switch/?id="+s);return this.load(i.id,0,i.message,e,t)}async nextTexture(e=!1){let t=++this.revision,s=b("modelId"),i=b("modelTexturesId");if(this.useCDN){let r=(await this.list()).models[s],a=Array.isArray(r)?r.length:1;return this.load(s,(i+1)%a,k,e,t)}let{textures:n}=await w(this.base+"rand_textures/?id="+s+"-"+i);n.id===1&&i===1?u("我还没有其他衣服呢!",4e3,10):await this.load(s,n.id,k,e,t)}};async function H(o){let e=new URL(o,document.baseURI),t=await fetch(e);if(!t.ok)throw new Error("Cannot load catalog: HTTP "+t.status);let s=await t.json();if(s.schemaVersion!==1||!s.models||!s.sources)throw new Error("Unsupported model catalog");let i=new Map,n=Object.keys(s.models).filter(a=>s.models[a].some(c=>c.manifest));function r(a,c){let m=s.models[a]?.find(d=>d.manifest&&(!c||d.source===c));if(!m?.manifest)throw new Error("No model manifest for "+a);let f=new URL(s.sources[m.source].baseUrl,t.url||e);e.hostname==="cdn.jsdmirror.com"&&f.hostname==="cdn.jsdelivr.net"&&f.pathname.startsWith("/gh/nova1751/live2d-api@cdn-")&&(f.hostname=e.hostname);let l=d=>new URL(d.split("/").map(encodeURIComponent).join("/"),f).href,g;if(m.dialogue){let d=i.get(m.source);d||(d=new Map((s.audio?.[m.source]??[]).map(y=>[y.toUpperCase(),l(y)])),i.set(m.source,d)),g={url:l(m.dialogue),audio:d}}return{modelUrl:l(m.manifest),dialogue:g,soundAliases:m.soundAliases}}return{ids:n,resolve:r,legacyIds:s.legacyIds}}var x=class{constructor(e,t){this.url=e;this.options=t;this.sequence=0;this.key="live2d:model:"+e}open(){return this.library??(this.library=H(this.url).catch(e=>{throw this.library=void 0,e}))}async select(e,t){let s=++this.sequence,i=await this.open();if(s!==this.sequence)return;let n=e(i.ids,i.legacyIds),{modelUrl:r,dialogue:a,soundAliases:c}=i.resolve(n);await window.loadlive2d("live2d",r,{start:t,coreUrl:this.options.coreUrl,dialogue:a,soundAliases:c}),s===this.sequence&&(this.active=n,localStorage.setItem(this.key,n),window.dispatchEvent(new CustomEvent("live2d:model",{detail:n})))}load(e,t,s,i=!1){return this.select((n,r)=>{let a=localStorage.getItem(this.key),c=r?.[Number(localStorage.getItem("modelId"))]?.[Number(localStorage.getItem("modelTexturesId"))];return this.options.modelId??(a&&n.includes(a)?a:c&&n.includes(c)?c:n[0])},i)}choose(e){return this.select(()=>e,!1)}cancel(){this.sequence++}reopen(e){if(this.active)window.loadlive2d.show?.(e);else return this.load(void 0,void 0,void 0,e)}character(e){return e.split("/").slice(0,2).join("/")}nextModel(e=!1){return this.select(t=>{let s=[...new Set(t.map(n=>this.character(n)))],i=s[(s.indexOf(this.character(this.active??""))+1)%s.length];return t.find(n=>this.character(n)===i)},e)}nextTexture(e=!1){return this.select(t=>{let s=t.filter(i=>this.character(i)===this.character(this.active??t[0]));return s[(s.indexOf(this.active??"")+1)%s.length]},e)}async costume(e){let t=await this.open(),s=t.ids.find(i=>t.resolve(i).modelUrl===e);s&&await this.select(()=>s,!1)}};var Y=document.currentScript,_=Y?.dataset.asteroidsUrl??"https://fastly.jsdelivr.net/gh/nova1751/live2d-api@latest/asteroids.js",h=o=>document.getElementById(o);function v(o){console.error("[Live2D]",o);let e=document.getElementById("waifu-status");e&&(e.textContent="加载失败,请检查网络或切换模型后重试。",u(e.textContent,5e3,10))}async function W(){let o=await w("https://v1.hitokoto.cn");u(p(o.hitokoto),6e3,9),setTimeout(()=>{u(`这句一言来自 <span>「${p(String(o.from))}」</span>,是 <span>${p(String(o.creator))}</span> 在 hitokoto.cn 投稿的。`,4e3,9)},6e3)}function J(){if(window.Asteroids)(window.ASTEROIDSPLAYERS??(window.ASTEROIDSPLAYERS=[])).push(new window.Asteroids);else{let o=document.createElement("script");o.src=_,document.head.appendChild(o)}}var N;function $(){clearTimeout(N),localStorage.removeItem("waifu-display"),h("waifu-toggle").setAttribute("tabindex","-1"),h("waifu-toggle").setAttribute("aria-expanded","true"),h("waifu").style.display="",setTimeout(()=>{h("waifu").style.bottom="0"},0)}function A(o){return o.isTrusted&&!!window.loadlive2d.prepareInteraction?.()}function G(){let o=h("waifu").contains(document.activeElement);window.loadlive2d.hide?.(),localStorage.setItem("waifu-display",String(Date.now())),u("愿你有一天能与重要的人重逢。",2e3,11),h("waifu").style.bottom="-500px",N=setTimeout(()=>{h("waifu").style.display="none";let e=h("waifu-toggle");e.removeAttribute("tabindex"),e.setAttribute("aria-expanded","false"),e.classList.add("waifu-toggle-active"),o&&e.focus()},window.matchMedia("(prefers-reduced-motion: reduce)").matches?0:3e3)}function P(o,e,t=!1){sessionStorage.removeItem("waifu-text"),document.body.insertAdjacentHTML("beforeend",`<div id="waifu">
|
|
3
|
+
<div id="waifu-status" role="status" class="waifu-sr-only"></div>
|
|
3
4
|
<div id="waifu-tips"></div>
|
|
4
5
|
<canvas id="live2d" width="800" height="800"></canvas>
|
|
5
6
|
<div id="waifu-tool"></div>
|
|
6
|
-
</div>`)
|
|
7
|
+
</div>`),$(),window.addEventListener("live2d:dialogue",n=>{let{detail:r,playback:a}=n;typeof r=="string"&&U(r,a)}),window.addEventListener("live2d:dialogue-end",n=>{let r=n.detail;r?.playback&&D(r.playback,r.interrupted)}),window.addEventListener("live2d:costume",n=>{let r=n.detail;typeof r=="string"&&e.costume(r).catch(v)});let s={hitokoto:"听一句话",asteroids:"启动小游戏","switch-model":"切换人物","switch-texture":"切换造型",photo:"保存照片",info:"项目信息",quit:"收起看板娘"},i={hitokoto:()=>W().catch(v),asteroids:J,"switch-model":n=>e.nextModel(A(n)).catch(v),"switch-texture":n=>e.nextTexture(A(n)).catch(v),photo:()=>{u("照好了嘛,是不是很可爱呢?",6e3,9),!(window.loadlive2d.capture?.()||!window.Live2D)&&(window.Live2D.captureName="photo.png",window.Live2D.captureFrame=!0)},info:()=>window.open("https://github.com/nova1751/live2d-api"),quit:()=>{e.cancel(),G()}};for(let n of Array.isArray(o.tools)?o.tools:Object.keys(i)){if(o.modelUrl&&(n==="switch-model"||n==="switch-texture")||!Object.prototype.hasOwnProperty.call(i,n))continue;let r=n;h("waifu-tool").insertAdjacentHTML("beforeend",`<button type="button" id="waifu-tool-${r}" aria-label="${s[r]}" title="${s[r]}">${E[r]}</button>`),h("waifu-tool-"+r).addEventListener("click",i[r])}e.load(void 0,void 0,void 0,t).catch(v),w(o.waifuPath).then(R).catch(v)}window.initWidget=(o,e)=>{let t=typeof o=="string"?{waifuPath:o,apiPath:e}:o;if(document.getElementById("waifu-toggle"))return;document.body.insertAdjacentHTML("beforeend",'<button type="button" id="waifu-toggle" aria-label="打开看板娘" aria-controls="waifu"><span>看板娘</span></button>');let s=h("waifu-toggle");s.setAttribute("aria-expanded","false");let i=t.catalogUrl?new x(t.catalogUrl,t):new T(t);i instanceof x&&Object.defineProperty(window,Symbol.for("live2dapi-noa.selectModel"),{configurable:!0,value:async r=>((s.getAttribute("aria-expanded")==="false"||localStorage.getItem("waifu-display"))&&s.click(),i.choose(r))}),s.addEventListener("click",r=>{let a=A(r);s.classList.remove("waifu-toggle-active"),s.hasAttribute("first-time")?(P(t,i,a),s.removeAttribute("first-time")):($(),i.reopen(a)?.catch(v)),document.querySelector("#waifu-tool button")?.focus()});let n=Number(localStorage.getItem("waifu-display"));n&&Date.now()-n<=864e5?(s.setAttribute("first-time","true"),setTimeout(()=>s.classList.add("waifu-toggle-active"),0)):P(t,i)};})();
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface ModelSource {
|
|
2
|
+
baseUrl: string;
|
|
3
|
+
}
|
|
4
|
+
export interface ModelVariant {
|
|
5
|
+
source: string;
|
|
6
|
+
manifest?: string;
|
|
7
|
+
dialogue?: string;
|
|
8
|
+
soundAliases?: Record<string, string>;
|
|
9
|
+
}
|
|
10
|
+
export interface ModelCatalog {
|
|
11
|
+
schemaVersion: 1;
|
|
12
|
+
legacyIds?: string[][];
|
|
13
|
+
sources: Record<string, ModelSource>;
|
|
14
|
+
models: Record<string, ModelVariant[]>;
|
|
15
|
+
audio?: Record<string, string[]>;
|
|
16
|
+
}
|
|
17
|
+
export interface DialogueSource {
|
|
18
|
+
url: string;
|
|
19
|
+
audio: ReadonlyMap<string, string>;
|
|
20
|
+
}
|
|
21
|
+
export declare function loadModelCatalog(input: string | URL): Promise<{
|
|
22
|
+
ids: string[];
|
|
23
|
+
resolve: (id: string, source?: string) => {
|
|
24
|
+
modelUrl: string;
|
|
25
|
+
dialogue: DialogueSource | undefined;
|
|
26
|
+
soundAliases: Record<string, string> | undefined;
|
|
27
|
+
};
|
|
28
|
+
legacyIds: string[][] | undefined;
|
|
29
|
+
}>;
|