README
GUI::HTMLWindow
This is a highly experimental module. Not so experimental in whether it works (it does), but rather in how developers will interact with it.
Quickstart
window MyWindow {
# foo exists in the website
method foo is js-outbound { * }
# bar is callable from the website
method bar($str) is js-inbound {
say $str;
}
}
with $window = MyWindow.new {
.add-file: "index.html";
.add-file: "style/main.css";
.homepage = 'index.html";
}
$window.open: :640width, :480height;
$window.foo; # calls foo() in JavaScript in the windowGuide
The UI::HTMLWindow package enables a new declarator, window, which represents a window that is filled with a web view.
It is a subclass of the Window class, which will handle all of the magic for you, however, you can add your own methods and has-scoped variables.
In addition to the window, there are two traits that you can use for your methods:
is js-outbounduse this to signal (akin toNativeCall) that this function exists in the JavaScript window context. Variables will be repackaged using.to-json, you should add this functionality to classes if you wish for it to be used. Otherwise, if an object isPositionalorAssociative, it will be handled as a JSON array/objects. Otherwise, the object will have.Strcalled and handled as a JSON string.is js-inboundused to signal that this method can be called from JavaScript. To callmethod foo($int), useRaku.foo(42). You cannot currently return results.
If you have a lot of files to add that are fairly consistent, you may wish to do them during a TWEAK phase.
Files are specified from the resources folder. At present, files are added to a temporary folder maintaining
whatever structure may exist in the resources folder. Adding non-resource files will be supported in a future version.
Beta notes
Not currently available on *nix or Windows
Be careful the rate you send messages from Raku to JS. If you send too many too fast, it is possible to crash WebKit. This will be fixed in the future with appropriate locks.
The exact way users will interact with this package may change to become more ergonomic. Trust nothing yet.
Version History
v0.0.1 - v0.0.3
Early beta, available only for macOS