posthtml-component 2.1.1 → 2.2.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 +2 -2
- package/src/index.js +15 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "posthtml-component",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "Laravel Blade-inspired components for PostHTML with slots, attributes as props, custom tags and more.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "posthtml/posthtml-components",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"style-to-object": "^1.0.6"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@biomejs/biome": "2.
|
|
42
|
+
"@biomejs/biome": "2.2.4",
|
|
43
43
|
"@vitest/coverage-v8": "^3.0.4",
|
|
44
44
|
"conventional-changelog-cli": "^5.0.0",
|
|
45
45
|
"highlight.js": "^11.6.0",
|
package/src/index.js
CHANGED
|
@@ -147,7 +147,7 @@ module.exports = (options = {}) => tree => {
|
|
|
147
147
|
return processStacks(
|
|
148
148
|
processPushes(
|
|
149
149
|
processTree(options)(
|
|
150
|
-
expressions(options.expressions)(tree)
|
|
150
|
+
expressions(options.expressions)(tree), tree.messages
|
|
151
151
|
),
|
|
152
152
|
pushedContent,
|
|
153
153
|
options.push
|
|
@@ -166,9 +166,7 @@ let processCounter = 0;
|
|
|
166
166
|
* @return {Object} PostHTML tree
|
|
167
167
|
*/
|
|
168
168
|
function processTree(options) {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
return tree => {
|
|
169
|
+
return (tree, messages) => {
|
|
172
170
|
log(`Processing tree number ${processCounter}..`, 'processTree');
|
|
173
171
|
|
|
174
172
|
if (options.plugins.length > 0) {
|
|
@@ -176,6 +174,8 @@ function processTree(options) {
|
|
|
176
174
|
}
|
|
177
175
|
|
|
178
176
|
match.call(tree, options.matcher, currentNode => {
|
|
177
|
+
const filledSlots = {};
|
|
178
|
+
|
|
179
179
|
log(`Match found for tag "${currentNode.tag}"..`, 'processTree');
|
|
180
180
|
|
|
181
181
|
if (!currentNode.attrs) {
|
|
@@ -184,6 +184,13 @@ function processTree(options) {
|
|
|
184
184
|
|
|
185
185
|
const componentPath = getComponentPath(currentNode, options);
|
|
186
186
|
|
|
187
|
+
if (messages) {
|
|
188
|
+
messages.push({
|
|
189
|
+
type: 'dependency',
|
|
190
|
+
file: componentPath
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
|
|
187
194
|
if (!componentPath) {
|
|
188
195
|
return currentNode;
|
|
189
196
|
}
|
|
@@ -222,14 +229,14 @@ function processTree(options) {
|
|
|
222
229
|
return currentNode.content || nextNode.content;
|
|
223
230
|
});
|
|
224
231
|
|
|
225
|
-
|
|
232
|
+
// Process <slot> tags
|
|
233
|
+
processSlotContent(nextNode, filledSlots, options);
|
|
234
|
+
|
|
235
|
+
nextNode = processTree(options)(nextNode, messages);
|
|
226
236
|
|
|
227
237
|
// Process <fill> tags
|
|
228
238
|
processFillContent(nextNode, filledSlots, options);
|
|
229
239
|
|
|
230
|
-
// Process <slot> tags
|
|
231
|
-
processSlotContent(nextNode, filledSlots, options);
|
|
232
|
-
|
|
233
240
|
// Remove component tag and replace content with <yield>
|
|
234
241
|
currentNode.tag = false;
|
|
235
242
|
currentNode.content = content;
|