@tilia/react 1.3.1 → 1.4.0-canary.20250117T230648

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/index.cjs ADDED
@@ -0,0 +1,41 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/index.js
20
+ var index_exports = {};
21
+ __export(index_exports, {
22
+ clear: () => import_core2.clear,
23
+ observe: () => import_core2.observe,
24
+ tilia: () => import_core2.tilia,
25
+ track: () => import_core2.track,
26
+ useTilia: () => useTilia
27
+ });
28
+ module.exports = __toCommonJS(index_exports);
29
+ var import_react = require("react");
30
+ var import_core = require("@tilia/core");
31
+ var import_core2 = require("@tilia/core");
32
+ function useTilia(p) {
33
+ const [, setCount] = (0, import_react.useState)(0);
34
+ const o = (0, import_core._connect)(p, () => setCount((i) => i + 1));
35
+ (0, import_react.useEffect)(function() {
36
+ (0, import_core._ready)(o);
37
+ return () => (0, import_core.clear)(o);
38
+ });
39
+ return p;
40
+ }
41
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.js"],
4
+ "sourcesContent": ["import { useState, useEffect } from \"react\";\nimport { _connect, _ready, clear } from \"@tilia/core\";\nexport { tilia, observe, track, clear } from \"@tilia/core\";\n\nexport function useTilia(p) {\n const [, setCount] = useState(0);\n const o = _connect(p, () => setCount((i) => i + 1));\n useEffect(function () {\n _ready(o);\n return () => clear(o);\n });\n return p;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAoC;AACpC,kBAAwC;AACxC,IAAAA,eAA6C;AAEtC,SAAS,SAAS,GAAG;AAC1B,QAAM,CAAC,EAAE,QAAQ,QAAI,uBAAS,CAAC;AAC/B,QAAM,QAAI,sBAAS,GAAG,MAAM,SAAS,CAAC,MAAM,IAAI,CAAC,CAAC;AAClD,8BAAU,WAAY;AACpB,4BAAO,CAAC;AACR,WAAO,UAAM,mBAAM,CAAC;AAAA,EACtB,CAAC;AACD,SAAO;AACT;",
6
+ "names": ["import_core"]
7
+ }
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
- export const tilia: <a>(tree: a) => a;
2
- export const observe: <a>(tree: a, callback: (tree: a) => void) => void;
1
+ export function tilia<a extends object>(tree: a): a;
2
+ export function observe<a>(tree: a, fn: (tree: a) => void): void;
3
+ export function track<a>(tree: a, fn: (tree: a) => void): observer;
4
+ export function clear(observer: observer): void;
3
5
  export const useTilia: <a>(tree: a) => a;
package/dist/index.mjs ADDED
@@ -0,0 +1,21 @@
1
+ // src/index.js
2
+ import { useState, useEffect } from "react";
3
+ import { _connect, _ready, clear } from "@tilia/core";
4
+ import { tilia, observe, track, clear as clear2 } from "@tilia/core";
5
+ function useTilia(p) {
6
+ const [, setCount] = useState(0);
7
+ const o = _connect(p, () => setCount((i) => i + 1));
8
+ useEffect(function() {
9
+ _ready(o);
10
+ return () => clear(o);
11
+ });
12
+ return p;
13
+ }
14
+ export {
15
+ clear2 as clear,
16
+ observe,
17
+ tilia,
18
+ track,
19
+ useTilia
20
+ };
21
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.js"],
4
+ "sourcesContent": ["import { useState, useEffect } from \"react\";\nimport { _connect, _ready, clear } from \"@tilia/core\";\nexport { tilia, observe, track, clear } from \"@tilia/core\";\n\nexport function useTilia(p) {\n const [, setCount] = useState(0);\n const o = _connect(p, () => setCount((i) => i + 1));\n useEffect(function () {\n _ready(o);\n return () => clear(o);\n });\n return p;\n}\n"],
5
+ "mappings": ";AAAA,SAAS,UAAU,iBAAiB;AACpC,SAAS,UAAU,QAAQ,aAAa;AACxC,SAAS,OAAO,SAAS,OAAO,SAAAA,cAAa;AAEtC,SAAS,SAAS,GAAG;AAC1B,QAAM,CAAC,EAAE,QAAQ,IAAI,SAAS,CAAC;AAC/B,QAAM,IAAI,SAAS,GAAG,MAAM,SAAS,CAAC,MAAM,IAAI,CAAC,CAAC;AAClD,YAAU,WAAY;AACpB,WAAO,CAAC;AACR,WAAO,MAAM,MAAM,CAAC;AAAA,EACtB,CAAC;AACD,SAAO;AACT;",
6
+ "names": ["clear"]
7
+ }
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@tilia/react",
3
- "version": "1.3.1",
4
- "main": "./dist/index.cjs.js",
5
- "module": "./dist/index.esm.js",
3
+ "version": "1.4.0-canary.20250117T230648",
4
+ "main": "./dist/index.cjs",
5
+ "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
7
7
  "type": "module",
8
8
  "repository": {
@@ -24,6 +24,6 @@
24
24
  "react": "*"
25
25
  },
26
26
  "dependencies": {
27
- "@tilia/core": "^1.3.0"
27
+ "@tilia/core": "1.4.0-canary.20250117T230449-canary.20250117T230648"
28
28
  }
29
29
  }
package/src/Tilia.res CHANGED
@@ -2,14 +2,18 @@
2
2
  @module("react") external useEffect: (unit => option<unit => unit>) => unit = "useEffect"
3
3
  open TiliaCore
4
4
 
5
+ type observer = observer
5
6
  let make = make
6
7
  let observe = observe
8
+ let track = track
9
+ let clear = clear
10
+
7
11
  let use = p => {
8
12
  let (_, setCount) = useState(0)
9
13
  let o = _connect(p, () => setCount(i => i + 1))
10
14
  useEffect(() => {
11
15
  _ready(o)
12
- Some(() => _clear(o))
16
+ Some(() => clear(o))
13
17
  })
14
18
  p
15
19
  }
package/src/Tilia.resi CHANGED
@@ -1,3 +1,7 @@
1
+ type observer = TiliaCore.observer
1
2
  let make: 'a => 'a
2
3
  let observe: ('a, 'a => unit) => unit
4
+ let track: ('a, 'a => unit) => observer
5
+ let clear: observer => unit
6
+
3
7
  let use: 'a => 'a
package/dist/index.cjs.js DELETED
@@ -1,2 +0,0 @@
1
- var u=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var m=(e,t)=>{for(var r in t)u(e,r,{get:t[r],enumerable:!0})},l=(e,t,r,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of f(t))!a.call(e,n)&&n!==r&&u(e,n,{get:()=>t[n],enumerable:!(c=s(t,n))||c.enumerable});return e};var p=e=>l(u({},"__esModule",{value:!0}),e);var x={};m(x,{observe:()=>o.observe,tilia:()=>o.tilia,useTilia:()=>_});module.exports=p(x);var i=require("react"),o=require("@tilia/core");function _(e){let[,t]=(0,i.useState)(0),r=(0,o._connect)(e,()=>t(c=>c+1));return(0,i.useEffect)(function(){return(0,o._ready)(r),()=>(0,o._clear)(r)}),e}
2
- //# sourceMappingURL=index.cjs.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/index.js"],
4
- "sourcesContent": ["import { useState, useEffect } from \"react\";\nimport { _connect, _ready, _clear, tilia, observe } from \"@tilia/core\";\n\nexport function useTilia(p) {\n const [, setCount] = useState(0);\n const o = _connect(p, () => setCount((i) => i + 1));\n useEffect(function () {\n _ready(o);\n return () => _clear(o);\n });\n return p;\n}\n\nexport { tilia, observe };\n"],
5
- "mappings": "4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sDAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAoC,iBACpCC,EAAyD,uBAElD,SAASH,EAASI,EAAG,CAC1B,GAAM,CAAC,CAAEC,CAAQ,KAAI,YAAS,CAAC,EACzBC,KAAI,YAASF,EAAG,IAAMC,EAAUE,GAAMA,EAAI,CAAC,CAAC,EAClD,sBAAU,UAAY,CACpB,mBAAOD,CAAC,EACD,OAAM,UAAOA,CAAC,CACvB,CAAC,EACMF,CACT",
6
- "names": ["index_exports", "__export", "useTilia", "__toCommonJS", "import_react", "import_core", "p", "setCount", "o", "i"]
7
- }
package/dist/index.esm.js DELETED
@@ -1,2 +0,0 @@
1
- import{useState as n,useEffect as c}from"react";import{_connect as i,_ready as u,_clear as s,tilia as m,observe as l}from"@tilia/core";function p(t){let[,o]=n(0),e=i(t,()=>o(r=>r+1));return c(function(){return u(e),()=>s(e)}),t}export{l as observe,m as tilia,p as useTilia};
2
- //# sourceMappingURL=index.esm.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/index.js"],
4
- "sourcesContent": ["import { useState, useEffect } from \"react\";\nimport { _connect, _ready, _clear, tilia, observe } from \"@tilia/core\";\n\nexport function useTilia(p) {\n const [, setCount] = useState(0);\n const o = _connect(p, () => setCount((i) => i + 1));\n useEffect(function () {\n _ready(o);\n return () => _clear(o);\n });\n return p;\n}\n\nexport { tilia, observe };\n"],
5
- "mappings": "AAAA,OAAS,YAAAA,EAAU,aAAAC,MAAiB,QACpC,OAAS,YAAAC,EAAU,UAAAC,EAAQ,UAAAC,EAAQ,SAAAC,EAAO,WAAAC,MAAe,cAElD,SAASC,EAASC,EAAG,CAC1B,GAAM,CAAC,CAAEC,CAAQ,EAAIT,EAAS,CAAC,EACzBU,EAAIR,EAASM,EAAG,IAAMC,EAAUE,GAAMA,EAAI,CAAC,CAAC,EAClD,OAAAV,EAAU,UAAY,CACpB,OAAAE,EAAOO,CAAC,EACD,IAAMN,EAAOM,CAAC,CACvB,CAAC,EACMF,CACT",
6
- "names": ["useState", "useEffect", "_connect", "_ready", "_clear", "tilia", "observe", "useTilia", "p", "setCount", "o", "i"]
7
- }