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.
Files changed (48) hide show
  1. package/README.md +132 -33
  2. package/dist/RuntimeAttr.res-Cr5Qmz0i.js +1 -0
  3. package/dist/RuntimeAttr.res-DAZkL5CF.mjs +539 -0
  4. package/dist/RuntimeHydrationMarkers.res-C5-ieaOS.js +1 -0
  5. package/dist/RuntimeHydrationMarkers.res-DHikAvHr.mjs +6 -0
  6. package/dist/RuntimeJsxProp.res-A6N-qWoK.js +1 -0
  7. package/dist/RuntimeJsxProp.res-D3W5GXqT.mjs +64 -0
  8. package/dist/Stdlib_Array-1YCQzU_Y.mjs +22 -0
  9. package/dist/Stdlib_Array-BeBVUIuY.js +1 -0
  10. package/dist/View.res-C36--SJD.js +1 -0
  11. package/dist/View.res-SuqJrQPC.mjs +777 -0
  12. package/dist/client.cjs +1 -0
  13. package/dist/client.mjs +131 -0
  14. package/dist/hydration.cjs +1 -0
  15. package/dist/hydration.mjs +385 -0
  16. package/dist/mdx.cjs +1 -0
  17. package/dist/mdx.mjs +50 -0
  18. package/dist/router.cjs +1 -0
  19. package/dist/router.mjs +276 -0
  20. package/dist/ssr.cjs +17 -0
  21. package/dist/ssr.mjs +321 -0
  22. package/dist/xote.cjs +1 -17
  23. package/dist/xote.mjs +1450 -2459
  24. package/dist/xote.umd.js +1 -17
  25. package/package.json +42 -10
  26. package/rescript.json +2 -2
  27. package/src/Mdx.res +77 -0
  28. package/src/Mdx.res.mjs +93 -0
  29. package/src/Router.res +62 -8
  30. package/src/Router.res.mjs +60 -6
  31. package/src/RuntimeDom.res +7 -0
  32. package/src/RuntimeDom.res.mjs +8 -0
  33. package/src/RuntimeJsxProp.res +5 -8
  34. package/src/RuntimeJsxProp.res.mjs +9 -10
  35. package/src/RuntimeValue.res +35 -0
  36. package/src/RuntimeValue.res.mjs +67 -0
  37. package/src/SSRState.res +1 -4
  38. package/src/SSRState.res.mjs +4 -10
  39. package/src/View.res +233 -39
  40. package/src/View.res.mjs +309 -32
  41. package/src/XoteJSX.res +214 -0
  42. package/src/XoteJSX.res.mjs +63 -0
  43. package/src/jsx-dev-runtime.mjs +7 -0
  44. package/src/jsx-runtime.mjs +276 -0
  45. package/src/Node.res +0 -2
  46. package/src/Node.res.mjs +0 -82
  47. package/src/ReactiveProp.res +0 -2
  48. package/src/ReactiveProp.res.mjs +0 -19
@@ -104,6 +104,69 @@ function propsToAttrs(props) {
104
104
  addAttr(attrs, props["aria-hidden"], "aria-hidden", RuntimeJsxProp$Xote.toBoolAttr);
105
105
  addAttr(attrs, props["aria-expanded"], "aria-expanded", RuntimeJsxProp$Xote.toBoolAttr);
106
106
  addAttr(attrs, props["aria-selected"], "aria-selected", RuntimeJsxProp$Xote.toBoolAttr);
107
+ addAttr(attrs, props.xmlns, "xmlns", RuntimeJsxProp$Xote.toStringAttr);
108
+ addAttr(attrs, props["xmlns:xlink"], "xmlns:xlink", RuntimeJsxProp$Xote.toStringAttr);
109
+ addAttr(attrs, props.version, "version", RuntimeJsxProp$Xote.toStringAttr);
110
+ addAttr(attrs, props.viewBox, "viewBox", RuntimeJsxProp$Xote.toStringAttr);
111
+ addAttr(attrs, props.preserveAspectRatio, "preserveAspectRatio", RuntimeJsxProp$Xote.toStringAttr);
112
+ addAttr(attrs, props.d, "d", RuntimeJsxProp$Xote.toStringAttr);
113
+ addAttr(attrs, props.pathLength, "pathLength", RuntimeJsxProp$Xote.toStringAttr);
114
+ addAttr(attrs, props.cx, "cx", RuntimeJsxProp$Xote.toStringAttr);
115
+ addAttr(attrs, props.cy, "cy", RuntimeJsxProp$Xote.toStringAttr);
116
+ addAttr(attrs, props.r, "r", RuntimeJsxProp$Xote.toStringAttr);
117
+ addAttr(attrs, props.rx, "rx", RuntimeJsxProp$Xote.toStringAttr);
118
+ addAttr(attrs, props.ry, "ry", RuntimeJsxProp$Xote.toStringAttr);
119
+ addAttr(attrs, props.x, "x", RuntimeJsxProp$Xote.toStringAttr);
120
+ addAttr(attrs, props.y, "y", RuntimeJsxProp$Xote.toStringAttr);
121
+ addAttr(attrs, props.x1, "x1", RuntimeJsxProp$Xote.toStringAttr);
122
+ addAttr(attrs, props.y1, "y1", RuntimeJsxProp$Xote.toStringAttr);
123
+ addAttr(attrs, props.x2, "x2", RuntimeJsxProp$Xote.toStringAttr);
124
+ addAttr(attrs, props.y2, "y2", RuntimeJsxProp$Xote.toStringAttr);
125
+ addAttr(attrs, props.fx, "fx", RuntimeJsxProp$Xote.toStringAttr);
126
+ addAttr(attrs, props.fy, "fy", RuntimeJsxProp$Xote.toStringAttr);
127
+ addAttr(attrs, props.dx, "dx", RuntimeJsxProp$Xote.toStringAttr);
128
+ addAttr(attrs, props.dy, "dy", RuntimeJsxProp$Xote.toStringAttr);
129
+ addAttr(attrs, props.points, "points", RuntimeJsxProp$Xote.toStringAttr);
130
+ addAttr(attrs, props.transform, "transform", RuntimeJsxProp$Xote.toStringAttr);
131
+ addAttr(attrs, props["transform-origin"], "transform-origin", RuntimeJsxProp$Xote.toStringAttr);
132
+ addAttr(attrs, props.fill, "fill", RuntimeJsxProp$Xote.toStringAttr);
133
+ addAttr(attrs, props["fill-opacity"], "fill-opacity", RuntimeJsxProp$Xote.toStringAttr);
134
+ addAttr(attrs, props["fill-rule"], "fill-rule", RuntimeJsxProp$Xote.toStringAttr);
135
+ addAttr(attrs, props.stroke, "stroke", RuntimeJsxProp$Xote.toStringAttr);
136
+ addAttr(attrs, props["stroke-width"], "stroke-width", RuntimeJsxProp$Xote.toStringAttr);
137
+ addAttr(attrs, props["stroke-linecap"], "stroke-linecap", RuntimeJsxProp$Xote.toStringAttr);
138
+ addAttr(attrs, props["stroke-linejoin"], "stroke-linejoin", RuntimeJsxProp$Xote.toStringAttr);
139
+ addAttr(attrs, props["stroke-dasharray"], "stroke-dasharray", RuntimeJsxProp$Xote.toStringAttr);
140
+ addAttr(attrs, props["stroke-dashoffset"], "stroke-dashoffset", RuntimeJsxProp$Xote.toStringAttr);
141
+ addAttr(attrs, props["stroke-opacity"], "stroke-opacity", RuntimeJsxProp$Xote.toStringAttr);
142
+ addAttr(attrs, props["stroke-miterlimit"], "stroke-miterlimit", RuntimeJsxProp$Xote.toStringAttr);
143
+ addAttr(attrs, props.opacity, "opacity", RuntimeJsxProp$Xote.toStringAttr);
144
+ addAttr(attrs, props.color, "color", RuntimeJsxProp$Xote.toStringAttr);
145
+ addAttr(attrs, props.visibility, "visibility", RuntimeJsxProp$Xote.toStringAttr);
146
+ addAttr(attrs, props["vector-effect"], "vector-effect", RuntimeJsxProp$Xote.toStringAttr);
147
+ addAttr(attrs, props["pointer-events"], "pointer-events", RuntimeJsxProp$Xote.toStringAttr);
148
+ addAttr(attrs, props["clip-path"], "clip-path", RuntimeJsxProp$Xote.toStringAttr);
149
+ addAttr(attrs, props["clip-rule"], "clip-rule", RuntimeJsxProp$Xote.toStringAttr);
150
+ addAttr(attrs, props.mask, "mask", RuntimeJsxProp$Xote.toStringAttr);
151
+ addAttr(attrs, props.filter, "filter", RuntimeJsxProp$Xote.toStringAttr);
152
+ addAttr(attrs, props["text-anchor"], "text-anchor", RuntimeJsxProp$Xote.toStringAttr);
153
+ addAttr(attrs, props["dominant-baseline"], "dominant-baseline", RuntimeJsxProp$Xote.toStringAttr);
154
+ addAttr(attrs, props["font-family"], "font-family", RuntimeJsxProp$Xote.toStringAttr);
155
+ addAttr(attrs, props["font-size"], "font-size", RuntimeJsxProp$Xote.toStringAttr);
156
+ addAttr(attrs, props["font-weight"], "font-weight", RuntimeJsxProp$Xote.toStringAttr);
157
+ addAttr(attrs, props["letter-spacing"], "letter-spacing", RuntimeJsxProp$Xote.toStringAttr);
158
+ addAttr(attrs, props["word-spacing"], "word-spacing", RuntimeJsxProp$Xote.toStringAttr);
159
+ addAttr(attrs, props["text-decoration"], "text-decoration", RuntimeJsxProp$Xote.toStringAttr);
160
+ addAttr(attrs, props.offset, "offset", RuntimeJsxProp$Xote.toStringAttr);
161
+ addAttr(attrs, props["stop-color"], "stop-color", RuntimeJsxProp$Xote.toStringAttr);
162
+ addAttr(attrs, props["stop-opacity"], "stop-opacity", RuntimeJsxProp$Xote.toStringAttr);
163
+ addAttr(attrs, props.gradientUnits, "gradientUnits", RuntimeJsxProp$Xote.toStringAttr);
164
+ addAttr(attrs, props.gradientTransform, "gradientTransform", RuntimeJsxProp$Xote.toStringAttr);
165
+ addAttr(attrs, props.spreadMethod, "spreadMethod", RuntimeJsxProp$Xote.toStringAttr);
166
+ addAttr(attrs, props["marker-start"], "marker-start", RuntimeJsxProp$Xote.toStringAttr);
167
+ addAttr(attrs, props["marker-mid"], "marker-mid", RuntimeJsxProp$Xote.toStringAttr);
168
+ addAttr(attrs, props["marker-end"], "marker-end", RuntimeJsxProp$Xote.toStringAttr);
169
+ addAttr(attrs, props["xlink:href"], "xlink:href", RuntimeJsxProp$Xote.toStringAttr);
107
170
  let dataObj = props.data;
108
171
  if (dataObj !== undefined) {
109
172
  let entries = (Object.entries(dataObj));
@@ -0,0 +1,7 @@
1
+ import { jsx } from "./jsx-runtime.mjs";
2
+
3
+ export { Fragment, jsx, jsxs } from "./jsx-runtime.mjs";
4
+
5
+ export function jsxDEV(type, props, key) {
6
+ return jsx(type, props, key);
7
+ }
@@ -0,0 +1,276 @@
1
+ import * as Computed from "./Computed.res.mjs";
2
+ import * as Signal from "./Signal.res.mjs";
3
+ import * as View from "./View.res.mjs";
4
+
5
+ export const Fragment = Symbol.for("xote.fragment");
6
+
7
+ const nodeTags = new Set([
8
+ "Element",
9
+ "Text",
10
+ "SignalText",
11
+ "Fragment",
12
+ "SignalFragment",
13
+ "Keyed",
14
+ "LazyComponent",
15
+ "KeyedList",
16
+ ]);
17
+
18
+ const eventAliases = {
19
+ onChange: "change",
20
+ onClick: "click",
21
+ onContextMenu: "contextmenu",
22
+ onDoubleClick: "dblclick",
23
+ onInput: "input",
24
+ onSubmit: "submit",
25
+ onFocus: "focus",
26
+ onBlur: "blur",
27
+ onKeyDown: "keydown",
28
+ onKeyUp: "keyup",
29
+ onMouseDown: "mousedown",
30
+ onMouseEnter: "mouseenter",
31
+ onMouseLeave: "mouseleave",
32
+ onMouseMove: "mousemove",
33
+ onMouseUp: "mouseup",
34
+ onDrag: "drag",
35
+ onDragStart: "dragstart",
36
+ onDragEnd: "dragend",
37
+ onDragOver: "dragover",
38
+ onDragEnter: "dragenter",
39
+ onDragLeave: "dragleave",
40
+ onDrop: "drop",
41
+ };
42
+
43
+ const attrAliases = {
44
+ acceptCharset: "accept-charset",
45
+ autoFocus: "autofocus",
46
+ className: "class",
47
+ contentEditable: "contenteditable",
48
+ htmlFor: "for",
49
+ httpEquiv: "http-equiv",
50
+ maxLength: "maxlength",
51
+ minLength: "minlength",
52
+ preserveAspectRatio: "preserveAspectRatio",
53
+ readOnly: "readonly",
54
+ spellCheck: "spellcheck",
55
+ srcSet: "srcset",
56
+ strokeDasharray: "stroke-dasharray",
57
+ strokeDashoffset: "stroke-dashoffset",
58
+ strokeLinecap: "stroke-linecap",
59
+ strokeLinejoin: "stroke-linejoin",
60
+ strokeMiterlimit: "stroke-miterlimit",
61
+ strokeWidth: "stroke-width",
62
+ tabIndex: "tabindex",
63
+ viewBox: "viewBox",
64
+ xlinkHref: "xlink:href",
65
+ };
66
+
67
+ const internalProps = new Set([
68
+ "children",
69
+ "components",
70
+ "key",
71
+ "mdxType",
72
+ "originalType",
73
+ "parentName",
74
+ "ref",
75
+ ]);
76
+
77
+ function isXoteNode(value) {
78
+ return value && typeof value === "object" && nodeTags.has(value.TAG);
79
+ }
80
+
81
+ function isReactiveProp(value) {
82
+ return (
83
+ value &&
84
+ typeof value === "object" &&
85
+ (value.TAG === "Static" || value.TAG === "Reactive")
86
+ );
87
+ }
88
+
89
+ function isSignal(value) {
90
+ return (
91
+ value &&
92
+ typeof value === "object" &&
93
+ "subs" in value &&
94
+ "value" in value &&
95
+ typeof value.equals === "function"
96
+ );
97
+ }
98
+
99
+ function toKebab(name) {
100
+ return name.replace(/[A-Z]/g, char => `-${char.toLowerCase()}`);
101
+ }
102
+
103
+ function normalizeAttrName(name) {
104
+ if (attrAliases[name]) {
105
+ return attrAliases[name];
106
+ }
107
+
108
+ if (/^(aria|data)[A-Z]/.test(name)) {
109
+ return toKebab(name);
110
+ }
111
+
112
+ return name;
113
+ }
114
+
115
+ function normalizeStyle(style) {
116
+ if (typeof style === "string") {
117
+ return style;
118
+ }
119
+
120
+ if (!style || typeof style !== "object") {
121
+ return String(style ?? "");
122
+ }
123
+
124
+ return Object.entries(style)
125
+ .filter(([, value]) => value !== null && value !== undefined && value !== false)
126
+ .map(([key, value]) => `${toKebab(key)}:${String(value)}`)
127
+ .join(";");
128
+ }
129
+
130
+ function stringifyAttrValue(name, value) {
131
+ if (name === "style") {
132
+ return normalizeStyle(value);
133
+ }
134
+
135
+ return String(value);
136
+ }
137
+
138
+ function attrFromValue(name, value) {
139
+ if (isReactiveProp(value)) {
140
+ if (value.TAG === "Static") {
141
+ return View.attr(name, stringifyAttrValue(name, value._0));
142
+ }
143
+
144
+ const signal = value._0;
145
+ return View.signalAttr(
146
+ name,
147
+ Computed.make(() => stringifyAttrValue(name, Signal.get(signal)), undefined, undefined),
148
+ );
149
+ }
150
+
151
+ if (isSignal(value)) {
152
+ return View.signalAttr(
153
+ name,
154
+ Computed.make(() => stringifyAttrValue(name, Signal.get(value)), undefined, undefined),
155
+ );
156
+ }
157
+
158
+ if (typeof value === "function") {
159
+ return View.computedAttr(name, () => stringifyAttrValue(name, value()));
160
+ }
161
+
162
+ return View.attr(name, stringifyAttrValue(name, value));
163
+ }
164
+
165
+ function eventNameFromProp(name, value) {
166
+ if (typeof value !== "function" || !/^on[A-Z]/.test(name)) {
167
+ return null;
168
+ }
169
+
170
+ return eventAliases[name] ?? name.slice(2).toLowerCase();
171
+ }
172
+
173
+ function normalizeChildren(children) {
174
+ if (children === null || children === undefined || typeof children === "boolean") {
175
+ return [];
176
+ }
177
+
178
+ if (Array.isArray(children)) {
179
+ return children.flatMap(normalizeChildren);
180
+ }
181
+
182
+ if (isXoteNode(children)) {
183
+ return [children];
184
+ }
185
+
186
+ return [View.text(String(children))];
187
+ }
188
+
189
+ function normalizeNode(value) {
190
+ if (isXoteNode(value)) {
191
+ return value;
192
+ }
193
+
194
+ return View.fragment(normalizeChildren(value));
195
+ }
196
+
197
+ function buildElement(tag, props = {}) {
198
+ const attrs = [];
199
+ const events = [];
200
+
201
+ for (const [rawName, value] of Object.entries(props)) {
202
+ if (internalProps.has(rawName) || value === null || value === undefined) {
203
+ continue;
204
+ }
205
+
206
+ const eventName = eventNameFromProp(rawName, value);
207
+ if (eventName) {
208
+ events.push([eventName, value]);
209
+ continue;
210
+ }
211
+
212
+ const attrName = normalizeAttrName(rawName);
213
+ attrs.push(attrFromValue(attrName, value));
214
+ }
215
+
216
+ return View.element(tag, attrs, events, normalizeChildren(props.children), undefined);
217
+ }
218
+
219
+ function getReservedKey(props, key) {
220
+ if (key !== undefined && key !== null) {
221
+ return key;
222
+ }
223
+
224
+ return props?.key;
225
+ }
226
+
227
+ function stripReservedKey(props) {
228
+ if (!props || !Object.prototype.hasOwnProperty.call(props, "key")) {
229
+ return props ?? {};
230
+ }
231
+
232
+ const { key: _key, ...nextProps } = props;
233
+ return nextProps;
234
+ }
235
+
236
+ function withKey(node, key, props) {
237
+ const reservedKey = getReservedKey(props, key);
238
+
239
+ if (reservedKey === undefined || reservedKey === null) {
240
+ return node;
241
+ }
242
+
243
+ return {
244
+ TAG: "Keyed",
245
+ key: String(reservedKey),
246
+ identity: props ?? {},
247
+ child: node,
248
+ };
249
+ }
250
+
251
+ export function jsx(type, props, key) {
252
+ const nextProps = stripReservedKey(props);
253
+
254
+ if (type === Fragment) {
255
+ return withKey(View.fragment(normalizeChildren(nextProps.children)), key, props);
256
+ }
257
+
258
+ if (typeof type === "string") {
259
+ return withKey(buildElement(type, nextProps), key, props);
260
+ }
261
+
262
+ if (typeof type === "function") {
263
+ return withKey(
264
+ {
265
+ TAG: "LazyComponent",
266
+ _0: () => normalizeNode(type(nextProps)),
267
+ },
268
+ key,
269
+ props,
270
+ );
271
+ }
272
+
273
+ throw new TypeError(`Unsupported Xote JSX element type: ${String(type)}`);
274
+ }
275
+
276
+ export const jsxs = jsx;
package/src/Node.res DELETED
@@ -1,2 +0,0 @@
1
- @deprecated("Use View instead. Node is deprecated and will be removed in a future release.")
2
- include View
package/src/Node.res.mjs DELETED
@@ -1,82 +0,0 @@
1
- // Generated by ReScript, PLEASE EDIT WITH CARE
2
-
3
- import * as View$Xote from "./View.res.mjs";
4
-
5
- let DOM = View$Xote.DOM;
6
-
7
- let Reactivity = View$Xote.Reactivity;
8
-
9
- let Attributes = View$Xote.Attributes;
10
-
11
- let attr = View$Xote.attr;
12
-
13
- let signalAttr = View$Xote.signalAttr;
14
-
15
- let computedAttr = View$Xote.computedAttr;
16
-
17
- let Attr = View$Xote.Attr;
18
-
19
- let Render = View$Xote.Render;
20
-
21
- let text = View$Xote.text;
22
-
23
- let signalText = View$Xote.signalText;
24
-
25
- let signalInt = View$Xote.signalInt;
26
-
27
- let signalFloat = View$Xote.signalFloat;
28
-
29
- let int = View$Xote.int;
30
-
31
- let float = View$Xote.float;
32
-
33
- let fragment = View$Xote.fragment;
34
-
35
- let signalFragment = View$Xote.signalFragment;
36
-
37
- let each = View$Xote.each;
38
-
39
- let list = View$Xote.list;
40
-
41
- let eachWithKey = View$Xote.eachWithKey;
42
-
43
- let keyedList = View$Xote.keyedList;
44
-
45
- let element = View$Xote.element;
46
-
47
- let $$null = View$Xote.$$null;
48
-
49
- let empty = View$Xote.empty;
50
-
51
- let mount = View$Xote.mount;
52
-
53
- let mountById = View$Xote.mountById;
54
-
55
- export {
56
- DOM,
57
- Reactivity,
58
- Attributes,
59
- attr,
60
- signalAttr,
61
- computedAttr,
62
- Attr,
63
- Render,
64
- text,
65
- signalText,
66
- signalInt,
67
- signalFloat,
68
- int,
69
- float,
70
- fragment,
71
- signalFragment,
72
- each,
73
- list,
74
- eachWithKey,
75
- keyedList,
76
- element,
77
- $$null,
78
- empty,
79
- mount,
80
- mountById,
81
- }
82
- /* View-Xote Not a pure module */
@@ -1,2 +0,0 @@
1
- @deprecated("Use Prop instead. ReactiveProp is deprecated and will be removed in a future release.")
2
- include Prop
@@ -1,19 +0,0 @@
1
- // Generated by ReScript, PLEASE EDIT WITH CARE
2
-
3
- import * as Prop$Xote from "./Prop.res.mjs";
4
-
5
- let get = Prop$Xote.get;
6
-
7
- let $$static = Prop$Xote.$$static;
8
-
9
- let reactive = Prop$Xote.reactive;
10
-
11
- let signal = Prop$Xote.signal;
12
-
13
- export {
14
- get,
15
- $$static,
16
- reactive,
17
- signal,
18
- }
19
- /* No side effect */