Skip to content

Commit

Permalink
Test directives
Browse files Browse the repository at this point in the history
  • Loading branch information
fbbdev committed Feb 5, 2025
1 parent 7a44364 commit b5f7396
Show file tree
Hide file tree
Showing 19 changed files with 113 additions and 1 deletion.
3 changes: 3 additions & 0 deletions v3/internal/generator/testcases/directives/bound_types.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[
".Service"
]
11 changes: 11 additions & 0 deletions v3/internal/generator/testcases/directives/includes.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//wails:include js/test.js
//wails:include **:js/test_all.js
//wails:include *c:js/test_c.js
//wails:include *i:js/test_i.js
//wails:include j*:js/test_j.js
//wails:include jc:js/test_jc.js
//wails:include ji:js/test_ji.js
//wails:include t*:js/test_t.ts
//wails:include tc:js/test_tc.ts
//wails:include ti:js/test_ti.ts
package main
3 changes: 3 additions & 0 deletions v3/internal/generator/testcases/directives/js/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { CustomMethod } from "./service.js";

CustomMethod("everywhere");
3 changes: 3 additions & 0 deletions v3/internal/generator/testcases/directives/js/test_all.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { CustomMethod } from "./service.js";

CustomMethod("everywhere again");
3 changes: 3 additions & 0 deletions v3/internal/generator/testcases/directives/js/test_c.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { CustomMethod } from "./service.js";

CustomMethod("Classes");
3 changes: 3 additions & 0 deletions v3/internal/generator/testcases/directives/js/test_i.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { CustomMethod } from "./service.js";

CustomMethod("Interfaces");
3 changes: 3 additions & 0 deletions v3/internal/generator/testcases/directives/js/test_j.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { CustomMethod } from "./service.js";

CustomMethod("JS");
3 changes: 3 additions & 0 deletions v3/internal/generator/testcases/directives/js/test_jc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { CustomMethod } from "./service.js";

CustomMethod("JS Classes");
3 changes: 3 additions & 0 deletions v3/internal/generator/testcases/directives/js/test_ji.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { CustomMethod } from "./service.js";

CustomMethod("JS Interfaces");
3 changes: 3 additions & 0 deletions v3/internal/generator/testcases/directives/js/test_t.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { CustomMethod } from "./service.js";

CustomMethod("TS");
3 changes: 3 additions & 0 deletions v3/internal/generator/testcases/directives/js/test_tc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { CustomMethod } from "./service.js";

CustomMethod("TS Classes");
3 changes: 3 additions & 0 deletions v3/internal/generator/testcases/directives/js/test_ti.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { CustomMethod } from "./service.js";

CustomMethod("TS Interfaces");
51 changes: 51 additions & 0 deletions v3/internal/generator/testcases/directives/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
//wails:inject console.log("Hello everywhere!");
//wails:inject **:console.log("Hello everywhere again!");
//wails:inject *c:console.log("Hello Classes!");
//wails:inject *i:console.log("Hello Interfaces!");
//wails:inject j*:console.log("Hello JS!");
//wails:inject jc:console.log("Hello JS Classes!");
//wails:inject ji:console.log("Hello JS Interfaces!");
//wails:inject t*:console.log("Hello TS!");
//wails:inject tc:console.log("Hello TS Classes!");
//wails:inject ti:console.log("Hello TS Interfaces!");
package main

import (
_ "embed"
"log"

"github.com/wailsapp/wails/v3/internal/generator/testcases/directives/otherpackage"
"github.com/wailsapp/wails/v3/pkg/application"
)

//wails:inject j*:/**
//wails:inject j*: * @param {string} arg
//wails:inject j*: * @returns {Promise<void>}
//wails:inject j*: */
//wails:inject j*:export async function CustomMethod(arg) {
//wails:inject t*:export async function CustomMethod(arg: string): Promise<void> {
//wails:inject await InternalMethod("Hello " + arg + "!");
//wails:inject }
type Service struct{}

func (*Service) VisibleMethod(otherpackage.Dummy) {}

//wails:internal
func (*Service) InternalMethod(string) {}

func main() {
app := application.New(application.Options{
Services: []application.Service{
application.NewService(&Service{}),
},
})

app.NewWebviewWindow()

err := app.Run()

if err != nil {
log.Fatal(err)
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//wails:include jc:js/*_j*.js
//wails:include tc:js/*_t*.ts
package otherpackage

type Dummy struct{}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { CustomMethod } from "../service.js";

CustomMethod("JS");
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { CustomMethod } from "../service.js";

CustomMethod("JS Classes");
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { CustomMethod } from "../service.js";

CustomMethod("TS");
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { CustomMethod } from "../service.js";

CustomMethod("TS Classes");
2 changes: 1 addition & 1 deletion v3/internal/generator/testdata/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"skipLibCheck": true,

"target": "ES6",
"lib": ["ES6"],
"lib": ["ES6", "DOM"],

"module": "ES6",
"moduleResolution": "Node",
Expand Down

0 comments on commit b5f7396

Please sign in to comment.