cm-chessboard 5.5.16 → 5.5.17

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cm-chessboard",
3
- "version": "5.5.16",
3
+ "version": "5.5.17",
4
4
  "description": "A JavaScript chessboard which is lightweight, ES6 module based, responsive, SVG rendered and without dependencies.",
5
5
  "keywords": [
6
6
  "chess",
@@ -28,7 +28,7 @@ export class RenderVideo extends Extension {
28
28
  console.log("recorder mediaType", this.props.mediaType)
29
29
  this.makeSpriteInline()
30
30
  this.registerExtensionPoint(EXTENSION_POINT.animation, async (event) => {
31
- if(event.event = "frame") {
31
+ if(event.event === "frame") {
32
32
  if (this.recorder && this.recorder.state === "recording") {
33
33
  await this.cloneImageAndRender()
34
34
  }
@@ -48,16 +48,17 @@ export class RenderVideo extends Extension {
48
48
  this.canvas.height = dimensions.height
49
49
  this.context = this.canvas.getContext('2d')
50
50
  document.body.append(this.canvas)
51
- /*
51
+
52
52
  this.image = new Image()
53
53
  this.image.width = this.canvas.width
54
54
  this.image.height = this.canvas.height
55
55
  this.image.style.position = "absolute"
56
56
  this.image.style.visibility = "hidden"
57
57
  document.body.append(this.image)
58
- */
59
- this.stream = this.canvas.captureStream(60)
60
- this.recorder = new MediaRecorder(this.stream, {mimeType: this.props.mediaType})
58
+
59
+ this.stream = this.canvas.captureStream(50)
60
+ this.recorder = new MediaRecorder(this.stream, {
61
+ mimeType: this.props.mediaType})
61
62
  this.recorder.ondataavailable = (event) => {
62
63
  if (event.data && event.data.size) {
63
64
  this.recordedData.push(event.data)
@@ -75,7 +76,7 @@ export class RenderVideo extends Extension {
75
76
  return
76
77
  }
77
78
  this.recordedData = []
78
- this.recorder.start()
79
+ this.recorder.start(100)
79
80
  console.log("recorder", this.recorder.state)
80
81
  resolve()
81
82
  })
@@ -112,14 +113,14 @@ export class RenderVideo extends Extension {
112
113
  }
113
114
 
114
115
  async cloneImageAndRender() {
115
- return new Promise((resolve, reject) => {
116
+ return new Promise((resolve) => {
116
117
  let serialized = new XMLSerializer().serializeToString(this.chessboard.view.svg)
117
118
  const blob = new Blob([serialized], {type: "image/svg+xml"})
118
119
  const blobURL = URL.createObjectURL(blob)
119
- const image = new Image()
120
+ // strange Safari "bug" that the content has only 300x150px
121
+ const image = this.props.mediaType === "video/mp4" ? this.image : new Image()
120
122
  image.onload = () => {
121
- this.context.drawImage(image, 0, 0, this.canvas.width, this.canvas.height)
122
- this.recorder.requestData()
123
+ this.context.drawImage(image, 0, 0, this.canvas.width, this.canvas.height, 0, 0, this.canvas.width, this.canvas.height)
123
124
  resolve()
124
125
  }
125
126
  image.src = blobURL