@auto-wiz/dom 1.0.0 → 1.0.1

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.
@@ -190,6 +190,11 @@ export async function executeExtractStep(step) {
190
190
  else if (prop === "innerText") {
191
191
  extractedData = element.textContent?.trim() || "";
192
192
  }
193
+ else if (prop === "outerHTML") {
194
+ // XML 구조를 보기 좋게 포맷팅
195
+ const rawHtml = element.outerHTML;
196
+ extractedData = formatXml(rawHtml);
197
+ }
193
198
  else {
194
199
  extractedData = element.textContent?.trim() || "";
195
200
  }
@@ -283,3 +288,48 @@ export async function executeStep(step) {
283
288
  };
284
289
  }
285
290
  }
291
+ /**
292
+ * Simple XML formatter for pretty printing
293
+ */
294
+ function formatXml(xml) {
295
+ let formatted = "";
296
+ let indent = 0;
297
+ const tab = " ";
298
+ // 태그 사이의 공백 제거 및 줄바꿈 정규화
299
+ // 주석이나 CDATA 등은 고려하지 않은 단순 구현
300
+ xml = xml.replace(/>\s+</g, "><").trim();
301
+ // 태그 단위로 분리 - <tag>, </tag>, <tag ... />, text content
302
+ // 정규식 개선: 태그와 텍스트를 더 정확하게 분리
303
+ // <[^>]+> : 태그
304
+ // [^<]+ : 텍스트
305
+ const tags = xml.match(/<[^>]+>|[^<]+/g) || [];
306
+ tags.forEach(tag => {
307
+ // 닫는 태그 </... >
308
+ if (tag.match(/^<\//)) {
309
+ indent = Math.max(0, indent - 1);
310
+ formatted += "\n" + tab.repeat(indent) + tag;
311
+ }
312
+ // Self-closing 태그 <... /> 또는 <! ... > (Example: <!DOCTYPE>)
313
+ else if (tag.match(/^<.*\/>$/) || tag.match(/^<!/)) {
314
+ if (formatted.length > 0)
315
+ formatted += "\n";
316
+ formatted += tab.repeat(indent) + tag;
317
+ }
318
+ // 여는 태그 <... >
319
+ else if (tag.match(/^<.*>$/)) {
320
+ if (formatted.length > 0)
321
+ formatted += "\n";
322
+ formatted += tab.repeat(indent) + tag;
323
+ indent++;
324
+ }
325
+ // 텍스트 컨텐츠
326
+ else {
327
+ // 텍스트는 줄바꿈 없이 이어붙이되, 내용이 있는 경우만
328
+ const text = tag.trim();
329
+ if (text.length > 0) {
330
+ formatted += text;
331
+ }
332
+ }
333
+ });
334
+ return formatted.trim();
335
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@auto-wiz/dom",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "license": "MIT",
5
5
  "author": "JaeSang",
6
6
  "repository": {
@@ -10,6 +10,7 @@
10
10
  "publishConfig": {
11
11
  "access": "public"
12
12
  },
13
+ "type": "module",
13
14
  "files": [
14
15
  "dist"
15
16
  ],
@@ -18,12 +19,11 @@
18
19
  "exports": {
19
20
  ".": {
20
21
  "types": "./dist/index.d.ts",
21
- "import": "./dist/index.js",
22
- "require": "./dist/index.js"
22
+ "import": "./dist/index.js"
23
23
  }
24
24
  },
25
25
  "dependencies": {
26
- "@auto-wiz/core": "1.0.0"
26
+ "@auto-wiz/core": "1.0.1"
27
27
  },
28
28
  "devDependencies": {
29
29
  "typescript": "^5.0.0"