5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-02 17:39:58 +08:00

[v2] Rename noautoinjectbindings -> noautoinjectipc

This commit is contained in:
Lea Anthony 2021-10-04 16:53:27 +11:00
parent a59d01ddb9
commit b15d98b555
5 changed files with 16 additions and 16 deletions

View File

@ -63,7 +63,7 @@ func (a *BrowserAssetServer) processIndexHTML() ([]byte, error) {
return nil, err return nil, err
} }
} }
if wailsOptions.disableBindingsInjection == false { if wailsOptions.disableIPCInjection == false {
indexHTML, err = injectHTML(string(indexHTML), `<script src="/wails/ipc.js"></script>`) indexHTML, err = injectHTML(string(indexHTML), `<script src="/wails/ipc.js"></script>`)
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -125,7 +125,7 @@ func (a *DesktopAssetServer) processIndexHTML() ([]byte, error) {
return nil, err return nil, err
} }
} }
if wailsOptions.disableBindingsInjection == false { if wailsOptions.disableIPCInjection == false {
indexHTML, err = injectHTML(string(indexHTML), `<script src="/wails/ipc.js"></script>`) indexHTML, err = injectHTML(string(indexHTML), `<script src="/wails/ipc.js"></script>`)
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -10,14 +10,14 @@ import (
type optionType string type optionType string
const ( const (
noAutoInject optionType = "noautoinject" noAutoInject optionType = "noautoinject"
noAutoInjectRuntime optionType = "noautoinjectruntime" noAutoInjectRuntime optionType = "noautoinjectruntime"
noAutoInjectBindings optionType = "noautoinjectbindings" noautoinjectipc optionType = "noautoinjectipc"
) )
type Options struct { type Options struct {
disableRuntimeInjection bool disableRuntimeInjection bool
disableBindingsInjection bool disableIPCInjection bool
} }
func newOptions(optionString string) *Options { func newOptions(optionString string) *Options {
@ -28,9 +28,9 @@ func newOptions(optionString string) *Options {
switch optionType(strings.TrimSpace(option)) { switch optionType(strings.TrimSpace(option)) {
case noAutoInject: case noAutoInject:
result.disableRuntimeInjection = true result.disableRuntimeInjection = true
result.disableBindingsInjection = true result.disableIPCInjection = true
case noAutoInjectBindings: case noautoinjectipc:
result.disableBindingsInjection = true result.disableIPCInjection = true
case noAutoInjectRuntime: case noAutoInjectRuntime:
result.disableRuntimeInjection = true result.disableRuntimeInjection = true
} }

View File

@ -33,8 +33,8 @@ func genMeta(content string) []byte {
func genOptions(runtime bool, bindings bool) *Options { func genOptions(runtime bool, bindings bool) *Options {
return &Options{ return &Options{
disableRuntimeInjection: runtime, disableRuntimeInjection: runtime,
disableBindingsInjection: bindings, disableIPCInjection: bindings,
} }
} }
@ -50,11 +50,11 @@ func Test_extractOptions(t *testing.T) {
{"bad options", genMeta("noauto"), genOptions(false, false), false}, {"bad options", genMeta("noauto"), genOptions(false, false), false},
{"realhtml", []byte(realHTML), genOptions(true, true), false}, {"realhtml", []byte(realHTML), genOptions(true, true), false},
{"noautoinject", genMeta("noautoinject"), genOptions(true, true), false}, {"noautoinject", genMeta("noautoinject"), genOptions(true, true), false},
{"noautoinjectbindings", genMeta("noautoinjectbindings"), genOptions(false, true), false}, {"noautoinjectipc", genMeta("noautoinjectipc"), genOptions(false, true), false},
{"noautoinjectruntime", genMeta("noautoinjectruntime"), genOptions(true, false), false}, {"noautoinjectruntime", genMeta("noautoinjectruntime"), genOptions(true, false), false},
{"spaces", genMeta(" noautoinjectruntime "), genOptions(true, false), false}, {"spaces", genMeta(" noautoinjectruntime "), genOptions(true, false), false},
{"multiple", genMeta("noautoinjectruntime,noautoinjectbindings"), genOptions(true, true), false}, {"multiple", genMeta("noautoinjectruntime,noautoinjectipc"), genOptions(true, true), false},
{"multiple spaces", genMeta(" noautoinjectruntime, noautoinjectbindings "), genOptions(true, true), false}, {"multiple spaces", genMeta(" noautoinjectruntime, noautoinjectipc "), genOptions(true, true), false},
} }
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {

View File

@ -44,7 +44,7 @@ The options are as follows:
| Value | Description | | Value | Description |
| -------------------- | ------------------------------------------------- | | -------------------- | ------------------------------------------------- |
| noautoinjectruntime | Disable the autoinjection of `/wails/runtime.js` | | noautoinjectruntime | Disable the autoinjection of `/wails/runtime.js` |
| noautoinjectbindings | Disable the autoinjection of `/wails/bindings.js` | | noautoinjectipc | Disable the autoinjection of `/wails/ipc.js` |
| noautoinject | Disable all autoinjection of scripts | | noautoinject | Disable all autoinjection of scripts |
Multiple options may be used provided they are comma seperated. Multiple options may be used provided they are comma seperated.