@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 ADDED
@@ -0,0 +1,2 @@
1
+ export * as recon from '@lukekaalim/act-recon/mod.ts';
2
+ export * as act from '@lukekaalim/act/mod.ts';
package/package.json CHANGED
@@ -1,9 +1,5 @@
1
1
  {
2
2
  "name": "@lukekaalim/act-backstage",
3
- "version": "1.0.0",
4
- "main": "mod.ts",
5
- "dependencies": {
6
- "@lukekaalim/act": "^3.0.0",
7
- "@lukekaalim/act-recon": "^1.0.0"
8
- }
9
- }
3
+ "version": "1.1.0",
4
+ "main": "mod.ts"
5
+ }
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 * as act from '@lukekaalim/act';
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
- scheduler.cancel(id)
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 * as act from '@lukekaalim/act';
2
- import * as recon from '@lukekaalim/act-recon';
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 === act.primitiveNodeTypes.null)
74
+ if (commit.element.type === primitiveNodeTypes.null)
75
75
  return { id, node: null };
76
76
 
77
77
  const node = nodeByCommit.get(id);