Shuffled Dyck words code hamiltonian 3regular maps on the sphere. These maps also correspond to synthetic weaving on the sphere, as the loop of wire corresponds to the hamiltonian circuit and each edge not in the circuit corresponds to the bond made by a pair of staples.
Surfaces of higher genus than the sphere can always be cut open into a planar polygon with 2n edges that are to be identified (i.e., paired up and glued back together when the time comes to reassemble the surface.) If the hamiltonian circuit never crosses the polygon, everything will be planar except, possibly, the few bonds that cross the polygon. These bonds may need some supplementary coding to be properly reconnected.
When the polygon in question is a square, the only two orientable surfaces it can represent are the sphere and the torus.
For the sphere, the polygoncrossing bonds reconnect in a way that, as one would expect, can be diagrammed on the plane without crossing lines.

Polygonal model of a spherical surface. Notice that when the closed hamiltonian circuit is traversed in the direction indicated, all polygoncrossing bonds are on the lefthand side (coded by u or d) and are visited in clockwise order. 
Therefore these polygoncrossing bonds are not in any way special and can be undip coded in the usual way along with all the other bonds that do not cross the polygon. Notice that, given the orientation of the hamiltonian circuit indicated all these bonds will be coded by
u and
d (there will be other bonds coded by
u and
d that do not cross the polygon, but no distinction need to be made.)
For the torus, the polygoncrossing bonds reconnect in a way that does not permit drawing their reconnection on the plane without crossing lines. However, as evidenced by the drawing below, the reconnection for either of the two cuts can be drawn on the plane, just not both at the same time.

Polygonal model of a torus. Either class of bonds, but not both, can be drawn in the plane without crossings. As drawn, only the pink bonds need special coding. 
We could code the the torus above by introducing two new characters for bond connections we cannot draw on the plane. For example, we could use a pink
u and a pink
d. Pink u's and d's, connect up with each other in the same planar way, they are just, so to speak, drawn on a separate page.
Does a double torus, triple torus, etc., need more colors? The polygonal model for a double torus is an octagon, shown here by subdividing the edges of a square.

Polygonal model of a double torus. When the model is in canonical form, as here (i.e., aba'b'cdc'd') the edges fall into two classes ({a, c} and {b, d}), either of which can be diagrammed on the plane. 
A double torus can be cut into a polygon in various ways, but the canonical way gives an octagon with edges ordered a b a' b' c d c' d', as in the drawing above. These edges partition into two classes whose reconnections can be drawn in the plane, just not both classes at the same time. Here again, we just need a pink
u and
d to code this surface. These two additional characters also suffice for any higher genus orientable surface that has been dissected in the canonical way.
Actually, we do not always have to have a canonical dissection in order to get by with just two additional characters. It suffices to have a dissection that partitions the polygoncrossing edges into two sets, each of which can be described by a parenthesis word. For instance, in a canonical polygon, the parenthesis word for either set happens to be ()()()..., but for our purposes any parenthesis word would serve.