@likec4/core 1.48.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.
- package/dist/THIRD-PARTY-LICENSES.md +1012 -0
- package/dist/_chunks/Builder.view-element.mjs +2 -3284
- package/dist/_chunks/LikeC4Model.d.mts +21 -25
- package/dist/_chunks/RichText.mjs +1 -148
- package/dist/_chunks/_types.d.mts +1 -5
- package/dist/_chunks/_types2.d.mts +2 -4
- package/dist/_chunks/assignTagColors.mjs +1 -24
- package/dist/_chunks/calcDriftsFromSnapshot.mjs +1 -379
- package/dist/_chunks/guards.d.mts +2026 -0
- package/dist/_chunks/guards.mjs +4 -0
- package/dist/_chunks/index.d.mts +255 -136
- package/dist/_chunks/libs/@mantine/colors-generator.mjs +2 -3403
- package/dist/_chunks/libs/@radix-ui/colors.mjs +1 -0
- package/dist/_chunks/libs/@ungap/structured-clone.mjs +1 -213
- package/dist/_chunks/libs/bail.mjs +1 -14
- package/dist/_chunks/libs/ccount.mjs +1 -25
- package/dist/_chunks/libs/character-entities-html4.mjs +1 -263
- package/dist/_chunks/libs/character-entities-legacy.mjs +1 -117
- package/dist/_chunks/libs/character-entities.mjs +2 -2136
- package/dist/_chunks/libs/comma-separated-tokens.mjs +1 -18
- package/dist/_chunks/libs/decode-named-character-reference.mjs +1 -21
- package/dist/_chunks/libs/defu.mjs +1 -42
- package/dist/_chunks/libs/devlop.mjs +1 -5
- package/dist/_chunks/libs/escape-string-regexp.mjs +1 -8
- package/dist/_chunks/libs/extend.mjs +1 -77
- package/dist/_chunks/libs/graphology-dag.mjs +1 -703
- package/dist/_chunks/libs/graphology.mjs +1 -4565
- package/dist/_chunks/libs/hast-util-sanitize.mjs +1 -863
- package/dist/_chunks/libs/hast-util-to-html.mjs +9 -2696
- package/dist/_chunks/libs/is-plain-obj.mjs +1 -9
- package/dist/_chunks/libs/longest-streak.mjs +1 -30
- package/dist/_chunks/libs/markdown-table.mjs +2 -290
- package/dist/_chunks/libs/mdast-util-find-and-replace.mjs +1 -653
- package/dist/_chunks/libs/mdast-util-from-markdown.mjs +3 -8522
- package/dist/_chunks/libs/mdast-util-gfm.mjs +15 -2393
- package/dist/_chunks/libs/mdast-util-to-hast.mjs +11 -1803
- package/dist/_chunks/libs/micromark-extension-gfm.mjs +1 -2243
- package/dist/_chunks/libs/mnemonist.d.mts +1 -91
- package/dist/_chunks/libs/mnemonist.mjs +1 -1978
- package/dist/_chunks/libs/natural-compare-lite.mjs +9 -42
- package/dist/_chunks/libs/ohash.mjs +1 -0
- package/dist/_chunks/libs/rehype-sanitize.mjs +1 -29
- package/dist/_chunks/libs/rehype-stringify.mjs +1 -34
- package/dist/_chunks/libs/remark-gfm.mjs +1 -36
- package/dist/_chunks/libs/remark-github-blockquote-alert.mjs +3 -100
- package/dist/_chunks/libs/remark-parse.mjs +1 -39
- package/dist/_chunks/libs/remark-rehype.mjs +1 -171
- package/dist/_chunks/libs/remeda.mjs +1 -702
- package/dist/_chunks/libs/trough.mjs +1 -158
- package/dist/_chunks/libs/unified.mjs +1 -2212
- package/dist/_chunks/rolldown-runtime.mjs +1 -42
- package/dist/_chunks/{index3.d.mts → theme.d.mts} +15 -13
- package/dist/_chunks/{index7.d.mts → to-text.d.mts} +165 -29
- package/dist/_chunks/to-text.mjs +1 -0
- package/dist/_chunks/vector.d.mts +198 -0
- package/dist/_chunks/vector.mjs +1 -0
- package/dist/builder/index.d.mts +2 -8
- package/dist/builder/index.mjs +1 -662
- package/dist/compute-view/index.d.mts +86 -15
- package/dist/compute-view/index.mjs +2 -262
- package/dist/geometry/index.d.mts +2 -2
- package/dist/geometry/index.mjs +1 -3
- package/dist/index.d.mts +9 -13
- package/dist/index.mjs +1 -27
- package/dist/model/index.d.mts +4 -14
- package/dist/model/index.mjs +1 -11
- package/dist/styles/index.d.mts +2 -8
- package/dist/styles/index.mjs +1 -30
- package/dist/types/index.d.mts +3 -9
- package/dist/types/index.mjs +1 -15
- package/dist/utils/graphology/index.d.mts +1 -1
- package/dist/utils/graphology/index.mjs +1 -3
- package/dist/utils/index.d.mts +4 -11
- package/dist/utils/index.mjs +1 -17
- package/package.json +13 -12
- package/dist/_chunks/LikeC4Styles.mjs +0 -691
- package/dist/_chunks/RichText.d.mts +0 -84
- package/dist/_chunks/_aux.d.mts +0 -289
- package/dist/_chunks/_aux.mjs +0 -18
- package/dist/_chunks/connection.mjs +0 -0
- package/dist/_chunks/const.d.mts +0 -43
- package/dist/_chunks/const.mjs +0 -33
- package/dist/_chunks/expression-model.d.mts +0 -192
- package/dist/_chunks/expression-model.mjs +0 -103
- package/dist/_chunks/expression.d.mts +0 -347
- package/dist/_chunks/expression.mjs +0 -107
- package/dist/_chunks/find.d.mts +0 -82
- package/dist/_chunks/find.mjs +0 -646
- package/dist/_chunks/find2.d.mts +0 -78
- package/dist/_chunks/find2.mjs +0 -287
- package/dist/_chunks/fqnRef.d.mts +0 -58
- package/dist/_chunks/fqnRef.mjs +0 -41
- package/dist/_chunks/geometry.mjs +0 -335
- package/dist/_chunks/index2.d.mts +0 -937
- package/dist/_chunks/index4.d.mts +0 -62
- package/dist/_chunks/index5.d.mts +0 -42
- package/dist/_chunks/index6.d.mts +0 -43
- package/dist/_chunks/index8.d.mts +0 -144
- package/dist/_chunks/invariant.mjs +0 -18
- package/dist/_chunks/iterable.mjs +0 -146
- package/dist/_chunks/libs/graphology-types.d.mts +0 -601
- package/dist/_chunks/libs/graphology.d.mts +0 -6
- package/dist/_chunks/mnemonist.d.mts +0 -1
- package/dist/_chunks/mnemonist.mjs +0 -0
- package/dist/_chunks/model.mjs +0 -1898
- package/dist/_chunks/model2.mjs +0 -0
- package/dist/_chunks/relationships-view.mjs +0 -132
- package/dist/_chunks/scalar.d.mts +0 -109
- package/dist/_chunks/scalar.mjs +0 -84
- package/dist/_chunks/utils.mjs +0 -483
- package/dist/compute-view/relationships-view/index.d.mts +0 -16
- package/dist/compute-view/relationships-view/index.mjs +0 -7
- package/dist/model/connection/deployment/index.d.mts +0 -12
- package/dist/model/connection/deployment/index.mjs +0 -9
- package/dist/model/connection/index.d.mts +0 -14
- package/dist/model/connection/index.mjs +0 -10
- package/dist/model/connection/model/index.d.mts +0 -12
- package/dist/model/connection/model/index.mjs +0 -8
- package/dist/types/RichText.d.mts +0 -3
- package/dist/types/RichText.mjs +0 -7
- package/dist/types/_aux.d.mts +0 -3
- package/dist/types/_aux.mjs +0 -3
- package/dist/types/expression-model.d.mts +0 -6
- package/dist/types/expression-model.mjs +0 -7
- package/dist/types/expression.d.mts +0 -5
- package/dist/types/expression.mjs +0 -7
- package/dist/types/fqnRef.d.mts +0 -4
- package/dist/types/fqnRef.mjs +0 -7
- package/dist/types/scalar.d.mts +0 -2
- package/dist/types/scalar.mjs +0 -7
- package/dist/utils/iterable/index.d.mts +0 -9
- package/dist/utils/iterable/index.mjs +0 -3
- package/dist/utils/mnemonist.d.mts +0 -2
- package/dist/utils/mnemonist.mjs +0 -12
|
@@ -1,9 +1 @@
|
|
|
1
|
-
|
|
2
|
-
function isPlainObject(value) {
|
|
3
|
-
if (typeof value !== "object" || value === null) return false;
|
|
4
|
-
const prototype = Object.getPrototypeOf(value);
|
|
5
|
-
return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in value) && !(Symbol.iterator in value);
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
//#endregion
|
|
9
|
-
export { isPlainObject as t };
|
|
1
|
+
function isPlainObject(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}export{isPlainObject as t};
|
|
@@ -1,30 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Get the count of the longest repeating streak of `substring` in `value`.
|
|
4
|
-
*
|
|
5
|
-
* @param {string} value
|
|
6
|
-
* Content to search in.
|
|
7
|
-
* @param {string} substring
|
|
8
|
-
* Substring to look for, typically one character.
|
|
9
|
-
* @returns {number}
|
|
10
|
-
* Count of most frequent adjacent `substring`s in `value`.
|
|
11
|
-
*/
|
|
12
|
-
function longestStreak(value, substring) {
|
|
13
|
-
const source = String(value);
|
|
14
|
-
let index = source.indexOf(substring);
|
|
15
|
-
let expected = index;
|
|
16
|
-
let count = 0;
|
|
17
|
-
let max = 0;
|
|
18
|
-
if (typeof substring !== "string") throw new TypeError("Expected substring");
|
|
19
|
-
while (index !== -1) {
|
|
20
|
-
if (index === expected) {
|
|
21
|
-
if (++count > max) max = count;
|
|
22
|
-
} else count = 1;
|
|
23
|
-
expected = index + substring.length;
|
|
24
|
-
index = source.indexOf(substring, expected);
|
|
25
|
-
}
|
|
26
|
-
return max;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
//#endregion
|
|
30
|
-
export { longestStreak as t };
|
|
1
|
+
function longestStreak(e,t){let n=String(e),r=n.indexOf(t),i=r,a=0,o=0;if(typeof t!=`string`)throw TypeError(`Expected substring`);for(;r!==-1;)r===i?++a>o&&(o=a):a=1,i=r+t.length,r=n.indexOf(t,i);return o}export{longestStreak as t};
|
|
@@ -1,290 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* @typedef {Options} MarkdownTableOptions
|
|
4
|
-
* Configuration.
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* @typedef Options
|
|
8
|
-
* Configuration.
|
|
9
|
-
* @property {boolean | null | undefined} [alignDelimiters=true]
|
|
10
|
-
* Whether to align the delimiters (default: `true`);
|
|
11
|
-
* they are aligned by default:
|
|
12
|
-
*
|
|
13
|
-
* ```markdown
|
|
14
|
-
* | Alpha | B |
|
|
15
|
-
* | ----- | ----- |
|
|
16
|
-
* | C | Delta |
|
|
17
|
-
* ```
|
|
18
|
-
*
|
|
19
|
-
* Pass `false` to make them staggered:
|
|
20
|
-
*
|
|
21
|
-
* ```markdown
|
|
22
|
-
* | Alpha | B |
|
|
23
|
-
* | - | - |
|
|
24
|
-
* | C | Delta |
|
|
25
|
-
* ```
|
|
26
|
-
* @property {ReadonlyArray<string | null | undefined> | string | null | undefined} [align]
|
|
27
|
-
* How to align columns (default: `''`);
|
|
28
|
-
* one style for all columns or styles for their respective columns;
|
|
29
|
-
* each style is either `'l'` (left), `'r'` (right), or `'c'` (center);
|
|
30
|
-
* other values are treated as `''`, which doesn’t place the colon in the
|
|
31
|
-
* alignment row but does align left;
|
|
32
|
-
* *only the lowercased first character is used, so `Right` is fine.*
|
|
33
|
-
* @property {boolean | null | undefined} [delimiterEnd=true]
|
|
34
|
-
* Whether to end each row with the delimiter (default: `true`).
|
|
35
|
-
*
|
|
36
|
-
* > 👉 **Note**: please don’t use this: it could create fragile structures
|
|
37
|
-
* > that aren’t understandable to some markdown parsers.
|
|
38
|
-
*
|
|
39
|
-
* When `true`, there are ending delimiters:
|
|
40
|
-
*
|
|
41
|
-
* ```markdown
|
|
42
|
-
* | Alpha | B |
|
|
43
|
-
* | ----- | ----- |
|
|
44
|
-
* | C | Delta |
|
|
45
|
-
* ```
|
|
46
|
-
*
|
|
47
|
-
* When `false`, there are no ending delimiters:
|
|
48
|
-
*
|
|
49
|
-
* ```markdown
|
|
50
|
-
* | Alpha | B
|
|
51
|
-
* | ----- | -----
|
|
52
|
-
* | C | Delta
|
|
53
|
-
* ```
|
|
54
|
-
* @property {boolean | null | undefined} [delimiterStart=true]
|
|
55
|
-
* Whether to begin each row with the delimiter (default: `true`).
|
|
56
|
-
*
|
|
57
|
-
* > 👉 **Note**: please don’t use this: it could create fragile structures
|
|
58
|
-
* > that aren’t understandable to some markdown parsers.
|
|
59
|
-
*
|
|
60
|
-
* When `true`, there are starting delimiters:
|
|
61
|
-
*
|
|
62
|
-
* ```markdown
|
|
63
|
-
* | Alpha | B |
|
|
64
|
-
* | ----- | ----- |
|
|
65
|
-
* | C | Delta |
|
|
66
|
-
* ```
|
|
67
|
-
*
|
|
68
|
-
* When `false`, there are no starting delimiters:
|
|
69
|
-
*
|
|
70
|
-
* ```markdown
|
|
71
|
-
* Alpha | B |
|
|
72
|
-
* ----- | ----- |
|
|
73
|
-
* C | Delta |
|
|
74
|
-
* ```
|
|
75
|
-
* @property {boolean | null | undefined} [padding=true]
|
|
76
|
-
* Whether to add a space of padding between delimiters and cells
|
|
77
|
-
* (default: `true`).
|
|
78
|
-
*
|
|
79
|
-
* When `true`, there is padding:
|
|
80
|
-
*
|
|
81
|
-
* ```markdown
|
|
82
|
-
* | Alpha | B |
|
|
83
|
-
* | ----- | ----- |
|
|
84
|
-
* | C | Delta |
|
|
85
|
-
* ```
|
|
86
|
-
*
|
|
87
|
-
* When `false`, there is no padding:
|
|
88
|
-
*
|
|
89
|
-
* ```markdown
|
|
90
|
-
* |Alpha|B |
|
|
91
|
-
* |-----|-----|
|
|
92
|
-
* |C |Delta|
|
|
93
|
-
* ```
|
|
94
|
-
* @property {((value: string) => number) | null | undefined} [stringLength]
|
|
95
|
-
* Function to detect the length of table cell content (optional);
|
|
96
|
-
* this is used when aligning the delimiters (`|`) between table cells;
|
|
97
|
-
* full-width characters and emoji mess up delimiter alignment when viewing
|
|
98
|
-
* the markdown source;
|
|
99
|
-
* to fix this, you can pass this function,
|
|
100
|
-
* which receives the cell content and returns its “visible” size;
|
|
101
|
-
* note that what is and isn’t visible depends on where the text is displayed.
|
|
102
|
-
*
|
|
103
|
-
* Without such a function, the following:
|
|
104
|
-
*
|
|
105
|
-
* ```js
|
|
106
|
-
* markdownTable([
|
|
107
|
-
* ['Alpha', 'Bravo'],
|
|
108
|
-
* ['中文', 'Charlie'],
|
|
109
|
-
* ['👩❤️👩', 'Delta']
|
|
110
|
-
* ])
|
|
111
|
-
* ```
|
|
112
|
-
*
|
|
113
|
-
* Yields:
|
|
114
|
-
*
|
|
115
|
-
* ```markdown
|
|
116
|
-
* | Alpha | Bravo |
|
|
117
|
-
* | - | - |
|
|
118
|
-
* | 中文 | Charlie |
|
|
119
|
-
* | 👩❤️👩 | Delta |
|
|
120
|
-
* ```
|
|
121
|
-
*
|
|
122
|
-
* With [`string-width`](https://github.com/sindresorhus/string-width):
|
|
123
|
-
*
|
|
124
|
-
* ```js
|
|
125
|
-
* import stringWidth from 'string-width'
|
|
126
|
-
*
|
|
127
|
-
* markdownTable(
|
|
128
|
-
* [
|
|
129
|
-
* ['Alpha', 'Bravo'],
|
|
130
|
-
* ['中文', 'Charlie'],
|
|
131
|
-
* ['👩❤️👩', 'Delta']
|
|
132
|
-
* ],
|
|
133
|
-
* {stringLength: stringWidth}
|
|
134
|
-
* )
|
|
135
|
-
* ```
|
|
136
|
-
*
|
|
137
|
-
* Yields:
|
|
138
|
-
*
|
|
139
|
-
* ```markdown
|
|
140
|
-
* | Alpha | Bravo |
|
|
141
|
-
* | ----- | ------- |
|
|
142
|
-
* | 中文 | Charlie |
|
|
143
|
-
* | 👩❤️👩 | Delta |
|
|
144
|
-
* ```
|
|
145
|
-
*/
|
|
146
|
-
/**
|
|
147
|
-
* @param {string} value
|
|
148
|
-
* Cell value.
|
|
149
|
-
* @returns {number}
|
|
150
|
-
* Cell size.
|
|
151
|
-
*/
|
|
152
|
-
function defaultStringLength(value) {
|
|
153
|
-
return value.length;
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Generate a markdown
|
|
157
|
-
* ([GFM](https://docs.github.com/en/github/writing-on-github/working-with-advanced-formatting/organizing-information-with-tables))
|
|
158
|
-
* table.
|
|
159
|
-
*
|
|
160
|
-
* @param {ReadonlyArray<ReadonlyArray<string | null | undefined>>} table
|
|
161
|
-
* Table data (matrix of strings).
|
|
162
|
-
* @param {Readonly<Options> | null | undefined} [options]
|
|
163
|
-
* Configuration (optional).
|
|
164
|
-
* @returns {string}
|
|
165
|
-
* Result.
|
|
166
|
-
*/
|
|
167
|
-
function markdownTable(table, options) {
|
|
168
|
-
const settings = options || {};
|
|
169
|
-
const align = (settings.align || []).concat();
|
|
170
|
-
const stringLength = settings.stringLength || defaultStringLength;
|
|
171
|
-
/** @type {Array<number>} Character codes as symbols for alignment per column. */
|
|
172
|
-
const alignments = [];
|
|
173
|
-
/** @type {Array<Array<string>>} Cells per row. */
|
|
174
|
-
const cellMatrix = [];
|
|
175
|
-
/** @type {Array<Array<number>>} Sizes of each cell per row. */
|
|
176
|
-
const sizeMatrix = [];
|
|
177
|
-
/** @type {Array<number>} */
|
|
178
|
-
const longestCellByColumn = [];
|
|
179
|
-
let mostCellsPerRow = 0;
|
|
180
|
-
let rowIndex = -1;
|
|
181
|
-
while (++rowIndex < table.length) {
|
|
182
|
-
/** @type {Array<string>} */
|
|
183
|
-
const row = [];
|
|
184
|
-
/** @type {Array<number>} */
|
|
185
|
-
const sizes = [];
|
|
186
|
-
let columnIndex = -1;
|
|
187
|
-
if (table[rowIndex].length > mostCellsPerRow) mostCellsPerRow = table[rowIndex].length;
|
|
188
|
-
while (++columnIndex < table[rowIndex].length) {
|
|
189
|
-
const cell = serialize(table[rowIndex][columnIndex]);
|
|
190
|
-
if (settings.alignDelimiters !== false) {
|
|
191
|
-
const size = stringLength(cell);
|
|
192
|
-
sizes[columnIndex] = size;
|
|
193
|
-
if (longestCellByColumn[columnIndex] === void 0 || size > longestCellByColumn[columnIndex]) longestCellByColumn[columnIndex] = size;
|
|
194
|
-
}
|
|
195
|
-
row.push(cell);
|
|
196
|
-
}
|
|
197
|
-
cellMatrix[rowIndex] = row;
|
|
198
|
-
sizeMatrix[rowIndex] = sizes;
|
|
199
|
-
}
|
|
200
|
-
let columnIndex = -1;
|
|
201
|
-
if (typeof align === "object" && "length" in align) while (++columnIndex < mostCellsPerRow) alignments[columnIndex] = toAlignment(align[columnIndex]);
|
|
202
|
-
else {
|
|
203
|
-
const code = toAlignment(align);
|
|
204
|
-
while (++columnIndex < mostCellsPerRow) alignments[columnIndex] = code;
|
|
205
|
-
}
|
|
206
|
-
columnIndex = -1;
|
|
207
|
-
/** @type {Array<string>} */
|
|
208
|
-
const row = [];
|
|
209
|
-
/** @type {Array<number>} */
|
|
210
|
-
const sizes = [];
|
|
211
|
-
while (++columnIndex < mostCellsPerRow) {
|
|
212
|
-
const code = alignments[columnIndex];
|
|
213
|
-
let before = "";
|
|
214
|
-
let after = "";
|
|
215
|
-
if (code === 99) {
|
|
216
|
-
before = ":";
|
|
217
|
-
after = ":";
|
|
218
|
-
} else if (code === 108) before = ":";
|
|
219
|
-
else if (code === 114) after = ":";
|
|
220
|
-
let size = settings.alignDelimiters === false ? 1 : Math.max(1, longestCellByColumn[columnIndex] - before.length - after.length);
|
|
221
|
-
const cell = before + "-".repeat(size) + after;
|
|
222
|
-
if (settings.alignDelimiters !== false) {
|
|
223
|
-
size = before.length + size + after.length;
|
|
224
|
-
if (size > longestCellByColumn[columnIndex]) longestCellByColumn[columnIndex] = size;
|
|
225
|
-
sizes[columnIndex] = size;
|
|
226
|
-
}
|
|
227
|
-
row[columnIndex] = cell;
|
|
228
|
-
}
|
|
229
|
-
cellMatrix.splice(1, 0, row);
|
|
230
|
-
sizeMatrix.splice(1, 0, sizes);
|
|
231
|
-
rowIndex = -1;
|
|
232
|
-
/** @type {Array<string>} */
|
|
233
|
-
const lines = [];
|
|
234
|
-
while (++rowIndex < cellMatrix.length) {
|
|
235
|
-
const row = cellMatrix[rowIndex];
|
|
236
|
-
const sizes = sizeMatrix[rowIndex];
|
|
237
|
-
columnIndex = -1;
|
|
238
|
-
/** @type {Array<string>} */
|
|
239
|
-
const line = [];
|
|
240
|
-
while (++columnIndex < mostCellsPerRow) {
|
|
241
|
-
const cell = row[columnIndex] || "";
|
|
242
|
-
let before = "";
|
|
243
|
-
let after = "";
|
|
244
|
-
if (settings.alignDelimiters !== false) {
|
|
245
|
-
const size = longestCellByColumn[columnIndex] - (sizes[columnIndex] || 0);
|
|
246
|
-
const code = alignments[columnIndex];
|
|
247
|
-
if (code === 114) before = " ".repeat(size);
|
|
248
|
-
else if (code === 99) if (size % 2) {
|
|
249
|
-
before = " ".repeat(size / 2 + .5);
|
|
250
|
-
after = " ".repeat(size / 2 - .5);
|
|
251
|
-
} else {
|
|
252
|
-
before = " ".repeat(size / 2);
|
|
253
|
-
after = before;
|
|
254
|
-
}
|
|
255
|
-
else after = " ".repeat(size);
|
|
256
|
-
}
|
|
257
|
-
if (settings.delimiterStart !== false && !columnIndex) line.push("|");
|
|
258
|
-
if (settings.padding !== false && !(settings.alignDelimiters === false && cell === "") && (settings.delimiterStart !== false || columnIndex)) line.push(" ");
|
|
259
|
-
if (settings.alignDelimiters !== false) line.push(before);
|
|
260
|
-
line.push(cell);
|
|
261
|
-
if (settings.alignDelimiters !== false) line.push(after);
|
|
262
|
-
if (settings.padding !== false) line.push(" ");
|
|
263
|
-
if (settings.delimiterEnd !== false || columnIndex !== mostCellsPerRow - 1) line.push("|");
|
|
264
|
-
}
|
|
265
|
-
lines.push(settings.delimiterEnd === false ? line.join("").replace(/ +$/, "") : line.join(""));
|
|
266
|
-
}
|
|
267
|
-
return lines.join("\n");
|
|
268
|
-
}
|
|
269
|
-
/**
|
|
270
|
-
* @param {string | null | undefined} [value]
|
|
271
|
-
* Value to serialize.
|
|
272
|
-
* @returns {string}
|
|
273
|
-
* Result.
|
|
274
|
-
*/
|
|
275
|
-
function serialize(value) {
|
|
276
|
-
return value === null || value === void 0 ? "" : String(value);
|
|
277
|
-
}
|
|
278
|
-
/**
|
|
279
|
-
* @param {string | null | undefined} value
|
|
280
|
-
* Value.
|
|
281
|
-
* @returns {number}
|
|
282
|
-
* Alignment.
|
|
283
|
-
*/
|
|
284
|
-
function toAlignment(value) {
|
|
285
|
-
const code = typeof value === "string" ? value.codePointAt(0) : 0;
|
|
286
|
-
return code === 67 || code === 99 ? 99 : code === 76 || code === 108 ? 108 : code === 82 || code === 114 ? 114 : 0;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
//#endregion
|
|
290
|
-
export { markdownTable as t };
|
|
1
|
+
function defaultStringLength(e){return e.length}function markdownTable(t,i){let a=i||{},o=(a.align||[]).concat(),s=a.stringLength||defaultStringLength,c=[],l=[],u=[],d=[],f=0,p=-1;for(;++p<t.length;){let e=[],r=[],i=-1;for(t[p].length>f&&(f=t[p].length);++i<t[p].length;){let o=serialize(t[p][i]);if(a.alignDelimiters!==!1){let e=s(o);r[i]=e,(d[i]===void 0||e>d[i])&&(d[i]=e)}e.push(o)}l[p]=e,u[p]=r}let m=-1;if(typeof o==`object`&&`length`in o)for(;++m<f;)c[m]=toAlignment(o[m]);else{let e=toAlignment(o);for(;++m<f;)c[m]=e}m=-1;let h=[],g=[];for(;++m<f;){let e=c[m],t=``,n=``;e===99?(t=`:`,n=`:`):e===108?t=`:`:e===114&&(n=`:`);let r=a.alignDelimiters===!1?1:Math.max(1,d[m]-t.length-n.length),i=t+`-`.repeat(r)+n;a.alignDelimiters!==!1&&(r=t.length+r+n.length,r>d[m]&&(d[m]=r),g[m]=r),h[m]=i}l.splice(1,0,h),u.splice(1,0,g),p=-1;let _=[];for(;++p<l.length;){let e=l[p],t=u[p];m=-1;let n=[];for(;++m<f;){let r=e[m]||``,i=``,o=``;if(a.alignDelimiters!==!1){let e=d[m]-(t[m]||0),n=c[m];n===114?i=` `.repeat(e):n===99?e%2?(i=` `.repeat(e/2+.5),o=` `.repeat(e/2-.5)):(i=` `.repeat(e/2),o=i):o=` `.repeat(e)}a.delimiterStart!==!1&&!m&&n.push(`|`),a.padding!==!1&&!(a.alignDelimiters===!1&&r===``)&&(a.delimiterStart!==!1||m)&&n.push(` `),a.alignDelimiters!==!1&&n.push(i),n.push(r),a.alignDelimiters!==!1&&n.push(o),a.padding!==!1&&n.push(` `),(a.delimiterEnd!==!1||m!==f-1)&&n.push(`|`)}_.push(a.delimiterEnd===!1?n.join(``).replace(/ +$/,``):n.join(``))}return _.join(`
|
|
2
|
+
`)}function serialize(e){return e==null?``:String(e)}function toAlignment(e){let t=typeof e==`string`?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}export{markdownTable as t};
|