xote 6.3.0 → 7.0.0-beta.1
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/README.md +132 -33
- package/dist/RuntimeAttr.res-Cr5Qmz0i.js +1 -0
- package/dist/RuntimeAttr.res-DAZkL5CF.mjs +539 -0
- package/dist/RuntimeHydrationMarkers.res-C5-ieaOS.js +1 -0
- package/dist/RuntimeHydrationMarkers.res-DHikAvHr.mjs +6 -0
- package/dist/RuntimeJsxProp.res-A6N-qWoK.js +1 -0
- package/dist/RuntimeJsxProp.res-D3W5GXqT.mjs +64 -0
- package/dist/Stdlib_Array-1YCQzU_Y.mjs +22 -0
- package/dist/Stdlib_Array-BeBVUIuY.js +1 -0
- package/dist/View.res-C36--SJD.js +1 -0
- package/dist/View.res-SuqJrQPC.mjs +777 -0
- package/dist/client.cjs +1 -0
- package/dist/client.mjs +131 -0
- package/dist/hydration.cjs +1 -0
- package/dist/hydration.mjs +385 -0
- package/dist/mdx.cjs +1 -0
- package/dist/mdx.mjs +50 -0
- package/dist/router.cjs +1 -0
- package/dist/router.mjs +276 -0
- package/dist/ssr.cjs +17 -0
- package/dist/ssr.mjs +321 -0
- package/dist/xote.cjs +1 -17
- package/dist/xote.mjs +1450 -2459
- package/dist/xote.umd.js +1 -17
- package/package.json +42 -10
- package/rescript.json +2 -2
- package/src/Mdx.res +77 -0
- package/src/Mdx.res.mjs +93 -0
- package/src/Router.res +62 -8
- package/src/Router.res.mjs +60 -6
- package/src/RuntimeDom.res +7 -0
- package/src/RuntimeDom.res.mjs +8 -0
- package/src/RuntimeJsxProp.res +5 -8
- package/src/RuntimeJsxProp.res.mjs +9 -10
- package/src/RuntimeValue.res +35 -0
- package/src/RuntimeValue.res.mjs +67 -0
- package/src/SSRState.res +1 -4
- package/src/SSRState.res.mjs +4 -10
- package/src/View.res +233 -39
- package/src/View.res.mjs +309 -32
- package/src/XoteJSX.res +214 -0
- package/src/XoteJSX.res.mjs +63 -0
- package/src/jsx-dev-runtime.mjs +7 -0
- package/src/jsx-runtime.mjs +276 -0
- package/src/Node.res +0 -2
- package/src/Node.res.mjs +0 -82
- package/src/ReactiveProp.res +0 -2
- package/src/ReactiveProp.res.mjs +0 -19
package/dist/router.mjs
ADDED
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import { D as e, E as t, f as n, i as r, l as i, u as a } from "./RuntimeAttr.res-DAZkL5CF.mjs";
|
|
2
|
+
import { c as o, r as s, x as c } from "./View.res-SuqJrQPC.mjs";
|
|
3
|
+
import { i as l, n as u } from "./RuntimeJsxProp.res-D3W5GXqT.mjs";
|
|
4
|
+
import { n as d, t as f } from "./Stdlib_Array-1YCQzU_Y.mjs";
|
|
5
|
+
//#region src/Route.res.mjs
|
|
6
|
+
var p = /* @__PURE__ */ e({
|
|
7
|
+
compile: () => _,
|
|
8
|
+
match: () => g,
|
|
9
|
+
matchCompiled: () => v,
|
|
10
|
+
matchPath: () => h,
|
|
11
|
+
matchPathname: () => y,
|
|
12
|
+
parsePattern: () => m
|
|
13
|
+
});
|
|
14
|
+
function m(e) {
|
|
15
|
+
return f(e.split("/"), (e) => {
|
|
16
|
+
if (e !== "") return e.startsWith(":") ? {
|
|
17
|
+
TAG: "Param",
|
|
18
|
+
_0: e.slice(1)
|
|
19
|
+
} : {
|
|
20
|
+
TAG: "Static",
|
|
21
|
+
_0: e
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function h(e, t) {
|
|
26
|
+
let n = t.split("/").filter((e) => e !== "");
|
|
27
|
+
if (e.length !== n.length) return "NoMatch";
|
|
28
|
+
let r = {};
|
|
29
|
+
return e.every((e, t) => {
|
|
30
|
+
let i = n[t];
|
|
31
|
+
return e.TAG === "Static" ? i === e._0 : (r[e._0] = i, !0);
|
|
32
|
+
}) ? {
|
|
33
|
+
TAG: "Match",
|
|
34
|
+
_0: r
|
|
35
|
+
} : "NoMatch";
|
|
36
|
+
}
|
|
37
|
+
function g(e, t) {
|
|
38
|
+
return h(m(e), t);
|
|
39
|
+
}
|
|
40
|
+
var _ = m, v = h, y = g, b = /* @__PURE__ */ e({
|
|
41
|
+
Link: () => Q,
|
|
42
|
+
Route: () => $,
|
|
43
|
+
addBasePath: () => O,
|
|
44
|
+
basePath: () => w,
|
|
45
|
+
emptyHistoryState: () => L,
|
|
46
|
+
getCurrentLocation: () => B,
|
|
47
|
+
getGlobalState: () => S,
|
|
48
|
+
getScrollFromState: () => R,
|
|
49
|
+
getScrollPosition: () => j,
|
|
50
|
+
getSymbolKey: () => x,
|
|
51
|
+
init: () => V,
|
|
52
|
+
initSSR: () => H,
|
|
53
|
+
link: () => q,
|
|
54
|
+
location: () => C,
|
|
55
|
+
makeHistoryState: () => I,
|
|
56
|
+
normalizeBasePath: () => E,
|
|
57
|
+
parseTarget: () => k,
|
|
58
|
+
push: () => U,
|
|
59
|
+
queueMicrotask: () => N,
|
|
60
|
+
replace: () => W,
|
|
61
|
+
route: () => G,
|
|
62
|
+
routes: () => K,
|
|
63
|
+
saveScrollPosition: () => z,
|
|
64
|
+
scrollAfterNavigation: () => F,
|
|
65
|
+
scrollHashIntoView: () => P,
|
|
66
|
+
scrollTo: () => M,
|
|
67
|
+
stripBasePath: () => D,
|
|
68
|
+
targetToHref: () => A,
|
|
69
|
+
warnIfNotInitialized: () => T
|
|
70
|
+
});
|
|
71
|
+
function x() {
|
|
72
|
+
return Symbol.for("xote.router.state");
|
|
73
|
+
}
|
|
74
|
+
function S() {
|
|
75
|
+
let e = globalThis[Symbol.for("xote.router.state")];
|
|
76
|
+
if (e !== void 0) return e;
|
|
77
|
+
let t = {
|
|
78
|
+
location: a({
|
|
79
|
+
pathname: "/",
|
|
80
|
+
search: "",
|
|
81
|
+
hash: ""
|
|
82
|
+
}, void 0, void 0),
|
|
83
|
+
basePath: { contents: "/" },
|
|
84
|
+
initialized: !1,
|
|
85
|
+
popStateHandler: void 0
|
|
86
|
+
};
|
|
87
|
+
return globalThis[Symbol.for("xote.router.state")] = t, t;
|
|
88
|
+
}
|
|
89
|
+
function C() {
|
|
90
|
+
return S().location;
|
|
91
|
+
}
|
|
92
|
+
function w() {
|
|
93
|
+
return S().basePath;
|
|
94
|
+
}
|
|
95
|
+
function T(e) {
|
|
96
|
+
if (!S().initialized) {
|
|
97
|
+
console.warn("[Xote Router] " + e + " called before Router.init(). Make sure to call Router.init() at your app entry point. This may cause incorrect routing behavior.");
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
function E(e) {
|
|
102
|
+
if (e === "" || e === "/") return "/";
|
|
103
|
+
let t = e.startsWith("/") ? e : "/" + e;
|
|
104
|
+
return t.endsWith("/") ? t.slice(0, t.length - 1 | 0) : t;
|
|
105
|
+
}
|
|
106
|
+
function D(e) {
|
|
107
|
+
let t = S().basePath.contents;
|
|
108
|
+
return t === "/" ? e : e === t ? "/" : e.startsWith(t + "/") ? e.slice(t.length) : e;
|
|
109
|
+
}
|
|
110
|
+
function O(e) {
|
|
111
|
+
let t = S().basePath.contents;
|
|
112
|
+
return t === "/" ? e : e === "/" ? t : t + e;
|
|
113
|
+
}
|
|
114
|
+
function k(e) {
|
|
115
|
+
let t = e.split("#"), n = r(t[0], ""), i = t[1], a = i === void 0 ? "" : "#" + i, o = n.split("?"), s = r(o[0], "/"), c = o[1];
|
|
116
|
+
return {
|
|
117
|
+
pathname: s,
|
|
118
|
+
search: c === void 0 ? "" : "?" + c,
|
|
119
|
+
hash: a
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function A(e) {
|
|
123
|
+
return O(e.pathname) + e.search + e.hash;
|
|
124
|
+
}
|
|
125
|
+
function j() {
|
|
126
|
+
return [window.scrollX || window.pageXOffset || 0, window.scrollY || window.pageYOffset || 0];
|
|
127
|
+
}
|
|
128
|
+
function M(e, t) {
|
|
129
|
+
window.scrollTo(e, t);
|
|
130
|
+
}
|
|
131
|
+
function N(e) {
|
|
132
|
+
globalThis.queueMicrotask(e);
|
|
133
|
+
}
|
|
134
|
+
function P(e) {
|
|
135
|
+
(() => {
|
|
136
|
+
if (!e) return;
|
|
137
|
+
let t = decodeURIComponent(e.startsWith("#") ? e.slice(1) : e), n = document.getElementById(t);
|
|
138
|
+
n && typeof n.scrollIntoView == "function" && n.scrollIntoView();
|
|
139
|
+
})();
|
|
140
|
+
}
|
|
141
|
+
function F(e) {
|
|
142
|
+
return e === "" ? M(0, 0) : N(() => P(e));
|
|
143
|
+
}
|
|
144
|
+
function I(e, t) {
|
|
145
|
+
return {
|
|
146
|
+
scrollX: e,
|
|
147
|
+
scrollY: t
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
function L() {
|
|
151
|
+
return {};
|
|
152
|
+
}
|
|
153
|
+
function R(e) {
|
|
154
|
+
let t = e && e.scrollX, n = e && e.scrollY;
|
|
155
|
+
if (t != null && n != null) return [t, n];
|
|
156
|
+
}
|
|
157
|
+
function z() {
|
|
158
|
+
let e = j(), t = I(e[0], e[1]), n = window.location.href;
|
|
159
|
+
window.history.replaceState(t, "", n);
|
|
160
|
+
}
|
|
161
|
+
function B() {
|
|
162
|
+
let e = window.location.pathname;
|
|
163
|
+
return {
|
|
164
|
+
pathname: D(e),
|
|
165
|
+
search: window.location.search,
|
|
166
|
+
hash: window.location.hash
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
function V(e, t) {
|
|
170
|
+
let r = e === void 0 ? "/" : e, i = S(), a = E(r);
|
|
171
|
+
if (i.basePath.contents = a, n(i.location, B()), i.initialized) return;
|
|
172
|
+
let o = (e) => {
|
|
173
|
+
n(S().location, B());
|
|
174
|
+
let t = window["history.state"];
|
|
175
|
+
if (t == null) return;
|
|
176
|
+
let r = R(t);
|
|
177
|
+
if (r !== void 0) return M(r[0], r[1]);
|
|
178
|
+
};
|
|
179
|
+
i.popStateHandler = o, window.addEventListener("popstate", o), i.initialized = !0;
|
|
180
|
+
}
|
|
181
|
+
function H(e, t, r, i, a) {
|
|
182
|
+
let o = e === void 0 ? "/" : e, s = t === void 0 ? "/" : t, c = r === void 0 ? "" : r, l = i === void 0 ? "" : i, u = S(), d = E(o);
|
|
183
|
+
u.basePath.contents = d, n(u.location, {
|
|
184
|
+
pathname: s,
|
|
185
|
+
search: c,
|
|
186
|
+
hash: l
|
|
187
|
+
}), u.initialized = !0;
|
|
188
|
+
}
|
|
189
|
+
function U(e, t, r, i) {
|
|
190
|
+
let a = t === void 0 ? "" : t, o = r === void 0 ? "" : r;
|
|
191
|
+
T("Router.push()"), z();
|
|
192
|
+
let s = {
|
|
193
|
+
pathname: e,
|
|
194
|
+
search: a,
|
|
195
|
+
hash: o
|
|
196
|
+
}, c = O(e) + a + o;
|
|
197
|
+
window.history.pushState(L(), "", c), n(S().location, s), F(o);
|
|
198
|
+
}
|
|
199
|
+
function W(e, t, r, i) {
|
|
200
|
+
let a = t === void 0 ? "" : t, o = r === void 0 ? "" : r;
|
|
201
|
+
T("Router.replace()");
|
|
202
|
+
let s = {
|
|
203
|
+
pathname: e,
|
|
204
|
+
search: a,
|
|
205
|
+
hash: o
|
|
206
|
+
}, c = O(e) + a + o;
|
|
207
|
+
window.history.replaceState(L(), "", c), n(S().location, s), F(o);
|
|
208
|
+
}
|
|
209
|
+
function G(e, t) {
|
|
210
|
+
return T("Router.route()"), o(c(() => {
|
|
211
|
+
let n = g(e, i(S().location).pathname);
|
|
212
|
+
return typeof n == "object" ? [t(n._0)] : [];
|
|
213
|
+
}, void 0, void 0));
|
|
214
|
+
}
|
|
215
|
+
function K(e) {
|
|
216
|
+
return T("Router.routes()"), o(c(() => {
|
|
217
|
+
let t = i(S().location), n = d(e, (e) => {
|
|
218
|
+
let n = g(e.pattern, t.pathname);
|
|
219
|
+
if (typeof n == "object") return e.render(n._0);
|
|
220
|
+
});
|
|
221
|
+
return n === void 0 ? [] : [n];
|
|
222
|
+
}, void 0, void 0));
|
|
223
|
+
}
|
|
224
|
+
function q(e, t, n, r) {
|
|
225
|
+
let i = t === void 0 ? [] : t, a = n === void 0 ? [] : n;
|
|
226
|
+
T("Router.link()");
|
|
227
|
+
let o = k(e);
|
|
228
|
+
return l(i.concat([s("href", A(o))]), [["click", (e) => {
|
|
229
|
+
e.preventDefault(), U(o.pathname, o.search, o.hash, void 0);
|
|
230
|
+
}]], a, void 0);
|
|
231
|
+
}
|
|
232
|
+
function J(e) {
|
|
233
|
+
let n = [], r = e.class;
|
|
234
|
+
r !== void 0 && n.push(u("class", t(r)));
|
|
235
|
+
let i = e.id;
|
|
236
|
+
i !== void 0 && n.push(u("id", t(i)));
|
|
237
|
+
let a = e.style;
|
|
238
|
+
a !== void 0 && n.push(u("style", t(a)));
|
|
239
|
+
let o = e.target;
|
|
240
|
+
o !== void 0 && n.push(u("target", t(o)));
|
|
241
|
+
let s = e["aria-label"];
|
|
242
|
+
return s !== void 0 && n.push(u("aria-label", t(s))), n;
|
|
243
|
+
}
|
|
244
|
+
function Y(e) {
|
|
245
|
+
let t = e.children;
|
|
246
|
+
return t === void 0 ? [] : t.TAG === "Fragment" ? t._0 : [t];
|
|
247
|
+
}
|
|
248
|
+
function X(e) {
|
|
249
|
+
T("Router.Link");
|
|
250
|
+
let t = k(e.to);
|
|
251
|
+
return l(J(e).concat([s("href", A(t))]), [["click", (n) => {
|
|
252
|
+
n.preventDefault(), U(t.pathname, t.search, t.hash, void 0);
|
|
253
|
+
let r = e.onClick;
|
|
254
|
+
if (r !== void 0) return r(n);
|
|
255
|
+
}]], Y(e), void 0);
|
|
256
|
+
}
|
|
257
|
+
function Z(e, t, n) {
|
|
258
|
+
return t === void 0 ? X(e) : {
|
|
259
|
+
TAG: "Keyed",
|
|
260
|
+
key: t,
|
|
261
|
+
identity: e,
|
|
262
|
+
child: X(e)
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
var Q = {
|
|
266
|
+
Prop: void 0,
|
|
267
|
+
propsToAttrs: J,
|
|
268
|
+
getChildren: Y,
|
|
269
|
+
make: X,
|
|
270
|
+
jsx: X,
|
|
271
|
+
jsxs: X,
|
|
272
|
+
jsxKeyed: Z,
|
|
273
|
+
jsxsKeyed: Z
|
|
274
|
+
}, $;
|
|
275
|
+
//#endregion
|
|
276
|
+
export { Q as Link, p as Route, b as Router, O as addBasePath, w as basePath, L as emptyHistoryState, B as getCurrentLocation, S as getGlobalState, R as getScrollFromState, j as getScrollPosition, x as getSymbolKey, V as init, H as initSSR, q as link, C as location, I as makeHistoryState, E as normalizeBasePath, k as parseTarget, U as push, N as queueMicrotask, W as replace, G as route, K as routes, z as saveScrollPosition, F as scrollAfterNavigation, P as scrollHashIntoView, M as scrollTo, D as stripBasePath, A as targetToHref, T as warnIfNotInitialized };
|
package/dist/ssr.cjs
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./RuntimeAttr.res-Cr5Qmz0i.js"),t=require("./Stdlib_Array-BeBVUIuY.js"),n=require("./RuntimeHydrationMarkers.res-C5-ieaOS.js");function r(e){return e.replaceAll(`&`,`&`).replaceAll(`<`,`<`).replaceAll(`>`,`>`).replaceAll(`"`,`"`).replaceAll(`'`,`'`)}var i=[`area`,`base`,`br`,`col`,`embed`,`hr`,`img`,`input`,`link`,`meta`,`param`,`source`,`track`,`wbr`];function a(e){return i.includes(e)}var o=e.D({Attributes:()=>l,Html:()=>h,Markers:()=>g,generateHydrationScript:()=>p,renderDocument:()=>m,renderNodeToString:()=>u,renderToString:()=>d,renderToStringWithRoot:()=>f});function s(t){let n=t[1],i=t[0],a;switch(n.TAG){case`Static`:a=n._0;break;case`SignalValue`:a=e.d(n._0);break;case`Compute`:a=n._0();break}return e.n(i)?e.r(a)?i:``:i+`="`+r(a)+`"`}function c(e){let t=e.map(s).filter(e=>e!==``);return t.length===0?``:` `+t.join(` `)}var l={renderAttr:s,renderAttrs:c};function u(t){for(;;){let i=t;switch(i.TAG){case`Element`:let o=i.tag,s=c(i.attrs);if(a(o))return`<`+o+s+` />`;let l=i.children.map(u).join(``);return`<`+o+s+`>`+l+`</`+o+`>`;case`Text`:return r(i._0);case`SignalText`:let d=e.d(i._0);return n.u+r(d)+n.l;case`Fragment`:return i._0.map(u).join(``);case`SignalFragment`:let f=e.d(i._0).map(u).join(``);return n.c+f+n.s;case`Keyed`:t=i.child;continue;case`LazyComponent`:let p=i._0();return n.o+u(p)+n.a;case`KeyedList`:let m=i.renderItem,h=i.keyFn,g=e.d(i.signal).map(e=>{let t=h(e),r=u(m(e));return n.n(t)+r+n.t}).join(``);return n.i+g+n.r}}}function d(e,t){return u(e())}function f(e,t,n){let r=t===void 0?`root`:t,i=u(e());return`<!--xote-root:`+r+`-->`+i+`<!--/xote-root-->`}function p(e){return`<script`+(e===void 0?``:` nonce="`+r(e)+`"`)+`>window.__XOTE_HYDRATED__=false;<\/script>`}function m(e,t,n,i,a,o,s){let c=e===void 0?``:e,l=t===void 0?``:t,u=n===void 0?[]:n,f=i===void 0?[]:i,m=a===void 0?``:a,h=d(s,void 0),g=p(o),_=f.map(e=>`<link rel="stylesheet" href="`+r(e)+`" />`).join(`
|
|
2
|
+
`),v=u.map(e=>{let t=o===void 0?``:` nonce="`+r(o)+`"`;return`<script type="module" src="`+r(e)+`"`+t+`><\/script>`}).join(`
|
|
3
|
+
`);return`<!DOCTYPE html>
|
|
4
|
+
<html>
|
|
5
|
+
<head>
|
|
6
|
+
<meta charset="UTF-8" />
|
|
7
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
8
|
+
`+_+`
|
|
9
|
+
`+c+`
|
|
10
|
+
</head>
|
|
11
|
+
<body`+(l===``?``:` `+l)+`>
|
|
12
|
+
<div id="root">`+h+`</div>
|
|
13
|
+
`+m+`
|
|
14
|
+
`+g+`
|
|
15
|
+
`+v+`
|
|
16
|
+
</body>
|
|
17
|
+
</html>`}var h,g,_=e.D({isClient:()=>y,isServer:()=>v,match:()=>S,onClient:()=>x,onServer:()=>b}),v=typeof document>`u`,y=!v;function b(t){if(v)return e.T(t())}function x(t){if(y)return e.T(t())}function S(e,t){return v?e():t()}function C(e){if(typeof e==`boolean`)return e}function w(e){if(e===null)return null}function T(e){if(typeof e==`string`)return e}function ee(e){if(typeof e==`number`)return e}function te(e){if(typeof e==`object`&&e&&!Array.isArray(e))return e}function ne(e){if(Array.isArray(e))return e}var E={bool:C,$$null:w,string:T,float:ee,object:te,array:ne},D=e.D({Codec:()=>K,clear:()=>Y,escapeForScript:()=>X,generateScript:()=>re,getClientState:()=>Z,register:()=>J,registry:()=>q,restore:()=>Q,signal:()=>ie,sync:()=>$});function O(e){return e}function k(e){let t=E.float(e);if(t!==void 0)return t|0}var A={encode:O,decode:k};function j(e){return e}function M(e){return E.float(e)}var N={encode:j,decode:M};function P(e){return e}function F(e){return E.string(e)}var I={encode:P,decode:F};function L(e){return e}function R(e){return E.bool(e)}var z={encode:L,decode:R};function B(e){return{encode:t=>t.map(e.encode),decode:n=>{let r=E.array(n);if(r===void 0)return;let i=t.t(r,e.decode);if(i.length===r.length)return i}}}function V(t){return{encode:n=>n===void 0?null:t.encode(e.E(n)),decode:n=>e.a(E.$$null(n))?e.T(void 0):e.o(t.decode(n),t=>e.T(t))}}function H(t,n){return{encode:e=>[t.encode(e[0]),n.encode(e[1])],decode:r=>{let i=Array.isArray(r)?r:void 0;if(i===void 0||i.length!==2)return;let a=i[0],o=i[1],s=t.decode(a),c=n.decode(o);if(s!==void 0&&c!==void 0)return[e.E(s),e.E(c)]}}}function U(t,n,r){return{encode:e=>[t.encode(e[0]),n.encode(e[1]),r.encode(e[2])],decode:i=>{let a=Array.isArray(i)?i:void 0;if(a===void 0||a.length!==3)return;let o=a[0],s=a[1],c=a[2],l=t.decode(o),u=n.decode(s),d=r.decode(c);if(l!==void 0&&u!==void 0&&d!==void 0)return[e.E(l),e.E(u),e.E(d)]}}}function W(t){return{encode:e=>{let n={};return Object.entries(e).forEach(e=>{n[e[0]]=t.encode(e[1])}),n},decode:n=>{let r=E.object(n);if(r===void 0)return;let i={},a={contents:!0};if(Object.entries(r).forEach(n=>{let r=t.decode(n[1]);r===void 0?a.contents=!1:i[n[0]]=e.E(r)}),a.contents)return i}}}function G(e,t){return{encode:e,decode:t}}var K={int:A,float:N,string:I,bool:z,array:B,option:V,tuple2:H,tuple3:U,dict:W,make:G},q={};function J(t,n,r){if(v){q[t]=r.encode(e.d(n));return}}function Y(){Object.keys(q).forEach(t=>{e.s(q,t)})}function X(e){return e.replaceAll(`<\/script>`,`<\\/script>`).replaceAll(`<!--`,`<\\!--`)}function re(t){let n=X(e.i(JSON.stringify(q),`{}`));return`<script`+(t===void 0?``:` nonce="`+r(t)+`"`)+`>window.__XOTE_STATE__=`+n+`;<\/script>`}function Z(){return y&&window.__XOTE_STATE__||{}}function Q(t,n,r){if(!y)return;let i=Z()[t];if(i===void 0)return;let a=r.decode(i);if(a!==void 0)return e.f(n,e.E(a))}function $(e,t,n){S(()=>J(e,t,n),()=>Q(e,t,n))}function ie(t,n,r){let i=e.u(n,void 0,void 0);return $(t,i,r),i}exports.Attributes=l,exports.Html=h,exports.Markers=g,Object.defineProperty(exports,"SSR",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"SSRContext",{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,"SSRState",{enumerable:!0,get:function(){return D}}),exports.generateHydrationScript=p,exports.renderDocument=m,exports.renderNodeToString=u,exports.renderToString=d,exports.renderToStringWithRoot=f;
|
package/dist/ssr.mjs
ADDED
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import { D as e, E as t, T as n, a as r, d as i, f as a, i as o, n as s, o as c, r as l, s as u, u as d } from "./RuntimeAttr.res-DAZkL5CF.mjs";
|
|
2
|
+
import { t as f } from "./Stdlib_Array-1YCQzU_Y.mjs";
|
|
3
|
+
import { a as p, c as m, i as h, l as ee, n as te, o as g, r as _, s as v, t as ne, u as re } from "./RuntimeHydrationMarkers.res-DHikAvHr.mjs";
|
|
4
|
+
//#region src/RuntimeHtml.res.mjs
|
|
5
|
+
function y(e) {
|
|
6
|
+
return e.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll("\"", """).replaceAll("'", "'");
|
|
7
|
+
}
|
|
8
|
+
var ie = [
|
|
9
|
+
"area",
|
|
10
|
+
"base",
|
|
11
|
+
"br",
|
|
12
|
+
"col",
|
|
13
|
+
"embed",
|
|
14
|
+
"hr",
|
|
15
|
+
"img",
|
|
16
|
+
"input",
|
|
17
|
+
"link",
|
|
18
|
+
"meta",
|
|
19
|
+
"param",
|
|
20
|
+
"source",
|
|
21
|
+
"track",
|
|
22
|
+
"wbr"
|
|
23
|
+
];
|
|
24
|
+
function ae(e) {
|
|
25
|
+
return ie.includes(e);
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/SSR.res.mjs
|
|
29
|
+
var oe = /* @__PURE__ */ e({
|
|
30
|
+
Attributes: () => S,
|
|
31
|
+
Html: () => O,
|
|
32
|
+
Markers: () => k,
|
|
33
|
+
generateHydrationScript: () => E,
|
|
34
|
+
renderDocument: () => D,
|
|
35
|
+
renderNodeToString: () => C,
|
|
36
|
+
renderToString: () => w,
|
|
37
|
+
renderToStringWithRoot: () => T
|
|
38
|
+
});
|
|
39
|
+
function b(e) {
|
|
40
|
+
let t = e[1], n = e[0], r;
|
|
41
|
+
switch (t.TAG) {
|
|
42
|
+
case "Static":
|
|
43
|
+
r = t._0;
|
|
44
|
+
break;
|
|
45
|
+
case "SignalValue":
|
|
46
|
+
r = i(t._0);
|
|
47
|
+
break;
|
|
48
|
+
case "Compute":
|
|
49
|
+
r = t._0();
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
return s(n) ? l(r) ? n : "" : n + "=\"" + y(r) + "\"";
|
|
53
|
+
}
|
|
54
|
+
function x(e) {
|
|
55
|
+
let t = e.map(b).filter((e) => e !== "");
|
|
56
|
+
return t.length === 0 ? "" : " " + t.join(" ");
|
|
57
|
+
}
|
|
58
|
+
var S = {
|
|
59
|
+
renderAttr: b,
|
|
60
|
+
renderAttrs: x
|
|
61
|
+
};
|
|
62
|
+
function C(e) {
|
|
63
|
+
for (;;) {
|
|
64
|
+
let t = e;
|
|
65
|
+
switch (t.TAG) {
|
|
66
|
+
case "Element":
|
|
67
|
+
let n = t.tag, r = x(t.attrs);
|
|
68
|
+
if (ae(n)) return "<" + n + r + " />";
|
|
69
|
+
let a = t.children.map(C).join("");
|
|
70
|
+
return "<" + n + r + ">" + a + "</" + n + ">";
|
|
71
|
+
case "Text": return y(t._0);
|
|
72
|
+
case "SignalText": return re + y(i(t._0)) + ee;
|
|
73
|
+
case "Fragment": return t._0.map(C).join("");
|
|
74
|
+
case "SignalFragment": return m + i(t._0).map(C).join("") + v;
|
|
75
|
+
case "Keyed":
|
|
76
|
+
e = t.child;
|
|
77
|
+
continue;
|
|
78
|
+
case "LazyComponent": return g + C(t._0()) + p;
|
|
79
|
+
case "KeyedList":
|
|
80
|
+
let o = t.renderItem, s = t.keyFn;
|
|
81
|
+
return h + i(t.signal).map((e) => {
|
|
82
|
+
let t = s(e), n = C(o(e));
|
|
83
|
+
return te(t) + n + ne;
|
|
84
|
+
}).join("") + _;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function w(e, t) {
|
|
89
|
+
return C(e());
|
|
90
|
+
}
|
|
91
|
+
function T(e, t, n) {
|
|
92
|
+
let r = t === void 0 ? "root" : t, i = C(e());
|
|
93
|
+
return "<!--xote-root:" + r + "-->" + i + "<!--/xote-root-->";
|
|
94
|
+
}
|
|
95
|
+
function E(e) {
|
|
96
|
+
return "<script" + (e === void 0 ? "" : " nonce=\"" + y(e) + "\"") + ">window.__XOTE_HYDRATED__=false;<\/script>";
|
|
97
|
+
}
|
|
98
|
+
function D(e, t, n, r, i, a, o) {
|
|
99
|
+
let s = e === void 0 ? "" : e, c = t === void 0 ? "" : t, l = n === void 0 ? [] : n, u = r === void 0 ? [] : r, d = i === void 0 ? "" : i, f = w(o, void 0), p = E(a), m = u.map((e) => "<link rel=\"stylesheet\" href=\"" + y(e) + "\" />").join("\n "), h = l.map((e) => {
|
|
100
|
+
let t = a === void 0 ? "" : " nonce=\"" + y(a) + "\"";
|
|
101
|
+
return "<script type=\"module\" src=\"" + y(e) + "\"" + t + "><\/script>";
|
|
102
|
+
}).join("\n ");
|
|
103
|
+
return "<!DOCTYPE html>\n<html>\n <head>\n <meta charset=\"UTF-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n " + m + "\n " + s + "\n </head>\n <body" + (c === "" ? "" : " " + c) + ">\n <div id=\"root\">" + f + "</div>\n " + d + "\n " + p + "\n " + h + "\n </body>\n</html>";
|
|
104
|
+
}
|
|
105
|
+
var O, k, se = /* @__PURE__ */ e({
|
|
106
|
+
isClient: () => j,
|
|
107
|
+
isServer: () => A,
|
|
108
|
+
match: () => P,
|
|
109
|
+
onClient: () => N,
|
|
110
|
+
onServer: () => M
|
|
111
|
+
}), A = typeof document > "u", j = !A;
|
|
112
|
+
function M(e) {
|
|
113
|
+
if (A) return n(e());
|
|
114
|
+
}
|
|
115
|
+
function N(e) {
|
|
116
|
+
if (j) return n(e());
|
|
117
|
+
}
|
|
118
|
+
function P(e, t) {
|
|
119
|
+
return A ? e() : t();
|
|
120
|
+
}
|
|
121
|
+
//#endregion
|
|
122
|
+
//#region node_modules/@rescript/runtime/lib/es6/Stdlib_JSON.js
|
|
123
|
+
function F(e) {
|
|
124
|
+
if (typeof e == "boolean") return e;
|
|
125
|
+
}
|
|
126
|
+
function I(e) {
|
|
127
|
+
if (e === null) return null;
|
|
128
|
+
}
|
|
129
|
+
function L(e) {
|
|
130
|
+
if (typeof e == "string") return e;
|
|
131
|
+
}
|
|
132
|
+
function R(e) {
|
|
133
|
+
if (typeof e == "number") return e;
|
|
134
|
+
}
|
|
135
|
+
function z(e) {
|
|
136
|
+
if (typeof e == "object" && e && !Array.isArray(e)) return e;
|
|
137
|
+
}
|
|
138
|
+
function B(e) {
|
|
139
|
+
if (Array.isArray(e)) return e;
|
|
140
|
+
}
|
|
141
|
+
var V = {
|
|
142
|
+
bool: F,
|
|
143
|
+
$$null: I,
|
|
144
|
+
string: L,
|
|
145
|
+
float: R,
|
|
146
|
+
object: z,
|
|
147
|
+
array: B
|
|
148
|
+
}, H = /* @__PURE__ */ e({
|
|
149
|
+
Codec: () => xe,
|
|
150
|
+
clear: () => Se,
|
|
151
|
+
escapeForScript: () => X,
|
|
152
|
+
generateScript: () => Ce,
|
|
153
|
+
getClientState: () => Z,
|
|
154
|
+
register: () => Y,
|
|
155
|
+
registry: () => J,
|
|
156
|
+
restore: () => Q,
|
|
157
|
+
signal: () => we,
|
|
158
|
+
sync: () => $
|
|
159
|
+
});
|
|
160
|
+
function U(e) {
|
|
161
|
+
return e;
|
|
162
|
+
}
|
|
163
|
+
function W(e) {
|
|
164
|
+
let t = V.float(e);
|
|
165
|
+
if (t !== void 0) return t | 0;
|
|
166
|
+
}
|
|
167
|
+
var G = {
|
|
168
|
+
encode: U,
|
|
169
|
+
decode: W
|
|
170
|
+
};
|
|
171
|
+
function K(e) {
|
|
172
|
+
return e;
|
|
173
|
+
}
|
|
174
|
+
function ce(e) {
|
|
175
|
+
return V.float(e);
|
|
176
|
+
}
|
|
177
|
+
var le = {
|
|
178
|
+
encode: K,
|
|
179
|
+
decode: ce
|
|
180
|
+
};
|
|
181
|
+
function ue(e) {
|
|
182
|
+
return e;
|
|
183
|
+
}
|
|
184
|
+
function de(e) {
|
|
185
|
+
return V.string(e);
|
|
186
|
+
}
|
|
187
|
+
var fe = {
|
|
188
|
+
encode: ue,
|
|
189
|
+
decode: de
|
|
190
|
+
};
|
|
191
|
+
function pe(e) {
|
|
192
|
+
return e;
|
|
193
|
+
}
|
|
194
|
+
function me(e) {
|
|
195
|
+
return V.bool(e);
|
|
196
|
+
}
|
|
197
|
+
var he = {
|
|
198
|
+
encode: pe,
|
|
199
|
+
decode: me
|
|
200
|
+
};
|
|
201
|
+
function ge(e) {
|
|
202
|
+
return {
|
|
203
|
+
encode: (t) => t.map(e.encode),
|
|
204
|
+
decode: (t) => {
|
|
205
|
+
let n = V.array(t);
|
|
206
|
+
if (n === void 0) return;
|
|
207
|
+
let r = f(n, e.decode);
|
|
208
|
+
if (r.length === n.length) return r;
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
function _e(e) {
|
|
213
|
+
return {
|
|
214
|
+
encode: (n) => n === void 0 ? null : e.encode(t(n)),
|
|
215
|
+
decode: (t) => r(V.$$null(t)) ? n(void 0) : c(e.decode(t), (e) => n(e))
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
function ve(e, n) {
|
|
219
|
+
return {
|
|
220
|
+
encode: (t) => [e.encode(t[0]), n.encode(t[1])],
|
|
221
|
+
decode: (r) => {
|
|
222
|
+
let i = Array.isArray(r) ? r : void 0;
|
|
223
|
+
if (i === void 0 || i.length !== 2) return;
|
|
224
|
+
let a = i[0], o = i[1], s = e.decode(a), c = n.decode(o);
|
|
225
|
+
if (s !== void 0 && c !== void 0) return [t(s), t(c)];
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
function ye(e, n, r) {
|
|
230
|
+
return {
|
|
231
|
+
encode: (t) => [
|
|
232
|
+
e.encode(t[0]),
|
|
233
|
+
n.encode(t[1]),
|
|
234
|
+
r.encode(t[2])
|
|
235
|
+
],
|
|
236
|
+
decode: (i) => {
|
|
237
|
+
let a = Array.isArray(i) ? i : void 0;
|
|
238
|
+
if (a === void 0 || a.length !== 3) return;
|
|
239
|
+
let o = a[0], s = a[1], c = a[2], l = e.decode(o), u = n.decode(s), d = r.decode(c);
|
|
240
|
+
if (l !== void 0 && u !== void 0 && d !== void 0) return [
|
|
241
|
+
t(l),
|
|
242
|
+
t(u),
|
|
243
|
+
t(d)
|
|
244
|
+
];
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
function q(e) {
|
|
249
|
+
return {
|
|
250
|
+
encode: (t) => {
|
|
251
|
+
let n = {};
|
|
252
|
+
return Object.entries(t).forEach((t) => {
|
|
253
|
+
n[t[0]] = e.encode(t[1]);
|
|
254
|
+
}), n;
|
|
255
|
+
},
|
|
256
|
+
decode: (n) => {
|
|
257
|
+
let r = V.object(n);
|
|
258
|
+
if (r === void 0) return;
|
|
259
|
+
let i = {}, a = { contents: !0 };
|
|
260
|
+
if (Object.entries(r).forEach((n) => {
|
|
261
|
+
let r = e.decode(n[1]);
|
|
262
|
+
r === void 0 ? a.contents = !1 : i[n[0]] = t(r);
|
|
263
|
+
}), a.contents) return i;
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
function be(e, t) {
|
|
268
|
+
return {
|
|
269
|
+
encode: e,
|
|
270
|
+
decode: t
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
var xe = {
|
|
274
|
+
int: G,
|
|
275
|
+
float: le,
|
|
276
|
+
string: fe,
|
|
277
|
+
bool: he,
|
|
278
|
+
array: ge,
|
|
279
|
+
option: _e,
|
|
280
|
+
tuple2: ve,
|
|
281
|
+
tuple3: ye,
|
|
282
|
+
dict: q,
|
|
283
|
+
make: be
|
|
284
|
+
}, J = {};
|
|
285
|
+
function Y(e, t, n) {
|
|
286
|
+
if (A) {
|
|
287
|
+
J[e] = n.encode(i(t));
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
function Se() {
|
|
292
|
+
Object.keys(J).forEach((e) => {
|
|
293
|
+
u(J, e);
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
function X(e) {
|
|
297
|
+
return e.replaceAll("<\/script>", "<\\/script>").replaceAll("<!--", "<\\!--");
|
|
298
|
+
}
|
|
299
|
+
function Ce(e) {
|
|
300
|
+
let t = X(o(JSON.stringify(J), "{}"));
|
|
301
|
+
return "<script" + (e === void 0 ? "" : " nonce=\"" + y(e) + "\"") + ">window.__XOTE_STATE__=" + t + ";<\/script>";
|
|
302
|
+
}
|
|
303
|
+
function Z() {
|
|
304
|
+
return j && window.__XOTE_STATE__ || {};
|
|
305
|
+
}
|
|
306
|
+
function Q(e, n, r) {
|
|
307
|
+
if (!j) return;
|
|
308
|
+
let i = Z()[e];
|
|
309
|
+
if (i === void 0) return;
|
|
310
|
+
let o = r.decode(i);
|
|
311
|
+
if (o !== void 0) return a(n, t(o));
|
|
312
|
+
}
|
|
313
|
+
function $(e, t, n) {
|
|
314
|
+
P(() => Y(e, t, n), () => Q(e, t, n));
|
|
315
|
+
}
|
|
316
|
+
function we(e, t, n) {
|
|
317
|
+
let r = d(t, void 0, void 0);
|
|
318
|
+
return $(e, r, n), r;
|
|
319
|
+
}
|
|
320
|
+
//#endregion
|
|
321
|
+
export { S as Attributes, O as Html, k as Markers, oe as SSR, se as SSRContext, H as SSRState, E as generateHydrationScript, D as renderDocument, C as renderNodeToString, w as renderToString, T as renderToStringWithRoot };
|