diff --git a/v2/pkg/assetserver/assetserver.go b/v2/pkg/assetserver/assetserver.go index e2e0372eb..66ae69439 100644 --- a/v2/pkg/assetserver/assetserver.go +++ b/v2/pkg/assetserver/assetserver.go @@ -43,6 +43,7 @@ type AssetServer struct { runtimeHandler RuntimeHandler assetServerWebView + disableRuntime bool } func NewAssetServerMainPage(bindingsJSON string, options *options.App, servingFromDisk bool, logger Logger, runtime RuntimeAssets) (*AssetServer, error) { @@ -166,8 +167,10 @@ func (d *AssetServer) processIndexHTML(indexHTML []byte) ([]byte, error) { } } - if err := insertScriptInHead(htmlNode, runtimeJSPath); err != nil { - return nil, err + if !d.disableRuntime { + if err := insertScriptInHead(htmlNode, runtimeJSPath); err != nil { + return nil, err + } } if err := insertScriptInHead(htmlNode, ipcJSPath); err != nil { @@ -206,3 +209,7 @@ func (d *AssetServer) logError(message string, args ...interface{}) { d.logger.Error("[AssetServer] "+message, args...) } } + +func (d *AssetServer) DisableRuntime() { + d.disableRuntime = true +} diff --git a/v3/TODO.md b/v3/TODO.md index 1652fb1e6..40b89e1b1 100644 --- a/v3/TODO.md +++ b/v3/TODO.md @@ -31,7 +31,8 @@ Informal and incomplete list of things needed in v3. - [x] Screens - [x] Clipboard - [x] Application -- [ ] Create `.d.ts` file +- [ ] Move to typescript module +- [ ] Move WML to plugin ## Templates diff --git a/v3/internal/runtime/desktop/wml.js b/v3/internal/runtime/desktop/wml.js index c45a9bbee..72b3ff1a8 100644 --- a/v3/internal/runtime/desktop/wml.js +++ b/v3/internal/runtime/desktop/wml.js @@ -24,9 +24,8 @@ function addWMLEventListeners() { return; } sendEvent(eventType); - } + }; // Remove existing listeners - element.removeEventListener(trigger, callback); // Add new listener @@ -59,7 +58,7 @@ function addWMLWindowListeners() { return; } callWindowMethod(windowMethod); - } + }; // Remove existing listeners element.removeEventListener(trigger, callback); diff --git a/v3/pkg/application/options_application.go b/v3/pkg/application/options_application.go index cfb11ee76..a806d0860 100644 --- a/v3/pkg/application/options_application.go +++ b/v3/pkg/application/options_application.go @@ -14,4 +14,6 @@ type Options struct { Silent bool CustomLoggers []logger.Output } + // InjectRuntime will inject the JS runtime into all created webview windows. + InjectRuntime bool } diff --git a/v3/pkg/application/webview_window.go b/v3/pkg/application/webview_window.go index dc2a7ddbb..ac9c7b16d 100644 --- a/v3/pkg/application/webview_window.go +++ b/v3/pkg/application/webview_window.go @@ -121,6 +121,9 @@ func NewWindow(options *WebviewWindowOptions) *WebviewWindow { result.messageProcessor = NewMessageProcessor(result) srv.UseRuntimeHandler(result.messageProcessor) + if !globalApplication.options.InjectRuntime { + srv.DisableRuntime() + } return result }