@lukekaalim/act-insight 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/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @lukekaalim/act-insight
2
2
 
3
+ ## 1.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - bcbd299: SSR API for @lukekaalim/act-web
8
+ - beec21c: Fixed Web text element rehydration, remove nodejs dependencies from dehydration
9
+
10
+ ### Patch Changes
11
+
12
+ - Updated dependencies [bcbd299]
13
+ - Updated dependencies [beec21c]
14
+ - @lukekaalim/act-web@5.0.0
15
+ - @lukekaalim/act-recon@3.1.0
16
+ - @lukekaalim/act@4.1.0
17
+ - @lukekaalim/act-debug@1.0.1
18
+
3
19
  ## 1.0.0
4
20
 
5
21
  ### Major Changes
package/InsightApp.ts CHANGED
@@ -12,6 +12,8 @@ export type InsightAppProps = {
12
12
  bus: ReconcilerDebugEventBus,
13
13
 
14
14
  document: Document,
15
+
16
+ onReady(): void,
15
17
  };
16
18
 
17
19
  export type InsightAppState = {
@@ -23,15 +25,30 @@ export type InsightAppState = {
23
25
  paused: boolean,
24
26
  }
25
27
 
26
- export const InsightApp: Component<InsightAppProps> = ({ controller, bus, document = window.document }) => {
28
+ const INSIGHT_SETTINGS_LOCALSTORAGE_KEY = `INSIGHT_SETTINGS`;
29
+
30
+ export const InsightApp: Component<InsightAppProps> = ({ onReady, controller, bus, document = window.document }) => {
27
31
  const [c, setRenderCounter] = useState(0);
28
32
 
33
+ const storedState = useMemo(() => {
34
+ const settings = window.localStorage.getItem(INSIGHT_SETTINGS_LOCALSTORAGE_KEY)
35
+ if (!settings)
36
+ return;
37
+ return JSON.parse(settings) as { breakOnAfterUpdate: boolean, breakOnBeforeUpdate: boolean };
38
+ }, [])
39
+
29
40
  const [insightState, setInsightState] = useState<InsightAppState>({
30
41
  commitBreakpoints: new Set(),
31
- breakOnAfterUpdate: false,
32
- breakOnBeforeUpdate: false,
42
+ breakOnAfterUpdate: storedState ? storedState.breakOnAfterUpdate : false,
43
+ breakOnBeforeUpdate: storedState ? storedState.breakOnBeforeUpdate : false,
33
44
  paused: false,
34
45
  });
46
+ useEffect(() => {
47
+ window.localStorage.setItem(INSIGHT_SETTINGS_LOCALSTORAGE_KEY, JSON.stringify({
48
+ breakOnAfterUpdate: insightState.breakOnAfterUpdate,
49
+ breakOnBeforeUpdate: insightState.breakOnBeforeUpdate,
50
+ }))
51
+ }, [insightState])
35
52
 
36
53
  const commitCache = useRef(() => new CommitLookupCache()).current;
37
54
  const deltaCache = useRef(() => new ThreadLookupCache(commitCache)).current;
@@ -44,9 +61,20 @@ export const InsightApp: Component<InsightAppProps> = ({ controller, bus, docume
44
61
  useEffect(() => {
45
62
  console.log('[Insight] Populate Cache')
46
63
 
64
+ bus.externalUpdate = () => {
65
+ const delta = controller.getDelta();
66
+ const thread = controller.getThread();
67
+
68
+ commitCache.setTree(controller.getTree())
69
+
70
+ deltaCache.ingestDelta(delta);
71
+ deltaCache.ingestThread(thread);
72
+ setRenderCounter(c => c + 1);
73
+ }
74
+
47
75
  bus.onThreadDone = (thread, delta) => {
48
76
  console.log('[Insight] ThreadDone')
49
-
77
+ commitCache.ingest(delta);
50
78
  deltaCache.ingestDelta(delta);
51
79
  deltaCache.ingestThread(thread);
52
80
  deltaCache.prevTask = null;
@@ -64,8 +92,7 @@ export const InsightApp: Component<InsightAppProps> = ({ controller, bus, docume
64
92
  if (insightState.breakOnBeforeUpdate)
65
93
  controller.scheduler.intercept = true;
66
94
 
67
- if (deltaCache.report)
68
- commitCache.ingest(deltaCache.report);
95
+ commitCache.setTree(controller.getTree())
69
96
 
70
97
  deltaCache.reset();
71
98
  deltaCache.ingestThread(thread);
@@ -101,6 +128,8 @@ export const InsightApp: Component<InsightAppProps> = ({ controller, bus, docume
101
128
  deltaCache.prevTask = prevTask;
102
129
  }
103
130
  }
131
+
132
+ onReady();
104
133
  }, [controller, bus, insightState]);
105
134
 
106
135
  const cacheSubscribers = useRef<Set<() => void>>(new Set()).current;
@@ -180,6 +209,15 @@ export const InsightApp: Component<InsightAppProps> = ({ controller, bus, docume
180
209
  ])
181
210
  }, [])
182
211
 
212
+ const reload = () => {
213
+ commitCache.setTree(controller.getTree())
214
+ deltaCache.reset();
215
+ deltaCache.ingestDelta(controller.getDelta());
216
+ deltaCache.ingestThread(controller.getThread());
217
+
218
+ setRenderCounter(c => c + 1)
219
+ }
220
+
183
221
  const viewportRef = useRef<HTMLElement | null>(null);
184
222
 
185
223
  const [selectedCommitId, setSelectedCommitId] = useState<CommitID | null>(null)
@@ -208,6 +246,7 @@ export const InsightApp: Component<InsightAppProps> = ({ controller, bus, docume
208
246
  state: insightState,
209
247
  onStateChange: setInsightState,
210
248
  }),
249
+ h('button', { onClick: reload}, 'Reload'),
211
250
  ]),
212
251
  h('div', { style: { flex: 1, overflow: 'hidden', background: '#c0d7ddff', display: 'flex' } }, [
213
252
  h('div', { style: { flex: 1 } },
package/lookup.ts CHANGED
@@ -28,7 +28,7 @@ export class MutableCommitRef {
28
28
  }
29
29
 
30
30
  resolve(lookupMap: Map<CommitID, MutableCommitRef>) {
31
- if (this.report.parent)
31
+ if (this.report.parent !== null)
32
32
  this.linkParent(this.report.parent, lookupMap);
33
33
  this.linkChildren(this.report.children, lookupMap);
34
34
  }
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@lukekaalim/act-insight",
3
3
  "main": "index.ts",
4
- "version": "1.0.0",
4
+ "version": "1.1.0",
5
5
  "scripts": {},
6
6
  "dependencies": {
7
7
  "@lukekaalim/act": "*",
8
- "@lukekaalim/act-recon": "3.0.0",
9
- "@lukekaalim/act-web": "4.0.0",
10
- "@lukekaalim/act-debug": "1.0.0",
8
+ "@lukekaalim/act-recon": "3.1.0",
9
+ "@lukekaalim/act-web": "5.0.0",
10
+ "@lukekaalim/act-debug": "1.0.1",
11
11
  "@sindresorhus/string-hash": "^2.0.0",
12
12
  "@types/firefox-webext-browser": "^120.0.4",
13
13
  "lodash-es": "^4.17.21"
package/utils.ts CHANGED
@@ -34,7 +34,7 @@ export const renderDEV = (node: Node, builders: NodeBuilder<any, any>[], { mode
34
34
  }
35
35
 
36
36
 
37
- export const createDebugPopup = (reconciler: DebugReconciler) => {
37
+ export const createDebugPopup = async (reconciler: DebugReconciler) => {
38
38
  const newWindow = window.open('', "DevTools", "popup");
39
39
  if (!newWindow)
40
40
  throw new Error(`Unable to make/find new window!`);
@@ -52,10 +52,13 @@ export const createDebugPopup = (reconciler: DebugReconciler) => {
52
52
  element.href = src.href;
53
53
  newWindow.document.head.appendChild(element)
54
54
  }
55
+
56
+ return new Promise<void>(onReady => {
57
+ render(
58
+ h(InsightApp, { controller: reconciler.controller, bus: reconciler.debugBus, document: newWindow.document, onReady }),
59
+ body,
60
+ { window: newWindow }
61
+ );
62
+ })
55
63
 
56
- render(
57
- h(InsightApp, { controller: reconciler.controller, bus: reconciler.debugBus, document: newWindow.document }),
58
- body,
59
- { window: newWindow }
60
- );
61
64
  }