@oakoliver/lipgloss 1.0.0 → 1.0.1
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/index.cjs +8 -7
- package/dist/index.js +8 -7
- package/dist/layout.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/layout.ts +13 -7
package/dist/index.cjs
CHANGED
|
@@ -2211,20 +2211,21 @@ function joinHorizontal(pos, ...strs) {
|
|
|
2211
2211
|
for (let i = 0; i < blocks.length; i++) {
|
|
2212
2212
|
if (blocks[i].length >= maxHeight) continue;
|
|
2213
2213
|
const extra = maxHeight - blocks[i].length;
|
|
2214
|
-
const empties = new Array(extra).fill("");
|
|
2215
2214
|
const p = Math.min(1, Math.max(0, pos));
|
|
2216
2215
|
if (p <= 0) {
|
|
2216
|
+
const empties = new Array(extra).fill("");
|
|
2217
2217
|
blocks[i] = [...blocks[i], ...empties];
|
|
2218
2218
|
} else if (p >= 1) {
|
|
2219
|
+
const empties = new Array(extra).fill("");
|
|
2219
2220
|
blocks[i] = [...empties, ...blocks[i]];
|
|
2220
2221
|
} else {
|
|
2221
2222
|
const split = Math.round(extra * p);
|
|
2222
|
-
const
|
|
2223
|
-
const
|
|
2223
|
+
const prependCount = split;
|
|
2224
|
+
const appendCount = extra - split;
|
|
2224
2225
|
blocks[i] = [
|
|
2225
|
-
...new Array(
|
|
2226
|
+
...new Array(prependCount).fill(""),
|
|
2226
2227
|
...blocks[i],
|
|
2227
|
-
...new Array(
|
|
2228
|
+
...new Array(appendCount).fill("")
|
|
2228
2229
|
];
|
|
2229
2230
|
}
|
|
2230
2231
|
}
|
|
@@ -2266,8 +2267,8 @@ function joinVertical(pos, ...strs) {
|
|
|
2266
2267
|
result.push(" ".repeat(gap) + line);
|
|
2267
2268
|
} else {
|
|
2268
2269
|
const split = Math.round(gap * p);
|
|
2269
|
-
const
|
|
2270
|
-
const
|
|
2270
|
+
const right = gap - split;
|
|
2271
|
+
const left = gap - right;
|
|
2271
2272
|
result.push(" ".repeat(left) + line + " ".repeat(right));
|
|
2272
2273
|
}
|
|
2273
2274
|
}
|
package/dist/index.js
CHANGED
|
@@ -2113,20 +2113,21 @@ function joinHorizontal(pos, ...strs) {
|
|
|
2113
2113
|
for (let i = 0; i < blocks.length; i++) {
|
|
2114
2114
|
if (blocks[i].length >= maxHeight) continue;
|
|
2115
2115
|
const extra = maxHeight - blocks[i].length;
|
|
2116
|
-
const empties = new Array(extra).fill("");
|
|
2117
2116
|
const p = Math.min(1, Math.max(0, pos));
|
|
2118
2117
|
if (p <= 0) {
|
|
2118
|
+
const empties = new Array(extra).fill("");
|
|
2119
2119
|
blocks[i] = [...blocks[i], ...empties];
|
|
2120
2120
|
} else if (p >= 1) {
|
|
2121
|
+
const empties = new Array(extra).fill("");
|
|
2121
2122
|
blocks[i] = [...empties, ...blocks[i]];
|
|
2122
2123
|
} else {
|
|
2123
2124
|
const split = Math.round(extra * p);
|
|
2124
|
-
const
|
|
2125
|
-
const
|
|
2125
|
+
const prependCount = split;
|
|
2126
|
+
const appendCount = extra - split;
|
|
2126
2127
|
blocks[i] = [
|
|
2127
|
-
...new Array(
|
|
2128
|
+
...new Array(prependCount).fill(""),
|
|
2128
2129
|
...blocks[i],
|
|
2129
|
-
...new Array(
|
|
2130
|
+
...new Array(appendCount).fill("")
|
|
2130
2131
|
];
|
|
2131
2132
|
}
|
|
2132
2133
|
}
|
|
@@ -2168,8 +2169,8 @@ function joinVertical(pos, ...strs) {
|
|
|
2168
2169
|
result.push(" ".repeat(gap) + line);
|
|
2169
2170
|
} else {
|
|
2170
2171
|
const split = Math.round(gap * p);
|
|
2171
|
-
const
|
|
2172
|
-
const
|
|
2172
|
+
const right = gap - split;
|
|
2173
|
+
const left = gap - right;
|
|
2173
2174
|
result.push(" ".repeat(left) + line + " ".repeat(right));
|
|
2174
2175
|
}
|
|
2175
2176
|
}
|
package/dist/layout.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../src/layout.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAO3C;;;GAGG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../src/layout.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAO3C;;;GAGG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CA6DvE;AAMD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAwCrE;AAMD;;GAEG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAExG;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CA0BjF;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAmChF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oakoliver/lipgloss",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "CSS-like terminal styling for JavaScript. Zero dependencies, multi-runtime (Node.js, Bun, Deno). Fluent API for colors, borders, padding, margins, alignment, and layout.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
package/src/layout.ts
CHANGED
|
@@ -35,23 +35,29 @@ export function joinHorizontal(pos: Position, ...strs: string[]): string {
|
|
|
35
35
|
for (let i = 0; i < blocks.length; i++) {
|
|
36
36
|
if (blocks[i].length >= maxHeight) continue;
|
|
37
37
|
const extra = maxHeight - blocks[i].length;
|
|
38
|
-
const empties = new Array<string>(extra).fill('');
|
|
39
38
|
|
|
40
39
|
const p = Math.min(1, Math.max(0, pos));
|
|
41
40
|
if (p <= 0) {
|
|
42
41
|
// Top aligned
|
|
42
|
+
const empties = new Array<string>(extra).fill('');
|
|
43
43
|
blocks[i] = [...blocks[i], ...empties];
|
|
44
44
|
} else if (p >= 1) {
|
|
45
45
|
// Bottom aligned
|
|
46
|
+
const empties = new Array<string>(extra).fill('');
|
|
46
47
|
blocks[i] = [...empties, ...blocks[i]];
|
|
47
48
|
} else {
|
|
49
|
+
// Somewhere in the middle
|
|
50
|
+
// Go logic: split = round(n * pos), then uses array slicing
|
|
51
|
+
// extraLines[top:] prepends (n - split) items from end
|
|
52
|
+
// extraLines[bottom:] appends (n - (n - split)) = split items from end
|
|
53
|
+
// Result: prepend (split) empties, append (n - split) empties
|
|
48
54
|
const split = Math.round(extra * p);
|
|
49
|
-
const
|
|
50
|
-
const
|
|
55
|
+
const prependCount = split;
|
|
56
|
+
const appendCount = extra - split;
|
|
51
57
|
blocks[i] = [
|
|
52
|
-
...new Array<string>(
|
|
58
|
+
...new Array<string>(prependCount).fill(''),
|
|
53
59
|
...blocks[i],
|
|
54
|
-
...new Array<string>(
|
|
60
|
+
...new Array<string>(appendCount).fill(''),
|
|
55
61
|
];
|
|
56
62
|
}
|
|
57
63
|
}
|
|
@@ -112,8 +118,8 @@ export function joinVertical(pos: Position, ...strs: string[]): string {
|
|
|
112
118
|
result.push(' '.repeat(gap) + line);
|
|
113
119
|
} else {
|
|
114
120
|
const split = Math.round(gap * p);
|
|
115
|
-
const
|
|
116
|
-
const
|
|
121
|
+
const right = gap - split;
|
|
122
|
+
const left = gap - right;
|
|
117
123
|
result.push(' '.repeat(left) + line + ' '.repeat(right));
|
|
118
124
|
}
|
|
119
125
|
}
|