cm-chessboard 5.5.15 → 5.5.16

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.
@@ -10,7 +10,7 @@
10
10
  <body>
11
11
  <h1><a href="../..">cm-chessboard</a></h1>
12
12
  <h2>Example: RenderVideo extension</h2>
13
- <p>Works in Chrome (webm) and Safari (mp4).</p>
13
+ <p>Works best in Chrome with webm format.</p>
14
14
  <div class="board board-small" id="board"></div>
15
15
  <video id="videoOut" controls="controls"></video>
16
16
  <script type="module">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cm-chessboard",
3
- "version": "5.5.15",
3
+ "version": "5.5.16",
4
4
  "description": "A JavaScript chessboard which is lightweight, ES6 module based, responsive, SVG rendered and without dependencies.",
5
5
  "keywords": [
6
6
  "chess",
@@ -26,8 +26,6 @@ export class RenderVideo extends Extension {
26
26
  }
27
27
  }
28
28
  console.log("recorder mediaType", this.props.mediaType)
29
- this.image = new Image()
30
- document.body.append(this.image)
31
29
  this.makeSpriteInline()
32
30
  this.registerExtensionPoint(EXTENSION_POINT.animation, async (event) => {
33
31
  if(event.event = "frame") {
@@ -50,14 +48,14 @@ export class RenderVideo extends Extension {
50
48
  this.canvas.height = dimensions.height
51
49
  this.context = this.canvas.getContext('2d')
52
50
  document.body.append(this.canvas)
53
-
51
+ /*
54
52
  this.image = new Image()
55
53
  this.image.width = this.canvas.width
56
54
  this.image.height = this.canvas.height
57
55
  this.image.style.position = "absolute"
58
56
  this.image.style.visibility = "hidden"
59
57
  document.body.append(this.image)
60
-
58
+ */
61
59
  this.stream = this.canvas.captureStream(60)
62
60
  this.recorder = new MediaRecorder(this.stream, {mimeType: this.props.mediaType})
63
61
  this.recorder.ondataavailable = (event) => {
@@ -115,20 +113,16 @@ export class RenderVideo extends Extension {
115
113
 
116
114
  async cloneImageAndRender() {
117
115
  return new Promise((resolve, reject) => {
118
- if(this.rendering) {
119
- resolve()
120
- }
121
- this.rendering = true
122
116
  let serialized = new XMLSerializer().serializeToString(this.chessboard.view.svg)
123
117
  const blob = new Blob([serialized], {type: "image/svg+xml"})
124
118
  const blobURL = URL.createObjectURL(blob)
125
- this.image.onload = () => {
126
- this.context.drawImage(this.image, 0, 0, this.canvas.width, this.canvas.height, 0, 0, this.canvas.width, this.canvas.height)
119
+ const image = new Image()
120
+ image.onload = () => {
121
+ this.context.drawImage(image, 0, 0, this.canvas.width, this.canvas.height)
127
122
  this.recorder.requestData()
128
- this.rendering = false
129
123
  resolve()
130
124
  }
131
- this.image.src = blobURL
125
+ image.src = blobURL
132
126
  })
133
127
  }
134
128