koota 0.2.2 → 0.3.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 +11 -3
- package/dist/{chunk-4QEK6BHY.js → chunk-G375UJC5.js} +295 -288
- package/dist/index.cjs +267 -258
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +1 -1
- package/dist/react.cjs +256 -259
- package/dist/react.d.cts +2 -4
- package/dist/react.d.ts +2 -4
- package/dist/react.js +7 -14
- package/dist/{world-DQXl4lI8.d.cts → world-BFj5O4_U.d.cts} +14 -3
- package/dist/{world-DQXl4lI8.d.ts → world-BFj5O4_U.d.ts} +14 -3
- package/package.json +3 -3
- package/react/index.cjs +256 -259
- package/react/index.d.cts +2 -4
- package/react/index.d.ts +2 -4
- package/react/index.js +7 -14
package/react/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Q as QueryParameter,
|
|
1
|
+
import { Q as QueryParameter, p as QueryResult, W as World, T as Trait, l as Entity, h as TraitInstance } from '../dist/world-BFj5O4_U.cjs';
|
|
2
2
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
3
|
|
|
4
4
|
declare function useQuery<T extends QueryParameter[]>(...parameters: T): QueryResult<T>;
|
|
@@ -18,6 +18,4 @@ declare function useQueryFirst<T extends QueryParameter[]>(...parameters: T): En
|
|
|
18
18
|
|
|
19
19
|
declare function useTraitEffect<T extends Trait>(target: Entity | World, trait: T, callback: (value: TraitInstance<T> | undefined) => void): void;
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
export { WorldProvider, getDefaultWorld, useActions, useQuery, useQueryFirst, useTrait, useTraitEffect, useWorld };
|
|
21
|
+
export { WorldProvider, useActions, useQuery, useQueryFirst, useTrait, useTraitEffect, useWorld };
|
package/react/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Q as QueryParameter,
|
|
1
|
+
import { Q as QueryParameter, p as QueryResult, W as World, T as Trait, l as Entity, h as TraitInstance } from '../dist/world-BFj5O4_U.js';
|
|
2
2
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
3
|
|
|
4
4
|
declare function useQuery<T extends QueryParameter[]>(...parameters: T): QueryResult<T>;
|
|
@@ -18,6 +18,4 @@ declare function useQueryFirst<T extends QueryParameter[]>(...parameters: T): En
|
|
|
18
18
|
|
|
19
19
|
declare function useTraitEffect<T extends Trait>(target: Entity | World, trait: T, callback: (value: TraitInstance<T> | undefined) => void): void;
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
export { WorldProvider, getDefaultWorld, useActions, useQuery, useQueryFirst, useTrait, useTraitEffect, useWorld };
|
|
21
|
+
export { WorldProvider, useActions, useQuery, useQueryFirst, useTrait, useTraitEffect, useWorld };
|
package/react/index.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
$internal,
|
|
3
|
-
cacheQuery
|
|
4
|
-
|
|
5
|
-
} from "../dist/chunk-4QEK6BHY.js";
|
|
3
|
+
cacheQuery
|
|
4
|
+
} from "../dist/chunk-G375UJC5.js";
|
|
6
5
|
|
|
7
6
|
// ../react/src/hooks/use-query.ts
|
|
8
7
|
import { useEffect, useMemo, useState } from "react";
|
|
@@ -14,14 +13,9 @@ import { useContext } from "react";
|
|
|
14
13
|
import { createContext } from "react";
|
|
15
14
|
var WorldContext = createContext(null);
|
|
16
15
|
|
|
17
|
-
// ../react/src/world/default-world.ts
|
|
18
|
-
var defaultWorld = createWorld();
|
|
19
|
-
var getDefaultWorld = () => defaultWorld;
|
|
20
|
-
|
|
21
16
|
// ../react/src/world/use-world.ts
|
|
22
17
|
function useWorld() {
|
|
23
|
-
|
|
24
|
-
return world;
|
|
18
|
+
return useContext(WorldContext);
|
|
25
19
|
}
|
|
26
20
|
|
|
27
21
|
// ../react/src/hooks/use-query.ts
|
|
@@ -32,17 +26,17 @@ function useQuery(...parameters) {
|
|
|
32
26
|
const query = world[$internal].queriesHashMap.get(hash2);
|
|
33
27
|
return [hash2, query.version];
|
|
34
28
|
}, [parameters]);
|
|
35
|
-
const [entities, setEntities] = useState(() => world.query(hash));
|
|
29
|
+
const [entities, setEntities] = useState(() => world.query(hash).sort());
|
|
36
30
|
useEffect(() => {
|
|
37
31
|
const unsubAdd = world.onAdd(parameters, () => {
|
|
38
|
-
setEntities(world.query(hash));
|
|
32
|
+
setEntities(world.query(hash).sort());
|
|
39
33
|
});
|
|
40
34
|
const unsubRemove = world.onRemove(parameters, () => {
|
|
41
|
-
setEntities(world.query(hash));
|
|
35
|
+
setEntities(world.query(hash).sort());
|
|
42
36
|
});
|
|
43
37
|
const query = world[$internal].queriesHashMap.get(hash);
|
|
44
38
|
if (query.version !== initialVersion) {
|
|
45
|
-
setEntities(world.query(hash));
|
|
39
|
+
setEntities(world.query(hash).sort());
|
|
46
40
|
}
|
|
47
41
|
return () => {
|
|
48
42
|
unsubAdd();
|
|
@@ -148,7 +142,6 @@ function useTraitEffect(target, trait, callback) {
|
|
|
148
142
|
}
|
|
149
143
|
export {
|
|
150
144
|
WorldProvider,
|
|
151
|
-
getDefaultWorld,
|
|
152
145
|
useActions,
|
|
153
146
|
useQuery,
|
|
154
147
|
useQueryFirst,
|