mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-14 14:45:49 +01:00
Merge branch 'master' into bugfix/2431_wayland_max_size
This commit is contained in:
commit
a220d53a91
31 changed files with 368 additions and 155 deletions
|
|
@ -85,6 +85,7 @@ func buildApplication(f *flags.Build) error {
|
|||
GarbleArgs: f.GarbleArgs,
|
||||
SkipBindings: f.SkipBindings,
|
||||
ProjectData: projectOptions,
|
||||
SkipEmbedCreate: f.SkipEmbedCreate,
|
||||
}
|
||||
|
||||
tableData := pterm.TableData{
|
||||
|
|
|
|||
|
|
@ -2,12 +2,13 @@ package main
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/wailsapp/wails/v2/internal/shell"
|
||||
"runtime"
|
||||
"runtime/debug"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/wailsapp/wails/v2/internal/shell"
|
||||
|
||||
"github.com/pterm/pterm"
|
||||
|
||||
"github.com/jaypipes/ghw"
|
||||
|
|
@ -78,6 +79,7 @@ func diagnoseEnvironment(f *flags.Doctor) error {
|
|||
{pterm.Bold.Sprint("OS"), info.OS.Name},
|
||||
{pterm.Bold.Sprint("Version"), info.OS.Version},
|
||||
{pterm.Bold.Sprint("ID"), info.OS.ID},
|
||||
{pterm.Bold.Sprint("Branding"), info.OS.Branding},
|
||||
{pterm.Bold.Sprint("Go Version"), runtime.Version()},
|
||||
{pterm.Bold.Sprint("Platform"), runtime.GOOS},
|
||||
{pterm.Bold.Sprint("Architecture"), runtime.GOARCH},
|
||||
|
|
|
|||
|
|
@ -1,15 +1,16 @@
|
|||
package flags
|
||||
|
||||
type BuildCommon struct {
|
||||
LdFlags string `description:"Additional ldflags to pass to the compiler"`
|
||||
Compiler string `description:"Use a different go compiler to build, eg go1.15beta1"`
|
||||
SkipBindings bool `description:"Skips generation of bindings"`
|
||||
RaceDetector bool `name:"race" description:"Build with Go's race detector"`
|
||||
SkipFrontend bool `name:"s" description:"Skips building the frontend"`
|
||||
Verbosity int `name:"v" description:"Verbosity level (0 = quiet, 1 = normal, 2 = verbose)"`
|
||||
Tags string `description:"Build tags to pass to Go compiler. Must be quoted. Space or comma (but not both) separated"`
|
||||
NoSyncGoMod bool `description:"Don't sync go.mod"`
|
||||
SkipModTidy bool `name:"m" description:"Skip mod tidy before compile"`
|
||||
LdFlags string `description:"Additional ldflags to pass to the compiler"`
|
||||
Compiler string `description:"Use a different go compiler to build, eg go1.15beta1"`
|
||||
SkipBindings bool `description:"Skips generation of bindings"`
|
||||
RaceDetector bool `name:"race" description:"Build with Go's race detector"`
|
||||
SkipFrontend bool `name:"s" description:"Skips building the frontend"`
|
||||
Verbosity int `name:"v" description:"Verbosity level (0 = quiet, 1 = normal, 2 = verbose)"`
|
||||
Tags string `description:"Build tags to pass to Go compiler. Must be quoted. Space or comma (but not both) separated"`
|
||||
NoSyncGoMod bool `description:"Don't sync go.mod"`
|
||||
SkipModTidy bool `name:"m" description:"Skip mod tidy before compile"`
|
||||
SkipEmbedCreate bool `description:"Skips creation of embed files"`
|
||||
}
|
||||
|
||||
func (c BuildCommon) Default() BuildCommon {
|
||||
|
|
|
|||
|
|
@ -117,21 +117,23 @@ func (d *Dev) loadAndMergeProjectConfig() error {
|
|||
// GenerateBuildOptions creates a build.Options using the flags
|
||||
func (d *Dev) GenerateBuildOptions() *build.Options {
|
||||
result := &build.Options{
|
||||
OutputType: "dev",
|
||||
Mode: build.Dev,
|
||||
Devtools: true,
|
||||
Arch: runtime.GOARCH,
|
||||
Pack: true,
|
||||
Platform: runtime.GOOS,
|
||||
LDFlags: d.LdFlags,
|
||||
Compiler: d.Compiler,
|
||||
ForceBuild: d.ForceBuild,
|
||||
IgnoreFrontend: d.SkipFrontend,
|
||||
SkipBindings: d.SkipBindings,
|
||||
Verbosity: d.Verbosity,
|
||||
WailsJSDir: d.WailsJSDir,
|
||||
RaceDetector: d.RaceDetector,
|
||||
ProjectData: d.projectConfig,
|
||||
OutputType: "dev",
|
||||
Mode: build.Dev,
|
||||
Devtools: true,
|
||||
Arch: runtime.GOARCH,
|
||||
Pack: true,
|
||||
Platform: runtime.GOOS,
|
||||
LDFlags: d.LdFlags,
|
||||
Compiler: d.Compiler,
|
||||
ForceBuild: d.ForceBuild,
|
||||
IgnoreFrontend: d.SkipFrontend,
|
||||
SkipBindings: d.SkipBindings,
|
||||
SkipModTidy: d.SkipModTidy,
|
||||
Verbosity: d.Verbosity,
|
||||
WailsJSDir: d.WailsJSDir,
|
||||
RaceDetector: d.RaceDetector,
|
||||
ProjectData: d.projectConfig,
|
||||
SkipEmbedCreate: d.SkipEmbedCreate,
|
||||
}
|
||||
|
||||
return result
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ require (
|
|||
github.com/godbus/dbus/v5 v5.1.0
|
||||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/gorilla/websocket v1.5.3
|
||||
github.com/jackmordaunt/icns v1.0.0
|
||||
github.com/jaypipes/ghw v0.13.0
|
||||
github.com/labstack/echo/v4 v4.13.3
|
||||
|
|
|
|||
|
|
@ -107,6 +107,8 @@ github.com/gookit/color v1.5.4 h1:FZmqs7XOyGgCAxmWyPslpiok1k05wmY3SJTytgvYFs0=
|
|||
github.com/gookit/color v1.5.4/go.mod h1:pZJOeOS8DM43rXbp4AZo1n9zCU2qjpcRko0b6/QJi9w=
|
||||
github.com/gorilla/css v1.0.1 h1:ntNaBIghp6JmvWnxbZKANoLyuXTPZ4cAMlo6RyhlbO8=
|
||||
github.com/gorilla/css v1.0.1/go.mod h1:BvnYkspnSzMmwRK+b8/xgNPLiIuNZr6vbZBTPQ2A3b0=
|
||||
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
|
||||
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=
|
||||
github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=
|
||||
github.com/itchyny/gojq v0.12.13 h1:IxyYlHYIlspQHHTE0f3cJF0NKDMfajxViuhBLnHd/QU=
|
||||
|
|
|
|||
|
|
@ -46,7 +46,12 @@ func CreateApp(appoptions *options.App) (*App, error) {
|
|||
ctx = context.WithValue(ctx, "debug", true)
|
||||
ctx = context.WithValue(ctx, "devtoolsEnabled", true)
|
||||
|
||||
// Set up logger
|
||||
// Set up logger if the appoptions.LogLevel is an invalid value, set it to the default log level
|
||||
appoptions.LogLevel, err = pkglogger.StringToLogLevel(appoptions.LogLevel.String())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
myLogger := logger.New(appoptions.Logger)
|
||||
myLogger.SetLogLevel(appoptions.LogLevel)
|
||||
|
||||
|
|
@ -91,15 +96,8 @@ func CreateApp(appoptions *options.App) (*App, error) {
|
|||
if frontendDevServerURLFlag != nil {
|
||||
frontendDevServerURL = *frontendDevServerURLFlag
|
||||
}
|
||||
// Only override LogLevel if the flag was explicitly set
|
||||
if loglevelFlag != nil && devFlags.Lookup("loglevel").Value.String() != appoptions.LogLevel.String() {
|
||||
loggerLevel, err := pkglogger.StringToLogLevel(*loglevelFlag)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if loggerLevel != appoptions.LogLevel {
|
||||
myLogger.SetLogLevel(loggerLevel)
|
||||
}
|
||||
if loglevelFlag != nil {
|
||||
loglevel = *loglevelFlag
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -176,6 +174,17 @@ func CreateApp(appoptions *options.App) (*App, error) {
|
|||
ctx = context.WithValue(ctx, "devserver", devServer)
|
||||
}
|
||||
|
||||
if loglevel != "" {
|
||||
level, err := pkglogger.StringToLogLevel(loglevel)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Only set the log level if it's different from the appoptions.LogLevel
|
||||
if level != appoptions.LogLevel {
|
||||
myLogger.SetLogLevel(level)
|
||||
}
|
||||
}
|
||||
|
||||
// Attach logger to context
|
||||
ctx = context.WithValue(ctx, "logger", myLogger)
|
||||
ctx = context.WithValue(ctx, "buildtype", "dev")
|
||||
|
|
@ -212,7 +221,7 @@ func CreateApp(appoptions *options.App) (*App, error) {
|
|||
|
||||
eventHandler := runtime.NewEvents(myLogger)
|
||||
ctx = context.WithValue(ctx, "events", eventHandler)
|
||||
messageDispatcher := dispatcher.NewDispatcher(ctx, myLogger, appBindings, eventHandler, appoptions.ErrorFormatter)
|
||||
messageDispatcher := dispatcher.NewDispatcher(ctx, myLogger, appBindings, eventHandler, appoptions.ErrorFormatter, appoptions.DisablePanicRecovery)
|
||||
|
||||
// Create the frontends and register to event handler
|
||||
desktopFrontend := desktop.NewFrontend(ctx, appoptions, myLogger, appBindings, messageDispatcher)
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ func CreateApp(appoptions *options.App) (*App, error) {
|
|||
ctx = context.WithValue(ctx, "buildtype", "production")
|
||||
}
|
||||
|
||||
messageDispatcher := dispatcher.NewDispatcher(ctx, myLogger, appBindings, eventHandler, appoptions.ErrorFormatter)
|
||||
messageDispatcher := dispatcher.NewDispatcher(ctx, myLogger, appBindings, eventHandler, appoptions.ErrorFormatter, appoptions.DisablePanicRecovery)
|
||||
appFrontend := desktop.NewFrontend(ctx, appoptions, myLogger, appBindings, messageDispatcher)
|
||||
eventHandler.AddFrontend(appFrontend)
|
||||
|
||||
|
|
|
|||
|
|
@ -63,18 +63,18 @@ export namespace binding_test {
|
|||
DoubleFour: number[][];
|
||||
Triple: number[][][];
|
||||
SingleMap: Record<string, number>;
|
||||
SliceMap: Record<string, number[]>;
|
||||
DoubleSliceMap: Record<string, number[][]>;
|
||||
ArrayMap: Record<string, number[]>;
|
||||
DoubleArrayMap1: Record<string, number[][]>;
|
||||
DoubleArrayMap2: Record<string, number[][]>;
|
||||
DoubleArrayMap3: Record<string, number[][]>;
|
||||
SliceMap: Record<string, Array<number>>;
|
||||
DoubleSliceMap: Record<string, Array<Array<number>>>;
|
||||
ArrayMap: Record<string, Array<number>>;
|
||||
DoubleArrayMap1: Record<string, Array<Array<number>>>;
|
||||
DoubleArrayMap2: Record<string, Array<Array<number>>>;
|
||||
DoubleArrayMap3: Record<string, Array<Array<number>>>;
|
||||
OneStructs: DeepMessage[];
|
||||
TwoStructs: DeepMessage[][];
|
||||
ThreeStructs: DeepMessage[][][];
|
||||
MapStructs: Record<string, DeepMessage[]>;
|
||||
MapTwoStructs: Record<string, DeepMessage[][]>;
|
||||
MapThreeStructs: Record<string, DeepMessage[][][]>;
|
||||
MapStructs: Record<string, Array<DeepMessage>>;
|
||||
MapTwoStructs: Record<string, Array<Array<DeepMessage>>>;
|
||||
MapThreeStructs: Record<string, Array<Array<Array<DeepMessage>>>>;
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new DeepElements(source);
|
||||
|
|
@ -97,9 +97,9 @@ export namespace binding_test {
|
|||
this.OneStructs = this.convertValues(source["OneStructs"], DeepMessage);
|
||||
this.TwoStructs = this.convertValues(source["TwoStructs"], DeepMessage);
|
||||
this.ThreeStructs = this.convertValues(source["ThreeStructs"], DeepMessage);
|
||||
this.MapStructs = this.convertValues(source["MapStructs"], DeepMessage[], true);
|
||||
this.MapTwoStructs = this.convertValues(source["MapTwoStructs"], DeepMessage[][], true);
|
||||
this.MapThreeStructs = this.convertValues(source["MapThreeStructs"], DeepMessage[][][], true);
|
||||
this.MapStructs = this.convertValues(source["MapStructs"], Array<DeepMessage>, true);
|
||||
this.MapTwoStructs = this.convertValues(source["MapTwoStructs"], Array<Array<DeepMessage>>, true);
|
||||
this.MapThreeStructs = this.convertValues(source["MapThreeStructs"], Array<Array<Array<DeepMessage>>>, true);
|
||||
}
|
||||
|
||||
convertValues(a: any, classs: any, asMap: boolean = false): any {
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ func (fm *Form) Restore() {
|
|||
SC_RESTORE,
|
||||
0,
|
||||
)
|
||||
w32.ShowWindow(fm.hwnd, w32.SW_RESTORE)
|
||||
w32.ShowWindow(fm.hwnd, w32.SW_SHOW)
|
||||
}
|
||||
|
||||
// Public methods
|
||||
|
|
|
|||
|
|
@ -20,17 +20,23 @@ import (
|
|||
|
||||
"github.com/wailsapp/wails/v2/internal/frontend/runtime"
|
||||
|
||||
"github.com/gorilla/websocket"
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/wailsapp/wails/v2/internal/binding"
|
||||
"github.com/wailsapp/wails/v2/internal/frontend"
|
||||
"github.com/wailsapp/wails/v2/internal/logger"
|
||||
"github.com/wailsapp/wails/v2/internal/menumanager"
|
||||
"github.com/wailsapp/wails/v2/pkg/options"
|
||||
"golang.org/x/net/websocket"
|
||||
)
|
||||
|
||||
type Screen = frontend.Screen
|
||||
|
||||
var upgrader = websocket.Upgrader{
|
||||
ReadBufferSize: 1024,
|
||||
WriteBufferSize: 1024,
|
||||
CheckOrigin: func(r *http.Request) bool { return true },
|
||||
}
|
||||
|
||||
type DevWebServer struct {
|
||||
server *echo.Echo
|
||||
ctx context.Context
|
||||
|
|
@ -155,51 +161,64 @@ func (d *DevWebServer) handleReloadApp(c echo.Context) error {
|
|||
}
|
||||
|
||||
func (d *DevWebServer) handleIPCWebSocket(c echo.Context) error {
|
||||
websocket.Handler(func(c *websocket.Conn) {
|
||||
d.LogDebug(fmt.Sprintf("Websocket client %p connected", c))
|
||||
conn, err := upgrader.Upgrade(c.Response(), c.Request(), nil)
|
||||
if err != nil {
|
||||
d.logger.Error("WebSocket upgrade failed %v", err)
|
||||
return err
|
||||
}
|
||||
d.LogDebug(fmt.Sprintf("WebSocket client %p connected", conn))
|
||||
|
||||
d.socketMutex.Lock()
|
||||
d.websocketClients[conn] = &sync.Mutex{}
|
||||
locker := d.websocketClients[conn]
|
||||
d.socketMutex.Unlock()
|
||||
|
||||
var wg sync.WaitGroup
|
||||
|
||||
defer func() {
|
||||
wg.Wait()
|
||||
d.socketMutex.Lock()
|
||||
d.websocketClients[c] = &sync.Mutex{}
|
||||
locker := d.websocketClients[c]
|
||||
delete(d.websocketClients, conn)
|
||||
d.socketMutex.Unlock()
|
||||
d.LogDebug(fmt.Sprintf("WebSocket client %p disconnected", conn))
|
||||
conn.Close()
|
||||
}()
|
||||
|
||||
defer func() {
|
||||
d.socketMutex.Lock()
|
||||
delete(d.websocketClients, c)
|
||||
d.socketMutex.Unlock()
|
||||
d.LogDebug(fmt.Sprintf("Websocket client %p disconnected", c))
|
||||
}()
|
||||
for {
|
||||
_, msgBytes, err := conn.ReadMessage()
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
|
||||
var msg string
|
||||
defer c.Close()
|
||||
for {
|
||||
if err := websocket.Message.Receive(c, &msg); err != nil {
|
||||
break
|
||||
}
|
||||
// We do not support drag in browsers
|
||||
if msg == "drag" {
|
||||
continue
|
||||
msg := string(msgBytes)
|
||||
wg.Add(1)
|
||||
|
||||
go func(m string) {
|
||||
defer wg.Done()
|
||||
|
||||
if m == "drag" {
|
||||
return
|
||||
}
|
||||
|
||||
// Notify the other browsers of "EventEmit"
|
||||
if len(msg) > 2 && strings.HasPrefix(string(msg), "EE") {
|
||||
d.notifyExcludingSender([]byte(msg), c)
|
||||
if len(m) > 2 && strings.HasPrefix(m, "EE") {
|
||||
d.notifyExcludingSender([]byte(m), conn)
|
||||
}
|
||||
|
||||
// Send the message to dispatch to the frontend
|
||||
result, err := d.dispatcher.ProcessMessage(string(msg), d)
|
||||
result, err := d.dispatcher.ProcessMessage(m, d)
|
||||
if err != nil {
|
||||
d.logger.Error(err.Error())
|
||||
}
|
||||
|
||||
if result != "" {
|
||||
locker.Lock()
|
||||
if err = websocket.Message.Send(c, result); err != nil {
|
||||
locker.Unlock()
|
||||
break
|
||||
defer locker.Unlock()
|
||||
if err := conn.WriteMessage(websocket.TextMessage, []byte(result)); err != nil {
|
||||
d.logger.Error("Websocket write message failed %v", err)
|
||||
}
|
||||
locker.Unlock()
|
||||
}
|
||||
}
|
||||
}).ServeHTTP(c.Response(), c.Request())
|
||||
}(msg)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -222,7 +241,7 @@ func (d *DevWebServer) broadcast(message string) {
|
|||
return
|
||||
}
|
||||
locker.Lock()
|
||||
err := websocket.Message.Send(client, message)
|
||||
err := client.WriteMessage(websocket.TextMessage, []byte(message))
|
||||
if err != nil {
|
||||
locker.Unlock()
|
||||
d.logger.Error(err.Error())
|
||||
|
|
@ -256,7 +275,7 @@ func (d *DevWebServer) broadcastExcludingSender(message string, sender *websocke
|
|||
return
|
||||
}
|
||||
locker.Lock()
|
||||
err := websocket.Message.Send(client, message)
|
||||
err := client.WriteMessage(websocket.TextMessage, []byte(message))
|
||||
if err != nil {
|
||||
locker.Unlock()
|
||||
d.logger.Error(err.Error())
|
||||
|
|
|
|||
|
|
@ -11,38 +11,42 @@ import (
|
|||
)
|
||||
|
||||
type Dispatcher struct {
|
||||
log *logger.Logger
|
||||
bindings *binding.Bindings
|
||||
events frontend.Events
|
||||
bindingsDB *binding.DB
|
||||
ctx context.Context
|
||||
errfmt options.ErrorFormatter
|
||||
log *logger.Logger
|
||||
bindings *binding.Bindings
|
||||
events frontend.Events
|
||||
bindingsDB *binding.DB
|
||||
ctx context.Context
|
||||
errfmt options.ErrorFormatter
|
||||
disablePanicRecovery bool
|
||||
}
|
||||
|
||||
func NewDispatcher(ctx context.Context, log *logger.Logger, bindings *binding.Bindings, events frontend.Events, errfmt options.ErrorFormatter) *Dispatcher {
|
||||
func NewDispatcher(ctx context.Context, log *logger.Logger, bindings *binding.Bindings, events frontend.Events, errfmt options.ErrorFormatter, disablePanicRecovery bool) *Dispatcher {
|
||||
return &Dispatcher{
|
||||
log: log,
|
||||
bindings: bindings,
|
||||
events: events,
|
||||
bindingsDB: bindings.DB(),
|
||||
ctx: ctx,
|
||||
errfmt: errfmt,
|
||||
log: log,
|
||||
bindings: bindings,
|
||||
events: events,
|
||||
bindingsDB: bindings.DB(),
|
||||
ctx: ctx,
|
||||
errfmt: errfmt,
|
||||
disablePanicRecovery: disablePanicRecovery,
|
||||
}
|
||||
}
|
||||
|
||||
func (d *Dispatcher) ProcessMessage(message string, sender frontend.Frontend) (_ string, err error) {
|
||||
defer func() {
|
||||
if e := recover(); e != nil {
|
||||
if errPanic, ok := e.(error); ok {
|
||||
err = errPanic
|
||||
} else {
|
||||
err = fmt.Errorf("%v", e)
|
||||
if !d.disablePanicRecovery {
|
||||
defer func() {
|
||||
if e := recover(); e != nil {
|
||||
if errPanic, ok := e.(error); ok {
|
||||
err = errPanic
|
||||
} else {
|
||||
err = fmt.Errorf("%v", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
d.log.Error("process message error: %s -> %s", message, err)
|
||||
}
|
||||
}()
|
||||
if err != nil {
|
||||
d.log.Error("process message error: %s -> %s", message, err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
if message == "" {
|
||||
return "", errors.New("No message to process")
|
||||
|
|
|
|||
|
|
@ -2,9 +2,10 @@ package operatingsystem
|
|||
|
||||
// OS contains information about the operating system
|
||||
type OS struct {
|
||||
ID string
|
||||
Name string
|
||||
Version string
|
||||
ID string
|
||||
Name string
|
||||
Version string
|
||||
Branding string
|
||||
}
|
||||
|
||||
// Info retrieves information about the current platform
|
||||
|
|
|
|||
|
|
@ -4,10 +4,44 @@ package operatingsystem
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/windows"
|
||||
"golang.org/x/sys/windows/registry"
|
||||
)
|
||||
|
||||
func stripNulls(str string) string {
|
||||
// Split the string into substrings at each null character
|
||||
substrings := strings.Split(str, "\x00")
|
||||
|
||||
// Join the substrings back into a single string
|
||||
strippedStr := strings.Join(substrings, "")
|
||||
|
||||
return strippedStr
|
||||
}
|
||||
|
||||
func mustStringToUTF16Ptr(input string) *uint16 {
|
||||
input = stripNulls(input)
|
||||
result, err := syscall.UTF16PtrFromString(input)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func getBranding() string {
|
||||
var modBranding = syscall.NewLazyDLL("winbrand.dll")
|
||||
var brandingFormatString = modBranding.NewProc("BrandingFormatString")
|
||||
|
||||
windowsLong := mustStringToUTF16Ptr("%WINDOWS_LONG%\x00")
|
||||
ret, _, _ := brandingFormatString.Call(
|
||||
uintptr(unsafe.Pointer(windowsLong)),
|
||||
)
|
||||
return windows.UTF16PtrToString((*uint16)(unsafe.Pointer(ret)))
|
||||
}
|
||||
|
||||
func platformInfo() (*OS, error) {
|
||||
// Default value
|
||||
var result OS
|
||||
|
|
@ -27,6 +61,7 @@ func platformInfo() (*OS, error) {
|
|||
result.Name = productName
|
||||
result.Version = fmt.Sprintf("%s (Build: %s)", releaseId, currentBuild)
|
||||
result.ID = displayVersion
|
||||
result.Branding = getBranding()
|
||||
|
||||
return &result, key.Close()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,9 +40,7 @@ const (
|
|||
jsVariableNameRegex = `^([A-Z]|[a-z]|\$|_)([A-Z]|[a-z]|[0-9]|\$|_)*$`
|
||||
)
|
||||
|
||||
var (
|
||||
jsVariableUnsafeChars = regexp.MustCompile(`[^A-Za-z0-9_]`)
|
||||
)
|
||||
var jsVariableUnsafeChars = regexp.MustCompile(`[^A-Za-z0-9_]`)
|
||||
|
||||
func nameTypeOf(typeOf reflect.Type) string {
|
||||
tname := typeOf.Name()
|
||||
|
|
@ -277,6 +275,7 @@ func (t *typeScriptClassBuilder) AddMapField(fieldName string, field reflect.Str
|
|||
valueType := field.Type.Elem()
|
||||
valueTypeName := nameTypeOf(valueType)
|
||||
valueTypeSuffix := ""
|
||||
valueTypePrefix := ""
|
||||
if valueType.Kind() == reflect.Ptr {
|
||||
valueType = valueType.Elem()
|
||||
valueTypeName = nameTypeOf(valueType)
|
||||
|
|
@ -289,7 +288,8 @@ func (t *typeScriptClassBuilder) AddMapField(fieldName string, field reflect.Str
|
|||
}
|
||||
valueType = valueType.Elem()
|
||||
valueTypeName = nameTypeOf(valueType)
|
||||
valueTypeSuffix = strings.Repeat("[]", arrayDepth)
|
||||
valueTypeSuffix = strings.Repeat(">", arrayDepth)
|
||||
valueTypePrefix = strings.Repeat("Array<", arrayDepth)
|
||||
}
|
||||
if valueType.Kind() == reflect.Ptr {
|
||||
valueType = valueType.Elem()
|
||||
|
|
@ -325,10 +325,10 @@ func (t *typeScriptClassBuilder) AddMapField(fieldName string, field reflect.Str
|
|||
fieldName = fmt.Sprintf(`"%s"?`, strippedFieldName)
|
||||
}
|
||||
}
|
||||
t.fields = append(t.fields, fmt.Sprintf("%s%s: Record<%s, %s>;", t.indent, fieldName, keyTypeStr, valueTypeName+valueTypeSuffix))
|
||||
t.fields = append(t.fields, fmt.Sprintf("%s%s: Record<%s, %s>;", t.indent, fieldName, keyTypeStr, valueTypePrefix+valueTypeName+valueTypeSuffix))
|
||||
if valueType.Kind() == reflect.Struct {
|
||||
t.constructorBody = append(t.constructorBody, fmt.Sprintf("%s%sthis%s = this.convertValues(source[\"%s\"], %s, true);",
|
||||
t.indent, t.indent, dotField, strippedFieldName, t.prefix+valueTypeName+valueTypeSuffix+t.suffix))
|
||||
t.indent, t.indent, dotField, strippedFieldName, t.prefix+valueTypePrefix+valueTypeName+valueTypeSuffix+t.suffix))
|
||||
} else {
|
||||
t.constructorBody = append(t.constructorBody, fmt.Sprintf("%s%sthis%s = source[\"%s\"];",
|
||||
t.indent, t.indent, dotField, strippedFieldName))
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ RequestExecutionLevel "${REQUEST_EXECUTION_LEVEL}"
|
|||
|
||||
${If} ${REQUEST_EXECUTION_LEVEL} == "user"
|
||||
# If the installer is run in user level, check the user specific key exists and is not empty then webview2 is already installed
|
||||
ReadRegStr $0 HKCU "Software\Microsoft\EdgeUpdate\Clients{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}" "pv"
|
||||
ReadRegStr $0 HKCU "Software\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}" "pv"
|
||||
${If} $0 != ""
|
||||
Goto ok
|
||||
${EndIf}
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ type Options struct {
|
|||
Obfuscated bool // Indicates that bound methods should be obfuscated
|
||||
GarbleArgs string // The arguments for Garble
|
||||
SkipBindings bool // Skip binding generation
|
||||
SkipEmbedCreate bool // Skip creation of embed files
|
||||
}
|
||||
|
||||
// Build the project!
|
||||
|
|
@ -120,8 +121,10 @@ func Build(options *Options) (string, error) {
|
|||
}
|
||||
|
||||
// Create embed directories if they don't exist
|
||||
if err := CreateEmbedDirectories(cwd, options); err != nil {
|
||||
return "", err
|
||||
if !options.SkipEmbedCreate {
|
||||
if err := CreateEmbedDirectories(cwd, options); err != nil {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
|
||||
// Generate bindings
|
||||
|
|
|
|||
|
|
@ -98,6 +98,9 @@ type App struct {
|
|||
|
||||
// DragAndDrop options for drag and drop behavior
|
||||
DragAndDrop *DragAndDrop
|
||||
|
||||
// DisablePanicRecovery disables the panic recovery system in messages processing
|
||||
DisablePanicRecovery bool
|
||||
}
|
||||
|
||||
type ErrorFormatter func(error) any
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue