mirror of
https://github.com/taigrr/wails.git
synced 2026-04-17 04:05:12 -07:00
Compare commits
5 Commits
v2.0.0-alp
...
v2.0.0-alp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2b5bbfd897 | ||
|
|
d2020fedda | ||
|
|
98789bd85a | ||
|
|
e6ace2fafd | ||
|
|
a55fc4d0e9 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -22,8 +22,6 @@ v2/test/**/frontend/dist
|
|||||||
v2/test/**/build/
|
v2/test/**/build/
|
||||||
v2/test/frameless/icon.png
|
v2/test/frameless/icon.png
|
||||||
v2/test/hidden/icon.png
|
v2/test/hidden/icon.png
|
||||||
v2/internal/ffenestri/runtime.c
|
|
||||||
v2/internal/runtime/assets/desktop.js
|
|
||||||
v2/test/kitchensink/frontend/public/bundle.*
|
v2/test/kitchensink/frontend/public/bundle.*
|
||||||
v2/pkg/parser/testproject/frontend/wails
|
v2/pkg/parser/testproject/frontend/wails
|
||||||
v2/test/kitchensink/frontend/public
|
v2/test/kitchensink/frontend/public
|
||||||
|
|||||||
@@ -147,7 +147,12 @@ This project was mainly coded to the following albums:
|
|||||||
|
|
||||||
[](https://app.fossa.io/projects/git%2Bgithub.com%2Fwailsapp%2Fwails?ref=badge_large)
|
[](https://app.fossa.io/projects/git%2Bgithub.com%2Fwailsapp%2Fwails?ref=badge_large)
|
||||||
|
|
||||||
## Special Thank You
|
## Special Thanks
|
||||||
|
|
||||||
|
<p align="center" style="text-align: center">
|
||||||
|
A *huge* thanks to <a href="https://pace.dev"><img src="pace.jpeg"/> Pace</a> for sponsoring the project and helping the efforts to get Wails ported to Apple Silicon!<br/><br/>
|
||||||
|
If you are looking for a Project Management tool that's powerful but quick and easy to use, check them out!<br/><br/>
|
||||||
|
</p>
|
||||||
|
|
||||||
<p align="center" style="text-align: center">
|
<p align="center" style="text-align: center">
|
||||||
A special thank you to JetBrains for donating licenses to us!<br/><br/>
|
A special thank you to JetBrains for donating licenses to us!<br/><br/>
|
||||||
|
|||||||
@@ -98,15 +98,15 @@
|
|||||||
#define NSAlertThirdButtonReturn 1002
|
#define NSAlertThirdButtonReturn 1002
|
||||||
|
|
||||||
// References to assets
|
// References to assets
|
||||||
extern const unsigned char *assets[];
|
#include "assets.h"
|
||||||
extern const unsigned char runtime;
|
extern const unsigned char runtime;
|
||||||
|
|
||||||
// Tray icons
|
// Tray icons
|
||||||
extern const unsigned char *trayIcons[];
|
#include "trayicons.h"
|
||||||
|
|
||||||
// Dialog icons
|
// Dialog icons
|
||||||
extern const unsigned char *defaultDialogIcons[];
|
extern const unsigned char *defaultDialogIcons[];
|
||||||
extern const unsigned char *userDialogIcons[];
|
#include "userdialogicons.h"
|
||||||
|
|
||||||
// MAIN DEBUG FLAG
|
// MAIN DEBUG FLAG
|
||||||
int debug;
|
int debug;
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ func (a *AssetBundle) WriteToCFile(targetDir string) (string, error) {
|
|||||||
var cdata strings.Builder
|
var cdata strings.Builder
|
||||||
|
|
||||||
// Write header
|
// Write header
|
||||||
header := `// assets.c
|
header := `// assets.h
|
||||||
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Ă‚ MODIWL.
|
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Ă‚ MODIWL.
|
||||||
// This file was auto-generated. DO NOT MODIFY.
|
// This file was auto-generated. DO NOT MODIFY.
|
||||||
|
|
||||||
@@ -185,7 +185,7 @@ func (a *AssetBundle) WriteToCFile(targetDir string) (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Save file
|
// Save file
|
||||||
assetsFile := filepath.Join(targetDir, "assets.c")
|
assetsFile := filepath.Join(targetDir, "assets.h")
|
||||||
err = ioutil.WriteFile(assetsFile, []byte(cdata.String()), 0600)
|
err = ioutil.WriteFile(assetsFile, []byte(cdata.String()), 0600)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ type Runtime struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// New creates a new runtime
|
// New creates a new runtime
|
||||||
func New(serviceBus *servicebus.ServiceBus, menu *menu.Menu, trayMenu *menu.TrayOptions, contextMenus *menu.ContextMenus) *Runtime {
|
func New(serviceBus *servicebus.ServiceBus, menu *menu.Menu, trayMenu *menu.Tray, contextMenus *menu.ContextMenus) *Runtime {
|
||||||
result := &Runtime{
|
result := &Runtime{
|
||||||
Browser: newBrowser(),
|
Browser: newBrowser(),
|
||||||
Events: newEvents(serviceBus),
|
Events: newEvents(serviceBus),
|
||||||
|
|||||||
76
v2/internal/runtime/scripts/rebuild.go
Normal file
76
v2/internal/runtime/scripts/rebuild.go
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"fmt"
|
||||||
|
"github.com/wailsapp/wails/v2/internal/fs"
|
||||||
|
"github.com/wailsapp/wails/v2/internal/shell"
|
||||||
|
"io/ioutil"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
|
||||||
|
sourceDir := fs.RelativePath("../../../internal/runtime/js")
|
||||||
|
|
||||||
|
platforms := []string{"darwin"}
|
||||||
|
|
||||||
|
for _, platform := range platforms {
|
||||||
|
println("Building JS Runtime for " + platform)
|
||||||
|
envvars := []string{"WAILSPLATFORM=" + platform}
|
||||||
|
|
||||||
|
// Split up the InstallCommand and execute it
|
||||||
|
stdout, stderr, err := shell.RunCommand(sourceDir, "npm", "install")
|
||||||
|
if err != nil {
|
||||||
|
for _, l := range strings.Split(stdout, "\n") {
|
||||||
|
fmt.Printf(" %s\n", l)
|
||||||
|
}
|
||||||
|
for _, l := range strings.Split(stderr, "\n") {
|
||||||
|
fmt.Printf(" %s\n", l)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
runtimeDir := fs.RelativePath("../js")
|
||||||
|
cmd := shell.CreateCommand(runtimeDir, "npm", "run", "build:desktop")
|
||||||
|
cmd.Env = append(os.Environ(), envvars...)
|
||||||
|
var stdo, stde bytes.Buffer
|
||||||
|
cmd.Stdout = &stdo
|
||||||
|
cmd.Stderr = &stde
|
||||||
|
err = cmd.Run()
|
||||||
|
if err != nil {
|
||||||
|
for _, l := range strings.Split(stdo.String(), "\n") {
|
||||||
|
fmt.Printf(" %s\n", l)
|
||||||
|
}
|
||||||
|
for _, l := range strings.Split(stde.String(), "\n") {
|
||||||
|
fmt.Printf(" %s\n", l)
|
||||||
|
}
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
wailsJS := fs.RelativePath("../../../internal/runtime/assets/desktop.js")
|
||||||
|
runtimeData, err := ioutil.ReadFile(wailsJS)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert to C structure
|
||||||
|
runtimeC := `
|
||||||
|
// runtime.c (c) 2019-Present Lea Anthony.
|
||||||
|
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Ă‚ MODIWL
|
||||||
|
// This file was auto-generated. DO NOT MODIFY.
|
||||||
|
const unsigned char runtime[]={`
|
||||||
|
for _, b := range runtimeData {
|
||||||
|
runtimeC += fmt.Sprintf("0x%x, ", b)
|
||||||
|
}
|
||||||
|
runtimeC += "0x00};"
|
||||||
|
|
||||||
|
// Save file
|
||||||
|
outputFile := fs.RelativePath(fmt.Sprintf("../../ffenestri/runtime_%s.c", platform))
|
||||||
|
|
||||||
|
if err := ioutil.WriteFile(outputFile, []byte(runtimeC), 0600); err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,8 +8,9 @@ import (
|
|||||||
|
|
||||||
// Tray defines all Tray related operations
|
// Tray defines all Tray related operations
|
||||||
type Tray interface {
|
type Tray interface {
|
||||||
|
NewTray(id string) *menu.Tray
|
||||||
On(menuID string, callback func(*menu.MenuItem))
|
On(menuID string, callback func(*menu.MenuItem))
|
||||||
Update()
|
Update(tray ...*menu.Tray)
|
||||||
GetByID(menuID string) *menu.MenuItem
|
GetByID(menuID string) *menu.MenuItem
|
||||||
RemoveByID(id string) bool
|
RemoveByID(id string) bool
|
||||||
SetLabel(label string)
|
SetLabel(label string)
|
||||||
@@ -18,11 +19,11 @@ type Tray interface {
|
|||||||
|
|
||||||
type trayRuntime struct {
|
type trayRuntime struct {
|
||||||
bus *servicebus.ServiceBus
|
bus *servicebus.ServiceBus
|
||||||
trayMenu *menu.TrayOptions
|
trayMenu *menu.Tray
|
||||||
}
|
}
|
||||||
|
|
||||||
// newTray creates a new Menu struct
|
// newTray creates a new Menu struct
|
||||||
func newTray(bus *servicebus.ServiceBus, menu *menu.TrayOptions) Tray {
|
func newTray(bus *servicebus.ServiceBus, menu *menu.Tray) Tray {
|
||||||
return &trayRuntime{
|
return &trayRuntime{
|
||||||
bus: bus,
|
bus: bus,
|
||||||
trayMenu: menu,
|
trayMenu: menu,
|
||||||
@@ -37,7 +38,16 @@ func (t *trayRuntime) On(menuID string, callback func(*menu.MenuItem)) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *trayRuntime) Update() {
|
// NewTray creates a new Tray item
|
||||||
|
func (t *trayRuntime) NewTray(trayID string) *menu.Tray {
|
||||||
|
return &menu.Tray{
|
||||||
|
ID: trayID,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *trayRuntime) Update(tray ...*menu.Tray) {
|
||||||
|
|
||||||
|
//trayToUpdate := t.trayMenu
|
||||||
t.bus.Publish("tray:update", t.trayMenu)
|
t.bus.Publish("tray:update", t.trayMenu)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ type Runtime struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewRuntime creates a new runtime subsystem
|
// NewRuntime creates a new runtime subsystem
|
||||||
func NewRuntime(bus *servicebus.ServiceBus, logger *logger.Logger, menu *menu.Menu, trayMenu *menu.TrayOptions, contextMenus *menu.ContextMenus) (*Runtime, error) {
|
func NewRuntime(bus *servicebus.ServiceBus, logger *logger.Logger, menu *menu.Menu, trayMenu *menu.Tray, contextMenus *menu.ContextMenus) (*Runtime, error) {
|
||||||
|
|
||||||
// Register quit channel
|
// Register quit channel
|
||||||
quitChannel, err := bus.Subscribe("quit")
|
quitChannel, err := bus.Subscribe("quit")
|
||||||
|
|||||||
@@ -26,14 +26,14 @@ type Tray struct {
|
|||||||
logger logger.CustomLogger
|
logger logger.CustomLogger
|
||||||
|
|
||||||
// The tray menu
|
// The tray menu
|
||||||
trayMenu *menu.TrayOptions
|
trayMenu *menu.Tray
|
||||||
|
|
||||||
// Service Bus
|
// Service Bus
|
||||||
bus *servicebus.ServiceBus
|
bus *servicebus.ServiceBus
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewTray creates a new menu subsystem
|
// NewTray creates a new menu subsystem
|
||||||
func NewTray(trayMenu *menu.TrayOptions, bus *servicebus.ServiceBus,
|
func NewTray(trayMenu *menu.Tray, bus *servicebus.ServiceBus,
|
||||||
logger *logger.Logger) (*Tray, error) {
|
logger *logger.Logger) (*Tray, error) {
|
||||||
|
|
||||||
// Register quit channel
|
// Register quit channel
|
||||||
|
|||||||
@@ -206,6 +206,15 @@ func (b *BaseBuilder) CompileProject(options *Options) error {
|
|||||||
// Set GO111MODULE environment variable
|
// Set GO111MODULE environment variable
|
||||||
cmd.Env = append(os.Environ(), "GO111MODULE=on")
|
cmd.Env = append(os.Environ(), "GO111MODULE=on")
|
||||||
|
|
||||||
|
// Add CGO flags
|
||||||
|
// We use the project/build dir as a temporary place for our generated c headers
|
||||||
|
buildBaseDir, err := fs.RelativeToCwd("build")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.Env = append(os.Environ(), fmt.Sprintf("CGO_CFLAGS=-I%s", buildBaseDir))
|
||||||
|
|
||||||
// Setup buffers
|
// Setup buffers
|
||||||
var stdo, stde bytes.Buffer
|
var stdo, stde bytes.Buffer
|
||||||
cmd.Stdout = &stdo
|
cmd.Stdout = &stdo
|
||||||
|
|||||||
@@ -113,10 +113,6 @@ func Build(options *Options) (string, error) {
|
|||||||
|
|
||||||
// Build the base assets
|
// Build the base assets
|
||||||
outputLogger.Println(" - Compiling Assets")
|
outputLogger.Println(" - Compiling Assets")
|
||||||
err = builder.BuildRuntime(options)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
err = builder.BuildAssets(options)
|
err = builder.BuildAssets(options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
|||||||
@@ -64,7 +64,10 @@ func (d *DesktopBuilder) BuildBaseAssets(assets *html.AssetBundle, options *Opti
|
|||||||
outputLogger.Print(" - Embedding Assets...")
|
outputLogger.Print(" - Embedding Assets...")
|
||||||
|
|
||||||
// Get target asset directory
|
// Get target asset directory
|
||||||
assetDir := fs.RelativePath("../../../internal/ffenestri")
|
assetDir, err := fs.RelativeToCwd("build")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// Dump assets as C
|
// Dump assets as C
|
||||||
assetsFile, err := assets.WriteToCFile(assetDir)
|
assetsFile, err := assets.WriteToCFile(assetDir)
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ func (d *DesktopBuilder) processTrayIcons(assetDir string, options *Options) err
|
|||||||
|
|
||||||
// Setup target
|
// Setup target
|
||||||
targetFilename := "trayicons"
|
targetFilename := "trayicons"
|
||||||
targetFile := filepath.Join(assetDir, targetFilename+".c")
|
targetFile := filepath.Join(assetDir, targetFilename+".h")
|
||||||
d.addFileToDelete(targetFile)
|
d.addFileToDelete(targetFile)
|
||||||
|
|
||||||
var dataBytes []byte
|
var dataBytes []byte
|
||||||
@@ -55,7 +55,7 @@ func (d *DesktopBuilder) processTrayIcons(assetDir string, options *Options) err
|
|||||||
var cdata strings.Builder
|
var cdata strings.Builder
|
||||||
|
|
||||||
// Write header
|
// Write header
|
||||||
header := `// trayicons.c
|
header := `// trayicons.h
|
||||||
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Ă‚ MODIWL.
|
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Ă‚ MODIWL.
|
||||||
// This file was auto-generated. DO NOT MODIFY.
|
// This file was auto-generated. DO NOT MODIFY.
|
||||||
|
|
||||||
@@ -135,7 +135,7 @@ func (d *DesktopBuilder) processDialogIcons(assetDir string, options *Options) e
|
|||||||
|
|
||||||
// Setup target
|
// Setup target
|
||||||
targetFilename := "userdialogicons"
|
targetFilename := "userdialogicons"
|
||||||
targetFile := filepath.Join(assetDir, targetFilename+".c")
|
targetFile := filepath.Join(assetDir, targetFilename+".h")
|
||||||
d.addFileToDelete(targetFile)
|
d.addFileToDelete(targetFile)
|
||||||
|
|
||||||
var dataBytes []byte
|
var dataBytes []byte
|
||||||
@@ -144,7 +144,7 @@ func (d *DesktopBuilder) processDialogIcons(assetDir string, options *Options) e
|
|||||||
var cdata strings.Builder
|
var cdata strings.Builder
|
||||||
|
|
||||||
// Write header
|
// Write header
|
||||||
header := `// userdialogicons.c
|
header := `// userdialogicons.h
|
||||||
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Ă‚ MODIWL.
|
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Ă‚ MODIWL.
|
||||||
// This file was auto-generated. DO NOT MODIFY.
|
// This file was auto-generated. DO NOT MODIFY.
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
package menu
|
package menu
|
||||||
|
|
||||||
// TrayOptions are the options
|
// Tray are the options
|
||||||
type TrayOptions struct {
|
type Tray struct {
|
||||||
|
|
||||||
|
// The ID of this tray
|
||||||
|
ID string
|
||||||
|
|
||||||
// Label is the text we wish to display in the tray
|
// Label is the text we wish to display in the tray
|
||||||
Label string
|
Label string
|
||||||
|
|
||||||
@@ -9,6 +9,6 @@ type Options struct {
|
|||||||
WebviewIsTransparent bool
|
WebviewIsTransparent bool
|
||||||
WindowBackgroundIsTranslucent bool
|
WindowBackgroundIsTranslucent bool
|
||||||
Menu *menu.Menu
|
Menu *menu.Menu
|
||||||
Tray *menu.TrayOptions
|
Tray *menu.Tray
|
||||||
ContextMenus *menu.ContextMenus
|
ContextMenus *menu.ContextMenus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ type App struct {
|
|||||||
DevTools bool
|
DevTools bool
|
||||||
RGBA int
|
RGBA int
|
||||||
ContextMenus *menu.ContextMenus
|
ContextMenus *menu.ContextMenus
|
||||||
Tray *menu.TrayOptions
|
Tray *menu.Tray
|
||||||
Menu *menu.Menu
|
Menu *menu.Menu
|
||||||
Mac *mac.Options
|
Mac *mac.Options
|
||||||
Logger logger.Logger `json:"-"`
|
Logger logger.Logger `json:"-"`
|
||||||
@@ -41,8 +41,8 @@ func MergeDefaults(appoptions *App) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetTray(appoptions *App) *menu.TrayOptions {
|
func GetTray(appoptions *App) *menu.Tray {
|
||||||
var result *menu.TrayOptions
|
var result *menu.Tray
|
||||||
switch runtime.GOOS {
|
switch runtime.GOOS {
|
||||||
case "darwin":
|
case "darwin":
|
||||||
if appoptions.Mac != nil {
|
if appoptions.Mac != nil {
|
||||||
|
|||||||
6
v2/test/kitchensink/frontend/package-lock.json
generated
6
v2/test/kitchensink/frontend/package-lock.json
generated
@@ -3125,9 +3125,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"rollup-plugin-svelte": {
|
"rollup-plugin-svelte": {
|
||||||
"version": "5.2.3",
|
"version": "6.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/rollup-plugin-svelte/-/rollup-plugin-svelte-5.2.3.tgz",
|
"resolved": "https://registry.npmjs.org/rollup-plugin-svelte/-/rollup-plugin-svelte-6.1.1.tgz",
|
||||||
"integrity": "sha512-513vOht9A93OV7fvmpIq8mD1JFgTZ5LidmpULKM2Od9P1l8oI5KwvO32fwCnASuVJS1EkRfvCnS7vKQ8DF4srg==",
|
"integrity": "sha512-ijnm0pH1ScrY4uxwaNXBpNVejVzpL2769hIEbAlnqNUWZrffLspu5/k9/l/Wsj3NrEHLQ6wCKGagVJonyfN7ow==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"require-relative": "^0.8.7",
|
"require-relative": "^0.8.7",
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
"rollup-plugin-livereload": "^1.0.0",
|
"rollup-plugin-livereload": "^1.0.0",
|
||||||
"rollup-plugin-postcss": "^3.1.8",
|
"rollup-plugin-postcss": "^3.1.8",
|
||||||
"rollup-plugin-string": "^3.0.0",
|
"rollup-plugin-string": "^3.0.0",
|
||||||
"rollup-plugin-svelte": "^5.0.3",
|
"rollup-plugin-svelte": "~6.1.1",
|
||||||
"rollup-plugin-terser": "^5.1.2",
|
"rollup-plugin-terser": "^5.1.2",
|
||||||
"sirv-cli": "^0.4.4",
|
"sirv-cli": "^0.4.4",
|
||||||
"svelte": "^3.31.0",
|
"svelte": "^3.31.0",
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ func main() {
|
|||||||
// Comment out line below to see Window.SetTitle() work
|
// Comment out line below to see Window.SetTitle() work
|
||||||
TitleBar: mac.TitleBarHiddenInset(),
|
TitleBar: mac.TitleBarHiddenInset(),
|
||||||
Menu: createApplicationMenu(),
|
Menu: createApplicationMenu(),
|
||||||
Tray: &menu.TrayOptions{
|
Tray: &menu.Tray{
|
||||||
Icon: "light",
|
Icon: "light",
|
||||||
Menu: createApplicationTray(),
|
Menu: createApplicationTray(),
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user