Spaces:
Sleeping
Sleeping
{"version":3,"sources":["index.ts"],"names":["targetDocument","window","parent","document","lastValue","Streamlit","events","addEventListener","RENDER_EVENT","event","queue","data","detail","args","Object","keys","forEach","name","spec","value","cookie","encodeURIComponent","path","date","Date","expires_at","toUTCString","newValue","saveOnly","setComponentValue","setComponentReady","setFrameHeight"],"mappings":"oIAAA,kBAGMA,GADuBC,OAAOC,QAAUD,QACVE,SAEhCC,EAA2B,KA2B/BC,IAAUC,OAAOC,iBAAiBF,IAAUG,cAZ5C,SAAkBC,GACd,IAgBiBC,EAhBXC,EAAQF,EAAkCG,OAgB/BF,EAdLC,EAAKE,KAAL,MAeZC,OAAOC,KAAKL,GAAOM,SAAQ,SAACC,GACxB,IAAMC,EAAOR,EAAMO,GACnB,GAAmB,OAAfC,EAAKC,MACLnB,EAAeoB,OAAf,UAA2BC,mBAAmBJ,GAA9C,8BAAyEI,mBAAmBH,EAAKI,WAChG,CACD,IAAMC,EAAO,IAAIC,KAAKN,EAAKO,YAC3BzB,EAAeoB,OACX,UAAGC,mBAAmBJ,GAAtB,YAA+BI,mBAAmBH,EAAKC,OAAvD,wBACYI,EAAKG,cADjB,qBAESL,mBAAmBH,EAAKI,MAFjC,SApBZ,IAAMK,EAAW3B,EAAeoB,OAC5BhB,IAAcuB,GAAahB,EAAKE,KAAKe,WACrCvB,IAAUwB,kBAAkBF,GAC5BvB,EAAYuB,MAKpBtB,IAAUyB,oBACVzB,IAAU0B,eAAe,K","file":"static/js/main.666d1b34.chunk.js","sourcesContent":["import {RenderData, Streamlit} from \"streamlit-component-lib\"\n\nconst targetWindow: Window = window.parent || window\nconst targetDocument = targetWindow.document\n\nlet lastValue: string | null = null\n\ninterface AddCookieSpec {\n value: string\n expires_at: string\n path: string\n}\n\ninterface DeleteCookieSpec {\n value: null\n path: string\n}\n\ntype CookieSpec = AddCookieSpec | DeleteCookieSpec\n\nfunction onRender(event: Event): void {\n const data = (event as CustomEvent<RenderData>).detail\n\n saveCookies(data.args[\"queue\"])\n\n const newValue = targetDocument.cookie\n if (lastValue !== newValue && !data.args.saveOnly) {\n Streamlit.setComponentValue(newValue)\n lastValue = newValue\n }\n}\n\nStreamlit.events.addEventListener(Streamlit.RENDER_EVENT, onRender)\nStreamlit.setComponentReady()\nStreamlit.setFrameHeight(0)\n\n\nfunction saveCookies(queue: { [k in string]: CookieSpec }) {\n Object.keys(queue).forEach((name) => {\n const spec = queue[name]\n if (spec.value === null)\n targetDocument.cookie = `${encodeURIComponent(name)}=; max-age=0; path=${encodeURIComponent(spec.path)}`\n else {\n const date = new Date(spec.expires_at)\n targetDocument.cookie = (\n `${encodeURIComponent(name)}=${encodeURIComponent(spec.value)};` +\n ` expires=${date.toUTCString()};` +\n ` path=${encodeURIComponent(spec.path)};`\n )\n }\n })\n}"],"sourceRoot":""} |