@junnyontop-pixel/neo-app 1.1.16 → 1.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/compiler/NeoParser.js +9 -3
- package/compiler/index.js +9 -2
- package/core/NeoCore.js +7 -0
- package/package.json +1 -1
- package/src/App.js +1 -1
package/compiler/NeoParser.js
CHANGED
|
@@ -22,6 +22,7 @@ export class NeoParser {
|
|
|
22
22
|
tag: match[2],
|
|
23
23
|
styles: {},
|
|
24
24
|
events: {},
|
|
25
|
+
props: {},
|
|
25
26
|
innerHtml: "",
|
|
26
27
|
children: []
|
|
27
28
|
};
|
|
@@ -39,21 +40,26 @@ export class NeoParser {
|
|
|
39
40
|
|
|
40
41
|
const blockContent = text.substring(startIndex, endIndex - 1);
|
|
41
42
|
|
|
43
|
+
const contentWithoutChildren = blockContent.replace(/@\w+:\w+\s*\{[\s\S]*?\}/g, "");
|
|
44
|
+
|
|
42
45
|
// 1. 블록 내부에서 속성 추출 (Innerhtml, Style, Event)
|
|
43
46
|
// 줄바꿈과 대소문자를 무시하고 " " 사이의 값을 정확히 가져옴
|
|
44
|
-
const htmlMatch = blockContent.match(/
|
|
47
|
+
const htmlMatch = blockContent.match(/innerHTML:\s*"([\s\S]*?)"/i);
|
|
45
48
|
if (htmlMatch) node.innerHtml = htmlMatch[1].trim();
|
|
46
49
|
|
|
47
50
|
const styleMatch = blockContent.match(/Style\(([\s\S]*?)\)/i);
|
|
48
51
|
if (styleMatch) node.styles = this.parseKV(styleMatch[1]);
|
|
49
52
|
|
|
50
|
-
const eventMatch =
|
|
53
|
+
const eventMatch = contentWithoutChildren.match(/Event\(([\s\S]*?)\)/i);
|
|
51
54
|
if (eventMatch) node.events = this.parseKV(eventMatch[1]);
|
|
52
55
|
|
|
56
|
+
const propsMatch = blockContent.match(/Props\(([\s\S]*?)\)/i);
|
|
57
|
+
if (propsMatch) node.props = this.parseKV(propsMatch[1]);
|
|
58
|
+
|
|
53
59
|
// 2. 자식 노드 재귀적 탐색
|
|
54
60
|
// 본인의 속성 정의 부분을 제외한 나머지 텍스트에서 자식 탐색
|
|
55
61
|
const remainingText = blockContent
|
|
56
|
-
.replace(/
|
|
62
|
+
.replace(/innerHTML:\s*"[\s\S]*?"/i, "")
|
|
57
63
|
.replace(/Style\(.*?\)/si, "")
|
|
58
64
|
.replace(/Event\(.*?\)/si, "");
|
|
59
65
|
|
package/compiler/index.js
CHANGED
|
@@ -41,9 +41,16 @@ try {
|
|
|
41
41
|
return `${propName}: () => { ${processedAction} }`;
|
|
42
42
|
}).join(`,\n${indent} `);
|
|
43
43
|
|
|
44
|
+
const mergedProps = {
|
|
45
|
+
id: node.id,
|
|
46
|
+
...node.props
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const propsContent = JSON.stringify(mergedProps).slice(1, -1);
|
|
50
|
+
|
|
44
51
|
return `${indent}h('${node.tag}', {
|
|
45
|
-
${indent}
|
|
46
|
-
${indent}
|
|
52
|
+
${indent} style: ${JSON.stringify(node.styles)},
|
|
53
|
+
${indent} ${propsContent}${eventProps ? ',\n' + indent + ' ' + eventProps : ''}
|
|
47
54
|
${indent}}, [${allChildren ? '\n' + allChildren + '\n' + indent : ''}])`;
|
|
48
55
|
}
|
|
49
56
|
|
package/core/NeoCore.js
CHANGED
|
@@ -33,6 +33,13 @@ export function h(tag, props, children = []) {
|
|
|
33
33
|
// }
|
|
34
34
|
|
|
35
35
|
Object.keys(props).forEach(key => {
|
|
36
|
+
const reserved = ['id', 'style', 'innerHTML', 'innerHtml'];
|
|
37
|
+
|
|
38
|
+
// 이벤트도 아니고, 예약어도 아닌 'type', 'placeholder' 같은 애들이라면?
|
|
39
|
+
if (!reserved.includes(key) && !key.startsWith('on')) {
|
|
40
|
+
el.setAttribute(key, props[key]);
|
|
41
|
+
}
|
|
42
|
+
|
|
36
43
|
if (key.startsWith('on') && typeof props[key] === 'function') {
|
|
37
44
|
const eventType = key.toLowerCase().substring(2);
|
|
38
45
|
el.addEventListener(eventType, props[key]);
|
package/package.json
CHANGED