Skip to content

Commit 68ae95a

Browse files
authored
Merge pull request #63 from Rhystic1/integrated
Reduced logging in prod for Story/Roleplay feature
2 parents 33a5767 + 813e219 commit 68ae95a

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

src/components/common/Spine/Loader.vue

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ import { globalParams, messagesEnum } from '@/utils/enum/globalParams'
1919
import type { AttachmentInterface, AttachmentItemColorInterface } from '@/utils/interfaces/live2d'
2020
import { animationMappings } from '@/utils/animationMappings'
2121
22+
// Helper for debug logging
23+
const logDebug = (...args: any[]) => {
24+
if (import.meta.env.DEV) {
25+
console.log(...args)
26+
}
27+
}
28+
2229
let canvas: HTMLCanvasElement | null = null
2330
let spineCanvas: any = null
2431
let currentLoadId = 0 // Track active load requests
@@ -61,11 +68,11 @@ const resetAttachmentColors = (player: any) => {
6168
}
6269
6370
const resolveAnimation = (requested: string, available: string[]): string | null => {
64-
console.log(`[Loader] Resolving animation: '${requested}' against available:`, available)
71+
logDebug(`[Loader] Resolving animation: '${requested}' against available:`, available)
6572
6673
if (!requested || requested === 'none') return null
6774
if (available.includes(requested)) {
68-
console.log(`[Loader] Found exact match: ${requested}`)
75+
logDebug(`[Loader] Found exact match: ${requested}`)
6976
return requested
7077
}
7178
@@ -92,15 +99,15 @@ const resolveAnimation = (requested: string, available: string[]): string | null
9299
93100
for (const { target, condition, triggers } of specialMappings) {
94101
if (condition(available) && triggers.some((t) => lowerRequested.includes(t))) {
95-
console.log(`[Loader] Mapped '${requested}' to '${target}'`)
102+
logDebug(`[Loader] Mapped '${requested}' to '${target}'`)
96103
return target
97104
}
98105
}
99106
100107
// Direct fuzzy match
101108
const directMatch = available.find((a) => a.toLowerCase().includes(lowerRequested))
102109
if (directMatch) {
103-
console.log(`[Loader] Found direct fuzzy match: ${directMatch}`)
110+
logDebug(`[Loader] Found direct fuzzy match: ${directMatch}`)
104111
return directMatch
105112
}
106113
@@ -113,15 +120,15 @@ const resolveAnimation = (requested: string, available: string[]): string | null
113120
// exact match of targetAnim (fuzzy)...
114121
let match = available.find((a) => a.toLowerCase().includes(targetAnim))
115122
if (match) {
116-
console.log(`[Loader] Found semantic match for ${targetAnim} (base): ${match}`)
123+
logDebug(`[Loader] Found semantic match for ${targetAnim} (base): ${match}`)
117124
return match
118125
}
119126
120127
// ...or match any of the triggers in available
121128
for (const trigger of triggers) {
122129
match = available.find((a) => a.toLowerCase().includes(trigger))
123130
if (match) {
124-
console.log(`[Loader] Found semantic match for ${targetAnim} (trigger: ${trigger}): ${match}`)
131+
logDebug(`[Loader] Found semantic match for ${targetAnim} (trigger: ${trigger}): ${match}`)
125132
return match
126133
}
127134
}
@@ -150,7 +157,7 @@ watch(() => market.live2d.current_animation, (newAnim) => {
150157
151158
const spineLoader = () => {
152159
if (!market.live2d.current_id) {
153-
console.log('[Loader] No current_id set, skipping load.')
160+
logDebug('[Loader] No current_id set, skipping load.')
154161
return
155162
}
156163
@@ -165,7 +172,7 @@ const spineLoader = () => {
165172
request.send()
166173
request.onloadend = () => {
167174
if (thisLoadId !== currentLoadId) {
168-
console.log('[Loader] Ignoring stale load request')
175+
logDebug('[Loader] Ignoring stale load request')
169176
return
170177
}
171178
@@ -240,7 +247,7 @@ const spineLoader = () => {
240247
}
241248
242249
if (resolvedAnim) {
243-
console.log(`[Loader] Setting initial animation to: ${resolvedAnim} (Requested: ${currentAnim})`)
250+
logDebug(`[Loader] Setting initial animation to: ${resolvedAnim} (Requested: ${currentAnim})`)
244251
market.live2d.current_animation = resolvedAnim
245252
246253
// Force set animation with a slight delay to ensure player is ready
@@ -794,19 +801,19 @@ const setYappable = (bool: boolean) => {
794801
watch(() => market.live2d.isYapping, (value) => {
795802
if (!spineCanvas || !spineCanvas.animationState) return
796803
797-
console.log(`[Loader] isYapping changed to: ${value}`)
804+
logDebug(`[Loader] isYapping changed to: ${value}`)
798805
799806
// Only allow yapping if asset supports it AND user enabled it
800807
if (value && market.live2d.canYap && market.live2d.yapEnabled) {
801808
try {
802-
console.log('[Loader] Setting yap animation')
809+
logDebug('[Loader] Setting yap animation')
803810
spineCanvas.animationState.setAnimation(1, YAP_TRACK, true)
804811
} catch (e) {
805812
console.warn('Could not add yap track', e)
806813
}
807814
} else {
808815
try {
809-
console.log('[Loader] Clearing yap animation')
816+
logDebug('[Loader] Clearing yap animation')
810817
spineCanvas.animationState.setEmptyAnimation(1, 0)
811818
} catch (e) {
812819
console.warn('Could not clear yap track', e)

0 commit comments

Comments
 (0)