@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,95 @@
1
+ /**
2
+ * Utility module to work with Arrays.
3
+ *
4
+ * @module array
5
+ */
6
+
7
+
8
+ /**
9
+ * Return the last element of an array. The element must exist
10
+ *
11
+ * @template L
12
+ * @param {ArrayLike<L>} arr
13
+ * @return {L}
14
+ */
15
+ const last = arr => arr[arr.length - 1];
16
+
17
+ /**
18
+ * Append elements from src to dest
19
+ *
20
+ * @template M
21
+ * @param {Array<M>} dest
22
+ * @param {Array<M>} src
23
+ */
24
+ const appendTo = (dest, src) => {
25
+ for (let i = 0; i < src.length; i++) {
26
+ dest.push(src[i]);
27
+ }
28
+ };
29
+
30
+ /**
31
+ * Transforms something array-like to an actual Array.
32
+ *
33
+ * @function
34
+ * @template T
35
+ * @param {ArrayLike<T>|Iterable<T>} arraylike
36
+ * @return {T}
37
+ */
38
+ const from = Array.from;
39
+
40
+ /**
41
+ * True iff condition holds on every element in the Array.
42
+ *
43
+ * @function
44
+ * @template {ArrayLike<any>} ARR
45
+ *
46
+ * @param {ARR} arr
47
+ * @param {ARR extends ArrayLike<infer S> ? ((value:S, index:number, arr:ARR) => boolean) : any} f
48
+ * @return {boolean}
49
+ */
50
+ const every = (arr, f) => {
51
+ for (let i = 0; i < arr.length; i++) {
52
+ if (!f(arr[i], i, arr)) {
53
+ return false
54
+ }
55
+ }
56
+ return true
57
+ };
58
+
59
+ /**
60
+ * True iff condition holds on some element in the Array.
61
+ *
62
+ * @function
63
+ * @template {ArrayLike<any>} ARR
64
+ *
65
+ * @param {ARR} arr
66
+ * @param {ARR extends ArrayLike<infer S> ? ((value:S, index:number, arr:ARR) => boolean) : never} f
67
+ * @return {boolean}
68
+ */
69
+ const some = (arr, f) => {
70
+ for (let i = 0; i < arr.length; i++) {
71
+ if (f(arr[i], i, arr)) {
72
+ return true
73
+ }
74
+ }
75
+ return false
76
+ };
77
+
78
+ /**
79
+ * @template T
80
+ * @param {number} len
81
+ * @param {function(number, Array<T>):T} f
82
+ * @return {Array<T>}
83
+ */
84
+ const unfold = (len, f) => {
85
+ const array = new Array(len);
86
+ for (let i = 0; i < len; i++) {
87
+ array[i] = f(i, array);
88
+ }
89
+ return array
90
+ };
91
+
92
+ const isArray = Array.isArray;
93
+
94
+ export { appendTo, every, from, isArray, last, some, unfold };
95
+ //# sourceMappingURL=array.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array.js","sources":["../../../../../../node_modules/lib0/array.js"],"sourcesContent":["/**\n * Utility module to work with Arrays.\n *\n * @module array\n */\n\nimport * as set from './set.js'\n\n/**\n * Return the last element of an array. The element must exist\n *\n * @template L\n * @param {ArrayLike<L>} arr\n * @return {L}\n */\nexport const last = arr => arr[arr.length - 1]\n\n/**\n * @template C\n * @return {Array<C>}\n */\nexport const create = () => /** @type {Array<C>} */ ([])\n\n/**\n * @template D\n * @param {Array<D>} a\n * @return {Array<D>}\n */\nexport const copy = a => /** @type {Array<D>} */ (a.slice())\n\n/**\n * Append elements from src to dest\n *\n * @template M\n * @param {Array<M>} dest\n * @param {Array<M>} src\n */\nexport const appendTo = (dest, src) => {\n for (let i = 0; i < src.length; i++) {\n dest.push(src[i])\n }\n}\n\n/**\n * Transforms something array-like to an actual Array.\n *\n * @function\n * @template T\n * @param {ArrayLike<T>|Iterable<T>} arraylike\n * @return {T}\n */\nexport const from = Array.from\n\n/**\n * True iff condition holds on every element in the Array.\n *\n * @function\n * @template {ArrayLike<any>} ARR\n *\n * @param {ARR} arr\n * @param {ARR extends ArrayLike<infer S> ? ((value:S, index:number, arr:ARR) => boolean) : any} f\n * @return {boolean}\n */\nexport const every = (arr, f) => {\n for (let i = 0; i < arr.length; i++) {\n if (!f(arr[i], i, arr)) {\n return false\n }\n }\n return true\n}\n\n/**\n * True iff condition holds on some element in the Array.\n *\n * @function\n * @template {ArrayLike<any>} ARR\n *\n * @param {ARR} arr\n * @param {ARR extends ArrayLike<infer S> ? ((value:S, index:number, arr:ARR) => boolean) : never} f\n * @return {boolean}\n */\nexport const some = (arr, f) => {\n for (let i = 0; i < arr.length; i++) {\n if (f(arr[i], i, arr)) {\n return true\n }\n }\n return false\n}\n\n/**\n * @template ELEM\n *\n * @param {ArrayLike<ELEM>} a\n * @param {ArrayLike<ELEM>} b\n * @return {boolean}\n */\nexport const equalFlat = (a, b) => a.length === b.length && every(a, (item, index) => item === b[index])\n\n/**\n * @template ELEM\n * @param {Array<Array<ELEM>>} arr\n * @return {Array<ELEM>}\n */\nexport const flatten = arr => fold(arr, /** @type {Array<ELEM>} */ ([]), (acc, val) => acc.concat(val))\n\n/**\n * @template T\n * @param {number} len\n * @param {function(number, Array<T>):T} f\n * @return {Array<T>}\n */\nexport const unfold = (len, f) => {\n const array = new Array(len)\n for (let i = 0; i < len; i++) {\n array[i] = f(i, array)\n }\n return array\n}\n\n/**\n * @template T\n * @template RESULT\n * @param {Array<T>} arr\n * @param {RESULT} seed\n * @param {function(RESULT, T, number):RESULT} folder\n */\nexport const fold = (arr, seed, folder) => arr.reduce(folder, seed)\n\nexport const isArray = Array.isArray\n\n/**\n * @template T\n * @param {Array<T>} arr\n * @return {Array<T>}\n */\nexport const unique = arr => from(set.from(arr))\n\n/**\n * @template T\n * @template M\n * @param {ArrayLike<T>} arr\n * @param {function(T):M} mapper\n * @return {Array<T>}\n */\nexport const uniqueBy = (arr, mapper) => {\n /**\n * @type {Set<M>}\n */\n const happened = set.create()\n /**\n * @type {Array<T>}\n */\n const result = []\n for (let i = 0; i < arr.length; i++) {\n const el = arr[i]\n const mapped = mapper(el)\n if (!happened.has(mapped)) {\n happened.add(mapped)\n result.push(el)\n }\n }\n return result\n}\n\n/**\n * @template {ArrayLike<any>} ARR\n * @template {function(ARR extends ArrayLike<infer T> ? T : never, number, ARR):any} MAPPER\n * @param {ARR} arr\n * @param {MAPPER} mapper\n * @return {Array<MAPPER extends function(...any): infer M ? M : never>}\n */\nexport const map = (arr, mapper) => {\n /**\n * @type {Array<any>}\n */\n const res = Array(arr.length)\n for (let i = 0; i < arr.length; i++) {\n res[i] = mapper(/** @type {any} */ (arr[i]), i, /** @type {any} */ (arr))\n }\n return /** @type {any} */ (res)\n}\n\n/**\n * This function bubble-sorts a single item to the correct position. The sort happens in-place and\n * might be useful to ensure that a single item is at the correct position in an otherwise sorted\n * array.\n *\n * @example\n * const arr = [3, 2, 5]\n * arr.sort((a, b) => a - b)\n * arr // => [2, 3, 5]\n * arr.splice(1, 0, 7)\n * array.bubbleSortItem(arr, 1, (a, b) => a - b)\n * arr // => [2, 3, 5, 7]\n *\n * @template T\n * @param {Array<T>} arr\n * @param {number} i\n * @param {(a:T,b:T) => number} compareFn\n */\nexport const bubblesortItem = (arr, i, compareFn) => {\n const n = arr[i]\n let j = i\n // try to sort to the right\n while (j + 1 < arr.length && compareFn(n, arr[j + 1]) > 0) {\n arr[j] = arr[j + 1]\n arr[++j] = n\n }\n if (i === j && j > 0) { // no change yet\n // sort to the left\n while (j > 0 && compareFn(arr[j - 1], n) > 0) {\n arr[j] = arr[j - 1]\n arr[--j] = n\n }\n }\n return j\n}\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,IAAI,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC;;AAe7C;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,QAAQ,GAAG,CAAC,IAAI,EAAE,GAAG,KAAK;AACvC,EAAE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AACvC,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AACpB,EAAE;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,IAAI,GAAG,KAAK,CAAC;;AAE1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,KAAK,GAAG,CAAC,GAAG,EAAE,CAAC,KAAK;AACjC,EAAE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AACvC,IAAI,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE;AAC5B,MAAM,OAAO;AACb,IAAI;AACJ,EAAE;AACF,EAAE,OAAO;AACT;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,IAAI,GAAG,CAAC,GAAG,EAAE,CAAC,KAAK;AAChC,EAAE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AACvC,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE;AAC3B,MAAM,OAAO;AACb,IAAI;AACJ,EAAE;AACF,EAAE,OAAO;AACT;;AAkBA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,MAAM,GAAG,CAAC,GAAG,EAAE,CAAC,KAAK;AAClC,EAAE,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,GAAG;AAC7B,EAAE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;AAChC,IAAI,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK;AACzB,EAAE;AACF,EAAE,OAAO;AACT;;AAWY,MAAC,OAAO,GAAG,KAAK,CAAC;;;;","x_google_ignoreList":[0]}
@@ -0,0 +1,30 @@
1
+ /* eslint-env browser */
2
+
3
+ /**
4
+ * Binary data constants.
5
+ *
6
+ * @module binary
7
+ */
8
+
9
+ /**
10
+ * n-th bit activated.
11
+ *
12
+ * @type {number}
13
+ */
14
+ const BIT1 = 1;
15
+ const BIT2 = 2;
16
+ const BIT3 = 4;
17
+ const BIT4 = 8;
18
+ const BIT6 = 32;
19
+ const BIT7 = 64;
20
+ const BIT8 = 128;
21
+ const BITS5 = 31;
22
+ const BITS6 = 63;
23
+ const BITS7 = 127;
24
+ /**
25
+ * @type {number}
26
+ */
27
+ const BITS31 = 0x7FFFFFFF;
28
+
29
+ export { BIT1, BIT2, BIT3, BIT4, BIT6, BIT7, BIT8, BITS31, BITS5, BITS6, BITS7 };
30
+ //# sourceMappingURL=binary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"binary.js","sources":["../../../../../../node_modules/lib0/binary.js"],"sourcesContent":["/* eslint-env browser */\n\n/**\n * Binary data constants.\n *\n * @module binary\n */\n\n/**\n * n-th bit activated.\n *\n * @type {number}\n */\nexport const BIT1 = 1\nexport const BIT2 = 2\nexport const BIT3 = 4\nexport const BIT4 = 8\nexport const BIT5 = 16\nexport const BIT6 = 32\nexport const BIT7 = 64\nexport const BIT8 = 128\nexport const BIT9 = 256\nexport const BIT10 = 512\nexport const BIT11 = 1024\nexport const BIT12 = 2048\nexport const BIT13 = 4096\nexport const BIT14 = 8192\nexport const BIT15 = 16384\nexport const BIT16 = 32768\nexport const BIT17 = 65536\nexport const BIT18 = 1 << 17\nexport const BIT19 = 1 << 18\nexport const BIT20 = 1 << 19\nexport const BIT21 = 1 << 20\nexport const BIT22 = 1 << 21\nexport const BIT23 = 1 << 22\nexport const BIT24 = 1 << 23\nexport const BIT25 = 1 << 24\nexport const BIT26 = 1 << 25\nexport const BIT27 = 1 << 26\nexport const BIT28 = 1 << 27\nexport const BIT29 = 1 << 28\nexport const BIT30 = 1 << 29\nexport const BIT31 = 1 << 30\nexport const BIT32 = 1 << 31\n\n/**\n * First n bits activated.\n *\n * @type {number}\n */\nexport const BITS0 = 0\nexport const BITS1 = 1\nexport const BITS2 = 3\nexport const BITS3 = 7\nexport const BITS4 = 15\nexport const BITS5 = 31\nexport const BITS6 = 63\nexport const BITS7 = 127\nexport const BITS8 = 255\nexport const BITS9 = 511\nexport const BITS10 = 1023\nexport const BITS11 = 2047\nexport const BITS12 = 4095\nexport const BITS13 = 8191\nexport const BITS14 = 16383\nexport const BITS15 = 32767\nexport const BITS16 = 65535\nexport const BITS17 = BIT18 - 1\nexport const BITS18 = BIT19 - 1\nexport const BITS19 = BIT20 - 1\nexport const BITS20 = BIT21 - 1\nexport const BITS21 = BIT22 - 1\nexport const BITS22 = BIT23 - 1\nexport const BITS23 = BIT24 - 1\nexport const BITS24 = BIT25 - 1\nexport const BITS25 = BIT26 - 1\nexport const BITS26 = BIT27 - 1\nexport const BITS27 = BIT28 - 1\nexport const BITS28 = BIT29 - 1\nexport const BITS29 = BIT30 - 1\nexport const BITS30 = BIT31 - 1\n/**\n * @type {number}\n */\nexport const BITS31 = 0x7FFFFFFF\n/**\n * @type {number}\n */\nexport const BITS32 = 0xFFFFFFFF\n"],"names":[],"mappings":"AAAA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACY,MAAC,IAAI,GAAG;AACR,MAAC,IAAI,GAAG;AACR,MAAC,IAAI,GAAG;AACR,MAAC,IAAI,GAAG;AAER,MAAC,IAAI,GAAG;AACR,MAAC,IAAI,GAAG;AACR,MAAC,IAAI,GAAG;AAoCR,MAAC,KAAK,GAAG;AACT,MAAC,KAAK,GAAG;AACT,MAAC,KAAK,GAAG;AAwBrB;AACA;AACA;AACY,MAAC,MAAM,GAAG;;;;","x_google_ignoreList":[0]}
@@ -0,0 +1,117 @@
1
+ import { setIfUndefined } from './map.js';
2
+ import { create } from './set.js';
3
+ import { fromBase64, toBase64, createUint8ArrayFromArrayBuffer } from './buffer.js';
4
+ import { onChange, varStorage, offChange } from './storage.js';
5
+
6
+ /* eslint-env browser */
7
+
8
+
9
+ /**
10
+ * @typedef {Object} Channel
11
+ * @property {Set<function(any, any):any>} Channel.subs
12
+ * @property {any} Channel.bc
13
+ */
14
+
15
+ /**
16
+ * @type {Map<string, Channel>}
17
+ */
18
+ const channels = new Map();
19
+
20
+ /* c8 ignore start */
21
+ class LocalStoragePolyfill {
22
+ /**
23
+ * @param {string} room
24
+ */
25
+ constructor (room) {
26
+ this.room = room;
27
+ /**
28
+ * @type {null|function({data:Uint8Array}):void}
29
+ */
30
+ this.onmessage = null;
31
+ /**
32
+ * @param {any} e
33
+ */
34
+ this._onChange = e => e.key === room && this.onmessage !== null && this.onmessage({ data: fromBase64(e.newValue || '') });
35
+ onChange(this._onChange);
36
+ }
37
+
38
+ /**
39
+ * @param {ArrayBuffer} buf
40
+ */
41
+ postMessage (buf) {
42
+ varStorage.setItem(this.room, toBase64(createUint8ArrayFromArrayBuffer(buf)));
43
+ }
44
+
45
+ close () {
46
+ offChange(this._onChange);
47
+ }
48
+ }
49
+ /* c8 ignore stop */
50
+
51
+ // Use BroadcastChannel or Polyfill
52
+ /* c8 ignore next */
53
+ const BC = typeof BroadcastChannel === 'undefined' ? LocalStoragePolyfill : BroadcastChannel;
54
+
55
+ /**
56
+ * @param {string} room
57
+ * @return {Channel}
58
+ */
59
+ const getChannel = room =>
60
+ setIfUndefined(channels, room, () => {
61
+ const subs = create();
62
+ const bc = new BC(room);
63
+ /**
64
+ * @param {{data:ArrayBuffer}} e
65
+ */
66
+ /* c8 ignore next */
67
+ bc.onmessage = e => subs.forEach(sub => sub(e.data, 'broadcastchannel'));
68
+ return {
69
+ bc, subs
70
+ }
71
+ });
72
+
73
+ /**
74
+ * Subscribe to global `publish` events.
75
+ *
76
+ * @function
77
+ * @param {string} room
78
+ * @param {function(any, any):any} f
79
+ */
80
+ const subscribe = (room, f) => {
81
+ getChannel(room).subs.add(f);
82
+ return f
83
+ };
84
+
85
+ /**
86
+ * Unsubscribe from `publish` global events.
87
+ *
88
+ * @function
89
+ * @param {string} room
90
+ * @param {function(any, any):any} f
91
+ */
92
+ const unsubscribe = (room, f) => {
93
+ const channel = getChannel(room);
94
+ const unsubscribed = channel.subs.delete(f);
95
+ if (unsubscribed && channel.subs.size === 0) {
96
+ channel.bc.close();
97
+ channels.delete(room);
98
+ }
99
+ return unsubscribed
100
+ };
101
+
102
+ /**
103
+ * Publish data to all subscribers (including subscribers on this tab)
104
+ *
105
+ * @function
106
+ * @param {string} room
107
+ * @param {any} data
108
+ * @param {any} [origin]
109
+ */
110
+ const publish = (room, data, origin = null) => {
111
+ const c = getChannel(room);
112
+ c.bc.postMessage(data);
113
+ c.subs.forEach(sub => sub(data, origin));
114
+ };
115
+
116
+ export { publish, subscribe, unsubscribe };
117
+ //# sourceMappingURL=broadcastchannel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"broadcastchannel.js","sources":["../../../../../../node_modules/lib0/broadcastchannel.js"],"sourcesContent":["/* eslint-env browser */\n\n/**\n * Helpers for cross-tab communication using broadcastchannel with LocalStorage fallback.\n *\n * ```js\n * // In browser window A:\n * broadcastchannel.subscribe('my events', data => console.log(data))\n * broadcastchannel.publish('my events', 'Hello world!') // => A: 'Hello world!' fires synchronously in same tab\n *\n * // In browser window B:\n * broadcastchannel.publish('my events', 'hello from tab B') // => A: 'hello from tab B'\n * ```\n *\n * @module broadcastchannel\n */\n\n// @todo before next major: use Uint8Array instead as buffer object\n\nimport * as map from './map.js'\nimport * as set from './set.js'\nimport * as buffer from './buffer.js'\nimport * as storage from './storage.js'\n\n/**\n * @typedef {Object} Channel\n * @property {Set<function(any, any):any>} Channel.subs\n * @property {any} Channel.bc\n */\n\n/**\n * @type {Map<string, Channel>}\n */\nconst channels = new Map()\n\n/* c8 ignore start */\nclass LocalStoragePolyfill {\n /**\n * @param {string} room\n */\n constructor (room) {\n this.room = room\n /**\n * @type {null|function({data:Uint8Array}):void}\n */\n this.onmessage = null\n /**\n * @param {any} e\n */\n this._onChange = e => e.key === room && this.onmessage !== null && this.onmessage({ data: buffer.fromBase64(e.newValue || '') })\n storage.onChange(this._onChange)\n }\n\n /**\n * @param {ArrayBuffer} buf\n */\n postMessage (buf) {\n storage.varStorage.setItem(this.room, buffer.toBase64(buffer.createUint8ArrayFromArrayBuffer(buf)))\n }\n\n close () {\n storage.offChange(this._onChange)\n }\n}\n/* c8 ignore stop */\n\n// Use BroadcastChannel or Polyfill\n/* c8 ignore next */\nconst BC = typeof BroadcastChannel === 'undefined' ? LocalStoragePolyfill : BroadcastChannel\n\n/**\n * @param {string} room\n * @return {Channel}\n */\nconst getChannel = room =>\n map.setIfUndefined(channels, room, () => {\n const subs = set.create()\n const bc = new BC(room)\n /**\n * @param {{data:ArrayBuffer}} e\n */\n /* c8 ignore next */\n bc.onmessage = e => subs.forEach(sub => sub(e.data, 'broadcastchannel'))\n return {\n bc, subs\n }\n })\n\n/**\n * Subscribe to global `publish` events.\n *\n * @function\n * @param {string} room\n * @param {function(any, any):any} f\n */\nexport const subscribe = (room, f) => {\n getChannel(room).subs.add(f)\n return f\n}\n\n/**\n * Unsubscribe from `publish` global events.\n *\n * @function\n * @param {string} room\n * @param {function(any, any):any} f\n */\nexport const unsubscribe = (room, f) => {\n const channel = getChannel(room)\n const unsubscribed = channel.subs.delete(f)\n if (unsubscribed && channel.subs.size === 0) {\n channel.bc.close()\n channels.delete(room)\n }\n return unsubscribed\n}\n\n/**\n * Publish data to all subscribers (including subscribers on this tab)\n *\n * @function\n * @param {string} room\n * @param {any} data\n * @param {any} [origin]\n */\nexport const publish = (room, data, origin = null) => {\n const c = getChannel(room)\n c.bc.postMessage(data)\n c.subs.forEach(sub => sub(data, origin))\n}\n"],"names":["buffer.fromBase64","storage.onChange","storage.varStorage","buffer.toBase64","buffer.createUint8ArrayFromArrayBuffer","storage.offChange","map.setIfUndefined","set.create"],"mappings":";;;;;AAAA;;;AAwBA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,MAAM,QAAQ,GAAG,IAAI,GAAG;;AAExB;AACA,MAAM,oBAAoB,CAAC;AAC3B;AACA;AACA;AACA,EAAE,WAAW,CAAC,CAAC,IAAI,EAAE;AACrB,IAAI,IAAI,CAAC,IAAI,GAAG;AAChB;AACA;AACA;AACA,IAAI,IAAI,CAAC,SAAS,GAAG;AACrB;AACA;AACA;AACA,IAAI,IAAI,CAAC,SAAS,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,IAAI,IAAI,IAAI,CAAC,SAAS,KAAK,IAAI,IAAI,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAEA,UAAiB,CAAC,CAAC,CAAC,QAAQ,IAAI,EAAE,CAAC,EAAE;AACnI,IAAIC,QAAgB,CAAC,IAAI,CAAC,SAAS;AACnC,EAAE;;AAEF;AACA;AACA;AACA,EAAE,WAAW,CAAC,CAAC,GAAG,EAAE;AACpB,IAAIC,UAAkB,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAEC,QAAe,CAACC,+BAAsC,CAAC,GAAG,CAAC,CAAC;AACtG,EAAE;;AAEF,EAAE,KAAK,CAAC,GAAG;AACX,IAAIC,SAAiB,CAAC,IAAI,CAAC,SAAS;AACpC,EAAE;AACF;AACA;;AAEA;AACA;AACA,MAAM,EAAE,GAAG,OAAO,gBAAgB,KAAK,WAAW,GAAG,oBAAoB,GAAG;;AAE5E;AACA;AACA;AACA;AACA,MAAM,UAAU,GAAG,IAAI;AACvB,EAAEC,cAAkB,CAAC,QAAQ,EAAE,IAAI,EAAE,MAAM;AAC3C,IAAI,MAAM,IAAI,GAAGC,MAAU;AAC3B,IAAI,MAAM,EAAE,GAAG,IAAI,EAAE,CAAC,IAAI;AAC1B;AACA;AACA;AACA;AACA,IAAI,EAAE,CAAC,SAAS,GAAG,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,kBAAkB,CAAC;AAC3E,IAAI,OAAO;AACX,MAAM,EAAE,EAAE;AACV;AACA,EAAE,CAAC;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,SAAS,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK;AACtC,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7B,EAAE,OAAO;AACT;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,WAAW,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK;AACxC,EAAE,MAAM,OAAO,GAAG,UAAU,CAAC,IAAI;AACjC,EAAE,MAAM,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC5C,EAAE,IAAI,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,EAAE;AAC/C,IAAI,OAAO,CAAC,EAAE,CAAC,KAAK;AACpB,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI;AACxB,EAAE;AACF,EAAE,OAAO;AACT;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,OAAO,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,KAAK;AACtD,EAAE,MAAM,CAAC,GAAG,UAAU,CAAC,IAAI;AAC3B,EAAE,CAAC,CAAC,EAAE,CAAC,WAAW,CAAC,IAAI;AACvB,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC;AACzC;;;;","x_google_ignoreList":[0]}
@@ -0,0 +1,96 @@
1
+ import { fromCharCode } from './string.js';
2
+ import { isBrowser } from './environment.js';
3
+
4
+ /**
5
+ * Utility functions to work with buffers (Uint8Array).
6
+ *
7
+ * @module buffer
8
+ */
9
+
10
+
11
+ /**
12
+ * @param {number} len
13
+ */
14
+ const createUint8ArrayFromLen = len => new Uint8Array(len);
15
+
16
+ /**
17
+ * Create Uint8Array with initial content from buffer
18
+ *
19
+ * @param {ArrayBuffer} buffer
20
+ * @param {number} byteOffset
21
+ * @param {number} length
22
+ */
23
+ const createUint8ArrayViewFromArrayBuffer = (buffer, byteOffset, length) => new Uint8Array(buffer, byteOffset, length);
24
+
25
+ /**
26
+ * Create Uint8Array with initial content from buffer
27
+ *
28
+ * @param {ArrayBuffer} buffer
29
+ */
30
+ const createUint8ArrayFromArrayBuffer = buffer => new Uint8Array(buffer);
31
+
32
+ /* c8 ignore start */
33
+ /**
34
+ * @param {Uint8Array} bytes
35
+ * @return {string}
36
+ */
37
+ const toBase64Browser = bytes => {
38
+ let s = '';
39
+ for (let i = 0; i < bytes.byteLength; i++) {
40
+ s += fromCharCode(bytes[i]);
41
+ }
42
+ // eslint-disable-next-line no-undef
43
+ return btoa(s)
44
+ };
45
+ /* c8 ignore stop */
46
+
47
+ /**
48
+ * @param {Uint8Array} bytes
49
+ * @return {string}
50
+ */
51
+ const toBase64Node = bytes => Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength).toString('base64');
52
+
53
+ /* c8 ignore start */
54
+ /**
55
+ * @param {string} s
56
+ * @return {Uint8Array<ArrayBuffer>}
57
+ */
58
+ const fromBase64Browser = s => {
59
+ // eslint-disable-next-line no-undef
60
+ const a = atob(s);
61
+ const bytes = createUint8ArrayFromLen(a.length);
62
+ for (let i = 0; i < a.length; i++) {
63
+ bytes[i] = a.charCodeAt(i);
64
+ }
65
+ return bytes
66
+ };
67
+ /* c8 ignore stop */
68
+
69
+ /**
70
+ * @param {string} s
71
+ */
72
+ const fromBase64Node = s => {
73
+ const buf = Buffer.from(s, 'base64');
74
+ return createUint8ArrayViewFromArrayBuffer(buf.buffer, buf.byteOffset, buf.byteLength)
75
+ };
76
+
77
+ /* c8 ignore next */
78
+ const toBase64 = isBrowser ? toBase64Browser : toBase64Node;
79
+
80
+ /* c8 ignore next */
81
+ const fromBase64 = isBrowser ? fromBase64Browser : fromBase64Node;
82
+
83
+ /**
84
+ * Copy the content of an Uint8Array view to a new ArrayBuffer.
85
+ *
86
+ * @param {Uint8Array} uint8Array
87
+ * @return {Uint8Array}
88
+ */
89
+ const copyUint8Array = uint8Array => {
90
+ const newBuf = createUint8ArrayFromLen(uint8Array.byteLength);
91
+ newBuf.set(uint8Array);
92
+ return newBuf
93
+ };
94
+
95
+ export { copyUint8Array, createUint8ArrayFromArrayBuffer, createUint8ArrayFromLen, createUint8ArrayViewFromArrayBuffer, fromBase64, toBase64 };
96
+ //# sourceMappingURL=buffer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buffer.js","sources":["../../../../../../node_modules/lib0/buffer.js"],"sourcesContent":["/**\n * Utility functions to work with buffers (Uint8Array).\n *\n * @module buffer\n */\n\nimport * as string from './string.js'\nimport * as env from './environment.js'\nimport * as array from './array.js'\nimport * as math from './math.js'\nimport * as encoding from './encoding.js'\nimport * as decoding from './decoding.js'\n\n/**\n * @param {number} len\n */\nexport const createUint8ArrayFromLen = len => new Uint8Array(len)\n\n/**\n * Create Uint8Array with initial content from buffer\n *\n * @param {ArrayBuffer} buffer\n * @param {number} byteOffset\n * @param {number} length\n */\nexport const createUint8ArrayViewFromArrayBuffer = (buffer, byteOffset, length) => new Uint8Array(buffer, byteOffset, length)\n\n/**\n * Create Uint8Array with initial content from buffer\n *\n * @param {ArrayBuffer} buffer\n */\nexport const createUint8ArrayFromArrayBuffer = buffer => new Uint8Array(buffer)\n\n/* c8 ignore start */\n/**\n * @param {Uint8Array} bytes\n * @return {string}\n */\nconst toBase64Browser = bytes => {\n let s = ''\n for (let i = 0; i < bytes.byteLength; i++) {\n s += string.fromCharCode(bytes[i])\n }\n // eslint-disable-next-line no-undef\n return btoa(s)\n}\n/* c8 ignore stop */\n\n/**\n * @param {Uint8Array} bytes\n * @return {string}\n */\nconst toBase64Node = bytes => Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength).toString('base64')\n\n/* c8 ignore start */\n/**\n * @param {string} s\n * @return {Uint8Array<ArrayBuffer>}\n */\nconst fromBase64Browser = s => {\n // eslint-disable-next-line no-undef\n const a = atob(s)\n const bytes = createUint8ArrayFromLen(a.length)\n for (let i = 0; i < a.length; i++) {\n bytes[i] = a.charCodeAt(i)\n }\n return bytes\n}\n/* c8 ignore stop */\n\n/**\n * @param {string} s\n */\nconst fromBase64Node = s => {\n const buf = Buffer.from(s, 'base64')\n return createUint8ArrayViewFromArrayBuffer(buf.buffer, buf.byteOffset, buf.byteLength)\n}\n\n/* c8 ignore next */\nexport const toBase64 = env.isBrowser ? toBase64Browser : toBase64Node\n\n/* c8 ignore next */\nexport const fromBase64 = env.isBrowser ? fromBase64Browser : fromBase64Node\n\n/**\n * Implements base64url - see https://datatracker.ietf.org/doc/html/rfc4648#section-5\n * @param {Uint8Array} buf\n */\nexport const toBase64UrlEncoded = buf => toBase64(buf).replaceAll('+', '-').replaceAll('/', '_').replaceAll('=', '')\n\n/**\n * @param {string} base64\n */\nexport const fromBase64UrlEncoded = base64 => fromBase64(base64.replaceAll('-', '+').replaceAll('_', '/'))\n\n/**\n * Base64 is always a more efficient choice. This exists for utility purposes only.\n *\n * @param {Uint8Array} buf\n */\nexport const toHexString = buf => array.map(buf, b => b.toString(16).padStart(2, '0')).join('')\n\n/**\n * Note: This function expects that the hex doesn't start with 0x..\n *\n * @param {string} hex\n */\nexport const fromHexString = hex => {\n const hlen = hex.length\n const buf = new Uint8Array(math.ceil(hlen / 2))\n for (let i = 0; i < hlen; i += 2) {\n buf[buf.length - i / 2 - 1] = Number.parseInt(hex.slice(hlen - i - 2, hlen - i), 16)\n }\n return buf\n}\n\n/**\n * Copy the content of an Uint8Array view to a new ArrayBuffer.\n *\n * @param {Uint8Array} uint8Array\n * @return {Uint8Array}\n */\nexport const copyUint8Array = uint8Array => {\n const newBuf = createUint8ArrayFromLen(uint8Array.byteLength)\n newBuf.set(uint8Array)\n return newBuf\n}\n\n/**\n * Encode anything as a UInt8Array. It's a pun on typescripts's `any` type.\n * See encoding.writeAny for more information.\n *\n * @param {any} data\n * @return {Uint8Array}\n */\nexport const encodeAny = data =>\n encoding.encode(encoder => encoding.writeAny(encoder, data))\n\n/**\n * Decode an any-encoded value.\n *\n * @param {Uint8Array} buf\n * @return {any}\n */\nexport const decodeAny = buf => decoding.readAny(decoding.createDecoder(buf))\n\n/**\n * Shift Byte Array {N} bits to the left. Does not expand byte array.\n *\n * @param {Uint8Array} bs\n * @param {number} N should be in the range of [0-7]\n */\nexport const shiftNBitsLeft = (bs, N) => {\n if (N === 0) return bs\n bs = new Uint8Array(bs)\n bs[0] <<= N\n for (let i = 1; i < bs.length; i++) {\n bs[i - 1] |= bs[i] >>> (8 - N)\n bs[i] <<= N\n }\n return bs\n}\n"],"names":["string.fromCharCode","env.isBrowser"],"mappings":";;;AAAA;AACA;AACA;AACA;AACA;;;AASA;AACA;AACA;AACY,MAAC,uBAAuB,GAAG,GAAG,IAAI,IAAI,UAAU,CAAC,GAAG;;AAEhE;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,mCAAmC,GAAG,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,KAAK,IAAI,UAAU,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM;;AAE5H;AACA;AACA;AACA;AACA;AACY,MAAC,+BAA+B,GAAG,MAAM,IAAI,IAAI,UAAU,CAAC,MAAM;;AAE9E;AACA;AACA;AACA;AACA;AACA,MAAM,eAAe,GAAG,KAAK,IAAI;AACjC,EAAE,IAAI,CAAC,GAAG;AACV,EAAE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE;AAC7C,IAAI,CAAC,IAAIA,YAAmB,CAAC,KAAK,CAAC,CAAC,CAAC;AACrC,EAAE;AACF;AACA,EAAE,OAAO,IAAI,CAAC,CAAC;AACf;AACA;;AAEA;AACA;AACA;AACA;AACA,MAAM,YAAY,GAAG,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,QAAQ;;AAE7G;AACA;AACA;AACA;AACA;AACA,MAAM,iBAAiB,GAAG,CAAC,IAAI;AAC/B;AACA,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;AAClB,EAAE,MAAM,KAAK,GAAG,uBAAuB,CAAC,CAAC,CAAC,MAAM;AAChD,EAAE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AACrC,IAAI,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC;AAC7B,EAAE;AACF,EAAE,OAAO;AACT;AACA;;AAEA;AACA;AACA;AACA,MAAM,cAAc,GAAG,CAAC,IAAI;AAC5B,EAAE,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,QAAQ;AACrC,EAAE,OAAO,mCAAmC,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,UAAU;AACvF;;AAEA;AACY,MAAC,QAAQ,GAAGC,SAAa,GAAG,eAAe,GAAG;;AAE1D;AACY,MAAC,UAAU,GAAGA,SAAa,GAAG,iBAAiB,GAAG;;AAkC9D;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,cAAc,GAAG,UAAU,IAAI;AAC5C,EAAE,MAAM,MAAM,GAAG,uBAAuB,CAAC,UAAU,CAAC,UAAU;AAC9D,EAAE,MAAM,CAAC,GAAG,CAAC,UAAU;AACvB,EAAE,OAAO;AACT;;;;","x_google_ignoreList":[0]}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Often used conditions.
3
+ *
4
+ * @module conditions
5
+ */
6
+
7
+ /**
8
+ * @template T
9
+ * @param {T|null|undefined} v
10
+ * @return {T|null}
11
+ */
12
+ /* c8 ignore next */
13
+ const undefinedToNull = v => v === undefined ? null : v;
14
+
15
+ export { undefinedToNull };
16
+ //# sourceMappingURL=conditions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conditions.js","sources":["../../../../../../node_modules/lib0/conditions.js"],"sourcesContent":["/**\n * Often used conditions.\n *\n * @module conditions\n */\n\n/**\n * @template T\n * @param {T|null|undefined} v\n * @return {T|null}\n */\n/* c8 ignore next */\nexport const undefinedToNull = v => v === undefined ? null : v\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,eAAe,GAAG,CAAC,IAAI,CAAC,KAAK,SAAS,GAAG,IAAI,GAAG;;;;","x_google_ignoreList":[0]}