How can we set branch transformation in keyman?

For example I want to set such rule:
u + w > ư

  • w > ư

however I want to get
u + w + w > uw

  • w + w > w

how can I reach those rules?

It’s not quite clear what you’re asking since the “+” in what you wrote was interpreted as a bullet. It seems that you want the “w” keystroke to produce “ư” (whether or not it is preceeded by “u”), but a second “w” keystroke should turn the “ư” into “w”.

+ "w" > "ư"
"ư" + "w" > "w"

Does this address your question?

I also want if I put u at first, then I put w, it will become ư as same
If in this scenario I put w again I want to transform the ư in to uw instead of w again.
Could you solve my problem?

One way to do what (I think) you want is to use a “dead key” as a marker.

c "w" keystroke produces "ư"
+ "w" > "ư"
c if "u" was typed before "w", the "uw" changes to "ư"
"u" + "w" > "ư" dk(u)
c "w" keystroke after "ư" changes "ư" to "w"
"ư" + "w" > "w"
c unless there was a "u" there before, as marked by dk(u)
"ư" dk(u) + "w" > "uw"

This lets you turn the two sequences (u and uw) into the same character, but distinguish them so that you can treat them differently in future matches.

An alternative approach might be to use multiple groups