-
-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Load blink.js from local server when loading from localhost #303
Comments
Figured this out too, must add it like this:
Now another problem: the websocket is replacing the http localhost webpack/vite server path with ws to initiate the websocket connection, but that is not the right port. The port must be injected into this file on generation. Can someone point me to the right files to edit for this and I will work on a PR? |
UPDATE: see this other comment #303 (comment) @bryaan thanks for figuring out how to get the port and solve the issue with the missing id values in
I'm not sure if I completely understand the situation you're describing. But, if you're talking about injecting the port into the JS file, I was able to do something like this: using Blink, Genie
Genie.Server.serve("gui/build", 8081) # serving webpack built project with local webserver
w = Window()
url = "http://localhost:8081/index.html?blinkPort=" * string(Blink.port[]) # add the port as a query param
@js w window.location = $url
wait() Basically, I gave up trying to use function App() {
let params = (new URL(document.location)).searchParams
let blinkPort = params.get("blinkPort")
let blinkUrl = `http://localhost:${blinkPort}/blink.js`
useEffect(() => {
const declareIds = 'var id = 1; var callback_id = 1;'
// attach as global variable
const declareIdsScript = document.createElement('script')
declareIdsScript.innerHTML = declareIds
document.body.appendChild(declareIdsScript)
const script = document.createElement('script')
script.src = blinkUrl
script.async = true
document.body.appendChild(script)
return () => {
document.body.removeChild(declareIdsScript)
document.body.removeChild(script)
}
}, [blinkUrl])
// rest of the app... You'll notice I "injected" the port via a query parameter. Maybe you could do something similar for your websocket port? |
I opened up this PR to address this issue of |
I am loading a js project from a local Vite server which is much like serving from Webpack. I point my window to
localhost:9100
and everything loads. Problem is when I try to callBlink.msg(...)
that blink.js has not been loaded onto the window. I am thinking of solving this by adding an import to the head like this:What I need to know is on what port Blink.jl is serving its blink.js file from. And if it is not can this functionality be implemented?
This would allow supporting a much much wider range of javascript usecases.
The text was updated successfully, but these errors were encountered: