@mateosuarezdev/flash 0.0.12 → 0.0.16
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.
- package/dist/framework.cjs +11 -0
- package/dist/framework.d.ts +53 -0
- package/dist/framework.js +32 -0
- package/dist/index-BkDMcLYE.cjs +11 -0
- package/dist/index-GxoBoxj9.js +47 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +148 -179
- package/dist/jsx-dev-runtime.cjs +1 -1
- package/dist/jsx-dev-runtime.js +3 -3
- package/dist/jsx-runtime.cjs +1 -1
- package/dist/jsx-runtime.js +43 -5
- package/dist/server-context-C7Uxb3AS.cjs +11 -0
- package/dist/server-context-giztFmxM.js +59 -0
- package/dist/server.cjs +7 -7
- package/dist/server.js +170 -153
- package/dist/vnode-tracking-BAFaVke9.js +25 -0
- package/dist/vnode-tracking-DC68rWms.cjs +11 -0
- package/package.json +6 -1
- package/dist/jsx-dev-runtime-C5Q23IsT.cjs +0 -11
- package/dist/jsx-dev-runtime-dAReTOgq.js +0 -65
- package/dist/server-context-EvJ6E74m.js +0 -54
- package/dist/server-context-TAJ6UxWy.cjs +0 -11
package/dist/jsx-dev-runtime.cjs
CHANGED
|
@@ -8,4 +8,4 @@
|
|
|
8
8
|
* See LICENSE file for full terms.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./jsx-
|
|
11
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./jsx-runtime.cjs");exports.Fragment=e.Fragment;exports.jsx=e.jsx;exports.jsxDEV=e.jsx;exports.jsxs=e.jsx;
|
package/dist/jsx-dev-runtime.js
CHANGED
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
* See LICENSE file for full terms.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import {
|
|
11
|
+
import { Fragment as j, jsx as a, jsx as r, jsx as e } from "./jsx-runtime.js";
|
|
12
12
|
export {
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
j as Fragment,
|
|
14
|
+
a as jsx,
|
|
15
15
|
r as jsxDEV,
|
|
16
16
|
e as jsxs
|
|
17
17
|
};
|
package/dist/jsx-runtime.cjs
CHANGED
|
@@ -8,4 +8,4 @@
|
|
|
8
8
|
* See LICENSE file for full terms.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
11
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./vnode-tracking-DC68rWms.cjs");function i(n,e,t){return{type:n,kind:"VNode",props:e,key:t,children:e.children,_id:o.newVNodeId(),_onMountCallbacks:[],_onUnmountCallbacks:[],_onBeforeExitCallbacks:[],_element:null,_parent:null,_renderedChildren:[],_lifecycleState:"mounting"}}function c(n,e,t){return{type:n,kind:"IntrinsicVNode",props:e,key:t,_id:o.newVNodeId(),_dom:void 0,_parent:null,_renderedChildren:[],_onMountCallbacks:[],_onUnmountCallbacks:[],_onBeforeExitCallbacks:[],_lifecycleState:"mounting"}}const l=Symbol.for("jsx.fragment");function r(n,e,t){return n===l?e?.children:typeof n=="function"?i(n,e??{},t):c(n,e??{},t)}exports.Fragment=l;exports.jsx=r;exports.jsxDEV=r;exports.jsxs=r;
|
package/dist/jsx-runtime.js
CHANGED
|
@@ -8,10 +8,48 @@
|
|
|
8
8
|
* See LICENSE file for full terms.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import {
|
|
11
|
+
import { n as r } from "./vnode-tracking-BAFaVke9.js";
|
|
12
|
+
function l(n, e, t) {
|
|
13
|
+
return {
|
|
14
|
+
type: n,
|
|
15
|
+
kind: "VNode",
|
|
16
|
+
props: e,
|
|
17
|
+
key: t,
|
|
18
|
+
children: e.children,
|
|
19
|
+
_id: r(),
|
|
20
|
+
_onMountCallbacks: [],
|
|
21
|
+
_onUnmountCallbacks: [],
|
|
22
|
+
_onBeforeExitCallbacks: [],
|
|
23
|
+
_element: null,
|
|
24
|
+
_parent: null,
|
|
25
|
+
_renderedChildren: [],
|
|
26
|
+
_lifecycleState: "mounting"
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function o(n, e, t) {
|
|
30
|
+
return {
|
|
31
|
+
type: n,
|
|
32
|
+
kind: "IntrinsicVNode",
|
|
33
|
+
props: e,
|
|
34
|
+
key: t,
|
|
35
|
+
_id: r(),
|
|
36
|
+
_dom: void 0,
|
|
37
|
+
// DOM created lazily during render
|
|
38
|
+
_parent: null,
|
|
39
|
+
_renderedChildren: [],
|
|
40
|
+
_onMountCallbacks: [],
|
|
41
|
+
_onUnmountCallbacks: [],
|
|
42
|
+
_onBeforeExitCallbacks: [],
|
|
43
|
+
_lifecycleState: "mounting"
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
const i = Symbol.for("jsx.fragment");
|
|
47
|
+
function c(n, e, t) {
|
|
48
|
+
return n === i ? e?.children : typeof n == "function" ? l(n, e ?? {}, t) : o(n, e ?? {}, t);
|
|
49
|
+
}
|
|
12
50
|
export {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
51
|
+
i as Fragment,
|
|
52
|
+
c as jsx,
|
|
53
|
+
c as jsxDEV,
|
|
54
|
+
c as jsxs
|
|
17
55
|
};
|
|
@@ -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";const n=new Map;let d=0,r=null;function c(){const e=d++;return n.set(e,null),r=e,e}function l(e){n.delete(e),r===e&&(r=null)}function o(){return r===null?null:n.get(r)??null}function i(e){if(r===null)throw new Error("No active render context");n.set(r,e)}function a(){if(r===null)throw new Error("createServerVNode called outside of render context");return{_parent:o(),_renderId:r}}function s(e,u){const t=o();if(!t)throw new Error("provideServerContext called outside of component render");t._contextMap||(t._contextMap=new Map),t._contextMap.set(e,u)}function x(e,u){let t=o();for(;t;){if(t._contextMap?.has(e))return t._contextMap.get(e);t=t._parent}return u}exports.consumeServerContext=x;exports.createServerVNode=a;exports.endRenderContext=l;exports.getCurrentServerVNode=o;exports.provideServerContext=s;exports.setCurrentServerVNode=i;exports.startRenderContext=c;
|
|
@@ -0,0 +1,59 @@
|
|
|
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
|
+
const r = /* @__PURE__ */ new Map();
|
|
12
|
+
let u = 0, n = null;
|
|
13
|
+
function a() {
|
|
14
|
+
const e = u++;
|
|
15
|
+
return r.set(e, null), n = e, e;
|
|
16
|
+
}
|
|
17
|
+
function l(e) {
|
|
18
|
+
r.delete(e), n === e && (n = null);
|
|
19
|
+
}
|
|
20
|
+
function c() {
|
|
21
|
+
return n === null ? null : r.get(n) ?? null;
|
|
22
|
+
}
|
|
23
|
+
function d(e) {
|
|
24
|
+
if (n === null)
|
|
25
|
+
throw new Error("No active render context");
|
|
26
|
+
r.set(n, e);
|
|
27
|
+
}
|
|
28
|
+
function s() {
|
|
29
|
+
if (n === null)
|
|
30
|
+
throw new Error("createServerVNode called outside of render context");
|
|
31
|
+
return {
|
|
32
|
+
_parent: c(),
|
|
33
|
+
_renderId: n
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function i(e, o) {
|
|
37
|
+
const t = c();
|
|
38
|
+
if (!t)
|
|
39
|
+
throw new Error("provideServerContext called outside of component render");
|
|
40
|
+
t._contextMap || (t._contextMap = /* @__PURE__ */ new Map()), t._contextMap.set(e, o);
|
|
41
|
+
}
|
|
42
|
+
function f(e, o) {
|
|
43
|
+
let t = c();
|
|
44
|
+
for (; t; ) {
|
|
45
|
+
if (t._contextMap?.has(e))
|
|
46
|
+
return t._contextMap.get(e);
|
|
47
|
+
t = t._parent;
|
|
48
|
+
}
|
|
49
|
+
return o;
|
|
50
|
+
}
|
|
51
|
+
export {
|
|
52
|
+
d as a,
|
|
53
|
+
s as b,
|
|
54
|
+
f as c,
|
|
55
|
+
l as e,
|
|
56
|
+
c as g,
|
|
57
|
+
i as p,
|
|
58
|
+
a as s
|
|
59
|
+
};
|
package/dist/server.cjs
CHANGED
|
@@ -8,20 +8,20 @@
|
|
|
8
8
|
* See LICENSE file for full terms.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
11
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./server-context-C7Uxb3AS.cjs"),S=require("node:fs/promises"),g=require("node:path");function N(r){return r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function b(r){return r.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}const H=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]);function j(r){return/^on[A-Z]/.test(r)}function E(r){return Object.entries(r).map(([t,n])=>`${t.replace(/[A-Z]/g,o=>`-${o.toLowerCase()}`)}:${n}`).join(";")}function T(r,t=!0){const n=Object.entries(r).filter(([e,o])=>!(o==null||t&&e==="children"||e==="innerHTML"||j(e))).map(([e,o])=>(e==="className"&&(e="class"),e==="style"&&typeof o=="object"&&(o=E(o)),typeof o=="boolean"?o?e:"":`${e}="${b(String(o))}"`)).filter(Boolean).join(" ");return n?` ${n}`:""}function A(r){return r?Array.isArray(r)?r:[r]:[]}function w(r){return r&&typeof r.then=="function"}function v(r,t){return`<div id="${r}" data-server-component="suspended" data-component-name="${t}">Loading...</div>`}const p=new Map;let y=0;function D(r){p.clear(),y=0;const t=l.startRenderContext();try{return a(r)}finally{l.endRenderContext(t)}}async function x(r){p.clear(),y=0;const t=l.startRenderContext();try{let n=a(r);for(;p.size>0;){console.log(`🔄 Resolving ${p.size} async components in parallel...`);const e=Array.from(p.entries());p.clear();const o=await Promise.allSettled(e.map(([s,{promise:i}])=>i));for(let s=0;s<e.length;s++){const i=e[s];if(!i)continue;const[u,{componentName:c,errorFallback:d,parentNode:h}]=i,m=o[s];if(!m)continue;const $=v(u,c);if(m.status==="fulfilled")try{console.log(`✅ Resolved: ${c} (${u})`),l.setCurrentServerVNode(h);const f=a(m.value);n=n.replace($,f)}catch(f){console.error(`❌ Error rendering ${c}:`,f),l.setCurrentServerVNode(h);const C=d?a(typeof d=="function"?d(f):d):`<div class="error">Error rendering ${c}</div>`;n=n.replace($,C)}else{console.error(`❌ Error resolving ${c}:`,m.reason),l.setCurrentServerVNode(h);const f=d?a(typeof d=="function"?d(m.reason):d):`<div class="error">Error loading ${c}</div>`;n=n.replace($,f)}}}return console.log("✅ All async components resolved!"),n}finally{l.endRenderContext(t)}}async function*P(r){p.clear(),y=0;const t=l.startRenderContext();try{for(yield a(r);p.size>0;){const e=Array.from(p.entries());p.clear();const o=e.map(async([s,{promise:i,parentNode:u}])=>{try{const c=await i;l.setCurrentServerVNode(u);const d=a(c);return`<script>
|
|
12
12
|
(function() {
|
|
13
|
-
const el = document.getElementById('${
|
|
13
|
+
const el = document.getElementById('${s}');
|
|
14
14
|
if (el) {
|
|
15
|
-
el.outerHTML = \`${
|
|
15
|
+
el.outerHTML = \`${d.replace(/`/g,"\\`").replace(/\$/g,"\\$")}\`;
|
|
16
16
|
}
|
|
17
17
|
})();
|
|
18
18
|
<\/script>`}catch{return`<script>
|
|
19
19
|
(function() {
|
|
20
|
-
const el = document.getElementById('${
|
|
20
|
+
const el = document.getElementById('${s}');
|
|
21
21
|
if (el) {
|
|
22
22
|
el.innerHTML = '<div class="error">Error loading component</div>';
|
|
23
23
|
}
|
|
24
24
|
})();
|
|
25
|
-
<\/script>`}});for(const
|
|
26
|
-
Example: const ${
|
|
27
|
-
<html${e}>${
|
|
25
|
+
<\/script>`}});for(const s of o)yield await s}}finally{l.endRenderContext(t)}}function a(r){if(typeof r=="function"){const e=r();return Array.isArray(e)?`<!--reactive-list-->${e.map(s=>a(s)).join("")}`:a(e)}if(typeof r=="string")return N(r);if(typeof r=="number")return String(r);if(Array.isArray(r))return r.map(e=>a(e)).join("");if(!r||typeof r!="object")return"";const{type:t,props:n}=r;if(t===Symbol.for("jsx.fragment"))return A(n.children).map(o=>a(o)).join("");if(typeof t=="string"&&t==="suspended"){const e=r,o=`async-${y++}`;return console.log(`⏳ Suspending: ${e._componentName} (${o})`),p.set(o,{id:o,promise:e.promise,componentName:e._componentName,errorFallback:e.errorFallback,parentNode:l.getCurrentServerVNode()}),v(o,e._componentName)}if(typeof t=="function"){const e=l.createServerVNode(),o=l.getCurrentServerVNode();l.setCurrentServerVNode(e);const s=t(n);if(w(s)){const u=`async-${y++}`,c=t.name||"AsyncComponent";return console.warn(`⚠️ DEPRECATED: Direct async component "${c}" detected. Please use suspend() HOF instead for better type safety and custom fallbacks.
|
|
26
|
+
Example: const ${c} = suspend(async (props) => { ... }, <Loading />, <Error />);`),console.log(`⏳ Suspending: ${c} (${u})`),p.set(u,{id:u,promise:s,componentName:c,parentNode:e}),l.setCurrentServerVNode(o),v(u,c)}const i=a(s);return l.setCurrentServerVNode(o),i}if(typeof t=="string"){const e=T(n);if(H.has(t))return`<${t}${e} />`;if(n.innerHTML!==void 0){const i=typeof n.innerHTML=="object"?JSON.stringify(n.innerHTML):n.innerHTML;return`<${t}${e}>${i}</${t}>`}const s=A(n.children).map(i=>{if(Array.isArray(i))return i.map(u=>a(u)).join("");if(typeof i=="function"){const u=i();return Array.isArray(u)?`<!--reactive-list-->${u.map(d=>a(d)).join("")}`:`<!--reactive-->${a(u)}`}return a(i)}).join("");return t==="html"?`<!DOCTYPE html>
|
|
27
|
+
<html${e}>${s}</html>`:`<${t}${e}>${s}</${t}>`}return""}class V{cacheDir;useDirectoryStructure;constructor(t={}){this.cacheDir=t.cacheDir||"./cache/html",this.useDirectoryStructure=t.useDirectoryStructure??!1}async save(t,n){const e=this.getFilepath(t);return await S.mkdir(g.dirname(e),{recursive:!0}),await Bun.write(e,n),console.log(`✅ Pre-rendered: ${t} → ${e}`),e}async load(t){const n=this.getFilepath(t),e=Bun.file(n);return await e.exists()?e:null}async clear(){await S.rm(this.cacheDir,{recursive:!0,force:!0}),await S.mkdir(this.cacheDir,{recursive:!0}),console.log("🗑️ Cache cleared")}async exists(t){const n=this.getFilepath(t);return await Bun.file(n).exists()}getFilepath(t){const n=t.replace(/^\/+|\/+$/g,"");if(this.useDirectoryStructure)return n===""?g.join(this.cacheDir,"index.html"):g.join(this.cacheDir,n,"index.html");{const e=n===""?"index.html":`${n.replace(/\//g,"-")}.html`;return g.join(this.cacheDir,e)}}}exports.PreRenderer=V;exports.renderToStream=P;exports.renderToString=D;exports.renderToStringAsync=x;
|
package/dist/server.js
CHANGED
|
@@ -8,16 +8,16 @@
|
|
|
8
8
|
* See LICENSE file for full terms.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import {
|
|
12
|
-
import { mkdir as
|
|
13
|
-
import { dirname as
|
|
14
|
-
function
|
|
15
|
-
return
|
|
11
|
+
import { s as v, e as A, a as f, g as b, b as w } from "./server-context-giztFmxM.js";
|
|
12
|
+
import { mkdir as H, rm as D } from "node:fs/promises";
|
|
13
|
+
import { dirname as j, join as $ } from "node:path";
|
|
14
|
+
function T(r) {
|
|
15
|
+
return r.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
16
16
|
}
|
|
17
|
-
function
|
|
18
|
-
return
|
|
17
|
+
function C(r) {
|
|
18
|
+
return r.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
19
19
|
}
|
|
20
|
-
const
|
|
20
|
+
const x = /* @__PURE__ */ new Set([
|
|
21
21
|
"area",
|
|
22
22
|
"base",
|
|
23
23
|
"br",
|
|
@@ -32,208 +32,225 @@ const T = /* @__PURE__ */ new Set([
|
|
|
32
32
|
"track",
|
|
33
33
|
"wbr"
|
|
34
34
|
]);
|
|
35
|
-
function
|
|
36
|
-
return /^on[A-Z]/.test(
|
|
35
|
+
function L(r) {
|
|
36
|
+
return /^on[A-Z]/.test(r);
|
|
37
37
|
}
|
|
38
|
-
function
|
|
39
|
-
return Object.entries(
|
|
38
|
+
function P(r) {
|
|
39
|
+
return Object.entries(r).map(([t, n]) => `${t.replace(/[A-Z]/g, (o) => `-${o.toLowerCase()}`)}:${n}`).join(";");
|
|
40
40
|
}
|
|
41
|
-
function
|
|
42
|
-
const
|
|
43
|
-
return
|
|
41
|
+
function I(r, t = !0) {
|
|
42
|
+
const n = Object.entries(r).filter(([e, o]) => !(o == null || t && e === "children" || e === "innerHTML" || L(e))).map(([e, o]) => (e === "className" && (e = "class"), e === "style" && typeof o == "object" && (o = P(o)), typeof o == "boolean" ? o ? e : "" : `${e}="${C(String(o))}"`)).filter(Boolean).join(" ");
|
|
43
|
+
return n ? ` ${n}` : "";
|
|
44
44
|
}
|
|
45
|
-
function
|
|
46
|
-
return
|
|
45
|
+
function E(r) {
|
|
46
|
+
return r ? Array.isArray(r) ? r : [r] : [];
|
|
47
47
|
}
|
|
48
|
-
function
|
|
49
|
-
return
|
|
48
|
+
function M(r) {
|
|
49
|
+
return r && typeof r.then == "function";
|
|
50
50
|
}
|
|
51
|
-
function
|
|
52
|
-
return `<div id="${
|
|
51
|
+
function S(r, t) {
|
|
52
|
+
return `<div id="${r}" data-server-component="suspended" data-component-name="${t}">Loading...</div>`;
|
|
53
53
|
}
|
|
54
|
-
const
|
|
54
|
+
const p = /* @__PURE__ */ new Map();
|
|
55
55
|
let y = 0;
|
|
56
|
-
function
|
|
57
|
-
|
|
56
|
+
function O(r) {
|
|
57
|
+
p.clear(), y = 0;
|
|
58
|
+
const t = v();
|
|
59
|
+
try {
|
|
60
|
+
return a(r);
|
|
61
|
+
} finally {
|
|
62
|
+
A(t);
|
|
63
|
+
}
|
|
58
64
|
}
|
|
59
|
-
async function
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
65
|
+
async function R(r) {
|
|
66
|
+
p.clear(), y = 0;
|
|
67
|
+
const t = v();
|
|
68
|
+
try {
|
|
69
|
+
let n = a(r);
|
|
70
|
+
for (; p.size > 0; ) {
|
|
71
|
+
console.log(
|
|
72
|
+
`🔄 Resolving ${p.size} async components in parallel...`
|
|
73
|
+
);
|
|
74
|
+
const e = Array.from(p.entries());
|
|
75
|
+
p.clear();
|
|
76
|
+
const o = await Promise.allSettled(
|
|
77
|
+
e.map(([i, { promise: s }]) => s)
|
|
78
|
+
);
|
|
79
|
+
for (let i = 0; i < e.length; i++) {
|
|
80
|
+
const s = e[i];
|
|
81
|
+
if (!s) continue;
|
|
82
|
+
const [l, { componentName: c, errorFallback: u, parentNode: g }] = s, m = o[i];
|
|
83
|
+
if (!m) continue;
|
|
84
|
+
const h = S(l, c);
|
|
85
|
+
if (m.status === "fulfilled")
|
|
86
|
+
try {
|
|
87
|
+
console.log(`✅ Resolved: ${c} (${l})`), f(g);
|
|
88
|
+
const d = a(m.value);
|
|
89
|
+
n = n.replace(h, d);
|
|
90
|
+
} catch (d) {
|
|
91
|
+
console.error(`❌ Error rendering ${c}:`, d), f(g);
|
|
92
|
+
const N = u ? a(
|
|
93
|
+
typeof u == "function" ? u(d) : u
|
|
94
|
+
) : `<div class="error">Error rendering ${c}</div>`;
|
|
95
|
+
n = n.replace(h, N);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
console.error(`❌ Error resolving ${c}:`, m.reason), f(g);
|
|
99
|
+
const d = u ? a(
|
|
100
|
+
typeof u == "function" ? u(m.reason) : u
|
|
101
|
+
) : `<div class="error">Error loading ${c}</div>`;
|
|
102
|
+
n = n.replace(h, d);
|
|
88
103
|
}
|
|
89
|
-
else {
|
|
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);
|
|
95
104
|
}
|
|
96
105
|
}
|
|
106
|
+
return console.log("✅ All async components resolved!"), n;
|
|
107
|
+
} finally {
|
|
108
|
+
A(t);
|
|
97
109
|
}
|
|
98
|
-
return console.log("✅ All async components resolved!"), r;
|
|
99
110
|
}
|
|
100
|
-
async function*
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
+
async function* V(r) {
|
|
112
|
+
p.clear(), y = 0;
|
|
113
|
+
const t = v();
|
|
114
|
+
try {
|
|
115
|
+
for (yield a(r); p.size > 0; ) {
|
|
116
|
+
const e = Array.from(p.entries());
|
|
117
|
+
p.clear();
|
|
118
|
+
const o = e.map(
|
|
119
|
+
async ([i, { promise: s, parentNode: l }]) => {
|
|
120
|
+
try {
|
|
121
|
+
const c = await s;
|
|
122
|
+
f(l);
|
|
123
|
+
const u = a(c);
|
|
124
|
+
return `<script>
|
|
111
125
|
(function() {
|
|
112
|
-
const el = document.getElementById('${
|
|
126
|
+
const el = document.getElementById('${i}');
|
|
113
127
|
if (el) {
|
|
114
|
-
el.outerHTML = \`${
|
|
128
|
+
el.outerHTML = \`${u.replace(/`/g, "\\`").replace(/\$/g, "\\$")}\`;
|
|
115
129
|
}
|
|
116
130
|
})();
|
|
117
131
|
<\/script>`;
|
|
118
|
-
|
|
119
|
-
|
|
132
|
+
} catch {
|
|
133
|
+
return `<script>
|
|
120
134
|
(function() {
|
|
121
|
-
const el = document.getElementById('${
|
|
135
|
+
const el = document.getElementById('${i}');
|
|
122
136
|
if (el) {
|
|
123
137
|
el.innerHTML = '<div class="error">Error loading component</div>';
|
|
124
138
|
}
|
|
125
139
|
})();
|
|
126
140
|
<\/script>`;
|
|
141
|
+
}
|
|
127
142
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
143
|
+
);
|
|
144
|
+
for (const i of o)
|
|
145
|
+
yield await i;
|
|
146
|
+
}
|
|
147
|
+
} finally {
|
|
148
|
+
A(t);
|
|
132
149
|
}
|
|
133
150
|
}
|
|
134
|
-
function
|
|
135
|
-
if (typeof
|
|
136
|
-
const e =
|
|
137
|
-
return Array.isArray(e) ? `<!--reactive-list-->${e.map((
|
|
151
|
+
function a(r) {
|
|
152
|
+
if (typeof r == "function") {
|
|
153
|
+
const e = r();
|
|
154
|
+
return Array.isArray(e) ? `<!--reactive-list-->${e.map((i) => a(i)).join("")}` : a(e);
|
|
138
155
|
}
|
|
139
|
-
if (typeof
|
|
140
|
-
return
|
|
141
|
-
if (typeof
|
|
142
|
-
return String(
|
|
143
|
-
if (Array.isArray(
|
|
144
|
-
return
|
|
145
|
-
if (!
|
|
156
|
+
if (typeof r == "string")
|
|
157
|
+
return T(r);
|
|
158
|
+
if (typeof r == "number")
|
|
159
|
+
return String(r);
|
|
160
|
+
if (Array.isArray(r))
|
|
161
|
+
return r.map((e) => a(e)).join("");
|
|
162
|
+
if (!r || typeof r != "object")
|
|
146
163
|
return "";
|
|
147
|
-
const { type:
|
|
148
|
-
if (
|
|
149
|
-
return
|
|
150
|
-
if (typeof
|
|
151
|
-
const e =
|
|
164
|
+
const { type: t, props: n } = r;
|
|
165
|
+
if (t === Symbol.for("jsx.fragment"))
|
|
166
|
+
return E(n.children).map((o) => a(o)).join("");
|
|
167
|
+
if (typeof t == "string" && t === "suspended") {
|
|
168
|
+
const e = r, o = `async-${y++}`;
|
|
152
169
|
return console.log(
|
|
153
|
-
`⏳ Suspending: ${e._componentName} (${
|
|
154
|
-
),
|
|
155
|
-
id:
|
|
170
|
+
`⏳ Suspending: ${e._componentName} (${o})`
|
|
171
|
+
), p.set(o, {
|
|
172
|
+
id: o,
|
|
156
173
|
promise: e.promise,
|
|
157
174
|
componentName: e._componentName,
|
|
158
175
|
errorFallback: e.errorFallback,
|
|
159
|
-
parentNode:
|
|
160
|
-
}),
|
|
176
|
+
parentNode: b()
|
|
177
|
+
}), S(o, e._componentName);
|
|
161
178
|
}
|
|
162
|
-
if (typeof
|
|
163
|
-
const e =
|
|
164
|
-
|
|
165
|
-
const
|
|
166
|
-
if (
|
|
167
|
-
const
|
|
179
|
+
if (typeof t == "function") {
|
|
180
|
+
const e = w(), o = b();
|
|
181
|
+
f(e);
|
|
182
|
+
const i = t(n);
|
|
183
|
+
if (M(i)) {
|
|
184
|
+
const l = `async-${y++}`, c = t.name || "AsyncComponent";
|
|
168
185
|
return console.warn(
|
|
169
|
-
`⚠️ DEPRECATED: Direct async component "${
|
|
170
|
-
Example: const ${
|
|
171
|
-
), console.log(`⏳ Suspending: ${
|
|
172
|
-
id:
|
|
173
|
-
promise:
|
|
174
|
-
componentName:
|
|
186
|
+
`⚠️ DEPRECATED: Direct async component "${c}" detected. Please use suspend() HOF instead for better type safety and custom fallbacks.
|
|
187
|
+
Example: const ${c} = suspend(async (props) => { ... }, <Loading />, <Error />);`
|
|
188
|
+
), console.log(`⏳ Suspending: ${c} (${l})`), p.set(l, {
|
|
189
|
+
id: l,
|
|
190
|
+
promise: i,
|
|
191
|
+
componentName: c,
|
|
175
192
|
parentNode: e
|
|
176
|
-
}),
|
|
193
|
+
}), f(o), S(l, c);
|
|
177
194
|
}
|
|
178
|
-
const
|
|
179
|
-
return
|
|
195
|
+
const s = a(i);
|
|
196
|
+
return f(o), s;
|
|
180
197
|
}
|
|
181
|
-
if (typeof
|
|
182
|
-
const e =
|
|
183
|
-
if (
|
|
184
|
-
return `<${
|
|
185
|
-
if (
|
|
186
|
-
const
|
|
187
|
-
return `<${
|
|
198
|
+
if (typeof t == "string") {
|
|
199
|
+
const e = I(n);
|
|
200
|
+
if (x.has(t))
|
|
201
|
+
return `<${t}${e} />`;
|
|
202
|
+
if (n.innerHTML !== void 0) {
|
|
203
|
+
const s = typeof n.innerHTML == "object" ? JSON.stringify(n.innerHTML) : n.innerHTML;
|
|
204
|
+
return `<${t}${e}>${s}</${t}>`;
|
|
188
205
|
}
|
|
189
|
-
const
|
|
190
|
-
if (Array.isArray(
|
|
191
|
-
return
|
|
192
|
-
if (typeof
|
|
193
|
-
const
|
|
194
|
-
return Array.isArray(
|
|
206
|
+
const i = E(n.children).map((s) => {
|
|
207
|
+
if (Array.isArray(s))
|
|
208
|
+
return s.map((l) => a(l)).join("");
|
|
209
|
+
if (typeof s == "function") {
|
|
210
|
+
const l = s();
|
|
211
|
+
return Array.isArray(l) ? `<!--reactive-list-->${l.map((u) => a(u)).join("")}` : `<!--reactive-->${a(l)}`;
|
|
195
212
|
}
|
|
196
|
-
return
|
|
213
|
+
return a(s);
|
|
197
214
|
}).join("");
|
|
198
|
-
return
|
|
199
|
-
<html${e}>${
|
|
215
|
+
return t === "html" ? `<!DOCTYPE html>
|
|
216
|
+
<html${e}>${i}</html>` : `<${t}${e}>${i}</${t}>`;
|
|
200
217
|
}
|
|
201
218
|
return "";
|
|
202
219
|
}
|
|
203
|
-
class
|
|
220
|
+
class _ {
|
|
204
221
|
cacheDir;
|
|
205
222
|
useDirectoryStructure;
|
|
206
|
-
constructor(
|
|
207
|
-
this.cacheDir =
|
|
223
|
+
constructor(t = {}) {
|
|
224
|
+
this.cacheDir = t.cacheDir || "./cache/html", this.useDirectoryStructure = t.useDirectoryStructure ?? !1;
|
|
208
225
|
}
|
|
209
|
-
async save(
|
|
210
|
-
const e = this.getFilepath(
|
|
211
|
-
return await
|
|
226
|
+
async save(t, n) {
|
|
227
|
+
const e = this.getFilepath(t);
|
|
228
|
+
return await H(j(e), { recursive: !0 }), await Bun.write(e, n), console.log(`✅ Pre-rendered: ${t} → ${e}`), e;
|
|
212
229
|
}
|
|
213
|
-
async load(
|
|
214
|
-
const
|
|
230
|
+
async load(t) {
|
|
231
|
+
const n = this.getFilepath(t), e = Bun.file(n);
|
|
215
232
|
return await e.exists() ? e : null;
|
|
216
233
|
}
|
|
217
234
|
async clear() {
|
|
218
|
-
await
|
|
235
|
+
await D(this.cacheDir, { recursive: !0, force: !0 }), await H(this.cacheDir, { recursive: !0 }), console.log("🗑️ Cache cleared");
|
|
219
236
|
}
|
|
220
|
-
async exists(
|
|
221
|
-
const
|
|
222
|
-
return await Bun.file(
|
|
237
|
+
async exists(t) {
|
|
238
|
+
const n = this.getFilepath(t);
|
|
239
|
+
return await Bun.file(n).exists();
|
|
223
240
|
}
|
|
224
|
-
getFilepath(
|
|
225
|
-
const
|
|
241
|
+
getFilepath(t) {
|
|
242
|
+
const n = t.replace(/^\/+|\/+$/g, "");
|
|
226
243
|
if (this.useDirectoryStructure)
|
|
227
|
-
return
|
|
244
|
+
return n === "" ? $(this.cacheDir, "index.html") : $(this.cacheDir, n, "index.html");
|
|
228
245
|
{
|
|
229
|
-
const e =
|
|
230
|
-
return
|
|
246
|
+
const e = n === "" ? "index.html" : `${n.replace(/\//g, "-")}.html`;
|
|
247
|
+
return $(this.cacheDir, e);
|
|
231
248
|
}
|
|
232
249
|
}
|
|
233
250
|
}
|
|
234
251
|
export {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
252
|
+
_ as PreRenderer,
|
|
253
|
+
V as renderToStream,
|
|
254
|
+
O as renderToString,
|
|
255
|
+
R as renderToStringAsync
|
|
239
256
|
};
|