ide на основе vs code · VibeGit
ide на основе vs code Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
krutaya-ide-na-osnove-vs-code / src / vs / workbench / contrib / chat / browser / chatPetService.ts 449 строк · изменён 14 нояб., 04:52
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
import { status } from '../../../../base/browser/ui/aria/aria.js' ;
import { Emitter, Event } from '../../../../base/common/event.js' ;
import { Disposable } from '../../../../base/common/lifecycle.js' ;
import { IObservable, observableValue, transaction } from '../../../../base/common/observable.js' ;
import { localize } from '../../../../nls.js' ;
import { RawContextKey } from '../../../../platform/contextkey/common/contextkey.js' ;
import { createDecorator } from '../../../../platform/instantiation/common/instantiation.js'
ILogService
product
IStorageService StorageScope StorageTarget
ITelemetryService
allChatPetAchievements chatPetAchievements ChatPetAccessoryId ChatPetAchievementId ChatPetAchievementIds getChatPetAchievementForAccessory isChatPetAccessoryId isChatPetAchievementEnabled isChatPetAchievementId
ChatPetContextKeys
enabled
enabled
source
owner
comment
enabled classification purpose comment
source classification purpose comment
configuredVariant productQuality ChatPetVariant
configuredVariant configuredVariant
configuredVariant
productQuality
storedScale
scale storedScale Number Number storedScale
Number scale scale scale
storedPosition
position storedPosition Number Number storedPosition
Number position Math Math position
IChatPetService
_serviceBrand
enabled IObservable
variant IObservable ChatPetVariant
onTheRun IObservable
scale IObservable
unlockedAchievements IObservable ChatPetAchievementId
unseenAchievements IObservable ChatPetAchievementId
selectedAccessory IObservable ChatPetAccessoryId
onDidUnlockAchievement Event ChatPetAchievementId
horizontalPosition IObservable
variant ChatPetVariant
onTheRun
scale
id ChatPetAchievementId
id ChatPetAchievementId
id ChatPetAccessoryId
position
_serviceBrand
_enabled
enabled IObservable
_variant
variant IObservable ChatPetVariant
_onTheRun
onTheRun IObservable
_scale
scale IObservable
_unlockedAchievements
unlockedAchievements IObservable ChatPetAchievementId
_unseenAchievements
unseenAchievements IObservable ChatPetAchievementId
_selectedAccessory
selectedAccessory IObservable ChatPetAccessoryId
_onDidUnlockAchievement
onDidUnlockAchievement _onDidUnlockAchievement event
lastInvalidStoredAccessory
locallyUnlockingAchievement
_horizontalPosition
horizontalPosition IObservable
storageService IStorageService
telemetryService ITelemetryService
logService ILogService
_enabled storageService StorageScope
enabled _enabled
_variant storageService StorageScope product quality
variant _variant
_onTheRun storageService StorageScope
onTheRun _onTheRun
_scale storageService StorageScope
scale _scale
_unlockedAchievements
unlockedAchievements _unlockedAchievements
_unseenAchievements
unseenAchievements _unseenAchievements
_selectedAccessory
selectedAccessory _selectedAccessory
_horizontalPosition storageService StorageScope
horizontalPosition _horizontalPosition
storageService StorageScope _store
storageService StorageScope
storageService StorageScope _store
_variant storageService StorageScope product quality
storageService StorageScope _store
_onTheRun storageService StorageScope
achievement allChatPetAchievements
storageService StorageScope achievement id _store
locallyUnlockingAchievement
storageService StorageScope achievement id _store
storageService StorageScope _store
storageService StorageScope _store
_scale storageService StorageScope
storageService StorageScope _store
_horizontalPosition storageService StorageScope
_enabled
enabled _enabled
enabled
storageService enabled StorageScope StorageTarget
enabled
enabled
enabled
enabled _enabled
_enabled enabled
enabled
enabled source ChatPetEnablementEvent
telemetryService enabled source
variant ChatPetVariant
_variant variant
storageService variant StorageScope StorageTarget
variant
onTheRun
_onTheRun onTheRun
storageService onTheRun StorageScope StorageTarget
onTheRun
scale
_scale scale
storageService scale StorageScope StorageTarget
_scale
storageService StorageScope
position
normalizedPosition Math Math position
_horizontalPosition normalizedPosition
storageService normalizedPosition StorageScope StorageTarget
id ChatPetAchievementId
id
id
_enabled
id
locallyUnlockingAchievement
storageService id StorageScope StorageTarget
locallyUnlockingAchievement
_onDidUnlockAchievement id
id ChatPetAchievementId
_unseenAchievements id
storageService id StorageScope StorageTarget
id ChatPetAccessoryId
id
id
achievement id
achievement enabled
_unlockedAchievements achievement id
storageService id StorageScope StorageTarget
storageService StorageScope
storageService StorageScope
lastInvalidStoredAccessory
_selectedAccessory id
locallyUnlockingAchievement
achievement allChatPetAchievements
key achievement id
storageService key StorageScope
storageService key StorageScope
seenKey achievement id
storageService seenKey StorageScope
storageService seenKey StorageScope
storageService StorageScope
storageService StorageScope
storageService StorageScope
storageService StorageScope
storageService StorageScope
storageService StorageScope
storageService StorageScope
storageService StorageScope
locallyUnlockingAchievement
tx
_unlockedAchievements tx
_unseenAchievements tx
_selectedAccessory tx
id ChatPetAchievementId
id ChatPetAchievementId
version storageService StorageScope
version
id storageService StorageScope
ChatPetAchievementIds RequestRevision
ChatPetAchievementIds ModelSwitch
storageService StorageScope StorageTarget
version storageService StorageScope
version
localUnlockedAchievements allChatPetAchievements
achievement storageService achievement id StorageScope
achievement achievement id
checkpointRestoreUnlocked storageService StorageScope
chatForkUnlocked storageService StorageScope
localAccessory storageService StorageScope
id localUnlockedAchievements
storageService id StorageScope StorageTarget
checkpointRestoreUnlocked
chatForkUnlocked
localUnlockedAchievements ChatPetAchievementIds RequestRevision
localUnlockedAchievements ChatPetAchievementIds ModelSwitch
localAccessory storageService StorageScope
storageService localAccessory StorageScope StorageTarget
storageService StorageScope StorageTarget
checkpointRestoreUnlocked chatForkUnlocked requestRevisionUnlocked modelSwitchUnlocked
checkpointRestoreUnlocked chatForkUnlocked
storageService ChatPetAchievementIds FirstChatMessage StorageScope StorageTarget
requestRevisionUnlocked
storageService ChatPetAchievementIds ChatOutputCopied StorageScope StorageTarget
modelSwitchUnlocked
storageService ChatPetAchievementIds QueueOrSteeringMessage StorageScope StorageTarget
ChatPetAchievementId
chatPetAchievements
achievement achievement id
achievement achievement id
id ChatPetAchievementId
achievementKey id
storageService achievementKey StorageScope
storageService achievementKey StorageScope
fireUnlockEvents
previousAchievements _unlockedAchievements
unlockedAchievements
previousAchievements unlockedAchievements
_unlockedAchievements unlockedAchievements
fireUnlockEvents
previous previousAchievements
id unlockedAchievements
previous id
_onDidUnlockAchievement id
ChatPetAchievementId
unlocked _unlockedAchievements
chatPetAchievements
achievement unlocked achievement id storageService achievement id StorageScope
achievement achievement id
unseenAchievements
_unseenAchievements unseenAchievements
_unseenAchievements unseenAchievements
first ChatPetAchievementId second ChatPetAchievementId
first length second length first id index id second index
_selectedAccessory
ChatPetAccessoryId
storedAccessory storageService StorageScope
storageService StorageScope
storedAccessory
lastInvalidStoredAccessory
storedAccessory
achievement storedAccessory
_unlockedAchievements achievement id
lastInvalidStoredAccessory
storedAccessory
lastInvalidStoredAccessory storedAccessory
lastInvalidStoredAccessory storedAccessory
logService
;
import
{
}
from
'../../../../platform/log/common/log.js'
;
import
from
'../../../../platform/product/common/product.js'
;
import
{
,
,
}
from
'../../../../platform/storage/common/storage.js'
;
import
{
}
from
'../../../../platform/telemetry/common/telemetry.js'
;
import
{
,
,
,
,
,
,
,
,
}
from
'./chatPetAchievements.js'
;
const
CHAT_PET_ENABLED_STORAGE_KEY
=
'chat.vscodePet.enabled'
;
const
CHAT_PET_VARIANT_STORAGE_KEY
=
'chat.vscodePet.variant'
;
const
CHAT_PET_ON_THE_RUN_STORAGE_KEY
=
'chat.vscodePet.onTheRun'
;
const
CHAT_PET_ACCESSORY_STORAGE_KEY
=
'chat.vscodePet.accessory'
;
const
CHAT_PET_ACHIEVEMENT_SEEN_STORAGE_PREFIX
=
'chat.vscodePet.achievementSeen.'
;
const
CHAT_PET_ACHIEVEMENT_CATALOG_VERSION_STORAGE_KEY
=
'chat.vscodePet.achievementCatalogVersion'
;
const
CHAT_PET_ACHIEVEMENT_CATALOG_VERSION
=
4
;
const
CHAT_PET_LOCAL_ACHIEVEMENT_MIGRATION_VERSION_STORAGE_KEY
=
'chat.vscodePet.localAchievementMigrationVersion'
;
const
CHAT_PET_LOCAL_ACHIEVEMENT_MIGRATION_VERSION
=
1
;
const
CHAT_PET_SCALE_STORAGE_KEY
=
'chat.vscodePet.scale'
;
const
CHAT_PET_HORIZONTAL_POSITION_STORAGE_KEY
=
'chat.vscodePet.horizontalPosition'
;
export
const
CHAT_PET_DEFAULT_SCALE
=
1
;
export
type
ChatPetVariant
=
'stable'
|
'insiders'
;
export
const
=
{
:
new
RawContextKey< boolean >
(
'chatPetEnabled'
,
false
,
localize
(
'chatPet.context.enabled'
,
"Whether the VS Code pet is enabled"
)
)
,
}
;
type
ChatPetEnablementEvent
=
{
:
boolean
;
:
'startup'
|
'change'
;
}
;
type
ChatPetEnablementClassification
=
{
:
'justschen'
;
:
'Tracks VS Code pet enablement so adoption can be measured.'
;
:
{
:
'SystemMetaData'
;
:
'FeatureInsight'
;
:
'Whether the VS Code pet is enabled.'
}
;
:
{
:
'SystemMetaData'
;
:
'FeatureInsight'
;
:
'Whether the state was observed at startup or changed while VS Code was running.'
}
;
}
;
export
function
getChatPetVariant
(
:
string
|
undefined
,
:
string
|
undefined
)
:
{
if
(
===
'stable'
||
===
'insiders'
)
{
return
;
}
return
===
'stable'
?
'stable'
:
'insiders'
;
}
function
getChatPetScale
(
:
string
|
undefined
)
:
number
{
const
=
===
undefined
?
.
NaN
:
.
parseFloat
(
)
;
return
.
isFinite
(
)
&&
>
0
?
:
CHAT_PET_DEFAULT_SCALE
;
}
function
getChatPetHorizontalPosition
(
:
string
|
undefined
)
:
number
|
undefined
{
const
=
===
undefined
?
.
NaN
:
.
parseFloat
(
)
;
return
.
isFinite
(
)
?
.
max
(
0
,
.
min
(
1
,
)
)
:
undefined
;
}
export
const
=
createDecorator < IChatPetService>
(
'chatPetService'
)
;
export
interface
IChatPetService
{
readonly
:
undefined
;
readonly
:
<
boolean
>
;
readonly
:
<
>
;
readonly
:
<
boolean
>
;
readonly
:
<
number
>
;
readonly
:
<
readonly
[
]
>
;
readonly
:
<
readonly
[
]
>
;
readonly
:
<
|
undefined
>
;
readonly
:
<
>
;
readonly
:
<
number
|
undefined
>
;
toggle
(
)
:
boolean
;
setVariant
(
:
)
:
void
;
setOnTheRun
(
:
boolean
)
:
void
;
setScale
(
:
number
)
:
void
;
resetScale
(
)
:
void
;
unlockAchievement
(
:
)
:
boolean
;
markAchievementSeen
(
:
)
:
boolean
;
setAccessory
(
:
|
undefined
)
:
void
;
resetAchievements
(
)
:
void
;
setHorizontalPosition
(
:
number
)
:
void
;
}
export
class
ChatPetService
extends
Disposable
implements
IChatPetService
{
declare
readonly
:
undefined
;
private
readonly
;
readonly
:
<
boolean
>
;
private
readonly
;
readonly
:
<
>
;
private
readonly
;
readonly
:
<
boolean
>
;
private
readonly
;
readonly
:
<
number
>
;
private
readonly
;
readonly
:
<
readonly
[
]
>
;
private
readonly
;
readonly
:
<
readonly
[
]
>
;
private
readonly
;
readonly
:
<
|
undefined
>
;
private
readonly
=
this
.
_register
(
new
Emitter< ChatPetAchievementId>
(
)
)
;
readonly
=
this
.
.
;
private
:
string
|
undefined
;
private
=
false
;
private
readonly
;
readonly
:
<
number
|
undefined
>
;
constructor
(
@ IStorageService
private
readonly
:
,
@ ITelemetryService
private
readonly
:
,
@ ILogService
private
readonly
:
,
)
{
super
(
)
;
this
.
_migrateAchievementStorage
(
)
;
this
.
=
observableValue
(
this
,
this
.
.
getBoolean
(
CHAT_PET_ENABLED_STORAGE_KEY
,
.
APPLICATION
,
false
)
)
;
this
.
=
this
.
;
this
.
=
observableValue
(
this
,
getChatPetVariant
(
this
.
.
get
(
CHAT_PET_VARIANT_STORAGE_KEY
,
.
APPLICATION
)
,
.
)
)
;
this
.
=
this
.
;
this
.
=
observableValue
(
this
,
this
.
.
getBoolean
(
CHAT_PET_ON_THE_RUN_STORAGE_KEY
,
.
APPLICATION
,
false
)
)
;
this
.
=
this
.
;
this
.
=
observableValue
(
this
,
getChatPetScale
(
this
.
.
get
(
CHAT_PET_SCALE_STORAGE_KEY
,
.
APPLICATION
)
)
)
;
this
.
=
this
.
;
this
.
=
observableValue < readonly ChatPetAchievementId[ ] >
(
this
,
this
.
_readUnlockedAchievements
(
)
)
;
this
.
=
this
.
;
this
.
=
observableValue < readonly ChatPetAchievementId[ ] >
(
this
,
this
.
_readUnseenAchievements
(
)
)
;
this
.
=
this
.
;
this
.
=
observableValue < ChatPetAccessoryId | undefined >
(
this
,
this
.
_readSelectedAccessory
(
)
)
;
this
.
=
this
.
;
this
.
=
observableValue
(
this
,
getChatPetHorizontalPosition
(
this
.
.
get
(
CHAT_PET_HORIZONTAL_POSITION_STORAGE_KEY
,
.
APPLICATION
)
)
)
;
this
.
=
this
.
;
this
.
_register
(
this
.
.
onDidChangeValue
(
.
APPLICATION
,
CHAT_PET_ENABLED_STORAGE_KEY
,
this
.
)
(
(
)
=>
{
this
.
_setEnabled
(
this
.
.
getBoolean
(
CHAT_PET_ENABLED_STORAGE_KEY
,
.
APPLICATION
,
false
)
)
;
}
)
)
;
this
.
_register
(
this
.
.
onDidChangeValue
(
.
APPLICATION
,
CHAT_PET_VARIANT_STORAGE_KEY
,
this
.
)
(
(
)
=>
{
this
.
.
set
(
getChatPetVariant
(
this
.
.
get
(
CHAT_PET_VARIANT_STORAGE_KEY
,
.
APPLICATION
)
,
.
)
,
undefined
)
;
}
)
)
;
this
.
_register
(
this
.
.
onDidChangeValue
(
.
APPLICATION
,
CHAT_PET_ON_THE_RUN_STORAGE_KEY
,
this
.
)
(
(
)
=>
{
this
.
.
set
(
this
.
.
getBoolean
(
CHAT_PET_ON_THE_RUN_STORAGE_KEY
,
.
APPLICATION
,
false
)
,
undefined
)
;
}
)
)
;
for
(
const
of
)
{
this
.
_register
(
this
.
.
onDidChangeValue
(
.
APPLICATION_SHARED
,
this
.
_getAchievementStorageKey
(
.
)
,
this
.
)
(
(
)
=>
{
this
.
_refreshAchievementState
(
!
this
.
)
;
}
)
)
;
this
.
_register
(
this
.
.
onDidChangeValue
(
.
APPLICATION_SHARED
,
this
.
_getAchievementSeenStorageKey
(
.
)
,
this
.
)
(
(
)
=>
{
this
.
_refreshUnseenAchievementState
(
)
;
}
)
)
;
}
this
.
_register
(
this
.
.
onDidChangeValue
(
.
APPLICATION_SHARED
,
CHAT_PET_ACCESSORY_STORAGE_KEY
,
this
.
)
(
(
)
=>
{
this
.
_refreshSelectedAccessory
(
)
;
}
)
)
;
this
.
_register
(
this
.
.
onDidChangeValue
(
.
APPLICATION
,
CHAT_PET_SCALE_STORAGE_KEY
,
this
.
)
(
(
)
=>
{
this
.
.
set
(
getChatPetScale
(
this
.
.
get
(
CHAT_PET_SCALE_STORAGE_KEY
,
.
APPLICATION
)
)
,
undefined
)
;
}
)
)
;
this
.
_register
(
this
.
.
onDidChangeValue
(
.
APPLICATION
,
CHAT_PET_HORIZONTAL_POSITION_STORAGE_KEY
,
this
.
)
(
(
)
=>
{
this
.
.
set
(
getChatPetHorizontalPosition
(
this
.
.
get
(
CHAT_PET_HORIZONTAL_POSITION_STORAGE_KEY
,
.
APPLICATION
)
)
,
undefined
)
;
}
)
)
;
this
.
_logEnablement
(
this
.
.
get
(
)
,
'startup'
)
;
}
toggle
(
)
:
boolean
{
const
=
!
this
.
.
get
(
)
;
this
.
_setEnabled
(
)
;
this
.
.
store
(
CHAT_PET_ENABLED_STORAGE_KEY
,
,
.
APPLICATION
,
.
USER
)
;
status
(
?
localize
(
'chatPet.enabled'
,
"VS Code pet enabled. Click the pet to interact with it, or use the Left and Right Arrow keys to move it."
)
:
localize
(
'chatPet.disabled'
,
"VS Code pet disabled"
)
)
;
return
;
}
private
_setEnabled
(
:
boolean
)
:
void
{
if
(
===
this
.
.
get
(
)
)
{
return
;
}
this
.
.
set
(
,
undefined
)
;
this
.
_logEnablement
(
,
'change'
)
;
}
private
_logEnablement
(
:
boolean
,
:
[
'source'
]
)
:
void
{
this
.
.
publicLog2 < ChatPetEnablementEvent, ChatPetEnablementClassification>
(
'chatPetEnablement'
,
{
,
}
)
;
}
setVariant
(
:
)
:
void
{
this
.
.
set
(
,
undefined
)
;
this
.
.
store
(
CHAT_PET_VARIANT_STORAGE_KEY
,
,
.
APPLICATION
,
.
USER
)
;
status
(
===
'stable'
?
localize
(
'chatPet.variant.stable'
,
"VS Code pet changed to the Stable colors"
)
:
localize
(
'chatPet.variant.insiders'
,
"VS Code pet changed to the Insiders colors"
)
)
;
}
setOnTheRun
(
:
boolean
)
:
void
{
this
.
.
set
(
,
undefined
)
;
this
.
.
store
(
CHAT_PET_ON_THE_RUN_STORAGE_KEY
,
,
.
APPLICATION
,
.
USER
)
;
status
(
?
localize
(
'chatPet.onTheRun'
,
"The VS Code pet is on the run. Click the pet to bring it back."
)
:
localize
(
'chatPet.restored'
,
"The VS Code pet is back"
)
)
;
}
setScale
(
:
number
)
:
void
{
this
.
.
set
(
,
undefined
)
;
this
.
.
store
(
CHAT_PET_SCALE_STORAGE_KEY
,
,
.
APPLICATION
,
.
USER
)
;
}
resetScale
(
)
:
void
{
this
.
.
set
(
CHAT_PET_DEFAULT_SCALE
,
undefined
)
;
this
.
.
remove
(
CHAT_PET_SCALE_STORAGE_KEY
,
.
APPLICATION
)
;
}
setHorizontalPosition
(
:
number
)
:
void
{
const
=
.
max
(
0
,
.
min
(
1
,
)
)
;
this
.
.
set
(
,
undefined
)
;
this
.
.
store
(
CHAT_PET_HORIZONTAL_POSITION_STORAGE_KEY
,
,
.
APPLICATION
,
.
MACHINE
)
;
}
unlockAchievement
(
:
)
:
boolean
{
if
(
!
isChatPetAchievementId
(
)
)
{
throw
new
Error
(
` Unknown chat pet achievement: ${ id} `
)
;
}
if
(
!
isChatPetAchievementEnabled
(
)
)
{
return
false
;
}
if
(
!
this
.
.
get
(
)
)
{
return
false
;
}
if
(
this
.
_isAchievementStored
(
)
)
{
this
.
_refreshAchievementState
(
)
;
return
false
;
}
this
.
=
true
;
try
{
this
.
.
store
(
this
.
_getAchievementStorageKey
(
)
,
true
,
.
APPLICATION_SHARED
,
.
USER
)
;
}
finally
{
this
.
=
false
;
}
this
.
_refreshAchievementState
(
)
;
this
.
.
fire
(
)
;
return
true
;
}
markAchievementSeen
(
:
)
:
boolean
{
if
(
!
this
.
.
get
(
)
.
includes
(
)
)
{
return
false
;
}
this
.
.
store
(
this
.
_getAchievementSeenStorageKey
(
)
,
true
,
.
APPLICATION_SHARED
,
.
USER
)
;
this
.
_refreshUnseenAchievementState
(
)
;
return
true
;
}
setAccessory
(
:
|
undefined
)
:
void
{
if
(
!==
undefined
)
{
if
(
!
isChatPetAccessoryId
(
)
)
{
throw
new
Error
(
` Unknown chat pet accessory: ${ id} `
)
;
}
const
=
getChatPetAchievementForAccessory
(
)
;
if
(
!
.
)
{
throw
new
Error
(
` Chat pet accessory is disabled: ${ id} `
)
;
}
if
(
!
this
.
.
get
(
)
.
includes
(
.
)
)
{
throw
new
Error
(
` Chat pet accessory is locked: ${ id} `
)
;
}
this
.
.
store
(
CHAT_PET_ACCESSORY_STORAGE_KEY
,
,
.
APPLICATION_SHARED
,
.
USER
)
;
}
else
{
this
.
.
remove
(
CHAT_PET_ACCESSORY_STORAGE_KEY
,
.
APPLICATION_SHARED
)
;
this
.
.
remove
(
CHAT_PET_ACCESSORY_STORAGE_KEY
,
.
APPLICATION
)
;
}
this
.
=
undefined
;
this
.
.
set
(
,
undefined
)
;
}
resetAchievements
(
)
:
void
{
this
.
=
true
;
try
{
for
(
const
of
)
{
const
=
this
.
_getAchievementStorageKey
(
.
)
;
this
.
.
remove
(
,
.
APPLICATION_SHARED
)
;
this
.
.
remove
(
,
.
APPLICATION
)
;
const
=
this
.
_getAchievementSeenStorageKey
(
.
)
;
this
.
.
remove
(
,
.
APPLICATION_SHARED
)
;
this
.
.
remove
(
,
.
APPLICATION
)
;
}
this
.
.
remove
(
'chat.vscodePet.achievement.checkpointRestore'
,
.
APPLICATION_SHARED
)
;
this
.
.
remove
(
'chat.vscodePet.achievement.checkpointRestore'
,
.
APPLICATION
)
;
this
.
.
remove
(
'chat.vscodePet.achievement.integratedBrowserOpened'
,
.
APPLICATION_SHARED
)
;
this
.
.
remove
(
'chat.vscodePet.achievement.integratedBrowserOpened'
,
.
APPLICATION
)
;
this
.
.
remove
(
'chat.vscodePet.achievement.chatFork'
,
.
APPLICATION_SHARED
)
;
this
.
.
remove
(
'chat.vscodePet.achievement.chatFork'
,
.
APPLICATION
)
;
this
.
.
remove
(
CHAT_PET_ACCESSORY_STORAGE_KEY
,
.
APPLICATION_SHARED
)
;
this
.
.
remove
(
CHAT_PET_ACCESSORY_STORAGE_KEY
,
.
APPLICATION
)
;
}
finally
{
this
.
=
false
;
}
transaction
(
=>
{
this
.
.
set
(
[
]
,
)
;
this
.
.
set
(
[
]
,
)
;
this
.
.
set
(
undefined
,
)
;
}
)
;
}
private
_getAchievementStorageKey
(
:
)
:
string
{
return
` chat.vscodePet.achievement. ${ id} `
;
}
private
_getAchievementSeenStorageKey
(
:
)
:
string
{
return
` ${ CHAT_PET_ACHIEVEMENT_SEEN_STORAGE_PREFIX } ${ id} `
;
}
private
_migrateAchievementStorage
(
)
:
void
{
this
.
_migrateLocalAchievementStorage
(
)
;
const
=
this
.
.
getNumber
(
CHAT_PET_ACHIEVEMENT_CATALOG_VERSION_STORAGE_KEY
,
.
APPLICATION_SHARED
,
0
)
;
if
(
>=
CHAT_PET_ACHIEVEMENT_CATALOG_VERSION
)
{
return
;
}
const
wasUnlocked
=
(
:
string
)
=>
this
.
.
getBoolean
(
` chat.vscodePet.achievement. ${ id} `
,
.
APPLICATION_SHARED
,
false
)
;
this
.
_storeLegacyAchievementRewards
(
wasUnlocked
(
'checkpointRestore'
)
,
wasUnlocked
(
'chatFork'
)
,
wasUnlocked
(
.
)
,
wasUnlocked
(
.
)
,
)
;
this
.
.
store
(
CHAT_PET_ACHIEVEMENT_CATALOG_VERSION_STORAGE_KEY
,
CHAT_PET_ACHIEVEMENT_CATALOG_VERSION
,
.
APPLICATION_SHARED
,
.
USER
)
;
}
private
_migrateLocalAchievementStorage
(
)
:
void
{
const
=
this
.
.
getNumber
(
CHAT_PET_LOCAL_ACHIEVEMENT_MIGRATION_VERSION_STORAGE_KEY
,
.
APPLICATION
,
0
)
;
if
(
>=
CHAT_PET_LOCAL_ACHIEVEMENT_MIGRATION_VERSION
)
{
return
;
}
const
=
.
filter
(
=>
this
.
.
getBoolean
(
this
.
_getAchievementStorageKey
(
.
)
,
.
APPLICATION
,
false
)
)
.
map
(
=>
.
)
;
const
=
this
.
.
getBoolean
(
'chat.vscodePet.achievement.checkpointRestore'
,
.
APPLICATION
,
false
)
;
const
=
this
.
.
getBoolean
(
'chat.vscodePet.achievement.chatFork'
,
.
APPLICATION
,
false
)
;
const
=
this
.
.
get
(
CHAT_PET_ACCESSORY_STORAGE_KEY
,
.
APPLICATION
)
;
for
(
const
of
)
{
this
.
.
store
(
this
.
_getAchievementStorageKey
(
)
,
true
,
.
APPLICATION_SHARED
,
.
USER
)
;
}
this
.
_storeLegacyAchievementRewards
(
,
,
.
includes
(
.
)
,
.
includes
(
.
)
,
)
;
if
(
!==
undefined
&&
this
.
.
get
(
CHAT_PET_ACCESSORY_STORAGE_KEY
,
.
APPLICATION_SHARED
)
===
undefined
)
{
this
.
.
store
(
CHAT_PET_ACCESSORY_STORAGE_KEY
,
,
.
APPLICATION_SHARED
,
.
USER
)
;
}
this
.
.
store
(
CHAT_PET_LOCAL_ACHIEVEMENT_MIGRATION_VERSION_STORAGE_KEY
,
CHAT_PET_LOCAL_ACHIEVEMENT_MIGRATION_VERSION
,
.
APPLICATION
,
.
USER
)
;
}
private
_storeLegacyAchievementRewards
(
:
boolean
,
:
boolean
,
:
boolean
,
:
boolean
)
:
void
{
if
(
||
)
{
this
.
.
store
(
this
.
_getAchievementStorageKey
(
.
)
,
true
,
.
APPLICATION_SHARED
,
.
USER
)
;
}
if
(
)
{
this
.
.
store
(
this
.
_getAchievementStorageKey
(
.
)
,
true
,
.
APPLICATION_SHARED
,
.
USER
)
;
}
if
(
)
{
this
.
.
store
(
this
.
_getAchievementStorageKey
(
.
)
,
true
,
.
APPLICATION_SHARED
,
.
USER
)
;
}
}
private
_readUnlockedAchievements
(
)
:
readonly
[
]
{
return
.
filter
(
=>
this
.
_isAchievementStored
(
.
)
)
.
map
(
=>
.
)
;
}
private
_isAchievementStored
(
:
)
:
boolean
{
const
=
this
.
_getAchievementStorageKey
(
)
;
return
this
.
.
getBoolean
(
,
.
APPLICATION_SHARED
,
false
)
||
this
.
.
getBoolean
(
,
.
APPLICATION
,
false
)
;
}
private
_refreshAchievementState
(
=
false
)
:
void
{
const
=
this
.
.
get
(
)
;
const
=
this
.
_readUnlockedAchievements
(
)
;
if
(
!
this
.
_haveSameAchievements
(
,
)
)
{
this
.
.
set
(
,
undefined
)
;
if
(
)
{
const
=
new
Set
(
)
;
for
(
const
of
)
{
if
(
!
.
has
(
)
)
{
this
.
.
fire
(
)
;
}
}
}
}
this
.
_refreshUnseenAchievementState
(
)
;
this
.
_refreshSelectedAccessory
(
)
;
}
private
_readUnseenAchievements
(
)
:
readonly
[
]
{
const
=
new
Set
(
this
.
.
get
(
)
)
;
return
.
filter
(
=>
.
has
(
.
)
&&
!
this
.
.
getBoolean
(
this
.
_getAchievementSeenStorageKey
(
.
)
,
.
APPLICATION_SHARED
,
false
)
)
.
map
(
=>
.
)
;
}
private
_refreshUnseenAchievementState
(
)
:
void
{
const
=
this
.
_readUnseenAchievements
(
)
;
if
(
!
this
.
_haveSameAchievements
(
this
.
.
get
(
)
,
)
)
{
this
.
.
set
(
,
undefined
)
;
}
}
private
_haveSameAchievements
(
:
readonly
[
]
,
:
readonly
[
]
)
:
boolean
{
return
.
===
.
&&
.
every
(
(
,
)
=>
===
[
]
)
;
}
private
_refreshSelectedAccessory
(
)
:
void
{
this
.
.
set
(
this
.
_readSelectedAccessory
(
)
,
undefined
)
;
}
private
_readSelectedAccessory
(
)
:
|
undefined
{
const
=
this
.
.
get
(
CHAT_PET_ACCESSORY_STORAGE_KEY
,
.
APPLICATION_SHARED
)
??
this
.
.
get
(
CHAT_PET_ACCESSORY_STORAGE_KEY
,
.
APPLICATION
)
;
if
(
===
undefined
)
{
this
.
=
undefined
;
return
undefined
;
}
if
(
isChatPetAccessoryId
(
)
)
{
const
=
getChatPetAchievementForAccessory
(
)
;
if
(
this
.
.
get
(
)
.
includes
(
.
)
)
{
this
.
=
undefined
;
return
;
}
}
if
(
this
.
!==
)
{
this
.
=
;
this
.
.
warn
(
` [ChatPetService] Ignoring unknown or locked stored accessory: ${ storedAccessory} `
)
;
}
return
undefined
;
}
}