diff --git a/frontend/.gitignore b/frontend/.gitignore index 599be4e..1d87233 100644 --- a/frontend/.gitignore +++ b/frontend/.gitignore @@ -2,3 +2,5 @@ *.ez /build erl_crash.dump +priv/static/aurinko_frontend.css +priv/static/aurinko_frontend.mjs diff --git a/frontend/priv/static/aurinko_frontend.css b/frontend/priv/static/aurinko_frontend.css deleted file mode 100644 index e6cf235..0000000 --- a/frontend/priv/static/aurinko_frontend.css +++ /dev/null @@ -1,545 +0,0 @@ -/* -! tailwindcss v3.4.1 | MIT License | https://tailwindcss.com -*/ - -/* -1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4) -2. Allow adding a border to an element by just adding a border-width. (https://github.com/tailwindcss/tailwindcss/pull/116) -*/ - -*, -::before, -::after { - box-sizing: border-box; - /* 1 */ - border-width: 0; - /* 2 */ - border-style: solid; - /* 2 */ - border-color: #e5e7eb; - /* 2 */ -} - -::before, -::after { - --tw-content: ''; -} - -/* -1. Use a consistent sensible line-height in all browsers. -2. Prevent adjustments of font size after orientation changes in iOS. -3. Use a more readable tab size. -4. Use the user's configured `sans` font-family by default. -5. Use the user's configured `sans` font-feature-settings by default. -6. Use the user's configured `sans` font-variation-settings by default. -7. Disable tap highlights on iOS -*/ - -html, -:host { - line-height: 1.5; - /* 1 */ - -webkit-text-size-adjust: 100%; - /* 2 */ - -moz-tab-size: 4; - /* 3 */ - -o-tab-size: 4; - tab-size: 4; - /* 3 */ - font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; - /* 4 */ - font-feature-settings: normal; - /* 5 */ - font-variation-settings: normal; - /* 6 */ - -webkit-tap-highlight-color: transparent; - /* 7 */ -} - -/* -1. Remove the margin in all browsers. -2. Inherit line-height from `html` so users can set them as a class directly on the `html` element. -*/ - -body { - margin: 0; - /* 1 */ - line-height: inherit; - /* 2 */ -} - -/* -1. Add the correct height in Firefox. -2. Correct the inheritance of border color in Firefox. (https://bugzilla.mozilla.org/show_bug.cgi?id=190655) -3. Ensure horizontal rules are visible by default. -*/ - -hr { - height: 0; - /* 1 */ - color: inherit; - /* 2 */ - border-top-width: 1px; - /* 3 */ -} - -/* -Add the correct text decoration in Chrome, Edge, and Safari. -*/ - -abbr:where([title]) { - -webkit-text-decoration: underline dotted; - text-decoration: underline dotted; -} - -/* -Remove the default font size and weight for headings. -*/ - -h1, -h2, -h3, -h4, -h5, -h6 { - font-size: inherit; - font-weight: inherit; -} - -/* -Reset links to optimize for opt-in styling instead of opt-out. -*/ - -a { - color: inherit; - text-decoration: inherit; -} - -/* -Add the correct font weight in Edge and Safari. -*/ - -b, -strong { - font-weight: bolder; -} - -/* -1. Use the user's configured `mono` font-family by default. -2. Use the user's configured `mono` font-feature-settings by default. -3. Use the user's configured `mono` font-variation-settings by default. -4. Correct the odd `em` font sizing in all browsers. -*/ - -code, -kbd, -samp, -pre { - font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; - /* 1 */ - font-feature-settings: normal; - /* 2 */ - font-variation-settings: normal; - /* 3 */ - font-size: 1em; - /* 4 */ -} - -/* -Add the correct font size in all browsers. -*/ - -small { - font-size: 80%; -} - -/* -Prevent `sub` and `sup` elements from affecting the line height in all browsers. -*/ - -sub, -sup { - font-size: 75%; - line-height: 0; - position: relative; - vertical-align: baseline; -} - -sub { - bottom: -0.25em; -} - -sup { - top: -0.5em; -} - -/* -1. Remove text indentation from table contents in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=999088, https://bugs.webkit.org/show_bug.cgi?id=201297) -2. Correct table border color inheritance in all Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=935729, https://bugs.webkit.org/show_bug.cgi?id=195016) -3. Remove gaps between table borders by default. -*/ - -table { - text-indent: 0; - /* 1 */ - border-color: inherit; - /* 2 */ - border-collapse: collapse; - /* 3 */ -} - -/* -1. Change the font styles in all browsers. -2. Remove the margin in Firefox and Safari. -3. Remove default padding in all browsers. -*/ - -button, -input, -optgroup, -select, -textarea { - font-family: inherit; - /* 1 */ - font-feature-settings: inherit; - /* 1 */ - font-variation-settings: inherit; - /* 1 */ - font-size: 100%; - /* 1 */ - font-weight: inherit; - /* 1 */ - line-height: inherit; - /* 1 */ - color: inherit; - /* 1 */ - margin: 0; - /* 2 */ - padding: 0; - /* 3 */ -} - -/* -Remove the inheritance of text transform in Edge and Firefox. -*/ - -button, -select { - text-transform: none; -} - -/* -1. Correct the inability to style clickable types in iOS and Safari. -2. Remove default button styles. -*/ - -button, -[type='button'], -[type='reset'], -[type='submit'] { - -webkit-appearance: button; - /* 1 */ - background-color: transparent; - /* 2 */ - background-image: none; - /* 2 */ -} - -/* -Use the modern Firefox focus style for all focusable elements. -*/ - -:-moz-focusring { - outline: auto; -} - -/* -Remove the additional `:invalid` styles in Firefox. (https://github.com/mozilla/gecko-dev/blob/2f9eacd9d3d995c937b4251a5557d95d494c9be1/layout/style/res/forms.css#L728-L737) -*/ - -:-moz-ui-invalid { - box-shadow: none; -} - -/* -Add the correct vertical alignment in Chrome and Firefox. -*/ - -progress { - vertical-align: baseline; -} - -/* -Correct the cursor style of increment and decrement buttons in Safari. -*/ - -::-webkit-inner-spin-button, -::-webkit-outer-spin-button { - height: auto; -} - -/* -1. Correct the odd appearance in Chrome and Safari. -2. Correct the outline style in Safari. -*/ - -[type='search'] { - -webkit-appearance: textfield; - /* 1 */ - outline-offset: -2px; - /* 2 */ -} - -/* -Remove the inner padding in Chrome and Safari on macOS. -*/ - -::-webkit-search-decoration { - -webkit-appearance: none; -} - -/* -1. Correct the inability to style clickable types in iOS and Safari. -2. Change font properties to `inherit` in Safari. -*/ - -::-webkit-file-upload-button { - -webkit-appearance: button; - /* 1 */ - font: inherit; - /* 2 */ -} - -/* -Add the correct display in Chrome and Safari. -*/ - -summary { - display: list-item; -} - -/* -Removes the default spacing and border for appropriate elements. -*/ - -blockquote, -dl, -dd, -h1, -h2, -h3, -h4, -h5, -h6, -hr, -figure, -p, -pre { - margin: 0; -} - -fieldset { - margin: 0; - padding: 0; -} - -legend { - padding: 0; -} - -ol, -ul, -menu { - list-style: none; - margin: 0; - padding: 0; -} - -/* -Reset default styling for dialogs. -*/ - -dialog { - padding: 0; -} - -/* -Prevent resizing textareas horizontally by default. -*/ - -textarea { - resize: vertical; -} - -/* -1. Reset the default placeholder opacity in Firefox. (https://github.com/tailwindlabs/tailwindcss/issues/3300) -2. Set the default placeholder color to the user's configured gray 400 color. -*/ - -input::-moz-placeholder, textarea::-moz-placeholder { - opacity: 1; - /* 1 */ - color: #9ca3af; - /* 2 */ -} - -input::placeholder, -textarea::placeholder { - opacity: 1; - /* 1 */ - color: #9ca3af; - /* 2 */ -} - -/* -Set the default cursor for buttons. -*/ - -button, -[role="button"] { - cursor: pointer; -} - -/* -Make sure disabled buttons don't get the pointer cursor. -*/ - -:disabled { - cursor: default; -} - -/* -1. Make replaced elements `display: block` by default. (https://github.com/mozdevs/cssremedy/issues/14) -2. Add `vertical-align: middle` to align replaced elements more sensibly by default. (https://github.com/jensimmons/cssremedy/issues/14#issuecomment-634934210) - This can trigger a poorly considered lint error in some tools but is included by design. -*/ - -img, -svg, -video, -canvas, -audio, -iframe, -embed, -object { - display: block; - /* 1 */ - vertical-align: middle; - /* 2 */ -} - -/* -Constrain images and videos to the parent width and preserve their intrinsic aspect ratio. (https://github.com/mozdevs/cssremedy/issues/14) -*/ - -img, -video { - max-width: 100%; - height: auto; -} - -/* Make elements with the HTML hidden attribute stay hidden by default */ - -[hidden] { - display: none; -} - -*, ::before, ::after { - --tw-border-spacing-x: 0; - --tw-border-spacing-y: 0; - --tw-translate-x: 0; - --tw-translate-y: 0; - --tw-rotate: 0; - --tw-skew-x: 0; - --tw-skew-y: 0; - --tw-scale-x: 1; - --tw-scale-y: 1; - --tw-pan-x: ; - --tw-pan-y: ; - --tw-pinch-zoom: ; - --tw-scroll-snap-strictness: proximity; - --tw-gradient-from-position: ; - --tw-gradient-via-position: ; - --tw-gradient-to-position: ; - --tw-ordinal: ; - --tw-slashed-zero: ; - --tw-numeric-figure: ; - --tw-numeric-spacing: ; - --tw-numeric-fraction: ; - --tw-ring-inset: ; - --tw-ring-offset-width: 0px; - --tw-ring-offset-color: #fff; - --tw-ring-color: rgb(59 130 246 / 0.5); - --tw-ring-offset-shadow: 0 0 #0000; - --tw-ring-shadow: 0 0 #0000; - --tw-shadow: 0 0 #0000; - --tw-shadow-colored: 0 0 #0000; - --tw-blur: ; - --tw-brightness: ; - --tw-contrast: ; - --tw-grayscale: ; - --tw-hue-rotate: ; - --tw-invert: ; - --tw-saturate: ; - --tw-sepia: ; - --tw-drop-shadow: ; - --tw-backdrop-blur: ; - --tw-backdrop-brightness: ; - --tw-backdrop-contrast: ; - --tw-backdrop-grayscale: ; - --tw-backdrop-hue-rotate: ; - --tw-backdrop-invert: ; - --tw-backdrop-opacity: ; - --tw-backdrop-saturate: ; - --tw-backdrop-sepia: ; -} - -::backdrop { - --tw-border-spacing-x: 0; - --tw-border-spacing-y: 0; - --tw-translate-x: 0; - --tw-translate-y: 0; - --tw-rotate: 0; - --tw-skew-x: 0; - --tw-skew-y: 0; - --tw-scale-x: 1; - --tw-scale-y: 1; - --tw-pan-x: ; - --tw-pan-y: ; - --tw-pinch-zoom: ; - --tw-scroll-snap-strictness: proximity; - --tw-gradient-from-position: ; - --tw-gradient-via-position: ; - --tw-gradient-to-position: ; - --tw-ordinal: ; - --tw-slashed-zero: ; - --tw-numeric-figure: ; - --tw-numeric-spacing: ; - --tw-numeric-fraction: ; - --tw-ring-inset: ; - --tw-ring-offset-width: 0px; - --tw-ring-offset-color: #fff; - --tw-ring-color: rgb(59 130 246 / 0.5); - --tw-ring-offset-shadow: 0 0 #0000; - --tw-ring-shadow: 0 0 #0000; - --tw-shadow: 0 0 #0000; - --tw-shadow-colored: 0 0 #0000; - --tw-blur: ; - --tw-brightness: ; - --tw-contrast: ; - --tw-grayscale: ; - --tw-hue-rotate: ; - --tw-invert: ; - --tw-saturate: ; - --tw-sepia: ; - --tw-drop-shadow: ; - --tw-backdrop-blur: ; - --tw-backdrop-brightness: ; - --tw-backdrop-contrast: ; - --tw-backdrop-grayscale: ; - --tw-backdrop-hue-rotate: ; - --tw-backdrop-invert: ; - --tw-backdrop-opacity: ; - --tw-backdrop-saturate: ; - --tw-backdrop-sepia: ; -} diff --git a/frontend/priv/static/aurinko_frontend.mjs b/frontend/priv/static/aurinko_frontend.mjs deleted file mode 100644 index 2be5313..0000000 --- a/frontend/priv/static/aurinko_frontend.mjs +++ /dev/null @@ -1,755 +0,0 @@ -// build/dev/javascript/prelude.mjs -var CustomType = class { - withFields(fields) { - let properties = Object.keys(this).map( - (label) => label in fields ? fields[label] : this[label] - ); - return new this.constructor(...properties); - } -}; -var List = class { - static fromArray(array3, tail) { - let t = tail || new Empty(); - for (let i = array3.length - 1; i >= 0; --i) { - t = new NonEmpty(array3[i], t); - } - return t; - } - [Symbol.iterator]() { - return new ListIterator(this); - } - toArray() { - return [...this]; - } - // @internal - atLeastLength(desired) { - for (let _ of this) { - if (desired <= 0) - return true; - desired--; - } - return desired <= 0; - } - // @internal - hasLength(desired) { - for (let _ of this) { - if (desired <= 0) - return false; - desired--; - } - return desired === 0; - } - countLength() { - let length2 = 0; - for (let _ of this) - length2++; - return length2; - } -}; -function toList(elements, tail) { - return List.fromArray(elements, tail); -} -var ListIterator = class { - #current; - constructor(current) { - this.#current = current; - } - next() { - if (this.#current instanceof Empty) { - return { done: true }; - } else { - let { head, tail } = this.#current; - this.#current = tail; - return { value: head, done: false }; - } - } -}; -var Empty = class extends List { -}; -var NonEmpty = class extends List { - constructor(head, tail) { - super(); - this.head = head; - this.tail = tail; - } -}; -var Result = class _Result extends CustomType { - // @internal - static isResult(data) { - return data instanceof _Result; - } -}; -var Ok = class extends Result { - constructor(value) { - super(); - this[0] = value; - } - // @internal - isOk() { - return true; - } -}; -var Error = class extends Result { - constructor(detail) { - super(); - this[0] = detail; - } - // @internal - isOk() { - return false; - } -}; -function makeError(variant, module, line, fn, message, extra) { - let error = new globalThis.Error(message); - error.gleam_error = variant; - error.module = module; - error.line = line; - error.fn = fn; - for (let k in extra) - error[k] = extra[k]; - return error; -} - -// build/dev/javascript/gleam_stdlib/gleam/option.mjs -var None = class extends CustomType { -}; - -// build/dev/javascript/gleam_stdlib/dict.mjs -var tempDataView = new DataView(new ArrayBuffer(8)); -var SHIFT = 5; -var BUCKET_SIZE = Math.pow(2, SHIFT); -var MASK = BUCKET_SIZE - 1; -var MAX_INDEX_NODE = BUCKET_SIZE / 2; -var MIN_ARRAY_NODE = BUCKET_SIZE / 4; - -// build/dev/javascript/gleam_stdlib/gleam_stdlib.mjs -function to_string3(term) { - return term.toString(); -} - -// build/dev/javascript/gleam_stdlib/gleam/int.mjs -function to_string(x) { - return to_string3(x); -} - -// build/dev/javascript/gleam_stdlib/gleam/bool.mjs -function guard(requirement, consequence, alternative) { - if (requirement) { - return consequence; - } else { - return alternative(); - } -} - -// build/dev/javascript/lustre/lustre/effect.mjs -var Effect = class extends CustomType { - constructor(all) { - super(); - this.all = all; - } -}; -function none() { - return new Effect(toList([])); -} - -// build/dev/javascript/lustre/lustre/internals/vdom.mjs -var Text = class extends CustomType { - constructor(content) { - super(); - this.content = content; - } -}; -var Element = class extends CustomType { - constructor(key, namespace, tag, attrs, children, self_closing, void$) { - super(); - this.key = key; - this.namespace = namespace; - this.tag = tag; - this.attrs = attrs; - this.children = children; - this.self_closing = self_closing; - this.void = void$; - } -}; -var Event = class extends CustomType { - constructor(x0, x1) { - super(); - this[0] = x0; - this[1] = x1; - } -}; - -// build/dev/javascript/lustre/lustre/attribute.mjs -function on(name, handler) { - return new Event("on" + name, handler); -} - -// build/dev/javascript/lustre/lustre/element.mjs -function element(tag, attrs, children) { - if (tag === "area") { - return new Element("", "", tag, attrs, toList([]), false, true); - } else if (tag === "base") { - return new Element("", "", tag, attrs, toList([]), false, true); - } else if (tag === "br") { - return new Element("", "", tag, attrs, toList([]), false, true); - } else if (tag === "col") { - return new Element("", "", tag, attrs, toList([]), false, true); - } else if (tag === "embed") { - return new Element("", "", tag, attrs, toList([]), false, true); - } else if (tag === "hr") { - return new Element("", "", tag, attrs, toList([]), false, true); - } else if (tag === "img") { - return new Element("", "", tag, attrs, toList([]), false, true); - } else if (tag === "input") { - return new Element("", "", tag, attrs, toList([]), false, true); - } else if (tag === "link") { - return new Element("", "", tag, attrs, toList([]), false, true); - } else if (tag === "meta") { - return new Element("", "", tag, attrs, toList([]), false, true); - } else if (tag === "param") { - return new Element("", "", tag, attrs, toList([]), false, true); - } else if (tag === "source") { - return new Element("", "", tag, attrs, toList([]), false, true); - } else if (tag === "track") { - return new Element("", "", tag, attrs, toList([]), false, true); - } else if (tag === "wbr") { - return new Element("", "", tag, attrs, toList([]), false, true); - } else { - return new Element("", "", tag, attrs, children, false, false); - } -} -function text(content) { - return new 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(); - this[0] = x0; - } -}; -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) { - let out; - let stack = [{ prev, next, parent: prev.parentNode }]; - while (stack.length) { - let { prev: prev2, next: next2, parent } = stack.pop(); - if (next2.subtree !== void 0) - next2 = next2.subtree(); - if (next2.content !== void 0) { - if (!prev2) { - const created = document.createTextNode(next2.content); - parent.appendChild(created); - out ??= created; - } else if (prev2.nodeType === Node.TEXT_NODE) { - if (prev2.textContent !== next2.content) - prev2.textContent = next2.content; - out ??= prev2; - } else { - const created = document.createTextNode(next2.content); - parent.replaceChild(created, prev2); - out ??= created; - } - } else if (next2.tag !== void 0) { - const created = createElementNode({ - prev: prev2, - next: next2, - dispatch, - stack, - isComponent - }); - if (!prev2) { - parent.appendChild(created); - } else if (prev2 !== created) { - parent.replaceChild(created, prev2); - } - out ??= created; - } else if (next2.elements !== void 0) { - iterateElement(next2, (fragmentElement) => { - stack.unshift({ prev: prev2, next: fragmentElement, parent }); - prev2 = prev2?.nextSibling; - }); - } else if (next2.subtree !== void 0) { - stack.push({ prev: prev2, next: next2, parent }); - } - } - return out; -} -function createElementNode({ prev, next, dispatch, stack }) { - const namespace = next.namespace || "http://www.w3.org/1999/xhtml"; - const canMorph = prev && prev.nodeType === Node.ELEMENT_NODE && prev.localName === next.tag && prev.namespaceURI === (next.namespace || "http://www.w3.org/1999/xhtml"); - const el2 = canMorph ? prev : namespace ? document.createElementNS(namespace, next.tag) : document.createElement(next.tag); - let handlersForEl; - if (!registeredHandlers.has(el2)) { - const emptyHandlers = /* @__PURE__ */ new Map(); - registeredHandlers.set(el2, emptyHandlers); - handlersForEl = emptyHandlers; - } else { - handlersForEl = registeredHandlers.get(el2); - } - const prevHandlers = canMorph ? new Set(handlersForEl.keys()) : null; - const prevAttributes = canMorph ? new Set(Array.from(prev.attributes, (a) => a.name)) : null; - let className = null; - let style = null; - let innerHTML = null; - for (const attr of next.attrs) { - const name = attr[0]; - const value = attr[1]; - 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); - if (!handlersForEl.has(eventName)) { - el2.addEventListener(eventName, lustreGenericEventHandler); - } - handlersForEl.set(eventName, callback); - if (canMorph) - prevHandlers.delete(eventName); - } else if (name.startsWith("data-lustre-on-")) { - const eventName = name.slice(15); - const callback = dispatch(lustreServerEventHandler); - if (!handlersForEl.has(eventName)) { - el2.addEventListener(eventName, lustreGenericEventHandler); - } - handlersForEl.set(eventName, callback); - el2.setAttribute(name, value); - } else if (name === "class") { - className = className === null ? value : className + " " + value; - } else if (name === "style") { - style = style === null ? value : style + value; - } else if (name === "dangerous-unescaped-html") { - innerHTML = value; - } else { - if (el2.getAttribute(name) !== value) - el2.setAttribute(name, value); - if (name === "value" || name === "selected") - el2[name] = value; - if (canMorph) - prevAttributes.delete(name); - } - } - if (className !== null) { - el2.setAttribute("class", className); - if (canMorph) - prevAttributes.delete("class"); - } - if (style !== null) { - el2.setAttribute("style", style); - if (canMorph) - prevAttributes.delete("style"); - } - if (canMorph) { - for (const attr of prevAttributes) { - el2.removeAttribute(attr); - } - for (const eventName of prevHandlers) { - handlersForEl.delete(eventName); - el2.removeEventListener(eventName, lustreGenericEventHandler); - } - } - if (next.key !== void 0 && next.key !== "") { - el2.setAttribute("data-lustre-key", next.key); - } else if (innerHTML !== null) { - el2.innerHTML = innerHTML; - return el2; - } - let prevChild = el2.firstChild; - let seenKeys = null; - let keyedChildren = null; - let incomingKeyedChildren = null; - let firstChild = next.children[Symbol.iterator]().next().value; - if (canMorph && firstChild !== void 0 && // Explicit checks are more verbose but truthy checks force a bunch of comparisons - // we don't care about: it's never gonna be a number etc. - firstChild.key !== void 0 && firstChild.key !== "") { - seenKeys = /* @__PURE__ */ new Set(); - keyedChildren = getKeyedChildren(prev); - incomingKeyedChildren = getKeyedChildren(next); - } - for (const child of next.children) { - iterateElement(child, (currElement) => { - if (currElement.key !== void 0 && seenKeys !== null) { - prevChild = diffKeyedChild( - prevChild, - currElement, - el2, - stack, - incomingKeyedChildren, - keyedChildren, - seenKeys - ); - } else { - stack.unshift({ prev: prevChild, next: currElement, parent: el2 }); - prevChild = prevChild?.nextSibling; - } - }); - } - while (prevChild) { - const next2 = prevChild.nextSibling; - el2.removeChild(prevChild); - prevChild = next2; - } - return el2; -} -var registeredHandlers = /* @__PURE__ */ new WeakMap(); -function lustreGenericEventHandler(event2) { - const target = event2.currentTarget; - if (!registeredHandlers.has(target)) { - target.removeEventListener(event2.type, lustreGenericEventHandler); - return; - } - const handlersForEventTarget = registeredHandlers.get(target); - if (!handlersForEventTarget.has(event2.type)) { - target.removeEventListener(event2.type, lustreGenericEventHandler); - return; - } - handlersForEventTarget.get(event2.type)(event2); -} -function lustreServerEventHandler(event2) { - const el2 = event2.currentTarget; - const tag = el2.getAttribute(`data-lustre-on-${event2.type}`); - const data = JSON.parse(el2.getAttribute("data-lustre-data") || "{}"); - const include = JSON.parse(el2.getAttribute("data-lustre-include") || "[]"); - switch (event2.type) { - case "input": - case "change": - include.push("target.value"); - break; - } - return { - tag, - data: include.reduce( - (data2, property) => { - const path = property.split("."); - for (let i = 0, o = data2, e = event2; i < path.length; i++) { - if (i === path.length - 1) { - o[path[i]] = e[path[i]]; - } else { - o[path[i]] ??= {}; - e = e[path[i]]; - o = o[path[i]]; - } - } - return data2; - }, - { data } - ) - }; -} -function getKeyedChildren(el2) { - const keyedChildren = /* @__PURE__ */ new Map(); - if (el2) { - for (const child of el2.children) { - 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, stack, 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) => { - stack.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}`); - stack.unshift({ prev: null, next: child, parent: el2 }); - return prevChild; - } - seenKeys.add(child.key); - const keyedChild = keyedChildren.get(child.key); - if (!keyedChild && !prevChild) { - stack.unshift({ prev: null, next: child, parent: el2 }); - return prevChild; - } - if (!keyedChild && prevChild !== null) { - const placeholder = document.createTextNode(""); - el2.insertBefore(placeholder, prevChild); - stack.unshift({ prev: placeholder, next: child, parent: el2 }); - return prevChild; - } - if (!keyedChild || keyedChild === prevChild) { - stack.unshift({ prev: prevChild, next: child, parent: el2 }); - prevChild = prevChild?.nextSibling; - return prevChild; - } - el2.insertBefore(keyedChild, prevChild); - stack.unshift({ prev: keyedChild, next: child, parent: el2 }); - return prevChild; -} -function iterateElement(element2, processElement) { - if (element2.elements !== void 0) { - for (const currElement of element2.elements) { - processElement(currElement); - } - } else { - processElement(element2); - } -} - -// build/dev/javascript/lustre/client-runtime.ffi.mjs -var LustreClientApplication2 = class _LustreClientApplication { - #root = null; - #queue = []; - #effects = []; - #didUpdate = false; - #isComponent = false; - #model = null; - #update = null; - #view = null; - static start(flags, selector, init3, update3, view2) { - if (!is_browser()) - return new Error(new NotABrowser()); - const root2 = selector instanceof HTMLElement ? selector : document.querySelector(selector); - if (!root2) - return new Error(new ElementNotFound(selector)); - const app = new _LustreClientApplication(init3(flags), update3, view2, root2); - return new Ok((msg) => app.send(msg)); - } - constructor([model, effects], update3, view2, root2 = document.body, isComponent = false) { - this.#model = model; - this.#update = update3; - this.#view = view2; - this.#root = root2; - this.#effects = effects.all.toArray(); - this.#didUpdate = true; - this.#isComponent = isComponent; - window.requestAnimationFrame(() => this.#tick()); - } - send(action) { - switch (true) { - case action instanceof Dispatch: { - this.#queue.push(action[0]); - this.#tick(); - return; - } - case action instanceof Shutdown: { - this.#shutdown(); - return; - } - case action instanceof Debug: { - this.#debug(action[0]); - return; - } - default: - return; - } - } - emit(event2, data) { - this.#root.dispatchEvent( - new CustomEvent(event2, { - bubbles: true, - detail: data, - composed: true - }) - ); - } - #tick() { - this.#flush_queue(); - if (this.#didUpdate) { - const vdom = this.#view(this.#model); - const dispatch = (handler) => (e) => { - const result = handler(e); - if (result instanceof Ok) { - this.send(new Dispatch(result[0])); - } - }; - this.#didUpdate = false; - this.#root = morph(this.#root, vdom, dispatch, this.#isComponent); - } - } - #flush_queue(iterations = 0) { - while (this.#queue.length) { - const [next, effects] = this.#update(this.#model, this.#queue.shift()); - this.#didUpdate ||= this.#model !== next; - this.#model = next; - this.#effects = this.#effects.concat(effects.all.toArray()); - } - while (this.#effects.length) { - this.#effects.shift()( - (msg) => this.send(new Dispatch(msg)), - (event2, data) => this.emit(event2, data) - ); - } - if (this.#queue.length) { - if (iterations < 5) { - this.#flush_queue(++iterations); - } else { - window.requestAnimationFrame(() => this.#tick()); - } - } - } - #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; - this.#model = null; - this.#queue = []; - this.#effects = []; - this.#didUpdate = false; - this.#update = () => { - }; - this.#view = () => { - }; - } -}; -var start = (app, selector, flags) => LustreClientApplication2.start( - flags, - selector, - app.init, - app.update, - app.view -); -var is_browser = () => globalThis.window && window.document; - -// build/dev/javascript/lustre/lustre.mjs -var App = class extends CustomType { - constructor(init3, update3, view2, on_attribute_change) { - super(); - this.init = init3; - this.update = update3; - this.view = view2; - this.on_attribute_change = on_attribute_change; - } -}; -var ElementNotFound = class extends CustomType { - constructor(selector) { - super(); - this.selector = selector; - } -}; -var NotABrowser = class extends CustomType { -}; -function application(init3, update3, view2) { - return new App(init3, update3, view2, new None()); -} -function simple(init3, update3, view2) { - let init$1 = (flags) => { - return [init3(flags), none()]; - }; - let update$1 = (model, msg) => { - return [update3(model, msg), none()]; - }; - return application(init$1, update$1, view2); -} -function start3(app, selector, flags) { - return guard( - !is_browser(), - new Error(new NotABrowser()), - () => { - return start(app, selector, flags); - } - ); -} - -// build/dev/javascript/lustre/lustre/element/html.mjs -function div(attrs, children) { - return element("div", attrs, children); -} -function p(attrs, children) { - return element("p", attrs, children); -} -function button(attrs, children) { - return element("button", attrs, children); -} - -// build/dev/javascript/lustre/lustre/event.mjs -function on2(name, handler) { - return on(name, handler); -} -function on_click(msg) { - return on2("click", (_) => { - return new Ok(msg); - }); -} - -// build/dev/javascript/aurinko_frontend/aurinko_frontend.mjs -var Incr = class extends CustomType { -}; -var Decr = class extends CustomType { -}; -function init2(_) { - return 0; -} -function update2(model, msg) { - if (msg instanceof Incr) { - return model + 1; - } else { - return model - 1; - } -} -function view(model) { - let count = to_string(model); - return div( - toList([]), - toList([ - button(toList([on_click(new Incr())]), toList([text(" + ")])), - p(toList([]), toList([text(count)])), - button(toList([on_click(new Decr())]), toList([text(" - ")])) - ]) - ); -} -function main() { - let app = simple(init2, update2, view); - let $ = start3(app, "#app", void 0); - if (!$.isOk()) { - throw makeError( - "assignment_no_match", - "aurinko_frontend", - 9, - "main", - "Assignment pattern did not match", - { value: $ } - ); - } - return void 0; -} - -// build/.lustre/entry.mjs -main();