cm-chessboard 5.5.1 → 5.5.2
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.
|
@@ -13,8 +13,6 @@
|
|
|
13
13
|
<p>Works in Chrome.</p>
|
|
14
14
|
<div class="board board-small" id="board"></div>
|
|
15
15
|
<video id="videoOut" controls="controls"></video>
|
|
16
|
-
<br style="clear: both"/>
|
|
17
|
-
|
|
18
16
|
<script type="module">
|
|
19
17
|
import {RenderVideo} from "../../src/cm-chessboard/extensions/render-video/RenderVideo.js"
|
|
20
18
|
import {Chessboard} from "../../src/cm-chessboard/Chessboard.js"
|
|
@@ -33,18 +31,17 @@
|
|
|
33
31
|
chessboard.recorderStart()
|
|
34
32
|
setTimeout(() => {
|
|
35
33
|
chessboard.movePiece("e2", "e4", true).then(() => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
34
|
+
setTimeout(() => {
|
|
35
|
+
chessboard.movePiece("e7", "e5", true).then(() => {
|
|
36
|
+
setTimeout(() => {
|
|
37
|
+
const url = chessboard.recorderStop()
|
|
38
|
+
const video = document.getElementById("videoOut")
|
|
39
|
+
video.src = url
|
|
40
|
+
}, 100)
|
|
41
|
+
})
|
|
42
|
+
}, 400)
|
|
44
43
|
})
|
|
45
|
-
|
|
46
44
|
}, 500)
|
|
47
|
-
|
|
48
45
|
</script>
|
|
49
46
|
</body>
|
|
50
47
|
</html>
|
package/package.json
CHANGED
|
@@ -17,20 +17,16 @@ export class RenderVideo extends Extension {
|
|
|
17
17
|
this.images = []
|
|
18
18
|
this.makeSpriteInline()
|
|
19
19
|
this.registerExtensionPoint(EXTENSION_POINT.animation, () => {
|
|
20
|
-
// console.log("EXTENSION_POINT.animation", data)
|
|
21
20
|
let clonedSvgElement = this.chessboard.view.svg.cloneNode(true)
|
|
22
|
-
// this.makeStyleInline(clonedSvgElement)
|
|
23
21
|
let serialized = new XMLSerializer().serializeToString(clonedSvgElement)
|
|
24
|
-
// console.log(serialized)
|
|
25
22
|
const blob = new Blob([serialized], {type: "image/svg+xml"})
|
|
26
23
|
const blobURL = URL.createObjectURL(blob)
|
|
27
24
|
const image = new Image()
|
|
28
25
|
this.images.push(image)
|
|
29
26
|
image.onload = () => {
|
|
30
|
-
// console.log("onload", event)
|
|
31
27
|
let context = this.canvas.getContext('2d')
|
|
32
|
-
// console.log(image)
|
|
33
28
|
context.drawImage(image, 0, 0, this.canvas.width, this.canvas.height)
|
|
29
|
+
this.recorder.requestData()
|
|
34
30
|
}
|
|
35
31
|
image.src = blobURL
|
|
36
32
|
})
|
|
@@ -49,12 +45,12 @@ export class RenderVideo extends Extension {
|
|
|
49
45
|
this.recorder = new MediaRecorder(this.stream, {mimeType: this.props.mediaType})
|
|
50
46
|
this.recordedData = []
|
|
51
47
|
this.recorder.ondataavailable = (event) => {
|
|
52
|
-
// console.log(event)
|
|
53
48
|
if (event.data && event.data.size) {
|
|
54
49
|
this.recordedData.push(event.data)
|
|
55
50
|
}
|
|
56
51
|
}
|
|
57
|
-
this.recorder.start(
|
|
52
|
+
this.recorder.start()
|
|
53
|
+
this.recorder.requestData()
|
|
58
54
|
console.log("recorder", this.recorder.state)
|
|
59
55
|
})
|
|
60
56
|
/**
|
|
@@ -71,7 +67,7 @@ export class RenderVideo extends Extension {
|
|
|
71
67
|
const computedStyle = getComputedStyle(element, null)
|
|
72
68
|
for (let i = 0; i < computedStyle.length; i++) {
|
|
73
69
|
const style = computedStyle[i] + ""
|
|
74
|
-
if (
|
|
70
|
+
if (["fill", "stroke", "stroke-width", "font-size"].includes(style)) {
|
|
75
71
|
element.style[style] = computedStyle[style]
|
|
76
72
|
}
|
|
77
73
|
}
|