bidi2pdf 0.1.13 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.devcontainer/Dockerfile +53 -0
- data/.devcontainer/devcontainer.json +51 -0
- data/.devcontainer/docker-compose.yml +33 -0
- data/.ruby-gemset +1 -1
- data/.ruby-version +1 -1
- data/CHANGELOG.md +93 -6
- data/README.md +80 -5
- data/docker/Dockerfile +1 -1
- data/docker/Dockerfile.slim +2 -2
- data/docker/chrome-driver/chrome.json +874 -0
- data/lib/bidi2pdf/bidi/browser_tab.rb +97 -4
- data/lib/bidi2pdf/bidi/buffered_web_socket_client.rb +178 -0
- data/lib/bidi2pdf/bidi/client.rb +12 -5
- data/lib/bidi2pdf/bidi/commands/base.rb +2 -0
- data/lib/bidi2pdf/bidi/commands/capture_screenshot.rb +33 -0
- data/lib/bidi2pdf/bidi/commands/set_viewport.rb +32 -0
- data/lib/bidi2pdf/bidi/commands.rb +2 -0
- data/lib/bidi2pdf/bidi/network_event.rb +12 -3
- data/lib/bidi2pdf/bidi/network_events.rb +9 -1
- data/lib/bidi2pdf/bidi/session.rb +1 -1
- data/lib/bidi2pdf/chromedriver_manager.rb +10 -6
- data/lib/bidi2pdf/cli.rb +11 -1
- data/lib/bidi2pdf/launcher.rb +5 -3
- data/lib/bidi2pdf/notifications/logging_subscriber.rb +2 -0
- data/lib/bidi2pdf/session_warmer.rb +377 -0
- data/lib/bidi2pdf/test_helpers/images.rb +8 -0
- data/lib/bidi2pdf/test_helpers/pdf_reader_utils.rb +1 -2
- data/lib/bidi2pdf/test_helpers/pdf_text_sanitizer.rb +1 -2
- data/lib/bidi2pdf/test_helpers/testcontainers/chromedriver_container.rb +1 -1
- data/lib/bidi2pdf/test_helpers/testcontainers/chromedriver_test_helper.rb +22 -2
- data/lib/bidi2pdf/test_helpers/testcontainers/container_endpoint.rb +30 -0
- data/lib/bidi2pdf/test_helpers/testcontainers/testcontainers_refinement.rb +33 -0
- data/lib/bidi2pdf/test_helpers/testcontainers.rb +1 -0
- data/lib/bidi2pdf/version.rb +1 -1
- data/lib/bidi2pdf.rb +26 -1
- data/sig/bidi2pdf/bidi/add_headers_interceptor.rbs +16 -9
- data/sig/bidi2pdf/bidi/auth_interceptor.rbs +32 -7
- data/sig/bidi2pdf/bidi/browser.rbs +4 -31
- data/sig/bidi2pdf/bidi/browser_console_logger.rbs +59 -0
- data/sig/bidi2pdf/bidi/browser_tab.rbs +269 -25
- data/sig/bidi2pdf/bidi/buffered_web_socket_client.rbs +81 -0
- data/sig/bidi2pdf/bidi/client.rbs +103 -43
- data/sig/bidi2pdf/bidi/command_manager.rbs +5 -17
- data/sig/bidi2pdf/bidi/commands/add_intercept.rbs +16 -8
- data/sig/bidi2pdf/bidi/commands/base.rbs +49 -9
- data/sig/bidi2pdf/bidi/commands/browser_close.rbs +3 -1
- data/sig/bidi2pdf/bidi/commands/browser_create_user_context.rbs +2 -0
- data/sig/bidi2pdf/bidi/commands/browser_remove_user_context.rbs +19 -0
- data/sig/bidi2pdf/bidi/commands/browsing_context_close.rbs +8 -2
- data/sig/bidi2pdf/bidi/commands/browsing_context_navigate.rbs +12 -6
- data/sig/bidi2pdf/bidi/commands/browsing_context_print.rbs +10 -5
- data/sig/bidi2pdf/bidi/commands/cancel_auth.rbs +8 -2
- data/sig/bidi2pdf/bidi/commands/capture_screenshot.rbs +31 -0
- data/sig/bidi2pdf/bidi/commands/cdp_get_session.rbs +17 -0
- data/sig/bidi2pdf/bidi/commands/create_window.rbs +4 -0
- data/sig/bidi2pdf/bidi/commands/get_user_contexts.rbs +2 -0
- data/sig/bidi2pdf/bidi/commands/network_continue.rbs +4 -0
- data/sig/bidi2pdf/bidi/commands/page_print.rbs +28 -0
- data/sig/bidi2pdf/bidi/commands/print_parameters_validator.rbs +3 -0
- data/sig/bidi2pdf/bidi/commands/provide_credentials.rbs +12 -6
- data/sig/bidi2pdf/bidi/commands/script_evaluate.rbs +4 -0
- data/sig/bidi2pdf/bidi/commands/session_end.rbs +2 -0
- data/sig/bidi2pdf/bidi/commands/session_status.rbs +3 -1
- data/sig/bidi2pdf/bidi/commands/session_subscribe.rbs +4 -0
- data/sig/bidi2pdf/bidi/commands/set_tab_cookie.rbs +51 -23
- data/sig/bidi2pdf/bidi/commands/set_usercontext_cookie.rbs +17 -19
- data/sig/bidi2pdf/bidi/commands/set_viewport.rbs +31 -0
- data/sig/bidi2pdf/bidi/connection_manager.rbs +2 -1
- data/sig/bidi2pdf/bidi/event_manager.rbs +14 -19
- data/sig/bidi2pdf/bidi/interceptor.rbs +5 -0
- data/sig/bidi2pdf/bidi/js_logger_helper.rbs +9 -0
- data/sig/bidi2pdf/bidi/logger_events.rbs +21 -0
- data/sig/bidi2pdf/bidi/navigation_failed_events.rbs +17 -0
- data/sig/bidi2pdf/bidi/network_event.rbs +64 -46
- data/sig/bidi2pdf/bidi/network_event_formatters/network_event_console_formatter.rbs +63 -0
- data/sig/bidi2pdf/bidi/network_event_formatters/network_event_formatter_utils.rbs +15 -0
- data/sig/bidi2pdf/bidi/network_event_formatters/network_event_html_formatter.rbs +18 -0
- data/sig/bidi2pdf/bidi/network_event_formatters.rbs +6 -0
- data/sig/bidi2pdf/bidi/network_events.rbs +14 -39
- data/sig/bidi2pdf/bidi/session.rbs +144 -31
- data/sig/bidi2pdf/bidi/user_context.rbs +64 -45
- data/sig/bidi2pdf/bidi/web_socket_dispatcher.rbs +22 -30
- data/sig/bidi2pdf/chromedriver_manager.rbs +61 -22
- data/sig/bidi2pdf/cli.rbs +22 -2
- data/sig/bidi2pdf/dsl.rbs +34 -0
- data/sig/bidi2pdf/launcher.rbs +39 -1
- data/sig/bidi2pdf/notifications/event.rbs +40 -0
- data/sig/bidi2pdf/notifications/instrumenter.rbs +21 -0
- data/sig/bidi2pdf/notifications/logging_subscriber.rbs +41 -0
- data/sig/bidi2pdf/notifications.rbs +24 -0
- data/sig/bidi2pdf/process_tree.rbs +2 -2
- data/sig/bidi2pdf/session_runner.rbs +41 -1
- data/sig/bidi2pdf/session_warmer.rbs +221 -0
- data/sig/bidi2pdf/test_helpers/configuration.rbs +51 -0
- data/sig/bidi2pdf/test_helpers/images/extractor.rbs +43 -0
- data/sig/bidi2pdf/test_helpers/images/image_similarity_checker.rbs +35 -0
- data/sig/bidi2pdf/test_helpers/images/tiff_helper.rbs +70 -0
- data/sig/bidi2pdf/test_helpers/images.rbs +0 -0
- data/sig/bidi2pdf/test_helpers/matchers/contains_pdf_image.rbs +0 -0
- data/sig/bidi2pdf/test_helpers/matchers/contains_pdf_text.rbs +0 -0
- data/sig/bidi2pdf/test_helpers/matchers/have_pdf_page_count.rbs +0 -0
- data/sig/bidi2pdf/test_helpers/matchers/match_pdf_text.rbs +0 -0
- data/sig/bidi2pdf/test_helpers/pdf_file_helper.rbs +23 -0
- data/sig/bidi2pdf/test_helpers/pdf_reader_utils.rbs +49 -0
- data/sig/bidi2pdf/test_helpers/pdf_text_sanitizer.rbs +38 -0
- data/sig/bidi2pdf/test_helpers/spec_paths_helper.rbs +35 -0
- data/sig/bidi2pdf/test_helpers/testcontainers/chromedriver_container.rbs +43 -0
- data/sig/bidi2pdf/test_helpers/testcontainers/chromedriver_test_helper.rbs +45 -0
- data/sig/bidi2pdf/test_helpers/testcontainers/container_endpoint.rbs +25 -0
- data/sig/bidi2pdf/test_helpers/testcontainers/shared_docker_network.rbs +3 -0
- data/sig/bidi2pdf/test_helpers/testcontainers/testcontainers_refinement.rbs +47 -0
- data/sig/bidi2pdf/test_helpers/testcontainers.rbs +6 -0
- data/sig/bidi2pdf/test_helpers.rbs +0 -0
- data/sig/bidi2pdf/verbose_logger.rbs +37 -0
- data/sig/bidi2pdf/version.rbs +3 -0
- data/sig/bidi2pdf.rbs +130 -2
- data/tasks/generate_rbs.rake +11 -11
- data/tasks/release_credentials_check.rake +97 -0
- metadata +67 -10
- data/sig/bidi2pdf/utils.rbs +0 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 36afd0d1f8c64ff6d72a8051785d3f65a7efcb336c07e1a6756b772ff4f17414
|
|
4
|
+
data.tar.gz: 6ecddfbacf09de3757b65009e1c41ca3cb90b8667d2fe80972200159d9f0c2b3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '0490c1e9e84467c4437eaf65128cf9adddac4509a66e7e41a791f10cb5fee6ee86d5fb821177af022a04a41441c6c57a37e8015e6a288c5e6838ecbc966bb628'
|
|
7
|
+
data.tar.gz: 935185356734aded9f38453cb2e6340501d1f99c482ffc17d62201867dd95224fe7018dfc079cfbdeed72ea44c63233fb5769987ddaa339ed7425ee6b0e281f5
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
FROM mcr.microsoft.com/devcontainers/ruby:2-3.4-trixie
|
|
2
|
+
|
|
3
|
+
# Install Rails
|
|
4
|
+
RUN su vscode -c "/usr/local/rvm/bin/rvm fix-permissions"
|
|
5
|
+
|
|
6
|
+
RUN rm -f /etc/apt/sources.list.d/yarn.list \
|
|
7
|
+
&& find /etc/apt/sources.list.d -type f \
|
|
8
|
+
-exec sed -i '\|https://dl.yarnpkg.com/debian|d' {} + \
|
|
9
|
+
&& apt-get update \
|
|
10
|
+
&& apt-get install -y --no-install-recommends \
|
|
11
|
+
build-essential \
|
|
12
|
+
git \
|
|
13
|
+
nodejs \
|
|
14
|
+
ca-certificates \
|
|
15
|
+
curl \
|
|
16
|
+
openssh-server \
|
|
17
|
+
procps \
|
|
18
|
+
util-linux \
|
|
19
|
+
socat \
|
|
20
|
+
libjemalloc2 libvips sqlite3 libyaml-dev chromium-driver \
|
|
21
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
22
|
+
|
|
23
|
+
# Default value to allow debug server to serve content over GitHub Codespace's port forwarding service
|
|
24
|
+
# The value is a comma-separated list of allowed domains
|
|
25
|
+
ENV RAILS_DEVELOPMENT_HOSTS=".githubpreview.dev,.preview.app.github.dev,.app.github.dev"
|
|
26
|
+
|
|
27
|
+
# Install rbenv and ruby-build as vscode.
|
|
28
|
+
RUN su vscode -c 'curl -fsSL https://rbenv.org/install.sh | bash'
|
|
29
|
+
|
|
30
|
+
# Install and select Ruby 3.4.8.
|
|
31
|
+
RUN su vscode -c '\
|
|
32
|
+
export RBENV_ROOT="$HOME/.rbenv" && \
|
|
33
|
+
export PATH="$RBENV_ROOT/bin:$PATH" && \
|
|
34
|
+
eval "$(rbenv init - bash)" && \
|
|
35
|
+
rbenv install 3.4.8 && \
|
|
36
|
+
rbenv global 3.4.8 && \
|
|
37
|
+
rbenv rehash && \
|
|
38
|
+
ruby --version \
|
|
39
|
+
'
|
|
40
|
+
|
|
41
|
+
RUN mkdir -p /home/vscode/.webdrivers \
|
|
42
|
+
&& chown -R vscode:vscode /home/vscode/.webdrivers \
|
|
43
|
+
&& ln -sfn /usr/bin/chromedriver /home/vscode/.webdrivers/chromedriver \
|
|
44
|
+
|
|
45
|
+
# [Optional] Uncomment this section to install additional OS packages.
|
|
46
|
+
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
|
47
|
+
# && apt-get -y install --no-install-recommends <your-package-list-here>
|
|
48
|
+
|
|
49
|
+
# [Optional] Uncomment this line to install additional gems.
|
|
50
|
+
# RUN su vscode -c "gem install <your-gem-names-here>"
|
|
51
|
+
|
|
52
|
+
# [Optional] Uncomment this line to install global node packages.
|
|
53
|
+
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
|
|
2
|
+
// README at: https://github.com/devcontainers/templates/tree/main/src/ruby-rails-postgres
|
|
3
|
+
{
|
|
4
|
+
"name": "Ruby-Bidi2PDF",
|
|
5
|
+
"dockerComposeFile": "docker-compose.yml",
|
|
6
|
+
"service": "app",
|
|
7
|
+
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
|
|
8
|
+
"runServices": [
|
|
9
|
+
"app",
|
|
10
|
+
"remote-chrome-debug"
|
|
11
|
+
],
|
|
12
|
+
// Features to add to the dev container. More info: https://containers.dev/features.
|
|
13
|
+
// "features": {},
|
|
14
|
+
"features": {
|
|
15
|
+
"ghcr.io/devcontainers/features/github-cli:1": {},
|
|
16
|
+
"ghcr.io/rails/devcontainer/features/activestorage": {},
|
|
17
|
+
"ghcr.io/devcontainers/features/docker-in-docker:4": {
|
|
18
|
+
"version": "latest",
|
|
19
|
+
"moby": false
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
|
23
|
+
// This can be used to network with other containers or the host.
|
|
24
|
+
// "forwardPorts": [3000, 5432],
|
|
25
|
+
|
|
26
|
+
// Use 'postCreateCommand' to run commands after the container is created.
|
|
27
|
+
// "postCreateCommand": "bundle install && rake db:setup",
|
|
28
|
+
|
|
29
|
+
// Configure tool-specific properties.
|
|
30
|
+
"customizations": {
|
|
31
|
+
"jetbrains": {
|
|
32
|
+
"settings": {
|
|
33
|
+
"com.intellij:app:HttpConfigurable.use_proxy_pac": true,
|
|
34
|
+
"com.intellij:app:BaseRefactoringSettings.safe_delete_when_delete": false,
|
|
35
|
+
"com.intellij:app:BaseRefactoringSettings.rename_search_in_comments_for_file": false,
|
|
36
|
+
"com.intellij:app:BaseRefactoringSettings.rename_search_for_references_for_file": false,
|
|
37
|
+
"com.intellij:app:BaseRefactoringSettings.rename_search_for_references_for_directory": false,
|
|
38
|
+
"com.intellij:app:BaseRefactoringSettings.move_search_for_references_for_file": false
|
|
39
|
+
},
|
|
40
|
+
"backend": "RubyMine"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
|
|
44
|
+
// "remoteUser": "root",
|
|
45
|
+
|
|
46
|
+
"containerEnv": {
|
|
47
|
+
"IN_DEV_CONTAINER": "true",
|
|
48
|
+
"DISABLE_CHROME_SANDBOX": "true",
|
|
49
|
+
"REMOTE_BROWSER_URL": "http://remote-chrome:3000/session"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
version: '3'
|
|
2
|
+
|
|
3
|
+
services:
|
|
4
|
+
app:
|
|
5
|
+
build:
|
|
6
|
+
context: ..
|
|
7
|
+
dockerfile: .devcontainer/Dockerfile
|
|
8
|
+
|
|
9
|
+
# volumes:
|
|
10
|
+
# - ../..:/workspaces:cached
|
|
11
|
+
|
|
12
|
+
# Overrides default command so things don't shut down after the process ends.
|
|
13
|
+
command: sleep infinity
|
|
14
|
+
|
|
15
|
+
# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
|
|
16
|
+
network_mode: service:remote-chrome-debug
|
|
17
|
+
|
|
18
|
+
# volumes:
|
|
19
|
+
# - /var/run/docker.sock:/var/run/docker.sock
|
|
20
|
+
|
|
21
|
+
# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
|
|
22
|
+
# (Adding the "ports" property to this file will not forward from a Codespace.)
|
|
23
|
+
|
|
24
|
+
remote-chrome-debug:
|
|
25
|
+
image: dieters877565/chromedriver:latest
|
|
26
|
+
environment:
|
|
27
|
+
ENABLE_XVFB: true
|
|
28
|
+
ENABLE_VNC: true
|
|
29
|
+
VNC_PASS: ${REMOTE_CHROME_VNC_PASS:-supersecret}
|
|
30
|
+
cap_add:
|
|
31
|
+
- SYS_ADMIN
|
|
32
|
+
ports:
|
|
33
|
+
- "127.0.0.1:${REMOTE_CHROME_VNC_PORT:-5900}:5900"
|
data/.ruby-gemset
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
-global
|
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
ruby-3.4.
|
|
1
|
+
ruby-3.4.8
|
data/CHANGELOG.md
CHANGED
|
@@ -8,10 +8,95 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
8
8
|
|
|
9
9
|
## [Unreleased]
|
|
10
10
|
|
|
11
|
-
[unreleased]: https://github.com/dieter-medium/bidi2pdf/compare/v0.1.
|
|
11
|
+
[unreleased]: https://github.com/dieter-medium/bidi2pdf/compare/v0.1.15..HEAD
|
|
12
12
|
|
|
13
13
|
<!-- generated by git-cliff end -->
|
|
14
14
|
|
|
15
|
+
## [0.1.15] - 2026-09-20
|
|
16
|
+
|
|
17
|
+
### 🎨 Refactored
|
|
18
|
+
|
|
19
|
+
- Remove deprecated benchmarking script
|
|
20
|
+
|
|
21
|
+
### 🐛 Fixed
|
|
22
|
+
|
|
23
|
+
- Handle partial Chrome session builds and cleanup
|
|
24
|
+
- Ensure consistent use of alias in nginx_url helper
|
|
25
|
+
- Use AtomicFixnum for thread-safe slot counting
|
|
26
|
+
- Refactor Chrome session setup in specs
|
|
27
|
+
- Improve session warmer configuration and timeout handling
|
|
28
|
+
- Decouple chromedriver log level from logger level
|
|
29
|
+
- Remove navigation ID generation for sub-resources
|
|
30
|
+
- Remove redundant timeout error test
|
|
31
|
+
- Improve string truncation for log safety
|
|
32
|
+
- Improve release credentials check for missing keys
|
|
33
|
+
- Enhance WebSocket handling for control frames and errors
|
|
34
|
+
- Add chromedriver log level configuration
|
|
35
|
+
- Adjust benchmark thresholds for CI environments
|
|
36
|
+
- Add string truncation for safe log output
|
|
37
|
+
- Set timeout for RSpec test runs
|
|
38
|
+
- Prevent logging raw data URLs during navigation
|
|
39
|
+
- Generate unique navigation IDs for sub-resource requests
|
|
40
|
+
|
|
41
|
+
### 🔄 Changed
|
|
42
|
+
|
|
43
|
+
- Merge pull request #124 from dieter-medium/feat/session-warmer
|
|
44
|
+
- Merge pull request #123 from dieter-medium/feat/faster-pdf-generation
|
|
45
|
+
- Merge pull request #122 from dieter-medium/chore-prepare-dev
|
|
46
|
+
- Bump version to 0.1.15.pre
|
|
47
|
+
|
|
48
|
+
### 🚀 Added
|
|
49
|
+
|
|
50
|
+
- Implement session warmer idle time management
|
|
51
|
+
- Improve session warmer threading and recovery
|
|
52
|
+
- Enhance session warming and WebSocket health checks
|
|
53
|
+
- Add session warmer and enhance version resolver error handling
|
|
54
|
+
- Add session warming and programmatic configuration
|
|
55
|
+
- Add chromedriver log level mapping and tests
|
|
56
|
+
- Add release credential check for rubygems.org
|
|
57
|
+
- Add navigation id handling in network events
|
|
58
|
+
- Replace WebSocket client library for performance
|
|
59
|
+
- Implement BufferedWebSocketClient and benchmarks
|
|
60
|
+
|
|
61
|
+
## [0.1.14] - 2026-09-19
|
|
62
|
+
|
|
63
|
+
### 🐛 Fixed
|
|
64
|
+
|
|
65
|
+
- Update Dockerfile to use Ruby 3.4-slim
|
|
66
|
+
|
|
67
|
+
### 🔄 Changed
|
|
68
|
+
|
|
69
|
+
- Merge pull request #120 from dieter-medium/chore-fix-sig
|
|
70
|
+
- Merge pull request #119 from dieter-medium/chore-update-gems
|
|
71
|
+
- Merge pull request #118 from dieter-medium/enhance-test-helpers
|
|
72
|
+
- Merge pull request #103 from dieter-medium/enhance-test-helpers
|
|
73
|
+
- Merge pull request #95 from dieter-medium/dependabot/bundler/bundler-b0eb7e8c29
|
|
74
|
+
- Merge pull request #82 from dieter-medium/dependabot/bundler/main/rake-13.4.2
|
|
75
|
+
- Merge pull request #96 from dieter-medium/dependabot/bundler/main/rubocop-1.88.2
|
|
76
|
+
- Merge pull request #100 from dieter-medium/dependabot/bundler/main/concurrent-ruby-1.3.8
|
|
77
|
+
- Merge pull request #101 from dieter-medium/dependabot/bundler/main/rbs-4.1.0
|
|
78
|
+
- Merge pull request #87 from dieter-medium/dependabot/bundler/main/rubocop-rspec-3.10.2
|
|
79
|
+
- Merge pull request #92 from dieter-medium/dependabot/bundler/main/rubocop-1.88.0
|
|
80
|
+
- Merge pull request #93 from dieter-medium/dependabot/bundler/bundler-0f363c4924
|
|
81
|
+
- Merge pull request #79 from dieter-medium/fix-slim-image
|
|
82
|
+
|
|
83
|
+
### 🔧 Build
|
|
84
|
+
|
|
85
|
+
- Bump excon in the bundler group across 1 directory
|
|
86
|
+
- Bump rake from 13.3.1 to 13.4.2
|
|
87
|
+
- Bump rubocop from 1.88.0 to 1.88.2
|
|
88
|
+
- Bump concurrent-ruby from 1.3.7 to 1.3.8
|
|
89
|
+
- Bump rbs from 4.0.2 to 4.1.0
|
|
90
|
+
- Bump rubocop-rspec from 3.9.0 to 3.10.2
|
|
91
|
+
- Bump rubocop from 1.86.0 to 1.88.0
|
|
92
|
+
- Bump concurrent-ruby
|
|
93
|
+
|
|
94
|
+
### 🚀 Added
|
|
95
|
+
|
|
96
|
+
- Add new RBS type definitions for Bidi2pdf
|
|
97
|
+
- Add screenshot and viewport management
|
|
98
|
+
- Add options for Chrome sandbox and flags wihtin the cli
|
|
99
|
+
|
|
15
100
|
## [0.1.13] - 2026-03-28
|
|
16
101
|
|
|
17
102
|
### 🔄 Changed
|
|
@@ -368,11 +453,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
368
453
|
|
|
369
454
|
### 🔄 Released
|
|
370
455
|
|
|
371
|
-
- [unreleased](https://github.com/dieter-medium/bidi2pdf/compare/v0.1.
|
|
372
|
-
- [0.1.
|
|
373
|
-
- [0.1.
|
|
374
|
-
- [0.1.
|
|
375
|
-
- [0.1.
|
|
456
|
+
- [unreleased](https://github.com/dieter-medium/bidi2pdf/compare/v0.1.15..HEAD)
|
|
457
|
+
- [0.1.15](https://github.com/dieter-medium/bidi2pdf/compare/v0.1.14..v0.1.15)
|
|
458
|
+
- [0.1.14](https://github.com/dieter-medium/bidi2pdf/compare/v0.1.13..v0.1.14)
|
|
459
|
+
- [0.1.13](https://github.com/dieter-medium/bidi2pdf/compare/v0.1.12..v0.1.13)
|
|
460
|
+
- [0.1.12](https://github.com/dieter-medium/bidi2pdf/compare/v0.1.11..v0.1.12)
|
|
461
|
+
- [0.1.11](https://github.com/dieter-medium/bidi2pdf/compare/v0.1.10..v0.1.11)
|
|
462
|
+
- [0.1.10](https://github.com/dieter-medium/bidi2pdf/compare/v0.1.9..v0.1.10)
|
|
376
463
|
- [0.1.9](https://github.com/dieter-medium/bidi2pdf/compare/v0.1.8..v0.1.9)
|
|
377
464
|
- [0.1.8](https://github.com/dieter-medium/bidi2pdf/compare/v0.1.7..v0.1.8)
|
|
378
465
|
- [0.1.7](https://github.com/dieter-medium/bidi2pdf/compare/v0.1.6..v0.1.7)
|
data/README.md
CHANGED
|
@@ -24,11 +24,12 @@ Bidi2pdf gives you **precision, flexibility, and full control**.
|
|
|
24
24
|
7. [Architecture](#architecture)
|
|
25
25
|
8. [Docker](#docker)
|
|
26
26
|
9. [Configuration Options](#configuration-options)
|
|
27
|
-
10. [
|
|
28
|
-
11. [
|
|
29
|
-
12. [
|
|
30
|
-
13. [
|
|
31
|
-
14. [
|
|
27
|
+
10. [Programmatic Configuration](#programmatic-configuration)
|
|
28
|
+
11. [Rails Integration](#rails-integration)
|
|
29
|
+
12. [Test Helpers](#test-helpers)
|
|
30
|
+
13. [Development](#development)
|
|
31
|
+
14. [Contributing](#contributing)
|
|
32
|
+
15. [License](#license)
|
|
32
33
|
|
|
33
34
|
## ✨ Key Features
|
|
34
35
|
|
|
@@ -334,6 +335,68 @@ docker compose -f docker/docker-compose.yml down
|
|
|
334
335
|
|
|
335
336
|
---
|
|
336
337
|
|
|
338
|
+
## 🔧 Programmatic Configuration
|
|
339
|
+
|
|
340
|
+
Beyond the per-render CLI flags above, a few gem-wide defaults are set once via `Bidi2pdf.configure`:
|
|
341
|
+
|
|
342
|
+
```ruby
|
|
343
|
+
Bidi2pdf.configure do |config|
|
|
344
|
+
config.default_timeout = 60 # seconds - default BiDi command timeout
|
|
345
|
+
config.enable_default_logging_subscriber = true
|
|
346
|
+
config.log_truncate_limit = 200 # bytes - see below
|
|
347
|
+
config.chromedriver_log_level = "WARNING" # see below
|
|
348
|
+
end
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
| Setting | Default | Description |
|
|
352
|
+
|-------------------------------------|---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
353
|
+
| `default_timeout` | `60` | Default timeout (seconds) for BiDi commands that don't specify their own. |
|
|
354
|
+
| `enable_default_logging_subscriber` | `true` | Subscribes a default logger to the gem's internal instrumentation events. |
|
|
355
|
+
| `log_truncate_limit` | `200` | Max bytes kept when logging a value that can be large (e.g. a `data:` URL) - truncated at a byte, not character, boundary. |
|
|
356
|
+
| `chromedriver_log_level` | `nil` | ChromeDriver's own `--log-level` (`"ALL"`/`"INFO"`/`"WARNING"`/`"SEVERE"`). Unset mirrors `Bidi2pdf.logger.level`; set explicitly to quiet ChromeDriver's own (often very verbose) output independently of your app's log level. |
|
|
357
|
+
|
|
358
|
+
`Bidi2pdf.logger`, `Bidi2pdf.network_events_logger`, `Bidi2pdf.browser_console_logger`, and
|
|
359
|
+
`Bidi2pdf.notification_service` are also configurable in the same block, for more advanced
|
|
360
|
+
logging/instrumentation needs.
|
|
361
|
+
|
|
362
|
+
### Pre-warmed sessions (`Bidi2pdf::SessionWarmer`)
|
|
363
|
+
|
|
364
|
+
Optional. Keeps a few Chrome sessions started in the background so a render skips browser startup.
|
|
365
|
+
Every slot is still used for exactly one render and then discarded - isolation is the same as
|
|
366
|
+
launching a fresh Chrome per PDF.
|
|
367
|
+
|
|
368
|
+
```ruby
|
|
369
|
+
Bidi2pdf::SessionWarmer.configure do |c|
|
|
370
|
+
# warms c.size sessions right here, e.g. at boot
|
|
371
|
+
c.size = 2
|
|
372
|
+
c.max_idle_age = 300
|
|
373
|
+
# c.remote_browser_url = "http://remote-chrome:3000/session"
|
|
374
|
+
end
|
|
375
|
+
|
|
376
|
+
Bidi2pdf::SessionWarmer.with_tab do |tab|
|
|
377
|
+
tab.navigate_to(url)
|
|
378
|
+
tab.print("invoice.pdf")
|
|
379
|
+
end
|
|
380
|
+
|
|
381
|
+
Bidi2pdf::SessionWarmer.shutdown
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
| Setting | Default | Description |
|
|
385
|
+
|----------------------|-----------------------|-----------------------------------------------------------------------------------------------------------|
|
|
386
|
+
| `size` | `1` | Number of sessions kept warm. With none ready, a render starts its own session as usual - it never waits. |
|
|
387
|
+
| `max_idle_age` | `300` | Seconds a warm session may sit unused before it is retired and replaced. `nil` disables the limit. |
|
|
388
|
+
| `headless` | `true` | Run Chrome headless. |
|
|
389
|
+
| `chrome_args` | `DEFAULT_CHROME_ARGS` | Chrome launch arguments. |
|
|
390
|
+
| `remote_browser_url` | `nil` | Connect each slot to a remote chromedriver instead of starting a local one. |
|
|
391
|
+
|
|
392
|
+
> **Security note:** an idle warm session is an open, unauthenticated automation endpoint
|
|
393
|
+
> (chromedriver's port, Chrome's debugging port - loopback only for a local chromedriver) for as
|
|
394
|
+
> long as it waits. `max_idle_age` bounds that window; keep it set unless the process runs somewhere
|
|
395
|
+
> nothing else can reach those ports. With `remote_browser_url`, who can reach that endpoint on the
|
|
396
|
+
> network is what matters, exactly as it does without the warmer.
|
|
397
|
+
|
|
398
|
+
---
|
|
399
|
+
|
|
337
400
|
## 🚂 Rails Integration
|
|
338
401
|
|
|
339
402
|
Rails integration is available as an additional gem:
|
|
@@ -390,6 +453,18 @@ This also provides the helper methods:
|
|
|
390
453
|
With the environment variable `DISABLE_CHROME_SANDBOX` set to `true`, the container will run Chrome without
|
|
391
454
|
the sandbox. This is useful for CI environments where the sandbox may cause issues.
|
|
392
455
|
|
|
456
|
+
Container URLs (`session_url` and similar) are built from the Docker host's address plus the container's
|
|
457
|
+
mapped port. That address is resolved by the `testcontainers` gem — which already handles a `tcp:`/`ssh:`
|
|
458
|
+
`DOCKER_HOST`, a native local daemon, and a sibling container reaching the daemon over the bridge gateway —
|
|
459
|
+
falling back to `"localhost"` only if the gem can't resolve a host at all (a known gap in
|
|
460
|
+
`testcontainers-core` 0.2.0 when the test process itself runs in a container on a custom network).
|
|
461
|
+
|
|
462
|
+
To override the Docker host address explicitly, set `TC_HOST` (e.g. `TC_HOST=localhost` for a test process
|
|
463
|
+
running in a container that shares the Docker daemon's network namespace — true docker-in-docker). `TC_HOST`
|
|
464
|
+
is a single global setting for where the daemon's published ports are reachable; it is not the name, URL, or
|
|
465
|
+
IP of an individual container. To reach one container *from another* container, join the shared network and
|
|
466
|
+
address it by alias instead (see `nginx_url(use_alias: true)` in the spec helpers).
|
|
467
|
+
|
|
393
468
|
#### Example
|
|
394
469
|
|
|
395
470
|
```ruby
|
data/docker/Dockerfile
CHANGED
|
@@ -5,7 +5,7 @@ ENV DEBIAN_FRONTEND=noninteractive
|
|
|
5
5
|
# Install dependencies
|
|
6
6
|
RUN apt-get update && apt-get upgrade -y &&\
|
|
7
7
|
apt-get install -y --no-install-recommends\
|
|
8
|
-
chromium chromium-driver\
|
|
8
|
+
chromium chromium-driver chromium-sandbox \
|
|
9
9
|
libglib2.0-0 \
|
|
10
10
|
libnss3 \
|
|
11
11
|
libxss1 \
|
data/docker/Dockerfile.slim
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
FROM ruby:3.
|
|
1
|
+
FROM ruby:3.4-slim AS builder
|
|
2
2
|
|
|
3
3
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
4
4
|
|
|
@@ -31,7 +31,7 @@ RUN gem install ./bidi2pdf-*.gem
|
|
|
31
31
|
|
|
32
32
|
# Stage 2
|
|
33
33
|
|
|
34
|
-
FROM ruby:3.
|
|
34
|
+
FROM ruby:3.4-slim
|
|
35
35
|
|
|
36
36
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
37
37
|
|