posthtml-component 2.1.0 → 2.2.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "posthtml-component",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
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,8 +39,8 @@
39
39
  "style-to-object": "^1.0.6"
40
40
  },
41
41
  "devDependencies": {
42
- "@biomejs/biome": "1.9.4",
43
- "@vitest/coverage-v8": "^2.0.4",
42
+ "@biomejs/biome": "2.1.1",
43
+ "@vitest/coverage-v8": "^3.0.4",
44
44
  "conventional-changelog-cli": "^5.0.0",
45
45
  "highlight.js": "^11.6.0",
46
46
  "markdown-it-anchor": "^9.0.1",
@@ -49,6 +49,6 @@
49
49
  "posthtml-beautify": "^0.7.0",
50
50
  "posthtml-include": "^2.0.1",
51
51
  "posthtml-markdownit": "^3.1.0",
52
- "vitest": "^2.0.4"
52
+ "vitest": "^3.0.4"
53
53
  }
54
54
  }
package/src/find-path.js CHANGED
@@ -1,7 +1,5 @@
1
- 'use strict';
2
-
3
- const path = require('path');
4
- const {existsSync} = require('fs');
1
+ const path = require('node:path');
2
+ const {existsSync} = require('node:fs');
5
3
 
6
4
  const folderSeparator = '.';
7
5
 
package/src/index.d.ts CHANGED
@@ -182,6 +182,7 @@ export type PostHTMLComponents = {
182
182
  *
183
183
  *
184
184
  */
185
+ // biome-ignore lint: using `any` until we can do better
185
186
  mergeCustomizer?: (objValue: any, srcValue: any) => any;
186
187
 
187
188
  /**
package/src/index.js CHANGED
@@ -1,7 +1,5 @@
1
- 'use strict';
2
-
3
- const {readFileSync, existsSync} = require('fs');
4
- const path = require('path');
1
+ const {readFileSync, existsSync} = require('node:fs');
2
+ const path = require('node:path');
5
3
  const {parser} = require('posthtml-parser');
6
4
  const {match, walk} = require('posthtml/lib/api');
7
5
  const expressions = require('posthtml-expressions');
@@ -149,7 +147,7 @@ module.exports = (options = {}) => tree => {
149
147
  return processStacks(
150
148
  processPushes(
151
149
  processTree(options)(
152
- expressions(options.expressions)(tree)
150
+ expressions(options.expressions)(tree), tree.messages
153
151
  ),
154
152
  pushedContent,
155
153
  options.push
@@ -170,7 +168,7 @@ let processCounter = 0;
170
168
  function processTree(options) {
171
169
  const filledSlots = {};
172
170
 
173
- return tree => {
171
+ return (tree, messages) => {
174
172
  log(`Processing tree number ${processCounter}..`, 'processTree');
175
173
 
176
174
  if (options.plugins.length > 0) {
@@ -186,6 +184,13 @@ function processTree(options) {
186
184
 
187
185
  const componentPath = getComponentPath(currentNode, options);
188
186
 
187
+ if (messages) {
188
+ messages.push({
189
+ type: 'dependency',
190
+ file: componentPath
191
+ });
192
+ }
193
+
189
194
  if (!componentPath) {
190
195
  return currentNode;
191
196
  }
@@ -224,7 +229,7 @@ function processTree(options) {
224
229
  return currentNode.content || nextNode.content;
225
230
  });
226
231
 
227
- nextNode = processTree(options)(nextNode);
232
+ nextNode = processTree(options)(nextNode, messages);
228
233
 
229
234
  // Process <fill> tags
230
235
  processFillContent(nextNode, filledSlots, options);
@@ -244,7 +249,7 @@ function processTree(options) {
244
249
  * 'undefined' or 'null'.
245
250
  */
246
251
  walk.call(currentNode, node => {
247
- if (node && node.attrs) {
252
+ if (node?.attrs) {
248
253
  for (const key in node.attrs) {
249
254
  if (node.attrs[key] === 'undefined' || node.attrs[key] === 'null') {
250
255
  delete node.attrs[key];
package/src/log.js CHANGED
@@ -1,4 +1,4 @@
1
- const {inspect} = require('util');
1
+ const {inspect} = require('node:util');
2
2
 
3
3
  const debug = false;
4
4
 
@@ -1,5 +1,3 @@
1
- 'use strict';
2
-
3
1
  const {match} = require('posthtml/lib/api');
4
2
  const parseAttrs = require('posthtml-attrs-parser');
5
3
  const styleToObject = require('style-to-object').default;
@@ -1,5 +1,3 @@
1
- 'use strict';
2
-
3
1
  const pick = require('lodash/pick');
4
2
  const assign = require('lodash/assign');
5
3
  const mergeWith = require('lodash/mergeWith');
@@ -1,7 +1,5 @@
1
- 'use strict';
2
-
3
- const vm = require('vm');
4
- const {existsSync, readFileSync} = require('fs');
1
+ const vm = require('node:vm');
2
+ const {existsSync, readFileSync} = require('node:fs');
5
3
  const {render} = require('posthtml-render');
6
4
  const {match} = require('posthtml/lib/api');
7
5
 
@@ -1,5 +1,3 @@
1
- 'use strict';
2
-
3
1
  const {match} = require('posthtml/lib/api');
4
2
  const {render} = require('posthtml-render');
5
3
  const omit = require('lodash/omit');
@@ -25,7 +23,7 @@ function setFilledSlots(currentNode, filledSlots, {fill, slotSeparator, propsSlo
25
23
 
26
24
  if (props) {
27
25
  for (const key in props) {
28
- if (props.hasOwnProperty(key)) {
26
+ if (Object.hasOwn(props, key)) {
29
27
  try {
30
28
  props[key] = JSON.parse(props[key]);
31
29
  } catch {}
@@ -1,5 +1,3 @@
1
- 'use strict';
2
-
3
1
  const {match} = require('posthtml/lib/api');
4
2
  const {render} = require('posthtml-render');
5
3
  const get = require('lodash/get');