cellery 1.4.3 → 1.4.5
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 +13 -6
- package/lib/compat.js +1 -0
- package/lib/template.js +28 -1
- package/package.json +3 -2
package/lib/cells.js
CHANGED
|
@@ -100,13 +100,19 @@ class Style {
|
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
addScope(parent) {
|
|
103
|
+
let inKeyframes = 0
|
|
103
104
|
walk(this.content, {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
105
|
+
enter(node) {
|
|
106
|
+
if (node.type === 'Atrule' && node.name === 'keyframes') inKeyframes++
|
|
107
|
+
if (node.type === 'Rule' && inKeyframes === 0) {
|
|
108
|
+
node.prelude.children.forEach((selector) => {
|
|
109
|
+
selector.children.prependData({ type: 'Combinator', name: ' ' })
|
|
110
|
+
selector.children.prependData({ type: 'IdSelector', name: parent })
|
|
111
|
+
})
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
leave(node) {
|
|
115
|
+
if (node.type === 'Atrule' && node.name === 'keyframes') inKeyframes--
|
|
110
116
|
}
|
|
111
117
|
})
|
|
112
118
|
}
|
|
@@ -143,6 +149,7 @@ class Text extends Cell {
|
|
|
143
149
|
super(opts)
|
|
144
150
|
this.value = opts.value || this.children.filter((c) => typeof c === 'string').join('') || ''
|
|
145
151
|
this.paragraph = !!opts.paragraph
|
|
152
|
+
this.pre = !!opts.pre
|
|
146
153
|
this.heading = opts.heading
|
|
147
154
|
}
|
|
148
155
|
}
|
package/lib/compat.js
CHANGED
|
@@ -8,6 +8,7 @@ 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 }),
|
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.5",
|
|
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",
|