@junnyontop-pixel/neo-app 1.1.3 → 1.1.5
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 +63 -33
- package/package.json +3 -3
- package/src/App.js +2 -3
package/compiler/NeoParser.js
CHANGED
|
@@ -1,52 +1,82 @@
|
|
|
1
1
|
export class NeoParser {
|
|
2
|
-
static parse(
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const scriptMatch = code.match(/@Script\s*\{([\s\S]*?)\}(?=\s*@|$)/);
|
|
2
|
+
static parse(source) {
|
|
3
|
+
const lines = source.split('\n');
|
|
4
|
+
let root = null;
|
|
6
5
|
let scriptContent = "";
|
|
7
|
-
|
|
6
|
+
const stack = [];
|
|
7
|
+
|
|
8
|
+
// 1. 스크립트 영역 추출 (@Script { ... })
|
|
9
|
+
const scriptMatch = source.match(/@Script\s*\{([\s\S]*?)\}/);
|
|
8
10
|
if (scriptMatch) {
|
|
9
11
|
scriptContent = scriptMatch[1].trim();
|
|
10
|
-
// 만약 사용자가 적은 마지막 } 가 잘려 나갔다면 복구하거나,
|
|
11
|
-
// 원본에서 블록 전체를 가져오는 로직으로 보강
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
// 2.
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
// 2. 태그 파싱
|
|
15
|
+
const tagRegex = /@(\w+):(\w+)\s*\{/g;
|
|
16
|
+
let match;
|
|
17
|
+
const tags = [];
|
|
18
|
+
|
|
19
|
+
// 소스에서 태그 블록들을 찾아내기 위한 단순화된 로직
|
|
20
|
+
const tokens = source.split(/(@\w+:\w+\s*\{)/).filter(t => t.trim());
|
|
21
21
|
|
|
22
22
|
tokens.forEach(token => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
const tagMatch = token.match(/@(\w+):(\w+)\s*\{/);
|
|
24
|
+
|
|
25
|
+
if (tagMatch) {
|
|
26
|
+
const node = {
|
|
27
|
+
id: tagMatch[1],
|
|
28
|
+
tag: tagMatch[2],
|
|
29
|
+
styles: {},
|
|
30
|
+
events: {},
|
|
31
|
+
innerHtml: "",
|
|
32
|
+
children: []
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// Style 추출 (안전 장치 추가)
|
|
36
|
+
const styleMatch = token.match(/Style\((.*?)\)/s);
|
|
37
|
+
if (styleMatch && styleMatch[1]) {
|
|
38
|
+
node.styles = this.parseKV(styleMatch[1]);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Event 추출 (안전 장치 추가)
|
|
42
|
+
const eventMatch = token.match(/Event\((.*?)\)/s);
|
|
43
|
+
if (eventMatch && eventMatch[1]) {
|
|
44
|
+
node.events = this.parseKV(eventMatch[1]);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Innerhtml 추출
|
|
48
|
+
const htmlMatch = token.match(/Innerhtml:\s*"(.*?)"/);
|
|
49
|
+
if (htmlMatch) {
|
|
50
|
+
node.innerHtml = htmlMatch[1];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (!root) {
|
|
54
|
+
root = node;
|
|
55
|
+
} else {
|
|
56
|
+
stack[stack.length - 1].children.push(node);
|
|
57
|
+
}
|
|
28
58
|
stack.push(node);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
stack[stack.length - 1].events = this.parseKV(token.match(/Event\((.*?)\)/)[1]);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (token.includes('}')) {
|
|
62
|
+
const closeCount = (token.match(/\}/g) || []).length;
|
|
63
|
+
for (let i = 0; i < closeCount; i++) {
|
|
64
|
+
if (stack.length > 0) stack.pop();
|
|
65
|
+
}
|
|
37
66
|
}
|
|
38
67
|
});
|
|
39
68
|
|
|
40
69
|
return { root, scriptContent };
|
|
41
70
|
}
|
|
42
71
|
|
|
43
|
-
static parseKV(
|
|
72
|
+
static parseKV(kvString) {
|
|
73
|
+
if (!kvString || !kvString.trim()) return {};
|
|
44
74
|
const obj = {};
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (
|
|
48
|
-
const
|
|
49
|
-
obj[
|
|
75
|
+
const pairs = kvString.split(';');
|
|
76
|
+
pairs.forEach(pair => {
|
|
77
|
+
if (pair.includes(':')) {
|
|
78
|
+
const [key, value] = pair.split(':').map(s => s.trim());
|
|
79
|
+
if (key && value) obj[key] = value;
|
|
50
80
|
}
|
|
51
81
|
});
|
|
52
82
|
return obj;
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@junnyontop-pixel/neo-app",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
4
4
|
"description": "나만의 커스텀 프레임워크 Neo",
|
|
5
5
|
"main": "core/NeoCore.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|
|
8
|
-
"neoc": "
|
|
9
|
-
"neoc-init": "
|
|
8
|
+
"neoc": "compiler/index.js",
|
|
9
|
+
"neoc-init": "scripts/init.js"
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
12
|
"compiler",
|
package/src/App.js
CHANGED
|
@@ -4,13 +4,12 @@ import { h } from '@junnyontop-pixel/neo-app/core/NeoCore.js';
|
|
|
4
4
|
|
|
5
5
|
// [User Script]
|
|
6
6
|
function sayHello() {
|
|
7
|
-
alert("안녕하세요!");
|
|
8
|
-
}
|
|
7
|
+
alert("안녕하세요!");
|
|
9
8
|
|
|
10
9
|
export default function render(state) {
|
|
11
10
|
return h('button', {
|
|
12
11
|
id: 'Btn',
|
|
13
12
|
style: {},
|
|
14
|
-
innerHtml:
|
|
13
|
+
innerHtml: ``
|
|
15
14
|
}, []);
|
|
16
15
|
}
|