My Pangamebook script can be used to generate static EPUBs. I am never going to look into adding JavaScript to support hidden state tracking, as most EPUB readers lack support for that anyway (plus I want books to be static text!).
There has been some discussions on this forum in the past about adding state to a static book. It could be done by adding some mark-up for “set flag” and branching on “if flag” later. A script could analyze the graph to duplicate nodes automatically, as needed (only nodes that can be reached both with and without a flag would have to be duplicated, and only for nodes that have a path leading to some node where the flag is checked). So an EPUB could track that the player picked up a key earlier in the story when they encounter a locked door. A bit wasteful perhaps, but solves the problem without requiring any read-time scripts in the book.
I did some design on an algorithm and mark-up for that, but never got around to implement it.