@nice2dev/ui-graphics 1.0.4 → 1.0.5

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 (183) hide show
  1. package/dist/cjs/animation/AnimationEditor.js +1 -1
  2. package/dist/cjs/animation/Audience.js +1 -1
  3. package/dist/cjs/core/LocalUI.js +1 -1
  4. package/dist/cjs/core/yjsCollaboration.js +2 -2
  5. package/dist/cjs/core/yjsCollaboration.js.map +1 -1
  6. package/dist/cjs/game/GameAsset2dEditor.js +1 -1
  7. package/dist/cjs/node_modules/lib0/array.js +103 -0
  8. package/dist/cjs/node_modules/lib0/array.js.map +1 -0
  9. package/dist/cjs/node_modules/lib0/binary.js +42 -0
  10. package/dist/cjs/node_modules/lib0/binary.js.map +1 -0
  11. package/dist/cjs/node_modules/lib0/broadcastchannel.js +121 -0
  12. package/dist/cjs/node_modules/lib0/broadcastchannel.js.map +1 -0
  13. package/dist/cjs/node_modules/lib0/buffer.js +103 -0
  14. package/dist/cjs/node_modules/lib0/buffer.js.map +1 -0
  15. package/dist/cjs/node_modules/lib0/conditions.js +18 -0
  16. package/dist/cjs/node_modules/lib0/conditions.js.map +1 -0
  17. package/dist/cjs/node_modules/lib0/decoding.js +460 -0
  18. package/dist/cjs/node_modules/lib0/decoding.js.map +1 -0
  19. package/dist/cjs/node_modules/lib0/dom.js +55 -0
  20. package/dist/cjs/node_modules/lib0/dom.js.map +1 -0
  21. package/dist/cjs/node_modules/lib0/encoding.js +688 -0
  22. package/dist/cjs/node_modules/lib0/encoding.js.map +1 -0
  23. package/dist/cjs/node_modules/lib0/environment.js +129 -0
  24. package/dist/cjs/node_modules/lib0/environment.js.map +1 -0
  25. package/dist/cjs/node_modules/lib0/error.js +37 -0
  26. package/dist/cjs/node_modules/lib0/error.js.map +1 -0
  27. package/dist/cjs/node_modules/lib0/function.js +135 -0
  28. package/dist/cjs/node_modules/lib0/function.js.map +1 -0
  29. package/dist/cjs/node_modules/lib0/iterator.js +52 -0
  30. package/dist/cjs/node_modules/lib0/iterator.js.map +1 -0
  31. package/dist/cjs/node_modules/lib0/logging.common.js +63 -0
  32. package/dist/cjs/node_modules/lib0/logging.common.js.map +1 -0
  33. package/dist/cjs/node_modules/lib0/logging.js +128 -0
  34. package/dist/cjs/node_modules/lib0/logging.js.map +1 -0
  35. package/dist/cjs/node_modules/lib0/map.js +108 -0
  36. package/dist/cjs/node_modules/lib0/map.js.map +1 -0
  37. package/dist/cjs/node_modules/lib0/math.js +44 -0
  38. package/dist/cjs/node_modules/lib0/math.js.map +1 -0
  39. package/dist/cjs/node_modules/lib0/number.js +21 -0
  40. package/dist/cjs/node_modules/lib0/number.js.map +1 -0
  41. package/dist/cjs/node_modules/lib0/object.js +132 -0
  42. package/dist/cjs/node_modules/lib0/object.js.map +1 -0
  43. package/dist/cjs/node_modules/lib0/observable.js +168 -0
  44. package/dist/cjs/node_modules/lib0/observable.js.map +1 -0
  45. package/dist/cjs/node_modules/lib0/pair.js +33 -0
  46. package/dist/cjs/node_modules/lib0/pair.js.map +1 -0
  47. package/dist/cjs/node_modules/lib0/prng.js +95 -0
  48. package/dist/cjs/node_modules/lib0/prng.js.map +1 -0
  49. package/dist/cjs/node_modules/lib0/promise.js +33 -0
  50. package/dist/cjs/node_modules/lib0/promise.js.map +1 -0
  51. package/dist/cjs/node_modules/lib0/random.js +28 -0
  52. package/dist/cjs/node_modules/lib0/random.js.map +1 -0
  53. package/dist/cjs/node_modules/lib0/schema.js +1168 -0
  54. package/dist/cjs/node_modules/lib0/schema.js.map +1 -0
  55. package/dist/cjs/node_modules/lib0/set.js +12 -0
  56. package/dist/cjs/node_modules/lib0/set.js.map +1 -0
  57. package/dist/cjs/node_modules/lib0/storage.js +79 -0
  58. package/dist/cjs/node_modules/lib0/storage.js.map +1 -0
  59. package/dist/cjs/node_modules/lib0/string.js +94 -0
  60. package/dist/cjs/node_modules/lib0/string.js.map +1 -0
  61. package/dist/cjs/node_modules/lib0/symbol.js +15 -0
  62. package/dist/cjs/node_modules/lib0/symbol.js.map +1 -0
  63. package/dist/cjs/node_modules/lib0/time.js +18 -0
  64. package/dist/cjs/node_modules/lib0/time.js.map +1 -0
  65. package/dist/cjs/node_modules/lib0/trait/equality.js +32 -0
  66. package/dist/cjs/node_modules/lib0/trait/equality.js.map +1 -0
  67. package/dist/cjs/node_modules/lib0/url.js +20 -0
  68. package/dist/cjs/node_modules/lib0/url.js.map +1 -0
  69. package/dist/cjs/node_modules/lib0/webcrypto.js +8 -0
  70. package/dist/cjs/node_modules/lib0/webcrypto.js.map +1 -0
  71. package/dist/cjs/node_modules/y-protocols/auth.js +27 -0
  72. package/dist/cjs/node_modules/y-protocols/auth.js.map +1 -0
  73. package/dist/cjs/node_modules/y-protocols/awareness.js +277 -0
  74. package/dist/cjs/node_modules/y-protocols/awareness.js.map +1 -0
  75. package/dist/cjs/node_modules/y-protocols/sync.js +149 -0
  76. package/dist/cjs/node_modules/y-protocols/sync.js.map +1 -0
  77. package/dist/cjs/node_modules/y-websocket/src/y-websocket.js +521 -0
  78. package/dist/cjs/node_modules/y-websocket/src/y-websocket.js.map +1 -0
  79. package/dist/cjs/node_modules/yjs/dist/yjs.js +10399 -0
  80. package/dist/cjs/node_modules/yjs/dist/yjs.js.map +1 -0
  81. package/dist/cjs/packages/ui/dist/index.js +65997 -0
  82. package/dist/cjs/packages/ui/dist/index.js.map +1 -0
  83. package/dist/cjs/pixel/PixelEditor.js +1 -1
  84. package/dist/cjs/pixel/PixelEditorMenuBar.js +1 -1
  85. package/dist/cjs/pixel/PixelEditorRightPanel.js +1 -1
  86. package/dist/cjs/pixel/PixelEditorTimeline.js +1 -1
  87. package/dist/cjs/pixel/PixelEditorToolbar.js +1 -1
  88. package/dist/cjs/pixel/SpriteGeneratorPanel.js +1 -1
  89. package/dist/cjs/vector/VectorEditor.js +1 -1
  90. package/dist/cjs/vector/VectorEditorMenuBar.js +1 -1
  91. package/dist/cjs/vector/VectorEditorRightPanel.js +1 -1
  92. package/dist/esm/animation/AnimationEditor.js +5 -5
  93. package/dist/esm/animation/Audience.js +2 -2
  94. package/dist/esm/core/LocalUI.js +4 -4
  95. package/dist/esm/core/yjsCollaboration.js +2 -2
  96. package/dist/esm/core/yjsCollaboration.js.map +1 -1
  97. package/dist/esm/game/GameAsset2dEditor.js +19 -19
  98. package/dist/esm/node_modules/lib0/array.js +95 -0
  99. package/dist/esm/node_modules/lib0/array.js.map +1 -0
  100. package/dist/esm/node_modules/lib0/binary.js +30 -0
  101. package/dist/esm/node_modules/lib0/binary.js.map +1 -0
  102. package/dist/esm/node_modules/lib0/broadcastchannel.js +117 -0
  103. package/dist/esm/node_modules/lib0/broadcastchannel.js.map +1 -0
  104. package/dist/esm/node_modules/lib0/buffer.js +96 -0
  105. package/dist/esm/node_modules/lib0/buffer.js.map +1 -0
  106. package/dist/esm/node_modules/lib0/conditions.js +16 -0
  107. package/dist/esm/node_modules/lib0/conditions.js.map +1 -0
  108. package/dist/esm/node_modules/lib0/decoding.js +439 -0
  109. package/dist/esm/node_modules/lib0/decoding.js.map +1 -0
  110. package/dist/esm/node_modules/lib0/dom.js +48 -0
  111. package/dist/esm/node_modules/lib0/dom.js.map +1 -0
  112. package/dist/esm/node_modules/lib0/encoding.js +663 -0
  113. package/dist/esm/node_modules/lib0/encoding.js.map +1 -0
  114. package/dist/esm/node_modules/lib0/environment.js +121 -0
  115. package/dist/esm/node_modules/lib0/environment.js.map +1 -0
  116. package/dist/esm/node_modules/lib0/error.js +33 -0
  117. package/dist/esm/node_modules/lib0/error.js.map +1 -0
  118. package/dist/esm/node_modules/lib0/function.js +130 -0
  119. package/dist/esm/node_modules/lib0/function.js.map +1 -0
  120. package/dist/esm/node_modules/lib0/iterator.js +48 -0
  121. package/dist/esm/node_modules/lib0/iterator.js.map +1 -0
  122. package/dist/esm/node_modules/lib0/logging.common.js +52 -0
  123. package/dist/esm/node_modules/lib0/logging.common.js.map +1 -0
  124. package/dist/esm/node_modules/lib0/logging.js +115 -0
  125. package/dist/esm/node_modules/lib0/logging.js.map +1 -0
  126. package/dist/esm/node_modules/lib0/map.js +102 -0
  127. package/dist/esm/node_modules/lib0/map.js.map +1 -0
  128. package/dist/esm/node_modules/lib0/math.js +37 -0
  129. package/dist/esm/node_modules/lib0/math.js.map +1 -0
  130. package/dist/esm/node_modules/lib0/number.js +17 -0
  131. package/dist/esm/node_modules/lib0/number.js.map +1 -0
  132. package/dist/esm/node_modules/lib0/object.js +119 -0
  133. package/dist/esm/node_modules/lib0/object.js.map +1 -0
  134. package/dist/esm/node_modules/lib0/observable.js +165 -0
  135. package/dist/esm/node_modules/lib0/observable.js.map +1 -0
  136. package/dist/esm/node_modules/lib0/pair.js +30 -0
  137. package/dist/esm/node_modules/lib0/pair.js.map +1 -0
  138. package/dist/esm/node_modules/lib0/prng.js +87 -0
  139. package/dist/esm/node_modules/lib0/prng.js.map +1 -0
  140. package/dist/esm/node_modules/lib0/promise.js +31 -0
  141. package/dist/esm/node_modules/lib0/promise.js.map +1 -0
  142. package/dist/esm/node_modules/lib0/random.js +25 -0
  143. package/dist/esm/node_modules/lib0/random.js.map +1 -0
  144. package/dist/esm/node_modules/lib0/schema.js +1113 -0
  145. package/dist/esm/node_modules/lib0/schema.js.map +1 -0
  146. package/dist/esm/node_modules/lib0/set.js +10 -0
  147. package/dist/esm/node_modules/lib0/set.js.map +1 -0
  148. package/dist/esm/node_modules/lib0/storage.js +75 -0
  149. package/dist/esm/node_modules/lib0/storage.js.map +1 -0
  150. package/dist/esm/node_modules/lib0/string.js +85 -0
  151. package/dist/esm/node_modules/lib0/string.js.map +1 -0
  152. package/dist/esm/node_modules/lib0/symbol.js +13 -0
  153. package/dist/esm/node_modules/lib0/symbol.js.map +1 -0
  154. package/dist/esm/node_modules/lib0/time.js +16 -0
  155. package/dist/esm/node_modules/lib0/time.js.map +1 -0
  156. package/dist/esm/node_modules/lib0/trait/equality.js +29 -0
  157. package/dist/esm/node_modules/lib0/trait/equality.js.map +1 -0
  158. package/dist/esm/node_modules/lib0/url.js +18 -0
  159. package/dist/esm/node_modules/lib0/url.js.map +1 -0
  160. package/dist/esm/node_modules/lib0/webcrypto.js +6 -0
  161. package/dist/esm/node_modules/lib0/webcrypto.js.map +1 -0
  162. package/dist/esm/node_modules/y-protocols/auth.js +24 -0
  163. package/dist/esm/node_modules/y-protocols/auth.js.map +1 -0
  164. package/dist/esm/node_modules/y-protocols/awareness.js +271 -0
  165. package/dist/esm/node_modules/y-protocols/awareness.js.map +1 -0
  166. package/dist/esm/node_modules/y-protocols/sync.js +138 -0
  167. package/dist/esm/node_modules/y-protocols/sync.js.map +1 -0
  168. package/dist/esm/node_modules/y-websocket/src/y-websocket.js +515 -0
  169. package/dist/esm/node_modules/y-websocket/src/y-websocket.js.map +1 -0
  170. package/dist/esm/node_modules/yjs/dist/yjs.js +10295 -0
  171. package/dist/esm/node_modules/yjs/dist/yjs.js.map +1 -0
  172. package/dist/esm/packages/ui/dist/index.js +65571 -0
  173. package/dist/esm/packages/ui/dist/index.js.map +1 -0
  174. package/dist/esm/pixel/PixelEditor.js +3 -3
  175. package/dist/esm/pixel/PixelEditorMenuBar.js +2 -2
  176. package/dist/esm/pixel/PixelEditorRightPanel.js +3 -3
  177. package/dist/esm/pixel/PixelEditorTimeline.js +2 -2
  178. package/dist/esm/pixel/PixelEditorToolbar.js +2 -2
  179. package/dist/esm/pixel/SpriteGeneratorPanel.js +8 -8
  180. package/dist/esm/vector/VectorEditor.js +3 -3
  181. package/dist/esm/vector/VectorEditorMenuBar.js +3 -3
  182. package/dist/esm/vector/VectorEditorRightPanel.js +13 -13
  183. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prng.js","sources":["../../../../../../node_modules/lib0/prng.js"],"sourcesContent":["/**\n * Fast Pseudo Random Number Generators.\n *\n * Given a seed a PRNG generates a sequence of numbers that cannot be reasonably predicted.\n * Two PRNGs must generate the same random sequence of numbers if given the same seed.\n *\n * @module prng\n */\n\nimport * as binary from './binary.js'\nimport { fromCharCode, fromCodePoint } from './string.js'\nimport * as math from './math.js'\nimport { Xoroshiro128plus } from './prng/Xoroshiro128plus.js'\nimport * as buffer from './buffer.js'\n\n/**\n * Description of the function\n * @callback generatorNext\n * @return {number} A random float in the cange of [0,1)\n */\n\n/**\n * A random type generator.\n *\n * @typedef {Object} PRNG\n * @property {generatorNext} next Generate new number\n */\nexport const DefaultPRNG = Xoroshiro128plus\n\n/**\n * Create a Xoroshiro128plus Pseudo-Random-Number-Generator.\n * This is the fastest full-period generator passing BigCrush without systematic failures.\n * But there are more PRNGs available in ./PRNG/.\n *\n * @param {number} seed A positive 32bit integer. Do not use negative numbers.\n * @return {PRNG}\n */\nexport const create = seed => new DefaultPRNG(seed)\n\n/**\n * Generates a single random bool.\n *\n * @param {PRNG} gen A random number generator.\n * @return {Boolean} A random boolean\n */\nexport const bool = gen => (gen.next() >= 0.5)\n\n/**\n * Generates a random integer with 53 bit resolution.\n *\n * @param {PRNG} gen A random number generator.\n * @param {Number} min The lower bound of the allowed return values (inclusive).\n * @param {Number} max The upper bound of the allowed return values (inclusive).\n * @return {Number} A random integer on [min, max]\n */\nexport const int53 = (gen, min, max) => math.floor(gen.next() * (max + 1 - min) + min)\n\n/**\n * Generates a random integer with 53 bit resolution.\n *\n * @param {PRNG} gen A random number generator.\n * @param {Number} min The lower bound of the allowed return values (inclusive).\n * @param {Number} max The upper bound of the allowed return values (inclusive).\n * @return {Number} A random integer on [min, max]\n */\nexport const uint53 = (gen, min, max) => math.abs(int53(gen, min, max))\n\n/**\n * Generates a random integer with 32 bit resolution.\n *\n * @param {PRNG} gen A random number generator.\n * @param {Number} min The lower bound of the allowed return values (inclusive).\n * @param {Number} max The upper bound of the allowed return values (inclusive).\n * @return {Number} A random integer on [min, max]\n */\nexport const int32 = (gen, min, max) => math.floor(gen.next() * (max + 1 - min) + min)\n\n/**\n * Generates a random integer with 53 bit resolution.\n *\n * @param {PRNG} gen A random number generator.\n * @param {Number} min The lower bound of the allowed return values (inclusive).\n * @param {Number} max The upper bound of the allowed return values (inclusive).\n * @return {Number} A random integer on [min, max]\n */\nexport const uint32 = (gen, min, max) => int32(gen, min, max) >>> 0\n\n/**\n * @deprecated\n * Optimized version of prng.int32. It has the same precision as prng.int32, but should be preferred when\n * openaring on smaller ranges.\n *\n * @param {PRNG} gen A random number generator.\n * @param {Number} min The lower bound of the allowed return values (inclusive).\n * @param {Number} max The upper bound of the allowed return values (inclusive). The max inclusive number is `binary.BITS31-1`\n * @return {Number} A random integer on [min, max]\n */\nexport const int31 = (gen, min, max) => int32(gen, min, max)\n\n/**\n * Generates a random real on [0, 1) with 53 bit resolution.\n *\n * @param {PRNG} gen A random number generator.\n * @return {Number} A random real number on [0, 1).\n */\nexport const real53 = gen => gen.next() // (((gen.next() >>> 5) * binary.BIT26) + (gen.next() >>> 6)) / MAX_SAFE_INTEGER\n\n/**\n * Generates a random character from char code 32 - 126. I.e. Characters, Numbers, special characters, and Space:\n *\n * @param {PRNG} gen A random number generator.\n * @return {string}\n *\n * (Space)!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[/]^_`abcdefghijklmnopqrstuvwxyz{|}~\n */\nexport const char = gen => fromCharCode(int31(gen, 32, 126))\n\n/**\n * @param {PRNG} gen\n * @return {string} A single letter (a-z)\n */\nexport const letter = gen => fromCharCode(int31(gen, 97, 122))\n\n/**\n * @param {PRNG} gen\n * @param {number} [minLen=0]\n * @param {number} [maxLen=20]\n * @return {string} A random word (0-20 characters) without spaces consisting of letters (a-z)\n */\nexport const word = (gen, minLen = 0, maxLen = 20) => {\n const len = int31(gen, minLen, maxLen)\n let str = ''\n for (let i = 0; i < len; i++) {\n str += letter(gen)\n }\n return str\n}\n\n/**\n * TODO: this function produces invalid runes. Does not cover all of utf16!!\n *\n * @param {PRNG} gen\n * @return {string}\n */\nexport const utf16Rune = gen => {\n const codepoint = int31(gen, 0, 256)\n return fromCodePoint(codepoint)\n}\n\n/**\n * @param {PRNG} gen\n * @param {number} [maxlen = 20]\n */\nexport const utf16String = (gen, maxlen = 20) => {\n const len = int31(gen, 0, maxlen)\n let str = ''\n for (let i = 0; i < len; i++) {\n str += utf16Rune(gen)\n }\n return str\n}\n\n/**\n * Returns one element of a given array.\n *\n * @param {PRNG} gen A random number generator.\n * @param {Array<T>} array Non empty Array of possible values.\n * @return {T} One of the values of the supplied Array.\n * @template T\n */\nexport const oneOf = (gen, array) => array[int31(gen, 0, array.length - 1)]\n\n/**\n * @param {PRNG} gen\n * @param {number} len\n * @return {Uint8Array<ArrayBuffer>}\n */\nexport const uint8Array = (gen, len) => {\n const buf = buffer.createUint8ArrayFromLen(len)\n for (let i = 0; i < buf.length; i++) {\n buf[i] = int32(gen, 0, binary.BITS8)\n }\n return buf\n}\n\n/* c8 ignore start */\n/**\n * @param {PRNG} gen\n * @param {number} len\n * @return {Uint16Array}\n */\nexport const uint16Array = (gen, len) => new Uint16Array(uint8Array(gen, len * 2).buffer)\n\n/**\n * @param {PRNG} gen\n * @param {number} len\n * @return {Uint32Array}\n */\nexport const uint32Array = (gen, len) => new Uint32Array(uint8Array(gen, len * 4).buffer)\n/* c8 ignore stop */\n"],"names":["math.floor"],"mappings":";;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAgCA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,IAAI,GAAG,GAAG,KAAK,GAAG,CAAC,IAAI,EAAE,IAAI,GAAG;;AAE7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,KAAK,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,KAAKA,KAAU,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG;;AAYrF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,KAAK,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,KAAKA,KAAU,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG;;AAYrF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,KAAK,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,KAAK,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG;;AAoB3D;AACA;AACA;AACA;AACY,MAAC,MAAM,GAAG,GAAG,IAAI,YAAY,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,EAAE,GAAG,CAAC;;AAE7D;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,IAAI,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,EAAE,MAAM,GAAG,EAAE,KAAK;AACtD,EAAE,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM;AACvC,EAAE,IAAI,GAAG,GAAG;AACZ,EAAE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;AAChC,IAAI,GAAG,IAAI,MAAM,CAAC,GAAG;AACrB,EAAE;AACF,EAAE,OAAO;AACT;;AA0BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,KAAK,GAAG,CAAC,GAAG,EAAE,KAAK,KAAK,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;AA6B1E;;;;","x_google_ignoreList":[0]}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Utility helpers to work with promises.
3
+ *
4
+ * @module promise
5
+ */
6
+
7
+
8
+ /**
9
+ * @template T
10
+ * @callback PromiseResolve
11
+ * @param {T|PromiseLike<T>} [result]
12
+ */
13
+
14
+ /**
15
+ * @template T
16
+ * @param {function(PromiseResolve<T>,function(Error):void):any} f
17
+ * @return {Promise<T>}
18
+ */
19
+ const create = f => /** @type {Promise<T>} */ (new Promise(f));
20
+
21
+ /**
22
+ * `Promise.all` wait for all promises in the array to resolve and return the result
23
+ * @template {unknown[] | []} PS
24
+ *
25
+ * @param {PS} ps
26
+ * @return {Promise<{ -readonly [P in keyof PS]: Awaited<PS[P]> }>}
27
+ */
28
+ Promise.all.bind(Promise);
29
+
30
+ export { create };
31
+ //# sourceMappingURL=promise.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promise.js","sources":["../../../../../../node_modules/lib0/promise.js"],"sourcesContent":["/**\n * Utility helpers to work with promises.\n *\n * @module promise\n */\n\nimport * as time from './time.js'\n\n/**\n * @template T\n * @callback PromiseResolve\n * @param {T|PromiseLike<T>} [result]\n */\n\n/**\n * @template T\n * @param {function(PromiseResolve<T>,function(Error):void):any} f\n * @return {Promise<T>}\n */\nexport const create = f => /** @type {Promise<T>} */ (new Promise(f))\n\n/**\n * @param {function(function():void,function(Error):void):void} f\n * @return {Promise<void>}\n */\nexport const createEmpty = f => new Promise(f)\n\n/**\n * `Promise.all` wait for all promises in the array to resolve and return the result\n * @template {unknown[] | []} PS\n *\n * @param {PS} ps\n * @return {Promise<{ -readonly [P in keyof PS]: Awaited<PS[P]> }>}\n */\nexport const all = Promise.all.bind(Promise)\n\n/**\n * @param {Error} [reason]\n * @return {Promise<never>}\n */\nexport const reject = reason => Promise.reject(reason)\n\n/**\n * @template T\n * @param {T|void} res\n * @return {Promise<T|void>}\n */\nexport const resolve = res => Promise.resolve(res)\n\n/**\n * @template T\n * @param {T} res\n * @return {Promise<T>}\n */\nexport const resolveWith = res => Promise.resolve(res)\n\n/**\n * @todo Next version, reorder parameters: check, [timeout, [intervalResolution]]\n * @deprecated use untilAsync instead\n *\n * @param {number} timeout\n * @param {function():boolean} check\n * @param {number} [intervalResolution]\n * @return {Promise<void>}\n */\nexport const until = (timeout, check, intervalResolution = 10) => create((resolve, reject) => {\n const startTime = time.getUnixTime()\n const hasTimeout = timeout > 0\n const untilInterval = () => {\n if (check()) {\n clearInterval(intervalHandle)\n resolve()\n } else if (hasTimeout) {\n /* c8 ignore else */\n if (time.getUnixTime() - startTime > timeout) {\n clearInterval(intervalHandle)\n reject(new Error('Timeout'))\n }\n }\n }\n const intervalHandle = setInterval(untilInterval, intervalResolution)\n})\n\n/**\n * @param {()=>Promise<boolean>|boolean} check\n * @param {number} timeout\n * @param {number} intervalResolution\n * @return {Promise<void>}\n */\nexport const untilAsync = async (check, timeout = 0, intervalResolution = 10) => {\n const startTime = time.getUnixTime()\n const noTimeout = timeout <= 0\n // eslint-disable-next-line no-unmodified-loop-condition\n while (noTimeout || time.getUnixTime() - startTime <= timeout) {\n if (await check()) return\n await wait(intervalResolution)\n }\n throw new Error('Timeout')\n}\n\n/**\n * @param {number} timeout\n * @return {Promise<undefined>}\n */\nexport const wait = timeout => create((resolve, _reject) => setTimeout(resolve, timeout))\n\n/**\n * Checks if an object is a promise using ducktyping.\n *\n * Promises are often polyfilled, so it makes sense to add some additional guarantees if the user of this\n * library has some insane environment where global Promise objects are overwritten.\n *\n * @param {any} p\n * @return {boolean}\n */\nexport const isPromise = p => p instanceof Promise || (p && p.then && p.catch && p.finally)\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;;;AAIA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACY,MAAC,MAAM,GAAG,CAAC,+BAA+B,IAAI,OAAO,CAAC,CAAC,CAAC;;AAQpE;AACA;AACA;AACA;AACA;AACA;AACA;AACmB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO;;;;","x_google_ignoreList":[0]}
@@ -0,0 +1,25 @@
1
+ import { getRandomValues } from './webcrypto.js';
2
+
3
+ /**
4
+ * Isomorphic module for true random numbers / buffers / uuids.
5
+ *
6
+ * Attention: falls back to Math.random if the browser does not support crypto.
7
+ *
8
+ * @module random
9
+ */
10
+
11
+
12
+ const uint32 = () => getRandomValues(new Uint32Array(1))[0];
13
+
14
+ // @ts-ignore
15
+ const uuidv4Template = [1e7] + -1e3 + -4e3 + -8e3 + -1e11;
16
+
17
+ /**
18
+ * @return {string}
19
+ */
20
+ const uuidv4 = () => uuidv4Template.replace(/[018]/g, /** @param {number} c */ c =>
21
+ (c ^ uint32() & 15 >> c / 4).toString(16)
22
+ );
23
+
24
+ export { uint32, uuidv4 };
25
+ //# sourceMappingURL=random.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"random.js","sources":["../../../../../../node_modules/lib0/random.js"],"sourcesContent":["/**\n * Isomorphic module for true random numbers / buffers / uuids.\n *\n * Attention: falls back to Math.random if the browser does not support crypto.\n *\n * @module random\n */\n\nimport * as math from './math.js'\nimport * as binary from './binary.js'\nimport { getRandomValues } from 'lib0/webcrypto'\n\nexport const rand = Math.random\n\nexport const uint32 = () => getRandomValues(new Uint32Array(1))[0]\n\nexport const uint53 = () => {\n const arr = getRandomValues(new Uint32Array(8))\n return (arr[0] & binary.BITS21) * (binary.BITS32 + 1) + (arr[1] >>> 0)\n}\n\n/**\n * @template T\n * @param {Array<T>} arr\n * @return {T}\n */\nexport const oneOf = arr => arr[math.floor(rand() * arr.length)]\n\n// @ts-ignore\nconst uuidv4Template = [1e7] + -1e3 + -4e3 + -8e3 + -1e11\n\n/**\n * @return {string}\n */\nexport const uuidv4 = () => uuidv4Template.replace(/[018]/g, /** @param {number} c */ c =>\n (c ^ uint32() & 15 >> c / 4).toString(16)\n)\n"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAQY,MAAC,MAAM,GAAG,MAAM,eAAe,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;;AAcjE;AACA,MAAM,cAAc,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG;;AAEpD;AACA;AACA;AACY,MAAC,MAAM,GAAG,MAAM,cAAc,CAAC,OAAO,CAAC,QAAQ,2BAA2B,CAAC;AACvF,EAAE,CAAC,CAAC,GAAG,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,EAAE;AAC1C;;;;","x_google_ignoreList":[0]}