@lukekaalim/act-backstage 1.3.0 → 3.0.0-alpha.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/CHANGELOG.md +22 -0
- package/package.json +2 -2
- package/render.ts +17 -35
- package/space.ts +13 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @lukekaalim/act-backstage
|
|
2
2
|
|
|
3
|
+
## 3.0.0-alpha.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- b3f6c49: Added debug capabilities and protocol
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [b3f6c49]
|
|
12
|
+
- @lukekaalim/act-recon@3.0.0-alpha.0
|
|
13
|
+
|
|
14
|
+
## 2.0.0
|
|
15
|
+
|
|
16
|
+
### Major Changes
|
|
17
|
+
|
|
18
|
+
- Scheduling refactor
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Updated dependencies
|
|
23
|
+
- @lukekaalim/act-recon@2.0.0
|
|
24
|
+
|
|
3
25
|
## 1.3.0
|
|
4
26
|
|
|
5
27
|
### Minor Changes
|
package/package.json
CHANGED
package/render.ts
CHANGED
|
@@ -1,52 +1,34 @@
|
|
|
1
|
-
import { CommitTree, createReconciler } from "@lukekaalim/act-recon";
|
|
1
|
+
import { CommitTree, createReconciler, Scheduler, WorkThread } from "@lukekaalim/act-recon";
|
|
2
2
|
import { RenderSpace } from "./space";
|
|
3
3
|
import * as act from '@lukekaalim/act';
|
|
4
4
|
|
|
5
|
-
export type ScheduleRequestFunc<ID> = (callback: () => void) => ID;
|
|
6
|
-
export type ScheduleCancelFunc<ID> = (id: ID) => void;
|
|
7
|
-
|
|
8
|
-
export type Scheduler<ID> = {
|
|
9
|
-
duration: number,
|
|
10
|
-
|
|
11
|
-
request: ScheduleRequestFunc<ID>,
|
|
12
|
-
cancel: ScheduleCancelFunc<ID>,
|
|
13
|
-
}
|
|
14
|
-
|
|
15
5
|
export type RenderFunction<T> = (node: act.Node, root: T) => { stop: () => void }
|
|
16
6
|
|
|
17
|
-
export const createRenderFunction = <
|
|
18
|
-
scheduler: Scheduler
|
|
7
|
+
export const createRenderFunction = <T>(
|
|
8
|
+
scheduler: Scheduler,
|
|
19
9
|
createSpace: (tree: CommitTree, root: T) => RenderSpace
|
|
20
10
|
): RenderFunction<T> => {
|
|
21
|
-
const render: RenderFunction<T> = (node: act.Node, root: T) => {
|
|
22
|
-
const reconciler = createReconciler(deltas => {
|
|
23
|
-
space.create(deltas).configure();
|
|
24
|
-
}, () => {
|
|
25
|
-
scheduler.cancel(id);
|
|
26
|
-
id = scheduler.request(work)
|
|
27
|
-
});
|
|
28
11
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
scheduler.cancel(id)
|
|
12
|
+
const render: RenderFunction<T> = (node: act.Node, root: T) => {
|
|
13
|
+
const onThreadComplete = (thread: WorkThread) => {
|
|
14
|
+
space.create(thread.deltas).configure();
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const reconciler = createReconciler(scheduler);
|
|
18
|
+
const threadCompleteSub = reconciler.subscribe(event => {
|
|
19
|
+
switch (event.type) {
|
|
20
|
+
case 'thread:complete':
|
|
21
|
+
return onThreadComplete(event.thread);
|
|
40
22
|
}
|
|
41
|
-
}
|
|
23
|
+
})
|
|
42
24
|
|
|
43
|
-
|
|
25
|
+
const space = createSpace(reconciler.tree, root);
|
|
44
26
|
|
|
45
|
-
reconciler.
|
|
27
|
+
reconciler.mount(node);
|
|
46
28
|
|
|
47
29
|
return {
|
|
48
30
|
stop() {
|
|
49
|
-
|
|
31
|
+
threadCompleteSub.cancel();
|
|
50
32
|
},
|
|
51
33
|
}
|
|
52
34
|
};
|
package/space.ts
CHANGED
|
@@ -41,6 +41,18 @@ export type NodeRef<T> = {
|
|
|
41
41
|
node: T,
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
/**
|
|
45
|
+
* A "simple" render space is just a conventional
|
|
46
|
+
* render space where we keep track of each commit
|
|
47
|
+
* in a map - and take a "SimpleRenderSpaceArgs"
|
|
48
|
+
* args object that tells us how we make, link,
|
|
49
|
+
* sort, and update our nodes.
|
|
50
|
+
*
|
|
51
|
+
* @param tree
|
|
52
|
+
* @param args
|
|
53
|
+
* @param nodeByCommit
|
|
54
|
+
* @returns
|
|
55
|
+
*/
|
|
44
56
|
export const createSimpleRenderSpace = <T, R extends string | Symbol>(
|
|
45
57
|
tree: recon.CommitTree,
|
|
46
58
|
args: SimpleRenderSpaceArgs<T, R>,
|
|
@@ -79,7 +91,7 @@ export const createSimpleRenderSpace = <T, R extends string | Symbol>(
|
|
|
79
91
|
if (node)
|
|
80
92
|
return { id, node }
|
|
81
93
|
}
|
|
82
|
-
// this element has no parents - it is probably a "root" commit
|
|
94
|
+
// this element has no "node" parents - it is probably a "root" commit
|
|
83
95
|
return null;
|
|
84
96
|
}
|
|
85
97
|
const findRootId = (ref: recon.CommitRef) => {
|
|
@@ -121,7 +133,6 @@ export const createSimpleRenderSpace = <T, R extends string | Symbol>(
|
|
|
121
133
|
commitByNode.set(node, delta.ref.id)
|
|
122
134
|
}
|
|
123
135
|
}
|
|
124
|
-
|
|
125
136
|
}
|
|
126
137
|
|
|
127
138
|
return {
|