Compare commits

...

61 Commits

Author SHA1 Message Date
Lea Anthony 0c2b3fb1cb Update generate-contributors.yml 2023-04-14 19:57:07 +10:00
stffabi 39a7ab5856 [assetserver, linux] Add support for WebKit2GTK 2.40+ features (#2592) 2023-04-14 11:16:27 +02:00
stffabi ec3da8b7ef [v2, darwin] Fix updating the menu on runtime (#2588) 2023-04-14 00:14:19 +10:00
stffabi b64b2a8da1 [v2, dev] Fix skipbindings flag in wails dev (#2584) 2023-04-13 07:45:49 +10:00
Misite Bao 1979bca0f5 chore: fix pnpm environment settings (#2580) 2023-04-12 22:21:25 +10:00
Misite Bao 0f791c71f4 fix: fix website build and add taskfile (#2577)
* chore: update dependencies

* docs: update source documents

* chore: use Taskfile instead of scripts
2023-04-12 21:36:01 +10:00
Travis McLane fbe7d4de6b Bugfix/remove miniaturize (#2579)
* remove duplicate 'minimize' from interface

already covered by 'minimise'

* [darwin] remove windowMiniaturize

duplicates the logic in windowMinimise

---------

Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
2023-04-12 21:34:31 +10:00
stffabi c8d203d4d6 [v3, darwin] Fix leaking WebKit processes on Window close (#2574)
* [v3, darwin] Fix leaking WebKit processes on Window close

* [v3] Remove window from window map if closed
[v3] Implement `HideOnClose` and ensure it isn't removed when closed

---------

Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
2023-04-12 21:33:00 +10:00
Lea Anthony f335cbd608 Update generate-contributors.yml 2023-04-12 08:44:17 +10:00
Lea Anthony b67d1e72a7 Update generate-contributors.yml 2023-04-12 08:41:28 +10:00
Misite Bao 5e3c736bee feat(cli): add Nodejs version in wails doctor (#2546)
* feat(cli): add Nodejs version in `wails doctor`

* Added check for output length

* docs: update changelog.mdx

---------

Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
2023-04-12 07:11:37 +10:00
Lea Anthony abc8f71a8d Update generate-contributors.yml 2023-04-11 21:29:41 +10:00
Lea Anthony cf8bb49093 Update generate-contributors.yml 2023-04-11 21:25:36 +10:00
Lea Anthony 3f62fa0d86 Update credits.mdx 2023-04-11 20:46:45 +10:00
Lea Anthony 8b977bcab4 Update generate-contributors.yml 2023-04-11 20:46:28 +10:00
Lea Anthony 3a1aeaab94 Update generate-contributors.yml 2023-04-11 20:22:27 +10:00
Travis McLane a7bf359930 update wml events to be parseable (#2561)
* update wml events to be parseable

* [v3] Rename `CustomEvent` to `WailsEvent` to prevent clashing with the standard JS `CustomEvent` object

---------

Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
2023-04-11 18:28:06 +10:00
github-actions[bot] 9574bfc054 chore: update sponsors.svg (#2566)
Co-authored-by: leaanthony <leaanthony@users.noreply.github.com>
2023-04-11 18:26:28 +10:00
希嘉嘉 739ca98597 Update templates.mdx (#2571) 2023-04-10 22:00:04 +10:00
Lea Anthony 424e4fc2e8 [v3] Add ability to get window by name 2023-04-07 19:47:01 +10:00
Misite Bao 7f1093dc51 chore: update auto workflows (#2555)
* chore: update workflows

* chore: update Taskfile

* chore: add lable to auto-sync pr
2023-04-07 18:19:14 +10:00
Lea Anthony a998465034 [v3] Update start_at_login plugin to allow better compilation on Linux 2023-04-06 08:29:20 +10:00
Lea Anthony 755e869fe7 [v3] Add start_at_login plugin
[v3] Fix plugin startup/shutdown order
2023-04-05 21:22:02 +10:00
Lea Anthony 7ecbc846b4 [v3] Improved plugin shutdown 2023-04-04 18:01:49 +10:00
Lea Anthony 767b7d6026 Check out repo for contributors workflow 2023-04-03 08:43:57 +10:00
Lea Anthony 086953bbe9 Do not directly commit contributors sag 2023-04-03 08:39:42 +10:00
Lea Anthony c51df752a1 Create PR for contributors SVG 2023-04-03 08:37:46 +10:00
Lea Anthony ea3b7ed9dd Generate Contributors SVG 2023-04-03 08:33:55 +10:00
dependabot[bot] ef6366af61 Bump webpack from 5.75.0 to 5.76.2 in /website (#2503)
Bumps [webpack](https://github.com/webpack/webpack) from 5.75.0 to 5.76.2.
- [Release notes](https://github.com/webpack/webpack/releases)
- [Commits](https://github.com/webpack/webpack/compare/v5.75.0...v5.76.2)

---
updated-dependencies:
- dependency-name: webpack
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-04-01 22:02:24 +11:00
dependabot[bot] 488666f407 Bump undici from 5.13.0 to 5.21.0 in /scripts/sponsors (#2502)
Bumps [undici](https://github.com/nodejs/undici) from 5.13.0 to 5.21.0.
- [Release notes](https://github.com/nodejs/undici/releases)
- [Commits](https://github.com/nodejs/undici/compare/v5.13.0...v5.21.0)

---
updated-dependencies:
- dependency-name: undici
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-04-01 22:00:55 +11:00
Simon Shutter 34fd76617e annotated menu example and updated runtime.Quit call (#2539) 2023-04-01 21:50:29 +11:00
憧憬Licoy 1e8b938d15 fix obfuscate build param name (#2542)
Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
2023-04-01 21:48:03 +11:00
Lea Anthony 3404250ac8 [v3] Add single_instance plugin 2023-04-01 20:36:55 +11:00
Misite Bao eddc949295 fix: fix console printing (#2483) 2023-04-01 18:22:27 +11:00
Misite Bao 49bd33e642 docs: update routing.mdx (#2547) 2023-04-01 16:05:09 +11:00
github-actions[bot] 78f638a9bc docs: sync documents (#2514)
Co-authored-by: misitebao <misitebao@users.noreply.github.com>
2023-04-01 16:04:43 +11:00
github-actions[bot] fef6e2a616 chore: update sponsors.svg (#2535)
Co-authored-by: leaanthony <leaanthony@users.noreply.github.com>
2023-04-01 16:03:09 +11:00
Noah Gorstein 2a22933220 docs: fix broken link for react router HashRouter (#2544) 2023-04-01 08:43:15 +11:00
Lea Anthony eae4fe62cd Merge branch 'v3/api-package' 2023-03-31 20:39:41 +11:00
stffabi b3a9332a5b [assetserver] Add linux platform implementation (#2543) 2023-03-31 20:39:13 +11:00
Lea Anthony e91b7832ee Provide types to runtime api 2023-03-31 20:37:50 +11:00
stffabi db527c0fc2 [assetserver] Add linux platform implementation (#2543) 2023-03-31 10:08:31 +02:00
Lea Anthony 0d25edc0c4 Improved api package 2023-03-30 12:51:43 +11:00
Lea Anthony eb36258c73 Merge branch 'master' into v3/plugins 2023-03-27 20:58:00 +11:00
Misite Bao bdb138d42c chore: fix push.yml (#2530) 2023-03-27 07:37:38 +11:00
Arpit Jain abe6f520b4 Fix dates in changelog (#2527) 2023-03-26 16:19:12 +11:00
Lea Anthony 365aaf6bb1 Add sqlite plugin 2023-03-25 09:39:59 +11:00
Lea Anthony 5949e305ea Reorder startup sequence
Add plugin scripts to asset server
Add InjectJS support in plugins
2023-03-24 08:43:00 +11:00
Lea Anthony bf86b0d9c1 Add Window creation hooks
Add InjectJS() to plugins interface
2023-03-23 06:51:24 +11:00
Lea Anthony d5808fde59 Simple logging plugin 2023-03-22 20:56:45 +11:00
Lea Anthony 3ae604e474 Exported() -> CallableByJS() 2023-03-22 20:42:20 +11:00
Lea Anthony 42fb91bc73 Fix for variadic args in bound methods 2023-03-22 20:36:46 +11:00
Lea Anthony 4165caa02e Add Exported() []string to plugin API 2023-03-21 08:55:55 +11:00
Lea Anthony b656bd2194 Prevent beeps when pressing a key in Mac window 2023-03-20 20:48:22 +11:00
Lea Anthony ba82f27534 Fix Bug with nil parameters.
Added browser and kvstore plugins.
2023-03-20 20:28:33 +11:00
Lea Anthony 13f620ae54 Add plugin init. Update plugin signature. 2023-03-19 09:13:05 +11:00
Lea Anthony c774af48b7 Extend call subsystem to support plugins 2023-03-18 09:12:44 +11:00
Lea Anthony 4300521064 Initial implementation 2023-03-18 08:11:36 +11:00
Lea Anthony 86aaa3a956 Merge branch 'v3/central-assetserver' into v3/plugins 2023-03-17 17:03:21 +11:00
stffabi 74f349862e [v3] AssetServer options update comments 2023-03-16 06:49:46 +01:00
stffabi 0e614b0194 [v3] Centralize the AssetServer and move it to the application 2023-03-16 06:49:45 +01:00
197 changed files with 8375 additions and 16617 deletions
@@ -0,0 +1,40 @@
name: update-contributors-svg
on:
workflow_dispatch: # Can trigger manually
schedule:
- cron: '0 7 * * *' # Schedule on everyday 7:00
jobs:
update-svg:
name: Update contributors SVG
runs-on: ubuntu-latest # You can also try macos-latest
steps:
- uses: actions/checkout@v3
- name: Set node
uses: actions/setup-node@v3
with:
node-version: lts/*
- name: Install pnpm
uses: pnpm/action-setup@v2.2.2
with:
version: 7
- name: Install deps
run: pnpm install
- name: Run SVG generation script
run: pnpx make-github-contributor-svg -t ${{ secrets.GITHUB_TOKEN }} -o vuejs-translations -r docs-zh-cn
- name: Move SVG
run: mv .github-contributors/* website/static/img/
- name: Commit
uses: EndBug/add-and-commit@v4
with:
message: "chore(workflow): update contributors image"
add: "website/static/img/*"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+6 -4
View File
@@ -1,9 +1,9 @@
name: Label sponsors
name: Label Sponsors
on:
pull_request:
types: [ opened ]
types: [opened]
issues:
types: [ opened ]
types: [opened]
jobs:
build:
name: is-sponsor-label
@@ -11,5 +11,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: JasonEtco/is-sponsor-label-action@v1
with:
label: Sponsor ❤️
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -1,4 +1,4 @@
name: Sync Translated Documents
name: Sync Translations
on:
workflow_dispatch:
@@ -10,22 +10,30 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Set node
- name: Setup Nodejs
uses: actions/setup-node@v2
with:
node-version: 16.x
node-version: 18.x
- name: Install Task
uses: arduino/setup-task@v1
with:
version: 3.x
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Sync Translated Documents
run: cd scripts && chmod 755 ./sync-translated-documents.sh && ./sync-translated-documents.sh
env:
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
working-directory: ./website
run: task crowdin:pull
- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
with:
commit-message: "docs: sync documents"
title: "docs: sync documents"
commit-message: "docs: sync translations"
title: "docs: sync translations"
body: "- [x] Sync translated documents"
branch: feature/documents
branch: chore/sync-translations
labels: translation
delete-branch: true
draft: true
@@ -1,8 +1,9 @@
name: Push Checks
name: Upload Source Documents
on:
push:
branches: [master]
workflow_dispatch:
jobs:
push_files_to_crowdin:
@@ -13,25 +14,28 @@ jobs:
- uses: actions/checkout@v2
- name: Verify Changed files
uses: tj-actions/verify-changed-files@v11.1
id: verify-changed-files
id: changed-files
uses: tj-actions/changed-files@v35
with:
files: |
website/**/*.mdx
website/**/*.md
website/**/*.json
- name: Set node
if: steps.verify-changed-files.outputs.files_changed != 'true'
- name: Setup Nodejs
uses: actions/setup-node@v2
with:
node-version: 16.x
node-version: 18.x
- name: Push files
- name: Setup Task
uses: arduino/setup-task@v1
with:
version: 3.x
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload source documents
if: steps.changed-files.outputs.any_changed == 'true'
env:
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
run: |
cd website
corepack enable
pnpm install
pnpm run crowdin push -b master
working-directory: ./website
run: task crowdin:push
+1
View File
@@ -35,3 +35,4 @@ v2/cmd/wails/internal/commands/initialise/templates/testtemplates/
/v3/.task
/v3/examples/build/bin/testapp
/websitev3/site/
/v3/examples/plugins/bin/testapp
+5 -5
View File
@@ -1,24 +1,24 @@
# https://taskfile.dev
version: '3'
version: "3"
vars:
GREETING: Hello, World!
tasks:
check-contributors:
contributors:check:
cmds:
- npx -y all-contributors-cli check
update-contributors:
contributors:update:
cmds:
- go run v3/tasks/contribs/main.go
build-contributors:
contributors:build:
cmds:
- npx -y all-contributors-cli generate
release:
dir: v2/tools/release
cmds:
- go run release.go
- go run release.go
+3 -3
View File
@@ -1775,9 +1775,9 @@
}
},
"node_modules/undici": {
"version": "5.13.0",
"resolved": "https://registry.npmmirror.com/undici/-/undici-5.13.0.tgz",
"integrity": "sha512-UDZKtwb2k7KRsK4SdXWG7ErXiL7yTGgLWvk2AXO1JMjgjh404nFo6tWSCM2xMpJwMPx3J8i/vfqEh1zOqvj82Q==",
"version": "5.21.0",
"resolved": "https://registry.npmjs.org/undici/-/undici-5.21.0.tgz",
"integrity": "sha512-HOjK8l6a57b2ZGXOcUsI5NLfoTrfmbOl90ixJDl0AEFG4wgHNDQxtZy15/ZQp7HhjkpaGlp/eneMgtsu1dIlUA==",
"dependencies": {
"busboy": "^1.6.0"
},
-5
View File
@@ -1,5 +0,0 @@
#!/usr/bin/env bash
cd ../website
npx @crowdin/cli@latest pull -b master --export-only-approved
+5 -3
View File
@@ -2,14 +2,15 @@ package flags
import (
"fmt"
"github.com/samber/lo"
"github.com/wailsapp/wails/v2/internal/project"
"github.com/wailsapp/wails/v2/pkg/commands/build"
"net"
"net/url"
"os"
"path/filepath"
"runtime"
"github.com/samber/lo"
"github.com/wailsapp/wails/v2/internal/project"
"github.com/wailsapp/wails/v2/pkg/commands/build"
)
type Dev struct {
@@ -126,6 +127,7 @@ func (d *Dev) GenerateBuildOptions() *build.Options {
Compiler: d.Compiler,
ForceBuild: d.ForceBuild,
IgnoreFrontend: d.SkipFrontend,
SkipBindings: d.SkipBindings,
Verbosity: d.Verbosity,
WailsJSDir: d.WailsJSDir,
RaceDetector: d.RaceDetector,
-25
View File
@@ -44,31 +44,6 @@ func sliceToMap(input []string) map[string]struct{} {
return result
}
type devFlags struct {
ldflags string
compilerCommand string
assetDir string
extensions string
reloadDirs string
openBrowser bool
noReload bool
skipBindings bool
wailsjsdir string
tags string
verbosity int
loglevel string
forceBuild bool
debounceMS int
devServer string
appargs string
saveConfig bool
raceDetector bool
frontendDevServerURL string
skipFrontend bool
noColour bool
}
// Application runs the application in dev mode
func Application(f *flags.Dev, logger *clilogger.CLILogger) error {
+1 -1
View File
@@ -41,7 +41,7 @@ func printBulletPoint(text string, args ...any) {
fatal(err.Error())
}
t = strings.Trim(t, "\n\r")
pterm.Printf(t, args...)
pterm.Printfln(t, args...)
}
func printFooter() {
@@ -130,6 +130,5 @@ func (f *Frontend) MenuSetApplicationMenu(menu *menu.Menu) {
}
func (f *Frontend) MenuUpdateApplicationMenu() {
f.MenuSetApplicationMenu(f.frontendOptions.Menu)
f.mainWindow.UpdateApplicationMenu()
}
+6 -43
View File
@@ -78,7 +78,6 @@ import (
"encoding/json"
"fmt"
"log"
"net/http"
"net/url"
"os"
"runtime"
@@ -88,6 +87,7 @@ import (
"unsafe"
"github.com/wailsapp/wails/v2/pkg/assetserver"
"github.com/wailsapp/wails/v2/pkg/assetserver/webview"
"github.com/wailsapp/wails/v2/internal/binding"
"github.com/wailsapp/wails/v2/internal/frontend"
@@ -166,10 +166,7 @@ func NewFrontend(ctx context.Context, appoptions *options.App, myLogger *logger.
}
result.assets = assets
// Start 10 processors to handle requests in parallel
for i := 0; i < 10; i++ {
go result.startRequestProcessor()
}
go result.startRequestProcessor()
}
go result.startMessageProcessor()
@@ -461,50 +458,16 @@ func processMessage(message *C.char) {
messageBuffer <- goMessage
}
var requestBuffer = make(chan unsafe.Pointer, 100)
var requestBuffer = make(chan webview.Request, 100)
func (f *Frontend) startRequestProcessor() {
for request := range requestBuffer {
f.processRequest(request)
C.g_object_unref(C.gpointer(request))
f.assets.ServeWebViewRequest(request)
request.Release()
}
}
//export processURLRequest
func processURLRequest(request unsafe.Pointer) {
// Increment reference counter to allow async processing, will be decremented after the processing
// has been finished by a worker.
C.g_object_ref(C.gpointer(request))
requestBuffer <- request
}
func (f *Frontend) processRequest(request unsafe.Pointer) {
req := (*C.WebKitURISchemeRequest)(request)
uri := C.webkit_uri_scheme_request_get_uri(req)
goURI := C.GoString(uri)
rw := &webKitResponseWriter{req: req}
defer rw.Close()
f.assets.ProcessHTTPRequestLegacy(
rw,
func() (*http.Request, error) {
method := webkit_uri_scheme_request_get_http_method(req)
r, err := http.NewRequest(method, goURI, nil)
if err != nil {
return nil, err
}
r.Header = webkit_uri_scheme_request_get_http_headers(req)
if r.URL.Host != f.startURL.Host {
if r.Body != nil {
r.Body.Close()
}
return nil, fmt.Errorf("Expected host '%s' in request, but was '%s'", f.startURL.Host, r.URL.Host)
}
return r, nil
})
requestBuffer <- webview.NewRequest(request)
}
@@ -12,10 +12,12 @@ import (
"github.com/wailsapp/wails/v2/pkg/options"
"github.com/wailsapp/wails/v2/pkg/options/linux"
"github.com/wailsapp/wails/v2/pkg/assetserver/webview"
)
func validateWebKit2Version(options *options.App) {
if C.webkit_get_major_version() == 2 && C.webkit_get_minor_version() >= webkit2MinMinorVersion {
if C.webkit_get_major_version() == 2 && C.webkit_get_minor_version() >= webview.Webkit2MinMinorVersion {
return
}
@@ -24,6 +26,6 @@ func validateWebKit2Version(options *options.App) {
msg = options.Linux.Messages
}
v := fmt.Sprintf("2.%d.0", webkit2MinMinorVersion)
v := fmt.Sprintf("2.%d.0", webview.Webkit2MinMinorVersion)
showModalDialogAndExit("WebKit2GTK", fmt.Sprintf(msg.WebKit2GTKMinRequired, v))
}
+27 -2
View File
@@ -1,11 +1,12 @@
package system
import (
"os/exec"
"strings"
"github.com/wailsapp/wails/v2/internal/shell"
"github.com/wailsapp/wails/v2/internal/system/operatingsystem"
"github.com/wailsapp/wails/v2/internal/system/packagemanager"
"os/exec"
"strings"
)
var (
@@ -32,6 +33,30 @@ func GetInfo() (*Info, error) {
return &result, nil
}
func checkNodejs() *packagemanager.Dependency {
// Check for Nodejs
output, err := exec.Command("node", "-v").Output()
installed := true
version := ""
if err != nil {
installed = false
} else {
if len(output) > 0 {
version = strings.TrimSpace(strings.Split(string(output), "\n")[0])[1:]
}
}
return &packagemanager.Dependency{
Name: "Nodejs",
PackageName: "N/A",
Installed: installed,
InstallCommand: "Available at https://nodejs.org/en/download/",
Version: version,
Optional: false,
External: false,
}
}
func checkNPM() *packagemanager.Dependency {
// Check for npm
+2 -2
View File
@@ -9,9 +9,8 @@ import (
"strings"
"syscall"
"github.com/wailsapp/wails/v2/internal/system/packagemanager"
"github.com/wailsapp/wails/v2/internal/system/operatingsystem"
"github.com/wailsapp/wails/v2/internal/system/packagemanager"
)
// Determine if the app is running on Apple Silicon
@@ -34,6 +33,7 @@ func (i *Info) discover() error {
i.OS = osinfo
i.Dependencies = append(i.Dependencies, checkXCodeSelect())
i.Dependencies = append(i.Dependencies, checkNodejs())
i.Dependencies = append(i.Dependencies, checkNPM())
i.Dependencies = append(i.Dependencies, checkXCodeBuild())
i.Dependencies = append(i.Dependencies, checkUPX())
+1
View File
@@ -49,6 +49,7 @@ func checkLocallyInstalled(checker func() *packagemanager.Dependency, dependency
}
var checkerFunctions = map[string]func() *packagemanager.Dependency{
"Nodejs": checkNodejs,
"npm": checkNPM,
"docker": checkDocker,
"upx": checkUPX,
+1
View File
@@ -19,6 +19,7 @@ func (i *Info) discover() error {
i.OS = osinfo
i.Dependencies = append(i.Dependencies, checkWebView2())
i.Dependencies = append(i.Dependencies, checkNodejs())
i.Dependencies = append(i.Dependencies, checkNPM())
i.Dependencies = append(i.Dependencies, checkUPX())
i.Dependencies = append(i.Dependencies, checkNSIS())
+28
View File
@@ -2,8 +2,11 @@ package assetserver
import (
"bytes"
"fmt"
"math/rand"
"net/http"
"net/http/httptest"
"strings"
"golang.org/x/net/html"
@@ -42,6 +45,9 @@ type AssetServer struct {
// Use http based runtime
runtimeHandler RuntimeHandler
// plugin scripts
pluginScripts map[string]string
assetServerWebView
}
@@ -89,6 +95,16 @@ func (d *AssetServer) UseRuntimeHandler(handler RuntimeHandler) {
d.runtimeHandler = handler
}
func (d *AssetServer) AddPluginScript(pluginName string, script string) {
if d.pluginScripts == nil {
d.pluginScripts = make(map[string]string)
}
pluginName = strings.ReplaceAll(pluginName, "/", "_")
pluginName = html.EscapeString(pluginName)
pluginScriptName := fmt.Sprintf("/plugin_%s_%d.js", pluginName, rand.Intn(100000))
d.pluginScripts[pluginScriptName] = script
}
func (d *AssetServer) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
if isWebSocket(req) {
// Forward WebSockets to the distinct websocket handler if it exists
@@ -149,6 +165,11 @@ func (d *AssetServer) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
d.writeBlob(rw, path, content)
default:
// Check if this is a plugin script
if script, ok := d.pluginScripts[path]; ok {
d.writeBlob(rw, path, []byte(script))
return
}
d.handler.ServeHTTP(rw, req)
}
}
@@ -174,6 +195,13 @@ func (d *AssetServer) processIndexHTML(indexHTML []byte) ([]byte, error) {
return nil, err
}
// Inject plugins
for scriptName := range d.pluginScripts {
if err := insertScriptInHead(htmlNode, scriptName); err != nil {
return nil, err
}
}
var buffer bytes.Buffer
err = html.Render(&buffer, htmlNode)
if err != nil {
@@ -0,0 +1,84 @@
//go:build linux
// +build linux
package webview
/*
#cgo linux pkg-config: gtk+-3.0 webkit2gtk-4.0 gio-unix-2.0
#include "gtk/gtk.h"
#include "webkit2/webkit2.h"
*/
import "C"
import (
"io"
"net/http"
"unsafe"
)
// NewRequest creates as new WebViewRequest based on a pointer to an `WebKitURISchemeRequest`
//
// Please make sure to call Release() when finished using the request.
func NewRequest(webKitURISchemeRequest unsafe.Pointer) Request {
webkitReq := (*C.WebKitURISchemeRequest)(webKitURISchemeRequest)
req := &request{req: webkitReq}
req.AddRef()
return req
}
var _ Request = &request{}
type request struct {
req *C.WebKitURISchemeRequest
header http.Header
body io.ReadCloser
rw *responseWriter
}
func (r *request) AddRef() error {
C.g_object_ref(C.gpointer(r.req))
return nil
}
func (r *request) Release() error {
C.g_object_unref(C.gpointer(r.req))
return nil
}
func (r *request) URL() (string, error) {
return C.GoString(C.webkit_uri_scheme_request_get_uri(r.req)), nil
}
func (r *request) Method() (string, error) {
return webkit_uri_scheme_request_get_http_method(r.req), nil
}
func (r *request) Header() (http.Header, error) {
if r.header != nil {
return r.header, nil
}
r.header = webkit_uri_scheme_request_get_http_headers(r.req)
return r.header, nil
}
func (r *request) Body() (io.ReadCloser, error) {
if r.body != nil {
return r.body, nil
}
r.body = webkit_uri_scheme_request_get_http_body(r.req)
return r.body, nil
}
func (r *request) Response() ResponseWriter {
if r.rw != nil {
return r.rw
}
r.rw = &responseWriter{req: r.req}
return r.rw
}

Some files were not shown because too many files have changed in this diff Show More