@mml-io/networked-dom-document 0.0.0-experimental-d240bbd-20230807
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/LICENSE +19 -0
- 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 -0
- package/build/index.js +1145 -0
- package/build/index.js.map +7 -0
- package/build/tsconfig.tsbuildinfo +1 -0
- package/package.json +24 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2023 Improbable MV Limited
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
SOFTWARE.
|
|
@@ -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" | "snapshot";
|
|
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
ADDED