Skip to content

Commit 1c9e28b

Browse files
authored
Merge pull request #44 from ghivert/feat/ugprade-to-otp-1
Ugprade to `gleam_otp` 1.0.0
2 parents 539f311 + 388c66d commit 1c9e28b

File tree

39 files changed

+721
-775
lines changed

39 files changed

+721
-775
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- uses: erlef/setup-beam@v1
1616
with:
1717
otp-version: '27.0.1'
18-
gleam-version: '1.10.0'
18+
gleam-version: '1.11.1'
1919
rebar3-version: '3'
2020
# elixir-version: "1.15.4"
2121
- run: gleam deps download
@@ -34,7 +34,7 @@ jobs:
3434
- uses: erlef/setup-beam@v1
3535
with:
3636
otp-version: '27.0.1'
37-
gleam-version: '1.10.0'
37+
gleam-version: '1.11.1'
3838
rebar3-version: '3'
3939
# elixir-version: "1.15.4"
4040
- run: gleam deps download
@@ -53,7 +53,7 @@ jobs:
5353
- uses: erlef/setup-beam@v1
5454
with:
5555
otp-version: '27.0.1'
56-
gleam-version: '1.10.0'
56+
gleam-version: '1.11.1'
5757
rebar3-version: '3'
5858
# elixir-version: "1.15.4"
5959
- run: gleam deps download
@@ -72,7 +72,7 @@ jobs:
7272
- uses: erlef/setup-beam@v1
7373
with:
7474
otp-version: '27.0.1'
75-
gleam-version: '1.10.0'
75+
gleam-version: '1.11.1'
7676
rebar3-version: '3'
7777
# elixir-version: "1.15.4"
7878
- run: gleam deps download

e2e/redraw_example/manifest.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
# You typically do not need to edit this file
33

44
packages = [
5-
{ name = "gleam_erlang", version = "0.34.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "0C38F2A128BAA0CEF17C3000BD2097EB80634E239CE31A86400C4416A5D0FDCC" },
5+
{ name = "gleam_erlang", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "7E6A5234F927C4B24F8054AB1E4572206C41F9E6D5C6C02273CB7531E7E5CED0" },
66
{ name = "gleam_javascript", version = "0.13.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_javascript", source = "hex", outer_checksum = "F98328FCF573DA6F3A35D7F6CB3F9FF19FD5224CCBA9151FCBEAA0B983AF2F58" },
7-
{ name = "gleam_otp", version = "0.16.1", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_stdlib"], otp_app = "gleam_otp", source = "hex", outer_checksum = "50DA1539FC8E8FA09924EB36A67A2BBB0AD6B27BCDED5A7EF627057CF69D035E" },
8-
{ name = "gleam_stdlib", version = "0.59.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "F8FEE9B35797301994B81AF75508CF87C328FE1585558B0FFD188DC2B32EAA95" },
9-
{ name = "gleeunit", version = "1.3.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "A7DD6C07B7DA49A6E28796058AA89E651D233B357D5607006D70619CD89DAAAB" },
7+
{ name = "gleam_otp", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_stdlib"], otp_app = "gleam_otp", source = "hex", outer_checksum = "7020E652D18F9ABAC9C877270B14160519FA0856EE80126231C505D719AD68DA" },
8+
{ name = "gleam_stdlib", version = "0.60.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "621D600BB134BC239CB2537630899817B1A42E60A1D46C5E9F3FAE39F88C800B" },
9+
{ name = "gleeunit", version = "1.5.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "D33B7736CF0766ED3065F64A1EBB351E72B2E8DE39BAFC8ADA0E35E92A6A934F" },
1010
{ name = "murmur3a", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "murmur3a", source = "hex", outer_checksum = "DAA714CEF379915D0F718BC410389245AA8ABFB6F48C73ADB9F011B009F28893" },
1111
{ name = "redraw", version = "2.0.2", build_tools = ["gleam"], requirements = ["gleam_javascript", "gleam_stdlib"], otp_app = "redraw", source = "hex", outer_checksum = "F95A1F4691A3CC2FD1FD7638178D7912AC5FB0E521C59970304E9DE4E739E40D" },
1212
{ name = "redraw_dom", version = "2.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "redraw"], otp_app = "redraw_dom", source = "hex", outer_checksum = "8318DA1E428B349177C444DDC2FA9AE0D33E0DD0CC5A55B82F030811FFD69EA4" },
1313
{ name = "shared_styles", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "sketch"], source = "local", path = "../shared_styles" },
14-
{ name = "sketch", version = "4.0.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_otp", "gleam_stdlib", "murmur3a"], source = "local", path = "../../sketch" },
14+
{ name = "sketch", version = "4.2.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_otp", "gleam_stdlib", "murmur3a"], source = "local", path = "../../sketch" },
1515
{ name = "sketch_redraw", version = "2.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "redraw", "redraw_dom", "sketch"], source = "local", path = "../../sketch_redraw" },
1616
]
1717

e2e/server_components/gleam.toml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ name = "server_components"
22
version = "1.0.0"
33

44
[dependencies]
5-
gleam_stdlib = "~> 0.34 or ~> 1.0"
6-
sketch = {path = "../../sketch"}
7-
sketch_lustre = {path = "../../sketch_lustre"}
8-
gleam_http = "~> 3.6"
9-
mist = ">= 4.0.0 and < 5.0.0"
5+
gleam_erlang = ">= 1.0.0 and < 2.0.0"
6+
gleam_http = ">= 4.0.0 and < 5.0.0"
7+
gleam_json = ">= 3.0.0 and < 4.0.0"
8+
gleam_otp = ">= 1.0.0 and < 2.0.0"
9+
gleam_stdlib = ">= 0.34.0 and < 1.0.0"
1010
lustre = ">= 5.0.0 and < 6.0.0"
11+
mist = ">= 5.0.0 and < 6.0.0"
1112
shared_view = {path = "../shared_view"}
12-
gleam_otp = ">= 0.13.0 and < 1.0.0"
13-
gleam_json = ">= 2.0.0 and < 3.0.0"
14-
gleam_erlang = ">= 0.28.0 and < 1.0.0"
13+
sketch = {path = "../../sketch"}
14+
sketch_lustre = {path = "../../sketch_lustre"}
1515

1616
[dev-dependencies]
17-
gleeunit = "~> 1.0"
17+
gleeunit = ">= 1.5.0 and < 2.0.0"

e2e/server_components/manifest.toml

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,37 @@
33

44
packages = [
55
{ name = "gleam_crypto", version = "1.5.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_crypto", source = "hex", outer_checksum = "917BC8B87DBD584830E3B389CBCAB140FFE7CB27866D27C6D0FB87A9ECF35602" },
6-
{ name = "gleam_erlang", version = "0.34.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "0C38F2A128BAA0CEF17C3000BD2097EB80634E239CE31A86400C4416A5D0FDCC" },
7-
{ name = "gleam_http", version = "3.7.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_http", source = "hex", outer_checksum = "8A70D2F70BB7CFEB5DF048A2183FFBA91AF6D4CF5798504841744A16999E33D2" },
8-
{ name = "gleam_json", version = "2.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_json", source = "hex", outer_checksum = "C55C5C2B318533A8072D221C5E06E5A75711C129E420DD1CE463342106012E5D" },
9-
{ name = "gleam_otp", version = "0.16.1", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_stdlib"], otp_app = "gleam_otp", source = "hex", outer_checksum = "50DA1539FC8E8FA09924EB36A67A2BBB0AD6B27BCDED5A7EF627057CF69D035E" },
10-
{ name = "gleam_stdlib", version = "0.59.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "F8FEE9B35797301994B81AF75508CF87C328FE1585558B0FFD188DC2B32EAA95" },
6+
{ name = "gleam_erlang", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "7E6A5234F927C4B24F8054AB1E4572206C41F9E6D5C6C02273CB7531E7E5CED0" },
7+
{ name = "gleam_http", version = "4.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_http", source = "hex", outer_checksum = "0A62451FC85B98062E0907659D92E6A89F5F3C0FBE4AB8046C99936BF6F91DBC" },
8+
{ name = "gleam_json", version = "3.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_json", source = "hex", outer_checksum = "5BA154440B22D9800955B1AB854282FA37B97F30F409D76B0824D0A60C934188" },
9+
{ name = "gleam_otp", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_stdlib"], otp_app = "gleam_otp", source = "hex", outer_checksum = "7020E652D18F9ABAC9C877270B14160519FA0856EE80126231C505D719AD68DA" },
10+
{ name = "gleam_stdlib", version = "0.60.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "621D600BB134BC239CB2537630899817B1A42E60A1D46C5E9F3FAE39F88C800B" },
1111
{ name = "gleam_yielder", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_yielder", source = "hex", outer_checksum = "8E4E4ECFA7982859F430C57F549200C7749823C106759F4A19A78AEA6687717A" },
12-
{ name = "gleeunit", version = "1.3.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "A7DD6C07B7DA49A6E28796058AA89E651D233B357D5607006D70619CD89DAAAB" },
13-
{ name = "glisten", version = "7.0.1", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_otp", "gleam_stdlib", "logging", "telemetry"], otp_app = "glisten", source = "hex", outer_checksum = "1A53CF9FB3231A93FF7F1BD519A43DC968C1722F126CDD278403A78725FC5189" },
14-
{ name = "gramps", version = "3.0.1", build_tools = ["gleam"], requirements = ["gleam_crypto", "gleam_erlang", "gleam_http", "gleam_stdlib"], otp_app = "gramps", source = "hex", outer_checksum = "59194B3980110B403EE6B75330DB82CDE05FC8138491C2EAEACBC7AAEF30B2E8" },
12+
{ name = "gleeunit", version = "1.5.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "D33B7736CF0766ED3065F64A1EBB351E72B2E8DE39BAFC8ADA0E35E92A6A934F" },
13+
{ name = "glisten", version = "8.0.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_otp", "gleam_stdlib", "logging", "telemetry"], otp_app = "glisten", source = "hex", outer_checksum = "17B3CC2E5093662404DDCF7C837D1CA093E5C436CE5F8A532F8EA0D12B5B2172" },
14+
{ name = "gramps", version = "3.0.2", build_tools = ["gleam"], requirements = ["gleam_crypto", "gleam_erlang", "gleam_http", "gleam_stdlib"], otp_app = "gramps", source = "hex", outer_checksum = "D213EEE41B467853E1FB9AAC204D2CB1AB301C84E8F7C1DF3307128221AB53BF" },
1515
{ name = "houdini", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "houdini", source = "hex", outer_checksum = "5BA517E5179F132F0471CB314F27FE210A10407387DA1EA4F6FD084F74469FC2" },
1616
{ name = "hpack_erl", version = "0.3.0", build_tools = ["rebar3"], requirements = [], otp_app = "hpack", source = "hex", outer_checksum = "D6137D7079169D8C485C6962DFE261AF5B9EF60FBC557344511C1E65E3D95FB0" },
1717
{ name = "logging", version = "1.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "logging", source = "hex", outer_checksum = "1098FBF10B54B44C2C7FDF0B01C1253CAFACDACABEFB4B0D027803246753E06D" },
18-
{ name = "lustre", version = "5.0.3", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_json", "gleam_otp", "gleam_stdlib", "houdini"], otp_app = "lustre", source = "hex", outer_checksum = "0BB69D69A9E75E675AA2C32A4A0E5086041D037829FC8AD385BA6A59E45A60A2" },
19-
{ name = "mist", version = "4.0.6", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_http", "gleam_otp", "gleam_stdlib", "gleam_yielder", "glisten", "gramps", "hpack_erl", "logging"], otp_app = "mist", source = "hex", outer_checksum = "ED319E5A7F2056E08340B6976EA5E717F3C3BB36056219AF826D280D9C077952" },
18+
{ name = "lustre", version = "5.2.1", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_json", "gleam_otp", "gleam_stdlib", "houdini"], otp_app = "lustre", source = "hex", outer_checksum = "DCD121F8E6B7E179B27D9A8AEB6C828D8380E26DF2E16D078511EDAD1CA9F2A7" },
19+
{ name = "mist", version = "5.0.1", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_http", "gleam_otp", "gleam_stdlib", "gleam_yielder", "glisten", "gramps", "hpack_erl", "logging"], otp_app = "mist", source = "hex", outer_checksum = "6926B37B7124F2E7CFE4B1A1046C127B2484E0C19D5ABAAEC10872E0CDA1F9AB" },
2020
{ name = "murmur3a", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "murmur3a", source = "hex", outer_checksum = "DAA714CEF379915D0F718BC410389245AA8ABFB6F48C73ADB9F011B009F28893" },
2121
{ name = "shared_styles", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "sketch"], source = "local", path = "../shared_styles" },
2222
{ name = "shared_view", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "lustre", "shared_styles", "sketch", "sketch_lustre"], source = "local", path = "../shared_view" },
23-
{ name = "sketch", version = "4.1.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_otp", "gleam_stdlib", "murmur3a"], source = "local", path = "../../sketch" },
24-
{ name = "sketch_lustre", version = "3.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "lustre", "sketch"], source = "local", path = "../../sketch_lustre" },
23+
{ name = "sketch", version = "4.2.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_otp", "gleam_stdlib", "murmur3a"], source = "local", path = "../../sketch" },
24+
{ name = "sketch_lustre", version = "3.1.1", build_tools = ["gleam"], requirements = ["gleam_stdlib", "lustre", "sketch"], source = "local", path = "../../sketch_lustre" },
2525
{ name = "telemetry", version = "1.3.0", build_tools = ["rebar3"], requirements = [], otp_app = "telemetry", source = "hex", outer_checksum = "7015FC8919DBE63764F4B4B87A95B7C0996BD539E0D499BE6EC9D7F3875B79E6" },
2626
]
2727

2828
[requirements]
29-
gleam_erlang = { version = ">= 0.28.0 and < 1.0.0" }
30-
gleam_http = { version = "~> 3.6" }
31-
gleam_json = { version = ">= 2.0.0 and < 3.0.0" }
32-
gleam_otp = { version = ">= 0.13.0 and < 1.0.0" }
33-
gleam_stdlib = { version = "~> 0.34 or ~> 1.0" }
34-
gleeunit = { version = "~> 1.0" }
29+
gleam_erlang = { version = ">= 1.0.0 and < 2.0.0" }
30+
gleam_http = { version = ">= 4.0.0 and < 5.0.0" }
31+
gleam_json = { version = ">= 3.0.0 and < 4.0.0" }
32+
gleam_otp = { version = ">= 1.0.0 and < 2.0.0" }
33+
gleam_stdlib = { version = ">= 0.34.0 and < 1.0.0" }
34+
gleeunit = { version = ">= 1.5.0 and < 2.0.0" }
3535
lustre = { version = ">= 5.0.0 and < 6.0.0" }
36-
mist = { version = ">= 4.0.0 and < 5.0.0" }
36+
mist = { version = ">= 5.0.0 and < 6.0.0" }
3737
shared_view = { path = "../shared_view" }
3838
sketch = { path = "../../sketch" }
3939
sketch_lustre = { path = "../../sketch_lustre" }

e2e/server_components/src/server_components.gleam

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
// IMPORTS ---------------------------------------------------------------------
22

33
import gleam/bytes_tree
4-
import gleam/erlang
4+
import gleam/erlang/application
55
import gleam/erlang/process.{type Selector, type Subject}
6-
import gleam/function
76
import gleam/http/request.{type Request}
87
import gleam/http/response.{type Response}
98
import gleam/json
109
import gleam/option.{type Option, None, Some}
11-
import gleam/otp/actor
1210
import gleam/result
1311
import lustre
1412
import lustre/attribute
@@ -44,7 +42,7 @@ pub fn main() {
4442
|> mist.new
4543
|> mist.bind("localhost")
4644
|> mist.port(1234)
47-
|> mist.start_http
45+
|> mist.start
4846

4947
process.sleep_forever()
5048
}
@@ -85,7 +83,7 @@ fn serve_html() -> Response(ResponseData) {
8583
]),
8684
]),
8785
html.body(
88-
[attribute.styles([#("margin", "0"), #("font-family", "Zain")])],
86+
[attribute.styles([#("max-width", "32rem"), #("margin", "3rem auto")])],
8987
// If you're using Lustre to render your HTML like we are here, or if
9088
// you're also running Lustre in the browser, youcan render the
9189
// `<lustre-server-component />` element using `server_component.element`.
@@ -115,8 +113,8 @@ fn serve_runtime() -> Response(ResponseData) {
115113
//
116114
// Lustre includes both a standard and a minified version of the runtime. The
117115
// minified bundle clocks in at just 10kB before compression!
118-
let assert Ok(lustre_priv) = erlang.priv_directory("lustre")
119-
let file_path = lustre_priv <> "/static/lustre-server-component.min.mjs"
116+
let assert Ok(lustre_priv) = application.priv_directory("lustre")
117+
let file_path = lustre_priv <> "/static/lustre-server-component.mjs"
120118

121119
case mist.send_file(file_path, offset: 0, limit: None) {
122120
Ok(file) ->
@@ -161,6 +159,7 @@ fn init_counter_socket(_) -> CounterSocketInit {
161159
|> result.map(sketch.global(_, host_class()))
162160

163161
let counter = shared_view.app(stylesheet)
162+
164163
// Rather than calling `lustre.start` as we do in the client, we construct the
165164
// Lustre runtime by calling `lustre.start_server_component`. This is the same
166165
// `Runtime` type we get from `lustre.start` but this function doesn't need a
@@ -174,7 +173,7 @@ fn init_counter_socket(_) -> CounterSocketInit {
174173
let self = process.new_subject()
175174
let selector =
176175
process.new_selector()
177-
|> process.selecting(self, function.identity)
176+
|> process.select(self)
178177

179178
// Calling `register_subject` is how the runtime knows to send messages to
180179
// this process when it wants to communicate with the client. In Lustre, server
@@ -189,9 +188,9 @@ fn init_counter_socket(_) -> CounterSocketInit {
189188

190189
fn loop_counter_socket(
191190
state: CounterSocket,
192-
connection: mist.WebsocketConnection,
193191
message: mist.WebsocketMessage(CounterSocketMessage),
194-
) {
192+
connection: mist.WebsocketConnection,
193+
) -> mist.Next(CounterSocket, CounterSocketMessage) {
195194
case message {
196195
// The client runtime will send us JSON-encoded text frames that we need to
197196
// decode and pass to the server component runtime.
@@ -203,11 +202,11 @@ fn loop_counter_socket(
203202
Error(_) -> Nil
204203
}
205204

206-
actor.continue(state)
205+
mist.continue(state)
207206
}
208207

209208
mist.Binary(_) -> {
210-
actor.continue(state)
209+
mist.continue(state)
211210
}
212211

213212
// We hit this case when the server component runtime sends us a message that
@@ -216,21 +215,19 @@ fn loop_counter_socket(
216215
// are encoded and sent to the client.
217216
mist.Custom(client_message) -> {
218217
let json = server_component.client_message_to_json(client_message)
219-
case mist.send_text_frame(connection, json.to_string(json)) {
220-
Ok(_) -> actor.continue(state)
221-
Error(_) -> {
222-
close_counter_socket(state)
223-
actor.Stop(process.Normal)
224-
}
225-
}
218+
let assert Ok(_) = mist.send_text_frame(connection, json.to_string(json))
219+
220+
mist.continue(state)
226221
}
227222

228223
mist.Closed | mist.Shutdown -> {
229224
// The server component runtime sets up a process monitor that can clean
230225
// up if our socket process dies or is killed, but it's good practice to
231226
// clean up ourselves if we get the opportunity.
232-
close_counter_socket(state)
233-
actor.Stop(process.Normal)
227+
server_component.deregister_subject(state.self)
228+
|> lustre.send(to: state.component)
229+
230+
mist.stop()
234231
}
235232
}
236233
}

0 commit comments

Comments
 (0)