@likec4/core 1.47.0 → 1.49.0

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 (152) hide show
  1. package/LICENSE +1 -1
  2. package/dist/THIRD-PARTY-LICENSES.md +1012 -0
  3. package/dist/_chunks/Builder.view-element.mjs +2 -0
  4. package/dist/_chunks/LikeC4Model.d.mts +1283 -0
  5. package/dist/_chunks/RichText.mjs +1 -0
  6. package/dist/_chunks/_types.d.mts +777 -0
  7. package/dist/_chunks/_types2.d.mts +36 -0
  8. package/dist/_chunks/assignTagColors.mjs +1 -0
  9. package/dist/_chunks/calcDriftsFromSnapshot.mjs +1 -0
  10. package/dist/_chunks/guards.d.mts +2026 -0
  11. package/dist/_chunks/guards.mjs +4 -0
  12. package/dist/_chunks/index.d.mts +288 -0
  13. package/dist/_chunks/libs/@mantine/colors-generator.mjs +15 -0
  14. package/dist/_chunks/libs/@radix-ui/colors.mjs +1 -0
  15. package/dist/_chunks/libs/@ungap/structured-clone.mjs +1 -0
  16. package/dist/_chunks/libs/bail.mjs +1 -0
  17. package/dist/_chunks/libs/ccount.mjs +1 -0
  18. package/dist/_chunks/libs/character-entities-html4.mjs +1 -0
  19. package/dist/_chunks/libs/character-entities-legacy.mjs +1 -0
  20. package/dist/_chunks/libs/character-entities.mjs +2 -0
  21. package/dist/_chunks/libs/comma-separated-tokens.mjs +1 -0
  22. package/dist/_chunks/libs/decode-named-character-reference.mjs +1 -0
  23. package/dist/_chunks/libs/defu.mjs +1 -0
  24. package/dist/_chunks/libs/devlop.mjs +1 -0
  25. package/dist/_chunks/libs/escape-string-regexp.mjs +1 -0
  26. package/dist/_chunks/libs/extend.mjs +1 -0
  27. package/dist/_chunks/libs/graphology-dag.mjs +1 -0
  28. package/dist/_chunks/libs/graphology.mjs +1 -0
  29. package/dist/_chunks/libs/hast-util-sanitize.mjs +1 -0
  30. package/dist/_chunks/libs/hast-util-to-html.mjs +9 -0
  31. package/dist/_chunks/libs/is-plain-obj.mjs +1 -0
  32. package/dist/_chunks/libs/longest-streak.mjs +1 -0
  33. package/dist/_chunks/libs/markdown-table.mjs +2 -0
  34. package/dist/_chunks/libs/mdast-util-find-and-replace.mjs +1 -0
  35. package/dist/_chunks/libs/mdast-util-from-markdown.mjs +3 -0
  36. package/dist/_chunks/libs/mdast-util-gfm.mjs +15 -0
  37. package/dist/_chunks/libs/mdast-util-to-hast.mjs +11 -0
  38. package/dist/_chunks/libs/micromark-extension-gfm.mjs +1 -0
  39. package/dist/_chunks/libs/mnemonist.d.mts +164 -0
  40. package/dist/_chunks/libs/mnemonist.mjs +1 -0
  41. package/dist/_chunks/libs/natural-compare-lite.mjs +9 -0
  42. package/dist/_chunks/libs/ohash.mjs +1 -0
  43. package/dist/_chunks/libs/rehype-sanitize.mjs +1 -0
  44. package/dist/_chunks/libs/rehype-stringify.mjs +1 -0
  45. package/dist/_chunks/libs/remark-gfm.mjs +1 -0
  46. package/dist/_chunks/libs/remark-github-blockquote-alert.mjs +3 -0
  47. package/dist/_chunks/libs/remark-parse.mjs +1 -0
  48. package/dist/_chunks/libs/remark-rehype.mjs +1 -0
  49. package/dist/_chunks/libs/remeda.mjs +1 -0
  50. package/dist/_chunks/libs/trough.mjs +1 -0
  51. package/dist/_chunks/libs/unified.mjs +1 -0
  52. package/dist/_chunks/rolldown-runtime.mjs +1 -0
  53. package/dist/_chunks/theme.d.mts +148 -0
  54. package/dist/_chunks/to-text.d.mts +404 -0
  55. package/dist/_chunks/to-text.mjs +1 -0
  56. package/dist/_chunks/vector.d.mts +198 -0
  57. package/dist/_chunks/vector.mjs +1 -0
  58. package/dist/builder/index.d.mts +5 -775
  59. package/dist/builder/index.mjs +1 -1053
  60. package/dist/compute-view/index.d.mts +156 -56
  61. package/dist/compute-view/index.mjs +2 -229
  62. package/dist/geometry/index.d.mts +2 -109
  63. package/dist/geometry/index.mjs +1 -328
  64. package/dist/index.d.mts +14 -20
  65. package/dist/index.mjs +1 -18
  66. package/dist/model/index.d.mts +5 -57
  67. package/dist/model/index.mjs +1 -4
  68. package/dist/styles/index.d.mts +3 -117
  69. package/dist/styles/index.mjs +1 -63
  70. package/dist/types/index.d.mts +3 -47
  71. package/dist/types/index.mjs +1 -17
  72. package/dist/utils/graphology/index.d.mts +2 -1864
  73. package/dist/utils/graphology/index.mjs +1 -1
  74. package/dist/utils/index.d.mts +4 -124
  75. package/dist/utils/index.mjs +1 -44
  76. package/package.json +20 -24
  77. package/compute-view/relationships/package.json +0 -4
  78. package/dist/compute-view/relationships-view/index.d.mts +0 -51
  79. package/dist/compute-view/relationships-view/index.mjs +0 -185
  80. package/dist/model/connection/deployment/index.d.mts +0 -15
  81. package/dist/model/connection/deployment/index.mjs +0 -2
  82. package/dist/model/connection/index.d.mts +0 -75
  83. package/dist/model/connection/index.mjs +0 -3
  84. package/dist/model/connection/model/index.d.mts +0 -15
  85. package/dist/model/connection/model/index.mjs +0 -2
  86. package/dist/shared/core.3ZhnKAlZ.mjs +0 -106
  87. package/dist/shared/core.78IWAHAE.mjs +0 -332
  88. package/dist/shared/core.B85MJLTf.mjs +0 -5
  89. package/dist/shared/core.BFd1lU9R.mjs +0 -29
  90. package/dist/shared/core.BKlholso.mjs +0 -3
  91. package/dist/shared/core.BNN-3vPH.mjs +0 -1255
  92. package/dist/shared/core.BPGOjone.d.mts +0 -46
  93. package/dist/shared/core.BP_QHEXs.mjs +0 -785
  94. package/dist/shared/core.BbE4y-yl.mjs +0 -177
  95. package/dist/shared/core.Bdy3hhTc.mjs +0 -28382
  96. package/dist/shared/core.BfCKSW-g.d.mts +0 -1266
  97. package/dist/shared/core.BhNcrwzK.mjs +0 -7
  98. package/dist/shared/core.BkVA6gjl.mjs +0 -5
  99. package/dist/shared/core.BoYfZOBm.mjs +0 -3
  100. package/dist/shared/core.BsSXS-_R.mjs +0 -7
  101. package/dist/shared/core.C3JowhaZ.mjs +0 -32
  102. package/dist/shared/core.C4x8aaWa.mjs +0 -27
  103. package/dist/shared/core.CAgYpDtM.d.mts +0 -98
  104. package/dist/shared/core.CHf8VEa3.mjs +0 -1206
  105. package/dist/shared/core.CLSZtnFh.mjs +0 -69
  106. package/dist/shared/core.C_3y3eqV.d.mts +0 -139
  107. package/dist/shared/core.CbT8JVYL.mjs +0 -5
  108. package/dist/shared/core.CdNCAwq7.mjs +0 -176
  109. package/dist/shared/core.CmGY9blO.mjs +0 -6717
  110. package/dist/shared/core.CmPXpJ8l.mjs +0 -21
  111. package/dist/shared/core.Coi_LOUZ.mjs +0 -7
  112. package/dist/shared/core.CqAJJpK_.mjs +0 -3
  113. package/dist/shared/core.CywrQs86.d.mts +0 -31
  114. package/dist/shared/core.D00YbOhQ.d.mts +0 -300
  115. package/dist/shared/core.D0WZutNd.mjs +0 -94
  116. package/dist/shared/core.D4npX2q8.mjs +0 -18
  117. package/dist/shared/core.DB0Ue5Wx.d.mts +0 -70
  118. package/dist/shared/core.DC5IAaDT.d.mts +0 -334
  119. package/dist/shared/core.DE9qzhn8.d.mts +0 -83
  120. package/dist/shared/core.DGcIbsj4.mjs +0 -3946
  121. package/dist/shared/core.DH7TXqXf.mjs +0 -136
  122. package/dist/shared/core.DKhRkHRN.d.mts +0 -41
  123. package/dist/shared/core.DRJma0Ol.mjs +0 -22
  124. package/dist/shared/core.DU5SRqNF.mjs +0 -2209
  125. package/dist/shared/core.DXhDWKFZ.d.mts +0 -3
  126. package/dist/shared/core.DbfO90vF.mjs +0 -434
  127. package/dist/shared/core.DcS-0zys.mjs +0 -10
  128. package/dist/shared/core.Dh119QSP.mjs +0 -4995
  129. package/dist/shared/core.DjcWextK.mjs +0 -1371
  130. package/dist/shared/core.Dojz4bvg.d.mts +0 -504
  131. package/dist/shared/core.FZ305VYd.mjs +0 -21
  132. package/dist/shared/core.OtRNdMxy.d.mts +0 -352
  133. package/dist/shared/core.RfnaEmgA.mjs +0 -7
  134. package/dist/shared/core.btEq3i3f.mjs +0 -300
  135. package/dist/shared/core.oSV6SRfk.mjs +0 -13
  136. package/dist/shared/core.om36dXXW.mjs +0 -41
  137. package/dist/shared/core.osFs8tU7.d.mts +0 -466
  138. package/dist/shared/core.q10OP9oJ.mjs +0 -5
  139. package/dist/shared/core.tpvDGvdC.d.mts +0 -87
  140. package/dist/shared/core.uFk_o9X6.mjs +0 -13
  141. package/dist/types/_aux.d.mts +0 -4
  142. package/dist/types/_aux.mjs +0 -8
  143. package/dist/types/expression-model.d.mts +0 -190
  144. package/dist/types/expression-model.mjs +0 -109
  145. package/dist/types/expression.d.mts +0 -6
  146. package/dist/types/expression.mjs +0 -113
  147. package/dist/types/fqnRef.d.mts +0 -60
  148. package/dist/types/fqnRef.mjs +0 -45
  149. package/dist/types/scalar.d.mts +0 -2
  150. package/dist/types/scalar.mjs +0 -4
  151. package/dist/utils/iterable/index.d.mts +0 -132
  152. package/dist/utils/iterable/index.mjs +0 -62
@@ -1,1206 +0,0 @@
1
- import { t as t$1 } from './core.BsSXS-_R.mjs';
2
- import { g as getDefaultExportFromCjs } from './core.B85MJLTf.mjs';
3
- import { r as requireForeach, b as requireIterator, a as markdownToText, m as markdownToHtml } from './core.Bdy3hhTc.mjs';
4
- import { m as memoizeProp } from './core.CLSZtnFh.mjs';
5
- import { n as nonexhaustive } from './core.D4npX2q8.mjs';
6
-
7
- function t(...t){return t$1(n,t)}function n(e,t){let n={...e};for(let[r,i]of Object.entries(n))t(i,r,e)&&delete n[r];return n}
8
-
9
- var typedArrays = {};
10
-
11
- /**
12
- * Mnemonist Typed Array Helpers
13
- * ==============================
14
- *
15
- * Miscellaneous helpers related to typed arrays.
16
- */
17
-
18
- var hasRequiredTypedArrays;
19
-
20
- function requireTypedArrays () {
21
- if (hasRequiredTypedArrays) return typedArrays;
22
- hasRequiredTypedArrays = 1;
23
- (function (exports$1) {
24
- /**
25
- * When using an unsigned integer array to store pointers, one might want to
26
- * choose the optimal word size in regards to the actual numbers of pointers
27
- * to store.
28
- *
29
- * This helpers does just that.
30
- *
31
- * @param {number} size - Expected size of the array to map.
32
- * @return {TypedArray}
33
- */
34
- var MAX_8BIT_INTEGER = Math.pow(2, 8) - 1,
35
- MAX_16BIT_INTEGER = Math.pow(2, 16) - 1,
36
- MAX_32BIT_INTEGER = Math.pow(2, 32) - 1;
37
-
38
- var MAX_SIGNED_8BIT_INTEGER = Math.pow(2, 7) - 1,
39
- MAX_SIGNED_16BIT_INTEGER = Math.pow(2, 15) - 1,
40
- MAX_SIGNED_32BIT_INTEGER = Math.pow(2, 31) - 1;
41
-
42
- exports$1.getPointerArray = function(size) {
43
- var maxIndex = size - 1;
44
-
45
- if (maxIndex <= MAX_8BIT_INTEGER)
46
- return Uint8Array;
47
-
48
- if (maxIndex <= MAX_16BIT_INTEGER)
49
- return Uint16Array;
50
-
51
- if (maxIndex <= MAX_32BIT_INTEGER)
52
- return Uint32Array;
53
-
54
- throw new Error('mnemonist: Pointer Array of size > 4294967295 is not supported.');
55
- };
56
-
57
- exports$1.getSignedPointerArray = function(size) {
58
- var maxIndex = size - 1;
59
-
60
- if (maxIndex <= MAX_SIGNED_8BIT_INTEGER)
61
- return Int8Array;
62
-
63
- if (maxIndex <= MAX_SIGNED_16BIT_INTEGER)
64
- return Int16Array;
65
-
66
- if (maxIndex <= MAX_SIGNED_32BIT_INTEGER)
67
- return Int32Array;
68
-
69
- return Float64Array;
70
- };
71
-
72
- /**
73
- * Function returning the minimal type able to represent the given number.
74
- *
75
- * @param {number} value - Value to test.
76
- * @return {TypedArrayClass}
77
- */
78
- exports$1.getNumberType = function(value) {
79
-
80
- // <= 32 bits itnteger?
81
- if (value === (value | 0)) {
82
-
83
- // Negative
84
- if (Math.sign(value) === -1) {
85
- if (value <= 127 && value >= -128)
86
- return Int8Array;
87
-
88
- if (value <= 32767 && value >= -32768)
89
- return Int16Array;
90
-
91
- return Int32Array;
92
- }
93
- else {
94
-
95
- if (value <= 255)
96
- return Uint8Array;
97
-
98
- if (value <= 65535)
99
- return Uint16Array;
100
-
101
- return Uint32Array;
102
- }
103
- }
104
-
105
- // 53 bits integer & floats
106
- // NOTE: it's kinda hard to tell whether we could use 32bits or not...
107
- return Float64Array;
108
- };
109
-
110
- /**
111
- * Function returning the minimal type able to represent the given array
112
- * of JavaScript numbers.
113
- *
114
- * @param {array} array - Array to represent.
115
- * @param {function} getter - Optional getter.
116
- * @return {TypedArrayClass}
117
- */
118
- var TYPE_PRIORITY = {
119
- Uint8Array: 1,
120
- Int8Array: 2,
121
- Uint16Array: 3,
122
- Int16Array: 4,
123
- Uint32Array: 5,
124
- Int32Array: 6,
125
- Float32Array: 7,
126
- Float64Array: 8
127
- };
128
-
129
- // TODO: make this a one-shot for one value
130
- exports$1.getMinimalRepresentation = function(array, getter) {
131
- var maxType = null,
132
- maxPriority = 0,
133
- p,
134
- t,
135
- v,
136
- i,
137
- l;
138
-
139
- for (i = 0, l = array.length; i < l; i++) {
140
- v = getter ? getter(array[i]) : array[i];
141
- t = exports$1.getNumberType(v);
142
- p = TYPE_PRIORITY[t.name];
143
-
144
- if (p > maxPriority) {
145
- maxPriority = p;
146
- maxType = t;
147
- }
148
- }
149
-
150
- return maxType;
151
- };
152
-
153
- /**
154
- * Function returning whether the given value is a typed array.
155
- *
156
- * @param {any} value - Value to test.
157
- * @return {boolean}
158
- */
159
- exports$1.isTypedArray = function(value) {
160
- return typeof ArrayBuffer !== 'undefined' && ArrayBuffer.isView(value);
161
- };
162
-
163
- /**
164
- * Function used to concat byte arrays.
165
- *
166
- * @param {...ByteArray}
167
- * @return {ByteArray}
168
- */
169
- exports$1.concat = function() {
170
- var length = 0,
171
- i,
172
- o,
173
- l;
174
-
175
- for (i = 0, l = arguments.length; i < l; i++)
176
- length += arguments[i].length;
177
-
178
- var array = new (arguments[0].constructor)(length);
179
-
180
- for (i = 0, o = 0; i < l; i++) {
181
- array.set(arguments[i], o);
182
- o += arguments[i].length;
183
- }
184
-
185
- return array;
186
- };
187
-
188
- /**
189
- * Function used to initialize a byte array of indices.
190
- *
191
- * @param {number} length - Length of target.
192
- * @return {ByteArray}
193
- */
194
- exports$1.indices = function(length) {
195
- var PointerArray = exports$1.getPointerArray(length);
196
-
197
- var array = new PointerArray(length);
198
-
199
- for (var i = 0; i < length; i++)
200
- array[i] = i;
201
-
202
- return array;
203
- };
204
- } (typedArrays));
205
- return typedArrays;
206
- }
207
-
208
- var iterables = {};
209
-
210
- /**
211
- * Mnemonist Iterable Function
212
- * ============================
213
- *
214
- * Harmonized iteration helpers over mixed iterable targets.
215
- */
216
-
217
- var hasRequiredIterables;
218
-
219
- function requireIterables () {
220
- if (hasRequiredIterables) return iterables;
221
- hasRequiredIterables = 1;
222
- var forEach = requireForeach();
223
-
224
- var typed = /*@__PURE__*/ requireTypedArrays();
225
-
226
- /**
227
- * Function used to determine whether the given object supports array-like
228
- * random access.
229
- *
230
- * @param {any} target - Target object.
231
- * @return {boolean}
232
- */
233
- function isArrayLike(target) {
234
- return Array.isArray(target) || typed.isTypedArray(target);
235
- }
236
-
237
- /**
238
- * Function used to guess the length of the structure over which we are going
239
- * to iterate.
240
- *
241
- * @param {any} target - Target object.
242
- * @return {number|undefined}
243
- */
244
- function guessLength(target) {
245
- if (typeof target.length === 'number')
246
- return target.length;
247
-
248
- if (typeof target.size === 'number')
249
- return target.size;
250
-
251
- return;
252
- }
253
-
254
- /**
255
- * Function used to convert an iterable to an array.
256
- *
257
- * @param {any} target - Iteration target.
258
- * @return {array}
259
- */
260
- function toArray(target) {
261
- var l = guessLength(target);
262
-
263
- var array = typeof l === 'number' ? new Array(l) : [];
264
-
265
- var i = 0;
266
-
267
- // TODO: we could optimize when given target is array like
268
- forEach(target, function(value) {
269
- array[i++] = value;
270
- });
271
-
272
- return array;
273
- }
274
-
275
- /**
276
- * Same as above but returns a supplementary indices array.
277
- *
278
- * @param {any} target - Iteration target.
279
- * @return {array}
280
- */
281
- function toArrayWithIndices(target) {
282
- var l = guessLength(target);
283
-
284
- var IndexArray = typeof l === 'number' ?
285
- typed.getPointerArray(l) :
286
- Array;
287
-
288
- var array = typeof l === 'number' ? new Array(l) : [];
289
- var indices = typeof l === 'number' ? new IndexArray(l) : [];
290
-
291
- var i = 0;
292
-
293
- // TODO: we could optimize when given target is array like
294
- forEach(target, function(value) {
295
- array[i] = value;
296
- indices[i] = i++;
297
- });
298
-
299
- return [array, indices];
300
- }
301
-
302
- /**
303
- * Exporting.
304
- */
305
- iterables.isArrayLike = isArrayLike;
306
- iterables.guessLength = guessLength;
307
- iterables.toArray = toArray;
308
- iterables.toArrayWithIndices = toArrayWithIndices;
309
- return iterables;
310
- }
311
-
312
- /**
313
- * Mnemonist LRUCache
314
- * ===================
315
- *
316
- * JavaScript implementation of the LRU Cache data structure. To save up
317
- * memory and allocations this implementation represents its underlying
318
- * doubly-linked list as static arrays and pointers. Thus, memory is allocated
319
- * only once at instantiation and JS objects are never created to serve as
320
- * pointers. This also means this implementation does not trigger too many
321
- * garbage collections.
322
- *
323
- * Note that to save up memory, a LRU Cache can be implemented using a singly
324
- * linked list by storing predecessors' pointers as hashmap values.
325
- * However, this means more hashmap lookups and would probably slow the whole
326
- * thing down. What's more, pointers are not the things taking most space in
327
- * memory.
328
- */
329
-
330
- var lruCache;
331
- var hasRequiredLruCache;
332
-
333
- function requireLruCache () {
334
- if (hasRequiredLruCache) return lruCache;
335
- hasRequiredLruCache = 1;
336
- var Iterator = requireIterator(),
337
- forEach = requireForeach(),
338
- typed = /*@__PURE__*/ requireTypedArrays(),
339
- iterables = /*@__PURE__*/ requireIterables();
340
-
341
- /**
342
- * LRUCache.
343
- *
344
- * @constructor
345
- * @param {function} Keys - Array class for storing keys.
346
- * @param {function} Values - Array class for storing values.
347
- * @param {number} capacity - Desired capacity.
348
- */
349
- function LRUCache(Keys, Values, capacity) {
350
- if (arguments.length < 2) {
351
- capacity = Keys;
352
- Keys = null;
353
- Values = null;
354
- }
355
-
356
- this.capacity = capacity;
357
-
358
- if (typeof this.capacity !== 'number' || this.capacity <= 0)
359
- throw new Error('mnemonist/lru-cache: capacity should be positive number.');
360
- else if (!isFinite(this.capacity) || Math.floor(this.capacity) !== this.capacity)
361
- throw new Error('mnemonist/lru-cache: capacity should be a finite positive integer.');
362
-
363
- var PointerArray = typed.getPointerArray(capacity);
364
-
365
- this.forward = new PointerArray(capacity);
366
- this.backward = new PointerArray(capacity);
367
- this.K = typeof Keys === 'function' ? new Keys(capacity) : new Array(capacity);
368
- this.V = typeof Values === 'function' ? new Values(capacity) : new Array(capacity);
369
-
370
- // Properties
371
- this.size = 0;
372
- this.head = 0;
373
- this.tail = 0;
374
- this.items = {};
375
- }
376
-
377
- /**
378
- * Method used to clear the structure.
379
- *
380
- * @return {undefined}
381
- */
382
- LRUCache.prototype.clear = function() {
383
- this.size = 0;
384
- this.head = 0;
385
- this.tail = 0;
386
- this.items = {};
387
- };
388
-
389
- /**
390
- * Method used to splay a value on top.
391
- *
392
- * @param {number} pointer - Pointer of the value to splay on top.
393
- * @return {LRUCache}
394
- */
395
- LRUCache.prototype.splayOnTop = function(pointer) {
396
- var oldHead = this.head;
397
-
398
- if (this.head === pointer)
399
- return this;
400
-
401
- var previous = this.backward[pointer],
402
- next = this.forward[pointer];
403
-
404
- if (this.tail === pointer) {
405
- this.tail = previous;
406
- }
407
- else {
408
- this.backward[next] = previous;
409
- }
410
-
411
- this.forward[previous] = next;
412
-
413
- this.backward[oldHead] = pointer;
414
- this.head = pointer;
415
- this.forward[pointer] = oldHead;
416
-
417
- return this;
418
- };
419
-
420
- /**
421
- * Method used to set the value for the given key in the cache.
422
- *
423
- * @param {any} key - Key.
424
- * @param {any} value - Value.
425
- * @return {undefined}
426
- */
427
- LRUCache.prototype.set = function(key, value) {
428
-
429
- var pointer = this.items[key];
430
-
431
- // The key already exists, we just need to update the value and splay on top
432
- if (typeof pointer !== 'undefined') {
433
- this.splayOnTop(pointer);
434
- this.V[pointer] = value;
435
-
436
- return;
437
- }
438
-
439
- // The cache is not yet full
440
- if (this.size < this.capacity) {
441
- pointer = this.size++;
442
- }
443
-
444
- // Cache is full, we need to drop the last value
445
- else {
446
- pointer = this.tail;
447
- this.tail = this.backward[pointer];
448
- delete this.items[this.K[pointer]];
449
- }
450
-
451
- // Storing key & value
452
- this.items[key] = pointer;
453
- this.K[pointer] = key;
454
- this.V[pointer] = value;
455
-
456
- // Moving the item at the front of the list
457
- this.forward[pointer] = this.head;
458
- this.backward[this.head] = pointer;
459
- this.head = pointer;
460
- };
461
-
462
- /**
463
- * Method used to set the value for the given key in the cache
464
- *
465
- * @param {any} key - Key.
466
- * @param {any} value - Value.
467
- * @return {{evicted: boolean, key: any, value: any}} An object containing the
468
- * key and value of an item that was overwritten or evicted in the set
469
- * operation, as well as a boolean indicating whether it was evicted due to
470
- * limited capacity. Return value is null if nothing was evicted or overwritten
471
- * during the set operation.
472
- */
473
- LRUCache.prototype.setpop = function(key, value) {
474
- var oldValue = null;
475
- var oldKey = null;
476
-
477
- var pointer = this.items[key];
478
-
479
- // The key already exists, we just need to update the value and splay on top
480
- if (typeof pointer !== 'undefined') {
481
- this.splayOnTop(pointer);
482
- oldValue = this.V[pointer];
483
- this.V[pointer] = value;
484
- return {evicted: false, key: key, value: oldValue};
485
- }
486
-
487
- // The cache is not yet full
488
- if (this.size < this.capacity) {
489
- pointer = this.size++;
490
- }
491
-
492
- // Cache is full, we need to drop the last value
493
- else {
494
- pointer = this.tail;
495
- this.tail = this.backward[pointer];
496
- oldValue = this.V[pointer];
497
- oldKey = this.K[pointer];
498
- delete this.items[oldKey];
499
- }
500
-
501
- // Storing key & value
502
- this.items[key] = pointer;
503
- this.K[pointer] = key;
504
- this.V[pointer] = value;
505
-
506
- // Moving the item at the front of the list
507
- this.forward[pointer] = this.head;
508
- this.backward[this.head] = pointer;
509
- this.head = pointer;
510
-
511
- // Return object if eviction took place, otherwise return null
512
- if (oldKey) {
513
- return {evicted: true, key: oldKey, value: oldValue};
514
- }
515
- else {
516
- return null;
517
- }
518
- };
519
-
520
- /**
521
- * Method used to check whether the key exists in the cache.
522
- *
523
- * @param {any} key - Key.
524
- * @return {boolean}
525
- */
526
- LRUCache.prototype.has = function(key) {
527
- return key in this.items;
528
- };
529
-
530
- /**
531
- * Method used to get the value attached to the given key. Will move the
532
- * related key to the front of the underlying linked list.
533
- *
534
- * @param {any} key - Key.
535
- * @return {any}
536
- */
537
- LRUCache.prototype.get = function(key) {
538
- var pointer = this.items[key];
539
-
540
- if (typeof pointer === 'undefined')
541
- return;
542
-
543
- this.splayOnTop(pointer);
544
-
545
- return this.V[pointer];
546
- };
547
-
548
- /**
549
- * Method used to get the value attached to the given key. Does not modify
550
- * the ordering of the underlying linked list.
551
- *
552
- * @param {any} key - Key.
553
- * @return {any}
554
- */
555
- LRUCache.prototype.peek = function(key) {
556
- var pointer = this.items[key];
557
-
558
- if (typeof pointer === 'undefined')
559
- return;
560
-
561
- return this.V[pointer];
562
- };
563
-
564
- /**
565
- * Method used to iterate over the cache's entries using a callback.
566
- *
567
- * @param {function} callback - Function to call for each item.
568
- * @param {object} scope - Optional scope.
569
- * @return {undefined}
570
- */
571
- LRUCache.prototype.forEach = function(callback, scope) {
572
- scope = arguments.length > 1 ? scope : this;
573
-
574
- var i = 0,
575
- l = this.size;
576
-
577
- var pointer = this.head,
578
- keys = this.K,
579
- values = this.V,
580
- forward = this.forward;
581
-
582
- while (i < l) {
583
-
584
- callback.call(scope, values[pointer], keys[pointer], this);
585
- pointer = forward[pointer];
586
-
587
- i++;
588
- }
589
- };
590
-
591
- /**
592
- * Method used to create an iterator over the cache's keys from most
593
- * recently used to least recently used.
594
- *
595
- * @return {Iterator}
596
- */
597
- LRUCache.prototype.keys = function() {
598
- var i = 0,
599
- l = this.size;
600
-
601
- var pointer = this.head,
602
- keys = this.K,
603
- forward = this.forward;
604
-
605
- return new Iterator(function() {
606
- if (i >= l)
607
- return {done: true};
608
-
609
- var key = keys[pointer];
610
-
611
- i++;
612
-
613
- if (i < l)
614
- pointer = forward[pointer];
615
-
616
- return {
617
- done: false,
618
- value: key
619
- };
620
- });
621
- };
622
-
623
- /**
624
- * Method used to create an iterator over the cache's values from most
625
- * recently used to least recently used.
626
- *
627
- * @return {Iterator}
628
- */
629
- LRUCache.prototype.values = function() {
630
- var i = 0,
631
- l = this.size;
632
-
633
- var pointer = this.head,
634
- values = this.V,
635
- forward = this.forward;
636
-
637
- return new Iterator(function() {
638
- if (i >= l)
639
- return {done: true};
640
-
641
- var value = values[pointer];
642
-
643
- i++;
644
-
645
- if (i < l)
646
- pointer = forward[pointer];
647
-
648
- return {
649
- done: false,
650
- value: value
651
- };
652
- });
653
- };
654
-
655
- /**
656
- * Method used to create an iterator over the cache's entries from most
657
- * recently used to least recently used.
658
- *
659
- * @return {Iterator}
660
- */
661
- LRUCache.prototype.entries = function() {
662
- var i = 0,
663
- l = this.size;
664
-
665
- var pointer = this.head,
666
- keys = this.K,
667
- values = this.V,
668
- forward = this.forward;
669
-
670
- return new Iterator(function() {
671
- if (i >= l)
672
- return {done: true};
673
-
674
- var key = keys[pointer],
675
- value = values[pointer];
676
-
677
- i++;
678
-
679
- if (i < l)
680
- pointer = forward[pointer];
681
-
682
- return {
683
- done: false,
684
- value: [key, value]
685
- };
686
- });
687
- };
688
-
689
- /**
690
- * Attaching the #.entries method to Symbol.iterator if possible.
691
- */
692
- if (typeof Symbol !== 'undefined')
693
- LRUCache.prototype[Symbol.iterator] = LRUCache.prototype.entries;
694
-
695
- /**
696
- * Convenience known methods.
697
- */
698
- LRUCache.prototype.inspect = function() {
699
- var proxy = new Map();
700
-
701
- var iterator = this.entries(),
702
- step;
703
-
704
- while ((step = iterator.next(), !step.done))
705
- proxy.set(step.value[0], step.value[1]);
706
-
707
- // Trick so that node displays the name of the constructor
708
- Object.defineProperty(proxy, 'constructor', {
709
- value: LRUCache,
710
- enumerable: false
711
- });
712
-
713
- return proxy;
714
- };
715
-
716
- if (typeof Symbol !== 'undefined')
717
- LRUCache.prototype[Symbol.for('nodejs.util.inspect.custom')] = LRUCache.prototype.inspect;
718
-
719
- /**
720
- * Static @.from function taking an arbitrary iterable & converting it into
721
- * a structure.
722
- *
723
- * @param {Iterable} iterable - Target iterable.
724
- * @param {function} Keys - Array class for storing keys.
725
- * @param {function} Values - Array class for storing values.
726
- * @param {number} capacity - Cache's capacity.
727
- * @return {LRUCache}
728
- */
729
- LRUCache.from = function(iterable, Keys, Values, capacity) {
730
- if (arguments.length < 2) {
731
- capacity = iterables.guessLength(iterable);
732
-
733
- if (typeof capacity !== 'number')
734
- throw new Error('mnemonist/lru-cache.from: could not guess iterable length. Please provide desired capacity as last argument.');
735
- }
736
- else if (arguments.length === 2) {
737
- capacity = Keys;
738
- Keys = null;
739
- Values = null;
740
- }
741
-
742
- var cache = new LRUCache(Keys, Values, capacity);
743
-
744
- forEach(iterable, function(value, key) {
745
- cache.set(key, value);
746
- });
747
-
748
- return cache;
749
- };
750
-
751
- /**
752
- * Exporting.
753
- */
754
- lruCache = LRUCache;
755
- return lruCache;
756
- }
757
-
758
- /**
759
- * Mnemonist LRUMap
760
- * =================
761
- *
762
- * Variant of the LRUCache class that leverages an ES6 Map instead of an object.
763
- * It might be faster for some use case but it is still hard to understand
764
- * when a Map can outperform an object in v8.
765
- */
766
-
767
- var lruMap;
768
- var hasRequiredLruMap;
769
-
770
- function requireLruMap () {
771
- if (hasRequiredLruMap) return lruMap;
772
- hasRequiredLruMap = 1;
773
- var LRUCache = /*@__PURE__*/ requireLruCache(),
774
- forEach = requireForeach(),
775
- typed = /*@__PURE__*/ requireTypedArrays(),
776
- iterables = /*@__PURE__*/ requireIterables();
777
-
778
- /**
779
- * LRUMap.
780
- *
781
- * @constructor
782
- * @param {function} Keys - Array class for storing keys.
783
- * @param {function} Values - Array class for storing values.
784
- * @param {number} capacity - Desired capacity.
785
- */
786
- function LRUMap(Keys, Values, capacity) {
787
- if (arguments.length < 2) {
788
- capacity = Keys;
789
- Keys = null;
790
- Values = null;
791
- }
792
-
793
- this.capacity = capacity;
794
-
795
- if (typeof this.capacity !== 'number' || this.capacity <= 0)
796
- throw new Error('mnemonist/lru-map: capacity should be positive number.');
797
- else if (!isFinite(this.capacity) || Math.floor(this.capacity) !== this.capacity)
798
- throw new Error('mnemonist/lru-map: capacity should be a finite positive integer.');
799
-
800
- var PointerArray = typed.getPointerArray(capacity);
801
-
802
- this.forward = new PointerArray(capacity);
803
- this.backward = new PointerArray(capacity);
804
- this.K = typeof Keys === 'function' ? new Keys(capacity) : new Array(capacity);
805
- this.V = typeof Values === 'function' ? new Values(capacity) : new Array(capacity);
806
-
807
- // Properties
808
- this.size = 0;
809
- this.head = 0;
810
- this.tail = 0;
811
- this.items = new Map();
812
- }
813
-
814
- /**
815
- * Method used to clear the structure.
816
- *
817
- * @return {undefined}
818
- */
819
- LRUMap.prototype.clear = function() {
820
- this.size = 0;
821
- this.head = 0;
822
- this.tail = 0;
823
- this.items.clear();
824
- };
825
-
826
- /**
827
- * Method used to set the value for the given key in the cache.
828
- *
829
- * @param {any} key - Key.
830
- * @param {any} value - Value.
831
- * @return {undefined}
832
- */
833
- LRUMap.prototype.set = function(key, value) {
834
-
835
- var pointer = this.items.get(key);
836
-
837
- // The key already exists, we just need to update the value and splay on top
838
- if (typeof pointer !== 'undefined') {
839
- this.splayOnTop(pointer);
840
- this.V[pointer] = value;
841
-
842
- return;
843
- }
844
-
845
- // The cache is not yet full
846
- if (this.size < this.capacity) {
847
- pointer = this.size++;
848
- }
849
-
850
- // Cache is full, we need to drop the last value
851
- else {
852
- pointer = this.tail;
853
- this.tail = this.backward[pointer];
854
- this.items.delete(this.K[pointer]);
855
- }
856
-
857
- // Storing key & value
858
- this.items.set(key, pointer);
859
- this.K[pointer] = key;
860
- this.V[pointer] = value;
861
-
862
- // Moving the item at the front of the list
863
- this.forward[pointer] = this.head;
864
- this.backward[this.head] = pointer;
865
- this.head = pointer;
866
- };
867
-
868
- /**
869
- * Method used to set the value for the given key in the cache.
870
- *
871
- * @param {any} key - Key.
872
- * @param {any} value - Value.
873
- * @return {{evicted: boolean, key: any, value: any}} An object containing the
874
- * key and value of an item that was overwritten or evicted in the set
875
- * operation, as well as a boolean indicating whether it was evicted due to
876
- * limited capacity. Return value is null if nothing was evicted or overwritten
877
- * during the set operation.
878
- */
879
- LRUMap.prototype.setpop = function(key, value) {
880
- var oldValue = null;
881
- var oldKey = null;
882
-
883
- var pointer = this.items.get(key);
884
-
885
- // The key already exists, we just need to update the value and splay on top
886
- if (typeof pointer !== 'undefined') {
887
- this.splayOnTop(pointer);
888
- oldValue = this.V[pointer];
889
- this.V[pointer] = value;
890
- return {evicted: false, key: key, value: oldValue};
891
- }
892
-
893
- // The cache is not yet full
894
- if (this.size < this.capacity) {
895
- pointer = this.size++;
896
- }
897
-
898
- // Cache is full, we need to drop the last value
899
- else {
900
- pointer = this.tail;
901
- this.tail = this.backward[pointer];
902
- oldValue = this.V[pointer];
903
- oldKey = this.K[pointer];
904
- this.items.delete(oldKey);
905
- }
906
-
907
- // Storing key & value
908
- this.items.set(key, pointer);
909
- this.K[pointer] = key;
910
- this.V[pointer] = value;
911
-
912
- // Moving the item at the front of the list
913
- this.forward[pointer] = this.head;
914
- this.backward[this.head] = pointer;
915
- this.head = pointer;
916
-
917
- // Return object if eviction took place, otherwise return null
918
- if (oldKey) {
919
- return {evicted: true, key: oldKey, value: oldValue};
920
- }
921
- else {
922
- return null;
923
- }
924
- };
925
-
926
- /**
927
- * Method used to check whether the key exists in the cache.
928
- *
929
- * @param {any} key - Key.
930
- * @return {boolean}
931
- */
932
- LRUMap.prototype.has = function(key) {
933
- return this.items.has(key);
934
- };
935
-
936
- /**
937
- * Method used to get the value attached to the given key. Will move the
938
- * related key to the front of the underlying linked list.
939
- *
940
- * @param {any} key - Key.
941
- * @return {any}
942
- */
943
- LRUMap.prototype.get = function(key) {
944
- var pointer = this.items.get(key);
945
-
946
- if (typeof pointer === 'undefined')
947
- return;
948
-
949
- this.splayOnTop(pointer);
950
-
951
- return this.V[pointer];
952
- };
953
-
954
- /**
955
- * Method used to get the value attached to the given key. Does not modify
956
- * the ordering of the underlying linked list.
957
- *
958
- * @param {any} key - Key.
959
- * @return {any}
960
- */
961
- LRUMap.prototype.peek = function(key) {
962
- var pointer = this.items.get(key);
963
-
964
- if (typeof pointer === 'undefined')
965
- return;
966
-
967
- return this.V[pointer];
968
- };
969
-
970
- /**
971
- * Methods that can be reused as-is from LRUCache.
972
- */
973
- LRUMap.prototype.splayOnTop = LRUCache.prototype.splayOnTop;
974
- LRUMap.prototype.forEach = LRUCache.prototype.forEach;
975
- LRUMap.prototype.keys = LRUCache.prototype.keys;
976
- LRUMap.prototype.values = LRUCache.prototype.values;
977
- LRUMap.prototype.entries = LRUCache.prototype.entries;
978
-
979
- /**
980
- * Attaching the #.entries method to Symbol.iterator if possible.
981
- */
982
- if (typeof Symbol !== 'undefined')
983
- LRUMap.prototype[Symbol.iterator] = LRUMap.prototype.entries;
984
-
985
- /**
986
- * Convenience known methods.
987
- */
988
- LRUMap.prototype.inspect = LRUCache.prototype.inspect;
989
-
990
- /**
991
- * Static @.from function taking an arbitrary iterable & converting it into
992
- * a structure.
993
- *
994
- * @param {Iterable} iterable - Target iterable.
995
- * @param {function} Keys - Array class for storing keys.
996
- * @param {function} Values - Array class for storing values.
997
- * @param {number} capacity - Cache's capacity.
998
- * @return {LRUMap}
999
- */
1000
- LRUMap.from = function(iterable, Keys, Values, capacity) {
1001
- if (arguments.length < 2) {
1002
- capacity = iterables.guessLength(iterable);
1003
-
1004
- if (typeof capacity !== 'number')
1005
- throw new Error('mnemonist/lru-cache.from: could not guess iterable length. Please provide desired capacity as last argument.');
1006
- }
1007
- else if (arguments.length === 2) {
1008
- capacity = Keys;
1009
- Keys = null;
1010
- Values = null;
1011
- }
1012
-
1013
- var cache = new LRUMap(Keys, Values, capacity);
1014
-
1015
- forEach(iterable, function(value, key) {
1016
- cache.set(key, value);
1017
- });
1018
-
1019
- return cache;
1020
- };
1021
-
1022
- /**
1023
- * Exporting.
1024
- */
1025
- lruMap = LRUMap;
1026
- return lruMap;
1027
- }
1028
-
1029
- var lruMapExports = /*@__PURE__*/ requireLruMap();
1030
- const LRUMap = /*@__PURE__*/getDefaultExportFromCjs(lruMapExports);
1031
-
1032
- function exact(a) {
1033
- return t(a, (v) => v === void 0);
1034
- }
1035
-
1036
- const symb_text = /* @__PURE__ */ Symbol.for("text");
1037
- const symb_html = /* @__PURE__ */ Symbol.for("html");
1038
- const emptyTxt = "";
1039
- const mdcache = new LRUMap(500);
1040
- const txtcache = new LRUMap(500);
1041
- class RichText {
1042
- static getOrCreateFromText(txt) {
1043
- if (txt.trim() === emptyTxt) {
1044
- return RichText.EMPTY;
1045
- }
1046
- let cached = txtcache.get(txt);
1047
- if (cached) {
1048
- return cached;
1049
- }
1050
- cached = new RichText({ txt });
1051
- txtcache.set(txt, cached);
1052
- return cached;
1053
- }
1054
- static getOrCreateFromMarkdown(md) {
1055
- if (md.trim() === emptyTxt) {
1056
- return RichText.EMPTY;
1057
- }
1058
- let cached = mdcache.get(md);
1059
- if (cached) {
1060
- return cached;
1061
- }
1062
- cached = new RichText({ md });
1063
- mdcache.set(md, cached);
1064
- return cached;
1065
- }
1066
- /**
1067
- * Creates and memoizes a RichText instance.
1068
- * @see ElementModel.description
1069
- * @example
1070
- *
1071
- * get description(): RichTextOrEmpty {
1072
- * return RichText.memoize(this, 'description', this.$element.description)
1073
- * }
1074
- */
1075
- static memoize(obj, tag, source) {
1076
- return memoizeProp(obj, tag, () => RichText.from(source));
1077
- }
1078
- /**
1079
- * Creates a RichText instance from a source.
1080
- */
1081
- static from(source) {
1082
- if (source === null || source === void 0 || source === RichText.EMPTY) {
1083
- return RichText.EMPTY;
1084
- }
1085
- if (source instanceof RichText) {
1086
- return source;
1087
- }
1088
- if (typeof source === "string") {
1089
- return this.getOrCreateFromText(source);
1090
- }
1091
- if ("isEmpty" in source && source.isEmpty) {
1092
- return RichText.EMPTY;
1093
- }
1094
- if ("md" in source) {
1095
- return this.getOrCreateFromMarkdown(source.md);
1096
- }
1097
- return this.getOrCreateFromText(source.txt);
1098
- }
1099
- /**
1100
- * This is a workaround for the fact that we need instance of RichText for `instanceof` checks
1101
- * It is invalid inheritance (returning `null` from getters), and we cast to @see RichTextEmpty
1102
- */
1103
- static EMPTY = new class extends RichText {
1104
- isEmpty = true;
1105
- nonEmpty = false;
1106
- isMarkdown = false;
1107
- $source = null;
1108
- constructor() {
1109
- super({ txt: emptyTxt });
1110
- }
1111
- get text() {
1112
- return null;
1113
- }
1114
- get md() {
1115
- return null;
1116
- }
1117
- get html() {
1118
- return null;
1119
- }
1120
- }();
1121
- $source;
1122
- isEmpty;
1123
- nonEmpty;
1124
- isMarkdown;
1125
- /**
1126
- * Private constructor to prevent direct instantiation.
1127
- * Use {@link RichText.from} or {@link RichText.memoize} instead.
1128
- */
1129
- constructor(source) {
1130
- this.isMarkdown = false;
1131
- if (typeof source === "string") {
1132
- this.$source = { txt: source };
1133
- this.isEmpty = source.trim() === emptyTxt;
1134
- } else {
1135
- this.$source = source;
1136
- this.isEmpty = true;
1137
- if ("md" in source) {
1138
- this.isEmpty = source.md === emptyTxt;
1139
- this.isMarkdown = true;
1140
- } else {
1141
- this.isEmpty = source.txt === emptyTxt;
1142
- }
1143
- }
1144
- this.nonEmpty = !this.isEmpty;
1145
- }
1146
- /**
1147
- * Returns the text content of the rich text.
1148
- * If the source is a string, it returns the string.
1149
- * If the source is a markdown, it returns the markdown.
1150
- */
1151
- get text() {
1152
- if (this.isEmpty || this.$source === null) {
1153
- return emptyTxt;
1154
- }
1155
- const source = this.$source;
1156
- if ("txt" in source) {
1157
- return source.txt;
1158
- }
1159
- return memoizeProp(this, symb_text, () => markdownToText(source.md));
1160
- }
1161
- /**
1162
- * Returns the markdown content of the rich text.
1163
- * If the source is a string, it returns the string.
1164
- * If the source is a markdown, it returns the markdown.
1165
- */
1166
- get md() {
1167
- if (this.isEmpty || this.$source === null) {
1168
- return emptyTxt;
1169
- }
1170
- const source = this.$source;
1171
- if ("md" in source) {
1172
- return source.md;
1173
- }
1174
- if ("txt" in source) {
1175
- return source.txt;
1176
- }
1177
- nonexhaustive(source);
1178
- }
1179
- /**
1180
- * Returns the html content of the rich text.
1181
- * If the source is a string, it returns the string.
1182
- * If the source is a markdown, it returns the HTML.
1183
- */
1184
- get html() {
1185
- if (this.isEmpty || this.$source === null) {
1186
- return emptyTxt;
1187
- }
1188
- const source = this.$source;
1189
- if ("txt" in source) {
1190
- return source.txt;
1191
- }
1192
- return memoizeProp(this, symb_html, () => markdownToHtml(source.md));
1193
- }
1194
- equals(other) {
1195
- if (this === other) return true;
1196
- if (!(other instanceof RichText)) return false;
1197
- if (this.isEmpty && other.isEmpty) return true;
1198
- if (this.isEmpty !== other.isEmpty || this.isMarkdown !== other.isMarkdown) return false;
1199
- if (this.isMarkdown) {
1200
- return this.$source?.md === other.$source?.md;
1201
- }
1202
- return this.$source?.txt === other.$source?.txt;
1203
- }
1204
- }
1205
-
1206
- export { RichText as R, exact as e, requireIterables as r, t };