html-react-parser 5.2.17 → 6.0.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/README.md +6 -0
- package/dist/html-react-parser.js +1030 -775
- package/dist/html-react-parser.js.map +1 -1
- package/dist/html-react-parser.min.js +1 -1
- package/dist/html-react-parser.min.js.map +1 -1
- package/lib/attributes-to-props.js +13 -14
- package/lib/attributes-to-props.js.map +1 -1
- package/lib/dom-to-react.js +17 -18
- package/lib/dom-to-react.js.map +1 -1
- package/lib/index.js +4 -4
- package/lib/index.js.map +1 -1
- package/lib/utilities.d.ts +1 -1
- package/lib/utilities.js +6 -8
- package/lib/utilities.js.map +1 -1
- package/package.json +29 -29
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = attributesToProps;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const react_property_1 = require("react-property");
|
|
5
|
+
const utilities_1 = require("./utilities");
|
|
6
6
|
// https://react.dev/learn/sharing-state-between-components#controlled-and-uncontrolled-components
|
|
7
7
|
// https://developer.mozilla.org/docs/Web/HTML/Attributes
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
const UNCONTROLLED_COMPONENT_ATTRIBUTES = ['checked', 'value'];
|
|
9
|
+
const UNCONTROLLED_COMPONENT_NAMES = ['input', 'select', 'textarea'];
|
|
10
|
+
const valueOnlyInputs = {
|
|
11
11
|
reset: true,
|
|
12
12
|
submit: true,
|
|
13
13
|
};
|
|
@@ -18,22 +18,21 @@ var valueOnlyInputs = {
|
|
|
18
18
|
* @param nodeName - DOM node name.
|
|
19
19
|
* @returns - React props.
|
|
20
20
|
*/
|
|
21
|
-
function attributesToProps(attributes, nodeName) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
var attributeValue = attributes[attributeName];
|
|
21
|
+
function attributesToProps(attributes = {}, nodeName) {
|
|
22
|
+
const props = {};
|
|
23
|
+
const isInputValueOnly = Boolean(attributes.type && valueOnlyInputs[attributes.type]);
|
|
24
|
+
for (const attributeName in attributes) {
|
|
25
|
+
const attributeValue = attributes[attributeName];
|
|
27
26
|
// ARIA (aria-*) or custom data (data-*) attribute
|
|
28
27
|
if ((0, react_property_1.isCustomAttribute)(attributeName)) {
|
|
29
28
|
props[attributeName] = attributeValue;
|
|
30
29
|
continue;
|
|
31
30
|
}
|
|
32
31
|
// convert HTML/SVG attribute to React prop
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
const attributeNameLowerCased = attributeName.toLowerCase();
|
|
33
|
+
let propName = getPropName(attributeNameLowerCased);
|
|
35
34
|
if (propName) {
|
|
36
|
-
|
|
35
|
+
const propertyInfo = (0, react_property_1.getPropertyInfo)(propName);
|
|
37
36
|
// convert attribute to uncontrolled component prop (e.g., `value` to `defaultValue`)
|
|
38
37
|
if (UNCONTROLLED_COMPONENT_ATTRIBUTES.includes(propName) &&
|
|
39
38
|
UNCONTROLLED_COMPONENT_NAMES.includes(nodeName) &&
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attributes-to-props.js","sourceRoot":"","sources":["../src/attributes-to-props.ts"],"names":[],"mappings":";;AA4CA,oCAkEC;AA9GD,
|
|
1
|
+
{"version":3,"file":"attributes-to-props.js","sourceRoot":"","sources":["../src/attributes-to-props.ts"],"names":[],"mappings":";;AA4CA,oCAkEC;AA9GD,mDAMwB;AAExB,2CAAuE;AAEvE,kGAAkG;AAClG,yDAAyD;AACzD,MAAM,iCAAiC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAU,CAAC;AACxE,MAAM,4BAA4B,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,UAAU,CAAU,CAAC;AAO9E,MAAM,eAAe,GAAG;IACtB,KAAK,EAAE,IAAI;IACX,MAAM,EAAE,IAAI;CACJ,CAAC;AAcX;;;;;;GAMG;AACH,SAAwB,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;YACV,CAAC;YACD,SAAS;QACX,CAAC;QAED,0CAA0C;QAC1C,IAAI,sCAA0B,EAAE,CAAC;YAC/B,KAAK,CAAC,aAAa,CAAC,GAAG,cAAc,CAAC;QACxC,CAAC;IACH,CAAC;IAED,mCAAmC;IACnC,IAAA,wBAAY,EAAC,UAAU,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAEtC,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;GAKG;AACH,SAAS,WAAW,CAAC,aAAqB;IACxC,OAAO,sCAAqB,CAAC,aAAa,CAAC,CAAC;AAC9C,CAAC"}
|
package/lib/dom-to-react.js
CHANGED
|
@@ -5,10 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.default = domToReact;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const attributes_to_props_1 = __importDefault(require("./attributes-to-props"));
|
|
10
|
+
const utilities_1 = require("./utilities");
|
|
11
|
+
const React = {
|
|
12
12
|
cloneElement: react_1.cloneElement,
|
|
13
13
|
createElement: react_1.createElement,
|
|
14
14
|
isValidElement: react_1.isValidElement,
|
|
@@ -20,19 +20,18 @@ var React = {
|
|
|
20
20
|
* @param options - Options.
|
|
21
21
|
* @returns - String or JSX element(s).
|
|
22
22
|
*/
|
|
23
|
-
function domToReact(nodes, options) {
|
|
23
|
+
function domToReact(nodes, options = {}) {
|
|
24
24
|
var _a, _b, _c, _d, _e;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
var node = nodes[index];
|
|
25
|
+
const reactElements = [];
|
|
26
|
+
const hasReplace = typeof options.replace === 'function';
|
|
27
|
+
const transform = (_a = options.transform) !== null && _a !== void 0 ? _a : utilities_1.returnFirstArg;
|
|
28
|
+
const { cloneElement, createElement, isValidElement } = (_b = options.library) !== null && _b !== void 0 ? _b : React;
|
|
29
|
+
const nodesLength = nodes.length;
|
|
30
|
+
for (let index = 0; index < nodesLength; index++) {
|
|
31
|
+
const node = nodes[index];
|
|
33
32
|
// replace with custom React element (if present)
|
|
34
33
|
if (hasReplace) {
|
|
35
|
-
|
|
34
|
+
let replaceElement = (_c = options.replace) === null || _c === void 0 ? void 0 : _c.call(options, node, index);
|
|
36
35
|
if (isValidElement(replaceElement)) {
|
|
37
36
|
// set "key" prop for sibling elements
|
|
38
37
|
// https://react.dev/learn/rendering-lists#rules-of-keys
|
|
@@ -46,7 +45,7 @@ function domToReact(nodes, options) {
|
|
|
46
45
|
}
|
|
47
46
|
}
|
|
48
47
|
if (node.type === 'text') {
|
|
49
|
-
|
|
48
|
+
const isWhitespace = !node.data.trim().length;
|
|
50
49
|
// We have a whitespace node that can't be nested in its parent
|
|
51
50
|
// so skip it
|
|
52
51
|
if (isWhitespace &&
|
|
@@ -64,8 +63,8 @@ function domToReact(nodes, options) {
|
|
|
64
63
|
reactElements.push(transform(node.data, node, index));
|
|
65
64
|
continue;
|
|
66
65
|
}
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
const element = node;
|
|
67
|
+
let props = {};
|
|
69
68
|
if (skipAttributesToProps(element)) {
|
|
70
69
|
(0, utilities_1.setStyleProp)(element.attribs.style, element.attribs);
|
|
71
70
|
props = element.attribs;
|
|
@@ -74,7 +73,7 @@ function domToReact(nodes, options) {
|
|
|
74
73
|
else if (element.attribs) {
|
|
75
74
|
props = (0, attributes_to_props_1.default)(element.attribs, element.name);
|
|
76
75
|
}
|
|
77
|
-
|
|
76
|
+
let children;
|
|
78
77
|
switch (node.type) {
|
|
79
78
|
case 'script':
|
|
80
79
|
case 'style':
|
package/lib/dom-to-react.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dom-to-react.js","sourceRoot":"","sources":["../src/dom-to-react.ts"],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CAAC,IAAI,KAAK,KAAK;QACnB,IAAA,6BAAiB,EAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAC3C,CAAC;AACJ,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -5,18 +5,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.htmlToDOM = exports.domToReact = exports.attributesToProps = exports.Text = exports.ProcessingInstruction = exports.Element = exports.Comment = void 0;
|
|
7
7
|
exports.default = HTMLReactParser;
|
|
8
|
-
|
|
8
|
+
const html_dom_parser_1 = __importDefault(require("html-dom-parser"));
|
|
9
9
|
exports.htmlToDOM = html_dom_parser_1.default;
|
|
10
|
-
|
|
10
|
+
const attributes_to_props_1 = __importDefault(require("./attributes-to-props"));
|
|
11
11
|
exports.attributesToProps = attributes_to_props_1.default;
|
|
12
|
-
|
|
12
|
+
const dom_to_react_1 = __importDefault(require("./dom-to-react"));
|
|
13
13
|
exports.domToReact = dom_to_react_1.default;
|
|
14
14
|
var domhandler_1 = require("domhandler");
|
|
15
15
|
Object.defineProperty(exports, "Comment", { enumerable: true, get: function () { return domhandler_1.Comment; } });
|
|
16
16
|
Object.defineProperty(exports, "Element", { enumerable: true, get: function () { return domhandler_1.Element; } });
|
|
17
17
|
Object.defineProperty(exports, "ProcessingInstruction", { enumerable: true, get: function () { return domhandler_1.ProcessingInstruction; } });
|
|
18
18
|
Object.defineProperty(exports, "Text", { enumerable: true, get: function () { return domhandler_1.Text; } });
|
|
19
|
-
|
|
19
|
+
const domParserOptions = { lowerCaseAttributeNames: false };
|
|
20
20
|
/**
|
|
21
21
|
* Converts HTML string to React elements.
|
|
22
22
|
*
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAqBA,kCAgBC;AArCD,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAqBA,kCAgBC;AArCD,sEAAwC;AAUA,oBAVjC,yBAAS,CAUiC;AARjD,gFAAsD;AAQ7C,4BARF,6BAAiB,CAQE;AAP1B,kEAAwC;AAOZ,qBAPrB,sBAAU,CAOqB;AAJtC,yCAA2E;AAAlE,qGAAA,OAAO,OAAA;AAAE,qGAAA,OAAO,OAAA;AAAE,mHAAA,qBAAqB,OAAA;AAAE,kGAAA,IAAI,OAAA;AAMtD,MAAM,gBAAgB,GAAG,EAAE,uBAAuB,EAAE,KAAK,EAAW,CAAC;AAErE;;;;;;GAMG;AACH,SAAwB,eAAe,CACrC,IAAY,EACZ,OAAgC;;IAEhC,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,MAAM,IAAI,SAAS,CAAC,iCAAiC,CAAC,CAAC;IACzD,CAAC;IAED,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO,IAAA,sBAAU,EACf,IAAA,yBAAS,EAAC,IAAI,EAAE,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,mCAAI,gBAAgB,CAAC,EACzD,OAAO,CACR,CAAC;AACJ,CAAC"}
|
package/lib/utilities.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export declare const PRESERVE_CUSTOM_ATTRIBUTES: boolean;
|
|
|
24
24
|
/**
|
|
25
25
|
* @see https://github.com/facebook/react/blob/cae635054e17a6f107a39d328649137b83f25972/packages/react-dom/src/client/validateDOMNesting.js#L213
|
|
26
26
|
*/
|
|
27
|
-
export declare const ELEMENTS_WITH_NO_TEXT_CHILDREN: Set<"
|
|
27
|
+
export declare const ELEMENTS_WITH_NO_TEXT_CHILDREN: Set<"tr" | "tbody" | "thead" | "tfoot" | "colgroup" | "table" | "head" | "html" | "frameset">;
|
|
28
28
|
/**
|
|
29
29
|
* Checks if the given node can contain text nodes
|
|
30
30
|
*
|
package/lib/utilities.js
CHANGED
|
@@ -6,9 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.returnFirstArg = exports.canTextBeChildOfNode = exports.ELEMENTS_WITH_NO_TEXT_CHILDREN = exports.PRESERVE_CUSTOM_ATTRIBUTES = void 0;
|
|
7
7
|
exports.isCustomComponent = isCustomComponent;
|
|
8
8
|
exports.setStyleProp = setStyleProp;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
const react_1 = require("react");
|
|
10
|
+
const style_to_js_1 = __importDefault(require("style-to-js"));
|
|
11
|
+
const RESERVED_SVG_MATHML_ELEMENTS = new Set([
|
|
12
12
|
'annotation-xml',
|
|
13
13
|
'color-profile',
|
|
14
14
|
'font-face',
|
|
@@ -40,7 +40,7 @@ function isCustomComponent(tagName, props) {
|
|
|
40
40
|
}
|
|
41
41
|
return true;
|
|
42
42
|
}
|
|
43
|
-
|
|
43
|
+
const styleOptions = {
|
|
44
44
|
reactCompat: true,
|
|
45
45
|
};
|
|
46
46
|
/**
|
|
@@ -89,9 +89,7 @@ exports.ELEMENTS_WITH_NO_TEXT_CHILDREN = new Set([
|
|
|
89
89
|
* @param node - Element node.
|
|
90
90
|
* @returns - Whether the node can contain text nodes.
|
|
91
91
|
*/
|
|
92
|
-
|
|
93
|
-
return !exports.ELEMENTS_WITH_NO_TEXT_CHILDREN.has(node.name);
|
|
94
|
-
};
|
|
92
|
+
const canTextBeChildOfNode = (node) => !exports.ELEMENTS_WITH_NO_TEXT_CHILDREN.has(node.name);
|
|
95
93
|
exports.canTextBeChildOfNode = canTextBeChildOfNode;
|
|
96
94
|
/**
|
|
97
95
|
* Returns the first argument as is.
|
|
@@ -99,6 +97,6 @@ exports.canTextBeChildOfNode = canTextBeChildOfNode;
|
|
|
99
97
|
* @param arg - The argument to be returned.
|
|
100
98
|
* @returns - The input argument `arg`.
|
|
101
99
|
*/
|
|
102
|
-
|
|
100
|
+
const returnFirstArg = (arg) => arg;
|
|
103
101
|
exports.returnFirstArg = returnFirstArg;
|
|
104
102
|
//# sourceMappingURL=utilities.js.map
|
package/lib/utilities.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utilities.js","sourceRoot":"","sources":["../src/utilities.ts"],"names":[],"mappings":";;;;;;AA6BA,8CAiBC;AAYD,oCAgBC;AAzED
|
|
1
|
+
{"version":3,"file":"utilities.js","sourceRoot":"","sources":["../src/utilities.ts"],"names":[],"mappings":";;;;;;AA6BA,8CAiBC;AAYD,oCAgBC;AAzED,iCAAgC;AAChC,8DAAoC;AAIpC,MAAM,4BAA4B,GAAG,IAAI,GAAG,CAAC;IAC3C,gBAAgB;IAChB,eAAe;IACf,WAAW;IACX,eAAe;IACf,eAAe;IACf,kBAAkB;IAClB,gBAAgB;IAChB,eAAe;CACP,CAAC,CAAC;AAKZ;;;;;;;;GAQG;AACH,SAAgB,iBAAiB,CAC/B,OAAe,EACf,KAAmC;IAEnC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAC3B,OAAO,OAAO,CAAC,KAAK,IAAI,OAAO,KAAK,CAAC,EAAE,KAAK,QAAQ,CAAC,CAAC;IACxD,CAAC;IAED,8CAA8C;IAC9C,4EAA4E;IAC5E,iFAAiF;IACjF,iFAAiF;IACjF,IAAI,4BAA4B,CAAC,GAAG,CAAC,OAAoC,CAAC,EAAE,CAAC;QAC3E,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,YAAY,GAAG;IACnB,WAAW,EAAE,IAAI;CACT,CAAC;AAEX;;;;;GAKG;AACH,SAAgB,YAAY,CAAC,KAAa,EAAE,KAAY;IACtD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO;IACT,CAAC;IAED,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;QAClB,KAAK,CAAC,KAAK,GAAG,EAAE,CAAC;QACjB,OAAO;IACT,CAAC;IAED,IAAI,CAAC;QACH,KAAK,CAAC,KAAK,GAAG,IAAA,qBAAS,EAAC,KAAK,EAAE,YAAY,CAAC,CAAC;QAC7C,6DAA6D;IAC/D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,KAAK,CAAC,KAAK,GAAG,EAAE,CAAC;IACnB,CAAC;AACH,CAAC;AAED;;GAEG;AACU,QAAA,0BAA0B,GAAG,MAAM,CAAC,eAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AAE9E;;GAEG;AACU,QAAA,8BAA8B,GAAG,IAAI,GAAG,CAAC;IACpD,IAAI;IACJ,OAAO;IACP,OAAO;IACP,OAAO;IACP,UAAU;IACV,OAAO;IACP,MAAM;IACN,MAAM;IACN,UAAU;CACF,CAAC,CAAC;AAKZ;;;;;GAKG;AACI,MAAM,oBAAoB,GAAG,CAAC,IAAa,EAAE,EAAE,CACpD,CAAC,sCAA8B,CAAC,GAAG,CAAC,IAAI,CAAC,IAAkC,CAAC,CAAC;AADlE,QAAA,oBAAoB,wBAC8C;AAE/E;;;;;GAKG;AACI,MAAM,cAAc,GAAG,CAAI,GAAM,EAAK,EAAE,CAAC,GAAG,CAAC;AAAvC,QAAA,cAAc,kBAAyB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "html-react-parser",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.1",
|
|
4
4
|
"description": "HTML to React parser.",
|
|
5
5
|
"author": "Mark <mark@remarkablemark.org> (https://remarkabl.org)",
|
|
6
6
|
"funding": [
|
|
@@ -60,48 +60,48 @@
|
|
|
60
60
|
"dom"
|
|
61
61
|
],
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"domhandler": "
|
|
64
|
-
"html-dom-parser": "
|
|
63
|
+
"domhandler": "6.0.1",
|
|
64
|
+
"html-dom-parser": "7.0.1",
|
|
65
65
|
"react-property": "2.0.2",
|
|
66
66
|
"style-to-js": "1.1.21"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"@commitlint/cli": "20.
|
|
70
|
-
"@commitlint/config-conventional": "20.
|
|
71
|
-
"@eslint/compat": "2.0.
|
|
72
|
-
"@eslint/eslintrc": "3.3.
|
|
73
|
-
"@eslint/js": "
|
|
74
|
-
"@rollup/plugin-commonjs": "29.0.
|
|
69
|
+
"@commitlint/cli": "20.5.0",
|
|
70
|
+
"@commitlint/config-conventional": "20.5.0",
|
|
71
|
+
"@eslint/compat": "2.0.4",
|
|
72
|
+
"@eslint/eslintrc": "3.3.5",
|
|
73
|
+
"@eslint/js": "10.0.1",
|
|
74
|
+
"@rollup/plugin-commonjs": "29.0.2",
|
|
75
75
|
"@rollup/plugin-node-resolve": "16.0.3",
|
|
76
|
-
"@rollup/plugin-terser": "0.
|
|
76
|
+
"@rollup/plugin-terser": "1.0.0",
|
|
77
77
|
"@rollup/plugin-typescript": "12.3.0",
|
|
78
|
-
"@size-limit/preset-big-lib": "12.0.
|
|
78
|
+
"@size-limit/preset-big-lib": "12.0.1",
|
|
79
79
|
"@types/benchmark": "2.1.5",
|
|
80
|
-
"@types/node": "25.2
|
|
81
|
-
"@types/react": "19.2.
|
|
80
|
+
"@types/node": "25.5.2",
|
|
81
|
+
"@types/react": "19.2.14",
|
|
82
82
|
"@types/react-dom": "19.2.3",
|
|
83
|
-
"@vitest/browser": "4.
|
|
84
|
-
"@vitest/browser-playwright": "4.
|
|
85
|
-
"@vitest/coverage-v8": "4.
|
|
83
|
+
"@vitest/browser": "4.1.3",
|
|
84
|
+
"@vitest/browser-playwright": "4.1.3",
|
|
85
|
+
"@vitest/coverage-v8": "4.1.3",
|
|
86
86
|
"benchmark": "2.1.4",
|
|
87
|
-
"eslint": "
|
|
87
|
+
"eslint": "10.2.0",
|
|
88
88
|
"eslint-plugin-prettier": "5.5.5",
|
|
89
|
-
"eslint-plugin-simple-import-sort": "
|
|
90
|
-
"eslint-plugin-tsdoc": "0.5.
|
|
91
|
-
"globals": "17.
|
|
89
|
+
"eslint-plugin-simple-import-sort": "13.0.0",
|
|
90
|
+
"eslint-plugin-tsdoc": "0.5.2",
|
|
91
|
+
"globals": "17.4.0",
|
|
92
92
|
"husky": "9.1.7",
|
|
93
|
-
"lint-staged": "16.
|
|
94
|
-
"playwright": "1.
|
|
95
|
-
"preact": "10.
|
|
96
|
-
"publint": "0.3.
|
|
93
|
+
"lint-staged": "16.4.0",
|
|
94
|
+
"playwright": "1.59.1",
|
|
95
|
+
"preact": "10.29.1",
|
|
96
|
+
"publint": "0.3.18",
|
|
97
97
|
"react": "19.2.4",
|
|
98
98
|
"react-dom": "19.2.4",
|
|
99
|
-
"rollup": "4.
|
|
100
|
-
"size-limit": "12.0.
|
|
99
|
+
"rollup": "4.60.1",
|
|
100
|
+
"size-limit": "12.0.1",
|
|
101
101
|
"ts-node": "10.9.2",
|
|
102
|
-
"typescript": "
|
|
103
|
-
"typescript-eslint": "8.
|
|
104
|
-
"vitest": "4.
|
|
102
|
+
"typescript": "6.0.2",
|
|
103
|
+
"typescript-eslint": "8.58.1",
|
|
104
|
+
"vitest": "4.1.3"
|
|
105
105
|
},
|
|
106
106
|
"peerDependencies": {
|
|
107
107
|
"@types/react": "0.14 || 15 || 16 || 17 || 18 || 19",
|