@rhizogrip/spore-cli 1.57.0 → 1.57.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/package.json +3 -3
- package/tui/answer.js +16 -13
- package/tui/index.js +1 -1
- package/tui/links.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rhizogrip/spore-cli",
|
|
3
|
-
"version": "1.57.
|
|
3
|
+
"version": "1.57.1",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "Christophe Le Bars",
|
|
6
6
|
"email": "clb@toort.net"
|
|
@@ -49,12 +49,12 @@
|
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@clack/prompts": "^1.8.1",
|
|
52
|
-
"@earendil-works/pi-tui": "1.
|
|
52
|
+
"@earendil-works/pi-tui": "1.5.0",
|
|
53
53
|
"chalk": "^6.0.1",
|
|
54
54
|
"minimist": "^1.2.8"
|
|
55
55
|
},
|
|
56
56
|
"optionalDependencies": {
|
|
57
|
-
"@rhizogrip/spore": "1.57.
|
|
57
|
+
"@rhizogrip/spore": "1.57.1"
|
|
58
58
|
},
|
|
59
59
|
"license": "Apache-2.0"
|
|
60
60
|
}
|
package/tui/answer.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { Markdown } from '@earendil-works/pi-tui'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* An answer as pi-tui draws it, keeping the code blocks it drew: `
|
|
4
|
+
* An answer as pi-tui draws it, keeping the code blocks it drew: `codeBlocks` is each one's text
|
|
5
5
|
* exactly as written, in the order shown. Labelled, each opening fence says how to copy it.
|
|
6
|
+
* It reads them line by line through `codeBlock` because pi-tui remembers what `highlightCode`
|
|
7
|
+
* returned, so that hook is not called again on a later pass.
|
|
6
8
|
*/
|
|
7
9
|
export class Answer extends Markdown {
|
|
8
10
|
constructor (text, theme, { labelled = false } = {}) {
|
|
@@ -10,12 +12,12 @@ export class Answer extends Markdown {
|
|
|
10
12
|
this.theme = {
|
|
11
13
|
...theme,
|
|
12
14
|
codeBlockBorder: (fence) => this.fence(fence),
|
|
13
|
-
|
|
15
|
+
codeBlock: (line) => this.codeLine(line)
|
|
14
16
|
}
|
|
15
17
|
this.base = theme
|
|
16
18
|
this.labelled = labelled
|
|
17
|
-
this.
|
|
18
|
-
this.
|
|
19
|
+
this.codeBlocks = []
|
|
20
|
+
this.opened = null
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
label (on) {
|
|
@@ -26,23 +28,24 @@ export class Answer extends Markdown {
|
|
|
26
28
|
|
|
27
29
|
render (width) {
|
|
28
30
|
if (this.cachedText !== this.text || this.cachedWidth !== width) {
|
|
29
|
-
this.
|
|
30
|
-
this.
|
|
31
|
+
this.codeBlocks = []
|
|
32
|
+
this.opened = null
|
|
31
33
|
}
|
|
32
34
|
return super.render(width)
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
fence (fence) {
|
|
36
|
-
if (this.
|
|
37
|
-
this.
|
|
38
|
+
if (this.opened) {
|
|
39
|
+
this.codeBlocks.push({ lang: this.opened.lang, text: this.opened.lines.join('\n') })
|
|
40
|
+
this.opened = null
|
|
38
41
|
return this.base.codeBlockBorder(fence)
|
|
39
42
|
}
|
|
40
|
-
this.
|
|
41
|
-
return this.base.codeBlockBorder(this.labelled ? `${fence} · /copy ${this.
|
|
43
|
+
this.opened = { lang: fence.replace(/^`+/, ''), lines: [] }
|
|
44
|
+
return this.base.codeBlockBorder(this.labelled ? `${fence} · /copy ${this.codeBlocks.length + 1}` : fence)
|
|
42
45
|
}
|
|
43
46
|
|
|
44
|
-
|
|
45
|
-
this.
|
|
46
|
-
return
|
|
47
|
+
codeLine (line) {
|
|
48
|
+
this.opened.lines.push(line)
|
|
49
|
+
return this.base.codeBlock(line)
|
|
47
50
|
}
|
|
48
51
|
}
|
package/tui/index.js
CHANGED
|
@@ -114,7 +114,7 @@ class Conversation {
|
|
|
114
114
|
/** The code blocks of the last answer, numbered on screen from 1. */
|
|
115
115
|
lastBlocks () {
|
|
116
116
|
const last = this.lastAnswer()
|
|
117
|
-
return last ? this.markdown(last).
|
|
117
|
+
return last ? this.markdown(last).codeBlocks : []
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
render (width) {
|
package/tui/links.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The `· /copy <n>` label on a code block's opening fence, made a link. It is drawn as an OSC 8
|
|
3
|
-
* hyperlink
|
|
3
|
+
* hyperlink, so a click on it reaches pi-tui's `openUrl` with a
|
|
4
4
|
* URL this module reads back into the number of the block to copy. The label's own look is
|
|
5
5
|
* unchanged, and the link adds no width to the line.
|
|
6
6
|
*/
|