jtsx-loader 0.1.8 → 0.1.9
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/factory/jsxFactory.js +9 -18
- package/factory/utils.js +36 -0
- package/package.json +5 -5
package/factory/jsxFactory.js
CHANGED
|
@@ -14,10 +14,10 @@ let config = {
|
|
|
14
14
|
|
|
15
15
|
// Какие аттрибуты должны быть заменены
|
|
16
16
|
const AttributeMapper = (val) => ({
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
tabIndex: 'tabindex',
|
|
18
|
+
className: 'class',
|
|
19
|
+
readOnly: 'readonly',
|
|
20
|
+
}[val] || val);
|
|
21
21
|
|
|
22
22
|
const voidElements = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'source', 'track', 'wbr'];
|
|
23
23
|
const isVoidElt = (tagName) => voidElements.includes(tagName);
|
|
@@ -119,25 +119,16 @@ const createTag = (tagName, attrs, children) => {
|
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
const _jsx = (tagName, attrs, ...children) => {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
return tagName({ ...attrs, children: children.length === 1 ? children[0] : children });
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
const tag = createTag(tagName, attrs, children);
|
|
128
|
-
return tag;
|
|
129
|
-
} catch (error) {
|
|
130
|
-
throw new Error(error);
|
|
122
|
+
if (typeof tagName === 'function') {
|
|
123
|
+
return tagName({ ...attrs, children: children.length === 1 ? children[0] : children });
|
|
131
124
|
}
|
|
125
|
+
|
|
126
|
+
const tag = createTag(tagName, attrs, children);
|
|
127
|
+
return tag;
|
|
132
128
|
}
|
|
133
129
|
|
|
134
130
|
const _jsxFragment = ({ children, ...attrs }) => {
|
|
135
131
|
return children.join(' ');
|
|
136
132
|
}
|
|
137
133
|
|
|
138
|
-
/* export {
|
|
139
|
-
DOMcreateElement as h,
|
|
140
|
-
DOMcreateFragment as Fragment,
|
|
141
|
-
} */
|
|
142
|
-
|
|
143
134
|
export { _jsx, _jsxFragment, _jsxUtils }
|
package/factory/utils.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const errorToObject = (error) => {
|
|
2
|
+
const obj = {};
|
|
3
|
+
for (const key of Object.getOwnPropertyNames(error)) {
|
|
4
|
+
obj[key] = error[key];
|
|
5
|
+
}
|
|
6
|
+
return obj;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const errorStackToArray = (error) => {
|
|
10
|
+
const stack = error.stack;
|
|
11
|
+
const lines = stack.split('\n');
|
|
12
|
+
|
|
13
|
+
return lines.map(line => {
|
|
14
|
+
const match = line.match(/at (.*) \((.*):(\d+):(\d+)\)/);
|
|
15
|
+
if (match) {
|
|
16
|
+
const functionName = match[1];
|
|
17
|
+
const filePath = match[2];
|
|
18
|
+
const lineNumber = match[3];
|
|
19
|
+
const columnNumber = match[4];
|
|
20
|
+
|
|
21
|
+
// console.log(`Function: ${functionName}, File: ${filePath}, Line: ${lineNumber}, Column: ${columnNumber}`);
|
|
22
|
+
return {
|
|
23
|
+
function: functionName,
|
|
24
|
+
file: filePath,
|
|
25
|
+
fileWithLine: `${filePath}:${lineNumber}:${columnNumber}`,
|
|
26
|
+
line: lineNumber,
|
|
27
|
+
column: columnNumber
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}).filter(v => v);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export {
|
|
34
|
+
errorStackToArray,
|
|
35
|
+
errorToObject
|
|
36
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jtsx-loader",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"main": "./loader/register.mjs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"imports": {
|
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
"url": "git+https://github.com/dergachevm/jtsx-loader"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"esbuild": "^0.25.
|
|
32
|
+
"esbuild": "^0.25.5"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"express": "^
|
|
36
|
-
"htmlfy": "^0.
|
|
37
|
-
"nodemon": "^3.1.
|
|
35
|
+
"express": "^5.1.0",
|
|
36
|
+
"htmlfy": "^0.7.5",
|
|
37
|
+
"nodemon": "^3.1.10"
|
|
38
38
|
}
|
|
39
39
|
}
|