1export const genGlobal2Ctx = <T,>() => {2 // Unique key per instance — previously all instances shared one 'myVal' slot,3 // so two contexts collided (last enterWith wins). Symbol keys isolate them.4 const key = Symbol()5 const globalAny = global as Record<symbol, unknown>7 const enterWith = (newVal: T) => {8 globalAny[key] = newVal9 }11 return {12 enterWith,13 getStore: () => globalAny[key] as T | undefined14 }15}