@mml-io/networked-dom-document 0.1.3 → 0.3.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/build/EditableNetworkedDOM.d.ts +18 -0
- package/build/NetworkedDOM.d.ts +51 -0
- package/build/common.d.ts +19 -0
- package/build/diffing.d.ts +11 -0
- package/build/index.d.ts +2 -1
- package/build/index.js +100 -120
- package/build/index.js.map +3 -3
- package/build/tsconfig.tsbuildinfo +1 -0
- package/package.json +4 -5
- package/src/EditableNetworkedDOM.ts +0 -128
- package/src/NetworkedDOM.ts +0 -717
- package/src/common.ts +0 -23
- package/src/diffing.ts +0 -542
- package/src/index.ts +0 -2
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { LogMessage } from "@mml-io/observable-dom-common";
|
|
2
|
+
import { ObservableDOMFactory } from "./NetworkedDOM";
|
|
3
|
+
export declare class EditableNetworkedDOM {
|
|
4
|
+
private htmlPath;
|
|
5
|
+
private params;
|
|
6
|
+
private websockets;
|
|
7
|
+
private loadedState;
|
|
8
|
+
private observableDOMFactory;
|
|
9
|
+
private ignoreTextNodes;
|
|
10
|
+
private logCallback?;
|
|
11
|
+
constructor(htmlPath: string, observableDOMFactory: ObservableDOMFactory, ignoreTextNodes?: boolean, logCallback?: (message: LogMessage) => void);
|
|
12
|
+
isLoaded(): boolean;
|
|
13
|
+
load(htmlContents: string, params?: object): void;
|
|
14
|
+
reload(): void;
|
|
15
|
+
dispose(): void;
|
|
16
|
+
addWebSocket(webSocket: WebSocket): void;
|
|
17
|
+
removeWebSocket(webSocket: WebSocket): void;
|
|
18
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { ClientMessage, PongMessage } from "@mml-io/networked-dom-protocol";
|
|
2
|
+
import { LogMessage, ObservableDOMInterface, ObservableDOMMessage, ObservableDOMParameters, StaticVirtualDOMElement } from "@mml-io/observable-dom-common";
|
|
3
|
+
import { VirtualDOMDiffStruct } from "./common";
|
|
4
|
+
export declare const networkedDOMProtocolSubProtocol_v0_1 = "networked-dom-v0.1";
|
|
5
|
+
export declare const defaultWebsocketSubProtocol = "networked-dom-v0.1";
|
|
6
|
+
export type ObservableDOMFactory = (observableDOMParameters: ObservableDOMParameters, callback: (message: ObservableDOMMessage, observableDOM: ObservableDOMInterface) => void) => ObservableDOMInterface;
|
|
7
|
+
export declare class NetworkedDOM {
|
|
8
|
+
static SupportedWebsocketSubProtocolsPreferenceOrder: string[];
|
|
9
|
+
private internalNodeIdToClientNodeId;
|
|
10
|
+
private clientNodeIdToInternalNodeId;
|
|
11
|
+
private currentConnectionId;
|
|
12
|
+
private connectionIdToWebSocketContext;
|
|
13
|
+
private webSocketToConnectionId;
|
|
14
|
+
private visibleNodeIdsByConnectionId;
|
|
15
|
+
private initialLoad;
|
|
16
|
+
private readonly htmlPath;
|
|
17
|
+
private disposed;
|
|
18
|
+
private ignoreTextNodes;
|
|
19
|
+
private documentRoot;
|
|
20
|
+
private nodeIdToNode;
|
|
21
|
+
private nodeIdToParentNodeId;
|
|
22
|
+
private observableDOM;
|
|
23
|
+
private documentEffectiveStartTime;
|
|
24
|
+
private latestDocumentTime;
|
|
25
|
+
private pingCounter;
|
|
26
|
+
private maximumNodeId;
|
|
27
|
+
private logCallback?;
|
|
28
|
+
constructor(observableDOMFactory: ObservableDOMFactory, htmlPath: string, htmlContents: string, oldInstanceDocumentRoot: StaticVirtualDOMElement | null, onLoad: (domDiff: VirtualDOMDiffStruct | null, networkedDOM: NetworkedDOM) => void, params?: {}, ignoreTextNodes?: boolean, logCallback?: (message: LogMessage) => void);
|
|
29
|
+
private defaultLogCallback;
|
|
30
|
+
private addRemappedNodeId;
|
|
31
|
+
private sendPings;
|
|
32
|
+
private getInitialSnapshot;
|
|
33
|
+
getDocumentTime(): number;
|
|
34
|
+
addExistingWebsockets(websockets: Array<WebSocket>, existingWebsocketMap: Map<WebSocket, number> | null, domDiff: VirtualDOMDiffStruct | null): void;
|
|
35
|
+
private findParentNodeOfNodeId;
|
|
36
|
+
private registerWebsocket;
|
|
37
|
+
static handleWebsocketSubprotocol(protocols: Set<string> | Array<string>): string | false;
|
|
38
|
+
addWebSocket(webSocket: WebSocket): void;
|
|
39
|
+
removeWebSocket(webSocket: WebSocket): void;
|
|
40
|
+
dispose(): void;
|
|
41
|
+
private processModification;
|
|
42
|
+
private removeKnownNodesInMutation;
|
|
43
|
+
private removeVirtualDOMElement;
|
|
44
|
+
static IsPongMessage(message: ClientMessage): message is PongMessage;
|
|
45
|
+
private dispatchRemoteEvent;
|
|
46
|
+
private getStaticVirtualDOMElementByInternalNodeIdOrThrow;
|
|
47
|
+
private addKnownNodesInMutation;
|
|
48
|
+
getSnapshot(): StaticVirtualDOMElement;
|
|
49
|
+
private addAndRemapNodeFromInstance;
|
|
50
|
+
getWebsocketConnectionIdMap(): Map<WebSocket, number>;
|
|
51
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { StaticVirtualDOMElement } from "@mml-io/observable-dom-common";
|
|
2
|
+
import * as rfc6902 from "rfc6902";
|
|
3
|
+
export type NodeMapping = {
|
|
4
|
+
clientFacingNodeId: number;
|
|
5
|
+
internalNodeId: number;
|
|
6
|
+
};
|
|
7
|
+
export type VirtualDOMDiffStruct = {
|
|
8
|
+
originalState: StaticVirtualDOMElement;
|
|
9
|
+
nodeIdRemappings: Array<NodeMapping>;
|
|
10
|
+
virtualDOMDiffs: Array<rfc6902.Operation>;
|
|
11
|
+
};
|
|
12
|
+
export type StaticVirtualDOMMutationRecord = {
|
|
13
|
+
type: "attributes" | "characterData" | "childList";
|
|
14
|
+
target: StaticVirtualDOMElement;
|
|
15
|
+
addedNodes: Array<StaticVirtualDOMElement>;
|
|
16
|
+
removedNodes: Array<StaticVirtualDOMElement>;
|
|
17
|
+
previousSibling: StaticVirtualDOMElement | null;
|
|
18
|
+
attributeName: string | null;
|
|
19
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Diff, NodeDescription } from "@mml-io/networked-dom-protocol";
|
|
2
|
+
import { StaticVirtualDOMElement } from "@mml-io/observable-dom-common";
|
|
3
|
+
import * as rfc6902 from "rfc6902";
|
|
4
|
+
import { StaticVirtualDOMMutationRecord, VirtualDOMDiffStruct } from "./common";
|
|
5
|
+
export declare const visibleToAttrName = "visible-to";
|
|
6
|
+
export declare const hiddenFromAttrName = "hidden-from";
|
|
7
|
+
export declare function diffFromApplicationOfStaticVirtualDOMMutationRecordToConnection(mutation: StaticVirtualDOMMutationRecord, parentNode: StaticVirtualDOMElement | null, connectionId: number, visibleNodesForConnection: Set<number>): Diff | null;
|
|
8
|
+
export declare function describeNodeWithChildrenForConnectionId(virtualDOMElement: StaticVirtualDOMElement, connectionId: number, visibleNodesForConnection: Set<number>): NodeDescription | null;
|
|
9
|
+
export declare function findParentNodeOfNodeId(virtualDOMElement: StaticVirtualDOMElement, targetNodeId: number): StaticVirtualDOMElement | null;
|
|
10
|
+
export declare function virtualDOMDiffToVirtualDOMMutationRecord(virtualStructure: StaticVirtualDOMElement, domDiff: rfc6902.Operation): Array<StaticVirtualDOMMutationRecord>;
|
|
11
|
+
export declare function calculateStaticVirtualDOMDiff(originalState: StaticVirtualDOMElement, latestState: StaticVirtualDOMElement): VirtualDOMDiffStruct;
|
package/build/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export * from "
|
|
1
|
+
export * from "./NetworkedDOM";
|
|
2
|
+
export * from "./EditableNetworkedDOM";
|