@lvce-editor/virtual-dom-worker 6.10.0 → 7.0.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/dist/index.d.ts +1 -81
- package/dist/parts/AddPatch/AddPatch.d.ts +5 -0
- package/dist/parts/ApplyPendingPatches/ApplyPendingPatches.d.ts +2 -0
- package/dist/parts/AriaLive/AriaLive.d.ts +1 -0
- package/dist/parts/AttributePatch/AttributePatch.d.ts +5 -0
- package/dist/parts/DomEventListener/DomEventListener.d.ts +6 -0
- package/dist/parts/GetKeys/GetKeys.d.ts +2 -0
- package/dist/parts/GetTotalChildCount/GetTotalChildCount.d.ts +2 -0
- package/dist/parts/IsKey/IsKey.d.ts +1 -0
- package/dist/parts/Main/Main.d.ts +8 -0
- package/dist/parts/MergeClassNames/MergeClassNames.d.ts +1 -0
- package/dist/parts/NavigateChildPatch/NavigateChildPatch.d.ts +4 -0
- package/dist/parts/NavigateParentPatch/NavigateParentPatch.d.ts +3 -0
- package/dist/parts/NavigateSiblingPatch/NavigateSiblingPatch.d.ts +4 -0
- package/dist/parts/Patch/Patch.d.ts +12 -0
- package/dist/parts/PatchType/PatchType.d.ts +11 -0
- package/dist/parts/PatchType/PatchType.js +1 -0
- package/dist/parts/Px/Px.d.ts +2 -0
- package/dist/parts/RemoveAttributePatch/RemoveAttributePatch.d.ts +4 -0
- package/dist/parts/RemoveChildPatch/RemoveChildPatch.d.ts +4 -0
- package/dist/parts/RemovePatch/RemovePatch.d.ts +4 -0
- package/dist/parts/ReplacePatch/ReplacePatch.d.ts +5 -0
- package/dist/parts/SetReferenceNodeUidPatch/SetReferenceNodeUidPatch.d.ts +4 -0
- package/dist/parts/SetReferenceNodeUidPatch/SetReferenceNodeUidPatch.js +1 -0
- package/dist/parts/Text/Text.d.ts +2 -0
- package/dist/parts/TextPatch/TextPatch.d.ts +4 -0
- package/dist/parts/VirtualDomDiff/VirtualDomDiff.d.ts +3 -0
- package/dist/parts/VirtualDomDiffTree/CompareNodes.d.ts +3 -0
- package/dist/parts/VirtualDomDiffTree/CompareNodes.js +10 -0
- package/dist/parts/VirtualDomDiffTree/DiffTrees.d.ts +3 -0
- package/dist/parts/VirtualDomDiffTree/RemoveTrailingNavigationPatches.d.ts +2 -0
- package/dist/parts/VirtualDomDiffTree/TreeToArray.d.ts +3 -0
- package/dist/parts/VirtualDomDiffTree/VirtualDomDiffTree.d.ts +3 -0
- package/dist/parts/VirtualDomNode/VirtualDomNode.d.ts +4 -0
- package/dist/parts/VirtualDomTree/VirtualDomTree.d.ts +6 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,81 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export { AriaRoles, ClassNames, InputEventType, KeyCode, KeyModifier, MouseEventType, VirtualDomElements, WhenExpression } from './parts/Main/Main.ts';
|
|
4
|
-
import { AriaRoles, ClassNames, InputEventType, KeyCode, KeyModifier, MouseEventType, VirtualDomElements, WhenExpression } from '@lvce-editor/constants';
|
|
5
|
-
|
|
6
|
-
declare const Polite = "polite";
|
|
7
|
-
export interface DomEventListener {
|
|
8
|
-
readonly name: string | number;
|
|
9
|
-
readonly params: readonly (string | number)[];
|
|
10
|
-
readonly passive?: boolean;
|
|
11
|
-
readonly preventDefault?: boolean;
|
|
12
|
-
}
|
|
13
|
-
export declare const mergeClassNames: (...classNames: readonly string[]) => string;
|
|
14
|
-
export declare const px: (value: number) => string;
|
|
15
|
-
export declare const position: (x: number, y: number) => string;
|
|
16
|
-
export interface VirtualDomNode {
|
|
17
|
-
readonly [key: string]: any;
|
|
18
|
-
readonly type: number;
|
|
19
|
-
}
|
|
20
|
-
export declare const text: (data: string) => VirtualDomNode;
|
|
21
|
-
export interface AddPatch {
|
|
22
|
-
readonly nodes: readonly VirtualDomNode[];
|
|
23
|
-
readonly type: 6;
|
|
24
|
-
}
|
|
25
|
-
export interface AttributePatch {
|
|
26
|
-
readonly key: string;
|
|
27
|
-
readonly type: 3;
|
|
28
|
-
readonly value: any;
|
|
29
|
-
}
|
|
30
|
-
export type NavigateChildPatch = {
|
|
31
|
-
readonly type: 7;
|
|
32
|
-
readonly index: number;
|
|
33
|
-
};
|
|
34
|
-
export type NavigateParentPatch = {
|
|
35
|
-
readonly type: 8;
|
|
36
|
-
};
|
|
37
|
-
export type NavigateSiblingPatch = {
|
|
38
|
-
readonly type: 10;
|
|
39
|
-
readonly index: number;
|
|
40
|
-
};
|
|
41
|
-
export interface RemoveAttributePatch {
|
|
42
|
-
readonly key: string;
|
|
43
|
-
readonly type: 4;
|
|
44
|
-
}
|
|
45
|
-
export interface RemoveChildPatch {
|
|
46
|
-
readonly index: number;
|
|
47
|
-
readonly type: 9;
|
|
48
|
-
}
|
|
49
|
-
export interface RemovePatch {
|
|
50
|
-
readonly index: number;
|
|
51
|
-
readonly type: 5;
|
|
52
|
-
}
|
|
53
|
-
export interface ReplacePatch {
|
|
54
|
-
readonly nodes: readonly VirtualDomNode[];
|
|
55
|
-
readonly type: 2;
|
|
56
|
-
}
|
|
57
|
-
export interface TextPatch {
|
|
58
|
-
readonly type: 1;
|
|
59
|
-
readonly value: string;
|
|
60
|
-
}
|
|
61
|
-
export type Patch = TextPatch | AttributePatch | ReplacePatch | RemoveAttributePatch | RemovePatch | AddPatch | NavigateChildPatch | NavigateParentPatch | RemoveChildPatch | NavigateSiblingPatch;
|
|
62
|
-
export declare const diff: (oldNodes: readonly VirtualDomNode[], newNodes: readonly VirtualDomNode[]) => readonly Patch[];
|
|
63
|
-
export declare const diffTree: (oldNodes: readonly VirtualDomNode[], newNodes: readonly VirtualDomNode[]) => readonly Patch[];
|
|
64
|
-
|
|
65
|
-
declare namespace AriaLive {
|
|
66
|
-
export { Polite };
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export {
|
|
70
|
-
AriaLive,
|
|
71
|
-
AriaRoles,
|
|
72
|
-
ClassNames,
|
|
73
|
-
InputEventType,
|
|
74
|
-
KeyCode,
|
|
75
|
-
KeyModifier,
|
|
76
|
-
MouseEventType,
|
|
77
|
-
VirtualDomElements,
|
|
78
|
-
WhenExpression,
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
export {};
|
|
1
|
+
export * from './parts/Main/Main.ts';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const Polite = "polite";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isKey: (key: string) => boolean;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { AriaRoles, ClassNames, InputEventType, KeyCode, KeyModifier, MouseEventType, VirtualDomElements, WhenExpression, } from '@lvce-editor/constants';
|
|
2
|
+
export * as AriaLive from '../AriaLive/AriaLive.ts';
|
|
3
|
+
export type * from '../DomEventListener/DomEventListener.ts';
|
|
4
|
+
export * from '../MergeClassNames/MergeClassNames.ts';
|
|
5
|
+
export * from '../Px/Px.ts';
|
|
6
|
+
export * from '../Text/Text.ts';
|
|
7
|
+
export { diff } from '../VirtualDomDiff/VirtualDomDiff.ts';
|
|
8
|
+
export { diffTree } from '../VirtualDomDiffTree/VirtualDomDiffTree.ts';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const mergeClassNames: (...classNames: readonly string[]) => string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AddPatch } from '../AddPatch/AddPatch.ts';
|
|
2
|
+
import type { AttributePatch } from '../AttributePatch/AttributePatch.ts';
|
|
3
|
+
import type { NavigateChildPatch } from '../NavigateChildPatch/NavigateChildPatch.ts';
|
|
4
|
+
import type { NavigateParentPatch } from '../NavigateParentPatch/NavigateParentPatch.ts';
|
|
5
|
+
import type { NavigateSiblingPatch } from '../NavigateSiblingPatch/NavigateSiblingPatch.ts';
|
|
6
|
+
import type { RemoveAttributePatch } from '../RemoveAttributePatch/RemoveAttributePatch.ts';
|
|
7
|
+
import type { RemoveChildPatch } from '../RemoveChildPatch/RemoveChildPatch.ts';
|
|
8
|
+
import type { RemovePatch } from '../RemovePatch/RemovePatch.ts';
|
|
9
|
+
import type { ReplacePatch } from '../ReplacePatch/ReplacePatch.ts';
|
|
10
|
+
import type { SetReferenceNodeUidPatch } from '../SetReferenceNodeUidPatch/SetReferenceNodeUidPatch.ts';
|
|
11
|
+
import type { TextPatch } from '../TextPatch/TextPatch.ts';
|
|
12
|
+
export type Patch = TextPatch | AttributePatch | ReplacePatch | RemoveAttributePatch | RemovePatch | AddPatch | NavigateChildPatch | NavigateParentPatch | RemoveChildPatch | NavigateSiblingPatch | SetReferenceNodeUidPatch;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const SetText = 1;
|
|
2
|
+
export declare const Replace = 2;
|
|
3
|
+
export declare const SetAttribute = 3;
|
|
4
|
+
export declare const RemoveAttribute = 4;
|
|
5
|
+
export declare const Remove = 5;
|
|
6
|
+
export declare const Add = 6;
|
|
7
|
+
export declare const NavigateChild = 7;
|
|
8
|
+
export declare const NavigateParent = 8;
|
|
9
|
+
export declare const RemoveChild = 9;
|
|
10
|
+
export declare const NavigateSibling = 10;
|
|
11
|
+
export declare const SetReferenceNodeUid = 11;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -8,6 +8,16 @@ export const compareNodes = (oldNode, newNode) => {
|
|
|
8
8
|
if (oldNode.type !== newNode.type) {
|
|
9
9
|
return null;
|
|
10
10
|
}
|
|
11
|
+
// Handle reference nodes - special handling for uid changes
|
|
12
|
+
if (oldNode.type === VirtualDomElements.Reference) {
|
|
13
|
+
if (oldNode.uid !== newNode.uid) {
|
|
14
|
+
patches.push({
|
|
15
|
+
type: PatchType.SetReferenceNodeUid,
|
|
16
|
+
uid: newNode.uid,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return patches;
|
|
20
|
+
}
|
|
11
21
|
// Handle text nodes
|
|
12
22
|
if (oldNode.type === VirtualDomElements.Text &&
|
|
13
23
|
newNode.type === VirtualDomElements.Text) {
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { Patch } from '../Patch/Patch.ts';
|
|
2
|
+
import type * as VirtualDomTree from '../VirtualDomTree/VirtualDomTree.ts';
|
|
3
|
+
export declare const diffTrees: (oldTree: readonly VirtualDomTree.VirtualDomTreeNode[], newTree: readonly VirtualDomTree.VirtualDomTreeNode[], patches: Patch[], path: number[]) => void;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { VirtualDomNode } from '../VirtualDomNode/VirtualDomNode.ts';
|
|
2
|
+
export interface VirtualDomTreeNode {
|
|
3
|
+
readonly children: readonly VirtualDomTreeNode[];
|
|
4
|
+
readonly node: VirtualDomNode;
|
|
5
|
+
}
|
|
6
|
+
export declare const arrayToTree: (nodes: readonly VirtualDomNode[]) => readonly VirtualDomTreeNode[];
|