Spaces:
Running
Running
Download utils/st_copy_to_clipboard/frontend/streamlit-component-lib.js from embedding-benchmark/RTEB: direct link, hf CLI and curl.
- Browser
- Download file 1.05 kB
-
https://huggingface.co/spaces/embedding-benchmark/RTEB/resolve/40af36f741033d89b635f0c8e8c468b32cf55325/utils/st_copy_to_clipboard/frontend/streamlit-component-lib.js
- Command line
-
hf download hf://spaces/embedding-benchmark/RTEB@40af36f741033d89b635f0c8e8c468b32cf55325/utils/st_copy_to_clipboard/frontend/streamlit-component-lib.js
-
curl -L -o streamlit-component-lib.js https://huggingface.co/spaces/embedding-benchmark/RTEB/resolve/40af36f741033d89b635f0c8e8c468b32cf55325/utils/st_copy_to_clipboard/frontend/streamlit-component-lib.js
1.05 kB
| // Borrowed minimalistic Streamlit API from Thiago | |
| // https://discuss.streamlit.io/t/code-snippet-create-components-without-any-frontend-tooling-no-react-babel-webpack-etc/13064 | |
| function sendMessageToStreamlitClient(type, data) { | |
| console.log(type, data); | |
| const outData = Object.assign( | |
| { | |
| isStreamlitMessage: true, | |
| type: type, | |
| }, | |
| data | |
| ); | |
| window.parent.postMessage(outData, '*'); | |
| } | |
| const Streamlit = { | |
| setComponentReady: function () { | |
| sendMessageToStreamlitClient('streamlit:componentReady', { apiVersion: 1 }); | |
| }, | |
| setFrameHeight: function (height) { | |
| sendMessageToStreamlitClient('streamlit:setFrameHeight', { height: height }); | |
| }, | |
| setComponentValue: function (value) { | |
| sendMessageToStreamlitClient('streamlit:setComponentValue', { value: value }); | |
| }, | |
| RENDER_EVENT: 'streamlit:render', | |
| events: { | |
| addEventListener: function (type, callback) { | |
| window.addEventListener('message', function (event) { | |
| if (event.data.type === type) { | |
| event.detail = event.data; | |
| callback(event); | |
| } | |
| }); | |
| }, | |
| }, | |
| }; | |