@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":"encoding.js","sources":["../../../../../../node_modules/lib0/encoding.js"],"sourcesContent":["/**\n * Efficient schema-less binary encoding with support for variable length encoding.\n *\n * Use [lib0/encoding] with [lib0/decoding]. Every encoding function has a corresponding decoding function.\n *\n * Encodes numbers in little-endian order (least to most significant byte order)\n * and is compatible with Golang's binary encoding (https://golang.org/pkg/encoding/binary/)\n * which is also used in Protocol Buffers.\n *\n * ```js\n * // encoding step\n * const encoder = encoding.createEncoder()\n * encoding.writeVarUint(encoder, 256)\n * encoding.writeVarString(encoder, 'Hello world!')\n * const buf = encoding.toUint8Array(encoder)\n * ```\n *\n * ```js\n * // decoding step\n * const decoder = decoding.createDecoder(buf)\n * decoding.readVarUint(decoder) // => 256\n * decoding.readVarString(decoder) // => 'Hello world!'\n * decoding.hasContent(decoder) // => false - all data is read\n * ```\n *\n * @module encoding\n */\n\nimport * as math from './math.js'\nimport * as number from './number.js'\nimport * as binary from './binary.js'\nimport * as string from './string.js'\nimport * as array from './array.js'\n\n/**\n * A BinaryEncoder handles the encoding to an Uint8Array.\n */\nexport class Encoder {\n constructor () {\n this.cpos = 0\n this.cbuf = new Uint8Array(100)\n /**\n * @type {Array<Uint8Array>}\n */\n this.bufs = []\n }\n}\n\n/**\n * @function\n * @return {Encoder}\n */\nexport const createEncoder = () => new Encoder()\n\n/**\n * @param {function(Encoder):void} f\n */\nexport const encode = (f) => {\n const encoder = createEncoder()\n f(encoder)\n return toUint8Array(encoder)\n}\n\n/**\n * The current length of the encoded data.\n *\n * @function\n * @param {Encoder} encoder\n * @return {number}\n */\nexport const length = encoder => {\n let len = encoder.cpos\n for (let i = 0; i < encoder.bufs.length; i++) {\n len += encoder.bufs[i].length\n }\n return len\n}\n\n/**\n * Check whether encoder is empty.\n *\n * @function\n * @param {Encoder} encoder\n * @return {boolean}\n */\nexport const hasContent = encoder => encoder.cpos > 0 || encoder.bufs.length > 0\n\n/**\n * Transform to Uint8Array.\n *\n * @function\n * @param {Encoder} encoder\n * @return {Uint8Array<ArrayBuffer>} The created ArrayBuffer.\n */\nexport const toUint8Array = encoder => {\n const uint8arr = new Uint8Array(length(encoder))\n let curPos = 0\n for (let i = 0; i < encoder.bufs.length; i++) {\n const d = encoder.bufs[i]\n uint8arr.set(d, curPos)\n curPos += d.length\n }\n uint8arr.set(new Uint8Array(encoder.cbuf.buffer, 0, encoder.cpos), curPos)\n return uint8arr\n}\n\n/**\n * Verify that it is possible to write `len` bytes wtihout checking. If\n * necessary, a new Buffer with the required length is attached.\n *\n * @param {Encoder} encoder\n * @param {number} len\n */\nexport const verifyLen = (encoder, len) => {\n const bufferLen = encoder.cbuf.length\n if (bufferLen - encoder.cpos < len) {\n encoder.bufs.push(new Uint8Array(encoder.cbuf.buffer, 0, encoder.cpos))\n encoder.cbuf = new Uint8Array(math.max(bufferLen, len) * 2)\n encoder.cpos = 0\n }\n}\n\n/**\n * Write one byte to the encoder.\n *\n * @function\n * @param {Encoder} encoder\n * @param {number} num The byte that is to be encoded.\n */\nexport const write = (encoder, num) => {\n const bufferLen = encoder.cbuf.length\n if (encoder.cpos === bufferLen) {\n encoder.bufs.push(encoder.cbuf)\n encoder.cbuf = new Uint8Array(bufferLen * 2)\n encoder.cpos = 0\n }\n encoder.cbuf[encoder.cpos++] = num\n}\n\n/**\n * Write one byte at a specific position.\n * Position must already be written (i.e. encoder.length > pos)\n *\n * @function\n * @param {Encoder} encoder\n * @param {number} pos Position to which to write data\n * @param {number} num Unsigned 8-bit integer\n */\nexport const set = (encoder, pos, num) => {\n let buffer = null\n // iterate all buffers and adjust position\n for (let i = 0; i < encoder.bufs.length && buffer === null; i++) {\n const b = encoder.bufs[i]\n if (pos < b.length) {\n buffer = b // found buffer\n } else {\n pos -= b.length\n }\n }\n if (buffer === null) {\n // use current buffer\n buffer = encoder.cbuf\n }\n buffer[pos] = num\n}\n\n/**\n * Write one byte as an unsigned integer.\n *\n * @function\n * @param {Encoder} encoder\n * @param {number} num The number that is to be encoded.\n */\nexport const writeUint8 = write\n\n/**\n * Write one byte as an unsigned Integer at a specific location.\n *\n * @function\n * @param {Encoder} encoder\n * @param {number} pos The location where the data will be written.\n * @param {number} num The number that is to be encoded.\n */\nexport const setUint8 = set\n\n/**\n * Write two bytes as an unsigned integer.\n *\n * @function\n * @param {Encoder} encoder\n * @param {number} num The number that is to be encoded.\n */\nexport const writeUint16 = (encoder, num) => {\n write(encoder, num & binary.BITS8)\n write(encoder, (num >>> 8) & binary.BITS8)\n}\n/**\n * Write two bytes as an unsigned integer at a specific location.\n *\n * @function\n * @param {Encoder} encoder\n * @param {number} pos The location where the data will be written.\n * @param {number} num The number that is to be encoded.\n */\nexport const setUint16 = (encoder, pos, num) => {\n set(encoder, pos, num & binary.BITS8)\n set(encoder, pos + 1, (num >>> 8) & binary.BITS8)\n}\n\n/**\n * Write two bytes as an unsigned integer\n *\n * @function\n * @param {Encoder} encoder\n * @param {number} num The number that is to be encoded.\n */\nexport const writeUint32 = (encoder, num) => {\n for (let i = 0; i < 4; i++) {\n write(encoder, num & binary.BITS8)\n num >>>= 8\n }\n}\n\n/**\n * Write two bytes as an unsigned integer in big endian order.\n * (most significant byte first)\n *\n * @function\n * @param {Encoder} encoder\n * @param {number} num The number that is to be encoded.\n */\nexport const writeUint32BigEndian = (encoder, num) => {\n for (let i = 3; i >= 0; i--) {\n write(encoder, (num >>> (8 * i)) & binary.BITS8)\n }\n}\n\n/**\n * Write two bytes as an unsigned integer at a specific location.\n *\n * @function\n * @param {Encoder} encoder\n * @param {number} pos The location where the data will be written.\n * @param {number} num The number that is to be encoded.\n */\nexport const setUint32 = (encoder, pos, num) => {\n for (let i = 0; i < 4; i++) {\n set(encoder, pos + i, num & binary.BITS8)\n num >>>= 8\n }\n}\n\n/**\n * Write a variable length unsigned integer. Max encodable integer is 2^53.\n *\n * @function\n * @param {Encoder} encoder\n * @param {number} num The number that is to be encoded.\n */\nexport const writeVarUint = (encoder, num) => {\n while (num > binary.BITS7) {\n write(encoder, binary.BIT8 | (binary.BITS7 & num))\n num = math.floor(num / 128) // shift >>> 7\n }\n write(encoder, binary.BITS7 & num)\n}\n\n/**\n * Write a variable length integer.\n *\n * We use the 7th bit instead for signaling that this is a negative number.\n *\n * @function\n * @param {Encoder} encoder\n * @param {number} num The number that is to be encoded.\n */\nexport const writeVarInt = (encoder, num) => {\n const isNegative = math.isNegativeZero(num)\n if (isNegative) {\n num = -num\n }\n // |- whether to continue reading |- whether is negative |- number\n write(encoder, (num > binary.BITS6 ? binary.BIT8 : 0) | (isNegative ? binary.BIT7 : 0) | (binary.BITS6 & num))\n num = math.floor(num / 64) // shift >>> 6\n // We don't need to consider the case of num === 0 so we can use a different\n // pattern here than above.\n while (num > 0) {\n write(encoder, (num > binary.BITS7 ? binary.BIT8 : 0) | (binary.BITS7 & num))\n num = math.floor(num / 128) // shift >>> 7\n }\n}\n\n/**\n * A cache to store strings temporarily\n */\nconst _strBuffer = new Uint8Array(30000)\nconst _maxStrBSize = _strBuffer.length / 3\n\n/**\n * Write a variable length string.\n *\n * @function\n * @param {Encoder} encoder\n * @param {String} str The string that is to be encoded.\n */\nexport const _writeVarStringNative = (encoder, str) => {\n if (str.length < _maxStrBSize) {\n // We can encode the string into the existing buffer\n /* c8 ignore next */\n const written = string.utf8TextEncoder.encodeInto(str, _strBuffer).written || 0\n writeVarUint(encoder, written)\n for (let i = 0; i < written; i++) {\n write(encoder, _strBuffer[i])\n }\n } else {\n writeVarUint8Array(encoder, string.encodeUtf8(str))\n }\n}\n\n/**\n * Write a variable length string.\n *\n * @function\n * @param {Encoder} encoder\n * @param {String} str The string that is to be encoded.\n */\nexport const _writeVarStringPolyfill = (encoder, str) => {\n const encodedString = unescape(encodeURIComponent(str))\n const len = encodedString.length\n writeVarUint(encoder, len)\n for (let i = 0; i < len; i++) {\n write(encoder, /** @type {number} */ (encodedString.codePointAt(i)))\n }\n}\n\n/**\n * Write a variable length string.\n *\n * @function\n * @param {Encoder} encoder\n * @param {String} str The string that is to be encoded.\n */\n/* c8 ignore next */\nexport const writeVarString = (string.utf8TextEncoder && /** @type {any} */ (string.utf8TextEncoder).encodeInto) ? _writeVarStringNative : _writeVarStringPolyfill\n\n/**\n * Write a string terminated by a special byte sequence. This is not very performant and is\n * generally discouraged. However, the resulting byte arrays are lexiographically ordered which\n * makes this a nice feature for databases.\n *\n * The string will be encoded using utf8 and then terminated and escaped using writeTerminatingUint8Array.\n *\n * @function\n * @param {Encoder} encoder\n * @param {String} str The string that is to be encoded.\n */\nexport const writeTerminatedString = (encoder, str) =>\n writeTerminatedUint8Array(encoder, string.encodeUtf8(str))\n\n/**\n * Write a terminating Uint8Array. Note that this is not performant and is generally\n * discouraged. There are few situations when this is needed.\n *\n * We use 0x0 as a terminating character. 0x1 serves as an escape character for 0x0 and 0x1.\n *\n * Example: [0,1,2] is encoded to [1,0,1,1,2,0]. 0x0, and 0x1 needed to be escaped using 0x1. Then\n * the result is terminated using the 0x0 character.\n *\n * This is basically how many systems implement null terminated strings. However, we use an escape\n * character 0x1 to avoid issues and potenial attacks on our database (if this is used as a key\n * encoder for NoSql databases).\n *\n * @function\n * @param {Encoder} encoder\n * @param {Uint8Array} buf The string that is to be encoded.\n */\nexport const writeTerminatedUint8Array = (encoder, buf) => {\n for (let i = 0; i < buf.length; i++) {\n const b = buf[i]\n if (b === 0 || b === 1) {\n write(encoder, 1)\n }\n write(encoder, buf[i])\n }\n write(encoder, 0)\n}\n\n/**\n * Write the content of another Encoder.\n *\n * @TODO: can be improved!\n * - Note: Should consider that when appending a lot of small Encoders, we should rather clone than referencing the old structure.\n * Encoders start with a rather big initial buffer.\n *\n * @function\n * @param {Encoder} encoder The enUint8Arr\n * @param {Encoder} append The BinaryEncoder to be written.\n */\nexport const writeBinaryEncoder = (encoder, append) => writeUint8Array(encoder, toUint8Array(append))\n\n/**\n * Append fixed-length Uint8Array to the encoder.\n *\n * @function\n * @param {Encoder} encoder\n * @param {Uint8Array} uint8Array\n */\nexport const writeUint8Array = (encoder, uint8Array) => {\n const bufferLen = encoder.cbuf.length\n const cpos = encoder.cpos\n const leftCopyLen = math.min(bufferLen - cpos, uint8Array.length)\n const rightCopyLen = uint8Array.length - leftCopyLen\n encoder.cbuf.set(uint8Array.subarray(0, leftCopyLen), cpos)\n encoder.cpos += leftCopyLen\n if (rightCopyLen > 0) {\n // Still something to write, write right half..\n // Append new buffer\n encoder.bufs.push(encoder.cbuf)\n // must have at least size of remaining buffer\n encoder.cbuf = new Uint8Array(math.max(bufferLen * 2, rightCopyLen))\n // copy array\n encoder.cbuf.set(uint8Array.subarray(leftCopyLen))\n encoder.cpos = rightCopyLen\n }\n}\n\n/**\n * Append an Uint8Array to Encoder.\n *\n * @function\n * @param {Encoder} encoder\n * @param {Uint8Array} uint8Array\n */\nexport const writeVarUint8Array = (encoder, uint8Array) => {\n writeVarUint(encoder, uint8Array.byteLength)\n writeUint8Array(encoder, uint8Array)\n}\n\n/**\n * Create an DataView of the next `len` bytes. Use it to write data after\n * calling this function.\n *\n * ```js\n * // write float32 using DataView\n * const dv = writeOnDataView(encoder, 4)\n * dv.setFloat32(0, 1.1)\n * // read float32 using DataView\n * const dv = readFromDataView(encoder, 4)\n * dv.getFloat32(0) // => 1.100000023841858 (leaving it to the reader to find out why this is the correct result)\n * ```\n *\n * @param {Encoder} encoder\n * @param {number} len\n * @return {DataView}\n */\nexport const writeOnDataView = (encoder, len) => {\n verifyLen(encoder, len)\n const dview = new DataView(encoder.cbuf.buffer, encoder.cpos, len)\n encoder.cpos += len\n return dview\n}\n\n/**\n * @param {Encoder} encoder\n * @param {number} num\n */\nexport const writeFloat32 = (encoder, num) => writeOnDataView(encoder, 4).setFloat32(0, num, false)\n\n/**\n * @param {Encoder} encoder\n * @param {number} num\n */\nexport const writeFloat64 = (encoder, num) => writeOnDataView(encoder, 8).setFloat64(0, num, false)\n\n/**\n * @param {Encoder} encoder\n * @param {bigint} num\n */\nexport const writeBigInt64 = (encoder, num) => /** @type {any} */ (writeOnDataView(encoder, 8)).setBigInt64(0, num, false)\n\n/**\n * @param {Encoder} encoder\n * @param {bigint} num\n */\nexport const writeBigUint64 = (encoder, num) => /** @type {any} */ (writeOnDataView(encoder, 8)).setBigUint64(0, num, false)\n\nconst floatTestBed = new DataView(new ArrayBuffer(4))\n/**\n * Check if a number can be encoded as a 32 bit float.\n *\n * @param {number} num\n * @return {boolean}\n */\nconst isFloat32 = num => {\n floatTestBed.setFloat32(0, num)\n return floatTestBed.getFloat32(0) === num\n}\n\n/**\n * @typedef {Array<AnyEncodable>} AnyEncodableArray\n */\n\n/**\n * @typedef {undefined|null|number|bigint|boolean|string|{[k:string]:AnyEncodable}|AnyEncodableArray|Uint8Array} AnyEncodable\n */\n\n/**\n * Encode data with efficient binary format.\n *\n * Differences to JSON:\n * • Transforms data to a binary format (not to a string)\n * • Encodes undefined, NaN, and ArrayBuffer (these can't be represented in JSON)\n * • Numbers are efficiently encoded either as a variable length integer, as a\n * 32 bit float, as a 64 bit float, or as a 64 bit bigint.\n *\n * Encoding table:\n *\n * | Data Type | Prefix | Encoding Method | Comment |\n * | ------------------- | -------- | ------------------ | ------- |\n * | undefined | 127 | | Functions, symbol, and everything that cannot be identified is encoded as undefined |\n * | null | 126 | | |\n * | integer | 125 | writeVarInt | Only encodes 32 bit signed integers |\n * | float32 | 124 | writeFloat32 | |\n * | float64 | 123 | writeFloat64 | |\n * | bigint | 122 | writeBigInt64 | |\n * | boolean (false) | 121 | | True and false are different data types so we save the following byte |\n * | boolean (true) | 120 | | - 0b01111000 so the last bit determines whether true or false |\n * | string | 119 | writeVarString | |\n * | object<string,any> | 118 | custom | Writes {length} then {length} key-value pairs |\n * | array<any> | 117 | custom | Writes {length} then {length} json values |\n * | Uint8Array | 116 | writeVarUint8Array | We use Uint8Array for any kind of binary data |\n *\n * Reasons for the decreasing prefix:\n * We need the first bit for extendability (later we may want to encode the\n * prefix with writeVarUint). The remaining 7 bits are divided as follows:\n * [0-30] the beginning of the data range is used for custom purposes\n * (defined by the function that uses this library)\n * [31-127] the end of the data range is used for data encoding by\n * lib0/encoding.js\n *\n * @param {Encoder} encoder\n * @param {AnyEncodable} data\n */\nexport const writeAny = (encoder, data) => {\n switch (typeof data) {\n case 'string':\n // TYPE 119: STRING\n write(encoder, 119)\n writeVarString(encoder, data)\n break\n case 'number':\n if (number.isInteger(data) && math.abs(data) <= binary.BITS31) {\n // TYPE 125: INTEGER\n write(encoder, 125)\n writeVarInt(encoder, data)\n } else if (isFloat32(data)) {\n // TYPE 124: FLOAT32\n write(encoder, 124)\n writeFloat32(encoder, data)\n } else {\n // TYPE 123: FLOAT64\n write(encoder, 123)\n writeFloat64(encoder, data)\n }\n break\n case 'bigint':\n // TYPE 122: BigInt\n write(encoder, 122)\n writeBigInt64(encoder, data)\n break\n case 'object':\n if (data === null) {\n // TYPE 126: null\n write(encoder, 126)\n } else if (array.isArray(data)) {\n // TYPE 117: Array\n write(encoder, 117)\n writeVarUint(encoder, data.length)\n for (let i = 0; i < data.length; i++) {\n writeAny(encoder, data[i])\n }\n } else if (data instanceof Uint8Array) {\n // TYPE 116: ArrayBuffer\n write(encoder, 116)\n writeVarUint8Array(encoder, data)\n } else {\n // TYPE 118: Object\n write(encoder, 118)\n const keys = Object.keys(data)\n writeVarUint(encoder, keys.length)\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i]\n writeVarString(encoder, key)\n writeAny(encoder, data[key])\n }\n }\n break\n case 'boolean':\n // TYPE 120/121: boolean (true/false)\n write(encoder, data ? 120 : 121)\n break\n default:\n // TYPE 127: undefined\n write(encoder, 127)\n }\n}\n\n/**\n * Now come a few stateful encoder that have their own classes.\n */\n\n/**\n * Basic Run Length Encoder - a basic compression implementation.\n *\n * Encodes [1,1,1,7] to [1,3,7,1] (3 times 1, 1 time 7). This encoder might do more harm than good if there are a lot of values that are not repeated.\n *\n * It was originally used for image compression. Cool .. article http://csbruce.com/cbm/transactor/pdfs/trans_v7_i06.pdf\n *\n * @note T must not be null!\n *\n * @template T\n */\nexport class RleEncoder extends Encoder {\n /**\n * @param {function(Encoder, T):void} writer\n */\n constructor (writer) {\n super()\n /**\n * The writer\n */\n this.w = writer\n /**\n * Current state\n * @type {T|null}\n */\n this.s = null\n this.count = 0\n }\n\n /**\n * @param {T} v\n */\n write (v) {\n if (this.s === v) {\n this.count++\n } else {\n if (this.count > 0) {\n // flush counter, unless this is the first value (count = 0)\n writeVarUint(this, this.count - 1) // since count is always > 0, we can decrement by one. non-standard encoding ftw\n }\n this.count = 1\n // write first value\n this.w(this, v)\n this.s = v\n }\n }\n}\n\n/**\n * Basic diff decoder using variable length encoding.\n *\n * Encodes the values [3, 1100, 1101, 1050, 0] to [3, 1097, 1, -51, -1050] using writeVarInt.\n */\nexport class IntDiffEncoder extends Encoder {\n /**\n * @param {number} start\n */\n constructor (start) {\n super()\n /**\n * Current state\n * @type {number}\n */\n this.s = start\n }\n\n /**\n * @param {number} v\n */\n write (v) {\n writeVarInt(this, v - this.s)\n this.s = v\n }\n}\n\n/**\n * A combination of IntDiffEncoder and RleEncoder.\n *\n * Basically first writes the IntDiffEncoder and then counts duplicate diffs using RleEncoding.\n *\n * Encodes the values [1,1,1,2,3,4,5,6] as [1,1,0,2,1,5] (RLE([1,0,0,1,1,1,1,1]) ⇒ RleIntDiff[1,1,0,2,1,5])\n */\nexport class RleIntDiffEncoder extends Encoder {\n /**\n * @param {number} start\n */\n constructor (start) {\n super()\n /**\n * Current state\n * @type {number}\n */\n this.s = start\n this.count = 0\n }\n\n /**\n * @param {number} v\n */\n write (v) {\n if (this.s === v && this.count > 0) {\n this.count++\n } else {\n if (this.count > 0) {\n // flush counter, unless this is the first value (count = 0)\n writeVarUint(this, this.count - 1) // since count is always > 0, we can decrement by one. non-standard encoding ftw\n }\n this.count = 1\n // write first value\n writeVarInt(this, v - this.s)\n this.s = v\n }\n }\n}\n\n/**\n * @param {UintOptRleEncoder} encoder\n */\nconst flushUintOptRleEncoder = encoder => {\n if (encoder.count > 0) {\n // flush counter, unless this is the first value (count = 0)\n // case 1: just a single value. set sign to positive\n // case 2: write several values. set sign to negative to indicate that there is a length coming\n writeVarInt(encoder.encoder, encoder.count === 1 ? encoder.s : -encoder.s)\n if (encoder.count > 1) {\n writeVarUint(encoder.encoder, encoder.count - 2) // since count is always > 1, we can decrement by one. non-standard encoding ftw\n }\n }\n}\n\n/**\n * Optimized Rle encoder that does not suffer from the mentioned problem of the basic Rle encoder.\n *\n * Internally uses VarInt encoder to write unsigned integers. If the input occurs multiple times, we write\n * write it as a negative number. The UintOptRleDecoder then understands that it needs to read a count.\n *\n * Encodes [1,2,3,3,3] as [1,2,-3,3] (once 1, once 2, three times 3)\n */\nexport class UintOptRleEncoder {\n constructor () {\n this.encoder = new Encoder()\n /**\n * @type {number}\n */\n this.s = 0\n this.count = 0\n }\n\n /**\n * @param {number} v\n */\n write (v) {\n if (this.s === v) {\n this.count++\n } else {\n flushUintOptRleEncoder(this)\n this.count = 1\n this.s = v\n }\n }\n\n /**\n * Flush the encoded state and transform this to a Uint8Array.\n *\n * Note that this should only be called once.\n */\n toUint8Array () {\n flushUintOptRleEncoder(this)\n return toUint8Array(this.encoder)\n }\n}\n\n/**\n * Increasing Uint Optimized RLE Encoder\n *\n * The RLE encoder counts the number of same occurences of the same value.\n * The IncUintOptRle encoder counts if the value increases.\n * I.e. 7, 8, 9, 10 will be encoded as [-7, 4]. 1, 3, 5 will be encoded\n * as [1, 3, 5].\n */\nexport class IncUintOptRleEncoder {\n constructor () {\n this.encoder = new Encoder()\n /**\n * @type {number}\n */\n this.s = 0\n this.count = 0\n }\n\n /**\n * @param {number} v\n */\n write (v) {\n if (this.s + this.count === v) {\n this.count++\n } else {\n flushUintOptRleEncoder(this)\n this.count = 1\n this.s = v\n }\n }\n\n /**\n * Flush the encoded state and transform this to a Uint8Array.\n *\n * Note that this should only be called once.\n */\n toUint8Array () {\n flushUintOptRleEncoder(this)\n return toUint8Array(this.encoder)\n }\n}\n\n/**\n * @param {IntDiffOptRleEncoder} encoder\n */\nconst flushIntDiffOptRleEncoder = encoder => {\n if (encoder.count > 0) {\n // 31 bit making up the diff | wether to write the counter\n // const encodedDiff = encoder.diff << 1 | (encoder.count === 1 ? 0 : 1)\n const encodedDiff = encoder.diff * 2 + (encoder.count === 1 ? 0 : 1)\n // flush counter, unless this is the first value (count = 0)\n // case 1: just a single value. set first bit to positive\n // case 2: write several values. set first bit to negative to indicate that there is a length coming\n writeVarInt(encoder.encoder, encodedDiff)\n if (encoder.count > 1) {\n writeVarUint(encoder.encoder, encoder.count - 2) // since count is always > 1, we can decrement by one. non-standard encoding ftw\n }\n }\n}\n\n/**\n * A combination of the IntDiffEncoder and the UintOptRleEncoder.\n *\n * The count approach is similar to the UintDiffOptRleEncoder, but instead of using the negative bitflag, it encodes\n * in the LSB whether a count is to be read. Therefore this Encoder only supports 31 bit integers!\n *\n * Encodes [1, 2, 3, 2] as [3, 1, 6, -1] (more specifically [(1 << 1) | 1, (3 << 0) | 0, -1])\n *\n * Internally uses variable length encoding. Contrary to normal UintVar encoding, the first byte contains:\n * * 1 bit that denotes whether the next value is a count (LSB)\n * * 1 bit that denotes whether this value is negative (MSB - 1)\n * * 1 bit that denotes whether to continue reading the variable length integer (MSB)\n *\n * Therefore, only five bits remain to encode diff ranges.\n *\n * Use this Encoder only when appropriate. In most cases, this is probably a bad idea.\n */\nexport class IntDiffOptRleEncoder {\n constructor () {\n this.encoder = new Encoder()\n /**\n * @type {number}\n */\n this.s = 0\n this.count = 0\n this.diff = 0\n }\n\n /**\n * @param {number} v\n */\n write (v) {\n if (this.diff === v - this.s) {\n this.s = v\n this.count++\n } else {\n flushIntDiffOptRleEncoder(this)\n this.count = 1\n this.diff = v - this.s\n this.s = v\n }\n }\n\n /**\n * Flush the encoded state and transform this to a Uint8Array.\n *\n * Note that this should only be called once.\n */\n toUint8Array () {\n flushIntDiffOptRleEncoder(this)\n return toUint8Array(this.encoder)\n }\n}\n\n/**\n * Optimized String Encoder.\n *\n * Encoding many small strings in a simple Encoder is not very efficient. The function call to decode a string takes some time and creates references that must be eventually deleted.\n * In practice, when decoding several million small strings, the GC will kick in more and more often to collect orphaned string objects (or maybe there is another reason?).\n *\n * This string encoder solves the above problem. All strings are concatenated and written as a single string using a single encoding call.\n *\n * The lengths are encoded using a UintOptRleEncoder.\n */\nexport class StringEncoder {\n constructor () {\n /**\n * @type {Array<string>}\n */\n this.sarr = []\n this.s = ''\n this.lensE = new UintOptRleEncoder()\n }\n\n /**\n * @param {string} string\n */\n write (string) {\n this.s += string\n if (this.s.length > 19) {\n this.sarr.push(this.s)\n this.s = ''\n }\n this.lensE.write(string.length)\n }\n\n toUint8Array () {\n const encoder = new Encoder()\n this.sarr.push(this.s)\n this.s = ''\n writeVarString(encoder, this.sarr.join(''))\n writeUint8Array(encoder, this.lensE.toUint8Array())\n return toUint8Array(encoder)\n }\n}\n"],"names":["math.max","binary.BITS7","binary.BIT8","math.floor","math.isNegativeZero","binary.BITS6","binary.BIT7","string.utf8TextEncoder","string.encodeUtf8","math.min","number.isInteger","math.abs","binary.BITS31","array.isArray"],"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;;;AAQA;AACA;AACA;AACO,MAAM,OAAO,CAAC;AACrB,EAAE,WAAW,CAAC,GAAG;AACjB,IAAI,IAAI,CAAC,IAAI,GAAG;AAChB,IAAI,IAAI,CAAC,IAAI,GAAG,IAAI,UAAU,CAAC,GAAG;AAClC;AACA;AACA;AACA,IAAI,IAAI,CAAC,IAAI,GAAG;AAChB,EAAE;AACF;;AAEA;AACA;AACA;AACA;AACY,MAAC,aAAa,GAAG,MAAM,IAAI,OAAO;;AAW9C;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,MAAM,GAAG,OAAO,IAAI;AACjC,EAAE,IAAI,GAAG,GAAG,OAAO,CAAC;AACpB,EAAE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AAChD,IAAI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAC3B,EAAE;AACF,EAAE,OAAO;AACT;;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,YAAY,GAAG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AAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM;AAClC,EAAE;;AAEF,EAAE,YAAY,CAAC,GAAG;AAClB,IAAI,MAAM,OAAO,GAAG,IAAI,OAAO;AAC/B,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACzB,IAAI,IAAI,CAAC,CAAC,GAAG;AACb,IAAI,cAAc,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;AAC9C,IAAI,eAAe,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE;AACtD,IAAI,OAAO,YAAY,CAAC,OAAO;AAC/B,EAAE;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;","x_google_ignoreList":[0]}
@@ -0,0 +1,129 @@
1
+ 'use strict';
2
+
3
+ var map = require('./map.js');
4
+ var string = require('./string.js');
5
+ var conditions = require('./conditions.js');
6
+ var storage = require('./storage.js');
7
+ var _function = require('./function.js');
8
+
9
+ /**
10
+ * Isomorphic module to work access the environment (query params, env variables).
11
+ *
12
+ * @module environment
13
+ */
14
+
15
+
16
+ /* c8 ignore next 2 */
17
+ // @ts-ignore
18
+ const isNode = typeof process !== 'undefined' && process.release && /node|io\.js/.test(process.release.name) && Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]';
19
+
20
+ /* c8 ignore next */
21
+ const isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && !isNode;
22
+
23
+ /**
24
+ * @type {Map<string,string>}
25
+ */
26
+ let params;
27
+
28
+ /* c8 ignore start */
29
+ const computeParams = () => {
30
+ if (params === undefined) {
31
+ if (isNode) {
32
+ params = map.create();
33
+ const pargs = process.argv;
34
+ let currParamName = null;
35
+ for (let i = 0; i < pargs.length; i++) {
36
+ const parg = pargs[i];
37
+ if (parg[0] === '-') {
38
+ if (currParamName !== null) {
39
+ params.set(currParamName, '');
40
+ }
41
+ currParamName = parg;
42
+ } else {
43
+ if (currParamName !== null) {
44
+ params.set(currParamName, parg);
45
+ currParamName = null;
46
+ }
47
+ }
48
+ }
49
+ if (currParamName !== null) {
50
+ params.set(currParamName, '');
51
+ }
52
+ // in ReactNative for example this would not be true (unless connected to the Remote Debugger)
53
+ } else if (typeof location === 'object') {
54
+ params = map.create(); // eslint-disable-next-line no-undef
55
+ (location.search || '?').slice(1).split('&').forEach((kv) => {
56
+ if (kv.length !== 0) {
57
+ const [key, value] = kv.split('=');
58
+ params.set(`--${string.fromCamelCase(key, '-')}`, value);
59
+ params.set(`-${string.fromCamelCase(key, '-')}`, value);
60
+ }
61
+ });
62
+ } else {
63
+ params = map.create();
64
+ }
65
+ }
66
+ return params
67
+ };
68
+ /* c8 ignore stop */
69
+
70
+ /**
71
+ * @param {string} name
72
+ * @return {boolean}
73
+ */
74
+ /* c8 ignore next */
75
+ const hasParam = (name) => computeParams().has(name);
76
+
77
+ /**
78
+ * @param {string} name
79
+ * @return {string|null}
80
+ */
81
+ /* c8 ignore next 4 */
82
+ const getVariable = (name) =>
83
+ isNode
84
+ ? conditions.undefinedToNull(process.env[name.toUpperCase().replaceAll('-', '_')])
85
+ : conditions.undefinedToNull(storage.varStorage.getItem(name));
86
+
87
+ /**
88
+ * @param {string} name
89
+ * @return {boolean}
90
+ */
91
+ /* c8 ignore next 2 */
92
+ const hasConf = (name) =>
93
+ hasParam('--' + name) || getVariable(name) !== null;
94
+
95
+ /* c8 ignore next */
96
+ const production = hasConf('production');
97
+
98
+ /* c8 ignore next 2 */
99
+ const forceColor = isNode &&
100
+ _function.isOneOf(process.env.FORCE_COLOR, ['true', '1', '2']);
101
+
102
+ /* c8 ignore start */
103
+ /**
104
+ * Color is enabled by default if the terminal supports it.
105
+ *
106
+ * Explicitly enable color using `--color` parameter
107
+ * Disable color using `--no-color` parameter or using `NO_COLOR=1` environment variable.
108
+ * `FORCE_COLOR=1` enables color and takes precedence over all.
109
+ */
110
+ const supportsColor = forceColor || (
111
+ !hasParam('--no-colors') && // @todo deprecate --no-colors
112
+ !hasConf('no-color') &&
113
+ (!isNode || process.stdout.isTTY) && (
114
+ !isNode ||
115
+ hasParam('--color') ||
116
+ getVariable('COLORTERM') !== null ||
117
+ (getVariable('TERM') || '').includes('color')
118
+ )
119
+ );
120
+ /* c8 ignore stop */
121
+
122
+ exports.getVariable = getVariable;
123
+ exports.hasConf = hasConf;
124
+ exports.hasParam = hasParam;
125
+ exports.isBrowser = isBrowser;
126
+ exports.isNode = isNode;
127
+ exports.production = production;
128
+ exports.supportsColor = supportsColor;
129
+ //# sourceMappingURL=environment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"environment.js","sources":["../../../../../../node_modules/lib0/environment.js"],"sourcesContent":["/**\n * Isomorphic module to work access the environment (query params, env variables).\n *\n * @module environment\n */\n\nimport * as map from './map.js'\nimport * as string from './string.js'\nimport * as conditions from './conditions.js'\nimport * as storage from './storage.js'\nimport * as f from './function.js'\n\n/* c8 ignore next 2 */\n// @ts-ignore\nexport const isNode = typeof process !== 'undefined' && process.release && /node|io\\.js/.test(process.release.name) && Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]'\n\n/* c8 ignore next */\nexport const isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && !isNode\n/* c8 ignore next 3 */\nexport const isMac = typeof navigator !== 'undefined'\n ? /Mac/.test(navigator.platform)\n : false\n\n/**\n * @type {Map<string,string>}\n */\nlet params\nconst args = []\n\n/* c8 ignore start */\nconst computeParams = () => {\n if (params === undefined) {\n if (isNode) {\n params = map.create()\n const pargs = process.argv\n let currParamName = null\n for (let i = 0; i < pargs.length; i++) {\n const parg = pargs[i]\n if (parg[0] === '-') {\n if (currParamName !== null) {\n params.set(currParamName, '')\n }\n currParamName = parg\n } else {\n if (currParamName !== null) {\n params.set(currParamName, parg)\n currParamName = null\n } else {\n args.push(parg)\n }\n }\n }\n if (currParamName !== null) {\n params.set(currParamName, '')\n }\n // in ReactNative for example this would not be true (unless connected to the Remote Debugger)\n } else if (typeof location === 'object') {\n params = map.create(); // eslint-disable-next-line no-undef\n (location.search || '?').slice(1).split('&').forEach((kv) => {\n if (kv.length !== 0) {\n const [key, value] = kv.split('=')\n params.set(`--${string.fromCamelCase(key, '-')}`, value)\n params.set(`-${string.fromCamelCase(key, '-')}`, value)\n }\n })\n } else {\n params = map.create()\n }\n }\n return params\n}\n/* c8 ignore stop */\n\n/**\n * @param {string} name\n * @return {boolean}\n */\n/* c8 ignore next */\nexport const hasParam = (name) => computeParams().has(name)\n\n/**\n * @param {string} name\n * @param {string} defaultVal\n * @return {string}\n */\n/* c8 ignore next 2 */\nexport const getParam = (name, defaultVal) =>\n computeParams().get(name) || defaultVal\n\n/**\n * @param {string} name\n * @return {string|null}\n */\n/* c8 ignore next 4 */\nexport const getVariable = (name) =>\n isNode\n ? conditions.undefinedToNull(process.env[name.toUpperCase().replaceAll('-', '_')])\n : conditions.undefinedToNull(storage.varStorage.getItem(name))\n\n/**\n * @param {string} name\n * @return {string|null}\n */\n/* c8 ignore next 2 */\nexport const getConf = (name) =>\n computeParams().get('--' + name) || getVariable(name)\n\n/**\n * @param {string} name\n * @return {string}\n */\n/* c8 ignore next 5 */\nexport const ensureConf = (name) => {\n const c = getConf(name)\n if (c == null) throw new Error(`Expected configuration \"${name.toUpperCase().replaceAll('-', '_')}\"`)\n return c\n}\n\n/**\n * @param {string} name\n * @return {boolean}\n */\n/* c8 ignore next 2 */\nexport const hasConf = (name) =>\n hasParam('--' + name) || getVariable(name) !== null\n\n/* c8 ignore next */\nexport const production = hasConf('production')\n\n/* c8 ignore next 2 */\nconst forceColor = isNode &&\n f.isOneOf(process.env.FORCE_COLOR, ['true', '1', '2'])\n\n/* c8 ignore start */\n/**\n * Color is enabled by default if the terminal supports it.\n *\n * Explicitly enable color using `--color` parameter\n * Disable color using `--no-color` parameter or using `NO_COLOR=1` environment variable.\n * `FORCE_COLOR=1` enables color and takes precedence over all.\n */\nexport const supportsColor = forceColor || (\n !hasParam('--no-colors') && // @todo deprecate --no-colors\n !hasConf('no-color') &&\n (!isNode || process.stdout.isTTY) && (\n !isNode ||\n hasParam('--color') ||\n getVariable('COLORTERM') !== null ||\n (getVariable('TERM') || '').includes('color')\n )\n)\n/* c8 ignore stop */\n"],"names":["map.create","string.fromCamelCase","conditions.undefinedToNull","storage.varStorage","f.isOneOf"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;;;AAQA;AACA;AACY,MAAC,MAAM,GAAG,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,OAAO,IAAI,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,OAAO,KAAK,WAAW,GAAG,OAAO,GAAG,CAAC,CAAC,KAAK;;AAExM;AACY,MAAC,SAAS,GAAG,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,QAAQ,KAAK,WAAW,IAAI,CAAC;;AAM9F;AACA;AACA;AACA,IAAI;;AAGJ;AACA,MAAM,aAAa,GAAG,MAAM;AAC5B,EAAE,IAAI,MAAM,KAAK,SAAS,EAAE;AAC5B,IAAI,IAAI,MAAM,EAAE;AAChB,MAAM,MAAM,GAAGA,UAAU;AACzB,MAAM,MAAM,KAAK,GAAG,OAAO,CAAC;AAC5B,MAAM,IAAI,aAAa,GAAG;AAC1B,MAAM,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AAC7C,QAAQ,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC;AAC5B,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;AAC7B,UAAU,IAAI,aAAa,KAAK,IAAI,EAAE;AACtC,YAAY,MAAM,CAAC,GAAG,CAAC,aAAa,EAAE,EAAE;AACxC,UAAU;AACV,UAAU,aAAa,GAAG;AA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EAAE;AACF,MAAME,0BAA0B,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACrF,MAAMA,0BAA0B,CAACC,kBAAkB,CAAC,OAAO,CAAC,IAAI,CAAC;;AAqBjE;AACA;AACA;AACA;AACA;AACY,MAAC,OAAO,GAAG,CAAC,IAAI;AAC5B,EAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,WAAW,CAAC,IAAI,CAAC,KAAK;;AAEjD;AACY,MAAC,UAAU,GAAG,OAAO,CAAC,YAAY;;AAE9C;AACA,MAAM,UAAU,GAAG,MAAM;AACzB,EAAEC,iBAAS,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC;;AAEvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,aAAa,GAAG,UAAU;AACvC,EAAE,CAAC,QAAQ,CAAC,aAAa,CAAC;AAC1B,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC;AACtB,GAAG,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;AACnC,IAAI,CAAC,MAAM;AACX,IAAI,QAAQ,CAAC,SAAS,CAAC;AACvB,IAAI,WAAW,CAAC,WAAW,CAAC,KAAK,IAAI;AACrC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,QAAQ,CAAC,OAAO;AAChD;AACA;AACA;;;;;;;;;;","x_google_ignoreList":[0]}
@@ -0,0 +1,37 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Error helpers.
5
+ *
6
+ * @module error
7
+ */
8
+
9
+ /**
10
+ * @param {string} s
11
+ * @return {Error}
12
+ */
13
+ /* c8 ignore next */
14
+ const create = s => new Error(s);
15
+
16
+ /**
17
+ * @throws {Error}
18
+ * @return {never}
19
+ */
20
+ /* c8 ignore next 3 */
21
+ const methodUnimplemented = () => {
22
+ throw create('Method unimplemented')
23
+ };
24
+
25
+ /**
26
+ * @throws {Error}
27
+ * @return {never}
28
+ */
29
+ /* c8 ignore next 3 */
30
+ const unexpectedCase = () => {
31
+ throw create('Unexpected case')
32
+ };
33
+
34
+ exports.create = create;
35
+ exports.methodUnimplemented = methodUnimplemented;
36
+ exports.unexpectedCase = unexpectedCase;
37
+ //# sourceMappingURL=error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.js","sources":["../../../../../../node_modules/lib0/error.js"],"sourcesContent":["/**\n * Error helpers.\n *\n * @module error\n */\n\n/**\n * @param {string} s\n * @return {Error}\n */\n/* c8 ignore next */\nexport const create = s => new Error(s)\n\n/**\n * @throws {Error}\n * @return {never}\n */\n/* c8 ignore next 3 */\nexport const methodUnimplemented = () => {\n throw create('Method unimplemented')\n}\n\n/**\n * @throws {Error}\n * @return {never}\n */\n/* c8 ignore next 3 */\nexport const unexpectedCase = () => {\n throw create('Unexpected case')\n}\n\n/**\n * @param {boolean} property\n * @return {asserts property is true}\n */\nexport const assert = property => { if (!property) throw create('Assert failed') }\n"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACY,MAAC,MAAM,GAAG,CAAC,IAAI,IAAI,KAAK,CAAC,CAAC;;AAEtC;AACA;AACA;AACA;AACA;AACY,MAAC,mBAAmB,GAAG,MAAM;AACzC,EAAE,MAAM,MAAM,CAAC,sBAAsB;AACrC;;AAEA;AACA;AACA;AACA;AACA;AACY,MAAC,cAAc,GAAG,MAAM;AACpC,EAAE,MAAM,MAAM,CAAC,iBAAiB;AAChC;;;;;;","x_google_ignoreList":[0]}
@@ -0,0 +1,135 @@
1
+ 'use strict';
2
+
3
+ var object = require('./object.js');
4
+ var equality = require('./trait/equality.js');
5
+
6
+ /**
7
+ * Common functions and function call helpers.
8
+ *
9
+ * @module function
10
+ */
11
+
12
+
13
+ /**
14
+ * Calls all functions in `fs` with args. Only throws after all functions were called.
15
+ *
16
+ * @param {Array<function>} fs
17
+ * @param {Array<any>} args
18
+ */
19
+ const callAll = (fs, args, i = 0) => {
20
+ try {
21
+ for (; i < fs.length; i++) {
22
+ fs[i](...args);
23
+ }
24
+ } finally {
25
+ if (i < fs.length) {
26
+ callAll(fs, args, i + 1);
27
+ }
28
+ }
29
+ };
30
+
31
+ /**
32
+ * @template A
33
+ *
34
+ * @param {A} a
35
+ * @return {A}
36
+ */
37
+ const id = a => a;
38
+
39
+ /* c8 ignore start */
40
+
41
+ /**
42
+ * @param {any} a
43
+ * @param {any} b
44
+ * @return {boolean}
45
+ */
46
+ const equalityDeep = (a, b) => {
47
+ if (a === b) {
48
+ return true
49
+ }
50
+ if (a == null || b == null || (a.constructor !== b.constructor && (a.constructor || Object) !== (b.constructor || Object))) {
51
+ return false
52
+ }
53
+ if (a[equality.EqualityTraitSymbol] != null) {
54
+ return a[equality.EqualityTraitSymbol](b)
55
+ }
56
+ switch (a.constructor) {
57
+ case ArrayBuffer:
58
+ a = new Uint8Array(a);
59
+ b = new Uint8Array(b);
60
+ // eslint-disable-next-line no-fallthrough
61
+ case Uint8Array: {
62
+ if (a.byteLength !== b.byteLength) {
63
+ return false
64
+ }
65
+ for (let i = 0; i < a.length; i++) {
66
+ if (a[i] !== b[i]) {
67
+ return false
68
+ }
69
+ }
70
+ break
71
+ }
72
+ case Set: {
73
+ if (a.size !== b.size) {
74
+ return false
75
+ }
76
+ for (const value of a) {
77
+ if (!b.has(value)) {
78
+ return false
79
+ }
80
+ }
81
+ break
82
+ }
83
+ case Map: {
84
+ if (a.size !== b.size) {
85
+ return false
86
+ }
87
+ for (const key of a.keys()) {
88
+ if (!b.has(key) || !equalityDeep(a.get(key), b.get(key))) {
89
+ return false
90
+ }
91
+ }
92
+ break
93
+ }
94
+ case undefined:
95
+ case Object:
96
+ if (object.size(a) !== object.size(b)) {
97
+ return false
98
+ }
99
+ for (const key in a) {
100
+ if (!object.hasProperty(a, key) || !equalityDeep(a[key], b[key])) {
101
+ return false
102
+ }
103
+ }
104
+ break
105
+ case Array:
106
+ if (a.length !== b.length) {
107
+ return false
108
+ }
109
+ for (let i = 0; i < a.length; i++) {
110
+ if (!equalityDeep(a[i], b[i])) {
111
+ return false
112
+ }
113
+ }
114
+ break
115
+ default:
116
+ return false
117
+ }
118
+ return true
119
+ };
120
+
121
+ /**
122
+ * @template V
123
+ * @template {V} OPTS
124
+ *
125
+ * @param {V} value
126
+ * @param {Array<OPTS>} options
127
+ */
128
+ // @ts-ignore
129
+ const isOneOf = (value, options) => options.includes(value);
130
+
131
+ exports.callAll = callAll;
132
+ exports.equalityDeep = equalityDeep;
133
+ exports.id = id;
134
+ exports.isOneOf = isOneOf;
135
+ //# sourceMappingURL=function.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"function.js","sources":["../../../../../../node_modules/lib0/function.js"],"sourcesContent":["/**\n * Common functions and function call helpers.\n *\n * @module function\n */\n\nimport * as array from './array.js'\nimport * as object from './object.js'\nimport * as equalityTrait from './trait/equality.js'\n\n/**\n * Calls all functions in `fs` with args. Only throws after all functions were called.\n *\n * @param {Array<function>} fs\n * @param {Array<any>} args\n */\nexport const callAll = (fs, args, i = 0) => {\n try {\n for (; i < fs.length; i++) {\n fs[i](...args)\n }\n } finally {\n if (i < fs.length) {\n callAll(fs, args, i + 1)\n }\n }\n}\n\nexport const nop = () => {}\n\n/**\n * @template T\n * @param {function():T} f\n * @return {T}\n */\nexport const apply = f => f()\n\n/**\n * @template A\n *\n * @param {A} a\n * @return {A}\n */\nexport const id = a => a\n\n/**\n * @template T\n *\n * @param {T} a\n * @param {T} b\n * @return {boolean}\n */\nexport const equalityStrict = (a, b) => a === b\n\n/**\n * @template T\n *\n * @param {Array<T>|object} a\n * @param {Array<T>|object} b\n * @return {boolean}\n */\nexport const equalityFlat = (a, b) => a === b || (a != null && b != null && a.constructor === b.constructor && ((array.isArray(a) && array.equalFlat(a, /** @type {Array<T>} */ (b))) || (typeof a === 'object' && object.equalFlat(a, b))))\n\n/* c8 ignore start */\n\n/**\n * @param {any} a\n * @param {any} b\n * @return {boolean}\n */\nexport const equalityDeep = (a, b) => {\n if (a === b) {\n return true\n }\n if (a == null || b == null || (a.constructor !== b.constructor && (a.constructor || Object) !== (b.constructor || Object))) {\n return false\n }\n if (a[equalityTrait.EqualityTraitSymbol] != null) {\n return a[equalityTrait.EqualityTraitSymbol](b)\n }\n switch (a.constructor) {\n case ArrayBuffer:\n a = new Uint8Array(a)\n b = new Uint8Array(b)\n // eslint-disable-next-line no-fallthrough\n case Uint8Array: {\n if (a.byteLength !== b.byteLength) {\n return false\n }\n for (let i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) {\n return false\n }\n }\n break\n }\n case Set: {\n if (a.size !== b.size) {\n return false\n }\n for (const value of a) {\n if (!b.has(value)) {\n return false\n }\n }\n break\n }\n case Map: {\n if (a.size !== b.size) {\n return false\n }\n for (const key of a.keys()) {\n if (!b.has(key) || !equalityDeep(a.get(key), b.get(key))) {\n return false\n }\n }\n break\n }\n case undefined:\n case Object:\n if (object.size(a) !== object.size(b)) {\n return false\n }\n for (const key in a) {\n if (!object.hasProperty(a, key) || !equalityDeep(a[key], b[key])) {\n return false\n }\n }\n break\n case Array:\n if (a.length !== b.length) {\n return false\n }\n for (let i = 0; i < a.length; i++) {\n if (!equalityDeep(a[i], b[i])) {\n return false\n }\n }\n break\n default:\n return false\n }\n return true\n}\n\n/**\n * @template V\n * @template {V} OPTS\n *\n * @param {V} value\n * @param {Array<OPTS>} options\n */\n// @ts-ignore\nexport const isOneOf = (value, options) => options.includes(value)\n/* c8 ignore stop */\n\nexport const isArray = array.isArray\n\n/**\n * @param {any} s\n * @return {s is String}\n */\nexport const isString = (s) => s && s.constructor === String\n\n/**\n * @param {any} n\n * @return {n is Number}\n */\nexport const isNumber = n => n != null && n.constructor === Number\n\n/**\n * @template {abstract new (...args: any) => any} TYPE\n * @param {any} n\n * @param {TYPE} T\n * @return {n is InstanceType<TYPE>}\n */\nexport const is = (n, T) => n && n.constructor === T\n\n/**\n * @template {abstract new (...args: any) => any} TYPE\n * @param {TYPE} T\n */\nexport const isTemplate = (T) =>\n /**\n * @param {any} n\n * @return {n is InstanceType<TYPE>}\n **/\n n => n && n.constructor === T\n"],"names":["equalityTrait.EqualityTraitSymbol","object.size","object.hasProperty"],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;;;AAMA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,OAAO,GAAG,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,KAAK;AAC5C,EAAE,IAAI;AACN,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AAC/B,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI;AACnB,IAAI;AACJ,EAAE,CAAC,SAAS;AACZ,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE;AACvB,MAAM,OAAO,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC;AAC7B,IAAI;AACJ,EAAE;AACF;;AAWA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,EAAE,GAAG,CAAC,IAAI;;AAoBvB;;AAEA;AACA;AACA;AACA;AACA;AACY,MAAC,YAAY,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK;AACtC,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE;AACf,IAAI,OAAO;AACX,EAAE;AACF,EAAE,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,IAAI,KAAK,CAAC,CAAC,WAAW,KAAK,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,CAAC,WAAW,IAAI,MAAM,OAAO,CAAC,CAAC,WAAW,IAAI,MAAM,CAAC,CAAC,EAAE;AAC9H,IAAI,OAAO;AACX,EAAE;AACF,EAAE,IAAI,CAAC,CAACA,4BAAiC,CAAC,IAAI,IAAI,EAAE;AACpD,IAAI,OAA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CAAC,GAAG,CAAC,CAAC,EAAE;AAClE,UAAU,OAAO;AACjB,QAAQ;AACR,MAAM;AACN,MAAM;AACN,IAAI;AACJ,IAAI,KAAK,SAAS;AAClB,IAAI,KAAK,MAAM;AACf,MAAM,IAAIC,WAAW,CAAC,CAAC,CAAC,KAAKA,WAAW,CAAC,CAAC,CAAC,EAAE;AAC7C,QAAQ,OAAO;AACf,MAAM;AACN,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC,EAAE;AAC3B,QAAQ,IAAI,CAACC,kBAAkB,CAAC,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE;AAC1E,UAAU,OAAO;AACjB,QAAQ;AACR,MAAM;AACN,MAAM;AACN,IAAI,KAAK,KAAK;AACd,MAAM,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,EAAE;AACjC,QAAQ,OAAO;AACf,MAAM;AACN,MAAM,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AACzC,QAAQ,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;AACvC,UAAU,OAAO;AACjB,QAAQ;AACR,MAAM;AACN,MAAM;AACN,IAAI;AACJ,MAAM,OAAO;AACb;AACA,EAAE,OAAO;AACT;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,OAAO,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,KAAK;;;;;;;","x_google_ignoreList":[0]}
@@ -0,0 +1,52 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Utility module to create and manipulate Iterators.
5
+ *
6
+ * @module iterator
7
+ */
8
+
9
+
10
+ /**
11
+ * @template T
12
+ * @param {function():IteratorResult<T>} next
13
+ * @return {IterableIterator<T>}
14
+ */
15
+ const createIterator = next => ({
16
+ /**
17
+ * @return {IterableIterator<T>}
18
+ */
19
+ [Symbol.iterator] () {
20
+ return this
21
+ },
22
+ // @ts-ignore
23
+ next
24
+ });
25
+
26
+ /**
27
+ * @template T
28
+ * @param {Iterator<T>} iterator
29
+ * @param {function(T):boolean} filter
30
+ */
31
+ const iteratorFilter = (iterator, filter) => createIterator(() => {
32
+ let res;
33
+ do {
34
+ res = iterator.next();
35
+ } while (!res.done && !filter(res.value))
36
+ return res
37
+ });
38
+
39
+ /**
40
+ * @template T,M
41
+ * @param {Iterator<T>} iterator
42
+ * @param {function(T):M} fmap
43
+ */
44
+ const iteratorMap = (iterator, fmap) => createIterator(() => {
45
+ const { done, value } = iterator.next();
46
+ return { done, value: done ? undefined : fmap(value) }
47
+ });
48
+
49
+ exports.createIterator = createIterator;
50
+ exports.iteratorFilter = iteratorFilter;
51
+ exports.iteratorMap = iteratorMap;
52
+ //# sourceMappingURL=iterator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iterator.js","sources":["../../../../../../node_modules/lib0/iterator.js"],"sourcesContent":["/**\n * Utility module to create and manipulate Iterators.\n *\n * @module iterator\n */\n\n/**\n * @template T,R\n * @param {Iterator<T>} iterator\n * @param {function(T):R} f\n * @return {IterableIterator<R>}\n */\nexport const mapIterator = (iterator, f) => ({\n [Symbol.iterator] () {\n return this\n },\n // @ts-ignore\n next () {\n const r = iterator.next()\n return { value: r.done ? undefined : f(r.value), done: r.done }\n }\n})\n\n/**\n * @template T\n * @param {function():IteratorResult<T>} next\n * @return {IterableIterator<T>}\n */\nexport const createIterator = next => ({\n /**\n * @return {IterableIterator<T>}\n */\n [Symbol.iterator] () {\n return this\n },\n // @ts-ignore\n next\n})\n\n/**\n * @template T\n * @param {Iterator<T>} iterator\n * @param {function(T):boolean} filter\n */\nexport const iteratorFilter = (iterator, filter) => createIterator(() => {\n let res\n do {\n res = iterator.next()\n } while (!res.done && !filter(res.value))\n return res\n})\n\n/**\n * @template T,M\n * @param {Iterator<T>} iterator\n * @param {function(T):M} fmap\n */\nexport const iteratorMap = (iterator, fmap) => createIterator(() => {\n const { done, value } = iterator.next()\n return { done, value: done ? undefined : fmap(value) }\n})\n"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;;;AAmBA;AACA;AACA;AACA;AACA;AACY,MAAC,cAAc,GAAG,IAAI,KAAK;AACvC;AACA;AACA;AACA,EAAE,CAAC,MAAM,CAAC,QAAQ,EAAE,GAAG;AACvB,IAAI,OAAO;AACX,EAAE,CAAC;AACH;AACA,EAAE;AACF,CAAC;;AAED;AACA;AACA;AACA;AACA;AACY,MAAC,cAAc,GAAG,CAAC,QAAQ,EAAE,MAAM,KAAK,cAAc,CAAC,MAAM;AACzE,EAAE,IAAI;AACN,EAAE,GAAG;AACL,IAAI,GAAG,GAAG,QAAQ,CAAC,IAAI;AACvB,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC;AAC1C,EAAE,OAAO;AACT,CAAC;;AAED;AACA;AACA;AACA;AACA;AACY,MAAC,WAAW,GAAG,CAAC,QAAQ,EAAE,IAAI,KAAK,cAAc,CAAC,MAAM;AACpE,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,QAAQ,CAAC,IAAI;AACvC,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,GAAG,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC;AACtD,CAAC;;;;;;","x_google_ignoreList":[0]}
@@ -0,0 +1,63 @@
1
+ 'use strict';
2
+
3
+ var symbol = require('./symbol.js');
4
+
5
+ const BOLD = symbol.create();
6
+ const UNBOLD = symbol.create();
7
+ const BLUE = symbol.create();
8
+ const GREY = symbol.create();
9
+ const GREEN = symbol.create();
10
+ const RED = symbol.create();
11
+ const PURPLE = symbol.create();
12
+ const ORANGE = symbol.create();
13
+ const UNCOLOR = symbol.create();
14
+
15
+ /* c8 ignore start */
16
+ /**
17
+ * @param {Array<undefined|string|Symbol|Object|number|function():any>} args
18
+ * @return {Array<string|object|number|undefined>}
19
+ */
20
+ const computeNoColorLoggingArgs = args => {
21
+ if (args.length === 1 && args[0]?.constructor === Function) {
22
+ args = /** @type {Array<string|Symbol|Object|number>} */ (/** @type {[function]} */ (args)[0]());
23
+ }
24
+ const strBuilder = [];
25
+ const logArgs = [];
26
+ // try with formatting until we find something unsupported
27
+ let i = 0;
28
+ for (; i < args.length; i++) {
29
+ const arg = args[i];
30
+ if (arg === undefined) {
31
+ break
32
+ } else if (arg.constructor === String || arg.constructor === Number) {
33
+ strBuilder.push(arg);
34
+ } else if (arg.constructor === Object) {
35
+ break
36
+ }
37
+ }
38
+ if (i > 0) {
39
+ // create logArgs with what we have so far
40
+ logArgs.push(strBuilder.join(''));
41
+ }
42
+ // append the rest
43
+ for (; i < args.length; i++) {
44
+ const arg = args[i];
45
+ if (!(arg instanceof Symbol)) {
46
+ logArgs.push(arg);
47
+ }
48
+ }
49
+ return logArgs
50
+ };
51
+ /* c8 ignore stop */
52
+
53
+ exports.BLUE = BLUE;
54
+ exports.BOLD = BOLD;
55
+ exports.GREEN = GREEN;
56
+ exports.GREY = GREY;
57
+ exports.ORANGE = ORANGE;
58
+ exports.PURPLE = PURPLE;
59
+ exports.RED = RED;
60
+ exports.UNBOLD = UNBOLD;
61
+ exports.UNCOLOR = UNCOLOR;
62
+ exports.computeNoColorLoggingArgs = computeNoColorLoggingArgs;
63
+ //# sourceMappingURL=logging.common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logging.common.js","sources":["../../../../../../node_modules/lib0/logging.common.js"],"sourcesContent":["import * as symbol from './symbol.js'\nimport * as time from './time.js'\nimport * as env from './environment.js'\nimport * as func from './function.js'\nimport * as json from './json.js'\n\nexport const BOLD = symbol.create()\nexport const UNBOLD = symbol.create()\nexport const BLUE = symbol.create()\nexport const GREY = symbol.create()\nexport const GREEN = symbol.create()\nexport const RED = symbol.create()\nexport const PURPLE = symbol.create()\nexport const ORANGE = symbol.create()\nexport const UNCOLOR = symbol.create()\n\n/* c8 ignore start */\n/**\n * @param {Array<undefined|string|Symbol|Object|number|function():any>} args\n * @return {Array<string|object|number|undefined>}\n */\nexport const computeNoColorLoggingArgs = 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 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 if (arg === undefined) {\n break\n } else if (arg.constructor === String || arg.constructor === Number) {\n strBuilder.push(arg)\n } else if (arg.constructor === Object) {\n break\n }\n }\n if (i > 0) {\n // create logArgs with what we have so far\n logArgs.push(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\nconst loggingColors = [GREEN, PURPLE, ORANGE, BLUE]\nlet nextColor = 0\nlet lastLoggingTime = time.getUnixTime()\n\n/* c8 ignore start */\n/**\n * @param {function(...any):void} _print\n * @param {string} moduleName\n * @return {function(...any):void}\n */\nexport const createModuleLogger = (_print, moduleName) => {\n const color = loggingColors[nextColor]\n const debugRegexVar = env.getVariable('log')\n const doLogging = debugRegexVar !== null &&\n (debugRegexVar === '*' || debugRegexVar === 'true' ||\n new RegExp(debugRegexVar, 'gi').test(moduleName))\n nextColor = (nextColor + 1) % loggingColors.length\n moduleName += ': '\n return !doLogging\n ? func.nop\n : (...args) => {\n if (args.length === 1 && args[0]?.constructor === Function) {\n args = args[0]()\n }\n const timeNow = time.getUnixTime()\n const timeDiff = timeNow - lastLoggingTime\n lastLoggingTime = timeNow\n _print(\n color,\n moduleName,\n UNCOLOR,\n ...args.map((arg) => {\n if (arg != null && arg.constructor === Uint8Array) {\n arg = Array.from(arg)\n }\n const t = typeof arg\n switch (t) {\n case 'string':\n case 'symbol':\n return arg\n default: {\n return json.stringify(arg)\n }\n }\n }),\n color,\n ' +' + timeDiff + 'ms'\n )\n }\n}\n/* c8 ignore stop */\n"],"names":["symbol.create"],"mappings":";;;;AAMY,MAAC,IAAI,GAAGA,aAAa;AACrB,MAAC,MAAM,GAAGA,aAAa;AACvB,MAAC,IAAI,GAAGA,aAAa;AACrB,MAAC,IAAI,GAAGA,aAAa;AACrB,MAAC,KAAK,GAAGA,aAAa;AACtB,MAAC,GAAG,GAAGA,aAAa;AACpB,MAAC,MAAM,GAAGA,aAAa;AACvB,MAAC,MAAM,GAAGA,aAAa;AACvB,MAAC,OAAO,GAAGA,aAAa;;AAEpC;AACA;AACA;AACA;AACA;AACY,MAAC,yBAAyB,GAAG,IAAI,IAAI;AACjD,EAAE,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,WAAW,KAAK,QAAQ,EAAE;AAC9D,IAAI,IAAI,gFAAgF,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE;AACnG,EAAE;AACF,EAAE,MAAM,UAAU,GAAG;AACrB,EAAE,MAAM,OAAO,GAAG;AAClB;AACA,EAAE,IAAI,CAAC,GAAG;AACV,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AAC/B,IAAI,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC;AACtB,IAAI,IAAI,GAAG,KAAK,SAAS,EAAE;AAC3B,MAAM;AACN,IAAI,CAAC,MAAM,IAAI,GAAG,CAAC,WAAW,KAAK,MAAM,IAAI,GAAG,CAAC,WAAW,KAAK,MAAM,EAAE;AACzE,MAAM,UAAU,CAAC,IAAI,CAAC,GAAG;AACzB,IAAI,CAAC,MAAM,IAAI,GAAG,CAAC,WAAW,KAAK,MAAM,EAAE;AAC3C,MAAM;AACN,IAAI;AACJ,EAAE;A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