aboutsummaryrefslogtreecommitdiff
path: root/examples/01-hello-world
diff options
context:
space:
mode:
authorHayleigh Thompson <me@hayleigh.dev>2024-06-16 10:01:31 +0100
committerHayleigh Thompson <me@hayleigh.dev>2024-06-16 10:01:31 +0100
commiteae7274bf965505b5144eb9362eb634fcd77019a (patch)
treed95f37cf2b6a18a0985c67ade89aaee23da5e602 /examples/01-hello-world
parentf07188d0735808ccb313aedfd7f81889de253267 (diff)
downloadlustre-eae7274bf965505b5144eb9362eb634fcd77019a.tar.gz
lustre-eae7274bf965505b5144eb9362eb634fcd77019a.zip
:wrench: Update deps, pin gleam_json to 1.0.1
Diffstat (limited to 'examples/01-hello-world')
-rw-r--r--examples/01-hello-world/README.md18
-rw-r--r--examples/01-hello-world/gleam.toml1
-rw-r--r--examples/01-hello-world/manifest.toml27
-rw-r--r--examples/01-hello-world/priv/static/app.mjs160
4 files changed, 131 insertions, 75 deletions
diff --git a/examples/01-hello-world/README.md b/examples/01-hello-world/README.md
index 6e99205..71df563 100644
--- a/examples/01-hello-world/README.md
+++ b/examples/01-hello-world/README.md
@@ -60,24 +60,6 @@ in this and all the other example. You can run `gleam run -m lustre/dev start`
in any of these examples to start a development server and head over to
`localhost:1234` to see what it produces.
-### Enabling lustre/ui
-
-[`lustre/ui`](https://hexdocs.pm/lustre_ui/) is a separate package published by us
-to provide a collection of robust styled elements for folks that want to get working
-with Lustre ASAP. Each of these examples have been written to use elements from
-that package.
-
-Lustre's development server can be configured to include the `lustre/ui` stylesheet
-by passing the `--use-example-styles` flag:
-
-```sh
-gleam run -m lustre/dev start --use-example-styles
-```
-
-It's not necessary to use `lustre/ui` to use Lustre or to check out any of these
-examples, but we've built these examples using the package so things look a little
-more interesting.
-
## Getting help
If you're having trouble with Lustre or not sure what the right way to do
diff --git a/examples/01-hello-world/gleam.toml b/examples/01-hello-world/gleam.toml
index e8efd73..6b9e4db 100644
--- a/examples/01-hello-world/gleam.toml
+++ b/examples/01-hello-world/gleam.toml
@@ -3,6 +3,7 @@ version = "1.0.0"
target = "javascript"
[dependencies]
+gleam_json = "1.0.1"
gleam_stdlib = "~> 0.36"
lustre = "~> 4.0"
lustre_ui = "~> 0.4"
diff --git a/examples/01-hello-world/manifest.toml b/examples/01-hello-world/manifest.toml
index c0d1211..ee55acd 100644
--- a/examples/01-hello-world/manifest.toml
+++ b/examples/01-hello-world/manifest.toml
@@ -3,42 +3,45 @@
packages = [
{ name = "argv", version = "1.0.2", build_tools = ["gleam"], requirements = [], otp_app = "argv", source = "hex", outer_checksum = "BA1FF0929525DEBA1CE67256E5ADF77A7CDDFE729E3E3F57A5BDCAA031DED09D" },
- { name = "birl", version = "1.6.1", build_tools = ["gleam"], requirements = ["gleam_stdlib", "ranger"], otp_app = "birl", source = "hex", outer_checksum = "976CFF85D34D50F7775896615A71745FBE0C325E50399787088F941B539A0497" },
+ { name = "birl", version = "1.7.1", build_tools = ["gleam"], requirements = ["gleam_stdlib", "ranger"], otp_app = "birl", source = "hex", outer_checksum = "5C66647D62BCB11FE327E7A6024907C4A17954EF22865FE0940B54A852446D01" },
{ name = "exception", version = "2.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "exception", source = "hex", outer_checksum = "F5580D584F16A20B7FCDCABF9E9BE9A2C1F6AC4F9176FA6DD0B63E3B20D450AA" },
{ name = "filepath", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "filepath", source = "hex", outer_checksum = "EFB6FF65C98B2A16378ABC3EE2B14124168C0CE5201553DE652E2644DCFDB594" },
- { name = "filespy", version = "0.3.0", build_tools = ["gleam"], requirements = ["fs", "gleam_erlang", "gleam_otp", "gleam_stdlib"], otp_app = "filespy", source = "hex", outer_checksum = "75F5910B31A528681D25316AAAE6C91CD3E977BD2492946564B7242FF941FB7A" },
{ name = "fs", version = "8.6.1", build_tools = ["rebar3"], requirements = [], otp_app = "fs", source = "hex", outer_checksum = "61EA2BDAEDAE4E2024D0D25C63E44DCCF65622D4402DB4A2DF12868D1546503F" },
{ name = "gleam_community_ansi", version = "1.4.0", build_tools = ["gleam"], requirements = ["gleam_community_colour", "gleam_stdlib"], otp_app = "gleam_community_ansi", source = "hex", outer_checksum = "FE79E08BF97009729259B6357EC058315B6FBB916FAD1C2FF9355115FEB0D3A4" },
{ name = "gleam_community_colour", version = "1.4.0", build_tools = ["gleam"], requirements = ["gleam_json", "gleam_stdlib"], otp_app = "gleam_community_colour", source = "hex", outer_checksum = "795964217EBEDB3DA656F5EB8F67D7AD22872EB95182042D3E7AFEF32D3FD2FE" },
{ name = "gleam_crypto", version = "1.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_crypto", source = "hex", outer_checksum = "ADD058DEDE8F0341F1ADE3AAC492A224F15700829D9A3A3F9ADF370F875C51B7" },
{ name = "gleam_erlang", version = "0.25.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "054D571A7092D2A9727B3E5D183B7507DAB0DA41556EC9133606F09C15497373" },
{ name = "gleam_http", version = "3.6.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_http", source = "hex", outer_checksum = "8C07DF9DF8CC7F054C650839A51C30A7D3C26482AC241C899C1CEA86B22DBE51" },
- { name = "gleam_json", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "thoas"], otp_app = "gleam_json", source = "hex", outer_checksum = "8B197DD5D578EA6AC2C0D4BDC634C71A5BCA8E7DB5F47091C263ECB411A60DF3" },
+ { name = "gleam_httpc", version = "2.2.0", build_tools = ["gleam"], requirements = ["gleam_http", "gleam_stdlib"], otp_app = "gleam_httpc", source = "hex", outer_checksum = "CF76C71002DEECF6DC5D9CA83D962728FAE166B57926BE442D827004D3C7DF1B" },
+ { name = "gleam_json", version = "1.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib", "thoas"], otp_app = "gleam_json", source = "hex", outer_checksum = "9063D14D25406326C0255BDA0021541E797D8A7A12573D849462CAFED459F6EB" },
{ name = "gleam_otp", version = "0.10.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_stdlib"], otp_app = "gleam_otp", source = "hex", outer_checksum = "0B04FE915ACECE539B317F9652CAADBBC0F000184D586AAAF2D94C100945D72B" },
{ name = "gleam_package_interface", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_json", "gleam_stdlib"], otp_app = "gleam_package_interface", source = "hex", outer_checksum = "52A721BCA972C8099BB881195D821AAA64B9F2655BECC102165D5A1097731F01" },
- { name = "gleam_stdlib", version = "0.36.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "C0D14D807FEC6F8A08A7C9EF8DFDE6AE5C10E40E21325B2B29365965D82EB3D4" },
- { name = "glearray", version = "0.2.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "glearray", source = "hex", outer_checksum = "908154F695D330E06A37FAB2C04119E8F315D643206F8F32B6A6C14A8709FFF4" },
+ { name = "gleam_stdlib", version = "0.38.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "663CF11861179AF415A625307447775C09404E752FF99A24E2057C835319F1BE" },
+ { name = "glearray", version = "0.2.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "glearray", source = "hex", outer_checksum = "9C207E05F38D724F464FA921378DB3ABC2B0A2F5821116D8BC8B2CACC68930D5" },
{ name = "gleeunit", version = "1.1.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "72CDC3D3F719478F26C4E2C5FED3E657AC81EC14A47D2D2DEBB8693CA3220C3B" },
- { name = "glint", version = "0.18.0", build_tools = ["gleam"], requirements = ["gleam_community_ansi", "gleam_community_colour", "gleam_stdlib", "snag"], otp_app = "glint", source = "hex", outer_checksum = "BB0F14643CC51C069A5DC6E9082EAFCD9967AFD1C9CC408803D1A40A3FD43B54" },
+ { name = "glint", version = "0.18.1", build_tools = ["gleam"], requirements = ["gleam_community_ansi", "gleam_community_colour", "gleam_stdlib", "snag"], otp_app = "glint", source = "hex", outer_checksum = "5FB54D7732B4105E4AF4D89A7EE6D5E8CF33DA13A3575D0C6ECE470B97958454" },
{ name = "glisten", version = "2.0.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_otp", "gleam_stdlib"], otp_app = "glisten", source = "hex", outer_checksum = "CF3A9383E9BA4A8CBAF2F7B799716290D02F2AC34E7A77556B49376B662B9314" },
+ { name = "gramps", version = "2.0.3", build_tools = ["gleam"], requirements = ["gleam_crypto", "gleam_erlang", "gleam_http", "gleam_stdlib"], otp_app = "gramps", source = "hex", outer_checksum = "3CCAA6E081225180D95C79679D383BBF51C8D1FDC1B84DA1DA444F628C373793" },
{ name = "hpack_erl", version = "0.3.0", build_tools = ["rebar3"], requirements = [], otp_app = "hpack", source = "hex", outer_checksum = "D6137D7079169D8C485C6962DFE261AF5B9EF60FBC557344511C1E65E3D95FB0" },
- { name = "logging", version = "1.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "logging", source = "hex", outer_checksum = "82C112ED9B6C30C1772A6FE2613B94B13F62EA35F5869A2630D13948D297BD39" },
- { name = "lustre", version = "4.1.7", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_json", "gleam_otp", "gleam_stdlib"], otp_app = "lustre", source = "hex", outer_checksum = "64F5D7E4DF51280185F70296ACB7D3DCC9B5DA09EFC5257F0E5601846DFBEF23" },
- { name = "lustre_dev_tools", version = "1.2.1", build_tools = ["gleam"], requirements = ["argv", "filepath", "filespy", "fs", "gleam_community_ansi", "gleam_erlang", "gleam_http", "gleam_json", "gleam_otp", "gleam_package_interface", "gleam_stdlib", "glint", "glisten", "mist", "simplifile", "spinner", "tom", "wisp"], otp_app = "lustre_dev_tools", source = "hex", outer_checksum = "930BBE8C4E92A16857C31B7B12616651433E1643304696FB93B69D659CE3ADC2" },
+ { name = "logging", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "logging", source = "hex", outer_checksum = "A996064F04EF6E67F0668FD0ACFB309830B05D0EE3A0C11BBBD2D4464334F792" },
+ { name = "lustre", version = "4.2.6", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_json", "gleam_otp", "gleam_stdlib"], otp_app = "lustre", source = "hex", outer_checksum = "9ABD71D63F4B8F362CB824DED2C4CA64895DEFACD8F22B0FF055BF15241B1AE2" },
+ { name = "lustre_dev_tools", version = "1.3.3", build_tools = ["gleam"], requirements = ["argv", "filepath", "fs", "gleam_community_ansi", "gleam_erlang", "gleam_http", "gleam_httpc", "gleam_json", "gleam_otp", "gleam_package_interface", "gleam_stdlib", "glint", "glisten", "mist", "simplifile", "spinner", "term_size", "tom", "wisp"], otp_app = "lustre_dev_tools", source = "hex", outer_checksum = "67B4E62DAD9B8323487AAA697A6F3FA72348B6DEA6674D65D4F7A1407CF377ED" },
{ name = "lustre_ui", version = "0.6.0", build_tools = ["gleam"], requirements = ["gleam_community_colour", "gleam_json", "gleam_stdlib", "lustre"], otp_app = "lustre_ui", source = "hex", outer_checksum = "FA1F9E89D89CDD5DF376ED86ABA8A38441CB2E664CD4D402F22A49DA4D7BB56D" },
- { name = "marceau", version = "1.1.0", build_tools = ["gleam"], requirements = [], otp_app = "marceau", source = "hex", outer_checksum = "1AAD727A30BE0F95562C3403BB9B27C823797AD90037714255EEBF617B1CDA81" },
- { name = "mist", version = "1.0.0", build_tools = ["gleam"], requirements = ["birl", "gleam_erlang", "gleam_http", "gleam_otp", "gleam_stdlib", "glisten", "hpack_erl", "logging"], otp_app = "mist", source = "hex", outer_checksum = "7765E53DCC9ACCACF217B8E0CA3DE7E848C783BFAE5118B75011E81C2C80385C" },
+ { name = "marceau", version = "1.2.0", build_tools = ["gleam"], requirements = [], otp_app = "marceau", source = "hex", outer_checksum = "5188D643C181EE350D8A20A3BDBD63AF7B6C505DE333CFBE05EF642ADD88A59B" },
+ { name = "mist", version = "1.2.0", build_tools = ["gleam"], requirements = ["birl", "gleam_erlang", "gleam_http", "gleam_otp", "gleam_stdlib", "glisten", "gramps", "hpack_erl", "logging"], otp_app = "mist", source = "hex", outer_checksum = "109B4D64E68C104CC23BB3CC5441ECD479DD7444889DA01113B75C6AF0F0E17B" },
{ name = "ranger", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "ranger", source = "hex", outer_checksum = "1566C272B1D141B3BBA38B25CB761EF56E312E79EC0E2DFD4D3C19FB0CC1F98C" },
{ name = "repeatedly", version = "2.1.1", build_tools = ["gleam"], requirements = [], otp_app = "repeatedly", source = "hex", outer_checksum = "38808C3EC382B0CD981336D5879C24ECB37FCB9C1D1BD128F7A80B0F74404D79" },
{ name = "simplifile", version = "1.7.0", build_tools = ["gleam"], requirements = ["filepath", "gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "1D5DFA3A2F9319EC85825F6ED88B8E449F381B0D55A62F5E61424E748E7DDEB0" },
{ name = "snag", version = "0.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "snag", source = "hex", outer_checksum = "54D32E16E33655346AA3E66CBA7E191DE0A8793D2C05284E3EFB90AD2CE92BCC" },
{ name = "spinner", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_community_ansi", "gleam_erlang", "gleam_stdlib", "glearray", "repeatedly"], otp_app = "spinner", source = "hex", outer_checksum = "200BA3D4A04D468898E63C0D316E23F526E02514BC46454091975CB5BAE41E8F" },
- { name = "thoas", version = "0.4.1", build_tools = ["rebar3"], requirements = [], otp_app = "thoas", source = "hex", outer_checksum = "4918D50026C073C4AB1388437132C77A6F6F7C8AC43C60C13758CC0ADCE2134E" },
+ { name = "term_size", version = "1.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "term_size", source = "hex", outer_checksum = "D00BD2BC8FB3EBB7E6AE076F3F1FF2AC9D5ED1805F004D0896C784D06C6645F1" },
+ { name = "thoas", version = "1.2.1", build_tools = ["rebar3"], requirements = [], otp_app = "thoas", source = "hex", outer_checksum = "E38697EDFFD6E91BD12CEA41B155115282630075C2A727E7A6B2947F5408B86A" },
{ name = "tom", version = "0.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "tom", source = "hex", outer_checksum = "0831C73E45405A2153091226BF98FB485ED16376988602CC01A5FD086B82D577" },
{ name = "wisp", version = "0.14.0", build_tools = ["gleam"], requirements = ["exception", "gleam_crypto", "gleam_erlang", "gleam_http", "gleam_json", "gleam_stdlib", "logging", "marceau", "mist", "simplifile"], otp_app = "wisp", source = "hex", outer_checksum = "9F5453AF1F9275E6F8707BC815D6A6A9DF41551921B16FBDBA52883773BAE684" },
]
[requirements]
+gleam_json = { version = "1.0.1" }
gleam_stdlib = { version = "~> 0.36" }
gleeunit = { version = "~> 1.0" }
lustre = { version = "~> 4.0" }
diff --git a/examples/01-hello-world/priv/static/app.mjs b/examples/01-hello-world/priv/static/app.mjs
index 60d0114..77b01fe 100644
--- a/examples/01-hello-world/priv/static/app.mjs
+++ b/examples/01-hello-world/priv/static/app.mjs
@@ -328,6 +328,12 @@ function text(content) {
}
// build/dev/javascript/lustre/lustre/internals/runtime.mjs
+var Debug = class extends CustomType {
+ constructor(x0) {
+ super();
+ this[0] = x0;
+ }
+};
var Dispatch = class extends CustomType {
constructor(x0) {
super();
@@ -336,6 +342,12 @@ var Dispatch = class extends CustomType {
};
var Shutdown = class extends CustomType {
};
+var ForceModel = class extends CustomType {
+ constructor(x0) {
+ super();
+ this[0] = x0;
+ }
+};
// build/dev/javascript/lustre/vdom.ffi.mjs
function morph(prev, next, dispatch, isComponent = false) {
@@ -373,6 +385,13 @@ function morph(prev, next, dispatch, isComponent = false) {
parent.replaceChild(created, prev2);
}
out ??= created;
+ } else if (next2.elements !== void 0) {
+ iterateElement(next2, (fragmentElement) => {
+ stack2.unshift({ prev: prev2, next: fragmentElement, parent });
+ prev2 = prev2?.nextSibling;
+ });
+ } else if (next2.subtree !== void 0) {
+ stack2.push({ prev: prev2, next: next2, parent });
}
}
return out;
@@ -397,9 +416,11 @@ function createElementNode({ prev, next, dispatch, stack: stack2 }) {
for (const attr of next.attrs) {
const name = attr[0];
const value = attr[1];
- const isProperty = attr[2];
- if (isProperty) {
- el2[name] = value;
+ if (attr.as_property) {
+ if (el2[name] !== value)
+ el2[name] = value;
+ if (canMorph)
+ prevAttributes.delete(name);
} else if (name.startsWith("on")) {
const eventName = name.slice(2);
const callback = dispatch(value);
@@ -424,8 +445,9 @@ function createElementNode({ prev, next, dispatch, stack: stack2 }) {
} else if (name === "dangerous-unescaped-html") {
innerHTML = value;
} else {
- el2.setAttribute(name, value);
- if (name === "value")
+ if (typeof value === "string")
+ el2.setAttribute(name, value);
+ if (name === "value" || name === "selected")
el2[name] = value;
if (canMorph)
prevAttributes.delete(name);
@@ -469,45 +491,22 @@ function createElementNode({ prev, next, dispatch, stack: stack2 }) {
incomingKeyedChildren = getKeyedChildren(next);
}
for (const child of next.children) {
- if (child.key !== void 0 && seenKeys !== null) {
- while (prevChild && !incomingKeyedChildren.has(prevChild.getAttribute("data-lustre-key"))) {
- const nextChild = prevChild.nextSibling;
- el2.removeChild(prevChild);
- prevChild = nextChild;
- }
- if (keyedChildren.size === 0) {
- stack2.unshift({ prev: prevChild, next: child, parent: el2 });
- prevChild = prevChild?.nextSibling;
- continue;
- }
- if (seenKeys.has(child.key)) {
- console.warn(`Duplicate key found in Lustre vnode: ${child.key}`);
- stack2.unshift({ prev: null, next: child, parent: el2 });
- continue;
- }
- seenKeys.add(child.key);
- const keyedChild = keyedChildren.get(child.key);
- if (!keyedChild && !prevChild) {
- stack2.unshift({ prev: null, next: child, parent: el2 });
- continue;
- }
- if (!keyedChild && prevChild !== null) {
- const placeholder = document.createTextNode("");
- el2.insertBefore(placeholder, prevChild);
- stack2.unshift({ prev: placeholder, next: child, parent: el2 });
- continue;
- }
- if (!keyedChild || keyedChild === prevChild) {
- stack2.unshift({ prev: prevChild, next: child, parent: el2 });
+ iterateElement(child, (currElement) => {
+ if (currElement.key !== void 0 && seenKeys !== null) {
+ prevChild = diffKeyedChild(
+ prevChild,
+ currElement,
+ el2,
+ stack2,
+ incomingKeyedChildren,
+ keyedChildren,
+ seenKeys
+ );
+ } else {
+ stack2.unshift({ prev: prevChild, next: currElement, parent: el2 });
prevChild = prevChild?.nextSibling;
- continue;
}
- el2.insertBefore(keyedChild, prevChild);
- stack2.unshift({ prev: keyedChild, next: child, parent: el2 });
- } else {
- stack2.unshift({ prev: prevChild, next: child, parent: el2 });
- prevChild = prevChild?.nextSibling;
- }
+ });
}
while (prevChild) {
const next2 = prevChild.nextSibling;
@@ -565,13 +564,63 @@ function getKeyedChildren(el2) {
const keyedChildren = /* @__PURE__ */ new Map();
if (el2) {
for (const child of el2.children) {
- const key = child.key || child?.getAttribute("data-lustre-key");
- if (key)
- keyedChildren.set(key, child);
+ iterateElement(child, (currElement) => {
+ const key = currElement?.key || currElement?.getAttribute?.("data-lustre-key");
+ if (key)
+ keyedChildren.set(key, currElement);
+ });
}
}
return keyedChildren;
}
+function diffKeyedChild(prevChild, child, el2, stack2, incomingKeyedChildren, keyedChildren, seenKeys) {
+ while (prevChild && !incomingKeyedChildren.has(prevChild.getAttribute("data-lustre-key"))) {
+ const nextChild = prevChild.nextSibling;
+ el2.removeChild(prevChild);
+ prevChild = nextChild;
+ }
+ if (keyedChildren.size === 0) {
+ iterateElement(child, (currChild) => {
+ stack2.unshift({ prev: prevChild, next: currChild, parent: el2 });
+ prevChild = prevChild?.nextSibling;
+ });
+ return prevChild;
+ }
+ if (seenKeys.has(child.key)) {
+ console.warn(`Duplicate key found in Lustre vnode: ${child.key}`);
+ stack2.unshift({ prev: null, next: child, parent: el2 });
+ return prevChild;
+ }
+ seenKeys.add(child.key);
+ const keyedChild = keyedChildren.get(child.key);
+ if (!keyedChild && !prevChild) {
+ stack2.unshift({ prev: null, next: child, parent: el2 });
+ return prevChild;
+ }
+ if (!keyedChild && prevChild !== null) {
+ const placeholder = document.createTextNode("");
+ el2.insertBefore(placeholder, prevChild);
+ stack2.unshift({ prev: placeholder, next: child, parent: el2 });
+ return prevChild;
+ }
+ if (!keyedChild || keyedChild === prevChild) {
+ stack2.unshift({ prev: prevChild, next: child, parent: el2 });
+ prevChild = prevChild?.nextSibling;
+ return prevChild;
+ }
+ el2.insertBefore(keyedChild, prevChild);
+ stack2.unshift({ prev: keyedChild, next: child, parent: el2 });
+ return prevChild;
+}
+function iterateElement(element3, processElement) {
+ if (element3.elements !== void 0) {
+ for (const currElement of element3.elements) {
+ processElement(currElement);
+ }
+ } else {
+ processElement(element3);
+ }
+}
// build/dev/javascript/lustre/client-runtime.ffi.mjs
var LustreClientApplication2 = class _LustreClientApplication {
@@ -613,6 +662,10 @@ var LustreClientApplication2 = class _LustreClientApplication {
this.#shutdown();
return;
}
+ case action instanceof Debug: {
+ this.#debug(action[0]);
+ return;
+ }
default:
return;
}
@@ -659,6 +712,23 @@ var LustreClientApplication2 = class _LustreClientApplication {
}
}
}
+ #debug(action) {
+ switch (true) {
+ case action instanceof ForceModel: {
+ const vdom = this.#view(action[0]);
+ const dispatch = (handler) => (e) => {
+ const result = handler(e);
+ if (result instanceof Ok) {
+ this.send(new Dispatch(result[0]));
+ }
+ };
+ this.#queue = [];
+ this.#effects = [];
+ this.#didUpdate = false;
+ this.#root = morph(this.#root, vdom, dispatch, this.#isComponent);
+ }
+ }
+ }
#shutdown() {
this.#root.remove();
this.#root = null;