jclic 2.1.21 → 2.1.23

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.
Files changed (175) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/jclic-node.js +9 -8
  3. package/dist/jclic-node.js.map +1 -1
  4. package/dist/jclic.min.js +2 -2
  5. package/dist/jclic.min.js.map +1 -1
  6. package/package.json +4 -4
  7. package/src/GlobalData.js +1 -1
  8. package/src/JClicPlayer.js +2 -2
  9. package/src/bags/MediaBag.js +6 -5
  10. package/dist/1078.jclic-node.js +0 -282
  11. package/dist/1078.jclic-node.js.map +0 -1
  12. package/dist/1196.jclic-node.js +0 -808
  13. package/dist/1196.jclic-node.js.map +0 -1
  14. package/dist/1253.jclic-node.js +0 -1432
  15. package/dist/1253.jclic-node.js.map +0 -1
  16. package/dist/13.jclic-node.js +0 -103
  17. package/dist/13.jclic-node.js.map +0 -1
  18. package/dist/1567.jclic-node.js +0 -2313
  19. package/dist/1567.jclic-node.js.map +0 -1
  20. package/dist/1588.jclic-node.js +0 -602
  21. package/dist/1588.jclic-node.js.map +0 -1
  22. package/dist/1725.jclic-node.js +0 -836
  23. package/dist/1725.jclic-node.js.map +0 -1
  24. package/dist/1731.jclic-node.js +0 -438
  25. package/dist/1731.jclic-node.js.map +0 -1
  26. package/dist/1842.jclic-node.js +0 -651
  27. package/dist/1842.jclic-node.js.map +0 -1
  28. package/dist/2160.jclic-node.js +0 -1016
  29. package/dist/2160.jclic-node.js.map +0 -1
  30. package/dist/222.jclic-node.js +0 -129
  31. package/dist/222.jclic-node.js.map +0 -1
  32. package/dist/2316.jclic-node.js +0 -949
  33. package/dist/2316.jclic-node.js.map +0 -1
  34. package/dist/2355.jclic-node.js +0 -371
  35. package/dist/2355.jclic-node.js.map +0 -1
  36. package/dist/2366.jclic-node.js +0 -431
  37. package/dist/2366.jclic-node.js.map +0 -1
  38. package/dist/2379.jclic-node.js +0 -202
  39. package/dist/2379.jclic-node.js.map +0 -1
  40. package/dist/2437.jclic-node.js +0 -450
  41. package/dist/2437.jclic-node.js.map +0 -1
  42. package/dist/2531.jclic-node.js +0 -869
  43. package/dist/2531.jclic-node.js.map +0 -1
  44. package/dist/2608.jclic-node.js +0 -160
  45. package/dist/2608.jclic-node.js.map +0 -1
  46. package/dist/2715.jclic-node.js +0 -554
  47. package/dist/2715.jclic-node.js.map +0 -1
  48. package/dist/277.jclic-node.js +0 -22
  49. package/dist/277.jclic-node.js.map +0 -1
  50. package/dist/2921.jclic-node.js +0 -660
  51. package/dist/2921.jclic-node.js.map +0 -1
  52. package/dist/2952.jclic-node.js +0 -101
  53. package/dist/2952.jclic-node.js.map +0 -1
  54. package/dist/3018.jclic-node.js +0 -421
  55. package/dist/3018.jclic-node.js.map +0 -1
  56. package/dist/3019.jclic-node.js +0 -682
  57. package/dist/3019.jclic-node.js.map +0 -1
  58. package/dist/3231.jclic-node.js +0 -274
  59. package/dist/3231.jclic-node.js.map +0 -1
  60. package/dist/331.jclic-node.js +0 -115
  61. package/dist/331.jclic-node.js.map +0 -1
  62. package/dist/3391.jclic-node.js +0 -276
  63. package/dist/3391.jclic-node.js.map +0 -1
  64. package/dist/3502.jclic-node.js +0 -671
  65. package/dist/3502.jclic-node.js.map +0 -1
  66. package/dist/3653.jclic-node.js +0 -982
  67. package/dist/3653.jclic-node.js.map +0 -1
  68. package/dist/371.jclic.min.js +0 -2
  69. package/dist/371.jclic.min.js.map +0 -1
  70. package/dist/3856.jclic-node.js +0 -575
  71. package/dist/3856.jclic-node.js.map +0 -1
  72. package/dist/4112.jclic-node.js +0 -659
  73. package/dist/4112.jclic-node.js.map +0 -1
  74. package/dist/4123.jclic-node.js +0 -910
  75. package/dist/4123.jclic-node.js.map +0 -1
  76. package/dist/427.jclic-node.js +0 -894
  77. package/dist/427.jclic-node.js.map +0 -1
  78. package/dist/4483.jclic-node.js +0 -327
  79. package/dist/4483.jclic-node.js.map +0 -1
  80. package/dist/4548.jclic-node.js +0 -1078
  81. package/dist/4548.jclic-node.js.map +0 -1
  82. package/dist/466.jclic-node.js +0 -99
  83. package/dist/466.jclic-node.js.map +0 -1
  84. package/dist/485.jclic-node.js +0 -783
  85. package/dist/485.jclic-node.js.map +0 -1
  86. package/dist/4921.jclic-node.js +0 -500
  87. package/dist/4921.jclic-node.js.map +0 -1
  88. package/dist/5091.jclic-node.js +0 -239
  89. package/dist/5091.jclic-node.js.map +0 -1
  90. package/dist/520.jclic-node.js +0 -550
  91. package/dist/520.jclic-node.js.map +0 -1
  92. package/dist/5312.jclic-node.js +0 -1126
  93. package/dist/5312.jclic-node.js.map +0 -1
  94. package/dist/5338.jclic-node.js +0 -212
  95. package/dist/5338.jclic-node.js.map +0 -1
  96. package/dist/5344.jclic-node.js +0 -229
  97. package/dist/5344.jclic-node.js.map +0 -1
  98. package/dist/5550.jclic-node.js +0 -238
  99. package/dist/5550.jclic-node.js.map +0 -1
  100. package/dist/5626.jclic-node.js +0 -614
  101. package/dist/5626.jclic-node.js.map +0 -1
  102. package/dist/5977.jclic-node.js +0 -1081
  103. package/dist/5977.jclic-node.js.map +0 -1
  104. package/dist/6148.jclic-node.js +0 -345
  105. package/dist/6148.jclic-node.js.map +0 -1
  106. package/dist/6176.jclic-node.js +0 -481
  107. package/dist/6176.jclic-node.js.map +0 -1
  108. package/dist/6221.jclic-node.js +0 -1072
  109. package/dist/6221.jclic-node.js.map +0 -1
  110. package/dist/6238.jclic-node.js +0 -718
  111. package/dist/6238.jclic-node.js.map +0 -1
  112. package/dist/6454.jclic-node.js +0 -1413
  113. package/dist/6454.jclic-node.js.map +0 -1
  114. package/dist/6565.jclic-node.js +0 -294
  115. package/dist/6565.jclic-node.js.map +0 -1
  116. package/dist/6579.jclic-node.js +0 -719
  117. package/dist/6579.jclic-node.js.map +0 -1
  118. package/dist/6715.jclic-node.js +0 -148
  119. package/dist/6715.jclic-node.js.map +0 -1
  120. package/dist/6777.jclic-node.js +0 -171
  121. package/dist/6777.jclic-node.js.map +0 -1
  122. package/dist/6782.jclic-node.js +0 -1611
  123. package/dist/6782.jclic-node.js.map +0 -1
  124. package/dist/6847.jclic-node.js +0 -601
  125. package/dist/6847.jclic-node.js.map +0 -1
  126. package/dist/6856.jclic-node.js +0 -252
  127. package/dist/6856.jclic-node.js.map +0 -1
  128. package/dist/696.jclic-node.js +0 -1821
  129. package/dist/696.jclic-node.js.map +0 -1
  130. package/dist/698.jclic-node.js +0 -583
  131. package/dist/698.jclic-node.js.map +0 -1
  132. package/dist/704.jclic-node.js +0 -80
  133. package/dist/704.jclic-node.js.map +0 -1
  134. package/dist/7046.jclic-node.js +0 -735
  135. package/dist/7046.jclic-node.js.map +0 -1
  136. package/dist/7220.jclic-node.js +0 -156
  137. package/dist/7220.jclic-node.js.map +0 -1
  138. package/dist/7257.jclic-node.js +0 -931
  139. package/dist/7257.jclic-node.js.map +0 -1
  140. package/dist/743.jclic-node.js +0 -583
  141. package/dist/743.jclic-node.js.map +0 -1
  142. package/dist/757.jclic-node.js +0 -1072
  143. package/dist/757.jclic-node.js.map +0 -1
  144. package/dist/7781.jclic-node.js +0 -202
  145. package/dist/7781.jclic-node.js.map +0 -1
  146. package/dist/7912.jclic-node.js +0 -2103
  147. package/dist/7912.jclic-node.js.map +0 -1
  148. package/dist/827.jclic-node.js +0 -708
  149. package/dist/827.jclic-node.js.map +0 -1
  150. package/dist/8276.jclic-node.js +0 -409
  151. package/dist/8276.jclic-node.js.map +0 -1
  152. package/dist/8322.jclic-node.js +0 -498
  153. package/dist/8322.jclic-node.js.map +0 -1
  154. package/dist/8641.jclic-node.js +0 -360
  155. package/dist/8641.jclic-node.js.map +0 -1
  156. package/dist/8837.jclic-node.js +0 -651
  157. package/dist/8837.jclic-node.js.map +0 -1
  158. package/dist/8895.jclic-node.js +0 -151
  159. package/dist/8895.jclic-node.js.map +0 -1
  160. package/dist/9072.jclic-node.js +0 -1285
  161. package/dist/9072.jclic-node.js.map +0 -1
  162. package/dist/9078.jclic-node.js +0 -935
  163. package/dist/9078.jclic-node.js.map +0 -1
  164. package/dist/9103.jclic-node.js +0 -718
  165. package/dist/9103.jclic-node.js.map +0 -1
  166. package/dist/9359.jclic-node.js +0 -145
  167. package/dist/9359.jclic-node.js.map +0 -1
  168. package/dist/9409.jclic-node.js +0 -921
  169. package/dist/9409.jclic-node.js.map +0 -1
  170. package/dist/9513.jclic-node.js +0 -720
  171. package/dist/9513.jclic-node.js.map +0 -1
  172. package/dist/9704.jclic-node.js +0 -81
  173. package/dist/9704.jclic-node.js.map +0 -1
  174. package/dist/9950.jclic-node.js +0 -827
  175. package/dist/9950.jclic-node.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"827.jclic-node.js","mappings":";;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEuD;AAChB;;AAEvC;AACA,+CAA+C,0EAA0E;AACzH,IAAI,6DAA6D,IAAI,wCAAwC;AAC7G;AACO;AACP;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,oBAAoB,0EAA0E;AAC9F,aAAa,wCAAwC;AACrD,aAAa,+BAA+B;AAC5C,aAAa,gCAAgC;AAC7C;AACA,gBAAgB,iDAAiD;AACjE,eAAe;AACf;AACA;AACA;AACA;AACA;AACA,2CAA2C,yDAAQ;AACnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB,6DAAiB;AACnC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,oCAAoC,0EAA0E;AAC9G;AACA,aAAa,wCAAwC;AACrD,aAAa,+BAA+B;AAC5C,aAAa,gCAAgC;AAC7C,MAAM,8FAA8F;AACpG,gBAAgB,iDAAiD;AACjE,eAAe;AACf;AACA;AACA;AACA;AACA;;AAEA;AACA,2CAA2C,0EAA0E,0BAA0B,6CAA6C;AAC5L,aAAa,wCAAwC;AACrD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,6DAAiB;AACrB;AACA;;AAEA;AACA;AACA,wBAAwB,0EAA0E;AAClG;AACA,YAAY,oDAAoD;AAChE;AACA,CAAC;;AAED,iEAAe,cAAc,EAAC;;;;;;;;;;;;;;;AChJ9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEuB;AACoB;;AAE3C;AACA,gDAAgD,8CAA8C;AAC9F;AACA;AACO;AACP;AACA;AACA,aAAa,wCAAwC;AACrD,aAAa,+BAA+B;AAC5C,aAAa,gCAAgC;AAC7C,MAAM,8FAA8F;AACpG,gBAAgB,iDAAiD;AACjE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8DAA8D,uDAAW;AACzE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kCAAkC,6CAAC;AACnC;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA,aAAa,kCAAkC;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY;AACZ;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA,YAAY;AACZ;AACA,4BAA4B,6CAAC;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA,aAAa,kCAAkC;AAC/C;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ,iCAAiC;AACtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ,iCAAiC;AACtD;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,kCAAkC;AAC/C;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,SAAS;AACtB;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,kCAAkC;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,YAAY,wCAAwC;AACpD;AACA;AACA;AACA;AACA,YAAY,gCAAgC;AAC5C;AACA;AACA,uCAAuC,kDAAkD;AACzF;AACA,YAAY,kCAAkC;AAC9C;AACA;AACA;AACA;AACA,YAAY,iBAAiB;AAC7B;AACA;AACA;AACA;AACA,YAAY,SAAS;AACrB;AACA;AACA,UAAU,mDAAmD;AAC7D;AACA,YAAY,6CAA6C;AACzD;AACA,CAAC;;AAED;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,wCAAwC;AACxC,0BAA0B,gFAAgF;AAC1G,UAAU,wBAAwB;AAClC;;AAEA,iEAAe,iBAAiB,EAAC;;;;;;;;;;;;;ACxSjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEkC;;AAElC;AACA;AACA;AACO;AACP;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,iBAAiB;AAC9B;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,4CAA4C,2BAA2B;AACvE;;AAEA;;AAEA;;AAEA;AACA,YAAY,wDAAG,oCAAoC,IAAI;AACvD;AACA;;AAEA;AACA,YAAY,wDAAG;AACf;AACA;;AAEA;AACA,YAAY,wDAAG;AACf;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,+CAA+C,wDAAG,qCAAqC,GAAG;;AAE1F;;AAEA;;AAEA;AACA;AACA;AACA,WAAW;AACX,SAAS;AACT;AACA,UAAU,wDAAG;AACb;AACA,SAAS;AACT;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,SAAS;AACtB,aAAa,iBAAiB;AAC9B;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA,YAAY;AACZ;AACA;AACA;AACA,oFAAoF;AACpF;AACA,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA,YAAY;AACZ;AACA;AACA,CAAC;;AAED;AACA;AACA,UAAU;AACV;AACA;;AAEA,iEAAe,WAAW,EAAC","sources":["webpack://jclic/./src/media/ActiveMediaBag.js","webpack://jclic/./src/media/ActiveMediaPlayer.js","webpack://jclic/./src/media/AudioBuffer.js"],"sourcesContent":["/**\n * File : media/ActiveMediaBag.js\n * Created : 28/04/2015\n * By : Francesc Busquets <francesc@gmail.com>\n *\n * JClic.js\n * An HTML5 player of JClic activities\n * https://projectestac.github.io/jclic.js\n *\n * @source https://github.com/projectestac/jclic.js\n *\n * @license EUPL-1.2\n * @licstart\n * (c) 2000-2020 Educational Telematic Network of Catalonia (XTEC)\n *\n * Licensed under the EUPL, Version 1.1 or -as soon they will be approved by\n * the European Commission- subsequent versions of the EUPL (the \"Licence\");\n * You may not use this work except in compliance with the Licence.\n *\n * You may obtain a copy of the Licence at:\n * https://joinup.ec.europa.eu/software/page/eupl\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the Licence is distributed on an \"AS IS\" basis, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n * Licence for the specific language governing permissions and limitations\n * under the Licence.\n * @licend\n * @module\n */\n\nimport ActiveMediaPlayer from './ActiveMediaPlayer.js';\nimport { settings } from '../Utils.js';\n\n/**\n * This class stores a collection of realized {@link module:media/ActiveMediaPlayer.ActiveMediaPlayer ActiveMediaPlayer} objects, related to a\n * {@link module:project/JClicProject.JClicProject JClicProject} or {@link module:Activity.Activity Activity}.\n */\nexport class ActiveMediaBag {\n /**\n * ActiveMediaBag constructor\n */\n constructor() {\n this.players = [];\n }\n\n /**\n * Creates a new {@link module:media/ActiveMediaPlayer.ActiveMediaPlayer ActiveMediaPlayer} linked to this media bag\n * @param {module:media/MediaContent.MediaContent} mc - The content used by the new player\n * @param {module:bags/MediaBag.MediaBag} mb - The project's MediaBag\n * @param {module:JClicPlayer.JClicPlayer} ps - An object implementing the\n * [PlayStation](http://projectestac.github.io/jclic/apidoc/edu/xtec/jclic/PlayStation.html) interface,\n * usually a {@link module:JClicPlayer.JClicPlayer JClicPlayer}.\n * @returns {module:media/ActiveMediaPlayer.ActiveMediaPlayer}\n */\n createActiveMediaPlayer(mc, mb, ps) {\n let amp = null;\n switch (mc.type) {\n case 'RECORD_AUDIO':\n if (mc.length <= 0 || mc.length >= settings.MAX_RECORD_LENGTH)\n break;\n /* falls through */\n case 'PLAY_RECORDED_AUDIO':\n if (mc.recBuffer < 0 || mc.recBuffer >= 10)\n break;\n /* falls through */\n case 'PLAY_AUDIO':\n case 'PLAY_MIDI':\n case 'PLAY_VIDEO':\n amp = new ActiveMediaPlayer(mc, mb, ps);\n break;\n }\n if (amp !== null)\n this.players.push(amp);\n return amp;\n }\n\n /**\n * Looks for an already existing {@link module:media/ActiveMediaPlayer.ActiveMediaPlayer ActiveMediaPlayer} equivalent to the requested.\n * When not found, a new one is created and and returned.\n * @param {module:media/MediaContent.MediaContent} mc - The content used by the new player\n * @param {module:bags/MediaBag.MediaBag} mb - The project's MediaBag\n * @param {module:JClicPlayer.JClicPlayer} ps - An object implementing the\n * {@link http://projectestac.github.io/jclic/apidoc/edu/xtec/jclic/PlayStation.html|PlayStation} interface,\n * usually a {@link module:JClicPlayer.JClicPlayer JClicPlayer}.\n * @returns {module:media/ActiveMediaPlayer.ActiveMediaPlayer}\n */\n getActiveMediaPlayer(mc, mb, ps) {\n return this.players.find(p => p.mc === mc || p.mc.isEquivalent(mc))\n || this.createActiveMediaPlayer(mc, mb, ps);\n }\n\n /**\n * Removes from the list of players the {@link module:media/ActiveMediaPlayer.ActiveMediaPlayer ActiveMediaPlayer} related to the specified {@link module:media/MediaContent.MediaContent}.\n * @param {module:media/MediaContent.MediaContent} mc - The media content to look for.\n */\n removeActiveMediaPlayer(mc) {\n const i = this.players.findIndex(p => p.mc === mc);\n if (i >= 0) {\n this.players[i].clear();\n // removes the element pointed by 'i'\n this.players.splice(i, 1);\n }\n }\n\n /**\n * Realizes all the media elements stored in this bag\n */\n realizeAll() {\n this.players.forEach(p => p.realize());\n }\n\n /**\n * Stops playing all media elements stored in this bag\n * @param {number} level - Level at and below what all media players will be muted.\n */\n stopAll(level) {\n if (typeof level === 'undefined')\n level = -1;\n this.players.forEach(amp => {\n if (level === -1 || amp.mc !== null && amp.mc.level <= level)\n amp.stop();\n });\n }\n\n /**\n * Removes all players from this media bag\n */\n removeAll() {\n this.players.forEach(p => p.clear());\n // Empty the `players` array\n this.players.length = 0;\n ActiveMediaPlayer.prototype.clearAllAudioBuffers();\n }\n}\n\nObject.assign(ActiveMediaBag.prototype, {\n /**\n * The collection of {@link module:media/ActiveMediaPlayer.ActiveMediaPlayer ActiveMediaPlayer} objects stored in this media bag.\n * @name module:media/ActiveMediaBag.ActiveMediaBag#players\n * @type {module:media/ActiveMediaPlayer.ActiveMediaPlayer[]} */\n players: [],\n});\n\nexport default ActiveMediaBag;\n","/**\n * File : media/ActiveMediaPlayer.js\n * Created : 28/04/2015\n * By : Francesc Busquets <francesc@gmail.com>\n *\n * JClic.js\n * An HTML5 player of JClic activities\n * https://projectestac.github.io/jclic.js\n *\n * @source https://github.com/projectestac/jclic.js\n *\n * @license EUPL-1.2\n * @licstart\n * (c) 2000-2020 Educational Telematic Network of Catalonia (XTEC)\n *\n * Licensed under the EUPL, Version 1.1 or -as soon they will be approved by\n * the European Commission- subsequent versions of the EUPL (the \"Licence\");\n * You may not use this work except in compliance with the Licence.\n *\n * You may obtain a copy of the Licence at:\n * https://joinup.ec.europa.eu/software/page/eupl\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the Licence is distributed on an \"AS IS\" basis, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n * Licence for the specific language governing permissions and limitations\n * under the Licence.\n * @licend\n * @module\n */\n\n/* global navigator */\n\nimport $ from 'jquery';\nimport AudioBuffer from './AudioBuffer.js';\n\n/**\n * This kind of object encapsulates a realized {@link module:media/MediaContent.MediaContent} and provides methods to start,\n * stop, pause and record different types of media (audio, video, MIDI, voice recording...)\n */\nexport class ActiveMediaPlayer {\n /**\n * ActiveMediaPlayer constructor\n * @param {module:media/MediaContent.MediaContent} mc - - The content used by this player\n * @param {module:bags/MediaBag.MediaBag} mb - The project's MediaBag\n * @param {module:JClicPlayer.JClicPlayer} ps - An object implementing the\n * {@link http://projectestac.github.io/jclic/apidoc/edu/xtec/jclic/PlayStation.html PlayStation} interface,\n * usually a {@link module:JClicPlayer.JClicPlayer JClicPlayer}.\n */\n constructor(mc, mb, ps) {\n this.mc = mc;\n this.ps = ps;\n switch (mc.type) {\n case 'RECORD_AUDIO':\n if (ActiveMediaPlayer.AUDIO_BUFFERS) {\n this.clearAudioBuffer(mc.recBuffer);\n ActiveMediaPlayer.AUDIO_BUFFERS[mc.recBuffer] = new AudioBuffer(mc.length);\n }\n /* falls through */\n case 'PLAY_RECORDED_AUDIO':\n this.useAudioBuffer = true;\n break;\n case 'PLAY_AUDIO':\n case 'PLAY_VIDEO':\n case 'PLAY_MIDI':\n this.mbe = mb.getElement(mc.file, true);\n break;\n default:\n break;\n }\n }\n\n /**\n * Generates the objects that will play media\n */\n realize() {\n if (this.mbe) {\n this.mbe.build(mbe => {\n if (mbe.data && mbe.data.pause && !mbe.data.paused && !mbe.data.ended && mbe.data.currentTime)\n mbe.data.pause();\n if ((mbe.type === 'video' || mbe.type === 'anim') && mbe.data) {\n this.$visualComponent = $(mbe.data);\n this.$visualComponent.css('z-index', 20);\n }\n }, this.ps, false, this.mc.level);\n }\n }\n\n /**\n * Plays the media, realizing it if needed.\n * @param {module:boxes/ActiveBox.ActiveBox} [_setBx] - The active box where this media will be placed (when video)\n */\n playNow(_setBx) {\n // TODO: Remove unused param \"_setBx\"\n if (this.useAudioBuffer) {\n if (ActiveMediaPlayer.AUDIO_BUFFERS) {\n const $div = this.ps && this.ps.$div;\n const buffer = ActiveMediaPlayer.AUDIO_BUFFERS[this.mc.recBuffer];\n if (buffer) {\n if (this.mc.type === 'RECORD_AUDIO') {\n buffer.record($div);\n } else {\n buffer.play();\n }\n }\n }\n } else if (this.mbe) {\n this.mbe.build(() => {\n if (this.mbe.data) {\n if (this.mbe.type === 'midi') {\n this.mbe.data.playTo = this.mc.to || 0;\n } else {\n let armed = false;\n const $player = $(this.mbe.data);\n // Clear previous event handlers\n $player.off();\n // If there is a time fragment specified, prepare to stop when the `to` position is reached\n if (this.mc.to > 0) {\n $player.on('timeupdate', () => {\n if (armed && this.mbe.data.currentTime >= this.mc.to / 1000) {\n $player.off('timeupdate');\n this.mbe.data.pause();\n }\n });\n }\n // Launch the media despite of its readyState\n armed = true;\n }\n if (!this.mbe.data.paused && !this.mbe.data.ended && this.mbe.data.currentTime)\n this.mbe.data.pause();\n // Seek the media position\n this.mbe.data.currentTime = this.mc.from > 0 ? this.mc.from / 1000 : 0;\n this.mbe.data.play();\n }\n }, this.ps, true, this.mc.level);\n }\n }\n\n /**\n * Plays the media when available, without blocking the current thread.\n * @param {module:boxes/ActiveBox.ActiveBox} [setBx] - The active box where this media will be placed (when video)\n */\n play(setBx) {\n this.stopAllAudioBuffers();\n this.playNow(setBx);\n }\n\n /**\n * Stops the media playing\n */\n stop() {\n if (this.useAudioBuffer)\n this.stopAudioBuffer(this.mc.recBuffer);\n else if (this.mbe && this.mbe.data && this.mbe.data.pause && !this.mbe.data.paused && !this.mbe.data.ended && this.mbe.data.currentTime)\n this.mbe.data.pause();\n }\n\n /**\n * Frees all resources used by this player\n */\n clear() {\n this.stop();\n if (this.useAudioBuffer)\n this.clearAudioBuffer(this.mc.recBuffer);\n }\n\n /**\n * Clears the specified audio buffer\n * @param {number} buffer - Index of the buffer in {@link module:media/ActiveMediaPlayer.ActiveMediaPlayer#AUDIO_BUFFERS AUDIO_BUFFERS}\n */\n clearAudioBuffer(buffer) {\n if (ActiveMediaPlayer.AUDIO_BUFFERS &&\n buffer >= 0 && buffer < ActiveMediaPlayer.AUDIO_BUFFERS.length &&\n ActiveMediaPlayer.AUDIO_BUFFERS[buffer]) {\n ActiveMediaPlayer.AUDIO_BUFFERS[buffer].clear();\n ActiveMediaPlayer.AUDIO_BUFFERS[buffer] = null;\n }\n }\n\n /**\n * Clears all audio buffers\n */\n clearAllAudioBuffers() {\n if (ActiveMediaPlayer.AUDIO_BUFFERS)\n ActiveMediaPlayer.AUDIO_BUFFERS.forEach((_buffer, n) => this.clearAudioBuffer(n));\n }\n\n /**\n * Counts the number of active audio buffers\n * @returns {number}\n */\n countActiveBuffers() {\n return ActiveMediaPlayer.AUDIO_BUFFERS ? ActiveMediaPlayer.AUDIO_BUFFERS.reduce((c, ab) => c + ab ? 1 : 0, 0) : 0;\n }\n\n /**\n * Stops the playing or recording actions of all audio buffers\n */\n stopAllAudioBuffers() {\n if (ActiveMediaPlayer.AUDIO_BUFFERS)\n ActiveMediaPlayer.AUDIO_BUFFERS.forEach(ab => ab ? ab.stop() : null);\n }\n\n /**\n * Stops a specific audio buffer\n * @param {number} buffer - Index of the buffer in {@link module:media/ActiveMediaPlayer.ActiveMediaPlayer#AUDIO_BUFFERS AUDIO_BUFFERS}\n */\n stopAudioBuffer(buffer) {\n if (ActiveMediaPlayer.AUDIO_BUFFERS &&\n buffer >= 0 && buffer < ActiveMediaPlayer.AUDIO_BUFFERS.length &&\n ActiveMediaPlayer.AUDIO_BUFFERS[buffer])\n ActiveMediaPlayer.AUDIO_BUFFERS[buffer].stop();\n }\n\n /**\n * Checks the position of visual components after a displacement or resizing of its container\n * @param {module:boxes/ActiveBox.ActiveBox} _bxi - The container where this player is hosted\n */\n checkVisualComponentBounds(_bxi) {\n // does nothing\n }\n\n /**\n * Sets the visual component of this player visible or invisible\n * @param {boolean} _state - `true` for visible\n */\n setVisualComponentVisible(_state) {\n // TODO: Implement setVisualComponentVisible\n }\n\n /**\n * Sets the ActiveBox associated to this media player\n * @param {module:boxes/ActiveBox.ActiveBox} setBx - The new container of this media. Can be `null`.\n */\n linkTo(setBx) {\n this.bx = setBx;\n if (this.bx && this.$visualComponent)\n this.bx.setHostedComponent(this.$visualComponent);\n }\n}\n\nObject.assign(ActiveMediaPlayer.prototype, {\n /**\n * The MediaContent associated to this player.\n * @name module:media/ActiveMediaPlayer.ActiveMediaPlayer#mc\n * @type {module:media/MediaContent.MediaContent} */\n mc: null,\n /**\n * The player to which this player belongs.\n * @name module:media/ActiveMediaPlayer.ActiveMediaPlayer#ps\n * @type {module:JClicPlayer.JClicPlayer} */\n ps: null,\n /**\n * MediaPlayers should be linked to {@link module:boxes/ActiveBox.ActiveBox ActiveBox} objects.\n * @name module:media/ActiveMediaPlayer.ActiveMediaPlayer#bx\n * @type {module:boxes/ActiveBox.ActiveBox} */\n bx: null,\n /**\n * The visual component for videos, usually a `video` HTML element\n * @name module:media/ActiveMediaPlayer.ActiveMediaPlayer#$visualComponent\n * @type {external:jQuery} */\n $visualComponent: null,\n /**\n * When `true`, this player makes use of a recording audio buffer\n * @name module:media/ActiveMediaPlayer.ActiveMediaPlayer#useAudioBuffer\n * @type {boolean} */\n useAudioBuffer: false,\n /**\n * The {@link module:bads/MediaBagElement.MediaBagElement} containing the reference to the media to be played\n * @name module:media/ActiveMediaPlayer.ActiveMediaPlayer#mbe\n * @type {module:bags/MediaBagElement.MediaBagElement} */\n mbe: null,\n});\n\n/**\n * Recording of audio is enabled only when `navigator.getUserMedia` and `MediaRecorder` are defined\n * In 02-Mar-2016 this is implemented only in Firefox 41 and Chrome 49 or later.\n * See: {@link https://addpipe.com/blog/mediarecorder-api}\n * @type Boolean\n */\nActiveMediaPlayer.REC_ENABLED = typeof MediaRecorder !== 'undefined' && typeof navigator !== 'undefined';\n\nif (ActiveMediaPlayer.REC_ENABLED) {\n navigator.getUserMedia = navigator.getUserMedia ||\n navigator.webkitGetUserMedia ||\n navigator.mozGetUserMedia ||\n navigator.msGetUserMedia;\n}\n\n/**\n * Audio buffers used for recording and playing voice are stored in a static array because\n * they are common to all instances of {@link module:media/ActiveMediaPlayer.ActiveMediaPlayer ActiveMediaPlayer}\n * Only initialized when {@link module:media/ActiveMediaPlayer.ActiveMediaPlayer#REC_ENABLED REC_ENABLED} is `true`.\n * @type {external:AudioBuffer[]} */\nActiveMediaPlayer.AUDIO_BUFFERS = ActiveMediaPlayer.REC_ENABLED ? [] : null;\n\nexport default ActiveMediaPlayer;\n","/**\n * File : media/EventSoundsElement.js\n * Created : 01/04/2015\n * By : Francesc Busquets <francesc@gmail.com>\n *\n * JClic.js\n * An HTML5 player of JClic activities\n * https://projectestac.github.io/jclic.js\n *\n * @source https://github.com/projectestac/jclic.js\n *\n * @license EUPL-1.2\n * @licstart\n * (c) 2000-2020 Educational Telematic Network of Catalonia (XTEC)\n *\n * Licensed under the EUPL, Version 1.1 or -as soon they will be approved by\n * the European Commission- subsequent versions of the EUPL (the \"Licence\");\n * You may not use this work except in compliance with the Licence.\n *\n * You may obtain a copy of the Licence at:\n * https://joinup.ec.europa.eu/software/page/eupl\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the Licence is distributed on an \"AS IS\" basis, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n * Licence for the specific language governing permissions and limitations\n * under the Licence.\n * @licend\n * @module\n */\n\n/* global navigator, window, document, Blob, URL, MediaRecorder */\n\nimport { log } from '../Utils.js';\n\n/**\n * The AudioBuffer object provides sound recording and replaying to activities.\n */\nexport class AudioBuffer {\n /**\n * AudioBuffer constructor\n * @param {number} [seconds] - The maximum amount of time allowed to be recorded by this AudioBuffer\n */\n constructor(seconds) {\n if (navigator && navigator.mediaDevices && navigator.mediaDevices.getUserMedia)\n this.enabled = true;\n if (seconds)\n this.seconds = seconds;\n this.chunks = [];\n }\n\n /**\n * Starts playing the currently recorded audio, if any.\n */\n play() {\n this.stop();\n if (this.mediaPlayer) {\n this.mediaPlayer.currentTime = 0;\n this.mediaPlayer.play();\n } else {\n this.playWhenFinished = true;\n }\n }\n\n /**\n * Stops the current operation, either recording or playing audio\n */\n stop() {\n if (this.mediaRecorder && this.mediaRecorder.state === 'recording')\n this.mediaRecorder.stop();\n else if (this.mediaPlayer && !this.mediaPlayer.paused)\n this.mediaPlayer.pause();\n }\n\n /**\n * Starts recording audio, or stops the recording if already started.\n * @param {external:jQuery} [$div] - Optional `div` element where the recording is performed, as a jQuery ref.\n */\n record($div) {\n if (this.mediaRecorder && this.mediaRecorder.state === 'recording')\n this.mediaRecorder.stop();\n else if (this.enabled) {\n this.stop();\n this.mediaPlayer = null;\n\n navigator.mediaDevices.getUserMedia({ audio: true, video: false })\n .then(mediaStream => {\n\n this.mediaRecorder = new MediaRecorder(mediaStream);\n\n this.mediaRecorder.ondataavailable = ev => this.chunks.push(ev.data);\n\n this.mediaRecorder.onerror = err => {\n log('error', `Error recording audio: ${err}`);\n this.mediaRecorder = null;\n };\n\n this.mediaRecorder.onstart = () => {\n log('debug', 'Recording audio started');\n this.visualFeedbak(true, $div);\n };\n\n this.mediaRecorder.onstop = () => {\n log('debug', 'Recording audio finished');\n this.visualFeedbak(false, $div);\n\n if (this.timeoutID) {\n window.clearTimeout(this.timeoutID);\n this.timeoutID = null;\n }\n\n const options = {};\n if (this.chunks.length > 0 && this.chunks[0].type)\n options.type = this.chunks[0].type;\n const blob = new Blob(this.chunks, options);\n this.chunks = [];\n this.mediaPlayer = document.createElement('audio');\n this.mediaPlayer.src = URL.createObjectURL(blob);\n this.mediaPlayer.pause();\n this.mediaRecorder = null;\n if (this.playWhenFinished) {\n this.playWhenFinished = false;\n this.mediaPlayer.play();\n }\n };\n\n this.mediaRecorder.onwarning = ev => log('warn', `Warning recording audio: ${ev}`);\n\n this.playWhenFinished = false;\n\n this.mediaRecorder.start();\n\n this.timeoutID = window.setTimeout(() => {\n if (this.mediaRecorder);\n this.mediaRecorder.stop();\n }, this.seconds * 1000);\n })\n .catch(err => {\n log('error', err.toString());\n this.visualFeedbak(false, $div);\n });\n }\n }\n\n /**\n * Set visual feedback to the user while the system is recording audio\n * Currently changes the cursor pointer associated to the HTML element\n * containing the recorder.\n * @param {boolean} enabled - Flag indicating if the visual feedback should be active or inactive\n * @param {external:jQuery} [$div] - Optional `div` element where the recording is performed, as a jQuery ref.\n */\n visualFeedbak(enabled, $div) {\n if ($div)\n $div.css('cursor', enabled ? 'progress' : 'inherit');\n }\n\n /**\n * Clears all data associated to this AudioBuffer\n */\n clear() {\n this.stop();\n this.mediaPlayer = null;\n }\n}\n\nObject.assign(AudioBuffer.prototype, {\n /**\n * AudioBuffer is enabled only in browsers with `navigator.MediaDevices.getuserMedia`\n * @name module:media/AudioBuffer.AudioBuffer#enabled\n * @type {boolean}\n */\n enabled: false,\n /**\n * Maximum length of recordings allowed to this AudioBuffer (in seconds)\n * @name module:media/AudioBuffer.AudioBuffer#seconds\n * @type {number}\n */\n seconds: 20,\n /**\n * The object used to record audio data and convert it to a valid stream for the {@link module:media/ActiveMediaPlayer.ActiveMediaPlayer ActiveMediaPlayer}\n * @name module:media/AudioBuffer.AudioBuffer#mediaRecorder\n * @type {external:MediaRecorder}\n */\n mediaRecorder: null,\n /**\n * Array of data chunks collected during the recording\n * @name module:media/AudioBuffer.AudioBuffer#chunks\n * @type {external:Blob[]}\n */\n chunks: null,\n /**\n * The HTML audio element used to play the recorded sound\n * @name module:media/AudioBuffer.AudioBuffer#mediaPlayer\n * @type {external:HTMLAudioElement}\n */\n mediaPlayer: null,\n /**\n * The identifier of the timer launched to stop the recording when the maximum time is exceeded.\n * This member is `null` when no timeout function is associated to this AudioBuffer\n * @name module:media/AudioBuffer.AudioBuffer#timeoutID\n * @type {number}\n */\n timeoutID: null,\n /**\n * Instructs this AudioBuffer recorder to start playing the collected audio at the end of the\n * current `mediaRecorder` task.\n * @name module:media/AudioBuffer.AudioBuffer#playWhenFinished\n * @type {boolean}\n */\n playWhenFinished: false,\n});\n\n/**\n * Maximum amount of time allowed for recordings (in seconds)\n * @type {number}\n */\nAudioBuffer.MAX_RECORD_LENGTH = 180;\n\nexport default AudioBuffer;\n"],"names":[],"sourceRoot":""}
@@ -1,409 +0,0 @@
1
- "use strict";
2
- exports.id = 8276;
3
- exports.ids = [8276];
4
- exports.modules = {
5
-
6
- /***/ 8276:
7
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
8
-
9
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10
- /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
11
- /* harmony export */ });
12
- /* unused harmony export Shaper */
13
- /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7750);
14
- /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__);
15
- /* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1253);
16
- /* harmony import */ var _AWT_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7912);
17
- /**
18
- * File : shapers/Shaper.js
19
- * Created : 13/04/2015
20
- * By : Francesc Busquets <francesc@gmail.com>
21
- *
22
- * JClic.js
23
- * An HTML5 player of JClic activities
24
- * https://projectestac.github.io/jclic.js
25
- *
26
- * @source https://github.com/projectestac/jclic.js
27
- *
28
- * @license EUPL-1.2
29
- * @licstart
30
- * (c) 2000-2020 Educational Telematic Network of Catalonia (XTEC)
31
- *
32
- * Licensed under the EUPL, Version 1.1 or -as soon they will be approved by
33
- * the European Commission- subsequent versions of the EUPL (the "Licence");
34
- * You may not use this work except in compliance with the Licence.
35
- *
36
- * You may obtain a copy of the Licence at:
37
- * https://joinup.ec.europa.eu/software/page/eupl
38
- *
39
- * Unless required by applicable law or agreed to in writing, software
40
- * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT
41
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
42
- * Licence for the specific language governing permissions and limitations
43
- * under the Licence.
44
- * @licend
45
- * @module
46
- */
47
-
48
-
49
-
50
-
51
-
52
- /**
53
- * The function of this class and its subclasses is to draw a set of "shapes" that will be used to
54
- * place {@link module:boxes/ActiveBox.ActiveBox ActiveBox} objects at a specific position, and to determine its dimension and
55
- * appearance.
56
- */
57
- class Shaper {
58
- /**
59
- * Shaper constructor
60
- * @param {number} nx - Number of columns (in grid-based shapers)
61
- * @param {number} ny - Number of rows (in grid-based shapers)
62
- */
63
- constructor(nx, ny) {
64
- this.reset(nx, ny);
65
- }
66
-
67
- /**
68
- * Registers a new type of shaper
69
- * @param {string} shaperName - The name used to identify this shaper
70
- * @param {function} shaperClass - The shaper class, usually extending Shaper
71
- * @returns {module:shapers/Shaper.Shaper} - The provided shaper class
72
- */
73
- static registerClass(shaperName, shaperClass) {
74
- Shaper.CLASSES[shaperName] = shaperClass;
75
- return shaperClass;
76
- }
77
-
78
- /**
79
- * Factory constructor that returns a Shaper of the requested class.
80
- * @param {string} className - The class name of the requested Shaper.
81
- * @param {number} nx - Number of columns (in grid-based shapers)
82
- * @param {number} ny - Number of rows (in grid-based shapers)
83
- * @returns {module:shapers/Shaper.Shaper}
84
- */
85
- static getShaper(className, nx, ny) {
86
- const cl = Shaper.CLASSES[(className || '').replace(/^edu\.xtec\.jclic\.shapers\./, '@')];
87
- if (!cl)
88
- (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .log */ .Rm)('error', `Unknown shaper: ${className}`);
89
- return cl ? new cl(nx, ny) : null;
90
- }
91
-
92
- /**
93
- * Initializes this Shaper to default values
94
- * @param {number} nCols - Number of columns
95
- * @param {number} nRows - Number of rows
96
- */
97
- reset(nCols, nRows) {
98
- this.nCols = nCols;
99
- this.nRows = nRows;
100
- this.nCells = nRows * nCols;
101
- this.initiated = false;
102
- this.shapeData = [];
103
- for (let i = 0; i < this.nCells; i++)
104
- this.shapeData[i] = new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Shape */ .yp();
105
- }
106
-
107
- /**
108
- * Loads this shaper settings from a specific JQuery XML element
109
- * @param {external:jQuery} $xml - The XML element with the shaper data
110
- */
111
- setProperties($xml) {
112
- (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .attrForEach */ .GM)($xml.get(0).attributes, (name, value) => {
113
- switch (name) {
114
- case 'class':
115
- this.className = value;
116
- break;
117
- case 'cols':
118
- this.nCols = Number(value);
119
- break;
120
- case 'rows':
121
- this.nRows = Number(value);
122
- break;
123
- case 'baseWidthFactor':
124
- case 'toothHeightFactor':
125
- case 'scaleX':
126
- case 'scaleY':
127
- this[name] = Number(value);
128
- break;
129
- case 'randomLines':
130
- case 'showEnclosure':
131
- this[name] = (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .getBoolean */ .pW)(value, true);
132
- break;
133
- }
134
- });
135
-
136
- // Reads the 'enclosing'
137
- // (main shape area where the other shape elements are placed)
138
- $xml.children('enclosing:first').each((_n, child) => {
139
- jquery__WEBPACK_IMPORTED_MODULE_0___default()(child).children('shape:first').each((_n, child2) => {
140
- let sh = Shaper.readShapeData(child2, this.scaleX, this.scaleY);
141
- this.enclosing = sh;
142
- this.showEnclosure = true;
143
- this.hasRemainder = true;
144
- });
145
- });
146
-
147
- // Read the shape elements
148
- $xml.children('shape').each((n, child) => {
149
- this.shapeData[n] = Shaper.readShapeData(child, this.scaleX, this.scaleY);
150
- });
151
-
152
- // Correction needed for '@Holes' shaper
153
- if (this.shapeData.length > 0 /* && this.shapeData.length !== this.nRows * this.nCols */) {
154
- //this.nRows = this.shapeData.length
155
- //this.nCols = 1
156
- //this.nCells = this.nCols * this.nRows
157
- this.nCells = this.shapeData.length;
158
- }
159
- return this;
160
- }
161
-
162
- /**
163
- * Reads an individual shape from an XML element.
164
- * Shapes are arrays of `stroke` objects.
165
- * Each `stroke` has an `action` (_move to_, _line to_, _quad to_...) and associated `data`.
166
- * @param {external:jQuery} $xml - The XML element with the shape data
167
- * @param {number} scaleX
168
- * @param {number} scaleY
169
- * @returns {module:AWT.Shape}
170
- */
171
- static readShapeData(xml, scaleX, scaleY) {
172
- const shd = [];
173
- let result = null;
174
- jquery__WEBPACK_IMPORTED_MODULE_0___default().each(xml.textContent.split('|'), (_n, txt) => {
175
- const sd = txt.split(':');
176
- // Possible strokes are: `rectangle`, `ellipse`, `M`, `L`, `Q`, `B`, `X`
177
- // Also possible, but not currently used in JClic: `roundRectangle` and `pie`
178
- let data = sd.length > 1 ? sd[1].split(',') : null;
179
- //
180
- // Data should be always divided by the scale (X or Y)
181
- if (data)
182
- data = data.map((d, n) => d / (n % 2 ? scaleY : scaleX));
183
-
184
- switch (sd[0]) {
185
- case 'rectangle':
186
- result = new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Rectangle */ .M_(data[0], data[1], data[2], data[3]);
187
- break;
188
- case 'ellipse':
189
- result = new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Ellipse */ .Pp(data[0], data[1], data[2], data[3]);
190
- break;
191
- default:
192
- // It's an `AWT.PathStroke`
193
- shd.push(new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .PathStroke */ .kg(sd[0], data));
194
- break;
195
- }
196
- });
197
-
198
- return !result && shd.length > 0 ? new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Path */ .wA(shd) : result;
199
- }
200
-
201
- /**
202
- * Gets a object with the basic attributes needed to rebuild this instance excluding functions,
203
- * parent references, constants and also attributes retaining the default value.
204
- * The resulting object is commonly usued to serialize elements in JSON format.
205
- * @returns {object} - The resulting object, with minimal attrributes
206
- */
207
- getAttributes() {
208
- const fields = [
209
- 'className', 'nCols', 'nRows',
210
- 'baseWidthFactor', 'toothHeightFactor',
211
- 'scaleX', 'scaleY',
212
- 'randomLines',
213
- ];
214
-
215
- if (this.customShapes) {
216
- ['showEnclosure', 'hasRemainder',
217
- 'enclosing', 'shapeData', // Array of AWT.Rectangle, AWT.Ellipse or (AWT.Path -> AWT.PathStroke)
218
- ].forEach(f => fields.push(f));
219
- }
220
-
221
- return (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .getAttr */ .iu)(this, fields);
222
- }
223
-
224
- /**
225
- * Builds a new shaper, based on the properties specified in a data object
226
- * @param {object} data - The data object to be parsed
227
- * @returns {module:shapers/Shaper.Shaper}
228
- */
229
- static factory(data) {
230
- const result = Shaper.getShaper(data.className, data.nCols, data.nRows);
231
- (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .setAttr */ .ob)(result, data, [
232
- 'className', 'nCols', 'nRows',
233
- 'baseWidthFactor', 'toothHeightFactor',
234
- 'scaleX', 'scaleY',
235
- 'randomLines',
236
- 'showEnclosure', 'hasRemainder',
237
- { key: 'enclosing', fn: _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Shape */ .yp },
238
- { key: 'shapeData', fn: _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Shape */ .yp, group: 'array' },
239
- ]);
240
-
241
- result.nCells = result.shapeData.length || result.nCols * result.nRows;
242
-
243
- return result;
244
- }
245
-
246
- /**
247
- * Builds the individual shapes that will form this Shaper
248
- */
249
- buildShapes() {
250
- }
251
-
252
- /**
253
- * Gets a clone of the nth Shape object, scaled and located inside a Rectangle
254
- * @param {number} n
255
- * @param {module:AWT.Rectangle} rect
256
- * @returns {module:AWT.Shape}
257
- */
258
- getShape(n, rect) {
259
- if (!this.initiated)
260
- this.buildShapes();
261
- if (n >= this.nCells || this.shapeData[n] === null)
262
- return null;
263
- return this.shapeData[n].getShape(rect);
264
- }
265
-
266
- /**
267
- * Gets the nth Shape data object
268
- * @param {number} n
269
- * @returns {object}
270
- */
271
- getShapeData(n) {
272
- return n >= 0 && n < this.shapeData.length ? this.shapeData[n] : null;
273
- }
274
-
275
- /**
276
- * Gets the AWT.Rectangle that contains all shapes of this Shaper.
277
- * @returns {module:AWT.Rectangle}
278
- */
279
- getEnclosingShapeData() {
280
- return new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Rectangle */ .M_(0, 0, 1, 1);
281
- }
282
-
283
- /**
284
- * When `hasRemainder` is true, this method gets the rectangle containing the full surface where
285
- * the Shaper develops.
286
- * @param {module:AWT.Rectangle} rect - The frame where to move and scale all the shapes
287
- * @returns {module:AWT.Rectangle}
288
- */
289
- getRemainderShape(rect) {
290
- if (!this.hasRemainder)
291
- return null;
292
-
293
- if (!this.initiated)
294
- this.buildShapes();
295
-
296
- const sh = this.getEnclosingShapeData();
297
- const r = sh ? sh.getShape(rect) : new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Rectangle */ .M_();
298
- for (let i = 0; i < this.nCells; i++) {
299
- if (this.shapeData[i])
300
- r.add(this.shapeData[i].getShape(rect), false);
301
- }
302
- return r;
303
- }
304
- }
305
-
306
- Object.assign(Shaper.prototype, {
307
- /**
308
- * This shaper class name
309
- * @name module:shapers/Shaper.Shaper#className
310
- * @type {string} */
311
- className: 'Shaper',
312
- /**
313
- * Number of columns (useful in grid-based shapers)
314
- * @name module:shapers/Shaper.Shaper#nCols
315
- * @type {number} */
316
- nCols: 0,
317
- /**
318
- * Number of rows (useful in grid-based shapers)
319
- * @name module:shapers/Shaper.Shaper#nRows
320
- * @type {number} */
321
- nRows: 0,
322
- /**
323
- * Number of cells managed by this shaper
324
- * @name module:shapers/Shaper.Shaper#nCells
325
- * @type {number} */
326
- nCells: 0,
327
- /**
328
- * Contains the specific definition of each shape
329
- * @name module:shapers/Shaper.Shaper#shapeData
330
- * @type {object} */
331
- shapeData: null,
332
- /**
333
- * Flag used to check if the `Shaper` has been initialized against a real surface
334
- * @name module:shapers/Shaper.Shaper#initiated
335
- * @type {boolean} */
336
- initiated: false,
337
- //
338
- // Fields used only in JigSaw shapers
339
- /**
340
- * In {@link module:shapers/JigSaw.JigSaw JigSaw}, ratio between the base width of the tooth and the total length of the side.
341
- * @name module:shapers/Shaper.Shaper#baseWidthFactor
342
- * @type {number} */
343
- baseWidthFactor: 1.0 / 3,
344
- /**
345
- * In {@link module:shapers/JigSaw.JigSaw JigSaw}, ratio between the tooth height and the total length of the side.
346
- * @name module:shapers/Shaper.Shaper#toothHeightFactor
347
- * @type {number} */
348
- toothHeightFactor: 1.0 / 6,
349
- /**
350
- * In {@link module:shapers/JigSaw.JigSaw JigSaw}, whether the tooths take random directions or not
351
- * @name module:shapers/Shaper.Shaper#randomLines
352
- * @type {boolean} */
353
- randomLines: false,
354
- //
355
- // Fields used only in the `Holes` shaper
356
- /**
357
- * In {@link module:shapers/Holes.Holes Holes}, scale to be applied to horizontal positions and lengths to achieve the real
358
- * value of the shape placed on a real surface.
359
- * @name module:shapers/Shaper.Shaper#scaleX
360
- * @type {number} */
361
- scaleX: 1.0,
362
- /**
363
- * In {@link module:shapers/Holes.Holes Holes}, scale to be applied to vertical positions and lengths to achieve the real
364
- * value of the shape placed on a real surface.
365
- * @name module:shapers/Shaper.Shaper#scaleY
366
- * @type {number} */
367
- scaleY: 1.0,
368
- /**
369
- * In {@link module:shapers/Holes.Holes Holes}, the enclosing area where all shapes are placed.
370
- * @name module:shapers/Shaper.Shaper#enclosing
371
- * @type {module:AWT.Shape} */
372
- enclosing: null,
373
- /**
374
- * In {@link module:shapers/Holes.Holes Holes}, when `true`, the enclosing area will be drawn
375
- * @name module:shapers/Shaper.Shaper#showEnclosure
376
- * @type {boolean} */
377
- showEnclosure: false,
378
- /**
379
- * Flag indicating if this shaper organizes its cells in rows and columns
380
- * @name module:shapers/Shaper.Shaper#rectangularShapes
381
- * @type {boolean} */
382
- rectangularShapes: false,
383
- /**
384
- * Flag indicating if this Shaper deploys over a surface biggest than the rectangle enclosing
385
- * all its shapes
386
- * @name module:shapers/Shaper.Shaper#hasRemainder
387
- * @type {boolean} */
388
- hasRemainder: false,
389
- /**
390
- * Only the `Holes` shaper has this flag activated
391
- * @name module:shapers/Shaper.Shaper#customShapes
392
- * @type {boolean} */
393
- customShapes: false,
394
- });
395
-
396
- /**
397
- * List of known classes derived from Shaper. It should be filled by real shaper classes at
398
- * declaration time.
399
- * @type {object} */
400
- Shaper.CLASSES = {};
401
-
402
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Shaper);
403
-
404
-
405
- /***/ })
406
-
407
- };
408
- ;
409
- //# sourceMappingURL=8276.jclic-node.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"8276.jclic-node.js","mappings":";;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEuB;AACsD;AACL;;AAExE;AACA;AACA,UAAU,kDAAkD;AAC5D;AACA;AACO;AACP;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,UAAU;AACvB,eAAe,8BAA8B;AAC7C;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,eAAe;AACf;AACA;AACA;AACA;AACA,MAAM,wDAAG,6BAA6B,UAAU;AAChD;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB,iBAAiB;AACrC,8BAA8B,oDAAK;AACnC;;AAEA;AACA;AACA,aAAa,iBAAiB;AAC9B;AACA;AACA,IAAI,gEAAW;AACf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB,+DAAU;AACjC;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA,MAAM,6CAAC;AACP;AACA;AACA;AACA;AACA,OAAO;AACP,KAAK;;AAEL;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,iBAAiB;AAC9B,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,eAAe;AACf;AACA;AACA;AACA;AACA,IAAI,kDAAM;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,uBAAuB,wDAAS;AAChC;AACA;AACA,uBAAuB,sDAAO;AAC9B;AACA;AACA;AACA,uBAAuB,yDAAU;AACjC;AACA;AACA,KAAK;;AAEL,2CAA2C,mDAAI;AAC/C;;AAEA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA,WAAW,4DAAO;AAClB;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe;AACf;AACA;AACA;AACA,IAAI,4DAAO;AACX;AACA;AACA;AACA;AACA;AACA,QAAQ,sBAAsB,oDAAK,EAAE;AACrC,QAAQ,sBAAsB,oDAAK,kBAAkB;AACrD;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,sBAAsB;AACnC,eAAe;AACf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe;AACf;AACA;AACA;AACA;;AAEA;AACA;AACA,eAAe;AACf;AACA;AACA,eAAe,wDAAS;AACxB;;AAEA;AACA;AACA;AACA,aAAa,sBAAsB;AACnC,eAAe;AACf;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,2CAA2C,wDAAS;AACpD,oBAAoB,iBAAiB;AACrC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA;AACA,YAAY,SAAS;AACrB;AACA;AACA;AACA;AACA,SAAS,0CAA0C;AACnD;AACA,YAAY,QAAQ;AACpB;AACA;AACA,SAAS,0CAA0C;AACnD;AACA,YAAY,QAAQ;AACpB;AACA;AACA,SAAS,0CAA0C;AACnD;AACA,YAAY,SAAS;AACrB;AACA;AACA;AACA;AACA,SAAS,uCAAuC;AAChD;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA,SAAS,uCAAuC;AAChD;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA,SAAS,uCAAuC;AAChD;AACA,YAAY,kBAAkB;AAC9B;AACA;AACA,SAAS,uCAAuC;AAChD;AACA,YAAY,SAAS;AACrB;AACA;AACA;AACA;AACA,YAAY,SAAS;AACrB;AACA;AACA;AACA;AACA;AACA,YAAY,SAAS;AACrB;AACA;AACA;AACA;AACA,YAAY,SAAS;AACrB;AACA,CAAC;;AAED;AACA;AACA;AACA,UAAU,QAAQ;AAClB;;AAEA,iEAAe,MAAM,EAAC","sources":["webpack://jclic/./src/shapers/Shaper.js"],"sourcesContent":["/**\n * File : shapers/Shaper.js\n * Created : 13/04/2015\n * By : Francesc Busquets <francesc@gmail.com>\n *\n * JClic.js\n * An HTML5 player of JClic activities\n * https://projectestac.github.io/jclic.js\n *\n * @source https://github.com/projectestac/jclic.js\n *\n * @license EUPL-1.2\n * @licstart\n * (c) 2000-2020 Educational Telematic Network of Catalonia (XTEC)\n *\n * Licensed under the EUPL, Version 1.1 or -as soon they will be approved by\n * the European Commission- subsequent versions of the EUPL (the \"Licence\");\n * You may not use this work except in compliance with the Licence.\n *\n * You may obtain a copy of the Licence at:\n * https://joinup.ec.europa.eu/software/page/eupl\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the Licence is distributed on an \"AS IS\" basis, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n * Licence for the specific language governing permissions and limitations\n * under the Licence.\n * @licend\n * @module\n */\n\nimport $ from 'jquery';\nimport { log, attrForEach, getBoolean, getAttr, setAttr } from '../Utils.js';\nimport { Shape, Rectangle, Ellipse, PathStroke, Path } from '../AWT.js';\n\n/**\n * The function of this class and its subclasses is to draw a set of \"shapes\" that will be used to\n * place {@link module:boxes/ActiveBox.ActiveBox ActiveBox} objects at a specific position, and to determine its dimension and\n * appearance.\n */\nexport class Shaper {\n /**\n * Shaper constructor\n * @param {number} nx - Number of columns (in grid-based shapers)\n * @param {number} ny - Number of rows (in grid-based shapers)\n */\n constructor(nx, ny) {\n this.reset(nx, ny);\n }\n\n /**\n * Registers a new type of shaper\n * @param {string} shaperName - The name used to identify this shaper\n * @param {function} shaperClass - The shaper class, usually extending Shaper\n * @returns {module:shapers/Shaper.Shaper} - The provided shaper class\n */\n static registerClass(shaperName, shaperClass) {\n Shaper.CLASSES[shaperName] = shaperClass;\n return shaperClass;\n }\n\n /**\n * Factory constructor that returns a Shaper of the requested class.\n * @param {string} className - The class name of the requested Shaper.\n * @param {number} nx - Number of columns (in grid-based shapers)\n * @param {number} ny - Number of rows (in grid-based shapers)\n * @returns {module:shapers/Shaper.Shaper}\n */\n static getShaper(className, nx, ny) {\n const cl = Shaper.CLASSES[(className || '').replace(/^edu\\.xtec\\.jclic\\.shapers\\./, '@')];\n if (!cl)\n log('error', `Unknown shaper: ${className}`);\n return cl ? new cl(nx, ny) : null;\n }\n\n /**\n * Initializes this Shaper to default values\n * @param {number} nCols - Number of columns\n * @param {number} nRows - Number of rows\n */\n reset(nCols, nRows) {\n this.nCols = nCols;\n this.nRows = nRows;\n this.nCells = nRows * nCols;\n this.initiated = false;\n this.shapeData = [];\n for (let i = 0; i < this.nCells; i++)\n this.shapeData[i] = new Shape();\n }\n\n /**\n * Loads this shaper settings from a specific JQuery XML element\n * @param {external:jQuery} $xml - The XML element with the shaper data\n */\n setProperties($xml) {\n attrForEach($xml.get(0).attributes, (name, value) => {\n switch (name) {\n case 'class':\n this.className = value;\n break;\n case 'cols':\n this.nCols = Number(value);\n break;\n case 'rows':\n this.nRows = Number(value);\n break;\n case 'baseWidthFactor':\n case 'toothHeightFactor':\n case 'scaleX':\n case 'scaleY':\n this[name] = Number(value);\n break;\n case 'randomLines':\n case 'showEnclosure':\n this[name] = getBoolean(value, true);\n break;\n }\n });\n\n // Reads the 'enclosing'\n // (main shape area where the other shape elements are placed)\n $xml.children('enclosing:first').each((_n, child) => {\n $(child).children('shape:first').each((_n, child2) => {\n let sh = Shaper.readShapeData(child2, this.scaleX, this.scaleY);\n this.enclosing = sh;\n this.showEnclosure = true;\n this.hasRemainder = true;\n });\n });\n\n // Read the shape elements\n $xml.children('shape').each((n, child) => {\n this.shapeData[n] = Shaper.readShapeData(child, this.scaleX, this.scaleY);\n });\n\n // Correction needed for '@Holes' shaper\n if (this.shapeData.length > 0 /* && this.shapeData.length !== this.nRows * this.nCols */) {\n //this.nRows = this.shapeData.length\n //this.nCols = 1\n //this.nCells = this.nCols * this.nRows\n this.nCells = this.shapeData.length;\n }\n return this;\n }\n\n /**\n * Reads an individual shape from an XML element.\n * Shapes are arrays of `stroke` objects.\n * Each `stroke` has an `action` (_move to_, _line to_, _quad to_...) and associated `data`.\n * @param {external:jQuery} $xml - The XML element with the shape data\n * @param {number} scaleX\n * @param {number} scaleY\n * @returns {module:AWT.Shape}\n */\n static readShapeData(xml, scaleX, scaleY) {\n const shd = [];\n let result = null;\n $.each(xml.textContent.split('|'), (_n, txt) => {\n const sd = txt.split(':');\n // Possible strokes are: `rectangle`, `ellipse`, `M`, `L`, `Q`, `B`, `X`\n // Also possible, but not currently used in JClic: `roundRectangle` and `pie`\n let data = sd.length > 1 ? sd[1].split(',') : null;\n //\n // Data should be always divided by the scale (X or Y)\n if (data)\n data = data.map((d, n) => d / (n % 2 ? scaleY : scaleX));\n\n switch (sd[0]) {\n case 'rectangle':\n result = new Rectangle(data[0], data[1], data[2], data[3]);\n break;\n case 'ellipse':\n result = new Ellipse(data[0], data[1], data[2], data[3]);\n break;\n default:\n // It's an `AWT.PathStroke`\n shd.push(new PathStroke(sd[0], data));\n break;\n }\n });\n\n return !result && shd.length > 0 ? new Path(shd) : result;\n }\n\n /**\n * Gets a object with the basic attributes needed to rebuild this instance excluding functions,\n * parent references, constants and also attributes retaining the default value.\n * The resulting object is commonly usued to serialize elements in JSON format.\n * @returns {object} - The resulting object, with minimal attrributes\n */\n getAttributes() {\n const fields = [\n 'className', 'nCols', 'nRows',\n 'baseWidthFactor', 'toothHeightFactor',\n 'scaleX', 'scaleY',\n 'randomLines',\n ];\n\n if (this.customShapes) {\n ['showEnclosure', 'hasRemainder',\n 'enclosing', 'shapeData', // Array of AWT.Rectangle, AWT.Ellipse or (AWT.Path -> AWT.PathStroke)\n ].forEach(f => fields.push(f));\n }\n\n return getAttr(this, fields);\n }\n\n /**\n * Builds a new shaper, based on the properties specified in a data object\n * @param {object} data - The data object to be parsed\n * @returns {module:shapers/Shaper.Shaper}\n */\n static factory(data) {\n const result = Shaper.getShaper(data.className, data.nCols, data.nRows);\n setAttr(result, data, [\n 'className', 'nCols', 'nRows',\n 'baseWidthFactor', 'toothHeightFactor',\n 'scaleX', 'scaleY',\n 'randomLines',\n 'showEnclosure', 'hasRemainder',\n { key: 'enclosing', fn: Shape },\n { key: 'shapeData', fn: Shape, group: 'array' },\n ]);\n\n result.nCells = result.shapeData.length || result.nCols * result.nRows;\n\n return result;\n }\n\n /**\n * Builds the individual shapes that will form this Shaper\n */\n buildShapes() {\n }\n\n /**\n * Gets a clone of the nth Shape object, scaled and located inside a Rectangle\n * @param {number} n\n * @param {module:AWT.Rectangle} rect\n * @returns {module:AWT.Shape}\n */\n getShape(n, rect) {\n if (!this.initiated)\n this.buildShapes();\n if (n >= this.nCells || this.shapeData[n] === null)\n return null;\n return this.shapeData[n].getShape(rect);\n }\n\n /**\n * Gets the nth Shape data object\n * @param {number} n\n * @returns {object}\n */\n getShapeData(n) {\n return n >= 0 && n < this.shapeData.length ? this.shapeData[n] : null;\n }\n\n /**\n * Gets the AWT.Rectangle that contains all shapes of this Shaper.\n * @returns {module:AWT.Rectangle}\n */\n getEnclosingShapeData() {\n return new Rectangle(0, 0, 1, 1);\n }\n\n /**\n * When `hasRemainder` is true, this method gets the rectangle containing the full surface where\n * the Shaper develops.\n * @param {module:AWT.Rectangle} rect - The frame where to move and scale all the shapes\n * @returns {module:AWT.Rectangle}\n */\n getRemainderShape(rect) {\n if (!this.hasRemainder)\n return null;\n\n if (!this.initiated)\n this.buildShapes();\n\n const sh = this.getEnclosingShapeData();\n const r = sh ? sh.getShape(rect) : new Rectangle();\n for (let i = 0; i < this.nCells; i++) {\n if (this.shapeData[i])\n r.add(this.shapeData[i].getShape(rect), false);\n }\n return r;\n }\n}\n\nObject.assign(Shaper.prototype, {\n /**\n * This shaper class name\n * @name module:shapers/Shaper.Shaper#className\n * @type {string} */\n className: 'Shaper',\n /**\n * Number of columns (useful in grid-based shapers)\n * @name module:shapers/Shaper.Shaper#nCols\n * @type {number} */\n nCols: 0,\n /**\n * Number of rows (useful in grid-based shapers)\n * @name module:shapers/Shaper.Shaper#nRows\n * @type {number} */\n nRows: 0,\n /**\n * Number of cells managed by this shaper\n * @name module:shapers/Shaper.Shaper#nCells\n * @type {number} */\n nCells: 0,\n /**\n * Contains the specific definition of each shape\n * @name module:shapers/Shaper.Shaper#shapeData\n * @type {object} */\n shapeData: null,\n /**\n * Flag used to check if the `Shaper` has been initialized against a real surface\n * @name module:shapers/Shaper.Shaper#initiated\n * @type {boolean} */\n initiated: false,\n //\n // Fields used only in JigSaw shapers\n /**\n * In {@link module:shapers/JigSaw.JigSaw JigSaw}, ratio between the base width of the tooth and the total length of the side.\n * @name module:shapers/Shaper.Shaper#baseWidthFactor\n * @type {number} */\n baseWidthFactor: 1.0 / 3,\n /**\n * In {@link module:shapers/JigSaw.JigSaw JigSaw}, ratio between the tooth height and the total length of the side.\n * @name module:shapers/Shaper.Shaper#toothHeightFactor\n * @type {number} */\n toothHeightFactor: 1.0 / 6,\n /**\n * In {@link module:shapers/JigSaw.JigSaw JigSaw}, whether the tooths take random directions or not\n * @name module:shapers/Shaper.Shaper#randomLines\n * @type {boolean} */\n randomLines: false,\n //\n // Fields used only in the `Holes` shaper\n /**\n * In {@link module:shapers/Holes.Holes Holes}, scale to be applied to horizontal positions and lengths to achieve the real\n * value of the shape placed on a real surface.\n * @name module:shapers/Shaper.Shaper#scaleX\n * @type {number} */\n scaleX: 1.0,\n /**\n * In {@link module:shapers/Holes.Holes Holes}, scale to be applied to vertical positions and lengths to achieve the real\n * value of the shape placed on a real surface.\n * @name module:shapers/Shaper.Shaper#scaleY\n * @type {number} */\n scaleY: 1.0,\n /**\n * In {@link module:shapers/Holes.Holes Holes}, the enclosing area where all shapes are placed.\n * @name module:shapers/Shaper.Shaper#enclosing\n * @type {module:AWT.Shape} */\n enclosing: null,\n /**\n * In {@link module:shapers/Holes.Holes Holes}, when `true`, the enclosing area will be drawn\n * @name module:shapers/Shaper.Shaper#showEnclosure\n * @type {boolean} */\n showEnclosure: false,\n /**\n * Flag indicating if this shaper organizes its cells in rows and columns\n * @name module:shapers/Shaper.Shaper#rectangularShapes\n * @type {boolean} */\n rectangularShapes: false,\n /**\n * Flag indicating if this Shaper deploys over a surface biggest than the rectangle enclosing\n * all its shapes\n * @name module:shapers/Shaper.Shaper#hasRemainder\n * @type {boolean} */\n hasRemainder: false,\n /**\n * Only the `Holes` shaper has this flag activated\n * @name module:shapers/Shaper.Shaper#customShapes\n * @type {boolean} */\n customShapes: false,\n});\n\n/**\n * List of known classes derived from Shaper. It should be filled by real shaper classes at\n * declaration time.\n * @type {object} */\nShaper.CLASSES = {};\n\nexport default Shaper;\n"],"names":[],"sourceRoot":""}