@lukekaalim/act-backstage 1.0.0 → 1.1.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/deps.ts +2 -0
- package/package.json +3 -7
- package/render.ts +9 -5
- package/space.ts +3 -3
package/deps.ts
ADDED
package/package.json
CHANGED
package/render.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CommitTree, createReconciler } from "@lukekaalim/act-recon";
|
|
2
2
|
import { RenderSpace } from "./space";
|
|
3
|
-
import
|
|
3
|
+
import { act } from "./deps";
|
|
4
4
|
|
|
5
5
|
export type ScheduleRequestFunc<ID> = (callback: () => void) => ID;
|
|
6
6
|
export type ScheduleCancelFunc<ID> = (id: ID) => void;
|
|
@@ -12,11 +12,13 @@ export type Scheduler<ID> = {
|
|
|
12
12
|
cancel: ScheduleCancelFunc<ID>,
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
export type RenderFunction<T> = (node: act.Node, root: T) => { stop: () => void }
|
|
16
|
+
|
|
15
17
|
export const createRenderFunction = <S, T>(
|
|
16
18
|
scheduler: Scheduler<S>,
|
|
17
19
|
createSpace: (tree: CommitTree, root: T) => RenderSpace
|
|
18
|
-
) => {
|
|
19
|
-
const render = (node: act.Node, root: T) => {
|
|
20
|
+
): RenderFunction<T> => {
|
|
21
|
+
const render: RenderFunction<T> = (node: act.Node, root: T) => {
|
|
20
22
|
const reconciler = createReconciler(deltas => {
|
|
21
23
|
space.create(deltas).configure();
|
|
22
24
|
}, () => {
|
|
@@ -42,8 +44,10 @@ export const createRenderFunction = <S, T>(
|
|
|
42
44
|
|
|
43
45
|
reconciler.threads.mount(node);
|
|
44
46
|
|
|
45
|
-
return
|
|
46
|
-
|
|
47
|
+
return {
|
|
48
|
+
stop() {
|
|
49
|
+
scheduler.cancel(id);
|
|
50
|
+
},
|
|
47
51
|
}
|
|
48
52
|
};
|
|
49
53
|
|
package/space.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { primitiveNodeTypes } from "@lukekaalim/act/node.ts";
|
|
2
|
+
import { recon, act } from "./deps.ts";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* A "RenderSpace" is a service that manages
|
|
@@ -71,7 +71,7 @@ export const createSimpleRenderSpace = <T, R extends string | Symbol>(
|
|
|
71
71
|
|
|
72
72
|
const commit = tree.commits.get(id) as recon.Commit;
|
|
73
73
|
// Early exit out of parent lookup if someone on the path is null;
|
|
74
|
-
if (commit.element.type ===
|
|
74
|
+
if (commit.element.type === primitiveNodeTypes.null)
|
|
75
75
|
return { id, node: null };
|
|
76
76
|
|
|
77
77
|
const node = nodeByCommit.get(id);
|