Skip to content

Commit fab2462

Browse files
committed
[Changed] Roll back playwright-core to v1.33.0
- 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.
1 parent 87f6346 commit fab2462

File tree

307 files changed

+59461
-98429
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

307 files changed

+59461
-98429
lines changed

assets/driver.js

-3
This file was deleted.

assets/package-lock.json

+12-27
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
},
55
"dependencies": {
66
"electron": "30.0.0",
7-
"playwright": "1.44.0"
7+
"playwright": "1.33.0"
88
}
99
}

config/config.exs

+22
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,25 @@ if config_env() == :test do
1515
config :playwright_assets,
1616
port: 4002
1717
end
18+
19+
if config_env() == :dev do
20+
config :esbuild,
21+
version: "0.21.3",
22+
cli: [
23+
args: ~w(
24+
driver=./node_modules/playwright/cli.js
25+
--bundle
26+
--platform=node
27+
--format=cjs
28+
--target=es2016
29+
--outdir=../priv/static
30+
--external:*.png
31+
--external:*/loader
32+
--external:@playwright/test/*
33+
),
34+
cd: Path.expand("../assets", __DIR__)
35+
]
36+
37+
# NOTE that the following are not actually copied and made available:
38+
# - playwright-core/lib/server/electron/loader.js
39+
end

lib/playwright/browser_context.ex

+2-5
Original file line numberDiff line numberDiff line change
@@ -352,9 +352,6 @@ defmodule Playwright.BrowserContext do
352352
{:ok, _} ->
353353
:ok
354354

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

621618
if Helpers.RouteHandler.matches(handler, request.url) do
622619
Helpers.RouteHandler.handle(handler, %{request: request, route: route})

lib/playwright/page.ex

+2-2
Original file line numberDiff line numberDiff line change
@@ -679,8 +679,8 @@ defmodule Playwright.Page do
679679
# dirty for API resource implementations to be reaching into Catalog.
680680
defp on_route(page, %{params: %{route: %{request: request} = route} = _params} = _event) do
681681
Enum.reduce_while(page.routes, [], fn handler, acc ->
682-
catalog = Playwright.Channel.Session.catalog(page.session)
683-
request = Playwright.Channel.Catalog.get(catalog, request.guid)
682+
catalog = Channel.Session.catalog(page.session)
683+
request = Channel.Catalog.get(catalog, request.guid)
684684

685685
if Helpers.RouteHandler.matches(handler, request.url) do
686686
Helpers.RouteHandler.handle(handler, %{request: request, route: route})

lib/playwright/route.ex

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ defmodule Playwright.Route do
2121

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

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

5050
params = %{
5151
body: body,

mix.exs

+12-5
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ defmodule Playwright.MixProject do
4949
{:cowlib, "~> 2.7.0"},
5050
{:credo, "~> 1.6", only: [:dev, :test], runtime: false},
5151
{:dialyxir, "~> 1.1", only: [:dev, :test], runtime: false},
52+
{:esbuild, "~> 0.8.1", runtime: Mix.env() == :dev},
5253
{:ex_doc, "~> 0.25", only: :dev, runtime: false},
5354
{:gun, "~> 1.3.3"},
5455
{:jason, "~> 1.2"},
@@ -156,14 +157,20 @@ defmodule Playwright.MixProject do
156157
]
157158
end
158159

160+
# NOTES:
161+
# - the `api.json` file is created to satisfy a `require('../../api.json')`
162+
# call found in Playwright's `driver.js` file. We don't actually have any
163+
# use for the "print-api-json" command, so an empty `api.json` works.
159164
defp aliases do
160165
[
161166
"assets.build": [
162-
"cmd rm -rf priv/static",
163-
"cmd mkdir -p priv/static/node_modules",
164-
"cmd cp -r assets/node_modules/playwright-core priv/static/node_modules",
165-
"cmd cp -r assets/driver.js priv/static"
166-
]
167+
"cmd rm -rf assets/node_modules",
168+
"cmd rm -rf priv/static",
169+
"cmd npm install --prefix assets",
170+
"cmd echo '{}' > assets/node_modules/playwright-core/api.json",
171+
"esbuild cli"
172+
],
173+
"assets.watch": ["esbuild module --watch"]
167174
]
168175
end
169176
end

mix.lock

+2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
%{
22
"bunt": {:hex, :bunt, "1.0.0", "081c2c665f086849e6d57900292b3a161727ab40431219529f13c4ddcf3e7a44", [:mix], [], "hexpm", "dc5f86aa08a5f6fa6b8096f0735c4e76d54ae5c9fa2c143e5a1fc7c1cd9bb6b5"},
3+
"castore": {:hex, :castore, "1.0.7", "b651241514e5f6956028147fe6637f7ac13802537e895a724f90bf3e36ddd1dd", [:mix], [], "hexpm", "da7785a4b0d2a021cd1292a60875a784b6caef71e76bf4917bdee1f390455cf5"},
34
"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"},
45
"cowlib": {:hex, :cowlib, "2.7.3", "a7ffcd0917e6d50b4d5fb28e9e2085a0ceb3c97dea310505f7460ff5ed764ce9", [:rebar3], [], "hexpm", "1e1a3d176d52daebbecbbcdfd27c27726076567905c2a9d7398c54da9d225761"},
56
"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"},
67
"dialyxir": {:hex, :dialyxir, "1.4.3", "edd0124f358f0b9e95bfe53a9fcf806d615d8f838e2202a9f430d59566b6b53b", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "bf2cfb75cd5c5006bec30141b131663299c661a864ec7fbbc72dfa557487a986"},
78
"earmark_parser": {:hex, :earmark_parser, "1.4.39", "424642f8335b05bb9eb611aa1564c148a8ee35c9c8a8bba6e129d51a3e3c6769", [:mix], [], "hexpm", "06553a88d1f1846da9ef066b87b57c6f605552cfbe40d20bd8d59cc6bde41944"},
89
"erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"},
10+
"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"},
911
"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"},
1012
"file_system": {:hex, :file_system, "1.0.0", "b689cc7dcee665f774de94b5a832e578bd7963c8e637ef940cd44327db7de2cd", [:mix], [], "hexpm", "6752092d66aec5a10e662aefeed8ddb9531d79db0bc145bb8c40325ca1d8536d"},
1113
"gun": {:hex, :gun, "1.3.3", "cf8b51beb36c22b9c8df1921e3f2bc4d2b1f68b49ad4fbc64e91875aa14e16b4", [:rebar3], [{:cowlib, "~> 2.7.0", [hex: :cowlib, repo: "hexpm", optional: false]}], "hexpm", "3106ce167f9c9723f849e4fb54ea4a4d814e3996ae243a1c828b256e749041e0"},

0 commit comments

Comments
 (0)