@latticexyz/react 2.2.18-9fa07c8489f1fbf167d0db01cd9aaa645a29c8e2 → 2.2.18-c2ad22c7feb566e1731ff16e8be291746bdffb3e
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.js +1 -102
- package/dist/index.js.map +1 -1
- package/package.json +6 -14
- package/dist/index.cjs +0 -138
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -30
package/dist/index.js
CHANGED
|
@@ -1,103 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
defineQuery,
|
|
4
|
-
getComponentValue,
|
|
5
|
-
Has,
|
|
6
|
-
isComponentUpdate
|
|
7
|
-
} from "@latticexyz/recs";
|
|
8
|
-
import { useEffect, useState } from "react";
|
|
9
|
-
function useComponentValue(component, entity, defaultValue) {
|
|
10
|
-
const [value, setValue] = useState(entity != null ? getComponentValue(component, entity) : void 0);
|
|
11
|
-
useEffect(() => {
|
|
12
|
-
setValue(entity != null ? getComponentValue(component, entity) : void 0);
|
|
13
|
-
if (entity == null) return;
|
|
14
|
-
const queryResult = defineQuery([Has(component)], { runOnInit: true });
|
|
15
|
-
const subscription = queryResult.update$.subscribe((update) => {
|
|
16
|
-
if (isComponentUpdate(update, component) && update.entity === entity) {
|
|
17
|
-
const [nextValue] = update.value;
|
|
18
|
-
setValue(nextValue);
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
return () => subscription.unsubscribe();
|
|
22
|
-
}, [component, entity]);
|
|
23
|
-
return value ?? defaultValue;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// src/useEntityQuery.ts
|
|
27
|
-
import { defineQuery as defineQuery2 } from "@latticexyz/recs";
|
|
28
|
-
import { useEffect as useEffect3, useMemo, useState as useState3 } from "react";
|
|
29
|
-
|
|
30
|
-
// src/utils/useDeepMemo.ts
|
|
31
|
-
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
32
|
-
import isEqual from "fast-deep-equal";
|
|
33
|
-
var useDeepMemo = (currentValue) => {
|
|
34
|
-
const [stableValue, setStableValue] = useState2(currentValue);
|
|
35
|
-
useEffect2(() => {
|
|
36
|
-
if (!isEqual(currentValue, stableValue)) {
|
|
37
|
-
setStableValue(currentValue);
|
|
38
|
-
}
|
|
39
|
-
}, [currentValue]);
|
|
40
|
-
return stableValue;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
// src/useEntityQuery.ts
|
|
44
|
-
import isEqual2 from "fast-deep-equal";
|
|
45
|
-
import { distinctUntilChanged, map } from "rxjs";
|
|
46
|
-
function useEntityQuery(fragments, options) {
|
|
47
|
-
const updateOnValueChange = options?.updateOnValueChange ?? true;
|
|
48
|
-
const stableFragments = useDeepMemo(fragments);
|
|
49
|
-
const query = useMemo(() => defineQuery2(stableFragments, { runOnInit: true }), [stableFragments]);
|
|
50
|
-
const [entities, setEntities] = useState3([...query.matching]);
|
|
51
|
-
useEffect3(() => {
|
|
52
|
-
setEntities([...query.matching]);
|
|
53
|
-
let observable = query.update$.pipe(map(() => [...query.matching]));
|
|
54
|
-
if (!updateOnValueChange) {
|
|
55
|
-
observable = observable.pipe(distinctUntilChanged((a, b) => isEqual2(a, b)));
|
|
56
|
-
}
|
|
57
|
-
const subscription = observable.subscribe((entities2) => setEntities(entities2));
|
|
58
|
-
return () => subscription.unsubscribe();
|
|
59
|
-
}, [query, updateOnValueChange]);
|
|
60
|
-
return entities;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// src/useObservableValue.ts
|
|
64
|
-
import { useEffect as useEffect4, useState as useState4 } from "react";
|
|
65
|
-
function useObservableValue(observable, defaultValue) {
|
|
66
|
-
const [value, setValue] = useState4(defaultValue);
|
|
67
|
-
useEffect4(() => {
|
|
68
|
-
const subscription = observable.subscribe(setValue);
|
|
69
|
-
return () => subscription.unsubscribe();
|
|
70
|
-
}, [observable]);
|
|
71
|
-
return value;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// src/usePromise.ts
|
|
75
|
-
import { useEffect as useEffect5, useRef, useState as useState5 } from "react";
|
|
76
|
-
function usePromise(promise) {
|
|
77
|
-
const promiseRef = useRef(promise);
|
|
78
|
-
const [result, setResult] = useState5(
|
|
79
|
-
promise == null ? { status: "idle" } : { status: "pending" }
|
|
80
|
-
);
|
|
81
|
-
useEffect5(() => {
|
|
82
|
-
if (promise !== promiseRef.current) {
|
|
83
|
-
promiseRef.current = promise;
|
|
84
|
-
setResult(promise == null ? { status: "idle" } : { status: "pending" });
|
|
85
|
-
}
|
|
86
|
-
}, [promise]);
|
|
87
|
-
useEffect5(() => {
|
|
88
|
-
if (promise == null) return;
|
|
89
|
-
Promise.allSettled([promise]).then(([settled]) => {
|
|
90
|
-
if (promise === promiseRef.current) {
|
|
91
|
-
setResult(settled);
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
}, [promise]);
|
|
95
|
-
return result;
|
|
96
|
-
}
|
|
97
|
-
export {
|
|
98
|
-
useComponentValue,
|
|
99
|
-
useEntityQuery,
|
|
100
|
-
useObservableValue,
|
|
101
|
-
usePromise
|
|
102
|
-
};
|
|
1
|
+
import{defineQuery as d,getComponentValue as f,Has as b,isComponentUpdate as S}from"@latticexyz/recs";import{useEffect as V,useState as x}from"react";function A(e,t,u){let[s,n]=x(t!=null?f(e,t):void 0);return V(()=>{if(n(t!=null?f(e,t):void 0),t==null)return;let r=d([b(e)],{runOnInit:!0}).update$.subscribe(o=>{if(S(o,e)&&o.entity===t){let[i]=o.value;n(i)}});return()=>r.unsubscribe()},[e,t]),s??u}import{defineQuery as E}from"@latticexyz/recs";import{useEffect as h,useMemo as v,useState as O}from"react";import{useEffect as C,useState as T}from"react";import g from"fast-deep-equal";var m=e=>{let[t,u]=T(e);return C(()=>{g(e,t)||u(e)},[e]),t};import y from"fast-deep-equal";import{distinctUntilChanged as R,map as P}from"rxjs";function X(e,t){let u=t?.updateOnValueChange??!0,s=m(e),n=v(()=>E(s,{runOnInit:!0}),[s]),[l,r]=O([...n.matching]);return h(()=>{r([...n.matching]);let o=n.update$.pipe(P(()=>[...n.matching]));u||(o=o.pipe(R((a,c)=>y(a,c))));let i=o.subscribe(a=>r(a));return()=>i.unsubscribe()},[n,u]),l}import{useEffect as q,useState as Q}from"react";function _(e,t){let[u,s]=Q(t);return q(()=>{let n=e.subscribe(s);return()=>n.unsubscribe()},[e]),u}import{useEffect as p,useRef as U,useState as F}from"react";function ne(e){let t=U(e),[u,s]=F(e==null?{status:"idle"}:{status:"pending"});return p(()=>{e!==t.current&&(t.current=e,s(e==null?{status:"idle"}:{status:"pending"}))},[e]),p(()=>{e!=null&&Promise.allSettled([e]).then(([n])=>{e===t.current&&s(n)})},[e]),u}export{A as useComponentValue,X as useEntityQuery,_ as useObservableValue,ne as usePromise};
|
|
103
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/useComponentValue.ts","../src/useEntityQuery.ts","../src/utils/useDeepMemo.ts","../src/useObservableValue.ts","../src/usePromise.ts"],"sourcesContent":["import {\n Component,\n ComponentValue,\n defineQuery,\n Entity,\n getComponentValue,\n Has,\n isComponentUpdate,\n Schema,\n} from \"@latticexyz/recs\";\nimport { useEffect, useState } from \"react\";\n\nexport function useComponentValue<S extends Schema>(\n component: Component<S>,\n entity: Entity | undefined,\n defaultValue: ComponentValue<S>,\n): ComponentValue<S>;\n\nexport function useComponentValue<S extends Schema>(\n component: Component<S>,\n entity: Entity | undefined,\n): ComponentValue<S> | undefined;\n\nexport function useComponentValue<S extends Schema>(\n component: Component<S>,\n entity: Entity | undefined,\n defaultValue?: ComponentValue<S>,\n) {\n const [value, setValue] = useState(entity != null ? getComponentValue(component, entity) : undefined);\n\n useEffect(() => {\n // component or entity changed, update state to latest value\n setValue(entity != null ? getComponentValue(component, entity) : undefined);\n if (entity == null) return;\n\n const queryResult = defineQuery([Has(component)], { runOnInit: true });\n const subscription = queryResult.update$.subscribe((update) => {\n if (isComponentUpdate(update, component) && update.entity === entity) {\n const [nextValue] = update.value;\n setValue(nextValue);\n }\n });\n return () => subscription.unsubscribe();\n }, [component, entity]);\n\n return value ?? defaultValue;\n}\n","import { defineQuery, QueryFragment } from \"@latticexyz/recs\";\nimport { useEffect, useMemo, useState } from \"react\";\nimport { useDeepMemo } from \"./utils/useDeepMemo\";\nimport isEqual from \"fast-deep-equal\";\nimport { distinctUntilChanged, map } from \"rxjs\";\n\n// This does a little more rendering than is necessary when arguments change,\n// but at least it's giving correct results now. Will optimize later!\n\n/**\n * Returns all matching entities for a given entity query,\n * and triggers a re-render as new query results come in.\n *\n * @param fragments Query fragments to match against, executed from left to right.\n * @param options.updateOnValueChange False - re-renders only on entity array changes. True (default) - also on component value changes.\n * @returns Set of entities matching the query fragments.\n */\nexport function useEntityQuery(fragments: QueryFragment[], options?: { updateOnValueChange?: boolean }) {\n const updateOnValueChange = options?.updateOnValueChange ?? true;\n\n const stableFragments = useDeepMemo(fragments);\n const query = useMemo(() => defineQuery(stableFragments, { runOnInit: true }), [stableFragments]);\n const [entities, setEntities] = useState([...query.matching]);\n\n useEffect(() => {\n setEntities([...query.matching]);\n let observable = query.update$.pipe(map(() => [...query.matching]));\n if (!updateOnValueChange) {\n // re-render only on entity array changes\n observable = observable.pipe(distinctUntilChanged((a, b) => isEqual(a, b)));\n }\n const subscription = observable.subscribe((entities) => setEntities(entities));\n return () => subscription.unsubscribe();\n }, [query, updateOnValueChange]);\n\n return entities;\n}\n","import { useEffect, useState } from \"react\";\nimport isEqual from \"fast-deep-equal\";\n\nexport const useDeepMemo = <T>(currentValue: T): T => {\n const [stableValue, setStableValue] = useState(currentValue);\n\n useEffect(() => {\n if (!isEqual(currentValue, stableValue)) {\n setStableValue(currentValue);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [currentValue]);\n\n return stableValue;\n};\n","import { useEffect, useState } from \"react\";\nimport { Observable } from \"rxjs\";\n\nexport function useObservableValue<T>(observable: Observable<T>, defaultValue: T): T;\n\nexport function useObservableValue<T>(observable: Observable<T>): T | undefined;\n\nexport function useObservableValue<T>(observable: Observable<T>, defaultValue?: T) {\n const [value, setValue] = useState(defaultValue);\n\n useEffect(() => {\n const subscription = observable.subscribe(setValue);\n return () => subscription.unsubscribe();\n }, [observable]);\n\n return value;\n}\n","import { useEffect, useRef, useState } from \"react\";\n\n// TODO: narrow type so `null`/`undefined` always return `{status: \"idle\"}`?\n\nexport type UsePromiseResult<T> = PromiseSettledResult<Awaited<T>> | { status: \"pending\" } | { status: \"idle\" };\n\nexport function usePromise<T>(promise: PromiseLike<T> | null | undefined) {\n const promiseRef = useRef(promise);\n const [result, setResult] = useState<UsePromiseResult<T>>(\n promise == null ? { status: \"idle\" } : { status: \"pending\" },\n );\n\n useEffect(() => {\n if (promise !== promiseRef.current) {\n promiseRef.current = promise;\n setResult(promise == null ? { status: \"idle\" } : { status: \"pending\" });\n }\n }, [promise]);\n\n useEffect(() => {\n if (promise == null) return;\n // TODO: do we need to check if result is already populated?\n Promise.allSettled([promise]).then(([settled]) => {\n if (promise === promiseRef.current) {\n setResult(settled);\n }\n });\n }, [promise]);\n\n return result;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/useComponentValue.ts","../src/useEntityQuery.ts","../src/utils/useDeepMemo.ts","../src/useObservableValue.ts","../src/usePromise.ts"],"sourcesContent":["import {\n Component,\n ComponentValue,\n defineQuery,\n Entity,\n getComponentValue,\n Has,\n isComponentUpdate,\n Schema,\n} from \"@latticexyz/recs\";\nimport { useEffect, useState } from \"react\";\n\nexport function useComponentValue<S extends Schema>(\n component: Component<S>,\n entity: Entity | undefined,\n defaultValue: ComponentValue<S>,\n): ComponentValue<S>;\n\nexport function useComponentValue<S extends Schema>(\n component: Component<S>,\n entity: Entity | undefined,\n): ComponentValue<S> | undefined;\n\nexport function useComponentValue<S extends Schema>(\n component: Component<S>,\n entity: Entity | undefined,\n defaultValue?: ComponentValue<S>,\n) {\n const [value, setValue] = useState(entity != null ? getComponentValue(component, entity) : undefined);\n\n useEffect(() => {\n // component or entity changed, update state to latest value\n setValue(entity != null ? getComponentValue(component, entity) : undefined);\n if (entity == null) return;\n\n const queryResult = defineQuery([Has(component)], { runOnInit: true });\n const subscription = queryResult.update$.subscribe((update) => {\n if (isComponentUpdate(update, component) && update.entity === entity) {\n const [nextValue] = update.value;\n setValue(nextValue);\n }\n });\n return () => subscription.unsubscribe();\n }, [component, entity]);\n\n return value ?? defaultValue;\n}\n","import { defineQuery, QueryFragment } from \"@latticexyz/recs\";\nimport { useEffect, useMemo, useState } from \"react\";\nimport { useDeepMemo } from \"./utils/useDeepMemo\";\nimport isEqual from \"fast-deep-equal\";\nimport { distinctUntilChanged, map } from \"rxjs\";\n\n// This does a little more rendering than is necessary when arguments change,\n// but at least it's giving correct results now. Will optimize later!\n\n/**\n * Returns all matching entities for a given entity query,\n * and triggers a re-render as new query results come in.\n *\n * @param fragments Query fragments to match against, executed from left to right.\n * @param options.updateOnValueChange False - re-renders only on entity array changes. True (default) - also on component value changes.\n * @returns Set of entities matching the query fragments.\n */\nexport function useEntityQuery(fragments: QueryFragment[], options?: { updateOnValueChange?: boolean }) {\n const updateOnValueChange = options?.updateOnValueChange ?? true;\n\n const stableFragments = useDeepMemo(fragments);\n const query = useMemo(() => defineQuery(stableFragments, { runOnInit: true }), [stableFragments]);\n const [entities, setEntities] = useState([...query.matching]);\n\n useEffect(() => {\n setEntities([...query.matching]);\n let observable = query.update$.pipe(map(() => [...query.matching]));\n if (!updateOnValueChange) {\n // re-render only on entity array changes\n observable = observable.pipe(distinctUntilChanged((a, b) => isEqual(a, b)));\n }\n const subscription = observable.subscribe((entities) => setEntities(entities));\n return () => subscription.unsubscribe();\n }, [query, updateOnValueChange]);\n\n return entities;\n}\n","import { useEffect, useState } from \"react\";\nimport isEqual from \"fast-deep-equal\";\n\nexport const useDeepMemo = <T>(currentValue: T): T => {\n const [stableValue, setStableValue] = useState(currentValue);\n\n useEffect(() => {\n if (!isEqual(currentValue, stableValue)) {\n setStableValue(currentValue);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [currentValue]);\n\n return stableValue;\n};\n","import { useEffect, useState } from \"react\";\nimport { Observable } from \"rxjs\";\n\nexport function useObservableValue<T>(observable: Observable<T>, defaultValue: T): T;\n\nexport function useObservableValue<T>(observable: Observable<T>): T | undefined;\n\nexport function useObservableValue<T>(observable: Observable<T>, defaultValue?: T) {\n const [value, setValue] = useState(defaultValue);\n\n useEffect(() => {\n const subscription = observable.subscribe(setValue);\n return () => subscription.unsubscribe();\n }, [observable]);\n\n return value;\n}\n","import { useEffect, useRef, useState } from \"react\";\n\n// TODO: narrow type so `null`/`undefined` always return `{status: \"idle\"}`?\n\nexport type UsePromiseResult<T> = PromiseSettledResult<Awaited<T>> | { status: \"pending\" } | { status: \"idle\" };\n\nexport function usePromise<T>(promise: PromiseLike<T> | null | undefined) {\n const promiseRef = useRef(promise);\n const [result, setResult] = useState<UsePromiseResult<T>>(\n promise == null ? { status: \"idle\" } : { status: \"pending\" },\n );\n\n useEffect(() => {\n if (promise !== promiseRef.current) {\n promiseRef.current = promise;\n setResult(promise == null ? { status: \"idle\" } : { status: \"pending\" });\n }\n }, [promise]);\n\n useEffect(() => {\n if (promise == null) return;\n // TODO: do we need to check if result is already populated?\n Promise.allSettled([promise]).then(([settled]) => {\n if (promise === promiseRef.current) {\n setResult(settled);\n }\n });\n }, [promise]);\n\n return result;\n}\n"],"mappings":"AAAA,OAGE,eAAAA,EAEA,qBAAAC,EACA,OAAAC,EACA,qBAAAC,MAEK,mBACP,OAAS,aAAAC,EAAW,YAAAC,MAAgB,QAa7B,SAASC,EACdC,EACAC,EACAC,EACA,CACA,GAAM,CAACC,EAAOC,CAAQ,EAAIN,EAASG,GAAU,KAAOP,EAAkBM,EAAWC,CAAM,EAAI,MAAS,EAEpG,OAAAJ,EAAU,IAAM,CAGd,GADAO,EAASH,GAAU,KAAOP,EAAkBM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AaA,EAAW,KAAKf,EAAqB,CAAC,EAAGgB,IAAMjB,EAAQ,EAAGiB,CAAC,CAAC,CAAC,GAE5E,IAAMC,EAAeF,EAAW,UAAWJ,GAAaC,EAAYD,CAAQ,CAAC,EAC7E,MAAO,IAAMM,EAAa,YAAY,CACxC,EAAG,CAACT,EAAOH,CAAmB,CAAC,EAExBM,CACT,CEpCA,OAAS,aAAAO,EAAW,YAAAC,MAAgB,QAO7B,SAASC,EAAsBC,EAA2BC,EAAkB,CACjF,GAAM,CAACC,EAAOC,CAAQ,EAAIL,EAASG,CAAY,EAE/C,OAAAJ,EAAU,IAAM,CACd,IAAMO,EAAeJ,EAAW,UAAUG,CAAQ,EAClD,MAAO,IAAMC,EAAa,YAAY,CACxC,EAAG,CAACJ,CAAU,CAAC,EAERE,CACT,CChBA,OAAS,aAAAG,EAAW,UAAAC,EAAQ,YAAAC,MAAgB,QAMrC,SAASC,GAAcC,EAA4C,CACxE,IAAMC,EAAaJ,EAAOG,CAAO,EAC3B,CAACE,EAAQC,CAAS,EAAIL,EAC1BE,GAAW,KAAO,CAAE,OAAQ,MAAO,EAAI,CAAE,OAAQ,SAAU,CAC7D,EAEA,OAAAJ,EAAU,IAAM,CACVI,IAAYC,EAAW,UACzBA,EAAW,QAAUD,EACrBG,EAAUH,GAAW,KAAO,CAAE,OAAQ,MAAO,EAAI,CAAE,OAAQ,SAAU,CAAC,EAE1E,EAAG,CAACA,CAAO,CAAC,EAEZJ,EAAU,IAAM,CACVI,GAAW,MAEf,QAAQ,WAAW,CAACA,CAAO,CAAC,EAAE,KAAK,CAAC,CAACI,CAAO,IAAM,CAC5CJ,IAAYC,EAAW,SACzBE,EAAUC,CAAO,CAErB,CAAC,CACH,EAAG,CAACJ,CAAO,CAAC,EAELE,CACT","names":["defineQuery","getComponentValue","Has","isComponentUpdate","useEffect","useState","useComponentValue","component","entity","defaultValue","value","setValue","subscription","update","nextValue","defineQuery","useEffect","useMemo","useState","useEffect","useState","isEqual","useDeepMemo","currentValue","stableValue","setStableValue","isEqual","distinctUntilChanged","map","useEntityQuery","fragments","options","updateOnValueChange","stableFragments","useDeepMemo","query","useMemo","defineQuery","entities","setEntities","useState","useEffect","observable","b","subscription","useEffect","useState","useObservableValue","observable","defaultValue","value","setValue","subscription","useEffect","useRef","useState","usePromise","promise","promiseRef","result","setResult","settled"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@latticexyz/react",
|
|
3
|
-
"version": "2.2.18-
|
|
3
|
+
"version": "2.2.18-c2ad22c7feb566e1731ff16e8be291746bdffb3e",
|
|
4
4
|
"description": "React tools for MUD client.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -10,16 +10,7 @@
|
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"type": "module",
|
|
12
12
|
"exports": {
|
|
13
|
-
".":
|
|
14
|
-
"import": {
|
|
15
|
-
"import": "./dist/index.js",
|
|
16
|
-
"types": "./dist/index.d.ts"
|
|
17
|
-
},
|
|
18
|
-
"require": {
|
|
19
|
-
"require": "./dist/index.cjs",
|
|
20
|
-
"types": "./dist/index.d.cts"
|
|
21
|
-
}
|
|
22
|
-
}
|
|
13
|
+
".": "./dist/index.js"
|
|
23
14
|
},
|
|
24
15
|
"typesVersions": {
|
|
25
16
|
"*": {
|
|
@@ -36,8 +27,8 @@
|
|
|
36
27
|
"mobx": "^6.7.0",
|
|
37
28
|
"react": "^18.2.0",
|
|
38
29
|
"rxjs": "7.5.5",
|
|
39
|
-
"@latticexyz/recs": "2.2.18-
|
|
40
|
-
"@latticexyz/store": "2.2.18-
|
|
30
|
+
"@latticexyz/recs": "2.2.18-c2ad22c7feb566e1731ff16e8be291746bdffb3e",
|
|
31
|
+
"@latticexyz/store": "2.2.18-c2ad22c7feb566e1731ff16e8be291746bdffb3e"
|
|
41
32
|
},
|
|
42
33
|
"devDependencies": {
|
|
43
34
|
"@testing-library/react-hooks": "^8.0.1",
|
|
@@ -47,7 +38,8 @@
|
|
|
47
38
|
"eslint-plugin-react-hooks": "4.6.0",
|
|
48
39
|
"jsdom": "^22.1.0",
|
|
49
40
|
"react-test-renderer": "^18.2.0",
|
|
50
|
-
"vite": "^4.3.6"
|
|
41
|
+
"vite": "^4.3.6",
|
|
42
|
+
"vitest": "0.34.6"
|
|
51
43
|
},
|
|
52
44
|
"scripts": {
|
|
53
45
|
"build": "pnpm run build:js",
|
package/dist/index.cjs
DELETED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/index.ts
|
|
31
|
-
var src_exports = {};
|
|
32
|
-
__export(src_exports, {
|
|
33
|
-
useComponentValue: () => useComponentValue,
|
|
34
|
-
useEntityQuery: () => useEntityQuery,
|
|
35
|
-
useObservableValue: () => useObservableValue,
|
|
36
|
-
usePromise: () => usePromise
|
|
37
|
-
});
|
|
38
|
-
module.exports = __toCommonJS(src_exports);
|
|
39
|
-
|
|
40
|
-
// src/useComponentValue.ts
|
|
41
|
-
var import_recs = require("@latticexyz/recs");
|
|
42
|
-
var import_react = require("react");
|
|
43
|
-
function useComponentValue(component, entity, defaultValue) {
|
|
44
|
-
const [value, setValue] = (0, import_react.useState)(entity != null ? (0, import_recs.getComponentValue)(component, entity) : void 0);
|
|
45
|
-
(0, import_react.useEffect)(() => {
|
|
46
|
-
setValue(entity != null ? (0, import_recs.getComponentValue)(component, entity) : void 0);
|
|
47
|
-
if (entity == null) return;
|
|
48
|
-
const queryResult = (0, import_recs.defineQuery)([(0, import_recs.Has)(component)], { runOnInit: true });
|
|
49
|
-
const subscription = queryResult.update$.subscribe((update) => {
|
|
50
|
-
if ((0, import_recs.isComponentUpdate)(update, component) && update.entity === entity) {
|
|
51
|
-
const [nextValue] = update.value;
|
|
52
|
-
setValue(nextValue);
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
return () => subscription.unsubscribe();
|
|
56
|
-
}, [component, entity]);
|
|
57
|
-
return value ?? defaultValue;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// src/useEntityQuery.ts
|
|
61
|
-
var import_recs2 = require("@latticexyz/recs");
|
|
62
|
-
var import_react3 = require("react");
|
|
63
|
-
|
|
64
|
-
// src/utils/useDeepMemo.ts
|
|
65
|
-
var import_react2 = require("react");
|
|
66
|
-
var import_fast_deep_equal = __toESM(require("fast-deep-equal"), 1);
|
|
67
|
-
var useDeepMemo = (currentValue) => {
|
|
68
|
-
const [stableValue, setStableValue] = (0, import_react2.useState)(currentValue);
|
|
69
|
-
(0, import_react2.useEffect)(() => {
|
|
70
|
-
if (!(0, import_fast_deep_equal.default)(currentValue, stableValue)) {
|
|
71
|
-
setStableValue(currentValue);
|
|
72
|
-
}
|
|
73
|
-
}, [currentValue]);
|
|
74
|
-
return stableValue;
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
// src/useEntityQuery.ts
|
|
78
|
-
var import_fast_deep_equal2 = __toESM(require("fast-deep-equal"), 1);
|
|
79
|
-
var import_rxjs = require("rxjs");
|
|
80
|
-
function useEntityQuery(fragments, options) {
|
|
81
|
-
const updateOnValueChange = options?.updateOnValueChange ?? true;
|
|
82
|
-
const stableFragments = useDeepMemo(fragments);
|
|
83
|
-
const query = (0, import_react3.useMemo)(() => (0, import_recs2.defineQuery)(stableFragments, { runOnInit: true }), [stableFragments]);
|
|
84
|
-
const [entities, setEntities] = (0, import_react3.useState)([...query.matching]);
|
|
85
|
-
(0, import_react3.useEffect)(() => {
|
|
86
|
-
setEntities([...query.matching]);
|
|
87
|
-
let observable = query.update$.pipe((0, import_rxjs.map)(() => [...query.matching]));
|
|
88
|
-
if (!updateOnValueChange) {
|
|
89
|
-
observable = observable.pipe((0, import_rxjs.distinctUntilChanged)((a, b) => (0, import_fast_deep_equal2.default)(a, b)));
|
|
90
|
-
}
|
|
91
|
-
const subscription = observable.subscribe((entities2) => setEntities(entities2));
|
|
92
|
-
return () => subscription.unsubscribe();
|
|
93
|
-
}, [query, updateOnValueChange]);
|
|
94
|
-
return entities;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// src/useObservableValue.ts
|
|
98
|
-
var import_react4 = require("react");
|
|
99
|
-
function useObservableValue(observable, defaultValue) {
|
|
100
|
-
const [value, setValue] = (0, import_react4.useState)(defaultValue);
|
|
101
|
-
(0, import_react4.useEffect)(() => {
|
|
102
|
-
const subscription = observable.subscribe(setValue);
|
|
103
|
-
return () => subscription.unsubscribe();
|
|
104
|
-
}, [observable]);
|
|
105
|
-
return value;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// src/usePromise.ts
|
|
109
|
-
var import_react5 = require("react");
|
|
110
|
-
function usePromise(promise) {
|
|
111
|
-
const promiseRef = (0, import_react5.useRef)(promise);
|
|
112
|
-
const [result, setResult] = (0, import_react5.useState)(
|
|
113
|
-
promise == null ? { status: "idle" } : { status: "pending" }
|
|
114
|
-
);
|
|
115
|
-
(0, import_react5.useEffect)(() => {
|
|
116
|
-
if (promise !== promiseRef.current) {
|
|
117
|
-
promiseRef.current = promise;
|
|
118
|
-
setResult(promise == null ? { status: "idle" } : { status: "pending" });
|
|
119
|
-
}
|
|
120
|
-
}, [promise]);
|
|
121
|
-
(0, import_react5.useEffect)(() => {
|
|
122
|
-
if (promise == null) return;
|
|
123
|
-
Promise.allSettled([promise]).then(([settled]) => {
|
|
124
|
-
if (promise === promiseRef.current) {
|
|
125
|
-
setResult(settled);
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
}, [promise]);
|
|
129
|
-
return result;
|
|
130
|
-
}
|
|
131
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
132
|
-
0 && (module.exports = {
|
|
133
|
-
useComponentValue,
|
|
134
|
-
useEntityQuery,
|
|
135
|
-
useObservableValue,
|
|
136
|
-
usePromise
|
|
137
|
-
});
|
|
138
|
-
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/useComponentValue.ts","../src/useEntityQuery.ts","../src/utils/useDeepMemo.ts","../src/useObservableValue.ts","../src/usePromise.ts"],"sourcesContent":["export * from \"./useComponentValue\";\nexport * from \"./useEntityQuery\";\nexport * from \"./useObservableValue\";\nexport * from \"./usePromise\";\n","import {\n Component,\n ComponentValue,\n defineQuery,\n Entity,\n getComponentValue,\n Has,\n isComponentUpdate,\n Schema,\n} from \"@latticexyz/recs\";\nimport { useEffect, useState } from \"react\";\n\nexport function useComponentValue<S extends Schema>(\n component: Component<S>,\n entity: Entity | undefined,\n defaultValue: ComponentValue<S>,\n): ComponentValue<S>;\n\nexport function useComponentValue<S extends Schema>(\n component: Component<S>,\n entity: Entity | undefined,\n): ComponentValue<S> | undefined;\n\nexport function useComponentValue<S extends Schema>(\n component: Component<S>,\n entity: Entity | undefined,\n defaultValue?: ComponentValue<S>,\n) {\n const [value, setValue] = useState(entity != null ? getComponentValue(component, entity) : undefined);\n\n useEffect(() => {\n // component or entity changed, update state to latest value\n setValue(entity != null ? getComponentValue(component, entity) : undefined);\n if (entity == null) return;\n\n const queryResult = defineQuery([Has(component)], { runOnInit: true });\n const subscription = queryResult.update$.subscribe((update) => {\n if (isComponentUpdate(update, component) && update.entity === entity) {\n const [nextValue] = update.value;\n setValue(nextValue);\n }\n });\n return () => subscription.unsubscribe();\n }, [component, entity]);\n\n return value ?? defaultValue;\n}\n","import { defineQuery, QueryFragment } from \"@latticexyz/recs\";\nimport { useEffect, useMemo, useState } from \"react\";\nimport { useDeepMemo } from \"./utils/useDeepMemo\";\nimport isEqual from \"fast-deep-equal\";\nimport { distinctUntilChanged, map } from \"rxjs\";\n\n// This does a little more rendering than is necessary when arguments change,\n// but at least it's giving correct results now. Will optimize later!\n\n/**\n * Returns all matching entities for a given entity query,\n * and triggers a re-render as new query results come in.\n *\n * @param fragments Query fragments to match against, executed from left to right.\n * @param options.updateOnValueChange False - re-renders only on entity array changes. True (default) - also on component value changes.\n * @returns Set of entities matching the query fragments.\n */\nexport function useEntityQuery(fragments: QueryFragment[], options?: { updateOnValueChange?: boolean }) {\n const updateOnValueChange = options?.updateOnValueChange ?? true;\n\n const stableFragments = useDeepMemo(fragments);\n const query = useMemo(() => defineQuery(stableFragments, { runOnInit: true }), [stableFragments]);\n const [entities, setEntities] = useState([...query.matching]);\n\n useEffect(() => {\n setEntities([...query.matching]);\n let observable = query.update$.pipe(map(() => [...query.matching]));\n if (!updateOnValueChange) {\n // re-render only on entity array changes\n observable = observable.pipe(distinctUntilChanged((a, b) => isEqual(a, b)));\n }\n const subscription = observable.subscribe((entities) => setEntities(entities));\n return () => subscription.unsubscribe();\n }, [query, updateOnValueChange]);\n\n return entities;\n}\n","import { useEffect, useState } from \"react\";\nimport isEqual from \"fast-deep-equal\";\n\nexport const useDeepMemo = <T>(currentValue: T): T => {\n const [stableValue, setStableValue] = useState(currentValue);\n\n useEffect(() => {\n if (!isEqual(currentValue, stableValue)) {\n setStableValue(currentValue);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [currentValue]);\n\n return stableValue;\n};\n","import { useEffect, useState } from \"react\";\nimport { Observable } from \"rxjs\";\n\nexport function useObservableValue<T>(observable: Observable<T>, defaultValue: T): T;\n\nexport function useObservableValue<T>(observable: Observable<T>): T | undefined;\n\nexport function useObservableValue<T>(observable: Observable<T>, defaultValue?: T) {\n const [value, setValue] = useState(defaultValue);\n\n useEffect(() => {\n const subscription = observable.subscribe(setValue);\n return () => subscription.unsubscribe();\n }, [observable]);\n\n return value;\n}\n","import { useEffect, useRef, useState } from \"react\";\n\n// TODO: narrow type so `null`/`undefined` always return `{status: \"idle\"}`?\n\nexport type UsePromiseResult<T> = PromiseSettledResult<Awaited<T>> | { status: \"pending\" } | { status: \"idle\" };\n\nexport function usePromise<T>(promise: PromiseLike<T> | null | undefined) {\n const promiseRef = useRef(promise);\n const [result, setResult] = useState<UsePromiseResult<T>>(\n promise == null ? { status: \"idle\" } : { status: \"pending\" },\n );\n\n useEffect(() => {\n if (promise !== promiseRef.current) {\n promiseRef.current = promise;\n setResult(promise == null ? { status: \"idle\" } : { status: \"pending\" });\n }\n }, [promise]);\n\n useEffect(() => {\n if (promise == null) return;\n // TODO: do we need to check if result is already populated?\n Promise.allSettled([promise]).then(([settled]) => {\n if (promise === promiseRef.current) {\n setResult(settled);\n }\n });\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;AAEZ,+BAAU,MAAM;AACd,QAAI,WAAW,KAAM;AAErB,YAAQ,WAAW,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,CAAC,OAAO,MAAM;AAChD,UAAI,YAAY,WAAW,SAAS;AAClC,kBAAU,OAAO;AAAA,MACnB;AAAA,IACF,CAAC;AAAA,EACH,GAAG,CAAC,OAAO,CAAC;AAEZ,SAAO;AACT;","names":["import_recs","import_react","import_react","isEqual","import_fast_deep_equal","isEqual","entities","import_react","import_react"]}
|
package/dist/index.d.cts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import * as _latticexyz_recs from '@latticexyz/recs';
|
|
2
|
-
import { Schema, Component, Entity, ComponentValue, QueryFragment } from '@latticexyz/recs';
|
|
3
|
-
import { Observable } from 'rxjs';
|
|
4
|
-
|
|
5
|
-
declare function useComponentValue<S extends Schema>(component: Component<S>, entity: Entity | undefined, defaultValue: ComponentValue<S>): ComponentValue<S>;
|
|
6
|
-
declare function useComponentValue<S extends Schema>(component: Component<S>, entity: Entity | undefined): ComponentValue<S> | undefined;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Returns all matching entities for a given entity query,
|
|
10
|
-
* and triggers a re-render as new query results come in.
|
|
11
|
-
*
|
|
12
|
-
* @param fragments Query fragments to match against, executed from left to right.
|
|
13
|
-
* @param options.updateOnValueChange False - re-renders only on entity array changes. True (default) - also on component value changes.
|
|
14
|
-
* @returns Set of entities matching the query fragments.
|
|
15
|
-
*/
|
|
16
|
-
declare function useEntityQuery(fragments: QueryFragment[], options?: {
|
|
17
|
-
updateOnValueChange?: boolean;
|
|
18
|
-
}): _latticexyz_recs.Entity[];
|
|
19
|
-
|
|
20
|
-
declare function useObservableValue<T>(observable: Observable<T>, defaultValue: T): T;
|
|
21
|
-
declare function useObservableValue<T>(observable: Observable<T>): T | undefined;
|
|
22
|
-
|
|
23
|
-
type UsePromiseResult<T> = PromiseSettledResult<Awaited<T>> | {
|
|
24
|
-
status: "pending";
|
|
25
|
-
} | {
|
|
26
|
-
status: "idle";
|
|
27
|
-
};
|
|
28
|
-
declare function usePromise<T>(promise: PromiseLike<T> | null | undefined): UsePromiseResult<T>;
|
|
29
|
-
|
|
30
|
-
export { type UsePromiseResult, useComponentValue, useEntityQuery, useObservableValue, usePromise };
|