@junnyontop-pixel/neo-app 1.1.9 → 1.1.10
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 +38 -40
- package/package.json +1 -1
- package/src/App.js +2 -1
package/compiler/NeoParser.js
CHANGED
|
@@ -1,61 +1,59 @@
|
|
|
1
1
|
export class NeoParser {
|
|
2
2
|
static parse(source) {
|
|
3
3
|
let scriptContent = "";
|
|
4
|
+
// 1. 스크립트 영역 추출 (@Script { ... })
|
|
4
5
|
const scriptMatch = source.match(/@Script\s*\{([\s\S]*?)\}/);
|
|
5
6
|
if (scriptMatch) {
|
|
6
7
|
scriptContent = scriptMatch[1].trim();
|
|
7
8
|
}
|
|
8
9
|
|
|
9
|
-
// 태그 블록
|
|
10
|
-
|
|
10
|
+
// 2. 태그 블록 분석 로직
|
|
11
|
+
// 정규식 설명: @아이디:태그 { 내부내용 } 을 줄바꿈 상관없이([\\s\\S]*?) 추출
|
|
12
|
+
const tagRegex = /@(\w+):(\w+)\s*\{([\s\S]*?)\}/g;
|
|
13
|
+
let match;
|
|
11
14
|
let root = null;
|
|
12
15
|
const stack = [];
|
|
13
16
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (tagMatch) {
|
|
18
|
-
const node = {
|
|
19
|
-
id: tagMatch[1],
|
|
20
|
-
tag: tagMatch[2],
|
|
21
|
-
styles: {},
|
|
22
|
-
events: {},
|
|
23
|
-
innerHtml: "", // 파서 내부 저장용
|
|
24
|
-
children: []
|
|
25
|
-
};
|
|
17
|
+
// source 전체를 훑으며 태그 블록을 하나씩 찾습니다.
|
|
18
|
+
while ((match = tagRegex.exec(source)) !== null) {
|
|
19
|
+
const [_, id, tag, content] = match;
|
|
26
20
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
21
|
+
const node = {
|
|
22
|
+
id: id,
|
|
23
|
+
tag: tag,
|
|
24
|
+
styles: {},
|
|
25
|
+
events: {},
|
|
26
|
+
innerHtml: "",
|
|
27
|
+
children: []
|
|
28
|
+
};
|
|
32
29
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
// 💡 [핵심] 블록 내부(content)에서 줄바꿈 무시하고 속성 추출
|
|
31
|
+
// Innerhtml 추출 (i 플래그로 대소문자 무시)
|
|
32
|
+
const htmlMatch = content.match(/Innerhtml:\s*"(.*?)"/i);
|
|
33
|
+
if (htmlMatch) {
|
|
34
|
+
node.innerHtml = htmlMatch[1];
|
|
35
|
+
}
|
|
37
36
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
// Style 추출 (si 플래그로 줄바꿈 허용 및 대소문자 무시)
|
|
38
|
+
const styleMatch = content.match(/Style\((.*?)\)/si);
|
|
39
|
+
if (styleMatch && styleMatch[1]) {
|
|
40
|
+
node.styles = this.parseKV(styleMatch[1]);
|
|
41
|
+
}
|
|
43
42
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
stack.push(node);
|
|
43
|
+
// Event 추출 (si 플래그)
|
|
44
|
+
const eventMatch = content.match(/Event\((.*?)\)/si);
|
|
45
|
+
if (eventMatch && eventMatch[1]) {
|
|
46
|
+
node.events = this.parseKV(eventMatch[1]);
|
|
50
47
|
}
|
|
51
48
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
49
|
+
// 3. 계층 구조 형성 (단순화된 방식: 첫 번째가 root, 나머지는 root의 자식)
|
|
50
|
+
// ※ 중첩 구조가 깊어질 경우 스택 로직이 필요하지만, 현재 요구사항엔 이 방식이 가장 확실합니다.
|
|
51
|
+
if (!root) {
|
|
52
|
+
root = node;
|
|
53
|
+
} else {
|
|
54
|
+
root.children.push(node);
|
|
57
55
|
}
|
|
58
|
-
}
|
|
56
|
+
}
|
|
59
57
|
|
|
60
58
|
return { root, scriptContent };
|
|
61
59
|
}
|
package/package.json
CHANGED