@lukekaalim/act-recon 3.0.0 → 3.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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @lukekaalim/act-recon
2
2
 
3
+ ## 3.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - bcbd299: SSR API for @lukekaalim/act-web
8
+
9
+ ### Patch Changes
10
+
11
+ - beec21c: Fixed Web text element rehydration, remove nodejs dependencies from dehydration
12
+ - Updated dependencies [bcbd299]
13
+ - Updated dependencies [beec21c]
14
+ - @lukekaalim/act@4.1.0
15
+
3
16
  ## 3.0.0
4
17
 
5
18
  ### Major Changes
package/commit.ts CHANGED
@@ -78,6 +78,11 @@ export class CommitRef2 {
78
78
  static fresh(parent: CommitRef2 | null) {
79
79
  return new CommitRef2(createId('CommitID'), parent);
80
80
  }
81
+ static rehydrate(id: CommitID, length: number) {
82
+ const ref = new CommitRef2(id, null);
83
+ ref.length = length;
84
+ return ref;
85
+ }
81
86
  }
82
87
 
83
88
  export class Commit2 {
package/element.ts CHANGED
@@ -12,8 +12,8 @@ import { loadHooks2 } from "./hooks";
12
12
  import { BoundaryState, ComponentState, ContextState, EffectTask } from "./state";
13
13
  import { keyedElementEqualityTest2, WorkTask } from "./update";
14
14
  import { ChangeReport2 } from "./algorithms";
15
- import { Reconciler2 } from "./reconciler";
16
15
  import { CommitTree2 } from "./tree";
16
+ import { internalHookImplementations } from "./internal";
17
17
 
18
18
  /**
19
19
  * A data structure that represents the immediate output
@@ -57,9 +57,11 @@ export class ElementOutput2 {
57
57
  if (!state.hooks)
58
58
  state.hooks = loadHooks2(tree.reconciler, state, this.ref);
59
59
 
60
+
60
61
  hookImplementation.useContext = state.hooks.useContext;
61
62
  hookImplementation.useEffect = state.hooks.useEffect;
62
63
  hookImplementation.useState = state.hooks.useState;
64
+ internalHookImplementations.useInternalComponentState = () => state;
63
65
 
64
66
  const props = {
65
67
  ...this.element.props,
package/internal.ts ADDED
@@ -0,0 +1,12 @@
1
+ import { UnsetHookImplementation } from "@lukekaalim/act";
2
+ import { ComponentState } from "./state";
3
+
4
+ export const useInternalComponentState = (): ComponentState => {
5
+ return internalHookImplementations.useInternalComponentState();
6
+ }
7
+
8
+ export const internalHookImplementations = {
9
+ useInternalComponentState(): ComponentState {
10
+ throw new UnsetHookImplementation();
11
+ },
12
+ }
package/mod.ts CHANGED
@@ -11,3 +11,4 @@ export * from './thread';
11
11
  export * from './tree';
12
12
  export * from './update';
13
13
  export * from './pool';
14
+ export * from './internal';
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@lukekaalim/act-recon",
3
3
  "type": "module",
4
- "version": "3.0.0",
4
+ "version": "3.1.0",
5
5
  "main": "mod.ts",
6
6
  "dependencies": {
7
- "@lukekaalim/act": "^4.0.0"
7
+ "@lukekaalim/act": "^4.1.0"
8
8
  }
9
9
  }
package/reconciler.ts CHANGED
@@ -48,12 +48,14 @@ export class Reconciler2 {
48
48
  this.pools.commit.maxSize = 2048
49
49
  }
50
50
 
51
+ startNewThread() {
52
+ this.thread = new WorkThread2(this.tree);
53
+ }
54
+
51
55
  submitThread() {
52
56
  const currentThread = this.thread;
53
- // Start a new thread
54
- this.thread = new WorkThread2(this.tree);
55
57
 
56
- this.running = false;
58
+ this.startNewThread();
57
59
 
58
60
  // send delta ready
59
61
  this.bus.render(currentThread.delta);
@@ -77,7 +79,6 @@ export class Reconciler2 {
77
79
  this.submitThread()
78
80
  }
79
81
  }
80
- running = false;
81
82
 
82
83
  mount(node: Node): CommitRef2 {
83
84
  const element = convertNodeToElement(node);
package/state.ts CHANGED
@@ -2,7 +2,7 @@ import { CommitID, CommitRef2 } from "./commit.ts";
2
2
  import { OpaqueID, Deps, EffectCleanup, ContextID, HookImplementation, createId, BoundaryProps } from '@lukekaalim/act';
3
3
  import { CommitTree2 } from "./tree.ts";
4
4
 
5
-
5
+ export type HookID = number;
6
6
  export type EffectID = OpaqueID<"EffectID">;
7
7
  export type EffectTask = {
8
8
  ref: CommitRef2,
@@ -15,19 +15,19 @@ export type ComponentState = {
15
15
 
16
16
  unmounted: boolean,
17
17
 
18
- hookIndex: number,
18
+ hookIndex: HookID,
19
19
  hooks: null | HookImplementation,
20
20
  effectTasks: null | EffectTask[],
21
21
 
22
- values: Map<number, unknown>;
23
- deps: Map<number, Deps>;
24
- effects: Map<number, EffectID>;
25
- cleanups: Map<number, EffectCleanup>;
22
+ values: Map<HookID, unknown>;
23
+ deps: Map<HookID, Deps>;
24
+ effects: Map<HookID, EffectID>;
25
+ cleanups: Map<HookID, EffectCleanup>;
26
26
 
27
27
  rejection: null | { value: unknown };
28
28
  boundary: null | BoundaryState;
29
29
 
30
- providers: Map<number, null | ContextState<unknown>>;
30
+ providers: Map<HookID, null | ContextState<unknown>>;
31
31
  };
32
32
 
33
33
  export type ContextState<T> = {
package/update.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { convertNodeToElements, createId, Element, Node } from "@lukekaalim/act";
1
+ import { convertNodeToElements, createId, Element, Node, specialNodeTypes } from "@lukekaalim/act";
2
2
  import { ChangeEqualityTest, ChangeReport2 } from "./algorithms.ts";
3
3
  import { Commit2, CommitID, CommitRef2 } from "./commit.ts";
4
4
  import { createObjectPool, ObjectPool } from "./pool.ts";
@@ -70,7 +70,7 @@ export class WorkTask {
70
70
  }
71
71
 
72
72
  export const keyedElementEqualityTest2: ChangeEqualityTest<Commit2, Element> = (prev, next, prev_index, next_index) => {
73
- const compatible = prev.element.type === next.type;
73
+ const compatible = prev.element.type === next.type || prev.element.type === specialNodeTypes.placeholder;
74
74
  if (!compatible)
75
75
  return false;
76
76
  const prevKey = prev.element.props.key;
@@ -80,5 +80,3 @@ export const keyedElementEqualityTest2: ChangeEqualityTest<Commit2, Element> =
80
80
 
81
81
  return prev_index === next_index;
82
82
  }
83
-
84
- (window as any).WorkTask = WorkTask;