Files
waveform-analysis/src/utils/waveformId.ts

11 lines
349 B
TypeScript
Raw Normal View History

import { getCurrentInstance } from 'vue'
let fallbackId = 0
/** Generate an instance-scoped id without requiring Vue 3.5's useId API. */
export function useWaveformInstanceId(prefix = 'waveform') {
const instance = getCurrentInstance()
const instanceId = instance ? `v${instance.uid}` : `f${++fallbackId}`
return `${prefix}-${instanceId}`
}