piral-blazor 1.0.0-pre.2217 → 1.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/LICENSE +1 -1
- package/README.md +55 -12
- package/convert.d.ts +13 -10
- package/convert.js +17 -12
- package/esm/converter.d.ts +10 -6
- package/esm/converter.js +164 -48
- package/esm/converter.js.map +1 -1
- package/esm/create.d.ts +21 -1
- package/esm/create.js +29 -15
- package/esm/create.js.map +1 -1
- package/esm/dependencies.d.ts +6 -3
- package/esm/dependencies.js +104 -14
- package/esm/dependencies.js.map +1 -1
- package/esm/events.d.ts +6 -0
- package/esm/events.js +145 -0
- package/esm/events.js.map +1 -0
- package/esm/interop.d.ts +29 -0
- package/esm/interop.js +205 -0
- package/esm/interop.js.map +1 -0
- package/esm/navigation.d.ts +2 -0
- package/esm/navigation.js +30 -0
- package/esm/navigation.js.map +1 -0
- package/esm/types.d.ts +97 -4
- package/infra.codegen +53 -68
- package/lib/converter.d.ts +10 -6
- package/lib/converter.js +164 -48
- package/lib/converter.js.map +1 -1
- package/lib/create.d.ts +21 -1
- package/lib/create.js +31 -17
- package/lib/create.js.map +1 -1
- package/lib/dependencies.d.ts +6 -3
- package/lib/dependencies.js +104 -14
- package/lib/dependencies.js.map +1 -1
- package/lib/events.d.ts +6 -0
- package/lib/events.js +154 -0
- package/lib/events.js.map +1 -0
- package/lib/index.js +1 -1
- package/lib/interop.d.ts +29 -0
- package/lib/interop.js +226 -0
- package/lib/interop.js.map +1 -0
- package/lib/navigation.d.ts +2 -0
- package/lib/navigation.js +35 -0
- package/lib/navigation.js.map +1 -0
- package/lib/types.d.ts +97 -4
- package/package.json +26 -13
- package/src/converter.ts +237 -57
- package/src/create.ts +53 -9
- package/src/dependencies.ts +122 -14
- package/src/events.ts +174 -0
- package/src/interop.ts +273 -0
- package/src/navigation.ts +36 -0
- package/src/types.ts +115 -4
- package/convert.ts +0 -17
- package/esm/internal/Environment.d.ts +0 -3
- package/esm/internal/Environment.js +0 -6
- package/esm/internal/Environment.js.map +0 -1
- package/esm/internal/Platform/BootConfig.d.ts +0 -20
- package/esm/internal/Platform/BootConfig.js +0 -10
- package/esm/internal/Platform/BootConfig.js.map +0 -1
- package/esm/internal/Platform/Mono/MonoDebugger.d.ts +0 -3
- package/esm/internal/Platform/Mono/MonoDebugger.js +0 -43
- package/esm/internal/Platform/Mono/MonoDebugger.js.map +0 -1
- package/esm/internal/Platform/Mono/MonoPlatform.d.ts +0 -2
- package/esm/internal/Platform/Mono/MonoPlatform.js +0 -403
- package/esm/internal/Platform/Mono/MonoPlatform.js.map +0 -1
- package/esm/internal/Platform/Mono/TimezoneDataFile.d.ts +0 -1
- package/esm/internal/Platform/Mono/TimezoneDataFile.js +0 -51
- package/esm/internal/Platform/Mono/TimezoneDataFile.js.map +0 -1
- package/esm/internal/Platform/Platform.d.ts +0 -31
- package/esm/internal/Platform/Platform.js +0 -2
- package/esm/internal/Platform/Platform.js.map +0 -1
- package/esm/internal/Platform/Url.d.ts +0 -2
- package/esm/internal/Platform/Url.js +0 -11
- package/esm/internal/Platform/Url.js.map +0 -1
- package/esm/internal/Platform/WebAssemblyConfigLoader.d.ts +0 -4
- package/esm/internal/Platform/WebAssemblyConfigLoader.js +0 -64
- package/esm/internal/Platform/WebAssemblyConfigLoader.js.map +0 -1
- package/esm/internal/Platform/WebAssemblyResourceLoader.d.ts +0 -24
- package/esm/internal/Platform/WebAssemblyResourceLoader.js +0 -223
- package/esm/internal/Platform/WebAssemblyResourceLoader.js.map +0 -1
- package/esm/internal/Platform/WebAssemblyStartOptions.d.ts +0 -13
- package/esm/internal/Platform/WebAssemblyStartOptions.js +0 -2
- package/esm/internal/Platform/WebAssemblyStartOptions.js.map +0 -1
- package/esm/internal/Rendering/BrowserRenderer.d.ts +0 -38
- package/esm/internal/Rendering/BrowserRenderer.js +0 -458
- package/esm/internal/Rendering/BrowserRenderer.js.map +0 -1
- package/esm/internal/Rendering/ElementReferenceCapture.d.ts +0 -1
- package/esm/internal/Rendering/ElementReferenceCapture.js +0 -24
- package/esm/internal/Rendering/ElementReferenceCapture.js.map +0 -1
- package/esm/internal/Rendering/EventDelegator.d.ts +0 -20
- package/esm/internal/Rendering/EventDelegator.js +0 -236
- package/esm/internal/Rendering/EventDelegator.js.map +0 -1
- package/esm/internal/Rendering/EventFieldInfo.d.ts +0 -6
- package/esm/internal/Rendering/EventFieldInfo.js +0 -32
- package/esm/internal/Rendering/EventFieldInfo.js.map +0 -1
- package/esm/internal/Rendering/EventForDotNet.d.ts +0 -10
- package/esm/internal/Rendering/EventForDotNet.js +0 -194
- package/esm/internal/Rendering/EventForDotNet.js.map +0 -1
- package/esm/internal/Rendering/LogicalElements.d.ts +0 -19
- package/esm/internal/Rendering/LogicalElements.js +0 -250
- package/esm/internal/Rendering/LogicalElements.js.map +0 -1
- package/esm/internal/Rendering/RenderBatch/BinaryDecoder.d.ts +0 -5
- package/esm/internal/Rendering/RenderBatch/BinaryDecoder.js +0 -34
- package/esm/internal/Rendering/RenderBatch/BinaryDecoder.js.map +0 -1
- package/esm/internal/Rendering/RenderBatch/OutOfProcessRenderBatch.d.ts +0 -18
- package/esm/internal/Rendering/RenderBatch/OutOfProcessRenderBatch.js +0 -190
- package/esm/internal/Rendering/RenderBatch/OutOfProcessRenderBatch.js.map +0 -1
- package/esm/internal/Rendering/RenderBatch/RenderBatch.d.ts +0 -87
- package/esm/internal/Rendering/RenderBatch/RenderBatch.js +0 -26
- package/esm/internal/Rendering/RenderBatch/RenderBatch.js.map +0 -1
- package/esm/internal/Rendering/RenderBatch/SharedMemoryRenderBatch.d.ts +0 -52
- package/esm/internal/Rendering/RenderBatch/SharedMemoryRenderBatch.js +0 -103
- package/esm/internal/Rendering/RenderBatch/SharedMemoryRenderBatch.js.map +0 -1
- package/esm/internal/Rendering/RenderBatch/Utf8Decoder.d.ts +0 -1
- package/esm/internal/Rendering/RenderBatch/Utf8Decoder.js +0 -63
- package/esm/internal/Rendering/RenderBatch/Utf8Decoder.js.map +0 -1
- package/esm/internal/Rendering/Renderer.d.ts +0 -8
- package/esm/internal/Rendering/Renderer.js +0 -69
- package/esm/internal/Rendering/Renderer.js.map +0 -1
- package/esm/internal/Rendering/RendererEventDispatcher.d.ts +0 -4
- package/esm/internal/Rendering/RendererEventDispatcher.js +0 -11
- package/esm/internal/Rendering/RendererEventDispatcher.js.map +0 -1
- package/esm/internal/Services/NavigationManager.d.ts +0 -16
- package/esm/internal/Services/NavigationManager.js +0 -138
- package/esm/internal/Services/NavigationManager.js.map +0 -1
- package/esm/internal/globals.d.ts +0 -1
- package/esm/internal/globals.js +0 -5
- package/esm/internal/globals.js.map +0 -1
- package/esm/internal/index.d.ts +0 -15
- package/esm/internal/index.js +0 -152
- package/esm/internal/index.js.map +0 -1
- package/lib/internal/Environment.d.ts +0 -3
- package/lib/internal/Environment.js +0 -9
- package/lib/internal/Environment.js.map +0 -1
- package/lib/internal/Platform/BootConfig.d.ts +0 -20
- package/lib/internal/Platform/BootConfig.js +0 -13
- package/lib/internal/Platform/BootConfig.js.map +0 -1
- package/lib/internal/Platform/Mono/MonoDebugger.d.ts +0 -3
- package/lib/internal/Platform/Mono/MonoDebugger.js +0 -48
- package/lib/internal/Platform/Mono/MonoDebugger.js.map +0 -1
- package/lib/internal/Platform/Mono/MonoPlatform.d.ts +0 -2
- package/lib/internal/Platform/Mono/MonoPlatform.js +0 -406
- package/lib/internal/Platform/Mono/MonoPlatform.js.map +0 -1
- package/lib/internal/Platform/Mono/TimezoneDataFile.d.ts +0 -1
- package/lib/internal/Platform/Mono/TimezoneDataFile.js +0 -55
- package/lib/internal/Platform/Mono/TimezoneDataFile.js.map +0 -1
- package/lib/internal/Platform/Platform.d.ts +0 -31
- package/lib/internal/Platform/Platform.js +0 -3
- package/lib/internal/Platform/Platform.js.map +0 -1
- package/lib/internal/Platform/Url.d.ts +0 -2
- package/lib/internal/Platform/Url.js +0 -16
- package/lib/internal/Platform/Url.js.map +0 -1
- package/lib/internal/Platform/WebAssemblyConfigLoader.d.ts +0 -4
- package/lib/internal/Platform/WebAssemblyConfigLoader.js +0 -67
- package/lib/internal/Platform/WebAssemblyConfigLoader.js.map +0 -1
- package/lib/internal/Platform/WebAssemblyResourceLoader.d.ts +0 -24
- package/lib/internal/Platform/WebAssemblyResourceLoader.js +0 -226
- package/lib/internal/Platform/WebAssemblyResourceLoader.js.map +0 -1
- package/lib/internal/Platform/WebAssemblyStartOptions.d.ts +0 -13
- package/lib/internal/Platform/WebAssemblyStartOptions.js +0 -3
- package/lib/internal/Platform/WebAssemblyStartOptions.js.map +0 -1
- package/lib/internal/Rendering/BrowserRenderer.d.ts +0 -38
- package/lib/internal/Rendering/BrowserRenderer.js +0 -461
- package/lib/internal/Rendering/BrowserRenderer.js.map +0 -1
- package/lib/internal/Rendering/ElementReferenceCapture.d.ts +0 -1
- package/lib/internal/Rendering/ElementReferenceCapture.js +0 -28
- package/lib/internal/Rendering/ElementReferenceCapture.js.map +0 -1
- package/lib/internal/Rendering/EventDelegator.d.ts +0 -20
- package/lib/internal/Rendering/EventDelegator.js +0 -239
- package/lib/internal/Rendering/EventDelegator.js.map +0 -1
- package/lib/internal/Rendering/EventFieldInfo.d.ts +0 -6
- package/lib/internal/Rendering/EventFieldInfo.js +0 -35
- package/lib/internal/Rendering/EventFieldInfo.js.map +0 -1
- package/lib/internal/Rendering/EventForDotNet.d.ts +0 -10
- package/lib/internal/Rendering/EventForDotNet.js +0 -197
- package/lib/internal/Rendering/EventForDotNet.js.map +0 -1
- package/lib/internal/Rendering/LogicalElements.d.ts +0 -19
- package/lib/internal/Rendering/LogicalElements.js +0 -265
- package/lib/internal/Rendering/LogicalElements.js.map +0 -1
- package/lib/internal/Rendering/RenderBatch/BinaryDecoder.d.ts +0 -5
- package/lib/internal/Rendering/RenderBatch/BinaryDecoder.js +0 -42
- package/lib/internal/Rendering/RenderBatch/BinaryDecoder.js.map +0 -1
- package/lib/internal/Rendering/RenderBatch/OutOfProcessRenderBatch.d.ts +0 -18
- package/lib/internal/Rendering/RenderBatch/OutOfProcessRenderBatch.js +0 -193
- package/lib/internal/Rendering/RenderBatch/OutOfProcessRenderBatch.js.map +0 -1
- package/lib/internal/Rendering/RenderBatch/RenderBatch.d.ts +0 -87
- package/lib/internal/Rendering/RenderBatch/RenderBatch.js +0 -29
- package/lib/internal/Rendering/RenderBatch/RenderBatch.js.map +0 -1
- package/lib/internal/Rendering/RenderBatch/SharedMemoryRenderBatch.d.ts +0 -52
- package/lib/internal/Rendering/RenderBatch/SharedMemoryRenderBatch.js +0 -106
- package/lib/internal/Rendering/RenderBatch/SharedMemoryRenderBatch.js.map +0 -1
- package/lib/internal/Rendering/RenderBatch/Utf8Decoder.d.ts +0 -1
- package/lib/internal/Rendering/RenderBatch/Utf8Decoder.js +0 -66
- package/lib/internal/Rendering/RenderBatch/Utf8Decoder.js.map +0 -1
- package/lib/internal/Rendering/Renderer.d.ts +0 -8
- package/lib/internal/Rendering/Renderer.js +0 -76
- package/lib/internal/Rendering/Renderer.js.map +0 -1
- package/lib/internal/Rendering/RendererEventDispatcher.d.ts +0 -4
- package/lib/internal/Rendering/RendererEventDispatcher.js +0 -16
- package/lib/internal/Rendering/RendererEventDispatcher.js.map +0 -1
- package/lib/internal/Services/NavigationManager.d.ts +0 -16
- package/lib/internal/Services/NavigationManager.js +0 -144
- package/lib/internal/Services/NavigationManager.js.map +0 -1
- package/lib/internal/globals.d.ts +0 -1
- package/lib/internal/globals.js +0 -7
- package/lib/internal/globals.js.map +0 -1
- package/lib/internal/index.d.ts +0 -15
- package/lib/internal/index.js +0 -161
- package/lib/internal/index.js.map +0 -1
- package/src/internal/Environment.ts +0 -11
- package/src/internal/Platform/BootConfig.ts +0 -21
- package/src/internal/Platform/Mono/MonoDebugger.ts +0 -48
- package/src/internal/Platform/Mono/MonoPlatform.ts +0 -494
- package/src/internal/Platform/Mono/MonoTypes.d.ts +0 -27
- package/src/internal/Platform/Mono/TimezoneDataFile.ts +0 -46
- package/src/internal/Platform/Platform.ts +0 -40
- package/src/internal/Platform/Url.ts +0 -11
- package/src/internal/Platform/WebAssemblyConfigLoader.ts +0 -34
- package/src/internal/Platform/WebAssemblyResourceLoader.ts +0 -234
- package/src/internal/Platform/WebAssemblyStartOptions.ts +0 -22
- package/src/internal/Rendering/BrowserRenderer.ts +0 -616
- package/src/internal/Rendering/ElementReferenceCapture.ts +0 -27
- package/src/internal/Rendering/EventDelegator.ts +0 -293
- package/src/internal/Rendering/EventFieldInfo.ts +0 -31
- package/src/internal/Rendering/EventForDotNet.ts +0 -370
- package/src/internal/Rendering/LogicalElements.ts +0 -289
- package/src/internal/Rendering/RenderBatch/BinaryDecoder.ts +0 -43
- package/src/internal/Rendering/RenderBatch/OutOfProcessRenderBatch.ts +0 -244
- package/src/internal/Rendering/RenderBatch/RenderBatch.ts +0 -100
- package/src/internal/Rendering/RenderBatch/SharedMemoryRenderBatch.ts +0 -137
- package/src/internal/Rendering/RenderBatch/Utf8Decoder.ts +0 -66
- package/src/internal/Rendering/Renderer.ts +0 -98
- package/src/internal/Rendering/RendererEventDispatcher.ts +0 -20
- package/src/internal/Services/NavigationManager.ts +0 -157
- package/src/internal/globals.ts +0 -5
- package/src/internal/index.ts +0 -170
|
@@ -1,289 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
A LogicalElement plays the same role as an Element instance from the point of view of the
|
|
3
|
-
API consumer. Inserting and removing logical elements updates the browser DOM just the same.
|
|
4
|
-
|
|
5
|
-
The difference is that, unlike regular DOM mutation APIs, the LogicalElement APIs don't use
|
|
6
|
-
the underlying DOM structure as the data storage for the element hierarchy. Instead, the
|
|
7
|
-
LogicalElement APIs take care of tracking hierarchical relationships separately. The point
|
|
8
|
-
of this is to permit a logical tree structure in which parent/child relationships don't
|
|
9
|
-
have to be materialized in terms of DOM element parent/child relationships. And the reason
|
|
10
|
-
why we want that is so that hierarchies of Blazor components can be tracked even when those
|
|
11
|
-
components' render output need not be a single literal DOM element.
|
|
12
|
-
|
|
13
|
-
Consumers of the API don't need to know about the implementation, but how it's done is:
|
|
14
|
-
- Each LogicalElement is materialized in the DOM as either:
|
|
15
|
-
- A Node instance, for actual Node instances inserted using 'insertLogicalChild' or
|
|
16
|
-
for Element instances promoted to LogicalElement via 'toLogicalElement'
|
|
17
|
-
- A Comment instance, for 'logical container' instances inserted using 'createAndInsertLogicalContainer'
|
|
18
|
-
- Then, on that instance (i.e., the Node or Comment), we store an array of 'logical children'
|
|
19
|
-
instances, e.g.,
|
|
20
|
-
[firstChild, secondChild, thirdChild, ...]
|
|
21
|
-
... plus we store a reference to the 'logical parent' (if any)
|
|
22
|
-
- The 'logical children' array means we can look up in O(1):
|
|
23
|
-
- The number of logical children (not currently implemented because not required, but trivial)
|
|
24
|
-
- The logical child at any given index
|
|
25
|
-
- Whenever a logical child is added or removed, we update the parent's array of logical children
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
const logicalChildrenPropname = createSymbolOrFallback('_blazorLogicalChildren');
|
|
29
|
-
const logicalParentPropname = createSymbolOrFallback('_blazorLogicalParent');
|
|
30
|
-
const logicalEndSiblingPropname = createSymbolOrFallback('_blazorLogicalEnd');
|
|
31
|
-
|
|
32
|
-
export function toLogicalRootCommentElement(start: Comment, end: Comment): LogicalElement {
|
|
33
|
-
// Now that we support start/end comments as component delimiters we are going to be setting up
|
|
34
|
-
// adding the components rendered output as siblings of the start/end tags (between).
|
|
35
|
-
// For that to work, we need to appropriately configure the parent element to be a logical element
|
|
36
|
-
// with all their children being the child elements.
|
|
37
|
-
// For example, imagine you have
|
|
38
|
-
// <app>
|
|
39
|
-
// <div><p>Static content</p></div>
|
|
40
|
-
// <!-- start component
|
|
41
|
-
// <!-- end component
|
|
42
|
-
// <footer>Some other content</footer>
|
|
43
|
-
// <app>
|
|
44
|
-
// We want the parent element to be something like
|
|
45
|
-
// *app
|
|
46
|
-
// |- *div
|
|
47
|
-
// |- *component
|
|
48
|
-
// |- *footer
|
|
49
|
-
if (!start.parentNode) {
|
|
50
|
-
throw new Error(`Comment not connected to the DOM ${start.textContent}`);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const parent = start.parentNode;
|
|
54
|
-
const parentLogicalElement = toLogicalElement(parent, /* allow existing contents */ true);
|
|
55
|
-
const children = getLogicalChildrenArray(parentLogicalElement);
|
|
56
|
-
Array.from(parent.childNodes).forEach((n) => children.push((n as unknown) as LogicalElement));
|
|
57
|
-
start[logicalParentPropname] = parentLogicalElement;
|
|
58
|
-
// We might not have an end comment in the case of non-prerendered components.
|
|
59
|
-
if (end) {
|
|
60
|
-
start[logicalEndSiblingPropname] = end;
|
|
61
|
-
toLogicalElement(end, /* allowExistingcontents */ true);
|
|
62
|
-
}
|
|
63
|
-
return toLogicalElement(start, /* allowExistingContents */ true);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export function toLogicalElement(element: Node, allowExistingContents?: boolean): LogicalElement {
|
|
67
|
-
// Normally it's good to assert that the element has started empty, because that's the usual
|
|
68
|
-
// situation and we probably have a bug if it's not. But for the element that contain prerendered
|
|
69
|
-
// root components, we want to let them keep their content until we replace it.
|
|
70
|
-
if (element.childNodes.length > 0 && !allowExistingContents) {
|
|
71
|
-
throw new Error('New logical elements must start empty, or allowExistingContents must be true');
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
element[logicalChildrenPropname] = [];
|
|
75
|
-
return (element as unknown) as LogicalElement;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export function createAndInsertLogicalContainer(parent: LogicalElement, childIndex: number): LogicalElement {
|
|
79
|
-
const containerElement = document.createComment('!');
|
|
80
|
-
insertLogicalChild(containerElement, parent, childIndex);
|
|
81
|
-
return (containerElement as any) as LogicalElement;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export function insertLogicalChild(child: Node, parent: LogicalElement, childIndex: number) {
|
|
85
|
-
const childAsLogicalElement = (child as any) as LogicalElement;
|
|
86
|
-
if (child instanceof Comment) {
|
|
87
|
-
const existingGrandchildren = getLogicalChildrenArray(childAsLogicalElement);
|
|
88
|
-
if (existingGrandchildren && getLogicalChildrenArray(childAsLogicalElement).length > 0) {
|
|
89
|
-
// There's nothing to stop us implementing support for this scenario, and it's not difficult
|
|
90
|
-
// (after inserting 'child' itself, also iterate through its logical children and physically
|
|
91
|
-
// put them as following-siblings in the DOM). However there's no scenario that requires it
|
|
92
|
-
// presently, so if we did implement it there'd be no good way to have tests for it.
|
|
93
|
-
throw new Error('Not implemented: inserting non-empty logical container');
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
if (getLogicalParent(childAsLogicalElement)) {
|
|
98
|
-
// Likewise, we could easily support this scenario too (in this 'if' block, just splice
|
|
99
|
-
// out 'child' from the logical children array of its previous logical parent by using
|
|
100
|
-
// Array.prototype.indexOf to determine its previous sibling index).
|
|
101
|
-
// But again, since there's not currently any scenario that would use it, we would not
|
|
102
|
-
// have any test coverage for such an implementation.
|
|
103
|
-
throw new Error('Not implemented: moving existing logical children');
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
const newSiblings = getLogicalChildrenArray(parent);
|
|
107
|
-
if (childIndex < newSiblings.length) {
|
|
108
|
-
// Insert
|
|
109
|
-
const nextSibling = (newSiblings[childIndex] as any) as Node;
|
|
110
|
-
nextSibling.parentNode!.insertBefore(child, nextSibling);
|
|
111
|
-
newSiblings.splice(childIndex, 0, childAsLogicalElement);
|
|
112
|
-
} else {
|
|
113
|
-
// Append
|
|
114
|
-
appendDomNode(child, parent);
|
|
115
|
-
newSiblings.push(childAsLogicalElement);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
childAsLogicalElement[logicalParentPropname] = parent;
|
|
119
|
-
if (!(logicalChildrenPropname in childAsLogicalElement)) {
|
|
120
|
-
childAsLogicalElement[logicalChildrenPropname] = [];
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
export function removeLogicalChild(parent: LogicalElement, childIndex: number) {
|
|
125
|
-
const childrenArray = getLogicalChildrenArray(parent);
|
|
126
|
-
const childToRemove = childrenArray.splice(childIndex, 1)[0];
|
|
127
|
-
|
|
128
|
-
// If it's a logical container, also remove its descendants
|
|
129
|
-
if (childToRemove instanceof Comment) {
|
|
130
|
-
const grandchildrenArray = getLogicalChildrenArray(childToRemove);
|
|
131
|
-
while (grandchildrenArray.length > 0) {
|
|
132
|
-
removeLogicalChild(childToRemove, 0);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// Finally, remove the node itself
|
|
137
|
-
const domNodeToRemove = (childToRemove as any) as Node;
|
|
138
|
-
domNodeToRemove.parentNode!.removeChild(domNodeToRemove);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
export function getLogicalParent(element: LogicalElement): LogicalElement | null {
|
|
142
|
-
return (element[logicalParentPropname] as LogicalElement) || null;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
export function getLogicalSiblingEnd(element: LogicalElement): LogicalElement | null {
|
|
146
|
-
return (element[logicalEndSiblingPropname] as LogicalElement) || null;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
export function getLogicalChild(parent: LogicalElement, childIndex: number): LogicalElement {
|
|
150
|
-
return getLogicalChildrenArray(parent)[childIndex];
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
export function isSvgElement(element: LogicalElement) {
|
|
154
|
-
return getClosestDomElement(element).namespaceURI === 'http://www.w3.org/2000/svg';
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
export function getLogicalChildrenArray(element: LogicalElement) {
|
|
158
|
-
return element[logicalChildrenPropname] as LogicalElement[];
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
export function permuteLogicalChildren(parent: LogicalElement, permutationList: PermutationListEntry[]) {
|
|
162
|
-
// The permutationList must represent a valid permutation, i.e., the list of 'from' indices
|
|
163
|
-
// is distinct, and the list of 'to' indices is a permutation of it. The algorithm here
|
|
164
|
-
// relies on that assumption.
|
|
165
|
-
|
|
166
|
-
// Each of the phases here has to happen separately, because each one is designed not to
|
|
167
|
-
// interfere with the indices or DOM entries used by subsequent phases.
|
|
168
|
-
|
|
169
|
-
// Phase 1: track which nodes we will move
|
|
170
|
-
const siblings = getLogicalChildrenArray(parent);
|
|
171
|
-
permutationList.forEach((listEntry: PermutationListEntryWithTrackingData) => {
|
|
172
|
-
listEntry.moveRangeStart = siblings[listEntry.fromSiblingIndex];
|
|
173
|
-
listEntry.moveRangeEnd = findLastDomNodeInRange(listEntry.moveRangeStart);
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
// Phase 2: insert markers
|
|
177
|
-
permutationList.forEach((listEntry: PermutationListEntryWithTrackingData) => {
|
|
178
|
-
const marker = (listEntry.moveToBeforeMarker = document.createComment('marker'));
|
|
179
|
-
const insertBeforeNode = (siblings[listEntry.toSiblingIndex + 1] as any) as Node;
|
|
180
|
-
if (insertBeforeNode) {
|
|
181
|
-
insertBeforeNode.parentNode!.insertBefore(marker, insertBeforeNode);
|
|
182
|
-
} else {
|
|
183
|
-
appendDomNode(marker, parent);
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
// Phase 3: move descendants & remove markers
|
|
188
|
-
permutationList.forEach((listEntry: PermutationListEntryWithTrackingData) => {
|
|
189
|
-
const insertBefore = listEntry.moveToBeforeMarker!;
|
|
190
|
-
const parentDomNode = insertBefore.parentNode!;
|
|
191
|
-
const elementToMove = listEntry.moveRangeStart!;
|
|
192
|
-
const moveEndNode = listEntry.moveRangeEnd!;
|
|
193
|
-
let nextToMove = (elementToMove as any) as Node | null;
|
|
194
|
-
while (nextToMove) {
|
|
195
|
-
const nextNext = nextToMove.nextSibling;
|
|
196
|
-
parentDomNode.insertBefore(nextToMove, insertBefore);
|
|
197
|
-
|
|
198
|
-
if (nextToMove === moveEndNode) {
|
|
199
|
-
break;
|
|
200
|
-
} else {
|
|
201
|
-
nextToMove = nextNext;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
parentDomNode.removeChild(insertBefore);
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
// Phase 4: update siblings index
|
|
209
|
-
permutationList.forEach((listEntry: PermutationListEntryWithTrackingData) => {
|
|
210
|
-
siblings[listEntry.toSiblingIndex] = listEntry.moveRangeStart!;
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
export function getClosestDomElement(logicalElement: LogicalElement) {
|
|
215
|
-
if (logicalElement instanceof Element) {
|
|
216
|
-
return logicalElement;
|
|
217
|
-
} else if (logicalElement instanceof Comment) {
|
|
218
|
-
return logicalElement.parentNode! as Element;
|
|
219
|
-
} else {
|
|
220
|
-
throw new Error('Not a valid logical element');
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
export interface PermutationListEntry {
|
|
225
|
-
fromSiblingIndex: number;
|
|
226
|
-
toSiblingIndex: number;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
interface PermutationListEntryWithTrackingData extends PermutationListEntry {
|
|
230
|
-
// These extra properties are used internally when processing the permutation list
|
|
231
|
-
moveRangeStart?: LogicalElement;
|
|
232
|
-
moveRangeEnd?: Node;
|
|
233
|
-
moveToBeforeMarker?: Node;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
function getLogicalNextSibling(element: LogicalElement): LogicalElement | null {
|
|
237
|
-
const siblings = getLogicalChildrenArray(getLogicalParent(element)!);
|
|
238
|
-
const siblingIndex = Array.prototype.indexOf.call(siblings, element);
|
|
239
|
-
return siblings[siblingIndex + 1] || null;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
function appendDomNode(child: Node, parent: LogicalElement) {
|
|
243
|
-
// This function only puts 'child' into the DOM in the right place relative to 'parent'
|
|
244
|
-
// It does not update the logical children array of anything
|
|
245
|
-
if (parent instanceof Element) {
|
|
246
|
-
parent.appendChild(child);
|
|
247
|
-
} else if (parent instanceof Comment) {
|
|
248
|
-
const parentLogicalNextSibling = (getLogicalNextSibling(parent) as any) as Node;
|
|
249
|
-
if (parentLogicalNextSibling) {
|
|
250
|
-
// Since the parent has a logical next-sibling, its appended child goes right before that
|
|
251
|
-
parentLogicalNextSibling.parentNode!.insertBefore(child, parentLogicalNextSibling);
|
|
252
|
-
} else {
|
|
253
|
-
// Since the parent has no logical next-sibling, keep recursing upwards until we find
|
|
254
|
-
// a logical ancestor that does have a next-sibling or is a physical element.
|
|
255
|
-
appendDomNode(child, getLogicalParent(parent)!);
|
|
256
|
-
}
|
|
257
|
-
} else {
|
|
258
|
-
// Should never happen
|
|
259
|
-
throw new Error(`Cannot append node because the parent is not a valid logical element. Parent: ${parent}`);
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
// Returns the final node (in depth-first evaluation order) that is a descendant of the logical element.
|
|
264
|
-
// As such, the entire subtree is between 'element' and 'findLastDomNodeInRange(element)' inclusive.
|
|
265
|
-
function findLastDomNodeInRange(element: LogicalElement) {
|
|
266
|
-
if (element instanceof Element) {
|
|
267
|
-
return element;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
const nextSibling = getLogicalNextSibling(element);
|
|
271
|
-
if (nextSibling) {
|
|
272
|
-
// Simple case: not the last logical sibling, so take the node before the next sibling
|
|
273
|
-
return ((nextSibling as any) as Node).previousSibling;
|
|
274
|
-
} else {
|
|
275
|
-
// Harder case: there's no logical next-sibling, so recurse upwards until we find
|
|
276
|
-
// a logical ancestor that does have one, or a physical element
|
|
277
|
-
const logicalParent = getLogicalParent(element)!;
|
|
278
|
-
return logicalParent instanceof Element ? logicalParent.lastChild : findLastDomNodeInRange(logicalParent);
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
function createSymbolOrFallback(fallback: string): symbol | string {
|
|
283
|
-
return typeof Symbol === 'function' ? Symbol() : fallback;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
// Nominal type to represent a logical element without needing to allocate any object for instances
|
|
287
|
-
export interface LogicalElement {
|
|
288
|
-
LogicalElement__DO_NOT_IMPLEMENT: any;
|
|
289
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
const uint64HighPartShift = Math.pow(2, 32);
|
|
2
|
-
const maxSafeNumberHighPart = Math.pow(2, 21) - 1; // The high-order int32 from Number.MAX_SAFE_INTEGER
|
|
3
|
-
|
|
4
|
-
export function readInt32LE(buffer: Uint8Array, position: number): any {
|
|
5
|
-
return buffer[position] | (buffer[position + 1] << 8) | (buffer[position + 2] << 16) | (buffer[position + 3] << 24);
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export function readUint32LE(buffer: Uint8Array, position: number): any {
|
|
9
|
-
return (
|
|
10
|
-
buffer[position] + (buffer[position + 1] << 8) + (buffer[position + 2] << 16) + ((buffer[position + 3] << 24) >>> 0)
|
|
11
|
-
); // The >>> 0 coerces the value to unsigned
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function readUint64LE(buffer: Uint8Array, position: number): any {
|
|
15
|
-
// This cannot be done using bit-shift operators in JavaScript, because
|
|
16
|
-
// those all implicitly convert to int32
|
|
17
|
-
const highPart = readUint32LE(buffer, position + 4);
|
|
18
|
-
if (highPart > maxSafeNumberHighPart) {
|
|
19
|
-
throw new Error(
|
|
20
|
-
`Cannot read uint64 with high order part ${highPart}, because the result would exceed Number.MAX_SAFE_INTEGER.`,
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return highPart * uint64HighPartShift + readUint32LE(buffer, position);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export function readLEB128(buffer: Uint8Array, position: number) {
|
|
28
|
-
let result = 0;
|
|
29
|
-
let shift = 0;
|
|
30
|
-
for (let index = 0; index < 4; index++) {
|
|
31
|
-
const byte = buffer[position + index];
|
|
32
|
-
result |= (byte & 127) << shift;
|
|
33
|
-
if (byte < 128) {
|
|
34
|
-
break;
|
|
35
|
-
}
|
|
36
|
-
shift += 7;
|
|
37
|
-
}
|
|
38
|
-
return result;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export function numLEB128Bytes(value: number) {
|
|
42
|
-
return value < 128 ? 1 : value < 16384 ? 2 : value < 2097152 ? 3 : 4;
|
|
43
|
-
}
|
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
RenderBatch,
|
|
3
|
-
ArrayRange,
|
|
4
|
-
RenderTreeDiff,
|
|
5
|
-
ArrayValues,
|
|
6
|
-
RenderTreeEdit,
|
|
7
|
-
EditType,
|
|
8
|
-
FrameType,
|
|
9
|
-
RenderTreeFrame,
|
|
10
|
-
RenderTreeDiffReader,
|
|
11
|
-
RenderTreeFrameReader,
|
|
12
|
-
RenderTreeEditReader,
|
|
13
|
-
ArrayRangeReader,
|
|
14
|
-
ArrayBuilderSegmentReader,
|
|
15
|
-
ArrayBuilderSegment,
|
|
16
|
-
} from './RenderBatch';
|
|
17
|
-
import { decodeUtf8 } from './Utf8Decoder';
|
|
18
|
-
import { readInt32LE, readUint64LE, readLEB128, numLEB128Bytes } from './BinaryDecoder';
|
|
19
|
-
|
|
20
|
-
const updatedComponentsEntryLength = 4; // Each is a single int32 giving the location of the data
|
|
21
|
-
const referenceFramesEntryLength = 20; // 1 int for frame type, then 16 bytes for type-specific data
|
|
22
|
-
const disposedComponentIdsEntryLength = 4; // Each is an int32 giving the ID
|
|
23
|
-
const disposedEventHandlerIdsEntryLength = 8; // Each is an int64 giving the ID
|
|
24
|
-
const editsEntryLength = 16; // 4 ints
|
|
25
|
-
const stringTableEntryLength = 4; // Each is an int32 giving the string data location, or -1 for null
|
|
26
|
-
|
|
27
|
-
export class OutOfProcessRenderBatch implements RenderBatch {
|
|
28
|
-
constructor(private batchData: Uint8Array) {
|
|
29
|
-
const stringReader = new OutOfProcessStringReader(batchData);
|
|
30
|
-
|
|
31
|
-
this.arrayRangeReader = new OutOfProcessArrayRangeReader(batchData);
|
|
32
|
-
this.arrayBuilderSegmentReader = new OutOfProcessArrayBuilderSegmentReader(batchData);
|
|
33
|
-
this.diffReader = new OutOfProcessRenderTreeDiffReader(batchData);
|
|
34
|
-
this.editReader = new OutOfProcessRenderTreeEditReader(batchData, stringReader);
|
|
35
|
-
this.frameReader = new OutOfProcessRenderTreeFrameReader(batchData, stringReader);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
updatedComponents(): ArrayRange<RenderTreeDiff> {
|
|
39
|
-
return readInt32LE(this.batchData, this.batchData.length - 20); // 5th-from-last int32
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
referenceFrames(): ArrayRange<RenderTreeFrame> {
|
|
43
|
-
return readInt32LE(this.batchData, this.batchData.length - 16); // 4th-from-last int32
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
disposedComponentIds(): ArrayRange<number> {
|
|
47
|
-
return readInt32LE(this.batchData, this.batchData.length - 12); // 3rd-from-last int32
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
disposedEventHandlerIds(): ArrayRange<number> {
|
|
51
|
-
return readInt32LE(this.batchData, this.batchData.length - 8); // 2th-from-last int32
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
updatedComponentsEntry(values: ArrayValues<RenderTreeDiff>, index: number): RenderTreeDiff {
|
|
55
|
-
const tableEntryPos = (values as any) + index * updatedComponentsEntryLength;
|
|
56
|
-
return readInt32LE(this.batchData, tableEntryPos);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
referenceFramesEntry(values: ArrayValues<RenderTreeFrame>, index: number): RenderTreeFrame {
|
|
60
|
-
return ((values as any) + index * referenceFramesEntryLength) as any;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
disposedComponentIdsEntry(values: ArrayValues<number>, index: number): number {
|
|
64
|
-
const entryPos = (values as any) + index * disposedComponentIdsEntryLength;
|
|
65
|
-
return readInt32LE(this.batchData, entryPos);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
disposedEventHandlerIdsEntry(values: ArrayValues<number>, index: number): number {
|
|
69
|
-
const entryPos = (values as any) + index * disposedEventHandlerIdsEntryLength;
|
|
70
|
-
return readUint64LE(this.batchData, entryPos);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
diffReader: RenderTreeDiffReader;
|
|
74
|
-
|
|
75
|
-
editReader: RenderTreeEditReader;
|
|
76
|
-
|
|
77
|
-
frameReader: RenderTreeFrameReader;
|
|
78
|
-
|
|
79
|
-
arrayRangeReader: ArrayRangeReader;
|
|
80
|
-
|
|
81
|
-
arrayBuilderSegmentReader: ArrayBuilderSegmentReader;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
class OutOfProcessRenderTreeDiffReader implements RenderTreeDiffReader {
|
|
85
|
-
constructor(private batchDataUint8: Uint8Array) {}
|
|
86
|
-
|
|
87
|
-
componentId(diff: RenderTreeDiff) {
|
|
88
|
-
// First int32 is componentId
|
|
89
|
-
return readInt32LE(this.batchDataUint8, diff as any);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
edits(diff: RenderTreeDiff) {
|
|
93
|
-
// Entries data starts after the componentId (which is a 4-byte int)
|
|
94
|
-
return (diff as any) + 4;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
editsEntry(values: ArrayValues<RenderTreeEdit>, index: number) {
|
|
98
|
-
return (values as any) + index * editsEntryLength;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
class OutOfProcessRenderTreeEditReader implements RenderTreeEditReader {
|
|
103
|
-
constructor(private batchDataUint8: Uint8Array, private stringReader: OutOfProcessStringReader) {}
|
|
104
|
-
|
|
105
|
-
editType(edit: RenderTreeEdit) {
|
|
106
|
-
return readInt32LE(this.batchDataUint8, edit as any); // 1st int
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
siblingIndex(edit: RenderTreeEdit) {
|
|
110
|
-
return readInt32LE(this.batchDataUint8, (edit as any) + 4); // 2nd int
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
newTreeIndex(edit: RenderTreeEdit) {
|
|
114
|
-
return readInt32LE(this.batchDataUint8, (edit as any) + 8); // 3rd int
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
moveToSiblingIndex(edit: RenderTreeEdit) {
|
|
118
|
-
return readInt32LE(this.batchDataUint8, (edit as any) + 8); // 3rd int
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
removedAttributeName(edit: RenderTreeEdit) {
|
|
122
|
-
const stringIndex = readInt32LE(this.batchDataUint8, (edit as any) + 12); // 4th int
|
|
123
|
-
return this.stringReader.readString(stringIndex);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
class OutOfProcessRenderTreeFrameReader implements RenderTreeFrameReader {
|
|
128
|
-
constructor(private batchDataUint8: Uint8Array, private stringReader: OutOfProcessStringReader) {}
|
|
129
|
-
|
|
130
|
-
// For render frames, the 2nd-4th ints have different meanings depending on frameType.
|
|
131
|
-
// It's the caller's responsibility not to evaluate properties that aren't applicable to the frameType.
|
|
132
|
-
|
|
133
|
-
frameType(frame: RenderTreeFrame) {
|
|
134
|
-
return readInt32LE(this.batchDataUint8, frame as any); // 1st int
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
subtreeLength(frame: RenderTreeFrame) {
|
|
138
|
-
return readInt32LE(this.batchDataUint8, (frame as any) + 4); // 2nd int
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
elementReferenceCaptureId(frame: RenderTreeFrame) {
|
|
142
|
-
const stringIndex = readInt32LE(this.batchDataUint8, (frame as any) + 4); // 2nd int
|
|
143
|
-
return this.stringReader.readString(stringIndex);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
componentId(frame: RenderTreeFrame) {
|
|
147
|
-
return readInt32LE(this.batchDataUint8, (frame as any) + 8); // 3rd int
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
elementName(frame: RenderTreeFrame) {
|
|
151
|
-
const stringIndex = readInt32LE(this.batchDataUint8, (frame as any) + 8); // 3rd int
|
|
152
|
-
return this.stringReader.readString(stringIndex);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
textContent(frame: RenderTreeFrame) {
|
|
156
|
-
const stringIndex = readInt32LE(this.batchDataUint8, (frame as any) + 4); // 2nd int
|
|
157
|
-
return this.stringReader.readString(stringIndex);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
markupContent(frame: RenderTreeFrame) {
|
|
161
|
-
const stringIndex = readInt32LE(this.batchDataUint8, (frame as any) + 4); // 2nd int
|
|
162
|
-
return this.stringReader.readString(stringIndex)!;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
attributeName(frame: RenderTreeFrame) {
|
|
166
|
-
const stringIndex = readInt32LE(this.batchDataUint8, (frame as any) + 4); // 2nd int
|
|
167
|
-
return this.stringReader.readString(stringIndex);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
attributeValue(frame: RenderTreeFrame) {
|
|
171
|
-
const stringIndex = readInt32LE(this.batchDataUint8, (frame as any) + 8); // 3rd int
|
|
172
|
-
return this.stringReader.readString(stringIndex);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
attributeEventHandlerId(frame: RenderTreeFrame) {
|
|
176
|
-
return readUint64LE(this.batchDataUint8, (frame as any) + 12); // Bytes 12-19
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
class OutOfProcessStringReader {
|
|
181
|
-
private stringTableStartIndex: number;
|
|
182
|
-
|
|
183
|
-
constructor(private batchDataUint8: Uint8Array) {
|
|
184
|
-
// Final int gives start position of the string table
|
|
185
|
-
this.stringTableStartIndex = readInt32LE(batchDataUint8, batchDataUint8.length - 4);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
readString(index: number): string | null {
|
|
189
|
-
if (index === -1) {
|
|
190
|
-
// Special value encodes 'null'
|
|
191
|
-
return null;
|
|
192
|
-
} else {
|
|
193
|
-
const stringTableEntryPos = readInt32LE(
|
|
194
|
-
this.batchDataUint8,
|
|
195
|
-
this.stringTableStartIndex + index * stringTableEntryLength,
|
|
196
|
-
);
|
|
197
|
-
|
|
198
|
-
// By default, .NET's BinaryWriter gives LEB128-length-prefixed UTF-8 data.
|
|
199
|
-
// This is convenient enough to decode in JavaScript.
|
|
200
|
-
const numUtf8Bytes = readLEB128(this.batchDataUint8, stringTableEntryPos);
|
|
201
|
-
const charsStart = stringTableEntryPos + numLEB128Bytes(numUtf8Bytes);
|
|
202
|
-
const utf8Data = new Uint8Array(
|
|
203
|
-
this.batchDataUint8.buffer,
|
|
204
|
-
this.batchDataUint8.byteOffset + charsStart,
|
|
205
|
-
numUtf8Bytes,
|
|
206
|
-
);
|
|
207
|
-
return decodeUtf8(utf8Data);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
class OutOfProcessArrayRangeReader implements ArrayRangeReader {
|
|
213
|
-
constructor(private batchDataUint8: Uint8Array) {}
|
|
214
|
-
|
|
215
|
-
count<T>(arrayRange: ArrayRange<T>) {
|
|
216
|
-
// First int is count
|
|
217
|
-
return readInt32LE(this.batchDataUint8, arrayRange as any);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
values<T>(arrayRange: ArrayRange<T>) {
|
|
221
|
-
// Entries data starts after the 'count' int (i.e., after 4 bytes)
|
|
222
|
-
return (arrayRange as any) + 4;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
class OutOfProcessArrayBuilderSegmentReader implements ArrayBuilderSegmentReader {
|
|
227
|
-
constructor(private batchDataUint8: Uint8Array) {}
|
|
228
|
-
|
|
229
|
-
offset<T>(arrayBuilderSegment: ArrayBuilderSegment<T>) {
|
|
230
|
-
// Not used by the out-of-process representation of RenderBatch data.
|
|
231
|
-
// This only exists on the ArrayBuilderSegmentReader for the shared-memory representation.
|
|
232
|
-
return 0;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
count<T>(arrayBuilderSegment: ArrayBuilderSegment<T>) {
|
|
236
|
-
// First int is count
|
|
237
|
-
return readInt32LE(this.batchDataUint8, arrayBuilderSegment as any);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
values<T>(arrayBuilderSegment: ArrayBuilderSegment<T>): ArrayValues<T> {
|
|
241
|
-
// Entries data starts after the 'count' int (i.e., after 4 bytes)
|
|
242
|
-
return (arrayBuilderSegment as any) + 4;
|
|
243
|
-
}
|
|
244
|
-
}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
export interface RenderBatch {
|
|
2
|
-
updatedComponents(): ArrayRange<RenderTreeDiff>;
|
|
3
|
-
referenceFrames(): ArrayRange<RenderTreeFrame>;
|
|
4
|
-
disposedComponentIds(): ArrayRange<number>;
|
|
5
|
-
disposedEventHandlerIds(): ArrayRange<number>;
|
|
6
|
-
|
|
7
|
-
updatedComponentsEntry(values: ArrayValues<RenderTreeDiff>, index: number): RenderTreeDiff;
|
|
8
|
-
referenceFramesEntry(values: ArrayValues<RenderTreeFrame>, index: number): RenderTreeFrame;
|
|
9
|
-
disposedComponentIdsEntry(values: ArrayValues<number>, index: number): number;
|
|
10
|
-
disposedEventHandlerIdsEntry(values: ArrayValues<number>, index: number): number;
|
|
11
|
-
|
|
12
|
-
diffReader: RenderTreeDiffReader;
|
|
13
|
-
editReader: RenderTreeEditReader;
|
|
14
|
-
frameReader: RenderTreeFrameReader;
|
|
15
|
-
arrayRangeReader: ArrayRangeReader;
|
|
16
|
-
arrayBuilderSegmentReader: ArrayBuilderSegmentReader;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface ArrayRangeReader {
|
|
20
|
-
count<T>(arrayRange: ArrayRange<T>): number;
|
|
21
|
-
values<T>(arrayRange: ArrayRange<T>): ArrayValues<T>;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface ArrayBuilderSegmentReader {
|
|
25
|
-
offset<T>(arrayBuilderSegment: ArrayBuilderSegment<T>): number;
|
|
26
|
-
count<T>(arrayBuilderSegment: ArrayBuilderSegment<T>): number;
|
|
27
|
-
values<T>(arrayBuilderSegment: ArrayBuilderSegment<T>): ArrayValues<T>;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface RenderTreeDiffReader {
|
|
31
|
-
componentId(diff: RenderTreeDiff): number;
|
|
32
|
-
edits(diff: RenderTreeDiff): ArrayBuilderSegment<RenderTreeEdit>;
|
|
33
|
-
editsEntry(values: ArrayValues<RenderTreeEdit>, index: number): RenderTreeEdit;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export interface RenderTreeEditReader {
|
|
37
|
-
editType(edit: RenderTreeEdit): EditType;
|
|
38
|
-
siblingIndex(edit: RenderTreeEdit): number;
|
|
39
|
-
newTreeIndex(edit: RenderTreeEdit): number;
|
|
40
|
-
moveToSiblingIndex(edit: RenderTreeEdit): number;
|
|
41
|
-
removedAttributeName(edit: RenderTreeEdit): string | null;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export interface RenderTreeFrameReader {
|
|
45
|
-
frameType(frame: RenderTreeFrame): FrameType;
|
|
46
|
-
subtreeLength(frame: RenderTreeFrame): number;
|
|
47
|
-
elementReferenceCaptureId(frame: RenderTreeFrame): string | null;
|
|
48
|
-
componentId(frame: RenderTreeFrame): number;
|
|
49
|
-
elementName(frame: RenderTreeFrame): string | null;
|
|
50
|
-
textContent(frame: RenderTreeFrame): string | null;
|
|
51
|
-
markupContent(frame: RenderTreeFrame): string;
|
|
52
|
-
attributeName(frame: RenderTreeFrame): string | null;
|
|
53
|
-
attributeValue(frame: RenderTreeFrame): string | null;
|
|
54
|
-
attributeEventHandlerId(frame: RenderTreeFrame): number;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export interface ArrayRange<T> {
|
|
58
|
-
ArrayRange__DO_NOT_IMPLEMENT: any;
|
|
59
|
-
}
|
|
60
|
-
export interface ArrayBuilderSegment<T> {
|
|
61
|
-
ArrayBuilderSegment__DO_NOT_IMPLEMENT: any;
|
|
62
|
-
}
|
|
63
|
-
export interface ArrayValues<T> {
|
|
64
|
-
ArrayValues__DO_NOT_IMPLEMENT: any;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export interface RenderTreeDiff {
|
|
68
|
-
RenderTreeDiff__DO_NOT_IMPLEMENT: any;
|
|
69
|
-
}
|
|
70
|
-
export interface RenderTreeFrame {
|
|
71
|
-
RenderTreeFrame__DO_NOT_IMPLEMENT: any;
|
|
72
|
-
}
|
|
73
|
-
export interface RenderTreeEdit {
|
|
74
|
-
RenderTreeEdit__DO_NOT_IMPLEMENT: any;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export enum EditType {
|
|
78
|
-
// The values must be kept in sync with the .NET equivalent in RenderTreeEditType.cs
|
|
79
|
-
prependFrame = 1,
|
|
80
|
-
removeFrame = 2,
|
|
81
|
-
setAttribute = 3,
|
|
82
|
-
removeAttribute = 4,
|
|
83
|
-
updateText = 5,
|
|
84
|
-
stepIn = 6,
|
|
85
|
-
stepOut = 7,
|
|
86
|
-
updateMarkup = 8,
|
|
87
|
-
permutationListEntry = 9,
|
|
88
|
-
permutationListEnd = 10,
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export enum FrameType {
|
|
92
|
-
// The values must be kept in sync with the .NET equivalent in RenderTreeFrameType.cs
|
|
93
|
-
element = 1,
|
|
94
|
-
text = 2,
|
|
95
|
-
attribute = 3,
|
|
96
|
-
component = 4,
|
|
97
|
-
region = 5,
|
|
98
|
-
elementReferenceCapture = 6,
|
|
99
|
-
markup = 8,
|
|
100
|
-
}
|