refactor(core): consolidate the IME composition guard into utils/ime (#4907)