Commit Graph

115 Commits

Author SHA1 Message Date
Karl Seguin
f65a39a3e3 Re-enable telemetry
Start work on supporting navigation events (clicks, form submission).
2025-08-11 21:37:00 +08:00
Karl Seguin
54ab1326e5 Switch XHR to new http client
get puppeteer/cdp.js working again

make test are all passing
2025-08-11 21:37:00 +08:00
Karl Seguin
b0fe5d60ab Initial work on integrating libcurl and making all http nonblocking 2025-08-11 21:36:56 +08:00
Karl Seguin
f5da89b50b lit compatibility
Aims to improve compatibility for the lit framework (e.g. what Reddit is using).

1 - Adds support for adoptedStyleSheets to the Document and ShadowRoot
2 - Adds mock support for replace and replaceSync to the CSSStyleSheet
3 - Optionally include shadowroot in dump
4 - Special-case setting innerHTML on a TemplateElement
2025-08-09 07:43:27 +08:00
Pierre Tachoire
dc23a74e7b add <base> in the DOM tree 2025-08-08 18:34:14 +02:00
Pierre Tachoire
3d0928a449 add a --with_base option to fetch
with_base option adds a <base> tag to the dump for better offline preview.
2025-08-08 15:18:11 +02:00
Pierre Tachoire
ea1bca05c7 fix no-script default value 2025-08-08 14:30:41 +02:00
Karl Seguin
cfd62ac137 Add a --noscript option to "improve" --dump
Currently, fetch --dump includes <script> tag (either inline or with src). I
don't know what use-case this is the desired behavior. Excluding them, via the
new --noscript option has benefit that if you --dump --noscript and open the
resulting page in the browser, you don't re-execute JavaScript, which is
likely to break the page.

For example, opening a --dump of github makes it look like the page is broken
because it re-executes JavaScript that isn't meant to be re-executed.

Similarly, opening a --dump in a browser might execute JavaScript that
lightpanda browser failed to execute, making it looks like it worked better
than it did.
2025-07-14 18:24:36 +08:00
Pierre Tachoire
b78729f685 test: inject platform to the serveCDP app 2025-07-03 09:49:00 -07:00
Pierre Tachoire
22a93a9c39 add pump message loop calls 2025-07-03 09:47:50 -07:00
Karl Seguin
b50b96bd1d Implement ImportMeta callback
The first time `import.meta` is called within a module, this callback is called
and we can populate it with whatever fields we want. For WebAPI, the important
field is `url`:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import.meta

Depends on: https://github.com/lightpanda-io/zig-v8-fork/pull/80
2025-07-01 15:59:24 +08:00
Pierre Tachoire
03e3f95d2e Merge pull request #810 from lightpanda-io/proxy-authentication
basic/bearer proxy authentication
2025-06-25 17:31:47 -07:00
sjorsdonkers
aea34264a9 basic/bearer testing 2025-06-25 12:04:38 +02:00
Karl Seguin
1e7ee4e0a1 proxy_type 'simple' renamed to 'forward' 2025-06-25 12:21:44 +08:00
sjorsdonkers
4560f31010 basic/bearer proxy authentication 2025-06-24 16:38:58 +02:00
Karl Seguin
c97a32e24b Initial work on CONNECT proxy.
Cannot currently connect to the proxy over TLS (though, once connected, it can
connect to the actual site over TLS). No support for authentication.
2025-06-24 15:10:20 +08:00
Karl Seguin
fe6ccad485 loop.run now takes a maximum wait time 2025-06-23 16:43:28 +08:00
Karl Seguin
e5a76d737c Increase default timeout from 3s to 10s.
The wait_for_network_idle demo often times out for me. I don't see any reason
to have the default so low. More likely to cause user scripts to unnecessarily
fail.
2025-06-03 09:57:51 +08:00
Karl Seguin
e3099a16d4 fix a silly log crash on exit error 2025-06-02 23:34:09 +08:00
Karl Seguin
c3f3eea7fb Improve logging
1 - Make log_level a runtime option (not a build-time)
2 - Make log_format a runtime option
3 - In Debug mode, allow for log scope filtering

Improve the general usability of scopes. Previously, the scope was more or less
based on the file that the log was in. Now they are more logically grouped.
Consider the case where you want to silence HTTP request information, previously
you'd have to filter out the `page`, `xhr` and `http_client` scopes, but that
would also elimiate other page, xhr and http_client logs. Now, you can just
filter out the `http` scope.
2025-06-02 21:38:56 +08:00
Karl Seguin
fe9344ce57 Try stateless logger (to save memory) 2025-05-27 19:57:58 +08:00
Karl Seguin
2feba3182a Replace std.log with a structured logger
Outputs in logfmt in release and a "pretty" print in debug mode. The format
along with the log level will become arguments to the binary at some point in
the future.
2025-05-27 19:57:58 +08:00
Karl Seguin
c77fb98b1f Fix insecure_disable_tls_host_verification in serve more
It's currently using `--insecure_tls_verify_host` which is inconsistent with
fetch-mode and not what the help text says.
2025-05-26 22:42:42 +08:00
Karl Seguin
b1d0368479 Remove --gc_hints option, apply the --gc_hints behavior by default 2025-05-23 14:15:55 +08:00
Karl Seguin
769d99e7bd Tweak debug logging
1 - Add a log_level build option to control the default log level from
    the build (e.g. -Dlog_level=debug). Defaults to info

2 - Add a new boolean log_unknown_properties build option to enable
    logging unknown properties. Defautls to false.

3 - Remove the log debug for script eval - this can be a huge value
    (i.e. hundreds of KB), which makes the debug log unusable IMO.
2025-05-20 11:29:14 +08:00
Karl Seguin
e918a0bf26 add direct http proxy support 2025-05-13 18:21:27 +08:00
Karl Seguin
ce2eed28c1 Fix memory leaks 2025-05-13 10:42:16 +08:00
Karl Seguin
505fa91d7d add keepalive to http client 2025-05-13 10:42:16 +08:00
Karl Seguin
78bfdd4515 Support gzip compressed content for the synchronous http client 2025-05-06 16:23:44 +08:00
Karl Seguin
6c592669da Introduce more general notification capabilities
Replaces the existing, very specialized Notification with something more
general.

Currently, the existing page_navigate and page_navigated have been migrated.

Telemetry's page navigation event now also hooks into these events to generate
the telemetry record.
2025-04-30 17:33:51 +08:00
Karl Seguin
2d5ff8252c Reorganize v8 contexts and scope
- Pages within the same session have proper isolation
  - they have their own window
  - they have their own SessionState
  - they have their own v8.Context

- Move inspector to CDP browser context
  - Browser now knows nothing about the inspector

- Use notification to emit a context-created message
  - This is still a bit hacky, but again, it decouples browser from CDP
2025-04-29 10:22:08 +08:00
Karl Seguin
89fea9b4df initialize ICU
This makes functions like new Intl.DateTimeFormat() not crash.
2025-04-25 13:15:38 +08:00
Karl Seguin
3134ff81f4 JS clicks and MouseInput clicks trigger page navigation 2025-04-18 16:24:04 +08:00
Karl Seguin
5816443ad3 improve XHR test reliability 2025-04-15 18:24:43 +08:00
Karl Seguin
e9fce9223e add some debug lines to see if we can fix the github action 2025-04-15 15:42:55 +08:00
Karl Seguin
b8d7744563 replace zig-js-runtime 2025-04-15 15:18:04 +08:00
Karl Seguin
71c3d484a9 Communicate page navigation state via notifications
In order to support click handling on anchors from JavaScript, we need some hook
from the page/session to the CDP instance. This first phase adds notifications
in page.navigate, as well as a primitive notification hook to the session.

CDP's existing Page.navigate uses this new notifiation system.
2025-04-10 14:25:19 +08:00
Pierre Tachoire
cf015b2ce7 main: exit 1 on memory leak detection 2025-03-31 12:35:33 +02:00
Karl Seguin
c6538e1038 Add an insecure_disable_tls_host_verification command line option
When set, this disables the host verification of all HTTP requests. Available
for both the fetch and serve mode.

Also introduced an App.Config, for future command line options which need to
be passed more deeply into the code.
2025-03-27 18:02:30 +08:00
Karl Seguin
21c9dde858 Zig 0.14 compatibility 2025-03-19 16:28:15 +01:00
Karl Seguin
ba8a0179d5 Share the HTTP client globally 2025-03-19 11:09:58 +08:00
Karl Seguin
cd33a089d1 flatten events, include aarch + os, remove eid 2025-03-18 08:26:58 +08:00
Karl Seguin
6b83281539 Add navigate telemetry 2025-03-18 08:25:44 +08:00
Karl Seguin
accf2c0e5e use async-client for telemetry 2025-03-18 08:02:09 +08:00
Karl Seguin
56ddcc8e29 Initial usage telemetry 2025-03-18 08:02:09 +08:00
Karl Seguin
3fe28d5441 Optimize memory usage
The two bigger changes here are:

1- The http_client has been moved from the Session to the Browser, allowing
   its connection pool to be re-used across multiple sessions

2- The browser now has a page_arena which is used for all page-level allocation
   and which can be re-used between pages (currently retains 1MB of memory).
   Previously, pages uses an arena that was tied to the lifetime of the page,
   thus it could not be re-used.

Using the Bench allocator for zig-js-runtime, allocated bytes went from
1347037879 to 834932438 (in a RUNS=1000 of puppeteer demo).

Various other changes to try to simplify the API and remove the possibility
of invalid states. For example, session.newPage() now includes the logic for
page.start() so that there should now never be a page that wasn't started.
2025-03-12 13:38:22 +08:00
Karl Seguin
28008d835e allow longer timeouts (u8 -> u16) 2025-02-27 11:00:37 +08:00
Karl Seguin
d0ba06c44b Add git_commit to build and build-dev target
Add "version" command to cli.
2025-02-26 20:44:44 +08:00
Karl Seguin
9519d3f7ce use an arena for the args 2025-02-22 20:25:01 +08:00
Karl Seguin
85df280447 When explicit mode (serve/fetch/help) isn't given, infer it from the options 2025-02-22 13:54:05 +08:00