@junnyontop-pixel/neo-app 1.1.13 → 1.1.15

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.
@@ -5,7 +5,7 @@ export class NeoParser {
5
5
  if (scriptMatch) scriptContent = scriptMatch[1].trim();
6
6
 
7
7
  // 태그 블록만 추출하기 위해 스크립트 제외
8
- const cleanSource = source.replace(/@Script\s*\{[\s\S]*?\}/, "").trim();
8
+ const cleanSource = source.replace(/@Script\s*\{[\s\S]*?\}/, "").trim();
9
9
 
10
10
  const root = this.parseRecursive(cleanSource);
11
11
  return { root, scriptContent };
@@ -64,8 +64,19 @@ export class NeoParser {
64
64
  const childNode = this.parseRecursive(remainingText.substring(childMatch.index));
65
65
  if (childNode) {
66
66
  node.children.push(childNode);
67
- // 중복 탐색 방지를 위해 인덱스 건너뛰기 로직 생략 (현재 구조 최적화)
68
- break; // 예시용 단일 자식 우선 처리, 실제론 루프 최적화 필요
67
+
68
+ // 자식 노드의 지점을 찾아서 다음 검색 위치를 조정
69
+ let braceCount = 1;
70
+ let i = remainingText.indexOf('{', childMatch.index) + 1;
71
+
72
+ while (braceCount > 0 && i < remainingText.length) {
73
+ if (remainingText[i] === '{') braceCount++;
74
+ else if (remainingText[i] === '}') braceCount--;
75
+ i++;
76
+ }
77
+
78
+ // 정규식의 다음 검색 시작 위치를 자식 노드가 끝난 지점(i)으로 옮겨줘
79
+ childRegex.lastIndex = i;
69
80
  }
70
81
  }
71
82
 
package/compiler/index.js CHANGED
@@ -22,24 +22,30 @@ try {
22
22
 
23
23
  // 3. 코드 생성 함수 (재귀 구조)
24
24
  function generateCode(node, indent = " ") {
25
- const childrenCode = node.children
26
- .map(child => generateCode(child, indent + " "))
27
- .join(',\n');
28
-
29
- // 이벤트들을 객체 문자열로 변환
30
- const eventProps = Object.entries(node.events).map(([evt, action]) => {
31
- const propName = `on${evt.charAt(0).toUpperCase() + evt.slice(1)}`;
32
- // $count -> state.count로 치환
33
- let processedAction = action.replace(/\$(\w+)/g, 'state.$1');
34
- return `${propName}: () => { ${processedAction} }`;
35
- }).join(`,\n${indent} `);
36
-
37
- return `${indent}h('${node.tag}', {
38
- ${indent} id: '${node.id}',
39
- ${indent} style: ${JSON.stringify(node.styles)},
40
- ${indent} innerHTML: \`${node.innerHtml.replace(/\$(\w+)/g, '${state.$1}')}\`${eventProps ? ',\n' + indent + ' ' + eventProps : ''}
41
- ${indent}}, [${childrenCode ? '\n' + childrenCode + '\n' + indent : ''}])`;
42
- }
25
+
26
+ const textNode = node.innerHtml
27
+ ? `\`${node.innerHtml.replace(/\$(\w+)/g, '${state.$1}')}\``
28
+ : null;
29
+
30
+ const childrenCode = node.children
31
+ .map(child => generateCode(child, indent + " "))
32
+ .join(',\n');
33
+
34
+ const allChildren = [textNode, childrenCode].filter(Boolean).join(',\n');
35
+
36
+ // 이벤트들을 객체 문자열로 변환
37
+ const eventProps = Object.entries(node.events).map(([evt, action]) => {
38
+ const propName = `on${evt.charAt(0).toUpperCase() + evt.slice(1)}`;
39
+ // $count -> state.count로 치환
40
+ let processedAction = action.replace(/\$(\w+)/g, 'state.$1');
41
+ return `${propName}: () => { ${processedAction} }`;
42
+ }).join(`,\n${indent} `);
43
+
44
+ return `${indent}h('${node.tag}', {
45
+ ${indent} id: '${node.id}',
46
+ ${indent} style: ${JSON.stringify(node.styles)}${eventProps ? ',\n' + indent + ' ' + eventProps : ''}
47
+ ${indent}}, [${allChildren ? '\n' + allChildren + '\n' + indent : ''}])`;
48
+ }
43
49
 
44
50
  // render 함수 생성 부분
45
51
  const finalJS = `
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@junnyontop-pixel/neo-app",
3
- "version": "1.1.13",
3
+ "version": "1.1.15",
4
4
  "description": "나만의 커스텀 프레임워크 Neo",
5
5
  "main": "core/NeoCore.js",
6
6
  "type": "module",
package/src/App.js CHANGED
@@ -6,9 +6,10 @@ export default function render(state) {
6
6
  if (state.title === undefined) state.title = "hello, neo";
7
7
 
8
8
  return h('button', {
9
- id: 'Btn',
10
- style: {},
11
- innerHTML: `인사하기`,
9
+ id: 'Btn',
10
+ style: {},
12
11
  onClick: () => { sayHello( }
13
- }, []);
12
+ }, [
13
+ `인사하기`
14
+ ]);
14
15
  }