cellery 1.4.2 → 1.4.4
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/lib/cells.js +3 -2
- package/lib/compat.js +3 -2
- package/lib/template.js +28 -1
- package/package.json +3 -2
package/lib/cells.js
CHANGED
|
@@ -143,6 +143,7 @@ class Text extends Cell {
|
|
|
143
143
|
super(opts)
|
|
144
144
|
this.value = opts.value || this.children.filter((c) => typeof c === 'string').join('') || ''
|
|
145
145
|
this.paragraph = !!opts.paragraph
|
|
146
|
+
this.pre = !!opts.pre
|
|
146
147
|
this.heading = opts.heading
|
|
147
148
|
}
|
|
148
149
|
}
|
|
@@ -156,7 +157,7 @@ class Input extends Cell {
|
|
|
156
157
|
}
|
|
157
158
|
}
|
|
158
159
|
|
|
159
|
-
class
|
|
160
|
+
class Details extends Cell {
|
|
160
161
|
constructor(opts = {}) {
|
|
161
162
|
super(opts)
|
|
162
163
|
this.value = opts.value || this.children.filter((c) => typeof c === 'string').join('') || ''
|
|
@@ -176,7 +177,7 @@ module.exports = {
|
|
|
176
177
|
Fragment,
|
|
177
178
|
Text,
|
|
178
179
|
Input,
|
|
179
|
-
|
|
180
|
+
Details,
|
|
180
181
|
Summary,
|
|
181
182
|
Style
|
|
182
183
|
}
|
package/lib/compat.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { Text, Input, Container, Fragment, Style,
|
|
1
|
+
const { Text, Input, Container, Fragment, Style, Details, Summary } = require('./cells')
|
|
2
2
|
|
|
3
3
|
module.exports = {
|
|
4
4
|
'': Fragment,
|
|
@@ -8,13 +8,14 @@ module.exports = {
|
|
|
8
8
|
h4: Text.Styled({ heading: 4 }),
|
|
9
9
|
h5: Text.Styled({ heading: 5 }),
|
|
10
10
|
h6: Text.Styled({ heading: 6 }),
|
|
11
|
+
pre: Text.Styled({ pre: true }),
|
|
11
12
|
div: Container,
|
|
12
13
|
input: Input.Styled({ multiline: false }),
|
|
13
14
|
textbox: Input.Styled({ multiline: true }),
|
|
14
15
|
span: Text,
|
|
15
16
|
button: Container.Styled({ events: ['click'] }),
|
|
16
17
|
p: Text.Styled({ paragraph: true }),
|
|
17
|
-
|
|
18
|
+
details: Details,
|
|
18
19
|
summary: Summary,
|
|
19
20
|
style: Style
|
|
20
21
|
}
|
package/lib/template.js
CHANGED
|
@@ -164,6 +164,14 @@ function parse(input, slots) {
|
|
|
164
164
|
|
|
165
165
|
// ---- builder ----
|
|
166
166
|
|
|
167
|
+
function isPromise(val) {
|
|
168
|
+
return val !== null && typeof val.then === 'function'
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function isStream(val) {
|
|
172
|
+
return val !== null && typeof val.on === 'function' && !(val instanceof cells.Cell)
|
|
173
|
+
}
|
|
174
|
+
|
|
167
175
|
function build(node, slots) {
|
|
168
176
|
if (node.type === 'text') return node.value
|
|
169
177
|
|
|
@@ -184,12 +192,31 @@ function build(node, slots) {
|
|
|
184
192
|
return c !== null
|
|
185
193
|
})
|
|
186
194
|
|
|
187
|
-
|
|
195
|
+
const cell = new Ctor({
|
|
188
196
|
...node.attrs,
|
|
189
197
|
children,
|
|
190
198
|
style,
|
|
191
199
|
cells: node.tag.toLowerCase() === 'style' ? registry : undefined
|
|
192
200
|
})
|
|
201
|
+
|
|
202
|
+
for (let i = 0; i < children.length; i++) {
|
|
203
|
+
const child = children[i]
|
|
204
|
+
|
|
205
|
+
if (isPromise(child)) {
|
|
206
|
+
child.then((val) => {
|
|
207
|
+
children[i] = val
|
|
208
|
+
cell.render()
|
|
209
|
+
})
|
|
210
|
+
} else if (isStream(child)) {
|
|
211
|
+
children.splice(i)
|
|
212
|
+
child.on('data', (val) => {
|
|
213
|
+
children.push(val)
|
|
214
|
+
cell.render()
|
|
215
|
+
})
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
return cell
|
|
193
220
|
}
|
|
194
221
|
|
|
195
222
|
module.exports = { cellery, register }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cellery",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.4",
|
|
4
4
|
"description": "cellery",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./package": "./package.json",
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
"brittle": "^3.19.0",
|
|
21
21
|
"lunte": "^1.2.0",
|
|
22
22
|
"prettier": "^3.6.2",
|
|
23
|
-
"prettier-config-holepunch": "^2.0.0"
|
|
23
|
+
"prettier-config-holepunch": "^2.0.0",
|
|
24
|
+
"streamx": "^2.25.0"
|
|
24
25
|
},
|
|
25
26
|
"scripts": {
|
|
26
27
|
"format": "prettier . --write",
|