diff options
-rw-r--r-- | gleam.toml | 1 | ||||
-rwxr-xr-x | priv/bin/esbuild | bin | 0 -> 9756978 bytes | |||
-rw-r--r-- | src/lustre.gleam | 2 | ||||
-rw-r--r-- | src/lustre/internals/runtime.gleam (renamed from src/lustre/runtime.gleam) | 0 | ||||
-rw-r--r-- | src/lustre/server.gleam | 36 | ||||
-rw-r--r-- | test/lustre_test.gleam | 2 |
6 files changed, 20 insertions, 21 deletions
@@ -13,7 +13,6 @@ gleam = ">= 0.33.0" internal_modules = [ "lustre/internals", "lustre/internals/*", - "lustre/runtime", "lustre/try", ] diff --git a/priv/bin/esbuild b/priv/bin/esbuild Binary files differnew file mode 100755 index 0000000..8c5cb93 --- /dev/null +++ b/priv/bin/esbuild diff --git a/src/lustre.gleam b/src/lustre.gleam index 77e0bb5..6c58c85 100644 --- a/src/lustre.gleam +++ b/src/lustre.gleam @@ -89,7 +89,7 @@ import gleam/otp/actor.{type StartError} import gleam/result import lustre/effect.{type Effect} import lustre/element.{type Element, type Patch} -import lustre/runtime +import lustre/internals/runtime // TYPES ----------------------------------------------------------------------- diff --git a/src/lustre/runtime.gleam b/src/lustre/internals/runtime.gleam index 646baf4..646baf4 100644 --- a/src/lustre/runtime.gleam +++ b/src/lustre/internals/runtime.gleam diff --git a/src/lustre/server.gleam b/src/lustre/server.gleam index cf6ebe6..1f7fef6 100644 --- a/src/lustre/server.gleam +++ b/src/lustre/server.gleam @@ -10,12 +10,12 @@ import lustre/attribute.{type Attribute, attribute} import lustre/effect.{type Effect} import lustre/element.{type Element, element} import lustre/internals/constants -import lustre/runtime.{type Action, Attrs, Event, SetSelector} +import lustre/internals/runtime.{type Action, Attrs, Event, SetSelector} // ELEMENTS -------------------------------------------------------------------- -/// A simple wrapper to render a `<lustre-server-component>` element. -/// +/// A simple wrapper to render a `<lustre-server-component>` element. +/// pub fn component(attrs: List(Attribute(msg))) -> Element(msg) { element("lustre-server-component", attrs, []) } @@ -24,9 +24,9 @@ pub fn component(attrs: List(Attribute(msg))) -> Element(msg) { /// The `route` attribute should always be included on a [`component`](#component) /// to tell the client runtime what path to initiate the WebSocket connection on. -/// -/// -/// +/// +/// +/// pub fn route(path: String) -> Attribute(msg) { attribute("route", path) } @@ -34,25 +34,25 @@ pub fn route(path: String) -> Attribute(msg) { /// Ocassionally you may want to attach custom data to an event sent to the server. /// This could be used to include a hash of the current build to detect if the /// event was sent from a stale client. -/// +/// /// ```gleam -/// +/// /// ``` -/// +/// pub fn data(json: Json) -> Attribute(msg) { json |> json.to_string |> attribute("data-lustre-data", _) } -/// Properties of the JavaScript event object are typically not serialisable. +/// Properties of the JavaScript event object are typically not serialisable. /// This means if we want to pass them to the server we need to copy them into /// a new object first. -/// +/// /// This attribute tells Lustre what properties to include. Properties can come /// from nested objects by using dot notation. For example, you could include the /// `id` of the target `element` by passing `["target.id"]`. -/// +/// /// ```gleam /// import gleam/dynamic /// import gleam/result.{try} @@ -60,21 +60,21 @@ pub fn data(json: Json) -> Attribute(msg) { /// import lustre/element/html /// import lustre/event /// import lustre/server -/// +/// /// pub fn custom_button(on_click: fn(String) -> msg) -> Element(msg) { /// let handler = fn(event) { /// use target <- try(dynamic.field("target", dynamic.dynamic)(event)) /// use id <- try(dynamic.field("id", dynamic.string)(target)) -/// +/// /// Ok(on_click(id)) /// } -/// +/// /// html.button([event.on_click(handler), server.include(["target.id"])], [ /// element.text("Click me!") /// ]) /// } /// ``` -/// +/// pub fn include(properties: List(String)) -> Attribute(msg) { properties |> json.array(json.string) @@ -85,13 +85,13 @@ pub fn include(properties: List(String)) -> Attribute(msg) { // EFFECTS --------------------------------------------------------------------- /// -/// +/// pub fn emit(event: String, data: Json) -> Effect(msg) { effect.event(event, data) } /// -/// +/// pub fn selector(sel: Selector(Action(runtime, msg))) -> Effect(msg) { do_selector(sel) } diff --git a/test/lustre_test.gleam b/test/lustre_test.gleam index c90dc8b..bae6c0f 100644 --- a/test/lustre_test.gleam +++ b/test/lustre_test.gleam @@ -10,7 +10,7 @@ import gleeunit import lustre import lustre/element import lustre/internals/patch -import lustre/runtime.{Debug, Dispatch, Shutdown, View} +import lustre/internals/runtime.{Debug, Dispatch, Shutdown, View} // MAIN ------------------------------------------------------------------------ |