@nice-code/state 0.4.2 → 0.4.4
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/README.md +262 -1
- package/build/devtools/browser/index.js +453 -126
- package/build/types/devtools/browser/components/DiffView.d.ts +6 -3
- package/build/types/devtools/browser/components/JsonDiffView.d.ts +21 -0
- package/build/types/devtools/browser/components/utils.d.ts +13 -0
- package/build/types/devtools/browser/devtools_dock.d.ts +7 -0
- package/package.json +1 -1
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Test-framework-style diff: only the paths that changed
|
|
3
|
-
*
|
|
4
|
-
* `
|
|
2
|
+
* Test-framework-style diff: only the paths that changed. Changed paths are
|
|
3
|
+
* grouped into a hierarchy by their shared parents — `countHistory.0` and
|
|
4
|
+
* `countHistory.1` nest under a single `countHistory` node, each shown by its
|
|
5
|
+
* direct key only. Single-child chains collapse to a dotted path (`a.b.c`) so
|
|
6
|
+
* lone deep changes stay on one line. Short values render inline with the key
|
|
7
|
+
* (`count: 0 → 1`); long ones keep the removed/added line block.
|
|
5
8
|
*/
|
|
6
9
|
export declare function DiffView({ before, after }: {
|
|
7
10
|
before: unknown;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified, git-style diff of the entire state snapshot. Both sides are rendered
|
|
3
|
+
* as pretty JSON and line-diffed, so unchanged structure stays visible for
|
|
4
|
+
* context while removed lines (red, `−`) and added lines (green, `+`) call out
|
|
5
|
+
* exactly which sections of the whole state moved.
|
|
6
|
+
*/
|
|
7
|
+
export declare function JsonDiffView({ before, after }: {
|
|
8
|
+
before: unknown;
|
|
9
|
+
after: unknown;
|
|
10
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
/**
|
|
12
|
+
* The full JSON of one snapshot with the lines that differ from the other side
|
|
13
|
+
* highlighted in place — red behind removed lines on the "before" side, green
|
|
14
|
+
* behind added lines on the "after" side. Lines common to both render plainly so
|
|
15
|
+
* the highlight reads as "here is what changed within the whole state".
|
|
16
|
+
*/
|
|
17
|
+
export declare function HighlightedJsonView({ before, after, side, }: {
|
|
18
|
+
before: unknown;
|
|
19
|
+
after: unknown;
|
|
20
|
+
side: "before" | "after";
|
|
21
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -16,6 +16,7 @@ export declare function summarizeChange(change: IDevtoolsStateChange): string;
|
|
|
16
16
|
export type TDiffKind = "added" | "removed" | "changed";
|
|
17
17
|
export interface IDiffEntry {
|
|
18
18
|
path: string;
|
|
19
|
+
segments: (string | number)[];
|
|
19
20
|
kind: TDiffKind;
|
|
20
21
|
before?: unknown;
|
|
21
22
|
after?: unknown;
|
|
@@ -27,3 +28,15 @@ export interface IDiffEntry {
|
|
|
27
28
|
* means equal branches keep their reference, so this stays cheap).
|
|
28
29
|
*/
|
|
29
30
|
export declare function computeDiff(before: unknown, after: unknown): IDiffEntry[];
|
|
31
|
+
export type TLineDiffKind = "common" | "removed" | "added";
|
|
32
|
+
export interface ILineDiffOp {
|
|
33
|
+
kind: TLineDiffKind;
|
|
34
|
+
text: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Classic LCS line diff between two blocks of text — the data behind the unified
|
|
38
|
+
* git-style "Diff View" and the per-line highlighting in the Before / After
|
|
39
|
+
* panels. Snapshots rendered as pretty JSON stay small, so the O(n·m) table is
|
|
40
|
+
* comfortably cheap.
|
|
41
|
+
*/
|
|
42
|
+
export declare function computeLineDiff(beforeText: string, afterText: string): ILineDiffOp[];
|
|
@@ -23,6 +23,13 @@ export interface IDockDevtoolInput extends IDockDevtoolSync {
|
|
|
23
23
|
export interface IDockView {
|
|
24
24
|
/** Offset (px) from the docked edge — stacks open panels on the same side. */
|
|
25
25
|
dockOffset: number;
|
|
26
|
+
/**
|
|
27
|
+
* True when this panel shares its dock side with another open panel (stacked
|
|
28
|
+
* either nearer or further from the edge). Stacked panels square off all their
|
|
29
|
+
* corners so they sit flush as one continuous block — only a panel alone on
|
|
30
|
+
* its side keeps its rounded, page-facing corners.
|
|
31
|
+
*/
|
|
32
|
+
stacked: boolean;
|
|
26
33
|
/** Is any devtool on the page currently open? */
|
|
27
34
|
anyOpen: boolean;
|
|
28
35
|
/** First-registered devtool — the one that renders the combined launcher. */
|