diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..13566b8
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..68da31b
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/webview_go.iml b/.idea/webview_go.iml
new file mode 100644
index 0000000..5e764c4
--- /dev/null
+++ b/.idea/webview_go.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/basic/main.go b/examples/basic/main.go
index 6b96c81..c3fb852 100644
--- a/examples/basic/main.go
+++ b/examples/basic/main.go
@@ -7,6 +7,8 @@ func main() {
defer w.Destroy()
w.SetTitle("Basic Example")
w.SetSize(480, 320, webview.HintNone)
- w.SetHtml("Thanks for using webview!")
+ w.SetUserAgent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36")
+ w.Navigate("https://www.whatismybrowser.com/detect/what-is-my-user-agent/")
+ // w.SetHtml("Thanks for using webview!")
w.Run()
}
diff --git a/examples/bind/main.go b/examples/bind/main.go
index 3374f84..0b17980 100644
--- a/examples/bind/main.go
+++ b/examples/bind/main.go
@@ -26,6 +26,8 @@ func main() {
defer w.Destroy()
w.SetTitle("Bind Example")
w.SetSize(480, 320, webview.HintNone)
+ //w.SetUserAgent("мой кастомный UA")
+ //w.Navigate("https://www.whatismybrowser.com/detect/what-is-my-user-agent/")
// A binding that increments a value and immediately returns the new value.
w.Bind("increment", func() IncrementResult {
diff --git a/go.mod b/go.mod
index a3c3067..5bf671a 100644
--- a/go.mod
+++ b/go.mod
@@ -1,3 +1,6 @@
module github.com/webview/webview_go
go 1.13
+
+replace github.com/webview/webview => ../webview/core
+replace github.com/webview/webview_go => ../webview_go
diff --git a/libs/webview/include/api.h b/libs/webview/include/api.h
new file mode 120000
index 0000000..2e91e1d
--- /dev/null
+++ b/libs/webview/include/api.h
@@ -0,0 +1 @@
+/Users/pavel/src/webview/core/include/webview/api.h
\ No newline at end of file
diff --git a/libs/webview/include/backends.hh b/libs/webview/include/backends.hh
new file mode 120000
index 0000000..af74250
--- /dev/null
+++ b/libs/webview/include/backends.hh
@@ -0,0 +1 @@
+/Users/pavel/src/webview/core/include/webview/backends.hh
\ No newline at end of file
diff --git a/libs/webview/include/c_api_impl.hh b/libs/webview/include/c_api_impl.hh
new file mode 120000
index 0000000..175f563
--- /dev/null
+++ b/libs/webview/include/c_api_impl.hh
@@ -0,0 +1 @@
+/Users/pavel/src/webview/core/include/webview/c_api_impl.hh
\ No newline at end of file
diff --git a/libs/webview/include/detail b/libs/webview/include/detail
new file mode 120000
index 0000000..7bc412c
--- /dev/null
+++ b/libs/webview/include/detail
@@ -0,0 +1 @@
+/Users/pavel/src/webview/core/include/webview/detail
\ No newline at end of file
diff --git a/libs/webview/include/errors.h b/libs/webview/include/errors.h
new file mode 120000
index 0000000..42da266
--- /dev/null
+++ b/libs/webview/include/errors.h
@@ -0,0 +1 @@
+/Users/pavel/src/webview/core/include/webview/errors.h
\ No newline at end of file
diff --git a/libs/webview/include/errors.hh b/libs/webview/include/errors.hh
new file mode 120000
index 0000000..ff5643e
--- /dev/null
+++ b/libs/webview/include/errors.hh
@@ -0,0 +1 @@
+/Users/pavel/src/webview/core/include/webview/errors.hh
\ No newline at end of file
diff --git a/libs/webview/include/json_deprecated.hh b/libs/webview/include/json_deprecated.hh
new file mode 120000
index 0000000..b17165d
--- /dev/null
+++ b/libs/webview/include/json_deprecated.hh
@@ -0,0 +1 @@
+/Users/pavel/src/webview/core/include/webview/json_deprecated.hh
\ No newline at end of file
diff --git a/libs/webview/include/macros.h b/libs/webview/include/macros.h
new file mode 120000
index 0000000..c81f963
--- /dev/null
+++ b/libs/webview/include/macros.h
@@ -0,0 +1 @@
+/Users/pavel/src/webview/core/include/webview/macros.h
\ No newline at end of file
diff --git a/libs/webview/include/types.h b/libs/webview/include/types.h
new file mode 120000
index 0000000..9f02735
--- /dev/null
+++ b/libs/webview/include/types.h
@@ -0,0 +1 @@
+/Users/pavel/src/webview/core/include/webview/types.h
\ No newline at end of file
diff --git a/libs/webview/include/types.hh b/libs/webview/include/types.hh
new file mode 120000
index 0000000..047e9af
--- /dev/null
+++ b/libs/webview/include/types.hh
@@ -0,0 +1 @@
+/Users/pavel/src/webview/core/include/webview/types.hh
\ No newline at end of file
diff --git a/libs/webview/include/version.h b/libs/webview/include/version.h
new file mode 120000
index 0000000..f7c927d
--- /dev/null
+++ b/libs/webview/include/version.h
@@ -0,0 +1 @@
+/Users/pavel/src/webview/core/include/webview/version.h
\ No newline at end of file
diff --git a/libs/webview/include/webview.h b/libs/webview/include/webview.h
deleted file mode 100644
index 62ac14b..0000000
--- a/libs/webview/include/webview.h
+++ /dev/null
@@ -1,3598 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2017 Serge Zaitsev
- * Copyright (c) 2022 Steffen André Langnes
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-/// @file webview.h
-
-#ifndef WEBVIEW_H
-#define WEBVIEW_H
-
-/**
- * Used to specify function linkage such as extern, inline, etc.
- *
- * When @c WEBVIEW_API is not already defined, the defaults are as follows:
- *
- * - @c inline when compiling C++ code.
- * - @c extern when compiling C code.
- *
- * The following macros can be used to automatically set an appropriate
- * value for @c WEBVIEW_API:
- *
- * - Define @c WEBVIEW_BUILD_SHARED when building a shared library.
- * - Define @c WEBVIEW_SHARED when using a shared library.
- * - Define @c WEBVIEW_STATIC when building or using a static library.
- */
-#ifndef WEBVIEW_API
-#if defined(WEBVIEW_SHARED) || defined(WEBVIEW_BUILD_SHARED)
-#if defined(_WIN32) || defined(__CYGWIN__)
-#if defined(WEBVIEW_BUILD_SHARED)
-#define WEBVIEW_API __declspec(dllexport)
-#else
-#define WEBVIEW_API __declspec(dllimport)
-#endif
-#else
-#define WEBVIEW_API __attribute__((visibility("default")))
-#endif
-#elif !defined(WEBVIEW_STATIC) && defined(__cplusplus)
-#define WEBVIEW_API inline
-#else
-#define WEBVIEW_API extern
-#endif
-#endif
-
-/// @name Version
-/// @{
-
-#ifndef WEBVIEW_VERSION_MAJOR
-/// The current library major version.
-#define WEBVIEW_VERSION_MAJOR 0
-#endif
-
-#ifndef WEBVIEW_VERSION_MINOR
-/// The current library minor version.
-#define WEBVIEW_VERSION_MINOR 11
-#endif
-
-#ifndef WEBVIEW_VERSION_PATCH
-/// The current library patch version.
-#define WEBVIEW_VERSION_PATCH 0
-#endif
-
-#ifndef WEBVIEW_VERSION_PRE_RELEASE
-/// SemVer 2.0.0 pre-release labels prefixed with "-".
-#define WEBVIEW_VERSION_PRE_RELEASE ""
-#endif
-
-#ifndef WEBVIEW_VERSION_BUILD_METADATA
-/// SemVer 2.0.0 build metadata prefixed with "+".
-#define WEBVIEW_VERSION_BUILD_METADATA ""
-#endif
-
-/// @}
-
-/// @name Used internally
-/// @{
-
-/// Utility macro for stringifying a macro argument.
-#define WEBVIEW_STRINGIFY(x) #x
-
-/// Utility macro for stringifying the result of a macro argument expansion.
-#define WEBVIEW_EXPAND_AND_STRINGIFY(x) WEBVIEW_STRINGIFY(x)
-
-/// @}
-
-/// @name Version
-/// @{
-
-/// SemVer 2.0.0 version number in MAJOR.MINOR.PATCH format.
-#define WEBVIEW_VERSION_NUMBER \
- WEBVIEW_EXPAND_AND_STRINGIFY(WEBVIEW_VERSION_MAJOR) \
- "." WEBVIEW_EXPAND_AND_STRINGIFY( \
- WEBVIEW_VERSION_MINOR) "." WEBVIEW_EXPAND_AND_STRINGIFY(WEBVIEW_VERSION_PATCH)
-
-/// @}
-
-/// Holds the elements of a MAJOR.MINOR.PATCH version number.
-typedef struct {
- /// Major version.
- unsigned int major;
- /// Minor version.
- unsigned int minor;
- /// Patch version.
- unsigned int patch;
-} webview_version_t;
-
-/// Holds the library's version information.
-typedef struct {
- /// The elements of the version number.
- webview_version_t version;
- /// SemVer 2.0.0 version number in MAJOR.MINOR.PATCH format.
- char version_number[32];
- /// SemVer 2.0.0 pre-release labels prefixed with "-" if specified, otherwise
- /// an empty string.
- char pre_release[48];
- /// SemVer 2.0.0 build metadata prefixed with "+", otherwise an empty string.
- char build_metadata[48];
-} webview_version_info_t;
-
-/// Pointer to a webview instance.
-typedef void *webview_t;
-
-/// Native handle kind. The actual type depends on the backend.
-typedef enum {
- /// Top-level window. @c GtkWindow pointer (GTK), @c NSWindow pointer (Cocoa)
- /// or @c HWND (Win32).
- WEBVIEW_NATIVE_HANDLE_KIND_UI_WINDOW,
- /// Browser widget. @c GtkWidget pointer (GTK), @c NSView pointer (Cocoa) or
- /// @c HWND (Win32).
- WEBVIEW_NATIVE_HANDLE_KIND_UI_WIDGET,
- /// Browser controller. @c WebKitWebView pointer (WebKitGTK), @c WKWebView
- /// pointer (Cocoa/WebKit) or @c ICoreWebView2Controller pointer
- /// (Win32/WebView2).
- WEBVIEW_NATIVE_HANDLE_KIND_BROWSER_CONTROLLER
-} webview_native_handle_kind_t;
-
-/// Window size hints
-typedef enum {
- /// Width and height are default size.
- WEBVIEW_HINT_NONE,
- /// Width and height are minimum bounds.
- WEBVIEW_HINT_MIN,
- /// Width and height are maximum bounds.
- WEBVIEW_HINT_MAX,
- /// Window size can not be changed by a user.
- WEBVIEW_HINT_FIXED
-} webview_hint_t;
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * Creates a new webview instance.
- *
- * @param debug Enable developer tools if supported by the backend.
- * @param window Optional native window handle, i.e. @c GtkWindow pointer
- * @c NSWindow pointer (Cocoa) or @c HWND (Win32). If non-null,
- * the webview widget is embedded into the given window, and the
- * caller is expected to assume responsibility for the window as
- * well as application lifecycle. If the window handle is null,
- * a new window is created and both the window and application
- * lifecycle are managed by the webview instance.
- * @remark Win32: The function also accepts a pointer to @c HWND (Win32) in the
- * window parameter for backward compatibility.
- * @remark Win32/WebView2: @c CoInitializeEx should be called with
- * @c COINIT_APARTMENTTHREADED before attempting to call this function
- * with an existing window. Omitting this step may cause WebView2
- * initialization to fail.
- * @return @c NULL on failure. Creation can fail for various reasons such
- * as when required runtime dependencies are missing or when window
- * creation fails.
- */
-WEBVIEW_API webview_t webview_create(int debug, void *window);
-
-/**
- * Destroys a webview instance and closes the native window.
- *
- * @param w The webview instance.
- */
-WEBVIEW_API void webview_destroy(webview_t w);
-
-/**
- * Runs the main loop until it's terminated.
- *
- * @param w The webview instance.
- */
-WEBVIEW_API void webview_run(webview_t w);
-
-/**
- * Stops the main loop. It is safe to call this function from another other
- * background thread.
- *
- * @param w The webview instance.
- */
-WEBVIEW_API void webview_terminate(webview_t w);
-
-/**
- * Schedules a function to be invoked on the thread with the run/event loop.
- * Use this function e.g. to interact with the library or native handles.
- *
- * @param w The webview instance.
- * @param fn The function to be invoked.
- * @param arg An optional argument passed along to the callback function.
- */
-WEBVIEW_API void
-webview_dispatch(webview_t w, void (*fn)(webview_t w, void *arg), void *arg);
-
-/**
- * Returns the native handle of the window associated with the webview instance.
- * The handle can be a @c GtkWindow pointer (GTK), @c NSWindow pointer (Cocoa)
- * or @c HWND (Win32).
- *
- * @param w The webview instance.
- * @return The handle of the native window.
- */
-WEBVIEW_API void *webview_get_window(webview_t w);
-
-/**
- * Get a native handle of choice.
- *
- * @param w The webview instance.
- * @param kind The kind of handle to retrieve.
- * @return The native handle or @c NULL.
- * @since 0.11
- */
-WEBVIEW_API void *webview_get_native_handle(webview_t w,
- webview_native_handle_kind_t kind);
-
-/**
- * Updates the title of the native window.
- *
- * @param w The webview instance.
- * @param title The new title.
- */
-WEBVIEW_API void webview_set_title(webview_t w, const char *title);
-
-/**
- * Updates the size of the native window.
- *
- * @param w The webview instance.
- * @param width New width.
- * @param height New height.
- * @param hints Size hints.
- */
-WEBVIEW_API void webview_set_size(webview_t w, int width, int height,
- webview_hint_t hints);
-
-/**
- * Navigates webview to the given URL. URL may be a properly encoded data URI.
- *
- * Example:
- * @code{.c}
- * webview_navigate(w, "https://github.com/webview/webview");
- * webview_navigate(w, "data:text/html,%3Ch1%3EHello%3C%2Fh1%3E");
- * webview_navigate(w, "data:text/html;base64,PGgxPkhlbGxvPC9oMT4=");
- * @endcode
- *
- * @param w The webview instance.
- * @param url URL.
- */
-WEBVIEW_API void webview_navigate(webview_t w, const char *url);
-
-/**
- * Load HTML content into the webview.
- *
- * Example:
- * @code{.c}
- * webview_set_html(w, "
Hello
");
- * @endcode
- *
- * @param w The webview instance.
- * @param html HTML content.
- */
-WEBVIEW_API void webview_set_html(webview_t w, const char *html);
-
-/**
- * Injects JavaScript code to be executed immediately upon loading a page.
- * The code will be executed before @c window.onload.
- *
- * @param w The webview instance.
- * @param js JS content.
- */
-WEBVIEW_API void webview_init(webview_t w, const char *js);
-
-/**
- * Evaluates arbitrary JavaScript code.
- *
- * Use bindings if you need to communicate the result of the evaluation.
- *
- * @param w The webview instance.
- * @param js JS content.
- */
-WEBVIEW_API void webview_eval(webview_t w, const char *js);
-
-/**
- * Binds a function pointer to a new global JavaScript function.
- *
- * Internally, JS glue code is injected to create the JS function by the
- * given name. The callback function is passed a sequential request
- * identifier, a request string and a user-provided argument. The request
- * string is a JSON array of the arguments passed to the JS function.
- *
- * @param w The webview instance.
- * @param name Name of the JS function.
- * @param fn Callback function.
- * @param arg User argument.
- */
-WEBVIEW_API void webview_bind(webview_t w, const char *name,
- void (*fn)(const char *seq, const char *req,
- void *arg),
- void *arg);
-
-/**
- * Removes a binding created with webview_bind().
- *
- * @param w The webview instance.
- * @param name Name of the binding.
- */
-WEBVIEW_API void webview_unbind(webview_t w, const char *name);
-
-/**
- * Responds to a binding call from the JS side.
- *
- * @param w The webview instance.
- * @param seq The sequence number of the binding call. Pass along the value
- * received in the binding handler (see webview_bind()).
- * @param status A status of zero tells the JS side that the binding call was
- * succesful; any other value indicates an error.
- * @param result The result of the binding call to be returned to the JS side.
- * This must either be a valid JSON value or an empty string for
- * the primitive JS value @c undefined.
- */
-WEBVIEW_API void webview_return(webview_t w, const char *seq, int status,
- const char *result);
-
-/**
- * Get the library's version information.
- *
- * @since 0.10
- */
-WEBVIEW_API const webview_version_info_t *webview_version(void);
-
-#ifdef __cplusplus
-}
-
-#ifndef WEBVIEW_HEADER
-
-#if !defined(WEBVIEW_GTK) && !defined(WEBVIEW_COCOA) && !defined(WEBVIEW_EDGE)
-#if defined(__APPLE__)
-#define WEBVIEW_COCOA
-#elif defined(__unix__)
-#define WEBVIEW_GTK
-#elif defined(_WIN32)
-#define WEBVIEW_EDGE
-#else
-#error "please, specify webview backend"
-#endif
-#endif
-
-#ifndef WEBVIEW_DEPRECATED
-#if __cplusplus >= 201402L
-#define WEBVIEW_DEPRECATED(reason) [[deprecated(reason)]]
-#elif defined(_MSC_VER)
-#define WEBVIEW_DEPRECATED(reason) __declspec(deprecated(reason))
-#else
-#define WEBVIEW_DEPRECATED(reason) __attribute__((deprecated(reason)))
-#endif
-#endif
-
-#ifndef WEBVIEW_DEPRECATED_PRIVATE
-#define WEBVIEW_DEPRECATED_PRIVATE \
- WEBVIEW_DEPRECATED("Private API should not be used")
-#endif
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include