lone-format 0.12.1 → 0.13.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.
Files changed (32) hide show
  1. package/dist/_chunks/_plugin-vue_export-helper-CHgC5LLL.js +9 -0
  2. package/dist/_chunks/index-13rwh2MK.js +788 -0
  3. package/dist/_chunks/index-DfjCsqDT.js +1005 -0
  4. package/dist/_chunks/index-DvNM7Tl4.js +1784 -0
  5. package/dist/components/JsonFormat/JsonNode.vue.d.ts +29 -0
  6. package/dist/components/JsonFormat/index.d.ts +2 -0
  7. package/dist/components/JsonFormat/index.js +4 -0
  8. package/dist/components/JsonFormat/index.vue.d.ts +50 -0
  9. package/dist/components/JsonFormat/themes.d.ts +29 -0
  10. package/dist/components/JsonFormat/types.d.ts +96 -0
  11. package/dist/components/SqlFormat/SqlClauseNode.vue.d.ts +13 -0
  12. package/dist/components/SqlFormat/index.d.ts +5 -0
  13. package/dist/components/SqlFormat/index.js +5 -0
  14. package/dist/components/SqlFormat/index.vue.d.ts +43 -0
  15. package/dist/components/SqlFormat/parser.d.ts +34 -0
  16. package/dist/components/SqlFormat/themes.d.ts +33 -0
  17. package/dist/components/SqlFormat/types.d.ts +99 -0
  18. package/dist/components/XmlFormat/XmlNode.vue.d.ts +37 -0
  19. package/dist/components/XmlFormat/index.d.ts +7 -0
  20. package/dist/components/XmlFormat/index.js +27 -0
  21. package/dist/components/XmlFormat/index.vue.d.ts +57 -0
  22. package/dist/components/XmlFormat/parser.d.ts +93 -0
  23. package/dist/components/XmlFormat/themes.d.ts +29 -0
  24. package/dist/components/XmlFormat/types.d.ts +113 -0
  25. package/dist/components/index.d.ts +6 -0
  26. package/dist/index.d.ts +6 -1
  27. package/dist/lone-format.css +1 -1
  28. package/dist/lone-format.js +13 -31862
  29. package/dist/lone-format.umd.cjs +53 -49
  30. package/dist/types/components.d.ts +1 -0
  31. package/dist/types/index.d.ts +6 -0
  32. package/package.json +8 -3
@@ -0,0 +1,29 @@
1
+ import { ThemeConfig } from './types';
2
+ import { DefineComponent, ComponentOptionsMixin, PublicProps, ComponentProvideOptions } from 'vue';
3
+ interface Props {
4
+ value: any;
5
+ keyName: string;
6
+ level: number;
7
+ path?: string;
8
+ expanded: Set<string>;
9
+ isLast?: boolean;
10
+ theme: ThemeConfig;
11
+ }
12
+ declare const _default: DefineComponent<Props, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
13
+ "update:value": (path: string, value: any) => any;
14
+ "toggle-expand": (path: string) => any;
15
+ copy: (value: any) => any;
16
+ "update:key": (oldPath: string, newKey: string) => any;
17
+ }, string, PublicProps, Readonly<Props> & Readonly<{
18
+ "onUpdate:value"?: ((path: string, value: any) => any) | undefined;
19
+ "onToggle-expand"?: ((path: string) => any) | undefined;
20
+ onCopy?: ((value: any) => any) | undefined;
21
+ "onUpdate:key"?: ((oldPath: string, newKey: string) => any) | undefined;
22
+ }>, {
23
+ path: string;
24
+ isLast: boolean;
25
+ }, {}, {}, {}, string, ComponentProvideOptions, false, {
26
+ keyRef: HTMLSpanElement;
27
+ valueRef: HTMLSpanElement;
28
+ }, HTMLDivElement>;
29
+ export default _default;
@@ -0,0 +1,2 @@
1
+ export { default } from './index.vue';
2
+ export * from './types';
@@ -0,0 +1,4 @@
1
+ import { J as f } from "../../_chunks/index-13rwh2MK.js";
2
+ export {
3
+ f as default
4
+ };
@@ -0,0 +1,50 @@
1
+ import { FilterConfig, ThemeType } from './types';
2
+ import { DefineComponent, ComponentOptionsMixin, PublicProps, ComponentProvideOptions } from 'vue';
3
+ interface Props {
4
+ modelValue: string;
5
+ readonly?: boolean;
6
+ maxDepth?: number;
7
+ theme?: ThemeType;
8
+ }
9
+ declare const _default: DefineComponent<Props, {
10
+ copyJson: () => Promise<void>;
11
+ compressSource: () => void;
12
+ expandAll: () => void;
13
+ collapseAll: () => void;
14
+ toggleExpand: (path: string) => void;
15
+ updateValue: (path: string, newValue: any) => void;
16
+ updateKey: (oldPath: string, newKey: string) => void;
17
+ filter: (config: FilterConfig) => void;
18
+ clearFilter: () => void;
19
+ sortKeys: () => void;
20
+ clearSortKeys: () => void;
21
+ isSorted: () => boolean;
22
+ isValidJson: () => boolean;
23
+ getParsedJson: () => any;
24
+ getFilteredJson: () => any;
25
+ getExpandedNodes: () => Set<string> & Omit<Set<string>, keyof Set<any>>;
26
+ getParseError: () => string;
27
+ getFilterError: () => string;
28
+ parseJson: (jsonString: string) => void;
29
+ copyValue: (value: any) => Promise<void>;
30
+ }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
31
+ "update:modelValue": (value: string) => any;
32
+ "copy-success": (value: string) => any;
33
+ "copy-error": (error: Error) => any;
34
+ "expand-all": () => any;
35
+ "collapse-all": () => any;
36
+ compress: (value: string) => any;
37
+ }, string, PublicProps, Readonly<Props> & Readonly<{
38
+ "onUpdate:modelValue"?: ((value: string) => any) | undefined;
39
+ "onCopy-success"?: ((value: string) => any) | undefined;
40
+ "onCopy-error"?: ((error: Error) => any) | undefined;
41
+ "onExpand-all"?: (() => any) | undefined;
42
+ "onCollapse-all"?: (() => any) | undefined;
43
+ onCompress?: ((value: string) => any) | undefined;
44
+ }>, {
45
+ theme: ThemeType;
46
+ modelValue: string;
47
+ readonly: boolean;
48
+ maxDepth: number;
49
+ }, {}, {}, {}, string, ComponentProvideOptions, false, {}, HTMLDivElement>;
50
+ export default _default;
@@ -0,0 +1,29 @@
1
+ import { ThemeConfig, ThemeType } from './types';
2
+ /**
3
+ * GitHub Light 主题配置
4
+ */
5
+ export declare const githubLightTheme: ThemeConfig;
6
+ /**
7
+ * GitHub Dark 主题配置
8
+ */
9
+ export declare const githubDarkTheme: ThemeConfig;
10
+ /**
11
+ * Min Light 主题配置 - 极简浅色主题
12
+ */
13
+ export declare const minLightTheme: ThemeConfig;
14
+ /**
15
+ * Slack Ochin 主题配置 - 温暖橙色主题
16
+ */
17
+ export declare const slackOchinTheme: ThemeConfig;
18
+ /**
19
+ * 预定义主题集合
20
+ */
21
+ export declare const themes: Record<ThemeType, ThemeConfig>;
22
+ /**
23
+ * 获取主题配置
24
+ */
25
+ export declare function getTheme(theme?: ThemeType): ThemeConfig;
26
+ /**
27
+ * 获取所有可用主题名称
28
+ */
29
+ export declare function getAvailableThemes(): ThemeType[];
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Filter 类型枚举
3
+ */
4
+ export type FilterType = 'jsonpath' | 'js';
5
+ /**
6
+ * 主题类型枚举
7
+ */
8
+ export type ThemeType = 'github-light' | 'github-dark' | 'min-light' | 'slack-ochin';
9
+ /**
10
+ * Filter 配置接口
11
+ */
12
+ export interface FilterConfig {
13
+ type: FilterType;
14
+ expression: string;
15
+ }
16
+ /**
17
+ * 主题配置接口
18
+ */
19
+ export interface ThemeConfig {
20
+ name: ThemeType;
21
+ colors: {
22
+ background: string;
23
+ surfaceBackground: string;
24
+ border: string;
25
+ text: string;
26
+ textSecondary: string;
27
+ buttonBackground: string;
28
+ buttonBackgroundHover: string;
29
+ buttonBorder: string;
30
+ buttonText: string;
31
+ buttonPrimary: string;
32
+ buttonPrimaryHover: string;
33
+ success: string;
34
+ successBackground: string;
35
+ error: string;
36
+ errorBackground: string;
37
+ syntaxString: string;
38
+ syntaxNumber: string;
39
+ syntaxBoolean: string;
40
+ syntaxNull: string;
41
+ syntaxKey: string;
42
+ syntaxBracket: string;
43
+ hoverBackground: string;
44
+ selectionBackground: string;
45
+ collapsedBackground: string;
46
+ collapsedBackgroundHover: string;
47
+ collapsedText: string;
48
+ indentLine: string;
49
+ };
50
+ }
51
+ /**
52
+ * JsonFormat 组件暴露的方法接口
53
+ */
54
+ export interface JsonFormatExposed {
55
+ copyJson: () => Promise<void>;
56
+ expandAll: () => void;
57
+ collapseAll: () => void;
58
+ toggleExpand: (path: string) => void;
59
+ updateValue: (path: string, newValue: any) => void;
60
+ updateKey: (oldPath: string, newKey: string) => void;
61
+ filter: (config: FilterConfig) => void;
62
+ clearFilter: () => void;
63
+ sortKeys: () => void;
64
+ clearSortKeys: () => void;
65
+ isSorted: () => boolean;
66
+ isValidJson: () => boolean;
67
+ getParsedJson: () => any;
68
+ getFilteredJson: () => any;
69
+ getExpandedNodes: () => Set<string>;
70
+ getParseError: () => string;
71
+ getFilterError: () => string;
72
+ parseJson: (jsonString: string) => void;
73
+ copyValue: (value: any) => Promise<void>;
74
+ }
75
+ /**
76
+ * JsonFormat 组件的 Props 接口
77
+ */
78
+ export interface JsonFormatProps {
79
+ modelValue: string;
80
+ readonly?: boolean;
81
+ maxDepth?: number;
82
+ showToolbar?: boolean;
83
+ theme?: ThemeType;
84
+ }
85
+ /**
86
+ * JsonFormat 组件的事件接口
87
+ */
88
+ export interface JsonFormatEmits {
89
+ 'update:modelValue': [value: string];
90
+ 'copy-success': [value: string];
91
+ 'copy-error': [error: Error];
92
+ 'expand-all': [];
93
+ 'collapse-all': [];
94
+ 'filter-success': [filteredData: any];
95
+ 'filter-error': [error: Error];
96
+ }
@@ -0,0 +1,13 @@
1
+ import { SqlClause, ThemeConfig } from './types';
2
+ import { DefineComponent, ComponentOptionsMixin, PublicProps, ComponentProvideOptions } from 'vue';
3
+ interface Props {
4
+ clause: SqlClause;
5
+ expandedClauses: Set<string>;
6
+ theme: ThemeConfig;
7
+ }
8
+ declare const _default: DefineComponent<Props, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
9
+ toggle: (path: string) => any;
10
+ }, string, PublicProps, Readonly<Props> & Readonly<{
11
+ onToggle?: ((path: string) => any) | undefined;
12
+ }>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, HTMLDivElement>;
13
+ export default _default;
@@ -0,0 +1,5 @@
1
+ import { default as SqlFormat } from './index.vue';
2
+ import { SqlDialect, ThemeType, SqlFormatOptions, SqlFormatExposed } from './types';
3
+ export { SqlFormat };
4
+ export type { SqlDialect, ThemeType, SqlFormatOptions, SqlFormatExposed };
5
+ export default SqlFormat;
@@ -0,0 +1,5 @@
1
+ import { S as o } from "../../_chunks/index-DfjCsqDT.js";
2
+ export {
3
+ o as SqlFormat,
4
+ o as default
5
+ };
@@ -0,0 +1,43 @@
1
+ import { ThemeType, SqlDialect } from './types';
2
+ import { DefineComponent, ComponentOptionsMixin, PublicProps, ComponentProvideOptions } from 'vue';
3
+ interface Props {
4
+ modelValue: string;
5
+ readonly?: boolean;
6
+ theme?: ThemeType;
7
+ dialect?: SqlDialect;
8
+ tabWidth?: number;
9
+ }
10
+ declare const _default: DefineComponent<Props, {
11
+ copySql: () => Promise<void>;
12
+ formatSource: () => void;
13
+ compressSource: () => void;
14
+ expandAll: () => void;
15
+ collapseAll: () => void;
16
+ toggleExpand: (path: string) => void;
17
+ isValidSql: () => boolean;
18
+ getParsedSql: () => null;
19
+ getParseError: () => string;
20
+ }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
21
+ "update:modelValue": (value: string) => any;
22
+ "copy-success": (value: string) => any;
23
+ "copy-error": (error: Error) => any;
24
+ "expand-all": () => any;
25
+ "collapse-all": () => any;
26
+ compress: (value: string) => any;
27
+ format: (value: string) => any;
28
+ }, string, PublicProps, Readonly<Props> & Readonly<{
29
+ "onUpdate:modelValue"?: ((value: string) => any) | undefined;
30
+ "onCopy-success"?: ((value: string) => any) | undefined;
31
+ "onCopy-error"?: ((error: Error) => any) | undefined;
32
+ "onExpand-all"?: (() => any) | undefined;
33
+ "onCollapse-all"?: (() => any) | undefined;
34
+ onCompress?: ((value: string) => any) | undefined;
35
+ onFormat?: ((value: string) => any) | undefined;
36
+ }>, {
37
+ theme: ThemeType;
38
+ modelValue: string;
39
+ readonly: boolean;
40
+ tabWidth: number;
41
+ dialect: SqlDialect;
42
+ }, {}, {}, {}, string, ComponentProvideOptions, false, {}, HTMLDivElement>;
43
+ export default _default;
@@ -0,0 +1,34 @@
1
+ import { ParsedSql, SqlFormatOptions } from './types';
2
+ /**
3
+ * 验证 SQL 字符串
4
+ * 使用 sql-formatter 进行验证,同时保留基础检查
5
+ */
6
+ export declare const validateSql: (sqlString: string) => {
7
+ valid: boolean;
8
+ error?: string;
9
+ };
10
+ /**
11
+ * 格式化 SQL 字符串
12
+ * 使用 sql-formatter 进行格式化
13
+ */
14
+ export declare const formatSql: (sqlString: string, options?: SqlFormatOptions) => string;
15
+ /**
16
+ * 压缩 SQL(移除多余空格和换行)
17
+ */
18
+ export declare const compressSql: (sqlString: string) => string;
19
+ /**
20
+ * 解析 SQL 为子句结构
21
+ * 使用 sql-formatter 格式化后进行解析;子查询内部递归拆分为嵌套子句。
22
+ */
23
+ export declare const parseSqlClauses: (sqlString: string) => ParsedSql;
24
+ /**
25
+ * SQL 语法 Token 类型
26
+ */
27
+ export interface SqlToken {
28
+ type: 'keyword' | 'function' | 'string' | 'number' | 'comment' | 'operator' | 'identifier' | 'punctuation' | 'whitespace';
29
+ value: string;
30
+ }
31
+ /**
32
+ * 高亮 SQL 语法(返回带有标记的 token 数组)
33
+ */
34
+ export declare const tokenizeSql: (sqlString: string) => SqlToken[];
@@ -0,0 +1,33 @@
1
+ import { ThemeConfig, ThemeType } from './types';
2
+ /**
3
+ * GitHub Light 主题
4
+ */
5
+ declare const githubLight: ThemeConfig;
6
+ /**
7
+ * GitHub Dark 主题
8
+ */
9
+ declare const githubDark: ThemeConfig;
10
+ /**
11
+ * Min Light 主题 - 与 JsonFormat 保持一致
12
+ */
13
+ declare const minLight: ThemeConfig;
14
+ /**
15
+ * Slack Ochin 主题
16
+ */
17
+ declare const slackOchin: ThemeConfig;
18
+ /**
19
+ * 主题映射表
20
+ */
21
+ declare const themes: Record<ThemeType, ThemeConfig>;
22
+ /**
23
+ * 获取主题配置
24
+ */
25
+ export declare const getTheme: (themeName: ThemeType) => ThemeConfig;
26
+ /**
27
+ * 获取所有主题名称
28
+ */
29
+ export declare const getThemeNames: () => ThemeType[];
30
+ /**
31
+ * 导出所有主题
32
+ */
33
+ export { githubLight, githubDark, minLight, slackOchin, themes };
@@ -0,0 +1,99 @@
1
+ /**
2
+ * SQL 方言类型枚举
3
+ */
4
+ export type SqlDialect = 'mysql' | 'postgresql' | 'sqlite' | 'sql' | 'plsql' | 'tsql';
5
+ /**
6
+ * 主题类型枚举(复用现有主题)
7
+ */
8
+ export type ThemeType = 'github-light' | 'github-dark' | 'min-light' | 'slack-ochin';
9
+ /**
10
+ * SQL 子句类型
11
+ */
12
+ export type SqlClauseType = 'SELECT' | 'FROM' | 'JOIN' | 'WHERE' | 'GROUP BY' | 'HAVING' | 'ORDER BY' | 'LIMIT' | 'INSERT' | 'INSERT INTO' | 'VALUES' | 'VALUE_TUPLE' | 'UPDATE' | 'SET' | 'DELETE' | 'CREATE' | 'ALTER' | 'DROP' | 'UNKNOWN';
13
+ /**
14
+ * 子句正文片段:要么是普通文本(括号、别名等),要么是嵌套的子句(子查询内部)
15
+ */
16
+ export type SqlBodySegment = {
17
+ kind: 'text';
18
+ text: string;
19
+ } | {
20
+ kind: 'clause';
21
+ clause: SqlClause;
22
+ };
23
+ /**
24
+ * SQL 子句节点接口
25
+ */
26
+ export interface SqlClause {
27
+ type: SqlClauseType;
28
+ content: string;
29
+ raw: string;
30
+ collapsible: boolean;
31
+ path?: string;
32
+ body?: SqlBodySegment[];
33
+ }
34
+ /**
35
+ * 主题配置接口
36
+ */
37
+ export interface ThemeConfig {
38
+ name: ThemeType;
39
+ colors: {
40
+ background: string;
41
+ surfaceBackground: string;
42
+ hoverBackground: string;
43
+ border: string;
44
+ text: string;
45
+ textSecondary: string;
46
+ buttonBackground: string;
47
+ buttonBackgroundHover: string;
48
+ buttonBorder: string;
49
+ buttonText: string;
50
+ buttonPrimary: string;
51
+ buttonPrimaryHover: string;
52
+ success: string;
53
+ successBackground: string;
54
+ error: string;
55
+ errorBackground: string;
56
+ sqlKeyword: string;
57
+ sqlFunction: string;
58
+ sqlString: string;
59
+ sqlNumber: string;
60
+ sqlComment: string;
61
+ sqlOperator: string;
62
+ sqlIdentifier: string;
63
+ sqlPunctuation: string;
64
+ collapsedBackground: string;
65
+ collapsedText: string;
66
+ indentLine: string;
67
+ };
68
+ }
69
+ /**
70
+ * SQL 格式化选项
71
+ */
72
+ export interface SqlFormatOptions {
73
+ dialect?: SqlDialect;
74
+ tabWidth?: number;
75
+ keywordCase?: 'upper' | 'lower' | 'preserve';
76
+ useTabs?: boolean;
77
+ linesBetweenQueries?: number;
78
+ }
79
+ /**
80
+ * SQL 格式化组件暴露的方法
81
+ */
82
+ export interface SqlFormatExposed {
83
+ copySql: () => Promise<void>;
84
+ formatSource: () => void;
85
+ compressSource: () => void;
86
+ expandAll: () => void;
87
+ collapseAll: () => void;
88
+ toggleExpand: (path: string) => void;
89
+ isValidSql: () => boolean;
90
+ getParsedSql: () => SqlClause[] | null;
91
+ getParseError: () => string;
92
+ }
93
+ /**
94
+ * 解析后的 SQL 数据
95
+ */
96
+ export interface ParsedSql {
97
+ clauses: SqlClause[];
98
+ raw: string;
99
+ }
@@ -0,0 +1,37 @@
1
+ import { ThemeConfig } from './types';
2
+ import { DefineComponent, ComponentOptionsMixin, PublicProps, ComponentProvideOptions } from 'vue';
3
+ interface Props {
4
+ node: any;
5
+ index: number;
6
+ level: number;
7
+ parentPath?: string;
8
+ expanded: Set<string>;
9
+ theme: ThemeConfig;
10
+ selfClosingTags?: Set<string>;
11
+ }
12
+ declare const _default: DefineComponent<Props, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
13
+ "toggle-expand": (path: string) => any;
14
+ copy: (value: any) => any;
15
+ "update:tagName": (path: string, oldTag: string, newTag: string) => any;
16
+ "update:attributeName": (path: string, oldAttrName: string, newAttrName: string) => any;
17
+ "update:attributeValue": (path: string, attrName: string, newValue: string) => any;
18
+ "update:textContent": (path: string, newContent: string) => any;
19
+ "update:cdataContent": (path: string, newContent: string) => any;
20
+ }, string, PublicProps, Readonly<Props> & Readonly<{
21
+ "onToggle-expand"?: ((path: string) => any) | undefined;
22
+ onCopy?: ((value: any) => any) | undefined;
23
+ "onUpdate:tagName"?: ((path: string, oldTag: string, newTag: string) => any) | undefined;
24
+ "onUpdate:attributeName"?: ((path: string, oldAttrName: string, newAttrName: string) => any) | undefined;
25
+ "onUpdate:attributeValue"?: ((path: string, attrName: string, newValue: string) => any) | undefined;
26
+ "onUpdate:textContent"?: ((path: string, newContent: string) => any) | undefined;
27
+ "onUpdate:cdataContent"?: ((path: string, newContent: string) => any) | undefined;
28
+ }>, {
29
+ level: number;
30
+ parentPath: string;
31
+ selfClosingTags: Set<string>;
32
+ }, {}, {}, {}, string, ComponentProvideOptions, false, {
33
+ tagNameRef: HTMLSpanElement;
34
+ cdataContentRef: HTMLSpanElement;
35
+ textContentRef: HTMLSpanElement;
36
+ }, HTMLDivElement>;
37
+ export default _default;
@@ -0,0 +1,7 @@
1
+ import { default as XmlFormat } from './index.vue';
2
+ import { default as XmlNode } from './XmlNode.vue';
3
+ export { XmlFormat, XmlNode };
4
+ export * from './types';
5
+ export * from './themes';
6
+ export * from './parser';
7
+ export default XmlFormat;
@@ -0,0 +1,27 @@
1
+ import { X as s } from "../../_chunks/index-DvNM7Tl4.js";
2
+ import { a as o, o as m, d as l, r, e as i, i as g, k as n, q as d, f as h, h as X, l as f, g as u, c as b, b as c, j as p, n as x, m as N, p as k, s as A, t as C, v as T } from "../../_chunks/index-DvNM7Tl4.js";
3
+ export {
4
+ s as XmlFormat,
5
+ o as XmlNode,
6
+ m as annotateSelfClosingInfo,
7
+ l as buildXml,
8
+ r as buildXmlFromArray,
9
+ i as compressXml,
10
+ g as countNodes,
11
+ s as default,
12
+ n as extractAttributes,
13
+ d as extractSelfClosingTags,
14
+ h as formatXml,
15
+ X as getRootNodeName,
16
+ f as getTextContent,
17
+ u as getTheme,
18
+ b as githubDark,
19
+ c as githubLight,
20
+ p as hasAttributes,
21
+ x as isEmptyNode,
22
+ N as minLight,
23
+ k as parseXml,
24
+ A as slackOchin,
25
+ C as themes,
26
+ T as validateXml
27
+ };
@@ -0,0 +1,57 @@
1
+ import { ThemeType, ParsedXml, FilterConfig } from './types';
2
+ import { DefineComponent, ComponentOptionsMixin, PublicProps, ComponentProvideOptions } from 'vue';
3
+ interface Props {
4
+ modelValue: string;
5
+ readonly?: boolean;
6
+ maxDepth?: number;
7
+ theme?: ThemeType;
8
+ showComments?: boolean;
9
+ showCdata?: boolean;
10
+ preserveWhitespace?: boolean;
11
+ }
12
+ declare const _default: DefineComponent<Props, {
13
+ copyXml: () => Promise<void>;
14
+ compressSource: () => void;
15
+ formatSource: () => void;
16
+ expandAll: () => void;
17
+ collapseAll: () => void;
18
+ toggleExpand: (path: string) => void;
19
+ filter: (config: FilterConfig) => void;
20
+ clearFilter: () => void;
21
+ sort: () => void;
22
+ clearSort: () => void;
23
+ isSorted: () => boolean;
24
+ isValidXml: () => boolean;
25
+ getParsedXml: () => ParsedXml | null;
26
+ getFilteredXml: () => ParsedXml | null;
27
+ getExpandedNodes: () => Set<string> & Omit<Set<string>, keyof Set<any>>;
28
+ getParseError: () => string;
29
+ getFilterError: () => string;
30
+ parseXmlString: (xmlString: string) => void;
31
+ copyValue: (value: any) => Promise<void>;
32
+ }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
33
+ "update:modelValue": (value: string) => any;
34
+ "copy-success": (value: string) => any;
35
+ "copy-error": (error: Error) => any;
36
+ "expand-all": () => any;
37
+ "collapse-all": () => any;
38
+ compress: (value: string) => any;
39
+ format: (value: string) => any;
40
+ }, string, PublicProps, Readonly<Props> & Readonly<{
41
+ "onUpdate:modelValue"?: ((value: string) => any) | undefined;
42
+ "onCopy-success"?: ((value: string) => any) | undefined;
43
+ "onCopy-error"?: ((error: Error) => any) | undefined;
44
+ "onExpand-all"?: (() => any) | undefined;
45
+ "onCollapse-all"?: (() => any) | undefined;
46
+ onCompress?: ((value: string) => any) | undefined;
47
+ onFormat?: ((value: string) => any) | undefined;
48
+ }>, {
49
+ theme: ThemeType;
50
+ modelValue: string;
51
+ readonly: boolean;
52
+ maxDepth: number;
53
+ showComments: boolean;
54
+ showCdata: boolean;
55
+ preserveWhitespace: boolean;
56
+ }, {}, {}, {}, string, ComponentProvideOptions, false, {}, HTMLDivElement>;
57
+ export default _default;
@@ -0,0 +1,93 @@
1
+ import { ParsedXml, XmlFormatOptions } from './types';
2
+ /**
3
+ * 默认解析选项
4
+ */
5
+ declare const defaultParserOptions: {
6
+ ignoreAttributes: boolean;
7
+ attributeNamePrefix: string;
8
+ textNodeName: string;
9
+ ignoreDeclaration: boolean;
10
+ commentPropName: string;
11
+ cdataPropName: string;
12
+ preserveOrder: boolean;
13
+ parseAttributeValue: boolean;
14
+ trimValues: boolean;
15
+ parseTagValue: boolean;
16
+ processEntities: boolean;
17
+ htmlEntities: boolean;
18
+ ignoreNameSpace: boolean;
19
+ allowBooleanAttributes: boolean;
20
+ unpairedTags: never[];
21
+ stopNodes: never[];
22
+ alwaysCreateTextNode: boolean;
23
+ };
24
+ /**
25
+ * 验证 XML 字符串
26
+ */
27
+ export declare const validateXml: (xmlString: string) => {
28
+ valid: boolean;
29
+ error?: string;
30
+ };
31
+ /**
32
+ * 解析 XML 字符串为 JSON 对象
33
+ */
34
+ export declare const parseXml: (xmlString: string, options?: Partial<typeof defaultParserOptions>) => ParsedXml;
35
+ /**
36
+ * 构建 XML 字符串
37
+ */
38
+ export declare const buildXml: (obj: ParsedXml, options?: XmlFormatOptions) => string;
39
+ /**
40
+ * 压缩 XML(移除格式化)
41
+ */
42
+ export declare const compressXml: (obj: ParsedXml, originalXml?: string) => string;
43
+ /**
44
+ * 格式化 XML 字符串
45
+ */
46
+ export declare const formatXml: (xmlString: string, options?: XmlFormatOptions) => string;
47
+ /**
48
+ * 从 XML 字符串中提取根节点名称
49
+ */
50
+ export declare const getRootNodeName: (xmlString: string) => string | null;
51
+ /**
52
+ * 统计 XML 节点数量
53
+ */
54
+ export declare const countNodes: (obj: ParsedXml) => number;
55
+ /**
56
+ * 检查是否有属性
57
+ */
58
+ export declare const hasAttributes: (node: any) => boolean;
59
+ /**
60
+ * 提取属性对象
61
+ */
62
+ export declare const extractAttributes: (node: any) => Record<string, string>;
63
+ /**
64
+ * 获取文本内容
65
+ */
66
+ export declare const getTextContent: (node: any) => string | null;
67
+ /**
68
+ * 判断是否为空节点
69
+ */
70
+ export declare const isEmptyNode: (node: any) => boolean;
71
+ /**
72
+ * 为已解析的 XML 数据(preserveOrder: true 格式)按文档顺序(DFS)注解自闭合状态
73
+ * 在每个元素对象上添加 ':selfClosing' 键,供 XmlNode 渲染时直接读取
74
+ * 必须在 parseXml() 之后、渲染前调用一次
75
+ */
76
+ export declare const annotateSelfClosingInfo: (data: any[], originalXml: string) => void;
77
+ /**
78
+ * 提取原始 XML 中的自闭合标签信息
79
+ */
80
+ export declare const extractSelfClosingTags: (xmlString: string) => Set<string>;
81
+ /**
82
+ * 从 preserveOrder 数组结构构建格式化的 XML 字符串
83
+ */
84
+ export declare const buildXmlFromArray: (data: any[], options?: {
85
+ indent?: string;
86
+ level?: number;
87
+ format?: boolean;
88
+ selfClosingTags?: Set<string>;
89
+ selfClosingOccurrences?: Map<string, boolean[]>;
90
+ selfClosingCounters?: Map<string, number>;
91
+ originalXml?: string;
92
+ }) => string;
93
+ export {};