fix(checkout): split checkout_page into helpers to avoid single-function OOM in elc --emit-header
Dev — Build & local smoke test / build-smoke (pull_request) Failing after 11m34s
Dev — Build & local smoke test / build-smoke (pull_request) Failing after 11m34s
Extract nav and style blocks into checkout_nav_html() and checkout_style_html() so the compiler processes each template in isolation rather than one 490-line function with mixed HTML template AST and BinOp string concat.
This commit is contained in:
+19
-33
@@ -11,6 +11,17 @@
|
||||
// 4. User fills name, email, card - submits
|
||||
// 5. stripe.confirmPayment() → redirects to /marketplace/success
|
||||
|
||||
fn checkout_nav_html() -> String {
|
||||
<nav id="nav">
|
||||
<div class="nav-inner">
|
||||
<a href="/" class="nav-logo" aria-label="Neuron home"><img src="/assets/brand/neuron-wordmark-on-light.png" srcset="/assets/brand/neuron-wordmark-on-light@2x.png 2x" alt="Neuron" height="28"></a>
|
||||
<div class="nav-links">
|
||||
<a href="/" class="nav-link">← Back</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
}
|
||||
|
||||
fn checkout_page(plan: String, pub_key: String) -> String {
|
||||
let is_founding: Bool = str_eq(plan, "founding")
|
||||
let is_free: Bool = str_eq(plan, "free")
|
||||
@@ -53,17 +64,9 @@ fn checkout_page(plan: String, pub_key: String) -> String {
|
||||
<li>2 devices included</li>"
|
||||
} }
|
||||
|
||||
return
|
||||
<nav id="nav">
|
||||
<div class="nav-inner">
|
||||
<a href="/" class="nav-logo" aria-label="Neuron home"><img src="/assets/brand/neuron-wordmark-on-light.png" srcset="/assets/brand/neuron-wordmark-on-light@2x.png 2x" alt="Neuron" height="28"></a>
|
||||
<div class="nav-links">
|
||||
<a href="/" class="nav-link">← Back</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
let nav_html: String = checkout_nav_html()
|
||||
|
||||
<main style="min-height: 100vh; padding: clamp(6rem, 14vh, 9rem) 2rem 4rem;">
|
||||
let main_html: String = <main style="min-height: 100vh; padding: clamp(6rem, 14vh, 9rem) 2rem 4rem;">
|
||||
<div class="checkout-shell">
|
||||
|
||||
<!-- Left: order summary -->
|
||||
@@ -236,23 +239,14 @@ fn checkout_page(plan: String, pub_key: String) -> String {
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<!-- Supabase JS -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/@supabase/supabase-js@2/dist/umd/supabase.js"></script>
|
||||
<!-- Stripe.js -->
|
||||
<script src="https://js.stripe.com/v3/" async></script>
|
||||
let style_html: String = checkout_style_html()
|
||||
|
||||
<style>
|
||||
.checkout-shell {
|
||||
max-width: 960px;
|
||||
margin: 0 auto;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 5rem;
|
||||
align-items: start;
|
||||
}
|
||||
@media (max-width: 720px) {
|
||||
.checkout-shell { grid-template-columns: 1fr; gap: 3rem; }
|
||||
let free_init_script: String = if is_free { "<script>document.addEventListener('DOMContentLoaded',function(){window.neuronCheckoutFree&&window.neuronCheckoutFree()});</script>" } else { "" }
|
||||
return nav_html + main_html + "<!-- Supabase JS --><script src=\"https://cdn.jsdelivr.net/npm/@supabase/supabase-js@2/dist/umd/supabase.js\"></script><!-- Stripe.js --><script src=\"https://js.stripe.com/v3/\" async></script>" + style_html + "<script src=\"/js/checkout-auth.js\" defer></script><script>window.NEURON_CFG=window.NEURON_CFG||{};window.NEURON_CFG.plan=\"{plan}\";window.NEURON_CFG.pub_key=\"{pub_key}\";</script><script src=\"/js/checkout-stripe.js\" defer></script>" + free_init_script
|
||||
}
|
||||
|
||||
fn checkout_style_html() -> String {
|
||||
<style>
|
||||
.checkout-plan-name {
|
||||
font-family: var(--head);
|
||||
font-size: clamp(1.5rem, 3vw, 2rem);
|
||||
@@ -494,12 +488,4 @@ fn checkout_page(plan: String, pub_key: String) -> String {
|
||||
}
|
||||
.checkout-auth-badge strong { color: var(--navy); font-weight: 500; }
|
||||
</style>
|
||||
|
||||
<script src="/js/checkout-auth.js" defer></script>
|
||||
|
||||
<script>window.NEURON_CFG=window.NEURON_CFG||{};window.NEURON_CFG.plan="{plan}";window.NEURON_CFG.pub_key="{pub_key}";</script><script src="/js/checkout-stripe.js" defer></script>
|
||||
|
||||
{#if is_free}
|
||||
<script>document.addEventListener('DOMContentLoaded',function(){window.neuronCheckoutFree&&window.neuronCheckoutFree()});</script>
|
||||
{/if}
|
||||
}
|
||||
|
||||
+4
-3
@@ -1966,7 +1966,8 @@ fn page_open() -> String {
|
||||
}
|
||||
|
||||
fn page_close() -> String {
|
||||
return <script src="/js/chat-widget.js" defer></script>
|
||||
let widgets: String = <div id="page-widgets">
|
||||
<script src="/js/chat-widget.js" defer></script>
|
||||
|
||||
<!-- ── Neuron Demo Chat Widget ──────────────────────────────────────────────── -->
|
||||
<div id="neuron-demo-btn">
|
||||
@@ -2023,6 +2024,6 @@ fn page_close() -> String {
|
||||
</div>
|
||||
|
||||
<script src="/js/styles.js" defer></script>
|
||||
</body>
|
||||
</html>
|
||||
</div>
|
||||
return widgets + "</body></html>"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user