diff --git a/packages/app/package.json b/packages/app/package.json index 1b31497..681fbe2 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -24,7 +24,7 @@ "throttle-debounce": "^5.0.2" }, "peerDependencies": { - "@pomade/core": "^0.1.3", + "@pomade/core": "^0.2.1", "@welshman/feeds": "workspace:*", "@welshman/lib": "workspace:*", "@welshman/net": "workspace:*", @@ -37,7 +37,7 @@ "devDependencies": { "rimraf": "~6.0.0", "typescript": "~5.8.0", - "@pomade/core": "^0.1.3", + "@pomade/core": "^0.2.1", "@types/throttle-debounce": "^5.0.2", "@welshman/feeds": "workspace:*", "@welshman/lib": "workspace:*", diff --git a/packages/util/src/Room.ts b/packages/util/src/Room.ts index 5ec9802..4c82360 100644 --- a/packages/util/src/Room.ts +++ b/packages/util/src/Room.ts @@ -31,15 +31,32 @@ export type PublishedRoomMeta = Omit & { event: TrustedEvent } -export const makeRoomMeta = (room: Partial = {}): RoomMeta => { - const v = ["a", "e", "i", "o", "u", "ay", "ey", "oy", "ou", "ia", "ea", "ough", "oo", "ee", "argh"] - const c = ["p", "b", "t", "d", "k", "g", "ch", "sh", "th", "f", "v", "s", "z", "l", "r", "m", "n", "pl", "bl", "cl", "gl", "pr", "br", "tr", "dr", "kr", "gr", "fl", "sl", "fr", "thr", "str", "sk", "sp", "st"] - const n = 6 + Math.random()*2|0, s = [c, v] - Math.random() < 0.5 && s.reverse() - const pronounceableId = Array.from({length: n}, (_, i) => s[i%2].splice(Math.random()*s[i%2].length|0, 1)).join("") + (1 + Math.floor(Math.random() * 9)) +const vowels = "a,e,i,o,u,ay,ey,oy,ou,ia,ea,ough,oo,ee,argh".split(",") +const consonants = + "p,b,t,d,k,g,ch,sh,th,f,v,s,z,l,r,m,n,pl,bl,cl,gl,pr,br,tr,dr,kr,gr,fl,sl,fr,thr,str,sk,sp,st".split( + ",", + ) + +export const generateH = () => { + const n = (6 + Math.random() * 2) | 0 + const s = [consonants, vowels] + + if (Math.random() < 0.5) { + s.reverse() + } + + return ( + Array.from({length: n}, (_, i) => + s[i % 2].splice((Math.random() * s[i % 2].length) | 0, 1), + ).join("") + + (1 + Math.floor(Math.random() * 9)) + ) +} + +export const makeRoomMeta = (room: Partial = {}): RoomMeta => { return { - h: room.h ?? pronounceableId, + h: room.h ?? generateH(), ...room, } }