diff --git a/README.md b/README.md index d349490..9adc157 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,8 @@ bun run your-app-entrypoint.js ## changelog +- **Version 1.2.0** + - modified `frontend/index.js` such that script can now be used in SharedWorker and HTTPS contexts - **Version 1.1.0** - added `func_register_teardown`, made `jsbuild_app_frontend` optional - **Version 1.0.1** diff --git a/frontend/index.js b/frontend/index.js index 57481fc..e52ebbc 100644 --- a/frontend/index.js +++ b/frontend/index.js @@ -33,8 +33,11 @@ class FramerockUtils { _setup_transport ({ on_open, on_close, on_message, on_error }) { console.debug('SETUP TRANSPORT') + + const ctx_location = window ? window.location : self.location + const ws_protocol = ctx_location.protocol === 'http:' ? 'ws:' : 'wss:' - this._ws = new WebSocket(`ws://${window.location.host}/ws`) + this._ws = new WebSocket(`${ws_protocol}//${ctx_location.host}/ws`) const ws = this._ws ws.binaryType = 'arraybuffer' diff --git a/package.json b/package.json index 174ddbe..0fce878 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "framerock", - "version": "1.1.0", + "version": "1.2.0", "type": "module", "main": "backend/index.js" }