Giter VIP home page Giter VIP logo

fpwebview's People

Contributors

pierceng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

fpwebview's Issues

The lib of libwebview.so only supports gtk3, and Lazarus LCL only supports gtk2, so the demo of lclembed is failed to run

Env: UOS 20.9(linux) + Lazarus 2.2.6

Build the demo of lclembed with IDE, run it with linrun.sh, error msg:
(lclembed:413784): Gtk-ERROR **: 11:59:08.552: GTK+ 2.x symbols detected. Using GTK+ 2.x and GTK+ 3 in the same process is not supported
Trace/breakpoint trap

linrun.sh script:
#!/bin/sh
LD_LIBRARY_PATH=pwd ./lclembed

If build the demo with linbuild.sh, error msg:

Free Pascal Compiler version 3.2.2 [2021/07/09] for x86_64
Copyright (c) 1993-2021 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling lclembed.lpr
(LCLEMBED) Registering new unit SYSTEM
(LCLEMBED) Load from LCLEMBED (implementation) unit SYSTEM
(SYSTEM) Loading unit SYSTEM
(SYSTEM) PPU Name: /usr/lib/fpc/3.2.2/units/x86_64-linux/rtl/system.ppu
(SYSTEM) PPU Time: 2021/07/09 11:43:06
(SYSTEM) PPU Flags: 159873
(SYSTEM) PPU Crc: C9D9E0D9
(SYSTEM) PPU Crc: 531A4B0E (intfc)
(SYSTEM) PPU Crc: 4EF193DD (indc)
(SYSTEM) Number of definitions: 2651
(SYSTEM) Number of symbols: 8182
(SYSTEM) PPU Source: system.pp not available
(SYSTEM) PPU Source: osdefs.inc not available
(SYSTEM) PPU Source: sysunixh.inc not available
(SYSTEM) PPU Source: systemh.inc not available
....
(UNIXUTIL) Loading unit UNIXUTIL
(UNIXUTIL) PPU Name: /usr/lib/fpc/3.2.2/units/x86_64-linux/rtl/unixutil.ppu
(UNIXUTIL) PPU Time: 2021/07/09 11:43:06
(UNIXUTIL) PPU Flags: 143488
(UNIXUTIL) PPU Crc: A5FC410E
(UNIXUTIL) PPU Crc: 6AB6AC1B (intfc)
(UNIXUTIL) PPU Crc: 4EF193DD (indc)
(UNIXUTIL) Number of definitions: 9
(UNIXUTIL) Number of symbols: 50
(UNIXUTIL) PPU Source: unixutil.pp not available
(UNIXUTIL) Load from UNIXUTIL (interface) unit SYSTEM
(UNIXUTIL) Adding dependency: UNIXUTIL depends on SYSTEM
(UNIXUTIL) Finished loading unit UNIXUTIL
(UNIX) Adding dependency: UNIX depends on UNIXUTIL
(UNIX) Load from UNIX (implementation) unit SYSCALL
(UNIX) Adding dependency: UNIX depends on SYSCALL
(UNIX) Finished loading unit UNIX
(CTHREADS) Adding dependency: CTHREADS depends on UNIX
(CTHREADS) Load from CTHREADS (implementation) unit UNIXTYPE
(CTHREADS) Adding dependency: CTHREADS depends on UNIXTYPE
(CTHREADS) Load from CTHREADS (implementation) unit INITC
(INITC) Loading unit INITC
(INITC) PPU Name: /usr/lib/fpc/3.2.2/units/x86_64-linux/rtl/initc.ppu
(INITC) PPU Time: 2021/07/09 11:43:06
(INITC) PPU Flags: 143488
(INITC) PPU Crc: FC1AE8F5
(INITC) PPU Crc: 020CC9B5 (intfc)
(INITC) PPU Crc: 4EF193DD (indc)
(INITC) Number of definitions: 6
(INITC) Number of symbols: 10
(INITC) PPU Source: initc.pp not available
(INITC) Registering new unit CTYPES
(INITC) Load from INITC (interface) unit SYSTEM
(INITC) Adding dependency: INITC depends on SYSTEM
(INITC) Load from INITC (interface) unit CTYPES
(CTYPES) Loading unit CTYPES
(CTYPES) PPU Name: /usr/lib/fpc/3.2.2/units/x86_64-linux/rtl/ctypes.ppu
(CTYPES) PPU Time: 2021/07/09 11:43:06
(CTYPES) PPU Flags: 143488
(CTYPES) PPU Crc: 0D029B26
(CTYPES) PPU Crc: B1FE86DC (intfc)
(CTYPES) PPU Crc: 00000000 (indc)
(CTYPES) Number of definitions: 2
(CTYPES) Number of symbols: 65
(CTYPES) PPU Source: ctypes.pp not available
(CTYPES) PPU Source: aliasctp.inc not available
(CTYPES) Load from CTYPES (interface) unit SYSTEM
(CTYPES) Adding dependency: CTYPES depends on SYSTEM
(CTYPES) Load from CTYPES (interface) unit UNIXTYPE
(CTYPES) Adding dependency: CTYPES depends on UNIXTYPE
(CTYPES) Finished loading unit CTYPES
(INITC) Adding dependency: INITC depends on CTYPES
(INITC) Finished loading unit INITC
(CTHREADS) Adding dependency: CTHREADS depends on INITC
(CTHREADS) Load from CTHREADS (implementation) unit DL
(DL) Loading unit DL
(DL) PPU Name: /usr/lib/fpc/3.2.2/units/x86_64-linux/rtl/dl.ppu
(DL) PPU Time: 2021/07/09 11:43:06
(DL) PPU Flags: 143489
(DL) PPU Crc: 5DFC9E82
(DL) PPU Crc: FFD8DEA1 (intfc)
(DL) PPU Crc: 4EF193DD (indc)
(DL) Number of definitions: 27
(DL) Number of symbols: 56
(DL) PPU Source: dl.pp not available
(DL) Load from DL (interface) unit SYSTEM
(DL) Adding dependency: DL depends on SYSTEM
(DL) Load from DL (implementation) unit CTYPES
(DL) Adding dependency: DL depends on CTYPES
(DL) Finished loading unit DL
(CTHREADS) Adding dependency: CTHREADS depends on DL
(CTHREADS) Finished loading unit CTHREADS
(LCLEMBED) Load from LCLEMBED (implementation) unit INTERFACES
(INTERFACES) Loading unit INTERFACES
lclembed.lpr(9,3) Fatal: Can't find unit Interfaces used by lclembed
Fatal: Compilation aborted
Error: /usr/bin/ppcx64 returned an error exitcode

bad license text

  1. GH repo tells

The code is under MIT license, with following exceptions:

  1. code in webview.pas tells

This Source Code Form is subject to the terms of the Mozilla Public
License

Suggestions for modifying the winbuild.bat file

Taking into account the fact that the assembly provides for compilation only for 64 bits, it is advisable to add -Twin64 -Px86_64 to the compilation options.
As for the paths to the compiler, on Windows, when installing fpc or lazarus, the PATH environment variable is automatically set, so in most cases, you can not specify the full path.
However, if for some reason PATH is not specified (or fpc is not installed at all), then in this case it is advisable to handle the error using errorlevel and give instructions for manually writing the full path to the compiler.

@echo off
echo Building...
copy "....\dll\x86_64\libwebview.a" .
copy "....\dll\x86_64\webview.dll" .
copy "....\dll\x86_64\WebView2Loader.dll" .
fpc.exe -Twin64 -Px86_64 -Fu....\src -Fl. servcli.lpr
if errorlevel 1 (
echo ERROR: not found fpc.exe
echo ERROR: Edit this batch file to set up location of fpc.exe
)

Couple issues related to windows compilation

I am attaching a patch file for a couple of issues I ran into when I was trying to build your project on windows:

fpwebview-58daefe-cc5b90c.patch

The only one I actually tested with was the browser_cli compilation, so you may want to make sure the change from libwebview to libimpwebview also makes sense the other places I did it..

Suggestion for 2 updates

Great work, thanks !

Looking at the reference c header file https://github.com/webview/webview/blob/master/webview.h, and after testing (Windows only but it should be the same on Linux & MacOSX), let me suggest two updates :

  1. It's possible to add a useful declaration in webview.pas :
    procedure webview_set_html(w: PWebView; const html: PAnsiChar); cdecl; external webview_lib;

  2. in lclembed example, there is an improvement in CreateWebView and DestroyWebView calls, because the c reference header file indicates that webview_run() is a message loop running until it's terminated by a call to webview_terminate(). So webview_run() is a blocking call. It is required in a pascal command line program but not in a LCL GUI application.

This leads to the following changes in lclembed GUI application :

CreateWebView :

  if wvHandle <> nil then
    begin
      webview_bind(wvHandle, PAnsiChar('HostSayHello'), @SayHello, nil);
      webview_navigate(wvHandle, PAnsiChar('http://localhost:8000/'));
//      webview_run(wvHandle); //        <-- no need to call this in a GUI application
    end
  else
    // Use GUI dialog, not writeln.
    writeln('Failed to create webview object.');

Then to destroy the webview we only need to call webview_destroy() :

procedure TForm1.OnClickExitProgram(Sender: TObject);
begin
  isExiting := true;
//  if wvHandle <> nil then
//    webview_terminate(wvHandle); //     <-- not needed in a GUI application
// Sleep(500);                            <-- not needed too, i suppose (don't know why it's here)
    fphttpapp.Application.Terminate;
 if wvHandle <> nil then
   webview_destroy(wvHandle); 
 wvHandle := nil; 
  WebPanel.Hide;
//  Halt;           <-- not needed, the application will close gracefully because it's not blocked anymore by webview_run()
end;end;

type

type
PWebView = type Pointer;

is better because it makes new type which is not compatible with pointer.

Error compiling demos in windows.

Hello,
trying to compile the first demos but not succed.
here is the result :
`
C:\tmp\fpwebview\demo\browser_cli>winbuild.bat
Set up FPC executable path.
"C:\GNU\fpc323\App\fpc\bin\i386-win32\fpc.exe"
Building...
1 file(s) copied.
1 file(s) copied.
1 file(s) copied.
Free Pascal Compiler version 3.2.3-1334-ga6764eccd9 [2024/01/09] for i386
Copyright (c) 1993-2021 by Florian Klaempfl and others
Target OS: Win32 for i386
Compiling browser_cli.lpr
Compiling C:\tmp\fpwebview\src\webview.pas
Linking browser_cli.exe
browser_cli.lpr(25,1) Error: Illegal COFF Magic while reading libwebview.a(impwebview1s2.o)
browser_cli.lpr(25,1) Error: Illegal COFF Magic while reading libwebview.a(impwebview1s9.o)
browser_cli.lpr(25,1) Error: Illegal COFF Magic while reading libwebview.a(impwebview1s8.o)
browser_cli.lpr(25,1) Error: Illegal COFF Magic while reading libwebview.a(impwebview1s10.o)
browser_cli.lpr(25,1) Error: Illegal COFF Magic while reading libwebview.a(impwebview1s4.o)
browser_cli.lpr(25,1) Error: Illegal COFF Magic while reading libwebview.a(impwebview1s3.o)
browser_cli.lpr(25,1) Fatal: There were 6 errors compiling module, stopping
Fatal: Compilation aborted
Error: C:\GNU\fpc323\App\fpc\bin\i386-win32\ppc386.exe returned an error exitcode

`

and here is the winbuild.bat
`
@echo off

echo Set up FPC executable path.
set pfpc=C:\GNU\fpc323\App\fpc\bin\i386-win32
set path=%path%

set fpcexe=%pfpc%\fpc.exe

if not exist "%fpcexe%" (
echo ERROR: Edit this batch file to set up location of fpc.exe
exit /b 1
)
echo "%fpcexe%"

echo Building...
copy "....\dll\x86_64\libwebview.a" .
copy "....\dll\x86_64\webview.dll" .
copy "....\dll\x86_64\WebView2Loader.dll" .
"%fpcexe%" -Fu....\src -Fl. browser_cli.lpr
`

I think the dll and import library are 64bit while my fpc installation is 32 bit.
Could you put also the x32 dll please.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.