@fraqjs/fraq 0.3.0 → 0.3.2
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.mjs +30 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -632,7 +632,36 @@ function msg(strings, ...values) {
|
|
|
632
632
|
type: "text",
|
|
633
633
|
data: { text: buffer }
|
|
634
634
|
});
|
|
635
|
-
return segments;
|
|
635
|
+
return trimBoundaryTextSegments(segments);
|
|
636
|
+
}
|
|
637
|
+
function isTextSegment(segment) {
|
|
638
|
+
return segment.type === "text";
|
|
639
|
+
}
|
|
640
|
+
function withText(segment, text) {
|
|
641
|
+
return {
|
|
642
|
+
...segment,
|
|
643
|
+
data: {
|
|
644
|
+
...segment.data,
|
|
645
|
+
text
|
|
646
|
+
}
|
|
647
|
+
};
|
|
648
|
+
}
|
|
649
|
+
function trimBoundaryTextSegments(segments) {
|
|
650
|
+
const result = [...segments];
|
|
651
|
+
const first = result[0];
|
|
652
|
+
if (first && isTextSegment(first)) {
|
|
653
|
+
const text = first.data.text.trimStart();
|
|
654
|
+
if (text) result[0] = withText(first, text);
|
|
655
|
+
else result.shift();
|
|
656
|
+
}
|
|
657
|
+
const lastIndex = result.length - 1;
|
|
658
|
+
const last = result[lastIndex];
|
|
659
|
+
if (last && isTextSegment(last)) {
|
|
660
|
+
const text = last.data.text.trimEnd();
|
|
661
|
+
if (text) result[lastIndex] = withText(last, text);
|
|
662
|
+
else result.pop();
|
|
663
|
+
}
|
|
664
|
+
return result;
|
|
636
665
|
}
|
|
637
666
|
let seg;
|
|
638
667
|
(function(_seg) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fraqjs/fraq",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.2",
|
|
5
5
|
"description": "Milky Bot framework",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist"
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
"main": "dist/index.mjs",
|
|
10
10
|
"typings": "dist/index.d.mts",
|
|
11
11
|
"keywords": [],
|
|
12
|
-
"author": "
|
|
12
|
+
"author": "fraqjs",
|
|
13
13
|
"repository": {
|
|
14
14
|
"type": "git",
|
|
15
|
-
"url": "git+https://github.com/
|
|
15
|
+
"url": "git+https://github.com/fraqjs/fraq.git"
|
|
16
16
|
},
|
|
17
17
|
"homepage": "https://fraq.ntqqrev.org/",
|
|
18
18
|
"license": "MIT",
|