-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReadme.md.js
147 lines (129 loc) · 3.52 KB
/
Readme.md.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
// @flow
import * as Dictionary from "dictionary.flow"
import type { Dict } from "dictionary.flow"
import * as DOMinion from "dominion"
import JSON from "./src/Format/JSON"
import FlatBuffer from "./src/Format/FlatBuffer"
import Log from "./src/Patch/Log"
DOMinion //?
const tree0 = DOMinion.createHost()
const tree1 = DOMinion.createHost(
[],
[
DOMinion.createElement(
"div",
[
DOMinion.setAttribute("id", "main"),
DOMinion.property("autofocus", true),
DOMinion.style({
backgroundColor: "red",
color: "white"
})
],
[
DOMinion.createTextNode("hi there"),
DOMinion.createComment("this is some comment"),
DOMinion.createElementNS("http://www.w3.org/2000/svg", "circle", [
DOMinion.setAttribute("cx", "40"),
DOMinion.setAttribute("cy", "50"),
DOMinion.setAttribute("r", "26")
])
]
)
]
) //?$.toDebugString()
const tree2 = DOMinion.createHost(
[],
[
DOMinion.createElement(
"div",
[
DOMinion.setAttribute("id", "main"),
DOMinion.property("autofocus", true),
DOMinion.style({
backgroundColor: "blue",
color: "white"
})
],
[
DOMinion.createTextNode("hi there"),
DOMinion.createComment("this is"),
DOMinion.createElementNS("http://www.w3.org/2000/svg", "circle", [
DOMinion.setAttribute("cx", "40"),
DOMinion.setAttribute("cy", "50"),
DOMinion.setAttribute("r", "26")
])
]
)
]
) //?$.toDebugString()
DOMinion.diff(tree0, tree1) // ?JSON.stringify($)
DOMinion.diff(tree1, tree1) //?JSON.stringify($)
DOMinion.diff(tree1, tree2) //?JSON.stringify($)
const json1 = JSON.encode(DOMinion.diff(tree0, tree1)) //?
const json2 = JSON.encode(DOMinion.diff(tree1, tree1)) //?
const json3 = JSON.encode(DOMinion.diff(tree1, tree2)) //?
const delta1 = FlatBuffer.encode(DOMinion.diff(tree0, tree1)) //?$.length
const body = document.createElement("div") //?$.innerHTML
const host = DOMinion.mount(body)
if (delta1.isError !== true) {
host.patch(FlatBuffer.decode(delta1)) //?
body.innerHTML //?
}
const delta2 = FlatBuffer.encode(DOMinion.diff(tree1, tree1)) //?$.length
if (delta2.isError !== true) {
DOMinion.patch(host, FlatBuffer.decode(delta2)) //?
body.innerHTML //?
}
const delta3 = FlatBuffer.encode(DOMinion.diff(tree1, tree2)) //?$.length
if (delta3.isError !== true) {
DOMinion.patch(host, FlatBuffer.decode(delta3)) //?
}
body.innerHTML //?
import * as Decoder from "decoder.flow"
const etree1 = DOMinion.createHost(
[],
[
DOMinion.createElement(
"button",
[
DOMinion.on(
"click",
Decoder.record({ type: Decoder.String, button: Decoder.Integer })
)
],
[]
)
]
) //?$.children[0].listeners
const edelta1 = FlatBuffer.encode(DOMinion.diff(tree0, etree1)) //?
try {
if (edelta1.isError !== true) {
DOMinion.patch(Log.archive(), FlatBuffer.decode(edelta1)) //?
}
} catch (error) {
error //?
}
const etree2 = DOMinion.createHost(
[],
[
DOMinion.createElement(
"button",
[
DOMinion.on(
"mouseover",
Decoder.record({ type: Decoder.String, button: Decoder.Integer })
)
],
[]
)
]
) //?$.children[0].listeners
const edelta2 = FlatBuffer.encode(DOMinion.diff(etree1, etree2)) //?
try {
if (edelta2.isError !== true) {
DOMinion.patch(Log.archive(), FlatBuffer.decode(edelta2)) //?
}
} catch (error) {
error //?
}