Skip to content

Commit

Permalink
[Changed] Roll back playwright-core to v1.33.0
Browse files Browse the repository at this point in the history
- Major changes to how playwright-core is vendored will come with the
  next version bump.
- Restore `esbuild` approach to `mix assets.build`.
- Fix a number of quirks stemming from rebase mistakes.
  • Loading branch information
coreyti committed May 30, 2024
1 parent 87f6346 commit fab2462
Show file tree
Hide file tree
Showing 307 changed files with 59,461 additions and 98,429 deletions.
3 changes: 0 additions & 3 deletions assets/driver.js

This file was deleted.

39 changes: 12 additions & 27 deletions assets/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
},
"dependencies": {
"electron": "30.0.0",
"playwright": "1.44.0"
"playwright": "1.33.0"
}
}
22 changes: 22 additions & 0 deletions config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,25 @@ if config_env() == :test do
config :playwright_assets,
port: 4002
end

if config_env() == :dev do
config :esbuild,
version: "0.21.3",
cli: [
args: ~w(
driver=./node_modules/playwright/cli.js
--bundle
--platform=node
--format=cjs
--target=es2016
--outdir=../priv/static
--external:*.png
--external:*/loader
--external:@playwright/test/*
),
cd: Path.expand("../assets", __DIR__)
]

# NOTE that the following are not actually copied and made available:
# - playwright-core/lib/server/electron/loader.js
end
7 changes: 2 additions & 5 deletions lib/playwright/browser_context.ex
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,6 @@ defmodule Playwright.BrowserContext do
{:ok, _} ->
:ok

{:ok, _} ->
:ok

{:error, %Channel.Error{message: "Target page, context or browser has been closed"}} ->
:ok
end
Expand Down Expand Up @@ -615,8 +612,8 @@ defmodule Playwright.BrowserContext do
# Do not love this; See Page.on_route/2 (which is an exact copy of this) for why.
defp on_route(context, %{params: %{route: %{request: request} = route} = _params} = _event) do
Enum.reduce_while(context.routes, [], fn handler, acc ->
catalog = Playwright.Channel.Session.catalog(context.session)
request = Playwright.Channel.Catalog.get(catalog, request.guid)
catalog = Channel.Session.catalog(context.session)
request = Channel.Catalog.get(catalog, request.guid)

if Helpers.RouteHandler.matches(handler, request.url) do
Helpers.RouteHandler.handle(handler, %{request: request, route: route})
Expand Down
4 changes: 2 additions & 2 deletions lib/playwright/page.ex
Original file line number Diff line number Diff line change
Expand Up @@ -679,8 +679,8 @@ defmodule Playwright.Page do
# dirty for API resource implementations to be reaching into Catalog.
defp on_route(page, %{params: %{route: %{request: request} = route} = _params} = _event) do
Enum.reduce_while(page.routes, [], fn handler, acc ->
catalog = Playwright.Channel.Session.catalog(page.session)
request = Playwright.Channel.Catalog.get(catalog, request.guid)
catalog = Channel.Session.catalog(page.session)
request = Channel.Catalog.get(catalog, request.guid)

if Helpers.RouteHandler.matches(handler, request.url) do
Helpers.RouteHandler.handle(handler, %{request: request, route: route})
Expand Down
8 changes: 4 additions & 4 deletions lib/playwright/route.ex
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ defmodule Playwright.Route do

def continue(%Route{session: session} = route, options) do
# HACK to deal with changes in v1.33.0
catalog = Playwright.Channel.Session.catalog(session)
request = Playwright.Channel.Catalog.get(catalog, route.request.guid)
catalog = Channel.Session.catalog(session)
request = Channel.Catalog.get(catalog, route.request.guid)
params = Map.merge(options, %{request_url: request.url})
Channel.post(session, {:guid, route.guid}, :continue, params)
end
Expand All @@ -44,8 +44,8 @@ defmodule Playwright.Route do
length = String.length(body)

# HACK to deal with changes in v1.33.0
catalog = Playwright.Channel.Session.catalog(session)
request = Playwright.Channel.Catalog.get(catalog, route.request.guid)
catalog = Channel.Session.catalog(session)
request = Channel.Catalog.get(catalog, route.request.guid)

params = %{
body: body,
Expand Down
17 changes: 12 additions & 5 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ defmodule Playwright.MixProject do
{:cowlib, "~> 2.7.0"},
{:credo, "~> 1.6", only: [:dev, :test], runtime: false},
{:dialyxir, "~> 1.1", only: [:dev, :test], runtime: false},
{:esbuild, "~> 0.8.1", runtime: Mix.env() == :dev},
{:ex_doc, "~> 0.25", only: :dev, runtime: false},
{:gun, "~> 1.3.3"},
{:jason, "~> 1.2"},
Expand Down Expand Up @@ -156,14 +157,20 @@ defmodule Playwright.MixProject do
]
end

# NOTES:
# - the `api.json` file is created to satisfy a `require('../../api.json')`
# call found in Playwright's `driver.js` file. We don't actually have any
# use for the "print-api-json" command, so an empty `api.json` works.
defp aliases do
[
"assets.build": [
"cmd rm -rf priv/static",
"cmd mkdir -p priv/static/node_modules",
"cmd cp -r assets/node_modules/playwright-core priv/static/node_modules",
"cmd cp -r assets/driver.js priv/static"
]
"cmd rm -rf assets/node_modules",
"cmd rm -rf priv/static",
"cmd npm install --prefix assets",
"cmd echo '{}' > assets/node_modules/playwright-core/api.json",
"esbuild cli"
],
"assets.watch": ["esbuild module --watch"]
]
end
end
2 changes: 2 additions & 0 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
%{
"bunt": {:hex, :bunt, "1.0.0", "081c2c665f086849e6d57900292b3a161727ab40431219529f13c4ddcf3e7a44", [:mix], [], "hexpm", "dc5f86aa08a5f6fa6b8096f0735c4e76d54ae5c9fa2c143e5a1fc7c1cd9bb6b5"},
"castore": {:hex, :castore, "1.0.7", "b651241514e5f6956028147fe6637f7ac13802537e895a724f90bf3e36ddd1dd", [:mix], [], "hexpm", "da7785a4b0d2a021cd1292a60875a784b6caef71e76bf4917bdee1f390455cf5"},
"cowboy": {:hex, :cowboy, "2.6.3", "99aa50e94e685557cad82e704457336a453d4abcb77839ad22dbe71f311fcc06", [:rebar3], [{:cowlib, "~> 2.7.3", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "~> 1.7.1", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "e5580029080f3f1ad17436fb97b0d5ed2ed4e4815a96bac36b5a992e20f58db6"},
"cowlib": {:hex, :cowlib, "2.7.3", "a7ffcd0917e6d50b4d5fb28e9e2085a0ceb3c97dea310505f7460ff5ed764ce9", [:rebar3], [], "hexpm", "1e1a3d176d52daebbecbbcdfd27c27726076567905c2a9d7398c54da9d225761"},
"credo": {:hex, :credo, "1.7.6", "b8f14011a5443f2839b04def0b252300842ce7388f3af177157c86da18dfbeea", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "146f347fb9f8cbc5f7e39e3f22f70acbef51d441baa6d10169dd604bfbc55296"},
"dialyxir": {:hex, :dialyxir, "1.4.3", "edd0124f358f0b9e95bfe53a9fcf806d615d8f838e2202a9f430d59566b6b53b", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "bf2cfb75cd5c5006bec30141b131663299c661a864ec7fbbc72dfa557487a986"},
"earmark_parser": {:hex, :earmark_parser, "1.4.39", "424642f8335b05bb9eb611aa1564c148a8ee35c9c8a8bba6e129d51a3e3c6769", [:mix], [], "hexpm", "06553a88d1f1846da9ef066b87b57c6f605552cfbe40d20bd8d59cc6bde41944"},
"erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"},
"esbuild": {:hex, :esbuild, "0.8.1", "0cbf919f0eccb136d2eeef0df49c4acf55336de864e63594adcea3814f3edf41", [:mix], [{:castore, ">= 0.0.0", [hex: :castore, repo: "hexpm", optional: false]}, {:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "25fc876a67c13cb0a776e7b5d7974851556baeda2085296c14ab48555ea7560f"},
"ex_doc": {:hex, :ex_doc, "0.32.2", "f60bbeb6ccbe75d005763e2a328e6f05e0624232f2393bc693611c2d3ae9fa0e", [:mix], [{:earmark_parser, "~> 1.4.39", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "a4480305cdfe7fdfcbb77d1092c76161626d9a7aa4fb698aee745996e34602df"},
"file_system": {:hex, :file_system, "1.0.0", "b689cc7dcee665f774de94b5a832e578bd7963c8e637ef940cd44327db7de2cd", [:mix], [], "hexpm", "6752092d66aec5a10e662aefeed8ddb9531d79db0bc145bb8c40325ca1d8536d"},
"gun": {:hex, :gun, "1.3.3", "cf8b51beb36c22b9c8df1921e3f2bc4d2b1f68b49ad4fbc64e91875aa14e16b4", [:rebar3], [{:cowlib, "~> 2.7.0", [hex: :cowlib, repo: "hexpm", optional: false]}], "hexpm", "3106ce167f9c9723f849e4fb54ea4a4d814e3996ae243a1c828b256e749041e0"},
Expand Down
Loading

0 comments on commit fab2462

Please sign in to comment.