@mateosuarezdev/flash 0.0.6 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,47 @@
1
+ /**
2
+ * @license
3
+ * Flash
4
+ * Copyright (c) 2025 Mateo Suarez. All rights reserved.
5
+ *
6
+ * Free to use in your own personal or commercial applications and projects.
7
+ * Unauthorized copying, modification, or distribution is strictly prohibited.
8
+ * See LICENSE file for full terms.
9
+ */
10
+
11
+ let e = null;
12
+ function o() {
13
+ return e;
14
+ }
15
+ function a(r) {
16
+ e = r;
17
+ }
18
+ function c() {
19
+ return {
20
+ _parent: e
21
+ };
22
+ }
23
+ function u() {
24
+ e = null;
25
+ }
26
+ function p(r, n) {
27
+ if (!e)
28
+ throw new Error("provideServerContext called outside of component render");
29
+ e._contextMap || (e._contextMap = /* @__PURE__ */ new Map()), e._contextMap.set(r, n);
30
+ }
31
+ function s(r, n) {
32
+ let t = e;
33
+ for (; t; ) {
34
+ if (t._contextMap?.has(r))
35
+ return t._contextMap.get(r);
36
+ t = t._parent;
37
+ }
38
+ return n;
39
+ }
40
+ export {
41
+ s as a,
42
+ c,
43
+ o as g,
44
+ p,
45
+ u as r,
46
+ a as s
47
+ };
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @license
3
+ * Flash
4
+ * Copyright (c) 2025 Mateo Suarez. All rights reserved.
5
+ *
6
+ * Free to use in your own personal or commercial applications and projects.
7
+ * Unauthorized copying, modification, or distribution is strictly prohibited.
8
+ * See LICENSE file for full terms.
9
+ */
10
+
11
+ "use strict";let e=null;function o(){return e}function u(r){e=r}function c(){return{_parent:e}}function v(){e=null}function i(r,n){if(!e)throw new Error("provideServerContext called outside of component render");e._contextMap||(e._contextMap=new Map),e._contextMap.set(r,n)}function S(r,n){let t=e;for(;t;){if(t._contextMap?.has(r))return t._contextMap.get(r);t=t._parent}return n}exports.consumeServerContext=S;exports.createServerVNode=c;exports.getCurrentServerVNode=o;exports.provideServerContext=i;exports.resetServerContext=v;exports.setCurrentServerVNode=u;
package/dist/server.cjs CHANGED
@@ -8,11 +8,11 @@
8
8
  * See LICENSE file for full terms.
9
9
  */
10
10
 
11
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("node:fs/promises"),m=require("node:path");function A(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function b(t){return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}const v=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]);function H(t){return/^on[A-Z]/.test(t)}function j(t){return Object.entries(t).map(([r,o])=>`${r.replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`)}:${o}`).join(";")}function E(t,r=!0){const o=Object.entries(t).filter(([e,n])=>!(n==null||r&&e==="children"||e==="innerHTML"||H(e))).map(([e,n])=>(e==="className"&&(e="class"),e==="style"&&typeof n=="object"&&(n=j(n)),typeof n=="boolean"?n?e:"":`${e}="${b(String(n))}"`)).filter(Boolean).join(" ");return o?` ${o}`:""}function $(t){return t?Array.isArray(t)?t:[t]:[]}function T(t){return t&&typeof t.then=="function"}function h(t,r){return`<div id="${t}" data-server-component="suspended" data-component-name="${r}">Loading...</div>`}const l=new Map;let d=0;function w(t){return l.clear(),d=0,s(t)}async function D(t){l.clear(),d=0;let r=s(t);for(;l.size>0;){console.log(`🔄 Resolving ${l.size} async components in parallel...`);const o=Array.from(l.entries());l.clear();const e=await Promise.allSettled(o.map(([n,{promise:i}])=>i));for(let n=0;n<o.length;n++){const i=o[n];if(!i)continue;const[a,{componentName:c,errorFallback:u}]=i,p=e[n];if(!p)continue;const y=h(a,c);if(p.status==="fulfilled")try{console.log(`✅ Resolved: ${c} (${a})`);const f=s(p.value);r=r.replace(y,f)}catch(f){console.error(`❌ Error rendering ${c}:`,f);const S=u?s(typeof u=="function"?u(f):u):`<div class="error">Error rendering ${c}</div>`;r=r.replace(y,S)}else{console.error(`❌ Error resolving ${c}:`,p.reason);const f=u?s(typeof u=="function"?u(p.reason):u):`<div class="error">Error loading ${c}</div>`;r=r.replace(y,f)}}}return console.log("✅ All async components resolved!"),r}async function*P(t){for(l.clear(),d=0,yield s(t);l.size>0;){const o=Array.from(l.entries());l.clear();const e=o.map(async([n,{promise:i}])=>{try{const a=await i,c=s(a);return`<script>
11
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./server-context-BPTFSl-d.cjs"),$=require("node:fs/promises"),g=require("node:path");function N(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function b(t){return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}const C=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]);function H(t){return/^on[A-Z]/.test(t)}function j(t){return Object.entries(t).map(([r,o])=>`${r.replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`)}:${o}`).join(";")}function E(t,r=!0){const o=Object.entries(t).filter(([e,n])=>!(n==null||r&&e==="children"||e==="innerHTML"||H(e))).map(([e,n])=>(e==="className"&&(e="class"),e==="style"&&typeof n=="object"&&(n=j(n)),typeof n=="boolean"?n?e:"":`${e}="${b(String(n))}"`)).filter(Boolean).join(" ");return o?` ${o}`:""}function v(t){return t?Array.isArray(t)?t:[t]:[]}function T(t){return t&&typeof t.then=="function"}function S(t,r){return`<div id="${t}" data-server-component="suspended" data-component-name="${r}">Loading...</div>`}const d=new Map;let y=0;function w(t){return d.clear(),y=0,u.resetServerContext(),c(t)}async function D(t){d.clear(),y=0,u.resetServerContext();let r=c(t);for(;d.size>0;){console.log(`🔄 Resolving ${d.size} async components in parallel...`);const o=Array.from(d.entries());d.clear();const e=await Promise.allSettled(o.map(([n,{promise:a}])=>a));for(let n=0;n<o.length;n++){const a=o[n];if(!a)continue;const[l,{componentName:s,errorFallback:i,parentNode:f}]=a,m=e[n];if(!m)continue;const h=S(l,s);if(m.status==="fulfilled")try{console.log(`✅ Resolved: ${s} (${l})`),u.setCurrentServerVNode(f);const p=c(m.value);r=r.replace(h,p)}catch(p){console.error(`❌ Error rendering ${s}:`,p),u.setCurrentServerVNode(f);const A=i?c(typeof i=="function"?i(p):i):`<div class="error">Error rendering ${s}</div>`;r=r.replace(h,A)}else{console.error(`❌ Error resolving ${s}:`,m.reason),u.setCurrentServerVNode(f);const p=i?c(typeof i=="function"?i(m.reason):i):`<div class="error">Error loading ${s}</div>`;r=r.replace(h,p)}}}return console.log("✅ All async components resolved!"),r}async function*x(t){for(d.clear(),y=0,u.resetServerContext(),yield c(t);d.size>0;){const o=Array.from(d.entries());d.clear();const e=o.map(async([n,{promise:a,parentNode:l}])=>{try{const s=await a;u.setCurrentServerVNode(l);const i=c(s);return`<script>
12
12
  (function() {
13
13
  const el = document.getElementById('${n}');
14
14
  if (el) {
15
- el.outerHTML = \`${c.replace(/`/g,"\\`").replace(/\$/g,"\\$")}\`;
15
+ el.outerHTML = \`${i.replace(/`/g,"\\`").replace(/\$/g,"\\$")}\`;
16
16
  }
17
17
  })();
18
18
  <\/script>`}catch{return`<script>
@@ -22,6 +22,6 @@
22
22
  el.innerHTML = '<div class="error">Error loading component</div>';
23
23
  }
24
24
  })();
25
- <\/script>`}});for(const n of e)yield await n}}function s(t){if(typeof t=="function"){const e=t();return Array.isArray(e)?`<!--reactive-list-->${e.map(i=>s(i)).join("")}`:s(e)}if(typeof t=="string")return A(t);if(typeof t=="number")return String(t);if(Array.isArray(t))return t.map(e=>s(e)).join("");if(!t||typeof t!="object")return"";const{type:r,props:o}=t;if(r===Symbol.for("jsx.fragment"))return $(o.children).map(n=>s(n)).join("");if(typeof r=="string"&&r==="suspended"){const e=t,n=`async-${d++}`;return console.log(`⏳ Suspending: ${e._componentName} (${n})`),l.set(n,{id:n,promise:e.promise,componentName:e._componentName,errorFallback:e.errorFallback}),h(n,e._componentName)}if(typeof r=="function"){const e=r(o);if(T(e)){const n=`async-${d++}`,i=r.name||"AsyncComponent";return console.warn(`⚠️ DEPRECATED: Direct async component "${i}" detected. Please use suspend() HOF instead for better type safety and custom fallbacks.
26
- Example: const ${i} = suspend(async (props) => { ... }, <Loading />, <Error />);`),console.log(`⏳ Suspending: ${i} (${n})`),l.set(n,{id:n,promise:e,componentName:i}),h(n,i)}return s(e)}if(typeof r=="string"){const e=E(o);if(v.has(r))return`<${r}${e} />`;if(o.innerHTML!==void 0){const a=typeof o.innerHTML=="object"?JSON.stringify(o.innerHTML):o.innerHTML;return`<${r}${e}>${a}</${r}>`}const i=$(o.children).map(a=>{if(Array.isArray(a))return a.map(c=>s(c)).join("");if(typeof a=="function"){const c=a();return Array.isArray(c)?`<!--reactive-list-->${c.map(p=>s(p)).join("")}`:`<!--reactive-->${s(c)}`}return s(a)}).join("");return r==="html"?`<!DOCTYPE html>
27
- <html${e}>${i}</html>`:`<${r}${e}>${i}</${r}>`}return""}class L{cacheDir;useDirectoryStructure;constructor(r={}){this.cacheDir=r.cacheDir||"./cache/html",this.useDirectoryStructure=r.useDirectoryStructure??!1}async save(r,o){const e=this.getFilepath(r);return await g.mkdir(m.dirname(e),{recursive:!0}),await Bun.write(e,o),console.log(`✅ Pre-rendered: ${r} → ${e}`),e}async load(r){const o=this.getFilepath(r),e=Bun.file(o);return await e.exists()?e:null}async clear(){await g.rm(this.cacheDir,{recursive:!0,force:!0}),await g.mkdir(this.cacheDir,{recursive:!0}),console.log("🗑️ Cache cleared")}async exists(r){const o=this.getFilepath(r);return await Bun.file(o).exists()}getFilepath(r){const o=r.replace(/^\/+|\/+$/g,"");if(this.useDirectoryStructure)return o===""?m.join(this.cacheDir,"index.html"):m.join(this.cacheDir,o,"index.html");{const e=o===""?"index.html":`${o.replace(/\//g,"-")}.html`;return m.join(this.cacheDir,e)}}}exports.PreRenderer=L;exports.renderToStream=P;exports.renderToString=w;exports.renderToStringAsync=D;
25
+ <\/script>`}});for(const n of e)yield await n}}function c(t){if(typeof t=="function"){const e=t();return Array.isArray(e)?`<!--reactive-list-->${e.map(a=>c(a)).join("")}`:c(e)}if(typeof t=="string")return N(t);if(typeof t=="number")return String(t);if(Array.isArray(t))return t.map(e=>c(e)).join("");if(!t||typeof t!="object")return"";const{type:r,props:o}=t;if(r===Symbol.for("jsx.fragment"))return v(o.children).map(n=>c(n)).join("");if(typeof r=="string"&&r==="suspended"){const e=t,n=`async-${y++}`;return console.log(`⏳ Suspending: ${e._componentName} (${n})`),d.set(n,{id:n,promise:e.promise,componentName:e._componentName,errorFallback:e.errorFallback,parentNode:u.getCurrentServerVNode()}),S(n,e._componentName)}if(typeof r=="function"){const e=u.createServerVNode(),n=u.getCurrentServerVNode();u.setCurrentServerVNode(e);const a=r(o);if(T(a)){const s=`async-${y++}`,i=r.name||"AsyncComponent";return console.warn(`⚠️ DEPRECATED: Direct async component "${i}" detected. Please use suspend() HOF instead for better type safety and custom fallbacks.
26
+ Example: const ${i} = suspend(async (props) => { ... }, <Loading />, <Error />);`),console.log(`⏳ Suspending: ${i} (${s})`),d.set(s,{id:s,promise:a,componentName:i,parentNode:e}),u.setCurrentServerVNode(n),S(s,i)}const l=c(a);return u.setCurrentServerVNode(n),l}if(typeof r=="string"){const e=E(o);if(C.has(r))return`<${r}${e} />`;if(o.innerHTML!==void 0){const l=typeof o.innerHTML=="object"?JSON.stringify(o.innerHTML):o.innerHTML;return`<${r}${e}>${l}</${r}>`}const a=v(o.children).map(l=>{if(Array.isArray(l))return l.map(s=>c(s)).join("");if(typeof l=="function"){const s=l();return Array.isArray(s)?`<!--reactive-list-->${s.map(f=>c(f)).join("")}`:`<!--reactive-->${c(s)}`}return c(l)}).join("");return r==="html"?`<!DOCTYPE html>
27
+ <html${e}>${a}</html>`:`<${r}${e}>${a}</${r}>`}return""}class P{cacheDir;useDirectoryStructure;constructor(r={}){this.cacheDir=r.cacheDir||"./cache/html",this.useDirectoryStructure=r.useDirectoryStructure??!1}async save(r,o){const e=this.getFilepath(r);return await $.mkdir(g.dirname(e),{recursive:!0}),await Bun.write(e,o),console.log(`✅ Pre-rendered: ${r} → ${e}`),e}async load(r){const o=this.getFilepath(r),e=Bun.file(o);return await e.exists()?e:null}async clear(){await $.rm(this.cacheDir,{recursive:!0,force:!0}),await $.mkdir(this.cacheDir,{recursive:!0}),console.log("🗑️ Cache cleared")}async exists(r){const o=this.getFilepath(r);return await Bun.file(o).exists()}getFilepath(r){const o=r.replace(/^\/+|\/+$/g,"");if(this.useDirectoryStructure)return o===""?g.join(this.cacheDir,"index.html"):g.join(this.cacheDir,o,"index.html");{const e=o===""?"index.html":`${o.replace(/\//g,"-")}.html`;return g.join(this.cacheDir,e)}}}exports.PreRenderer=P;exports.renderToStream=x;exports.renderToString=w;exports.renderToStringAsync=D;
package/dist/server.js CHANGED
@@ -8,15 +8,16 @@
8
8
  * See LICENSE file for full terms.
9
9
  */
10
10
 
11
- import { mkdir as h, rm as S } from "node:fs/promises";
12
- import { dirname as b, join as y } from "node:path";
13
- function v(t) {
11
+ import { s as p, g as v, c as E, r as S } from "./server-context-BA2xc7wp.js";
12
+ import { mkdir as A, rm as N } from "node:fs/promises";
13
+ import { dirname as w, join as h } from "node:path";
14
+ function D(t) {
14
15
  return t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
15
16
  }
16
- function H(t) {
17
+ function j(t) {
17
18
  return t.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
18
19
  }
19
- const E = /* @__PURE__ */ new Set([
20
+ const T = /* @__PURE__ */ new Set([
20
21
  "area",
21
22
  "base",
22
23
  "br",
@@ -31,84 +32,86 @@ const E = /* @__PURE__ */ new Set([
31
32
  "track",
32
33
  "wbr"
33
34
  ]);
34
- function w(t) {
35
+ function C(t) {
35
36
  return /^on[A-Z]/.test(t);
36
37
  }
37
- function D(t) {
38
+ function L(t) {
38
39
  return Object.entries(t).map(([r, o]) => `${r.replace(/[A-Z]/g, (n) => `-${n.toLowerCase()}`)}:${o}`).join(";");
39
40
  }
40
- function j(t, r = !0) {
41
- const o = Object.entries(t).filter(([e, n]) => !(n == null || r && e === "children" || e === "innerHTML" || w(e))).map(([e, n]) => (e === "className" && (e = "class"), e === "style" && typeof n == "object" && (n = D(n)), typeof n == "boolean" ? n ? e : "" : `${e}="${H(String(n))}"`)).filter(Boolean).join(" ");
41
+ function x(t, r = !0) {
42
+ const o = Object.entries(t).filter(([e, n]) => !(n == null || r && e === "children" || e === "innerHTML" || C(e))).map(([e, n]) => (e === "className" && (e = "class"), e === "style" && typeof n == "object" && (n = L(n)), typeof n == "boolean" ? n ? e : "" : `${e}="${j(String(n))}"`)).filter(Boolean).join(" ");
42
43
  return o ? ` ${o}` : "";
43
44
  }
44
- function $(t) {
45
+ function b(t) {
45
46
  return t ? Array.isArray(t) ? t : [t] : [];
46
47
  }
47
- function T(t) {
48
+ function P(t) {
48
49
  return t && typeof t.then == "function";
49
50
  }
50
- function g(t, r) {
51
+ function $(t, r) {
51
52
  return `<div id="${t}" data-server-component="suspended" data-component-name="${r}">Loading...</div>`;
52
53
  }
53
- const l = /* @__PURE__ */ new Map();
54
- let d = 0;
55
- function P(t) {
56
- return l.clear(), d = 0, s(t);
54
+ const u = /* @__PURE__ */ new Map();
55
+ let y = 0;
56
+ function B(t) {
57
+ return u.clear(), y = 0, S(), c(t);
57
58
  }
58
- async function x(t) {
59
- l.clear(), d = 0;
60
- let r = s(t);
61
- for (; l.size > 0; ) {
59
+ async function I(t) {
60
+ u.clear(), y = 0, S();
61
+ let r = c(t);
62
+ for (; u.size > 0; ) {
62
63
  console.log(
63
- `🔄 Resolving ${l.size} async components in parallel...`
64
+ `🔄 Resolving ${u.size} async components in parallel...`
64
65
  );
65
- const o = Array.from(l.entries());
66
- l.clear();
66
+ const o = Array.from(u.entries());
67
+ u.clear();
67
68
  const e = await Promise.allSettled(
68
- o.map(([n, { promise: i }]) => i)
69
+ o.map(([n, { promise: a }]) => a)
69
70
  );
70
71
  for (let n = 0; n < o.length; n++) {
71
- const i = o[n];
72
- if (!i) continue;
73
- const [a, { componentName: c, errorFallback: u }] = i, p = e[n];
74
- if (!p) continue;
75
- const m = g(a, c);
76
- if (p.status === "fulfilled")
72
+ const a = o[n];
73
+ if (!a) continue;
74
+ const [l, { componentName: i, errorFallback: s, parentNode: d }] = a, m = e[n];
75
+ if (!m) continue;
76
+ const g = $(l, i);
77
+ if (m.status === "fulfilled")
77
78
  try {
78
- console.log(`✅ Resolved: ${c} (${a})`);
79
- const f = s(p.value);
80
- r = r.replace(m, f);
79
+ console.log(`✅ Resolved: ${i} (${l})`), p(d);
80
+ const f = c(m.value);
81
+ r = r.replace(g, f);
81
82
  } catch (f) {
82
- console.error(`❌ Error rendering ${c}:`, f);
83
- const A = u ? s(
84
- typeof u == "function" ? u(f) : u
85
- ) : `<div class="error">Error rendering ${c}</div>`;
86
- r = r.replace(m, A);
83
+ console.error(`❌ Error rendering ${i}:`, f), p(d);
84
+ const H = s ? c(
85
+ typeof s == "function" ? s(f) : s
86
+ ) : `<div class="error">Error rendering ${i}</div>`;
87
+ r = r.replace(g, H);
87
88
  }
88
89
  else {
89
- console.error(`❌ Error resolving ${c}:`, p.reason);
90
- const f = u ? s(
91
- typeof u == "function" ? u(p.reason) : u
92
- ) : `<div class="error">Error loading ${c}</div>`;
93
- r = r.replace(m, f);
90
+ console.error(`❌ Error resolving ${i}:`, m.reason), p(d);
91
+ const f = s ? c(
92
+ typeof s == "function" ? s(m.reason) : s
93
+ ) : `<div class="error">Error loading ${i}</div>`;
94
+ r = r.replace(g, f);
94
95
  }
95
96
  }
96
97
  }
97
98
  return console.log("✅ All async components resolved!"), r;
98
99
  }
99
- async function* C(t) {
100
- for (l.clear(), d = 0, yield s(t); l.size > 0; ) {
101
- const o = Array.from(l.entries());
102
- l.clear();
100
+ async function* O(t) {
101
+ for (u.clear(), y = 0, S(), yield c(t); u.size > 0; ) {
102
+ const o = Array.from(u.entries());
103
+ u.clear();
103
104
  const e = o.map(
104
- async ([n, { promise: i }]) => {
105
+ async ([n, { promise: a, parentNode: l }]) => {
105
106
  try {
106
- const a = await i, c = s(a);
107
+ const i = await a;
108
+ p(l);
109
+ const s = c(i);
107
110
  return `<script>
108
111
  (function() {
109
112
  const el = document.getElementById('${n}');
110
113
  if (el) {
111
- el.outerHTML = \`${c.replace(/`/g, "\\`").replace(/\$/g, "\\$")}\`;
114
+ el.outerHTML = \`${s.replace(/`/g, "\\`").replace(/\$/g, "\\$")}\`;
112
115
  }
113
116
  })();
114
117
  <\/script>`;
@@ -128,72 +131,76 @@ async function* C(t) {
128
131
  yield await n;
129
132
  }
130
133
  }
131
- function s(t) {
134
+ function c(t) {
132
135
  if (typeof t == "function") {
133
136
  const e = t();
134
- return Array.isArray(e) ? `<!--reactive-list-->${e.map((i) => s(i)).join("")}` : s(e);
137
+ return Array.isArray(e) ? `<!--reactive-list-->${e.map((a) => c(a)).join("")}` : c(e);
135
138
  }
136
139
  if (typeof t == "string")
137
- return v(t);
140
+ return D(t);
138
141
  if (typeof t == "number")
139
142
  return String(t);
140
143
  if (Array.isArray(t))
141
- return t.map((e) => s(e)).join("");
144
+ return t.map((e) => c(e)).join("");
142
145
  if (!t || typeof t != "object")
143
146
  return "";
144
147
  const { type: r, props: o } = t;
145
148
  if (r === Symbol.for("jsx.fragment"))
146
- return $(o.children).map((n) => s(n)).join("");
149
+ return b(o.children).map((n) => c(n)).join("");
147
150
  if (typeof r == "string" && r === "suspended") {
148
- const e = t, n = `async-${d++}`;
151
+ const e = t, n = `async-${y++}`;
149
152
  return console.log(
150
153
  `⏳ Suspending: ${e._componentName} (${n})`
151
- ), l.set(n, {
154
+ ), u.set(n, {
152
155
  id: n,
153
156
  promise: e.promise,
154
157
  componentName: e._componentName,
155
- errorFallback: e.errorFallback
156
- // Store custom error fallback
157
- }), g(n, e._componentName);
158
+ errorFallback: e.errorFallback,
159
+ parentNode: v()
160
+ }), $(n, e._componentName);
158
161
  }
159
162
  if (typeof r == "function") {
160
- const e = r(o);
161
- if (T(e)) {
162
- const n = `async-${d++}`, i = r.name || "AsyncComponent";
163
+ const e = E(), n = v();
164
+ p(e);
165
+ const a = r(o);
166
+ if (P(a)) {
167
+ const i = `async-${y++}`, s = r.name || "AsyncComponent";
163
168
  return console.warn(
164
- `⚠️ DEPRECATED: Direct async component "${i}" detected. Please use suspend() HOF instead for better type safety and custom fallbacks.
165
- Example: const ${i} = suspend(async (props) => { ... }, <Loading />, <Error />);`
166
- ), console.log(`⏳ Suspending: ${i} (${n})`), l.set(n, {
167
- id: n,
168
- promise: e,
169
- componentName: i
170
- }), g(n, i);
169
+ `⚠️ DEPRECATED: Direct async component "${s}" detected. Please use suspend() HOF instead for better type safety and custom fallbacks.
170
+ Example: const ${s} = suspend(async (props) => { ... }, <Loading />, <Error />);`
171
+ ), console.log(`⏳ Suspending: ${s} (${i})`), u.set(i, {
172
+ id: i,
173
+ promise: a,
174
+ componentName: s,
175
+ parentNode: e
176
+ }), p(n), $(i, s);
171
177
  }
172
- return s(e);
178
+ const l = c(a);
179
+ return p(n), l;
173
180
  }
174
181
  if (typeof r == "string") {
175
- const e = j(o);
176
- if (E.has(r))
182
+ const e = x(o);
183
+ if (T.has(r))
177
184
  return `<${r}${e} />`;
178
185
  if (o.innerHTML !== void 0) {
179
- const a = typeof o.innerHTML == "object" ? JSON.stringify(o.innerHTML) : o.innerHTML;
180
- return `<${r}${e}>${a}</${r}>`;
186
+ const l = typeof o.innerHTML == "object" ? JSON.stringify(o.innerHTML) : o.innerHTML;
187
+ return `<${r}${e}>${l}</${r}>`;
181
188
  }
182
- const i = $(o.children).map((a) => {
183
- if (Array.isArray(a))
184
- return a.map((c) => s(c)).join("");
185
- if (typeof a == "function") {
186
- const c = a();
187
- return Array.isArray(c) ? `<!--reactive-list-->${c.map((p) => s(p)).join("")}` : `<!--reactive-->${s(c)}`;
189
+ const a = b(o.children).map((l) => {
190
+ if (Array.isArray(l))
191
+ return l.map((i) => c(i)).join("");
192
+ if (typeof l == "function") {
193
+ const i = l();
194
+ return Array.isArray(i) ? `<!--reactive-list-->${i.map((d) => c(d)).join("")}` : `<!--reactive-->${c(i)}`;
188
195
  }
189
- return s(a);
196
+ return c(l);
190
197
  }).join("");
191
198
  return r === "html" ? `<!DOCTYPE html>
192
- <html${e}>${i}</html>` : `<${r}${e}>${i}</${r}>`;
199
+ <html${e}>${a}</html>` : `<${r}${e}>${a}</${r}>`;
193
200
  }
194
201
  return "";
195
202
  }
196
- class M {
203
+ class V {
197
204
  cacheDir;
198
205
  useDirectoryStructure;
199
206
  constructor(r = {}) {
@@ -201,14 +208,14 @@ class M {
201
208
  }
202
209
  async save(r, o) {
203
210
  const e = this.getFilepath(r);
204
- return await h(b(e), { recursive: !0 }), await Bun.write(e, o), console.log(`✅ Pre-rendered: ${r} → ${e}`), e;
211
+ return await A(w(e), { recursive: !0 }), await Bun.write(e, o), console.log(`✅ Pre-rendered: ${r} → ${e}`), e;
205
212
  }
206
213
  async load(r) {
207
214
  const o = this.getFilepath(r), e = Bun.file(o);
208
215
  return await e.exists() ? e : null;
209
216
  }
210
217
  async clear() {
211
- await S(this.cacheDir, { recursive: !0, force: !0 }), await h(this.cacheDir, { recursive: !0 }), console.log("🗑️ Cache cleared");
218
+ await N(this.cacheDir, { recursive: !0, force: !0 }), await A(this.cacheDir, { recursive: !0 }), console.log("🗑️ Cache cleared");
212
219
  }
213
220
  async exists(r) {
214
221
  const o = this.getFilepath(r);
@@ -217,16 +224,16 @@ class M {
217
224
  getFilepath(r) {
218
225
  const o = r.replace(/^\/+|\/+$/g, "");
219
226
  if (this.useDirectoryStructure)
220
- return o === "" ? y(this.cacheDir, "index.html") : y(this.cacheDir, o, "index.html");
227
+ return o === "" ? h(this.cacheDir, "index.html") : h(this.cacheDir, o, "index.html");
221
228
  {
222
229
  const e = o === "" ? "index.html" : `${o.replace(/\//g, "-")}.html`;
223
- return y(this.cacheDir, e);
230
+ return h(this.cacheDir, e);
224
231
  }
225
232
  }
226
233
  }
227
234
  export {
228
- M as PreRenderer,
229
- C as renderToStream,
230
- P as renderToString,
231
- x as renderToStringAsync
235
+ V as PreRenderer,
236
+ O as renderToStream,
237
+ B as renderToString,
238
+ I as renderToStringAsync
232
239
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mateosuarezdev/flash",
3
- "version": "0.0.6",
3
+ "version": "0.0.11",
4
4
  "description": "Custom jsx runtime",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",