@tilia/react 6.0.1 → 6.0.2

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/TiliaReact.mjs +54 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tilia/react",
3
- "version": "6.0.1",
3
+ "version": "6.0.2",
4
4
  "homepage": "https://tiliajs.dev/react",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -0,0 +1,54 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+
3
+ import * as Tilia from "tilia/src/Tilia.mjs";
4
+ import * as React from "react";
5
+
6
+ function make(ctx) {
7
+ let _observe = ctx._observe;
8
+ let tilia = ctx.tilia;
9
+ let useTilia = () => {
10
+ let match = React.useState(0);
11
+ let setCount = match[1];
12
+ let o = _observe(() => setCount(i => i + 1 | 0));
13
+ React.useEffect(() => {
14
+ Tilia._ready(o, true);
15
+ return () => Tilia._clear(o);
16
+ });
17
+ };
18
+ let useComputed = fn => React.useMemo(() => tilia({
19
+ value: Tilia.computed(fn)
20
+ }), []).value;
21
+ let leaf = fn => (p => {
22
+ let match = React.useState(0);
23
+ let setCount = match[1];
24
+ let o = _observe(() => setCount(i => i + 1 | 0));
25
+ React.useEffect(() => {
26
+ Tilia._ready(o, true);
27
+ return () => Tilia._clear(o);
28
+ });
29
+ let node = fn(p);
30
+ Tilia._done(o);
31
+ return node;
32
+ });
33
+ return {
34
+ useTilia: useTilia,
35
+ useComputed: useComputed,
36
+ leaf: leaf
37
+ };
38
+ }
39
+
40
+ let tr = make(Tilia._ctx);
41
+
42
+ let useTilia = tr.useTilia;
43
+
44
+ let useComputed = tr.useComputed;
45
+
46
+ let leaf = tr.leaf;
47
+
48
+ export {
49
+ useTilia,
50
+ useComputed,
51
+ leaf,
52
+ make,
53
+ }
54
+ /* tr Not a pure module */