@@ -228,8 +228,8 @@ pub fn free(buf: []const u8) void {
228228/// Safely allocate memory using the WebUI memory management system
229229/// it can be safely freed using `free()` at any time.
230230/// In general, you should not use this function
231- pub fn malloc (size : usize ) []u8 {
232- const ptr = c .webui_malloc (size ).? ; // TODO: Proper allocation failure check
231+ pub fn malloc (size : usize ) ! []u8 {
232+ const ptr = c .webui_malloc (size ) orelse return error . AllocateFailed ;
233233 return @as ([* ]u8 , @ptrCast (ptr ))[0.. size ];
234234}
235235
@@ -536,6 +536,41 @@ pub fn interfaceGetSizeAt(self: webui, event_number: usize, index: usize) usize
536536 return c .webui_interface_get_size_at (self .window_handle , event_number , index );
537537}
538538
539+ // Show a window using embedded HTML, or a file. If the window is already
540+ pub fn interfaceShowClient (self : webui , event_number : usize , content : [:0 ]const u8 ) bool {
541+ return c .webui_interface_show_client (self .window_handle , event_number , content .ptr );
542+ }
543+
544+ // Close a specific client.
545+ pub fn interfaceCloseClient (self : webui , event_number : usize ) void {
546+ c .webui_interface_close_client (self .window_handle , event_number );
547+ }
548+
549+ // Safely send raw data to the UI. Single client.
550+ pub fn interfaceSendRawClient (
551+ self : webui ,
552+ event_number : usize ,
553+ function : [:0 ]const u8 ,
554+ raw : []const u8 ,
555+ ) void {
556+ c .webui_interface_send_raw_client (self .window_handle , event_number , function .ptr , raw .ptr , raw .len );
557+ }
558+
559+ // Navigate to a specific URL. Single client.
560+ pub fn interfaceNavigateClient (self : webui , event_number : usize , url : [:0 ]const u8 ) void {
561+ c .webui_interface_navigate_client (self .window_handle , event_number , url .ptr );
562+ }
563+
564+ // Run JavaScript without waiting for the response. Single client.
565+ pub fn interfaceRunClient (self : webui , event_number : usize , script_content : [:0 ]const u8 ) void {
566+ c .webui_interface_run_client (self .window_handle , event_number , script_content .ptr );
567+ }
568+
569+ // Run JavaScript and get the response back. Single client.
570+ pub fn interfaceScriptClient (self : webui , event_number : usize , script_content : [:0 ]const u8 , timeout : usize , buffer : []u8 ) void {
571+ c .webui_interface_script_client (self .window_handle , event_number , script_content .ptr , timeout , buffer .ptr , buffer .len );
572+ }
573+
539574/// a very convenient function for binding callback.
540575/// you just need to pase a function to get param.
541576/// no need to care webui param api.
@@ -752,10 +787,12 @@ pub const Config = enum(c_int) {
752787 /// root folder gets changed.
753788 /// Default: False
754789 folder_monitor ,
755- /// Allow multiple clients to connect to the same window,
756- /// This is helpful for web apps (non-desktop software),
757- /// Please see the documentation for more details.
758- /// Default: False
790+ /// Allow or prevent WebUI from adding `webui_auth` cookies.
791+ /// WebUI uses these cookies to identify clients and block
792+ /// unauthorized access to the window content using a URL.
793+ /// Please keep this option to `True` if you want only a single
794+ /// client to access the window content.
795+ /// Default: True
759796 multi_client ,
760797 /// Allow multiple clients to connect to the same window,
761798 /// This is helpful for web apps (non-desktop software),
0 commit comments