xote 6.1.2 → 6.2.0
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 +90 -10
- package/dist/xote.cjs +10 -10
- package/dist/xote.mjs +1491 -1330
- package/dist/xote.umd.js +8 -8
- package/package.json +16 -1
- package/rescript.json +2 -0
- package/src/Html.res +13 -13
- package/src/Html.res.mjs +13 -13
- package/src/Hydration.res +134 -79
- package/src/Hydration.res.mjs +255 -186
- package/src/Node.res +2 -594
- package/src/Node.res.mjs +31 -535
- package/src/Prop.res +16 -0
- package/src/Prop.res.mjs +35 -0
- package/src/ReactiveProp.res +2 -14
- package/src/ReactiveProp.res.mjs +7 -20
- package/src/Route.res +4 -0
- package/src/Route.res.mjs +9 -0
- package/src/Router.res +25 -49
- package/src/Router.res.mjs +22 -34
- package/src/RuntimeAttr.res +21 -0
- package/src/RuntimeAttr.res.mjs +42 -0
- package/src/RuntimeDom.res +95 -0
- package/src/RuntimeDom.res.mjs +101 -0
- package/src/RuntimeHtml.res +27 -0
- package/src/RuntimeHtml.res.mjs +34 -0
- package/src/RuntimeHydrationMarkers.res +24 -0
- package/src/RuntimeHydrationMarkers.res.mjs +68 -0
- package/src/RuntimeJsxProp.res +46 -0
- package/src/RuntimeJsxProp.res.mjs +52 -0
- package/src/RuntimeOwner.res +43 -0
- package/src/RuntimeOwner.res.mjs +51 -0
- package/src/SSR.res +25 -93
- package/src/SSR.res.mjs +59 -126
- package/src/SSRState.res +3 -0
- package/src/SSRState.res.mjs +8 -2
- package/src/View.res +599 -0
- package/src/View.res.mjs +614 -0
- package/src/XoteJSX.res +64 -118
- package/src/XoteJSX.res.mjs +79 -118
package/src/SSR.res.mjs
CHANGED
|
@@ -1,72 +1,9 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
|
|
3
3
|
import * as Signal$Xote from "./Signal.res.mjs";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
let voidElements = [
|
|
10
|
-
"area",
|
|
11
|
-
"base",
|
|
12
|
-
"br",
|
|
13
|
-
"col",
|
|
14
|
-
"embed",
|
|
15
|
-
"hr",
|
|
16
|
-
"img",
|
|
17
|
-
"input",
|
|
18
|
-
"link",
|
|
19
|
-
"meta",
|
|
20
|
-
"param",
|
|
21
|
-
"source",
|
|
22
|
-
"track",
|
|
23
|
-
"wbr"
|
|
24
|
-
];
|
|
25
|
-
|
|
26
|
-
function isVoidElement(tag) {
|
|
27
|
-
return voidElements.includes(tag);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
let Html = {
|
|
31
|
-
escape: escape,
|
|
32
|
-
voidElements: voidElements,
|
|
33
|
-
isVoidElement: isVoidElement
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
let signalTextStart = "<!--$-->";
|
|
37
|
-
|
|
38
|
-
let signalTextEnd = "<!--/$-->";
|
|
39
|
-
|
|
40
|
-
let signalFragmentStart = "<!--#-->";
|
|
41
|
-
|
|
42
|
-
let signalFragmentEnd = "<!--/#-->";
|
|
43
|
-
|
|
44
|
-
let keyedListStart = "<!--kl-->";
|
|
45
|
-
|
|
46
|
-
let keyedListEnd = "<!--/kl-->";
|
|
47
|
-
|
|
48
|
-
function keyedItemStart(key) {
|
|
49
|
-
return `<!--k:` + key + `-->`;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
let keyedItemEnd = "<!--/k-->";
|
|
53
|
-
|
|
54
|
-
let lazyComponentStart = "<!--lc-->";
|
|
55
|
-
|
|
56
|
-
let lazyComponentEnd = "<!--/lc-->";
|
|
57
|
-
|
|
58
|
-
let Markers = {
|
|
59
|
-
signalTextStart: signalTextStart,
|
|
60
|
-
signalTextEnd: signalTextEnd,
|
|
61
|
-
signalFragmentStart: signalFragmentStart,
|
|
62
|
-
signalFragmentEnd: signalFragmentEnd,
|
|
63
|
-
keyedListStart: keyedListStart,
|
|
64
|
-
keyedListEnd: keyedListEnd,
|
|
65
|
-
keyedItemStart: keyedItemStart,
|
|
66
|
-
keyedItemEnd: keyedItemEnd,
|
|
67
|
-
lazyComponentStart: lazyComponentStart,
|
|
68
|
-
lazyComponentEnd: lazyComponentEnd
|
|
69
|
-
};
|
|
4
|
+
import * as RuntimeAttr$Xote from "./RuntimeAttr.res.mjs";
|
|
5
|
+
import * as RuntimeHtml$Xote from "./RuntimeHtml.res.mjs";
|
|
6
|
+
import * as RuntimeHydrationMarkers$Xote from "./RuntimeHydrationMarkers.res.mjs";
|
|
70
7
|
|
|
71
8
|
function renderAttr(param) {
|
|
72
9
|
let value = param[1];
|
|
@@ -83,28 +20,14 @@ function renderAttr(param) {
|
|
|
83
20
|
attrValue = value._0();
|
|
84
21
|
break;
|
|
85
22
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
case "contenteditable" :
|
|
93
|
-
case "disabled" :
|
|
94
|
-
case "draggable" :
|
|
95
|
-
case "hidden" :
|
|
96
|
-
case "multiple" :
|
|
97
|
-
case "readonly" :
|
|
98
|
-
case "required" :
|
|
99
|
-
case "spellcheck" :
|
|
100
|
-
break;
|
|
101
|
-
default:
|
|
102
|
-
return key + `="` + escape(attrValue) + `"`;
|
|
103
|
-
}
|
|
104
|
-
if (attrValue === "true") {
|
|
105
|
-
return key;
|
|
23
|
+
if (RuntimeAttr$Xote.isBoolean(key)) {
|
|
24
|
+
if (RuntimeAttr$Xote.shouldRenderBoolean(attrValue)) {
|
|
25
|
+
return key;
|
|
26
|
+
} else {
|
|
27
|
+
return "";
|
|
28
|
+
}
|
|
106
29
|
} else {
|
|
107
|
-
return ""
|
|
30
|
+
return key + `="` + RuntimeHtml$Xote.escape(attrValue) + `"`;
|
|
108
31
|
}
|
|
109
32
|
}
|
|
110
33
|
|
|
@@ -122,41 +45,47 @@ let Attributes = {
|
|
|
122
45
|
renderAttrs: renderAttrs
|
|
123
46
|
};
|
|
124
47
|
|
|
125
|
-
function renderNodeToString(
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
let
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
48
|
+
function renderNodeToString(_node) {
|
|
49
|
+
while (true) {
|
|
50
|
+
let node = _node;
|
|
51
|
+
switch (node.TAG) {
|
|
52
|
+
case "Element" :
|
|
53
|
+
let tag = node.tag;
|
|
54
|
+
let attrsStr = renderAttrs(node.attrs);
|
|
55
|
+
if (RuntimeHtml$Xote.isVoidElement(tag)) {
|
|
56
|
+
return `<` + tag + attrsStr + ` />`;
|
|
57
|
+
}
|
|
58
|
+
let childrenStr = node.children.map(renderNodeToString).join("");
|
|
59
|
+
return `<` + tag + attrsStr + `>` + childrenStr + `</` + tag + `>`;
|
|
60
|
+
case "Text" :
|
|
61
|
+
return RuntimeHtml$Xote.escape(node._0);
|
|
62
|
+
case "SignalText" :
|
|
63
|
+
let value = Signal$Xote.peek(node._0);
|
|
64
|
+
return RuntimeHydrationMarkers$Xote.signalTextStart + RuntimeHtml$Xote.escape(value) + RuntimeHydrationMarkers$Xote.signalTextEnd;
|
|
65
|
+
case "Fragment" :
|
|
66
|
+
return node._0.map(renderNodeToString).join("");
|
|
67
|
+
case "SignalFragment" :
|
|
68
|
+
let children = Signal$Xote.peek(node._0);
|
|
69
|
+
let content = children.map(renderNodeToString).join("");
|
|
70
|
+
return RuntimeHydrationMarkers$Xote.signalFragmentStart + content + RuntimeHydrationMarkers$Xote.signalFragmentEnd;
|
|
71
|
+
case "Keyed" :
|
|
72
|
+
_node = node.child;
|
|
73
|
+
continue;
|
|
74
|
+
case "LazyComponent" :
|
|
75
|
+
let childNode = node._0();
|
|
76
|
+
return RuntimeHydrationMarkers$Xote.lazyComponentStart + renderNodeToString(childNode) + RuntimeHydrationMarkers$Xote.lazyComponentEnd;
|
|
77
|
+
case "KeyedList" :
|
|
78
|
+
let renderItem = node.renderItem;
|
|
79
|
+
let keyFn = node.keyFn;
|
|
80
|
+
let items = Signal$Xote.peek(node.signal);
|
|
81
|
+
let content$1 = items.map(item => {
|
|
82
|
+
let key = keyFn(item);
|
|
83
|
+
let itemHtml = renderNodeToString(renderItem(item));
|
|
84
|
+
return RuntimeHydrationMarkers$Xote.keyedItemStart(key) + itemHtml + RuntimeHydrationMarkers$Xote.keyedItemEnd;
|
|
85
|
+
}).join("");
|
|
86
|
+
return RuntimeHydrationMarkers$Xote.keyedListStart + content$1 + RuntimeHydrationMarkers$Xote.keyedListEnd;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
160
89
|
}
|
|
161
90
|
|
|
162
91
|
function renderToString(component, optionsOpt) {
|
|
@@ -171,7 +100,7 @@ function renderToStringWithRoot(component, rootIdOpt, optionsOpt) {
|
|
|
171
100
|
}
|
|
172
101
|
|
|
173
102
|
function generateHydrationScript(nonce) {
|
|
174
|
-
let nonceAttr = nonce !== undefined ? ` nonce="` + escape(nonce) + `"` : "";
|
|
103
|
+
let nonceAttr = nonce !== undefined ? ` nonce="` + RuntimeHtml$Xote.escape(nonce) + `"` : "";
|
|
175
104
|
return `<script` + nonceAttr + `>window.__XOTE_HYDRATED__=false;</script>`;
|
|
176
105
|
}
|
|
177
106
|
|
|
@@ -183,10 +112,10 @@ function renderDocument(headOpt, bodyAttrsOpt, scriptsOpt, stylesOpt, stateScrip
|
|
|
183
112
|
let stateScript = stateScriptOpt !== undefined ? stateScriptOpt : "";
|
|
184
113
|
let content = renderToString(component, undefined);
|
|
185
114
|
let hydrationScript = generateHydrationScript(nonce);
|
|
186
|
-
let styleLinks = styles.map(href => `<link rel="stylesheet" href="` + escape(href) + `" />`).join("\n ");
|
|
115
|
+
let styleLinks = styles.map(href => `<link rel="stylesheet" href="` + RuntimeHtml$Xote.escape(href) + `" />`).join("\n ");
|
|
187
116
|
let scriptTags = scripts.map(src => {
|
|
188
|
-
let nonceAttr = nonce !== undefined ? ` nonce="` + escape(nonce) + `"` : "";
|
|
189
|
-
return `<script type="module" src="` + escape(src) + `"` + nonceAttr + `></script>`;
|
|
117
|
+
let nonceAttr = nonce !== undefined ? ` nonce="` + RuntimeHtml$Xote.escape(nonce) + `"` : "";
|
|
118
|
+
return `<script type="module" src="` + RuntimeHtml$Xote.escape(src) + `"` + nonceAttr + `></script>`;
|
|
190
119
|
}).join("\n ");
|
|
191
120
|
return `<!DOCTYPE html>
|
|
192
121
|
<html>
|
|
@@ -207,6 +136,10 @@ function renderDocument(headOpt, bodyAttrsOpt, scriptsOpt, stylesOpt, stateScrip
|
|
|
207
136
|
</html>`;
|
|
208
137
|
}
|
|
209
138
|
|
|
139
|
+
let Html;
|
|
140
|
+
|
|
141
|
+
let Markers;
|
|
142
|
+
|
|
210
143
|
export {
|
|
211
144
|
Html,
|
|
212
145
|
Markers,
|
package/src/SSRState.res
CHANGED
package/src/SSRState.res.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
|
|
3
|
-
import * as SSR$Xote from "./SSR.res.mjs";
|
|
4
3
|
import * as Signal$Xote from "./Signal.res.mjs";
|
|
5
4
|
import * as Stdlib_Dict from "@rescript/runtime/lib/es6/Stdlib_Dict.js";
|
|
6
5
|
import * as Stdlib_JSON from "@rescript/runtime/lib/es6/Stdlib_JSON.js";
|
|
@@ -8,6 +7,7 @@ import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.js";
|
|
|
8
7
|
import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
|
|
9
8
|
import * as SSRContext$Xote from "./SSRContext.res.mjs";
|
|
10
9
|
import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.js";
|
|
10
|
+
import * as RuntimeHtml$Xote from "./RuntimeHtml.res.mjs";
|
|
11
11
|
|
|
12
12
|
function int_encode(v) {
|
|
13
13
|
return v;
|
|
@@ -234,7 +234,7 @@ function escapeForScript(str) {
|
|
|
234
234
|
function generateScript(nonce) {
|
|
235
235
|
let json = Stdlib_Option.getOr(JSON.stringify(registry), "{}");
|
|
236
236
|
let escapedJson = escapeForScript(json);
|
|
237
|
-
let nonceAttr = nonce !== undefined ? ` nonce="` +
|
|
237
|
+
let nonceAttr = nonce !== undefined ? ` nonce="` + RuntimeHtml$Xote.escape(nonce) + `"` : "";
|
|
238
238
|
return `<script` + nonceAttr + `>window.__XOTE_STATE__=` + escapedJson + `;</script>`;
|
|
239
239
|
}
|
|
240
240
|
|
|
@@ -271,6 +271,10 @@ function make$1(id, initial, codec) {
|
|
|
271
271
|
return signal;
|
|
272
272
|
}
|
|
273
273
|
|
|
274
|
+
let signal = make$1;
|
|
275
|
+
|
|
276
|
+
let syncSignal = sync;
|
|
277
|
+
|
|
274
278
|
export {
|
|
275
279
|
Codec,
|
|
276
280
|
registry,
|
|
@@ -282,5 +286,7 @@ export {
|
|
|
282
286
|
restore,
|
|
283
287
|
sync,
|
|
284
288
|
make$1 as make,
|
|
289
|
+
signal,
|
|
290
|
+
syncSignal,
|
|
285
291
|
}
|
|
286
292
|
/* SSRContext-Xote Not a pure module */
|