@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":"logging.js","sources":["../../../../../../node_modules/lib0/logging.js"],"sourcesContent":["/**\n * Isomorphic logging module with support for colors!\n *\n * @module logging\n */\n\nimport * as env from './environment.js'\nimport * as set from './set.js'\nimport * as pair from './pair.js'\nimport * as dom from './dom.js'\nimport * as json from './json.js'\nimport * as map from './map.js'\nimport * as eventloop from './eventloop.js'\nimport * as math from './math.js'\nimport * as common from './logging.common.js'\n\nexport { BOLD, UNBOLD, BLUE, GREY, GREEN, RED, PURPLE, ORANGE, UNCOLOR } from './logging.common.js'\n\n/**\n * @type {Object<Symbol,pair.Pair<string,string>>}\n */\nconst _browserStyleMap = {\n [common.BOLD]: pair.create('font-weight', 'bold'),\n [common.UNBOLD]: pair.create('font-weight', 'normal'),\n [common.BLUE]: pair.create('color', 'blue'),\n [common.GREEN]: pair.create('color', 'green'),\n [common.GREY]: pair.create('color', 'grey'),\n [common.RED]: pair.create('color', 'red'),\n [common.PURPLE]: pair.create('color', 'purple'),\n [common.ORANGE]: pair.create('color', 'orange'), // not well supported in chrome when debugging node with inspector - TODO: deprecate\n [common.UNCOLOR]: pair.create('color', 'black')\n}\n\n/**\n * @param {Array<string|Symbol|Object|number|function():any>} args\n * @return {Array<string|object|number>}\n */\n/* c8 ignore start */\nconst computeBrowserLoggingArgs = (args) => {\n if (args.length === 1 && args[0]?.constructor === Function) {\n args = /** @type {Array<string|Symbol|Object|number>} */ (/** @type {[function]} */ (args)[0]())\n }\n const strBuilder = []\n const styles = []\n const currentStyle = map.create()\n /**\n * @type {Array<string|Object|number>}\n */\n let logArgs = []\n // try with formatting until we find something unsupported\n let i = 0\n for (; i < args.length; i++) {\n const arg = args[i]\n // @ts-ignore\n const style = _browserStyleMap[arg]\n if (style !== undefined) {\n currentStyle.set(style.left, style.right)\n } else {\n if (arg === undefined) {\n break\n }\n if (arg.constructor === String || arg.constructor === Number) {\n const style = dom.mapToStyleString(currentStyle)\n if (i > 0 || style.length > 0) {\n strBuilder.push('%c' + arg)\n styles.push(style)\n } else {\n strBuilder.push(arg)\n }\n } else {\n break\n }\n }\n }\n if (i > 0) {\n // create logArgs with what we have so far\n logArgs = styles\n logArgs.unshift(strBuilder.join(''))\n }\n // append the rest\n for (; i < args.length; i++) {\n const arg = args[i]\n if (!(arg instanceof Symbol)) {\n logArgs.push(arg)\n }\n }\n return logArgs\n}\n/* c8 ignore stop */\n\n/* c8 ignore start */\nconst computeLoggingArgs = env.supportsColor\n ? computeBrowserLoggingArgs\n : common.computeNoColorLoggingArgs\n/* c8 ignore stop */\n\n/**\n * @param {Array<string|Symbol|Object|number>} args\n */\nexport const print = (...args) => {\n console.log(...computeLoggingArgs(args))\n /* c8 ignore next */\n vconsoles.forEach((vc) => vc.print(args))\n}\n\n/* c8 ignore start */\n/**\n * @param {Array<string|Symbol|Object|number>} args\n */\nexport const warn = (...args) => {\n console.warn(...computeLoggingArgs(args))\n args.unshift(common.ORANGE)\n vconsoles.forEach((vc) => vc.print(args))\n}\n/* c8 ignore stop */\n\n/**\n * @param {Error} err\n */\n/* c8 ignore start */\nexport const printError = (err) => {\n console.error(err)\n vconsoles.forEach((vc) => vc.printError(err))\n}\n/* c8 ignore stop */\n\n/**\n * @param {string} url image location\n * @param {number} height height of the image in pixel\n */\n/* c8 ignore start */\nexport const printImg = (url, height) => {\n if (env.isBrowser) {\n console.log(\n '%c ',\n `font-size: ${height}px; background-size: contain; background-repeat: no-repeat; background-image: url(${url})`\n )\n // console.log('%c ', `font-size: ${height}x; background: url(${url}) no-repeat;`)\n }\n vconsoles.forEach((vc) => vc.printImg(url, height))\n}\n/* c8 ignore stop */\n\n/**\n * @param {string} base64\n * @param {number} height\n */\n/* c8 ignore next 2 */\nexport const printImgBase64 = (base64, height) =>\n printImg(`data:image/gif;base64,${base64}`, height)\n\n/**\n * @param {Array<string|Symbol|Object|number>} args\n */\nexport const group = (...args) => {\n console.group(...computeLoggingArgs(args))\n /* c8 ignore next */\n vconsoles.forEach((vc) => vc.group(args))\n}\n\n/**\n * @param {Array<string|Symbol|Object|number>} args\n */\nexport const groupCollapsed = (...args) => {\n console.groupCollapsed(...computeLoggingArgs(args))\n /* c8 ignore next */\n vconsoles.forEach((vc) => vc.groupCollapsed(args))\n}\n\nexport const groupEnd = () => {\n console.groupEnd()\n /* c8 ignore next */\n vconsoles.forEach((vc) => vc.groupEnd())\n}\n\n/**\n * @param {function():Node} createNode\n */\n/* c8 ignore next 2 */\nexport const printDom = (createNode) =>\n vconsoles.forEach((vc) => vc.printDom(createNode()))\n\n/**\n * @param {HTMLCanvasElement} canvas\n * @param {number} height\n */\n/* c8 ignore next 2 */\nexport const printCanvas = (canvas, height) =>\n printImg(canvas.toDataURL(), height)\n\nexport const vconsoles = set.create()\n\n/**\n * @param {Array<string|Symbol|Object|number>} args\n * @return {Array<Element>}\n */\n/* c8 ignore start */\nconst _computeLineSpans = (args) => {\n const spans = []\n const currentStyle = new Map()\n // try with formatting until we find something unsupported\n let i = 0\n for (; i < args.length; i++) {\n let arg = args[i]\n // @ts-ignore\n const style = _browserStyleMap[arg]\n if (style !== undefined) {\n currentStyle.set(style.left, style.right)\n } else {\n if (arg === undefined) {\n arg = 'undefined '\n }\n if (arg.constructor === String || arg.constructor === Number) {\n // @ts-ignore\n const span = dom.element('span', [\n pair.create('style', dom.mapToStyleString(currentStyle))\n ], [dom.text(arg.toString())])\n if (span.innerHTML === '') {\n span.innerHTML = '&nbsp;'\n }\n spans.push(span)\n } else {\n break\n }\n }\n }\n // append the rest\n for (; i < args.length; i++) {\n let content = args[i]\n if (!(content instanceof Symbol)) {\n if (content.constructor !== String && content.constructor !== Number) {\n content = ' ' + json.stringify(content) + ' '\n }\n spans.push(\n dom.element('span', [], [dom.text(/** @type {string} */ (content))])\n )\n }\n }\n return spans\n}\n/* c8 ignore stop */\n\nconst lineStyle =\n 'font-family:monospace;border-bottom:1px solid #e2e2e2;padding:2px;'\n\n/* c8 ignore start */\nexport class VConsole {\n /**\n * @param {Element} dom\n */\n constructor (dom) {\n this.dom = dom\n /**\n * @type {Element}\n */\n this.ccontainer = this.dom\n this.depth = 0\n vconsoles.add(this)\n }\n\n /**\n * @param {Array<string|Symbol|Object|number>} args\n * @param {boolean} collapsed\n */\n group (args, collapsed = false) {\n eventloop.enqueue(() => {\n const triangleDown = dom.element('span', [\n pair.create('hidden', collapsed),\n pair.create('style', 'color:grey;font-size:120%;')\n ], [dom.text('▼')])\n const triangleRight = dom.element('span', [\n pair.create('hidden', !collapsed),\n pair.create('style', 'color:grey;font-size:125%;')\n ], [dom.text('▶')])\n const content = dom.element(\n 'div',\n [pair.create(\n 'style',\n `${lineStyle};padding-left:${this.depth * 10}px`\n )],\n [triangleDown, triangleRight, dom.text(' ')].concat(\n _computeLineSpans(args)\n )\n )\n const nextContainer = dom.element('div', [\n pair.create('hidden', collapsed)\n ])\n const nextLine = dom.element('div', [], [content, nextContainer])\n dom.append(this.ccontainer, [nextLine])\n this.ccontainer = nextContainer\n this.depth++\n // when header is clicked, collapse/uncollapse container\n dom.addEventListener(content, 'click', (_event) => {\n nextContainer.toggleAttribute('hidden')\n triangleDown.toggleAttribute('hidden')\n triangleRight.toggleAttribute('hidden')\n })\n })\n }\n\n /**\n * @param {Array<string|Symbol|Object|number>} args\n */\n groupCollapsed (args) {\n this.group(args, true)\n }\n\n groupEnd () {\n eventloop.enqueue(() => {\n if (this.depth > 0) {\n this.depth--\n // @ts-ignore\n this.ccontainer = this.ccontainer.parentElement.parentElement\n }\n })\n }\n\n /**\n * @param {Array<string|Symbol|Object|number>} args\n */\n print (args) {\n eventloop.enqueue(() => {\n dom.append(this.ccontainer, [\n dom.element('div', [\n pair.create(\n 'style',\n `${lineStyle};padding-left:${this.depth * 10}px`\n )\n ], _computeLineSpans(args))\n ])\n })\n }\n\n /**\n * @param {Error} err\n */\n printError (err) {\n this.print([common.RED, common.BOLD, err.toString()])\n }\n\n /**\n * @param {string} url\n * @param {number} height\n */\n printImg (url, height) {\n eventloop.enqueue(() => {\n dom.append(this.ccontainer, [\n dom.element('img', [\n pair.create('src', url),\n pair.create('height', `${math.round(height * 1.5)}px`)\n ])\n ])\n })\n }\n\n /**\n * @param {Node} node\n */\n printDom (node) {\n eventloop.enqueue(() => {\n dom.append(this.ccontainer, [node])\n })\n }\n\n destroy () {\n eventloop.enqueue(() => {\n vconsoles.delete(this)\n })\n }\n}\n/* c8 ignore stop */\n\n/**\n * @param {Element} dom\n */\n/* c8 ignore next */\nexport const createVConsole = (dom) => new VConsole(dom)\n\n/**\n * @param {string} moduleName\n * @return {function(...any):void}\n */\nexport const createModuleLogger = (moduleName) => common.createModuleLogger(print, moduleName)\n"],"names":["common.BOLD","pair.create","common.UNBOLD","common.BLUE","common.GREEN","common.GREY","common.RED","common.PURPLE","common.ORANGE","common.UNCOLOR","map.create","dom.mapToStyleString","env.supportsColor","common.computeNoColorLoggingArgs","set.create"],"mappings":"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","x_google_ignoreList":[0]}
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Utility module to work with key-value stores.
3
+ *
4
+ * @module map
5
+ */
6
+
7
+ /**
8
+ * @template K
9
+ * @template V
10
+ * @typedef {Map<K,V>} GlobalMap
11
+ */
12
+
13
+ /**
14
+ * Creates a new Map instance.
15
+ *
16
+ * @function
17
+ * @return {Map<any, any>}
18
+ *
19
+ * @function
20
+ */
21
+ const create = () => new Map();
22
+
23
+ /**
24
+ * Copy a Map object into a fresh Map object.
25
+ *
26
+ * @function
27
+ * @template K,V
28
+ * @param {Map<K,V>} m
29
+ * @return {Map<K,V>}
30
+ */
31
+ const copy = m => {
32
+ const r = create();
33
+ m.forEach((v, k) => { r.set(k, v); });
34
+ return r
35
+ };
36
+
37
+ /**
38
+ * Get map property. Create T if property is undefined and set T on map.
39
+ *
40
+ * ```js
41
+ * const listeners = map.setIfUndefined(events, 'eventName', set.create)
42
+ * listeners.add(listener)
43
+ * ```
44
+ *
45
+ * @function
46
+ * @template {Map<any, any>} MAP
47
+ * @template {MAP extends Map<any,infer V> ? function():V : unknown} CF
48
+ * @param {MAP} map
49
+ * @param {MAP extends Map<infer K,any> ? K : unknown} key
50
+ * @param {CF} createT
51
+ * @return {ReturnType<CF>}
52
+ */
53
+ const setIfUndefined = (map, key, createT) => {
54
+ let set = map.get(key);
55
+ if (set === undefined) {
56
+ map.set(key, set = createT());
57
+ }
58
+ return set
59
+ };
60
+
61
+ /**
62
+ * Creates an Array and populates it with the content of all key-value pairs using the `f(value, key)` function.
63
+ *
64
+ * @function
65
+ * @template K
66
+ * @template V
67
+ * @template R
68
+ * @param {Map<K,V>} m
69
+ * @param {function(V,K):R} f
70
+ * @return {Array<R>}
71
+ */
72
+ const map = (m, f) => {
73
+ const res = [];
74
+ for (const [key, value] of m) {
75
+ res.push(f(value, key));
76
+ }
77
+ return res
78
+ };
79
+
80
+ /**
81
+ * Tests whether any key-value pairs pass the test implemented by `f(value, key)`.
82
+ *
83
+ * @todo should rename to some - similarly to Array.some
84
+ *
85
+ * @function
86
+ * @template K
87
+ * @template V
88
+ * @param {Map<K,V>} m
89
+ * @param {function(V,K):boolean} f
90
+ * @return {boolean}
91
+ */
92
+ const any = (m, f) => {
93
+ for (const [key, value] of m) {
94
+ if (f(value, key)) {
95
+ return true
96
+ }
97
+ }
98
+ return false
99
+ };
100
+
101
+ export { any, copy, create, map, setIfUndefined };
102
+ //# sourceMappingURL=map.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"map.js","sources":["../../../../../../node_modules/lib0/map.js"],"sourcesContent":["/**\n * Utility module to work with key-value stores.\n *\n * @module map\n */\n\n/**\n * @template K\n * @template V\n * @typedef {Map<K,V>} GlobalMap\n */\n\n/**\n * Creates a new Map instance.\n *\n * @function\n * @return {Map<any, any>}\n *\n * @function\n */\nexport const create = () => new Map()\n\n/**\n * Copy a Map object into a fresh Map object.\n *\n * @function\n * @template K,V\n * @param {Map<K,V>} m\n * @return {Map<K,V>}\n */\nexport const copy = m => {\n const r = create()\n m.forEach((v, k) => { r.set(k, v) })\n return r\n}\n\n/**\n * Get map property. Create T if property is undefined and set T on map.\n *\n * ```js\n * const listeners = map.setIfUndefined(events, 'eventName', set.create)\n * listeners.add(listener)\n * ```\n *\n * @function\n * @template {Map<any, any>} MAP\n * @template {MAP extends Map<any,infer V> ? function():V : unknown} CF\n * @param {MAP} map\n * @param {MAP extends Map<infer K,any> ? K : unknown} key\n * @param {CF} createT\n * @return {ReturnType<CF>}\n */\nexport const setIfUndefined = (map, key, createT) => {\n let set = map.get(key)\n if (set === undefined) {\n map.set(key, set = createT())\n }\n return set\n}\n\n/**\n * Creates an Array and populates it with the content of all key-value pairs using the `f(value, key)` function.\n *\n * @function\n * @template K\n * @template V\n * @template R\n * @param {Map<K,V>} m\n * @param {function(V,K):R} f\n * @return {Array<R>}\n */\nexport const map = (m, f) => {\n const res = []\n for (const [key, value] of m) {\n res.push(f(value, key))\n }\n return res\n}\n\n/**\n * Tests whether any key-value pairs pass the test implemented by `f(value, key)`.\n *\n * @todo should rename to some - similarly to Array.some\n *\n * @function\n * @template K\n * @template V\n * @param {Map<K,V>} m\n * @param {function(V,K):boolean} f\n * @return {boolean}\n */\nexport const any = (m, f) => {\n for (const [key, value] of m) {\n if (f(value, key)) {\n return true\n }\n }\n return false\n}\n\n/**\n * Tests whether all key-value pairs pass the test implemented by `f(value, key)`.\n *\n * @function\n * @template K\n * @template V\n * @param {Map<K,V>} m\n * @param {function(V,K):boolean} f\n * @return {boolean}\n */\nexport const all = (m, f) => {\n for (const [key, value] of m) {\n if (!f(value, key)) {\n return false\n }\n }\n return true\n}\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,MAAM,GAAG,MAAM,IAAI,GAAG;;AAEnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,IAAI,GAAG,CAAC,IAAI;AACzB,EAAE,MAAM,CAAC,GAAG,MAAM;AAClB,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAC,CAAC,CAAC;AACrC,EAAE,OAAO;AACT;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,cAAc,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,KAAK;AACrD,EAAE,IAAI,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG;AACvB,EAAE,IAAI,GAAG,KAAK,SAAS,EAAE;AACzB,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,EAAE;AAChC,EAAE;AACF,EAAE,OAAO;AACT;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK;AAC7B,EAAE,MAAM,GAAG,GAAG;AACd,EAAE,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE;AAChC,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,EAAE,GAAG,CAAC;AAC1B,EAAE;AACF,EAAE,OAAO;AACT;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK;AAC7B,EAAE,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE;AAChC,IAAI,IAAI,CAAC,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE;AACvB,MAAM,OAAO;AACb,IAAI;AACJ,EAAE;AACF,EAAE,OAAO;AACT;;;;","x_google_ignoreList":[0]}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Common Math expressions.
3
+ *
4
+ * @module math
5
+ */
6
+
7
+ const floor = Math.floor;
8
+ const abs = Math.abs;
9
+
10
+ /**
11
+ * @function
12
+ * @param {number} a
13
+ * @param {number} b
14
+ * @return {number} The smaller element of a and b
15
+ */
16
+ const min = (a, b) => a < b ? a : b;
17
+
18
+ /**
19
+ * @function
20
+ * @param {number} a
21
+ * @param {number} b
22
+ * @return {number} The bigger element of a and b
23
+ */
24
+ const max = (a, b) => a > b ? a : b;
25
+
26
+ const pow = Math.pow;
27
+
28
+ /**
29
+ * Check whether n is negative, while considering the -0 edge case. While `-0 < 0` is false, this
30
+ * function returns true for -0,-1,,.. and returns false for 0,1,2,...
31
+ * @param {number} n
32
+ * @return {boolean} Wether n is negative. This function also distinguishes between -0 and +0
33
+ */
34
+ const isNegativeZero = n => n !== 0 ? n < 0 : 1 / n < 0;
35
+
36
+ export { abs, floor, isNegativeZero, max, min, pow };
37
+ //# sourceMappingURL=math.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"math.js","sources":["../../../../../../node_modules/lib0/math.js"],"sourcesContent":["/**\n * Common Math expressions.\n *\n * @module math\n */\n\nexport const floor = Math.floor\nexport const ceil = Math.ceil\nexport const abs = Math.abs\nexport const imul = Math.imul\nexport const round = Math.round\nexport const log10 = Math.log10\nexport const log2 = Math.log2\nexport const log = Math.log\nexport const sqrt = Math.sqrt\n\n/**\n * @function\n * @param {number} a\n * @param {number} b\n * @return {number} The sum of a and b\n */\nexport const add = (a, b) => a + b\n\n/**\n * @function\n * @param {number} a\n * @param {number} b\n * @return {number} The smaller element of a and b\n */\nexport const min = (a, b) => a < b ? a : b\n\n/**\n * @function\n * @param {number} a\n * @param {number} b\n * @return {number} The bigger element of a and b\n */\nexport const max = (a, b) => a > b ? a : b\n\nexport const isNaN = Number.isNaN\n\nexport const pow = Math.pow\n/**\n * Base 10 exponential function. Returns the value of 10 raised to the power of pow.\n *\n * @param {number} exp\n * @return {number}\n */\nexport const exp10 = exp => Math.pow(10, exp)\n\nexport const sign = Math.sign\n\n/**\n * Check whether n is negative, while considering the -0 edge case. While `-0 < 0` is false, this\n * function returns true for -0,-1,,.. and returns false for 0,1,2,...\n * @param {number} n\n * @return {boolean} Wether n is negative. This function also distinguishes between -0 and +0\n */\nexport const isNegativeZero = n => n !== 0 ? n < 0 : 1 / n < 0\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEY,MAAC,KAAK,GAAG,IAAI,CAAC;AAEd,MAAC,GAAG,GAAG,IAAI,CAAC;;AAgBxB;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG;;AAEzC;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG;;AAI7B,MAAC,GAAG,GAAG,IAAI,CAAC;;AAWxB;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,cAAc,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG;;;;","x_google_ignoreList":[0]}
@@ -0,0 +1,17 @@
1
+ import { floor } from './math.js';
2
+
3
+ /**
4
+ * Utility helpers for working with numbers.
5
+ *
6
+ * @module number
7
+ */
8
+
9
+
10
+ const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER;
11
+ const MIN_SAFE_INTEGER = Number.MIN_SAFE_INTEGER;
12
+
13
+ /* c8 ignore next */
14
+ const isInteger = Number.isInteger || (num => typeof num === 'number' && isFinite(num) && floor(num) === num);
15
+
16
+ export { MAX_SAFE_INTEGER, MIN_SAFE_INTEGER, isInteger };
17
+ //# sourceMappingURL=number.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"number.js","sources":["../../../../../../node_modules/lib0/number.js"],"sourcesContent":["/**\n * Utility helpers for working with numbers.\n *\n * @module number\n */\n\nimport * as math from './math.js'\nimport * as binary from './binary.js'\n\nexport const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER\nexport const MIN_SAFE_INTEGER = Number.MIN_SAFE_INTEGER\n\nexport const LOWEST_INT32 = 1 << 31\nexport const HIGHEST_INT32 = binary.BITS31\nexport const HIGHEST_UINT32 = binary.BITS32\n\n/* c8 ignore next */\nexport const isInteger = Number.isInteger || (num => typeof num === 'number' && isFinite(num) && math.floor(num) === num)\nexport const isNaN = Number.isNaN\nexport const parseInt = Number.parseInt\n\n/**\n * Count the number of \"1\" bits in an unsigned 32bit number.\n *\n * Super fun bitcount algorithm by Brian Kernighan.\n *\n * @param {number} n\n */\nexport const countBits = n => {\n n &= binary.BITS32\n let count = 0\n while (n) {\n n &= (n - 1)\n count++\n }\n return count\n}\n"],"names":["math.floor"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;;;AAKY,MAAC,gBAAgB,GAAG,MAAM,CAAC;AAC3B,MAAC,gBAAgB,GAAG,MAAM,CAAC;;AAMvC;AACY,MAAC,SAAS,GAAG,MAAM,CAAC,SAAS,KAAK,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,QAAQ,CAAC,GAAG,CAAC,IAAIA,KAAU,CAAC,GAAG,CAAC,KAAK,GAAG;;;;","x_google_ignoreList":[0]}
@@ -0,0 +1,119 @@
1
+ import { equals } from './trait/equality.js';
2
+
3
+ /**
4
+ * @param {any} o
5
+ * @return {o is { [k:string]:any }}
6
+ */
7
+ const isObject = o => typeof o === 'object';
8
+
9
+ /**
10
+ * Object.assign
11
+ */
12
+ const assign = Object.assign;
13
+
14
+ /**
15
+ * @param {Object<string,any>} obj
16
+ */
17
+ const keys = Object.keys;
18
+
19
+ /**
20
+ * @template V
21
+ * @param {{[k:string]:V}} obj
22
+ * @param {function(V,string):any} f
23
+ */
24
+ const forEach = (obj, f) => {
25
+ for (const key in obj) {
26
+ f(obj[key], key);
27
+ }
28
+ };
29
+
30
+ /**
31
+ * @todo implement mapToArray & map
32
+ *
33
+ * @template R
34
+ * @param {Object<string,any>} obj
35
+ * @param {function(any,string):R} f
36
+ * @return {Array<R>}
37
+ */
38
+ const map = (obj, f) => {
39
+ const results = [];
40
+ for (const key in obj) {
41
+ results.push(f(obj[key], key));
42
+ }
43
+ return results
44
+ };
45
+
46
+ /**
47
+ * @param {Object<string,any>} obj
48
+ * @return {number}
49
+ */
50
+ const size = obj => keys(obj).length;
51
+
52
+ /**
53
+ * @param {Object|null|undefined} obj
54
+ */
55
+ const isEmpty = obj => {
56
+ // eslint-disable-next-line no-unreachable-loop
57
+ for (const _k in obj) {
58
+ return false
59
+ }
60
+ return true
61
+ };
62
+
63
+ /**
64
+ * @template {{ [key:string|number|symbol]: any }} T
65
+ * @param {T} obj
66
+ * @param {(v:T[keyof T],k:keyof T)=>boolean} f
67
+ * @return {boolean}
68
+ */
69
+ const every = (obj, f) => {
70
+ for (const key in obj) {
71
+ if (!f(obj[key], key)) {
72
+ return false
73
+ }
74
+ }
75
+ return true
76
+ };
77
+
78
+ /**
79
+ * Calls `Object.prototype.hasOwnProperty`.
80
+ *
81
+ * @param {any} obj
82
+ * @param {string|number|symbol} key
83
+ * @return {boolean}
84
+ */
85
+ const hasProperty = (obj, key) => Object.prototype.hasOwnProperty.call(obj, key);
86
+
87
+ /**
88
+ * @param {Object<string,any>} a
89
+ * @param {Object<string,any>} b
90
+ * @return {boolean}
91
+ */
92
+ const equalFlat = (a, b) => a === b || (size(a) === size(b) && every(a, (val, key) => (val !== undefined || hasProperty(b, key)) && equals(b[key], val)));
93
+
94
+ /**
95
+ * Make an object immutable. This hurts performance and is usually not needed if you perform good
96
+ * coding practices.
97
+ */
98
+ const freeze = Object.freeze;
99
+
100
+ /**
101
+ * Make an object and all its children immutable.
102
+ * This *really* hurts performance and is usually not needed if you perform good coding practices.
103
+ *
104
+ * @template {any} T
105
+ * @param {T} o
106
+ * @return {Readonly<T>}
107
+ */
108
+ const deepFreeze = (o) => {
109
+ for (const key in o) {
110
+ const c = o[key];
111
+ if (typeof c === 'object' || typeof c === 'function') {
112
+ deepFreeze(o[key]);
113
+ }
114
+ }
115
+ return freeze(o)
116
+ };
117
+
118
+ export { assign, deepFreeze, equalFlat, every, forEach, freeze, hasProperty, isEmpty, isObject, keys, map, size };
119
+ //# sourceMappingURL=object.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"object.js","sources":["../../../../../../node_modules/lib0/object.js"],"sourcesContent":["import * as equalityTrait from './trait/equality.js'\n\n/**\n * Utility functions for working with EcmaScript objects.\n *\n * @module object\n */\n\n/**\n * @return {Object<string,any>} obj\n */\nexport const create = () => Object.create(null)\n\n/**\n * @param {any} o\n * @return {o is { [k:string]:any }}\n */\nexport const isObject = o => typeof o === 'object'\n\n/**\n * Object.assign\n */\nexport const assign = Object.assign\n\n/**\n * @param {Object<string,any>} obj\n */\nexport const keys = Object.keys\n\n/**\n * @template V\n * @param {{[key:string]: V}} obj\n * @return {Array<V>}\n */\nexport const values = Object.values\n\n/**\n * @template V\n * @param {{[k:string]:V}} obj\n * @param {function(V,string):any} f\n */\nexport const forEach = (obj, f) => {\n for (const key in obj) {\n f(obj[key], key)\n }\n}\n\n/**\n * @todo implement mapToArray & map\n *\n * @template R\n * @param {Object<string,any>} obj\n * @param {function(any,string):R} f\n * @return {Array<R>}\n */\nexport const map = (obj, f) => {\n const results = []\n for (const key in obj) {\n results.push(f(obj[key], key))\n }\n return results\n}\n\n/**\n * @deprecated use object.size instead\n * @param {Object<string,any>} obj\n * @return {number}\n */\nexport const length = obj => keys(obj).length\n\n/**\n * @param {Object<string,any>} obj\n * @return {number}\n */\nexport const size = obj => keys(obj).length\n\n/**\n * @template {{ [key:string|number|symbol]: any }} T\n * @param {T} obj\n * @param {(v:T[keyof T],k:keyof T)=>boolean} f\n * @return {boolean}\n */\nexport const some = (obj, f) => {\n for (const key in obj) {\n if (f(obj[key], key)) {\n return true\n }\n }\n return false\n}\n\n/**\n * @param {Object|null|undefined} obj\n */\nexport const isEmpty = obj => {\n // eslint-disable-next-line no-unreachable-loop\n for (const _k in obj) {\n return false\n }\n return true\n}\n\n/**\n * @template {{ [key:string|number|symbol]: any }} T\n * @param {T} obj\n * @param {(v:T[keyof T],k:keyof T)=>boolean} f\n * @return {boolean}\n */\nexport const every = (obj, f) => {\n for (const key in obj) {\n if (!f(obj[key], key)) {\n return false\n }\n }\n return true\n}\n\n/**\n * Calls `Object.prototype.hasOwnProperty`.\n *\n * @param {any} obj\n * @param {string|number|symbol} key\n * @return {boolean}\n */\nexport const hasProperty = (obj, key) => Object.prototype.hasOwnProperty.call(obj, key)\n\n/**\n * @param {Object<string,any>} a\n * @param {Object<string,any>} b\n * @return {boolean}\n */\nexport const equalFlat = (a, b) => a === b || (size(a) === size(b) && every(a, (val, key) => (val !== undefined || hasProperty(b, key)) && equalityTrait.equals(b[key], val)))\n\n/**\n * Make an object immutable. This hurts performance and is usually not needed if you perform good\n * coding practices.\n */\nexport const freeze = Object.freeze\n\n/**\n * Make an object and all its children immutable.\n * This *really* hurts performance and is usually not needed if you perform good coding practices.\n *\n * @template {any} T\n * @param {T} o\n * @return {Readonly<T>}\n */\nexport const deepFreeze = (o) => {\n for (const key in o) {\n const c = o[key]\n if (typeof c === 'object' || typeof c === 'function') {\n deepFreeze(o[key])\n }\n }\n return freeze(o)\n}\n\n/**\n * Get object property. Create T if property is undefined and set T on object.\n *\n * @function\n * @template {object} KV\n * @template {keyof KV} [K=keyof KV]\n * @param {KV} o\n * @param {K} key\n * @param {() => KV[K]} createT\n * @return {KV[K]}\n */\nexport const setIfUndefined = (o, key, createT) => hasProperty(o, key) ? o[key] : (o[key] = createT())\n"],"names":["equalityTrait.equals"],"mappings":";;AAaA;AACA;AACA;AACA;AACY,MAAC,QAAQ,GAAG,CAAC,IAAI,OAAO,CAAC,KAAK;;AAE1C;AACA;AACA;AACY,MAAC,MAAM,GAAG,MAAM,CAAC;;AAE7B;AACA;AACA;AACY,MAAC,IAAI,GAAG,MAAM,CAAC;;AAS3B;AACA;AACA;AACA;AACA;AACY,MAAC,OAAO,GAAG,CAAC,GAAG,EAAE,CAAC,KAAK;AACnC,EAAE,KAAK,MAAM,GAAG,IAAI,GAAG,EAAE;AACzB,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,GAAG;AACnB,EAAE;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,GAAG,GAAG,CAAC,GAAG,EAAE,CAAC,KAAK;AAC/B,EAAE,MAAM,OAAO,GAAG;AAClB,EAAE,KAAK,MAAM,GAAG,IAAI,GAAG,EAAE;AACzB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC;AACjC,EAAE;AACF,EAAE,OAAO;AACT;;AASA;AACA;AACA;AACA;AACY,MAAC,IAAI,GAAG,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC;;AAiBrC;AACA;AACA;AACY,MAAC,OAAO,GAAG,GAAG,IAAI;AAC9B;AACA,EAAE,KAAK,MAAM,EAAE,IAAI,GAAG,EAAE;AACxB,IAAI,OAAO;AACX,EAAE;AACF,EAAE,OAAO;AACT;;AAEA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,KAAK,GAAG,CAAC,GAAG,EAAE,CAAC,KAAK;AACjC,EAAE,KAAK,MAAM,GAAG,IAAI,GAAG,EAAE;AACzB,IAAI,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE;AAC3B,MAAM,OAAO;AACb,IAAI;AACJ,EAAE;AACF,EAAE,OAAO;AACT;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,WAAW,GAAG,CAAC,GAAG,EAAE,GAAG,KAAK,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG;;AAEtF;AACA;AACA;AACA;AACA;AACY,MAAC,SAAS,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,GAAG,KAAK,SAAS,IAAI,WAAW,CAAC,CAAC,EAAE,GAAG,CAAC,KAAKA,MAAoB,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;;AAE7K;AACA;AACA;AACA;AACY,MAAC,MAAM,GAAG,MAAM,CAAC;;AAE7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,UAAU,GAAG,CAAC,CAAC,KAAK;AACjC,EAAE,KAAK,MAAM,GAAG,IAAI,CAAC,EAAE;AACvB,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG;AACnB,IAAI,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,UAAU,EAAE;AAC1D,MAAM,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC;AACvB,IAAI;AACJ,EAAE;AACF,EAAE,OAAO,MAAM,CAAC,CAAC;AACjB;;;;","x_google_ignoreList":[0]}
@@ -0,0 +1,165 @@
1
+ import { create, setIfUndefined } from './map.js';
2
+ import { create as create$1 } from './set.js';
3
+ import { from } from './array.js';
4
+
5
+ /**
6
+ * Observable class prototype.
7
+ *
8
+ * @module observable
9
+ */
10
+
11
+
12
+ /**
13
+ * Handles named events.
14
+ * @experimental
15
+ *
16
+ * This is basically a (better typed) duplicate of Observable, which will replace Observable in the
17
+ * next release.
18
+ *
19
+ * @template {{[key in keyof EVENTS]: function(...any):void}} EVENTS
20
+ */
21
+ class ObservableV2 {
22
+ constructor () {
23
+ /**
24
+ * Some desc.
25
+ * @type {Map<string, Set<any>>}
26
+ */
27
+ this._observers = create();
28
+ }
29
+
30
+ /**
31
+ * @template {keyof EVENTS & string} NAME
32
+ * @param {NAME} name
33
+ * @param {EVENTS[NAME]} f
34
+ */
35
+ on (name, f) {
36
+ setIfUndefined(this._observers, /** @type {string} */ (name), create$1).add(f);
37
+ return f
38
+ }
39
+
40
+ /**
41
+ * @template {keyof EVENTS & string} NAME
42
+ * @param {NAME} name
43
+ * @param {EVENTS[NAME]} f
44
+ */
45
+ once (name, f) {
46
+ /**
47
+ * @param {...any} args
48
+ */
49
+ const _f = (...args) => {
50
+ this.off(name, /** @type {any} */ (_f));
51
+ f(...args);
52
+ };
53
+ this.on(name, /** @type {any} */ (_f));
54
+ }
55
+
56
+ /**
57
+ * @template {keyof EVENTS & string} NAME
58
+ * @param {NAME} name
59
+ * @param {EVENTS[NAME]} f
60
+ */
61
+ off (name, f) {
62
+ const observers = this._observers.get(name);
63
+ if (observers !== undefined) {
64
+ observers.delete(f);
65
+ if (observers.size === 0) {
66
+ this._observers.delete(name);
67
+ }
68
+ }
69
+ }
70
+
71
+ /**
72
+ * Emit a named event. All registered event listeners that listen to the
73
+ * specified name will receive the event.
74
+ *
75
+ * @todo This should catch exceptions
76
+ *
77
+ * @template {keyof EVENTS & string} NAME
78
+ * @param {NAME} name The event name.
79
+ * @param {Parameters<EVENTS[NAME]>} args The arguments that are applied to the event listener.
80
+ */
81
+ emit (name, args) {
82
+ // copy all listeners to an array first to make sure that no event is emitted to listeners that are subscribed while the event handler is called.
83
+ return from((this._observers.get(name) || create()).values()).forEach(f => f(...args))
84
+ }
85
+
86
+ destroy () {
87
+ this._observers = create();
88
+ }
89
+ }
90
+
91
+ /* c8 ignore start */
92
+ /**
93
+ * Handles named events.
94
+ *
95
+ * @deprecated
96
+ * @template N
97
+ */
98
+ class Observable {
99
+ constructor () {
100
+ /**
101
+ * Some desc.
102
+ * @type {Map<N, any>}
103
+ */
104
+ this._observers = create();
105
+ }
106
+
107
+ /**
108
+ * @param {N} name
109
+ * @param {function} f
110
+ */
111
+ on (name, f) {
112
+ setIfUndefined(this._observers, name, create$1).add(f);
113
+ }
114
+
115
+ /**
116
+ * @param {N} name
117
+ * @param {function} f
118
+ */
119
+ once (name, f) {
120
+ /**
121
+ * @param {...any} args
122
+ */
123
+ const _f = (...args) => {
124
+ this.off(name, _f);
125
+ f(...args);
126
+ };
127
+ this.on(name, _f);
128
+ }
129
+
130
+ /**
131
+ * @param {N} name
132
+ * @param {function} f
133
+ */
134
+ off (name, f) {
135
+ const observers = this._observers.get(name);
136
+ if (observers !== undefined) {
137
+ observers.delete(f);
138
+ if (observers.size === 0) {
139
+ this._observers.delete(name);
140
+ }
141
+ }
142
+ }
143
+
144
+ /**
145
+ * Emit a named event. All registered event listeners that listen to the
146
+ * specified name will receive the event.
147
+ *
148
+ * @todo This should catch exceptions
149
+ *
150
+ * @param {N} name The event name.
151
+ * @param {Array<any>} args The arguments that are applied to the event listener.
152
+ */
153
+ emit (name, args) {
154
+ // copy all listeners to an array first to make sure that no event is emitted to listeners that are subscribed while the event handler is called.
155
+ return from((this._observers.get(name) || create()).values()).forEach(f => f(...args))
156
+ }
157
+
158
+ destroy () {
159
+ this._observers = create();
160
+ }
161
+ }
162
+ /* c8 ignore end */
163
+
164
+ export { Observable, ObservableV2 };
165
+ //# sourceMappingURL=observable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observable.js","sources":["../../../../../../node_modules/lib0/observable.js"],"sourcesContent":["/**\n * Observable class prototype.\n *\n * @module observable\n */\n\nimport * as map from './map.js'\nimport * as set from './set.js'\nimport * as array from './array.js'\n\n/**\n * Handles named events.\n * @experimental\n *\n * This is basically a (better typed) duplicate of Observable, which will replace Observable in the\n * next release.\n *\n * @template {{[key in keyof EVENTS]: function(...any):void}} EVENTS\n */\nexport class ObservableV2 {\n constructor () {\n /**\n * Some desc.\n * @type {Map<string, Set<any>>}\n */\n this._observers = map.create()\n }\n\n /**\n * @template {keyof EVENTS & string} NAME\n * @param {NAME} name\n * @param {EVENTS[NAME]} f\n */\n on (name, f) {\n map.setIfUndefined(this._observers, /** @type {string} */ (name), set.create).add(f)\n return f\n }\n\n /**\n * @template {keyof EVENTS & string} NAME\n * @param {NAME} name\n * @param {EVENTS[NAME]} f\n */\n once (name, f) {\n /**\n * @param {...any} args\n */\n const _f = (...args) => {\n this.off(name, /** @type {any} */ (_f))\n f(...args)\n }\n this.on(name, /** @type {any} */ (_f))\n }\n\n /**\n * @template {keyof EVENTS & string} NAME\n * @param {NAME} name\n * @param {EVENTS[NAME]} f\n */\n off (name, f) {\n const observers = this._observers.get(name)\n if (observers !== undefined) {\n observers.delete(f)\n if (observers.size === 0) {\n this._observers.delete(name)\n }\n }\n }\n\n /**\n * Emit a named event. All registered event listeners that listen to the\n * specified name will receive the event.\n *\n * @todo This should catch exceptions\n *\n * @template {keyof EVENTS & string} NAME\n * @param {NAME} name The event name.\n * @param {Parameters<EVENTS[NAME]>} args The arguments that are applied to the event listener.\n */\n emit (name, args) {\n // copy all listeners to an array first to make sure that no event is emitted to listeners that are subscribed while the event handler is called.\n return array.from((this._observers.get(name) || map.create()).values()).forEach(f => f(...args))\n }\n\n destroy () {\n this._observers = map.create()\n }\n}\n\n/* c8 ignore start */\n/**\n * Handles named events.\n *\n * @deprecated\n * @template N\n */\nexport class Observable {\n constructor () {\n /**\n * Some desc.\n * @type {Map<N, any>}\n */\n this._observers = map.create()\n }\n\n /**\n * @param {N} name\n * @param {function} f\n */\n on (name, f) {\n map.setIfUndefined(this._observers, name, set.create).add(f)\n }\n\n /**\n * @param {N} name\n * @param {function} f\n */\n once (name, f) {\n /**\n * @param {...any} args\n */\n const _f = (...args) => {\n this.off(name, _f)\n f(...args)\n }\n this.on(name, _f)\n }\n\n /**\n * @param {N} name\n * @param {function} f\n */\n off (name, f) {\n const observers = this._observers.get(name)\n if (observers !== undefined) {\n observers.delete(f)\n if (observers.size === 0) {\n this._observers.delete(name)\n }\n }\n }\n\n /**\n * Emit a named event. All registered event listeners that listen to the\n * specified name will receive the event.\n *\n * @todo This should catch exceptions\n *\n * @param {N} name The event name.\n * @param {Array<any>} args The arguments that are applied to the event listener.\n */\n emit (name, args) {\n // copy all listeners to an array first to make sure that no event is emitted to listeners that are subscribed while the event handler is called.\n return array.from((this._observers.get(name) || map.create()).values()).forEach(f => f(...args))\n }\n\n destroy () {\n this._observers = map.create()\n }\n}\n/* c8 ignore end */\n"],"names":["map.create","map.setIfUndefined","set.create","array.from"],"mappings":"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","x_google_ignoreList":[0]}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Working with value pairs.
3
+ *
4
+ * @module pair
5
+ */
6
+
7
+ /**
8
+ * @template L,R
9
+ */
10
+ class Pair {
11
+ /**
12
+ * @param {L} left
13
+ * @param {R} right
14
+ */
15
+ constructor (left, right) {
16
+ this.left = left;
17
+ this.right = right;
18
+ }
19
+ }
20
+
21
+ /**
22
+ * @template L,R
23
+ * @param {L} left
24
+ * @param {R} right
25
+ * @return {Pair<L,R>}
26
+ */
27
+ const create = (left, right) => new Pair(left, right);
28
+
29
+ export { Pair, create };
30
+ //# sourceMappingURL=pair.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pair.js","sources":["../../../../../../node_modules/lib0/pair.js"],"sourcesContent":["/**\n * Working with value pairs.\n *\n * @module pair\n */\n\n/**\n * @template L,R\n */\nexport class Pair {\n /**\n * @param {L} left\n * @param {R} right\n */\n constructor (left, right) {\n this.left = left\n this.right = right\n }\n}\n\n/**\n * @template L,R\n * @param {L} left\n * @param {R} right\n * @return {Pair<L,R>}\n */\nexport const create = (left, right) => new Pair(left, right)\n\n/**\n * @template L,R\n * @param {R} right\n * @param {L} left\n * @return {Pair<L,R>}\n */\nexport const createReversed = (right, left) => new Pair(left, right)\n\n/**\n * @template L,R\n * @param {Array<Pair<L,R>>} arr\n * @param {function(L, R):any} f\n */\nexport const forEach = (arr, f) => arr.forEach(p => f(p.left, p.right))\n\n/**\n * @template L,R,X\n * @param {Array<Pair<L,R>>} arr\n * @param {function(L, R):X} f\n * @return {Array<X>}\n */\nexport const map = (arr, f) => arr.map(p => f(p.left, p.right))\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACO,MAAM,IAAI,CAAC;AAClB;AACA;AACA;AACA;AACA,EAAE,WAAW,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE;AAC5B,IAAI,IAAI,CAAC,IAAI,GAAG;AAChB,IAAI,IAAI,CAAC,KAAK,GAAG;AACjB,EAAE;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,MAAM,GAAG,CAAC,IAAI,EAAE,KAAK,KAAK,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK;;;;","x_google_ignoreList":[0]}
@@ -0,0 +1,87 @@
1
+ import { fromCharCode } from './string.js';
2
+ import { floor } from './math.js';
3
+
4
+ /**
5
+ * Fast Pseudo Random Number Generators.
6
+ *
7
+ * Given a seed a PRNG generates a sequence of numbers that cannot be reasonably predicted.
8
+ * Two PRNGs must generate the same random sequence of numbers if given the same seed.
9
+ *
10
+ * @module prng
11
+ */
12
+
13
+
14
+ /**
15
+ * Generates a single random bool.
16
+ *
17
+ * @param {PRNG} gen A random number generator.
18
+ * @return {Boolean} A random boolean
19
+ */
20
+ const bool = gen => (gen.next() >= 0.5);
21
+
22
+ /**
23
+ * Generates a random integer with 53 bit resolution.
24
+ *
25
+ * @param {PRNG} gen A random number generator.
26
+ * @param {Number} min The lower bound of the allowed return values (inclusive).
27
+ * @param {Number} max The upper bound of the allowed return values (inclusive).
28
+ * @return {Number} A random integer on [min, max]
29
+ */
30
+ const int53 = (gen, min, max) => floor(gen.next() * (max + 1 - min) + min);
31
+
32
+ /**
33
+ * Generates a random integer with 32 bit resolution.
34
+ *
35
+ * @param {PRNG} gen A random number generator.
36
+ * @param {Number} min The lower bound of the allowed return values (inclusive).
37
+ * @param {Number} max The upper bound of the allowed return values (inclusive).
38
+ * @return {Number} A random integer on [min, max]
39
+ */
40
+ const int32 = (gen, min, max) => floor(gen.next() * (max + 1 - min) + min);
41
+
42
+ /**
43
+ * @deprecated
44
+ * Optimized version of prng.int32. It has the same precision as prng.int32, but should be preferred when
45
+ * openaring on smaller ranges.
46
+ *
47
+ * @param {PRNG} gen A random number generator.
48
+ * @param {Number} min The lower bound of the allowed return values (inclusive).
49
+ * @param {Number} max The upper bound of the allowed return values (inclusive). The max inclusive number is `binary.BITS31-1`
50
+ * @return {Number} A random integer on [min, max]
51
+ */
52
+ const int31 = (gen, min, max) => int32(gen, min, max);
53
+
54
+ /**
55
+ * @param {PRNG} gen
56
+ * @return {string} A single letter (a-z)
57
+ */
58
+ const letter = gen => fromCharCode(int31(gen, 97, 122));
59
+
60
+ /**
61
+ * @param {PRNG} gen
62
+ * @param {number} [minLen=0]
63
+ * @param {number} [maxLen=20]
64
+ * @return {string} A random word (0-20 characters) without spaces consisting of letters (a-z)
65
+ */
66
+ const word = (gen, minLen = 0, maxLen = 20) => {
67
+ const len = int31(gen, minLen, maxLen);
68
+ let str = '';
69
+ for (let i = 0; i < len; i++) {
70
+ str += letter(gen);
71
+ }
72
+ return str
73
+ };
74
+
75
+ /**
76
+ * Returns one element of a given array.
77
+ *
78
+ * @param {PRNG} gen A random number generator.
79
+ * @param {Array<T>} array Non empty Array of possible values.
80
+ * @return {T} One of the values of the supplied Array.
81
+ * @template T
82
+ */
83
+ const oneOf = (gen, array) => array[int31(gen, 0, array.length - 1)];
84
+ /* c8 ignore stop */
85
+
86
+ export { bool, int31, int32, int53, letter, oneOf, word };
87
+ //# sourceMappingURL=prng.js.map