Radical JS runtime overhaul. New @wailsio/runtime package

This commit is contained in:
Lea Anthony
2023-12-28 19:18:26 +11:00
parent d1255d3a9d
commit b08126d745
61 changed files with 1809 additions and 4726 deletions
+8 -8
View File
@@ -41,26 +41,26 @@ func (m *MessageProcessor) httpError(rw http.ResponseWriter, message string, arg
rw.Write([]byte(fmt.Sprintf(message, args...)))
}
func (m *MessageProcessor) getTargetWindow(r *http.Request) Window {
func (m *MessageProcessor) getTargetWindow(r *http.Request) (Window, string) {
windowName := r.Header.Get(webViewRequestHeaderWindowName)
if windowName != "" {
return globalApplication.GetWindowByName(windowName)
return globalApplication.GetWindowByName(windowName), windowName
}
windowID := r.Header.Get(webViewRequestHeaderWindowId)
if windowID == "" {
return nil
return nil, windowID
}
wID, err := strconv.ParseUint(windowID, 10, 64)
if err != nil {
m.Error("Window ID '%s' not parsable: %s", windowID, err)
return nil
return nil, windowID
}
targetWindow := globalApplication.getWindowForID(uint(wID))
if targetWindow == nil {
m.Error("Window ID %d not found", wID)
return nil
return nil, windowID
}
return targetWindow
return targetWindow, windowID
}
func (m *MessageProcessor) HandleRuntimeCall(rw http.ResponseWriter, r *http.Request) {
@@ -115,9 +115,9 @@ func (m *MessageProcessor) HandleRuntimeCallWithIDs(rw http.ResponseWriter, r *h
}
params := QueryParams(r.URL.Query())
targetWindow := m.getTargetWindow(r)
targetWindow, nameOrID := m.getTargetWindow(r)
if targetWindow == nil {
m.httpError(rw, "No valid window found")
m.httpError(rw, fmt.Sprintf("Window '%s' not found", nameOrID))
return
}