Incorrect heading numbering after a #pause in Touying?

I saw there was a similar topic about this, but the proposed fix did not work for me, as I am already using Touying.

Here is a working example. As you can hopefully see, the last slide’s numbering resets:

#import "@preview/touying:0.5.3": *
#import themes.metropolis: *
#import themes.university: *

#import "@preview/ctheorems:1.1.3": *
#show: thmrules.with(qed-symbol: $square$)

#show: metropolis-theme.with(
  aspect-ratio: "16-9",
  align: top + left
)

#let theorem = thmbox(
  "global.id",
  "Theorem",
  fill: rgb("#eeffee"),
  base: none,
)

#let definition = thmbox(
  "global.id",
  "Definition",
  inset: (x: 1.2em, top: 1em),
  base: none,
)

#counter(heading).step()

#title-slide()

== Test slide 1

#definition[
  This is definition 1
]

#definition[
  This is definition 2
]

== A slide with no theorems

Wow, there really are no theorems here

#pause

Yup, even after pausing there is nothing interesting - But for some reason removing the pause fixes the numbering issue, even though it is not a realistic fix for my project


== The numbering resets

#definition[
  This is definition 3. But it shows up as definition 1 later...
]

#pause

#theorem[
  And this is the main theorem we will present. It is theorem 4
]


According to the author of touying (@OrangeX4), the answer is that there is no simple way to fix this.

Touying helped handle the cases for levels 1 and 2, but the subsequent levels currently cannot be processed because typst does not yet have a frozen state feature.

Okay, thank you. Though, i’m not sure that I understand what the “levels” are referring to here. Could you expand on that? Understanding might help me figure out a workaround.

What I actually quoted was his response to a similar issue. In that issue, the error occurred with the counter for level 3 headings, whereas in your case, it’s the counter for theorems.